@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | 30 | function inc_config_dist() { |
| 31 | - actualise_metas(liste_metas()); |
|
| 31 | + actualise_metas(liste_metas()); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -45,34 +45,34 @@ discard block |
||
| 45 | 45 | * Liste (table, casier, sous_casier) |
| 46 | 46 | */ |
| 47 | 47 | function expliquer_config($cfg) { |
| 48 | - // par defaut, sur la table des meta |
|
| 49 | - $table = 'meta'; |
|
| 50 | - $casier = null; |
|
| 51 | - $sous_casier = []; |
|
| 52 | - $cfg = explode('/', $cfg); |
|
| 53 | - |
|
| 54 | - // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 55 | - if (!reset($cfg) and count($cfg) > 1) { |
|
| 56 | - array_shift($cfg); |
|
| 57 | - $table = array_shift($cfg); |
|
| 58 | - if (!isset($GLOBALS[$table])) { |
|
| 59 | - lire_metas($table); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 64 | - if (count($cfg)) { |
|
| 65 | - // pas sur un appel vide '' |
|
| 66 | - if ('' !== ($c = array_shift($cfg))) { |
|
| 67 | - $casier = $c; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - if (count($cfg)) { |
|
| 72 | - $sous_casier = $cfg; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return [$table, $casier, $sous_casier]; |
|
| 48 | + // par defaut, sur la table des meta |
|
| 49 | + $table = 'meta'; |
|
| 50 | + $casier = null; |
|
| 51 | + $sous_casier = []; |
|
| 52 | + $cfg = explode('/', $cfg); |
|
| 53 | + |
|
| 54 | + // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 55 | + if (!reset($cfg) and count($cfg) > 1) { |
|
| 56 | + array_shift($cfg); |
|
| 57 | + $table = array_shift($cfg); |
|
| 58 | + if (!isset($GLOBALS[$table])) { |
|
| 59 | + lire_metas($table); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 64 | + if (count($cfg)) { |
|
| 65 | + // pas sur un appel vide '' |
|
| 66 | + if ('' !== ($c = array_shift($cfg))) { |
|
| 67 | + $casier = $c; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + if (count($cfg)) { |
|
| 72 | + $sous_casier = $cfg; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return [$table, $casier, $sous_casier]; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -100,65 +100,65 @@ discard block |
||
| 100 | 100 | * Contenu de la configuration obtenue |
| 101 | 101 | */ |
| 102 | 102 | function lire_config($cfg = '', $def = null, $unserialize = true) { |
| 103 | - // lire le stockage sous la forme /table/valeur |
|
| 104 | - // ou valeur qui est en fait implicitement /meta/valeur |
|
| 105 | - // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 106 | - |
|
| 107 | - // traiter en priorite le cas simple et frequent |
|
| 108 | - // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 109 | - if ($cfg and strpbrk($cfg, '/:') === false) { |
|
| 110 | - $r = isset($GLOBALS['meta'][$cfg]) ? |
|
| 111 | - ((!$unserialize |
|
| 112 | - // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 113 | - or !is_string($GLOBALS['meta'][$cfg]) |
|
| 114 | - // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 115 | - or strpos($GLOBALS['meta'][$cfg], ':') === false |
|
| 116 | - or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t) |
|
| 117 | - : $def; |
|
| 118 | - |
|
| 119 | - return $r; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // Brancher sur methodes externes si besoin |
|
| 123 | - if ($cfg and $p = strpos($cfg, '::')) { |
|
| 124 | - $methode = substr($cfg, 0, $p); |
|
| 125 | - $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 126 | - |
|
| 127 | - return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 131 | - |
|
| 132 | - if (!isset($GLOBALS[$table])) { |
|
| 133 | - return $def; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - $r = $GLOBALS[$table]; |
|
| 137 | - |
|
| 138 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 139 | - if (!$casier) { |
|
| 140 | - return $unserialize ? $r : serialize($r); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // casier principal : |
|
| 144 | - // le deserializer si demande |
|
| 145 | - // ou si on a besoin |
|
| 146 | - // d'un sous casier |
|
| 147 | - $r = $r[$casier] ?? null; |
|
| 148 | - if (($unserialize or is_countable($sous_casier) ? count($sous_casier) : 0) and $r and is_string($r)) { |
|
| 149 | - $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // aller chercher le sous_casier |
|
| 153 | - while (!is_null($r) and $casier = array_shift($sous_casier)) { |
|
| 154 | - $r = $r[$casier] ?? null; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if (is_null($r)) { |
|
| 158 | - return $def; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $r; |
|
| 103 | + // lire le stockage sous la forme /table/valeur |
|
| 104 | + // ou valeur qui est en fait implicitement /meta/valeur |
|
| 105 | + // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 106 | + |
|
| 107 | + // traiter en priorite le cas simple et frequent |
|
| 108 | + // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 109 | + if ($cfg and strpbrk($cfg, '/:') === false) { |
|
| 110 | + $r = isset($GLOBALS['meta'][$cfg]) ? |
|
| 111 | + ((!$unserialize |
|
| 112 | + // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 113 | + or !is_string($GLOBALS['meta'][$cfg]) |
|
| 114 | + // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 115 | + or strpos($GLOBALS['meta'][$cfg], ':') === false |
|
| 116 | + or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t) |
|
| 117 | + : $def; |
|
| 118 | + |
|
| 119 | + return $r; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // Brancher sur methodes externes si besoin |
|
| 123 | + if ($cfg and $p = strpos($cfg, '::')) { |
|
| 124 | + $methode = substr($cfg, 0, $p); |
|
| 125 | + $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 126 | + |
|
| 127 | + return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 131 | + |
|
| 132 | + if (!isset($GLOBALS[$table])) { |
|
| 133 | + return $def; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $r = $GLOBALS[$table]; |
|
| 137 | + |
|
| 138 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 139 | + if (!$casier) { |
|
| 140 | + return $unserialize ? $r : serialize($r); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // casier principal : |
|
| 144 | + // le deserializer si demande |
|
| 145 | + // ou si on a besoin |
|
| 146 | + // d'un sous casier |
|
| 147 | + $r = $r[$casier] ?? null; |
|
| 148 | + if (($unserialize or is_countable($sous_casier) ? count($sous_casier) : 0) and $r and is_string($r)) { |
|
| 149 | + $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // aller chercher le sous_casier |
|
| 153 | + while (!is_null($r) and $casier = array_shift($sous_casier)) { |
|
| 154 | + $r = $r[$casier] ?? null; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if (is_null($r)) { |
|
| 158 | + return $def; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $r; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @return mixed |
| 173 | 173 | */ |
| 174 | 174 | function lire_config_metapack_dist($cfg = '', $def = null, $unserialize = true) { |
| 175 | - return lire_config($cfg, $def, $unserialize); |
|
| 175 | + return lire_config($cfg, $def, $unserialize); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -184,142 +184,142 @@ discard block |
||
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | 186 | function ecrire_config($cfg, $store) { |
| 187 | - // Brancher sur methodes externes si besoin |
|
| 188 | - if ($cfg and $p = strpos($cfg, '::')) { |
|
| 189 | - $methode = substr($cfg, 0, $p); |
|
| 190 | - $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 191 | - |
|
| 192 | - return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 196 | - // il faut au moins un casier pour ecrire |
|
| 197 | - if (!$casier) { |
|
| 198 | - return false; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - // trouvons ou creons le pointeur sur le casier |
|
| 202 | - $st = $GLOBALS[$table][$casier] ?? null; |
|
| 203 | - if (!is_array($st) and ($sous_casier or is_array($store))) { |
|
| 204 | - if ($st === null) { |
|
| 205 | - // ne rien creer si c'est une demande d'effacement |
|
| 206 | - if ($store === null) { |
|
| 207 | - return false; |
|
| 208 | - } |
|
| 209 | - $st = []; |
|
| 210 | - } else { |
|
| 211 | - $st = unserialize($st); |
|
| 212 | - if ($st === false) { |
|
| 213 | - // ne rien creer si c'est une demande d'effacement |
|
| 214 | - if ($store === null) { |
|
| 215 | - return false; |
|
| 216 | - } |
|
| 217 | - $st = []; |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - $has_planes = false; |
|
| 223 | - // si on a affaire a un sous caiser |
|
| 224 | - // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 225 | - if ($c = $sous_casier) { |
|
| 226 | - $sc = &$st; |
|
| 227 | - $pointeurs = []; |
|
| 228 | - while (is_countable($c) ? count($c) : 0 and $cc = array_shift($c)) { |
|
| 229 | - // creer l'entree si elle n'existe pas |
|
| 230 | - if (!isset($sc[$cc])) { |
|
| 231 | - // si on essaye d'effacer une config qui n'existe pas |
|
| 232 | - // ne rien creer mais sortir |
|
| 233 | - if (is_null($store)) { |
|
| 234 | - return false; |
|
| 235 | - } |
|
| 236 | - $sc[$cc] = []; |
|
| 237 | - } |
|
| 238 | - $pointeurs[$cc] = &$sc; |
|
| 239 | - $sc = &$sc[$cc]; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - // si c'est une demande d'effacement |
|
| 243 | - if (is_null($store)) { |
|
| 244 | - $c = $sous_casier; |
|
| 245 | - $sous = array_pop($c); |
|
| 246 | - // effacer, et remonter pour effacer les parents vides |
|
| 247 | - do { |
|
| 248 | - unset($pointeurs[$sous][$sous]); |
|
| 249 | - } while ($sous = array_pop($c) and !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 250 | - |
|
| 251 | - // si on a vide tous les sous casiers, |
|
| 252 | - // et que le casier est vide |
|
| 253 | - // vider aussi la meta |
|
| 254 | - if (!$sous and !(is_countable($st) ? count($st) : 0)) { |
|
| 255 | - $st = null; |
|
| 256 | - } |
|
| 257 | - } // dans tous les autres cas, on ecrase |
|
| 258 | - else { |
|
| 259 | - |
|
| 260 | - if ( |
|
| 261 | - defined('_MYSQL_NOPLANES') |
|
| 262 | - and _MYSQL_NOPLANES |
|
| 263 | - and !empty($GLOBALS['meta']['charset_sql_connexion']) |
|
| 264 | - and $GLOBALS['meta']['charset_sql_connexion'] == 'utf8' |
|
| 265 | - ) { |
|
| 266 | - |
|
| 267 | - // detecter si la valeur qu'on veut ecrire a des planes |
|
| 268 | - // @see utf8_noplanes |
|
| 269 | - $serialized_store = (is_string($store) ? $store : serialize($store)); |
|
| 270 | - // un preg_match rapide pour voir si ca vaut le coup de lancer utf8_noplanes |
|
| 271 | - if (preg_match(',[\xF0-\xF4],ms', $serialized_store)) { |
|
| 272 | - if (!function_exists('utf8_noplanes')) { |
|
| 273 | - include_spip('inc/charsets'); |
|
| 274 | - } |
|
| 275 | - if ($serialized_store !== utf8_noplanes($serialized_store)) { |
|
| 276 | - $has_planes = true; |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - $sc = $store; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - // Maintenant que $st est modifiee |
|
| 285 | - // reprenons la comme valeur a stocker dans le casier principal |
|
| 286 | - $store = $st; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - if (is_null($store)) { |
|
| 290 | - if (is_null($st) and !$sous_casier) { |
|
| 291 | - return false; |
|
| 292 | - } // la config n'existait deja pas ! |
|
| 293 | - effacer_meta($casier, $table); |
|
| 294 | - supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 295 | - } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 296 | - else { |
|
| 297 | - if (!isset($GLOBALS[$table])) { |
|
| 298 | - installer_table_meta($table); |
|
| 299 | - } |
|
| 300 | - // si ce n'est pas une chaine |
|
| 301 | - // il faut serializer |
|
| 302 | - if (!is_string($store)) { |
|
| 303 | - $serialized_store = serialize($store); |
|
| 304 | - ecrire_meta($casier, $serialized_store, null, $table); |
|
| 305 | - // et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine |
|
| 306 | - // car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4) |
|
| 307 | - if ($has_planes) { |
|
| 308 | - $check_store = sql_getfetsel('valeur', 'spip_'.$table, 'nom='.sql_quote($casier)); |
|
| 309 | - if ($check_store !== $serialized_store) { |
|
| 310 | - array_walk_recursive($store, function (&$value, $key) {if (is_string($value)) {$value = utf8_noplanes($value);}}); |
|
| 311 | - $serialized_store = serialize($store); |
|
| 312 | - ecrire_meta($casier, $serialized_store, null, $table); |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - else { |
|
| 317 | - ecrire_meta($casier, $store, null, $table); |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - // verifier que lire_config($cfg)==$store ? |
|
| 322 | - return true; |
|
| 187 | + // Brancher sur methodes externes si besoin |
|
| 188 | + if ($cfg and $p = strpos($cfg, '::')) { |
|
| 189 | + $methode = substr($cfg, 0, $p); |
|
| 190 | + $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 191 | + |
|
| 192 | + return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 196 | + // il faut au moins un casier pour ecrire |
|
| 197 | + if (!$casier) { |
|
| 198 | + return false; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + // trouvons ou creons le pointeur sur le casier |
|
| 202 | + $st = $GLOBALS[$table][$casier] ?? null; |
|
| 203 | + if (!is_array($st) and ($sous_casier or is_array($store))) { |
|
| 204 | + if ($st === null) { |
|
| 205 | + // ne rien creer si c'est une demande d'effacement |
|
| 206 | + if ($store === null) { |
|
| 207 | + return false; |
|
| 208 | + } |
|
| 209 | + $st = []; |
|
| 210 | + } else { |
|
| 211 | + $st = unserialize($st); |
|
| 212 | + if ($st === false) { |
|
| 213 | + // ne rien creer si c'est une demande d'effacement |
|
| 214 | + if ($store === null) { |
|
| 215 | + return false; |
|
| 216 | + } |
|
| 217 | + $st = []; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + $has_planes = false; |
|
| 223 | + // si on a affaire a un sous caiser |
|
| 224 | + // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 225 | + if ($c = $sous_casier) { |
|
| 226 | + $sc = &$st; |
|
| 227 | + $pointeurs = []; |
|
| 228 | + while (is_countable($c) ? count($c) : 0 and $cc = array_shift($c)) { |
|
| 229 | + // creer l'entree si elle n'existe pas |
|
| 230 | + if (!isset($sc[$cc])) { |
|
| 231 | + // si on essaye d'effacer une config qui n'existe pas |
|
| 232 | + // ne rien creer mais sortir |
|
| 233 | + if (is_null($store)) { |
|
| 234 | + return false; |
|
| 235 | + } |
|
| 236 | + $sc[$cc] = []; |
|
| 237 | + } |
|
| 238 | + $pointeurs[$cc] = &$sc; |
|
| 239 | + $sc = &$sc[$cc]; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + // si c'est une demande d'effacement |
|
| 243 | + if (is_null($store)) { |
|
| 244 | + $c = $sous_casier; |
|
| 245 | + $sous = array_pop($c); |
|
| 246 | + // effacer, et remonter pour effacer les parents vides |
|
| 247 | + do { |
|
| 248 | + unset($pointeurs[$sous][$sous]); |
|
| 249 | + } while ($sous = array_pop($c) and !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 250 | + |
|
| 251 | + // si on a vide tous les sous casiers, |
|
| 252 | + // et que le casier est vide |
|
| 253 | + // vider aussi la meta |
|
| 254 | + if (!$sous and !(is_countable($st) ? count($st) : 0)) { |
|
| 255 | + $st = null; |
|
| 256 | + } |
|
| 257 | + } // dans tous les autres cas, on ecrase |
|
| 258 | + else { |
|
| 259 | + |
|
| 260 | + if ( |
|
| 261 | + defined('_MYSQL_NOPLANES') |
|
| 262 | + and _MYSQL_NOPLANES |
|
| 263 | + and !empty($GLOBALS['meta']['charset_sql_connexion']) |
|
| 264 | + and $GLOBALS['meta']['charset_sql_connexion'] == 'utf8' |
|
| 265 | + ) { |
|
| 266 | + |
|
| 267 | + // detecter si la valeur qu'on veut ecrire a des planes |
|
| 268 | + // @see utf8_noplanes |
|
| 269 | + $serialized_store = (is_string($store) ? $store : serialize($store)); |
|
| 270 | + // un preg_match rapide pour voir si ca vaut le coup de lancer utf8_noplanes |
|
| 271 | + if (preg_match(',[\xF0-\xF4],ms', $serialized_store)) { |
|
| 272 | + if (!function_exists('utf8_noplanes')) { |
|
| 273 | + include_spip('inc/charsets'); |
|
| 274 | + } |
|
| 275 | + if ($serialized_store !== utf8_noplanes($serialized_store)) { |
|
| 276 | + $has_planes = true; |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + $sc = $store; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + // Maintenant que $st est modifiee |
|
| 285 | + // reprenons la comme valeur a stocker dans le casier principal |
|
| 286 | + $store = $st; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + if (is_null($store)) { |
|
| 290 | + if (is_null($st) and !$sous_casier) { |
|
| 291 | + return false; |
|
| 292 | + } // la config n'existait deja pas ! |
|
| 293 | + effacer_meta($casier, $table); |
|
| 294 | + supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 295 | + } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 296 | + else { |
|
| 297 | + if (!isset($GLOBALS[$table])) { |
|
| 298 | + installer_table_meta($table); |
|
| 299 | + } |
|
| 300 | + // si ce n'est pas une chaine |
|
| 301 | + // il faut serializer |
|
| 302 | + if (!is_string($store)) { |
|
| 303 | + $serialized_store = serialize($store); |
|
| 304 | + ecrire_meta($casier, $serialized_store, null, $table); |
|
| 305 | + // et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine |
|
| 306 | + // car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4) |
|
| 307 | + if ($has_planes) { |
|
| 308 | + $check_store = sql_getfetsel('valeur', 'spip_'.$table, 'nom='.sql_quote($casier)); |
|
| 309 | + if ($check_store !== $serialized_store) { |
|
| 310 | + array_walk_recursive($store, function (&$value, $key) {if (is_string($value)) {$value = utf8_noplanes($value);}}); |
|
| 311 | + $serialized_store = serialize($store); |
|
| 312 | + ecrire_meta($casier, $serialized_store, null, $table); |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + else { |
|
| 317 | + ecrire_meta($casier, $store, null, $table); |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + // verifier que lire_config($cfg)==$store ? |
|
| 322 | + return true; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -333,14 +333,14 @@ discard block |
||
| 333 | 333 | * @return bool |
| 334 | 334 | */ |
| 335 | 335 | function ecrire_config_metapack_dist($cfg, $store) { |
| 336 | - // cas particulier en metapack:: |
|
| 337 | - // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 338 | - // intacte en sortie ... |
|
| 339 | - if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 340 | - $store = serialize($store); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - return ecrire_config($cfg, $store); |
|
| 336 | + // cas particulier en metapack:: |
|
| 337 | + // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 338 | + // intacte en sortie ... |
|
| 339 | + if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 340 | + $store = serialize($store); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + return ecrire_config($cfg, $store); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | /** |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | * @return bool |
| 351 | 351 | */ |
| 352 | 352 | function effacer_config($cfg) { |
| 353 | - ecrire_config($cfg, null); |
|
| 353 | + ecrire_config($cfg, null); |
|
| 354 | 354 | |
| 355 | - return true; |
|
| 355 | + return true; |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -369,58 +369,58 @@ discard block |
||
| 369 | 369 | * Couples nom de la `meta` => valeur par défaut |
| 370 | 370 | */ |
| 371 | 371 | function liste_metas() { |
| 372 | - return pipeline('configurer_liste_metas', [ |
|
| 373 | - 'nom_site' => _T('info_mon_site_spip'), |
|
| 374 | - 'slogan_site' => '', |
|
| 375 | - 'adresse_site' => preg_replace(',/$,', '', url_de_base()), |
|
| 376 | - 'descriptif_site' => '', |
|
| 377 | - 'activer_logos' => 'oui', |
|
| 378 | - 'activer_logos_survol' => 'non', |
|
| 379 | - 'articles_surtitre' => 'non', |
|
| 380 | - 'articles_soustitre' => 'non', |
|
| 381 | - 'articles_descriptif' => 'non', |
|
| 382 | - 'articles_chapeau' => 'non', |
|
| 383 | - 'articles_texte' => 'oui', |
|
| 384 | - 'articles_ps' => 'non', |
|
| 385 | - 'articles_redac' => 'non', |
|
| 386 | - 'post_dates' => 'non', |
|
| 387 | - 'articles_urlref' => 'non', |
|
| 388 | - 'articles_redirection' => 'non', |
|
| 389 | - 'creer_preview' => 'non', |
|
| 390 | - 'taille_preview' => 150, |
|
| 391 | - 'articles_modif' => 'non', |
|
| 392 | - |
|
| 393 | - 'rubriques_descriptif' => 'non', |
|
| 394 | - 'rubriques_texte' => 'oui', |
|
| 395 | - |
|
| 396 | - 'accepter_inscriptions' => 'non', |
|
| 397 | - 'accepter_visiteurs' => 'non', |
|
| 398 | - 'prevenir_auteurs' => 'non', |
|
| 399 | - 'suivi_edito' => 'non', |
|
| 400 | - 'adresse_suivi' => '', |
|
| 401 | - 'adresse_suivi_inscription' => '', |
|
| 402 | - 'adresse_neuf' => '', |
|
| 403 | - 'jours_neuf' => '', |
|
| 404 | - 'quoi_de_neuf' => 'non', |
|
| 405 | - 'preview' => ',0minirezo,1comite,', |
|
| 406 | - |
|
| 407 | - 'syndication_integrale' => 'oui', |
|
| 408 | - 'charset' => _DEFAULT_CHARSET, |
|
| 409 | - 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 410 | - |
|
| 411 | - 'multi_rubriques' => 'non', |
|
| 412 | - 'multi_secteurs' => 'non', |
|
| 413 | - 'gerer_trad' => 'non', |
|
| 414 | - 'langues_multilingue' => '', |
|
| 415 | - |
|
| 416 | - 'version_html_max' => 'html4', |
|
| 417 | - |
|
| 418 | - 'type_urls' => 'page', |
|
| 419 | - |
|
| 420 | - 'email_envoi' => '', |
|
| 421 | - 'email_webmaster' => '', |
|
| 422 | - 'auto_compress_http' => 'non', |
|
| 423 | - ]); |
|
| 372 | + return pipeline('configurer_liste_metas', [ |
|
| 373 | + 'nom_site' => _T('info_mon_site_spip'), |
|
| 374 | + 'slogan_site' => '', |
|
| 375 | + 'adresse_site' => preg_replace(',/$,', '', url_de_base()), |
|
| 376 | + 'descriptif_site' => '', |
|
| 377 | + 'activer_logos' => 'oui', |
|
| 378 | + 'activer_logos_survol' => 'non', |
|
| 379 | + 'articles_surtitre' => 'non', |
|
| 380 | + 'articles_soustitre' => 'non', |
|
| 381 | + 'articles_descriptif' => 'non', |
|
| 382 | + 'articles_chapeau' => 'non', |
|
| 383 | + 'articles_texte' => 'oui', |
|
| 384 | + 'articles_ps' => 'non', |
|
| 385 | + 'articles_redac' => 'non', |
|
| 386 | + 'post_dates' => 'non', |
|
| 387 | + 'articles_urlref' => 'non', |
|
| 388 | + 'articles_redirection' => 'non', |
|
| 389 | + 'creer_preview' => 'non', |
|
| 390 | + 'taille_preview' => 150, |
|
| 391 | + 'articles_modif' => 'non', |
|
| 392 | + |
|
| 393 | + 'rubriques_descriptif' => 'non', |
|
| 394 | + 'rubriques_texte' => 'oui', |
|
| 395 | + |
|
| 396 | + 'accepter_inscriptions' => 'non', |
|
| 397 | + 'accepter_visiteurs' => 'non', |
|
| 398 | + 'prevenir_auteurs' => 'non', |
|
| 399 | + 'suivi_edito' => 'non', |
|
| 400 | + 'adresse_suivi' => '', |
|
| 401 | + 'adresse_suivi_inscription' => '', |
|
| 402 | + 'adresse_neuf' => '', |
|
| 403 | + 'jours_neuf' => '', |
|
| 404 | + 'quoi_de_neuf' => 'non', |
|
| 405 | + 'preview' => ',0minirezo,1comite,', |
|
| 406 | + |
|
| 407 | + 'syndication_integrale' => 'oui', |
|
| 408 | + 'charset' => _DEFAULT_CHARSET, |
|
| 409 | + 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 410 | + |
|
| 411 | + 'multi_rubriques' => 'non', |
|
| 412 | + 'multi_secteurs' => 'non', |
|
| 413 | + 'gerer_trad' => 'non', |
|
| 414 | + 'langues_multilingue' => '', |
|
| 415 | + |
|
| 416 | + 'version_html_max' => 'html4', |
|
| 417 | + |
|
| 418 | + 'type_urls' => 'page', |
|
| 419 | + |
|
| 420 | + 'email_envoi' => '', |
|
| 421 | + 'email_webmaster' => '', |
|
| 422 | + 'auto_compress_http' => 'non', |
|
| 423 | + ]); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -431,43 +431,43 @@ discard block |
||
| 431 | 431 | * @return void |
| 432 | 432 | */ |
| 433 | 433 | function actualise_metas($liste_meta) { |
| 434 | - $meta_serveur = |
|
| 435 | - [ |
|
| 436 | - 'version_installee', |
|
| 437 | - 'adresse_site', |
|
| 438 | - 'alea_ephemere_ancien', |
|
| 439 | - 'alea_ephemere', |
|
| 440 | - 'alea_ephemere_date', |
|
| 441 | - 'langue_site', |
|
| 442 | - 'langues_proposees', |
|
| 443 | - 'date_calcul_rubriques', |
|
| 444 | - 'derniere_modif', |
|
| 445 | - 'optimiser_table', |
|
| 446 | - 'drapeau_edition', |
|
| 447 | - 'creer_preview', |
|
| 448 | - 'taille_preview', |
|
| 449 | - 'creer_htpasswd', |
|
| 450 | - 'creer_htaccess', |
|
| 451 | - 'gd_formats_read', |
|
| 452 | - 'gd_formats', |
|
| 453 | - 'netpbm_formats', |
|
| 454 | - 'formats_graphiques', |
|
| 455 | - 'image_process', |
|
| 456 | - 'plugin_header', |
|
| 457 | - 'plugin' |
|
| 458 | - ]; |
|
| 459 | - // verifier le impt=non |
|
| 460 | - sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 461 | - |
|
| 462 | - foreach ($liste_meta as $nom => $valeur) { |
|
| 463 | - if (empty($GLOBALS['meta'][$nom])) { |
|
| 464 | - ecrire_meta($nom, $valeur); |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - include_spip('inc/rubriques'); |
|
| 469 | - $langues = calculer_langues_utilisees(); |
|
| 470 | - ecrire_meta('langues_utilisees', $langues); |
|
| 434 | + $meta_serveur = |
|
| 435 | + [ |
|
| 436 | + 'version_installee', |
|
| 437 | + 'adresse_site', |
|
| 438 | + 'alea_ephemere_ancien', |
|
| 439 | + 'alea_ephemere', |
|
| 440 | + 'alea_ephemere_date', |
|
| 441 | + 'langue_site', |
|
| 442 | + 'langues_proposees', |
|
| 443 | + 'date_calcul_rubriques', |
|
| 444 | + 'derniere_modif', |
|
| 445 | + 'optimiser_table', |
|
| 446 | + 'drapeau_edition', |
|
| 447 | + 'creer_preview', |
|
| 448 | + 'taille_preview', |
|
| 449 | + 'creer_htpasswd', |
|
| 450 | + 'creer_htaccess', |
|
| 451 | + 'gd_formats_read', |
|
| 452 | + 'gd_formats', |
|
| 453 | + 'netpbm_formats', |
|
| 454 | + 'formats_graphiques', |
|
| 455 | + 'image_process', |
|
| 456 | + 'plugin_header', |
|
| 457 | + 'plugin' |
|
| 458 | + ]; |
|
| 459 | + // verifier le impt=non |
|
| 460 | + sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 461 | + |
|
| 462 | + foreach ($liste_meta as $nom => $valeur) { |
|
| 463 | + if (empty($GLOBALS['meta'][$nom])) { |
|
| 464 | + ecrire_meta($nom, $valeur); |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + include_spip('inc/rubriques'); |
|
| 469 | + $langues = calculer_langues_utilisees(); |
|
| 470 | + ecrire_meta('langues_utilisees', $langues); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | |
@@ -489,18 +489,18 @@ discard block |
||
| 489 | 489 | */ |
| 490 | 490 | function appliquer_modifs_config($purger_skel = false) { |
| 491 | 491 | |
| 492 | - foreach (liste_metas() as $i => $v) { |
|
| 493 | - if (($x = _request($i)) !== null) { |
|
| 494 | - ecrire_meta($i, $x); |
|
| 495 | - } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 496 | - ecrire_meta($i, $v); |
|
| 497 | - } |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - if ($purger_skel) { |
|
| 501 | - include_spip('inc/invalideur'); |
|
| 502 | - purger_repertoire(_DIR_SKELS); |
|
| 503 | - } |
|
| 492 | + foreach (liste_metas() as $i => $v) { |
|
| 493 | + if (($x = _request($i)) !== null) { |
|
| 494 | + ecrire_meta($i, $x); |
|
| 495 | + } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 496 | + ecrire_meta($i, $v); |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + if ($purger_skel) { |
|
| 501 | + include_spip('inc/invalideur'); |
|
| 502 | + purger_repertoire(_DIR_SKELS); |
|
| 503 | + } |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -511,21 +511,21 @@ discard block |
||
| 511 | 511 | * @return string |
| 512 | 512 | */ |
| 513 | 513 | function appliquer_adresse_site($adresse_site) { |
| 514 | - if ($adresse_site !== null) { |
|
| 515 | - if (!strlen($adresse_site)) { |
|
| 516 | - $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 517 | - $adresse_site = url_de_base(); |
|
| 518 | - } |
|
| 519 | - $adresse_site = preg_replace(',/?\s*$,', '', $adresse_site); |
|
| 514 | + if ($adresse_site !== null) { |
|
| 515 | + if (!strlen($adresse_site)) { |
|
| 516 | + $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 517 | + $adresse_site = url_de_base(); |
|
| 518 | + } |
|
| 519 | + $adresse_site = preg_replace(',/?\s*$,', '', $adresse_site); |
|
| 520 | 520 | |
| 521 | - if (!tester_url_absolue($adresse_site)) { |
|
| 522 | - $adresse_site = "http://$adresse_site"; |
|
| 523 | - } |
|
| 521 | + if (!tester_url_absolue($adresse_site)) { |
|
| 522 | + $adresse_site = "http://$adresse_site"; |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | - $adresse_site = entites_html($adresse_site); |
|
| 525 | + $adresse_site = entites_html($adresse_site); |
|
| 526 | 526 | |
| 527 | - ecrire_meta('adresse_site', $adresse_site); |
|
| 528 | - } |
|
| 527 | + ecrire_meta('adresse_site', $adresse_site); |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | - return $adresse_site; |
|
| 530 | + return $adresse_site; |
|
| 531 | 531 | } |
@@ -307,7 +307,7 @@ |
||
| 307 | 307 | if ($has_planes) { |
| 308 | 308 | $check_store = sql_getfetsel('valeur', 'spip_'.$table, 'nom='.sql_quote($casier)); |
| 309 | 309 | if ($check_store !== $serialized_store) { |
| 310 | - array_walk_recursive($store, function (&$value, $key) {if (is_string($value)) {$value = utf8_noplanes($value);}}); |
|
| 310 | + array_walk_recursive($store, function(&$value, $key) {if (is_string($value)) {$value = utf8_noplanes($value); }}); |
|
| 311 | 311 | $serialized_store = serialize($store); |
| 312 | 312 | ecrire_meta($casier, $serialized_store, null, $table); |
| 313 | 313 | } |
@@ -312,8 +312,7 @@ |
||
| 312 | 312 | ecrire_meta($casier, $serialized_store, null, $table); |
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | - } |
|
| 316 | - else { |
|
| 315 | + } else { |
|
| 317 | 316 | ecrire_meta($casier, $store, null, $table); |
| 318 | 317 | } |
| 319 | 318 | } |