@@ -10,210 +10,210 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/install'); |
| 17 | 17 | |
| 18 | 18 | function formulaires_declarer_bases_charger_dist() { |
| 19 | 19 | |
| 20 | - if (!autoriser('detruire')) { |
|
| 21 | - return false; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - [$adresse_db, $login_db, $pass_db, $sel, $server_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 25 | - |
|
| 26 | - $deja = bases_referencees(_FILE_CONNECT); |
|
| 27 | - // proposer un nom de connect si pas encore saisi |
|
| 28 | - $nom_connect = ''; |
|
| 29 | - if (defined('_DECLARER_CHOIX_DB')) { |
|
| 30 | - $nom_connect = _DECLARER_CHOIX_DB; |
|
| 31 | - $n = ''; |
|
| 32 | - while (in_array($nom_connect . $n, $deja)) { |
|
| 33 | - $n = ($n ? $n + 1 : 1); |
|
| 34 | - } |
|
| 35 | - $nom_connect .= $n; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - return [ |
|
| 39 | - '_etapes' => 3, |
|
| 40 | - '_bases_deja' => $deja, |
|
| 41 | - '_bases_prop' => defined('_DECLARER_SERVEUR_DB') ? liste_bases(_DECLARER_SERVEUR_DB) : '', |
|
| 42 | - '_tables' => (defined('_DECLARER_SERVEUR_DB') && defined('_DECLARER_CHOIX_DB')) ? |
|
| 43 | - $tables = sql_alltable('%', _DECLARER_SERVEUR_DB) |
|
| 44 | - : |
|
| 45 | - [], |
|
| 46 | - 'main_db' => '', |
|
| 47 | - '_serveurs' => liste_serveurs(), |
|
| 48 | - 'sql_serveur_db' => 'sqlite3', // valeur par defaut |
|
| 49 | - 'adresse_db' => $adresse_db, |
|
| 50 | - 'login_db' => '', |
|
| 51 | - 'pass_db' => '', |
|
| 52 | - 'choix_db' => '', |
|
| 53 | - 'table_new' => '', |
|
| 54 | - 'nom_connect' => $nom_connect, |
|
| 55 | - ]; |
|
| 20 | + if (!autoriser('detruire')) { |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + [$adresse_db, $login_db, $pass_db, $sel, $server_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 25 | + |
|
| 26 | + $deja = bases_referencees(_FILE_CONNECT); |
|
| 27 | + // proposer un nom de connect si pas encore saisi |
|
| 28 | + $nom_connect = ''; |
|
| 29 | + if (defined('_DECLARER_CHOIX_DB')) { |
|
| 30 | + $nom_connect = _DECLARER_CHOIX_DB; |
|
| 31 | + $n = ''; |
|
| 32 | + while (in_array($nom_connect . $n, $deja)) { |
|
| 33 | + $n = ($n ? $n + 1 : 1); |
|
| 34 | + } |
|
| 35 | + $nom_connect .= $n; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + return [ |
|
| 39 | + '_etapes' => 3, |
|
| 40 | + '_bases_deja' => $deja, |
|
| 41 | + '_bases_prop' => defined('_DECLARER_SERVEUR_DB') ? liste_bases(_DECLARER_SERVEUR_DB) : '', |
|
| 42 | + '_tables' => (defined('_DECLARER_SERVEUR_DB') && defined('_DECLARER_CHOIX_DB')) ? |
|
| 43 | + $tables = sql_alltable('%', _DECLARER_SERVEUR_DB) |
|
| 44 | + : |
|
| 45 | + [], |
|
| 46 | + 'main_db' => '', |
|
| 47 | + '_serveurs' => liste_serveurs(), |
|
| 48 | + 'sql_serveur_db' => 'sqlite3', // valeur par defaut |
|
| 49 | + 'adresse_db' => $adresse_db, |
|
| 50 | + 'login_db' => '', |
|
| 51 | + 'pass_db' => '', |
|
| 52 | + 'choix_db' => '', |
|
| 53 | + 'table_new' => '', |
|
| 54 | + 'nom_connect' => $nom_connect, |
|
| 55 | + ]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function liste_serveurs() { |
| 59 | - $options = []; |
|
| 60 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 61 | - $d = opendir($dir); |
|
| 62 | - if (!$d) { |
|
| 63 | - return []; |
|
| 64 | - } |
|
| 65 | - while ($f = readdir($d)) { |
|
| 66 | - if ( |
|
| 67 | - preg_match('/^(.*)[.]php$/', $f, $s) |
|
| 68 | - && is_readable($f = $dir . $f) |
|
| 69 | - ) { |
|
| 70 | - require_once($f); |
|
| 71 | - $s = $s[1]; |
|
| 72 | - $v = 'spip_versions_' . $s; |
|
| 73 | - if (function_exists($v) && $v()) { |
|
| 74 | - $options[$s] = "install_select_type_$s"; |
|
| 75 | - } else { |
|
| 76 | - spip_logger()->info("$s: portage indisponible"); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - ksort($options); |
|
| 81 | - |
|
| 82 | - return $options; |
|
| 59 | + $options = []; |
|
| 60 | + $dir = _DIR_RESTREINT . 'req/'; |
|
| 61 | + $d = opendir($dir); |
|
| 62 | + if (!$d) { |
|
| 63 | + return []; |
|
| 64 | + } |
|
| 65 | + while ($f = readdir($d)) { |
|
| 66 | + if ( |
|
| 67 | + preg_match('/^(.*)[.]php$/', $f, $s) |
|
| 68 | + && is_readable($f = $dir . $f) |
|
| 69 | + ) { |
|
| 70 | + require_once($f); |
|
| 71 | + $s = $s[1]; |
|
| 72 | + $v = 'spip_versions_' . $s; |
|
| 73 | + if (function_exists($v) && $v()) { |
|
| 74 | + $options[$s] = "install_select_type_$s"; |
|
| 75 | + } else { |
|
| 76 | + spip_logger()->info("$s: portage indisponible"); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + ksort($options); |
|
| 81 | + |
|
| 82 | + return $options; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | function liste_bases($server_db) { |
| 86 | - if ( |
|
| 87 | - is_null($server_db) |
|
| 88 | - || !$result = sql_listdbs($server_db) |
|
| 89 | - ) { |
|
| 90 | - return ''; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $noms = []; |
|
| 94 | - |
|
| 95 | - // si sqlite : result est deja un tableau |
|
| 96 | - if (is_array($result)) { |
|
| 97 | - $noms = $result; |
|
| 98 | - } else { |
|
| 99 | - while ($row = sql_fetch($result, $server_db)) { |
|
| 100 | - $noms[] = reset($row); |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - return $noms; |
|
| 86 | + if ( |
|
| 87 | + is_null($server_db) |
|
| 88 | + || !$result = sql_listdbs($server_db) |
|
| 89 | + ) { |
|
| 90 | + return ''; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $noms = []; |
|
| 94 | + |
|
| 95 | + // si sqlite : result est deja un tableau |
|
| 96 | + if (is_array($result)) { |
|
| 97 | + $noms = $result; |
|
| 98 | + } else { |
|
| 99 | + while ($row = sql_fetch($result, $server_db)) { |
|
| 100 | + $noms[] = reset($row); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + return $noms; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | function formulaires_declarer_bases_verifier_1_dist() { |
| 108 | - $erreurs = []; |
|
| 109 | - [$def_adresse_db, $def_login_db, $def_pass_db, $sel_db, $def_serveur_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 110 | - |
|
| 111 | - if (!$adresse_db = _request('adresse_db')) { |
|
| 112 | - $adresse_db = defined('_INSTALL_HOST_DB') ? _INSTALL_HOST_DB : $def_adresse_db; |
|
| 113 | - } |
|
| 114 | - if (!$serveur_db = _request('sql_serveur_db')) { |
|
| 115 | - $serveur_db = defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : $def_serveur_db; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $login_db = $pass_db = ''; |
|
| 119 | - if (!preg_match(',^sqlite,i', (string) $serveur_db)) { |
|
| 120 | - if (!$login_db = _request('login_db')) { |
|
| 121 | - $login_db = defined('_INSTALL_USER_DB') ? _INSTALL_USER_DB : $def_login_db; |
|
| 122 | - } |
|
| 123 | - if (!$pass_db = _request('pass_db')) { |
|
| 124 | - $pass_db = defined('_INSTALL_PASS_DB') ? _INSTALL_PASS_DB : $def_pass_db; |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
|
| 129 | - if ($link) { |
|
| 130 | - $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 131 | - $GLOBALS['connexions'][$serveur_db] = $link; |
|
| 132 | - define('_DECLARER_SERVEUR_DB', $serveur_db); |
|
| 133 | - define('_DECLARER_ADRESSE_DB', $adresse_db); |
|
| 134 | - define('_DECLARER_LOGIN_DB', $login_db); |
|
| 135 | - define('_DECLARER_PASS_DB', $pass_db); |
|
| 136 | - // si on est sur le meme serveur que connect.php |
|
| 137 | - // indiquer quelle est la db utilisee pour l'exclure des choix possibles |
|
| 138 | - if ($serveur_db == $def_serveur_db && $adresse_db == $def_adresse_db) { |
|
| 139 | - set_request('main_db', $sel_db); |
|
| 140 | - } else { |
|
| 141 | - set_request('main_db', ''); |
|
| 142 | - } |
|
| 143 | - } else { |
|
| 144 | - $erreurs['message_erreur'] = _T('avis_connexion_echec_1'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return $erreurs; |
|
| 108 | + $erreurs = []; |
|
| 109 | + [$def_adresse_db, $def_login_db, $def_pass_db, $sel_db, $def_serveur_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 110 | + |
|
| 111 | + if (!$adresse_db = _request('adresse_db')) { |
|
| 112 | + $adresse_db = defined('_INSTALL_HOST_DB') ? _INSTALL_HOST_DB : $def_adresse_db; |
|
| 113 | + } |
|
| 114 | + if (!$serveur_db = _request('sql_serveur_db')) { |
|
| 115 | + $serveur_db = defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : $def_serveur_db; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + $login_db = $pass_db = ''; |
|
| 119 | + if (!preg_match(',^sqlite,i', (string) $serveur_db)) { |
|
| 120 | + if (!$login_db = _request('login_db')) { |
|
| 121 | + $login_db = defined('_INSTALL_USER_DB') ? _INSTALL_USER_DB : $def_login_db; |
|
| 122 | + } |
|
| 123 | + if (!$pass_db = _request('pass_db')) { |
|
| 124 | + $pass_db = defined('_INSTALL_PASS_DB') ? _INSTALL_PASS_DB : $def_pass_db; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
|
| 129 | + if ($link) { |
|
| 130 | + $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 131 | + $GLOBALS['connexions'][$serveur_db] = $link; |
|
| 132 | + define('_DECLARER_SERVEUR_DB', $serveur_db); |
|
| 133 | + define('_DECLARER_ADRESSE_DB', $adresse_db); |
|
| 134 | + define('_DECLARER_LOGIN_DB', $login_db); |
|
| 135 | + define('_DECLARER_PASS_DB', $pass_db); |
|
| 136 | + // si on est sur le meme serveur que connect.php |
|
| 137 | + // indiquer quelle est la db utilisee pour l'exclure des choix possibles |
|
| 138 | + if ($serveur_db == $def_serveur_db && $adresse_db == $def_adresse_db) { |
|
| 139 | + set_request('main_db', $sel_db); |
|
| 140 | + } else { |
|
| 141 | + set_request('main_db', ''); |
|
| 142 | + } |
|
| 143 | + } else { |
|
| 144 | + $erreurs['message_erreur'] = _T('avis_connexion_echec_1'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return $erreurs; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | function formulaires_declarer_bases_verifier_2_dist() { |
| 151 | - $erreurs = []; |
|
| 152 | - $choix_db = _request('choix_db'); |
|
| 153 | - if ($choix_db == '-1') { |
|
| 154 | - $choix_db = _request('table_new'); |
|
| 155 | - } |
|
| 156 | - if (!$choix_db) { |
|
| 157 | - $erreurs['choix_db'] = _T('info_obligatoire'); |
|
| 158 | - } else { |
|
| 159 | - define('_ECRIRE_INSTALL', 1); // hackons sqlite |
|
| 160 | - if (!sql_selectdb($choix_db, _DECLARER_SERVEUR_DB)) { |
|
| 161 | - $erreurs['choix_db'] = _T('avis_base_inaccessible', ['base' => $choix_db]); |
|
| 162 | - } else { |
|
| 163 | - define('_DECLARER_CHOIX_DB', $choix_db); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - return $erreurs; |
|
| 151 | + $erreurs = []; |
|
| 152 | + $choix_db = _request('choix_db'); |
|
| 153 | + if ($choix_db == '-1') { |
|
| 154 | + $choix_db = _request('table_new'); |
|
| 155 | + } |
|
| 156 | + if (!$choix_db) { |
|
| 157 | + $erreurs['choix_db'] = _T('info_obligatoire'); |
|
| 158 | + } else { |
|
| 159 | + define('_ECRIRE_INSTALL', 1); // hackons sqlite |
|
| 160 | + if (!sql_selectdb($choix_db, _DECLARER_SERVEUR_DB)) { |
|
| 161 | + $erreurs['choix_db'] = _T('avis_base_inaccessible', ['base' => $choix_db]); |
|
| 162 | + } else { |
|
| 163 | + define('_DECLARER_CHOIX_DB', $choix_db); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + return $erreurs; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | function formulaires_declarer_bases_verifier_3_dist() { |
| 171 | - $erreurs = []; |
|
| 172 | - $nom_connect = _request('nom_connect'); |
|
| 173 | - if (!$nom_connect) { |
|
| 174 | - $erreurs['nom_connect'] = _T('info_obligatoire'); |
|
| 175 | - } else { |
|
| 176 | - // securite : le nom doit etre un mot sans caracteres speciaux |
|
| 177 | - $f = preg_replace(',[^\w],', '', (string) $nom_connect); |
|
| 178 | - if ($f !== $nom_connect) { |
|
| 179 | - $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
|
| 180 | - } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 181 | - $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
|
| 182 | - } else { |
|
| 183 | - define('_DECLARER_NOM_CONNECT', $nom_connect); |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - return $erreurs; |
|
| 171 | + $erreurs = []; |
|
| 172 | + $nom_connect = _request('nom_connect'); |
|
| 173 | + if (!$nom_connect) { |
|
| 174 | + $erreurs['nom_connect'] = _T('info_obligatoire'); |
|
| 175 | + } else { |
|
| 176 | + // securite : le nom doit etre un mot sans caracteres speciaux |
|
| 177 | + $f = preg_replace(',[^\w],', '', (string) $nom_connect); |
|
| 178 | + if ($f !== $nom_connect) { |
|
| 179 | + $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
|
| 180 | + } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 181 | + $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
|
| 182 | + } else { |
|
| 183 | + define('_DECLARER_NOM_CONNECT', $nom_connect); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + return $erreurs; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | function formulaires_declarer_bases_traiter_dist() { |
| 191 | 191 | |
| 192 | - $adresse_db = _DECLARER_ADRESSE_DB; |
|
| 193 | - if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 194 | - [, $adresse_db, $port] = $r; |
|
| 195 | - } else { |
|
| 196 | - $port = ''; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - $server_db = addcslashes((string) _DECLARER_SERVEUR_DB, "'\\"); |
|
| 200 | - |
|
| 201 | - $conn = install_mode_appel($server_db) |
|
| 202 | - . install_connexion( |
|
| 203 | - $adresse_db, |
|
| 204 | - $port, |
|
| 205 | - _DECLARER_LOGIN_DB, |
|
| 206 | - _DECLARER_PASS_DB, |
|
| 207 | - _DECLARER_CHOIX_DB, |
|
| 208 | - _DECLARER_SERVEUR_DB, |
|
| 209 | - '', |
|
| 210 | - '', |
|
| 211 | - '' |
|
| 212 | - ); |
|
| 213 | - |
|
| 214 | - install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 215 | - |
|
| 216 | - return [ |
|
| 217 | - 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>']) |
|
| 218 | - ]; |
|
| 192 | + $adresse_db = _DECLARER_ADRESSE_DB; |
|
| 193 | + if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 194 | + [, $adresse_db, $port] = $r; |
|
| 195 | + } else { |
|
| 196 | + $port = ''; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + $server_db = addcslashes((string) _DECLARER_SERVEUR_DB, "'\\"); |
|
| 200 | + |
|
| 201 | + $conn = install_mode_appel($server_db) |
|
| 202 | + . install_connexion( |
|
| 203 | + $adresse_db, |
|
| 204 | + $port, |
|
| 205 | + _DECLARER_LOGIN_DB, |
|
| 206 | + _DECLARER_PASS_DB, |
|
| 207 | + _DECLARER_CHOIX_DB, |
|
| 208 | + _DECLARER_SERVEUR_DB, |
|
| 209 | + '', |
|
| 210 | + '', |
|
| 211 | + '' |
|
| 212 | + ); |
|
| 213 | + |
|
| 214 | + install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 215 | + |
|
| 216 | + return [ |
|
| 217 | + 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>']) |
|
| 218 | + ]; |
|
| 219 | 219 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -39,26 +39,26 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function formulaires_inscription_charger_dist($mode = '', $options = [], $retour = '') { |
| 41 | 41 | |
| 42 | - $id = ($options['id'] ?? 0); |
|
| 43 | - |
|
| 44 | - // fournir le mode de la config ou tester si l'argument du formulaire est un mode accepte par celle-ci |
|
| 45 | - // pas de formulaire si le mode est interdit |
|
| 46 | - include_spip('inc/autoriser'); |
|
| 47 | - if (!autoriser('inscrireauteur', $mode, $id)) { |
|
| 48 | - return false; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - // pas de formulaire si on a déjà une session avec un statut égal ou meilleur au mode |
|
| 52 | - if (isset($GLOBALS['visiteur_session']['statut']) && $GLOBALS['visiteur_session']['statut'] <= $mode) { |
|
| 53 | - return false; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return [ |
|
| 57 | - 'nom_inscription' => '', |
|
| 58 | - 'mail_inscription' => '', |
|
| 59 | - 'id' => $id, |
|
| 60 | - '_mode' => $mode |
|
| 61 | - ]; |
|
| 42 | + $id = ($options['id'] ?? 0); |
|
| 43 | + |
|
| 44 | + // fournir le mode de la config ou tester si l'argument du formulaire est un mode accepte par celle-ci |
|
| 45 | + // pas de formulaire si le mode est interdit |
|
| 46 | + include_spip('inc/autoriser'); |
|
| 47 | + if (!autoriser('inscrireauteur', $mode, $id)) { |
|
| 48 | + return false; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + // pas de formulaire si on a déjà une session avec un statut égal ou meilleur au mode |
|
| 52 | + if (isset($GLOBALS['visiteur_session']['statut']) && $GLOBALS['visiteur_session']['statut'] <= $mode) { |
|
| 53 | + return false; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return [ |
|
| 57 | + 'nom_inscription' => '', |
|
| 58 | + 'mail_inscription' => '', |
|
| 59 | + 'id' => $id, |
|
| 60 | + '_mode' => $mode |
|
| 61 | + ]; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -71,65 +71,65 @@ discard block |
||
| 71 | 71 | * @return array |
| 72 | 72 | */ |
| 73 | 73 | function formulaires_inscription_verifier_dist($mode = '', $options = [], $retour = '') { |
| 74 | - set_request('_upgrade_auteur'); // securite |
|
| 75 | - include_spip('inc/filtres'); |
|
| 76 | - $erreurs = []; |
|
| 77 | - |
|
| 78 | - $id = ($options['id'] ?? 0); |
|
| 79 | - |
|
| 80 | - include_spip('inc/autoriser'); |
|
| 81 | - if (!autoriser('inscrireauteur', $mode, $id) || strlen((string) _request('nobot')) > 0) { |
|
| 82 | - $erreurs['message_erreur'] = _T('pass_rien_a_faire_ici'); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - if (!$nom = _request('nom_inscription')) { |
|
| 86 | - $erreurs['nom_inscription'] = _T('info_obligatoire'); |
|
| 87 | - } elseif (!nom_acceptable(_request('nom_inscription'))) { |
|
| 88 | - $erreurs['nom_inscription'] = _T('ecrire:info_nom_pas_conforme'); |
|
| 89 | - } |
|
| 90 | - if (!$mail = (string) _request('mail_inscription')) { |
|
| 91 | - $erreurs['mail_inscription'] = _T('info_obligatoire'); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - // compatibilite avec anciennes fonction surchargeables |
|
| 95 | - // plus de definition par defaut |
|
| 96 | - if ($erreurs === []) { |
|
| 97 | - include_spip('action/inscrire_auteur'); |
|
| 98 | - $f = function_exists('test_inscription') ? 'test_inscription' : 'test_inscription_dist'; |
|
| 99 | - $declaration = $f($mode, $mail, $nom, $options); |
|
| 100 | - if (is_string($declaration)) { |
|
| 101 | - $k = (str_contains($declaration, 'mail')) ? |
|
| 102 | - 'mail_inscription' : 'nom_inscription'; |
|
| 103 | - $erreurs[$k] = _T($declaration); |
|
| 104 | - } else { |
|
| 105 | - include_spip('base/abstract_sql'); |
|
| 106 | - |
|
| 107 | - if ( |
|
| 108 | - $row = sql_fetsel( |
|
| 109 | - 'statut, id_auteur, login, email', |
|
| 110 | - 'spip_auteurs', |
|
| 111 | - 'email=' . sql_quote($declaration['email']) |
|
| 112 | - ) |
|
| 113 | - ) { |
|
| 114 | - if ($row['statut'] == '5poubelle' && empty($declaration['pass'])) { |
|
| 115 | - // irrecuperable |
|
| 116 | - $erreurs['message_erreur'] = _T('form_forum_access_refuse'); |
|
| 117 | - } else { |
|
| 118 | - if ($row['statut'] != 'nouveau' && empty($declaration['pass'])) { |
|
| 119 | - if ((int) $row['statut'] > (int) $mode) { |
|
| 120 | - set_request('_upgrade_auteur', $row['id_auteur']); |
|
| 121 | - } else { |
|
| 122 | - // deja inscrit |
|
| 123 | - $erreurs['message_erreur'] = _T('form_forum_email_deja_enregistre'); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - spip_logger()->info($row['id_auteur'] . ' veut se resinscrire'); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - return $erreurs; |
|
| 74 | + set_request('_upgrade_auteur'); // securite |
|
| 75 | + include_spip('inc/filtres'); |
|
| 76 | + $erreurs = []; |
|
| 77 | + |
|
| 78 | + $id = ($options['id'] ?? 0); |
|
| 79 | + |
|
| 80 | + include_spip('inc/autoriser'); |
|
| 81 | + if (!autoriser('inscrireauteur', $mode, $id) || strlen((string) _request('nobot')) > 0) { |
|
| 82 | + $erreurs['message_erreur'] = _T('pass_rien_a_faire_ici'); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + if (!$nom = _request('nom_inscription')) { |
|
| 86 | + $erreurs['nom_inscription'] = _T('info_obligatoire'); |
|
| 87 | + } elseif (!nom_acceptable(_request('nom_inscription'))) { |
|
| 88 | + $erreurs['nom_inscription'] = _T('ecrire:info_nom_pas_conforme'); |
|
| 89 | + } |
|
| 90 | + if (!$mail = (string) _request('mail_inscription')) { |
|
| 91 | + $erreurs['mail_inscription'] = _T('info_obligatoire'); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + // compatibilite avec anciennes fonction surchargeables |
|
| 95 | + // plus de definition par defaut |
|
| 96 | + if ($erreurs === []) { |
|
| 97 | + include_spip('action/inscrire_auteur'); |
|
| 98 | + $f = function_exists('test_inscription') ? 'test_inscription' : 'test_inscription_dist'; |
|
| 99 | + $declaration = $f($mode, $mail, $nom, $options); |
|
| 100 | + if (is_string($declaration)) { |
|
| 101 | + $k = (str_contains($declaration, 'mail')) ? |
|
| 102 | + 'mail_inscription' : 'nom_inscription'; |
|
| 103 | + $erreurs[$k] = _T($declaration); |
|
| 104 | + } else { |
|
| 105 | + include_spip('base/abstract_sql'); |
|
| 106 | + |
|
| 107 | + if ( |
|
| 108 | + $row = sql_fetsel( |
|
| 109 | + 'statut, id_auteur, login, email', |
|
| 110 | + 'spip_auteurs', |
|
| 111 | + 'email=' . sql_quote($declaration['email']) |
|
| 112 | + ) |
|
| 113 | + ) { |
|
| 114 | + if ($row['statut'] == '5poubelle' && empty($declaration['pass'])) { |
|
| 115 | + // irrecuperable |
|
| 116 | + $erreurs['message_erreur'] = _T('form_forum_access_refuse'); |
|
| 117 | + } else { |
|
| 118 | + if ($row['statut'] != 'nouveau' && empty($declaration['pass'])) { |
|
| 119 | + if ((int) $row['statut'] > (int) $mode) { |
|
| 120 | + set_request('_upgrade_auteur', $row['id_auteur']); |
|
| 121 | + } else { |
|
| 122 | + // deja inscrit |
|
| 123 | + $erreurs['message_erreur'] = _T('form_forum_email_deja_enregistre'); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + spip_logger()->info($row['id_auteur'] . ' veut se resinscrire'); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + return $erreurs; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -140,51 +140,51 @@ discard block |
||
| 140 | 140 | * @return array |
| 141 | 141 | */ |
| 142 | 142 | function formulaires_inscription_traiter_dist($mode = '', array $options = [], $retour = '') { |
| 143 | - if ($retour) { |
|
| 144 | - refuser_traiter_formulaire_ajax(); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - include_spip('inc/filtres'); |
|
| 148 | - include_spip('inc/autoriser'); |
|
| 149 | - |
|
| 150 | - $id = ($options['id'] ?? 0); |
|
| 151 | - |
|
| 152 | - if (!autoriser('inscrireauteur', $mode, $id)) { |
|
| 153 | - $desc = 'rien a faire ici'; |
|
| 154 | - } else { |
|
| 155 | - if ($id_auteur = _request('_upgrade_auteur')) { |
|
| 156 | - include_spip('action/editer_auteur'); |
|
| 157 | - autoriser_exception('modifier', 'auteur', $id_auteur); |
|
| 158 | - autoriser_exception('instituer', 'auteur', $id_auteur); |
|
| 159 | - auteur_modifier($id_auteur, ['statut' => $mode]); |
|
| 160 | - autoriser_exception('modifier', 'auteur', $id_auteur, false); |
|
| 161 | - autoriser_exception('instituer', 'auteur', $id_auteur, false); |
|
| 162 | - |
|
| 163 | - return ['message_ok' => _T('form_forum_email_deja_enregistre'), 'id_auteur' => $id_auteur]; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $nom = _request('nom_inscription'); |
|
| 167 | - $mail_complet = _request('mail_inscription'); |
|
| 168 | - |
|
| 169 | - $inscrire_auteur = charger_fonction('inscrire_auteur', 'action'); |
|
| 170 | - $desc = $inscrire_auteur($mode, $mail_complet, $nom, $options); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - // erreur ? |
|
| 174 | - if (is_string($desc)) { |
|
| 175 | - return ['message_erreur' => $desc]; |
|
| 176 | - } // OK |
|
| 177 | - else { |
|
| 178 | - $retours = [ |
|
| 179 | - 'message_ok' => _T('form_forum_identifiant_mail'), |
|
| 180 | - 'id_auteur' => $desc['id_auteur'] |
|
| 181 | - ]; |
|
| 182 | - |
|
| 183 | - // Si on demande à rediriger juste après validation du formulaire |
|
| 184 | - if ($retour) { |
|
| 185 | - $retours['redirect'] = $retour; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - return $retours; |
|
| 189 | - } |
|
| 143 | + if ($retour) { |
|
| 144 | + refuser_traiter_formulaire_ajax(); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + include_spip('inc/filtres'); |
|
| 148 | + include_spip('inc/autoriser'); |
|
| 149 | + |
|
| 150 | + $id = ($options['id'] ?? 0); |
|
| 151 | + |
|
| 152 | + if (!autoriser('inscrireauteur', $mode, $id)) { |
|
| 153 | + $desc = 'rien a faire ici'; |
|
| 154 | + } else { |
|
| 155 | + if ($id_auteur = _request('_upgrade_auteur')) { |
|
| 156 | + include_spip('action/editer_auteur'); |
|
| 157 | + autoriser_exception('modifier', 'auteur', $id_auteur); |
|
| 158 | + autoriser_exception('instituer', 'auteur', $id_auteur); |
|
| 159 | + auteur_modifier($id_auteur, ['statut' => $mode]); |
|
| 160 | + autoriser_exception('modifier', 'auteur', $id_auteur, false); |
|
| 161 | + autoriser_exception('instituer', 'auteur', $id_auteur, false); |
|
| 162 | + |
|
| 163 | + return ['message_ok' => _T('form_forum_email_deja_enregistre'), 'id_auteur' => $id_auteur]; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $nom = _request('nom_inscription'); |
|
| 167 | + $mail_complet = _request('mail_inscription'); |
|
| 168 | + |
|
| 169 | + $inscrire_auteur = charger_fonction('inscrire_auteur', 'action'); |
|
| 170 | + $desc = $inscrire_auteur($mode, $mail_complet, $nom, $options); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + // erreur ? |
|
| 174 | + if (is_string($desc)) { |
|
| 175 | + return ['message_erreur' => $desc]; |
|
| 176 | + } // OK |
|
| 177 | + else { |
|
| 178 | + $retours = [ |
|
| 179 | + 'message_ok' => _T('form_forum_identifiant_mail'), |
|
| 180 | + 'id_auteur' => $desc['id_auteur'] |
|
| 181 | + ]; |
|
| 182 | + |
|
| 183 | + // Si on demande à rediriger juste après validation du formulaire |
|
| 184 | + if ($retour) { |
|
| 185 | + $retours['redirect'] = $retour; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + return $retours; |
|
| 189 | + } |
|
| 190 | 190 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $row = sql_fetsel( |
| 109 | 109 | 'statut, id_auteur, login, email', |
| 110 | 110 | 'spip_auteurs', |
| 111 | - 'email=' . sql_quote($declaration['email']) |
|
| 111 | + 'email='.sql_quote($declaration['email']) |
|
| 112 | 112 | ) |
| 113 | 113 | ) { |
| 114 | 114 | if ($row['statut'] == '5poubelle' && empty($declaration['pass'])) { |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | - spip_logger()->info($row['id_auteur'] . ' veut se resinscrire'); |
|
| 127 | + spip_logger()->info($row['id_auteur'].' veut se resinscrire'); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -10,31 +10,31 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('base/abstract_sql'); |
| 17 | 17 | |
| 18 | 18 | function retrouve_auteur($id_auteur, $jeton = '') { |
| 19 | - if ($id_auteur = (int) $id_auteur) { |
|
| 20 | - return sql_fetsel( |
|
| 21 | - '*', |
|
| 22 | - 'spip_auteurs', |
|
| 23 | - ['id_auteur=' . (int) $id_auteur, "statut<>'5poubelle'", "pass<>''", "login<>''"] |
|
| 24 | - ); |
|
| 25 | - } elseif ($jeton) { |
|
| 26 | - include_spip('action/inscrire_auteur'); |
|
| 27 | - if ( |
|
| 28 | - ($auteur = auteur_verifier_jeton($jeton)) |
|
| 29 | - && $auteur['statut'] != '5poubelle' |
|
| 30 | - && $auteur['pass'] != '' |
|
| 31 | - && $auteur['login'] != '' |
|
| 32 | - ) { |
|
| 33 | - return $auteur; |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - return false; |
|
| 19 | + if ($id_auteur = (int) $id_auteur) { |
|
| 20 | + return sql_fetsel( |
|
| 21 | + '*', |
|
| 22 | + 'spip_auteurs', |
|
| 23 | + ['id_auteur=' . (int) $id_auteur, "statut<>'5poubelle'", "pass<>''", "login<>''"] |
|
| 24 | + ); |
|
| 25 | + } elseif ($jeton) { |
|
| 26 | + include_spip('action/inscrire_auteur'); |
|
| 27 | + if ( |
|
| 28 | + ($auteur = auteur_verifier_jeton($jeton)) |
|
| 29 | + && $auteur['statut'] != '5poubelle' |
|
| 30 | + && $auteur['pass'] != '' |
|
| 31 | + && $auteur['login'] != '' |
|
| 32 | + ) { |
|
| 33 | + return $auteur; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + return false; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // chargement des valeurs par defaut des champs du formulaire |
@@ -49,30 +49,30 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | function formulaires_mot_de_passe_charger_dist($id_auteur = null, $jeton = null) { |
| 51 | 51 | |
| 52 | - $valeurs = []; |
|
| 53 | - // compatibilite anciens appels du formulaire |
|
| 54 | - if (is_null($jeton)) { |
|
| 55 | - $jeton = _request('p'); |
|
| 56 | - } |
|
| 57 | - $auteur = retrouve_auteur($id_auteur, $jeton); |
|
| 58 | - |
|
| 59 | - if ($auteur) { |
|
| 60 | - $valeurs['id_auteur'] = $id_auteur; // a toutes fins utiles pour le formulaire |
|
| 61 | - if ($jeton) { |
|
| 62 | - $valeurs['_hidden'] = '<input type="hidden" name="p" value="' . $jeton . '" />'; |
|
| 63 | - } |
|
| 64 | - } else { |
|
| 65 | - $valeurs['message_erreur'] = _T('pass_erreur_code_inconnu'); |
|
| 66 | - $valeurs['editable'] = false; // pas de saisie |
|
| 67 | - } |
|
| 68 | - $valeurs['oubli'] = ''; |
|
| 69 | - // le champ login n'est pas utilise, mais il est destine aux navigateurs smarts |
|
| 70 | - // qui veulent remplir le formulaire avec login/mot de passe |
|
| 71 | - // et qui sinon remplissent le champ nobot (autocomplete=off n'est pas une option, certains navigateurs l'ignorant) |
|
| 72 | - $valeurs['login'] = ''; |
|
| 73 | - $valeurs['nobot'] = ''; |
|
| 74 | - |
|
| 75 | - return $valeurs; |
|
| 52 | + $valeurs = []; |
|
| 53 | + // compatibilite anciens appels du formulaire |
|
| 54 | + if (is_null($jeton)) { |
|
| 55 | + $jeton = _request('p'); |
|
| 56 | + } |
|
| 57 | + $auteur = retrouve_auteur($id_auteur, $jeton); |
|
| 58 | + |
|
| 59 | + if ($auteur) { |
|
| 60 | + $valeurs['id_auteur'] = $id_auteur; // a toutes fins utiles pour le formulaire |
|
| 61 | + if ($jeton) { |
|
| 62 | + $valeurs['_hidden'] = '<input type="hidden" name="p" value="' . $jeton . '" />'; |
|
| 63 | + } |
|
| 64 | + } else { |
|
| 65 | + $valeurs['message_erreur'] = _T('pass_erreur_code_inconnu'); |
|
| 66 | + $valeurs['editable'] = false; // pas de saisie |
|
| 67 | + } |
|
| 68 | + $valeurs['oubli'] = ''; |
|
| 69 | + // le champ login n'est pas utilise, mais il est destine aux navigateurs smarts |
|
| 70 | + // qui veulent remplir le formulaire avec login/mot de passe |
|
| 71 | + // et qui sinon remplissent le champ nobot (autocomplete=off n'est pas une option, certains navigateurs l'ignorant) |
|
| 72 | + $valeurs['login'] = ''; |
|
| 73 | + $valeurs['nobot'] = ''; |
|
| 74 | + |
|
| 75 | + return $valeurs; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -83,36 +83,36 @@ discard block |
||
| 83 | 83 | * @param int $id_auteur |
| 84 | 84 | */ |
| 85 | 85 | function formulaires_mot_de_passe_verifier_dist($id_auteur = null, $jeton = null) { |
| 86 | - $erreurs = []; |
|
| 87 | - if (!_request('oubli')) { |
|
| 88 | - $erreurs['oubli'] = _T('info_obligatoire'); |
|
| 89 | - } else { |
|
| 90 | - if (strlen((string) ($p = _request('oubli'))) < _PASS_LONGUEUR_MINI) { |
|
| 91 | - $erreurs['oubli'] = _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]); |
|
| 92 | - } else { |
|
| 93 | - if (!is_null($c = _request('oubli_confirm'))) { |
|
| 94 | - if (!$c) { |
|
| 95 | - $erreurs['oubli_confirm'] = _T('info_obligatoire'); |
|
| 96 | - } elseif ($c !== $p) { |
|
| 97 | - $erreurs['oubli'] = _T('info_passes_identiques'); |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - if (isset($erreurs['oubli'])) { |
|
| 103 | - set_request('oubli'); |
|
| 104 | - set_request('oubli_confirm'); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if (_request('nobot')) { |
|
| 108 | - $erreurs['message_erreur'] = _T('pass_rien_a_faire_ici'); |
|
| 109 | - } |
|
| 110 | - // precaution |
|
| 111 | - if (_request('login')) { |
|
| 112 | - set_request('login'); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - return $erreurs; |
|
| 86 | + $erreurs = []; |
|
| 87 | + if (!_request('oubli')) { |
|
| 88 | + $erreurs['oubli'] = _T('info_obligatoire'); |
|
| 89 | + } else { |
|
| 90 | + if (strlen((string) ($p = _request('oubli'))) < _PASS_LONGUEUR_MINI) { |
|
| 91 | + $erreurs['oubli'] = _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]); |
|
| 92 | + } else { |
|
| 93 | + if (!is_null($c = _request('oubli_confirm'))) { |
|
| 94 | + if (!$c) { |
|
| 95 | + $erreurs['oubli_confirm'] = _T('info_obligatoire'); |
|
| 96 | + } elseif ($c !== $p) { |
|
| 97 | + $erreurs['oubli'] = _T('info_passes_identiques'); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + if (isset($erreurs['oubli'])) { |
|
| 103 | + set_request('oubli'); |
|
| 104 | + set_request('oubli_confirm'); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if (_request('nobot')) { |
|
| 108 | + $erreurs['message_erreur'] = _T('pass_rien_a_faire_ici'); |
|
| 109 | + } |
|
| 110 | + // precaution |
|
| 111 | + if (_request('login')) { |
|
| 112 | + set_request('login'); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + return $erreurs; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -122,61 +122,61 @@ discard block |
||
| 122 | 122 | * @param int $id_auteur |
| 123 | 123 | */ |
| 124 | 124 | function formulaires_mot_de_passe_traiter_dist($id_auteur = null, $jeton = null) { |
| 125 | - $res = ['message_ok' => '']; |
|
| 126 | - refuser_traiter_formulaire_ajax(); // puisqu'on va loger l'auteur a la volee (c'est bonus) |
|
| 127 | - |
|
| 128 | - // compatibilite anciens appels du formulaire |
|
| 129 | - if (is_null($jeton)) { |
|
| 130 | - $jeton = _request('p'); |
|
| 131 | - } |
|
| 132 | - $row = retrouve_auteur($id_auteur, $jeton); |
|
| 133 | - |
|
| 134 | - if ( |
|
| 135 | - $row |
|
| 136 | - && ($id_auteur = $row['id_auteur']) |
|
| 137 | - && ($oubli = _request('oubli')) |
|
| 138 | - ) { |
|
| 139 | - include_spip('action/editer_auteur'); |
|
| 140 | - include_spip('action/inscrire_auteur'); |
|
| 141 | - if ($err = auteur_modifier($id_auteur, ['pass' => $oubli])) { |
|
| 142 | - $res = ['message_erreur' => $err]; |
|
| 143 | - } else { |
|
| 144 | - auteur_effacer_jeton($id_auteur); |
|
| 145 | - |
|
| 146 | - // Par défaut, on rappelle de s'identifier avec son email s'il existe |
|
| 147 | - // et qu'il n'est PAS utilisé par quelqu'un d'autre |
|
| 148 | - if ( |
|
| 149 | - $row['email'] && !sql_fetsel( |
|
| 150 | - 'id_auteur', |
|
| 151 | - 'spip_auteurs', |
|
| 152 | - [ |
|
| 153 | - '(email=' . sql_quote($row['email']) . ' or login=' . sql_quote($row['email']) . ')', |
|
| 154 | - 'id_auteur != ' . $id_auteur |
|
| 155 | - ], |
|
| 156 | - '', |
|
| 157 | - '', |
|
| 158 | - '0,1' |
|
| 159 | - ) |
|
| 160 | - ) { |
|
| 161 | - $identifiant = $row['email']; |
|
| 162 | - } |
|
| 163 | - // Sinon on dit d'utiliser le login |
|
| 164 | - else { |
|
| 165 | - $identifiant = $row['login']; |
|
| 166 | - } |
|
| 167 | - $res['message_ok'] = '<b>' . _T('pass_nouveau_enregistre') . '</b>' . |
|
| 168 | - '<br />' . _T('pass_rappel_login', ['login' => $identifiant]); |
|
| 169 | - |
|
| 170 | - include_spip('inc/auth'); |
|
| 171 | - $auth = auth_identifier_login($row['login'], $oubli); |
|
| 172 | - if (!is_array($auth)) { |
|
| 173 | - spip_logger()->error('Erreur identification ' . $row['login'] . " après changement de mot de passe: $auth"); |
|
| 174 | - } |
|
| 175 | - elseif ($auth['id_auteur'] == $id_auteur) { |
|
| 176 | - auth_loger($auth); |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - return $res; |
|
| 125 | + $res = ['message_ok' => '']; |
|
| 126 | + refuser_traiter_formulaire_ajax(); // puisqu'on va loger l'auteur a la volee (c'est bonus) |
|
| 127 | + |
|
| 128 | + // compatibilite anciens appels du formulaire |
|
| 129 | + if (is_null($jeton)) { |
|
| 130 | + $jeton = _request('p'); |
|
| 131 | + } |
|
| 132 | + $row = retrouve_auteur($id_auteur, $jeton); |
|
| 133 | + |
|
| 134 | + if ( |
|
| 135 | + $row |
|
| 136 | + && ($id_auteur = $row['id_auteur']) |
|
| 137 | + && ($oubli = _request('oubli')) |
|
| 138 | + ) { |
|
| 139 | + include_spip('action/editer_auteur'); |
|
| 140 | + include_spip('action/inscrire_auteur'); |
|
| 141 | + if ($err = auteur_modifier($id_auteur, ['pass' => $oubli])) { |
|
| 142 | + $res = ['message_erreur' => $err]; |
|
| 143 | + } else { |
|
| 144 | + auteur_effacer_jeton($id_auteur); |
|
| 145 | + |
|
| 146 | + // Par défaut, on rappelle de s'identifier avec son email s'il existe |
|
| 147 | + // et qu'il n'est PAS utilisé par quelqu'un d'autre |
|
| 148 | + if ( |
|
| 149 | + $row['email'] && !sql_fetsel( |
|
| 150 | + 'id_auteur', |
|
| 151 | + 'spip_auteurs', |
|
| 152 | + [ |
|
| 153 | + '(email=' . sql_quote($row['email']) . ' or login=' . sql_quote($row['email']) . ')', |
|
| 154 | + 'id_auteur != ' . $id_auteur |
|
| 155 | + ], |
|
| 156 | + '', |
|
| 157 | + '', |
|
| 158 | + '0,1' |
|
| 159 | + ) |
|
| 160 | + ) { |
|
| 161 | + $identifiant = $row['email']; |
|
| 162 | + } |
|
| 163 | + // Sinon on dit d'utiliser le login |
|
| 164 | + else { |
|
| 165 | + $identifiant = $row['login']; |
|
| 166 | + } |
|
| 167 | + $res['message_ok'] = '<b>' . _T('pass_nouveau_enregistre') . '</b>' . |
|
| 168 | + '<br />' . _T('pass_rappel_login', ['login' => $identifiant]); |
|
| 169 | + |
|
| 170 | + include_spip('inc/auth'); |
|
| 171 | + $auth = auth_identifier_login($row['login'], $oubli); |
|
| 172 | + if (!is_array($auth)) { |
|
| 173 | + spip_logger()->error('Erreur identification ' . $row['login'] . " après changement de mot de passe: $auth"); |
|
| 174 | + } |
|
| 175 | + elseif ($auth['id_auteur'] == $id_auteur) { |
|
| 176 | + auth_loger($auth); |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + return $res; |
|
| 182 | 182 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | return sql_fetsel( |
| 21 | 21 | '*', |
| 22 | 22 | 'spip_auteurs', |
| 23 | - ['id_auteur=' . (int) $id_auteur, "statut<>'5poubelle'", "pass<>''", "login<>''"] |
|
| 23 | + ['id_auteur='.(int) $id_auteur, "statut<>'5poubelle'", "pass<>''", "login<>''"] |
|
| 24 | 24 | ); |
| 25 | 25 | } elseif ($jeton) { |
| 26 | 26 | include_spip('action/inscrire_auteur'); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if ($auteur) { |
| 60 | 60 | $valeurs['id_auteur'] = $id_auteur; // a toutes fins utiles pour le formulaire |
| 61 | 61 | if ($jeton) { |
| 62 | - $valeurs['_hidden'] = '<input type="hidden" name="p" value="' . $jeton . '" />'; |
|
| 62 | + $valeurs['_hidden'] = '<input type="hidden" name="p" value="'.$jeton.'" />'; |
|
| 63 | 63 | } |
| 64 | 64 | } else { |
| 65 | 65 | $valeurs['message_erreur'] = _T('pass_erreur_code_inconnu'); |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | 'id_auteur', |
| 151 | 151 | 'spip_auteurs', |
| 152 | 152 | [ |
| 153 | - '(email=' . sql_quote($row['email']) . ' or login=' . sql_quote($row['email']) . ')', |
|
| 154 | - 'id_auteur != ' . $id_auteur |
|
| 153 | + '(email='.sql_quote($row['email']).' or login='.sql_quote($row['email']).')', |
|
| 154 | + 'id_auteur != '.$id_auteur |
|
| 155 | 155 | ], |
| 156 | 156 | '', |
| 157 | 157 | '', |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | else { |
| 165 | 165 | $identifiant = $row['login']; |
| 166 | 166 | } |
| 167 | - $res['message_ok'] = '<b>' . _T('pass_nouveau_enregistre') . '</b>' . |
|
| 168 | - '<br />' . _T('pass_rappel_login', ['login' => $identifiant]); |
|
| 167 | + $res['message_ok'] = '<b>'._T('pass_nouveau_enregistre').'</b>'. |
|
| 168 | + '<br />'._T('pass_rappel_login', ['login' => $identifiant]); |
|
| 169 | 169 | |
| 170 | 170 | include_spip('inc/auth'); |
| 171 | 171 | $auth = auth_identifier_login($row['login'], $oubli); |
| 172 | 172 | if (!is_array($auth)) { |
| 173 | - spip_logger()->error('Erreur identification ' . $row['login'] . " après changement de mot de passe: $auth"); |
|
| 173 | + spip_logger()->error('Erreur identification '.$row['login']." après changement de mot de passe: $auth"); |
|
| 174 | 174 | } |
| 175 | 175 | elseif ($auth['id_auteur'] == $id_auteur) { |
| 176 | 176 | auth_loger($auth); |
@@ -171,8 +171,7 @@ |
||
| 171 | 171 | $auth = auth_identifier_login($row['login'], $oubli); |
| 172 | 172 | if (!is_array($auth)) { |
| 173 | 173 | spip_logger()->error('Erreur identification ' . $row['login'] . " après changement de mot de passe: $auth"); |
| 174 | - } |
|
| 175 | - elseif ($auth['id_auteur'] == $id_auteur) { |
|
| 174 | + } elseif ($auth['id_auteur'] == $id_auteur) { |
|
| 176 | 175 | auth_loger($auth); |
| 177 | 176 | } |
| 178 | 177 | } |
@@ -10,98 +10,98 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // chargement des valeurs par defaut des champs du formulaire |
| 17 | 17 | function formulaires_oubli_charger_dist() { |
| 18 | - return ['oubli' => '', 'nobot' => '']; |
|
| 18 | + return ['oubli' => '', 'nobot' => '']; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | // https://code.spip.net/@message_oubli |
| 22 | 22 | function message_oubli($email, $param) { |
| 23 | - $r = formulaires_oubli_mail($email); |
|
| 24 | - |
|
| 25 | - if (is_array($r) && $r[1] && $r[1]['statut'] !== '5poubelle' && $r[1]['pass'] !== '') { |
|
| 26 | - include_spip('inc/texte'); # pour corriger_typo |
|
| 27 | - |
|
| 28 | - include_spip('action/inscrire_auteur'); |
|
| 29 | - $cookie = auteur_attribuer_jeton($r[1]['id_auteur']); |
|
| 30 | - |
|
| 31 | - // l'url_reset doit etre une URL de confiance, on force donc un url_absolue sur adresse_site |
|
| 32 | - include_spip('inc/filtres'); |
|
| 33 | - $msg = recuperer_fond( |
|
| 34 | - 'modeles/mail_oubli', |
|
| 35 | - [ |
|
| 36 | - 'url_reset' => url_absolue( |
|
| 37 | - generer_url_public('spip_pass', "$param=$cookie"), |
|
| 38 | - $GLOBALS['meta']['adresse_site'] . '/' |
|
| 39 | - ) |
|
| 40 | - ] |
|
| 41 | - ); |
|
| 42 | - include_spip('inc/notifications'); |
|
| 43 | - notifications_envoyer_mails($email, $msg); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - return _T('pass_recevoir_mail'); |
|
| 23 | + $r = formulaires_oubli_mail($email); |
|
| 24 | + |
|
| 25 | + if (is_array($r) && $r[1] && $r[1]['statut'] !== '5poubelle' && $r[1]['pass'] !== '') { |
|
| 26 | + include_spip('inc/texte'); # pour corriger_typo |
|
| 27 | + |
|
| 28 | + include_spip('action/inscrire_auteur'); |
|
| 29 | + $cookie = auteur_attribuer_jeton($r[1]['id_auteur']); |
|
| 30 | + |
|
| 31 | + // l'url_reset doit etre une URL de confiance, on force donc un url_absolue sur adresse_site |
|
| 32 | + include_spip('inc/filtres'); |
|
| 33 | + $msg = recuperer_fond( |
|
| 34 | + 'modeles/mail_oubli', |
|
| 35 | + [ |
|
| 36 | + 'url_reset' => url_absolue( |
|
| 37 | + generer_url_public('spip_pass', "$param=$cookie"), |
|
| 38 | + $GLOBALS['meta']['adresse_site'] . '/' |
|
| 39 | + ) |
|
| 40 | + ] |
|
| 41 | + ); |
|
| 42 | + include_spip('inc/notifications'); |
|
| 43 | + notifications_envoyer_mails($email, $msg); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + return _T('pass_recevoir_mail'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // la saisie a ete validee, on peut agir |
| 50 | 50 | function formulaires_oubli_traiter_dist() { |
| 51 | 51 | |
| 52 | - $message = message_oubli(_request('oubli'), 'p'); |
|
| 52 | + $message = message_oubli(_request('oubli'), 'p'); |
|
| 53 | 53 | |
| 54 | - return ['message_ok' => $message]; |
|
| 54 | + return ['message_ok' => $message]; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | // fonction qu'on peut redefinir pour filtrer les adresses mail |
| 59 | 59 | // https://code.spip.net/@test_oubli |
| 60 | 60 | function test_oubli_dist($email) { |
| 61 | - include_spip('inc/filtres'); # pour email_valide() |
|
| 62 | - if (!email_valide($email)) { |
|
| 63 | - return _T('pass_erreur_non_valide', ['email_oubli' => spip_htmlspecialchars($email)]); |
|
| 64 | - } |
|
| 61 | + include_spip('inc/filtres'); # pour email_valide() |
|
| 62 | + if (!email_valide($email)) { |
|
| 63 | + return _T('pass_erreur_non_valide', ['email_oubli' => spip_htmlspecialchars($email)]); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return ['mail' => $email]; |
|
| 66 | + return ['mail' => $email]; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | function formulaires_oubli_verifier_dist() { |
| 70 | - $erreurs = []; |
|
| 70 | + $erreurs = []; |
|
| 71 | 71 | |
| 72 | - $email = (string) _request('oubli'); |
|
| 72 | + $email = (string) _request('oubli'); |
|
| 73 | 73 | |
| 74 | - $r = formulaires_oubli_mail($email); |
|
| 74 | + $r = formulaires_oubli_mail($email); |
|
| 75 | 75 | |
| 76 | - if (!is_array($r)) { |
|
| 77 | - $erreurs['oubli'] = $r; |
|
| 78 | - } else { |
|
| 79 | - if (!$r[1]) { |
|
| 80 | - spip_logger('oubli')->info("demande de reinitialisation de mot de passe pour $email non enregistre sur le site"); |
|
| 81 | - } elseif ($r[1]['statut'] == '5poubelle' || $r[1]['pass'] == '') { |
|
| 82 | - spip_logger('oubli')->info("demande de reinitialisation de mot de passe pour $email sans acces (poubelle ou pass vide)"); |
|
| 83 | - } |
|
| 84 | - } |
|
| 76 | + if (!is_array($r)) { |
|
| 77 | + $erreurs['oubli'] = $r; |
|
| 78 | + } else { |
|
| 79 | + if (!$r[1]) { |
|
| 80 | + spip_logger('oubli')->info("demande de reinitialisation de mot de passe pour $email non enregistre sur le site"); |
|
| 81 | + } elseif ($r[1]['statut'] == '5poubelle' || $r[1]['pass'] == '') { |
|
| 82 | + spip_logger('oubli')->info("demande de reinitialisation de mot de passe pour $email sans acces (poubelle ou pass vide)"); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - if (_request('nobot')) { |
|
| 87 | - $erreurs['message_erreur'] = _T('pass_rien_a_faire_ici'); |
|
| 88 | - } |
|
| 86 | + if (_request('nobot')) { |
|
| 87 | + $erreurs['message_erreur'] = _T('pass_rien_a_faire_ici'); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - return $erreurs; |
|
| 90 | + return $erreurs; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | function formulaires_oubli_mail($email) { |
| 94 | - $f = function_exists('test_oubli') ? 'test_oubli' : 'test_oubli_dist'; |
|
| 95 | - $declaration = $f($email); |
|
| 96 | - |
|
| 97 | - if (!is_array($declaration)) { |
|
| 98 | - return $declaration; |
|
| 99 | - } else { |
|
| 100 | - include_spip('base/abstract_sql'); |
|
| 101 | - |
|
| 102 | - return [ |
|
| 103 | - $declaration, |
|
| 104 | - sql_fetsel('id_auteur,statut,pass', 'spip_auteurs', "login<>'' AND email =" . sql_quote($declaration['mail'])) |
|
| 105 | - ]; |
|
| 106 | - } |
|
| 94 | + $f = function_exists('test_oubli') ? 'test_oubli' : 'test_oubli_dist'; |
|
| 95 | + $declaration = $f($email); |
|
| 96 | + |
|
| 97 | + if (!is_array($declaration)) { |
|
| 98 | + return $declaration; |
|
| 99 | + } else { |
|
| 100 | + include_spip('base/abstract_sql'); |
|
| 101 | + |
|
| 102 | + return [ |
|
| 103 | + $declaration, |
|
| 104 | + sql_fetsel('id_auteur,statut,pass', 'spip_auteurs', "login<>'' AND email =" . sql_quote($declaration['mail'])) |
|
| 105 | + ]; |
|
| 106 | + } |
|
| 107 | 107 | } |
@@ -10,53 +10,53 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // Fonction appelee par divers pipelines |
| 17 | 17 | function notifications_instituerarticle_dist($quoi, $id_article, $options) { |
| 18 | 18 | |
| 19 | - // ne devrait jamais se produire |
|
| 20 | - if ($options['statut'] == $options['statut_ancien']) { |
|
| 21 | - spip_logger('notifications')->info('statut inchange'); |
|
| 22 | - |
|
| 23 | - return; |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - include_spip('inc/texte'); |
|
| 27 | - |
|
| 28 | - $modele = ''; |
|
| 29 | - if ($options['statut'] == 'publie') { |
|
| 30 | - if ( |
|
| 31 | - $GLOBALS['meta']['post_dates'] == 'non' |
|
| 32 | - && strtotime((string) $options['date']) > time() |
|
| 33 | - ) { |
|
| 34 | - $modele = 'notifications/article_valide'; |
|
| 35 | - } else { |
|
| 36 | - $modele = 'notifications/article_publie'; |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if ($options['statut'] == 'prop' && $options['statut_ancien'] != 'publie') { |
|
| 41 | - $modele = 'notifications/article_propose'; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - if ($modele) { |
|
| 45 | - $destinataires = []; |
|
| 46 | - if ($GLOBALS['meta']['suivi_edito'] == 'oui') { |
|
| 47 | - $destinataires = explode(',', (string) $GLOBALS['meta']['adresse_suivi']); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - $destinataires = pipeline( |
|
| 52 | - 'notifications_destinataires', |
|
| 53 | - [ |
|
| 54 | - 'args' => ['quoi' => $quoi, 'id' => $id_article, 'options' => $options], |
|
| 55 | - 'data' => $destinataires |
|
| 56 | - ] |
|
| 57 | - ); |
|
| 58 | - |
|
| 59 | - $texte = email_notification_article($id_article, $modele); |
|
| 60 | - notifications_envoyer_mails($destinataires, $texte); |
|
| 61 | - } |
|
| 19 | + // ne devrait jamais se produire |
|
| 20 | + if ($options['statut'] == $options['statut_ancien']) { |
|
| 21 | + spip_logger('notifications')->info('statut inchange'); |
|
| 22 | + |
|
| 23 | + return; |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + include_spip('inc/texte'); |
|
| 27 | + |
|
| 28 | + $modele = ''; |
|
| 29 | + if ($options['statut'] == 'publie') { |
|
| 30 | + if ( |
|
| 31 | + $GLOBALS['meta']['post_dates'] == 'non' |
|
| 32 | + && strtotime((string) $options['date']) > time() |
|
| 33 | + ) { |
|
| 34 | + $modele = 'notifications/article_valide'; |
|
| 35 | + } else { |
|
| 36 | + $modele = 'notifications/article_publie'; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if ($options['statut'] == 'prop' && $options['statut_ancien'] != 'publie') { |
|
| 41 | + $modele = 'notifications/article_propose'; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + if ($modele) { |
|
| 45 | + $destinataires = []; |
|
| 46 | + if ($GLOBALS['meta']['suivi_edito'] == 'oui') { |
|
| 47 | + $destinataires = explode(',', (string) $GLOBALS['meta']['adresse_suivi']); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + $destinataires = pipeline( |
|
| 52 | + 'notifications_destinataires', |
|
| 53 | + [ |
|
| 54 | + 'args' => ['quoi' => $quoi, 'id' => $id_article, 'options' => $options], |
|
| 55 | + 'data' => $destinataires |
|
| 56 | + ] |
|
| 57 | + ); |
|
| 58 | + |
|
| 59 | + $texte = email_notification_article($id_article, $modele); |
|
| 60 | + notifications_envoyer_mails($destinataires, $texte); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | include_spip('inc/headers'); |
@@ -21,61 +21,61 @@ discard block |
||
| 21 | 21 | // Mise en place des fichiers de configuration si ce n'est fait |
| 22 | 22 | |
| 23 | 23 | function install_etape_fin_dist() { |
| 24 | - ecrire_acces(); |
|
| 24 | + ecrire_acces(); |
|
| 25 | 25 | |
| 26 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CHMOD_TMP); |
|
| 27 | - if (file_exists(_FILE_CHMOD_TMP) && !@rename(_FILE_CHMOD_TMP, $f) && @copy(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | - spip_unlink(_FILE_CHMOD_TMP); |
|
| 29 | - } |
|
| 26 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CHMOD_TMP); |
|
| 27 | + if (file_exists(_FILE_CHMOD_TMP) && !@rename(_FILE_CHMOD_TMP, $f) && @copy(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | + spip_unlink(_FILE_CHMOD_TMP); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CONNECT_TMP); |
|
| 32 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 33 | - spip_logger()->info("renomme $f"); |
|
| 34 | - if (!@rename(_FILE_CONNECT_TMP, $f) && @copy(_FILE_CONNECT_TMP, $f)) { |
|
| 35 | - @spip_unlink(_FILE_CONNECT_TMP); |
|
| 36 | - } |
|
| 37 | - } |
|
| 31 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CONNECT_TMP); |
|
| 32 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 33 | + spip_logger()->info("renomme $f"); |
|
| 34 | + if (!@rename(_FILE_CONNECT_TMP, $f) && @copy(_FILE_CONNECT_TMP, $f)) { |
|
| 35 | + @spip_unlink(_FILE_CONNECT_TMP); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - // creer le repertoire cache, qui sert partout ! |
|
| 40 | - // deja fait en etape 4 en principe, on garde au cas ou |
|
| 41 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 42 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 43 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 44 | - } |
|
| 39 | + // creer le repertoire cache, qui sert partout ! |
|
| 40 | + // deja fait en etape 4 en principe, on garde au cas ou |
|
| 41 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 42 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 43 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // Verifier la securite des htaccess |
|
| 47 | - // Si elle ne fonctionne pas, prevenir |
|
| 48 | - $msg = install_verifier_htaccess(); |
|
| 49 | - if ($msg) { |
|
| 50 | - $cible = _T('public:accueil_site'); |
|
| 51 | - $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 52 | - $minipage = new Installation(); |
|
| 53 | - echo $minipage->page($msg . $cible); |
|
| 54 | - // ok, deboucher dans l'espace prive |
|
| 55 | - } else { |
|
| 56 | - redirige_url_ecrire('accueil'); |
|
| 57 | - } |
|
| 46 | + // Verifier la securite des htaccess |
|
| 47 | + // Si elle ne fonctionne pas, prevenir |
|
| 48 | + $msg = install_verifier_htaccess(); |
|
| 49 | + if ($msg) { |
|
| 50 | + $cible = _T('public:accueil_site'); |
|
| 51 | + $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 52 | + $minipage = new Installation(); |
|
| 53 | + echo $minipage->page($msg . $cible); |
|
| 54 | + // ok, deboucher dans l'espace prive |
|
| 55 | + } else { |
|
| 56 | + redirige_url_ecrire('accueil'); |
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function install_verifier_htaccess() { |
| 61 | - if ( |
|
| 62 | - verifier_htaccess(_DIR_TMP, true) |
|
| 63 | - && verifier_htaccess(_DIR_CONNECT, true) |
|
| 64 | - && verifier_htaccess(_DIR_VENDOR, true) |
|
| 65 | - ) { |
|
| 66 | - return ''; |
|
| 67 | - } |
|
| 61 | + if ( |
|
| 62 | + verifier_htaccess(_DIR_TMP, true) |
|
| 63 | + && verifier_htaccess(_DIR_CONNECT, true) |
|
| 64 | + && verifier_htaccess(_DIR_VENDOR, true) |
|
| 65 | + ) { |
|
| 66 | + return ''; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $titre = _T('htaccess_inoperant'); |
|
| 69 | + $titre = _T('htaccess_inoperant'); |
|
| 70 | 70 | |
| 71 | - $averti = _T( |
|
| 72 | - 'htaccess_a_simuler', |
|
| 73 | - [ |
|
| 74 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 75 | - 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 76 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 77 | - ] |
|
| 78 | - ); |
|
| 71 | + $averti = _T( |
|
| 72 | + 'htaccess_a_simuler', |
|
| 73 | + [ |
|
| 74 | + 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 75 | + 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 76 | + 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 77 | + ] |
|
| 78 | + ); |
|
| 79 | 79 | |
| 80 | - return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 80 | + return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 81 | 81 | } |
@@ -10,170 +10,170 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/headers'); |
| 17 | 17 | |
| 18 | 18 | function install_etape_3b_dist() { |
| 19 | - $auth_spip = null; |
|
| 20 | - $session = null; |
|
| 21 | - $row = null; |
|
| 22 | - $login = _request('login'); |
|
| 23 | - $email = _request('email'); |
|
| 24 | - $nom = _request('nom'); |
|
| 25 | - $pass = _request('pass'); |
|
| 26 | - $pass_verif = _request('pass_verif'); |
|
| 27 | - |
|
| 28 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 29 | - ? _INSTALL_SERVER_DB |
|
| 30 | - : _request('server_db'); |
|
| 31 | - |
|
| 32 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 33 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 34 | - } |
|
| 35 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 36 | - define('_LOGIN_TROP_COURT', 4); |
|
| 37 | - } |
|
| 38 | - if ($login) { |
|
| 39 | - $echec = ($pass != $pass_verif) ? |
|
| 40 | - _T('info_passes_identiques') |
|
| 41 | - : ((strlen((string) $pass) < _PASS_LONGUEUR_MINI) ? |
|
| 42 | - _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]) |
|
| 43 | - : ((strlen((string) $login) < _LOGIN_TROP_COURT) ? |
|
| 44 | - _T('info_login_trop_court') |
|
| 45 | - : '')); |
|
| 46 | - include_spip('inc/filtres'); |
|
| 47 | - if (!$echec && $email && !email_valide($email)) { |
|
| 48 | - $echec = _T('form_email_non_valide'); |
|
| 49 | - } |
|
| 50 | - if ($echec) { |
|
| 51 | - echouer_etape_3b($echec); |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - if (@file_exists(_FILE_CHMOD_TMP)) { |
|
| 56 | - include(_FILE_CHMOD_TMP); |
|
| 57 | - } else { |
|
| 58 | - redirige_url_ecrire('install'); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 62 | - redirige_url_ecrire('install'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - # maintenant on connait le vrai charset du site s'il est deja configure |
|
| 66 | - # sinon par defaut lire_meta reglera _DEFAULT_CHARSET |
|
| 67 | - # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET) |
|
| 68 | - |
|
| 69 | - lire_metas(); |
|
| 70 | - if ($login) { |
|
| 71 | - include_spip('inc/charsets'); |
|
| 72 | - |
|
| 73 | - $nom = (importer_charset($nom, _DEFAULT_CHARSET)); |
|
| 74 | - $login = (importer_charset($login, _DEFAULT_CHARSET)); |
|
| 75 | - $email = (importer_charset($email, _DEFAULT_CHARSET)); |
|
| 76 | - |
|
| 77 | - include_spip('auth/spip'); |
|
| 78 | - // prelablement, creer le champ webmestre si il n'existe pas (install neuve sur une vieille base) |
|
| 79 | - $t = sql_showtable('spip_auteurs', true); |
|
| 80 | - if (!isset($t['field']['webmestre'])) { |
|
| 81 | - @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"); |
|
| 82 | - } |
|
| 83 | - // prelablement, creer le champ backup_cles si il n'existe pas (install neuve sur une vieille base) |
|
| 84 | - if (!isset($t['field']['backup_cles'])) { |
|
| 85 | - @sql_alter("TABLE spip_auteurs ADD backup_cles mediumtext DEFAULT '' NOT NULL"); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - // il faut avoir une cle des auth valide pour creer un nouvel auteur webmestre |
|
| 89 | - $cles = \Spip\Chiffrer\SpipCles::instance(); |
|
| 90 | - $secret = $cles->getSecretAuth(); |
|
| 91 | - |
|
| 92 | - $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 93 | - if ($id_auteur !== null) { |
|
| 94 | - // c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe |
|
| 95 | - // pour restaurer la copie des cles |
|
| 96 | - if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 97 | - $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 98 | - if (empty($row['backup_cles']) || !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) { |
|
| 99 | - $echec = _T('avis_connexion_erreur_fichier_cle_manquant_1'); |
|
| 100 | - echouer_etape_3b($echec); |
|
| 101 | - } |
|
| 102 | - spip_logger('auth')->notice("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur"); |
|
| 103 | - $cles->save(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - sql_updateq('spip_auteurs', [ |
|
| 107 | - 'nom' => $nom, |
|
| 108 | - 'email' => $email, |
|
| 109 | - 'login' => $login, |
|
| 110 | - 'statut' => '0minirezo' |
|
| 111 | - ], 'id_auteur=' . (int) $id_auteur); |
|
| 112 | - // le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 113 | - @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 114 | - if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 115 | - $echec = _T('avis_erreur_creation_compte'); |
|
| 116 | - echouer_etape_3b($echec); |
|
| 117 | - } |
|
| 118 | - } else { |
|
| 119 | - // Si on a pas de cle et qu'on ne sait pas la creer, on ne peut pas creer de nouveau compte : |
|
| 120 | - // il faut qu'un webmestre avec un backup fasse l'install |
|
| 121 | - if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 122 | - $echec = _T('avis_connexion_erreur_fichier_cle_manquant_2'); |
|
| 123 | - echouer_etape_3b($echec); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $id_auteur = sql_insertq('spip_auteurs', [ |
|
| 127 | - 'nom' => $nom, |
|
| 128 | - 'email' => $email, |
|
| 129 | - 'login' => $login, |
|
| 130 | - 'statut' => '0minirezo' |
|
| 131 | - ]); |
|
| 132 | - // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 133 | - @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 134 | - if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 135 | - $echec = _T('avis_erreur_creation_compte'); |
|
| 136 | - echouer_etape_3b($echec); |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - // inserer email comme email webmaster principal |
|
| 141 | - // (sauf s'il est vide: cas de la re-installation) |
|
| 142 | - if ($email) { |
|
| 143 | - ecrire_meta('email_webmaster', $email); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - // Connecter directement celui qui vient de (re)donner son login |
|
| 147 | - // mais sans cookie d'admin ni connexion longue |
|
| 148 | - include_spip('inc/auth'); |
|
| 149 | - $auteur = auth_identifier_login($login, $pass); |
|
| 150 | - if (!$auteur || !auth_loger($auteur)) { |
|
| 151 | - $logger->info("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - // installer les metas |
|
| 156 | - $config = charger_fonction('config', 'inc'); |
|
| 157 | - $config(); |
|
| 158 | - |
|
| 159 | - // activer les plugins |
|
| 160 | - // leur installation ne peut pas se faire sur le meme hit, il faudra donc |
|
| 161 | - // poursuivre au hit suivant |
|
| 162 | - include_spip('inc/plugin'); |
|
| 163 | - actualise_plugins_actifs(); |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - include_spip('inc/distant'); |
|
| 167 | - redirige_par_entete(parametre_url(self(), 'etape', '4', '&')); |
|
| 19 | + $auth_spip = null; |
|
| 20 | + $session = null; |
|
| 21 | + $row = null; |
|
| 22 | + $login = _request('login'); |
|
| 23 | + $email = _request('email'); |
|
| 24 | + $nom = _request('nom'); |
|
| 25 | + $pass = _request('pass'); |
|
| 26 | + $pass_verif = _request('pass_verif'); |
|
| 27 | + |
|
| 28 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 29 | + ? _INSTALL_SERVER_DB |
|
| 30 | + : _request('server_db'); |
|
| 31 | + |
|
| 32 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 33 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 34 | + } |
|
| 35 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 36 | + define('_LOGIN_TROP_COURT', 4); |
|
| 37 | + } |
|
| 38 | + if ($login) { |
|
| 39 | + $echec = ($pass != $pass_verif) ? |
|
| 40 | + _T('info_passes_identiques') |
|
| 41 | + : ((strlen((string) $pass) < _PASS_LONGUEUR_MINI) ? |
|
| 42 | + _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]) |
|
| 43 | + : ((strlen((string) $login) < _LOGIN_TROP_COURT) ? |
|
| 44 | + _T('info_login_trop_court') |
|
| 45 | + : '')); |
|
| 46 | + include_spip('inc/filtres'); |
|
| 47 | + if (!$echec && $email && !email_valide($email)) { |
|
| 48 | + $echec = _T('form_email_non_valide'); |
|
| 49 | + } |
|
| 50 | + if ($echec) { |
|
| 51 | + echouer_etape_3b($echec); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + if (@file_exists(_FILE_CHMOD_TMP)) { |
|
| 56 | + include(_FILE_CHMOD_TMP); |
|
| 57 | + } else { |
|
| 58 | + redirige_url_ecrire('install'); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 62 | + redirige_url_ecrire('install'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + # maintenant on connait le vrai charset du site s'il est deja configure |
|
| 66 | + # sinon par defaut lire_meta reglera _DEFAULT_CHARSET |
|
| 67 | + # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET) |
|
| 68 | + |
|
| 69 | + lire_metas(); |
|
| 70 | + if ($login) { |
|
| 71 | + include_spip('inc/charsets'); |
|
| 72 | + |
|
| 73 | + $nom = (importer_charset($nom, _DEFAULT_CHARSET)); |
|
| 74 | + $login = (importer_charset($login, _DEFAULT_CHARSET)); |
|
| 75 | + $email = (importer_charset($email, _DEFAULT_CHARSET)); |
|
| 76 | + |
|
| 77 | + include_spip('auth/spip'); |
|
| 78 | + // prelablement, creer le champ webmestre si il n'existe pas (install neuve sur une vieille base) |
|
| 79 | + $t = sql_showtable('spip_auteurs', true); |
|
| 80 | + if (!isset($t['field']['webmestre'])) { |
|
| 81 | + @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"); |
|
| 82 | + } |
|
| 83 | + // prelablement, creer le champ backup_cles si il n'existe pas (install neuve sur une vieille base) |
|
| 84 | + if (!isset($t['field']['backup_cles'])) { |
|
| 85 | + @sql_alter("TABLE spip_auteurs ADD backup_cles mediumtext DEFAULT '' NOT NULL"); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + // il faut avoir une cle des auth valide pour creer un nouvel auteur webmestre |
|
| 89 | + $cles = \Spip\Chiffrer\SpipCles::instance(); |
|
| 90 | + $secret = $cles->getSecretAuth(); |
|
| 91 | + |
|
| 92 | + $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 93 | + if ($id_auteur !== null) { |
|
| 94 | + // c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe |
|
| 95 | + // pour restaurer la copie des cles |
|
| 96 | + if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 97 | + $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 98 | + if (empty($row['backup_cles']) || !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) { |
|
| 99 | + $echec = _T('avis_connexion_erreur_fichier_cle_manquant_1'); |
|
| 100 | + echouer_etape_3b($echec); |
|
| 101 | + } |
|
| 102 | + spip_logger('auth')->notice("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur"); |
|
| 103 | + $cles->save(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + sql_updateq('spip_auteurs', [ |
|
| 107 | + 'nom' => $nom, |
|
| 108 | + 'email' => $email, |
|
| 109 | + 'login' => $login, |
|
| 110 | + 'statut' => '0minirezo' |
|
| 111 | + ], 'id_auteur=' . (int) $id_auteur); |
|
| 112 | + // le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 113 | + @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 114 | + if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 115 | + $echec = _T('avis_erreur_creation_compte'); |
|
| 116 | + echouer_etape_3b($echec); |
|
| 117 | + } |
|
| 118 | + } else { |
|
| 119 | + // Si on a pas de cle et qu'on ne sait pas la creer, on ne peut pas creer de nouveau compte : |
|
| 120 | + // il faut qu'un webmestre avec un backup fasse l'install |
|
| 121 | + if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 122 | + $echec = _T('avis_connexion_erreur_fichier_cle_manquant_2'); |
|
| 123 | + echouer_etape_3b($echec); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $id_auteur = sql_insertq('spip_auteurs', [ |
|
| 127 | + 'nom' => $nom, |
|
| 128 | + 'email' => $email, |
|
| 129 | + 'login' => $login, |
|
| 130 | + 'statut' => '0minirezo' |
|
| 131 | + ]); |
|
| 132 | + // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 133 | + @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 134 | + if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 135 | + $echec = _T('avis_erreur_creation_compte'); |
|
| 136 | + echouer_etape_3b($echec); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + // inserer email comme email webmaster principal |
|
| 141 | + // (sauf s'il est vide: cas de la re-installation) |
|
| 142 | + if ($email) { |
|
| 143 | + ecrire_meta('email_webmaster', $email); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + // Connecter directement celui qui vient de (re)donner son login |
|
| 147 | + // mais sans cookie d'admin ni connexion longue |
|
| 148 | + include_spip('inc/auth'); |
|
| 149 | + $auteur = auth_identifier_login($login, $pass); |
|
| 150 | + if (!$auteur || !auth_loger($auteur)) { |
|
| 151 | + $logger->info("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + // installer les metas |
|
| 156 | + $config = charger_fonction('config', 'inc'); |
|
| 157 | + $config(); |
|
| 158 | + |
|
| 159 | + // activer les plugins |
|
| 160 | + // leur installation ne peut pas se faire sur le meme hit, il faudra donc |
|
| 161 | + // poursuivre au hit suivant |
|
| 162 | + include_spip('inc/plugin'); |
|
| 163 | + actualise_plugins_actifs(); |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + include_spip('inc/distant'); |
|
| 167 | + redirige_par_entete(parametre_url(self(), 'etape', '4', '&')); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | function echouer_etape_3b($echec): never { |
| 171 | - echo minipres( |
|
| 172 | - 'AUTO', |
|
| 173 | - info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 174 | - "<div class='error'><h3>$echec</h3>\n" . |
|
| 175 | - '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 176 | - '</div>' |
|
| 177 | - ); |
|
| 178 | - exit; |
|
| 171 | + echo minipres( |
|
| 172 | + 'AUTO', |
|
| 173 | + info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 174 | + "<div class='error'><h3>$echec</h3>\n" . |
|
| 175 | + '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 176 | + '</div>' |
|
| 177 | + ); |
|
| 178 | + exit; |
|
| 179 | 179 | } |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | $cles = \Spip\Chiffrer\SpipCles::instance(); |
| 90 | 90 | $secret = $cles->getSecretAuth(); |
| 91 | 91 | |
| 92 | - $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 92 | + $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login='.sql_quote($login)); |
|
| 93 | 93 | if ($id_auteur !== null) { |
| 94 | 94 | // c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe |
| 95 | 95 | // pour restaurer la copie des cles |
| 96 | 96 | if (!$secret && !auth_spip_initialiser_secret()) { |
| 97 | - $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 97 | + $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur='.(int) $id_auteur); |
|
| 98 | 98 | if (empty($row['backup_cles']) || !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) { |
| 99 | 99 | $echec = _T('avis_connexion_erreur_fichier_cle_manquant_1'); |
| 100 | 100 | echouer_etape_3b($echec); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | 'email' => $email, |
| 109 | 109 | 'login' => $login, |
| 110 | 110 | 'statut' => '0minirezo' |
| 111 | - ], 'id_auteur=' . (int) $id_auteur); |
|
| 111 | + ], 'id_auteur='.(int) $id_auteur); |
|
| 112 | 112 | // le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne |
| 113 | 113 | @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
| 114 | 114 | if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | include_spip('inc/auth'); |
| 149 | 149 | $auteur = auth_identifier_login($login, $pass); |
| 150 | 150 | if (!$auteur || !auth_loger($auteur)) { |
| 151 | - $logger->info("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 151 | + $logger->info("login automatique impossible $auth_spip $session".(is_countable($row) ? count($row) : 0)); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | function echouer_etape_3b($echec): never { |
| 171 | 171 | echo minipres( |
| 172 | 172 | 'AUTO', |
| 173 | - info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 174 | - "<div class='error'><h3>$echec</h3>\n" . |
|
| 175 | - '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 173 | + info_progression_etape(3, 'etape_', 'install/', true). |
|
| 174 | + "<div class='error'><h3>$echec</h3>\n". |
|
| 175 | + '<p>'._T('avis_connexion_echec_2').'</p>'. |
|
| 176 | 176 | '</div>' |
| 177 | 177 | ); |
| 178 | 178 | exit; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | include_spip('inc/headers'); |
@@ -20,201 +20,201 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | function install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db) { |
| 22 | 22 | |
| 23 | - $logger = spip_logger(); |
|
| 24 | - |
|
| 25 | - // Prefix des tables : |
|
| 26 | - // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 27 | - // a partir de ce qui est envoye a l'installation |
|
| 28 | - if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 29 | - $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 30 | - ? $GLOBALS['table_prefix'] |
|
| 31 | - : preparer_prefixe_tables(_request('tprefix')); |
|
| 32 | - // S'il est vide on remet spip |
|
| 33 | - if (!$table_prefix) { |
|
| 34 | - $table_prefix = 'spip'; |
|
| 35 | - } |
|
| 36 | - } else { |
|
| 37 | - $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 41 | - [, $adresse_db, $port] = $r; |
|
| 42 | - } else { |
|
| 43 | - $port = ''; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - $GLOBALS['connexions'][$server_db] |
|
| 47 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 48 | - |
|
| 49 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 50 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 51 | - |
|
| 52 | - $fquery = sql_serveur('query', $server_db); |
|
| 53 | - if ($choix_db == 'new_spip') { |
|
| 54 | - $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 55 | - if (preg_match($re, (string) $sel_db)) { |
|
| 56 | - $ok = sql_create_base($sel_db, $server_db); |
|
| 57 | - if (!$ok) { |
|
| 58 | - $re = "Impossible de creer la base $re"; |
|
| 59 | - $logger->info($re); |
|
| 60 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 61 | - } |
|
| 62 | - } else { |
|
| 63 | - $re = "Le nom de la base doit correspondre a $re"; |
|
| 64 | - $logger->info($re); |
|
| 65 | - |
|
| 66 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 71 | - // un sql_mode |
|
| 72 | - install_mode_appel($server_db, false); |
|
| 73 | - $GLOBALS['connexions'][$server_db] |
|
| 74 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 75 | - |
|
| 76 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 77 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 78 | - |
|
| 79 | - // Completer le tableau decrivant la connexion |
|
| 80 | - |
|
| 81 | - $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 82 | - $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 83 | - |
|
| 84 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 85 | - if ($old) { |
|
| 86 | - $old = sql_fetch($old, $server_db); |
|
| 87 | - } |
|
| 88 | - if (!$old) { |
|
| 89 | - // Si possible, demander au serveur d'envoyer les textes |
|
| 90 | - // dans le codage std de SPIP, |
|
| 91 | - $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 92 | - |
|
| 93 | - if ($charset) { |
|
| 94 | - sql_set_charset($charset['charset'], $server_db); |
|
| 95 | - $GLOBALS['meta']['charset_sql_base'] = |
|
| 96 | - $charset['charset']; |
|
| 97 | - $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 98 | - $charset['collation']; |
|
| 99 | - $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 100 | - $charset['charset']; |
|
| 101 | - $charsetbase = $charset['charset']; |
|
| 102 | - } else { |
|
| 103 | - $logger->info(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 104 | - $charsetbase = 'standard'; |
|
| 105 | - } |
|
| 106 | - $logger->info("Creation des tables. Codage $charsetbase"); |
|
| 107 | - creer_base($server_db); // AT LAST |
|
| 108 | - // memoriser avec quel charset on l'a creee |
|
| 109 | - |
|
| 110 | - if ($charset) { |
|
| 111 | - $t = [ |
|
| 112 | - 'nom' => 'charset_sql_base', |
|
| 113 | - 'valeur' => $charset['charset'], |
|
| 114 | - 'impt' => 'non' |
|
| 115 | - ]; |
|
| 116 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 117 | - $t['nom'] = 'charset_collation_sql_base'; |
|
| 118 | - $t['valeur'] = $charset['collation']; |
|
| 119 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 120 | - $t['nom'] = 'charset_sql_connexion'; |
|
| 121 | - $t['valeur'] = $charset['charset']; |
|
| 122 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 123 | - } |
|
| 124 | - $t = [ |
|
| 125 | - 'nom' => 'version_installee', |
|
| 126 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 127 | - 'impt' => 'non' |
|
| 128 | - ]; |
|
| 129 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 130 | - $t['nom'] = 'nouvelle_install'; |
|
| 131 | - $t['valeur'] = 1; |
|
| 132 | - @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 133 | - // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 134 | - if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 135 | - @sql_insertq( |
|
| 136 | - 'spip_meta', |
|
| 137 | - ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 138 | - [], |
|
| 139 | - $server_db |
|
| 140 | - ); |
|
| 141 | - } |
|
| 142 | - } else { |
|
| 143 | - // pour recreer les tables disparues au besoin |
|
| 144 | - $logger->info('Table des Meta deja la. Verification des autres.'); |
|
| 145 | - creer_base($server_db); |
|
| 146 | - $fupdateq = sql_serveur('updateq', $server_db); |
|
| 147 | - |
|
| 148 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 149 | - |
|
| 150 | - if ($r) { |
|
| 151 | - $r = sql_fetch($r, $server_db); |
|
| 152 | - } |
|
| 153 | - $version_installee = $r ? (double)$r['valeur'] : 0; |
|
| 154 | - if (!$version_installee || $GLOBALS['spip_version_base'] < $version_installee) { |
|
| 155 | - $fupdateq( |
|
| 156 | - 'spip_meta', |
|
| 157 | - ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 158 | - "nom='version_installee'", |
|
| 159 | - '', |
|
| 160 | - $server_db |
|
| 161 | - ); |
|
| 162 | - $logger->info('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 163 | - } |
|
| 164 | - // eliminer la derniere operation d'admin mal terminee |
|
| 165 | - // notamment la mise a jour |
|
| 166 | - @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - // recuperer le charset de la connexion dans les meta |
|
| 170 | - $charset = ''; |
|
| 171 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 172 | - if ($r) { |
|
| 173 | - $r = sql_fetch($r, $server_db); |
|
| 174 | - } |
|
| 175 | - if ($r) { |
|
| 176 | - $charset = $r['valeur']; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - $ligne_rappel = install_mode_appel($server_db); |
|
| 180 | - |
|
| 181 | - $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 182 | - if (!$result_ok) { |
|
| 183 | - return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - if ($chmod_db) { |
|
| 187 | - install_fichier_connexion( |
|
| 188 | - _FILE_CHMOD_TMP, |
|
| 189 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 190 | - ); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - // si ce fichier existe a cette etape c'est qu'il provient |
|
| 194 | - // d'une installation qui ne l'a pas cree correctement. |
|
| 195 | - // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 196 | - |
|
| 197 | - if (_FILE_CONNECT && file_exists(_FILE_CONNECT)) { |
|
| 198 | - spip_unlink(_FILE_CONNECT); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - install_fichier_connexion( |
|
| 202 | - _FILE_CONNECT_TMP, |
|
| 203 | - $ligne_rappel |
|
| 204 | - . install_connexion( |
|
| 205 | - $adresse_db, |
|
| 206 | - $port, |
|
| 207 | - $login_db, |
|
| 208 | - $pass_db, |
|
| 209 | - $sel_db, |
|
| 210 | - $server_db, |
|
| 211 | - $table_prefix, |
|
| 212 | - '', |
|
| 213 | - $charset |
|
| 214 | - ) |
|
| 215 | - ); |
|
| 216 | - |
|
| 217 | - return ''; |
|
| 23 | + $logger = spip_logger(); |
|
| 24 | + |
|
| 25 | + // Prefix des tables : |
|
| 26 | + // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 27 | + // a partir de ce qui est envoye a l'installation |
|
| 28 | + if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 29 | + $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 30 | + ? $GLOBALS['table_prefix'] |
|
| 31 | + : preparer_prefixe_tables(_request('tprefix')); |
|
| 32 | + // S'il est vide on remet spip |
|
| 33 | + if (!$table_prefix) { |
|
| 34 | + $table_prefix = 'spip'; |
|
| 35 | + } |
|
| 36 | + } else { |
|
| 37 | + $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 41 | + [, $adresse_db, $port] = $r; |
|
| 42 | + } else { |
|
| 43 | + $port = ''; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + $GLOBALS['connexions'][$server_db] |
|
| 47 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 48 | + |
|
| 49 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 50 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 51 | + |
|
| 52 | + $fquery = sql_serveur('query', $server_db); |
|
| 53 | + if ($choix_db == 'new_spip') { |
|
| 54 | + $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 55 | + if (preg_match($re, (string) $sel_db)) { |
|
| 56 | + $ok = sql_create_base($sel_db, $server_db); |
|
| 57 | + if (!$ok) { |
|
| 58 | + $re = "Impossible de creer la base $re"; |
|
| 59 | + $logger->info($re); |
|
| 60 | + return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 61 | + } |
|
| 62 | + } else { |
|
| 63 | + $re = "Le nom de la base doit correspondre a $re"; |
|
| 64 | + $logger->info($re); |
|
| 65 | + |
|
| 66 | + return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 71 | + // un sql_mode |
|
| 72 | + install_mode_appel($server_db, false); |
|
| 73 | + $GLOBALS['connexions'][$server_db] |
|
| 74 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 75 | + |
|
| 76 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 77 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 78 | + |
|
| 79 | + // Completer le tableau decrivant la connexion |
|
| 80 | + |
|
| 81 | + $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 82 | + $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 83 | + |
|
| 84 | + $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 85 | + if ($old) { |
|
| 86 | + $old = sql_fetch($old, $server_db); |
|
| 87 | + } |
|
| 88 | + if (!$old) { |
|
| 89 | + // Si possible, demander au serveur d'envoyer les textes |
|
| 90 | + // dans le codage std de SPIP, |
|
| 91 | + $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 92 | + |
|
| 93 | + if ($charset) { |
|
| 94 | + sql_set_charset($charset['charset'], $server_db); |
|
| 95 | + $GLOBALS['meta']['charset_sql_base'] = |
|
| 96 | + $charset['charset']; |
|
| 97 | + $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 98 | + $charset['collation']; |
|
| 99 | + $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 100 | + $charset['charset']; |
|
| 101 | + $charsetbase = $charset['charset']; |
|
| 102 | + } else { |
|
| 103 | + $logger->info(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 104 | + $charsetbase = 'standard'; |
|
| 105 | + } |
|
| 106 | + $logger->info("Creation des tables. Codage $charsetbase"); |
|
| 107 | + creer_base($server_db); // AT LAST |
|
| 108 | + // memoriser avec quel charset on l'a creee |
|
| 109 | + |
|
| 110 | + if ($charset) { |
|
| 111 | + $t = [ |
|
| 112 | + 'nom' => 'charset_sql_base', |
|
| 113 | + 'valeur' => $charset['charset'], |
|
| 114 | + 'impt' => 'non' |
|
| 115 | + ]; |
|
| 116 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 117 | + $t['nom'] = 'charset_collation_sql_base'; |
|
| 118 | + $t['valeur'] = $charset['collation']; |
|
| 119 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 120 | + $t['nom'] = 'charset_sql_connexion'; |
|
| 121 | + $t['valeur'] = $charset['charset']; |
|
| 122 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 123 | + } |
|
| 124 | + $t = [ |
|
| 125 | + 'nom' => 'version_installee', |
|
| 126 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 127 | + 'impt' => 'non' |
|
| 128 | + ]; |
|
| 129 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 130 | + $t['nom'] = 'nouvelle_install'; |
|
| 131 | + $t['valeur'] = 1; |
|
| 132 | + @sql_insertq('spip_meta', $t, [], $server_db); |
|
| 133 | + // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 134 | + if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 135 | + @sql_insertq( |
|
| 136 | + 'spip_meta', |
|
| 137 | + ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 138 | + [], |
|
| 139 | + $server_db |
|
| 140 | + ); |
|
| 141 | + } |
|
| 142 | + } else { |
|
| 143 | + // pour recreer les tables disparues au besoin |
|
| 144 | + $logger->info('Table des Meta deja la. Verification des autres.'); |
|
| 145 | + creer_base($server_db); |
|
| 146 | + $fupdateq = sql_serveur('updateq', $server_db); |
|
| 147 | + |
|
| 148 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 149 | + |
|
| 150 | + if ($r) { |
|
| 151 | + $r = sql_fetch($r, $server_db); |
|
| 152 | + } |
|
| 153 | + $version_installee = $r ? (double)$r['valeur'] : 0; |
|
| 154 | + if (!$version_installee || $GLOBALS['spip_version_base'] < $version_installee) { |
|
| 155 | + $fupdateq( |
|
| 156 | + 'spip_meta', |
|
| 157 | + ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 158 | + "nom='version_installee'", |
|
| 159 | + '', |
|
| 160 | + $server_db |
|
| 161 | + ); |
|
| 162 | + $logger->info('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 163 | + } |
|
| 164 | + // eliminer la derniere operation d'admin mal terminee |
|
| 165 | + // notamment la mise a jour |
|
| 166 | + @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + // recuperer le charset de la connexion dans les meta |
|
| 170 | + $charset = ''; |
|
| 171 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 172 | + if ($r) { |
|
| 173 | + $r = sql_fetch($r, $server_db); |
|
| 174 | + } |
|
| 175 | + if ($r) { |
|
| 176 | + $charset = $r['valeur']; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + $ligne_rappel = install_mode_appel($server_db); |
|
| 180 | + |
|
| 181 | + $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 182 | + if (!$result_ok) { |
|
| 183 | + return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + if ($chmod_db) { |
|
| 187 | + install_fichier_connexion( |
|
| 188 | + _FILE_CHMOD_TMP, |
|
| 189 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 190 | + ); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + // si ce fichier existe a cette etape c'est qu'il provient |
|
| 194 | + // d'une installation qui ne l'a pas cree correctement. |
|
| 195 | + // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 196 | + |
|
| 197 | + if (_FILE_CONNECT && file_exists(_FILE_CONNECT)) { |
|
| 198 | + spip_unlink(_FILE_CONNECT); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + install_fichier_connexion( |
|
| 202 | + _FILE_CONNECT_TMP, |
|
| 203 | + $ligne_rappel |
|
| 204 | + . install_connexion( |
|
| 205 | + $adresse_db, |
|
| 206 | + $port, |
|
| 207 | + $login_db, |
|
| 208 | + $pass_db, |
|
| 209 | + $sel_db, |
|
| 210 | + $server_db, |
|
| 211 | + $table_prefix, |
|
| 212 | + '', |
|
| 213 | + $charset |
|
| 214 | + ) |
|
| 215 | + ); |
|
| 216 | + |
|
| 217 | + return ''; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -229,166 +229,166 @@ discard block |
||
| 229 | 229 | * @return string Le préfixe corrigé |
| 230 | 230 | */ |
| 231 | 231 | function preparer_prefixe_tables($prefixe) { |
| 232 | - return trim(preg_replace(',^\d+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 232 | + return trim(preg_replace(',^\d+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | function install_propose_ldap() { |
| 236 | - return generer_form_ecrire('install', ( |
|
| 237 | - fieldset( |
|
| 238 | - _T('info_authentification_externe'), |
|
| 239 | - [ |
|
| 240 | - 'etape' => [ |
|
| 241 | - 'label' => _T('texte_annuaire_ldap_1'), |
|
| 242 | - 'valeur' => 'ldap1', |
|
| 243 | - 'hidden' => true |
|
| 244 | - ] |
|
| 245 | - ], |
|
| 246 | - bouton_suivant(_T('bouton_acces_ldap')) |
|
| 247 | - ))); |
|
| 236 | + return generer_form_ecrire('install', ( |
|
| 237 | + fieldset( |
|
| 238 | + _T('info_authentification_externe'), |
|
| 239 | + [ |
|
| 240 | + 'etape' => [ |
|
| 241 | + 'label' => _T('texte_annuaire_ldap_1'), |
|
| 242 | + 'valeur' => 'ldap1', |
|
| 243 | + 'hidden' => true |
|
| 244 | + ] |
|
| 245 | + ], |
|
| 246 | + bouton_suivant(_T('bouton_acces_ldap')) |
|
| 247 | + ))); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | function install_premier_auteur($email, $login, $nom, #[\SensitiveParameter] $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 | function install_etape_3_dist() { |
| 312 | - $ldap_present = _request('ldap_present'); |
|
| 313 | - |
|
| 314 | - if (!$ldap_present) { |
|
| 315 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 316 | - ? _INSTALL_HOST_DB |
|
| 317 | - : _request('adresse_db'); |
|
| 318 | - |
|
| 319 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 320 | - ? _INSTALL_USER_DB |
|
| 321 | - : _request('login_db'); |
|
| 322 | - |
|
| 323 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 324 | - ? _INSTALL_PASS_DB |
|
| 325 | - : _request('pass_db'); |
|
| 326 | - |
|
| 327 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 328 | - ? _INSTALL_SERVER_DB |
|
| 329 | - : _request('server_db'); |
|
| 330 | - |
|
| 331 | - $chmod_db = defined('_SPIP_CHMOD') |
|
| 332 | - ? _SPIP_CHMOD |
|
| 333 | - : _request('chmod'); |
|
| 334 | - |
|
| 335 | - $choix_db = defined('_INSTALL_NAME_DB') |
|
| 336 | - ? _INSTALL_NAME_DB |
|
| 337 | - : _request('choix_db'); |
|
| 338 | - |
|
| 339 | - $sel_db = ($choix_db == 'new_spip') |
|
| 340 | - ? _request('table_new') : $choix_db; |
|
| 341 | - |
|
| 342 | - $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 343 | - |
|
| 344 | - if ($res) { |
|
| 345 | - $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 346 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 347 | - . $res |
|
| 348 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 349 | - . '</div>'; |
|
| 350 | - } |
|
| 351 | - } else { |
|
| 352 | - $res = ''; |
|
| 353 | - [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 354 | - $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - if (!$res) { |
|
| 358 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 359 | - include(_FILE_CONNECT_TMP); |
|
| 360 | - } else { |
|
| 361 | - redirige_url_ecrire('install'); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 365 | - include(_FILE_CHMOD_TMP); |
|
| 366 | - } else { |
|
| 367 | - redirige_url_ecrire('install'); |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 371 | - . (defined('_INSTALL_NAME_DB') ? '' |
|
| 372 | - : "\n<input type='hidden' name='sel_db' value=\"" . spip_htmlspecialchars($sel_db) . '" />'); |
|
| 373 | - |
|
| 374 | - $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 375 | - |
|
| 376 | - $res = "<div class='success'><b>" |
|
| 377 | - . _T('info_base_installee') |
|
| 378 | - . '</b></div>' |
|
| 379 | - . install_premier_auteur( |
|
| 380 | - _request('email'), |
|
| 381 | - _request('login'), |
|
| 382 | - _request('nom'), |
|
| 383 | - _request('pass'), |
|
| 384 | - $hidden, |
|
| 385 | - $auteur_obligatoire |
|
| 386 | - ) |
|
| 387 | - . (($ldap_present || !function_exists('ldap_connect')) |
|
| 388 | - ? '' : install_propose_ldap()); |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - |
|
| 392 | - $minipage = new Installation(); |
|
| 393 | - echo $minipage->page($res); |
|
| 312 | + $ldap_present = _request('ldap_present'); |
|
| 313 | + |
|
| 314 | + if (!$ldap_present) { |
|
| 315 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 316 | + ? _INSTALL_HOST_DB |
|
| 317 | + : _request('adresse_db'); |
|
| 318 | + |
|
| 319 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 320 | + ? _INSTALL_USER_DB |
|
| 321 | + : _request('login_db'); |
|
| 322 | + |
|
| 323 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 324 | + ? _INSTALL_PASS_DB |
|
| 325 | + : _request('pass_db'); |
|
| 326 | + |
|
| 327 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 328 | + ? _INSTALL_SERVER_DB |
|
| 329 | + : _request('server_db'); |
|
| 330 | + |
|
| 331 | + $chmod_db = defined('_SPIP_CHMOD') |
|
| 332 | + ? _SPIP_CHMOD |
|
| 333 | + : _request('chmod'); |
|
| 334 | + |
|
| 335 | + $choix_db = defined('_INSTALL_NAME_DB') |
|
| 336 | + ? _INSTALL_NAME_DB |
|
| 337 | + : _request('choix_db'); |
|
| 338 | + |
|
| 339 | + $sel_db = ($choix_db == 'new_spip') |
|
| 340 | + ? _request('table_new') : $choix_db; |
|
| 341 | + |
|
| 342 | + $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 343 | + |
|
| 344 | + if ($res) { |
|
| 345 | + $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 346 | + . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 347 | + . $res |
|
| 348 | + . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 349 | + . '</div>'; |
|
| 350 | + } |
|
| 351 | + } else { |
|
| 352 | + $res = ''; |
|
| 353 | + [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 354 | + $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + if (!$res) { |
|
| 358 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 359 | + include(_FILE_CONNECT_TMP); |
|
| 360 | + } else { |
|
| 361 | + redirige_url_ecrire('install'); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 365 | + include(_FILE_CHMOD_TMP); |
|
| 366 | + } else { |
|
| 367 | + redirige_url_ecrire('install'); |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 371 | + . (defined('_INSTALL_NAME_DB') ? '' |
|
| 372 | + : "\n<input type='hidden' name='sel_db' value=\"" . spip_htmlspecialchars($sel_db) . '" />'); |
|
| 373 | + |
|
| 374 | + $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 375 | + |
|
| 376 | + $res = "<div class='success'><b>" |
|
| 377 | + . _T('info_base_installee') |
|
| 378 | + . '</b></div>' |
|
| 379 | + . install_premier_auteur( |
|
| 380 | + _request('email'), |
|
| 381 | + _request('login'), |
|
| 382 | + _request('nom'), |
|
| 383 | + _request('pass'), |
|
| 384 | + $hidden, |
|
| 385 | + $auteur_obligatoire |
|
| 386 | + ) |
|
| 387 | + . (($ldap_present || !function_exists('ldap_connect')) |
|
| 388 | + ? '' : install_propose_ldap()); |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + |
|
| 392 | + $minipage = new Installation(); |
|
| 393 | + echo $minipage->page($res); |
|
| 394 | 394 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
| 48 | 48 | |
| 49 | 49 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 50 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 50 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 51 | 51 | |
| 52 | 52 | $fquery = sql_serveur('query', $server_db); |
| 53 | 53 | if ($choix_db == 'new_spip') { |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | if (!$ok) { |
| 58 | 58 | $re = "Impossible de creer la base $re"; |
| 59 | 59 | $logger->info($re); |
| 60 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 60 | + return '<p>'._T('avis_connexion_erreur_creer_base')."</p><!--\n$re\n-->"; |
|
| 61 | 61 | } |
| 62 | 62 | } else { |
| 63 | 63 | $re = "Le nom de la base doit correspondre a $re"; |
| 64 | 64 | $logger->info($re); |
| 65 | 65 | |
| 66 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 66 | + return '<p>'._T('avis_connexion_erreur_nom_base')."</p><!--\n$re\n-->"; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
| 75 | 75 | |
| 76 | 76 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 77 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 77 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 78 | 78 | |
| 79 | 79 | // Completer le tableau decrivant la connexion |
| 80 | 80 | |
| 81 | 81 | $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
| 82 | 82 | $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
| 83 | 83 | |
| 84 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 84 | + $old = sql_showbase($table_prefix.'_meta', $server_db); |
|
| 85 | 85 | if ($old) { |
| 86 | 86 | $old = sql_fetch($old, $server_db); |
| 87 | 87 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $charset['charset']; |
| 101 | 101 | $charsetbase = $charset['charset']; |
| 102 | 102 | } else { |
| 103 | - $logger->info(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 103 | + $logger->info(_DEFAULT_CHARSET.' inconnu du serveur SQL'); |
|
| 104 | 104 | $charsetbase = 'standard'; |
| 105 | 105 | } |
| 106 | 106 | $logger->info("Creation des tables. Codage $charsetbase"); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | if ($r) { |
| 151 | 151 | $r = sql_fetch($r, $server_db); |
| 152 | 152 | } |
| 153 | - $version_installee = $r ? (double)$r['valeur'] : 0; |
|
| 153 | + $version_installee = $r ? (double) $r['valeur'] : 0; |
|
| 154 | 154 | if (!$version_installee || $GLOBALS['spip_version_base'] < $version_installee) { |
| 155 | 155 | $fupdateq( |
| 156 | 156 | 'spip_meta', |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | '', |
| 160 | 160 | $server_db |
| 161 | 161 | ); |
| 162 | - $logger->info('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 162 | + $logger->info('nouvelle version installee: '.$GLOBALS['spip_version_base']); |
|
| 163 | 163 | } |
| 164 | 164 | // eliminer la derniere operation d'admin mal terminee |
| 165 | 165 | // notamment la mise a jour |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | if ($chmod_db) { |
| 187 | 187 | install_fichier_connexion( |
| 188 | 188 | _FILE_CHMOD_TMP, |
| 189 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 189 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', ".sprintf('0%3o', $chmod_db).");\n" |
|
| 190 | 190 | ); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -249,16 +249,16 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | function install_premier_auteur($email, $login, $nom, #[\SensitiveParameter] $pass, $hidden, $auteur_obligatoire) { |
| 252 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 252 | + return info_progression_etape(3, 'etape_', 'install/'). |
|
| 253 | 253 | info_etape( |
| 254 | 254 | _T('info_informations_personnelles'), |
| 255 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 256 | - aider('install5', true) . |
|
| 257 | - '<p>' . |
|
| 255 | + '<b>'._T('texte_informations_personnelles_1').'</b>'. |
|
| 256 | + aider('install5', true). |
|
| 257 | + '<p>'. |
|
| 258 | 258 | ($auteur_obligatoire ? |
| 259 | 259 | '' |
| 260 | 260 | : |
| 261 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 261 | + _T('texte_informations_personnelles_2').' '._T('info_laisser_champs_vides') |
|
| 262 | 262 | ) |
| 263 | 263 | ) |
| 264 | 264 | . generer_form_ecrire('install', ( |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | _T('info_identification_publique'), |
| 269 | 269 | [ |
| 270 | 270 | 'nom' => [ |
| 271 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 271 | + 'label' => '<b>'._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n", |
|
| 272 | 272 | 'valeur' => $nom, |
| 273 | 273 | 'required' => $auteur_obligatoire, |
| 274 | 274 | ], |
| 275 | 275 | 'email' => [ |
| 276 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 276 | + 'label' => '<b>'._T('entree_adresse_email')."</b>\n", |
|
| 277 | 277 | 'valeur' => $email, |
| 278 | 278 | ] |
| 279 | 279 | ] |
@@ -283,23 +283,23 @@ discard block |
||
| 283 | 283 | _T('entree_identifiants_connexion'), |
| 284 | 284 | [ |
| 285 | 285 | 'login' => [ |
| 286 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 286 | + 'label' => '<b>'._T('entree_login')."</b><br />\n"._T( |
|
| 287 | 287 | 'info_login_trop_court_car_pluriel', |
| 288 | 288 | ['nb' => _LOGIN_TROP_COURT] |
| 289 | - ) . "\n", |
|
| 289 | + )."\n", |
|
| 290 | 290 | 'valeur' => $login, |
| 291 | 291 | 'required' => $auteur_obligatoire, |
| 292 | 292 | ], |
| 293 | 293 | 'pass' => [ |
| 294 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 294 | + 'label' => '<b>'._T('entree_mot_passe')."</b><br />\n"._T( |
|
| 295 | 295 | 'info_passe_trop_court_car_pluriel', |
| 296 | 296 | ['nb' => _PASS_LONGUEUR_MINI] |
| 297 | - ) . "\n", |
|
| 297 | + )."\n", |
|
| 298 | 298 | 'valeur' => $pass, |
| 299 | 299 | 'required' => $auteur_obligatoire, |
| 300 | 300 | ], |
| 301 | 301 | 'pass_verif' => [ |
| 302 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 302 | + 'label' => '<b>'._T('info_confirmer_passe')."</b><br />\n", |
|
| 303 | 303 | 'valeur' => $pass, |
| 304 | 304 | 'required' => $auteur_obligatoire, |
| 305 | 305 | ] |
@@ -343,9 +343,9 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | if ($res) { |
| 345 | 345 | $res = info_progression_etape(2, 'etape_', 'install/', true) |
| 346 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 346 | + . "<div class='error'><h3>"._T('avis_operation_echec').'</h3>' |
|
| 347 | 347 | . $res |
| 348 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 348 | + . '<p>'._T('texte_operation_echec').'</p>' |
|
| 349 | 349 | . '</div>'; |
| 350 | 350 | } |
| 351 | 351 | } else { |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
| 371 | 371 | . (defined('_INSTALL_NAME_DB') ? '' |
| 372 | - : "\n<input type='hidden' name='sel_db' value=\"" . spip_htmlspecialchars($sel_db) . '" />'); |
|
| 372 | + : "\n<input type='hidden' name='sel_db' value=\"".spip_htmlspecialchars($sel_db).'" />'); |
|
| 373 | 373 | |
| 374 | 374 | $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
| 375 | 375 | |
@@ -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 | /** |
@@ -53,92 +53,92 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function plugins_installer_dist($plug, $action, $dir_type = '_DIR_PLUGINS') { |
| 55 | 55 | |
| 56 | - // Charger les informations du XML du plugin et vérification de l'existence d'une installation |
|
| 57 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 58 | - $infos = $get_infos($plug, false, constant($dir_type)); |
|
| 59 | - if (!isset($infos['install']) || !$infos['install']) { |
|
| 60 | - return false; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // Passer en chemin absolu si possible, c'est plus efficace |
|
| 64 | - $dir = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 65 | - if (!defined($dir)) { |
|
| 66 | - $dir = $dir_type; |
|
| 67 | - } |
|
| 68 | - $dir = constant($dir); |
|
| 69 | - foreach ($infos['install'] as $file) { |
|
| 70 | - $file = $dir . $plug . '/' . trim((string) $file); |
|
| 71 | - if (file_exists($file)) { |
|
| 72 | - include_once($file); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // Détermination de la table meta et du nom de la meta plugin |
|
| 77 | - $table = 'meta'; |
|
| 78 | - if (isset($infos['meta']) && $infos['meta'] !== 'meta') { |
|
| 79 | - $table = $infos['meta']; |
|
| 80 | - // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
|
| 81 | - lire_metas($table); |
|
| 82 | - } |
|
| 83 | - $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 84 | - |
|
| 85 | - // Détermination de la fonction à appeler et de ses arguments |
|
| 86 | - $f = $infos['prefix'] . '_install'; |
|
| 87 | - if (!function_exists($f)) { |
|
| 88 | - $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
|
| 89 | - $arg = $infos; |
|
| 90 | - // On passe la table et la meta pour éviter de les recalculer dans la fonction appelée |
|
| 91 | - $arg['meta'] = $table; |
|
| 92 | - $arg['nom_meta'] = $nom_meta; |
|
| 93 | - } else { |
|
| 94 | - // Ancienne méthode d'installation - TODO à supprimer à terme |
|
| 95 | - // stupide: info deja dans le nom |
|
| 96 | - $arg = $infos['prefix']; |
|
| 97 | - } |
|
| 98 | - $version = $infos['schema'] ?? ''; |
|
| 99 | - |
|
| 100 | - if (!$f) { |
|
| 101 | - // installation sans operation particuliere |
|
| 102 | - $infos['install_test'] = [true, '']; |
|
| 103 | - return $infos; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // Tester si l'action demandée est nécessaire ou pas. |
|
| 107 | - $test = $f('test', $arg, $version); |
|
| 108 | - if ($action == 'uninstall') { |
|
| 109 | - $test = !$test; |
|
| 110 | - } |
|
| 111 | - // Si deja fait, on ne fait rien et on ne dit rien |
|
| 112 | - if ($test) { |
|
| 113 | - return true; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - // Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos |
|
| 117 | - // pour renvoyer le bon message en retour de la fonction. |
|
| 118 | - if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) { |
|
| 119 | - $infos['upgrade'] = true; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // executer l'installation ou l'inverse |
|
| 123 | - // et renvoyer la trace (mais il faudrait passer en AJAX plutot) |
|
| 124 | - ob_start(); |
|
| 125 | - $f($action, $arg, $version); |
|
| 126 | - $aff = ob_get_contents(); |
|
| 127 | - ob_end_clean(); |
|
| 128 | - |
|
| 129 | - // vider le cache des descriptions de tables a chaque (de)installation |
|
| 130 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 131 | - $trouver_table(''); |
|
| 132 | - $infos['install_test'] = [$f('test', $arg, $version), $aff]; |
|
| 133 | - |
|
| 134 | - // Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin |
|
| 135 | - // on force la création du fichier cache à la date du moment. |
|
| 136 | - // On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta. |
|
| 137 | - if ($table !== 'meta' && $action == 'install' && empty($infos['upgrade'])) { |
|
| 138 | - touch_meta(false, $table); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - return $infos; |
|
| 56 | + // Charger les informations du XML du plugin et vérification de l'existence d'une installation |
|
| 57 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 58 | + $infos = $get_infos($plug, false, constant($dir_type)); |
|
| 59 | + if (!isset($infos['install']) || !$infos['install']) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // Passer en chemin absolu si possible, c'est plus efficace |
|
| 64 | + $dir = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 65 | + if (!defined($dir)) { |
|
| 66 | + $dir = $dir_type; |
|
| 67 | + } |
|
| 68 | + $dir = constant($dir); |
|
| 69 | + foreach ($infos['install'] as $file) { |
|
| 70 | + $file = $dir . $plug . '/' . trim((string) $file); |
|
| 71 | + if (file_exists($file)) { |
|
| 72 | + include_once($file); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // Détermination de la table meta et du nom de la meta plugin |
|
| 77 | + $table = 'meta'; |
|
| 78 | + if (isset($infos['meta']) && $infos['meta'] !== 'meta') { |
|
| 79 | + $table = $infos['meta']; |
|
| 80 | + // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
|
| 81 | + lire_metas($table); |
|
| 82 | + } |
|
| 83 | + $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 84 | + |
|
| 85 | + // Détermination de la fonction à appeler et de ses arguments |
|
| 86 | + $f = $infos['prefix'] . '_install'; |
|
| 87 | + if (!function_exists($f)) { |
|
| 88 | + $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
|
| 89 | + $arg = $infos; |
|
| 90 | + // On passe la table et la meta pour éviter de les recalculer dans la fonction appelée |
|
| 91 | + $arg['meta'] = $table; |
|
| 92 | + $arg['nom_meta'] = $nom_meta; |
|
| 93 | + } else { |
|
| 94 | + // Ancienne méthode d'installation - TODO à supprimer à terme |
|
| 95 | + // stupide: info deja dans le nom |
|
| 96 | + $arg = $infos['prefix']; |
|
| 97 | + } |
|
| 98 | + $version = $infos['schema'] ?? ''; |
|
| 99 | + |
|
| 100 | + if (!$f) { |
|
| 101 | + // installation sans operation particuliere |
|
| 102 | + $infos['install_test'] = [true, '']; |
|
| 103 | + return $infos; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // Tester si l'action demandée est nécessaire ou pas. |
|
| 107 | + $test = $f('test', $arg, $version); |
|
| 108 | + if ($action == 'uninstall') { |
|
| 109 | + $test = !$test; |
|
| 110 | + } |
|
| 111 | + // Si deja fait, on ne fait rien et on ne dit rien |
|
| 112 | + if ($test) { |
|
| 113 | + return true; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + // Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos |
|
| 117 | + // pour renvoyer le bon message en retour de la fonction. |
|
| 118 | + if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) { |
|
| 119 | + $infos['upgrade'] = true; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // executer l'installation ou l'inverse |
|
| 123 | + // et renvoyer la trace (mais il faudrait passer en AJAX plutot) |
|
| 124 | + ob_start(); |
|
| 125 | + $f($action, $arg, $version); |
|
| 126 | + $aff = ob_get_contents(); |
|
| 127 | + ob_end_clean(); |
|
| 128 | + |
|
| 129 | + // vider le cache des descriptions de tables a chaque (de)installation |
|
| 130 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 131 | + $trouver_table(''); |
|
| 132 | + $infos['install_test'] = [$f('test', $arg, $version), $aff]; |
|
| 133 | + |
|
| 134 | + // Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin |
|
| 135 | + // on force la création du fichier cache à la date du moment. |
|
| 136 | + // On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta. |
|
| 137 | + if ($table !== 'meta' && $action == 'install' && empty($infos['upgrade'])) { |
|
| 138 | + touch_meta(false, $table); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + return $infos; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -154,24 +154,24 @@ discard block |
||
| 154 | 154 | * @return bool|void |
| 155 | 155 | */ |
| 156 | 156 | function spip_plugin_install($action, $infos, $version_cible) { |
| 157 | - $nom_meta = $infos['nom_meta']; |
|
| 158 | - $table = $infos['meta']; |
|
| 159 | - switch ($action) { |
|
| 160 | - case 'test': |
|
| 161 | - return (isset($GLOBALS[$table]) |
|
| 162 | - && isset($GLOBALS[$table][$nom_meta]) |
|
| 163 | - && spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
|
| 164 | - case 'install': |
|
| 165 | - if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 166 | - $upgrade($nom_meta, $version_cible, $table); |
|
| 167 | - } |
|
| 168 | - break; |
|
| 169 | - case 'uninstall': |
|
| 170 | - if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 171 | - $vider_tables($nom_meta, $table); |
|
| 172 | - } |
|
| 173 | - break; |
|
| 174 | - } |
|
| 157 | + $nom_meta = $infos['nom_meta']; |
|
| 158 | + $table = $infos['meta']; |
|
| 159 | + switch ($action) { |
|
| 160 | + case 'test': |
|
| 161 | + return (isset($GLOBALS[$table]) |
|
| 162 | + && isset($GLOBALS[$table][$nom_meta]) |
|
| 163 | + && spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
|
| 164 | + case 'install': |
|
| 165 | + if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 166 | + $upgrade($nom_meta, $version_cible, $table); |
|
| 167 | + } |
|
| 168 | + break; |
|
| 169 | + case 'uninstall': |
|
| 170 | + if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 171 | + $vider_tables($nom_meta, $table); |
|
| 172 | + } |
|
| 173 | + break; |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | * @return array Tableau des plugins actifs |
| 191 | 191 | **/ |
| 192 | 192 | function liste_plugin_actifs() { |
| 193 | - $liste = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 194 | - if (!$liste) { |
|
| 195 | - return []; |
|
| 196 | - } |
|
| 197 | - $liste = unserialize($liste); |
|
| 198 | - return is_array($liste) ? $liste : []; |
|
| 193 | + $liste = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 194 | + if (!$liste) { |
|
| 195 | + return []; |
|
| 196 | + } |
|
| 197 | + $liste = unserialize($liste); |
|
| 198 | + return is_array($liste) ? $liste : []; |
|
| 199 | 199 | } |