@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | define('_PHP_MAX', '8.2.99'); |
| 39 | 39 | |
| 40 | 40 | if (!defined('_DIR_RESTREINT_ABS')) { |
| 41 | - /** le nom du repertoire ecrire/ */ |
|
| 42 | - define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 41 | + /** le nom du repertoire ecrire/ */ |
|
| 42 | + define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** Chemin relatif pour aller dans ecrire |
| 46 | 46 | * vide si on est dans ecrire, 'ecrire/' sinon */ |
| 47 | 47 | define( |
| 48 | - '_DIR_RESTREINT', |
|
| 49 | - (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 48 | + '_DIR_RESTREINT', |
|
| 49 | + (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | 52 | /** Chemin relatif pour aller à la racine */ |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | // Icones |
| 63 | 63 | if (!defined('_NOM_IMG_PACK')) { |
| 64 | - /** Nom du dossier images */ |
|
| 65 | - define('_NOM_IMG_PACK', 'images/'); |
|
| 64 | + /** Nom du dossier images */ |
|
| 65 | + define('_NOM_IMG_PACK', 'images/'); |
|
| 66 | 66 | } |
| 67 | 67 | /** le chemin http (relatif) vers les images standard */ |
| 68 | 68 | define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
| 72 | 72 | |
| 73 | 73 | if (!defined('_JAVASCRIPT')) { |
| 74 | - /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 75 | - define('_JAVASCRIPT', 'javascript/'); |
|
| 74 | + /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 75 | + define('_JAVASCRIPT', 'javascript/'); |
|
| 76 | 76 | } // utilisable avec #CHEMIN et find_in_path |
| 77 | 77 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 78 | 78 | define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
@@ -82,47 +82,47 @@ discard block |
||
| 82 | 82 | # mais on peut les mettre ailleurs et changer completement les noms |
| 83 | 83 | |
| 84 | 84 | if (!defined('_NOM_TEMPORAIRES_INACCESSIBLES')) { |
| 85 | - /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 86 | - define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 85 | + /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 86 | + define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 87 | 87 | } |
| 88 | 88 | if (!defined('_NOM_TEMPORAIRES_ACCESSIBLES')) { |
| 89 | - /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 90 | - define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 89 | + /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 90 | + define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 91 | 91 | } |
| 92 | 92 | if (!defined('_NOM_PERMANENTS_INACCESSIBLES')) { |
| 93 | - /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 94 | - define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 93 | + /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 94 | + define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 95 | 95 | } |
| 96 | 96 | if (!defined('_NOM_PERMANENTS_ACCESSIBLES')) { |
| 97 | - /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 98 | - define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 97 | + /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 98 | + define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | /** Le nom du fichier de personnalisation */ |
| 103 | 103 | if (!defined('_NOM_CONFIG')) { |
| 104 | - define('_NOM_CONFIG', 'mes_options'); |
|
| 104 | + define('_NOM_CONFIG', 'mes_options'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // Son emplacement absolu si on le trouve |
| 108 | 108 | if ( |
| 109 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 110 | - or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 109 | + @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 110 | + or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 111 | 111 | ) { |
| 112 | - /** Emplacement absolu du fichier d'option */ |
|
| 113 | - define('_FILE_OPTIONS', $f); |
|
| 112 | + /** Emplacement absolu du fichier d'option */ |
|
| 113 | + define('_FILE_OPTIONS', $f); |
|
| 114 | 114 | } else { |
| 115 | - define('_FILE_OPTIONS', ''); |
|
| 115 | + define('_FILE_OPTIONS', ''); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | if (!defined('MODULES_IDIOMES')) { |
| 119 | - /** |
|
| 120 | - * Modules par défaut pour la traduction. |
|
| 121 | - * |
|
| 122 | - * Constante utilisée par le compilateur et le décompilateur |
|
| 123 | - * sa valeur etant traitée par inc_traduire_dist |
|
| 124 | - */ |
|
| 125 | - define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 119 | + /** |
|
| 120 | + * Modules par défaut pour la traduction. |
|
| 121 | + * |
|
| 122 | + * Constante utilisée par le compilateur et le décompilateur |
|
| 123 | + * sa valeur etant traitée par inc_traduire_dist |
|
| 124 | + */ |
|
| 125 | + define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // *** Fin des define *** // |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | // inclure l'ecran de securite |
| 132 | 132 | if ( |
| 133 | - !defined('_ECRAN_SECURITE') |
|
| 134 | - and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 133 | + !defined('_ECRAN_SECURITE') |
|
| 134 | + and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 135 | 135 | ) { |
| 136 | - include $f; |
|
| 136 | + include $f; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | |
@@ -141,30 +141,30 @@ discard block |
||
| 141 | 141 | * Détecteur de robot d'indexation |
| 142 | 142 | */ |
| 143 | 143 | if (!defined('_IS_BOT')) { |
| 144 | - define( |
|
| 145 | - '_IS_BOT', |
|
| 146 | - isset($_SERVER['HTTP_USER_AGENT']) |
|
| 147 | - and preg_match( |
|
| 148 | - // mots generiques |
|
| 149 | - ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 150 | - // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 151 | - . 'MSIE 6\.0|' |
|
| 152 | - // UA plus cibles |
|
| 153 | - . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 154 | - . ',i', |
|
| 155 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 156 | - ) |
|
| 157 | - ); |
|
| 144 | + define( |
|
| 145 | + '_IS_BOT', |
|
| 146 | + isset($_SERVER['HTTP_USER_AGENT']) |
|
| 147 | + and preg_match( |
|
| 148 | + // mots generiques |
|
| 149 | + ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 150 | + // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 151 | + . 'MSIE 6\.0|' |
|
| 152 | + // UA plus cibles |
|
| 153 | + . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 154 | + . ',i', |
|
| 155 | + (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 156 | + ) |
|
| 157 | + ); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (!defined('_IS_CLI')) { |
| 161 | - define( |
|
| 162 | - '_IS_CLI', |
|
| 163 | - !isset($_SERVER['HTTP_HOST']) |
|
| 164 | - and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 165 | - and !empty($_SERVER['argv']) |
|
| 166 | - and empty($_SERVER['REQUEST_METHOD']) |
|
| 167 | - ); |
|
| 161 | + define( |
|
| 162 | + '_IS_CLI', |
|
| 163 | + !isset($_SERVER['HTTP_HOST']) |
|
| 164 | + and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 165 | + and !empty($_SERVER['argv']) |
|
| 166 | + and empty($_SERVER['REQUEST_METHOD']) |
|
| 167 | + ); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // *** Parametrage par defaut de SPIP *** |
@@ -176,61 +176,61 @@ discard block |
||
| 176 | 176 | // Ne pas les rendre indefinies. |
| 177 | 177 | |
| 178 | 178 | global |
| 179 | - $nombre_de_logs, |
|
| 180 | - $taille_des_logs, |
|
| 181 | - $table_prefix, |
|
| 182 | - $cookie_prefix, |
|
| 183 | - $dossier_squelettes, |
|
| 184 | - $filtrer_javascript, |
|
| 185 | - $type_urls, |
|
| 186 | - $debut_date_publication, |
|
| 187 | - $ip, |
|
| 188 | - $mysql_rappel_connexion, |
|
| 189 | - $mysql_rappel_nom_base, |
|
| 190 | - $test_i18n, |
|
| 191 | - $ignore_auth_http, |
|
| 192 | - $ignore_remote_user, |
|
| 193 | - $derniere_modif_invalide, |
|
| 194 | - $home_server, |
|
| 195 | - $help_server, |
|
| 196 | - $url_glossaire_externe, |
|
| 197 | - $tex_server, |
|
| 198 | - $traiter_math, |
|
| 199 | - $xhtml, |
|
| 200 | - $xml_indent, |
|
| 201 | - $source_vignettes, |
|
| 202 | - $formats_logos, |
|
| 203 | - $controler_dates_rss, |
|
| 204 | - $spip_pipeline, |
|
| 205 | - $spip_matrice, |
|
| 206 | - $plugins, |
|
| 207 | - $surcharges, |
|
| 208 | - $exceptions_des_tables, |
|
| 209 | - $tables_principales, |
|
| 210 | - $table_des_tables, |
|
| 211 | - $tables_auxiliaires, |
|
| 212 | - $table_primary, |
|
| 213 | - $table_date, |
|
| 214 | - $table_titre, |
|
| 215 | - $tables_jointures, |
|
| 216 | - $liste_des_statuts, |
|
| 217 | - $liste_des_etats, |
|
| 218 | - $liste_des_authentifications, |
|
| 219 | - $spip_version_branche, |
|
| 220 | - $spip_version_code, |
|
| 221 | - $spip_version_base, |
|
| 222 | - $spip_sql_version, |
|
| 223 | - $spip_version_affichee, |
|
| 224 | - $visiteur_session, |
|
| 225 | - $auteur_session, |
|
| 226 | - $connect_statut, |
|
| 227 | - $connect_toutes_rubriques, |
|
| 228 | - $hash_recherche, |
|
| 229 | - $hash_recherche_strict, |
|
| 230 | - $ldap_present, |
|
| 231 | - $meta, |
|
| 232 | - $connect_id_rubrique, |
|
| 233 | - $puce; |
|
| 179 | + $nombre_de_logs, |
|
| 180 | + $taille_des_logs, |
|
| 181 | + $table_prefix, |
|
| 182 | + $cookie_prefix, |
|
| 183 | + $dossier_squelettes, |
|
| 184 | + $filtrer_javascript, |
|
| 185 | + $type_urls, |
|
| 186 | + $debut_date_publication, |
|
| 187 | + $ip, |
|
| 188 | + $mysql_rappel_connexion, |
|
| 189 | + $mysql_rappel_nom_base, |
|
| 190 | + $test_i18n, |
|
| 191 | + $ignore_auth_http, |
|
| 192 | + $ignore_remote_user, |
|
| 193 | + $derniere_modif_invalide, |
|
| 194 | + $home_server, |
|
| 195 | + $help_server, |
|
| 196 | + $url_glossaire_externe, |
|
| 197 | + $tex_server, |
|
| 198 | + $traiter_math, |
|
| 199 | + $xhtml, |
|
| 200 | + $xml_indent, |
|
| 201 | + $source_vignettes, |
|
| 202 | + $formats_logos, |
|
| 203 | + $controler_dates_rss, |
|
| 204 | + $spip_pipeline, |
|
| 205 | + $spip_matrice, |
|
| 206 | + $plugins, |
|
| 207 | + $surcharges, |
|
| 208 | + $exceptions_des_tables, |
|
| 209 | + $tables_principales, |
|
| 210 | + $table_des_tables, |
|
| 211 | + $tables_auxiliaires, |
|
| 212 | + $table_primary, |
|
| 213 | + $table_date, |
|
| 214 | + $table_titre, |
|
| 215 | + $tables_jointures, |
|
| 216 | + $liste_des_statuts, |
|
| 217 | + $liste_des_etats, |
|
| 218 | + $liste_des_authentifications, |
|
| 219 | + $spip_version_branche, |
|
| 220 | + $spip_version_code, |
|
| 221 | + $spip_version_base, |
|
| 222 | + $spip_sql_version, |
|
| 223 | + $spip_version_affichee, |
|
| 224 | + $visiteur_session, |
|
| 225 | + $auteur_session, |
|
| 226 | + $connect_statut, |
|
| 227 | + $connect_toutes_rubriques, |
|
| 228 | + $hash_recherche, |
|
| 229 | + $hash_recherche_strict, |
|
| 230 | + $ldap_present, |
|
| 231 | + $meta, |
|
| 232 | + $connect_id_rubrique, |
|
| 233 | + $puce; |
|
| 234 | 234 | |
| 235 | 235 | # comment on logge, defaut 4 tmp/spip.log de 100k, 0 ou 0 suppriment le log |
| 236 | 236 | $nombre_de_logs = 4; |
@@ -285,48 +285,48 @@ discard block |
||
| 285 | 285 | // Prendre en compte les entetes HTTP_X_FORWARDED_XX |
| 286 | 286 | // |
| 287 | 287 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
| 288 | - if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 289 | - $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 290 | - } |
|
| 291 | - if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 292 | - $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 293 | - } |
|
| 288 | + if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 289 | + $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 290 | + } |
|
| 291 | + if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 292 | + $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 293 | + } |
|
| 294 | 294 | } |
| 295 | 295 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 296 | - if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 297 | - $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 298 | - if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 299 | - $_SERVER['HTTPS'] = 'on'; |
|
| 300 | - if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 301 | - $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 306 | - if (strpos($host, ',') !== false) { |
|
| 307 | - $h = explode(',', $host); |
|
| 308 | - $host = trim(reset($h)); |
|
| 309 | - } |
|
| 310 | - // securite sur le contenu de l'entete |
|
| 311 | - $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 312 | - $_SERVER['HTTP_HOST'] = $host; |
|
| 296 | + if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 297 | + $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 298 | + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 299 | + $_SERVER['HTTPS'] = 'on'; |
|
| 300 | + if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 301 | + $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 306 | + if (strpos($host, ',') !== false) { |
|
| 307 | + $h = explode(',', $host); |
|
| 308 | + $host = trim(reset($h)); |
|
| 309 | + } |
|
| 310 | + // securite sur le contenu de l'entete |
|
| 311 | + $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 312 | + $_SERVER['HTTP_HOST'] = $host; |
|
| 313 | 313 | } |
| 314 | 314 | // |
| 315 | 315 | // On note le numero IP du client dans la variable $ip |
| 316 | 316 | // |
| 317 | 317 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 318 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 319 | - if (strpos($ip, ',') !== false) { |
|
| 320 | - $ip = explode(',', $ip); |
|
| 321 | - $ip = reset($ip); |
|
| 322 | - } |
|
| 323 | - // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 324 | - if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 325 | - $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 326 | - } |
|
| 318 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 319 | + if (strpos($ip, ',') !== false) { |
|
| 320 | + $ip = explode(',', $ip); |
|
| 321 | + $ip = reset($ip); |
|
| 322 | + } |
|
| 323 | + // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 324 | + if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 325 | + $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 326 | + } |
|
| 327 | 327 | } |
| 328 | 328 | if (isset($_SERVER['REMOTE_ADDR'])) { |
| 329 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 329 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Pour renforcer la privacy, decommentez la ligne ci-dessous (ou recopiez-la |
@@ -411,24 +411,24 @@ discard block |
||
| 411 | 411 | |
| 412 | 412 | // Liste des statuts. |
| 413 | 413 | $liste_des_statuts = [ |
| 414 | - 'info_administrateurs' => '0minirezo', |
|
| 415 | - 'info_redacteurs' => '1comite', |
|
| 416 | - 'info_visiteurs' => '6forum', |
|
| 417 | - 'texte_statut_poubelle' => '5poubelle' |
|
| 414 | + 'info_administrateurs' => '0minirezo', |
|
| 415 | + 'info_redacteurs' => '1comite', |
|
| 416 | + 'info_visiteurs' => '6forum', |
|
| 417 | + 'texte_statut_poubelle' => '5poubelle' |
|
| 418 | 418 | ]; |
| 419 | 419 | |
| 420 | 420 | $liste_des_etats = [ |
| 421 | - 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 422 | - 'texte_statut_propose_evaluation' => 'prop', |
|
| 423 | - 'texte_statut_publie' => 'publie', |
|
| 424 | - 'texte_statut_poubelle' => 'poubelle', |
|
| 425 | - 'texte_statut_refuse' => 'refuse' |
|
| 421 | + 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 422 | + 'texte_statut_propose_evaluation' => 'prop', |
|
| 423 | + 'texte_statut_publie' => 'publie', |
|
| 424 | + 'texte_statut_poubelle' => 'poubelle', |
|
| 425 | + 'texte_statut_refuse' => 'refuse' |
|
| 426 | 426 | ]; |
| 427 | 427 | |
| 428 | 428 | // liste des methodes d'authentifications |
| 429 | 429 | $liste_des_authentifications = [ |
| 430 | - 'spip' => 'spip', |
|
| 431 | - 'ldap' => 'ldap' |
|
| 430 | + 'spip' => 'spip', |
|
| 431 | + 'ldap' => 'ldap' |
|
| 432 | 432 | ]; |
| 433 | 433 | |
| 434 | 434 | // Experimental : pour supprimer systematiquement l'affichage des numeros |
@@ -478,12 +478,12 @@ discard block |
||
| 478 | 478 | // Definition personnelles eventuelles |
| 479 | 479 | |
| 480 | 480 | if (_FILE_OPTIONS) { |
| 481 | - include_once _FILE_OPTIONS; |
|
| 481 | + include_once _FILE_OPTIONS; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | if (!defined('SPIP_ERREUR_REPORT')) { |
| 485 | - /** Masquer les warning */ |
|
| 486 | - define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 485 | + /** Masquer les warning */ |
|
| 486 | + define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 487 | 487 | } |
| 488 | 488 | error_reporting(SPIP_ERREUR_REPORT); |
| 489 | 489 | |
@@ -496,10 +496,10 @@ discard block |
||
| 496 | 496 | // ===> on execute en neutralisant les messages d'erreur |
| 497 | 497 | |
| 498 | 498 | spip_initialisation_core( |
| 499 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 499 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 503 | 503 | ); |
| 504 | 504 | |
| 505 | 505 | |
@@ -509,71 +509,71 @@ discard block |
||
| 509 | 509 | // donc il faut avoir tout fini ici avant de charger les plugins |
| 510 | 510 | |
| 511 | 511 | if (@is_readable(_CACHE_PLUGINS_OPT) and @is_readable(_CACHE_PLUGINS_PATH)) { |
| 512 | - // chargement optimise precompile |
|
| 513 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 512 | + // chargement optimise precompile |
|
| 513 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 514 | 514 | } else { |
| 515 | - spip_initialisation_suite(); |
|
| 516 | - include_spip('inc/plugin'); |
|
| 517 | - // generer les fichiers php precompiles |
|
| 518 | - // de chargement des plugins et des pipelines |
|
| 519 | - actualise_plugins_actifs(); |
|
| 515 | + spip_initialisation_suite(); |
|
| 516 | + include_spip('inc/plugin'); |
|
| 517 | + // generer les fichiers php precompiles |
|
| 518 | + // de chargement des plugins et des pipelines |
|
| 519 | + actualise_plugins_actifs(); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | // Initialisations non critiques surchargeables par les plugins |
| 523 | 523 | spip_initialisation_suite(); |
| 524 | 524 | |
| 525 | 525 | if (!defined('_LOG_FILTRE_GRAVITE')) { |
| 526 | - /** niveau maxi d'enregistrement des logs */ |
|
| 527 | - define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 526 | + /** niveau maxi d'enregistrement des logs */ |
|
| 527 | + define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | if (!defined('_OUTILS_DEVELOPPEURS')) { |
| 531 | - /** Activer des outils pour développeurs ? */ |
|
| 532 | - define('_OUTILS_DEVELOPPEURS', false); |
|
| 531 | + /** Activer des outils pour développeurs ? */ |
|
| 532 | + define('_OUTILS_DEVELOPPEURS', false); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | // charger systematiquement inc/autoriser dans l'espace restreint |
| 536 | 536 | if (test_espace_prive()) { |
| 537 | - include_spip('inc/autoriser'); |
|
| 537 | + include_spip('inc/autoriser'); |
|
| 538 | 538 | } |
| 539 | 539 | // |
| 540 | 540 | // Installer Spip si pas installe... sauf si justement on est en train |
| 541 | 541 | // |
| 542 | 542 | if ( |
| 543 | - !(_FILE_CONNECT |
|
| 544 | - or autoriser_sans_cookie(_request('exec')) |
|
| 545 | - or _request('action') == 'cookie' |
|
| 546 | - or _request('action') == 'converser' |
|
| 547 | - or _request('action') == 'test_dirs') |
|
| 543 | + !(_FILE_CONNECT |
|
| 544 | + or autoriser_sans_cookie(_request('exec')) |
|
| 545 | + or _request('action') == 'cookie' |
|
| 546 | + or _request('action') == 'converser' |
|
| 547 | + or _request('action') == 'test_dirs') |
|
| 548 | 548 | ) { |
| 549 | - // Si on peut installer, on lance illico |
|
| 550 | - if (test_espace_prive()) { |
|
| 551 | - include_spip('inc/headers'); |
|
| 552 | - redirige_url_ecrire('install'); |
|
| 553 | - } else { |
|
| 554 | - // Si on est dans le site public, dire que qq s'en occupe |
|
| 555 | - include_spip('inc/lang'); |
|
| 556 | - utiliser_langue_visiteur(); |
|
| 557 | - include_spip('inc/minipres'); |
|
| 558 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 559 | - exit; |
|
| 560 | - } |
|
| 561 | - // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 549 | + // Si on peut installer, on lance illico |
|
| 550 | + if (test_espace_prive()) { |
|
| 551 | + include_spip('inc/headers'); |
|
| 552 | + redirige_url_ecrire('install'); |
|
| 553 | + } else { |
|
| 554 | + // Si on est dans le site public, dire que qq s'en occupe |
|
| 555 | + include_spip('inc/lang'); |
|
| 556 | + utiliser_langue_visiteur(); |
|
| 557 | + include_spip('inc/minipres'); |
|
| 558 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 559 | + exit; |
|
| 560 | + } |
|
| 561 | + // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | // memoriser un tri sessionne eventuel |
| 565 | 565 | if ( |
| 566 | - isset($_REQUEST['var_memotri']) |
|
| 567 | - and $t = $_REQUEST['var_memotri'] |
|
| 568 | - and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 566 | + isset($_REQUEST['var_memotri']) |
|
| 567 | + and $t = $_REQUEST['var_memotri'] |
|
| 568 | + and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 569 | 569 | ) { |
| 570 | - if (!function_exists('session_set')) { |
|
| 571 | - include_spip('inc/session'); |
|
| 572 | - } |
|
| 573 | - $t = preg_replace(',\W,', '_', $t); |
|
| 574 | - if ($v = _request($t)) { |
|
| 575 | - session_set($t, $v); |
|
| 576 | - } |
|
| 570 | + if (!function_exists('session_set')) { |
|
| 571 | + include_spip('inc/session'); |
|
| 572 | + } |
|
| 573 | + $t = preg_replace(',\W,', '_', $t); |
|
| 574 | + if ($v = _request($t)) { |
|
| 575 | + session_set($t, $v); |
|
| 576 | + } |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | /** |
@@ -583,22 +583,22 @@ discard block |
||
| 583 | 583 | * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite |
| 584 | 584 | */ |
| 585 | 585 | if (!defined('_HEADER_COMPOSED_BY')) { |
| 586 | - define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 586 | + define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 587 | 587 | } |
| 588 | 588 | if (!headers_sent() and _HEADER_COMPOSED_BY) { |
| 589 | - if (!defined('_HEADER_VARY')) { |
|
| 590 | - define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 591 | - } |
|
| 592 | - if (_HEADER_VARY) { |
|
| 593 | - header(_HEADER_VARY); |
|
| 594 | - } |
|
| 595 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 596 | - include_spip('inc/filtres_mini'); |
|
| 597 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 598 | - } else { |
|
| 599 | - // header minimal |
|
| 600 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 601 | - } |
|
| 589 | + if (!defined('_HEADER_VARY')) { |
|
| 590 | + define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 591 | + } |
|
| 592 | + if (_HEADER_VARY) { |
|
| 593 | + header(_HEADER_VARY); |
|
| 594 | + } |
|
| 595 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 596 | + include_spip('inc/filtres_mini'); |
|
| 597 | + header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 598 | + } else { |
|
| 599 | + // header minimal |
|
| 600 | + header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 601 | + } |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * Ce programme est un logiciel libre distribué sous licence GNU/GPL. * |
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 12 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Initialisation de SPIP |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | define('_DIR_RACINE', _DIR_RESTREINT ? '' : '../'); |
| 54 | 54 | |
| 55 | 55 | /** chemin absolu vers la racine */ |
| 56 | -define('_ROOT_RACINE', dirname(__DIR__) . '/'); |
|
| 56 | +define('_ROOT_RACINE', dirname(__DIR__).'/'); |
|
| 57 | 57 | /** chemin absolu vers le repertoire de travail */ |
| 58 | -define('_ROOT_CWD', getcwd() . '/'); |
|
| 58 | +define('_ROOT_CWD', getcwd().'/'); |
|
| 59 | 59 | /** chemin absolu vers ecrire */ |
| 60 | -define('_ROOT_RESTREINT', _ROOT_CWD . _DIR_RESTREINT); |
|
| 60 | +define('_ROOT_RESTREINT', _ROOT_CWD._DIR_RESTREINT); |
|
| 61 | 61 | |
| 62 | 62 | // Icones |
| 63 | 63 | if (!defined('_NOM_IMG_PACK')) { |
@@ -65,17 +65,17 @@ discard block |
||
| 65 | 65 | define('_NOM_IMG_PACK', 'images/'); |
| 66 | 66 | } |
| 67 | 67 | /** le chemin http (relatif) vers les images standard */ |
| 68 | -define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
|
| 68 | +define('_DIR_IMG_PACK', (_DIR_RACINE.'prive/'._NOM_IMG_PACK)); |
|
| 69 | 69 | |
| 70 | 70 | /** le chemin php (absolu) vers les images standard (pour hebergement centralise) */ |
| 71 | -define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
|
| 71 | +define('_ROOT_IMG_PACK', dirname(__DIR__).'/prive/'._NOM_IMG_PACK); |
|
| 72 | 72 | |
| 73 | 73 | if (!defined('_JAVASCRIPT')) { |
| 74 | 74 | /** Nom du repertoire des bibliotheques JavaScript */ |
| 75 | 75 | define('_JAVASCRIPT', 'javascript/'); |
| 76 | 76 | } // utilisable avec #CHEMIN et find_in_path |
| 77 | 77 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 78 | -define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
|
| 78 | +define('_DIR_JAVASCRIPT', (_DIR_RACINE.'prive/'._JAVASCRIPT)); |
|
| 79 | 79 | |
| 80 | 80 | # Le nom des 4 repertoires modifiables par les scripts lances par httpd |
| 81 | 81 | # Par defaut ces 4 noms seront suffixes par _DIR_RACINE (cf plus bas) |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // Son emplacement absolu si on le trouve |
| 108 | 108 | if ( |
| 109 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 110 | - or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 109 | + @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES._NOM_CONFIG.'.php') |
|
| 110 | + or (@file_exists($f = _ROOT_RESTREINT._NOM_CONFIG.'.php')) |
|
| 111 | 111 | ) { |
| 112 | 112 | /** Emplacement absolu du fichier d'option */ |
| 113 | 113 | define('_FILE_OPTIONS', $f); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | // inclure l'ecran de securite |
| 132 | 132 | if ( |
| 133 | 133 | !defined('_ECRAN_SECURITE') |
| 134 | - and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 134 | + and @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES.'ecran_securite.php') |
|
| 135 | 135 | ) { |
| 136 | 136 | include $f; |
| 137 | 137 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // UA plus cibles |
| 153 | 153 | . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
| 154 | 154 | . ',i', |
| 155 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 155 | + (string) $_SERVER['HTTP_USER_AGENT'] |
|
| 156 | 156 | ) |
| 157 | 157 | ); |
| 158 | 158 | } |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | # la matrice standard (fichiers definissant les fonctions a inclure) |
| 395 | 395 | $spip_matrice = []; |
| 396 | 396 | # les plugins a activer |
| 397 | -$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 397 | +$plugins = []; // voir le contenu du repertoire /plugins/ |
|
| 398 | 398 | # les surcharges de include_spip() |
| 399 | 399 | $surcharges = []; // format 'inc_truc' => '/plugins/chose/inc_truc2.php' |
| 400 | 400 | |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | // |
| 473 | 473 | // Charger les fonctions liees aux serveurs Http et Sql. |
| 474 | 474 | // |
| 475 | -require_once _ROOT_RESTREINT . 'inc/utils.php'; |
|
| 476 | -require_once _ROOT_RESTREINT . 'base/connect_sql.php'; |
|
| 475 | +require_once _ROOT_RESTREINT.'inc/utils.php'; |
|
| 476 | +require_once _ROOT_RESTREINT.'base/connect_sql.php'; |
|
| 477 | 477 | |
| 478 | 478 | // Definition personnelles eventuelles |
| 479 | 479 | |
@@ -496,10 +496,10 @@ discard block |
||
| 496 | 496 | // ===> on execute en neutralisant les messages d'erreur |
| 497 | 497 | |
| 498 | 498 | spip_initialisation_core( |
| 499 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 499 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 500 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 501 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 502 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 503 | 503 | ); |
| 504 | 504 | |
| 505 | 505 | |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | include_spip('inc/lang'); |
| 556 | 556 | utiliser_langue_visiteur(); |
| 557 | 557 | include_spip('inc/minipres'); |
| 558 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 558 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>"._T('info_travaux_texte').'</p>', ['status' => 503]); |
|
| 559 | 559 | exit; |
| 560 | 560 | } |
| 561 | 561 | // autrement c'est une install ad hoc (spikini...), on sait pas faire |
@@ -594,12 +594,12 @@ discard block |
||
| 594 | 594 | } |
| 595 | 595 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 596 | 596 | include_spip('inc/filtres_mini'); |
| 597 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 597 | + header(_HEADER_COMPOSED_BY." $spip_version_affichee @ www.spip.net + ".url_absolue(_DIR_VAR.'config.txt')); |
|
| 598 | 598 | } else { |
| 599 | 599 | // header minimal |
| 600 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 600 | + header(_HEADER_COMPOSED_BY.' @ www.spip.net'); |
|
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
| 605 | -spip_log($methode . ' ' . self() . ' - ' . _FILE_CONNECT, _LOG_DEBUG); |
|
| 605 | +spip_log($methode.' '.self().' - '._FILE_CONNECT, _LOG_DEBUG); |
|
@@ -19,138 +19,138 @@ |
||
| 19 | 19 | **/ |
| 20 | 20 | class Minipres extends Minipublic { |
| 21 | 21 | |
| 22 | - protected function setOptions(array $options) { |
|
| 23 | - $options['couleur_fond'] = '#aaa'; |
|
| 24 | - $options['css_files'] = [ |
|
| 25 | - find_in_theme('minipres.css') |
|
| 26 | - ]; |
|
| 27 | - |
|
| 28 | - if (!empty($options['titre']) and $options['titre'] === 'AUTO') { |
|
| 29 | - $options['titre'] = _T('info_installation_systeme_publication'); |
|
| 30 | - } |
|
| 31 | - $options['page_title'] = ($options['titre'] ?? ''); |
|
| 32 | - |
|
| 33 | - return $options; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Retourne le début d'une page HTML minimale (de type installation ou erreur) |
|
| 39 | - * |
|
| 40 | - * @param array $options |
|
| 41 | - * @return string |
|
| 42 | - * Code HTML |
|
| 43 | - */ |
|
| 44 | - public function installDebutPage($options = []) { |
|
| 45 | - |
|
| 46 | - $options = $this->setOptions($options); |
|
| 47 | - return parent::ouvreBody($options) |
|
| 48 | - . parent::ouvreCorps($options); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Retourne le fin d'une page HTML minimale (de type installation ou erreur) |
|
| 53 | - * |
|
| 54 | - * @param array $options |
|
| 55 | - * @return string |
|
| 56 | - * Code HTML |
|
| 57 | - */ |
|
| 58 | - public function installFinPage($options = []) { |
|
| 59 | - |
|
| 60 | - $options = $this->setOptions($options); |
|
| 61 | - return parent::fermeCorps($options) |
|
| 62 | - . parent::fermeBody(); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Retourne une page HTML contenant, dans une présentation minimale, |
|
| 68 | - * le contenu transmis dans `$corps`. |
|
| 69 | - * |
|
| 70 | - * Appelée pour afficher un message d’erreur (l’utilisateur n’a pas |
|
| 71 | - * accès à cette page par exemple). |
|
| 72 | - * |
|
| 73 | - * Lorsqu’aucun argument n’est transmis, un header 403 est renvoyé, |
|
| 74 | - * ainsi qu’un message indiquant une interdiction d’accès. |
|
| 75 | - * |
|
| 76 | - * @param string $corps |
|
| 77 | - * Corps de la page |
|
| 78 | - * @param array $options |
|
| 79 | - * @return string |
|
| 80 | - * HTML de la page |
|
| 81 | - * @see ouvreBody() |
|
| 82 | - * string $titre : Titre à l'affichage (différent de $page_title) |
|
| 83 | - * int $status : status de la page |
|
| 84 | - * string $footer : pied de la box en remplacement du bouton retour par défaut |
|
| 85 | - * @uses ouvreBody() |
|
| 86 | - * @uses fermeBody() |
|
| 87 | - * |
|
| 88 | - */ |
|
| 89 | - public function page($corps = '', $options = []) { |
|
| 90 | - |
|
| 91 | - $footer = ''; |
|
| 92 | - |
|
| 93 | - $titre = $options['titre'] ?? ''; |
|
| 94 | - if (!$titre) { |
|
| 95 | - if (empty($corps) and !isset($options['status'])) { |
|
| 96 | - $options['status'] = 403; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if ( |
|
| 100 | - !$titre = _request('action') |
|
| 101 | - and !$titre = _request('exec') |
|
| 102 | - and !$titre = _request('page') |
|
| 103 | - ) { |
|
| 104 | - $titre = '?'; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - $titre = spip_htmlspecialchars($titre); |
|
| 108 | - |
|
| 109 | - $titre = ($titre == 'install') |
|
| 110 | - ? _T('avis_espace_interdit') |
|
| 111 | - : $titre . ' : ' . _T('info_acces_interdit'); |
|
| 112 | - |
|
| 113 | - $statut = $GLOBALS['visiteur_session']['statut'] ?? ''; |
|
| 114 | - $nom = $GLOBALS['visiteur_session']['nom'] ?? ''; |
|
| 115 | - |
|
| 116 | - if ($statut != '0minirezo') { |
|
| 117 | - $titre = _T('info_acces_interdit'); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - if ($statut and test_espace_prive()) { |
|
| 121 | - $footer = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil')); |
|
| 122 | - } |
|
| 123 | - elseif (!empty($_COOKIE['spip_admin'])) { |
|
| 124 | - $footer = bouton_action(_T('public:lien_connecter'), generer_url_public('login')); |
|
| 125 | - } |
|
| 126 | - else { |
|
| 127 | - $footer = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - $corps = ""; |
|
| 131 | - spip_log($nom . " $titre " . $_SERVER['REQUEST_URI'], 'minipres'); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - $options['footer'] = $footer; |
|
| 135 | - $options['page_title'] = $titre; |
|
| 136 | - $options['titre'] = $titre; |
|
| 137 | - |
|
| 138 | - $options = $this->setOptions($options); |
|
| 139 | - |
|
| 140 | - $html = parent::page($corps, $options); |
|
| 141 | - |
|
| 142 | - if (!_AJAX) { |
|
| 143 | - return $html; |
|
| 144 | - } else { |
|
| 145 | - include_spip('inc/headers'); |
|
| 146 | - include_spip('inc/actions'); |
|
| 147 | - $url = self('&', true); |
|
| 148 | - foreach ($_POST as $v => $c) { |
|
| 149 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 150 | - } |
|
| 151 | - ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false); |
|
| 152 | - return ''; |
|
| 153 | - } |
|
| 154 | - } |
|
| 22 | + protected function setOptions(array $options) { |
|
| 23 | + $options['couleur_fond'] = '#aaa'; |
|
| 24 | + $options['css_files'] = [ |
|
| 25 | + find_in_theme('minipres.css') |
|
| 26 | + ]; |
|
| 27 | + |
|
| 28 | + if (!empty($options['titre']) and $options['titre'] === 'AUTO') { |
|
| 29 | + $options['titre'] = _T('info_installation_systeme_publication'); |
|
| 30 | + } |
|
| 31 | + $options['page_title'] = ($options['titre'] ?? ''); |
|
| 32 | + |
|
| 33 | + return $options; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Retourne le début d'une page HTML minimale (de type installation ou erreur) |
|
| 39 | + * |
|
| 40 | + * @param array $options |
|
| 41 | + * @return string |
|
| 42 | + * Code HTML |
|
| 43 | + */ |
|
| 44 | + public function installDebutPage($options = []) { |
|
| 45 | + |
|
| 46 | + $options = $this->setOptions($options); |
|
| 47 | + return parent::ouvreBody($options) |
|
| 48 | + . parent::ouvreCorps($options); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Retourne le fin d'une page HTML minimale (de type installation ou erreur) |
|
| 53 | + * |
|
| 54 | + * @param array $options |
|
| 55 | + * @return string |
|
| 56 | + * Code HTML |
|
| 57 | + */ |
|
| 58 | + public function installFinPage($options = []) { |
|
| 59 | + |
|
| 60 | + $options = $this->setOptions($options); |
|
| 61 | + return parent::fermeCorps($options) |
|
| 62 | + . parent::fermeBody(); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Retourne une page HTML contenant, dans une présentation minimale, |
|
| 68 | + * le contenu transmis dans `$corps`. |
|
| 69 | + * |
|
| 70 | + * Appelée pour afficher un message d’erreur (l’utilisateur n’a pas |
|
| 71 | + * accès à cette page par exemple). |
|
| 72 | + * |
|
| 73 | + * Lorsqu’aucun argument n’est transmis, un header 403 est renvoyé, |
|
| 74 | + * ainsi qu’un message indiquant une interdiction d’accès. |
|
| 75 | + * |
|
| 76 | + * @param string $corps |
|
| 77 | + * Corps de la page |
|
| 78 | + * @param array $options |
|
| 79 | + * @return string |
|
| 80 | + * HTML de la page |
|
| 81 | + * @see ouvreBody() |
|
| 82 | + * string $titre : Titre à l'affichage (différent de $page_title) |
|
| 83 | + * int $status : status de la page |
|
| 84 | + * string $footer : pied de la box en remplacement du bouton retour par défaut |
|
| 85 | + * @uses ouvreBody() |
|
| 86 | + * @uses fermeBody() |
|
| 87 | + * |
|
| 88 | + */ |
|
| 89 | + public function page($corps = '', $options = []) { |
|
| 90 | + |
|
| 91 | + $footer = ''; |
|
| 92 | + |
|
| 93 | + $titre = $options['titre'] ?? ''; |
|
| 94 | + if (!$titre) { |
|
| 95 | + if (empty($corps) and !isset($options['status'])) { |
|
| 96 | + $options['status'] = 403; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if ( |
|
| 100 | + !$titre = _request('action') |
|
| 101 | + and !$titre = _request('exec') |
|
| 102 | + and !$titre = _request('page') |
|
| 103 | + ) { |
|
| 104 | + $titre = '?'; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + $titre = spip_htmlspecialchars($titre); |
|
| 108 | + |
|
| 109 | + $titre = ($titre == 'install') |
|
| 110 | + ? _T('avis_espace_interdit') |
|
| 111 | + : $titre . ' : ' . _T('info_acces_interdit'); |
|
| 112 | + |
|
| 113 | + $statut = $GLOBALS['visiteur_session']['statut'] ?? ''; |
|
| 114 | + $nom = $GLOBALS['visiteur_session']['nom'] ?? ''; |
|
| 115 | + |
|
| 116 | + if ($statut != '0minirezo') { |
|
| 117 | + $titre = _T('info_acces_interdit'); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + if ($statut and test_espace_prive()) { |
|
| 121 | + $footer = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil')); |
|
| 122 | + } |
|
| 123 | + elseif (!empty($_COOKIE['spip_admin'])) { |
|
| 124 | + $footer = bouton_action(_T('public:lien_connecter'), generer_url_public('login')); |
|
| 125 | + } |
|
| 126 | + else { |
|
| 127 | + $footer = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + $corps = ""; |
|
| 131 | + spip_log($nom . " $titre " . $_SERVER['REQUEST_URI'], 'minipres'); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + $options['footer'] = $footer; |
|
| 135 | + $options['page_title'] = $titre; |
|
| 136 | + $options['titre'] = $titre; |
|
| 137 | + |
|
| 138 | + $options = $this->setOptions($options); |
|
| 139 | + |
|
| 140 | + $html = parent::page($corps, $options); |
|
| 141 | + |
|
| 142 | + if (!_AJAX) { |
|
| 143 | + return $html; |
|
| 144 | + } else { |
|
| 145 | + include_spip('inc/headers'); |
|
| 146 | + include_spip('inc/actions'); |
|
| 147 | + $url = self('&', true); |
|
| 148 | + foreach ($_POST as $v => $c) { |
|
| 149 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 150 | + } |
|
| 151 | + ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false); |
|
| 152 | + return ''; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | 156 | } |
@@ -19,262 +19,262 @@ |
||
| 19 | 19 | **/ |
| 20 | 20 | class Minipublic { |
| 21 | 21 | |
| 22 | - public function __construct() { |
|
| 23 | - include_fichiers_fonctions(); |
|
| 24 | - include_spip('inc/headers'); |
|
| 25 | - include_spip('inc/texte'); //inclue inc/lang et inc/filtres |
|
| 26 | - include_spip('inc/filtres_images_mini'); |
|
| 27 | - } |
|
| 22 | + public function __construct() { |
|
| 23 | + include_fichiers_fonctions(); |
|
| 24 | + include_spip('inc/headers'); |
|
| 25 | + include_spip('inc/texte'); //inclue inc/lang et inc/filtres |
|
| 26 | + include_spip('inc/filtres_images_mini'); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Retourne le début d'une page HTML minimale |
|
| 31 | - * |
|
| 32 | - * Le contenu de CSS minimales (reset.css, clear.css, minipublic.css) est inséré |
|
| 33 | - * dans une balise script inline (compactée si possible) |
|
| 34 | - * |
|
| 35 | - * @param array $options |
|
| 36 | - * string $lang : forcer la langue utilisateur |
|
| 37 | - * string $page_title : titre éventuel de la page (nom du site par défaut) |
|
| 38 | - * string $couleur_fond : pour la couleur dominante de la page (par défaut on reprend le réglage de la page de login) |
|
| 39 | - * bool $all_inline : inliner les CSS pour envoyer toute la page en 1 hit |
|
| 40 | - * string $doctype |
|
| 41 | - * string $charset |
|
| 42 | - * string $onload |
|
| 43 | - * array $css_files : ajouter des fichiers css |
|
| 44 | - * string $css : ajouter du CSS inline |
|
| 45 | - * string $head : contenu à ajouter à la fin <head> (pour inclusion de JS ou JS inline...) |
|
| 46 | - * @return string |
|
| 47 | - * Code HTML |
|
| 48 | - * |
|
| 49 | - * @uses html_lang_attributes() |
|
| 50 | - * @uses minifier() si le plugin compresseur est présent |
|
| 51 | - * @uses url_absolue_css() |
|
| 52 | - * |
|
| 53 | - * @uses utiliser_langue_visiteur() |
|
| 54 | - * @uses http_no_cache() |
|
| 55 | - */ |
|
| 56 | - protected function ouvreBody($options = []) { |
|
| 57 | - if (empty($options['lang'])) { |
|
| 58 | - // on se limite sur une langue de $GLOBALS['meta']['langues_multilingue'] car on est dans le public |
|
| 59 | - utiliser_langue_visiteur($GLOBALS['meta']['langues_multilingue'] ?? null); |
|
| 60 | - } else { |
|
| 61 | - changer_langue($options['lang']); |
|
| 62 | - } |
|
| 63 | - http_no_cache(); |
|
| 29 | + /** |
|
| 30 | + * Retourne le début d'une page HTML minimale |
|
| 31 | + * |
|
| 32 | + * Le contenu de CSS minimales (reset.css, clear.css, minipublic.css) est inséré |
|
| 33 | + * dans une balise script inline (compactée si possible) |
|
| 34 | + * |
|
| 35 | + * @param array $options |
|
| 36 | + * string $lang : forcer la langue utilisateur |
|
| 37 | + * string $page_title : titre éventuel de la page (nom du site par défaut) |
|
| 38 | + * string $couleur_fond : pour la couleur dominante de la page (par défaut on reprend le réglage de la page de login) |
|
| 39 | + * bool $all_inline : inliner les CSS pour envoyer toute la page en 1 hit |
|
| 40 | + * string $doctype |
|
| 41 | + * string $charset |
|
| 42 | + * string $onload |
|
| 43 | + * array $css_files : ajouter des fichiers css |
|
| 44 | + * string $css : ajouter du CSS inline |
|
| 45 | + * string $head : contenu à ajouter à la fin <head> (pour inclusion de JS ou JS inline...) |
|
| 46 | + * @return string |
|
| 47 | + * Code HTML |
|
| 48 | + * |
|
| 49 | + * @uses html_lang_attributes() |
|
| 50 | + * @uses minifier() si le plugin compresseur est présent |
|
| 51 | + * @uses url_absolue_css() |
|
| 52 | + * |
|
| 53 | + * @uses utiliser_langue_visiteur() |
|
| 54 | + * @uses http_no_cache() |
|
| 55 | + */ |
|
| 56 | + protected function ouvreBody($options = []) { |
|
| 57 | + if (empty($options['lang'])) { |
|
| 58 | + // on se limite sur une langue de $GLOBALS['meta']['langues_multilingue'] car on est dans le public |
|
| 59 | + utiliser_langue_visiteur($GLOBALS['meta']['langues_multilingue'] ?? null); |
|
| 60 | + } else { |
|
| 61 | + changer_langue($options['lang']); |
|
| 62 | + } |
|
| 63 | + http_no_cache(); |
|
| 64 | 64 | |
| 65 | - $page_title = (isset($options['page_title']) ? $options['page_title'] : $GLOBALS['meta']['nom_site']); |
|
| 66 | - $doctype = (isset($options['doctype']) ? $options['doctype'] : "<!DOCTYPE html>"); |
|
| 67 | - $doctype = trim($doctype) . "\n"; |
|
| 68 | - $charset = (isset($options['charset']) ? $options['charset'] : "utf-8"); |
|
| 69 | - $all_inline = (isset($options['all_inline']) ? $options['all_inline'] : true); |
|
| 70 | - $onLoad = (isset($options['onLoad']) ? $options['onLoad'] : ''); |
|
| 71 | - if ($onLoad) { |
|
| 72 | - $onLoad = ' onload="' . attribut_html($onLoad) . '"'; |
|
| 73 | - } |
|
| 65 | + $page_title = (isset($options['page_title']) ? $options['page_title'] : $GLOBALS['meta']['nom_site']); |
|
| 66 | + $doctype = (isset($options['doctype']) ? $options['doctype'] : "<!DOCTYPE html>"); |
|
| 67 | + $doctype = trim($doctype) . "\n"; |
|
| 68 | + $charset = (isset($options['charset']) ? $options['charset'] : "utf-8"); |
|
| 69 | + $all_inline = (isset($options['all_inline']) ? $options['all_inline'] : true); |
|
| 70 | + $onLoad = (isset($options['onLoad']) ? $options['onLoad'] : ''); |
|
| 71 | + if ($onLoad) { |
|
| 72 | + $onLoad = ' onload="' . attribut_html($onLoad) . '"'; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - # envoyer le charset |
|
| 76 | - if (!headers_sent()) { |
|
| 77 | - header('Content-Type: text/html; charset=' . $charset); |
|
| 78 | - } |
|
| 75 | + # envoyer le charset |
|
| 76 | + if (!headers_sent()) { |
|
| 77 | + header('Content-Type: text/html; charset=' . $charset); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - $css = ''; |
|
| 80 | + $css = ''; |
|
| 81 | 81 | |
| 82 | - if (function_exists('couleur_hex_to_hsl')) { |
|
| 83 | - if (!empty($options['couleur_fond'])) { |
|
| 84 | - $couleur_fond = $options['couleur_fond']; |
|
| 85 | - } else { |
|
| 86 | - $couleur_fond = lire_config("couleur_login", "#db1762"); |
|
| 87 | - } |
|
| 88 | - $h = couleur_hex_to_hsl($couleur_fond, "h"); |
|
| 89 | - $s = couleur_hex_to_hsl($couleur_fond, "s"); |
|
| 90 | - $l = couleur_hex_to_hsl($couleur_fond, "l"); |
|
| 91 | - } |
|
| 82 | + if (function_exists('couleur_hex_to_hsl')) { |
|
| 83 | + if (!empty($options['couleur_fond'])) { |
|
| 84 | + $couleur_fond = $options['couleur_fond']; |
|
| 85 | + } else { |
|
| 86 | + $couleur_fond = lire_config("couleur_login", "#db1762"); |
|
| 87 | + } |
|
| 88 | + $h = couleur_hex_to_hsl($couleur_fond, "h"); |
|
| 89 | + $s = couleur_hex_to_hsl($couleur_fond, "s"); |
|
| 90 | + $l = couleur_hex_to_hsl($couleur_fond, "l"); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $inline = ":root {" |
|
| 94 | - . "--minipublic-color-theme--h: $h;" |
|
| 95 | - . "--minipublic-color-theme--s: $s;" |
|
| 96 | - . "--minipublic-color-theme--l: $l;}"; |
|
| 97 | - $vars = file_get_contents(find_in_theme('minipublic.vars.css')); |
|
| 98 | - $inline .= "\n" . trim($vars); |
|
| 99 | - if (function_exists('minifier')) { |
|
| 100 | - $inline = minifier($inline, 'css'); |
|
| 101 | - } |
|
| 102 | - $files = [ |
|
| 103 | - find_in_theme('reset.css'), |
|
| 104 | - find_in_theme('clear.css'), |
|
| 105 | - find_in_theme('minipublic.css'), |
|
| 106 | - ]; |
|
| 107 | - if (!empty($options['css_files'])) { |
|
| 108 | - foreach ($options['css_files'] as $css_file) { |
|
| 109 | - $files[] = $css_file; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - if ($all_inline) { |
|
| 113 | - // inliner les CSS (optimisation de la page minipublic qui passe en un seul hit a la demande) |
|
| 114 | - foreach ($files as $name) { |
|
| 115 | - $file = direction_css($name); |
|
| 116 | - if (function_exists('minifier')) { |
|
| 117 | - $file = minifier($file); |
|
| 118 | - } else { |
|
| 119 | - $file = url_absolue_css($file); // precaution |
|
| 120 | - } |
|
| 121 | - $css .= file_get_contents($file); |
|
| 122 | - } |
|
| 123 | - $css = "$inline\n$css"; |
|
| 124 | - if (!empty($options['css'])) { |
|
| 125 | - $css .= "\n" . $options['css']; |
|
| 126 | - } |
|
| 127 | - $css = "<style type='text/css'>$css</style>"; |
|
| 128 | - } else { |
|
| 129 | - $css = "<style type='text/css'>$inline</style>"; |
|
| 130 | - foreach ($files as $name) { |
|
| 131 | - $file = timestamp(direction_css($name)); |
|
| 132 | - $css .= "<link rel='stylesheet' href='" . attribut_html($file) . "' type='text/css' />\n"; |
|
| 133 | - } |
|
| 134 | - if (!empty($options['css'])) { |
|
| 135 | - $css .= "<style type='text/css'>" . $options['css'] . "</style>"; |
|
| 136 | - } |
|
| 137 | - } |
|
| 93 | + $inline = ":root {" |
|
| 94 | + . "--minipublic-color-theme--h: $h;" |
|
| 95 | + . "--minipublic-color-theme--s: $s;" |
|
| 96 | + . "--minipublic-color-theme--l: $l;}"; |
|
| 97 | + $vars = file_get_contents(find_in_theme('minipublic.vars.css')); |
|
| 98 | + $inline .= "\n" . trim($vars); |
|
| 99 | + if (function_exists('minifier')) { |
|
| 100 | + $inline = minifier($inline, 'css'); |
|
| 101 | + } |
|
| 102 | + $files = [ |
|
| 103 | + find_in_theme('reset.css'), |
|
| 104 | + find_in_theme('clear.css'), |
|
| 105 | + find_in_theme('minipublic.css'), |
|
| 106 | + ]; |
|
| 107 | + if (!empty($options['css_files'])) { |
|
| 108 | + foreach ($options['css_files'] as $css_file) { |
|
| 109 | + $files[] = $css_file; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + if ($all_inline) { |
|
| 113 | + // inliner les CSS (optimisation de la page minipublic qui passe en un seul hit a la demande) |
|
| 114 | + foreach ($files as $name) { |
|
| 115 | + $file = direction_css($name); |
|
| 116 | + if (function_exists('minifier')) { |
|
| 117 | + $file = minifier($file); |
|
| 118 | + } else { |
|
| 119 | + $file = url_absolue_css($file); // precaution |
|
| 120 | + } |
|
| 121 | + $css .= file_get_contents($file); |
|
| 122 | + } |
|
| 123 | + $css = "$inline\n$css"; |
|
| 124 | + if (!empty($options['css'])) { |
|
| 125 | + $css .= "\n" . $options['css']; |
|
| 126 | + } |
|
| 127 | + $css = "<style type='text/css'>$css</style>"; |
|
| 128 | + } else { |
|
| 129 | + $css = "<style type='text/css'>$inline</style>"; |
|
| 130 | + foreach ($files as $name) { |
|
| 131 | + $file = timestamp(direction_css($name)); |
|
| 132 | + $css .= "<link rel='stylesheet' href='" . attribut_html($file) . "' type='text/css' />\n"; |
|
| 133 | + } |
|
| 134 | + if (!empty($options['css'])) { |
|
| 135 | + $css .= "<style type='text/css'>" . $options['css'] . "</style>"; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - return $doctype . |
|
| 140 | - html_lang_attributes() . |
|
| 141 | - "<head>\n" . |
|
| 142 | - '<title>' . |
|
| 143 | - textebrut($page_title) . |
|
| 144 | - "</title>\n" . |
|
| 145 | - "<meta name=\"viewport\" content=\"width=device-width\" />\n" . |
|
| 146 | - $css . |
|
| 147 | - (empty($options['head']) ? "" : $options['head']) . |
|
| 148 | - "</head>\n" . |
|
| 149 | - "<body{$onLoad} class=\"minipublic\">\n" . |
|
| 150 | - "\t<div class=\"minipublic-bloc\">\n"; |
|
| 151 | - } |
|
| 139 | + return $doctype . |
|
| 140 | + html_lang_attributes() . |
|
| 141 | + "<head>\n" . |
|
| 142 | + '<title>' . |
|
| 143 | + textebrut($page_title) . |
|
| 144 | + "</title>\n" . |
|
| 145 | + "<meta name=\"viewport\" content=\"width=device-width\" />\n" . |
|
| 146 | + $css . |
|
| 147 | + (empty($options['head']) ? "" : $options['head']) . |
|
| 148 | + "</head>\n" . |
|
| 149 | + "<body{$onLoad} class=\"minipublic\">\n" . |
|
| 150 | + "\t<div class=\"minipublic-bloc\">\n"; |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Ouvre le corps : affiche le header avec un éventuel titre + ouvre le div corps |
|
| 155 | - * @param $options |
|
| 156 | - * @return string |
|
| 157 | - */ |
|
| 158 | - protected function ouvreCorps($options = []) { |
|
| 159 | - $url_site = url_de_base(); |
|
| 160 | - $header = "<header>\n" . |
|
| 161 | - "<h1><a href=\"" . attribut_html($url_site) . "\">" . interdire_scripts($GLOBALS['meta']['nom_site'] ?? '') . "</a></h1>\n"; |
|
| 153 | + /** |
|
| 154 | + * Ouvre le corps : affiche le header avec un éventuel titre + ouvre le div corps |
|
| 155 | + * @param $options |
|
| 156 | + * @return string |
|
| 157 | + */ |
|
| 158 | + protected function ouvreCorps($options = []) { |
|
| 159 | + $url_site = url_de_base(); |
|
| 160 | + $header = "<header>\n" . |
|
| 161 | + "<h1><a href=\"" . attribut_html($url_site) . "\">" . interdire_scripts($GLOBALS['meta']['nom_site'] ?? '') . "</a></h1>\n"; |
|
| 162 | 162 | |
| 163 | - $titre = (isset($options['titre']) ? $options['titre'] : ''); |
|
| 164 | - if ($titre) { |
|
| 165 | - $header .= "<h2>" . interdire_scripts($titre) . "</h2>"; |
|
| 166 | - } |
|
| 167 | - $header .= "</header>"; |
|
| 163 | + $titre = (isset($options['titre']) ? $options['titre'] : ''); |
|
| 164 | + if ($titre) { |
|
| 165 | + $header .= "<h2>" . interdire_scripts($titre) . "</h2>"; |
|
| 166 | + } |
|
| 167 | + $header .= "</header>"; |
|
| 168 | 168 | |
| 169 | - return $header . "<div class='corps'>\n"; |
|
| 170 | - } |
|
| 169 | + return $header . "<div class='corps'>\n"; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Ferme le corps : affiche le footer par défaut ou custom et ferme le div corps |
|
| 174 | - * @param $options |
|
| 175 | - * @return string |
|
| 176 | - */ |
|
| 177 | - protected function fermeCorps($options = []) { |
|
| 178 | - $url_site = url_de_base(); |
|
| 172 | + /** |
|
| 173 | + * Ferme le corps : affiche le footer par défaut ou custom et ferme le div corps |
|
| 174 | + * @param $options |
|
| 175 | + * @return string |
|
| 176 | + */ |
|
| 177 | + protected function fermeCorps($options = []) { |
|
| 178 | + $url_site = url_de_base(); |
|
| 179 | 179 | |
| 180 | - if (isset($options['footer'])) { |
|
| 181 | - $footer = $options['footer']; |
|
| 182 | - } else { |
|
| 183 | - $footer = "<a href=\"" . attribut_html($url_site) . "\">" . _T('retour') . "</a>\n"; |
|
| 184 | - } |
|
| 185 | - if (!empty($footer)) { |
|
| 186 | - $footer = "<footer>\n{$footer}</footer>"; |
|
| 187 | - } |
|
| 180 | + if (isset($options['footer'])) { |
|
| 181 | + $footer = $options['footer']; |
|
| 182 | + } else { |
|
| 183 | + $footer = "<a href=\"" . attribut_html($url_site) . "\">" . _T('retour') . "</a>\n"; |
|
| 184 | + } |
|
| 185 | + if (!empty($footer)) { |
|
| 186 | + $footer = "<footer>\n{$footer}</footer>"; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - return "</div>\n" . $footer; |
|
| 190 | - } |
|
| 189 | + return "</div>\n" . $footer; |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Retourne la fin d'une page HTML minimale |
|
| 195 | - * |
|
| 196 | - * @return string Code HTML |
|
| 197 | - */ |
|
| 198 | - protected function fermeBody() { |
|
| 199 | - return "\n\t</div>\n</body>\n</html>"; |
|
| 200 | - } |
|
| 193 | + /** |
|
| 194 | + * Retourne la fin d'une page HTML minimale |
|
| 195 | + * |
|
| 196 | + * @return string Code HTML |
|
| 197 | + */ |
|
| 198 | + protected function fermeBody() { |
|
| 199 | + return "\n\t</div>\n</body>\n</html>"; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | 202 | |
| 203 | - /** |
|
| 204 | - * Retourne une page HTML contenant, dans une présentation minimale, |
|
| 205 | - * le contenu transmis dans `$corps`. |
|
| 206 | - * |
|
| 207 | - * Appelée pour afficher un message ou une demande de confirmation simple et rapide |
|
| 208 | - * |
|
| 209 | - * @param string $corps |
|
| 210 | - * Corps de la page |
|
| 211 | - * @param array $options |
|
| 212 | - * @return string |
|
| 213 | - * HTML de la page |
|
| 214 | - * @see ouvreBody() |
|
| 215 | - * @see ouvreCorps() |
|
| 216 | - * string $titre : Titre à l'affichage (différent de $page_title) |
|
| 217 | - * int $status : status de la page |
|
| 218 | - * string $footer : pied de la box en remplacement du bouton retour par défaut |
|
| 219 | - * @uses ouvreBody() |
|
| 220 | - * @uses ouvreCorps() |
|
| 221 | - * @uses fermeCorps() |
|
| 222 | - * @uses fermeBody() |
|
| 223 | - * |
|
| 224 | - */ |
|
| 225 | - public function page($corps, $options = []) { |
|
| 203 | + /** |
|
| 204 | + * Retourne une page HTML contenant, dans une présentation minimale, |
|
| 205 | + * le contenu transmis dans `$corps`. |
|
| 206 | + * |
|
| 207 | + * Appelée pour afficher un message ou une demande de confirmation simple et rapide |
|
| 208 | + * |
|
| 209 | + * @param string $corps |
|
| 210 | + * Corps de la page |
|
| 211 | + * @param array $options |
|
| 212 | + * @return string |
|
| 213 | + * HTML de la page |
|
| 214 | + * @see ouvreBody() |
|
| 215 | + * @see ouvreCorps() |
|
| 216 | + * string $titre : Titre à l'affichage (différent de $page_title) |
|
| 217 | + * int $status : status de la page |
|
| 218 | + * string $footer : pied de la box en remplacement du bouton retour par défaut |
|
| 219 | + * @uses ouvreBody() |
|
| 220 | + * @uses ouvreCorps() |
|
| 221 | + * @uses fermeCorps() |
|
| 222 | + * @uses fermeBody() |
|
| 223 | + * |
|
| 224 | + */ |
|
| 225 | + public function page($corps, $options = []) { |
|
| 226 | 226 | |
| 227 | - // par securite |
|
| 228 | - if (!defined('_AJAX')) { |
|
| 229 | - define('_AJAX', false); |
|
| 230 | - } |
|
| 227 | + // par securite |
|
| 228 | + if (!defined('_AJAX')) { |
|
| 229 | + define('_AJAX', false); |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - $status = ((int) ($options['status'] ?? 200)) ?: 200; |
|
| 232 | + $status = ((int) ($options['status'] ?? 200)) ?: 200; |
|
| 233 | 233 | |
| 234 | - http_response_code($status); |
|
| 234 | + http_response_code($status); |
|
| 235 | 235 | |
| 236 | - $html = $this->ouvreBody($options) |
|
| 237 | - . $this->ouvreCorps($options) |
|
| 238 | - . $corps |
|
| 239 | - . $this->fermeCorps($options) |
|
| 240 | - . $this->fermeBody(); |
|
| 236 | + $html = $this->ouvreBody($options) |
|
| 237 | + . $this->ouvreCorps($options) |
|
| 238 | + . $corps |
|
| 239 | + . $this->fermeCorps($options) |
|
| 240 | + . $this->fermeBody(); |
|
| 241 | 241 | |
| 242 | - if ( |
|
| 243 | - $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 244 | - and empty($options['all_inline']) |
|
| 245 | - ) { |
|
| 246 | - define('_SET_HTML_BASE', true); |
|
| 247 | - include_spip('public/assembler'); |
|
| 248 | - $GLOBALS['html'] = true; |
|
| 249 | - page_base_href($html); |
|
| 250 | - } |
|
| 251 | - return $html; |
|
| 252 | - } |
|
| 242 | + if ( |
|
| 243 | + $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 244 | + and empty($options['all_inline']) |
|
| 245 | + ) { |
|
| 246 | + define('_SET_HTML_BASE', true); |
|
| 247 | + include_spip('public/assembler'); |
|
| 248 | + $GLOBALS['html'] = true; |
|
| 249 | + page_base_href($html); |
|
| 250 | + } |
|
| 251 | + return $html; |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - /** |
|
| 255 | - * Fonction helper pour les erreurs |
|
| 256 | - * @param ?string $message_erreur |
|
| 257 | - * @param array $options |
|
| 258 | - * @see page() |
|
| 259 | - * @return string |
|
| 260 | - * |
|
| 261 | - */ |
|
| 262 | - public function pageErreur($message_erreur = null, $options = []) { |
|
| 254 | + /** |
|
| 255 | + * Fonction helper pour les erreurs |
|
| 256 | + * @param ?string $message_erreur |
|
| 257 | + * @param array $options |
|
| 258 | + * @see page() |
|
| 259 | + * @return string |
|
| 260 | + * |
|
| 261 | + */ |
|
| 262 | + public function pageErreur($message_erreur = null, $options = []) { |
|
| 263 | 263 | |
| 264 | - if (empty($message_erreur)) { |
|
| 265 | - if (empty($options['lang'])) { |
|
| 266 | - utiliser_langue_visiteur(); |
|
| 267 | - } else { |
|
| 268 | - changer_langue($options['lang']); |
|
| 269 | - } |
|
| 270 | - $message_erreur = _T('info_acces_interdit'); |
|
| 271 | - } |
|
| 272 | - $corps = "<div class='msg-alert error'>" |
|
| 273 | - . $message_erreur |
|
| 274 | - . "</div>"; |
|
| 275 | - if (empty($options['status'])) { |
|
| 276 | - $options['status'] = 403; |
|
| 277 | - } |
|
| 278 | - return $this->page($corps, $options); |
|
| 279 | - } |
|
| 264 | + if (empty($message_erreur)) { |
|
| 265 | + if (empty($options['lang'])) { |
|
| 266 | + utiliser_langue_visiteur(); |
|
| 267 | + } else { |
|
| 268 | + changer_langue($options['lang']); |
|
| 269 | + } |
|
| 270 | + $message_erreur = _T('info_acces_interdit'); |
|
| 271 | + } |
|
| 272 | + $corps = "<div class='msg-alert error'>" |
|
| 273 | + . $message_erreur |
|
| 274 | + . "</div>"; |
|
| 275 | + if (empty($options['status'])) { |
|
| 276 | + $options['status'] = 403; |
|
| 277 | + } |
|
| 278 | + return $this->page($corps, $options); |
|
| 279 | + } |
|
| 280 | 280 | } |
@@ -64,17 +64,17 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $page_title = (isset($options['page_title']) ? $options['page_title'] : $GLOBALS['meta']['nom_site']); |
| 66 | 66 | $doctype = (isset($options['doctype']) ? $options['doctype'] : "<!DOCTYPE html>"); |
| 67 | - $doctype = trim($doctype) . "\n"; |
|
| 67 | + $doctype = trim($doctype)."\n"; |
|
| 68 | 68 | $charset = (isset($options['charset']) ? $options['charset'] : "utf-8"); |
| 69 | 69 | $all_inline = (isset($options['all_inline']) ? $options['all_inline'] : true); |
| 70 | 70 | $onLoad = (isset($options['onLoad']) ? $options['onLoad'] : ''); |
| 71 | 71 | if ($onLoad) { |
| 72 | - $onLoad = ' onload="' . attribut_html($onLoad) . '"'; |
|
| 72 | + $onLoad = ' onload="'.attribut_html($onLoad).'"'; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | # envoyer le charset |
| 76 | 76 | if (!headers_sent()) { |
| 77 | - header('Content-Type: text/html; charset=' . $charset); |
|
| 77 | + header('Content-Type: text/html; charset='.$charset); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $css = ''; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | . "--minipublic-color-theme--s: $s;" |
| 96 | 96 | . "--minipublic-color-theme--l: $l;}"; |
| 97 | 97 | $vars = file_get_contents(find_in_theme('minipublic.vars.css')); |
| 98 | - $inline .= "\n" . trim($vars); |
|
| 98 | + $inline .= "\n".trim($vars); |
|
| 99 | 99 | if (function_exists('minifier')) { |
| 100 | 100 | $inline = minifier($inline, 'css'); |
| 101 | 101 | } |
@@ -122,31 +122,31 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | $css = "$inline\n$css"; |
| 124 | 124 | if (!empty($options['css'])) { |
| 125 | - $css .= "\n" . $options['css']; |
|
| 125 | + $css .= "\n".$options['css']; |
|
| 126 | 126 | } |
| 127 | 127 | $css = "<style type='text/css'>$css</style>"; |
| 128 | 128 | } else { |
| 129 | 129 | $css = "<style type='text/css'>$inline</style>"; |
| 130 | 130 | foreach ($files as $name) { |
| 131 | 131 | $file = timestamp(direction_css($name)); |
| 132 | - $css .= "<link rel='stylesheet' href='" . attribut_html($file) . "' type='text/css' />\n"; |
|
| 132 | + $css .= "<link rel='stylesheet' href='".attribut_html($file)."' type='text/css' />\n"; |
|
| 133 | 133 | } |
| 134 | 134 | if (!empty($options['css'])) { |
| 135 | - $css .= "<style type='text/css'>" . $options['css'] . "</style>"; |
|
| 135 | + $css .= "<style type='text/css'>".$options['css']."</style>"; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - return $doctype . |
|
| 140 | - html_lang_attributes() . |
|
| 141 | - "<head>\n" . |
|
| 142 | - '<title>' . |
|
| 143 | - textebrut($page_title) . |
|
| 144 | - "</title>\n" . |
|
| 145 | - "<meta name=\"viewport\" content=\"width=device-width\" />\n" . |
|
| 146 | - $css . |
|
| 147 | - (empty($options['head']) ? "" : $options['head']) . |
|
| 148 | - "</head>\n" . |
|
| 149 | - "<body{$onLoad} class=\"minipublic\">\n" . |
|
| 139 | + return $doctype. |
|
| 140 | + html_lang_attributes(). |
|
| 141 | + "<head>\n". |
|
| 142 | + '<title>'. |
|
| 143 | + textebrut($page_title). |
|
| 144 | + "</title>\n". |
|
| 145 | + "<meta name=\"viewport\" content=\"width=device-width\" />\n". |
|
| 146 | + $css. |
|
| 147 | + (empty($options['head']) ? "" : $options['head']). |
|
| 148 | + "</head>\n". |
|
| 149 | + "<body{$onLoad} class=\"minipublic\">\n". |
|
| 150 | 150 | "\t<div class=\"minipublic-bloc\">\n"; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | protected function ouvreCorps($options = []) { |
| 159 | 159 | $url_site = url_de_base(); |
| 160 | - $header = "<header>\n" . |
|
| 161 | - "<h1><a href=\"" . attribut_html($url_site) . "\">" . interdire_scripts($GLOBALS['meta']['nom_site'] ?? '') . "</a></h1>\n"; |
|
| 160 | + $header = "<header>\n". |
|
| 161 | + "<h1><a href=\"".attribut_html($url_site)."\">".interdire_scripts($GLOBALS['meta']['nom_site'] ?? '')."</a></h1>\n"; |
|
| 162 | 162 | |
| 163 | 163 | $titre = (isset($options['titre']) ? $options['titre'] : ''); |
| 164 | 164 | if ($titre) { |
| 165 | - $header .= "<h2>" . interdire_scripts($titre) . "</h2>"; |
|
| 165 | + $header .= "<h2>".interdire_scripts($titre)."</h2>"; |
|
| 166 | 166 | } |
| 167 | 167 | $header .= "</header>"; |
| 168 | 168 | |
| 169 | - return $header . "<div class='corps'>\n"; |
|
| 169 | + return $header."<div class='corps'>\n"; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | if (isset($options['footer'])) { |
| 181 | 181 | $footer = $options['footer']; |
| 182 | 182 | } else { |
| 183 | - $footer = "<a href=\"" . attribut_html($url_site) . "\">" . _T('retour') . "</a>\n"; |
|
| 183 | + $footer = "<a href=\"".attribut_html($url_site)."\">"._T('retour')."</a>\n"; |
|
| 184 | 184 | } |
| 185 | 185 | if (!empty($footer)) { |
| 186 | 186 | $footer = "<footer>\n{$footer}</footer>"; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - return "</div>\n" . $footer; |
|
| 189 | + return "</div>\n".$footer; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | * @return void |
| 43 | 43 | **/ |
| 44 | 44 | function install_fichier_connexion($nom, $texte) { |
| 45 | - $texte = '<' . "?php\n" |
|
| 46 | - . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 47 | - . $texte; |
|
| 45 | + $texte = '<' . "?php\n" |
|
| 46 | + . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n" |
|
| 47 | + . $texte; |
|
| 48 | 48 | |
| 49 | - ecrire_fichier($nom, $texte); |
|
| 49 | + ecrire_fichier($nom, $texte); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -75,20 +75,20 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | **/ |
| 77 | 77 | function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') { |
| 78 | - $adr = addcslashes($adr, "'\\"); |
|
| 79 | - $port = addcslashes($port, "'\\"); |
|
| 80 | - $login = addcslashes($login, "'\\"); |
|
| 81 | - $pass = addcslashes($pass, "'\\"); |
|
| 82 | - $base = addcslashes($base, "'\\"); |
|
| 83 | - $type = addcslashes($type, "'\\"); |
|
| 84 | - $pref = addcslashes($pref, "'\\"); |
|
| 85 | - $ldap = addcslashes($ldap, "'\\"); |
|
| 86 | - $charset = addcslashes($charset, "'\\"); |
|
| 87 | - |
|
| 88 | - return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 89 | - . 'spip_connect_db(' |
|
| 90 | - . "'$adr','$port','$login','$pass','$base'" |
|
| 91 | - . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 78 | + $adr = addcslashes($adr, "'\\"); |
|
| 79 | + $port = addcslashes($port, "'\\"); |
|
| 80 | + $login = addcslashes($login, "'\\"); |
|
| 81 | + $pass = addcslashes($pass, "'\\"); |
|
| 82 | + $base = addcslashes($base, "'\\"); |
|
| 83 | + $type = addcslashes($type, "'\\"); |
|
| 84 | + $pref = addcslashes($pref, "'\\"); |
|
| 85 | + $ldap = addcslashes($ldap, "'\\"); |
|
| 86 | + $charset = addcslashes($charset, "'\\"); |
|
| 87 | + |
|
| 88 | + return "\$GLOBALS['spip_connect_version'] = 0.8;\n" |
|
| 89 | + . 'spip_connect_db(' |
|
| 90 | + . "'$adr','$port','$login','$pass','$base'" |
|
| 91 | + . ",'$type', '$pref','$ldap','$charset');\n"; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
@@ -104,29 +104,29 @@ discard block |
||
| 104 | 104 | * Tableau des informations sur la connexion |
| 105 | 105 | **/ |
| 106 | 106 | function analyse_fichier_connection(string $file): array { |
| 107 | - if (!file_exists($file)) { |
|
| 108 | - return []; |
|
| 109 | - } |
|
| 110 | - $s = file_get_contents($file); |
|
| 111 | - if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 112 | - array_shift($regs); |
|
| 113 | - |
|
| 114 | - return $regs; |
|
| 115 | - } else { |
|
| 116 | - $ar = '\s*\'([^\']*)\''; |
|
| 117 | - $r = '\s*,' . $ar; |
|
| 118 | - $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 119 | - if (preg_match($r, $s, $regs)) { |
|
| 120 | - $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';'); |
|
| 121 | - array_shift($regs); |
|
| 122 | - array_shift($regs); |
|
| 123 | - |
|
| 124 | - return $regs; |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - spip_log("$file n'est pas un fichier de connexion"); |
|
| 128 | - |
|
| 129 | - return []; |
|
| 107 | + if (!file_exists($file)) { |
|
| 108 | + return []; |
|
| 109 | + } |
|
| 110 | + $s = file_get_contents($file); |
|
| 111 | + if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { |
|
| 112 | + array_shift($regs); |
|
| 113 | + |
|
| 114 | + return $regs; |
|
| 115 | + } else { |
|
| 116 | + $ar = '\s*\'([^\']*)\''; |
|
| 117 | + $r = '\s*,' . $ar; |
|
| 118 | + $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#"; |
|
| 119 | + if (preg_match($r, $s, $regs)) { |
|
| 120 | + $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';'); |
|
| 121 | + array_shift($regs); |
|
| 122 | + array_shift($regs); |
|
| 123 | + |
|
| 124 | + return $regs; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + spip_log("$file n'est pas un fichier de connexion"); |
|
| 128 | + |
|
| 129 | + return []; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -143,75 +143,75 @@ discard block |
||
| 143 | 143 | * Liste des noms de connecteurs |
| 144 | 144 | **/ |
| 145 | 145 | function bases_referencees($exclu = '') { |
| 146 | - $tables = []; |
|
| 147 | - foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 148 | - if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 149 | - $tables[] = basename($f, '.php'); |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - return $tables; |
|
| 146 | + $tables = []; |
|
| 147 | + foreach (preg_files(_DIR_CONNECT, '.php$') as $f) { |
|
| 148 | + if ($f != $exclu and analyse_fichier_connection($f)) { |
|
| 149 | + $tables[] = basename($f, '.php'); |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return $tables; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
| 157 | 157 | function install_mode_appel($server_db, $tout = true) { |
| 158 | - return ($server_db != 'mysql') ? '' |
|
| 159 | - : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 160 | - . test_sql_mode_mysql($server_db)); |
|
| 158 | + return ($server_db != 'mysql') ? '' |
|
| 159 | + : (($tout ? test_rappel_nom_base_mysql($server_db) : '') |
|
| 160 | + . test_sql_mode_mysql($server_db)); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // |
| 164 | 164 | // Verifier que l'hebergement est compatible SPIP ... ou l'inverse :-) |
| 165 | 165 | // (sert a l'etape 1 de l'installation) |
| 166 | 166 | function tester_compatibilite_hebergement() { |
| 167 | - $err = []; |
|
| 168 | - |
|
| 169 | - $p = phpversion(); |
|
| 170 | - if (version_compare($p, _PHP_MIN, '<')) { |
|
| 171 | - $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]); |
|
| 172 | - } |
|
| 173 | - if (version_compare($p, _PHP_MAX, '>')) { |
|
| 174 | - $err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions()); |
|
| 178 | - if (!empty($diff)) { |
|
| 179 | - $err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 183 | - if ($err) { |
|
| 184 | - die("<div class='error'>" |
|
| 185 | - . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 186 | - . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - // Il faut une base de donnees tout de meme ... |
|
| 190 | - $serveurs = install_select_serveur(); |
|
| 191 | - if (!$serveurs) { |
|
| 192 | - $err[] = _T('install_extension_php_obligatoire') |
|
| 193 | - . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 194 | - . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 195 | - . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0) |
|
| 199 | - if ($a = @ini_get('mbstring.func_overload')) { |
|
| 200 | - $err[] = _T('install_extension_mbstring') |
|
| 201 | - . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - if ($err) { |
|
| 205 | - echo "<div class='error'>" |
|
| 206 | - . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 207 | - foreach ($err as $e) { |
|
| 208 | - echo "<li><strong>$e</strong></li>\n"; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 212 | - # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 213 | - echo "</ul></div>\n"; |
|
| 214 | - } |
|
| 167 | + $err = []; |
|
| 168 | + |
|
| 169 | + $p = phpversion(); |
|
| 170 | + if (version_compare($p, _PHP_MIN, '<')) { |
|
| 171 | + $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]); |
|
| 172 | + } |
|
| 173 | + if (version_compare($p, _PHP_MAX, '>')) { |
|
| 174 | + $err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions()); |
|
| 178 | + if (!empty($diff)) { |
|
| 179 | + $err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + // Si on n'a pas la bonne version de PHP, c'est la fin |
|
| 183 | + if ($err) { |
|
| 184 | + die("<div class='error'>" |
|
| 185 | + . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>" |
|
| 186 | + . "<li><strong>{$err[0]}</strong></li>\n</ul></div>"); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + // Il faut une base de donnees tout de meme ... |
|
| 190 | + $serveurs = install_select_serveur(); |
|
| 191 | + if (!$serveurs) { |
|
| 192 | + $err[] = _T('install_extension_php_obligatoire') |
|
| 193 | + . " <a href='http://www.php.net/mysql'>MYSQL</a>" |
|
| 194 | + . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>" |
|
| 195 | + . "| <a href='http://www.php.net/sqlite'>SQLite</a>"; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0) |
|
| 199 | + if ($a = @ini_get('mbstring.func_overload')) { |
|
| 200 | + $err[] = _T('install_extension_mbstring') |
|
| 201 | + . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>"; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + if ($err) { |
|
| 205 | + echo "<div class='error'>" |
|
| 206 | + . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"; |
|
| 207 | + foreach ($err as $e) { |
|
| 208 | + echo "<li><strong>$e</strong></li>\n"; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + # a priori ici on pourrait die(), mais il faut laisser la possibilite |
|
| 212 | + # de forcer malgre tout (pour tester, ou si bug de detection) |
|
| 213 | + echo "</ul></div>\n"; |
|
| 214 | + } |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -221,23 +221,23 @@ discard block |
||
| 221 | 221 | * @note superflu ?? |
| 222 | 222 | */ |
| 223 | 223 | function login_hebergeur() { |
| 224 | - $base_hebergeur = 'localhost'; # par defaut |
|
| 224 | + $base_hebergeur = 'localhost'; # par defaut |
|
| 225 | 225 | |
| 226 | - // Free |
|
| 227 | - if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 228 | - $base_hebergeur = 'sql.free.fr'; |
|
| 229 | - $login_hebergeur = $regs[1]; |
|
| 230 | - } else { |
|
| 231 | - $login_hebergeur = ''; |
|
| 232 | - } |
|
| 226 | + // Free |
|
| 227 | + if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) { |
|
| 228 | + $base_hebergeur = 'sql.free.fr'; |
|
| 229 | + $login_hebergeur = $regs[1]; |
|
| 230 | + } else { |
|
| 231 | + $login_hebergeur = ''; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - return [$base_hebergeur, $login_hebergeur]; |
|
| 234 | + return [$base_hebergeur, $login_hebergeur]; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
| 238 | 238 | function info_etape($titre, $complement = '') { |
| 239 | - return '<h2>' . $titre . "</h2>\n" . |
|
| 240 | - ($complement ? '' . $complement . "\n" : ''); |
|
| 239 | + return '<h2>' . $titre . "</h2>\n" . |
|
| 240 | + ($complement ? '' . $complement . "\n" : ''); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -247,155 +247,155 @@ discard block |
||
| 247 | 247 | * @return string Code HTML du bouton |
| 248 | 248 | **/ |
| 249 | 249 | function bouton_suivant($code = '') { |
| 250 | - if ($code == '') { |
|
| 251 | - $code = _T('bouton_suivant'); |
|
| 252 | - } |
|
| 253 | - static $suivant = 0; |
|
| 254 | - $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 255 | - $suivant += 1; |
|
| 256 | - |
|
| 257 | - return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 258 | - $code . |
|
| 259 | - " >>\" /></p>\n"; |
|
| 250 | + if ($code == '') { |
|
| 251 | + $code = _T('bouton_suivant'); |
|
| 252 | + } |
|
| 253 | + static $suivant = 0; |
|
| 254 | + $id = 'suivant' . (($suivant > 0) ? strval($suivant) : ''); |
|
| 255 | + $suivant += 1; |
|
| 256 | + |
|
| 257 | + return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" . |
|
| 258 | + $code . |
|
| 259 | + " >>\" /></p>\n"; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | function info_progression_etape($en_cours, $phase, $dir, $erreur = false) { |
| 263 | - $intitule_etat = []; |
|
| 264 | - //$en_cours = _request('etape')?_request('etape'):""; |
|
| 265 | - $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 266 | - $debut = 1; |
|
| 267 | - $etat = 'ok'; |
|
| 268 | - $last = count($liste); |
|
| 263 | + $intitule_etat = []; |
|
| 264 | + //$en_cours = _request('etape')?_request('etape'):""; |
|
| 265 | + $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$'); |
|
| 266 | + $debut = 1; |
|
| 267 | + $etat = 'ok'; |
|
| 268 | + $last = count($liste); |
|
| 269 | 269 | // $texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo')); |
| 270 | 270 | |
| 271 | - include_spip('inc/texte'); |
|
| 272 | - $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee')); |
|
| 273 | - $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 274 | - $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles')); |
|
| 275 | - $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape')); |
|
| 271 | + include_spip('inc/texte'); |
|
| 272 | + $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee')); |
|
| 273 | + $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base')); |
|
| 274 | + $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles')); |
|
| 275 | + $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape')); |
|
| 276 | 276 | |
| 277 | - $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap')); |
|
| 278 | - $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap')); |
|
| 279 | - $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1')); |
|
| 280 | - $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap')); |
|
| 281 | - $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok')); |
|
| 277 | + $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap')); |
|
| 278 | + $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap')); |
|
| 279 | + $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1')); |
|
| 280 | + $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap')); |
|
| 281 | + $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok')); |
|
| 282 | 282 | |
| 283 | 283 | // $aff_etapes = "<span id='etapes'>"; |
| 284 | 284 | |
| 285 | - $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 286 | - |
|
| 287 | - foreach ($liste as $etape => $fichier) { |
|
| 288 | - if ($debut < $last) { |
|
| 289 | - if ($debut == $en_cours && $erreur) { |
|
| 290 | - $class = 'on erreur'; |
|
| 291 | - } else { |
|
| 292 | - if ($debut == $en_cours) { |
|
| 293 | - $class = 'on'; |
|
| 294 | - } else { |
|
| 295 | - if ($debut > $en_cours) { |
|
| 296 | - $class = 'prochains'; |
|
| 297 | - } else { |
|
| 298 | - $class = 'valides'; |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 304 | - $aff_etapes .= ($debut == $en_cours) ? '<strong>' : ''; |
|
| 305 | - $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 306 | - $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 307 | - $aff_etapes .= ($debut == $en_cours) ? '</strong>' : ''; |
|
| 308 | - $aff_etapes .= '</div></li>'; |
|
| 309 | - } |
|
| 310 | - $debut++; |
|
| 311 | - } |
|
| 312 | - $aff_etapes .= '</ul>'; |
|
| 313 | - $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 314 | - |
|
| 315 | - return $aff_etapes; |
|
| 285 | + $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>"; |
|
| 286 | + |
|
| 287 | + foreach ($liste as $etape => $fichier) { |
|
| 288 | + if ($debut < $last) { |
|
| 289 | + if ($debut == $en_cours && $erreur) { |
|
| 290 | + $class = 'on erreur'; |
|
| 291 | + } else { |
|
| 292 | + if ($debut == $en_cours) { |
|
| 293 | + $class = 'on'; |
|
| 294 | + } else { |
|
| 295 | + if ($debut > $en_cours) { |
|
| 296 | + $class = 'prochains'; |
|
| 297 | + } else { |
|
| 298 | + $class = 'valides'; |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + $aff_etapes .= "<li class='$class'><div class='fond'>"; |
|
| 304 | + $aff_etapes .= ($debut == $en_cours) ? '<strong>' : ''; |
|
| 305 | + $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em> : </em>"; |
|
| 306 | + $aff_etapes .= $intitule_etat["$phase"][$debut]; |
|
| 307 | + $aff_etapes .= ($debut == $en_cours) ? '</strong>' : ''; |
|
| 308 | + $aff_etapes .= '</div></li>'; |
|
| 309 | + } |
|
| 310 | + $debut++; |
|
| 311 | + } |
|
| 312 | + $aff_etapes .= '</ul>'; |
|
| 313 | + $aff_etapes .= "<br class='nettoyeur' />\n"; |
|
| 314 | + |
|
| 315 | + return $aff_etapes; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | function fieldset($legend, $champs = [], $apres = '', $avant = '') { |
| 320 | - return "<fieldset>\n" . |
|
| 321 | - $avant . |
|
| 322 | - ($legend ? '<legend>' . $legend . "</legend>\n" : '') . |
|
| 323 | - fieldset_champs($champs) . |
|
| 324 | - $apres . |
|
| 325 | - "</fieldset>\n"; |
|
| 320 | + return "<fieldset>\n" . |
|
| 321 | + $avant . |
|
| 322 | + ($legend ? '<legend>' . $legend . "</legend>\n" : '') . |
|
| 323 | + fieldset_champs($champs) . |
|
| 324 | + $apres . |
|
| 325 | + "</fieldset>\n"; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | function fieldset_champs($champs = []) { |
| 329 | - $fieldset = ''; |
|
| 330 | - foreach ($champs as $nom => $contenu) { |
|
| 331 | - $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 332 | - $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 333 | - if (isset($contenu['alternatives'])) { |
|
| 334 | - $fieldset .= $contenu['label'] . "\n"; |
|
| 335 | - foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 336 | - $fieldset .= "<input type='radio' name='" . $nom . |
|
| 337 | - "' id='$nom-$valeur' value='$valeur'" |
|
| 338 | - . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 339 | - . "/>\n"; |
|
| 340 | - $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 341 | - } |
|
| 342 | - $fieldset .= "<br />\n"; |
|
| 343 | - } else { |
|
| 344 | - $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 345 | - $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 346 | - . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 347 | - . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '') |
|
| 348 | - . " />\n"; |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - return $fieldset; |
|
| 329 | + $fieldset = ''; |
|
| 330 | + foreach ($champs as $nom => $contenu) { |
|
| 331 | + $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text'); |
|
| 332 | + $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' "; |
|
| 333 | + if (isset($contenu['alternatives'])) { |
|
| 334 | + $fieldset .= $contenu['label'] . "\n"; |
|
| 335 | + foreach ($contenu['alternatives'] as $valeur => $label) { |
|
| 336 | + $fieldset .= "<input type='radio' name='" . $nom . |
|
| 337 | + "' id='$nom-$valeur' value='$valeur'" |
|
| 338 | + . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '') |
|
| 339 | + . "/>\n"; |
|
| 340 | + $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n"; |
|
| 341 | + } |
|
| 342 | + $fieldset .= "<br />\n"; |
|
| 343 | + } else { |
|
| 344 | + $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n"; |
|
| 345 | + $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'" |
|
| 346 | + . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '') |
|
| 347 | + . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '') |
|
| 348 | + . " />\n"; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + return $fieldset; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | function install_select_serveur() { |
| 356 | - $options = []; |
|
| 357 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 358 | - $d = opendir($dir); |
|
| 359 | - if (!$d) { |
|
| 360 | - return []; |
|
| 361 | - } |
|
| 362 | - while (($f = readdir($d)) !== false) { |
|
| 363 | - if ( |
|
| 364 | - (preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 365 | - and is_readable($f = $dir . $f) |
|
| 366 | - ) { |
|
| 367 | - require_once($f); |
|
| 368 | - $s = $s[1]; |
|
| 369 | - $v = 'spip_versions_' . $s; |
|
| 370 | - if (function_exists($v) and $v()) { |
|
| 371 | - $titre = _T("install_select_type_$s"); |
|
| 372 | - // proposer mysql par defaut si dispo |
|
| 373 | - $checked = ($s == 'mysql' ? " checked='checked'" : ''); |
|
| 374 | - $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 375 | - . "<label for='$s'>" . ($titre ?: $s) . '</label></li>'; |
|
| 376 | - } else { |
|
| 377 | - spip_log("$s: portage indisponible"); |
|
| 378 | - } |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - sort($options); |
|
| 382 | - |
|
| 383 | - return $options; |
|
| 356 | + $options = []; |
|
| 357 | + $dir = _DIR_RESTREINT . 'req/'; |
|
| 358 | + $d = opendir($dir); |
|
| 359 | + if (!$d) { |
|
| 360 | + return []; |
|
| 361 | + } |
|
| 362 | + while (($f = readdir($d)) !== false) { |
|
| 363 | + if ( |
|
| 364 | + (preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 365 | + and is_readable($f = $dir . $f) |
|
| 366 | + ) { |
|
| 367 | + require_once($f); |
|
| 368 | + $s = $s[1]; |
|
| 369 | + $v = 'spip_versions_' . $s; |
|
| 370 | + if (function_exists($v) and $v()) { |
|
| 371 | + $titre = _T("install_select_type_$s"); |
|
| 372 | + // proposer mysql par defaut si dispo |
|
| 373 | + $checked = ($s == 'mysql' ? " checked='checked'" : ''); |
|
| 374 | + $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>" |
|
| 375 | + . "<label for='$s'>" . ($titre ?: $s) . '</label></li>'; |
|
| 376 | + } else { |
|
| 377 | + spip_log("$s: portage indisponible"); |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + sort($options); |
|
| 382 | + |
|
| 383 | + return $options; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) { |
| 387 | - $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 388 | - |
|
| 389 | - return generer_form_ecrire('install', ( |
|
| 390 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 391 | - . $hidden |
|
| 392 | - . (_request('echec') ? |
|
| 393 | - ('<p><b>' . _T('avis_connexion_echec_1') . |
|
| 394 | - '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>') |
|
| 395 | - : '') |
|
| 396 | - |
|
| 397 | - . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 398 | - . http_script(' |
|
| 387 | + $server_db = (is_string($predef[0])) ? $predef[0] : ''; |
|
| 388 | + |
|
| 389 | + return generer_form_ecrire('install', ( |
|
| 390 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 391 | + . $hidden |
|
| 392 | + . (_request('echec') ? |
|
| 393 | + ('<p><b>' . _T('avis_connexion_echec_1') . |
|
| 394 | + '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>') |
|
| 395 | + : '') |
|
| 396 | + |
|
| 397 | + . ($jquery ? http_script('', 'jquery.js') : '') |
|
| 398 | + . http_script(' |
|
| 399 | 399 | jQuery(function($) { |
| 400 | 400 | $details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur"); |
| 401 | 401 | $("input[type=hidden][name=server_db]").each(function(){ |
@@ -428,145 +428,145 @@ discard block |
||
| 428 | 428 | }); |
| 429 | 429 | });') |
| 430 | 430 | |
| 431 | - . ($server_db |
|
| 432 | - ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 433 | - . (($predef[0]) |
|
| 434 | - ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 435 | - : '') |
|
| 436 | - : ('<fieldset><legend>' |
|
| 437 | - . _T('install_select_type_db') |
|
| 438 | - . '</legend>' |
|
| 439 | - . '<p class="explication">' |
|
| 440 | - . _T('install_types_db_connus') |
|
| 441 | - // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 442 | - // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 443 | - . '</p>' |
|
| 444 | - . "\n<div class='p'>\n<ul>\n" |
|
| 445 | - . join("\n", install_select_serveur()) |
|
| 446 | - . "\n</ul>\n</div></fieldset>") |
|
| 447 | - ) |
|
| 448 | - . '<div id="install_adresse_base_hebergeur">' |
|
| 449 | - . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 450 | - . ($predef[1] |
|
| 451 | - ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 452 | - : fieldset( |
|
| 453 | - _T('entree_base_donnee_1'), |
|
| 454 | - [ |
|
| 455 | - 'adresse_db' => [ |
|
| 456 | - 'label' => $db[1], |
|
| 457 | - 'valeur' => $db[0] |
|
| 458 | - ], |
|
| 459 | - ] |
|
| 460 | - ) |
|
| 461 | - ) |
|
| 462 | - . '</div>' |
|
| 463 | - |
|
| 464 | - . '<div id="install_login_base_hebergeur">' |
|
| 465 | - . ($predef[2] |
|
| 466 | - ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 467 | - : fieldset( |
|
| 468 | - _T('entree_login_connexion_1'), |
|
| 469 | - [ |
|
| 470 | - 'login_db' => [ |
|
| 471 | - 'label' => $login[1], |
|
| 472 | - 'valeur' => $login[0] |
|
| 473 | - ], |
|
| 474 | - ] |
|
| 475 | - ) |
|
| 476 | - ) |
|
| 477 | - . '</div>' |
|
| 478 | - |
|
| 479 | - . '<div id="install_pass_base_hebergeur">' |
|
| 480 | - . ($predef[3] |
|
| 481 | - ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 482 | - : fieldset( |
|
| 483 | - _T('entree_mot_passe_1'), |
|
| 484 | - [ |
|
| 485 | - 'pass_db' => [ |
|
| 486 | - 'label' => $pass[1], |
|
| 487 | - 'valeur' => $pass[0] |
|
| 488 | - ], |
|
| 489 | - ] |
|
| 490 | - ) |
|
| 491 | - ) |
|
| 492 | - . '</div>' |
|
| 493 | - |
|
| 494 | - . bouton_suivant())); |
|
| 431 | + . ($server_db |
|
| 432 | + ? '<input type="hidden" name="server_db" value="' . $server_db . '" />' |
|
| 433 | + . (($predef[0]) |
|
| 434 | + ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>') |
|
| 435 | + : '') |
|
| 436 | + : ('<fieldset><legend>' |
|
| 437 | + . _T('install_select_type_db') |
|
| 438 | + . '</legend>' |
|
| 439 | + . '<p class="explication">' |
|
| 440 | + . _T('install_types_db_connus') |
|
| 441 | + // Passer l'avertissement SQLIte en commentaire, on pourra facilement le supprimer par la suite sans changer les traductions. |
|
| 442 | + // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>' |
|
| 443 | + . '</p>' |
|
| 444 | + . "\n<div class='p'>\n<ul>\n" |
|
| 445 | + . join("\n", install_select_serveur()) |
|
| 446 | + . "\n</ul>\n</div></fieldset>") |
|
| 447 | + ) |
|
| 448 | + . '<div id="install_adresse_base_hebergeur">' |
|
| 449 | + . '<p>' . _T('texte_connexion_mysql') . '</p>' |
|
| 450 | + . ($predef[1] |
|
| 451 | + ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>' |
|
| 452 | + : fieldset( |
|
| 453 | + _T('entree_base_donnee_1'), |
|
| 454 | + [ |
|
| 455 | + 'adresse_db' => [ |
|
| 456 | + 'label' => $db[1], |
|
| 457 | + 'valeur' => $db[0] |
|
| 458 | + ], |
|
| 459 | + ] |
|
| 460 | + ) |
|
| 461 | + ) |
|
| 462 | + . '</div>' |
|
| 463 | + |
|
| 464 | + . '<div id="install_login_base_hebergeur">' |
|
| 465 | + . ($predef[2] |
|
| 466 | + ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>' |
|
| 467 | + : fieldset( |
|
| 468 | + _T('entree_login_connexion_1'), |
|
| 469 | + [ |
|
| 470 | + 'login_db' => [ |
|
| 471 | + 'label' => $login[1], |
|
| 472 | + 'valeur' => $login[0] |
|
| 473 | + ], |
|
| 474 | + ] |
|
| 475 | + ) |
|
| 476 | + ) |
|
| 477 | + . '</div>' |
|
| 478 | + |
|
| 479 | + . '<div id="install_pass_base_hebergeur">' |
|
| 480 | + . ($predef[3] |
|
| 481 | + ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>' |
|
| 482 | + : fieldset( |
|
| 483 | + _T('entree_mot_passe_1'), |
|
| 484 | + [ |
|
| 485 | + 'pass_db' => [ |
|
| 486 | + 'label' => $pass[1], |
|
| 487 | + 'valeur' => $pass[0] |
|
| 488 | + ], |
|
| 489 | + ] |
|
| 490 | + ) |
|
| 491 | + ) |
|
| 492 | + . '</div>' |
|
| 493 | + |
|
| 494 | + . bouton_suivant())); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | // 4 valeurs qu'on reconduit d'un script a l'autre |
| 498 | 498 | // sauf s'ils sont predefinis. |
| 499 | 499 | |
| 500 | 500 | function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) { |
| 501 | - return ((defined('_INSTALL_HOST_DB')) |
|
| 502 | - ? '' |
|
| 503 | - : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . '" />' |
|
| 504 | - ) |
|
| 505 | - . ((defined('_INSTALL_USER_DB')) |
|
| 506 | - ? '' |
|
| 507 | - : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />' |
|
| 508 | - ) |
|
| 509 | - . ((defined('_INSTALL_PASS_DB')) |
|
| 510 | - ? '' |
|
| 511 | - : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />' |
|
| 512 | - ) |
|
| 513 | - |
|
| 514 | - . ((defined('_INSTALL_SERVER_DB')) |
|
| 515 | - ? '' |
|
| 516 | - : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />' |
|
| 517 | - ); |
|
| 501 | + return ((defined('_INSTALL_HOST_DB')) |
|
| 502 | + ? '' |
|
| 503 | + : "\n<input type='hidden' name='adresse_db' value=\"" . spip_htmlspecialchars($adresse_db) . '" />' |
|
| 504 | + ) |
|
| 505 | + . ((defined('_INSTALL_USER_DB')) |
|
| 506 | + ? '' |
|
| 507 | + : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />' |
|
| 508 | + ) |
|
| 509 | + . ((defined('_INSTALL_PASS_DB')) |
|
| 510 | + ? '' |
|
| 511 | + : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />' |
|
| 512 | + ) |
|
| 513 | + |
|
| 514 | + . ((defined('_INSTALL_SERVER_DB')) |
|
| 515 | + ? '' |
|
| 516 | + : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />' |
|
| 517 | + ); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | // presentation des bases existantes |
| 521 | 521 | |
| 522 | 522 | function install_etape_liste_bases($server_db, $login_db, $disabled = []) { |
| 523 | - $bases = $checked = []; |
|
| 524 | - $noms = sql_listdbs($server_db); |
|
| 525 | - if (!$noms) { |
|
| 526 | - return ''; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - foreach ($noms as $nom) { |
|
| 530 | - $id = spip_htmlspecialchars($nom); |
|
| 531 | - $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 532 | - $base = ' name="choix_db" value="' |
|
| 533 | - . $nom |
|
| 534 | - . '"' |
|
| 535 | - . $dis |
|
| 536 | - . " type='radio' id='$id'"; |
|
| 537 | - $label = "<label for='$id'>" |
|
| 538 | - . ($dis ? "<i>$nom</i>" : $nom) |
|
| 539 | - . '</label>'; |
|
| 540 | - |
|
| 541 | - if ( |
|
| 542 | - !$checked and !$dis and |
|
| 543 | - (($nom == $login_db) or |
|
| 544 | - ($GLOBALS['table_prefix'] == $nom)) |
|
| 545 | - ) { |
|
| 546 | - $checked = "<input$base checked='checked' />\n$label"; |
|
| 547 | - } else { |
|
| 548 | - $bases[] = "<input$base />\n$label"; |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - if (!$bases && !$checked) { |
|
| 553 | - return false; |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - if ($checked) { |
|
| 557 | - array_unshift($bases, $checked); |
|
| 558 | - $checked = true; |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - return [$checked, $bases]; |
|
| 523 | + $bases = $checked = []; |
|
| 524 | + $noms = sql_listdbs($server_db); |
|
| 525 | + if (!$noms) { |
|
| 526 | + return ''; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + foreach ($noms as $nom) { |
|
| 530 | + $id = spip_htmlspecialchars($nom); |
|
| 531 | + $dis = in_array($nom, $disabled) ? " disabled='disabled'" : ''; |
|
| 532 | + $base = ' name="choix_db" value="' |
|
| 533 | + . $nom |
|
| 534 | + . '"' |
|
| 535 | + . $dis |
|
| 536 | + . " type='radio' id='$id'"; |
|
| 537 | + $label = "<label for='$id'>" |
|
| 538 | + . ($dis ? "<i>$nom</i>" : $nom) |
|
| 539 | + . '</label>'; |
|
| 540 | + |
|
| 541 | + if ( |
|
| 542 | + !$checked and !$dis and |
|
| 543 | + (($nom == $login_db) or |
|
| 544 | + ($GLOBALS['table_prefix'] == $nom)) |
|
| 545 | + ) { |
|
| 546 | + $checked = "<input$base checked='checked' />\n$label"; |
|
| 547 | + } else { |
|
| 548 | + $bases[] = "<input$base />\n$label"; |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + if (!$bases && !$checked) { |
|
| 553 | + return false; |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + if ($checked) { |
|
| 557 | + array_unshift($bases, $checked); |
|
| 558 | + $checked = true; |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + return [$checked, $bases]; |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | function install_propager($hidden) { |
| 565 | - $res = ''; |
|
| 566 | - foreach ($hidden as $k) { |
|
| 567 | - $v = spip_htmlentities(_request($k)); |
|
| 568 | - $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 569 | - } |
|
| 565 | + $res = ''; |
|
| 566 | + foreach ($hidden as $k) { |
|
| 567 | + $v = spip_htmlentities(_request($k)); |
|
| 568 | + $res .= "<input type='hidden' name='$k' value='$v' />"; |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | - return $res; |
|
| 571 | + return $res; |
|
| 572 | 572 | } |