@@ -11,112 +11,112 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/texte'); |
| 18 | 18 | |
| 19 | 19 | function inc_plonger_dist($id_rubrique, $idom = '', $list = [], $col = 1, $exclu = 0, $do = 'aff') { |
| 20 | 20 | |
| 21 | - if ($list) { |
|
| 22 | - $id_rubrique = $list[$col - 1]; |
|
| 23 | - } |
|
| 21 | + if ($list) { |
|
| 22 | + $id_rubrique = $list[$col - 1]; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - $ret = ''; |
|
| 25 | + $ret = ''; |
|
| 26 | 26 | |
| 27 | - # recherche les filles et petites-filles de la rubrique donnee |
|
| 28 | - # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 29 | - # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 30 | - # racine... sauf vers elle-meme ou sa propre branche) |
|
| 31 | - $ordre = []; |
|
| 32 | - $rub = []; |
|
| 27 | + # recherche les filles et petites-filles de la rubrique donnee |
|
| 28 | + # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 29 | + # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 30 | + # racine... sauf vers elle-meme ou sa propre branche) |
|
| 31 | + $ordre = []; |
|
| 32 | + $rub = []; |
|
| 33 | 33 | |
| 34 | - $res = sql_select( |
|
| 35 | - 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
|
| 36 | - 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
|
| 37 | - 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 34 | + $res = sql_select( |
|
| 35 | + 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
|
| 36 | + 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
|
| 37 | + 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 38 | 38 | AND rub1.id_rubrique!=' . sql_quote($exclu) . ' |
| 39 | 39 | AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')', |
| 40 | - '', |
|
| 41 | - '0+rub1.titre,rub1.titre' |
|
| 42 | - ); |
|
| 40 | + '', |
|
| 41 | + '0+rub1.titre,rub1.titre' |
|
| 42 | + ); |
|
| 43 | 43 | |
| 44 | - while ($row = sql_fetch($res)) { |
|
| 45 | - if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 46 | - $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 47 | - if ($row['id_parent'] == $id_rubrique) { |
|
| 48 | - $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 49 | - if ($row['langue_choisie'] != 'oui') { |
|
| 50 | - $t .= ' <small title="' |
|
| 51 | - . traduire_nom_langue($row['lang']) |
|
| 52 | - . '">[' . $row['lang'] . ']</small>'; |
|
| 53 | - } |
|
| 54 | - $ordre[$row['id_rubrique']] = $t; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - $next = $list[$col] ?? 0; |
|
| 59 | - if ($ordre) { |
|
| 60 | - $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 61 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 62 | - $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 44 | + while ($row = sql_fetch($res)) { |
|
| 45 | + if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 46 | + $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 47 | + if ($row['id_parent'] == $id_rubrique) { |
|
| 48 | + $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 49 | + if ($row['langue_choisie'] != 'oui') { |
|
| 50 | + $t .= ' <small title="' |
|
| 51 | + . traduire_nom_langue($row['lang']) |
|
| 52 | + . '">[' . $row['lang'] . ']</small>'; |
|
| 53 | + } |
|
| 54 | + $ordre[$row['id_rubrique']] = $t; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + $next = $list[$col] ?? 0; |
|
| 59 | + if ($ordre) { |
|
| 60 | + $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 61 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 62 | + $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 63 | 63 | |
| 64 | - foreach ($ordre as $id => $titrebrut) { |
|
| 65 | - $titre = supprimer_numero($titrebrut); |
|
| 64 | + foreach ($ordre as $id => $titrebrut) { |
|
| 65 | + $titre = supprimer_numero($titrebrut); |
|
| 66 | 66 | |
| 67 | - $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 68 | - if (isset($rub[$id]['enfants'])) { |
|
| 69 | - $classe2 = " class='rub-ouverte'"; |
|
| 70 | - $url = "\nhref='$rec&id=$id'"; |
|
| 71 | - } else { |
|
| 72 | - $classe2 = $url = ''; |
|
| 73 | - $url = "\nhref='javascript:void(0)'"; |
|
| 74 | - } |
|
| 67 | + $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 68 | + if (isset($rub[$id]['enfants'])) { |
|
| 69 | + $classe2 = " class='rub-ouverte'"; |
|
| 70 | + $url = "\nhref='$rec&id=$id'"; |
|
| 71 | + } else { |
|
| 72 | + $classe2 = $url = ''; |
|
| 73 | + $url = "\nhref='javascript:void(0)'"; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $js_func = $do . '_selection_titre'; |
|
| 77 | - $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 78 | - . (!is_array($list) ? ' false' |
|
| 79 | - : "aff_selection_provisoire($id,$args)") |
|
| 76 | + $js_func = $do . '_selection_titre'; |
|
| 77 | + $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 78 | + . (!is_array($list) ? ' false' |
|
| 79 | + : "aff_selection_provisoire($id,$args)") |
|
| 80 | 80 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 81 | 81 | # et l'affichage de son titre dans le bandeau |
| 82 | - . "\"\nondblclick=\"" |
|
| 83 | - . "$js_func(this." |
|
| 84 | - . 'firstChild.nodeValue,' |
|
| 85 | - . $id |
|
| 86 | - . ",'selection_rubrique','id_parent');" |
|
| 87 | - . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 88 | - . '"'; |
|
| 82 | + . "\"\nondblclick=\"" |
|
| 83 | + . "$js_func(this." |
|
| 84 | + . 'firstChild.nodeValue,' |
|
| 85 | + . $id |
|
| 86 | + . ",'selection_rubrique','id_parent');" |
|
| 87 | + . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 88 | + . '"'; |
|
| 89 | 89 | |
| 90 | - $ret .= "<div class='" |
|
| 91 | - . (($id == $next) ? 'item on' : 'item') |
|
| 92 | - . "'><div class='" |
|
| 93 | - . $classe1 |
|
| 94 | - . "'><div$classe2><a" |
|
| 95 | - . $url |
|
| 96 | - . $click |
|
| 97 | - . '>' |
|
| 98 | - . $titre |
|
| 99 | - . '</a></div></div></div>'; |
|
| 100 | - } |
|
| 101 | - } |
|
| 90 | + $ret .= "<div class='" |
|
| 91 | + . (($id == $next) ? 'item on' : 'item') |
|
| 92 | + . "'><div class='" |
|
| 93 | + . $classe1 |
|
| 94 | + . "'><div$classe2><a" |
|
| 95 | + . $url |
|
| 96 | + . $click |
|
| 97 | + . '>' |
|
| 98 | + . $titre |
|
| 99 | + . '</a></div></div></div>'; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - $idom2 = $idom . '_col_' . ($col + 1); |
|
| 104 | - $left = ($col * 250); |
|
| 103 | + $idom2 = $idom . '_col_' . ($col + 1); |
|
| 104 | + $left = ($col * 250); |
|
| 105 | 105 | |
| 106 | - return http_img_pack( |
|
| 107 | - 'loader.svg', |
|
| 108 | - '', |
|
| 109 | - "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 110 | - . ($left - 30) |
|
| 111 | - . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
|
| 112 | - ) |
|
| 113 | - . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 114 | - . ($left - 250) |
|
| 115 | - . "px;'>" |
|
| 116 | - . $ret |
|
| 117 | - . "\n</div>\n<div id='$idom2'>" |
|
| 118 | - . ($next |
|
| 119 | - ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 120 | - : '') |
|
| 121 | - . "\n</div>"; |
|
| 106 | + return http_img_pack( |
|
| 107 | + 'loader.svg', |
|
| 108 | + '', |
|
| 109 | + "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 110 | + . ($left - 30) |
|
| 111 | + . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
|
| 112 | + ) |
|
| 113 | + . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 114 | + . ($left - 250) |
|
| 115 | + . "px;'>" |
|
| 116 | + . $ret |
|
| 117 | + . "\n</div>\n<div id='$idom2'>" |
|
| 118 | + . ($next |
|
| 119 | + ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 120 | + : '') |
|
| 121 | + . "\n</div>"; |
|
| 122 | 122 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Presentation |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/presentation_mini'); |
@@ -31,141 +31,141 @@ discard block |
||
| 31 | 31 | include_spip('inc/filtres_alertes'); |
| 32 | 32 | |
| 33 | 33 | function debut_cadre($style, $icone = '', $fonction = '', $titre = '', $id = '', $class = '', $padding = true) { |
| 34 | - $fond = null; |
|
| 35 | - $style_mapping = [ |
|
| 36 | - 'r' => 'simple', |
|
| 37 | - 'e' => 'raccourcis', |
|
| 38 | - 'couleur' => 'basic highlight', |
|
| 39 | - 'couleur-foncee' => 'basic highlight', |
|
| 40 | - 'trait-couleur' => 'important', |
|
| 41 | - 'alerte' => 'notice', |
|
| 42 | - 'info' => 'info', |
|
| 43 | - 'sous_rub' => 'simple sous-rub' |
|
| 44 | - ]; |
|
| 45 | - $style_titre_mapping = ['couleur' => 'topper', 'trait-couleur' => 'section']; |
|
| 46 | - $c = $style_mapping[$style] ?? 'simple'; |
|
| 47 | - $class = $c . ($class ? " $class" : ''); |
|
| 48 | - if (!$padding) { |
|
| 49 | - $class .= ($class ? ' ' : '') . 'no-padding'; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - //($id?"id='$id' ":"") |
|
| 53 | - if (strlen($icone) > 1) { |
|
| 54 | - if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 55 | - [$fond, $fonction] = $icone_renommer($icone, $fonction); |
|
| 56 | - } |
|
| 57 | - $size = 24; |
|
| 58 | - if (preg_match('/-([0-9]{1,3})[.](gif|png)$/i', $fond, $match)) { |
|
| 59 | - $size = $match[1]; |
|
| 60 | - } |
|
| 61 | - if ($fonction) { |
|
| 62 | - // 2 images pour composer l'icone : le fond (article) en background, |
|
| 63 | - // la fonction (new) en image |
|
| 64 | - $icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n" . |
|
| 65 | - http_style_background($fond, 'no-repeat center center', $size)); |
|
| 66 | - } else { |
|
| 67 | - $icone = http_img_pack($fond, '', "class='cadre-icone' width='$size' height='$size'"); |
|
| 68 | - } |
|
| 69 | - $titre = $icone . $titre; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return boite_ouvrir($titre, $class, $style_titre_mapping[$style] ?? '', $id); |
|
| 34 | + $fond = null; |
|
| 35 | + $style_mapping = [ |
|
| 36 | + 'r' => 'simple', |
|
| 37 | + 'e' => 'raccourcis', |
|
| 38 | + 'couleur' => 'basic highlight', |
|
| 39 | + 'couleur-foncee' => 'basic highlight', |
|
| 40 | + 'trait-couleur' => 'important', |
|
| 41 | + 'alerte' => 'notice', |
|
| 42 | + 'info' => 'info', |
|
| 43 | + 'sous_rub' => 'simple sous-rub' |
|
| 44 | + ]; |
|
| 45 | + $style_titre_mapping = ['couleur' => 'topper', 'trait-couleur' => 'section']; |
|
| 46 | + $c = $style_mapping[$style] ?? 'simple'; |
|
| 47 | + $class = $c . ($class ? " $class" : ''); |
|
| 48 | + if (!$padding) { |
|
| 49 | + $class .= ($class ? ' ' : '') . 'no-padding'; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + //($id?"id='$id' ":"") |
|
| 53 | + if (strlen($icone) > 1) { |
|
| 54 | + if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 55 | + [$fond, $fonction] = $icone_renommer($icone, $fonction); |
|
| 56 | + } |
|
| 57 | + $size = 24; |
|
| 58 | + if (preg_match('/-([0-9]{1,3})[.](gif|png)$/i', $fond, $match)) { |
|
| 59 | + $size = $match[1]; |
|
| 60 | + } |
|
| 61 | + if ($fonction) { |
|
| 62 | + // 2 images pour composer l'icone : le fond (article) en background, |
|
| 63 | + // la fonction (new) en image |
|
| 64 | + $icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n" . |
|
| 65 | + http_style_background($fond, 'no-repeat center center', $size)); |
|
| 66 | + } else { |
|
| 67 | + $icone = http_img_pack($fond, '', "class='cadre-icone' width='$size' height='$size'"); |
|
| 68 | + } |
|
| 69 | + $titre = $icone . $titre; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return boite_ouvrir($titre, $class, $style_titre_mapping[$style] ?? '', $id); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | function fin_cadre() { |
| 76 | - return boite_fermer(); |
|
| 76 | + return boite_fermer(); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | function debut_cadre_relief( |
| 81 | - $icone = '', |
|
| 82 | - $dummy = '', |
|
| 83 | - $fonction = '', |
|
| 84 | - $titre = '', |
|
| 85 | - $id = '', |
|
| 86 | - $class = '' |
|
| 81 | + $icone = '', |
|
| 82 | + $dummy = '', |
|
| 83 | + $fonction = '', |
|
| 84 | + $titre = '', |
|
| 85 | + $id = '', |
|
| 86 | + $class = '' |
|
| 87 | 87 | ) { |
| 88 | - return debut_cadre('r', $icone, $fonction, $titre, $id, $class); |
|
| 88 | + return debut_cadre('r', $icone, $fonction, $titre, $id, $class); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function fin_cadre_relief() { |
| 92 | - return fin_cadre(); |
|
| 92 | + return fin_cadre(); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | function debut_cadre_enfonce( |
| 96 | - $icone = '', |
|
| 97 | - $dummy = '', |
|
| 98 | - $fonction = '', |
|
| 99 | - $titre = '', |
|
| 100 | - $id = '', |
|
| 101 | - $class = '' |
|
| 96 | + $icone = '', |
|
| 97 | + $dummy = '', |
|
| 98 | + $fonction = '', |
|
| 99 | + $titre = '', |
|
| 100 | + $id = '', |
|
| 101 | + $class = '' |
|
| 102 | 102 | ) { |
| 103 | - return debut_cadre('e', $icone, $fonction, $titre, $id, $class); |
|
| 103 | + return debut_cadre('e', $icone, $fonction, $titre, $id, $class); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | function fin_cadre_enfonce() { |
| 107 | - return fin_cadre(); |
|
| 107 | + return fin_cadre(); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | function debut_cadre_sous_rub( |
| 111 | - $icone = '', |
|
| 112 | - $dummy = '', |
|
| 113 | - $fonction = '', |
|
| 114 | - $titre = '', |
|
| 115 | - $id = '', |
|
| 116 | - $class = '' |
|
| 111 | + $icone = '', |
|
| 112 | + $dummy = '', |
|
| 113 | + $fonction = '', |
|
| 114 | + $titre = '', |
|
| 115 | + $id = '', |
|
| 116 | + $class = '' |
|
| 117 | 117 | ) { |
| 118 | - return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class); |
|
| 118 | + return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | function fin_cadre_sous_rub() { |
| 122 | - return fin_cadre(); |
|
| 122 | + return fin_cadre(); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | function debut_cadre_couleur( |
| 126 | - $icone = '', |
|
| 127 | - $dummy = '', |
|
| 128 | - $fonction = '', |
|
| 129 | - $titre = '', |
|
| 130 | - $id = '', |
|
| 131 | - $class = '' |
|
| 126 | + $icone = '', |
|
| 127 | + $dummy = '', |
|
| 128 | + $fonction = '', |
|
| 129 | + $titre = '', |
|
| 130 | + $id = '', |
|
| 131 | + $class = '' |
|
| 132 | 132 | ) { |
| 133 | - return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class); |
|
| 133 | + return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | function fin_cadre_couleur() { |
| 137 | - return fin_cadre(); |
|
| 137 | + return fin_cadre(); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | function debut_cadre_trait_couleur( |
| 141 | - $icone = '', |
|
| 142 | - $dummy = '', |
|
| 143 | - $fonction = '', |
|
| 144 | - $titre = '', |
|
| 145 | - $id = '', |
|
| 146 | - $class = '' |
|
| 141 | + $icone = '', |
|
| 142 | + $dummy = '', |
|
| 143 | + $fonction = '', |
|
| 144 | + $titre = '', |
|
| 145 | + $id = '', |
|
| 146 | + $class = '' |
|
| 147 | 147 | ) { |
| 148 | - return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class); |
|
| 148 | + return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | function fin_cadre_trait_couleur() { |
| 152 | - return fin_cadre(); |
|
| 152 | + return fin_cadre(); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | function debut_boite_alerte() { |
| 156 | - return debut_cadre('alerte', '', '', '', '', ''); |
|
| 156 | + return debut_cadre('alerte', '', '', '', '', ''); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | function fin_boite_alerte() { |
| 160 | - return fin_cadre(); |
|
| 160 | + return fin_cadre(); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | function debut_boite_info() { |
| 164 | - return debut_cadre('info', '', '', '', '', ''); |
|
| 164 | + return debut_cadre('info', '', '', '', '', ''); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function fin_boite_info() { |
| 168 | - return fin_cadre(); |
|
| 168 | + return fin_cadre(); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -176,17 +176,17 @@ discard block |
||
| 176 | 176 | * @return string Code PHP. |
| 177 | 177 | **/ |
| 178 | 178 | function gros_titre( |
| 179 | - $titre, |
|
| 180 | - $ze_logo = '' |
|
| 179 | + $titre, |
|
| 180 | + $ze_logo = '' |
|
| 181 | 181 | ) { |
| 182 | - return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n"; |
|
| 182 | + return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // La boite des raccourcis |
| 186 | 186 | // Se place a droite si l'ecran est en mode panoramique. |
| 187 | 187 | function bloc_des_raccourcis($bloc) { |
| 188 | - return creer_colonne_droite() |
|
| 189 | - . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer(); |
|
| 188 | + return creer_colonne_droite() |
|
| 189 | + . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer(); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // |
@@ -196,18 +196,18 @@ discard block |
||
| 196 | 196 | // Fonctions onglets |
| 197 | 197 | // @param string $sous_classe prend la valeur second pour definir les onglet de deuxieme niveau |
| 198 | 198 | function debut_onglet($classe = 'barre_onglet') { |
| 199 | - return "<div class = '$classe clearfix'><ul>\n"; |
|
| 199 | + return "<div class = '$classe clearfix'><ul>\n"; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | function fin_onglet() { |
| 203 | - return "</ul></div>\n"; |
|
| 203 | + return "</ul></div>\n"; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | function onglet($texte, $lien, $onglet_ref, $onglet, $icone = '') { |
| 207 | - return '<li>' |
|
| 208 | - . ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '') |
|
| 209 | - . lien_ou_expose($lien, $texte, $onglet == $onglet_ref) |
|
| 210 | - . '</li>'; |
|
| 207 | + return '<li>' |
|
| 208 | + . ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '') |
|
| 209 | + . lien_ou_expose($lien, $texte, $onglet == $onglet_ref) |
|
| 210 | + . '</li>'; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | * Code HTML du lien |
| 240 | 240 | **/ |
| 241 | 241 | function icone_verticale($texte, $lien, $fond, $fonction = '', $align = '', $javascript = '') { |
| 242 | - // cas d'ajax_action_auteur: faut defaire le boulot |
|
| 243 | - // (il faudrait fusionner avec le cas $javascript) |
|
| 244 | - if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) { |
|
| 245 | - [$x, $lien, $atts, $texte] = $r; |
|
| 246 | - $javascript .= $atts; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript); |
|
| 242 | + // cas d'ajax_action_auteur: faut defaire le boulot |
|
| 243 | + // (il faudrait fusionner avec le cas $javascript) |
|
| 244 | + if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) { |
|
| 245 | + [$x, $lien, $atts, $texte] = $r; |
|
| 246 | + $javascript .= $atts; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -271,15 +271,15 @@ discard block |
||
| 271 | 271 | * Code HTML du lien |
| 272 | 272 | **/ |
| 273 | 273 | function icone_horizontale($texte, $lien, $fond, $fonction = '', $dummy = '', $javascript = '') { |
| 274 | - $retour = ''; |
|
| 275 | - // cas d'ajax_action_auteur: faut defaire le boulot |
|
| 276 | - // (il faudrait fusionner avec le cas $javascript) |
|
| 277 | - if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) { |
|
| 278 | - [$x, $lien, $atts, $texte] = $r; |
|
| 279 | - $javascript .= $atts; |
|
| 280 | - } |
|
| 274 | + $retour = ''; |
|
| 275 | + // cas d'ajax_action_auteur: faut defaire le boulot |
|
| 276 | + // (il faudrait fusionner avec le cas $javascript) |
|
| 277 | + if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) { |
|
| 278 | + [$x, $lien, $atts, $texte] = $r; |
|
| 279 | + $javascript .= $atts; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - $retour = icone_base($lien, $texte, $fond, $fonction, 'horizontale', $javascript); |
|
| 282 | + $retour = icone_base($lien, $texte, $fond, $fonction, 'horizontale', $javascript); |
|
| 283 | 283 | |
| 284 | - return $retour; |
|
| 284 | + return $retour; |
|
| 285 | 285 | } |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | ]; |
| 45 | 45 | $style_titre_mapping = ['couleur' => 'topper', 'trait-couleur' => 'section']; |
| 46 | 46 | $c = $style_mapping[$style] ?? 'simple'; |
| 47 | - $class = $c . ($class ? " $class" : ''); |
|
| 47 | + $class = $c.($class ? " $class" : ''); |
|
| 48 | 48 | if (!$padding) { |
| 49 | - $class .= ($class ? ' ' : '') . 'no-padding'; |
|
| 49 | + $class .= ($class ? ' ' : '').'no-padding'; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | //($id?"id='$id' ":"") |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | if ($fonction) { |
| 62 | 62 | // 2 images pour composer l'icone : le fond (article) en background, |
| 63 | 63 | // la fonction (new) en image |
| 64 | - $icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n" . |
|
| 64 | + $icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n". |
|
| 65 | 65 | http_style_background($fond, 'no-repeat center center', $size)); |
| 66 | 66 | } else { |
| 67 | 67 | $icone = http_img_pack($fond, '', "class='cadre-icone' width='$size' height='$size'"); |
| 68 | 68 | } |
| 69 | - $titre = $icone . $titre; |
|
| 69 | + $titre = $icone.$titre; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return boite_ouvrir($titre, $class, $style_titre_mapping[$style] ?? '', $id); |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | $titre, |
| 180 | 180 | $ze_logo = '' |
| 181 | 181 | ) { |
| 182 | - return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n"; |
|
| 182 | + return "<h1 class = 'grostitre'>".$ze_logo.' '.typo($titre)."</h1>\n"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // La boite des raccourcis |
| 186 | 186 | // Se place a droite si l'ecran est en mode panoramique. |
| 187 | 187 | function bloc_des_raccourcis($bloc) { |
| 188 | 188 | return creer_colonne_droite() |
| 189 | - . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer(); |
|
| 189 | + . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis').$bloc.boite_fermer(); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // |
@@ -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 | defined('_RECHERCHE_LOCK_KEY') || define('_RECHERCHE_LOCK_KEY', 'fulltext'); |
@@ -35,198 +35,198 @@ discard block |
||
| 35 | 35 | * @return array Couples (type d'objet => Couples (champ => score)) |
| 36 | 36 | */ |
| 37 | 37 | function liste_des_champs() { |
| 38 | - static $liste = null; |
|
| 39 | - if (is_null($liste)) { |
|
| 40 | - $liste = []; |
|
| 41 | - // recuperer les tables_objets_sql declarees |
|
| 42 | - include_spip('base/objets'); |
|
| 43 | - $tables_objets = lister_tables_objets_sql(); |
|
| 44 | - foreach ($tables_objets as $t => $infos) { |
|
| 45 | - if ($infos['rechercher_champs']) { |
|
| 46 | - $liste[$infos['type']] = $infos['rechercher_champs']; |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - // puis passer dans le pipeline |
|
| 50 | - $liste = pipeline('rechercher_liste_des_champs', $liste); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - return $liste; |
|
| 38 | + static $liste = null; |
|
| 39 | + if (is_null($liste)) { |
|
| 40 | + $liste = []; |
|
| 41 | + // recuperer les tables_objets_sql declarees |
|
| 42 | + include_spip('base/objets'); |
|
| 43 | + $tables_objets = lister_tables_objets_sql(); |
|
| 44 | + foreach ($tables_objets as $t => $infos) { |
|
| 45 | + if ($infos['rechercher_champs']) { |
|
| 46 | + $liste[$infos['type']] = $infos['rechercher_champs']; |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + // puis passer dans le pipeline |
|
| 50 | + $liste = pipeline('rechercher_liste_des_champs', $liste); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + return $liste; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | // Recherche des auteurs et mots-cles associes |
| 58 | 58 | // en ne regardant que le titre ou le nom |
| 59 | 59 | function liste_des_jointures() { |
| 60 | - static $liste = null; |
|
| 61 | - if (is_null($liste)) { |
|
| 62 | - $liste = []; |
|
| 63 | - // recuperer les tables_objets_sql declarees |
|
| 64 | - include_spip('base/objets'); |
|
| 65 | - $tables_objets = lister_tables_objets_sql(); |
|
| 66 | - foreach ($tables_objets as $t => $infos) { |
|
| 67 | - if ($infos['rechercher_jointures']) { |
|
| 68 | - $liste[$infos['type']] = $infos['rechercher_jointures']; |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - // puis passer dans le pipeline |
|
| 72 | - $liste = pipeline('rechercher_liste_des_jointures', $liste); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return $liste; |
|
| 60 | + static $liste = null; |
|
| 61 | + if (is_null($liste)) { |
|
| 62 | + $liste = []; |
|
| 63 | + // recuperer les tables_objets_sql declarees |
|
| 64 | + include_spip('base/objets'); |
|
| 65 | + $tables_objets = lister_tables_objets_sql(); |
|
| 66 | + foreach ($tables_objets as $t => $infos) { |
|
| 67 | + if ($infos['rechercher_jointures']) { |
|
| 68 | + $liste[$infos['type']] = $infos['rechercher_jointures']; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + // puis passer dans le pipeline |
|
| 72 | + $liste = pipeline('rechercher_liste_des_jointures', $liste); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return $liste; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | function expression_recherche($recherche, $options) { |
| 79 | - // ne calculer qu'une seule fois l'expression par hit |
|
| 80 | - // (meme si utilisee dans plusieurs boucles) |
|
| 81 | - static $expression = []; |
|
| 82 | - $key = serialize([$recherche, $options['preg_flags']]); |
|
| 83 | - if (isset($expression[$key])) { |
|
| 84 | - return $expression[$key]; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 88 | - if ($u and strpos($options['preg_flags'], (string) $u) === false) { |
|
| 89 | - $options['preg_flags'] .= $u; |
|
| 90 | - } |
|
| 91 | - include_spip('inc/charsets'); |
|
| 92 | - $recherche = trim($recherche); |
|
| 93 | - |
|
| 94 | - // retirer les + de +truc et les * de truc* |
|
| 95 | - $recherche = preg_replace(',(^|\s)\+(\w),Uims', '$1$2', $recherche); |
|
| 96 | - $recherche = preg_replace(',(\w)\*($|\s),Uims', '$1$2', $recherche); |
|
| 97 | - |
|
| 98 | - $is_preg = false; |
|
| 99 | - if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) { |
|
| 100 | - // c'est une preg |
|
| 101 | - $recherche_trans = translitteration($recherche); |
|
| 102 | - $preg = $recherche_trans . $options['preg_flags']; |
|
| 103 | - $is_preg = true; |
|
| 104 | - } else { |
|
| 105 | - // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP, |
|
| 106 | - // sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un', |
|
| 107 | - // 'une', 'des' ...) |
|
| 108 | - |
|
| 109 | - // attention : plusieurs mots entre guillemets sont a rechercher tels quels |
|
| 110 | - $recherche_trans = $recherche_mod = $recherche_org = $recherche; |
|
| 111 | - |
|
| 112 | - // les expressions entre " " sont un mot a chercher tel quel |
|
| 113 | - // -> on remplace les espaces par un \x1 et on enleve les guillemets |
|
| 114 | - if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 115 | - foreach ($matches as $match) { |
|
| 116 | - $word = preg_replace(',\s+,Uims', "\x1", $match); |
|
| 117 | - $word = trim($word, '"'); |
|
| 118 | - $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - if (preg_match(',\s+,' . $u, $recherche_mod)) { |
|
| 123 | - $is_preg = true; |
|
| 124 | - |
|
| 125 | - $recherche_inter = '|'; |
|
| 126 | - $recherche_mots = explode(' ', $recherche_mod); |
|
| 127 | - $min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4; |
|
| 128 | - $petits_mots = true; |
|
| 129 | - foreach ($recherche_mots as $mot) { |
|
| 130 | - if (strlen($mot) >= $min_long) { |
|
| 131 | - // echapper les caracteres de regexp qui sont eventuellement dans la recherche |
|
| 132 | - $recherche_inter .= preg_quote($mot) . ' '; |
|
| 133 | - $petits_mots = false; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $recherche_inter = str_replace("\x1", '\s', $recherche_inter); |
|
| 137 | - |
|
| 138 | - // mais on cherche quand même l'expression complète, même si elle |
|
| 139 | - // comporte des mots de moins de quatre lettres |
|
| 140 | - $recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|'); |
|
| 141 | - if (!$recherche or $petits_mots) { |
|
| 142 | - $recherche = preg_quote($recherche_org); |
|
| 143 | - } |
|
| 144 | - $recherche_trans = translitteration($recherche); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - $preg = '/' . str_replace('/', '\\/', $recherche_trans) . '/' . $options['preg_flags']; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite |
|
| 151 | - // ou si l'expression reguliere est invalide |
|
| 152 | - if ( |
|
| 153 | - !$is_preg |
|
| 154 | - or (@preg_match($preg, '') === false) |
|
| 155 | - ) { |
|
| 156 | - $methode = 'LIKE'; |
|
| 157 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 158 | - |
|
| 159 | - // echapper les % et _ |
|
| 160 | - $q = str_replace(['%', '_'], ['\%', '\_'], trim($recherche)); |
|
| 161 | - |
|
| 162 | - // eviter les parentheses et autres caractères qui interferent avec pcre par la suite (dans le preg_match_all) s'il y a des reponses |
|
| 163 | - $recherche = preg_quote($recherche, '/'); |
|
| 164 | - $recherche_trans = translitteration($recherche); |
|
| 165 | - $recherche_mod = $recherche_trans; |
|
| 166 | - |
|
| 167 | - // les expressions entre " " sont un mot a chercher tel quel |
|
| 168 | - // -> on remplace les espaces par un _ et on enleve les guillemets |
|
| 169 | - // corriger le like dans le $q |
|
| 170 | - if (preg_match(',["][^"]+["],Uims', $q, $matches)) { |
|
| 171 | - foreach ($matches as $match) { |
|
| 172 | - $word = preg_replace(',\s+,Uims', '_', $match); |
|
| 173 | - $word = trim($word, '"'); |
|
| 174 | - $q = str_replace($match, $word, $q); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - // corriger la regexp |
|
| 178 | - if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 179 | - foreach ($matches as $match) { |
|
| 180 | - $word = preg_replace(',\s+,Uims', '[\s]', $match); |
|
| 181 | - $word = trim($word, '"'); |
|
| 182 | - $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - $q = sql_quote( |
|
| 186 | - '%' |
|
| 187 | - . preg_replace(',\s+,' . $u, '%', $q) |
|
| 188 | - . '%' |
|
| 189 | - ); |
|
| 190 | - |
|
| 191 | - $preg = '/' . preg_replace(',\s+,' . $u, '.+', trim($recherche_mod)) . '/' . $options['preg_flags']; |
|
| 192 | - } else { |
|
| 193 | - $methode = 'REGEXP'; |
|
| 194 | - $q = sql_quote(trim($recherche, '/')); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - // tous les caracteres transliterables de $q sont remplaces par un joker |
|
| 198 | - // permet de matcher en SQL meme si on est sensible aux accents (SQLite) |
|
| 199 | - $q_t = $q; |
|
| 200 | - for ($i = 0; $i < spip_strlen($q); $i++) { |
|
| 201 | - $char = spip_substr($q, $i, 1); |
|
| 202 | - if ( |
|
| 203 | - !is_ascii($char) |
|
| 204 | - and $char_t = translitteration($char) |
|
| 205 | - and $char_t !== $char |
|
| 206 | - ) { |
|
| 207 | - // on utilise ..?.? car le char utf peut etre encode sur 1, 2 ou 3 bytes |
|
| 208 | - // mais c'est un pis aller cf #4354 |
|
| 209 | - $q_t = str_replace($char, $is_preg ? '..?.?' : '_', $q_t); |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - $q = $q_t; |
|
| 214 | - |
|
| 215 | - // fix : SQLite 3 est sensible aux accents, on jokerise les caracteres |
|
| 216 | - // les plus frequents qui peuvent etre accentues |
|
| 217 | - // (oui c'est tres dicustable...) |
|
| 218 | - if ( |
|
| 219 | - isset($GLOBALS['connexions'][$options['serveur'] ?: 0]['type']) |
|
| 220 | - and strncmp($GLOBALS['connexions'][$options['serveur'] ?: 0]['type'], 'sqlite', 6) == 0 |
|
| 221 | - ) { |
|
| 222 | - $q_t = strtr($q, 'aeuioc', $is_preg ? '......' : '______'); |
|
| 223 | - // si il reste au moins un char significatif... |
|
| 224 | - if (preg_match(",[^'%_.],", $q_t)) { |
|
| 225 | - $q = $q_t; |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - return $expression[$key] = [$methode, $q, $preg]; |
|
| 79 | + // ne calculer qu'une seule fois l'expression par hit |
|
| 80 | + // (meme si utilisee dans plusieurs boucles) |
|
| 81 | + static $expression = []; |
|
| 82 | + $key = serialize([$recherche, $options['preg_flags']]); |
|
| 83 | + if (isset($expression[$key])) { |
|
| 84 | + return $expression[$key]; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 88 | + if ($u and strpos($options['preg_flags'], (string) $u) === false) { |
|
| 89 | + $options['preg_flags'] .= $u; |
|
| 90 | + } |
|
| 91 | + include_spip('inc/charsets'); |
|
| 92 | + $recherche = trim($recherche); |
|
| 93 | + |
|
| 94 | + // retirer les + de +truc et les * de truc* |
|
| 95 | + $recherche = preg_replace(',(^|\s)\+(\w),Uims', '$1$2', $recherche); |
|
| 96 | + $recherche = preg_replace(',(\w)\*($|\s),Uims', '$1$2', $recherche); |
|
| 97 | + |
|
| 98 | + $is_preg = false; |
|
| 99 | + if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) { |
|
| 100 | + // c'est une preg |
|
| 101 | + $recherche_trans = translitteration($recherche); |
|
| 102 | + $preg = $recherche_trans . $options['preg_flags']; |
|
| 103 | + $is_preg = true; |
|
| 104 | + } else { |
|
| 105 | + // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP, |
|
| 106 | + // sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un', |
|
| 107 | + // 'une', 'des' ...) |
|
| 108 | + |
|
| 109 | + // attention : plusieurs mots entre guillemets sont a rechercher tels quels |
|
| 110 | + $recherche_trans = $recherche_mod = $recherche_org = $recherche; |
|
| 111 | + |
|
| 112 | + // les expressions entre " " sont un mot a chercher tel quel |
|
| 113 | + // -> on remplace les espaces par un \x1 et on enleve les guillemets |
|
| 114 | + if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 115 | + foreach ($matches as $match) { |
|
| 116 | + $word = preg_replace(',\s+,Uims', "\x1", $match); |
|
| 117 | + $word = trim($word, '"'); |
|
| 118 | + $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + if (preg_match(',\s+,' . $u, $recherche_mod)) { |
|
| 123 | + $is_preg = true; |
|
| 124 | + |
|
| 125 | + $recherche_inter = '|'; |
|
| 126 | + $recherche_mots = explode(' ', $recherche_mod); |
|
| 127 | + $min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4; |
|
| 128 | + $petits_mots = true; |
|
| 129 | + foreach ($recherche_mots as $mot) { |
|
| 130 | + if (strlen($mot) >= $min_long) { |
|
| 131 | + // echapper les caracteres de regexp qui sont eventuellement dans la recherche |
|
| 132 | + $recherche_inter .= preg_quote($mot) . ' '; |
|
| 133 | + $petits_mots = false; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $recherche_inter = str_replace("\x1", '\s', $recherche_inter); |
|
| 137 | + |
|
| 138 | + // mais on cherche quand même l'expression complète, même si elle |
|
| 139 | + // comporte des mots de moins de quatre lettres |
|
| 140 | + $recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|'); |
|
| 141 | + if (!$recherche or $petits_mots) { |
|
| 142 | + $recherche = preg_quote($recherche_org); |
|
| 143 | + } |
|
| 144 | + $recherche_trans = translitteration($recherche); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + $preg = '/' . str_replace('/', '\\/', $recherche_trans) . '/' . $options['preg_flags']; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite |
|
| 151 | + // ou si l'expression reguliere est invalide |
|
| 152 | + if ( |
|
| 153 | + !$is_preg |
|
| 154 | + or (@preg_match($preg, '') === false) |
|
| 155 | + ) { |
|
| 156 | + $methode = 'LIKE'; |
|
| 157 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 158 | + |
|
| 159 | + // echapper les % et _ |
|
| 160 | + $q = str_replace(['%', '_'], ['\%', '\_'], trim($recherche)); |
|
| 161 | + |
|
| 162 | + // eviter les parentheses et autres caractères qui interferent avec pcre par la suite (dans le preg_match_all) s'il y a des reponses |
|
| 163 | + $recherche = preg_quote($recherche, '/'); |
|
| 164 | + $recherche_trans = translitteration($recherche); |
|
| 165 | + $recherche_mod = $recherche_trans; |
|
| 166 | + |
|
| 167 | + // les expressions entre " " sont un mot a chercher tel quel |
|
| 168 | + // -> on remplace les espaces par un _ et on enleve les guillemets |
|
| 169 | + // corriger le like dans le $q |
|
| 170 | + if (preg_match(',["][^"]+["],Uims', $q, $matches)) { |
|
| 171 | + foreach ($matches as $match) { |
|
| 172 | + $word = preg_replace(',\s+,Uims', '_', $match); |
|
| 173 | + $word = trim($word, '"'); |
|
| 174 | + $q = str_replace($match, $word, $q); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + // corriger la regexp |
|
| 178 | + if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 179 | + foreach ($matches as $match) { |
|
| 180 | + $word = preg_replace(',\s+,Uims', '[\s]', $match); |
|
| 181 | + $word = trim($word, '"'); |
|
| 182 | + $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + $q = sql_quote( |
|
| 186 | + '%' |
|
| 187 | + . preg_replace(',\s+,' . $u, '%', $q) |
|
| 188 | + . '%' |
|
| 189 | + ); |
|
| 190 | + |
|
| 191 | + $preg = '/' . preg_replace(',\s+,' . $u, '.+', trim($recherche_mod)) . '/' . $options['preg_flags']; |
|
| 192 | + } else { |
|
| 193 | + $methode = 'REGEXP'; |
|
| 194 | + $q = sql_quote(trim($recherche, '/')); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + // tous les caracteres transliterables de $q sont remplaces par un joker |
|
| 198 | + // permet de matcher en SQL meme si on est sensible aux accents (SQLite) |
|
| 199 | + $q_t = $q; |
|
| 200 | + for ($i = 0; $i < spip_strlen($q); $i++) { |
|
| 201 | + $char = spip_substr($q, $i, 1); |
|
| 202 | + if ( |
|
| 203 | + !is_ascii($char) |
|
| 204 | + and $char_t = translitteration($char) |
|
| 205 | + and $char_t !== $char |
|
| 206 | + ) { |
|
| 207 | + // on utilise ..?.? car le char utf peut etre encode sur 1, 2 ou 3 bytes |
|
| 208 | + // mais c'est un pis aller cf #4354 |
|
| 209 | + $q_t = str_replace($char, $is_preg ? '..?.?' : '_', $q_t); |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + $q = $q_t; |
|
| 214 | + |
|
| 215 | + // fix : SQLite 3 est sensible aux accents, on jokerise les caracteres |
|
| 216 | + // les plus frequents qui peuvent etre accentues |
|
| 217 | + // (oui c'est tres dicustable...) |
|
| 218 | + if ( |
|
| 219 | + isset($GLOBALS['connexions'][$options['serveur'] ?: 0]['type']) |
|
| 220 | + and strncmp($GLOBALS['connexions'][$options['serveur'] ?: 0]['type'], 'sqlite', 6) == 0 |
|
| 221 | + ) { |
|
| 222 | + $q_t = strtr($q, 'aeuioc', $is_preg ? '......' : '______'); |
|
| 223 | + // si il reste au moins un char significatif... |
|
| 224 | + if (preg_match(",[^'%_.],", $q_t)) { |
|
| 225 | + $q = $q_t; |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + return $expression[$key] = [$methode, $q, $preg]; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | |
@@ -253,142 +253,142 @@ discard block |
||
| 253 | 253 | * @return array |
| 254 | 254 | */ |
| 255 | 255 | function recherche_en_base($recherche = '', $tables = null, $options = [], $serveur = '') { |
| 256 | - include_spip('base/abstract_sql'); |
|
| 257 | - |
|
| 258 | - if (!is_array($tables)) { |
|
| 259 | - $liste = liste_des_champs(); |
|
| 260 | - |
|
| 261 | - if ( |
|
| 262 | - is_string($tables) |
|
| 263 | - and $tables != '' |
|
| 264 | - ) { |
|
| 265 | - $toutes = []; |
|
| 266 | - foreach (explode(',', $tables) as $t) { |
|
| 267 | - $t = trim($t); |
|
| 268 | - if (isset($liste[$t])) { |
|
| 269 | - $toutes[$t] = $liste[$t]; |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - $tables = $toutes; |
|
| 273 | - unset($toutes); |
|
| 274 | - } else { |
|
| 275 | - $tables = $liste; |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - if (!strlen($recherche) or !count($tables)) { |
|
| 280 | - return []; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - include_spip('inc/autoriser'); |
|
| 284 | - |
|
| 285 | - // options par defaut |
|
| 286 | - $options = array_merge( |
|
| 287 | - [ |
|
| 288 | - 'preg_flags' => 'UimsS', |
|
| 289 | - 'toutvoir' => false, |
|
| 290 | - 'champs' => false, |
|
| 291 | - 'score' => false, |
|
| 292 | - 'matches' => false, |
|
| 293 | - 'jointures' => false, |
|
| 294 | - 'serveur' => $serveur |
|
| 295 | - ], |
|
| 296 | - $options |
|
| 297 | - ); |
|
| 298 | - |
|
| 299 | - $results = []; |
|
| 300 | - |
|
| 301 | - // Utiliser l'iterateur (DATA:recherche) |
|
| 302 | - // pour recuperer les couples (id_objet, score) |
|
| 303 | - // Le resultat est au format { |
|
| 304 | - // id1 = { 'score' => x, attrs => { } }, |
|
| 305 | - // id2 = { 'score' => x, attrs => { } }, |
|
| 306 | - // } |
|
| 307 | - |
|
| 308 | - include_spip('inc/recherche_to_array'); |
|
| 309 | - |
|
| 310 | - foreach ($tables as $table => $champs) { |
|
| 311 | - # lock via memoization, si dispo |
|
| 312 | - if (function_exists('cache_lock')) { |
|
| 313 | - cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - spip_timer('rech'); |
|
| 317 | - |
|
| 318 | - # TODO : ici plutot charger un iterateur via l'API iterateurs |
|
| 319 | - $to_array = charger_fonction('recherche_to_array', 'inc'); |
|
| 320 | - $results[$table] = $to_array( |
|
| 321 | - $recherche, |
|
| 322 | - array_merge($options, ['table' => $table, 'champs' => $champs]) |
|
| 323 | - ); |
|
| 324 | - ##var_dump($results[$table]); |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - spip_log( |
|
| 328 | - "recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'), |
|
| 329 | - 'recherche' |
|
| 330 | - ); |
|
| 331 | - |
|
| 332 | - if (isset($lock)) { |
|
| 333 | - cache_unlock($lock); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return $results; |
|
| 256 | + include_spip('base/abstract_sql'); |
|
| 257 | + |
|
| 258 | + if (!is_array($tables)) { |
|
| 259 | + $liste = liste_des_champs(); |
|
| 260 | + |
|
| 261 | + if ( |
|
| 262 | + is_string($tables) |
|
| 263 | + and $tables != '' |
|
| 264 | + ) { |
|
| 265 | + $toutes = []; |
|
| 266 | + foreach (explode(',', $tables) as $t) { |
|
| 267 | + $t = trim($t); |
|
| 268 | + if (isset($liste[$t])) { |
|
| 269 | + $toutes[$t] = $liste[$t]; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + $tables = $toutes; |
|
| 273 | + unset($toutes); |
|
| 274 | + } else { |
|
| 275 | + $tables = $liste; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + if (!strlen($recherche) or !count($tables)) { |
|
| 280 | + return []; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + include_spip('inc/autoriser'); |
|
| 284 | + |
|
| 285 | + // options par defaut |
|
| 286 | + $options = array_merge( |
|
| 287 | + [ |
|
| 288 | + 'preg_flags' => 'UimsS', |
|
| 289 | + 'toutvoir' => false, |
|
| 290 | + 'champs' => false, |
|
| 291 | + 'score' => false, |
|
| 292 | + 'matches' => false, |
|
| 293 | + 'jointures' => false, |
|
| 294 | + 'serveur' => $serveur |
|
| 295 | + ], |
|
| 296 | + $options |
|
| 297 | + ); |
|
| 298 | + |
|
| 299 | + $results = []; |
|
| 300 | + |
|
| 301 | + // Utiliser l'iterateur (DATA:recherche) |
|
| 302 | + // pour recuperer les couples (id_objet, score) |
|
| 303 | + // Le resultat est au format { |
|
| 304 | + // id1 = { 'score' => x, attrs => { } }, |
|
| 305 | + // id2 = { 'score' => x, attrs => { } }, |
|
| 306 | + // } |
|
| 307 | + |
|
| 308 | + include_spip('inc/recherche_to_array'); |
|
| 309 | + |
|
| 310 | + foreach ($tables as $table => $champs) { |
|
| 311 | + # lock via memoization, si dispo |
|
| 312 | + if (function_exists('cache_lock')) { |
|
| 313 | + cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + spip_timer('rech'); |
|
| 317 | + |
|
| 318 | + # TODO : ici plutot charger un iterateur via l'API iterateurs |
|
| 319 | + $to_array = charger_fonction('recherche_to_array', 'inc'); |
|
| 320 | + $results[$table] = $to_array( |
|
| 321 | + $recherche, |
|
| 322 | + array_merge($options, ['table' => $table, 'champs' => $champs]) |
|
| 323 | + ); |
|
| 324 | + ##var_dump($results[$table]); |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + spip_log( |
|
| 328 | + "recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'), |
|
| 329 | + 'recherche' |
|
| 330 | + ); |
|
| 331 | + |
|
| 332 | + if (isset($lock)) { |
|
| 333 | + cache_unlock($lock); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return $results; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
| 341 | 341 | // Effectue une recherche sur toutes les tables de la base de donnees |
| 342 | 342 | function remplace_en_base($recherche = '', $remplace = null, $tables = null, $options = []) { |
| 343 | - include_spip('inc/modifier'); |
|
| 344 | - |
|
| 345 | - // options par defaut |
|
| 346 | - $options = array_merge( |
|
| 347 | - [ |
|
| 348 | - 'preg_flags' => 'UimsS', |
|
| 349 | - 'toutmodifier' => false |
|
| 350 | - ], |
|
| 351 | - $options |
|
| 352 | - ); |
|
| 353 | - $options['champs'] = true; |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - if (!is_array($tables)) { |
|
| 357 | - $tables = liste_des_champs(); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - $results = recherche_en_base($recherche, $tables, $options); |
|
| 361 | - |
|
| 362 | - $preg = '/' . str_replace('/', '\\/', $recherche) . '/' . $options['preg_flags']; |
|
| 363 | - |
|
| 364 | - foreach ($results as $table => $r) { |
|
| 365 | - $_id_table = id_table_objet($table); |
|
| 366 | - foreach ($r as $id => $x) { |
|
| 367 | - if ( |
|
| 368 | - $options['toutmodifier'] |
|
| 369 | - or autoriser('modifier', $table, $id) |
|
| 370 | - ) { |
|
| 371 | - $modifs = []; |
|
| 372 | - foreach ($x['champs'] as $key => $val) { |
|
| 373 | - if ($key == $_id_table) { |
|
| 374 | - continue; |
|
| 375 | - } |
|
| 376 | - $repl = preg_replace($preg, $remplace, $val); |
|
| 377 | - if ($repl <> $val) { |
|
| 378 | - $modifs[$key] = $repl; |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - if ($modifs) { |
|
| 382 | - objet_modifier_champs( |
|
| 383 | - $table, |
|
| 384 | - $id, |
|
| 385 | - [ |
|
| 386 | - 'champs' => array_keys($modifs), |
|
| 387 | - ], |
|
| 388 | - $modifs |
|
| 389 | - ); |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - } |
|
| 343 | + include_spip('inc/modifier'); |
|
| 344 | + |
|
| 345 | + // options par defaut |
|
| 346 | + $options = array_merge( |
|
| 347 | + [ |
|
| 348 | + 'preg_flags' => 'UimsS', |
|
| 349 | + 'toutmodifier' => false |
|
| 350 | + ], |
|
| 351 | + $options |
|
| 352 | + ); |
|
| 353 | + $options['champs'] = true; |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + if (!is_array($tables)) { |
|
| 357 | + $tables = liste_des_champs(); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + $results = recherche_en_base($recherche, $tables, $options); |
|
| 361 | + |
|
| 362 | + $preg = '/' . str_replace('/', '\\/', $recherche) . '/' . $options['preg_flags']; |
|
| 363 | + |
|
| 364 | + foreach ($results as $table => $r) { |
|
| 365 | + $_id_table = id_table_objet($table); |
|
| 366 | + foreach ($r as $id => $x) { |
|
| 367 | + if ( |
|
| 368 | + $options['toutmodifier'] |
|
| 369 | + or autoriser('modifier', $table, $id) |
|
| 370 | + ) { |
|
| 371 | + $modifs = []; |
|
| 372 | + foreach ($x['champs'] as $key => $val) { |
|
| 373 | + if ($key == $_id_table) { |
|
| 374 | + continue; |
|
| 375 | + } |
|
| 376 | + $repl = preg_replace($preg, $remplace, $val); |
|
| 377 | + if ($repl <> $val) { |
|
| 378 | + $modifs[$key] = $repl; |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + if ($modifs) { |
|
| 382 | + objet_modifier_champs( |
|
| 383 | + $table, |
|
| 384 | + $id, |
|
| 385 | + [ |
|
| 386 | + 'champs' => array_keys($modifs), |
|
| 387 | + ], |
|
| 388 | + $modifs |
|
| 389 | + ); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | 394 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Pipelines |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -35,36 +35,36 @@ discard block |
||
| 35 | 35 | * @return string Contenu complété des scripts javascripts, dont jQuery |
| 36 | 36 | **/ |
| 37 | 37 | function f_jQuery_prive($texte) { |
| 38 | - $x = ''; |
|
| 39 | - $jquery_plugins = pipeline( |
|
| 40 | - 'jquery_plugins', |
|
| 41 | - [ |
|
| 42 | - 'prive/javascript/jquery.js', |
|
| 43 | - 'prive/javascript/jquery.form.js', |
|
| 44 | - 'prive/javascript/jquery.autosave.js', |
|
| 45 | - 'prive/javascript/jquery.placeholder-label.js', |
|
| 46 | - 'prive/javascript/ajaxCallback.js', |
|
| 47 | - 'prive/javascript/js.cookie.js', |
|
| 48 | - 'prive/javascript/spip_barre.js', |
|
| 49 | - ] |
|
| 50 | - ); |
|
| 51 | - foreach (array_unique($jquery_plugins) as $script) { |
|
| 52 | - if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 53 | - $script = timestamp($script); |
|
| 54 | - $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - // inserer avant le premier script externe ou a la fin |
|
| 58 | - if ( |
|
| 59 | - preg_match(',<script[^><]*src=,', $texte, $match) |
|
| 60 | - and $p = strpos($texte, (string) $match[0]) |
|
| 61 | - ) { |
|
| 62 | - $texte = substr_replace($texte, $x, $p, 0); |
|
| 63 | - } else { |
|
| 64 | - $texte .= $x; |
|
| 65 | - } |
|
| 38 | + $x = ''; |
|
| 39 | + $jquery_plugins = pipeline( |
|
| 40 | + 'jquery_plugins', |
|
| 41 | + [ |
|
| 42 | + 'prive/javascript/jquery.js', |
|
| 43 | + 'prive/javascript/jquery.form.js', |
|
| 44 | + 'prive/javascript/jquery.autosave.js', |
|
| 45 | + 'prive/javascript/jquery.placeholder-label.js', |
|
| 46 | + 'prive/javascript/ajaxCallback.js', |
|
| 47 | + 'prive/javascript/js.cookie.js', |
|
| 48 | + 'prive/javascript/spip_barre.js', |
|
| 49 | + ] |
|
| 50 | + ); |
|
| 51 | + foreach (array_unique($jquery_plugins) as $script) { |
|
| 52 | + if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 53 | + $script = timestamp($script); |
|
| 54 | + $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + // inserer avant le premier script externe ou a la fin |
|
| 58 | + if ( |
|
| 59 | + preg_match(',<script[^><]*src=,', $texte, $match) |
|
| 60 | + and $p = strpos($texte, (string) $match[0]) |
|
| 61 | + ) { |
|
| 62 | + $texte = substr_replace($texte, $x, $p, 0); |
|
| 63 | + } else { |
|
| 64 | + $texte .= $x; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return $texte; |
|
| 67 | + return $texte; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -77,42 +77,42 @@ discard block |
||
| 77 | 77 | * @return string |
| 78 | 78 | */ |
| 79 | 79 | function affichage_final_prive_title_auto($texte) { |
| 80 | - if ( |
|
| 81 | - strpos($texte, '<title>') === false |
|
| 82 | - and |
|
| 83 | - (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match) |
|
| 84 | - or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match)) |
|
| 85 | - and $match = textebrut(trim($match[1])) |
|
| 86 | - and ($p = strpos($texte, '<head>')) !== false |
|
| 87 | - ) { |
|
| 88 | - if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 89 | - $nom_site_spip = _T('info_mon_site_spip'); |
|
| 90 | - } |
|
| 80 | + if ( |
|
| 81 | + strpos($texte, '<title>') === false |
|
| 82 | + and |
|
| 83 | + (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match) |
|
| 84 | + or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match)) |
|
| 85 | + and $match = textebrut(trim($match[1])) |
|
| 86 | + and ($p = strpos($texte, '<head>')) !== false |
|
| 87 | + ) { |
|
| 88 | + if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 89 | + $nom_site_spip = _T('info_mon_site_spip'); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $titre = '<title>[' |
|
| 93 | - . $nom_site_spip |
|
| 94 | - . '] ' . $match |
|
| 95 | - . '</title>'; |
|
| 92 | + $titre = '<title>[' |
|
| 93 | + . $nom_site_spip |
|
| 94 | + . '] ' . $match |
|
| 95 | + . '</title>'; |
|
| 96 | 96 | |
| 97 | - $texte = substr_replace($texte, $titre, $p + 6, 0); |
|
| 98 | - } |
|
| 97 | + $texte = substr_replace($texte, $titre, $p + 6, 0); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - return $texte; |
|
| 100 | + return $texte; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | // Fonction standard pour le pipeline 'boite_infos' |
| 105 | 105 | function f_boite_infos($flux) { |
| 106 | - $args = $flux['args']; |
|
| 107 | - $type = $args['type']; |
|
| 108 | - unset($args['row']); |
|
| 109 | - if (!trouver_fond($type, 'prive/objets/infos/')) { |
|
| 110 | - $type = 'objet'; |
|
| 111 | - } |
|
| 112 | - $args['espace_prive'] = 1; |
|
| 113 | - $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args); |
|
| 106 | + $args = $flux['args']; |
|
| 107 | + $type = $args['type']; |
|
| 108 | + unset($args['row']); |
|
| 109 | + if (!trouver_fond($type, 'prive/objets/infos/')) { |
|
| 110 | + $type = 'objet'; |
|
| 111 | + } |
|
| 112 | + $args['espace_prive'] = 1; |
|
| 113 | + $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args); |
|
| 114 | 114 | |
| 115 | - return $flux; |
|
| 115 | + return $flux; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
@@ -131,97 +131,97 @@ discard block |
||
| 131 | 131 | * @return array Données du pipeline |
| 132 | 132 | */ |
| 133 | 133 | function f_afficher_blocs_ecrire($flux) { |
| 134 | - static $o = []; |
|
| 135 | - if (is_string($fond = $flux['args']['fond'])) { |
|
| 136 | - $exec = $flux['args']['contexte']['exec'] ?? _request('exec'); |
|
| 137 | - if (!isset($o[$exec])) { |
|
| 138 | - $o[$exec] = trouver_objet_exec($exec); |
|
| 139 | - } |
|
| 140 | - // cas particulier |
|
| 141 | - if ($exec == 'infos_perso') { |
|
| 142 | - $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur']; |
|
| 143 | - } |
|
| 144 | - $typepage = ($flux['args']['contexte']['type-page'] ?? $exec); |
|
| 145 | - if ($fond == "prive/squelettes/navigation/$typepage") { |
|
| 146 | - $flux['data']['texte'] = pipeline( |
|
| 147 | - 'affiche_gauche', |
|
| 148 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 149 | - ); |
|
| 150 | - } elseif ($fond == "prive/squelettes/extra/$typepage") { |
|
| 151 | - include_spip('inc/presentation_mini'); |
|
| 152 | - $flux['data']['texte'] = pipeline( |
|
| 153 | - 'affiche_droite', |
|
| 154 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 155 | - ) . liste_objets_bloques( |
|
| 156 | - $exec, |
|
| 157 | - $flux['args']['contexte'] |
|
| 158 | - ); |
|
| 159 | - } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) { |
|
| 160 | - // id non defini sur les formulaire de nouveaux objets |
|
| 161 | - $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0; |
|
| 162 | - $flux['data']['texte'] = pipeline( |
|
| 163 | - 'affiche_hierarchie', |
|
| 164 | - ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']] |
|
| 165 | - ); |
|
| 166 | - } elseif ($fond == "prive/squelettes/contenu/$typepage") { |
|
| 167 | - // Préparation du marqueur affiche_milieu |
|
| 168 | - // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div |
|
| 169 | - $est_page_objet = !empty($o[$exec]['type']); |
|
| 170 | - $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true); |
|
| 171 | - $encapsuler_milieu = ($est_page_objet and !$est_en_edition); |
|
| 172 | - $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur( |
|
| 173 | - $flux['data']['texte'], |
|
| 174 | - '<!--affiche_milieu-->', |
|
| 175 | - '<div id=["\']wysiwyg', |
|
| 176 | - $encapsuler_milieu ? '<div class="affiche_milieu">' : '', |
|
| 177 | - $encapsuler_milieu ? '</div>' : '' |
|
| 178 | - ); |
|
| 179 | - if ( |
|
| 180 | - $o[$exec] |
|
| 181 | - and $objet = $o[$exec]['type'] |
|
| 182 | - and $o[$exec]['edition'] == false |
|
| 183 | - and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 184 | - and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 185 | - ) { |
|
| 186 | - // inserer le formulaire de traduction |
|
| 187 | - $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond( |
|
| 188 | - 'prive/objets/editer/traductions', |
|
| 189 | - ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1] |
|
| 190 | - ) . '<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 191 | - $flux['data']['texte'] = pipeline('afficher_fiche_objet', [ |
|
| 192 | - 'args' => [ |
|
| 193 | - 'contexte' => $flux['args']['contexte'], |
|
| 194 | - 'type' => $objet, |
|
| 195 | - 'id' => $id |
|
| 196 | - ], |
|
| 197 | - 'data' => $flux['data']['texte'] |
|
| 198 | - ]); |
|
| 199 | - } |
|
| 200 | - $flux['data']['texte'] = pipeline( |
|
| 201 | - 'affiche_milieu', |
|
| 202 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 203 | - ); |
|
| 204 | - } elseif ($fond == 'prive/squelettes/inclure/pied') { |
|
| 205 | - $flux['data']['texte'] = pipeline( |
|
| 206 | - 'affiche_pied', |
|
| 207 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 208 | - ); |
|
| 209 | - } elseif ( |
|
| 210 | - strncmp($fond, 'prive/objets/contenu/', 21) == 0 |
|
| 211 | - and $objet = basename($fond) |
|
| 212 | - and $objet == substr($fond, 21) |
|
| 213 | - and isset($o[$objet]) |
|
| 214 | - and $o[$objet] |
|
| 215 | - ) { |
|
| 216 | - $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]); |
|
| 217 | - $flux['data']['texte'] = pipeline('afficher_contenu_objet', [ |
|
| 218 | - 'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']], |
|
| 219 | - 'data' => $flux['data']['texte'] |
|
| 220 | - ]); |
|
| 221 | - } |
|
| 222 | - } |
|
| 134 | + static $o = []; |
|
| 135 | + if (is_string($fond = $flux['args']['fond'])) { |
|
| 136 | + $exec = $flux['args']['contexte']['exec'] ?? _request('exec'); |
|
| 137 | + if (!isset($o[$exec])) { |
|
| 138 | + $o[$exec] = trouver_objet_exec($exec); |
|
| 139 | + } |
|
| 140 | + // cas particulier |
|
| 141 | + if ($exec == 'infos_perso') { |
|
| 142 | + $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur']; |
|
| 143 | + } |
|
| 144 | + $typepage = ($flux['args']['contexte']['type-page'] ?? $exec); |
|
| 145 | + if ($fond == "prive/squelettes/navigation/$typepage") { |
|
| 146 | + $flux['data']['texte'] = pipeline( |
|
| 147 | + 'affiche_gauche', |
|
| 148 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 149 | + ); |
|
| 150 | + } elseif ($fond == "prive/squelettes/extra/$typepage") { |
|
| 151 | + include_spip('inc/presentation_mini'); |
|
| 152 | + $flux['data']['texte'] = pipeline( |
|
| 153 | + 'affiche_droite', |
|
| 154 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 155 | + ) . liste_objets_bloques( |
|
| 156 | + $exec, |
|
| 157 | + $flux['args']['contexte'] |
|
| 158 | + ); |
|
| 159 | + } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) { |
|
| 160 | + // id non defini sur les formulaire de nouveaux objets |
|
| 161 | + $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0; |
|
| 162 | + $flux['data']['texte'] = pipeline( |
|
| 163 | + 'affiche_hierarchie', |
|
| 164 | + ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']] |
|
| 165 | + ); |
|
| 166 | + } elseif ($fond == "prive/squelettes/contenu/$typepage") { |
|
| 167 | + // Préparation du marqueur affiche_milieu |
|
| 168 | + // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div |
|
| 169 | + $est_page_objet = !empty($o[$exec]['type']); |
|
| 170 | + $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true); |
|
| 171 | + $encapsuler_milieu = ($est_page_objet and !$est_en_edition); |
|
| 172 | + $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur( |
|
| 173 | + $flux['data']['texte'], |
|
| 174 | + '<!--affiche_milieu-->', |
|
| 175 | + '<div id=["\']wysiwyg', |
|
| 176 | + $encapsuler_milieu ? '<div class="affiche_milieu">' : '', |
|
| 177 | + $encapsuler_milieu ? '</div>' : '' |
|
| 178 | + ); |
|
| 179 | + if ( |
|
| 180 | + $o[$exec] |
|
| 181 | + and $objet = $o[$exec]['type'] |
|
| 182 | + and $o[$exec]['edition'] == false |
|
| 183 | + and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 184 | + and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 185 | + ) { |
|
| 186 | + // inserer le formulaire de traduction |
|
| 187 | + $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond( |
|
| 188 | + 'prive/objets/editer/traductions', |
|
| 189 | + ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1] |
|
| 190 | + ) . '<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 191 | + $flux['data']['texte'] = pipeline('afficher_fiche_objet', [ |
|
| 192 | + 'args' => [ |
|
| 193 | + 'contexte' => $flux['args']['contexte'], |
|
| 194 | + 'type' => $objet, |
|
| 195 | + 'id' => $id |
|
| 196 | + ], |
|
| 197 | + 'data' => $flux['data']['texte'] |
|
| 198 | + ]); |
|
| 199 | + } |
|
| 200 | + $flux['data']['texte'] = pipeline( |
|
| 201 | + 'affiche_milieu', |
|
| 202 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 203 | + ); |
|
| 204 | + } elseif ($fond == 'prive/squelettes/inclure/pied') { |
|
| 205 | + $flux['data']['texte'] = pipeline( |
|
| 206 | + 'affiche_pied', |
|
| 207 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 208 | + ); |
|
| 209 | + } elseif ( |
|
| 210 | + strncmp($fond, 'prive/objets/contenu/', 21) == 0 |
|
| 211 | + and $objet = basename($fond) |
|
| 212 | + and $objet == substr($fond, 21) |
|
| 213 | + and isset($o[$objet]) |
|
| 214 | + and $o[$objet] |
|
| 215 | + ) { |
|
| 216 | + $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]); |
|
| 217 | + $flux['data']['texte'] = pipeline('afficher_contenu_objet', [ |
|
| 218 | + 'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']], |
|
| 219 | + 'data' => $flux['data']['texte'] |
|
| 220 | + ]); |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - return $flux; |
|
| 224 | + return $flux; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -249,36 +249,36 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | function afficher_blocs_ecrire_preparer_marqueur(?string $texte, string $marqueur, string $inserer_avant, string $ouvrir = '', string $fermer = ''): ?string { |
| 251 | 251 | |
| 252 | - if ($texte) { |
|
| 253 | - $encapsuler = (($ouvrir and $fermer) ? true : false); |
|
| 254 | - $marqueur_pos = strpos($texte, $marqueur); |
|
| 255 | - $full_marqueur = "$ouvrir$marqueur$fermer"; |
|
| 252 | + if ($texte) { |
|
| 253 | + $encapsuler = (($ouvrir and $fermer) ? true : false); |
|
| 254 | + $marqueur_pos = strpos($texte, $marqueur); |
|
| 255 | + $full_marqueur = "$ouvrir$marqueur$fermer"; |
|
| 256 | 256 | |
| 257 | - // Le marqueur est absent : on l'ajoute avant l'élément indiqué |
|
| 258 | - if ($marqueur_pos === false) { |
|
| 259 | - $texte = preg_replace( |
|
| 260 | - ",$inserer_avant,", |
|
| 261 | - "$full_marqueur\\0", |
|
| 262 | - $texte |
|
| 263 | - ); |
|
| 264 | - // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes. |
|
| 265 | - // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante. |
|
| 266 | - // Il ne faut donc aucun espace blanc en trop. |
|
| 267 | - } elseif ( |
|
| 268 | - $marqueur_pos !== false |
|
| 269 | - and $encapsuler |
|
| 270 | - and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir |
|
| 271 | - ) { |
|
| 272 | - $texte = substr_replace( |
|
| 273 | - $texte, |
|
| 274 | - $full_marqueur, |
|
| 275 | - $marqueur_pos, |
|
| 276 | - strlen($marqueur) |
|
| 277 | - ); |
|
| 278 | - } |
|
| 279 | - } |
|
| 257 | + // Le marqueur est absent : on l'ajoute avant l'élément indiqué |
|
| 258 | + if ($marqueur_pos === false) { |
|
| 259 | + $texte = preg_replace( |
|
| 260 | + ",$inserer_avant,", |
|
| 261 | + "$full_marqueur\\0", |
|
| 262 | + $texte |
|
| 263 | + ); |
|
| 264 | + // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes. |
|
| 265 | + // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante. |
|
| 266 | + // Il ne faut donc aucun espace blanc en trop. |
|
| 267 | + } elseif ( |
|
| 268 | + $marqueur_pos !== false |
|
| 269 | + and $encapsuler |
|
| 270 | + and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir |
|
| 271 | + ) { |
|
| 272 | + $texte = substr_replace( |
|
| 273 | + $texte, |
|
| 274 | + $full_marqueur, |
|
| 275 | + $marqueur_pos, |
|
| 276 | + strlen($marqueur) |
|
| 277 | + ); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - return $texte; |
|
| 281 | + return $texte; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -289,23 +289,23 @@ discard block |
||
| 289 | 289 | * @return string |
| 290 | 290 | */ |
| 291 | 291 | function f_queue_affiche_milieu($flux) { |
| 292 | - $args = $flux['args']; |
|
| 293 | - $res = ''; |
|
| 294 | - foreach ($args as $key => $arg) { |
|
| 295 | - if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) { |
|
| 296 | - $objet = preg_replace(',^id_,', '', $key); |
|
| 297 | - $res .= recuperer_fond( |
|
| 298 | - 'modeles/object_jobs_list', |
|
| 299 | - ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1], |
|
| 300 | - ['ajax' => true] |
|
| 301 | - ); |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - if ($res) { |
|
| 305 | - $flux['data'] = $res . $flux['data']; |
|
| 306 | - } |
|
| 292 | + $args = $flux['args']; |
|
| 293 | + $res = ''; |
|
| 294 | + foreach ($args as $key => $arg) { |
|
| 295 | + if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) { |
|
| 296 | + $objet = preg_replace(',^id_,', '', $key); |
|
| 297 | + $res .= recuperer_fond( |
|
| 298 | + 'modeles/object_jobs_list', |
|
| 299 | + ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1], |
|
| 300 | + ['ajax' => true] |
|
| 301 | + ); |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + if ($res) { |
|
| 305 | + $flux['data'] = $res . $flux['data']; |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - return $flux; |
|
| 308 | + return $flux; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -319,39 +319,39 @@ discard block |
||
| 319 | 319 | * @return array|bool |
| 320 | 320 | */ |
| 321 | 321 | function trouver_objet_exec(string $exec) { |
| 322 | - static $objet_exec = []; |
|
| 323 | - if (!$exec) { |
|
| 324 | - return false; |
|
| 325 | - } |
|
| 326 | - // cas particulier |
|
| 327 | - if ($exec === 'infos_perso') { |
|
| 328 | - $exec = 'auteur'; |
|
| 329 | - set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 330 | - } |
|
| 331 | - if (!isset($objet_exec[$exec])) { |
|
| 332 | - $objet_exec[$exec] = false; |
|
| 333 | - $infos = lister_tables_objets_sql(); |
|
| 334 | - foreach ($infos as $t => $info) { |
|
| 335 | - if ($exec === $info['url_edit'] and $info['editable']) { |
|
| 336 | - return $objet_exec[$exec] = [ |
|
| 337 | - 'edition' => $exec == $info['url_voir'] ? '' : true, |
|
| 338 | - 'table_objet_sql' => $t, |
|
| 339 | - 'table' => $info['table_objet'], |
|
| 340 | - 'type' => $info['type'], |
|
| 341 | - 'id_table_objet' => id_table_objet($info['type']) |
|
| 342 | - ]; |
|
| 343 | - } |
|
| 344 | - if ($exec === $info['url_voir']) { |
|
| 345 | - return $objet_exec[$exec] = [ |
|
| 346 | - 'edition' => false, |
|
| 347 | - 'table_objet_sql' => $t, |
|
| 348 | - 'table' => $info['table_objet'], |
|
| 349 | - 'type' => $info['type'], |
|
| 350 | - 'id_table_objet' => id_table_objet($info['type']) |
|
| 351 | - ]; |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - } |
|
| 322 | + static $objet_exec = []; |
|
| 323 | + if (!$exec) { |
|
| 324 | + return false; |
|
| 325 | + } |
|
| 326 | + // cas particulier |
|
| 327 | + if ($exec === 'infos_perso') { |
|
| 328 | + $exec = 'auteur'; |
|
| 329 | + set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 330 | + } |
|
| 331 | + if (!isset($objet_exec[$exec])) { |
|
| 332 | + $objet_exec[$exec] = false; |
|
| 333 | + $infos = lister_tables_objets_sql(); |
|
| 334 | + foreach ($infos as $t => $info) { |
|
| 335 | + if ($exec === $info['url_edit'] and $info['editable']) { |
|
| 336 | + return $objet_exec[$exec] = [ |
|
| 337 | + 'edition' => $exec == $info['url_voir'] ? '' : true, |
|
| 338 | + 'table_objet_sql' => $t, |
|
| 339 | + 'table' => $info['table_objet'], |
|
| 340 | + 'type' => $info['type'], |
|
| 341 | + 'id_table_objet' => id_table_objet($info['type']) |
|
| 342 | + ]; |
|
| 343 | + } |
|
| 344 | + if ($exec === $info['url_voir']) { |
|
| 345 | + return $objet_exec[$exec] = [ |
|
| 346 | + 'edition' => false, |
|
| 347 | + 'table_objet_sql' => $t, |
|
| 348 | + 'table' => $info['table_objet'], |
|
| 349 | + 'type' => $info['type'], |
|
| 350 | + 'id_table_objet' => id_table_objet($info['type']) |
|
| 351 | + ]; |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - return $objet_exec[$exec]; |
|
| 356 | + return $objet_exec[$exec]; |
|
| 357 | 357 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // |
@@ -21,54 +21,54 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | function produire_image_math($tex) { |
| 23 | 23 | |
| 24 | - switch ($GLOBALS['traiter_math']) { |
|
| 25 | - // Attention: mathml desactiv'e pour l'instant |
|
| 26 | - case 'mathml': |
|
| 27 | - $ext = '.xhtml'; |
|
| 28 | - $server = $GLOBALS['mathml_server']; |
|
| 29 | - break; |
|
| 30 | - case 'tex': |
|
| 31 | - $ext = '.png'; |
|
| 32 | - $server = $GLOBALS['tex_server']; |
|
| 33 | - break; |
|
| 34 | - default: |
|
| 35 | - return $tex; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 39 | - if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 40 | - @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 41 | - } |
|
| 42 | - $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - if (!@file_exists($fichier)) { |
|
| 46 | - // Aller chercher l'image sur le serveur |
|
| 47 | - if ($server) { |
|
| 48 | - spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 49 | - include_spip('inc/distant'); |
|
| 50 | - recuperer_url($url, ['file' => $fichier]); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - // Composer la reponse selon presence ou non de l'image |
|
| 56 | - $tex = entites_html($tex); |
|
| 57 | - if (@file_exists($fichier)) { |
|
| 58 | - // MathML |
|
| 59 | - if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 60 | - return implode('', file($fichier)); |
|
| 61 | - } // TeX |
|
| 62 | - else { |
|
| 63 | - [, , , $size] = @spip_getimagesize($fichier); |
|
| 64 | - $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 65 | - |
|
| 66 | - return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 67 | - } |
|
| 68 | - } else // pas de fichier |
|
| 69 | - { |
|
| 70 | - return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 71 | - } |
|
| 24 | + switch ($GLOBALS['traiter_math']) { |
|
| 25 | + // Attention: mathml desactiv'e pour l'instant |
|
| 26 | + case 'mathml': |
|
| 27 | + $ext = '.xhtml'; |
|
| 28 | + $server = $GLOBALS['mathml_server']; |
|
| 29 | + break; |
|
| 30 | + case 'tex': |
|
| 31 | + $ext = '.png'; |
|
| 32 | + $server = $GLOBALS['tex_server']; |
|
| 33 | + break; |
|
| 34 | + default: |
|
| 35 | + return $tex; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + // Regarder dans le repertoire local des images TeX et blocs MathML |
|
| 39 | + if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) { |
|
| 40 | + @mkdir($dir_tex, _SPIP_CHMOD); |
|
| 41 | + } |
|
| 42 | + $fichier = $dir_tex . md5(trim($tex)) . $ext; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + if (!@file_exists($fichier)) { |
|
| 46 | + // Aller chercher l'image sur le serveur |
|
| 47 | + if ($server) { |
|
| 48 | + spip_log($url = $server . '?' . rawurlencode($tex)); |
|
| 49 | + include_spip('inc/distant'); |
|
| 50 | + recuperer_url($url, ['file' => $fichier]); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + // Composer la reponse selon presence ou non de l'image |
|
| 56 | + $tex = entites_html($tex); |
|
| 57 | + if (@file_exists($fichier)) { |
|
| 58 | + // MathML |
|
| 59 | + if ($GLOBALS['traiter_math'] == 'mathml') { |
|
| 60 | + return implode('', file($fichier)); |
|
| 61 | + } // TeX |
|
| 62 | + else { |
|
| 63 | + [, , , $size] = @spip_getimagesize($fichier); |
|
| 64 | + $alt = "alt=\"$tex\" title=\"$tex\""; |
|
| 65 | + |
|
| 66 | + return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />"; |
|
| 67 | + } |
|
| 68 | + } else // pas de fichier |
|
| 69 | + { |
|
| 70 | + return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>"; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
@@ -103,52 +103,52 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | function traiter_math($letexte, $source = '', $defaire_amp = false) { |
| 105 | 105 | |
| 106 | - $texte_a_voir = $letexte; |
|
| 107 | - while (($debut = strpos($texte_a_voir, '<math>')) !== false) { |
|
| 108 | - if (!$fin = strpos($texte_a_voir, '</math>')) { |
|
| 109 | - $fin = strlen($texte_a_voir); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 113 | - $texte_milieu = substr( |
|
| 114 | - $texte_a_voir, |
|
| 115 | - $debut + strlen('<math>'), |
|
| 116 | - $fin - $debut - strlen('<math>') |
|
| 117 | - ); |
|
| 118 | - $texte_fin = substr( |
|
| 119 | - $texte_a_voir, |
|
| 120 | - $fin + strlen('</math>'), |
|
| 121 | - strlen($texte_a_voir) |
|
| 122 | - ); |
|
| 123 | - |
|
| 124 | - // Les doubles $$x^2$$ en mode 'div' |
|
| 125 | - while ((preg_match(',[$][$]([^$]+)[$][$],', $texte_milieu, $regs))) { |
|
| 126 | - $expression = $regs[1]; |
|
| 127 | - if ($defaire_amp) { |
|
| 128 | - $expression = str_replace('&', '&', $expression); |
|
| 129 | - } |
|
| 130 | - $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 131 | - $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 132 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 133 | - . code_echappement($echap, $source) |
|
| 134 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // Les simples $x^2$ en mode 'span' |
|
| 138 | - while ((preg_match(',[$]([^$]+)[$],', $texte_milieu, $regs))) { |
|
| 139 | - $expression = $regs[1]; |
|
| 140 | - if ($defaire_amp) { |
|
| 141 | - $expression = str_replace('&', '&', $expression); |
|
| 142 | - } |
|
| 143 | - $echap = produire_image_math($expression); |
|
| 144 | - $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 145 | - $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 146 | - . code_echappement($echap, $source) |
|
| 147 | - . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - return $texte_a_voir; |
|
| 106 | + $texte_a_voir = $letexte; |
|
| 107 | + while (($debut = strpos($texte_a_voir, '<math>')) !== false) { |
|
| 108 | + if (!$fin = strpos($texte_a_voir, '</math>')) { |
|
| 109 | + $fin = strlen($texte_a_voir); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $texte_debut = substr($texte_a_voir, 0, $debut); |
|
| 113 | + $texte_milieu = substr( |
|
| 114 | + $texte_a_voir, |
|
| 115 | + $debut + strlen('<math>'), |
|
| 116 | + $fin - $debut - strlen('<math>') |
|
| 117 | + ); |
|
| 118 | + $texte_fin = substr( |
|
| 119 | + $texte_a_voir, |
|
| 120 | + $fin + strlen('</math>'), |
|
| 121 | + strlen($texte_a_voir) |
|
| 122 | + ); |
|
| 123 | + |
|
| 124 | + // Les doubles $$x^2$$ en mode 'div' |
|
| 125 | + while ((preg_match(',[$][$]([^$]+)[$][$],', $texte_milieu, $regs))) { |
|
| 126 | + $expression = $regs[1]; |
|
| 127 | + if ($defaire_amp) { |
|
| 128 | + $expression = str_replace('&', '&', $expression); |
|
| 129 | + } |
|
| 130 | + $echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($expression) . "</p>\n"; |
|
| 131 | + $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 132 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 133 | + . code_echappement($echap, $source) |
|
| 134 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // Les simples $x^2$ en mode 'span' |
|
| 138 | + while ((preg_match(',[$]([^$]+)[$],', $texte_milieu, $regs))) { |
|
| 139 | + $expression = $regs[1]; |
|
| 140 | + if ($defaire_amp) { |
|
| 141 | + $expression = str_replace('&', '&', $expression); |
|
| 142 | + } |
|
| 143 | + $echap = produire_image_math($expression); |
|
| 144 | + $pos = strpos($texte_milieu, (string) $regs[0]); |
|
| 145 | + $texte_milieu = substr($texte_milieu, 0, $pos) |
|
| 146 | + . code_echappement($echap, $source) |
|
| 147 | + . substr($texte_milieu, $pos + strlen($regs[0])); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + $texte_a_voir = $texte_debut . $texte_milieu . $texte_fin; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return $texte_a_voir; |
|
| 154 | 154 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -26,70 +26,70 @@ discard block |
||
| 26 | 26 | * @return string Code HTML du cadre dépliable |
| 27 | 27 | **/ |
| 28 | 28 | function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') { |
| 29 | - $bouton = bouton_block_depliable($titre, $deplie, $ids); |
|
| 30 | - |
|
| 31 | - return |
|
| 32 | - debut_cadre($style_cadre, $icone, '', $bouton, '', '', false) |
|
| 33 | - . debut_block_depliable($deplie, $ids) |
|
| 34 | - . "<div class='cadre_padding'>\n" |
|
| 35 | - . $contenu |
|
| 36 | - . "</div>\n" |
|
| 37 | - . fin_block() |
|
| 38 | - . fin_cadre(); |
|
| 29 | + $bouton = bouton_block_depliable($titre, $deplie, $ids); |
|
| 30 | + |
|
| 31 | + return |
|
| 32 | + debut_cadre($style_cadre, $icone, '', $bouton, '', '', false) |
|
| 33 | + . debut_block_depliable($deplie, $ids) |
|
| 34 | + . "<div class='cadre_padding'>\n" |
|
| 35 | + . $contenu |
|
| 36 | + . "</div>\n" |
|
| 37 | + . fin_block() |
|
| 38 | + . fin_cadre(); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) { |
| 42 | - return "\n" |
|
| 43 | - . bouton_block_depliable($invite, $visible, $nom) |
|
| 44 | - . debut_block_depliable($visible, $nom) |
|
| 45 | - . $masque |
|
| 46 | - . fin_block(); |
|
| 42 | + return "\n" |
|
| 43 | + . bouton_block_depliable($invite, $visible, $nom) |
|
| 44 | + . debut_block_depliable($visible, $nom) |
|
| 45 | + . $masque |
|
| 46 | + . fin_block(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function debut_block_depliable($deplie, $id = '') { |
| 50 | - $class = ' blocdeplie'; |
|
| 51 | - // si on n'accepte pas js, ne pas fermer |
|
| 52 | - if (!$deplie) { |
|
| 53 | - $class = ' blocreplie'; |
|
| 54 | - } |
|
| 50 | + $class = ' blocdeplie'; |
|
| 51 | + // si on n'accepte pas js, ne pas fermer |
|
| 52 | + if (!$deplie) { |
|
| 53 | + $class = ' blocreplie'; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>"; |
|
| 56 | + return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>"; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | function fin_block() { |
| 60 | - return "<div class='nettoyeur'></div>\n</div>"; |
|
| 60 | + return "<div class='nettoyeur'></div>\n</div>"; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // $texte : texte du bouton |
| 64 | 64 | // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page |
| 65 | 65 | // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit) |
| 66 | 66 | function bouton_block_depliable($texte, $deplie, $ids = '') { |
| 67 | - $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 68 | - |
|
| 69 | - $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie'); |
|
| 70 | - if (strlen($ids)) { |
|
| 71 | - $cible = explode(',', $ids); |
|
| 72 | - $cible = '#' . implode(',#', $cible); |
|
| 73 | - } else { |
|
| 74 | - $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $b = (strpos($texte, '<h') === false ? 'h3' : 'div'); |
|
| 78 | - |
|
| 79 | - return "<$b " |
|
| 80 | - . ($bouton_id ? "id='$bouton_id' " : '') |
|
| 81 | - . "class='titrem$class'" |
|
| 82 | - . (($deplie === -1) |
|
| 83 | - ? '' |
|
| 84 | - : " onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 85 | - ) |
|
| 86 | - . '>' |
|
| 87 | - // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 88 | - . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 89 | - . "$texte</$b>" |
|
| 90 | - . http_script(($deplie === 'incertain') |
|
| 91 | - ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});" |
|
| 92 | - : ''); |
|
| 67 | + $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 68 | + |
|
| 69 | + $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie'); |
|
| 70 | + if (strlen($ids)) { |
|
| 71 | + $cible = explode(',', $ids); |
|
| 72 | + $cible = '#' . implode(',#', $cible); |
|
| 73 | + } else { |
|
| 74 | + $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $b = (strpos($texte, '<h') === false ? 'h3' : 'div'); |
|
| 78 | + |
|
| 79 | + return "<$b " |
|
| 80 | + . ($bouton_id ? "id='$bouton_id' " : '') |
|
| 81 | + . "class='titrem$class'" |
|
| 82 | + . (($deplie === -1) |
|
| 83 | + ? '' |
|
| 84 | + : " onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 85 | + ) |
|
| 86 | + . '>' |
|
| 87 | + // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 88 | + . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 89 | + . "$texte</$b>" |
|
| 90 | + . http_script(($deplie === 'incertain') |
|
| 91 | + ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});" |
|
| 92 | + : ''); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // |
@@ -97,66 +97,66 @@ discard block |
||
| 97 | 97 | // |
| 98 | 98 | function verif_butineur() { |
| 99 | 99 | |
| 100 | - preg_match(',^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,', $_SERVER['HTTP_USER_AGENT'], $match); |
|
| 101 | - $GLOBALS['browser_name'] = $match[1]; |
|
| 102 | - $GLOBALS['browser_version'] = $match[2]; |
|
| 103 | - $GLOBALS['browser_description'] = $match[3]; |
|
| 104 | - $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur |
|
| 105 | - $GLOBALS['browser_barre'] = ''; |
|
| 106 | - |
|
| 107 | - if (!preg_match(',opera,i', $GLOBALS['browser_description']) && preg_match(',opera,i', $GLOBALS['browser_name'])) { |
|
| 108 | - $GLOBALS['browser_name'] = 'Opera'; |
|
| 109 | - $GLOBALS['browser_version'] = $match[2]; |
|
| 110 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 111 | - } else { |
|
| 112 | - if (preg_match(',opera,i', $GLOBALS['browser_description'])) { |
|
| 113 | - preg_match(',Opera ([^\ ]*),i', $GLOBALS['browser_description'], $match); |
|
| 114 | - $GLOBALS['browser_name'] = 'Opera'; |
|
| 115 | - $GLOBALS['browser_version'] = $match[1]; |
|
| 116 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 117 | - } else { |
|
| 118 | - if (preg_match(',msie,i', $GLOBALS['browser_description'])) { |
|
| 119 | - preg_match(',MSIE ([^;]*),i', $GLOBALS['browser_description'], $match); |
|
| 120 | - $GLOBALS['browser_name'] = 'MSIE'; |
|
| 121 | - $GLOBALS['browser_version'] = $match[1]; |
|
| 122 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5); |
|
| 123 | - } else { |
|
| 124 | - if ( |
|
| 125 | - preg_match(',KHTML,i', $GLOBALS['browser_description']) && |
|
| 126 | - preg_match(',Safari/([^;]*),', $GLOBALS['browser_description'], $match) |
|
| 127 | - ) { |
|
| 128 | - $GLOBALS['browser_name'] = 'Safari'; |
|
| 129 | - $GLOBALS['browser_version'] = $match[1]; |
|
| 130 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0); |
|
| 131 | - } else { |
|
| 132 | - if (preg_match(',mozilla,i', $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) { |
|
| 133 | - // Numero de version pour Mozilla "authentique" |
|
| 134 | - if (preg_match(',rv:([0-9]+\.[0-9]+),', $GLOBALS['browser_description'], $match)) { |
|
| 135 | - $GLOBALS['browser_rev'] = doubleval($match[1]); |
|
| 136 | - } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) |
|
| 137 | - else { |
|
| 138 | - if ( |
|
| 139 | - strpos($GLOBALS['browser_description'], 'Gecko') and !strpos( |
|
| 140 | - $GLOBALS['browser_description'], |
|
| 141 | - 'KHTML' |
|
| 142 | - ) |
|
| 143 | - ) { |
|
| 144 | - $GLOBALS['browser_rev'] = 1.4; |
|
| 145 | - } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) |
|
| 146 | - else { |
|
| 147 | - $GLOBALS['browser_rev'] = 1.0; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if (!$GLOBALS['browser_name']) { |
|
| 158 | - $GLOBALS['browser_name'] = 'Mozilla'; |
|
| 159 | - } |
|
| 100 | + preg_match(',^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,', $_SERVER['HTTP_USER_AGENT'], $match); |
|
| 101 | + $GLOBALS['browser_name'] = $match[1]; |
|
| 102 | + $GLOBALS['browser_version'] = $match[2]; |
|
| 103 | + $GLOBALS['browser_description'] = $match[3]; |
|
| 104 | + $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur |
|
| 105 | + $GLOBALS['browser_barre'] = ''; |
|
| 106 | + |
|
| 107 | + if (!preg_match(',opera,i', $GLOBALS['browser_description']) && preg_match(',opera,i', $GLOBALS['browser_name'])) { |
|
| 108 | + $GLOBALS['browser_name'] = 'Opera'; |
|
| 109 | + $GLOBALS['browser_version'] = $match[2]; |
|
| 110 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 111 | + } else { |
|
| 112 | + if (preg_match(',opera,i', $GLOBALS['browser_description'])) { |
|
| 113 | + preg_match(',Opera ([^\ ]*),i', $GLOBALS['browser_description'], $match); |
|
| 114 | + $GLOBALS['browser_name'] = 'Opera'; |
|
| 115 | + $GLOBALS['browser_version'] = $match[1]; |
|
| 116 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 117 | + } else { |
|
| 118 | + if (preg_match(',msie,i', $GLOBALS['browser_description'])) { |
|
| 119 | + preg_match(',MSIE ([^;]*),i', $GLOBALS['browser_description'], $match); |
|
| 120 | + $GLOBALS['browser_name'] = 'MSIE'; |
|
| 121 | + $GLOBALS['browser_version'] = $match[1]; |
|
| 122 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5); |
|
| 123 | + } else { |
|
| 124 | + if ( |
|
| 125 | + preg_match(',KHTML,i', $GLOBALS['browser_description']) && |
|
| 126 | + preg_match(',Safari/([^;]*),', $GLOBALS['browser_description'], $match) |
|
| 127 | + ) { |
|
| 128 | + $GLOBALS['browser_name'] = 'Safari'; |
|
| 129 | + $GLOBALS['browser_version'] = $match[1]; |
|
| 130 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0); |
|
| 131 | + } else { |
|
| 132 | + if (preg_match(',mozilla,i', $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) { |
|
| 133 | + // Numero de version pour Mozilla "authentique" |
|
| 134 | + if (preg_match(',rv:([0-9]+\.[0-9]+),', $GLOBALS['browser_description'], $match)) { |
|
| 135 | + $GLOBALS['browser_rev'] = doubleval($match[1]); |
|
| 136 | + } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) |
|
| 137 | + else { |
|
| 138 | + if ( |
|
| 139 | + strpos($GLOBALS['browser_description'], 'Gecko') and !strpos( |
|
| 140 | + $GLOBALS['browser_description'], |
|
| 141 | + 'KHTML' |
|
| 142 | + ) |
|
| 143 | + ) { |
|
| 144 | + $GLOBALS['browser_rev'] = 1.4; |
|
| 145 | + } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) |
|
| 146 | + else { |
|
| 147 | + $GLOBALS['browser_rev'] = 1.0; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if (!$GLOBALS['browser_name']) { |
|
| 158 | + $GLOBALS['browser_name'] = 'Mozilla'; |
|
| 159 | + } |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | verif_butineur(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $class = ' blocreplie'; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>"; |
|
| 56 | + return '<div '.($id ? "id='$id' " : '')."class='bloc_depliable$class'>"; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | function fin_block() { |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page |
| 65 | 65 | // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit) |
| 66 | 66 | function bouton_block_depliable($texte, $deplie, $ids = '') { |
| 67 | - $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 67 | + $bouton_id = 'b'.substr(md5($texte.microtime()), 0, 8); |
|
| 68 | 68 | |
| 69 | 69 | $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie'); |
| 70 | 70 | if (strlen($ids)) { |
| 71 | 71 | $cible = explode(',', $ids); |
| 72 | - $cible = '#' . implode(',#', $cible); |
|
| 72 | + $cible = '#'.implode(',#', $cible); |
|
| 73 | 73 | } else { |
| 74 | 74 | $cible = "#$bouton_id + div.bloc_depliable"; |
| 75 | 75 | } |
@@ -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 | // Les parametres generaux du site sont dans une table SQL; |
@@ -27,51 +27,51 @@ discard block |
||
| 27 | 27 | define('_META_CACHE_TIME', 1 << 24); |
| 28 | 28 | |
| 29 | 29 | function inc_meta_dist($table = 'meta') { |
| 30 | - $new = null; |
|
| 31 | - // Lire les meta, en cache si present, valide et lisible |
|
| 32 | - // en cas d'install ne pas faire confiance au meta_cache eventuel |
|
| 33 | - $cache = cache_meta($table); |
|
| 30 | + $new = null; |
|
| 31 | + // Lire les meta, en cache si present, valide et lisible |
|
| 32 | + // en cas d'install ne pas faire confiance au meta_cache eventuel |
|
| 33 | + $cache = cache_meta($table); |
|
| 34 | 34 | |
| 35 | - if ( |
|
| 36 | - (!$exec = _request('exec') or !autoriser_sans_cookie($exec)) |
|
| 37 | - and $new = jeune_fichier($cache, _META_CACHE_TIME) |
|
| 38 | - and lire_fichier_securise($cache, $meta) |
|
| 39 | - and $meta = @unserialize($meta) |
|
| 40 | - ) { |
|
| 41 | - $GLOBALS[$table] = $meta; |
|
| 42 | - } |
|
| 35 | + if ( |
|
| 36 | + (!$exec = _request('exec') or !autoriser_sans_cookie($exec)) |
|
| 37 | + and $new = jeune_fichier($cache, _META_CACHE_TIME) |
|
| 38 | + and lire_fichier_securise($cache, $meta) |
|
| 39 | + and $meta = @unserialize($meta) |
|
| 40 | + ) { |
|
| 41 | + $GLOBALS[$table] = $meta; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - if ( |
|
| 45 | - isset($GLOBALS[$table]['touch']) |
|
| 46 | - and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME) |
|
| 47 | - ) { |
|
| 48 | - $GLOBALS[$table] = []; |
|
| 49 | - } |
|
| 50 | - // sinon lire en base |
|
| 51 | - if (!$GLOBALS[$table]) { |
|
| 52 | - $new = !lire_metas($table); |
|
| 53 | - } |
|
| 44 | + if ( |
|
| 45 | + isset($GLOBALS[$table]['touch']) |
|
| 46 | + and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME) |
|
| 47 | + ) { |
|
| 48 | + $GLOBALS[$table] = []; |
|
| 49 | + } |
|
| 50 | + // sinon lire en base |
|
| 51 | + if (!$GLOBALS[$table]) { |
|
| 52 | + $new = !lire_metas($table); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // renouveller l'alea general si trop vieux ou sur demande explicite |
|
| 56 | - if ( |
|
| 57 | - (test_espace_prive() || isset($_GET['renouvelle_alea'])) |
|
| 58 | - and $GLOBALS[$table] |
|
| 59 | - and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0)) |
|
| 60 | - ) { |
|
| 61 | - // si on n'a pas l'acces en ecriture sur le cache, |
|
| 62 | - // ne pas renouveller l'alea sinon le cache devient faux |
|
| 63 | - if (supprimer_fichier($cache)) { |
|
| 64 | - include_spip('inc/acces'); |
|
| 65 | - renouvelle_alea(); |
|
| 66 | - $new = false; |
|
| 67 | - } else { |
|
| 68 | - spip_log("impossible d'ecrire dans " . $cache); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - // et refaire le cache si on a du lire en base |
|
| 72 | - if (!$new) { |
|
| 73 | - touch_meta(false, $table); |
|
| 74 | - } |
|
| 55 | + // renouveller l'alea general si trop vieux ou sur demande explicite |
|
| 56 | + if ( |
|
| 57 | + (test_espace_prive() || isset($_GET['renouvelle_alea'])) |
|
| 58 | + and $GLOBALS[$table] |
|
| 59 | + and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0)) |
|
| 60 | + ) { |
|
| 61 | + // si on n'a pas l'acces en ecriture sur le cache, |
|
| 62 | + // ne pas renouveller l'alea sinon le cache devient faux |
|
| 63 | + if (supprimer_fichier($cache)) { |
|
| 64 | + include_spip('inc/acces'); |
|
| 65 | + renouvelle_alea(); |
|
| 66 | + $new = false; |
|
| 67 | + } else { |
|
| 68 | + spip_log("impossible d'ecrire dans " . $cache); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + // et refaire le cache si on a du lire en base |
|
| 72 | + if (!$new) { |
|
| 73 | + touch_meta(false, $table); |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // fonctions aussi appelees a l'install ==> spip_query en premiere requete |
@@ -79,39 +79,39 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | function lire_metas($table = 'meta') { |
| 81 | 81 | |
| 82 | - if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) { |
|
| 83 | - include_spip('base/abstract_sql'); |
|
| 84 | - $GLOBALS[$table] = []; |
|
| 85 | - while ($row = sql_fetch($result)) { |
|
| 86 | - $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 87 | - } |
|
| 88 | - sql_free($result); |
|
| 82 | + if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) { |
|
| 83 | + include_spip('base/abstract_sql'); |
|
| 84 | + $GLOBALS[$table] = []; |
|
| 85 | + while ($row = sql_fetch($result)) { |
|
| 86 | + $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 87 | + } |
|
| 88 | + sql_free($result); |
|
| 89 | 89 | |
| 90 | - if ( |
|
| 91 | - !isset($GLOBALS[$table]['charset']) |
|
| 92 | - or !$GLOBALS[$table]['charset'] |
|
| 93 | - or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install |
|
| 94 | - ) { |
|
| 95 | - ecrire_meta('charset', _DEFAULT_CHARSET, null, $table); |
|
| 96 | - } |
|
| 90 | + if ( |
|
| 91 | + !isset($GLOBALS[$table]['charset']) |
|
| 92 | + or !$GLOBALS[$table]['charset'] |
|
| 93 | + or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install |
|
| 94 | + ) { |
|
| 95 | + ecrire_meta('charset', _DEFAULT_CHARSET, null, $table); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - // noter cette table de configuration dans les meta de SPIP |
|
| 99 | - if ($table !== 'meta') { |
|
| 100 | - $liste = []; |
|
| 101 | - if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 102 | - $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 103 | - } |
|
| 104 | - if (!$liste) { |
|
| 105 | - $liste = []; |
|
| 106 | - } |
|
| 107 | - if (!in_array($table, $liste)) { |
|
| 108 | - $liste[] = $table; |
|
| 109 | - ecrire_meta('tables_config', serialize($liste)); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 98 | + // noter cette table de configuration dans les meta de SPIP |
|
| 99 | + if ($table !== 'meta') { |
|
| 100 | + $liste = []; |
|
| 101 | + if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 102 | + $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 103 | + } |
|
| 104 | + if (!$liste) { |
|
| 105 | + $liste = []; |
|
| 106 | + } |
|
| 107 | + if (!in_array($table, $liste)) { |
|
| 108 | + $liste[] = $table; |
|
| 109 | + ecrire_meta('tables_config', serialize($liste)); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return $GLOBALS[$table] ?? null; |
|
| 114 | + return $GLOBALS[$table] ?? null; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -125,22 +125,22 @@ discard block |
||
| 125 | 125 | * Table SQL d'enregistrement des meta. |
| 126 | 126 | **/ |
| 127 | 127 | function touch_meta($antidate = false, $table = 'meta') { |
| 128 | - $file = cache_meta($table); |
|
| 129 | - if (!$antidate or !@touch($file, $antidate)) { |
|
| 130 | - $r = $GLOBALS[$table] ?? []; |
|
| 131 | - if ($table == 'meta') { |
|
| 132 | - unset($r['alea_ephemere']); |
|
| 133 | - unset($r['alea_ephemere_ancien']); |
|
| 134 | - // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables |
|
| 135 | - // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique |
|
| 136 | - // meme si son squelette est en cache |
|
| 137 | - //unset($r['secret_du_site']); |
|
| 138 | - if ($antidate) { |
|
| 139 | - $r['touch'] = $antidate; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - ecrire_fichier_securise($file, serialize($r)); |
|
| 143 | - } |
|
| 128 | + $file = cache_meta($table); |
|
| 129 | + if (!$antidate or !@touch($file, $antidate)) { |
|
| 130 | + $r = $GLOBALS[$table] ?? []; |
|
| 131 | + if ($table == 'meta') { |
|
| 132 | + unset($r['alea_ephemere']); |
|
| 133 | + unset($r['alea_ephemere_ancien']); |
|
| 134 | + // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables |
|
| 135 | + // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique |
|
| 136 | + // meme si son squelette est en cache |
|
| 137 | + //unset($r['secret_du_site']); |
|
| 138 | + if ($antidate) { |
|
| 139 | + $r['touch'] = $antidate; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + ecrire_fichier_securise($file, serialize($r)); |
|
| 143 | + } |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -156,21 +156,21 @@ discard block |
||
| 156 | 156 | * Table SQL d'enregistrement de la meta. |
| 157 | 157 | **/ |
| 158 | 158 | function effacer_meta($nom, $table = 'meta') { |
| 159 | - // section critique sur le cache: |
|
| 160 | - // l'invalider avant et apres la MAJ de la BD |
|
| 161 | - // c'est un peu moins bien qu'un vrai verrou mais ca suffira |
|
| 162 | - // et utiliser une statique pour eviter des acces disques a repetition |
|
| 163 | - static $touch = []; |
|
| 164 | - $antidate = time() - (_META_CACHE_TIME << 4); |
|
| 165 | - if (!isset($touch[$table])) { |
|
| 166 | - touch_meta($antidate, $table); |
|
| 167 | - } |
|
| 168 | - sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | - unset($GLOBALS[$table][$nom]); |
|
| 170 | - if (!isset($touch[$table])) { |
|
| 171 | - touch_meta($antidate, $table); |
|
| 172 | - $touch[$table] = false; |
|
| 173 | - } |
|
| 159 | + // section critique sur le cache: |
|
| 160 | + // l'invalider avant et apres la MAJ de la BD |
|
| 161 | + // c'est un peu moins bien qu'un vrai verrou mais ca suffira |
|
| 162 | + // et utiliser une statique pour eviter des acces disques a repetition |
|
| 163 | + static $touch = []; |
|
| 164 | + $antidate = time() - (_META_CACHE_TIME << 4); |
|
| 165 | + if (!isset($touch[$table])) { |
|
| 166 | + touch_meta($antidate, $table); |
|
| 167 | + } |
|
| 168 | + sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | + unset($GLOBALS[$table][$nom]); |
|
| 170 | + if (!isset($touch[$table])) { |
|
| 171 | + touch_meta($antidate, $table); |
|
| 172 | + $touch[$table] = false; |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -191,53 +191,53 @@ discard block |
||
| 191 | 191 | **/ |
| 192 | 192 | function ecrire_meta($nom, $valeur, $importable = null, $table = 'meta') { |
| 193 | 193 | |
| 194 | - static $touch = []; |
|
| 195 | - if (!$nom) { |
|
| 196 | - return; |
|
| 197 | - } |
|
| 198 | - include_spip('base/abstract_sql'); |
|
| 199 | - $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | - // table pas encore installee, travailler en php seulement |
|
| 201 | - if (!$res) { |
|
| 202 | - $GLOBALS[$table][$nom] = $valeur; |
|
| 194 | + static $touch = []; |
|
| 195 | + if (!$nom) { |
|
| 196 | + return; |
|
| 197 | + } |
|
| 198 | + include_spip('base/abstract_sql'); |
|
| 199 | + $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | + // table pas encore installee, travailler en php seulement |
|
| 201 | + if (!$res) { |
|
| 202 | + $GLOBALS[$table][$nom] = $valeur; |
|
| 203 | 203 | |
| 204 | - return; |
|
| 205 | - } |
|
| 206 | - $row = sql_fetch($res); |
|
| 207 | - sql_free($res); |
|
| 204 | + return; |
|
| 205 | + } |
|
| 206 | + $row = sql_fetch($res); |
|
| 207 | + sql_free($res); |
|
| 208 | 208 | |
| 209 | - // ne pas invalider le cache si affectation a l'identique |
|
| 210 | - // (tant pis si impt aurait du changer) |
|
| 211 | - if ( |
|
| 212 | - $row and $valeur == $row['valeur'] |
|
| 213 | - and isset($GLOBALS[$table][$nom]) |
|
| 214 | - and $GLOBALS[$table][$nom] == $valeur |
|
| 215 | - ) { |
|
| 216 | - return; |
|
| 217 | - } |
|
| 209 | + // ne pas invalider le cache si affectation a l'identique |
|
| 210 | + // (tant pis si impt aurait du changer) |
|
| 211 | + if ( |
|
| 212 | + $row and $valeur == $row['valeur'] |
|
| 213 | + and isset($GLOBALS[$table][$nom]) |
|
| 214 | + and $GLOBALS[$table][$nom] == $valeur |
|
| 215 | + ) { |
|
| 216 | + return; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - $GLOBALS[$table][$nom] = $valeur; |
|
| 220 | - // cf effacer pour comprendre le double touch |
|
| 221 | - $antidate = time() - (_META_CACHE_TIME << 1); |
|
| 222 | - if (!isset($touch[$table])) { |
|
| 223 | - touch_meta($antidate, $table); |
|
| 224 | - } |
|
| 225 | - $r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')]; |
|
| 226 | - // Gaffe aux tables sans impt (vieilles versions de SPIP notamment) |
|
| 227 | - // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot |
|
| 228 | - // de lecture des descriptions des tables |
|
| 229 | - if ($importable and isset($row['impt'])) { |
|
| 230 | - $r['impt'] = sql_quote($importable, '', 'text'); |
|
| 231 | - } |
|
| 232 | - if ($row) { |
|
| 233 | - sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | - } else { |
|
| 235 | - sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | - } |
|
| 237 | - if (!isset($touch[$table])) { |
|
| 238 | - touch_meta($antidate, $table); |
|
| 239 | - $touch[$table] = false; |
|
| 240 | - } |
|
| 219 | + $GLOBALS[$table][$nom] = $valeur; |
|
| 220 | + // cf effacer pour comprendre le double touch |
|
| 221 | + $antidate = time() - (_META_CACHE_TIME << 1); |
|
| 222 | + if (!isset($touch[$table])) { |
|
| 223 | + touch_meta($antidate, $table); |
|
| 224 | + } |
|
| 225 | + $r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')]; |
|
| 226 | + // Gaffe aux tables sans impt (vieilles versions de SPIP notamment) |
|
| 227 | + // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot |
|
| 228 | + // de lecture des descriptions des tables |
|
| 229 | + if ($importable and isset($row['impt'])) { |
|
| 230 | + $r['impt'] = sql_quote($importable, '', 'text'); |
|
| 231 | + } |
|
| 232 | + if ($row) { |
|
| 233 | + sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | + } else { |
|
| 235 | + sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | + } |
|
| 237 | + if (!isset($touch[$table])) { |
|
| 238 | + touch_meta($antidate, $table); |
|
| 239 | + $touch[$table] = false; |
|
| 240 | + } |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * Nom du fichier cache |
| 250 | 250 | **/ |
| 251 | 251 | function cache_meta($table = 'meta') { |
| 252 | - return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 252 | + return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | * @param string $table |
| 259 | 259 | */ |
| 260 | 260 | function installer_table_meta($table) { |
| 261 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 262 | - if (!$trouver_table("spip_$table")) { |
|
| 263 | - include_spip('base/auxiliaires'); |
|
| 264 | - include_spip('base/create'); |
|
| 265 | - creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false); |
|
| 266 | - $trouver_table(''); |
|
| 267 | - } |
|
| 268 | - lire_metas($table); |
|
| 261 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 262 | + if (!$trouver_table("spip_$table")) { |
|
| 263 | + include_spip('base/auxiliaires'); |
|
| 264 | + include_spip('base/create'); |
|
| 265 | + creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false); |
|
| 266 | + $trouver_table(''); |
|
| 267 | + } |
|
| 268 | + lire_metas($table); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -277,47 +277,47 @@ discard block |
||
| 277 | 277 | * @param bool $force |
| 278 | 278 | */ |
| 279 | 279 | function supprimer_table_meta($table, $force = false) { |
| 280 | - if ($table !== 'meta') { |
|
| 281 | - // Vérifier le contenu restant de la table |
|
| 282 | - $nb_variables = sql_countsel("spip_$table"); |
|
| 280 | + if ($table !== 'meta') { |
|
| 281 | + // Vérifier le contenu restant de la table |
|
| 282 | + $nb_variables = sql_countsel("spip_$table"); |
|
| 283 | 283 | |
| 284 | - // Supprimer si : |
|
| 285 | - // - la table est vide |
|
| 286 | - // - ou limitée à la variable charset |
|
| 287 | - // - ou qu'on force la suppression |
|
| 288 | - if ( |
|
| 289 | - $force |
|
| 290 | - or !$nb_variables |
|
| 291 | - or ( |
|
| 292 | - ($nb_variables == 1) |
|
| 293 | - and isset($GLOBALS[$table]['charset']) |
|
| 294 | - ) |
|
| 295 | - ) { |
|
| 296 | - // Supprimer la table des globaleset de la base |
|
| 297 | - unset($GLOBALS[$table]); |
|
| 298 | - sql_drop_table("spip_$table"); |
|
| 299 | - // Supprimer le fichier cache |
|
| 300 | - include_spip('inc/flock'); |
|
| 301 | - $cache = cache_meta($table); |
|
| 302 | - supprimer_fichier($cache); |
|
| 284 | + // Supprimer si : |
|
| 285 | + // - la table est vide |
|
| 286 | + // - ou limitée à la variable charset |
|
| 287 | + // - ou qu'on force la suppression |
|
| 288 | + if ( |
|
| 289 | + $force |
|
| 290 | + or !$nb_variables |
|
| 291 | + or ( |
|
| 292 | + ($nb_variables == 1) |
|
| 293 | + and isset($GLOBALS[$table]['charset']) |
|
| 294 | + ) |
|
| 295 | + ) { |
|
| 296 | + // Supprimer la table des globaleset de la base |
|
| 297 | + unset($GLOBALS[$table]); |
|
| 298 | + sql_drop_table("spip_$table"); |
|
| 299 | + // Supprimer le fichier cache |
|
| 300 | + include_spip('inc/flock'); |
|
| 301 | + $cache = cache_meta($table); |
|
| 302 | + supprimer_fichier($cache); |
|
| 303 | 303 | |
| 304 | - // vider le cache des tables |
|
| 305 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 306 | - $trouver_table(''); |
|
| 304 | + // vider le cache des tables |
|
| 305 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 306 | + $trouver_table(''); |
|
| 307 | 307 | |
| 308 | - // Supprimer la table de la liste des tables de configuration autres que spip_meta |
|
| 309 | - if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 310 | - $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 311 | - $cle = array_search($table, $liste); |
|
| 312 | - if ($cle !== false) { |
|
| 313 | - unset($liste[$cle]); |
|
| 314 | - if ($liste) { |
|
| 315 | - ecrire_meta('tables_config', serialize($liste)); |
|
| 316 | - } else { |
|
| 317 | - effacer_meta('tables_config'); |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } |
|
| 308 | + // Supprimer la table de la liste des tables de configuration autres que spip_meta |
|
| 309 | + if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 310 | + $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 311 | + $cle = array_search($table, $liste); |
|
| 312 | + if ($cle !== false) { |
|
| 313 | + unset($liste[$cle]); |
|
| 314 | + if ($liste) { |
|
| 315 | + ecrire_meta('tables_config', serialize($liste)); |
|
| 316 | + } else { |
|
| 317 | + effacer_meta('tables_config'); |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | 323 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Les fonctions de toggg pour faire du JSON |
@@ -25,63 +25,63 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | function var2js($var) { |
| 28 | - $asso = false; |
|
| 29 | - switch (true) { |
|
| 30 | - case is_null($var): |
|
| 31 | - return 'null'; |
|
| 32 | - case is_string($var): |
|
| 33 | - return '"' . addcslashes($var, "\"\\\n\r/") . '"'; |
|
| 34 | - case is_bool($var): |
|
| 35 | - return $var ? 'true' : 'false'; |
|
| 36 | - case is_scalar($var): |
|
| 37 | - return (string)$var; |
|
| 38 | - case is_object($var):// blam |
|
| 39 | - $var = get_object_vars($var); |
|
| 40 | - $asso = true; |
|
| 41 | - // $var devient un array, on continue |
|
| 42 | - case is_array($var): |
|
| 43 | - $keys = array_keys($var); |
|
| 44 | - $ikey = count($keys); |
|
| 45 | - while (!$asso && $ikey--) { |
|
| 46 | - $asso = $ikey !== $keys[$ikey]; |
|
| 47 | - } |
|
| 48 | - $sep = ''; |
|
| 49 | - if ($asso) { |
|
| 50 | - $ret = '{'; |
|
| 51 | - foreach ($var as $key => $elt) { |
|
| 52 | - $ret .= $sep . '"' . $key . '":' . var2js($elt); |
|
| 53 | - $sep = ','; |
|
| 54 | - } |
|
| 28 | + $asso = false; |
|
| 29 | + switch (true) { |
|
| 30 | + case is_null($var): |
|
| 31 | + return 'null'; |
|
| 32 | + case is_string($var): |
|
| 33 | + return '"' . addcslashes($var, "\"\\\n\r/") . '"'; |
|
| 34 | + case is_bool($var): |
|
| 35 | + return $var ? 'true' : 'false'; |
|
| 36 | + case is_scalar($var): |
|
| 37 | + return (string)$var; |
|
| 38 | + case is_object($var):// blam |
|
| 39 | + $var = get_object_vars($var); |
|
| 40 | + $asso = true; |
|
| 41 | + // $var devient un array, on continue |
|
| 42 | + case is_array($var): |
|
| 43 | + $keys = array_keys($var); |
|
| 44 | + $ikey = count($keys); |
|
| 45 | + while (!$asso && $ikey--) { |
|
| 46 | + $asso = $ikey !== $keys[$ikey]; |
|
| 47 | + } |
|
| 48 | + $sep = ''; |
|
| 49 | + if ($asso) { |
|
| 50 | + $ret = '{'; |
|
| 51 | + foreach ($var as $key => $elt) { |
|
| 52 | + $ret .= $sep . '"' . $key . '":' . var2js($elt); |
|
| 53 | + $sep = ','; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - return $ret . '}'; |
|
| 57 | - } else { |
|
| 58 | - $ret = '['; |
|
| 59 | - foreach ($var as $elt) { |
|
| 60 | - $ret .= $sep . var2js($elt); |
|
| 61 | - $sep = ','; |
|
| 62 | - } |
|
| 56 | + return $ret . '}'; |
|
| 57 | + } else { |
|
| 58 | + $ret = '['; |
|
| 59 | + foreach ($var as $elt) { |
|
| 60 | + $ret .= $sep . var2js($elt); |
|
| 61 | + $sep = ','; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $ret . ']'; |
|
| 65 | - } |
|
| 66 | - } |
|
| 64 | + return $ret . ']'; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - return false; |
|
| 68 | + return false; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | if (!function_exists('json_encode')) { |
| 72 | - function json_encode($v) { |
|
| 73 | - return var2js($v); |
|
| 74 | - } |
|
| 72 | + function json_encode($v) { |
|
| 73 | + return var2js($v); |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | function json_export($var) { |
| 78 | - $var = json_encode($var, JSON_THROW_ON_ERROR); |
|
| 78 | + $var = json_encode($var, JSON_THROW_ON_ERROR); |
|
| 79 | 79 | |
| 80 | - // flag indiquant qu'on est en iframe et qu'il faut proteger nos |
|
| 81 | - // donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop |
|
| 82 | - if (defined('FILE_UPLOAD')) { |
|
| 83 | - return '<textarea>' . spip_htmlspecialchars($var) . '</textarea>'; |
|
| 84 | - } else { |
|
| 85 | - return $var; |
|
| 86 | - } |
|
| 80 | + // flag indiquant qu'on est en iframe et qu'il faut proteger nos |
|
| 81 | + // donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop |
|
| 82 | + if (defined('FILE_UPLOAD')) { |
|
| 83 | + return '<textarea>' . spip_htmlspecialchars($var) . '</textarea>'; |
|
| 84 | + } else { |
|
| 85 | + return $var; |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -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 | |
@@ -48,66 +48,66 @@ discard block |
||
| 48 | 48 | * Nom de la fonction, ou false. |
| 49 | 49 | */ |
| 50 | 50 | function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
| 51 | - static $echecs = []; |
|
| 52 | - |
|
| 53 | - if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | - $dossier .= '/'; |
|
| 55 | - } |
|
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | - |
|
| 58 | - if (function_exists($f)) { |
|
| 59 | - return $f; |
|
| 60 | - } |
|
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 62 | - return $g; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if (isset($echecs[$f])) { |
|
| 66 | - return $echecs[$f]; |
|
| 67 | - } |
|
| 68 | - // Sinon charger le fichier de declaration si plausible |
|
| 69 | - |
|
| 70 | - if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | - if ($continue) { |
|
| 72 | - return false; |
|
| 73 | - } //appel interne, on passe |
|
| 74 | - include_spip('inc/minipres'); |
|
| 75 | - echo minipres(); |
|
| 76 | - exit; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // passer en minuscules (cf les balises de formulaires) |
|
| 80 | - // et inclure le fichier |
|
| 81 | - if ( |
|
| 82 | - !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 83 | - // si le fichier truc/machin/nom.php n'existe pas, |
|
| 84 | - // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 85 | - and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 86 | - ) { |
|
| 87 | - include_spip(substr($dossier, 0, -1)); |
|
| 88 | - } |
|
| 89 | - if (function_exists($f)) { |
|
| 90 | - return $f; |
|
| 91 | - } |
|
| 92 | - if (function_exists($g)) { |
|
| 93 | - return $g; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if ($continue) { |
|
| 97 | - return $echecs[$f] = false; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // Echec : message d'erreur |
|
| 101 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 102 | - ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 103 | - |
|
| 104 | - include_spip('inc/minipres'); |
|
| 105 | - echo minipres( |
|
| 106 | - _T('forum_titre_erreur'), |
|
| 107 | - _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']), |
|
| 108 | - ['all_inline' => true,'status' => 404] |
|
| 109 | - ); |
|
| 110 | - exit; |
|
| 51 | + static $echecs = []; |
|
| 52 | + |
|
| 53 | + if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | + $dossier .= '/'; |
|
| 55 | + } |
|
| 56 | + $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | + |
|
| 58 | + if (function_exists($f)) { |
|
| 59 | + return $f; |
|
| 60 | + } |
|
| 61 | + if (function_exists($g = $f . '_dist')) { |
|
| 62 | + return $g; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if (isset($echecs[$f])) { |
|
| 66 | + return $echecs[$f]; |
|
| 67 | + } |
|
| 68 | + // Sinon charger le fichier de declaration si plausible |
|
| 69 | + |
|
| 70 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | + if ($continue) { |
|
| 72 | + return false; |
|
| 73 | + } //appel interne, on passe |
|
| 74 | + include_spip('inc/minipres'); |
|
| 75 | + echo minipres(); |
|
| 76 | + exit; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // passer en minuscules (cf les balises de formulaires) |
|
| 80 | + // et inclure le fichier |
|
| 81 | + if ( |
|
| 82 | + !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 83 | + // si le fichier truc/machin/nom.php n'existe pas, |
|
| 84 | + // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 85 | + and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 86 | + ) { |
|
| 87 | + include_spip(substr($dossier, 0, -1)); |
|
| 88 | + } |
|
| 89 | + if (function_exists($f)) { |
|
| 90 | + return $f; |
|
| 91 | + } |
|
| 92 | + if (function_exists($g)) { |
|
| 93 | + return $g; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if ($continue) { |
|
| 97 | + return $echecs[$f] = false; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // Echec : message d'erreur |
|
| 101 | + spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 102 | + ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 103 | + |
|
| 104 | + include_spip('inc/minipres'); |
|
| 105 | + echo minipres( |
|
| 106 | + _T('forum_titre_erreur'), |
|
| 107 | + _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']), |
|
| 108 | + ['all_inline' => true,'status' => 404] |
|
| 109 | + ); |
|
| 110 | + exit; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -117,17 +117,17 @@ discard block |
||
| 117 | 117 | * @return bool |
| 118 | 118 | */ |
| 119 | 119 | function include_once_check($file) { |
| 120 | - if (file_exists($file)) { |
|
| 121 | - include_once $file; |
|
| 120 | + if (file_exists($file)) { |
|
| 121 | + include_once $file; |
|
| 122 | 122 | |
| 123 | - return true; |
|
| 124 | - } |
|
| 125 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 126 | - $crash = ($crash ?: []); |
|
| 127 | - $crash[$file] = true; |
|
| 128 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 123 | + return true; |
|
| 124 | + } |
|
| 125 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 126 | + $crash = ($crash ?: []); |
|
| 127 | + $crash[$file] = true; |
|
| 128 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 129 | 129 | |
| 130 | - return false; |
|
| 130 | + return false; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * - string : chemin du fichier trouvé |
| 152 | 152 | **/ |
| 153 | 153 | function include_spip($f, $include = true) { |
| 154 | - return find_in_path($f . '.php', '', $include); |
|
| 154 | + return find_in_path($f . '.php', '', $include); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * - string : chemin du fichier trouvé |
| 172 | 172 | **/ |
| 173 | 173 | function require_spip($f) { |
| 174 | - return find_in_path($f . '.php', '', 'required'); |
|
| 174 | + return find_in_path($f . '.php', '', 'required'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -180,27 +180,27 @@ discard block |
||
| 180 | 180 | * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis |
| 181 | 181 | */ |
| 182 | 182 | function include_fichiers_fonctions() { |
| 183 | - static $done = false; |
|
| 184 | - if (!$done) { |
|
| 185 | - include_spip('inc/lang'); |
|
| 186 | - |
|
| 187 | - // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 188 | - // donc il faut l'inclure "en globals" |
|
| 189 | - if ($f = find_in_path('mes_fonctions.php')) { |
|
| 190 | - global $dossier_squelettes; |
|
| 191 | - include_once(_ROOT_CWD . $f); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 195 | - // chargement optimise precompile |
|
| 196 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 197 | - } |
|
| 198 | - if (test_espace_prive()) { |
|
| 199 | - include_spip('inc/filtres_ecrire'); |
|
| 200 | - } |
|
| 201 | - include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 202 | - $done = true; |
|
| 203 | - } |
|
| 183 | + static $done = false; |
|
| 184 | + if (!$done) { |
|
| 185 | + include_spip('inc/lang'); |
|
| 186 | + |
|
| 187 | + // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 188 | + // donc il faut l'inclure "en globals" |
|
| 189 | + if ($f = find_in_path('mes_fonctions.php')) { |
|
| 190 | + global $dossier_squelettes; |
|
| 191 | + include_once(_ROOT_CWD . $f); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 195 | + // chargement optimise precompile |
|
| 196 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 197 | + } |
|
| 198 | + if (test_espace_prive()) { |
|
| 199 | + include_spip('inc/filtres_ecrire'); |
|
| 200 | + } |
|
| 201 | + include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 202 | + $done = true; |
|
| 203 | + } |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -226,23 +226,23 @@ discard block |
||
| 226 | 226 | * Les paramètres du pipeline modifiés |
| 227 | 227 | **/ |
| 228 | 228 | function minipipe($fonc, &$val) { |
| 229 | - // fonction |
|
| 230 | - if (function_exists($fonc)) { |
|
| 231 | - $val = call_user_func($fonc, $val); |
|
| 232 | - } // Class::Methode |
|
| 233 | - else { |
|
| 234 | - if ( |
|
| 235 | - preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 236 | - and $methode = [$regs[1], $regs[2]] |
|
| 237 | - and is_callable($methode) |
|
| 238 | - ) { |
|
| 239 | - $val = call_user_func($methode, $val); |
|
| 240 | - } else { |
|
| 241 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - return $val; |
|
| 229 | + // fonction |
|
| 230 | + if (function_exists($fonc)) { |
|
| 231 | + $val = call_user_func($fonc, $val); |
|
| 232 | + } // Class::Methode |
|
| 233 | + else { |
|
| 234 | + if ( |
|
| 235 | + preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 236 | + and $methode = [$regs[1], $regs[2]] |
|
| 237 | + and is_callable($methode) |
|
| 238 | + ) { |
|
| 239 | + $val = call_user_func($methode, $val); |
|
| 240 | + } else { |
|
| 241 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + return $val; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -273,46 +273,46 @@ discard block |
||
| 273 | 273 | * Résultat |
| 274 | 274 | */ |
| 275 | 275 | function pipeline($action, $val = null) { |
| 276 | - static $charger; |
|
| 277 | - |
|
| 278 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 279 | - if (!$charger) { |
|
| 280 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 281 | - include_spip('inc/plugin'); |
|
| 282 | - // generer les fichiers php precompiles |
|
| 283 | - // de chargement des plugins et des pipelines |
|
| 284 | - actualise_plugins_actifs(); |
|
| 285 | - if (!($ok = @is_readable($charger))) { |
|
| 286 | - spip_log("fichier $charger pas cree"); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - if ($ok) { |
|
| 291 | - include_once $charger; |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - // appliquer notre fonction si elle existe |
|
| 296 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 297 | - if (function_exists($fonc)) { |
|
| 298 | - $val = $fonc($val); |
|
| 299 | - } // plantage ? |
|
| 300 | - else { |
|
| 301 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - // si le flux est une table avec 2 cle args&data |
|
| 305 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 306 | - // array_key_exists pour php 4.1.0 |
|
| 307 | - if ( |
|
| 308 | - is_array($val) |
|
| 309 | - and count($val) == 2 |
|
| 310 | - and (array_key_exists('data', $val)) |
|
| 311 | - ) { |
|
| 312 | - $val = $val['data']; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - return $val; |
|
| 276 | + static $charger; |
|
| 277 | + |
|
| 278 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 279 | + if (!$charger) { |
|
| 280 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 281 | + include_spip('inc/plugin'); |
|
| 282 | + // generer les fichiers php precompiles |
|
| 283 | + // de chargement des plugins et des pipelines |
|
| 284 | + actualise_plugins_actifs(); |
|
| 285 | + if (!($ok = @is_readable($charger))) { |
|
| 286 | + spip_log("fichier $charger pas cree"); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + if ($ok) { |
|
| 291 | + include_once $charger; |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + // appliquer notre fonction si elle existe |
|
| 296 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 297 | + if (function_exists($fonc)) { |
|
| 298 | + $val = $fonc($val); |
|
| 299 | + } // plantage ? |
|
| 300 | + else { |
|
| 301 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + // si le flux est une table avec 2 cle args&data |
|
| 305 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 306 | + // array_key_exists pour php 4.1.0 |
|
| 307 | + if ( |
|
| 308 | + is_array($val) |
|
| 309 | + and count($val) == 2 |
|
| 310 | + and (array_key_exists('data', $val)) |
|
| 311 | + ) { |
|
| 312 | + $val = $val['data']; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + return $val; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -356,38 +356,38 @@ discard block |
||
| 356 | 356 | * paramètre est planté pour cause de compatibilité ascendante. |
| 357 | 357 | */ |
| 358 | 358 | function spip_log($message = null, $name = null) { |
| 359 | - static $pre = []; |
|
| 360 | - static $log; |
|
| 361 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 362 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 363 | - $logname = null; |
|
| 364 | - } |
|
| 365 | - if (!isset($regs[2])) { |
|
| 366 | - $niveau = _LOG_INFO; |
|
| 367 | - } |
|
| 368 | - else { |
|
| 369 | - $niveau = intval($regs[2]); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 373 | - if (!$pre) { |
|
| 374 | - $pre = [ |
|
| 375 | - _LOG_HS => 'HS:', |
|
| 376 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 377 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 378 | - _LOG_ERREUR => 'ERREUR:', |
|
| 379 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 380 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 381 | - _LOG_INFO => 'info:', |
|
| 382 | - _LOG_DEBUG => 'debug:' |
|
| 383 | - ]; |
|
| 384 | - $log = charger_fonction('log', 'inc'); |
|
| 385 | - } |
|
| 386 | - if (!is_string($message)) { |
|
| 387 | - $message = print_r($message, true); |
|
| 388 | - } |
|
| 389 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 390 | - } |
|
| 359 | + static $pre = []; |
|
| 360 | + static $log; |
|
| 361 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 362 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 363 | + $logname = null; |
|
| 364 | + } |
|
| 365 | + if (!isset($regs[2])) { |
|
| 366 | + $niveau = _LOG_INFO; |
|
| 367 | + } |
|
| 368 | + else { |
|
| 369 | + $niveau = intval($regs[2]); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 373 | + if (!$pre) { |
|
| 374 | + $pre = [ |
|
| 375 | + _LOG_HS => 'HS:', |
|
| 376 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 377 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 378 | + _LOG_ERREUR => 'ERREUR:', |
|
| 379 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 380 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 381 | + _LOG_INFO => 'info:', |
|
| 382 | + _LOG_DEBUG => 'debug:' |
|
| 383 | + ]; |
|
| 384 | + $log = charger_fonction('log', 'inc'); |
|
| 385 | + } |
|
| 386 | + if (!is_string($message)) { |
|
| 387 | + $message = print_r($message, true); |
|
| 388 | + } |
|
| 389 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 390 | + } |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
@@ -398,8 +398,8 @@ discard block |
||
| 398 | 398 | * @param array $opt Tableau d'options |
| 399 | 399 | **/ |
| 400 | 400 | function journal($phrase, $opt = []) { |
| 401 | - $journal = charger_fonction('journal', 'inc'); |
|
| 402 | - $journal($phrase, $opt); |
|
| 401 | + $journal = charger_fonction('journal', 'inc'); |
|
| 402 | + $journal($phrase, $opt); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | |
@@ -418,37 +418,37 @@ discard block |
||
| 418 | 418 | **/ |
| 419 | 419 | function _request($var, $c = false) { |
| 420 | 420 | |
| 421 | - if (is_array($c)) { |
|
| 422 | - return $c[$var] ?? null; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - if (isset($_GET[$var])) { |
|
| 426 | - $a = $_GET[$var]; |
|
| 427 | - } elseif (isset($_POST[$var])) { |
|
| 428 | - $a = $_POST[$var]; |
|
| 429 | - } else { |
|
| 430 | - return null; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - // Si on est en ajax et en POST tout a ete encode |
|
| 434 | - // via encodeURIComponent, il faut donc repasser |
|
| 435 | - // dans le charset local... |
|
| 436 | - if ( |
|
| 437 | - defined('_AJAX') |
|
| 438 | - and _AJAX |
|
| 439 | - and isset($GLOBALS['meta']['charset']) |
|
| 440 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 441 | - and is_string($a) |
|
| 442 | - // check rapide mais pas fiable |
|
| 443 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 444 | - // check fiable |
|
| 445 | - and include_spip('inc/charsets') |
|
| 446 | - and is_utf8($a) |
|
| 447 | - ) { |
|
| 448 | - return importer_charset($a, 'utf-8'); |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - return $a; |
|
| 421 | + if (is_array($c)) { |
|
| 422 | + return $c[$var] ?? null; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + if (isset($_GET[$var])) { |
|
| 426 | + $a = $_GET[$var]; |
|
| 427 | + } elseif (isset($_POST[$var])) { |
|
| 428 | + $a = $_POST[$var]; |
|
| 429 | + } else { |
|
| 430 | + return null; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + // Si on est en ajax et en POST tout a ete encode |
|
| 434 | + // via encodeURIComponent, il faut donc repasser |
|
| 435 | + // dans le charset local... |
|
| 436 | + if ( |
|
| 437 | + defined('_AJAX') |
|
| 438 | + and _AJAX |
|
| 439 | + and isset($GLOBALS['meta']['charset']) |
|
| 440 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 441 | + and is_string($a) |
|
| 442 | + // check rapide mais pas fiable |
|
| 443 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 444 | + // check fiable |
|
| 445 | + and include_spip('inc/charsets') |
|
| 446 | + and is_utf8($a) |
|
| 447 | + ) { |
|
| 448 | + return importer_charset($a, 'utf-8'); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + return $a; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | |
@@ -466,22 +466,22 @@ discard block |
||
| 466 | 466 | * - false sinon |
| 467 | 467 | **/ |
| 468 | 468 | function set_request($var, $val = null, $c = false) { |
| 469 | - if (is_array($c)) { |
|
| 470 | - unset($c[$var]); |
|
| 471 | - if ($val !== null) { |
|
| 472 | - $c[$var] = $val; |
|
| 473 | - } |
|
| 469 | + if (is_array($c)) { |
|
| 470 | + unset($c[$var]); |
|
| 471 | + if ($val !== null) { |
|
| 472 | + $c[$var] = $val; |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - return $c; |
|
| 476 | - } |
|
| 475 | + return $c; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | - unset($_GET[$var]); |
|
| 479 | - unset($_POST[$var]); |
|
| 480 | - if ($val !== null) { |
|
| 481 | - $_GET[$var] = $val; |
|
| 482 | - } |
|
| 478 | + unset($_GET[$var]); |
|
| 479 | + unset($_POST[$var]); |
|
| 480 | + if ($val !== null) { |
|
| 481 | + $_GET[$var] = $val; |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - return false; # n'affecte pas $c |
|
| 484 | + return false; # n'affecte pas $c |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -501,25 +501,25 @@ discard block |
||
| 501 | 501 | * @return array|mixed|string |
| 502 | 502 | */ |
| 503 | 503 | function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') { |
| 504 | - if (is_array($value)) { |
|
| 505 | - if ($key == '*') { |
|
| 506 | - $key = array_keys($value); |
|
| 507 | - } |
|
| 508 | - if (!is_array($key)) { |
|
| 509 | - $key = [$key]; |
|
| 510 | - } |
|
| 511 | - foreach ($key as $k) { |
|
| 512 | - if (!empty($value[$k])) { |
|
| 513 | - $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - return $value; |
|
| 517 | - } |
|
| 518 | - // si la valeur vient des GET ou POST on la sanitize |
|
| 519 | - if (!empty($value) and $value == _request($key)) { |
|
| 520 | - $value = $sanitize_function($value); |
|
| 521 | - } |
|
| 522 | - return $value; |
|
| 504 | + if (is_array($value)) { |
|
| 505 | + if ($key == '*') { |
|
| 506 | + $key = array_keys($value); |
|
| 507 | + } |
|
| 508 | + if (!is_array($key)) { |
|
| 509 | + $key = [$key]; |
|
| 510 | + } |
|
| 511 | + foreach ($key as $k) { |
|
| 512 | + if (!empty($value[$k])) { |
|
| 513 | + $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + return $value; |
|
| 517 | + } |
|
| 518 | + // si la valeur vient des GET ou POST on la sanitize |
|
| 519 | + if (!empty($value) and $value == _request($key)) { |
|
| 520 | + $value = $sanitize_function($value); |
|
| 521 | + } |
|
| 522 | + return $value; |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
@@ -527,23 +527,22 @@ discard block |
||
| 527 | 527 | * |
| 528 | 528 | * On est sur le web, on exclut certains protocoles, |
| 529 | 529 | * notamment 'file://', 'php://' et d'autres… |
| 530 | - |
|
| 531 | 530 | * @param string $url |
| 532 | 531 | * @return bool |
| 533 | 532 | */ |
| 534 | 533 | function tester_url_absolue($url) { |
| 535 | - $url = trim($url); |
|
| 536 | - if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 537 | - if ( |
|
| 538 | - isset($m[1]) |
|
| 539 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 540 | - and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 541 | - ) { |
|
| 542 | - return false; |
|
| 543 | - } |
|
| 544 | - return true; |
|
| 545 | - } |
|
| 546 | - return false; |
|
| 534 | + $url = trim($url); |
|
| 535 | + if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 536 | + if ( |
|
| 537 | + isset($m[1]) |
|
| 538 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 539 | + and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 540 | + ) { |
|
| 541 | + return false; |
|
| 542 | + } |
|
| 543 | + return true; |
|
| 544 | + } |
|
| 545 | + return false; |
|
| 547 | 546 | } |
| 548 | 547 | |
| 549 | 548 | /** |
@@ -565,95 +564,95 @@ discard block |
||
| 565 | 564 | * @return string URL |
| 566 | 565 | */ |
| 567 | 566 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 568 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 569 | - if (strpos($c, '|') !== false and is_null($v)) { |
|
| 570 | - return null; |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - // lever l'#ancre |
|
| 574 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 575 | - $url = $r[1]; |
|
| 576 | - $ancre = $r[2]; |
|
| 577 | - } else { |
|
| 578 | - $ancre = ''; |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - // eclater |
|
| 582 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 583 | - |
|
| 584 | - // recuperer la base |
|
| 585 | - $a = array_shift($url); |
|
| 586 | - if (!$a) { |
|
| 587 | - $a = './'; |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 591 | - $ajouts = array_flip(explode('|', $c)); |
|
| 592 | - $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 593 | - $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 594 | - $v_read = null; |
|
| 595 | - // lire les variables et agir |
|
| 596 | - foreach ($url as $n => $val) { |
|
| 597 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 598 | - $r = array_pad($r, 3, null); |
|
| 599 | - if ($v === null) { |
|
| 600 | - // c'est un tableau, on memorise les valeurs |
|
| 601 | - if (substr($r[1], -2) == '[]') { |
|
| 602 | - if (!$v_read) { |
|
| 603 | - $v_read = []; |
|
| 604 | - } |
|
| 605 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 606 | - } // c'est un scalaire, on retourne direct |
|
| 607 | - else { |
|
| 608 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 609 | - } |
|
| 610 | - } // suppression |
|
| 611 | - elseif (!$testv) { |
|
| 612 | - unset($url[$n]); |
|
| 613 | - } |
|
| 614 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 615 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 616 | - elseif (substr($r[1], -2) != '[]') { |
|
| 617 | - $url[$n] = $r[1] . '=' . $u; |
|
| 618 | - unset($ajouts[$r[1]]); |
|
| 619 | - } |
|
| 620 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 621 | - // départ, on remplira à l'étape suivante |
|
| 622 | - else { |
|
| 623 | - unset($url[$n]); |
|
| 624 | - } |
|
| 625 | - } |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - // traiter les parametres pas encore trouves |
|
| 629 | - if ( |
|
| 630 | - $v === null |
|
| 631 | - and $args = func_get_args() |
|
| 632 | - and count($args) == 2 |
|
| 633 | - ) { |
|
| 634 | - return $v_read; // rien trouve ou un tableau |
|
| 635 | - } elseif ($testv) { |
|
| 636 | - foreach ($ajouts as $k => $n) { |
|
| 637 | - if (!is_array($v)) { |
|
| 638 | - $url[] = $k . '=' . $u; |
|
| 639 | - } else { |
|
| 640 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 641 | - foreach ($v as $w) { |
|
| 642 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 643 | - } |
|
| 644 | - } |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - // eliminer les vides |
|
| 649 | - $url = array_filter($url); |
|
| 650 | - |
|
| 651 | - // recomposer l'adresse |
|
| 652 | - if ($url) { |
|
| 653 | - $a .= '?' . join($sep, $url); |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - return $a . $ancre; |
|
| 567 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 568 | + if (strpos($c, '|') !== false and is_null($v)) { |
|
| 569 | + return null; |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + // lever l'#ancre |
|
| 573 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 574 | + $url = $r[1]; |
|
| 575 | + $ancre = $r[2]; |
|
| 576 | + } else { |
|
| 577 | + $ancre = ''; |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + // eclater |
|
| 581 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 582 | + |
|
| 583 | + // recuperer la base |
|
| 584 | + $a = array_shift($url); |
|
| 585 | + if (!$a) { |
|
| 586 | + $a = './'; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 590 | + $ajouts = array_flip(explode('|', $c)); |
|
| 591 | + $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 592 | + $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 593 | + $v_read = null; |
|
| 594 | + // lire les variables et agir |
|
| 595 | + foreach ($url as $n => $val) { |
|
| 596 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 597 | + $r = array_pad($r, 3, null); |
|
| 598 | + if ($v === null) { |
|
| 599 | + // c'est un tableau, on memorise les valeurs |
|
| 600 | + if (substr($r[1], -2) == '[]') { |
|
| 601 | + if (!$v_read) { |
|
| 602 | + $v_read = []; |
|
| 603 | + } |
|
| 604 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 605 | + } // c'est un scalaire, on retourne direct |
|
| 606 | + else { |
|
| 607 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 608 | + } |
|
| 609 | + } // suppression |
|
| 610 | + elseif (!$testv) { |
|
| 611 | + unset($url[$n]); |
|
| 612 | + } |
|
| 613 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 614 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 615 | + elseif (substr($r[1], -2) != '[]') { |
|
| 616 | + $url[$n] = $r[1] . '=' . $u; |
|
| 617 | + unset($ajouts[$r[1]]); |
|
| 618 | + } |
|
| 619 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 620 | + // départ, on remplira à l'étape suivante |
|
| 621 | + else { |
|
| 622 | + unset($url[$n]); |
|
| 623 | + } |
|
| 624 | + } |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + // traiter les parametres pas encore trouves |
|
| 628 | + if ( |
|
| 629 | + $v === null |
|
| 630 | + and $args = func_get_args() |
|
| 631 | + and count($args) == 2 |
|
| 632 | + ) { |
|
| 633 | + return $v_read; // rien trouve ou un tableau |
|
| 634 | + } elseif ($testv) { |
|
| 635 | + foreach ($ajouts as $k => $n) { |
|
| 636 | + if (!is_array($v)) { |
|
| 637 | + $url[] = $k . '=' . $u; |
|
| 638 | + } else { |
|
| 639 | + $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 640 | + foreach ($v as $w) { |
|
| 641 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 642 | + } |
|
| 643 | + } |
|
| 644 | + } |
|
| 645 | + } |
|
| 646 | + |
|
| 647 | + // eliminer les vides |
|
| 648 | + $url = array_filter($url); |
|
| 649 | + |
|
| 650 | + // recomposer l'adresse |
|
| 651 | + if ($url) { |
|
| 652 | + $a .= '?' . join($sep, $url); |
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + return $a . $ancre; |
|
| 657 | 656 | } |
| 658 | 657 | |
| 659 | 658 | /** |
@@ -671,21 +670,21 @@ discard block |
||
| 671 | 670 | * @return string |
| 672 | 671 | */ |
| 673 | 672 | function ancre_url($url, $ancre) { |
| 674 | - // lever l'#ancre |
|
| 675 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 676 | - $url = $r[1]; |
|
| 677 | - } |
|
| 678 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 679 | - if (!function_exists('translitteration')) { |
|
| 680 | - include_spip('inc/charsets'); |
|
| 681 | - } |
|
| 682 | - $ancre = preg_replace( |
|
| 683 | - ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 684 | - ['', '-'], |
|
| 685 | - translitteration($ancre) |
|
| 686 | - ); |
|
| 687 | - } |
|
| 688 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 673 | + // lever l'#ancre |
|
| 674 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 675 | + $url = $r[1]; |
|
| 676 | + } |
|
| 677 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 678 | + if (!function_exists('translitteration')) { |
|
| 679 | + include_spip('inc/charsets'); |
|
| 680 | + } |
|
| 681 | + $ancre = preg_replace( |
|
| 682 | + ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 683 | + ['', '-'], |
|
| 684 | + translitteration($ancre) |
|
| 685 | + ); |
|
| 686 | + } |
|
| 687 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 689 | 688 | } |
| 690 | 689 | |
| 691 | 690 | /** |
@@ -695,16 +694,16 @@ discard block |
||
| 695 | 694 | * @return string |
| 696 | 695 | */ |
| 697 | 696 | function nettoyer_uri($reset = null) { |
| 698 | - static $done = false; |
|
| 699 | - static $propre = ''; |
|
| 700 | - if (!is_null($reset)) { |
|
| 701 | - return $propre = $reset; |
|
| 702 | - } |
|
| 703 | - if ($done) { |
|
| 704 | - return $propre; |
|
| 705 | - } |
|
| 706 | - $done = true; |
|
| 707 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 697 | + static $done = false; |
|
| 698 | + static $propre = ''; |
|
| 699 | + if (!is_null($reset)) { |
|
| 700 | + return $propre = $reset; |
|
| 701 | + } |
|
| 702 | + if ($done) { |
|
| 703 | + return $propre; |
|
| 704 | + } |
|
| 705 | + $done = true; |
|
| 706 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 708 | 707 | } |
| 709 | 708 | |
| 710 | 709 | /** |
@@ -716,16 +715,16 @@ discard block |
||
| 716 | 715 | * @return string |
| 717 | 716 | */ |
| 718 | 717 | function nettoyer_uri_var($request_uri) { |
| 719 | - $uri1 = $request_uri; |
|
| 720 | - do { |
|
| 721 | - $uri = $uri1; |
|
| 722 | - $uri1 = preg_replace( |
|
| 723 | - ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 724 | - '\1', |
|
| 725 | - $uri |
|
| 726 | - ); |
|
| 727 | - } while ($uri <> $uri1); |
|
| 728 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 718 | + $uri1 = $request_uri; |
|
| 719 | + do { |
|
| 720 | + $uri = $uri1; |
|
| 721 | + $uri1 = preg_replace( |
|
| 722 | + ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 723 | + '\1', |
|
| 724 | + $uri |
|
| 725 | + ); |
|
| 726 | + } while ($uri <> $uri1); |
|
| 727 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 729 | 728 | } |
| 730 | 729 | |
| 731 | 730 | |
@@ -739,48 +738,48 @@ discard block |
||
| 739 | 738 | * URL vers soi-même |
| 740 | 739 | **/ |
| 741 | 740 | function self($amp = '&', $root = false) { |
| 742 | - $url = nettoyer_uri(); |
|
| 743 | - if ( |
|
| 744 | - !$root |
|
| 745 | - and ( |
|
| 746 | - // si pas de profondeur on peut tronquer |
|
| 747 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 748 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 749 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 750 | - ) { |
|
| 751 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 752 | - } |
|
| 753 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 754 | - foreach ($_POST as $v => $c) { |
|
| 755 | - if (substr($v, 0, 3) == 'id_') { |
|
| 756 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 757 | - } |
|
| 758 | - } |
|
| 759 | - |
|
| 760 | - // supprimer les variables sans interet |
|
| 761 | - if (test_espace_prive()) { |
|
| 762 | - $url = preg_replace(',([?&])(' |
|
| 763 | - . 'lang|show_docs|' |
|
| 764 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 765 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 766 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 767 | - } |
|
| 768 | - |
|
| 769 | - // eviter les hacks |
|
| 770 | - include_spip('inc/filtres_mini'); |
|
| 771 | - $url = spip_htmlspecialchars($url); |
|
| 772 | - |
|
| 773 | - $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 774 | - |
|
| 775 | - // & ? |
|
| 776 | - if ($amp != '&') { |
|
| 777 | - $url = str_replace('&', $amp, $url); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - // Si ca demarre par ? ou vide, donner './' |
|
| 781 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 782 | - |
|
| 783 | - return $url; |
|
| 741 | + $url = nettoyer_uri(); |
|
| 742 | + if ( |
|
| 743 | + !$root |
|
| 744 | + and ( |
|
| 745 | + // si pas de profondeur on peut tronquer |
|
| 746 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 747 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 748 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 749 | + ) { |
|
| 750 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 751 | + } |
|
| 752 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 753 | + foreach ($_POST as $v => $c) { |
|
| 754 | + if (substr($v, 0, 3) == 'id_') { |
|
| 755 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 756 | + } |
|
| 757 | + } |
|
| 758 | + |
|
| 759 | + // supprimer les variables sans interet |
|
| 760 | + if (test_espace_prive()) { |
|
| 761 | + $url = preg_replace(',([?&])(' |
|
| 762 | + . 'lang|show_docs|' |
|
| 763 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 764 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 765 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + // eviter les hacks |
|
| 769 | + include_spip('inc/filtres_mini'); |
|
| 770 | + $url = spip_htmlspecialchars($url); |
|
| 771 | + |
|
| 772 | + $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 773 | + |
|
| 774 | + // & ? |
|
| 775 | + if ($amp != '&') { |
|
| 776 | + $url = str_replace('&', $amp, $url); |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + // Si ca demarre par ? ou vide, donner './' |
|
| 780 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 781 | + |
|
| 782 | + return $url; |
|
| 784 | 783 | } |
| 785 | 784 | |
| 786 | 785 | |
@@ -791,7 +790,7 @@ discard block |
||
| 791 | 790 | * true si c'est le cas, false sinon. |
| 792 | 791 | */ |
| 793 | 792 | function test_espace_prive() { |
| 794 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 793 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 795 | 794 | } |
| 796 | 795 | |
| 797 | 796 | /** |
@@ -801,7 +800,7 @@ discard block |
||
| 801 | 800 | * @return bool |
| 802 | 801 | */ |
| 803 | 802 | function test_plugin_actif($plugin) { |
| 804 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 803 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 805 | 804 | } |
| 806 | 805 | |
| 807 | 806 | /** |
@@ -832,52 +831,52 @@ discard block |
||
| 832 | 831 | * Texte |
| 833 | 832 | */ |
| 834 | 833 | function _T($texte, $args = [], $options = []) { |
| 835 | - static $traduire = false; |
|
| 836 | - $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 837 | - if ($options) { |
|
| 838 | - // support de l'ancien argument $class |
|
| 839 | - if (is_string($options)) { |
|
| 840 | - $options = ['class' => $options]; |
|
| 841 | - } |
|
| 842 | - $o = array_merge($o, $options); |
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - if (!$traduire) { |
|
| 846 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 847 | - include_spip('inc/lang'); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - // On peut passer explicitement la langue dans le tableau |
|
| 851 | - // On utilise le même nom de variable que la globale |
|
| 852 | - if (isset($args['spip_lang'])) { |
|
| 853 | - $lang = $args['spip_lang']; |
|
| 854 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 855 | - unset($args['spip_lang']); |
|
| 856 | - } // Sinon on prend la langue du contexte |
|
| 857 | - else { |
|
| 858 | - $lang = $GLOBALS['spip_lang']; |
|
| 859 | - } |
|
| 860 | - $text = $traduire($texte, $lang); |
|
| 861 | - |
|
| 862 | - if ($text === null || !strlen($text)) { |
|
| 863 | - if (!$o['force']) { |
|
| 864 | - return ''; |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - $text = $texte; |
|
| 868 | - |
|
| 869 | - // pour les chaines non traduites, assurer un service minimum |
|
| 870 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 871 | - $n = strpos($text, ':'); |
|
| 872 | - if ($n !== false) { |
|
| 873 | - $text = substr($text, $n + 1); |
|
| 874 | - } |
|
| 875 | - $text = str_replace('_', ' ', $text); |
|
| 876 | - } |
|
| 877 | - $o['class'] = null; |
|
| 878 | - } |
|
| 879 | - |
|
| 880 | - return _L($text, $args, $o); |
|
| 834 | + static $traduire = false; |
|
| 835 | + $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 836 | + if ($options) { |
|
| 837 | + // support de l'ancien argument $class |
|
| 838 | + if (is_string($options)) { |
|
| 839 | + $options = ['class' => $options]; |
|
| 840 | + } |
|
| 841 | + $o = array_merge($o, $options); |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + if (!$traduire) { |
|
| 845 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 846 | + include_spip('inc/lang'); |
|
| 847 | + } |
|
| 848 | + |
|
| 849 | + // On peut passer explicitement la langue dans le tableau |
|
| 850 | + // On utilise le même nom de variable que la globale |
|
| 851 | + if (isset($args['spip_lang'])) { |
|
| 852 | + $lang = $args['spip_lang']; |
|
| 853 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 854 | + unset($args['spip_lang']); |
|
| 855 | + } // Sinon on prend la langue du contexte |
|
| 856 | + else { |
|
| 857 | + $lang = $GLOBALS['spip_lang']; |
|
| 858 | + } |
|
| 859 | + $text = $traduire($texte, $lang); |
|
| 860 | + |
|
| 861 | + if ($text === null || !strlen($text)) { |
|
| 862 | + if (!$o['force']) { |
|
| 863 | + return ''; |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + $text = $texte; |
|
| 867 | + |
|
| 868 | + // pour les chaines non traduites, assurer un service minimum |
|
| 869 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 870 | + $n = strpos($text, ':'); |
|
| 871 | + if ($n !== false) { |
|
| 872 | + $text = substr($text, $n + 1); |
|
| 873 | + } |
|
| 874 | + $text = str_replace('_', ' ', $text); |
|
| 875 | + } |
|
| 876 | + $o['class'] = null; |
|
| 877 | + } |
|
| 878 | + |
|
| 879 | + return _L($text, $args, $o); |
|
| 881 | 880 | } |
| 882 | 881 | |
| 883 | 882 | |
@@ -904,53 +903,53 @@ discard block |
||
| 904 | 903 | * Texte |
| 905 | 904 | */ |
| 906 | 905 | function _L($text, $args = [], $options = []) { |
| 907 | - $f = $text; |
|
| 908 | - $defaut_options = [ |
|
| 909 | - 'class' => null, |
|
| 910 | - 'sanitize' => true, |
|
| 911 | - ]; |
|
| 912 | - // support de l'ancien argument $class |
|
| 913 | - if ($options and is_string($options)) { |
|
| 914 | - $options = ['class' => $options]; |
|
| 915 | - } |
|
| 916 | - if (is_array($options)) { |
|
| 917 | - $options += $defaut_options; |
|
| 918 | - } else { |
|
| 919 | - $options = $defaut_options; |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - if (is_array($args) and count($args)) { |
|
| 923 | - if (!function_exists('interdire_scripts')) { |
|
| 924 | - include_spip('inc/texte'); |
|
| 925 | - } |
|
| 926 | - if (!function_exists('echapper_html_suspect')) { |
|
| 927 | - include_spip('inc/texte_mini'); |
|
| 928 | - } |
|
| 929 | - foreach ($args as $name => $value) { |
|
| 930 | - if (strpos($text, (string) "@$name@") !== false) { |
|
| 931 | - if ($options['sanitize']) { |
|
| 932 | - $value = echapper_html_suspect($value); |
|
| 933 | - $value = interdire_scripts($value, -1); |
|
| 934 | - } |
|
| 935 | - if (!empty($options['class'])) { |
|
| 936 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 937 | - } |
|
| 938 | - $text = str_replace("@$name@", $value, $text); |
|
| 939 | - unset($args[$name]); |
|
| 940 | - } |
|
| 941 | - } |
|
| 942 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 943 | - // (chaines de langues pas a jour) |
|
| 944 | - if ($args) { |
|
| 945 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 946 | - } |
|
| 947 | - } |
|
| 948 | - |
|
| 949 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 950 | - return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 951 | - } else { |
|
| 952 | - return $text; |
|
| 953 | - } |
|
| 906 | + $f = $text; |
|
| 907 | + $defaut_options = [ |
|
| 908 | + 'class' => null, |
|
| 909 | + 'sanitize' => true, |
|
| 910 | + ]; |
|
| 911 | + // support de l'ancien argument $class |
|
| 912 | + if ($options and is_string($options)) { |
|
| 913 | + $options = ['class' => $options]; |
|
| 914 | + } |
|
| 915 | + if (is_array($options)) { |
|
| 916 | + $options += $defaut_options; |
|
| 917 | + } else { |
|
| 918 | + $options = $defaut_options; |
|
| 919 | + } |
|
| 920 | + |
|
| 921 | + if (is_array($args) and count($args)) { |
|
| 922 | + if (!function_exists('interdire_scripts')) { |
|
| 923 | + include_spip('inc/texte'); |
|
| 924 | + } |
|
| 925 | + if (!function_exists('echapper_html_suspect')) { |
|
| 926 | + include_spip('inc/texte_mini'); |
|
| 927 | + } |
|
| 928 | + foreach ($args as $name => $value) { |
|
| 929 | + if (strpos($text, (string) "@$name@") !== false) { |
|
| 930 | + if ($options['sanitize']) { |
|
| 931 | + $value = echapper_html_suspect($value); |
|
| 932 | + $value = interdire_scripts($value, -1); |
|
| 933 | + } |
|
| 934 | + if (!empty($options['class'])) { |
|
| 935 | + $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 936 | + } |
|
| 937 | + $text = str_replace("@$name@", $value, $text); |
|
| 938 | + unset($args[$name]); |
|
| 939 | + } |
|
| 940 | + } |
|
| 941 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 942 | + // (chaines de langues pas a jour) |
|
| 943 | + if ($args) { |
|
| 944 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 945 | + } |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 949 | + return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 950 | + } else { |
|
| 951 | + return $text; |
|
| 952 | + } |
|
| 954 | 953 | } |
| 955 | 954 | |
| 956 | 955 | |
@@ -964,13 +963,13 @@ discard block |
||
| 964 | 963 | * @return string |
| 965 | 964 | */ |
| 966 | 965 | function joli_repertoire($rep) { |
| 967 | - $a = substr($rep, 0, 1); |
|
| 968 | - if ($a <> '.' and $a <> '/') { |
|
| 969 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 970 | - } |
|
| 971 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 966 | + $a = substr($rep, 0, 1); |
|
| 967 | + if ($a <> '.' and $a <> '/') { |
|
| 968 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 969 | + } |
|
| 970 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 972 | 971 | |
| 973 | - return $rep; |
|
| 972 | + return $rep; |
|
| 974 | 973 | } |
| 975 | 974 | |
| 976 | 975 | |
@@ -995,54 +994,54 @@ discard block |
||
| 995 | 994 | * @return float|int|string|void |
| 996 | 995 | */ |
| 997 | 996 | function spip_timer($t = 'rien', $raw = false) { |
| 998 | - static $time; |
|
| 999 | - $a = time(); |
|
| 1000 | - $b = microtime(); |
|
| 1001 | - // microtime peut contenir les microsecondes et le temps |
|
| 1002 | - $b = explode(' ', $b); |
|
| 1003 | - if (count($b) == 2) { |
|
| 1004 | - $a = end($b); |
|
| 1005 | - } // plus precis ! |
|
| 1006 | - $b = reset($b); |
|
| 1007 | - if (!isset($time[$t])) { |
|
| 1008 | - $time[$t] = $a + $b; |
|
| 1009 | - } else { |
|
| 1010 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 1011 | - unset($time[$t]); |
|
| 997 | + static $time; |
|
| 998 | + $a = time(); |
|
| 999 | + $b = microtime(); |
|
| 1000 | + // microtime peut contenir les microsecondes et le temps |
|
| 1001 | + $b = explode(' ', $b); |
|
| 1002 | + if (count($b) == 2) { |
|
| 1003 | + $a = end($b); |
|
| 1004 | + } // plus precis ! |
|
| 1005 | + $b = reset($b); |
|
| 1006 | + if (!isset($time[$t])) { |
|
| 1007 | + $time[$t] = $a + $b; |
|
| 1008 | + } else { |
|
| 1009 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 1010 | + unset($time[$t]); |
|
| 1012 | 1011 | # echo "'$p'";exit; |
| 1013 | - if ($raw) { |
|
| 1014 | - return $p; |
|
| 1015 | - } |
|
| 1016 | - if ($p < 1000) { |
|
| 1017 | - $s = ''; |
|
| 1018 | - } else { |
|
| 1019 | - $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1020 | - $p -= ($x * 1000); |
|
| 1021 | - } |
|
| 1012 | + if ($raw) { |
|
| 1013 | + return $p; |
|
| 1014 | + } |
|
| 1015 | + if ($p < 1000) { |
|
| 1016 | + $s = ''; |
|
| 1017 | + } else { |
|
| 1018 | + $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1019 | + $p -= ($x * 1000); |
|
| 1020 | + } |
|
| 1022 | 1021 | |
| 1023 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1024 | - } |
|
| 1022 | + return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1023 | + } |
|
| 1025 | 1024 | } |
| 1026 | 1025 | |
| 1027 | 1026 | |
| 1028 | 1027 | // Renvoie False si un fichier n'est pas plus vieux que $duree secondes, |
| 1029 | 1028 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 1030 | 1029 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 1031 | - if ($duree) { |
|
| 1032 | - clearstatcache(); |
|
| 1033 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1034 | - return false; |
|
| 1035 | - } |
|
| 1036 | - } |
|
| 1037 | - if ($touch !== false) { |
|
| 1038 | - if (!@touch($fichier)) { |
|
| 1039 | - spip_unlink($fichier); |
|
| 1040 | - @touch($fichier); |
|
| 1041 | - }; |
|
| 1042 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1043 | - } |
|
| 1030 | + if ($duree) { |
|
| 1031 | + clearstatcache(); |
|
| 1032 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1033 | + return false; |
|
| 1034 | + } |
|
| 1035 | + } |
|
| 1036 | + if ($touch !== false) { |
|
| 1037 | + if (!@touch($fichier)) { |
|
| 1038 | + spip_unlink($fichier); |
|
| 1039 | + @touch($fichier); |
|
| 1040 | + }; |
|
| 1041 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1042 | + } |
|
| 1044 | 1043 | |
| 1045 | - return true; |
|
| 1044 | + return true; |
|
| 1046 | 1045 | } |
| 1047 | 1046 | |
| 1048 | 1047 | |
@@ -1053,11 +1052,11 @@ discard block |
||
| 1053 | 1052 | * @uses cron() |
| 1054 | 1053 | **/ |
| 1055 | 1054 | function action_cron() { |
| 1056 | - include_spip('inc/headers'); |
|
| 1057 | - http_response_code(204); // No Content |
|
| 1058 | - header('Connection: close'); |
|
| 1059 | - define('_DIRECT_CRON_FORCE', true); |
|
| 1060 | - cron(); |
|
| 1055 | + include_spip('inc/headers'); |
|
| 1056 | + http_response_code(204); // No Content |
|
| 1057 | + header('Connection: close'); |
|
| 1058 | + define('_DIRECT_CRON_FORCE', true); |
|
| 1059 | + cron(); |
|
| 1061 | 1060 | } |
| 1062 | 1061 | |
| 1063 | 1062 | /** |
@@ -1073,26 +1072,26 @@ discard block |
||
| 1073 | 1072 | * True si la tache a pu être effectuée |
| 1074 | 1073 | */ |
| 1075 | 1074 | function cron($taches = [], $taches_old = []) { |
| 1076 | - // si pas en mode cron force, laisser tomber. |
|
| 1077 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1078 | - return false; |
|
| 1079 | - } |
|
| 1080 | - if (!is_array($taches)) { |
|
| 1081 | - $taches = $taches_old; |
|
| 1082 | - } // compat anciens appels |
|
| 1083 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1084 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1085 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1086 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1087 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1088 | - return false; |
|
| 1089 | - } |
|
| 1090 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1091 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1092 | - return $genie($taches); |
|
| 1093 | - } |
|
| 1094 | - |
|
| 1095 | - return false; |
|
| 1075 | + // si pas en mode cron force, laisser tomber. |
|
| 1076 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1077 | + return false; |
|
| 1078 | + } |
|
| 1079 | + if (!is_array($taches)) { |
|
| 1080 | + $taches = $taches_old; |
|
| 1081 | + } // compat anciens appels |
|
| 1082 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1083 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1084 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1085 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1086 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1087 | + return false; |
|
| 1088 | + } |
|
| 1089 | + spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1090 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1091 | + return $genie($taches); |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + return false; |
|
| 1096 | 1095 | } |
| 1097 | 1096 | |
| 1098 | 1097 | /** |
@@ -1124,17 +1123,17 @@ discard block |
||
| 1124 | 1123 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1125 | 1124 | */ |
| 1126 | 1125 | function job_queue_add( |
| 1127 | - $function, |
|
| 1128 | - $description, |
|
| 1129 | - $arguments = [], |
|
| 1130 | - $file = '', |
|
| 1131 | - $no_duplicate = false, |
|
| 1132 | - $time = 0, |
|
| 1133 | - $priority = 0 |
|
| 1126 | + $function, |
|
| 1127 | + $description, |
|
| 1128 | + $arguments = [], |
|
| 1129 | + $file = '', |
|
| 1130 | + $no_duplicate = false, |
|
| 1131 | + $time = 0, |
|
| 1132 | + $priority = 0 |
|
| 1134 | 1133 | ) { |
| 1135 | - include_spip('inc/queue'); |
|
| 1134 | + include_spip('inc/queue'); |
|
| 1136 | 1135 | |
| 1137 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1136 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1138 | 1137 | } |
| 1139 | 1138 | |
| 1140 | 1139 | /** |
@@ -1145,9 +1144,9 @@ discard block |
||
| 1145 | 1144 | * @return bool |
| 1146 | 1145 | */ |
| 1147 | 1146 | function job_queue_remove($id_job) { |
| 1148 | - include_spip('inc/queue'); |
|
| 1147 | + include_spip('inc/queue'); |
|
| 1149 | 1148 | |
| 1150 | - return queue_remove_job($id_job); |
|
| 1149 | + return queue_remove_job($id_job); |
|
| 1151 | 1150 | } |
| 1152 | 1151 | |
| 1153 | 1152 | /** |
@@ -1160,9 +1159,9 @@ discard block |
||
| 1160 | 1159 | * or an array of simple array to link multiples objet in one time |
| 1161 | 1160 | */ |
| 1162 | 1161 | function job_queue_link($id_job, $objets) { |
| 1163 | - include_spip('inc/queue'); |
|
| 1162 | + include_spip('inc/queue'); |
|
| 1164 | 1163 | |
| 1165 | - return queue_link_job($id_job, $objets); |
|
| 1164 | + return queue_link_job($id_job, $objets); |
|
| 1166 | 1165 | } |
| 1167 | 1166 | |
| 1168 | 1167 | |
@@ -1182,36 +1181,36 @@ discard block |
||
| 1182 | 1181 | * - `null` si la queue n'est pas encore initialisée |
| 1183 | 1182 | */ |
| 1184 | 1183 | function queue_sleep_time_to_next_job($force = null) { |
| 1185 | - static $queue_next_job_time = -1; |
|
| 1186 | - if ($force === true) { |
|
| 1187 | - $queue_next_job_time = -1; |
|
| 1188 | - } elseif ($force) { |
|
| 1189 | - $queue_next_job_time = $force; |
|
| 1190 | - } |
|
| 1191 | - |
|
| 1192 | - if ($queue_next_job_time == -1) { |
|
| 1193 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1194 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1195 | - } |
|
| 1196 | - // utiliser un cache memoire si dispo |
|
| 1197 | - if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1198 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1199 | - } else { |
|
| 1200 | - $queue_next_job_time = null; |
|
| 1201 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1202 | - $queue_next_job_time = intval($contenu); |
|
| 1203 | - } |
|
| 1204 | - } |
|
| 1205 | - } |
|
| 1206 | - |
|
| 1207 | - if (is_null($queue_next_job_time)) { |
|
| 1208 | - return null; |
|
| 1209 | - } |
|
| 1210 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1211 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1212 | - } |
|
| 1213 | - |
|
| 1214 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1184 | + static $queue_next_job_time = -1; |
|
| 1185 | + if ($force === true) { |
|
| 1186 | + $queue_next_job_time = -1; |
|
| 1187 | + } elseif ($force) { |
|
| 1188 | + $queue_next_job_time = $force; |
|
| 1189 | + } |
|
| 1190 | + |
|
| 1191 | + if ($queue_next_job_time == -1) { |
|
| 1192 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1193 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1194 | + } |
|
| 1195 | + // utiliser un cache memoire si dispo |
|
| 1196 | + if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1197 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1198 | + } else { |
|
| 1199 | + $queue_next_job_time = null; |
|
| 1200 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1201 | + $queue_next_job_time = intval($contenu); |
|
| 1202 | + } |
|
| 1203 | + } |
|
| 1204 | + } |
|
| 1205 | + |
|
| 1206 | + if (is_null($queue_next_job_time)) { |
|
| 1207 | + return null; |
|
| 1208 | + } |
|
| 1209 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1210 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1215 | 1214 | } |
| 1216 | 1215 | |
| 1217 | 1216 | |
@@ -1223,11 +1222,11 @@ discard block |
||
| 1223 | 1222 | * @return string |
| 1224 | 1223 | */ |
| 1225 | 1224 | function quote_amp($u) { |
| 1226 | - return preg_replace( |
|
| 1227 | - '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1228 | - '&', |
|
| 1229 | - $u |
|
| 1230 | - ); |
|
| 1225 | + return preg_replace( |
|
| 1226 | + '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1227 | + '&', |
|
| 1228 | + $u |
|
| 1229 | + ); |
|
| 1231 | 1230 | } |
| 1232 | 1231 | |
| 1233 | 1232 | |
@@ -1250,27 +1249,27 @@ discard block |
||
| 1250 | 1249 | * Balise HTML `<script>` et son contenu |
| 1251 | 1250 | **/ |
| 1252 | 1251 | function http_script($script, $src = '', $noscript = '') { |
| 1253 | - static $done = []; |
|
| 1252 | + static $done = []; |
|
| 1254 | 1253 | |
| 1255 | - if ($src && !isset($done[$src])) { |
|
| 1256 | - $done[$src] = true; |
|
| 1257 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1258 | - $src = " src='$src'"; |
|
| 1259 | - } else { |
|
| 1260 | - $src = ''; |
|
| 1261 | - } |
|
| 1262 | - if ($script) { |
|
| 1263 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1264 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1265 | - '/*]]>*/'); |
|
| 1266 | - } |
|
| 1267 | - if ($noscript) { |
|
| 1268 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1269 | - } |
|
| 1254 | + if ($src && !isset($done[$src])) { |
|
| 1255 | + $done[$src] = true; |
|
| 1256 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1257 | + $src = " src='$src'"; |
|
| 1258 | + } else { |
|
| 1259 | + $src = ''; |
|
| 1260 | + } |
|
| 1261 | + if ($script) { |
|
| 1262 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1263 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1264 | + '/*]]>*/'); |
|
| 1265 | + } |
|
| 1266 | + if ($noscript) { |
|
| 1267 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1268 | + } |
|
| 1270 | 1269 | |
| 1271 | - return ($src or $script or $noscript) |
|
| 1272 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1273 | - : ''; |
|
| 1270 | + return ($src or $script or $noscript) |
|
| 1271 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1272 | + : ''; |
|
| 1274 | 1273 | } |
| 1275 | 1274 | |
| 1276 | 1275 | |
@@ -1305,7 +1304,7 @@ discard block |
||
| 1305 | 1304 | * Texte échappé |
| 1306 | 1305 | **/ |
| 1307 | 1306 | function texte_script(string $texte): string { |
| 1308 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1307 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1309 | 1308 | } |
| 1310 | 1309 | |
| 1311 | 1310 | |
@@ -1342,68 +1341,68 @@ discard block |
||
| 1342 | 1341 | * Liste des chemins, par ordre de priorité. |
| 1343 | 1342 | **/ |
| 1344 | 1343 | function _chemin($dir_path = null) { |
| 1345 | - static $path_base = null; |
|
| 1346 | - static $path_full = null; |
|
| 1347 | - if ($path_base == null) { |
|
| 1348 | - // Chemin standard depuis l'espace public |
|
| 1349 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1350 | - _DIR_RACINE . ':' . |
|
| 1351 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1352 | - _DIR_RACINE . 'prive/:' . |
|
| 1353 | - _DIR_RESTREINT; |
|
| 1354 | - // Ajouter squelettes/ |
|
| 1355 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1356 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1357 | - } |
|
| 1358 | - foreach (explode(':', $path) as $dir) { |
|
| 1359 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1360 | - $dir .= '/'; |
|
| 1361 | - } |
|
| 1362 | - $path_base[] = $dir; |
|
| 1363 | - } |
|
| 1364 | - $path_full = $path_base; |
|
| 1365 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1366 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1367 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1368 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1369 | - } |
|
| 1370 | - } |
|
| 1371 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1372 | - } |
|
| 1373 | - if ($dir_path === null) { |
|
| 1374 | - return $path_full; |
|
| 1375 | - } |
|
| 1376 | - |
|
| 1377 | - if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1378 | - $tete = ''; |
|
| 1379 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1380 | - $tete = array_shift($path_base); |
|
| 1381 | - } |
|
| 1382 | - $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1383 | - $dirs = array_reverse($dirs); |
|
| 1384 | - foreach ($dirs as $dir_path) { |
|
| 1385 | - if (substr($dir_path, -1) != '/') { |
|
| 1386 | - $dir_path .= '/'; |
|
| 1387 | - } |
|
| 1388 | - if (!in_array($dir_path, $path_base)) { |
|
| 1389 | - array_unshift($path_base, $dir_path); |
|
| 1390 | - } |
|
| 1391 | - } |
|
| 1392 | - if (strlen($tete)) { |
|
| 1393 | - array_unshift($path_base, $tete); |
|
| 1394 | - } |
|
| 1395 | - } |
|
| 1396 | - $path_full = $path_base; |
|
| 1397 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1398 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1399 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1400 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1401 | - } |
|
| 1402 | - } |
|
| 1403 | - |
|
| 1404 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1405 | - |
|
| 1406 | - return $path_full; |
|
| 1344 | + static $path_base = null; |
|
| 1345 | + static $path_full = null; |
|
| 1346 | + if ($path_base == null) { |
|
| 1347 | + // Chemin standard depuis l'espace public |
|
| 1348 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1349 | + _DIR_RACINE . ':' . |
|
| 1350 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1351 | + _DIR_RACINE . 'prive/:' . |
|
| 1352 | + _DIR_RESTREINT; |
|
| 1353 | + // Ajouter squelettes/ |
|
| 1354 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1355 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1356 | + } |
|
| 1357 | + foreach (explode(':', $path) as $dir) { |
|
| 1358 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1359 | + $dir .= '/'; |
|
| 1360 | + } |
|
| 1361 | + $path_base[] = $dir; |
|
| 1362 | + } |
|
| 1363 | + $path_full = $path_base; |
|
| 1364 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1365 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1366 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1367 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1368 | + } |
|
| 1369 | + } |
|
| 1370 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1371 | + } |
|
| 1372 | + if ($dir_path === null) { |
|
| 1373 | + return $path_full; |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1377 | + $tete = ''; |
|
| 1378 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1379 | + $tete = array_shift($path_base); |
|
| 1380 | + } |
|
| 1381 | + $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1382 | + $dirs = array_reverse($dirs); |
|
| 1383 | + foreach ($dirs as $dir_path) { |
|
| 1384 | + if (substr($dir_path, -1) != '/') { |
|
| 1385 | + $dir_path .= '/'; |
|
| 1386 | + } |
|
| 1387 | + if (!in_array($dir_path, $path_base)) { |
|
| 1388 | + array_unshift($path_base, $dir_path); |
|
| 1389 | + } |
|
| 1390 | + } |
|
| 1391 | + if (strlen($tete)) { |
|
| 1392 | + array_unshift($path_base, $tete); |
|
| 1393 | + } |
|
| 1394 | + } |
|
| 1395 | + $path_full = $path_base; |
|
| 1396 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1397 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1398 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1399 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1400 | + } |
|
| 1401 | + } |
|
| 1402 | + |
|
| 1403 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1404 | + |
|
| 1405 | + return $path_full; |
|
| 1407 | 1406 | } |
| 1408 | 1407 | |
| 1409 | 1408 | /** |
@@ -1416,78 +1415,78 @@ discard block |
||
| 1416 | 1415 | * @return array Liste de chemins |
| 1417 | 1416 | **/ |
| 1418 | 1417 | function creer_chemin() { |
| 1419 | - $path_a = _chemin(); |
|
| 1420 | - static $c = ''; |
|
| 1418 | + $path_a = _chemin(); |
|
| 1419 | + static $c = ''; |
|
| 1421 | 1420 | |
| 1422 | - // on calcule le chemin si le dossier skel a change |
|
| 1423 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1424 | - // assurer le non plantage lors de la montee de version : |
|
| 1425 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1426 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1427 | - } |
|
| 1421 | + // on calcule le chemin si le dossier skel a change |
|
| 1422 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1423 | + // assurer le non plantage lors de la montee de version : |
|
| 1424 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1425 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1426 | + } |
|
| 1428 | 1427 | |
| 1429 | - return $path_a; |
|
| 1428 | + return $path_a; |
|
| 1430 | 1429 | } |
| 1431 | 1430 | |
| 1432 | 1431 | |
| 1433 | 1432 | function lister_themes_prives() { |
| 1434 | - static $themes = null; |
|
| 1435 | - if (is_null($themes)) { |
|
| 1436 | - // si pas encore definie |
|
| 1437 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1438 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1439 | - } |
|
| 1440 | - $themes = [_SPIP_THEME_PRIVE]; |
|
| 1441 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1442 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1443 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1444 | - } else { |
|
| 1445 | - $prefs = []; |
|
| 1446 | - } |
|
| 1447 | - if (is_string($prefs)) { |
|
| 1448 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1449 | - } |
|
| 1450 | - if ( |
|
| 1451 | - ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1452 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1453 | - and $theme != _SPIP_THEME_PRIVE |
|
| 1454 | - ) { |
|
| 1455 | - array_unshift($themes, $theme); |
|
| 1456 | - } // placer le theme choisi en tete |
|
| 1457 | - } |
|
| 1458 | - |
|
| 1459 | - return $themes; |
|
| 1433 | + static $themes = null; |
|
| 1434 | + if (is_null($themes)) { |
|
| 1435 | + // si pas encore definie |
|
| 1436 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1437 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1438 | + } |
|
| 1439 | + $themes = [_SPIP_THEME_PRIVE]; |
|
| 1440 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1441 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1442 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1443 | + } else { |
|
| 1444 | + $prefs = []; |
|
| 1445 | + } |
|
| 1446 | + if (is_string($prefs)) { |
|
| 1447 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1448 | + } |
|
| 1449 | + if ( |
|
| 1450 | + ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1451 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1452 | + and $theme != _SPIP_THEME_PRIVE |
|
| 1453 | + ) { |
|
| 1454 | + array_unshift($themes, $theme); |
|
| 1455 | + } // placer le theme choisi en tete |
|
| 1456 | + } |
|
| 1457 | + |
|
| 1458 | + return $themes; |
|
| 1460 | 1459 | } |
| 1461 | 1460 | |
| 1462 | 1461 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1463 | - static $themefiles = []; |
|
| 1464 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1465 | - return $themefiles["$subdir$file"]; |
|
| 1466 | - } |
|
| 1467 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1468 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1469 | - if ( |
|
| 1470 | - preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1471 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1472 | - and $f = find_in_theme("$file_svg_generique") |
|
| 1473 | - ) { |
|
| 1474 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1475 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 1476 | - } |
|
| 1477 | - else { |
|
| 1478 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1479 | - } |
|
| 1480 | - } |
|
| 1481 | - |
|
| 1482 | - $themes = lister_themes_prives(); |
|
| 1483 | - foreach ($themes as $theme) { |
|
| 1484 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1485 | - return $themefiles["$subdir$file"] = $f; |
|
| 1486 | - } |
|
| 1487 | - } |
|
| 1488 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1489 | - |
|
| 1490 | - return $themefiles["$subdir$file"] = ''; |
|
| 1462 | + static $themefiles = []; |
|
| 1463 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1464 | + return $themefiles["$subdir$file"]; |
|
| 1465 | + } |
|
| 1466 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1467 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1468 | + if ( |
|
| 1469 | + preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1470 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1471 | + and $f = find_in_theme("$file_svg_generique") |
|
| 1472 | + ) { |
|
| 1473 | + if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1474 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 1475 | + } |
|
| 1476 | + else { |
|
| 1477 | + return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1478 | + } |
|
| 1479 | + } |
|
| 1480 | + |
|
| 1481 | + $themes = lister_themes_prives(); |
|
| 1482 | + foreach ($themes as $theme) { |
|
| 1483 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1484 | + return $themefiles["$subdir$file"] = $f; |
|
| 1485 | + } |
|
| 1486 | + } |
|
| 1487 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1488 | + |
|
| 1489 | + return $themefiles["$subdir$file"] = ''; |
|
| 1491 | 1490 | } |
| 1492 | 1491 | |
| 1493 | 1492 | |
@@ -1511,31 +1510,31 @@ discard block |
||
| 1511 | 1510 | * sinon chaîne vide. |
| 1512 | 1511 | **/ |
| 1513 | 1512 | function chemin_image($icone) { |
| 1514 | - static $icone_renommer; |
|
| 1515 | - if ($p = strpos($icone, '?')) { |
|
| 1516 | - $icone = substr($icone, 0, $p); |
|
| 1517 | - } |
|
| 1518 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1519 | - if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1520 | - return $icone; |
|
| 1521 | - } |
|
| 1522 | - |
|
| 1523 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1524 | - if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1525 | - return $f; |
|
| 1526 | - } |
|
| 1527 | - // sinon passer par le module de renommage |
|
| 1528 | - if (is_null($icone_renommer)) { |
|
| 1529 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1530 | - } |
|
| 1531 | - if ($icone_renommer) { |
|
| 1532 | - [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1533 | - if (file_exists($icone)) { |
|
| 1534 | - return $icone; |
|
| 1535 | - } |
|
| 1536 | - } |
|
| 1537 | - |
|
| 1538 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1513 | + static $icone_renommer; |
|
| 1514 | + if ($p = strpos($icone, '?')) { |
|
| 1515 | + $icone = substr($icone, 0, $p); |
|
| 1516 | + } |
|
| 1517 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1518 | + if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1519 | + return $icone; |
|
| 1520 | + } |
|
| 1521 | + |
|
| 1522 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1523 | + if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1524 | + return $f; |
|
| 1525 | + } |
|
| 1526 | + // sinon passer par le module de renommage |
|
| 1527 | + if (is_null($icone_renommer)) { |
|
| 1528 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1529 | + } |
|
| 1530 | + if ($icone_renommer) { |
|
| 1531 | + [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1532 | + if (file_exists($icone)) { |
|
| 1533 | + return $icone; |
|
| 1534 | + } |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1539 | 1538 | } |
| 1540 | 1539 | |
| 1541 | 1540 | // |
@@ -1573,128 +1572,128 @@ discard block |
||
| 1573 | 1572 | * - false : fichier introuvable |
| 1574 | 1573 | **/ |
| 1575 | 1574 | function find_in_path($file, $dirname = '', $include = false) { |
| 1576 | - static $dirs = []; |
|
| 1577 | - static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1578 | - static $c = ''; |
|
| 1579 | - |
|
| 1580 | - if (!$file and !strlen($file)) { |
|
| 1581 | - return false; |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - // on calcule le chemin si le dossier skel a change |
|
| 1585 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1586 | - // assurer le non plantage lors de la montee de version : |
|
| 1587 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1588 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1589 | - } |
|
| 1590 | - |
|
| 1591 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1592 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1593 | - return false; |
|
| 1594 | - } |
|
| 1595 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1596 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1597 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1598 | - } |
|
| 1599 | - |
|
| 1600 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1601 | - } |
|
| 1602 | - |
|
| 1603 | - $a = strrpos($file, '/'); |
|
| 1604 | - if ($a !== false) { |
|
| 1605 | - $dirname .= substr($file, 0, ++$a); |
|
| 1606 | - $file = substr($file, $a); |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - foreach (creer_chemin() as $dir) { |
|
| 1610 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1611 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1612 | - } |
|
| 1613 | - if ($dirs[$a]) { |
|
| 1614 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1615 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1616 | - include_once _ROOT_CWD . $a; |
|
| 1617 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1618 | - } |
|
| 1619 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1620 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1621 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1622 | - return $a; |
|
| 1623 | - } |
|
| 1624 | - define('_SAUVER_CHEMIN', true); |
|
| 1625 | - } |
|
| 1626 | - |
|
| 1627 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1628 | - } |
|
| 1629 | - } |
|
| 1630 | - } |
|
| 1631 | - |
|
| 1632 | - if ($include) { |
|
| 1633 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1634 | - if ($include === 'required') { |
|
| 1635 | - echo '<pre>', |
|
| 1636 | - '<strong>Erreur Fatale</strong><br />'; |
|
| 1637 | - if (function_exists('debug_print_backtrace')) { |
|
| 1638 | - echo debug_print_backtrace(); |
|
| 1639 | - } |
|
| 1640 | - echo '</pre>'; |
|
| 1641 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1642 | - } |
|
| 1643 | - } |
|
| 1644 | - |
|
| 1645 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1646 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1647 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1648 | - return false; |
|
| 1649 | - } |
|
| 1650 | - define('_SAUVER_CHEMIN', true); |
|
| 1651 | - } |
|
| 1652 | - |
|
| 1653 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1575 | + static $dirs = []; |
|
| 1576 | + static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1577 | + static $c = ''; |
|
| 1578 | + |
|
| 1579 | + if (!$file and !strlen($file)) { |
|
| 1580 | + return false; |
|
| 1581 | + } |
|
| 1582 | + |
|
| 1583 | + // on calcule le chemin si le dossier skel a change |
|
| 1584 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1585 | + // assurer le non plantage lors de la montee de version : |
|
| 1586 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1587 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1588 | + } |
|
| 1589 | + |
|
| 1590 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1591 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1592 | + return false; |
|
| 1593 | + } |
|
| 1594 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1595 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1596 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1597 | + } |
|
| 1598 | + |
|
| 1599 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1600 | + } |
|
| 1601 | + |
|
| 1602 | + $a = strrpos($file, '/'); |
|
| 1603 | + if ($a !== false) { |
|
| 1604 | + $dirname .= substr($file, 0, ++$a); |
|
| 1605 | + $file = substr($file, $a); |
|
| 1606 | + } |
|
| 1607 | + |
|
| 1608 | + foreach (creer_chemin() as $dir) { |
|
| 1609 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1610 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1611 | + } |
|
| 1612 | + if ($dirs[$a]) { |
|
| 1613 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1614 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1615 | + include_once _ROOT_CWD . $a; |
|
| 1616 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1617 | + } |
|
| 1618 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1619 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1620 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1621 | + return $a; |
|
| 1622 | + } |
|
| 1623 | + define('_SAUVER_CHEMIN', true); |
|
| 1624 | + } |
|
| 1625 | + |
|
| 1626 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1627 | + } |
|
| 1628 | + } |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + if ($include) { |
|
| 1632 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1633 | + if ($include === 'required') { |
|
| 1634 | + echo '<pre>', |
|
| 1635 | + '<strong>Erreur Fatale</strong><br />'; |
|
| 1636 | + if (function_exists('debug_print_backtrace')) { |
|
| 1637 | + echo debug_print_backtrace(); |
|
| 1638 | + } |
|
| 1639 | + echo '</pre>'; |
|
| 1640 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1641 | + } |
|
| 1642 | + } |
|
| 1643 | + |
|
| 1644 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1645 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1646 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1647 | + return false; |
|
| 1648 | + } |
|
| 1649 | + define('_SAUVER_CHEMIN', true); |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1654 | 1653 | } |
| 1655 | 1654 | |
| 1656 | 1655 | function clear_path_cache() { |
| 1657 | - $GLOBALS['path_files'] = []; |
|
| 1658 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1656 | + $GLOBALS['path_files'] = []; |
|
| 1657 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1659 | 1658 | } |
| 1660 | 1659 | |
| 1661 | 1660 | function load_path_cache() { |
| 1662 | - // charger le path des plugins |
|
| 1663 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1664 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1665 | - } |
|
| 1666 | - $GLOBALS['path_files'] = []; |
|
| 1667 | - // si le visiteur est admin, |
|
| 1668 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1669 | - if ( |
|
| 1670 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1671 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1672 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1673 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1674 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1675 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1676 | - !_request('var_mode') |
|
| 1677 | - ) { |
|
| 1678 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1679 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1680 | - // mais si semble corrompu on relit avec un verrou |
|
| 1681 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1682 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1683 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1684 | - $GLOBALS['path_files'] = []; |
|
| 1685 | - } |
|
| 1686 | - } |
|
| 1687 | - } |
|
| 1688 | - } |
|
| 1661 | + // charger le path des plugins |
|
| 1662 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1663 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1664 | + } |
|
| 1665 | + $GLOBALS['path_files'] = []; |
|
| 1666 | + // si le visiteur est admin, |
|
| 1667 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1668 | + if ( |
|
| 1669 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1670 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1671 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1672 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1673 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1674 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1675 | + !_request('var_mode') |
|
| 1676 | + ) { |
|
| 1677 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1678 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1679 | + // mais si semble corrompu on relit avec un verrou |
|
| 1680 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1681 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1682 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1683 | + $GLOBALS['path_files'] = []; |
|
| 1684 | + } |
|
| 1685 | + } |
|
| 1686 | + } |
|
| 1687 | + } |
|
| 1689 | 1688 | } |
| 1690 | 1689 | |
| 1691 | 1690 | function save_path_cache() { |
| 1692 | - if ( |
|
| 1693 | - defined('_SAUVER_CHEMIN') |
|
| 1694 | - and _SAUVER_CHEMIN |
|
| 1695 | - ) { |
|
| 1696 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1697 | - } |
|
| 1691 | + if ( |
|
| 1692 | + defined('_SAUVER_CHEMIN') |
|
| 1693 | + and _SAUVER_CHEMIN |
|
| 1694 | + ) { |
|
| 1695 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1696 | + } |
|
| 1698 | 1697 | } |
| 1699 | 1698 | |
| 1700 | 1699 | |
@@ -1714,33 +1713,33 @@ discard block |
||
| 1714 | 1713 | * @return array |
| 1715 | 1714 | */ |
| 1716 | 1715 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1717 | - $liste_fichiers = []; |
|
| 1718 | - $maxfiles = 10000; |
|
| 1719 | - |
|
| 1720 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1721 | - // on a pas encore inclus flock.php |
|
| 1722 | - if (!function_exists('preg_files')) { |
|
| 1723 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1724 | - } |
|
| 1725 | - |
|
| 1726 | - // Parcourir le chemin |
|
| 1727 | - foreach (creer_chemin() as $d) { |
|
| 1728 | - $f = $d . $dir; |
|
| 1729 | - if (@is_dir($f)) { |
|
| 1730 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1731 | - foreach ($liste as $chemin) { |
|
| 1732 | - $nom = basename($chemin); |
|
| 1733 | - // ne prendre que les fichiers pas deja trouves |
|
| 1734 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1735 | - // les autres sont donc masques |
|
| 1736 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1737 | - $liste_fichiers[$nom] = $chemin; |
|
| 1738 | - } |
|
| 1739 | - } |
|
| 1740 | - } |
|
| 1741 | - } |
|
| 1742 | - |
|
| 1743 | - return $liste_fichiers; |
|
| 1716 | + $liste_fichiers = []; |
|
| 1717 | + $maxfiles = 10000; |
|
| 1718 | + |
|
| 1719 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1720 | + // on a pas encore inclus flock.php |
|
| 1721 | + if (!function_exists('preg_files')) { |
|
| 1722 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1723 | + } |
|
| 1724 | + |
|
| 1725 | + // Parcourir le chemin |
|
| 1726 | + foreach (creer_chemin() as $d) { |
|
| 1727 | + $f = $d . $dir; |
|
| 1728 | + if (@is_dir($f)) { |
|
| 1729 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1730 | + foreach ($liste as $chemin) { |
|
| 1731 | + $nom = basename($chemin); |
|
| 1732 | + // ne prendre que les fichiers pas deja trouves |
|
| 1733 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1734 | + // les autres sont donc masques |
|
| 1735 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1736 | + $liste_fichiers[$nom] = $chemin; |
|
| 1737 | + } |
|
| 1738 | + } |
|
| 1739 | + } |
|
| 1740 | + } |
|
| 1741 | + |
|
| 1742 | + return $liste_fichiers; |
|
| 1744 | 1743 | } |
| 1745 | 1744 | |
| 1746 | 1745 | /** |
@@ -1752,17 +1751,17 @@ discard block |
||
| 1752 | 1751 | * @return bool |
| 1753 | 1752 | */ |
| 1754 | 1753 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1755 | - static $autsanscookie = ['install', 'base_repair']; |
|
| 1754 | + static $autsanscookie = ['install', 'base_repair']; |
|
| 1756 | 1755 | |
| 1757 | - if (in_array($nom, $autsanscookie)) { |
|
| 1758 | - if (test_espace_prive()) { |
|
| 1759 | - include_spip('base/connect_sql'); |
|
| 1760 | - if (!$strict or !spip_connect()) { |
|
| 1761 | - return true; |
|
| 1762 | - } |
|
| 1763 | - } |
|
| 1764 | - } |
|
| 1765 | - return false; |
|
| 1756 | + if (in_array($nom, $autsanscookie)) { |
|
| 1757 | + if (test_espace_prive()) { |
|
| 1758 | + include_spip('base/connect_sql'); |
|
| 1759 | + if (!$strict or !spip_connect()) { |
|
| 1760 | + return true; |
|
| 1761 | + } |
|
| 1762 | + } |
|
| 1763 | + } |
|
| 1764 | + return false; |
|
| 1766 | 1765 | } |
| 1767 | 1766 | |
| 1768 | 1767 | /** |
@@ -1788,95 +1787,95 @@ discard block |
||
| 1788 | 1787 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip) |
| 1789 | 1788 | */ |
| 1790 | 1789 | function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 1791 | - if ($public === null) { |
|
| 1792 | - $public = !test_espace_prive(); |
|
| 1793 | - } |
|
| 1794 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1795 | - |
|
| 1796 | - if (!$public) { |
|
| 1797 | - if (!$entite) { |
|
| 1798 | - return ''; |
|
| 1799 | - } |
|
| 1800 | - if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1801 | - include_spip('inc/urls'); |
|
| 1802 | - } |
|
| 1803 | - $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1804 | - } else { |
|
| 1805 | - if ($type === null) { |
|
| 1806 | - $type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1807 | - } |
|
| 1808 | - |
|
| 1809 | - $f = charger_fonction($type, 'urls', true); |
|
| 1810 | - // se rabattre sur les urls page si les urls perso non dispo |
|
| 1811 | - if (!$f) { |
|
| 1812 | - $f = charger_fonction('page', 'urls', true); |
|
| 1813 | - } |
|
| 1814 | - |
|
| 1815 | - // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1816 | - // sinon on veut effectuer le passage id ==> URL |
|
| 1817 | - if (!$entite) { |
|
| 1818 | - return $f; |
|
| 1819 | - } |
|
| 1820 | - |
|
| 1821 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1822 | - // base distante |
|
| 1823 | - if ( |
|
| 1824 | - is_string($public) |
|
| 1825 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1826 | - ) { |
|
| 1827 | - $f = $g; |
|
| 1828 | - } |
|
| 1829 | - |
|
| 1830 | - $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1831 | - } |
|
| 1832 | - if ($res) { |
|
| 1833 | - return $res; |
|
| 1834 | - } |
|
| 1835 | - // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1836 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1837 | - if (!function_exists($f .= '_dist')) { |
|
| 1838 | - $f = ''; |
|
| 1839 | - } |
|
| 1840 | - } |
|
| 1841 | - if ($f) { |
|
| 1842 | - $url = $f($id, $args, $ancre); |
|
| 1843 | - if (strlen($args)) { |
|
| 1844 | - $url .= strstr($url, '?') |
|
| 1845 | - ? '&' . $args |
|
| 1846 | - : '?' . $args; |
|
| 1847 | - } |
|
| 1848 | - |
|
| 1849 | - return $url; |
|
| 1850 | - } |
|
| 1851 | - // On a ete gentil mais la .... |
|
| 1852 | - spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1853 | - |
|
| 1854 | - return ''; |
|
| 1790 | + if ($public === null) { |
|
| 1791 | + $public = !test_espace_prive(); |
|
| 1792 | + } |
|
| 1793 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1794 | + |
|
| 1795 | + if (!$public) { |
|
| 1796 | + if (!$entite) { |
|
| 1797 | + return ''; |
|
| 1798 | + } |
|
| 1799 | + if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1800 | + include_spip('inc/urls'); |
|
| 1801 | + } |
|
| 1802 | + $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1803 | + } else { |
|
| 1804 | + if ($type === null) { |
|
| 1805 | + $type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1806 | + } |
|
| 1807 | + |
|
| 1808 | + $f = charger_fonction($type, 'urls', true); |
|
| 1809 | + // se rabattre sur les urls page si les urls perso non dispo |
|
| 1810 | + if (!$f) { |
|
| 1811 | + $f = charger_fonction('page', 'urls', true); |
|
| 1812 | + } |
|
| 1813 | + |
|
| 1814 | + // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1815 | + // sinon on veut effectuer le passage id ==> URL |
|
| 1816 | + if (!$entite) { |
|
| 1817 | + return $f; |
|
| 1818 | + } |
|
| 1819 | + |
|
| 1820 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1821 | + // base distante |
|
| 1822 | + if ( |
|
| 1823 | + is_string($public) |
|
| 1824 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1825 | + ) { |
|
| 1826 | + $f = $g; |
|
| 1827 | + } |
|
| 1828 | + |
|
| 1829 | + $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1830 | + } |
|
| 1831 | + if ($res) { |
|
| 1832 | + return $res; |
|
| 1833 | + } |
|
| 1834 | + // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1835 | + if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1836 | + if (!function_exists($f .= '_dist')) { |
|
| 1837 | + $f = ''; |
|
| 1838 | + } |
|
| 1839 | + } |
|
| 1840 | + if ($f) { |
|
| 1841 | + $url = $f($id, $args, $ancre); |
|
| 1842 | + if (strlen($args)) { |
|
| 1843 | + $url .= strstr($url, '?') |
|
| 1844 | + ? '&' . $args |
|
| 1845 | + : '?' . $args; |
|
| 1846 | + } |
|
| 1847 | + |
|
| 1848 | + return $url; |
|
| 1849 | + } |
|
| 1850 | + // On a ete gentil mais la .... |
|
| 1851 | + spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1852 | + |
|
| 1853 | + return ''; |
|
| 1855 | 1854 | } |
| 1856 | 1855 | |
| 1857 | 1856 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
| 1858 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1859 | - $url = generer_url_ecrire($exec, $args); |
|
| 1860 | - if (intval($id)) { |
|
| 1861 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1862 | - } else { |
|
| 1863 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1864 | - } |
|
| 1865 | - if ($ancre) { |
|
| 1866 | - $url = ancre_url($url, $ancre); |
|
| 1867 | - } |
|
| 1857 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1858 | + $url = generer_url_ecrire($exec, $args); |
|
| 1859 | + if (intval($id)) { |
|
| 1860 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1861 | + } else { |
|
| 1862 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1863 | + } |
|
| 1864 | + if ($ancre) { |
|
| 1865 | + $url = ancre_url($url, $ancre); |
|
| 1866 | + } |
|
| 1868 | 1867 | |
| 1869 | - return $url; |
|
| 1868 | + return $url; |
|
| 1870 | 1869 | } |
| 1871 | 1870 | |
| 1872 | 1871 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1873 | - include_spip('base/connect_sql'); |
|
| 1874 | - $id_type = id_table_objet($entite, $public); |
|
| 1872 | + include_spip('base/connect_sql'); |
|
| 1873 | + $id_type = id_table_objet($entite, $public); |
|
| 1875 | 1874 | |
| 1876 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1877 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1878 | - . (!$args ? '' : "&$args") |
|
| 1879 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1875 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1876 | + . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1877 | + . (!$args ? '' : "&$args") |
|
| 1878 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1880 | 1879 | } |
| 1881 | 1880 | |
| 1882 | 1881 | |
@@ -1887,31 +1886,31 @@ discard block |
||
| 1887 | 1886 | * @return string |
| 1888 | 1887 | */ |
| 1889 | 1888 | function urlencode_1738($url) { |
| 1890 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1891 | - $uri = ''; |
|
| 1892 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1893 | - if (ord($a = $url[$i]) > 127) { |
|
| 1894 | - $a = rawurlencode($a); |
|
| 1895 | - } |
|
| 1896 | - $uri .= $a; |
|
| 1897 | - } |
|
| 1898 | - $url = $uri; |
|
| 1899 | - } |
|
| 1889 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1890 | + $uri = ''; |
|
| 1891 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1892 | + if (ord($a = $url[$i]) > 127) { |
|
| 1893 | + $a = rawurlencode($a); |
|
| 1894 | + } |
|
| 1895 | + $uri .= $a; |
|
| 1896 | + } |
|
| 1897 | + $url = $uri; |
|
| 1898 | + } |
|
| 1900 | 1899 | |
| 1901 | - return quote_amp($url); |
|
| 1900 | + return quote_amp($url); |
|
| 1902 | 1901 | } |
| 1903 | 1902 | |
| 1904 | 1903 | function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) { |
| 1905 | - if (!$connect) { |
|
| 1906 | - $connect = true; |
|
| 1907 | - } |
|
| 1908 | - $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1909 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1910 | - include_spip('inc/filtres_mini'); |
|
| 1911 | - $h = url_absolue($h); |
|
| 1912 | - } |
|
| 1904 | + if (!$connect) { |
|
| 1905 | + $connect = true; |
|
| 1906 | + } |
|
| 1907 | + $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1908 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1909 | + include_spip('inc/filtres_mini'); |
|
| 1910 | + $h = url_absolue($h); |
|
| 1911 | + } |
|
| 1913 | 1912 | |
| 1914 | - return $h; |
|
| 1913 | + return $h; |
|
| 1915 | 1914 | } |
| 1916 | 1915 | |
| 1917 | 1916 | |
@@ -1927,11 +1926,11 @@ discard block |
||
| 1927 | 1926 | * true si la valeur est considérée active ; false sinon. |
| 1928 | 1927 | **/ |
| 1929 | 1928 | function test_valeur_serveur($truc) { |
| 1930 | - if (!$truc) { |
|
| 1931 | - return false; |
|
| 1932 | - } |
|
| 1929 | + if (!$truc) { |
|
| 1930 | + return false; |
|
| 1931 | + } |
|
| 1933 | 1932 | |
| 1934 | - return (strtolower($truc) !== 'off'); |
|
| 1933 | + return (strtolower($truc) !== 'off'); |
|
| 1935 | 1934 | } |
| 1936 | 1935 | |
| 1937 | 1936 | // |
@@ -1959,82 +1958,82 @@ discard block |
||
| 1959 | 1958 | */ |
| 1960 | 1959 | function url_de_base($profondeur = null) { |
| 1961 | 1960 | |
| 1962 | - static $url = []; |
|
| 1963 | - if (is_array($profondeur)) { |
|
| 1964 | - return $url = $profondeur; |
|
| 1965 | - } |
|
| 1966 | - if ($profondeur === false) { |
|
| 1967 | - return $url; |
|
| 1968 | - } |
|
| 1969 | - |
|
| 1970 | - if (is_null($profondeur)) { |
|
| 1971 | - $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 1972 | - } |
|
| 1973 | - |
|
| 1974 | - if (isset($url[$profondeur])) { |
|
| 1975 | - return $url[$profondeur]; |
|
| 1976 | - } |
|
| 1977 | - |
|
| 1978 | - $http = 'http'; |
|
| 1979 | - |
|
| 1980 | - if ( |
|
| 1981 | - isset($_SERVER['SCRIPT_URI']) |
|
| 1982 | - and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 1983 | - ) { |
|
| 1984 | - $http = 'https'; |
|
| 1985 | - } elseif ( |
|
| 1986 | - isset($_SERVER['HTTPS']) |
|
| 1987 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1988 | - ) { |
|
| 1989 | - $http = 'https'; |
|
| 1990 | - } |
|
| 1991 | - |
|
| 1992 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 1993 | - $host = $_SERVER['HTTP_HOST'] ?? null; |
|
| 1994 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1995 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1996 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 1997 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1998 | - $http = $scheme; |
|
| 1999 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 2000 | - } |
|
| 2001 | - } |
|
| 2002 | - if ( |
|
| 2003 | - isset($_SERVER['SERVER_PORT']) |
|
| 2004 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 2005 | - and strpos($host, ':') == false |
|
| 2006 | - ) { |
|
| 2007 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2008 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 2009 | - } |
|
| 2010 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2011 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2012 | - } |
|
| 2013 | - if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2014 | - $host .= ":$port"; |
|
| 2015 | - } |
|
| 2016 | - if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2017 | - $host .= ":$port"; |
|
| 2018 | - } |
|
| 2019 | - } |
|
| 2020 | - |
|
| 2021 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 2022 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2023 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2024 | - } else { |
|
| 2025 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2026 | - if ( |
|
| 2027 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2028 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2029 | - ) { |
|
| 2030 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2031 | - } |
|
| 2032 | - } |
|
| 2033 | - } |
|
| 2034 | - |
|
| 2035 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2036 | - |
|
| 2037 | - return $url[$profondeur]; |
|
| 1961 | + static $url = []; |
|
| 1962 | + if (is_array($profondeur)) { |
|
| 1963 | + return $url = $profondeur; |
|
| 1964 | + } |
|
| 1965 | + if ($profondeur === false) { |
|
| 1966 | + return $url; |
|
| 1967 | + } |
|
| 1968 | + |
|
| 1969 | + if (is_null($profondeur)) { |
|
| 1970 | + $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 1971 | + } |
|
| 1972 | + |
|
| 1973 | + if (isset($url[$profondeur])) { |
|
| 1974 | + return $url[$profondeur]; |
|
| 1975 | + } |
|
| 1976 | + |
|
| 1977 | + $http = 'http'; |
|
| 1978 | + |
|
| 1979 | + if ( |
|
| 1980 | + isset($_SERVER['SCRIPT_URI']) |
|
| 1981 | + and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 1982 | + ) { |
|
| 1983 | + $http = 'https'; |
|
| 1984 | + } elseif ( |
|
| 1985 | + isset($_SERVER['HTTPS']) |
|
| 1986 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1987 | + ) { |
|
| 1988 | + $http = 'https'; |
|
| 1989 | + } |
|
| 1990 | + |
|
| 1991 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 1992 | + $host = $_SERVER['HTTP_HOST'] ?? null; |
|
| 1993 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1994 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1995 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 1996 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1997 | + $http = $scheme; |
|
| 1998 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 1999 | + } |
|
| 2000 | + } |
|
| 2001 | + if ( |
|
| 2002 | + isset($_SERVER['SERVER_PORT']) |
|
| 2003 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 2004 | + and strpos($host, ':') == false |
|
| 2005 | + ) { |
|
| 2006 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2007 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 2008 | + } |
|
| 2009 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2010 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2011 | + } |
|
| 2012 | + if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2013 | + $host .= ":$port"; |
|
| 2014 | + } |
|
| 2015 | + if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2016 | + $host .= ":$port"; |
|
| 2017 | + } |
|
| 2018 | + } |
|
| 2019 | + |
|
| 2020 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 2021 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2022 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2023 | + } else { |
|
| 2024 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2025 | + if ( |
|
| 2026 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2027 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2028 | + ) { |
|
| 2029 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2030 | + } |
|
| 2031 | + } |
|
| 2032 | + } |
|
| 2033 | + |
|
| 2034 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2035 | + |
|
| 2036 | + return $url[$profondeur]; |
|
| 2038 | 2037 | } |
| 2039 | 2038 | |
| 2040 | 2039 | /** |
@@ -2047,26 +2046,26 @@ discard block |
||
| 2047 | 2046 | * @return string |
| 2048 | 2047 | */ |
| 2049 | 2048 | function url_de_($http, $host, $request, $prof = 0) { |
| 2050 | - $prof = max($prof, 0); |
|
| 2049 | + $prof = max($prof, 0); |
|
| 2051 | 2050 | |
| 2052 | - $myself = ltrim($request, '/'); |
|
| 2053 | - # supprimer la chaine de GET |
|
| 2054 | - [$myself] = explode('?', $myself); |
|
| 2055 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2056 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2057 | - if (strpos($myself, '://') !== false) { |
|
| 2058 | - $myself = explode('://', $myself); |
|
| 2059 | - array_shift($myself); |
|
| 2060 | - $myself = implode('://', $myself); |
|
| 2061 | - $myself = explode('/', $myself); |
|
| 2062 | - array_shift($myself); |
|
| 2063 | - $myself = implode('/', $myself); |
|
| 2064 | - } |
|
| 2065 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2051 | + $myself = ltrim($request, '/'); |
|
| 2052 | + # supprimer la chaine de GET |
|
| 2053 | + [$myself] = explode('?', $myself); |
|
| 2054 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2055 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2056 | + if (strpos($myself, '://') !== false) { |
|
| 2057 | + $myself = explode('://', $myself); |
|
| 2058 | + array_shift($myself); |
|
| 2059 | + $myself = implode('://', $myself); |
|
| 2060 | + $myself = explode('/', $myself); |
|
| 2061 | + array_shift($myself); |
|
| 2062 | + $myself = implode('/', $myself); |
|
| 2063 | + } |
|
| 2064 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2066 | 2065 | |
| 2067 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2066 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2068 | 2067 | |
| 2069 | - return $url; |
|
| 2068 | + return $url; |
|
| 2070 | 2069 | } |
| 2071 | 2070 | |
| 2072 | 2071 | |
@@ -2101,25 +2100,25 @@ discard block |
||
| 2101 | 2100 | * @return string URL |
| 2102 | 2101 | **/ |
| 2103 | 2102 | function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) { |
| 2104 | - if (!$rel) { |
|
| 2105 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2106 | - } else { |
|
| 2107 | - if (!is_string($rel)) { |
|
| 2108 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2109 | - } |
|
| 2110 | - } |
|
| 2111 | - |
|
| 2112 | - [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2113 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2114 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2115 | - } elseif ($args) { |
|
| 2116 | - $args = "?$args"; |
|
| 2117 | - } |
|
| 2118 | - if ($ancre) { |
|
| 2119 | - $args .= "#$ancre"; |
|
| 2120 | - } |
|
| 2121 | - |
|
| 2122 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2103 | + if (!$rel) { |
|
| 2104 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2105 | + } else { |
|
| 2106 | + if (!is_string($rel)) { |
|
| 2107 | + $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2108 | + } |
|
| 2109 | + } |
|
| 2110 | + |
|
| 2111 | + [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2112 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2113 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2114 | + } elseif ($args) { |
|
| 2115 | + $args = "?$args"; |
|
| 2116 | + } |
|
| 2117 | + if ($ancre) { |
|
| 2118 | + $args .= "#$ancre"; |
|
| 2119 | + } |
|
| 2120 | + |
|
| 2121 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2123 | 2122 | } |
| 2124 | 2123 | |
| 2125 | 2124 | // |
@@ -2141,15 +2140,15 @@ discard block |
||
| 2141 | 2140 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2142 | 2141 | **/ |
| 2143 | 2142 | function get_spip_script($default = '') { |
| 2144 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2145 | - return 'spip.php'; |
|
| 2146 | - } |
|
| 2147 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2148 | - if (_SPIP_SCRIPT) { |
|
| 2149 | - return _SPIP_SCRIPT; |
|
| 2150 | - } else { |
|
| 2151 | - return $default; |
|
| 2152 | - } |
|
| 2143 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2144 | + return 'spip.php'; |
|
| 2145 | + } |
|
| 2146 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2147 | + if (_SPIP_SCRIPT) { |
|
| 2148 | + return _SPIP_SCRIPT; |
|
| 2149 | + } else { |
|
| 2150 | + return $default; |
|
| 2151 | + } |
|
| 2153 | 2152 | } |
| 2154 | 2153 | |
| 2155 | 2154 | /** |
@@ -2178,38 +2177,38 @@ discard block |
||
| 2178 | 2177 | * @return string URL |
| 2179 | 2178 | **/ |
| 2180 | 2179 | function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') { |
| 2181 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2182 | - // standardiser vers la nouvelle API |
|
| 2183 | - |
|
| 2184 | - if (!$action) { |
|
| 2185 | - $action = get_spip_script(); |
|
| 2186 | - } |
|
| 2187 | - if ($script) { |
|
| 2188 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2189 | - } |
|
| 2190 | - |
|
| 2191 | - if ($args) { |
|
| 2192 | - if (is_array($args)) { |
|
| 2193 | - $r = ''; |
|
| 2194 | - foreach ($args as $k => $v) { |
|
| 2195 | - $r .= '&' . $k . '=' . $v; |
|
| 2196 | - } |
|
| 2197 | - $args = substr($r, 1); |
|
| 2198 | - } |
|
| 2199 | - $action .= |
|
| 2200 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2201 | - } |
|
| 2202 | - if (!$no_entities) { |
|
| 2203 | - $action = quote_amp($action); |
|
| 2204 | - } |
|
| 2205 | - |
|
| 2206 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2207 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2180 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2181 | + // standardiser vers la nouvelle API |
|
| 2182 | + |
|
| 2183 | + if (!$action) { |
|
| 2184 | + $action = get_spip_script(); |
|
| 2185 | + } |
|
| 2186 | + if ($script) { |
|
| 2187 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2188 | + } |
|
| 2189 | + |
|
| 2190 | + if ($args) { |
|
| 2191 | + if (is_array($args)) { |
|
| 2192 | + $r = ''; |
|
| 2193 | + foreach ($args as $k => $v) { |
|
| 2194 | + $r .= '&' . $k . '=' . $v; |
|
| 2195 | + } |
|
| 2196 | + $args = substr($r, 1); |
|
| 2197 | + } |
|
| 2198 | + $action .= |
|
| 2199 | + (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2200 | + } |
|
| 2201 | + if (!$no_entities) { |
|
| 2202 | + $action = quote_amp($action); |
|
| 2203 | + } |
|
| 2204 | + |
|
| 2205 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2206 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2208 | 2207 | } |
| 2209 | 2208 | |
| 2210 | 2209 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2211 | 2210 | |
| 2212 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2211 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2213 | 2212 | } |
| 2214 | 2213 | |
| 2215 | 2214 | // Pour les formulaires en methode POST, |
@@ -2234,19 +2233,19 @@ discard block |
||
| 2234 | 2233 | **/ |
| 2235 | 2234 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2236 | 2235 | |
| 2237 | - $script1 = explode('&', $script); |
|
| 2238 | - $script1 = reset($script1); |
|
| 2236 | + $script1 = explode('&', $script); |
|
| 2237 | + $script1 = reset($script1); |
|
| 2239 | 2238 | |
| 2240 | - return "<form action='" |
|
| 2241 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2242 | - . "' " |
|
| 2243 | - . ($atts ?: " method='post'") |
|
| 2244 | - . "><div>\n" |
|
| 2245 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2246 | - . $corps |
|
| 2247 | - . (!$submit ? '' : |
|
| 2248 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2249 | - . "</div></form>\n"; |
|
| 2239 | + return "<form action='" |
|
| 2240 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2241 | + . "' " |
|
| 2242 | + . ($atts ?: " method='post'") |
|
| 2243 | + . "><div>\n" |
|
| 2244 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2245 | + . $corps |
|
| 2246 | + . (!$submit ? '' : |
|
| 2247 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2248 | + . "</div></form>\n"; |
|
| 2250 | 2249 | } |
| 2251 | 2250 | |
| 2252 | 2251 | /** |
@@ -2263,22 +2262,22 @@ discard block |
||
| 2263 | 2262 | * @return string |
| 2264 | 2263 | */ |
| 2265 | 2264 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2266 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2267 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2268 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2269 | - $h = (_DIR_RACINE and !$public) |
|
| 2270 | - ? generer_url_ecrire(_request('exec')) |
|
| 2271 | - : generer_url_public(); |
|
| 2265 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2266 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2267 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2268 | + $h = (_DIR_RACINE and !$public) |
|
| 2269 | + ? generer_url_ecrire(_request('exec')) |
|
| 2270 | + : generer_url_public(); |
|
| 2272 | 2271 | |
| 2273 | - return "\n<form action='" . |
|
| 2274 | - $h . |
|
| 2275 | - "'" . |
|
| 2276 | - $atts . |
|
| 2277 | - ">\n" . |
|
| 2278 | - '<div>' . |
|
| 2279 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2280 | - $corps . |
|
| 2281 | - '</div></form>'; |
|
| 2272 | + return "\n<form action='" . |
|
| 2273 | + $h . |
|
| 2274 | + "'" . |
|
| 2275 | + $atts . |
|
| 2276 | + ">\n" . |
|
| 2277 | + '<div>' . |
|
| 2278 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2279 | + $corps . |
|
| 2280 | + '</div></form>'; |
|
| 2282 | 2281 | } |
| 2283 | 2282 | |
| 2284 | 2283 | /** |
@@ -2297,22 +2296,22 @@ discard block |
||
| 2297 | 2296 | * URL |
| 2298 | 2297 | */ |
| 2299 | 2298 | function generer_url_action($script, $args = '', $no_entities = false, $public = false) { |
| 2300 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2301 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2302 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2303 | - $url = (_DIR_RACINE and !$public) |
|
| 2304 | - ? generer_url_ecrire(_request('exec')) |
|
| 2305 | - : generer_url_public('', '', false, false); |
|
| 2306 | - $url = parametre_url($url, 'action', $script); |
|
| 2307 | - if ($args) { |
|
| 2308 | - $url .= quote_amp('&' . $args); |
|
| 2309 | - } |
|
| 2299 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2300 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2301 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2302 | + $url = (_DIR_RACINE and !$public) |
|
| 2303 | + ? generer_url_ecrire(_request('exec')) |
|
| 2304 | + : generer_url_public('', '', false, false); |
|
| 2305 | + $url = parametre_url($url, 'action', $script); |
|
| 2306 | + if ($args) { |
|
| 2307 | + $url .= quote_amp('&' . $args); |
|
| 2308 | + } |
|
| 2310 | 2309 | |
| 2311 | - if ($no_entities) { |
|
| 2312 | - $url = str_replace('&', '&', $url); |
|
| 2313 | - } |
|
| 2310 | + if ($no_entities) { |
|
| 2311 | + $url = str_replace('&', '&', $url); |
|
| 2312 | + } |
|
| 2314 | 2313 | |
| 2315 | - return $url; |
|
| 2314 | + return $url; |
|
| 2316 | 2315 | } |
| 2317 | 2316 | |
| 2318 | 2317 | |
@@ -2325,8 +2324,8 @@ discard block |
||
| 2325 | 2324 | * @param string $ta Répertoire temporaire accessible |
| 2326 | 2325 | */ |
| 2327 | 2326 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2328 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2329 | - spip_initialisation_suite(); |
|
| 2327 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2328 | + spip_initialisation_suite(); |
|
| 2330 | 2329 | } |
| 2331 | 2330 | |
| 2332 | 2331 | /** |
@@ -2346,322 +2345,322 @@ discard block |
||
| 2346 | 2345 | * @param string $ta Répertoire temporaire accessible |
| 2347 | 2346 | */ |
| 2348 | 2347 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2349 | - static $too_late = 0; |
|
| 2350 | - if ($too_late++) { |
|
| 2351 | - return; |
|
| 2352 | - } |
|
| 2353 | - |
|
| 2354 | - // Declaration des repertoires |
|
| 2355 | - |
|
| 2356 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2357 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2358 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2359 | - } |
|
| 2360 | - |
|
| 2361 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2362 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2363 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2364 | - } |
|
| 2365 | - |
|
| 2366 | - // le nom du repertoire des librairies |
|
| 2367 | - if (!defined('_DIR_LIB')) { |
|
| 2368 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2369 | - } |
|
| 2370 | - |
|
| 2371 | - if (!defined('_DIR_IMG')) { |
|
| 2372 | - define('_DIR_IMG', $pa); |
|
| 2373 | - } |
|
| 2374 | - if (!defined('_DIR_LOGOS')) { |
|
| 2375 | - define('_DIR_LOGOS', $pa); |
|
| 2376 | - } |
|
| 2377 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2378 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2379 | - } |
|
| 2380 | - |
|
| 2381 | - if (!defined('_DIR_DUMP')) { |
|
| 2382 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2383 | - } |
|
| 2384 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2385 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2386 | - } |
|
| 2387 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2388 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2389 | - } |
|
| 2390 | - if (!defined('_DIR_CACHE')) { |
|
| 2391 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2392 | - } |
|
| 2393 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2394 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2395 | - } |
|
| 2396 | - if (!defined('_DIR_SKELS')) { |
|
| 2397 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2398 | - } |
|
| 2399 | - if (!defined('_DIR_AIDE')) { |
|
| 2400 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2401 | - } |
|
| 2402 | - if (!defined('_DIR_TMP')) { |
|
| 2403 | - define('_DIR_TMP', $ti); |
|
| 2404 | - } |
|
| 2405 | - |
|
| 2406 | - if (!defined('_DIR_VAR')) { |
|
| 2407 | - define('_DIR_VAR', $ta); |
|
| 2408 | - } |
|
| 2409 | - |
|
| 2410 | - if (!defined('_DIR_ETC')) { |
|
| 2411 | - define('_DIR_ETC', $pi); |
|
| 2412 | - } |
|
| 2413 | - if (!defined('_DIR_CONNECT')) { |
|
| 2414 | - define('_DIR_CONNECT', $pi); |
|
| 2415 | - } |
|
| 2416 | - if (!defined('_DIR_CHMOD')) { |
|
| 2417 | - define('_DIR_CHMOD', $pi); |
|
| 2418 | - } |
|
| 2419 | - |
|
| 2420 | - if (!isset($GLOBALS['test_dirs'])) { |
|
| 2421 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2422 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2423 | - $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2424 | - } |
|
| 2425 | - |
|
| 2426 | - // Declaration des fichiers |
|
| 2427 | - |
|
| 2428 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2429 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2430 | - } |
|
| 2431 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2432 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2433 | - } |
|
| 2434 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2435 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2436 | - } |
|
| 2437 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2438 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2439 | - } |
|
| 2440 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2441 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2442 | - } |
|
| 2443 | - |
|
| 2444 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2445 | - if (!defined('_FILE_META')) { |
|
| 2446 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2447 | - } |
|
| 2448 | - if (!defined('_DIR_LOG')) { |
|
| 2449 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2450 | - } |
|
| 2451 | - if (!defined('_FILE_LOG')) { |
|
| 2452 | - define('_FILE_LOG', 'spip'); |
|
| 2453 | - } |
|
| 2454 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2455 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2456 | - } |
|
| 2457 | - |
|
| 2458 | - // Le fichier de connexion a la base de donnees |
|
| 2459 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2460 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2461 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2462 | - } |
|
| 2463 | - if (!defined('_FILE_CONNECT')) { |
|
| 2464 | - define( |
|
| 2465 | - '_FILE_CONNECT', |
|
| 2466 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2467 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2468 | - : false)) |
|
| 2469 | - ); |
|
| 2470 | - } |
|
| 2471 | - |
|
| 2472 | - // Le fichier de reglages des droits |
|
| 2473 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2474 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2475 | - } |
|
| 2476 | - if (!defined('_FILE_CHMOD')) { |
|
| 2477 | - define( |
|
| 2478 | - '_FILE_CHMOD', |
|
| 2479 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2480 | - : false) |
|
| 2481 | - ); |
|
| 2482 | - } |
|
| 2483 | - |
|
| 2484 | - if (!defined('_FILE_LDAP')) { |
|
| 2485 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2486 | - } |
|
| 2487 | - |
|
| 2488 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2489 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2490 | - } |
|
| 2491 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2492 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2493 | - } |
|
| 2494 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2495 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2496 | - } |
|
| 2497 | - |
|
| 2498 | - // Definition des droits d'acces en ecriture |
|
| 2499 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2500 | - include_once _FILE_CHMOD; |
|
| 2501 | - } |
|
| 2502 | - |
|
| 2503 | - // Se mefier des fichiers mal remplis! |
|
| 2504 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2505 | - define('_SPIP_CHMOD', 0777); |
|
| 2506 | - } |
|
| 2507 | - |
|
| 2508 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2509 | - /** Le charset par défaut lors de l'installation */ |
|
| 2510 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2511 | - } |
|
| 2512 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2513 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2514 | - } |
|
| 2515 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2516 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2517 | - } |
|
| 2518 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2519 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2520 | - } |
|
| 2521 | - |
|
| 2522 | - // La taille des Log |
|
| 2523 | - if (!defined('_MAX_LOG')) { |
|
| 2524 | - define('_MAX_LOG', 100); |
|
| 2525 | - } |
|
| 2526 | - |
|
| 2527 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2528 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2529 | - if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2530 | - if (!defined('_OS_SERVEUR')) { |
|
| 2531 | - define('_OS_SERVEUR', 'windows'); |
|
| 2532 | - } |
|
| 2533 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2534 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2535 | - } // utiliser le flock php |
|
| 2536 | - } else { |
|
| 2537 | - if (!defined('_OS_SERVEUR')) { |
|
| 2538 | - define('_OS_SERVEUR', ''); |
|
| 2539 | - } |
|
| 2540 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2541 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2542 | - } // utiliser le flock php |
|
| 2543 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2544 | - } |
|
| 2545 | - |
|
| 2546 | - // Langue par defaut |
|
| 2547 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2548 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2549 | - } |
|
| 2550 | - |
|
| 2551 | - // |
|
| 2552 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2553 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2554 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2555 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2556 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2557 | - |
|
| 2558 | - // charger tout de suite le path et son cache |
|
| 2559 | - load_path_cache(); |
|
| 2560 | - |
|
| 2561 | - // *********** traiter les variables ************ |
|
| 2562 | - |
|
| 2563 | - // |
|
| 2564 | - // Securite |
|
| 2565 | - // |
|
| 2566 | - |
|
| 2567 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2568 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2569 | - die(); |
|
| 2570 | - } |
|
| 2571 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2572 | - spip_desinfecte($_GET); |
|
| 2573 | - spip_desinfecte($_POST); |
|
| 2574 | - spip_desinfecte($_COOKIE); |
|
| 2575 | - spip_desinfecte($_REQUEST); |
|
| 2576 | - |
|
| 2577 | - // appliquer le cookie_prefix |
|
| 2578 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2579 | - include_spip('inc/cookie'); |
|
| 2580 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2581 | - } |
|
| 2582 | - |
|
| 2583 | - // |
|
| 2584 | - // Capacites php (en fonction de la version) |
|
| 2585 | - // |
|
| 2586 | - $GLOBALS['flag_ob'] = (function_exists('ob_start') |
|
| 2587 | - && function_exists('ini_get') |
|
| 2588 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2589 | - $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name'); |
|
| 2590 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ''); |
|
| 2591 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2592 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2593 | - |
|
| 2594 | - |
|
| 2595 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2596 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2597 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2598 | - } else { |
|
| 2599 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2600 | - if ( |
|
| 2601 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2602 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2603 | - ) { |
|
| 2604 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2605 | - } |
|
| 2606 | - } |
|
| 2607 | - |
|
| 2608 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2609 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2610 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2611 | - } |
|
| 2612 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2613 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2614 | - } |
|
| 2615 | - |
|
| 2616 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2617 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2618 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2619 | - $inc_meta(); |
|
| 2620 | - |
|
| 2621 | - // nombre de repertoires depuis la racine |
|
| 2622 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2623 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2624 | - // le calcul est faux) |
|
| 2625 | - if (!_DIR_RESTREINT) { |
|
| 2626 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2627 | - } else { |
|
| 2628 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2629 | - $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2630 | - if ( |
|
| 2631 | - !$uri_ref |
|
| 2632 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2633 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2634 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2635 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2636 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2637 | - ) { |
|
| 2638 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2639 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2640 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2641 | - } else { |
|
| 2642 | - $uri_ref = ''; |
|
| 2643 | - } |
|
| 2644 | - } |
|
| 2645 | - if (!$uri or !$uri_ref) { |
|
| 2646 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2647 | - } else { |
|
| 2648 | - $GLOBALS['profondeur_url'] = max( |
|
| 2649 | - 0, |
|
| 2650 | - substr_count($uri[0], '/') |
|
| 2651 | - - substr_count($uri_ref, '/') |
|
| 2652 | - ); |
|
| 2653 | - } |
|
| 2654 | - } |
|
| 2655 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2656 | - if (_FILE_CONNECT) { |
|
| 2657 | - if ( |
|
| 2658 | - verifier_visiteur() == '0minirezo' |
|
| 2659 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2660 | - and !isset($_COOKIE['spip_admin']) |
|
| 2661 | - ) { |
|
| 2662 | - clear_path_cache(); |
|
| 2663 | - } |
|
| 2664 | - } |
|
| 2348 | + static $too_late = 0; |
|
| 2349 | + if ($too_late++) { |
|
| 2350 | + return; |
|
| 2351 | + } |
|
| 2352 | + |
|
| 2353 | + // Declaration des repertoires |
|
| 2354 | + |
|
| 2355 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2356 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2357 | + define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2358 | + } |
|
| 2359 | + |
|
| 2360 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2361 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2362 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2363 | + } |
|
| 2364 | + |
|
| 2365 | + // le nom du repertoire des librairies |
|
| 2366 | + if (!defined('_DIR_LIB')) { |
|
| 2367 | + define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2368 | + } |
|
| 2369 | + |
|
| 2370 | + if (!defined('_DIR_IMG')) { |
|
| 2371 | + define('_DIR_IMG', $pa); |
|
| 2372 | + } |
|
| 2373 | + if (!defined('_DIR_LOGOS')) { |
|
| 2374 | + define('_DIR_LOGOS', $pa); |
|
| 2375 | + } |
|
| 2376 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2377 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2378 | + } |
|
| 2379 | + |
|
| 2380 | + if (!defined('_DIR_DUMP')) { |
|
| 2381 | + define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2382 | + } |
|
| 2383 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2384 | + define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2385 | + } |
|
| 2386 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2387 | + define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2388 | + } |
|
| 2389 | + if (!defined('_DIR_CACHE')) { |
|
| 2390 | + define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2391 | + } |
|
| 2392 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2393 | + define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2394 | + } |
|
| 2395 | + if (!defined('_DIR_SKELS')) { |
|
| 2396 | + define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2397 | + } |
|
| 2398 | + if (!defined('_DIR_AIDE')) { |
|
| 2399 | + define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2400 | + } |
|
| 2401 | + if (!defined('_DIR_TMP')) { |
|
| 2402 | + define('_DIR_TMP', $ti); |
|
| 2403 | + } |
|
| 2404 | + |
|
| 2405 | + if (!defined('_DIR_VAR')) { |
|
| 2406 | + define('_DIR_VAR', $ta); |
|
| 2407 | + } |
|
| 2408 | + |
|
| 2409 | + if (!defined('_DIR_ETC')) { |
|
| 2410 | + define('_DIR_ETC', $pi); |
|
| 2411 | + } |
|
| 2412 | + if (!defined('_DIR_CONNECT')) { |
|
| 2413 | + define('_DIR_CONNECT', $pi); |
|
| 2414 | + } |
|
| 2415 | + if (!defined('_DIR_CHMOD')) { |
|
| 2416 | + define('_DIR_CHMOD', $pi); |
|
| 2417 | + } |
|
| 2418 | + |
|
| 2419 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 2420 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2421 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2422 | + $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2423 | + } |
|
| 2424 | + |
|
| 2425 | + // Declaration des fichiers |
|
| 2426 | + |
|
| 2427 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2428 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2429 | + } |
|
| 2430 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2431 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2432 | + } |
|
| 2433 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2434 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2435 | + } |
|
| 2436 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2437 | + define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2438 | + } |
|
| 2439 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2440 | + define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2441 | + } |
|
| 2442 | + |
|
| 2443 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2444 | + if (!defined('_FILE_META')) { |
|
| 2445 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2446 | + } |
|
| 2447 | + if (!defined('_DIR_LOG')) { |
|
| 2448 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2449 | + } |
|
| 2450 | + if (!defined('_FILE_LOG')) { |
|
| 2451 | + define('_FILE_LOG', 'spip'); |
|
| 2452 | + } |
|
| 2453 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2454 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2455 | + } |
|
| 2456 | + |
|
| 2457 | + // Le fichier de connexion a la base de donnees |
|
| 2458 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2459 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2460 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2461 | + } |
|
| 2462 | + if (!defined('_FILE_CONNECT')) { |
|
| 2463 | + define( |
|
| 2464 | + '_FILE_CONNECT', |
|
| 2465 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2466 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2467 | + : false)) |
|
| 2468 | + ); |
|
| 2469 | + } |
|
| 2470 | + |
|
| 2471 | + // Le fichier de reglages des droits |
|
| 2472 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2473 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2474 | + } |
|
| 2475 | + if (!defined('_FILE_CHMOD')) { |
|
| 2476 | + define( |
|
| 2477 | + '_FILE_CHMOD', |
|
| 2478 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2479 | + : false) |
|
| 2480 | + ); |
|
| 2481 | + } |
|
| 2482 | + |
|
| 2483 | + if (!defined('_FILE_LDAP')) { |
|
| 2484 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2485 | + } |
|
| 2486 | + |
|
| 2487 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2488 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2489 | + } |
|
| 2490 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2491 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2492 | + } |
|
| 2493 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2494 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2495 | + } |
|
| 2496 | + |
|
| 2497 | + // Definition des droits d'acces en ecriture |
|
| 2498 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2499 | + include_once _FILE_CHMOD; |
|
| 2500 | + } |
|
| 2501 | + |
|
| 2502 | + // Se mefier des fichiers mal remplis! |
|
| 2503 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2504 | + define('_SPIP_CHMOD', 0777); |
|
| 2505 | + } |
|
| 2506 | + |
|
| 2507 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2508 | + /** Le charset par défaut lors de l'installation */ |
|
| 2509 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2510 | + } |
|
| 2511 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2512 | + define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2513 | + } |
|
| 2514 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2515 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2516 | + } |
|
| 2517 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2518 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2519 | + } |
|
| 2520 | + |
|
| 2521 | + // La taille des Log |
|
| 2522 | + if (!defined('_MAX_LOG')) { |
|
| 2523 | + define('_MAX_LOG', 100); |
|
| 2524 | + } |
|
| 2525 | + |
|
| 2526 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2527 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2528 | + if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2529 | + if (!defined('_OS_SERVEUR')) { |
|
| 2530 | + define('_OS_SERVEUR', 'windows'); |
|
| 2531 | + } |
|
| 2532 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2533 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2534 | + } // utiliser le flock php |
|
| 2535 | + } else { |
|
| 2536 | + if (!defined('_OS_SERVEUR')) { |
|
| 2537 | + define('_OS_SERVEUR', ''); |
|
| 2538 | + } |
|
| 2539 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2540 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2541 | + } // utiliser le flock php |
|
| 2542 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2543 | + } |
|
| 2544 | + |
|
| 2545 | + // Langue par defaut |
|
| 2546 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2547 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2548 | + } |
|
| 2549 | + |
|
| 2550 | + // |
|
| 2551 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2552 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2553 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2554 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2555 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2556 | + |
|
| 2557 | + // charger tout de suite le path et son cache |
|
| 2558 | + load_path_cache(); |
|
| 2559 | + |
|
| 2560 | + // *********** traiter les variables ************ |
|
| 2561 | + |
|
| 2562 | + // |
|
| 2563 | + // Securite |
|
| 2564 | + // |
|
| 2565 | + |
|
| 2566 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2567 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2568 | + die(); |
|
| 2569 | + } |
|
| 2570 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2571 | + spip_desinfecte($_GET); |
|
| 2572 | + spip_desinfecte($_POST); |
|
| 2573 | + spip_desinfecte($_COOKIE); |
|
| 2574 | + spip_desinfecte($_REQUEST); |
|
| 2575 | + |
|
| 2576 | + // appliquer le cookie_prefix |
|
| 2577 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2578 | + include_spip('inc/cookie'); |
|
| 2579 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2580 | + } |
|
| 2581 | + |
|
| 2582 | + // |
|
| 2583 | + // Capacites php (en fonction de la version) |
|
| 2584 | + // |
|
| 2585 | + $GLOBALS['flag_ob'] = (function_exists('ob_start') |
|
| 2586 | + && function_exists('ini_get') |
|
| 2587 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2588 | + $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name'); |
|
| 2589 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ''); |
|
| 2590 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2591 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2592 | + |
|
| 2593 | + |
|
| 2594 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2595 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2596 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2597 | + } else { |
|
| 2598 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2599 | + if ( |
|
| 2600 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2601 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2602 | + ) { |
|
| 2603 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2604 | + } |
|
| 2605 | + } |
|
| 2606 | + |
|
| 2607 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2608 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2609 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2610 | + } |
|
| 2611 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2612 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2613 | + } |
|
| 2614 | + |
|
| 2615 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2616 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2617 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2618 | + $inc_meta(); |
|
| 2619 | + |
|
| 2620 | + // nombre de repertoires depuis la racine |
|
| 2621 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2622 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2623 | + // le calcul est faux) |
|
| 2624 | + if (!_DIR_RESTREINT) { |
|
| 2625 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2626 | + } else { |
|
| 2627 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2628 | + $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2629 | + if ( |
|
| 2630 | + !$uri_ref |
|
| 2631 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2632 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2633 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2634 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2635 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2636 | + ) { |
|
| 2637 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2638 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2639 | + $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2640 | + } else { |
|
| 2641 | + $uri_ref = ''; |
|
| 2642 | + } |
|
| 2643 | + } |
|
| 2644 | + if (!$uri or !$uri_ref) { |
|
| 2645 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2646 | + } else { |
|
| 2647 | + $GLOBALS['profondeur_url'] = max( |
|
| 2648 | + 0, |
|
| 2649 | + substr_count($uri[0], '/') |
|
| 2650 | + - substr_count($uri_ref, '/') |
|
| 2651 | + ); |
|
| 2652 | + } |
|
| 2653 | + } |
|
| 2654 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2655 | + if (_FILE_CONNECT) { |
|
| 2656 | + if ( |
|
| 2657 | + verifier_visiteur() == '0minirezo' |
|
| 2658 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2659 | + and !isset($_COOKIE['spip_admin']) |
|
| 2660 | + ) { |
|
| 2661 | + clear_path_cache(); |
|
| 2662 | + } |
|
| 2663 | + } |
|
| 2665 | 2664 | } |
| 2666 | 2665 | |
| 2667 | 2666 | /** |
@@ -2670,190 +2669,190 @@ discard block |
||
| 2670 | 2669 | * |
| 2671 | 2670 | */ |
| 2672 | 2671 | function spip_initialisation_suite() { |
| 2673 | - static $too_late = 0; |
|
| 2674 | - if ($too_late++) { |
|
| 2675 | - return; |
|
| 2676 | - } |
|
| 2677 | - |
|
| 2678 | - // taille mini des login |
|
| 2679 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2680 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2681 | - } |
|
| 2682 | - |
|
| 2683 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2684 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2685 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2686 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2687 | - |
|
| 2688 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2689 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2690 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2691 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2692 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2693 | - |
|
| 2694 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2695 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2696 | - } |
|
| 2697 | - |
|
| 2698 | - // largeur maximale des images dans l'administration |
|
| 2699 | - if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2700 | - define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2701 | - } |
|
| 2702 | - |
|
| 2703 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2704 | - if (!defined('_IMG_QUALITE')) { |
|
| 2705 | - define('_IMG_QUALITE', 85); |
|
| 2706 | - } # valeur par defaut |
|
| 2707 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2708 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2709 | - } # surcharge pour la lib GD |
|
| 2710 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2711 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2712 | - } # surcharge pour imagick en ligne de commande |
|
| 2713 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2714 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2715 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2716 | - } # surcharge pour imagick en PHP |
|
| 2717 | - |
|
| 2718 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2719 | - define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2720 | - } // poids en octet |
|
| 2721 | - |
|
| 2722 | - // qq chaines standard |
|
| 2723 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2724 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2725 | - } |
|
| 2726 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2727 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2728 | - } |
|
| 2729 | - if (!defined('_SPIP_DUMP')) { |
|
| 2730 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2731 | - } |
|
| 2732 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2733 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2734 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2735 | - } |
|
| 2736 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2737 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2738 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2739 | - } |
|
| 2740 | - |
|
| 2741 | - if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2742 | - /** |
|
| 2743 | - * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2744 | - * @var int Nombre de caractères */ |
|
| 2745 | - define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2746 | - } |
|
| 2747 | - |
|
| 2748 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2749 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2750 | - } |
|
| 2751 | - |
|
| 2752 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2753 | - /** Définit le doctype de l’espace privé */ |
|
| 2754 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2755 | - } |
|
| 2756 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2757 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2758 | - define( |
|
| 2759 | - '_DOCTYPE_AIDE', |
|
| 2760 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2761 | - ); |
|
| 2762 | - } |
|
| 2763 | - |
|
| 2764 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2765 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2766 | - * le script de l'espace public, alias index.php */ |
|
| 2767 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2768 | - } |
|
| 2769 | - if (!defined('_SPIP_PAGE')) { |
|
| 2770 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2771 | - define('_SPIP_PAGE', 'page'); |
|
| 2772 | - } |
|
| 2773 | - |
|
| 2774 | - // le script de l'espace prive |
|
| 2775 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2776 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2777 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2778 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2779 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2780 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2781 | - } else { |
|
| 2782 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2783 | - } |
|
| 2784 | - } |
|
| 2785 | - |
|
| 2786 | - |
|
| 2787 | - if (!defined('_SPIP_AJAX')) { |
|
| 2788 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2789 | - ? 1 |
|
| 2790 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2791 | - } |
|
| 2792 | - |
|
| 2793 | - // La requete est-elle en ajax ? |
|
| 2794 | - if (!defined('_AJAX')) { |
|
| 2795 | - define( |
|
| 2796 | - '_AJAX', |
|
| 2797 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2798 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2799 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2800 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2801 | - ) |
|
| 2802 | - and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2803 | - ); |
|
| 2804 | - } |
|
| 2805 | - |
|
| 2806 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2807 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2808 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2809 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2810 | - define( |
|
| 2811 | - '_IMG_GD_MAX_PIXELS', |
|
| 2812 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2813 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2814 | - : 0 |
|
| 2815 | - ); |
|
| 2816 | - } |
|
| 2817 | - |
|
| 2818 | - if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2819 | - define('_MEMORY_LIMIT_MIN', 16); |
|
| 2820 | - } // en Mo |
|
| 2821 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2822 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2823 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2824 | - if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2825 | - if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2826 | - $unit = strtolower(substr($memory, -1)); |
|
| 2827 | - $memory = substr($memory, 0, -1); |
|
| 2828 | - switch ($unit) { |
|
| 2829 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2830 | - case 'g': |
|
| 2831 | - $memory *= 1024; |
|
| 2832 | - case 'm': |
|
| 2833 | - $memory *= 1024; |
|
| 2834 | - case 'k': |
|
| 2835 | - $memory *= 1024; |
|
| 2836 | - } |
|
| 2837 | - if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2838 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2839 | - if (trim(ini_get('memory_limit')) != $m) { |
|
| 2840 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2841 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2842 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2843 | - } |
|
| 2844 | - } |
|
| 2845 | - } else { |
|
| 2846 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2847 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2848 | - } |
|
| 2849 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2850 | - } |
|
| 2851 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2852 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2853 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2854 | - } |
|
| 2855 | - |
|
| 2856 | - init_var_mode(); |
|
| 2672 | + static $too_late = 0; |
|
| 2673 | + if ($too_late++) { |
|
| 2674 | + return; |
|
| 2675 | + } |
|
| 2676 | + |
|
| 2677 | + // taille mini des login |
|
| 2678 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2679 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2680 | + } |
|
| 2681 | + |
|
| 2682 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2683 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2684 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2685 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2686 | + |
|
| 2687 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2688 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2689 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2690 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2691 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2692 | + |
|
| 2693 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2694 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2695 | + } |
|
| 2696 | + |
|
| 2697 | + // largeur maximale des images dans l'administration |
|
| 2698 | + if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2699 | + define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2700 | + } |
|
| 2701 | + |
|
| 2702 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2703 | + if (!defined('_IMG_QUALITE')) { |
|
| 2704 | + define('_IMG_QUALITE', 85); |
|
| 2705 | + } # valeur par defaut |
|
| 2706 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2707 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2708 | + } # surcharge pour la lib GD |
|
| 2709 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2710 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2711 | + } # surcharge pour imagick en ligne de commande |
|
| 2712 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2713 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2714 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2715 | + } # surcharge pour imagick en PHP |
|
| 2716 | + |
|
| 2717 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2718 | + define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2719 | + } // poids en octet |
|
| 2720 | + |
|
| 2721 | + // qq chaines standard |
|
| 2722 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2723 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2724 | + } |
|
| 2725 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2726 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2727 | + } |
|
| 2728 | + if (!defined('_SPIP_DUMP')) { |
|
| 2729 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2730 | + } |
|
| 2731 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2732 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2733 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2734 | + } |
|
| 2735 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2736 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2737 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2738 | + } |
|
| 2739 | + |
|
| 2740 | + if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2741 | + /** |
|
| 2742 | + * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2743 | + * @var int Nombre de caractères */ |
|
| 2744 | + define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2745 | + } |
|
| 2746 | + |
|
| 2747 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2748 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2749 | + } |
|
| 2750 | + |
|
| 2751 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2752 | + /** Définit le doctype de l’espace privé */ |
|
| 2753 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2754 | + } |
|
| 2755 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2756 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2757 | + define( |
|
| 2758 | + '_DOCTYPE_AIDE', |
|
| 2759 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2760 | + ); |
|
| 2761 | + } |
|
| 2762 | + |
|
| 2763 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2764 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2765 | + * le script de l'espace public, alias index.php */ |
|
| 2766 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2767 | + } |
|
| 2768 | + if (!defined('_SPIP_PAGE')) { |
|
| 2769 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2770 | + define('_SPIP_PAGE', 'page'); |
|
| 2771 | + } |
|
| 2772 | + |
|
| 2773 | + // le script de l'espace prive |
|
| 2774 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2775 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2776 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2777 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2778 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2779 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2780 | + } else { |
|
| 2781 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2782 | + } |
|
| 2783 | + } |
|
| 2784 | + |
|
| 2785 | + |
|
| 2786 | + if (!defined('_SPIP_AJAX')) { |
|
| 2787 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2788 | + ? 1 |
|
| 2789 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2790 | + } |
|
| 2791 | + |
|
| 2792 | + // La requete est-elle en ajax ? |
|
| 2793 | + if (!defined('_AJAX')) { |
|
| 2794 | + define( |
|
| 2795 | + '_AJAX', |
|
| 2796 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2797 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2798 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2799 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2800 | + ) |
|
| 2801 | + and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2802 | + ); |
|
| 2803 | + } |
|
| 2804 | + |
|
| 2805 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2806 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2807 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2808 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2809 | + define( |
|
| 2810 | + '_IMG_GD_MAX_PIXELS', |
|
| 2811 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2812 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2813 | + : 0 |
|
| 2814 | + ); |
|
| 2815 | + } |
|
| 2816 | + |
|
| 2817 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2818 | + define('_MEMORY_LIMIT_MIN', 16); |
|
| 2819 | + } // en Mo |
|
| 2820 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2821 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2822 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2823 | + if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2824 | + if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2825 | + $unit = strtolower(substr($memory, -1)); |
|
| 2826 | + $memory = substr($memory, 0, -1); |
|
| 2827 | + switch ($unit) { |
|
| 2828 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2829 | + case 'g': |
|
| 2830 | + $memory *= 1024; |
|
| 2831 | + case 'm': |
|
| 2832 | + $memory *= 1024; |
|
| 2833 | + case 'k': |
|
| 2834 | + $memory *= 1024; |
|
| 2835 | + } |
|
| 2836 | + if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2837 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2838 | + if (trim(ini_get('memory_limit')) != $m) { |
|
| 2839 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2840 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2841 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2842 | + } |
|
| 2843 | + } |
|
| 2844 | + } else { |
|
| 2845 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2846 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2847 | + } |
|
| 2848 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2849 | + } |
|
| 2850 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2851 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2852 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2853 | + } |
|
| 2854 | + |
|
| 2855 | + init_var_mode(); |
|
| 2857 | 2856 | } |
| 2858 | 2857 | |
| 2859 | 2858 | /** |
@@ -2887,219 +2886,219 @@ discard block |
||
| 2887 | 2886 | * ` var_mode` (calcul ou recalcul). |
| 2888 | 2887 | */ |
| 2889 | 2888 | function init_var_mode() { |
| 2890 | - static $done = false; |
|
| 2891 | - if (!$done) { |
|
| 2892 | - if (isset($_GET['var_mode'])) { |
|
| 2893 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 2894 | - // tout le monde peut calcul/recalcul |
|
| 2895 | - if (!defined('_VAR_MODE')) { |
|
| 2896 | - if (in_array('recalcul', $var_mode)) { |
|
| 2897 | - define('_VAR_MODE', 'recalcul'); |
|
| 2898 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 2899 | - define('_VAR_MODE', 'calcul'); |
|
| 2900 | - } |
|
| 2901 | - } |
|
| 2902 | - $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 2903 | - if ($var_mode) { |
|
| 2904 | - include_spip('inc/autoriser'); |
|
| 2905 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2906 | - if ( |
|
| 2907 | - autoriser( |
|
| 2908 | - ($_GET['var_mode'] == 'preview') |
|
| 2909 | - ? 'previsualiser' |
|
| 2910 | - : 'debug' |
|
| 2911 | - ) |
|
| 2912 | - ) { |
|
| 2913 | - if (in_array('traduction', $var_mode)) { |
|
| 2914 | - // forcer le calcul pour passer dans traduire |
|
| 2915 | - if (!defined('_VAR_MODE')) { |
|
| 2916 | - define('_VAR_MODE', 'calcul'); |
|
| 2917 | - } |
|
| 2918 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2919 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2920 | - define('_VAR_NOCACHE', true); |
|
| 2921 | - } |
|
| 2922 | - $var_mode = array_diff($var_mode, ['traduction']); |
|
| 2923 | - } |
|
| 2924 | - if (in_array('preview', $var_mode)) { |
|
| 2925 | - // basculer sur les criteres de preview dans les boucles |
|
| 2926 | - if (!defined('_VAR_PREVIEW')) { |
|
| 2927 | - define('_VAR_PREVIEW', true); |
|
| 2928 | - } |
|
| 2929 | - // forcer le calcul |
|
| 2930 | - if (!defined('_VAR_MODE')) { |
|
| 2931 | - define('_VAR_MODE', 'calcul'); |
|
| 2932 | - } |
|
| 2933 | - // et ne pas enregistrer de cache |
|
| 2934 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2935 | - define('_VAR_NOCACHE', true); |
|
| 2936 | - } |
|
| 2937 | - $var_mode = array_diff($var_mode, ['preview']); |
|
| 2938 | - } |
|
| 2939 | - if (in_array('inclure', $var_mode)) { |
|
| 2940 | - // forcer le compilo et ignorer les caches existants |
|
| 2941 | - if (!defined('_VAR_MODE')) { |
|
| 2942 | - define('_VAR_MODE', 'calcul'); |
|
| 2943 | - } |
|
| 2944 | - if (!defined('_VAR_INCLURE')) { |
|
| 2945 | - define('_VAR_INCLURE', true); |
|
| 2946 | - } |
|
| 2947 | - // et ne pas enregistrer de cache |
|
| 2948 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2949 | - define('_VAR_NOCACHE', true); |
|
| 2950 | - } |
|
| 2951 | - $var_mode = array_diff($var_mode, ['inclure']); |
|
| 2952 | - } |
|
| 2953 | - if (in_array('urls', $var_mode)) { |
|
| 2954 | - // forcer le compilo et ignorer les caches existants |
|
| 2955 | - if (!defined('_VAR_MODE')) { |
|
| 2956 | - define('_VAR_MODE', 'calcul'); |
|
| 2957 | - } |
|
| 2958 | - if (!defined('_VAR_URLS')) { |
|
| 2959 | - define('_VAR_URLS', true); |
|
| 2960 | - } |
|
| 2961 | - $var_mode = array_diff($var_mode, ['urls']); |
|
| 2962 | - } |
|
| 2963 | - if (in_array('images', $var_mode)) { |
|
| 2964 | - // forcer le compilo et ignorer les caches existants |
|
| 2965 | - if (!defined('_VAR_MODE')) { |
|
| 2966 | - define('_VAR_MODE', 'calcul'); |
|
| 2967 | - } |
|
| 2968 | - // indiquer qu'on doit recalculer les images |
|
| 2969 | - if (!defined('_VAR_IMAGES')) { |
|
| 2970 | - define('_VAR_IMAGES', true); |
|
| 2971 | - } |
|
| 2972 | - $var_mode = array_diff($var_mode, ['images']); |
|
| 2973 | - } |
|
| 2974 | - if (in_array('debug', $var_mode)) { |
|
| 2975 | - if (!defined('_VAR_MODE')) { |
|
| 2976 | - define('_VAR_MODE', 'debug'); |
|
| 2977 | - } |
|
| 2978 | - // et ne pas enregistrer de cache |
|
| 2979 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2980 | - define('_VAR_NOCACHE', true); |
|
| 2981 | - } |
|
| 2982 | - $var_mode = array_diff($var_mode, ['debug']); |
|
| 2983 | - } |
|
| 2984 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2985 | - define('_VAR_MODE', reset($var_mode)); |
|
| 2986 | - } |
|
| 2987 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2988 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2989 | - . ' ' . _VAR_MODE); |
|
| 2990 | - } |
|
| 2991 | - } // pas autorise ? |
|
| 2992 | - else { |
|
| 2993 | - // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 2994 | - if ( |
|
| 2995 | - !$GLOBALS['visiteur_session'] |
|
| 2996 | - and !empty($_SERVER['HTTP_HOST']) |
|
| 2997 | - and !empty($_SERVER['REQUEST_METHOD']) |
|
| 2998 | - and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 2999 | - ) { |
|
| 3000 | - $self = self('&', true); |
|
| 3001 | - if (strpos($self, 'page=login') === false) { |
|
| 3002 | - include_spip('inc/headers'); |
|
| 3003 | - $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3004 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3005 | - } |
|
| 3006 | - } |
|
| 3007 | - // sinon tant pis |
|
| 3008 | - } |
|
| 3009 | - } |
|
| 3010 | - } |
|
| 3011 | - if (!defined('_VAR_MODE')) { |
|
| 3012 | - /** |
|
| 3013 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 3014 | - * @see init_var_mode() |
|
| 3015 | - */ |
|
| 3016 | - define('_VAR_MODE', false); |
|
| 3017 | - } |
|
| 3018 | - $done = true; |
|
| 3019 | - } |
|
| 2889 | + static $done = false; |
|
| 2890 | + if (!$done) { |
|
| 2891 | + if (isset($_GET['var_mode'])) { |
|
| 2892 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 2893 | + // tout le monde peut calcul/recalcul |
|
| 2894 | + if (!defined('_VAR_MODE')) { |
|
| 2895 | + if (in_array('recalcul', $var_mode)) { |
|
| 2896 | + define('_VAR_MODE', 'recalcul'); |
|
| 2897 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 2898 | + define('_VAR_MODE', 'calcul'); |
|
| 2899 | + } |
|
| 2900 | + } |
|
| 2901 | + $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 2902 | + if ($var_mode) { |
|
| 2903 | + include_spip('inc/autoriser'); |
|
| 2904 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2905 | + if ( |
|
| 2906 | + autoriser( |
|
| 2907 | + ($_GET['var_mode'] == 'preview') |
|
| 2908 | + ? 'previsualiser' |
|
| 2909 | + : 'debug' |
|
| 2910 | + ) |
|
| 2911 | + ) { |
|
| 2912 | + if (in_array('traduction', $var_mode)) { |
|
| 2913 | + // forcer le calcul pour passer dans traduire |
|
| 2914 | + if (!defined('_VAR_MODE')) { |
|
| 2915 | + define('_VAR_MODE', 'calcul'); |
|
| 2916 | + } |
|
| 2917 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2918 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2919 | + define('_VAR_NOCACHE', true); |
|
| 2920 | + } |
|
| 2921 | + $var_mode = array_diff($var_mode, ['traduction']); |
|
| 2922 | + } |
|
| 2923 | + if (in_array('preview', $var_mode)) { |
|
| 2924 | + // basculer sur les criteres de preview dans les boucles |
|
| 2925 | + if (!defined('_VAR_PREVIEW')) { |
|
| 2926 | + define('_VAR_PREVIEW', true); |
|
| 2927 | + } |
|
| 2928 | + // forcer le calcul |
|
| 2929 | + if (!defined('_VAR_MODE')) { |
|
| 2930 | + define('_VAR_MODE', 'calcul'); |
|
| 2931 | + } |
|
| 2932 | + // et ne pas enregistrer de cache |
|
| 2933 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2934 | + define('_VAR_NOCACHE', true); |
|
| 2935 | + } |
|
| 2936 | + $var_mode = array_diff($var_mode, ['preview']); |
|
| 2937 | + } |
|
| 2938 | + if (in_array('inclure', $var_mode)) { |
|
| 2939 | + // forcer le compilo et ignorer les caches existants |
|
| 2940 | + if (!defined('_VAR_MODE')) { |
|
| 2941 | + define('_VAR_MODE', 'calcul'); |
|
| 2942 | + } |
|
| 2943 | + if (!defined('_VAR_INCLURE')) { |
|
| 2944 | + define('_VAR_INCLURE', true); |
|
| 2945 | + } |
|
| 2946 | + // et ne pas enregistrer de cache |
|
| 2947 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2948 | + define('_VAR_NOCACHE', true); |
|
| 2949 | + } |
|
| 2950 | + $var_mode = array_diff($var_mode, ['inclure']); |
|
| 2951 | + } |
|
| 2952 | + if (in_array('urls', $var_mode)) { |
|
| 2953 | + // forcer le compilo et ignorer les caches existants |
|
| 2954 | + if (!defined('_VAR_MODE')) { |
|
| 2955 | + define('_VAR_MODE', 'calcul'); |
|
| 2956 | + } |
|
| 2957 | + if (!defined('_VAR_URLS')) { |
|
| 2958 | + define('_VAR_URLS', true); |
|
| 2959 | + } |
|
| 2960 | + $var_mode = array_diff($var_mode, ['urls']); |
|
| 2961 | + } |
|
| 2962 | + if (in_array('images', $var_mode)) { |
|
| 2963 | + // forcer le compilo et ignorer les caches existants |
|
| 2964 | + if (!defined('_VAR_MODE')) { |
|
| 2965 | + define('_VAR_MODE', 'calcul'); |
|
| 2966 | + } |
|
| 2967 | + // indiquer qu'on doit recalculer les images |
|
| 2968 | + if (!defined('_VAR_IMAGES')) { |
|
| 2969 | + define('_VAR_IMAGES', true); |
|
| 2970 | + } |
|
| 2971 | + $var_mode = array_diff($var_mode, ['images']); |
|
| 2972 | + } |
|
| 2973 | + if (in_array('debug', $var_mode)) { |
|
| 2974 | + if (!defined('_VAR_MODE')) { |
|
| 2975 | + define('_VAR_MODE', 'debug'); |
|
| 2976 | + } |
|
| 2977 | + // et ne pas enregistrer de cache |
|
| 2978 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2979 | + define('_VAR_NOCACHE', true); |
|
| 2980 | + } |
|
| 2981 | + $var_mode = array_diff($var_mode, ['debug']); |
|
| 2982 | + } |
|
| 2983 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2984 | + define('_VAR_MODE', reset($var_mode)); |
|
| 2985 | + } |
|
| 2986 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2987 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2988 | + . ' ' . _VAR_MODE); |
|
| 2989 | + } |
|
| 2990 | + } // pas autorise ? |
|
| 2991 | + else { |
|
| 2992 | + // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 2993 | + if ( |
|
| 2994 | + !$GLOBALS['visiteur_session'] |
|
| 2995 | + and !empty($_SERVER['HTTP_HOST']) |
|
| 2996 | + and !empty($_SERVER['REQUEST_METHOD']) |
|
| 2997 | + and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 2998 | + ) { |
|
| 2999 | + $self = self('&', true); |
|
| 3000 | + if (strpos($self, 'page=login') === false) { |
|
| 3001 | + include_spip('inc/headers'); |
|
| 3002 | + $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3003 | + redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3004 | + } |
|
| 3005 | + } |
|
| 3006 | + // sinon tant pis |
|
| 3007 | + } |
|
| 3008 | + } |
|
| 3009 | + } |
|
| 3010 | + if (!defined('_VAR_MODE')) { |
|
| 3011 | + /** |
|
| 3012 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 3013 | + * @see init_var_mode() |
|
| 3014 | + */ |
|
| 3015 | + define('_VAR_MODE', false); |
|
| 3016 | + } |
|
| 3017 | + $done = true; |
|
| 3018 | + } |
|
| 3020 | 3019 | } |
| 3021 | 3020 | |
| 3022 | 3021 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
| 3023 | 3022 | // supprimer aussi les eventuels caracteres nuls %00, qui peuvent tromper |
| 3024 | 3023 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 3025 | 3024 | function spip_desinfecte(&$t, $deep = true) { |
| 3026 | - foreach ($t as $key => $val) { |
|
| 3027 | - if (is_string($t[$key])) { |
|
| 3028 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3029 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 3030 | - else { |
|
| 3031 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3032 | - spip_desinfecte($t[$key], $deep); |
|
| 3033 | - } |
|
| 3034 | - } |
|
| 3035 | - } |
|
| 3025 | + foreach ($t as $key => $val) { |
|
| 3026 | + if (is_string($t[$key])) { |
|
| 3027 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3028 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 3029 | + else { |
|
| 3030 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3031 | + spip_desinfecte($t[$key], $deep); |
|
| 3032 | + } |
|
| 3033 | + } |
|
| 3034 | + } |
|
| 3036 | 3035 | } |
| 3037 | 3036 | |
| 3038 | 3037 | // retourne le statut du visiteur s'il s'annonce |
| 3039 | 3038 | |
| 3040 | 3039 | function verifier_visiteur() { |
| 3041 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 3042 | - // il faut forcer l'init si ce n'est fait |
|
| 3043 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3044 | - // certaines constantes |
|
| 3045 | - @spip_initialisation_core( |
|
| 3046 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3047 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3048 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3049 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3050 | - ); |
|
| 3051 | - |
|
| 3052 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3053 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3054 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 3055 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3056 | - $variables_session = ['session_nom', 'session_email']; |
|
| 3057 | - foreach ($variables_session as $var) { |
|
| 3058 | - if (_request($var) !== null) { |
|
| 3059 | - $init = true; |
|
| 3060 | - break; |
|
| 3061 | - } |
|
| 3062 | - } |
|
| 3063 | - if (isset($init)) { |
|
| 3064 | - #@spip_initialisation_suite(); |
|
| 3065 | - $session = charger_fonction('session', 'inc'); |
|
| 3066 | - $session(); |
|
| 3067 | - include_spip('inc/texte'); |
|
| 3068 | - foreach ($variables_session as $var) { |
|
| 3069 | - if (($a = _request($var)) !== null) { |
|
| 3070 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3071 | - } |
|
| 3072 | - } |
|
| 3073 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3074 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3075 | - } |
|
| 3076 | - $session($GLOBALS['visiteur_session']); |
|
| 3077 | - |
|
| 3078 | - return 0; |
|
| 3079 | - } |
|
| 3080 | - |
|
| 3081 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3082 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3083 | - $session = charger_fonction('session', 'inc'); |
|
| 3084 | - if ($session()) { |
|
| 3085 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3086 | - } |
|
| 3087 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3088 | - include_spip('inc/auth'); |
|
| 3089 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3090 | - } |
|
| 3091 | - if ($h) { |
|
| 3092 | - $GLOBALS['visiteur_session'] = $h; |
|
| 3093 | - |
|
| 3094 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3095 | - } |
|
| 3096 | - } |
|
| 3097 | - |
|
| 3098 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3099 | - include_spip('inc/lang'); |
|
| 3100 | - utiliser_langue_visiteur(); |
|
| 3101 | - |
|
| 3102 | - return false; |
|
| 3040 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 3041 | + // il faut forcer l'init si ce n'est fait |
|
| 3042 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3043 | + // certaines constantes |
|
| 3044 | + @spip_initialisation_core( |
|
| 3045 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3046 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3047 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3048 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3049 | + ); |
|
| 3050 | + |
|
| 3051 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3052 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3053 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 3054 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3055 | + $variables_session = ['session_nom', 'session_email']; |
|
| 3056 | + foreach ($variables_session as $var) { |
|
| 3057 | + if (_request($var) !== null) { |
|
| 3058 | + $init = true; |
|
| 3059 | + break; |
|
| 3060 | + } |
|
| 3061 | + } |
|
| 3062 | + if (isset($init)) { |
|
| 3063 | + #@spip_initialisation_suite(); |
|
| 3064 | + $session = charger_fonction('session', 'inc'); |
|
| 3065 | + $session(); |
|
| 3066 | + include_spip('inc/texte'); |
|
| 3067 | + foreach ($variables_session as $var) { |
|
| 3068 | + if (($a = _request($var)) !== null) { |
|
| 3069 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3070 | + } |
|
| 3071 | + } |
|
| 3072 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3073 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3074 | + } |
|
| 3075 | + $session($GLOBALS['visiteur_session']); |
|
| 3076 | + |
|
| 3077 | + return 0; |
|
| 3078 | + } |
|
| 3079 | + |
|
| 3080 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3081 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3082 | + $session = charger_fonction('session', 'inc'); |
|
| 3083 | + if ($session()) { |
|
| 3084 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3085 | + } |
|
| 3086 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3087 | + include_spip('inc/auth'); |
|
| 3088 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3089 | + } |
|
| 3090 | + if ($h) { |
|
| 3091 | + $GLOBALS['visiteur_session'] = $h; |
|
| 3092 | + |
|
| 3093 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3094 | + } |
|
| 3095 | + } |
|
| 3096 | + |
|
| 3097 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3098 | + include_spip('inc/lang'); |
|
| 3099 | + utiliser_langue_visiteur(); |
|
| 3100 | + |
|
| 3101 | + return false; |
|
| 3103 | 3102 | } |
| 3104 | 3103 | |
| 3105 | 3104 | |
@@ -3122,21 +3121,21 @@ discard block |
||
| 3122 | 3121 | * - string Langue utilisée. |
| 3123 | 3122 | **/ |
| 3124 | 3123 | function lang_select($lang = null) { |
| 3125 | - static $pile_langues = []; |
|
| 3126 | - if (!function_exists('changer_langue')) { |
|
| 3127 | - include_spip('inc/lang'); |
|
| 3128 | - } |
|
| 3129 | - if ($lang === null) { |
|
| 3130 | - $lang = array_pop($pile_langues); |
|
| 3131 | - } else { |
|
| 3132 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3133 | - } |
|
| 3134 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3135 | - return $lang; |
|
| 3136 | - } |
|
| 3137 | - changer_langue($lang); |
|
| 3124 | + static $pile_langues = []; |
|
| 3125 | + if (!function_exists('changer_langue')) { |
|
| 3126 | + include_spip('inc/lang'); |
|
| 3127 | + } |
|
| 3128 | + if ($lang === null) { |
|
| 3129 | + $lang = array_pop($pile_langues); |
|
| 3130 | + } else { |
|
| 3131 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3132 | + } |
|
| 3133 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3134 | + return $lang; |
|
| 3135 | + } |
|
| 3136 | + changer_langue($lang); |
|
| 3138 | 3137 | |
| 3139 | - return $lang; |
|
| 3138 | + return $lang; |
|
| 3140 | 3139 | } |
| 3141 | 3140 | |
| 3142 | 3141 | /** |
@@ -3153,20 +3152,20 @@ discard block |
||
| 3153 | 3152 | * Identifiant de la session |
| 3154 | 3153 | **/ |
| 3155 | 3154 | function spip_session($force = false) { |
| 3156 | - static $session; |
|
| 3157 | - if ($force or !isset($session)) { |
|
| 3158 | - $s = pipeline( |
|
| 3159 | - 'definir_session', |
|
| 3160 | - $GLOBALS['visiteur_session'] |
|
| 3161 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3162 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3163 | - : '' |
|
| 3164 | - ); |
|
| 3165 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3166 | - } |
|
| 3155 | + static $session; |
|
| 3156 | + if ($force or !isset($session)) { |
|
| 3157 | + $s = pipeline( |
|
| 3158 | + 'definir_session', |
|
| 3159 | + $GLOBALS['visiteur_session'] |
|
| 3160 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3161 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3162 | + : '' |
|
| 3163 | + ); |
|
| 3164 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3165 | + } |
|
| 3167 | 3166 | |
| 3168 | - #spip_log('session: '.$session); |
|
| 3169 | - return $session; |
|
| 3167 | + #spip_log('session: '.$session); |
|
| 3168 | + return $session; |
|
| 3170 | 3169 | } |
| 3171 | 3170 | |
| 3172 | 3171 | |
@@ -3185,9 +3184,9 @@ discard block |
||
| 3185 | 3184 | * Lien sur une icone d'aide |
| 3186 | 3185 | **/ |
| 3187 | 3186 | function aider($aide = '', $distante = false) { |
| 3188 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3187 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3189 | 3188 | |
| 3190 | - return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3189 | + return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3191 | 3190 | } |
| 3192 | 3191 | |
| 3193 | 3192 | /** |
@@ -3197,24 +3196,24 @@ discard block |
||
| 3197 | 3196 | */ |
| 3198 | 3197 | function exec_info_dist() { |
| 3199 | 3198 | |
| 3200 | - include_spip('inc/autoriser'); |
|
| 3201 | - if (autoriser('phpinfos')) { |
|
| 3202 | - $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3203 | - $cookies_backup = []; |
|
| 3204 | - foreach ($cookies_masques as $k) { |
|
| 3205 | - if (!empty($_COOKIE[$k])) { |
|
| 3206 | - $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3207 | - $_COOKIE[$k] = '******************************'; |
|
| 3208 | - } |
|
| 3209 | - } |
|
| 3210 | - phpinfo(); |
|
| 3211 | - foreach ($cookies_backup as $k => $v) { |
|
| 3212 | - $_COOKIE[$k] = $v; |
|
| 3213 | - } |
|
| 3214 | - } else { |
|
| 3215 | - include_spip('inc/filtres'); |
|
| 3216 | - sinon_interdire_acces(); |
|
| 3217 | - } |
|
| 3199 | + include_spip('inc/autoriser'); |
|
| 3200 | + if (autoriser('phpinfos')) { |
|
| 3201 | + $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3202 | + $cookies_backup = []; |
|
| 3203 | + foreach ($cookies_masques as $k) { |
|
| 3204 | + if (!empty($_COOKIE[$k])) { |
|
| 3205 | + $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3206 | + $_COOKIE[$k] = '******************************'; |
|
| 3207 | + } |
|
| 3208 | + } |
|
| 3209 | + phpinfo(); |
|
| 3210 | + foreach ($cookies_backup as $k => $v) { |
|
| 3211 | + $_COOKIE[$k] = $v; |
|
| 3212 | + } |
|
| 3213 | + } else { |
|
| 3214 | + include_spip('inc/filtres'); |
|
| 3215 | + sinon_interdire_acces(); |
|
| 3216 | + } |
|
| 3218 | 3217 | } |
| 3219 | 3218 | |
| 3220 | 3219 | /** |
@@ -3234,13 +3233,13 @@ discard block |
||
| 3234 | 3233 | * - string si $message à false. |
| 3235 | 3234 | **/ |
| 3236 | 3235 | function erreur_squelette($message = '', $lieu = '') { |
| 3237 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3238 | - if (is_array($lieu)) { |
|
| 3239 | - include_spip('public/compiler'); |
|
| 3240 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3241 | - } |
|
| 3236 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3237 | + if (is_array($lieu)) { |
|
| 3238 | + include_spip('public/compiler'); |
|
| 3239 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3240 | + } |
|
| 3242 | 3241 | |
| 3243 | - return $debusquer($message, $lieu); |
|
| 3242 | + return $debusquer($message, $lieu); |
|
| 3244 | 3243 | } |
| 3245 | 3244 | |
| 3246 | 3245 | /** |
@@ -3277,108 +3276,108 @@ discard block |
||
| 3277 | 3276 | * - ou tableau d'information sur le squelette. |
| 3278 | 3277 | */ |
| 3279 | 3278 | function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') { |
| 3280 | - if (!function_exists('evaluer_fond')) { |
|
| 3281 | - include_spip('public/assembler'); |
|
| 3282 | - } |
|
| 3283 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3284 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3285 | - if (!is_array($options)) { |
|
| 3286 | - $options = ['trim' => $options]; |
|
| 3287 | - } |
|
| 3288 | - if (!isset($options['trim'])) { |
|
| 3289 | - $options['trim'] = true; |
|
| 3290 | - } |
|
| 3291 | - |
|
| 3292 | - if (isset($contexte['connect'])) { |
|
| 3293 | - $connect = $contexte['connect']; |
|
| 3294 | - unset($contexte['connect']); |
|
| 3295 | - } |
|
| 3296 | - |
|
| 3297 | - $texte = ''; |
|
| 3298 | - $pages = []; |
|
| 3299 | - $lang_select = ''; |
|
| 3300 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3301 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3302 | - if (!isset($contexte['lang'])) { |
|
| 3303 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3304 | - } |
|
| 3305 | - |
|
| 3306 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3307 | - $lang_select = lang_select($contexte['lang']); |
|
| 3308 | - } |
|
| 3309 | - } |
|
| 3310 | - |
|
| 3311 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3312 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3313 | - } |
|
| 3314 | - |
|
| 3315 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3316 | - |
|
| 3317 | - // fix #4235 |
|
| 3318 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3319 | - |
|
| 3320 | - |
|
| 3321 | - foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3322 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3323 | - |
|
| 3324 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3325 | - if ($page === '') { |
|
| 3326 | - $c = $options['compil'] ?? ''; |
|
| 3327 | - $a = ['fichier' => $f]; |
|
| 3328 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3329 | - erreur_squelette($erreur, $c); |
|
| 3330 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3331 | - $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3332 | - } |
|
| 3333 | - |
|
| 3334 | - $page = pipeline('recuperer_fond', [ |
|
| 3335 | - 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3336 | - 'data' => $page |
|
| 3337 | - ]); |
|
| 3338 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3339 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3340 | - include_spip('inc/filtres'); |
|
| 3341 | - } |
|
| 3342 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3343 | - array_merge( |
|
| 3344 | - $contexte, |
|
| 3345 | - ['fond' => $f], |
|
| 3346 | - ($connect ? ['connect' => $connect] : []) |
|
| 3347 | - ), |
|
| 3348 | - '', |
|
| 3349 | - $page['texte'], |
|
| 3350 | - $options['ajax'] |
|
| 3351 | - ); |
|
| 3352 | - } |
|
| 3353 | - |
|
| 3354 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3355 | - $pages[] = $page; |
|
| 3356 | - } else { |
|
| 3357 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3358 | - } |
|
| 3359 | - |
|
| 3360 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3361 | - if (isset($page['invalideurs']['session'])) { |
|
| 3362 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3363 | - } |
|
| 3364 | - } |
|
| 3365 | - |
|
| 3366 | - // restaurer le sessionnement du contexte appelant, |
|
| 3367 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3368 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3369 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3370 | - } |
|
| 3371 | - |
|
| 3372 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3373 | - |
|
| 3374 | - if ($lang_select) { |
|
| 3375 | - lang_select(); |
|
| 3376 | - } |
|
| 3377 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3378 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3379 | - } else { |
|
| 3380 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3381 | - } |
|
| 3279 | + if (!function_exists('evaluer_fond')) { |
|
| 3280 | + include_spip('public/assembler'); |
|
| 3281 | + } |
|
| 3282 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3283 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3284 | + if (!is_array($options)) { |
|
| 3285 | + $options = ['trim' => $options]; |
|
| 3286 | + } |
|
| 3287 | + if (!isset($options['trim'])) { |
|
| 3288 | + $options['trim'] = true; |
|
| 3289 | + } |
|
| 3290 | + |
|
| 3291 | + if (isset($contexte['connect'])) { |
|
| 3292 | + $connect = $contexte['connect']; |
|
| 3293 | + unset($contexte['connect']); |
|
| 3294 | + } |
|
| 3295 | + |
|
| 3296 | + $texte = ''; |
|
| 3297 | + $pages = []; |
|
| 3298 | + $lang_select = ''; |
|
| 3299 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3300 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3301 | + if (!isset($contexte['lang'])) { |
|
| 3302 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3303 | + } |
|
| 3304 | + |
|
| 3305 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3306 | + $lang_select = lang_select($contexte['lang']); |
|
| 3307 | + } |
|
| 3308 | + } |
|
| 3309 | + |
|
| 3310 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3311 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3312 | + } |
|
| 3313 | + |
|
| 3314 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3315 | + |
|
| 3316 | + // fix #4235 |
|
| 3317 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3318 | + |
|
| 3319 | + |
|
| 3320 | + foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3321 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3322 | + |
|
| 3323 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3324 | + if ($page === '') { |
|
| 3325 | + $c = $options['compil'] ?? ''; |
|
| 3326 | + $a = ['fichier' => $f]; |
|
| 3327 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3328 | + erreur_squelette($erreur, $c); |
|
| 3329 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3330 | + $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3331 | + } |
|
| 3332 | + |
|
| 3333 | + $page = pipeline('recuperer_fond', [ |
|
| 3334 | + 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3335 | + 'data' => $page |
|
| 3336 | + ]); |
|
| 3337 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3338 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3339 | + include_spip('inc/filtres'); |
|
| 3340 | + } |
|
| 3341 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3342 | + array_merge( |
|
| 3343 | + $contexte, |
|
| 3344 | + ['fond' => $f], |
|
| 3345 | + ($connect ? ['connect' => $connect] : []) |
|
| 3346 | + ), |
|
| 3347 | + '', |
|
| 3348 | + $page['texte'], |
|
| 3349 | + $options['ajax'] |
|
| 3350 | + ); |
|
| 3351 | + } |
|
| 3352 | + |
|
| 3353 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3354 | + $pages[] = $page; |
|
| 3355 | + } else { |
|
| 3356 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3357 | + } |
|
| 3358 | + |
|
| 3359 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3360 | + if (isset($page['invalideurs']['session'])) { |
|
| 3361 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3362 | + } |
|
| 3363 | + } |
|
| 3364 | + |
|
| 3365 | + // restaurer le sessionnement du contexte appelant, |
|
| 3366 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3367 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3368 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3369 | + } |
|
| 3370 | + |
|
| 3371 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3372 | + |
|
| 3373 | + if ($lang_select) { |
|
| 3374 | + lang_select(); |
|
| 3375 | + } |
|
| 3376 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3377 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3378 | + } else { |
|
| 3379 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3380 | + } |
|
| 3382 | 3381 | } |
| 3383 | 3382 | |
| 3384 | 3383 | /** |
@@ -3388,7 +3387,7 @@ discard block |
||
| 3388 | 3387 | * @return string |
| 3389 | 3388 | */ |
| 3390 | 3389 | function trouve_modele($nom) { |
| 3391 | - return trouver_fond($nom, 'modeles/'); |
|
| 3390 | + return trouver_fond($nom, 'modeles/'); |
|
| 3392 | 3391 | } |
| 3393 | 3392 | |
| 3394 | 3393 | /** |
@@ -3404,21 +3403,21 @@ discard block |
||
| 3404 | 3403 | * @return array|string |
| 3405 | 3404 | */ |
| 3406 | 3405 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3407 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3408 | - if (!$pathinfo) { |
|
| 3409 | - return $f; |
|
| 3410 | - } |
|
| 3411 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3412 | - $p = pathinfo($f); |
|
| 3413 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3414 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3415 | - } |
|
| 3416 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3417 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3418 | - } |
|
| 3419 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3406 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3407 | + if (!$pathinfo) { |
|
| 3408 | + return $f; |
|
| 3409 | + } |
|
| 3410 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3411 | + $p = pathinfo($f); |
|
| 3412 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3413 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3414 | + } |
|
| 3415 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3416 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3417 | + } |
|
| 3418 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3420 | 3419 | |
| 3421 | - return $p; |
|
| 3420 | + return $p; |
|
| 3422 | 3421 | } |
| 3423 | 3422 | |
| 3424 | 3423 | /** |
@@ -3438,21 +3437,21 @@ discard block |
||
| 3438 | 3437 | * Nom de l'exec, sinon chaîne vide. |
| 3439 | 3438 | **/ |
| 3440 | 3439 | function tester_url_ecrire($nom) { |
| 3441 | - static $exec = []; |
|
| 3442 | - if (isset($exec[$nom])) { |
|
| 3443 | - return $exec[$nom]; |
|
| 3444 | - } |
|
| 3445 | - // tester si c'est une page en squelette |
|
| 3446 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3447 | - return $exec[$nom] = 'fond'; |
|
| 3448 | - } // echafaudage d'un fond ! |
|
| 3449 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3450 | - return $exec[$nom] = 'fond'; |
|
| 3451 | - } |
|
| 3452 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3453 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3454 | - // et des define intrusifs potentiels |
|
| 3455 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3440 | + static $exec = []; |
|
| 3441 | + if (isset($exec[$nom])) { |
|
| 3442 | + return $exec[$nom]; |
|
| 3443 | + } |
|
| 3444 | + // tester si c'est une page en squelette |
|
| 3445 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3446 | + return $exec[$nom] = 'fond'; |
|
| 3447 | + } // echafaudage d'un fond ! |
|
| 3448 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3449 | + return $exec[$nom] = 'fond'; |
|
| 3450 | + } |
|
| 3451 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3452 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3453 | + // et des define intrusifs potentiels |
|
| 3454 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3456 | 3455 | } |
| 3457 | 3456 | |
| 3458 | 3457 | /** |
@@ -3462,8 +3461,8 @@ discard block |
||
| 3462 | 3461 | * true si la constante _VERSION_HTML n'est pas définie ou égale à html5 |
| 3463 | 3462 | **/ |
| 3464 | 3463 | function html5_permis() { |
| 3465 | - return (!defined('_VERSION_HTML') |
|
| 3466 | - or _VERSION_HTML !== 'html4'); |
|
| 3464 | + return (!defined('_VERSION_HTML') |
|
| 3465 | + or _VERSION_HTML !== 'html4'); |
|
| 3467 | 3466 | } |
| 3468 | 3467 | |
| 3469 | 3468 | /** |
@@ -3473,30 +3472,30 @@ discard block |
||
| 3473 | 3472 | * @return array |
| 3474 | 3473 | */ |
| 3475 | 3474 | function formats_image_acceptables($gd = null, $svg_allowed = true) { |
| 3476 | - $formats = null; |
|
| 3477 | - if (!is_null($gd)) { |
|
| 3478 | - $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3479 | - if (isset($GLOBALS['meta'][$config])) { |
|
| 3480 | - $formats = $GLOBALS['meta'][$config]; |
|
| 3481 | - $formats = explode(',', $formats); |
|
| 3482 | - $formats = array_filter($formats); |
|
| 3483 | - $formats = array_map('trim', $formats); |
|
| 3484 | - } |
|
| 3485 | - } |
|
| 3486 | - if (is_null($formats)) { |
|
| 3487 | - include_spip('inc/filtres_images_lib_mini'); |
|
| 3488 | - $formats = _image_extensions_acceptees_en_entree(); |
|
| 3489 | - } |
|
| 3490 | - |
|
| 3491 | - if ($svg_allowed) { |
|
| 3492 | - if (!in_array('svg', $formats)) { |
|
| 3493 | - $formats[] = 'svg'; |
|
| 3494 | - } |
|
| 3495 | - } |
|
| 3496 | - else { |
|
| 3497 | - $formats = array_diff($formats, ['svg']); |
|
| 3498 | - } |
|
| 3499 | - return $formats; |
|
| 3475 | + $formats = null; |
|
| 3476 | + if (!is_null($gd)) { |
|
| 3477 | + $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3478 | + if (isset($GLOBALS['meta'][$config])) { |
|
| 3479 | + $formats = $GLOBALS['meta'][$config]; |
|
| 3480 | + $formats = explode(',', $formats); |
|
| 3481 | + $formats = array_filter($formats); |
|
| 3482 | + $formats = array_map('trim', $formats); |
|
| 3483 | + } |
|
| 3484 | + } |
|
| 3485 | + if (is_null($formats)) { |
|
| 3486 | + include_spip('inc/filtres_images_lib_mini'); |
|
| 3487 | + $formats = _image_extensions_acceptees_en_entree(); |
|
| 3488 | + } |
|
| 3489 | + |
|
| 3490 | + if ($svg_allowed) { |
|
| 3491 | + if (!in_array('svg', $formats)) { |
|
| 3492 | + $formats[] = 'svg'; |
|
| 3493 | + } |
|
| 3494 | + } |
|
| 3495 | + else { |
|
| 3496 | + $formats = array_diff($formats, ['svg']); |
|
| 3497 | + } |
|
| 3498 | + return $formats; |
|
| 3500 | 3499 | } |
| 3501 | 3500 | |
| 3502 | 3501 | /** |
@@ -3505,20 +3504,20 @@ discard block |
||
| 3505 | 3504 | * @return array|bool |
| 3506 | 3505 | */ |
| 3507 | 3506 | function spip_getimagesize($fichier) { |
| 3508 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3509 | - include_spip('inc/svg'); |
|
| 3510 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3511 | - [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3512 | - $imagesize = [ |
|
| 3513 | - $width, |
|
| 3514 | - $height, |
|
| 3515 | - IMAGETYPE_SVG, |
|
| 3516 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3517 | - 'mime' => 'image/svg+xml' |
|
| 3518 | - ]; |
|
| 3519 | - } |
|
| 3520 | - } |
|
| 3521 | - return $imagesize; |
|
| 3507 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3508 | + include_spip('inc/svg'); |
|
| 3509 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3510 | + [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3511 | + $imagesize = [ |
|
| 3512 | + $width, |
|
| 3513 | + $height, |
|
| 3514 | + IMAGETYPE_SVG, |
|
| 3515 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3516 | + 'mime' => 'image/svg+xml' |
|
| 3517 | + ]; |
|
| 3518 | + } |
|
| 3519 | + } |
|
| 3520 | + return $imagesize; |
|
| 3522 | 3521 | } |
| 3523 | 3522 | |
| 3524 | 3523 | /** |
@@ -3532,19 +3531,19 @@ discard block |
||
| 3532 | 3531 | * @param string $statut |
| 3533 | 3532 | */ |
| 3534 | 3533 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3535 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3536 | - if ( |
|
| 3537 | - !$alertes |
|
| 3538 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3539 | - ) { |
|
| 3540 | - $alertes = []; |
|
| 3541 | - } |
|
| 3534 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3535 | + if ( |
|
| 3536 | + !$alertes |
|
| 3537 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3538 | + ) { |
|
| 3539 | + $alertes = []; |
|
| 3540 | + } |
|
| 3542 | 3541 | |
| 3543 | - if (!isset($alertes[$statut])) { |
|
| 3544 | - $alertes[$statut] = []; |
|
| 3545 | - } |
|
| 3546 | - $alertes[$statut][$nom] = $message; |
|
| 3547 | - ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3542 | + if (!isset($alertes[$statut])) { |
|
| 3543 | + $alertes[$statut] = []; |
|
| 3544 | + } |
|
| 3545 | + $alertes[$statut][$nom] = $message; |
|
| 3546 | + ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3548 | 3547 | } |
| 3549 | 3548 | |
| 3550 | 3549 | /** |
@@ -3558,10 +3557,10 @@ discard block |
||
| 3558 | 3557 | * @return string|string[] |
| 3559 | 3558 | */ |
| 3560 | 3559 | function spip_sanitize_classname($classes) { |
| 3561 | - if (is_array($classes)) { |
|
| 3562 | - return array_map('spip_sanitize_classname', $classes); |
|
| 3563 | - } |
|
| 3564 | - return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3560 | + if (is_array($classes)) { |
|
| 3561 | + return array_map('spip_sanitize_classname', $classes); |
|
| 3562 | + } |
|
| 3563 | + return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3565 | 3564 | } |
| 3566 | 3565 | |
| 3567 | 3566 | |
@@ -3586,32 +3585,32 @@ discard block |
||
| 3586 | 3585 | * Avec operateur : bool. |
| 3587 | 3586 | **/ |
| 3588 | 3587 | function spip_version_compare($v1, $v2, $op = null) { |
| 3589 | - $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3590 | - $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3591 | - $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3592 | - $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3593 | - |
|
| 3594 | - $v1 = explode('.', $v1); |
|
| 3595 | - $v2 = explode('.', $v2); |
|
| 3596 | - // $v1 est toujours une version, donc sans etoile |
|
| 3597 | - while (count($v1) < count($v2)) { |
|
| 3598 | - $v1[] = '0'; |
|
| 3599 | - } |
|
| 3600 | - |
|
| 3601 | - // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3602 | - $etoile = false; |
|
| 3603 | - foreach ($v1 as $k => $v) { |
|
| 3604 | - if (!isset($v2[$k])) { |
|
| 3605 | - $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3606 | - } else { |
|
| 3607 | - if ($v2[$k] == '*') { |
|
| 3608 | - $etoile = true; |
|
| 3609 | - $v2[$k] = $v; |
|
| 3610 | - } |
|
| 3611 | - } |
|
| 3612 | - } |
|
| 3613 | - $v1 = implode('.', $v1); |
|
| 3614 | - $v2 = implode('.', $v2); |
|
| 3615 | - |
|
| 3616 | - return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3588 | + $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3589 | + $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3590 | + $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3591 | + $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3592 | + |
|
| 3593 | + $v1 = explode('.', $v1); |
|
| 3594 | + $v2 = explode('.', $v2); |
|
| 3595 | + // $v1 est toujours une version, donc sans etoile |
|
| 3596 | + while (count($v1) < count($v2)) { |
|
| 3597 | + $v1[] = '0'; |
|
| 3598 | + } |
|
| 3599 | + |
|
| 3600 | + // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3601 | + $etoile = false; |
|
| 3602 | + foreach ($v1 as $k => $v) { |
|
| 3603 | + if (!isset($v2[$k])) { |
|
| 3604 | + $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3605 | + } else { |
|
| 3606 | + if ($v2[$k] == '*') { |
|
| 3607 | + $etoile = true; |
|
| 3608 | + $v2[$k] = $v; |
|
| 3609 | + } |
|
| 3610 | + } |
|
| 3611 | + } |
|
| 3612 | + $v1 = implode('.', $v1); |
|
| 3613 | + $v2 = implode('.', $v2); |
|
| 3614 | + |
|
| 3615 | + return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3617 | 3616 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | if (strlen($dossier) and substr($dossier, -1) != '/') { |
| 54 | 54 | $dossier .= '/'; |
| 55 | 55 | } |
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 56 | + $f = str_replace('/', '_', $dossier).$nom; |
|
| 57 | 57 | |
| 58 | 58 | if (function_exists($f)) { |
| 59 | 59 | return $f; |
| 60 | 60 | } |
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 61 | + if (function_exists($g = $f.'_dist')) { |
|
| 62 | 62 | return $g; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // passer en minuscules (cf les balises de formulaires) |
| 80 | 80 | // et inclure le fichier |
| 81 | 81 | if ( |
| 82 | - !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | + !$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 83 | 83 | // si le fichier truc/machin/nom.php n'existe pas, |
| 84 | 84 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 85 | 85 | and strlen(dirname($dossier)) and dirname($dossier) != '.' |
@@ -98,14 +98,14 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Echec : message d'erreur |
| 101 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 102 | 102 | ($inc ? '' : " (fichier $d absent de $dossier)")); |
| 103 | 103 | |
| 104 | 104 | include_spip('inc/minipres'); |
| 105 | 105 | echo minipres( |
| 106 | 106 | _T('forum_titre_erreur'), |
| 107 | - _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']), |
|
| 108 | - ['all_inline' => true,'status' => 404] |
|
| 107 | + _T('fichier_introuvable', ['fichier' => '<b>'.spip_htmlentities($d).'</b>']), |
|
| 108 | + ['all_inline' => true, 'status' => 404] |
|
| 109 | 109 | ); |
| 110 | 110 | exit; |
| 111 | 111 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * - string : chemin du fichier trouvé |
| 152 | 152 | **/ |
| 153 | 153 | function include_spip($f, $include = true) { |
| 154 | - return find_in_path($f . '.php', '', $include); |
|
| 154 | + return find_in_path($f.'.php', '', $include); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * - string : chemin du fichier trouvé |
| 172 | 172 | **/ |
| 173 | 173 | function require_spip($f) { |
| 174 | - return find_in_path($f . '.php', '', 'required'); |
|
| 174 | + return find_in_path($f.'.php', '', 'required'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | // donc il faut l'inclure "en globals" |
| 189 | 189 | if ($f = find_in_path('mes_fonctions.php')) { |
| 190 | 190 | global $dossier_squelettes; |
| 191 | - include_once(_ROOT_CWD . $f); |
|
| 191 | + include_once(_ROOT_CWD.$f); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // appliquer notre fonction si elle existe |
| 296 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 296 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 297 | 297 | if (function_exists($fonc)) { |
| 298 | 298 | $val = $fonc($val); |
| 299 | 299 | } // plantage ? |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | function spip_log($message = null, $name = null) { |
| 359 | 359 | static $pre = []; |
| 360 | 360 | static $log; |
| 361 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 361 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 362 | 362 | if (!isset($regs[1]) or !$logname = $regs[1]) { |
| 363 | 363 | $logname = null; |
| 364 | 364 | } |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | if (!is_string($message)) { |
| 387 | 387 | $message = print_r($message, true); |
| 388 | 388 | } |
| 389 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 389 | + $log($pre[$niveau].' '.$message, $logname); |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | $a = './'; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 590 | + $regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,'; |
|
| 591 | 591 | $ajouts = array_flip(explode('|', $c)); |
| 592 | 592 | $u = is_array($v) ? $v : rawurlencode((string) $v); |
| 593 | 593 | $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 615 | 615 | // pour un tableau ce sera fait dans la prochaine boucle |
| 616 | 616 | elseif (substr($r[1], -2) != '[]') { |
| 617 | - $url[$n] = $r[1] . '=' . $u; |
|
| 617 | + $url[$n] = $r[1].'='.$u; |
|
| 618 | 618 | unset($ajouts[$r[1]]); |
| 619 | 619 | } |
| 620 | 620 | // Pour les tableaux on laisse tomber les valeurs de |
@@ -635,11 +635,11 @@ discard block |
||
| 635 | 635 | } elseif ($testv) { |
| 636 | 636 | foreach ($ajouts as $k => $n) { |
| 637 | 637 | if (!is_array($v)) { |
| 638 | - $url[] = $k . '=' . $u; |
|
| 638 | + $url[] = $k.'='.$u; |
|
| 639 | 639 | } else { |
| 640 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 640 | + $id = (substr($k, -2) == '[]') ? $k : ($k.'[]'); |
|
| 641 | 641 | foreach ($v as $w) { |
| 642 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 642 | + $url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | } |
@@ -650,10 +650,10 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | // recomposer l'adresse |
| 652 | 652 | if ($url) { |
| 653 | - $a .= '?' . join($sep, $url); |
|
| 653 | + $a .= '?'.join($sep, $url); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - return $a . $ancre; |
|
| 656 | + return $a.$ancre; |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | translitteration($ancre) |
| 686 | 686 | ); |
| 687 | 687 | } |
| 688 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 688 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | * @return bool |
| 802 | 802 | */ |
| 803 | 803 | function test_plugin_actif($plugin) { |
| 804 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 804 | + return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false; |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /** |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | $value = interdire_scripts($value, -1); |
| 934 | 934 | } |
| 935 | 935 | if (!empty($options['class'])) { |
| 936 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 936 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 937 | 937 | } |
| 938 | 938 | $text = str_replace("@$name@", $value, $text); |
| 939 | 939 | unset($args[$name]); |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | // Si des variables n'ont pas ete inserees, le signaler |
| 943 | 943 | // (chaines de langues pas a jour) |
| 944 | 944 | if ($args) { |
| 945 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 945 | + spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 946 | 946 | } |
| 947 | 947 | } |
| 948 | 948 | |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | function joli_repertoire($rep) { |
| 967 | 967 | $a = substr($rep, 0, 1); |
| 968 | 968 | if ($a <> '.' and $a <> '/') { |
| 969 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 969 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep; |
|
| 970 | 970 | } |
| 971 | 971 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 972 | 972 | |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | $p -= ($x * 1000); |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1023 | + return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | if ($taches and count($taches) and !spip_connect()) { |
| 1088 | 1088 | return false; |
| 1089 | 1089 | } |
| 1090 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1090 | + spip_log('cron !', 'jq'._LOG_DEBUG); |
|
| 1091 | 1091 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 1092 | 1092 | return $genie($taches); |
| 1093 | 1093 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | |
| 1192 | 1192 | if ($queue_next_job_time == -1) { |
| 1193 | 1193 | if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
| 1194 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1194 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt'); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | // utiliser un cache memoire si dispo |
| 1197 | 1197 | if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
@@ -1260,8 +1260,8 @@ discard block |
||
| 1260 | 1260 | $src = ''; |
| 1261 | 1261 | } |
| 1262 | 1262 | if ($script) { |
| 1263 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1264 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1263 | + $script = ("/*<![CDATA[*/\n". |
|
| 1264 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script). |
|
| 1265 | 1265 | '/*]]>*/'); |
| 1266 | 1266 | } |
| 1267 | 1267 | if ($noscript) { |
@@ -1347,13 +1347,13 @@ discard block |
||
| 1347 | 1347 | if ($path_base == null) { |
| 1348 | 1348 | // Chemin standard depuis l'espace public |
| 1349 | 1349 | $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
| 1350 | - _DIR_RACINE . ':' . |
|
| 1351 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1352 | - _DIR_RACINE . 'prive/:' . |
|
| 1350 | + _DIR_RACINE.':'. |
|
| 1351 | + _DIR_RACINE.'squelettes-dist/:'. |
|
| 1352 | + _DIR_RACINE.'prive/:'. |
|
| 1353 | 1353 | _DIR_RESTREINT; |
| 1354 | 1354 | // Ajouter squelettes/ |
| 1355 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1356 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1355 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 1356 | + $path = _DIR_RACINE.'squelettes/:'.$path; |
|
| 1357 | 1357 | } |
| 1358 | 1358 | foreach (explode(':', $path) as $dir) { |
| 1359 | 1359 | if (strlen($dir) and substr($dir, -1) != '/') { |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | // Et le(s) dossier(s) des squelettes nommes |
| 1366 | 1366 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1367 | 1367 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1368 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1368 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 1369 | 1369 | } |
| 1370 | 1370 | } |
| 1371 | 1371 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | |
| 1377 | 1377 | if (is_array($dir_path) or strlen($dir_path)) { |
| 1378 | 1378 | $tete = ''; |
| 1379 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1379 | + if (reset($path_base) == _DIR_RACINE.'squelettes/') { |
|
| 1380 | 1380 | $tete = array_shift($path_base); |
| 1381 | 1381 | } |
| 1382 | 1382 | $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | // Et le(s) dossier(s) des squelettes nommes |
| 1398 | 1398 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1399 | 1399 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1400 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1400 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/'); |
|
| 1401 | 1401 | } |
| 1402 | 1402 | } |
| 1403 | 1403 | |
@@ -1468,14 +1468,14 @@ discard block |
||
| 1468 | 1468 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 1469 | 1469 | if ( |
| 1470 | 1470 | preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
| 1471 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1471 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg' |
|
| 1472 | 1472 | and $f = find_in_theme("$file_svg_generique") |
| 1473 | 1473 | ) { |
| 1474 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1474 | + if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) { |
|
| 1475 | 1475 | return $themefiles["$subdir$file"] = $fsize; |
| 1476 | 1476 | } |
| 1477 | 1477 | else { |
| 1478 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1478 | + return $themefiles["$subdir$file"] = "$f?".$m[1].'px'; |
|
| 1479 | 1479 | } |
| 1480 | 1480 | } |
| 1481 | 1481 | |
@@ -1485,7 +1485,7 @@ discard block |
||
| 1485 | 1485 | return $themefiles["$subdir$file"] = $f; |
| 1486 | 1486 | } |
| 1487 | 1487 | } |
| 1488 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1488 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 1489 | 1489 | |
| 1490 | 1490 | return $themefiles["$subdir$file"] = ''; |
| 1491 | 1491 | } |
@@ -1593,8 +1593,8 @@ discard block |
||
| 1593 | 1593 | return false; |
| 1594 | 1594 | } |
| 1595 | 1595 | if ($include and !isset($inc[$dirname][$file])) { |
| 1596 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1597 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1596 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1597 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | 1600 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
@@ -1607,14 +1607,14 @@ discard block |
||
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | foreach (creer_chemin() as $dir) { |
| 1610 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1611 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1610 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 1611 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a); |
|
| 1612 | 1612 | } |
| 1613 | 1613 | if ($dirs[$a]) { |
| 1614 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1614 | + if (file_exists(_ROOT_CWD.($a .= $file))) { |
|
| 1615 | 1615 | if ($include and !isset($inc[$dirname][$file])) { |
| 1616 | - include_once _ROOT_CWD . $a; |
|
| 1617 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1616 | + include_once _ROOT_CWD.$a; |
|
| 1617 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1618 | 1618 | } |
| 1619 | 1619 | if (!defined('_SAUVER_CHEMIN')) { |
| 1620 | 1620 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | define('_SAUVER_CHEMIN', true); |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1627 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a; |
|
| 1628 | 1628 | } |
| 1629 | 1629 | } |
| 1630 | 1630 | } |
@@ -1650,7 +1650,7 @@ discard block |
||
| 1650 | 1650 | define('_SAUVER_CHEMIN', true); |
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1653 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false; |
|
| 1654 | 1654 | } |
| 1655 | 1655 | |
| 1656 | 1656 | function clear_path_cache() { |
@@ -1720,12 +1720,12 @@ discard block |
||
| 1720 | 1720 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
| 1721 | 1721 | // on a pas encore inclus flock.php |
| 1722 | 1722 | if (!function_exists('preg_files')) { |
| 1723 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1723 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 1724 | 1724 | } |
| 1725 | 1725 | |
| 1726 | 1726 | // Parcourir le chemin |
| 1727 | 1727 | foreach (creer_chemin() as $d) { |
| 1728 | - $f = $d . $dir; |
|
| 1728 | + $f = $d.$dir; |
|
| 1729 | 1729 | if (@is_dir($f)) { |
| 1730 | 1730 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
| 1731 | 1731 | foreach ($liste as $chemin) { |
@@ -1833,7 +1833,7 @@ discard block |
||
| 1833 | 1833 | return $res; |
| 1834 | 1834 | } |
| 1835 | 1835 | // Sinon c'est un raccourci ou compat SPIP < 2 |
| 1836 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1836 | + if (!function_exists($f = 'generer_url_'.$entite)) { |
|
| 1837 | 1837 | if (!function_exists($f .= '_dist')) { |
| 1838 | 1838 | $f = ''; |
| 1839 | 1839 | } |
@@ -1842,8 +1842,8 @@ discard block |
||
| 1842 | 1842 | $url = $f($id, $args, $ancre); |
| 1843 | 1843 | if (strlen($args)) { |
| 1844 | 1844 | $url .= strstr($url, '?') |
| 1845 | - ? '&' . $args |
|
| 1846 | - : '?' . $args; |
|
| 1845 | + ? '&'.$args |
|
| 1846 | + : '?'.$args; |
|
| 1847 | 1847 | } |
| 1848 | 1848 | |
| 1849 | 1849 | return $url; |
@@ -1873,8 +1873,8 @@ discard block |
||
| 1873 | 1873 | include_spip('base/connect_sql'); |
| 1874 | 1874 | $id_type = id_table_objet($entite, $public); |
| 1875 | 1875 | |
| 1876 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1877 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1876 | + return _DIR_RACINE.get_spip_script('./') |
|
| 1877 | + . '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1878 | 1878 | . (!$args ? '' : "&$args") |
| 1879 | 1879 | . (!$ancre ? '' : "#$ancre"); |
| 1880 | 1880 | } |
@@ -2027,7 +2027,7 @@ discard block |
||
| 2027 | 2027 | !empty($_SERVER['QUERY_STRING']) |
| 2028 | 2028 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2029 | 2029 | ) { |
| 2030 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2030 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2031 | 2031 | } |
| 2032 | 2032 | } |
| 2033 | 2033 | } |
@@ -2062,9 +2062,9 @@ discard block |
||
| 2062 | 2062 | array_shift($myself); |
| 2063 | 2063 | $myself = implode('/', $myself); |
| 2064 | 2064 | } |
| 2065 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2065 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 2066 | 2066 | |
| 2067 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2067 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 2068 | 2068 | |
| 2069 | 2069 | return $url; |
| 2070 | 2070 | } |
@@ -2102,16 +2102,16 @@ discard block |
||
| 2102 | 2102 | **/ |
| 2103 | 2103 | function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) { |
| 2104 | 2104 | if (!$rel) { |
| 2105 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2105 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 2106 | 2106 | } else { |
| 2107 | 2107 | if (!is_string($rel)) { |
| 2108 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2108 | + $rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT; |
|
| 2109 | 2109 | } |
| 2110 | 2110 | } |
| 2111 | 2111 | |
| 2112 | 2112 | [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
| 2113 | 2113 | if ($script and ($script <> 'accueil' or $rel)) { |
| 2114 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2114 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 2115 | 2115 | } elseif ($args) { |
| 2116 | 2116 | $args = "?$args"; |
| 2117 | 2117 | } |
@@ -2119,7 +2119,7 @@ discard block |
||
| 2119 | 2119 | $args .= "#$ancre"; |
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2122 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2123 | 2123 | } |
| 2124 | 2124 | |
| 2125 | 2125 | // |
@@ -2192,24 +2192,24 @@ discard block |
||
| 2192 | 2192 | if (is_array($args)) { |
| 2193 | 2193 | $r = ''; |
| 2194 | 2194 | foreach ($args as $k => $v) { |
| 2195 | - $r .= '&' . $k . '=' . $v; |
|
| 2195 | + $r .= '&'.$k.'='.$v; |
|
| 2196 | 2196 | } |
| 2197 | 2197 | $args = substr($r, 1); |
| 2198 | 2198 | } |
| 2199 | 2199 | $action .= |
| 2200 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2200 | + (strpos($action, '?') !== false ? '&' : '?').$args; |
|
| 2201 | 2201 | } |
| 2202 | 2202 | if (!$no_entities) { |
| 2203 | 2203 | $action = quote_amp($action); |
| 2204 | 2204 | } |
| 2205 | 2205 | |
| 2206 | 2206 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 2207 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2207 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2208 | 2208 | } |
| 2209 | 2209 | |
| 2210 | 2210 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2211 | 2211 | |
| 2212 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2212 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 2213 | 2213 | } |
| 2214 | 2214 | |
| 2215 | 2215 | // Pour les formulaires en methode POST, |
@@ -2244,8 +2244,7 @@ discard block |
||
| 2244 | 2244 | . "><div>\n" |
| 2245 | 2245 | . "<input type='hidden' name='exec' value='$script1' />" |
| 2246 | 2246 | . $corps |
| 2247 | - . (!$submit ? '' : |
|
| 2248 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2247 | + . (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>')) |
|
| 2249 | 2248 | . "</div></form>\n"; |
| 2250 | 2249 | } |
| 2251 | 2250 | |
@@ -2270,14 +2269,14 @@ discard block |
||
| 2270 | 2269 | ? generer_url_ecrire(_request('exec')) |
| 2271 | 2270 | : generer_url_public(); |
| 2272 | 2271 | |
| 2273 | - return "\n<form action='" . |
|
| 2274 | - $h . |
|
| 2275 | - "'" . |
|
| 2276 | - $atts . |
|
| 2277 | - ">\n" . |
|
| 2278 | - '<div>' . |
|
| 2279 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2280 | - $corps . |
|
| 2272 | + return "\n<form action='". |
|
| 2273 | + $h. |
|
| 2274 | + "'". |
|
| 2275 | + $atts. |
|
| 2276 | + ">\n". |
|
| 2277 | + '<div>'. |
|
| 2278 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 2279 | + $corps. |
|
| 2281 | 2280 | '</div></form>'; |
| 2282 | 2281 | } |
| 2283 | 2282 | |
@@ -2305,7 +2304,7 @@ discard block |
||
| 2305 | 2304 | : generer_url_public('', '', false, false); |
| 2306 | 2305 | $url = parametre_url($url, 'action', $script); |
| 2307 | 2306 | if ($args) { |
| 2308 | - $url .= quote_amp('&' . $args); |
|
| 2307 | + $url .= quote_amp('&'.$args); |
|
| 2309 | 2308 | } |
| 2310 | 2309 | |
| 2311 | 2310 | if ($no_entities) { |
@@ -2355,17 +2354,17 @@ discard block |
||
| 2355 | 2354 | |
| 2356 | 2355 | // le nom du repertoire plugins/ activables/desactivables |
| 2357 | 2356 | if (!defined('_DIR_PLUGINS')) { |
| 2358 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2357 | + define('_DIR_PLUGINS', _DIR_RACINE.'plugins/'); |
|
| 2359 | 2358 | } |
| 2360 | 2359 | |
| 2361 | 2360 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 2362 | 2361 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 2363 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2362 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/'); |
|
| 2364 | 2363 | } |
| 2365 | 2364 | |
| 2366 | 2365 | // le nom du repertoire des librairies |
| 2367 | 2366 | if (!defined('_DIR_LIB')) { |
| 2368 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2367 | + define('_DIR_LIB', _DIR_RACINE.'lib/'); |
|
| 2369 | 2368 | } |
| 2370 | 2369 | |
| 2371 | 2370 | if (!defined('_DIR_IMG')) { |
@@ -2375,29 +2374,29 @@ discard block |
||
| 2375 | 2374 | define('_DIR_LOGOS', $pa); |
| 2376 | 2375 | } |
| 2377 | 2376 | if (!defined('_DIR_IMG_ICONES')) { |
| 2378 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2377 | + define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/'); |
|
| 2379 | 2378 | } |
| 2380 | 2379 | |
| 2381 | 2380 | if (!defined('_DIR_DUMP')) { |
| 2382 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2381 | + define('_DIR_DUMP', $ti.'dump/'); |
|
| 2383 | 2382 | } |
| 2384 | 2383 | if (!defined('_DIR_SESSIONS')) { |
| 2385 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2384 | + define('_DIR_SESSIONS', $ti.'sessions/'); |
|
| 2386 | 2385 | } |
| 2387 | 2386 | if (!defined('_DIR_TRANSFERT')) { |
| 2388 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2387 | + define('_DIR_TRANSFERT', $ti.'upload/'); |
|
| 2389 | 2388 | } |
| 2390 | 2389 | if (!defined('_DIR_CACHE')) { |
| 2391 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2390 | + define('_DIR_CACHE', $ti.'cache/'); |
|
| 2392 | 2391 | } |
| 2393 | 2392 | if (!defined('_DIR_CACHE_XML')) { |
| 2394 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2393 | + define('_DIR_CACHE_XML', _DIR_CACHE.'xml/'); |
|
| 2395 | 2394 | } |
| 2396 | 2395 | if (!defined('_DIR_SKELS')) { |
| 2397 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2396 | + define('_DIR_SKELS', _DIR_CACHE.'skel/'); |
|
| 2398 | 2397 | } |
| 2399 | 2398 | if (!defined('_DIR_AIDE')) { |
| 2400 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2399 | + define('_DIR_AIDE', _DIR_CACHE.'aide/'); |
|
| 2401 | 2400 | } |
| 2402 | 2401 | if (!defined('_DIR_TMP')) { |
| 2403 | 2402 | define('_DIR_TMP', $ti); |
@@ -2426,27 +2425,27 @@ discard block |
||
| 2426 | 2425 | // Declaration des fichiers |
| 2427 | 2426 | |
| 2428 | 2427 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 2429 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2428 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php'); |
|
| 2430 | 2429 | } |
| 2431 | 2430 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 2432 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2431 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php'); |
|
| 2433 | 2432 | } |
| 2434 | 2433 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 2435 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2434 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php'); |
|
| 2436 | 2435 | } |
| 2437 | 2436 | if (!defined('_CACHE_PIPELINES')) { |
| 2438 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2437 | + define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php'); |
|
| 2439 | 2438 | } |
| 2440 | 2439 | if (!defined('_CACHE_CHEMIN')) { |
| 2441 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2440 | + define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt'); |
|
| 2442 | 2441 | } |
| 2443 | 2442 | |
| 2444 | 2443 | # attention .php obligatoire pour ecrire_fichier_securise |
| 2445 | 2444 | if (!defined('_FILE_META')) { |
| 2446 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2445 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 2447 | 2446 | } |
| 2448 | 2447 | if (!defined('_DIR_LOG')) { |
| 2449 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2448 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 2450 | 2449 | } |
| 2451 | 2450 | if (!defined('_FILE_LOG')) { |
| 2452 | 2451 | define('_FILE_LOG', 'spip'); |
@@ -2463,8 +2462,8 @@ discard block |
||
| 2463 | 2462 | if (!defined('_FILE_CONNECT')) { |
| 2464 | 2463 | define( |
| 2465 | 2464 | '_FILE_CONNECT', |
| 2466 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2467 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2465 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f |
|
| 2466 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f |
|
| 2468 | 2467 | : false)) |
| 2469 | 2468 | ); |
| 2470 | 2469 | } |
@@ -2476,7 +2475,7 @@ discard block |
||
| 2476 | 2475 | if (!defined('_FILE_CHMOD')) { |
| 2477 | 2476 | define( |
| 2478 | 2477 | '_FILE_CHMOD', |
| 2479 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2478 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f |
|
| 2480 | 2479 | : false) |
| 2481 | 2480 | ); |
| 2482 | 2481 | } |
@@ -2489,10 +2488,10 @@ discard block |
||
| 2489 | 2488 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 2490 | 2489 | } |
| 2491 | 2490 | if (!defined('_FILE_CONNECT_TMP')) { |
| 2492 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2491 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 2493 | 2492 | } |
| 2494 | 2493 | if (!defined('_FILE_CHMOD_TMP')) { |
| 2495 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2494 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 2496 | 2495 | } |
| 2497 | 2496 | |
| 2498 | 2497 | // Definition des droits d'acces en ecriture |
@@ -2510,13 +2509,13 @@ discard block |
||
| 2510 | 2509 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 2511 | 2510 | } |
| 2512 | 2511 | if (!defined('_ROOT_PLUGINS')) { |
| 2513 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2512 | + define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/'); |
|
| 2514 | 2513 | } |
| 2515 | 2514 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 2516 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2515 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/'); |
|
| 2517 | 2516 | } |
| 2518 | 2517 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 2519 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2518 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2520 | 2519 | } |
| 2521 | 2520 | |
| 2522 | 2521 | // La taille des Log |
@@ -2553,7 +2552,7 @@ discard block |
||
| 2553 | 2552 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 2554 | 2553 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 2555 | 2554 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 2556 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2555 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 2557 | 2556 | |
| 2558 | 2557 | // charger tout de suite le path et son cache |
| 2559 | 2558 | load_path_cache(); |
@@ -2601,7 +2600,7 @@ discard block |
||
| 2601 | 2600 | !empty($_SERVER['QUERY_STRING']) |
| 2602 | 2601 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2603 | 2602 | ) { |
| 2604 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2603 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2605 | 2604 | } |
| 2606 | 2605 | } |
| 2607 | 2606 | |
@@ -2637,7 +2636,7 @@ discard block |
||
| 2637 | 2636 | ) { |
| 2638 | 2637 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 2639 | 2638 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 2640 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2639 | + $uri_ref = ($uri_ref['path'] ?? '').'/'; |
|
| 2641 | 2640 | } else { |
| 2642 | 2641 | $uri_ref = ''; |
| 2643 | 2642 | } |
@@ -2731,7 +2730,7 @@ discard block |
||
| 2731 | 2730 | } |
| 2732 | 2731 | if (!defined('_CACHE_RUBRIQUES')) { |
| 2733 | 2732 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 2734 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2733 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2735 | 2734 | } |
| 2736 | 2735 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 2737 | 2736 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -2835,7 +2834,7 @@ discard block |
||
| 2835 | 2834 | $memory *= 1024; |
| 2836 | 2835 | } |
| 2837 | 2836 | if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
| 2838 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2837 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M'); |
|
| 2839 | 2838 | if (trim(ini_get('memory_limit')) != $m) { |
| 2840 | 2839 | if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
| 2841 | 2840 | define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
@@ -2986,7 +2985,7 @@ discard block |
||
| 2986 | 2985 | } |
| 2987 | 2986 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 2988 | 2987 | spip_log($GLOBALS['visiteur_session']['nom'] |
| 2989 | - . ' ' . _VAR_MODE); |
|
| 2988 | + . ' '._VAR_MODE); |
|
| 2990 | 2989 | } |
| 2991 | 2990 | } // pas autorise ? |
| 2992 | 2991 | else { |
@@ -3001,7 +3000,7 @@ discard block |
||
| 3001 | 3000 | if (strpos($self, 'page=login') === false) { |
| 3002 | 3001 | include_spip('inc/headers'); |
| 3003 | 3002 | $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
| 3004 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3003 | + redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true)); |
|
| 3005 | 3004 | } |
| 3006 | 3005 | } |
| 3007 | 3006 | // sinon tant pis |
@@ -3043,10 +3042,10 @@ discard block |
||
| 3043 | 3042 | // mais on risque de perturber des plugins en initialisant trop tot |
| 3044 | 3043 | // certaines constantes |
| 3045 | 3044 | @spip_initialisation_core( |
| 3046 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3047 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3048 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3049 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3045 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 3046 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 3047 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3048 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3050 | 3049 | ); |
| 3051 | 3050 | |
| 3052 | 3051 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
@@ -3079,7 +3078,7 @@ discard block |
||
| 3079 | 3078 | } |
| 3080 | 3079 | |
| 3081 | 3080 | $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
| 3082 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3081 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 3083 | 3082 | $session = charger_fonction('session', 'inc'); |
| 3084 | 3083 | if ($session()) { |
| 3085 | 3084 | return $GLOBALS['visiteur_session']['statut']; |
@@ -3159,7 +3158,7 @@ discard block |
||
| 3159 | 3158 | 'definir_session', |
| 3160 | 3159 | $GLOBALS['visiteur_session'] |
| 3161 | 3160 | ? serialize($GLOBALS['visiteur_session']) |
| 3162 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3161 | + . '_'.@$_COOKIE['spip_session'] |
|
| 3163 | 3162 | : '' |
| 3164 | 3163 | ); |
| 3165 | 3164 | $session = $s ? substr(md5($s), 0, 8) : ''; |
@@ -3315,11 +3314,11 @@ discard block |
||
| 3315 | 3314 | $GLOBALS['_INC_PUBLIC']++; |
| 3316 | 3315 | |
| 3317 | 3316 | // fix #4235 |
| 3318 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3317 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3319 | 3318 | |
| 3320 | 3319 | |
| 3321 | 3320 | foreach (is_array($fond) ? $fond : [$fond] as $f) { |
| 3322 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3321 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3323 | 3322 | |
| 3324 | 3323 | $page = evaluer_fond($f, $contexte, $connect); |
| 3325 | 3324 | if ($page === '') { |
@@ -3404,7 +3403,7 @@ discard block |
||
| 3404 | 3403 | * @return array|string |
| 3405 | 3404 | */ |
| 3406 | 3405 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3407 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3406 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 3408 | 3407 | if (!$pathinfo) { |
| 3409 | 3408 | return $f; |
| 3410 | 3409 | } |