@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -29,50 +29,50 @@ discard block |
||
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | - /** @var bool Évaluation réussie ? */ |
|
| 32 | + /** @var bool Évaluation réussie ? */ |
|
| 33 | 33 | $res = true; |
| 34 | 34 | |
| 35 | 35 | // Cas d'une page contenant du PHP : |
| 36 | 36 | if (empty($page['process_ins']) or $page['process_ins'] != 'html') { |
| 37 | - include_spip('inc/lang'); |
|
| 37 | + include_spip('inc/lang'); |
|
| 38 | 38 | |
| 39 | - // restaurer l'etat des notes avant calcul |
|
| 40 | - if ( |
|
| 41 | - isset($page['notes']) |
|
| 42 | - and $page['notes'] |
|
| 43 | - and $notes = charger_fonction('notes', 'inc', true) |
|
| 44 | - ) { |
|
| 45 | - $notes($page['notes'], 'restaurer_etat'); |
|
| 46 | - } |
|
| 47 | - ob_start(); |
|
| 48 | - if (strpos($page['texte'], '?xml') !== false) { |
|
| 49 | - $page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']); |
|
| 50 | - } |
|
| 39 | + // restaurer l'etat des notes avant calcul |
|
| 40 | + if ( |
|
| 41 | + isset($page['notes']) |
|
| 42 | + and $page['notes'] |
|
| 43 | + and $notes = charger_fonction('notes', 'inc', true) |
|
| 44 | + ) { |
|
| 45 | + $notes($page['notes'], 'restaurer_etat'); |
|
| 46 | + } |
|
| 47 | + ob_start(); |
|
| 48 | + if (strpos($page['texte'], '?xml') !== false) { |
|
| 49 | + $page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - try { |
|
| 53 | - $res = eval('?' . '>' . $page['texte']); |
|
| 54 | - $page['texte'] = ob_get_contents(); |
|
| 55 | - } catch (\Throwable $e) { |
|
| 56 | - $code = $page['texte']; |
|
| 57 | - $GLOBALS['numero_ligne_php'] = 1; |
|
| 58 | - if (!function_exists('numerote_ligne_php')) { |
|
| 59 | - function numerote_ligne_php($match) { |
|
| 60 | - $GLOBALS['numero_ligne_php']++; |
|
| 61 | - return "\n/*" . str_pad($GLOBALS['numero_ligne_php'], 3, '0', STR_PAD_LEFT) . '*/'; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - $code = '/*001*/' . preg_replace_callback(",\n,", 'numerote_ligne_php', $code); |
|
| 65 | - $code = trim(highlight_string($code, true)); |
|
| 66 | - erreur_squelette('L' . $e->getLine() . ': ' . $e->getMessage() . '<br />' . $code, [$page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang']]); |
|
| 67 | - $page['texte'] = '<!-- Erreur -->'; |
|
| 68 | - } |
|
| 69 | - ob_end_clean(); |
|
| 52 | + try { |
|
| 53 | + $res = eval('?' . '>' . $page['texte']); |
|
| 54 | + $page['texte'] = ob_get_contents(); |
|
| 55 | + } catch (\Throwable $e) { |
|
| 56 | + $code = $page['texte']; |
|
| 57 | + $GLOBALS['numero_ligne_php'] = 1; |
|
| 58 | + if (!function_exists('numerote_ligne_php')) { |
|
| 59 | + function numerote_ligne_php($match) { |
|
| 60 | + $GLOBALS['numero_ligne_php']++; |
|
| 61 | + return "\n/*" . str_pad($GLOBALS['numero_ligne_php'], 3, '0', STR_PAD_LEFT) . '*/'; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + $code = '/*001*/' . preg_replace_callback(",\n,", 'numerote_ligne_php', $code); |
|
| 65 | + $code = trim(highlight_string($code, true)); |
|
| 66 | + erreur_squelette('L' . $e->getLine() . ': ' . $e->getMessage() . '<br />' . $code, [$page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang']]); |
|
| 67 | + $page['texte'] = '<!-- Erreur -->'; |
|
| 68 | + } |
|
| 69 | + ob_end_clean(); |
|
| 70 | 70 | |
| 71 | - $page['process_ins'] = 'html'; |
|
| 71 | + $page['process_ins'] = 'html'; |
|
| 72 | 72 | |
| 73 | - if (strpos($page['texte'], '?xml') !== false) { |
|
| 74 | - $page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']); |
|
| 75 | - } |
|
| 73 | + if (strpos($page['texte'], '?xml') !== false) { |
|
| 74 | + $page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']); |
|
| 75 | + } |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | page_base_href($page['texte']); |
@@ -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,106 +184,106 @@ 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 | - // si on a affaire a un sous caiser |
|
| 223 | - // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 224 | - if ($c = $sous_casier) { |
|
| 225 | - $sc = &$st; |
|
| 226 | - $pointeurs = []; |
|
| 227 | - while (is_countable($c) ? count($c) : 0 and $cc = array_shift($c)) { |
|
| 228 | - // creer l'entree si elle n'existe pas |
|
| 229 | - if (!isset($sc[$cc])) { |
|
| 230 | - // si on essaye d'effacer une config qui n'existe pas |
|
| 231 | - // ne rien creer mais sortir |
|
| 232 | - if (is_null($store)) { |
|
| 233 | - return false; |
|
| 234 | - } |
|
| 235 | - $sc[$cc] = []; |
|
| 236 | - } |
|
| 237 | - $pointeurs[$cc] = &$sc; |
|
| 238 | - $sc = &$sc[$cc]; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - // si c'est une demande d'effacement |
|
| 242 | - if (is_null($store)) { |
|
| 243 | - $c = $sous_casier; |
|
| 244 | - $sous = array_pop($c); |
|
| 245 | - // effacer, et remonter pour effacer les parents vides |
|
| 246 | - do { |
|
| 247 | - unset($pointeurs[$sous][$sous]); |
|
| 248 | - } while ($sous = array_pop($c) and !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 249 | - |
|
| 250 | - // si on a vide tous les sous casiers, |
|
| 251 | - // et que le casier est vide |
|
| 252 | - // vider aussi la meta |
|
| 253 | - if (!$sous and !(is_countable($st) ? count($st) : 0)) { |
|
| 254 | - $st = null; |
|
| 255 | - } |
|
| 256 | - } // dans tous les autres cas, on ecrase |
|
| 257 | - else { |
|
| 258 | - $sc = $store; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // Maintenant que $st est modifiee |
|
| 262 | - // reprenons la comme valeur a stocker dans le casier principal |
|
| 263 | - $store = $st; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - if (is_null($store)) { |
|
| 267 | - if (is_null($st) and !$sous_casier) { |
|
| 268 | - return false; |
|
| 269 | - } // la config n'existait deja pas ! |
|
| 270 | - effacer_meta($casier, $table); |
|
| 271 | - supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 272 | - } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 273 | - else { |
|
| 274 | - if (!isset($GLOBALS[$table])) { |
|
| 275 | - installer_table_meta($table); |
|
| 276 | - } |
|
| 277 | - // si ce n'est pas une chaine |
|
| 278 | - // il faut serializer |
|
| 279 | - if (!is_string($store)) { |
|
| 280 | - $store = serialize($store); |
|
| 281 | - } |
|
| 282 | - ecrire_meta($casier, $store, null, $table); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - // verifier que lire_config($cfg)==$store ? |
|
| 286 | - 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 | + // si on a affaire a un sous caiser |
|
| 223 | + // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 224 | + if ($c = $sous_casier) { |
|
| 225 | + $sc = &$st; |
|
| 226 | + $pointeurs = []; |
|
| 227 | + while (is_countable($c) ? count($c) : 0 and $cc = array_shift($c)) { |
|
| 228 | + // creer l'entree si elle n'existe pas |
|
| 229 | + if (!isset($sc[$cc])) { |
|
| 230 | + // si on essaye d'effacer une config qui n'existe pas |
|
| 231 | + // ne rien creer mais sortir |
|
| 232 | + if (is_null($store)) { |
|
| 233 | + return false; |
|
| 234 | + } |
|
| 235 | + $sc[$cc] = []; |
|
| 236 | + } |
|
| 237 | + $pointeurs[$cc] = &$sc; |
|
| 238 | + $sc = &$sc[$cc]; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + // si c'est une demande d'effacement |
|
| 242 | + if (is_null($store)) { |
|
| 243 | + $c = $sous_casier; |
|
| 244 | + $sous = array_pop($c); |
|
| 245 | + // effacer, et remonter pour effacer les parents vides |
|
| 246 | + do { |
|
| 247 | + unset($pointeurs[$sous][$sous]); |
|
| 248 | + } while ($sous = array_pop($c) and !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 249 | + |
|
| 250 | + // si on a vide tous les sous casiers, |
|
| 251 | + // et que le casier est vide |
|
| 252 | + // vider aussi la meta |
|
| 253 | + if (!$sous and !(is_countable($st) ? count($st) : 0)) { |
|
| 254 | + $st = null; |
|
| 255 | + } |
|
| 256 | + } // dans tous les autres cas, on ecrase |
|
| 257 | + else { |
|
| 258 | + $sc = $store; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // Maintenant que $st est modifiee |
|
| 262 | + // reprenons la comme valeur a stocker dans le casier principal |
|
| 263 | + $store = $st; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + if (is_null($store)) { |
|
| 267 | + if (is_null($st) and !$sous_casier) { |
|
| 268 | + return false; |
|
| 269 | + } // la config n'existait deja pas ! |
|
| 270 | + effacer_meta($casier, $table); |
|
| 271 | + supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 272 | + } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 273 | + else { |
|
| 274 | + if (!isset($GLOBALS[$table])) { |
|
| 275 | + installer_table_meta($table); |
|
| 276 | + } |
|
| 277 | + // si ce n'est pas une chaine |
|
| 278 | + // il faut serializer |
|
| 279 | + if (!is_string($store)) { |
|
| 280 | + $store = serialize($store); |
|
| 281 | + } |
|
| 282 | + ecrire_meta($casier, $store, null, $table); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + // verifier que lire_config($cfg)==$store ? |
|
| 286 | + return true; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | |
@@ -297,14 +297,14 @@ discard block |
||
| 297 | 297 | * @return bool |
| 298 | 298 | */ |
| 299 | 299 | function ecrire_config_metapack_dist($cfg, $store) { |
| 300 | - // cas particulier en metapack:: |
|
| 301 | - // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 302 | - // intacte en sortie ... |
|
| 303 | - if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 304 | - $store = serialize($store); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - return ecrire_config($cfg, $store); |
|
| 300 | + // cas particulier en metapack:: |
|
| 301 | + // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 302 | + // intacte en sortie ... |
|
| 303 | + if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 304 | + $store = serialize($store); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + return ecrire_config($cfg, $store); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -314,9 +314,9 @@ discard block |
||
| 314 | 314 | * @return bool |
| 315 | 315 | */ |
| 316 | 316 | function effacer_config($cfg) { |
| 317 | - ecrire_config($cfg, null); |
|
| 317 | + ecrire_config($cfg, null); |
|
| 318 | 318 | |
| 319 | - return true; |
|
| 319 | + return true; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -333,58 +333,58 @@ discard block |
||
| 333 | 333 | * Couples nom de la `meta` => valeur par défaut |
| 334 | 334 | */ |
| 335 | 335 | function liste_metas() { |
| 336 | - return pipeline('configurer_liste_metas', [ |
|
| 337 | - 'nom_site' => _T('info_mon_site_spip'), |
|
| 338 | - 'slogan_site' => '', |
|
| 339 | - 'adresse_site' => preg_replace(',/$,', '', url_de_base()), |
|
| 340 | - 'descriptif_site' => '', |
|
| 341 | - 'activer_logos' => 'oui', |
|
| 342 | - 'activer_logos_survol' => 'non', |
|
| 343 | - 'articles_surtitre' => 'non', |
|
| 344 | - 'articles_soustitre' => 'non', |
|
| 345 | - 'articles_descriptif' => 'non', |
|
| 346 | - 'articles_chapeau' => 'non', |
|
| 347 | - 'articles_texte' => 'oui', |
|
| 348 | - 'articles_ps' => 'non', |
|
| 349 | - 'articles_redac' => 'non', |
|
| 350 | - 'post_dates' => 'non', |
|
| 351 | - 'articles_urlref' => 'non', |
|
| 352 | - 'articles_redirection' => 'non', |
|
| 353 | - 'creer_preview' => 'non', |
|
| 354 | - 'taille_preview' => 150, |
|
| 355 | - 'articles_modif' => 'non', |
|
| 356 | - |
|
| 357 | - 'rubriques_descriptif' => 'non', |
|
| 358 | - 'rubriques_texte' => 'oui', |
|
| 359 | - |
|
| 360 | - 'accepter_inscriptions' => 'non', |
|
| 361 | - 'accepter_visiteurs' => 'non', |
|
| 362 | - 'prevenir_auteurs' => 'non', |
|
| 363 | - 'suivi_edito' => 'non', |
|
| 364 | - 'adresse_suivi' => '', |
|
| 365 | - 'adresse_suivi_inscription' => '', |
|
| 366 | - 'adresse_neuf' => '', |
|
| 367 | - 'jours_neuf' => '', |
|
| 368 | - 'quoi_de_neuf' => 'non', |
|
| 369 | - 'preview' => ',0minirezo,1comite,', |
|
| 370 | - |
|
| 371 | - 'syndication_integrale' => 'oui', |
|
| 372 | - 'charset' => _DEFAULT_CHARSET, |
|
| 373 | - 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 374 | - |
|
| 375 | - 'multi_rubriques' => 'non', |
|
| 376 | - 'multi_secteurs' => 'non', |
|
| 377 | - 'gerer_trad' => 'non', |
|
| 378 | - 'langues_multilingue' => '', |
|
| 379 | - |
|
| 380 | - 'version_html_max' => 'html4', |
|
| 381 | - |
|
| 382 | - 'type_urls' => 'page', |
|
| 383 | - |
|
| 384 | - 'email_envoi' => '', |
|
| 385 | - 'email_webmaster' => '', |
|
| 386 | - 'auto_compress_http' => 'non', |
|
| 387 | - ]); |
|
| 336 | + return pipeline('configurer_liste_metas', [ |
|
| 337 | + 'nom_site' => _T('info_mon_site_spip'), |
|
| 338 | + 'slogan_site' => '', |
|
| 339 | + 'adresse_site' => preg_replace(',/$,', '', url_de_base()), |
|
| 340 | + 'descriptif_site' => '', |
|
| 341 | + 'activer_logos' => 'oui', |
|
| 342 | + 'activer_logos_survol' => 'non', |
|
| 343 | + 'articles_surtitre' => 'non', |
|
| 344 | + 'articles_soustitre' => 'non', |
|
| 345 | + 'articles_descriptif' => 'non', |
|
| 346 | + 'articles_chapeau' => 'non', |
|
| 347 | + 'articles_texte' => 'oui', |
|
| 348 | + 'articles_ps' => 'non', |
|
| 349 | + 'articles_redac' => 'non', |
|
| 350 | + 'post_dates' => 'non', |
|
| 351 | + 'articles_urlref' => 'non', |
|
| 352 | + 'articles_redirection' => 'non', |
|
| 353 | + 'creer_preview' => 'non', |
|
| 354 | + 'taille_preview' => 150, |
|
| 355 | + 'articles_modif' => 'non', |
|
| 356 | + |
|
| 357 | + 'rubriques_descriptif' => 'non', |
|
| 358 | + 'rubriques_texte' => 'oui', |
|
| 359 | + |
|
| 360 | + 'accepter_inscriptions' => 'non', |
|
| 361 | + 'accepter_visiteurs' => 'non', |
|
| 362 | + 'prevenir_auteurs' => 'non', |
|
| 363 | + 'suivi_edito' => 'non', |
|
| 364 | + 'adresse_suivi' => '', |
|
| 365 | + 'adresse_suivi_inscription' => '', |
|
| 366 | + 'adresse_neuf' => '', |
|
| 367 | + 'jours_neuf' => '', |
|
| 368 | + 'quoi_de_neuf' => 'non', |
|
| 369 | + 'preview' => ',0minirezo,1comite,', |
|
| 370 | + |
|
| 371 | + 'syndication_integrale' => 'oui', |
|
| 372 | + 'charset' => _DEFAULT_CHARSET, |
|
| 373 | + 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 374 | + |
|
| 375 | + 'multi_rubriques' => 'non', |
|
| 376 | + 'multi_secteurs' => 'non', |
|
| 377 | + 'gerer_trad' => 'non', |
|
| 378 | + 'langues_multilingue' => '', |
|
| 379 | + |
|
| 380 | + 'version_html_max' => 'html4', |
|
| 381 | + |
|
| 382 | + 'type_urls' => 'page', |
|
| 383 | + |
|
| 384 | + 'email_envoi' => '', |
|
| 385 | + 'email_webmaster' => '', |
|
| 386 | + 'auto_compress_http' => 'non', |
|
| 387 | + ]); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -395,43 +395,43 @@ discard block |
||
| 395 | 395 | * @return void |
| 396 | 396 | */ |
| 397 | 397 | function actualise_metas($liste_meta) { |
| 398 | - $meta_serveur = |
|
| 399 | - [ |
|
| 400 | - 'version_installee', |
|
| 401 | - 'adresse_site', |
|
| 402 | - 'alea_ephemere_ancien', |
|
| 403 | - 'alea_ephemere', |
|
| 404 | - 'alea_ephemere_date', |
|
| 405 | - 'langue_site', |
|
| 406 | - 'langues_proposees', |
|
| 407 | - 'date_calcul_rubriques', |
|
| 408 | - 'derniere_modif', |
|
| 409 | - 'optimiser_table', |
|
| 410 | - 'drapeau_edition', |
|
| 411 | - 'creer_preview', |
|
| 412 | - 'taille_preview', |
|
| 413 | - 'creer_htpasswd', |
|
| 414 | - 'creer_htaccess', |
|
| 415 | - 'gd_formats_read', |
|
| 416 | - 'gd_formats', |
|
| 417 | - 'netpbm_formats', |
|
| 418 | - 'formats_graphiques', |
|
| 419 | - 'image_process', |
|
| 420 | - 'plugin_header', |
|
| 421 | - 'plugin' |
|
| 422 | - ]; |
|
| 423 | - // verifier le impt=non |
|
| 424 | - sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 425 | - |
|
| 426 | - foreach ($liste_meta as $nom => $valeur) { |
|
| 427 | - if (empty($GLOBALS['meta'][$nom])) { |
|
| 428 | - ecrire_meta($nom, $valeur); |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - include_spip('inc/rubriques'); |
|
| 433 | - $langues = calculer_langues_utilisees(); |
|
| 434 | - ecrire_meta('langues_utilisees', $langues); |
|
| 398 | + $meta_serveur = |
|
| 399 | + [ |
|
| 400 | + 'version_installee', |
|
| 401 | + 'adresse_site', |
|
| 402 | + 'alea_ephemere_ancien', |
|
| 403 | + 'alea_ephemere', |
|
| 404 | + 'alea_ephemere_date', |
|
| 405 | + 'langue_site', |
|
| 406 | + 'langues_proposees', |
|
| 407 | + 'date_calcul_rubriques', |
|
| 408 | + 'derniere_modif', |
|
| 409 | + 'optimiser_table', |
|
| 410 | + 'drapeau_edition', |
|
| 411 | + 'creer_preview', |
|
| 412 | + 'taille_preview', |
|
| 413 | + 'creer_htpasswd', |
|
| 414 | + 'creer_htaccess', |
|
| 415 | + 'gd_formats_read', |
|
| 416 | + 'gd_formats', |
|
| 417 | + 'netpbm_formats', |
|
| 418 | + 'formats_graphiques', |
|
| 419 | + 'image_process', |
|
| 420 | + 'plugin_header', |
|
| 421 | + 'plugin' |
|
| 422 | + ]; |
|
| 423 | + // verifier le impt=non |
|
| 424 | + sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 425 | + |
|
| 426 | + foreach ($liste_meta as $nom => $valeur) { |
|
| 427 | + if (empty($GLOBALS['meta'][$nom])) { |
|
| 428 | + ecrire_meta($nom, $valeur); |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + include_spip('inc/rubriques'); |
|
| 433 | + $langues = calculer_langues_utilisees(); |
|
| 434 | + ecrire_meta('langues_utilisees', $langues); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | |
@@ -453,18 +453,18 @@ discard block |
||
| 453 | 453 | */ |
| 454 | 454 | function appliquer_modifs_config($purger_skel = false) { |
| 455 | 455 | |
| 456 | - foreach (liste_metas() as $i => $v) { |
|
| 457 | - if (($x = _request($i)) !== null) { |
|
| 458 | - ecrire_meta($i, $x); |
|
| 459 | - } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 460 | - ecrire_meta($i, $v); |
|
| 461 | - } |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - if ($purger_skel) { |
|
| 465 | - include_spip('inc/invalideur'); |
|
| 466 | - purger_repertoire(_DIR_SKELS); |
|
| 467 | - } |
|
| 456 | + foreach (liste_metas() as $i => $v) { |
|
| 457 | + if (($x = _request($i)) !== null) { |
|
| 458 | + ecrire_meta($i, $x); |
|
| 459 | + } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 460 | + ecrire_meta($i, $v); |
|
| 461 | + } |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + if ($purger_skel) { |
|
| 465 | + include_spip('inc/invalideur'); |
|
| 466 | + purger_repertoire(_DIR_SKELS); |
|
| 467 | + } |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -475,21 +475,21 @@ discard block |
||
| 475 | 475 | * @return string |
| 476 | 476 | */ |
| 477 | 477 | function appliquer_adresse_site($adresse_site) { |
| 478 | - if ($adresse_site !== null) { |
|
| 479 | - if (!strlen($adresse_site)) { |
|
| 480 | - $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 481 | - $adresse_site = url_de_base(); |
|
| 482 | - } |
|
| 483 | - $adresse_site = preg_replace(',/?\s*$,', '', $adresse_site); |
|
| 478 | + if ($adresse_site !== null) { |
|
| 479 | + if (!strlen($adresse_site)) { |
|
| 480 | + $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 481 | + $adresse_site = url_de_base(); |
|
| 482 | + } |
|
| 483 | + $adresse_site = preg_replace(',/?\s*$,', '', $adresse_site); |
|
| 484 | 484 | |
| 485 | - if (!tester_url_absolue($adresse_site)) { |
|
| 486 | - $adresse_site = "http://$adresse_site"; |
|
| 487 | - } |
|
| 485 | + if (!tester_url_absolue($adresse_site)) { |
|
| 486 | + $adresse_site = "http://$adresse_site"; |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - $adresse_site = entites_html($adresse_site); |
|
| 489 | + $adresse_site = entites_html($adresse_site); |
|
| 490 | 490 | |
| 491 | - ecrire_meta('adresse_site', $adresse_site); |
|
| 492 | - } |
|
| 491 | + ecrire_meta('adresse_site', $adresse_site); |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | - return $adresse_site; |
|
| 494 | + return $adresse_site; |
|
| 495 | 495 | } |