Support This Project

ApacheConfig.php

Return to Main Page   Python Tools   Downloads

Example Usage:

$ac = new ApacheConfig();                       // Create a configuration instance
$ac -> readOpts('/etc/conf.d/apache2');         // Read compile options from a Gentoo style config file
$ac -> read('/etc/apache2/httpd.conf');         // Read the configuration

if ($ac -> errMsg) {
    echo $ac -> errMsg . '<br/>';               // Puke if something went wrong
} else {
    $out = new ApacheConfigWriter();            // Instantiate a formatter
    $out -> options['showcomments'] = false;    // Don't show comments
    $out -> options['return'] = false;          // Echo results, don't return them as string
    if ($simpledumps) {
        echo '<h1>Full Config</h1>';
        $out -> simpleDump($ac);                // Dump the entire configuration file
        echo '<h1>Active Config</h1>';
        $ac -> evaluate();                      // Apply IfDefine and IfModule statements
        $out -> simpleDump($ac);                // Dump the active configuration
    }
    $out -> report($ac);                        // Generate a formatted HTML report
}

ApacheConfig Class Highlights

Methods 
deevaluate()Evaluate the config tree assuming all modules and compile time defines are true, thus including the entire configuration.
evaluate()Evaluate the config tree using the current values for coreModules, and options.
read(file)Read the specified configuration file.
readOpts(file[, key="APACHE2_OPTS"])Read compile options. This method looks for a line starting with the specified key, then extracts all sequences of "-D TOKEN". Each TOKEN is assumed to be set when evaluate() is called.
Properties 
coreModules[]A boolean array indicating which modules should be considered part of the Apache core. The array is indexed by module identifier (e.g. $coreModules['worker.c']). The predefined core modules are core.c, mpm_common.c, and worker.c
options[]A boolean array of compile time options, eg. $options['SSL']. This array is set by readOpts(). If your configuration information is saved in a different format, your application should modify this array.
verboseBoolean. when Set, various methods will output diagnostic information.

ApacheConfigWriter Class Highlights

Methods 
report()Generate a formatted report. The 'format' option must be 'html' for this to generate any output.
setOption(option, value)Set options:
format -- html or string. Specifies output format. Default: html
indentdepth -- integer. number of spaces to use for indenting output. Default: 4
return -- boolean. When set, return output as a string. When false, echo to output stream. Default: true
showcomments -- boolean. When set, include comments in output. Default: true
simpleDump()Generate a simple indented version of the current configuration.

Return to Main Page   Python Tools   Downloads

SourceForge.net LogoSupport This Project