@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
| 147 | 147 | $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
| 148 | 148 | . $data[$root] |
| 149 | - . '</option>' . "\n"; |
|
| 149 | + . '</option>'."\n"; |
|
| 150 | 150 | } else { |
| 151 | 151 | $r = ''; |
| 152 | 152 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // et voila le travail |
| 177 | - return $r . $sous; |
|
| 177 | + return $r.$sous; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -221,12 +221,12 @@ discard block |
||
| 221 | 221 | while ($r = sql_fetch($q)) { |
| 222 | 222 | if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
| 223 | 223 | // titre largeur maxi a 50 |
| 224 | - $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 224 | + $titre = couper(supprimer_tags(typo($r['titre'])).' ', 50); |
|
| 225 | 225 | if ( |
| 226 | 226 | $GLOBALS['meta']['multi_rubriques'] == 'oui' |
| 227 | 227 | and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0) |
| 228 | 228 | ) { |
| 229 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 229 | + $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 230 | 230 | } |
| 231 | 231 | $data[$r['id_rubrique']] = $titre; |
| 232 | 232 | $enfants[$r['id_parent']][] = $r['id_rubrique']; |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
| 254 | 254 | |
| 255 | 255 | if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
| 256 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 256 | + $r = "<input$att type='hidden' value='".$r[1]."' />".$r[2]; |
|
| 257 | 257 | } else { |
| 258 | - $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 258 | + $r = '<select'.$att." size='1'>\n$opt</select>\n"; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | # message pour neuneus (a supprimer ?) |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 298 | 298 | |
| 299 | 299 | if ($id_rubrique) { |
| 300 | - $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 300 | + $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 301 | 301 | } else { |
| 302 | 302 | if ($type == 'auteur') { |
| 303 | 303 | $titre = ' '; |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
| 310 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 310 | + $init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'"; |
|
| 311 | 311 | |
| 312 | 312 | $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
| 313 | 313 | . (!$idem ? '' : "&exclus=$idem") |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | . " jQuery(this).toggleClass('toggled'); " |
| 357 | 357 | . "return charger_node_url_si_vide('" |
| 358 | 358 | . $url |
| 359 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 359 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>" |
|
| 360 | 360 | . $img_icone |
| 361 | 361 | . "</a><img src='" |
| 362 | 362 | . chemin_image('loader.svg') |
@@ -18,16 +18,16 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!defined('_SPIP_SELECT_RUBRIQUES')) { |
| 25 | - /** |
|
| 26 | - * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | - * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | - * mettre 100000 pour desactiver ajax |
|
| 29 | - */ |
|
| 30 | - define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 25 | + /** |
|
| 26 | + * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | + * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | + * mettre 100000 pour desactiver ajax |
|
| 29 | + */ |
|
| 30 | + define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -55,22 +55,22 @@ discard block |
||
| 55 | 55 | * Code HTML du sélecteur |
| 56 | 56 | **/ |
| 57 | 57 | function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 58 | - if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // Mode sans Ajax : |
|
| 63 | - // - soit parce que le cookie ajax n'est pas la |
|
| 64 | - // - soit parce qu'il y a peu de rubriques |
|
| 65 | - if ( |
|
| 66 | - _SPIP_AJAX < 1 |
|
| 67 | - or $type == 'breve' |
|
| 68 | - or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 69 | - ) { |
|
| 70 | - return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 71 | - } else { |
|
| 72 | - return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 73 | - } |
|
| 58 | + if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // Mode sans Ajax : |
|
| 63 | + // - soit parce que le cookie ajax n'est pas la |
|
| 64 | + // - soit parce qu'il y a peu de rubriques |
|
| 65 | + if ( |
|
| 66 | + _SPIP_AJAX < 1 |
|
| 67 | + or $type == 'breve' |
|
| 68 | + or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 69 | + ) { |
|
| 70 | + return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 71 | + } else { |
|
| 72 | + return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // compatibilite pour extensions qui utilisaient l'ancien nom |
@@ -87,17 +87,17 @@ discard block |
||
| 87 | 87 | **/ |
| 88 | 88 | function style_menu_rubriques($i) { |
| 89 | 89 | |
| 90 | - $espace = ''; |
|
| 91 | - $style = ''; |
|
| 92 | - for ($count = 1; $count <= $i; $count++) { |
|
| 93 | - $espace .= ' '; |
|
| 94 | - } |
|
| 95 | - if ($i == 1) { |
|
| 96 | - $espace = ''; |
|
| 97 | - } |
|
| 98 | - $class = "niveau_$i"; |
|
| 99 | - |
|
| 100 | - return [$class, $style, $espace]; |
|
| 90 | + $espace = ''; |
|
| 91 | + $style = ''; |
|
| 92 | + for ($count = 1; $count <= $i; $count++) { |
|
| 93 | + $espace .= ' '; |
|
| 94 | + } |
|
| 95 | + if ($i == 1) { |
|
| 96 | + $espace = ''; |
|
| 97 | + } |
|
| 98 | + $class = "niveau_$i"; |
|
| 99 | + |
|
| 100 | + return [$class, $style, $espace]; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -121,60 +121,60 @@ discard block |
||
| 121 | 121 | * Code HTML du sélecteur |
| 122 | 122 | **/ |
| 123 | 123 | function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) { |
| 124 | - static $decalage_secteur; |
|
| 125 | - |
|
| 126 | - // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | - if ( |
|
| 128 | - $exclus > 0 |
|
| 129 | - and $root == $exclus |
|
| 130 | - ) { |
|
| 131 | - return ''; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 135 | - |
|
| 136 | - // selected ? |
|
| 137 | - $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 138 | - |
|
| 139 | - // le style en fonction de la profondeur |
|
| 140 | - [$class, $style, $espace] = style_menu_rubriques($niv); |
|
| 141 | - |
|
| 142 | - $class .= ' selec_rub'; |
|
| 143 | - |
|
| 144 | - // creer l'<option> pour la rubrique $root |
|
| 145 | - |
|
| 146 | - if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
|
| 147 | - $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | - . $data[$root] |
|
| 149 | - . '</option>' . "\n"; |
|
| 150 | - } else { |
|
| 151 | - $r = ''; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - // et le sous-menu pour ses enfants |
|
| 155 | - $sous = ''; |
|
| 156 | - if (isset($enfants[$root])) { |
|
| 157 | - foreach ($enfants[$root] as $sousrub) { |
|
| 158 | - $sous .= sous_menu_rubriques( |
|
| 159 | - $id_rubrique, |
|
| 160 | - $sousrub, |
|
| 161 | - $niv + 1, |
|
| 162 | - $data, |
|
| 163 | - $enfants, |
|
| 164 | - $exclus, |
|
| 165 | - $restreint, |
|
| 166 | - $type |
|
| 167 | - ); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 172 | - if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 173 | - return $sous; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - // et voila le travail |
|
| 177 | - return $r . $sous; |
|
| 124 | + static $decalage_secteur; |
|
| 125 | + |
|
| 126 | + // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | + if ( |
|
| 128 | + $exclus > 0 |
|
| 129 | + and $root == $exclus |
|
| 130 | + ) { |
|
| 131 | + return ''; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 135 | + |
|
| 136 | + // selected ? |
|
| 137 | + $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 138 | + |
|
| 139 | + // le style en fonction de la profondeur |
|
| 140 | + [$class, $style, $espace] = style_menu_rubriques($niv); |
|
| 141 | + |
|
| 142 | + $class .= ' selec_rub'; |
|
| 143 | + |
|
| 144 | + // creer l'<option> pour la rubrique $root |
|
| 145 | + |
|
| 146 | + if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
|
| 147 | + $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | + . $data[$root] |
|
| 149 | + . '</option>' . "\n"; |
|
| 150 | + } else { |
|
| 151 | + $r = ''; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + // et le sous-menu pour ses enfants |
|
| 155 | + $sous = ''; |
|
| 156 | + if (isset($enfants[$root])) { |
|
| 157 | + foreach ($enfants[$root] as $sousrub) { |
|
| 158 | + $sous .= sous_menu_rubriques( |
|
| 159 | + $id_rubrique, |
|
| 160 | + $sousrub, |
|
| 161 | + $niv + 1, |
|
| 162 | + $data, |
|
| 163 | + $enfants, |
|
| 164 | + $exclus, |
|
| 165 | + $restreint, |
|
| 166 | + $type |
|
| 167 | + ); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 172 | + if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 173 | + return $sous; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + // et voila le travail |
|
| 177 | + return $r . $sous; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -195,75 +195,75 @@ discard block |
||
| 195 | 195 | * Code HTML du sélecteur |
| 196 | 196 | **/ |
| 197 | 197 | function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) { |
| 198 | - $enfants = []; |
|
| 199 | - $data = []; |
|
| 200 | - if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 201 | - $data[0] = _T('info_racine_site'); |
|
| 202 | - } |
|
| 203 | - # premier choix = neant |
|
| 204 | - # si auteur (rubriques restreintes) |
|
| 205 | - # ou si creation avec id_rubrique=0 |
|
| 206 | - elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 207 | - $data[0] = ' '; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // |
|
| 211 | - // creer une structure contenant toute l'arborescence |
|
| 212 | - // |
|
| 213 | - |
|
| 214 | - include_spip('base/abstract_sql'); |
|
| 215 | - $q = sql_select( |
|
| 216 | - 'id_rubrique, id_parent, titre, statut, lang, langue_choisie', |
|
| 217 | - 'spip_rubriques', |
|
| 218 | - ($type == 'breve' ? ' id_parent=0 ' : ''), |
|
| 219 | - '', |
|
| 220 | - '0+titre,titre' |
|
| 221 | - ); |
|
| 222 | - while ($r = sql_fetch($q)) { |
|
| 223 | - if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 224 | - // titre largeur maxi a 50 |
|
| 225 | - $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 226 | - if ( |
|
| 227 | - $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 228 | - and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0) |
|
| 229 | - ) { |
|
| 230 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 231 | - } |
|
| 232 | - $data[$r['id_rubrique']] = $titre; |
|
| 233 | - $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 234 | - if ($id_rubrique == $r['id_rubrique']) { |
|
| 235 | - $id_parent = $r['id_parent']; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // si une seule rubrique comme choix possible, |
|
| 241 | - // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 242 | - // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 243 | - if ( |
|
| 244 | - count($data) == 2 |
|
| 245 | - and isset($data[0]) |
|
| 246 | - and !in_array($type, ['auteur', 'rubrique']) |
|
| 247 | - and !$id_rubrique |
|
| 248 | - ) { |
|
| 249 | - unset($data[0]); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 254 | - $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 255 | - |
|
| 256 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 257 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 258 | - } else { |
|
| 259 | - $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - # message pour neuneus (a supprimer ?) |
|
| 198 | + $enfants = []; |
|
| 199 | + $data = []; |
|
| 200 | + if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 201 | + $data[0] = _T('info_racine_site'); |
|
| 202 | + } |
|
| 203 | + # premier choix = neant |
|
| 204 | + # si auteur (rubriques restreintes) |
|
| 205 | + # ou si creation avec id_rubrique=0 |
|
| 206 | + elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 207 | + $data[0] = ' '; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // |
|
| 211 | + // creer une structure contenant toute l'arborescence |
|
| 212 | + // |
|
| 213 | + |
|
| 214 | + include_spip('base/abstract_sql'); |
|
| 215 | + $q = sql_select( |
|
| 216 | + 'id_rubrique, id_parent, titre, statut, lang, langue_choisie', |
|
| 217 | + 'spip_rubriques', |
|
| 218 | + ($type == 'breve' ? ' id_parent=0 ' : ''), |
|
| 219 | + '', |
|
| 220 | + '0+titre,titre' |
|
| 221 | + ); |
|
| 222 | + while ($r = sql_fetch($q)) { |
|
| 223 | + if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 224 | + // titre largeur maxi a 50 |
|
| 225 | + $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 226 | + if ( |
|
| 227 | + $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 228 | + and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0) |
|
| 229 | + ) { |
|
| 230 | + $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 231 | + } |
|
| 232 | + $data[$r['id_rubrique']] = $titre; |
|
| 233 | + $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 234 | + if ($id_rubrique == $r['id_rubrique']) { |
|
| 235 | + $id_parent = $r['id_parent']; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // si une seule rubrique comme choix possible, |
|
| 241 | + // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 242 | + // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 243 | + if ( |
|
| 244 | + count($data) == 2 |
|
| 245 | + and isset($data[0]) |
|
| 246 | + and !in_array($type, ['auteur', 'rubrique']) |
|
| 247 | + and !$id_rubrique |
|
| 248 | + ) { |
|
| 249 | + unset($data[0]); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 254 | + $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 255 | + |
|
| 256 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 257 | + $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 258 | + } else { |
|
| 259 | + $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + # message pour neuneus (a supprimer ?) |
|
| 263 | 263 | # if ($type != 'auteur' AND $type != 'breve') |
| 264 | 264 | # $r .= "\n<br />"._T('texte_rappel_selection_champs'); |
| 265 | 265 | |
| 266 | - return $r; |
|
| 266 | + return $r; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -297,26 +297,26 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 299 | 299 | |
| 300 | - if ($id_rubrique) { |
|
| 301 | - $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 302 | - } else { |
|
| 303 | - if ($type == 'auteur') { |
|
| 304 | - $titre = ' '; |
|
| 305 | - } else { |
|
| 306 | - $titre = _T('info_racine_site'); |
|
| 307 | - } |
|
| 308 | - } |
|
| 300 | + if ($id_rubrique) { |
|
| 301 | + $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 302 | + } else { |
|
| 303 | + if ($type == 'auteur') { |
|
| 304 | + $titre = ' '; |
|
| 305 | + } else { |
|
| 306 | + $titre = _T('info_racine_site'); |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 311 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 310 | + $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 311 | + $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 312 | 312 | |
| 313 | - $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 314 | - . (!$idem ? '' : "&exclus=$idem") |
|
| 315 | - . ($restreint ? '' : '&racine=oui') |
|
| 316 | - . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 313 | + $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 314 | + . (!$idem ? '' : "&exclus=$idem") |
|
| 315 | + . ($restreint ? '' : '&racine=oui') |
|
| 316 | + . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 317 | 317 | |
| 318 | 318 | |
| 319 | - return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 319 | + return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -346,30 +346,30 @@ discard block |
||
| 346 | 346 | * Code HTML du sélecteur de rubrique AJAX |
| 347 | 347 | **/ |
| 348 | 348 | function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) { |
| 349 | - $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 350 | - // si icone de recherche on embed le svg |
|
| 351 | - $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 352 | - $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur')); |
|
| 353 | - |
|
| 354 | - return |
|
| 355 | - "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 356 | - . $js |
|
| 357 | - . " jQuery(this).toggleClass('toggled'); " |
|
| 358 | - . "return charger_node_url_si_vide('" |
|
| 359 | - . $url |
|
| 360 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 361 | - . $img_icone |
|
| 362 | - . "</a><img src='" |
|
| 363 | - . chemin_image('loader.svg') |
|
| 364 | - . "' class='loader' id='img_" |
|
| 365 | - . $idom |
|
| 366 | - . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 367 | - . "<input id='titreparent' name='titreparent' class='text'" |
|
| 368 | - . $init |
|
| 369 | - . ' />' |
|
| 370 | - . "<input type='hidden' id='$name' name='$name' value='" |
|
| 371 | - . $id |
|
| 372 | - . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 373 | - . $idom |
|
| 374 | - . "'\nstyle='display: none;'></div>"; |
|
| 349 | + $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 350 | + // si icone de recherche on embed le svg |
|
| 351 | + $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 352 | + $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur')); |
|
| 353 | + |
|
| 354 | + return |
|
| 355 | + "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 356 | + . $js |
|
| 357 | + . " jQuery(this).toggleClass('toggled'); " |
|
| 358 | + . "return charger_node_url_si_vide('" |
|
| 359 | + . $url |
|
| 360 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 361 | + . $img_icone |
|
| 362 | + . "</a><img src='" |
|
| 363 | + . chemin_image('loader.svg') |
|
| 364 | + . "' class='loader' id='img_" |
|
| 365 | + . $idom |
|
| 366 | + . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 367 | + . "<input id='titreparent' name='titreparent' class='text'" |
|
| 368 | + . $init |
|
| 369 | + . ' />' |
|
| 370 | + . "<input type='hidden' id='$name' name='$name' value='" |
|
| 371 | + . $id |
|
| 372 | + . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 373 | + . $idom |
|
| 374 | + . "'\nstyle='display: none;'></div>"; |
|
| 375 | 375 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | renouvelle_alea(); |
| 66 | 66 | $new = false; |
| 67 | 67 | } else { |
| 68 | - spip_log("impossible d'ecrire dans " . $cache); |
|
| 68 | + spip_log("impossible d'ecrire dans ".$cache); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | // et refaire le cache si on a du lire en base |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | if (!isset($touch[$table])) { |
| 167 | 167 | touch_meta($antidate, $table); |
| 168 | 168 | } |
| 169 | - sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | + sql_delete('spip_'.$table, "nom='$nom'", '', 'continue'); |
|
| 170 | 170 | unset($GLOBALS[$table][$nom]); |
| 171 | 171 | if (!isset($touch[$table])) { |
| 172 | 172 | touch_meta($antidate, $table); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | 199 | include_spip('base/abstract_sql'); |
| 200 | - $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | + $res = sql_select('*', 'spip_'.$table, 'nom='.sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 201 | 201 | // table pas encore installee, travailler en php seulement |
| 202 | 202 | if (!$res) { |
| 203 | 203 | $GLOBALS[$table][$nom] = $valeur; |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | $r['impt'] = sql_quote($importable, '', 'text'); |
| 232 | 232 | } |
| 233 | 233 | if ($row) { |
| 234 | - sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | + sql_update('spip_'.$table, $r, 'nom='.sql_quote($nom)); |
|
| 235 | 235 | } else { |
| 236 | - sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | + sql_insert('spip_'.$table, '('.join(',', array_keys($r)).')', '('.join(',', array_values($r)).')'); |
|
| 237 | 237 | } |
| 238 | 238 | if (!isset($touch[$table])) { |
| 239 | 239 | touch_meta($antidate, $table); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * Nom du fichier cache |
| 251 | 251 | **/ |
| 252 | 252 | function cache_meta($table = 'meta') { |
| 253 | - return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 253 | + return ($table == 'meta') ? _FILE_META : (_DIR_CACHE.$table.'.php'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | // Les parametres generaux du site sont dans une table SQL; |
@@ -27,51 +27,51 @@ discard block |
||
| 27 | 27 | define('_META_CACHE_TIME', 1 << 24); |
| 28 | 28 | |
| 29 | 29 | function inc_meta_dist($table = 'meta') { |
| 30 | - $new = null; |
|
| 31 | - // Lire les meta, en cache si present, valide et lisible |
|
| 32 | - // en cas d'install ne pas faire confiance au meta_cache eventuel |
|
| 33 | - $cache = cache_meta($table); |
|
| 30 | + $new = null; |
|
| 31 | + // Lire les meta, en cache si present, valide et lisible |
|
| 32 | + // en cas d'install ne pas faire confiance au meta_cache eventuel |
|
| 33 | + $cache = cache_meta($table); |
|
| 34 | 34 | |
| 35 | - if ( |
|
| 36 | - (!$exec = _request('exec') or !autoriser_sans_cookie($exec)) |
|
| 37 | - and $new = jeune_fichier($cache, _META_CACHE_TIME) |
|
| 38 | - and lire_fichier_securise($cache, $meta) |
|
| 39 | - and $meta = @unserialize($meta) |
|
| 40 | - ) { |
|
| 41 | - $GLOBALS[$table] = $meta; |
|
| 42 | - } |
|
| 35 | + if ( |
|
| 36 | + (!$exec = _request('exec') or !autoriser_sans_cookie($exec)) |
|
| 37 | + and $new = jeune_fichier($cache, _META_CACHE_TIME) |
|
| 38 | + and lire_fichier_securise($cache, $meta) |
|
| 39 | + and $meta = @unserialize($meta) |
|
| 40 | + ) { |
|
| 41 | + $GLOBALS[$table] = $meta; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - if ( |
|
| 45 | - isset($GLOBALS[$table]['touch']) |
|
| 46 | - and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME) |
|
| 47 | - ) { |
|
| 48 | - $GLOBALS[$table] = []; |
|
| 49 | - } |
|
| 50 | - // sinon lire en base |
|
| 51 | - if (!$GLOBALS[$table]) { |
|
| 52 | - $new = !lire_metas($table); |
|
| 53 | - } |
|
| 44 | + if ( |
|
| 45 | + isset($GLOBALS[$table]['touch']) |
|
| 46 | + and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME) |
|
| 47 | + ) { |
|
| 48 | + $GLOBALS[$table] = []; |
|
| 49 | + } |
|
| 50 | + // sinon lire en base |
|
| 51 | + if (!$GLOBALS[$table]) { |
|
| 52 | + $new = !lire_metas($table); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // renouveller l'alea general si trop vieux ou sur demande explicite |
|
| 56 | - if ( |
|
| 57 | - (test_espace_prive() || isset($_GET['renouvelle_alea'])) |
|
| 58 | - and $GLOBALS[$table] |
|
| 59 | - and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0)) |
|
| 60 | - ) { |
|
| 61 | - // si on n'a pas l'acces en ecriture sur le cache, |
|
| 62 | - // ne pas renouveller l'alea sinon le cache devient faux |
|
| 63 | - if (supprimer_fichier($cache)) { |
|
| 64 | - include_spip('inc/acces'); |
|
| 65 | - renouvelle_alea(); |
|
| 66 | - $new = false; |
|
| 67 | - } else { |
|
| 68 | - spip_log("impossible d'ecrire dans " . $cache); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - // et refaire le cache si on a du lire en base |
|
| 72 | - if (!$new) { |
|
| 73 | - touch_meta(false, $table); |
|
| 74 | - } |
|
| 55 | + // renouveller l'alea general si trop vieux ou sur demande explicite |
|
| 56 | + if ( |
|
| 57 | + (test_espace_prive() || isset($_GET['renouvelle_alea'])) |
|
| 58 | + and $GLOBALS[$table] |
|
| 59 | + and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0)) |
|
| 60 | + ) { |
|
| 61 | + // si on n'a pas l'acces en ecriture sur le cache, |
|
| 62 | + // ne pas renouveller l'alea sinon le cache devient faux |
|
| 63 | + if (supprimer_fichier($cache)) { |
|
| 64 | + include_spip('inc/acces'); |
|
| 65 | + renouvelle_alea(); |
|
| 66 | + $new = false; |
|
| 67 | + } else { |
|
| 68 | + spip_log("impossible d'ecrire dans " . $cache); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + // et refaire le cache si on a du lire en base |
|
| 72 | + if (!$new) { |
|
| 73 | + touch_meta(false, $table); |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // fonctions aussi appelees a l'install ==> spip_query en premiere requete |
@@ -79,39 +79,39 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | function lire_metas($table = 'meta') { |
| 81 | 81 | |
| 82 | - if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) { |
|
| 83 | - include_spip('base/abstract_sql'); |
|
| 84 | - $GLOBALS[$table] = []; |
|
| 85 | - while ($row = sql_fetch($result)) { |
|
| 86 | - $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 87 | - } |
|
| 88 | - sql_free($result); |
|
| 82 | + if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) { |
|
| 83 | + include_spip('base/abstract_sql'); |
|
| 84 | + $GLOBALS[$table] = []; |
|
| 85 | + while ($row = sql_fetch($result)) { |
|
| 86 | + $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 87 | + } |
|
| 88 | + sql_free($result); |
|
| 89 | 89 | |
| 90 | - if ( |
|
| 91 | - !isset($GLOBALS[$table]['charset']) |
|
| 92 | - or !$GLOBALS[$table]['charset'] |
|
| 93 | - or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install |
|
| 94 | - ) { |
|
| 95 | - ecrire_meta('charset', _DEFAULT_CHARSET, null, $table); |
|
| 96 | - } |
|
| 90 | + if ( |
|
| 91 | + !isset($GLOBALS[$table]['charset']) |
|
| 92 | + or !$GLOBALS[$table]['charset'] |
|
| 93 | + or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install |
|
| 94 | + ) { |
|
| 95 | + ecrire_meta('charset', _DEFAULT_CHARSET, null, $table); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - // noter cette table de configuration dans les meta de SPIP |
|
| 99 | - if ($table !== 'meta') { |
|
| 100 | - $liste = []; |
|
| 101 | - if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 102 | - $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 103 | - } |
|
| 104 | - if (!$liste) { |
|
| 105 | - $liste = []; |
|
| 106 | - } |
|
| 107 | - if (!in_array($table, $liste)) { |
|
| 108 | - $liste[] = $table; |
|
| 109 | - ecrire_meta('tables_config', serialize($liste)); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 98 | + // noter cette table de configuration dans les meta de SPIP |
|
| 99 | + if ($table !== 'meta') { |
|
| 100 | + $liste = []; |
|
| 101 | + if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 102 | + $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 103 | + } |
|
| 104 | + if (!$liste) { |
|
| 105 | + $liste = []; |
|
| 106 | + } |
|
| 107 | + if (!in_array($table, $liste)) { |
|
| 108 | + $liste[] = $table; |
|
| 109 | + ecrire_meta('tables_config', serialize($liste)); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return $GLOBALS[$table] ?? null; |
|
| 114 | + return $GLOBALS[$table] ?? null; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -125,22 +125,22 @@ discard block |
||
| 125 | 125 | * Table SQL d'enregistrement des meta. |
| 126 | 126 | **/ |
| 127 | 127 | function touch_meta($antidate = false, $table = 'meta') { |
| 128 | - $file = cache_meta($table); |
|
| 129 | - if (!$antidate or !@touch($file, $antidate)) { |
|
| 130 | - $r = $GLOBALS[$table] ?? []; |
|
| 131 | - if ($table == 'meta') { |
|
| 132 | - unset($r['alea_ephemere']); |
|
| 133 | - unset($r['alea_ephemere_ancien']); |
|
| 134 | - // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables |
|
| 135 | - // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique |
|
| 136 | - // meme si son squelette est en cache |
|
| 137 | - //unset($r['secret_du_site']); |
|
| 138 | - if ($antidate) { |
|
| 139 | - $r['touch'] = $antidate; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - ecrire_fichier_securise($file, serialize($r)); |
|
| 143 | - } |
|
| 128 | + $file = cache_meta($table); |
|
| 129 | + if (!$antidate or !@touch($file, $antidate)) { |
|
| 130 | + $r = $GLOBALS[$table] ?? []; |
|
| 131 | + if ($table == 'meta') { |
|
| 132 | + unset($r['alea_ephemere']); |
|
| 133 | + unset($r['alea_ephemere_ancien']); |
|
| 134 | + // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables |
|
| 135 | + // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique |
|
| 136 | + // meme si son squelette est en cache |
|
| 137 | + //unset($r['secret_du_site']); |
|
| 138 | + if ($antidate) { |
|
| 139 | + $r['touch'] = $antidate; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + ecrire_fichier_securise($file, serialize($r)); |
|
| 143 | + } |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -156,21 +156,21 @@ discard block |
||
| 156 | 156 | * Table SQL d'enregistrement de la meta. |
| 157 | 157 | **/ |
| 158 | 158 | function effacer_meta($nom, $table = 'meta') { |
| 159 | - // section critique sur le cache: |
|
| 160 | - // l'invalider avant et apres la MAJ de la BD |
|
| 161 | - // c'est un peu moins bien qu'un vrai verrou mais ca suffira |
|
| 162 | - // et utiliser une statique pour eviter des acces disques a repetition |
|
| 163 | - static $touch = []; |
|
| 164 | - $antidate = time() - (_META_CACHE_TIME << 4); |
|
| 165 | - if (!isset($touch[$table])) { |
|
| 166 | - touch_meta($antidate, $table); |
|
| 167 | - } |
|
| 168 | - sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | - unset($GLOBALS[$table][$nom]); |
|
| 170 | - if (!isset($touch[$table])) { |
|
| 171 | - touch_meta($antidate, $table); |
|
| 172 | - $touch[$table] = false; |
|
| 173 | - } |
|
| 159 | + // section critique sur le cache: |
|
| 160 | + // l'invalider avant et apres la MAJ de la BD |
|
| 161 | + // c'est un peu moins bien qu'un vrai verrou mais ca suffira |
|
| 162 | + // et utiliser une statique pour eviter des acces disques a repetition |
|
| 163 | + static $touch = []; |
|
| 164 | + $antidate = time() - (_META_CACHE_TIME << 4); |
|
| 165 | + if (!isset($touch[$table])) { |
|
| 166 | + touch_meta($antidate, $table); |
|
| 167 | + } |
|
| 168 | + sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | + unset($GLOBALS[$table][$nom]); |
|
| 170 | + if (!isset($touch[$table])) { |
|
| 171 | + touch_meta($antidate, $table); |
|
| 172 | + $touch[$table] = false; |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -191,53 +191,53 @@ discard block |
||
| 191 | 191 | **/ |
| 192 | 192 | function ecrire_meta($nom, $valeur, $importable = null, $table = 'meta') { |
| 193 | 193 | |
| 194 | - static $touch = []; |
|
| 195 | - if (!$nom) { |
|
| 196 | - return; |
|
| 197 | - } |
|
| 198 | - include_spip('base/abstract_sql'); |
|
| 199 | - $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | - // table pas encore installee, travailler en php seulement |
|
| 201 | - if (!$res) { |
|
| 202 | - $GLOBALS[$table][$nom] = $valeur; |
|
| 194 | + static $touch = []; |
|
| 195 | + if (!$nom) { |
|
| 196 | + return; |
|
| 197 | + } |
|
| 198 | + include_spip('base/abstract_sql'); |
|
| 199 | + $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | + // table pas encore installee, travailler en php seulement |
|
| 201 | + if (!$res) { |
|
| 202 | + $GLOBALS[$table][$nom] = $valeur; |
|
| 203 | 203 | |
| 204 | - return; |
|
| 205 | - } |
|
| 206 | - $row = sql_fetch($res); |
|
| 207 | - sql_free($res); |
|
| 204 | + return; |
|
| 205 | + } |
|
| 206 | + $row = sql_fetch($res); |
|
| 207 | + sql_free($res); |
|
| 208 | 208 | |
| 209 | - // ne pas invalider le cache si affectation a l'identique |
|
| 210 | - // (tant pis si impt aurait du changer) |
|
| 211 | - if ( |
|
| 212 | - $row and $valeur == $row['valeur'] |
|
| 213 | - and isset($GLOBALS[$table][$nom]) |
|
| 214 | - and $GLOBALS[$table][$nom] == $valeur |
|
| 215 | - ) { |
|
| 216 | - return; |
|
| 217 | - } |
|
| 209 | + // ne pas invalider le cache si affectation a l'identique |
|
| 210 | + // (tant pis si impt aurait du changer) |
|
| 211 | + if ( |
|
| 212 | + $row and $valeur == $row['valeur'] |
|
| 213 | + and isset($GLOBALS[$table][$nom]) |
|
| 214 | + and $GLOBALS[$table][$nom] == $valeur |
|
| 215 | + ) { |
|
| 216 | + return; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - $GLOBALS[$table][$nom] = $valeur; |
|
| 220 | - // cf effacer pour comprendre le double touch |
|
| 221 | - $antidate = time() - (_META_CACHE_TIME << 1); |
|
| 222 | - if (!isset($touch[$table])) { |
|
| 223 | - touch_meta($antidate, $table); |
|
| 224 | - } |
|
| 225 | - $r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')]; |
|
| 226 | - // Gaffe aux tables sans impt (vieilles versions de SPIP notamment) |
|
| 227 | - // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot |
|
| 228 | - // de lecture des descriptions des tables |
|
| 229 | - if ($importable and isset($row['impt'])) { |
|
| 230 | - $r['impt'] = sql_quote($importable, '', 'text'); |
|
| 231 | - } |
|
| 232 | - if ($row) { |
|
| 233 | - sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | - } else { |
|
| 235 | - sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | - } |
|
| 237 | - if (!isset($touch[$table])) { |
|
| 238 | - touch_meta($antidate, $table); |
|
| 239 | - $touch[$table] = false; |
|
| 240 | - } |
|
| 219 | + $GLOBALS[$table][$nom] = $valeur; |
|
| 220 | + // cf effacer pour comprendre le double touch |
|
| 221 | + $antidate = time() - (_META_CACHE_TIME << 1); |
|
| 222 | + if (!isset($touch[$table])) { |
|
| 223 | + touch_meta($antidate, $table); |
|
| 224 | + } |
|
| 225 | + $r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')]; |
|
| 226 | + // Gaffe aux tables sans impt (vieilles versions de SPIP notamment) |
|
| 227 | + // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot |
|
| 228 | + // de lecture des descriptions des tables |
|
| 229 | + if ($importable and isset($row['impt'])) { |
|
| 230 | + $r['impt'] = sql_quote($importable, '', 'text'); |
|
| 231 | + } |
|
| 232 | + if ($row) { |
|
| 233 | + sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | + } else { |
|
| 235 | + sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | + } |
|
| 237 | + if (!isset($touch[$table])) { |
|
| 238 | + touch_meta($antidate, $table); |
|
| 239 | + $touch[$table] = false; |
|
| 240 | + } |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * Nom du fichier cache |
| 250 | 250 | **/ |
| 251 | 251 | function cache_meta($table = 'meta') { |
| 252 | - return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 252 | + return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | * @param string $table |
| 259 | 259 | */ |
| 260 | 260 | function installer_table_meta($table) { |
| 261 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 262 | - if (!$trouver_table("spip_$table")) { |
|
| 263 | - include_spip('base/auxiliaires'); |
|
| 264 | - include_spip('base/create'); |
|
| 265 | - creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false); |
|
| 266 | - $trouver_table(''); |
|
| 267 | - } |
|
| 268 | - lire_metas($table); |
|
| 261 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 262 | + if (!$trouver_table("spip_$table")) { |
|
| 263 | + include_spip('base/auxiliaires'); |
|
| 264 | + include_spip('base/create'); |
|
| 265 | + creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false); |
|
| 266 | + $trouver_table(''); |
|
| 267 | + } |
|
| 268 | + lire_metas($table); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -277,47 +277,47 @@ discard block |
||
| 277 | 277 | * @param bool $force |
| 278 | 278 | */ |
| 279 | 279 | function supprimer_table_meta($table, $force = false) { |
| 280 | - if ($table !== 'meta') { |
|
| 281 | - // Vérifier le contenu restant de la table |
|
| 282 | - $nb_variables = sql_countsel("spip_$table"); |
|
| 280 | + if ($table !== 'meta') { |
|
| 281 | + // Vérifier le contenu restant de la table |
|
| 282 | + $nb_variables = sql_countsel("spip_$table"); |
|
| 283 | 283 | |
| 284 | - // Supprimer si : |
|
| 285 | - // - la table est vide |
|
| 286 | - // - ou limitée à la variable charset |
|
| 287 | - // - ou qu'on force la suppression |
|
| 288 | - if ( |
|
| 289 | - $force |
|
| 290 | - or !$nb_variables |
|
| 291 | - or ( |
|
| 292 | - ($nb_variables == 1) |
|
| 293 | - and isset($GLOBALS[$table]['charset']) |
|
| 294 | - ) |
|
| 295 | - ) { |
|
| 296 | - // Supprimer la table des globaleset de la base |
|
| 297 | - unset($GLOBALS[$table]); |
|
| 298 | - sql_drop_table("spip_$table"); |
|
| 299 | - // Supprimer le fichier cache |
|
| 300 | - include_spip('inc/flock'); |
|
| 301 | - $cache = cache_meta($table); |
|
| 302 | - supprimer_fichier($cache); |
|
| 284 | + // Supprimer si : |
|
| 285 | + // - la table est vide |
|
| 286 | + // - ou limitée à la variable charset |
|
| 287 | + // - ou qu'on force la suppression |
|
| 288 | + if ( |
|
| 289 | + $force |
|
| 290 | + or !$nb_variables |
|
| 291 | + or ( |
|
| 292 | + ($nb_variables == 1) |
|
| 293 | + and isset($GLOBALS[$table]['charset']) |
|
| 294 | + ) |
|
| 295 | + ) { |
|
| 296 | + // Supprimer la table des globaleset de la base |
|
| 297 | + unset($GLOBALS[$table]); |
|
| 298 | + sql_drop_table("spip_$table"); |
|
| 299 | + // Supprimer le fichier cache |
|
| 300 | + include_spip('inc/flock'); |
|
| 301 | + $cache = cache_meta($table); |
|
| 302 | + supprimer_fichier($cache); |
|
| 303 | 303 | |
| 304 | - // vider le cache des tables |
|
| 305 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 306 | - $trouver_table(''); |
|
| 304 | + // vider le cache des tables |
|
| 305 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 306 | + $trouver_table(''); |
|
| 307 | 307 | |
| 308 | - // Supprimer la table de la liste des tables de configuration autres que spip_meta |
|
| 309 | - if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 310 | - $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 311 | - $cle = array_search($table, $liste); |
|
| 312 | - if ($cle !== false) { |
|
| 313 | - unset($liste[$cle]); |
|
| 314 | - if ($liste) { |
|
| 315 | - ecrire_meta('tables_config', serialize($liste)); |
|
| 316 | - } else { |
|
| 317 | - effacer_meta('tables_config'); |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } |
|
| 308 | + // Supprimer la table de la liste des tables de configuration autres que spip_meta |
|
| 309 | + if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 310 | + $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 311 | + $cle = array_search($table, $liste); |
|
| 312 | + if ($cle !== false) { |
|
| 313 | + unset($liste[$cle]); |
|
| 314 | + if ($liste) { |
|
| 315 | + ecrire_meta('tables_config', serialize($liste)); |
|
| 316 | + } else { |
|
| 317 | + effacer_meta('tables_config'); |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | 323 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $row = sql_fetsel( |
| 57 | 57 | 'alea_actuel, alea_futur', |
| 58 | 58 | 'spip_auteurs', |
| 59 | - 'login=' . sql_quote($login, $serveur, 'text'), |
|
| 59 | + 'login='.sql_quote($login, $serveur, 'text'), |
|
| 60 | 60 | '', |
| 61 | 61 | '', |
| 62 | 62 | '', |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | if ($row) { |
| 68 | 68 | include_spip('auth/sha256.inc'); |
| 69 | - $shapass = spip_sha256($row['alea_actuel'] . $pass); |
|
| 70 | - $shanext = spip_sha256($row['alea_futur'] . $pass); |
|
| 71 | - $md5pass = md5($row['alea_actuel'] . $pass); |
|
| 69 | + $shapass = spip_sha256($row['alea_actuel'].$pass); |
|
| 70 | + $shanext = spip_sha256($row['alea_futur'].$pass); |
|
| 71 | + $md5pass = md5($row['alea_actuel'].$pass); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | $row = sql_fetsel( |
| 81 | 81 | '*', |
| 82 | 82 | 'spip_auteurs', |
| 83 | - 'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote( |
|
| 83 | + 'login='.sql_quote($login, $serveur, 'text').' AND pass='.sql_quote( |
|
| 84 | 84 | $shapass, |
| 85 | 85 | $serveur, |
| 86 | 86 | 'text' |
| 87 | - ) . " AND statut<>'5poubelle'", |
|
| 87 | + )." AND statut<>'5poubelle'", |
|
| 88 | 88 | '', |
| 89 | 89 | '', |
| 90 | 90 | '', |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | $row = sql_fetsel( |
| 98 | 98 | '*', |
| 99 | 99 | 'spip_auteurs', |
| 100 | - 'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote( |
|
| 100 | + 'login='.sql_quote($login, $serveur, 'text').' AND pass='.sql_quote( |
|
| 101 | 101 | $md5pass, |
| 102 | 102 | $serveur, |
| 103 | 103 | 'text' |
| 104 | - ) . " AND statut<>'5poubelle'", |
|
| 104 | + )." AND statut<>'5poubelle'", |
|
| 105 | 105 | '', |
| 106 | 106 | '', |
| 107 | 107 | '', |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | 'alea_actuel' => 'alea_futur', |
| 124 | 124 | 'pass' => sql_quote($shanext, $serveur, 'text'), |
| 125 | 125 | 'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text') |
| 126 | - ], 'id_auteur=' . $row['id_auteur'] . ' AND pass IN (' . sql_quote( |
|
| 126 | + ], 'id_auteur='.$row['id_auteur'].' AND pass IN ('.sql_quote( |
|
| 127 | 127 | $shapass, |
| 128 | 128 | $serveur, |
| 129 | 129 | 'text' |
| 130 | - ) . ', ' . sql_quote($md5pass, $serveur, 'text') . ')', '', $serveur); |
|
| 130 | + ).', '.sql_quote($md5pass, $serveur, 'text').')', '', $serveur); |
|
| 131 | 131 | // En profiter pour verifier la securite de tmp/ |
| 132 | 132 | // Si elle ne fonctionne pas a l'installation, prevenir |
| 133 | 133 | if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) { |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | // javascript qui gere la securite du login en evitant de faire circuler le pass en clair |
| 165 | 165 | $flux['data'] .= |
| 166 | - ($compat_md5 ? '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'md5.js"></script>' : '') |
|
| 167 | - . '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'login-sha-min.js"></script>' |
|
| 166 | + ($compat_md5 ? '<script type="text/javascript" src="'._DIR_JAVASCRIPT.'md5.js"></script>' : '') |
|
| 167 | + . '<script type="text/javascript" src="'._DIR_JAVASCRIPT.'login-sha-min.js"></script>' |
|
| 168 | 168 | . '<script type="text/javascript">/*<![CDATA[*/' |
| 169 | - . "var login_info={'alea_actuel':'" . $flux['args']['contexte']['_alea_actuel'] . "'," |
|
| 170 | - . "'alea_futur':'" . $flux['args']['contexte']['_alea_futur'] . "'," |
|
| 171 | - . "'login':'" . $flux['args']['contexte']['var_login'] . "'," |
|
| 172 | - . "'page_auteur': '" . generer_url_public('informer_auteur') . "'," |
|
| 169 | + . "var login_info={'alea_actuel':'".$flux['args']['contexte']['_alea_actuel']."'," |
|
| 170 | + . "'alea_futur':'".$flux['args']['contexte']['_alea_futur']."'," |
|
| 171 | + . "'login':'".$flux['args']['contexte']['var_login']."'," |
|
| 172 | + . "'page_auteur': '".generer_url_public('informer_auteur')."'," |
|
| 173 | 173 | . "'informe_auteur_en_cours':false," |
| 174 | 174 | . "'attente_informe':0," |
| 175 | - . "'compat_md5':" . ($compat_md5 ? 'true' : 'false') . '};' |
|
| 175 | + . "'compat_md5':".($compat_md5 ? 'true' : 'false').'};' |
|
| 176 | 176 | . "jQuery(function(){ |
| 177 | 177 | jQuery('#var_login').change(actualise_auteur); |
| 178 | 178 | jQuery('form#formulaire_login').submit(login_submit); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } else { |
| 216 | 216 | $n = sql_countsel( |
| 217 | 217 | 'spip_auteurs', |
| 218 | - 'login=' . sql_quote($new_login) . ' AND id_auteur!=' . intval($id_auteur) . " AND statut!='5poubelle'", |
|
| 218 | + 'login='.sql_quote($new_login).' AND id_auteur!='.intval($id_auteur)." AND statut!='5poubelle'", |
|
| 219 | 219 | '', |
| 220 | 220 | '', |
| 221 | 221 | $serveur |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | if ( |
| 245 | 245 | !$id_auteur = intval($id_auteur) |
| 246 | - or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 246 | + or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur='.intval($id_auteur), '', '', '', '', $serveur) |
|
| 247 | 247 | ) { |
| 248 | 248 | return false; |
| 249 | 249 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | $anciens = sql_allfetsel( |
| 259 | 259 | 'id_auteur', |
| 260 | 260 | 'spip_auteurs', |
| 261 | - 'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'", |
|
| 261 | + 'login='.sql_quote($new_login, $serveur, 'text')." AND statut='5poubelle'", |
|
| 262 | 262 | '', |
| 263 | 263 | '', |
| 264 | 264 | '', |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | $r = sql_getfetsel( |
| 293 | 293 | 'login', |
| 294 | 294 | 'spip_auteurs', |
| 295 | - "statut<>'5poubelle'" . |
|
| 296 | - ' AND (length(pass)>0)' . |
|
| 295 | + "statut<>'5poubelle'". |
|
| 296 | + ' AND (length(pass)>0)'. |
|
| 297 | 297 | " AND (login=$l)", |
| 298 | 298 | '', |
| 299 | 299 | '', |
@@ -312,8 +312,8 @@ discard block |
||
| 312 | 312 | return sql_getfetsel( |
| 313 | 313 | 'login', |
| 314 | 314 | 'spip_auteurs', |
| 315 | - "statut<>'5poubelle'" . |
|
| 316 | - ' AND (length(pass)>0)' . |
|
| 315 | + "statut<>'5poubelle'". |
|
| 316 | + ' AND (length(pass)>0)'. |
|
| 317 | 317 | " AND (login<>'' AND (nom=$l OR email=$l))", |
| 318 | 318 | '', |
| 319 | 319 | '', |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | if ( |
| 405 | 405 | !$id_auteur = intval($id_auteur) |
| 406 | - or !sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 406 | + or !sql_fetsel('login', 'spip_auteurs', 'id_auteur='.intval($id_auteur), '', '', '', '', $serveur) |
|
| 407 | 407 | ) { |
| 408 | 408 | return false; |
| 409 | 409 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $htpass = generer_htpass($new_pass); |
| 415 | 415 | $alea_actuel = creer_uniqid(); |
| 416 | 416 | $alea_futur = creer_uniqid(); |
| 417 | - $pass = spip_sha256($alea_actuel . $new_pass); |
|
| 417 | + $pass = spip_sha256($alea_actuel.$new_pass); |
|
| 418 | 418 | $c['pass'] = $pass; |
| 419 | 419 | $c['htpass'] = $htpass; |
| 420 | 420 | $c['alea_actuel'] = $alea_actuel; |
@@ -450,8 +450,8 @@ discard block |
||
| 450 | 450 | or isset($champs['statut']) |
| 451 | 451 | or (isset($options['all']) and $options['all']) |
| 452 | 452 | ) { |
| 453 | - $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 454 | - $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 453 | + $htaccess = _DIR_RESTREINT._ACCESS_FILE_NAME; |
|
| 454 | + $htpasswd = _DIR_TMP._AUTH_USER_FILE; |
|
| 455 | 455 | |
| 456 | 456 | // Cette variable de configuration peut etre posee par un plugin |
| 457 | 457 | // par exemple acces_restreint ; |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | and !@file_exists($htaccess) |
| 462 | 462 | ) { |
| 463 | 463 | spip_unlink($htpasswd); |
| 464 | - spip_unlink($htpasswd . '-admin'); |
|
| 464 | + spip_unlink($htpasswd.'-admin'); |
|
| 465 | 465 | |
| 466 | 466 | return; |
| 467 | 467 | } |
@@ -479,16 +479,16 @@ discard block |
||
| 479 | 479 | ); |
| 480 | 480 | while ($t = sql_fetch($s)) { |
| 481 | 481 | if (strlen($t['login']) and strlen($t['htpass'])) { |
| 482 | - $p1 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 482 | + $p1 .= $t['login'].':'.$t['htpass']."\n"; |
|
| 483 | 483 | if ($t['statut'] == '0minirezo') { |
| 484 | - $p2 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 484 | + $p2 .= $t['login'].':'.$t['htpass']."\n"; |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | sql_free($s); |
| 489 | 489 | if ($p1) { |
| 490 | 490 | ecrire_fichier($htpasswd, $p1); |
| 491 | - ecrire_fichier($htpasswd . '-admin', $p2); |
|
| 491 | + ecrire_fichier($htpasswd.'-admin', $p2); |
|
| 492 | 492 | spip_log("Ecriture de $htpasswd et $htpasswd-admin"); |
| 493 | 493 | } |
| 494 | 494 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -32,110 +32,110 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function auth_spip_dist($login, $pass, $serveur = '', $phpauth = false) { |
| 34 | 34 | |
| 35 | - // retrouver le login |
|
| 36 | - $login = auth_spip_retrouver_login($login); |
|
| 37 | - // login inconnu, n'allons pas plus loin |
|
| 38 | - if (!$login) { |
|
| 39 | - return []; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - $md5pass = ''; |
|
| 43 | - $shapass = $shanext = ''; |
|
| 44 | - |
|
| 45 | - if (preg_match(',^\{([0-9a-f]{64});([0-9a-f]{64})\}$,i', $pass, $regs)) { |
|
| 46 | - $shapass = $regs[1]; |
|
| 47 | - $shanext = $regs[2]; |
|
| 48 | - } // compat avec une base mixte md5/sha256 : le js a envoye les 2 hash |
|
| 49 | - elseif (preg_match(',^\{([0-9a-f]{64});([0-9a-f]{64});([0-9a-f]{32});([0-9a-f]{32})\}$,i', $pass, $regs)) { |
|
| 50 | - $shapass = $regs[1]; |
|
| 51 | - $shanext = $regs[2]; |
|
| 52 | - $md5pass = $regs[3]; |
|
| 53 | - //$md5next = $regs[4]; |
|
| 54 | - } // si envoi non crypte, crypter maintenant |
|
| 55 | - elseif ($pass) { |
|
| 56 | - $row = sql_fetsel( |
|
| 57 | - 'alea_actuel, alea_futur', |
|
| 58 | - 'spip_auteurs', |
|
| 59 | - 'login=' . sql_quote($login, $serveur, 'text'), |
|
| 60 | - '', |
|
| 61 | - '', |
|
| 62 | - '', |
|
| 63 | - '', |
|
| 64 | - $serveur |
|
| 65 | - ); |
|
| 66 | - |
|
| 67 | - if ($row) { |
|
| 68 | - include_spip('auth/sha256.inc'); |
|
| 69 | - $shapass = spip_sha256($row['alea_actuel'] . $pass); |
|
| 70 | - $shanext = spip_sha256($row['alea_futur'] . $pass); |
|
| 71 | - $md5pass = md5($row['alea_actuel'] . $pass); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - // login inexistant ou mot de passe vide |
|
| 76 | - if (!$shapass and !$md5pass) { |
|
| 77 | - return []; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - $row = sql_fetsel( |
|
| 81 | - '*', |
|
| 82 | - 'spip_auteurs', |
|
| 83 | - 'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote( |
|
| 84 | - $shapass, |
|
| 85 | - $serveur, |
|
| 86 | - 'text' |
|
| 87 | - ) . " AND statut<>'5poubelle'", |
|
| 88 | - '', |
|
| 89 | - '', |
|
| 90 | - '', |
|
| 91 | - '', |
|
| 92 | - $serveur |
|
| 93 | - ); |
|
| 94 | - |
|
| 95 | - // compat avec les anciennes bases en md5 |
|
| 96 | - if (!$row and $md5pass) { |
|
| 97 | - $row = sql_fetsel( |
|
| 98 | - '*', |
|
| 99 | - 'spip_auteurs', |
|
| 100 | - 'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote( |
|
| 101 | - $md5pass, |
|
| 102 | - $serveur, |
|
| 103 | - 'text' |
|
| 104 | - ) . " AND statut<>'5poubelle'", |
|
| 105 | - '', |
|
| 106 | - '', |
|
| 107 | - '', |
|
| 108 | - '', |
|
| 109 | - $serveur |
|
| 110 | - ); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // login/mot de passe incorrect |
|
| 114 | - if (!$row) { |
|
| 115 | - return []; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // fait tourner le codage du pass dans la base |
|
| 119 | - // sauf si phpauth : cela reviendrait a changer l'alea a chaque hit, et aucune action verifiable par securiser_action() |
|
| 120 | - if ($shanext and !$phpauth) { |
|
| 121 | - include_spip('inc/acces'); // pour creer_uniqid |
|
| 122 | - @sql_update('spip_auteurs', [ |
|
| 123 | - 'alea_actuel' => 'alea_futur', |
|
| 124 | - 'pass' => sql_quote($shanext, $serveur, 'text'), |
|
| 125 | - 'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text') |
|
| 126 | - ], 'id_auteur=' . $row['id_auteur'] . ' AND pass IN (' . sql_quote( |
|
| 127 | - $shapass, |
|
| 128 | - $serveur, |
|
| 129 | - 'text' |
|
| 130 | - ) . ', ' . sql_quote($md5pass, $serveur, 'text') . ')', '', $serveur); |
|
| 131 | - // En profiter pour verifier la securite de tmp/ |
|
| 132 | - // Si elle ne fonctionne pas a l'installation, prevenir |
|
| 133 | - if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) { |
|
| 134 | - return false; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $row; |
|
| 35 | + // retrouver le login |
|
| 36 | + $login = auth_spip_retrouver_login($login); |
|
| 37 | + // login inconnu, n'allons pas plus loin |
|
| 38 | + if (!$login) { |
|
| 39 | + return []; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + $md5pass = ''; |
|
| 43 | + $shapass = $shanext = ''; |
|
| 44 | + |
|
| 45 | + if (preg_match(',^\{([0-9a-f]{64});([0-9a-f]{64})\}$,i', $pass, $regs)) { |
|
| 46 | + $shapass = $regs[1]; |
|
| 47 | + $shanext = $regs[2]; |
|
| 48 | + } // compat avec une base mixte md5/sha256 : le js a envoye les 2 hash |
|
| 49 | + elseif (preg_match(',^\{([0-9a-f]{64});([0-9a-f]{64});([0-9a-f]{32});([0-9a-f]{32})\}$,i', $pass, $regs)) { |
|
| 50 | + $shapass = $regs[1]; |
|
| 51 | + $shanext = $regs[2]; |
|
| 52 | + $md5pass = $regs[3]; |
|
| 53 | + //$md5next = $regs[4]; |
|
| 54 | + } // si envoi non crypte, crypter maintenant |
|
| 55 | + elseif ($pass) { |
|
| 56 | + $row = sql_fetsel( |
|
| 57 | + 'alea_actuel, alea_futur', |
|
| 58 | + 'spip_auteurs', |
|
| 59 | + 'login=' . sql_quote($login, $serveur, 'text'), |
|
| 60 | + '', |
|
| 61 | + '', |
|
| 62 | + '', |
|
| 63 | + '', |
|
| 64 | + $serveur |
|
| 65 | + ); |
|
| 66 | + |
|
| 67 | + if ($row) { |
|
| 68 | + include_spip('auth/sha256.inc'); |
|
| 69 | + $shapass = spip_sha256($row['alea_actuel'] . $pass); |
|
| 70 | + $shanext = spip_sha256($row['alea_futur'] . $pass); |
|
| 71 | + $md5pass = md5($row['alea_actuel'] . $pass); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + // login inexistant ou mot de passe vide |
|
| 76 | + if (!$shapass and !$md5pass) { |
|
| 77 | + return []; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + $row = sql_fetsel( |
|
| 81 | + '*', |
|
| 82 | + 'spip_auteurs', |
|
| 83 | + 'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote( |
|
| 84 | + $shapass, |
|
| 85 | + $serveur, |
|
| 86 | + 'text' |
|
| 87 | + ) . " AND statut<>'5poubelle'", |
|
| 88 | + '', |
|
| 89 | + '', |
|
| 90 | + '', |
|
| 91 | + '', |
|
| 92 | + $serveur |
|
| 93 | + ); |
|
| 94 | + |
|
| 95 | + // compat avec les anciennes bases en md5 |
|
| 96 | + if (!$row and $md5pass) { |
|
| 97 | + $row = sql_fetsel( |
|
| 98 | + '*', |
|
| 99 | + 'spip_auteurs', |
|
| 100 | + 'login=' . sql_quote($login, $serveur, 'text') . ' AND pass=' . sql_quote( |
|
| 101 | + $md5pass, |
|
| 102 | + $serveur, |
|
| 103 | + 'text' |
|
| 104 | + ) . " AND statut<>'5poubelle'", |
|
| 105 | + '', |
|
| 106 | + '', |
|
| 107 | + '', |
|
| 108 | + '', |
|
| 109 | + $serveur |
|
| 110 | + ); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // login/mot de passe incorrect |
|
| 114 | + if (!$row) { |
|
| 115 | + return []; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // fait tourner le codage du pass dans la base |
|
| 119 | + // sauf si phpauth : cela reviendrait a changer l'alea a chaque hit, et aucune action verifiable par securiser_action() |
|
| 120 | + if ($shanext and !$phpauth) { |
|
| 121 | + include_spip('inc/acces'); // pour creer_uniqid |
|
| 122 | + @sql_update('spip_auteurs', [ |
|
| 123 | + 'alea_actuel' => 'alea_futur', |
|
| 124 | + 'pass' => sql_quote($shanext, $serveur, 'text'), |
|
| 125 | + 'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text') |
|
| 126 | + ], 'id_auteur=' . $row['id_auteur'] . ' AND pass IN (' . sql_quote( |
|
| 127 | + $shapass, |
|
| 128 | + $serveur, |
|
| 129 | + 'text' |
|
| 130 | + ) . ', ' . sql_quote($md5pass, $serveur, 'text') . ')', '', $serveur); |
|
| 131 | + // En profiter pour verifier la securite de tmp/ |
|
| 132 | + // Si elle ne fonctionne pas a l'installation, prevenir |
|
| 133 | + if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) { |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return $row; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -145,41 +145,41 @@ discard block |
||
| 145 | 145 | * @return array |
| 146 | 146 | */ |
| 147 | 147 | function auth_spip_formulaire_login($flux) { |
| 148 | - // faut il encore envoyer md5 ? |
|
| 149 | - // on regarde si il reste des pass md5 en base pour des auteurs en statut pas poubelle |
|
| 150 | - // les hash md5 ont une longueur 32, les sha 64 |
|
| 151 | - // en evitant une requete sql a chaque affichage du formulaire login sans session |
|
| 152 | - // (perf issue pour les sites qui mettent le formulaire de login sur la home) |
|
| 153 | - $compat_md5 = false; |
|
| 154 | - if (!isset($GLOBALS['meta']['sha_256_only']) or _request('var_mode')) { |
|
| 155 | - $compat_md5 = sql_countsel('spip_auteurs', "length(pass)=32 AND statut<>'poubelle'"); |
|
| 156 | - if ($compat_md5 and isset($GLOBALS['meta']['sha_256_only'])) { |
|
| 157 | - effacer_meta('sha_256_only'); |
|
| 158 | - } |
|
| 159 | - if (!$compat_md5) { |
|
| 160 | - ecrire_meta('sha_256_only', 'oui'); |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - // javascript qui gere la securite du login en evitant de faire circuler le pass en clair |
|
| 165 | - $flux['data'] .= |
|
| 166 | - ($compat_md5 ? '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'md5.js"></script>' : '') |
|
| 167 | - . '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'login-sha-min.js"></script>' |
|
| 168 | - . '<script type="text/javascript">/*<![CDATA[*/' |
|
| 169 | - . "var login_info={'alea_actuel':'" . $flux['args']['contexte']['_alea_actuel'] . "'," |
|
| 170 | - . "'alea_futur':'" . $flux['args']['contexte']['_alea_futur'] . "'," |
|
| 171 | - . "'login':'" . $flux['args']['contexte']['var_login'] . "'," |
|
| 172 | - . "'page_auteur': '" . generer_url_public('informer_auteur') . "'," |
|
| 173 | - . "'informe_auteur_en_cours':false," |
|
| 174 | - . "'attente_informe':0," |
|
| 175 | - . "'compat_md5':" . ($compat_md5 ? 'true' : 'false') . '};' |
|
| 176 | - . "jQuery(function(){ |
|
| 148 | + // faut il encore envoyer md5 ? |
|
| 149 | + // on regarde si il reste des pass md5 en base pour des auteurs en statut pas poubelle |
|
| 150 | + // les hash md5 ont une longueur 32, les sha 64 |
|
| 151 | + // en evitant une requete sql a chaque affichage du formulaire login sans session |
|
| 152 | + // (perf issue pour les sites qui mettent le formulaire de login sur la home) |
|
| 153 | + $compat_md5 = false; |
|
| 154 | + if (!isset($GLOBALS['meta']['sha_256_only']) or _request('var_mode')) { |
|
| 155 | + $compat_md5 = sql_countsel('spip_auteurs', "length(pass)=32 AND statut<>'poubelle'"); |
|
| 156 | + if ($compat_md5 and isset($GLOBALS['meta']['sha_256_only'])) { |
|
| 157 | + effacer_meta('sha_256_only'); |
|
| 158 | + } |
|
| 159 | + if (!$compat_md5) { |
|
| 160 | + ecrire_meta('sha_256_only', 'oui'); |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + // javascript qui gere la securite du login en evitant de faire circuler le pass en clair |
|
| 165 | + $flux['data'] .= |
|
| 166 | + ($compat_md5 ? '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'md5.js"></script>' : '') |
|
| 167 | + . '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'login-sha-min.js"></script>' |
|
| 168 | + . '<script type="text/javascript">/*<![CDATA[*/' |
|
| 169 | + . "var login_info={'alea_actuel':'" . $flux['args']['contexte']['_alea_actuel'] . "'," |
|
| 170 | + . "'alea_futur':'" . $flux['args']['contexte']['_alea_futur'] . "'," |
|
| 171 | + . "'login':'" . $flux['args']['contexte']['var_login'] . "'," |
|
| 172 | + . "'page_auteur': '" . generer_url_public('informer_auteur') . "'," |
|
| 173 | + . "'informe_auteur_en_cours':false," |
|
| 174 | + . "'attente_informe':0," |
|
| 175 | + . "'compat_md5':" . ($compat_md5 ? 'true' : 'false') . '};' |
|
| 176 | + . "jQuery(function(){ |
|
| 177 | 177 | jQuery('#var_login').change(actualise_auteur); |
| 178 | 178 | jQuery('form#formulaire_login').submit(login_submit); |
| 179 | 179 | });" |
| 180 | - . '/*]]>*/</script>'; |
|
| 180 | + . '/*]]>*/</script>'; |
|
| 181 | 181 | |
| 182 | - return $flux; |
|
| 182 | + return $flux; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | * toujours true pour un auteur cree dans SPIP |
| 192 | 192 | */ |
| 193 | 193 | function auth_spip_autoriser_modifier_login(string $serveur = ''): bool { |
| 194 | - // les fonctions d'ecriture sur base distante sont encore incompletes |
|
| 195 | - if (strlen($serveur)) { |
|
| 196 | - return false; |
|
| 197 | - } |
|
| 198 | - return true; |
|
| 194 | + // les fonctions d'ecriture sur base distante sont encore incompletes |
|
| 195 | + if (strlen($serveur)) { |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 198 | + return true; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -209,25 +209,25 @@ discard block |
||
| 209 | 209 | * message d'erreur si login non valide, chaine vide sinon |
| 210 | 210 | */ |
| 211 | 211 | function auth_spip_verifier_login($new_login, $id_auteur = 0, $serveur = '') { |
| 212 | - // login et mot de passe |
|
| 213 | - if (strlen($new_login)) { |
|
| 214 | - if (strlen($new_login) < _LOGIN_TROP_COURT) { |
|
| 215 | - return _T('info_login_trop_court_car_pluriel', ['nb' => _LOGIN_TROP_COURT]); |
|
| 216 | - } else { |
|
| 217 | - $n = sql_countsel( |
|
| 218 | - 'spip_auteurs', |
|
| 219 | - 'login=' . sql_quote($new_login) . ' AND id_auteur!=' . intval($id_auteur) . " AND statut!='5poubelle'", |
|
| 220 | - '', |
|
| 221 | - '', |
|
| 222 | - $serveur |
|
| 223 | - ); |
|
| 224 | - if ($n) { |
|
| 225 | - return _T('info_login_existant'); |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - return ''; |
|
| 212 | + // login et mot de passe |
|
| 213 | + if (strlen($new_login)) { |
|
| 214 | + if (strlen($new_login) < _LOGIN_TROP_COURT) { |
|
| 215 | + return _T('info_login_trop_court_car_pluriel', ['nb' => _LOGIN_TROP_COURT]); |
|
| 216 | + } else { |
|
| 217 | + $n = sql_countsel( |
|
| 218 | + 'spip_auteurs', |
|
| 219 | + 'login=' . sql_quote($new_login) . ' AND id_auteur!=' . intval($id_auteur) . " AND statut!='5poubelle'", |
|
| 220 | + '', |
|
| 221 | + '', |
|
| 222 | + $serveur |
|
| 223 | + ); |
|
| 224 | + if ($n) { |
|
| 225 | + return _T('info_login_existant'); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + return ''; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -239,41 +239,41 @@ discard block |
||
| 239 | 239 | * @return bool |
| 240 | 240 | */ |
| 241 | 241 | function auth_spip_modifier_login($new_login, $id_auteur, $serveur = '') { |
| 242 | - if (is_null($new_login) or auth_spip_verifier_login($new_login, $id_auteur, $serveur) != '') { |
|
| 243 | - return false; |
|
| 244 | - } |
|
| 245 | - if ( |
|
| 246 | - !$id_auteur = intval($id_auteur) |
|
| 247 | - or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 248 | - ) { |
|
| 249 | - return false; |
|
| 250 | - } |
|
| 251 | - if ($new_login == $auteur['login']) { |
|
| 252 | - return true; |
|
| 253 | - } // on a rien fait mais c'est bon ! |
|
| 254 | - |
|
| 255 | - include_spip('action/editer_auteur'); |
|
| 256 | - |
|
| 257 | - // vider le login des auteurs a la poubelle qui avaient ce meme login |
|
| 258 | - if (strlen($new_login)) { |
|
| 259 | - $anciens = sql_allfetsel( |
|
| 260 | - 'id_auteur', |
|
| 261 | - 'spip_auteurs', |
|
| 262 | - 'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'", |
|
| 263 | - '', |
|
| 264 | - '', |
|
| 265 | - '', |
|
| 266 | - '', |
|
| 267 | - $serveur |
|
| 268 | - ); |
|
| 269 | - while ($row = array_pop($anciens)) { |
|
| 270 | - auteur_modifier($row['id_auteur'], ['login' => ''], true); // manque la gestion de $serveur |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - auteur_modifier($id_auteur, ['login' => $new_login], true); // manque la gestion de $serveur |
|
| 275 | - |
|
| 276 | - return true; |
|
| 242 | + if (is_null($new_login) or auth_spip_verifier_login($new_login, $id_auteur, $serveur) != '') { |
|
| 243 | + return false; |
|
| 244 | + } |
|
| 245 | + if ( |
|
| 246 | + !$id_auteur = intval($id_auteur) |
|
| 247 | + or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 248 | + ) { |
|
| 249 | + return false; |
|
| 250 | + } |
|
| 251 | + if ($new_login == $auteur['login']) { |
|
| 252 | + return true; |
|
| 253 | + } // on a rien fait mais c'est bon ! |
|
| 254 | + |
|
| 255 | + include_spip('action/editer_auteur'); |
|
| 256 | + |
|
| 257 | + // vider le login des auteurs a la poubelle qui avaient ce meme login |
|
| 258 | + if (strlen($new_login)) { |
|
| 259 | + $anciens = sql_allfetsel( |
|
| 260 | + 'id_auteur', |
|
| 261 | + 'spip_auteurs', |
|
| 262 | + 'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'", |
|
| 263 | + '', |
|
| 264 | + '', |
|
| 265 | + '', |
|
| 266 | + '', |
|
| 267 | + $serveur |
|
| 268 | + ); |
|
| 269 | + while ($row = array_pop($anciens)) { |
|
| 270 | + auteur_modifier($row['id_auteur'], ['login' => ''], true); // manque la gestion de $serveur |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + auteur_modifier($id_auteur, ['login' => $new_login], true); // manque la gestion de $serveur |
|
| 275 | + |
|
| 276 | + return true; |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -285,44 +285,44 @@ discard block |
||
| 285 | 285 | * @return string |
| 286 | 286 | */ |
| 287 | 287 | function auth_spip_retrouver_login($login, $serveur = '') { |
| 288 | - if (!strlen($login)) { |
|
| 289 | - return null; |
|
| 290 | - } // pas la peine de requeter |
|
| 291 | - $l = sql_quote($login, $serveur, 'text'); |
|
| 292 | - if ( |
|
| 293 | - $r = sql_getfetsel( |
|
| 294 | - 'login', |
|
| 295 | - 'spip_auteurs', |
|
| 296 | - "statut<>'5poubelle'" . |
|
| 297 | - ' AND (length(pass)>0)' . |
|
| 298 | - " AND (login=$l)", |
|
| 299 | - '', |
|
| 300 | - '', |
|
| 301 | - '', |
|
| 302 | - '', |
|
| 303 | - $serveur |
|
| 304 | - ) |
|
| 305 | - ) { |
|
| 306 | - return $r; |
|
| 307 | - } |
|
| 308 | - // Si pas d'auteur avec ce login |
|
| 309 | - // regarder s'il a saisi son nom ou son mail. |
|
| 310 | - // Ne pas fusionner avec la requete precedente |
|
| 311 | - // car un nom peut etre homonyme d'un autre login |
|
| 312 | - else { |
|
| 313 | - return sql_getfetsel( |
|
| 314 | - 'login', |
|
| 315 | - 'spip_auteurs', |
|
| 316 | - "statut<>'5poubelle'" . |
|
| 317 | - ' AND (length(pass)>0)' . |
|
| 318 | - " AND (login<>'' AND (nom=$l OR email=$l))", |
|
| 319 | - '', |
|
| 320 | - '', |
|
| 321 | - '', |
|
| 322 | - '', |
|
| 323 | - $serveur |
|
| 324 | - ); |
|
| 325 | - } |
|
| 288 | + if (!strlen($login)) { |
|
| 289 | + return null; |
|
| 290 | + } // pas la peine de requeter |
|
| 291 | + $l = sql_quote($login, $serveur, 'text'); |
|
| 292 | + if ( |
|
| 293 | + $r = sql_getfetsel( |
|
| 294 | + 'login', |
|
| 295 | + 'spip_auteurs', |
|
| 296 | + "statut<>'5poubelle'" . |
|
| 297 | + ' AND (length(pass)>0)' . |
|
| 298 | + " AND (login=$l)", |
|
| 299 | + '', |
|
| 300 | + '', |
|
| 301 | + '', |
|
| 302 | + '', |
|
| 303 | + $serveur |
|
| 304 | + ) |
|
| 305 | + ) { |
|
| 306 | + return $r; |
|
| 307 | + } |
|
| 308 | + // Si pas d'auteur avec ce login |
|
| 309 | + // regarder s'il a saisi son nom ou son mail. |
|
| 310 | + // Ne pas fusionner avec la requete precedente |
|
| 311 | + // car un nom peut etre homonyme d'un autre login |
|
| 312 | + else { |
|
| 313 | + return sql_getfetsel( |
|
| 314 | + 'login', |
|
| 315 | + 'spip_auteurs', |
|
| 316 | + "statut<>'5poubelle'" . |
|
| 317 | + ' AND (length(pass)>0)' . |
|
| 318 | + " AND (login<>'' AND (nom=$l OR email=$l))", |
|
| 319 | + '', |
|
| 320 | + '', |
|
| 321 | + '', |
|
| 322 | + '', |
|
| 323 | + $serveur |
|
| 324 | + ); |
|
| 325 | + } |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | |
@@ -340,11 +340,11 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | function auth_spip_informer_login($infos, $row, $serveur = '') { |
| 342 | 342 | |
| 343 | - // pour la methode SPIP on a besoin des alea en plus pour encoder le pass avec |
|
| 344 | - $infos['alea_actuel'] = $row['alea_actuel']; |
|
| 345 | - $infos['alea_futur'] = $row['alea_futur']; |
|
| 343 | + // pour la methode SPIP on a besoin des alea en plus pour encoder le pass avec |
|
| 344 | + $infos['alea_actuel'] = $row['alea_actuel']; |
|
| 345 | + $infos['alea_futur'] = $row['alea_futur']; |
|
| 346 | 346 | |
| 347 | - return $infos; |
|
| 347 | + return $infos; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -355,11 +355,11 @@ discard block |
||
| 355 | 355 | * toujours true pour un auteur cree dans SPIP |
| 356 | 356 | */ |
| 357 | 357 | function auth_spip_autoriser_modifier_pass(string $serveur = ''): bool { |
| 358 | - // les fonctions d'ecriture sur base distante sont encore incompletes |
|
| 359 | - if (strlen($serveur)) { |
|
| 360 | - return false; |
|
| 361 | - } |
|
| 362 | - return true; |
|
| 358 | + // les fonctions d'ecriture sur base distante sont encore incompletes |
|
| 359 | + if (strlen($serveur)) { |
|
| 360 | + return false; |
|
| 361 | + } |
|
| 362 | + return true; |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | |
@@ -380,12 +380,12 @@ discard block |
||
| 380 | 380 | * message d'erreur si login non valide, chaine vide sinon |
| 381 | 381 | */ |
| 382 | 382 | function auth_spip_verifier_pass($login, $new_pass, $id_auteur = 0, $serveur = '') { |
| 383 | - // login et mot de passe |
|
| 384 | - if (strlen($new_pass) < _PASS_LONGUEUR_MINI) { |
|
| 385 | - return _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]); |
|
| 386 | - } |
|
| 383 | + // login et mot de passe |
|
| 384 | + if (strlen($new_pass) < _PASS_LONGUEUR_MINI) { |
|
| 385 | + return _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]); |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - return ''; |
|
| 388 | + return ''; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -399,34 +399,34 @@ discard block |
||
| 399 | 399 | * @return bool |
| 400 | 400 | */ |
| 401 | 401 | function auth_spip_modifier_pass($login, $new_pass, $id_auteur, $serveur = '') { |
| 402 | - if (is_null($new_pass) or auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 403 | - return false; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - if ( |
|
| 407 | - !$id_auteur = intval($id_auteur) |
|
| 408 | - or !sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 409 | - ) { |
|
| 410 | - return false; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - $c = []; |
|
| 414 | - include_spip('inc/acces'); |
|
| 415 | - include_spip('auth/sha256.inc'); |
|
| 416 | - $htpass = generer_htpass($new_pass); |
|
| 417 | - $alea_actuel = creer_uniqid(); |
|
| 418 | - $alea_futur = creer_uniqid(); |
|
| 419 | - $pass = spip_sha256($alea_actuel . $new_pass); |
|
| 420 | - $c['pass'] = $pass; |
|
| 421 | - $c['htpass'] = $htpass; |
|
| 422 | - $c['alea_actuel'] = $alea_actuel; |
|
| 423 | - $c['alea_futur'] = $alea_futur; |
|
| 424 | - $c['low_sec'] = ''; |
|
| 425 | - |
|
| 426 | - include_spip('action/editer_auteur'); |
|
| 427 | - auteur_modifier($id_auteur, $c, true); // manque la gestion de $serveur |
|
| 428 | - |
|
| 429 | - return true; // on a bien modifie le pass |
|
| 402 | + if (is_null($new_pass) or auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 403 | + return false; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + if ( |
|
| 407 | + !$id_auteur = intval($id_auteur) |
|
| 408 | + or !sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 409 | + ) { |
|
| 410 | + return false; |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + $c = []; |
|
| 414 | + include_spip('inc/acces'); |
|
| 415 | + include_spip('auth/sha256.inc'); |
|
| 416 | + $htpass = generer_htpass($new_pass); |
|
| 417 | + $alea_actuel = creer_uniqid(); |
|
| 418 | + $alea_futur = creer_uniqid(); |
|
| 419 | + $pass = spip_sha256($alea_actuel . $new_pass); |
|
| 420 | + $c['pass'] = $pass; |
|
| 421 | + $c['htpass'] = $htpass; |
|
| 422 | + $c['alea_actuel'] = $alea_actuel; |
|
| 423 | + $c['alea_futur'] = $alea_futur; |
|
| 424 | + $c['low_sec'] = ''; |
|
| 425 | + |
|
| 426 | + include_spip('action/editer_auteur'); |
|
| 427 | + auteur_modifier($id_auteur, $c, true); // manque la gestion de $serveur |
|
| 428 | + |
|
| 429 | + return true; // on a bien modifie le pass |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -440,58 +440,58 @@ discard block |
||
| 440 | 440 | * @return void |
| 441 | 441 | */ |
| 442 | 442 | function auth_spip_synchroniser_distant($id_auteur, $champs, $options = [], string $serveur = '') : void { |
| 443 | - // ne rien faire pour une base distante : on ne sait pas regenerer les htaccess |
|
| 444 | - if (strlen($serveur)) { |
|
| 445 | - return; |
|
| 446 | - } |
|
| 447 | - // si un login, pass ou statut a ete modifie |
|
| 448 | - // regenerer les fichier htpass |
|
| 449 | - if ( |
|
| 450 | - isset($champs['login']) |
|
| 451 | - or isset($champs['pass']) |
|
| 452 | - or isset($champs['statut']) |
|
| 453 | - or (isset($options['all']) and $options['all']) |
|
| 454 | - ) { |
|
| 455 | - $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 456 | - $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 457 | - |
|
| 458 | - // Cette variable de configuration peut etre posee par un plugin |
|
| 459 | - // par exemple acces_restreint ; |
|
| 460 | - // si .htaccess existe, outrepasser spip_meta |
|
| 461 | - if ( |
|
| 462 | - (!isset($GLOBALS['meta']['creer_htpasswd']) or ($GLOBALS['meta']['creer_htpasswd'] != 'oui')) |
|
| 463 | - and !@file_exists($htaccess) |
|
| 464 | - ) { |
|
| 465 | - spip_unlink($htpasswd); |
|
| 466 | - spip_unlink($htpasswd . '-admin'); |
|
| 467 | - |
|
| 468 | - return; |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre |
|
| 472 | - # de devenir redacteur le cas echeant (auth http)... a nettoyer |
|
| 473 | - // attention, il faut au prealable se connecter a la base (necessaire car utilise par install) |
|
| 474 | - |
|
| 475 | - $p1 = ''; // login:htpass pour tous |
|
| 476 | - $p2 = ''; // login:htpass pour les admins |
|
| 477 | - $s = sql_select( |
|
| 478 | - 'login, htpass, statut', |
|
| 479 | - 'spip_auteurs', |
|
| 480 | - sql_in('statut', ['1comite', '0minirezo', 'nouveau']) |
|
| 481 | - ); |
|
| 482 | - while ($t = sql_fetch($s)) { |
|
| 483 | - if (strlen($t['login']) and strlen($t['htpass'])) { |
|
| 484 | - $p1 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 485 | - if ($t['statut'] == '0minirezo') { |
|
| 486 | - $p2 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 487 | - } |
|
| 488 | - } |
|
| 489 | - } |
|
| 490 | - sql_free($s); |
|
| 491 | - if ($p1) { |
|
| 492 | - ecrire_fichier($htpasswd, $p1); |
|
| 493 | - ecrire_fichier($htpasswd . '-admin', $p2); |
|
| 494 | - spip_log("Ecriture de $htpasswd et $htpasswd-admin"); |
|
| 495 | - } |
|
| 496 | - } |
|
| 443 | + // ne rien faire pour une base distante : on ne sait pas regenerer les htaccess |
|
| 444 | + if (strlen($serveur)) { |
|
| 445 | + return; |
|
| 446 | + } |
|
| 447 | + // si un login, pass ou statut a ete modifie |
|
| 448 | + // regenerer les fichier htpass |
|
| 449 | + if ( |
|
| 450 | + isset($champs['login']) |
|
| 451 | + or isset($champs['pass']) |
|
| 452 | + or isset($champs['statut']) |
|
| 453 | + or (isset($options['all']) and $options['all']) |
|
| 454 | + ) { |
|
| 455 | + $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 456 | + $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 457 | + |
|
| 458 | + // Cette variable de configuration peut etre posee par un plugin |
|
| 459 | + // par exemple acces_restreint ; |
|
| 460 | + // si .htaccess existe, outrepasser spip_meta |
|
| 461 | + if ( |
|
| 462 | + (!isset($GLOBALS['meta']['creer_htpasswd']) or ($GLOBALS['meta']['creer_htpasswd'] != 'oui')) |
|
| 463 | + and !@file_exists($htaccess) |
|
| 464 | + ) { |
|
| 465 | + spip_unlink($htpasswd); |
|
| 466 | + spip_unlink($htpasswd . '-admin'); |
|
| 467 | + |
|
| 468 | + return; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre |
|
| 472 | + # de devenir redacteur le cas echeant (auth http)... a nettoyer |
|
| 473 | + // attention, il faut au prealable se connecter a la base (necessaire car utilise par install) |
|
| 474 | + |
|
| 475 | + $p1 = ''; // login:htpass pour tous |
|
| 476 | + $p2 = ''; // login:htpass pour les admins |
|
| 477 | + $s = sql_select( |
|
| 478 | + 'login, htpass, statut', |
|
| 479 | + 'spip_auteurs', |
|
| 480 | + sql_in('statut', ['1comite', '0minirezo', 'nouveau']) |
|
| 481 | + ); |
|
| 482 | + while ($t = sql_fetch($s)) { |
|
| 483 | + if (strlen($t['login']) and strlen($t['htpass'])) { |
|
| 484 | + $p1 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 485 | + if ($t['statut'] == '0minirezo') { |
|
| 486 | + $p2 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | + } |
|
| 490 | + sql_free($s); |
|
| 491 | + if ($p1) { |
|
| 492 | + ecrire_fichier($htpasswd, $p1); |
|
| 493 | + ecrire_fichier($htpasswd . '-admin', $p2); |
|
| 494 | + spip_log("Ecriture de $htpasswd et $htpasswd-admin"); |
|
| 495 | + } |
|
| 496 | + } |
|
| 497 | 497 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG_ECRIRE($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | * Liste (lang) des arguments collectés et fournis. |
| 56 | 56 | */ |
| 57 | 57 | function balise_MENU_LANG_ECRIRE_stat($args, $context_compil) { |
| 58 | - include_spip('inc/lang'); |
|
| 59 | - if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 58 | + include_spip('inc/lang'); |
|
| 59 | + if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return $args; |
|
| 63 | + return $args; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * Liste : Chemin du squelette, durée du cache, contexte |
| 77 | 77 | **/ |
| 78 | 78 | function balise_MENU_LANG_ECRIRE_dyn($opt) { |
| 79 | - return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 79 | + return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -96,30 +96,30 @@ discard block |
||
| 96 | 96 | * Liste : Chemin du squelette, durée du cache, contexte |
| 97 | 97 | **/ |
| 98 | 98 | function menu_lang_pour_tous($nom, $default) { |
| 99 | - include_spip('inc/lang'); |
|
| 99 | + include_spip('inc/lang'); |
|
| 100 | 100 | |
| 101 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 102 | - $opt = lang_select($default); # et remplace |
|
| 103 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 104 | - $default = ''; # annule tout choix par defaut |
|
| 105 | - if ($opt) { |
|
| 106 | - lang_select(); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - } |
|
| 101 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 102 | + $opt = lang_select($default); # et remplace |
|
| 103 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 104 | + $default = ''; # annule tout choix par defaut |
|
| 105 | + if ($opt) { |
|
| 106 | + lang_select(); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - # lien a partir de / |
|
| 112 | - $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 113 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), '&'); |
|
| 111 | + # lien a partir de / |
|
| 112 | + $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 113 | + $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), '&'); |
|
| 114 | 114 | |
| 115 | - return [ |
|
| 116 | - 'formulaires/menu_lang', |
|
| 117 | - 3600, |
|
| 118 | - [ |
|
| 119 | - 'nom' => $nom, |
|
| 120 | - 'url' => $post, |
|
| 121 | - 'name' => $nom, |
|
| 122 | - 'default' => $default, |
|
| 123 | - ] |
|
| 124 | - ]; |
|
| 115 | + return [ |
|
| 116 | + 'formulaires/menu_lang', |
|
| 117 | + 3600, |
|
| 118 | + [ |
|
| 119 | + 'nom' => $nom, |
|
| 120 | + 'url' => $post, |
|
| 121 | + 'name' => $nom, |
|
| 122 | + 'default' => $default, |
|
| 123 | + ] |
|
| 124 | + ]; |
|
| 125 | 125 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | include_spip('inc/lang'); |
| 100 | 100 | |
| 101 | 101 | if ($GLOBALS['spip_lang'] <> $default) { |
| 102 | - $opt = lang_select($default); # et remplace |
|
| 102 | + $opt = lang_select($default); # et remplace |
|
| 103 | 103 | if ($GLOBALS['spip_lang'] <> $default) { |
| 104 | - $default = ''; # annule tout choix par defaut |
|
| 104 | + $default = ''; # annule tout choix par defaut |
|
| 105 | 105 | if ($opt) { |
| 106 | 106 | lang_select(); |
| 107 | 107 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | # lien a partir de / |
| 112 | 112 | $cible = parametre_url(self(), 'lang', '', '&'); |
| 113 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), '&'); |
|
| 113 | + $post = generer_url_action('converser', 'redirect='.rawurlencode($cible), '&'); |
|
| 114 | 114 | |
| 115 | 115 | return [ |
| 116 | 116 | 'formulaires/menu_lang', |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * Liste (lang) des arguments collectés et fournis. |
| 56 | 56 | */ |
| 57 | 57 | function balise_MENU_LANG_stat($args, $context_compil) { |
| 58 | - if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 58 | + if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return $args; |
|
| 62 | + return $args; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * Liste : Chemin du squelette, durée du cache, contexte |
| 76 | 76 | **/ |
| 77 | 77 | function balise_MENU_LANG_dyn($opt) { |
| 78 | - include_spip('balise/menu_lang_ecrire'); |
|
| 78 | + include_spip('balise/menu_lang_ecrire'); |
|
| 79 | 79 | |
| 80 | - return menu_lang_pour_tous('var_lang', $opt); |
|
| 80 | + return menu_lang_pour_tous('var_lang', $opt); |
|
| 81 | 81 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | function generer_generer_url_arg($type, $p, $_id) { |
| 76 | 76 | if ($s = trouver_nom_serveur_distant($p)) { |
| 77 | 77 | // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
| 78 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 78 | + if (function_exists($f = 'generer_generer_url_'.$s)) { |
|
| 79 | 79 | return $f($type, $_id, $s); |
| 80 | 80 | } |
| 81 | 81 | if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | # exception des urls de documents sur un serveur distant... |
| 86 | 86 | if ($type == 'document') { |
| 87 | 87 | return |
| 88 | - "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | - "quete_meta('dir_img', $s) . \n\t" . |
|
| 88 | + "quete_meta('adresse_site', $s) . '/' .\n\t". |
|
| 89 | + "quete_meta('dir_img', $s) . \n\t". |
|
| 90 | 90 | "quete_fichier($_id,$s)"; |
| 91 | 91 | } |
| 92 | 92 | $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | function balise_URL_SITE_SPIP_dist($p) { |
| 232 | 232 | $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
| 233 | - $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 233 | + $p->code = 'spip_htmlspecialchars('.$p->code.')'; |
|
| 234 | 234 | $p->interdire_scripts = false; |
| 235 | 235 | |
| 236 | 236 | return $p; |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | if ($s = trouver_nom_serveur_distant($p)) { |
| 272 | 272 | // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
| 273 | 273 | // elle devra aussi traiter le cas derogatoire type=page |
| 274 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 274 | + if (function_exists($f = 'generer_generer_url_'.$s)) { |
|
| 275 | 275 | if ($args and $args !== "''") { |
| 276 | 276 | $code .= ", $args"; |
| 277 | 277 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $p->code = $code; |
| 280 | 280 | return $p; |
| 281 | 281 | } |
| 282 | - $s = 'connect=' . addslashes($s); |
|
| 282 | + $s = 'connect='.addslashes($s); |
|
| 283 | 283 | $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $code = "generer_url_public($code, $args$noentities)"; |
| 295 | 295 | } |
| 296 | 296 | $p->code = $code; |
| 297 | - spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 297 | + spip_log("Calcul url page : connect vaut $s ca donne :".$p->code." args $args", _LOG_INFO); |
|
| 298 | 298 | |
| 299 | 299 | #$p->interdire_scripts = true; |
| 300 | 300 | return $p; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $fonc .= ",$args$noentities"; |
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | - $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 341 | + $p->code = 'generer_url_ecrire('.$fonc.')'; |
|
| 342 | 342 | $p->interdire_scripts = false; |
| 343 | 343 | |
| 344 | 344 | return $p; |
@@ -373,17 +373,17 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $args = interprete_argument_balise(2, $p); |
| 375 | 375 | if ($args != "''" && $args !== null) { |
| 376 | - $p->code .= ',' . $args; |
|
| 376 | + $p->code .= ','.$args; |
|
| 377 | 377 | } |
| 378 | 378 | $redirect = interprete_argument_balise(3, $p); |
| 379 | 379 | if ($redirect != "''" && $redirect !== null) { |
| 380 | 380 | if ($args == "''" || $args === null) { |
| 381 | 381 | $p->code .= ",''"; |
| 382 | 382 | } |
| 383 | - $p->code .= ',' . $redirect; |
|
| 383 | + $p->code .= ','.$redirect; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 386 | + $p->code = 'generer_action_auteur('.$p->code.')'; |
|
| 387 | 387 | $p->interdire_scripts = false; |
| 388 | 388 | |
| 389 | 389 | return $p; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | * Code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function generer_generer_url($type, $p) { |
| 40 | - $_id = interprete_argument_balise(1, $p); |
|
| 40 | + $_id = interprete_argument_balise(1, $p); |
|
| 41 | 41 | |
| 42 | - if (!$_id) { |
|
| 43 | - $primary = id_table_objet($type); |
|
| 44 | - $_id = champ_sql($primary, $p); |
|
| 45 | - } |
|
| 42 | + if (!$_id) { |
|
| 43 | + $primary = id_table_objet($type); |
|
| 44 | + $_id = champ_sql($primary, $p); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return generer_generer_url_arg($type, $p, $_id); |
|
| 47 | + return generer_generer_url_arg($type, $p, $_id); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -73,28 +73,28 @@ discard block |
||
| 73 | 73 | * Code compilé |
| 74 | 74 | **/ |
| 75 | 75 | function generer_generer_url_arg($type, $p, $_id) { |
| 76 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 77 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 78 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 79 | - return $f($type, $_id, $s); |
|
| 80 | - } |
|
| 81 | - if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
|
| 82 | - return null; |
|
| 83 | - } |
|
| 84 | - $s = _q($s); |
|
| 85 | - # exception des urls de documents sur un serveur distant... |
|
| 86 | - if ($type == 'document') { |
|
| 87 | - return |
|
| 88 | - "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | - "quete_meta('dir_img', $s) . \n\t" . |
|
| 90 | - "quete_fichier($_id,$s)"; |
|
| 91 | - } |
|
| 92 | - $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 93 | - } else { |
|
| 94 | - $s = ", '', '', true"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 76 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 77 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 78 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 79 | + return $f($type, $_id, $s); |
|
| 80 | + } |
|
| 81 | + if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
|
| 82 | + return null; |
|
| 83 | + } |
|
| 84 | + $s = _q($s); |
|
| 85 | + # exception des urls de documents sur un serveur distant... |
|
| 86 | + if ($type == 'document') { |
|
| 87 | + return |
|
| 88 | + "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | + "quete_meta('dir_img', $s) . \n\t" . |
|
| 90 | + "quete_fichier($_id,$s)"; |
|
| 91 | + } |
|
| 92 | + $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 93 | + } else { |
|
| 94 | + $s = ", '', '', true"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -119,27 +119,27 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function balise_URL__dist($p) { |
| 121 | 121 | |
| 122 | - $nom = $p->nom_champ; |
|
| 123 | - if ($nom === 'URL_') { |
|
| 124 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 125 | - erreur_squelette($msg, $p); |
|
| 126 | - $p->interdire_scripts = false; |
|
| 127 | - |
|
| 128 | - return $p; |
|
| 129 | - } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 130 | - return $f($p); |
|
| 131 | - } else { |
|
| 132 | - $nom = strtolower($nom); |
|
| 133 | - $code = generer_generer_url(substr($nom, 4), $p); |
|
| 134 | - $code = champ_sql($nom, $p, $code); |
|
| 135 | - $p->code = $code; |
|
| 136 | - if (!$p->etoile) { |
|
| 137 | - $p->code = "vider_url($code)"; |
|
| 138 | - } |
|
| 139 | - $p->interdire_scripts = false; |
|
| 140 | - |
|
| 141 | - return $p; |
|
| 142 | - } |
|
| 122 | + $nom = $p->nom_champ; |
|
| 123 | + if ($nom === 'URL_') { |
|
| 124 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 125 | + erreur_squelette($msg, $p); |
|
| 126 | + $p->interdire_scripts = false; |
|
| 127 | + |
|
| 128 | + return $p; |
|
| 129 | + } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 130 | + return $f($p); |
|
| 131 | + } else { |
|
| 132 | + $nom = strtolower($nom); |
|
| 133 | + $code = generer_generer_url(substr($nom, 4), $p); |
|
| 134 | + $code = champ_sql($nom, $p, $code); |
|
| 135 | + $p->code = $code; |
|
| 136 | + if (!$p->etoile) { |
|
| 137 | + $p->code = "vider_url($code)"; |
|
| 138 | + } |
|
| 139 | + $p->interdire_scripts = false; |
|
| 140 | + |
|
| 141 | + return $p; |
|
| 142 | + } |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -163,20 +163,20 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | function balise_URL_ARTICLE_dist($p) { |
| 165 | 165 | |
| 166 | - // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 167 | - if ($p->type_requete == 'syndic_articles') { |
|
| 168 | - $code = champ_sql('url', $p); |
|
| 169 | - } else { |
|
| 170 | - $code = generer_generer_url('article', $p); |
|
| 171 | - } |
|
| 166 | + // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 167 | + if ($p->type_requete == 'syndic_articles') { |
|
| 168 | + $code = champ_sql('url', $p); |
|
| 169 | + } else { |
|
| 170 | + $code = generer_generer_url('article', $p); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $p->code = $code; |
|
| 174 | - if (!$p->etoile) { |
|
| 175 | - $p->code = "vider_url($code)"; |
|
| 176 | - } |
|
| 177 | - $p->interdire_scripts = false; |
|
| 173 | + $p->code = $code; |
|
| 174 | + if (!$p->etoile) { |
|
| 175 | + $p->code = "vider_url($code)"; |
|
| 176 | + } |
|
| 177 | + $p->interdire_scripts = false; |
|
| 178 | 178 | |
| 179 | - return $p; |
|
| 179 | + return $p; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -196,21 +196,21 @@ discard block |
||
| 196 | 196 | * Pile complétée par le code à générer |
| 197 | 197 | */ |
| 198 | 198 | function balise_URL_SITE_dist($p) { |
| 199 | - $code = champ_sql('url_site', $p, ''); |
|
| 200 | - if (!$code) { |
|
| 201 | - $code = generer_generer_url('site', $p); |
|
| 202 | - if ($code === null) { |
|
| 203 | - return null; |
|
| 204 | - } |
|
| 205 | - } else { |
|
| 206 | - if (!$p->etoile) { |
|
| 207 | - $code = "calculer_url($code,'','url', \$connect)"; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - $p->code = $code; |
|
| 211 | - $p->interdire_scripts = false; |
|
| 212 | - |
|
| 213 | - return $p; |
|
| 199 | + $code = champ_sql('url_site', $p, ''); |
|
| 200 | + if (!$code) { |
|
| 201 | + $code = generer_generer_url('site', $p); |
|
| 202 | + if ($code === null) { |
|
| 203 | + return null; |
|
| 204 | + } |
|
| 205 | + } else { |
|
| 206 | + if (!$p->etoile) { |
|
| 207 | + $code = "calculer_url($code,'','url', \$connect)"; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + $p->code = $code; |
|
| 211 | + $p->interdire_scripts = false; |
|
| 212 | + |
|
| 213 | + return $p; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Autres balises URL_*, qui ne concernent pas une table |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | * Pile complétée par le code à générer |
| 230 | 230 | */ |
| 231 | 231 | function balise_URL_SITE_SPIP_dist($p) { |
| 232 | - $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 233 | - $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 234 | - $p->interdire_scripts = false; |
|
| 232 | + $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 233 | + $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 234 | + $p->interdire_scripts = false; |
|
| 235 | 235 | |
| 236 | - return $p; |
|
| 236 | + return $p; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | |
@@ -262,42 +262,42 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function balise_URL_PAGE_dist($p) { |
| 264 | 264 | |
| 265 | - $code = interprete_argument_balise(1, $p); |
|
| 266 | - $args = interprete_argument_balise(2, $p); |
|
| 267 | - if ($args == null) { |
|
| 268 | - $args = "''"; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 272 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 273 | - // elle devra aussi traiter le cas derogatoire type=page |
|
| 274 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 275 | - if ($args and $args !== "''") { |
|
| 276 | - $code .= ", $args"; |
|
| 277 | - } |
|
| 278 | - $code = $f('page', $code, $s); |
|
| 279 | - $p->code = $code; |
|
| 280 | - return $p; |
|
| 281 | - } |
|
| 282 | - $s = 'connect=' . addslashes($s); |
|
| 283 | - $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - if (!$code) { |
|
| 287 | - $noentities = $p->etoile ? "'&'" : ''; |
|
| 288 | - $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 289 | - } else { |
|
| 290 | - if (!$args) { |
|
| 291 | - $args = "''"; |
|
| 292 | - } |
|
| 293 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 294 | - $code = "generer_url_public($code, $args$noentities)"; |
|
| 295 | - } |
|
| 296 | - $p->code = $code; |
|
| 297 | - spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 298 | - |
|
| 299 | - #$p->interdire_scripts = true; |
|
| 300 | - return $p; |
|
| 265 | + $code = interprete_argument_balise(1, $p); |
|
| 266 | + $args = interprete_argument_balise(2, $p); |
|
| 267 | + if ($args == null) { |
|
| 268 | + $args = "''"; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 272 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 273 | + // elle devra aussi traiter le cas derogatoire type=page |
|
| 274 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 275 | + if ($args and $args !== "''") { |
|
| 276 | + $code .= ", $args"; |
|
| 277 | + } |
|
| 278 | + $code = $f('page', $code, $s); |
|
| 279 | + $p->code = $code; |
|
| 280 | + return $p; |
|
| 281 | + } |
|
| 282 | + $s = 'connect=' . addslashes($s); |
|
| 283 | + $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + if (!$code) { |
|
| 287 | + $noentities = $p->etoile ? "'&'" : ''; |
|
| 288 | + $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 289 | + } else { |
|
| 290 | + if (!$args) { |
|
| 291 | + $args = "''"; |
|
| 292 | + } |
|
| 293 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 294 | + $code = "generer_url_public($code, $args$noentities)"; |
|
| 295 | + } |
|
| 296 | + $p->code = $code; |
|
| 297 | + spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 298 | + |
|
| 299 | + #$p->interdire_scripts = true; |
|
| 300 | + return $p; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
@@ -324,24 +324,24 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | function balise_URL_ECRIRE_dist($p) { |
| 326 | 326 | |
| 327 | - $code = interprete_argument_balise(1, $p); |
|
| 328 | - if (!$code) { |
|
| 329 | - $fonc = "''"; |
|
| 330 | - } else { |
|
| 331 | - $fonc = $code; |
|
| 332 | - $args = interprete_argument_balise(2, $p); |
|
| 333 | - if ($args === null) { |
|
| 334 | - $args = "''"; |
|
| 335 | - } |
|
| 336 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 337 | - if (($args != "''") or $noentities) { |
|
| 338 | - $fonc .= ",$args$noentities"; |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 342 | - $p->interdire_scripts = false; |
|
| 343 | - |
|
| 344 | - return $p; |
|
| 327 | + $code = interprete_argument_balise(1, $p); |
|
| 328 | + if (!$code) { |
|
| 329 | + $fonc = "''"; |
|
| 330 | + } else { |
|
| 331 | + $fonc = $code; |
|
| 332 | + $args = interprete_argument_balise(2, $p); |
|
| 333 | + if ($args === null) { |
|
| 334 | + $args = "''"; |
|
| 335 | + } |
|
| 336 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 337 | + if (($args != "''") or $noentities) { |
|
| 338 | + $fonc .= ",$args$noentities"; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 342 | + $p->interdire_scripts = false; |
|
| 343 | + |
|
| 344 | + return $p; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | |
@@ -367,24 +367,24 @@ discard block |
||
| 367 | 367 | * Pile complétée par le code à générer |
| 368 | 368 | */ |
| 369 | 369 | function balise_URL_ACTION_AUTEUR_dist($p) { |
| 370 | - $p->descr['session'] = true; |
|
| 371 | - |
|
| 372 | - $p->code = interprete_argument_balise(1, $p); |
|
| 373 | - |
|
| 374 | - $args = interprete_argument_balise(2, $p); |
|
| 375 | - if ($args != "''" && $args !== null) { |
|
| 376 | - $p->code .= ',' . $args; |
|
| 377 | - } |
|
| 378 | - $redirect = interprete_argument_balise(3, $p); |
|
| 379 | - if ($redirect != "''" && $redirect !== null) { |
|
| 380 | - if ($args == "''" || $args === null) { |
|
| 381 | - $p->code .= ",''"; |
|
| 382 | - } |
|
| 383 | - $p->code .= ',' . $redirect; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 387 | - $p->interdire_scripts = false; |
|
| 388 | - |
|
| 389 | - return $p; |
|
| 370 | + $p->descr['session'] = true; |
|
| 371 | + |
|
| 372 | + $p->code = interprete_argument_balise(1, $p); |
|
| 373 | + |
|
| 374 | + $args = interprete_argument_balise(2, $p); |
|
| 375 | + if ($args != "''" && $args !== null) { |
|
| 376 | + $p->code .= ',' . $args; |
|
| 377 | + } |
|
| 378 | + $redirect = interprete_argument_balise(3, $p); |
|
| 379 | + if ($redirect != "''" && $redirect !== null) { |
|
| 380 | + if ($args == "''" || $args === null) { |
|
| 381 | + $p->code .= ",''"; |
|
| 382 | + } |
|
| 383 | + $p->code .= ',' . $redirect; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 387 | + $p->interdire_scripts = false; |
|
| 388 | + |
|
| 389 | + return $p; |
|
| 390 | 390 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/abstract_sql'); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * Pile complétée du code compilé |
| 42 | 42 | **/ |
| 43 | 43 | function balise_FORMULAIRE_ECRIRE_AUTEUR($p) { |
| 44 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 44 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -59,44 +59,44 @@ discard block |
||
| 59 | 59 | * - chaîne vide sinon (erreur ou non affichage). |
| 60 | 60 | */ |
| 61 | 61 | function balise_FORMULAIRE_ECRIRE_AUTEUR_stat($args, $context_compil) { |
| 62 | - include_spip('inc/filtres'); |
|
| 63 | - // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 64 | - $id = intval($args[1]); |
|
| 65 | - if (!$args[0] and !$id) { |
|
| 66 | - $msg = [ |
|
| 67 | - 'zbug_champ_hors_motif', |
|
| 68 | - [ |
|
| 69 | - 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 70 | - 'motif' => 'AUTEURS/ARTICLES' |
|
| 71 | - ] |
|
| 72 | - ]; |
|
| 62 | + include_spip('inc/filtres'); |
|
| 63 | + // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 64 | + $id = intval($args[1]); |
|
| 65 | + if (!$args[0] and !$id) { |
|
| 66 | + $msg = [ |
|
| 67 | + 'zbug_champ_hors_motif', |
|
| 68 | + [ |
|
| 69 | + 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 70 | + 'motif' => 'AUTEURS/ARTICLES' |
|
| 71 | + ] |
|
| 72 | + ]; |
|
| 73 | 73 | |
| 74 | - erreur_squelette($msg, $context_compil); |
|
| 74 | + erreur_squelette($msg, $context_compil); |
|
| 75 | 75 | |
| 76 | - return ''; |
|
| 77 | - } |
|
| 78 | - // Si on est dans un contexte article, |
|
| 79 | - // sortir tous les mails des auteurs de l'article |
|
| 80 | - if (!$args[0] and $id) { |
|
| 81 | - $r = ''; |
|
| 82 | - $s = sql_allfetsel( |
|
| 83 | - 'email', |
|
| 84 | - 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 85 | - "A.email != '' AND L.id_objet=$id" |
|
| 86 | - ); |
|
| 87 | - foreach ($s as $row) { |
|
| 88 | - if (email_valide($row['email'])) { |
|
| 89 | - $r .= ', ' . $row['email']; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - $args[2] = substr($r, 2); |
|
| 93 | - } |
|
| 76 | + return ''; |
|
| 77 | + } |
|
| 78 | + // Si on est dans un contexte article, |
|
| 79 | + // sortir tous les mails des auteurs de l'article |
|
| 80 | + if (!$args[0] and $id) { |
|
| 81 | + $r = ''; |
|
| 82 | + $s = sql_allfetsel( |
|
| 83 | + 'email', |
|
| 84 | + 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 85 | + "A.email != '' AND L.id_objet=$id" |
|
| 86 | + ); |
|
| 87 | + foreach ($s as $row) { |
|
| 88 | + if (email_valide($row['email'])) { |
|
| 89 | + $r .= ', ' . $row['email']; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + $args[2] = substr($r, 2); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 96 | - if (!$args[2] or !email_valide($args[2])) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 95 | + // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 96 | + if (!$args[2] or !email_valide($args[2])) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - // OK |
|
| 101 | - return $args; |
|
| 100 | + // OK |
|
| 101 | + return $args; |
|
| 102 | 102 | } |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | ); |
| 87 | 87 | foreach ($s as $row) { |
| 88 | 88 | if (email_valide($row['email'])) { |
| 89 | - $r .= ', ' . $row['email']; |
|
| 89 | + $r .= ', '.$row['email']; |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | $args[2] = substr($r, 2); |
@@ -11,134 +11,134 @@ |
||
| 11 | 11 | // plage invalide en iso-8859-1 mais souvent utilisee quand meme (windows) |
| 12 | 12 | // cf. http://openweb.eu.org/articles/caracteres_illegaux/ |
| 13 | 13 | // voir aussi copie de ces valeurs dans inc/charsets.php |
| 14 | - 128 => 8364, |
|
| 15 | - 129 => 129 /* ?? */, |
|
| 16 | - 130 => 8218, |
|
| 17 | - 131 => 402, |
|
| 18 | - 132 => 8222, |
|
| 19 | - 133 => 8230, |
|
| 20 | - 134 => 8224, |
|
| 21 | - 135 => 8225, |
|
| 22 | - 136 => 710, |
|
| 23 | - 137 => 8240, |
|
| 24 | - 138 => 352, |
|
| 25 | - 139 => 8249, |
|
| 26 | - 140 => 338, |
|
| 27 | - 141 => 141 /* ?? */, |
|
| 28 | - 142 => 381, |
|
| 29 | - 143 => 143 /* ?? */, |
|
| 30 | - 144 => 144 /* ?? */, |
|
| 31 | - 145 => 8216, |
|
| 32 | - 146 => 8217, |
|
| 33 | - 147 => 8220, |
|
| 34 | - 148 => 8221, |
|
| 35 | - 149 => 8226, |
|
| 36 | - 150 => 8211, |
|
| 37 | - 151 => 8212, |
|
| 38 | - 152 => 732, |
|
| 39 | - 153 => 8482, |
|
| 40 | - 154 => 353, |
|
| 41 | - 155 => 8250, |
|
| 42 | - 156 => 339, |
|
| 43 | - 157 => 157 /* ?? */, |
|
| 44 | - 158 => 382, |
|
| 45 | - 159 => 376, |
|
| 14 | + 128 => 8364, |
|
| 15 | + 129 => 129 /* ?? */, |
|
| 16 | + 130 => 8218, |
|
| 17 | + 131 => 402, |
|
| 18 | + 132 => 8222, |
|
| 19 | + 133 => 8230, |
|
| 20 | + 134 => 8224, |
|
| 21 | + 135 => 8225, |
|
| 22 | + 136 => 710, |
|
| 23 | + 137 => 8240, |
|
| 24 | + 138 => 352, |
|
| 25 | + 139 => 8249, |
|
| 26 | + 140 => 338, |
|
| 27 | + 141 => 141 /* ?? */, |
|
| 28 | + 142 => 381, |
|
| 29 | + 143 => 143 /* ?? */, |
|
| 30 | + 144 => 144 /* ?? */, |
|
| 31 | + 145 => 8216, |
|
| 32 | + 146 => 8217, |
|
| 33 | + 147 => 8220, |
|
| 34 | + 148 => 8221, |
|
| 35 | + 149 => 8226, |
|
| 36 | + 150 => 8211, |
|
| 37 | + 151 => 8212, |
|
| 38 | + 152 => 732, |
|
| 39 | + 153 => 8482, |
|
| 40 | + 154 => 353, |
|
| 41 | + 155 => 8250, |
|
| 42 | + 156 => 339, |
|
| 43 | + 157 => 157 /* ?? */, |
|
| 44 | + 158 => 382, |
|
| 45 | + 159 => 376, |
|
| 46 | 46 | |
| 47 | - 160 => 160, |
|
| 48 | - 161 => 161, |
|
| 49 | - 162 => 162, |
|
| 50 | - 163 => 163, |
|
| 51 | - 164 => 164, |
|
| 52 | - 165 => 165, |
|
| 53 | - 166 => 166, |
|
| 54 | - 167 => 167, |
|
| 55 | - 168 => 168, |
|
| 56 | - 169 => 169, |
|
| 57 | - 170 => 170, |
|
| 58 | - 171 => 171, |
|
| 59 | - 172 => 172, |
|
| 60 | - 173 => 173, |
|
| 61 | - 174 => 174, |
|
| 62 | - 175 => 175, |
|
| 63 | - 176 => 176, |
|
| 64 | - 177 => 177, |
|
| 65 | - 178 => 178, |
|
| 66 | - 179 => 179, |
|
| 67 | - 180 => 180, |
|
| 68 | - 181 => 181, |
|
| 69 | - 182 => 182, |
|
| 70 | - 183 => 183, |
|
| 71 | - 184 => 184, |
|
| 72 | - 185 => 185, |
|
| 73 | - 186 => 186, |
|
| 74 | - 187 => 187, |
|
| 75 | - 188 => 188, |
|
| 76 | - 189 => 189, |
|
| 77 | - 190 => 190, |
|
| 78 | - 191 => 191, |
|
| 79 | - 192 => 192, |
|
| 80 | - 193 => 193, |
|
| 81 | - 194 => 194, |
|
| 82 | - 195 => 195, |
|
| 83 | - 196 => 196, |
|
| 84 | - 197 => 197, |
|
| 85 | - 198 => 198, |
|
| 86 | - 199 => 199, |
|
| 87 | - 200 => 200, |
|
| 88 | - 201 => 201, |
|
| 89 | - 202 => 202, |
|
| 90 | - 203 => 203, |
|
| 91 | - 204 => 204, |
|
| 92 | - 205 => 205, |
|
| 93 | - 206 => 206, |
|
| 94 | - 207 => 207, |
|
| 95 | - 208 => 208, |
|
| 96 | - 209 => 209, |
|
| 97 | - 210 => 210, |
|
| 98 | - 211 => 211, |
|
| 99 | - 212 => 212, |
|
| 100 | - 213 => 213, |
|
| 101 | - 214 => 214, |
|
| 102 | - 215 => 215, |
|
| 103 | - 216 => 216, |
|
| 104 | - 217 => 217, |
|
| 105 | - 218 => 218, |
|
| 106 | - 219 => 219, |
|
| 107 | - 220 => 220, |
|
| 108 | - 221 => 221, |
|
| 109 | - 222 => 222, |
|
| 110 | - 223 => 223, |
|
| 111 | - 224 => 224, |
|
| 112 | - 225 => 225, |
|
| 113 | - 226 => 226, |
|
| 114 | - 227 => 227, |
|
| 115 | - 228 => 228, |
|
| 116 | - 229 => 229, |
|
| 117 | - 230 => 230, |
|
| 118 | - 231 => 231, |
|
| 119 | - 232 => 232, |
|
| 120 | - 233 => 233, |
|
| 121 | - 234 => 234, |
|
| 122 | - 235 => 235, |
|
| 123 | - 236 => 236, |
|
| 124 | - 237 => 237, |
|
| 125 | - 238 => 238, |
|
| 126 | - 239 => 239, |
|
| 127 | - 240 => 240, |
|
| 128 | - 241 => 241, |
|
| 129 | - 242 => 242, |
|
| 130 | - 243 => 243, |
|
| 131 | - 244 => 244, |
|
| 132 | - 245 => 245, |
|
| 133 | - 246 => 246, |
|
| 134 | - 247 => 247, |
|
| 135 | - 248 => 248, |
|
| 136 | - 249 => 249, |
|
| 137 | - 250 => 250, |
|
| 138 | - 251 => 251, |
|
| 139 | - 252 => 252, |
|
| 140 | - 253 => 253, |
|
| 141 | - 254 => 254, |
|
| 142 | - 255 => 255 |
|
| 47 | + 160 => 160, |
|
| 48 | + 161 => 161, |
|
| 49 | + 162 => 162, |
|
| 50 | + 163 => 163, |
|
| 51 | + 164 => 164, |
|
| 52 | + 165 => 165, |
|
| 53 | + 166 => 166, |
|
| 54 | + 167 => 167, |
|
| 55 | + 168 => 168, |
|
| 56 | + 169 => 169, |
|
| 57 | + 170 => 170, |
|
| 58 | + 171 => 171, |
|
| 59 | + 172 => 172, |
|
| 60 | + 173 => 173, |
|
| 61 | + 174 => 174, |
|
| 62 | + 175 => 175, |
|
| 63 | + 176 => 176, |
|
| 64 | + 177 => 177, |
|
| 65 | + 178 => 178, |
|
| 66 | + 179 => 179, |
|
| 67 | + 180 => 180, |
|
| 68 | + 181 => 181, |
|
| 69 | + 182 => 182, |
|
| 70 | + 183 => 183, |
|
| 71 | + 184 => 184, |
|
| 72 | + 185 => 185, |
|
| 73 | + 186 => 186, |
|
| 74 | + 187 => 187, |
|
| 75 | + 188 => 188, |
|
| 76 | + 189 => 189, |
|
| 77 | + 190 => 190, |
|
| 78 | + 191 => 191, |
|
| 79 | + 192 => 192, |
|
| 80 | + 193 => 193, |
|
| 81 | + 194 => 194, |
|
| 82 | + 195 => 195, |
|
| 83 | + 196 => 196, |
|
| 84 | + 197 => 197, |
|
| 85 | + 198 => 198, |
|
| 86 | + 199 => 199, |
|
| 87 | + 200 => 200, |
|
| 88 | + 201 => 201, |
|
| 89 | + 202 => 202, |
|
| 90 | + 203 => 203, |
|
| 91 | + 204 => 204, |
|
| 92 | + 205 => 205, |
|
| 93 | + 206 => 206, |
|
| 94 | + 207 => 207, |
|
| 95 | + 208 => 208, |
|
| 96 | + 209 => 209, |
|
| 97 | + 210 => 210, |
|
| 98 | + 211 => 211, |
|
| 99 | + 212 => 212, |
|
| 100 | + 213 => 213, |
|
| 101 | + 214 => 214, |
|
| 102 | + 215 => 215, |
|
| 103 | + 216 => 216, |
|
| 104 | + 217 => 217, |
|
| 105 | + 218 => 218, |
|
| 106 | + 219 => 219, |
|
| 107 | + 220 => 220, |
|
| 108 | + 221 => 221, |
|
| 109 | + 222 => 222, |
|
| 110 | + 223 => 223, |
|
| 111 | + 224 => 224, |
|
| 112 | + 225 => 225, |
|
| 113 | + 226 => 226, |
|
| 114 | + 227 => 227, |
|
| 115 | + 228 => 228, |
|
| 116 | + 229 => 229, |
|
| 117 | + 230 => 230, |
|
| 118 | + 231 => 231, |
|
| 119 | + 232 => 232, |
|
| 120 | + 233 => 233, |
|
| 121 | + 234 => 234, |
|
| 122 | + 235 => 235, |
|
| 123 | + 236 => 236, |
|
| 124 | + 237 => 237, |
|
| 125 | + 238 => 238, |
|
| 126 | + 239 => 239, |
|
| 127 | + 240 => 240, |
|
| 128 | + 241 => 241, |
|
| 129 | + 242 => 242, |
|
| 130 | + 243 => 243, |
|
| 131 | + 244 => 244, |
|
| 132 | + 245 => 245, |
|
| 133 | + 246 => 246, |
|
| 134 | + 247 => 247, |
|
| 135 | + 248 => 248, |
|
| 136 | + 249 => 249, |
|
| 137 | + 250 => 250, |
|
| 138 | + 251 => 251, |
|
| 139 | + 252 => 252, |
|
| 140 | + 253 => 253, |
|
| 141 | + 254 => 254, |
|
| 142 | + 255 => 255 |
|
| 143 | 143 | |
| 144 | 144 | ]; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | load_charset('iso-8859-1'); |
@@ -27,61 +27,61 @@ discard block |
||
| 27 | 27 | $trans = $GLOBALS['CHARSET']['iso-8859-1']; |
| 28 | 28 | |
| 29 | 29 | $mod = [ |
| 30 | - 0xA0 => 0x00A0, |
|
| 31 | - 0xA4 => 0x00A4, |
|
| 32 | - 0xAC => 0x060C, |
|
| 33 | - 0xAD => 0x00AD, |
|
| 34 | - 0xBB => 0x061B, |
|
| 35 | - 0xBF => 0x061F, |
|
| 36 | - 0xC1 => 0x0621, |
|
| 37 | - 0xC2 => 0x0622, |
|
| 38 | - 0xC3 => 0x0623, |
|
| 39 | - 0xC4 => 0x0624, |
|
| 40 | - 0xC5 => 0x0625, |
|
| 41 | - 0xC6 => 0x0626, |
|
| 42 | - 0xC7 => 0x0627, |
|
| 43 | - 0xC8 => 0x0628, |
|
| 44 | - 0xC9 => 0x0629, |
|
| 45 | - 0xCA => 0x062A, |
|
| 46 | - 0xCB => 0x062B, |
|
| 47 | - 0xCC => 0x062C, |
|
| 48 | - 0xCD => 0x062D, |
|
| 49 | - 0xCE => 0x062E, |
|
| 50 | - 0xCF => 0x062F, |
|
| 51 | - 0xD0 => 0x0630, |
|
| 52 | - 0xD1 => 0x0631, |
|
| 53 | - 0xD2 => 0x0632, |
|
| 54 | - 0xD3 => 0x0633, |
|
| 55 | - 0xD4 => 0x0634, |
|
| 56 | - 0xD5 => 0x0635, |
|
| 57 | - 0xD6 => 0x0636, |
|
| 58 | - 0xD7 => 0x0637, |
|
| 59 | - 0xD8 => 0x0638, |
|
| 60 | - 0xD9 => 0x0639, |
|
| 61 | - 0xDA => 0x063A, |
|
| 62 | - 0xE0 => 0x0640, |
|
| 63 | - 0xE1 => 0x0641, |
|
| 64 | - 0xE2 => 0x0642, |
|
| 65 | - 0xE3 => 0x0643, |
|
| 66 | - 0xE4 => 0x0644, |
|
| 67 | - 0xE5 => 0x0645, |
|
| 68 | - 0xE6 => 0x0646, |
|
| 69 | - 0xE7 => 0x0647, |
|
| 70 | - 0xE8 => 0x0648, |
|
| 71 | - 0xE9 => 0x0649, |
|
| 72 | - 0xEA => 0x064A, |
|
| 73 | - 0xEB => 0x064B, |
|
| 74 | - 0xEC => 0x064C, |
|
| 75 | - 0xED => 0x064D, |
|
| 76 | - 0xEE => 0x064E, |
|
| 77 | - 0xEF => 0x064F, |
|
| 78 | - 0xF0 => 0x0650, |
|
| 79 | - 0xF1 => 0x0651, |
|
| 80 | - 0xF2 => 0x0652 |
|
| 30 | + 0xA0 => 0x00A0, |
|
| 31 | + 0xA4 => 0x00A4, |
|
| 32 | + 0xAC => 0x060C, |
|
| 33 | + 0xAD => 0x00AD, |
|
| 34 | + 0xBB => 0x061B, |
|
| 35 | + 0xBF => 0x061F, |
|
| 36 | + 0xC1 => 0x0621, |
|
| 37 | + 0xC2 => 0x0622, |
|
| 38 | + 0xC3 => 0x0623, |
|
| 39 | + 0xC4 => 0x0624, |
|
| 40 | + 0xC5 => 0x0625, |
|
| 41 | + 0xC6 => 0x0626, |
|
| 42 | + 0xC7 => 0x0627, |
|
| 43 | + 0xC8 => 0x0628, |
|
| 44 | + 0xC9 => 0x0629, |
|
| 45 | + 0xCA => 0x062A, |
|
| 46 | + 0xCB => 0x062B, |
|
| 47 | + 0xCC => 0x062C, |
|
| 48 | + 0xCD => 0x062D, |
|
| 49 | + 0xCE => 0x062E, |
|
| 50 | + 0xCF => 0x062F, |
|
| 51 | + 0xD0 => 0x0630, |
|
| 52 | + 0xD1 => 0x0631, |
|
| 53 | + 0xD2 => 0x0632, |
|
| 54 | + 0xD3 => 0x0633, |
|
| 55 | + 0xD4 => 0x0634, |
|
| 56 | + 0xD5 => 0x0635, |
|
| 57 | + 0xD6 => 0x0636, |
|
| 58 | + 0xD7 => 0x0637, |
|
| 59 | + 0xD8 => 0x0638, |
|
| 60 | + 0xD9 => 0x0639, |
|
| 61 | + 0xDA => 0x063A, |
|
| 62 | + 0xE0 => 0x0640, |
|
| 63 | + 0xE1 => 0x0641, |
|
| 64 | + 0xE2 => 0x0642, |
|
| 65 | + 0xE3 => 0x0643, |
|
| 66 | + 0xE4 => 0x0644, |
|
| 67 | + 0xE5 => 0x0645, |
|
| 68 | + 0xE6 => 0x0646, |
|
| 69 | + 0xE7 => 0x0647, |
|
| 70 | + 0xE8 => 0x0648, |
|
| 71 | + 0xE9 => 0x0649, |
|
| 72 | + 0xEA => 0x064A, |
|
| 73 | + 0xEB => 0x064B, |
|
| 74 | + 0xEC => 0x064C, |
|
| 75 | + 0xED => 0x064D, |
|
| 76 | + 0xEE => 0x064E, |
|
| 77 | + 0xEF => 0x064F, |
|
| 78 | + 0xF0 => 0x0650, |
|
| 79 | + 0xF1 => 0x0651, |
|
| 80 | + 0xF2 => 0x0652 |
|
| 81 | 81 | ]; |
| 82 | 82 | |
| 83 | 83 | foreach ($mod as $num => $val) { |
| 84 | - $trans[$num] = $val; |
|
| 84 | + $trans[$num] = $val; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $GLOBALS['CHARSET']['iso-8859-6'] = $trans; |