php-general Digest 14 May 2009 09:19:17 - 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
--
---BeginMessage---
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---
---BeginMessage---
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---
---BeginMessage---
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