@@ -11,77 +11,77 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // https://code.spip.net/@install_etape_ldap3_dist |
| 18 | 18 | function install_etape_ldap3_dist() { |
| 19 | - $info = []; |
|
| 20 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 21 | - $login_ldap = _request('login_ldap'); |
|
| 22 | - $pass_ldap = _request('pass_ldap'); |
|
| 23 | - $port_ldap = _request('port_ldap'); |
|
| 19 | + $info = []; |
|
| 20 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 21 | + $login_ldap = _request('login_ldap'); |
|
| 22 | + $pass_ldap = _request('pass_ldap'); |
|
| 23 | + $port_ldap = _request('port_ldap'); |
|
| 24 | 24 | |
| 25 | - $base_ldap_text = defined('_INSTALL_BASE_LDAP') |
|
| 26 | - ? _INSTALL_BASE_LDAP |
|
| 27 | - : 'ou=users, dc=mon-domaine, dc=com'; |
|
| 25 | + $base_ldap_text = defined('_INSTALL_BASE_LDAP') |
|
| 26 | + ? _INSTALL_BASE_LDAP |
|
| 27 | + : 'ou=users, dc=mon-domaine, dc=com'; |
|
| 28 | 28 | |
| 29 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 29 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 30 | 30 | |
| 31 | - echo info_etape( |
|
| 32 | - _T('info_chemin_acces_1'), |
|
| 33 | - info_progression_etape(3, 'etape_ldap', 'install/') |
|
| 34 | - ), |
|
| 35 | - _T('info_chemin_acces_2'); |
|
| 31 | + echo info_etape( |
|
| 32 | + _T('info_chemin_acces_1'), |
|
| 33 | + info_progression_etape(3, 'etape_ldap', 'install/') |
|
| 34 | + ), |
|
| 35 | + _T('info_chemin_acces_2'); |
|
| 36 | 36 | |
| 37 | - $ldap_link = @ldap_connect("$adresse_ldap", "$port_ldap"); |
|
| 38 | - if ($ldap_link) { |
|
| 39 | - @ldap_bind($ldap_link, "$login_ldap", "$pass_ldap"); |
|
| 40 | - $result = @ldap_read($ldap_link, '', 'objectclass=*', ['namingContexts']); |
|
| 41 | - $info = @ldap_get_entries($ldap_link, $result); |
|
| 42 | - @ldap_close($ldap_link); |
|
| 43 | - } |
|
| 37 | + $ldap_link = @ldap_connect("$adresse_ldap", "$port_ldap"); |
|
| 38 | + if ($ldap_link) { |
|
| 39 | + @ldap_bind($ldap_link, "$login_ldap", "$pass_ldap"); |
|
| 40 | + $result = @ldap_read($ldap_link, '', 'objectclass=*', ['namingContexts']); |
|
| 41 | + $info = @ldap_get_entries($ldap_link, $result); |
|
| 42 | + @ldap_close($ldap_link); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $checked = false; |
|
| 46 | - $res = ''; |
|
| 47 | - if (is_array($info) and $info['count'] > 0) { |
|
| 48 | - $res .= '<p>' . _T('info_selection_chemin_acces') . '</p>'; |
|
| 49 | - $res .= '<ul>'; |
|
| 50 | - $n = 0; |
|
| 51 | - for ($i = 0; $i < $info['count']; $i++) { |
|
| 52 | - $names = $info[$i]['namingcontexts']; |
|
| 53 | - if (is_array($names)) { |
|
| 54 | - for ($j = 0; $j < $names['count']; $j++) { |
|
| 55 | - $n++; |
|
| 56 | - $res .= '<li><input name="base_ldap" value="' . spip_htmlspecialchars($names[$j]) . "\" type='radio' id='tab$n'"; |
|
| 57 | - if (!$checked) { |
|
| 58 | - $res .= ' checked="checked"'; |
|
| 59 | - $checked = true; |
|
| 60 | - } |
|
| 61 | - $res .= ' />'; |
|
| 62 | - $res .= "<label for='tab$n'>" . spip_htmlspecialchars($names[$j]) . "</label></li>\n"; |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - $res .= '</ul>'; |
|
| 67 | - $res .= _T('info_ou') . ' '; |
|
| 68 | - } |
|
| 69 | - $res .= "<br />\n<input name=\"base_ldap\" value=\"\" type='radio' id='manuel'"; |
|
| 70 | - if (!$checked) { |
|
| 71 | - $res .= ' checked="checked"'; |
|
| 72 | - $checked = true; |
|
| 73 | - } |
|
| 45 | + $checked = false; |
|
| 46 | + $res = ''; |
|
| 47 | + if (is_array($info) and $info['count'] > 0) { |
|
| 48 | + $res .= '<p>' . _T('info_selection_chemin_acces') . '</p>'; |
|
| 49 | + $res .= '<ul>'; |
|
| 50 | + $n = 0; |
|
| 51 | + for ($i = 0; $i < $info['count']; $i++) { |
|
| 52 | + $names = $info[$i]['namingcontexts']; |
|
| 53 | + if (is_array($names)) { |
|
| 54 | + for ($j = 0; $j < $names['count']; $j++) { |
|
| 55 | + $n++; |
|
| 56 | + $res .= '<li><input name="base_ldap" value="' . spip_htmlspecialchars($names[$j]) . "\" type='radio' id='tab$n'"; |
|
| 57 | + if (!$checked) { |
|
| 58 | + $res .= ' checked="checked"'; |
|
| 59 | + $checked = true; |
|
| 60 | + } |
|
| 61 | + $res .= ' />'; |
|
| 62 | + $res .= "<label for='tab$n'>" . spip_htmlspecialchars($names[$j]) . "</label></li>\n"; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + $res .= '</ul>'; |
|
| 67 | + $res .= _T('info_ou') . ' '; |
|
| 68 | + } |
|
| 69 | + $res .= "<br />\n<input name=\"base_ldap\" value=\"\" type='radio' id='manuel'"; |
|
| 70 | + if (!$checked) { |
|
| 71 | + $res .= ' checked="checked"'; |
|
| 72 | + $checked = true; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - $res .= ' />' |
|
| 76 | - . "\n<label for='manuel'>" . _T('entree_chemin_acces') . '</label> ' |
|
| 77 | - . "\n<fieldset>" |
|
| 78 | - . "<input type='text' name='base_ldap_text' class='text' value=\"$base_ldap_text\" size='40' />" |
|
| 79 | - . "\n</fieldset>" |
|
| 80 | - . "\n<input type='hidden' name='etape' value='ldap4' />" |
|
| 81 | - . install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
|
| 82 | - . bouton_suivant(); |
|
| 75 | + $res .= ' />' |
|
| 76 | + . "\n<label for='manuel'>" . _T('entree_chemin_acces') . '</label> ' |
|
| 77 | + . "\n<fieldset>" |
|
| 78 | + . "<input type='text' name='base_ldap_text' class='text' value=\"$base_ldap_text\" size='40' />" |
|
| 79 | + . "\n</fieldset>" |
|
| 80 | + . "\n<input type='hidden' name='etape' value='ldap4' />" |
|
| 81 | + . install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap']) |
|
| 82 | + . bouton_suivant(); |
|
| 83 | 83 | |
| 84 | - echo generer_form_ecrire('install', $res); |
|
| 84 | + echo generer_form_ecrire('install', $res); |
|
| 85 | 85 | |
| 86 | - echo install_fin_html(); |
|
| 86 | + echo install_fin_html(); |
|
| 87 | 87 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -35,45 +35,45 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | */ |
| 37 | 37 | function install_etape_1_dist() { |
| 38 | - echo install_debut_html(); |
|
| 38 | + echo install_debut_html(); |
|
| 39 | 39 | |
| 40 | - // stopper en cas de grosse incompatibilite de l'hebergement |
|
| 41 | - tester_compatibilite_hebergement(); |
|
| 40 | + // stopper en cas de grosse incompatibilite de l'hebergement |
|
| 41 | + tester_compatibilite_hebergement(); |
|
| 42 | 42 | |
| 43 | - // Recuperer les anciennes donnees pour plus de facilite (si presentes) |
|
| 44 | - $s = !@is_readable(_FILE_CONNECT_TMP) ? '' |
|
| 45 | - : analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 43 | + // Recuperer les anciennes donnees pour plus de facilite (si presentes) |
|
| 44 | + $s = !@is_readable(_FILE_CONNECT_TMP) ? '' |
|
| 45 | + : analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 46 | 46 | |
| 47 | - [$adresse_db, $login_db] = $s ?: login_hebergeur(); |
|
| 47 | + [$adresse_db, $login_db] = $s ?: login_hebergeur(); |
|
| 48 | 48 | |
| 49 | - $chmod = (isset($_GET['chmod']) and preg_match(',^[0-9]+$,', $_GET['chmod'])) ? |
|
| 50 | - sprintf('%04o', $_GET['chmod']) : '0777'; |
|
| 49 | + $chmod = (isset($_GET['chmod']) and preg_match(',^[0-9]+$,', $_GET['chmod'])) ? |
|
| 50 | + sprintf('%04o', $_GET['chmod']) : '0777'; |
|
| 51 | 51 | |
| 52 | - if (@is_readable(_FILE_CHMOD_TMP)) { |
|
| 53 | - $s = @join('', @file(_FILE_CHMOD_TMP)); |
|
| 54 | - if (preg_match("#define\('_SPIP_CHMOD', (.*)\)#", $s, $regs)) { |
|
| 55 | - $chmod = $regs[1]; |
|
| 56 | - } |
|
| 57 | - } |
|
| 52 | + if (@is_readable(_FILE_CHMOD_TMP)) { |
|
| 53 | + $s = @join('', @file(_FILE_CHMOD_TMP)); |
|
| 54 | + if (preg_match("#define\('_SPIP_CHMOD', (.*)\)#", $s, $regs)) { |
|
| 55 | + $chmod = $regs[1]; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - $db = [$adresse_db, _T('entree_base_donnee_2')]; |
|
| 61 | - $login = [$login_db, _T('entree_login_connexion_2')]; |
|
| 62 | - $pass = ['', _T('entree_mot_passe_2')]; |
|
| 60 | + $db = [$adresse_db, _T('entree_base_donnee_2')]; |
|
| 61 | + $login = [$login_db, _T('entree_login_connexion_2')]; |
|
| 62 | + $pass = ['', _T('entree_mot_passe_2')]; |
|
| 63 | 63 | |
| 64 | - $predef = [ |
|
| 65 | - defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : '', |
|
| 66 | - defined('_INSTALL_HOST_DB'), |
|
| 67 | - defined('_INSTALL_USER_DB'), |
|
| 68 | - defined('_INSTALL_PASS_DB') |
|
| 69 | - ]; |
|
| 64 | + $predef = [ |
|
| 65 | + defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : '', |
|
| 66 | + defined('_INSTALL_HOST_DB'), |
|
| 67 | + defined('_INSTALL_USER_DB'), |
|
| 68 | + defined('_INSTALL_PASS_DB') |
|
| 69 | + ]; |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | - echo info_progression_etape(1, 'etape_', 'install/'); |
|
| 72 | + echo info_progression_etape(1, 'etape_', 'install/'); |
|
| 73 | 73 | |
| 74 | - // ces deux chaines de langues doivent etre reecrites |
|
| 74 | + // ces deux chaines de langues doivent etre reecrites |
|
| 75 | 75 | # echo info_etape(_T('info_connexion_mysql'), _T('texte_connexion_mysql').aide ("install1", true)); |
| 76 | - echo info_etape(_T('info_connexion_base_donnee')); |
|
| 77 | - echo install_connexion_form($db, $login, $pass, $predef, "\n<input type='hidden' name='chmod' value='$chmod' />", 2); |
|
| 78 | - echo install_fin_html(); |
|
| 76 | + echo info_etape(_T('info_connexion_base_donnee')); |
|
| 77 | + echo install_connexion_form($db, $login, $pass, $predef, "\n<input type='hidden' name='chmod' value='$chmod' />", 2); |
|
| 78 | + echo install_fin_html(); |
|
| 79 | 79 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -20,199 +20,199 @@ discard block |
||
| 20 | 20 | // https://code.spip.net/@install_bases |
| 21 | 21 | function install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db) { |
| 22 | 22 | |
| 23 | - // Prefix des tables : |
|
| 24 | - // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 25 | - // a partir de ce qui est envoye a l'installation |
|
| 26 | - if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 27 | - $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 28 | - ? $GLOBALS['table_prefix'] |
|
| 29 | - : preparer_prefixe_tables(_request('tprefix')); |
|
| 30 | - // S'il est vide on remet spip |
|
| 31 | - if (!$table_prefix) { |
|
| 32 | - $table_prefix = 'spip'; |
|
| 33 | - } |
|
| 34 | - } else { |
|
| 35 | - $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 39 | - [, $adresse_db, $port] = $r; |
|
| 40 | - } else { |
|
| 41 | - $port = ''; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - $GLOBALS['connexions'][$server_db] |
|
| 45 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 46 | - |
|
| 47 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 48 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 49 | - |
|
| 50 | - $fquery = sql_serveur('query', $server_db); |
|
| 51 | - if ($choix_db == 'new_spip') { |
|
| 52 | - $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 53 | - if (preg_match($re, $sel_db)) { |
|
| 54 | - $ok = sql_create_base($sel_db, $server_db); |
|
| 55 | - if (!$ok) { |
|
| 56 | - $re = "Impossible de creer la base $re"; |
|
| 57 | - spip_log($re); |
|
| 58 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 59 | - } |
|
| 60 | - } else { |
|
| 61 | - $re = "Le nom de la base doit correspondre a $re"; |
|
| 62 | - spip_log($re); |
|
| 63 | - |
|
| 64 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 69 | - // un sql_mode |
|
| 70 | - install_mode_appel($server_db, false); |
|
| 71 | - $GLOBALS['connexions'][$server_db] |
|
| 72 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 73 | - |
|
| 74 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 75 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 76 | - |
|
| 77 | - // Completer le tableau decrivant la connexion |
|
| 78 | - |
|
| 79 | - $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 80 | - $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 81 | - |
|
| 82 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 83 | - if ($old) { |
|
| 84 | - $old = sql_fetch($old, $server_db); |
|
| 85 | - } |
|
| 86 | - if (!$old) { |
|
| 87 | - // Si possible, demander au serveur d'envoyer les textes |
|
| 88 | - // dans le codage std de SPIP, |
|
| 89 | - $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 90 | - |
|
| 91 | - if ($charset) { |
|
| 92 | - sql_set_charset($charset['charset'], $server_db); |
|
| 93 | - $GLOBALS['meta']['charset_sql_base'] = |
|
| 94 | - $charset['charset']; |
|
| 95 | - $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 96 | - $charset['collation']; |
|
| 97 | - $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 98 | - $charset['charset']; |
|
| 99 | - $charsetbase = $charset['charset']; |
|
| 100 | - } else { |
|
| 101 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 102 | - $charsetbase = 'standard'; |
|
| 103 | - } |
|
| 104 | - spip_log("Creation des tables. Codage $charsetbase"); |
|
| 105 | - creer_base($server_db); // AT LAST |
|
| 106 | - // memoriser avec quel charset on l'a creee |
|
| 107 | - |
|
| 108 | - if ($charset) { |
|
| 109 | - $t = [ |
|
| 110 | - 'nom' => 'charset_sql_base', |
|
| 111 | - 'valeur' => $charset['charset'], |
|
| 112 | - 'impt' => 'non' |
|
| 113 | - ]; |
|
| 114 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 115 | - $t['nom'] = 'charset_collation_sql_base'; |
|
| 116 | - $t['valeur'] = $charset['collation']; |
|
| 117 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 118 | - $t['nom'] = 'charset_sql_connexion'; |
|
| 119 | - $t['valeur'] = $charset['charset']; |
|
| 120 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 121 | - } |
|
| 122 | - $t = [ |
|
| 123 | - 'nom' => 'version_installee', |
|
| 124 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 125 | - 'impt' => 'non' |
|
| 126 | - ]; |
|
| 127 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 128 | - $t['nom'] = 'nouvelle_install'; |
|
| 129 | - $t['valeur'] = 1; |
|
| 130 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 131 | - // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 132 | - if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 133 | - @sql_insertq( |
|
| 134 | - 'spip_meta', |
|
| 135 | - ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 136 | - '', |
|
| 137 | - $server_db |
|
| 138 | - ); |
|
| 139 | - } |
|
| 140 | - } else { |
|
| 141 | - // pour recreer les tables disparues au besoin |
|
| 142 | - spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 143 | - creer_base($server_db); |
|
| 144 | - $fupdateq = sql_serveur('updateq', $server_db); |
|
| 145 | - |
|
| 146 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 147 | - |
|
| 148 | - if ($r) { |
|
| 149 | - $r = sql_fetch($r, $server_db); |
|
| 150 | - } |
|
| 151 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 152 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 153 | - $fupdateq( |
|
| 154 | - 'spip_meta', |
|
| 155 | - ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 156 | - "nom='version_installee'", |
|
| 157 | - '', |
|
| 158 | - $server_db |
|
| 159 | - ); |
|
| 160 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 161 | - } |
|
| 162 | - // eliminer la derniere operation d'admin mal terminee |
|
| 163 | - // notamment la mise a jour |
|
| 164 | - @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // recuperer le charset de la connexion dans les meta |
|
| 168 | - $charset = ''; |
|
| 169 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 170 | - if ($r) { |
|
| 171 | - $r = sql_fetch($r, $server_db); |
|
| 172 | - } |
|
| 173 | - if ($r) { |
|
| 174 | - $charset = $r['valeur']; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $ligne_rappel = install_mode_appel($server_db); |
|
| 178 | - |
|
| 179 | - $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 180 | - if (!$result_ok) { |
|
| 181 | - return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if ($chmod_db) { |
|
| 185 | - install_fichier_connexion( |
|
| 186 | - _FILE_CHMOD_TMP, |
|
| 187 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 188 | - ); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - // si ce fichier existe a cette etape c'est qu'il provient |
|
| 192 | - // d'une installation qui ne l'a pas cree correctement. |
|
| 193 | - // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 194 | - |
|
| 195 | - if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 196 | - spip_unlink(_FILE_CONNECT); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - install_fichier_connexion( |
|
| 200 | - _FILE_CONNECT_TMP, |
|
| 201 | - $ligne_rappel |
|
| 202 | - . install_connexion( |
|
| 203 | - $adresse_db, |
|
| 204 | - $port, |
|
| 205 | - $login_db, |
|
| 206 | - $pass_db, |
|
| 207 | - $sel_db, |
|
| 208 | - $server_db, |
|
| 209 | - $table_prefix, |
|
| 210 | - '', |
|
| 211 | - $charset |
|
| 212 | - ) |
|
| 213 | - ); |
|
| 214 | - |
|
| 215 | - return ''; |
|
| 23 | + // Prefix des tables : |
|
| 24 | + // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 25 | + // a partir de ce qui est envoye a l'installation |
|
| 26 | + if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 27 | + $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 28 | + ? $GLOBALS['table_prefix'] |
|
| 29 | + : preparer_prefixe_tables(_request('tprefix')); |
|
| 30 | + // S'il est vide on remet spip |
|
| 31 | + if (!$table_prefix) { |
|
| 32 | + $table_prefix = 'spip'; |
|
| 33 | + } |
|
| 34 | + } else { |
|
| 35 | + $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 39 | + [, $adresse_db, $port] = $r; |
|
| 40 | + } else { |
|
| 41 | + $port = ''; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + $GLOBALS['connexions'][$server_db] |
|
| 45 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 46 | + |
|
| 47 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 48 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 49 | + |
|
| 50 | + $fquery = sql_serveur('query', $server_db); |
|
| 51 | + if ($choix_db == 'new_spip') { |
|
| 52 | + $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 53 | + if (preg_match($re, $sel_db)) { |
|
| 54 | + $ok = sql_create_base($sel_db, $server_db); |
|
| 55 | + if (!$ok) { |
|
| 56 | + $re = "Impossible de creer la base $re"; |
|
| 57 | + spip_log($re); |
|
| 58 | + return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 59 | + } |
|
| 60 | + } else { |
|
| 61 | + $re = "Le nom de la base doit correspondre a $re"; |
|
| 62 | + spip_log($re); |
|
| 63 | + |
|
| 64 | + return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 69 | + // un sql_mode |
|
| 70 | + install_mode_appel($server_db, false); |
|
| 71 | + $GLOBALS['connexions'][$server_db] |
|
| 72 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 73 | + |
|
| 74 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 75 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 76 | + |
|
| 77 | + // Completer le tableau decrivant la connexion |
|
| 78 | + |
|
| 79 | + $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 80 | + $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 81 | + |
|
| 82 | + $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 83 | + if ($old) { |
|
| 84 | + $old = sql_fetch($old, $server_db); |
|
| 85 | + } |
|
| 86 | + if (!$old) { |
|
| 87 | + // Si possible, demander au serveur d'envoyer les textes |
|
| 88 | + // dans le codage std de SPIP, |
|
| 89 | + $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 90 | + |
|
| 91 | + if ($charset) { |
|
| 92 | + sql_set_charset($charset['charset'], $server_db); |
|
| 93 | + $GLOBALS['meta']['charset_sql_base'] = |
|
| 94 | + $charset['charset']; |
|
| 95 | + $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 96 | + $charset['collation']; |
|
| 97 | + $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 98 | + $charset['charset']; |
|
| 99 | + $charsetbase = $charset['charset']; |
|
| 100 | + } else { |
|
| 101 | + spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 102 | + $charsetbase = 'standard'; |
|
| 103 | + } |
|
| 104 | + spip_log("Creation des tables. Codage $charsetbase"); |
|
| 105 | + creer_base($server_db); // AT LAST |
|
| 106 | + // memoriser avec quel charset on l'a creee |
|
| 107 | + |
|
| 108 | + if ($charset) { |
|
| 109 | + $t = [ |
|
| 110 | + 'nom' => 'charset_sql_base', |
|
| 111 | + 'valeur' => $charset['charset'], |
|
| 112 | + 'impt' => 'non' |
|
| 113 | + ]; |
|
| 114 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 115 | + $t['nom'] = 'charset_collation_sql_base'; |
|
| 116 | + $t['valeur'] = $charset['collation']; |
|
| 117 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 118 | + $t['nom'] = 'charset_sql_connexion'; |
|
| 119 | + $t['valeur'] = $charset['charset']; |
|
| 120 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 121 | + } |
|
| 122 | + $t = [ |
|
| 123 | + 'nom' => 'version_installee', |
|
| 124 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 125 | + 'impt' => 'non' |
|
| 126 | + ]; |
|
| 127 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 128 | + $t['nom'] = 'nouvelle_install'; |
|
| 129 | + $t['valeur'] = 1; |
|
| 130 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 131 | + // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 132 | + if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 133 | + @sql_insertq( |
|
| 134 | + 'spip_meta', |
|
| 135 | + ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 136 | + '', |
|
| 137 | + $server_db |
|
| 138 | + ); |
|
| 139 | + } |
|
| 140 | + } else { |
|
| 141 | + // pour recreer les tables disparues au besoin |
|
| 142 | + spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 143 | + creer_base($server_db); |
|
| 144 | + $fupdateq = sql_serveur('updateq', $server_db); |
|
| 145 | + |
|
| 146 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 147 | + |
|
| 148 | + if ($r) { |
|
| 149 | + $r = sql_fetch($r, $server_db); |
|
| 150 | + } |
|
| 151 | + $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 152 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 153 | + $fupdateq( |
|
| 154 | + 'spip_meta', |
|
| 155 | + ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 156 | + "nom='version_installee'", |
|
| 157 | + '', |
|
| 158 | + $server_db |
|
| 159 | + ); |
|
| 160 | + spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 161 | + } |
|
| 162 | + // eliminer la derniere operation d'admin mal terminee |
|
| 163 | + // notamment la mise a jour |
|
| 164 | + @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // recuperer le charset de la connexion dans les meta |
|
| 168 | + $charset = ''; |
|
| 169 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 170 | + if ($r) { |
|
| 171 | + $r = sql_fetch($r, $server_db); |
|
| 172 | + } |
|
| 173 | + if ($r) { |
|
| 174 | + $charset = $r['valeur']; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $ligne_rappel = install_mode_appel($server_db); |
|
| 178 | + |
|
| 179 | + $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 180 | + if (!$result_ok) { |
|
| 181 | + return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if ($chmod_db) { |
|
| 185 | + install_fichier_connexion( |
|
| 186 | + _FILE_CHMOD_TMP, |
|
| 187 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 188 | + ); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + // si ce fichier existe a cette etape c'est qu'il provient |
|
| 192 | + // d'une installation qui ne l'a pas cree correctement. |
|
| 193 | + // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 194 | + |
|
| 195 | + if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 196 | + spip_unlink(_FILE_CONNECT); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + install_fichier_connexion( |
|
| 200 | + _FILE_CONNECT_TMP, |
|
| 201 | + $ligne_rappel |
|
| 202 | + . install_connexion( |
|
| 203 | + $adresse_db, |
|
| 204 | + $port, |
|
| 205 | + $login_db, |
|
| 206 | + $pass_db, |
|
| 207 | + $sel_db, |
|
| 208 | + $server_db, |
|
| 209 | + $table_prefix, |
|
| 210 | + '', |
|
| 211 | + $charset |
|
| 212 | + ) |
|
| 213 | + ); |
|
| 214 | + |
|
| 215 | + return ''; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -227,169 +227,169 @@ discard block |
||
| 227 | 227 | * @return string Le préfixe corrigé |
| 228 | 228 | */ |
| 229 | 229 | function preparer_prefixe_tables($prefixe) { |
| 230 | - return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 230 | + return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // https://code.spip.net/@install_propose_ldap |
| 234 | 234 | function install_propose_ldap() { |
| 235 | - return generer_form_ecrire('install', ( |
|
| 236 | - fieldset( |
|
| 237 | - _T('info_authentification_externe'), |
|
| 238 | - [ |
|
| 239 | - 'etape' => [ |
|
| 240 | - 'label' => _T('texte_annuaire_ldap_1'), |
|
| 241 | - 'valeur' => 'ldap1', |
|
| 242 | - 'hidden' => true |
|
| 243 | - ] |
|
| 244 | - ], |
|
| 245 | - bouton_suivant(_T('bouton_acces_ldap')) |
|
| 246 | - ))); |
|
| 235 | + return generer_form_ecrire('install', ( |
|
| 236 | + fieldset( |
|
| 237 | + _T('info_authentification_externe'), |
|
| 238 | + [ |
|
| 239 | + 'etape' => [ |
|
| 240 | + 'label' => _T('texte_annuaire_ldap_1'), |
|
| 241 | + 'valeur' => 'ldap1', |
|
| 242 | + 'hidden' => true |
|
| 243 | + ] |
|
| 244 | + ], |
|
| 245 | + bouton_suivant(_T('bouton_acces_ldap')) |
|
| 246 | + ))); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | // https://code.spip.net/@install_premier_auteur |
| 251 | 251 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 252 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 253 | - info_etape( |
|
| 254 | - _T('info_informations_personnelles'), |
|
| 255 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | - aider('install5', true) . |
|
| 257 | - '<p>' . |
|
| 258 | - ($auteur_obligatoire ? |
|
| 259 | - '' |
|
| 260 | - : |
|
| 261 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 262 | - ) |
|
| 263 | - ) |
|
| 264 | - . generer_form_ecrire('install', ( |
|
| 265 | - "\n<input type='hidden' name='etape' value='3b' />" |
|
| 266 | - . $hidden |
|
| 267 | - . fieldset( |
|
| 268 | - _T('info_identification_publique'), |
|
| 269 | - [ |
|
| 270 | - 'nom' => [ |
|
| 271 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 272 | - 'valeur' => $nom, |
|
| 273 | - 'required' => $auteur_obligatoire, |
|
| 274 | - ], |
|
| 275 | - 'email' => [ |
|
| 276 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 277 | - 'valeur' => $email, |
|
| 278 | - ] |
|
| 279 | - ] |
|
| 280 | - ) |
|
| 281 | - |
|
| 282 | - . fieldset( |
|
| 283 | - _T('entree_identifiants_connexion'), |
|
| 284 | - [ |
|
| 285 | - 'login' => [ |
|
| 286 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 287 | - 'info_login_trop_court_car_pluriel', |
|
| 288 | - ['nb' => _LOGIN_TROP_COURT] |
|
| 289 | - ) . "\n", |
|
| 290 | - 'valeur' => $login, |
|
| 291 | - 'required' => $auteur_obligatoire, |
|
| 292 | - ], |
|
| 293 | - 'pass' => [ |
|
| 294 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 295 | - 'info_passe_trop_court_car_pluriel', |
|
| 296 | - ['nb' => _PASS_LONGUEUR_MINI] |
|
| 297 | - ) . "\n", |
|
| 298 | - 'valeur' => $pass, |
|
| 299 | - 'required' => $auteur_obligatoire, |
|
| 300 | - ], |
|
| 301 | - 'pass_verif' => [ |
|
| 302 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 303 | - 'valeur' => $pass, |
|
| 304 | - 'required' => $auteur_obligatoire, |
|
| 305 | - ] |
|
| 306 | - ] |
|
| 307 | - ) |
|
| 308 | - . bouton_suivant())); |
|
| 252 | + return info_progression_etape(3, 'etape_', 'install/') . |
|
| 253 | + info_etape( |
|
| 254 | + _T('info_informations_personnelles'), |
|
| 255 | + '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | + aider('install5', true) . |
|
| 257 | + '<p>' . |
|
| 258 | + ($auteur_obligatoire ? |
|
| 259 | + '' |
|
| 260 | + : |
|
| 261 | + _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 262 | + ) |
|
| 263 | + ) |
|
| 264 | + . generer_form_ecrire('install', ( |
|
| 265 | + "\n<input type='hidden' name='etape' value='3b' />" |
|
| 266 | + . $hidden |
|
| 267 | + . fieldset( |
|
| 268 | + _T('info_identification_publique'), |
|
| 269 | + [ |
|
| 270 | + 'nom' => [ |
|
| 271 | + 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 272 | + 'valeur' => $nom, |
|
| 273 | + 'required' => $auteur_obligatoire, |
|
| 274 | + ], |
|
| 275 | + 'email' => [ |
|
| 276 | + 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 277 | + 'valeur' => $email, |
|
| 278 | + ] |
|
| 279 | + ] |
|
| 280 | + ) |
|
| 281 | + |
|
| 282 | + . fieldset( |
|
| 283 | + _T('entree_identifiants_connexion'), |
|
| 284 | + [ |
|
| 285 | + 'login' => [ |
|
| 286 | + 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 287 | + 'info_login_trop_court_car_pluriel', |
|
| 288 | + ['nb' => _LOGIN_TROP_COURT] |
|
| 289 | + ) . "\n", |
|
| 290 | + 'valeur' => $login, |
|
| 291 | + 'required' => $auteur_obligatoire, |
|
| 292 | + ], |
|
| 293 | + 'pass' => [ |
|
| 294 | + 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 295 | + 'info_passe_trop_court_car_pluriel', |
|
| 296 | + ['nb' => _PASS_LONGUEUR_MINI] |
|
| 297 | + ) . "\n", |
|
| 298 | + 'valeur' => $pass, |
|
| 299 | + 'required' => $auteur_obligatoire, |
|
| 300 | + ], |
|
| 301 | + 'pass_verif' => [ |
|
| 302 | + 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 303 | + 'valeur' => $pass, |
|
| 304 | + 'required' => $auteur_obligatoire, |
|
| 305 | + ] |
|
| 306 | + ] |
|
| 307 | + ) |
|
| 308 | + . bouton_suivant())); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // https://code.spip.net/@install_etape_3_dist |
| 312 | 312 | function install_etape_3_dist() { |
| 313 | - $ldap_present = _request('ldap_present'); |
|
| 314 | - |
|
| 315 | - if (!$ldap_present) { |
|
| 316 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 317 | - ? _INSTALL_HOST_DB |
|
| 318 | - : _request('adresse_db'); |
|
| 319 | - |
|
| 320 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 321 | - ? _INSTALL_USER_DB |
|
| 322 | - : _request('login_db'); |
|
| 323 | - |
|
| 324 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 325 | - ? _INSTALL_PASS_DB |
|
| 326 | - : _request('pass_db'); |
|
| 327 | - |
|
| 328 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 329 | - ? _INSTALL_SERVER_DB |
|
| 330 | - : _request('server_db'); |
|
| 331 | - |
|
| 332 | - $chmod_db = defined('_SPIP_CHMOD') |
|
| 333 | - ? _SPIP_CHMOD |
|
| 334 | - : _request('chmod'); |
|
| 335 | - |
|
| 336 | - $choix_db = defined('_INSTALL_NAME_DB') |
|
| 337 | - ? _INSTALL_NAME_DB |
|
| 338 | - : _request('choix_db'); |
|
| 339 | - |
|
| 340 | - $sel_db = ($choix_db == 'new_spip') |
|
| 341 | - ? _request('table_new') : $choix_db; |
|
| 342 | - |
|
| 343 | - $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 344 | - |
|
| 345 | - if ($res) { |
|
| 346 | - $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 347 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 348 | - . $res |
|
| 349 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 350 | - . '</div>'; |
|
| 351 | - } |
|
| 352 | - } else { |
|
| 353 | - $res = ''; |
|
| 354 | - [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 355 | - $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - if (!$res) { |
|
| 359 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 360 | - include(_FILE_CONNECT_TMP); |
|
| 361 | - } else { |
|
| 362 | - redirige_url_ecrire('install'); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 366 | - include(_FILE_CHMOD_TMP); |
|
| 367 | - } else { |
|
| 368 | - redirige_url_ecrire('install'); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 372 | - . (defined('_INSTALL_NAME_DB') ? '' |
|
| 373 | - : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 374 | - |
|
| 375 | - $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 376 | - |
|
| 377 | - $res = "<div class='success'><b>" |
|
| 378 | - . _T('info_base_installee') |
|
| 379 | - . '</b></div>' |
|
| 380 | - . install_premier_auteur( |
|
| 381 | - _request('email'), |
|
| 382 | - _request('login'), |
|
| 383 | - _request('nom'), |
|
| 384 | - _request('pass'), |
|
| 385 | - $hidden, |
|
| 386 | - $auteur_obligatoire |
|
| 387 | - ) |
|
| 388 | - . (($ldap_present or !function_exists('ldap_connect')) |
|
| 389 | - ? '' : install_propose_ldap()); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - echo install_debut_html(); |
|
| 393 | - echo $res; |
|
| 394 | - echo install_fin_html(); |
|
| 313 | + $ldap_present = _request('ldap_present'); |
|
| 314 | + |
|
| 315 | + if (!$ldap_present) { |
|
| 316 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 317 | + ? _INSTALL_HOST_DB |
|
| 318 | + : _request('adresse_db'); |
|
| 319 | + |
|
| 320 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 321 | + ? _INSTALL_USER_DB |
|
| 322 | + : _request('login_db'); |
|
| 323 | + |
|
| 324 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 325 | + ? _INSTALL_PASS_DB |
|
| 326 | + : _request('pass_db'); |
|
| 327 | + |
|
| 328 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 329 | + ? _INSTALL_SERVER_DB |
|
| 330 | + : _request('server_db'); |
|
| 331 | + |
|
| 332 | + $chmod_db = defined('_SPIP_CHMOD') |
|
| 333 | + ? _SPIP_CHMOD |
|
| 334 | + : _request('chmod'); |
|
| 335 | + |
|
| 336 | + $choix_db = defined('_INSTALL_NAME_DB') |
|
| 337 | + ? _INSTALL_NAME_DB |
|
| 338 | + : _request('choix_db'); |
|
| 339 | + |
|
| 340 | + $sel_db = ($choix_db == 'new_spip') |
|
| 341 | + ? _request('table_new') : $choix_db; |
|
| 342 | + |
|
| 343 | + $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 344 | + |
|
| 345 | + if ($res) { |
|
| 346 | + $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 347 | + . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 348 | + . $res |
|
| 349 | + . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 350 | + . '</div>'; |
|
| 351 | + } |
|
| 352 | + } else { |
|
| 353 | + $res = ''; |
|
| 354 | + [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 355 | + $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + if (!$res) { |
|
| 359 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 360 | + include(_FILE_CONNECT_TMP); |
|
| 361 | + } else { |
|
| 362 | + redirige_url_ecrire('install'); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 366 | + include(_FILE_CHMOD_TMP); |
|
| 367 | + } else { |
|
| 368 | + redirige_url_ecrire('install'); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 372 | + . (defined('_INSTALL_NAME_DB') ? '' |
|
| 373 | + : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 374 | + |
|
| 375 | + $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 376 | + |
|
| 377 | + $res = "<div class='success'><b>" |
|
| 378 | + . _T('info_base_installee') |
|
| 379 | + . '</b></div>' |
|
| 380 | + . install_premier_auteur( |
|
| 381 | + _request('email'), |
|
| 382 | + _request('login'), |
|
| 383 | + _request('nom'), |
|
| 384 | + _request('pass'), |
|
| 385 | + $hidden, |
|
| 386 | + $auteur_obligatoire |
|
| 387 | + ) |
|
| 388 | + . (($ldap_present or !function_exists('ldap_connect')) |
|
| 389 | + ? '' : install_propose_ldap()); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + echo install_debut_html(); |
|
| 393 | + echo $res; |
|
| 394 | + echo install_fin_html(); |
|
| 395 | 395 | } |
@@ -11,89 +11,89 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // https://code.spip.net/@install_etape_ldap1_dist |
| 18 | 18 | function install_etape_ldap1_dist() { |
| 19 | - $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 20 | - ? _INSTALL_HOST_LDAP |
|
| 21 | - : 'localhost'; |
|
| 19 | + $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 20 | + ? _INSTALL_HOST_LDAP |
|
| 21 | + : 'localhost'; |
|
| 22 | 22 | |
| 23 | - $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 24 | - ? _INSTALL_PORT_LDAP |
|
| 25 | - : 389; |
|
| 23 | + $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 24 | + ? _INSTALL_PORT_LDAP |
|
| 25 | + : 389; |
|
| 26 | 26 | |
| 27 | - $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 28 | - ? _INSTALL_TLS_LDAP |
|
| 29 | - : 'non'; |
|
| 27 | + $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 28 | + ? _INSTALL_TLS_LDAP |
|
| 29 | + : 'non'; |
|
| 30 | 30 | |
| 31 | - $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 32 | - ? _INSTALL_PROTOCOLE_LDAP |
|
| 33 | - : 3; // on essaie 2 en cas d'echec |
|
| 31 | + $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 32 | + ? _INSTALL_PROTOCOLE_LDAP |
|
| 33 | + : 3; // on essaie 2 en cas d'echec |
|
| 34 | 34 | |
| 35 | - $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 36 | - ? _INSTALL_USER_LDAP |
|
| 37 | - : ''; |
|
| 35 | + $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 36 | + ? _INSTALL_USER_LDAP |
|
| 37 | + : ''; |
|
| 38 | 38 | |
| 39 | - $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 40 | - ? _INSTALL_PASS_LDAP |
|
| 41 | - : ''; |
|
| 39 | + $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 40 | + ? _INSTALL_PASS_LDAP |
|
| 41 | + : ''; |
|
| 42 | 42 | |
| 43 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 43 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 44 | 44 | |
| 45 | - echo info_etape( |
|
| 46 | - _T('titre_connexion_ldap'), |
|
| 47 | - info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 48 | - ); |
|
| 45 | + echo info_etape( |
|
| 46 | + _T('titre_connexion_ldap'), |
|
| 47 | + info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 48 | + ); |
|
| 49 | 49 | |
| 50 | - echo generer_form_ecrire('install', ( |
|
| 51 | - "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 52 | - . fieldset( |
|
| 53 | - _T('entree_adresse_annuaire'), |
|
| 54 | - [ |
|
| 55 | - 'adresse_ldap' => [ |
|
| 56 | - 'label' => _T('texte_adresse_annuaire_1'), |
|
| 57 | - 'valeur' => $adresse_ldap |
|
| 58 | - ], |
|
| 59 | - 'port_ldap' => [ |
|
| 60 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 61 | - 'valeur' => $port_ldap |
|
| 62 | - ], |
|
| 63 | - 'tls_ldap' => [ |
|
| 64 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 65 | - 'valeur' => $tls_ldap, |
|
| 66 | - 'alternatives' => [ |
|
| 67 | - 'non' => _T('item_non'), |
|
| 68 | - 'oui' => _T('item_oui') |
|
| 69 | - ] |
|
| 70 | - ], |
|
| 71 | - 'protocole_ldap' => [ |
|
| 72 | - 'label' => _T('protocole_ldap'), |
|
| 73 | - 'valeur' => $protocole_ldap, |
|
| 74 | - 'alternatives' => [ |
|
| 75 | - '3' => '3', |
|
| 76 | - '2' => '2' |
|
| 77 | - ] |
|
| 78 | - ] |
|
| 79 | - ] |
|
| 80 | - ) |
|
| 50 | + echo generer_form_ecrire('install', ( |
|
| 51 | + "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 52 | + . fieldset( |
|
| 53 | + _T('entree_adresse_annuaire'), |
|
| 54 | + [ |
|
| 55 | + 'adresse_ldap' => [ |
|
| 56 | + 'label' => _T('texte_adresse_annuaire_1'), |
|
| 57 | + 'valeur' => $adresse_ldap |
|
| 58 | + ], |
|
| 59 | + 'port_ldap' => [ |
|
| 60 | + 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 61 | + 'valeur' => $port_ldap |
|
| 62 | + ], |
|
| 63 | + 'tls_ldap' => [ |
|
| 64 | + 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 65 | + 'valeur' => $tls_ldap, |
|
| 66 | + 'alternatives' => [ |
|
| 67 | + 'non' => _T('item_non'), |
|
| 68 | + 'oui' => _T('item_oui') |
|
| 69 | + ] |
|
| 70 | + ], |
|
| 71 | + 'protocole_ldap' => [ |
|
| 72 | + 'label' => _T('protocole_ldap'), |
|
| 73 | + 'valeur' => $protocole_ldap, |
|
| 74 | + 'alternatives' => [ |
|
| 75 | + '3' => '3', |
|
| 76 | + '2' => '2' |
|
| 77 | + ] |
|
| 78 | + ] |
|
| 79 | + ] |
|
| 80 | + ) |
|
| 81 | 81 | |
| 82 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 83 | - . fieldset( |
|
| 84 | - _T('connexion_ldap'), |
|
| 85 | - [ |
|
| 86 | - 'login_ldap' => [ |
|
| 87 | - 'label' => _T('texte_login_ldap_1'), |
|
| 88 | - 'valeur' => $login_ldap |
|
| 89 | - ], |
|
| 90 | - 'pass_ldap' => [ |
|
| 91 | - 'label' => _T('entree_passe_ldap'), |
|
| 92 | - 'valeur' => $pass_ldap |
|
| 93 | - ] |
|
| 94 | - ] |
|
| 95 | - ) |
|
| 96 | - . bouton_suivant())); |
|
| 82 | + . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 83 | + . fieldset( |
|
| 84 | + _T('connexion_ldap'), |
|
| 85 | + [ |
|
| 86 | + 'login_ldap' => [ |
|
| 87 | + 'label' => _T('texte_login_ldap_1'), |
|
| 88 | + 'valeur' => $login_ldap |
|
| 89 | + ], |
|
| 90 | + 'pass_ldap' => [ |
|
| 91 | + 'label' => _T('entree_passe_ldap'), |
|
| 92 | + 'valeur' => $pass_ldap |
|
| 93 | + ] |
|
| 94 | + ] |
|
| 95 | + ) |
|
| 96 | + . bouton_suivant())); |
|
| 97 | 97 | |
| 98 | - echo install_fin_html(); |
|
| 98 | + echo install_fin_html(); |
|
| 99 | 99 | } |
@@ -11,91 +11,91 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('base/abstract_sql'); |
| 18 | 18 | |
| 19 | 19 | // https://code.spip.net/@install_etape_2_dist |
| 20 | 20 | function install_etape_2_dist() { |
| 21 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 22 | - ? _INSTALL_HOST_DB |
|
| 23 | - : _request('adresse_db'); |
|
| 21 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 22 | + ? _INSTALL_HOST_DB |
|
| 23 | + : _request('adresse_db'); |
|
| 24 | 24 | |
| 25 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 26 | - [, $adresse_db, $port] = $r; |
|
| 27 | - } else { |
|
| 28 | - $port = ''; |
|
| 29 | - } |
|
| 25 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 26 | + [, $adresse_db, $port] = $r; |
|
| 27 | + } else { |
|
| 28 | + $port = ''; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 32 | - ? _INSTALL_USER_DB |
|
| 33 | - : _request('login_db'); |
|
| 31 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 32 | + ? _INSTALL_USER_DB |
|
| 33 | + : _request('login_db'); |
|
| 34 | 34 | |
| 35 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 36 | - ? _INSTALL_PASS_DB |
|
| 37 | - : _request('pass_db'); |
|
| 35 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 36 | + ? _INSTALL_PASS_DB |
|
| 37 | + : _request('pass_db'); |
|
| 38 | 38 | |
| 39 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 40 | - ? _INSTALL_SERVER_DB |
|
| 41 | - : _request('server_db'); |
|
| 39 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 40 | + ? _INSTALL_SERVER_DB |
|
| 41 | + : _request('server_db'); |
|
| 42 | 42 | |
| 43 | - $name_db = defined('_INSTALL_NAME_DB') |
|
| 44 | - ? _INSTALL_NAME_DB |
|
| 45 | - : ''; |
|
| 43 | + $name_db = defined('_INSTALL_NAME_DB') |
|
| 44 | + ? _INSTALL_NAME_DB |
|
| 45 | + : ''; |
|
| 46 | 46 | |
| 47 | - $chmod = _request('chmod'); |
|
| 47 | + $chmod = _request('chmod'); |
|
| 48 | 48 | |
| 49 | - $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 50 | - $GLOBALS['connexions'][$server_db] = $link; |
|
| 49 | + $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 50 | + $GLOBALS['connexions'][$server_db] = $link; |
|
| 51 | 51 | |
| 52 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 53 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 52 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 53 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 54 | 54 | |
| 55 | - echo install_debut_html(); |
|
| 55 | + echo install_debut_html(); |
|
| 56 | 56 | |
| 57 | 57 | // prenons toutes les dispositions possibles pour que rien ne s'affiche ! |
| 58 | 58 | |
| 59 | - /* |
|
| 59 | + /* |
|
| 60 | 60 | * /!\ sqlite3/PDO : erreur sur join(', ', $link) |
| 61 | 61 | * L'objet PDO ne peut pas etre transformee en chaine |
| 62 | 62 | * Un echo $link ne fonctionne pas non plus |
| 63 | 63 | * Il faut utiliser par exemple print_r($link) |
| 64 | 64 | */ |
| 65 | - //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 66 | - $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 67 | - //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 68 | - //echo "\n-->\n"; |
|
| 65 | + //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 66 | + $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 67 | + //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 68 | + //echo "\n-->\n"; |
|
| 69 | 69 | |
| 70 | - if (($db_connect == '0') && $link) { |
|
| 71 | - echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 72 | - echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 70 | + if (($db_connect == '0') && $link) { |
|
| 71 | + echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 72 | + echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 73 | 73 | |
| 74 | - echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 74 | + echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 75 | 75 | |
| 76 | - echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 77 | - [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 76 | + echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 77 | + [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 78 | 78 | |
| 79 | - $hidden = (defined('_SPIP_CHMOD') |
|
| 80 | - ? '' |
|
| 81 | - : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 82 | - . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 79 | + $hidden = (defined('_SPIP_CHMOD') |
|
| 80 | + ? '' |
|
| 81 | + : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 82 | + . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 83 | 83 | |
| 84 | - echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 85 | - } else { |
|
| 86 | - echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 84 | + echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 85 | + } else { |
|
| 86 | + echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 87 | 87 | |
| 88 | - echo "<div class='error'>"; |
|
| 89 | - echo info_etape(_T('info_connexion_base')); |
|
| 90 | - echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 91 | - echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 88 | + echo "<div class='error'>"; |
|
| 89 | + echo info_etape(_T('info_connexion_base')); |
|
| 90 | + echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 91 | + echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 92 | 92 | |
| 93 | - echo "<p style='font-size: small;'>", |
|
| 94 | - _T('avis_connexion_echec_3'), |
|
| 95 | - '</p></div>'; |
|
| 96 | - } |
|
| 93 | + echo "<p style='font-size: small;'>", |
|
| 94 | + _T('avis_connexion_echec_3'), |
|
| 95 | + '</p></div>'; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - echo install_fin_html(); |
|
| 98 | + echo install_fin_html(); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Liste les bases accessibles, |
@@ -103,77 +103,77 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // https://code.spip.net/@install_etape_2_bases |
| 105 | 105 | function install_etape_2_bases($login_db, $server_db) { |
| 106 | - $res = install_etape_liste_bases($server_db, $login_db); |
|
| 107 | - if ($res) { |
|
| 108 | - [$checked, $bases] = $res; |
|
| 109 | - |
|
| 110 | - return [ |
|
| 111 | - $checked, |
|
| 112 | - "<label for='choix_db'><b>" |
|
| 113 | - . _T('texte_choix_base_2') |
|
| 114 | - . '</b><br />' |
|
| 115 | - . _T('texte_choix_base_3') |
|
| 116 | - . '</label>' |
|
| 117 | - . "<ul>\n<li>" |
|
| 118 | - . join("</li>\n<li>", $bases) |
|
| 119 | - . "</li>\n</ul><p>" |
|
| 120 | - . _T('info_ou') |
|
| 121 | - . ' ' |
|
| 122 | - ]; |
|
| 123 | - } |
|
| 124 | - $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 106 | + $res = install_etape_liste_bases($server_db, $login_db); |
|
| 107 | + if ($res) { |
|
| 108 | + [$checked, $bases] = $res; |
|
| 109 | + |
|
| 110 | + return [ |
|
| 111 | + $checked, |
|
| 112 | + "<label for='choix_db'><b>" |
|
| 113 | + . _T('texte_choix_base_2') |
|
| 114 | + . '</b><br />' |
|
| 115 | + . _T('texte_choix_base_3') |
|
| 116 | + . '</label>' |
|
| 117 | + . "<ul>\n<li>" |
|
| 118 | + . join("</li>\n<li>", $bases) |
|
| 119 | + . "</li>\n</ul><p>" |
|
| 120 | + . _T('info_ou') |
|
| 121 | + . ' ' |
|
| 122 | + ]; |
|
| 123 | + } |
|
| 124 | + $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 125 | 125 | ' . _T('avis_lecture_noms_bases_2') . '<p>'; |
| 126 | 126 | |
| 127 | - $checked = false; |
|
| 128 | - if ($login_db) { |
|
| 129 | - // Si un login comporte un point, le nom de la base est plus |
|
| 130 | - // probablement le login sans le point -- testons pour savoir |
|
| 131 | - $test_base = $login_db; |
|
| 132 | - $ok = sql_selectdb($test_base, $server_db); |
|
| 133 | - $test_base2 = str_replace('.', '_', $test_base); |
|
| 134 | - if (sql_selectdb($test_base2, $server_db)) { |
|
| 135 | - $test_base = $test_base2; |
|
| 136 | - $ok = true; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - if ($ok) { |
|
| 140 | - $res .= _T('avis_lecture_noms_bases_3') |
|
| 141 | - . '<ul>' |
|
| 142 | - . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 143 | - . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 144 | - . '</ul>' |
|
| 145 | - . '<p>' . _T('info_ou') . ' '; |
|
| 146 | - $checked = true; |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - return [$checked, $res]; |
|
| 127 | + $checked = false; |
|
| 128 | + if ($login_db) { |
|
| 129 | + // Si un login comporte un point, le nom de la base est plus |
|
| 130 | + // probablement le login sans le point -- testons pour savoir |
|
| 131 | + $test_base = $login_db; |
|
| 132 | + $ok = sql_selectdb($test_base, $server_db); |
|
| 133 | + $test_base2 = str_replace('.', '_', $test_base); |
|
| 134 | + if (sql_selectdb($test_base2, $server_db)) { |
|
| 135 | + $test_base = $test_base2; |
|
| 136 | + $ok = true; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + if ($ok) { |
|
| 140 | + $res .= _T('avis_lecture_noms_bases_3') |
|
| 141 | + . '<ul>' |
|
| 142 | + . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 143 | + . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 144 | + . '</ul>' |
|
| 145 | + . '<p>' . _T('info_ou') . ' '; |
|
| 146 | + $checked = true; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + return [$checked, $res]; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // https://code.spip.net/@install_etape_2_form |
| 154 | 154 | function install_etape_2_form($hidden, $checked, $res, $etape) { |
| 155 | - return generer_form_ecrire('install', ( |
|
| 156 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 157 | - . $hidden |
|
| 158 | - . (defined('_INSTALL_NAME_DB') |
|
| 159 | - ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 160 | - : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 161 | - . $res |
|
| 162 | - . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 163 | - . ($checked ? '' : " checked='checked'") |
|
| 164 | - . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 165 | - . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 166 | - ) |
|
| 167 | - |
|
| 168 | - . ((defined('_INSTALL_TABLE_PREFIX') |
|
| 169 | - or $GLOBALS['table_prefix'] != 'spip') |
|
| 170 | - ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 171 | - : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 172 | - . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 173 | - . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 174 | - . 'spip' # valeur par defaut |
|
| 175 | - . "' size='20' /></p></fieldset>" |
|
| 176 | - ) |
|
| 177 | - |
|
| 178 | - . bouton_suivant())); |
|
| 155 | + return generer_form_ecrire('install', ( |
|
| 156 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 157 | + . $hidden |
|
| 158 | + . (defined('_INSTALL_NAME_DB') |
|
| 159 | + ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 160 | + : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 161 | + . $res |
|
| 162 | + . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 163 | + . ($checked ? '' : " checked='checked'") |
|
| 164 | + . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 165 | + . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 166 | + ) |
|
| 167 | + |
|
| 168 | + . ((defined('_INSTALL_TABLE_PREFIX') |
|
| 169 | + or $GLOBALS['table_prefix'] != 'spip') |
|
| 170 | + ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 171 | + : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 172 | + . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 173 | + . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 174 | + . 'spip' # valeur par defaut |
|
| 175 | + . "' size='20' /></p></fieldset>" |
|
| 176 | + ) |
|
| 177 | + |
|
| 178 | + . bouton_suivant())); |
|
| 179 | 179 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | if (defined('_TEST_DIRS')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | define('_TEST_DIRS', '1'); |
| 21 | 21 | |
@@ -27,42 +27,42 @@ discard block |
||
| 27 | 27 | // |
| 28 | 28 | // https://code.spip.net/@test_ecrire |
| 29 | 29 | function test_ecrire($my_dir) { |
| 30 | - static $chmod = 0; |
|
| 31 | - |
|
| 32 | - $ok = false; |
|
| 33 | - $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 34 | - $self = basename($script); |
|
| 35 | - $uid = @fileowner('.'); |
|
| 36 | - $uid2 = @fileowner($self); |
|
| 37 | - $gid = @filegroup('.'); |
|
| 38 | - $gid2 = @filegroup($self); |
|
| 39 | - $perms = @fileperms($self); |
|
| 40 | - |
|
| 41 | - // Comparer l'appartenance d'un fichier cree par PHP |
|
| 42 | - // avec celle du script et du repertoire courant |
|
| 43 | - if (!$chmod) { |
|
| 44 | - @rmdir('test'); |
|
| 45 | - spip_unlink('test'); // effacer au cas ou |
|
| 46 | - @touch('test'); |
|
| 47 | - if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 48 | - $chmod = 0700; |
|
| 49 | - } else { |
|
| 50 | - if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 51 | - $chmod = 0770; |
|
| 52 | - } else { |
|
| 53 | - $chmod = 0777; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - // Appliquer de plus les droits d'acces du script |
|
| 57 | - if ($perms > 0) { |
|
| 58 | - $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 59 | - $chmod |= $perms; |
|
| 60 | - } |
|
| 61 | - spip_unlink('test'); |
|
| 62 | - } |
|
| 63 | - $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 64 | - |
|
| 65 | - return $ok ? $chmod : false; |
|
| 30 | + static $chmod = 0; |
|
| 31 | + |
|
| 32 | + $ok = false; |
|
| 33 | + $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 34 | + $self = basename($script); |
|
| 35 | + $uid = @fileowner('.'); |
|
| 36 | + $uid2 = @fileowner($self); |
|
| 37 | + $gid = @filegroup('.'); |
|
| 38 | + $gid2 = @filegroup($self); |
|
| 39 | + $perms = @fileperms($self); |
|
| 40 | + |
|
| 41 | + // Comparer l'appartenance d'un fichier cree par PHP |
|
| 42 | + // avec celle du script et du repertoire courant |
|
| 43 | + if (!$chmod) { |
|
| 44 | + @rmdir('test'); |
|
| 45 | + spip_unlink('test'); // effacer au cas ou |
|
| 46 | + @touch('test'); |
|
| 47 | + if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 48 | + $chmod = 0700; |
|
| 49 | + } else { |
|
| 50 | + if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) { |
|
| 51 | + $chmod = 0770; |
|
| 52 | + } else { |
|
| 53 | + $chmod = 0777; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + // Appliquer de plus les droits d'acces du script |
|
| 57 | + if ($perms > 0) { |
|
| 58 | + $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 59 | + $chmod |= $perms; |
|
| 60 | + } |
|
| 61 | + spip_unlink('test'); |
|
| 62 | + } |
|
| 63 | + $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 64 | + |
|
| 65 | + return $ok ? $chmod : false; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // |
@@ -73,84 +73,84 @@ discard block |
||
| 73 | 73 | // https://code.spip.net/@install_etape_chmod_dist |
| 74 | 74 | function install_etape_chmod_dist() { |
| 75 | 75 | |
| 76 | - $continuer = null; |
|
| 77 | - $test_dir = _request('test_dir'); |
|
| 78 | - $chmod = 0; |
|
| 79 | - |
|
| 80 | - if ($test_dir) { |
|
| 81 | - if (substr($test_dir, -1) !== '/') { |
|
| 82 | - $test_dir .= '/'; |
|
| 83 | - } |
|
| 84 | - if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 85 | - $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 86 | - } |
|
| 87 | - } else { |
|
| 88 | - if (!_FILE_CONNECT) { |
|
| 89 | - $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 90 | - $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - $bad_dirs = []; |
|
| 95 | - $absent_dirs = []; |
|
| 96 | - |
|
| 97 | - foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 98 | - $test = test_ecrire($my_dir); |
|
| 99 | - if (!$test) { |
|
| 100 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 101 | - if (@file_exists($my_dir)) { |
|
| 102 | - $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 103 | - } else { |
|
| 104 | - $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 105 | - } |
|
| 106 | - } else { |
|
| 107 | - $chmod = max($chmod, $test); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - if ($bad_dirs or $absent_dirs) { |
|
| 112 | - if (!_FILE_CONNECT) { |
|
| 113 | - $titre = _T('dirs_preliminaire'); |
|
| 114 | - $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 115 | - } else { |
|
| 116 | - $titre = _T('dirs_probleme_droits'); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 121 | - |
|
| 122 | - if ($bad_dirs) { |
|
| 123 | - $res .= |
|
| 124 | - _T( |
|
| 125 | - 'dirs_repertoires_suivants', |
|
| 126 | - ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
|
| 127 | - ) . |
|
| 128 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - if ($absent_dirs) { |
|
| 132 | - $res .= |
|
| 133 | - _T( |
|
| 134 | - 'dirs_repertoires_absents', |
|
| 135 | - ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
|
| 136 | - ) . |
|
| 137 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 138 | - } |
|
| 139 | - $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 140 | - |
|
| 141 | - $t = _T('login_recharger'); |
|
| 142 | - $t = (!$test_dir ? '' : |
|
| 143 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 144 | - . "<input type='hidden' name='etape' value='chmod' />" |
|
| 145 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 146 | - |
|
| 147 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 148 | - } else { |
|
| 149 | - $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 150 | - if (!$deja) { |
|
| 151 | - redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 152 | - } else { |
|
| 153 | - redirige_url_ecrire(); |
|
| 154 | - } |
|
| 155 | - } |
|
| 76 | + $continuer = null; |
|
| 77 | + $test_dir = _request('test_dir'); |
|
| 78 | + $chmod = 0; |
|
| 79 | + |
|
| 80 | + if ($test_dir) { |
|
| 81 | + if (substr($test_dir, -1) !== '/') { |
|
| 82 | + $test_dir .= '/'; |
|
| 83 | + } |
|
| 84 | + if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 85 | + $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 86 | + } |
|
| 87 | + } else { |
|
| 88 | + if (!_FILE_CONNECT) { |
|
| 89 | + $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 90 | + $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + $bad_dirs = []; |
|
| 95 | + $absent_dirs = []; |
|
| 96 | + |
|
| 97 | + foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 98 | + $test = test_ecrire($my_dir); |
|
| 99 | + if (!$test) { |
|
| 100 | + $m = preg_replace(',^' . _DIR_RACINE . ',', '', $my_dir); |
|
| 101 | + if (@file_exists($my_dir)) { |
|
| 102 | + $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 103 | + } else { |
|
| 104 | + $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 105 | + } |
|
| 106 | + } else { |
|
| 107 | + $chmod = max($chmod, $test); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + if ($bad_dirs or $absent_dirs) { |
|
| 112 | + if (!_FILE_CONNECT) { |
|
| 113 | + $titre = _T('dirs_preliminaire'); |
|
| 114 | + $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 115 | + } else { |
|
| 116 | + $titre = _T('dirs_probleme_droits'); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 121 | + |
|
| 122 | + if ($bad_dirs) { |
|
| 123 | + $res .= |
|
| 124 | + _T( |
|
| 125 | + 'dirs_repertoires_suivants', |
|
| 126 | + ['bad_dirs' => join("\n", array_keys($bad_dirs))] |
|
| 127 | + ) . |
|
| 128 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + if ($absent_dirs) { |
|
| 132 | + $res .= |
|
| 133 | + _T( |
|
| 134 | + 'dirs_repertoires_absents', |
|
| 135 | + ['bad_dirs' => join("\n", array_keys($absent_dirs))] |
|
| 136 | + ) . |
|
| 137 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 138 | + } |
|
| 139 | + $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 140 | + |
|
| 141 | + $t = _T('login_recharger'); |
|
| 142 | + $t = (!$test_dir ? '' : |
|
| 143 | + "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 144 | + . "<input type='hidden' name='etape' value='chmod' />" |
|
| 145 | + . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 146 | + |
|
| 147 | + echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 148 | + } else { |
|
| 149 | + $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 150 | + if (!$deja) { |
|
| 151 | + redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 152 | + } else { |
|
| 153 | + redirige_url_ecrire(); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | 156 | } |
@@ -11,147 +11,147 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
| 18 | 18 | |
| 19 | 19 | function install_etape_3b_dist() { |
| 20 | - $auth_spip = null; |
|
| 21 | - $session = null; |
|
| 22 | - $row = null; |
|
| 23 | - $login = _request('login'); |
|
| 24 | - $email = _request('email'); |
|
| 25 | - $nom = _request('nom'); |
|
| 26 | - $pass = _request('pass'); |
|
| 27 | - $pass_verif = _request('pass_verif'); |
|
| 28 | - |
|
| 29 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 30 | - ? _INSTALL_SERVER_DB |
|
| 31 | - : _request('server_db'); |
|
| 32 | - |
|
| 33 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 34 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 35 | - } |
|
| 36 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 37 | - define('_LOGIN_TROP_COURT', 4); |
|
| 38 | - } |
|
| 39 | - if ($login) { |
|
| 40 | - $echec = ($pass != $pass_verif) ? |
|
| 41 | - _T('info_passes_identiques') |
|
| 42 | - : ((strlen($pass) < _PASS_LONGUEUR_MINI) ? |
|
| 43 | - _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]) |
|
| 44 | - : ((strlen($login) < _LOGIN_TROP_COURT) ? |
|
| 45 | - _T('info_login_trop_court') |
|
| 46 | - : '')); |
|
| 47 | - include_spip('inc/filtres'); |
|
| 48 | - if (!$echec and $email and !email_valide($email)) { |
|
| 49 | - $echec = _T('form_email_non_valide'); |
|
| 50 | - } |
|
| 51 | - if ($echec) { |
|
| 52 | - echo minipres( |
|
| 53 | - 'AUTO', |
|
| 54 | - info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 55 | - "<div class='error'><h3>$echec</h3>\n" . |
|
| 56 | - '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 57 | - '</div>' |
|
| 58 | - ); |
|
| 59 | - exit; |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if (@file_exists(_FILE_CHMOD_TMP)) { |
|
| 64 | - include(_FILE_CHMOD_TMP); |
|
| 65 | - } else { |
|
| 66 | - redirige_url_ecrire('install'); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 70 | - redirige_url_ecrire('install'); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - # maintenant on connait le vrai charset du site s'il est deja configure |
|
| 74 | - # sinon par defaut lire_meta reglera _DEFAULT_CHARSET |
|
| 75 | - # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET) |
|
| 76 | - |
|
| 77 | - lire_metas(); |
|
| 78 | - if ($login) { |
|
| 79 | - include_spip('inc/charsets'); |
|
| 80 | - |
|
| 81 | - $nom = (importer_charset($nom, _DEFAULT_CHARSET)); |
|
| 82 | - $login = (importer_charset($login, _DEFAULT_CHARSET)); |
|
| 83 | - $email = (importer_charset($email, _DEFAULT_CHARSET)); |
|
| 84 | - # pour le passwd, bizarrement il faut le convertir comme s'il avait |
|
| 85 | - # ete tape en iso-8859-1 ; car c'est en fait ce que voit md5.js |
|
| 86 | - $pass = unicode2charset(utf_8_to_unicode($pass), 'iso-8859-1'); |
|
| 87 | - include_spip('auth/sha256.inc'); |
|
| 88 | - include_spip('inc/acces'); |
|
| 89 | - $htpass = generer_htpass($pass); |
|
| 90 | - $alea_actuel = creer_uniqid(); |
|
| 91 | - $alea_futur = creer_uniqid(); |
|
| 92 | - $shapass = spip_sha256($alea_actuel . $pass); |
|
| 93 | - // prelablement, creer le champ webmestre si il n'existe pas (install neuve |
|
| 94 | - // sur une vieille base |
|
| 95 | - $t = sql_showtable('spip_auteurs', true); |
|
| 96 | - if (!isset($t['field']['webmestre'])) { |
|
| 97 | - @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 101 | - if ($id_auteur !== null) { |
|
| 102 | - sql_updateq('spip_auteurs', [ |
|
| 103 | - 'nom' => $nom, |
|
| 104 | - 'email' => $email, |
|
| 105 | - 'login' => $login, |
|
| 106 | - 'pass' => $shapass, |
|
| 107 | - 'alea_actuel' => $alea_actuel, |
|
| 108 | - 'alea_futur' => $alea_futur, |
|
| 109 | - 'htpass' => $htpass, |
|
| 110 | - 'statut' => '0minirezo' |
|
| 111 | - ], "id_auteur=$id_auteur"); |
|
| 112 | - } else { |
|
| 113 | - $id_auteur = sql_insertq('spip_auteurs', [ |
|
| 114 | - 'nom' => $nom, |
|
| 115 | - 'email' => $email, |
|
| 116 | - 'login' => $login, |
|
| 117 | - 'pass' => $shapass, |
|
| 118 | - 'htpass' => $htpass, |
|
| 119 | - 'alea_actuel' => $alea_actuel, |
|
| 120 | - 'alea_futur' => $alea_futur, |
|
| 121 | - 'statut' => '0minirezo' |
|
| 122 | - ]); |
|
| 123 | - } |
|
| 124 | - // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 125 | - @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 126 | - |
|
| 127 | - // inserer email comme email webmaster principal |
|
| 128 | - // (sauf s'il est vide: cas de la re-installation) |
|
| 129 | - if ($email) { |
|
| 130 | - ecrire_meta('email_webmaster', $email); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // Connecter directement celui qui vient de (re)donner son login |
|
| 134 | - // mais sans cookie d'admin ni connexion longue |
|
| 135 | - include_spip('inc/auth'); |
|
| 136 | - if ( |
|
| 137 | - !$auteur = auth_identifier_login($login, $pass) |
|
| 138 | - or !auth_loger($auteur) |
|
| 139 | - ) { |
|
| 140 | - spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - // installer les metas |
|
| 145 | - $config = charger_fonction('config', 'inc'); |
|
| 146 | - $config(); |
|
| 147 | - |
|
| 148 | - // activer les plugins |
|
| 149 | - // leur installation ne peut pas se faire sur le meme hit, il faudra donc |
|
| 150 | - // poursuivre au hit suivant |
|
| 151 | - include_spip('inc/plugin'); |
|
| 152 | - actualise_plugins_actifs(); |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - include_spip('inc/distant'); |
|
| 156 | - redirige_par_entete(parametre_url(self(), 'etape', '4', '&')); |
|
| 20 | + $auth_spip = null; |
|
| 21 | + $session = null; |
|
| 22 | + $row = null; |
|
| 23 | + $login = _request('login'); |
|
| 24 | + $email = _request('email'); |
|
| 25 | + $nom = _request('nom'); |
|
| 26 | + $pass = _request('pass'); |
|
| 27 | + $pass_verif = _request('pass_verif'); |
|
| 28 | + |
|
| 29 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 30 | + ? _INSTALL_SERVER_DB |
|
| 31 | + : _request('server_db'); |
|
| 32 | + |
|
| 33 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 34 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 35 | + } |
|
| 36 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 37 | + define('_LOGIN_TROP_COURT', 4); |
|
| 38 | + } |
|
| 39 | + if ($login) { |
|
| 40 | + $echec = ($pass != $pass_verif) ? |
|
| 41 | + _T('info_passes_identiques') |
|
| 42 | + : ((strlen($pass) < _PASS_LONGUEUR_MINI) ? |
|
| 43 | + _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]) |
|
| 44 | + : ((strlen($login) < _LOGIN_TROP_COURT) ? |
|
| 45 | + _T('info_login_trop_court') |
|
| 46 | + : '')); |
|
| 47 | + include_spip('inc/filtres'); |
|
| 48 | + if (!$echec and $email and !email_valide($email)) { |
|
| 49 | + $echec = _T('form_email_non_valide'); |
|
| 50 | + } |
|
| 51 | + if ($echec) { |
|
| 52 | + echo minipres( |
|
| 53 | + 'AUTO', |
|
| 54 | + info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 55 | + "<div class='error'><h3>$echec</h3>\n" . |
|
| 56 | + '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 57 | + '</div>' |
|
| 58 | + ); |
|
| 59 | + exit; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if (@file_exists(_FILE_CHMOD_TMP)) { |
|
| 64 | + include(_FILE_CHMOD_TMP); |
|
| 65 | + } else { |
|
| 66 | + redirige_url_ecrire('install'); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 70 | + redirige_url_ecrire('install'); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + # maintenant on connait le vrai charset du site s'il est deja configure |
|
| 74 | + # sinon par defaut lire_meta reglera _DEFAULT_CHARSET |
|
| 75 | + # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET) |
|
| 76 | + |
|
| 77 | + lire_metas(); |
|
| 78 | + if ($login) { |
|
| 79 | + include_spip('inc/charsets'); |
|
| 80 | + |
|
| 81 | + $nom = (importer_charset($nom, _DEFAULT_CHARSET)); |
|
| 82 | + $login = (importer_charset($login, _DEFAULT_CHARSET)); |
|
| 83 | + $email = (importer_charset($email, _DEFAULT_CHARSET)); |
|
| 84 | + # pour le passwd, bizarrement il faut le convertir comme s'il avait |
|
| 85 | + # ete tape en iso-8859-1 ; car c'est en fait ce que voit md5.js |
|
| 86 | + $pass = unicode2charset(utf_8_to_unicode($pass), 'iso-8859-1'); |
|
| 87 | + include_spip('auth/sha256.inc'); |
|
| 88 | + include_spip('inc/acces'); |
|
| 89 | + $htpass = generer_htpass($pass); |
|
| 90 | + $alea_actuel = creer_uniqid(); |
|
| 91 | + $alea_futur = creer_uniqid(); |
|
| 92 | + $shapass = spip_sha256($alea_actuel . $pass); |
|
| 93 | + // prelablement, creer le champ webmestre si il n'existe pas (install neuve |
|
| 94 | + // sur une vieille base |
|
| 95 | + $t = sql_showtable('spip_auteurs', true); |
|
| 96 | + if (!isset($t['field']['webmestre'])) { |
|
| 97 | + @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 101 | + if ($id_auteur !== null) { |
|
| 102 | + sql_updateq('spip_auteurs', [ |
|
| 103 | + 'nom' => $nom, |
|
| 104 | + 'email' => $email, |
|
| 105 | + 'login' => $login, |
|
| 106 | + 'pass' => $shapass, |
|
| 107 | + 'alea_actuel' => $alea_actuel, |
|
| 108 | + 'alea_futur' => $alea_futur, |
|
| 109 | + 'htpass' => $htpass, |
|
| 110 | + 'statut' => '0minirezo' |
|
| 111 | + ], "id_auteur=$id_auteur"); |
|
| 112 | + } else { |
|
| 113 | + $id_auteur = sql_insertq('spip_auteurs', [ |
|
| 114 | + 'nom' => $nom, |
|
| 115 | + 'email' => $email, |
|
| 116 | + 'login' => $login, |
|
| 117 | + 'pass' => $shapass, |
|
| 118 | + 'htpass' => $htpass, |
|
| 119 | + 'alea_actuel' => $alea_actuel, |
|
| 120 | + 'alea_futur' => $alea_futur, |
|
| 121 | + 'statut' => '0minirezo' |
|
| 122 | + ]); |
|
| 123 | + } |
|
| 124 | + // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 125 | + @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 126 | + |
|
| 127 | + // inserer email comme email webmaster principal |
|
| 128 | + // (sauf s'il est vide: cas de la re-installation) |
|
| 129 | + if ($email) { |
|
| 130 | + ecrire_meta('email_webmaster', $email); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // Connecter directement celui qui vient de (re)donner son login |
|
| 134 | + // mais sans cookie d'admin ni connexion longue |
|
| 135 | + include_spip('inc/auth'); |
|
| 136 | + if ( |
|
| 137 | + !$auteur = auth_identifier_login($login, $pass) |
|
| 138 | + or !auth_loger($auteur) |
|
| 139 | + ) { |
|
| 140 | + spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + // installer les metas |
|
| 145 | + $config = charger_fonction('config', 'inc'); |
|
| 146 | + $config(); |
|
| 147 | + |
|
| 148 | + // activer les plugins |
|
| 149 | + // leur installation ne peut pas se faire sur le meme hit, il faudra donc |
|
| 150 | + // poursuivre au hit suivant |
|
| 151 | + include_spip('inc/plugin'); |
|
| 152 | + actualise_plugins_actifs(); |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + include_spip('inc/distant'); |
|
| 156 | + redirige_par_entete(parametre_url(self(), 'etape', '4', '&')); |
|
| 157 | 157 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | * @return int |
| 28 | 28 | */ |
| 29 | 29 | function genie_mise_a_jour_dist($t) { |
| 30 | - include_spip('inc/meta'); |
|
| 31 | - $maj = info_maj('spip', 'SPIP', $GLOBALS['spip_version_branche']); |
|
| 32 | - ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : '', 'non'); |
|
| 30 | + include_spip('inc/meta'); |
|
| 31 | + $maj = info_maj('spip', 'SPIP', $GLOBALS['spip_version_branche']); |
|
| 32 | + ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : '', 'non'); |
|
| 33 | 33 | |
| 34 | - mise_a_jour_ecran_securite(); |
|
| 34 | + mise_a_jour_ecran_securite(); |
|
| 35 | 35 | |
| 36 | - spip_log('Verification version SPIP : ' . ($maj ?: 'version a jour'), 'verifie_maj'); |
|
| 36 | + spip_log('Verification version SPIP : ' . ($maj ?: 'version a jour'), 'verifie_maj'); |
|
| 37 | 37 | |
| 38 | - return 1; |
|
| 38 | + return 1; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // TODO : fournir une URL sur spip.net pour maitriser la diffusion d'une nouvelle version de l'ecran via l'update auto |
@@ -52,46 +52,46 @@ discard block |
||
| 52 | 52 | * ou de ne repondre une 304 que si le md5 est bon |
| 53 | 53 | */ |
| 54 | 54 | function mise_a_jour_ecran_securite() { |
| 55 | - // TODO : url https avec verification du certificat |
|
| 56 | - return; |
|
| 57 | - |
|
| 58 | - // si l'ecran n'est pas deja present ou pas updatable, sortir |
|
| 59 | - if ( |
|
| 60 | - !_URL_ECRAN_SECURITE |
|
| 61 | - or !file_exists($filename = _DIR_ETC . 'ecran_securite.php') |
|
| 62 | - or !is_writable($filename) |
|
| 63 | - or !$last_modified = filemtime($filename) |
|
| 64 | - or !$md5 = md5_file($filename) |
|
| 65 | - ) { |
|
| 66 | - return false; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - include_spip('inc/distant'); |
|
| 70 | - $tmp_file = _DIR_TMP . 'ecran_securite.php'; |
|
| 71 | - $url = parametre_url(_URL_ECRAN_SECURITE, 'md5', $md5); |
|
| 72 | - $url = parametre_url($url, 'vspip', $GLOBALS['spip_version_branche']); |
|
| 73 | - $res = recuperer_url($url, [ |
|
| 74 | - 'if_modified_since' => $last_modified, |
|
| 75 | - 'file' => $tmp_file |
|
| 76 | - ]); |
|
| 77 | - |
|
| 78 | - // si il y a une version plus recente que l'on a recu correctement |
|
| 79 | - if ( |
|
| 80 | - $res['status'] == 200 |
|
| 81 | - and $res['length'] |
|
| 82 | - and $tmp_file = $res['file'] |
|
| 83 | - ) { |
|
| 84 | - if ($md5 !== md5_file($tmp_file)) { |
|
| 85 | - // on essaye de l'inclure pour verifier que ca ne fait pas erreur fatale |
|
| 86 | - include_once $tmp_file; |
|
| 87 | - // ok, on le copie a la place de l'ecran existant |
|
| 88 | - // en backupant l'ecran avant, au cas ou |
|
| 89 | - @copy($filename, $filename . '-bck-' . date('Y-m-d-His', $last_modified)); |
|
| 90 | - @rename($tmp_file, $filename); |
|
| 91 | - } else { |
|
| 92 | - @unlink($tmp_file); |
|
| 93 | - } |
|
| 94 | - } |
|
| 55 | + // TODO : url https avec verification du certificat |
|
| 56 | + return; |
|
| 57 | + |
|
| 58 | + // si l'ecran n'est pas deja present ou pas updatable, sortir |
|
| 59 | + if ( |
|
| 60 | + !_URL_ECRAN_SECURITE |
|
| 61 | + or !file_exists($filename = _DIR_ETC . 'ecran_securite.php') |
|
| 62 | + or !is_writable($filename) |
|
| 63 | + or !$last_modified = filemtime($filename) |
|
| 64 | + or !$md5 = md5_file($filename) |
|
| 65 | + ) { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + include_spip('inc/distant'); |
|
| 70 | + $tmp_file = _DIR_TMP . 'ecran_securite.php'; |
|
| 71 | + $url = parametre_url(_URL_ECRAN_SECURITE, 'md5', $md5); |
|
| 72 | + $url = parametre_url($url, 'vspip', $GLOBALS['spip_version_branche']); |
|
| 73 | + $res = recuperer_url($url, [ |
|
| 74 | + 'if_modified_since' => $last_modified, |
|
| 75 | + 'file' => $tmp_file |
|
| 76 | + ]); |
|
| 77 | + |
|
| 78 | + // si il y a une version plus recente que l'on a recu correctement |
|
| 79 | + if ( |
|
| 80 | + $res['status'] == 200 |
|
| 81 | + and $res['length'] |
|
| 82 | + and $tmp_file = $res['file'] |
|
| 83 | + ) { |
|
| 84 | + if ($md5 !== md5_file($tmp_file)) { |
|
| 85 | + // on essaye de l'inclure pour verifier que ca ne fait pas erreur fatale |
|
| 86 | + include_once $tmp_file; |
|
| 87 | + // ok, on le copie a la place de l'ecran existant |
|
| 88 | + // en backupant l'ecran avant, au cas ou |
|
| 89 | + @copy($filename, $filename . '-bck-' . date('Y-m-d-His', $last_modified)); |
|
| 90 | + @rename($tmp_file, $filename); |
|
| 91 | + } else { |
|
| 92 | + @unlink($tmp_file); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -109,54 +109,54 @@ discard block |
||
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | 111 | function info_maj($dir, $file, $version) { |
| 112 | - include_spip('inc/plugin'); |
|
| 113 | - |
|
| 114 | - [$maj, $min, $rev] = preg_split('/\D+/', $version); |
|
| 115 | - |
|
| 116 | - $nom = _DIR_CACHE_XML . _VERSIONS_LISTE; |
|
| 117 | - $page = !file_exists($nom) ? '' : file_get_contents($nom); |
|
| 118 | - $page = info_maj_cache($nom, $dir, $page); |
|
| 119 | - |
|
| 120 | - // reperer toutes les versions de numero majeur superieur ou egal |
|
| 121 | - // (a revoir quand on arrivera a SPIP V10 ...) |
|
| 122 | - $p = substr('0123456789', intval($maj)); |
|
| 123 | - $p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i'; |
|
| 124 | - preg_match_all($p, $page, $m, PREG_SET_ORDER); |
|
| 125 | - $page = $page_majeure = ''; |
|
| 126 | - |
|
| 127 | - // branche en cours d'utilisation |
|
| 128 | - $branche = implode('.', array_slice(explode('.', $version, 3), 0, 2)); |
|
| 129 | - |
|
| 130 | - foreach ($m as $v) { |
|
| 131 | - $v = array_pad($v, 5, 0); |
|
| 132 | - [, $maj2, $min2, , $rev2] = $v; |
|
| 133 | - $branche_maj = $maj2 . '.' . $min2; |
|
| 134 | - $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 135 | - // d'abord les mises à jour de la même branche |
|
| 136 | - if ( |
|
| 137 | - (spip_version_compare($version, $version_maj, '<')) |
|
| 138 | - and (spip_version_compare($page, $version_maj, '<')) |
|
| 139 | - and spip_version_compare($branche, $branche_maj, '=') |
|
| 140 | - ) { |
|
| 141 | - $page = $version_maj; |
|
| 142 | - } |
|
| 143 | - // puis les mises à jours majeures |
|
| 144 | - if ( |
|
| 145 | - (spip_version_compare($version, $version_maj, '<')) |
|
| 146 | - and (spip_version_compare($page, $version_maj, '<')) |
|
| 147 | - and spip_version_compare($branche, $branche_maj, '<') |
|
| 148 | - ) { |
|
| 149 | - $page_majeure = $version_maj; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - if (!$page and !$page_majeure) { |
|
| 153 | - return ''; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - $message = $page ? _T('nouvelle_version_spip', ['version' => $page]) . ($page_majeure ? ' | ' : '') : ''; |
|
| 157 | - $message .= $page_majeure ? _T('nouvelle_version_spip_majeure', ['version' => $page_majeure]) : ''; |
|
| 158 | - |
|
| 159 | - return "<a class='info_maj_spip' href='https://www.spip.net/fr_update' title='$page'>" . $message . '</a>'; |
|
| 112 | + include_spip('inc/plugin'); |
|
| 113 | + |
|
| 114 | + [$maj, $min, $rev] = preg_split('/\D+/', $version); |
|
| 115 | + |
|
| 116 | + $nom = _DIR_CACHE_XML . _VERSIONS_LISTE; |
|
| 117 | + $page = !file_exists($nom) ? '' : file_get_contents($nom); |
|
| 118 | + $page = info_maj_cache($nom, $dir, $page); |
|
| 119 | + |
|
| 120 | + // reperer toutes les versions de numero majeur superieur ou egal |
|
| 121 | + // (a revoir quand on arrivera a SPIP V10 ...) |
|
| 122 | + $p = substr('0123456789', intval($maj)); |
|
| 123 | + $p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i'; |
|
| 124 | + preg_match_all($p, $page, $m, PREG_SET_ORDER); |
|
| 125 | + $page = $page_majeure = ''; |
|
| 126 | + |
|
| 127 | + // branche en cours d'utilisation |
|
| 128 | + $branche = implode('.', array_slice(explode('.', $version, 3), 0, 2)); |
|
| 129 | + |
|
| 130 | + foreach ($m as $v) { |
|
| 131 | + $v = array_pad($v, 5, 0); |
|
| 132 | + [, $maj2, $min2, , $rev2] = $v; |
|
| 133 | + $branche_maj = $maj2 . '.' . $min2; |
|
| 134 | + $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 135 | + // d'abord les mises à jour de la même branche |
|
| 136 | + if ( |
|
| 137 | + (spip_version_compare($version, $version_maj, '<')) |
|
| 138 | + and (spip_version_compare($page, $version_maj, '<')) |
|
| 139 | + and spip_version_compare($branche, $branche_maj, '=') |
|
| 140 | + ) { |
|
| 141 | + $page = $version_maj; |
|
| 142 | + } |
|
| 143 | + // puis les mises à jours majeures |
|
| 144 | + if ( |
|
| 145 | + (spip_version_compare($version, $version_maj, '<')) |
|
| 146 | + and (spip_version_compare($page, $version_maj, '<')) |
|
| 147 | + and spip_version_compare($branche, $branche_maj, '<') |
|
| 148 | + ) { |
|
| 149 | + $page_majeure = $version_maj; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + if (!$page and !$page_majeure) { |
|
| 153 | + return ''; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + $message = $page ? _T('nouvelle_version_spip', ['version' => $page]) . ($page_majeure ? ' | ' : '') : ''; |
|
| 157 | + $message .= $page_majeure ? _T('nouvelle_version_spip_majeure', ['version' => $page_majeure]) : ''; |
|
| 158 | + |
|
| 159 | + return "<a class='info_maj_spip' href='https://www.spip.net/fr_update' title='$page'>" . $message . '</a>'; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -177,25 +177,25 @@ discard block |
||
| 177 | 177 | * Contenu du fichier de cache de l'info de maj de SPIP. |
| 178 | 178 | */ |
| 179 | 179 | function info_maj_cache($nom, $dir, $page = '') { |
| 180 | - include_spip('inc/acces'); |
|
| 181 | - $alea_ephemere = charger_aleas(); |
|
| 182 | - $re = '<archives id="a' . $alea_ephemere . '">'; |
|
| 183 | - if (preg_match("/$re/", $page)) { |
|
| 184 | - return $page; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE; |
|
| 188 | - $a = file_exists($nom) ? filemtime($nom) : ''; |
|
| 189 | - include_spip('inc/distant'); |
|
| 190 | - $res = recuperer_url_cache($url, ['if_modified_since' => $a]); |
|
| 191 | - // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 192 | - if ($res) { |
|
| 193 | - $page = $res['page'] ?: $page; |
|
| 194 | - } |
|
| 195 | - // Placer l'indicateur de fraicheur |
|
| 196 | - $page = preg_replace('/^<archives.*?>/', $re, $page); |
|
| 197 | - sous_repertoire(_DIR_CACHE_XML); |
|
| 198 | - ecrire_fichier($nom, $page); |
|
| 199 | - |
|
| 200 | - return $page; |
|
| 180 | + include_spip('inc/acces'); |
|
| 181 | + $alea_ephemere = charger_aleas(); |
|
| 182 | + $re = '<archives id="a' . $alea_ephemere . '">'; |
|
| 183 | + if (preg_match("/$re/", $page)) { |
|
| 184 | + return $page; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE; |
|
| 188 | + $a = file_exists($nom) ? filemtime($nom) : ''; |
|
| 189 | + include_spip('inc/distant'); |
|
| 190 | + $res = recuperer_url_cache($url, ['if_modified_since' => $a]); |
|
| 191 | + // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 192 | + if ($res) { |
|
| 193 | + $page = $res['page'] ?: $page; |
|
| 194 | + } |
|
| 195 | + // Placer l'indicateur de fraicheur |
|
| 196 | + $page = preg_replace('/^<archives.*?>/', $re, $page); |
|
| 197 | + sous_repertoire(_DIR_CACHE_XML); |
|
| 198 | + ecrire_fichier($nom, $page); |
|
| 199 | + |
|
| 200 | + return $page; |
|
| 201 | 201 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/abstract_sql'); |
@@ -35,26 +35,26 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function genie_optimiser_dist($t) { |
| 37 | 37 | |
| 38 | - optimiser_base_une_table(); |
|
| 39 | - optimiser_base(); |
|
| 40 | - optimiser_caches_contextes(); |
|
| 38 | + optimiser_base_une_table(); |
|
| 39 | + optimiser_base(); |
|
| 40 | + optimiser_caches_contextes(); |
|
| 41 | 41 | |
| 42 | - // la date souhaitee pour le tour suivant = apres-demain a 4h du mat ; |
|
| 43 | - // sachant qu'on a un delai de 48h, on renvoie aujourd'hui a 4h du mat |
|
| 44 | - // avec une periode de flou entre 2h et 6h pour ne pas saturer un hebergeur |
|
| 45 | - // qui aurait beaucoup de sites SPIP |
|
| 46 | - return -(mktime(2, 0, 0) + random_int(0, 3600 * 4)); |
|
| 42 | + // la date souhaitee pour le tour suivant = apres-demain a 4h du mat ; |
|
| 43 | + // sachant qu'on a un delai de 48h, on renvoie aujourd'hui a 4h du mat |
|
| 44 | + // avec une periode de flou entre 2h et 6h pour ne pas saturer un hebergeur |
|
| 45 | + // qui aurait beaucoup de sites SPIP |
|
| 46 | + return -(mktime(2, 0, 0) + random_int(0, 3600 * 4)); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Vider les contextes ajax de plus de 48h |
| 51 | 51 | */ |
| 52 | 52 | function optimiser_caches_contextes() { |
| 53 | - sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 54 | - if (is_dir($d = _DIR_CACHE . 'contextes')) { |
|
| 55 | - include_spip('inc/invalideur'); |
|
| 56 | - purger_repertoire($d, ['mtime' => time() - 48 * 24 * 3600, 'limit' => 10000]); |
|
| 57 | - } |
|
| 53 | + sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 54 | + if (is_dir($d = _DIR_CACHE . 'contextes')) { |
|
| 55 | + include_spip('inc/invalideur'); |
|
| 56 | + purger_repertoire($d, ['mtime' => time() - 48 * 24 * 3600, 'limit' => 10000]); |
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return void |
| 70 | 70 | **/ |
| 71 | 71 | function optimiser_base($attente = 86400) { |
| 72 | - optimiser_base_disparus($attente); |
|
| 72 | + optimiser_base_disparus($attente); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -86,28 +86,28 @@ discard block |
||
| 86 | 86 | **/ |
| 87 | 87 | function optimiser_base_une_table() { |
| 88 | 88 | |
| 89 | - $tables = []; |
|
| 90 | - $result = sql_showbase(); |
|
| 91 | - |
|
| 92 | - // on n'optimise qu'une seule table a chaque fois, |
|
| 93 | - // pour ne pas vautrer le systeme |
|
| 94 | - // lire http://dev.mysql.com/doc/refman/5.0/fr/optimize-table.html |
|
| 95 | - while ($row = sql_fetch($result)) { |
|
| 96 | - $tables[] = array_shift($row); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - spip_log('optimiser_base_une_table ' . json_encode($tables, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG); |
|
| 100 | - if ($tables) { |
|
| 101 | - $table_op = intval(lire_config('optimiser_table', 0) + 1) % sizeof($tables); |
|
| 102 | - ecrire_config('optimiser_table', $table_op); |
|
| 103 | - $q = $tables[$table_op]; |
|
| 104 | - spip_log("optimiser_base_une_table : debut d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 105 | - if (sql_optimize($q)) { |
|
| 106 | - spip_log("optimiser_base_une_table : fin d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 107 | - } else { |
|
| 108 | - spip_log("optimiser_base_une_table : Pas d'optimiseur necessaire", 'genie' . _LOG_DEBUG); |
|
| 109 | - } |
|
| 110 | - } |
|
| 89 | + $tables = []; |
|
| 90 | + $result = sql_showbase(); |
|
| 91 | + |
|
| 92 | + // on n'optimise qu'une seule table a chaque fois, |
|
| 93 | + // pour ne pas vautrer le systeme |
|
| 94 | + // lire http://dev.mysql.com/doc/refman/5.0/fr/optimize-table.html |
|
| 95 | + while ($row = sql_fetch($result)) { |
|
| 96 | + $tables[] = array_shift($row); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + spip_log('optimiser_base_une_table ' . json_encode($tables, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG); |
|
| 100 | + if ($tables) { |
|
| 101 | + $table_op = intval(lire_config('optimiser_table', 0) + 1) % sizeof($tables); |
|
| 102 | + ecrire_config('optimiser_table', $table_op); |
|
| 103 | + $q = $tables[$table_op]; |
|
| 104 | + spip_log("optimiser_base_une_table : debut d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 105 | + if (sql_optimize($q)) { |
|
| 106 | + spip_log("optimiser_base_une_table : fin d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 107 | + } else { |
|
| 108 | + spip_log("optimiser_base_une_table : Pas d'optimiseur necessaire", 'genie' . _LOG_DEBUG); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | |
@@ -133,18 +133,18 @@ discard block |
||
| 133 | 133 | * Nombre de suppressions |
| 134 | 134 | **/ |
| 135 | 135 | function optimiser_sansref($table, $id, $sel, $and = '') { |
| 136 | - $in = []; |
|
| 137 | - while ($row = sql_fetch($sel)) { |
|
| 138 | - $in[$row['id']] = true; |
|
| 139 | - } |
|
| 140 | - sql_free($sel); |
|
| 141 | - |
|
| 142 | - if ($in) { |
|
| 143 | - sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 144 | - spip_log("optimiser_sansref: Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in)), 'genie' . _LOG_DEBUG); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return count($in); |
|
| 136 | + $in = []; |
|
| 137 | + while ($row = sql_fetch($sel)) { |
|
| 138 | + $in[$row['id']] = true; |
|
| 139 | + } |
|
| 140 | + sql_free($sel); |
|
| 141 | + |
|
| 142 | + if ($in) { |
|
| 143 | + sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 144 | + spip_log("optimiser_sansref: Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in)), 'genie' . _LOG_DEBUG); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return count($in); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
@@ -166,81 +166,81 @@ discard block |
||
| 166 | 166 | **/ |
| 167 | 167 | function optimiser_base_disparus($attente = 86400) { |
| 168 | 168 | |
| 169 | - # format = 20060610110141, si on veut forcer une optimisation tout de suite |
|
| 170 | - $mydate = date('Y-m-d H:i:s', time() - $attente); |
|
| 171 | - $mydate_quote = sql_quote($mydate); |
|
| 169 | + # format = 20060610110141, si on veut forcer une optimisation tout de suite |
|
| 170 | + $mydate = date('Y-m-d H:i:s', time() - $attente); |
|
| 171 | + $mydate_quote = sql_quote($mydate); |
|
| 172 | 172 | |
| 173 | - $n = 0; |
|
| 173 | + $n = 0; |
|
| 174 | 174 | |
| 175 | - // |
|
| 176 | - // Rubriques |
|
| 177 | - // |
|
| 175 | + // |
|
| 176 | + // Rubriques |
|
| 177 | + // |
|
| 178 | 178 | |
| 179 | - # les articles qui sont dans une id_rubrique inexistante |
|
| 180 | - # attention on controle id_rubrique>0 pour ne pas tuer les articles |
|
| 181 | - # specialement affectes a une rubrique non-existante (plugin, |
|
| 182 | - # cf. https://core.spip.net/issues/1549 ) |
|
| 183 | - $res = sql_select( |
|
| 184 | - 'A.id_article AS id', |
|
| 185 | - 'spip_articles AS A |
|
| 179 | + # les articles qui sont dans une id_rubrique inexistante |
|
| 180 | + # attention on controle id_rubrique>0 pour ne pas tuer les articles |
|
| 181 | + # specialement affectes a une rubrique non-existante (plugin, |
|
| 182 | + # cf. https://core.spip.net/issues/1549 ) |
|
| 183 | + $res = sql_select( |
|
| 184 | + 'A.id_article AS id', |
|
| 185 | + 'spip_articles AS A |
|
| 186 | 186 | LEFT JOIN spip_rubriques AS R |
| 187 | 187 | ON A.id_rubrique=R.id_rubrique', |
| 188 | - "A.id_rubrique > 0 |
|
| 188 | + "A.id_rubrique > 0 |
|
| 189 | 189 | AND R.id_rubrique IS NULL |
| 190 | 190 | AND A.maj < $mydate_quote" |
| 191 | - ); |
|
| 191 | + ); |
|
| 192 | 192 | |
| 193 | - $n += optimiser_sansref('spip_articles', 'id_article', $res); |
|
| 193 | + $n += optimiser_sansref('spip_articles', 'id_article', $res); |
|
| 194 | 194 | |
| 195 | - // les articles a la poubelle |
|
| 196 | - sql_delete('spip_articles', "statut='poubelle' AND maj < $mydate_quote"); |
|
| 195 | + // les articles a la poubelle |
|
| 196 | + sql_delete('spip_articles', "statut='poubelle' AND maj < $mydate_quote"); |
|
| 197 | 197 | |
| 198 | - // |
|
| 199 | - // Auteurs |
|
| 200 | - // |
|
| 198 | + // |
|
| 199 | + // Auteurs |
|
| 200 | + // |
|
| 201 | 201 | |
| 202 | - include_spip('action/editer_liens'); |
|
| 203 | - // optimiser les liens de tous les auteurs vers des objets effaces |
|
| 204 | - // et depuis des auteurs effaces |
|
| 205 | - $n += objet_optimiser_liens(['auteur' => '*'], '*'); |
|
| 202 | + include_spip('action/editer_liens'); |
|
| 203 | + // optimiser les liens de tous les auteurs vers des objets effaces |
|
| 204 | + // et depuis des auteurs effaces |
|
| 205 | + $n += objet_optimiser_liens(['auteur' => '*'], '*'); |
|
| 206 | 206 | |
| 207 | - # effacer les auteurs poubelle qui ne sont lies a rien |
|
| 208 | - $res = sql_select( |
|
| 209 | - 'A.id_auteur AS id', |
|
| 210 | - 'spip_auteurs AS A |
|
| 207 | + # effacer les auteurs poubelle qui ne sont lies a rien |
|
| 208 | + $res = sql_select( |
|
| 209 | + 'A.id_auteur AS id', |
|
| 210 | + 'spip_auteurs AS A |
|
| 211 | 211 | LEFT JOIN spip_auteurs_liens AS L |
| 212 | 212 | ON L.id_auteur=A.id_auteur', |
| 213 | - "L.id_auteur IS NULL |
|
| 213 | + "L.id_auteur IS NULL |
|
| 214 | 214 | AND A.statut='5poubelle' AND A.maj < $mydate_quote" |
| 215 | - ); |
|
| 216 | - |
|
| 217 | - $n += optimiser_sansref('spip_auteurs', 'id_auteur', $res); |
|
| 218 | - |
|
| 219 | - # supprimer les auteurs 'nouveau' qui n'ont jamais donne suite |
|
| 220 | - # au mail de confirmation (45 jours pour repondre, ca devrait suffire) |
|
| 221 | - if (!defined('_AUTEURS_DELAI_REJET_NOUVEAU')) { |
|
| 222 | - define('_AUTEURS_DELAI_REJET_NOUVEAU', 45 * 24 * 3600); |
|
| 223 | - } |
|
| 224 | - sql_delete('spip_auteurs', "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - intval(_AUTEURS_DELAI_REJET_NOUVEAU)))); |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
|
| 228 | - * |
|
| 229 | - * L'index 'data' est un entier indiquant le nombre d'optimisations |
|
| 230 | - * qui ont été réalisées (par exemple le nombre de suppressions faites) |
|
| 231 | - * et qui doit être incrémenté par les fonctions |
|
| 232 | - * utilisant ce pipeline si elles suppriment des éléments. |
|
| 233 | - * |
|
| 234 | - * @pipeline_appel optimiser_base_disparus |
|
| 235 | - */ |
|
| 236 | - $n = pipeline('optimiser_base_disparus', [ |
|
| 237 | - 'args' => [ |
|
| 238 | - 'attente' => $attente, |
|
| 239 | - 'date' => $mydate |
|
| 240 | - ], |
|
| 241 | - 'data' => $n |
|
| 242 | - ]); |
|
| 243 | - |
|
| 244 | - |
|
| 245 | - spip_log("optimiser_base_disparus : {$n} lien(s) mort(s)", 'genie' . _LOG_DEBUG); |
|
| 215 | + ); |
|
| 216 | + |
|
| 217 | + $n += optimiser_sansref('spip_auteurs', 'id_auteur', $res); |
|
| 218 | + |
|
| 219 | + # supprimer les auteurs 'nouveau' qui n'ont jamais donne suite |
|
| 220 | + # au mail de confirmation (45 jours pour repondre, ca devrait suffire) |
|
| 221 | + if (!defined('_AUTEURS_DELAI_REJET_NOUVEAU')) { |
|
| 222 | + define('_AUTEURS_DELAI_REJET_NOUVEAU', 45 * 24 * 3600); |
|
| 223 | + } |
|
| 224 | + sql_delete('spip_auteurs', "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - intval(_AUTEURS_DELAI_REJET_NOUVEAU)))); |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
|
| 228 | + * |
|
| 229 | + * L'index 'data' est un entier indiquant le nombre d'optimisations |
|
| 230 | + * qui ont été réalisées (par exemple le nombre de suppressions faites) |
|
| 231 | + * et qui doit être incrémenté par les fonctions |
|
| 232 | + * utilisant ce pipeline si elles suppriment des éléments. |
|
| 233 | + * |
|
| 234 | + * @pipeline_appel optimiser_base_disparus |
|
| 235 | + */ |
|
| 236 | + $n = pipeline('optimiser_base_disparus', [ |
|
| 237 | + 'args' => [ |
|
| 238 | + 'attente' => $attente, |
|
| 239 | + 'date' => $mydate |
|
| 240 | + ], |
|
| 241 | + 'data' => $n |
|
| 242 | + ]); |
|
| 243 | + |
|
| 244 | + |
|
| 245 | + spip_log("optimiser_base_disparus : {$n} lien(s) mort(s)", 'genie' . _LOG_DEBUG); |
|
| 246 | 246 | } |