php-general Digest 2 Feb 2008 23:04:30 -0000 Issue 5271

Topics (messages 268559 through 268577):

Re: Redirecting STDERR to a file?
        268559 by: Per Jessen
        268562 by: js
        268563 by: Per Jessen
        268564 by: js
        268565 by: Richard Heyes

Location in php's source for ini-values
        268560 by: ehl lhe
        268567 by: Nathan Rixham
        268571 by: ehl lhe
        268573 by: Daniel Brown

Re: PEAR website and MSIE 6 (M$ forcing IE7)
        268561 by: Richard Heyes

Re: Calling All Opinionated ******** ....
        268566 by: Nathan Rixham

Jacco van Hooren
        268568 by: Nathan Rixham

PHPPDO 1.0RC1 released
        268569 by: Nikolay Ananiev
        268572 by: Larry Garfield
        268574 by: Nikolay Ananiev

Server to client file transfer with authorization: file always corrupt
        268570 by: szalinski

how can make like http://wallpaper.pc86.com ?
        268575 by: RandMan
        268576 by: dg

Re: PEAR website and MSIE 6
        268577 by: Shawn McKenzie

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 ---
js wrote:

> 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.

Well, it depends on what you're after.  Are you solving a problem or are
you doing an exercise because you can? 

If you're solving a problem, and my nohup suggestion isn't sufficient,
just write your daemon in C.  If it's an exercise, take a look at
proc_open().


/Per Jessen, Zürich

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

> > 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.
>
> Well, it depends on what you're after.  Are you solving a problem or are
> you doing an exercise because you can?

Not an exercise. This is for my day job...

> If you're solving a problem, and my nohup suggestion isn't sufficient,
> just write your daemon in C.  If it's an exercise, take a look at
> proc_open().

C would be the last resort. I suppose it would be easily done in Perl,
but most of my colleagues prefer PHP.
I love to make taking over the code easy, so PHP is more preferable to me.

I took your advice and tried proc_open, but it seems blocking the
parent process.
 (BTW, I didn't know this function, thanks!)

I've already spent a lot of time solving this, os might beter to give
up this problem
and go for the other solution...

Anyway, thanks for you help.
I do appreciate it very much.

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

> C would be the last resort. I suppose it would be easily done in Perl,
> but most of my colleagues prefer PHP.
> I love to make taking over the code easy, so PHP is more preferable to
> me.

That makes perfect sense, but sometimes PHP is not the best/right
answer. 

What I think you need to do is: 

parent:   fork() your child process, then do whatever. 
child:    use proc_open to call your program and redirect stderr. 



/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
> > C would be the last resort. I suppose it would be easily done in Perl,
> > but most of my colleagues prefer PHP.
> > I love to make taking over the code easy, so PHP is more preferable to
> > me.
>
> That makes perfect sense, but sometimes PHP is not the best/right
> answer.
>
> What I think you need to do is:
>
> parent:   fork() your child process, then do whatever.
> child:    use proc_open to call your program and redirect stderr.

That's kind of odd, but seems to be the only way to workaround this...
Thanks for you help.

--- End Message ---
--- Begin Message ---
C would be the last resort. I suppose it would be easily done in Perl,
but most of my colleagues prefer PHP.
I love to make taking over the code easy, so PHP is more preferable to
me.
That makes perfect sense, but sometimes PHP is not the best/right
answer.

What I think you need to do is:

parent:   fork() your child process, then do whatever.
child:    use proc_open to call your program and redirect stderr.

That's kind of odd, but seems to be the only way to workaround this...
Thanks for you help.

Having come to this rather late, I recently wrote some code that may be of some help to you which forks processes: http://www.phpguru.org/downloads/pcntl/

You need pcntl and it only works on *nix (I understand). It does make fork()ing somewhat easier though. Be careful of defunct processes though.

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and Helpdesk software for £299pa hosted for you -
no installation, no maintenance, new features automatic and free

--- End Message ---
--- Begin Message ---
hello,


I'd like to know where PHP finally sets the php.ini-values in it's sourcecode, 
e.g. max_execution_time, open_basedir, etc...
What I need is to set several static values which must not be editable using 
php.ini, .htaccess, ini_set, or whatever - so I simply need to set final values 
for several php.ini-settings by modifying the php sourcecode...


regards,
ehl22
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

--- End Message ---
--- Begin Message ---
ehl lhe wrote:
hello,


I'd like to know where PHP finally sets the php.ini-values in it's sourcecode, 
e.g. max_execution_time, open_basedir, etc...
What I need is to set several static values which must not be editable using 
php.ini, .htaccess, ini_set, or whatever - so I simply need to set final values 
for several php.ini-settings by modifying the php sourcecode...


regards,
ehl22
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

can't see any need for this? just set your webserver up with the appropriate permissions and you don't have a problem..
--- End Message ---
--- Begin Message ---
please, don't ask me why I need this - I know exactly why I need it and why 
there is no other solution...
 
 
thanks anyway,
regards
ehl22
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

--- End Message ---
--- Begin Message ---
On Feb 2, 2008 6:09 AM, ehl lhe <[EMAIL PROTECTED]> wrote:
>
> hello,
>
>
> I'd like to know where PHP finally sets the php.ini-values in it's 
> sourcecode, e.g. max_execution_time, open_basedir, etc...
> What I need is to set several static values which must not be editable using 
> php.ini, .htaccess, ini_set, or whatever - so I simply need to set final 
> values for several php.ini-settings by modifying the php sourcecode...

    That's a question that's better asked on the Internals list.  Ask
on there and you'll probably get the answer you're looking for much
quicker.

-- 
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

--- End Message ---
--- Begin Message ---
Feb 12th is D-day.

"[Microsoft] has posted guidelines on how to ward off the automatic update"

Not exactly "forcing" if they've provided an alternative.

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and Helpdesk software for £299pa hosted for you -
no installation, no maintenance, new features automatic and free

--- End Message ---
--- Begin Message ---
Jochem Maas 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

Jochem,

You develop sites in php, zend make php, zend have a framework, so that may aswell be "the" php framework - it's great, well coded, doc'd and stable, and doesn't try to do anything too fancy.

At the end of the day the ZF framework is a developer's framework, use it if you want to make sensible, structured OO php applications to a high standard, use something else if you want to quickly make "it'll do" applications in an webdev sweat shop.

ps: get zend studio and integrate it with svn aswell - zend studio cuts hours out your dev time.

Nathan

--- End Message ---
--- Begin Message --- wish he'd turn that auto responder off.. *sigh* - he's now top of my contacts in gtalk..
--- End Message ---
--- Begin Message ---
Hi guys,
I've just released phppdo-1.0RC1. From the readme:

PHPPDO is a database abstraction layer over the current PHP database 
functions,
which aim is to offer a migration path for new applications to the PDO 
classes
presented in PHP 5.1.

Why a migration path?
Currently, most hosting providers offering a shared hosting do not include
support for PDO in their PHP5 enabled web servers. That means most web
developers are stuck with the old database functions and can't migrate to 
PDO.
PHPPDO makes such a migration possible by providing a PDO-like API interface
over the old database functions. After using PHPPDO, a migration to PDO 
afterwards
is a matter of changing a single line of code (this can even be automatic,
when the script detects PDO).

Downloading PHPPDO
http://sourceforge.net/project/showfiles.php?group_id=216242

For more info visit:
http://www.devuni.com/forums/viewforum.php?f=24

Testers needed :) 

