php-general Digest 2 Feb 2008 09:29:32 -0000 Issue 5270

Topics (messages 268543 through 268558):

Re: Search function not working...
        268543 by: Jim Lucas

Posting Summary for Week Ending 1 February, 2008: [EMAIL PROTECTED]
        268544 by: PostTrack [Dan Brown]

Calling All Opinionated ******** ....
        268545 by: Jochem Maas
        268546 by: Warren Vail
        268547 by: Eric Butera
        268548 by: Greg Donald
        268549 by: Mr Webber
        268550 by: Jochem Maas
        268555 by: Paul Scott

Re: Timeout while waiting for a server->client transfer to  start (large files)
        268551 by: szalinski
        268552 by: Casey

Re: PEAR website and MSIE 6 (M$ forcing IE7)
        268553 by: Daevid Vincent
        268556 by: mike

Redirecting STDERR to a file?
        268554 by: js
        268557 by: Per Jessen
        268558 by: js

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Jason Pruim wrote:
So I said in another thread that I would be asking another question about functions... So here it goes, I am attempting to write a function to search the database, which used to work just fine when I wrote it without using a function (Would that be considered static?) Now that I am attempting to rewrite my stuff so I can reuse the code, now it's not working... Here is what I used to do and it worked just fine:


$qstring = "SELECT * FROM ".$table." WHERE FName like '%$search%' or LName like '%$search%' or Add1 like '%$search%' or Add2 like '%$search%' or City like '%$search%' or State like '%$search%' or Zip like '%$search%' or XCode like '%$search%'";
if ($_SESSION['search'] != NULL){
    echo "The search string is: <strong>$search</strong>.<BR>";
    $qrow[]= mysql_query($qstring) or die(mysql_error());
    $qresult = $qrow[0];
    $num_rows = mysql_num_rows($qresult);
    //display search form
        echo "
            <form action='search.php' method='GET'>
            <label>Search:
            <input type='text' name='search' id='search' />
            </label>
            <input type='submit' value='Go!' />
        </form>";

echo <<<HTML
    <a href='index.php'>Return to database</A>
    <P>Total Records found: {$num_rows}</P>
    <A href='excelexport.php'>Export selection to excel</A>
    <form method='GET' action='edit.php'>
    <table border='1'>
        <tr>
        <th><a href='?order=a'>First Name</A></th>
        <th><A href='?order=b'>Last Name</A></th>
        <th><A href='?order=c'>Address Line 1</A></th>
        <TH><A href='?order=d'>Address Line 2</A></th>
        <TH><A href='?order=e'>City</A></th>
        <th><A href='?order=f'>State</A></th>
        <th><A href='?order=g'>Zip</A></th>
        <TH><A href='?order=h'>Code</A></th>
        <th><A href='?order=i'>ID #</A></th>
        <TH>Edit</th>
        <th>Delete</th>
    </tr>
HTML;
    echo "Just testing: ".$_SESSION['search'];
while($qrow = mysql_fetch_assoc($qresult)) {
    //Display the search results using heredoc syntax
echo <<<HTML
<tr> <td>{$qrow['FName']}</td>
        <td>{$qrow['LName']}</td>
        <td>{$qrow['Add1']}</td>
        <td>{$qrow['Add2']}</td>
        <td>{$qrow['City']}</td>
        <td>{$qrow['State']}</td>
        <td>{$qrow['Zip']}</td>
        <td>{$qrow['XCode']}</td>
        <td>{$qrow['Record']}</td>
        <td><a href='edit.php?Record={$qrow['Record']}'>Edit</a></td>
        <td><a href='delete.php?Record={$qrow['Record']}'>Delete</a></td>
    </tr>
</form>
HTML;

Now, here is what I have as a function and is not working:

<?PHP
$FName ="";
$LName ="";
$Add1 = "";
$Add2 = "";
//        $_SESSION['search'] = $_GET['search'];
function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2) { $qstring = "SELECT * FROM ".$table." WHERE FName like '%$searchvar%' or LName like '%$searchvar%' or Add1 like '%$searchvar%' or Add2 like '%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar%' or Zip like '%$searchvar%' or XCode like '%$searchvar%'";
        $qrow[]= mysql_query($qstring) or die(mysql_error());
        $qresult = $qrow[0];
        $num_rows = mysql_num_rows($qresult);
//while($qrow = mysql_fetch_assoc($qresult)) { $FName = $qrow['FName'];
    $LName = $qrow['LName'];
    $Add1 = $qrow['Add1'];
    $Add2 = $qrow['Add2'];
        return;
} ?>

And what happens, is first of all it displays the entire database on the search page, which I'm kind of okay with... But when you search, it updates the variables, and echo's out the right search term, but it doesn't update the database to only show the search results... I think it might be tied to it displaying the entire database at page load... But I'm not sure.. Anyone have an idea of what I did wrong other then everything? :)


Oh, and as far as calling the function I do this: search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2);



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Ok, here would be my rendition of this function.

<?php

