php-general Digest 14 May 2009 09:19:17 -0000 Issue 6120

Topics (messages 292558 through 292562):

Re: how to enable ttf support in php 5.2.9
        292558 by: Ross McKay

Re: handling chunked input from php://stdin
        292559 by: whisperstream

Re: fileinfo on RHEL5
        292560 by: Michael A. Peters

Re: shell_exec problem with bsdtar
        292561 by: Lester Caine

Cannot output the same data from text file in PHP
        292562 by: Moses

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Ashley Sheridan wrote:

>Great idea in theory, if you can guarantee that they'll *only* be using
>MS Office to paste from. In my experience, you can only guarantee on the
>stupidity of the end users, nothing else.

I was mostly being facetious :)
The only thing that really works is getting the users to cooperate by
giving them a button for Word and a button for Text and explaining to
them how it *helps them* to use those buttons properly. But that only
works while they remember, and they never remember when they're in a
hurry (which is always).
-- 
Ross McKay, Toronto, NSW Australia
"Darwin's rolling over in his coffin,
'cos the fittest are surviving much less often" - NOFX

--- End Message ---
--- Begin Message ---
Thanks for the code, but I figured out the issue I was having.  My problem
was actually getting the data not parsing chunked text.  After taking a
wireshark trace of the traffic I realised that the chunked xml didn't even
hit the php process and instead died somewhere in IIS's fastcgi process.

If anyone else stumbles upon this, here is the problem and my solution.

Production env was IIS 6.0, php 5.2.9-2, installed as module under fastcgi.
XML posted form services was sent to the php script responsible for handling
it
However, if the xml data was chunked, IIS would die with a "500 Server
Error" message and the php processor would never even see the xml.

>From what I can gather (really not a whole lot of data out there), fastcgi
under IIS 6.0 doesn't seem to handle chunked transfer-encoded data.......(it
seems like such a major flaw that I'm wondering if I missed some
configuration setting to get it to work?)

Solution:
Since php5.2.9-2 no longer has the isapi module, I had to uninstall 5.2.9-2
and instead installed 5.2.6 with the php5isapi.dll.  Once that was
configured I retested and hey presto, the chunked data is sent to the php
process without error.  I didn't even need to decode the chunked data as it
is done before I even get access to the data.

Spent a day trying to figure out what was wrong, hopefully it'll save
someone else some time.


Nathan Rixham wrote:
> 
> Shawn McKenzie wrote:
>> whisperstream wrote:
>>> I have a server running that receives xml formatted events from other
>>> services I have no control over.  For certain events the
>>> transfer-encoding
>>> is chunked.
>>>
>>> I was just doing
>>>
>>> $input = file_get_contents('php://stdin');
>>>
>>> and this works well until there is chunked input.  Then I tried
>>>
>>> $handle = fopen('php://input', "rb");
>>> $input = '';
>>> while (!feof($handle)) {
>>>   $input .= fread($handle, 8192);
>>> }
>>> fclose($handle);
>>>
>>> And that gives about the same result, has anyone else come across this
>>> and
>>> how did they solve it?
>>>
>>> Thanks in advance
>>>
>> 
>> There aren't really many examples around, but check
>> http_chunked_decode() from PECL.
>> 
> 
> simples!
> 
> function HTTPChunkDecoder( $chunkedData ) {
>    $decodedData = '';
>    do {
>      $tempChunk = explode(chr(13).chr(10), $chunkedData, 2);
>      $chunkSize = hexdec($tempChunk[0]);
>      $decodedData .= substr($tempChunk[1], 0, $chunkSize);
>      $chunkedData = substr($tempChunk[1], $chunkSize+2);
>    } while (strlen($chunkedData) > 0);
>    return $decodedData;
> }
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/handling-chunked-input-from-php%3A--stdin-tp23512171p23533268.html
Sent from the PHP - General mailing list archive at Nabble.com.


--- End Message ---
--- Begin Message ---
brian wrote:
RHEL5/PHP 5.1.6

I'm having some trouble getting the Fileinfo package working. It installed fine, and phpinfo() says it's enabled. But it consistently returns an empty string when getting the MIME of a file.

/usr/share/pear/bin/pecl install fileinfo
vi /etc/php.d/fileinfo.ini
extension=fileinfo.so

ln -s /usr/share/file/magic /etc/magic.mime

The code:

define('FINFO_PATH', '/usr/share/file/magic');
...
$fi = new finfo(FILEINFO_MIME, FINFO_PATH);
$type = $fi->file($file_path);

$type is always empty. And, yes, the path to the file is good.

This works fine on the dev box (PHP 5.2.6). Unfortunately, the decision to use RHEL5 for production was out of my hands and I'm stuck with this older version. At least, I'm thinking it might be due to that. I didn't see anything in the manual about it, though.

I did come across a post[1] online about doing file conversions where the guy mentions rolling an upgrade to 5.2.4 for RHEL5 but wasn't specific as to whether it was necessary to get Fileinfo to work at all. I might try using that upgrade but thought I'd do a sanity check here first. Any other reason it'd be returning nothing?

I'm running php 5.2.9 on CentOS 5 with FileInfo 1.0.4

I have src.rpm's here:

http://www.clfsrpm.net/php/

Works well enough for me.

--- End Message ---
--- Begin Message ---
Lester Caine wrote:
I'm trying to emulate Linux facilities on the windows servers, and have found bsdtar can be renamed tar.exe so that it will work the same as a shell_exec( "tar" ) call in Linux.

The full paths are used to the files and the command line returns the extracted file name when run at a command prompt, and similar commands for unzip and unrar work fine, later in the check list, but using the 'tar' and also 'bsdtar' command simply returns NULL, and the extracted file is not created.

Any ideas what I've got wrong?

OK - had a sleep on it, and started again fresh.

The bottom line is that WHAT shell_exec returns is rather variable. There is a comment about returning windows errors on the manual page, but in fact 2> may not JUST contain errors, it also has the normal return from some programs. So 2> 'output' may be generally required to find out what has been returned, if the shell_exec return is NULL.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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

I have a written a script in PHP which outputs the result from a text file.
The PHP script is as follows:

<?php
$alldata = file("result.txt");
echo "<table><tr><td>";
foreach($alldata as $line_num => $line) {
echo $line."<br>";
}
echo"</td></tr></table>";
?>

I have attached the result.txt file. However the output of the script is as
follows:


Query: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sbjct: 1 atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60

which is not exactly  as in the result.txt file in that the pipelines are
displaced.

Any pointer to this problem shall be appreciated. Thanking you in advance.

Moses
Query: 1  atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60
          ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sbjct: 1  atggcaatcgtttcagcagaaaaattcgtaattcgagctcgcccggggatcgatcctcta 60

                                    

--- End Message ---

Reply via email to