Example #1
0
File: index.php Project: N9dZ/www
            $aliasContents .= '<li><a href="' . str_replace('.conf', '', $file) . '/">' . str_replace('.conf', '', $file) . '</a></li>';
        }
    }
    closedir($handle);
}
if (empty($aliasContents)) {
    $aliasContents = "<li>" . $langues[$langue]['txtNoAlias'] . "</li>\n";
}
//[modif oto] - Récupération des ServerName de httpd-vhosts.conf
//$addVhost = "<li style='color:red;'>".$langues[$langue]['txtAddVhost']."</li>";
$addVhost = "<li><a href='add_vhost.php?lang=" . $langue . "'>" . $langues[$langue]['txtAddVhost'] . "</a></li>";
if ($VirtualHostMenu == "on") {
    $vhostError = false;
    $error_message = array();
    $allToolsClass = "four-columns";
    $virtualHost = check_virtualhost();
    $vhostsContents = '';
    if ($virtualHost['include_vhosts'] === false) {
        $vhostsContents = "<li><i style='color:red;'>Error Include Apache</i></li>";
        $vhostError = true;
        $error_message[] = sprintf($langues[$langue]['txtNoIncVhost'], $wampConf['apacheVersion']);
    } else {
        if ($virtualHost['vhosts_exist'] === false) {
            $vhostsContents = "<li><i style='color:red;'>No vhosts file</i></li>";
            $vhostError = true;
            $error_message[] = sprintf($langues[$langue]['txtNoVhostFile'], $virtualHost['vhosts_file']);
        } else {
            if ($virtualHost['nb_Server'] > 0) {
                $port_number = true;
                $nb_Server = $virtualHost['nb_Server'];
                $nb_Virtual = $virtualHost['nb_Virtual'];
Example #2
0
//Replace Used Port by New port ($_SERVER['argv'][1])
$portToUse = intval(trim($_SERVER['argv'][1]));
//Check validity
$goodPort = true;
if ($portToUse < 80 || $portToUse > 81 && $portToUse < 1025 || $portToUse > 65535) {
    $goodPort = false;
}
if ($goodPort) {
    //Change port into httpd.conf
    $httpdFileContents = @file_get_contents($c_apacheConfFile) or die("httpd.conf file not found");
    $findTxtRegex = array('/^(Listen 0.0.0.0).*$/m', '/^(Listen \\[::0\\]).*$/m', '/^(ServerName localhost).*$/m');
    $httpdFileContents = preg_replace($findTxtRegex, "\$1:" . $portToUse, $httpdFileContents);
    $fphttpd = fopen($c_apacheConfFile, "w");
    fwrite($fphttpd, $httpdFileContents);
    fclose($fphttpd);
    $virtualHost = check_virtualhost(true);
    //Change port into httpd-vhosts.conf
    if ($virtualHost['include_vhosts'] && $virtualHost['vhosts_exist']) {
        $c_vhostConfFile = $c_apacheVersionDir . '/apache' . $wampConf['apacheVersion'] . '/' . $wampConf['apacheConfDir'] . '/extra/httpd-vhosts.conf';
        $myVhostsContents = file_get_contents($c_vhostConfFile) or die("httpd-vhosts.conf file not found");
        $findTxtRegex = $replaceTxtRegex = array();
        $findTxtRegex[] = '/^([ \\t]*<VirtualHost).*$/m';
        $replaceTxtRegex[] = '$1 *:' . $portToUse . '>';
        if (version_compare($wampConf['apacheVersion'], '2.4.0', '<')) {
            //Second element only for Apache 2.2
            $findTxtRegex[] = '/^([ \\t]*NameVirtualHost).*$/m';
            $replaceTxtRegex[] = '$1 *:' . $portToUse;
        }
        $myVhostsContents = preg_replace($findTxtRegex, $replaceTxtRegex, $myVhostsContents);
        $fphttpdVhosts = fopen($c_vhostConfFile, "w");
        fwrite($fphttpdVhosts, $myVhostsContents);