function search($searchvar, $table) {

        // Since we want to ensure that we have good data before we run our
        // query, we want to clear our search data before we use it
        $clean_searchvar = mysql_real_escape_string($searchvar);

        // Build our SQL statement
        $SQL = "SELECT     *
                FROM    {$table}
                WHERE   FName   LIKE '%{$clean_searchvar}%'
                OR      LName   LIKE '%{$clean_searchvar}%'
                OR      Add1    LIKE '%{$clean_searchvar}%'
                OR      Add2    LIKE '%{$clean_searchvar}%'
                OR      City    LIKE '%{$clean_searchvar}%'
                OR      State   LIKE '%{$clean_searchvar}%'
                OR      Zip     LIKE '%{$clean_searchvar}%'
                OR      XCode   LIKE '%{$clean_searchvar}%'";

        // Process SQL statement, continue on success or display error
        $res = mysql_query($SQL) or die(mysql_error());

        // Initialize array to contain data set from DB
        $results = array();

        // Check to make sure their is a result set
        if ( mysql_num_rows($res) > 0 ) {

                // Loop through result set
                while ( $row = mysql_fetch_assoc($res) ) {

                        // Place returned row of data into our results array
                        $results[] = $row;

                }

        }

        // Return result set of data, or blank array
        return $results;

}


// $_SESSION['search'] = $_GET['search'];
$searchvar = 'something you want to search for';

// Call function
$dataSet = search($searchvar, 'myTable');

// Get the number of results returned
$num_rows = count($dataSet);

?>

if the above code get messed up by the email, check out this link.

http://www.cmsws.com/examples/php/testscripts/[EMAIL 
PROTECTED]/Search_function_not_working.php

This should return to you all the information you need.

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--- End Message ---
--- Begin Message ---
        Posting Summary for PHP-General List
        Week Ending: Friday, 1 February, 2008

        Messages            | Bytes              | Sender
        --------------------+--------------------+------------------
        403 (100%)          717988 (100%)       EVERYONE
        54     (13.4%)     61663   (8.6%)      Nathan Nobbe <quickshiftin at 
gmail dot com>
        38     (9.4%)      56548   (7.9%)      Richard Lynch <ceo at l-i-e dot 
com>
        37     (9.2%)      62959   (8.8%)      Jochem Maas <jochem at iamjochem 
dot com>
        34     (8.4%)      30253   (4.2%)      Per Jessen <per at computer dot 
org>
        24     (6%)        44984   (6.3%)      Robert Cummings <robert at 
interjinn dot com>
        18     (4.5%)      29650   (4.1%)      Eric Butera <eric dot butera at 
gmail dot com>
        17     (4.2%)      21616   (3%)        Greg Donald <gdonald at gmail 
dot com>
        13     (3.2%)      29709   (4.1%)      Jim Lucas <lists at cmsws dot 
com>
        12     (3%)        23082   (3.2%)      Jason Pruim <japruim at raoset 
dot com>
        12     (3%)        15590   (2.2%)      Paul Scott <pscott at uwc dot ac 
dot za>
        12     (3%)        18692   (2.6%)      Stut <stuttle at gmail dot com>
        12     (3%)        29611   (4.1%)      Zoltán Németh <znemeth at 
alterationx dot hu>
        8      (2%)        5256    (0.7%)      Richard Heyes <richardh at 
phpguru dot org>
        7      (1.7%)      10847   (1.5%)      Tom Chubb <tomchubb at gmail dot 
com>
        7      (1.7%)      8182    (1.1%)      Nathan Rixham <nrixham at gmail 
dot com>
        6      (1.5%)      7308    (1%)        Chris <dmagick at gmail dot com>
        4      (1%)        10478   (1.5%)      Janet N <janet9k at gmail dot 
com>
        4      (1%)        8541    (1.2%)      Michael Fischer <michi dot 
fischer at gmx dot net>
        4      (1%)        4864    (0.7%)      Andrew Ballard <aballard at 
gmail dot com>
        3      (0.7%)      11368   (1.6%)      David Giragosian <dgiragosian at 
gmail dot com>
        3      (0.7%)      6707    (0.9%)      Mr Webber <captain_webber at 
hotmail dot com>
        3      (0.7%)      4189    (0.6%)      Anup Shukla <anup dot shkl at 
gmail dot com>
        3      (0.7%)      7737    (1.1%)      Mike Morton <mike at webtraxx 
dot com>
        3      (0.7%)      5654    (0.8%)      nihilism machine 
<nihilismmachine at gmail dot com>
        3      (0.7%)      29192   (4.1%)      Umar <unix dot co at gmail dot 
com>
        3      (0.7%)      20380   (2.8%)      Andrés Robinet <agrobinet at 
bestplace dot biz>
        3      (0.7%)      9477    (1.3%)      Michael Fischer <michi dot 
fischer at gmx dot net>
        2      (0.5%)      73397   (10.2%)     philip <spy_c_xamaican at rogers 
dot com>
        2      (0.5%)      1637    (0.2%)      jekillen <jekillen at prodigy 
dot net>
        2      (0.5%)      1816    (0.3%)      Casey <heavyccasey at gmail dot 
com>
        2      (0.5%)      2105    (0.3%)      Colin Guthrie <gmane at colin 
dot guthr dot ie>
        2      (0.5%)      974     (0.1%)      M dot  Sokolewicz <tularis at 
php dot net>
        2      (0.5%)      1021    (0.1%)      Mike Yrabedra <lists at 323inc 
dot com>
        2      (0.5%)      1824    (0.3%)      Kyohere Luke <pr0f3t at gmail 
dot com>
        2      (0.5%)      3617    (0.5%)      Daevid Vincent <daevid at daevid 
