@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $GLOBALS['contexte'] = calculer_contexte(); |
| 39 | 39 | $page = ['contexte_implicite' => calculer_contexte_implicite()]; |
| 40 | - $page['contexte_implicite']['cache'] = $fond . preg_replace( |
|
| 40 | + $page['contexte_implicite']['cache'] = $fond.preg_replace( |
|
| 41 | 41 | ',\.[a-zA-Z0-9]*$,', |
| 42 | 42 | '', |
| 43 | 43 | preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']) |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | if ($page === '') { |
| 139 | 139 | $erreur = _T( |
| 140 | 140 | 'info_erreur_squelette2', |
| 141 | - ['fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES] |
|
| 141 | + ['fichier' => spip_htmlspecialchars($fond).'.'._EXTENSION_SQUELETTES] |
|
| 142 | 142 | ); |
| 143 | 143 | erreur_squelette($erreur); |
| 144 | 144 | // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
| 184 | 184 | and !isset($page['entetes']['Last-Modified']) |
| 185 | 185 | ) { |
| 186 | - $page['entetes']['Last-Modified'] = gmdate('D, d M Y H:i:s', $lastmodified) . ' GMT'; |
|
| 186 | + $page['entetes']['Last-Modified'] = gmdate('D, d M Y H:i:s', $lastmodified).' GMT'; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // fermer la connexion apres les headers si requete HEAD |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | 'spip_version_code' => $GLOBALS['spip_version_code'], |
| 249 | 249 | ]; |
| 250 | 250 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 251 | - $contexte_implicite['host'] .= '|' . $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 251 | + $contexte_implicite['host'] .= '|'.$_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $contexte_implicite; |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | if (is_null($id)) { |
| 582 | - $msg = "modeles/$modele : " . _T('zbug_parametres_inclus_incorrects', ['param' => "id/$primary"]); |
|
| 582 | + $msg = "modeles/$modele : "._T('zbug_parametres_inclus_incorrects', ['param' => "id/$primary"]); |
|
| 583 | 583 | erreur_squelette($msg); |
| 584 | 584 | // on passe id=0 au routeur pour tomber sur le modele par defaut et eviter une seconde erreur sur un modele inexistant |
| 585 | 585 | $id = 0; |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
| 629 | - if (!trouve_modele($fond = ($type . '_' . $soustype))) { |
|
| 629 | + if (!trouve_modele($fond = ($type.'_'.$soustype))) { |
|
| 630 | 630 | $fond = ''; |
| 631 | 631 | $class = $soustype; |
| 632 | 632 | } |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | return false; |
| 643 | 643 | } |
| 644 | - $fond = 'modeles/' . $fond; |
|
| 644 | + $fond = 'modeles/'.$fond; |
|
| 645 | 645 | // Creer le contexte |
| 646 | 646 | $contexte = $env; |
| 647 | 647 | $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | // sinon, s'il y a un lien, on l'ajoute classiquement |
| 683 | 683 | if ( |
| 684 | 684 | strstr( |
| 685 | - ' ' . ($classes = extraire_attribut($retour, 'class')) . ' ', |
|
| 685 | + ' '.($classes = extraire_attribut($retour, 'class')).' ', |
|
| 686 | 686 | 'spip_lien_ok' |
| 687 | 687 | ) |
| 688 | 688 | ) { |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | ); |
| 694 | 694 | } else { |
| 695 | 695 | if ($lien) { |
| 696 | - $retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . '</a>'; |
|
| 696 | + $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour.'</a>'; |
|
| 697 | 697 | } |
| 698 | 698 | } |
| 699 | 699 | |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | return $page; |
| 718 | 718 | } |
| 719 | 719 | // eval $page et affecte $res |
| 720 | - include _ROOT_RESTREINT . 'public/evaluer_page.php'; |
|
| 720 | + include _ROOT_RESTREINT.'public/evaluer_page.php'; |
|
| 721 | 721 | |
| 722 | 722 | // Lever un drapeau (global) si le fond utilise #SESSION |
| 723 | 723 | // a destination de public/parametrer |
@@ -785,16 +785,16 @@ discard block |
||
| 785 | 785 | if (($pos = strpos($head, '<head>')) !== false) { |
| 786 | 786 | $head = substr_replace($head, $base, $pos + 6, 0); |
| 787 | 787 | } elseif (preg_match(',<head[^>]*>,i', $head, $r)) { |
| 788 | - $head = str_replace($r[0], $r[0] . $base, $head); |
|
| 788 | + $head = str_replace($r[0], $r[0].$base, $head); |
|
| 789 | 789 | } |
| 790 | - $texte = $head . substr($texte, $poshead); |
|
| 790 | + $texte = $head.substr($texte, $poshead); |
|
| 791 | 791 | } |
| 792 | 792 | if ($href_base) { |
| 793 | 793 | // gerer les ancres |
| 794 | 794 | $base = $_SERVER['REQUEST_URI']; |
| 795 | 795 | // pas de guillemets ni < dans l'URL qu'on insere dans le HTML |
| 796 | 796 | if (strpos($base, "'") or strpos($base, '"') or strpos($base, '<')) { |
| 797 | - $base = str_replace(["'",'"','<'], ['%27','%22','%3C'], $base); |
|
| 797 | + $base = str_replace(["'", '"', '<'], ['%27', '%22', '%3C'], $base); |
|
| 798 | 798 | } |
| 799 | 799 | if (strpos($texte, "href='#") !== false) { |
| 800 | 800 | $texte = str_replace("href='#", "href='$base#", $texte); |
@@ -20,178 +20,178 @@ discard block |
||
| 20 | 20 | **/ |
| 21 | 21 | |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // En cas de modification, il faut aussi actualiser la regexp de nettoyer_uri_var() dans inc/utils.php |
| 27 | 27 | if (!defined('_CONTEXTE_IGNORE_VARIABLES')) { |
| 28 | - define('_CONTEXTE_IGNORE_VARIABLES', '/(^var_|^PHPSESSID$|^fbclid$|^utm_)/'); |
|
| 28 | + define('_CONTEXTE_IGNORE_VARIABLES', '/(^var_|^PHPSESSID$|^fbclid$|^utm_)/'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | function assembler($fond, string $connect = '') { |
| 32 | 32 | |
| 33 | - $chemin_cache = null; |
|
| 34 | - $lastmodified = null; |
|
| 35 | - $res = null; |
|
| 36 | - // flag_preserver est modifie ici, et utilise en globale |
|
| 37 | - // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
|
| 38 | - // contexte est utilise en globale dans le formulaire d'admin |
|
| 39 | - |
|
| 40 | - $GLOBALS['contexte'] = calculer_contexte(); |
|
| 41 | - $page = ['contexte_implicite' => calculer_contexte_implicite()]; |
|
| 42 | - $page['contexte_implicite']['cache'] = $fond . preg_replace( |
|
| 43 | - ',\.[a-zA-Z0-9]*$,', |
|
| 44 | - '', |
|
| 45 | - preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']) |
|
| 46 | - ); |
|
| 47 | - // Cette fonction est utilisee deux fois |
|
| 48 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 49 | - // Les quatre derniers parametres sont modifies par la fonction: |
|
| 50 | - // emplacement, validite, et, s'il est valide, contenu & age |
|
| 51 | - if ($cacher) { |
|
| 52 | - $res = $cacher($GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, $page, $lastmodified); |
|
| 53 | - } else { |
|
| 54 | - $GLOBALS['use_cache'] = -1; |
|
| 55 | - } |
|
| 56 | - // Si un resultat est retourne, c'est un message d'impossibilite |
|
| 57 | - if ($res) { |
|
| 58 | - return ['texte' => $res]; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - if (!$chemin_cache || !$lastmodified) { |
|
| 62 | - $lastmodified = time(); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
|
| 66 | - $calculer_page = true; |
|
| 67 | - |
|
| 68 | - // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) |
|
| 69 | - // une perennite valide a meme reponse qu'une requete HEAD (par defaut les |
|
| 70 | - // pages sont dynamiques) |
|
| 71 | - if ( |
|
| 72 | - isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 73 | - and (!defined('_VAR_MODE') or !_VAR_MODE) |
|
| 74 | - and $chemin_cache |
|
| 75 | - and isset($page['entetes']) |
|
| 76 | - and isset($page['entetes']['Cache-Control']) |
|
| 77 | - and strstr($page['entetes']['Cache-Control'], 'max-age=') |
|
| 78 | - and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 79 | - ) { |
|
| 80 | - $since = preg_replace( |
|
| 81 | - '/;.*/', |
|
| 82 | - '', |
|
| 83 | - $_SERVER['HTTP_IF_MODIFIED_SINCE'] |
|
| 84 | - ); |
|
| 85 | - $since = str_replace('GMT', '', $since); |
|
| 86 | - if (trim($since) == gmdate('D, d M Y H:i:s', $lastmodified)) { |
|
| 87 | - $page['status'] = 304; |
|
| 88 | - $headers_only = true; |
|
| 89 | - $calculer_page = false; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // Si requete HEAD ou Last-modified compatible, ignorer le texte |
|
| 94 | - // et pas de content-type (pour contrer le bouton admin de inc-public) |
|
| 95 | - if (!$calculer_page) { |
|
| 96 | - $page['texte'] = ''; |
|
| 97 | - } else { |
|
| 98 | - // si la page est prise dans le cache |
|
| 99 | - if (!$GLOBALS['use_cache']) { |
|
| 100 | - // Informer les boutons d'admin du contexte |
|
| 101 | - // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
|
| 102 | - $GLOBALS['contexte'] = $page['contexte']; |
|
| 103 | - |
|
| 104 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 105 | - // d'inversion url => objet |
|
| 106 | - // plus necessaire si on utilise bien la fonction urls_decoder_url |
|
| 107 | - #unset($_SERVER['REDIRECT_url_propre']); |
|
| 108 | - #unset($_ENV['url_propre']); |
|
| 109 | - } else { |
|
| 110 | - // Compat ascendante : |
|
| 111 | - // 1. $contexte est global |
|
| 112 | - // (a evacuer car urls_decoder_url gere ce probleme ?) |
|
| 113 | - // et calculer la page |
|
| 114 | - if (!test_espace_prive()) { |
|
| 115 | - include_spip('inc/urls'); |
|
| 116 | - [$fond, $GLOBALS['contexte'], $url_redirect] = urls_decoder_url( |
|
| 117 | - nettoyer_uri(), |
|
| 118 | - $fond, |
|
| 119 | - $GLOBALS['contexte'], |
|
| 120 | - true |
|
| 121 | - ); |
|
| 122 | - } |
|
| 123 | - // squelette par defaut |
|
| 124 | - if (!strlen($fond ?? '')) { |
|
| 125 | - $fond = 'sommaire'; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - // produire la page : peut mettre a jour $lastmodified |
|
| 129 | - $produire_page = charger_fonction('produire_page', 'public'); |
|
| 130 | - $page = $produire_page( |
|
| 131 | - $fond, |
|
| 132 | - $GLOBALS['contexte'], |
|
| 133 | - $GLOBALS['use_cache'], |
|
| 134 | - $chemin_cache, |
|
| 135 | - null, |
|
| 136 | - $page, |
|
| 137 | - $lastmodified, |
|
| 138 | - $connect |
|
| 139 | - ); |
|
| 140 | - if ($page === '') { |
|
| 141 | - $erreur = _T( |
|
| 142 | - 'info_erreur_squelette2', |
|
| 143 | - ['fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES] |
|
| 144 | - ); |
|
| 145 | - erreur_squelette($erreur); |
|
| 146 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 147 | - $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - if ($page and $chemin_cache) { |
|
| 152 | - $page['cache'] = $chemin_cache; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - auto_content_type($page); |
|
| 156 | - |
|
| 157 | - $GLOBALS['flag_preserver'] |= headers_sent(); |
|
| 158 | - |
|
| 159 | - // Definir les entetes si ce n'est fait |
|
| 160 | - if (!$GLOBALS['flag_preserver']) { |
|
| 161 | - // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions |
|
| 162 | - if ( |
|
| 163 | - trim($page['texte']) === '' |
|
| 164 | - and _VAR_MODE !== 'debug' |
|
| 165 | - and !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur |
|
| 166 | - ) { |
|
| 167 | - $GLOBALS['contexte']['fond_erreur'] = $fond; |
|
| 168 | - $page = message_page_indisponible($page, $GLOBALS['contexte']); |
|
| 169 | - } |
|
| 170 | - // pas de cache client en mode 'observation' |
|
| 171 | - if (defined('_VAR_MODE') and _VAR_MODE) { |
|
| 172 | - $page['entetes']['Cache-Control'] = 'no-cache,must-revalidate'; |
|
| 173 | - $page['entetes']['Pragma'] = 'no-cache'; |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // Entete Last-Modified: |
|
| 179 | - // eviter d'etre incoherent en envoyant un lastmodified identique |
|
| 180 | - // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
|
| 181 | - if ( |
|
| 182 | - $lastmodified |
|
| 183 | - and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 184 | - and !isset($page['entetes']['Last-Modified']) |
|
| 185 | - ) { |
|
| 186 | - $page['entetes']['Last-Modified'] = gmdate('D, d M Y H:i:s', $lastmodified) . ' GMT'; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - // fermer la connexion apres les headers si requete HEAD |
|
| 190 | - if ($headers_only) { |
|
| 191 | - $page['entetes']['Connection'] = 'close'; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - return $page; |
|
| 33 | + $chemin_cache = null; |
|
| 34 | + $lastmodified = null; |
|
| 35 | + $res = null; |
|
| 36 | + // flag_preserver est modifie ici, et utilise en globale |
|
| 37 | + // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
|
| 38 | + // contexte est utilise en globale dans le formulaire d'admin |
|
| 39 | + |
|
| 40 | + $GLOBALS['contexte'] = calculer_contexte(); |
|
| 41 | + $page = ['contexte_implicite' => calculer_contexte_implicite()]; |
|
| 42 | + $page['contexte_implicite']['cache'] = $fond . preg_replace( |
|
| 43 | + ',\.[a-zA-Z0-9]*$,', |
|
| 44 | + '', |
|
| 45 | + preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']) |
|
| 46 | + ); |
|
| 47 | + // Cette fonction est utilisee deux fois |
|
| 48 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 49 | + // Les quatre derniers parametres sont modifies par la fonction: |
|
| 50 | + // emplacement, validite, et, s'il est valide, contenu & age |
|
| 51 | + if ($cacher) { |
|
| 52 | + $res = $cacher($GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, $page, $lastmodified); |
|
| 53 | + } else { |
|
| 54 | + $GLOBALS['use_cache'] = -1; |
|
| 55 | + } |
|
| 56 | + // Si un resultat est retourne, c'est un message d'impossibilite |
|
| 57 | + if ($res) { |
|
| 58 | + return ['texte' => $res]; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + if (!$chemin_cache || !$lastmodified) { |
|
| 62 | + $lastmodified = time(); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
|
| 66 | + $calculer_page = true; |
|
| 67 | + |
|
| 68 | + // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) |
|
| 69 | + // une perennite valide a meme reponse qu'une requete HEAD (par defaut les |
|
| 70 | + // pages sont dynamiques) |
|
| 71 | + if ( |
|
| 72 | + isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 73 | + and (!defined('_VAR_MODE') or !_VAR_MODE) |
|
| 74 | + and $chemin_cache |
|
| 75 | + and isset($page['entetes']) |
|
| 76 | + and isset($page['entetes']['Cache-Control']) |
|
| 77 | + and strstr($page['entetes']['Cache-Control'], 'max-age=') |
|
| 78 | + and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 79 | + ) { |
|
| 80 | + $since = preg_replace( |
|
| 81 | + '/;.*/', |
|
| 82 | + '', |
|
| 83 | + $_SERVER['HTTP_IF_MODIFIED_SINCE'] |
|
| 84 | + ); |
|
| 85 | + $since = str_replace('GMT', '', $since); |
|
| 86 | + if (trim($since) == gmdate('D, d M Y H:i:s', $lastmodified)) { |
|
| 87 | + $page['status'] = 304; |
|
| 88 | + $headers_only = true; |
|
| 89 | + $calculer_page = false; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // Si requete HEAD ou Last-modified compatible, ignorer le texte |
|
| 94 | + // et pas de content-type (pour contrer le bouton admin de inc-public) |
|
| 95 | + if (!$calculer_page) { |
|
| 96 | + $page['texte'] = ''; |
|
| 97 | + } else { |
|
| 98 | + // si la page est prise dans le cache |
|
| 99 | + if (!$GLOBALS['use_cache']) { |
|
| 100 | + // Informer les boutons d'admin du contexte |
|
| 101 | + // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
|
| 102 | + $GLOBALS['contexte'] = $page['contexte']; |
|
| 103 | + |
|
| 104 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 105 | + // d'inversion url => objet |
|
| 106 | + // plus necessaire si on utilise bien la fonction urls_decoder_url |
|
| 107 | + #unset($_SERVER['REDIRECT_url_propre']); |
|
| 108 | + #unset($_ENV['url_propre']); |
|
| 109 | + } else { |
|
| 110 | + // Compat ascendante : |
|
| 111 | + // 1. $contexte est global |
|
| 112 | + // (a evacuer car urls_decoder_url gere ce probleme ?) |
|
| 113 | + // et calculer la page |
|
| 114 | + if (!test_espace_prive()) { |
|
| 115 | + include_spip('inc/urls'); |
|
| 116 | + [$fond, $GLOBALS['contexte'], $url_redirect] = urls_decoder_url( |
|
| 117 | + nettoyer_uri(), |
|
| 118 | + $fond, |
|
| 119 | + $GLOBALS['contexte'], |
|
| 120 | + true |
|
| 121 | + ); |
|
| 122 | + } |
|
| 123 | + // squelette par defaut |
|
| 124 | + if (!strlen($fond ?? '')) { |
|
| 125 | + $fond = 'sommaire'; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + // produire la page : peut mettre a jour $lastmodified |
|
| 129 | + $produire_page = charger_fonction('produire_page', 'public'); |
|
| 130 | + $page = $produire_page( |
|
| 131 | + $fond, |
|
| 132 | + $GLOBALS['contexte'], |
|
| 133 | + $GLOBALS['use_cache'], |
|
| 134 | + $chemin_cache, |
|
| 135 | + null, |
|
| 136 | + $page, |
|
| 137 | + $lastmodified, |
|
| 138 | + $connect |
|
| 139 | + ); |
|
| 140 | + if ($page === '') { |
|
| 141 | + $erreur = _T( |
|
| 142 | + 'info_erreur_squelette2', |
|
| 143 | + ['fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES] |
|
| 144 | + ); |
|
| 145 | + erreur_squelette($erreur); |
|
| 146 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 147 | + $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + if ($page and $chemin_cache) { |
|
| 152 | + $page['cache'] = $chemin_cache; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + auto_content_type($page); |
|
| 156 | + |
|
| 157 | + $GLOBALS['flag_preserver'] |= headers_sent(); |
|
| 158 | + |
|
| 159 | + // Definir les entetes si ce n'est fait |
|
| 160 | + if (!$GLOBALS['flag_preserver']) { |
|
| 161 | + // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions |
|
| 162 | + if ( |
|
| 163 | + trim($page['texte']) === '' |
|
| 164 | + and _VAR_MODE !== 'debug' |
|
| 165 | + and !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur |
|
| 166 | + ) { |
|
| 167 | + $GLOBALS['contexte']['fond_erreur'] = $fond; |
|
| 168 | + $page = message_page_indisponible($page, $GLOBALS['contexte']); |
|
| 169 | + } |
|
| 170 | + // pas de cache client en mode 'observation' |
|
| 171 | + if (defined('_VAR_MODE') and _VAR_MODE) { |
|
| 172 | + $page['entetes']['Cache-Control'] = 'no-cache,must-revalidate'; |
|
| 173 | + $page['entetes']['Pragma'] = 'no-cache'; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // Entete Last-Modified: |
|
| 179 | + // eviter d'etre incoherent en envoyant un lastmodified identique |
|
| 180 | + // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
|
| 181 | + if ( |
|
| 182 | + $lastmodified |
|
| 183 | + and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 184 | + and !isset($page['entetes']['Last-Modified']) |
|
| 185 | + ) { |
|
| 186 | + $page['entetes']['Last-Modified'] = gmdate('D, d M Y H:i:s', $lastmodified) . ' GMT'; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + // fermer la connexion apres les headers si requete HEAD |
|
| 190 | + if ($headers_only) { |
|
| 191 | + $page['entetes']['Connection'] = 'close'; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + return $page; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -208,19 +208,19 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | function calculer_contexte() { |
| 210 | 210 | |
| 211 | - $contexte = []; |
|
| 212 | - foreach ($_GET as $var => $val) { |
|
| 213 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { |
|
| 214 | - $contexte[$var] = $val; |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - foreach ($_POST as $var => $val) { |
|
| 218 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { |
|
| 219 | - $contexte[$var] = $val; |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - return $contexte; |
|
| 211 | + $contexte = []; |
|
| 212 | + foreach ($_GET as $var => $val) { |
|
| 213 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { |
|
| 214 | + $contexte[$var] = $val; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + foreach ($_POST as $var => $val) { |
|
| 218 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { |
|
| 219 | + $contexte[$var] = $val; |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + return $contexte; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -231,25 +231,25 @@ discard block |
||
| 231 | 231 | * @return array |
| 232 | 232 | */ |
| 233 | 233 | function calculer_contexte_implicite() { |
| 234 | - static $notes = null; |
|
| 235 | - if (is_null($notes)) { |
|
| 236 | - $notes = charger_fonction('notes', 'inc', true); |
|
| 237 | - } |
|
| 238 | - $contexte_implicite = [ |
|
| 239 | - 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
|
| 240 | - 'host' => ($_SERVER['HTTP_HOST'] ?? null), |
|
| 241 | - 'https' => ($_SERVER['HTTPS'] ?? ''), |
|
| 242 | - 'espace' => test_espace_prive(), |
|
| 243 | - 'marqueur' => ($GLOBALS['marqueur'] ?? ''), |
|
| 244 | - 'marqueur_skel' => ($GLOBALS['marqueur_skel'] ?? ''), |
|
| 245 | - 'notes' => $notes ? $notes('', 'contexter_cache') : '', |
|
| 246 | - 'spip_version_code' => $GLOBALS['spip_version_code'], |
|
| 247 | - ]; |
|
| 248 | - if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 249 | - $contexte_implicite['host'] .= '|' . $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - return $contexte_implicite; |
|
| 234 | + static $notes = null; |
|
| 235 | + if (is_null($notes)) { |
|
| 236 | + $notes = charger_fonction('notes', 'inc', true); |
|
| 237 | + } |
|
| 238 | + $contexte_implicite = [ |
|
| 239 | + 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
|
| 240 | + 'host' => ($_SERVER['HTTP_HOST'] ?? null), |
|
| 241 | + 'https' => ($_SERVER['HTTPS'] ?? ''), |
|
| 242 | + 'espace' => test_espace_prive(), |
|
| 243 | + 'marqueur' => ($GLOBALS['marqueur'] ?? ''), |
|
| 244 | + 'marqueur_skel' => ($GLOBALS['marqueur_skel'] ?? ''), |
|
| 245 | + 'notes' => $notes ? $notes('', 'contexter_cache') : '', |
|
| 246 | + 'spip_version_code' => $GLOBALS['spip_version_code'], |
|
| 247 | + ]; |
|
| 248 | + if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 249 | + $contexte_implicite['host'] .= '|' . $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + return $contexte_implicite; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // |
@@ -258,55 +258,55 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | function auto_content_type($page) { |
| 260 | 260 | |
| 261 | - if (!isset($GLOBALS['flag_preserver'])) { |
|
| 262 | - $GLOBALS['flag_preserver'] = ($page && preg_match( |
|
| 263 | - '/header\s*\(\s*.content\-type:/isx', |
|
| 264 | - $page['texte'] |
|
| 265 | - ) || (isset($page['entetes']['Content-Type']))); |
|
| 266 | - } |
|
| 261 | + if (!isset($GLOBALS['flag_preserver'])) { |
|
| 262 | + $GLOBALS['flag_preserver'] = ($page && preg_match( |
|
| 263 | + '/header\s*\(\s*.content\-type:/isx', |
|
| 264 | + $page['texte'] |
|
| 265 | + ) || (isset($page['entetes']['Content-Type']))); |
|
| 266 | + } |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | function inclure_page($fond, $contexte, string $connect = '') { |
| 270 | - $use_cache = null; |
|
| 271 | - $chemin_cache = null; |
|
| 272 | - $lastinclude = null; |
|
| 273 | - $res = null; |
|
| 274 | - static $cacher, $produire_page; |
|
| 275 | - |
|
| 276 | - // enlever le fond de contexte inclus car sinon il prend la main |
|
| 277 | - // dans les sous inclusions -> boucle infinie d'inclusion identique |
|
| 278 | - // (cette precaution n'est probablement plus utile) |
|
| 279 | - unset($contexte['fond']); |
|
| 280 | - $page = ['contexte_implicite' => calculer_contexte_implicite()]; |
|
| 281 | - $page['contexte_implicite']['cache'] = $fond; |
|
| 282 | - if (is_null($cacher)) { |
|
| 283 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 284 | - } |
|
| 285 | - // Les quatre derniers parametres sont modifies par la fonction: |
|
| 286 | - // emplacement, validite, et, s'il est valide, contenu & age |
|
| 287 | - if ($cacher) { |
|
| 288 | - $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 289 | - } else { |
|
| 290 | - $use_cache = -1; |
|
| 291 | - } |
|
| 292 | - // $res = message d'erreur : on sort de la |
|
| 293 | - if ($res) { |
|
| 294 | - return ['texte' => $res]; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - // Si use_cache ne vaut pas 0, la page doit etre calculee |
|
| 298 | - // produire la page : peut mettre a jour $lastinclude |
|
| 299 | - // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
|
| 300 | - if ($use_cache) { |
|
| 301 | - if (is_null($produire_page)) { |
|
| 302 | - $produire_page = charger_fonction('produire_page', 'public'); |
|
| 303 | - } |
|
| 304 | - $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
|
| 305 | - } |
|
| 306 | - // dans tous les cas, mettre a jour $GLOBALS['lastmodified'] |
|
| 307 | - $GLOBALS['lastmodified'] = max(($GLOBALS['lastmodified'] ?? 0), $lastinclude); |
|
| 308 | - |
|
| 309 | - return $page; |
|
| 270 | + $use_cache = null; |
|
| 271 | + $chemin_cache = null; |
|
| 272 | + $lastinclude = null; |
|
| 273 | + $res = null; |
|
| 274 | + static $cacher, $produire_page; |
|
| 275 | + |
|
| 276 | + // enlever le fond de contexte inclus car sinon il prend la main |
|
| 277 | + // dans les sous inclusions -> boucle infinie d'inclusion identique |
|
| 278 | + // (cette precaution n'est probablement plus utile) |
|
| 279 | + unset($contexte['fond']); |
|
| 280 | + $page = ['contexte_implicite' => calculer_contexte_implicite()]; |
|
| 281 | + $page['contexte_implicite']['cache'] = $fond; |
|
| 282 | + if (is_null($cacher)) { |
|
| 283 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 284 | + } |
|
| 285 | + // Les quatre derniers parametres sont modifies par la fonction: |
|
| 286 | + // emplacement, validite, et, s'il est valide, contenu & age |
|
| 287 | + if ($cacher) { |
|
| 288 | + $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 289 | + } else { |
|
| 290 | + $use_cache = -1; |
|
| 291 | + } |
|
| 292 | + // $res = message d'erreur : on sort de la |
|
| 293 | + if ($res) { |
|
| 294 | + return ['texte' => $res]; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + // Si use_cache ne vaut pas 0, la page doit etre calculee |
|
| 298 | + // produire la page : peut mettre a jour $lastinclude |
|
| 299 | + // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
|
| 300 | + if ($use_cache) { |
|
| 301 | + if (is_null($produire_page)) { |
|
| 302 | + $produire_page = charger_fonction('produire_page', 'public'); |
|
| 303 | + } |
|
| 304 | + $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
|
| 305 | + } |
|
| 306 | + // dans tous les cas, mettre a jour $GLOBALS['lastmodified'] |
|
| 307 | + $GLOBALS['lastmodified'] = max(($GLOBALS['lastmodified'] ?? 0), $lastinclude); |
|
| 308 | + |
|
| 309 | + return $page; |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -324,41 +324,41 @@ discard block |
||
| 324 | 324 | * @return array |
| 325 | 325 | */ |
| 326 | 326 | function public_produire_page_dist( |
| 327 | - $fond, |
|
| 328 | - $contexte, |
|
| 329 | - $use_cache, |
|
| 330 | - $chemin_cache, |
|
| 331 | - $contexte_cache, |
|
| 332 | - &$page, |
|
| 333 | - &$lastinclude, |
|
| 334 | - $connect = '' |
|
| 327 | + $fond, |
|
| 328 | + $contexte, |
|
| 329 | + $use_cache, |
|
| 330 | + $chemin_cache, |
|
| 331 | + $contexte_cache, |
|
| 332 | + &$page, |
|
| 333 | + &$lastinclude, |
|
| 334 | + $connect = '' |
|
| 335 | 335 | ) { |
| 336 | - static $parametrer, $cacher; |
|
| 337 | - if (!$parametrer) { |
|
| 338 | - $parametrer = charger_fonction('parametrer', 'public'); |
|
| 339 | - } |
|
| 340 | - $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
|
| 341 | - // et on l'enregistre sur le disque |
|
| 342 | - if ( |
|
| 343 | - $chemin_cache |
|
| 344 | - and $use_cache > -1 |
|
| 345 | - and is_array($page) |
|
| 346 | - and count($page) |
|
| 347 | - and isset($page['entetes']['X-Spip-Cache']) |
|
| 348 | - and $page['entetes']['X-Spip-Cache'] > 0 |
|
| 349 | - ) { |
|
| 350 | - if (is_null($cacher)) { |
|
| 351 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 352 | - } |
|
| 353 | - $lastinclude = time(); |
|
| 354 | - if ($cacher) { |
|
| 355 | - $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 356 | - } else { |
|
| 357 | - $use_cache = -1; |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - return $page; |
|
| 336 | + static $parametrer, $cacher; |
|
| 337 | + if (!$parametrer) { |
|
| 338 | + $parametrer = charger_fonction('parametrer', 'public'); |
|
| 339 | + } |
|
| 340 | + $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
|
| 341 | + // et on l'enregistre sur le disque |
|
| 342 | + if ( |
|
| 343 | + $chemin_cache |
|
| 344 | + and $use_cache > -1 |
|
| 345 | + and is_array($page) |
|
| 346 | + and count($page) |
|
| 347 | + and isset($page['entetes']['X-Spip-Cache']) |
|
| 348 | + and $page['entetes']['X-Spip-Cache'] > 0 |
|
| 349 | + ) { |
|
| 350 | + if (is_null($cacher)) { |
|
| 351 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 352 | + } |
|
| 353 | + $lastinclude = time(); |
|
| 354 | + if ($cacher) { |
|
| 355 | + $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 356 | + } else { |
|
| 357 | + $use_cache = -1; |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + return $page; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | // Fonction inseree par le compilateur dans le code compile. |
@@ -372,14 +372,14 @@ discard block |
||
| 372 | 372 | // 4: langue |
| 373 | 373 | |
| 374 | 374 | function inserer_balise_dynamique($contexte_exec, $contexte_compil) { |
| 375 | - arguments_balise_dyn_depuis_modele(null, 'reset'); |
|
| 376 | - |
|
| 377 | - if (!is_array($contexte_exec)) { |
|
| 378 | - echo $contexte_exec; |
|
| 379 | - } // message d'erreur etc |
|
| 380 | - else { |
|
| 381 | - inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
|
| 382 | - } |
|
| 375 | + arguments_balise_dyn_depuis_modele(null, 'reset'); |
|
| 376 | + |
|
| 377 | + if (!is_array($contexte_exec)) { |
|
| 378 | + echo $contexte_exec; |
|
| 379 | + } // message d'erreur etc |
|
| 380 | + else { |
|
| 381 | + inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
|
| 382 | + } |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
@@ -392,101 +392,101 @@ discard block |
||
| 392 | 392 | * @return string |
| 393 | 393 | */ |
| 394 | 394 | function inclure_balise_dynamique($texte, $echo = true, $contexte_compil = []) { |
| 395 | - if (is_array($texte)) { |
|
| 396 | - [$fond, $delainc, $contexte_inclus] = $texte; |
|
| 397 | - |
|
| 398 | - // delais a l'ancienne, c'est pratiquement mort |
|
| 399 | - $d = $GLOBALS['delais'] ?? null; |
|
| 400 | - $GLOBALS['delais'] = $delainc; |
|
| 401 | - |
|
| 402 | - $page = recuperer_fond( |
|
| 403 | - $fond, |
|
| 404 | - $contexte_inclus, |
|
| 405 | - ['trim' => false, 'raw' => true, 'compil' => $contexte_compil] |
|
| 406 | - ); |
|
| 407 | - |
|
| 408 | - $texte = $page['texte']; |
|
| 409 | - |
|
| 410 | - $GLOBALS['delais'] = $d; |
|
| 411 | - // Faire remonter les entetes |
|
| 412 | - if ( |
|
| 413 | - isset($page['entetes']) |
|
| 414 | - and is_array($page['entetes']) |
|
| 415 | - ) { |
|
| 416 | - // mais pas toutes |
|
| 417 | - unset($page['entetes']['X-Spip-Cache']); |
|
| 418 | - unset($page['entetes']['Content-Type']); |
|
| 419 | - if (isset($GLOBALS['page']) and is_array($GLOBALS['page'])) { |
|
| 420 | - if (!is_array($GLOBALS['page']['entetes'])) { |
|
| 421 | - $GLOBALS['page']['entetes'] = []; |
|
| 422 | - } |
|
| 423 | - $GLOBALS['page']['entetes'] = |
|
| 424 | - array_merge($GLOBALS['page']['entetes'], $page['entetes']); |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
|
| 428 | - if ( |
|
| 429 | - isset($page['contexte']['_pipelines']) |
|
| 430 | - and is_array($page['contexte']['_pipelines']) |
|
| 431 | - and count($page['contexte']['_pipelines']) |
|
| 432 | - ) { |
|
| 433 | - foreach ($page['contexte']['_pipelines'] as $pipe => $args) { |
|
| 434 | - $args['contexte'] = $page['contexte']; |
|
| 435 | - unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
|
| 436 | - $texte = pipeline( |
|
| 437 | - $pipe, |
|
| 438 | - [ |
|
| 439 | - 'data' => $texte, |
|
| 440 | - 'args' => $args |
|
| 441 | - ] |
|
| 442 | - ); |
|
| 443 | - } |
|
| 444 | - } |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 448 | - // compatibilite : avant on donnait le numero de ligne ou rien. |
|
| 449 | - $ligne = intval($contexte_compil[3] ?? $contexte_compil); |
|
| 450 | - $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
|
| 451 | - } |
|
| 452 | - if ($echo) { |
|
| 453 | - echo $texte; |
|
| 454 | - } else { |
|
| 455 | - return $texte; |
|
| 456 | - } |
|
| 395 | + if (is_array($texte)) { |
|
| 396 | + [$fond, $delainc, $contexte_inclus] = $texte; |
|
| 397 | + |
|
| 398 | + // delais a l'ancienne, c'est pratiquement mort |
|
| 399 | + $d = $GLOBALS['delais'] ?? null; |
|
| 400 | + $GLOBALS['delais'] = $delainc; |
|
| 401 | + |
|
| 402 | + $page = recuperer_fond( |
|
| 403 | + $fond, |
|
| 404 | + $contexte_inclus, |
|
| 405 | + ['trim' => false, 'raw' => true, 'compil' => $contexte_compil] |
|
| 406 | + ); |
|
| 407 | + |
|
| 408 | + $texte = $page['texte']; |
|
| 409 | + |
|
| 410 | + $GLOBALS['delais'] = $d; |
|
| 411 | + // Faire remonter les entetes |
|
| 412 | + if ( |
|
| 413 | + isset($page['entetes']) |
|
| 414 | + and is_array($page['entetes']) |
|
| 415 | + ) { |
|
| 416 | + // mais pas toutes |
|
| 417 | + unset($page['entetes']['X-Spip-Cache']); |
|
| 418 | + unset($page['entetes']['Content-Type']); |
|
| 419 | + if (isset($GLOBALS['page']) and is_array($GLOBALS['page'])) { |
|
| 420 | + if (!is_array($GLOBALS['page']['entetes'])) { |
|
| 421 | + $GLOBALS['page']['entetes'] = []; |
|
| 422 | + } |
|
| 423 | + $GLOBALS['page']['entetes'] = |
|
| 424 | + array_merge($GLOBALS['page']['entetes'], $page['entetes']); |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
|
| 428 | + if ( |
|
| 429 | + isset($page['contexte']['_pipelines']) |
|
| 430 | + and is_array($page['contexte']['_pipelines']) |
|
| 431 | + and count($page['contexte']['_pipelines']) |
|
| 432 | + ) { |
|
| 433 | + foreach ($page['contexte']['_pipelines'] as $pipe => $args) { |
|
| 434 | + $args['contexte'] = $page['contexte']; |
|
| 435 | + unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
|
| 436 | + $texte = pipeline( |
|
| 437 | + $pipe, |
|
| 438 | + [ |
|
| 439 | + 'data' => $texte, |
|
| 440 | + 'args' => $args |
|
| 441 | + ] |
|
| 442 | + ); |
|
| 443 | + } |
|
| 444 | + } |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 448 | + // compatibilite : avant on donnait le numero de ligne ou rien. |
|
| 449 | + $ligne = intval($contexte_compil[3] ?? $contexte_compil); |
|
| 450 | + $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
|
| 451 | + } |
|
| 452 | + if ($echo) { |
|
| 453 | + echo $texte; |
|
| 454 | + } else { |
|
| 455 | + return $texte; |
|
| 456 | + } |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | function message_page_indisponible($page, $contexte) { |
| 460 | - static $deja = false; |
|
| 461 | - if ($deja) { |
|
| 462 | - return 'erreur'; |
|
| 463 | - } |
|
| 464 | - $codes = [ |
|
| 465 | - '404' => '404 Not Found', |
|
| 466 | - '503' => '503 Service Unavailable', |
|
| 467 | - ]; |
|
| 468 | - |
|
| 469 | - $contexte['status'] = ($page !== false) ? '404' : '503'; |
|
| 470 | - $contexte['code'] = $codes[$contexte['status']]; |
|
| 471 | - $contexte['fond'] = '404'; // gere les 2 erreurs |
|
| 472 | - if (!isset($contexte['lang'])) { |
|
| 473 | - include_spip('inc/lang'); |
|
| 474 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - $deja = true; |
|
| 478 | - // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
|
| 479 | - // ex restriction d'acces => 401 |
|
| 480 | - $contexte = pipeline('page_indisponible', $contexte); |
|
| 481 | - |
|
| 482 | - // produire la page d'erreur |
|
| 483 | - $page = inclure_page($contexte['fond'], $contexte); |
|
| 484 | - if (!$page) { |
|
| 485 | - $page = inclure_page('404', $contexte); |
|
| 486 | - } |
|
| 487 | - $page['status'] = $contexte['status']; |
|
| 488 | - |
|
| 489 | - return $page; |
|
| 460 | + static $deja = false; |
|
| 461 | + if ($deja) { |
|
| 462 | + return 'erreur'; |
|
| 463 | + } |
|
| 464 | + $codes = [ |
|
| 465 | + '404' => '404 Not Found', |
|
| 466 | + '503' => '503 Service Unavailable', |
|
| 467 | + ]; |
|
| 468 | + |
|
| 469 | + $contexte['status'] = ($page !== false) ? '404' : '503'; |
|
| 470 | + $contexte['code'] = $codes[$contexte['status']]; |
|
| 471 | + $contexte['fond'] = '404'; // gere les 2 erreurs |
|
| 472 | + if (!isset($contexte['lang'])) { |
|
| 473 | + include_spip('inc/lang'); |
|
| 474 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + $deja = true; |
|
| 478 | + // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
|
| 479 | + // ex restriction d'acces => 401 |
|
| 480 | + $contexte = pipeline('page_indisponible', $contexte); |
|
| 481 | + |
|
| 482 | + // produire la page d'erreur |
|
| 483 | + $page = inclure_page($contexte['fond'], $contexte); |
|
| 484 | + if (!$page) { |
|
| 485 | + $page = inclure_page('404', $contexte); |
|
| 486 | + } |
|
| 487 | + $page['status'] = $contexte['status']; |
|
| 488 | + |
|
| 489 | + return $page; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -498,44 +498,44 @@ discard block |
||
| 498 | 498 | * @return mixed |
| 499 | 499 | */ |
| 500 | 500 | function arguments_balise_dyn_depuis_modele($arg, $operation = 'set') { |
| 501 | - static $balise_dyn_appellee_par_modele = null; |
|
| 502 | - switch ($operation) { |
|
| 503 | - case 'read': |
|
| 504 | - return $balise_dyn_appellee_par_modele; |
|
| 505 | - case 'reset': |
|
| 506 | - $balise_dyn_appellee_par_modele = null; |
|
| 507 | - return null; |
|
| 508 | - case 'set': |
|
| 509 | - default: |
|
| 510 | - $balise_dyn_appellee_par_modele = $arg; |
|
| 511 | - return $arg; |
|
| 512 | - } |
|
| 501 | + static $balise_dyn_appellee_par_modele = null; |
|
| 502 | + switch ($operation) { |
|
| 503 | + case 'read': |
|
| 504 | + return $balise_dyn_appellee_par_modele; |
|
| 505 | + case 'reset': |
|
| 506 | + $balise_dyn_appellee_par_modele = null; |
|
| 507 | + return null; |
|
| 508 | + case 'set': |
|
| 509 | + default: |
|
| 510 | + $balise_dyn_appellee_par_modele = $arg; |
|
| 511 | + return $arg; |
|
| 512 | + } |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | // temporairement ici : a mettre dans le futur inc/modeles |
| 516 | 516 | // creer_contexte_de_modele('left', 'autostart=true', ...) renvoie un array() |
| 517 | 517 | function creer_contexte_de_modele($args) { |
| 518 | - $contexte = []; |
|
| 519 | - foreach ($args as $var => $val) { |
|
| 520 | - if (is_int($var)) { // argument pas formate |
|
| 521 | - if (in_array($val, ['left', 'right', 'center'])) { |
|
| 522 | - $var = 'align'; |
|
| 523 | - $contexte[$var] = $val; |
|
| 524 | - } else { |
|
| 525 | - $args = explode('=', $val); |
|
| 526 | - if (count($args) >= 2) { // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 527 | - $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1); |
|
| 528 | - } else // notation abregee |
|
| 529 | - { |
|
| 530 | - $contexte[trim($val)] = trim($val); |
|
| 531 | - } |
|
| 532 | - } |
|
| 533 | - } else { |
|
| 534 | - $contexte[$var] = $val; |
|
| 535 | - } |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - return $contexte; |
|
| 518 | + $contexte = []; |
|
| 519 | + foreach ($args as $var => $val) { |
|
| 520 | + if (is_int($var)) { // argument pas formate |
|
| 521 | + if (in_array($val, ['left', 'right', 'center'])) { |
|
| 522 | + $var = 'align'; |
|
| 523 | + $contexte[$var] = $val; |
|
| 524 | + } else { |
|
| 525 | + $args = explode('=', $val); |
|
| 526 | + if (count($args) >= 2) { // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 527 | + $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1); |
|
| 528 | + } else // notation abregee |
|
| 529 | + { |
|
| 530 | + $contexte[trim($val)] = trim($val); |
|
| 531 | + } |
|
| 532 | + } |
|
| 533 | + } else { |
|
| 534 | + $contexte[$var] = $val; |
|
| 535 | + } |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + return $contexte; |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | /** |
@@ -550,43 +550,43 @@ discard block |
||
| 550 | 550 | * @return string |
| 551 | 551 | */ |
| 552 | 552 | function styliser_modele($modele, $id, $contexte = null) { |
| 553 | - static $styliseurs = null; |
|
| 554 | - if (is_null($styliseurs)) { |
|
| 555 | - $tables_objet = lister_tables_objets_sql(); |
|
| 556 | - foreach ($tables_objet as $table => $desc) { |
|
| 557 | - if ( |
|
| 558 | - isset($desc['modeles']) and $desc['modeles'] |
|
| 559 | - and isset($desc['modeles_styliser']) and $desc['modeles_styliser'] |
|
| 560 | - and function_exists($desc['modeles_styliser']) |
|
| 561 | - ) { |
|
| 562 | - $primary = id_table_objet($table); |
|
| 563 | - foreach ($desc['modeles'] as $m) { |
|
| 564 | - $styliseurs[$m] = ['primary' => $primary, 'callback' => $desc['modeles_styliser']]; |
|
| 565 | - } |
|
| 566 | - } |
|
| 567 | - } |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - if (isset($styliseurs[$modele])) { |
|
| 571 | - $styliseur = $styliseurs[$modele]['callback']; |
|
| 572 | - $primary = $styliseurs[$modele]['primary']; |
|
| 573 | - if (is_null($id) and $contexte) { |
|
| 574 | - if (isset($contexte['id'])) { |
|
| 575 | - $id = $contexte['id']; |
|
| 576 | - } elseif (isset($contexte[$primary])) { |
|
| 577 | - $id = $contexte[$primary]; |
|
| 578 | - } |
|
| 579 | - } |
|
| 580 | - if (is_null($id)) { |
|
| 581 | - $msg = "modeles/$modele : " . _T('zbug_parametres_inclus_incorrects', ['param' => "id/$primary"]); |
|
| 582 | - erreur_squelette($msg); |
|
| 583 | - // on passe id=0 au routeur pour tomber sur le modele par defaut et eviter une seconde erreur sur un modele inexistant |
|
| 584 | - $id = 0; |
|
| 585 | - } |
|
| 586 | - $modele = $styliseur($modele, $id); |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - return $modele; |
|
| 553 | + static $styliseurs = null; |
|
| 554 | + if (is_null($styliseurs)) { |
|
| 555 | + $tables_objet = lister_tables_objets_sql(); |
|
| 556 | + foreach ($tables_objet as $table => $desc) { |
|
| 557 | + if ( |
|
| 558 | + isset($desc['modeles']) and $desc['modeles'] |
|
| 559 | + and isset($desc['modeles_styliser']) and $desc['modeles_styliser'] |
|
| 560 | + and function_exists($desc['modeles_styliser']) |
|
| 561 | + ) { |
|
| 562 | + $primary = id_table_objet($table); |
|
| 563 | + foreach ($desc['modeles'] as $m) { |
|
| 564 | + $styliseurs[$m] = ['primary' => $primary, 'callback' => $desc['modeles_styliser']]; |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + if (isset($styliseurs[$modele])) { |
|
| 571 | + $styliseur = $styliseurs[$modele]['callback']; |
|
| 572 | + $primary = $styliseurs[$modele]['primary']; |
|
| 573 | + if (is_null($id) and $contexte) { |
|
| 574 | + if (isset($contexte['id'])) { |
|
| 575 | + $id = $contexte['id']; |
|
| 576 | + } elseif (isset($contexte[$primary])) { |
|
| 577 | + $id = $contexte[$primary]; |
|
| 578 | + } |
|
| 579 | + } |
|
| 580 | + if (is_null($id)) { |
|
| 581 | + $msg = "modeles/$modele : " . _T('zbug_parametres_inclus_incorrects', ['param' => "id/$primary"]); |
|
| 582 | + erreur_squelette($msg); |
|
| 583 | + // on passe id=0 au routeur pour tomber sur le modele par defaut et eviter une seconde erreur sur un modele inexistant |
|
| 584 | + $id = 0; |
|
| 585 | + } |
|
| 586 | + $modele = $styliseur($modele, $id); |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + return $modele; |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
@@ -603,102 +603,102 @@ discard block |
||
| 603 | 603 | */ |
| 604 | 604 | function inclure_modele($type, $id, $params, $lien, string $connect = '', $env = []) { |
| 605 | 605 | |
| 606 | - static $compteur; |
|
| 607 | - if (++$compteur > 10) { |
|
| 608 | - return ''; |
|
| 609 | - } # ne pas boucler indefiniment |
|
| 610 | - |
|
| 611 | - $type = strtolower($type); |
|
| 612 | - $type = styliser_modele($type, $id); |
|
| 613 | - |
|
| 614 | - $fond = $class = ''; |
|
| 615 | - |
|
| 616 | - $params = array_filter(explode('|', $params)); |
|
| 617 | - if ($params) { |
|
| 618 | - $soustype = current($params); |
|
| 619 | - $soustype = strtolower(trim($soustype)); |
|
| 620 | - if (in_array($soustype, ['left', 'right', 'center', 'ajax'])) { |
|
| 621 | - $soustype = next($params); |
|
| 622 | - $soustype = strtolower($soustype); |
|
| 623 | - } |
|
| 624 | - |
|
| 625 | - if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
|
| 626 | - if (!trouve_modele($fond = ($type . '_' . $soustype))) { |
|
| 627 | - $fond = ''; |
|
| 628 | - $class = $soustype; |
|
| 629 | - } |
|
| 630 | - // enlever le sous type des params |
|
| 631 | - $params = array_diff($params, [$soustype]); |
|
| 632 | - } |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - // Si ca marche pas en precisant le sous-type, prendre le type |
|
| 636 | - if (!$fond and !trouve_modele($fond = $type)) { |
|
| 637 | - spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE); |
|
| 638 | - |
|
| 639 | - return false; |
|
| 640 | - } |
|
| 641 | - $fond = 'modeles/' . $fond; |
|
| 642 | - // Creer le contexte |
|
| 643 | - $contexte = $env; |
|
| 644 | - $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
|
| 645 | - |
|
| 646 | - // Le numero du modele est mis dans l'environnement |
|
| 647 | - // d'une part sous l'identifiant "id" |
|
| 648 | - // et d'autre part sous l'identifiant de la cle primaire |
|
| 649 | - // par la fonction id_table_objet, |
|
| 650 | - // (<article1> =>> article =>> id_article =>> id_article=1) |
|
| 651 | - $_id = id_table_objet($type); |
|
| 652 | - $contexte['id'] = $contexte[$_id] = $id; |
|
| 653 | - |
|
| 654 | - if (isset($class)) { |
|
| 655 | - $contexte['class'] = $class; |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - // Si un lien a ete passe en parametre, ex: [<modele1>->url] ou [<modele1|title_du_lien{hreflang}->url] |
|
| 659 | - if ($lien) { |
|
| 660 | - # un eventuel guillemet (") sera reechappe par #ENV |
|
| 661 | - $contexte['lien'] = str_replace('"', '"', $lien['href']); |
|
| 662 | - $contexte['lien_class'] = $lien['class']; |
|
| 663 | - $contexte['lien_mime'] = $lien['mime']; |
|
| 664 | - $contexte['lien_title'] = $lien['title']; |
|
| 665 | - $contexte['lien_hreflang'] = $lien['hreflang']; |
|
| 666 | - } |
|
| 667 | - |
|
| 668 | - // Traiter les parametres |
|
| 669 | - // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
|
| 670 | - $arg_list = creer_contexte_de_modele($params); |
|
| 671 | - $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
|
| 672 | - $contexte = array_merge($contexte, $arg_list); |
|
| 673 | - |
|
| 674 | - // Appliquer le modele avec le contexte |
|
| 675 | - $retour = recuperer_fond($fond, $contexte, [], $connect); |
|
| 676 | - |
|
| 677 | - // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
|
| 678 | - // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
|
| 679 | - // sinon, s'il y a un lien, on l'ajoute classiquement |
|
| 680 | - if ( |
|
| 681 | - strstr( |
|
| 682 | - ' ' . ($classes = extraire_attribut($retour, 'class')) . ' ', |
|
| 683 | - 'spip_lien_ok' |
|
| 684 | - ) |
|
| 685 | - ) { |
|
| 686 | - $retour = inserer_attribut( |
|
| 687 | - $retour, |
|
| 688 | - 'class', |
|
| 689 | - trim(str_replace(' spip_lien_ok ', ' ', " $classes ")) |
|
| 690 | - ); |
|
| 691 | - } else { |
|
| 692 | - if ($lien) { |
|
| 693 | - $retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . '</a>'; |
|
| 694 | - } |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - $compteur--; |
|
| 698 | - |
|
| 699 | - return (isset($arg_list['ajax']) and $arg_list['ajax'] == 'ajax') |
|
| 700 | - ? encoder_contexte_ajax($contexte, '', $retour) |
|
| 701 | - : $retour; |
|
| 606 | + static $compteur; |
|
| 607 | + if (++$compteur > 10) { |
|
| 608 | + return ''; |
|
| 609 | + } # ne pas boucler indefiniment |
|
| 610 | + |
|
| 611 | + $type = strtolower($type); |
|
| 612 | + $type = styliser_modele($type, $id); |
|
| 613 | + |
|
| 614 | + $fond = $class = ''; |
|
| 615 | + |
|
| 616 | + $params = array_filter(explode('|', $params)); |
|
| 617 | + if ($params) { |
|
| 618 | + $soustype = current($params); |
|
| 619 | + $soustype = strtolower(trim($soustype)); |
|
| 620 | + if (in_array($soustype, ['left', 'right', 'center', 'ajax'])) { |
|
| 621 | + $soustype = next($params); |
|
| 622 | + $soustype = strtolower($soustype); |
|
| 623 | + } |
|
| 624 | + |
|
| 625 | + if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
|
| 626 | + if (!trouve_modele($fond = ($type . '_' . $soustype))) { |
|
| 627 | + $fond = ''; |
|
| 628 | + $class = $soustype; |
|
| 629 | + } |
|
| 630 | + // enlever le sous type des params |
|
| 631 | + $params = array_diff($params, [$soustype]); |
|
| 632 | + } |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + // Si ca marche pas en precisant le sous-type, prendre le type |
|
| 636 | + if (!$fond and !trouve_modele($fond = $type)) { |
|
| 637 | + spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE); |
|
| 638 | + |
|
| 639 | + return false; |
|
| 640 | + } |
|
| 641 | + $fond = 'modeles/' . $fond; |
|
| 642 | + // Creer le contexte |
|
| 643 | + $contexte = $env; |
|
| 644 | + $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
|
| 645 | + |
|
| 646 | + // Le numero du modele est mis dans l'environnement |
|
| 647 | + // d'une part sous l'identifiant "id" |
|
| 648 | + // et d'autre part sous l'identifiant de la cle primaire |
|
| 649 | + // par la fonction id_table_objet, |
|
| 650 | + // (<article1> =>> article =>> id_article =>> id_article=1) |
|
| 651 | + $_id = id_table_objet($type); |
|
| 652 | + $contexte['id'] = $contexte[$_id] = $id; |
|
| 653 | + |
|
| 654 | + if (isset($class)) { |
|
| 655 | + $contexte['class'] = $class; |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + // Si un lien a ete passe en parametre, ex: [<modele1>->url] ou [<modele1|title_du_lien{hreflang}->url] |
|
| 659 | + if ($lien) { |
|
| 660 | + # un eventuel guillemet (") sera reechappe par #ENV |
|
| 661 | + $contexte['lien'] = str_replace('"', '"', $lien['href']); |
|
| 662 | + $contexte['lien_class'] = $lien['class']; |
|
| 663 | + $contexte['lien_mime'] = $lien['mime']; |
|
| 664 | + $contexte['lien_title'] = $lien['title']; |
|
| 665 | + $contexte['lien_hreflang'] = $lien['hreflang']; |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + // Traiter les parametres |
|
| 669 | + // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
|
| 670 | + $arg_list = creer_contexte_de_modele($params); |
|
| 671 | + $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
|
| 672 | + $contexte = array_merge($contexte, $arg_list); |
|
| 673 | + |
|
| 674 | + // Appliquer le modele avec le contexte |
|
| 675 | + $retour = recuperer_fond($fond, $contexte, [], $connect); |
|
| 676 | + |
|
| 677 | + // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
|
| 678 | + // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
|
| 679 | + // sinon, s'il y a un lien, on l'ajoute classiquement |
|
| 680 | + if ( |
|
| 681 | + strstr( |
|
| 682 | + ' ' . ($classes = extraire_attribut($retour, 'class')) . ' ', |
|
| 683 | + 'spip_lien_ok' |
|
| 684 | + ) |
|
| 685 | + ) { |
|
| 686 | + $retour = inserer_attribut( |
|
| 687 | + $retour, |
|
| 688 | + 'class', |
|
| 689 | + trim(str_replace(' spip_lien_ok ', ' ', " $classes ")) |
|
| 690 | + ); |
|
| 691 | + } else { |
|
| 692 | + if ($lien) { |
|
| 693 | + $retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . '</a>'; |
|
| 694 | + } |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + $compteur--; |
|
| 698 | + |
|
| 699 | + return (isset($arg_list['ajax']) and $arg_list['ajax'] == 'ajax') |
|
| 700 | + ? encoder_contexte_ajax($contexte, '', $retour) |
|
| 701 | + : $retour; |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | // Un inclure_page qui marche aussi pour l'espace prive |
@@ -707,105 +707,105 @@ discard block |
||
| 707 | 707 | // recuperer_fond($fond,$contexte,array('raw'=>true)) |
| 708 | 708 | function evaluer_fond($fond, $contexte = [], string $connect = '') { |
| 709 | 709 | |
| 710 | - $page = inclure_page($fond, $contexte, $connect); |
|
| 711 | - |
|
| 712 | - if (!$page) { |
|
| 713 | - return $page; |
|
| 714 | - } |
|
| 715 | - // eval $page et affecte $res |
|
| 716 | - include _ROOT_RESTREINT . 'public/evaluer_page.php'; |
|
| 717 | - |
|
| 718 | - // Lever un drapeau (global) si le fond utilise #SESSION |
|
| 719 | - // a destination de public/parametrer |
|
| 720 | - // pour remonter vers les inclusions appelantes |
|
| 721 | - // il faut bien lever ce drapeau apres avoir evalue le fond |
|
| 722 | - // pour ne pas faire descendre le flag vers les inclusions appelees |
|
| 723 | - if ( |
|
| 724 | - isset($page['invalideurs']) |
|
| 725 | - and isset($page['invalideurs']['session']) |
|
| 726 | - ) { |
|
| 727 | - $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - return $page; |
|
| 710 | + $page = inclure_page($fond, $contexte, $connect); |
|
| 711 | + |
|
| 712 | + if (!$page) { |
|
| 713 | + return $page; |
|
| 714 | + } |
|
| 715 | + // eval $page et affecte $res |
|
| 716 | + include _ROOT_RESTREINT . 'public/evaluer_page.php'; |
|
| 717 | + |
|
| 718 | + // Lever un drapeau (global) si le fond utilise #SESSION |
|
| 719 | + // a destination de public/parametrer |
|
| 720 | + // pour remonter vers les inclusions appelantes |
|
| 721 | + // il faut bien lever ce drapeau apres avoir evalue le fond |
|
| 722 | + // pour ne pas faire descendre le flag vers les inclusions appelees |
|
| 723 | + if ( |
|
| 724 | + isset($page['invalideurs']) |
|
| 725 | + and isset($page['invalideurs']['session']) |
|
| 726 | + ) { |
|
| 727 | + $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + return $page; |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | |
| 734 | 734 | function page_base_href(&$texte) { |
| 735 | - static $set_html_base = null; |
|
| 736 | - if (is_null($set_html_base)) { |
|
| 737 | - if (!defined('_SET_HTML_BASE')) { |
|
| 738 | - // si la profondeur est superieure a 1 |
|
| 739 | - // est que ce n'est pas une url page ni une url action |
|
| 740 | - // activer par defaut |
|
| 741 | - $set_html_base = (( |
|
| 742 | - $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 743 | - and _request(_SPIP_PAGE) !== 'login' |
|
| 744 | - and !_request('action')) ? true : false); |
|
| 745 | - } else { |
|
| 746 | - $set_html_base = _SET_HTML_BASE; |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - |
|
| 750 | - if ( |
|
| 751 | - $set_html_base |
|
| 752 | - and isset($GLOBALS['html']) and $GLOBALS['html'] |
|
| 753 | - and $GLOBALS['profondeur_url'] > 0 |
|
| 754 | - and ($poshead = strpos($texte, '</head>')) !== false |
|
| 755 | - ) { |
|
| 756 | - $head = substr($texte, 0, $poshead); |
|
| 757 | - $insert = false; |
|
| 758 | - $href_base = false; |
|
| 759 | - if (strpos($head, '<base') === false) { |
|
| 760 | - $insert = true; |
|
| 761 | - } else { |
|
| 762 | - // si aucun <base ...> n'a de href il faut en inserer un |
|
| 763 | - // sinon juste re-ecrire les ancres si besoin |
|
| 764 | - $insert = true; |
|
| 765 | - include_spip('inc/filtres'); |
|
| 766 | - $bases = extraire_balises($head, 'base'); |
|
| 767 | - foreach ($bases as $base) { |
|
| 768 | - if ($href_base = extraire_attribut($base, 'href')) { |
|
| 769 | - $insert = false; |
|
| 770 | - break; |
|
| 771 | - } |
|
| 772 | - } |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - if ($insert) { |
|
| 776 | - include_spip('inc/filtres_mini'); |
|
| 777 | - // ajouter un base qui reglera tous les liens relatifs |
|
| 778 | - $href_base = url_absolue('./'); |
|
| 779 | - $base = "\n<base href=\"$href_base\" />"; |
|
| 780 | - if (($pos = strpos($head, '<head>')) !== false) { |
|
| 781 | - $head = substr_replace($head, $base, $pos + 6, 0); |
|
| 782 | - } elseif (preg_match(',<head[^>]*>,i', $head, $r)) { |
|
| 783 | - $head = str_replace($r[0], $r[0] . $base, $head); |
|
| 784 | - } |
|
| 785 | - $texte = $head . substr($texte, $poshead); |
|
| 786 | - } |
|
| 787 | - if ($href_base) { |
|
| 788 | - // gerer les ancres |
|
| 789 | - $base = $_SERVER['REQUEST_URI']; |
|
| 790 | - // pas de guillemets ni < dans l'URL qu'on insere dans le HTML |
|
| 791 | - if (strpos($base, "'") or strpos($base, '"') or strpos($base, '<')) { |
|
| 792 | - $base = str_replace(["'",'"','<'], ['%27','%22','%3C'], $base); |
|
| 793 | - } |
|
| 794 | - if (strpos($texte, "href='#") !== false) { |
|
| 795 | - $texte = str_replace("href='#", "href='$base#", $texte); |
|
| 796 | - } |
|
| 797 | - if (strpos($texte, 'href="#') !== false) { |
|
| 798 | - $texte = str_replace('href="#', "href=\"$base#", $texte); |
|
| 799 | - } |
|
| 800 | - } |
|
| 801 | - } |
|
| 735 | + static $set_html_base = null; |
|
| 736 | + if (is_null($set_html_base)) { |
|
| 737 | + if (!defined('_SET_HTML_BASE')) { |
|
| 738 | + // si la profondeur est superieure a 1 |
|
| 739 | + // est que ce n'est pas une url page ni une url action |
|
| 740 | + // activer par defaut |
|
| 741 | + $set_html_base = (( |
|
| 742 | + $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 743 | + and _request(_SPIP_PAGE) !== 'login' |
|
| 744 | + and !_request('action')) ? true : false); |
|
| 745 | + } else { |
|
| 746 | + $set_html_base = _SET_HTML_BASE; |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + |
|
| 750 | + if ( |
|
| 751 | + $set_html_base |
|
| 752 | + and isset($GLOBALS['html']) and $GLOBALS['html'] |
|
| 753 | + and $GLOBALS['profondeur_url'] > 0 |
|
| 754 | + and ($poshead = strpos($texte, '</head>')) !== false |
|
| 755 | + ) { |
|
| 756 | + $head = substr($texte, 0, $poshead); |
|
| 757 | + $insert = false; |
|
| 758 | + $href_base = false; |
|
| 759 | + if (strpos($head, '<base') === false) { |
|
| 760 | + $insert = true; |
|
| 761 | + } else { |
|
| 762 | + // si aucun <base ...> n'a de href il faut en inserer un |
|
| 763 | + // sinon juste re-ecrire les ancres si besoin |
|
| 764 | + $insert = true; |
|
| 765 | + include_spip('inc/filtres'); |
|
| 766 | + $bases = extraire_balises($head, 'base'); |
|
| 767 | + foreach ($bases as $base) { |
|
| 768 | + if ($href_base = extraire_attribut($base, 'href')) { |
|
| 769 | + $insert = false; |
|
| 770 | + break; |
|
| 771 | + } |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + if ($insert) { |
|
| 776 | + include_spip('inc/filtres_mini'); |
|
| 777 | + // ajouter un base qui reglera tous les liens relatifs |
|
| 778 | + $href_base = url_absolue('./'); |
|
| 779 | + $base = "\n<base href=\"$href_base\" />"; |
|
| 780 | + if (($pos = strpos($head, '<head>')) !== false) { |
|
| 781 | + $head = substr_replace($head, $base, $pos + 6, 0); |
|
| 782 | + } elseif (preg_match(',<head[^>]*>,i', $head, $r)) { |
|
| 783 | + $head = str_replace($r[0], $r[0] . $base, $head); |
|
| 784 | + } |
|
| 785 | + $texte = $head . substr($texte, $poshead); |
|
| 786 | + } |
|
| 787 | + if ($href_base) { |
|
| 788 | + // gerer les ancres |
|
| 789 | + $base = $_SERVER['REQUEST_URI']; |
|
| 790 | + // pas de guillemets ni < dans l'URL qu'on insere dans le HTML |
|
| 791 | + if (strpos($base, "'") or strpos($base, '"') or strpos($base, '<')) { |
|
| 792 | + $base = str_replace(["'",'"','<'], ['%27','%22','%3C'], $base); |
|
| 793 | + } |
|
| 794 | + if (strpos($texte, "href='#") !== false) { |
|
| 795 | + $texte = str_replace("href='#", "href='$base#", $texte); |
|
| 796 | + } |
|
| 797 | + if (strpos($texte, 'href="#') !== false) { |
|
| 798 | + $texte = str_replace('href="#', "href=\"$base#", $texte); |
|
| 799 | + } |
|
| 800 | + } |
|
| 801 | + } |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | |
| 805 | 805 | // Envoyer les entetes, en retenant ceux qui sont a usage interne |
| 806 | 806 | // et demarrent par X-Spip-... |
| 807 | 807 | function envoyer_entetes($entetes) { |
| 808 | - foreach ($entetes as $k => $v) { # if (strncmp($k, 'X-Spip-', 7)) |
|
| 809 | - @header(strlen($v) ? "$k: $v" : $k); |
|
| 810 | - } |
|
| 808 | + foreach ($entetes as $k => $v) { # if (strncmp($k, 'X-Spip-', 7)) |
|
| 809 | + @header(strlen($v) ? "$k: $v" : $k); |
|
| 810 | + } |
|
| 811 | 811 | } |
@@ -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 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * Code PHP compilé de la boucle |
| 33 | 33 | **/ |
| 34 | 34 | function boucle_DEFAUT_dist($id_boucle, &$boucles) { |
| 35 | - return calculer_boucle($id_boucle, $boucles); |
|
| 35 | + return calculer_boucle($id_boucle, $boucles); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * Code PHP compilé de la boucle |
| 52 | 52 | **/ |
| 53 | 53 | function boucle_BOUCLE_dist($id_boucle, &$boucles) { |
| 54 | - return calculer_boucle($id_boucle, $boucles); |
|
| 54 | + return calculer_boucle($id_boucle, $boucles); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -81,30 +81,30 @@ discard block |
||
| 81 | 81 | * Code PHP compilé de la boucle |
| 82 | 82 | **/ |
| 83 | 83 | function boucle_HIERARCHIE_dist($id_boucle, &$boucles) { |
| 84 | - $boucle = &$boucles[$id_boucle]; |
|
| 85 | - $id_table = $boucle->id_table . '.id_rubrique'; |
|
| 84 | + $boucle = &$boucles[$id_boucle]; |
|
| 85 | + $id_table = $boucle->id_table . '.id_rubrique'; |
|
| 86 | 86 | |
| 87 | - // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
|
| 88 | - // sauf en presence du critere {tout} (vu par phraser_html) |
|
| 89 | - // ou {id_article} qui positionne aussi le {tout} |
|
| 87 | + // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
|
| 88 | + // sauf en presence du critere {tout} (vu par phraser_html) |
|
| 89 | + // ou {id_article} qui positionne aussi le {tout} |
|
| 90 | 90 | |
| 91 | - $boucle->hierarchie = 'if (!($id_rubrique = intval(' |
|
| 92 | - . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles) |
|
| 93 | - . ")))\n\t\treturn '';\n\t" |
|
| 94 | - . "include_spip('inc/rubriques');\n\t" |
|
| 95 | - . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
|
| 96 | - . (isset($boucle->modificateur['tout']) ? 'true' : 'false') |
|
| 97 | - . ");\n\t" |
|
| 98 | - . 'if (!$hierarchie) return "";' . "\n\t"; |
|
| 91 | + $boucle->hierarchie = 'if (!($id_rubrique = intval(' |
|
| 92 | + . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles) |
|
| 93 | + . ")))\n\t\treturn '';\n\t" |
|
| 94 | + . "include_spip('inc/rubriques');\n\t" |
|
| 95 | + . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
|
| 96 | + . (isset($boucle->modificateur['tout']) ? 'true' : 'false') |
|
| 97 | + . ");\n\t" |
|
| 98 | + . 'if (!$hierarchie) return "";' . "\n\t"; |
|
| 99 | 99 | |
| 100 | - $boucle->where[] = ["'IN'", "'$id_table'", '"($hierarchie)"']; |
|
| 100 | + $boucle->where[] = ["'IN'", "'$id_table'", '"($hierarchie)"']; |
|
| 101 | 101 | |
| 102 | - $order = "FIELD($id_table, \$hierarchie)"; |
|
| 103 | - if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != ' DESC') { |
|
| 104 | - $boucle->default_order[] = "\"$order\""; |
|
| 105 | - } else { |
|
| 106 | - $boucle->default_order[0] = "\"$order DESC\""; |
|
| 107 | - } |
|
| 102 | + $order = "FIELD($id_table, \$hierarchie)"; |
|
| 103 | + if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != ' DESC') { |
|
| 104 | + $boucle->default_order[] = "\"$order\""; |
|
| 105 | + } else { |
|
| 106 | + $boucle->default_order[0] = "\"$order DESC\""; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - return calculer_boucle($id_boucle, $boucles); |
|
| 109 | + return calculer_boucle($id_boucle, $boucles); |
|
| 110 | 110 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | **/ |
| 83 | 83 | function boucle_HIERARCHIE_dist($id_boucle, &$boucles) { |
| 84 | 84 | $boucle = &$boucles[$id_boucle]; |
| 85 | - $id_table = $boucle->id_table . '.id_rubrique'; |
|
| 85 | + $id_table = $boucle->id_table.'.id_rubrique'; |
|
| 86 | 86 | |
| 87 | 87 | // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
| 88 | 88 | // sauf en presence du critere {tout} (vu par phraser_html) |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
| 96 | 96 | . (isset($boucle->modificateur['tout']) ? 'true' : 'false') |
| 97 | 97 | . ");\n\t" |
| 98 | - . 'if (!$hierarchie) return "";' . "\n\t"; |
|
| 98 | + . 'if (!$hierarchie) return "";'."\n\t"; |
|
| 99 | 99 | |
| 100 | 100 | $boucle->where[] = ["'IN'", "'$id_table'", '"($hierarchie)"']; |
| 101 | 101 | |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | * @package SPIP\Core\SQL\Upgrade |
| 19 | 19 | **/ |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | $GLOBALS['maj'][21676] = [ |
| 26 | - ['ranger_cache_gd2'], |
|
| 26 | + ['ranger_cache_gd2'], |
|
| 27 | 27 | ]; |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -32,30 +32,30 @@ discard block |
||
| 32 | 32 | * https://core.spip.net/issues/3277 |
| 33 | 33 | */ |
| 34 | 34 | function ranger_cache_gd2() { |
| 35 | - spip_log('ranger_cache_gd2'); |
|
| 36 | - $base = _DIR_VAR . 'cache-gd2/'; |
|
| 37 | - if (is_dir($base) and is_readable($base)) { |
|
| 38 | - if ($dir = opendir($base)) { |
|
| 39 | - while (($f = readdir($dir)) !== false) { |
|
| 40 | - if ( |
|
| 41 | - !is_dir($base . $f) and strncmp($f, '.', 1) !== 0 |
|
| 42 | - and preg_match(',[0-9a-f]{32}\.\w+,', $f) |
|
| 43 | - ) { |
|
| 44 | - $sub = substr($f, 0, 2); |
|
| 45 | - $sub = sous_repertoire($base, $sub); |
|
| 46 | - @rename($base . $f, $sub . substr($f, 2)); |
|
| 47 | - @unlink($base . $f); // au cas ou le rename a foire (collision) |
|
| 48 | - } |
|
| 49 | - if (time() >= _TIME_OUT) { |
|
| 50 | - return; |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - } |
|
| 35 | + spip_log('ranger_cache_gd2'); |
|
| 36 | + $base = _DIR_VAR . 'cache-gd2/'; |
|
| 37 | + if (is_dir($base) and is_readable($base)) { |
|
| 38 | + if ($dir = opendir($base)) { |
|
| 39 | + while (($f = readdir($dir)) !== false) { |
|
| 40 | + if ( |
|
| 41 | + !is_dir($base . $f) and strncmp($f, '.', 1) !== 0 |
|
| 42 | + and preg_match(',[0-9a-f]{32}\.\w+,', $f) |
|
| 43 | + ) { |
|
| 44 | + $sub = substr($f, 0, 2); |
|
| 45 | + $sub = sous_repertoire($base, $sub); |
|
| 46 | + @rename($base . $f, $sub . substr($f, 2)); |
|
| 47 | + @unlink($base . $f); // au cas ou le rename a foire (collision) |
|
| 48 | + } |
|
| 49 | + if (time() >= _TIME_OUT) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | $GLOBALS['maj'][21742] = [ |
| 59 | - ['sql_alter', "TABLE spip_articles CHANGE url_site url_site text DEFAULT '' NOT NULL"], |
|
| 60 | - ['sql_alter', "TABLE spip_articles CHANGE virtuel virtuel text DEFAULT '' NOT NULL"], |
|
| 59 | + ['sql_alter', "TABLE spip_articles CHANGE url_site url_site text DEFAULT '' NOT NULL"], |
|
| 60 | + ['sql_alter', "TABLE spip_articles CHANGE virtuel virtuel text DEFAULT '' NOT NULL"], |
|
| 61 | 61 | ]; |
@@ -33,18 +33,18 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | function ranger_cache_gd2() { |
| 35 | 35 | spip_log('ranger_cache_gd2'); |
| 36 | - $base = _DIR_VAR . 'cache-gd2/'; |
|
| 36 | + $base = _DIR_VAR.'cache-gd2/'; |
|
| 37 | 37 | if (is_dir($base) and is_readable($base)) { |
| 38 | 38 | if ($dir = opendir($base)) { |
| 39 | 39 | while (($f = readdir($dir)) !== false) { |
| 40 | 40 | if ( |
| 41 | - !is_dir($base . $f) and strncmp($f, '.', 1) !== 0 |
|
| 41 | + !is_dir($base.$f) and strncmp($f, '.', 1) !== 0 |
|
| 42 | 42 | and preg_match(',[0-9a-f]{32}\.\w+,', $f) |
| 43 | 43 | ) { |
| 44 | 44 | $sub = substr($f, 0, 2); |
| 45 | 45 | $sub = sous_repertoire($base, $sub); |
| 46 | - @rename($base . $f, $sub . substr($f, 2)); |
|
| 47 | - @unlink($base . $f); // au cas ou le rename a foire (collision) |
|
| 46 | + @rename($base.$f, $sub.substr($f, 2)); |
|
| 47 | + @unlink($base.$f); // au cas ou le rename a foire (collision) |
|
| 48 | 48 | } |
| 49 | 49 | if (time() >= _TIME_OUT) { |
| 50 | 50 | return; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @package SPIP\Core\SQL\Upgrade |
| 19 | 19 | **/ |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | include_spip('base/medias'); |
@@ -27,27 +27,27 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // http://archives.rezo.net/archives/spip-zone.mbox/C6RZKNBUNJYN42IOEOC4QKVCA233AMLI/ |
| 29 | 29 | $GLOBALS['maj'][13833] = [ |
| 30 | - ['sql_alter', 'TABLE spip_documents_liens ADD INDEX objet(id_objet,objet)'] |
|
| 30 | + ['sql_alter', 'TABLE spip_documents_liens ADD INDEX objet(id_objet,objet)'] |
|
| 31 | 31 | ]; |
| 32 | 32 | |
| 33 | 33 | // 2.1 |
| 34 | 34 | |
| 35 | 35 | $GLOBALS['maj'][13904] = [ |
| 36 | - ['sql_alter', "TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"], |
|
| 37 | - [ |
|
| 38 | - 'sql_update', |
|
| 39 | - 'spip_auteurs', |
|
| 40 | - ['webmestre' => "'oui'"], |
|
| 41 | - sql_in('id_auteur', defined('_ID_WEBMESTRES') ? explode( |
|
| 42 | - ':', |
|
| 43 | - _ID_WEBMESTRES |
|
| 44 | - ) : (autoriser('configurer') ? [$GLOBALS['visiteur_session']['id_auteur']] : [0])) |
|
| 45 | - ] // le webmestre est celui qui fait l'upgrade si rien de defini |
|
| 36 | + ['sql_alter', "TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"], |
|
| 37 | + [ |
|
| 38 | + 'sql_update', |
|
| 39 | + 'spip_auteurs', |
|
| 40 | + ['webmestre' => "'oui'"], |
|
| 41 | + sql_in('id_auteur', defined('_ID_WEBMESTRES') ? explode( |
|
| 42 | + ':', |
|
| 43 | + _ID_WEBMESTRES |
|
| 44 | + ) : (autoriser('configurer') ? [$GLOBALS['visiteur_session']['id_auteur']] : [0])) |
|
| 45 | + ] // le webmestre est celui qui fait l'upgrade si rien de defini |
|
| 46 | 46 | ]; |
| 47 | 47 | |
| 48 | 48 | // sites plantes en mode "'su" au lieu de "sus" |
| 49 | 49 | $GLOBALS['maj'][13929] = [ |
| 50 | - ['sql_update', 'spip_syndic', ['syndication' => "'sus'"], "syndication LIKE '\\'%'"] |
|
| 50 | + ['sql_update', 'spip_syndic', ['syndication' => "'sus'"], "syndication LIKE '\\'%'"] |
|
| 51 | 51 | ]; |
| 52 | 52 | |
| 53 | 53 | // Types de fichiers m4a/m4b/m4p/m4u/m4v/dv |
@@ -61,24 +61,24 @@ discard block |
||
| 61 | 61 | // La version 14588 etait une mauvaise piste: |
| 62 | 62 | // Retour en arriere pour ceux qui l'ont subi, ne rien faire sinon |
| 63 | 63 | if (@$GLOBALS['meta']['version_installee'] >= 14588) { |
| 64 | - // "mode" est un mot-cle d'Oracle |
|
| 65 | - $GLOBALS['maj'][14588] = [ |
|
| 66 | - ['sql_alter', 'TABLE spip_documents DROP INDEX mode'], |
|
| 67 | - [ |
|
| 68 | - 'sql_alter', |
|
| 69 | - "TABLE spip_documents CHANGE mode genre ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 70 | - ], |
|
| 71 | - ['sql_alter', 'TABLE spip_documents ADD INDEX genre(genre)'] |
|
| 72 | - ]; |
|
| 73 | - // solution moins intrusive au pb de mot-cle d'Oracle, retour avant 14588 |
|
| 74 | - $GLOBALS['maj'][14598] = [ |
|
| 75 | - ['sql_alter', 'TABLE spip_documents DROP INDEX genre'], |
|
| 76 | - [ |
|
| 77 | - 'sql_alter', |
|
| 78 | - "TABLE spip_documents CHANGE genre mode ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 79 | - ], |
|
| 80 | - ['sql_alter', 'TABLE spip_documents ADD INDEX mode(mode)'] |
|
| 81 | - ]; |
|
| 64 | + // "mode" est un mot-cle d'Oracle |
|
| 65 | + $GLOBALS['maj'][14588] = [ |
|
| 66 | + ['sql_alter', 'TABLE spip_documents DROP INDEX mode'], |
|
| 67 | + [ |
|
| 68 | + 'sql_alter', |
|
| 69 | + "TABLE spip_documents CHANGE mode genre ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 70 | + ], |
|
| 71 | + ['sql_alter', 'TABLE spip_documents ADD INDEX genre(genre)'] |
|
| 72 | + ]; |
|
| 73 | + // solution moins intrusive au pb de mot-cle d'Oracle, retour avant 14588 |
|
| 74 | + $GLOBALS['maj'][14598] = [ |
|
| 75 | + ['sql_alter', 'TABLE spip_documents DROP INDEX genre'], |
|
| 76 | + [ |
|
| 77 | + 'sql_alter', |
|
| 78 | + "TABLE spip_documents CHANGE genre mode ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL" |
|
| 79 | + ], |
|
| 80 | + ['sql_alter', 'TABLE spip_documents ADD INDEX mode(mode)'] |
|
| 81 | + ]; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Restauration correcte des types mime des fichiers Ogg |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | * @package SPIP\Core\SQL\Upgrade |
| 19 | 19 | **/ |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | $GLOBALS['maj'][23375] = [ |
| 26 | - ['sql_alter', 'TABLE spip_auteurs CHANGE prefs prefs text'], |
|
| 26 | + ['sql_alter', 'TABLE spip_auteurs CHANGE prefs prefs text'], |
|
| 27 | 27 | ]; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @package SPIP\Core\SQL\Upgrade |
| 21 | 21 | **/ |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -35,49 +35,49 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function maj_timestamp_mysql($tables = null) { |
| 37 | 37 | |
| 38 | - include_spip('base/dump'); |
|
| 39 | - if (is_null($tables)) { |
|
| 40 | - $tables = base_lister_toutes_tables(); |
|
| 41 | - } elseif (is_string($tables)) { |
|
| 42 | - $tables = [$tables]; |
|
| 43 | - } elseif (!is_array($tables)) { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 38 | + include_spip('base/dump'); |
|
| 39 | + if (is_null($tables)) { |
|
| 40 | + $tables = base_lister_toutes_tables(); |
|
| 41 | + } elseif (is_string($tables)) { |
|
| 42 | + $tables = [$tables]; |
|
| 43 | + } elseif (!is_array($tables)) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - // rien a faire si base non mysql |
|
| 48 | - if (strncmp($GLOBALS['connexions'][0]['type'], 'mysql', 5) !== 0) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 47 | + // rien a faire si base non mysql |
|
| 48 | + if (strncmp($GLOBALS['connexions'][0]['type'], 'mysql', 5) !== 0) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 53 | - // forcer le vidage de cache |
|
| 54 | - $trouver_table(''); |
|
| 52 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 53 | + // forcer le vidage de cache |
|
| 54 | + $trouver_table(''); |
|
| 55 | 55 | |
| 56 | - foreach ($tables as $table) { |
|
| 57 | - if (time() >= _TIME_OUT) { |
|
| 58 | - return; |
|
| 59 | - } |
|
| 60 | - if ($desc = $trouver_table($table)) { |
|
| 61 | - $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 62 | - $d = array_diff($desc['field'], $fields_corrected); |
|
| 63 | - if ($d) { |
|
| 64 | - spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 65 | - foreach ($desc['field'] as $field => $type) { |
|
| 66 | - if ($desc['field'][$field] !== $fields_corrected[$field]) { |
|
| 67 | - spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 68 | - sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 69 | - $trouver_table(''); |
|
| 70 | - $new_desc = $trouver_table($table); |
|
| 71 | - spip_log( |
|
| 72 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 74 | - ); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 56 | + foreach ($tables as $table) { |
|
| 57 | + if (time() >= _TIME_OUT) { |
|
| 58 | + return; |
|
| 59 | + } |
|
| 60 | + if ($desc = $trouver_table($table)) { |
|
| 61 | + $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 62 | + $d = array_diff($desc['field'], $fields_corrected); |
|
| 63 | + if ($d) { |
|
| 64 | + spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 65 | + foreach ($desc['field'] as $field => $type) { |
|
| 66 | + if ($desc['field'][$field] !== $fields_corrected[$field]) { |
|
| 67 | + spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 68 | + sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 69 | + $trouver_table(''); |
|
| 70 | + $new_desc = $trouver_table($table); |
|
| 71 | + spip_log( |
|
| 72 | + "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 74 | + ); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // forcer le vidage de cache |
|
| 82 | - $trouver_table(''); |
|
| 81 | + // forcer le vidage de cache |
|
| 82 | + $trouver_table(''); |
|
| 83 | 83 | } |
@@ -64,13 +64,13 @@ |
||
| 64 | 64 | spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
| 65 | 65 | foreach ($desc['field'] as $field => $type) { |
| 66 | 66 | if ($desc['field'][$field] !== $fields_corrected[$field]) { |
| 67 | - spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 68 | - sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 67 | + spip_log("Adaptation TIMESTAMP table $table", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 68 | + sql_alter("table $table change $field $field ".$fields_corrected[$field]); |
|
| 69 | 69 | $trouver_table(''); |
| 70 | 70 | $new_desc = $trouver_table($table); |
| 71 | 71 | spip_log( |
| 72 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 72 | + "Apres conversion $table : ".var_export($new_desc['field'], true), |
|
| 73 | + 'maj.'._LOG_INFO_IMPORTANTE |
|
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | include_spip('maj/legacy/v30'); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Installation |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/acces'); |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | 35 | function base_determine_autoinc($table, $desc = []) { |
| 36 | - if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | - $autoinc = true; |
|
| 38 | - } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | - $autoinc = false; |
|
| 40 | - } else { |
|
| 41 | - // essayer de faire au mieux ! |
|
| 42 | - $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | - and strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | - and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 45 | - } |
|
| 36 | + if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | + $autoinc = true; |
|
| 38 | + } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | + $autoinc = false; |
|
| 40 | + } else { |
|
| 41 | + // essayer de faire au mieux ! |
|
| 42 | + $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | + and strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | + and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $autoinc; |
|
| 47 | + return $autoinc; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -61,58 +61,58 @@ discard block |
||
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | 63 | function creer_ou_upgrader_table($table, $desc, $autoinc, $upgrade = false, $serveur = '') { |
| 64 | - #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | - $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | - #if (!$sql_desc) $sql_desc = false; |
|
| 67 | - #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | - if (!$sql_desc) { |
|
| 69 | - if ($autoinc === 'auto') { |
|
| 70 | - $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | - } |
|
| 72 | - #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | - if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | - } |
|
| 76 | - // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | - #if (!$sql_desc) $sql_desc = false; |
|
| 79 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | - if (!$sql_desc) { |
|
| 81 | - // on retente avec un sleep ? |
|
| 82 | - sleep(1); |
|
| 83 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | - #if (!$sql_desc) $sql_desc = false; |
|
| 86 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | - if (!$sql_desc) { |
|
| 88 | - spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | - // ajouter les champs manquants |
|
| 94 | - // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | - // c'est toujours a faire manuellement |
|
| 96 | - $last = ''; |
|
| 97 | - if (isset($desc['field'])) { |
|
| 98 | - foreach ($desc['field'] as $field => $type) { |
|
| 99 | - if (!isset($sql_desc['field'][$field])) { |
|
| 100 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | - } |
|
| 102 | - $last = $field; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - if (isset($desc['key'])) { |
|
| 106 | - foreach ($desc['key'] as $key => $type) { |
|
| 107 | - // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | - // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | - if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | - sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | - } |
|
| 112 | - $last = $field; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 64 | + #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | + $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | + #if (!$sql_desc) $sql_desc = false; |
|
| 67 | + #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | + if (!$sql_desc) { |
|
| 69 | + if ($autoinc === 'auto') { |
|
| 70 | + $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | + } |
|
| 72 | + #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | + if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | + } |
|
| 76 | + // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | + #if (!$sql_desc) $sql_desc = false; |
|
| 79 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | + if (!$sql_desc) { |
|
| 81 | + // on retente avec un sleep ? |
|
| 82 | + sleep(1); |
|
| 83 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | + #if (!$sql_desc) $sql_desc = false; |
|
| 86 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | + if (!$sql_desc) { |
|
| 88 | + spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | + // ajouter les champs manquants |
|
| 94 | + // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | + // c'est toujours a faire manuellement |
|
| 96 | + $last = ''; |
|
| 97 | + if (isset($desc['field'])) { |
|
| 98 | + foreach ($desc['field'] as $field => $type) { |
|
| 99 | + if (!isset($sql_desc['field'][$field])) { |
|
| 100 | + sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | + } |
|
| 102 | + $last = $field; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + if (isset($desc['key'])) { |
|
| 106 | + foreach ($desc['key'] as $key => $type) { |
|
| 107 | + // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | + // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | + if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | + sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | + } |
|
| 112 | + $last = $field; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -134,26 +134,26 @@ discard block |
||
| 134 | 134 | * @return void |
| 135 | 135 | */ |
| 136 | 136 | function alterer_base($tables_inc, $tables_noinc, $up = false, $serveur = '') { |
| 137 | - if ($up === false) { |
|
| 138 | - $old = false; |
|
| 139 | - $up = []; |
|
| 140 | - } else { |
|
| 141 | - $old = true; |
|
| 142 | - if (!is_array($up)) { |
|
| 143 | - $up = [$up]; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - foreach ($tables_inc as $k => $v) { |
|
| 147 | - if (!$old or in_array($k, $up)) { |
|
| 148 | - creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 149 | - } |
|
| 150 | - } |
|
| 137 | + if ($up === false) { |
|
| 138 | + $old = false; |
|
| 139 | + $up = []; |
|
| 140 | + } else { |
|
| 141 | + $old = true; |
|
| 142 | + if (!is_array($up)) { |
|
| 143 | + $up = [$up]; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + foreach ($tables_inc as $k => $v) { |
|
| 147 | + if (!$old or in_array($k, $up)) { |
|
| 148 | + creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - foreach ($tables_noinc as $k => $v) { |
|
| 153 | - if (!$old or in_array($k, $up)) { |
|
| 154 | - creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 155 | - } |
|
| 156 | - } |
|
| 152 | + foreach ($tables_noinc as $k => $v) { |
|
| 153 | + if (!$old or in_array($k, $up)) { |
|
| 154 | + creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | function creer_base($serveur = '') { |
| 175 | 175 | |
| 176 | - // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 177 | - // de la conformite de la base |
|
| 178 | - // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 176 | + // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 177 | + // de la conformite de la base |
|
| 178 | + // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 179 | 179 | |
| 180 | - alterer_base( |
|
| 181 | - lister_tables_principales(), |
|
| 182 | - lister_tables_auxiliaires(), |
|
| 183 | - false, |
|
| 184 | - $serveur |
|
| 185 | - ); |
|
| 180 | + alterer_base( |
|
| 181 | + lister_tables_principales(), |
|
| 182 | + lister_tables_auxiliaires(), |
|
| 183 | + false, |
|
| 184 | + $serveur |
|
| 185 | + ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | * @return void |
| 203 | 203 | */ |
| 204 | 204 | function maj_tables($upgrade_tables = [], $serveur = '') { |
| 205 | - alterer_base( |
|
| 206 | - lister_tables_principales(), |
|
| 207 | - lister_tables_auxiliaires(), |
|
| 208 | - $upgrade_tables, |
|
| 209 | - $serveur |
|
| 210 | - ); |
|
| 205 | + alterer_base( |
|
| 206 | + lister_tables_principales(), |
|
| 207 | + lister_tables_auxiliaires(), |
|
| 208 | + $upgrade_tables, |
|
| 209 | + $serveur |
|
| 210 | + ); |
|
| 211 | 211 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | #if (!$sql_desc) $sql_desc = false; |
| 86 | 86 | #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 87 | 87 | if (!$sql_desc) { |
| 88 | - spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 88 | + spip_log("Echec creation table $table", 'maj'._LOG_CRITIQUE); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } else { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | if (isset($desc['field'])) { |
| 98 | 98 | foreach ($desc['field'] as $field => $type) { |
| 99 | 99 | if (!isset($sql_desc['field'][$field])) { |
| 100 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 100 | + sql_alter("TABLE $table ADD $field $type".($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | 101 | } |
| 102 | 102 | $last = $field; |
| 103 | 103 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $res = admin_repair_tables(); |
| 40 | 40 | if (!$res) { |
| 41 | - $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 41 | + $res = "<div class='error'>"._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error()."</div>\n"; |
|
| 42 | 42 | } else { |
| 43 | 43 | include_spip('inc/rubriques'); |
| 44 | 44 | calculer_rubriques(); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $res .= pipeline('base_admin_repair', $res); |
| 49 | 49 | echo minipres( |
| 50 | 50 | _T('texte_tentative_recuperation'), |
| 51 | - $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 51 | + $res.generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | 52 | ); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | $count = sql_countsel($tab); |
| 92 | 92 | |
| 93 | 93 | if ($count > 1) { |
| 94 | - $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 94 | + $m .= '('._T('texte_compte_elements', ['count' => $count]).")\n"; |
|
| 95 | 95 | } else { |
| 96 | 96 | if ($count == 1) { |
| 97 | - $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 97 | + $m .= '('._T('texte_compte_element', ['count' => $count]).")\n"; |
|
| 98 | 98 | } else { |
| 99 | - $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 99 | + $m .= '('._T('texte_vide').")\n"; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | and $msg = join( |
| 106 | 106 | ' ', |
| 107 | 107 | (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
| 108 | - ) . ' ' |
|
| 108 | + ).' ' |
|
| 109 | 109 | and strpos($msg, ' OK ') === false |
| 110 | 110 | ) { |
| 111 | 111 | $class = " class='notice'"; |
| 112 | - $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 112 | + $m .= '<br /><tt>'.spip_htmlentities($msg)."</tt>\n"; |
|
| 113 | 113 | } else { |
| 114 | - $m .= ' ' . _T('texte_table_ok'); |
|
| 114 | + $m .= ' '._T('texte_table_ok'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $res .= "<div$class>$m</div>"; |
@@ -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 | /** |
@@ -36,20 +36,20 @@ discard block |
||
| 36 | 36 | **/ |
| 37 | 37 | function base_repair_dist($titre = '', $reprise = '') { |
| 38 | 38 | |
| 39 | - $res = admin_repair_tables(); |
|
| 40 | - if (!$res) { |
|
| 41 | - $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 42 | - } else { |
|
| 43 | - include_spip('inc/rubriques'); |
|
| 44 | - calculer_rubriques(); |
|
| 45 | - propager_les_secteurs(); |
|
| 46 | - } |
|
| 47 | - include_spip('inc/minipres'); |
|
| 48 | - $res .= pipeline('base_admin_repair', $res); |
|
| 49 | - echo minipres( |
|
| 50 | - _T('texte_tentative_recuperation'), |
|
| 51 | - $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | - ); |
|
| 39 | + $res = admin_repair_tables(); |
|
| 40 | + if (!$res) { |
|
| 41 | + $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 42 | + } else { |
|
| 43 | + include_spip('inc/rubriques'); |
|
| 44 | + calculer_rubriques(); |
|
| 45 | + propager_les_secteurs(); |
|
| 46 | + } |
|
| 47 | + include_spip('inc/minipres'); |
|
| 48 | + $res .= pipeline('base_admin_repair', $res); |
|
| 49 | + echo minipres( |
|
| 50 | + _T('texte_tentative_recuperation'), |
|
| 51 | + $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | + ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -63,59 +63,59 @@ discard block |
||
| 63 | 63 | **/ |
| 64 | 64 | function admin_repair_tables() { |
| 65 | 65 | |
| 66 | - $repair = sql_serveur('repair', '', true); |
|
| 66 | + $repair = sql_serveur('repair', '', true); |
|
| 67 | 67 | |
| 68 | - // recreer les tables manquantes eventuelles |
|
| 69 | - include_spip('base/create'); |
|
| 70 | - creer_base(); |
|
| 71 | - $tables = sql_alltable(); |
|
| 68 | + // recreer les tables manquantes eventuelles |
|
| 69 | + include_spip('base/create'); |
|
| 70 | + creer_base(); |
|
| 71 | + $tables = sql_alltable(); |
|
| 72 | 72 | |
| 73 | - $res = ''; |
|
| 74 | - foreach ($tables as $tab) { |
|
| 75 | - $class = ''; |
|
| 76 | - $m = "<strong>$tab</strong> "; |
|
| 77 | - spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 78 | - // supprimer la meta avant de lancer la reparation |
|
| 79 | - // car le repair peut etre long ; on ne veut pas boucler |
|
| 80 | - effacer_meta('admin_repair'); |
|
| 81 | - if ($repair) { |
|
| 82 | - $result_repair = sql_repair($tab); |
|
| 83 | - if (!$result_repair) { |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 86 | - } |
|
| 73 | + $res = ''; |
|
| 74 | + foreach ($tables as $tab) { |
|
| 75 | + $class = ''; |
|
| 76 | + $m = "<strong>$tab</strong> "; |
|
| 77 | + spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 78 | + // supprimer la meta avant de lancer la reparation |
|
| 79 | + // car le repair peut etre long ; on ne veut pas boucler |
|
| 80 | + effacer_meta('admin_repair'); |
|
| 81 | + if ($repair) { |
|
| 82 | + $result_repair = sql_repair($tab); |
|
| 83 | + if (!$result_repair) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // essayer de maj la table (creation de champs manquants) |
|
| 89 | - maj_tables($tab); |
|
| 88 | + // essayer de maj la table (creation de champs manquants) |
|
| 89 | + maj_tables($tab); |
|
| 90 | 90 | |
| 91 | - $count = sql_countsel($tab); |
|
| 91 | + $count = sql_countsel($tab); |
|
| 92 | 92 | |
| 93 | - if ($count > 1) { |
|
| 94 | - $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 95 | - } else { |
|
| 96 | - if ($count == 1) { |
|
| 97 | - $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 98 | - } else { |
|
| 99 | - $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 100 | - } |
|
| 101 | - } |
|
| 93 | + if ($count > 1) { |
|
| 94 | + $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 95 | + } else { |
|
| 96 | + if ($count == 1) { |
|
| 97 | + $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 98 | + } else { |
|
| 99 | + $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - if ( |
|
| 104 | - $result_repair |
|
| 105 | - and $msg = join( |
|
| 106 | - ' ', |
|
| 107 | - (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
|
| 108 | - ) . ' ' |
|
| 109 | - and strpos($msg, ' OK ') === false |
|
| 110 | - ) { |
|
| 111 | - $class = " class='notice'"; |
|
| 112 | - $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 113 | - } else { |
|
| 114 | - $m .= ' ' . _T('texte_table_ok'); |
|
| 115 | - } |
|
| 103 | + if ( |
|
| 104 | + $result_repair |
|
| 105 | + and $msg = join( |
|
| 106 | + ' ', |
|
| 107 | + (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
|
| 108 | + ) . ' ' |
|
| 109 | + and strpos($msg, ' OK ') === false |
|
| 110 | + ) { |
|
| 111 | + $class = " class='notice'"; |
|
| 112 | + $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 113 | + } else { |
|
| 114 | + $m .= ' ' . _T('texte_table_ok'); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - $res .= "<div$class>$m</div>"; |
|
| 118 | - } |
|
| 117 | + $res .= "<div$class>$m</div>"; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - return $res; |
|
| 120 | + return $res; |
|
| 121 | 121 | } |