--- End Message ---
--- Begin Message ---
On Saturday 02 February 2008, Nikolay Ananiev wrote:
> Hi guys,
> I've just released phppdo-1.0RC1. From the readme:
>
> PHPPDO is a database abstraction layer over the current PHP database
> functions,
> which aim is to offer a migration path for new applications to the PDO
> classes
> presented in PHP 5.1.
>
> Why a migration path?
> Currently, most hosting providers offering a shared hosting do not include
> support for PDO in their PHP5 enabled web servers. That means most web
> developers are stuck with the old database functions and can't migrate to
> PDO.

Do you have a source for that?  Any web host running a stock PHP 5.1 or later 
will have PDO.  They'd have to go to extra effort not to, at which point 
they're not a host worth using.  (The same applies to SPL, PCRE, XML, and a 
bunch of other "optional but default" extension that only a suicidal web host 
would disable.)

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
"Larry Garfield" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Saturday 02 February 2008, Nikolay Ananiev wrote:
>> Hi guys,
>> I've just released phppdo-1.0RC1. From the readme:
>>
>> PHPPDO is a database abstraction layer over the current PHP database
>> functions,
>> which aim is to offer a migration path for new applications to the PDO
>> classes
>> presented in PHP 5.1.
>>
>> Why a migration path?
>> Currently, most hosting providers offering a shared hosting do not 
>> include
>> support for PDO in their PHP5 enabled web servers. That means most web
>> developers are stuck with the old database functions and can't migrate to
>> PDO.
>
> Do you have a source for that?  Any web host running a stock PHP 5.1 or 
> later
> will have PDO.  They'd have to go to extra effort not to, at which point
> they're not a host worth using.  (The same applies to SPL, PCRE, XML, and 
> a
> bunch of other "optional but default" extension that only a suicidal web 
> host
> would disable.)

I can't give you exact numbers. I'm working for a web development company 
and
many of our clients have shared hosting. Since PHP 5.1 is out, the best I've 
seen is
PDO with SQLite driver and nothing more. The reason
to create PHPPDO is because our framework makes
heavy use of PDO and we need to mimic PDO for hosts that don't have it or
don't have the required driver. 

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

I am having trouble with a file transfer script, as you can see, I am
trying trying to keep the code as simple as possible.

But everytime I download a file with it, it is corrupt. For example, when
I download a 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.

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

A couple of questions:

Have I got too many header requests?
Do I need to worry about output buffering, which is possibly corrupting
the file output (if so, please tell me what to do!)?
Is there an easier way to get returned response header and get a
redirected link, instead of finding and cutting strings?
Is there maybe something wrong with the structure or order of the header
requests, and/or returned headers etc?

Here is what I have so far:

