@@ -62,6 +62,11 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // http://doc.spip.org/@sous_menu_rubriques |
| 65 | +/** |
|
| 66 | + * @param integer $root |
|
| 67 | + * @param integer $niv |
|
| 68 | + * @param integer $exclus |
|
| 69 | + */ |
|
| 65 | 70 | function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) { |
| 66 | 71 | static $decalage_secteur; |
| 67 | 72 | |
@@ -205,6 +210,12 @@ discard block |
||
| 205 | 210 | // getElement en mode Ajax est trop couteux). |
| 206 | 211 | |
| 207 | 212 | // http://doc.spip.org/@construire_selecteur |
| 213 | +/** |
|
| 214 | + * @param string $url |
|
| 215 | + * @param string $js |
|
| 216 | + * @param string $idom |
|
| 217 | + * @param string $name |
|
| 218 | + */ |
|
| 208 | 219 | function construire_selecteur($url, $js, $idom, $name, $init='', $id=0){ |
| 209 | 220 | $icone = (strpos($idom, 'auteur')!==false) ? 'auteur-24.png' : 'rechercher-20.png'; |
| 210 | 221 | return |
@@ -24,18 +24,18 @@ discard block |
||
| 24 | 24 | // $idem : en mode rubrique = la rubrique soi-meme |
| 25 | 25 | // http://doc.spip.org/@inc_chercher_rubrique_dist |
| 26 | 26 | function inc_chercher_rubrique_dist ($id_rubrique, $type, $restreint, $idem=0, $do='aff') { |
| 27 | - if (sql_countsel('spip_rubriques')<1) |
|
| 28 | - return ''; |
|
| 27 | + if (sql_countsel('spip_rubriques')<1) |
|
| 28 | + return ''; |
|
| 29 | 29 | |
| 30 | - // Mode sans Ajax : |
|
| 31 | - // - soit parce que le cookie ajax n'est pas la |
|
| 32 | - // - soit parce qu'il y a peu de rubriques |
|
| 33 | - if (_SPIP_AJAX < 1 |
|
| 34 | - OR $type == 'breve' |
|
| 35 | - OR sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES) |
|
| 36 | - return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 30 | + // Mode sans Ajax : |
|
| 31 | + // - soit parce que le cookie ajax n'est pas la |
|
| 32 | + // - soit parce qu'il y a peu de rubriques |
|
| 33 | + if (_SPIP_AJAX < 1 |
|
| 34 | + OR $type == 'breve' |
|
| 35 | + OR sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES) |
|
| 36 | + return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 37 | 37 | |
| 38 | - else return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 38 | + else return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
@@ -44,119 +44,119 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | // http://doc.spip.org/@style_menu_rubriques |
| 46 | 46 | function style_menu_rubriques($i) { |
| 47 | - global $browser_name, $spip_lang_left; |
|
| 48 | - |
|
| 49 | - $espace = ''; |
|
| 50 | - if (preg_match(",mozilla,i", $browser_name)) { |
|
| 51 | - $style = "padding-$spip_lang_left: 16px; " |
|
| 52 | - . "margin-$spip_lang_left: ".(($i-1)*16)."px;"; |
|
| 53 | - } else { |
|
| 54 | - $style = ''; |
|
| 55 | - for ($count = 0; $count <= $i; $count ++) |
|
| 56 | - $espace .= " "; |
|
| 57 | - } |
|
| 58 | - if ($i ==1) |
|
| 59 | - $espace= ""; |
|
| 60 | - $class = "niveau_$i"; |
|
| 61 | - return array($class,$style,$espace); |
|
| 47 | + global $browser_name, $spip_lang_left; |
|
| 48 | + |
|
| 49 | + $espace = ''; |
|
| 50 | + if (preg_match(",mozilla,i", $browser_name)) { |
|
| 51 | + $style = "padding-$spip_lang_left: 16px; " |
|
| 52 | + . "margin-$spip_lang_left: ".(($i-1)*16)."px;"; |
|
| 53 | + } else { |
|
| 54 | + $style = ''; |
|
| 55 | + for ($count = 0; $count <= $i; $count ++) |
|
| 56 | + $espace .= " "; |
|
| 57 | + } |
|
| 58 | + if ($i ==1) |
|
| 59 | + $espace= ""; |
|
| 60 | + $class = "niveau_$i"; |
|
| 61 | + return array($class,$style,$espace); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // http://doc.spip.org/@sous_menu_rubriques |
| 65 | 65 | function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) { |
| 66 | - static $decalage_secteur; |
|
| 66 | + static $decalage_secteur; |
|
| 67 | 67 | |
| 68 | - // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 69 | - if ($exclus > 0 |
|
| 70 | - AND $root == $exclus) return ''; |
|
| 68 | + // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 69 | + if ($exclus > 0 |
|
| 70 | + AND $root == $exclus) return ''; |
|
| 71 | 71 | |
| 72 | - // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 72 | + // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 73 | 73 | |
| 74 | - // selected ? |
|
| 75 | - $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 74 | + // selected ? |
|
| 75 | + $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 76 | 76 | |
| 77 | - // le style en fonction de la profondeur |
|
| 78 | - list($class, $style, $espace) = style_menu_rubriques($niv); |
|
| 77 | + // le style en fonction de la profondeur |
|
| 78 | + list($class, $style, $espace) = style_menu_rubriques($niv); |
|
| 79 | 79 | |
| 80 | - $class .= " selec_rub"; |
|
| 80 | + $class .= " selec_rub"; |
|
| 81 | 81 | |
| 82 | - // creer l'<option> pour la rubrique $root |
|
| 82 | + // creer l'<option> pour la rubrique $root |
|
| 83 | 83 | |
| 84 | - if (isset($data[$root])) # pas de racine sauf pour les rubriques |
|
| 85 | - { |
|
| 86 | - $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 87 | - .$data[$root] |
|
| 88 | - .'</option>'."\n"; |
|
| 89 | - } else $r = ''; |
|
| 84 | + if (isset($data[$root])) # pas de racine sauf pour les rubriques |
|
| 85 | + { |
|
| 86 | + $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 87 | + .$data[$root] |
|
| 88 | + .'</option>'."\n"; |
|
| 89 | + } else $r = ''; |
|
| 90 | 90 | |
| 91 | - // et le sous-menu pour ses enfants |
|
| 92 | - $sous = ''; |
|
| 93 | - if (isset($enfants[$root])) |
|
| 94 | - foreach ($enfants[$root] as $sousrub) |
|
| 95 | - $sous .= sous_menu_rubriques($id_rubrique, $sousrub, |
|
| 96 | - $niv+1, $data, $enfants, $exclus, $restreint, $type); |
|
| 97 | - |
|
| 98 | - // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 99 | - if ($restreint AND $root!=$id_rubrique AND !autoriser('publierdans','rubrique',$root)) |
|
| 100 | - return $sous; |
|
| 101 | - |
|
| 102 | - // et voila le travail |
|
| 103 | - return $r.$sous; |
|
| 91 | + // et le sous-menu pour ses enfants |
|
| 92 | + $sous = ''; |
|
| 93 | + if (isset($enfants[$root])) |
|
| 94 | + foreach ($enfants[$root] as $sousrub) |
|
| 95 | + $sous .= sous_menu_rubriques($id_rubrique, $sousrub, |
|
| 96 | + $niv+1, $data, $enfants, $exclus, $restreint, $type); |
|
| 97 | + |
|
| 98 | + // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 99 | + if ($restreint AND $root!=$id_rubrique AND !autoriser('publierdans','rubrique',$root)) |
|
| 100 | + return $sous; |
|
| 101 | + |
|
| 102 | + // et voila le travail |
|
| 103 | + return $r.$sous; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Le selecteur de rubriques en mode classique (menu) |
| 107 | 107 | // http://doc.spip.org/@selecteur_rubrique_html |
| 108 | 108 | function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem=0) { |
| 109 | - $data = array(); |
|
| 110 | - if ($type == 'rubrique' AND autoriser('publierdans','rubrique',0)) |
|
| 111 | - $data[0] = _T('info_racine_site'); |
|
| 112 | - # premier choix = neant |
|
| 113 | - # si auteur (rubriques restreintes) |
|
| 114 | - # ou si creation avec id_rubrique=0 |
|
| 115 | - elseif ($type == 'auteur' OR !$id_rubrique) |
|
| 116 | - $data[0] = ' '; |
|
| 117 | - |
|
| 118 | - // |
|
| 119 | - // creer une structure contenant toute l'arborescence |
|
| 120 | - // |
|
| 121 | - |
|
| 122 | - include_spip('base/abstract_sql'); |
|
| 123 | - $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); |
|
| 124 | - while ($r = sql_fetch($q)) { |
|
| 125 | - if (autoriser('voir','rubrique',$r['id_rubrique'])){ |
|
| 126 | - // titre largeur maxi a 50 |
|
| 127 | - $titre = couper(supprimer_tags(typo($r['titre']))." ", 50); |
|
| 128 | - if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 129 | - AND ($r['langue_choisie'] == "oui" OR $r['id_parent'] == 0)) |
|
| 130 | - $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 131 | - $data[$r['id_rubrique']] = $titre; |
|
| 132 | - $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 133 | - if ($id_rubrique == $r['id_rubrique']) $id_parent = $r['id_parent']; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // si une seule rubrique comme choix possible, |
|
| 138 | - // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 139 | - // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 140 | - if (count($data)==2 |
|
| 141 | - AND isset($data[0]) |
|
| 142 | - AND !in_array($type,array('auteur','rubrique')) |
|
| 143 | - AND !$id_rubrique) |
|
| 144 | - unset($data[0]); |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - $opt = sous_menu_rubriques($id_rubrique,0, 0,$data,$enfants,$idem, $restreint, $type); |
|
| 148 | - $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 149 | - |
|
| 150 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,',$opt,$r)) |
|
| 151 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2] ; |
|
| 152 | - else |
|
| 153 | - $r = "<select".$att." size='1'>\n$opt</select>\n"; |
|
| 154 | - |
|
| 155 | - # message pour neuneus (a supprimer ?) |
|
| 109 | + $data = array(); |
|
| 110 | + if ($type == 'rubrique' AND autoriser('publierdans','rubrique',0)) |
|
| 111 | + $data[0] = _T('info_racine_site'); |
|
| 112 | + # premier choix = neant |
|
| 113 | + # si auteur (rubriques restreintes) |
|
| 114 | + # ou si creation avec id_rubrique=0 |
|
| 115 | + elseif ($type == 'auteur' OR !$id_rubrique) |
|
| 116 | + $data[0] = ' '; |
|
| 117 | + |
|
| 118 | + // |
|
| 119 | + // creer une structure contenant toute l'arborescence |
|
| 120 | + // |
|
| 121 | + |
|
| 122 | + include_spip('base/abstract_sql'); |
|
| 123 | + $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); |
|
| 124 | + while ($r = sql_fetch($q)) { |
|
| 125 | + if (autoriser('voir','rubrique',$r['id_rubrique'])){ |
|
| 126 | + // titre largeur maxi a 50 |
|
| 127 | + $titre = couper(supprimer_tags(typo($r['titre']))." ", 50); |
|
| 128 | + if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 129 | + AND ($r['langue_choisie'] == "oui" OR $r['id_parent'] == 0)) |
|
| 130 | + $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 131 | + $data[$r['id_rubrique']] = $titre; |
|
| 132 | + $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 133 | + if ($id_rubrique == $r['id_rubrique']) $id_parent = $r['id_parent']; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // si une seule rubrique comme choix possible, |
|
| 138 | + // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 139 | + // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 140 | + if (count($data)==2 |
|
| 141 | + AND isset($data[0]) |
|
| 142 | + AND !in_array($type,array('auteur','rubrique')) |
|
| 143 | + AND !$id_rubrique) |
|
| 144 | + unset($data[0]); |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + $opt = sous_menu_rubriques($id_rubrique,0, 0,$data,$enfants,$idem, $restreint, $type); |
|
| 148 | + $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 149 | + |
|
| 150 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,',$opt,$r)) |
|
| 151 | + $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2] ; |
|
| 152 | + else |
|
| 153 | + $r = "<select".$att." size='1'>\n$opt</select>\n"; |
|
| 154 | + |
|
| 155 | + # message pour neuneus (a supprimer ?) |
|
| 156 | 156 | # if ($type != 'auteur' AND $type != 'breve') |
| 157 | 157 | # $r .= "\n<br />"._T('texte_rappel_selection_champs'); |
| 158 | 158 | |
| 159 | - return $r; |
|
| 159 | + return $r; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -179,23 +179,23 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem=0, $do) { |
| 181 | 181 | |
| 182 | - if ($id_rubrique) { |
|
| 183 | - $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 184 | - } else if ($type == 'auteur') |
|
| 185 | - $titre = ' '; |
|
| 186 | - else |
|
| 187 | - $titre = _T('info_racine_site'); |
|
| 182 | + if ($id_rubrique) { |
|
| 183 | + $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 184 | + } else if ($type == 'auteur') |
|
| 185 | + $titre = ' '; |
|
| 186 | + else |
|
| 187 | + $titre = _T('info_racine_site'); |
|
| 188 | 188 | |
| 189 | - $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 190 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 189 | + $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 190 | + $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 191 | 191 | |
| 192 | - $url = generer_url_ecrire('selectionner',"id=$id_rubrique&type=$type&do=$do" |
|
| 193 | - . (!$idem ? '' : "&exclus=$idem") |
|
| 194 | - . ($restreint ? "" : "&racine=oui") |
|
| 195 | - . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 192 | + $url = generer_url_ecrire('selectionner',"id=$id_rubrique&type=$type&do=$do" |
|
| 193 | + . (!$idem ? '' : "&exclus=$idem") |
|
| 194 | + . ($restreint ? "" : "&racine=oui") |
|
| 195 | + . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 196 | 196 | |
| 197 | 197 | |
| 198 | - return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 198 | + return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // construit un bloc comportant une icone clicable avec image animee a cote |
@@ -206,26 +206,26 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | // http://doc.spip.org/@construire_selecteur |
| 208 | 208 | function construire_selecteur($url, $js, $idom, $name, $init='', $id=0){ |
| 209 | - $icone = (strpos($idom, 'auteur')!==false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 210 | - return |
|
| 211 | - "<div class='rubrique_actuelle'><a href='#' onclick=\"" |
|
| 212 | - . $js |
|
| 213 | - . "return charger_node_url_si_vide('" |
|
| 214 | - . $url |
|
| 215 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='"._T('titre_image_selecteur')."'><img src='" |
|
| 216 | - . chemin_image($icone) |
|
| 217 | - . "'\nstyle='vertical-align: middle;' alt='"._T('titre_image_selecteur')."' /></a><img src='" |
|
| 218 | - . chemin_image('searching.gif') |
|
| 219 | - . "' id='img_" |
|
| 220 | - . $idom |
|
| 221 | - . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 222 | - . "<input id='titreparent' name='titreparent'" |
|
| 223 | - . $init |
|
| 224 | - . " />" |
|
| 225 | - . "<input type='hidden' id='$name' name='$name' value='" |
|
| 226 | - . $id |
|
| 227 | - . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 228 | - . $idom |
|
| 229 | - . "'\nstyle='display: none;'></div>"; |
|
| 209 | + $icone = (strpos($idom, 'auteur')!==false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 210 | + return |
|
| 211 | + "<div class='rubrique_actuelle'><a href='#' onclick=\"" |
|
| 212 | + . $js |
|
| 213 | + . "return charger_node_url_si_vide('" |
|
| 214 | + . $url |
|
| 215 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='"._T('titre_image_selecteur')."'><img src='" |
|
| 216 | + . chemin_image($icone) |
|
| 217 | + . "'\nstyle='vertical-align: middle;' alt='"._T('titre_image_selecteur')."' /></a><img src='" |
|
| 218 | + . chemin_image('searching.gif') |
|
| 219 | + . "' id='img_" |
|
| 220 | + . $idom |
|
| 221 | + . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 222 | + . "<input id='titreparent' name='titreparent'" |
|
| 223 | + . $init |
|
| 224 | + . " />" |
|
| 225 | + . "<input type='hidden' id='$name' name='$name' value='" |
|
| 226 | + . $id |
|
| 227 | + . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 228 | + . $idom |
|
| 229 | + . "'\nstyle='display: none;'></div>"; |
|
| 230 | 230 | } |
| 231 | 231 | ?> |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | // n'importe ou (defaut), et les breves dans les secteurs. |
| 24 | 24 | // $idem : en mode rubrique = la rubrique soi-meme |
| 25 | 25 | // http://doc.spip.org/@inc_chercher_rubrique_dist |
| 26 | -function inc_chercher_rubrique_dist ($id_rubrique, $type, $restreint, $idem=0, $do='aff') { |
|
| 27 | - if (sql_countsel('spip_rubriques')<1) |
|
| 26 | +function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
|
| 27 | + if (sql_countsel('spip_rubriques') < 1) |
|
| 28 | 28 | return ''; |
| 29 | 29 | |
| 30 | 30 | // Mode sans Ajax : |
@@ -49,16 +49,16 @@ discard block |
||
| 49 | 49 | $espace = ''; |
| 50 | 50 | if (preg_match(",mozilla,i", $browser_name)) { |
| 51 | 51 | $style = "padding-$spip_lang_left: 16px; " |
| 52 | - . "margin-$spip_lang_left: ".(($i-1)*16)."px;"; |
|
| 52 | + . "margin-$spip_lang_left: ".(($i - 1) * 16)."px;"; |
|
| 53 | 53 | } else { |
| 54 | 54 | $style = ''; |
| 55 | - for ($count = 0; $count <= $i; $count ++) |
|
| 55 | + for ($count = 0; $count <= $i; $count++) |
|
| 56 | 56 | $espace .= " "; |
| 57 | 57 | } |
| 58 | - if ($i ==1) |
|
| 59 | - $espace= ""; |
|
| 58 | + if ($i == 1) |
|
| 59 | + $espace = ""; |
|
| 60 | 60 | $class = "niveau_$i"; |
| 61 | - return array($class,$style,$espace); |
|
| 61 | + return array($class, $style, $espace); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // http://doc.spip.org/@sous_menu_rubriques |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | if (isset($enfants[$root])) |
| 94 | 94 | foreach ($enfants[$root] as $sousrub) |
| 95 | 95 | $sous .= sous_menu_rubriques($id_rubrique, $sousrub, |
| 96 | - $niv+1, $data, $enfants, $exclus, $restreint, $type); |
|
| 96 | + $niv + 1, $data, $enfants, $exclus, $restreint, $type); |
|
| 97 | 97 | |
| 98 | 98 | // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
| 99 | - if ($restreint AND $root!=$id_rubrique AND !autoriser('publierdans','rubrique',$root)) |
|
| 99 | + if ($restreint AND $root != $id_rubrique AND !autoriser('publierdans', 'rubrique', $root)) |
|
| 100 | 100 | return $sous; |
| 101 | 101 | |
| 102 | 102 | // et voila le travail |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | // Le selecteur de rubriques en mode classique (menu) |
| 107 | 107 | // http://doc.spip.org/@selecteur_rubrique_html |
| 108 | -function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem=0) { |
|
| 108 | +function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) { |
|
| 109 | 109 | $data = array(); |
| 110 | - if ($type == 'rubrique' AND autoriser('publierdans','rubrique',0)) |
|
| 110 | + if ($type == 'rubrique' AND autoriser('publierdans', 'rubrique', 0)) |
|
| 111 | 111 | $data[0] = _T('info_racine_site'); |
| 112 | 112 | # premier choix = neant |
| 113 | 113 | # si auteur (rubriques restreintes) |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | // |
| 121 | 121 | |
| 122 | 122 | include_spip('base/abstract_sql'); |
| 123 | - $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); |
|
| 123 | + $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); |
|
| 124 | 124 | while ($r = sql_fetch($q)) { |
| 125 | - if (autoriser('voir','rubrique',$r['id_rubrique'])){ |
|
| 125 | + if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 126 | 126 | // titre largeur maxi a 50 |
| 127 | 127 | $titre = couper(supprimer_tags(typo($r['titre']))." ", 50); |
| 128 | 128 | if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
@@ -137,18 +137,18 @@ discard block |
||
| 137 | 137 | // si une seule rubrique comme choix possible, |
| 138 | 138 | // inutile de mettre le selecteur sur un choix vide par defaut |
| 139 | 139 | // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
| 140 | - if (count($data)==2 |
|
| 140 | + if (count($data) == 2 |
|
| 141 | 141 | AND isset($data[0]) |
| 142 | - AND !in_array($type,array('auteur','rubrique')) |
|
| 142 | + AND !in_array($type, array('auteur', 'rubrique')) |
|
| 143 | 143 | AND !$id_rubrique) |
| 144 | 144 | unset($data[0]); |
| 145 | 145 | |
| 146 | 146 | |
| 147 | - $opt = sous_menu_rubriques($id_rubrique,0, 0,$data,$enfants,$idem, $restreint, $type); |
|
| 147 | + $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 148 | 148 | $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
| 149 | 149 | |
| 150 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,',$opt,$r)) |
|
| 151 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2] ; |
|
| 150 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) |
|
| 151 | + $r = "<input$att type='hidden' value='".$r[1]."' />".$r[2]; |
|
| 152 | 152 | else |
| 153 | 153 | $r = "<select".$att." size='1'>\n$opt</select>\n"; |
| 154 | 154 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * @param string $do |
| 178 | 178 | * @return string |
| 179 | 179 | */ |
| 180 | -function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem=0, $do) { |
|
| 180 | +function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do) { |
|
| 181 | 181 | |
| 182 | 182 | if ($id_rubrique) { |
| 183 | 183 | $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | $titre = _T('info_racine_site'); |
| 188 | 188 | |
| 189 | 189 | $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
| 190 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 190 | + $init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'"; |
|
| 191 | 191 | |
| 192 | - $url = generer_url_ecrire('selectionner',"id=$id_rubrique&type=$type&do=$do" |
|
| 192 | + $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 193 | 193 | . (!$idem ? '' : "&exclus=$idem") |
| 194 | 194 | . ($restreint ? "" : "&racine=oui") |
| 195 | 195 | . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | // getElement en mode Ajax est trop couteux). |
| 206 | 206 | |
| 207 | 207 | // http://doc.spip.org/@construire_selecteur |
| 208 | -function construire_selecteur($url, $js, $idom, $name, $init='', $id=0){ |
|
| 209 | - $icone = (strpos($idom, 'auteur')!==false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 208 | +function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) { |
|
| 209 | + $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 210 | 210 | return |
| 211 | 211 | "<div class='rubrique_actuelle'><a href='#' onclick=\"" |
| 212 | 212 | . $js |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | define('_SPIP_SELECT_RUBRIQUES', 20); /* mettre 100000 pour desactiver ajax */ |
| 16 | 18 | |
@@ -24,18 +26,20 @@ discard block |
||
| 24 | 26 | // $idem : en mode rubrique = la rubrique soi-meme |
| 25 | 27 | // http://doc.spip.org/@inc_chercher_rubrique_dist |
| 26 | 28 | function inc_chercher_rubrique_dist ($id_rubrique, $type, $restreint, $idem=0, $do='aff') { |
| 27 | - if (sql_countsel('spip_rubriques')<1) |
|
| 28 | - return ''; |
|
| 29 | + if (sql_countsel('spip_rubriques')<1) { |
|
| 30 | + return ''; |
|
| 31 | + } |
|
| 29 | 32 | |
| 30 | 33 | // Mode sans Ajax : |
| 31 | 34 | // - soit parce que le cookie ajax n'est pas la |
| 32 | 35 | // - soit parce qu'il y a peu de rubriques |
| 33 | 36 | if (_SPIP_AJAX < 1 |
| 34 | 37 | OR $type == 'breve' |
| 35 | - OR sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES) |
|
| 36 | - return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 37 | - |
|
| 38 | - else return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 38 | + OR sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES) { |
|
| 39 | + return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 40 | + } else { |
|
| 41 | + return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 42 | + } |
|
| 39 | 43 | |
| 40 | 44 | } |
| 41 | 45 | |
@@ -52,11 +56,13 @@ discard block |
||
| 52 | 56 | . "margin-$spip_lang_left: ".(($i-1)*16)."px;"; |
| 53 | 57 | } else { |
| 54 | 58 | $style = ''; |
| 55 | - for ($count = 0; $count <= $i; $count ++) |
|
| 56 | - $espace .= " "; |
|
| 59 | + for ($count = 0; $count <= $i; $count ++) { |
|
| 60 | + $espace .= " "; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + if ($i ==1) { |
|
| 64 | + $espace= ""; |
|
| 57 | 65 | } |
| 58 | - if ($i ==1) |
|
| 59 | - $espace= ""; |
|
| 60 | 66 | $class = "niveau_$i"; |
| 61 | 67 | return array($class,$style,$espace); |
| 62 | 68 | } |
@@ -67,7 +73,9 @@ discard block |
||
| 67 | 73 | |
| 68 | 74 | // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
| 69 | 75 | if ($exclus > 0 |
| 70 | - AND $root == $exclus) return ''; |
|
| 76 | + AND $root == $exclus) { |
|
| 77 | + return ''; |
|
| 78 | + } |
|
| 71 | 79 | |
| 72 | 80 | // en fonction du niveau faire un affichage plus ou moins kikoo |
| 73 | 81 | |
@@ -81,23 +89,29 @@ discard block |
||
| 81 | 89 | |
| 82 | 90 | // creer l'<option> pour la rubrique $root |
| 83 | 91 | |
| 84 | - if (isset($data[$root])) # pas de racine sauf pour les rubriques |
|
| 92 | + if (isset($data[$root])) { |
|
| 93 | + # pas de racine sauf pour les rubriques |
|
| 85 | 94 | { |
| 86 | 95 | $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
| 87 | 96 | .$data[$root] |
| 88 | 97 | .'</option>'."\n"; |
| 89 | - } else $r = ''; |
|
| 98 | + } |
|
| 99 | + } else { |
|
| 100 | + $r = ''; |
|
| 101 | + } |
|
| 90 | 102 | |
| 91 | 103 | // et le sous-menu pour ses enfants |
| 92 | 104 | $sous = ''; |
| 93 | - if (isset($enfants[$root])) |
|
| 94 | - foreach ($enfants[$root] as $sousrub) |
|
| 105 | + if (isset($enfants[$root])) { |
|
| 106 | + foreach ($enfants[$root] as $sousrub) |
|
| 95 | 107 | $sous .= sous_menu_rubriques($id_rubrique, $sousrub, |
| 96 | 108 | $niv+1, $data, $enfants, $exclus, $restreint, $type); |
| 109 | + } |
|
| 97 | 110 | |
| 98 | 111 | // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
| 99 | - if ($restreint AND $root!=$id_rubrique AND !autoriser('publierdans','rubrique',$root)) |
|
| 100 | - return $sous; |
|
| 112 | + if ($restreint AND $root!=$id_rubrique AND !autoriser('publierdans','rubrique',$root)) { |
|
| 113 | + return $sous; |
|
| 114 | + } |
|
| 101 | 115 | |
| 102 | 116 | // et voila le travail |
| 103 | 117 | return $r.$sous; |
@@ -107,13 +121,15 @@ discard block |
||
| 107 | 121 | // http://doc.spip.org/@selecteur_rubrique_html |
| 108 | 122 | function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem=0) { |
| 109 | 123 | $data = array(); |
| 110 | - if ($type == 'rubrique' AND autoriser('publierdans','rubrique',0)) |
|
| 111 | - $data[0] = _T('info_racine_site'); |
|
| 124 | + if ($type == 'rubrique' AND autoriser('publierdans','rubrique',0)) { |
|
| 125 | + $data[0] = _T('info_racine_site'); |
|
| 126 | + } |
|
| 112 | 127 | # premier choix = neant |
| 113 | 128 | # si auteur (rubriques restreintes) |
| 114 | 129 | # ou si creation avec id_rubrique=0 |
| 115 | - elseif ($type == 'auteur' OR !$id_rubrique) |
|
| 116 | - $data[0] = ' '; |
|
| 130 | + elseif ($type == 'auteur' OR !$id_rubrique) { |
|
| 131 | + $data[0] = ' '; |
|
| 132 | + } |
|
| 117 | 133 | |
| 118 | 134 | // |
| 119 | 135 | // creer une structure contenant toute l'arborescence |
@@ -126,11 +142,14 @@ discard block |
||
| 126 | 142 | // titre largeur maxi a 50 |
| 127 | 143 | $titre = couper(supprimer_tags(typo($r['titre']))." ", 50); |
| 128 | 144 | if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
| 129 | - AND ($r['langue_choisie'] == "oui" OR $r['id_parent'] == 0)) |
|
| 130 | - $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 145 | + AND ($r['langue_choisie'] == "oui" OR $r['id_parent'] == 0)) { |
|
| 146 | + $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 147 | + } |
|
| 131 | 148 | $data[$r['id_rubrique']] = $titre; |
| 132 | 149 | $enfants[$r['id_parent']][] = $r['id_rubrique']; |
| 133 | - if ($id_rubrique == $r['id_rubrique']) $id_parent = $r['id_parent']; |
|
| 150 | + if ($id_rubrique == $r['id_rubrique']) { |
|
| 151 | + $id_parent = $r['id_parent']; |
|
| 152 | + } |
|
| 134 | 153 | } |
| 135 | 154 | } |
| 136 | 155 | |
@@ -140,17 +159,19 @@ discard block |
||
| 140 | 159 | if (count($data)==2 |
| 141 | 160 | AND isset($data[0]) |
| 142 | 161 | AND !in_array($type,array('auteur','rubrique')) |
| 143 | - AND !$id_rubrique) |
|
| 144 | - unset($data[0]); |
|
| 162 | + AND !$id_rubrique) { |
|
| 163 | + unset($data[0]); |
|
| 164 | + } |
|
| 145 | 165 | |
| 146 | 166 | |
| 147 | 167 | $opt = sous_menu_rubriques($id_rubrique,0, 0,$data,$enfants,$idem, $restreint, $type); |
| 148 | 168 | $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
| 149 | 169 | |
| 150 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,',$opt,$r)) |
|
| 151 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2] ; |
|
| 152 | - else |
|
| 153 | - $r = "<select".$att." size='1'>\n$opt</select>\n"; |
|
| 170 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,',$opt,$r)) { |
|
| 171 | + $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2] ; |
|
| 172 | + } else { |
|
| 173 | + $r = "<select".$att." size='1'>\n$opt</select>\n"; |
|
| 174 | + } |
|
| 154 | 175 | |
| 155 | 176 | # message pour neuneus (a supprimer ?) |
| 156 | 177 | # if ($type != 'auteur' AND $type != 'breve') |
@@ -181,10 +202,11 @@ discard block |
||
| 181 | 202 | |
| 182 | 203 | if ($id_rubrique) { |
| 183 | 204 | $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
| 184 | - } else if ($type == 'auteur') |
|
| 185 | - $titre = ' '; |
|
| 186 | - else |
|
| 187 | - $titre = _T('info_racine_site'); |
|
| 205 | + } else if ($type == 'auteur') { |
|
| 206 | + $titre = ' '; |
|
| 207 | + } else { |
|
| 208 | + $titre = _T('info_racine_site'); |
|
| 209 | + } |
|
| 188 | 210 | |
| 189 | 211 | $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
| 190 | 212 | $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
@@ -23,39 +23,39 @@ discard block |
||
| 23 | 23 | // |
| 24 | 24 | // http://doc.spip.org/@test_ecrire |
| 25 | 25 | function test_ecrire($my_dir) { |
| 26 | - static $chmod = 0; |
|
| 26 | + static $chmod = 0; |
|
| 27 | 27 | |
| 28 | - $ok = false; |
|
| 29 | - $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 30 | - $self = basename($script); |
|
| 31 | - $uid = @fileowner('.'); |
|
| 32 | - $uid2 = @fileowner($self); |
|
| 33 | - $gid = @filegroup('.'); |
|
| 34 | - $gid2 = @filegroup($self); |
|
| 35 | - $perms = @fileperms($self); |
|
| 36 | - |
|
| 37 | - // Comparer l'appartenance d'un fichier cree par PHP |
|
| 38 | - // avec celle du script et du repertoire courant |
|
| 39 | - if(!$chmod) { |
|
| 40 | - @rmdir('test'); |
|
| 41 | - spip_unlink('test'); // effacer au cas ou |
|
| 42 | - @touch('test'); |
|
| 43 | - if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) |
|
| 44 | - $chmod = 0700; |
|
| 45 | - else if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) |
|
| 46 | - $chmod = 0770; |
|
| 47 | - else |
|
| 48 | - $chmod = 0777; |
|
| 49 | - // Appliquer de plus les droits d'acces du script |
|
| 50 | - if ($perms > 0) { |
|
| 51 | - $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 52 | - $chmod |= $perms; |
|
| 53 | - } |
|
| 54 | - spip_unlink('test'); |
|
| 55 | - } |
|
| 56 | - $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 57 | - |
|
| 58 | - return $ok ? $chmod : false; |
|
| 28 | + $ok = false; |
|
| 29 | + $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 30 | + $self = basename($script); |
|
| 31 | + $uid = @fileowner('.'); |
|
| 32 | + $uid2 = @fileowner($self); |
|
| 33 | + $gid = @filegroup('.'); |
|
| 34 | + $gid2 = @filegroup($self); |
|
| 35 | + $perms = @fileperms($self); |
|
| 36 | + |
|
| 37 | + // Comparer l'appartenance d'un fichier cree par PHP |
|
| 38 | + // avec celle du script et du repertoire courant |
|
| 39 | + if(!$chmod) { |
|
| 40 | + @rmdir('test'); |
|
| 41 | + spip_unlink('test'); // effacer au cas ou |
|
| 42 | + @touch('test'); |
|
| 43 | + if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) |
|
| 44 | + $chmod = 0700; |
|
| 45 | + else if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) |
|
| 46 | + $chmod = 0770; |
|
| 47 | + else |
|
| 48 | + $chmod = 0777; |
|
| 49 | + // Appliquer de plus les droits d'acces du script |
|
| 50 | + if ($perms > 0) { |
|
| 51 | + $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 52 | + $chmod |= $perms; |
|
| 53 | + } |
|
| 54 | + spip_unlink('test'); |
|
| 55 | + } |
|
| 56 | + $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 57 | + |
|
| 58 | + return $ok ? $chmod : false; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // |
@@ -66,73 +66,73 @@ discard block |
||
| 66 | 66 | // http://doc.spip.org/@install_etape_chmod_dist |
| 67 | 67 | function install_etape_chmod_dist() |
| 68 | 68 | { |
| 69 | - global $test_dirs; |
|
| 70 | - $test_dir = _request('test_dir'); |
|
| 71 | - $chmod = 0; |
|
| 72 | - |
|
| 73 | - if ($test_dir) { |
|
| 74 | - if (substr($test_dir,-1)!=='/') $test_dir .= '/'; |
|
| 75 | - if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE . $test_dir; |
|
| 76 | - } else { |
|
| 77 | - if (!_FILE_CONNECT) { |
|
| 78 | - $test_dirs[] = _DIR_CONNECT; |
|
| 79 | - $test_dirs[] = _DIR_CHMOD; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - $bad_dirs = array(); |
|
| 84 | - $absent_dirs = array();; |
|
| 85 | - |
|
| 86 | - while (list(, $my_dir) = each($test_dirs)) { |
|
| 87 | - $test = test_ecrire($my_dir); |
|
| 88 | - if (!$test) { |
|
| 89 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '',$my_dir); |
|
| 90 | - if (@file_exists($my_dir)) { |
|
| 91 | - $bad_dirs["<li>".$m."</li>"] = 1; |
|
| 92 | - } else |
|
| 93 | - $absent_dirs["<li>".$m."</li>"] = 1; |
|
| 94 | - } else $chmod = max($chmod, $test); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if ($bad_dirs OR $absent_dirs) { |
|
| 98 | - |
|
| 99 | - if (!_FILE_CONNECT) { |
|
| 100 | - $titre = _T('dirs_preliminaire'); |
|
| 101 | - $continuer = ' '._T('dirs_commencer') . '.'; |
|
| 102 | - } else |
|
| 103 | - $titre = _T('dirs_probleme_droits'); |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - $res = "<div align='right'>". menu_langues('var_lang_ecrire')."</div>\n"; |
|
| 107 | - |
|
| 108 | - if ($bad_dirs) { |
|
| 109 | - $res .= |
|
| 110 | - _T('dirs_repertoires_suivants', |
|
| 111 | - array('bad_dirs' => join("\n", array_keys($bad_dirs)))) . |
|
| 112 | - "<b>". _T('login_recharger')."</b>."; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - if ($absent_dirs) { |
|
| 116 | - $res .= |
|
| 117 | - _T('dirs_repertoires_absents', |
|
| 118 | - array('bad_dirs' => join("\n", array_keys($absent_dirs)))) . |
|
| 119 | - "<b>". _T('login_recharger')."</b>."; |
|
| 120 | - } |
|
| 121 | - $res = "<p>" . $continuer . $res . aide ("install0", true) . "</p>"; |
|
| 122 | - |
|
| 123 | - $t = _T('login_recharger'); |
|
| 124 | - $t = (!$test_dir ? '' : |
|
| 125 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 126 | - . "<input type='hidden' name='etape' value='chmod' />" |
|
| 127 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 128 | - |
|
| 129 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 130 | - |
|
| 131 | - } else { |
|
| 132 | - $deja = (_FILE_CONNECT AND analyse_fichier_connection(_FILE_CONNECT)); |
|
| 133 | - if (!$deja) |
|
| 134 | - redirige_url_ecrire("install", "etape=1&chmod=".$chmod); |
|
| 135 | - else redirige_url_ecrire(); |
|
| 136 | - } |
|
| 69 | + global $test_dirs; |
|
| 70 | + $test_dir = _request('test_dir'); |
|
| 71 | + $chmod = 0; |
|
| 72 | + |
|
| 73 | + if ($test_dir) { |
|
| 74 | + if (substr($test_dir,-1)!=='/') $test_dir .= '/'; |
|
| 75 | + if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE . $test_dir; |
|
| 76 | + } else { |
|
| 77 | + if (!_FILE_CONNECT) { |
|
| 78 | + $test_dirs[] = _DIR_CONNECT; |
|
| 79 | + $test_dirs[] = _DIR_CHMOD; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + $bad_dirs = array(); |
|
| 84 | + $absent_dirs = array();; |
|
| 85 | + |
|
| 86 | + while (list(, $my_dir) = each($test_dirs)) { |
|
| 87 | + $test = test_ecrire($my_dir); |
|
| 88 | + if (!$test) { |
|
| 89 | + $m = preg_replace(',^' . _DIR_RACINE . ',', '',$my_dir); |
|
| 90 | + if (@file_exists($my_dir)) { |
|
| 91 | + $bad_dirs["<li>".$m."</li>"] = 1; |
|
| 92 | + } else |
|
| 93 | + $absent_dirs["<li>".$m."</li>"] = 1; |
|
| 94 | + } else $chmod = max($chmod, $test); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if ($bad_dirs OR $absent_dirs) { |
|
| 98 | + |
|
| 99 | + if (!_FILE_CONNECT) { |
|
| 100 | + $titre = _T('dirs_preliminaire'); |
|
| 101 | + $continuer = ' '._T('dirs_commencer') . '.'; |
|
| 102 | + } else |
|
| 103 | + $titre = _T('dirs_probleme_droits'); |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + $res = "<div align='right'>". menu_langues('var_lang_ecrire')."</div>\n"; |
|
| 107 | + |
|
| 108 | + if ($bad_dirs) { |
|
| 109 | + $res .= |
|
| 110 | + _T('dirs_repertoires_suivants', |
|
| 111 | + array('bad_dirs' => join("\n", array_keys($bad_dirs)))) . |
|
| 112 | + "<b>". _T('login_recharger')."</b>."; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + if ($absent_dirs) { |
|
| 116 | + $res .= |
|
| 117 | + _T('dirs_repertoires_absents', |
|
| 118 | + array('bad_dirs' => join("\n", array_keys($absent_dirs)))) . |
|
| 119 | + "<b>". _T('login_recharger')."</b>."; |
|
| 120 | + } |
|
| 121 | + $res = "<p>" . $continuer . $res . aide ("install0", true) . "</p>"; |
|
| 122 | + |
|
| 123 | + $t = _T('login_recharger'); |
|
| 124 | + $t = (!$test_dir ? '' : |
|
| 125 | + "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 126 | + . "<input type='hidden' name='etape' value='chmod' />" |
|
| 127 | + . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 128 | + |
|
| 129 | + echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 130 | + |
|
| 131 | + } else { |
|
| 132 | + $deja = (_FILE_CONNECT AND analyse_fichier_connection(_FILE_CONNECT)); |
|
| 133 | + if (!$deja) |
|
| 134 | + redirige_url_ecrire("install", "etape=1&chmod=".$chmod); |
|
| 135 | + else redirige_url_ecrire(); |
|
| 136 | + } |
|
| 137 | 137 | } |
| 138 | 138 | ?> |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | // Comparer l'appartenance d'un fichier cree par PHP |
| 38 | 38 | // avec celle du script et du repertoire courant |
| 39 | - if(!$chmod) { |
|
| 39 | + if (!$chmod) { |
|
| 40 | 40 | @rmdir('test'); |
| 41 | 41 | spip_unlink('test'); // effacer au cas ou |
| 42 | 42 | @touch('test'); |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | function install_etape_chmod_dist() |
| 68 | 68 | { |
| 69 | 69 | global $test_dirs; |
| 70 | - $test_dir = _request('test_dir'); |
|
| 70 | + $test_dir = _request('test_dir'); |
|
| 71 | 71 | $chmod = 0; |
| 72 | 72 | |
| 73 | 73 | if ($test_dir) { |
| 74 | - if (substr($test_dir,-1)!=='/') $test_dir .= '/'; |
|
| 75 | - if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE . $test_dir; |
|
| 74 | + if (substr($test_dir, -1) !== '/') $test_dir .= '/'; |
|
| 75 | + if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE.$test_dir; |
|
| 76 | 76 | } else { |
| 77 | 77 | if (!_FILE_CONNECT) { |
| 78 | 78 | $test_dirs[] = _DIR_CONNECT; |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $bad_dirs = array(); |
| 84 | - $absent_dirs = array();; |
|
| 84 | + $absent_dirs = array(); ; |
|
| 85 | 85 | |
| 86 | 86 | while (list(, $my_dir) = each($test_dirs)) { |
| 87 | 87 | $test = test_ecrire($my_dir); |
| 88 | 88 | if (!$test) { |
| 89 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '',$my_dir); |
|
| 89 | + $m = preg_replace(',^'._DIR_RACINE.',', '', $my_dir); |
|
| 90 | 90 | if (@file_exists($my_dir)) { |
| 91 | 91 | $bad_dirs["<li>".$m."</li>"] = 1; |
| 92 | 92 | } else |
@@ -98,35 +98,34 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | if (!_FILE_CONNECT) { |
| 100 | 100 | $titre = _T('dirs_preliminaire'); |
| 101 | - $continuer = ' '._T('dirs_commencer') . '.'; |
|
| 101 | + $continuer = ' '._T('dirs_commencer').'.'; |
|
| 102 | 102 | } else |
| 103 | 103 | $titre = _T('dirs_probleme_droits'); |
| 104 | 104 | |
| 105 | 105 | |
| 106 | - $res = "<div align='right'>". menu_langues('var_lang_ecrire')."</div>\n"; |
|
| 106 | + $res = "<div align='right'>".menu_langues('var_lang_ecrire')."</div>\n"; |
|
| 107 | 107 | |
| 108 | 108 | if ($bad_dirs) { |
| 109 | 109 | $res .= |
| 110 | 110 | _T('dirs_repertoires_suivants', |
| 111 | - array('bad_dirs' => join("\n", array_keys($bad_dirs)))) . |
|
| 112 | - "<b>". _T('login_recharger')."</b>."; |
|
| 111 | + array('bad_dirs' => join("\n", array_keys($bad_dirs)))). |
|
| 112 | + "<b>"._T('login_recharger')."</b>."; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | if ($absent_dirs) { |
| 116 | 116 | $res .= |
| 117 | 117 | _T('dirs_repertoires_absents', |
| 118 | - array('bad_dirs' => join("\n", array_keys($absent_dirs)))) . |
|
| 119 | - "<b>". _T('login_recharger')."</b>."; |
|
| 118 | + array('bad_dirs' => join("\n", array_keys($absent_dirs)))). |
|
| 119 | + "<b>"._T('login_recharger')."</b>."; |
|
| 120 | 120 | } |
| 121 | - $res = "<p>" . $continuer . $res . aide ("install0", true) . "</p>"; |
|
| 121 | + $res = "<p>".$continuer.$res.aide("install0", true)."</p>"; |
|
| 122 | 122 | |
| 123 | 123 | $t = _T('login_recharger'); |
| 124 | - $t = (!$test_dir ? '' : |
|
| 125 | - "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />") |
|
| 124 | + $t = (!$test_dir ? '' : "<input type='hidden' name='test_dir' value='".spip_htmlspecialchars($test_dir, ENT_QUOTES)."' />") |
|
| 126 | 125 | . "<input type='hidden' name='etape' value='chmod' />" |
| 127 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 126 | + . "<div style='text-align: right'><input type='submit' value='".attribut_html($t)."' /></div>"; |
|
| 128 | 127 | |
| 129 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 128 | + echo minipres($titre, $res.generer_form_ecrire('install', $t)); |
|
| 130 | 129 | |
| 131 | 130 | } else { |
| 132 | 131 | $deja = (_FILE_CONNECT AND analyse_fichier_connection(_FILE_CONNECT)); |
@@ -30,47 +30,47 @@ discard block |
||
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | 32 | function charger_fonction($nom, $dossier='exec', $continue=false) { |
| 33 | - static $echecs = array(); |
|
| 33 | + static $echecs = array(); |
|
| 34 | 34 | |
| 35 | - if (strlen($dossier) AND substr($dossier,-1) != '/') $dossier .= '/'; |
|
| 36 | - $f = str_replace('/','_',$dossier) . $nom; |
|
| 35 | + if (strlen($dossier) AND substr($dossier,-1) != '/') $dossier .= '/'; |
|
| 36 | + $f = str_replace('/','_',$dossier) . $nom; |
|
| 37 | 37 | |
| 38 | - if (function_exists($f)) |
|
| 39 | - return $f; |
|
| 40 | - if (function_exists($g = $f . '_dist')) |
|
| 41 | - return $g; |
|
| 38 | + if (function_exists($f)) |
|
| 39 | + return $f; |
|
| 40 | + if (function_exists($g = $f . '_dist')) |
|
| 41 | + return $g; |
|
| 42 | 42 | |
| 43 | - if (isset($echecs[$f])) return $echecs[$f]; |
|
| 44 | - // Sinon charger le fichier de declaration si plausible |
|
| 43 | + if (isset($echecs[$f])) return $echecs[$f]; |
|
| 44 | + // Sinon charger le fichier de declaration si plausible |
|
| 45 | 45 | |
| 46 | - if (!preg_match(',^\w+$,', $f)){ |
|
| 47 | - if ($continue) return false; //appel interne, on passe |
|
| 48 | - include_spip('inc/minipres'); |
|
| 49 | - echo minipres(); |
|
| 50 | - exit; |
|
| 51 | - } |
|
| 46 | + if (!preg_match(',^\w+$,', $f)){ |
|
| 47 | + if ($continue) return false; //appel interne, on passe |
|
| 48 | + include_spip('inc/minipres'); |
|
| 49 | + echo minipres(); |
|
| 50 | + exit; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - // passer en minuscules (cf les balises de formulaires) |
|
| 54 | - // et inclure le fichier |
|
| 55 | - if (!$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 56 | - // si le fichier truc/machin/nom.php n'existe pas, |
|
| 57 | - // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 58 | - AND strlen(dirname($dossier)) AND dirname($dossier)!='.') |
|
| 59 | - include_spip(substr($dossier,0,-1)); |
|
| 60 | - if (function_exists($f)) return $f; |
|
| 61 | - if (function_exists($g)) return $g; |
|
| 53 | + // passer en minuscules (cf les balises de formulaires) |
|
| 54 | + // et inclure le fichier |
|
| 55 | + if (!$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 56 | + // si le fichier truc/machin/nom.php n'existe pas, |
|
| 57 | + // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 58 | + AND strlen(dirname($dossier)) AND dirname($dossier)!='.') |
|
| 59 | + include_spip(substr($dossier,0,-1)); |
|
| 60 | + if (function_exists($f)) return $f; |
|
| 61 | + if (function_exists($g)) return $g; |
|
| 62 | 62 | |
| 63 | - if ($continue) return $echecs[$f] = false; |
|
| 63 | + if ($continue) return $echecs[$f] = false; |
|
| 64 | 64 | |
| 65 | - // Echec : message d'erreur |
|
| 66 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 67 | - ($inc ? "" : " (fichier $d absent de $dossier)")); |
|
| 65 | + // Echec : message d'erreur |
|
| 66 | + spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 67 | + ($inc ? "" : " (fichier $d absent de $dossier)")); |
|
| 68 | 68 | |
| 69 | - include_spip('inc/minipres'); |
|
| 70 | - echo minipres(_T('forum_titre_erreur'), |
|
| 71 | - _T('fichier_introuvable', array('fichier'=> '<b>'.spip_htmlentities($d).'</b>')), |
|
| 72 | - array('all_inline'=>true,'status'=>404)); |
|
| 73 | - exit; |
|
| 69 | + include_spip('inc/minipres'); |
|
| 70 | + echo minipres(_T('forum_titre_erreur'), |
|
| 71 | + _T('fichier_introuvable', array('fichier'=> '<b>'.spip_htmlentities($d).'</b>')), |
|
| 72 | + array('all_inline'=>true,'status'=>404)); |
|
| 73 | + exit; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | * @return bool |
| 80 | 80 | */ |
| 81 | 81 | function include_once_check($file){ |
| 82 | - if (file_exists($file)) {include_once $file;return true;} |
|
| 83 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins'])?unserialize($GLOBALS['meta']['message_crash_plugins']):''); |
|
| 84 | - $crash = ($crash?$crash:array()); |
|
| 85 | - $crash[$file] = true; |
|
| 86 | - ecrire_meta('message_crash_plugins',serialize($crash)); |
|
| 87 | - return false; |
|
| 82 | + if (file_exists($file)) {include_once $file;return true;} |
|
| 83 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins'])?unserialize($GLOBALS['meta']['message_crash_plugins']):''); |
|
| 84 | + $crash = ($crash?$crash:array()); |
|
| 85 | + $crash[$file] = true; |
|
| 86 | + ecrire_meta('message_crash_plugins',serialize($crash)); |
|
| 87 | + return false; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | // |
| 93 | 93 | // http://doc.spip.org/@include_spip |
| 94 | 94 | function include_spip($f, $include = true) { |
| 95 | - return find_in_path($f . '.php', '', $include); |
|
| 95 | + return find_in_path($f . '.php', '', $include); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
| 99 | 99 | function require_spip($f) { |
| 100 | - return find_in_path($f . '.php', '', 'required'); |
|
| 100 | + return find_in_path($f . '.php', '', 'required'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // un pipeline est lie a une action et une valeur |
@@ -114,59 +114,59 @@ discard block |
||
| 114 | 114 | // on passe $val par reference pour limiter les allocations memoire |
| 115 | 115 | // http://doc.spip.org/@minipipe |
| 116 | 116 | function minipipe($fonc,&$val){ |
| 117 | - // fonction |
|
| 118 | - if (function_exists($fonc)) |
|
| 119 | - $val = call_user_func($fonc, $val); |
|
| 120 | - // Class::Methode |
|
| 121 | - else if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 122 | - AND $methode = array($regs[1], $regs[2]) |
|
| 123 | - AND is_callable($methode)) |
|
| 124 | - $val = call_user_func($methode, $val); |
|
| 125 | - else { |
|
| 126 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 127 | - } |
|
| 128 | - return $val; |
|
| 117 | + // fonction |
|
| 118 | + if (function_exists($fonc)) |
|
| 119 | + $val = call_user_func($fonc, $val); |
|
| 120 | + // Class::Methode |
|
| 121 | + else if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 122 | + AND $methode = array($regs[1], $regs[2]) |
|
| 123 | + AND is_callable($methode)) |
|
| 124 | + $val = call_user_func($methode, $val); |
|
| 125 | + else { |
|
| 126 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 127 | + } |
|
| 128 | + return $val; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // chargement du pipeline sous la forme d'un fichier php prepare |
| 132 | 132 | // http://doc.spip.org/@pipeline |
| 133 | 133 | function pipeline($action, $val=null) { |
| 134 | - static $charger; |
|
| 135 | - |
|
| 136 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 137 | - if (!$charger) { |
|
| 138 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 139 | - include_spip('inc/plugin'); |
|
| 140 | - // generer les fichiers php precompiles |
|
| 141 | - // de chargement des plugins et des pipelines |
|
| 142 | - actualise_plugins_actifs(); |
|
| 143 | - if (!($ok = @is_readable($charger))) |
|
| 144 | - spip_log("fichier $charger pas cree"); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - if ($ok) { |
|
| 148 | - include_once $charger; |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // appliquer notre fonction si elle existe |
|
| 153 | - $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 154 | - if (function_exists($fonc)) { |
|
| 155 | - $val = $fonc($val); |
|
| 156 | - } |
|
| 157 | - // plantage ? |
|
| 158 | - else { |
|
| 159 | - spip_log("fonction $fonc absente : pipeline desactive",_LOG_ERREUR); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - // si le flux est une table avec 2 cle args&data |
|
| 163 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 164 | - // array_key_exists pour php 4.1.0 |
|
| 165 | - if (is_array($val) |
|
| 166 | - AND count($val)==2 |
|
| 167 | - AND (array_key_exists('data',$val))) |
|
| 168 | - $val = $val['data']; |
|
| 169 | - return $val; |
|
| 134 | + static $charger; |
|
| 135 | + |
|
| 136 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 137 | + if (!$charger) { |
|
| 138 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 139 | + include_spip('inc/plugin'); |
|
| 140 | + // generer les fichiers php precompiles |
|
| 141 | + // de chargement des plugins et des pipelines |
|
| 142 | + actualise_plugins_actifs(); |
|
| 143 | + if (!($ok = @is_readable($charger))) |
|
| 144 | + spip_log("fichier $charger pas cree"); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + if ($ok) { |
|
| 148 | + include_once $charger; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // appliquer notre fonction si elle existe |
|
| 153 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 154 | + if (function_exists($fonc)) { |
|
| 155 | + $val = $fonc($val); |
|
| 156 | + } |
|
| 157 | + // plantage ? |
|
| 158 | + else { |
|
| 159 | + spip_log("fonction $fonc absente : pipeline desactive",_LOG_ERREUR); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + // si le flux est une table avec 2 cle args&data |
|
| 163 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 164 | + // array_key_exists pour php 4.1.0 |
|
| 165 | + if (is_array($val) |
|
| 166 | + AND count($val)==2 |
|
| 167 | + AND (array_key_exists('data',$val))) |
|
| 168 | + $val = $val['data']; |
|
| 169 | + return $val; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -187,38 +187,38 @@ discard block |
||
| 187 | 187 | * @param string $logsuf ## inutile !! a supprimer ? |
| 188 | 188 | */ |
| 189 | 189 | function spip_log($message=NULL, $name=NULL) { |
| 190 | - static $pre = array(); |
|
| 191 | - static $log; |
|
| 192 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 193 | - if (!isset($regs[1]) OR !$logname = $regs[1]) |
|
| 194 | - $logname = null; |
|
| 195 | - if (!isset($regs[2]) OR !$niveau = $regs[2]) |
|
| 196 | - $niveau = _LOG_INFO; |
|
| 197 | - |
|
| 198 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 199 | - if (!$pre){ |
|
| 200 | - $pre = array( |
|
| 201 | - _LOG_HS=>'HS:', |
|
| 202 | - _LOG_ALERTE_ROUGE=>'ALERTE:', |
|
| 203 | - _LOG_CRITIQUE=>'CRITIQUE:', |
|
| 204 | - _LOG_ERREUR=>'ERREUR:', |
|
| 205 | - _LOG_AVERTISSEMENT=>'WARNING:', |
|
| 206 | - _LOG_INFO_IMPORTANTE=>'!INFO:', |
|
| 207 | - _LOG_INFO=>'info:', |
|
| 208 | - _LOG_DEBUG=>'debug:'); |
|
| 209 | - $log = charger_fonction('log', 'inc'); |
|
| 210 | - } |
|
| 211 | - if (!is_string($message)) $message = var_export($message, true); |
|
| 212 | - $log($pre[$niveau].' '.$message, $logname); |
|
| 213 | - } |
|
| 190 | + static $pre = array(); |
|
| 191 | + static $log; |
|
| 192 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 193 | + if (!isset($regs[1]) OR !$logname = $regs[1]) |
|
| 194 | + $logname = null; |
|
| 195 | + if (!isset($regs[2]) OR !$niveau = $regs[2]) |
|
| 196 | + $niveau = _LOG_INFO; |
|
| 197 | + |
|
| 198 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 199 | + if (!$pre){ |
|
| 200 | + $pre = array( |
|
| 201 | + _LOG_HS=>'HS:', |
|
| 202 | + _LOG_ALERTE_ROUGE=>'ALERTE:', |
|
| 203 | + _LOG_CRITIQUE=>'CRITIQUE:', |
|
| 204 | + _LOG_ERREUR=>'ERREUR:', |
|
| 205 | + _LOG_AVERTISSEMENT=>'WARNING:', |
|
| 206 | + _LOG_INFO_IMPORTANTE=>'!INFO:', |
|
| 207 | + _LOG_INFO=>'info:', |
|
| 208 | + _LOG_DEBUG=>'debug:'); |
|
| 209 | + $log = charger_fonction('log', 'inc'); |
|
| 210 | + } |
|
| 211 | + if (!is_string($message)) $message = var_export($message, true); |
|
| 212 | + $log($pre[$niveau].' '.$message, $logname); |
|
| 213 | + } |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // |
| 217 | 217 | // Enregistrement des journaux |
| 218 | 218 | // |
| 219 | 219 | function journal($phrase, $opt = array()) { |
| 220 | - $journal = charger_fonction('journal', 'inc'); |
|
| 221 | - $journal($phrase, $opt); |
|
| 220 | + $journal = charger_fonction('journal', 'inc'); |
|
| 221 | + $journal($phrase, $opt); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // Renvoie le _GET ou le _POST emis par l'utilisateur |
@@ -226,50 +226,50 @@ discard block |
||
| 226 | 226 | // http://doc.spip.org/@_request |
| 227 | 227 | function _request($var, $c=false) { |
| 228 | 228 | |
| 229 | - if (is_array($c)) |
|
| 230 | - return isset($c[$var]) ? $c[$var] : NULL; |
|
| 231 | - |
|
| 232 | - if (isset($_GET[$var])) $a = $_GET[$var]; |
|
| 233 | - elseif (isset($_POST[$var])) $a = $_POST[$var]; |
|
| 234 | - else return NULL; |
|
| 235 | - |
|
| 236 | - // Si on est en ajax et en POST tout a ete encode |
|
| 237 | - // via encodeURIComponent, il faut donc repasser |
|
| 238 | - // dans le charset local... |
|
| 239 | - if (defined('_AJAX') |
|
| 240 | - AND _AJAX |
|
| 241 | - AND isset($GLOBALS['meta']['charset']) |
|
| 242 | - AND $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 243 | - AND is_string($a) |
|
| 244 | - // check rapide mais pas fiable |
|
| 245 | - AND preg_match(',[\x80-\xFF],', $a) |
|
| 246 | - // check fiable |
|
| 247 | - AND include_spip('inc/charsets') |
|
| 248 | - AND is_utf8($a) |
|
| 249 | - ) { |
|
| 250 | - return importer_charset($a, 'utf-8'); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - return $a; |
|
| 229 | + if (is_array($c)) |
|
| 230 | + return isset($c[$var]) ? $c[$var] : NULL; |
|
| 231 | + |
|
| 232 | + if (isset($_GET[$var])) $a = $_GET[$var]; |
|
| 233 | + elseif (isset($_POST[$var])) $a = $_POST[$var]; |
|
| 234 | + else return NULL; |
|
| 235 | + |
|
| 236 | + // Si on est en ajax et en POST tout a ete encode |
|
| 237 | + // via encodeURIComponent, il faut donc repasser |
|
| 238 | + // dans le charset local... |
|
| 239 | + if (defined('_AJAX') |
|
| 240 | + AND _AJAX |
|
| 241 | + AND isset($GLOBALS['meta']['charset']) |
|
| 242 | + AND $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 243 | + AND is_string($a) |
|
| 244 | + // check rapide mais pas fiable |
|
| 245 | + AND preg_match(',[\x80-\xFF],', $a) |
|
| 246 | + // check fiable |
|
| 247 | + AND include_spip('inc/charsets') |
|
| 248 | + AND is_utf8($a) |
|
| 249 | + ) { |
|
| 250 | + return importer_charset($a, 'utf-8'); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + return $a; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | // Methode set de la fonction _request() |
| 257 | 257 | // Attention au cas ou l'on fait set_request('truc', NULL); |
| 258 | 258 | // http://doc.spip.org/@set_request |
| 259 | 259 | function set_request($var, $val = NULL, $c=false) { |
| 260 | - if (is_array($c)) { |
|
| 261 | - unset($c[$var]); |
|
| 262 | - if ($val !== NULL) |
|
| 263 | - $c[$var] = $val; |
|
| 264 | - return $c; |
|
| 265 | - } |
|
| 260 | + if (is_array($c)) { |
|
| 261 | + unset($c[$var]); |
|
| 262 | + if ($val !== NULL) |
|
| 263 | + $c[$var] = $val; |
|
| 264 | + return $c; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - unset($_GET[$var]); |
|
| 268 | - unset($_POST[$var]); |
|
| 269 | - if ($val !== NULL) |
|
| 270 | - $_GET[$var] = $val; |
|
| 267 | + unset($_GET[$var]); |
|
| 268 | + unset($_POST[$var]); |
|
| 269 | + if ($val !== NULL) |
|
| 270 | + $_GET[$var] = $val; |
|
| 271 | 271 | |
| 272 | - return false; # n'affecte pas $c |
|
| 272 | + return false; # n'affecte pas $c |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | |
@@ -278,23 +278,22 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * On est sur le web, on exclut certains protocoles, |
| 280 | 280 | * notamment 'file://', 'php://' et d'autres… |
| 281 | - |
|
| 282 | 281 | * @param string $url |
| 283 | 282 | * @return bool |
| 284 | 283 | */ |
| 285 | 284 | function tester_url_absolue($url) { |
| 286 | - $url = trim($url); |
|
| 287 | - if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 288 | - if ( |
|
| 289 | - isset($m[1]) |
|
| 290 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 291 | - and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 292 | - ) { |
|
| 293 | - return false; |
|
| 294 | - } |
|
| 295 | - return true; |
|
| 296 | - } |
|
| 297 | - return false; |
|
| 285 | + $url = trim($url); |
|
| 286 | + if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 287 | + if ( |
|
| 288 | + isset($m[1]) |
|
| 289 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 290 | + and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 291 | + ) { |
|
| 292 | + return false; |
|
| 293 | + } |
|
| 294 | + return true; |
|
| 295 | + } |
|
| 296 | + return false; |
|
| 298 | 297 | } |
| 299 | 298 | |
| 300 | 299 | /** |
@@ -313,71 +312,71 @@ discard block |
||
| 313 | 312 | * @return string |
| 314 | 313 | */ |
| 315 | 314 | function parametre_url($url, $c, $v=NULL, $sep='&') { |
| 316 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 317 | - if (strpos($c,"|")!==false AND is_null($v)) |
|
| 318 | - return null; |
|
| 319 | - |
|
| 320 | - // lever l'#ancre |
|
| 321 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 322 | - $url = $r[1]; |
|
| 323 | - $ancre = $r[2]; |
|
| 324 | - } else |
|
| 325 | - $ancre = ''; |
|
| 326 | - |
|
| 327 | - // eclater |
|
| 328 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 329 | - |
|
| 330 | - // recuperer la base |
|
| 331 | - $a = array_shift($url); |
|
| 332 | - if (!$a) $a= './'; |
|
| 333 | - |
|
| 334 | - $regexp = ',^(' . str_replace('[]','\[\]',$c) . '[[]?[]]?)(=.*)?$,'; |
|
| 335 | - $ajouts = array_flip(explode('|',$c)); |
|
| 336 | - $u = is_array($v) ? $v : rawurlencode($v); |
|
| 337 | - $testv = (is_array($v)?count($v):strlen($v)); |
|
| 338 | - // lire les variables et agir |
|
| 339 | - foreach ($url as $n => $val) { |
|
| 340 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 341 | - if ($v === NULL) { |
|
| 342 | - return $r[2]?substr($r[2],1):''; |
|
| 343 | - } |
|
| 344 | - // suppression |
|
| 345 | - elseif (!$testv) { |
|
| 346 | - unset($url[$n]); |
|
| 347 | - } |
|
| 348 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 349 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 350 | - elseif (substr($r[1],-2) != '[]') { |
|
| 351 | - $url[$n] = $r[1].'='.$u; |
|
| 352 | - unset($ajouts[$r[1]]); |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - // traiter les parametres pas encore trouves |
|
| 358 | - if ($v === NULL |
|
| 359 | - AND $args = func_get_args() |
|
| 360 | - AND count($args)==2) |
|
| 361 | - return $v; |
|
| 362 | - elseif ($testv) { |
|
| 363 | - foreach($ajouts as $k => $n) { |
|
| 364 | - if (!is_array($v)) |
|
| 365 | - $url[] = $k .'=' . $u; |
|
| 366 | - else { |
|
| 367 | - $id = (substr($k,-2) == '[]') ? $k : ($k ."[]"); |
|
| 368 | - foreach ($v as $w) $url[]= $id .'=' . $w; |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - // eliminer les vides |
|
| 374 | - $url = array_filter($url); |
|
| 375 | - |
|
| 376 | - // recomposer l'adresse |
|
| 377 | - if ($url) |
|
| 378 | - $a .= '?' . join($sep, $url); |
|
| 379 | - |
|
| 380 | - return $a . $ancre; |
|
| 315 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 316 | + if (strpos($c,"|")!==false AND is_null($v)) |
|
| 317 | + return null; |
|
| 318 | + |
|
| 319 | + // lever l'#ancre |
|
| 320 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 321 | + $url = $r[1]; |
|
| 322 | + $ancre = $r[2]; |
|
| 323 | + } else |
|
| 324 | + $ancre = ''; |
|
| 325 | + |
|
| 326 | + // eclater |
|
| 327 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 328 | + |
|
| 329 | + // recuperer la base |
|
| 330 | + $a = array_shift($url); |
|
| 331 | + if (!$a) $a= './'; |
|
| 332 | + |
|
| 333 | + $regexp = ',^(' . str_replace('[]','\[\]',$c) . '[[]?[]]?)(=.*)?$,'; |
|
| 334 | + $ajouts = array_flip(explode('|',$c)); |
|
| 335 | + $u = is_array($v) ? $v : rawurlencode($v); |
|
| 336 | + $testv = (is_array($v)?count($v):strlen($v)); |
|
| 337 | + // lire les variables et agir |
|
| 338 | + foreach ($url as $n => $val) { |
|
| 339 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 340 | + if ($v === NULL) { |
|
| 341 | + return $r[2]?substr($r[2],1):''; |
|
| 342 | + } |
|
| 343 | + // suppression |
|
| 344 | + elseif (!$testv) { |
|
| 345 | + unset($url[$n]); |
|
| 346 | + } |
|
| 347 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 348 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 349 | + elseif (substr($r[1],-2) != '[]') { |
|
| 350 | + $url[$n] = $r[1].'='.$u; |
|
| 351 | + unset($ajouts[$r[1]]); |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + // traiter les parametres pas encore trouves |
|
| 357 | + if ($v === NULL |
|
| 358 | + AND $args = func_get_args() |
|
| 359 | + AND count($args)==2) |
|
| 360 | + return $v; |
|
| 361 | + elseif ($testv) { |
|
| 362 | + foreach($ajouts as $k => $n) { |
|
| 363 | + if (!is_array($v)) |
|
| 364 | + $url[] = $k .'=' . $u; |
|
| 365 | + else { |
|
| 366 | + $id = (substr($k,-2) == '[]') ? $k : ($k ."[]"); |
|
| 367 | + foreach ($v as $w) $url[]= $id .'=' . $w; |
|
| 368 | + } |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + // eliminer les vides |
|
| 373 | + $url = array_filter($url); |
|
| 374 | + |
|
| 375 | + // recomposer l'adresse |
|
| 376 | + if ($url) |
|
| 377 | + $a .= '?' . join($sep, $url); |
|
| 378 | + |
|
| 379 | + return $a . $ancre; |
|
| 381 | 380 | } |
| 382 | 381 | |
| 383 | 382 | // Prend une URL et lui ajoute/retire une ancre apres l'avoir nettoyee |
@@ -385,17 +384,17 @@ discard block |
||
| 385 | 384 | // et on remplace ceux a l'interieur ou au bout par - |
| 386 | 385 | // http://doc.spip.org/@ancre_url |
| 387 | 386 | function ancre_url($url, $ancre) { |
| 388 | - // lever l'#ancre |
|
| 389 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 390 | - $url = $r[1]; |
|
| 391 | - } |
|
| 392 | - if (preg_match('/[^-_a-zA-Z0-9]+/S',$ancre)){ |
|
| 393 | - if (!function_exists('translitteration')) |
|
| 394 | - include_spip('inc/charsets'); |
|
| 395 | - $ancre = preg_replace(array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), array('', '-'), |
|
| 396 | - translitteration($ancre)); |
|
| 397 | - } |
|
| 398 | - return $url . (strlen($ancre) ? '#'. $ancre : ''); |
|
| 387 | + // lever l'#ancre |
|
| 388 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 389 | + $url = $r[1]; |
|
| 390 | + } |
|
| 391 | + if (preg_match('/[^-_a-zA-Z0-9]+/S',$ancre)){ |
|
| 392 | + if (!function_exists('translitteration')) |
|
| 393 | + include_spip('inc/charsets'); |
|
| 394 | + $ancre = preg_replace(array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), array('', '-'), |
|
| 395 | + translitteration($ancre)); |
|
| 396 | + } |
|
| 397 | + return $url . (strlen($ancre) ? '#'. $ancre : ''); |
|
| 399 | 398 | } |
| 400 | 399 | |
| 401 | 400 | /** |
@@ -407,21 +406,21 @@ discard block |
||
| 407 | 406 | */ |
| 408 | 407 | function nettoyer_uri($reset = null) |
| 409 | 408 | { |
| 410 | - static $done = false; |
|
| 411 | - static $propre = ''; |
|
| 412 | - if (!is_null($reset)) return $propre=$reset; |
|
| 413 | - if ($done) return $propre; |
|
| 414 | - $done = true; |
|
| 409 | + static $done = false; |
|
| 410 | + static $propre = ''; |
|
| 411 | + if (!is_null($reset)) return $propre=$reset; |
|
| 412 | + if ($done) return $propre; |
|
| 413 | + $done = true; |
|
| 415 | 414 | |
| 416 | - $uri1 = $GLOBALS['REQUEST_URI']; |
|
| 417 | - do { |
|
| 418 | - $uri = $uri1; |
|
| 419 | - $uri1 = preg_replace |
|
| 420 | - (',([?&])(PHPSESSID|(var_[^=&]*))=[^&]*(&|$),i', |
|
| 421 | - '\1', $uri); |
|
| 422 | - } while ($uri<>$uri1); |
|
| 415 | + $uri1 = $GLOBALS['REQUEST_URI']; |
|
| 416 | + do { |
|
| 417 | + $uri = $uri1; |
|
| 418 | + $uri1 = preg_replace |
|
| 419 | + (',([?&])(PHPSESSID|(var_[^=&]*))=[^&]*(&|$),i', |
|
| 420 | + '\1', $uri); |
|
| 421 | + } while ($uri<>$uri1); |
|
| 423 | 422 | |
| 424 | - return $propre = (preg_replace(',[?&]$,', '', $uri1)); |
|
| 423 | + return $propre = (preg_replace(',[?&]$,', '', $uri1)); |
|
| 425 | 424 | } |
| 426 | 425 | |
| 427 | 426 | |
@@ -435,49 +434,49 @@ discard block |
||
| 435 | 434 | * URL vers soi-même |
| 436 | 435 | **/ |
| 437 | 436 | function self($amp = '&', $root = false) { |
| 438 | - $url = nettoyer_uri(); |
|
| 439 | - if (!$root |
|
| 440 | - AND ( |
|
| 441 | - // si pas de profondeur on peut tronquer |
|
| 442 | - $GLOBALS['profondeur_url']<(_DIR_RESTREINT?1:2) |
|
| 443 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 444 | - OR (defined('_SET_HTML_BASE') AND !_SET_HTML_BASE)) |
|
| 445 | - ) |
|
| 446 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 447 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 448 | - foreach ($_POST as $v => $c) |
|
| 449 | - if (substr($v,0,3) == 'id_') |
|
| 450 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 451 | - |
|
| 452 | - // supprimer les variables sans interet |
|
| 453 | - if (test_espace_prive()) { |
|
| 454 | - $url = preg_replace (',([?&])(' |
|
| 455 | - .'lang|show_docs|' |
|
| 456 | - .'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 457 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 458 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - // eviter les hacks |
|
| 462 | - include_spip('inc/filtres_mini'); |
|
| 463 | - $url = spip_htmlspecialchars($url); |
|
| 437 | + $url = nettoyer_uri(); |
|
| 438 | + if (!$root |
|
| 439 | + AND ( |
|
| 440 | + // si pas de profondeur on peut tronquer |
|
| 441 | + $GLOBALS['profondeur_url']<(_DIR_RESTREINT?1:2) |
|
| 442 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 443 | + OR (defined('_SET_HTML_BASE') AND !_SET_HTML_BASE)) |
|
| 444 | + ) |
|
| 445 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 446 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 447 | + foreach ($_POST as $v => $c) |
|
| 448 | + if (substr($v,0,3) == 'id_') |
|
| 449 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 450 | + |
|
| 451 | + // supprimer les variables sans interet |
|
| 452 | + if (test_espace_prive()) { |
|
| 453 | + $url = preg_replace (',([?&])(' |
|
| 454 | + .'lang|show_docs|' |
|
| 455 | + .'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 456 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 457 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + // eviter les hacks |
|
| 461 | + include_spip('inc/filtres_mini'); |
|
| 462 | + $url = spip_htmlspecialchars($url); |
|
| 464 | 463 | |
| 465 | - $url = str_replace(array("'", '"', '<', '[', ']'), array('%27', '%22', '%3C', '%5B', '%5D'), $url); |
|
| 464 | + $url = str_replace(array("'", '"', '<', '[', ']'), array('%27', '%22', '%3C', '%5B', '%5D'), $url); |
|
| 466 | 465 | |
| 467 | - // & ? |
|
| 468 | - if ($amp != '&') |
|
| 469 | - $url = str_replace('&', $amp, $url); |
|
| 466 | + // & ? |
|
| 467 | + if ($amp != '&') |
|
| 468 | + $url = str_replace('&', $amp, $url); |
|
| 470 | 469 | |
| 471 | - // Si ca demarre par ? ou vide, donner './' |
|
| 472 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 470 | + // Si ca demarre par ? ou vide, donner './' |
|
| 471 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 473 | 472 | |
| 474 | - return $url; |
|
| 473 | + return $url; |
|
| 475 | 474 | } |
| 476 | 475 | |
| 477 | 476 | // Indique si on est dans l'espace prive |
| 478 | 477 | // http://doc.spip.org/@test_espace_prive |
| 479 | 478 | function test_espace_prive() { |
| 480 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 479 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 481 | 480 | } |
| 482 | 481 | |
| 483 | 482 | /** |
@@ -488,7 +487,7 @@ discard block |
||
| 488 | 487 | * @return bool |
| 489 | 488 | */ |
| 490 | 489 | function test_plugin_actif($plugin){ |
| 491 | - return ($plugin AND defined('_DIR_PLUGIN_'.strtoupper($plugin)))? true:false; |
|
| 490 | + return ($plugin AND defined('_DIR_PLUGIN_'.strtoupper($plugin)))? true:false; |
|
| 492 | 491 | } |
| 493 | 492 | |
| 494 | 493 | /** |
@@ -503,49 +502,49 @@ discard block |
||
| 503 | 502 | * @return mixed|string |
| 504 | 503 | */ |
| 505 | 504 | function _T($texte, $args=array(), $options=array()) { |
| 506 | - static $traduire=false ; |
|
| 507 | - $o = array('class'=>'', 'force'=>true); |
|
| 508 | - if ($options){ |
|
| 509 | - // support de l'ancien argument $class |
|
| 510 | - if (is_string($options)) |
|
| 511 | - $options = array('class'=>$options); |
|
| 512 | - $o = array_merge($o,$options); |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - if (!$traduire) { |
|
| 516 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 517 | - include_spip('inc/lang'); |
|
| 518 | - } |
|
| 505 | + static $traduire=false ; |
|
| 506 | + $o = array('class'=>'', 'force'=>true); |
|
| 507 | + if ($options){ |
|
| 508 | + // support de l'ancien argument $class |
|
| 509 | + if (is_string($options)) |
|
| 510 | + $options = array('class'=>$options); |
|
| 511 | + $o = array_merge($o,$options); |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + if (!$traduire) { |
|
| 515 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 516 | + include_spip('inc/lang'); |
|
| 517 | + } |
|
| 519 | 518 | |
| 520 | - // On peut passer explicitement la langue dans le tableau |
|
| 521 | - // On utilise le même nom de variable que la globale |
|
| 522 | - if (isset($args['spip_lang'])){ |
|
| 523 | - $lang = $args['spip_lang']; |
|
| 524 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 525 | - unset($args['spip_lang']); |
|
| 526 | - } |
|
| 527 | - // Sinon on prend la langue du contexte |
|
| 528 | - else { |
|
| 529 | - $lang = $GLOBALS['spip_lang']; |
|
| 530 | - } |
|
| 531 | - $text = $traduire($texte, $lang); |
|
| 519 | + // On peut passer explicitement la langue dans le tableau |
|
| 520 | + // On utilise le même nom de variable que la globale |
|
| 521 | + if (isset($args['spip_lang'])){ |
|
| 522 | + $lang = $args['spip_lang']; |
|
| 523 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 524 | + unset($args['spip_lang']); |
|
| 525 | + } |
|
| 526 | + // Sinon on prend la langue du contexte |
|
| 527 | + else { |
|
| 528 | + $lang = $GLOBALS['spip_lang']; |
|
| 529 | + } |
|
| 530 | + $text = $traduire($texte, $lang); |
|
| 532 | 531 | |
| 533 | - if (!strlen($text)){ |
|
| 534 | - if (!$o['force']) |
|
| 535 | - return ''; |
|
| 532 | + if (!strlen($text)){ |
|
| 533 | + if (!$o['force']) |
|
| 534 | + return ''; |
|
| 536 | 535 | |
| 537 | - $text = $texte; |
|
| 536 | + $text = $texte; |
|
| 538 | 537 | |
| 539 | - // pour les chaines non traduites, assurer un service minimum |
|
| 540 | - if (!$GLOBALS['test_i18n'] AND (_request('var_mode') != 'traduction')) |
|
| 541 | - $text = str_replace('_', ' ', |
|
| 542 | - (($n = strpos($text,':')) === false ? $texte : |
|
| 543 | - substr($texte, $n+1))); |
|
| 544 | - $o['class'] = null; |
|
| 538 | + // pour les chaines non traduites, assurer un service minimum |
|
| 539 | + if (!$GLOBALS['test_i18n'] AND (_request('var_mode') != 'traduction')) |
|
| 540 | + $text = str_replace('_', ' ', |
|
| 541 | + (($n = strpos($text,':')) === false ? $texte : |
|
| 542 | + substr($texte, $n+1))); |
|
| 543 | + $o['class'] = null; |
|
| 545 | 544 | |
| 546 | - } |
|
| 545 | + } |
|
| 547 | 546 | |
| 548 | - return _L($text, $args, $o['class']); |
|
| 547 | + return _L($text, $args, $o['class']); |
|
| 549 | 548 | |
| 550 | 549 | } |
| 551 | 550 | |
@@ -553,34 +552,34 @@ discard block |
||
| 553 | 552 | // Aussi appelee quand une chaine n'est pas encore dans les fichiers de langue |
| 554 | 553 | // http://doc.spip.org/@_L |
| 555 | 554 | function _L($text, $args=array(), $class=null) { |
| 556 | - $f = $text; |
|
| 557 | - if (is_array($args)) { |
|
| 558 | - foreach ($args as $name => $value) { |
|
| 559 | - if ($class) |
|
| 560 | - $value = "<span class='$class'>$value</span>"; |
|
| 561 | - $t = str_replace ("@$name@", $value, $text); |
|
| 562 | - if ($text !== $t) {unset($args[$name]); $text = $t;} |
|
| 563 | - } |
|
| 564 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 565 | - // (chaines de langues pas a jour) |
|
| 566 | - if ($args) spip_log("$f: variables inutilisees " . join(', ', array_keys($args)),_LOG_DEBUG); |
|
| 567 | - } |
|
| 568 | - |
|
| 569 | - if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class===null) |
|
| 570 | - return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 571 | - else |
|
| 572 | - return $text; |
|
| 555 | + $f = $text; |
|
| 556 | + if (is_array($args)) { |
|
| 557 | + foreach ($args as $name => $value) { |
|
| 558 | + if ($class) |
|
| 559 | + $value = "<span class='$class'>$value</span>"; |
|
| 560 | + $t = str_replace ("@$name@", $value, $text); |
|
| 561 | + if ($text !== $t) {unset($args[$name]); $text = $t;} |
|
| 562 | + } |
|
| 563 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 564 | + // (chaines de langues pas a jour) |
|
| 565 | + if ($args) spip_log("$f: variables inutilisees " . join(', ', array_keys($args)),_LOG_DEBUG); |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class===null) |
|
| 569 | + return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 570 | + else |
|
| 571 | + return $text; |
|
| 573 | 572 | } |
| 574 | 573 | |
| 575 | 574 | // Afficher "ecrire/data/" au lieu de "data/" dans les messages |
| 576 | 575 | // ou tmp/ au lieu de ../tmp/ |
| 577 | 576 | // http://doc.spip.org/@joli_repertoire |
| 578 | 577 | function joli_repertoire($rep) { |
| 579 | - $a = substr($rep,0,1); |
|
| 580 | - if ($a<>'.' AND $a<>'/') |
|
| 581 | - $rep = (_DIR_RESTREINT?'':_DIR_RESTREINT_ABS).$rep; |
|
| 582 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 583 | - return $rep; |
|
| 578 | + $a = substr($rep,0,1); |
|
| 579 | + if ($a<>'.' AND $a<>'/') |
|
| 580 | + $rep = (_DIR_RESTREINT?'':_DIR_RESTREINT_ABS).$rep; |
|
| 581 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 582 | + return $rep; |
|
| 584 | 583 | } |
| 585 | 584 | |
| 586 | 585 | |
@@ -589,27 +588,27 @@ discard block |
||
| 589 | 588 | // |
| 590 | 589 | // http://doc.spip.org/@spip_timer |
| 591 | 590 | function spip_timer($t='rien', $raw = false) { |
| 592 | - static $time; |
|
| 593 | - $a=time(); $b=microtime(); |
|
| 594 | - // microtime peut contenir les microsecondes et le temps |
|
| 595 | - $b=explode(' ',$b); |
|
| 596 | - if (count($b)==2) $a = end($b); // plus precis ! |
|
| 597 | - $b = reset($b); |
|
| 598 | - if (!isset($time[$t])) { |
|
| 599 | - $time[$t] = $a + $b; |
|
| 600 | - } else { |
|
| 601 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 602 | - unset($time[$t]); |
|
| 591 | + static $time; |
|
| 592 | + $a=time(); $b=microtime(); |
|
| 593 | + // microtime peut contenir les microsecondes et le temps |
|
| 594 | + $b=explode(' ',$b); |
|
| 595 | + if (count($b)==2) $a = end($b); // plus precis ! |
|
| 596 | + $b = reset($b); |
|
| 597 | + if (!isset($time[$t])) { |
|
| 598 | + $time[$t] = $a + $b; |
|
| 599 | + } else { |
|
| 600 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 601 | + unset($time[$t]); |
|
| 603 | 602 | # echo "'$p'";exit; |
| 604 | - if ($raw) return $p; |
|
| 605 | - if ($p < 1000) |
|
| 606 | - $s = ''; |
|
| 607 | - else { |
|
| 608 | - $s = sprintf("%d ", $x = floor($p/1000)); |
|
| 609 | - $p -= ($x*1000); |
|
| 610 | - } |
|
| 611 | - return $s . sprintf($s?"%07.3f ms":"%.3f ms", $p); |
|
| 612 | - } |
|
| 603 | + if ($raw) return $p; |
|
| 604 | + if ($p < 1000) |
|
| 605 | + $s = ''; |
|
| 606 | + else { |
|
| 607 | + $s = sprintf("%d ", $x = floor($p/1000)); |
|
| 608 | + $p -= ($x*1000); |
|
| 609 | + } |
|
| 610 | + return $s . sprintf($s?"%07.3f ms":"%.3f ms", $p); |
|
| 611 | + } |
|
| 613 | 612 | } |
| 614 | 613 | |
| 615 | 614 | |
@@ -617,16 +616,16 @@ discard block |
||
| 617 | 616 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 618 | 617 | // http://doc.spip.org/@spip_touch |
| 619 | 618 | function spip_touch($fichier, $duree=0, $touch=true) { |
| 620 | - if ($duree) { |
|
| 621 | - clearstatcache(); |
|
| 622 | - if ((@$f=filemtime($fichier)) AND ($f >= time() - $duree)) |
|
| 623 | - return false; |
|
| 624 | - } |
|
| 625 | - if ($touch!==false) { |
|
| 626 | - if (!@touch($fichier)) { spip_unlink($fichier); @touch($fichier); }; |
|
| 627 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 628 | - } |
|
| 629 | - return true; |
|
| 619 | + if ($duree) { |
|
| 620 | + clearstatcache(); |
|
| 621 | + if ((@$f=filemtime($fichier)) AND ($f >= time() - $duree)) |
|
| 622 | + return false; |
|
| 623 | + } |
|
| 624 | + if ($touch!==false) { |
|
| 625 | + if (!@touch($fichier)) { spip_unlink($fichier); @touch($fichier); }; |
|
| 626 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 627 | + } |
|
| 628 | + return true; |
|
| 630 | 629 | } |
| 631 | 630 | |
| 632 | 631 | // Ce declencheur de tache de fond, de l'espace prive (cf inc_presentation) |
@@ -638,11 +637,11 @@ discard block |
||
| 638 | 637 | |
| 639 | 638 | // http://doc.spip.org/@action_cron |
| 640 | 639 | function action_cron() { |
| 641 | - include_spip('inc/headers'); |
|
| 642 | - http_status(204); // No Content |
|
| 643 | - header("Connection: close"); |
|
| 644 | - define('_DIRECT_CRON_FORCE',true); |
|
| 645 | - cron(); |
|
| 640 | + include_spip('inc/headers'); |
|
| 641 | + http_status(204); // No Content |
|
| 642 | + header("Connection: close"); |
|
| 643 | + define('_DIRECT_CRON_FORCE',true); |
|
| 644 | + cron(); |
|
| 646 | 645 | } |
| 647 | 646 | |
| 648 | 647 | /** |
@@ -662,19 +661,19 @@ discard block |
||
| 662 | 661 | * @return bool |
| 663 | 662 | */ |
| 664 | 663 | function cron ($taches=array(), $taches_old= array()) { |
| 665 | - // si pas en mode cron force, laisser tomber. |
|
| 666 | - if (!defined('_DIRECT_CRON_FORCE')) return false; |
|
| 667 | - if (!is_array($taches)) $taches = $taches_old; // compat anciens appels |
|
| 668 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 669 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 670 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 671 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 672 | - if ($taches AND count($taches) AND !spip_connect()) return false; |
|
| 673 | - spip_log("cron !",'jq'._LOG_DEBUG); |
|
| 674 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 675 | - return $genie($taches); |
|
| 676 | - } |
|
| 677 | - return false; |
|
| 664 | + // si pas en mode cron force, laisser tomber. |
|
| 665 | + if (!defined('_DIRECT_CRON_FORCE')) return false; |
|
| 666 | + if (!is_array($taches)) $taches = $taches_old; // compat anciens appels |
|
| 667 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 668 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 669 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 670 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 671 | + if ($taches AND count($taches) AND !spip_connect()) return false; |
|
| 672 | + spip_log("cron !",'jq'._LOG_DEBUG); |
|
| 673 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 674 | + return $genie($taches); |
|
| 675 | + } |
|
| 676 | + return false; |
|
| 678 | 677 | } |
| 679 | 678 | |
| 680 | 679 | /** |
@@ -700,8 +699,8 @@ discard block |
||
| 700 | 699 | * id of job |
| 701 | 700 | */ |
| 702 | 701 | function job_queue_add($function, $description, $arguments = array(), $file = '', $no_duplicate = FALSE, $time=0, $priority=0) { |
| 703 | - include_spip('inc/queue'); |
|
| 704 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 702 | + include_spip('inc/queue'); |
|
| 703 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 705 | 704 | } |
| 706 | 705 | |
| 707 | 706 | /** |
@@ -711,8 +710,8 @@ discard block |
||
| 711 | 710 | * @return bool |
| 712 | 711 | */ |
| 713 | 712 | function job_queue_remove($id_job){ |
| 714 | - include_spip('inc/queue'); |
|
| 715 | - return queue_remove_job($id_job); |
|
| 713 | + include_spip('inc/queue'); |
|
| 714 | + return queue_remove_job($id_job); |
|
| 716 | 715 | } |
| 717 | 716 | |
| 718 | 717 | /** |
@@ -724,8 +723,8 @@ discard block |
||
| 724 | 723 | * or an array of simple array to link multiples objet in one time |
| 725 | 724 | */ |
| 726 | 725 | function job_queue_link($id_job,$objets){ |
| 727 | - include_spip('inc/queue'); |
|
| 728 | - return queue_link_job($id_job,$objets); |
|
| 726 | + include_spip('inc/queue'); |
|
| 727 | + return queue_link_job($id_job,$objets); |
|
| 729 | 728 | } |
| 730 | 729 | |
| 731 | 730 | |
@@ -742,62 +741,62 @@ discard block |
||
| 742 | 741 | * @return int |
| 743 | 742 | */ |
| 744 | 743 | function queue_sleep_time_to_next_job($force=null) { |
| 745 | - static $queue_next_job_time = -1; |
|
| 746 | - if ($force===true) |
|
| 747 | - $queue_next_job_time = -1; |
|
| 748 | - elseif ($force) |
|
| 749 | - $queue_next_job_time = $force; |
|
| 750 | - |
|
| 751 | - if ($queue_next_job_time==-1) { |
|
| 752 | - define('_JQ_NEXT_JOB_TIME_FILENAME',_DIR_TMP . "job_queue_next.txt"); |
|
| 753 | - // utiliser un cache memoire si dispo |
|
| 754 | - if (include_spip('inc/memoization') AND defined('_MEMOIZE_MEMORY') AND _MEMOIZE_MEMORY) { |
|
| 755 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 756 | - } |
|
| 757 | - else { |
|
| 758 | - $queue_next_job_time = null; |
|
| 759 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) |
|
| 760 | - $queue_next_job_time = intval($contenu); |
|
| 761 | - } |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - if (is_null($queue_next_job_time)) |
|
| 765 | - return null; |
|
| 766 | - if (!$_SERVER['REQUEST_TIME']) |
|
| 767 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 768 | - return $queue_next_job_time-$_SERVER['REQUEST_TIME']; |
|
| 744 | + static $queue_next_job_time = -1; |
|
| 745 | + if ($force===true) |
|
| 746 | + $queue_next_job_time = -1; |
|
| 747 | + elseif ($force) |
|
| 748 | + $queue_next_job_time = $force; |
|
| 749 | + |
|
| 750 | + if ($queue_next_job_time==-1) { |
|
| 751 | + define('_JQ_NEXT_JOB_TIME_FILENAME',_DIR_TMP . "job_queue_next.txt"); |
|
| 752 | + // utiliser un cache memoire si dispo |
|
| 753 | + if (include_spip('inc/memoization') AND defined('_MEMOIZE_MEMORY') AND _MEMOIZE_MEMORY) { |
|
| 754 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 755 | + } |
|
| 756 | + else { |
|
| 757 | + $queue_next_job_time = null; |
|
| 758 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) |
|
| 759 | + $queue_next_job_time = intval($contenu); |
|
| 760 | + } |
|
| 761 | + } |
|
| 762 | + |
|
| 763 | + if (is_null($queue_next_job_time)) |
|
| 764 | + return null; |
|
| 765 | + if (!$_SERVER['REQUEST_TIME']) |
|
| 766 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 767 | + return $queue_next_job_time-$_SERVER['REQUEST_TIME']; |
|
| 769 | 768 | } |
| 770 | 769 | |
| 771 | 770 | |
| 772 | 771 | // transformation XML des "&" en "&" |
| 773 | 772 | // http://doc.spip.org/@quote_amp |
| 774 | 773 | function quote_amp($u) { |
| 775 | - return preg_replace( |
|
| 776 | - "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,5};)/i", |
|
| 777 | - "&",$u); |
|
| 774 | + return preg_replace( |
|
| 775 | + "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,5};)/i", |
|
| 776 | + "&",$u); |
|
| 778 | 777 | } |
| 779 | 778 | |
| 780 | 779 | // Production d'une balise Script valide |
| 781 | 780 | // http://doc.spip.org/@http_script |
| 782 | 781 | function http_script($script, $src='', $noscript='') { |
| 783 | - static $done = array(); |
|
| 784 | - |
|
| 785 | - if ($src && !isset($done[$src])){ |
|
| 786 | - $done[$src] = true; |
|
| 787 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 788 | - $src = " src='$src'"; |
|
| 789 | - } |
|
| 790 | - else $src = ''; |
|
| 791 | - if ($script) |
|
| 792 | - $script = ("/*<![CDATA[*/\n" . |
|
| 793 | - preg_replace(',</([^>]*)>,','<\/\1>', $script) . |
|
| 794 | - "/*]]>*/"); |
|
| 795 | - if ($noscript) |
|
| 796 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 797 | - |
|
| 798 | - return ($src OR $script OR $noscript) |
|
| 799 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 800 | - : ''; |
|
| 782 | + static $done = array(); |
|
| 783 | + |
|
| 784 | + if ($src && !isset($done[$src])){ |
|
| 785 | + $done[$src] = true; |
|
| 786 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 787 | + $src = " src='$src'"; |
|
| 788 | + } |
|
| 789 | + else $src = ''; |
|
| 790 | + if ($script) |
|
| 791 | + $script = ("/*<![CDATA[*/\n" . |
|
| 792 | + preg_replace(',</([^>]*)>,','<\/\1>', $script) . |
|
| 793 | + "/*]]>*/"); |
|
| 794 | + if ($noscript) |
|
| 795 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 796 | + |
|
| 797 | + return ($src OR $script OR $noscript) |
|
| 798 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 799 | + : ''; |
|
| 801 | 800 | } |
| 802 | 801 | |
| 803 | 802 | // Transforme n'importe quel champ en une chaine utilisable |
@@ -805,7 +804,7 @@ discard block |
||
| 805 | 804 | // < ? php $x = '[(#TEXTE|texte_script)]'; ? > |
| 806 | 805 | // http://doc.spip.org/@texte_script |
| 807 | 806 | function texte_script($texte) { |
| 808 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 807 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 809 | 808 | } |
| 810 | 809 | |
| 811 | 810 | // Chaque appel a cette fonction ajoute un repertoire en tete du chemin courant (path) |
@@ -816,107 +815,107 @@ discard block |
||
| 816 | 815 | // Exception: si un $dossier_squelette est defini, il reste en tete, pour raison historique |
| 817 | 816 | // http://doc.spip.org/@_chemin |
| 818 | 817 | function _chemin($dir_path=NULL){ |
| 819 | - static $path_base = NULL; |
|
| 820 | - static $path_full = NULL; |
|
| 821 | - if ($path_base==NULL){ |
|
| 822 | - // Chemin standard depuis l'espace public |
|
| 823 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 824 | - _DIR_RACINE.':'. |
|
| 825 | - _DIR_RACINE.'squelettes-dist/:'. |
|
| 826 | - _DIR_RACINE.'prive/:'. |
|
| 827 | - _DIR_RESTREINT; |
|
| 828 | - // Ajouter squelettes/ |
|
| 829 | - if (@is_dir(_DIR_RACINE.'squelettes')) |
|
| 830 | - $path = _DIR_RACINE.'squelettes/:' . $path; |
|
| 831 | - foreach (explode(':', $path) as $dir) { |
|
| 832 | - if (strlen($dir) AND substr($dir,-1) != '/') |
|
| 833 | - $dir .= "/"; |
|
| 834 | - $path_base[] = $dir; |
|
| 835 | - } |
|
| 836 | - $path_full = $path_base; |
|
| 837 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 838 | - if (strlen($GLOBALS['dossier_squelettes'])) |
|
| 839 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 840 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 841 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 842 | - } |
|
| 843 | - if ($dir_path===NULL) return $path_full; |
|
| 844 | - |
|
| 845 | - if (strlen($dir_path)){ |
|
| 846 | - $tete = ""; |
|
| 847 | - if (reset($path_base)==_DIR_RACINE.'squelettes/') |
|
| 848 | - $tete = array_shift($path_base); |
|
| 849 | - $dirs = array_reverse(explode(':',$dir_path)); |
|
| 850 | - foreach($dirs as $dir_path){ |
|
| 851 | - #if ($dir_path{0}!='/') |
|
| 852 | - # $dir_path = $dir_path; |
|
| 853 | - if (substr($dir_path,-1) != '/') |
|
| 854 | - $dir_path .= "/"; |
|
| 855 | - if (!in_array($dir_path,$path_base)) |
|
| 856 | - array_unshift($path_base,$dir_path); |
|
| 857 | - } |
|
| 858 | - if (strlen($tete)) |
|
| 859 | - array_unshift($path_base,$tete); |
|
| 860 | - } |
|
| 861 | - $path_full = $path_base; |
|
| 862 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 863 | - if (strlen($GLOBALS['dossier_squelettes'])) |
|
| 864 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 865 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 866 | - |
|
| 867 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 868 | - return $path_full; |
|
| 818 | + static $path_base = NULL; |
|
| 819 | + static $path_full = NULL; |
|
| 820 | + if ($path_base==NULL){ |
|
| 821 | + // Chemin standard depuis l'espace public |
|
| 822 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 823 | + _DIR_RACINE.':'. |
|
| 824 | + _DIR_RACINE.'squelettes-dist/:'. |
|
| 825 | + _DIR_RACINE.'prive/:'. |
|
| 826 | + _DIR_RESTREINT; |
|
| 827 | + // Ajouter squelettes/ |
|
| 828 | + if (@is_dir(_DIR_RACINE.'squelettes')) |
|
| 829 | + $path = _DIR_RACINE.'squelettes/:' . $path; |
|
| 830 | + foreach (explode(':', $path) as $dir) { |
|
| 831 | + if (strlen($dir) AND substr($dir,-1) != '/') |
|
| 832 | + $dir .= "/"; |
|
| 833 | + $path_base[] = $dir; |
|
| 834 | + } |
|
| 835 | + $path_full = $path_base; |
|
| 836 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 837 | + if (strlen($GLOBALS['dossier_squelettes'])) |
|
| 838 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 839 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 840 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 841 | + } |
|
| 842 | + if ($dir_path===NULL) return $path_full; |
|
| 843 | + |
|
| 844 | + if (strlen($dir_path)){ |
|
| 845 | + $tete = ""; |
|
| 846 | + if (reset($path_base)==_DIR_RACINE.'squelettes/') |
|
| 847 | + $tete = array_shift($path_base); |
|
| 848 | + $dirs = array_reverse(explode(':',$dir_path)); |
|
| 849 | + foreach($dirs as $dir_path){ |
|
| 850 | + #if ($dir_path{0}!='/') |
|
| 851 | + # $dir_path = $dir_path; |
|
| 852 | + if (substr($dir_path,-1) != '/') |
|
| 853 | + $dir_path .= "/"; |
|
| 854 | + if (!in_array($dir_path,$path_base)) |
|
| 855 | + array_unshift($path_base,$dir_path); |
|
| 856 | + } |
|
| 857 | + if (strlen($tete)) |
|
| 858 | + array_unshift($path_base,$tete); |
|
| 859 | + } |
|
| 860 | + $path_full = $path_base; |
|
| 861 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 862 | + if (strlen($GLOBALS['dossier_squelettes'])) |
|
| 863 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 864 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 865 | + |
|
| 866 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 867 | + return $path_full; |
|
| 869 | 868 | } |
| 870 | 869 | |
| 871 | 870 | // http://doc.spip.org/@creer_chemin |
| 872 | 871 | function creer_chemin() { |
| 873 | - $path_a = _chemin(); |
|
| 874 | - static $c = ''; |
|
| 872 | + $path_a = _chemin(); |
|
| 873 | + static $c = ''; |
|
| 875 | 874 | |
| 876 | - // on calcule le chemin si le dossier skel a change |
|
| 877 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 878 | - // assurer le non plantage lors de la montee de version : |
|
| 879 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 880 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 881 | - } |
|
| 882 | - return $path_a; |
|
| 875 | + // on calcule le chemin si le dossier skel a change |
|
| 876 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 877 | + // assurer le non plantage lors de la montee de version : |
|
| 878 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 879 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 880 | + } |
|
| 881 | + return $path_a; |
|
| 883 | 882 | } |
| 884 | 883 | |
| 885 | 884 | |
| 886 | 885 | function lister_themes_prives(){ |
| 887 | - static $themes = null; |
|
| 888 | - if (is_null($themes)){ |
|
| 889 | - // si pas encore definie |
|
| 890 | - if (!defined('_SPIP_THEME_PRIVE')) |
|
| 891 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 892 | - $themes = array(_SPIP_THEME_PRIVE); |
|
| 893 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 894 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 895 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 896 | - } else { |
|
| 897 | - $prefs = array(); |
|
| 898 | - } |
|
| 899 | - if (is_string($prefs)) |
|
| 900 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 901 | - if ( |
|
| 902 | - ((isset($prefs['theme']) AND $theme = $prefs['theme']) |
|
| 903 | - OR (isset($GLOBALS['theme_prive_defaut']) AND $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 904 | - AND $theme != _SPIP_THEME_PRIVE) |
|
| 905 | - array_unshift($themes,$theme); // placer le theme choisi en tete |
|
| 906 | - } |
|
| 907 | - return $themes; |
|
| 886 | + static $themes = null; |
|
| 887 | + if (is_null($themes)){ |
|
| 888 | + // si pas encore definie |
|
| 889 | + if (!defined('_SPIP_THEME_PRIVE')) |
|
| 890 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 891 | + $themes = array(_SPIP_THEME_PRIVE); |
|
| 892 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 893 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 894 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 895 | + } else { |
|
| 896 | + $prefs = array(); |
|
| 897 | + } |
|
| 898 | + if (is_string($prefs)) |
|
| 899 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 900 | + if ( |
|
| 901 | + ((isset($prefs['theme']) AND $theme = $prefs['theme']) |
|
| 902 | + OR (isset($GLOBALS['theme_prive_defaut']) AND $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 903 | + AND $theme != _SPIP_THEME_PRIVE) |
|
| 904 | + array_unshift($themes,$theme); // placer le theme choisi en tete |
|
| 905 | + } |
|
| 906 | + return $themes; |
|
| 908 | 907 | } |
| 909 | 908 | |
| 910 | 909 | function find_in_theme($file, $subdir='', $include=false){ |
| 911 | - static $themefiles=array(); |
|
| 912 | - if (isset($themefiles["$subdir$file"])) return $themefiles["$subdir$file"]; |
|
| 913 | - $themes = lister_themes_prives(); |
|
| 914 | - foreach($themes as $theme){ |
|
| 915 | - if ($f = find_in_path($file,"prive/themes/$theme/$subdir",$include)) |
|
| 916 | - return $themefiles["$subdir$file"] = $f; |
|
| 917 | - } |
|
| 918 | - spip_log("$file introuvable dans le theme prive ".reset($themes),'theme'); |
|
| 919 | - return $themefiles["$subdir$file"] = ""; |
|
| 910 | + static $themefiles=array(); |
|
| 911 | + if (isset($themefiles["$subdir$file"])) return $themefiles["$subdir$file"]; |
|
| 912 | + $themes = lister_themes_prives(); |
|
| 913 | + foreach($themes as $theme){ |
|
| 914 | + if ($f = find_in_path($file,"prive/themes/$theme/$subdir",$include)) |
|
| 915 | + return $themefiles["$subdir$file"] = $f; |
|
| 916 | + } |
|
| 917 | + spip_log("$file introuvable dans le theme prive ".reset($themes),'theme'); |
|
| 918 | + return $themefiles["$subdir$file"] = ""; |
|
| 920 | 919 | } |
| 921 | 920 | |
| 922 | 921 | // Cherche une image dans les dossiers images |
@@ -926,22 +925,22 @@ discard block |
||
| 926 | 925 | // dans _DIR_IMG_PACK |
| 927 | 926 | // http://doc.spip.org/@chemin_image |
| 928 | 927 | function chemin_image($icone){ |
| 929 | - static $icone_renommer; |
|
| 930 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 931 | - if (strpos($icone,"/")!==false AND file_exists($icone)) return $icone; |
|
| 928 | + static $icone_renommer; |
|
| 929 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 930 | + if (strpos($icone,"/")!==false AND file_exists($icone)) return $icone; |
|
| 932 | 931 | |
| 933 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 934 | - if (preg_match(',[.](png|gif|jpg)$,',$icone) AND $f = find_in_theme("images/$icone")) |
|
| 935 | - return $f; |
|
| 936 | - // sinon passer par le module de renommage |
|
| 937 | - if (is_null($icone_renommer)) |
|
| 938 | - $icone_renommer = charger_fonction('icone_renommer','inc',true); |
|
| 939 | - if ($icone_renommer){ |
|
| 940 | - list($icone,$fonction) = $icone_renommer($icone,""); |
|
| 941 | - if (file_exists($icone)) |
|
| 942 | - return $icone; |
|
| 943 | - } |
|
| 944 | - return find_in_path ($icone, _NOM_IMG_PACK); |
|
| 932 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 933 | + if (preg_match(',[.](png|gif|jpg)$,',$icone) AND $f = find_in_theme("images/$icone")) |
|
| 934 | + return $f; |
|
| 935 | + // sinon passer par le module de renommage |
|
| 936 | + if (is_null($icone_renommer)) |
|
| 937 | + $icone_renommer = charger_fonction('icone_renommer','inc',true); |
|
| 938 | + if ($icone_renommer){ |
|
| 939 | + list($icone,$fonction) = $icone_renommer($icone,""); |
|
| 940 | + if (file_exists($icone)) |
|
| 941 | + return $icone; |
|
| 942 | + } |
|
| 943 | + return find_in_path ($icone, _NOM_IMG_PACK); |
|
| 945 | 944 | } |
| 946 | 945 | |
| 947 | 946 | // |
@@ -953,109 +952,109 @@ discard block |
||
| 953 | 952 | |
| 954 | 953 | // http://doc.spip.org/@find_in_path |
| 955 | 954 | function find_in_path ($file, $dirname='', $include=false) { |
| 956 | - static $dirs=array(); |
|
| 957 | - static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743 |
|
| 958 | - static $c = ''; |
|
| 959 | - |
|
| 960 | - // on calcule le chemin si le dossier skel a change |
|
| 961 | - if ($c != $GLOBALS['dossier_squelettes']){ |
|
| 962 | - // assurer le non plantage lors de la montee de version : |
|
| 963 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 964 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 965 | - } |
|
| 966 | - |
|
| 967 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 968 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) |
|
| 969 | - return false; |
|
| 970 | - if ($include AND !isset($inc[$dirname][$file])) { |
|
| 971 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 972 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 973 | - } |
|
| 974 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 975 | - } |
|
| 976 | - |
|
| 977 | - $a = strrpos($file,'/'); |
|
| 978 | - if ($a !== false) { |
|
| 979 | - $dirname .= substr($file, 0, ++$a); |
|
| 980 | - $file = substr($file, $a); |
|
| 981 | - } |
|
| 982 | - |
|
| 983 | - foreach(creer_chemin() as $dir) { |
|
| 984 | - if (!isset($dirs[$a = $dir . $dirname])) |
|
| 985 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a) ; |
|
| 986 | - if ($dirs[$a]) { |
|
| 987 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 988 | - if ($include AND !isset($inc[$dirname][$file])) { |
|
| 989 | - include_once _ROOT_CWD . $a; |
|
| 990 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 991 | - } |
|
| 992 | - if (!defined('_SAUVER_CHEMIN')){ |
|
| 993 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 994 | - if (is_null($GLOBALS['path_files'])) return $a; |
|
| 995 | - define('_SAUVER_CHEMIN', true); |
|
| 996 | - } |
|
| 997 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 998 | - } |
|
| 999 | - } |
|
| 1000 | - } |
|
| 1001 | - |
|
| 1002 | - if ($include){ |
|
| 1003 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1004 | - if ($include==='required'){ |
|
| 1005 | - echo '<pre>', |
|
| 1006 | - "<strong>Erreur Fatale</strong><br />"; |
|
| 1007 | - if (function_exists('debug_print_backtrace')) |
|
| 1008 | - echo debug_print_backtrace(); |
|
| 1009 | - echo '</pre>'; |
|
| 1010 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1011 | - } |
|
| 1012 | - } |
|
| 1013 | - |
|
| 1014 | - if (!defined('_SAUVER_CHEMIN')){ |
|
| 1015 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1016 | - if (is_null($GLOBALS['path_files'])) return false; |
|
| 1017 | - define('_SAUVER_CHEMIN', true); |
|
| 1018 | - } |
|
| 1019 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 955 | + static $dirs=array(); |
|
| 956 | + static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743 |
|
| 957 | + static $c = ''; |
|
| 958 | + |
|
| 959 | + // on calcule le chemin si le dossier skel a change |
|
| 960 | + if ($c != $GLOBALS['dossier_squelettes']){ |
|
| 961 | + // assurer le non plantage lors de la montee de version : |
|
| 962 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 963 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 964 | + } |
|
| 965 | + |
|
| 966 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 967 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) |
|
| 968 | + return false; |
|
| 969 | + if ($include AND !isset($inc[$dirname][$file])) { |
|
| 970 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 971 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 972 | + } |
|
| 973 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 974 | + } |
|
| 975 | + |
|
| 976 | + $a = strrpos($file,'/'); |
|
| 977 | + if ($a !== false) { |
|
| 978 | + $dirname .= substr($file, 0, ++$a); |
|
| 979 | + $file = substr($file, $a); |
|
| 980 | + } |
|
| 981 | + |
|
| 982 | + foreach(creer_chemin() as $dir) { |
|
| 983 | + if (!isset($dirs[$a = $dir . $dirname])) |
|
| 984 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a) ; |
|
| 985 | + if ($dirs[$a]) { |
|
| 986 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 987 | + if ($include AND !isset($inc[$dirname][$file])) { |
|
| 988 | + include_once _ROOT_CWD . $a; |
|
| 989 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 990 | + } |
|
| 991 | + if (!defined('_SAUVER_CHEMIN')){ |
|
| 992 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 993 | + if (is_null($GLOBALS['path_files'])) return $a; |
|
| 994 | + define('_SAUVER_CHEMIN', true); |
|
| 995 | + } |
|
| 996 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 997 | + } |
|
| 998 | + } |
|
| 999 | + } |
|
| 1000 | + |
|
| 1001 | + if ($include){ |
|
| 1002 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1003 | + if ($include==='required'){ |
|
| 1004 | + echo '<pre>', |
|
| 1005 | + "<strong>Erreur Fatale</strong><br />"; |
|
| 1006 | + if (function_exists('debug_print_backtrace')) |
|
| 1007 | + echo debug_print_backtrace(); |
|
| 1008 | + echo '</pre>'; |
|
| 1009 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1010 | + } |
|
| 1011 | + } |
|
| 1012 | + |
|
| 1013 | + if (!defined('_SAUVER_CHEMIN')){ |
|
| 1014 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1015 | + if (is_null($GLOBALS['path_files'])) return false; |
|
| 1016 | + define('_SAUVER_CHEMIN', true); |
|
| 1017 | + } |
|
| 1018 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1020 | 1019 | } |
| 1021 | 1020 | |
| 1022 | 1021 | function clear_path_cache(){ |
| 1023 | - $GLOBALS['path_files'] = array(); |
|
| 1024 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1022 | + $GLOBALS['path_files'] = array(); |
|
| 1023 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1025 | 1024 | } |
| 1026 | 1025 | function load_path_cache(){ |
| 1027 | - // charger le path des plugins |
|
| 1028 | - if (@is_readable(_CACHE_PLUGINS_PATH)){ |
|
| 1029 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1030 | - } |
|
| 1031 | - $GLOBALS['path_files'] = array(); |
|
| 1032 | - // si le visiteur est admin, |
|
| 1033 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1034 | - if ( |
|
| 1035 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1036 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1037 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1038 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1039 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1040 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1041 | - !_request('var_mode') |
|
| 1042 | - ){ |
|
| 1043 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1044 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)){ |
|
| 1045 | - // mais si semble corrompu on relit avec un verrou |
|
| 1046 | - if (!$GLOBALS['path_files']=unserialize($contenu)){ |
|
| 1047 | - lire_fichier(_CACHE_CHEMIN,$contenu); |
|
| 1048 | - if (!$GLOBALS['path_files']=unserialize($contenu)) |
|
| 1049 | - $GLOBALS['path_files'] = array(); |
|
| 1050 | - } |
|
| 1051 | - } |
|
| 1052 | - } |
|
| 1026 | + // charger le path des plugins |
|
| 1027 | + if (@is_readable(_CACHE_PLUGINS_PATH)){ |
|
| 1028 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1029 | + } |
|
| 1030 | + $GLOBALS['path_files'] = array(); |
|
| 1031 | + // si le visiteur est admin, |
|
| 1032 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1033 | + if ( |
|
| 1034 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1035 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1036 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1037 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1038 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1039 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1040 | + !_request('var_mode') |
|
| 1041 | + ){ |
|
| 1042 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1043 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)){ |
|
| 1044 | + // mais si semble corrompu on relit avec un verrou |
|
| 1045 | + if (!$GLOBALS['path_files']=unserialize($contenu)){ |
|
| 1046 | + lire_fichier(_CACHE_CHEMIN,$contenu); |
|
| 1047 | + if (!$GLOBALS['path_files']=unserialize($contenu)) |
|
| 1048 | + $GLOBALS['path_files'] = array(); |
|
| 1049 | + } |
|
| 1050 | + } |
|
| 1051 | + } |
|
| 1053 | 1052 | } |
| 1054 | 1053 | |
| 1055 | 1054 | function save_path_cache(){ |
| 1056 | - if (defined('_SAUVER_CHEMIN') |
|
| 1057 | - AND _SAUVER_CHEMIN) |
|
| 1058 | - ecrire_fichier(_CACHE_CHEMIN,serialize($GLOBALS['path_files'])); |
|
| 1055 | + if (defined('_SAUVER_CHEMIN') |
|
| 1056 | + AND _SAUVER_CHEMIN) |
|
| 1057 | + ecrire_fichier(_CACHE_CHEMIN,serialize($GLOBALS['path_files'])); |
|
| 1059 | 1058 | } |
| 1060 | 1059 | |
| 1061 | 1060 | |
@@ -1071,25 +1070,25 @@ discard block |
||
| 1071 | 1070 | */ |
| 1072 | 1071 | // http://doc.spip.org/@find_all_in_path |
| 1073 | 1072 | function find_all_in_path($dir,$pattern, $recurs=false){ |
| 1074 | - $liste_fichiers=array(); |
|
| 1075 | - $maxfiles = 10000; |
|
| 1076 | - |
|
| 1077 | - // Parcourir le chemin |
|
| 1078 | - foreach (creer_chemin() as $d) { |
|
| 1079 | - $f = $d.$dir; |
|
| 1080 | - if (@is_dir($f)){ |
|
| 1081 | - $liste = preg_files($f,$pattern,$maxfiles-count($liste_fichiers),$recurs===true?array():$recurs); |
|
| 1082 | - foreach($liste as $chemin){ |
|
| 1083 | - $nom = basename($chemin); |
|
| 1084 | - // ne prendre que les fichiers pas deja trouves |
|
| 1085 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1086 | - // les autres sont donc masques |
|
| 1087 | - if (!isset($liste_fichiers[$nom])) |
|
| 1088 | - $liste_fichiers[$nom] = $chemin; |
|
| 1089 | - } |
|
| 1090 | - } |
|
| 1091 | - } |
|
| 1092 | - return $liste_fichiers; |
|
| 1073 | + $liste_fichiers=array(); |
|
| 1074 | + $maxfiles = 10000; |
|
| 1075 | + |
|
| 1076 | + // Parcourir le chemin |
|
| 1077 | + foreach (creer_chemin() as $d) { |
|
| 1078 | + $f = $d.$dir; |
|
| 1079 | + if (@is_dir($f)){ |
|
| 1080 | + $liste = preg_files($f,$pattern,$maxfiles-count($liste_fichiers),$recurs===true?array():$recurs); |
|
| 1081 | + foreach($liste as $chemin){ |
|
| 1082 | + $nom = basename($chemin); |
|
| 1083 | + // ne prendre que les fichiers pas deja trouves |
|
| 1084 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1085 | + // les autres sont donc masques |
|
| 1086 | + if (!isset($liste_fichiers[$nom])) |
|
| 1087 | + $liste_fichiers[$nom] = $chemin; |
|
| 1088 | + } |
|
| 1089 | + } |
|
| 1090 | + } |
|
| 1091 | + return $liste_fichiers; |
|
| 1093 | 1092 | } |
| 1094 | 1093 | |
| 1095 | 1094 | // predicat sur les scripts de ecrire qui n'authentifient pas par cookie |
@@ -1097,9 +1096,9 @@ discard block |
||
| 1097 | 1096 | // http://doc.spip.org/@autoriser_sans_cookie |
| 1098 | 1097 | function autoriser_sans_cookie($nom) |
| 1099 | 1098 | { |
| 1100 | - static $autsanscookie = array('install', 'base_repair'); |
|
| 1101 | - $nom = preg_replace('/.php[3]?$/', '', basename($nom)); |
|
| 1102 | - return in_array($nom, $autsanscookie); |
|
| 1099 | + static $autsanscookie = array('install', 'base_repair'); |
|
| 1100 | + $nom = preg_replace('/.php[3]?$/', '', basename($nom)); |
|
| 1101 | + return in_array($nom, $autsanscookie); |
|
| 1103 | 1102 | } |
| 1104 | 1103 | |
| 1105 | 1104 | /** |
@@ -1128,112 +1127,112 @@ discard block |
||
| 1128 | 1127 | */ |
| 1129 | 1128 | function generer_url_entite($id='', $entite='', $args='', $ancre='', $public=NULL, $type=NULL) |
| 1130 | 1129 | { |
| 1131 | - if ($public === NULL) $public = !test_espace_prive(); |
|
| 1132 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1133 | - |
|
| 1134 | - if (!$public) { |
|
| 1135 | - if (!$entite) return ''; |
|
| 1136 | - if (!function_exists('generer_url_ecrire_objet')) |
|
| 1137 | - include_spip('inc/urls'); |
|
| 1138 | - $res = generer_url_ecrire_objet($entite,$id, $args, $ancre, false); |
|
| 1139 | - } else { |
|
| 1140 | - if ($type === NULL) { |
|
| 1141 | - $type = ($GLOBALS['type_urls'] === 'page' |
|
| 1142 | - AND $GLOBALS['meta']['type_urls']) |
|
| 1143 | - ? $GLOBALS['meta']['type_urls'] |
|
| 1144 | - : $GLOBALS['type_urls']; // pour SPIP <2 |
|
| 1145 | - } |
|
| 1146 | - |
|
| 1147 | - $f = charger_fonction($type, 'urls', true); |
|
| 1148 | - // se rabattre sur les urls page si les urls perso non dispo |
|
| 1149 | - if (!$f) $f = charger_fonction('page', 'urls', true); |
|
| 1150 | - |
|
| 1151 | - // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1152 | - // sinon on veut effectuer le passage id ==> URL |
|
| 1153 | - if (!$entite) return $f; |
|
| 1154 | - |
|
| 1155 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1156 | - // base distante |
|
| 1157 | - if (is_string($public) |
|
| 1158 | - AND $g = charger_fonction('connect', 'urls', true)) |
|
| 1159 | - $f = $g; |
|
| 1160 | - |
|
| 1161 | - $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1162 | - |
|
| 1163 | - } |
|
| 1164 | - if ($res) return $res; |
|
| 1165 | - // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1166 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1167 | - if (!function_exists($f .= '_dist')) $f = ''; |
|
| 1168 | - } |
|
| 1169 | - if ($f) { |
|
| 1170 | - $url = $f($id, $args, $ancre); |
|
| 1171 | - if (strlen($args)) |
|
| 1172 | - $url .= strstr($url, '?') |
|
| 1173 | - ? '&'.$args |
|
| 1174 | - : '?'.$args; |
|
| 1175 | - return $url; |
|
| 1176 | - } |
|
| 1177 | - // On a ete gentil mais la .... |
|
| 1178 | - spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1179 | - return ''; |
|
| 1130 | + if ($public === NULL) $public = !test_espace_prive(); |
|
| 1131 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1132 | + |
|
| 1133 | + if (!$public) { |
|
| 1134 | + if (!$entite) return ''; |
|
| 1135 | + if (!function_exists('generer_url_ecrire_objet')) |
|
| 1136 | + include_spip('inc/urls'); |
|
| 1137 | + $res = generer_url_ecrire_objet($entite,$id, $args, $ancre, false); |
|
| 1138 | + } else { |
|
| 1139 | + if ($type === NULL) { |
|
| 1140 | + $type = ($GLOBALS['type_urls'] === 'page' |
|
| 1141 | + AND $GLOBALS['meta']['type_urls']) |
|
| 1142 | + ? $GLOBALS['meta']['type_urls'] |
|
| 1143 | + : $GLOBALS['type_urls']; // pour SPIP <2 |
|
| 1144 | + } |
|
| 1145 | + |
|
| 1146 | + $f = charger_fonction($type, 'urls', true); |
|
| 1147 | + // se rabattre sur les urls page si les urls perso non dispo |
|
| 1148 | + if (!$f) $f = charger_fonction('page', 'urls', true); |
|
| 1149 | + |
|
| 1150 | + // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1151 | + // sinon on veut effectuer le passage id ==> URL |
|
| 1152 | + if (!$entite) return $f; |
|
| 1153 | + |
|
| 1154 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1155 | + // base distante |
|
| 1156 | + if (is_string($public) |
|
| 1157 | + AND $g = charger_fonction('connect', 'urls', true)) |
|
| 1158 | + $f = $g; |
|
| 1159 | + |
|
| 1160 | + $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1161 | + |
|
| 1162 | + } |
|
| 1163 | + if ($res) return $res; |
|
| 1164 | + // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1165 | + if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1166 | + if (!function_exists($f .= '_dist')) $f = ''; |
|
| 1167 | + } |
|
| 1168 | + if ($f) { |
|
| 1169 | + $url = $f($id, $args, $ancre); |
|
| 1170 | + if (strlen($args)) |
|
| 1171 | + $url .= strstr($url, '?') |
|
| 1172 | + ? '&'.$args |
|
| 1173 | + : '?'.$args; |
|
| 1174 | + return $url; |
|
| 1175 | + } |
|
| 1176 | + // On a ete gentil mais la .... |
|
| 1177 | + spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1178 | + return ''; |
|
| 1180 | 1179 | } |
| 1181 | 1180 | |
| 1182 | 1181 | function generer_url_ecrire_entite_edit($id, $entite, $args='', $ancre=''){ |
| 1183 | - $exec = objet_info($entite,'url_edit'); |
|
| 1184 | - $url = generer_url_ecrire($exec,$args); |
|
| 1185 | - if (intval($id)) |
|
| 1186 | - $url = parametre_url($url,id_table_objet($entite),$id); |
|
| 1187 | - else |
|
| 1188 | - $url = parametre_url($url,'new','oui'); |
|
| 1189 | - if ($ancre) |
|
| 1190 | - $url = ancre_url($url,$ancre); |
|
| 1191 | - return $url; |
|
| 1182 | + $exec = objet_info($entite,'url_edit'); |
|
| 1183 | + $url = generer_url_ecrire($exec,$args); |
|
| 1184 | + if (intval($id)) |
|
| 1185 | + $url = parametre_url($url,id_table_objet($entite),$id); |
|
| 1186 | + else |
|
| 1187 | + $url = parametre_url($url,'new','oui'); |
|
| 1188 | + if ($ancre) |
|
| 1189 | + $url = ancre_url($url,$ancre); |
|
| 1190 | + return $url; |
|
| 1192 | 1191 | } |
| 1193 | 1192 | |
| 1194 | 1193 | // http://doc.spip.org/@urls_connect_dist |
| 1195 | 1194 | function urls_connect_dist($i, &$entite, $args='', $ancre='', $public=null) { |
| 1196 | - include_spip('base/connect_sql'); |
|
| 1197 | - $id_type = id_table_objet($entite,$public); |
|
| 1198 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1199 | - . "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1200 | - . (!$args ? '' : "&$args") |
|
| 1201 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1195 | + include_spip('base/connect_sql'); |
|
| 1196 | + $id_type = id_table_objet($entite,$public); |
|
| 1197 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1198 | + . "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1199 | + . (!$args ? '' : "&$args") |
|
| 1200 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1202 | 1201 | } |
| 1203 | 1202 | |
| 1204 | 1203 | |
| 1205 | 1204 | // Transformer les caracteres utf8 d'une URL (farsi par ex) selon la RFC 1738 |
| 1206 | 1205 | function urlencode_1738($url) { |
| 1207 | - if (preg_match(',[^\x00-\x7E],sS', $url)){ |
|
| 1208 | - $uri = ''; |
|
| 1209 | - for ($i=0; $i < strlen($url); $i++) { |
|
| 1210 | - if (ord($a = $url[$i]) > 127) |
|
| 1211 | - $a = rawurlencode($a); |
|
| 1212 | - $uri .= $a; |
|
| 1213 | - } |
|
| 1214 | - $url = $uri; |
|
| 1215 | - } |
|
| 1216 | - return quote_amp($url); |
|
| 1206 | + if (preg_match(',[^\x00-\x7E],sS', $url)){ |
|
| 1207 | + $uri = ''; |
|
| 1208 | + for ($i=0; $i < strlen($url); $i++) { |
|
| 1209 | + if (ord($a = $url[$i]) > 127) |
|
| 1210 | + $a = rawurlencode($a); |
|
| 1211 | + $uri .= $a; |
|
| 1212 | + } |
|
| 1213 | + $url = $uri; |
|
| 1214 | + } |
|
| 1215 | + return quote_amp($url); |
|
| 1217 | 1216 | } |
| 1218 | 1217 | |
| 1219 | 1218 | // http://doc.spip.org/@generer_url_entite_absolue |
| 1220 | 1219 | function generer_url_entite_absolue($id='', $entite='', $args='', $ancre='', $connect=NULL) |
| 1221 | 1220 | { |
| 1222 | - if (!$connect) $connect = true; |
|
| 1223 | - $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1224 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1225 | - include_spip('inc/filtres_mini'); |
|
| 1226 | - $h = url_absolue($h); |
|
| 1227 | - } |
|
| 1228 | - return $h; |
|
| 1221 | + if (!$connect) $connect = true; |
|
| 1222 | + $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1223 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1224 | + include_spip('inc/filtres_mini'); |
|
| 1225 | + $h = url_absolue($h); |
|
| 1226 | + } |
|
| 1227 | + return $h; |
|
| 1229 | 1228 | } |
| 1230 | 1229 | |
| 1231 | 1230 | // Sur certains serveurs, la valeur 'Off' tient lieu de false dans certaines |
| 1232 | 1231 | // variables d'environnement comme $_SERVER[HTTPS] ou ini_get(register_globals) |
| 1233 | 1232 | // http://doc.spip.org/@test_valeur_serveur |
| 1234 | 1233 | function test_valeur_serveur($truc) { |
| 1235 | - if (!$truc) return false; |
|
| 1236 | - return (strtolower($truc) !== 'off'); |
|
| 1234 | + if (!$truc) return false; |
|
| 1235 | + return (strtolower($truc) !== 'off'); |
|
| 1237 | 1236 | } |
| 1238 | 1237 | |
| 1239 | 1238 | // |
@@ -1258,51 +1257,51 @@ discard block |
||
| 1258 | 1257 | */ |
| 1259 | 1258 | function url_de_base($profondeur=null) { |
| 1260 | 1259 | |
| 1261 | - static $url = array(); |
|
| 1262 | - if (is_array($profondeur)) return $url = $profondeur; |
|
| 1263 | - if ($profondeur===false) return $url; |
|
| 1264 | - |
|
| 1265 | - if (is_null($profondeur)) $profondeur = $GLOBALS['profondeur_url']; |
|
| 1266 | - |
|
| 1267 | - if (isset($url[$profondeur])) |
|
| 1268 | - return $url[$profondeur]; |
|
| 1269 | - |
|
| 1270 | - $http = ( |
|
| 1271 | - (isset($_SERVER["SCRIPT_URI"]) AND |
|
| 1272 | - substr($_SERVER["SCRIPT_URI"],0,5) == 'https') |
|
| 1273 | - OR (isset($_SERVER['HTTPS']) AND |
|
| 1274 | - test_valeur_serveur($_SERVER['HTTPS'])) |
|
| 1275 | - ) ? 'https' : 'http'; |
|
| 1276 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 1277 | - $host = $_SERVER['HTTP_HOST']; |
|
| 1278 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1279 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1280 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 1281 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1282 | - $http = $scheme; |
|
| 1283 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 1284 | - } |
|
| 1285 | - } |
|
| 1286 | - if (isset($_SERVER['SERVER_PORT']) |
|
| 1287 | - AND $port=$_SERVER['SERVER_PORT'] |
|
| 1288 | - AND strpos($host,":")==false){ |
|
| 1289 | - if ($http=="http" AND $port!=80) $host.=":$port"; |
|
| 1290 | - if ($http=="https" AND $port!=443) $host.=":$port"; |
|
| 1291 | - } |
|
| 1292 | - if (!$GLOBALS['REQUEST_URI']){ |
|
| 1293 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 1294 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 1295 | - } else { |
|
| 1296 | - $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; |
|
| 1297 | - if ($_SERVER['QUERY_STRING'] |
|
| 1298 | - AND !strpos($_SERVER['REQUEST_URI'], '?')) |
|
| 1299 | - $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1300 | - } |
|
| 1301 | - } |
|
| 1302 | - |
|
| 1303 | - $url[$profondeur] = url_de_($http,$host,$GLOBALS['REQUEST_URI'],$profondeur); |
|
| 1304 | - |
|
| 1305 | - return $url[$profondeur]; |
|
| 1260 | + static $url = array(); |
|
| 1261 | + if (is_array($profondeur)) return $url = $profondeur; |
|
| 1262 | + if ($profondeur===false) return $url; |
|
| 1263 | + |
|
| 1264 | + if (is_null($profondeur)) $profondeur = $GLOBALS['profondeur_url']; |
|
| 1265 | + |
|
| 1266 | + if (isset($url[$profondeur])) |
|
| 1267 | + return $url[$profondeur]; |
|
| 1268 | + |
|
| 1269 | + $http = ( |
|
| 1270 | + (isset($_SERVER["SCRIPT_URI"]) AND |
|
| 1271 | + substr($_SERVER["SCRIPT_URI"],0,5) == 'https') |
|
| 1272 | + OR (isset($_SERVER['HTTPS']) AND |
|
| 1273 | + test_valeur_serveur($_SERVER['HTTPS'])) |
|
| 1274 | + ) ? 'https' : 'http'; |
|
| 1275 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 1276 | + $host = $_SERVER['HTTP_HOST']; |
|
| 1277 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1278 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1279 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 1280 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1281 | + $http = $scheme; |
|
| 1282 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 1283 | + } |
|
| 1284 | + } |
|
| 1285 | + if (isset($_SERVER['SERVER_PORT']) |
|
| 1286 | + AND $port=$_SERVER['SERVER_PORT'] |
|
| 1287 | + AND strpos($host,":")==false){ |
|
| 1288 | + if ($http=="http" AND $port!=80) $host.=":$port"; |
|
| 1289 | + if ($http=="https" AND $port!=443) $host.=":$port"; |
|
| 1290 | + } |
|
| 1291 | + if (!$GLOBALS['REQUEST_URI']){ |
|
| 1292 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 1293 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 1294 | + } else { |
|
| 1295 | + $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; |
|
| 1296 | + if ($_SERVER['QUERY_STRING'] |
|
| 1297 | + AND !strpos($_SERVER['REQUEST_URI'], '?')) |
|
| 1298 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1299 | + } |
|
| 1300 | + } |
|
| 1301 | + |
|
| 1302 | + $url[$profondeur] = url_de_($http,$host,$GLOBALS['REQUEST_URI'],$profondeur); |
|
| 1303 | + |
|
| 1304 | + return $url[$profondeur]; |
|
| 1306 | 1305 | } |
| 1307 | 1306 | /** |
| 1308 | 1307 | * fonction testable de construction d'une url appelee par url_de_base() |
@@ -1313,25 +1312,25 @@ discard block |
||
| 1313 | 1312 | * @return string |
| 1314 | 1313 | */ |
| 1315 | 1314 | function url_de_($http,$host,$request,$prof=0){ |
| 1316 | - $prof = max($prof,0); |
|
| 1315 | + $prof = max($prof,0); |
|
| 1317 | 1316 | |
| 1318 | - $myself = ltrim($request,'/'); |
|
| 1319 | - # supprimer la chaine de GET |
|
| 1320 | - list($myself) = explode('?', $myself); |
|
| 1321 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 1322 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 1323 | - if (strpos($myself,'://') !== false) { |
|
| 1324 | - $myself = explode('://',$myself); |
|
| 1325 | - array_shift($myself); |
|
| 1326 | - $myself = implode('://',$myself); |
|
| 1327 | - $myself = explode('/',$myself); |
|
| 1328 | - array_shift($myself); |
|
| 1329 | - $myself = implode('/',$myself); |
|
| 1330 | - } |
|
| 1331 | - $url = join('/', array_slice(explode('/', $myself), 0, -1-$prof)).'/'; |
|
| 1317 | + $myself = ltrim($request,'/'); |
|
| 1318 | + # supprimer la chaine de GET |
|
| 1319 | + list($myself) = explode('?', $myself); |
|
| 1320 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 1321 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 1322 | + if (strpos($myself,'://') !== false) { |
|
| 1323 | + $myself = explode('://',$myself); |
|
| 1324 | + array_shift($myself); |
|
| 1325 | + $myself = implode('://',$myself); |
|
| 1326 | + $myself = explode('/',$myself); |
|
| 1327 | + array_shift($myself); |
|
| 1328 | + $myself = implode('/',$myself); |
|
| 1329 | + } |
|
| 1330 | + $url = join('/', array_slice(explode('/', $myself), 0, -1-$prof)).'/'; |
|
| 1332 | 1331 | |
| 1333 | - $url = $http.'://'.rtrim($host,'/').'/'.ltrim($url,'/'); |
|
| 1334 | - return $url; |
|
| 1332 | + $url = $http.'://'.rtrim($host,'/').'/'.ltrim($url,'/'); |
|
| 1333 | + return $url; |
|
| 1335 | 1334 | } |
| 1336 | 1335 | |
| 1337 | 1336 | |
@@ -1345,25 +1344,25 @@ discard block |
||
| 1345 | 1344 | |
| 1346 | 1345 | // http://doc.spip.org/@generer_url_ecrire |
| 1347 | 1346 | function generer_url_ecrire($script='', $args="", $no_entities=false, $rel=false) { |
| 1348 | - if (!$rel) |
|
| 1349 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 1350 | - else if (!is_string($rel)) |
|
| 1351 | - $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 1352 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 1347 | + if (!$rel) |
|
| 1348 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 1349 | + else if (!is_string($rel)) |
|
| 1350 | + $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 1351 | + ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 1353 | 1352 | |
| 1354 | - @list($script, $ancre) = explode('#', $script); |
|
| 1355 | - if ($script AND ($script<>'accueil' OR $rel)) |
|
| 1356 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 1357 | - elseif ($args) |
|
| 1358 | - $args ="?$args"; |
|
| 1359 | - if ($ancre) $args .= "#$ancre"; |
|
| 1360 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 1353 | + @list($script, $ancre) = explode('#', $script); |
|
| 1354 | + if ($script AND ($script<>'accueil' OR $rel)) |
|
| 1355 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 1356 | + elseif ($args) |
|
| 1357 | + $args ="?$args"; |
|
| 1358 | + if ($ancre) $args .= "#$ancre"; |
|
| 1359 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 1361 | 1360 | } |
| 1362 | 1361 | |
| 1363 | 1362 | // http://doc.spip.org/@generer_url_retour |
| 1364 | 1363 | function generer_url_retour($script, $args="") |
| 1365 | 1364 | { |
| 1366 | - return rawurlencode(generer_url_ecrire($script, $args, true, true)); |
|
| 1365 | + return rawurlencode(generer_url_ecrire($script, $args, true, true)); |
|
| 1367 | 1366 | } |
| 1368 | 1367 | |
| 1369 | 1368 | // |
@@ -1374,42 +1373,42 @@ discard block |
||
| 1374 | 1373 | // dans le cas de '', un $default = './' peut servir (comme dans urls/page.php) |
| 1375 | 1374 | // http://doc.spip.org/@get_spip_script |
| 1376 | 1375 | function get_spip_script($default='') { |
| 1377 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 1378 | - if (_SPIP_SCRIPT) |
|
| 1379 | - return _SPIP_SCRIPT; |
|
| 1380 | - else |
|
| 1381 | - return $default; |
|
| 1376 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 1377 | + if (_SPIP_SCRIPT) |
|
| 1378 | + return _SPIP_SCRIPT; |
|
| 1379 | + else |
|
| 1380 | + return $default; |
|
| 1382 | 1381 | } |
| 1383 | 1382 | |
| 1384 | 1383 | // http://doc.spip.org/@generer_url_public |
| 1385 | 1384 | function generer_url_public($script='', $args="", $no_entities=false, $rel=true, $action='') { |
| 1386 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 1387 | - // standardiser vers la nouvelle API |
|
| 1385 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 1386 | + // standardiser vers la nouvelle API |
|
| 1388 | 1387 | |
| 1389 | - if (!$action) $action = get_spip_script(); |
|
| 1390 | - if ($script) |
|
| 1391 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 1388 | + if (!$action) $action = get_spip_script(); |
|
| 1389 | + if ($script) |
|
| 1390 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 1392 | 1391 | |
| 1393 | - if ($args) { |
|
| 1394 | - if (is_array($args)) { |
|
| 1395 | - $r = ''; |
|
| 1396 | - foreach($args as $k => $v) $r .= '&' . $k . '=' . $v; |
|
| 1397 | - $args = substr($r,1); |
|
| 1398 | - } |
|
| 1399 | - $action .= |
|
| 1400 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 1401 | - } |
|
| 1402 | - if (!$no_entities) |
|
| 1403 | - $action = quote_amp($action); |
|
| 1392 | + if ($args) { |
|
| 1393 | + if (is_array($args)) { |
|
| 1394 | + $r = ''; |
|
| 1395 | + foreach($args as $k => $v) $r .= '&' . $k . '=' . $v; |
|
| 1396 | + $args = substr($r,1); |
|
| 1397 | + } |
|
| 1398 | + $action .= |
|
| 1399 | + (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 1400 | + } |
|
| 1401 | + if (!$no_entities) |
|
| 1402 | + $action = quote_amp($action); |
|
| 1404 | 1403 | |
| 1405 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 1406 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(),'/') . preg_replace(",^/[.]/,","/","/$action")); |
|
| 1404 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 1405 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(),'/') . preg_replace(",^/[.]/,","/","/$action")); |
|
| 1407 | 1406 | } |
| 1408 | 1407 | |
| 1409 | 1408 | // http://doc.spip.org/@generer_url_prive |
| 1410 | 1409 | function generer_url_prive($script, $args="", $no_entities=false) { |
| 1411 | 1410 | |
| 1412 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 1411 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 1413 | 1412 | } |
| 1414 | 1413 | |
| 1415 | 1414 | // Pour les formulaires en methode POST, |
@@ -1419,21 +1418,21 @@ discard block |
||
| 1419 | 1418 | |
| 1420 | 1419 | // http://doc.spip.org/@generer_form_ecrire |
| 1421 | 1420 | function generer_form_ecrire($script, $corps, $atts='', $submit='') { |
| 1422 | - global $spip_lang_right; |
|
| 1421 | + global $spip_lang_right; |
|
| 1423 | 1422 | |
| 1424 | - $script1 = explode('&', $script); |
|
| 1425 | - $script1 = reset($script1); |
|
| 1423 | + $script1 = explode('&', $script); |
|
| 1424 | + $script1 = reset($script1); |
|
| 1426 | 1425 | |
| 1427 | - return "<form action='" |
|
| 1428 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 1429 | - . "' " |
|
| 1430 | - . ($atts ? $atts : " method='post'") |
|
| 1431 | - . "><div>\n" |
|
| 1432 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 1433 | - . $corps |
|
| 1434 | - . (!$submit ? '' : |
|
| 1435 | - ("<div style='text-align: $spip_lang_right'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>")) |
|
| 1436 | - . "</div></form>\n"; |
|
| 1426 | + return "<form action='" |
|
| 1427 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 1428 | + . "' " |
|
| 1429 | + . ($atts ? $atts : " method='post'") |
|
| 1430 | + . "><div>\n" |
|
| 1431 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 1432 | + . $corps |
|
| 1433 | + . (!$submit ? '' : |
|
| 1434 | + ("<div style='text-align: $spip_lang_right'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>")) |
|
| 1435 | + . "</div></form>\n"; |
|
| 1437 | 1436 | } |
| 1438 | 1437 | |
| 1439 | 1438 | /** |
@@ -1451,37 +1450,37 @@ discard block |
||
| 1451 | 1450 | * @return string |
| 1452 | 1451 | */ |
| 1453 | 1452 | function generer_form_action($script, $corps, $atts='', $public=false) { |
| 1454 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 1455 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 1456 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 1457 | - $h = (_DIR_RACINE AND !$public) |
|
| 1458 | - ? generer_url_ecrire(_request('exec')) |
|
| 1459 | - : generer_url_public(); |
|
| 1460 | - |
|
| 1461 | - return "\n<form action='" . |
|
| 1462 | - $h . |
|
| 1463 | - "'" . |
|
| 1464 | - $atts . |
|
| 1465 | - ">\n" . |
|
| 1466 | - "<div>" . |
|
| 1467 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 1468 | - $corps . |
|
| 1469 | - "</div></form>"; |
|
| 1453 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 1454 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 1455 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 1456 | + $h = (_DIR_RACINE AND !$public) |
|
| 1457 | + ? generer_url_ecrire(_request('exec')) |
|
| 1458 | + : generer_url_public(); |
|
| 1459 | + |
|
| 1460 | + return "\n<form action='" . |
|
| 1461 | + $h . |
|
| 1462 | + "'" . |
|
| 1463 | + $atts . |
|
| 1464 | + ">\n" . |
|
| 1465 | + "<div>" . |
|
| 1466 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 1467 | + $corps . |
|
| 1468 | + "</div></form>"; |
|
| 1470 | 1469 | } |
| 1471 | 1470 | |
| 1472 | 1471 | // http://doc.spip.org/@generer_url_action |
| 1473 | 1472 | function generer_url_action($script, $args="", $no_entities=false , $public = false) { |
| 1474 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 1475 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 1476 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 1477 | - $url = (_DIR_RACINE AND !$public) |
|
| 1478 | - ? generer_url_ecrire(_request('exec')) |
|
| 1479 | - : generer_url_public('','',false,false); |
|
| 1480 | - $url = parametre_url($url,'action',$script); |
|
| 1481 | - if ($args) $url .= quote_amp('&'.$args); |
|
| 1473 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 1474 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 1475 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 1476 | + $url = (_DIR_RACINE AND !$public) |
|
| 1477 | + ? generer_url_ecrire(_request('exec')) |
|
| 1478 | + : generer_url_public('','',false,false); |
|
| 1479 | + $url = parametre_url($url,'action',$script); |
|
| 1480 | + if ($args) $url .= quote_amp('&'.$args); |
|
| 1482 | 1481 | |
| 1483 | - if ($no_entities) $url = str_replace('&','&',$url); |
|
| 1484 | - return $url; |
|
| 1482 | + if ($no_entities) $url = str_replace('&','&',$url); |
|
| 1483 | + return $url; |
|
| 1485 | 1484 | } |
| 1486 | 1485 | |
| 1487 | 1486 | |
@@ -1494,8 +1493,8 @@ discard block |
||
| 1494 | 1493 | * @param string $ta |
| 1495 | 1494 | */ |
| 1496 | 1495 | function spip_initialisation($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) { |
| 1497 | - spip_initialisation_core($pi,$pa,$ti,$ta); |
|
| 1498 | - spip_initialisation_suite(); |
|
| 1496 | + spip_initialisation_core($pi,$pa,$ti,$ta); |
|
| 1497 | + spip_initialisation_suite(); |
|
| 1499 | 1498 | } |
| 1500 | 1499 | |
| 1501 | 1500 | /** |
@@ -1513,235 +1512,235 @@ discard block |
||
| 1513 | 1512 | * @param string $ta |
| 1514 | 1513 | */ |
| 1515 | 1514 | function spip_initialisation_core($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) { |
| 1516 | - static $too_late = 0; |
|
| 1517 | - if ($too_late++) return; |
|
| 1515 | + static $too_late = 0; |
|
| 1516 | + if ($too_late++) return; |
|
| 1518 | 1517 | |
| 1519 | - // Declaration des repertoires |
|
| 1518 | + // Declaration des repertoires |
|
| 1520 | 1519 | |
| 1521 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 1522 | - if (!defined('_DIR_PLUGINS')) define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 1520 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 1521 | + if (!defined('_DIR_PLUGINS')) define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 1523 | 1522 | |
| 1524 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 1525 | - if (!defined('_DIR_PLUGINS_DIST')) define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 1523 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 1524 | + if (!defined('_DIR_PLUGINS_DIST')) define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 1526 | 1525 | |
| 1527 | - // le nom du repertoire des librairies |
|
| 1528 | - if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 1526 | + // le nom du repertoire des librairies |
|
| 1527 | + if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 1529 | 1528 | |
| 1530 | - if (!defined('_DIR_IMG')) define('_DIR_IMG', $pa); |
|
| 1531 | - if (!defined('_DIR_LOGOS')) define('_DIR_LOGOS', $pa); |
|
| 1532 | - if (!defined('_DIR_IMG_ICONES')) define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 1533 | - |
|
| 1534 | - if (!defined('_DIR_DUMP')) define('_DIR_DUMP', $ti . "dump/"); |
|
| 1535 | - if (!defined('_DIR_SESSIONS')) define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 1536 | - if (!defined('_DIR_TRANSFERT')) define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 1537 | - if (!defined('_DIR_CACHE')) define('_DIR_CACHE', $ti . "cache/"); |
|
| 1538 | - if (!defined('_DIR_CACHE_XML')) define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 1539 | - if (!defined('_DIR_SKELS')) define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 1540 | - if (!defined('_DIR_AIDE')) define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 1541 | - if (!defined('_DIR_TMP')) define('_DIR_TMP', $ti); |
|
| 1542 | - |
|
| 1543 | - if (!defined('_DIR_VAR')) define('_DIR_VAR', $ta); |
|
| 1544 | - |
|
| 1545 | - if (!defined('_DIR_ETC')) define('_DIR_ETC', $pi); |
|
| 1546 | - if (!defined('_DIR_CONNECT')) define('_DIR_CONNECT', $pi); |
|
| 1547 | - if (!defined('_DIR_CHMOD')) define('_DIR_CHMOD', $pi); |
|
| 1548 | - |
|
| 1549 | - if (!isset($GLOBALS['test_dirs'])) |
|
| 1550 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 1551 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 1552 | - $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 1553 | - |
|
| 1554 | - // Declaration des fichiers |
|
| 1555 | - |
|
| 1556 | - if (!defined('_CACHE_PLUGINS_PATH')) define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 1557 | - if (!defined('_CACHE_PLUGINS_OPT')) define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 1558 | - if (!defined('_CACHE_PLUGINS_FCT')) define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 1559 | - if (!defined('_CACHE_PIPELINES')) define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 1560 | - if (!defined('_CACHE_CHEMIN')) define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 1561 | - |
|
| 1562 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 1563 | - if (!defined('_FILE_META')) define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 1564 | - if (!defined('_DIR_LOG')) define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 1565 | - if (!defined('_FILE_LOG')) define('_FILE_LOG', 'spip'); |
|
| 1566 | - if (!defined('_FILE_LOG_SUFFIX')) define('_FILE_LOG_SUFFIX', '.log'); |
|
| 1567 | - |
|
| 1568 | - // Le fichier de connexion a la base de donnees |
|
| 1569 | - // tient compte des anciennes versions (inc_connect...) |
|
| 1570 | - if (!defined('_FILE_CONNECT_INS')) define('_FILE_CONNECT_INS', 'connect'); |
|
| 1571 | - if (!defined('_FILE_CONNECT')) define('_FILE_CONNECT', |
|
| 1572 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 1573 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 1574 | - : false))); |
|
| 1575 | - |
|
| 1576 | - // Le fichier de reglages des droits |
|
| 1577 | - if (!defined('_FILE_CHMOD_INS')) define('_FILE_CHMOD_INS', 'chmod'); |
|
| 1578 | - if (!defined('_FILE_CHMOD')) define('_FILE_CHMOD', |
|
| 1579 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 1580 | - : false)); |
|
| 1581 | - |
|
| 1582 | - if (!defined('_FILE_LDAP')) define('_FILE_LDAP', 'ldap.php'); |
|
| 1583 | - |
|
| 1584 | - if (!defined('_FILE_TMP_SUFFIX')) define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 1585 | - if (!defined('_FILE_CONNECT_TMP')) define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 1586 | - if (!defined('_FILE_CHMOD_TMP')) define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 1587 | - |
|
| 1588 | - // Definition des droits d'acces en ecriture |
|
| 1589 | - if (!defined('_SPIP_CHMOD') AND _FILE_CHMOD) |
|
| 1590 | - include_once _FILE_CHMOD; |
|
| 1591 | - |
|
| 1592 | - // Se mefier des fichiers mal remplis! |
|
| 1593 | - if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', 0777); |
|
| 1594 | - |
|
| 1595 | - // Le charset par defaut lors de l'installation |
|
| 1596 | - if (!defined('_DEFAULT_CHARSET')) define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 1597 | - if (!defined('_ROOT_PLUGINS')) define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 1598 | - if (!defined('_ROOT_PLUGINS_DIST')) define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 1599 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE,'',_DIR_PLUGINS_SUPPL)); |
|
| 1600 | - |
|
| 1601 | - // La taille des Log |
|
| 1602 | - if (!defined('_MAX_LOG')) define('_MAX_LOG', 100); |
|
| 1603 | - |
|
| 1604 | - // Sommes-nous dans l'empire du Mal ? |
|
| 1605 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 1606 | - if (strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false){ |
|
| 1607 | - if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', 'windows'); |
|
| 1608 | - if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1609 | - } |
|
| 1610 | - else { |
|
| 1611 | - if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', ''); |
|
| 1612 | - if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1613 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 1614 | - } |
|
| 1615 | - |
|
| 1616 | - // Langue par defaut |
|
| 1617 | - if (!defined('_LANGUE_PAR_DEFAUT')) define('_LANGUE_PAR_DEFAUT','fr'); |
|
| 1618 | - |
|
| 1619 | - // PHP_VERSION_ID dispo depuis PHP 5.2.7 |
|
| 1620 | - if (!defined('PHP_VERSION_ID')) { |
|
| 1621 | - $version = explode('.',PHP_VERSION); |
|
| 1622 | - define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); |
|
| 1623 | - } |
|
| 1624 | - |
|
| 1625 | - // |
|
| 1626 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 1627 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 1628 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 1629 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 1630 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1631 | - |
|
| 1632 | - // charger tout de suite le path et son cache |
|
| 1633 | - load_path_cache(); |
|
| 1634 | - |
|
| 1635 | - // *********** traiter les variables ************ |
|
| 1636 | - |
|
| 1637 | - // |
|
| 1638 | - // Securite |
|
| 1639 | - // |
|
| 1640 | - |
|
| 1641 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 1642 | - if (isset($_REQUEST['GLOBALS'])) die(); |
|
| 1643 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 1644 | - spip_desinfecte($_GET); |
|
| 1645 | - spip_desinfecte($_POST); |
|
| 1646 | - spip_desinfecte($_COOKIE); |
|
| 1647 | - spip_desinfecte($_REQUEST); |
|
| 1648 | - |
|
| 1649 | - // Par ailleurs on ne veut pas de magic_quotes au cours de l'execution |
|
| 1650 | - if (PHP_VERSION_ID<50300) { |
|
| 1651 | - @set_magic_quotes_runtime(0); |
|
| 1652 | - } |
|
| 1653 | - |
|
| 1654 | - // Si les variables sont passees en global par le serveur, |
|
| 1655 | - // il faut faire quelques verifications de base |
|
| 1656 | - $avertir_register_globals = false; |
|
| 1657 | - if (test_valeur_serveur(@ini_get('register_globals'))) { |
|
| 1658 | - // ne pas desinfecter les globales en profondeur car elle contient aussi les |
|
| 1659 | - // precedentes, qui seraient desinfectees 2 fois. |
|
| 1660 | - spip_desinfecte($GLOBALS,false); |
|
| 1661 | - if (include_spip('inc/php3')) |
|
| 1662 | - spip_register_globals(true); |
|
| 1663 | - |
|
| 1664 | - $avertir_register_globals = true; |
|
| 1665 | - } |
|
| 1666 | - |
|
| 1667 | - // appliquer le cookie_prefix |
|
| 1668 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 1669 | - include_spip('inc/cookie'); |
|
| 1670 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 1671 | - } |
|
| 1672 | - |
|
| 1673 | - // |
|
| 1674 | - // Capacites php (en fonction de la version) |
|
| 1675 | - // |
|
| 1676 | - $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 1677 | - && function_exists("ini_get") |
|
| 1678 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 1679 | - $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 1680 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 1681 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 1682 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 1683 | - |
|
| 1684 | - |
|
| 1685 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 1686 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 1687 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 1688 | - } else { |
|
| 1689 | - $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; |
|
| 1690 | - if ($_SERVER['QUERY_STRING'] |
|
| 1691 | - AND !strpos($_SERVER['REQUEST_URI'], '?')) |
|
| 1692 | - $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1693 | - } |
|
| 1694 | - |
|
| 1695 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 1696 | - if (!defined('_RENOUVELLE_ALEA')) define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 1697 | - |
|
| 1698 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 1699 | - // charge aussi effacer_meta et ecrire_meta |
|
| 1700 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 1701 | - $inc_meta(); |
|
| 1702 | - |
|
| 1703 | - // on a pas pu le faire plus tot |
|
| 1704 | - if ($avertir_register_globals) |
|
| 1705 | - avertir_auteurs("register_globals",_L("Problème de sécurité : register_globals=on; dans php.ini à corriger.")); |
|
| 1706 | - |
|
| 1707 | - // nombre de repertoires depuis la racine |
|
| 1708 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 1709 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 1710 | - // le calcul est faux) |
|
| 1711 | - if (!_DIR_RESTREINT) |
|
| 1712 | - $GLOBALS['profondeur_url'] = 1; |
|
| 1713 | - else { |
|
| 1714 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 1715 | - $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 1716 | - if (!$uri_ref |
|
| 1717 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 1718 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 1719 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 1720 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 1721 | - OR $ti!==_NOM_TEMPORAIRES_INACCESSIBLES){ |
|
| 1722 | - |
|
| 1723 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1724 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 1725 | - $uri_ref = $uri_ref['path'].'/'; |
|
| 1726 | - } |
|
| 1727 | - else |
|
| 1728 | - $uri_ref = ""; |
|
| 1729 | - } |
|
| 1730 | - if (!$uri OR !$uri_ref) |
|
| 1731 | - $GLOBALS['profondeur_url'] = 0; |
|
| 1732 | - else { |
|
| 1733 | - $GLOBALS['profondeur_url'] = max(0, |
|
| 1734 | - substr_count($uri[0], '/') |
|
| 1735 | - - substr_count($uri_ref,'/')); |
|
| 1736 | - } |
|
| 1737 | - } |
|
| 1738 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 1739 | - if (_FILE_CONNECT) { |
|
| 1740 | - if (verifier_visiteur()=='0minirezo' |
|
| 1741 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 1742 | - AND !isset($_COOKIE['spip_admin'])) |
|
| 1743 | - clear_path_cache(); |
|
| 1744 | - } |
|
| 1529 | + if (!defined('_DIR_IMG')) define('_DIR_IMG', $pa); |
|
| 1530 | + if (!defined('_DIR_LOGOS')) define('_DIR_LOGOS', $pa); |
|
| 1531 | + if (!defined('_DIR_IMG_ICONES')) define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 1532 | + |
|
| 1533 | + if (!defined('_DIR_DUMP')) define('_DIR_DUMP', $ti . "dump/"); |
|
| 1534 | + if (!defined('_DIR_SESSIONS')) define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 1535 | + if (!defined('_DIR_TRANSFERT')) define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 1536 | + if (!defined('_DIR_CACHE')) define('_DIR_CACHE', $ti . "cache/"); |
|
| 1537 | + if (!defined('_DIR_CACHE_XML')) define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 1538 | + if (!defined('_DIR_SKELS')) define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 1539 | + if (!defined('_DIR_AIDE')) define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 1540 | + if (!defined('_DIR_TMP')) define('_DIR_TMP', $ti); |
|
| 1541 | + |
|
| 1542 | + if (!defined('_DIR_VAR')) define('_DIR_VAR', $ta); |
|
| 1543 | + |
|
| 1544 | + if (!defined('_DIR_ETC')) define('_DIR_ETC', $pi); |
|
| 1545 | + if (!defined('_DIR_CONNECT')) define('_DIR_CONNECT', $pi); |
|
| 1546 | + if (!defined('_DIR_CHMOD')) define('_DIR_CHMOD', $pi); |
|
| 1547 | + |
|
| 1548 | + if (!isset($GLOBALS['test_dirs'])) |
|
| 1549 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 1550 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 1551 | + $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 1552 | + |
|
| 1553 | + // Declaration des fichiers |
|
| 1554 | + |
|
| 1555 | + if (!defined('_CACHE_PLUGINS_PATH')) define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 1556 | + if (!defined('_CACHE_PLUGINS_OPT')) define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 1557 | + if (!defined('_CACHE_PLUGINS_FCT')) define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 1558 | + if (!defined('_CACHE_PIPELINES')) define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 1559 | + if (!defined('_CACHE_CHEMIN')) define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 1560 | + |
|
| 1561 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 1562 | + if (!defined('_FILE_META')) define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 1563 | + if (!defined('_DIR_LOG')) define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 1564 | + if (!defined('_FILE_LOG')) define('_FILE_LOG', 'spip'); |
|
| 1565 | + if (!defined('_FILE_LOG_SUFFIX')) define('_FILE_LOG_SUFFIX', '.log'); |
|
| 1566 | + |
|
| 1567 | + // Le fichier de connexion a la base de donnees |
|
| 1568 | + // tient compte des anciennes versions (inc_connect...) |
|
| 1569 | + if (!defined('_FILE_CONNECT_INS')) define('_FILE_CONNECT_INS', 'connect'); |
|
| 1570 | + if (!defined('_FILE_CONNECT')) define('_FILE_CONNECT', |
|
| 1571 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 1572 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 1573 | + : false))); |
|
| 1574 | + |
|
| 1575 | + // Le fichier de reglages des droits |
|
| 1576 | + if (!defined('_FILE_CHMOD_INS')) define('_FILE_CHMOD_INS', 'chmod'); |
|
| 1577 | + if (!defined('_FILE_CHMOD')) define('_FILE_CHMOD', |
|
| 1578 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 1579 | + : false)); |
|
| 1580 | + |
|
| 1581 | + if (!defined('_FILE_LDAP')) define('_FILE_LDAP', 'ldap.php'); |
|
| 1582 | + |
|
| 1583 | + if (!defined('_FILE_TMP_SUFFIX')) define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 1584 | + if (!defined('_FILE_CONNECT_TMP')) define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 1585 | + if (!defined('_FILE_CHMOD_TMP')) define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 1586 | + |
|
| 1587 | + // Definition des droits d'acces en ecriture |
|
| 1588 | + if (!defined('_SPIP_CHMOD') AND _FILE_CHMOD) |
|
| 1589 | + include_once _FILE_CHMOD; |
|
| 1590 | + |
|
| 1591 | + // Se mefier des fichiers mal remplis! |
|
| 1592 | + if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', 0777); |
|
| 1593 | + |
|
| 1594 | + // Le charset par defaut lors de l'installation |
|
| 1595 | + if (!defined('_DEFAULT_CHARSET')) define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 1596 | + if (!defined('_ROOT_PLUGINS')) define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 1597 | + if (!defined('_ROOT_PLUGINS_DIST')) define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 1598 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE,'',_DIR_PLUGINS_SUPPL)); |
|
| 1599 | + |
|
| 1600 | + // La taille des Log |
|
| 1601 | + if (!defined('_MAX_LOG')) define('_MAX_LOG', 100); |
|
| 1602 | + |
|
| 1603 | + // Sommes-nous dans l'empire du Mal ? |
|
| 1604 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 1605 | + if (strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false){ |
|
| 1606 | + if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', 'windows'); |
|
| 1607 | + if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1608 | + } |
|
| 1609 | + else { |
|
| 1610 | + if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', ''); |
|
| 1611 | + if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1612 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + // Langue par defaut |
|
| 1616 | + if (!defined('_LANGUE_PAR_DEFAUT')) define('_LANGUE_PAR_DEFAUT','fr'); |
|
| 1617 | + |
|
| 1618 | + // PHP_VERSION_ID dispo depuis PHP 5.2.7 |
|
| 1619 | + if (!defined('PHP_VERSION_ID')) { |
|
| 1620 | + $version = explode('.',PHP_VERSION); |
|
| 1621 | + define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); |
|
| 1622 | + } |
|
| 1623 | + |
|
| 1624 | + // |
|
| 1625 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 1626 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 1627 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 1628 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 1629 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1630 | + |
|
| 1631 | + // charger tout de suite le path et son cache |
|
| 1632 | + load_path_cache(); |
|
| 1633 | + |
|
| 1634 | + // *********** traiter les variables ************ |
|
| 1635 | + |
|
| 1636 | + // |
|
| 1637 | + // Securite |
|
| 1638 | + // |
|
| 1639 | + |
|
| 1640 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 1641 | + if (isset($_REQUEST['GLOBALS'])) die(); |
|
| 1642 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 1643 | + spip_desinfecte($_GET); |
|
| 1644 | + spip_desinfecte($_POST); |
|
| 1645 | + spip_desinfecte($_COOKIE); |
|
| 1646 | + spip_desinfecte($_REQUEST); |
|
| 1647 | + |
|
| 1648 | + // Par ailleurs on ne veut pas de magic_quotes au cours de l'execution |
|
| 1649 | + if (PHP_VERSION_ID<50300) { |
|
| 1650 | + @set_magic_quotes_runtime(0); |
|
| 1651 | + } |
|
| 1652 | + |
|
| 1653 | + // Si les variables sont passees en global par le serveur, |
|
| 1654 | + // il faut faire quelques verifications de base |
|
| 1655 | + $avertir_register_globals = false; |
|
| 1656 | + if (test_valeur_serveur(@ini_get('register_globals'))) { |
|
| 1657 | + // ne pas desinfecter les globales en profondeur car elle contient aussi les |
|
| 1658 | + // precedentes, qui seraient desinfectees 2 fois. |
|
| 1659 | + spip_desinfecte($GLOBALS,false); |
|
| 1660 | + if (include_spip('inc/php3')) |
|
| 1661 | + spip_register_globals(true); |
|
| 1662 | + |
|
| 1663 | + $avertir_register_globals = true; |
|
| 1664 | + } |
|
| 1665 | + |
|
| 1666 | + // appliquer le cookie_prefix |
|
| 1667 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 1668 | + include_spip('inc/cookie'); |
|
| 1669 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 1670 | + } |
|
| 1671 | + |
|
| 1672 | + // |
|
| 1673 | + // Capacites php (en fonction de la version) |
|
| 1674 | + // |
|
| 1675 | + $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 1676 | + && function_exists("ini_get") |
|
| 1677 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 1678 | + $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 1679 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 1680 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 1681 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 1682 | + |
|
| 1683 | + |
|
| 1684 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 1685 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 1686 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 1687 | + } else { |
|
| 1688 | + $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; |
|
| 1689 | + if ($_SERVER['QUERY_STRING'] |
|
| 1690 | + AND !strpos($_SERVER['REQUEST_URI'], '?')) |
|
| 1691 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1692 | + } |
|
| 1693 | + |
|
| 1694 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 1695 | + if (!defined('_RENOUVELLE_ALEA')) define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 1696 | + |
|
| 1697 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 1698 | + // charge aussi effacer_meta et ecrire_meta |
|
| 1699 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 1700 | + $inc_meta(); |
|
| 1701 | + |
|
| 1702 | + // on a pas pu le faire plus tot |
|
| 1703 | + if ($avertir_register_globals) |
|
| 1704 | + avertir_auteurs("register_globals",_L("Problème de sécurité : register_globals=on; dans php.ini à corriger.")); |
|
| 1705 | + |
|
| 1706 | + // nombre de repertoires depuis la racine |
|
| 1707 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 1708 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 1709 | + // le calcul est faux) |
|
| 1710 | + if (!_DIR_RESTREINT) |
|
| 1711 | + $GLOBALS['profondeur_url'] = 1; |
|
| 1712 | + else { |
|
| 1713 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 1714 | + $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 1715 | + if (!$uri_ref |
|
| 1716 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 1717 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 1718 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 1719 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 1720 | + OR $ti!==_NOM_TEMPORAIRES_INACCESSIBLES){ |
|
| 1721 | + |
|
| 1722 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1723 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 1724 | + $uri_ref = $uri_ref['path'].'/'; |
|
| 1725 | + } |
|
| 1726 | + else |
|
| 1727 | + $uri_ref = ""; |
|
| 1728 | + } |
|
| 1729 | + if (!$uri OR !$uri_ref) |
|
| 1730 | + $GLOBALS['profondeur_url'] = 0; |
|
| 1731 | + else { |
|
| 1732 | + $GLOBALS['profondeur_url'] = max(0, |
|
| 1733 | + substr_count($uri[0], '/') |
|
| 1734 | + - substr_count($uri_ref,'/')); |
|
| 1735 | + } |
|
| 1736 | + } |
|
| 1737 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 1738 | + if (_FILE_CONNECT) { |
|
| 1739 | + if (verifier_visiteur()=='0minirezo' |
|
| 1740 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 1741 | + AND !isset($_COOKIE['spip_admin'])) |
|
| 1742 | + clear_path_cache(); |
|
| 1743 | + } |
|
| 1745 | 1744 | |
| 1746 | 1745 | } |
| 1747 | 1746 | |
@@ -1751,205 +1750,205 @@ discard block |
||
| 1751 | 1750 | * |
| 1752 | 1751 | */ |
| 1753 | 1752 | function spip_initialisation_suite() { |
| 1754 | - static $too_late = 0; |
|
| 1755 | - if ($too_late++) return; |
|
| 1753 | + static $too_late = 0; |
|
| 1754 | + if ($too_late++) return; |
|
| 1756 | 1755 | |
| 1757 | - // taille mini des login |
|
| 1758 | - if (!defined('_LOGIN_TROP_COURT')) define('_LOGIN_TROP_COURT', 4); |
|
| 1756 | + // taille mini des login |
|
| 1757 | + if (!defined('_LOGIN_TROP_COURT')) define('_LOGIN_TROP_COURT', 4); |
|
| 1759 | 1758 | |
| 1760 | - // la taille maxi des logos (0 : pas de limite) |
|
| 1761 | - if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 1762 | - if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 1763 | - if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 1759 | + // la taille maxi des logos (0 : pas de limite) |
|
| 1760 | + if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 1761 | + if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 1762 | + if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 1764 | 1763 | |
| 1765 | - if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 1764 | + if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 1766 | 1765 | |
| 1767 | - if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 1768 | - if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 1769 | - if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 1770 | - if (!defined('_PASS_LONGUEUR_MINI')) define('_PASS_LONGUEUR_MINI',6); |
|
| 1766 | + if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 1767 | + if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 1768 | + if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 1769 | + if (!defined('_PASS_LONGUEUR_MINI')) define('_PASS_LONGUEUR_MINI',6); |
|
| 1771 | 1770 | |
| 1772 | 1771 | |
| 1773 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 1772 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 1774 | 1773 | if (!defined('_IMG_QUALITE')) define('_IMG_QUALITE', 85); # valeur par defaut |
| 1775 | 1774 | if (!defined('_IMG_GD_QUALITE')) define('_IMG_GD_QUALITE', _IMG_QUALITE); # surcharge pour la lib GD |
| 1776 | 1775 | if (!defined('_IMG_CONVERT_QUALITE')) define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); # surcharge pour imagick en ligne de commande |
| 1777 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 1776 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 1778 | 1777 | if (!defined('_IMG_IMAGICK_QUALITE')) define('_IMG_IMAGICK_QUALITE', 75); # surcharge pour imagick en PHP |
| 1779 | 1778 | |
| 1780 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) define('_COPIE_LOCALE_MAX_SIZE',16777216); // poids en octet |
|
| 1781 | - |
|
| 1782 | - // qq chaines standard |
|
| 1783 | - if (!defined('_ACCESS_FILE_NAME')) define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 1784 | - if (!defined('_AUTH_USER_FILE')) define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 1785 | - if (!defined('_SPIP_DUMP')) define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 1786 | - if (!defined('_CACHE_RUBRIQUES')) define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 1787 | - if (!defined('_CACHE_RUBRIQUES_MAX')) define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 1788 | - |
|
| 1789 | - if (!defined('_EXTENSION_SQUELETTES')) define('_EXTENSION_SQUELETTES', 'html'); |
|
| 1790 | - |
|
| 1791 | - if (!defined('_DOCTYPE_ECRIRE')) define('_DOCTYPE_ECRIRE', |
|
| 1792 | - // "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n"); |
|
| 1793 | - //"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n"); |
|
| 1794 | - //"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n"); |
|
| 1795 | - // "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 //EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>\n"); |
|
| 1796 | - "<!DOCTYPE html>\n"); |
|
| 1797 | - if (!defined('_DOCTYPE_AIDE')) define('_DOCTYPE_AIDE', |
|
| 1798 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 1799 | - |
|
| 1800 | - // L'adresse de base du site ; on peut mettre '' si la racine est geree par |
|
| 1801 | - // le script de l'espace public, alias index.php |
|
| 1802 | - if (!defined('_SPIP_SCRIPT')) define('_SPIP_SCRIPT', 'spip.php'); |
|
| 1803 | - // argument page, personalisable en cas de conflit avec un autre script |
|
| 1804 | - if (!defined('_SPIP_PAGE')) define('_SPIP_PAGE', 'page'); |
|
| 1805 | - |
|
| 1806 | - // le script de l'espace prive |
|
| 1807 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 1808 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 1809 | - // meme pb sur thttpd cf. http://forum.spip.org/fr_184153.html |
|
| 1810 | - |
|
| 1811 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) define('_SPIP_ECRIRE_SCRIPT', // true ? #decommenter ici et commenter la |
|
| 1812 | - preg_match(',IIS|thttpd,',$_SERVER['SERVER_SOFTWARE']) ? |
|
| 1813 | - 'index.php' : ''); |
|
| 1814 | - |
|
| 1815 | - |
|
| 1816 | - if (!defined('_SPIP_AJAX')) |
|
| 1817 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 1818 | - ? 1 |
|
| 1819 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 1820 | - |
|
| 1821 | - // La requete est-elle en ajax ? |
|
| 1822 | - if (!defined('_AJAX')) define('_AJAX', |
|
| 1823 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 1824 | - OR @$_REQUEST['var_ajax_redir'] # redirection 302 apres ajax jQuery |
|
| 1825 | - OR @$_REQUEST['var_ajaxcharset'] # compat ascendante pour plugins |
|
| 1826 | - OR @$_REQUEST['var_ajax'] # forms ajax & inclure ajax de spip |
|
| 1827 | - ) |
|
| 1828 | - AND !@$_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 |
|
| 1829 | - ); |
|
| 1830 | - |
|
| 1831 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 1832 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 1833 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 1834 | - if (!defined('_IMG_GD_MAX_PIXELS')) define('_IMG_GD_MAX_PIXELS', |
|
| 1835 | - (isset($GLOBALS['meta']['max_taille_vignettes'])&&$GLOBALS['meta']['max_taille_vignettes']<5500000) |
|
| 1836 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 1837 | - : 0); |
|
| 1838 | - |
|
| 1839 | - if (!defined('_MEMORY_LIMIT_MIN')) define('_MEMORY_LIMIT_MIN',10); // en Mo |
|
| 1840 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 1841 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 1842 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 1843 | - if (test_espace_prive() AND _MEMORY_LIMIT_MIN>8){ |
|
| 1844 | - if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 1845 | - $unit = strtolower(substr($memory,strlen($memory/1),1)); |
|
| 1846 | - switch($unit) { |
|
| 1847 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 1848 | - case 'g': $memory *= 1024; |
|
| 1849 | - case 'm': $memory *= 1024; |
|
| 1850 | - case 'k': $memory *= 1024; |
|
| 1851 | - } |
|
| 1852 | - if ($memory<_MEMORY_LIMIT_MIN*1024*1024){ |
|
| 1853 | - ini_set('memory_limit',$m=_MEMORY_LIMIT_MIN.'M'); |
|
| 1854 | - if (trim(ini_get('memory_limit'))!=$m){ |
|
| 1855 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1856 | - } |
|
| 1857 | - } |
|
| 1858 | - } |
|
| 1859 | - else |
|
| 1860 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1861 | - } |
|
| 1862 | - // Protocoles a normaliser dans les chaines de langues |
|
| 1863 | - if (!defined('_PROTOCOLES_STD')) |
|
| 1864 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 1865 | - |
|
| 1866 | - init_var_mode(); |
|
| 1779 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) define('_COPIE_LOCALE_MAX_SIZE',16777216); // poids en octet |
|
| 1780 | + |
|
| 1781 | + // qq chaines standard |
|
| 1782 | + if (!defined('_ACCESS_FILE_NAME')) define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 1783 | + if (!defined('_AUTH_USER_FILE')) define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 1784 | + if (!defined('_SPIP_DUMP')) define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 1785 | + if (!defined('_CACHE_RUBRIQUES')) define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 1786 | + if (!defined('_CACHE_RUBRIQUES_MAX')) define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 1787 | + |
|
| 1788 | + if (!defined('_EXTENSION_SQUELETTES')) define('_EXTENSION_SQUELETTES', 'html'); |
|
| 1789 | + |
|
| 1790 | + if (!defined('_DOCTYPE_ECRIRE')) define('_DOCTYPE_ECRIRE', |
|
| 1791 | + // "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n"); |
|
| 1792 | + //"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n"); |
|
| 1793 | + //"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n"); |
|
| 1794 | + // "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 //EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>\n"); |
|
| 1795 | + "<!DOCTYPE html>\n"); |
|
| 1796 | + if (!defined('_DOCTYPE_AIDE')) define('_DOCTYPE_AIDE', |
|
| 1797 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 1798 | + |
|
| 1799 | + // L'adresse de base du site ; on peut mettre '' si la racine est geree par |
|
| 1800 | + // le script de l'espace public, alias index.php |
|
| 1801 | + if (!defined('_SPIP_SCRIPT')) define('_SPIP_SCRIPT', 'spip.php'); |
|
| 1802 | + // argument page, personalisable en cas de conflit avec un autre script |
|
| 1803 | + if (!defined('_SPIP_PAGE')) define('_SPIP_PAGE', 'page'); |
|
| 1804 | + |
|
| 1805 | + // le script de l'espace prive |
|
| 1806 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 1807 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 1808 | + // meme pb sur thttpd cf. http://forum.spip.org/fr_184153.html |
|
| 1809 | + |
|
| 1810 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) define('_SPIP_ECRIRE_SCRIPT', // true ? #decommenter ici et commenter la |
|
| 1811 | + preg_match(',IIS|thttpd,',$_SERVER['SERVER_SOFTWARE']) ? |
|
| 1812 | + 'index.php' : ''); |
|
| 1813 | + |
|
| 1814 | + |
|
| 1815 | + if (!defined('_SPIP_AJAX')) |
|
| 1816 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 1817 | + ? 1 |
|
| 1818 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 1819 | + |
|
| 1820 | + // La requete est-elle en ajax ? |
|
| 1821 | + if (!defined('_AJAX')) define('_AJAX', |
|
| 1822 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 1823 | + OR @$_REQUEST['var_ajax_redir'] # redirection 302 apres ajax jQuery |
|
| 1824 | + OR @$_REQUEST['var_ajaxcharset'] # compat ascendante pour plugins |
|
| 1825 | + OR @$_REQUEST['var_ajax'] # forms ajax & inclure ajax de spip |
|
| 1826 | + ) |
|
| 1827 | + AND !@$_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 |
|
| 1828 | + ); |
|
| 1829 | + |
|
| 1830 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 1831 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 1832 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 1833 | + if (!defined('_IMG_GD_MAX_PIXELS')) define('_IMG_GD_MAX_PIXELS', |
|
| 1834 | + (isset($GLOBALS['meta']['max_taille_vignettes'])&&$GLOBALS['meta']['max_taille_vignettes']<5500000) |
|
| 1835 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 1836 | + : 0); |
|
| 1837 | + |
|
| 1838 | + if (!defined('_MEMORY_LIMIT_MIN')) define('_MEMORY_LIMIT_MIN',10); // en Mo |
|
| 1839 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 1840 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 1841 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 1842 | + if (test_espace_prive() AND _MEMORY_LIMIT_MIN>8){ |
|
| 1843 | + if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 1844 | + $unit = strtolower(substr($memory,strlen($memory/1),1)); |
|
| 1845 | + switch($unit) { |
|
| 1846 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 1847 | + case 'g': $memory *= 1024; |
|
| 1848 | + case 'm': $memory *= 1024; |
|
| 1849 | + case 'k': $memory *= 1024; |
|
| 1850 | + } |
|
| 1851 | + if ($memory<_MEMORY_LIMIT_MIN*1024*1024){ |
|
| 1852 | + ini_set('memory_limit',$m=_MEMORY_LIMIT_MIN.'M'); |
|
| 1853 | + if (trim(ini_get('memory_limit'))!=$m){ |
|
| 1854 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1855 | + } |
|
| 1856 | + } |
|
| 1857 | + } |
|
| 1858 | + else |
|
| 1859 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1860 | + } |
|
| 1861 | + // Protocoles a normaliser dans les chaines de langues |
|
| 1862 | + if (!defined('_PROTOCOLES_STD')) |
|
| 1863 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 1864 | + |
|
| 1865 | + init_var_mode(); |
|
| 1867 | 1866 | } |
| 1868 | 1867 | |
| 1869 | 1868 | // Reperer les variables d'URL qui conditionnent la perennite du cache, des urls |
| 1870 | 1869 | // ou d'autres petit caches (trouver_table, css et js compactes ...) |
| 1871 | 1870 | // http://doc.spip.org/@init_var_mode |
| 1872 | 1871 | function init_var_mode(){ |
| 1873 | - static $done = false; |
|
| 1874 | - if (!$done) { |
|
| 1875 | - |
|
| 1876 | - if (isset($_GET['var_mode'])) { |
|
| 1877 | - // tout le monde peut calcul/recalcul |
|
| 1878 | - if ($_GET['var_mode'] == 'calcul' |
|
| 1879 | - OR $_GET['var_mode'] == 'recalcul') { |
|
| 1880 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 1881 | - } |
|
| 1882 | - // preview, debug, blocs, urls et images necessitent une autorisation |
|
| 1883 | - else if (in_array($_GET['var_mode'],array('preview','debug','inclure','urls','images','traduction'))) { |
|
| 1884 | - include_spip('inc/autoriser'); |
|
| 1885 | - if (autoriser( |
|
| 1886 | - ($_GET['var_mode'] == 'preview') |
|
| 1887 | - ? 'previsualiser' |
|
| 1888 | - : 'debug' |
|
| 1889 | - )) { |
|
| 1890 | - switch($_GET['var_mode']){ |
|
| 1891 | - case 'traduction': |
|
| 1892 | - // forcer le calcul pour passer dans traduire |
|
| 1893 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1894 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 1895 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1896 | - break; |
|
| 1897 | - case 'preview': |
|
| 1898 | - // basculer sur les criteres de preview dans les boucles |
|
| 1899 | - if (!defined('_VAR_PREVIEW')) define('_VAR_PREVIEW',true); |
|
| 1900 | - // forcer le calcul |
|
| 1901 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1902 | - // et ne pas enregistrer de cache |
|
| 1903 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1904 | - break; |
|
| 1905 | - case 'inclure': |
|
| 1906 | - // forcer le compilo et ignorer les caches existants |
|
| 1907 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1908 | - if (!defined('_VAR_INCLURE')) define('_VAR_INCLURE',true); |
|
| 1909 | - // et ne pas enregistrer de cache |
|
| 1910 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1911 | - break; |
|
| 1912 | - case 'urls': |
|
| 1913 | - // forcer le compilo et ignorer les caches existants |
|
| 1914 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1915 | - if (!defined('_VAR_URLS')) define('_VAR_URLS',true); |
|
| 1916 | - break; |
|
| 1917 | - case 'images': |
|
| 1918 | - // forcer le compilo et ignorer les caches existants |
|
| 1919 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1920 | - // indiquer qu'on doit recalculer les images |
|
| 1921 | - if (!defined('_VAR_IMAGES')) define('_VAR_IMAGES',true); |
|
| 1922 | - break; |
|
| 1923 | - case 'debug': |
|
| 1924 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','debug'); |
|
| 1925 | - // et ne pas enregistrer de cache |
|
| 1926 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1927 | - break; |
|
| 1928 | - default : |
|
| 1929 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 1930 | - break; |
|
| 1931 | - } |
|
| 1932 | - if (isset($GLOBALS['visiteur_session']['nom'])) |
|
| 1933 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 1934 | - . " "._VAR_MODE); |
|
| 1935 | - } |
|
| 1936 | - // pas autorise ? |
|
| 1937 | - else { |
|
| 1938 | - // si on n'est pas connecte on se redirige |
|
| 1939 | - if (!$GLOBALS['visiteur_session']) { |
|
| 1940 | - include_spip('inc/headers'); |
|
| 1941 | - redirige_par_entete(generer_url_public('login', |
|
| 1942 | - 'url='.rawurlencode( |
|
| 1943 | - parametre_url(self(), 'var_mode', $_GET['var_mode'], '&') |
|
| 1944 | - ), true)); |
|
| 1945 | - } |
|
| 1946 | - // sinon tant pis |
|
| 1947 | - } |
|
| 1948 | - } |
|
| 1949 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',false); |
|
| 1950 | - } |
|
| 1951 | - $done = true; |
|
| 1952 | - } |
|
| 1872 | + static $done = false; |
|
| 1873 | + if (!$done) { |
|
| 1874 | + |
|
| 1875 | + if (isset($_GET['var_mode'])) { |
|
| 1876 | + // tout le monde peut calcul/recalcul |
|
| 1877 | + if ($_GET['var_mode'] == 'calcul' |
|
| 1878 | + OR $_GET['var_mode'] == 'recalcul') { |
|
| 1879 | + if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 1880 | + } |
|
| 1881 | + // preview, debug, blocs, urls et images necessitent une autorisation |
|
| 1882 | + else if (in_array($_GET['var_mode'],array('preview','debug','inclure','urls','images','traduction'))) { |
|
| 1883 | + include_spip('inc/autoriser'); |
|
| 1884 | + if (autoriser( |
|
| 1885 | + ($_GET['var_mode'] == 'preview') |
|
| 1886 | + ? 'previsualiser' |
|
| 1887 | + : 'debug' |
|
| 1888 | + )) { |
|
| 1889 | + switch($_GET['var_mode']){ |
|
| 1890 | + case 'traduction': |
|
| 1891 | + // forcer le calcul pour passer dans traduire |
|
| 1892 | + if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1893 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 1894 | + if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1895 | + break; |
|
| 1896 | + case 'preview': |
|
| 1897 | + // basculer sur les criteres de preview dans les boucles |
|
| 1898 | + if (!defined('_VAR_PREVIEW')) define('_VAR_PREVIEW',true); |
|
| 1899 | + // forcer le calcul |
|
| 1900 | + if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1901 | + // et ne pas enregistrer de cache |
|
| 1902 | + if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1903 | + break; |
|
| 1904 | + case 'inclure': |
|
| 1905 | + // forcer le compilo et ignorer les caches existants |
|
| 1906 | + if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1907 | + if (!defined('_VAR_INCLURE')) define('_VAR_INCLURE',true); |
|
| 1908 | + // et ne pas enregistrer de cache |
|
| 1909 | + if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1910 | + break; |
|
| 1911 | + case 'urls': |
|
| 1912 | + // forcer le compilo et ignorer les caches existants |
|
| 1913 | + if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1914 | + if (!defined('_VAR_URLS')) define('_VAR_URLS',true); |
|
| 1915 | + break; |
|
| 1916 | + case 'images': |
|
| 1917 | + // forcer le compilo et ignorer les caches existants |
|
| 1918 | + if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1919 | + // indiquer qu'on doit recalculer les images |
|
| 1920 | + if (!defined('_VAR_IMAGES')) define('_VAR_IMAGES',true); |
|
| 1921 | + break; |
|
| 1922 | + case 'debug': |
|
| 1923 | + if (!defined('_VAR_MODE')) define('_VAR_MODE','debug'); |
|
| 1924 | + // et ne pas enregistrer de cache |
|
| 1925 | + if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1926 | + break; |
|
| 1927 | + default : |
|
| 1928 | + if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 1929 | + break; |
|
| 1930 | + } |
|
| 1931 | + if (isset($GLOBALS['visiteur_session']['nom'])) |
|
| 1932 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 1933 | + . " "._VAR_MODE); |
|
| 1934 | + } |
|
| 1935 | + // pas autorise ? |
|
| 1936 | + else { |
|
| 1937 | + // si on n'est pas connecte on se redirige |
|
| 1938 | + if (!$GLOBALS['visiteur_session']) { |
|
| 1939 | + include_spip('inc/headers'); |
|
| 1940 | + redirige_par_entete(generer_url_public('login', |
|
| 1941 | + 'url='.rawurlencode( |
|
| 1942 | + parametre_url(self(), 'var_mode', $_GET['var_mode'], '&') |
|
| 1943 | + ), true)); |
|
| 1944 | + } |
|
| 1945 | + // sinon tant pis |
|
| 1946 | + } |
|
| 1947 | + } |
|
| 1948 | + if (!defined('_VAR_MODE')) define('_VAR_MODE',false); |
|
| 1949 | + } |
|
| 1950 | + $done = true; |
|
| 1951 | + } |
|
| 1953 | 1952 | } |
| 1954 | 1953 | |
| 1955 | 1954 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
@@ -1957,84 +1956,84 @@ discard block |
||
| 1957 | 1956 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 1958 | 1957 | // http://doc.spip.org/@spip_desinfecte |
| 1959 | 1958 | function spip_desinfecte(&$t,$deep = true) { |
| 1960 | - static $magic_quotes; |
|
| 1961 | - if (!isset($magic_quotes)) |
|
| 1962 | - $magic_quotes = @get_magic_quotes_gpc(); |
|
| 1963 | - |
|
| 1964 | - foreach ($t as $key => $val) { |
|
| 1965 | - if (is_string($t[$key])) { |
|
| 1966 | - if ($magic_quotes) |
|
| 1967 | - $t[$key] = stripslashes($t[$key]); |
|
| 1968 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 1969 | - } |
|
| 1970 | - // traiter aussi les "texte_plus" de article_edit |
|
| 1971 | - else if ($deep AND is_array($t[$key]) AND $key!=='GLOBALS') |
|
| 1972 | - spip_desinfecte($t[$key],$deep); |
|
| 1973 | - } |
|
| 1959 | + static $magic_quotes; |
|
| 1960 | + if (!isset($magic_quotes)) |
|
| 1961 | + $magic_quotes = @get_magic_quotes_gpc(); |
|
| 1962 | + |
|
| 1963 | + foreach ($t as $key => $val) { |
|
| 1964 | + if (is_string($t[$key])) { |
|
| 1965 | + if ($magic_quotes) |
|
| 1966 | + $t[$key] = stripslashes($t[$key]); |
|
| 1967 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 1968 | + } |
|
| 1969 | + // traiter aussi les "texte_plus" de article_edit |
|
| 1970 | + else if ($deep AND is_array($t[$key]) AND $key!=='GLOBALS') |
|
| 1971 | + spip_desinfecte($t[$key],$deep); |
|
| 1972 | + } |
|
| 1974 | 1973 | } |
| 1975 | 1974 | |
| 1976 | 1975 | // retourne le statut du visiteur s'il s'annonce |
| 1977 | 1976 | |
| 1978 | 1977 | // http://doc.spip.org/@verifier_visiteur |
| 1979 | 1978 | function verifier_visiteur() { |
| 1980 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 1981 | - // il faut forcer l'init si ce n'est fait |
|
| 1982 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 1983 | - // certaines constantes |
|
| 1984 | - @spip_initialisation_core( |
|
| 1985 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 1986 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 1987 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 1988 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 1989 | - ); |
|
| 1990 | - |
|
| 1991 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 1992 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 1993 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 1994 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 1995 | - $variables_session = array('session_nom', 'session_email'); |
|
| 1996 | - foreach($variables_session as $var) { |
|
| 1997 | - if (_request($var) !== null) { |
|
| 1998 | - $init = true; |
|
| 1999 | - break; |
|
| 2000 | - } |
|
| 2001 | - } |
|
| 2002 | - if (isset($init)) { |
|
| 2003 | - #@spip_initialisation_suite(); |
|
| 2004 | - $session = charger_fonction('session', 'inc'); |
|
| 2005 | - $session(); |
|
| 2006 | - include_spip('inc/texte'); |
|
| 2007 | - foreach($variables_session as $var) |
|
| 2008 | - if (($a = _request($var)) !== null) |
|
| 2009 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 2010 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) |
|
| 2011 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2012 | - $session($GLOBALS['visiteur_session']); |
|
| 2013 | - return 0; |
|
| 2014 | - } |
|
| 2015 | - |
|
| 2016 | - $h = (isset($_SERVER['PHP_AUTH_USER']) AND !$GLOBALS['ignore_auth_http']); |
|
| 2017 | - if ($h OR isset($_COOKIE['spip_session']) OR isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 2018 | - |
|
| 2019 | - $session = charger_fonction('session', 'inc'); |
|
| 2020 | - if ($session()) { |
|
| 2021 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 2022 | - } |
|
| 2023 | - if ($h AND isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 2024 | - include_spip('inc/auth'); |
|
| 2025 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 2026 | - } |
|
| 2027 | - if ($h) { |
|
| 2028 | - $GLOBALS['visiteur_session'] = $h; |
|
| 2029 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 2030 | - } |
|
| 2031 | - } |
|
| 2032 | - |
|
| 2033 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 2034 | - include_spip('inc/lang'); |
|
| 2035 | - utiliser_langue_visiteur(); |
|
| 2036 | - |
|
| 2037 | - return false; |
|
| 1979 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 1980 | + // il faut forcer l'init si ce n'est fait |
|
| 1981 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 1982 | + // certaines constantes |
|
| 1983 | + @spip_initialisation_core( |
|
| 1984 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 1985 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 1986 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 1987 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 1988 | + ); |
|
| 1989 | + |
|
| 1990 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 1991 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 1992 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 1993 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 1994 | + $variables_session = array('session_nom', 'session_email'); |
|
| 1995 | + foreach($variables_session as $var) { |
|
| 1996 | + if (_request($var) !== null) { |
|
| 1997 | + $init = true; |
|
| 1998 | + break; |
|
| 1999 | + } |
|
| 2000 | + } |
|
| 2001 | + if (isset($init)) { |
|
| 2002 | + #@spip_initialisation_suite(); |
|
| 2003 | + $session = charger_fonction('session', 'inc'); |
|
| 2004 | + $session(); |
|
| 2005 | + include_spip('inc/texte'); |
|
| 2006 | + foreach($variables_session as $var) |
|
| 2007 | + if (($a = _request($var)) !== null) |
|
| 2008 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 2009 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) |
|
| 2010 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2011 | + $session($GLOBALS['visiteur_session']); |
|
| 2012 | + return 0; |
|
| 2013 | + } |
|
| 2014 | + |
|
| 2015 | + $h = (isset($_SERVER['PHP_AUTH_USER']) AND !$GLOBALS['ignore_auth_http']); |
|
| 2016 | + if ($h OR isset($_COOKIE['spip_session']) OR isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 2017 | + |
|
| 2018 | + $session = charger_fonction('session', 'inc'); |
|
| 2019 | + if ($session()) { |
|
| 2020 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 2021 | + } |
|
| 2022 | + if ($h AND isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 2023 | + include_spip('inc/auth'); |
|
| 2024 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 2025 | + } |
|
| 2026 | + if ($h) { |
|
| 2027 | + $GLOBALS['visiteur_session'] = $h; |
|
| 2028 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 2029 | + } |
|
| 2030 | + } |
|
| 2031 | + |
|
| 2032 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 2033 | + include_spip('inc/lang'); |
|
| 2034 | + utiliser_langue_visiteur(); |
|
| 2035 | + |
|
| 2036 | + return false; |
|
| 2038 | 2037 | } |
| 2039 | 2038 | |
| 2040 | 2039 | // selectionne la langue donnee en argument et memorise la courante |
@@ -2046,18 +2045,18 @@ discard block |
||
| 2046 | 2045 | |
| 2047 | 2046 | // http://doc.spip.org/@lang_select |
| 2048 | 2047 | function lang_select ($lang=NULL) { |
| 2049 | - static $pile_langues = array(); |
|
| 2050 | - if (!function_exists('changer_langue')) |
|
| 2051 | - include_spip('inc/lang'); |
|
| 2052 | - if ($lang === NULL) |
|
| 2053 | - $lang = array_pop($pile_langues); |
|
| 2054 | - else { |
|
| 2055 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 2056 | - } |
|
| 2057 | - if (isset($GLOBALS['spip_lang']) AND $lang == $GLOBALS['spip_lang']) |
|
| 2058 | - return $lang; |
|
| 2059 | - changer_langue($lang); |
|
| 2060 | - return $lang; |
|
| 2048 | + static $pile_langues = array(); |
|
| 2049 | + if (!function_exists('changer_langue')) |
|
| 2050 | + include_spip('inc/lang'); |
|
| 2051 | + if ($lang === NULL) |
|
| 2052 | + $lang = array_pop($pile_langues); |
|
| 2053 | + else { |
|
| 2054 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 2055 | + } |
|
| 2056 | + if (isset($GLOBALS['spip_lang']) AND $lang == $GLOBALS['spip_lang']) |
|
| 2057 | + return $lang; |
|
| 2058 | + changer_langue($lang); |
|
| 2059 | + return $lang; |
|
| 2061 | 2060 | } |
| 2062 | 2061 | |
| 2063 | 2062 | |
@@ -2070,18 +2069,18 @@ discard block |
||
| 2070 | 2069 | // de fichier cache |
| 2071 | 2070 | // http://doc.spip.org/@spip_session |
| 2072 | 2071 | function spip_session($force = false) { |
| 2073 | - static $session; |
|
| 2074 | - if ($force OR !isset($session)) { |
|
| 2075 | - $s = pipeline('definir_session', |
|
| 2076 | - $GLOBALS['visiteur_session'] |
|
| 2077 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 2078 | - . '_' . @$_COOKIE['spip_session'] |
|
| 2079 | - : '' |
|
| 2080 | - ); |
|
| 2081 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 2082 | - } |
|
| 2083 | - #spip_log('session: '.$session); |
|
| 2084 | - return $session; |
|
| 2072 | + static $session; |
|
| 2073 | + if ($force OR !isset($session)) { |
|
| 2074 | + $s = pipeline('definir_session', |
|
| 2075 | + $GLOBALS['visiteur_session'] |
|
| 2076 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 2077 | + . '_' . @$_COOKIE['spip_session'] |
|
| 2078 | + : '' |
|
| 2079 | + ); |
|
| 2080 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 2081 | + } |
|
| 2082 | + #spip_log('session: '.$session); |
|
| 2083 | + return $session; |
|
| 2085 | 2084 | } |
| 2086 | 2085 | |
| 2087 | 2086 | |
@@ -2098,18 +2097,18 @@ discard block |
||
| 2098 | 2097 | **/ |
| 2099 | 2098 | // http://doc.spip.org/@aide |
| 2100 | 2099 | function aide($aide='', $distante = false) { |
| 2101 | - $aider = charger_fonction('aider', 'inc', true); |
|
| 2102 | - return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 2100 | + $aider = charger_fonction('aider', 'inc', true); |
|
| 2101 | + return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 2103 | 2102 | } |
| 2104 | 2103 | |
| 2105 | 2104 | // normalement il faudrait creer exec/info.php, mais pour mettre juste ca: |
| 2106 | 2105 | // http://doc.spip.org/@exec_info_dist |
| 2107 | 2106 | function exec_info_dist() { |
| 2108 | - global $connect_statut; |
|
| 2109 | - if ($connect_statut == '0minirezo') |
|
| 2110 | - phpinfo(); |
|
| 2111 | - else |
|
| 2112 | - echo "pas admin"; |
|
| 2107 | + global $connect_statut; |
|
| 2108 | + if ($connect_statut == '0minirezo') |
|
| 2109 | + phpinfo(); |
|
| 2110 | + else |
|
| 2111 | + echo "pas admin"; |
|
| 2113 | 2112 | } |
| 2114 | 2113 | |
| 2115 | 2114 | /** |
@@ -2129,12 +2128,12 @@ discard block |
||
| 2129 | 2128 | * - string si $message à false. |
| 2130 | 2129 | **/ |
| 2131 | 2130 | function erreur_squelette($message='', $lieu='') { |
| 2132 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 2133 | - if (is_array($lieu)) { |
|
| 2134 | - include_spip('public/compiler'); |
|
| 2135 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 2136 | - } |
|
| 2137 | - return $debusquer($message, $lieu); |
|
| 2131 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 2132 | + if (is_array($lieu)) { |
|
| 2133 | + include_spip('public/compiler'); |
|
| 2134 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 2135 | + } |
|
| 2136 | + return $debusquer($message, $lieu); |
|
| 2138 | 2137 | } |
| 2139 | 2138 | |
| 2140 | 2139 | /** |
@@ -2169,67 +2168,67 @@ discard block |
||
| 2169 | 2168 | * ou tableau d'information sur le squelette. |
| 2170 | 2169 | */ |
| 2171 | 2170 | function recuperer_fond($fond, $contexte=array(), $options = array(), $connect='') { |
| 2172 | - if (!function_exists('evaluer_fond')) |
|
| 2173 | - include_spip('public/assembler'); |
|
| 2174 | - // assurer la compat avec l'ancienne syntaxe |
|
| 2175 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 2176 | - if (!is_array($options)) $options = array('trim'=>$options); |
|
| 2177 | - if (!isset($options['trim'])) $options['trim']=true; |
|
| 2178 | - |
|
| 2179 | - if (isset($contexte['connect'])){ |
|
| 2180 | - $connect = ($connect ? $connect : $contexte['connect']); |
|
| 2181 | - unset($contexte['connect']); |
|
| 2182 | - } |
|
| 2183 | - |
|
| 2184 | - $texte = ""; |
|
| 2185 | - $pages = array(); |
|
| 2186 | - $lang_select = ''; |
|
| 2187 | - if (!isset($options['etoile']) OR !$options['etoile']){ |
|
| 2188 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 2189 | - if (!isset($contexte['lang'])) |
|
| 2190 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 2191 | - |
|
| 2192 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 2193 | - $lang_select = lang_select($contexte['lang']); |
|
| 2194 | - } |
|
| 2195 | - } |
|
| 2196 | - |
|
| 2197 | - @$GLOBALS['_INC_PUBLIC']++; |
|
| 2198 | - |
|
| 2199 | - foreach(is_array($fond) ? $fond : array($fond) as $f){ |
|
| 2200 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 2201 | - if ($page === '') { |
|
| 2202 | - $c = isset($options['compil']) ? $options['compil'] :''; |
|
| 2203 | - $a = array('fichier'=>$fond); |
|
| 2204 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 2205 | - erreur_squelette($erreur, $c); |
|
| 2206 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 2207 | - $page = array('texte' => '', 'erreur' => $erreur); |
|
| 2208 | - } |
|
| 2209 | - |
|
| 2210 | - $page = pipeline('recuperer_fond',array( |
|
| 2211 | - 'args'=>array('fond'=>$f,'contexte'=>$contexte,'options'=>$options,'connect'=>$connect), |
|
| 2212 | - 'data'=>$page |
|
| 2213 | - )); |
|
| 2214 | - if (isset($options['ajax']) AND $options['ajax']){ |
|
| 2215 | - if (!function_exists('encoder_contexte_ajax')) |
|
| 2216 | - include_spip('inc/filtres'); |
|
| 2217 | - $page['texte'] = encoder_contexte_ajax(array_merge($contexte,array('fond'=>$f)),'',$page['texte'], $options['ajax']); |
|
| 2218 | - } |
|
| 2219 | - |
|
| 2220 | - if (isset($options['raw']) AND $options['raw']) |
|
| 2221 | - $pages[] = $page; |
|
| 2222 | - else |
|
| 2223 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 2224 | - } |
|
| 2225 | - |
|
| 2226 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 2227 | - |
|
| 2228 | - if ($lang_select) lang_select(); |
|
| 2229 | - if (isset($options['raw']) AND $options['raw']) |
|
| 2230 | - return is_array($fond)?$pages:reset($pages); |
|
| 2231 | - else |
|
| 2232 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 2171 | + if (!function_exists('evaluer_fond')) |
|
| 2172 | + include_spip('public/assembler'); |
|
| 2173 | + // assurer la compat avec l'ancienne syntaxe |
|
| 2174 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 2175 | + if (!is_array($options)) $options = array('trim'=>$options); |
|
| 2176 | + if (!isset($options['trim'])) $options['trim']=true; |
|
| 2177 | + |
|
| 2178 | + if (isset($contexte['connect'])){ |
|
| 2179 | + $connect = ($connect ? $connect : $contexte['connect']); |
|
| 2180 | + unset($contexte['connect']); |
|
| 2181 | + } |
|
| 2182 | + |
|
| 2183 | + $texte = ""; |
|
| 2184 | + $pages = array(); |
|
| 2185 | + $lang_select = ''; |
|
| 2186 | + if (!isset($options['etoile']) OR !$options['etoile']){ |
|
| 2187 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 2188 | + if (!isset($contexte['lang'])) |
|
| 2189 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 2190 | + |
|
| 2191 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 2192 | + $lang_select = lang_select($contexte['lang']); |
|
| 2193 | + } |
|
| 2194 | + } |
|
| 2195 | + |
|
| 2196 | + @$GLOBALS['_INC_PUBLIC']++; |
|
| 2197 | + |
|
| 2198 | + foreach(is_array($fond) ? $fond : array($fond) as $f){ |
|
| 2199 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 2200 | + if ($page === '') { |
|
| 2201 | + $c = isset($options['compil']) ? $options['compil'] :''; |
|
| 2202 | + $a = array('fichier'=>$fond); |
|
| 2203 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 2204 | + erreur_squelette($erreur, $c); |
|
| 2205 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 2206 | + $page = array('texte' => '', 'erreur' => $erreur); |
|
| 2207 | + } |
|
| 2208 | + |
|
| 2209 | + $page = pipeline('recuperer_fond',array( |
|
| 2210 | + 'args'=>array('fond'=>$f,'contexte'=>$contexte,'options'=>$options,'connect'=>$connect), |
|
| 2211 | + 'data'=>$page |
|
| 2212 | + )); |
|
| 2213 | + if (isset($options['ajax']) AND $options['ajax']){ |
|
| 2214 | + if (!function_exists('encoder_contexte_ajax')) |
|
| 2215 | + include_spip('inc/filtres'); |
|
| 2216 | + $page['texte'] = encoder_contexte_ajax(array_merge($contexte,array('fond'=>$f)),'',$page['texte'], $options['ajax']); |
|
| 2217 | + } |
|
| 2218 | + |
|
| 2219 | + if (isset($options['raw']) AND $options['raw']) |
|
| 2220 | + $pages[] = $page; |
|
| 2221 | + else |
|
| 2222 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 2223 | + } |
|
| 2224 | + |
|
| 2225 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 2226 | + |
|
| 2227 | + if ($lang_select) lang_select(); |
|
| 2228 | + if (isset($options['raw']) AND $options['raw']) |
|
| 2229 | + return is_array($fond)?$pages:reset($pages); |
|
| 2230 | + else |
|
| 2231 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 2233 | 2232 | } |
| 2234 | 2233 | |
| 2235 | 2234 | /** |
@@ -2239,7 +2238,7 @@ discard block |
||
| 2239 | 2238 | * @return string |
| 2240 | 2239 | */ |
| 2241 | 2240 | function trouve_modele($nom) { |
| 2242 | - return trouver_fond($nom,'modeles/'); |
|
| 2241 | + return trouver_fond($nom,'modeles/'); |
|
| 2243 | 2242 | } |
| 2244 | 2243 | |
| 2245 | 2244 | /** |
@@ -2255,54 +2254,54 @@ discard block |
||
| 2255 | 2254 | * @return array|string |
| 2256 | 2255 | */ |
| 2257 | 2256 | function trouver_fond($nom, $dir='', $pathinfo = false) { |
| 2258 | - $f = find_in_path($nom.'.'. _EXTENSION_SQUELETTES, $dir?rtrim($dir,'/').'/':''); |
|
| 2259 | - if (!$pathinfo) return $f; |
|
| 2260 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 2261 | - $p = pathinfo($f); |
|
| 2262 | - if (!isset($p['extension']) OR !$p['extension']) { |
|
| 2263 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 2264 | - } |
|
| 2265 | - if (!isset($p['extension']) OR !$p['filename']) { |
|
| 2266 | - $p['filename'] = ($p['basename']?substr($p['basename'],0,-strlen($p['extension'])-1):''); |
|
| 2267 | - } |
|
| 2268 | - $p['fond'] = ($f?substr($f,0,-strlen($p['extension'])-1):''); |
|
| 2269 | - return $p; |
|
| 2257 | + $f = find_in_path($nom.'.'. _EXTENSION_SQUELETTES, $dir?rtrim($dir,'/').'/':''); |
|
| 2258 | + if (!$pathinfo) return $f; |
|
| 2259 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 2260 | + $p = pathinfo($f); |
|
| 2261 | + if (!isset($p['extension']) OR !$p['extension']) { |
|
| 2262 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 2263 | + } |
|
| 2264 | + if (!isset($p['extension']) OR !$p['filename']) { |
|
| 2265 | + $p['filename'] = ($p['basename']?substr($p['basename'],0,-strlen($p['extension'])-1):''); |
|
| 2266 | + } |
|
| 2267 | + $p['fond'] = ($f?substr($f,0,-strlen($p['extension'])-1):''); |
|
| 2268 | + return $p; |
|
| 2270 | 2269 | } |
| 2271 | 2270 | |
| 2272 | 2271 | function tester_url_ecrire($nom){ |
| 2273 | - static $exec=array(); |
|
| 2274 | - if (isset($exec[$nom])) return $exec[$nom]; |
|
| 2275 | - // tester si c'est une page en squelette |
|
| 2276 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) |
|
| 2277 | - return $exec[$nom] = 'fond'; |
|
| 2278 | - // compat skels orthogonaux version precedente |
|
| 2279 | - elseif (trouver_fond($nom, 'prive/exec/')) |
|
| 2280 | - return $exec[$nom] = 'fond_monobloc'; |
|
| 2281 | - // echafaudage d'un fond ! |
|
| 2282 | - elseif(include_spip('public/styliser_par_z') AND z_echafaudable($nom)) |
|
| 2283 | - return $exec[$nom] = 'fond'; |
|
| 2284 | - // attention, il ne faut pas inclure l'exec ici |
|
| 2285 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 2286 | - // et des define intrusifs potentiels |
|
| 2287 | - return $exec[$nom] = ((find_in_path("{$nom}.php",'exec/') OR charger_fonction($nom,'exec',true))?$nom:''); |
|
| 2272 | + static $exec=array(); |
|
| 2273 | + if (isset($exec[$nom])) return $exec[$nom]; |
|
| 2274 | + // tester si c'est une page en squelette |
|
| 2275 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) |
|
| 2276 | + return $exec[$nom] = 'fond'; |
|
| 2277 | + // compat skels orthogonaux version precedente |
|
| 2278 | + elseif (trouver_fond($nom, 'prive/exec/')) |
|
| 2279 | + return $exec[$nom] = 'fond_monobloc'; |
|
| 2280 | + // echafaudage d'un fond ! |
|
| 2281 | + elseif(include_spip('public/styliser_par_z') AND z_echafaudable($nom)) |
|
| 2282 | + return $exec[$nom] = 'fond'; |
|
| 2283 | + // attention, il ne faut pas inclure l'exec ici |
|
| 2284 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 2285 | + // et des define intrusifs potentiels |
|
| 2286 | + return $exec[$nom] = ((find_in_path("{$nom}.php",'exec/') OR charger_fonction($nom,'exec',true))?$nom:''); |
|
| 2288 | 2287 | } |
| 2289 | 2288 | |
| 2290 | 2289 | // Charger dynamiquement une extension php |
| 2291 | 2290 | // http://doc.spip.org/@charger_php_extension |
| 2292 | 2291 | function charger_php_extension($module) { |
| 2293 | - if (extension_loaded($module)) { |
|
| 2294 | - return true; |
|
| 2295 | - } else { |
|
| 2296 | - $charger_php_extension = charger_fonction('charger_php_extension','inc'); |
|
| 2297 | - return $charger_php_extension($module); |
|
| 2298 | - } |
|
| 2292 | + if (extension_loaded($module)) { |
|
| 2293 | + return true; |
|
| 2294 | + } else { |
|
| 2295 | + $charger_php_extension = charger_fonction('charger_php_extension','inc'); |
|
| 2296 | + return $charger_php_extension($module); |
|
| 2297 | + } |
|
| 2299 | 2298 | } |
| 2300 | 2299 | |
| 2301 | 2300 | // Renvoie TRUE si et seulement si la configuration autorise |
| 2302 | 2301 | // le code HTML5 sur le site public |
| 2303 | 2302 | function html5_permis() { |
| 2304 | 2303 | return (isset($GLOBALS['meta']['version_html_max']) |
| 2305 | - AND ('html5' == $GLOBALS['meta']['version_html_max'])); |
|
| 2304 | + AND ('html5' == $GLOBALS['meta']['version_html_max'])); |
|
| 2306 | 2305 | } |
| 2307 | 2306 | |
| 2308 | 2307 | /* |
@@ -2313,7 +2312,7 @@ discard block |
||
| 2313 | 2312 | // Fonction depreciee |
| 2314 | 2313 | // http://doc.spip.org/@lire_meta |
| 2315 | 2314 | function lire_meta($nom) { |
| 2316 | - return $GLOBALS['meta'][$nom]; |
|
| 2315 | + return $GLOBALS['meta'][$nom]; |
|
| 2317 | 2316 | } |
| 2318 | 2317 | |
| 2319 | 2318 | // Fonction depreciee |
@@ -2323,15 +2322,15 @@ discard block |
||
| 2323 | 2322 | // Fonction depreciee, cf. http://doc.spip.org/@sql_fetch |
| 2324 | 2323 | // http://doc.spip.org/@spip_fetch_array |
| 2325 | 2324 | function spip_fetch_array($r, $t=NULL) { |
| 2326 | - if (!isset($t)) { |
|
| 2327 | - if ($r) return sql_fetch($r); |
|
| 2328 | - } else { |
|
| 2329 | - if ($t=='SPIP_NUM') $t = MYSQL_NUM; |
|
| 2330 | - if ($t=='SPIP_BOTH') $t = MYSQL_BOTH; |
|
| 2331 | - if ($t=='SPIP_ASSOC') $t = MYSQL_ASSOC; |
|
| 2332 | - spip_log("appel deprecie de spip_fetch_array(..., $t)", 'vieilles_defs'); |
|
| 2333 | - if ($r) return mysql_fetch_array($r, $t); |
|
| 2334 | - } |
|
| 2325 | + if (!isset($t)) { |
|
| 2326 | + if ($r) return sql_fetch($r); |
|
| 2327 | + } else { |
|
| 2328 | + if ($t=='SPIP_NUM') $t = MYSQL_NUM; |
|
| 2329 | + if ($t=='SPIP_BOTH') $t = MYSQL_BOTH; |
|
| 2330 | + if ($t=='SPIP_ASSOC') $t = MYSQL_ASSOC; |
|
| 2331 | + spip_log("appel deprecie de spip_fetch_array(..., $t)", 'vieilles_defs'); |
|
| 2332 | + if ($r) return mysql_fetch_array($r, $t); |
|
| 2333 | + } |
|
| 2335 | 2334 | } |
| 2336 | 2335 | |
| 2337 | 2336 | /** |
@@ -2345,14 +2344,14 @@ discard block |
||
| 2345 | 2344 | * @param string $statut |
| 2346 | 2345 | */ |
| 2347 | 2346 | function avertir_auteurs($nom,$message, $statut=''){ |
| 2348 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 2349 | - if (!$alertes |
|
| 2350 | - OR !is_array($alertes = unserialize($alertes))) |
|
| 2351 | - $alertes = array(); |
|
| 2352 | - |
|
| 2353 | - if (!isset($alertes[$statut])) |
|
| 2354 | - $alertes[$statut] = array(); |
|
| 2355 | - $alertes[$statut][$nom] = $message; |
|
| 2356 | - ecrire_meta("message_alertes_auteurs",serialize($alertes)); |
|
| 2347 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 2348 | + if (!$alertes |
|
| 2349 | + OR !is_array($alertes = unserialize($alertes))) |
|
| 2350 | + $alertes = array(); |
|
| 2351 | + |
|
| 2352 | + if (!isset($alertes[$statut])) |
|
| 2353 | + $alertes[$statut] = array(); |
|
| 2354 | + $alertes[$statut][$nom] = $message; |
|
| 2355 | + ecrire_meta("message_alertes_auteurs",serialize($alertes)); |
|
| 2357 | 2356 | } |
| 2358 | 2357 | ?> |
@@ -29,21 +29,21 @@ discard block |
||
| 29 | 29 | * @param bool $continue |
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | -function charger_fonction($nom, $dossier='exec', $continue=false) { |
|
| 32 | +function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
|
| 33 | 33 | static $echecs = array(); |
| 34 | 34 | |
| 35 | - if (strlen($dossier) AND substr($dossier,-1) != '/') $dossier .= '/'; |
|
| 36 | - $f = str_replace('/','_',$dossier) . $nom; |
|
| 35 | + if (strlen($dossier) AND substr($dossier, -1) != '/') $dossier .= '/'; |
|
| 36 | + $f = str_replace('/', '_', $dossier).$nom; |
|
| 37 | 37 | |
| 38 | 38 | if (function_exists($f)) |
| 39 | 39 | return $f; |
| 40 | - if (function_exists($g = $f . '_dist')) |
|
| 40 | + if (function_exists($g = $f.'_dist')) |
|
| 41 | 41 | return $g; |
| 42 | 42 | |
| 43 | 43 | if (isset($echecs[$f])) return $echecs[$f]; |
| 44 | 44 | // Sinon charger le fichier de declaration si plausible |
| 45 | 45 | |
| 46 | - if (!preg_match(',^\w+$,', $f)){ |
|
| 46 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 47 | 47 | if ($continue) return false; //appel interne, on passe |
| 48 | 48 | include_spip('inc/minipres'); |
| 49 | 49 | echo minipres(); |
@@ -55,21 +55,21 @@ discard block |
||
| 55 | 55 | if (!$inc = include_spip($dossier.($d = strtolower($nom))) |
| 56 | 56 | // si le fichier truc/machin/nom.php n'existe pas, |
| 57 | 57 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 58 | - AND strlen(dirname($dossier)) AND dirname($dossier)!='.') |
|
| 59 | - include_spip(substr($dossier,0,-1)); |
|
| 58 | + AND strlen(dirname($dossier)) AND dirname($dossier) != '.') |
|
| 59 | + include_spip(substr($dossier, 0, -1)); |
|
| 60 | 60 | if (function_exists($f)) return $f; |
| 61 | 61 | if (function_exists($g)) return $g; |
| 62 | 62 | |
| 63 | 63 | if ($continue) return $echecs[$f] = false; |
| 64 | 64 | |
| 65 | 65 | // Echec : message d'erreur |
| 66 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 66 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 67 | 67 | ($inc ? "" : " (fichier $d absent de $dossier)")); |
| 68 | 68 | |
| 69 | 69 | include_spip('inc/minipres'); |
| 70 | 70 | echo minipres(_T('forum_titre_erreur'), |
| 71 | 71 | _T('fichier_introuvable', array('fichier'=> '<b>'.spip_htmlentities($d).'</b>')), |
| 72 | - array('all_inline'=>true,'status'=>404)); |
|
| 72 | + array('all_inline'=>true, 'status'=>404)); |
|
| 73 | 73 | exit; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | * @param string $file |
| 79 | 79 | * @return bool |
| 80 | 80 | */ |
| 81 | -function include_once_check($file){ |
|
| 82 | - if (file_exists($file)) {include_once $file;return true;} |
|
| 83 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins'])?unserialize($GLOBALS['meta']['message_crash_plugins']):''); |
|
| 84 | - $crash = ($crash?$crash:array()); |
|
| 81 | +function include_once_check($file) { |
|
| 82 | + if (file_exists($file)) {include_once $file; return true; } |
|
| 83 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ?unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 84 | + $crash = ($crash ? $crash : array()); |
|
| 85 | 85 | $crash[$file] = true; |
| 86 | - ecrire_meta('message_crash_plugins',serialize($crash)); |
|
| 86 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 87 | 87 | return false; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | // |
| 93 | 93 | // http://doc.spip.org/@include_spip |
| 94 | 94 | function include_spip($f, $include = true) { |
| 95 | - return find_in_path($f . '.php', '', $include); |
|
| 95 | + return find_in_path($f.'.php', '', $include); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
| 99 | 99 | function require_spip($f) { |
| 100 | - return find_in_path($f . '.php', '', 'required'); |
|
| 100 | + return find_in_path($f.'.php', '', 'required'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // un pipeline est lie a une action et une valeur |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | // utilisee dans le script pipeline precompile |
| 114 | 114 | // on passe $val par reference pour limiter les allocations memoire |
| 115 | 115 | // http://doc.spip.org/@minipipe |
| 116 | -function minipipe($fonc,&$val){ |
|
| 116 | +function minipipe($fonc, &$val) { |
|
| 117 | 117 | // fonction |
| 118 | 118 | if (function_exists($fonc)) |
| 119 | 119 | $val = call_user_func($fonc, $val); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | // chargement du pipeline sous la forme d'un fichier php prepare |
| 132 | 132 | // http://doc.spip.org/@pipeline |
| 133 | -function pipeline($action, $val=null) { |
|
| 133 | +function pipeline($action, $val = null) { |
|
| 134 | 134 | static $charger; |
| 135 | 135 | |
| 136 | 136 | // chargement initial des fonctions mises en cache, ou generation du cache |
@@ -156,15 +156,15 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | // plantage ? |
| 158 | 158 | else { |
| 159 | - spip_log("fonction $fonc absente : pipeline desactive",_LOG_ERREUR); |
|
| 159 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // si le flux est une table avec 2 cle args&data |
| 163 | 163 | // on ne ressort du pipe que les donnees dans 'data' |
| 164 | 164 | // array_key_exists pour php 4.1.0 |
| 165 | 165 | if (is_array($val) |
| 166 | - AND count($val)==2 |
|
| 167 | - AND (array_key_exists('data',$val))) |
|
| 166 | + AND count($val) == 2 |
|
| 167 | + AND (array_key_exists('data', $val))) |
|
| 168 | 168 | $val = $val['data']; |
| 169 | 169 | return $val; |
| 170 | 170 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @param string $logdir ## inutile !! a supprimer ? |
| 187 | 187 | * @param string $logsuf ## inutile !! a supprimer ? |
| 188 | 188 | */ |
| 189 | -function spip_log($message=NULL, $name=NULL) { |
|
| 189 | +function spip_log($message = NULL, $name = NULL) { |
|
| 190 | 190 | static $pre = array(); |
| 191 | 191 | static $log; |
| 192 | 192 | preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $niveau = _LOG_INFO; |
| 197 | 197 | |
| 198 | 198 | if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
| 199 | - if (!$pre){ |
|
| 199 | + if (!$pre) { |
|
| 200 | 200 | $pre = array( |
| 201 | 201 | _LOG_HS=>'HS:', |
| 202 | 202 | _LOG_ALERTE_ROUGE=>'ALERTE:', |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | // Renvoie le _GET ou le _POST emis par l'utilisateur |
| 225 | 225 | // ou pioche dans $c si c'est un array() |
| 226 | 226 | // http://doc.spip.org/@_request |
| 227 | -function _request($var, $c=false) { |
|
| 227 | +function _request($var, $c = false) { |
|
| 228 | 228 | |
| 229 | 229 | if (is_array($c)) |
| 230 | 230 | return isset($c[$var]) ? $c[$var] : NULL; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | // Methode set de la fonction _request() |
| 257 | 257 | // Attention au cas ou l'on fait set_request('truc', NULL); |
| 258 | 258 | // http://doc.spip.org/@set_request |
| 259 | -function set_request($var, $val = NULL, $c=false) { |
|
| 259 | +function set_request($var, $val = NULL, $c = false) { |
|
| 260 | 260 | if (is_array($c)) { |
| 261 | 261 | unset($c[$var]); |
| 262 | 262 | if ($val !== NULL) |
@@ -312,9 +312,9 @@ discard block |
||
| 312 | 312 | * @param string $sep |
| 313 | 313 | * @return string |
| 314 | 314 | */ |
| 315 | -function parametre_url($url, $c, $v=NULL, $sep='&') { |
|
| 315 | +function parametre_url($url, $c, $v = NULL, $sep = '&') { |
|
| 316 | 316 | // requete erronnee : plusieurs variable dans $c et aucun $v |
| 317 | - if (strpos($c,"|")!==false AND is_null($v)) |
|
| 317 | + if (strpos($c, "|") !== false AND is_null($v)) |
|
| 318 | 318 | return null; |
| 319 | 319 | |
| 320 | 320 | // lever l'#ancre |
@@ -329,17 +329,17 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | // recuperer la base |
| 331 | 331 | $a = array_shift($url); |
| 332 | - if (!$a) $a= './'; |
|
| 332 | + if (!$a) $a = './'; |
|
| 333 | 333 | |
| 334 | - $regexp = ',^(' . str_replace('[]','\[\]',$c) . '[[]?[]]?)(=.*)?$,'; |
|
| 335 | - $ajouts = array_flip(explode('|',$c)); |
|
| 334 | + $regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,'; |
|
| 335 | + $ajouts = array_flip(explode('|', $c)); |
|
| 336 | 336 | $u = is_array($v) ? $v : rawurlencode($v); |
| 337 | - $testv = (is_array($v)?count($v):strlen($v)); |
|
| 337 | + $testv = (is_array($v) ?count($v) : strlen($v)); |
|
| 338 | 338 | // lire les variables et agir |
| 339 | 339 | foreach ($url as $n => $val) { |
| 340 | 340 | if (preg_match($regexp, urldecode($val), $r)) { |
| 341 | 341 | if ($v === NULL) { |
| 342 | - return $r[2]?substr($r[2],1):''; |
|
| 342 | + return $r[2] ?substr($r[2], 1) : ''; |
|
| 343 | 343 | } |
| 344 | 344 | // suppression |
| 345 | 345 | elseif (!$testv) { |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | } |
| 348 | 348 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 349 | 349 | // pour un tableau ce sera fait dans la prochaine boucle |
| 350 | - elseif (substr($r[1],-2) != '[]') { |
|
| 350 | + elseif (substr($r[1], -2) != '[]') { |
|
| 351 | 351 | $url[$n] = $r[1].'='.$u; |
| 352 | 352 | unset($ajouts[$r[1]]); |
| 353 | 353 | } |
@@ -357,15 +357,15 @@ discard block |
||
| 357 | 357 | // traiter les parametres pas encore trouves |
| 358 | 358 | if ($v === NULL |
| 359 | 359 | AND $args = func_get_args() |
| 360 | - AND count($args)==2) |
|
| 360 | + AND count($args) == 2) |
|
| 361 | 361 | return $v; |
| 362 | 362 | elseif ($testv) { |
| 363 | - foreach($ajouts as $k => $n) { |
|
| 363 | + foreach ($ajouts as $k => $n) { |
|
| 364 | 364 | if (!is_array($v)) |
| 365 | - $url[] = $k .'=' . $u; |
|
| 365 | + $url[] = $k.'='.$u; |
|
| 366 | 366 | else { |
| 367 | - $id = (substr($k,-2) == '[]') ? $k : ($k ."[]"); |
|
| 368 | - foreach ($v as $w) $url[]= $id .'=' . $w; |
|
| 367 | + $id = (substr($k, -2) == '[]') ? $k : ($k."[]"); |
|
| 368 | + foreach ($v as $w) $url[] = $id.'='.$w; |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | } |
@@ -375,9 +375,9 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | // recomposer l'adresse |
| 377 | 377 | if ($url) |
| 378 | - $a .= '?' . join($sep, $url); |
|
| 378 | + $a .= '?'.join($sep, $url); |
|
| 379 | 379 | |
| 380 | - return $a . $ancre; |
|
| 380 | + return $a.$ancre; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | // Prend une URL et lui ajoute/retire une ancre apres l'avoir nettoyee |
@@ -389,13 +389,13 @@ discard block |
||
| 389 | 389 | if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
| 390 | 390 | $url = $r[1]; |
| 391 | 391 | } |
| 392 | - if (preg_match('/[^-_a-zA-Z0-9]+/S',$ancre)){ |
|
| 392 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 393 | 393 | if (!function_exists('translitteration')) |
| 394 | 394 | include_spip('inc/charsets'); |
| 395 | 395 | $ancre = preg_replace(array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), array('', '-'), |
| 396 | 396 | translitteration($ancre)); |
| 397 | 397 | } |
| 398 | - return $url . (strlen($ancre) ? '#'. $ancre : ''); |
|
| 398 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /** |
@@ -409,17 +409,16 @@ discard block |
||
| 409 | 409 | { |
| 410 | 410 | static $done = false; |
| 411 | 411 | static $propre = ''; |
| 412 | - if (!is_null($reset)) return $propre=$reset; |
|
| 412 | + if (!is_null($reset)) return $propre = $reset; |
|
| 413 | 413 | if ($done) return $propre; |
| 414 | 414 | $done = true; |
| 415 | 415 | |
| 416 | 416 | $uri1 = $GLOBALS['REQUEST_URI']; |
| 417 | 417 | do { |
| 418 | 418 | $uri = $uri1; |
| 419 | - $uri1 = preg_replace |
|
| 420 | - (',([?&])(PHPSESSID|(var_[^=&]*))=[^&]*(&|$),i', |
|
| 419 | + $uri1 = preg_replace(',([?&])(PHPSESSID|(var_[^=&]*))=[^&]*(&|$),i', |
|
| 421 | 420 | '\1', $uri); |
| 422 | - } while ($uri<>$uri1); |
|
| 421 | + } while ($uri <> $uri1); |
|
| 423 | 422 | |
| 424 | 423 | return $propre = (preg_replace(',[?&]$,', '', $uri1)); |
| 425 | 424 | } |
@@ -439,19 +438,19 @@ discard block |
||
| 439 | 438 | if (!$root |
| 440 | 439 | AND ( |
| 441 | 440 | // si pas de profondeur on peut tronquer |
| 442 | - $GLOBALS['profondeur_url']<(_DIR_RESTREINT?1:2) |
|
| 441 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 443 | 442 | // sinon c'est OK si _SET_HTML_BASE a ete force a false |
| 444 | 443 | OR (defined('_SET_HTML_BASE') AND !_SET_HTML_BASE)) |
| 445 | 444 | ) |
| 446 | 445 | $url = preg_replace(',^[^?]*/,', '', $url); |
| 447 | 446 | // ajouter le cas echeant les variables _POST['id_...'] |
| 448 | 447 | foreach ($_POST as $v => $c) |
| 449 | - if (substr($v,0,3) == 'id_') |
|
| 448 | + if (substr($v, 0, 3) == 'id_') |
|
| 450 | 449 | $url = parametre_url($url, $v, $c, '&'); |
| 451 | 450 | |
| 452 | 451 | // supprimer les variables sans interet |
| 453 | 452 | if (test_espace_prive()) { |
| 454 | - $url = preg_replace (',([?&])(' |
|
| 453 | + $url = preg_replace(',([?&])(' |
|
| 455 | 454 | .'lang|show_docs|' |
| 456 | 455 | .'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
| 457 | 456 | $url = preg_replace(',([?&])[&]+,', '\1', $url); |
@@ -487,8 +486,8 @@ discard block |
||
| 487 | 486 | * @param string $plugin |
| 488 | 487 | * @return bool |
| 489 | 488 | */ |
| 490 | -function test_plugin_actif($plugin){ |
|
| 491 | - return ($plugin AND defined('_DIR_PLUGIN_'.strtoupper($plugin)))? true:false; |
|
| 489 | +function test_plugin_actif($plugin) { |
|
| 490 | + return ($plugin AND defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true:false; |
|
| 492 | 491 | } |
| 493 | 492 | |
| 494 | 493 | /** |
@@ -502,14 +501,14 @@ discard block |
||
| 502 | 501 | * bool force : forcer un retour meme si la chaine n'a pas de traduction |
| 503 | 502 | * @return mixed|string |
| 504 | 503 | */ |
| 505 | -function _T($texte, $args=array(), $options=array()) { |
|
| 506 | - static $traduire=false ; |
|
| 504 | +function _T($texte, $args = array(), $options = array()) { |
|
| 505 | + static $traduire = false; |
|
| 507 | 506 | $o = array('class'=>'', 'force'=>true); |
| 508 | - if ($options){ |
|
| 507 | + if ($options) { |
|
| 509 | 508 | // support de l'ancien argument $class |
| 510 | 509 | if (is_string($options)) |
| 511 | 510 | $options = array('class'=>$options); |
| 512 | - $o = array_merge($o,$options); |
|
| 511 | + $o = array_merge($o, $options); |
|
| 513 | 512 | } |
| 514 | 513 | |
| 515 | 514 | if (!$traduire) { |
@@ -519,7 +518,7 @@ discard block |
||
| 519 | 518 | |
| 520 | 519 | // On peut passer explicitement la langue dans le tableau |
| 521 | 520 | // On utilise le même nom de variable que la globale |
| 522 | - if (isset($args['spip_lang'])){ |
|
| 521 | + if (isset($args['spip_lang'])) { |
|
| 523 | 522 | $lang = $args['spip_lang']; |
| 524 | 523 | // On l'enleve pour ne pas le passer au remplacement |
| 525 | 524 | unset($args['spip_lang']); |
@@ -530,7 +529,7 @@ discard block |
||
| 530 | 529 | } |
| 531 | 530 | $text = $traduire($texte, $lang); |
| 532 | 531 | |
| 533 | - if (!strlen($text)){ |
|
| 532 | + if (!strlen($text)) { |
|
| 534 | 533 | if (!$o['force']) |
| 535 | 534 | return ''; |
| 536 | 535 | |
@@ -539,8 +538,7 @@ discard block |
||
| 539 | 538 | // pour les chaines non traduites, assurer un service minimum |
| 540 | 539 | if (!$GLOBALS['test_i18n'] AND (_request('var_mode') != 'traduction')) |
| 541 | 540 | $text = str_replace('_', ' ', |
| 542 | - (($n = strpos($text,':')) === false ? $texte : |
|
| 543 | - substr($texte, $n+1))); |
|
| 541 | + (($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1))); |
|
| 544 | 542 | $o['class'] = null; |
| 545 | 543 | |
| 546 | 544 | } |
@@ -552,21 +550,21 @@ discard block |
||
| 552 | 550 | // Remplacer les variables @....@ par leur valeur dans une chaine de langue. |
| 553 | 551 | // Aussi appelee quand une chaine n'est pas encore dans les fichiers de langue |
| 554 | 552 | // http://doc.spip.org/@_L |
| 555 | -function _L($text, $args=array(), $class=null) { |
|
| 553 | +function _L($text, $args = array(), $class = null) { |
|
| 556 | 554 | $f = $text; |
| 557 | 555 | if (is_array($args)) { |
| 558 | 556 | foreach ($args as $name => $value) { |
| 559 | 557 | if ($class) |
| 560 | 558 | $value = "<span class='$class'>$value</span>"; |
| 561 | - $t = str_replace ("@$name@", $value, $text); |
|
| 562 | - if ($text !== $t) {unset($args[$name]); $text = $t;} |
|
| 559 | + $t = str_replace("@$name@", $value, $text); |
|
| 560 | + if ($text !== $t) {unset($args[$name]); $text = $t; } |
|
| 563 | 561 | } |
| 564 | 562 | // Si des variables n'ont pas ete inserees, le signaler |
| 565 | 563 | // (chaines de langues pas a jour) |
| 566 | - if ($args) spip_log("$f: variables inutilisees " . join(', ', array_keys($args)),_LOG_DEBUG); |
|
| 564 | + if ($args) spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 567 | 565 | } |
| 568 | 566 | |
| 569 | - if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class===null) |
|
| 567 | + if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class === null) |
|
| 570 | 568 | return "<span class=debug-traduction-erreur>$text</span>"; |
| 571 | 569 | else |
| 572 | 570 | return $text; |
@@ -576,9 +574,9 @@ discard block |
||
| 576 | 574 | // ou tmp/ au lieu de ../tmp/ |
| 577 | 575 | // http://doc.spip.org/@joli_repertoire |
| 578 | 576 | function joli_repertoire($rep) { |
| 579 | - $a = substr($rep,0,1); |
|
| 580 | - if ($a<>'.' AND $a<>'/') |
|
| 581 | - $rep = (_DIR_RESTREINT?'':_DIR_RESTREINT_ABS).$rep; |
|
| 577 | + $a = substr($rep, 0, 1); |
|
| 578 | + if ($a <> '.' AND $a <> '/') |
|
| 579 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep; |
|
| 582 | 580 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 583 | 581 | return $rep; |
| 584 | 582 | } |
@@ -588,12 +586,12 @@ discard block |
||
| 588 | 586 | // spip_timer : on l'appelle deux fois et on a la difference, affichable |
| 589 | 587 | // |
| 590 | 588 | // http://doc.spip.org/@spip_timer |
| 591 | -function spip_timer($t='rien', $raw = false) { |
|
| 589 | +function spip_timer($t = 'rien', $raw = false) { |
|
| 592 | 590 | static $time; |
| 593 | - $a=time(); $b=microtime(); |
|
| 591 | + $a = time(); $b = microtime(); |
|
| 594 | 592 | // microtime peut contenir les microsecondes et le temps |
| 595 | - $b=explode(' ',$b); |
|
| 596 | - if (count($b)==2) $a = end($b); // plus precis ! |
|
| 593 | + $b = explode(' ', $b); |
|
| 594 | + if (count($b) == 2) $a = end($b); // plus precis ! |
|
| 597 | 595 | $b = reset($b); |
| 598 | 596 | if (!isset($time[$t])) { |
| 599 | 597 | $time[$t] = $a + $b; |
@@ -605,10 +603,10 @@ discard block |
||
| 605 | 603 | if ($p < 1000) |
| 606 | 604 | $s = ''; |
| 607 | 605 | else { |
| 608 | - $s = sprintf("%d ", $x = floor($p/1000)); |
|
| 609 | - $p -= ($x*1000); |
|
| 606 | + $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 607 | + $p -= ($x * 1000); |
|
| 610 | 608 | } |
| 611 | - return $s . sprintf($s?"%07.3f ms":"%.3f ms", $p); |
|
| 609 | + return $s.sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 612 | 610 | } |
| 613 | 611 | } |
| 614 | 612 | |
@@ -616,13 +614,13 @@ discard block |
||
| 616 | 614 | // Renvoie False si un fichier n'est pas plus vieux que $duree secondes, |
| 617 | 615 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 618 | 616 | // http://doc.spip.org/@spip_touch |
| 619 | -function spip_touch($fichier, $duree=0, $touch=true) { |
|
| 617 | +function spip_touch($fichier, $duree = 0, $touch = true) { |
|
| 620 | 618 | if ($duree) { |
| 621 | 619 | clearstatcache(); |
| 622 | - if ((@$f=filemtime($fichier)) AND ($f >= time() - $duree)) |
|
| 620 | + if ((@$f = filemtime($fichier)) AND ($f >= time() - $duree)) |
|
| 623 | 621 | return false; |
| 624 | 622 | } |
| 625 | - if ($touch!==false) { |
|
| 623 | + if ($touch !== false) { |
|
| 626 | 624 | if (!@touch($fichier)) { spip_unlink($fichier); @touch($fichier); }; |
| 627 | 625 | @chmod($fichier, _SPIP_CHMOD & ~0111); |
| 628 | 626 | } |
@@ -641,7 +639,7 @@ discard block |
||
| 641 | 639 | include_spip('inc/headers'); |
| 642 | 640 | http_status(204); // No Content |
| 643 | 641 | header("Connection: close"); |
| 644 | - define('_DIRECT_CRON_FORCE',true); |
|
| 642 | + define('_DIRECT_CRON_FORCE', true); |
|
| 645 | 643 | cron(); |
| 646 | 644 | } |
| 647 | 645 | |
@@ -661,7 +659,7 @@ discard block |
||
| 661 | 659 | * taches forcees, pour compat avec ancienne syntaxe |
| 662 | 660 | * @return bool |
| 663 | 661 | */ |
| 664 | -function cron ($taches=array(), $taches_old= array()) { |
|
| 662 | +function cron($taches = array(), $taches_old = array()) { |
|
| 665 | 663 | // si pas en mode cron force, laisser tomber. |
| 666 | 664 | if (!defined('_DIRECT_CRON_FORCE')) return false; |
| 667 | 665 | if (!is_array($taches)) $taches = $taches_old; // compat anciens appels |
@@ -670,7 +668,7 @@ discard block |
||
| 670 | 668 | // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
| 671 | 669 | // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
| 672 | 670 | if ($taches AND count($taches) AND !spip_connect()) return false; |
| 673 | - spip_log("cron !",'jq'._LOG_DEBUG); |
|
| 671 | + spip_log("cron !", 'jq'._LOG_DEBUG); |
|
| 674 | 672 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 675 | 673 | return $genie($taches); |
| 676 | 674 | } |
@@ -699,7 +697,7 @@ discard block |
||
| 699 | 697 | * @return int |
| 700 | 698 | * id of job |
| 701 | 699 | */ |
| 702 | -function job_queue_add($function, $description, $arguments = array(), $file = '', $no_duplicate = FALSE, $time=0, $priority=0) { |
|
| 700 | +function job_queue_add($function, $description, $arguments = array(), $file = '', $no_duplicate = FALSE, $time = 0, $priority = 0) { |
|
| 703 | 701 | include_spip('inc/queue'); |
| 704 | 702 | return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
| 705 | 703 | } |
@@ -710,7 +708,7 @@ discard block |
||
| 710 | 708 | * id of jonb to delete |
| 711 | 709 | * @return bool |
| 712 | 710 | */ |
| 713 | -function job_queue_remove($id_job){ |
|
| 711 | +function job_queue_remove($id_job) { |
|
| 714 | 712 | include_spip('inc/queue'); |
| 715 | 713 | return queue_remove_job($id_job); |
| 716 | 714 | } |
@@ -723,9 +721,9 @@ discard block |
||
| 723 | 721 | * can be a simple array('objet'=>'article','id_objet'=>23) |
| 724 | 722 | * or an array of simple array to link multiples objet in one time |
| 725 | 723 | */ |
| 726 | -function job_queue_link($id_job,$objets){ |
|
| 724 | +function job_queue_link($id_job, $objets) { |
|
| 727 | 725 | include_spip('inc/queue'); |
| 728 | - return queue_link_job($id_job,$objets); |
|
| 726 | + return queue_link_job($id_job, $objets); |
|
| 729 | 727 | } |
| 730 | 728 | |
| 731 | 729 | |
@@ -741,15 +739,15 @@ discard block |
||
| 741 | 739 | * @param int/bool $force_next |
| 742 | 740 | * @return int |
| 743 | 741 | */ |
| 744 | -function queue_sleep_time_to_next_job($force=null) { |
|
| 742 | +function queue_sleep_time_to_next_job($force = null) { |
|
| 745 | 743 | static $queue_next_job_time = -1; |
| 746 | - if ($force===true) |
|
| 744 | + if ($force === true) |
|
| 747 | 745 | $queue_next_job_time = -1; |
| 748 | 746 | elseif ($force) |
| 749 | 747 | $queue_next_job_time = $force; |
| 750 | 748 | |
| 751 | - if ($queue_next_job_time==-1) { |
|
| 752 | - define('_JQ_NEXT_JOB_TIME_FILENAME',_DIR_TMP . "job_queue_next.txt"); |
|
| 749 | + if ($queue_next_job_time == -1) { |
|
| 750 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP."job_queue_next.txt"); |
|
| 753 | 751 | // utiliser un cache memoire si dispo |
| 754 | 752 | if (include_spip('inc/memoization') AND defined('_MEMOIZE_MEMORY') AND _MEMOIZE_MEMORY) { |
| 755 | 753 | $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
@@ -765,7 +763,7 @@ discard block |
||
| 765 | 763 | return null; |
| 766 | 764 | if (!$_SERVER['REQUEST_TIME']) |
| 767 | 765 | $_SERVER['REQUEST_TIME'] = time(); |
| 768 | - return $queue_next_job_time-$_SERVER['REQUEST_TIME']; |
|
| 766 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 769 | 767 | } |
| 770 | 768 | |
| 771 | 769 | |
@@ -774,23 +772,23 @@ discard block |
||
| 774 | 772 | function quote_amp($u) { |
| 775 | 773 | return preg_replace( |
| 776 | 774 | "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,5};)/i", |
| 777 | - "&",$u); |
|
| 775 | + "&", $u); |
|
| 778 | 776 | } |
| 779 | 777 | |
| 780 | 778 | // Production d'une balise Script valide |
| 781 | 779 | // http://doc.spip.org/@http_script |
| 782 | -function http_script($script, $src='', $noscript='') { |
|
| 780 | +function http_script($script, $src = '', $noscript = '') { |
|
| 783 | 781 | static $done = array(); |
| 784 | 782 | |
| 785 | - if ($src && !isset($done[$src])){ |
|
| 783 | + if ($src && !isset($done[$src])) { |
|
| 786 | 784 | $done[$src] = true; |
| 787 | 785 | $src = find_in_path($src, _JAVASCRIPT); |
| 788 | 786 | $src = " src='$src'"; |
| 789 | 787 | } |
| 790 | 788 | else $src = ''; |
| 791 | 789 | if ($script) |
| 792 | - $script = ("/*<![CDATA[*/\n" . |
|
| 793 | - preg_replace(',</([^>]*)>,','<\/\1>', $script) . |
|
| 790 | + $script = ("/*<![CDATA[*/\n". |
|
| 791 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script). |
|
| 794 | 792 | "/*]]>*/"); |
| 795 | 793 | if ($noscript) |
| 796 | 794 | $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
@@ -815,10 +813,10 @@ discard block |
||
| 815 | 813 | // du path, dans cet ordre. |
| 816 | 814 | // Exception: si un $dossier_squelette est defini, il reste en tete, pour raison historique |
| 817 | 815 | // http://doc.spip.org/@_chemin |
| 818 | -function _chemin($dir_path=NULL){ |
|
| 816 | +function _chemin($dir_path = NULL) { |
|
| 819 | 817 | static $path_base = NULL; |
| 820 | 818 | static $path_full = NULL; |
| 821 | - if ($path_base==NULL){ |
|
| 819 | + if ($path_base == NULL) { |
|
| 822 | 820 | // Chemin standard depuis l'espace public |
| 823 | 821 | $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
| 824 | 822 | _DIR_RACINE.':'. |
@@ -827,9 +825,9 @@ discard block |
||
| 827 | 825 | _DIR_RESTREINT; |
| 828 | 826 | // Ajouter squelettes/ |
| 829 | 827 | if (@is_dir(_DIR_RACINE.'squelettes')) |
| 830 | - $path = _DIR_RACINE.'squelettes/:' . $path; |
|
| 828 | + $path = _DIR_RACINE.'squelettes/:'.$path; |
|
| 831 | 829 | foreach (explode(':', $path) as $dir) { |
| 832 | - if (strlen($dir) AND substr($dir,-1) != '/') |
|
| 830 | + if (strlen($dir) AND substr($dir, -1) != '/') |
|
| 833 | 831 | $dir .= "/"; |
| 834 | 832 | $path_base[] = $dir; |
| 835 | 833 | } |
@@ -837,32 +835,32 @@ discard block |
||
| 837 | 835 | // Et le(s) dossier(s) des squelettes nommes |
| 838 | 836 | if (strlen($GLOBALS['dossier_squelettes'])) |
| 839 | 837 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
| 840 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 838 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 841 | 839 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
| 842 | 840 | } |
| 843 | - if ($dir_path===NULL) return $path_full; |
|
| 841 | + if ($dir_path === NULL) return $path_full; |
|
| 844 | 842 | |
| 845 | - if (strlen($dir_path)){ |
|
| 843 | + if (strlen($dir_path)) { |
|
| 846 | 844 | $tete = ""; |
| 847 | - if (reset($path_base)==_DIR_RACINE.'squelettes/') |
|
| 845 | + if (reset($path_base) == _DIR_RACINE.'squelettes/') |
|
| 848 | 846 | $tete = array_shift($path_base); |
| 849 | - $dirs = array_reverse(explode(':',$dir_path)); |
|
| 850 | - foreach($dirs as $dir_path){ |
|
| 847 | + $dirs = array_reverse(explode(':', $dir_path)); |
|
| 848 | + foreach ($dirs as $dir_path) { |
|
| 851 | 849 | #if ($dir_path{0}!='/') |
| 852 | 850 | # $dir_path = $dir_path; |
| 853 | - if (substr($dir_path,-1) != '/') |
|
| 851 | + if (substr($dir_path, -1) != '/') |
|
| 854 | 852 | $dir_path .= "/"; |
| 855 | - if (!in_array($dir_path,$path_base)) |
|
| 856 | - array_unshift($path_base,$dir_path); |
|
| 853 | + if (!in_array($dir_path, $path_base)) |
|
| 854 | + array_unshift($path_base, $dir_path); |
|
| 857 | 855 | } |
| 858 | 856 | if (strlen($tete)) |
| 859 | - array_unshift($path_base,$tete); |
|
| 857 | + array_unshift($path_base, $tete); |
|
| 860 | 858 | } |
| 861 | 859 | $path_full = $path_base; |
| 862 | 860 | // Et le(s) dossier(s) des squelettes nommes |
| 863 | 861 | if (strlen($GLOBALS['dossier_squelettes'])) |
| 864 | 862 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
| 865 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 863 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 866 | 864 | |
| 867 | 865 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
| 868 | 866 | return $path_full; |
@@ -883,9 +881,9 @@ discard block |
||
| 883 | 881 | } |
| 884 | 882 | |
| 885 | 883 | |
| 886 | -function lister_themes_prives(){ |
|
| 884 | +function lister_themes_prives() { |
|
| 887 | 885 | static $themes = null; |
| 888 | - if (is_null($themes)){ |
|
| 886 | + if (is_null($themes)) { |
|
| 889 | 887 | // si pas encore definie |
| 890 | 888 | if (!defined('_SPIP_THEME_PRIVE')) |
| 891 | 889 | define('_SPIP_THEME_PRIVE', 'spip'); |
@@ -902,20 +900,20 @@ discard block |
||
| 902 | 900 | ((isset($prefs['theme']) AND $theme = $prefs['theme']) |
| 903 | 901 | OR (isset($GLOBALS['theme_prive_defaut']) AND $theme = $GLOBALS['theme_prive_defaut'])) |
| 904 | 902 | AND $theme != _SPIP_THEME_PRIVE) |
| 905 | - array_unshift($themes,$theme); // placer le theme choisi en tete |
|
| 903 | + array_unshift($themes, $theme); // placer le theme choisi en tete |
|
| 906 | 904 | } |
| 907 | 905 | return $themes; |
| 908 | 906 | } |
| 909 | 907 | |
| 910 | -function find_in_theme($file, $subdir='', $include=false){ |
|
| 911 | - static $themefiles=array(); |
|
| 908 | +function find_in_theme($file, $subdir = '', $include = false) { |
|
| 909 | + static $themefiles = array(); |
|
| 912 | 910 | if (isset($themefiles["$subdir$file"])) return $themefiles["$subdir$file"]; |
| 913 | 911 | $themes = lister_themes_prives(); |
| 914 | - foreach($themes as $theme){ |
|
| 915 | - if ($f = find_in_path($file,"prive/themes/$theme/$subdir",$include)) |
|
| 912 | + foreach ($themes as $theme) { |
|
| 913 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) |
|
| 916 | 914 | return $themefiles["$subdir$file"] = $f; |
| 917 | 915 | } |
| 918 | - spip_log("$file introuvable dans le theme prive ".reset($themes),'theme'); |
|
| 916 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 919 | 917 | return $themefiles["$subdir$file"] = ""; |
| 920 | 918 | } |
| 921 | 919 | |
@@ -925,23 +923,23 @@ discard block |
||
| 925 | 923 | // peut se trouver dans un dossier plugin, donc on passe par un find_in_path si elle n'est pas |
| 926 | 924 | // dans _DIR_IMG_PACK |
| 927 | 925 | // http://doc.spip.org/@chemin_image |
| 928 | -function chemin_image($icone){ |
|
| 926 | +function chemin_image($icone) { |
|
| 929 | 927 | static $icone_renommer; |
| 930 | 928 | // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
| 931 | - if (strpos($icone,"/")!==false AND file_exists($icone)) return $icone; |
|
| 929 | + if (strpos($icone, "/") !== false AND file_exists($icone)) return $icone; |
|
| 932 | 930 | |
| 933 | 931 | // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
| 934 | - if (preg_match(',[.](png|gif|jpg)$,',$icone) AND $f = find_in_theme("images/$icone")) |
|
| 932 | + if (preg_match(',[.](png|gif|jpg)$,', $icone) AND $f = find_in_theme("images/$icone")) |
|
| 935 | 933 | return $f; |
| 936 | 934 | // sinon passer par le module de renommage |
| 937 | 935 | if (is_null($icone_renommer)) |
| 938 | - $icone_renommer = charger_fonction('icone_renommer','inc',true); |
|
| 939 | - if ($icone_renommer){ |
|
| 940 | - list($icone,$fonction) = $icone_renommer($icone,""); |
|
| 936 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 937 | + if ($icone_renommer) { |
|
| 938 | + list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 941 | 939 | if (file_exists($icone)) |
| 942 | 940 | return $icone; |
| 943 | 941 | } |
| 944 | - return find_in_path ($icone, _NOM_IMG_PACK); |
|
| 942 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 945 | 943 | } |
| 946 | 944 | |
| 947 | 945 | // |
@@ -952,13 +950,13 @@ discard block |
||
| 952 | 950 | $GLOBALS['path_files'] = null; |
| 953 | 951 | |
| 954 | 952 | // http://doc.spip.org/@find_in_path |
| 955 | -function find_in_path ($file, $dirname='', $include=false) { |
|
| 956 | - static $dirs=array(); |
|
| 953 | +function find_in_path($file, $dirname = '', $include = false) { |
|
| 954 | + static $dirs = array(); |
|
| 957 | 955 | static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743 |
| 958 | 956 | static $c = ''; |
| 959 | 957 | |
| 960 | 958 | // on calcule le chemin si le dossier skel a change |
| 961 | - if ($c != $GLOBALS['dossier_squelettes']){ |
|
| 959 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 962 | 960 | // assurer le non plantage lors de la montee de version : |
| 963 | 961 | $c = $GLOBALS['dossier_squelettes']; |
| 964 | 962 | creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
@@ -968,40 +966,40 @@ discard block |
||
| 968 | 966 | if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) |
| 969 | 967 | return false; |
| 970 | 968 | if ($include AND !isset($inc[$dirname][$file])) { |
| 971 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 972 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 969 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 970 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 973 | 971 | } |
| 974 | 972 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
| 975 | 973 | } |
| 976 | 974 | |
| 977 | - $a = strrpos($file,'/'); |
|
| 975 | + $a = strrpos($file, '/'); |
|
| 978 | 976 | if ($a !== false) { |
| 979 | 977 | $dirname .= substr($file, 0, ++$a); |
| 980 | 978 | $file = substr($file, $a); |
| 981 | 979 | } |
| 982 | 980 | |
| 983 | - foreach(creer_chemin() as $dir) { |
|
| 984 | - if (!isset($dirs[$a = $dir . $dirname])) |
|
| 985 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a) ; |
|
| 981 | + foreach (creer_chemin() as $dir) { |
|
| 982 | + if (!isset($dirs[$a = $dir.$dirname])) |
|
| 983 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a); |
|
| 986 | 984 | if ($dirs[$a]) { |
| 987 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 985 | + if (file_exists(_ROOT_CWD.($a .= $file))) { |
|
| 988 | 986 | if ($include AND !isset($inc[$dirname][$file])) { |
| 989 | - include_once _ROOT_CWD . $a; |
|
| 990 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 987 | + include_once _ROOT_CWD.$a; |
|
| 988 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 991 | 989 | } |
| 992 | - if (!defined('_SAUVER_CHEMIN')){ |
|
| 990 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 993 | 991 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
| 994 | 992 | if (is_null($GLOBALS['path_files'])) return $a; |
| 995 | 993 | define('_SAUVER_CHEMIN', true); |
| 996 | 994 | } |
| 997 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 995 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a; |
|
| 998 | 996 | } |
| 999 | 997 | } |
| 1000 | 998 | } |
| 1001 | 999 | |
| 1002 | - if ($include){ |
|
| 1000 | + if ($include) { |
|
| 1003 | 1001 | spip_log("include_spip $dirname$file non trouve"); |
| 1004 | - if ($include==='required'){ |
|
| 1002 | + if ($include === 'required') { |
|
| 1005 | 1003 | echo '<pre>', |
| 1006 | 1004 | "<strong>Erreur Fatale</strong><br />"; |
| 1007 | 1005 | if (function_exists('debug_print_backtrace')) |
@@ -1011,21 +1009,21 @@ discard block |
||
| 1011 | 1009 | } |
| 1012 | 1010 | } |
| 1013 | 1011 | |
| 1014 | - if (!defined('_SAUVER_CHEMIN')){ |
|
| 1012 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1015 | 1013 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
| 1016 | 1014 | if (is_null($GLOBALS['path_files'])) return false; |
| 1017 | 1015 | define('_SAUVER_CHEMIN', true); |
| 1018 | 1016 | } |
| 1019 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1017 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false; |
|
| 1020 | 1018 | } |
| 1021 | 1019 | |
| 1022 | -function clear_path_cache(){ |
|
| 1020 | +function clear_path_cache() { |
|
| 1023 | 1021 | $GLOBALS['path_files'] = array(); |
| 1024 | 1022 | spip_unlink(_CACHE_CHEMIN); |
| 1025 | 1023 | } |
| 1026 | -function load_path_cache(){ |
|
| 1024 | +function load_path_cache() { |
|
| 1027 | 1025 | // charger le path des plugins |
| 1028 | - if (@is_readable(_CACHE_PLUGINS_PATH)){ |
|
| 1026 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1029 | 1027 | include_once(_CACHE_PLUGINS_PATH); |
| 1030 | 1028 | } |
| 1031 | 1029 | $GLOBALS['path_files'] = array(); |
@@ -1039,23 +1037,23 @@ discard block |
||
| 1039 | 1037 | // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
| 1040 | 1038 | // et en ignorant ce cache en cas de recalcul explicite |
| 1041 | 1039 | !_request('var_mode') |
| 1042 | - ){ |
|
| 1040 | + ) { |
|
| 1043 | 1041 | // on essaye de lire directement sans verrou pour aller plus vite |
| 1044 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)){ |
|
| 1042 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1045 | 1043 | // mais si semble corrompu on relit avec un verrou |
| 1046 | - if (!$GLOBALS['path_files']=unserialize($contenu)){ |
|
| 1047 | - lire_fichier(_CACHE_CHEMIN,$contenu); |
|
| 1048 | - if (!$GLOBALS['path_files']=unserialize($contenu)) |
|
| 1044 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1045 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1046 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) |
|
| 1049 | 1047 | $GLOBALS['path_files'] = array(); |
| 1050 | 1048 | } |
| 1051 | 1049 | } |
| 1052 | 1050 | } |
| 1053 | 1051 | } |
| 1054 | 1052 | |
| 1055 | -function save_path_cache(){ |
|
| 1053 | +function save_path_cache() { |
|
| 1056 | 1054 | if (defined('_SAUVER_CHEMIN') |
| 1057 | 1055 | AND _SAUVER_CHEMIN) |
| 1058 | - ecrire_fichier(_CACHE_CHEMIN,serialize($GLOBALS['path_files'])); |
|
| 1056 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1059 | 1057 | } |
| 1060 | 1058 | |
| 1061 | 1059 | |
@@ -1070,16 +1068,16 @@ discard block |
||
| 1070 | 1068 | * @return array |
| 1071 | 1069 | */ |
| 1072 | 1070 | // http://doc.spip.org/@find_all_in_path |
| 1073 | -function find_all_in_path($dir,$pattern, $recurs=false){ |
|
| 1074 | - $liste_fichiers=array(); |
|
| 1071 | +function find_all_in_path($dir, $pattern, $recurs = false) { |
|
| 1072 | + $liste_fichiers = array(); |
|
| 1075 | 1073 | $maxfiles = 10000; |
| 1076 | 1074 | |
| 1077 | 1075 | // Parcourir le chemin |
| 1078 | 1076 | foreach (creer_chemin() as $d) { |
| 1079 | 1077 | $f = $d.$dir; |
| 1080 | - if (@is_dir($f)){ |
|
| 1081 | - $liste = preg_files($f,$pattern,$maxfiles-count($liste_fichiers),$recurs===true?array():$recurs); |
|
| 1082 | - foreach($liste as $chemin){ |
|
| 1078 | + if (@is_dir($f)) { |
|
| 1079 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1080 | + foreach ($liste as $chemin) { |
|
| 1083 | 1081 | $nom = basename($chemin); |
| 1084 | 1082 | // ne prendre que les fichiers pas deja trouves |
| 1085 | 1083 | // car find_in_path prend le premier qu'il trouve, |
@@ -1126,7 +1124,7 @@ discard block |
||
| 1126 | 1124 | * array : derogatoire, la fonction d'url retourne (objet,id_objet) utilises par nettoyer_raccourcis_typo() pour generer un lien titre |
| 1127 | 1125 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip) |
| 1128 | 1126 | */ |
| 1129 | -function generer_url_entite($id='', $entite='', $args='', $ancre='', $public=NULL, $type=NULL) |
|
| 1127 | +function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = NULL, $type = NULL) |
|
| 1130 | 1128 | { |
| 1131 | 1129 | if ($public === NULL) $public = !test_espace_prive(); |
| 1132 | 1130 | $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
@@ -1135,12 +1133,12 @@ discard block |
||
| 1135 | 1133 | if (!$entite) return ''; |
| 1136 | 1134 | if (!function_exists('generer_url_ecrire_objet')) |
| 1137 | 1135 | include_spip('inc/urls'); |
| 1138 | - $res = generer_url_ecrire_objet($entite,$id, $args, $ancre, false); |
|
| 1136 | + $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1139 | 1137 | } else { |
| 1140 | 1138 | if ($type === NULL) { |
| 1141 | 1139 | $type = ($GLOBALS['type_urls'] === 'page' |
| 1142 | 1140 | AND $GLOBALS['meta']['type_urls']) |
| 1143 | - ? $GLOBALS['meta']['type_urls'] |
|
| 1141 | + ? $GLOBALS['meta']['type_urls'] |
|
| 1144 | 1142 | : $GLOBALS['type_urls']; // pour SPIP <2 |
| 1145 | 1143 | } |
| 1146 | 1144 | |
@@ -1163,7 +1161,7 @@ discard block |
||
| 1163 | 1161 | } |
| 1164 | 1162 | if ($res) return $res; |
| 1165 | 1163 | // Sinon c'est un raccourci ou compat SPIP < 2 |
| 1166 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1164 | + if (!function_exists($f = 'generer_url_'.$entite)) { |
|
| 1167 | 1165 | if (!function_exists($f .= '_dist')) $f = ''; |
| 1168 | 1166 | } |
| 1169 | 1167 | if ($f) { |
@@ -1179,23 +1177,23 @@ discard block |
||
| 1179 | 1177 | return ''; |
| 1180 | 1178 | } |
| 1181 | 1179 | |
| 1182 | -function generer_url_ecrire_entite_edit($id, $entite, $args='', $ancre=''){ |
|
| 1183 | - $exec = objet_info($entite,'url_edit'); |
|
| 1184 | - $url = generer_url_ecrire($exec,$args); |
|
| 1180 | +function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
|
| 1181 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1182 | + $url = generer_url_ecrire($exec, $args); |
|
| 1185 | 1183 | if (intval($id)) |
| 1186 | - $url = parametre_url($url,id_table_objet($entite),$id); |
|
| 1184 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1187 | 1185 | else |
| 1188 | - $url = parametre_url($url,'new','oui'); |
|
| 1186 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1189 | 1187 | if ($ancre) |
| 1190 | - $url = ancre_url($url,$ancre); |
|
| 1188 | + $url = ancre_url($url, $ancre); |
|
| 1191 | 1189 | return $url; |
| 1192 | 1190 | } |
| 1193 | 1191 | |
| 1194 | 1192 | // http://doc.spip.org/@urls_connect_dist |
| 1195 | -function urls_connect_dist($i, &$entite, $args='', $ancre='', $public=null) { |
|
| 1193 | +function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
|
| 1196 | 1194 | include_spip('base/connect_sql'); |
| 1197 | - $id_type = id_table_objet($entite,$public); |
|
| 1198 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1195 | + $id_type = id_table_objet($entite, $public); |
|
| 1196 | + return _DIR_RACINE.get_spip_script('./') |
|
| 1199 | 1197 | . "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
| 1200 | 1198 | . (!$args ? '' : "&$args") |
| 1201 | 1199 | . (!$ancre ? '' : "#$ancre"); |
@@ -1204,9 +1202,9 @@ discard block |
||
| 1204 | 1202 | |
| 1205 | 1203 | // Transformer les caracteres utf8 d'une URL (farsi par ex) selon la RFC 1738 |
| 1206 | 1204 | function urlencode_1738($url) { |
| 1207 | - if (preg_match(',[^\x00-\x7E],sS', $url)){ |
|
| 1205 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1208 | 1206 | $uri = ''; |
| 1209 | - for ($i=0; $i < strlen($url); $i++) { |
|
| 1207 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1210 | 1208 | if (ord($a = $url[$i]) > 127) |
| 1211 | 1209 | $a = rawurlencode($a); |
| 1212 | 1210 | $uri .= $a; |
@@ -1217,7 +1215,7 @@ discard block |
||
| 1217 | 1215 | } |
| 1218 | 1216 | |
| 1219 | 1217 | // http://doc.spip.org/@generer_url_entite_absolue |
| 1220 | -function generer_url_entite_absolue($id='', $entite='', $args='', $ancre='', $connect=NULL) |
|
| 1218 | +function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = NULL) |
|
| 1221 | 1219 | { |
| 1222 | 1220 | if (!$connect) $connect = true; |
| 1223 | 1221 | $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
@@ -1256,11 +1254,11 @@ discard block |
||
| 1256 | 1254 | * si array : reinitialise le tableau static complet avec la valeur fournie |
| 1257 | 1255 | * @return string|array |
| 1258 | 1256 | */ |
| 1259 | -function url_de_base($profondeur=null) { |
|
| 1257 | +function url_de_base($profondeur = null) { |
|
| 1260 | 1258 | |
| 1261 | 1259 | static $url = array(); |
| 1262 | 1260 | if (is_array($profondeur)) return $url = $profondeur; |
| 1263 | - if ($profondeur===false) return $url; |
|
| 1261 | + if ($profondeur === false) return $url; |
|
| 1264 | 1262 | |
| 1265 | 1263 | if (is_null($profondeur)) $profondeur = $GLOBALS['profondeur_url']; |
| 1266 | 1264 | |
@@ -1269,7 +1267,7 @@ discard block |
||
| 1269 | 1267 | |
| 1270 | 1268 | $http = ( |
| 1271 | 1269 | (isset($_SERVER["SCRIPT_URI"]) AND |
| 1272 | - substr($_SERVER["SCRIPT_URI"],0,5) == 'https') |
|
| 1270 | + substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https') |
|
| 1273 | 1271 | OR (isset($_SERVER['HTTPS']) AND |
| 1274 | 1272 | test_valeur_serveur($_SERVER['HTTPS'])) |
| 1275 | 1273 | ) ? 'https' : 'http'; |
@@ -1284,12 +1282,12 @@ discard block |
||
| 1284 | 1282 | } |
| 1285 | 1283 | } |
| 1286 | 1284 | if (isset($_SERVER['SERVER_PORT']) |
| 1287 | - AND $port=$_SERVER['SERVER_PORT'] |
|
| 1288 | - AND strpos($host,":")==false){ |
|
| 1289 | - if ($http=="http" AND $port!=80) $host.=":$port"; |
|
| 1290 | - if ($http=="https" AND $port!=443) $host.=":$port"; |
|
| 1285 | + AND $port = $_SERVER['SERVER_PORT'] |
|
| 1286 | + AND strpos($host, ":") == false) { |
|
| 1287 | + if ($http == "http" AND $port != 80) $host .= ":$port"; |
|
| 1288 | + if ($http == "https" AND $port != 443) $host .= ":$port"; |
|
| 1291 | 1289 | } |
| 1292 | - if (!$GLOBALS['REQUEST_URI']){ |
|
| 1290 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 1293 | 1291 | if (isset($_SERVER['REQUEST_URI'])) { |
| 1294 | 1292 | $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
| 1295 | 1293 | } else { |
@@ -1300,7 +1298,7 @@ discard block |
||
| 1300 | 1298 | } |
| 1301 | 1299 | } |
| 1302 | 1300 | |
| 1303 | - $url[$profondeur] = url_de_($http,$host,$GLOBALS['REQUEST_URI'],$profondeur); |
|
| 1301 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 1304 | 1302 | |
| 1305 | 1303 | return $url[$profondeur]; |
| 1306 | 1304 | } |
@@ -1312,25 +1310,25 @@ discard block |
||
| 1312 | 1310 | * @param int $prof |
| 1313 | 1311 | * @return string |
| 1314 | 1312 | */ |
| 1315 | -function url_de_($http,$host,$request,$prof=0){ |
|
| 1316 | - $prof = max($prof,0); |
|
| 1313 | +function url_de_($http, $host, $request, $prof = 0) { |
|
| 1314 | + $prof = max($prof, 0); |
|
| 1317 | 1315 | |
| 1318 | - $myself = ltrim($request,'/'); |
|
| 1316 | + $myself = ltrim($request, '/'); |
|
| 1319 | 1317 | # supprimer la chaine de GET |
| 1320 | 1318 | list($myself) = explode('?', $myself); |
| 1321 | 1319 | // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
| 1322 | 1320 | // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
| 1323 | - if (strpos($myself,'://') !== false) { |
|
| 1324 | - $myself = explode('://',$myself); |
|
| 1321 | + if (strpos($myself, '://') !== false) { |
|
| 1322 | + $myself = explode('://', $myself); |
|
| 1325 | 1323 | array_shift($myself); |
| 1326 | - $myself = implode('://',$myself); |
|
| 1327 | - $myself = explode('/',$myself); |
|
| 1324 | + $myself = implode('://', $myself); |
|
| 1325 | + $myself = explode('/', $myself); |
|
| 1328 | 1326 | array_shift($myself); |
| 1329 | - $myself = implode('/',$myself); |
|
| 1327 | + $myself = implode('/', $myself); |
|
| 1330 | 1328 | } |
| 1331 | - $url = join('/', array_slice(explode('/', $myself), 0, -1-$prof)).'/'; |
|
| 1329 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 1332 | 1330 | |
| 1333 | - $url = $http.'://'.rtrim($host,'/').'/'.ltrim($url,'/'); |
|
| 1331 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 1334 | 1332 | return $url; |
| 1335 | 1333 | } |
| 1336 | 1334 | |
@@ -1344,24 +1342,24 @@ discard block |
||
| 1344 | 1342 | // http://httpd.apache.org/docs/2.0/mod/mod_dir.html |
| 1345 | 1343 | |
| 1346 | 1344 | // http://doc.spip.org/@generer_url_ecrire |
| 1347 | -function generer_url_ecrire($script='', $args="", $no_entities=false, $rel=false) { |
|
| 1345 | +function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { |
|
| 1348 | 1346 | if (!$rel) |
| 1349 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 1347 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 1350 | 1348 | else if (!is_string($rel)) |
| 1351 | 1349 | $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
| 1352 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 1350 | + ('./'._SPIP_ECRIRE_SCRIPT); |
|
| 1353 | 1351 | |
| 1354 | 1352 | @list($script, $ancre) = explode('#', $script); |
| 1355 | - if ($script AND ($script<>'accueil' OR $rel)) |
|
| 1356 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 1353 | + if ($script AND ($script <> 'accueil' OR $rel)) |
|
| 1354 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 1357 | 1355 | elseif ($args) |
| 1358 | - $args ="?$args"; |
|
| 1356 | + $args = "?$args"; |
|
| 1359 | 1357 | if ($ancre) $args .= "#$ancre"; |
| 1360 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 1358 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 1361 | 1359 | } |
| 1362 | 1360 | |
| 1363 | 1361 | // http://doc.spip.org/@generer_url_retour |
| 1364 | -function generer_url_retour($script, $args="") |
|
| 1362 | +function generer_url_retour($script, $args = "") |
|
| 1365 | 1363 | { |
| 1366 | 1364 | return rawurlencode(generer_url_ecrire($script, $args, true, true)); |
| 1367 | 1365 | } |
@@ -1373,7 +1371,7 @@ discard block |
||
| 1373 | 1371 | // Detecter le fichier de base, a la racine, comme etant spip.php ou '' |
| 1374 | 1372 | // dans le cas de '', un $default = './' peut servir (comme dans urls/page.php) |
| 1375 | 1373 | // http://doc.spip.org/@get_spip_script |
| 1376 | -function get_spip_script($default='') { |
|
| 1374 | +function get_spip_script($default = '') { |
|
| 1377 | 1375 | # cas define('_SPIP_SCRIPT', ''); |
| 1378 | 1376 | if (_SPIP_SCRIPT) |
| 1379 | 1377 | return _SPIP_SCRIPT; |
@@ -1382,7 +1380,7 @@ discard block |
||
| 1382 | 1380 | } |
| 1383 | 1381 | |
| 1384 | 1382 | // http://doc.spip.org/@generer_url_public |
| 1385 | -function generer_url_public($script='', $args="", $no_entities=false, $rel=true, $action='') { |
|
| 1383 | +function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') { |
|
| 1386 | 1384 | // si le script est une action (spip_pass, spip_inscription), |
| 1387 | 1385 | // standardiser vers la nouvelle API |
| 1388 | 1386 | |
@@ -1393,23 +1391,23 @@ discard block |
||
| 1393 | 1391 | if ($args) { |
| 1394 | 1392 | if (is_array($args)) { |
| 1395 | 1393 | $r = ''; |
| 1396 | - foreach($args as $k => $v) $r .= '&' . $k . '=' . $v; |
|
| 1397 | - $args = substr($r,1); |
|
| 1394 | + foreach ($args as $k => $v) $r .= '&'.$k.'='.$v; |
|
| 1395 | + $args = substr($r, 1); |
|
| 1398 | 1396 | } |
| 1399 | 1397 | $action .= |
| 1400 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 1398 | + (strpos($action, '?') !== false ? '&' : '?').$args; |
|
| 1401 | 1399 | } |
| 1402 | 1400 | if (!$no_entities) |
| 1403 | 1401 | $action = quote_amp($action); |
| 1404 | 1402 | |
| 1405 | 1403 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 1406 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(),'/') . preg_replace(",^/[.]/,","/","/$action")); |
|
| 1404 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 1407 | 1405 | } |
| 1408 | 1406 | |
| 1409 | 1407 | // http://doc.spip.org/@generer_url_prive |
| 1410 | -function generer_url_prive($script, $args="", $no_entities=false) { |
|
| 1408 | +function generer_url_prive($script, $args = "", $no_entities = false) { |
|
| 1411 | 1409 | |
| 1412 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 1410 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 1413 | 1411 | } |
| 1414 | 1412 | |
| 1415 | 1413 | // Pour les formulaires en methode POST, |
@@ -1418,7 +1416,7 @@ discard block |
||
| 1418 | 1416 | // 2) ca suit http://en.wikipedia.org/wiki/Representational_State_Transfer |
| 1419 | 1417 | |
| 1420 | 1418 | // http://doc.spip.org/@generer_form_ecrire |
| 1421 | -function generer_form_ecrire($script, $corps, $atts='', $submit='') { |
|
| 1419 | +function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
|
| 1422 | 1420 | global $spip_lang_right; |
| 1423 | 1421 | |
| 1424 | 1422 | $script1 = explode('&', $script); |
@@ -1431,8 +1429,7 @@ discard block |
||
| 1431 | 1429 | . "><div>\n" |
| 1432 | 1430 | . "<input type='hidden' name='exec' value='$script1' />" |
| 1433 | 1431 | . $corps |
| 1434 | - . (!$submit ? '' : |
|
| 1435 | - ("<div style='text-align: $spip_lang_right'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>")) |
|
| 1432 | + . (!$submit ? '' : ("<div style='text-align: $spip_lang_right'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>")) |
|
| 1436 | 1433 | . "</div></form>\n"; |
| 1437 | 1434 | } |
| 1438 | 1435 | |
@@ -1450,7 +1447,7 @@ discard block |
||
| 1450 | 1447 | * @param bool $public |
| 1451 | 1448 | * @return string |
| 1452 | 1449 | */ |
| 1453 | -function generer_form_action($script, $corps, $atts='', $public=false) { |
|
| 1450 | +function generer_form_action($script, $corps, $atts = '', $public = false) { |
|
| 1454 | 1451 | // si l'on est dans l'espace prive, on garde dans l'url |
| 1455 | 1452 | // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
| 1456 | 1453 | // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
@@ -1458,29 +1455,29 @@ discard block |
||
| 1458 | 1455 | ? generer_url_ecrire(_request('exec')) |
| 1459 | 1456 | : generer_url_public(); |
| 1460 | 1457 | |
| 1461 | - return "\n<form action='" . |
|
| 1462 | - $h . |
|
| 1463 | - "'" . |
|
| 1464 | - $atts . |
|
| 1465 | - ">\n" . |
|
| 1466 | - "<div>" . |
|
| 1467 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 1468 | - $corps . |
|
| 1458 | + return "\n<form action='". |
|
| 1459 | + $h. |
|
| 1460 | + "'". |
|
| 1461 | + $atts. |
|
| 1462 | + ">\n". |
|
| 1463 | + "<div>". |
|
| 1464 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 1465 | + $corps. |
|
| 1469 | 1466 | "</div></form>"; |
| 1470 | 1467 | } |
| 1471 | 1468 | |
| 1472 | 1469 | // http://doc.spip.org/@generer_url_action |
| 1473 | -function generer_url_action($script, $args="", $no_entities=false , $public = false) { |
|
| 1470 | +function generer_url_action($script, $args = "", $no_entities = false, $public = false) { |
|
| 1474 | 1471 | // si l'on est dans l'espace prive, on garde dans l'url |
| 1475 | 1472 | // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
| 1476 | 1473 | // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
| 1477 | - $url = (_DIR_RACINE AND !$public) |
|
| 1474 | + $url = (_DIR_RACINE AND !$public) |
|
| 1478 | 1475 | ? generer_url_ecrire(_request('exec')) |
| 1479 | - : generer_url_public('','',false,false); |
|
| 1480 | - $url = parametre_url($url,'action',$script); |
|
| 1476 | + : generer_url_public('', '', false, false); |
|
| 1477 | + $url = parametre_url($url, 'action', $script); |
|
| 1481 | 1478 | if ($args) $url .= quote_amp('&'.$args); |
| 1482 | 1479 | |
| 1483 | - if ($no_entities) $url = str_replace('&','&',$url); |
|
| 1480 | + if ($no_entities) $url = str_replace('&', '&', $url); |
|
| 1484 | 1481 | return $url; |
| 1485 | 1482 | } |
| 1486 | 1483 | |
@@ -1493,8 +1490,8 @@ discard block |
||
| 1493 | 1490 | * @param string $ti |
| 1494 | 1491 | * @param string $ta |
| 1495 | 1492 | */ |
| 1496 | -function spip_initialisation($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) { |
|
| 1497 | - spip_initialisation_core($pi,$pa,$ti,$ta); |
|
| 1493 | +function spip_initialisation($pi = NULL, $pa = NULL, $ti = NULL, $ta = NULL) { |
|
| 1494 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 1498 | 1495 | spip_initialisation_suite(); |
| 1499 | 1496 | } |
| 1500 | 1497 | |
@@ -1512,32 +1509,32 @@ discard block |
||
| 1512 | 1509 | * @param string $ti |
| 1513 | 1510 | * @param string $ta |
| 1514 | 1511 | */ |
| 1515 | -function spip_initialisation_core($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) { |
|
| 1512 | +function spip_initialisation_core($pi = NULL, $pa = NULL, $ti = NULL, $ta = NULL) { |
|
| 1516 | 1513 | static $too_late = 0; |
| 1517 | 1514 | if ($too_late++) return; |
| 1518 | 1515 | |
| 1519 | 1516 | // Declaration des repertoires |
| 1520 | 1517 | |
| 1521 | 1518 | // le nom du repertoire plugins/ activables/desactivables |
| 1522 | - if (!defined('_DIR_PLUGINS')) define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 1519 | + if (!defined('_DIR_PLUGINS')) define('_DIR_PLUGINS', _DIR_RACINE."plugins/"); |
|
| 1523 | 1520 | |
| 1524 | 1521 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 1525 | - if (!defined('_DIR_PLUGINS_DIST')) define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 1522 | + if (!defined('_DIR_PLUGINS_DIST')) define('_DIR_PLUGINS_DIST', _DIR_RACINE."plugins-dist/"); |
|
| 1526 | 1523 | |
| 1527 | 1524 | // le nom du repertoire des librairies |
| 1528 | - if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 1525 | + if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE."lib/"); |
|
| 1529 | 1526 | |
| 1530 | 1527 | if (!defined('_DIR_IMG')) define('_DIR_IMG', $pa); |
| 1531 | 1528 | if (!defined('_DIR_LOGOS')) define('_DIR_LOGOS', $pa); |
| 1532 | - if (!defined('_DIR_IMG_ICONES')) define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 1533 | - |
|
| 1534 | - if (!defined('_DIR_DUMP')) define('_DIR_DUMP', $ti . "dump/"); |
|
| 1535 | - if (!defined('_DIR_SESSIONS')) define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 1536 | - if (!defined('_DIR_TRANSFERT')) define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 1537 | - if (!defined('_DIR_CACHE')) define('_DIR_CACHE', $ti . "cache/"); |
|
| 1538 | - if (!defined('_DIR_CACHE_XML')) define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 1539 | - if (!defined('_DIR_SKELS')) define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 1540 | - if (!defined('_DIR_AIDE')) define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 1529 | + if (!defined('_DIR_IMG_ICONES')) define('_DIR_IMG_ICONES', _DIR_LOGOS."icones/"); |
|
| 1530 | + |
|
| 1531 | + if (!defined('_DIR_DUMP')) define('_DIR_DUMP', $ti."dump/"); |
|
| 1532 | + if (!defined('_DIR_SESSIONS')) define('_DIR_SESSIONS', $ti."sessions/"); |
|
| 1533 | + if (!defined('_DIR_TRANSFERT')) define('_DIR_TRANSFERT', $ti."upload/"); |
|
| 1534 | + if (!defined('_DIR_CACHE')) define('_DIR_CACHE', $ti."cache/"); |
|
| 1535 | + if (!defined('_DIR_CACHE_XML')) define('_DIR_CACHE_XML', _DIR_CACHE."xml/"); |
|
| 1536 | + if (!defined('_DIR_SKELS')) define('_DIR_SKELS', _DIR_CACHE."skel/"); |
|
| 1537 | + if (!defined('_DIR_AIDE')) define('_DIR_AIDE', _DIR_CACHE."aide/"); |
|
| 1541 | 1538 | if (!defined('_DIR_TMP')) define('_DIR_TMP', $ti); |
| 1542 | 1539 | |
| 1543 | 1540 | if (!defined('_DIR_VAR')) define('_DIR_VAR', $ta); |
@@ -1549,19 +1546,19 @@ discard block |
||
| 1549 | 1546 | if (!isset($GLOBALS['test_dirs'])) |
| 1550 | 1547 | // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
| 1551 | 1548 | // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
| 1552 | - $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 1549 | + $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 1553 | 1550 | |
| 1554 | 1551 | // Declaration des fichiers |
| 1555 | 1552 | |
| 1556 | - if (!defined('_CACHE_PLUGINS_PATH')) define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 1557 | - if (!defined('_CACHE_PLUGINS_OPT')) define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 1558 | - if (!defined('_CACHE_PLUGINS_FCT')) define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 1559 | - if (!defined('_CACHE_PIPELINES')) define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 1560 | - if (!defined('_CACHE_CHEMIN')) define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 1553 | + if (!defined('_CACHE_PLUGINS_PATH')) define('_CACHE_PLUGINS_PATH', _DIR_CACHE."charger_plugins_chemins.php"); |
|
| 1554 | + if (!defined('_CACHE_PLUGINS_OPT')) define('_CACHE_PLUGINS_OPT', _DIR_CACHE."charger_plugins_options.php"); |
|
| 1555 | + if (!defined('_CACHE_PLUGINS_FCT')) define('_CACHE_PLUGINS_FCT', _DIR_CACHE."charger_plugins_fonctions.php"); |
|
| 1556 | + if (!defined('_CACHE_PIPELINES')) define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 1557 | + if (!defined('_CACHE_CHEMIN')) define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 1561 | 1558 | |
| 1562 | 1559 | # attention .php obligatoire pour ecrire_fichier_securise |
| 1563 | - if (!defined('_FILE_META')) define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 1564 | - if (!defined('_DIR_LOG')) define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 1560 | + if (!defined('_FILE_META')) define('_FILE_META', $ti.'meta_cache.php'); |
|
| 1561 | + if (!defined('_DIR_LOG')) define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 1565 | 1562 | if (!defined('_FILE_LOG')) define('_FILE_LOG', 'spip'); |
| 1566 | 1563 | if (!defined('_FILE_LOG_SUFFIX')) define('_FILE_LOG_SUFFIX', '.log'); |
| 1567 | 1564 | |
@@ -1569,21 +1566,21 @@ discard block |
||
| 1569 | 1566 | // tient compte des anciennes versions (inc_connect...) |
| 1570 | 1567 | if (!defined('_FILE_CONNECT_INS')) define('_FILE_CONNECT_INS', 'connect'); |
| 1571 | 1568 | if (!defined('_FILE_CONNECT')) define('_FILE_CONNECT', |
| 1572 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 1573 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 1569 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f |
|
| 1570 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f |
|
| 1574 | 1571 | : false))); |
| 1575 | 1572 | |
| 1576 | 1573 | // Le fichier de reglages des droits |
| 1577 | 1574 | if (!defined('_FILE_CHMOD_INS')) define('_FILE_CHMOD_INS', 'chmod'); |
| 1578 | 1575 | if (!defined('_FILE_CHMOD')) define('_FILE_CHMOD', |
| 1579 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 1576 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f |
|
| 1580 | 1577 | : false)); |
| 1581 | 1578 | |
| 1582 | 1579 | if (!defined('_FILE_LDAP')) define('_FILE_LDAP', 'ldap.php'); |
| 1583 | 1580 | |
| 1584 | 1581 | if (!defined('_FILE_TMP_SUFFIX')) define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 1585 | - if (!defined('_FILE_CONNECT_TMP')) define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 1586 | - if (!defined('_FILE_CHMOD_TMP')) define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 1582 | + if (!defined('_FILE_CONNECT_TMP')) define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 1583 | + if (!defined('_FILE_CHMOD_TMP')) define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 1587 | 1584 | |
| 1588 | 1585 | // Definition des droits d'acces en ecriture |
| 1589 | 1586 | if (!defined('_SPIP_CHMOD') AND _FILE_CHMOD) |
@@ -1594,31 +1591,31 @@ discard block |
||
| 1594 | 1591 | |
| 1595 | 1592 | // Le charset par defaut lors de l'installation |
| 1596 | 1593 | if (!defined('_DEFAULT_CHARSET')) define('_DEFAULT_CHARSET', 'utf-8'); |
| 1597 | - if (!defined('_ROOT_PLUGINS')) define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 1598 | - if (!defined('_ROOT_PLUGINS_DIST')) define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 1599 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE,'',_DIR_PLUGINS_SUPPL)); |
|
| 1594 | + if (!defined('_ROOT_PLUGINS')) define('_ROOT_PLUGINS', _ROOT_RACINE."plugins/"); |
|
| 1595 | + if (!defined('_ROOT_PLUGINS_DIST')) define('_ROOT_PLUGINS_DIST', _ROOT_RACINE."plugins-dist/"); |
|
| 1596 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 1600 | 1597 | |
| 1601 | 1598 | // La taille des Log |
| 1602 | 1599 | if (!defined('_MAX_LOG')) define('_MAX_LOG', 100); |
| 1603 | 1600 | |
| 1604 | 1601 | // Sommes-nous dans l'empire du Mal ? |
| 1605 | 1602 | // (ou sous le signe du Pingouin, ascendant GNU ?) |
| 1606 | - if (strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false){ |
|
| 1603 | + if (strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 1607 | 1604 | if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', 'windows'); |
| 1608 | - if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1605 | + if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE', 1); // utiliser le flock php |
|
| 1609 | 1606 | } |
| 1610 | 1607 | else { |
| 1611 | 1608 | if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', ''); |
| 1612 | - if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1609 | + if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE', 1); // utiliser le flock php |
|
| 1613 | 1610 | #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
| 1614 | 1611 | } |
| 1615 | 1612 | |
| 1616 | 1613 | // Langue par defaut |
| 1617 | - if (!defined('_LANGUE_PAR_DEFAUT')) define('_LANGUE_PAR_DEFAUT','fr'); |
|
| 1614 | + if (!defined('_LANGUE_PAR_DEFAUT')) define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 1618 | 1615 | |
| 1619 | 1616 | // PHP_VERSION_ID dispo depuis PHP 5.2.7 |
| 1620 | 1617 | if (!defined('PHP_VERSION_ID')) { |
| 1621 | - $version = explode('.',PHP_VERSION); |
|
| 1618 | + $version = explode('.', PHP_VERSION); |
|
| 1622 | 1619 | define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); |
| 1623 | 1620 | } |
| 1624 | 1621 | |
@@ -1627,7 +1624,7 @@ discard block |
||
| 1627 | 1624 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 1628 | 1625 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 1629 | 1626 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 1630 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1627 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 1631 | 1628 | |
| 1632 | 1629 | // charger tout de suite le path et son cache |
| 1633 | 1630 | load_path_cache(); |
@@ -1647,7 +1644,7 @@ discard block |
||
| 1647 | 1644 | spip_desinfecte($_REQUEST); |
| 1648 | 1645 | |
| 1649 | 1646 | // Par ailleurs on ne veut pas de magic_quotes au cours de l'execution |
| 1650 | - if (PHP_VERSION_ID<50300) { |
|
| 1647 | + if (PHP_VERSION_ID < 50300) { |
|
| 1651 | 1648 | @set_magic_quotes_runtime(0); |
| 1652 | 1649 | } |
| 1653 | 1650 | |
@@ -1657,7 +1654,7 @@ discard block |
||
| 1657 | 1654 | if (test_valeur_serveur(@ini_get('register_globals'))) { |
| 1658 | 1655 | // ne pas desinfecter les globales en profondeur car elle contient aussi les |
| 1659 | 1656 | // precedentes, qui seraient desinfectees 2 fois. |
| 1660 | - spip_desinfecte($GLOBALS,false); |
|
| 1657 | + spip_desinfecte($GLOBALS, false); |
|
| 1661 | 1658 | if (include_spip('inc/php3')) |
| 1662 | 1659 | spip_register_globals(true); |
| 1663 | 1660 | |
@@ -1701,8 +1698,8 @@ discard block |
||
| 1701 | 1698 | $inc_meta(); |
| 1702 | 1699 | |
| 1703 | 1700 | // on a pas pu le faire plus tot |
| 1704 | - if ($avertir_register_globals) |
|
| 1705 | - avertir_auteurs("register_globals",_L("Problème de sécurité : register_globals=on; dans php.ini à corriger.")); |
|
| 1701 | + if ($avertir_register_globals) |
|
| 1702 | + avertir_auteurs("register_globals", _L("Problème de sécurité : register_globals=on; dans php.ini à corriger.")); |
|
| 1706 | 1703 | |
| 1707 | 1704 | // nombre de repertoires depuis la racine |
| 1708 | 1705 | // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
@@ -1718,7 +1715,7 @@ discard block |
||
| 1718 | 1715 | // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
| 1719 | 1716 | // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
| 1720 | 1717 | // s'en remettre a l'adresse du site. alea jacta est. |
| 1721 | - OR $ti!==_NOM_TEMPORAIRES_INACCESSIBLES){ |
|
| 1718 | + OR $ti !== _NOM_TEMPORAIRES_INACCESSIBLES) { |
|
| 1722 | 1719 | |
| 1723 | 1720 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 1724 | 1721 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
@@ -1732,12 +1729,12 @@ discard block |
||
| 1732 | 1729 | else { |
| 1733 | 1730 | $GLOBALS['profondeur_url'] = max(0, |
| 1734 | 1731 | substr_count($uri[0], '/') |
| 1735 | - - substr_count($uri_ref,'/')); |
|
| 1732 | + - substr_count($uri_ref, '/')); |
|
| 1736 | 1733 | } |
| 1737 | 1734 | } |
| 1738 | 1735 | // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
| 1739 | 1736 | if (_FILE_CONNECT) { |
| 1740 | - if (verifier_visiteur()=='0minirezo' |
|
| 1737 | + if (verifier_visiteur() == '0minirezo' |
|
| 1741 | 1738 | // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
| 1742 | 1739 | AND !isset($_COOKIE['spip_admin'])) |
| 1743 | 1740 | clear_path_cache(); |
@@ -1767,7 +1764,7 @@ discard block |
||
| 1767 | 1764 | if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
| 1768 | 1765 | if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
| 1769 | 1766 | if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
| 1770 | - if (!defined('_PASS_LONGUEUR_MINI')) define('_PASS_LONGUEUR_MINI',6); |
|
| 1767 | + if (!defined('_PASS_LONGUEUR_MINI')) define('_PASS_LONGUEUR_MINI', 6); |
|
| 1771 | 1768 | |
| 1772 | 1769 | |
| 1773 | 1770 | // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
@@ -1777,7 +1774,7 @@ discard block |
||
| 1777 | 1774 | // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
| 1778 | 1775 | if (!defined('_IMG_IMAGICK_QUALITE')) define('_IMG_IMAGICK_QUALITE', 75); # surcharge pour imagick en PHP |
| 1779 | 1776 | |
| 1780 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) define('_COPIE_LOCALE_MAX_SIZE',16777216); // poids en octet |
|
| 1777 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) define('_COPIE_LOCALE_MAX_SIZE', 16777216); // poids en octet |
|
| 1781 | 1778 | |
| 1782 | 1779 | // qq chaines standard |
| 1783 | 1780 | if (!defined('_ACCESS_FILE_NAME')) define('_ACCESS_FILE_NAME', '.htaccess'); |
@@ -1809,7 +1806,7 @@ discard block |
||
| 1809 | 1806 | // meme pb sur thttpd cf. http://forum.spip.org/fr_184153.html |
| 1810 | 1807 | |
| 1811 | 1808 | if (!defined('_SPIP_ECRIRE_SCRIPT')) define('_SPIP_ECRIRE_SCRIPT', // true ? #decommenter ici et commenter la |
| 1812 | - preg_match(',IIS|thttpd,',$_SERVER['SERVER_SOFTWARE']) ? |
|
| 1809 | + preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE']) ? |
|
| 1813 | 1810 | 'index.php' : ''); |
| 1814 | 1811 | |
| 1815 | 1812 | |
@@ -1832,32 +1829,32 @@ discard block |
||
| 1832 | 1829 | # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
| 1833 | 1830 | # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
| 1834 | 1831 | if (!defined('_IMG_GD_MAX_PIXELS')) define('_IMG_GD_MAX_PIXELS', |
| 1835 | - (isset($GLOBALS['meta']['max_taille_vignettes'])&&$GLOBALS['meta']['max_taille_vignettes']<5500000) |
|
| 1832 | + (isset($GLOBALS['meta']['max_taille_vignettes']) && $GLOBALS['meta']['max_taille_vignettes'] < 5500000) |
|
| 1836 | 1833 | ? $GLOBALS['meta']['max_taille_vignettes'] |
| 1837 | 1834 | : 0); |
| 1838 | 1835 | |
| 1839 | - if (!defined('_MEMORY_LIMIT_MIN')) define('_MEMORY_LIMIT_MIN',10); // en Mo |
|
| 1836 | + if (!defined('_MEMORY_LIMIT_MIN')) define('_MEMORY_LIMIT_MIN', 10); // en Mo |
|
| 1840 | 1837 | // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
| 1841 | 1838 | // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
| 1842 | 1839 | // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
| 1843 | - if (test_espace_prive() AND _MEMORY_LIMIT_MIN>8){ |
|
| 1840 | + if (test_espace_prive() AND _MEMORY_LIMIT_MIN > 8) { |
|
| 1844 | 1841 | if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
| 1845 | - $unit = strtolower(substr($memory,strlen($memory/1),1)); |
|
| 1846 | - switch($unit) { |
|
| 1842 | + $unit = strtolower(substr($memory, strlen($memory / 1), 1)); |
|
| 1843 | + switch ($unit) { |
|
| 1847 | 1844 | // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
| 1848 | 1845 | case 'g': $memory *= 1024; |
| 1849 | 1846 | case 'm': $memory *= 1024; |
| 1850 | 1847 | case 'k': $memory *= 1024; |
| 1851 | 1848 | } |
| 1852 | - if ($memory<_MEMORY_LIMIT_MIN*1024*1024){ |
|
| 1853 | - ini_set('memory_limit',$m=_MEMORY_LIMIT_MIN.'M'); |
|
| 1854 | - if (trim(ini_get('memory_limit'))!=$m){ |
|
| 1855 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1849 | + if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 1850 | + ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M'); |
|
| 1851 | + if (trim(ini_get('memory_limit')) != $m) { |
|
| 1852 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1856 | 1853 | } |
| 1857 | 1854 | } |
| 1858 | 1855 | } |
| 1859 | 1856 | else |
| 1860 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1857 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1861 | 1858 | } |
| 1862 | 1859 | // Protocoles a normaliser dans les chaines de langues |
| 1863 | 1860 | if (!defined('_PROTOCOLES_STD')) |
@@ -1869,7 +1866,7 @@ discard block |
||
| 1869 | 1866 | // Reperer les variables d'URL qui conditionnent la perennite du cache, des urls |
| 1870 | 1867 | // ou d'autres petit caches (trouver_table, css et js compactes ...) |
| 1871 | 1868 | // http://doc.spip.org/@init_var_mode |
| 1872 | -function init_var_mode(){ |
|
| 1869 | +function init_var_mode() { |
|
| 1873 | 1870 | static $done = false; |
| 1874 | 1871 | if (!$done) { |
| 1875 | 1872 | |
@@ -1877,56 +1874,56 @@ discard block |
||
| 1877 | 1874 | // tout le monde peut calcul/recalcul |
| 1878 | 1875 | if ($_GET['var_mode'] == 'calcul' |
| 1879 | 1876 | OR $_GET['var_mode'] == 'recalcul') { |
| 1880 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 1877 | + if (!defined('_VAR_MODE')) define('_VAR_MODE', $_GET['var_mode']); |
|
| 1881 | 1878 | } |
| 1882 | 1879 | // preview, debug, blocs, urls et images necessitent une autorisation |
| 1883 | - else if (in_array($_GET['var_mode'],array('preview','debug','inclure','urls','images','traduction'))) { |
|
| 1880 | + else if (in_array($_GET['var_mode'], array('preview', 'debug', 'inclure', 'urls', 'images', 'traduction'))) { |
|
| 1884 | 1881 | include_spip('inc/autoriser'); |
| 1885 | 1882 | if (autoriser( |
| 1886 | 1883 | ($_GET['var_mode'] == 'preview') |
| 1887 | 1884 | ? 'previsualiser' |
| 1888 | 1885 | : 'debug' |
| 1889 | 1886 | )) { |
| 1890 | - switch($_GET['var_mode']){ |
|
| 1887 | + switch ($_GET['var_mode']) { |
|
| 1891 | 1888 | case 'traduction': |
| 1892 | 1889 | // forcer le calcul pour passer dans traduire |
| 1893 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1890 | + if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul'); |
|
| 1894 | 1891 | // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
| 1895 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1892 | + if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE', true); |
|
| 1896 | 1893 | break; |
| 1897 | 1894 | case 'preview': |
| 1898 | 1895 | // basculer sur les criteres de preview dans les boucles |
| 1899 | - if (!defined('_VAR_PREVIEW')) define('_VAR_PREVIEW',true); |
|
| 1896 | + if (!defined('_VAR_PREVIEW')) define('_VAR_PREVIEW', true); |
|
| 1900 | 1897 | // forcer le calcul |
| 1901 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1898 | + if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul'); |
|
| 1902 | 1899 | // et ne pas enregistrer de cache |
| 1903 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1900 | + if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE', true); |
|
| 1904 | 1901 | break; |
| 1905 | 1902 | case 'inclure': |
| 1906 | 1903 | // forcer le compilo et ignorer les caches existants |
| 1907 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1908 | - if (!defined('_VAR_INCLURE')) define('_VAR_INCLURE',true); |
|
| 1904 | + if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul'); |
|
| 1905 | + if (!defined('_VAR_INCLURE')) define('_VAR_INCLURE', true); |
|
| 1909 | 1906 | // et ne pas enregistrer de cache |
| 1910 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1907 | + if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE', true); |
|
| 1911 | 1908 | break; |
| 1912 | 1909 | case 'urls': |
| 1913 | 1910 | // forcer le compilo et ignorer les caches existants |
| 1914 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1915 | - if (!defined('_VAR_URLS')) define('_VAR_URLS',true); |
|
| 1911 | + if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul'); |
|
| 1912 | + if (!defined('_VAR_URLS')) define('_VAR_URLS', true); |
|
| 1916 | 1913 | break; |
| 1917 | 1914 | case 'images': |
| 1918 | 1915 | // forcer le compilo et ignorer les caches existants |
| 1919 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1916 | + if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul'); |
|
| 1920 | 1917 | // indiquer qu'on doit recalculer les images |
| 1921 | - if (!defined('_VAR_IMAGES')) define('_VAR_IMAGES',true); |
|
| 1918 | + if (!defined('_VAR_IMAGES')) define('_VAR_IMAGES', true); |
|
| 1922 | 1919 | break; |
| 1923 | 1920 | case 'debug': |
| 1924 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','debug'); |
|
| 1921 | + if (!defined('_VAR_MODE')) define('_VAR_MODE', 'debug'); |
|
| 1925 | 1922 | // et ne pas enregistrer de cache |
| 1926 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 1923 | + if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE', true); |
|
| 1927 | 1924 | break; |
| 1928 | 1925 | default : |
| 1929 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 1926 | + if (!defined('_VAR_MODE')) define('_VAR_MODE', $_GET['var_mode']); |
|
| 1930 | 1927 | break; |
| 1931 | 1928 | } |
| 1932 | 1929 | if (isset($GLOBALS['visiteur_session']['nom'])) |
@@ -1946,7 +1943,7 @@ discard block |
||
| 1946 | 1943 | // sinon tant pis |
| 1947 | 1944 | } |
| 1948 | 1945 | } |
| 1949 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',false); |
|
| 1946 | + if (!defined('_VAR_MODE')) define('_VAR_MODE', false); |
|
| 1950 | 1947 | } |
| 1951 | 1948 | $done = true; |
| 1952 | 1949 | } |
@@ -1956,7 +1953,7 @@ discard block |
||
| 1956 | 1953 | // supprimer aussi les eventuels caracteres nuls %00, qui peuvent tromper |
| 1957 | 1954 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 1958 | 1955 | // http://doc.spip.org/@spip_desinfecte |
| 1959 | -function spip_desinfecte(&$t,$deep = true) { |
|
| 1956 | +function spip_desinfecte(&$t, $deep = true) { |
|
| 1960 | 1957 | static $magic_quotes; |
| 1961 | 1958 | if (!isset($magic_quotes)) |
| 1962 | 1959 | $magic_quotes = @get_magic_quotes_gpc(); |
@@ -1968,8 +1965,8 @@ discard block |
||
| 1968 | 1965 | $t[$key] = str_replace(chr(0), '-', $t[$key]); |
| 1969 | 1966 | } |
| 1970 | 1967 | // traiter aussi les "texte_plus" de article_edit |
| 1971 | - else if ($deep AND is_array($t[$key]) AND $key!=='GLOBALS') |
|
| 1972 | - spip_desinfecte($t[$key],$deep); |
|
| 1968 | + else if ($deep AND is_array($t[$key]) AND $key !== 'GLOBALS') |
|
| 1969 | + spip_desinfecte($t[$key], $deep); |
|
| 1973 | 1970 | } |
| 1974 | 1971 | } |
| 1975 | 1972 | |
@@ -1982,10 +1979,10 @@ discard block |
||
| 1982 | 1979 | // mais on risque de perturber des plugins en initialisant trop tot |
| 1983 | 1980 | // certaines constantes |
| 1984 | 1981 | @spip_initialisation_core( |
| 1985 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 1986 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 1987 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 1988 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 1982 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 1983 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 1984 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 1985 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 1989 | 1986 | ); |
| 1990 | 1987 | |
| 1991 | 1988 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
@@ -1993,7 +1990,7 @@ discard block |
||
| 1993 | 1990 | // Attention on separe bien session_nom et nom, pour eviter |
| 1994 | 1991 | // les melanges entre donnees SQL et variables plus aleatoires |
| 1995 | 1992 | $variables_session = array('session_nom', 'session_email'); |
| 1996 | - foreach($variables_session as $var) { |
|
| 1993 | + foreach ($variables_session as $var) { |
|
| 1997 | 1994 | if (_request($var) !== null) { |
| 1998 | 1995 | $init = true; |
| 1999 | 1996 | break; |
@@ -2004,7 +2001,7 @@ discard block |
||
| 2004 | 2001 | $session = charger_fonction('session', 'inc'); |
| 2005 | 2002 | $session(); |
| 2006 | 2003 | include_spip('inc/texte'); |
| 2007 | - foreach($variables_session as $var) |
|
| 2004 | + foreach ($variables_session as $var) |
|
| 2008 | 2005 | if (($a = _request($var)) !== null) |
| 2009 | 2006 | $GLOBALS['visiteur_session'][$var] = safehtml($a); |
| 2010 | 2007 | if (!isset($GLOBALS['visiteur_session']['id_auteur'])) |
@@ -2013,14 +2010,14 @@ discard block |
||
| 2013 | 2010 | return 0; |
| 2014 | 2011 | } |
| 2015 | 2012 | |
| 2016 | - $h = (isset($_SERVER['PHP_AUTH_USER']) AND !$GLOBALS['ignore_auth_http']); |
|
| 2013 | + $h = (isset($_SERVER['PHP_AUTH_USER']) AND !$GLOBALS['ignore_auth_http']); |
|
| 2017 | 2014 | if ($h OR isset($_COOKIE['spip_session']) OR isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
| 2018 | 2015 | |
| 2019 | 2016 | $session = charger_fonction('session', 'inc'); |
| 2020 | 2017 | if ($session()) { |
| 2021 | 2018 | return $GLOBALS['visiteur_session']['statut']; |
| 2022 | 2019 | } |
| 2023 | - if ($h AND isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 2020 | + if ($h AND isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 2024 | 2021 | include_spip('inc/auth'); |
| 2025 | 2022 | $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
| 2026 | 2023 | } |
@@ -2045,7 +2042,7 @@ discard block |
||
| 2045 | 2042 | // cette fonction retourne toujours non False |
| 2046 | 2043 | |
| 2047 | 2044 | // http://doc.spip.org/@lang_select |
| 2048 | -function lang_select ($lang=NULL) { |
|
| 2045 | +function lang_select($lang = NULL) { |
|
| 2049 | 2046 | static $pile_langues = array(); |
| 2050 | 2047 | if (!function_exists('changer_langue')) |
| 2051 | 2048 | include_spip('inc/lang'); |
@@ -2075,7 +2072,7 @@ discard block |
||
| 2075 | 2072 | $s = pipeline('definir_session', |
| 2076 | 2073 | $GLOBALS['visiteur_session'] |
| 2077 | 2074 | ? serialize($GLOBALS['visiteur_session']) |
| 2078 | - . '_' . @$_COOKIE['spip_session'] |
|
| 2075 | + . '_'.@$_COOKIE['spip_session'] |
|
| 2079 | 2076 | : '' |
| 2080 | 2077 | ); |
| 2081 | 2078 | $session = $s ? substr(md5($s), 0, 8) : ''; |
@@ -2097,9 +2094,9 @@ discard block |
||
| 2097 | 2094 | * @return Lien sur une icone d'aide |
| 2098 | 2095 | **/ |
| 2099 | 2096 | // http://doc.spip.org/@aide |
| 2100 | -function aide($aide='', $distante = false) { |
|
| 2097 | +function aide($aide = '', $distante = false) { |
|
| 2101 | 2098 | $aider = charger_fonction('aider', 'inc', true); |
| 2102 | - return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 2099 | + return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 2103 | 2100 | } |
| 2104 | 2101 | |
| 2105 | 2102 | // normalement il faudrait creer exec/info.php, mais pour mettre juste ca: |
@@ -2128,7 +2125,7 @@ discard block |
||
| 2128 | 2125 | * Rien dans la plupart des cas |
| 2129 | 2126 | * - string si $message à false. |
| 2130 | 2127 | **/ |
| 2131 | -function erreur_squelette($message='', $lieu='') { |
|
| 2128 | +function erreur_squelette($message = '', $lieu = '') { |
|
| 2132 | 2129 | $debusquer = charger_fonction('debusquer', 'public'); |
| 2133 | 2130 | if (is_array($lieu)) { |
| 2134 | 2131 | include_spip('public/compiler'); |
@@ -2168,15 +2165,15 @@ discard block |
||
| 2168 | 2165 | * Contenu du squelette calculé |
| 2169 | 2166 | * ou tableau d'information sur le squelette. |
| 2170 | 2167 | */ |
| 2171 | -function recuperer_fond($fond, $contexte=array(), $options = array(), $connect='') { |
|
| 2168 | +function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') { |
|
| 2172 | 2169 | if (!function_exists('evaluer_fond')) |
| 2173 | 2170 | include_spip('public/assembler'); |
| 2174 | 2171 | // assurer la compat avec l'ancienne syntaxe |
| 2175 | 2172 | // (trim etait le 3eme argument, par defaut a true) |
| 2176 | 2173 | if (!is_array($options)) $options = array('trim'=>$options); |
| 2177 | - if (!isset($options['trim'])) $options['trim']=true; |
|
| 2174 | + if (!isset($options['trim'])) $options['trim'] = true; |
|
| 2178 | 2175 | |
| 2179 | - if (isset($contexte['connect'])){ |
|
| 2176 | + if (isset($contexte['connect'])) { |
|
| 2180 | 2177 | $connect = ($connect ? $connect : $contexte['connect']); |
| 2181 | 2178 | unset($contexte['connect']); |
| 2182 | 2179 | } |
@@ -2184,7 +2181,7 @@ discard block |
||
| 2184 | 2181 | $texte = ""; |
| 2185 | 2182 | $pages = array(); |
| 2186 | 2183 | $lang_select = ''; |
| 2187 | - if (!isset($options['etoile']) OR !$options['etoile']){ |
|
| 2184 | + if (!isset($options['etoile']) OR !$options['etoile']) { |
|
| 2188 | 2185 | // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
| 2189 | 2186 | if (!isset($contexte['lang'])) |
| 2190 | 2187 | $contexte['lang'] = $GLOBALS['spip_lang']; |
@@ -2196,10 +2193,10 @@ discard block |
||
| 2196 | 2193 | |
| 2197 | 2194 | @$GLOBALS['_INC_PUBLIC']++; |
| 2198 | 2195 | |
| 2199 | - foreach(is_array($fond) ? $fond : array($fond) as $f){ |
|
| 2196 | + foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 2200 | 2197 | $page = evaluer_fond($f, $contexte, $connect); |
| 2201 | 2198 | if ($page === '') { |
| 2202 | - $c = isset($options['compil']) ? $options['compil'] :''; |
|
| 2199 | + $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 2203 | 2200 | $a = array('fichier'=>$fond); |
| 2204 | 2201 | $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
| 2205 | 2202 | erreur_squelette($erreur, $c); |
@@ -2207,14 +2204,14 @@ discard block |
||
| 2207 | 2204 | $page = array('texte' => '', 'erreur' => $erreur); |
| 2208 | 2205 | } |
| 2209 | 2206 | |
| 2210 | - $page = pipeline('recuperer_fond',array( |
|
| 2211 | - 'args'=>array('fond'=>$f,'contexte'=>$contexte,'options'=>$options,'connect'=>$connect), |
|
| 2207 | + $page = pipeline('recuperer_fond', array( |
|
| 2208 | + 'args'=>array('fond'=>$f, 'contexte'=>$contexte, 'options'=>$options, 'connect'=>$connect), |
|
| 2212 | 2209 | 'data'=>$page |
| 2213 | 2210 | )); |
| 2214 | - if (isset($options['ajax']) AND $options['ajax']){ |
|
| 2211 | + if (isset($options['ajax']) AND $options['ajax']) { |
|
| 2215 | 2212 | if (!function_exists('encoder_contexte_ajax')) |
| 2216 | 2213 | include_spip('inc/filtres'); |
| 2217 | - $page['texte'] = encoder_contexte_ajax(array_merge($contexte,array('fond'=>$f)),'',$page['texte'], $options['ajax']); |
|
| 2214 | + $page['texte'] = encoder_contexte_ajax(array_merge($contexte, array('fond'=>$f)), '', $page['texte'], $options['ajax']); |
|
| 2218 | 2215 | } |
| 2219 | 2216 | |
| 2220 | 2217 | if (isset($options['raw']) AND $options['raw']) |
@@ -2227,7 +2224,7 @@ discard block |
||
| 2227 | 2224 | |
| 2228 | 2225 | if ($lang_select) lang_select(); |
| 2229 | 2226 | if (isset($options['raw']) AND $options['raw']) |
| 2230 | - return is_array($fond)?$pages:reset($pages); |
|
| 2227 | + return is_array($fond) ? $pages : reset($pages); |
|
| 2231 | 2228 | else |
| 2232 | 2229 | return $options['trim'] ? ltrim($texte) : $texte; |
| 2233 | 2230 | } |
@@ -2239,7 +2236,7 @@ discard block |
||
| 2239 | 2236 | * @return string |
| 2240 | 2237 | */ |
| 2241 | 2238 | function trouve_modele($nom) { |
| 2242 | - return trouver_fond($nom,'modeles/'); |
|
| 2239 | + return trouver_fond($nom, 'modeles/'); |
|
| 2243 | 2240 | } |
| 2244 | 2241 | |
| 2245 | 2242 | /** |
@@ -2254,8 +2251,8 @@ discard block |
||
| 2254 | 2251 | * @param bool $pathinfo |
| 2255 | 2252 | * @return array|string |
| 2256 | 2253 | */ |
| 2257 | -function trouver_fond($nom, $dir='', $pathinfo = false) { |
|
| 2258 | - $f = find_in_path($nom.'.'. _EXTENSION_SQUELETTES, $dir?rtrim($dir,'/').'/':''); |
|
| 2254 | +function trouver_fond($nom, $dir = '', $pathinfo = false) { |
|
| 2255 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ?rtrim($dir, '/').'/' : ''); |
|
| 2259 | 2256 | if (!$pathinfo) return $f; |
| 2260 | 2257 | // renvoyer un tableau detaille si $pathinfo==true |
| 2261 | 2258 | $p = pathinfo($f); |
@@ -2263,14 +2260,14 @@ discard block |
||
| 2263 | 2260 | $p['extension'] = _EXTENSION_SQUELETTES; |
| 2264 | 2261 | } |
| 2265 | 2262 | if (!isset($p['extension']) OR !$p['filename']) { |
| 2266 | - $p['filename'] = ($p['basename']?substr($p['basename'],0,-strlen($p['extension'])-1):''); |
|
| 2263 | + $p['filename'] = ($p['basename'] ?substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 2267 | 2264 | } |
| 2268 | - $p['fond'] = ($f?substr($f,0,-strlen($p['extension'])-1):''); |
|
| 2265 | + $p['fond'] = ($f ?substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 2269 | 2266 | return $p; |
| 2270 | 2267 | } |
| 2271 | 2268 | |
| 2272 | -function tester_url_ecrire($nom){ |
|
| 2273 | - static $exec=array(); |
|
| 2269 | +function tester_url_ecrire($nom) { |
|
| 2270 | + static $exec = array(); |
|
| 2274 | 2271 | if (isset($exec[$nom])) return $exec[$nom]; |
| 2275 | 2272 | // tester si c'est une page en squelette |
| 2276 | 2273 | if (trouver_fond($nom, 'prive/squelettes/contenu/')) |
@@ -2279,12 +2276,12 @@ discard block |
||
| 2279 | 2276 | elseif (trouver_fond($nom, 'prive/exec/')) |
| 2280 | 2277 | return $exec[$nom] = 'fond_monobloc'; |
| 2281 | 2278 | // echafaudage d'un fond ! |
| 2282 | - elseif(include_spip('public/styliser_par_z') AND z_echafaudable($nom)) |
|
| 2279 | + elseif (include_spip('public/styliser_par_z') AND z_echafaudable($nom)) |
|
| 2283 | 2280 | return $exec[$nom] = 'fond'; |
| 2284 | 2281 | // attention, il ne faut pas inclure l'exec ici |
| 2285 | 2282 | // car sinon #URL_ECRIRE provoque des inclusions |
| 2286 | 2283 | // et des define intrusifs potentiels |
| 2287 | - return $exec[$nom] = ((find_in_path("{$nom}.php",'exec/') OR charger_fonction($nom,'exec',true))?$nom:''); |
|
| 2284 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') OR charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 2288 | 2285 | } |
| 2289 | 2286 | |
| 2290 | 2287 | // Charger dynamiquement une extension php |
@@ -2293,7 +2290,7 @@ discard block |
||
| 2293 | 2290 | if (extension_loaded($module)) { |
| 2294 | 2291 | return true; |
| 2295 | 2292 | } else { |
| 2296 | - $charger_php_extension = charger_fonction('charger_php_extension','inc'); |
|
| 2293 | + $charger_php_extension = charger_fonction('charger_php_extension', 'inc'); |
|
| 2297 | 2294 | return $charger_php_extension($module); |
| 2298 | 2295 | } |
| 2299 | 2296 | } |
@@ -2322,13 +2319,13 @@ discard block |
||
| 2322 | 2319 | |
| 2323 | 2320 | // Fonction depreciee, cf. http://doc.spip.org/@sql_fetch |
| 2324 | 2321 | // http://doc.spip.org/@spip_fetch_array |
| 2325 | -function spip_fetch_array($r, $t=NULL) { |
|
| 2322 | +function spip_fetch_array($r, $t = NULL) { |
|
| 2326 | 2323 | if (!isset($t)) { |
| 2327 | 2324 | if ($r) return sql_fetch($r); |
| 2328 | 2325 | } else { |
| 2329 | - if ($t=='SPIP_NUM') $t = MYSQL_NUM; |
|
| 2330 | - if ($t=='SPIP_BOTH') $t = MYSQL_BOTH; |
|
| 2331 | - if ($t=='SPIP_ASSOC') $t = MYSQL_ASSOC; |
|
| 2326 | + if ($t == 'SPIP_NUM') $t = MYSQL_NUM; |
|
| 2327 | + if ($t == 'SPIP_BOTH') $t = MYSQL_BOTH; |
|
| 2328 | + if ($t == 'SPIP_ASSOC') $t = MYSQL_ASSOC; |
|
| 2332 | 2329 | spip_log("appel deprecie de spip_fetch_array(..., $t)", 'vieilles_defs'); |
| 2333 | 2330 | if ($r) return mysql_fetch_array($r, $t); |
| 2334 | 2331 | } |
@@ -2344,7 +2341,7 @@ discard block |
||
| 2344 | 2341 | * @param string $message |
| 2345 | 2342 | * @param string $statut |
| 2346 | 2343 | */ |
| 2347 | -function avertir_auteurs($nom,$message, $statut=''){ |
|
| 2344 | +function avertir_auteurs($nom, $message, $statut = '') { |
|
| 2348 | 2345 | $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
| 2349 | 2346 | if (!$alertes |
| 2350 | 2347 | OR !is_array($alertes = unserialize($alertes))) |
@@ -2353,6 +2350,6 @@ discard block |
||
| 2353 | 2350 | if (!isset($alertes[$statut])) |
| 2354 | 2351 | $alertes[$statut] = array(); |
| 2355 | 2352 | $alertes[$statut][$nom] = $message; |
| 2356 | - ecrire_meta("message_alertes_auteurs",serialize($alertes)); |
|
| 2353 | + ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 2357 | 2354 | } |
| 2358 | 2355 | ?> |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // |
| 16 | 18 | // Utilitaires indispensables autour du serveur Http. |
@@ -32,19 +34,28 @@ discard block |
||
| 32 | 34 | function charger_fonction($nom, $dossier='exec', $continue=false) { |
| 33 | 35 | static $echecs = array(); |
| 34 | 36 | |
| 35 | - if (strlen($dossier) AND substr($dossier,-1) != '/') $dossier .= '/'; |
|
| 37 | + if (strlen($dossier) AND substr($dossier,-1) != '/') { |
|
| 38 | + $dossier .= '/'; |
|
| 39 | + } |
|
| 36 | 40 | $f = str_replace('/','_',$dossier) . $nom; |
| 37 | 41 | |
| 38 | - if (function_exists($f)) |
|
| 39 | - return $f; |
|
| 40 | - if (function_exists($g = $f . '_dist')) |
|
| 41 | - return $g; |
|
| 42 | + if (function_exists($f)) { |
|
| 43 | + return $f; |
|
| 44 | + } |
|
| 45 | + if (function_exists($g = $f . '_dist')) { |
|
| 46 | + return $g; |
|
| 47 | + } |
|
| 42 | 48 | |
| 43 | - if (isset($echecs[$f])) return $echecs[$f]; |
|
| 49 | + if (isset($echecs[$f])) { |
|
| 50 | + return $echecs[$f]; |
|
| 51 | + } |
|
| 44 | 52 | // Sinon charger le fichier de declaration si plausible |
| 45 | 53 | |
| 46 | 54 | if (!preg_match(',^\w+$,', $f)){ |
| 47 | - if ($continue) return false; //appel interne, on passe |
|
| 55 | + if ($continue) { |
|
| 56 | + return false; |
|
| 57 | + } |
|
| 58 | + //appel interne, on passe |
|
| 48 | 59 | include_spip('inc/minipres'); |
| 49 | 60 | echo minipres(); |
| 50 | 61 | exit; |
@@ -55,12 +66,19 @@ discard block |
||
| 55 | 66 | if (!$inc = include_spip($dossier.($d = strtolower($nom))) |
| 56 | 67 | // si le fichier truc/machin/nom.php n'existe pas, |
| 57 | 68 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 58 | - AND strlen(dirname($dossier)) AND dirname($dossier)!='.') |
|
| 59 | - include_spip(substr($dossier,0,-1)); |
|
| 60 | - if (function_exists($f)) return $f; |
|
| 61 | - if (function_exists($g)) return $g; |
|
| 69 | + AND strlen(dirname($dossier)) AND dirname($dossier)!='.') { |
|
| 70 | + include_spip(substr($dossier,0,-1)); |
|
| 71 | + } |
|
| 72 | + if (function_exists($f)) { |
|
| 73 | + return $f; |
|
| 74 | + } |
|
| 75 | + if (function_exists($g)) { |
|
| 76 | + return $g; |
|
| 77 | + } |
|
| 62 | 78 | |
| 63 | - if ($continue) return $echecs[$f] = false; |
|
| 79 | + if ($continue) { |
|
| 80 | + return $echecs[$f] = false; |
|
| 81 | + } |
|
| 64 | 82 | |
| 65 | 83 | // Echec : message d'erreur |
| 66 | 84 | spip_log("fonction $nom ($f ou $g) indisponible" . |
@@ -115,14 +133,15 @@ discard block |
||
| 115 | 133 | // http://doc.spip.org/@minipipe |
| 116 | 134 | function minipipe($fonc,&$val){ |
| 117 | 135 | // fonction |
| 118 | - if (function_exists($fonc)) |
|
| 119 | - $val = call_user_func($fonc, $val); |
|
| 136 | + if (function_exists($fonc)) { |
|
| 137 | + $val = call_user_func($fonc, $val); |
|
| 138 | + } |
|
| 120 | 139 | // Class::Methode |
| 121 | 140 | else if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
| 122 | 141 | AND $methode = array($regs[1], $regs[2]) |
| 123 | - AND is_callable($methode)) |
|
| 124 | - $val = call_user_func($methode, $val); |
|
| 125 | - else { |
|
| 142 | + AND is_callable($methode)) { |
|
| 143 | + $val = call_user_func($methode, $val); |
|
| 144 | + } else { |
|
| 126 | 145 | spip_log("Erreur - '$fonc' non definie !"); |
| 127 | 146 | } |
| 128 | 147 | return $val; |
@@ -140,8 +159,9 @@ discard block |
||
| 140 | 159 | // generer les fichiers php precompiles |
| 141 | 160 | // de chargement des plugins et des pipelines |
| 142 | 161 | actualise_plugins_actifs(); |
| 143 | - if (!($ok = @is_readable($charger))) |
|
| 144 | - spip_log("fichier $charger pas cree"); |
|
| 162 | + if (!($ok = @is_readable($charger))) { |
|
| 163 | + spip_log("fichier $charger pas cree"); |
|
| 164 | + } |
|
| 145 | 165 | } |
| 146 | 166 | |
| 147 | 167 | if ($ok) { |
@@ -164,8 +184,9 @@ discard block |
||
| 164 | 184 | // array_key_exists pour php 4.1.0 |
| 165 | 185 | if (is_array($val) |
| 166 | 186 | AND count($val)==2 |
| 167 | - AND (array_key_exists('data',$val))) |
|
| 168 | - $val = $val['data']; |
|
| 187 | + AND (array_key_exists('data',$val))) { |
|
| 188 | + $val = $val['data']; |
|
| 189 | + } |
|
| 169 | 190 | return $val; |
| 170 | 191 | } |
| 171 | 192 | |
@@ -190,10 +211,12 @@ discard block |
||
| 190 | 211 | static $pre = array(); |
| 191 | 212 | static $log; |
| 192 | 213 | preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
| 193 | - if (!isset($regs[1]) OR !$logname = $regs[1]) |
|
| 194 | - $logname = null; |
|
| 195 | - if (!isset($regs[2]) OR !$niveau = $regs[2]) |
|
| 196 | - $niveau = _LOG_INFO; |
|
| 214 | + if (!isset($regs[1]) OR !$logname = $regs[1]) { |
|
| 215 | + $logname = null; |
|
| 216 | + } |
|
| 217 | + if (!isset($regs[2]) OR !$niveau = $regs[2]) { |
|
| 218 | + $niveau = _LOG_INFO; |
|
| 219 | + } |
|
| 197 | 220 | |
| 198 | 221 | if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
| 199 | 222 | if (!$pre){ |
@@ -208,7 +231,9 @@ discard block |
||
| 208 | 231 | _LOG_DEBUG=>'debug:'); |
| 209 | 232 | $log = charger_fonction('log', 'inc'); |
| 210 | 233 | } |
| 211 | - if (!is_string($message)) $message = var_export($message, true); |
|
| 234 | + if (!is_string($message)) { |
|
| 235 | + $message = var_export($message, true); |
|
| 236 | + } |
|
| 212 | 237 | $log($pre[$niveau].' '.$message, $logname); |
| 213 | 238 | } |
| 214 | 239 | } |
@@ -226,12 +251,17 @@ discard block |
||
| 226 | 251 | // http://doc.spip.org/@_request |
| 227 | 252 | function _request($var, $c=false) { |
| 228 | 253 | |
| 229 | - if (is_array($c)) |
|
| 230 | - return isset($c[$var]) ? $c[$var] : NULL; |
|
| 254 | + if (is_array($c)) { |
|
| 255 | + return isset($c[$var]) ? $c[$var] : NULL; |
|
| 256 | + } |
|
| 231 | 257 | |
| 232 | - if (isset($_GET[$var])) $a = $_GET[$var]; |
|
| 233 | - elseif (isset($_POST[$var])) $a = $_POST[$var]; |
|
| 234 | - else return NULL; |
|
| 258 | + if (isset($_GET[$var])) { |
|
| 259 | + $a = $_GET[$var]; |
|
| 260 | + } elseif (isset($_POST[$var])) { |
|
| 261 | + $a = $_POST[$var]; |
|
| 262 | + } else { |
|
| 263 | + return NULL; |
|
| 264 | + } |
|
| 235 | 265 | |
| 236 | 266 | // Si on est en ajax et en POST tout a ete encode |
| 237 | 267 | // via encodeURIComponent, il faut donc repasser |
@@ -259,15 +289,17 @@ discard block |
||
| 259 | 289 | function set_request($var, $val = NULL, $c=false) { |
| 260 | 290 | if (is_array($c)) { |
| 261 | 291 | unset($c[$var]); |
| 262 | - if ($val !== NULL) |
|
| 263 | - $c[$var] = $val; |
|
| 292 | + if ($val !== NULL) { |
|
| 293 | + $c[$var] = $val; |
|
| 294 | + } |
|
| 264 | 295 | return $c; |
| 265 | 296 | } |
| 266 | 297 | |
| 267 | 298 | unset($_GET[$var]); |
| 268 | 299 | unset($_POST[$var]); |
| 269 | - if ($val !== NULL) |
|
| 270 | - $_GET[$var] = $val; |
|
| 300 | + if ($val !== NULL) { |
|
| 301 | + $_GET[$var] = $val; |
|
| 302 | + } |
|
| 271 | 303 | |
| 272 | 304 | return false; # n'affecte pas $c |
| 273 | 305 | } |
@@ -314,22 +346,26 @@ discard block |
||
| 314 | 346 | */ |
| 315 | 347 | function parametre_url($url, $c, $v=NULL, $sep='&') { |
| 316 | 348 | // requete erronnee : plusieurs variable dans $c et aucun $v |
| 317 | - if (strpos($c,"|")!==false AND is_null($v)) |
|
| 318 | - return null; |
|
| 349 | + if (strpos($c,"|")!==false AND is_null($v)) { |
|
| 350 | + return null; |
|
| 351 | + } |
|
| 319 | 352 | |
| 320 | 353 | // lever l'#ancre |
| 321 | 354 | if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
| 322 | 355 | $url = $r[1]; |
| 323 | 356 | $ancre = $r[2]; |
| 324 | - } else |
|
| 325 | - $ancre = ''; |
|
| 357 | + } else { |
|
| 358 | + $ancre = ''; |
|
| 359 | + } |
|
| 326 | 360 | |
| 327 | 361 | // eclater |
| 328 | 362 | $url = preg_split(',[?]|&|&,', $url); |
| 329 | 363 | |
| 330 | 364 | // recuperer la base |
| 331 | 365 | $a = array_shift($url); |
| 332 | - if (!$a) $a= './'; |
|
| 366 | + if (!$a) { |
|
| 367 | + $a= './'; |
|
| 368 | + } |
|
| 333 | 369 | |
| 334 | 370 | $regexp = ',^(' . str_replace('[]','\[\]',$c) . '[[]?[]]?)(=.*)?$,'; |
| 335 | 371 | $ajouts = array_flip(explode('|',$c)); |
@@ -357,15 +393,17 @@ discard block |
||
| 357 | 393 | // traiter les parametres pas encore trouves |
| 358 | 394 | if ($v === NULL |
| 359 | 395 | AND $args = func_get_args() |
| 360 | - AND count($args)==2) |
|
| 361 | - return $v; |
|
| 362 | - elseif ($testv) { |
|
| 396 | + AND count($args)==2) { |
|
| 397 | + return $v; |
|
| 398 | + } elseif ($testv) { |
|
| 363 | 399 | foreach($ajouts as $k => $n) { |
| 364 | - if (!is_array($v)) |
|
| 365 | - $url[] = $k .'=' . $u; |
|
| 366 | - else { |
|
| 400 | + if (!is_array($v)) { |
|
| 401 | + $url[] = $k .'=' . $u; |
|
| 402 | + } else { |
|
| 367 | 403 | $id = (substr($k,-2) == '[]') ? $k : ($k ."[]"); |
| 368 | - foreach ($v as $w) $url[]= $id .'=' . $w; |
|
| 404 | + foreach ($v as $w) { |
|
| 405 | + $url[]= $id .'=' . $w; |
|
| 406 | + } |
|
| 369 | 407 | } |
| 370 | 408 | } |
| 371 | 409 | } |
@@ -374,8 +412,9 @@ discard block |
||
| 374 | 412 | $url = array_filter($url); |
| 375 | 413 | |
| 376 | 414 | // recomposer l'adresse |
| 377 | - if ($url) |
|
| 378 | - $a .= '?' . join($sep, $url); |
|
| 415 | + if ($url) { |
|
| 416 | + $a .= '?' . join($sep, $url); |
|
| 417 | + } |
|
| 379 | 418 | |
| 380 | 419 | return $a . $ancre; |
| 381 | 420 | } |
@@ -390,8 +429,9 @@ discard block |
||
| 390 | 429 | $url = $r[1]; |
| 391 | 430 | } |
| 392 | 431 | if (preg_match('/[^-_a-zA-Z0-9]+/S',$ancre)){ |
| 393 | - if (!function_exists('translitteration')) |
|
| 394 | - include_spip('inc/charsets'); |
|
| 432 | + if (!function_exists('translitteration')) { |
|
| 433 | + include_spip('inc/charsets'); |
|
| 434 | + } |
|
| 395 | 435 | $ancre = preg_replace(array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), array('', '-'), |
| 396 | 436 | translitteration($ancre)); |
| 397 | 437 | } |
@@ -409,8 +449,12 @@ discard block |
||
| 409 | 449 | { |
| 410 | 450 | static $done = false; |
| 411 | 451 | static $propre = ''; |
| 412 | - if (!is_null($reset)) return $propre=$reset; |
|
| 413 | - if ($done) return $propre; |
|
| 452 | + if (!is_null($reset)) { |
|
| 453 | + return $propre=$reset; |
|
| 454 | + } |
|
| 455 | + if ($done) { |
|
| 456 | + return $propre; |
|
| 457 | + } |
|
| 414 | 458 | $done = true; |
| 415 | 459 | |
| 416 | 460 | $uri1 = $GLOBALS['REQUEST_URI']; |
@@ -442,12 +486,14 @@ discard block |
||
| 442 | 486 | $GLOBALS['profondeur_url']<(_DIR_RESTREINT?1:2) |
| 443 | 487 | // sinon c'est OK si _SET_HTML_BASE a ete force a false |
| 444 | 488 | OR (defined('_SET_HTML_BASE') AND !_SET_HTML_BASE)) |
| 445 | - ) |
|
| 446 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 489 | + ) { |
|
| 490 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 491 | + } |
|
| 447 | 492 | // ajouter le cas echeant les variables _POST['id_...'] |
| 448 | - foreach ($_POST as $v => $c) |
|
| 449 | - if (substr($v,0,3) == 'id_') |
|
| 493 | + foreach ($_POST as $v => $c) { |
|
| 494 | + if (substr($v,0,3) == 'id_') |
|
| 450 | 495 | $url = parametre_url($url, $v, $c, '&'); |
| 496 | + } |
|
| 451 | 497 | |
| 452 | 498 | // supprimer les variables sans interet |
| 453 | 499 | if (test_espace_prive()) { |
@@ -465,8 +511,9 @@ discard block |
||
| 465 | 511 | $url = str_replace(array("'", '"', '<', '[', ']'), array('%27', '%22', '%3C', '%5B', '%5D'), $url); |
| 466 | 512 | |
| 467 | 513 | // & ? |
| 468 | - if ($amp != '&') |
|
| 469 | - $url = str_replace('&', $amp, $url); |
|
| 514 | + if ($amp != '&') { |
|
| 515 | + $url = str_replace('&', $amp, $url); |
|
| 516 | + } |
|
| 470 | 517 | |
| 471 | 518 | // Si ca demarre par ? ou vide, donner './' |
| 472 | 519 | $url = preg_replace(',^([?].*)?$,', './\1', $url); |
@@ -507,8 +554,9 @@ discard block |
||
| 507 | 554 | $o = array('class'=>'', 'force'=>true); |
| 508 | 555 | if ($options){ |
| 509 | 556 | // support de l'ancien argument $class |
| 510 | - if (is_string($options)) |
|
| 511 | - $options = array('class'=>$options); |
|
| 557 | + if (is_string($options)) { |
|
| 558 | + $options = array('class'=>$options); |
|
| 559 | + } |
|
| 512 | 560 | $o = array_merge($o,$options); |
| 513 | 561 | } |
| 514 | 562 | |
@@ -531,16 +579,18 @@ discard block |
||
| 531 | 579 | $text = $traduire($texte, $lang); |
| 532 | 580 | |
| 533 | 581 | if (!strlen($text)){ |
| 534 | - if (!$o['force']) |
|
| 535 | - return ''; |
|
| 582 | + if (!$o['force']) { |
|
| 583 | + return ''; |
|
| 584 | + } |
|
| 536 | 585 | |
| 537 | 586 | $text = $texte; |
| 538 | 587 | |
| 539 | 588 | // pour les chaines non traduites, assurer un service minimum |
| 540 | - if (!$GLOBALS['test_i18n'] AND (_request('var_mode') != 'traduction')) |
|
| 541 | - $text = str_replace('_', ' ', |
|
| 589 | + if (!$GLOBALS['test_i18n'] AND (_request('var_mode') != 'traduction')) { |
|
| 590 | + $text = str_replace('_', ' ', |
|
| 542 | 591 | (($n = strpos($text,':')) === false ? $texte : |
| 543 | 592 | substr($texte, $n+1))); |
| 593 | + } |
|
| 544 | 594 | $o['class'] = null; |
| 545 | 595 | |
| 546 | 596 | } |
@@ -556,29 +606,34 @@ discard block |
||
| 556 | 606 | $f = $text; |
| 557 | 607 | if (is_array($args)) { |
| 558 | 608 | foreach ($args as $name => $value) { |
| 559 | - if ($class) |
|
| 560 | - $value = "<span class='$class'>$value</span>"; |
|
| 609 | + if ($class) { |
|
| 610 | + $value = "<span class='$class'>$value</span>"; |
|
| 611 | + } |
|
| 561 | 612 | $t = str_replace ("@$name@", $value, $text); |
| 562 | 613 | if ($text !== $t) {unset($args[$name]); $text = $t;} |
| 563 | 614 | } |
| 564 | 615 | // Si des variables n'ont pas ete inserees, le signaler |
| 565 | 616 | // (chaines de langues pas a jour) |
| 566 | - if ($args) spip_log("$f: variables inutilisees " . join(', ', array_keys($args)),_LOG_DEBUG); |
|
| 617 | + if ($args) { |
|
| 618 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)),_LOG_DEBUG); |
|
| 619 | + } |
|
| 567 | 620 | } |
| 568 | 621 | |
| 569 | - if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class===null) |
|
| 570 | - return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 571 | - else |
|
| 572 | - return $text; |
|
| 573 | -} |
|
| 622 | + if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class===null) { |
|
| 623 | + return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 624 | + } else { |
|
| 625 | + return $text; |
|
| 626 | + } |
|
| 627 | + } |
|
| 574 | 628 | |
| 575 | 629 | // Afficher "ecrire/data/" au lieu de "data/" dans les messages |
| 576 | 630 | // ou tmp/ au lieu de ../tmp/ |
| 577 | 631 | // http://doc.spip.org/@joli_repertoire |
| 578 | 632 | function joli_repertoire($rep) { |
| 579 | 633 | $a = substr($rep,0,1); |
| 580 | - if ($a<>'.' AND $a<>'/') |
|
| 581 | - $rep = (_DIR_RESTREINT?'':_DIR_RESTREINT_ABS).$rep; |
|
| 634 | + if ($a<>'.' AND $a<>'/') { |
|
| 635 | + $rep = (_DIR_RESTREINT?'':_DIR_RESTREINT_ABS).$rep; |
|
| 636 | + } |
|
| 582 | 637 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 583 | 638 | return $rep; |
| 584 | 639 | } |
@@ -593,7 +648,10 @@ discard block |
||
| 593 | 648 | $a=time(); $b=microtime(); |
| 594 | 649 | // microtime peut contenir les microsecondes et le temps |
| 595 | 650 | $b=explode(' ',$b); |
| 596 | - if (count($b)==2) $a = end($b); // plus precis ! |
|
| 651 | + if (count($b)==2) { |
|
| 652 | + $a = end($b); |
|
| 653 | + } |
|
| 654 | + // plus precis ! |
|
| 597 | 655 | $b = reset($b); |
| 598 | 656 | if (!isset($time[$t])) { |
| 599 | 657 | $time[$t] = $a + $b; |
@@ -601,10 +659,12 @@ discard block |
||
| 601 | 659 | $p = ($a + $b - $time[$t]) * 1000; |
| 602 | 660 | unset($time[$t]); |
| 603 | 661 | # echo "'$p'";exit; |
| 604 | - if ($raw) return $p; |
|
| 605 | - if ($p < 1000) |
|
| 606 | - $s = ''; |
|
| 607 | - else { |
|
| 662 | + if ($raw) { |
|
| 663 | + return $p; |
|
| 664 | + } |
|
| 665 | + if ($p < 1000) { |
|
| 666 | + $s = ''; |
|
| 667 | + } else { |
|
| 608 | 668 | $s = sprintf("%d ", $x = floor($p/1000)); |
| 609 | 669 | $p -= ($x*1000); |
| 610 | 670 | } |
@@ -619,8 +679,9 @@ discard block |
||
| 619 | 679 | function spip_touch($fichier, $duree=0, $touch=true) { |
| 620 | 680 | if ($duree) { |
| 621 | 681 | clearstatcache(); |
| 622 | - if ((@$f=filemtime($fichier)) AND ($f >= time() - $duree)) |
|
| 623 | - return false; |
|
| 682 | + if ((@$f=filemtime($fichier)) AND ($f >= time() - $duree)) { |
|
| 683 | + return false; |
|
| 684 | + } |
|
| 624 | 685 | } |
| 625 | 686 | if ($touch!==false) { |
| 626 | 687 | if (!@touch($fichier)) { spip_unlink($fichier); @touch($fichier); }; |
@@ -663,13 +724,20 @@ discard block |
||
| 663 | 724 | */ |
| 664 | 725 | function cron ($taches=array(), $taches_old= array()) { |
| 665 | 726 | // si pas en mode cron force, laisser tomber. |
| 666 | - if (!defined('_DIRECT_CRON_FORCE')) return false; |
|
| 667 | - if (!is_array($taches)) $taches = $taches_old; // compat anciens appels |
|
| 727 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 728 | + return false; |
|
| 729 | + } |
|
| 730 | + if (!is_array($taches)) { |
|
| 731 | + $taches = $taches_old; |
|
| 732 | + } |
|
| 733 | + // compat anciens appels |
|
| 668 | 734 | // si taches a inserer en base et base inaccessible, laisser tomber |
| 669 | 735 | // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
| 670 | 736 | // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
| 671 | 737 | // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
| 672 | - if ($taches AND count($taches) AND !spip_connect()) return false; |
|
| 738 | + if ($taches AND count($taches) AND !spip_connect()) { |
|
| 739 | + return false; |
|
| 740 | + } |
|
| 673 | 741 | spip_log("cron !",'jq'._LOG_DEBUG); |
| 674 | 742 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 675 | 743 | return $genie($taches); |
@@ -743,28 +811,31 @@ discard block |
||
| 743 | 811 | */ |
| 744 | 812 | function queue_sleep_time_to_next_job($force=null) { |
| 745 | 813 | static $queue_next_job_time = -1; |
| 746 | - if ($force===true) |
|
| 747 | - $queue_next_job_time = -1; |
|
| 748 | - elseif ($force) |
|
| 749 | - $queue_next_job_time = $force; |
|
| 814 | + if ($force===true) { |
|
| 815 | + $queue_next_job_time = -1; |
|
| 816 | + } elseif ($force) { |
|
| 817 | + $queue_next_job_time = $force; |
|
| 818 | + } |
|
| 750 | 819 | |
| 751 | 820 | if ($queue_next_job_time==-1) { |
| 752 | 821 | define('_JQ_NEXT_JOB_TIME_FILENAME',_DIR_TMP . "job_queue_next.txt"); |
| 753 | 822 | // utiliser un cache memoire si dispo |
| 754 | 823 | if (include_spip('inc/memoization') AND defined('_MEMOIZE_MEMORY') AND _MEMOIZE_MEMORY) { |
| 755 | 824 | $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
| 756 | - } |
|
| 757 | - else { |
|
| 825 | + } else { |
|
| 758 | 826 | $queue_next_job_time = null; |
| 759 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) |
|
| 760 | - $queue_next_job_time = intval($contenu); |
|
| 827 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 828 | + $queue_next_job_time = intval($contenu); |
|
| 829 | + } |
|
| 761 | 830 | } |
| 762 | 831 | } |
| 763 | 832 | |
| 764 | - if (is_null($queue_next_job_time)) |
|
| 765 | - return null; |
|
| 766 | - if (!$_SERVER['REQUEST_TIME']) |
|
| 767 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 833 | + if (is_null($queue_next_job_time)) { |
|
| 834 | + return null; |
|
| 835 | + } |
|
| 836 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 837 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 838 | + } |
|
| 768 | 839 | return $queue_next_job_time-$_SERVER['REQUEST_TIME']; |
| 769 | 840 | } |
| 770 | 841 | |
@@ -786,14 +857,17 @@ discard block |
||
| 786 | 857 | $done[$src] = true; |
| 787 | 858 | $src = find_in_path($src, _JAVASCRIPT); |
| 788 | 859 | $src = " src='$src'"; |
| 860 | + } else { |
|
| 861 | + $src = ''; |
|
| 789 | 862 | } |
| 790 | - else $src = ''; |
|
| 791 | - if ($script) |
|
| 792 | - $script = ("/*<![CDATA[*/\n" . |
|
| 863 | + if ($script) { |
|
| 864 | + $script = ("/*<![CDATA[*/\n" . |
|
| 793 | 865 | preg_replace(',</([^>]*)>,','<\/\1>', $script) . |
| 794 | 866 | "/*]]>*/"); |
| 795 | - if ($noscript) |
|
| 796 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 867 | + } |
|
| 868 | + if ($noscript) { |
|
| 869 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 870 | + } |
|
| 797 | 871 | |
| 798 | 872 | return ($src OR $script OR $noscript) |
| 799 | 873 | ? "<script type='text/javascript'$src>$script</script>$noscript" |
@@ -826,43 +900,53 @@ discard block |
||
| 826 | 900 | _DIR_RACINE.'prive/:'. |
| 827 | 901 | _DIR_RESTREINT; |
| 828 | 902 | // Ajouter squelettes/ |
| 829 | - if (@is_dir(_DIR_RACINE.'squelettes')) |
|
| 830 | - $path = _DIR_RACINE.'squelettes/:' . $path; |
|
| 903 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 904 | + $path = _DIR_RACINE.'squelettes/:' . $path; |
|
| 905 | + } |
|
| 831 | 906 | foreach (explode(':', $path) as $dir) { |
| 832 | - if (strlen($dir) AND substr($dir,-1) != '/') |
|
| 833 | - $dir .= "/"; |
|
| 907 | + if (strlen($dir) AND substr($dir,-1) != '/') { |
|
| 908 | + $dir .= "/"; |
|
| 909 | + } |
|
| 834 | 910 | $path_base[] = $dir; |
| 835 | 911 | } |
| 836 | 912 | $path_full = $path_base; |
| 837 | 913 | // Et le(s) dossier(s) des squelettes nommes |
| 838 | - if (strlen($GLOBALS['dossier_squelettes'])) |
|
| 839 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 914 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 915 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 840 | 916 | array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
| 917 | + } |
|
| 841 | 918 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
| 842 | 919 | } |
| 843 | - if ($dir_path===NULL) return $path_full; |
|
| 920 | + if ($dir_path===NULL) { |
|
| 921 | + return $path_full; |
|
| 922 | + } |
|
| 844 | 923 | |
| 845 | 924 | if (strlen($dir_path)){ |
| 846 | 925 | $tete = ""; |
| 847 | - if (reset($path_base)==_DIR_RACINE.'squelettes/') |
|
| 848 | - $tete = array_shift($path_base); |
|
| 926 | + if (reset($path_base)==_DIR_RACINE.'squelettes/') { |
|
| 927 | + $tete = array_shift($path_base); |
|
| 928 | + } |
|
| 849 | 929 | $dirs = array_reverse(explode(':',$dir_path)); |
| 850 | 930 | foreach($dirs as $dir_path){ |
| 851 | 931 | #if ($dir_path{0}!='/') |
| 852 | 932 | # $dir_path = $dir_path; |
| 853 | - if (substr($dir_path,-1) != '/') |
|
| 854 | - $dir_path .= "/"; |
|
| 855 | - if (!in_array($dir_path,$path_base)) |
|
| 856 | - array_unshift($path_base,$dir_path); |
|
| 933 | + if (substr($dir_path,-1) != '/') { |
|
| 934 | + $dir_path .= "/"; |
|
| 935 | + } |
|
| 936 | + if (!in_array($dir_path,$path_base)) { |
|
| 937 | + array_unshift($path_base,$dir_path); |
|
| 938 | + } |
|
| 939 | + } |
|
| 940 | + if (strlen($tete)) { |
|
| 941 | + array_unshift($path_base,$tete); |
|
| 857 | 942 | } |
| 858 | - if (strlen($tete)) |
|
| 859 | - array_unshift($path_base,$tete); |
|
| 860 | 943 | } |
| 861 | 944 | $path_full = $path_base; |
| 862 | 945 | // Et le(s) dossier(s) des squelettes nommes |
| 863 | - if (strlen($GLOBALS['dossier_squelettes'])) |
|
| 864 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 946 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 947 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) |
|
| 865 | 948 | array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
| 949 | + } |
|
| 866 | 950 | |
| 867 | 951 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
| 868 | 952 | return $path_full; |
@@ -887,8 +971,9 @@ discard block |
||
| 887 | 971 | static $themes = null; |
| 888 | 972 | if (is_null($themes)){ |
| 889 | 973 | // si pas encore definie |
| 890 | - if (!defined('_SPIP_THEME_PRIVE')) |
|
| 891 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 974 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 975 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 976 | + } |
|
| 892 | 977 | $themes = array(_SPIP_THEME_PRIVE); |
| 893 | 978 | // lors d'une installation neuve, prefs n'est pas definie. |
| 894 | 979 | if (isset($GLOBALS['visiteur_session']['prefs'])) { |
@@ -896,24 +981,30 @@ discard block |
||
| 896 | 981 | } else { |
| 897 | 982 | $prefs = array(); |
| 898 | 983 | } |
| 899 | - if (is_string($prefs)) |
|
| 900 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 984 | + if (is_string($prefs)) { |
|
| 985 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 986 | + } |
|
| 901 | 987 | if ( |
| 902 | 988 | ((isset($prefs['theme']) AND $theme = $prefs['theme']) |
| 903 | 989 | OR (isset($GLOBALS['theme_prive_defaut']) AND $theme = $GLOBALS['theme_prive_defaut'])) |
| 904 | - AND $theme != _SPIP_THEME_PRIVE) |
|
| 905 | - array_unshift($themes,$theme); // placer le theme choisi en tete |
|
| 990 | + AND $theme != _SPIP_THEME_PRIVE) { |
|
| 991 | + array_unshift($themes,$theme); |
|
| 992 | + } |
|
| 993 | + // placer le theme choisi en tete |
|
| 906 | 994 | } |
| 907 | 995 | return $themes; |
| 908 | 996 | } |
| 909 | 997 | |
| 910 | 998 | function find_in_theme($file, $subdir='', $include=false){ |
| 911 | 999 | static $themefiles=array(); |
| 912 | - if (isset($themefiles["$subdir$file"])) return $themefiles["$subdir$file"]; |
|
| 1000 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1001 | + return $themefiles["$subdir$file"]; |
|
| 1002 | + } |
|
| 913 | 1003 | $themes = lister_themes_prives(); |
| 914 | 1004 | foreach($themes as $theme){ |
| 915 | - if ($f = find_in_path($file,"prive/themes/$theme/$subdir",$include)) |
|
| 916 | - return $themefiles["$subdir$file"] = $f; |
|
| 1005 | + if ($f = find_in_path($file,"prive/themes/$theme/$subdir",$include)) { |
|
| 1006 | + return $themefiles["$subdir$file"] = $f; |
|
| 1007 | + } |
|
| 917 | 1008 | } |
| 918 | 1009 | spip_log("$file introuvable dans le theme prive ".reset($themes),'theme'); |
| 919 | 1010 | return $themefiles["$subdir$file"] = ""; |
@@ -928,18 +1019,23 @@ discard block |
||
| 928 | 1019 | function chemin_image($icone){ |
| 929 | 1020 | static $icone_renommer; |
| 930 | 1021 | // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
| 931 | - if (strpos($icone,"/")!==false AND file_exists($icone)) return $icone; |
|
| 1022 | + if (strpos($icone,"/")!==false AND file_exists($icone)) { |
|
| 1023 | + return $icone; |
|
| 1024 | + } |
|
| 932 | 1025 | |
| 933 | 1026 | // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
| 934 | - if (preg_match(',[.](png|gif|jpg)$,',$icone) AND $f = find_in_theme("images/$icone")) |
|
| 935 | - return $f; |
|
| 1027 | + if (preg_match(',[.](png|gif|jpg)$,',$icone) AND $f = find_in_theme("images/$icone")) { |
|
| 1028 | + return $f; |
|
| 1029 | + } |
|
| 936 | 1030 | // sinon passer par le module de renommage |
| 937 | - if (is_null($icone_renommer)) |
|
| 938 | - $icone_renommer = charger_fonction('icone_renommer','inc',true); |
|
| 1031 | + if (is_null($icone_renommer)) { |
|
| 1032 | + $icone_renommer = charger_fonction('icone_renommer','inc',true); |
|
| 1033 | + } |
|
| 939 | 1034 | if ($icone_renommer){ |
| 940 | 1035 | list($icone,$fonction) = $icone_renommer($icone,""); |
| 941 | - if (file_exists($icone)) |
|
| 942 | - return $icone; |
|
| 1036 | + if (file_exists($icone)) { |
|
| 1037 | + return $icone; |
|
| 1038 | + } |
|
| 943 | 1039 | } |
| 944 | 1040 | return find_in_path ($icone, _NOM_IMG_PACK); |
| 945 | 1041 | } |
@@ -965,8 +1061,9 @@ discard block |
||
| 965 | 1061 | } |
| 966 | 1062 | |
| 967 | 1063 | if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
| 968 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) |
|
| 969 | - return false; |
|
| 1064 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1065 | + return false; |
|
| 1066 | + } |
|
| 970 | 1067 | if ($include AND !isset($inc[$dirname][$file])) { |
| 971 | 1068 | include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
| 972 | 1069 | $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
@@ -981,8 +1078,9 @@ discard block |
||
| 981 | 1078 | } |
| 982 | 1079 | |
| 983 | 1080 | foreach(creer_chemin() as $dir) { |
| 984 | - if (!isset($dirs[$a = $dir . $dirname])) |
|
| 985 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a) ; |
|
| 1081 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1082 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a) ; |
|
| 1083 | + } |
|
| 986 | 1084 | if ($dirs[$a]) { |
| 987 | 1085 | if (file_exists(_ROOT_CWD . ($a .= $file))) { |
| 988 | 1086 | if ($include AND !isset($inc[$dirname][$file])) { |
@@ -991,7 +1089,9 @@ discard block |
||
| 991 | 1089 | } |
| 992 | 1090 | if (!defined('_SAUVER_CHEMIN')){ |
| 993 | 1091 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
| 994 | - if (is_null($GLOBALS['path_files'])) return $a; |
|
| 1092 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1093 | + return $a; |
|
| 1094 | + } |
|
| 995 | 1095 | define('_SAUVER_CHEMIN', true); |
| 996 | 1096 | } |
| 997 | 1097 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
@@ -1004,8 +1104,9 @@ discard block |
||
| 1004 | 1104 | if ($include==='required'){ |
| 1005 | 1105 | echo '<pre>', |
| 1006 | 1106 | "<strong>Erreur Fatale</strong><br />"; |
| 1007 | - if (function_exists('debug_print_backtrace')) |
|
| 1008 | - echo debug_print_backtrace(); |
|
| 1107 | + if (function_exists('debug_print_backtrace')) { |
|
| 1108 | + echo debug_print_backtrace(); |
|
| 1109 | + } |
|
| 1009 | 1110 | echo '</pre>'; |
| 1010 | 1111 | die("Erreur interne: ne peut inclure $dirname$file"); |
| 1011 | 1112 | } |
@@ -1013,7 +1114,9 @@ discard block |
||
| 1013 | 1114 | |
| 1014 | 1115 | if (!defined('_SAUVER_CHEMIN')){ |
| 1015 | 1116 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
| 1016 | - if (is_null($GLOBALS['path_files'])) return false; |
|
| 1117 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1118 | + return false; |
|
| 1119 | + } |
|
| 1017 | 1120 | define('_SAUVER_CHEMIN', true); |
| 1018 | 1121 | } |
| 1019 | 1122 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
@@ -1045,8 +1148,9 @@ discard block |
||
| 1045 | 1148 | // mais si semble corrompu on relit avec un verrou |
| 1046 | 1149 | if (!$GLOBALS['path_files']=unserialize($contenu)){ |
| 1047 | 1150 | lire_fichier(_CACHE_CHEMIN,$contenu); |
| 1048 | - if (!$GLOBALS['path_files']=unserialize($contenu)) |
|
| 1049 | - $GLOBALS['path_files'] = array(); |
|
| 1151 | + if (!$GLOBALS['path_files']=unserialize($contenu)) { |
|
| 1152 | + $GLOBALS['path_files'] = array(); |
|
| 1153 | + } |
|
| 1050 | 1154 | } |
| 1051 | 1155 | } |
| 1052 | 1156 | } |
@@ -1054,9 +1158,10 @@ discard block |
||
| 1054 | 1158 | |
| 1055 | 1159 | function save_path_cache(){ |
| 1056 | 1160 | if (defined('_SAUVER_CHEMIN') |
| 1057 | - AND _SAUVER_CHEMIN) |
|
| 1058 | - ecrire_fichier(_CACHE_CHEMIN,serialize($GLOBALS['path_files'])); |
|
| 1059 | -} |
|
| 1161 | + AND _SAUVER_CHEMIN) { |
|
| 1162 | + ecrire_fichier(_CACHE_CHEMIN,serialize($GLOBALS['path_files'])); |
|
| 1163 | + } |
|
| 1164 | + } |
|
| 1060 | 1165 | |
| 1061 | 1166 | |
| 1062 | 1167 | /** |
@@ -1084,8 +1189,9 @@ discard block |
||
| 1084 | 1189 | // ne prendre que les fichiers pas deja trouves |
| 1085 | 1190 | // car find_in_path prend le premier qu'il trouve, |
| 1086 | 1191 | // les autres sont donc masques |
| 1087 | - if (!isset($liste_fichiers[$nom])) |
|
| 1088 | - $liste_fichiers[$nom] = $chemin; |
|
| 1192 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1193 | + $liste_fichiers[$nom] = $chemin; |
|
| 1194 | + } |
|
| 1089 | 1195 | } |
| 1090 | 1196 | } |
| 1091 | 1197 | } |
@@ -1128,13 +1234,18 @@ discard block |
||
| 1128 | 1234 | */ |
| 1129 | 1235 | function generer_url_entite($id='', $entite='', $args='', $ancre='', $public=NULL, $type=NULL) |
| 1130 | 1236 | { |
| 1131 | - if ($public === NULL) $public = !test_espace_prive(); |
|
| 1237 | + if ($public === NULL) { |
|
| 1238 | + $public = !test_espace_prive(); |
|
| 1239 | + } |
|
| 1132 | 1240 | $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
| 1133 | 1241 | |
| 1134 | 1242 | if (!$public) { |
| 1135 | - if (!$entite) return ''; |
|
| 1136 | - if (!function_exists('generer_url_ecrire_objet')) |
|
| 1137 | - include_spip('inc/urls'); |
|
| 1243 | + if (!$entite) { |
|
| 1244 | + return ''; |
|
| 1245 | + } |
|
| 1246 | + if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1247 | + include_spip('inc/urls'); |
|
| 1248 | + } |
|
| 1138 | 1249 | $res = generer_url_ecrire_objet($entite,$id, $args, $ancre, false); |
| 1139 | 1250 | } else { |
| 1140 | 1251 | if ($type === NULL) { |
@@ -1146,32 +1257,42 @@ discard block |
||
| 1146 | 1257 | |
| 1147 | 1258 | $f = charger_fonction($type, 'urls', true); |
| 1148 | 1259 | // se rabattre sur les urls page si les urls perso non dispo |
| 1149 | - if (!$f) $f = charger_fonction('page', 'urls', true); |
|
| 1260 | + if (!$f) { |
|
| 1261 | + $f = charger_fonction('page', 'urls', true); |
|
| 1262 | + } |
|
| 1150 | 1263 | |
| 1151 | 1264 | // si $entite='', on veut la fonction de passage URL ==> id |
| 1152 | 1265 | // sinon on veut effectuer le passage id ==> URL |
| 1153 | - if (!$entite) return $f; |
|
| 1266 | + if (!$entite) { |
|
| 1267 | + return $f; |
|
| 1268 | + } |
|
| 1154 | 1269 | |
| 1155 | 1270 | // mais d'abord il faut tester le cas des urls sur une |
| 1156 | 1271 | // base distante |
| 1157 | 1272 | if (is_string($public) |
| 1158 | - AND $g = charger_fonction('connect', 'urls', true)) |
|
| 1159 | - $f = $g; |
|
| 1273 | + AND $g = charger_fonction('connect', 'urls', true)) { |
|
| 1274 | + $f = $g; |
|
| 1275 | + } |
|
| 1160 | 1276 | |
| 1161 | 1277 | $res = $f(intval($id), $entite, $args, $ancre, $public); |
| 1162 | 1278 | |
| 1163 | 1279 | } |
| 1164 | - if ($res) return $res; |
|
| 1280 | + if ($res) { |
|
| 1281 | + return $res; |
|
| 1282 | + } |
|
| 1165 | 1283 | // Sinon c'est un raccourci ou compat SPIP < 2 |
| 1166 | 1284 | if (!function_exists($f = 'generer_url_' . $entite)) { |
| 1167 | - if (!function_exists($f .= '_dist')) $f = ''; |
|
| 1285 | + if (!function_exists($f .= '_dist')) { |
|
| 1286 | + $f = ''; |
|
| 1287 | + } |
|
| 1168 | 1288 | } |
| 1169 | 1289 | if ($f) { |
| 1170 | 1290 | $url = $f($id, $args, $ancre); |
| 1171 | - if (strlen($args)) |
|
| 1172 | - $url .= strstr($url, '?') |
|
| 1291 | + if (strlen($args)) { |
|
| 1292 | + $url .= strstr($url, '?') |
|
| 1173 | 1293 | ? '&'.$args |
| 1174 | 1294 | : '?'.$args; |
| 1295 | + } |
|
| 1175 | 1296 | return $url; |
| 1176 | 1297 | } |
| 1177 | 1298 | // On a ete gentil mais la .... |
@@ -1182,12 +1303,14 @@ discard block |
||
| 1182 | 1303 | function generer_url_ecrire_entite_edit($id, $entite, $args='', $ancre=''){ |
| 1183 | 1304 | $exec = objet_info($entite,'url_edit'); |
| 1184 | 1305 | $url = generer_url_ecrire($exec,$args); |
| 1185 | - if (intval($id)) |
|
| 1186 | - $url = parametre_url($url,id_table_objet($entite),$id); |
|
| 1187 | - else |
|
| 1188 | - $url = parametre_url($url,'new','oui'); |
|
| 1189 | - if ($ancre) |
|
| 1190 | - $url = ancre_url($url,$ancre); |
|
| 1306 | + if (intval($id)) { |
|
| 1307 | + $url = parametre_url($url,id_table_objet($entite),$id); |
|
| 1308 | + } else { |
|
| 1309 | + $url = parametre_url($url,'new','oui'); |
|
| 1310 | + } |
|
| 1311 | + if ($ancre) { |
|
| 1312 | + $url = ancre_url($url,$ancre); |
|
| 1313 | + } |
|
| 1191 | 1314 | return $url; |
| 1192 | 1315 | } |
| 1193 | 1316 | |
@@ -1207,8 +1330,9 @@ discard block |
||
| 1207 | 1330 | if (preg_match(',[^\x00-\x7E],sS', $url)){ |
| 1208 | 1331 | $uri = ''; |
| 1209 | 1332 | for ($i=0; $i < strlen($url); $i++) { |
| 1210 | - if (ord($a = $url[$i]) > 127) |
|
| 1211 | - $a = rawurlencode($a); |
|
| 1333 | + if (ord($a = $url[$i]) > 127) { |
|
| 1334 | + $a = rawurlencode($a); |
|
| 1335 | + } |
|
| 1212 | 1336 | $uri .= $a; |
| 1213 | 1337 | } |
| 1214 | 1338 | $url = $uri; |
@@ -1219,7 +1343,9 @@ discard block |
||
| 1219 | 1343 | // http://doc.spip.org/@generer_url_entite_absolue |
| 1220 | 1344 | function generer_url_entite_absolue($id='', $entite='', $args='', $ancre='', $connect=NULL) |
| 1221 | 1345 | { |
| 1222 | - if (!$connect) $connect = true; |
|
| 1346 | + if (!$connect) { |
|
| 1347 | + $connect = true; |
|
| 1348 | + } |
|
| 1223 | 1349 | $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
| 1224 | 1350 | if (!preg_match(',^\w+:,', $h)) { |
| 1225 | 1351 | include_spip('inc/filtres_mini'); |
@@ -1232,7 +1358,9 @@ discard block |
||
| 1232 | 1358 | // variables d'environnement comme $_SERVER[HTTPS] ou ini_get(register_globals) |
| 1233 | 1359 | // http://doc.spip.org/@test_valeur_serveur |
| 1234 | 1360 | function test_valeur_serveur($truc) { |
| 1235 | - if (!$truc) return false; |
|
| 1361 | + if (!$truc) { |
|
| 1362 | + return false; |
|
| 1363 | + } |
|
| 1236 | 1364 | return (strtolower($truc) !== 'off'); |
| 1237 | 1365 | } |
| 1238 | 1366 | |
@@ -1259,13 +1387,20 @@ discard block |
||
| 1259 | 1387 | function url_de_base($profondeur=null) { |
| 1260 | 1388 | |
| 1261 | 1389 | static $url = array(); |
| 1262 | - if (is_array($profondeur)) return $url = $profondeur; |
|
| 1263 | - if ($profondeur===false) return $url; |
|
| 1390 | + if (is_array($profondeur)) { |
|
| 1391 | + return $url = $profondeur; |
|
| 1392 | + } |
|
| 1393 | + if ($profondeur===false) { |
|
| 1394 | + return $url; |
|
| 1395 | + } |
|
| 1264 | 1396 | |
| 1265 | - if (is_null($profondeur)) $profondeur = $GLOBALS['profondeur_url']; |
|
| 1397 | + if (is_null($profondeur)) { |
|
| 1398 | + $profondeur = $GLOBALS['profondeur_url']; |
|
| 1399 | + } |
|
| 1266 | 1400 | |
| 1267 | - if (isset($url[$profondeur])) |
|
| 1268 | - return $url[$profondeur]; |
|
| 1401 | + if (isset($url[$profondeur])) { |
|
| 1402 | + return $url[$profondeur]; |
|
| 1403 | + } |
|
| 1269 | 1404 | |
| 1270 | 1405 | $http = ( |
| 1271 | 1406 | (isset($_SERVER["SCRIPT_URI"]) AND |
@@ -1286,8 +1421,12 @@ discard block |
||
| 1286 | 1421 | if (isset($_SERVER['SERVER_PORT']) |
| 1287 | 1422 | AND $port=$_SERVER['SERVER_PORT'] |
| 1288 | 1423 | AND strpos($host,":")==false){ |
| 1289 | - if ($http=="http" AND $port!=80) $host.=":$port"; |
|
| 1290 | - if ($http=="https" AND $port!=443) $host.=":$port"; |
|
| 1424 | + if ($http=="http" AND $port!=80) { |
|
| 1425 | + $host.=":$port"; |
|
| 1426 | + } |
|
| 1427 | + if ($http=="https" AND $port!=443) { |
|
| 1428 | + $host.=":$port"; |
|
| 1429 | + } |
|
| 1291 | 1430 | } |
| 1292 | 1431 | if (!$GLOBALS['REQUEST_URI']){ |
| 1293 | 1432 | if (isset($_SERVER['REQUEST_URI'])) { |
@@ -1295,8 +1434,9 @@ discard block |
||
| 1295 | 1434 | } else { |
| 1296 | 1435 | $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; |
| 1297 | 1436 | if ($_SERVER['QUERY_STRING'] |
| 1298 | - AND !strpos($_SERVER['REQUEST_URI'], '?')) |
|
| 1299 | - $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1437 | + AND !strpos($_SERVER['REQUEST_URI'], '?')) { |
|
| 1438 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1439 | + } |
|
| 1300 | 1440 | } |
| 1301 | 1441 | } |
| 1302 | 1442 | |
@@ -1345,18 +1485,22 @@ discard block |
||
| 1345 | 1485 | |
| 1346 | 1486 | // http://doc.spip.org/@generer_url_ecrire |
| 1347 | 1487 | function generer_url_ecrire($script='', $args="", $no_entities=false, $rel=false) { |
| 1348 | - if (!$rel) |
|
| 1349 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 1350 | - else if (!is_string($rel)) |
|
| 1351 | - $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 1488 | + if (!$rel) { |
|
| 1489 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 1490 | + } else if (!is_string($rel)) { |
|
| 1491 | + $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 1352 | 1492 | ('./' . _SPIP_ECRIRE_SCRIPT); |
| 1493 | + } |
|
| 1353 | 1494 | |
| 1354 | 1495 | @list($script, $ancre) = explode('#', $script); |
| 1355 | - if ($script AND ($script<>'accueil' OR $rel)) |
|
| 1356 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 1357 | - elseif ($args) |
|
| 1358 | - $args ="?$args"; |
|
| 1359 | - if ($ancre) $args .= "#$ancre"; |
|
| 1496 | + if ($script AND ($script<>'accueil' OR $rel)) { |
|
| 1497 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 1498 | + } elseif ($args) { |
|
| 1499 | + $args ="?$args"; |
|
| 1500 | + } |
|
| 1501 | + if ($ancre) { |
|
| 1502 | + $args .= "#$ancre"; |
|
| 1503 | + } |
|
| 1360 | 1504 | return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
| 1361 | 1505 | } |
| 1362 | 1506 | |
@@ -1375,32 +1519,39 @@ discard block |
||
| 1375 | 1519 | // http://doc.spip.org/@get_spip_script |
| 1376 | 1520 | function get_spip_script($default='') { |
| 1377 | 1521 | # cas define('_SPIP_SCRIPT', ''); |
| 1378 | - if (_SPIP_SCRIPT) |
|
| 1379 | - return _SPIP_SCRIPT; |
|
| 1380 | - else |
|
| 1381 | - return $default; |
|
| 1382 | -} |
|
| 1522 | + if (_SPIP_SCRIPT) { |
|
| 1523 | + return _SPIP_SCRIPT; |
|
| 1524 | + } else { |
|
| 1525 | + return $default; |
|
| 1526 | + } |
|
| 1527 | + } |
|
| 1383 | 1528 | |
| 1384 | 1529 | // http://doc.spip.org/@generer_url_public |
| 1385 | 1530 | function generer_url_public($script='', $args="", $no_entities=false, $rel=true, $action='') { |
| 1386 | 1531 | // si le script est une action (spip_pass, spip_inscription), |
| 1387 | 1532 | // standardiser vers la nouvelle API |
| 1388 | 1533 | |
| 1389 | - if (!$action) $action = get_spip_script(); |
|
| 1390 | - if ($script) |
|
| 1391 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 1534 | + if (!$action) { |
|
| 1535 | + $action = get_spip_script(); |
|
| 1536 | + } |
|
| 1537 | + if ($script) { |
|
| 1538 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 1539 | + } |
|
| 1392 | 1540 | |
| 1393 | 1541 | if ($args) { |
| 1394 | 1542 | if (is_array($args)) { |
| 1395 | 1543 | $r = ''; |
| 1396 | - foreach($args as $k => $v) $r .= '&' . $k . '=' . $v; |
|
| 1544 | + foreach($args as $k => $v) { |
|
| 1545 | + $r .= '&' . $k . '=' . $v; |
|
| 1546 | + } |
|
| 1397 | 1547 | $args = substr($r,1); |
| 1398 | 1548 | } |
| 1399 | 1549 | $action .= |
| 1400 | 1550 | (strpos($action, '?') !== false ? '&' : '?') . $args; |
| 1401 | 1551 | } |
| 1402 | - if (!$no_entities) |
|
| 1403 | - $action = quote_amp($action); |
|
| 1552 | + if (!$no_entities) { |
|
| 1553 | + $action = quote_amp($action); |
|
| 1554 | + } |
|
| 1404 | 1555 | |
| 1405 | 1556 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 1406 | 1557 | return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(),'/') . preg_replace(",^/[.]/,","/","/$action")); |
@@ -1478,9 +1629,13 @@ discard block |
||
| 1478 | 1629 | ? generer_url_ecrire(_request('exec')) |
| 1479 | 1630 | : generer_url_public('','',false,false); |
| 1480 | 1631 | $url = parametre_url($url,'action',$script); |
| 1481 | - if ($args) $url .= quote_amp('&'.$args); |
|
| 1632 | + if ($args) { |
|
| 1633 | + $url .= quote_amp('&'.$args); |
|
| 1634 | + } |
|
| 1482 | 1635 | |
| 1483 | - if ($no_entities) $url = str_replace('&','&',$url); |
|
| 1636 | + if ($no_entities) { |
|
| 1637 | + $url = str_replace('&','&',$url); |
|
| 1638 | + } |
|
| 1484 | 1639 | return $url; |
| 1485 | 1640 | } |
| 1486 | 1641 | |
@@ -1514,107 +1669,204 @@ discard block |
||
| 1514 | 1669 | */ |
| 1515 | 1670 | function spip_initialisation_core($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) { |
| 1516 | 1671 | static $too_late = 0; |
| 1517 | - if ($too_late++) return; |
|
| 1672 | + if ($too_late++) { |
|
| 1673 | + return; |
|
| 1674 | + } |
|
| 1518 | 1675 | |
| 1519 | 1676 | // Declaration des repertoires |
| 1520 | 1677 | |
| 1521 | 1678 | // le nom du repertoire plugins/ activables/desactivables |
| 1522 | - if (!defined('_DIR_PLUGINS')) define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 1679 | + if (!defined('_DIR_PLUGINS')) { |
|
| 1680 | + define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 1681 | + } |
|
| 1523 | 1682 | |
| 1524 | 1683 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 1525 | - if (!defined('_DIR_PLUGINS_DIST')) define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 1684 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 1685 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 1686 | + } |
|
| 1526 | 1687 | |
| 1527 | 1688 | // le nom du repertoire des librairies |
| 1528 | - if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 1689 | + if (!defined('_DIR_LIB')) { |
|
| 1690 | + define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 1691 | + } |
|
| 1529 | 1692 | |
| 1530 | - if (!defined('_DIR_IMG')) define('_DIR_IMG', $pa); |
|
| 1531 | - if (!defined('_DIR_LOGOS')) define('_DIR_LOGOS', $pa); |
|
| 1532 | - if (!defined('_DIR_IMG_ICONES')) define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 1533 | - |
|
| 1534 | - if (!defined('_DIR_DUMP')) define('_DIR_DUMP', $ti . "dump/"); |
|
| 1535 | - if (!defined('_DIR_SESSIONS')) define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 1536 | - if (!defined('_DIR_TRANSFERT')) define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 1537 | - if (!defined('_DIR_CACHE')) define('_DIR_CACHE', $ti . "cache/"); |
|
| 1538 | - if (!defined('_DIR_CACHE_XML')) define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 1539 | - if (!defined('_DIR_SKELS')) define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 1540 | - if (!defined('_DIR_AIDE')) define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 1541 | - if (!defined('_DIR_TMP')) define('_DIR_TMP', $ti); |
|
| 1542 | - |
|
| 1543 | - if (!defined('_DIR_VAR')) define('_DIR_VAR', $ta); |
|
| 1544 | - |
|
| 1545 | - if (!defined('_DIR_ETC')) define('_DIR_ETC', $pi); |
|
| 1546 | - if (!defined('_DIR_CONNECT')) define('_DIR_CONNECT', $pi); |
|
| 1547 | - if (!defined('_DIR_CHMOD')) define('_DIR_CHMOD', $pi); |
|
| 1548 | - |
|
| 1549 | - if (!isset($GLOBALS['test_dirs'])) |
|
| 1550 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 1693 | + if (!defined('_DIR_IMG')) { |
|
| 1694 | + define('_DIR_IMG', $pa); |
|
| 1695 | + } |
|
| 1696 | + if (!defined('_DIR_LOGOS')) { |
|
| 1697 | + define('_DIR_LOGOS', $pa); |
|
| 1698 | + } |
|
| 1699 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 1700 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 1701 | + } |
|
| 1702 | + |
|
| 1703 | + if (!defined('_DIR_DUMP')) { |
|
| 1704 | + define('_DIR_DUMP', $ti . "dump/"); |
|
| 1705 | + } |
|
| 1706 | + if (!defined('_DIR_SESSIONS')) { |
|
| 1707 | + define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 1708 | + } |
|
| 1709 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 1710 | + define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 1711 | + } |
|
| 1712 | + if (!defined('_DIR_CACHE')) { |
|
| 1713 | + define('_DIR_CACHE', $ti . "cache/"); |
|
| 1714 | + } |
|
| 1715 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 1716 | + define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 1717 | + } |
|
| 1718 | + if (!defined('_DIR_SKELS')) { |
|
| 1719 | + define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 1720 | + } |
|
| 1721 | + if (!defined('_DIR_AIDE')) { |
|
| 1722 | + define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 1723 | + } |
|
| 1724 | + if (!defined('_DIR_TMP')) { |
|
| 1725 | + define('_DIR_TMP', $ti); |
|
| 1726 | + } |
|
| 1727 | + |
|
| 1728 | + if (!defined('_DIR_VAR')) { |
|
| 1729 | + define('_DIR_VAR', $ta); |
|
| 1730 | + } |
|
| 1731 | + |
|
| 1732 | + if (!defined('_DIR_ETC')) { |
|
| 1733 | + define('_DIR_ETC', $pi); |
|
| 1734 | + } |
|
| 1735 | + if (!defined('_DIR_CONNECT')) { |
|
| 1736 | + define('_DIR_CONNECT', $pi); |
|
| 1737 | + } |
|
| 1738 | + if (!defined('_DIR_CHMOD')) { |
|
| 1739 | + define('_DIR_CHMOD', $pi); |
|
| 1740 | + } |
|
| 1741 | + |
|
| 1742 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 1743 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 1551 | 1744 | // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
| 1552 | 1745 | $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
| 1746 | + } |
|
| 1553 | 1747 | |
| 1554 | 1748 | // Declaration des fichiers |
| 1555 | 1749 | |
| 1556 | - if (!defined('_CACHE_PLUGINS_PATH')) define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 1557 | - if (!defined('_CACHE_PLUGINS_OPT')) define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 1558 | - if (!defined('_CACHE_PLUGINS_FCT')) define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 1559 | - if (!defined('_CACHE_PIPELINES')) define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 1560 | - if (!defined('_CACHE_CHEMIN')) define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 1750 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 1751 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 1752 | + } |
|
| 1753 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 1754 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 1755 | + } |
|
| 1756 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 1757 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 1758 | + } |
|
| 1759 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 1760 | + define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 1761 | + } |
|
| 1762 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 1763 | + define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 1764 | + } |
|
| 1561 | 1765 | |
| 1562 | 1766 | # attention .php obligatoire pour ecrire_fichier_securise |
| 1563 | - if (!defined('_FILE_META')) define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 1564 | - if (!defined('_DIR_LOG')) define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 1565 | - if (!defined('_FILE_LOG')) define('_FILE_LOG', 'spip'); |
|
| 1566 | - if (!defined('_FILE_LOG_SUFFIX')) define('_FILE_LOG_SUFFIX', '.log'); |
|
| 1767 | + if (!defined('_FILE_META')) { |
|
| 1768 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 1769 | + } |
|
| 1770 | + if (!defined('_DIR_LOG')) { |
|
| 1771 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 1772 | + } |
|
| 1773 | + if (!defined('_FILE_LOG')) { |
|
| 1774 | + define('_FILE_LOG', 'spip'); |
|
| 1775 | + } |
|
| 1776 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 1777 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 1778 | + } |
|
| 1567 | 1779 | |
| 1568 | 1780 | // Le fichier de connexion a la base de donnees |
| 1569 | 1781 | // tient compte des anciennes versions (inc_connect...) |
| 1570 | - if (!defined('_FILE_CONNECT_INS')) define('_FILE_CONNECT_INS', 'connect'); |
|
| 1571 | - if (!defined('_FILE_CONNECT')) define('_FILE_CONNECT', |
|
| 1782 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 1783 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 1784 | + } |
|
| 1785 | + if (!defined('_FILE_CONNECT')) { |
|
| 1786 | + define('_FILE_CONNECT', |
|
| 1572 | 1787 | (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
| 1573 | 1788 | : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
| 1574 | 1789 | : false))); |
| 1790 | + } |
|
| 1575 | 1791 | |
| 1576 | 1792 | // Le fichier de reglages des droits |
| 1577 | - if (!defined('_FILE_CHMOD_INS')) define('_FILE_CHMOD_INS', 'chmod'); |
|
| 1578 | - if (!defined('_FILE_CHMOD')) define('_FILE_CHMOD', |
|
| 1793 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 1794 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 1795 | + } |
|
| 1796 | + if (!defined('_FILE_CHMOD')) { |
|
| 1797 | + define('_FILE_CHMOD', |
|
| 1579 | 1798 | (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
| 1580 | 1799 | : false)); |
| 1800 | + } |
|
| 1581 | 1801 | |
| 1582 | - if (!defined('_FILE_LDAP')) define('_FILE_LDAP', 'ldap.php'); |
|
| 1802 | + if (!defined('_FILE_LDAP')) { |
|
| 1803 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 1804 | + } |
|
| 1583 | 1805 | |
| 1584 | - if (!defined('_FILE_TMP_SUFFIX')) define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 1585 | - if (!defined('_FILE_CONNECT_TMP')) define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 1586 | - if (!defined('_FILE_CHMOD_TMP')) define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 1806 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 1807 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 1808 | + } |
|
| 1809 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 1810 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 1811 | + } |
|
| 1812 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 1813 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 1814 | + } |
|
| 1587 | 1815 | |
| 1588 | 1816 | // Definition des droits d'acces en ecriture |
| 1589 | - if (!defined('_SPIP_CHMOD') AND _FILE_CHMOD) |
|
| 1590 | - include_once _FILE_CHMOD; |
|
| 1817 | + if (!defined('_SPIP_CHMOD') AND _FILE_CHMOD) { |
|
| 1818 | + include_once _FILE_CHMOD; |
|
| 1819 | + } |
|
| 1591 | 1820 | |
| 1592 | 1821 | // Se mefier des fichiers mal remplis! |
| 1593 | - if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', 0777); |
|
| 1822 | + if (!defined('_SPIP_CHMOD')) { |
|
| 1823 | + define('_SPIP_CHMOD', 0777); |
|
| 1824 | + } |
|
| 1594 | 1825 | |
| 1595 | 1826 | // Le charset par defaut lors de l'installation |
| 1596 | - if (!defined('_DEFAULT_CHARSET')) define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 1597 | - if (!defined('_ROOT_PLUGINS')) define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 1598 | - if (!defined('_ROOT_PLUGINS_DIST')) define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 1599 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE,'',_DIR_PLUGINS_SUPPL)); |
|
| 1827 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 1828 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 1829 | + } |
|
| 1830 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 1831 | + define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 1832 | + } |
|
| 1833 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 1834 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 1835 | + } |
|
| 1836 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 1837 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE,'',_DIR_PLUGINS_SUPPL)); |
|
| 1838 | + } |
|
| 1600 | 1839 | |
| 1601 | 1840 | // La taille des Log |
| 1602 | - if (!defined('_MAX_LOG')) define('_MAX_LOG', 100); |
|
| 1841 | + if (!defined('_MAX_LOG')) { |
|
| 1842 | + define('_MAX_LOG', 100); |
|
| 1843 | + } |
|
| 1603 | 1844 | |
| 1604 | 1845 | // Sommes-nous dans l'empire du Mal ? |
| 1605 | 1846 | // (ou sous le signe du Pingouin, ascendant GNU ?) |
| 1606 | 1847 | if (strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false){ |
| 1607 | - if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', 'windows'); |
|
| 1608 | - if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1609 | - } |
|
| 1610 | - else { |
|
| 1611 | - if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', ''); |
|
| 1612 | - if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php |
|
| 1848 | + if (!defined('_OS_SERVEUR')) { |
|
| 1849 | + define('_OS_SERVEUR', 'windows'); |
|
| 1850 | + } |
|
| 1851 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 1852 | + define('_SPIP_LOCK_MODE',1); |
|
| 1853 | + } |
|
| 1854 | + // utiliser le flock php |
|
| 1855 | + } else { |
|
| 1856 | + if (!defined('_OS_SERVEUR')) { |
|
| 1857 | + define('_OS_SERVEUR', ''); |
|
| 1858 | + } |
|
| 1859 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 1860 | + define('_SPIP_LOCK_MODE',1); |
|
| 1861 | + } |
|
| 1862 | + // utiliser le flock php |
|
| 1613 | 1863 | #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
| 1614 | 1864 | } |
| 1615 | 1865 | |
| 1616 | 1866 | // Langue par defaut |
| 1617 | - if (!defined('_LANGUE_PAR_DEFAUT')) define('_LANGUE_PAR_DEFAUT','fr'); |
|
| 1867 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 1868 | + define('_LANGUE_PAR_DEFAUT','fr'); |
|
| 1869 | + } |
|
| 1618 | 1870 | |
| 1619 | 1871 | // PHP_VERSION_ID dispo depuis PHP 5.2.7 |
| 1620 | 1872 | if (!defined('PHP_VERSION_ID')) { |
@@ -1639,7 +1891,9 @@ discard block |
||
| 1639 | 1891 | // |
| 1640 | 1892 | |
| 1641 | 1893 | // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
| 1642 | - if (isset($_REQUEST['GLOBALS'])) die(); |
|
| 1894 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 1895 | + die(); |
|
| 1896 | + } |
|
| 1643 | 1897 | // nettoyer les magic quotes \' et les caracteres nuls %00 |
| 1644 | 1898 | spip_desinfecte($_GET); |
| 1645 | 1899 | spip_desinfecte($_POST); |
@@ -1658,8 +1912,9 @@ discard block |
||
| 1658 | 1912 | // ne pas desinfecter les globales en profondeur car elle contient aussi les |
| 1659 | 1913 | // precedentes, qui seraient desinfectees 2 fois. |
| 1660 | 1914 | spip_desinfecte($GLOBALS,false); |
| 1661 | - if (include_spip('inc/php3')) |
|
| 1662 | - spip_register_globals(true); |
|
| 1915 | + if (include_spip('inc/php3')) { |
|
| 1916 | + spip_register_globals(true); |
|
| 1917 | + } |
|
| 1663 | 1918 | |
| 1664 | 1919 | $avertir_register_globals = true; |
| 1665 | 1920 | } |
@@ -1688,12 +1943,15 @@ discard block |
||
| 1688 | 1943 | } else { |
| 1689 | 1944 | $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF']; |
| 1690 | 1945 | if ($_SERVER['QUERY_STRING'] |
| 1691 | - AND !strpos($_SERVER['REQUEST_URI'], '?')) |
|
| 1692 | - $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1946 | + AND !strpos($_SERVER['REQUEST_URI'], '?')) { |
|
| 1947 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 1948 | + } |
|
| 1693 | 1949 | } |
| 1694 | 1950 | |
| 1695 | 1951 | // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
| 1696 | - if (!defined('_RENOUVELLE_ALEA')) define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 1952 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 1953 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 1954 | + } |
|
| 1697 | 1955 | |
| 1698 | 1956 | // charger les meta si possible et renouveller l'alea au besoin |
| 1699 | 1957 | // charge aussi effacer_meta et ecrire_meta |
@@ -1701,16 +1959,17 @@ discard block |
||
| 1701 | 1959 | $inc_meta(); |
| 1702 | 1960 | |
| 1703 | 1961 | // on a pas pu le faire plus tot |
| 1704 | - if ($avertir_register_globals) |
|
| 1705 | - avertir_auteurs("register_globals",_L("Problème de sécurité : register_globals=on; dans php.ini à corriger.")); |
|
| 1962 | + if ($avertir_register_globals) { |
|
| 1963 | + avertir_auteurs("register_globals",_L("Problème de sécurité : register_globals=on; dans php.ini à corriger.")); |
|
| 1964 | + } |
|
| 1706 | 1965 | |
| 1707 | 1966 | // nombre de repertoires depuis la racine |
| 1708 | 1967 | // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
| 1709 | 1968 | // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
| 1710 | 1969 | // le calcul est faux) |
| 1711 | - if (!_DIR_RESTREINT) |
|
| 1712 | - $GLOBALS['profondeur_url'] = 1; |
|
| 1713 | - else { |
|
| 1970 | + if (!_DIR_RESTREINT) { |
|
| 1971 | + $GLOBALS['profondeur_url'] = 1; |
|
| 1972 | + } else { |
|
| 1714 | 1973 | $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
| 1715 | 1974 | $uri_ref = $_SERVER["SCRIPT_NAME"]; |
| 1716 | 1975 | if (!$uri_ref |
@@ -1723,13 +1982,13 @@ discard block |
||
| 1723 | 1982 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 1724 | 1983 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 1725 | 1984 | $uri_ref = $uri_ref['path'].'/'; |
| 1726 | - } |
|
| 1727 | - else |
|
| 1728 | - $uri_ref = ""; |
|
| 1985 | + } else { |
|
| 1986 | + $uri_ref = ""; |
|
| 1987 | + } |
|
| 1729 | 1988 | } |
| 1730 | - if (!$uri OR !$uri_ref) |
|
| 1731 | - $GLOBALS['profondeur_url'] = 0; |
|
| 1732 | - else { |
|
| 1989 | + if (!$uri OR !$uri_ref) { |
|
| 1990 | + $GLOBALS['profondeur_url'] = 0; |
|
| 1991 | + } else { |
|
| 1733 | 1992 | $GLOBALS['profondeur_url'] = max(0, |
| 1734 | 1993 | substr_count($uri[0], '/') |
| 1735 | 1994 | - substr_count($uri_ref,'/')); |
@@ -1739,8 +1998,9 @@ discard block |
||
| 1739 | 1998 | if (_FILE_CONNECT) { |
| 1740 | 1999 | if (verifier_visiteur()=='0minirezo' |
| 1741 | 2000 | // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
| 1742 | - AND !isset($_COOKIE['spip_admin'])) |
|
| 1743 | - clear_path_cache(); |
|
| 2001 | + AND !isset($_COOKIE['spip_admin'])) { |
|
| 2002 | + clear_path_cache(); |
|
| 2003 | + } |
|
| 1744 | 2004 | } |
| 1745 | 2005 | |
| 1746 | 2006 | } |
@@ -1752,74 +2012,140 @@ discard block |
||
| 1752 | 2012 | */ |
| 1753 | 2013 | function spip_initialisation_suite() { |
| 1754 | 2014 | static $too_late = 0; |
| 1755 | - if ($too_late++) return; |
|
| 2015 | + if ($too_late++) { |
|
| 2016 | + return; |
|
| 2017 | + } |
|
| 1756 | 2018 | |
| 1757 | 2019 | // taille mini des login |
| 1758 | - if (!defined('_LOGIN_TROP_COURT')) define('_LOGIN_TROP_COURT', 4); |
|
| 2020 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2021 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2022 | + } |
|
| 1759 | 2023 | |
| 1760 | 2024 | // la taille maxi des logos (0 : pas de limite) |
| 1761 | - if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 1762 | - if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 1763 | - if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2025 | + if (!defined('_LOGO_MAX_SIZE')) { |
|
| 2026 | + define('_LOGO_MAX_SIZE', 0); |
|
| 2027 | + } |
|
| 2028 | + # poids en ko |
|
| 2029 | + if (!defined('_LOGO_MAX_WIDTH')) { |
|
| 2030 | + define('_LOGO_MAX_WIDTH', 0); |
|
| 2031 | + } |
|
| 2032 | + # largeur en pixels |
|
| 2033 | + if (!defined('_LOGO_MAX_HEIGHT')) { |
|
| 2034 | + define('_LOGO_MAX_HEIGHT', 0); |
|
| 2035 | + } |
|
| 2036 | + # hauteur en pixels |
|
| 1764 | 2037 | |
| 1765 | - if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2038 | + if (!defined('_DOC_MAX_SIZE')) { |
|
| 2039 | + define('_DOC_MAX_SIZE', 0); |
|
| 2040 | + } |
|
| 2041 | + # poids en ko |
|
| 1766 | 2042 | |
| 1767 | - if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 1768 | - if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 1769 | - if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 1770 | - if (!defined('_PASS_LONGUEUR_MINI')) define('_PASS_LONGUEUR_MINI',6); |
|
| 2043 | + if (!defined('_IMG_MAX_SIZE')) { |
|
| 2044 | + define('_IMG_MAX_SIZE', 0); |
|
| 2045 | + } |
|
| 2046 | + # poids en ko |
|
| 2047 | + if (!defined('_IMG_MAX_WIDTH')) { |
|
| 2048 | + define('_IMG_MAX_WIDTH', 0); |
|
| 2049 | + } |
|
| 2050 | + # largeur en pixels |
|
| 2051 | + if (!defined('_IMG_MAX_HEIGHT')) { |
|
| 2052 | + define('_IMG_MAX_HEIGHT', 0); |
|
| 2053 | + } |
|
| 2054 | + # hauteur en pixels |
|
| 2055 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2056 | + define('_PASS_LONGUEUR_MINI',6); |
|
| 2057 | + } |
|
| 1771 | 2058 | |
| 1772 | 2059 | |
| 1773 | 2060 | // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
| 1774 | - if (!defined('_IMG_QUALITE')) define('_IMG_QUALITE', 85); # valeur par defaut |
|
| 1775 | - if (!defined('_IMG_GD_QUALITE')) define('_IMG_GD_QUALITE', _IMG_QUALITE); # surcharge pour la lib GD |
|
| 1776 | - if (!defined('_IMG_CONVERT_QUALITE')) define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); # surcharge pour imagick en ligne de commande |
|
| 2061 | + if (!defined('_IMG_QUALITE')) { |
|
| 2062 | + define('_IMG_QUALITE', 85); |
|
| 2063 | + } |
|
| 2064 | + # valeur par defaut |
|
| 2065 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2066 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2067 | + } |
|
| 2068 | + # surcharge pour la lib GD |
|
| 2069 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2070 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2071 | + } |
|
| 2072 | + # surcharge pour imagick en ligne de commande |
|
| 1777 | 2073 | // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
| 1778 | - if (!defined('_IMG_IMAGICK_QUALITE')) define('_IMG_IMAGICK_QUALITE', 75); # surcharge pour imagick en PHP |
|
| 2074 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2075 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2076 | + } |
|
| 2077 | + # surcharge pour imagick en PHP |
|
| 1779 | 2078 | |
| 1780 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) define('_COPIE_LOCALE_MAX_SIZE',16777216); // poids en octet |
|
| 2079 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2080 | + define('_COPIE_LOCALE_MAX_SIZE',16777216); |
|
| 2081 | + } |
|
| 2082 | + // poids en octet |
|
| 1781 | 2083 | |
| 1782 | 2084 | // qq chaines standard |
| 1783 | - if (!defined('_ACCESS_FILE_NAME')) define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 1784 | - if (!defined('_AUTH_USER_FILE')) define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 1785 | - if (!defined('_SPIP_DUMP')) define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 1786 | - if (!defined('_CACHE_RUBRIQUES')) define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 1787 | - if (!defined('_CACHE_RUBRIQUES_MAX')) define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2085 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2086 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2087 | + } |
|
| 2088 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2089 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2090 | + } |
|
| 2091 | + if (!defined('_SPIP_DUMP')) { |
|
| 2092 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2093 | + } |
|
| 2094 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2095 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2096 | + } |
|
| 2097 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2098 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2099 | + } |
|
| 1788 | 2100 | |
| 1789 | - if (!defined('_EXTENSION_SQUELETTES')) define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2101 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2102 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2103 | + } |
|
| 1790 | 2104 | |
| 1791 | - if (!defined('_DOCTYPE_ECRIRE')) define('_DOCTYPE_ECRIRE', |
|
| 2105 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2106 | + define('_DOCTYPE_ECRIRE', |
|
| 1792 | 2107 | // "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n"); |
| 1793 | 2108 | //"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n"); |
| 1794 | 2109 | //"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n"); |
| 1795 | 2110 | // "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1 //EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>\n"); |
| 1796 | 2111 | "<!DOCTYPE html>\n"); |
| 1797 | - if (!defined('_DOCTYPE_AIDE')) define('_DOCTYPE_AIDE', |
|
| 2112 | + } |
|
| 2113 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2114 | + define('_DOCTYPE_AIDE', |
|
| 1798 | 2115 | "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
| 2116 | + } |
|
| 1799 | 2117 | |
| 1800 | 2118 | // L'adresse de base du site ; on peut mettre '' si la racine est geree par |
| 1801 | 2119 | // le script de l'espace public, alias index.php |
| 1802 | - if (!defined('_SPIP_SCRIPT')) define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2120 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2121 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2122 | + } |
|
| 1803 | 2123 | // argument page, personalisable en cas de conflit avec un autre script |
| 1804 | - if (!defined('_SPIP_PAGE')) define('_SPIP_PAGE', 'page'); |
|
| 2124 | + if (!defined('_SPIP_PAGE')) { |
|
| 2125 | + define('_SPIP_PAGE', 'page'); |
|
| 2126 | + } |
|
| 1805 | 2127 | |
| 1806 | 2128 | // le script de l'espace prive |
| 1807 | 2129 | // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
| 1808 | 2130 | // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
| 1809 | 2131 | // meme pb sur thttpd cf. http://forum.spip.org/fr_184153.html |
| 1810 | 2132 | |
| 1811 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) define('_SPIP_ECRIRE_SCRIPT', // true ? #decommenter ici et commenter la |
|
| 2133 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2134 | + define('_SPIP_ECRIRE_SCRIPT', // true ? #decommenter ici et commenter la |
|
| 1812 | 2135 | preg_match(',IIS|thttpd,',$_SERVER['SERVER_SOFTWARE']) ? |
| 1813 | 2136 | 'index.php' : ''); |
| 2137 | + } |
|
| 1814 | 2138 | |
| 1815 | 2139 | |
| 1816 | - if (!defined('_SPIP_AJAX')) |
|
| 1817 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2140 | + if (!defined('_SPIP_AJAX')) { |
|
| 2141 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 1818 | 2142 | ? 1 |
| 1819 | 2143 | : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
| 2144 | + } |
|
| 1820 | 2145 | |
| 1821 | 2146 | // La requete est-elle en ajax ? |
| 1822 | - if (!defined('_AJAX')) define('_AJAX', |
|
| 2147 | + if (!defined('_AJAX')) { |
|
| 2148 | + define('_AJAX', |
|
| 1823 | 2149 | (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
| 1824 | 2150 | OR @$_REQUEST['var_ajax_redir'] # redirection 302 apres ajax jQuery |
| 1825 | 2151 | OR @$_REQUEST['var_ajaxcharset'] # compat ascendante pour plugins |
@@ -1827,16 +2153,22 @@ discard block |
||
| 1827 | 2153 | ) |
| 1828 | 2154 | AND !@$_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 |
| 1829 | 2155 | ); |
| 2156 | + } |
|
| 1830 | 2157 | |
| 1831 | 2158 | # nombre de pixels maxi pour calcul de la vignette avec gd |
| 1832 | 2159 | # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
| 1833 | 2160 | # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
| 1834 | - if (!defined('_IMG_GD_MAX_PIXELS')) define('_IMG_GD_MAX_PIXELS', |
|
| 2161 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2162 | + define('_IMG_GD_MAX_PIXELS', |
|
| 1835 | 2163 | (isset($GLOBALS['meta']['max_taille_vignettes'])&&$GLOBALS['meta']['max_taille_vignettes']<5500000) |
| 1836 | 2164 | ? $GLOBALS['meta']['max_taille_vignettes'] |
| 1837 | 2165 | : 0); |
| 2166 | + } |
|
| 1838 | 2167 | |
| 1839 | - if (!defined('_MEMORY_LIMIT_MIN')) define('_MEMORY_LIMIT_MIN',10); // en Mo |
|
| 2168 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2169 | + define('_MEMORY_LIMIT_MIN',10); |
|
| 2170 | + } |
|
| 2171 | + // en Mo |
|
| 1840 | 2172 | // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
| 1841 | 2173 | // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
| 1842 | 2174 | // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
@@ -1852,16 +2184,22 @@ discard block |
||
| 1852 | 2184 | if ($memory<_MEMORY_LIMIT_MIN*1024*1024){ |
| 1853 | 2185 | ini_set('memory_limit',$m=_MEMORY_LIMIT_MIN.'M'); |
| 1854 | 2186 | if (trim(ini_get('memory_limit'))!=$m){ |
| 1855 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2187 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2188 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); |
|
| 2189 | + } |
|
| 2190 | + // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1856 | 2191 | } |
| 1857 | 2192 | } |
| 1858 | - } |
|
| 1859 | - else |
|
| 1860 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2193 | + } else |
|
| 2194 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2195 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); |
|
| 2196 | + } |
|
| 2197 | + // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 1861 | 2198 | } |
| 1862 | 2199 | // Protocoles a normaliser dans les chaines de langues |
| 1863 | - if (!defined('_PROTOCOLES_STD')) |
|
| 1864 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2200 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2201 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2202 | + } |
|
| 1865 | 2203 | |
| 1866 | 2204 | init_var_mode(); |
| 1867 | 2205 | } |
@@ -1877,7 +2215,9 @@ discard block |
||
| 1877 | 2215 | // tout le monde peut calcul/recalcul |
| 1878 | 2216 | if ($_GET['var_mode'] == 'calcul' |
| 1879 | 2217 | OR $_GET['var_mode'] == 'recalcul') { |
| 1880 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 2218 | + if (!defined('_VAR_MODE')) { |
|
| 2219 | + define('_VAR_MODE',$_GET['var_mode']); |
|
| 2220 | + } |
|
| 1881 | 2221 | } |
| 1882 | 2222 | // preview, debug, blocs, urls et images necessitent une autorisation |
| 1883 | 2223 | else if (in_array($_GET['var_mode'],array('preview','debug','inclure','urls','images','traduction'))) { |
@@ -1890,48 +2230,79 @@ discard block |
||
| 1890 | 2230 | switch($_GET['var_mode']){ |
| 1891 | 2231 | case 'traduction': |
| 1892 | 2232 | // forcer le calcul pour passer dans traduire |
| 1893 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 2233 | + if (!defined('_VAR_MODE')) { |
|
| 2234 | + define('_VAR_MODE','calcul'); |
|
| 2235 | + } |
|
| 1894 | 2236 | // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
| 1895 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 2237 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2238 | + define('_VAR_NOCACHE',true); |
|
| 2239 | + } |
|
| 1896 | 2240 | break; |
| 1897 | 2241 | case 'preview': |
| 1898 | 2242 | // basculer sur les criteres de preview dans les boucles |
| 1899 | - if (!defined('_VAR_PREVIEW')) define('_VAR_PREVIEW',true); |
|
| 2243 | + if (!defined('_VAR_PREVIEW')) { |
|
| 2244 | + define('_VAR_PREVIEW',true); |
|
| 2245 | + } |
|
| 1900 | 2246 | // forcer le calcul |
| 1901 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 2247 | + if (!defined('_VAR_MODE')) { |
|
| 2248 | + define('_VAR_MODE','calcul'); |
|
| 2249 | + } |
|
| 1902 | 2250 | // et ne pas enregistrer de cache |
| 1903 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 2251 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2252 | + define('_VAR_NOCACHE',true); |
|
| 2253 | + } |
|
| 1904 | 2254 | break; |
| 1905 | 2255 | case 'inclure': |
| 1906 | 2256 | // forcer le compilo et ignorer les caches existants |
| 1907 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1908 | - if (!defined('_VAR_INCLURE')) define('_VAR_INCLURE',true); |
|
| 2257 | + if (!defined('_VAR_MODE')) { |
|
| 2258 | + define('_VAR_MODE','calcul'); |
|
| 2259 | + } |
|
| 2260 | + if (!defined('_VAR_INCLURE')) { |
|
| 2261 | + define('_VAR_INCLURE',true); |
|
| 2262 | + } |
|
| 1909 | 2263 | // et ne pas enregistrer de cache |
| 1910 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 2264 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2265 | + define('_VAR_NOCACHE',true); |
|
| 2266 | + } |
|
| 1911 | 2267 | break; |
| 1912 | 2268 | case 'urls': |
| 1913 | 2269 | // forcer le compilo et ignorer les caches existants |
| 1914 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 1915 | - if (!defined('_VAR_URLS')) define('_VAR_URLS',true); |
|
| 2270 | + if (!defined('_VAR_MODE')) { |
|
| 2271 | + define('_VAR_MODE','calcul'); |
|
| 2272 | + } |
|
| 2273 | + if (!defined('_VAR_URLS')) { |
|
| 2274 | + define('_VAR_URLS',true); |
|
| 2275 | + } |
|
| 1916 | 2276 | break; |
| 1917 | 2277 | case 'images': |
| 1918 | 2278 | // forcer le compilo et ignorer les caches existants |
| 1919 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul'); |
|
| 2279 | + if (!defined('_VAR_MODE')) { |
|
| 2280 | + define('_VAR_MODE','calcul'); |
|
| 2281 | + } |
|
| 1920 | 2282 | // indiquer qu'on doit recalculer les images |
| 1921 | - if (!defined('_VAR_IMAGES')) define('_VAR_IMAGES',true); |
|
| 2283 | + if (!defined('_VAR_IMAGES')) { |
|
| 2284 | + define('_VAR_IMAGES',true); |
|
| 2285 | + } |
|
| 1922 | 2286 | break; |
| 1923 | 2287 | case 'debug': |
| 1924 | - if (!defined('_VAR_MODE')) define('_VAR_MODE','debug'); |
|
| 2288 | + if (!defined('_VAR_MODE')) { |
|
| 2289 | + define('_VAR_MODE','debug'); |
|
| 2290 | + } |
|
| 1925 | 2291 | // et ne pas enregistrer de cache |
| 1926 | - if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true); |
|
| 2292 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2293 | + define('_VAR_NOCACHE',true); |
|
| 2294 | + } |
|
| 1927 | 2295 | break; |
| 1928 | 2296 | default : |
| 1929 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']); |
|
| 2297 | + if (!defined('_VAR_MODE')) { |
|
| 2298 | + define('_VAR_MODE',$_GET['var_mode']); |
|
| 2299 | + } |
|
| 1930 | 2300 | break; |
| 1931 | 2301 | } |
| 1932 | - if (isset($GLOBALS['visiteur_session']['nom'])) |
|
| 1933 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2302 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2303 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 1934 | 2304 | . " "._VAR_MODE); |
| 2305 | + } |
|
| 1935 | 2306 | } |
| 1936 | 2307 | // pas autorise ? |
| 1937 | 2308 | else { |
@@ -1946,7 +2317,9 @@ discard block |
||
| 1946 | 2317 | // sinon tant pis |
| 1947 | 2318 | } |
| 1948 | 2319 | } |
| 1949 | - if (!defined('_VAR_MODE')) define('_VAR_MODE',false); |
|
| 2320 | + if (!defined('_VAR_MODE')) { |
|
| 2321 | + define('_VAR_MODE',false); |
|
| 2322 | + } |
|
| 1950 | 2323 | } |
| 1951 | 2324 | $done = true; |
| 1952 | 2325 | } |
@@ -1958,18 +2331,21 @@ discard block |
||
| 1958 | 2331 | // http://doc.spip.org/@spip_desinfecte |
| 1959 | 2332 | function spip_desinfecte(&$t,$deep = true) { |
| 1960 | 2333 | static $magic_quotes; |
| 1961 | - if (!isset($magic_quotes)) |
|
| 1962 | - $magic_quotes = @get_magic_quotes_gpc(); |
|
| 2334 | + if (!isset($magic_quotes)) { |
|
| 2335 | + $magic_quotes = @get_magic_quotes_gpc(); |
|
| 2336 | + } |
|
| 1963 | 2337 | |
| 1964 | 2338 | foreach ($t as $key => $val) { |
| 1965 | 2339 | if (is_string($t[$key])) { |
| 1966 | - if ($magic_quotes) |
|
| 1967 | - $t[$key] = stripslashes($t[$key]); |
|
| 2340 | + if ($magic_quotes) { |
|
| 2341 | + $t[$key] = stripslashes($t[$key]); |
|
| 2342 | + } |
|
| 1968 | 2343 | $t[$key] = str_replace(chr(0), '-', $t[$key]); |
| 1969 | 2344 | } |
| 1970 | 2345 | // traiter aussi les "texte_plus" de article_edit |
| 1971 | - else if ($deep AND is_array($t[$key]) AND $key!=='GLOBALS') |
|
| 1972 | - spip_desinfecte($t[$key],$deep); |
|
| 2346 | + else if ($deep AND is_array($t[$key]) AND $key!=='GLOBALS') { |
|
| 2347 | + spip_desinfecte($t[$key],$deep); |
|
| 2348 | + } |
|
| 1973 | 2349 | } |
| 1974 | 2350 | } |
| 1975 | 2351 | |
@@ -2004,11 +2380,13 @@ discard block |
||
| 2004 | 2380 | $session = charger_fonction('session', 'inc'); |
| 2005 | 2381 | $session(); |
| 2006 | 2382 | include_spip('inc/texte'); |
| 2007 | - foreach($variables_session as $var) |
|
| 2008 | - if (($a = _request($var)) !== null) |
|
| 2383 | + foreach($variables_session as $var) { |
|
| 2384 | + if (($a = _request($var)) !== null) |
|
| 2009 | 2385 | $GLOBALS['visiteur_session'][$var] = safehtml($a); |
| 2010 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) |
|
| 2011 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2386 | + } |
|
| 2387 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 2388 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 2389 | + } |
|
| 2012 | 2390 | $session($GLOBALS['visiteur_session']); |
| 2013 | 2391 | return 0; |
| 2014 | 2392 | } |
@@ -2047,15 +2425,17 @@ discard block |
||
| 2047 | 2425 | // http://doc.spip.org/@lang_select |
| 2048 | 2426 | function lang_select ($lang=NULL) { |
| 2049 | 2427 | static $pile_langues = array(); |
| 2050 | - if (!function_exists('changer_langue')) |
|
| 2051 | - include_spip('inc/lang'); |
|
| 2052 | - if ($lang === NULL) |
|
| 2053 | - $lang = array_pop($pile_langues); |
|
| 2054 | - else { |
|
| 2428 | + if (!function_exists('changer_langue')) { |
|
| 2429 | + include_spip('inc/lang'); |
|
| 2430 | + } |
|
| 2431 | + if ($lang === NULL) { |
|
| 2432 | + $lang = array_pop($pile_langues); |
|
| 2433 | + } else { |
|
| 2055 | 2434 | array_push($pile_langues, $GLOBALS['spip_lang']); |
| 2056 | 2435 | } |
| 2057 | - if (isset($GLOBALS['spip_lang']) AND $lang == $GLOBALS['spip_lang']) |
|
| 2058 | - return $lang; |
|
| 2436 | + if (isset($GLOBALS['spip_lang']) AND $lang == $GLOBALS['spip_lang']) { |
|
| 2437 | + return $lang; |
|
| 2438 | + } |
|
| 2059 | 2439 | changer_langue($lang); |
| 2060 | 2440 | return $lang; |
| 2061 | 2441 | } |
@@ -2106,11 +2486,12 @@ discard block |
||
| 2106 | 2486 | // http://doc.spip.org/@exec_info_dist |
| 2107 | 2487 | function exec_info_dist() { |
| 2108 | 2488 | global $connect_statut; |
| 2109 | - if ($connect_statut == '0minirezo') |
|
| 2110 | - phpinfo(); |
|
| 2111 | - else |
|
| 2112 | - echo "pas admin"; |
|
| 2113 | -} |
|
| 2489 | + if ($connect_statut == '0minirezo') { |
|
| 2490 | + phpinfo(); |
|
| 2491 | + } else { |
|
| 2492 | + echo "pas admin"; |
|
| 2493 | + } |
|
| 2494 | + } |
|
| 2114 | 2495 | |
| 2115 | 2496 | /** |
| 2116 | 2497 | * Génère une erreur de squelette |
@@ -2169,12 +2550,17 @@ discard block |
||
| 2169 | 2550 | * ou tableau d'information sur le squelette. |
| 2170 | 2551 | */ |
| 2171 | 2552 | function recuperer_fond($fond, $contexte=array(), $options = array(), $connect='') { |
| 2172 | - if (!function_exists('evaluer_fond')) |
|
| 2173 | - include_spip('public/assembler'); |
|
| 2553 | + if (!function_exists('evaluer_fond')) { |
|
| 2554 | + include_spip('public/assembler'); |
|
| 2555 | + } |
|
| 2174 | 2556 | // assurer la compat avec l'ancienne syntaxe |
| 2175 | 2557 | // (trim etait le 3eme argument, par defaut a true) |
| 2176 | - if (!is_array($options)) $options = array('trim'=>$options); |
|
| 2177 | - if (!isset($options['trim'])) $options['trim']=true; |
|
| 2558 | + if (!is_array($options)) { |
|
| 2559 | + $options = array('trim'=>$options); |
|
| 2560 | + } |
|
| 2561 | + if (!isset($options['trim'])) { |
|
| 2562 | + $options['trim']=true; |
|
| 2563 | + } |
|
| 2178 | 2564 | |
| 2179 | 2565 | if (isset($contexte['connect'])){ |
| 2180 | 2566 | $connect = ($connect ? $connect : $contexte['connect']); |
@@ -2186,8 +2572,9 @@ discard block |
||
| 2186 | 2572 | $lang_select = ''; |
| 2187 | 2573 | if (!isset($options['etoile']) OR !$options['etoile']){ |
| 2188 | 2574 | // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
| 2189 | - if (!isset($contexte['lang'])) |
|
| 2190 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 2575 | + if (!isset($contexte['lang'])) { |
|
| 2576 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 2577 | + } |
|
| 2191 | 2578 | |
| 2192 | 2579 | if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
| 2193 | 2580 | $lang_select = lang_select($contexte['lang']); |
@@ -2212,25 +2599,30 @@ discard block |
||
| 2212 | 2599 | 'data'=>$page |
| 2213 | 2600 | )); |
| 2214 | 2601 | if (isset($options['ajax']) AND $options['ajax']){ |
| 2215 | - if (!function_exists('encoder_contexte_ajax')) |
|
| 2216 | - include_spip('inc/filtres'); |
|
| 2602 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 2603 | + include_spip('inc/filtres'); |
|
| 2604 | + } |
|
| 2217 | 2605 | $page['texte'] = encoder_contexte_ajax(array_merge($contexte,array('fond'=>$f)),'',$page['texte'], $options['ajax']); |
| 2218 | 2606 | } |
| 2219 | 2607 | |
| 2220 | - if (isset($options['raw']) AND $options['raw']) |
|
| 2221 | - $pages[] = $page; |
|
| 2222 | - else |
|
| 2223 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 2608 | + if (isset($options['raw']) AND $options['raw']) { |
|
| 2609 | + $pages[] = $page; |
|
| 2610 | + } else { |
|
| 2611 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 2612 | + } |
|
| 2224 | 2613 | } |
| 2225 | 2614 | |
| 2226 | 2615 | $GLOBALS['_INC_PUBLIC']--; |
| 2227 | 2616 | |
| 2228 | - if ($lang_select) lang_select(); |
|
| 2229 | - if (isset($options['raw']) AND $options['raw']) |
|
| 2230 | - return is_array($fond)?$pages:reset($pages); |
|
| 2231 | - else |
|
| 2232 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 2233 | -} |
|
| 2617 | + if ($lang_select) { |
|
| 2618 | + lang_select(); |
|
| 2619 | + } |
|
| 2620 | + if (isset($options['raw']) AND $options['raw']) { |
|
| 2621 | + return is_array($fond)?$pages:reset($pages); |
|
| 2622 | + } else { |
|
| 2623 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 2624 | + } |
|
| 2625 | + } |
|
| 2234 | 2626 | |
| 2235 | 2627 | /** |
| 2236 | 2628 | * Trouve un squelette dans le repertoire modeles/ |
@@ -2256,7 +2648,9 @@ discard block |
||
| 2256 | 2648 | */ |
| 2257 | 2649 | function trouver_fond($nom, $dir='', $pathinfo = false) { |
| 2258 | 2650 | $f = find_in_path($nom.'.'. _EXTENSION_SQUELETTES, $dir?rtrim($dir,'/').'/':''); |
| 2259 | - if (!$pathinfo) return $f; |
|
| 2651 | + if (!$pathinfo) { |
|
| 2652 | + return $f; |
|
| 2653 | + } |
|
| 2260 | 2654 | // renvoyer un tableau detaille si $pathinfo==true |
| 2261 | 2655 | $p = pathinfo($f); |
| 2262 | 2656 | if (!isset($p['extension']) OR !$p['extension']) { |
@@ -2271,16 +2665,21 @@ discard block |
||
| 2271 | 2665 | |
| 2272 | 2666 | function tester_url_ecrire($nom){ |
| 2273 | 2667 | static $exec=array(); |
| 2274 | - if (isset($exec[$nom])) return $exec[$nom]; |
|
| 2668 | + if (isset($exec[$nom])) { |
|
| 2669 | + return $exec[$nom]; |
|
| 2670 | + } |
|
| 2275 | 2671 | // tester si c'est une page en squelette |
| 2276 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) |
|
| 2277 | - return $exec[$nom] = 'fond'; |
|
| 2672 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 2673 | + return $exec[$nom] = 'fond'; |
|
| 2674 | + } |
|
| 2278 | 2675 | // compat skels orthogonaux version precedente |
| 2279 | - elseif (trouver_fond($nom, 'prive/exec/')) |
|
| 2280 | - return $exec[$nom] = 'fond_monobloc'; |
|
| 2676 | + elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 2677 | + return $exec[$nom] = 'fond_monobloc'; |
|
| 2678 | + } |
|
| 2281 | 2679 | // echafaudage d'un fond ! |
| 2282 | - elseif(include_spip('public/styliser_par_z') AND z_echafaudable($nom)) |
|
| 2283 | - return $exec[$nom] = 'fond'; |
|
| 2680 | + elseif(include_spip('public/styliser_par_z') AND z_echafaudable($nom)) { |
|
| 2681 | + return $exec[$nom] = 'fond'; |
|
| 2682 | + } |
|
| 2284 | 2683 | // attention, il ne faut pas inclure l'exec ici |
| 2285 | 2684 | // car sinon #URL_ECRIRE provoque des inclusions |
| 2286 | 2685 | // et des define intrusifs potentiels |
@@ -2324,13 +2723,23 @@ discard block |
||
| 2324 | 2723 | // http://doc.spip.org/@spip_fetch_array |
| 2325 | 2724 | function spip_fetch_array($r, $t=NULL) { |
| 2326 | 2725 | if (!isset($t)) { |
| 2327 | - if ($r) return sql_fetch($r); |
|
| 2726 | + if ($r) { |
|
| 2727 | + return sql_fetch($r); |
|
| 2728 | + } |
|
| 2328 | 2729 | } else { |
| 2329 | - if ($t=='SPIP_NUM') $t = MYSQL_NUM; |
|
| 2330 | - if ($t=='SPIP_BOTH') $t = MYSQL_BOTH; |
|
| 2331 | - if ($t=='SPIP_ASSOC') $t = MYSQL_ASSOC; |
|
| 2730 | + if ($t=='SPIP_NUM') { |
|
| 2731 | + $t = MYSQL_NUM; |
|
| 2732 | + } |
|
| 2733 | + if ($t=='SPIP_BOTH') { |
|
| 2734 | + $t = MYSQL_BOTH; |
|
| 2735 | + } |
|
| 2736 | + if ($t=='SPIP_ASSOC') { |
|
| 2737 | + $t = MYSQL_ASSOC; |
|
| 2738 | + } |
|
| 2332 | 2739 | spip_log("appel deprecie de spip_fetch_array(..., $t)", 'vieilles_defs'); |
| 2333 | - if ($r) return mysql_fetch_array($r, $t); |
|
| 2740 | + if ($r) { |
|
| 2741 | + return mysql_fetch_array($r, $t); |
|
| 2742 | + } |
|
| 2334 | 2743 | } |
| 2335 | 2744 | } |
| 2336 | 2745 | |
@@ -2347,11 +2756,13 @@ discard block |
||
| 2347 | 2756 | function avertir_auteurs($nom,$message, $statut=''){ |
| 2348 | 2757 | $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
| 2349 | 2758 | if (!$alertes |
| 2350 | - OR !is_array($alertes = unserialize($alertes))) |
|
| 2351 | - $alertes = array(); |
|
| 2759 | + OR !is_array($alertes = unserialize($alertes))) { |
|
| 2760 | + $alertes = array(); |
|
| 2761 | + } |
|
| 2352 | 2762 | |
| 2353 | - if (!isset($alertes[$statut])) |
|
| 2354 | - $alertes[$statut] = array(); |
|
| 2763 | + if (!isset($alertes[$statut])) { |
|
| 2764 | + $alertes[$statut] = array(); |
|
| 2765 | + } |
|
| 2355 | 2766 | $alertes[$statut][$nom] = $message; |
| 2356 | 2767 | ecrire_meta("message_alertes_auteurs",serialize($alertes)); |
| 2357 | 2768 | } |
@@ -22,202 +22,202 @@ |
||
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 23 | 23 | |
| 24 | 24 | $GLOBALS['codes_langues'] = array( |
| 25 | - 'aa' => "Afar", |
|
| 26 | - 'ab' => "Abkhazian", |
|
| 27 | - 'af' => "Afrikaans", |
|
| 28 | - 'am' => "Amharic", |
|
| 29 | - 'an' => "Aragonés", |
|
| 30 | - 'ar' => "عربي", |
|
| 31 | - 'as' => "Assamese", |
|
| 32 | - 'ast' => "asturianu", |
|
| 33 | - 'ay' => "Aymara", |
|
| 34 | - 'az' => "Azərbaycan dili", |
|
| 35 | - 'ba' => "Bashkir", |
|
| 36 | - 'be' => "Беларуская", |
|
| 37 | - 'ber_tam' => "Tamazigh", |
|
| 38 | - 'ber_tam_tfng' => "Tamazigh tifinagh", |
|
| 39 | - 'bg' => "български", |
|
| 40 | - 'bh' => "Bihari", |
|
| 41 | - 'bi' => "Bislama", |
|
| 42 | - 'bm' => "Bambara", |
|
| 43 | - 'bn' => "Bengali; Bangla", |
|
| 44 | - 'bo' => "Tibetan", |
|
| 45 | - 'br' => "brezhoneg", |
|
| 46 | - 'bs' => "bosanski", |
|
| 47 | - 'ca' => "català", |
|
| 48 | - 'co' => "corsu", |
|
| 49 | - 'cpf' => "Kréol réyoné", |
|
| 50 | - 'cpf_dom' => "Kreyòl", |
|
| 51 | - 'cpf_hat' => "Kreyòl (Peyi Dayiti)", |
|
| 52 | - 'cs' => "čeština", |
|
| 53 | - 'cy' => "Cymraeg", # welsh, gallois |
|
| 54 | - 'da' => "dansk", |
|
| 55 | - 'de' => "Deutsch", |
|
| 56 | - 'dz' => "Bhutani", |
|
| 57 | - 'el' => "ελληνικά", |
|
| 58 | - 'en' => "English", |
|
| 59 | - 'en_hx' => "H4ck3R", |
|
| 60 | - 'en_sm' => "Smurf", |
|
| 61 | - 'eo' => "Esperanto", |
|
| 62 | - 'es' => "Español", |
|
| 63 | - 'es_co' => "Colombiano", |
|
| 64 | - 'es_mx_pop' => "Mexicano a lo güey", |
|
| 65 | - 'et' => "eesti", |
|
| 66 | - 'eu' => "euskara", |
|
| 67 | - 'fa' => "فارسى", |
|
| 68 | - 'ff' => "Fulah", // peul |
|
| 69 | - 'fi' => "suomi", |
|
| 70 | - 'fj' => "Fiji", |
|
| 71 | - 'fo' => "føroyskt", |
|
| 72 | - 'fon' => "fongbè", |
|
| 73 | - 'fr' => "français", |
|
| 74 | - 'fr_fem' => "français féminin", |
|
| 75 | - 'fr_sc' => "schtroumpf", |
|
| 76 | - 'fr_lpc' => "langue parlée complétée", |
|
| 77 | - 'fr_lsf' => "langue des signes française", |
|
| 78 | - 'fr_spl' => "français simplifié", |
|
| 79 | - 'fr_tu' => "français copain", |
|
| 80 | - 'fy' => "Frisian", |
|
| 81 | - 'ga' => "Irish", |
|
| 82 | - 'gd' => "Scots Gaelic", |
|
| 83 | - 'gl' => "galego", |
|
| 84 | - 'gn' => "Guarani", |
|
| 85 | - 'grc' => "Ἀρχαία Ἑλληνική", // grec ancien |
|
| 86 | - 'gu' => "Gujarati", |
|
| 87 | - 'ha' => "Hausa", |
|
| 88 | - 'hac' => "ک-هۆرامی", //"Kurdish-Horami" |
|
| 89 | - 'hbo' => "עברית־התנך", // hebreu classique ou biblique |
|
| 90 | - 'he' => "עברית", |
|
| 91 | - 'hi' => "हिंदी", |
|
| 92 | - 'hr' => "hrvatski", |
|
| 93 | - 'hu' => "magyar", |
|
| 94 | - 'hy' => "Հայերեն",// Arménien |
|
| 95 | - 'ia' => "Interlingua", |
|
| 96 | - 'id' => "Indonesia", |
|
| 97 | - 'ie' => "Interlingue", |
|
| 98 | - 'ik' => "Inupiak", |
|
| 99 | - 'is' => "íslenska", |
|
| 100 | - 'it' => "italiano", |
|
| 101 | - 'it_fem' => "italiana", |
|
| 102 | - 'iu' => "Inuktitut", |
|
| 103 | - 'ja' => "日本語", |
|
| 104 | - 'jv' => "Javanese", |
|
| 105 | - 'ka' => "ქართული", |
|
| 106 | - 'kk' => "қазақ тілі", // Kazakh |
|
| 107 | - 'kl' => "kalaallisut", |
|
| 108 | - 'km' => "ភាសាខ្មែរ",// Khmer |
|
| 109 | - 'kn' => "Kannada", |
|
| 110 | - 'ko' => "한국어", |
|
| 111 | - 'kok' => "कोंकणी", // Konkani |
|
| 112 | - 'ks' => "Kashmiri", |
|
| 113 | - 'ku' => "کوردی", |
|
| 114 | - 'ky' => "Kirghiz", |
|
| 115 | - 'la' => "lingua latina", |
|
| 116 | - 'lb' => "Lëtzebuergesch", |
|
| 117 | - 'ln' => "Lingala", |
|
| 118 | - 'lo' => "ພາສາລາວ", # lao |
|
| 119 | - 'lt' => "lietuvių", |
|
| 120 | - 'lu' => "luba-katanga", |
|
| 121 | - 'lv' => "latviešu", |
|
| 122 | - 'man' => "mandingue", # a traduire en mandingue |
|
| 123 | - 'mfv' => "manjak", # ISO-639-3 |
|
| 124 | - 'mg' => "Malagasy", |
|
| 125 | - 'mi' => "Maori", |
|
| 126 | - 'mk' => "македонски јазик", |
|
| 127 | - 'ml' => "Malayalam", |
|
| 128 | - 'mn' => "Монгол хэл", |
|
| 129 | - 'mo' => "Moldavian", |
|
| 130 | - 'mos' => "Moré", |
|
| 131 | - 'mr' => "मराठी", |
|
| 132 | - 'ms' => "Bahasa Malaysia", |
|
| 133 | - 'mt' => "Maltese", |
|
| 134 | - 'my' => "Burmese", |
|
| 135 | - 'na' => "Nauru", |
|
| 136 | - 'nap' => "napulitano", |
|
| 137 | - 'ne' => "Nepali", |
|
| 138 | - 'nqo' => "N'ko", // www.manden.org |
|
| 139 | - 'nl' => "Nederlands", |
|
| 140 | - 'no' => "norsk", |
|
| 141 | - 'nb' => "norsk bokmål", |
|
| 142 | - 'nn' => "norsk nynorsk", |
|
| 143 | - 'oc' => "òc", |
|
| 144 | - 'oc_lnc' => "òc lengadocian", |
|
| 145 | - 'oc_ni' => "òc niçard", |
|
| 146 | - 'oc_ni_la' => "òc niçard (larg)", |
|
| 147 | - 'oc_ni_mis' => "òc nissart (mistralenc)", |
|
| 148 | - 'oc_prv' => "òc provençau", |
|
| 149 | - 'oc_gsc' => "òc gascon", |
|
| 150 | - 'oc_lms' => "òc lemosin", |
|
| 151 | - 'oc_auv' => "òc auvernhat", |
|
| 152 | - 'oc_va' => "òc vivaroaupenc", |
|
| 153 | - 'om' => "(Afan) Oromo", |
|
| 154 | - 'or' => "Oriya", |
|
| 155 | - 'pa' => "Punjabi", |
|
| 156 | - 'pbb' => 'Nasa Yuwe', |
|
| 157 | - 'pl' => "polski", |
|
| 158 | - 'prs' => "دری", // ISO-639-3 Dari (Afghanistan) |
|
| 159 | - 'ps' => "پښتو", |
|
| 160 | - 'pt' => "Português", |
|
| 161 | - 'pt_br' => "Português do Brasil", |
|
| 162 | - 'qu' => "Quechua", |
|
| 163 | - 'rm' => "Rhaeto-Romance", |
|
| 164 | - 'rn' => "Kirundi", |
|
| 165 | - 'ro' => "română", |
|
| 166 | - 'roa' => "ch'ti", |
|
| 167 | - 'ru' => "русский", |
|
| 168 | - 'rw' => "Kinyarwanda", |
|
| 169 | - 'sa' => "संस्कृत", |
|
| 170 | - 'sc' => "sardu", |
|
| 171 | - 'scn' => "sicilianu", |
|
| 172 | - 'sd' => "Sindhi", |
|
| 173 | - 'sg' => "Sangho", |
|
| 174 | - 'sh' => "srpskohrvastski", |
|
| 175 | - 'sh_latn' => 'srpskohrvastski', |
|
| 176 | - 'sh_cyrl' => 'Српскохрватски', |
|
| 177 | - 'si' => "Sinhalese", |
|
| 178 | - 'sk' => "slovenčina", // (Slovakia) |
|
| 179 | - 'sl' => "slovenščina", // (Slovenia) |
|
| 180 | - 'sm' => "Samoan", |
|
| 181 | - 'sn' => "Shona", |
|
| 182 | - 'so' => "Somali", |
|
| 183 | - 'sq' => "shqip", |
|
| 184 | - 'sr' => "српски", |
|
| 185 | - 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 186 | - 'sro' => 'sardu campidanésu', |
|
| 187 | - 'ss' => "Siswati", |
|
| 188 | - 'st' => "Sesotho", |
|
| 189 | - 'su' => "Sundanese", |
|
| 190 | - 'sv' => "svenska", |
|
| 191 | - 'sw' => "Kiswahili", |
|
| 192 | - 'ta' => "தமிழ்", // Tamil |
|
| 193 | - 'te' => "Telugu", |
|
| 194 | - 'tg' => "Tajik", |
|
| 195 | - 'th' => "ไทย", |
|
| 196 | - 'ti' => "Tigrinya", |
|
| 197 | - 'tk' => "Turkmen", |
|
| 198 | - 'tl' => "Tagalog", |
|
| 199 | - 'tn' => "Setswana", |
|
| 200 | - 'to' => "Tonga", |
|
| 201 | - 'tr' => "Türkçe", |
|
| 202 | - 'ts' => "Tsonga", |
|
| 203 | - 'tt' => "Татар", |
|
| 204 | - 'tw' => "Twi", |
|
| 205 | - 'ty' => "reo mā`ohi", // tahitien |
|
| 206 | - 'ug' => "Uighur", |
|
| 207 | - 'uk' => "українська", |
|
| 208 | - 'ur' => "ٱردو", |
|
| 209 | - 'uz' => "O'zbekcha", |
|
| 210 | - 'vi' => "Tiếng Việt", |
|
| 211 | - 'vo' => "Volapuk", |
|
| 212 | - 'wa' => "walon", |
|
| 213 | - 'wo' => "Wolof", |
|
| 214 | - 'xh' => "Xhosa", |
|
| 215 | - 'yi' => "Yiddish", |
|
| 216 | - 'yo' => "Yoruba", |
|
| 217 | - 'za' => "Zhuang", |
|
| 218 | - 'zh' => "中文", // chinois (ecriture simplifiee) |
|
| 219 | - 'zh_tw' => "台灣中文", // chinois taiwan (ecr. traditionnelle) |
|
| 220 | - 'zu' => "Zulu" |
|
| 25 | + 'aa' => "Afar", |
|
| 26 | + 'ab' => "Abkhazian", |
|
| 27 | + 'af' => "Afrikaans", |
|
| 28 | + 'am' => "Amharic", |
|
| 29 | + 'an' => "Aragonés", |
|
| 30 | + 'ar' => "عربي", |
|
| 31 | + 'as' => "Assamese", |
|
| 32 | + 'ast' => "asturianu", |
|
| 33 | + 'ay' => "Aymara", |
|
| 34 | + 'az' => "Azərbaycan dili", |
|
| 35 | + 'ba' => "Bashkir", |
|
| 36 | + 'be' => "Беларуская", |
|
| 37 | + 'ber_tam' => "Tamazigh", |
|
| 38 | + 'ber_tam_tfng' => "Tamazigh tifinagh", |
|
| 39 | + 'bg' => "български", |
|
| 40 | + 'bh' => "Bihari", |
|
| 41 | + 'bi' => "Bislama", |
|
| 42 | + 'bm' => "Bambara", |
|
| 43 | + 'bn' => "Bengali; Bangla", |
|
| 44 | + 'bo' => "Tibetan", |
|
| 45 | + 'br' => "brezhoneg", |
|
| 46 | + 'bs' => "bosanski", |
|
| 47 | + 'ca' => "català", |
|
| 48 | + 'co' => "corsu", |
|
| 49 | + 'cpf' => "Kréol réyoné", |
|
| 50 | + 'cpf_dom' => "Kreyòl", |
|
| 51 | + 'cpf_hat' => "Kreyòl (Peyi Dayiti)", |
|
| 52 | + 'cs' => "čeština", |
|
| 53 | + 'cy' => "Cymraeg", # welsh, gallois |
|
| 54 | + 'da' => "dansk", |
|
| 55 | + 'de' => "Deutsch", |
|
| 56 | + 'dz' => "Bhutani", |
|
| 57 | + 'el' => "ελληνικά", |
|
| 58 | + 'en' => "English", |
|
| 59 | + 'en_hx' => "H4ck3R", |
|
| 60 | + 'en_sm' => "Smurf", |
|
| 61 | + 'eo' => "Esperanto", |
|
| 62 | + 'es' => "Español", |
|
| 63 | + 'es_co' => "Colombiano", |
|
| 64 | + 'es_mx_pop' => "Mexicano a lo güey", |
|
| 65 | + 'et' => "eesti", |
|
| 66 | + 'eu' => "euskara", |
|
| 67 | + 'fa' => "فارسى", |
|
| 68 | + 'ff' => "Fulah", // peul |
|
| 69 | + 'fi' => "suomi", |
|
| 70 | + 'fj' => "Fiji", |
|
| 71 | + 'fo' => "føroyskt", |
|
| 72 | + 'fon' => "fongbè", |
|
| 73 | + 'fr' => "français", |
|
| 74 | + 'fr_fem' => "français féminin", |
|
| 75 | + 'fr_sc' => "schtroumpf", |
|
| 76 | + 'fr_lpc' => "langue parlée complétée", |
|
| 77 | + 'fr_lsf' => "langue des signes française", |
|
| 78 | + 'fr_spl' => "français simplifié", |
|
| 79 | + 'fr_tu' => "français copain", |
|
| 80 | + 'fy' => "Frisian", |
|
| 81 | + 'ga' => "Irish", |
|
| 82 | + 'gd' => "Scots Gaelic", |
|
| 83 | + 'gl' => "galego", |
|
| 84 | + 'gn' => "Guarani", |
|
| 85 | + 'grc' => "Ἀρχαία Ἑλληνική", // grec ancien |
|
| 86 | + 'gu' => "Gujarati", |
|
| 87 | + 'ha' => "Hausa", |
|
| 88 | + 'hac' => "ک-هۆرامی", //"Kurdish-Horami" |
|
| 89 | + 'hbo' => "עברית־התנך", // hebreu classique ou biblique |
|
| 90 | + 'he' => "עברית", |
|
| 91 | + 'hi' => "हिंदी", |
|
| 92 | + 'hr' => "hrvatski", |
|
| 93 | + 'hu' => "magyar", |
|
| 94 | + 'hy' => "Հայերեն",// Arménien |
|
| 95 | + 'ia' => "Interlingua", |
|
| 96 | + 'id' => "Indonesia", |
|
| 97 | + 'ie' => "Interlingue", |
|
| 98 | + 'ik' => "Inupiak", |
|
| 99 | + 'is' => "íslenska", |
|
| 100 | + 'it' => "italiano", |
|
| 101 | + 'it_fem' => "italiana", |
|
| 102 | + 'iu' => "Inuktitut", |
|
| 103 | + 'ja' => "日本語", |
|
| 104 | + 'jv' => "Javanese", |
|
| 105 | + 'ka' => "ქართული", |
|
| 106 | + 'kk' => "қазақ тілі", // Kazakh |
|
| 107 | + 'kl' => "kalaallisut", |
|
| 108 | + 'km' => "ភាសាខ្មែរ",// Khmer |
|
| 109 | + 'kn' => "Kannada", |
|
| 110 | + 'ko' => "한국어", |
|
| 111 | + 'kok' => "कोंकणी", // Konkani |
|
| 112 | + 'ks' => "Kashmiri", |
|
| 113 | + 'ku' => "کوردی", |
|
| 114 | + 'ky' => "Kirghiz", |
|
| 115 | + 'la' => "lingua latina", |
|
| 116 | + 'lb' => "Lëtzebuergesch", |
|
| 117 | + 'ln' => "Lingala", |
|
| 118 | + 'lo' => "ພາສາລາວ", # lao |
|
| 119 | + 'lt' => "lietuvių", |
|
| 120 | + 'lu' => "luba-katanga", |
|
| 121 | + 'lv' => "latviešu", |
|
| 122 | + 'man' => "mandingue", # a traduire en mandingue |
|
| 123 | + 'mfv' => "manjak", # ISO-639-3 |
|
| 124 | + 'mg' => "Malagasy", |
|
| 125 | + 'mi' => "Maori", |
|
| 126 | + 'mk' => "македонски јазик", |
|
| 127 | + 'ml' => "Malayalam", |
|
| 128 | + 'mn' => "Монгол хэл", |
|
| 129 | + 'mo' => "Moldavian", |
|
| 130 | + 'mos' => "Moré", |
|
| 131 | + 'mr' => "मराठी", |
|
| 132 | + 'ms' => "Bahasa Malaysia", |
|
| 133 | + 'mt' => "Maltese", |
|
| 134 | + 'my' => "Burmese", |
|
| 135 | + 'na' => "Nauru", |
|
| 136 | + 'nap' => "napulitano", |
|
| 137 | + 'ne' => "Nepali", |
|
| 138 | + 'nqo' => "N'ko", // www.manden.org |
|
| 139 | + 'nl' => "Nederlands", |
|
| 140 | + 'no' => "norsk", |
|
| 141 | + 'nb' => "norsk bokmål", |
|
| 142 | + 'nn' => "norsk nynorsk", |
|
| 143 | + 'oc' => "òc", |
|
| 144 | + 'oc_lnc' => "òc lengadocian", |
|
| 145 | + 'oc_ni' => "òc niçard", |
|
| 146 | + 'oc_ni_la' => "òc niçard (larg)", |
|
| 147 | + 'oc_ni_mis' => "òc nissart (mistralenc)", |
|
| 148 | + 'oc_prv' => "òc provençau", |
|
| 149 | + 'oc_gsc' => "òc gascon", |
|
| 150 | + 'oc_lms' => "òc lemosin", |
|
| 151 | + 'oc_auv' => "òc auvernhat", |
|
| 152 | + 'oc_va' => "òc vivaroaupenc", |
|
| 153 | + 'om' => "(Afan) Oromo", |
|
| 154 | + 'or' => "Oriya", |
|
| 155 | + 'pa' => "Punjabi", |
|
| 156 | + 'pbb' => 'Nasa Yuwe', |
|
| 157 | + 'pl' => "polski", |
|
| 158 | + 'prs' => "دری", // ISO-639-3 Dari (Afghanistan) |
|
| 159 | + 'ps' => "پښتو", |
|
| 160 | + 'pt' => "Português", |
|
| 161 | + 'pt_br' => "Português do Brasil", |
|
| 162 | + 'qu' => "Quechua", |
|
| 163 | + 'rm' => "Rhaeto-Romance", |
|
| 164 | + 'rn' => "Kirundi", |
|
| 165 | + 'ro' => "română", |
|
| 166 | + 'roa' => "ch'ti", |
|
| 167 | + 'ru' => "русский", |
|
| 168 | + 'rw' => "Kinyarwanda", |
|
| 169 | + 'sa' => "संस्कृत", |
|
| 170 | + 'sc' => "sardu", |
|
| 171 | + 'scn' => "sicilianu", |
|
| 172 | + 'sd' => "Sindhi", |
|
| 173 | + 'sg' => "Sangho", |
|
| 174 | + 'sh' => "srpskohrvastski", |
|
| 175 | + 'sh_latn' => 'srpskohrvastski', |
|
| 176 | + 'sh_cyrl' => 'Српскохрватски', |
|
| 177 | + 'si' => "Sinhalese", |
|
| 178 | + 'sk' => "slovenčina", // (Slovakia) |
|
| 179 | + 'sl' => "slovenščina", // (Slovenia) |
|
| 180 | + 'sm' => "Samoan", |
|
| 181 | + 'sn' => "Shona", |
|
| 182 | + 'so' => "Somali", |
|
| 183 | + 'sq' => "shqip", |
|
| 184 | + 'sr' => "српски", |
|
| 185 | + 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 186 | + 'sro' => 'sardu campidanésu', |
|
| 187 | + 'ss' => "Siswati", |
|
| 188 | + 'st' => "Sesotho", |
|
| 189 | + 'su' => "Sundanese", |
|
| 190 | + 'sv' => "svenska", |
|
| 191 | + 'sw' => "Kiswahili", |
|
| 192 | + 'ta' => "தமிழ்", // Tamil |
|
| 193 | + 'te' => "Telugu", |
|
| 194 | + 'tg' => "Tajik", |
|
| 195 | + 'th' => "ไทย", |
|
| 196 | + 'ti' => "Tigrinya", |
|
| 197 | + 'tk' => "Turkmen", |
|
| 198 | + 'tl' => "Tagalog", |
|
| 199 | + 'tn' => "Setswana", |
|
| 200 | + 'to' => "Tonga", |
|
| 201 | + 'tr' => "Türkçe", |
|
| 202 | + 'ts' => "Tsonga", |
|
| 203 | + 'tt' => "Татар", |
|
| 204 | + 'tw' => "Twi", |
|
| 205 | + 'ty' => "reo mā`ohi", // tahitien |
|
| 206 | + 'ug' => "Uighur", |
|
| 207 | + 'uk' => "українська", |
|
| 208 | + 'ur' => "ٱردو", |
|
| 209 | + 'uz' => "O'zbekcha", |
|
| 210 | + 'vi' => "Tiếng Việt", |
|
| 211 | + 'vo' => "Volapuk", |
|
| 212 | + 'wa' => "walon", |
|
| 213 | + 'wo' => "Wolof", |
|
| 214 | + 'xh' => "Xhosa", |
|
| 215 | + 'yi' => "Yiddish", |
|
| 216 | + 'yo' => "Yoruba", |
|
| 217 | + 'za' => "Zhuang", |
|
| 218 | + 'zh' => "中文", // chinois (ecriture simplifiee) |
|
| 219 | + 'zh_tw' => "台灣中文", // chinois taiwan (ecr. traditionnelle) |
|
| 220 | + 'zu' => "Zulu" |
|
| 221 | 221 | |
| 222 | 222 | ); |
| 223 | 223 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | // Raccourcis dependant du sens de la langue |
| 24 | 24 | function definir_raccourcis_alineas(){ |
| 25 | - return array('',''); |
|
| 25 | + return array('',''); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | // |
| 32 | 32 | // http://doc.spip.org/@traiter_tableau |
| 33 | 33 | function traiter_tableau($bloc) { |
| 34 | - return $bloc; |
|
| 34 | + return $bloc; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
@@ -40,23 +40,23 @@ discard block |
||
| 40 | 40 | // |
| 41 | 41 | // http://doc.spip.org/@traiter_listes |
| 42 | 42 | function traiter_listes ($texte) { |
| 43 | - return $texte; |
|
| 43 | + return $texte; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // Nettoie un texte, traite les raccourcis autre qu'URL, la typo, etc. |
| 47 | 47 | // http://doc.spip.org/@traiter_raccourcis |
| 48 | 48 | function traiter_raccourcis($letexte) { |
| 49 | 49 | |
| 50 | - // Appeler les fonctions de pre_traitement |
|
| 51 | - $letexte = pipeline('pre_propre', $letexte); |
|
| 50 | + // Appeler les fonctions de pre_traitement |
|
| 51 | + $letexte = pipeline('pre_propre', $letexte); |
|
| 52 | 52 | |
| 53 | - // APPELER ICI UN PIPELINE traiter_raccourcis ? |
|
| 54 | - // $letexte = pipeline('traiter_raccourcis', $letexte); |
|
| 53 | + // APPELER ICI UN PIPELINE traiter_raccourcis ? |
|
| 54 | + // $letexte = pipeline('traiter_raccourcis', $letexte); |
|
| 55 | 55 | |
| 56 | - // Appeler les fonctions de post-traitement |
|
| 57 | - $letexte = pipeline('post_propre', $letexte); |
|
| 56 | + // Appeler les fonctions de post-traitement |
|
| 57 | + $letexte = pipeline('post_propre', $letexte); |
|
| 58 | 58 | |
| 59 | - return $letexte; |
|
| 59 | + return $letexte; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /************************************************************************************************************************* |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | // afficher joliment les <script> |
| 67 | 67 | // http://doc.spip.org/@echappe_js |
| 68 | 68 | function echappe_js($t,$class=' class="echappe-js"') { |
| 69 | - if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) |
|
| 70 | - foreach ($r as $regs) |
|
| 71 | - $t = str_replace($regs[0], |
|
| 72 | - "<code$class>".nl2br(spip_htmlspecialchars($regs[0])).'</code>', |
|
| 73 | - $t); |
|
| 74 | - return $t; |
|
| 69 | + if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) |
|
| 70 | + foreach ($r as $regs) |
|
| 71 | + $t = str_replace($regs[0], |
|
| 72 | + "<code$class>".nl2br(spip_htmlspecialchars($regs[0])).'</code>', |
|
| 73 | + $t); |
|
| 74 | + return $t; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
@@ -101,50 +101,50 @@ discard block |
||
| 101 | 101 | * Code protégé |
| 102 | 102 | **/ |
| 103 | 103 | function interdire_scripts($arg, $mode_filtre=null) { |
| 104 | - // on memorise le resultat sur les arguments non triviaux |
|
| 105 | - static $dejavu = array(); |
|
| 106 | - |
|
| 107 | - // Attention, si ce n'est pas une chaine, laisser intact |
|
| 108 | - if (!$arg OR !is_string($arg) OR !strstr($arg, '<')) return $arg; |
|
| 109 | - |
|
| 110 | - if (is_null($mode_filtre) or !in_array($mode_filtre, array(-1, 0, 1))) { |
|
| 111 | - $mode_filtre = $GLOBALS['filtrer_javascript']; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - if (isset($dejavu[$mode_filtre][$arg])) { |
|
| 115 | - return $dejavu[$mode_filtre][$arg]; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // echapper les tags asp/php |
|
| 119 | - $t = str_replace('<'.'%', '<%', $arg); |
|
| 120 | - |
|
| 121 | - // echapper le php |
|
| 122 | - $t = str_replace('<'.'?', '<?', $t); |
|
| 123 | - |
|
| 124 | - // echapper le < script language=php > |
|
| 125 | - $t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '<\1', $t); |
|
| 126 | - |
|
| 127 | - // Pour le js, trois modes : parano (-1), prive (0), ok (1) |
|
| 128 | - switch ($mode_filtre) { |
|
| 129 | - case 0: |
|
| 130 | - if (!_DIR_RESTREINT) |
|
| 131 | - $t = echappe_js($t); |
|
| 132 | - break; |
|
| 133 | - case -1: |
|
| 134 | - $t = echappe_js($t); |
|
| 135 | - break; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - // pas de <base href /> svp ! |
|
| 139 | - $t = preg_replace(',<(base\b),iS', '<\1', $t); |
|
| 140 | - |
|
| 141 | - // Reinserer les echappements des modeles |
|
| 142 | - if (defined('_PROTEGE_JS_MODELES')) |
|
| 143 | - $t = echappe_retour($t,"javascript"._PROTEGE_JS_MODELES); |
|
| 144 | - if (defined('_PROTEGE_PHP_MODELES')) |
|
| 145 | - $t = echappe_retour($t,"php"._PROTEGE_PHP_MODELES); |
|
| 146 | - |
|
| 147 | - return $dejavu[$mode_filtre][$arg] = $t; |
|
| 104 | + // on memorise le resultat sur les arguments non triviaux |
|
| 105 | + static $dejavu = array(); |
|
| 106 | + |
|
| 107 | + // Attention, si ce n'est pas une chaine, laisser intact |
|
| 108 | + if (!$arg OR !is_string($arg) OR !strstr($arg, '<')) return $arg; |
|
| 109 | + |
|
| 110 | + if (is_null($mode_filtre) or !in_array($mode_filtre, array(-1, 0, 1))) { |
|
| 111 | + $mode_filtre = $GLOBALS['filtrer_javascript']; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + if (isset($dejavu[$mode_filtre][$arg])) { |
|
| 115 | + return $dejavu[$mode_filtre][$arg]; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // echapper les tags asp/php |
|
| 119 | + $t = str_replace('<'.'%', '<%', $arg); |
|
| 120 | + |
|
| 121 | + // echapper le php |
|
| 122 | + $t = str_replace('<'.'?', '<?', $t); |
|
| 123 | + |
|
| 124 | + // echapper le < script language=php > |
|
| 125 | + $t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '<\1', $t); |
|
| 126 | + |
|
| 127 | + // Pour le js, trois modes : parano (-1), prive (0), ok (1) |
|
| 128 | + switch ($mode_filtre) { |
|
| 129 | + case 0: |
|
| 130 | + if (!_DIR_RESTREINT) |
|
| 131 | + $t = echappe_js($t); |
|
| 132 | + break; |
|
| 133 | + case -1: |
|
| 134 | + $t = echappe_js($t); |
|
| 135 | + break; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + // pas de <base href /> svp ! |
|
| 139 | + $t = preg_replace(',<(base\b),iS', '<\1', $t); |
|
| 140 | + |
|
| 141 | + // Reinserer les echappements des modeles |
|
| 142 | + if (defined('_PROTEGE_JS_MODELES')) |
|
| 143 | + $t = echappe_retour($t,"javascript"._PROTEGE_JS_MODELES); |
|
| 144 | + if (defined('_PROTEGE_PHP_MODELES')) |
|
| 145 | + $t = echappe_retour($t,"php"._PROTEGE_PHP_MODELES); |
|
| 146 | + |
|
| 147 | + return $dejavu[$mode_filtre][$arg] = $t; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Typographie generale |
@@ -152,54 +152,54 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | // http://doc.spip.org/@typo |
| 154 | 154 | function typo($letexte, $echapper=true, $connect=null, $env=array()) { |
| 155 | - // Plus vite ! |
|
| 156 | - if (!$letexte) return $letexte; |
|
| 157 | - |
|
| 158 | - // les appels directs a cette fonction depuis le php de l'espace |
|
| 159 | - // prive etant historiquement ecrit sans argment $connect |
|
| 160 | - // on utilise la presence de celui-ci pour distinguer les cas |
|
| 161 | - // ou il faut passer interdire_script explicitement |
|
| 162 | - // les appels dans les squelettes (de l'espace prive) fournissant un $connect |
|
| 163 | - // ne seront pas perturbes |
|
| 164 | - $interdire_script = false; |
|
| 165 | - if (is_null($connect)){ |
|
| 166 | - $connect = ''; |
|
| 167 | - $interdire_script = true; |
|
| 168 | - $env['espace_prive'] = 1; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - // Echapper les codes <html> etc |
|
| 172 | - if ($echapper) |
|
| 173 | - $letexte = echappe_html($letexte, 'TYPO'); |
|
| 174 | - |
|
| 175 | - // |
|
| 176 | - // Installer les modeles, notamment images et documents ; |
|
| 177 | - // |
|
| 178 | - // NOTE : propre() ne passe pas par ici mais directement par corriger_typo |
|
| 179 | - // cf. inc/lien |
|
| 180 | - |
|
| 181 | - $letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect, null, $env); |
|
| 182 | - if ($letexte != $mem) $echapper = true; |
|
| 183 | - unset($mem); |
|
| 184 | - |
|
| 185 | - $letexte = corriger_typo($letexte); |
|
| 186 | - $letexte = echapper_faux_tags($letexte); |
|
| 187 | - |
|
| 188 | - // reintegrer les echappements |
|
| 189 | - if ($echapper) |
|
| 190 | - $letexte = echappe_retour($letexte, 'TYPO'); |
|
| 191 | - |
|
| 192 | - // Dans les appels directs hors squelette, securiser ici aussi |
|
| 193 | - if ($interdire_script) |
|
| 194 | - $letexte = interdire_scripts($letexte); |
|
| 195 | - |
|
| 196 | - // Dans l'espace prive on se mefie de tout contenu dangereux |
|
| 197 | - // https://core.spip.net/issues/3371 |
|
| 198 | - if (isset($env['espace_prive']) AND $env['espace_prive']){ |
|
| 199 | - $letexte = echapper_html_suspect($letexte); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - return $letexte; |
|
| 155 | + // Plus vite ! |
|
| 156 | + if (!$letexte) return $letexte; |
|
| 157 | + |
|
| 158 | + // les appels directs a cette fonction depuis le php de l'espace |
|
| 159 | + // prive etant historiquement ecrit sans argment $connect |
|
| 160 | + // on utilise la presence de celui-ci pour distinguer les cas |
|
| 161 | + // ou il faut passer interdire_script explicitement |
|
| 162 | + // les appels dans les squelettes (de l'espace prive) fournissant un $connect |
|
| 163 | + // ne seront pas perturbes |
|
| 164 | + $interdire_script = false; |
|
| 165 | + if (is_null($connect)){ |
|
| 166 | + $connect = ''; |
|
| 167 | + $interdire_script = true; |
|
| 168 | + $env['espace_prive'] = 1; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + // Echapper les codes <html> etc |
|
| 172 | + if ($echapper) |
|
| 173 | + $letexte = echappe_html($letexte, 'TYPO'); |
|
| 174 | + |
|
| 175 | + // |
|
| 176 | + // Installer les modeles, notamment images et documents ; |
|
| 177 | + // |
|
| 178 | + // NOTE : propre() ne passe pas par ici mais directement par corriger_typo |
|
| 179 | + // cf. inc/lien |
|
| 180 | + |
|
| 181 | + $letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect, null, $env); |
|
| 182 | + if ($letexte != $mem) $echapper = true; |
|
| 183 | + unset($mem); |
|
| 184 | + |
|
| 185 | + $letexte = corriger_typo($letexte); |
|
| 186 | + $letexte = echapper_faux_tags($letexte); |
|
| 187 | + |
|
| 188 | + // reintegrer les echappements |
|
| 189 | + if ($echapper) |
|
| 190 | + $letexte = echappe_retour($letexte, 'TYPO'); |
|
| 191 | + |
|
| 192 | + // Dans les appels directs hors squelette, securiser ici aussi |
|
| 193 | + if ($interdire_script) |
|
| 194 | + $letexte = interdire_scripts($letexte); |
|
| 195 | + |
|
| 196 | + // Dans l'espace prive on se mefie de tout contenu dangereux |
|
| 197 | + // https://core.spip.net/issues/3371 |
|
| 198 | + if (isset($env['espace_prive']) AND $env['espace_prive']){ |
|
| 199 | + $letexte = echapper_html_suspect($letexte); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + return $letexte; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // Correcteur typographique |
@@ -211,46 +211,46 @@ discard block |
||
| 211 | 211 | // http://doc.spip.org/@corriger_typo |
| 212 | 212 | function corriger_typo($letexte, $lang='') { |
| 213 | 213 | |
| 214 | - // Plus vite ! |
|
| 215 | - if (!$letexte) return $letexte; |
|
| 214 | + // Plus vite ! |
|
| 215 | + if (!$letexte) return $letexte; |
|
| 216 | 216 | |
| 217 | - $letexte = pipeline('pre_typo', $letexte); |
|
| 217 | + $letexte = pipeline('pre_typo', $letexte); |
|
| 218 | 218 | |
| 219 | - // Caracteres de controle "illegaux" |
|
| 220 | - $letexte = corriger_caracteres($letexte); |
|
| 219 | + // Caracteres de controle "illegaux" |
|
| 220 | + $letexte = corriger_caracteres($letexte); |
|
| 221 | 221 | |
| 222 | - // Proteger les caracteres typographiques a l'interieur des tags html |
|
| 223 | - if (preg_match_all(_TYPO_BALISE, $letexte, $regs, PREG_SET_ORDER)) { |
|
| 224 | - foreach ($regs as $reg) { |
|
| 225 | - $insert = $reg[0]; |
|
| 226 | - // hack: on transforme les caracteres a proteger en les remplacant |
|
| 227 | - // par des caracteres "illegaux". (cf corriger_caracteres()) |
|
| 228 | - $insert = strtr($insert, _TYPO_PROTEGER, _TYPO_PROTECTEUR); |
|
| 229 | - $letexte = str_replace($reg[0], $insert, $letexte); |
|
| 230 | - } |
|
| 231 | - } |
|
| 222 | + // Proteger les caracteres typographiques a l'interieur des tags html |
|
| 223 | + if (preg_match_all(_TYPO_BALISE, $letexte, $regs, PREG_SET_ORDER)) { |
|
| 224 | + foreach ($regs as $reg) { |
|
| 225 | + $insert = $reg[0]; |
|
| 226 | + // hack: on transforme les caracteres a proteger en les remplacant |
|
| 227 | + // par des caracteres "illegaux". (cf corriger_caracteres()) |
|
| 228 | + $insert = strtr($insert, _TYPO_PROTEGER, _TYPO_PROTECTEUR); |
|
| 229 | + $letexte = str_replace($reg[0], $insert, $letexte); |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - // trouver les blocs multi et les traiter a part |
|
| 234 | - $letexte = extraire_multi($e = $letexte, $lang, true); |
|
| 235 | - $e = ($e === $letexte); |
|
| 233 | + // trouver les blocs multi et les traiter a part |
|
| 234 | + $letexte = extraire_multi($e = $letexte, $lang, true); |
|
| 235 | + $e = ($e === $letexte); |
|
| 236 | 236 | |
| 237 | - // Charger & appliquer les fonctions de typographie |
|
| 238 | - $typographie = charger_fonction(lang_typo($lang), 'typographie'); |
|
| 239 | - $letexte = $typographie($letexte); |
|
| 237 | + // Charger & appliquer les fonctions de typographie |
|
| 238 | + $typographie = charger_fonction(lang_typo($lang), 'typographie'); |
|
| 239 | + $letexte = $typographie($letexte); |
|
| 240 | 240 | |
| 241 | - // Les citations en une autre langue, s'il y a lieu |
|
| 242 | - if (!$e) $letexte = echappe_retour($letexte, 'multi'); |
|
| 241 | + // Les citations en une autre langue, s'il y a lieu |
|
| 242 | + if (!$e) $letexte = echappe_retour($letexte, 'multi'); |
|
| 243 | 243 | |
| 244 | - // Retablir les caracteres proteges |
|
| 245 | - $letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER); |
|
| 244 | + // Retablir les caracteres proteges |
|
| 245 | + $letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER); |
|
| 246 | 246 | |
| 247 | - // pipeline |
|
| 248 | - $letexte = pipeline('post_typo', $letexte); |
|
| 247 | + // pipeline |
|
| 248 | + $letexte = pipeline('post_typo', $letexte); |
|
| 249 | 249 | |
| 250 | - # un message pour abs_url - on est passe en mode texte |
|
| 251 | - $GLOBALS['mode_abs_url'] = 'texte'; |
|
| 250 | + # un message pour abs_url - on est passe en mode texte |
|
| 251 | + $GLOBALS['mode_abs_url'] = 'texte'; |
|
| 252 | 252 | |
| 253 | - return $letexte; |
|
| 253 | + return $letexte; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | |
@@ -266,43 +266,43 @@ discard block |
||
| 266 | 266 | // http://doc.spip.org/@paragrapher |
| 267 | 267 | // /!\ appelee dans inc/filtres et public/composer |
| 268 | 268 | function paragrapher($letexte, $forcer=true) { |
| 269 | - return $letexte; |
|
| 269 | + return $letexte; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // Harmonise les retours chariots et mange les paragraphes html |
| 273 | 273 | // http://doc.spip.org/@traiter_retours_chariots |
| 274 | 274 | // ne sert plus |
| 275 | 275 | function traiter_retours_chariots($letexte) { |
| 276 | - $letexte = preg_replace(",\r\n?,S", "\n", $letexte); |
|
| 277 | - $letexte = preg_replace(",<p[>[:space:]],iS", "\n\n\\0", $letexte); |
|
| 278 | - $letexte = preg_replace(",</p[>[:space:]],iS", "\\0\n\n", $letexte); |
|
| 279 | - return $letexte; |
|
| 276 | + $letexte = preg_replace(",\r\n?,S", "\n", $letexte); |
|
| 277 | + $letexte = preg_replace(",<p[>[:space:]],iS", "\n\n\\0", $letexte); |
|
| 278 | + $letexte = preg_replace(",</p[>[:space:]],iS", "\\0\n\n", $letexte); |
|
| 279 | + return $letexte; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | |
| 283 | 283 | // Filtre a appliquer aux champs du type #TEXTE* |
| 284 | 284 | // http://doc.spip.org/@propre |
| 285 | 285 | function propre($t, $connect=null, $env=array()) { |
| 286 | - // les appels directs a cette fonction depuis le php de l'espace |
|
| 287 | - // prive etant historiquement ecrits sans argment $connect |
|
| 288 | - // on utilise la presence de celui-ci pour distinguer les cas |
|
| 289 | - // ou il faut passer interdire_script explicitement |
|
| 290 | - // les appels dans les squelettes (de l'espace prive) fournissant un $connect |
|
| 291 | - // ne seront pas perturbes |
|
| 292 | - $interdire_script = false; |
|
| 293 | - if (is_null($connect)){ |
|
| 294 | - $connect = ''; |
|
| 295 | - $interdire_script = true; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - if (!$t) return strval($t); |
|
| 299 | - |
|
| 300 | - $t = echappe_html($t); |
|
| 301 | - $t = expanser_liens($t,$connect, $env); |
|
| 302 | - $t = traiter_raccourcis($t); |
|
| 303 | - $t = echappe_retour_modeles($t, $interdire_script); |
|
| 304 | - |
|
| 305 | - return $t; |
|
| 286 | + // les appels directs a cette fonction depuis le php de l'espace |
|
| 287 | + // prive etant historiquement ecrits sans argment $connect |
|
| 288 | + // on utilise la presence de celui-ci pour distinguer les cas |
|
| 289 | + // ou il faut passer interdire_script explicitement |
|
| 290 | + // les appels dans les squelettes (de l'espace prive) fournissant un $connect |
|
| 291 | + // ne seront pas perturbes |
|
| 292 | + $interdire_script = false; |
|
| 293 | + if (is_null($connect)){ |
|
| 294 | + $connect = ''; |
|
| 295 | + $interdire_script = true; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + if (!$t) return strval($t); |
|
| 299 | + |
|
| 300 | + $t = echappe_html($t); |
|
| 301 | + $t = expanser_liens($t,$connect, $env); |
|
| 302 | + $t = traiter_raccourcis($t); |
|
| 303 | + $t = echappe_retour_modeles($t, $interdire_script); |
|
| 304 | + |
|
| 305 | + return $t; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | ?> |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | // Raccourcis dependant du sens de la langue |
| 24 | -function definir_raccourcis_alineas(){ |
|
| 25 | - return array('',''); |
|
| 24 | +function definir_raccourcis_alineas() { |
|
| 25 | + return array('', ''); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | // Traitement des listes (merci a Michael Parienti) |
| 40 | 40 | // |
| 41 | 41 | // http://doc.spip.org/@traiter_listes |
| 42 | -function traiter_listes ($texte) { |
|
| 42 | +function traiter_listes($texte) { |
|
| 43 | 43 | return $texte; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | // afficher joliment les <script> |
| 67 | 67 | // http://doc.spip.org/@echappe_js |
| 68 | -function echappe_js($t,$class=' class="echappe-js"') { |
|
| 68 | +function echappe_js($t, $class = ' class="echappe-js"') { |
|
| 69 | 69 | if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) |
| 70 | 70 | foreach ($r as $regs) |
| 71 | 71 | $t = str_replace($regs[0], |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @return string |
| 101 | 101 | * Code protégé |
| 102 | 102 | **/ |
| 103 | -function interdire_scripts($arg, $mode_filtre=null) { |
|
| 103 | +function interdire_scripts($arg, $mode_filtre = null) { |
|
| 104 | 104 | // on memorise le resultat sur les arguments non triviaux |
| 105 | 105 | static $dejavu = array(); |
| 106 | 106 | |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | // Reinserer les echappements des modeles |
| 142 | 142 | if (defined('_PROTEGE_JS_MODELES')) |
| 143 | - $t = echappe_retour($t,"javascript"._PROTEGE_JS_MODELES); |
|
| 143 | + $t = echappe_retour($t, "javascript"._PROTEGE_JS_MODELES); |
|
| 144 | 144 | if (defined('_PROTEGE_PHP_MODELES')) |
| 145 | - $t = echappe_retour($t,"php"._PROTEGE_PHP_MODELES); |
|
| 145 | + $t = echappe_retour($t, "php"._PROTEGE_PHP_MODELES); |
|
| 146 | 146 | |
| 147 | 147 | return $dejavu[$mode_filtre][$arg] = $t; |
| 148 | 148 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | // avec protection prealable des balises HTML et SPIP |
| 152 | 152 | |
| 153 | 153 | // http://doc.spip.org/@typo |
| 154 | -function typo($letexte, $echapper=true, $connect=null, $env=array()) { |
|
| 154 | +function typo($letexte, $echapper = true, $connect = null, $env = array()) { |
|
| 155 | 155 | // Plus vite ! |
| 156 | 156 | if (!$letexte) return $letexte; |
| 157 | 157 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | // les appels dans les squelettes (de l'espace prive) fournissant un $connect |
| 163 | 163 | // ne seront pas perturbes |
| 164 | 164 | $interdire_script = false; |
| 165 | - if (is_null($connect)){ |
|
| 165 | + if (is_null($connect)) { |
|
| 166 | 166 | $connect = ''; |
| 167 | 167 | $interdire_script = true; |
| 168 | 168 | $env['espace_prive'] = 1; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | // Dans l'espace prive on se mefie de tout contenu dangereux |
| 197 | 197 | // https://core.spip.net/issues/3371 |
| 198 | - if (isset($env['espace_prive']) AND $env['espace_prive']){ |
|
| 198 | + if (isset($env['espace_prive']) AND $env['espace_prive']) { |
|
| 199 | 199 | $letexte = echapper_html_suspect($letexte); |
| 200 | 200 | } |
| 201 | 201 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | define('_TYPO_BALISE', ",</?[a-z!][^<>]*[".preg_quote(_TYPO_PROTEGER)."][^<>]*>,imsS"); |
| 210 | 210 | |
| 211 | 211 | // http://doc.spip.org/@corriger_typo |
| 212 | -function corriger_typo($letexte, $lang='') { |
|
| 212 | +function corriger_typo($letexte, $lang = '') { |
|
| 213 | 213 | |
| 214 | 214 | // Plus vite ! |
| 215 | 215 | if (!$letexte) return $letexte; |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | // |
| 266 | 266 | // http://doc.spip.org/@paragrapher |
| 267 | 267 | // /!\ appelee dans inc/filtres et public/composer |
| 268 | -function paragrapher($letexte, $forcer=true) { |
|
| 268 | +function paragrapher($letexte, $forcer = true) { |
|
| 269 | 269 | return $letexte; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | // Filtre a appliquer aux champs du type #TEXTE* |
| 284 | 284 | // http://doc.spip.org/@propre |
| 285 | -function propre($t, $connect=null, $env=array()) { |
|
| 285 | +function propre($t, $connect = null, $env = array()) { |
|
| 286 | 286 | // les appels directs a cette fonction depuis le php de l'espace |
| 287 | 287 | // prive etant historiquement ecrits sans argment $connect |
| 288 | 288 | // on utilise la presence de celui-ci pour distinguer les cas |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | // les appels dans les squelettes (de l'espace prive) fournissant un $connect |
| 291 | 291 | // ne seront pas perturbes |
| 292 | 292 | $interdire_script = false; |
| 293 | - if (is_null($connect)){ |
|
| 293 | + if (is_null($connect)) { |
|
| 294 | 294 | $connect = ''; |
| 295 | 295 | $interdire_script = true; |
| 296 | 296 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | if (!$t) return strval($t); |
| 299 | 299 | |
| 300 | 300 | $t = echappe_html($t); |
| 301 | - $t = expanser_liens($t,$connect, $env); |
|
| 301 | + $t = expanser_liens($t, $connect, $env); |
|
| 302 | 302 | $t = traiter_raccourcis($t); |
| 303 | 303 | $t = echappe_retour_modeles($t, $interdire_script); |
| 304 | 304 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/texte_mini'); |
| 16 | 18 | include_spip('inc/lien'); |
@@ -66,11 +68,12 @@ discard block |
||
| 66 | 68 | // afficher joliment les <script> |
| 67 | 69 | // http://doc.spip.org/@echappe_js |
| 68 | 70 | function echappe_js($t,$class=' class="echappe-js"') { |
| 69 | - if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) |
|
| 70 | - foreach ($r as $regs) |
|
| 71 | + if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 72 | + foreach ($r as $regs) |
|
| 71 | 73 | $t = str_replace($regs[0], |
| 72 | 74 | "<code$class>".nl2br(spip_htmlspecialchars($regs[0])).'</code>', |
| 73 | 75 | $t); |
| 76 | + } |
|
| 74 | 77 | return $t; |
| 75 | 78 | } |
| 76 | 79 | |
@@ -105,7 +108,9 @@ discard block |
||
| 105 | 108 | static $dejavu = array(); |
| 106 | 109 | |
| 107 | 110 | // Attention, si ce n'est pas une chaine, laisser intact |
| 108 | - if (!$arg OR !is_string($arg) OR !strstr($arg, '<')) return $arg; |
|
| 111 | + if (!$arg OR !is_string($arg) OR !strstr($arg, '<')) { |
|
| 112 | + return $arg; |
|
| 113 | + } |
|
| 109 | 114 | |
| 110 | 115 | if (is_null($mode_filtre) or !in_array($mode_filtre, array(-1, 0, 1))) { |
| 111 | 116 | $mode_filtre = $GLOBALS['filtrer_javascript']; |
@@ -127,8 +132,9 @@ discard block |
||
| 127 | 132 | // Pour le js, trois modes : parano (-1), prive (0), ok (1) |
| 128 | 133 | switch ($mode_filtre) { |
| 129 | 134 | case 0: |
| 130 | - if (!_DIR_RESTREINT) |
|
| 131 | - $t = echappe_js($t); |
|
| 135 | + if (!_DIR_RESTREINT) { |
|
| 136 | + $t = echappe_js($t); |
|
| 137 | + } |
|
| 132 | 138 | break; |
| 133 | 139 | case -1: |
| 134 | 140 | $t = echappe_js($t); |
@@ -139,10 +145,12 @@ discard block |
||
| 139 | 145 | $t = preg_replace(',<(base\b),iS', '<\1', $t); |
| 140 | 146 | |
| 141 | 147 | // Reinserer les echappements des modeles |
| 142 | - if (defined('_PROTEGE_JS_MODELES')) |
|
| 143 | - $t = echappe_retour($t,"javascript"._PROTEGE_JS_MODELES); |
|
| 144 | - if (defined('_PROTEGE_PHP_MODELES')) |
|
| 145 | - $t = echappe_retour($t,"php"._PROTEGE_PHP_MODELES); |
|
| 148 | + if (defined('_PROTEGE_JS_MODELES')) { |
|
| 149 | + $t = echappe_retour($t,"javascript"._PROTEGE_JS_MODELES); |
|
| 150 | + } |
|
| 151 | + if (defined('_PROTEGE_PHP_MODELES')) { |
|
| 152 | + $t = echappe_retour($t,"php"._PROTEGE_PHP_MODELES); |
|
| 153 | + } |
|
| 146 | 154 | |
| 147 | 155 | return $dejavu[$mode_filtre][$arg] = $t; |
| 148 | 156 | } |
@@ -153,7 +161,9 @@ discard block |
||
| 153 | 161 | // http://doc.spip.org/@typo |
| 154 | 162 | function typo($letexte, $echapper=true, $connect=null, $env=array()) { |
| 155 | 163 | // Plus vite ! |
| 156 | - if (!$letexte) return $letexte; |
|
| 164 | + if (!$letexte) { |
|
| 165 | + return $letexte; |
|
| 166 | + } |
|
| 157 | 167 | |
| 158 | 168 | // les appels directs a cette fonction depuis le php de l'espace |
| 159 | 169 | // prive etant historiquement ecrit sans argment $connect |
@@ -169,8 +179,9 @@ discard block |
||
| 169 | 179 | } |
| 170 | 180 | |
| 171 | 181 | // Echapper les codes <html> etc |
| 172 | - if ($echapper) |
|
| 173 | - $letexte = echappe_html($letexte, 'TYPO'); |
|
| 182 | + if ($echapper) { |
|
| 183 | + $letexte = echappe_html($letexte, 'TYPO'); |
|
| 184 | + } |
|
| 174 | 185 | |
| 175 | 186 | // |
| 176 | 187 | // Installer les modeles, notamment images et documents ; |
@@ -179,19 +190,23 @@ discard block |
||
| 179 | 190 | // cf. inc/lien |
| 180 | 191 | |
| 181 | 192 | $letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect, null, $env); |
| 182 | - if ($letexte != $mem) $echapper = true; |
|
| 193 | + if ($letexte != $mem) { |
|
| 194 | + $echapper = true; |
|
| 195 | + } |
|
| 183 | 196 | unset($mem); |
| 184 | 197 | |
| 185 | 198 | $letexte = corriger_typo($letexte); |
| 186 | 199 | $letexte = echapper_faux_tags($letexte); |
| 187 | 200 | |
| 188 | 201 | // reintegrer les echappements |
| 189 | - if ($echapper) |
|
| 190 | - $letexte = echappe_retour($letexte, 'TYPO'); |
|
| 202 | + if ($echapper) { |
|
| 203 | + $letexte = echappe_retour($letexte, 'TYPO'); |
|
| 204 | + } |
|
| 191 | 205 | |
| 192 | 206 | // Dans les appels directs hors squelette, securiser ici aussi |
| 193 | - if ($interdire_script) |
|
| 194 | - $letexte = interdire_scripts($letexte); |
|
| 207 | + if ($interdire_script) { |
|
| 208 | + $letexte = interdire_scripts($letexte); |
|
| 209 | + } |
|
| 195 | 210 | |
| 196 | 211 | // Dans l'espace prive on se mefie de tout contenu dangereux |
| 197 | 212 | // https://core.spip.net/issues/3371 |
@@ -212,7 +227,9 @@ discard block |
||
| 212 | 227 | function corriger_typo($letexte, $lang='') { |
| 213 | 228 | |
| 214 | 229 | // Plus vite ! |
| 215 | - if (!$letexte) return $letexte; |
|
| 230 | + if (!$letexte) { |
|
| 231 | + return $letexte; |
|
| 232 | + } |
|
| 216 | 233 | |
| 217 | 234 | $letexte = pipeline('pre_typo', $letexte); |
| 218 | 235 | |
@@ -239,7 +256,9 @@ discard block |
||
| 239 | 256 | $letexte = $typographie($letexte); |
| 240 | 257 | |
| 241 | 258 | // Les citations en une autre langue, s'il y a lieu |
| 242 | - if (!$e) $letexte = echappe_retour($letexte, 'multi'); |
|
| 259 | + if (!$e) { |
|
| 260 | + $letexte = echappe_retour($letexte, 'multi'); |
|
| 261 | + } |
|
| 243 | 262 | |
| 244 | 263 | // Retablir les caracteres proteges |
| 245 | 264 | $letexte = strtr($letexte, _TYPO_PROTECTEUR, _TYPO_PROTEGER); |
@@ -295,7 +314,9 @@ discard block |
||
| 295 | 314 | $interdire_script = true; |
| 296 | 315 | } |
| 297 | 316 | |
| 298 | - if (!$t) return strval($t); |
|
| 317 | + if (!$t) { |
|
| 318 | + return strval($t); |
|
| 319 | + } |
|
| 299 | 320 | |
| 300 | 321 | $t = echappe_html($t); |
| 301 | 322 | $t = expanser_liens($t,$connect, $env); |
@@ -18,21 +18,21 @@ discard block |
||
| 18 | 18 | // avec un poids pour le score |
| 19 | 19 | // http://doc.spip.org/@liste_des_champs |
| 20 | 20 | function liste_des_champs() { |
| 21 | - static $liste=null; |
|
| 22 | - if (is_null($liste)) { |
|
| 23 | - $liste = array(); |
|
| 24 | - // recuperer les tables_objets_sql declarees |
|
| 25 | - include_spip('base/objets'); |
|
| 26 | - $tables_objets = lister_tables_objets_sql(); |
|
| 27 | - foreach($tables_objets as $t=>$infos){ |
|
| 28 | - if ($infos['rechercher_champs']){ |
|
| 29 | - $liste[$infos['type']] = $infos['rechercher_champs']; |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - // puis passer dans le pipeline |
|
| 33 | - $liste = pipeline('rechercher_liste_des_champs', $liste); |
|
| 34 | - } |
|
| 35 | - return $liste; |
|
| 21 | + static $liste=null; |
|
| 22 | + if (is_null($liste)) { |
|
| 23 | + $liste = array(); |
|
| 24 | + // recuperer les tables_objets_sql declarees |
|
| 25 | + include_spip('base/objets'); |
|
| 26 | + $tables_objets = lister_tables_objets_sql(); |
|
| 27 | + foreach($tables_objets as $t=>$infos){ |
|
| 28 | + if ($infos['rechercher_champs']){ |
|
| 29 | + $liste[$infos['type']] = $infos['rechercher_champs']; |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + // puis passer dans le pipeline |
|
| 33 | + $liste = pipeline('rechercher_liste_des_champs', $liste); |
|
| 34 | + } |
|
| 35 | + return $liste; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -40,162 +40,162 @@ discard block |
||
| 40 | 40 | // en ne regardant que le titre ou le nom |
| 41 | 41 | // http://doc.spip.org/@liste_des_jointures |
| 42 | 42 | function liste_des_jointures() { |
| 43 | - static $liste=null; |
|
| 44 | - if (is_null($liste)) { |
|
| 45 | - $liste = array(); |
|
| 46 | - // recuperer les tables_objets_sql declarees |
|
| 47 | - include_spip('base/objets'); |
|
| 48 | - $tables_objets = lister_tables_objets_sql(); |
|
| 49 | - foreach($tables_objets as $t=>$infos){ |
|
| 50 | - if ($infos['rechercher_jointures']){ |
|
| 51 | - $liste[$infos['type']] = $infos['rechercher_jointures']; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - // puis passer dans le pipeline |
|
| 55 | - $liste = pipeline('rechercher_liste_des_jointures', $liste); |
|
| 56 | - } |
|
| 57 | - return $liste; |
|
| 43 | + static $liste=null; |
|
| 44 | + if (is_null($liste)) { |
|
| 45 | + $liste = array(); |
|
| 46 | + // recuperer les tables_objets_sql declarees |
|
| 47 | + include_spip('base/objets'); |
|
| 48 | + $tables_objets = lister_tables_objets_sql(); |
|
| 49 | + foreach($tables_objets as $t=>$infos){ |
|
| 50 | + if ($infos['rechercher_jointures']){ |
|
| 51 | + $liste[$infos['type']] = $infos['rechercher_jointures']; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + // puis passer dans le pipeline |
|
| 55 | + $liste = pipeline('rechercher_liste_des_jointures', $liste); |
|
| 56 | + } |
|
| 57 | + return $liste; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function expression_recherche($recherche, $options) { |
| 61 | - // ne calculer qu'une seule fois l'expression par hit |
|
| 62 | - // (meme si utilisee dans plusieurs boucles) |
|
| 63 | - static $expression = array(); |
|
| 64 | - $key = serialize(array($recherche, $options['preg_flags'])); |
|
| 65 | - if (isset($expression[$key])) { |
|
| 66 | - return $expression[$key]; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 70 | - if ($u and strpos($options['preg_flags'], $u) === false) { |
|
| 71 | - $options['preg_flags'] .= $u; |
|
| 72 | - } |
|
| 73 | - include_spip('inc/charsets'); |
|
| 74 | - $recherche = trim($recherche); |
|
| 75 | - |
|
| 76 | - $is_preg = false; |
|
| 77 | - if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) { |
|
| 78 | - // c'est une preg |
|
| 79 | - $recherche_trans = translitteration($recherche); |
|
| 80 | - $preg = $recherche_trans . $options['preg_flags']; |
|
| 81 | - $is_preg = true; |
|
| 82 | - } else { |
|
| 83 | - // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP, |
|
| 84 | - // sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un', |
|
| 85 | - // 'une', 'des' ...) |
|
| 86 | - |
|
| 87 | - // attention : plusieurs mots entre guillemets sont a rechercher tels quels |
|
| 88 | - $recherche_trans = $recherche_mod = $recherche; |
|
| 89 | - |
|
| 90 | - // les expressions entre " " sont un mot a chercher tel quel |
|
| 91 | - // -> on remplace les espaces par un \x1 et on enleve les guillemets |
|
| 92 | - if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 93 | - foreach ($matches as $match) { |
|
| 94 | - $word = preg_replace(",\s+,Uims", "\x1", $match); |
|
| 95 | - $word = trim($word, '"'); |
|
| 96 | - $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - if (preg_match(",\s+," . $u, $recherche_mod)) { |
|
| 101 | - $is_preg = true; |
|
| 102 | - |
|
| 103 | - $recherche_inter = '|'; |
|
| 104 | - $recherche_mots = explode(' ', $recherche_mod); |
|
| 105 | - $min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4; |
|
| 106 | - foreach ($recherche_mots as $mot) { |
|
| 107 | - if (strlen($mot) >= $min_long) { |
|
| 108 | - // echapper les caracteres de regexp qui sont eventuellement dans la recherche |
|
| 109 | - $recherche_inter .= preg_quote($mot) . ' '; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - $recherche_inter = str_replace("\x1", '\s', $recherche_inter); |
|
| 113 | - |
|
| 114 | - // mais on cherche quand même l'expression complète, même si elle |
|
| 115 | - // comporte des mots de moins de quatre lettres |
|
| 116 | - $recherche = rtrim(preg_quote($recherche) . preg_replace(',\s+,' . $u, '|', $recherche_inter), '|'); |
|
| 117 | - $recherche_trans = translitteration($recherche); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $preg = '/' . str_replace('/', '\\/', $recherche_trans) . '/' . $options['preg_flags']; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite |
|
| 124 | - // ou si l'expression reguliere est invalide |
|
| 125 | - if (!$is_preg |
|
| 126 | - or (@preg_match($preg, '') === false) |
|
| 127 | - ) { |
|
| 128 | - $methode = 'LIKE'; |
|
| 129 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 130 | - |
|
| 131 | - // echapper les % et _ |
|
| 132 | - $q = str_replace(array('%', '_'), array('\%', '\_'), trim($recherche)); |
|
| 133 | - |
|
| 134 | - // 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 |
|
| 135 | - $recherche = preg_quote($recherche, '/'); |
|
| 136 | - $recherche_trans = translitteration($recherche); |
|
| 137 | - $recherche_mod = $recherche_trans; |
|
| 138 | - |
|
| 139 | - // les expressions entre " " sont un mot a chercher tel quel |
|
| 140 | - // -> on remplace les espaces par un _ et on enleve les guillemets |
|
| 141 | - // corriger le like dans le $q |
|
| 142 | - if (preg_match(',["][^"]+["],Uims', $q, $matches)) { |
|
| 143 | - foreach ($matches as $match) { |
|
| 144 | - $word = preg_replace(",\s+,Uims", "_", $match); |
|
| 145 | - $word = trim($word, '"'); |
|
| 146 | - $q = str_replace($match, $word, $q); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - // corriger la regexp |
|
| 150 | - if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 151 | - foreach ($matches as $match) { |
|
| 152 | - $word = preg_replace(",\s+,Uims", "[\s]", $match); |
|
| 153 | - $word = trim($word, '"'); |
|
| 154 | - $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - $q = sql_quote( |
|
| 158 | - "%" |
|
| 159 | - . preg_replace(",\s+," . $u, "%", $q) |
|
| 160 | - . "%" |
|
| 161 | - ); |
|
| 162 | - |
|
| 163 | - $preg = '/' . preg_replace(",\s+," . $u, ".+", trim($recherche_mod)) . '/' . $options['preg_flags']; |
|
| 164 | - |
|
| 165 | - } else { |
|
| 166 | - $methode = 'REGEXP'; |
|
| 167 | - $q = sql_quote(trim($recherche, '/')); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - // tous les caracteres transliterables de $q sont remplaces par un joker |
|
| 171 | - // permet de matcher en SQL meme si on est sensible aux accents (SQLite) |
|
| 172 | - $q_t = $q; |
|
| 173 | - for ($i = 0; $i < spip_strlen($q); $i++) { |
|
| 174 | - $char = spip_substr($q, $i, 1); |
|
| 175 | - if (!is_ascii($char) |
|
| 176 | - and $char_t = translitteration($char) |
|
| 177 | - and $char_t !== $char |
|
| 178 | - ) { |
|
| 179 | - $q_t = str_replace($char, $is_preg ? "." : "_", $q_t); |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - $q = $q_t; |
|
| 184 | - |
|
| 185 | - // fix : SQLite 3 est sensible aux accents, on jokerise les caracteres |
|
| 186 | - // les plus frequents qui peuvent etre accentues |
|
| 187 | - // (oui c'est tres dicustable...) |
|
| 188 | - if (isset($GLOBALS['connexions'][$options['serveur'] ? $options['serveur'] : 0]['type']) |
|
| 189 | - and strncmp($GLOBALS['connexions'][$options['serveur'] ? $options['serveur'] : 0]['type'], 'sqlite', 6) == 0 |
|
| 190 | - ) { |
|
| 191 | - $q_t = strtr($q, "aeuioc", $is_preg ? "......" : "______"); |
|
| 192 | - // si il reste au moins un char significatif... |
|
| 193 | - if (preg_match(",[^'%_.],", $q_t)) { |
|
| 194 | - $q = $q_t; |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - return $expression[$key] = array($methode, $q, $preg); |
|
| 61 | + // ne calculer qu'une seule fois l'expression par hit |
|
| 62 | + // (meme si utilisee dans plusieurs boucles) |
|
| 63 | + static $expression = array(); |
|
| 64 | + $key = serialize(array($recherche, $options['preg_flags'])); |
|
| 65 | + if (isset($expression[$key])) { |
|
| 66 | + return $expression[$key]; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 70 | + if ($u and strpos($options['preg_flags'], $u) === false) { |
|
| 71 | + $options['preg_flags'] .= $u; |
|
| 72 | + } |
|
| 73 | + include_spip('inc/charsets'); |
|
| 74 | + $recherche = trim($recherche); |
|
| 75 | + |
|
| 76 | + $is_preg = false; |
|
| 77 | + if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) { |
|
| 78 | + // c'est une preg |
|
| 79 | + $recherche_trans = translitteration($recherche); |
|
| 80 | + $preg = $recherche_trans . $options['preg_flags']; |
|
| 81 | + $is_preg = true; |
|
| 82 | + } else { |
|
| 83 | + // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP, |
|
| 84 | + // sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un', |
|
| 85 | + // 'une', 'des' ...) |
|
| 86 | + |
|
| 87 | + // attention : plusieurs mots entre guillemets sont a rechercher tels quels |
|
| 88 | + $recherche_trans = $recherche_mod = $recherche; |
|
| 89 | + |
|
| 90 | + // les expressions entre " " sont un mot a chercher tel quel |
|
| 91 | + // -> on remplace les espaces par un \x1 et on enleve les guillemets |
|
| 92 | + if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 93 | + foreach ($matches as $match) { |
|
| 94 | + $word = preg_replace(",\s+,Uims", "\x1", $match); |
|
| 95 | + $word = trim($word, '"'); |
|
| 96 | + $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + if (preg_match(",\s+," . $u, $recherche_mod)) { |
|
| 101 | + $is_preg = true; |
|
| 102 | + |
|
| 103 | + $recherche_inter = '|'; |
|
| 104 | + $recherche_mots = explode(' ', $recherche_mod); |
|
| 105 | + $min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4; |
|
| 106 | + foreach ($recherche_mots as $mot) { |
|
| 107 | + if (strlen($mot) >= $min_long) { |
|
| 108 | + // echapper les caracteres de regexp qui sont eventuellement dans la recherche |
|
| 109 | + $recherche_inter .= preg_quote($mot) . ' '; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + $recherche_inter = str_replace("\x1", '\s', $recherche_inter); |
|
| 113 | + |
|
| 114 | + // mais on cherche quand même l'expression complète, même si elle |
|
| 115 | + // comporte des mots de moins de quatre lettres |
|
| 116 | + $recherche = rtrim(preg_quote($recherche) . preg_replace(',\s+,' . $u, '|', $recherche_inter), '|'); |
|
| 117 | + $recherche_trans = translitteration($recherche); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $preg = '/' . str_replace('/', '\\/', $recherche_trans) . '/' . $options['preg_flags']; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite |
|
| 124 | + // ou si l'expression reguliere est invalide |
|
| 125 | + if (!$is_preg |
|
| 126 | + or (@preg_match($preg, '') === false) |
|
| 127 | + ) { |
|
| 128 | + $methode = 'LIKE'; |
|
| 129 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 130 | + |
|
| 131 | + // echapper les % et _ |
|
| 132 | + $q = str_replace(array('%', '_'), array('\%', '\_'), trim($recherche)); |
|
| 133 | + |
|
| 134 | + // 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 |
|
| 135 | + $recherche = preg_quote($recherche, '/'); |
|
| 136 | + $recherche_trans = translitteration($recherche); |
|
| 137 | + $recherche_mod = $recherche_trans; |
|
| 138 | + |
|
| 139 | + // les expressions entre " " sont un mot a chercher tel quel |
|
| 140 | + // -> on remplace les espaces par un _ et on enleve les guillemets |
|
| 141 | + // corriger le like dans le $q |
|
| 142 | + if (preg_match(',["][^"]+["],Uims', $q, $matches)) { |
|
| 143 | + foreach ($matches as $match) { |
|
| 144 | + $word = preg_replace(",\s+,Uims", "_", $match); |
|
| 145 | + $word = trim($word, '"'); |
|
| 146 | + $q = str_replace($match, $word, $q); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + // corriger la regexp |
|
| 150 | + if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) { |
|
| 151 | + foreach ($matches as $match) { |
|
| 152 | + $word = preg_replace(",\s+,Uims", "[\s]", $match); |
|
| 153 | + $word = trim($word, '"'); |
|
| 154 | + $recherche_mod = str_replace($match, $word, $recherche_mod); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + $q = sql_quote( |
|
| 158 | + "%" |
|
| 159 | + . preg_replace(",\s+," . $u, "%", $q) |
|
| 160 | + . "%" |
|
| 161 | + ); |
|
| 162 | + |
|
| 163 | + $preg = '/' . preg_replace(",\s+," . $u, ".+", trim($recherche_mod)) . '/' . $options['preg_flags']; |
|
| 164 | + |
|
| 165 | + } else { |
|
| 166 | + $methode = 'REGEXP'; |
|
| 167 | + $q = sql_quote(trim($recherche, '/')); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + // tous les caracteres transliterables de $q sont remplaces par un joker |
|
| 171 | + // permet de matcher en SQL meme si on est sensible aux accents (SQLite) |
|
| 172 | + $q_t = $q; |
|
| 173 | + for ($i = 0; $i < spip_strlen($q); $i++) { |
|
| 174 | + $char = spip_substr($q, $i, 1); |
|
| 175 | + if (!is_ascii($char) |
|
| 176 | + and $char_t = translitteration($char) |
|
| 177 | + and $char_t !== $char |
|
| 178 | + ) { |
|
| 179 | + $q_t = str_replace($char, $is_preg ? "." : "_", $q_t); |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + $q = $q_t; |
|
| 184 | + |
|
| 185 | + // fix : SQLite 3 est sensible aux accents, on jokerise les caracteres |
|
| 186 | + // les plus frequents qui peuvent etre accentues |
|
| 187 | + // (oui c'est tres dicustable...) |
|
| 188 | + if (isset($GLOBALS['connexions'][$options['serveur'] ? $options['serveur'] : 0]['type']) |
|
| 189 | + and strncmp($GLOBALS['connexions'][$options['serveur'] ? $options['serveur'] : 0]['type'], 'sqlite', 6) == 0 |
|
| 190 | + ) { |
|
| 191 | + $q_t = strtr($q, "aeuioc", $is_preg ? "......" : "______"); |
|
| 192 | + // si il reste au moins un char significatif... |
|
| 193 | + if (preg_match(",[^'%_.],", $q_t)) { |
|
| 194 | + $q = $q_t; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + return $expression[$key] = array($methode, $q, $preg); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
@@ -208,119 +208,119 @@ discard block |
||
| 208 | 208 | // On peut passer les tables, ou une chaine listant les tables souhaitees |
| 209 | 209 | // http://doc.spip.org/@recherche_en_base |
| 210 | 210 | function recherche_en_base($recherche='', $tables=NULL, $options=array(), $serveur='') { |
| 211 | - include_spip('base/abstract_sql'); |
|
| 212 | - |
|
| 213 | - if (!is_array($tables)) { |
|
| 214 | - $liste = liste_des_champs(); |
|
| 215 | - |
|
| 216 | - if (is_string($tables) |
|
| 217 | - AND $tables != '') { |
|
| 218 | - $toutes = array(); |
|
| 219 | - foreach(explode(',', $tables) as $t) |
|
| 220 | - if (isset($liste[$t])) |
|
| 221 | - $toutes[$t] = $liste[$t]; |
|
| 222 | - $tables = $toutes; |
|
| 223 | - unset($toutes); |
|
| 224 | - } else |
|
| 225 | - $tables = $liste; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - if (!strlen($recherche) OR !count($tables)) |
|
| 229 | - return array(); |
|
| 230 | - |
|
| 231 | - include_spip('inc/autoriser'); |
|
| 232 | - |
|
| 233 | - // options par defaut |
|
| 234 | - $options = array_merge(array( |
|
| 235 | - 'preg_flags' => 'UimsS', |
|
| 236 | - 'toutvoir' => false, |
|
| 237 | - 'champs' => false, |
|
| 238 | - 'score' => false, |
|
| 239 | - 'matches' => false, |
|
| 240 | - 'jointures' => false, |
|
| 241 | - 'serveur' => $serveur |
|
| 242 | - ), |
|
| 243 | - $options |
|
| 244 | - ); |
|
| 245 | - |
|
| 246 | - $results = array(); |
|
| 247 | - |
|
| 248 | - // Utiliser l'iterateur (DATA:recherche) |
|
| 249 | - // pour recuperer les couples (id_objet, score) |
|
| 250 | - // Le resultat est au format { |
|
| 251 | - // id1 = { 'score' => x, attrs => { } }, |
|
| 252 | - // id2 = { 'score' => x, attrs => { } }, |
|
| 253 | - // } |
|
| 254 | - include_spip('inc/memoization'); |
|
| 255 | - foreach ($tables as $table => $champs) { |
|
| 256 | - # lock via memoization, si dispo |
|
| 257 | - if (function_exists('cache_lock')) |
|
| 258 | - cache_lock($lock = 'recherche '.$table.' '.$recherche); |
|
| 259 | - |
|
| 260 | - spip_timer('rech'); |
|
| 261 | - |
|
| 262 | - // TODO: ici plutot charger un iterateur via l'API iterateurs |
|
| 263 | - include_spip('inc/recherche_to_array'); |
|
| 264 | - $to_array = charger_fonction('recherche_to_array', 'inc'); |
|
| 265 | - $results[$table] = $to_array($recherche, |
|
| 266 | - array_merge($options, array('table' => $table, 'champs' => $champs)) |
|
| 267 | - ); |
|
| 268 | - ##var_dump($results[$table]); |
|
| 269 | - |
|
| 270 | - |
|
| 271 | - spip_log("recherche $table ($recherche) : ".count($results[$table])." resultats ".spip_timer('rech'),'recherche'); |
|
| 272 | - |
|
| 273 | - if (isset($lock)) |
|
| 274 | - cache_unlock($lock); |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - return $results; |
|
| 211 | + include_spip('base/abstract_sql'); |
|
| 212 | + |
|
| 213 | + if (!is_array($tables)) { |
|
| 214 | + $liste = liste_des_champs(); |
|
| 215 | + |
|
| 216 | + if (is_string($tables) |
|
| 217 | + AND $tables != '') { |
|
| 218 | + $toutes = array(); |
|
| 219 | + foreach(explode(',', $tables) as $t) |
|
| 220 | + if (isset($liste[$t])) |
|
| 221 | + $toutes[$t] = $liste[$t]; |
|
| 222 | + $tables = $toutes; |
|
| 223 | + unset($toutes); |
|
| 224 | + } else |
|
| 225 | + $tables = $liste; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + if (!strlen($recherche) OR !count($tables)) |
|
| 229 | + return array(); |
|
| 230 | + |
|
| 231 | + include_spip('inc/autoriser'); |
|
| 232 | + |
|
| 233 | + // options par defaut |
|
| 234 | + $options = array_merge(array( |
|
| 235 | + 'preg_flags' => 'UimsS', |
|
| 236 | + 'toutvoir' => false, |
|
| 237 | + 'champs' => false, |
|
| 238 | + 'score' => false, |
|
| 239 | + 'matches' => false, |
|
| 240 | + 'jointures' => false, |
|
| 241 | + 'serveur' => $serveur |
|
| 242 | + ), |
|
| 243 | + $options |
|
| 244 | + ); |
|
| 245 | + |
|
| 246 | + $results = array(); |
|
| 247 | + |
|
| 248 | + // Utiliser l'iterateur (DATA:recherche) |
|
| 249 | + // pour recuperer les couples (id_objet, score) |
|
| 250 | + // Le resultat est au format { |
|
| 251 | + // id1 = { 'score' => x, attrs => { } }, |
|
| 252 | + // id2 = { 'score' => x, attrs => { } }, |
|
| 253 | + // } |
|
| 254 | + include_spip('inc/memoization'); |
|
| 255 | + foreach ($tables as $table => $champs) { |
|
| 256 | + # lock via memoization, si dispo |
|
| 257 | + if (function_exists('cache_lock')) |
|
| 258 | + cache_lock($lock = 'recherche '.$table.' '.$recherche); |
|
| 259 | + |
|
| 260 | + spip_timer('rech'); |
|
| 261 | + |
|
| 262 | + // TODO: ici plutot charger un iterateur via l'API iterateurs |
|
| 263 | + include_spip('inc/recherche_to_array'); |
|
| 264 | + $to_array = charger_fonction('recherche_to_array', 'inc'); |
|
| 265 | + $results[$table] = $to_array($recherche, |
|
| 266 | + array_merge($options, array('table' => $table, 'champs' => $champs)) |
|
| 267 | + ); |
|
| 268 | + ##var_dump($results[$table]); |
|
| 269 | + |
|
| 270 | + |
|
| 271 | + spip_log("recherche $table ($recherche) : ".count($results[$table])." resultats ".spip_timer('rech'),'recherche'); |
|
| 272 | + |
|
| 273 | + if (isset($lock)) |
|
| 274 | + cache_unlock($lock); |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + return $results; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | |
| 281 | 281 | // Effectue une recherche sur toutes les tables de la base de donnees |
| 282 | 282 | // http://doc.spip.org/@remplace_en_base |
| 283 | 283 | function remplace_en_base($recherche='', $remplace=NULL, $tables=NULL, $options=array()) { |
| 284 | - include_spip('inc/modifier'); |
|
| 285 | - |
|
| 286 | - // options par defaut |
|
| 287 | - $options = array_merge(array( |
|
| 288 | - 'preg_flags' => 'UimsS', |
|
| 289 | - 'toutmodifier' => false |
|
| 290 | - ), |
|
| 291 | - $options |
|
| 292 | - ); |
|
| 293 | - $options['champs'] = true; |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - if (!is_array($tables)) |
|
| 297 | - $tables = liste_des_champs(); |
|
| 298 | - |
|
| 299 | - $results = recherche_en_base($recherche, $tables, $options); |
|
| 300 | - |
|
| 301 | - $preg = '/'.str_replace('/', '\\/', $recherche).'/' . $options['preg_flags']; |
|
| 302 | - |
|
| 303 | - foreach ($results as $table => $r) { |
|
| 304 | - $_id_table = id_table_objet($table); |
|
| 305 | - foreach ($r as $id => $x) { |
|
| 306 | - if ($options['toutmodifier'] |
|
| 307 | - OR autoriser('modifier', $table, $id)) { |
|
| 308 | - $modifs = array(); |
|
| 309 | - foreach ($x['champs'] as $key => $val) { |
|
| 310 | - if ($key == $_id_table) next; |
|
| 311 | - $repl = preg_replace($preg, $remplace, $val); |
|
| 312 | - if ($repl <> $val) |
|
| 313 | - $modifs[$key] = $repl; |
|
| 314 | - } |
|
| 315 | - if ($modifs) |
|
| 316 | - objet_modifier_champs($table, $id, |
|
| 317 | - array( |
|
| 318 | - 'champs' => array_keys($modifs), |
|
| 319 | - ), |
|
| 320 | - $modifs); |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - } |
|
| 284 | + include_spip('inc/modifier'); |
|
| 285 | + |
|
| 286 | + // options par defaut |
|
| 287 | + $options = array_merge(array( |
|
| 288 | + 'preg_flags' => 'UimsS', |
|
| 289 | + 'toutmodifier' => false |
|
| 290 | + ), |
|
| 291 | + $options |
|
| 292 | + ); |
|
| 293 | + $options['champs'] = true; |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + if (!is_array($tables)) |
|
| 297 | + $tables = liste_des_champs(); |
|
| 298 | + |
|
| 299 | + $results = recherche_en_base($recherche, $tables, $options); |
|
| 300 | + |
|
| 301 | + $preg = '/'.str_replace('/', '\\/', $recherche).'/' . $options['preg_flags']; |
|
| 302 | + |
|
| 303 | + foreach ($results as $table => $r) { |
|
| 304 | + $_id_table = id_table_objet($table); |
|
| 305 | + foreach ($r as $id => $x) { |
|
| 306 | + if ($options['toutmodifier'] |
|
| 307 | + OR autoriser('modifier', $table, $id)) { |
|
| 308 | + $modifs = array(); |
|
| 309 | + foreach ($x['champs'] as $key => $val) { |
|
| 310 | + if ($key == $_id_table) next; |
|
| 311 | + $repl = preg_replace($preg, $remplace, $val); |
|
| 312 | + if ($repl <> $val) |
|
| 313 | + $modifs[$key] = $repl; |
|
| 314 | + } |
|
| 315 | + if ($modifs) |
|
| 316 | + objet_modifier_champs($table, $id, |
|
| 317 | + array( |
|
| 318 | + 'champs' => array_keys($modifs), |
|
| 319 | + ), |
|
| 320 | + $modifs); |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | ?> |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | // avec un poids pour le score |
| 19 | 19 | // http://doc.spip.org/@liste_des_champs |
| 20 | 20 | function liste_des_champs() { |
| 21 | - static $liste=null; |
|
| 21 | + static $liste = null; |
|
| 22 | 22 | if (is_null($liste)) { |
| 23 | 23 | $liste = array(); |
| 24 | 24 | // recuperer les tables_objets_sql declarees |
| 25 | 25 | include_spip('base/objets'); |
| 26 | 26 | $tables_objets = lister_tables_objets_sql(); |
| 27 | - foreach($tables_objets as $t=>$infos){ |
|
| 28 | - if ($infos['rechercher_champs']){ |
|
| 27 | + foreach ($tables_objets as $t=>$infos) { |
|
| 28 | + if ($infos['rechercher_champs']) { |
|
| 29 | 29 | $liste[$infos['type']] = $infos['rechercher_champs']; |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | // en ne regardant que le titre ou le nom |
| 41 | 41 | // http://doc.spip.org/@liste_des_jointures |
| 42 | 42 | function liste_des_jointures() { |
| 43 | - static $liste=null; |
|
| 43 | + static $liste = null; |
|
| 44 | 44 | if (is_null($liste)) { |
| 45 | 45 | $liste = array(); |
| 46 | 46 | // recuperer les tables_objets_sql declarees |
| 47 | 47 | include_spip('base/objets'); |
| 48 | 48 | $tables_objets = lister_tables_objets_sql(); |
| 49 | - foreach($tables_objets as $t=>$infos){ |
|
| 50 | - if ($infos['rechercher_jointures']){ |
|
| 49 | + foreach ($tables_objets as $t=>$infos) { |
|
| 50 | + if ($infos['rechercher_jointures']) { |
|
| 51 | 51 | $liste[$infos['type']] = $infos['rechercher_jointures']; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) { |
| 78 | 78 | // c'est une preg |
| 79 | 79 | $recherche_trans = translitteration($recherche); |
| 80 | - $preg = $recherche_trans . $options['preg_flags']; |
|
| 80 | + $preg = $recherche_trans.$options['preg_flags']; |
|
| 81 | 81 | $is_preg = true; |
| 82 | 82 | } else { |
| 83 | 83 | // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP, |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if (preg_match(",\s+," . $u, $recherche_mod)) { |
|
| 100 | + if (preg_match(",\s+,".$u, $recherche_mod)) { |
|
| 101 | 101 | $is_preg = true; |
| 102 | 102 | |
| 103 | 103 | $recherche_inter = '|'; |
@@ -106,18 +106,18 @@ discard block |
||
| 106 | 106 | foreach ($recherche_mots as $mot) { |
| 107 | 107 | if (strlen($mot) >= $min_long) { |
| 108 | 108 | // echapper les caracteres de regexp qui sont eventuellement dans la recherche |
| 109 | - $recherche_inter .= preg_quote($mot) . ' '; |
|
| 109 | + $recherche_inter .= preg_quote($mot).' '; |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | $recherche_inter = str_replace("\x1", '\s', $recherche_inter); |
| 113 | 113 | |
| 114 | 114 | // mais on cherche quand même l'expression complète, même si elle |
| 115 | 115 | // comporte des mots de moins de quatre lettres |
| 116 | - $recherche = rtrim(preg_quote($recherche) . preg_replace(',\s+,' . $u, '|', $recherche_inter), '|'); |
|
| 116 | + $recherche = rtrim(preg_quote($recherche).preg_replace(',\s+,'.$u, '|', $recherche_inter), '|'); |
|
| 117 | 117 | $recherche_trans = translitteration($recherche); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $preg = '/' . str_replace('/', '\\/', $recherche_trans) . '/' . $options['preg_flags']; |
|
| 120 | + $preg = '/'.str_replace('/', '\\/', $recherche_trans).'/'.$options['preg_flags']; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite |
@@ -156,11 +156,11 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | $q = sql_quote( |
| 158 | 158 | "%" |
| 159 | - . preg_replace(",\s+," . $u, "%", $q) |
|
| 159 | + . preg_replace(",\s+,".$u, "%", $q) |
|
| 160 | 160 | . "%" |
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | - $preg = '/' . preg_replace(",\s+," . $u, ".+", trim($recherche_mod)) . '/' . $options['preg_flags']; |
|
| 163 | + $preg = '/'.preg_replace(",\s+,".$u, ".+", trim($recherche_mod)).'/'.$options['preg_flags']; |
|
| 164 | 164 | |
| 165 | 165 | } else { |
| 166 | 166 | $methode = 'REGEXP'; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | // - score pour retourner un score |
| 208 | 208 | // On peut passer les tables, ou une chaine listant les tables souhaitees |
| 209 | 209 | // http://doc.spip.org/@recherche_en_base |
| 210 | -function recherche_en_base($recherche='', $tables=NULL, $options=array(), $serveur='') { |
|
| 210 | +function recherche_en_base($recherche = '', $tables = NULL, $options = array(), $serveur = '') { |
|
| 211 | 211 | include_spip('base/abstract_sql'); |
| 212 | 212 | |
| 213 | 213 | if (!is_array($tables)) { |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | if (is_string($tables) |
| 217 | 217 | AND $tables != '') { |
| 218 | 218 | $toutes = array(); |
| 219 | - foreach(explode(',', $tables) as $t) |
|
| 219 | + foreach (explode(',', $tables) as $t) |
|
| 220 | 220 | if (isset($liste[$t])) |
| 221 | 221 | $toutes[$t] = $liste[$t]; |
| 222 | 222 | $tables = $toutes; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | ##var_dump($results[$table]); |
| 269 | 269 | |
| 270 | 270 | |
| 271 | - spip_log("recherche $table ($recherche) : ".count($results[$table])." resultats ".spip_timer('rech'),'recherche'); |
|
| 271 | + spip_log("recherche $table ($recherche) : ".count($results[$table])." resultats ".spip_timer('rech'), 'recherche'); |
|
| 272 | 272 | |
| 273 | 273 | if (isset($lock)) |
| 274 | 274 | cache_unlock($lock); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | // Effectue une recherche sur toutes les tables de la base de donnees |
| 282 | 282 | // http://doc.spip.org/@remplace_en_base |
| 283 | -function remplace_en_base($recherche='', $remplace=NULL, $tables=NULL, $options=array()) { |
|
| 283 | +function remplace_en_base($recherche = '', $remplace = NULL, $tables = NULL, $options = array()) { |
|
| 284 | 284 | include_spip('inc/modifier'); |
| 285 | 285 | |
| 286 | 286 | // options par defaut |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | $results = recherche_en_base($recherche, $tables, $options); |
| 300 | 300 | |
| 301 | - $preg = '/'.str_replace('/', '\\/', $recherche).'/' . $options['preg_flags']; |
|
| 301 | + $preg = '/'.str_replace('/', '\\/', $recherche).'/'.$options['preg_flags']; |
|
| 302 | 302 | |
| 303 | 303 | foreach ($results as $table => $r) { |
| 304 | 304 | $_id_table = id_table_objet($table); |
@@ -11,7 +11,9 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | |
| 14 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 14 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 15 | + return; |
|
| 16 | +} |
|
| 15 | 17 | |
| 16 | 18 | |
| 17 | 19 | // Donne la liste des champs/tables ou l'on sait chercher/remplacer |
@@ -216,17 +218,20 @@ discard block |
||
| 216 | 218 | if (is_string($tables) |
| 217 | 219 | AND $tables != '') { |
| 218 | 220 | $toutes = array(); |
| 219 | - foreach(explode(',', $tables) as $t) |
|
| 220 | - if (isset($liste[$t])) |
|
| 221 | + foreach(explode(',', $tables) as $t) { |
|
| 222 | + if (isset($liste[$t])) |
|
| 221 | 223 | $toutes[$t] = $liste[$t]; |
| 224 | + } |
|
| 222 | 225 | $tables = $toutes; |
| 223 | 226 | unset($toutes); |
| 224 | - } else |
|
| 225 | - $tables = $liste; |
|
| 227 | + } else { |
|
| 228 | + $tables = $liste; |
|
| 229 | + } |
|
| 226 | 230 | } |
| 227 | 231 | |
| 228 | - if (!strlen($recherche) OR !count($tables)) |
|
| 229 | - return array(); |
|
| 232 | + if (!strlen($recherche) OR !count($tables)) { |
|
| 233 | + return array(); |
|
| 234 | + } |
|
| 230 | 235 | |
| 231 | 236 | include_spip('inc/autoriser'); |
| 232 | 237 | |
@@ -254,8 +259,9 @@ discard block |
||
| 254 | 259 | include_spip('inc/memoization'); |
| 255 | 260 | foreach ($tables as $table => $champs) { |
| 256 | 261 | # lock via memoization, si dispo |
| 257 | - if (function_exists('cache_lock')) |
|
| 258 | - cache_lock($lock = 'recherche '.$table.' '.$recherche); |
|
| 262 | + if (function_exists('cache_lock')) { |
|
| 263 | + cache_lock($lock = 'recherche '.$table.' '.$recherche); |
|
| 264 | + } |
|
| 259 | 265 | |
| 260 | 266 | spip_timer('rech'); |
| 261 | 267 | |
@@ -270,8 +276,9 @@ discard block |
||
| 270 | 276 | |
| 271 | 277 | spip_log("recherche $table ($recherche) : ".count($results[$table])." resultats ".spip_timer('rech'),'recherche'); |
| 272 | 278 | |
| 273 | - if (isset($lock)) |
|
| 274 | - cache_unlock($lock); |
|
| 279 | + if (isset($lock)) { |
|
| 280 | + cache_unlock($lock); |
|
| 281 | + } |
|
| 275 | 282 | } |
| 276 | 283 | |
| 277 | 284 | return $results; |
@@ -293,8 +300,9 @@ discard block |
||
| 293 | 300 | $options['champs'] = true; |
| 294 | 301 | |
| 295 | 302 | |
| 296 | - if (!is_array($tables)) |
|
| 297 | - $tables = liste_des_champs(); |
|
| 303 | + if (!is_array($tables)) { |
|
| 304 | + $tables = liste_des_champs(); |
|
| 305 | + } |
|
| 298 | 306 | |
| 299 | 307 | $results = recherche_en_base($recherche, $tables, $options); |
| 300 | 308 | |
@@ -307,17 +315,21 @@ discard block |
||
| 307 | 315 | OR autoriser('modifier', $table, $id)) { |
| 308 | 316 | $modifs = array(); |
| 309 | 317 | foreach ($x['champs'] as $key => $val) { |
| 310 | - if ($key == $_id_table) next; |
|
| 318 | + if ($key == $_id_table) { |
|
| 319 | + next; |
|
| 320 | + } |
|
| 311 | 321 | $repl = preg_replace($preg, $remplace, $val); |
| 312 | - if ($repl <> $val) |
|
| 313 | - $modifs[$key] = $repl; |
|
| 322 | + if ($repl <> $val) { |
|
| 323 | + $modifs[$key] = $repl; |
|
| 324 | + } |
|
| 314 | 325 | } |
| 315 | - if ($modifs) |
|
| 316 | - objet_modifier_champs($table, $id, |
|
| 326 | + if ($modifs) { |
|
| 327 | + objet_modifier_champs($table, $id, |
|
| 317 | 328 | array( |
| 318 | 329 | 'champs' => array_keys($modifs), |
| 319 | 330 | ), |
| 320 | 331 | $modifs); |
| 332 | + } |
|
| 321 | 333 | } |
| 322 | 334 | } |
| 323 | 335 | } |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | * @return void |
| 34 | 34 | **/ |
| 35 | 35 | function echo_log($f, $ret) { |
| 36 | - spip_log("Page " . self() . " function $f: echo ".substr($ret,0,50)."...",'echo'); |
|
| 37 | - echo |
|
| 38 | - (_SIGNALER_ECHOS?"#Echo par $f#" :"") |
|
| 39 | - . $ret; |
|
| 36 | + spip_log("Page " . self() . " function $f: echo ".substr($ret,0,50)."...",'echo'); |
|
| 37 | + echo |
|
| 38 | + (_SIGNALER_ECHOS?"#Echo par $f#" :"") |
|
| 39 | + . $ret; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | * @return string Code HTML |
| 75 | 75 | */ |
| 76 | 76 | function creer_colonne_droite(){ |
| 77 | - static $deja_colonne_droite; |
|
| 78 | - if ($GLOBALS['spip_ecran']!='large' OR $deja_colonne_droite) return ''; |
|
| 79 | - $deja_colonne_droite = true; |
|
| 80 | - return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 77 | + static $deja_colonne_droite; |
|
| 78 | + if ($GLOBALS['spip_ecran']!='large' OR $deja_colonne_droite) return ''; |
|
| 79 | + $deja_colonne_droite = true; |
|
| 80 | + return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -85,129 +85,129 @@ discard block |
||
| 85 | 85 | * @return string Code HTML |
| 86 | 86 | */ |
| 87 | 87 | function debut_droite() { |
| 88 | - return liste_objets_bloques(_request('exec')) |
|
| 89 | - . creer_colonne_droite() |
|
| 90 | - . "</div>" |
|
| 91 | - . "\n<div id='contenu'>"; |
|
| 88 | + return liste_objets_bloques(_request('exec')) |
|
| 89 | + . creer_colonne_droite() |
|
| 90 | + . "</div>" |
|
| 91 | + . "\n<div id='contenu'>"; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // http://doc.spip.org/@liste_articles_bloques |
| 95 | 95 | function liste_objets_bloques($exec,$contexte=array(),$auteur=null){ |
| 96 | - $res = ''; |
|
| 97 | - if ($GLOBALS['meta']["articles_modif"] != "non") { |
|
| 98 | - include_spip('inc/drapeau_edition'); |
|
| 99 | - if (is_null($auteur)) |
|
| 100 | - $auteur = $GLOBALS['visiteur_session']; |
|
| 101 | - if ($en_cours=trouver_objet_exec($exec) |
|
| 102 | - AND $en_cours['edition'] |
|
| 103 | - AND $type = $en_cours['type'] |
|
| 104 | - AND ($id = $contexte[$en_cours['id_table_objet']] OR $id = _request($en_cours['id_table_objet']))) { |
|
| 105 | - // marquer le fait que l'objet est ouvert en edition par toto |
|
| 106 | - // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 107 | - signale_edition ($id, $auteur, $type); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 111 | - if (count($objets_ouverts)) { |
|
| 112 | - $res .= recuperer_fond('prive/objets/liste/objets-en-edition',array(),array('ajax'=>true)); |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - return $res; |
|
| 96 | + $res = ''; |
|
| 97 | + if ($GLOBALS['meta']["articles_modif"] != "non") { |
|
| 98 | + include_spip('inc/drapeau_edition'); |
|
| 99 | + if (is_null($auteur)) |
|
| 100 | + $auteur = $GLOBALS['visiteur_session']; |
|
| 101 | + if ($en_cours=trouver_objet_exec($exec) |
|
| 102 | + AND $en_cours['edition'] |
|
| 103 | + AND $type = $en_cours['type'] |
|
| 104 | + AND ($id = $contexte[$en_cours['id_table_objet']] OR $id = _request($en_cours['id_table_objet']))) { |
|
| 105 | + // marquer le fait que l'objet est ouvert en edition par toto |
|
| 106 | + // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 107 | + signale_edition ($id, $auteur, $type); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 111 | + if (count($objets_ouverts)) { |
|
| 112 | + $res .= recuperer_fond('prive/objets/liste/objets-en-edition',array(),array('ajax'=>true)); |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + return $res; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Fin de page de l'interface privee. |
| 119 | 119 | // Elle comporte une image invisible declenchant une tache de fond |
| 120 | 120 | // http://doc.spip.org/@fin_page |
| 121 | 121 | function fin_page(){ |
| 122 | - include_spip('inc/pipelines'); |
|
| 123 | - // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 124 | - $debug = ((_request('exec') !== 'valider_xml') |
|
| 125 | - AND ((_request('var_mode') == 'debug') |
|
| 126 | - OR (isset($GLOBALS['tableau_des_temps']) AND $GLOBALS['tableau_des_temps']) |
|
| 127 | - AND isset($_COOKIE['spip_admin']))); |
|
| 128 | - $t = '</div><div id="pied"><div class="largeur">' |
|
| 129 | - . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 130 | - . "</div>" |
|
| 131 | - . "</div></div>" // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 132 | - . ($debug?erreur_squelette():'') |
|
| 133 | - . "</body></html>\n"; |
|
| 134 | - return f_queue($t); |
|
| 122 | + include_spip('inc/pipelines'); |
|
| 123 | + // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 124 | + $debug = ((_request('exec') !== 'valider_xml') |
|
| 125 | + AND ((_request('var_mode') == 'debug') |
|
| 126 | + OR (isset($GLOBALS['tableau_des_temps']) AND $GLOBALS['tableau_des_temps']) |
|
| 127 | + AND isset($_COOKIE['spip_admin']))); |
|
| 128 | + $t = '</div><div id="pied"><div class="largeur">' |
|
| 129 | + . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 130 | + . "</div>" |
|
| 131 | + . "</div></div>" // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 132 | + . ($debug?erreur_squelette():'') |
|
| 133 | + . "</body></html>\n"; |
|
| 134 | + return f_queue($t); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | function html_tests_js(){ |
| 138 | - if (_SPIP_AJAX AND !defined('_TESTER_NOSCRIPT')) { |
|
| 139 | - // pour le pied de page (deja defini si on est validation XML) |
|
| 140 | - define('_TESTER_NOSCRIPT', |
|
| 141 | - "<noscript>\n<div style='display:none;'><img src='" |
|
| 142 | - . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 143 | - . "' width='1' height='1' alt='' /></div></noscript>\n"); |
|
| 144 | - } |
|
| 145 | - return |
|
| 146 | - (defined('_SESSION_REJOUER') ? _SESSION_REJOUER : '') |
|
| 147 | - . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 138 | + if (_SPIP_AJAX AND !defined('_TESTER_NOSCRIPT')) { |
|
| 139 | + // pour le pied de page (deja defini si on est validation XML) |
|
| 140 | + define('_TESTER_NOSCRIPT', |
|
| 141 | + "<noscript>\n<div style='display:none;'><img src='" |
|
| 142 | + . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 143 | + . "' width='1' height='1' alt='' /></div></noscript>\n"); |
|
| 144 | + } |
|
| 145 | + return |
|
| 146 | + (defined('_SESSION_REJOUER') ? _SESSION_REJOUER : '') |
|
| 147 | + . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | function info_maj_spip(){ |
| 151 | 151 | |
| 152 | - $maj = $GLOBALS['meta']['info_maj_spip']; |
|
| 153 | - if (!$maj) |
|
| 154 | - return ""; |
|
| 152 | + $maj = $GLOBALS['meta']['info_maj_spip']; |
|
| 153 | + if (!$maj) |
|
| 154 | + return ""; |
|
| 155 | 155 | |
| 156 | - $maj = explode('|',$maj); |
|
| 157 | - // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 158 | - if ($GLOBALS['spip_version_branche']!==reset($maj)) |
|
| 159 | - return ""; |
|
| 156 | + $maj = explode('|',$maj); |
|
| 157 | + // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 158 | + if ($GLOBALS['spip_version_branche']!==reset($maj)) |
|
| 159 | + return ""; |
|
| 160 | 160 | |
| 161 | - if (!autoriser('webmestre')) |
|
| 162 | - return ""; |
|
| 161 | + if (!autoriser('webmestre')) |
|
| 162 | + return ""; |
|
| 163 | 163 | |
| 164 | - array_shift($maj); |
|
| 165 | - $maj = implode('|',$maj); |
|
| 164 | + array_shift($maj); |
|
| 165 | + $maj = implode('|',$maj); |
|
| 166 | 166 | |
| 167 | - return "$maj<br />"; |
|
| 167 | + return "$maj<br />"; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // http://doc.spip.org/@info_copyright |
| 171 | 171 | function info_copyright() { |
| 172 | - global $spip_version_affichee, $spip_lang; |
|
| 173 | - |
|
| 174 | - $version = $spip_version_affichee; |
|
| 175 | - |
|
| 176 | - // |
|
| 177 | - // Mention, le cas echeant, de la revision SVN courante |
|
| 178 | - // |
|
| 179 | - if ($svn_revision = version_svn_courante(_DIR_RACINE)) { |
|
| 180 | - $version .= ' ' . (($svn_revision < 0) ? 'SVN ':'') |
|
| 181 | - . "[<a href='http://core.spip.net/projects/spip/repository/revisions/" |
|
| 182 | - . abs($svn_revision) . "' target=\"_blank\" rel=\"noopener noreferrer\">" |
|
| 183 | - . abs($svn_revision) . "</a>]"; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - // et la version de l'ecran de securite |
|
| 187 | - $secu = defined('_ECRAN_SECURITE') |
|
| 188 | - ? "<br />"._T('ecran_securite',array('version'=>_ECRAN_SECURITE)) |
|
| 189 | - : ''; |
|
| 190 | - |
|
| 191 | - return _T('info_copyright', |
|
| 192 | - array('spip' => "<b>SPIP $version</b> ", |
|
| 193 | - 'lien_gpl' => |
|
| 194 | - "<a href='". generer_url_ecrire("aide", "aide=licence&var_lang=$spip_lang") . "' onclick=\"window.open(this.href, 'spip_aide', 'scrollbars=yes,resizable=yes,width=740,height=580'); return false;\">" . _T('info_copyright_gpl')."</a>")) |
|
| 195 | - . $secu; |
|
| 172 | + global $spip_version_affichee, $spip_lang; |
|
| 173 | + |
|
| 174 | + $version = $spip_version_affichee; |
|
| 175 | + |
|
| 176 | + // |
|
| 177 | + // Mention, le cas echeant, de la revision SVN courante |
|
| 178 | + // |
|
| 179 | + if ($svn_revision = version_svn_courante(_DIR_RACINE)) { |
|
| 180 | + $version .= ' ' . (($svn_revision < 0) ? 'SVN ':'') |
|
| 181 | + . "[<a href='http://core.spip.net/projects/spip/repository/revisions/" |
|
| 182 | + . abs($svn_revision) . "' target=\"_blank\" rel=\"noopener noreferrer\">" |
|
| 183 | + . abs($svn_revision) . "</a>]"; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + // et la version de l'ecran de securite |
|
| 187 | + $secu = defined('_ECRAN_SECURITE') |
|
| 188 | + ? "<br />"._T('ecran_securite',array('version'=>_ECRAN_SECURITE)) |
|
| 189 | + : ''; |
|
| 190 | + |
|
| 191 | + return _T('info_copyright', |
|
| 192 | + array('spip' => "<b>SPIP $version</b> ", |
|
| 193 | + 'lien_gpl' => |
|
| 194 | + "<a href='". generer_url_ecrire("aide", "aide=licence&var_lang=$spip_lang") . "' onclick=\"window.open(this.href, 'spip_aide', 'scrollbars=yes,resizable=yes,width=740,height=580'); return false;\">" . _T('info_copyright_gpl')."</a>")) |
|
| 195 | + . $secu; |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // http://doc.spip.org/@formulaire_recherche |
| 200 | 200 | function formulaire_recherche($page, $complement=""){ |
| 201 | - $recherche = _request('recherche'); |
|
| 202 | - $recherche_aff = entites_html($recherche); |
|
| 203 | - if (!strlen($recherche)) { |
|
| 204 | - $recherche_aff = _T('info_rechercher'); |
|
| 205 | - $onfocus = " onfocus=\"this.value='';\""; |
|
| 206 | - } else $onfocus = ''; |
|
| 207 | - |
|
| 208 | - $form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 209 | - $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='"._T('info_rechercher')."' />"; |
|
| 210 | - return "<div class='spip_recherche'>".generer_form_ecrire($page, $form . $complement, " method='get'")."</div>"; |
|
| 201 | + $recherche = _request('recherche'); |
|
| 202 | + $recherche_aff = entites_html($recherche); |
|
| 203 | + if (!strlen($recherche)) { |
|
| 204 | + $recherche_aff = _T('info_rechercher'); |
|
| 205 | + $onfocus = " onfocus=\"this.value='';\""; |
|
| 206 | + } else $onfocus = ''; |
|
| 207 | + |
|
| 208 | + $form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 209 | + $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='"._T('info_rechercher')."' />"; |
|
| 210 | + return "<div class='spip_recherche'>".generer_form_ecrire($page, $form . $complement, " method='get'")."</div>"; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | ?> |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | * @return void |
| 34 | 34 | **/ |
| 35 | 35 | function echo_log($f, $ret) { |
| 36 | - spip_log("Page " . self() . " function $f: echo ".substr($ret,0,50)."...",'echo'); |
|
| 36 | + spip_log("Page ".self()." function $f: echo ".substr($ret, 0, 50)."...", 'echo'); |
|
| 37 | 37 | echo |
| 38 | - (_SIGNALER_ECHOS?"#Echo par $f#" :"") |
|
| 38 | + (_SIGNALER_ECHOS ? "#Echo par $f#" : "") |
|
| 39 | 39 | . $ret; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | * Retourne le code HTML d'un début de cadre pour le centre de page (haut de page) |
| 44 | 44 | * @return string Code HTML |
| 45 | 45 | */ |
| 46 | -function debut_grand_cadre(){ return "\n<div class='table_page'>\n";} |
|
| 46 | +function debut_grand_cadre() { return "\n<div class='table_page'>\n"; } |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Retourne le code HTML d'une fin de cadre pour le centre de page (haut de page) |
| 50 | 50 | * @return string Code HTML |
| 51 | 51 | */ |
| 52 | -function fin_grand_cadre(){ return "\n</div>";} |
|
| 52 | +function fin_grand_cadre() { return "\n</div>"; } |
|
| 53 | 53 | |
| 54 | 54 | // Debut de la colonne de gauche |
| 55 | 55 | // div navigation fermee par creer_colonne_droite qui ouvre |
@@ -61,21 +61,21 @@ discard block |
||
| 61 | 61 | * Retourne le code HTML du début de la colonne gauche |
| 62 | 62 | * @return string Code HTML |
| 63 | 63 | */ |
| 64 | -function debut_gauche() { return "<div id='conteneur' class=''>\n<div id='navigation' class='lat' role='contentinfo'>\n";} |
|
| 64 | +function debut_gauche() { return "<div id='conteneur' class=''>\n<div id='navigation' class='lat' role='contentinfo'>\n"; } |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Retourne le code HTML de la fin de la colonne |
| 68 | 68 | * @return string Code HTML |
| 69 | 69 | */ |
| 70 | -function fin_gauche(){return "</div></div><br class='nettoyeur' />";} |
|
| 70 | +function fin_gauche() {return "</div></div><br class='nettoyeur' />"; } |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * Retourne le code HTML du changement de colonne (passer de la gauche à la droite) |
| 74 | 74 | * @return string Code HTML |
| 75 | 75 | */ |
| 76 | -function creer_colonne_droite(){ |
|
| 76 | +function creer_colonne_droite() { |
|
| 77 | 77 | static $deja_colonne_droite; |
| 78 | - if ($GLOBALS['spip_ecran']!='large' OR $deja_colonne_droite) return ''; |
|
| 78 | + if ($GLOBALS['spip_ecran'] != 'large' OR $deja_colonne_droite) return ''; |
|
| 79 | 79 | $deja_colonne_droite = true; |
| 80 | 80 | return "\n</div><div id='extra' class='lat' role='complementary'>"; |
| 81 | 81 | } |
@@ -92,24 +92,24 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // http://doc.spip.org/@liste_articles_bloques |
| 95 | -function liste_objets_bloques($exec,$contexte=array(),$auteur=null){ |
|
| 95 | +function liste_objets_bloques($exec, $contexte = array(), $auteur = null) { |
|
| 96 | 96 | $res = ''; |
| 97 | 97 | if ($GLOBALS['meta']["articles_modif"] != "non") { |
| 98 | 98 | include_spip('inc/drapeau_edition'); |
| 99 | 99 | if (is_null($auteur)) |
| 100 | 100 | $auteur = $GLOBALS['visiteur_session']; |
| 101 | - if ($en_cours=trouver_objet_exec($exec) |
|
| 101 | + if ($en_cours = trouver_objet_exec($exec) |
|
| 102 | 102 | AND $en_cours['edition'] |
| 103 | 103 | AND $type = $en_cours['type'] |
| 104 | 104 | AND ($id = $contexte[$en_cours['id_table_objet']] OR $id = _request($en_cours['id_table_objet']))) { |
| 105 | 105 | // marquer le fait que l'objet est ouvert en edition par toto |
| 106 | 106 | // a telle date ; une alerte sera donnee aux autres redacteurs |
| 107 | - signale_edition ($id, $auteur, $type); |
|
| 107 | + signale_edition($id, $auteur, $type); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
| 111 | 111 | if (count($objets_ouverts)) { |
| 112 | - $res .= recuperer_fond('prive/objets/liste/objets-en-edition',array(),array('ajax'=>true)); |
|
| 112 | + $res .= recuperer_fond('prive/objets/liste/objets-en-edition', array(), array('ajax'=>true)); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | return $res; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | // Fin de page de l'interface privee. |
| 119 | 119 | // Elle comporte une image invisible declenchant une tache de fond |
| 120 | 120 | // http://doc.spip.org/@fin_page |
| 121 | -function fin_page(){ |
|
| 121 | +function fin_page() { |
|
| 122 | 122 | include_spip('inc/pipelines'); |
| 123 | 123 | // avec &var_profile=1 on a le tableau de mesures SQL |
| 124 | 124 | $debug = ((_request('exec') !== 'valider_xml') |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | . recuperer_fond('prive/squelettes/inclure/pied') |
| 130 | 130 | . "</div>" |
| 131 | 131 | . "</div></div>" // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
| 132 | - . ($debug?erreur_squelette():'') |
|
| 132 | + . ($debug ?erreur_squelette() : '') |
|
| 133 | 133 | . "</body></html>\n"; |
| 134 | 134 | return f_queue($t); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | -function html_tests_js(){ |
|
| 137 | +function html_tests_js() { |
|
| 138 | 138 | if (_SPIP_AJAX AND !defined('_TESTER_NOSCRIPT')) { |
| 139 | 139 | // pour le pied de page (deja defini si on est validation XML) |
| 140 | 140 | define('_TESTER_NOSCRIPT', |
@@ -147,22 +147,22 @@ discard block |
||
| 147 | 147 | . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | -function info_maj_spip(){ |
|
| 150 | +function info_maj_spip() { |
|
| 151 | 151 | |
| 152 | 152 | $maj = $GLOBALS['meta']['info_maj_spip']; |
| 153 | 153 | if (!$maj) |
| 154 | 154 | return ""; |
| 155 | 155 | |
| 156 | - $maj = explode('|',$maj); |
|
| 156 | + $maj = explode('|', $maj); |
|
| 157 | 157 | // c'est une ancienne notif, on a fait la maj depuis ! |
| 158 | - if ($GLOBALS['spip_version_branche']!==reset($maj)) |
|
| 158 | + if ($GLOBALS['spip_version_branche'] !== reset($maj)) |
|
| 159 | 159 | return ""; |
| 160 | 160 | |
| 161 | 161 | if (!autoriser('webmestre')) |
| 162 | 162 | return ""; |
| 163 | 163 | |
| 164 | 164 | array_shift($maj); |
| 165 | - $maj = implode('|',$maj); |
|
| 165 | + $maj = implode('|', $maj); |
|
| 166 | 166 | |
| 167 | 167 | return "$maj<br />"; |
| 168 | 168 | } |
@@ -177,27 +177,27 @@ discard block |
||
| 177 | 177 | // Mention, le cas echeant, de la revision SVN courante |
| 178 | 178 | // |
| 179 | 179 | if ($svn_revision = version_svn_courante(_DIR_RACINE)) { |
| 180 | - $version .= ' ' . (($svn_revision < 0) ? 'SVN ':'') |
|
| 180 | + $version .= ' '.(($svn_revision < 0) ? 'SVN ' : '') |
|
| 181 | 181 | . "[<a href='http://core.spip.net/projects/spip/repository/revisions/" |
| 182 | - . abs($svn_revision) . "' target=\"_blank\" rel=\"noopener noreferrer\">" |
|
| 183 | - . abs($svn_revision) . "</a>]"; |
|
| 182 | + . abs($svn_revision)."' target=\"_blank\" rel=\"noopener noreferrer\">" |
|
| 183 | + . abs($svn_revision)."</a>]"; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | // et la version de l'ecran de securite |
| 187 | 187 | $secu = defined('_ECRAN_SECURITE') |
| 188 | - ? "<br />"._T('ecran_securite',array('version'=>_ECRAN_SECURITE)) |
|
| 188 | + ? "<br />"._T('ecran_securite', array('version'=>_ECRAN_SECURITE)) |
|
| 189 | 189 | : ''; |
| 190 | 190 | |
| 191 | 191 | return _T('info_copyright', |
| 192 | 192 | array('spip' => "<b>SPIP $version</b> ", |
| 193 | 193 | 'lien_gpl' => |
| 194 | - "<a href='". generer_url_ecrire("aide", "aide=licence&var_lang=$spip_lang") . "' onclick=\"window.open(this.href, 'spip_aide', 'scrollbars=yes,resizable=yes,width=740,height=580'); return false;\">" . _T('info_copyright_gpl')."</a>")) |
|
| 194 | + "<a href='".generer_url_ecrire("aide", "aide=licence&var_lang=$spip_lang")."' onclick=\"window.open(this.href, 'spip_aide', 'scrollbars=yes,resizable=yes,width=740,height=580'); return false;\">"._T('info_copyright_gpl')."</a>")) |
|
| 195 | 195 | . $secu; |
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // http://doc.spip.org/@formulaire_recherche |
| 200 | -function formulaire_recherche($page, $complement=""){ |
|
| 200 | +function formulaire_recherche($page, $complement = "") { |
|
| 201 | 201 | $recherche = _request('recherche'); |
| 202 | 202 | $recherche_aff = entites_html($recherche); |
| 203 | 203 | if (!strlen($recherche)) { |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | $onfocus = " onfocus=\"this.value='';\""; |
| 206 | 206 | } else $onfocus = ''; |
| 207 | 207 | |
| 208 | - $form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 209 | - $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='"._T('info_rechercher')."' />"; |
|
| 210 | - return "<div class='spip_recherche'>".generer_form_ecrire($page, $form . $complement, " method='get'")."</div>"; |
|
| 208 | + $form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"'.$onfocus.' />'; |
|
| 209 | + $form .= "<input type='image' src='".chemin_image('rechercher-20.png')."' name='submit' class='submit' alt='"._T('info_rechercher')."' />"; |
|
| 210 | + return "<div class='spip_recherche'>".generer_form_ecrire($page, $form.$complement, " method='get'")."</div>"; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | ?> |
@@ -17,57 +17,57 @@ |
||
| 17 | 17 | // http://doc.spip.org/@inc_informer_dist |
| 18 | 18 | function inc_informer_dist($id, $col, $exclus, $rac, $type, $do='aff') |
| 19 | 19 | { |
| 20 | - include_spip('inc/texte'); |
|
| 21 | - if ($type == "rubrique") { |
|
| 22 | - $row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = " . intval($id)); |
|
| 23 | - if ($row) { |
|
| 24 | - $titre = typo($row["titre"]); |
|
| 25 | - $descriptif = propre($row["descriptif"]); |
|
| 26 | - } else { |
|
| 27 | - $titre = _T('info_racine_site'); |
|
| 28 | - } |
|
| 29 | - } else |
|
| 30 | - $titre = ''; |
|
| 20 | + include_spip('inc/texte'); |
|
| 21 | + if ($type == "rubrique") { |
|
| 22 | + $row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = " . intval($id)); |
|
| 23 | + if ($row) { |
|
| 24 | + $titre = typo($row["titre"]); |
|
| 25 | + $descriptif = propre($row["descriptif"]); |
|
| 26 | + } else { |
|
| 27 | + $titre = _T('info_racine_site'); |
|
| 28 | + } |
|
| 29 | + } else |
|
| 30 | + $titre = ''; |
|
| 31 | 31 | |
| 32 | - $res = ''; |
|
| 33 | - if ($type == "rubrique" AND $GLOBALS['spip_display'] != 1 AND isset($GLOBALS['meta']['image_process'])) |
|
| 34 | - if ($GLOBALS['meta']['image_process'] != "non") { |
|
| 35 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 36 | - if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 37 | - list($fid, $dir, $nom, $format) = $res; |
|
| 38 | - include_spip('inc/filtres_images_mini'); |
|
| 39 | - $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 40 | - if ($res) |
|
| 41 | - $res = "<div style='float: ".$GLOBALS['spip_lang_right']."; margin-".$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>"; |
|
| 42 | - } |
|
| 43 | - } |
|
| 32 | + $res = ''; |
|
| 33 | + if ($type == "rubrique" AND $GLOBALS['spip_display'] != 1 AND isset($GLOBALS['meta']['image_process'])) |
|
| 34 | + if ($GLOBALS['meta']['image_process'] != "non") { |
|
| 35 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 36 | + if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 37 | + list($fid, $dir, $nom, $format) = $res; |
|
| 38 | + include_spip('inc/filtres_images_mini'); |
|
| 39 | + $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 40 | + if ($res) |
|
| 41 | + $res = "<div style='float: ".$GLOBALS['spip_lang_right']."; margin-".$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>"; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 46 | - $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 47 | - $id = intval($id); |
|
| 45 | + $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 46 | + $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 47 | + $id = intval($id); |
|
| 48 | 48 | |
| 49 | 49 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 50 | 50 | # et l'affichage de son titre dans le bandeau |
| 51 | - $titre = strtr(str_replace("'", "’", |
|
| 52 | - str_replace('"', """, textebrut($titre))), |
|
| 53 | - "\n\r", " "); |
|
| 51 | + $titre = strtr(str_replace("'", "’", |
|
| 52 | + str_replace('"', """, textebrut($titre))), |
|
| 53 | + "\n\r", " "); |
|
| 54 | 54 | |
| 55 | - $js_func = $do . '_selection_titre'; |
|
| 56 | - return "<div style='display: none;'>" |
|
| 57 | - . "<input type='text' id='".$rac."_sel' value='$id' />" |
|
| 58 | - . "<input type='text' id='".$rac."_sel2' value=\"" |
|
| 59 | - . entites_html($titre) |
|
| 60 | - . "\" />" |
|
| 61 | - . "</div>" |
|
| 62 | - . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 63 | - . (!$res ? '' : $res) |
|
| 64 | - . "<p><b>".safehtml($titre)."</b></p>" |
|
| 65 | - . (!$descriptif ? '' : "<div>".safehtml($descriptif)."</div>") |
|
| 66 | - . "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 67 | - . "<input type='submit' class='fondo' value='" |
|
| 68 | - . _T('bouton_choisir') |
|
| 69 | - . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 70 | - . "</div>" |
|
| 71 | - . "</div>"; |
|
| 55 | + $js_func = $do . '_selection_titre'; |
|
| 56 | + return "<div style='display: none;'>" |
|
| 57 | + . "<input type='text' id='".$rac."_sel' value='$id' />" |
|
| 58 | + . "<input type='text' id='".$rac."_sel2' value=\"" |
|
| 59 | + . entites_html($titre) |
|
| 60 | + . "\" />" |
|
| 61 | + . "</div>" |
|
| 62 | + . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 63 | + . (!$res ? '' : $res) |
|
| 64 | + . "<p><b>".safehtml($titre)."</b></p>" |
|
| 65 | + . (!$descriptif ? '' : "<div>".safehtml($descriptif)."</div>") |
|
| 66 | + . "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 67 | + . "<input type='submit' class='fondo' value='" |
|
| 68 | + . _T('bouton_choisir') |
|
| 69 | + . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 70 | + . "</div>" |
|
| 71 | + . "</div>"; |
|
| 72 | 72 | } |
| 73 | 73 | ?> |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | # Les information d'une rubrique selectionnee dans le mini navigateur |
| 16 | 16 | |
| 17 | 17 | // http://doc.spip.org/@inc_informer_dist |
| 18 | -function inc_informer_dist($id, $col, $exclus, $rac, $type, $do='aff') |
|
| 18 | +function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff') |
|
| 19 | 19 | { |
| 20 | 20 | include_spip('inc/texte'); |
| 21 | 21 | if ($type == "rubrique") { |
| 22 | - $row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = " . intval($id)); |
|
| 22 | + $row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = ".intval($id)); |
|
| 23 | 23 | if ($row) { |
| 24 | 24 | $titre = typo($row["titre"]); |
| 25 | 25 | $descriptif = propre($row["descriptif"]); |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | if ($type == "rubrique" AND $GLOBALS['spip_display'] != 1 AND isset($GLOBALS['meta']['image_process'])) |
| 34 | 34 | if ($GLOBALS['meta']['image_process'] != "non") { |
| 35 | 35 | $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
| 36 | - if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 36 | + if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 37 | 37 | list($fid, $dir, $nom, $format) = $res; |
| 38 | 38 | include_spip('inc/filtres_images_mini'); |
| 39 | 39 | $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
| 40 | 40 | if ($res) |
| 41 | - $res = "<div style='float: ".$GLOBALS['spip_lang_right']."; margin-".$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>"; |
|
| 41 | + $res = "<div style='float: ".$GLOBALS['spip_lang_right']."; margin-".$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>"; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | str_replace('"', """, textebrut($titre))), |
| 53 | 53 | "\n\r", " "); |
| 54 | 54 | |
| 55 | - $js_func = $do . '_selection_titre'; |
|
| 55 | + $js_func = $do.'_selection_titre'; |
|
| 56 | 56 | return "<div style='display: none;'>" |
| 57 | 57 | . "<input type='text' id='".$rac."_sel' value='$id' />" |
| 58 | 58 | . "<input type='text' id='".$rac."_sel2' value=\"" |
@@ -22,132 +22,132 @@ discard block |
||
| 22 | 22 | // http://doc.spip.org/@assembler |
| 23 | 23 | function assembler($fond, $connect='') { |
| 24 | 24 | |
| 25 | - // flag_preserver est modifie ici, et utilise en globale |
|
| 26 | - // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
|
| 27 | - // contexte est utilise en globale dans le formulaire d'admin |
|
| 28 | - global $flag_preserver, $use_cache, $contexte; |
|
| 29 | - |
|
| 30 | - $contexte = calculer_contexte(); |
|
| 31 | - $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
|
| 32 | - $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 33 | - // Cette fonction est utilisee deux fois |
|
| 34 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 35 | - // Les quatre derniers parametres sont modifies par la fonction: |
|
| 36 | - // emplacement, validite, et, s'il est valide, contenu & age |
|
| 37 | - if ($cacher) |
|
| 38 | - $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 39 | - else |
|
| 40 | - $use_cache = -1; |
|
| 41 | - // Si un resultat est retourne, c'est un message d'impossibilite |
|
| 42 | - if ($res) {return array('texte' => $res);} |
|
| 43 | - |
|
| 44 | - if (!$chemin_cache || !$lastmodified) $lastmodified = time(); |
|
| 45 | - |
|
| 46 | - $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
|
| 47 | - $calculer_page = true; |
|
| 48 | - |
|
| 49 | - // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) |
|
| 50 | - // une perennite valide a meme reponse qu'une requete HEAD (par defaut les |
|
| 51 | - // pages sont dynamiques) |
|
| 52 | - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 53 | - AND (!defined('_VAR_MODE') OR !_VAR_MODE) |
|
| 54 | - AND $chemin_cache |
|
| 55 | - AND isset($page['entetes']) |
|
| 56 | - AND isset($page['entetes']['Cache-Control']) |
|
| 57 | - AND strstr($page['entetes']['Cache-Control'],'max-age=') |
|
| 58 | - AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/') |
|
| 59 | - ) { |
|
| 60 | - $since = preg_replace('/;.*/', '', |
|
| 61 | - $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
|
| 62 | - $since = str_replace('GMT', '', $since); |
|
| 63 | - if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { |
|
| 64 | - $page['status'] = 304; |
|
| 65 | - $headers_only = true; |
|
| 66 | - $calculer_page = false; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - // Si requete HEAD ou Last-modified compatible, ignorer le texte |
|
| 71 | - // et pas de content-type (pour contrer le bouton admin de inc-public) |
|
| 72 | - if (!$calculer_page) { |
|
| 73 | - $page['texte'] = ""; |
|
| 74 | - } else { |
|
| 75 | - // si la page est prise dans le cache |
|
| 76 | - if (!$use_cache) { |
|
| 77 | - // Informer les boutons d'admin du contexte |
|
| 78 | - // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
|
| 79 | - $contexte = $page['contexte']; |
|
| 80 | - |
|
| 81 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 82 | - // d'inversion url => objet |
|
| 83 | - // plus necessaire si on utilise bien la fonction urls_decoder_url |
|
| 84 | - #unset($_SERVER['REDIRECT_url_propre']); |
|
| 85 | - #unset($_ENV['url_propre']); |
|
| 86 | - } |
|
| 87 | - else { |
|
| 88 | - // Compat ascendante : |
|
| 89 | - // 1. $contexte est global |
|
| 90 | - // (a evacuer car urls_decoder_url gere ce probleme ?) |
|
| 91 | - // et calculer la page |
|
| 92 | - if (!test_espace_prive()) { |
|
| 93 | - include_spip('inc/urls'); |
|
| 94 | - list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true); |
|
| 95 | - } |
|
| 96 | - // squelette par defaut |
|
| 97 | - if (!strlen($fond)) |
|
| 98 | - $fond = 'sommaire'; |
|
| 99 | - |
|
| 100 | - // produire la page : peut mettre a jour $lastmodified |
|
| 101 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 102 | - $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, NULL, $page, $lastmodified, $connect); |
|
| 103 | - if ($page === '') { |
|
| 104 | - $erreur = _T('info_erreur_squelette2', |
|
| 105 | - array('fichier'=>spip_htmlspecialchars($fond).'.'._EXTENSION_SQUELETTES)); |
|
| 106 | - erreur_squelette($erreur); |
|
| 107 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 108 | - $page = array('texte' => '', 'erreur' => $erreur); |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - if ($page AND $chemin_cache) $page['cache'] = $chemin_cache; |
|
| 113 | - |
|
| 114 | - auto_content_type($page); |
|
| 115 | - |
|
| 116 | - $flag_preserver |= headers_sent(); |
|
| 117 | - |
|
| 118 | - // Definir les entetes si ce n'est fait |
|
| 119 | - if (!$flag_preserver) { |
|
| 120 | - if ($GLOBALS['flag_ob']) { |
|
| 121 | - // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions |
|
| 122 | - if (trim($page['texte']) === '' |
|
| 123 | - AND _VAR_MODE != 'debug' |
|
| 124 | - AND !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur |
|
| 125 | - ) { |
|
| 126 | - $contexte['fond_erreur'] = $fond; |
|
| 127 | - $page = message_page_indisponible($page, $contexte); |
|
| 128 | - } |
|
| 129 | - // pas de cache client en mode 'observation' |
|
| 130 | - if (defined('_VAR_MODE') AND _VAR_MODE) { |
|
| 131 | - $page['entetes']["Cache-Control"]= "no-cache,must-revalidate"; |
|
| 132 | - $page['entetes']["Pragma"] = "no-cache"; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - // Entete Last-Modified: |
|
| 139 | - // eviter d'etre incoherent en envoyant un lastmodified identique |
|
| 140 | - // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
|
| 141 | - if ($lastmodified |
|
| 142 | - AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 143 | - AND !isset($page['entetes']["Last-Modified"])) |
|
| 144 | - $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 145 | - |
|
| 146 | - // fermer la connexion apres les headers si requete HEAD |
|
| 147 | - if ($headers_only) |
|
| 148 | - $page['entetes']["Connection"] = "close"; |
|
| 149 | - |
|
| 150 | - return $page; |
|
| 25 | + // flag_preserver est modifie ici, et utilise en globale |
|
| 26 | + // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
|
| 27 | + // contexte est utilise en globale dans le formulaire d'admin |
|
| 28 | + global $flag_preserver, $use_cache, $contexte; |
|
| 29 | + |
|
| 30 | + $contexte = calculer_contexte(); |
|
| 31 | + $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
|
| 32 | + $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 33 | + // Cette fonction est utilisee deux fois |
|
| 34 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 35 | + // Les quatre derniers parametres sont modifies par la fonction: |
|
| 36 | + // emplacement, validite, et, s'il est valide, contenu & age |
|
| 37 | + if ($cacher) |
|
| 38 | + $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 39 | + else |
|
| 40 | + $use_cache = -1; |
|
| 41 | + // Si un resultat est retourne, c'est un message d'impossibilite |
|
| 42 | + if ($res) {return array('texte' => $res);} |
|
| 43 | + |
|
| 44 | + if (!$chemin_cache || !$lastmodified) $lastmodified = time(); |
|
| 45 | + |
|
| 46 | + $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
|
| 47 | + $calculer_page = true; |
|
| 48 | + |
|
| 49 | + // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) |
|
| 50 | + // une perennite valide a meme reponse qu'une requete HEAD (par defaut les |
|
| 51 | + // pages sont dynamiques) |
|
| 52 | + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 53 | + AND (!defined('_VAR_MODE') OR !_VAR_MODE) |
|
| 54 | + AND $chemin_cache |
|
| 55 | + AND isset($page['entetes']) |
|
| 56 | + AND isset($page['entetes']['Cache-Control']) |
|
| 57 | + AND strstr($page['entetes']['Cache-Control'],'max-age=') |
|
| 58 | + AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/') |
|
| 59 | + ) { |
|
| 60 | + $since = preg_replace('/;.*/', '', |
|
| 61 | + $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
|
| 62 | + $since = str_replace('GMT', '', $since); |
|
| 63 | + if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { |
|
| 64 | + $page['status'] = 304; |
|
| 65 | + $headers_only = true; |
|
| 66 | + $calculer_page = false; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + // Si requete HEAD ou Last-modified compatible, ignorer le texte |
|
| 71 | + // et pas de content-type (pour contrer le bouton admin de inc-public) |
|
| 72 | + if (!$calculer_page) { |
|
| 73 | + $page['texte'] = ""; |
|
| 74 | + } else { |
|
| 75 | + // si la page est prise dans le cache |
|
| 76 | + if (!$use_cache) { |
|
| 77 | + // Informer les boutons d'admin du contexte |
|
| 78 | + // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
|
| 79 | + $contexte = $page['contexte']; |
|
| 80 | + |
|
| 81 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 82 | + // d'inversion url => objet |
|
| 83 | + // plus necessaire si on utilise bien la fonction urls_decoder_url |
|
| 84 | + #unset($_SERVER['REDIRECT_url_propre']); |
|
| 85 | + #unset($_ENV['url_propre']); |
|
| 86 | + } |
|
| 87 | + else { |
|
| 88 | + // Compat ascendante : |
|
| 89 | + // 1. $contexte est global |
|
| 90 | + // (a evacuer car urls_decoder_url gere ce probleme ?) |
|
| 91 | + // et calculer la page |
|
| 92 | + if (!test_espace_prive()) { |
|
| 93 | + include_spip('inc/urls'); |
|
| 94 | + list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true); |
|
| 95 | + } |
|
| 96 | + // squelette par defaut |
|
| 97 | + if (!strlen($fond)) |
|
| 98 | + $fond = 'sommaire'; |
|
| 99 | + |
|
| 100 | + // produire la page : peut mettre a jour $lastmodified |
|
| 101 | + $produire_page = charger_fonction('produire_page','public'); |
|
| 102 | + $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, NULL, $page, $lastmodified, $connect); |
|
| 103 | + if ($page === '') { |
|
| 104 | + $erreur = _T('info_erreur_squelette2', |
|
| 105 | + array('fichier'=>spip_htmlspecialchars($fond).'.'._EXTENSION_SQUELETTES)); |
|
| 106 | + erreur_squelette($erreur); |
|
| 107 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 108 | + $page = array('texte' => '', 'erreur' => $erreur); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + if ($page AND $chemin_cache) $page['cache'] = $chemin_cache; |
|
| 113 | + |
|
| 114 | + auto_content_type($page); |
|
| 115 | + |
|
| 116 | + $flag_preserver |= headers_sent(); |
|
| 117 | + |
|
| 118 | + // Definir les entetes si ce n'est fait |
|
| 119 | + if (!$flag_preserver) { |
|
| 120 | + if ($GLOBALS['flag_ob']) { |
|
| 121 | + // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions |
|
| 122 | + if (trim($page['texte']) === '' |
|
| 123 | + AND _VAR_MODE != 'debug' |
|
| 124 | + AND !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur |
|
| 125 | + ) { |
|
| 126 | + $contexte['fond_erreur'] = $fond; |
|
| 127 | + $page = message_page_indisponible($page, $contexte); |
|
| 128 | + } |
|
| 129 | + // pas de cache client en mode 'observation' |
|
| 130 | + if (defined('_VAR_MODE') AND _VAR_MODE) { |
|
| 131 | + $page['entetes']["Cache-Control"]= "no-cache,must-revalidate"; |
|
| 132 | + $page['entetes']["Pragma"] = "no-cache"; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + // Entete Last-Modified: |
|
| 139 | + // eviter d'etre incoherent en envoyant un lastmodified identique |
|
| 140 | + // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
|
| 141 | + if ($lastmodified |
|
| 142 | + AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 143 | + AND !isset($page['entetes']["Last-Modified"])) |
|
| 144 | + $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 145 | + |
|
| 146 | + // fermer la connexion apres les headers si requete HEAD |
|
| 147 | + if ($headers_only) |
|
| 148 | + $page['entetes']["Connection"] = "close"; |
|
| 149 | + |
|
| 150 | + return $page; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // |
@@ -160,17 +160,17 @@ discard block |
||
| 160 | 160 | // http://doc.spip.org/@calculer_contexte |
| 161 | 161 | function calculer_contexte() { |
| 162 | 162 | |
| 163 | - $contexte = array(); |
|
| 164 | - foreach($_GET as $var => $val) { |
|
| 165 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 166 | - $contexte[$var] = $val; |
|
| 167 | - } |
|
| 168 | - foreach($_POST as $var => $val) { |
|
| 169 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 170 | - $contexte[$var] = $val; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return $contexte; |
|
| 163 | + $contexte = array(); |
|
| 164 | + foreach($_GET as $var => $val) { |
|
| 165 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 166 | + $contexte[$var] = $val; |
|
| 167 | + } |
|
| 168 | + foreach($_POST as $var => $val) { |
|
| 169 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 170 | + $contexte[$var] = $val; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return $contexte; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -181,20 +181,20 @@ discard block |
||
| 181 | 181 | * @return array |
| 182 | 182 | */ |
| 183 | 183 | function calculer_contexte_implicite(){ |
| 184 | - static $notes = null; |
|
| 185 | - if (is_null($notes)) |
|
| 186 | - $notes = charger_fonction('notes','inc',true); |
|
| 187 | - $contexte_implicite = array( |
|
| 188 | - 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
|
| 189 | - 'host' => $_SERVER['HTTP_HOST'], |
|
| 190 | - 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''), |
|
| 191 | - 'espace' => test_espace_prive(), |
|
| 192 | - 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 193 | - 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 194 | - 'notes' => $notes?$notes('','contexter_cache'):'', |
|
| 195 | - 'spip_version_code' => $GLOBALS['spip_version_code'], |
|
| 196 | - ); |
|
| 197 | - return $contexte_implicite; |
|
| 184 | + static $notes = null; |
|
| 185 | + if (is_null($notes)) |
|
| 186 | + $notes = charger_fonction('notes','inc',true); |
|
| 187 | + $contexte_implicite = array( |
|
| 188 | + 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
|
| 189 | + 'host' => $_SERVER['HTTP_HOST'], |
|
| 190 | + 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''), |
|
| 191 | + 'espace' => test_espace_prive(), |
|
| 192 | + 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 193 | + 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 194 | + 'notes' => $notes?$notes('','contexter_cache'):'', |
|
| 195 | + 'spip_version_code' => $GLOBALS['spip_version_code'], |
|
| 196 | + ); |
|
| 197 | + return $contexte_implicite; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // |
@@ -204,47 +204,47 @@ discard block |
||
| 204 | 204 | // http://doc.spip.org/@auto_content_type |
| 205 | 205 | function auto_content_type($page) |
| 206 | 206 | { |
| 207 | - global $flag_preserver; |
|
| 208 | - if (!isset($flag_preserver)) |
|
| 209 | - { |
|
| 210 | - $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",$page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 211 | - } |
|
| 207 | + global $flag_preserver; |
|
| 208 | + if (!isset($flag_preserver)) |
|
| 209 | + { |
|
| 210 | + $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",$page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 211 | + } |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // http://doc.spip.org/@inclure_page |
| 215 | 215 | function inclure_page($fond, $contexte, $connect='') { |
| 216 | - static $cacher, $produire_page; |
|
| 217 | - global $lastmodified; |
|
| 218 | - |
|
| 219 | - // enlever le fond de contexte inclus car sinon il prend la main |
|
| 220 | - // dans les sous inclusions -> boucle infinie d'inclusion identique |
|
| 221 | - // (cette precaution n'est probablement plus utile) |
|
| 222 | - unset($contexte['fond']); |
|
| 223 | - $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
|
| 224 | - $page['contexte_implicite']['cache'] = $fond; |
|
| 225 | - if (is_null($cacher)) |
|
| 226 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 227 | - // Les quatre derniers parametres sont modifies par la fonction: |
|
| 228 | - // emplacement, validite, et, s'il est valide, contenu & age |
|
| 229 | - if ($cacher) |
|
| 230 | - $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 231 | - else |
|
| 232 | - $use_cache = -1; |
|
| 233 | - // $res = message d'erreur : on sort de la |
|
| 234 | - if ($res) {return array('texte' => $res);} |
|
| 235 | - |
|
| 236 | - // Si use_cache ne vaut pas 0, la page doit etre calculee |
|
| 237 | - // produire la page : peut mettre a jour $lastinclude |
|
| 238 | - // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
|
| 239 | - if ($use_cache) { |
|
| 240 | - if (is_null($produire_page)) |
|
| 241 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 242 | - $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
|
| 243 | - } |
|
| 244 | - // dans tous les cas, mettre a jour $lastmodified |
|
| 245 | - $lastmodified = max($lastmodified, $lastinclude); |
|
| 246 | - |
|
| 247 | - return $page; |
|
| 216 | + static $cacher, $produire_page; |
|
| 217 | + global $lastmodified; |
|
| 218 | + |
|
| 219 | + // enlever le fond de contexte inclus car sinon il prend la main |
|
| 220 | + // dans les sous inclusions -> boucle infinie d'inclusion identique |
|
| 221 | + // (cette precaution n'est probablement plus utile) |
|
| 222 | + unset($contexte['fond']); |
|
| 223 | + $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
|
| 224 | + $page['contexte_implicite']['cache'] = $fond; |
|
| 225 | + if (is_null($cacher)) |
|
| 226 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 227 | + // Les quatre derniers parametres sont modifies par la fonction: |
|
| 228 | + // emplacement, validite, et, s'il est valide, contenu & age |
|
| 229 | + if ($cacher) |
|
| 230 | + $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 231 | + else |
|
| 232 | + $use_cache = -1; |
|
| 233 | + // $res = message d'erreur : on sort de la |
|
| 234 | + if ($res) {return array('texte' => $res);} |
|
| 235 | + |
|
| 236 | + // Si use_cache ne vaut pas 0, la page doit etre calculee |
|
| 237 | + // produire la page : peut mettre a jour $lastinclude |
|
| 238 | + // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
|
| 239 | + if ($use_cache) { |
|
| 240 | + if (is_null($produire_page)) |
|
| 241 | + $produire_page = charger_fonction('produire_page','public'); |
|
| 242 | + $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
|
| 243 | + } |
|
| 244 | + // dans tous les cas, mettre a jour $lastmodified |
|
| 245 | + $lastmodified = max($lastmodified, $lastinclude); |
|
| 246 | + |
|
| 247 | + return $page; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -262,25 +262,25 @@ discard block |
||
| 262 | 262 | * @return array |
| 263 | 263 | */ |
| 264 | 264 | function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect=''){ |
| 265 | - static $parametrer,$cacher; |
|
| 266 | - if (!$parametrer) |
|
| 267 | - $parametrer = charger_fonction('parametrer', 'public'); |
|
| 268 | - $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
|
| 269 | - // et on l'enregistre sur le disque |
|
| 270 | - if ($chemin_cache |
|
| 271 | - AND $use_cache>-1 |
|
| 272 | - AND is_array($page) |
|
| 273 | - AND count($page) |
|
| 274 | - AND $page['entetes']['X-Spip-Cache'] > 0){ |
|
| 275 | - if (is_null($cacher)) |
|
| 276 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 277 | - $lastinclude = time(); |
|
| 278 | - if ($cacher) |
|
| 279 | - $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 280 | - else |
|
| 281 | - $use_cache = -1; |
|
| 282 | - } |
|
| 283 | - return $page; |
|
| 265 | + static $parametrer,$cacher; |
|
| 266 | + if (!$parametrer) |
|
| 267 | + $parametrer = charger_fonction('parametrer', 'public'); |
|
| 268 | + $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
|
| 269 | + // et on l'enregistre sur le disque |
|
| 270 | + if ($chemin_cache |
|
| 271 | + AND $use_cache>-1 |
|
| 272 | + AND is_array($page) |
|
| 273 | + AND count($page) |
|
| 274 | + AND $page['entetes']['X-Spip-Cache'] > 0){ |
|
| 275 | + if (is_null($cacher)) |
|
| 276 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 277 | + $lastinclude = time(); |
|
| 278 | + if ($cacher) |
|
| 279 | + $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 280 | + else |
|
| 281 | + $use_cache = -1; |
|
| 282 | + } |
|
| 283 | + return $page; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
@@ -296,11 +296,11 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | function inserer_balise_dynamique($contexte_exec, $contexte_compil) |
| 298 | 298 | { |
| 299 | - if (!is_array($contexte_exec)) |
|
| 300 | - echo $contexte_exec; // message d'erreur etc |
|
| 301 | - else { |
|
| 302 | - inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
|
| 303 | - } |
|
| 299 | + if (!is_array($contexte_exec)) |
|
| 300 | + echo $contexte_exec; // message d'erreur etc |
|
| 301 | + else { |
|
| 302 | + inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
|
| 303 | + } |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // Attention, un appel explicite a cette fonction suppose certains include |
@@ -309,204 +309,204 @@ discard block |
||
| 309 | 309 | // http://doc.spip.org/@inclure_balise_dynamique |
| 310 | 310 | function inclure_balise_dynamique($texte, $echo=true, $contexte_compil=array()) |
| 311 | 311 | { |
| 312 | - if (is_array($texte)) { |
|
| 313 | - |
|
| 314 | - list($fond, $delainc, $contexte_inclus) = $texte; |
|
| 315 | - |
|
| 316 | - // delais a l'ancienne, c'est pratiquement mort |
|
| 317 | - $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : NULL; |
|
| 318 | - $GLOBALS['delais'] = $delainc; |
|
| 319 | - |
|
| 320 | - $page = recuperer_fond($fond,$contexte_inclus,array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 321 | - |
|
| 322 | - $texte = $page['texte']; |
|
| 323 | - |
|
| 324 | - $GLOBALS['delais'] = $d; |
|
| 325 | - // Faire remonter les entetes |
|
| 326 | - if (is_array($page['entetes'])) { |
|
| 327 | - // mais pas toutes |
|
| 328 | - unset($page['entetes']['X-Spip-Cache']); |
|
| 329 | - unset($page['entetes']['Content-Type']); |
|
| 330 | - if (isset($GLOBALS['page']) AND is_array($GLOBALS['page'])) { |
|
| 331 | - if (!is_array($GLOBALS['page']['entetes'])) |
|
| 332 | - $GLOBALS['page']['entetes'] = array(); |
|
| 333 | - $GLOBALS['page']['entetes'] = |
|
| 334 | - array_merge($GLOBALS['page']['entetes'],$page['entetes']); |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
|
| 338 | - if (isset($page['contexte']['_pipelines']) |
|
| 339 | - AND is_array($page['contexte']['_pipelines']) |
|
| 340 | - AND count($page['contexte']['_pipelines'])) { |
|
| 341 | - foreach($page['contexte']['_pipelines'] as $pipe=>$args){ |
|
| 342 | - $args['contexte'] = $page['contexte']; |
|
| 343 | - unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
|
| 344 | - $texte = pipeline( |
|
| 345 | - $pipe, |
|
| 346 | - array( |
|
| 347 | - 'data'=>$texte, |
|
| 348 | - 'args'=>$args |
|
| 349 | - ), |
|
| 350 | - false |
|
| 351 | - ); |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') { |
|
| 357 | - // compatibilite : avant on donnait le numero de ligne ou rien. |
|
| 358 | - $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 359 | - $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
|
| 360 | - } |
|
| 361 | - if ($echo) |
|
| 362 | - echo $texte; |
|
| 363 | - else |
|
| 364 | - return $texte; |
|
| 312 | + if (is_array($texte)) { |
|
| 313 | + |
|
| 314 | + list($fond, $delainc, $contexte_inclus) = $texte; |
|
| 315 | + |
|
| 316 | + // delais a l'ancienne, c'est pratiquement mort |
|
| 317 | + $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : NULL; |
|
| 318 | + $GLOBALS['delais'] = $delainc; |
|
| 319 | + |
|
| 320 | + $page = recuperer_fond($fond,$contexte_inclus,array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 321 | + |
|
| 322 | + $texte = $page['texte']; |
|
| 323 | + |
|
| 324 | + $GLOBALS['delais'] = $d; |
|
| 325 | + // Faire remonter les entetes |
|
| 326 | + if (is_array($page['entetes'])) { |
|
| 327 | + // mais pas toutes |
|
| 328 | + unset($page['entetes']['X-Spip-Cache']); |
|
| 329 | + unset($page['entetes']['Content-Type']); |
|
| 330 | + if (isset($GLOBALS['page']) AND is_array($GLOBALS['page'])) { |
|
| 331 | + if (!is_array($GLOBALS['page']['entetes'])) |
|
| 332 | + $GLOBALS['page']['entetes'] = array(); |
|
| 333 | + $GLOBALS['page']['entetes'] = |
|
| 334 | + array_merge($GLOBALS['page']['entetes'],$page['entetes']); |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
|
| 338 | + if (isset($page['contexte']['_pipelines']) |
|
| 339 | + AND is_array($page['contexte']['_pipelines']) |
|
| 340 | + AND count($page['contexte']['_pipelines'])) { |
|
| 341 | + foreach($page['contexte']['_pipelines'] as $pipe=>$args){ |
|
| 342 | + $args['contexte'] = $page['contexte']; |
|
| 343 | + unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
|
| 344 | + $texte = pipeline( |
|
| 345 | + $pipe, |
|
| 346 | + array( |
|
| 347 | + 'data'=>$texte, |
|
| 348 | + 'args'=>$args |
|
| 349 | + ), |
|
| 350 | + false |
|
| 351 | + ); |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') { |
|
| 357 | + // compatibilite : avant on donnait le numero de ligne ou rien. |
|
| 358 | + $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 359 | + $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
|
| 360 | + } |
|
| 361 | + if ($echo) |
|
| 362 | + echo $texte; |
|
| 363 | + else |
|
| 364 | + return $texte; |
|
| 365 | 365 | |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // http://doc.spip.org/@message_page_indisponible |
| 369 | 369 | function message_page_indisponible ($page, $contexte) { |
| 370 | - static $deja = false; |
|
| 371 | - if ($deja) return "erreur"; |
|
| 372 | - $codes = array( |
|
| 373 | - '404' => '404 Not Found', |
|
| 374 | - '503' => '503 Service Unavailable', |
|
| 375 | - ); |
|
| 376 | - |
|
| 377 | - $contexte['status'] = ($page !== false) ? '404' : '503'; |
|
| 378 | - $contexte['code'] = $codes[$contexte['status']]; |
|
| 379 | - $contexte['fond'] = '404'; // gere les 2 erreurs |
|
| 380 | - if (!isset($contexte['lang'])) |
|
| 381 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 382 | - |
|
| 383 | - $deja = true; |
|
| 384 | - // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
|
| 385 | - // ex restriction d'acces => 401 |
|
| 386 | - $contexte = pipeline('page_indisponible',$contexte); |
|
| 387 | - |
|
| 388 | - // produire la page d'erreur |
|
| 389 | - $page = inclure_page($contexte['fond'], $contexte); |
|
| 390 | - if (!$page) |
|
| 391 | - $page = inclure_page('404', $contexte); |
|
| 392 | - $page['status'] = $contexte['status']; |
|
| 393 | - |
|
| 394 | - return $page; |
|
| 370 | + static $deja = false; |
|
| 371 | + if ($deja) return "erreur"; |
|
| 372 | + $codes = array( |
|
| 373 | + '404' => '404 Not Found', |
|
| 374 | + '503' => '503 Service Unavailable', |
|
| 375 | + ); |
|
| 376 | + |
|
| 377 | + $contexte['status'] = ($page !== false) ? '404' : '503'; |
|
| 378 | + $contexte['code'] = $codes[$contexte['status']]; |
|
| 379 | + $contexte['fond'] = '404'; // gere les 2 erreurs |
|
| 380 | + if (!isset($contexte['lang'])) |
|
| 381 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 382 | + |
|
| 383 | + $deja = true; |
|
| 384 | + // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
|
| 385 | + // ex restriction d'acces => 401 |
|
| 386 | + $contexte = pipeline('page_indisponible',$contexte); |
|
| 387 | + |
|
| 388 | + // produire la page d'erreur |
|
| 389 | + $page = inclure_page($contexte['fond'], $contexte); |
|
| 390 | + if (!$page) |
|
| 391 | + $page = inclure_page('404', $contexte); |
|
| 392 | + $page['status'] = $contexte['status']; |
|
| 393 | + |
|
| 394 | + return $page; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | // temporairement ici : a mettre dans le futur inc/modeles |
| 398 | 398 | // creer_contexte_de_modele('left', 'autostart=true', ...) renvoie un array() |
| 399 | 399 | // http://doc.spip.org/@creer_contexte_de_modele |
| 400 | 400 | function creer_contexte_de_modele($args) { |
| 401 | - $contexte = array(); |
|
| 402 | - foreach ($args as $var=>$val) { |
|
| 403 | - if (is_int($var)){ // argument pas formate |
|
| 404 | - if (in_array($val, array('left', 'right', 'center'))) { |
|
| 405 | - $var = 'align'; |
|
| 406 | - $contexte[$var] = $val; |
|
| 407 | - } else { |
|
| 408 | - $args = explode('=', $val); |
|
| 409 | - if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | - $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); |
|
| 411 | - else // notation abregee |
|
| 412 | - $contexte[trim($val)] = trim($val); |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - else |
|
| 416 | - $contexte[$var] = $val; |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - return $contexte; |
|
| 401 | + $contexte = array(); |
|
| 402 | + foreach ($args as $var=>$val) { |
|
| 403 | + if (is_int($var)){ // argument pas formate |
|
| 404 | + if (in_array($val, array('left', 'right', 'center'))) { |
|
| 405 | + $var = 'align'; |
|
| 406 | + $contexte[$var] = $val; |
|
| 407 | + } else { |
|
| 408 | + $args = explode('=', $val); |
|
| 409 | + if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | + $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); |
|
| 411 | + else // notation abregee |
|
| 412 | + $contexte[trim($val)] = trim($val); |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + else |
|
| 416 | + $contexte[$var] = $val; |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + return $contexte; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // Calcule le modele et retourne la mini-page ainsi calculee |
| 423 | 423 | // http://doc.spip.org/@inclure_modele |
| 424 | 424 | function inclure_modele($type, $id, $params, $lien, $connect='', $env=array()) { |
| 425 | 425 | |
| 426 | - static $compteur; |
|
| 427 | - if (++$compteur>10) return ''; # ne pas boucler indefiniment |
|
| 428 | - |
|
| 429 | - $type = strtolower($type); |
|
| 430 | - |
|
| 431 | - $fond = $class = ''; |
|
| 432 | - |
|
| 433 | - $params = array_filter(explode('|', $params)); |
|
| 434 | - if ($params) { |
|
| 435 | - list(,$soustype) = each($params); |
|
| 436 | - $soustype = strtolower(trim($soustype)); |
|
| 437 | - if (in_array($soustype, |
|
| 438 | - array('left', 'right', 'center', 'ajax'))) { |
|
| 439 | - list(,$soustype) = each($params); |
|
| 440 | - $soustype = strtolower($soustype); |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
|
| 444 | - if (!trouve_modele($fond = ($type.'_'.$soustype))) { |
|
| 445 | - $fond = ''; |
|
| 446 | - $class = $soustype; |
|
| 447 | - } |
|
| 448 | - // enlever le sous type des params |
|
| 449 | - $params = array_diff($params,array($soustype)); |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - // Si ca marche pas en precisant le sous-type, prendre le type |
|
| 454 | - if (!$fond AND !trouve_modele($fond = $type)){ |
|
| 455 | - spip_log("Modele $type introuvable",_LOG_INFO_IMPORTANTE); |
|
| 456 | - return false; |
|
| 457 | - } |
|
| 458 | - $fond = 'modeles/'.$fond; |
|
| 459 | - // Creer le contexte |
|
| 460 | - $contexte = $env; |
|
| 461 | - $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
|
| 462 | - |
|
| 463 | - // Le numero du modele est mis dans l'environnement |
|
| 464 | - // d'une part sous l'identifiant "id" |
|
| 465 | - // et d'autre part sous l'identifiant de la cle primaire |
|
| 466 | - // par la fonction id_table_objet, |
|
| 467 | - // (<article1> =>> article =>> id_article =>> id_article=1) |
|
| 468 | - $_id = id_table_objet($type); |
|
| 469 | - $contexte['id'] = $contexte[$_id] = $id; |
|
| 470 | - |
|
| 471 | - if (isset($class)) |
|
| 472 | - $contexte['class'] = $class; |
|
| 473 | - |
|
| 474 | - // Si un lien a ete passe en parametre, ex: [<modele1>->url] |
|
| 475 | - if ($lien) { |
|
| 476 | - # un eventuel guillemet (") sera reechappe par #ENV |
|
| 477 | - $contexte['lien'] = str_replace(""",'"', $lien['href']); |
|
| 478 | - $contexte['lien_class'] = $lien['class']; |
|
| 479 | - $contexte['lien_mime'] = $lien['mime']; |
|
| 480 | - $contexte['lien_title'] = $lien['title']; |
|
| 481 | - $contexte['lien_hreflang'] = $lien['hreflang']; |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - // Traiter les parametres |
|
| 485 | - // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
|
| 486 | - $arg_list = creer_contexte_de_modele($params); |
|
| 487 | - $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
|
| 488 | - $contexte = array_merge($contexte,$arg_list); |
|
| 489 | - |
|
| 490 | - |
|
| 491 | - // Appliquer le modele avec le contexte |
|
| 492 | - $retour = recuperer_fond($fond, $contexte, array(), $connect); |
|
| 493 | - |
|
| 494 | - |
|
| 495 | - // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
|
| 496 | - // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
|
| 497 | - // sinon, s'il y a un lien, on l'ajoute classiquement |
|
| 498 | - if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')).' ', |
|
| 499 | - 'spip_lien_ok')) { |
|
| 500 | - $retour = inserer_attribut($retour, 'class', |
|
| 501 | - trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
|
| 502 | - } else if ($lien) |
|
| 503 | - $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 504 | - |
|
| 505 | - $compteur--; |
|
| 506 | - |
|
| 507 | - return (isset($arg_list['ajax'])AND $arg_list['ajax']=='ajax') |
|
| 508 | - ? encoder_contexte_ajax($contexte,'',$retour) |
|
| 509 | - : $retour; |
|
| 426 | + static $compteur; |
|
| 427 | + if (++$compteur>10) return ''; # ne pas boucler indefiniment |
|
| 428 | + |
|
| 429 | + $type = strtolower($type); |
|
| 430 | + |
|
| 431 | + $fond = $class = ''; |
|
| 432 | + |
|
| 433 | + $params = array_filter(explode('|', $params)); |
|
| 434 | + if ($params) { |
|
| 435 | + list(,$soustype) = each($params); |
|
| 436 | + $soustype = strtolower(trim($soustype)); |
|
| 437 | + if (in_array($soustype, |
|
| 438 | + array('left', 'right', 'center', 'ajax'))) { |
|
| 439 | + list(,$soustype) = each($params); |
|
| 440 | + $soustype = strtolower($soustype); |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
|
| 444 | + if (!trouve_modele($fond = ($type.'_'.$soustype))) { |
|
| 445 | + $fond = ''; |
|
| 446 | + $class = $soustype; |
|
| 447 | + } |
|
| 448 | + // enlever le sous type des params |
|
| 449 | + $params = array_diff($params,array($soustype)); |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + // Si ca marche pas en precisant le sous-type, prendre le type |
|
| 454 | + if (!$fond AND !trouve_modele($fond = $type)){ |
|
| 455 | + spip_log("Modele $type introuvable",_LOG_INFO_IMPORTANTE); |
|
| 456 | + return false; |
|
| 457 | + } |
|
| 458 | + $fond = 'modeles/'.$fond; |
|
| 459 | + // Creer le contexte |
|
| 460 | + $contexte = $env; |
|
| 461 | + $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
|
| 462 | + |
|
| 463 | + // Le numero du modele est mis dans l'environnement |
|
| 464 | + // d'une part sous l'identifiant "id" |
|
| 465 | + // et d'autre part sous l'identifiant de la cle primaire |
|
| 466 | + // par la fonction id_table_objet, |
|
| 467 | + // (<article1> =>> article =>> id_article =>> id_article=1) |
|
| 468 | + $_id = id_table_objet($type); |
|
| 469 | + $contexte['id'] = $contexte[$_id] = $id; |
|
| 470 | + |
|
| 471 | + if (isset($class)) |
|
| 472 | + $contexte['class'] = $class; |
|
| 473 | + |
|
| 474 | + // Si un lien a ete passe en parametre, ex: [<modele1>->url] |
|
| 475 | + if ($lien) { |
|
| 476 | + # un eventuel guillemet (") sera reechappe par #ENV |
|
| 477 | + $contexte['lien'] = str_replace(""",'"', $lien['href']); |
|
| 478 | + $contexte['lien_class'] = $lien['class']; |
|
| 479 | + $contexte['lien_mime'] = $lien['mime']; |
|
| 480 | + $contexte['lien_title'] = $lien['title']; |
|
| 481 | + $contexte['lien_hreflang'] = $lien['hreflang']; |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + // Traiter les parametres |
|
| 485 | + // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
|
| 486 | + $arg_list = creer_contexte_de_modele($params); |
|
| 487 | + $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
|
| 488 | + $contexte = array_merge($contexte,$arg_list); |
|
| 489 | + |
|
| 490 | + |
|
| 491 | + // Appliquer le modele avec le contexte |
|
| 492 | + $retour = recuperer_fond($fond, $contexte, array(), $connect); |
|
| 493 | + |
|
| 494 | + |
|
| 495 | + // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
|
| 496 | + // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
|
| 497 | + // sinon, s'il y a un lien, on l'ajoute classiquement |
|
| 498 | + if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')).' ', |
|
| 499 | + 'spip_lien_ok')) { |
|
| 500 | + $retour = inserer_attribut($retour, 'class', |
|
| 501 | + trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
|
| 502 | + } else if ($lien) |
|
| 503 | + $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 504 | + |
|
| 505 | + $compteur--; |
|
| 506 | + |
|
| 507 | + return (isset($arg_list['ajax'])AND $arg_list['ajax']=='ajax') |
|
| 508 | + ? encoder_contexte_ajax($contexte,'',$retour) |
|
| 509 | + : $retour; |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | // Un inclure_page qui marche aussi pour l'espace prive |
@@ -516,81 +516,81 @@ discard block |
||
| 516 | 516 | // http://doc.spip.org/@evaluer_fond |
| 517 | 517 | function evaluer_fond ($fond, $contexte=array(), $connect=null) { |
| 518 | 518 | |
| 519 | - $page = inclure_page($fond, $contexte, $connect); |
|
| 519 | + $page = inclure_page($fond, $contexte, $connect); |
|
| 520 | 520 | |
| 521 | - if (!$page) return $page; |
|
| 522 | - // eval $page et affecte $res |
|
| 523 | - include _ROOT_RESTREINT."public/evaluer_page.php"; |
|
| 521 | + if (!$page) return $page; |
|
| 522 | + // eval $page et affecte $res |
|
| 523 | + include _ROOT_RESTREINT."public/evaluer_page.php"; |
|
| 524 | 524 | |
| 525 | - // Lever un drapeau (global) si le fond utilise #SESSION |
|
| 526 | - // a destination de public/parametrer |
|
| 527 | - // pour remonter vers les inclusions appelantes |
|
| 528 | - // il faut bien lever ce drapeau apres avoir evalue le fond |
|
| 529 | - // pour ne pas faire descendre le flag vers les inclusions appelees |
|
| 530 | - if (isset($page['invalideurs']) |
|
| 531 | - AND isset($page['invalideurs']['session'])) |
|
| 532 | - $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 533 | - |
|
| 534 | - return $page; |
|
| 525 | + // Lever un drapeau (global) si le fond utilise #SESSION |
|
| 526 | + // a destination de public/parametrer |
|
| 527 | + // pour remonter vers les inclusions appelantes |
|
| 528 | + // il faut bien lever ce drapeau apres avoir evalue le fond |
|
| 529 | + // pour ne pas faire descendre le flag vers les inclusions appelees |
|
| 530 | + if (isset($page['invalideurs']) |
|
| 531 | + AND isset($page['invalideurs']['session'])) |
|
| 532 | + $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 533 | + |
|
| 534 | + return $page; |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
| 538 | 538 | // http://doc.spip.org/@page_base_href |
| 539 | 539 | function page_base_href(&$texte){ |
| 540 | - static $set_html_base = null; |
|
| 541 | - if (is_null($set_html_base)){ |
|
| 542 | - if (!defined('_SET_HTML_BASE')) |
|
| 543 | - // si la profondeur est superieure a 1 |
|
| 544 | - // est que ce n'est pas une url page ni une url action |
|
| 545 | - // activer par defaut |
|
| 546 | - $set_html_base = (( |
|
| 547 | - $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) |
|
| 548 | - AND _request(_SPIP_PAGE) !== 'login' |
|
| 549 | - AND !_request('action'))?true:false); |
|
| 550 | - else |
|
| 551 | - $set_html_base = _SET_HTML_BASE; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - if ($set_html_base |
|
| 555 | - AND isset($GLOBALS['html']) AND $GLOBALS['html'] |
|
| 556 | - AND $GLOBALS['profondeur_url']>0 |
|
| 557 | - AND ($poshead = strpos($texte,'</head>'))!==FALSE){ |
|
| 558 | - $head = substr($texte,0,$poshead); |
|
| 559 | - $insert = false; |
|
| 560 | - if (strpos($head, '<base')===false) |
|
| 561 | - $insert = true; |
|
| 562 | - else { |
|
| 563 | - // si aucun <base ...> n'a de href c'est bon quand meme ! |
|
| 564 | - $insert = true; |
|
| 565 | - include_spip('inc/filtres'); |
|
| 566 | - $bases = extraire_balises($head,'base'); |
|
| 567 | - foreach ($bases as $base) |
|
| 568 | - if (extraire_attribut($base,'href')) |
|
| 569 | - $insert = false; |
|
| 570 | - } |
|
| 571 | - if ($insert) { |
|
| 572 | - include_spip('inc/filtres_mini'); |
|
| 573 | - // ajouter un base qui reglera tous les liens relatifs |
|
| 574 | - $base = url_absolue('./'); |
|
| 575 | - $bbase = "\n<base href=\"$base\" />"; |
|
| 576 | - if (($pos = strpos($head, '<head>')) !== false) |
|
| 577 | - $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 578 | - elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 579 | - $head = str_replace($r[0], $r[0].$bbase, $head); |
|
| 580 | - } |
|
| 581 | - $texte = $head . substr($texte,$poshead); |
|
| 582 | - // gerer les ancres |
|
| 583 | - $base = $_SERVER['REQUEST_URI']; |
|
| 584 | - // pas de guillemets ni < dans l'URL qu'on insere dans le HTML |
|
| 585 | - if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { |
|
| 586 | - $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); |
|
| 587 | - } |
|
| 588 | - if (strpos($texte,"href='#")!==false) |
|
| 589 | - $texte = str_replace("href='#","href='$base#",$texte); |
|
| 590 | - if (strpos($texte, "href=\"#")!==false) |
|
| 591 | - $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 592 | - } |
|
| 593 | - } |
|
| 540 | + static $set_html_base = null; |
|
| 541 | + if (is_null($set_html_base)){ |
|
| 542 | + if (!defined('_SET_HTML_BASE')) |
|
| 543 | + // si la profondeur est superieure a 1 |
|
| 544 | + // est que ce n'est pas une url page ni une url action |
|
| 545 | + // activer par defaut |
|
| 546 | + $set_html_base = (( |
|
| 547 | + $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) |
|
| 548 | + AND _request(_SPIP_PAGE) !== 'login' |
|
| 549 | + AND !_request('action'))?true:false); |
|
| 550 | + else |
|
| 551 | + $set_html_base = _SET_HTML_BASE; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + if ($set_html_base |
|
| 555 | + AND isset($GLOBALS['html']) AND $GLOBALS['html'] |
|
| 556 | + AND $GLOBALS['profondeur_url']>0 |
|
| 557 | + AND ($poshead = strpos($texte,'</head>'))!==FALSE){ |
|
| 558 | + $head = substr($texte,0,$poshead); |
|
| 559 | + $insert = false; |
|
| 560 | + if (strpos($head, '<base')===false) |
|
| 561 | + $insert = true; |
|
| 562 | + else { |
|
| 563 | + // si aucun <base ...> n'a de href c'est bon quand meme ! |
|
| 564 | + $insert = true; |
|
| 565 | + include_spip('inc/filtres'); |
|
| 566 | + $bases = extraire_balises($head,'base'); |
|
| 567 | + foreach ($bases as $base) |
|
| 568 | + if (extraire_attribut($base,'href')) |
|
| 569 | + $insert = false; |
|
| 570 | + } |
|
| 571 | + if ($insert) { |
|
| 572 | + include_spip('inc/filtres_mini'); |
|
| 573 | + // ajouter un base qui reglera tous les liens relatifs |
|
| 574 | + $base = url_absolue('./'); |
|
| 575 | + $bbase = "\n<base href=\"$base\" />"; |
|
| 576 | + if (($pos = strpos($head, '<head>')) !== false) |
|
| 577 | + $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 578 | + elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 579 | + $head = str_replace($r[0], $r[0].$bbase, $head); |
|
| 580 | + } |
|
| 581 | + $texte = $head . substr($texte,$poshead); |
|
| 582 | + // gerer les ancres |
|
| 583 | + $base = $_SERVER['REQUEST_URI']; |
|
| 584 | + // pas de guillemets ni < dans l'URL qu'on insere dans le HTML |
|
| 585 | + if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { |
|
| 586 | + $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); |
|
| 587 | + } |
|
| 588 | + if (strpos($texte,"href='#")!==false) |
|
| 589 | + $texte = str_replace("href='#","href='$base#",$texte); |
|
| 590 | + if (strpos($texte, "href=\"#")!==false) |
|
| 591 | + $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 592 | + } |
|
| 593 | + } |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | |
@@ -598,9 +598,9 @@ discard block |
||
| 598 | 598 | // et demarrent par X-Spip-... |
| 599 | 599 | // http://doc.spip.org/@envoyer_entetes |
| 600 | 600 | function envoyer_entetes($entetes) { |
| 601 | - foreach ($entetes as $k => $v) |
|
| 602 | - # if (strncmp($k, 'X-Spip-', 7)) |
|
| 603 | - @header(strlen($v)?"$k: $v":$k); |
|
| 601 | + foreach ($entetes as $k => $v) |
|
| 602 | + # if (strncmp($k, 'X-Spip-', 7)) |
|
| 603 | + @header(strlen($v)?"$k: $v":$k); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | ?> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | // |
| 21 | 21 | |
| 22 | 22 | // http://doc.spip.org/@assembler |
| 23 | -function assembler($fond, $connect='') { |
|
| 23 | +function assembler($fond, $connect = '') { |
|
| 24 | 24 | |
| 25 | 25 | // flag_preserver est modifie ici, et utilise en globale |
| 26 | 26 | // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $contexte = calculer_contexte(); |
| 31 | 31 | $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
| 32 | - $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 32 | + $page['contexte_implicite']['cache'] = $fond.preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 33 | 33 | // Cette fonction est utilisee deux fois |
| 34 | 34 | $cacher = charger_fonction('cacher', 'public', true); |
| 35 | 35 | // Les quatre derniers parametres sont modifies par la fonction: |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | else |
| 40 | 40 | $use_cache = -1; |
| 41 | 41 | // Si un resultat est retourne, c'est un message d'impossibilite |
| 42 | - if ($res) {return array('texte' => $res);} |
|
| 42 | + if ($res) {return array('texte' => $res); } |
|
| 43 | 43 | |
| 44 | 44 | if (!$chemin_cache || !$lastmodified) $lastmodified = time(); |
| 45 | 45 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | AND $chemin_cache |
| 55 | 55 | AND isset($page['entetes']) |
| 56 | 56 | AND isset($page['entetes']['Cache-Control']) |
| 57 | - AND strstr($page['entetes']['Cache-Control'],'max-age=') |
|
| 58 | - AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/') |
|
| 57 | + AND strstr($page['entetes']['Cache-Control'], 'max-age=') |
|
| 58 | + AND !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 59 | 59 | ) { |
| 60 | 60 | $since = preg_replace('/;.*/', '', |
| 61 | 61 | $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $page['texte'] = ""; |
| 74 | 74 | } else { |
| 75 | 75 | // si la page est prise dans le cache |
| 76 | - if (!$use_cache) { |
|
| 76 | + if (!$use_cache) { |
|
| 77 | 77 | // Informer les boutons d'admin du contexte |
| 78 | 78 | // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
| 79 | 79 | $contexte = $page['contexte']; |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | // et calculer la page |
| 92 | 92 | if (!test_espace_prive()) { |
| 93 | 93 | include_spip('inc/urls'); |
| 94 | - list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true); |
|
| 94 | + list($fond, $contexte, $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $contexte, true); |
|
| 95 | 95 | } |
| 96 | 96 | // squelette par defaut |
| 97 | 97 | if (!strlen($fond)) |
| 98 | 98 | $fond = 'sommaire'; |
| 99 | 99 | |
| 100 | 100 | // produire la page : peut mettre a jour $lastmodified |
| 101 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 101 | + $produire_page = charger_fonction('produire_page', 'public'); |
|
| 102 | 102 | $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, NULL, $page, $lastmodified, $connect); |
| 103 | 103 | if ($page === '') { |
| 104 | 104 | $erreur = _T('info_erreur_squelette2', |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | auto_content_type($page); |
| 115 | 115 | |
| 116 | - $flag_preserver |= headers_sent(); |
|
| 116 | + $flag_preserver |= headers_sent(); |
|
| 117 | 117 | |
| 118 | 118 | // Definir les entetes si ce n'est fait |
| 119 | 119 | if (!$flag_preserver) { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | // pas de cache client en mode 'observation' |
| 130 | 130 | if (defined('_VAR_MODE') AND _VAR_MODE) { |
| 131 | - $page['entetes']["Cache-Control"]= "no-cache,must-revalidate"; |
|
| 131 | + $page['entetes']["Cache-Control"] = "no-cache,must-revalidate"; |
|
| 132 | 132 | $page['entetes']["Pragma"] = "no-cache"; |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | if ($lastmodified |
| 142 | 142 | AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
| 143 | 143 | AND !isset($page['entetes']["Last-Modified"])) |
| 144 | - $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 144 | + $page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 145 | 145 | |
| 146 | 146 | // fermer la connexion apres les headers si requete HEAD |
| 147 | 147 | if ($headers_only) |
@@ -161,12 +161,12 @@ discard block |
||
| 161 | 161 | function calculer_contexte() { |
| 162 | 162 | |
| 163 | 163 | $contexte = array(); |
| 164 | - foreach($_GET as $var => $val) { |
|
| 165 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 164 | + foreach ($_GET as $var => $val) { |
|
| 165 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) |
|
| 166 | 166 | $contexte[$var] = $val; |
| 167 | 167 | } |
| 168 | - foreach($_POST as $var => $val) { |
|
| 169 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 168 | + foreach ($_POST as $var => $val) { |
|
| 169 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) |
|
| 170 | 170 | $contexte[$var] = $val; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -180,18 +180,18 @@ discard block |
||
| 180 | 180 | * @staticvar string $notes |
| 181 | 181 | * @return array |
| 182 | 182 | */ |
| 183 | -function calculer_contexte_implicite(){ |
|
| 183 | +function calculer_contexte_implicite() { |
|
| 184 | 184 | static $notes = null; |
| 185 | 185 | if (is_null($notes)) |
| 186 | - $notes = charger_fonction('notes','inc',true); |
|
| 186 | + $notes = charger_fonction('notes', 'inc', true); |
|
| 187 | 187 | $contexte_implicite = array( |
| 188 | 188 | 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
| 189 | 189 | 'host' => $_SERVER['HTTP_HOST'], |
| 190 | 190 | 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''), |
| 191 | 191 | 'espace' => test_espace_prive(), |
| 192 | - 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 193 | - 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 194 | - 'notes' => $notes?$notes('','contexter_cache'):'', |
|
| 192 | + 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 193 | + 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 194 | + 'notes' => $notes ? $notes('', 'contexter_cache') : '', |
|
| 195 | 195 | 'spip_version_code' => $GLOBALS['spip_version_code'], |
| 196 | 196 | ); |
| 197 | 197 | return $contexte_implicite; |
@@ -207,12 +207,12 @@ discard block |
||
| 207 | 207 | global $flag_preserver; |
| 208 | 208 | if (!isset($flag_preserver)) |
| 209 | 209 | { |
| 210 | - $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",$page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 210 | + $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx", $page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // http://doc.spip.org/@inclure_page |
| 215 | -function inclure_page($fond, $contexte, $connect='') { |
|
| 215 | +function inclure_page($fond, $contexte, $connect = '') { |
|
| 216 | 216 | static $cacher, $produire_page; |
| 217 | 217 | global $lastmodified; |
| 218 | 218 | |
@@ -231,14 +231,14 @@ discard block |
||
| 231 | 231 | else |
| 232 | 232 | $use_cache = -1; |
| 233 | 233 | // $res = message d'erreur : on sort de la |
| 234 | - if ($res) {return array('texte' => $res);} |
|
| 234 | + if ($res) {return array('texte' => $res); } |
|
| 235 | 235 | |
| 236 | 236 | // Si use_cache ne vaut pas 0, la page doit etre calculee |
| 237 | 237 | // produire la page : peut mettre a jour $lastinclude |
| 238 | 238 | // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
| 239 | 239 | if ($use_cache) { |
| 240 | 240 | if (is_null($produire_page)) |
| 241 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 241 | + $produire_page = charger_fonction('produire_page', 'public'); |
|
| 242 | 242 | $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
| 243 | 243 | } |
| 244 | 244 | // dans tous les cas, mettre a jour $lastmodified |
@@ -261,17 +261,17 @@ discard block |
||
| 261 | 261 | * @param string $connect |
| 262 | 262 | * @return array |
| 263 | 263 | */ |
| 264 | -function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect=''){ |
|
| 265 | - static $parametrer,$cacher; |
|
| 264 | +function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect = '') { |
|
| 265 | + static $parametrer, $cacher; |
|
| 266 | 266 | if (!$parametrer) |
| 267 | 267 | $parametrer = charger_fonction('parametrer', 'public'); |
| 268 | 268 | $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
| 269 | 269 | // et on l'enregistre sur le disque |
| 270 | 270 | if ($chemin_cache |
| 271 | - AND $use_cache>-1 |
|
| 271 | + AND $use_cache > -1 |
|
| 272 | 272 | AND is_array($page) |
| 273 | 273 | AND count($page) |
| 274 | - AND $page['entetes']['X-Spip-Cache'] > 0){ |
|
| 274 | + AND $page['entetes']['X-Spip-Cache'] > 0) { |
|
| 275 | 275 | if (is_null($cacher)) |
| 276 | 276 | $cacher = charger_fonction('cacher', 'public', true); |
| 277 | 277 | $lastinclude = time(); |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | // $echo = faut-il faire echo ou return |
| 308 | 308 | |
| 309 | 309 | // http://doc.spip.org/@inclure_balise_dynamique |
| 310 | -function inclure_balise_dynamique($texte, $echo=true, $contexte_compil=array()) |
|
| 310 | +function inclure_balise_dynamique($texte, $echo = true, $contexte_compil = array()) |
|
| 311 | 311 | { |
| 312 | 312 | if (is_array($texte)) { |
| 313 | 313 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : NULL; |
| 318 | 318 | $GLOBALS['delais'] = $delainc; |
| 319 | 319 | |
| 320 | - $page = recuperer_fond($fond,$contexte_inclus,array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 320 | + $page = recuperer_fond($fond, $contexte_inclus, array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 321 | 321 | |
| 322 | 322 | $texte = $page['texte']; |
| 323 | 323 | |
@@ -331,14 +331,14 @@ discard block |
||
| 331 | 331 | if (!is_array($GLOBALS['page']['entetes'])) |
| 332 | 332 | $GLOBALS['page']['entetes'] = array(); |
| 333 | 333 | $GLOBALS['page']['entetes'] = |
| 334 | - array_merge($GLOBALS['page']['entetes'],$page['entetes']); |
|
| 334 | + array_merge($GLOBALS['page']['entetes'], $page['entetes']); |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
| 338 | 338 | if (isset($page['contexte']['_pipelines']) |
| 339 | 339 | AND is_array($page['contexte']['_pipelines']) |
| 340 | 340 | AND count($page['contexte']['_pipelines'])) { |
| 341 | - foreach($page['contexte']['_pipelines'] as $pipe=>$args){ |
|
| 341 | + foreach ($page['contexte']['_pipelines'] as $pipe=>$args) { |
|
| 342 | 342 | $args['contexte'] = $page['contexte']; |
| 343 | 343 | unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
| 344 | 344 | $texte = pipeline( |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') { |
| 357 | 357 | // compatibilite : avant on donnait le numero de ligne ou rien. |
| 358 | - $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 358 | + $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 359 | 359 | $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
| 360 | 360 | } |
| 361 | 361 | if ($echo) |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // http://doc.spip.org/@message_page_indisponible |
| 369 | -function message_page_indisponible ($page, $contexte) { |
|
| 369 | +function message_page_indisponible($page, $contexte) { |
|
| 370 | 370 | static $deja = false; |
| 371 | 371 | if ($deja) return "erreur"; |
| 372 | 372 | $codes = array( |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | $deja = true; |
| 384 | 384 | // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
| 385 | 385 | // ex restriction d'acces => 401 |
| 386 | - $contexte = pipeline('page_indisponible',$contexte); |
|
| 386 | + $contexte = pipeline('page_indisponible', $contexte); |
|
| 387 | 387 | |
| 388 | 388 | // produire la page d'erreur |
| 389 | 389 | $page = inclure_page($contexte['fond'], $contexte); |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | function creer_contexte_de_modele($args) { |
| 401 | 401 | $contexte = array(); |
| 402 | 402 | foreach ($args as $var=>$val) { |
| 403 | - if (is_int($var)){ // argument pas formate |
|
| 403 | + if (is_int($var)) { // argument pas formate |
|
| 404 | 404 | if (in_array($val, array('left', 'right', 'center'))) { |
| 405 | 405 | $var = 'align'; |
| 406 | 406 | $contexte[$var] = $val; |
| 407 | 407 | } else { |
| 408 | 408 | $args = explode('=', $val); |
| 409 | - if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | - $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); |
|
| 409 | + if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | + $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1); |
|
| 411 | 411 | else // notation abregee |
| 412 | 412 | $contexte[trim($val)] = trim($val); |
| 413 | 413 | } |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | |
| 422 | 422 | // Calcule le modele et retourne la mini-page ainsi calculee |
| 423 | 423 | // http://doc.spip.org/@inclure_modele |
| 424 | -function inclure_modele($type, $id, $params, $lien, $connect='', $env=array()) { |
|
| 424 | +function inclure_modele($type, $id, $params, $lien, $connect = '', $env = array()) { |
|
| 425 | 425 | |
| 426 | 426 | static $compteur; |
| 427 | - if (++$compteur>10) return ''; # ne pas boucler indefiniment |
|
| 427 | + if (++$compteur > 10) return ''; # ne pas boucler indefiniment |
|
| 428 | 428 | |
| 429 | 429 | $type = strtolower($type); |
| 430 | 430 | |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | $class = $soustype; |
| 447 | 447 | } |
| 448 | 448 | // enlever le sous type des params |
| 449 | - $params = array_diff($params,array($soustype)); |
|
| 449 | + $params = array_diff($params, array($soustype)); |
|
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | // Si ca marche pas en precisant le sous-type, prendre le type |
| 454 | - if (!$fond AND !trouve_modele($fond = $type)){ |
|
| 455 | - spip_log("Modele $type introuvable",_LOG_INFO_IMPORTANTE); |
|
| 454 | + if (!$fond AND !trouve_modele($fond = $type)) { |
|
| 455 | + spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE); |
|
| 456 | 456 | return false; |
| 457 | 457 | } |
| 458 | 458 | $fond = 'modeles/'.$fond; |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | // Si un lien a ete passe en parametre, ex: [<modele1>->url] |
| 475 | 475 | if ($lien) { |
| 476 | 476 | # un eventuel guillemet (") sera reechappe par #ENV |
| 477 | - $contexte['lien'] = str_replace(""",'"', $lien['href']); |
|
| 477 | + $contexte['lien'] = str_replace(""", '"', $lien['href']); |
|
| 478 | 478 | $contexte['lien_class'] = $lien['class']; |
| 479 | 479 | $contexte['lien_mime'] = $lien['mime']; |
| 480 | 480 | $contexte['lien_title'] = $lien['title']; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
| 486 | 486 | $arg_list = creer_contexte_de_modele($params); |
| 487 | 487 | $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
| 488 | - $contexte = array_merge($contexte,$arg_list); |
|
| 488 | + $contexte = array_merge($contexte, $arg_list); |
|
| 489 | 489 | |
| 490 | 490 | |
| 491 | 491 | // Appliquer le modele avec le contexte |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
| 496 | 496 | // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
| 497 | 497 | // sinon, s'il y a un lien, on l'ajoute classiquement |
| 498 | - if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')).' ', |
|
| 498 | + if (strstr(' '.($classes = extraire_attribut($retour, 'class')).' ', |
|
| 499 | 499 | 'spip_lien_ok')) { |
| 500 | 500 | $retour = inserer_attribut($retour, 'class', |
| 501 | 501 | trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | $compteur--; |
| 506 | 506 | |
| 507 | - return (isset($arg_list['ajax'])AND $arg_list['ajax']=='ajax') |
|
| 508 | - ? encoder_contexte_ajax($contexte,'',$retour) |
|
| 507 | + return (isset($arg_list['ajax']) AND $arg_list['ajax'] == 'ajax') |
|
| 508 | + ? encoder_contexte_ajax($contexte, '', $retour) |
|
| 509 | 509 | : $retour; |
| 510 | 510 | } |
| 511 | 511 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | // pour recuperer $page complet, utiliser: |
| 515 | 515 | // recuperer_fond($fond,$contexte,array('raw'=>true)) |
| 516 | 516 | // http://doc.spip.org/@evaluer_fond |
| 517 | -function evaluer_fond ($fond, $contexte=array(), $connect=null) { |
|
| 517 | +function evaluer_fond($fond, $contexte = array(), $connect = null) { |
|
| 518 | 518 | |
| 519 | 519 | $page = inclure_page($fond, $contexte, $connect); |
| 520 | 520 | |
@@ -536,36 +536,36 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | |
| 538 | 538 | // http://doc.spip.org/@page_base_href |
| 539 | -function page_base_href(&$texte){ |
|
| 539 | +function page_base_href(&$texte) { |
|
| 540 | 540 | static $set_html_base = null; |
| 541 | - if (is_null($set_html_base)){ |
|
| 541 | + if (is_null($set_html_base)) { |
|
| 542 | 542 | if (!defined('_SET_HTML_BASE')) |
| 543 | 543 | // si la profondeur est superieure a 1 |
| 544 | 544 | // est que ce n'est pas une url page ni une url action |
| 545 | 545 | // activer par defaut |
| 546 | 546 | $set_html_base = (( |
| 547 | - $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) |
|
| 547 | + $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 548 | 548 | AND _request(_SPIP_PAGE) !== 'login' |
| 549 | - AND !_request('action'))?true:false); |
|
| 549 | + AND !_request('action')) ?true:false); |
|
| 550 | 550 | else |
| 551 | 551 | $set_html_base = _SET_HTML_BASE; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | if ($set_html_base |
| 555 | 555 | AND isset($GLOBALS['html']) AND $GLOBALS['html'] |
| 556 | - AND $GLOBALS['profondeur_url']>0 |
|
| 557 | - AND ($poshead = strpos($texte,'</head>'))!==FALSE){ |
|
| 558 | - $head = substr($texte,0,$poshead); |
|
| 556 | + AND $GLOBALS['profondeur_url'] > 0 |
|
| 557 | + AND ($poshead = strpos($texte, '</head>')) !== FALSE) { |
|
| 558 | + $head = substr($texte, 0, $poshead); |
|
| 559 | 559 | $insert = false; |
| 560 | - if (strpos($head, '<base')===false) |
|
| 560 | + if (strpos($head, '<base') === false) |
|
| 561 | 561 | $insert = true; |
| 562 | 562 | else { |
| 563 | 563 | // si aucun <base ...> n'a de href c'est bon quand meme ! |
| 564 | 564 | $insert = true; |
| 565 | 565 | include_spip('inc/filtres'); |
| 566 | - $bases = extraire_balises($head,'base'); |
|
| 566 | + $bases = extraire_balises($head, 'base'); |
|
| 567 | 567 | foreach ($bases as $base) |
| 568 | - if (extraire_attribut($base,'href')) |
|
| 568 | + if (extraire_attribut($base, 'href')) |
|
| 569 | 569 | $insert = false; |
| 570 | 570 | } |
| 571 | 571 | if ($insert) { |
@@ -574,21 +574,21 @@ discard block |
||
| 574 | 574 | $base = url_absolue('./'); |
| 575 | 575 | $bbase = "\n<base href=\"$base\" />"; |
| 576 | 576 | if (($pos = strpos($head, '<head>')) !== false) |
| 577 | - $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 578 | - elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 577 | + $head = substr_replace($head, $bbase, $pos + 6, 0); |
|
| 578 | + elseif (preg_match(",<head[^>]*>,i", $head, $r)) { |
|
| 579 | 579 | $head = str_replace($r[0], $r[0].$bbase, $head); |
| 580 | 580 | } |
| 581 | - $texte = $head . substr($texte,$poshead); |
|
| 581 | + $texte = $head.substr($texte, $poshead); |
|
| 582 | 582 | // gerer les ancres |
| 583 | 583 | $base = $_SERVER['REQUEST_URI']; |
| 584 | 584 | // pas de guillemets ni < dans l'URL qu'on insere dans le HTML |
| 585 | - if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { |
|
| 586 | - $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); |
|
| 585 | + if (strpos($base, "'") or strpos($base, '"') or strpos($base, '<')) { |
|
| 586 | + $base = str_replace(array("'", '"', '<'), array("%27", '%22', '%3C'), $base); |
|
| 587 | 587 | } |
| 588 | - if (strpos($texte,"href='#")!==false) |
|
| 589 | - $texte = str_replace("href='#","href='$base#",$texte); |
|
| 590 | - if (strpos($texte, "href=\"#")!==false) |
|
| 591 | - $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 588 | + if (strpos($texte, "href='#") !== false) |
|
| 589 | + $texte = str_replace("href='#", "href='$base#", $texte); |
|
| 590 | + if (strpos($texte, "href=\"#") !== false) |
|
| 591 | + $texte = str_replace("href=\"#", "href=\"$base#", $texte); |
|
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | 594 | } |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | function envoyer_entetes($entetes) { |
| 601 | 601 | foreach ($entetes as $k => $v) |
| 602 | 602 | # if (strncmp($k, 'X-Spip-', 7)) |
| 603 | - @header(strlen($v)?"$k: $v":$k); |
|
| 603 | + @header(strlen($v) ? "$k: $v" : $k); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | ?> |
@@ -10,9 +10,13 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | -if (!defined('_CONTEXTE_IGNORE_VARIABLES')) define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$)/"); |
|
| 17 | +if (!defined('_CONTEXTE_IGNORE_VARIABLES')) { |
|
| 18 | + define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$)/"); |
|
| 19 | +} |
|
| 16 | 20 | // |
| 17 | 21 | // calcule la page et les entetes |
| 18 | 22 | // determine le contexte donne par l'URL (en tenant compte des reecritures) |
@@ -34,14 +38,17 @@ discard block |
||
| 34 | 38 | $cacher = charger_fonction('cacher', 'public', true); |
| 35 | 39 | // Les quatre derniers parametres sont modifies par la fonction: |
| 36 | 40 | // emplacement, validite, et, s'il est valide, contenu & age |
| 37 | - if ($cacher) |
|
| 38 | - $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 39 | - else |
|
| 40 | - $use_cache = -1; |
|
| 41 | + if ($cacher) { |
|
| 42 | + $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 43 | + } else { |
|
| 44 | + $use_cache = -1; |
|
| 45 | + } |
|
| 41 | 46 | // Si un resultat est retourne, c'est un message d'impossibilite |
| 42 | 47 | if ($res) {return array('texte' => $res);} |
| 43 | 48 | |
| 44 | - if (!$chemin_cache || !$lastmodified) $lastmodified = time(); |
|
| 49 | + if (!$chemin_cache || !$lastmodified) { |
|
| 50 | + $lastmodified = time(); |
|
| 51 | + } |
|
| 45 | 52 | |
| 46 | 53 | $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
| 47 | 54 | $calculer_page = true; |
@@ -83,8 +90,7 @@ discard block |
||
| 83 | 90 | // plus necessaire si on utilise bien la fonction urls_decoder_url |
| 84 | 91 | #unset($_SERVER['REDIRECT_url_propre']); |
| 85 | 92 | #unset($_ENV['url_propre']); |
| 86 | - } |
|
| 87 | - else { |
|
| 93 | + } else { |
|
| 88 | 94 | // Compat ascendante : |
| 89 | 95 | // 1. $contexte est global |
| 90 | 96 | // (a evacuer car urls_decoder_url gere ce probleme ?) |
@@ -94,8 +100,9 @@ discard block |
||
| 94 | 100 | list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true); |
| 95 | 101 | } |
| 96 | 102 | // squelette par defaut |
| 97 | - if (!strlen($fond)) |
|
| 98 | - $fond = 'sommaire'; |
|
| 103 | + if (!strlen($fond)) { |
|
| 104 | + $fond = 'sommaire'; |
|
| 105 | + } |
|
| 99 | 106 | |
| 100 | 107 | // produire la page : peut mettre a jour $lastmodified |
| 101 | 108 | $produire_page = charger_fonction('produire_page','public'); |
@@ -109,7 +116,9 @@ discard block |
||
| 109 | 116 | } |
| 110 | 117 | } |
| 111 | 118 | |
| 112 | - if ($page AND $chemin_cache) $page['cache'] = $chemin_cache; |
|
| 119 | + if ($page AND $chemin_cache) { |
|
| 120 | + $page['cache'] = $chemin_cache; |
|
| 121 | + } |
|
| 113 | 122 | |
| 114 | 123 | auto_content_type($page); |
| 115 | 124 | |
@@ -140,12 +149,14 @@ discard block |
||
| 140 | 149 | // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
| 141 | 150 | if ($lastmodified |
| 142 | 151 | AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
| 143 | - AND !isset($page['entetes']["Last-Modified"])) |
|
| 144 | - $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 152 | + AND !isset($page['entetes']["Last-Modified"])) { |
|
| 153 | + $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 154 | + } |
|
| 145 | 155 | |
| 146 | 156 | // fermer la connexion apres les headers si requete HEAD |
| 147 | - if ($headers_only) |
|
| 148 | - $page['entetes']["Connection"] = "close"; |
|
| 157 | + if ($headers_only) { |
|
| 158 | + $page['entetes']["Connection"] = "close"; |
|
| 159 | + } |
|
| 149 | 160 | |
| 150 | 161 | return $page; |
| 151 | 162 | } |
@@ -162,12 +173,14 @@ discard block |
||
| 162 | 173 | |
| 163 | 174 | $contexte = array(); |
| 164 | 175 | foreach($_GET as $var => $val) { |
| 165 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 166 | - $contexte[$var] = $val; |
|
| 176 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) { |
|
| 177 | + $contexte[$var] = $val; |
|
| 178 | + } |
|
| 167 | 179 | } |
| 168 | 180 | foreach($_POST as $var => $val) { |
| 169 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 170 | - $contexte[$var] = $val; |
|
| 181 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) { |
|
| 182 | + $contexte[$var] = $val; |
|
| 183 | + } |
|
| 171 | 184 | } |
| 172 | 185 | |
| 173 | 186 | return $contexte; |
@@ -182,8 +195,9 @@ discard block |
||
| 182 | 195 | */ |
| 183 | 196 | function calculer_contexte_implicite(){ |
| 184 | 197 | static $notes = null; |
| 185 | - if (is_null($notes)) |
|
| 186 | - $notes = charger_fonction('notes','inc',true); |
|
| 198 | + if (is_null($notes)) { |
|
| 199 | + $notes = charger_fonction('notes','inc',true); |
|
| 200 | + } |
|
| 187 | 201 | $contexte_implicite = array( |
| 188 | 202 | 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
| 189 | 203 | 'host' => $_SERVER['HTTP_HOST'], |
@@ -222,14 +236,16 @@ discard block |
||
| 222 | 236 | unset($contexte['fond']); |
| 223 | 237 | $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
| 224 | 238 | $page['contexte_implicite']['cache'] = $fond; |
| 225 | - if (is_null($cacher)) |
|
| 226 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 239 | + if (is_null($cacher)) { |
|
| 240 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 241 | + } |
|
| 227 | 242 | // Les quatre derniers parametres sont modifies par la fonction: |
| 228 | 243 | // emplacement, validite, et, s'il est valide, contenu & age |
| 229 | - if ($cacher) |
|
| 230 | - $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 231 | - else |
|
| 232 | - $use_cache = -1; |
|
| 244 | + if ($cacher) { |
|
| 245 | + $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 246 | + } else { |
|
| 247 | + $use_cache = -1; |
|
| 248 | + } |
|
| 233 | 249 | // $res = message d'erreur : on sort de la |
| 234 | 250 | if ($res) {return array('texte' => $res);} |
| 235 | 251 | |
@@ -237,8 +253,9 @@ discard block |
||
| 237 | 253 | // produire la page : peut mettre a jour $lastinclude |
| 238 | 254 | // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
| 239 | 255 | if ($use_cache) { |
| 240 | - if (is_null($produire_page)) |
|
| 241 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 256 | + if (is_null($produire_page)) { |
|
| 257 | + $produire_page = charger_fonction('produire_page','public'); |
|
| 258 | + } |
|
| 242 | 259 | $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
| 243 | 260 | } |
| 244 | 261 | // dans tous les cas, mettre a jour $lastmodified |
@@ -263,8 +280,9 @@ discard block |
||
| 263 | 280 | */ |
| 264 | 281 | function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect=''){ |
| 265 | 282 | static $parametrer,$cacher; |
| 266 | - if (!$parametrer) |
|
| 267 | - $parametrer = charger_fonction('parametrer', 'public'); |
|
| 283 | + if (!$parametrer) { |
|
| 284 | + $parametrer = charger_fonction('parametrer', 'public'); |
|
| 285 | + } |
|
| 268 | 286 | $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
| 269 | 287 | // et on l'enregistre sur le disque |
| 270 | 288 | if ($chemin_cache |
@@ -272,13 +290,15 @@ discard block |
||
| 272 | 290 | AND is_array($page) |
| 273 | 291 | AND count($page) |
| 274 | 292 | AND $page['entetes']['X-Spip-Cache'] > 0){ |
| 275 | - if (is_null($cacher)) |
|
| 276 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 293 | + if (is_null($cacher)) { |
|
| 294 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 295 | + } |
|
| 277 | 296 | $lastinclude = time(); |
| 278 | - if ($cacher) |
|
| 279 | - $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 280 | - else |
|
| 281 | - $use_cache = -1; |
|
| 297 | + if ($cacher) { |
|
| 298 | + $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 299 | + } else { |
|
| 300 | + $use_cache = -1; |
|
| 301 | + } |
|
| 282 | 302 | } |
| 283 | 303 | return $page; |
| 284 | 304 | } |
@@ -296,8 +316,10 @@ discard block |
||
| 296 | 316 | |
| 297 | 317 | function inserer_balise_dynamique($contexte_exec, $contexte_compil) |
| 298 | 318 | { |
| 299 | - if (!is_array($contexte_exec)) |
|
| 300 | - echo $contexte_exec; // message d'erreur etc |
|
| 319 | + if (!is_array($contexte_exec)) { |
|
| 320 | + echo $contexte_exec; |
|
| 321 | + } |
|
| 322 | + // message d'erreur etc |
|
| 301 | 323 | else { |
| 302 | 324 | inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
| 303 | 325 | } |
@@ -328,8 +350,9 @@ discard block |
||
| 328 | 350 | unset($page['entetes']['X-Spip-Cache']); |
| 329 | 351 | unset($page['entetes']['Content-Type']); |
| 330 | 352 | if (isset($GLOBALS['page']) AND is_array($GLOBALS['page'])) { |
| 331 | - if (!is_array($GLOBALS['page']['entetes'])) |
|
| 332 | - $GLOBALS['page']['entetes'] = array(); |
|
| 353 | + if (!is_array($GLOBALS['page']['entetes'])) { |
|
| 354 | + $GLOBALS['page']['entetes'] = array(); |
|
| 355 | + } |
|
| 333 | 356 | $GLOBALS['page']['entetes'] = |
| 334 | 357 | array_merge($GLOBALS['page']['entetes'],$page['entetes']); |
| 335 | 358 | } |
@@ -358,17 +381,20 @@ discard block |
||
| 358 | 381 | $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
| 359 | 382 | $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
| 360 | 383 | } |
| 361 | - if ($echo) |
|
| 362 | - echo $texte; |
|
| 363 | - else |
|
| 364 | - return $texte; |
|
| 384 | + if ($echo) { |
|
| 385 | + echo $texte; |
|
| 386 | + } else { |
|
| 387 | + return $texte; |
|
| 388 | + } |
|
| 365 | 389 | |
| 366 | 390 | } |
| 367 | 391 | |
| 368 | 392 | // http://doc.spip.org/@message_page_indisponible |
| 369 | 393 | function message_page_indisponible ($page, $contexte) { |
| 370 | 394 | static $deja = false; |
| 371 | - if ($deja) return "erreur"; |
|
| 395 | + if ($deja) { |
|
| 396 | + return "erreur"; |
|
| 397 | + } |
|
| 372 | 398 | $codes = array( |
| 373 | 399 | '404' => '404 Not Found', |
| 374 | 400 | '503' => '503 Service Unavailable', |
@@ -377,8 +403,9 @@ discard block |
||
| 377 | 403 | $contexte['status'] = ($page !== false) ? '404' : '503'; |
| 378 | 404 | $contexte['code'] = $codes[$contexte['status']]; |
| 379 | 405 | $contexte['fond'] = '404'; // gere les 2 erreurs |
| 380 | - if (!isset($contexte['lang'])) |
|
| 381 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 406 | + if (!isset($contexte['lang'])) { |
|
| 407 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 408 | + } |
|
| 382 | 409 | |
| 383 | 410 | $deja = true; |
| 384 | 411 | // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
@@ -387,8 +414,9 @@ discard block |
||
| 387 | 414 | |
| 388 | 415 | // produire la page d'erreur |
| 389 | 416 | $page = inclure_page($contexte['fond'], $contexte); |
| 390 | - if (!$page) |
|
| 391 | - $page = inclure_page('404', $contexte); |
|
| 417 | + if (!$page) { |
|
| 418 | + $page = inclure_page('404', $contexte); |
|
| 419 | + } |
|
| 392 | 420 | $page['status'] = $contexte['status']; |
| 393 | 421 | |
| 394 | 422 | return $page; |
@@ -406,14 +434,17 @@ discard block |
||
| 406 | 434 | $contexte[$var] = $val; |
| 407 | 435 | } else { |
| 408 | 436 | $args = explode('=', $val); |
| 409 | - if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 437 | + if (count($args)>=2) { |
|
| 438 | + // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | 439 | $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); |
| 411 | - else // notation abregee |
|
| 440 | + } else { |
|
| 441 | + // notation abregee |
|
| 412 | 442 | $contexte[trim($val)] = trim($val); |
| 443 | + } |
|
| 413 | 444 | } |
| 445 | + } else { |
|
| 446 | + $contexte[$var] = $val; |
|
| 414 | 447 | } |
| 415 | - else |
|
| 416 | - $contexte[$var] = $val; |
|
| 417 | 448 | } |
| 418 | 449 | |
| 419 | 450 | return $contexte; |
@@ -424,7 +455,10 @@ discard block |
||
| 424 | 455 | function inclure_modele($type, $id, $params, $lien, $connect='', $env=array()) { |
| 425 | 456 | |
| 426 | 457 | static $compteur; |
| 427 | - if (++$compteur>10) return ''; # ne pas boucler indefiniment |
|
| 458 | + if (++$compteur>10) { |
|
| 459 | + return ''; |
|
| 460 | + } |
|
| 461 | + # ne pas boucler indefiniment |
|
| 428 | 462 | |
| 429 | 463 | $type = strtolower($type); |
| 430 | 464 | |
@@ -468,8 +502,9 @@ discard block |
||
| 468 | 502 | $_id = id_table_objet($type); |
| 469 | 503 | $contexte['id'] = $contexte[$_id] = $id; |
| 470 | 504 | |
| 471 | - if (isset($class)) |
|
| 472 | - $contexte['class'] = $class; |
|
| 505 | + if (isset($class)) { |
|
| 506 | + $contexte['class'] = $class; |
|
| 507 | + } |
|
| 473 | 508 | |
| 474 | 509 | // Si un lien a ete passe en parametre, ex: [<modele1>->url] |
| 475 | 510 | if ($lien) { |
@@ -499,8 +534,9 @@ discard block |
||
| 499 | 534 | 'spip_lien_ok')) { |
| 500 | 535 | $retour = inserer_attribut($retour, 'class', |
| 501 | 536 | trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
| 502 | - } else if ($lien) |
|
| 503 | - $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 537 | + } else if ($lien) { |
|
| 538 | + $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 539 | + } |
|
| 504 | 540 | |
| 505 | 541 | $compteur--; |
| 506 | 542 | |
@@ -518,7 +554,9 @@ discard block |
||
| 518 | 554 | |
| 519 | 555 | $page = inclure_page($fond, $contexte, $connect); |
| 520 | 556 | |
| 521 | - if (!$page) return $page; |
|
| 557 | + if (!$page) { |
|
| 558 | + return $page; |
|
| 559 | + } |
|
| 522 | 560 | // eval $page et affecte $res |
| 523 | 561 | include _ROOT_RESTREINT."public/evaluer_page.php"; |
| 524 | 562 | |
@@ -528,8 +566,9 @@ discard block |
||
| 528 | 566 | // il faut bien lever ce drapeau apres avoir evalue le fond |
| 529 | 567 | // pour ne pas faire descendre le flag vers les inclusions appelees |
| 530 | 568 | if (isset($page['invalideurs']) |
| 531 | - AND isset($page['invalideurs']['session'])) |
|
| 532 | - $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 569 | + AND isset($page['invalideurs']['session'])) { |
|
| 570 | + $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 571 | + } |
|
| 533 | 572 | |
| 534 | 573 | return $page; |
| 535 | 574 | } |
@@ -539,16 +578,17 @@ discard block |
||
| 539 | 578 | function page_base_href(&$texte){ |
| 540 | 579 | static $set_html_base = null; |
| 541 | 580 | if (is_null($set_html_base)){ |
| 542 | - if (!defined('_SET_HTML_BASE')) |
|
| 543 | - // si la profondeur est superieure a 1 |
|
| 581 | + if (!defined('_SET_HTML_BASE')) { |
|
| 582 | + // si la profondeur est superieure a 1 |
|
| 544 | 583 | // est que ce n'est pas une url page ni une url action |
| 545 | 584 | // activer par defaut |
| 546 | 585 | $set_html_base = (( |
| 547 | 586 | $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) |
| 548 | 587 | AND _request(_SPIP_PAGE) !== 'login' |
| 549 | 588 | AND !_request('action'))?true:false); |
| 550 | - else |
|
| 551 | - $set_html_base = _SET_HTML_BASE; |
|
| 589 | + } else { |
|
| 590 | + $set_html_base = _SET_HTML_BASE; |
|
| 591 | + } |
|
| 552 | 592 | } |
| 553 | 593 | |
| 554 | 594 | if ($set_html_base |
@@ -557,25 +597,26 @@ discard block |
||
| 557 | 597 | AND ($poshead = strpos($texte,'</head>'))!==FALSE){ |
| 558 | 598 | $head = substr($texte,0,$poshead); |
| 559 | 599 | $insert = false; |
| 560 | - if (strpos($head, '<base')===false) |
|
| 561 | - $insert = true; |
|
| 562 | - else { |
|
| 600 | + if (strpos($head, '<base')===false) { |
|
| 601 | + $insert = true; |
|
| 602 | + } else { |
|
| 563 | 603 | // si aucun <base ...> n'a de href c'est bon quand meme ! |
| 564 | 604 | $insert = true; |
| 565 | 605 | include_spip('inc/filtres'); |
| 566 | 606 | $bases = extraire_balises($head,'base'); |
| 567 | - foreach ($bases as $base) |
|
| 568 | - if (extraire_attribut($base,'href')) |
|
| 607 | + foreach ($bases as $base) { |
|
| 608 | + if (extraire_attribut($base,'href')) |
|
| 569 | 609 | $insert = false; |
| 610 | + } |
|
| 570 | 611 | } |
| 571 | 612 | if ($insert) { |
| 572 | 613 | include_spip('inc/filtres_mini'); |
| 573 | 614 | // ajouter un base qui reglera tous les liens relatifs |
| 574 | 615 | $base = url_absolue('./'); |
| 575 | 616 | $bbase = "\n<base href=\"$base\" />"; |
| 576 | - if (($pos = strpos($head, '<head>')) !== false) |
|
| 577 | - $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 578 | - elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 617 | + if (($pos = strpos($head, '<head>')) !== false) { |
|
| 618 | + $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 619 | + } elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 579 | 620 | $head = str_replace($r[0], $r[0].$bbase, $head); |
| 580 | 621 | } |
| 581 | 622 | $texte = $head . substr($texte,$poshead); |
@@ -585,10 +626,12 @@ discard block |
||
| 585 | 626 | if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { |
| 586 | 627 | $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); |
| 587 | 628 | } |
| 588 | - if (strpos($texte,"href='#")!==false) |
|
| 589 | - $texte = str_replace("href='#","href='$base#",$texte); |
|
| 590 | - if (strpos($texte, "href=\"#")!==false) |
|
| 591 | - $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 629 | + if (strpos($texte,"href='#")!==false) { |
|
| 630 | + $texte = str_replace("href='#","href='$base#",$texte); |
|
| 631 | + } |
|
| 632 | + if (strpos($texte, "href=\"#")!==false) { |
|
| 633 | + $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 634 | + } |
|
| 592 | 635 | } |
| 593 | 636 | } |
| 594 | 637 | } |
@@ -598,9 +641,10 @@ discard block |
||
| 598 | 641 | // et demarrent par X-Spip-... |
| 599 | 642 | // http://doc.spip.org/@envoyer_entetes |
| 600 | 643 | function envoyer_entetes($entetes) { |
| 601 | - foreach ($entetes as $k => $v) |
|
| 602 | - # if (strncmp($k, 'X-Spip-', 7)) |
|
| 603 | - @header(strlen($v)?"$k: $v":$k); |
|
| 604 | -} |
|
| 644 | + foreach ($entetes as $k => $v) { |
|
| 645 | + # if (strncmp($k, 'X-Spip-', 7)) |
|
| 646 | + @header(strlen($v)?"$k: $v":$k); |
|
| 647 | + } |
|
| 648 | + } |
|
| 605 | 649 | |
| 606 | 650 | ?> |