function lance_install($lang, $DEBUG = FALSE) { $PHP_SELF = $_SERVER['PHP_SELF']; include CONFIG_PATH . 'dbconnect.php'; include ROOT_PATH . 'version.php'; //verif si create / alter table possible !!! if (!test_create_table($DEBUG)) { echo "<font color=\"red\"><b>CREATE TABLE</b> " . _('install_impossible_sur_db') . " <b>{$mysql_database}</b> (" . _('install_verif_droits_mysql') . " <b>{$mysql_user}</b>)...</font><br> \n"; echo "<br>" . _('install_puis') . " ...<br>\n"; echo "<form action=\"{$PHP_SELF}\" method=\"POST\">\n"; echo "<input type=\"submit\" value=\"" . _('form_redo') . "\">\n"; echo "</form>\n"; } elseif (!test_drop_table($DEBUG)) { echo "<font color=\"red\"><b>DROP TABLE</b> " . _('install_impossible_sur_db') . " <b>{$mysql_database}</b> (" . _('install_verif_droits_mysql') . " <b>{$mysql_user}</b>)...</font><br> \n"; echo "<br>" . _('install_puis') . " ...<br>\n"; echo "<form action=\"{$PHP_SELF}\" method=\"POST\">\n"; echo "<input type=\"submit\" value=\"" . _('form_redo') . "\">\n"; echo "</form>\n"; } else { //on execute le script [nouvelle vesion].sql qui crée et initialise les tables $file_sql = "sql/php_conges_v{$config_php_conges_version}.sql"; if (file_exists($file_sql)) { $result = execute_sql_file($file_sql, $DEBUG); } /*************************************/ // FIN : mise à jour de la "installed_version" et de la langue dans la table conges_config $sql_update_version = "UPDATE conges_config SET conf_valeur = '{$config_php_conges_version}' WHERE conf_nom='installed_version' "; $result_update_version = SQL::query($sql_update_version); $sql_update_lang = "UPDATE conges_config SET conf_valeur = '{$lang}' WHERE conf_nom='lang' "; $result_update_lang = SQL::query($sql_update_lang); $tab_url = explode("/", $_SERVER['PHP_SELF']); array_pop($tab_url); array_pop($tab_url); $url_accueil = implode("/", $tab_url); // on prend l'url complet sans le /install/install.php à la fin $sql_update_lang = "UPDATE conges_config SET conf_valeur = '{$url_accueil}' WHERE conf_nom='URL_ACCUEIL_CONGES' "; $result_update_lang = SQL::query($sql_update_lang); $comment_log = "Install de php_conges (version = {$config_php_conges_version}) "; log_action(0, "", "", $comment_log, $DEBUG); /*************************************/ // on propose la page de config .... echo "<br><br><h2>" . _('install_ok') . " !</h2><br>\n"; echo "<META HTTP-EQUIV=REFRESH CONTENT=\"2; URL=../config/\">"; } }
function e2_drop_table_historique_ajout($DEBUG = FALSE) { if (test_create_table($DEBUG)) { if (test_drop_table($DEBUG)) { $sql_drop_1 = "DROP TABLE `conges_historique_ajout`"; $result_drop_1 = SQL::query($sql_drop_1); } } }
/** * Run Tests of main bridge functionality */ function run_self_test() { global $limit_query_size; if (!function_exists('curl_init')) { echo '<b>PHP CURL extension is disabled.</b><br />Please contact your hosting provider to enable PHP CURL extension. It is necessary for bridge self test only.'; return; } $html = '<h2>' . basename($_SERVER["SCRIPT_NAME"]) . ' Self Test Tool</h2>'; $html .= '<div style="padding: 5px; margin: 10px 0;">This tool checks your website to make sure there are no problems in your hosting configuration.<br />Your hosting support can solve all problems found here.</div>'; $html .= '<table cellpadding=2>' . '<tr>' . '<th>Test Title</th>' . '<th>Result</th>' . '</tr>'; $html .= '<tr><td>Bridge Version</td><td>' . $GLOBALS['version'] . '</td><td></td></tr>'; $html .= '<tr><td>Temporary Directory Exists and Writable</td><td>' . (($res = test_temp_directory()) ? TEST_YES : TEST_NO) . '</td>'; if (!$res) { $html .= '<td width=450>Create temporary dir ' . dirname(__FILE__) . '/tmp and set permissions to write</td>'; } $html .= '<tr><td>Temporary Directory has enough free space </td><td>' . (($res = test_temp_free_space()) ? TEST_YES : TEST_NO) . '</td>'; if (!$res) { $html .= '<td>Delete unused and temporary files or request more disk space from your hosting provider.</td>'; } $html .= '<tr><td><a href="http://www.google.com/search?hl=en&q=post_max_size+php+&aq=f&aqi=&aql=&oq=&gs_rfai=" target="_blank">Post Maximum Size</a> </td><td>' . ini_get('post_max_size') . '</td>'; $html .= '<tr><td><a href="http://php.net/manual/en/book.zlib.php" target="_blank">Zlib PHP Extension</a> Loaded</td><td>' . (($res = test_is_gz_avaliable()) ? TEST_YES : TEST_NO) . '</td>'; if (!$res) { $html .= '<td>Ask your hosting provider to enable Zlib php extension</td>'; } $html .= '<tr><td><a href="http://www.modsecurity.org/documentation/modsecurity-apache/2.5.12/modsecurity2-apache-reference.html" target="_blank">Apache mod_security</a> Disabled</td><td>' . (($res = test_apache_mod_security()) ? TEST_YES : test_is_cgi_mode() == true ? TEST_SKIP : TEST_NO) . '</td>'; if (!$res) { $html .= '<td>Ask your hosting provider to disable mod_security extension for bridge.php</td>'; } $html .= '<tr><td><a href="http://www.hardened-php.net/suhosin/" target="_blank">Suhosin PHP extension</a> Disabled</td><td>' . (($res = test_suhosin_extension_loaded()) ? TEST_YES : TEST_NO) . '</td>'; if (!$res) { $html .= '<td>Ask your hosting provider to disable Suhosin extension for bridge.php or set suhosin.request.max_value_length equal 1048576 (currently ' . intval(ini_get('suhosin.request.max_value_length')) . ') </td>'; } $html .= '<tr><td>Default Login and Password Changed</td><td>' . (($res = test_default_password_is_changed()) ? TEST_YES : TEST_NO) . '</td>'; if (!$res) { $html .= '<td>Change your login credentials in bridge.php to make your connection secure</td>'; } $html .= '<tr><td><a href="http://php.net/manual/en/security.magicquotes.php" target="_blank">Magic Quotes GPC/Runtime</a> disabled</td><td>' . (($res = test_magic_quotes()) ? TEST_YES : TEST_NO) . '</td>'; if (!$res) { $html .= '<td>Ask your hosting provider to disable Magic Quotes php extension</td>'; } $html .= '<tr><td><a href="http://www.google.com/search?hl=en&q=post+multipart+form-data&aq=f&aqi=g2g-m8&aql=&oq=&gs_rfai=" target="_blank">Post (multipart/form-data)</a> Allowed</td><td>' . (($res = test_post_to_self()) ? TEST_YES : TEST_NO) . '</td>'; if (!$res) { $html .= '<td>Method POST is not allowed. Please check your Apache configuration or contact your hosting provider to solve this problem.</td>'; } if ($limit_query_size) { $html .= '<tr><td>Size of database data at one query</td><td>' . $limit_query_size . 'Kb</td>'; } $html .= '<tr><td>Check Default Timezone Set</td><td>' . (ini_get('date.timezone') != "" ? '<span style="color: #008000;">Ok</span> (' . date_default_timezone_get() . ')' : '<span style="color: #007000;">Ok</span> (' . date_default_timezone_get() . ')') . '</td>'; $html .= '<tr><td><b>Database Permissions Check</b></td><td></td></tr>' . '<tr><td>Create Table</td><td>' . (($res = test_create_table()) ? TEST_OK : TEST_FAIL) . '</td>'; if (!$res) { $html .= '<td>Error details: "' . $GLOBALS['testResult'] . '"</td>'; } $html .= '<tr><td>Insert Data Row</td><td>' . (($res = test_insert_row()) ? TEST_OK : TEST_FAIL) . '</td>'; if (!$res) { $html .= '<td>Error details: "' . $GLOBALS['testResult'] . '"</td>'; } $html .= '<tr><td>Update Data Row</td><td>' . (($res = test_update_row()) ? TEST_OK : TEST_FAIL) . '</td>'; if (!$res) { $html .= '<td>Error details: "' . $GLOBALS['testResult'] . '"</td>'; } $html .= '<tr><td>Delete Data Row</td><td>' . (($res = test_delete_row()) ? TEST_OK : TEST_FAIL) . '</td>'; if (!$res) { $html .= '<td>Error details: "' . $GLOBALS['testResult'] . '"</td>'; } $html .= '<tr><td>Drop Table</td><td>' . (($res = test_drop_table()) ? TEST_OK : TEST_FAIL) . '</td>'; if (!$res) { $html .= '<td>Error details: "' . $GLOBALS['testResult'] . '"</td>'; } $html .= '</table><br /><br />' . '<a href="?phpinfo">More information about your PHP configuration</a><br /><br />' . 'Log file path: ' . realpath(m1BridgeGetTempDir() . '/bridge_log.txt') . '<div style="font-size: 12px;">Type: ' . getCartType() . '</div>' . '<div style="margin-top: 15px; font-size: 13px;">PHP MySQL Bridge by <a href="http://emagicone.com" target="_blank" style="color: #15428B">eMagicOne</a></div>'; echo $html; }
function lance_maj($lang, $installed_version, $config_php_conges_version, $etape, $DEBUG = FALSE) { if ($DEBUG) { echo " lang = {$lang} ## etape = {$etape} ## version = {$installed_version}<br>\n"; } $PHP_SELF = $_SERVER['PHP_SELF']; include CONFIG_PATH . 'dbconnect.php'; //*** ETAPE 0 if ($etape == 0) { //avant tout , on conseille une sauvegarde de la database !! (cf vieux index.php) echo "<h3>" . _('install_maj_passer_de') . " <font color=\"black\">{$installed_version}</font> " . _('install_maj_a_version') . " <font color=\"black\">{$config_php_conges_version}</font> .</h3>\n"; echo "<h3><font color=\"red\">" . _('install_maj_sauvegardez') . " !!!</font></h3>\n"; echo "<h2>....</h2>\n"; echo "<br>\n"; echo "<form action=\"{$PHP_SELF}?lang={$lang}\" method=\"POST\">\n"; echo "<input type=\"hidden\" name=\"etape\" value=\"1\">\n"; echo "<input type=\"hidden\" name=\"version\" value=\"{$installed_version}\">\n"; echo "<input type=\"submit\" value=\"" . _('form_continuer') . "\">\n"; echo "</form>\n"; echo "<br><br>\n"; } elseif ($etape == 1) { //verif si create / alter table possible !!! if (!test_create_table($DEBUG)) { echo "<font color=\"red\"><b>CREATE TABLE</b> " . _('install_impossible_sur_db') . " <b>{$mysql_database}</b> (" . _('install_verif_droits_mysql') . " <b>{$mysql_user}</b>)...</font><br> \n"; echo "<br>puis ...<br>\n"; echo "<form action=\"{$PHP_SELF}?lang={$lang}\" method=\"POST\">\n"; echo "<input type=\"hidden\" name=\"etape\"value=\"1\" >\n"; echo "<input type=\"hidden\" name=\"version\" value=\"{$installed_version}\">\n"; echo "<input type=\"submit\" value=\"" . _('form_redo') . "\">\n"; echo "</form>\n"; } elseif (!test_alter_table($DEBUG)) { echo "<font color=\"red\"><b>ALTER TABLE</b> " . _('install_impossible_sur_db') . " <b>{$mysql_database}</b> (" . _('install_verif_droits_mysql') . " <b>{$mysql_user}</b>)...</font><br> \n"; echo "<br>puis ...<br>\n"; echo "<form action=\"{$PHP_SELF}?lang={$lang}\" method=\"POST\">\n"; echo "<input type=\"hidden\" name=\"etape\"value=\"1\" >\n"; echo "<input type=\"hidden\" name=\"version\" value=\"{$installed_version}\">\n"; echo "<input type=\"submit\" value=\"" . _('form_redo') . "\">\n"; echo "</form>\n"; } elseif (!test_drop_table($DEBUG)) { echo "<font color=\"red\"><b>DROP TABLE</b> " . _('install_impossible_sur_db') . " <b>{$mysql_database}</b> (" . _('install_verif_droits_mysql') . " <b>{$mysql_user}</b>)...</font><br> \n"; echo "<br>puis ...<br>\n"; echo "<form action=\"{$PHP_SELF}?lang={$lang}\">\n"; echo "<input type=\"hidden\" name=\"etape\"value=\"1\" >\n"; echo "<input type=\"hidden\" name=\"version\" value=\"{$installed_version}\">\n"; echo "<input type=\"submit\" value=\"" . _('form_redo') . "\">\n"; echo "</form>\n"; } else { if (!$DEBUG) { echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$PHP_SELF}?etape=2&version={$installed_version}&lang={$lang}\">"; } else { echo "<a href=\"{$PHP_SELF}?etape=2&version={$installed_version}&lang={$lang}\">" . _('install_etape') . " 1 OK</a><br>\n"; } } } elseif ($etape == 2) { // si on part d'une version <= v1.0 : on travaille sinon, on passe à l'étape 3 if (substr($installed_version, 0, 1) == "0" || $installed_version == "1.0") { //verif si la copie de l'ancien fichier de config est présent et lisible (install/config_old.php) if (!test_old_config_file($DEBUG)) { echo "<font color=\"red\">\n"; echo _('install_le_fichier') . " \"<b>install / config_old.php</b>\" " . _('install_inaccessible') . " !<br>\n"; echo _('install_maj_conserv_config') . "<br>\n"; echo _('install_maj_copy_config_file') . " \"<b>install</b>\" " . _('install_maj_whith_name') . " \"<b>config_old.php</b>\" " . _('install_maj_and') . "<br>\n"; echo _('install_maj_verif_droit_fichier') . " <br>\n"; echo "</font><br> \n"; echo "<br>" . _('install_puis') . " ...<br>\n"; echo "<form action=\"{$PHP_SELF}?lang={$lang}\" method=\"POST\">\n"; echo "<input type=\"hidden\" name=\"etape\"value=\"2\" >\n"; echo "<input type=\"hidden\" name=\"version\" value=\"{$installed_version}\">\n"; echo "<input type=\"submit\" value=\"" . _('form_continuer') . "\">\n"; echo "</form>\n"; } else { if (!$DEBUG) { echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$PHP_SELF}?etape=3&version={$installed_version}&lang={$lang}\">"; } else { echo "<a href=\"{$PHP_SELF}?etape=3&version={$installed_version}&lang={$lang}\">" . _('install_etape') . " 2 OK</a><br>\n"; } } } else { if (!$DEBUG) { echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$PHP_SELF}?etape=3&version={$installed_version}&lang={$lang}\">"; } else { echo "<a href=\"{$PHP_SELF}?etape=3&version={$installed_version}&lang={$lang}\">" . _('install_etape') . " 2 OK</a><br>\n"; } } } elseif ($etape == 3) { // ATTENTION on ne passe cette étape que si on est en version inferieure à 1.0 ! (donc en v0.xxx) (sinon on passe à l'étape 4) if (substr($installed_version, 0, 1) != "0") { if (!$DEBUG) { echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$PHP_SELF}?etape=4&version={$installed_version}&lang={$lang}\">"; } else { echo "<a href=\"{$PHP_SELF}?etape=4&version={$installed_version}&lang={$lang}\">" . _('install_etape') . " 3 OK</a><br>\n"; } } else { //on lance l'execution de fichier sql de migration l'un après l'autre jusqu a la version 0.10.1 .. $db_version = explode(".", $installed_version); $db_sub_version = (int) $db_version[1]; for ($i = $db_sub_version; $i <= 10; $i++) { if ($i == 10) { // si on en est à v0.10 on passe en v1.0 $sql_file = "sql/upgrade_v0.10_to_v1.0.sql"; } else { $j = $i + 1; $sql_file = "sql/upgrade_v0." . $i . "_to_v0." . $j . ".sql"; } if ($DEBUG) { echo "sql_file = {$sql_file}<br>\n"; } execute_sql_file($sql_file, $DEBUG); } if (!$DEBUG) { echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$PHP_SELF}?etape=4&version=1.0&lang={$lang}\">"; } else { echo "<a href=\"{$PHP_SELF}?etape=4&version=1.0&lang={$lang}\">" . _('install_etape') . " 3 OK</a><br>\n"; } } } elseif ($etape == 4) { // on est au moins à la version 1.0 .... // ensuite tout se fait en php (plus de script de migration sql) // on determine la version la + élevée entre $installed_version et 1.0 , et on part de celle là ! if (substr($installed_version, 0, 1) == "0") { $start_version = "1.0"; } else { $start_version = $installed_version; } //on lance l'execution (include) des scripts d'upgrade l'un après l'autre jusqu a la version voulue ($config_php_conges_version) .. if ($start_version == "1.0") { $file_upgrade = 'upgrade_from_v1.0.php'; $new_installed_version = "1.1"; // execute le script php d'upgrade de la version1.0 (vers la suivante (1.1)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.1") { $file_upgrade = 'upgrade_from_v1.1.php'; $new_installed_version = "1.1.1"; // execute le script php d'upgrade de la version1.1 (vers la suivante (1.1.1)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.1.1") { $file_upgrade = 'upgrade_from_v1.1.1.php'; $new_installed_version = "1.2"; // execute le script php d'upgrade de la version1.1.1 (vers la suivante (1.2)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.2") { $file_upgrade = 'upgrade_from_v1.2.php'; $new_installed_version = "1.2.1"; // execute le script php d'upgrade de la version1.2 (vers la suivante (1.2.1)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.2.1") { $file_upgrade = 'upgrade_from_v1.2.1.php'; $new_installed_version = "1.3.0"; // execute le script php d'upgrade de la version1.2.1 (vers la suivante (1.3.0)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.3.0") { $file_upgrade = 'upgrade_from_v1.3.0.php'; $new_installed_version = "1.3.1"; // execute le script php d'upgrade de la version1.3.0 (vers la suivante (1.3.1)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.3.1") { $file_upgrade = 'upgrade_from_v1.3.1.php'; $new_installed_version = "1.3.2"; // execute le script php d'upgrade de la version1.3.1 (vers la suivante (1.3.2)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.3.2") { $file_upgrade = 'upgrade_from_v1.3.2.php'; $new_installed_version = "1.4.0"; // execute le script php d'upgrade de la version1.3.1.2 (vers la suivante (1.4.0)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.4.0") { $file_upgrade = 'upgrade_from_v1.4.0.php'; $new_installed_version = "1.4.1"; // execute le script php d'upgrade de la version1.4.0 (vers la suivante (1.4.1)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.4.1" || $start_version == "1.4.2") { $file_upgrade = 'upgrade_from_v1.4.2.php'; $new_installed_version = "1.5.0"; // execute le script php d'upgrade de la version1.4.2 (vers la suivante (1.5.0)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.5.0" || $start_version == "1.5.1") { $file_upgrade = 'upgrade_from_v1.5.0.php'; $new_installed_version = "1.6.0"; // execute le script php d'upgrade de la version1.5.0 (vers la suivante (1.6.0)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } elseif ($start_version == "1.6.0") { $file_upgrade = 'upgrade_from_v1.6.0.php'; $new_installed_version = "1.7.0"; // execute le script php d'upgrade de la version1.6.0 (vers la suivante (1.7.0)) echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$file_upgrade}?version={$new_installed_version}&lang={$lang}\">"; } else { if (!$DEBUG) { echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL={$PHP_SELF}?etape=5&version=1.4.1&lang={$lang}\">"; } else { echo "<a href=\"{$PHP_SELF}?etape=5&version=1.5.0&lang={$lang}\">" . _('install_etape') . " 4 OK</a><br>\n"; } } } elseif ($etape == 5) { // FIN // test si fichiers config.php ou config_old.php existent encore (si oui : demande de les éffacer ! if (test_config_file($DEBUG) || test_old_config_file($DEBUG)) { if (test_config_file($DEBUG)) { echo _('install_le_fichier') . " <b>\"config.php\"</b> " . _('install_remove_fichier') . ".<br> \n"; } if (test_old_config_file($DEBUG)) { echo _('install_le_fichier') . " <b>\"install/config_old.php\"</b> " . _('install_remove_fichier') . ".<br> \n"; } echo "<br><a href=\"{$PHP_SELF}?etape=5&version={$config_php_conges_version}&lang={$lang}\">" . _('install_reload_page') . " ....</a><br>\n"; } else { // mise à jour de la "installed_version" et de la langue dans la table conges_config $sql_update_version = "UPDATE conges_config SET conf_valeur = '{$config_php_conges_version}' WHERE conf_nom='installed_version' "; $result_update_version = SQL::query($sql_update_version); $sql_update_lang = "UPDATE conges_config SET conf_valeur = '{$lang}' WHERE conf_nom='lang' "; $result_update_lang = SQL::query($sql_update_lang); $comment_log = "Mise a jour de php_conges (version {$installed_version} --> version {$config_php_conges_version}) "; log_action(0, "", "", $comment_log, $DEBUG); // on propose la page de config .... echo "<br><br><h2>" . _('install_ok') . " !</h2><br>\n"; echo "<META HTTP-EQUIV=REFRESH CONTENT=\"2; URL=../config/\">"; } } else { // rien, on ne devrait jammais arriver dans ce else !!! } }