<?php

//[modif oto]
// Mise à jour dynamique ancienne version Apache utilisée
require 'wampserver.lib.php';
require 'config.inc.php';
$newApacheVersion = $_SERVER['argv'][1];
// on charge le fichier de configuration du php courant
require $c_phpVersionDir . '/php' . $wampConf['phpVersion'] . '/' . $wampBinConfFiles;
// on verifie que la nouvelle version de apache est compatible avec le php courant
$newApacheVersionTemp = $newApacheVersion;
while (!isset($phpConf['apache'][$newApacheVersionTemp]) && $newApacheVersionTemp != '') {
    $pos = strrpos($newApacheVersionTemp, '.');
    $newApacheVersionTemp = substr($newApacheVersionTemp, 0, $pos);
}
if ($newApacheVersionTemp == '') {
    exit;
}
// on charge le fichier de conf de la nouvelle version
require $c_apacheVersionDir . '/apache' . $newApacheVersion . '/' . $wampBinConfFiles;
$apacheConf['apacheVersion'] = $newApacheVersion;
// Renseigne l'ancienne version Apache
$apacheConf['apacheLastKnown'] = $wampConf['apacheVersion'];
wampIniSet($configurationFile, $apacheConf);
Beispiel #2
0
function switchPhpVersion($newPhpVersion)
{
    require 'config.inc.php';
    //on charge le fichier de conf de la nouvelle version
    require $c_phpVersionDir . '/php' . $newPhpVersion . '/' . $wampBinConfFiles;
    //on determine les textes httpd.conf en fonction de la version d'apache
    $apacheVersion = $wampConf['apacheVersion'];
    while (!isset($phpConf['apache'][$apacheVersion]) && $apacheVersion != '') {
        $pos = strrpos($apacheVersion, '.');
        $apacheVersion = substr($apacheVersion, 0, $pos);
    }
    // on sauvegarde le php.ini courant
    copy($c_phpConfFile, $c_phpVersionDir . '/php' . $wampConf['phpVersion'] . '/' . $phpConfFileForApache);
    //on place le nouveau php.ini
    copy($c_phpVersionDir . '/php' . $newPhpVersion . '/' . $phpConfFileForApache, $c_phpConfFile);
    // on modifie le fichier de conf d'apache
    $httpdContents = file($c_apacheConfFile);
    foreach ($httpdContents as $line) {
        if (strstr($line, 'LoadModule') && strstr($line, 'php')) {
            $newHttpdContents .= 'LoadModule ' . $phpConf['apache'][$apacheVersion]['LoadModuleName'] . ' "' . $c_phpVersionDir . '/php' . $newPhpVersion . '/' . $phpConf['apache'][$apacheVersion]['LoadModuleFile'] . '"' . "\r\n";
        } elseif ($phpConf['apache'][$apacheVersion]['AddModule'] != '' && strstr($line, 'AddModule') && strstr($line, 'php')) {
            $newHttpdContents .= 'AddModule ' . $phpConf['apache'][$apacheVersion]['AddModule'] . "\r\n";
        } else {
            $newHttpdContents .= $line;
        }
    }
    file_put_contents($c_apacheConfFile, $newHttpdContents);
    //on copie des dll
    foreach ($phpDllToCopy as $dll) {
        if (is_file($c_phpVersionDir . '/php' . $newPhpVersion . '/' . $dll)) {
            unlink($c_apacheVersionDir . '/apache' . $wampConf['apacheVersion'] . '/' . $wampConf['apacheExeDir'] . '/' . $dll);
            copy($c_phpVersionDir . '/php' . $newPhpVersion . '/' . $dll, $c_apacheVersionDir . '/apache' . $wampConf['apacheVersion'] . '/' . $wampConf['apacheExeDir'] . '/' . $dll);
        }
    }
    //on modifie la conf de wampserver
    $wampIniNewContents['phpIniDir'] = $phpConf['phpIniDir'];
    $wampIniNewContents['phpExeDir'] = $phpConf['phpExeDir'];
    $wampIniNewContents['phpConfFile'] = $phpConf['phpConfFile'];
    $wampIniNewContents['phpVersion'] = $newPhpVersion;
    wampIniSet($configurationFile, $wampIniNewContents);
}
Beispiel #3
0
function switchPhpVersion($newPhpVersion)
{
    require 'config.inc.php';
    //on charge le fichier de conf de la nouvelle version
    require $c_phpVersionDir . '/php' . $newPhpVersion . '/' . $wampBinConfFiles;
    //on determine les textes httpd.conf en fonction de la version d'apache
    $apacheVersion = $wampConf['apacheVersion'];
    while (!isset($phpConf['apache'][$apacheVersion]) && $apacheVersion != '') {
        $pos = strrpos($apacheVersion, '.');
        $apacheVersion = substr($apacheVersion, 0, $pos);
    }
    // on modifie le fichier de conf d'apache
    $httpdContents = file($c_apacheConfFile);
    $newHttpdContents = '';
    foreach ($httpdContents as $line) {
        if (strstr($line, 'LoadModule') && strstr($line, 'php')) {
            $newHttpdContents .= 'LoadModule ' . $phpConf['apache'][$apacheVersion]['LoadModuleName'] . ' "' . $c_phpVersionDir . '/php' . $newPhpVersion . '/' . $phpConf['apache'][$apacheVersion]['LoadModuleFile'] . '"' . "\r\n";
        } elseif (!empty($phpConf['apache'][$apacheVersion]['AddModule']) && strstr($line, 'AddModule') && strstr($line, 'php')) {
            $newHttpdContents .= 'AddModule ' . $phpConf['apache'][$apacheVersion]['AddModule'] . "\r\n";
        } else {
            $newHttpdContents .= $line;
        }
    }
    file_put_contents($c_apacheConfFile, $newHttpdContents);
    //on modifie la conf de wampserver
    $wampIniNewContents['phpIniDir'] = $phpConf['phpIniDir'];
    $wampIniNewContents['phpExeDir'] = $phpConf['phpExeDir'];
    $wampIniNewContents['phpConfFile'] = $phpConf['phpConfFile'];
    // Renseigne ancienne version PHP
    $wampIniNewContents['phpLastKnown'] = $wampConf['phpVersion'];
    $wampIniNewContents['phpVersion'] = $newPhpVersion;
    wampIniSet($configurationFile, $wampIniNewContents);
    //Create symbolic link to php dll's and to phpForApache.ini of new version
    linkPhpDllToApacheBin($newPhpVersion);
}
Beispiel #4
0
            if (strpos($value, "DO_NOT_DELETE") !== false) {
                unlink($c_phpVersionDir . "/" . $value);
            }
        }
    }
    $fp = fopen($c_phpVersionDir . "/DO_NOT_DELETE_" . $c_phpCliVersion . ".txt", 'w');
    fwrite($fp, $do_not_delete_txt);
    fclose($fp);
}
//Check if PhpMyAdmin version in wampmanager.conf is the one used
$PhpMyAdminFileContents = @file_get_contents($aliasDir . "phpmyadmin.conf");
//Exemple: <Directory "J:/wamp/apps/phpmyadmin4.5.2/">
if (preg_match("#^[ \t]*<Directory.*phpmyadmin([0-9\\.]*)/\"?>\r?\$#m", $PhpMyAdminFileContents, $matches) == 1) {
    if (version_compare($wampConf['phpmyadminVersion'], $matches[1]) != 0) {
        $phpmyAdminVersion['phpmyadminVersion'] = $matches[1];
        wampIniSet($configurationFile, $phpmyAdminVersion);
    }
}
//End of verify files
// ************************
//   gestion de la langue
// on recupere la langue courante
if (isset($wampConf['language'])) {
    $lang = $wampConf['language'];
} else {
    $lang = $wampConf['defaultLanguage'];
}
// on inclus le fichier correspondant si existant
require $langDir . $wampConf['defaultLanguage'] . '.lang';
if (is_file($langDir . $lang . '.lang')) {
    require $langDir . $lang . '.lang';
Beispiel #5
0
        $fp = fopen($c_phpConfFile, 'w');
        fwrite($fp, $iniFileContents);
        fclose($fp);
    }
}
//Check if the file wamp/bin/php/DO_NOT_DELETE_x.y.z.txt match CLI php version used
if (!file_exists($c_phpVersionDir . "/DO_NOT_DELETE_" . $c_phpCliVersion . ".txt")) {
    $do_not_delete_txt = "This PHP version " . $c_phpCliVersion . " is used by WampServer in CLI mode.\nIf you delete it, WampServer won't work anymore.";
    if ($handle = opendir($c_phpVersionDir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != ".." && !is_dir($c_phpVersionDir . '/' . $file)) {
                $list[] = $file;
            }
        }
        closedir($handle);
    }
    if (!empty($list)) {
        foreach ($list as $value) {
            if (strpos($value, "DO_NOT_DELETE") !== false) {
                unlink($c_phpVersionDir . "/" . $value);
            }
        }
    }
    $fp = fopen($c_phpVersionDir . "/DO_NOT_DELETE_" . $c_phpCliVersion . ".txt", 'w');
    fwrite($fp, $do_not_delete_txt);
    fclose($fp);
}
if (version_compare($wampConf['wampserverVersion'], $wamp_oto_version) < 0) {
    $wampVersion['wampserverVersion'] = $wamp_oto_version;
    wampIniSet($configurationFile, $wampVersion);
}
<?php

