QuickPHP calls QuickPHP_ReqMod.php (in the same folder as QuickPHP.exe) and passes the following variables to the script each time it processes a request. This enables the mods to modify the variables to implement functions such as mod_rewrite.
If QuickPHP_ReqMod.php file does not exist, QuickPHP simply works as before. This mod feature is for advanced users only.
Variables available to the script:
$DebugLog - Boolean - R/W - Default = false
Set this to true for QuickPHP to save the output from executing QuickPHP_ReqMod.php to QuickPHP_ReqMod_DebugLog.html (same folder as QuickPHP.exe).
This allows you to output message to the log file via Echo, Print, etc.
$RequestURI - String - R/W
Read from this variable to find out the URI being requested by the client.
Set this to any URI you wish to redirect the request to (e.g. for implementing mod_rewrite).
$RequestHeaders - String - R/W
Contains the request headers sent from the client.
The request headers are delimited by '\r\n' (return and line feed characters).
To add an arbitary header, simply append a new line to this variable and terminate it with '\r\n'.
There is no limit to the number of headers you can add.
Hint: Parse this string into an array to conveniently add or remove headers and then reconstruct the string at the end.
$UniqueID - String - R/W
Contains a unique ID for the current request.
If you wish to generate your own UniqueID in place of the default, change this value.
$ModuleSignature - String - R/W
Each module should append to this string to indicate its effects on the server.
e.g. ' mod_bwlimited/1.4' (Note the space before the name of the module).
Naming convention - ' <module name>/<version>'
$DocumentRoot - String - R
Holds the current DocumentRoot folder of this server.
$DefaultDoc - String - R
Holds the filename of the default document of this server.
The following are variables similar to $_SERVER['x'].
Some of these values will be updated to reflect the altered $RequestURI (if it is altered) after the execution of the script.
$GatewayInterface - String - R
$QueryString - String - R
$RedirectStatus - String - R
$RemoteAddr - String - R
$RemotePort - String - R
$RequestMethod - String - R
$ScriptFilename - String - R
$ScriptName - String - R
$ServerAddr - String - R
$ServerName - String - R
$ServerPort - String - R
$ServerProtocol - String - R
$ServerSignature - String - R
$ServerSoftware - String - R
$PhpSelf - String - R
*** R - Read-only. They can be changed in the script but will not affect the way server processes the request.
*** R/W - Read-write. Can be changed and will affect the server.
Notes:
It is recommended that you only include external PHP files from QuickPHP_ReqMod.php.
For example, for mod_rewrite, you could create a file called mod_rewrite.php, and include that in QuickPHP_ReqMod.php.
The QuickPHP_ReqMod.php file could end up calling several mods. In which case, it becomes a convenient place to enable / disable specific mods.
Example:
- Code: Select all
include("mod_rewrite.php");
include("mod_log_referer.php");
include("mod_spelling.php");
// Disabled mods. Uncomment to enable.
//include("mod_unique_id.php");
Get started with this - it simply prints out all the available variables into QuickPHP_ReqMod_DebugLog.html:
- Code: Select all
<?php
$DebugLog = true;
Echo $RequestURI.'<br>';
Echo $DocumentRoot.'<br>';
Echo $DefaultDoc.'<br>';
Echo $GatewayInterface.'<br>';
Echo $RequestHeaders.'<br>';
Echo $QueryString.'<br>';
Echo $RedirectStatus.'<br>';
Echo $RemoteAddr.'<br>';
Echo $RemotePort.'<br>';
Echo $RequestMethod.'<br>';
Echo $ScriptFilename.'<br>';
Echo $ScriptName.'<br>';
Echo $ServerAddr.'<br>';
Echo $ServerName.'<br>';
Echo $ServerPort.'<br>';
Echo $ServerProtocol.'<br>';
Echo $ServerSignature.'<br>';
Echo $ServerSoftware.'<br>';
Echo $UniqueID.'<br>';
Echo $PhpSelf.'<br>';
Echo $ModuleSignature.'<br>';
$ModuleSignature .= ' mod_bwlimited/1.4';
?>
