How do I get the request limitation size in IIS via PHP?

From: Phil Powell (soazine_at_erols.com)
Date: 06/22/04


Date: 21 Jun 2004 15:43:01 -0700

Following is my function I wrote to retrieve the value of
LimitRequestBody in php.conf if the webserver is Apache:

[PHP]
/*-----------------------------------------------------------------------------------------------------------------------------
        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]);
        }
  }

[/PHP]

Nice function, however, HUGE dilemma: the application that will use
this function is designed to be fully portable, that is, it can run in
Apache or IIS or anything that can run PHP. That means everything in
this application needs to run equally in any webserver that can handle
PHP, including this function.

This function works only if you're using Apache since it retrieves a
specific file /etc/httpd/conf.d/php.conf that has a value I need that
PHP itself cannot provide to determine the absolute limit of a
request.

So how do I write this for IIS or any other PHP-friendly webserver?

Thanx
Phil



Relevant Pages

  • Re: where can I find howto docs to setup LAMP
    ... How can I make apache start automaticly when I boot the server? ... > a linux webserver with mysql and php. ...
    (alt.os.linux.suse)
  • where can I find howto docs to setup LAMP
    ... How can I make apache start automaticly when I boot the server? ... linux webserver with mysql and php. ...
    (alt.os.linux.suse)
  • Re: redirect / new website how to redirect old (google) links to new site ?
    ... Andy Hassall wrote: ... It may not be as good as Apache, but it still is a perfectly good webserver. ... since all the new code is PHP and is gradually ...
    (comp.lang.php)
  • Weird apache problem
    ... It's running Apache and php4, and when you try to load a page using Firefox, you get a popup asking you what to do with the file. ... The load module and add module lines exist in the httpd.conf file and the webserver has been restarted repeatedly, ... Copyright 1997-2006 The PHP Group ... DirectoryIndex index.php index.php3 index.html index.htm ...
    (freebsd-questions)
  • How do I get the request limitation size in IIS via PHP?
    ... LimitRequestBody in php.conf if the webserver is Apache: ... Apache or IIS or anything that can run PHP. ...
    (microsoft.public.inetserver.iis)