// [modif oto] - script ajouté pour gérer les nouveaux paramètres
// de configuration ajoutés à wampmanager.conf
require 'wampserver.lib.php';
require 'config.inc.php';
if ($_SERVER['argv'][2] == 'create') {
    createWampConfParam($_SERVER['argv'][1], $_SERVER['argv'][3], $_SERVER['argv'][4], $configurationFile);
} else {
    $wampIniNewContents[$_SERVER['argv'][1]] = $_SERVER['argv'][2];
    wampIniSet($configurationFile, $wampIniNewContents);
}
    if ($numMariadb < 0 || $numMysql > 9999) {
        $numMariadb = 0;
    }
    $newMariadb = "wampmariadb" . $numMariadb;
} else {
    $newMariadb = "wampmariadb";
}
$newServicesNames['ServiceApache'] = $newApache;
$newServicesNames['ServiceMysql'] = $newMysql;
$newServicesNames['ServicenewMariadb'] = $newMariadb;
$newServicesNames['apacheServiceInstallParams'] = "-n " . $newApache . " -k install";
$newServicesNames['apacheServiceRemoveParams'] = "-n " . $newApache . " -k uninstall";
$newServicesNames['mysqlServiceInstallParams'] = "--install-manual " . $newMysql;
$newServicesNames['mysqlServiceRemoveParams'] = "--remove " . $newMysql;
$newServicesNames['mariadbServiceInstallParams'] = "--install-manual " . $newMariadb;
$newServicesNames['mariadbServiceRemoveParams'] = "--remove " . $newMariadb;
//Replace services names in wampmanager.conf
wampIniSet($configurationFile, $newServicesNames);
//Install new services
//Install Apache service
$command = 'start /b /wait ' . $c_apacheExe . ' ' . $newServicesNames['apacheServiceInstallParams'];
`{$command}`;
//Apache service to manual start
$command = "start /b /wait SC \\\\. config " . $newApache . " start= demand";
`{$command}`;
//Install Mysql service
$command = 'start /b /wait ' . $c_mysqlExe . ' ' . $newServicesNames['mysqlServiceInstallParams'];
`{$command}`;
//Install Mariadb service
$command = 'start /b /wait ' . $c_mariadbExe . ' ' . $newServicesNames['mariadbServiceInstallParams'];
`{$command}`;
    //To avoid problems with subsequent replacements. To be sure Unix-like end of lines.
    $phpIniFileContents = preg_replace("/\r\n?/", "\n", $phpIniFileContents);
    $nb_phpIni = 0;
    //must be two replacements
    $phpIniReplace = false;
    $findTxtRegex = array('/^(mysql.default_port)[ \\t]*=.*$/m', '/^(mysqli.default_port)[ \\t]*=.*$/m');
    $phpIniFileContents = preg_replace($findTxtRegex, "\$1 = " . $portToUse, $phpIniFileContents, -1, $nb_phpIni);
    if ($nb_phpIni == 2) {
        $phpIniReplace = true;
    }
    if ($myIniReplace && $phpIniReplace) {
        $myIni = fopen($c_mysqlConfFile, "w");
        fwrite($myIni, $mySqlIniFileContents);
        fclose($myIni);
        $phpIni = fopen($c_phpConfFile, "w");
        fwrite($phpIni, $phpIniFileContents);
        fclose($phpIni);
        $myIniConf['mysqlPortUsed'] = $portToUse;
        if ($portToUse == $c_DefaultMysqlPort) {
            $myIniConf['mysqlUseOtherPort'] = "off";
        } else {
            $myIniConf['mysqlUseOtherPort'] = "on";
        }
        wampIniSet($configurationFile, $myIniConf);
    }
} else {
    echo "The port number you give: " . $portToUse . "\n\n";
    echo "is not valid (Must be between 3301 and 3309)\n";
    echo "\nPress ENTER to continue...";
    trim(fgets(STDIN));
}
Beispiel #9
0
function switchPhpVersion($newPhpVersion)
{
    require 'config.inc.php';
    //on charge le fichier de conf de la nouvelle version
    require $c_phpVersionDir . '/php' . $newPhpVersion . '/' . $wampBinConfFiles;
    //on determine les textes httpd.conf en fonction de la version d'apache
    $apacheVersion = $wampConf['apacheVersion'];
    while (!isset($phpConf['apache'][$apacheVersion]) && $apacheVersion != '') {
        $pos = strrpos($apacheVersion, '.');
        $apacheVersion = substr($apacheVersion, 0, $pos);
    }
    //on place le nouveau php.ini
    //[modif oto] - Create symbolic link to phpForApache.ini file of active PHP version
    $target = $c_phpVersionDir . "/php" . $newPhpVersion . "/" . $phpConfFileForApache;
    $link = $c_apacheVersionDir . "/apache" . $wampConf['apacheVersion'] . "/" . $wampConf['apacheExeDir'] . "/php.ini";
    if (is_file($link) || is_link($link)) {
        unlink($link);
    }
    symlink($target, $link);
    // on modifie le fichier de conf d'apache
    $httpdContents = file($c_apacheConfFile);
    //[modif oto] - Pour éviter erreur variable non déclarée
    $newHttpdContents = '';
    foreach ($httpdContents as $line) {
        if (strstr($line, 'LoadModule') && strstr($line, 'php')) {
            $newHttpdContents .= 'LoadModule ' . $phpConf['apache'][$apacheVersion]['LoadModuleName'] . ' "' . $c_phpVersionDir . '/php' . $newPhpVersion . '/' . $phpConf['apache'][$apacheVersion]['LoadModuleFile'] . '"' . "\r\n";
        } else {
            $newHttpdContents .= $line;
        }
    }
    file_put_contents($c_apacheConfFile, $newHttpdContents);
    //on copie des dll
    //[modif oto] - Create symbolic link instead of copy files
    foreach ($phpDllToCopy as $dll) {
        $target = $c_phpVersionDir . '/php' . $newPhpVersion . '/' . $dll;
        $link = $c_apacheVersionDir . '/apache' . $wampConf['apacheVersion'] . '/' . $wampConf['apacheExeDir'] . '/' . $dll;
        if (is_file($target)) {
            if (is_file($link) || is_link($link)) {
                unlink($link);
            }
            symlink($target, $link);
        }
    }
    //on modifie la conf de wampserver
    $wampIniNewContents['phpIniDir'] = $phpConf['phpIniDir'];
    $wampIniNewContents['phpExeDir'] = $phpConf['phpExeDir'];
    $wampIniNewContents['phpConfFile'] = $phpConf['phpConfFile'];
    //[modif oto] - Renseigne ancienne version PHP
    $wampIniNewContents['phpLastKnown'] = $wampConf['phpVersion'];
    $wampIniNewContents['phpVersion'] = $newPhpVersion;
    wampIniSet($configurationFile, $wampIniNewContents);
}
<?php

