// Arno Esterhuizen // and Romain Bourdon // and Hervé Leclerc // Icons by Mark James // Version 2.5 -> 3.0.0 by Dominique Ottello aka Otomatic // 3.1.9 - Support VirtualHost IDNA ServerName // // // $server_dir = "../"; require $server_dir.'scripts/config.inc.php'; require $server_dir.'scripts/wampserver.lib.php'; //chemin jusqu'aux fichiers alias $aliasDir = $server_dir.'alias/'; //Fonctionne à condition d'avoir ServerSignature On et ServerTokens Full dans httpd.conf $server_software = $_SERVER['SERVER_SOFTWARE']; $error_content = ''; // on récupère les versions des applis $phpVersion = $wampConf['phpVersion']; $apacheVersion = $wampConf['apacheVersion']; $doca_version = 'doca'.substr($apacheVersion,0,3); $mysqlVersion = $wampConf['mysqlVersion']; //On récupère la valeur de VirtualHostMenu $VirtualHostMenu = $wampConf['VirtualHostSubMenu']; //on récupère la valeur de apachePortUsed $port = $wampConf['apachePortUsed']; $UrlPort = $port !== "80" ? ":".$port : ''; //On récupère le ou les valeurs des ports en écoute dans Apache $ListenPorts = implode(' - ',listen_ports()); //on récupère la valeur de mysqlPortUsed $Mysqlport = $wampConf['mysqlPortUsed']; // répertoires à ignorer dans les projets $projectsListIgnore = array ('.','..','wampthemes','wamplangues'); // Recherche des différents thèmes disponibles $styleswitcher = ''."\n"; //affichage du phpinfo if (isset($_GET['phpinfo'])) { $type_info = intval(trim($_GET['phpinfo'])); if($type_info < -1 || $type_info > 64) $type_info = -1; phpinfo($type_info); exit(); } // Language $langue = $wampConf['language']; $i_langues = glob('wamplangues/index_*.php'); $languages = array(); foreach ($i_langues as $value) { $languages[] = str_replace(array('wamplangues/index_','.php'), '', $value); } $langueget = (!empty($_GET['lang']) ? strip_tags(trim($_GET['lang'])) : ''); if(in_array($langueget,$languages)) $langue = $langueget; // Recherche des différentes langues disponibles $langueswitcher = '
'; include 'wamplangues/index_english.php'; if(file_exists('wamplangues/index_'.$langue.'.php')) { $langue_temp = $langues; include 'wamplangues/index_'.$langue.'.php'; $langues = array_merge($langue_temp, $langues); } //initialisation // Récupération MySQL si supporté $nbDBMS = 0; $MySQLdb = ''; if(isset($wampConf['SupportMySQL']) && $wampConf['SupportMySQL'] =='on') { $nbDBMS++; $defaultDBMSMySQL = ($wampConf['mysqlPortUsed'] == '3306') ? " - ".$langues['defaultDBMS'] : ""; $MySQLdb = <<< EOF
{$langues['versm']}
${mysqlVersion} - {$langues['mysqlportUsed']}{$Mysqlport}{$defaultDBMSMySQL} -  {$langues['documentation']} MySQL
EOF; } // Récupération MariaDB si supporté $MariaDB = ''; if(isset($wampConf['SupportMariaDB']) && $wampConf['SupportMariaDB'] =='on') { $nbDBMS++; $defaultDBMSMaria = ($wampConf['mariaPortUsed'] == '3306') ? " - ".$langues['defaultDBMS'] : ""; $MariaDB = <<< EOF
{$langues['versmaria']}
${c_mariadbVersion} - {$langues['mariaportUsed']}{$wampConf['mariaPortUsed']}{$defaultDBMSMaria} -  {$langues['documentation']} MariaDB
EOF; } /* Help MySQL - MariaDB popup */ $popupLink = ''; if($nbDBMS > 1) { $popupLink = <<< EOF - MySQL - MariaDB{$langues['HelpMySQLMariaDB']} EOF; } //Default DBMS in first position if(empty($defaultDBMSMySQL)) $DBMSTypes = $MariaDB.str_replace('',$popupLink.'',$MySQLdb); else $DBMSTypes = $MySQLdb.str_replace('',$popupLink.'',$MariaDB); // No Database Mysql System $noDBMS = (empty($MySQLdb) && empty($MariaDB)) ? true : false; $phpmyadminTool = $noDBMS ? '' : '
  • phpmyadmin
  • '; $aliasContents = ''; // récupération des alias if (is_dir($aliasDir)) { $handle=opendir($aliasDir); while (($file = readdir($handle))!==false) { if (is_file($aliasDir.$file) && strstr($file, '.conf')) { if(!($noDBMS && ($file == 'phpmyadmin.conf' || $file == 'adminer.conf'))) { $msg = ''; $aliasContents .= '
  • '.str_replace('.conf','',$file).'
  • '; } } } closedir($handle); } if (empty($aliasContents)) $aliasContents = "
  • ".$langues['txtNoAlias']."
  • \n"; //Récupération des ServerName de httpd-vhosts.conf $addVhost = "
  • ".$langues['txtAddVhost']."
  • "; if($VirtualHostMenu == "on") { $vhostError = false; $vhostErrorCorrected = true; $error_message = array(); $allToolsClass = "four-columns"; $virtualHost = check_virtualhost(); $vhostsContents = ''; if($virtualHost['include_vhosts'] === false) { $vhostsContents = "
  • Error Include Apache
  • "; $vhostError = true; $error_message[] = sprintf($langues['txtNoIncVhost'],$wampConf['apacheVersion']); } else { if($virtualHost['vhosts_exist'] === false) { $vhostsContents = "
  • No vhosts file
  • "; $vhostError = true; $error_message[] = sprintf($langues['txtNoVhostFile'],$virtualHost['vhosts_file']); } else { if($virtualHost['nb_Server'] > 0) { $port_number = true; $nb_Server = $virtualHost['nb_Server']; $nb_Virtual = $virtualHost['nb_Virtual']; $nb_Document = $virtualHost['nb_Document']; $nb_Directory = $virtualHost['nb_Directory']; $nb_End_Directory = $virtualHost['nb_End_Directory']; foreach($virtualHost['ServerName'] as $key => $value) { if($virtualHost['ServerNameValid'][$value] === false) { $vhostError = true; $vhostErrorCorrected = false; $vhostsContents .= '
  • '.$value.' - syntax error
  • '; $error_message[] = sprintf($langues['txtServerName'],"".$value."",$virtualHost['vhosts_file']); } elseif($virtualHost['ServerNameValid'][$value] === true) { $UrlPortVH = ($virtualHost['ServerNamePort'][$value] != '80') ? ':'.$virtualHost['ServerNamePort'][$value] : ''; if(!$virtualHost['port_listen'] && $virtualHost['ServerNamePortListen'][$value] !== true || $virtualHost['ServerNamePortApacheVar'][$value] !== true) { $value_url = ((strpos($value, ':') !== false) ? strstr($value,':',true) : $value); $vhostsContents .= '
  • '.$value_url.$UrlPortVH.' - Not a Listen port
  • '; if($virtualHost['ServerNamePortListen'][$value] !== true) $msg_error = ' not an Apache Listen port'; elseif($virtualHost['ServerNamePortApacheVar'][$value] !== true) $msg_error = ' not an Apache define variable'; if(!$vhostError) { $vhostError = true; $vhostErrorCorrected = false; $error_message[] = "Port ".$UrlPortVH." used for the VirtualHost is ".$msg_error; } } elseif($virtualHost['ServerNameIp'][$value] !== false) { $vh_ip = $virtualHost['ServerNameIp'][$value]; if($virtualHost['ServerNameIpValid'][$value] !== false) { $vhostsContents .= '
  • '.$vh_ip.' ('.$value.')
  • '; } else { $vhostError = true; $vhostErrorCorrected = false; $vhostsContents .= '
  • '.$vh_ip.' for '.$value.' - IP not valid
  • '; $error_message[] = sprintf($langues['txtServerNameIp'],"".$vh_ip."","".$value."",$virtualHost['vhosts_file']); } } elseif($virtualHost['DocRootNotwww'][$value] === false) { $vhostError = true; $vhostErrorCorrected = false; $vhostsContents .= '
  • '.$value.' - DocumentRoot error
  • '; $error_message[] = sprintf($langues['txtDocRoot'],"".$value."","".$wwwDir.""); } elseif($virtualHost['ServerNameDev'][$value] === true) { $vhostError = true; $vhostErrorCorrected = false; $vhostsContents .= '
  • '.$value.' - TLD error
  • '; $error_message[] = sprintf($langues['txtTLDdev'],"".$value."",".dev"); } else { $value_url = ((strpos($value, ':') !== false) ? strstr($value,':',true) : $value); $valueaff = ($virtualHost['ServerNameIDNA'][$value] === true) ? "

    IDNA-> ".$virtualHost['ServerNameUTF8'][$value]."

    " : ''; $vhostsContents .= '
  • '.$value.''.$valueaff.'
  • '; } } else { $vhostError = true; $error_message[] = sprintf($langues['txtVhostNotClean'],$virtualHost['vhosts_file']); } } //Check number of ".$value."", "DocumentRoot", $virtualHost['vhosts_file']); break; } } } //Check validity of Directory Path if($virtualHost['directory'] === false) { foreach($virtualHost['directoryPath'] as $value) { if($virtualHost['directoryPathValid'][$value] === false) { $documentPathError = $value; $vhostError = true; $vhostErrorCorrected = false; $error_message[] = sprintf($langues['txtNoPath'],"".$value."", "<Directory ...", $virtualHost['vhosts_file']); break; } } } //Check number of to number of ServerName if($nb_Server != $nb_Virtual && $wampConf['NotCheckDuplicate'] == 'off') { $port_number = false; $vhostError = true; $vhostErrorCorrected = false; $error_message[] = sprintf($langues['txtNbNotEqual'],"<VirtualHost","ServerName",$virtualHost['vhosts_file']); } //Check number of port definition of equals to number of ServerName if($virtualHost['nb_Virtual_Port'] != $nb_Virtual && $wampConf['NotCheckDuplicate'] == 'off') { $port_number = false; $vhostError = true; $vhostErrorCorrected = false; $error_message[] = sprintf($langues['txtNbNotEqual'],"port definition of <VirtualHost *:xx>","ServerName",$virtualHost['vhosts_file']); } //Check validity of port number if($port_number && $virtualHost['port_number'] === false) { $port_number = false; $vhostError = true; $vhostErrorCorrected = false; $error_message[] = sprintf($langues['txtPortNumber'],"<VirtualHost *:port>",$virtualHost['vhosts_file']); } //Check if duplicate ServerName if($virtualHost['nb_duplicate'] > 0) { $DuplicateNames = ''; foreach($virtualHost['duplicate'] as $NameValue) $DuplicateNames .= " ".$NameValue; $vhostError = true; $vhostErrorCorrected = false; $error_message[] = "Duplicate ServerName ".$DuplicateNames." into ".$virtualHost['vhosts_file']; } //Check if duplicate Server IP if($virtualHost['nb_duplicateIp'] > 0) { $DuplicateNames = ''; foreach($virtualHost['duplicateIp'] as $NameValue) $DuplicateNames .= " ".$NameValue; $vhostError = true; $vhostErrorCorrected = false; $error_message[] = "Duplicate IP ".$DuplicateNames." into ".$virtualHost['vhosts_file']; } } } } if(empty($vhostsContents)) { $vhostsContents = "
  • No VirtualHost
  • "; $vhostError = true; $error_message[] = sprintf($langues['txtNoVhost'],$wampConf['apacheVersion']); } if(!$c_hostsFile_writable){ $vhostError = true; $error_message[] = sprintf($langues['txtNotWritable'],$c_hostsFile)."
    ".nl2br($WarningMsg); } if($vhostError) { $vhostsContents .= "
  • Error(s) See below
  • "; $error_content .= "

    "; foreach($error_message as $value) { $error_content .= $value."
    "; } $error_content .= "

    \n"; if($vhostErrorCorrected) $addVhost = "
  • ".$langues['txtAddVhost']." ".$langues['txtCorrected']."
  • "; } } else { $allToolsClass = "three-columns"; } //Fin Récupération ServerName // récupération des projets $handle=opendir("."); $projectContents = ''; while (($file = readdir($handle))!==false) { if (is_dir($file) && !in_array($file,$projectsListIgnore)) { $projectContents .= '
  • '.$file.'
  • '; } } closedir($handle); if (empty($projectContents)) $projectContents = "
  • ".$langues['txtNoProjet']."
  • \n"; else { if(strpos($projectContents,"http://localhost/") !== false) { $projectContents .= "
  • Warning: See below
  • "; if(!isset($error_content)) $error_content = ''; $error_content .= "

    ".sprintf($langues['nolocalhost'],$wampConf['apacheVersion'])."

    "; } else { $projectContents .= "
  • ".sprintf($langues['txtProjects'],$wwwDir)."
  • "; } } //initialisation $phpExtContents = ''; // récupération des extensions PHP $loaded_extensions = get_loaded_extensions(); // classement alphabétique des extensions setlocale(LC_ALL,"{$langues['locale']}"); sort($loaded_extensions,SORT_LOCALE_STRING); foreach ($loaded_extensions as $extension) $phpExtContents .= "
  • ${extension}
  • "; //vérifications diverses - Quel php.ini est chargé ? $phpini = strtolower(trim(str_replace("\\","/",php_ini_loaded_file()))); $c_phpConfFileOri = strtolower($c_phpVersionDir.'/php'.$wampConf['phpVersion'].'/'.$phpConfFileForApache); $c_phpCliConf = strtolower($c_phpVersionDir.'/php'.$wampConf['phpVersion'].'/'.$wampConf['phpConfFile']); if($phpini != strtolower($c_phpConfFile) && $phpini != $c_phpConfFileOri) { $error_content .= "

    *** ERROR *** The PHP configuration loaded file is: ".$phpini." - should be: ".$c_phpConfFile." or ".$c_phpConfFileOri; $error_content .= "
    You must perform: Right-click icon Wampmanager -> Refresh
    "; if($phpini == $c_phpCliConf || $phpini == $c_phpCliConfFile) $error_content .= " - This file is only for PHP in Command Line - Maybe you've added 'PHPIniDir' in the 'httpd.conf' file. Delete or comment this line."; $error_content .= "

    "; } if($filelist = php_ini_scanned_files()) { if (strlen($filelist) > 0) { $error_content .= "

    *** ERROR *** There are too much php.ini files

    "; $files = explode(',', $filelist); foreach ($files as $file) { $error_content .= "

    *** ERROR *** There are other php.ini files: ".trim(str_replace("\\","/",$file))."

    "; } } } $pageContents = <<< EOPAGE {$langues['titreHtml']}

    {$langues['titreConf']}

    {$langues['versa']}
    ${apacheVersion}  - {$langues['documentation']}
    {$langues['server']}
    ${server_software} - {$langues['portUsed']}{$ListenPorts}
    {$langues['versp']}
    ${phpVersion}  - {$langues['documentation']}
    {$langues['phpExt']}
      ${phpExtContents}
    ${DBMSTypes}
     

    {$langues['titrePage']}

    {$langues['txtProjet']}

      ${projectContents}

    {$langues['txtAlias']}

      ${aliasContents}
    EOPAGE; if($VirtualHostMenu == "on") { $pageContents .= <<< EOPAGEA

    {$langues['txtVhost']}

      ${vhostsContents}
    EOPAGEA; } if(!empty($error_content)) { $pageContents .= <<< EOPAGEB
    ${error_content} EOPAGEB; } $pageContents .= <<< EOPAGEC
     
    EOPAGEC; echo $pageContents; ?>