dot com>
        1      (0.2%)      611     (0.1%)      Peter Jackson <tasmaniac at 
iprimus dot com dot au>
        1      (0.2%)      2975    (0.4%)      PHP Employer <resumes at 
worldnetjobs dot com>
        1      (0.2%)      1824    (0.3%)      Gaudett Kacerski <stoutening at 
contracostatimes dot com>
        1      (0.2%)      625     (0.1%)      Christoph Boget <christoph dot 
boget at gmail dot com>
        1      (0.2%)      1816    (0.3%)      Lagrow Cordaro <loyalists at 
abgender dot com>
        1      (0.2%)      1782    (0.2%)      Dax Solomon Umaming <knightlust 
at gmail dot com>
        1      (0.2%)      769     (0.1%)      Bill Guion <bguion at comcast 
dot net>
        1      (0.2%)      1009    (0.1%)      mike <mike503 at gmail dot com>
        1      (0.2%)      441     (0.1%)      Floor Terra <floort at gmail dot 
com>
        1      (0.2%)      708     (0.1%)      Isaac Gouy <igouy2 at yahoo dot 
com>
        1      (0.2%)      520     (0.1%)      jeffry s <paragasu at gmail dot 
com>
        1      (0.2%)      5682    (0.8%)      Michael McGlothlin <michaelm at 
swplumb dot com>
        1      (0.2%)      841     (0.1%)      Manuel Lemos <mlemos at acm dot 
org>
        1      (0.2%)      983     (0.1%)      Brady Mitchell <mydarb at gmail 
dot com>
        1      (0.2%)      1361    (0.2%)      Bastien Koert <bastien_k at 
hotmail dot com>
        1      (0.2%)      820     (0.1%)      Zbigniew Szalbot <zszalbot at 
gmail dot com>
        1      (0.2%)      1229    (0.2%)      greenCountry <adityavit at gmail 
dot com>
        1      (0.2%)      1147    (0.2%)      <resumes at worldnetjobs dot com>
        1      (0.2%)      584     (0.1%)      Barney Tramble <barneytramble at 
gmail dot com>
        1      (0.2%)      1093    (0.2%)      Ravi Menon <jravimenon at gmail 
dot com>
        1      (0.2%)      1392    (0.2%)      Chuck <chuck dot carson at gmail 
dot com>
        1      (0.2%)      10049   (1.4%)      Daniel Brown <parasane at gmail 
dot com>
        1      (0.2%)      1849    (0.3%)      Radmall Overbaugh <learner at 
centerstagechicago dot com>
        1      (0.2%)      296     (0%)        little btx <btxlittle at gmail 
dot com>
        1      (0.2%)      1186    (0.2%)      Kevin Eppinger <ke7227 at 
sbcglobal dot net>
        1      (0.2%)      249     (0%)        Jay Blanchard <jblanchard at 
pocket dot com>
        1      (0.2%)      579     (0.1%)      Teck <tek dot katu at gmail dot 
com>
        1      (0.2%)      837     (0.1%)      Max Antonov <idler at instanceof 
dot ru>
        1      (0.2%)      674     (0.1%)      skylark <myphplist at gmail dot 
com>
        1      (0.2%)      818     (0.1%)      Nisse Engström <news dot NOSPAM 
dot 0ixbtqKe at luden dot se>
        1      (0.2%)      2025    (0.3%)      Erik Stackhouse <erik at 
holistictech dot net>
        1      (0.2%)      962     (0.1%)      Brady Mitchell <mydarb at gmail 
dot com>
        1      (0.2%)      1081    (0.2%)      Mick <asurfer at iinet dot net 
dot au>
        1      (0.2%)      820     (0.1%)      Christoph Boget <jcboget at 
yahoo dot com>
        1      (0.2%)      1079    (0.2%)      tedd <tedd dot sperling at gmail 
dot com>
        1      (0.2%)      3070    (0.4%)      Strader, William A dot  <WILLIAM 
dot A dot STRADER at saic dot com>
        1      (0.2%)      465     (0.1%)      John Papas <jspapas at gmail dot 
com>
        1      (0.2%)      473     (0.1%)      Mike Potter <ssskibeh at gmail 
dot com>
        1      (0.2%)      1800    (0.3%)      Steve Edberg <sbedberg at 
ucdavis dot edu>
        1      (0.2%)      536     (0.1%)      Don Don <progwihz at yahoo dot 
com>


NOTE: Numbers may not add up to 100% due to protection of names and addresses 
upon request.

DISCLAIMER: If you want your email address omitted from future weekly reports,
please email me privately at [EMAIL PROTECTED] and it will be removed.

--- End Message ---
--- Begin Message ---
hi people,

I'm in the market for a new framework/toolkit/whatever-you-want-to-call-it.
I've been taking a good hard look at the Zend Framework - if nothing else the 
docs
are very impressive.

I'd like to hear from people who have or are using ZF with regard to their
experiences, dislikes, likes, problems, new found fame and fortune, etc ... but
only if it concerns ZF.

I don't need to hear stuff like 'use XYZ it's great' - finding php 
frameworks/CMS/etc
is easy ... figuring out which are best of breed is another matter, if only 
because
it involves reading zillions of lines of code and documentation. besides I find 
that
you only ever get bitten in the ass by short-comings and bugs when your 80% 
into the
project that needs to be online yesterday and you knee deep in a nightmare 
requirements
change or tackling some PITA performance issue.