require 'wampserver.lib.php';
require 'config.inc.php';
$newMysqlVersion = $_SERVER['argv'][1];
//on charge le fichier de conf de la nouvelle version
require $c_mysqlVersionDir . '/mysql' . $newMysqlVersion . '/' . $wampBinConfFiles;
$mysqlConf['mysqlVersion'] = $newMysqlVersion;
wampIniSet($configurationFile, $mysqlConf);
Beispiel #11
0
<?php

require 'config.inc.php';
require 'wampserver.lib.php';
//[modif oto] - Update wampserver version from modif oto
if (!empty($wampserverVersionOto) && $wampConf['wampserverVersion'] !== $wampserverVersionOto) {
    $wampConf['wampserverVersion'] = $newWampConf['wampserverVersion'] = $wampserverVersionOto;
    wampIniSet($configurationFile, $newWampConf);
}
// ************************
//   gestion de la langue
// on recupere la langue courante
if (isset($wampConf['language'])) {
    $lang = $wampConf['language'];
} else {
    $lang = $wampConf['defaultLanguage'];
}
// on inclus le fichier correspondant
if (is_file($langDir . $lang . '.lang')) {
    require $langDir . $lang . '.lang';
} else {
    require $langDir . $wampConf['defaultLanguage'] . 'lang';
}
// on inclus les fichiers de langue de modules par defaut
if ($handle = opendir($langDir . $modulesDir)) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != ".." && preg_match('|_' . $wampConf['defaultLanguage'] . '|', $file)) {
            include $langDir . $modulesDir . $file;
        }
    }
    closedir($handle);
<?php

//[modif oto]
// Mise à jour dynamique ancienne version MariaDB utilisée
require 'wampserver.lib.php';
require 'config.inc.php';
$newMariadbVersion = $_SERVER['argv'][1];
//on charge le fichier de conf de la nouvelle version
require $c_mariadbVersionDir . '/mariadb' . $newMariadbVersion . '/' . $wampBinConfFiles;
// Renseigne ancienne version MariaDB
$mariadbConf['mariadbLastKnown'] = $wampConf['mariadbVersion'];
$mariadbConf['mariadbVersion'] = $newMariadbVersion;
wampIniSet($configurationFile, $mariadbConf);