@@ -37,29 +37,29 @@ discard block |
||
| 37 | 37 | * @return string |
| 38 | 38 | */ |
| 39 | 39 | function parametres_css_prive(){ |
| 40 | - global $visiteur_session; |
|
| 40 | + global $visiteur_session; |
|
| 41 | 41 | |
| 42 | - $args = array(); |
|
| 43 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 44 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']),0,4); |
|
| 45 | - $args['themes'] = implode(',',lister_themes_prives()); |
|
| 46 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 47 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 48 | - $args['md5b'] = (function_exists('md5_boutons_plugins')?md5_boutons_plugins():''); |
|
| 42 | + $args = array(); |
|
| 43 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 44 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']),0,4); |
|
| 45 | + $args['themes'] = implode(',',lister_themes_prives()); |
|
| 46 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 47 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 48 | + $args['md5b'] = (function_exists('md5_boutons_plugins')?md5_boutons_plugins():''); |
|
| 49 | 49 | |
| 50 | - $c = (is_array($visiteur_session) |
|
| 51 | - AND is_array($visiteur_session['prefs'])) |
|
| 52 | - ? $visiteur_session['prefs']['couleur'] |
|
| 53 | - : 1; |
|
| 50 | + $c = (is_array($visiteur_session) |
|
| 51 | + AND is_array($visiteur_session['prefs'])) |
|
| 52 | + ? $visiteur_session['prefs']['couleur'] |
|
| 53 | + : 1; |
|
| 54 | 54 | |
| 55 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 56 | - parse_str($couleurs($c),$c); |
|
| 57 | - $args = array_merge($args, $c); |
|
| 55 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 56 | + parse_str($couleurs($c),$c); |
|
| 57 | + $args = array_merge($args, $c); |
|
| 58 | 58 | |
| 59 | - if (_request('var_mode')=='recalcul' OR (defined('_VAR_MODE') AND _VAR_MODE=='recalcul')) |
|
| 60 | - $args['var_mode'] = 'recalcul'; |
|
| 59 | + if (_request('var_mode')=='recalcul' OR (defined('_VAR_MODE') AND _VAR_MODE=='recalcul')) |
|
| 60 | + $args['var_mode'] = 'recalcul'; |
|
| 61 | 61 | |
| 62 | - return http_build_query($args); |
|
| 62 | + return http_build_query($args); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -80,53 +80,53 @@ discard block |
||
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | 82 | function chercher_rubrique($titre,$id_objet, $id_parent, $objet, $id_secteur, $restreint,$actionable = false, $retour_sans_cadre=false){ |
| 83 | - global $spip_lang_right; |
|
| 84 | - include_spip('inc/autoriser'); |
|
| 85 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) |
|
| 86 | - return ""; |
|
| 87 | - if (!sql_countsel('spip_rubriques')) |
|
| 88 | - return ""; |
|
| 89 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 90 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet=='rubrique')?$id_objet:0); |
|
| 91 | - |
|
| 92 | - if ($id_parent == 0) $logo = "racine-24.png"; |
|
| 93 | - elseif ($id_secteur == $id_parent) $logo = "secteur-24.png"; |
|
| 94 | - else $logo = "rubrique-24.png"; |
|
| 95 | - |
|
| 96 | - $confirm = ""; |
|
| 97 | - if ($objet=='rubrique') { |
|
| 98 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 99 | - // confirmation du deplacement |
|
| 100 | - $contient_breves = sql_countsel('spip_breves', "id_rubrique=".intval($id_objet)); |
|
| 101 | - |
|
| 102 | - if ($contient_breves > 0) { |
|
| 103 | - $scb = ($contient_breves>1? 's':''); |
|
| 104 | - $scb = _T('avis_deplacement_rubrique', |
|
| 105 | - array('contient_breves' => $contient_breves, |
|
| 106 | - 'scb' => $scb)); |
|
| 107 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 108 | - ."<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 109 | - . $scb . |
|
| 110 | - "</label></div></div>\n"; |
|
| 111 | - } else |
|
| 112 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 113 | - } |
|
| 114 | - $form .= $confirm; |
|
| 115 | - if ($actionable){ |
|
| 116 | - if (strpos($form,'<select')!==false) { |
|
| 117 | - $form .= "<div style='text-align: $spip_lang_right;'>" |
|
| 118 | - . '<input class="fondo" type="submit" value="'._T('bouton_choisir').'"/>' |
|
| 119 | - . "</div>"; |
|
| 120 | - } |
|
| 121 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 122 | - $form = generer_action_auteur("editer_$objet", $id_objet, self(), $form, " method='post' class='submit_plongeur'"); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - if ($retour_sans_cadre) |
|
| 126 | - return $form; |
|
| 127 | - |
|
| 128 | - include_spip('inc/presentation'); |
|
| 129 | - return debut_cadre_couleur($logo, true, "", $titre) . $form .fin_cadre_couleur(true); |
|
| 83 | + global $spip_lang_right; |
|
| 84 | + include_spip('inc/autoriser'); |
|
| 85 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) |
|
| 86 | + return ""; |
|
| 87 | + if (!sql_countsel('spip_rubriques')) |
|
| 88 | + return ""; |
|
| 89 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 90 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet=='rubrique')?$id_objet:0); |
|
| 91 | + |
|
| 92 | + if ($id_parent == 0) $logo = "racine-24.png"; |
|
| 93 | + elseif ($id_secteur == $id_parent) $logo = "secteur-24.png"; |
|
| 94 | + else $logo = "rubrique-24.png"; |
|
| 95 | + |
|
| 96 | + $confirm = ""; |
|
| 97 | + if ($objet=='rubrique') { |
|
| 98 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 99 | + // confirmation du deplacement |
|
| 100 | + $contient_breves = sql_countsel('spip_breves', "id_rubrique=".intval($id_objet)); |
|
| 101 | + |
|
| 102 | + if ($contient_breves > 0) { |
|
| 103 | + $scb = ($contient_breves>1? 's':''); |
|
| 104 | + $scb = _T('avis_deplacement_rubrique', |
|
| 105 | + array('contient_breves' => $contient_breves, |
|
| 106 | + 'scb' => $scb)); |
|
| 107 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 108 | + ."<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 109 | + . $scb . |
|
| 110 | + "</label></div></div>\n"; |
|
| 111 | + } else |
|
| 112 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 113 | + } |
|
| 114 | + $form .= $confirm; |
|
| 115 | + if ($actionable){ |
|
| 116 | + if (strpos($form,'<select')!==false) { |
|
| 117 | + $form .= "<div style='text-align: $spip_lang_right;'>" |
|
| 118 | + . '<input class="fondo" type="submit" value="'._T('bouton_choisir').'"/>' |
|
| 119 | + . "</div>"; |
|
| 120 | + } |
|
| 121 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 122 | + $form = generer_action_auteur("editer_$objet", $id_objet, self(), $form, " method='post' class='submit_plongeur'"); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + if ($retour_sans_cadre) |
|
| 126 | + return $form; |
|
| 127 | + |
|
| 128 | + include_spip('inc/presentation'); |
|
| 129 | + return debut_cadre_couleur($logo, true, "", $titre) . $form .fin_cadre_couleur(true); |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
@@ -141,12 +141,12 @@ discard block |
||
| 141 | 141 | * @return bool |
| 142 | 142 | */ |
| 143 | 143 | function avoir_visiteurs($past=false, $accepter=true) { |
| 144 | - if ($GLOBALS['meta']["forums_publics"] == 'abo') return true; |
|
| 145 | - if ($accepter AND $GLOBALS['meta']["accepter_visiteurs"] <> 'non') return true; |
|
| 146 | - if (sql_countsel('spip_articles', "accepter_forum='abo'"))return true; |
|
| 147 | - if (!$past) return false; |
|
| 148 | - return sql_countsel('spip_auteurs', |
|
| 149 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 144 | + if ($GLOBALS['meta']["forums_publics"] == 'abo') return true; |
|
| 145 | + if ($accepter AND $GLOBALS['meta']["accepter_visiteurs"] <> 'non') return true; |
|
| 146 | + if (sql_countsel('spip_articles', "accepter_forum='abo'"))return true; |
|
| 147 | + if (!$past) return false; |
|
| 148 | + return sql_countsel('spip_auteurs', |
|
| 149 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 150 | 150 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))"); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -163,17 +163,17 @@ discard block |
||
| 163 | 163 | * @return array |
| 164 | 164 | */ |
| 165 | 165 | function statuts_articles_visibles($statut_auteur){ |
| 166 | - static $auth = array(); |
|
| 167 | - if (!isset($auth[$statut_auteur])){ |
|
| 168 | - $auth[$statut_auteur] = array(); |
|
| 169 | - $statuts = array_map('reset',sql_allfetsel('distinct statut','spip_articles')); |
|
| 170 | - foreach($statuts as $s){ |
|
| 171 | - if (autoriser('voir','article',0,array('statut'=>$statut_auteur),array('statut'=>$s))) |
|
| 172 | - $auth[$statut_auteur][] = $s; |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - return $auth[$statut_auteur]; |
|
| 166 | + static $auth = array(); |
|
| 167 | + if (!isset($auth[$statut_auteur])){ |
|
| 168 | + $auth[$statut_auteur] = array(); |
|
| 169 | + $statuts = array_map('reset',sql_allfetsel('distinct statut','spip_articles')); |
|
| 170 | + foreach($statuts as $s){ |
|
| 171 | + if (autoriser('voir','article',0,array('statut'=>$statut_auteur),array('statut'=>$s))) |
|
| 172 | + $auth[$statut_auteur][] = $s; |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + return $auth[$statut_auteur]; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -187,33 +187,33 @@ discard block |
||
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | 189 | function traduire_statut_auteur($statut,$attente=""){ |
| 190 | - $plus = ""; |
|
| 191 | - if ($statut=='nouveau') { |
|
| 192 | - if ($attente) { |
|
| 193 | - $statut = $attente; |
|
| 194 | - $plus = " ("._T('info_statut_auteur_a_confirmer').")"; |
|
| 195 | - } |
|
| 196 | - else return _T('info_statut_auteur_a_confirmer'); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - $recom = array("info_administrateurs" => _T('item_administrateur_2'), |
|
| 200 | - "info_redacteurs" => _T('intem_redacteur'), |
|
| 201 | - "info_visiteurs" => _T('item_visiteur'), |
|
| 202 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 203 | - ); |
|
| 204 | - if (isset($recom[$statut])) |
|
| 205 | - return $recom[$statut].$plus; |
|
| 206 | - |
|
| 207 | - // retrouver directement par le statut sinon |
|
| 208 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])){ |
|
| 209 | - if (isset($recom[$t])) |
|
| 210 | - return $recom[$t].$plus; |
|
| 211 | - return _T($t).$plus; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 215 | - // c'est toujours plus informatif que rien du tout |
|
| 216 | - return $statut; |
|
| 190 | + $plus = ""; |
|
| 191 | + if ($statut=='nouveau') { |
|
| 192 | + if ($attente) { |
|
| 193 | + $statut = $attente; |
|
| 194 | + $plus = " ("._T('info_statut_auteur_a_confirmer').")"; |
|
| 195 | + } |
|
| 196 | + else return _T('info_statut_auteur_a_confirmer'); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + $recom = array("info_administrateurs" => _T('item_administrateur_2'), |
|
| 200 | + "info_redacteurs" => _T('intem_redacteur'), |
|
| 201 | + "info_visiteurs" => _T('item_visiteur'), |
|
| 202 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 203 | + ); |
|
| 204 | + if (isset($recom[$statut])) |
|
| 205 | + return $recom[$statut].$plus; |
|
| 206 | + |
|
| 207 | + // retrouver directement par le statut sinon |
|
| 208 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])){ |
|
| 209 | + if (isset($recom[$t])) |
|
| 210 | + return $recom[$t].$plus; |
|
| 211 | + return _T($t).$plus; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 215 | + // c'est toujours plus informatif que rien du tout |
|
| 216 | + return $statut; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -224,23 +224,23 @@ discard block |
||
| 224 | 224 | * @return string |
| 225 | 225 | */ |
| 226 | 226 | function afficher_qui_edite($id_objet,$objet){ |
| 227 | - static $qui = array(); |
|
| 228 | - if (isset($qui[$objet][$id_objet])) |
|
| 229 | - return $qui[$objet][$id_objet]; |
|
| 227 | + static $qui = array(); |
|
| 228 | + if (isset($qui[$objet][$id_objet])) |
|
| 229 | + return $qui[$objet][$id_objet]; |
|
| 230 | 230 | |
| 231 | - if ($GLOBALS['meta']['articles_modif'] == 'non') |
|
| 232 | - return $qui[$objet][$id_objet] = ''; |
|
| 231 | + if ($GLOBALS['meta']['articles_modif'] == 'non') |
|
| 232 | + return $qui[$objet][$id_objet] = ''; |
|
| 233 | 233 | |
| 234 | - include_spip('inc/drapeau_edition'); |
|
| 235 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 236 | - if (!$modif) return $qui[$objet][$id_objet] = ''; |
|
| 237 | - |
|
| 238 | - include_spip('base/objets'); |
|
| 239 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 240 | - if (isset($infos['texte_signale_edition'])) |
|
| 241 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 234 | + include_spip('inc/drapeau_edition'); |
|
| 235 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 236 | + if (!$modif) return $qui[$objet][$id_objet] = ''; |
|
| 237 | + |
|
| 238 | + include_spip('base/objets'); |
|
| 239 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 240 | + if (isset($infos['texte_signale_edition'])) |
|
| 241 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 242 | 242 | |
| 243 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 243 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -256,46 +256,46 @@ discard block |
||
| 256 | 256 | * @return array |
| 257 | 257 | */ |
| 258 | 258 | function auteurs_lister_statuts($quoi='tous',$en_base=true) { |
| 259 | - if (!defined('AUTEURS_MIN_REDAC')) define('AUTEURS_MIN_REDAC', "0minirezo,1comite,5poubelle"); |
|
| 260 | - |
|
| 261 | - switch($quoi){ |
|
| 262 | - case "redacteurs": |
|
| 263 | - $statut = AUTEURS_MIN_REDAC; |
|
| 264 | - $statut = explode(',',$statut); |
|
| 265 | - if ($en_base) { |
|
| 266 | - $check = array_map('reset',sql_allfetsel('DISTINCT statut','spip_auteurs',sql_in('statut',$statut))); |
|
| 267 | - $retire = array_diff($statut,$check); |
|
| 268 | - $statut = array_diff($statut,$retire); |
|
| 269 | - } |
|
| 270 | - return array_unique($statut); |
|
| 271 | - break; |
|
| 272 | - case "visiteurs": |
|
| 273 | - $statut = array(); |
|
| 274 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 275 | - $exclus = explode(',',$exclus); |
|
| 276 | - if (!$en_base){ |
|
| 277 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 278 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']),$exclus); |
|
| 279 | - } |
|
| 280 | - $s_complement = array_map('reset',sql_allfetsel('DISTINCT statut','spip_auteurs',sql_in('statut',$exclus,'NOT'))); |
|
| 281 | - return array_unique(array_merge($statut,$s_complement)); |
|
| 282 | - break; |
|
| 283 | - default: |
|
| 284 | - case "tous": |
|
| 285 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 286 | - $s_complement = array_map('reset',sql_allfetsel('DISTINCT statut','spip_auteurs',sql_in('statut',$statut,'NOT'))); |
|
| 287 | - $statut = array_merge($statut,$s_complement); |
|
| 288 | - if ($en_base) { |
|
| 289 | - $check = array_map('reset',sql_allfetsel('DISTINCT statut','spip_auteurs',sql_in('statut',$statut))); |
|
| 290 | - $retire = array_diff($statut,$check); |
|
| 291 | - $statut = array_diff($statut,$retire); |
|
| 292 | - } |
|
| 293 | - return array_unique($statut); |
|
| 294 | - break; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - // on arrive jamais ici |
|
| 298 | - return array_values($GLOBALS['liste_des_statuts']); |
|
| 259 | + if (!defined('AUTEURS_MIN_REDAC')) define('AUTEURS_MIN_REDAC', "0minirezo,1comite,5poubelle"); |
|
| 260 | + |
|
| 261 | + switch($quoi){ |
|
| 262 | + case "redacteurs": |
|
| 263 | + $statut = AUTEURS_MIN_REDAC; |
|
| 264 | + $statut = explode(',',$statut); |
|
| 265 | + if ($en_base) { |
|
| 266 | + $check = array_map('reset',sql_allfetsel('DISTINCT statut','spip_auteurs',sql_in('statut',$statut))); |
|
| 267 | + $retire = array_diff($statut,$check); |
|
| 268 | + $statut = array_diff($statut,$retire); |
|
| 269 | + } |
|
| 270 | + return array_unique($statut); |
|
| 271 | + break; |
|
| 272 | + case "visiteurs": |
|
| 273 | + $statut = array(); |
|
| 274 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 275 | + $exclus = explode(',',$exclus); |
|
| 276 | + if (!$en_base){ |
|
| 277 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 278 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']),$exclus); |
|
| 279 | + } |
|
| 280 | + $s_complement = array_map('reset',sql_allfetsel('DISTINCT statut','spip_auteurs',sql_in('statut',$exclus,'NOT'))); |
|
| 281 | + return array_unique(array_merge($statut,$s_complement)); |
|
| 282 | + break; |
|
| 283 | + default: |
|
| 284 | + case "tous": |
|
| 285 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 286 | + $s_complement = array_map('reset',sql_allfetsel('DISTINCT statut','spip_auteurs',sql_in('statut',$statut,'NOT'))); |
|
| 287 | + $statut = array_merge($statut,$s_complement); |
|
| 288 | + if ($en_base) { |
|
| 289 | + $check = array_map('reset',sql_allfetsel('DISTINCT statut','spip_auteurs',sql_in('statut',$statut))); |
|
| 290 | + $retire = array_diff($statut,$check); |
|
| 291 | + $statut = array_diff($statut,$retire); |
|
| 292 | + } |
|
| 293 | + return array_unique($statut); |
|
| 294 | + break; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + // on arrive jamais ici |
|
| 298 | + return array_values($GLOBALS['liste_des_statuts']); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -310,28 +310,28 @@ discard block |
||
| 310 | 310 | * @return int Identifiant de la rubrique dans laquelle créer l'objet |
| 311 | 311 | */ |
| 312 | 312 | function trouver_rubrique_creer_objet($id_rubrique,$objet){ |
| 313 | - global $connect_id_rubrique; |
|
| 314 | - if (!$id_rubrique AND defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') AND _CHOIX_RUBRIQUE_PAR_DEFAUT){ |
|
| 315 | - $in = !count($connect_id_rubrique) |
|
| 316 | - ? '' |
|
| 317 | - : (" AND ".sql_in('id_rubrique', $connect_id_rubrique)); |
|
| 318 | - |
|
| 319 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 320 | - if ($objet == 'rubrique') { |
|
| 321 | - $id_rubrique = 0; |
|
| 322 | - } else { |
|
| 323 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', "id_rubrique DESC", 1); |
|
| 324 | - } |
|
| 313 | + global $connect_id_rubrique; |
|
| 314 | + if (!$id_rubrique AND defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') AND _CHOIX_RUBRIQUE_PAR_DEFAUT){ |
|
| 315 | + $in = !count($connect_id_rubrique) |
|
| 316 | + ? '' |
|
| 317 | + : (" AND ".sql_in('id_rubrique', $connect_id_rubrique)); |
|
| 318 | + |
|
| 319 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 320 | + if ($objet == 'rubrique') { |
|
| 321 | + $id_rubrique = 0; |
|
| 322 | + } else { |
|
| 323 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', "id_rubrique DESC", 1); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)){ |
|
| 327 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 328 | - $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 329 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)){ |
|
| 330 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 331 | - } |
|
| 332 | - } |
|
| 333 | - } |
|
| 334 | - return $id_rubrique; |
|
| 326 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)){ |
|
| 327 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 328 | + $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 329 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)){ |
|
| 330 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 331 | + } |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + return $id_rubrique; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -342,10 +342,10 @@ discard block |
||
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | 344 | function lien_article_virtuel($virtuel){ |
| 345 | - include_spip('inc/lien'); |
|
| 346 | - if (!$virtuel = virtuel_redirige($virtuel)) |
|
| 347 | - return ''; |
|
| 348 | - return propre("[->".$virtuel."]"); |
|
| 345 | + include_spip('inc/lien'); |
|
| 346 | + if (!$virtuel = virtuel_redirige($virtuel)) |
|
| 347 | + return ''; |
|
| 348 | + return propre("[->".$virtuel."]"); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | |
@@ -361,11 +361,11 @@ discard block |
||
| 361 | 361 | * @return string |
| 362 | 362 | */ |
| 363 | 363 | function bouton_spip_rss($op, $args=array(), $lang='', $title='RSS') { |
| 364 | - include_spip('inc/acces'); |
|
| 365 | - $clic = http_img_pack('feed.png', 'RSS', '', $title); |
|
| 366 | - $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 367 | - $url = generer_url_public('rss', $args); |
|
| 368 | - return "<a style='float: ".$GLOBALS['spip_lang_right'].";' href='$url'>$clic</a>"; |
|
| 364 | + include_spip('inc/acces'); |
|
| 365 | + $clic = http_img_pack('feed.png', 'RSS', '', $title); |
|
| 366 | + $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 367 | + $url = generer_url_public('rss', $args); |
|
| 368 | + return "<a style='float: ".$GLOBALS['spip_lang_right'].";' href='$url'>$clic</a>"; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | |
@@ -379,68 +379,68 @@ discard block |
||
| 379 | 379 | */ |
| 380 | 380 | function alertes_auteur($id_auteur) { |
| 381 | 381 | |
| 382 | - $alertes = array(); |
|
| 383 | - |
|
| 384 | - // si on n'est plus compatible avec php4 : le dire a tous ceux qui passent |
|
| 385 | - // dans l'espace prive |
|
| 386 | - if (version_compare(phpversion(), _PHP_MIN) == -1) |
|
| 387 | - $alertes[] = _L('SPIP nécessite PHP @min@, votre version est @version@.', array('min'=> _PHP_MIN, 'version' => phpversion())); |
|
| 388 | - |
|
| 389 | - if (isset($GLOBALS['meta']['message_crash_tables']) |
|
| 390 | - AND autoriser('detruire', null, null, $id_auteur)) { |
|
| 391 | - include_spip('genie/maintenance'); |
|
| 392 | - if ($msg = message_crash_tables()) |
|
| 393 | - $alertes[] = $msg; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - if (isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 397 | - AND $GLOBALS['meta']['message_crash_plugins'] |
|
| 398 | - AND autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 399 | - AND is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))) { |
|
| 400 | - $msg = implode(', ',array_map('joli_repertoire',array_keys($msg))); |
|
| 401 | - $alertes[] = _T('plugins_erreur', array('plugins' => $msg)); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 405 | - if ($a |
|
| 406 | - AND is_array($a = unserialize($a)) |
|
| 407 | - AND count($a)){ |
|
| 408 | - $update = false; |
|
| 409 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])){ |
|
| 410 | - $alertes = array_merge($alertes,$a[$GLOBALS['visiteur_session']['statut']]); |
|
| 411 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 412 | - $update = true; |
|
| 413 | - } |
|
| 414 | - if (isset($a[''])){ |
|
| 415 | - $alertes = array_merge($alertes,$a['']); |
|
| 416 | - unset($a['']); |
|
| 417 | - $update = true; |
|
| 418 | - } |
|
| 419 | - if ($update) |
|
| 420 | - ecrire_meta("message_alertes_auteurs",serialize($a)); |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - if (isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 424 | - AND autoriser('configurer', '_plugins', null, $id_auteur)) { |
|
| 425 | - include_spip('inc/plugin'); |
|
| 426 | - $alertes[] = plugin_donne_erreurs(); |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - $alertes = pipeline( |
|
| 430 | - 'alertes_auteur', |
|
| 431 | - array( |
|
| 432 | - 'args' => array( |
|
| 433 | - 'id_auteur' => $id_auteur, |
|
| 434 | - 'exec' => _request('exec'), |
|
| 435 | - ), |
|
| 436 | - 'data' => $alertes |
|
| 437 | - ) |
|
| 438 | - ); |
|
| 439 | - |
|
| 440 | - if ($alertes = array_filter($alertes)) |
|
| 441 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>". |
|
| 442 | - join(' | ', $alertes) |
|
| 443 | - ."</div></div>"; |
|
| 382 | + $alertes = array(); |
|
| 383 | + |
|
| 384 | + // si on n'est plus compatible avec php4 : le dire a tous ceux qui passent |
|
| 385 | + // dans l'espace prive |
|
| 386 | + if (version_compare(phpversion(), _PHP_MIN) == -1) |
|
| 387 | + $alertes[] = _L('SPIP nécessite PHP @min@, votre version est @version@.', array('min'=> _PHP_MIN, 'version' => phpversion())); |
|
| 388 | + |
|
| 389 | + if (isset($GLOBALS['meta']['message_crash_tables']) |
|
| 390 | + AND autoriser('detruire', null, null, $id_auteur)) { |
|
| 391 | + include_spip('genie/maintenance'); |
|
| 392 | + if ($msg = message_crash_tables()) |
|
| 393 | + $alertes[] = $msg; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + if (isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 397 | + AND $GLOBALS['meta']['message_crash_plugins'] |
|
| 398 | + AND autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 399 | + AND is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))) { |
|
| 400 | + $msg = implode(', ',array_map('joli_repertoire',array_keys($msg))); |
|
| 401 | + $alertes[] = _T('plugins_erreur', array('plugins' => $msg)); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 405 | + if ($a |
|
| 406 | + AND is_array($a = unserialize($a)) |
|
| 407 | + AND count($a)){ |
|
| 408 | + $update = false; |
|
| 409 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])){ |
|
| 410 | + $alertes = array_merge($alertes,$a[$GLOBALS['visiteur_session']['statut']]); |
|
| 411 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 412 | + $update = true; |
|
| 413 | + } |
|
| 414 | + if (isset($a[''])){ |
|
| 415 | + $alertes = array_merge($alertes,$a['']); |
|
| 416 | + unset($a['']); |
|
| 417 | + $update = true; |
|
| 418 | + } |
|
| 419 | + if ($update) |
|
| 420 | + ecrire_meta("message_alertes_auteurs",serialize($a)); |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + if (isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 424 | + AND autoriser('configurer', '_plugins', null, $id_auteur)) { |
|
| 425 | + include_spip('inc/plugin'); |
|
| 426 | + $alertes[] = plugin_donne_erreurs(); |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + $alertes = pipeline( |
|
| 430 | + 'alertes_auteur', |
|
| 431 | + array( |
|
| 432 | + 'args' => array( |
|
| 433 | + 'id_auteur' => $id_auteur, |
|
| 434 | + 'exec' => _request('exec'), |
|
| 435 | + ), |
|
| 436 | + 'data' => $alertes |
|
| 437 | + ) |
|
| 438 | + ); |
|
| 439 | + |
|
| 440 | + if ($alertes = array_filter($alertes)) |
|
| 441 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>". |
|
| 442 | + join(' | ', $alertes) |
|
| 443 | + ."</div></div>"; |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | /** |
@@ -449,8 +449,8 @@ discard block |
||
| 449 | 449 | * @return string |
| 450 | 450 | */ |
| 451 | 451 | function filtre_afficher_enfant_rub_dist($id_rubrique){ |
| 452 | - include_spip('inc/presenter_enfants'); |
|
| 453 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 452 | + include_spip('inc/presenter_enfants'); |
|
| 453 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -468,15 +468,15 @@ discard block |
||
| 468 | 468 | * @return string |
| 469 | 469 | */ |
| 470 | 470 | function afficher_plus_info($lien, $titre="+", $titre_lien="") { |
| 471 | - $titre = attribut_html($titre); |
|
| 472 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 473 | - http_img_pack("information-16.png", $titre) ."</a>"; |
|
| 474 | - |
|
| 475 | - if (!$titre_lien) { |
|
| 476 | - return $icone; |
|
| 477 | - } else { |
|
| 478 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 479 | - } |
|
| 471 | + $titre = attribut_html($titre); |
|
| 472 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 473 | + http_img_pack("information-16.png", $titre) ."</a>"; |
|
| 474 | + |
|
| 475 | + if (!$titre_lien) { |
|
| 476 | + return $icone; |
|
| 477 | + } else { |
|
| 478 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 479 | + } |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | /** |
@@ -492,18 +492,18 @@ discard block |
||
| 492 | 492 | * @return array |
| 493 | 493 | */ |
| 494 | 494 | function lister_objets_lies($objet_source,$objet,$id_objet,$objet_lien){ |
| 495 | - include_spip('action/editer_liens'); |
|
| 496 | - $l = array(); |
|
| 497 | - // quand $objet == $objet_lien == $objet_source on reste sur le cas par defaut de $objet_lien == $objet_source |
|
| 498 | - if ($objet_lien==$objet AND $objet_lien!==$objet_source){ |
|
| 499 | - $res = objet_trouver_liens(array($objet=>$id_objet),array($objet_source=>'*')); |
|
| 500 | - } |
|
| 501 | - else{ |
|
| 502 | - $res = objet_trouver_liens(array($objet_source=>'*'),array($objet=>$id_objet)); |
|
| 503 | - } |
|
| 504 | - while ($row = array_shift($res)) |
|
| 505 | - $l[] = $row[$objet_source]; |
|
| 506 | - |
|
| 507 | - return $l; |
|
| 495 | + include_spip('action/editer_liens'); |
|
| 496 | + $l = array(); |
|
| 497 | + // quand $objet == $objet_lien == $objet_source on reste sur le cas par defaut de $objet_lien == $objet_source |
|
| 498 | + if ($objet_lien==$objet AND $objet_lien!==$objet_source){ |
|
| 499 | + $res = objet_trouver_liens(array($objet=>$id_objet),array($objet_source=>'*')); |
|
| 500 | + } |
|
| 501 | + else{ |
|
| 502 | + $res = objet_trouver_liens(array($objet_source=>'*'),array($objet=>$id_objet)); |
|
| 503 | + } |
|
| 504 | + while ($row = array_shift($res)) |
|
| 505 | + $l[] = $row[$objet_source]; |
|
| 506 | + |
|
| 507 | + return $l; |
|
| 508 | 508 | } |
| 509 | 509 | ?> |
@@ -24,76 +24,76 @@ discard block |
||
| 24 | 24 | // (chemins relatifs a la racine du site, separes par des ":") |
| 25 | 25 | // http://doc.spip.org/@liste_plugin_files |
| 26 | 26 | function liste_plugin_files($dir_plugins = null){ |
| 27 | - static $plugin_files=array(); |
|
| 28 | - if (is_null($dir_plugins)) |
|
| 29 | - $dir_plugins = _DIR_PLUGINS; |
|
| 30 | - if (!isset($plugin_files[$dir_plugins]) |
|
| 31 | - OR count($plugin_files[$dir_plugins]) == 0){ |
|
| 32 | - $plugin_files[$dir_plugins] = array(); |
|
| 33 | - foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 34 | - $plugin_files[$dir_plugins][] = substr($plugin,strlen($dir_plugins)); |
|
| 35 | - } |
|
| 27 | + static $plugin_files=array(); |
|
| 28 | + if (is_null($dir_plugins)) |
|
| 29 | + $dir_plugins = _DIR_PLUGINS; |
|
| 30 | + if (!isset($plugin_files[$dir_plugins]) |
|
| 31 | + OR count($plugin_files[$dir_plugins]) == 0){ |
|
| 32 | + $plugin_files[$dir_plugins] = array(); |
|
| 33 | + foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 34 | + $plugin_files[$dir_plugins][] = substr($plugin,strlen($dir_plugins)); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - sort($plugin_files[$dir_plugins]); |
|
| 38 | - // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 39 | - // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 40 | - $get_infos = charger_fonction('get_infos','plugins'); |
|
| 41 | - $get_infos($plugin_files[$dir_plugins],false,$dir_plugins,true); |
|
| 42 | - } |
|
| 43 | - return $plugin_files[$dir_plugins]; |
|
| 37 | + sort($plugin_files[$dir_plugins]); |
|
| 38 | + // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 39 | + // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 40 | + $get_infos = charger_fonction('get_infos','plugins'); |
|
| 41 | + $get_infos($plugin_files[$dir_plugins],false,$dir_plugins,true); |
|
| 42 | + } |
|
| 43 | + return $plugin_files[$dir_plugins]; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | function fast_find_plugin_dirs($dir, $max_prof=100) { |
| 47 | - $fichiers = array(); |
|
| 48 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 49 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 50 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 51 | - if ($dir == '') $dir = '.'; |
|
| 52 | - |
|
| 53 | - if (!is_dir($dir)) |
|
| 54 | - return $fichiers; |
|
| 55 | - if (is_plugin_dir($dir,'')) { |
|
| 56 | - $fichiers[] = $dir; |
|
| 57 | - return $fichiers; |
|
| 58 | - } |
|
| 59 | - if ($max_prof<=0) |
|
| 60 | - return $fichiers; |
|
| 61 | - |
|
| 62 | - $subdirs = array(); |
|
| 63 | - if (@is_dir($dir) AND is_readable($dir) AND $d = @opendir($dir)) { |
|
| 64 | - while (($f = readdir($d)) !== false) { |
|
| 65 | - if ($f[0] != '.' # ignorer . .. .svn etc |
|
| 66 | - AND $f != 'CVS' |
|
| 67 | - AND is_dir($f = "$dir/$f")) |
|
| 68 | - $subdirs[] = $f; |
|
| 69 | - } |
|
| 70 | - closedir($d); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - foreach($subdirs as $d){ |
|
| 74 | - $fichiers = array_merge($fichiers,fast_find_plugin_dirs("$d/",$max_prof-1)); |
|
| 75 | - } |
|
| 76 | - return $fichiers; |
|
| 47 | + $fichiers = array(); |
|
| 48 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 49 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 50 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 51 | + if ($dir == '') $dir = '.'; |
|
| 52 | + |
|
| 53 | + if (!is_dir($dir)) |
|
| 54 | + return $fichiers; |
|
| 55 | + if (is_plugin_dir($dir,'')) { |
|
| 56 | + $fichiers[] = $dir; |
|
| 57 | + return $fichiers; |
|
| 58 | + } |
|
| 59 | + if ($max_prof<=0) |
|
| 60 | + return $fichiers; |
|
| 61 | + |
|
| 62 | + $subdirs = array(); |
|
| 63 | + if (@is_dir($dir) AND is_readable($dir) AND $d = @opendir($dir)) { |
|
| 64 | + while (($f = readdir($d)) !== false) { |
|
| 65 | + if ($f[0] != '.' # ignorer . .. .svn etc |
|
| 66 | + AND $f != 'CVS' |
|
| 67 | + AND is_dir($f = "$dir/$f")) |
|
| 68 | + $subdirs[] = $f; |
|
| 69 | + } |
|
| 70 | + closedir($d); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + foreach($subdirs as $d){ |
|
| 74 | + $fichiers = array_merge($fichiers,fast_find_plugin_dirs("$d/",$max_prof-1)); |
|
| 75 | + } |
|
| 76 | + return $fichiers; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | function is_plugin_dir($dir,$dir_plugins = null){ |
| 80 | - if (is_array($dir)){ |
|
| 81 | - foreach($dir as $k=>$d){ |
|
| 82 | - if (!is_plugin_dir($d,$dir_plugins)) |
|
| 83 | - unset($dir[$k]); |
|
| 84 | - } |
|
| 85 | - return $dir; |
|
| 86 | - } |
|
| 87 | - if (is_null($dir_plugins)) |
|
| 88 | - $dir_plugins = _DIR_PLUGINS; |
|
| 89 | - $search = array("$dir_plugins$dir/plugin.xml","$dir_plugins$dir/paquet.xml"); |
|
| 80 | + if (is_array($dir)){ |
|
| 81 | + foreach($dir as $k=>$d){ |
|
| 82 | + if (!is_plugin_dir($d,$dir_plugins)) |
|
| 83 | + unset($dir[$k]); |
|
| 84 | + } |
|
| 85 | + return $dir; |
|
| 86 | + } |
|
| 87 | + if (is_null($dir_plugins)) |
|
| 88 | + $dir_plugins = _DIR_PLUGINS; |
|
| 89 | + $search = array("$dir_plugins$dir/plugin.xml","$dir_plugins$dir/paquet.xml"); |
|
| 90 | 90 | |
| 91 | - foreach($search as $s){ |
|
| 92 | - if (file_exists($s)){ |
|
| 93 | - return $dir; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - return ''; |
|
| 91 | + foreach($search as $s){ |
|
| 92 | + if (file_exists($s)){ |
|
| 93 | + return $dir; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + return ''; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Regexp d'extraction des informations d'un intervalle de compatibilité |
@@ -118,34 +118,34 @@ discard block |
||
| 118 | 118 | **/ |
| 119 | 119 | function plugin_version_compatible($intervalle, $version, $avec_quoi = '') { |
| 120 | 120 | |
| 121 | - if (!strlen($intervalle)) return true; |
|
| 122 | - if (!preg_match(_EXTRAIRE_INTERVALLE,$intervalle,$regs)) return false; |
|
| 123 | - // Extraction des bornes et traitement de * pour la borne sup : |
|
| 124 | - // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 125 | - $minimum = $regs[1]; |
|
| 126 | - $maximum = $regs[2]; |
|
| 127 | - |
|
| 128 | - // si une borne de compatibilité supérieure a été définie (dans |
|
| 129 | - // mes_options.php, sous la forme : define('_DEV_PLUGINS', '3.1.99'); |
|
| 130 | - // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 131 | - // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 132 | - // entre plugins) |
|
| 133 | - if (defined('_DEV_PLUGINS') && $avec_quoi == 'spip') { |
|
| 134 | - $maximum = _DEV_PLUGINS.']'; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - $minimum_inc = $intervalle{0}=="["; |
|
| 138 | - $maximum_inc = substr($intervalle,-1)=="]"; |
|
| 139 | - |
|
| 140 | - if (strlen($minimum)){ |
|
| 141 | - if ($minimum_inc AND spip_version_compare($version,$minimum,'<')) return false; |
|
| 142 | - if (!$minimum_inc AND spip_version_compare($version,$minimum,'<=')) return false; |
|
| 143 | - } |
|
| 144 | - if (strlen($maximum)){ |
|
| 145 | - if ($maximum_inc AND spip_version_compare($version,$maximum,'>')) return false; |
|
| 146 | - if (!$maximum_inc AND spip_version_compare($version,$maximum,'>=')) return false; |
|
| 147 | - } |
|
| 148 | - return true; |
|
| 121 | + if (!strlen($intervalle)) return true; |
|
| 122 | + if (!preg_match(_EXTRAIRE_INTERVALLE,$intervalle,$regs)) return false; |
|
| 123 | + // Extraction des bornes et traitement de * pour la borne sup : |
|
| 124 | + // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 125 | + $minimum = $regs[1]; |
|
| 126 | + $maximum = $regs[2]; |
|
| 127 | + |
|
| 128 | + // si une borne de compatibilité supérieure a été définie (dans |
|
| 129 | + // mes_options.php, sous la forme : define('_DEV_PLUGINS', '3.1.99'); |
|
| 130 | + // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 131 | + // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 132 | + // entre plugins) |
|
| 133 | + if (defined('_DEV_PLUGINS') && $avec_quoi == 'spip') { |
|
| 134 | + $maximum = _DEV_PLUGINS.']'; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + $minimum_inc = $intervalle{0}=="["; |
|
| 138 | + $maximum_inc = substr($intervalle,-1)=="]"; |
|
| 139 | + |
|
| 140 | + if (strlen($minimum)){ |
|
| 141 | + if ($minimum_inc AND spip_version_compare($version,$minimum,'<')) return false; |
|
| 142 | + if (!$minimum_inc AND spip_version_compare($version,$minimum,'<=')) return false; |
|
| 143 | + } |
|
| 144 | + if (strlen($maximum)){ |
|
| 145 | + if ($maximum_inc AND spip_version_compare($version,$maximum,'>')) return false; |
|
| 146 | + if (!$maximum_inc AND spip_version_compare($version,$maximum,'>=')) return false; |
|
| 147 | + } |
|
| 148 | + return true; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
@@ -159,48 +159,48 @@ discard block |
||
| 159 | 159 | * @return array |
| 160 | 160 | */ |
| 161 | 161 | function liste_plugin_valides($liste_plug, $force = false){ |
| 162 | - $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 163 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 164 | - $infos = array( |
|
| 165 | - // lister les extensions qui sont automatiquement actives |
|
| 166 | - '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 167 | - '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 168 | - ); |
|
| 169 | - |
|
| 170 | - // creer une premiere liste non ordonnee mais qui ne retient |
|
| 171 | - // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 172 | - $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 173 | - $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 174 | - $infos['_DIR_RESTREINT']['SPIP']['chemin'] = array(); |
|
| 175 | - $liste_non_classee = array('SPIP' => array( |
|
| 176 | - 'nom' => 'SPIP', |
|
| 177 | - 'etat' => 'stable', |
|
| 178 | - 'version' => $GLOBALS['spip_version_branche'], |
|
| 179 | - 'dir_type' => '_DIR_RESTREINT', |
|
| 180 | - 'dir' => '', |
|
| 181 | - ) |
|
| 182 | - ); |
|
| 183 | - |
|
| 184 | - foreach ($liste_ext as $plug){ |
|
| 185 | - if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) |
|
| 186 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 187 | - } |
|
| 188 | - foreach ($liste_plug as $plug){ |
|
| 189 | - if (isset($infos['_DIR_PLUGINS'][$plug])) |
|
| 190 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 191 | - } |
|
| 162 | + $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 163 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 164 | + $infos = array( |
|
| 165 | + // lister les extensions qui sont automatiquement actives |
|
| 166 | + '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 167 | + '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 168 | + ); |
|
| 169 | + |
|
| 170 | + // creer une premiere liste non ordonnee mais qui ne retient |
|
| 171 | + // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 172 | + $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 173 | + $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 174 | + $infos['_DIR_RESTREINT']['SPIP']['chemin'] = array(); |
|
| 175 | + $liste_non_classee = array('SPIP' => array( |
|
| 176 | + 'nom' => 'SPIP', |
|
| 177 | + 'etat' => 'stable', |
|
| 178 | + 'version' => $GLOBALS['spip_version_branche'], |
|
| 179 | + 'dir_type' => '_DIR_RESTREINT', |
|
| 180 | + 'dir' => '', |
|
| 181 | + ) |
|
| 182 | + ); |
|
| 183 | + |
|
| 184 | + foreach ($liste_ext as $plug){ |
|
| 185 | + if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) |
|
| 186 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 187 | + } |
|
| 188 | + foreach ($liste_plug as $plug){ |
|
| 189 | + if (isset($infos['_DIR_PLUGINS'][$plug])) |
|
| 190 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL){ |
|
| 194 | - $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 195 | - foreach ($liste_plug as $plug){ |
|
| 196 | - if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) |
|
| 197 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 198 | - } |
|
| 199 | - } |
|
| 193 | + if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL){ |
|
| 194 | + $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 195 | + foreach ($liste_plug as $plug){ |
|
| 196 | + if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) |
|
| 197 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - plugin_fixer_procure($liste_non_classee, $infos); |
|
| 201 | + plugin_fixer_procure($liste_non_classee, $infos); |
|
| 202 | 202 | |
| 203 | - return array($infos, $liste_non_classee); |
|
| 203 | + return array($infos, $liste_non_classee); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -214,23 +214,23 @@ discard block |
||
| 214 | 214 | * @param string $dir_type |
| 215 | 215 | */ |
| 216 | 216 | function plugin_valide_resume(&$liste, $plug, $infos, $dir_type){ |
| 217 | - $i = $infos[$dir_type][$plug]; |
|
| 218 | - if (isset($i['erreur']) AND $i['erreur']) |
|
| 219 | - return; |
|
| 220 | - if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) |
|
| 221 | - return; |
|
| 222 | - $p = strtoupper($i['prefix']); |
|
| 223 | - if (!isset($liste[$p]) |
|
| 224 | - OR spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 225 | - ){ |
|
| 226 | - $liste[$p] = array( |
|
| 227 | - 'nom' => $i['nom'], |
|
| 228 | - 'etat' => $i['etat'], |
|
| 229 | - 'version' => $i['version'], |
|
| 230 | - 'dir' => $plug, |
|
| 231 | - 'dir_type' => $dir_type |
|
| 232 | - ); |
|
| 233 | - } |
|
| 217 | + $i = $infos[$dir_type][$plug]; |
|
| 218 | + if (isset($i['erreur']) AND $i['erreur']) |
|
| 219 | + return; |
|
| 220 | + if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) |
|
| 221 | + return; |
|
| 222 | + $p = strtoupper($i['prefix']); |
|
| 223 | + if (!isset($liste[$p]) |
|
| 224 | + OR spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 225 | + ){ |
|
| 226 | + $liste[$p] = array( |
|
| 227 | + 'nom' => $i['nom'], |
|
| 228 | + 'etat' => $i['etat'], |
|
| 229 | + 'version' => $i['version'], |
|
| 230 | + 'dir' => $plug, |
|
| 231 | + 'dir_type' => $dir_type |
|
| 232 | + ); |
|
| 233 | + } |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -244,44 +244,44 @@ discard block |
||
| 244 | 244 | * @param array $infos |
| 245 | 245 | */ |
| 246 | 246 | function plugin_fixer_procure(&$liste, &$infos){ |
| 247 | - foreach($liste as $p=>$resume){ |
|
| 248 | - $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 249 | - if (isset($i['procure']) AND $i['procure']){ |
|
| 250 | - foreach($i['procure'] as $procure){ |
|
| 251 | - $p = strtoupper($procure['nom']); |
|
| 252 | - $dir = $resume['dir']; |
|
| 253 | - if ($dir) $dir .= "/"; |
|
| 254 | - $dir .= "procure:".$procure['nom']; |
|
| 255 | - |
|
| 256 | - $procure['etat'] = '?'; |
|
| 257 | - $procure['dir_type'] = $resume['dir_type']; |
|
| 258 | - $procure['dir'] = $dir; |
|
| 259 | - |
|
| 260 | - // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 261 | - // on ajoute cette version a la liste |
|
| 262 | - if (!isset($liste[$p]) |
|
| 263 | - OR spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 264 | - ){ |
|
| 265 | - $liste[$p] = $procure; |
|
| 266 | - |
|
| 267 | - // on fournit une information minimale pour ne pas perturber la compilation |
|
| 268 | - $infos[$resume['dir_type']][$dir] = array( |
|
| 269 | - 'prefix' => $procure['nom'], |
|
| 270 | - 'nom' => $procure['nom'], |
|
| 271 | - 'etat' => $procure['etat'], |
|
| 272 | - 'version' => $procure['version'], |
|
| 273 | - 'chemin' => array(), |
|
| 274 | - 'necessite' => array(), |
|
| 275 | - 'utilise' => array(), |
|
| 276 | - 'lib' => array(), |
|
| 277 | - 'menu' => array(), |
|
| 278 | - 'onglet' => array(), |
|
| 279 | - 'procure' => array(), |
|
| 280 | - ); |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - } |
|
| 247 | + foreach($liste as $p=>$resume){ |
|
| 248 | + $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 249 | + if (isset($i['procure']) AND $i['procure']){ |
|
| 250 | + foreach($i['procure'] as $procure){ |
|
| 251 | + $p = strtoupper($procure['nom']); |
|
| 252 | + $dir = $resume['dir']; |
|
| 253 | + if ($dir) $dir .= "/"; |
|
| 254 | + $dir .= "procure:".$procure['nom']; |
|
| 255 | + |
|
| 256 | + $procure['etat'] = '?'; |
|
| 257 | + $procure['dir_type'] = $resume['dir_type']; |
|
| 258 | + $procure['dir'] = $dir; |
|
| 259 | + |
|
| 260 | + // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 261 | + // on ajoute cette version a la liste |
|
| 262 | + if (!isset($liste[$p]) |
|
| 263 | + OR spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 264 | + ){ |
|
| 265 | + $liste[$p] = $procure; |
|
| 266 | + |
|
| 267 | + // on fournit une information minimale pour ne pas perturber la compilation |
|
| 268 | + $infos[$resume['dir_type']][$dir] = array( |
|
| 269 | + 'prefix' => $procure['nom'], |
|
| 270 | + 'nom' => $procure['nom'], |
|
| 271 | + 'etat' => $procure['etat'], |
|
| 272 | + 'version' => $procure['version'], |
|
| 273 | + 'chemin' => array(), |
|
| 274 | + 'necessite' => array(), |
|
| 275 | + 'utilise' => array(), |
|
| 276 | + 'lib' => array(), |
|
| 277 | + 'menu' => array(), |
|
| 278 | + 'onglet' => array(), |
|
| 279 | + 'procure' => array(), |
|
| 280 | + ); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -294,16 +294,16 @@ discard block |
||
| 294 | 294 | * @return array |
| 295 | 295 | */ |
| 296 | 296 | function liste_chemin_plugin($liste, $dir_plugins=_DIR_PLUGINS){ |
| 297 | - foreach ($liste as $prefix=>$infos) { |
|
| 298 | - if (!$dir_plugins |
|
| 299 | - OR ( |
|
| 300 | - defined($infos['dir_type']) |
|
| 301 | - AND constant($infos['dir_type'])==$dir_plugins)) |
|
| 302 | - $liste[$prefix] = $infos['dir']; |
|
| 303 | - else |
|
| 304 | - unset($liste[$prefix]); |
|
| 305 | - } |
|
| 306 | - return $liste; |
|
| 297 | + foreach ($liste as $prefix=>$infos) { |
|
| 298 | + if (!$dir_plugins |
|
| 299 | + OR ( |
|
| 300 | + defined($infos['dir_type']) |
|
| 301 | + AND constant($infos['dir_type'])==$dir_plugins)) |
|
| 302 | + $liste[$prefix] = $infos['dir']; |
|
| 303 | + else |
|
| 304 | + unset($liste[$prefix]); |
|
| 305 | + } |
|
| 306 | + return $liste; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | // http://doc.spip.org/@liste_chemin_plugin_actifs |
| 316 | 316 | function liste_chemin_plugin_actifs($dir_plugins=_DIR_PLUGINS){ |
| 317 | - include_spip('plugins/installer'); |
|
| 318 | - return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 317 | + include_spip('plugins/installer'); |
|
| 318 | + return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | // Pour tester utilise, il faut connaitre tous les plugins |
@@ -328,87 +328,87 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | function plugin_trier($infos, $liste_non_classee) |
| 330 | 330 | { |
| 331 | - $toute_la_liste = $liste_non_classee; |
|
| 332 | - $liste = $ordre = array(); |
|
| 333 | - $count = 0; |
|
| 334 | - while ($c=count($liste_non_classee) AND $c!=$count){ // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 335 | - #echo "tour::";var_dump($liste_non_classee); |
|
| 336 | - $count = $c; |
|
| 337 | - foreach($liste_non_classee as $p=>$resume) { |
|
| 338 | - $plug = $resume['dir']; |
|
| 339 | - $dir_type = $resume['dir_type']; |
|
| 340 | - $info1 = $infos[$dir_type][$plug]; |
|
| 341 | - // si des plugins sont necessaires, |
|
| 342 | - // on ne peut inserer qu'apres eux |
|
| 343 | - foreach($info1['necessite'] as $need){ |
|
| 344 | - $nom = strtoupper($need['nom']); |
|
| 345 | - $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 346 | - if (!isset($liste[$nom]) OR !plugin_version_compatible($compat,$liste[$nom]['version'])) { |
|
| 347 | - $info1 = false; |
|
| 348 | - break; |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - if (!$info1) continue; |
|
| 352 | - // idem si des plugins sont utiles, |
|
| 353 | - // sauf si ils sont de toute facon absents de la liste |
|
| 354 | - foreach($info1['utilise'] as $need){ |
|
| 355 | - $nom = strtoupper($need['nom']); |
|
| 356 | - $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 357 | - if (isset($toute_la_liste[$nom])) { |
|
| 358 | - if (!isset($liste[$nom]) OR |
|
| 359 | - !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 360 | - $info1 = false; |
|
| 361 | - break; |
|
| 362 | - } |
|
| 363 | - } |
|
| 364 | - } |
|
| 365 | - if ($info1) { |
|
| 366 | - $ordre[$p] = $info1; |
|
| 367 | - $liste[$p] = $liste_non_classee[$p]; |
|
| 368 | - unset($liste_non_classee[$p]); |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - } |
|
| 372 | - return array($liste, $ordre, $liste_non_classee); |
|
| 331 | + $toute_la_liste = $liste_non_classee; |
|
| 332 | + $liste = $ordre = array(); |
|
| 333 | + $count = 0; |
|
| 334 | + while ($c=count($liste_non_classee) AND $c!=$count){ // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 335 | + #echo "tour::";var_dump($liste_non_classee); |
|
| 336 | + $count = $c; |
|
| 337 | + foreach($liste_non_classee as $p=>$resume) { |
|
| 338 | + $plug = $resume['dir']; |
|
| 339 | + $dir_type = $resume['dir_type']; |
|
| 340 | + $info1 = $infos[$dir_type][$plug]; |
|
| 341 | + // si des plugins sont necessaires, |
|
| 342 | + // on ne peut inserer qu'apres eux |
|
| 343 | + foreach($info1['necessite'] as $need){ |
|
| 344 | + $nom = strtoupper($need['nom']); |
|
| 345 | + $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 346 | + if (!isset($liste[$nom]) OR !plugin_version_compatible($compat,$liste[$nom]['version'])) { |
|
| 347 | + $info1 = false; |
|
| 348 | + break; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + if (!$info1) continue; |
|
| 352 | + // idem si des plugins sont utiles, |
|
| 353 | + // sauf si ils sont de toute facon absents de la liste |
|
| 354 | + foreach($info1['utilise'] as $need){ |
|
| 355 | + $nom = strtoupper($need['nom']); |
|
| 356 | + $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 357 | + if (isset($toute_la_liste[$nom])) { |
|
| 358 | + if (!isset($liste[$nom]) OR |
|
| 359 | + !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 360 | + $info1 = false; |
|
| 361 | + break; |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + if ($info1) { |
|
| 366 | + $ordre[$p] = $info1; |
|
| 367 | + $liste[$p] = $liste_non_classee[$p]; |
|
| 368 | + unset($liste_non_classee[$p]); |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + } |
|
| 372 | + return array($liste, $ordre, $liste_non_classee); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | // Collecte les erreurs dans la meta |
| 376 | 376 | |
| 377 | 377 | function plugins_erreurs($liste_non_classee, $liste, $infos, $msg=array()) |
| 378 | 378 | { |
| 379 | - static $erreurs = array(); |
|
| 380 | - foreach($liste_non_classee as $p=>$resume){ |
|
| 381 | - $dir_type = $resume['dir_type']; |
|
| 382 | - $plug = $resume['dir']; |
|
| 383 | - $k = $infos[$dir_type][$plug]; |
|
| 384 | - $plug = constant($dir_type) . $plug; |
|
| 385 | - if (!isset($msg[$p])) { |
|
| 386 | - if (!$msg[$p] = plugin_necessite($k['necessite'], $liste)) |
|
| 387 | - $msg[$p] = plugin_necessite($k['utilise'], $liste); |
|
| 388 | - } else { |
|
| 389 | - foreach($msg[$p] as $c => $l) |
|
| 390 | - $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 391 | - } |
|
| 392 | - $erreurs[$plug] = $msg[$p]; |
|
| 393 | - } |
|
| 394 | - ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 379 | + static $erreurs = array(); |
|
| 380 | + foreach($liste_non_classee as $p=>$resume){ |
|
| 381 | + $dir_type = $resume['dir_type']; |
|
| 382 | + $plug = $resume['dir']; |
|
| 383 | + $k = $infos[$dir_type][$plug]; |
|
| 384 | + $plug = constant($dir_type) . $plug; |
|
| 385 | + if (!isset($msg[$p])) { |
|
| 386 | + if (!$msg[$p] = plugin_necessite($k['necessite'], $liste)) |
|
| 387 | + $msg[$p] = plugin_necessite($k['utilise'], $liste); |
|
| 388 | + } else { |
|
| 389 | + foreach($msg[$p] as $c => $l) |
|
| 390 | + $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 391 | + } |
|
| 392 | + $erreurs[$plug] = $msg[$p]; |
|
| 393 | + } |
|
| 394 | + ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | function plugin_donne_erreurs($raw=false, $raz=true) { |
| 398 | - if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) return $raw?array():''; |
|
| 399 | - $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 400 | - // Compat ancienne version |
|
| 401 | - if (!$list) |
|
| 402 | - $list = $raw?array():$GLOBALS['meta']['plugin_erreur_activation']; |
|
| 403 | - elseif(!$raw) { |
|
| 404 | - foreach($list as $plug => $msg) |
|
| 405 | - $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 406 | - . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>"; |
|
| 407 | - $list ="<ul>" . join("\n", $list) . "</ul>"; |
|
| 408 | - } |
|
| 409 | - if ($raz) |
|
| 410 | - effacer_meta('plugin_erreur_activation'); |
|
| 411 | - return $list; |
|
| 398 | + if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) return $raw?array():''; |
|
| 399 | + $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 400 | + // Compat ancienne version |
|
| 401 | + if (!$list) |
|
| 402 | + $list = $raw?array():$GLOBALS['meta']['plugin_erreur_activation']; |
|
| 403 | + elseif(!$raw) { |
|
| 404 | + foreach($list as $plug => $msg) |
|
| 405 | + $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 406 | + . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>"; |
|
| 407 | + $list ="<ul>" . join("\n", $list) . "</ul>"; |
|
| 408 | + } |
|
| 409 | + if ($raz) |
|
| 410 | + effacer_meta('plugin_erreur_activation'); |
|
| 411 | + return $list; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -425,14 +425,14 @@ discard block |
||
| 425 | 425 | * |
| 426 | 426 | **/ |
| 427 | 427 | function plugin_necessite($n, $liste) { |
| 428 | - $msg = array(); |
|
| 429 | - foreach($n as $need){ |
|
| 430 | - $id = strtoupper($need['nom']); |
|
| 431 | - if ($r = plugin_controler_necessite($liste, $id, $need['compatibilite'])) { |
|
| 432 | - $msg[] = $r; |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - return $msg; |
|
| 428 | + $msg = array(); |
|
| 429 | + foreach($n as $need){ |
|
| 430 | + $id = strtoupper($need['nom']); |
|
| 431 | + if ($r = plugin_controler_necessite($liste, $id, $need['compatibilite'])) { |
|
| 432 | + $msg[] = $r; |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + return $msg; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -450,34 +450,34 @@ discard block |
||
| 450 | 450 | **/ |
| 451 | 451 | function plugin_controler_necessite($liste, $nom, $version) |
| 452 | 452 | { |
| 453 | - if (isset($liste[$nom]) AND plugin_version_compatible($version,$liste[$nom]['version'])) { |
|
| 454 | - return ''; |
|
| 455 | - } |
|
| 456 | - // retrouver le minimum |
|
| 457 | - if (preg_match(_EXTRAIRE_INTERVALLE, $version, $regs)) { |
|
| 458 | - $minimum = $regs[1]; |
|
| 459 | - if ($minimum) { |
|
| 460 | - return _T('plugin_necessite_plugin', array( |
|
| 461 | - 'plugin' => $nom, |
|
| 462 | - 'version' => $minimum)); |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - return _T('plugin_necessite_plugin_sans_version', array('plugin' => $nom)); |
|
| 453 | + if (isset($liste[$nom]) AND plugin_version_compatible($version,$liste[$nom]['version'])) { |
|
| 454 | + return ''; |
|
| 455 | + } |
|
| 456 | + // retrouver le minimum |
|
| 457 | + if (preg_match(_EXTRAIRE_INTERVALLE, $version, $regs)) { |
|
| 458 | + $minimum = $regs[1]; |
|
| 459 | + if ($minimum) { |
|
| 460 | + return _T('plugin_necessite_plugin', array( |
|
| 461 | + 'plugin' => $nom, |
|
| 462 | + 'version' => $minimum)); |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + return _T('plugin_necessite_plugin_sans_version', array('plugin' => $nom)); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | function plugin_controler_lib($lib, $url) |
| 469 | 469 | { |
| 470 | - /* Feature sortie du core, voir STP |
|
| 470 | + /* Feature sortie du core, voir STP |
|
| 471 | 471 | * if ($url) { |
| 472 | 472 | include_spip('inc/charger_plugin'); |
| 473 | 473 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 474 | 474 | }*/ |
| 475 | - return _T('plugin_necessite_lib', array('lib'=>$lib)) . " <a href='$url'>$url</a>"; |
|
| 475 | + return _T('plugin_necessite_lib', array('lib'=>$lib)) . " <a href='$url'>$url</a>"; |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | // Pour compatibilite et lisibilite du code |
| 479 | 479 | function actualise_plugins_actifs($pipe_recherche = false){ |
| 480 | - return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 480 | + return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | // mise a jour du meta en fonction de l'etat du repertoire |
@@ -488,210 +488,210 @@ discard block |
||
| 488 | 488 | // http://doc.spip.org/@ecrire_plugin_actifs |
| 489 | 489 | function ecrire_plugin_actifs($plugin,$pipe_recherche=false,$operation='raz') { |
| 490 | 490 | |
| 491 | - // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 492 | - sous_repertoire(_DIR_CACHE, '', false,true); |
|
| 491 | + // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 492 | + sous_repertoire(_DIR_CACHE, '', false,true); |
|
| 493 | 493 | |
| 494 | - if (!spip_connect()) return false; |
|
| 495 | - if ($operation!='raz') { |
|
| 496 | - $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 497 | - $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 498 | - if(defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL){ |
|
| 499 | - $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 500 | - $plugin_valides_supp = is_plugin_dir($plugin_valides_supp,_DIR_PLUGINS_SUPPL); |
|
| 501 | - $plugin_valides = array_merge($plugin_valides,$plugin_valides_supp); |
|
| 502 | - } |
|
| 503 | - // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 504 | - // on les reinjecte ici |
|
| 505 | - if (isset($GLOBALS['meta']['plugin_attente']) |
|
| 506 | - AND $a = unserialize($GLOBALS['meta']['plugin_attente'])) |
|
| 507 | - $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 494 | + if (!spip_connect()) return false; |
|
| 495 | + if ($operation!='raz') { |
|
| 496 | + $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 497 | + $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 498 | + if(defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL){ |
|
| 499 | + $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 500 | + $plugin_valides_supp = is_plugin_dir($plugin_valides_supp,_DIR_PLUGINS_SUPPL); |
|
| 501 | + $plugin_valides = array_merge($plugin_valides,$plugin_valides_supp); |
|
| 502 | + } |
|
| 503 | + // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 504 | + // on les reinjecte ici |
|
| 505 | + if (isset($GLOBALS['meta']['plugin_attente']) |
|
| 506 | + AND $a = unserialize($GLOBALS['meta']['plugin_attente'])) |
|
| 507 | + $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 508 | 508 | |
| 509 | - if ($operation=='ajoute') |
|
| 510 | - $plugin = array_merge($plugin_valides,$plugin); |
|
| 511 | - elseif ($operation=='enleve') |
|
| 512 | - $plugin = array_diff($plugin_valides,$plugin); |
|
| 513 | - else $plugin = $plugin_valides; |
|
| 514 | - } |
|
| 515 | - $actifs_avant = $GLOBALS['meta']['plugin']; |
|
| 516 | - |
|
| 517 | - // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 518 | - if ($ajouter_dependances = charger_fonction("ajouter_dependances","plugins",true)){ |
|
| 519 | - $plugin = $ajouter_dependances($plugin); |
|
| 520 | - } |
|
| 521 | - |
|
| 522 | - // recharger le xml des plugins a activer |
|
| 523 | - // on forcer le reload ici, meme si le fichier xml n'a pas change |
|
| 524 | - // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 525 | - // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 526 | - // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 527 | - list($infos,$liste) = liste_plugin_valides($plugin,true); |
|
| 528 | - // trouver l'ordre d'activation |
|
| 529 | - list($plugin_valides,$ordre,$reste) = plugin_trier($infos, $liste); |
|
| 530 | - if ($reste) plugins_erreurs($reste, $liste, $infos); |
|
| 531 | - // Ignorer les plugins necessitant une lib absente |
|
| 532 | - // et preparer la meta d'entete Http |
|
| 533 | - $err = $msg = $header = array(); |
|
| 534 | - foreach($plugin_valides as $p => $resume) { |
|
| 535 | - $header[]= $p.($resume['version']?"(".$resume['version'].")":""); |
|
| 536 | - if ($resume['dir']){ |
|
| 537 | - foreach($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 538 | - if (!find_in_path($l['nom'], 'lib/')) { |
|
| 539 | - $err[$p] = $resume; |
|
| 540 | - $msg[$p][] = $l; |
|
| 541 | - unset($plugin_valides[$p]); |
|
| 542 | - } |
|
| 543 | - } |
|
| 544 | - } |
|
| 545 | - } |
|
| 546 | - if ($err) plugins_erreurs($err, '', $infos, $msg); |
|
| 547 | - |
|
| 548 | - if (isset($GLOBALS['meta']['message_crash_plugins'])) |
|
| 549 | - effacer_meta('message_crash_plugins'); |
|
| 550 | - ecrire_meta('plugin',serialize($plugin_valides)); |
|
| 551 | - $liste = array_diff_key($liste,$plugin_valides); |
|
| 552 | - ecrire_meta('plugin_attente',serialize($liste)); |
|
| 553 | - $header = strtolower(implode(",",$header)); |
|
| 554 | - ecrire_meta('plugin_header',substr($header,0,900)); |
|
| 555 | - if (!isset($GLOBALS['spip_header_silencieux']) OR !$GLOBALS['spip_header_silencieux']) |
|
| 556 | - ecrire_fichier(_DIR_VAR."config.txt", (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY:"Composed-By: SPIP") . ' '. $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header); |
|
| 557 | - else |
|
| 558 | - @unlink(_DIR_VAR."config.txt"); |
|
| 559 | - // generer charger_plugins_chemin.php |
|
| 560 | - plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 561 | - // generer les fichiers |
|
| 562 | - // charger_plugins_options.php |
|
| 563 | - // charger_plugins_fonctions.php |
|
| 564 | - // et retourner les fichiers a verifier |
|
| 565 | - plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 566 | - // mise a jour de la matrice des pipelines |
|
| 567 | - pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 568 | - // generer le fichier _CACHE_PIPELINE |
|
| 569 | - pipeline_precompile(); |
|
| 570 | - |
|
| 571 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 572 | - spip_attend_invalidation_opcode_cache(); |
|
| 573 | - |
|
| 574 | - if (spip_connect()) { |
|
| 575 | - // lancer et initialiser les nouveaux crons ! |
|
| 576 | - include_spip('inc/genie'); |
|
| 577 | - genie_queue_watch_dist(); |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 509 | + if ($operation=='ajoute') |
|
| 510 | + $plugin = array_merge($plugin_valides,$plugin); |
|
| 511 | + elseif ($operation=='enleve') |
|
| 512 | + $plugin = array_diff($plugin_valides,$plugin); |
|
| 513 | + else $plugin = $plugin_valides; |
|
| 514 | + } |
|
| 515 | + $actifs_avant = $GLOBALS['meta']['plugin']; |
|
| 516 | + |
|
| 517 | + // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 518 | + if ($ajouter_dependances = charger_fonction("ajouter_dependances","plugins",true)){ |
|
| 519 | + $plugin = $ajouter_dependances($plugin); |
|
| 520 | + } |
|
| 521 | + |
|
| 522 | + // recharger le xml des plugins a activer |
|
| 523 | + // on forcer le reload ici, meme si le fichier xml n'a pas change |
|
| 524 | + // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 525 | + // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 526 | + // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 527 | + list($infos,$liste) = liste_plugin_valides($plugin,true); |
|
| 528 | + // trouver l'ordre d'activation |
|
| 529 | + list($plugin_valides,$ordre,$reste) = plugin_trier($infos, $liste); |
|
| 530 | + if ($reste) plugins_erreurs($reste, $liste, $infos); |
|
| 531 | + // Ignorer les plugins necessitant une lib absente |
|
| 532 | + // et preparer la meta d'entete Http |
|
| 533 | + $err = $msg = $header = array(); |
|
| 534 | + foreach($plugin_valides as $p => $resume) { |
|
| 535 | + $header[]= $p.($resume['version']?"(".$resume['version'].")":""); |
|
| 536 | + if ($resume['dir']){ |
|
| 537 | + foreach($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 538 | + if (!find_in_path($l['nom'], 'lib/')) { |
|
| 539 | + $err[$p] = $resume; |
|
| 540 | + $msg[$p][] = $l; |
|
| 541 | + unset($plugin_valides[$p]); |
|
| 542 | + } |
|
| 543 | + } |
|
| 544 | + } |
|
| 545 | + } |
|
| 546 | + if ($err) plugins_erreurs($err, '', $infos, $msg); |
|
| 547 | + |
|
| 548 | + if (isset($GLOBALS['meta']['message_crash_plugins'])) |
|
| 549 | + effacer_meta('message_crash_plugins'); |
|
| 550 | + ecrire_meta('plugin',serialize($plugin_valides)); |
|
| 551 | + $liste = array_diff_key($liste,$plugin_valides); |
|
| 552 | + ecrire_meta('plugin_attente',serialize($liste)); |
|
| 553 | + $header = strtolower(implode(",",$header)); |
|
| 554 | + ecrire_meta('plugin_header',substr($header,0,900)); |
|
| 555 | + if (!isset($GLOBALS['spip_header_silencieux']) OR !$GLOBALS['spip_header_silencieux']) |
|
| 556 | + ecrire_fichier(_DIR_VAR."config.txt", (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY:"Composed-By: SPIP") . ' '. $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header); |
|
| 557 | + else |
|
| 558 | + @unlink(_DIR_VAR."config.txt"); |
|
| 559 | + // generer charger_plugins_chemin.php |
|
| 560 | + plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 561 | + // generer les fichiers |
|
| 562 | + // charger_plugins_options.php |
|
| 563 | + // charger_plugins_fonctions.php |
|
| 564 | + // et retourner les fichiers a verifier |
|
| 565 | + plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 566 | + // mise a jour de la matrice des pipelines |
|
| 567 | + pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 568 | + // generer le fichier _CACHE_PIPELINE |
|
| 569 | + pipeline_precompile(); |
|
| 570 | + |
|
| 571 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 572 | + spip_attend_invalidation_opcode_cache(); |
|
| 573 | + |
|
| 574 | + if (spip_connect()) { |
|
| 575 | + // lancer et initialiser les nouveaux crons ! |
|
| 576 | + include_spip('inc/genie'); |
|
| 577 | + genie_queue_watch_dist(); |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | function plugins_precompile_chemin($plugin_valides, $ordre) |
| 584 | 584 | { |
| 585 | - $chemins = array(); |
|
| 586 | - $contenu = ""; |
|
| 587 | - foreach($ordre as $p => $info){ |
|
| 588 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 589 | - if (isset($plugin_valides[$p])){ |
|
| 590 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 591 | - $plug = $plugin_valides[$p]['dir']; |
|
| 592 | - // definir le plugin, donc le path avant l'include du fichier options |
|
| 593 | - // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 594 | - |
|
| 595 | - $dir = $dir_type.".'" . $plug ."/'"; |
|
| 585 | + $chemins = array(); |
|
| 586 | + $contenu = ""; |
|
| 587 | + foreach($ordre as $p => $info){ |
|
| 588 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 589 | + if (isset($plugin_valides[$p])){ |
|
| 590 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 591 | + $plug = $plugin_valides[$p]['dir']; |
|
| 592 | + // definir le plugin, donc le path avant l'include du fichier options |
|
| 593 | + // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 594 | + |
|
| 595 | + $dir = $dir_type.".'" . $plug ."/'"; |
|
| 596 | 596 | |
| 597 | - $prefix = strtoupper(preg_replace(',\W,','_',$info['prefix'])); |
|
| 598 | - if ($prefix!=="SPIP"){ |
|
| 599 | - $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 600 | - foreach($info['chemin'] as $chemin){ |
|
| 601 | - if (!isset($chemin['version']) OR plugin_version_compatible($chemin['version'],$GLOBALS['spip_version_branche'],'spip')){ |
|
| 602 | - $dir = $chemin['path']; |
|
| 603 | - if (strlen($dir) AND $dir{0}=="/") $dir = substr($dir,1); |
|
| 604 | - if (strlen($dir) AND $dir=="./") $dir = ''; |
|
| 605 | - if (strlen($dir)) $dir = rtrim($dir,'/').'/'; |
|
| 606 | - if (!isset($chemin['type']) OR $chemin['type']=='public') |
|
| 607 | - $chemins['public'][]="_DIR_PLUGIN_$prefix".(strlen($dir)?".'$dir'":""); |
|
| 608 | - if (!isset($chemin['type']) OR $chemin['type']=='prive') |
|
| 609 | - $chemins['prive'][]="_DIR_PLUGIN_$prefix".(strlen($dir)?".'$dir'":""); |
|
| 610 | - } |
|
| 611 | - } |
|
| 612 | - } |
|
| 613 | - } |
|
| 614 | - } |
|
| 615 | - if (count($chemins)){ |
|
| 616 | - $contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(".implode(',',array_reverse($chemins['public'])).")));\n" |
|
| 617 | - . "else _chemin(implode(':',array(".implode(',',array_reverse($chemins['prive'])).")));\n"; |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 597 | + $prefix = strtoupper(preg_replace(',\W,','_',$info['prefix'])); |
|
| 598 | + if ($prefix!=="SPIP"){ |
|
| 599 | + $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 600 | + foreach($info['chemin'] as $chemin){ |
|
| 601 | + if (!isset($chemin['version']) OR plugin_version_compatible($chemin['version'],$GLOBALS['spip_version_branche'],'spip')){ |
|
| 602 | + $dir = $chemin['path']; |
|
| 603 | + if (strlen($dir) AND $dir{0}=="/") $dir = substr($dir,1); |
|
| 604 | + if (strlen($dir) AND $dir=="./") $dir = ''; |
|
| 605 | + if (strlen($dir)) $dir = rtrim($dir,'/').'/'; |
|
| 606 | + if (!isset($chemin['type']) OR $chemin['type']=='public') |
|
| 607 | + $chemins['public'][]="_DIR_PLUGIN_$prefix".(strlen($dir)?".'$dir'":""); |
|
| 608 | + if (!isset($chemin['type']) OR $chemin['type']=='prive') |
|
| 609 | + $chemins['prive'][]="_DIR_PLUGIN_$prefix".(strlen($dir)?".'$dir'":""); |
|
| 610 | + } |
|
| 611 | + } |
|
| 612 | + } |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | + if (count($chemins)){ |
|
| 616 | + $contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(".implode(',',array_reverse($chemins['public'])).")));\n" |
|
| 617 | + . "else _chemin(implode(':',array(".implode(',',array_reverse($chemins['prive'])).")));\n"; |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | function plugins_precompile_xxxtions($plugin_valides, $ordre) |
| 624 | 624 | { |
| 625 | - $contenu = array('options' => '', 'fonctions' =>''); |
|
| 626 | - $boutons = array(); |
|
| 627 | - $onglets = array(); |
|
| 628 | - $sign = ""; |
|
| 629 | - |
|
| 630 | - foreach($ordre as $p => $info){ |
|
| 631 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 632 | - if (isset($plugin_valides[$p])){ |
|
| 633 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 634 | - $plug = $plugin_valides[$p]['dir']; |
|
| 635 | - $dir = constant($dir_type); |
|
| 636 | - $root_dir_type = str_replace('_DIR_','_ROOT_',$dir_type); |
|
| 637 | - if ($info['menu']) |
|
| 638 | - $boutons = array_merge($boutons,$info['menu']); |
|
| 639 | - if ($info['onglet']) |
|
| 640 | - $onglets = array_merge($onglets,$info['onglet']); |
|
| 641 | - foreach($contenu as $charge => $v){ |
|
| 642 | - // si pas declare/detecte a la lecture du paquet.xml, |
|
| 643 | - // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 644 | - // donc ni sa relecture, ni sa detection |
|
| 645 | - if (!isset($info[$charge]) |
|
| 646 | - AND $dir // exclure le cas du plugin "SPIP" |
|
| 647 | - AND strpos($dir,":")===false // exclure le cas des procure: |
|
| 648 | - AND file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 649 | - ){ |
|
| 650 | - if (is_readable("$dir$plug/".($file=$info['prefix']."_".$charge.".php"))){ |
|
| 651 | - $info[$charge] = array($file); |
|
| 652 | - } |
|
| 653 | - } |
|
| 654 | - if (isset($info[$charge])){ |
|
| 655 | - $files = $info[$charge]; |
|
| 656 | - foreach($files as $k=>$file){ |
|
| 657 | - // on genere un if file_exists devant chaque include |
|
| 658 | - // pour pouvoir garder le meme niveau d'erreur general |
|
| 659 | - $file = trim($file); |
|
| 660 | - if (!is_readable("$dir$plug/$file") |
|
| 661 | - // uniquement pour les paquet.xml |
|
| 662 | - AND file_exists("$dir$plug/paquet.xml")){ |
|
| 663 | - unset($info[$charge][$k]); |
|
| 664 | - } |
|
| 665 | - else { |
|
| 666 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 667 | - $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 668 | - } |
|
| 669 | - } |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - $sign .= md5(serialize($info)); |
|
| 673 | - } |
|
| 674 | - } |
|
| 675 | - |
|
| 676 | - $contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n" . $contenu['options']; |
|
| 677 | - $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons) |
|
| 678 | - . plugin_ongletbouton("onglets_plugins", $onglets); |
|
| 679 | - |
|
| 680 | - ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 681 | - ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 625 | + $contenu = array('options' => '', 'fonctions' =>''); |
|
| 626 | + $boutons = array(); |
|
| 627 | + $onglets = array(); |
|
| 628 | + $sign = ""; |
|
| 629 | + |
|
| 630 | + foreach($ordre as $p => $info){ |
|
| 631 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 632 | + if (isset($plugin_valides[$p])){ |
|
| 633 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 634 | + $plug = $plugin_valides[$p]['dir']; |
|
| 635 | + $dir = constant($dir_type); |
|
| 636 | + $root_dir_type = str_replace('_DIR_','_ROOT_',$dir_type); |
|
| 637 | + if ($info['menu']) |
|
| 638 | + $boutons = array_merge($boutons,$info['menu']); |
|
| 639 | + if ($info['onglet']) |
|
| 640 | + $onglets = array_merge($onglets,$info['onglet']); |
|
| 641 | + foreach($contenu as $charge => $v){ |
|
| 642 | + // si pas declare/detecte a la lecture du paquet.xml, |
|
| 643 | + // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 644 | + // donc ni sa relecture, ni sa detection |
|
| 645 | + if (!isset($info[$charge]) |
|
| 646 | + AND $dir // exclure le cas du plugin "SPIP" |
|
| 647 | + AND strpos($dir,":")===false // exclure le cas des procure: |
|
| 648 | + AND file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 649 | + ){ |
|
| 650 | + if (is_readable("$dir$plug/".($file=$info['prefix']."_".$charge.".php"))){ |
|
| 651 | + $info[$charge] = array($file); |
|
| 652 | + } |
|
| 653 | + } |
|
| 654 | + if (isset($info[$charge])){ |
|
| 655 | + $files = $info[$charge]; |
|
| 656 | + foreach($files as $k=>$file){ |
|
| 657 | + // on genere un if file_exists devant chaque include |
|
| 658 | + // pour pouvoir garder le meme niveau d'erreur general |
|
| 659 | + $file = trim($file); |
|
| 660 | + if (!is_readable("$dir$plug/$file") |
|
| 661 | + // uniquement pour les paquet.xml |
|
| 662 | + AND file_exists("$dir$plug/paquet.xml")){ |
|
| 663 | + unset($info[$charge][$k]); |
|
| 664 | + } |
|
| 665 | + else { |
|
| 666 | + $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 667 | + $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + $sign .= md5(serialize($info)); |
|
| 673 | + } |
|
| 674 | + } |
|
| 675 | + |
|
| 676 | + $contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n" . $contenu['options']; |
|
| 677 | + $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons) |
|
| 678 | + . plugin_ongletbouton("onglets_plugins", $onglets); |
|
| 679 | + |
|
| 680 | + ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 681 | + ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | function plugin_ongletbouton($nom, $val) |
| 685 | 685 | { |
| 686 | - if (!$val) $val = array(); |
|
| 687 | - define("_UPDATED_$nom",$val = serialize($val)); |
|
| 688 | - define("_UPDATED_md5_$nom",$md5=md5($val)); |
|
| 689 | - $val = "unserialize('".str_replace("'","\'",$val)."')"; |
|
| 690 | - return |
|
| 691 | - "if (!function_exists('$nom')) {\n" |
|
| 692 | - ."function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 693 | - ."function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n" |
|
| 694 | - ."}\n"; |
|
| 686 | + if (!$val) $val = array(); |
|
| 687 | + define("_UPDATED_$nom",$val = serialize($val)); |
|
| 688 | + define("_UPDATED_md5_$nom",$md5=md5($val)); |
|
| 689 | + $val = "unserialize('".str_replace("'","\'",$val)."')"; |
|
| 690 | + return |
|
| 691 | + "if (!function_exists('$nom')) {\n" |
|
| 692 | + ."function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 693 | + ."function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n" |
|
| 694 | + ."}\n"; |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | // creer le fichier CACHE_PLUGIN_VERIF a partir de |
@@ -700,146 +700,146 @@ discard block |
||
| 700 | 700 | |
| 701 | 701 | function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) |
| 702 | 702 | { |
| 703 | - static $liste_pipe_manquants=array(); |
|
| 704 | - if (($pipe_recherche)&&(!in_array($pipe_recherche,$liste_pipe_manquants))) |
|
| 705 | - $liste_pipe_manquants[]=$pipe_recherche; |
|
| 706 | - |
|
| 707 | - foreach($ordre as $p => $info){ |
|
| 708 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 709 | - if (isset($plugin_valides[$p])){ |
|
| 710 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 711 | - $root_dir_type = str_replace('_DIR_','_ROOT_',$dir_type); |
|
| 712 | - $plug = $plugin_valides[$p]['dir']; |
|
| 713 | - $prefix = (($info['prefix']=="spip")?"":$info['prefix']."_"); |
|
| 714 | - if (isset($info['pipeline']) AND is_array($info['pipeline'])){ |
|
| 715 | - foreach($info['pipeline'] as $pipe){ |
|
| 716 | - $nom = $pipe['nom']; |
|
| 717 | - if (isset($pipe['action'])) |
|
| 718 | - $action = $pipe['action']; |
|
| 719 | - else |
|
| 720 | - $action = $nom; |
|
| 721 | - $nomlower = strtolower($nom); |
|
| 722 | - if ($nomlower!=$nom |
|
| 723 | - AND isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 724 | - AND !isset($GLOBALS['spip_pipeline'][$nomlower])){ |
|
| 725 | - $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 726 | - unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 727 | - } |
|
| 728 | - $nom = $nomlower; |
|
| 729 | - // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 730 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel |
|
| 731 | - $GLOBALS['spip_pipeline'][$nom]=""; |
|
| 732 | - if ($action){ |
|
| 733 | - if (strpos($GLOBALS['spip_pipeline'][$nom],"|$prefix$action")===FALSE) |
|
| 734 | - $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),","|$prefix$action\\1",$GLOBALS['spip_pipeline'][$nom],1); |
|
| 735 | - if (isset($pipe['inclure'])){ |
|
| 736 | - $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 737 | - "$root_dir_type:$plug/".$pipe['inclure']; |
|
| 738 | - } |
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - } |
|
| 742 | - } |
|
| 743 | - } |
|
| 703 | + static $liste_pipe_manquants=array(); |
|
| 704 | + if (($pipe_recherche)&&(!in_array($pipe_recherche,$liste_pipe_manquants))) |
|
| 705 | + $liste_pipe_manquants[]=$pipe_recherche; |
|
| 706 | + |
|
| 707 | + foreach($ordre as $p => $info){ |
|
| 708 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 709 | + if (isset($plugin_valides[$p])){ |
|
| 710 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 711 | + $root_dir_type = str_replace('_DIR_','_ROOT_',$dir_type); |
|
| 712 | + $plug = $plugin_valides[$p]['dir']; |
|
| 713 | + $prefix = (($info['prefix']=="spip")?"":$info['prefix']."_"); |
|
| 714 | + if (isset($info['pipeline']) AND is_array($info['pipeline'])){ |
|
| 715 | + foreach($info['pipeline'] as $pipe){ |
|
| 716 | + $nom = $pipe['nom']; |
|
| 717 | + if (isset($pipe['action'])) |
|
| 718 | + $action = $pipe['action']; |
|
| 719 | + else |
|
| 720 | + $action = $nom; |
|
| 721 | + $nomlower = strtolower($nom); |
|
| 722 | + if ($nomlower!=$nom |
|
| 723 | + AND isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 724 | + AND !isset($GLOBALS['spip_pipeline'][$nomlower])){ |
|
| 725 | + $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 726 | + unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 727 | + } |
|
| 728 | + $nom = $nomlower; |
|
| 729 | + // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 730 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel |
|
| 731 | + $GLOBALS['spip_pipeline'][$nom]=""; |
|
| 732 | + if ($action){ |
|
| 733 | + if (strpos($GLOBALS['spip_pipeline'][$nom],"|$prefix$action")===FALSE) |
|
| 734 | + $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),","|$prefix$action\\1",$GLOBALS['spip_pipeline'][$nom],1); |
|
| 735 | + if (isset($pipe['inclure'])){ |
|
| 736 | + $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 737 | + "$root_dir_type:$plug/".$pipe['inclure']; |
|
| 738 | + } |
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + } |
|
| 742 | + } |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - // on charge les fichiers d'options qui peuvent completer |
|
| 746 | - // la globale spip_pipeline egalement |
|
| 747 | - if (@is_readable(_CACHE_PLUGINS_PATH)) |
|
| 748 | - include_once(_CACHE_PLUGINS_PATH); // securite : a priori n'a pu etre fait plus tot |
|
| 749 | - if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 750 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 751 | - } else { |
|
| 752 | - spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT); |
|
| 753 | - } |
|
| 745 | + // on charge les fichiers d'options qui peuvent completer |
|
| 746 | + // la globale spip_pipeline egalement |
|
| 747 | + if (@is_readable(_CACHE_PLUGINS_PATH)) |
|
| 748 | + include_once(_CACHE_PLUGINS_PATH); // securite : a priori n'a pu etre fait plus tot |
|
| 749 | + if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 750 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 751 | + } else { |
|
| 752 | + spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT); |
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | - // on ajoute les pipe qui ont ete recenses manquants |
|
| 756 | - foreach($liste_pipe_manquants as $add_pipe) |
|
| 757 | - if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) |
|
| 758 | - $GLOBALS['spip_pipeline'][$add_pipe]= ''; |
|
| 755 | + // on ajoute les pipe qui ont ete recenses manquants |
|
| 756 | + foreach($liste_pipe_manquants as $add_pipe) |
|
| 757 | + if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) |
|
| 758 | + $GLOBALS['spip_pipeline'][$add_pipe]= ''; |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | // precompilation des pipelines |
| 762 | 762 | // http://doc.spip.org/@pipeline_precompile |
| 763 | 763 | function pipeline_precompile(){ |
| 764 | - global $spip_pipeline, $spip_matrice; |
|
| 765 | - |
|
| 766 | - $content = ""; |
|
| 767 | - foreach($spip_pipeline as $action=>$pipeline){ |
|
| 768 | - $s_inc = ""; |
|
| 769 | - $s_call = ""; |
|
| 770 | - $pipe = array_filter(explode('|',$pipeline)); |
|
| 771 | - // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 772 | - foreach ($pipe as $fonc) { |
|
| 773 | - $fonc = trim($fonc); |
|
| 774 | - $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; |
|
| 775 | - if (isset($spip_matrice[$fonc])){ |
|
| 776 | - $file = $spip_matrice[$fonc]; |
|
| 777 | - $file = "'$file'"; |
|
| 778 | - // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 779 | - if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums",$file,$regs)){ |
|
| 780 | - $dir = $regs[1]; |
|
| 781 | - $root_dir = str_replace('_DIR_','_ROOT_',$dir); |
|
| 782 | - if (defined($root_dir)) |
|
| 783 | - $dir = $root_dir; |
|
| 784 | - $file = str_replace($regs[0],"'.".$dir.".'",$file); |
|
| 785 | - $file = str_replace("''.","",$file); |
|
| 786 | - $file = str_replace(constant($dir), '', $file); |
|
| 787 | - } |
|
| 788 | - $s_inc .= "include_once_check($file);\n"; |
|
| 789 | - } |
|
| 790 | - } |
|
| 791 | - if (strlen($s_inc)) |
|
| 792 | - $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 793 | - $content .= "// Pipeline $action \n" |
|
| 794 | - . "function execute_pipeline_$action(&\$val){\n" |
|
| 795 | - . $s_inc |
|
| 796 | - . $s_call |
|
| 797 | - . "return \$val;\n}\n"; |
|
| 798 | - } |
|
| 799 | - ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 800 | - clear_path_cache(); |
|
| 764 | + global $spip_pipeline, $spip_matrice; |
|
| 765 | + |
|
| 766 | + $content = ""; |
|
| 767 | + foreach($spip_pipeline as $action=>$pipeline){ |
|
| 768 | + $s_inc = ""; |
|
| 769 | + $s_call = ""; |
|
| 770 | + $pipe = array_filter(explode('|',$pipeline)); |
|
| 771 | + // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 772 | + foreach ($pipe as $fonc) { |
|
| 773 | + $fonc = trim($fonc); |
|
| 774 | + $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; |
|
| 775 | + if (isset($spip_matrice[$fonc])){ |
|
| 776 | + $file = $spip_matrice[$fonc]; |
|
| 777 | + $file = "'$file'"; |
|
| 778 | + // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 779 | + if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums",$file,$regs)){ |
|
| 780 | + $dir = $regs[1]; |
|
| 781 | + $root_dir = str_replace('_DIR_','_ROOT_',$dir); |
|
| 782 | + if (defined($root_dir)) |
|
| 783 | + $dir = $root_dir; |
|
| 784 | + $file = str_replace($regs[0],"'.".$dir.".'",$file); |
|
| 785 | + $file = str_replace("''.","",$file); |
|
| 786 | + $file = str_replace(constant($dir), '', $file); |
|
| 787 | + } |
|
| 788 | + $s_inc .= "include_once_check($file);\n"; |
|
| 789 | + } |
|
| 790 | + } |
|
| 791 | + if (strlen($s_inc)) |
|
| 792 | + $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 793 | + $content .= "// Pipeline $action \n" |
|
| 794 | + . "function execute_pipeline_$action(&\$val){\n" |
|
| 795 | + . $s_inc |
|
| 796 | + . $s_call |
|
| 797 | + . "return \$val;\n}\n"; |
|
| 798 | + } |
|
| 799 | + ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 800 | + clear_path_cache(); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | |
| 804 | 804 | // http://doc.spip.org/@plugin_est_installe |
| 805 | 805 | function plugin_est_installe($plug_path){ |
| 806 | - $plugin_installes = isset($GLOBALS['meta']['plugin_installes'])?unserialize($GLOBALS['meta']['plugin_installes']):array(); |
|
| 807 | - if (!$plugin_installes) return false; |
|
| 808 | - return in_array($plug_path,$plugin_installes); |
|
| 806 | + $plugin_installes = isset($GLOBALS['meta']['plugin_installes'])?unserialize($GLOBALS['meta']['plugin_installes']):array(); |
|
| 807 | + if (!$plugin_installes) return false; |
|
| 808 | + return in_array($plug_path,$plugin_installes); |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | |
| 812 | 812 | function plugin_installes_meta() |
| 813 | 813 | { |
| 814 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 815 | - $meta_plug_installes = array(); |
|
| 816 | - foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix=>$resume) { |
|
| 817 | - if ($plug = $resume['dir']){ |
|
| 818 | - $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 819 | - if ($infos){ |
|
| 820 | - if (!is_array($infos) OR $infos['install_test'][0]) |
|
| 821 | - $meta_plug_installes[] = $plug; |
|
| 822 | - if (is_array($infos)){ |
|
| 823 | - list($ok, $trace) = $infos['install_test']; |
|
| 824 | - include_spip('inc/filtres_boites'); |
|
| 825 | - echo "<div class='install-plugins svp_retour'>" |
|
| 826 | - .boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))), ($ok ? 'success' : 'error')) |
|
| 827 | - .$trace |
|
| 828 | - ."<div class='result'>" |
|
| 829 | - .($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec")) |
|
| 830 | - ."</div>" |
|
| 831 | - .boite_fermer() |
|
| 832 | - ."</div>"; |
|
| 833 | - } |
|
| 834 | - } |
|
| 835 | - } |
|
| 836 | - } |
|
| 837 | - ecrire_meta('plugin_installes',serialize($meta_plug_installes),'non'); |
|
| 814 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 815 | + $meta_plug_installes = array(); |
|
| 816 | + foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix=>$resume) { |
|
| 817 | + if ($plug = $resume['dir']){ |
|
| 818 | + $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 819 | + if ($infos){ |
|
| 820 | + if (!is_array($infos) OR $infos['install_test'][0]) |
|
| 821 | + $meta_plug_installes[] = $plug; |
|
| 822 | + if (is_array($infos)){ |
|
| 823 | + list($ok, $trace) = $infos['install_test']; |
|
| 824 | + include_spip('inc/filtres_boites'); |
|
| 825 | + echo "<div class='install-plugins svp_retour'>" |
|
| 826 | + .boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))), ($ok ? 'success' : 'error')) |
|
| 827 | + .$trace |
|
| 828 | + ."<div class='result'>" |
|
| 829 | + .($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec")) |
|
| 830 | + ."</div>" |
|
| 831 | + .boite_fermer() |
|
| 832 | + ."</div>"; |
|
| 833 | + } |
|
| 834 | + } |
|
| 835 | + } |
|
| 836 | + } |
|
| 837 | + ecrire_meta('plugin_installes',serialize($meta_plug_installes),'non'); |
|
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | function ecrire_fichier_php($nom, $contenu, $comment='') |
| 841 | 841 | { |
| 842 | - ecrire_fichier($nom, |
|
| 843 | - '<'.'?php' . "\n" . $comment ."\nif (defined('_ECRIRE_INC_VERSION')) {\n". $contenu . "}\n?".'>'); |
|
| 842 | + ecrire_fichier($nom, |
|
| 843 | + '<'.'?php' . "\n" . $comment ."\nif (defined('_ECRIRE_INC_VERSION')) {\n". $contenu . "}\n?".'>'); |
|
| 844 | 844 | } |
| 845 | 845 | |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | * @return array |
| 23 | 23 | */ |
| 24 | 24 | function inc_simplexml_to_array_dist($u, $utiliser_namespace=false){ |
| 25 | - // decoder la chaine en SimpleXML si pas deja fait |
|
| 26 | - if (is_string($u)) |
|
| 27 | - $u = simplexml_load_string($u); |
|
| 28 | - return array('root'=>@xmlObjToArr($u, $utiliser_namespace)); |
|
| 25 | + // decoder la chaine en SimpleXML si pas deja fait |
|
| 26 | + if (is_string($u)) |
|
| 27 | + $u = simplexml_load_string($u); |
|
| 28 | + return array('root'=>@xmlObjToArr($u, $utiliser_namespace)); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
@@ -40,65 +40,65 @@ discard block |
||
| 40 | 40 | **/ |
| 41 | 41 | function xmlObjToArr($obj, $utiliser_namespace=false) { |
| 42 | 42 | |
| 43 | - $tableau = array(); |
|
| 44 | - |
|
| 45 | - // Cette fonction getDocNamespaces() est longue sur de gros xml. On permet donc |
|
| 46 | - // de l'activer ou pas suivant le contenu supposé du XML |
|
| 47 | - if (is_object($obj)) { |
|
| 48 | - if (is_array($utiliser_namespace)){ |
|
| 49 | - $namespace = $utiliser_namespace; |
|
| 50 | - } |
|
| 51 | - else { |
|
| 52 | - if ($utiliser_namespace) |
|
| 53 | - $namespace = $obj->getDocNamespaces(true); |
|
| 54 | - $namespace[NULL] = NULL; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $name = strtolower((string)$obj->getName()); |
|
| 58 | - $text = trim((string)$obj); |
|
| 59 | - if (strlen($text) <= 0) { |
|
| 60 | - $text = NULL; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - $children = array(); |
|
| 64 | - $attributes = array(); |
|
| 65 | - |
|
| 66 | - // get info for all namespaces |
|
| 67 | - foreach( $namespace as $ns=>$nsUrl ) { |
|
| 68 | - // attributes |
|
| 69 | - $objAttributes = $obj->attributes($ns, true); |
|
| 70 | - foreach( $objAttributes as $attributeName => $attributeValue ) { |
|
| 71 | - $attribName = strtolower(trim((string)$attributeName)); |
|
| 72 | - $attribVal = trim((string)$attributeValue); |
|
| 73 | - if (!empty($ns)) { |
|
| 74 | - $attribName = $ns . ':' . $attribName; |
|
| 75 | - } |
|
| 76 | - $attributes[$attribName] = $attribVal; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // children |
|
| 80 | - $objChildren = $obj->children($ns, true); |
|
| 81 | - foreach( $objChildren as $childName=>$child ) { |
|
| 82 | - $childName = strtolower((string)$childName); |
|
| 83 | - if( !empty($ns) ) { |
|
| 84 | - $childName = $ns.':'.$childName; |
|
| 85 | - } |
|
| 86 | - $children[$childName][] = xmlObjToArr($child, $namespace); |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - $tableau = array( |
|
| 91 | - 'name'=>$name, |
|
| 92 | - ); |
|
| 93 | - if ($text) |
|
| 94 | - $tableau['text'] = $text; |
|
| 95 | - if ($attributes) |
|
| 96 | - $tableau['attributes'] = $attributes; |
|
| 97 | - if ($children) |
|
| 98 | - $tableau['children'] = $children; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $tableau; |
|
| 43 | + $tableau = array(); |
|
| 44 | + |
|
| 45 | + // Cette fonction getDocNamespaces() est longue sur de gros xml. On permet donc |
|
| 46 | + // de l'activer ou pas suivant le contenu supposé du XML |
|
| 47 | + if (is_object($obj)) { |
|
| 48 | + if (is_array($utiliser_namespace)){ |
|
| 49 | + $namespace = $utiliser_namespace; |
|
| 50 | + } |
|
| 51 | + else { |
|
| 52 | + if ($utiliser_namespace) |
|
| 53 | + $namespace = $obj->getDocNamespaces(true); |
|
| 54 | + $namespace[NULL] = NULL; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $name = strtolower((string)$obj->getName()); |
|
| 58 | + $text = trim((string)$obj); |
|
| 59 | + if (strlen($text) <= 0) { |
|
| 60 | + $text = NULL; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + $children = array(); |
|
| 64 | + $attributes = array(); |
|
| 65 | + |
|
| 66 | + // get info for all namespaces |
|
| 67 | + foreach( $namespace as $ns=>$nsUrl ) { |
|
| 68 | + // attributes |
|
| 69 | + $objAttributes = $obj->attributes($ns, true); |
|
| 70 | + foreach( $objAttributes as $attributeName => $attributeValue ) { |
|
| 71 | + $attribName = strtolower(trim((string)$attributeName)); |
|
| 72 | + $attribVal = trim((string)$attributeValue); |
|
| 73 | + if (!empty($ns)) { |
|
| 74 | + $attribName = $ns . ':' . $attribName; |
|
| 75 | + } |
|
| 76 | + $attributes[$attribName] = $attribVal; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // children |
|
| 80 | + $objChildren = $obj->children($ns, true); |
|
| 81 | + foreach( $objChildren as $childName=>$child ) { |
|
| 82 | + $childName = strtolower((string)$childName); |
|
| 83 | + if( !empty($ns) ) { |
|
| 84 | + $childName = $ns.':'.$childName; |
|
| 85 | + } |
|
| 86 | + $children[$childName][] = xmlObjToArr($child, $namespace); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + $tableau = array( |
|
| 91 | + 'name'=>$name, |
|
| 92 | + ); |
|
| 93 | + if ($text) |
|
| 94 | + $tableau['text'] = $text; |
|
| 95 | + if ($attributes) |
|
| 96 | + $tableau['attributes'] = $attributes; |
|
| 97 | + if ($children) |
|
| 98 | + $tableau['children'] = $children; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + return $tableau; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | ?> |
@@ -22,104 +22,104 @@ |
||
| 22 | 22 | // http://doc.spip.org/@inc_couleurs_dist |
| 23 | 23 | function inc_couleurs_dist($choix=NULL, $ajouter=false) |
| 24 | 24 | { |
| 25 | - static $couleurs_spip = array( |
|
| 25 | + static $couleurs_spip = array( |
|
| 26 | 26 | // Vert |
| 27 | 27 | 1 => array ( |
| 28 | - "couleur_foncee" => "#9DBA00", |
|
| 29 | - "couleur_claire" => "#C5E41C", |
|
| 30 | - "couleur_lien" => "#657701", |
|
| 31 | - "couleur_lien_off" => "#A6C113" |
|
| 32 | - ), |
|
| 28 | + "couleur_foncee" => "#9DBA00", |
|
| 29 | + "couleur_claire" => "#C5E41C", |
|
| 30 | + "couleur_lien" => "#657701", |
|
| 31 | + "couleur_lien_off" => "#A6C113" |
|
| 32 | + ), |
|
| 33 | 33 | // Violet clair |
| 34 | 34 | 2 => array ( |
| 35 | - "couleur_foncee" => "#eb68b3", |
|
| 36 | - "couleur_claire" => "#ffa9e6", |
|
| 37 | - "couleur_lien" => "#8F004D", |
|
| 38 | - "couleur_lien_off" => "#BE6B97" |
|
| 39 | - ), |
|
| 35 | + "couleur_foncee" => "#eb68b3", |
|
| 36 | + "couleur_claire" => "#ffa9e6", |
|
| 37 | + "couleur_lien" => "#8F004D", |
|
| 38 | + "couleur_lien_off" => "#BE6B97" |
|
| 39 | + ), |
|
| 40 | 40 | // Orange |
| 41 | 41 | 3 => array ( |
| 42 | - "couleur_foncee" => "#fa9a00", |
|
| 43 | - "couleur_claire" => "#ffc000", |
|
| 44 | - "couleur_lien" => "#FF5B00", |
|
| 45 | - "couleur_lien_off" => "#B49280" |
|
| 46 | - ), |
|
| 42 | + "couleur_foncee" => "#fa9a00", |
|
| 43 | + "couleur_claire" => "#ffc000", |
|
| 44 | + "couleur_lien" => "#FF5B00", |
|
| 45 | + "couleur_lien_off" => "#B49280" |
|
| 46 | + ), |
|
| 47 | 47 | // Saumon |
| 48 | 48 | 4 => array ( |
| 49 | - "couleur_foncee" => "#CDA261", |
|
| 50 | - "couleur_claire" => "#FFDDAA", |
|
| 51 | - "couleur_lien" => "#AA6A09", |
|
| 52 | - "couleur_lien_off" => "#B79562" |
|
| 53 | - ), |
|
| 49 | + "couleur_foncee" => "#CDA261", |
|
| 50 | + "couleur_claire" => "#FFDDAA", |
|
| 51 | + "couleur_lien" => "#AA6A09", |
|
| 52 | + "couleur_lien_off" => "#B79562" |
|
| 53 | + ), |
|
| 54 | 54 | // Bleu pastel |
| 55 | 55 | 5 => array ( |
| 56 | - "couleur_foncee" => "#5da7c5", |
|
| 57 | - "couleur_claire" => "#97d2e1", |
|
| 58 | - "couleur_lien" => "#116587", |
|
| 59 | - "couleur_lien_off" => "#81B7CD" |
|
| 60 | - ), |
|
| 56 | + "couleur_foncee" => "#5da7c5", |
|
| 57 | + "couleur_claire" => "#97d2e1", |
|
| 58 | + "couleur_lien" => "#116587", |
|
| 59 | + "couleur_lien_off" => "#81B7CD" |
|
| 60 | + ), |
|
| 61 | 61 | // Gris |
| 62 | 62 | 6 => array ( |
| 63 | - "couleur_foncee" => "#85909A", |
|
| 64 | - "couleur_claire" => "#C0CAD4", |
|
| 65 | - "couleur_lien" => "#3B5063", |
|
| 66 | - "couleur_lien_off" => "#6D8499" |
|
| 67 | - ), |
|
| 63 | + "couleur_foncee" => "#85909A", |
|
| 64 | + "couleur_claire" => "#C0CAD4", |
|
| 65 | + "couleur_lien" => "#3B5063", |
|
| 66 | + "couleur_lien_off" => "#6D8499" |
|
| 67 | + ), |
|
| 68 | 68 | // Vert de gris |
| 69 | 69 | 7 => array ( |
| 70 | - "couleur_foncee" => "#999966", |
|
| 71 | - "couleur_claire" => "#CCCC99", |
|
| 72 | - "couleur_lien" => "#666633", |
|
| 73 | - "couleur_lien_off" => "#999966" |
|
| 74 | - ), |
|
| 70 | + "couleur_foncee" => "#999966", |
|
| 71 | + "couleur_claire" => "#CCCC99", |
|
| 72 | + "couleur_lien" => "#666633", |
|
| 73 | + "couleur_lien_off" => "#999966" |
|
| 74 | + ), |
|
| 75 | 75 | // Rose vieux |
| 76 | 76 | 8 => array ( |
| 77 | - "couleur_foncee" => "#EB68B3", |
|
| 78 | - "couleur_claire" => "#E4A7C5", |
|
| 79 | - "couleur_lien" => "#8F004D", |
|
| 80 | - "couleur_lien_off" => "#BE6B97" |
|
| 81 | - ), |
|
| 77 | + "couleur_foncee" => "#EB68B3", |
|
| 78 | + "couleur_claire" => "#E4A7C5", |
|
| 79 | + "couleur_lien" => "#8F004D", |
|
| 80 | + "couleur_lien_off" => "#BE6B97" |
|
| 81 | + ), |
|
| 82 | 82 | // Violet |
| 83 | 83 | 9 => array ( |
| 84 | - "couleur_foncee" => "#8F8FBD", |
|
| 85 | - "couleur_claire" => "#C4C4DD", |
|
| 86 | - "couleur_lien" => "#6071A5", |
|
| 87 | - "couleur_lien_off" => "#5C5C8C" |
|
| 88 | - ), |
|
| 84 | + "couleur_foncee" => "#8F8FBD", |
|
| 85 | + "couleur_claire" => "#C4C4DD", |
|
| 86 | + "couleur_lien" => "#6071A5", |
|
| 87 | + "couleur_lien_off" => "#5C5C8C" |
|
| 88 | + ), |
|
| 89 | 89 | // Gris |
| 90 | 90 | 10 => array ( |
| 91 | - "couleur_foncee" => "#909090", |
|
| 92 | - "couleur_claire" => "#D3D3D3", |
|
| 93 | - "couleur_lien" => "#808080", |
|
| 94 | - "couleur_lien_off" => "#909090" |
|
| 95 | - ), |
|
| 91 | + "couleur_foncee" => "#909090", |
|
| 92 | + "couleur_claire" => "#D3D3D3", |
|
| 93 | + "couleur_lien" => "#808080", |
|
| 94 | + "couleur_lien_off" => "#909090" |
|
| 95 | + ), |
|
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | - if (is_numeric($choix)) { |
|
| 99 | - // Compatibilite ascendante (plug-ins notamment) |
|
| 100 | - $GLOBALS["couleur_claire"] = $couleurs_spip[$choix]['couleur_claire']; |
|
| 101 | - $GLOBALS["couleur_foncee"] = $couleurs_spip[$choix]['couleur_foncee']; |
|
| 102 | - $GLOBALS["couleur_lien"] = $couleurs_spip[$choix]['couleur_lien']; |
|
| 103 | - $GLOBALS["couleur_lien_off"] = $couleurs_spip[$choix]['couleur_lien_off']; |
|
| 98 | + if (is_numeric($choix)) { |
|
| 99 | + // Compatibilite ascendante (plug-ins notamment) |
|
| 100 | + $GLOBALS["couleur_claire"] = $couleurs_spip[$choix]['couleur_claire']; |
|
| 101 | + $GLOBALS["couleur_foncee"] = $couleurs_spip[$choix]['couleur_foncee']; |
|
| 102 | + $GLOBALS["couleur_lien"] = $couleurs_spip[$choix]['couleur_lien']; |
|
| 103 | + $GLOBALS["couleur_lien_off"] = $couleurs_spip[$choix]['couleur_lien_off']; |
|
| 104 | 104 | |
| 105 | - return |
|
| 106 | - "couleur_claire=" . |
|
| 107 | - substr($couleurs_spip[$choix]['couleur_claire'],1). |
|
| 108 | - '&couleur_foncee=' . |
|
| 109 | - substr($couleurs_spip[$choix]['couleur_foncee'],1); |
|
| 110 | - } else { |
|
| 111 | - if (is_array($choix)) { |
|
| 112 | - if ($ajouter) { |
|
| 113 | - foreach($choix as $c) |
|
| 114 | - $couleurs_spip[] = $c; |
|
| 115 | - return $couleurs_spip; |
|
| 116 | - } else { |
|
| 117 | - return $couleurs_spip = $choix; |
|
| 118 | - } |
|
| 119 | - } |
|
| 105 | + return |
|
| 106 | + "couleur_claire=" . |
|
| 107 | + substr($couleurs_spip[$choix]['couleur_claire'],1). |
|
| 108 | + '&couleur_foncee=' . |
|
| 109 | + substr($couleurs_spip[$choix]['couleur_foncee'],1); |
|
| 110 | + } else { |
|
| 111 | + if (is_array($choix)) { |
|
| 112 | + if ($ajouter) { |
|
| 113 | + foreach($choix as $c) |
|
| 114 | + $couleurs_spip[] = $c; |
|
| 115 | + return $couleurs_spip; |
|
| 116 | + } else { |
|
| 117 | + return $couleurs_spip = $choix; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - } |
|
| 122 | - return $couleurs_spip; |
|
| 121 | + } |
|
| 122 | + return $couleurs_spip; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | ?> |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 15 | 15 | if (!defined('_AUTO_SELECTION_RUBRIQUE')) |
| 16 | - define('_AUTO_SELECTION_RUBRIQUE',false); |
|
| 16 | + define('_AUTO_SELECTION_RUBRIQUE',false); |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -26,32 +26,32 @@ discard block |
||
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | 28 | function inc_preselectionner_parent_nouvel_objet_dist($objet, $row){ |
| 29 | - if (!_AUTO_SELECTION_RUBRIQUE) |
|
| 30 | - return ''; |
|
| 31 | - |
|
| 32 | - if (!isset($row['id_rubrique'])) |
|
| 33 | - return ''; |
|
| 34 | - |
|
| 35 | - $id_rubrique = ''; |
|
| 36 | - if ($GLOBALS['connect_id_rubrique']){ |
|
| 37 | - // si admin restreint : sa rubrique |
|
| 38 | - $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
|
| 39 | - } |
|
| 40 | - else { |
|
| 41 | - // sinon la derniere rubrique cree |
|
| 42 | - $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "", "", "id_rubrique DESC", "0,1"); |
|
| 43 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 44 | - } |
|
| 45 | - // si le choix ne convient pas, on cherche dans un secteur |
|
| 46 | - if (!autoriser('creer'.$objet.'dans','rubrique',$id_rubrique)){ |
|
| 47 | - $id_rubrique = ''; |
|
| 48 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 49 | - $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 50 | - while (!$id_rubrique AND $row_rub = sql_fetch($res)){ |
|
| 51 | - if (autoriser('creer'.$objet.'dans','rubrique',$row_rub['id_rubrique'])) |
|
| 52 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - return $id_rubrique; |
|
| 29 | + if (!_AUTO_SELECTION_RUBRIQUE) |
|
| 30 | + return ''; |
|
| 31 | + |
|
| 32 | + if (!isset($row['id_rubrique'])) |
|
| 33 | + return ''; |
|
| 34 | + |
|
| 35 | + $id_rubrique = ''; |
|
| 36 | + if ($GLOBALS['connect_id_rubrique']){ |
|
| 37 | + // si admin restreint : sa rubrique |
|
| 38 | + $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
|
| 39 | + } |
|
| 40 | + else { |
|
| 41 | + // sinon la derniere rubrique cree |
|
| 42 | + $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "", "", "id_rubrique DESC", "0,1"); |
|
| 43 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 44 | + } |
|
| 45 | + // si le choix ne convient pas, on cherche dans un secteur |
|
| 46 | + if (!autoriser('creer'.$objet.'dans','rubrique',$id_rubrique)){ |
|
| 47 | + $id_rubrique = ''; |
|
| 48 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 49 | + $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 50 | + while (!$id_rubrique AND $row_rub = sql_fetch($res)){ |
|
| 51 | + if (autoriser('creer'.$objet.'dans','rubrique',$row_rub['id_rubrique'])) |
|
| 52 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + return $id_rubrique; |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -43,84 +43,84 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | */ |
| 45 | 45 | function urls_decoder_url($url, $fond='', $contexte=array(), $assembler=false){ |
| 46 | - static $current_base = null; |
|
| 47 | - // les anciennes fonctions modifient directement les globales |
|
| 48 | - // on les sauve avant l'appel, et on les retablit apres ! |
|
| 49 | - $save = array(@$GLOBALS['fond'],@$GLOBALS['contexte'],@$_SERVER['REDIRECT_url_propre'],@$_ENV['url_propre'],$GLOBALS['profondeur_url']); |
|
| 50 | - if (is_null($current_base)){ |
|
| 51 | - include_spip('inc/filtres_mini'); |
|
| 52 | - // le decodage des urls se fait toujours par rapport au site public |
|
| 53 | - $current_base = url_absolue(_DIR_RACINE?_DIR_RACINE:'./'); |
|
| 54 | - } |
|
| 55 | - if (strncmp($url,$current_base,strlen($current_base))==0) |
|
| 56 | - $url = substr($url,strlen($current_base)); |
|
| 46 | + static $current_base = null; |
|
| 47 | + // les anciennes fonctions modifient directement les globales |
|
| 48 | + // on les sauve avant l'appel, et on les retablit apres ! |
|
| 49 | + $save = array(@$GLOBALS['fond'],@$GLOBALS['contexte'],@$_SERVER['REDIRECT_url_propre'],@$_ENV['url_propre'],$GLOBALS['profondeur_url']); |
|
| 50 | + if (is_null($current_base)){ |
|
| 51 | + include_spip('inc/filtres_mini'); |
|
| 52 | + // le decodage des urls se fait toujours par rapport au site public |
|
| 53 | + $current_base = url_absolue(_DIR_RACINE?_DIR_RACINE:'./'); |
|
| 54 | + } |
|
| 55 | + if (strncmp($url,$current_base,strlen($current_base))==0) |
|
| 56 | + $url = substr($url,strlen($current_base)); |
|
| 57 | 57 | |
| 58 | - // si on est pas en train d'assembler la page principale, |
|
| 59 | - // vider les globales url propres qui ne doivent pas etre utilisees en cas |
|
| 60 | - // d'inversion url => objet |
|
| 61 | - if (!$assembler) { |
|
| 62 | - unset($_SERVER['REDIRECT_url_propre']); |
|
| 63 | - unset($_ENV['url_propre']); |
|
| 64 | - include_spip('inc/filtres_mini'); |
|
| 65 | - if (strpos($url,"://")===false){ |
|
| 58 | + // si on est pas en train d'assembler la page principale, |
|
| 59 | + // vider les globales url propres qui ne doivent pas etre utilisees en cas |
|
| 60 | + // d'inversion url => objet |
|
| 61 | + if (!$assembler) { |
|
| 62 | + unset($_SERVER['REDIRECT_url_propre']); |
|
| 63 | + unset($_ENV['url_propre']); |
|
| 64 | + include_spip('inc/filtres_mini'); |
|
| 65 | + if (strpos($url,"://")===false){ |
|
| 66 | 66 | $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"),'/'),'/'); |
| 67 | 67 | } |
| 68 | 68 | else { |
| 69 | 69 | $GLOBALS['profondeur_url'] = max(0,substr_count($url,"/")-substr_count($current_base,"/")); |
| 70 | 70 | } |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | |
| 74 | - $url_redirect = ""; |
|
| 75 | - $renommer = generer_url_entite('','','','',true); |
|
| 76 | - if (!$renommer AND !function_exists('recuperer_parametres_url')) |
|
| 77 | - $renommer = charger_fonction('page','urls'); // fallback pour decoder l'url |
|
| 78 | - if ($renommer) { |
|
| 79 | - $a = $renommer($url, $fond, $contexte); |
|
| 80 | - if (is_array($a)) { |
|
| 81 | - list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null); |
|
| 82 | - if ($url_redirect == $url) |
|
| 83 | - $url_redirect = ""; // securite pour eviter une redirection infinie |
|
| 84 | - if ($assembler AND strlen($url_redirect)) { |
|
| 85 | - spip_log("Redirige $url vers $url_redirect"); |
|
| 86 | - include_spip('inc/headers'); |
|
| 87 | - redirige_par_entete($url_redirect, '', 301); |
|
| 88 | - } |
|
| 89 | - if (isset($nfond)) |
|
| 90 | - $fond = $nfond; |
|
| 91 | - else if ($fond == '' |
|
| 92 | - OR $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 93 | - ) |
|
| 94 | - $fond = $type; |
|
| 95 | - if (isset($ncontexte)) |
|
| 96 | - $contexte = $ncontexte; |
|
| 97 | - if (defined('_DEFINIR_CONTEXTE_TYPE') AND _DEFINIR_CONTEXTE_TYPE) |
|
| 98 | - $contexte['type'] = $type; |
|
| 99 | - if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') AND _DEFINIR_CONTEXTE_TYPE_PAGE) |
|
| 100 | - $contexte['type-page'] = $type; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - // compatibilite <= 1.9.2 |
|
| 104 | - elseif (function_exists('recuperer_parametres_url')) { |
|
| 105 | - $GLOBALS['fond'] = $fond; |
|
| 106 | - $GLOBALS['contexte'] = $contexte; |
|
| 107 | - recuperer_parametres_url($fond, nettoyer_uri()); |
|
| 108 | - // fond est en principe modifiee directement |
|
| 109 | - $contexte = $GLOBALS['contexte']; |
|
| 110 | - } |
|
| 74 | + $url_redirect = ""; |
|
| 75 | + $renommer = generer_url_entite('','','','',true); |
|
| 76 | + if (!$renommer AND !function_exists('recuperer_parametres_url')) |
|
| 77 | + $renommer = charger_fonction('page','urls'); // fallback pour decoder l'url |
|
| 78 | + if ($renommer) { |
|
| 79 | + $a = $renommer($url, $fond, $contexte); |
|
| 80 | + if (is_array($a)) { |
|
| 81 | + list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null); |
|
| 82 | + if ($url_redirect == $url) |
|
| 83 | + $url_redirect = ""; // securite pour eviter une redirection infinie |
|
| 84 | + if ($assembler AND strlen($url_redirect)) { |
|
| 85 | + spip_log("Redirige $url vers $url_redirect"); |
|
| 86 | + include_spip('inc/headers'); |
|
| 87 | + redirige_par_entete($url_redirect, '', 301); |
|
| 88 | + } |
|
| 89 | + if (isset($nfond)) |
|
| 90 | + $fond = $nfond; |
|
| 91 | + else if ($fond == '' |
|
| 92 | + OR $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 93 | + ) |
|
| 94 | + $fond = $type; |
|
| 95 | + if (isset($ncontexte)) |
|
| 96 | + $contexte = $ncontexte; |
|
| 97 | + if (defined('_DEFINIR_CONTEXTE_TYPE') AND _DEFINIR_CONTEXTE_TYPE) |
|
| 98 | + $contexte['type'] = $type; |
|
| 99 | + if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') AND _DEFINIR_CONTEXTE_TYPE_PAGE) |
|
| 100 | + $contexte['type-page'] = $type; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + // compatibilite <= 1.9.2 |
|
| 104 | + elseif (function_exists('recuperer_parametres_url')) { |
|
| 105 | + $GLOBALS['fond'] = $fond; |
|
| 106 | + $GLOBALS['contexte'] = $contexte; |
|
| 107 | + recuperer_parametres_url($fond, nettoyer_uri()); |
|
| 108 | + // fond est en principe modifiee directement |
|
| 109 | + $contexte = $GLOBALS['contexte']; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - // retablir les globales |
|
| 113 | - list($GLOBALS['fond'],$GLOBALS['contexte'],$_SERVER['REDIRECT_url_propre'],$_ENV['url_propre'],$GLOBALS['profondeur_url']) = $save; |
|
| 112 | + // retablir les globales |
|
| 113 | + list($GLOBALS['fond'],$GLOBALS['contexte'],$_SERVER['REDIRECT_url_propre'],$_ENV['url_propre'],$GLOBALS['profondeur_url']) = $save; |
|
| 114 | 114 | |
| 115 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 116 | - // d'inversion url => objet |
|
| 117 | - // maintenir pour compat ? |
|
| 118 | - #if ($assembler) { |
|
| 119 | - # unset($_SERVER['REDIRECT_url_propre']); |
|
| 120 | - # unset($_ENV['url_propre']); |
|
| 121 | - #} |
|
| 115 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 116 | + // d'inversion url => objet |
|
| 117 | + // maintenir pour compat ? |
|
| 118 | + #if ($assembler) { |
|
| 119 | + # unset($_SERVER['REDIRECT_url_propre']); |
|
| 120 | + # unset($_ENV['url_propre']); |
|
| 121 | + #} |
|
| 122 | 122 | |
| 123 | - return array($fond,$contexte,$url_redirect); |
|
| 123 | + return array($fond,$contexte,$url_redirect); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -134,21 +134,21 @@ discard block |
||
| 134 | 134 | * @return string/array |
| 135 | 135 | */ |
| 136 | 136 | function urls_liste_objets($preg = true){ |
| 137 | - static $url_objets = null; |
|
| 138 | - if (is_null($url_objets)){ |
|
| 139 | - $url_objets = array(); |
|
| 140 | - // recuperer les tables_objets_sql declarees |
|
| 141 | - $tables_objets = lister_tables_objets_sql(); |
|
| 142 | - foreach($tables_objets as $t=>$infos){ |
|
| 143 | - if ($infos['page']) { |
|
| 144 | - $url_objets[] = $infos['type']; |
|
| 145 | - $url_objets = array_merge($url_objets,$infos['type_surnoms']); |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - $url_objets = pipeline('declarer_url_objets',$url_objets); |
|
| 149 | - } |
|
| 150 | - if (!$preg) return $url_objets; |
|
| 151 | - return implode('|',array_map('preg_quote',$url_objets)); |
|
| 137 | + static $url_objets = null; |
|
| 138 | + if (is_null($url_objets)){ |
|
| 139 | + $url_objets = array(); |
|
| 140 | + // recuperer les tables_objets_sql declarees |
|
| 141 | + $tables_objets = lister_tables_objets_sql(); |
|
| 142 | + foreach($tables_objets as $t=>$infos){ |
|
| 143 | + if ($infos['page']) { |
|
| 144 | + $url_objets[] = $infos['type']; |
|
| 145 | + $url_objets = array_merge($url_objets,$infos['type_surnoms']); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + $url_objets = pipeline('declarer_url_objets',$url_objets); |
|
| 149 | + } |
|
| 150 | + if (!$preg) return $url_objets; |
|
| 151 | + return implode('|',array_map('preg_quote',$url_objets)); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -162,21 +162,21 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | function nettoyer_url_page($url, $contexte=array()) |
| 164 | 164 | { |
| 165 | - $url_objets = urls_liste_objets(); |
|
| 166 | - $raccourci_url_page_html = ',^(?:[^?]*/)?('. $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 167 | - $raccourci_url_page_id = ',^(?:[^?]*/)?('. $url_objets .')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 168 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('. $url_objets .')([0-9]+)=?(&.*)?$,'; |
|
| 165 | + $url_objets = urls_liste_objets(); |
|
| 166 | + $raccourci_url_page_html = ',^(?:[^?]*/)?('. $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 167 | + $raccourci_url_page_id = ',^(?:[^?]*/)?('. $url_objets .')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 168 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('. $url_objets .')([0-9]+)=?(&.*)?$,'; |
|
| 169 | 169 | |
| 170 | - if (preg_match($raccourci_url_page_html, $url, $regs) |
|
| 171 | - OR preg_match($raccourci_url_page_id, $url, $regs) |
|
| 172 | - OR preg_match($raccourci_url_page_spip, $url, $regs)) { |
|
| 173 | - $type = objet_type($regs[1]); |
|
| 174 | - $_id = id_table_objet($type); |
|
| 175 | - $contexte[$_id] = $regs[2]; |
|
| 176 | - $suite = $regs[3]; |
|
| 177 | - return array($contexte, $type, null, $type, $suite); |
|
| 178 | - } |
|
| 179 | - return array(); |
|
| 170 | + if (preg_match($raccourci_url_page_html, $url, $regs) |
|
| 171 | + OR preg_match($raccourci_url_page_id, $url, $regs) |
|
| 172 | + OR preg_match($raccourci_url_page_spip, $url, $regs)) { |
|
| 173 | + $type = objet_type($regs[1]); |
|
| 174 | + $_id = id_table_objet($type); |
|
| 175 | + $contexte[$_id] = $regs[2]; |
|
| 176 | + $suite = $regs[3]; |
|
| 177 | + return array($contexte, $type, null, $type, $suite); |
|
| 178 | + } |
|
| 179 | + return array(); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -193,28 +193,28 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | */ |
| 195 | 195 | function generer_url_ecrire_objet($objet,$id, $args='', $ancre='', $public=null, $connect=''){ |
| 196 | - static $furls = array(); |
|
| 197 | - if (!isset($furls[$objet])){ |
|
| 198 | - if (function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 199 | - // ou definie par un plugin |
|
| 200 | - OR $f = charger_fonction($f,'urls',true)) |
|
| 201 | - $furls[$objet] = $f; |
|
| 202 | - else |
|
| 203 | - $furls[$objet] = ''; |
|
| 204 | - } |
|
| 205 | - if ($furls[$objet]) |
|
| 206 | - return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 207 | - // si pas de flag public fourni |
|
| 208 | - // le calculer en fonction de la declaration de statut |
|
| 209 | - if (is_null($public) AND !$connect) |
|
| 210 | - $public = objet_test_si_publie($objet, $id, $connect); |
|
| 211 | - if ($public OR $connect){ |
|
| 212 | - return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
|
| 213 | - } |
|
| 214 | - $a = id_table_objet($objet) . "=" . intval($id); |
|
| 215 | - if (!function_exists('objet_info')) |
|
| 216 | - include_spip('inc/filtres'); |
|
| 217 | - return generer_url_ecrire(objet_info($objet,'url_voir'), $a . ($args ? "&$args" : '')). ($ancre ? "#$ancre" : ''); |
|
| 196 | + static $furls = array(); |
|
| 197 | + if (!isset($furls[$objet])){ |
|
| 198 | + if (function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 199 | + // ou definie par un plugin |
|
| 200 | + OR $f = charger_fonction($f,'urls',true)) |
|
| 201 | + $furls[$objet] = $f; |
|
| 202 | + else |
|
| 203 | + $furls[$objet] = ''; |
|
| 204 | + } |
|
| 205 | + if ($furls[$objet]) |
|
| 206 | + return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 207 | + // si pas de flag public fourni |
|
| 208 | + // le calculer en fonction de la declaration de statut |
|
| 209 | + if (is_null($public) AND !$connect) |
|
| 210 | + $public = objet_test_si_publie($objet, $id, $connect); |
|
| 211 | + if ($public OR $connect){ |
|
| 212 | + return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
|
| 213 | + } |
|
| 214 | + $a = id_table_objet($objet) . "=" . intval($id); |
|
| 215 | + if (!function_exists('objet_info')) |
|
| 216 | + include_spip('inc/filtres'); |
|
| 217 | + return generer_url_ecrire(objet_info($objet,'url_voir'), $a . ($args ? "&$args" : '')). ($ancre ? "#$ancre" : ''); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | ?> |
@@ -14,31 +14,31 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | // http://doc.spip.org/@creer_pass_aleatoire |
| 16 | 16 | function creer_pass_aleatoire($longueur = 8, $sel = "") { |
| 17 | - $seed = (double) (microtime() + 1) * time(); |
|
| 18 | - mt_srand($seed); |
|
| 19 | - srand($seed); |
|
| 20 | - $s = ''; |
|
| 21 | - $pass = ''; |
|
| 22 | - for ($i = 0; $i < $longueur; $i++) { |
|
| 23 | - if (!$s) { |
|
| 24 | - $s = mt_rand(); |
|
| 25 | - if (!$s) $s = rand(); |
|
| 26 | - $s = substr(md5(uniqid($s).$sel), 0, 16); |
|
| 27 | - } |
|
| 28 | - $r = unpack("Cr", pack("H2", $s.$s)); |
|
| 29 | - $x = $r['r'] & 63; |
|
| 30 | - if ($x < 10) $x = chr($x + 48); |
|
| 31 | - else if ($x < 36) $x = chr($x + 55); |
|
| 32 | - else if ($x < 62) $x = chr($x + 61); |
|
| 33 | - else if ($x == 63) $x = '/'; |
|
| 34 | - else $x = '.'; |
|
| 35 | - $pass .= $x; |
|
| 36 | - $s = substr($s, 2); |
|
| 37 | - } |
|
| 38 | - $pass = preg_replace("@[./]@", "a", $pass); |
|
| 39 | - $pass = preg_replace("@[I1l]@", "L", $pass); |
|
| 40 | - $pass = preg_replace("@[0O]@", "o", $pass); |
|
| 41 | - return $pass; |
|
| 17 | + $seed = (double) (microtime() + 1) * time(); |
|
| 18 | + mt_srand($seed); |
|
| 19 | + srand($seed); |
|
| 20 | + $s = ''; |
|
| 21 | + $pass = ''; |
|
| 22 | + for ($i = 0; $i < $longueur; $i++) { |
|
| 23 | + if (!$s) { |
|
| 24 | + $s = mt_rand(); |
|
| 25 | + if (!$s) $s = rand(); |
|
| 26 | + $s = substr(md5(uniqid($s).$sel), 0, 16); |
|
| 27 | + } |
|
| 28 | + $r = unpack("Cr", pack("H2", $s.$s)); |
|
| 29 | + $x = $r['r'] & 63; |
|
| 30 | + if ($x < 10) $x = chr($x + 48); |
|
| 31 | + else if ($x < 36) $x = chr($x + 55); |
|
| 32 | + else if ($x < 62) $x = chr($x + 61); |
|
| 33 | + else if ($x == 63) $x = '/'; |
|
| 34 | + else $x = '.'; |
|
| 35 | + $pass .= $x; |
|
| 36 | + $s = substr($s, 2); |
|
| 37 | + } |
|
| 38 | + $pass = preg_replace("@[./]@", "a", $pass); |
|
| 39 | + $pass = preg_replace("@[I1l]@", "L", $pass); |
|
| 40 | + $pass = preg_replace("@[0O]@", "o", $pass); |
|
| 41 | + return $pass; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -49,18 +49,18 @@ discard block |
||
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | 51 | function creer_uniqid() { |
| 52 | - static $seeded; |
|
| 53 | - |
|
| 54 | - if (!$seeded) { |
|
| 55 | - $seed = (double) (microtime() + 1) * time(); |
|
| 56 | - mt_srand($seed); |
|
| 57 | - srand($seed); |
|
| 58 | - $seeded = true; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - $s = mt_rand(); |
|
| 62 | - if (!$s) $s = rand(); |
|
| 63 | - return uniqid($s, 1); |
|
| 52 | + static $seeded; |
|
| 53 | + |
|
| 54 | + if (!$seeded) { |
|
| 55 | + $seed = (double) (microtime() + 1) * time(); |
|
| 56 | + mt_srand($seed); |
|
| 57 | + srand($seed); |
|
| 58 | + $seeded = true; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + $s = mt_rand(); |
|
| 62 | + if (!$s) $s = rand(); |
|
| 63 | + return uniqid($s, 1); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // |
@@ -69,15 +69,15 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | // http://doc.spip.org/@renouvelle_alea |
| 71 | 71 | function renouvelle_alea() { |
| 72 | - if (!isset($GLOBALS['meta']['alea_ephemere'])){ |
|
| 73 | - include_spip('base/abstract_sql'); |
|
| 74 | - $GLOBALS['meta']['alea_ephemere'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere'"); |
|
| 75 | - } |
|
| 76 | - ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non'); |
|
| 77 | - $GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid()); |
|
| 78 | - ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non'); |
|
| 79 | - ecrire_meta('alea_ephemere_date', time(), 'non'); |
|
| 80 | - spip_log("renouvellement de l'alea_ephemere"); |
|
| 72 | + if (!isset($GLOBALS['meta']['alea_ephemere'])){ |
|
| 73 | + include_spip('base/abstract_sql'); |
|
| 74 | + $GLOBALS['meta']['alea_ephemere'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere'"); |
|
| 75 | + } |
|
| 76 | + ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non'); |
|
| 77 | + $GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid()); |
|
| 78 | + ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non'); |
|
| 79 | + ecrire_meta('alea_ephemere_date', time(), 'non'); |
|
| 80 | + spip_log("renouvellement de l'alea_ephemere"); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // |
@@ -86,20 +86,20 @@ discard block |
||
| 86 | 86 | // |
| 87 | 87 | // http://doc.spip.org/@low_sec |
| 88 | 88 | function low_sec($id_auteur) { |
| 89 | - // Pas d'id_auteur : low_sec |
|
| 90 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 91 | - if (!$low_sec = $GLOBALS['meta']['low_sec']) { |
|
| 92 | - ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire()); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - else { |
|
| 96 | - $low_sec = sql_getfetsel("low_sec", "spip_auteurs", "id_auteur = $id_auteur"); |
|
| 97 | - if (!$low_sec) { |
|
| 98 | - $low_sec = creer_pass_aleatoire(); |
|
| 99 | - sql_updateq("spip_auteurs", array("low_sec" => $low_sec), "id_auteur = $id_auteur"); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - return $low_sec; |
|
| 89 | + // Pas d'id_auteur : low_sec |
|
| 90 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 91 | + if (!$low_sec = $GLOBALS['meta']['low_sec']) { |
|
| 92 | + ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire()); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + else { |
|
| 96 | + $low_sec = sql_getfetsel("low_sec", "spip_auteurs", "id_auteur = $id_auteur"); |
|
| 97 | + if (!$low_sec) { |
|
| 98 | + $low_sec = creer_pass_aleatoire(); |
|
| 99 | + sql_updateq("spip_auteurs", array("low_sec" => $low_sec), "id_auteur = $id_auteur"); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + return $low_sec; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Inclure les arguments significatifs pour le hachage |
@@ -107,46 +107,46 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | function param_low_sec($op, $args=array(), $lang='', $mime='rss') |
| 109 | 109 | { |
| 110 | - $a = $b = ''; |
|
| 111 | - foreach ($args as $val => $var) |
|
| 112 | - if ($var) { |
|
| 113 | - if ($val<>'statut') $a .= ':' . $val.'-'.$var; |
|
| 114 | - $b .= $val.'='.$var . '&'; |
|
| 115 | - } |
|
| 116 | - $a = substr($a,1); |
|
| 117 | - $id = intval(@$GLOBALS['connect_id_auteur']); |
|
| 118 | - return $b |
|
| 119 | - . "op=" |
|
| 120 | - . $op |
|
| 121 | - . "&id=" |
|
| 122 | - . $id |
|
| 123 | - . "&cle=" |
|
| 124 | - . afficher_low_sec($id, "$mime $op $a") |
|
| 125 | - . (!$a ? '' : "&args=$a") |
|
| 126 | - . (!$lang ? '' : "&lang=$lang"); |
|
| 110 | + $a = $b = ''; |
|
| 111 | + foreach ($args as $val => $var) |
|
| 112 | + if ($var) { |
|
| 113 | + if ($val<>'statut') $a .= ':' . $val.'-'.$var; |
|
| 114 | + $b .= $val.'='.$var . '&'; |
|
| 115 | + } |
|
| 116 | + $a = substr($a,1); |
|
| 117 | + $id = intval(@$GLOBALS['connect_id_auteur']); |
|
| 118 | + return $b |
|
| 119 | + . "op=" |
|
| 120 | + . $op |
|
| 121 | + . "&id=" |
|
| 122 | + . $id |
|
| 123 | + . "&cle=" |
|
| 124 | + . afficher_low_sec($id, "$mime $op $a") |
|
| 125 | + . (!$a ? '' : "&args=$a") |
|
| 126 | + . (!$lang ? '' : "&lang=$lang"); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // http://doc.spip.org/@afficher_low_sec |
| 130 | 130 | function afficher_low_sec ($id_auteur, $action='') { |
| 131 | - return substr(md5($action.low_sec($id_auteur)),0,8); |
|
| 131 | + return substr(md5($action.low_sec($id_auteur)),0,8); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // http://doc.spip.org/@verifier_low_sec |
| 135 | 135 | function verifier_low_sec ($id_auteur, $cle, $action='') { |
| 136 | - return ($cle == afficher_low_sec($id_auteur, $action)); |
|
| 136 | + return ($cle == afficher_low_sec($id_auteur, $action)); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // http://doc.spip.org/@effacer_low_sec |
| 140 | 140 | function effacer_low_sec($id_auteur) { |
| 141 | - if (!$id_auteur = intval($id_auteur)) return; // jamais trop prudent ;) |
|
| 142 | - sql_updateq("spip_auteurs", array("low_sec" => ''), "id_auteur = $id_auteur"); |
|
| 141 | + if (!$id_auteur = intval($id_auteur)) return; // jamais trop prudent ;) |
|
| 142 | + sql_updateq("spip_auteurs", array("low_sec" => ''), "id_auteur = $id_auteur"); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // http://doc.spip.org/@initialiser_sel |
| 146 | 146 | function initialiser_sel() { |
| 147 | - global $htsalt; |
|
| 148 | - if (CRYPT_MD5) $htsalt = '$1$'.creer_pass_aleatoire(); |
|
| 149 | - else return ""; |
|
| 147 | + global $htsalt; |
|
| 148 | + if (CRYPT_MD5) $htsalt = '$1$'.creer_pass_aleatoire(); |
|
| 149 | + else return ""; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // Cette fonction ne sert qu'a la connexion en mode http_auth.non LDAP |
@@ -154,48 +154,48 @@ discard block |
||
| 154 | 154 | // Voir le plugin "acces restreint" |
| 155 | 155 | // http://doc.spip.org/@ecrire_acces |
| 156 | 156 | function ecrire_acces() { |
| 157 | - $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 158 | - $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 159 | - |
|
| 160 | - // Cette variable de configuration peut etre posee par un plugin |
|
| 161 | - // par exemple acces_restreint ; |
|
| 162 | - // si .htaccess existe, outrepasser spip_meta |
|
| 163 | - if (($GLOBALS['meta']['creer_htpasswd'] != 'oui') |
|
| 164 | - AND !@file_exists($htaccess)) { |
|
| 165 | - spip_unlink($htpasswd); |
|
| 166 | - spip_unlink($htpasswd."-admin"); |
|
| 167 | - return; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre |
|
| 171 | - # de devenir redacteur le cas echeant (auth http)... a nettoyer |
|
| 172 | - // attention, il faut au prealable se connecter a la base (necessaire car utilise par install) |
|
| 173 | - // TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test spip_connect_ldap() |
|
| 174 | - |
|
| 175 | - if (spip_connect_ldap()) return; |
|
| 176 | - $p1 = ''; // login:htpass pour tous |
|
| 177 | - $p2 = ''; // login:htpass pour les admins |
|
| 178 | - $s = sql_select("login, htpass, statut", "spip_auteurs", sql_in("statut", array('1comite','0minirezo','nouveau'))); |
|
| 179 | - while ($t = sql_fetch($s)) { |
|
| 180 | - if (strlen($t['login']) AND strlen($t['htpass'])) { |
|
| 181 | - $p1 .= $t['login'].':'.$t['htpass']."\n"; |
|
| 182 | - if ($t['statut'] == '0minirezo') |
|
| 183 | - $p2 .= $t['login'].':'.$t['htpass']."\n"; |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - if ($p1) { |
|
| 187 | - ecrire_fichier($htpasswd, $p1); |
|
| 188 | - ecrire_fichier($htpasswd.'-admin', $p2); |
|
| 189 | - spip_log("Ecriture de $htpasswd et $htpasswd-admin"); |
|
| 190 | - } |
|
| 157 | + $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 158 | + $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 159 | + |
|
| 160 | + // Cette variable de configuration peut etre posee par un plugin |
|
| 161 | + // par exemple acces_restreint ; |
|
| 162 | + // si .htaccess existe, outrepasser spip_meta |
|
| 163 | + if (($GLOBALS['meta']['creer_htpasswd'] != 'oui') |
|
| 164 | + AND !@file_exists($htaccess)) { |
|
| 165 | + spip_unlink($htpasswd); |
|
| 166 | + spip_unlink($htpasswd."-admin"); |
|
| 167 | + return; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre |
|
| 171 | + # de devenir redacteur le cas echeant (auth http)... a nettoyer |
|
| 172 | + // attention, il faut au prealable se connecter a la base (necessaire car utilise par install) |
|
| 173 | + // TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test spip_connect_ldap() |
|
| 174 | + |
|
| 175 | + if (spip_connect_ldap()) return; |
|
| 176 | + $p1 = ''; // login:htpass pour tous |
|
| 177 | + $p2 = ''; // login:htpass pour les admins |
|
| 178 | + $s = sql_select("login, htpass, statut", "spip_auteurs", sql_in("statut", array('1comite','0minirezo','nouveau'))); |
|
| 179 | + while ($t = sql_fetch($s)) { |
|
| 180 | + if (strlen($t['login']) AND strlen($t['htpass'])) { |
|
| 181 | + $p1 .= $t['login'].':'.$t['htpass']."\n"; |
|
| 182 | + if ($t['statut'] == '0minirezo') |
|
| 183 | + $p2 .= $t['login'].':'.$t['htpass']."\n"; |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + if ($p1) { |
|
| 187 | + ecrire_fichier($htpasswd, $p1); |
|
| 188 | + ecrire_fichier($htpasswd.'-admin', $p2); |
|
| 189 | + spip_log("Ecriture de $htpasswd et $htpasswd-admin"); |
|
| 190 | + } |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
| 194 | 194 | // http://doc.spip.org/@generer_htpass |
| 195 | 195 | function generer_htpass($pass) { |
| 196 | - global $htsalt; |
|
| 197 | - if (function_exists('crypt')) |
|
| 198 | - return crypt($pass, $htsalt); |
|
| 196 | + global $htsalt; |
|
| 197 | + if (function_exists('crypt')) |
|
| 198 | + return crypt($pass, $htsalt); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // |
@@ -203,46 +203,46 @@ discard block |
||
| 203 | 203 | // |
| 204 | 204 | // http://doc.spip.org/@verifier_htaccess |
| 205 | 205 | function verifier_htaccess($rep, $force=false) { |
| 206 | - $htaccess = rtrim($rep,"/") . "/" . _ACCESS_FILE_NAME; |
|
| 207 | - if (((@file_exists($htaccess)) OR defined('_TEST_DIRS')) AND !$force) |
|
| 208 | - return true; |
|
| 209 | - if ($ht = @fopen($htaccess, "w")) { |
|
| 210 | - fputs($ht, "deny from all\n"); |
|
| 211 | - fclose($ht); |
|
| 212 | - @chmod($htaccess, _SPIP_CHMOD & 0666); |
|
| 213 | - $t = rtrim($rep,"/") . "/.ok"; |
|
| 214 | - if ($ht = @fopen($t, "w")) { |
|
| 215 | - @fclose($ht); |
|
| 216 | - include_spip('inc/distant'); |
|
| 217 | - $t = substr($t,strlen(_DIR_RACINE)); |
|
| 218 | - $t = url_de_base() . $t; |
|
| 219 | - $ht = recuperer_lapage($t, false, 'HEAD', 0); |
|
| 220 | - // htaccess inoperant si on a recupere des entetes HTTP |
|
| 221 | - // (ignorer la reussite si connexion par fopen) |
|
| 222 | - $ht = !(isset($ht[0]) AND $ht[0]); |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - spip_log("Creation de $htaccess " . ($ht ? " reussie" : " manquee")); |
|
| 226 | - return $ht; |
|
| 206 | + $htaccess = rtrim($rep,"/") . "/" . _ACCESS_FILE_NAME; |
|
| 207 | + if (((@file_exists($htaccess)) OR defined('_TEST_DIRS')) AND !$force) |
|
| 208 | + return true; |
|
| 209 | + if ($ht = @fopen($htaccess, "w")) { |
|
| 210 | + fputs($ht, "deny from all\n"); |
|
| 211 | + fclose($ht); |
|
| 212 | + @chmod($htaccess, _SPIP_CHMOD & 0666); |
|
| 213 | + $t = rtrim($rep,"/") . "/.ok"; |
|
| 214 | + if ($ht = @fopen($t, "w")) { |
|
| 215 | + @fclose($ht); |
|
| 216 | + include_spip('inc/distant'); |
|
| 217 | + $t = substr($t,strlen(_DIR_RACINE)); |
|
| 218 | + $t = url_de_base() . $t; |
|
| 219 | + $ht = recuperer_lapage($t, false, 'HEAD', 0); |
|
| 220 | + // htaccess inoperant si on a recupere des entetes HTTP |
|
| 221 | + // (ignorer la reussite si connexion par fopen) |
|
| 222 | + $ht = !(isset($ht[0]) AND $ht[0]); |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + spip_log("Creation de $htaccess " . ($ht ? " reussie" : " manquee")); |
|
| 226 | + return $ht; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | |
| 230 | 230 | |
| 231 | 231 | // http://doc.spip.org/@gerer_htaccess |
| 232 | 232 | function gerer_htaccess() { |
| 233 | - // Cette variable de configuration peut etre posee par un plugin |
|
| 234 | - // par exemple acces_restreint |
|
| 235 | - $f = ($GLOBALS['meta']['creer_htaccess'] === 'oui'); |
|
| 236 | - $dirs = sql_allfetsel('extension', 'spip_types_documents'); |
|
| 237 | - $dirs[] = array('extension' => 'distant'); |
|
| 238 | - foreach($dirs as $e) { |
|
| 239 | - if (is_dir($dir = _DIR_IMG . $e['extension'])) { |
|
| 240 | - if ($f) |
|
| 241 | - verifier_htaccess($dir); |
|
| 242 | - else spip_unlink($dir . '/' . _ACCESS_FILE_NAME); |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - return $GLOBALS['meta']['creer_htaccess']; |
|
| 233 | + // Cette variable de configuration peut etre posee par un plugin |
|
| 234 | + // par exemple acces_restreint |
|
| 235 | + $f = ($GLOBALS['meta']['creer_htaccess'] === 'oui'); |
|
| 236 | + $dirs = sql_allfetsel('extension', 'spip_types_documents'); |
|
| 237 | + $dirs[] = array('extension' => 'distant'); |
|
| 238 | + foreach($dirs as $e) { |
|
| 239 | + if (is_dir($dir = _DIR_IMG . $e['extension'])) { |
|
| 240 | + if ($f) |
|
| 241 | + verifier_htaccess($dir); |
|
| 242 | + else spip_unlink($dir . '/' . _ACCESS_FILE_NAME); |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + return $GLOBALS['meta']['creer_htaccess']; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | initialiser_sel(); |
@@ -17,214 +17,214 @@ |
||
| 17 | 17 | // methodes sql |
| 18 | 18 | function inc_recherche_to_array_dist($recherche, $options = array()) { |
| 19 | 19 | |
| 20 | - // options par defaut |
|
| 21 | - $options = array_merge( |
|
| 22 | - array( |
|
| 23 | - 'score' => true, |
|
| 24 | - 'champs' => false, |
|
| 25 | - 'toutvoir' => false, |
|
| 26 | - 'matches' => false, |
|
| 27 | - 'jointures' => false |
|
| 28 | - ), |
|
| 29 | - $options |
|
| 30 | - ); |
|
| 31 | - |
|
| 32 | - include_spip('inc/rechercher'); |
|
| 33 | - include_spip('inc/autoriser'); |
|
| 34 | - |
|
| 35 | - $requete = array( |
|
| 36 | - "SELECT"=>array(), |
|
| 37 | - "FROM"=>array(), |
|
| 38 | - "WHERE"=>array(), |
|
| 39 | - "GROUPBY"=>array(), |
|
| 40 | - "ORDERBY"=>array(), |
|
| 41 | - "LIMIT"=>"", |
|
| 42 | - "HAVING"=>array() |
|
| 43 | - ); |
|
| 44 | - |
|
| 45 | - $table = sinon($options['table'], 'article'); |
|
| 46 | - if ($options['champs']) |
|
| 47 | - $champs = $options['champs']; |
|
| 48 | - else { |
|
| 49 | - $l = liste_des_champs(); |
|
| 50 | - $champs = $l['article']; |
|
| 51 | - } |
|
| 52 | - $serveur = $options['serveur']; |
|
| 53 | - |
|
| 54 | - list($methode, $q, $preg) = expression_recherche($recherche, $options); |
|
| 55 | - |
|
| 56 | - $jointures = $options['jointures'] |
|
| 57 | - ? liste_des_jointures() |
|
| 58 | - : array(); |
|
| 59 | - |
|
| 60 | - $_id_table = id_table_objet($table); |
|
| 61 | - |
|
| 62 | - // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ',' |
|
| 63 | - // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs) |
|
| 64 | - if (strpos($_id_table,",")!==false){ |
|
| 65 | - $_id_table = explode(',',$_id_table); |
|
| 66 | - $_id_table = reset($_id_table); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $requete['SELECT'][] = "t.".$_id_table; |
|
| 70 | - $a = array(); |
|
| 71 | - // Recherche fulltext |
|
| 72 | - foreach ($champs as $champ => $poids) { |
|
| 73 | - if (is_array($champ)){ |
|
| 74 | - spip_log("requetes imbriquees interdites"); |
|
| 75 | - } else { |
|
| 76 | - if (strpos($champ,".")===FALSE) |
|
| 77 | - $champ = "t.$champ"; |
|
| 78 | - $requete['SELECT'][] = $champ; |
|
| 79 | - $a[] = $champ.' '.$methode.' '.$q; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - if ($a) $requete['WHERE'][] = join(" OR ", $a); |
|
| 83 | - $requete['FROM'][] = table_objet_sql($table).' AS t'; |
|
| 84 | - |
|
| 85 | - $results = array(); |
|
| 86 | - |
|
| 87 | - $s = sql_select( |
|
| 88 | - $requete['SELECT'], $requete['FROM'], $requete['WHERE'], |
|
| 89 | - implode(" ",$requete['GROUPBY']), |
|
| 90 | - $requete['ORDERBY'], $requete['LIMIT'], |
|
| 91 | - $requete['HAVING'], $serveur |
|
| 92 | - ); |
|
| 93 | - |
|
| 94 | - while ($t = sql_fetch($s,$serveur) |
|
| 95 | - AND (!isset($t['score']) OR $t['score']>0)) { |
|
| 96 | - $id = intval($t[$_id_table]); |
|
| 97 | - |
|
| 98 | - if ($options['toutvoir'] |
|
| 99 | - OR autoriser('voir', $table, $id)) { |
|
| 100 | - // indiquer les champs concernes |
|
| 101 | - $champs_vus = array(); |
|
| 102 | - $score = 0; |
|
| 103 | - $matches = array(); |
|
| 104 | - |
|
| 105 | - $vu = false; |
|
| 106 | - foreach ($champs as $champ => $poids) { |
|
| 107 | - $champ = explode('.',$champ); |
|
| 108 | - $champ = end($champ); |
|
| 109 | - // translitteration_rapide uniquement si on est deja en utf-8 |
|
| 110 | - $value = ($GLOBALS['meta']['charset']=='utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ])); |
|
| 111 | - if ($n = |
|
| 112 | - ($options['score'] || $options['matches']) |
|
| 113 | - ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER) |
|
| 114 | - : preg_match($preg, $value) |
|
| 115 | - ) { |
|
| 116 | - $vu = true; |
|
| 117 | - |
|
| 118 | - if ($options['champs']) |
|
| 119 | - $champs_vus[$champ] = $t[$champ]; |
|
| 120 | - if ($options['score']) |
|
| 121 | - $score += $n * $poids; |
|
| 122 | - if ($options['matches']) |
|
| 123 | - $matches[$champ] = $regs; |
|
| 124 | - |
|
| 125 | - if (!$options['champs'] |
|
| 126 | - AND !$options['score'] |
|
| 127 | - AND !$options['matches']) |
|
| 128 | - break; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - if ($vu) { |
|
| 133 | - if (!isset($results)) |
|
| 134 | - $results = array(); |
|
| 135 | - $results[$id] = array(); |
|
| 136 | - if ($champs_vus) |
|
| 137 | - $results[$id]['champs'] = $champs_vus; |
|
| 138 | - if ($score) |
|
| 139 | - $results[$id]['score'] = $score; |
|
| 140 | - if ($matches) |
|
| 141 | - $results[$id]['matches'] = $matches; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - // Gerer les donnees associees |
|
| 148 | - // ici on est un peu naze : pas capables de reconstruire une jointure complexe |
|
| 149 | - // on ne sait passer que par table de laison en 1 coup |
|
| 150 | - if (isset($jointures[$table]) |
|
| 151 | - AND $joints = recherche_en_base( |
|
| 152 | - $recherche, |
|
| 153 | - $jointures[$table], |
|
| 154 | - array_merge($options, array('jointures' => false)) |
|
| 155 | - ) |
|
| 156 | - ) { |
|
| 157 | - include_spip('action/editer_liens'); |
|
| 158 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 159 | - $cle_depart = id_table_objet($table); |
|
| 160 | - $table_depart = table_objet($table,$serveur); |
|
| 161 | - $desc_depart = $trouver_table($table_depart,$serveur); |
|
| 162 | - $depart_associable = objet_associable($table); |
|
| 163 | - foreach ($joints as $table_liee => $ids_trouves) { |
|
| 164 | - // on peut definir une fonction de recherche jointe pour regler les cas particuliers |
|
| 165 | - if ( |
|
| 166 | - !( |
|
| 167 | - $rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}","inc",true) |
|
| 168 | - or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}","inc",true) |
|
| 169 | - or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie","inc",true) |
|
| 170 | - ) |
|
| 171 | - ){ |
|
| 172 | - $cle_arrivee = id_table_objet($table_liee); |
|
| 173 | - $table_arrivee = table_objet($table_liee,$serveur); |
|
| 174 | - $desc_arrivee = $trouver_table($table_arrivee,$serveur); |
|
| 175 | - // cas simple : $cle_depart dans la table_liee |
|
| 176 | - if (isset($desc_arrivee['field'][$cle_depart])){ |
|
| 177 | - $s = sql_select("$cle_depart, $cle_arrivee", $desc_arrivee['table_sql'], sql_in($cle_arrivee, array_keys($ids_trouves)), '','','','',$serveur); |
|
| 178 | - } |
|
| 179 | - // cas simple : $cle_arrivee dans la table |
|
| 180 | - elseif (isset($desc_depart['field'][$cle_arrivee])){ |
|
| 181 | - $s = sql_select("$cle_depart, $cle_arrivee", $desc_depart['table_sql'], sql_in($cle_arrivee, array_keys($ids_trouves)), '','','','',$serveur); |
|
| 182 | - } |
|
| 183 | - // sinon cherchons une table de liaison |
|
| 184 | - // cas recherche principale article, objet lie document : passer par spip_documents_liens |
|
| 185 | - elseif ($l = objet_associable($table_liee)){ |
|
| 186 | - list($primary, $table_liens) = $l; |
|
| 187 | - $s = sql_select("id_objet as $cle_depart, $primary as $cle_arrivee", $table_liens, array("objet='$table'",sql_in($primary, array_keys($ids_trouves))), '','','','',$serveur); |
|
| 188 | - } |
|
| 189 | - // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens |
|
| 190 | - elseif ($l = $depart_associable){ |
|
| 191 | - list($primary, $table_liens) = $l; |
|
| 192 | - $s = sql_select("$primary as $cle_depart, id_objet as $cle_arrivee", $table_liens, array("objet='$table_liee'",sql_in('id_objet', array_keys($ids_trouves))), '','','','',$serveur); |
|
| 193 | - } |
|
| 194 | - // cas table de liaison generique spip_xxx_yyy |
|
| 195 | - elseif($t=$trouver_table($table_arrivee."_".$table_depart,$serveur) |
|
| 196 | - OR $t=$trouver_table($table_depart."_".$table_arrivee,$serveur)){ |
|
| 197 | - $s = sql_select("$cle_depart,$cle_arrivee", $t["table_sql"], sql_in($cle_arrivee, array_keys($ids_trouves)), '','','','',$serveur); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - else |
|
| 201 | - list($cle_depart,$cle_arrivee,$s) = $rechercher_joints($table,$table_liee,array_keys($ids_trouves), $serveur); |
|
| 202 | - |
|
| 203 | - while ($t = is_array($s)?array_shift($s):sql_fetch($s)) { |
|
| 204 | - $id = $t[$cle_depart]; |
|
| 205 | - $joint = $ids_trouves[$t[$cle_arrivee]]; |
|
| 206 | - if (!isset($results)) |
|
| 207 | - $results = array(); |
|
| 208 | - if (!isset($results[$id])) |
|
| 209 | - $results[$id] = array(); |
|
| 210 | - if (isset($joint['score']) and $joint['score']) { |
|
| 211 | - $results[$id]['score'] += $joint['score']; |
|
| 212 | - } |
|
| 213 | - if (isset($joint['champs']) and $joint['champs']) { |
|
| 214 | - foreach($joint['champs'] as $c => $val) { |
|
| 215 | - $results[$id]['champs'][$table_liee.'.'.$c] = $val; |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - if (isset($joint['matches']) and $joint['matches']) { |
|
| 219 | - foreach($joint['matches'] as $c => $val) { |
|
| 220 | - $results[$id]['matches'][$table_liee.'.'.$c] = $val; |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return $results; |
|
| 20 | + // options par defaut |
|
| 21 | + $options = array_merge( |
|
| 22 | + array( |
|
| 23 | + 'score' => true, |
|
| 24 | + 'champs' => false, |
|
| 25 | + 'toutvoir' => false, |
|
| 26 | + 'matches' => false, |
|
| 27 | + 'jointures' => false |
|
| 28 | + ), |
|
| 29 | + $options |
|
| 30 | + ); |
|
| 31 | + |
|
| 32 | + include_spip('inc/rechercher'); |
|
| 33 | + include_spip('inc/autoriser'); |
|
| 34 | + |
|
| 35 | + $requete = array( |
|
| 36 | + "SELECT"=>array(), |
|
| 37 | + "FROM"=>array(), |
|
| 38 | + "WHERE"=>array(), |
|
| 39 | + "GROUPBY"=>array(), |
|
| 40 | + "ORDERBY"=>array(), |
|
| 41 | + "LIMIT"=>"", |
|
| 42 | + "HAVING"=>array() |
|
| 43 | + ); |
|
| 44 | + |
|
| 45 | + $table = sinon($options['table'], 'article'); |
|
| 46 | + if ($options['champs']) |
|
| 47 | + $champs = $options['champs']; |
|
| 48 | + else { |
|
| 49 | + $l = liste_des_champs(); |
|
| 50 | + $champs = $l['article']; |
|
| 51 | + } |
|
| 52 | + $serveur = $options['serveur']; |
|
| 53 | + |
|
| 54 | + list($methode, $q, $preg) = expression_recherche($recherche, $options); |
|
| 55 | + |
|
| 56 | + $jointures = $options['jointures'] |
|
| 57 | + ? liste_des_jointures() |
|
| 58 | + : array(); |
|
| 59 | + |
|
| 60 | + $_id_table = id_table_objet($table); |
|
| 61 | + |
|
| 62 | + // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ',' |
|
| 63 | + // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs) |
|
| 64 | + if (strpos($_id_table,",")!==false){ |
|
| 65 | + $_id_table = explode(',',$_id_table); |
|
| 66 | + $_id_table = reset($_id_table); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $requete['SELECT'][] = "t.".$_id_table; |
|
| 70 | + $a = array(); |
|
| 71 | + // Recherche fulltext |
|
| 72 | + foreach ($champs as $champ => $poids) { |
|
| 73 | + if (is_array($champ)){ |
|
| 74 | + spip_log("requetes imbriquees interdites"); |
|
| 75 | + } else { |
|
| 76 | + if (strpos($champ,".")===FALSE) |
|
| 77 | + $champ = "t.$champ"; |
|
| 78 | + $requete['SELECT'][] = $champ; |
|
| 79 | + $a[] = $champ.' '.$methode.' '.$q; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + if ($a) $requete['WHERE'][] = join(" OR ", $a); |
|
| 83 | + $requete['FROM'][] = table_objet_sql($table).' AS t'; |
|
| 84 | + |
|
| 85 | + $results = array(); |
|
| 86 | + |
|
| 87 | + $s = sql_select( |
|
| 88 | + $requete['SELECT'], $requete['FROM'], $requete['WHERE'], |
|
| 89 | + implode(" ",$requete['GROUPBY']), |
|
| 90 | + $requete['ORDERBY'], $requete['LIMIT'], |
|
| 91 | + $requete['HAVING'], $serveur |
|
| 92 | + ); |
|
| 93 | + |
|
| 94 | + while ($t = sql_fetch($s,$serveur) |
|
| 95 | + AND (!isset($t['score']) OR $t['score']>0)) { |
|
| 96 | + $id = intval($t[$_id_table]); |
|
| 97 | + |
|
| 98 | + if ($options['toutvoir'] |
|
| 99 | + OR autoriser('voir', $table, $id)) { |
|
| 100 | + // indiquer les champs concernes |
|
| 101 | + $champs_vus = array(); |
|
| 102 | + $score = 0; |
|
| 103 | + $matches = array(); |
|
| 104 | + |
|
| 105 | + $vu = false; |
|
| 106 | + foreach ($champs as $champ => $poids) { |
|
| 107 | + $champ = explode('.',$champ); |
|
| 108 | + $champ = end($champ); |
|
| 109 | + // translitteration_rapide uniquement si on est deja en utf-8 |
|
| 110 | + $value = ($GLOBALS['meta']['charset']=='utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ])); |
|
| 111 | + if ($n = |
|
| 112 | + ($options['score'] || $options['matches']) |
|
| 113 | + ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER) |
|
| 114 | + : preg_match($preg, $value) |
|
| 115 | + ) { |
|
| 116 | + $vu = true; |
|
| 117 | + |
|
| 118 | + if ($options['champs']) |
|
| 119 | + $champs_vus[$champ] = $t[$champ]; |
|
| 120 | + if ($options['score']) |
|
| 121 | + $score += $n * $poids; |
|
| 122 | + if ($options['matches']) |
|
| 123 | + $matches[$champ] = $regs; |
|
| 124 | + |
|
| 125 | + if (!$options['champs'] |
|
| 126 | + AND !$options['score'] |
|
| 127 | + AND !$options['matches']) |
|
| 128 | + break; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + if ($vu) { |
|
| 133 | + if (!isset($results)) |
|
| 134 | + $results = array(); |
|
| 135 | + $results[$id] = array(); |
|
| 136 | + if ($champs_vus) |
|
| 137 | + $results[$id]['champs'] = $champs_vus; |
|
| 138 | + if ($score) |
|
| 139 | + $results[$id]['score'] = $score; |
|
| 140 | + if ($matches) |
|
| 141 | + $results[$id]['matches'] = $matches; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + // Gerer les donnees associees |
|
| 148 | + // ici on est un peu naze : pas capables de reconstruire une jointure complexe |
|
| 149 | + // on ne sait passer que par table de laison en 1 coup |
|
| 150 | + if (isset($jointures[$table]) |
|
| 151 | + AND $joints = recherche_en_base( |
|
| 152 | + $recherche, |
|
| 153 | + $jointures[$table], |
|
| 154 | + array_merge($options, array('jointures' => false)) |
|
| 155 | + ) |
|
| 156 | + ) { |
|
| 157 | + include_spip('action/editer_liens'); |
|
| 158 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 159 | + $cle_depart = id_table_objet($table); |
|
| 160 | + $table_depart = table_objet($table,$serveur); |
|
| 161 | + $desc_depart = $trouver_table($table_depart,$serveur); |
|
| 162 | + $depart_associable = objet_associable($table); |
|
| 163 | + foreach ($joints as $table_liee => $ids_trouves) { |
|
| 164 | + // on peut definir une fonction de recherche jointe pour regler les cas particuliers |
|
| 165 | + if ( |
|
| 166 | + !( |
|
| 167 | + $rechercher_joints = charger_fonction("rechercher_joints_${table}_${table_liee}","inc",true) |
|
| 168 | + or $rechercher_joints = charger_fonction("rechercher_joints_objet_${table_liee}","inc",true) |
|
| 169 | + or $rechercher_joints = charger_fonction("rechercher_joints_${table}_objet_lie","inc",true) |
|
| 170 | + ) |
|
| 171 | + ){ |
|
| 172 | + $cle_arrivee = id_table_objet($table_liee); |
|
| 173 | + $table_arrivee = table_objet($table_liee,$serveur); |
|
| 174 | + $desc_arrivee = $trouver_table($table_arrivee,$serveur); |
|
| 175 | + // cas simple : $cle_depart dans la table_liee |
|
| 176 | + if (isset($desc_arrivee['field'][$cle_depart])){ |
|
| 177 | + $s = sql_select("$cle_depart, $cle_arrivee", $desc_arrivee['table_sql'], sql_in($cle_arrivee, array_keys($ids_trouves)), '','','','',$serveur); |
|
| 178 | + } |
|
| 179 | + // cas simple : $cle_arrivee dans la table |
|
| 180 | + elseif (isset($desc_depart['field'][$cle_arrivee])){ |
|
| 181 | + $s = sql_select("$cle_depart, $cle_arrivee", $desc_depart['table_sql'], sql_in($cle_arrivee, array_keys($ids_trouves)), '','','','',$serveur); |
|
| 182 | + } |
|
| 183 | + // sinon cherchons une table de liaison |
|
| 184 | + // cas recherche principale article, objet lie document : passer par spip_documents_liens |
|
| 185 | + elseif ($l = objet_associable($table_liee)){ |
|
| 186 | + list($primary, $table_liens) = $l; |
|
| 187 | + $s = sql_select("id_objet as $cle_depart, $primary as $cle_arrivee", $table_liens, array("objet='$table'",sql_in($primary, array_keys($ids_trouves))), '','','','',$serveur); |
|
| 188 | + } |
|
| 189 | + // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens |
|
| 190 | + elseif ($l = $depart_associable){ |
|
| 191 | + list($primary, $table_liens) = $l; |
|
| 192 | + $s = sql_select("$primary as $cle_depart, id_objet as $cle_arrivee", $table_liens, array("objet='$table_liee'",sql_in('id_objet', array_keys($ids_trouves))), '','','','',$serveur); |
|
| 193 | + } |
|
| 194 | + // cas table de liaison generique spip_xxx_yyy |
|
| 195 | + elseif($t=$trouver_table($table_arrivee."_".$table_depart,$serveur) |
|
| 196 | + OR $t=$trouver_table($table_depart."_".$table_arrivee,$serveur)){ |
|
| 197 | + $s = sql_select("$cle_depart,$cle_arrivee", $t["table_sql"], sql_in($cle_arrivee, array_keys($ids_trouves)), '','','','',$serveur); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + else |
|
| 201 | + list($cle_depart,$cle_arrivee,$s) = $rechercher_joints($table,$table_liee,array_keys($ids_trouves), $serveur); |
|
| 202 | + |
|
| 203 | + while ($t = is_array($s)?array_shift($s):sql_fetch($s)) { |
|
| 204 | + $id = $t[$cle_depart]; |
|
| 205 | + $joint = $ids_trouves[$t[$cle_arrivee]]; |
|
| 206 | + if (!isset($results)) |
|
| 207 | + $results = array(); |
|
| 208 | + if (!isset($results[$id])) |
|
| 209 | + $results[$id] = array(); |
|
| 210 | + if (isset($joint['score']) and $joint['score']) { |
|
| 211 | + $results[$id]['score'] += $joint['score']; |
|
| 212 | + } |
|
| 213 | + if (isset($joint['champs']) and $joint['champs']) { |
|
| 214 | + foreach($joint['champs'] as $c => $val) { |
|
| 215 | + $results[$id]['champs'][$table_liee.'.'.$c] = $val; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + if (isset($joint['matches']) and $joint['matches']) { |
|
| 219 | + foreach($joint['matches'] as $c => $val) { |
|
| 220 | + $results[$id]['matches'][$table_liee.'.'.$c] = $val; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return $results; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
@@ -32,27 +32,27 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function inc_auth_dist() { |
| 34 | 34 | |
| 35 | - global $connect_login ; |
|
| 35 | + global $connect_login ; |
|
| 36 | 36 | |
| 37 | - $row = auth_mode(); |
|
| 37 | + $row = auth_mode(); |
|
| 38 | 38 | |
| 39 | - if ($row) return auth_init_droits($row); |
|
| 39 | + if ($row) return auth_init_droits($row); |
|
| 40 | 40 | |
| 41 | - if (!$connect_login) return auth_a_loger(); |
|
| 41 | + if (!$connect_login) return auth_a_loger(); |
|
| 42 | 42 | |
| 43 | - // Cas ou l'auteur a ete identifie mais on n'a pas d'info sur lui |
|
| 44 | - // C'est soit parce que la base est inutilisable, |
|
| 45 | - // soit parce que la table des auteurs a changee (restauration etc) |
|
| 46 | - // Pas la peine d'insister. |
|
| 47 | - // Renvoyer le nom fautif et une URL de remise a zero |
|
| 43 | + // Cas ou l'auteur a ete identifie mais on n'a pas d'info sur lui |
|
| 44 | + // C'est soit parce que la base est inutilisable, |
|
| 45 | + // soit parce que la table des auteurs a changee (restauration etc) |
|
| 46 | + // Pas la peine d'insister. |
|
| 47 | + // Renvoyer le nom fautif et une URL de remise a zero |
|
| 48 | 48 | |
| 49 | - if (spip_connect()) |
|
| 50 | - return array('login' => $connect_login, |
|
| 51 | - 'site' => generer_url_public('', "action=logout&logout=prive")); |
|
| 49 | + if (spip_connect()) |
|
| 50 | + return array('login' => $connect_login, |
|
| 51 | + 'site' => generer_url_public('', "action=logout&logout=prive")); |
|
| 52 | 52 | |
| 53 | - $n = intval(sql_errno()); |
|
| 54 | - spip_log("Erreur base de donnees $n " . sql_error()); |
|
| 55 | - return $n ? $n : 1; |
|
| 53 | + $n = intval(sql_errno()); |
|
| 54 | + spip_log("Erreur base de donnees $n " . sql_error()); |
|
| 55 | + return $n ? $n : 1; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -65,34 +65,34 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | function auth_echec($raison) |
| 67 | 67 | { |
| 68 | - include_spip('inc/minipres'); |
|
| 69 | - include_spip('inc/headers'); |
|
| 70 | - // pas authentifie. Pourquoi ? |
|
| 71 | - if (is_string($raison)) { |
|
| 72 | - // redirection vers une page d'authentification |
|
| 73 | - // on ne revient pas de cette fonction |
|
| 74 | - // sauf si pb de header |
|
| 75 | - $raison = redirige_formulaire($raison); |
|
| 76 | - } elseif (is_int($raison)) { |
|
| 77 | - // erreur SQL a afficher |
|
| 78 | - $raison = minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'). "<p><tt>".sql_errno()." ".sql_error()."</tt></p>"); |
|
| 79 | - } elseif (@$raison['statut']) { |
|
| 80 | - // un simple visiteur n'a pas acces a l'espace prive |
|
| 81 | - spip_log("connexion refusee a " . @$raison['id_auteur']); |
|
| 82 | - $raison = minipres(_T('avis_erreur_connexion'),_T('avis_erreur_visiteur')); |
|
| 83 | - } else { |
|
| 84 | - // auteur en fin de droits ... |
|
| 85 | - $h = $raison['site']; |
|
| 86 | - $raison = minipres(_T('avis_erreur_connexion'), |
|
| 87 | - "<br /><br /><p>" |
|
| 88 | - . _T('texte_inc_auth_1', |
|
| 89 | - array('auth_login' => $raison['login'])) |
|
| 90 | - . " <a href='$h'>" |
|
| 91 | - . _T('texte_inc_auth_2') |
|
| 92 | - . "</a>" |
|
| 93 | - . _T('texte_inc_auth_3')); |
|
| 94 | - } |
|
| 95 | - return $raison; |
|
| 68 | + include_spip('inc/minipres'); |
|
| 69 | + include_spip('inc/headers'); |
|
| 70 | + // pas authentifie. Pourquoi ? |
|
| 71 | + if (is_string($raison)) { |
|
| 72 | + // redirection vers une page d'authentification |
|
| 73 | + // on ne revient pas de cette fonction |
|
| 74 | + // sauf si pb de header |
|
| 75 | + $raison = redirige_formulaire($raison); |
|
| 76 | + } elseif (is_int($raison)) { |
|
| 77 | + // erreur SQL a afficher |
|
| 78 | + $raison = minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'). "<p><tt>".sql_errno()." ".sql_error()."</tt></p>"); |
|
| 79 | + } elseif (@$raison['statut']) { |
|
| 80 | + // un simple visiteur n'a pas acces a l'espace prive |
|
| 81 | + spip_log("connexion refusee a " . @$raison['id_auteur']); |
|
| 82 | + $raison = minipres(_T('avis_erreur_connexion'),_T('avis_erreur_visiteur')); |
|
| 83 | + } else { |
|
| 84 | + // auteur en fin de droits ... |
|
| 85 | + $h = $raison['site']; |
|
| 86 | + $raison = minipres(_T('avis_erreur_connexion'), |
|
| 87 | + "<br /><br /><p>" |
|
| 88 | + . _T('texte_inc_auth_1', |
|
| 89 | + array('auth_login' => $raison['login'])) |
|
| 90 | + . " <a href='$h'>" |
|
| 91 | + . _T('texte_inc_auth_2') |
|
| 92 | + . "</a>" |
|
| 93 | + . _T('texte_inc_auth_3')); |
|
| 94 | + } |
|
| 95 | + return $raison; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -103,78 +103,78 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | function auth_mode() |
| 105 | 105 | { |
| 106 | - global $auth_can_disconnect, $ignore_auth_http, $ignore_remote_user; |
|
| 107 | - global $connect_login ; |
|
| 108 | - |
|
| 109 | - // |
|
| 110 | - // Initialiser variables (eviter hacks par URL) |
|
| 111 | - // |
|
| 112 | - |
|
| 113 | - $connect_login = ''; |
|
| 114 | - $id_auteur = NULL; |
|
| 115 | - $auth_can_disconnect = false; |
|
| 116 | - |
|
| 117 | - // |
|
| 118 | - // Recuperer les donnees d'identification |
|
| 119 | - // |
|
| 120 | - |
|
| 121 | - // Session valide en cours ? |
|
| 122 | - if (isset($_COOKIE['spip_session'])) { |
|
| 123 | - $session = charger_fonction('session', 'inc'); |
|
| 124 | - if ($id_auteur = $session() |
|
| 125 | - OR $id_auteur===0 // reprise sur restauration |
|
| 126 | - ) { |
|
| 127 | - $auth_can_disconnect = true; |
|
| 128 | - $connect_login = $GLOBALS['visiteur_session']['login']; |
|
| 129 | - } else unset($_COOKIE['spip_session']); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // Essayer auth http si significatif |
|
| 133 | - // (ignorer les login d'intranet independants de spip) |
|
| 134 | - if (!$ignore_auth_http) { |
|
| 135 | - if ( |
|
| 136 | - (isset($_SERVER['PHP_AUTH_USER']) AND isset($_SERVER['PHP_AUTH_PW']) |
|
| 137 | - AND $r = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) |
|
| 138 | - OR |
|
| 139 | - // Si auth http differtente de basic, PHP_AUTH_PW |
|
| 140 | - // est indisponible mais tentons quand meme pour |
|
| 141 | - // autocreation via LDAP |
|
| 142 | - (isset($_SERVER['REMOTE_USER']) |
|
| 143 | - AND $r = lire_php_auth($_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'], '')) |
|
| 144 | - ) { |
|
| 145 | - if (!$id_auteur) { |
|
| 146 | - $_SERVER['PHP_AUTH_PW'] = ''; |
|
| 147 | - $auth_can_disconnect = true; |
|
| 148 | - $GLOBALS['visiteur_session'] = $r; |
|
| 149 | - $connect_login = $GLOBALS['visiteur_session']['login']; |
|
| 150 | - $id_auteur = $r['id_auteur']; |
|
| 151 | - } else { |
|
| 152 | - // cas de la session en plus de PHP_AUTH |
|
| 153 | - /* if ($id_auteur != $r['id_auteur']){ |
|
| 106 | + global $auth_can_disconnect, $ignore_auth_http, $ignore_remote_user; |
|
| 107 | + global $connect_login ; |
|
| 108 | + |
|
| 109 | + // |
|
| 110 | + // Initialiser variables (eviter hacks par URL) |
|
| 111 | + // |
|
| 112 | + |
|
| 113 | + $connect_login = ''; |
|
| 114 | + $id_auteur = NULL; |
|
| 115 | + $auth_can_disconnect = false; |
|
| 116 | + |
|
| 117 | + // |
|
| 118 | + // Recuperer les donnees d'identification |
|
| 119 | + // |
|
| 120 | + |
|
| 121 | + // Session valide en cours ? |
|
| 122 | + if (isset($_COOKIE['spip_session'])) { |
|
| 123 | + $session = charger_fonction('session', 'inc'); |
|
| 124 | + if ($id_auteur = $session() |
|
| 125 | + OR $id_auteur===0 // reprise sur restauration |
|
| 126 | + ) { |
|
| 127 | + $auth_can_disconnect = true; |
|
| 128 | + $connect_login = $GLOBALS['visiteur_session']['login']; |
|
| 129 | + } else unset($_COOKIE['spip_session']); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // Essayer auth http si significatif |
|
| 133 | + // (ignorer les login d'intranet independants de spip) |
|
| 134 | + if (!$ignore_auth_http) { |
|
| 135 | + if ( |
|
| 136 | + (isset($_SERVER['PHP_AUTH_USER']) AND isset($_SERVER['PHP_AUTH_PW']) |
|
| 137 | + AND $r = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) |
|
| 138 | + OR |
|
| 139 | + // Si auth http differtente de basic, PHP_AUTH_PW |
|
| 140 | + // est indisponible mais tentons quand meme pour |
|
| 141 | + // autocreation via LDAP |
|
| 142 | + (isset($_SERVER['REMOTE_USER']) |
|
| 143 | + AND $r = lire_php_auth($_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'], '')) |
|
| 144 | + ) { |
|
| 145 | + if (!$id_auteur) { |
|
| 146 | + $_SERVER['PHP_AUTH_PW'] = ''; |
|
| 147 | + $auth_can_disconnect = true; |
|
| 148 | + $GLOBALS['visiteur_session'] = $r; |
|
| 149 | + $connect_login = $GLOBALS['visiteur_session']['login']; |
|
| 150 | + $id_auteur = $r['id_auteur']; |
|
| 151 | + } else { |
|
| 152 | + // cas de la session en plus de PHP_AUTH |
|
| 153 | + /* if ($id_auteur != $r['id_auteur']){ |
|
| 154 | 154 | spip_log("vol de session $id_auteur" . join(', ', $r)); |
| 155 | 155 | unset($_COOKIE['spip_session']); |
| 156 | 156 | $id_auteur = ''; |
| 157 | 157 | } */ |
| 158 | - } |
|
| 159 | - } |
|
| 160 | - // Authentification .htaccess old style, car .htaccess semble |
|
| 161 | - // souvent definir *aussi* PHP_AUTH_USER et PHP_AUTH_PW |
|
| 162 | - else if (isset($_SERVER['REMOTE_USER'])) |
|
| 163 | - $connect_login = $_SERVER['REMOTE_USER']; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $where = (is_numeric($id_auteur) |
|
| 167 | - /*AND $id_auteur>0*/ // reprise lors des restaurations |
|
| 168 | - ) ? |
|
| 169 | - "id_auteur=$id_auteur" : |
|
| 170 | - (!strlen($connect_login) ? '' : "login=" . sql_quote($connect_login,'','text')); |
|
| 171 | - |
|
| 172 | - if (!$where) return ''; |
|
| 173 | - |
|
| 174 | - // Trouver les autres infos dans la table auteurs. |
|
| 175 | - // le champ 'quand' est utilise par l'agenda |
|
| 176 | - |
|
| 177 | - return sql_fetsel("*, en_ligne AS quand", "spip_auteurs", "$where AND statut!='5poubelle'"); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + // Authentification .htaccess old style, car .htaccess semble |
|
| 161 | + // souvent definir *aussi* PHP_AUTH_USER et PHP_AUTH_PW |
|
| 162 | + else if (isset($_SERVER['REMOTE_USER'])) |
|
| 163 | + $connect_login = $_SERVER['REMOTE_USER']; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $where = (is_numeric($id_auteur) |
|
| 167 | + /*AND $id_auteur>0*/ // reprise lors des restaurations |
|
| 168 | + ) ? |
|
| 169 | + "id_auteur=$id_auteur" : |
|
| 170 | + (!strlen($connect_login) ? '' : "login=" . sql_quote($connect_login,'','text')); |
|
| 171 | + |
|
| 172 | + if (!$where) return ''; |
|
| 173 | + |
|
| 174 | + // Trouver les autres infos dans la table auteurs. |
|
| 175 | + // le champ 'quand' est utilise par l'agenda |
|
| 176 | + |
|
| 177 | + return sql_fetsel("*, en_ligne AS quand", "spip_auteurs", "$where AND statut!='5poubelle'"); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -190,73 +190,73 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | function auth_init_droits($row) |
| 192 | 192 | { |
| 193 | - global $connect_statut, $connect_toutes_rubriques, $connect_id_rubrique, $connect_login, $connect_id_auteur; |
|
| 194 | - |
|
| 195 | - if ($row['statut']=='nouveau'){ |
|
| 196 | - include_spip('action/inscrire_auteur'); |
|
| 197 | - $row = confirmer_statut_inscription($row); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $connect_id_auteur = $row['id_auteur']; |
|
| 201 | - $connect_login = $row['login']; |
|
| 202 | - $connect_statut = $row['statut']; |
|
| 203 | - |
|
| 204 | - $GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row); |
|
| 205 | - |
|
| 206 | - // au cas ou : ne pas memoriser les champs sensibles |
|
| 207 | - unset($GLOBALS['visiteur_session']['pass']); |
|
| 208 | - unset($GLOBALS['visiteur_session']['htpass']); |
|
| 209 | - unset($GLOBALS['visiteur_session']['alea_actuel']); |
|
| 210 | - unset($GLOBALS['visiteur_session']['alea_futur']); |
|
| 211 | - |
|
| 212 | - // creer la session au besoin |
|
| 213 | - if (!isset($_COOKIE['spip_session'])) { |
|
| 214 | - $session = charger_fonction('session', 'inc'); |
|
| 215 | - $spip_session = $session($row); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - // reinjecter les preferences_auteur apres le reset de spip_session |
|
| 219 | - // car utilisees au retour par auth_loger() |
|
| 220 | - $r = @unserialize($row['prefs']); |
|
| 221 | - $GLOBALS['visiteur_session']['prefs'] = ($r ? $r : array()); |
|
| 222 | - // si prefs pas definies, les definir par defaut |
|
| 223 | - if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])){ |
|
| 224 | - $GLOBALS['visiteur_session']['prefs']['couleur'] = 1; |
|
| 225 | - $GLOBALS['visiteur_session']['prefs']['display'] = 2; |
|
| 226 | - $GLOBALS['visiteur_session']['prefs']["display_navigation"] = "navigation_avec_icones"; |
|
| 227 | - $GLOBALS['visiteur_session']['prefs']["display_outils"] = "oui"; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - $GLOBALS['visiteur_session'] = pipeline('preparer_visiteur_session',array('args'=>array('row'=>$row),'data'=>$GLOBALS['visiteur_session'])); |
|
| 231 | - |
|
| 232 | - // Etablir les droits selon le codage attendu |
|
| 233 | - // dans ecrire/index.php ecrire/prive.php |
|
| 234 | - |
|
| 235 | - // Pas autorise a acceder a ecrire ? renvoyer le tableau |
|
| 236 | - // A noter : le premier appel a autoriser() a le bon gout |
|
| 237 | - // d'initialiser $GLOBALS['visiteur_session']['restreint'], |
|
| 238 | - // qui ne figure pas dans le fichier de session |
|
| 239 | - include_spip('inc/autoriser'); |
|
| 240 | - |
|
| 241 | - if (!autoriser('ecrire')) |
|
| 242 | - return $row; |
|
| 243 | - |
|
| 244 | - // autoriser('ecrire') ne laisse passer que les Admin et les Redac |
|
| 245 | - |
|
| 246 | - auth_trace($row); |
|
| 247 | - |
|
| 248 | - // Administrateurs |
|
| 249 | - if (in_array($connect_statut, explode(',', _STATUT_AUTEUR_RUBRIQUE))) { |
|
| 250 | - if (is_array($GLOBALS['visiteur_session']['restreint'])) { |
|
| 251 | - $connect_id_rubrique = $GLOBALS['visiteur_session']['restreint']; |
|
| 252 | - } |
|
| 253 | - if ($connect_statut == '0minirezo') { |
|
| 254 | - $connect_toutes_rubriques = !$connect_id_rubrique; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - // Pour les redacteurs, inc_version a fait l'initialisation minimale |
|
| 258 | - |
|
| 259 | - return ''; // i.e. pas de pb. |
|
| 193 | + global $connect_statut, $connect_toutes_rubriques, $connect_id_rubrique, $connect_login, $connect_id_auteur; |
|
| 194 | + |
|
| 195 | + if ($row['statut']=='nouveau'){ |
|
| 196 | + include_spip('action/inscrire_auteur'); |
|
| 197 | + $row = confirmer_statut_inscription($row); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $connect_id_auteur = $row['id_auteur']; |
|
| 201 | + $connect_login = $row['login']; |
|
| 202 | + $connect_statut = $row['statut']; |
|
| 203 | + |
|
| 204 | + $GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row); |
|
| 205 | + |
|
| 206 | + // au cas ou : ne pas memoriser les champs sensibles |
|
| 207 | + unset($GLOBALS['visiteur_session']['pass']); |
|
| 208 | + unset($GLOBALS['visiteur_session']['htpass']); |
|
| 209 | + unset($GLOBALS['visiteur_session']['alea_actuel']); |
|
| 210 | + unset($GLOBALS['visiteur_session']['alea_futur']); |
|
| 211 | + |
|
| 212 | + // creer la session au besoin |
|
| 213 | + if (!isset($_COOKIE['spip_session'])) { |
|
| 214 | + $session = charger_fonction('session', 'inc'); |
|
| 215 | + $spip_session = $session($row); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + // reinjecter les preferences_auteur apres le reset de spip_session |
|
| 219 | + // car utilisees au retour par auth_loger() |
|
| 220 | + $r = @unserialize($row['prefs']); |
|
| 221 | + $GLOBALS['visiteur_session']['prefs'] = ($r ? $r : array()); |
|
| 222 | + // si prefs pas definies, les definir par defaut |
|
| 223 | + if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])){ |
|
| 224 | + $GLOBALS['visiteur_session']['prefs']['couleur'] = 1; |
|
| 225 | + $GLOBALS['visiteur_session']['prefs']['display'] = 2; |
|
| 226 | + $GLOBALS['visiteur_session']['prefs']["display_navigation"] = "navigation_avec_icones"; |
|
| 227 | + $GLOBALS['visiteur_session']['prefs']["display_outils"] = "oui"; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + $GLOBALS['visiteur_session'] = pipeline('preparer_visiteur_session',array('args'=>array('row'=>$row),'data'=>$GLOBALS['visiteur_session'])); |
|
| 231 | + |
|
| 232 | + // Etablir les droits selon le codage attendu |
|
| 233 | + // dans ecrire/index.php ecrire/prive.php |
|
| 234 | + |
|
| 235 | + // Pas autorise a acceder a ecrire ? renvoyer le tableau |
|
| 236 | + // A noter : le premier appel a autoriser() a le bon gout |
|
| 237 | + // d'initialiser $GLOBALS['visiteur_session']['restreint'], |
|
| 238 | + // qui ne figure pas dans le fichier de session |
|
| 239 | + include_spip('inc/autoriser'); |
|
| 240 | + |
|
| 241 | + if (!autoriser('ecrire')) |
|
| 242 | + return $row; |
|
| 243 | + |
|
| 244 | + // autoriser('ecrire') ne laisse passer que les Admin et les Redac |
|
| 245 | + |
|
| 246 | + auth_trace($row); |
|
| 247 | + |
|
| 248 | + // Administrateurs |
|
| 249 | + if (in_array($connect_statut, explode(',', _STATUT_AUTEUR_RUBRIQUE))) { |
|
| 250 | + if (is_array($GLOBALS['visiteur_session']['restreint'])) { |
|
| 251 | + $connect_id_rubrique = $GLOBALS['visiteur_session']['restreint']; |
|
| 252 | + } |
|
| 253 | + if ($connect_statut == '0minirezo') { |
|
| 254 | + $connect_toutes_rubriques = !$connect_id_rubrique; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + // Pour les redacteurs, inc_version a fait l'initialisation minimale |
|
| 258 | + |
|
| 259 | + return ''; // i.e. pas de pb. |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -266,21 +266,21 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | function auth_a_loger() |
| 268 | 268 | { |
| 269 | - $redirect = generer_url_public('login', |
|
| 270 | - "url=" . rawurlencode(self('&',true)), '&'); |
|
| 271 | - |
|
| 272 | - // un echec au "bonjour" (login initial) quand le statut est |
|
| 273 | - // inconnu signale sans doute un probleme de cookies |
|
| 274 | - if (isset($_GET['bonjour'])) |
|
| 275 | - $redirect = parametre_url($redirect, |
|
| 276 | - 'var_erreur', |
|
| 277 | - (!isset($GLOBALS['visiteur_session']['statut']) |
|
| 278 | - ? 'cookie' |
|
| 279 | - : 'statut' |
|
| 280 | - ), |
|
| 281 | - '&' |
|
| 282 | - ); |
|
| 283 | - return $redirect; |
|
| 269 | + $redirect = generer_url_public('login', |
|
| 270 | + "url=" . rawurlencode(self('&',true)), '&'); |
|
| 271 | + |
|
| 272 | + // un echec au "bonjour" (login initial) quand le statut est |
|
| 273 | + // inconnu signale sans doute un probleme de cookies |
|
| 274 | + if (isset($_GET['bonjour'])) |
|
| 275 | + $redirect = parametre_url($redirect, |
|
| 276 | + 'var_erreur', |
|
| 277 | + (!isset($GLOBALS['visiteur_session']['statut']) |
|
| 278 | + ? 'cookie' |
|
| 279 | + : 'statut' |
|
| 280 | + ), |
|
| 281 | + '&' |
|
| 282 | + ); |
|
| 283 | + return $redirect; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -292,19 +292,19 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | function auth_trace($row, $date=null) |
| 294 | 294 | { |
| 295 | - // Indiquer la connexion. A la minute pres ca suffit. |
|
| 296 | - if (!is_numeric($connect_quand = $row['quand'])) |
|
| 297 | - $connect_quand = strtotime($connect_quand); |
|
| 295 | + // Indiquer la connexion. A la minute pres ca suffit. |
|
| 296 | + if (!is_numeric($connect_quand = $row['quand'])) |
|
| 297 | + $connect_quand = strtotime($connect_quand); |
|
| 298 | 298 | |
| 299 | - if (is_null($date)) |
|
| 300 | - $date = date('Y-m-d H:i:s'); |
|
| 299 | + if (is_null($date)) |
|
| 300 | + $date = date('Y-m-d H:i:s'); |
|
| 301 | 301 | |
| 302 | - if (abs(strtotime($date) - $connect_quand) >= 60) { |
|
| 303 | - sql_updateq("spip_auteurs", array("en_ligne" => $date), "id_auteur=" .$row['id_auteur']); |
|
| 304 | - $row['en_ligne'] = $date; |
|
| 305 | - } |
|
| 302 | + if (abs(strtotime($date) - $connect_quand) >= 60) { |
|
| 303 | + sql_updateq("spip_auteurs", array("en_ligne" => $date), "id_auteur=" .$row['id_auteur']); |
|
| 304 | + $row['en_ligne'] = $date; |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - pipeline('trig_auth_trace',array('args'=>array('row'=>$row,'date'=>$date))); |
|
| 307 | + pipeline('trig_auth_trace',array('args'=>array('row'=>$row,'date'=>$date))); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | |
@@ -320,23 +320,23 @@ discard block |
||
| 320 | 320 | * @return mixed |
| 321 | 321 | */ |
| 322 | 322 | function auth_administrer($fonction,$args,$defaut=false){ |
| 323 | - $auth_methode = array_shift($args); |
|
| 324 | - $auth_methode = $auth_methode ? $auth_methode : 'spip'; // valeur par defaut au cas ou |
|
| 325 | - if ($auth = charger_fonction($auth_methode,'auth',true) |
|
| 326 | - AND function_exists($f="auth_{$auth_methode}_$fonction") |
|
| 327 | - ) |
|
| 328 | - $res = call_user_func_array($f, $args); |
|
| 329 | - else |
|
| 330 | - $res = $defaut; |
|
| 331 | - $res = pipeline('auth_administrer',array( |
|
| 332 | - 'args' => array( |
|
| 333 | - 'fonction' => $fonction, |
|
| 334 | - 'methode' => $auth_methode, |
|
| 335 | - 'args' => $args |
|
| 336 | - ), |
|
| 337 | - 'data' => $res |
|
| 338 | - )); |
|
| 339 | - return $res; |
|
| 323 | + $auth_methode = array_shift($args); |
|
| 324 | + $auth_methode = $auth_methode ? $auth_methode : 'spip'; // valeur par defaut au cas ou |
|
| 325 | + if ($auth = charger_fonction($auth_methode,'auth',true) |
|
| 326 | + AND function_exists($f="auth_{$auth_methode}_$fonction") |
|
| 327 | + ) |
|
| 328 | + $res = call_user_func_array($f, $args); |
|
| 329 | + else |
|
| 330 | + $res = $defaut; |
|
| 331 | + $res = pipeline('auth_administrer',array( |
|
| 332 | + 'args' => array( |
|
| 333 | + 'fonction' => $fonction, |
|
| 334 | + 'methode' => $auth_methode, |
|
| 335 | + 'args' => $args |
|
| 336 | + ), |
|
| 337 | + 'data' => $res |
|
| 338 | + )); |
|
| 339 | + return $res; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | * @return array |
| 347 | 347 | */ |
| 348 | 348 | function auth_formulaire_login($flux){ |
| 349 | - foreach ($GLOBALS['liste_des_authentifications'] as $methode) |
|
| 350 | - $flux = auth_administrer('formulaire_login',array($methode,$flux),$flux); |
|
| 351 | - return $flux; |
|
| 349 | + foreach ($GLOBALS['liste_des_authentifications'] as $methode) |
|
| 350 | + $flux = auth_administrer('formulaire_login',array($methode,$flux),$flux); |
|
| 351 | + return $flux; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | |
@@ -363,19 +363,19 @@ discard block |
||
| 363 | 363 | * @return string/bool |
| 364 | 364 | */ |
| 365 | 365 | function auth_retrouver_login($login, $serveur=''){ |
| 366 | - if (!spip_connect($serveur)) { |
|
| 367 | - include_spip('inc/minipres'); |
|
| 368 | - echo minipres(_T('info_travaux_titre'), |
|
| 369 | - _T('titre_probleme_technique')); |
|
| 370 | - exit; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 374 | - if ($auteur = auth_administrer('retrouver_login',array($methode, $login, $serveur))) { |
|
| 375 | - return $auteur; |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - return false; |
|
| 366 | + if (!spip_connect($serveur)) { |
|
| 367 | + include_spip('inc/minipres'); |
|
| 368 | + echo minipres(_T('info_travaux_titre'), |
|
| 369 | + _T('titre_probleme_technique')); |
|
| 370 | + exit; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 374 | + if ($auteur = auth_administrer('retrouver_login',array($methode, $login, $serveur))) { |
|
| 375 | + return $auteur; |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + return false; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | |
@@ -391,28 +391,28 @@ discard block |
||
| 391 | 391 | * @return array |
| 392 | 392 | */ |
| 393 | 393 | function auth_informer_login($login, $serveur=''){ |
| 394 | - if (!$login |
|
| 395 | - OR !$login = auth_retrouver_login($login, $serveur) |
|
| 396 | - OR !$row = sql_fetsel('*','spip_auteurs','login='.sql_quote($login,$serveur,'text'),'','','','',$serveur) |
|
| 397 | - ) |
|
| 398 | - return array(); |
|
| 399 | - |
|
| 400 | - $prefs = unserialize($row['prefs']); |
|
| 401 | - $infos = array( |
|
| 402 | - 'id_auteur'=>$row['id_auteur'], |
|
| 403 | - 'login'=>$row['login'], |
|
| 404 | - 'cnx' => ($prefs['cnx'] == 'perma') ? '1' : '0', |
|
| 405 | - 'logo' => recuperer_fond('formulaires/inc-logo_auteur', $row), |
|
| 406 | - ); |
|
| 407 | - |
|
| 408 | - // desactiver le hash md5 si pas auteur spip ? |
|
| 409 | - if ($row['source']!=='spip'){ |
|
| 410 | - $row['alea_actuel']= ''; |
|
| 411 | - $row['alea_futur']= ''; |
|
| 412 | - } |
|
| 413 | - verifier_visiteur(); |
|
| 414 | - |
|
| 415 | - return auth_administrer('informer_login',array($row['source'],$infos, $row, $serveur),$infos); |
|
| 394 | + if (!$login |
|
| 395 | + OR !$login = auth_retrouver_login($login, $serveur) |
|
| 396 | + OR !$row = sql_fetsel('*','spip_auteurs','login='.sql_quote($login,$serveur,'text'),'','','','',$serveur) |
|
| 397 | + ) |
|
| 398 | + return array(); |
|
| 399 | + |
|
| 400 | + $prefs = unserialize($row['prefs']); |
|
| 401 | + $infos = array( |
|
| 402 | + 'id_auteur'=>$row['id_auteur'], |
|
| 403 | + 'login'=>$row['login'], |
|
| 404 | + 'cnx' => ($prefs['cnx'] == 'perma') ? '1' : '0', |
|
| 405 | + 'logo' => recuperer_fond('formulaires/inc-logo_auteur', $row), |
|
| 406 | + ); |
|
| 407 | + |
|
| 408 | + // desactiver le hash md5 si pas auteur spip ? |
|
| 409 | + if ($row['source']!=='spip'){ |
|
| 410 | + $row['alea_actuel']= ''; |
|
| 411 | + $row['alea_futur']= ''; |
|
| 412 | + } |
|
| 413 | + verifier_visiteur(); |
|
| 414 | + |
|
| 415 | + return auth_administrer('informer_login',array($row['source'],$infos, $row, $serveur),$infos); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | |
@@ -426,20 +426,20 @@ discard block |
||
| 426 | 426 | * @return mixed |
| 427 | 427 | */ |
| 428 | 428 | function auth_identifier_login($login, $password, $serveur=''){ |
| 429 | - $erreur = ""; |
|
| 430 | - foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 431 | - if ($auth = charger_fonction($methode, 'auth',true)){ |
|
| 432 | - $auteur = $auth($login, $password, $serveur); |
|
| 433 | - if (is_array($auteur) AND count($auteur)) { |
|
| 434 | - spip_log("connexion de $login par methode $methode"); |
|
| 435 | - $auteur['auth'] = $methode; |
|
| 436 | - return $auteur; |
|
| 437 | - } |
|
| 438 | - elseif (is_string($auteur)) |
|
| 439 | - $erreur .= "$auteur "; |
|
| 440 | - } |
|
| 441 | - } |
|
| 442 | - return $erreur; |
|
| 429 | + $erreur = ""; |
|
| 430 | + foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 431 | + if ($auth = charger_fonction($methode, 'auth',true)){ |
|
| 432 | + $auteur = $auth($login, $password, $serveur); |
|
| 433 | + if (is_array($auteur) AND count($auteur)) { |
|
| 434 | + spip_log("connexion de $login par methode $methode"); |
|
| 435 | + $auteur['auth'] = $methode; |
|
| 436 | + return $auteur; |
|
| 437 | + } |
|
| 438 | + elseif (is_string($auteur)) |
|
| 439 | + $erreur .= "$auteur "; |
|
| 440 | + } |
|
| 441 | + } |
|
| 442 | + return $erreur; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -453,14 +453,14 @@ discard block |
||
| 453 | 453 | * @return string |
| 454 | 454 | */ |
| 455 | 455 | function auth_url_retour_login($auth_methode, $login, $redirect='', $serveur=''){ |
| 456 | - $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 457 | - return $securiser_action('auth', "$auth_methode/$login", $redirect, true); |
|
| 456 | + $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 457 | + return $securiser_action('auth', "$auth_methode/$login", $redirect, true); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | function auth_terminer_identifier_login($auth_methode, $login, $serveur=''){ |
| 461 | - $args = func_get_args(); |
|
| 462 | - $auteur = auth_administrer('terminer_identifier_login',$args); |
|
| 463 | - return $auteur; |
|
| 461 | + $args = func_get_args(); |
|
| 462 | + $auteur = auth_administrer('terminer_identifier_login',$args); |
|
| 463 | + return $auteur; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | /** |
@@ -470,41 +470,41 @@ discard block |
||
| 470 | 470 | * @return bool |
| 471 | 471 | */ |
| 472 | 472 | function auth_loger($auteur){ |
| 473 | - if (!is_array($auteur) OR !count($auteur)) |
|
| 474 | - return false; |
|
| 475 | - |
|
| 476 | - // initialiser et poser le cookie de session |
|
| 477 | - unset($_COOKIE['spip_session']); |
|
| 478 | - auth_init_droits($auteur); |
|
| 479 | - |
|
| 480 | - // initialiser les prefs |
|
| 481 | - $p = $GLOBALS['visiteur_session']['prefs']; |
|
| 482 | - $p['cnx'] = ($auteur['cookie'] == 'oui') ? 'perma' : ''; |
|
| 483 | - |
|
| 484 | - sql_updateq('spip_auteurs', |
|
| 485 | - array('prefs' => serialize($p)), |
|
| 486 | - "id_auteur=" . $auteur['id_auteur']); |
|
| 487 | - |
|
| 488 | - // Si on est admin, poser le cookie de correspondance |
|
| 489 | - include_spip('inc/cookie'); |
|
| 490 | - if ($auteur['statut'] == '0minirezo') { |
|
| 491 | - spip_setcookie('spip_admin', '@'.$auteur['login'], |
|
| 492 | - time() + 7 * 24 * 3600); |
|
| 493 | - } |
|
| 494 | - // sinon le supprimer ... |
|
| 495 | - else { |
|
| 496 | - spip_setcookie('spip_admin', '',1); |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - // bloquer ici le visiteur qui tente d'abuser de ses droits |
|
| 500 | - verifier_visiteur(); |
|
| 501 | - return true; |
|
| 473 | + if (!is_array($auteur) OR !count($auteur)) |
|
| 474 | + return false; |
|
| 475 | + |
|
| 476 | + // initialiser et poser le cookie de session |
|
| 477 | + unset($_COOKIE['spip_session']); |
|
| 478 | + auth_init_droits($auteur); |
|
| 479 | + |
|
| 480 | + // initialiser les prefs |
|
| 481 | + $p = $GLOBALS['visiteur_session']['prefs']; |
|
| 482 | + $p['cnx'] = ($auteur['cookie'] == 'oui') ? 'perma' : ''; |
|
| 483 | + |
|
| 484 | + sql_updateq('spip_auteurs', |
|
| 485 | + array('prefs' => serialize($p)), |
|
| 486 | + "id_auteur=" . $auteur['id_auteur']); |
|
| 487 | + |
|
| 488 | + // Si on est admin, poser le cookie de correspondance |
|
| 489 | + include_spip('inc/cookie'); |
|
| 490 | + if ($auteur['statut'] == '0minirezo') { |
|
| 491 | + spip_setcookie('spip_admin', '@'.$auteur['login'], |
|
| 492 | + time() + 7 * 24 * 3600); |
|
| 493 | + } |
|
| 494 | + // sinon le supprimer ... |
|
| 495 | + else { |
|
| 496 | + spip_setcookie('spip_admin', '',1); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + // bloquer ici le visiteur qui tente d'abuser de ses droits |
|
| 500 | + verifier_visiteur(); |
|
| 501 | + return true; |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | |
| 505 | 505 | function auth_deloger(){ |
| 506 | - $logout = charger_fonction('logout','action'); |
|
| 507 | - $logout(); |
|
| 506 | + $logout = charger_fonction('logout','action'); |
|
| 507 | + $logout(); |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | /** |
@@ -516,8 +516,8 @@ discard block |
||
| 516 | 516 | * @return bool |
| 517 | 517 | */ |
| 518 | 518 | function auth_autoriser_modifier_login($auth_methode, $serveur=''){ |
| 519 | - $args = func_get_args(); |
|
| 520 | - return auth_administrer('autoriser_modifier_login',$args); |
|
| 519 | + $args = func_get_args(); |
|
| 520 | + return auth_administrer('autoriser_modifier_login',$args); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | /** |
@@ -532,8 +532,8 @@ discard block |
||
| 532 | 532 | * message d'erreur ou chaine vide si pas d'erreur |
| 533 | 533 | */ |
| 534 | 534 | function auth_verifier_login($auth_methode, $new_login, $id_auteur=0, $serveur=''){ |
| 535 | - $args = func_get_args(); |
|
| 536 | - return auth_administrer('verifier_login',$args,''); |
|
| 535 | + $args = func_get_args(); |
|
| 536 | + return auth_administrer('verifier_login',$args,''); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** |
@@ -546,8 +546,8 @@ discard block |
||
| 546 | 546 | * @return bool |
| 547 | 547 | */ |
| 548 | 548 | function auth_modifier_login($auth_methode, $new_login, $id_auteur, $serveur=''){ |
| 549 | - $args = func_get_args(); |
|
| 550 | - return auth_administrer('modifier_login',$args); |
|
| 549 | + $args = func_get_args(); |
|
| 550 | + return auth_administrer('modifier_login',$args); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -560,8 +560,8 @@ discard block |
||
| 560 | 560 | * succes ou echec |
| 561 | 561 | */ |
| 562 | 562 | function auth_autoriser_modifier_pass($auth_methode, $serveur=''){ |
| 563 | - $args = func_get_args(); |
|
| 564 | - return auth_administrer('autoriser_modifier_pass',$args); |
|
| 563 | + $args = func_get_args(); |
|
| 564 | + return auth_administrer('autoriser_modifier_pass',$args); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | /** |
@@ -577,8 +577,8 @@ discard block |
||
| 577 | 577 | * message d'erreur ou chaine vide si pas d'erreur |
| 578 | 578 | */ |
| 579 | 579 | function auth_verifier_pass($auth_methode, $login, $new_pass, $id_auteur=0, $serveur=''){ |
| 580 | - $args = func_get_args(); |
|
| 581 | - return auth_administrer('verifier_pass',$args,''); |
|
| 580 | + $args = func_get_args(); |
|
| 581 | + return auth_administrer('verifier_pass',$args,''); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -594,8 +594,8 @@ discard block |
||
| 594 | 594 | * succes ou echec |
| 595 | 595 | */ |
| 596 | 596 | function auth_modifier_pass($auth_methode, $login, $new_pass, $id_auteur, $serveur=''){ |
| 597 | - $args = func_get_args(); |
|
| 598 | - return auth_administrer('modifier_pass',$args); |
|
| 597 | + $args = func_get_args(); |
|
| 598 | + return auth_administrer('modifier_pass',$args); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
@@ -611,18 +611,18 @@ discard block |
||
| 611 | 611 | * @return void |
| 612 | 612 | */ |
| 613 | 613 | function auth_synchroniser_distant($auth_methode=true, $id_auteur=0, $champs=array(), $options = array(), $serveur=''){ |
| 614 | - $args = func_get_args(); |
|
| 615 | - if ($auth_methode===true OR (isset($options['all']) AND $options['all']==true)){ |
|
| 616 | - $options['all'] = true; // ajouter une option all=>true pour chaque auth |
|
| 617 | - $args = array(true, $id_auteur, $champs, $options, $serveur); |
|
| 618 | - foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 619 | - array_shift($args); |
|
| 620 | - array_unshift($args,$methode); |
|
| 621 | - auth_administrer('synchroniser_distant',$args); |
|
| 622 | - } |
|
| 623 | - } |
|
| 624 | - else |
|
| 625 | - auth_administrer('synchroniser_distant',$args); |
|
| 614 | + $args = func_get_args(); |
|
| 615 | + if ($auth_methode===true OR (isset($options['all']) AND $options['all']==true)){ |
|
| 616 | + $options['all'] = true; // ajouter une option all=>true pour chaque auth |
|
| 617 | + $args = array(true, $id_auteur, $champs, $options, $serveur); |
|
| 618 | + foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 619 | + array_shift($args); |
|
| 620 | + array_unshift($args,$methode); |
|
| 621 | + auth_administrer('synchroniser_distant',$args); |
|
| 622 | + } |
|
| 623 | + } |
|
| 624 | + else |
|
| 625 | + auth_administrer('synchroniser_distant',$args); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | |
@@ -635,27 +635,27 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | function lire_php_auth($login, $pw, $serveur=''){ |
| 637 | 637 | |
| 638 | - $row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login,$serveur,'text'),'','','','',$serveur); |
|
| 639 | - |
|
| 640 | - if (!$row) { |
|
| 641 | - if (spip_connect_ldap($serveur) |
|
| 642 | - AND $auth_ldap = charger_fonction('ldap', 'auth', true)) |
|
| 643 | - return $auth_ldap($login, $pw, $serveur, true); |
|
| 644 | - return false; |
|
| 645 | - } |
|
| 646 | - // su pas de source definie |
|
| 647 | - // ou auth/xxx introuvable, utiliser 'spip' |
|
| 648 | - if (!$auth_methode = $row['source'] |
|
| 649 | - OR !$auth = charger_fonction($auth_methode, 'auth', true)) |
|
| 650 | - $auth = charger_fonction('spip', 'auth', true); |
|
| 651 | - |
|
| 652 | - $auteur=''; |
|
| 653 | - if ($auth) |
|
| 654 | - $auteur = $auth($login, $pw, $serveur, true); |
|
| 655 | - // verifier que ce n'est pas un message d'erreur |
|
| 656 | - if (is_array($auteur) AND count($auteur)) |
|
| 657 | - return $auteur; |
|
| 658 | - return false; |
|
| 638 | + $row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login,$serveur,'text'),'','','','',$serveur); |
|
| 639 | + |
|
| 640 | + if (!$row) { |
|
| 641 | + if (spip_connect_ldap($serveur) |
|
| 642 | + AND $auth_ldap = charger_fonction('ldap', 'auth', true)) |
|
| 643 | + return $auth_ldap($login, $pw, $serveur, true); |
|
| 644 | + return false; |
|
| 645 | + } |
|
| 646 | + // su pas de source definie |
|
| 647 | + // ou auth/xxx introuvable, utiliser 'spip' |
|
| 648 | + if (!$auth_methode = $row['source'] |
|
| 649 | + OR !$auth = charger_fonction($auth_methode, 'auth', true)) |
|
| 650 | + $auth = charger_fonction('spip', 'auth', true); |
|
| 651 | + |
|
| 652 | + $auteur=''; |
|
| 653 | + if ($auth) |
|
| 654 | + $auteur = $auth($login, $pw, $serveur, true); |
|
| 655 | + // verifier que ce n'est pas un message d'erreur |
|
| 656 | + if (is_array($auteur) AND count($auteur)) |
|
| 657 | + return $auteur; |
|
| 658 | + return false; |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | /** |
@@ -669,21 +669,21 @@ discard block |
||
| 669 | 669 | * @param string $lien |
| 670 | 670 | */ |
| 671 | 671 | function ask_php_auth($pb, $raison, $retour='', $url='', $re='', $lien='') { |
| 672 | - @Header("WWW-Authenticate: Basic realm=\"espace prive\""); |
|
| 673 | - @Header("HTTP/1.0 401 Unauthorized"); |
|
| 674 | - $corps = ""; |
|
| 675 | - $public = generer_url_public(); |
|
| 676 | - $ecrire = generer_url_ecrire(); |
|
| 677 | - $retour = $retour?$retour:_T('icone_retour'); |
|
| 678 | - $corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] "; |
|
| 679 | - if ($url) { |
|
| 680 | - $corps .= "[<a href='" . generer_url_action('cookie',"essai_auth_http=oui&$url") . "'>$re</a>]"; |
|
| 681 | - } |
|
| 682 | - |
|
| 683 | - if ($lien) |
|
| 684 | - $corps .= " [<a href='$ecrire'>"._T('login_espace_prive')."</a>]"; |
|
| 685 | - include_spip('inc/minipres'); |
|
| 686 | - echo minipres($pb,$corps); |
|
| 687 | - exit; |
|
| 672 | + @Header("WWW-Authenticate: Basic realm=\"espace prive\""); |
|
| 673 | + @Header("HTTP/1.0 401 Unauthorized"); |
|
| 674 | + $corps = ""; |
|
| 675 | + $public = generer_url_public(); |
|
| 676 | + $ecrire = generer_url_ecrire(); |
|
| 677 | + $retour = $retour?$retour:_T('icone_retour'); |
|
| 678 | + $corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] "; |
|
| 679 | + if ($url) { |
|
| 680 | + $corps .= "[<a href='" . generer_url_action('cookie',"essai_auth_http=oui&$url") . "'>$re</a>]"; |
|
| 681 | + } |
|
| 682 | + |
|
| 683 | + if ($lien) |
|
| 684 | + $corps .= " [<a href='$ecrire'>"._T('login_espace_prive')."</a>]"; |
|
| 685 | + include_spip('inc/minipres'); |
|
| 686 | + echo minipres($pb,$corps); |
|
| 687 | + exit; |
|
| 688 | 688 | } |
| 689 | 689 | ?> |