so people, roll out your ZF love stories and nightmares - spare no details - 
share the
knowledge. or something :-)

tia,
Jochem

--- End Message ---
--- Begin Message ---
These things are all on the bleeding edge, and if I'm not mistaken, Zend may
be one of the newest, no?  Extrapolate (Bleeding Edge = painful development)

Warren Vail

> -----Original Message-----
> From: Jochem Maas [mailto:[EMAIL PROTECTED]
> Sent: Friday, February 01, 2008 1:18 PM
> To: [php] PHP General List
> Subject: [PHP] Calling All Opinionated ******** ....
> 
> hi people,
> 
> I'm in the market for a new framework/toolkit/whatever-you-want-to-call-
> it.
> I've been taking a good hard look at the Zend Framework - if nothing else
> the docs
> are very impressive.
> 
> I'd like to hear from people who have or are using ZF with regard to their
> experiences, dislikes, likes, problems, new found fame and fortune, etc
> ... but
> only if it concerns ZF.
> 
> I don't need to hear stuff like 'use XYZ it's great' - finding php
> frameworks/CMS/etc
> is easy ... figuring out which are best of breed is another matter, if
> only because
> it involves reading zillions of lines of code and documentation. besides I
> find that
> you only ever get bitten in the ass by short-comings and bugs when your
> 80% into the
> project that needs to be online yesterday and you knee deep in a nightmare
> requirements
> change or tackling some PITA performance issue.
> 
> so people, roll out your ZF love stories and nightmares - spare no details
> - share the
> knowledge. or something :-)
> 
> tia,
> Jochem
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
On Feb 1, 2008 4:18 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> hi people,
>
> I'm in the market for a new framework/toolkit/whatever-you-want-to-call-it.
> I've been taking a good hard look at the Zend Framework - if nothing else the 
> docs
> are very impressive.
>
> I'd like to hear from people who have or are using ZF with regard to their
> experiences, dislikes, likes, problems, new found fame and fortune, etc ... 
> but
> only if it concerns ZF.
>
> I don't need to hear stuff like 'use XYZ it's great' - finding php 
> frameworks/CMS/etc
> is easy ... figuring out which are best of breed is another matter, if only 
> because
> it involves reading zillions of lines of code and documentation. besides I 
> find that
> you only ever get bitten in the ass by short-comings and bugs when your 80% 
> into the
> project that needs to be online yesterday and you knee deep in a nightmare 
> requirements
> change or tackling some PITA performance issue.
>
> so people, roll out your ZF love stories and nightmares - spare no details - 
> share the
> knowledge. or something :-)
>
> tia,
> Jochem
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

So far I've only used the Zend_Mail functionality and it beats
everything else I've tried as far as extensibility and performance are
concerned.  I've tried out several different packages and it just
wins.

The docs are great, it has unit tests on all parts of it, and there
are lots of eyes looking over it, it's a no brainer!

--- End Message ---
--- Begin Message ---
On 2/1/08, Jochem Maas <[EMAIL PROTECTED]> wrote:
> I'm in the market for a new framework/toolkit/whatever-you-want-to-call-it.
> I've been taking a good hard look at the Zend Framework - if nothing else the 
> docs
> are very impressive.
>
> I'd like to hear from people who have or are using ZF with regard to their
> experiences, dislikes, likes, problems, new found fame and fortune, etc ... 
> but
> only if it concerns ZF.
>
> I don't need to hear stuff like 'use XYZ it's great' - finding php 
> frameworks/CMS/etc
> is easy ... figuring out which are best of breed is another matter, if only 
> because
> it involves reading zillions of lines of code and documentation. besides I 
> find that
> you only ever get bitten in the ass by short-comings and bugs when your 80% 
> into the
> project that needs to be online yesterday and you knee deep in a nightmare 
> requirements
> change or tackling some PITA performance issue.
>
> so people, roll out your ZF love stories and nightmares - spare no details - 
> share the
> knowledge. or something :-)

Hilarious.  "I'm in the market for a new framework, but please only
tell me about ZF because I don't want to spend my own time researching
stuff for myself."  Since when is learning something new a crime?  Why
are you even a programmer?

ZF works fine if you don't mind all the bloated OO PHP.  Use it or don't.


-- 
Greg Donald
http://destiney.com/

--- End Message ---
--- Begin Message ---
My thoughts, exactly.  I had to count to 10 to keep myself from replying to
"His Rudeness".

-----Original Message-----
From: Greg Donald [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 01, 2008 5:17 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Calling All Opinionated ******** ....

On 2/1/08, Jochem Maas <[EMAIL PROTECTED]> wrote:
> I'm in the market for a new
framework/toolkit/whatever-you-want-to-call-it.
> I've been taking a good hard look at the Zend Framework - if nothing else
the docs
> are very impressive.
>
> I'd like to hear from people who have or are using ZF with regard to their
> experiences, dislikes, likes, problems, new found fame and fortune, etc
.. but
> only if it concerns ZF.
>
> I don't need to hear stuff like 'use XYZ it's great' - finding php
frameworks/CMS/etc
> is easy ... figuring out which are best of breed is another matter, if
only because
> it involves reading zillions of lines of code and documentation. besides I
find that
> you only ever get bitten in the ass by short-comings and bugs when your
80% into the
> project that needs to be online yesterday and you knee deep in a nightmare
requirements
> change or tackling some PITA performance issue.
>
> so people, roll out your ZF love stories and nightmares - spare no details
- share the
> knowledge. or something :-)