<?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 ---
how can make like http://wallpaper.pc86.com ?

look like XP file manager, any body have idea ?
i feel this so simple, but i have't any direction

thank you ! 

--- End Message ---
--- Begin Message ---
Looks like Treeview

http://developer.yahoo.com/yui/treeview/


On Feb 2, 2008, at 1:33 PM, RandMan wrote:

how can make like http://wallpaper.pc86.com ?

look like XP file manager, any body have idea ?
i feel this so simple, but i have't any direction

thank you !

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


--- End Message ---
--- Begin Message ---
Glad I read threads that I don't care about or I wouldn't have found out
about Firebug!  I just installed it, very cool!

Also, considering the price of oil/gas, I'm sorry that the 'war for oil'
didn't work out the way we had hoped.  You would have thought we would
have learned in WWII when we started the 'war for strudel'.  Have you
seen the price of strudel?  It went up during WWII and has continued to
rise.

I would call you a dumb ass, but you seem very knowledgeable in PHP and
I may need some help in the future :-)


Jochem Maas wrote:
> Daevid Vincent schreef:
>>  
>>
>>> -----Original Message-----
>>> From: Jochem Maas [mailto:[EMAIL PROTECTED] Sent: Thursday,
>>> January 31, 2008 8:19 AM
>>> To: [EMAIL PROTECTED]
>>> Cc: PHP General List
>>> Subject: Re: [PHP] PEAR website and MSIE 6
>>>
>>> Richard Heyes schreef:
>>>>> firefox not an option?
>>>> Nope.
>>>>
>>>>  > or anything else that resembles a proper browser ;-)
>>>>
>>>> Strange, IE has been working fine for me for the last eight years...
>>
>> Yes. http://pear.php.net crashes my IE6 too. This is a problem with the
>> site, not the browser.
>>> seriously though - why is FF (or any other browser) not an option? your
>>> a web developer, I would imagine you should be running a complete
>>> arsenal of
>>> different browsers as part of the job, no?
>>> and then there's the question as to why you don't upgrade to IE7.
>>
>> Please stop with the browser wars.
> 
> it's not browser wars - it's pragmatism - thinking aloud about how to
> get round the issue - I'm assuming Richard does have access to the PEAR
> site's
> source files or the means to upload them to the PEAR webserver.
> 
>  They're boring and tired and serve no
>> purpose. IE6 is fast and launches in 1 second. FF takes many seconds.
>> IE7 is
>> also a bloated pig and I will be very sad in 15 days when M$ FORCES
>> everyone
>> to it. IE also has very nice DirectX rendering filters for gradients.
>>  
>>> or maybe rebuild the windows machine in question (hey it wouldn't be
>>> the first time something
>>> like this was helped by a clean install right?)
>>
>> It is NOT the OS. It is the PEAR site itself that is to blame. There is
>> clearly some code or tag or something that is causing this failure. 
> 
> let's see now - a webserver outputs some content, it may be invalid. a
> browser
> crashes upon trying to render the content. hmm, sounds to me like the
> problem is
> in the browser, decent software should crash because of shitty input.
> 
> granted if the PEAR just didn't render properly or caused 'invalid
> XML/XHTML/whatever'
> message in the browser then yes it would be the site's problem. but
> until the browser
> is capable of saying 'hey this content is junk, I can't use it [because
> of XYZ]' then
> really the first issue is with that browser.
> 
> it's same at the server end - if your browser (or you, maliciously)
> posts freaking/invalid
> byte sequences at some script I've got on the server then would you
> consider it correct
> that the server crashed? or would you expect some kind of 'your input
> sucks' error
> message to appear?
> 
>> It
>> didn't used to be there either. I've gone to the PEAR site many times
>> in the
>> past. The site isn't even that compex, so I'm curious why the webmaster
>> couldn't just fix this problem and make everyone happy? 
> 
> we work around bugs and problems all day in the job we do - how is
> cranking up a
> different browser because a site happens not to work with a particular
> site any different?
> 
> if we're really about making everyone happy - how about we tackle something
> serious like the whole 'war for oil' business? exactly how fragile is a
> human mind if
> a browser crashing on a particular site is deciding factor in being
> capable of
> experiencing happiness? (not that I'm suggesting this about Richard - Im
> sure he
> was just a little miffed and ping'ed the question out of curiousity more
> than anything)
> 
>> Or is the PHP
>> community so snobbish that they're turning into the Linux community?
>> I find it so ironic that all the fringe browser people freak out if their
>> browser isn't supported by some site and demand retribution, yet when the
>> tables are turned how quick they are to tell 80% of the world to use a
>> 20%
>> browser...
> 
> let's make it sound like they all *chose* IE shall we - a large majority
> of that 80% actually think IE *is* the internet, they certainly didn't
> choose it
> because they thought it was the best tool for the job (which it may or
> may not
> be depending or circumstance and/or perspective) - indoctrination and
> ignorance
> do not make good metrics for determining the superiority of a given
> product ...
> keyboard layout being another fine example ... de facto not necessarily
> equal da bom
> 
>>
>> *sigh*
> 
> indeed

--- End Message ---

Reply via email to