Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
* Config.php example with Apache container
4
* @author   Bertrand Mansion <bmansion@mamasam.com>
5
* @package  Config
6
*/
7
// $Id: Apache.php 120908 2003-03-22 17:44:12Z mansion $
8
 
9
require_once('Config.php');
10
 
11
$datasrc = '/path/to/httpd.conf';
12
$conf = new Config();
13
$content =& $conf->parseConfig($datasrc, 'apache');
14
if (PEAR::isError($content)) {
15
    die($content->getMessage());
16
}
17
 
18
// adding a new virtual-host
19
 
20
$content->createBlank();
21
$content->createComment('My virtual host');
22
$content->createBlank();
23
 
24
$vhost =& $content->createSection('VirtualHost', array('127.0.0.1:82'));
25
$vhost->createDirective('DocumentRoot', '/usr/share/www');
26
$vhost->createDirective('ServerName', 'www.mamasam.com');
27
$location =& $vhost->createSection('Location', array('/admin'));
28
$location->createDirective('AuthType', 'basic');
29
$location->createDirective('Require', 'group admin');
30
 
31
// adding some directives Listen
32
 
33
if ($listen =& $content->getItem('directive', 'Listen')) {
34
    $res =& $content->createDirective('Listen', '82', null, 'after', $listen);
35
} else {
36
    $listen =& $content->createDirective('Listen', '81', null, 'bottom');
37
    if (PEAR::isError($listen)) {
38
        die($listen->getMessage());
39
    }
40
    $content->createDirective('Listen', '82', null, 'after', $listen);
41
}
42
 
43
echo '<pre>'.htmlspecialchars($content->toString('apache')).'</pre>';
44
 
45
// Writing the files
46
/*
47
if (!PEAR::isError($write = $conf->writeConfig('/tmp/httpd.conf', 'apache'))) {
48
    echo 'done writing config<br>';
49
} else {
50
    die($write->getMessage());
51
}
52
 
53
if ($vhost->writeDatasrc('/tmp/vhost.conf', 'apache')) {
54
    echo 'done writing vhost<br>';
55
}
56
*/
57
?>