Hilarious.  "I'm in the market for a new framework, but please only
tell me about ZF because I don't want to spend my own time researching
stuff for myself."  Since when is learning something new a crime?  Why
are you even a programmer?

ZF works fine if you don't mind all the bloated OO PHP.  Use it or don't.


-- 
Greg Donald
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Greg Donald schreef:
On 2/1/08, Jochem Maas <[EMAIL PROTECTED]> wrote:
I'm in the market for a new framework/toolkit/whatever-you-want-to-call-it.
I've been taking a good hard look at the Zend Framework - if nothing else the 
docs
are very impressive.

I'd like to hear from people who have or are using ZF with regard to their
experiences, dislikes, likes, problems, new found fame and fortune, etc ... but
only if it concerns ZF.

I don't need to hear stuff like 'use XYZ it's great' - finding php 
frameworks/CMS/etc
is easy ... figuring out which are best of breed is another matter, if only 
because
it involves reading zillions of lines of code and documentation. besides I find 
that
you only ever get bitten in the ass by short-comings and bugs when your 80% 
into the
project that needs to be online yesterday and you knee deep in a nightmare 
requirements
change or tackling some PITA performance issue.

so people, roll out your ZF love stories and nightmares - spare no details - 
share the
knowledge. or something :-)

Hilarious.  "I'm in the market for a new framework, but please only
tell me about ZF because I don't want to spend my own time researching
stuff for myself."

you need some glasses?  I've just spent 4 hours reading
ZF documentation and code ... today - I've played with it in the past
but it was still beta at that time. I'm starting to take another look,
but no ammount of playing with it or reading documentation will tell me
if I'm going to have major regrets about choosing ZF for a large project
when I'm 400 hours into it and stuck with a deadline and an impossible
situation.

funnily enough I'm not capable of researching inside someone else's head
when it comes to *their opinion*, more specifically people who you are familiar
with to soome degree, whereby you able to gauge to a better extent how relevant
the opinion/experience offered is to one's own situation.

Since when is learning something new a crime?

and where do you go to learn someone else's opinion?

Why
are you even a programmer?

something bothering you? got out of the wrong side of bed today?

ZF works fine if you don't mind all the bloated OO PHP.  Use it or don't.

brilliant advice, you we're on better form yesterday my friend.



--- End Message ---
--- Begin Message ---
On Fri, 2008-02-01 at 22:18 +0100, Jochem Maas wrote:
> I'd like to hear from people who have or are using ZF with regard to their
> experiences, dislikes, likes, problems, new found fame and fortune, etc ... 
> but
> only if it concerns ZF.
> 

I have integrated a few ZF components into the Chisimba framework -
search_lucene, Http_request, and a few others so far, and they are OK. I
find some of the bits really slow, but solid, others perform well.

My biggest gripe with ZF components is that the Exception handler
Zend_Exception, is sometimes tricky to override with the native Chisimba
customException handler (which produces pretty output as opposed to an
ugly call stack, and logs the ugly things (user wise) to a log file).
Sometimes it takes a few more minutes of time.

Basically, I would say evaluate each component on its own merit. If you
would like to use one, check the code and run some performance tests on
it - sometimes you will be able to roll your own in less time and with
simpler code.

--Paul 

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

--- End Message ---
--- Begin Message ---
On Thu, 31 Jan 2008 07:13:55 -0000, Per Jessen <[EMAIL PROTECTED]> wrote:

Richard Lynch wrote:

Your script is reading the whole file, 64 measly bytes at a time, into
a monstrous string $tmp.

Then, finally, when you've loaded the whole [bleep] file into RAM in
$tmp, you just echo it out, right?

Don't do that.

:-)

while (!feof($fp)){
  echo fread($fp, 2048);
}


And if the OP is opening the file anyway, he might as well use
readfile() instead.


/Per Jessen, Zürich

Well I got it to work, much thanks to Richard Lynch, but now everytime I download a file, it is corrupt. For example, when I download small .rar file, just to test, it is always corrupt ('Unexpected end of archive'). I also cleared my browser cache just to be sure, but same problem.

Here is the code as it stands. I just can't get my head around why it wouldn't be working as it is...

<?php

//ob_start();
//ob_end_flush();
//ob_implicit_flush(TRUE);

$rslogin = '';
$rspass = '';
$link = addslashes(trim($_POST['link']));

function cut_str($str, $left, $right)
  {
  $str = substr(stristr($str, $left), strlen($left));
  $leftLen = strlen(stristr($str, $right));
  $leftLen = $leftLen ? -($leftLen) : strlen($str);
  $str = substr($str, 0, $leftLen);
  return $str;
  }

// Get the full premium link, and store it in $full_link after the redirect. *Surely* there is an easier way to get redirections?

