I am trying to obtain the value that is set in /etc/httpd/conf.d/php.conf for LimitRequestBody and it fails every time:

echo ini_get('LimitRequestBody') . '<P>' . get_cfg_var('LimitRequestBody');

This produces:

In short, nothing. I am trying to obtain this variable set up by a PHP config file but I can't obtain yet in php.conf I see it clearly.

Help!

Thanx
Phil

    those two functions are looking at php.ini not php.conf which is why they are returning nothing.

    why not simply use file_get_contents() to grab /etc/httpd/conf.d/php.conf and then check for that directive.

      Wow! That is a very elaborate method to get something like that, but perhaps the best method is to obtain it once and set into a $_SESSION variable

      Phil

        This is what I came up with to display the value of LimitRequestBytes, very elaborate for just a simple thing, and I betcha somewhere out there in PHPland this could be done much more simply:

        /*-----------------------------------------------------------------------------------------------------------------------------
        	There is no native method in PHP to obtain a value that is in a separate CONFIG file, particularly
        	/etc/httpd/conf.d/php.conf, therefore, you will have to obtain it yourself the hard way: splice up the
        	file and retrieve and set into a session variable, or, obtain from the existing session variable
          -------------------------------------------------------------------------------------------------------------------------------*/
          function &getLimitRequestBody() {
        	global $limitRequestBodyFilePath;
        	if ($_SESSION['limitRequestBody']) {
          	 return $_SESSION['limitRequestBody'];
        	} else {
        	 $fileID = @fopen($limitRequestBodyFilePath, 'r');
        	 if (!$fileID) return 0;	// BOMB OUT - $limitRequestBodyFilePath SET IN CSV FILE AND IS REQUIRED TO OBTAIN LimitRequestBody
        	 $contents = @fread($fileID, filesize($limitRequestBodyFilePath));
        	 @fclose($fileID);
        	 preg_match('/LimitRequestBody[\\s\\t]*([0-9]+)\n*/i', $contents, $matchArray);
                 $_SESSION['limitRequestBody'] = (int)trim($matchArray[1]);
        	 return (int)trim($matchArray[1]);
        	}
          }					
        

        Phil

          Ok one big BIG failure issue.. what if the webserver is not Apache? Then what do I do?

          Phil

            if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache')) {getLimitRequestBody();}
            else {echo 'you are not using Apache';}
            

              That's a step. That only tells me they're not using Apache, which then causes an even bigger can-of-worms when building a portable application that has to account for limitations in request size.

              Phil

                Write a Reply...