I tried the C code below and I get post data from Apache fine. Now I tried to test that php gets data on stdin and that appears to fail. Maybe I tested wrong, can anyone verify if this test should work?
Step 1: Set 'post_max_size = 1' in php.ini Step 2: Send html form post to this code: <?php if($_ENV['REQUEST_METHOD'] == 'POST') { if (strcasecmp($_ENV['REQUEST_METHOD'], 'POST') == 0) { $cl = $_ENV['CONTENT_LENGTH']; $stdin = fopen('php://stdin', 'r'); if(!$stdin) {print('Error opening stdin'); exit(1);} $raw_data = fgets($stdin, $cl); fclose($stdin); print("STDIN<br>STRLEN = ".strlen($raw_data)); print('<pre>'); print($raw_data); print('</pre>'); } } print('<hr>ENV<pre>'); print_r($_ENV); print('</pre>'); ?> ENV variables all look correct. stdin ($raw_data) appears to be empty, strlen returns 0. The CONTENT_LENGTH environment variable is reported correctly and changes according to how much data is posted. Is fopen('php://stdin', 'r'); the correct way to read from stdin? Are there any other ways to read from stdin? Is post_max_size = 1 a valid setting? -- Andy On Wed, Aug 04, 2004 at 11:18:26PM -0500, AJL wrote: > > Yeah, I would expect a 50x response for a Deny from all. I tried > adding the Limit directive to .htacces in both the cgi directory and > the www directory, no luck: > <Limit POST> > Order Allow,Deny > Allow from all > </Limit> > > I found this C code: > ftp://ftp.ncsa.uiuc.edu/Web/httpd/Unix/ncsa_httpd/cgi/cgi-src/post-query.c > > and compiled it and redirected my sample code (posted earlier) and I > get the posted form variables fine. So maybe Apache CGI setup is > working okay. > > The next logical step seems to be to see what php is getting on stdin > and what environment variables are set. I know I can check the > environment variables with $_ENV. Anyone know how I can get an exact > copy of the data that was passed on stdin? > > -- > Andy > > On Thu, Aug 05, 2004 at 03:20:23AM +0000, Curt Zirzow wrote: > > * Thus wrote AJL: > > > On Wed, Aug 04, 2004 at 02:55:16PM -0700, Justin Patrin wrote: > > > > > > > > Sounds like Apache just isn't passing in POST data. Are you *sure* > > > > there's Apache directive for this? > > > Yeah, that's what I'm thinking more and more, apache not passing it in > > > or in a way that php is not understanding. > > > > > > Anyone know of possible apache settings/directives that affect how CGI > > > programs are invoked and/or how data is passed to them? > > > > <Location /cgi-bin> # or similar > > <Limit POST> > > Order deny,allow > > Deny from all > > </Limit> > > </Location> > > > > But, you technically should get a 50x error with that. > > > > > > Curt > > -- > > First, let me assure you that this is not one of those shady pyramid schemes > > you've been hearing about. No, sir. Our model is the trapezoid! > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php