if(strlen($link)>0)
{
        $url = @parse_url($link);
        $fp = @fsockopen($url['host'], 80, $errno, $errstr);
        if (!$fp)
        {
            $errormsg = "Error: <b>$errstr</b>, please try again later.";
            echo $errormsg;
            exit;
        }

                        $vars = 
"dl.start=PREMIUM&uri={$url['path']}&directstart=1";
                        $out = "POST {$url['path']} HTTP/1.1\r\n";
                        $out .= "Host: {$url['host']}\r\n";
$out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n"; $out .= "Authorization: Basic ".base64_encode("{$rslogin}:{$rspass}")."\r\n";
                        $out .= "Content-Type: 
application/x-www-form-urlencoded\r\n";
                        $out .= "Content-Length: ".strlen($vars)."\r\n";
                        $out .= "Connection: Close\r\n\r\n";
                        fwrite($fp, $out);
                        fwrite($fp, $out.$vars);
                        while (!feof($fp))
                        {
                        $string .= fgets($fp, 256);
                        }
                         //Tell us what data is returned
                         //print($string);
                        @fclose($fp);

                        if (stristr($string, "Location:"))
                        {
                                $redirect = trim(cut_str($string, "Location:", 
"\n"));
                                $full_link = addslashes(trim($redirect));
                        }

//print($string);
//print("<html><body><h1>".$full_link."</h1>");


        
if ($full_link)

        {

        //      Get info about the file we want to download:
        
                $furl = parse_url($full_link);
        $fvars = "dl.start=PREMIUM&uri={$furl['path']}&directstart=1";
        $head = "Host: {$furl['host']}\r\n";
$head .= "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n"; $head .= "Authorization: Basic ".base64_encode("{$rslogin}:{$rspass}")."\r\n";
        $head .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $head .= "Content-Length: ".strlen($fvars)."\r\n";
        $head .= "Connection: close\r\n\r\n";
        $fp = @fsockopen($furl['host'], 80, $errno, $errstr);
        if (!$fp)
        {
            echo "The script says <b>$errstr</b>, please try again later.";
            exit;
        }
        fwrite($fp, "POST {$furl['path']}  HTTP/1.1\r\n");
        fwrite($fp, $head.$fvars);
        while (!feof($fp))
        {
//Keep reading the info until we get the filename and size from the returned Header - is there no easy way //of doing this? I also don't like the way I have to 'find' the redirected link (above).??
            $tmp .= fgets($fp, 256);
                        $d = explode("\r\n\r\n", $tmp);
                        
// I tried changing this to if ($d), { etc.., (instead of $d[1]) and the download of the rar file *wasn't* corrupt, it just had a filetype of x-rar-compressed instead of //application/octet-stream, and the filesize was 'unknown' - now this is just confusing me...! So i think (and guess) the problem of the file corruption is here, //because it must add some data to the filestream which corrupts it. Darn.
                        if($d[1])
            {
                preg_match("#filename=(.+?)\n#", $tmp, $fname);
                preg_match("#Content-Length: (.+?)\n#", $tmp, $fsize);
$h['filename'] = $fname[1] != "" ? $fname[1] : basename($furl['path']);
                $h['fsize'] = $fsize[1];
                                break;
            }
                        
}
        @fclose($fp);           

        $filename = $h['filename'];
        $fsize = $h['fsize'];

//Now automatically download the file:
        
        @header("Cache-Control:");
        @header("Cache-Control: public");
        @header("Content-Type: application/octet-stream");
        @header("Content-Disposition: attachment; filename=".$filename);
        @header("Accept-Ranges: bytes");
        if(isset($_SERVER['HTTP_RANGE']))
        {
            list($a, $range)=explode("=",$_SERVER['HTTP_RANGE']);
            $range = str_replace("-", "", $range);
            $new_length = $fsize - $range;
            @header("HTTP/1.1 206 Partial Content");
            @header("Content-Length: $new_length");
        }
        else
        {
            @header("Content-Length: ".$fsize);
        }
        $f2vars = "dl.start=PREMIUM&uri={$furl['path']}&directstart=1";
        $head2 = "Host: {$furl['host']}\r\n";
$head2 .= "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n"; $head2 .= "Authorization: Basic ".base64_encode("{$rslogin}:{$rspass}")."\r\n";
        $head2 .= "Content-Type: application/x-www-form-urlencoded\r\n";
        if($range != "") $head2 .= "Range: bytes={$range}-\r\n";
        $head2 .= "Content-Length: ".strlen($fvars)."\r\n";
        $head2 .= "Connection: close\r\n\r\n";
        $fp = @fsockopen($furl['host'], 80, $errno, $errstr);
        if (!$fp)
        {
echo "<span style='color:#688000; background-color:#BBDB54; font-size : 10pt; text-decoration: none; font-family: Trebuchet MS;'>The script says <b>$errstr</b>, please try again later.</span>";
            exit;
        }
        @stream_set_timeout($fp, 120);
        fwrite($fp, "POST {$furl['path']}  HTTP/1.1\r\n");
        fwrite($fp, $head2.$f2vars);
        fflush($fp);
        while (!feof($fp))
        {
            $download = fread($fp, 2048);
                        echo $download;
            //ob_flush(); //php.net suggestion
        }

//These two buggers were here originally, but I don't even know if I am supposed to have them here.
         flush();
         ob_flush();
       @fclose($fp);
        exit;

        }


}
else
{
        $data = "<form method=\"post\">\n";
$data .= "<input type=\"text\" id=\"link\" style=\"text-align:center\" name=\"link\" size=\"60\" onfocus=\"if(this.value=='Enter rapidshare.com URL here'){this.value=''}\">\n";
        $data .= "<br><input type=\"submit\" value=\"Download\"></form>";
        echo $data;
}
?>

