示例#1
0
<?php

//[modif oto]
// Pour tenir compte des diff�rences de configuration Apache 2.2 et 2.4
// et du support ou non d'IPv6
require 'wampserver.lib.php';
require 'config.inc.php';
//[modif oto] - Test of Apache version for cohabition of Apache 2.4 and Apache 2.2
if (substr($wampConf['apacheVersion'], 0, 3) == "2.4") {
    $onlineText = "#   onlineoffline tag - don't remove\n    Require all granted";
    $offlineText = "#   onlineoffline tag - don't remove\n    Require local";
} else {
    $onlineText = "#   onlineoffline tag - don't remove\n    Order Allow,Deny\n    Allow from all";
    $offlineText = "#   onlineoffline tag - don't remove\n    Order Deny,Allow\n    Deny from all\n    Allow from localhost " . (test_IPv6() ? "::1 " : "") . "127.0.0.1";
}
$httpConfFileContents = file_get_contents($c_apacheConfFile) or die("httpd.conf file not found");
// on modifie le fichier httpd.conf
if ($_SERVER['argv'][1] == 'off') {
    $wampIniNewContents['status'] = 'offline';
    $httpConfFileContents = str_replace($onlineText, $offlineText, $httpConfFileContents);
    $fpHttpd = fopen($c_apacheConfFile, "w");
    fwrite($fpHttpd, $httpConfFileContents);
    fclose($fpHttpd);
}
if ($_SERVER['argv'][1] == 'on') {
    $wampIniNewContents['status'] = 'online';
    $httpConfFileContents = str_replace($offlineText, $onlineText, $httpConfFileContents);
    $fpHttpd = fopen($c_apacheConfFile, "w");
    fwrite($fpHttpd, $httpConfFileContents);
    fclose($fpHttpd);
}
示例#2
0
*/
// $1 = First line: [1] => #   onlineoffline tag - don't remove
/* $2 = Directives
[2] =>
    Require local
    Require ip 192.163.10.2
*/
// $3 = Last line: [3] => </Directory>
$apacheType = substr($wampConf['apacheVersion'], 0, 3);
//Test of Apache version for cohabition of Apache 2.4 and Apache 2.2
if ($apacheType == "2.4") {
    $onlineText = "    Require all granted";
    $offlineText = "    Require local";
} else {
    $onlineText = "    Order Allow,Deny\n    Allow from all";
    if (test_IPv6()) {
        $offlineText = "    Order Deny,Allow\n    Deny from all\n    Allow from localhost ::1 127.0.0.1";
    } else {
        $offlineText = "    Order Deny,Allow\n    Deny from all\n    Allow from localhost 127.0.0.1";
    }
}
// We modify httpd.conf file
if ($_SERVER['argv'][1] == 'off') {
    $replacement = "\n" . $offlineText . "\n";
    $wampIniNewContents['status'] = 'offline';
} elseif ($_SERVER['argv'][1] == 'on') {
    $replacement = "\n" . $onlineText . "\n";
    $wampIniNewContents['status'] = 'online';
}
$nb = 0;
$httpConfFileContents = preg_replace("~(^[ \t]*#[ \t]*onlineoffline tag.*\r?\$)((?:.|\r?\n)+?)(^[ \t]*</Directory>\r?\$)~m", "\$1" . $replacement . "\$3", $httpConfFileContents, -1, $nb);