Following is my function I wrote to retrieve the value of
LimitRequestBod y 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 &getLimitReques tBody() {
global $limitRequestBo dyFilePath;
if ($_SESSION['limitRequestBo dy']) {
return $_SESSION['limitRequestBo dy'];
} else {
$fileID = @fopen($limitRe questBodyFilePa th, 'r');
if (!$fileID) return 0; // BOMB OUT - $limitRequestBo dyFilePath SET
IN CSV FILE AND IS REQUIRED TO OBTAIN LimitRequestBod y
$contents = @fread($fileID, filesize($limit RequestBodyFile Path));
@fclose($fileID );
preg_match('/LimitRequestBod y[\s\t]*([0-9]+)\n*/i', $contents,
$matchArray);
$_SESSION['limitRequestBo dy'] = (int)trim($matc hArray[1]);
return (int)trim($matc hArray[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
LimitRequestBod y 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 &getLimitReques tBody() {
global $limitRequestBo dyFilePath;
if ($_SESSION['limitRequestBo dy']) {
return $_SESSION['limitRequestBo dy'];
} else {
$fileID = @fopen($limitRe questBodyFilePa th, 'r');
if (!$fileID) return 0; // BOMB OUT - $limitRequestBo dyFilePath SET
IN CSV FILE AND IS REQUIRED TO OBTAIN LimitRequestBod y
$contents = @fread($fileID, filesize($limit RequestBodyFile Path));
@fclose($fileID );
preg_match('/LimitRequestBod y[\s\t]*([0-9]+)\n*/i', $contents,
$matchArray);
$_SESSION['limitRequestBo dy'] = (int)trim($matc hArray[1]);
return (int)trim($matc hArray[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