Thanks to anyone who has already helped, I hope some genius can spot an obvious error, because this is just beyond me!
--- End Message ---
--- Begin Message ---
On Feb 1, 2008, at 5:45 PM, szalinski <[EMAIL PROTECTED]> wrote:

On Thu, 31 Jan 2008 07:13:55 -0000, Per Jessen <[EMAIL PROTECTED]> wrote:

Richard Lynch wrote:

Your script is reading the whole file, 64 measly bytes at a time, into
a monstrous string $tmp.

Then, finally, when you've loaded the whole [bleep] file into RAM in
$tmp, you just echo it out, right?

Don't do that.

:-)

while (!feof($fp)){
 echo fread($fp, 2048);
}


And if the OP is opening the file anyway, he might as well use
readfile() instead.


/Per Jessen, Zürich

Well I got it to work, much thanks to Richard Lynch, but now everytime I download a file, it is corrupt. For example, when I download small .rar file, just to test, it is always corrupt ('Unexpected end of archive'). I also cleared my browser cache just to be sure, but same problem.

Here is the code as it stands. I just can't get my head around why it wouldn't be working as it is...

<?php

//ob_start();
//ob_end_flush();
//ob_implicit_flush(TRUE);

$rslogin = '';
$rspass = '';
$link = addslashes(trim($_POST['link']));

function cut_str($str, $left, $right)
 {
 $str = substr(stristr($str, $left), strlen($left));
 $leftLen = strlen(stristr($str, $right));
 $leftLen = $leftLen ? -($leftLen) : strlen($str);
 $str = substr($str, 0, $leftLen);
 return $str;
 }

// Get the full premium link, and store it in $full_link after the redirect. *Surely* there is an easier way to get redirections?

if(strlen($link)>0)
{
   $url = @parse_url($link);
   $fp = @fsockopen($url['host'], 80, $errno, $errstr);
   if (!$fp)
       {
$errormsg = "Error: <b>$errstr</b>, please try again later.";
           echo $errormsg;
           exit;
       }

$vars = "dl.start=PREMIUM&uri={$url['path']} &directstart=1";
           $out = "POST {$url['path']} HTTP/1.1\r\n";
           $out .= "Host: {$url['host']}\r\n";
$out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n"; $out .= "Authorization: Basic ".base64_encode("{$rslogin}: {$rspass}")."\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r \n";
           $out .= "Content-Length: ".strlen($vars)."\r\n";
           $out .= "Connection: Close\r\n\r\n";
           fwrite($fp, $out);
           fwrite($fp, $out.$vars);
           while (!feof($fp))
           {
           $string .= fgets($fp, 256);
           }
            //Tell us what data is returned
            //print($string);
           @fclose($fp);

           if (stristr($string, "Location:"))
           {
               $redirect = trim(cut_str($string, "Location:", "\n"));
               $full_link = addslashes(trim($redirect));
           }

//print($string);
//print("<html><body><h1>".$full_link."</h1>");



if ($full_link)

   {

   //    Get info about the file we want to download:

       $furl = parse_url($full_link);
       $fvars = "dl.start=PREMIUM&uri={$furl['path']}&directstart=1";
       $head = "Host: {$furl['host']}\r\n";
$head .= "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n"; $head .= "Authorization: Basic ".base64_encode("{$rslogin}: {$rspass}")."\r\n";
       $head .= "Content-Type: application/x-www-form-urlencoded\r\n";
       $head .= "Content-Length: ".strlen($fvars)."\r\n";
       $head .= "Connection: close\r\n\r\n";
       $fp = @fsockopen($furl['host'], 80, $errno, $errstr);
       if (!$fp)
       {
echo "The script says <b>$errstr</b>, please try again later.";
           exit;
       }
       fwrite($fp, "POST {$furl['path']}  HTTP/1.1\r\n");
       fwrite($fp, $head.$fvars);
       while (!feof($fp))
       {
//Keep reading the info until we get the filename and size from the returned Header - is there no easy way //of doing this? I also don't like the way I have to 'find' the redirected link (above).??
           $tmp .= fgets($fp, 256);
           $d = explode("\r\n\r\n", $tmp);

// I tried changing this to if ($d), { etc.., (instead of $d[1]) and the download of the rar file *wasn't* corrupt, it just had a filetype of x-rar-compressed instead of //application/octet-stream, and the filesize was 'unknown' - now this is just confusing me...! So i think (and guess) the problem of the file corruption is here, //because it must add some data to the filestream which corrupts it. Darn.
           if($d[1])
           {
               preg_match("#filename=(.+?)\n#", $tmp, $fname);
               preg_match("#Content-Length: (.+?)\n#", $tmp, $fsize);
$h['filename'] = $fname[1] != "" ? $fname[1] : basename($furl['path']);
               $h['fsize'] = $fsize[1];
               break;
           }

}
       @fclose($fp);

       $filename = $h['filename'];
       $fsize = $h['fsize'];

//Now automatically download the file:

       @header("Cache-Control:");
       @header("Cache-Control: public");
       @header("Content-Type: application/octet-stream");
@header("Content-Disposition: attachment; filename=". $filename);
       @header("Accept-Ranges: bytes");
       if(isset($_SERVER['HTTP_RANGE']))
       {
           list($a, $range)=explode("=",$_SERVER['HTTP_RANGE']);
           $range = str_replace("-", "", $range);
           $new_length = $fsize - $range;
           @header("HTTP/1.1 206 Partial Content");
           @header("Content-Length: $new_length");
       }
       else
       {
           @header("Content-Length: ".$fsize);
       }
       $f2vars = "dl.start=PREMIUM&uri={$furl['path']}&directstart=1";
       $head2 = "Host: {$furl['host']}\r\n";
$head2 .= "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n"; $head2 .= "Authorization: Basic ".base64_encode("{$rslogin}: {$rspass}")."\r\n"; $head2 .= "Content-Type: application/x-www-form-urlencoded\r \n";
       if($range != "") $head2 .= "Range: bytes={$range}-\r\n";
       $head2 .= "Content-Length: ".strlen($fvars)."\r\n";
       $head2 .= "Connection: close\r\n\r\n";
       $fp = @fsockopen($furl['host'], 80, $errno, $errstr);
       if (!$fp)
       {
echo "<span style='color:#688000; background- color:#BBDB54; font-size : 10pt; text-decoration: none; font-family: Trebuchet MS;'>The script says <b>$errstr</b>, please try again later.</span>";
           exit;
       }
       @stream_set_timeout($fp, 120);
       fwrite($fp, "POST {$furl['path']}  HTTP/1.1\r\n");
       fwrite($fp, $head2.$f2vars);
       fflush($fp);
       while (!feof($fp))
       {
           $download = fread($fp, 2048);
           echo $download;
           //ob_flush(); //php.net suggestion
       }

//These two buggers were here originally, but I don't even know if I am supposed to have them here.
        flush();
        ob_flush();
      @fclose($fp);
       exit;

   }


}
else
{
       $data = "<form method=\"post\">\n";
$data .= "<input type=\"text\" id=\"link\" style=\"text- align:center\" name=\"link\" size=\"60\" onfocus=\"if (this.value=='Enter rapidshare.com URL here'){this.value=''}\">\n"; $data .= "<br><input type=\"submit\" value=\"Download\"></ form>";
       echo $data;
}
?>

