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

2009-05-14 Thread php-general-digest-help

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 

php-general Digest 14 May 2009 21:43:09 -0000 Issue 6121

2009-05-14 Thread php-general-digest-help

php-general Digest 14 May 2009 21:43:09 - Issue 6121

Topics (messages 292563 through 292593):

Re: Cannot output the same data from text file in PHP
292563 by: Peter Ford
292564 by: Jan G.B.
292569 by: Mike Roberts
292570 by: Nathan Rixham
292579 by: Ashley Sheridan
292580 by: Andrew Ballard
292581 by: Ashley Sheridan
292582 by: Mike Roberts
292583 by: Ashley Sheridan
292587 by: Paul M Foster
292589 by: Andrew Ballard
292591 by: Ashley Sheridan

Re: Sending SMS through website
292565 by: Select Performers

When is __destruct called on an object in $_SESSION ?
292566 by: Peter Ford
292567 by: Stuart
292568 by: Peter Ford

suggestion required
292571 by: Pravinc

where  what
292572 by: PJ

Re: where  what-SOLVED
292573 by: PJ

include file syntax
292574 by: PJ
292576 by: Shawn McKenzie

php  html integration
292575 by: PJ
292577 by: Shawn McKenzie
292578 by: Tom Worster
292584 by: tedd
292588 by: Paul M Foster

Software to read/write Excel to CD?
292585 by: Skip Evans
292590 by: Paul M Foster
292592 by: Ashley Sheridan

php ssl connection timeout issue
292586 by: Jerry Zhao
292593 by: Shawn McKenzie

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---
Moses wrote:
 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 tabletrtd;
 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 atggcaatcgtttcagcagattcgtaattcgagctcgcccatcgatcctcta 60
 
 Sbjct: 1 atggcaatcgtttcagcagattcgtaattcgagctcgcccatcgatcctcta 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
 

Not a PHP problem, but a HTML problem:
First, HTML compresses white space into just one space, so all of those leading
spaces on line 2 are lost.
Second, you are (probably) displaying using a proportionally-spaced font, so the
narrow pipeline characters take up less width than the letters.

So you need something like:
?php
$alldata = file(result.txt);
echo tabletrtd style='white-space: pre; font-family: monospace;';
foreach($alldata as $line_num = $line)
{
echo $line.\n;
}
echo/td/tr/table;
?


-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent
---End Message---
---BeginMessage---
You could even make it shorter, if you don't need the line numbers anyway:
pre
 ?
  echo nl2br(file_get_contents('file.txt'));
 ?
/pre

2009/5/14 Peter Ford p...@justcroft.com:
 Moses wrote:
 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 tabletrtd;
 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 atggcaatcgtttcagcagattcgtaattcgagctcgcccatcgatcctcta 60
 
 Sbjct: 1 atggcaatcgtttcagcagattcgtaattcgagctcgcccatcgatcctcta 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


 Not a PHP problem, but a HTML problem:
 First, HTML compresses white space into just one space, so all of those 
 leading
 spaces on line 2 are lost.
 Second, you are (probably) displaying using a proportionally-spaced font, so 
 the
 narrow pipeline characters take up less width than the letters.

 So you need something like:
 ?php
 $alldata = file(result.txt);
 echo tabletrtd style='white-space: pre; font-family: monospace;';
 foreach($alldata as $line_num = $line)
 {
    echo $line.\n;
 }
 echo/td/tr/table;
 ?


 --
 Peter Ford                              phone: 01580 89
 Developer                               fax:   01580 893399
 Justcroft International Ltd., Staplehurst, Kent

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


---End Message---
---BeginMessage---
Is there a moderator or some responsible