Thanks to anyone who has already helped, I hope some genius can spot an obvious error, because this is just beyond me!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


I had no time to read the whole thing, but maybe remove the trailing ? >.
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Richard Heyes [mailto:[EMAIL PROTECTED] 
> Sent: Friday, February 01, 2008 3:43 AM
> To: Daevid Vincent
> Cc: 'PHP General List'
> Subject: Re: [PHP] PEAR website and MSIE 6
> 
> Daevid Vincent wrote:
> > I will be very sad in 15 days when M$ FORCES everyone to it.
> 
> WT?

Feb 12th is D-day.

http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2005-
28,GGLG:en&q=microsoft+forcing+ie7

--- End Message ---
--- Begin Message ---
On 2/1/08, Daevid Vincent <[EMAIL PROTECTED]> wrote:
> Feb 12th is D-day.
>
> http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2005-
> 28,GGLG:en&q=microsoft+forcing+ie7

Actually...
http://blog.wired.com/monkeybites/2008/01/microsofts-ie-7.html

"The short story is that you won't wake up February 12 and find your
beloved IE 6 has been replaced with IE 7."

It's not a for sure thing, it depends on your setup it looks like.
WSUS definately needs assistance. It looks a bit confusing according
to microsoft's website whether a normal user's XP will be upgraded. Of
course, you can just not upgrade your system, or selectively install
the updates (which I suggest anyhow)

--- End Message ---
--- Begin Message ---
Hi,

I was trying to write a script  in PHP that takes a program name
as an argument and invoke it as a daemon.
PHP provides fork(pcntl_fork), setsid(posix_setsid) and umask,
so it was easy.
However, I couldn't find a way  to redirect STDERR a file.
I like to have the daemon write its log to its  own logfile, like
apache and mysql do.

So is there any way to accomplish that?
Any pointers, suggestions would be greatly appreciated.

Thanks.

--- End Message ---
--- Begin Message ---
js wrote:

> I was trying to write a script  in PHP that takes a program name
> as an argument and invoke it as a daemon.
> PHP provides fork(pcntl_fork), setsid(posix_setsid) and umask,
> so it was easy.
> However, I couldn't find a way  to redirect STDERR a file.
> I like to have the daemon write its log to its  own logfile, like
> apache and mysql do.

I think "nohup <program> 2>errorlog" will do what you're after.


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
nohup would work in some ways, but that's not a real daemon
because the process will have tty, in a session and has a process group.
I like to have a real daemon.

On Feb 2, 2008 5:25 PM, Per Jessen <[EMAIL PROTECTED]> wrote:
> js wrote:
>
> > I was trying to write a script  in PHP that takes a program name
> > as an argument and invoke it as a daemon.
> > PHP provides fork(pcntl_fork), setsid(posix_setsid) and umask,
> > so it was easy.
> > However, I couldn't find a way  to redirect STDERR a file.
> > I like to have the daemon write its log to its  own logfile, like
> > apache and mysql do.
>
> I think "nohup <program> 2>errorlog" will do what you're after.
>
>
> /Per Jessen, Zürich
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---

Reply via email to