@@ -15,27 +15,27 @@ discard block |
||
| 15 | 15 | include_spip('inc/boutons'); |
| 16 | 16 | |
| 17 | 17 | function definir_barre_contexte($contexte = null){ |
| 18 | - if (is_null($contexte)) |
|
| 19 | - $contexte = $_GET; |
|
| 20 | - elseif(is_string($contexte)) |
|
| 21 | - $contexte = unserialize($contexte); |
|
| 22 | - if (!isset($contexte['id_rubrique']) AND isset($contexte['exec'])){ |
|
| 23 | - if (!function_exists('trouver_objet_exec')) |
|
| 24 | - include_spip('inc/pipelines_ecrire'); |
|
| 25 | - if ($e=trouver_objet_exec($contexte['exec'])){ |
|
| 26 | - $_id = $e['id_table_objet']; |
|
| 27 | - if (isset($contexte[$_id]) AND $id=intval($contexte[$_id])){ |
|
| 28 | - $table = $e['table_objet_sql']; |
|
| 29 | - $row = sql_fetsel('*',$table,"$_id=".intval($id)); |
|
| 30 | - if (isset($row['id_rubrique'])){ |
|
| 31 | - $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 32 | - if (isset($row['id_secteur'])) |
|
| 33 | - $contexte['id_secteur'] = $row['id_secteur']; |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - return $contexte; |
|
| 18 | + if (is_null($contexte)) |
|
| 19 | + $contexte = $_GET; |
|
| 20 | + elseif(is_string($contexte)) |
|
| 21 | + $contexte = unserialize($contexte); |
|
| 22 | + if (!isset($contexte['id_rubrique']) AND isset($contexte['exec'])){ |
|
| 23 | + if (!function_exists('trouver_objet_exec')) |
|
| 24 | + include_spip('inc/pipelines_ecrire'); |
|
| 25 | + if ($e=trouver_objet_exec($contexte['exec'])){ |
|
| 26 | + $_id = $e['id_table_objet']; |
|
| 27 | + if (isset($contexte[$_id]) AND $id=intval($contexte[$_id])){ |
|
| 28 | + $table = $e['table_objet_sql']; |
|
| 29 | + $row = sql_fetsel('*',$table,"$_id=".intval($id)); |
|
| 30 | + if (isset($row['id_rubrique'])){ |
|
| 31 | + $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 32 | + if (isset($row['id_secteur'])) |
|
| 33 | + $contexte['id_secteur'] = $row['id_secteur']; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + return $contexte; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -51,55 +51,55 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function definir_barre_boutons($contexte=array(),$icones = true, $autorise = true) { |
| 53 | 53 | include_spip('inc/autoriser'); |
| 54 | - $boutons_admin=array(); |
|
| 54 | + $boutons_admin=array(); |
|
| 55 | 55 | |
| 56 | - // les boutons du core, issus de prive/navigation.xml |
|
| 57 | - $liste_boutons = array(); |
|
| 56 | + // les boutons du core, issus de prive/navigation.xml |
|
| 57 | + $liste_boutons = array(); |
|
| 58 | 58 | |
| 59 | - // ajouter les boutons issus des plugin via plugin.xml |
|
| 60 | - if (function_exists('boutons_plugins') |
|
| 61 | - AND is_array($liste_boutons_plugins = boutons_plugins())) |
|
| 62 | - $liste_boutons = &$liste_boutons_plugins; |
|
| 59 | + // ajouter les boutons issus des plugin via plugin.xml |
|
| 60 | + if (function_exists('boutons_plugins') |
|
| 61 | + AND is_array($liste_boutons_plugins = boutons_plugins())) |
|
| 62 | + $liste_boutons = &$liste_boutons_plugins; |
|
| 63 | 63 | |
| 64 | - foreach($liste_boutons as $id => $infos){ |
|
| 65 | - $parent = ""; |
|
| 66 | - // les boutons principaux ne sont pas soumis a autorisation |
|
| 67 | - if (!isset($infos['parent']) OR !($parent = $infos['parent']) OR !$autorise OR autoriser('menu',"_$id",0,NULL,array('contexte'=>$contexte))){ |
|
| 68 | - if ($parent |
|
| 69 | - AND $parent = preg_replace(',^bando_,','menu_',$parent) |
|
| 70 | - AND isset($boutons_admin[$parent])){ |
|
| 71 | - if (!is_array($boutons_admin[$parent]->sousmenu)) |
|
| 72 | - $boutons_admin[$parent]->sousmenu = array(); |
|
| 73 | - $position = (isset($infos['position']) AND strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 74 | - if ($position<0) $position = count($boutons_admin[$parent]->sousmenu)+1+$position; |
|
| 75 | - $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu,0,$position) |
|
| 76 | - + array($id=> new Bouton( |
|
| 77 | - ($icones AND $infos['icone'])?find_in_theme($infos['icone']):'', // icone |
|
| 78 | - $infos['titre'], // titre |
|
| 79 | - (isset($infos['action']) AND $infos['action'])?$infos['action']:null, |
|
| 80 | - (isset($infos['parametres']) AND $infos['parametres'])?$infos['parametres']:null |
|
| 81 | - )) |
|
| 82 | - + array_slice($boutons_admin[$parent]->sousmenu,$position,100); |
|
| 83 | - } |
|
| 84 | - if (!$parent |
|
| 85 | - // provisoire, eviter les vieux boutons |
|
| 86 | - AND (!in_array($id,array('forum','statistiques_visites'))) |
|
| 64 | + foreach($liste_boutons as $id => $infos){ |
|
| 65 | + $parent = ""; |
|
| 66 | + // les boutons principaux ne sont pas soumis a autorisation |
|
| 67 | + if (!isset($infos['parent']) OR !($parent = $infos['parent']) OR !$autorise OR autoriser('menu',"_$id",0,NULL,array('contexte'=>$contexte))){ |
|
| 68 | + if ($parent |
|
| 69 | + AND $parent = preg_replace(',^bando_,','menu_',$parent) |
|
| 70 | + AND isset($boutons_admin[$parent])){ |
|
| 71 | + if (!is_array($boutons_admin[$parent]->sousmenu)) |
|
| 72 | + $boutons_admin[$parent]->sousmenu = array(); |
|
| 73 | + $position = (isset($infos['position']) AND strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 74 | + if ($position<0) $position = count($boutons_admin[$parent]->sousmenu)+1+$position; |
|
| 75 | + $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu,0,$position) |
|
| 76 | + + array($id=> new Bouton( |
|
| 77 | + ($icones AND $infos['icone'])?find_in_theme($infos['icone']):'', // icone |
|
| 78 | + $infos['titre'], // titre |
|
| 79 | + (isset($infos['action']) AND $infos['action'])?$infos['action']:null, |
|
| 80 | + (isset($infos['parametres']) AND $infos['parametres'])?$infos['parametres']:null |
|
| 81 | + )) |
|
| 82 | + + array_slice($boutons_admin[$parent]->sousmenu,$position,100); |
|
| 83 | + } |
|
| 84 | + if (!$parent |
|
| 85 | + // provisoire, eviter les vieux boutons |
|
| 86 | + AND (!in_array($id,array('forum','statistiques_visites'))) |
|
| 87 | 87 | |
| 88 | - ) { |
|
| 89 | - $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 90 | - $boutons_admin = array_slice($boutons_admin,0,$position) |
|
| 91 | - +array($id=> new Bouton( |
|
| 92 | - ($icones AND isset($infos['icone']) AND $infos['icone'])?find_in_theme($infos['icone']):'', // icone |
|
| 93 | - $infos['titre'], // titre |
|
| 94 | - (isset($infos['action']) AND $infos['action'])?$infos['action']:null, |
|
| 95 | - (isset($infos['parametres']) AND $infos['parametres'])?$infos['parametres']:null |
|
| 96 | - )) |
|
| 97 | - + array_slice($boutons_admin,$position,100); |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 88 | + ) { |
|
| 89 | + $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 90 | + $boutons_admin = array_slice($boutons_admin,0,$position) |
|
| 91 | + +array($id=> new Bouton( |
|
| 92 | + ($icones AND isset($infos['icone']) AND $infos['icone'])?find_in_theme($infos['icone']):'', // icone |
|
| 93 | + $infos['titre'], // titre |
|
| 94 | + (isset($infos['action']) AND $infos['action'])?$infos['action']:null, |
|
| 95 | + (isset($infos['parametres']) AND $infos['parametres'])?$infos['parametres']:null |
|
| 96 | + )) |
|
| 97 | + + array_slice($boutons_admin,$position,100); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return pipeline('ajouter_menus', $boutons_admin); |
|
| 102 | + return pipeline('ajouter_menus', $boutons_admin); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -111,21 +111,21 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | // http://doc.spip.org/@bandeau_creer_url |
| 113 | 113 | function bandeau_creer_url($url, $args="", $contexte=null){ |
| 114 | - if (!preg_match(',[\/\?],',$url)) { |
|
| 115 | - $url = generer_url_ecrire($url,$args,true); |
|
| 116 | - // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 117 | - // &truc=@machin@ |
|
| 118 | - // @machin@ etant remplace par _request('machin') |
|
| 119 | - $url = str_replace('&','&',$url); |
|
| 120 | - while (preg_match(",[&?]([a-z_]+)=@([a-z_]+)@,i",$url,$matches)){ |
|
| 121 | - if ($matches[2]=='id_secteur' AND !isset($contexte['id_secteur']) AND isset($contexte['id_rubrique'])) |
|
| 122 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur','spip_rubriques','id_rubrique='.intval($contexte['id_rubrique'])); |
|
| 123 | - $val = _request($matches[2],$contexte); |
|
| 124 | - $url = parametre_url($url,$matches[1],$val?$val:'','&'); |
|
| 125 | - } |
|
| 126 | - $url = str_replace('&','&',$url); |
|
| 127 | - } |
|
| 128 | - return $url; |
|
| 114 | + if (!preg_match(',[\/\?],',$url)) { |
|
| 115 | + $url = generer_url_ecrire($url,$args,true); |
|
| 116 | + // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 117 | + // &truc=@machin@ |
|
| 118 | + // @machin@ etant remplace par _request('machin') |
|
| 119 | + $url = str_replace('&','&',$url); |
|
| 120 | + while (preg_match(",[&?]([a-z_]+)=@([a-z_]+)@,i",$url,$matches)){ |
|
| 121 | + if ($matches[2]=='id_secteur' AND !isset($contexte['id_secteur']) AND isset($contexte['id_rubrique'])) |
|
| 122 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur','spip_rubriques','id_rubrique='.intval($contexte['id_rubrique'])); |
|
| 123 | + $val = _request($matches[2],$contexte); |
|
| 124 | + $url = parametre_url($url,$matches[1],$val?$val:'','&'); |
|
| 125 | + } |
|
| 126 | + $url = str_replace('&','&',$url); |
|
| 127 | + } |
|
| 128 | + return $url; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @return unknown |
| 139 | 139 | */ |
| 140 | 140 | function inc_bandeau_dist() { |
| 141 | - return recuperer_fond('prive/squelettes/inclure/barre-nav',$_GET); |
|
| 141 | + return recuperer_fond('prive/squelettes/inclure/barre-nav',$_GET); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | ?> |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | // new=oui = article a creer si on valide le formulaire |
| 23 | 23 | // http://doc.spip.org/@inc_article_select_dist |
| 24 | 24 | function inc_precharger_article_dist($id_article, $id_rubrique=0, $lier_trad=0) { |
| 25 | - return precharger_objet('article', $id_article, $id_rubrique, $lier_trad, 'titre'); |
|
| 25 | + return precharger_objet('article', $id_article, $id_rubrique, $lier_trad, 'titre'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | // |
| 33 | 33 | // (fonction facultative si pas de changement dans les traitements) |
| 34 | 34 | function inc_precharger_traduction_article_dist($id_article, $id_rubrique=0, $lier_trad=0) { |
| 35 | - return precharger_traduction_objet('article', $id_article, $id_rubrique, $lier_trad, 'titre'); |
|
| 35 | + return precharger_traduction_objet('article', $id_article, $id_rubrique, $lier_trad, 'titre'); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 18 | 18 | |
| 19 | 19 | if (!function_exists('envoyer_mail')) { |
| 20 | - define('_FUNCTION_ENVOYER_MAIL', charger_fonction('envoyer_mail', 'inc')); |
|
| 20 | + define('_FUNCTION_ENVOYER_MAIL', charger_fonction('envoyer_mail', 'inc')); |
|
| 21 | 21 | // http://doc.spip.org/@envoyer_mail |
| 22 | - function envoyer_mail() { |
|
| 23 | - $args = func_get_args(); |
|
| 24 | - if (_FUNCTION_ENVOYER_MAIL) |
|
| 25 | - return call_user_func_array(_FUNCTION_ENVOYER_MAIL, $args); |
|
| 26 | - } |
|
| 22 | + function envoyer_mail() { |
|
| 23 | + $args = func_get_args(); |
|
| 24 | + if (_FUNCTION_ENVOYER_MAIL) |
|
| 25 | + return call_user_func_array(_FUNCTION_ENVOYER_MAIL, $args); |
|
| 26 | + } |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
@@ -29,64 +29,64 @@ discard block |
||
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | 31 | function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false) { |
| 32 | - global $spip_lang_right,$spip_lang_left; |
|
| 32 | + global $spip_lang_right,$spip_lang_left; |
|
| 33 | 33 | |
| 34 | - utiliser_langue_visiteur(); |
|
| 35 | - |
|
| 36 | - http_no_cache(); |
|
| 37 | - |
|
| 38 | - if ($titre=='AUTO') |
|
| 39 | - $titre=_T('info_installation_systeme_publication'); |
|
| 40 | - |
|
| 41 | - # le charset est en utf-8, pour recuperer le nom comme il faut |
|
| 42 | - # lors de l'installation |
|
| 43 | - if (!headers_sent()) |
|
| 44 | - header('Content-Type: text/html; charset=utf-8'); |
|
| 45 | - |
|
| 46 | - $css = ""; |
|
| 47 | - $files = array('reset.css','clear.css','minipres.css'); |
|
| 48 | - if ($all_inline){ |
|
| 49 | - // inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande) |
|
| 50 | - foreach ($files as $name){ |
|
| 51 | - $file = direction_css(find_in_theme($name)); |
|
| 52 | - if (function_exists("compacte")) |
|
| 53 | - $file = compacte($file); |
|
| 54 | - else |
|
| 55 | - $file = url_absolue_css($file); // precaution |
|
| 56 | - lire_fichier($file,$c); |
|
| 57 | - $css .= $c; |
|
| 58 | - } |
|
| 59 | - $css = "<style type='text/css'>".$css."</style>"; |
|
| 60 | - } |
|
| 61 | - else{ |
|
| 62 | - foreach ($files as $name){ |
|
| 63 | - $file = direction_css(find_in_theme($name)); |
|
| 64 | - $css .= "<link rel='stylesheet' href='$file' type='text/css' />\n"; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - // au cas ou minipres() est appele avant spip_initialisation_suite() |
|
| 69 | - if (!defined('_DOCTYPE_ECRIRE')) define('_DOCTYPE_ECRIRE', ''); |
|
| 70 | - return _DOCTYPE_ECRIRE. |
|
| 71 | - html_lang_attributes(). |
|
| 72 | - "<head>\n". |
|
| 73 | - "<title>". |
|
| 74 | - textebrut($titre). |
|
| 75 | - "</title>\n". |
|
| 76 | - "<meta name='viewport' content='width=device-width' />\n". |
|
| 77 | - $css . |
|
| 34 | + utiliser_langue_visiteur(); |
|
| 35 | + |
|
| 36 | + http_no_cache(); |
|
| 37 | + |
|
| 38 | + if ($titre=='AUTO') |
|
| 39 | + $titre=_T('info_installation_systeme_publication'); |
|
| 40 | + |
|
| 41 | + # le charset est en utf-8, pour recuperer le nom comme il faut |
|
| 42 | + # lors de l'installation |
|
| 43 | + if (!headers_sent()) |
|
| 44 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 45 | + |
|
| 46 | + $css = ""; |
|
| 47 | + $files = array('reset.css','clear.css','minipres.css'); |
|
| 48 | + if ($all_inline){ |
|
| 49 | + // inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande) |
|
| 50 | + foreach ($files as $name){ |
|
| 51 | + $file = direction_css(find_in_theme($name)); |
|
| 52 | + if (function_exists("compacte")) |
|
| 53 | + $file = compacte($file); |
|
| 54 | + else |
|
| 55 | + $file = url_absolue_css($file); // precaution |
|
| 56 | + lire_fichier($file,$c); |
|
| 57 | + $css .= $c; |
|
| 58 | + } |
|
| 59 | + $css = "<style type='text/css'>".$css."</style>"; |
|
| 60 | + } |
|
| 61 | + else{ |
|
| 62 | + foreach ($files as $name){ |
|
| 63 | + $file = direction_css(find_in_theme($name)); |
|
| 64 | + $css .= "<link rel='stylesheet' href='$file' type='text/css' />\n"; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + // au cas ou minipres() est appele avant spip_initialisation_suite() |
|
| 69 | + if (!defined('_DOCTYPE_ECRIRE')) define('_DOCTYPE_ECRIRE', ''); |
|
| 70 | + return _DOCTYPE_ECRIRE. |
|
| 71 | + html_lang_attributes(). |
|
| 72 | + "<head>\n". |
|
| 73 | + "<title>". |
|
| 74 | + textebrut($titre). |
|
| 75 | + "</title>\n". |
|
| 76 | + "<meta name='viewport' content='width=device-width' />\n". |
|
| 77 | + $css . |
|
| 78 | 78 | "</head> |
| 79 | 79 | <body".$onLoad." class='minipres'> |
| 80 | 80 | <div id='minipres'> |
| 81 | 81 | <h1>". |
| 82 | - $titre . |
|
| 83 | - "</h1> |
|
| 82 | + $titre . |
|
| 83 | + "</h1> |
|
| 84 | 84 | <div>\n"; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // http://doc.spip.org/@install_fin_html |
| 88 | 88 | function install_fin_html() { |
| 89 | - return "\n\t</div>\n\t</div>\n</body>\n</html>"; |
|
| 89 | + return "\n\t</div>\n\t</div>\n</body>\n</html>"; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
@@ -105,45 +105,45 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | function minipres($titre='', $corps="", $onload='', $all_inline = false) |
| 107 | 107 | { |
| 108 | - if (!defined('_AJAX')) define('_AJAX', false); // par securite |
|
| 109 | - if (!$titre) { |
|
| 110 | - if (!_AJAX) |
|
| 111 | - http_status(403); |
|
| 112 | - if (!$titre = _request('action') |
|
| 113 | - AND !$titre = _request('exec') |
|
| 114 | - AND !$titre = _request('page')) |
|
| 115 | - $titre = '?'; |
|
| 116 | - |
|
| 117 | - $titre = spip_htmlspecialchars($titre); |
|
| 118 | - |
|
| 119 | - $titre = ($titre == 'install') |
|
| 120 | - ? _T('avis_espace_interdit') |
|
| 121 | - : $titre . ' : '. _T('info_acces_interdit'); |
|
| 122 | - |
|
| 123 | - $statut = isset($GLOBALS['visiteur_session']['statut']) ? $GLOBALS['visiteur_session']['statut'] : ''; |
|
| 124 | - $nom = isset($GLOBALS['visiteur_session']['nom']) ? $GLOBALS['visiteur_session']['nom'] : ''; |
|
| 125 | - |
|
| 126 | - if ($statut != '0minirezo') { |
|
| 127 | - $titre = _T('info_acces_interdit'); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - $corps = generer_form_ecrire('accueil', '','', |
|
| 131 | - $statut ? _T('public:accueil_site') : _T('public:lien_connecter') |
|
| 132 | - ); |
|
| 133 | - spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - if (!_AJAX) |
|
| 137 | - return install_debut_html($titre, $onload, $all_inline) |
|
| 138 | - . $corps |
|
| 139 | - . install_fin_html(); |
|
| 140 | - else { |
|
| 141 | - include_spip('inc/headers'); |
|
| 142 | - include_spip('inc/actions'); |
|
| 143 | - $url = self('&',true); |
|
| 144 | - foreach ($_POST as $v => $c) |
|
| 145 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 146 | - ajax_retour("<div>".$titre . redirige_formulaire($url)."</div>",false); |
|
| 147 | - } |
|
| 108 | + if (!defined('_AJAX')) define('_AJAX', false); // par securite |
|
| 109 | + if (!$titre) { |
|
| 110 | + if (!_AJAX) |
|
| 111 | + http_status(403); |
|
| 112 | + if (!$titre = _request('action') |
|
| 113 | + AND !$titre = _request('exec') |
|
| 114 | + AND !$titre = _request('page')) |
|
| 115 | + $titre = '?'; |
|
| 116 | + |
|
| 117 | + $titre = spip_htmlspecialchars($titre); |
|
| 118 | + |
|
| 119 | + $titre = ($titre == 'install') |
|
| 120 | + ? _T('avis_espace_interdit') |
|
| 121 | + : $titre . ' : '. _T('info_acces_interdit'); |
|
| 122 | + |
|
| 123 | + $statut = isset($GLOBALS['visiteur_session']['statut']) ? $GLOBALS['visiteur_session']['statut'] : ''; |
|
| 124 | + $nom = isset($GLOBALS['visiteur_session']['nom']) ? $GLOBALS['visiteur_session']['nom'] : ''; |
|
| 125 | + |
|
| 126 | + if ($statut != '0minirezo') { |
|
| 127 | + $titre = _T('info_acces_interdit'); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + $corps = generer_form_ecrire('accueil', '','', |
|
| 131 | + $statut ? _T('public:accueil_site') : _T('public:lien_connecter') |
|
| 132 | + ); |
|
| 133 | + spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + if (!_AJAX) |
|
| 137 | + return install_debut_html($titre, $onload, $all_inline) |
|
| 138 | + . $corps |
|
| 139 | + . install_fin_html(); |
|
| 140 | + else { |
|
| 141 | + include_spip('inc/headers'); |
|
| 142 | + include_spip('inc/actions'); |
|
| 143 | + $url = self('&',true); |
|
| 144 | + foreach ($_POST as $v => $c) |
|
| 145 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 146 | + ajax_retour("<div>".$titre . redirige_formulaire($url)."</div>",false); |
|
| 147 | + } |
|
| 148 | 148 | } |
| 149 | 149 | ?> |
@@ -31,22 +31,22 @@ discard block |
||
| 31 | 31 | * @return array|string |
| 32 | 32 | */ |
| 33 | 33 | function generer_action_auteur($action, $arg, $redirect = "", $mode = false, $att = '', $public = false){ |
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - return $securiser_action($action, $arg, $redirect, $mode, $att, $public); |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + return $securiser_action($action, $arg, $redirect, $mode, $att, $public); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // http://doc.spip.org/@redirige_action_auteur |
| 39 | 39 | function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) { |
| 40 | 40 | |
| 41 | - $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) .generer_url_ecrire($ret, $gra, true, true); |
|
| 41 | + $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) .generer_url_ecrire($ret, $gra, true, true); |
|
| 42 | 42 | |
| 43 | - return generer_action_auteur($action, $arg, $r, $mode, $atts, $public); |
|
| 43 | + return generer_action_auteur($action, $arg, $r, $mode, $atts, $public); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // http://doc.spip.org/@redirige_action_post |
| 47 | 47 | function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = ''){ |
| 48 | - $r = _DIR_RESTREINT.generer_url_ecrire($ret, $gra, false, true); |
|
| 49 | - return generer_action_auteur($action, $arg, $r, $corps, $att." method='post'"); |
|
| 48 | + $r = _DIR_RESTREINT.generer_url_ecrire($ret, $gra, false, true); |
|
| 49 | + return generer_action_auteur($action, $arg, $r, $corps, $att." method='post'"); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -63,34 +63,34 @@ discard block |
||
| 63 | 63 | * passer "text/html" comme $content_type |
| 64 | 64 | */ |
| 65 | 65 | function ajax_retour($corps, $content_type = null){ |
| 66 | - $xml = false; |
|
| 67 | - if (is_null($content_type) OR $content_type===true){ |
|
| 68 | - $xml = true; |
|
| 69 | - $content_type = 'text/html'; |
|
| 70 | - } |
|
| 71 | - elseif (!$content_type OR !is_string($content_type) OR strpos($content_type,'/')===false) { |
|
| 72 | - $content_type = 'text/html'; |
|
| 73 | - } |
|
| 66 | + $xml = false; |
|
| 67 | + if (is_null($content_type) OR $content_type===true){ |
|
| 68 | + $xml = true; |
|
| 69 | + $content_type = 'text/html'; |
|
| 70 | + } |
|
| 71 | + elseif (!$content_type OR !is_string($content_type) OR strpos($content_type,'/')===false) { |
|
| 72 | + $content_type = 'text/html'; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - $e = ""; |
|
| 76 | - if (isset($_COOKIE['spip_admin']) |
|
| 77 | - AND ((_request('var_mode')=='debug') OR !empty($GLOBALS['tableau_des_temps']))) |
|
| 78 | - $e = erreur_squelette(); |
|
| 79 | - if (isset($GLOBALS['transformer_xml']) OR (isset($GLOBALS['exec']) AND $GLOBALS['exec']=='valider_xml')){ |
|
| 80 | - $debut = _DOCTYPE_ECRIRE |
|
| 81 | - ."<html><head><title>Debug Spip Ajax</title></head>" |
|
| 82 | - ."<body><div>\n\n" |
|
| 83 | - ."<!-- %%%%%%%%%%%%%%%%%%% Ajax %%%%%%%%%%%%%%%%%%% -->\n"; |
|
| 75 | + $e = ""; |
|
| 76 | + if (isset($_COOKIE['spip_admin']) |
|
| 77 | + AND ((_request('var_mode')=='debug') OR !empty($GLOBALS['tableau_des_temps']))) |
|
| 78 | + $e = erreur_squelette(); |
|
| 79 | + if (isset($GLOBALS['transformer_xml']) OR (isset($GLOBALS['exec']) AND $GLOBALS['exec']=='valider_xml')){ |
|
| 80 | + $debut = _DOCTYPE_ECRIRE |
|
| 81 | + ."<html><head><title>Debug Spip Ajax</title></head>" |
|
| 82 | + ."<body><div>\n\n" |
|
| 83 | + ."<!-- %%%%%%%%%%%%%%%%%%% Ajax %%%%%%%%%%%%%%%%%%% -->\n"; |
|
| 84 | 84 | |
| 85 | - $fin = '</div></body></html>'; |
|
| 85 | + $fin = '</div></body></html>'; |
|
| 86 | 86 | |
| 87 | - } else { |
|
| 88 | - $c = $GLOBALS['meta']["charset"]; |
|
| 89 | - header('Content-Type: '.$content_type.'; charset='.$c); |
|
| 90 | - $debut = (($xml AND strlen(trim($corps))) ? '<'."?xml version='1.0' encoding='".$c."'?".">\n" : ''); |
|
| 91 | - $fin = ""; |
|
| 92 | - } |
|
| 93 | - echo $debut, $corps, $fin, $e; |
|
| 87 | + } else { |
|
| 88 | + $c = $GLOBALS['meta']["charset"]; |
|
| 89 | + header('Content-Type: '.$content_type.'; charset='.$c); |
|
| 90 | + $debut = (($xml AND strlen(trim($corps))) ? '<'."?xml version='1.0' encoding='".$c."'?".">\n" : ''); |
|
| 91 | + $fin = ""; |
|
| 92 | + } |
|
| 93 | + echo $debut, $corps, $fin, $e; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | ?> |
@@ -72,39 +72,39 @@ discard block |
||
| 72 | 72 | * @return array |
| 73 | 73 | */ |
| 74 | 74 | function cvtmulti_recuperer_post_precedents($form){ |
| 75 | - include_spip('inc/filtres'); |
|
| 76 | - if ($form |
|
| 77 | - AND $c = _request('cvtm_prev_post') |
|
| 78 | - AND $c = decoder_contexte_ajax($c, $form)){ |
|
| 79 | - #var_dump($c); |
|
| 75 | + include_spip('inc/filtres'); |
|
| 76 | + if ($form |
|
| 77 | + AND $c = _request('cvtm_prev_post') |
|
| 78 | + AND $c = decoder_contexte_ajax($c, $form)){ |
|
| 79 | + #var_dump($c); |
|
| 80 | 80 | |
| 81 | - # reinjecter dans la bonne variable pour permettre de retrouver |
|
| 82 | - # toutes les saisies dans un seul tableau |
|
| 83 | - if ($_SERVER['REQUEST_METHOD']=='POST') |
|
| 84 | - $store = &$_POST; |
|
| 85 | - else |
|
| 86 | - $store = &$_GET; |
|
| 87 | - |
|
| 88 | - foreach($c as $k=>$v) |
|
| 89 | - // on ecrase pas si saisi a nouveau ! |
|
| 90 | - if (!isset($store[$k])) |
|
| 91 | - $_REQUEST[$k] = $store[$k] = $v; |
|
| 92 | - // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie |
|
| 93 | - elseif(is_array($store[$k]) |
|
| 94 | - AND is_array($v) |
|
| 95 | - AND $z = array_keys($v) |
|
| 96 | - AND !is_numeric(reset($z)) |
|
| 97 | - AND $z = array_keys($store[$k]) |
|
| 98 | - AND !is_numeric(reset($z)) |
|
| 99 | - ) |
|
| 100 | - $_REQUEST[$k] = $store[$k] = array_merge($v,$store[$k]); |
|
| 101 | - |
|
| 102 | - // vider pour eviter un second appel a verifier_n |
|
| 103 | - // en cas de double implementation (unipotence) |
|
| 104 | - set_request('cvtm_prev_post'); |
|
| 105 | - return array($c['_etape'],$c['_etapes']); |
|
| 106 | - } |
|
| 107 | - return false; |
|
| 81 | + # reinjecter dans la bonne variable pour permettre de retrouver |
|
| 82 | + # toutes les saisies dans un seul tableau |
|
| 83 | + if ($_SERVER['REQUEST_METHOD']=='POST') |
|
| 84 | + $store = &$_POST; |
|
| 85 | + else |
|
| 86 | + $store = &$_GET; |
|
| 87 | + |
|
| 88 | + foreach($c as $k=>$v) |
|
| 89 | + // on ecrase pas si saisi a nouveau ! |
|
| 90 | + if (!isset($store[$k])) |
|
| 91 | + $_REQUEST[$k] = $store[$k] = $v; |
|
| 92 | + // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie |
|
| 93 | + elseif(is_array($store[$k]) |
|
| 94 | + AND is_array($v) |
|
| 95 | + AND $z = array_keys($v) |
|
| 96 | + AND !is_numeric(reset($z)) |
|
| 97 | + AND $z = array_keys($store[$k]) |
|
| 98 | + AND !is_numeric(reset($z)) |
|
| 99 | + ) |
|
| 100 | + $_REQUEST[$k] = $store[$k] = array_merge($v,$store[$k]); |
|
| 101 | + |
|
| 102 | + // vider pour eviter un second appel a verifier_n |
|
| 103 | + // en cas de double implementation (unipotence) |
|
| 104 | + set_request('cvtm_prev_post'); |
|
| 105 | + return array($c['_etape'],$c['_etapes']); |
|
| 106 | + } |
|
| 107 | + return false; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -117,25 +117,25 @@ discard block |
||
| 117 | 117 | * @return array |
| 118 | 118 | */ |
| 119 | 119 | function cvtmulti_sauver_post($form, $je_suis_poste, &$valeurs){ |
| 120 | - if (!isset($valeurs['_cvtm_prev_post'])){ |
|
| 121 | - $post = array('_etape'=>$valeurs['_etape'],'_etapes'=>$valeurs['_etapes']); |
|
| 122 | - foreach(array_keys($valeurs) as $champ){ |
|
| 123 | - if (substr($champ,0,1)!=='_'){ |
|
| 124 | - if ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])) { |
|
| 125 | - if (($v = _request($champ))!==NULL) |
|
| 126 | - $post[$champ] = $v; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - include_spip('inc/filtres'); |
|
| 131 | - $c = encoder_contexte_ajax($post,$form); |
|
| 132 | - if (!isset($valeurs['_hidden'])) |
|
| 133 | - $valeurs['_hidden'] = ''; |
|
| 134 | - $valeurs['_hidden'] .= "<input type='hidden' name='cvtm_prev_post' value='$c' />"; |
|
| 135 | - // marquer comme fait, pour eviter double encodage (unipotence) |
|
| 136 | - $valeurs['_cvtm_prev_post'] = true; |
|
| 137 | - } |
|
| 138 | - return $valeurs; |
|
| 120 | + if (!isset($valeurs['_cvtm_prev_post'])){ |
|
| 121 | + $post = array('_etape'=>$valeurs['_etape'],'_etapes'=>$valeurs['_etapes']); |
|
| 122 | + foreach(array_keys($valeurs) as $champ){ |
|
| 123 | + if (substr($champ,0,1)!=='_'){ |
|
| 124 | + if ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])) { |
|
| 125 | + if (($v = _request($champ))!==NULL) |
|
| 126 | + $post[$champ] = $v; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + include_spip('inc/filtres'); |
|
| 131 | + $c = encoder_contexte_ajax($post,$form); |
|
| 132 | + if (!isset($valeurs['_hidden'])) |
|
| 133 | + $valeurs['_hidden'] = ''; |
|
| 134 | + $valeurs['_hidden'] .= "<input type='hidden' name='cvtm_prev_post' value='$c' />"; |
|
| 135 | + // marquer comme fait, pour eviter double encodage (unipotence) |
|
| 136 | + $valeurs['_cvtm_prev_post'] = true; |
|
| 137 | + } |
|
| 138 | + return $valeurs; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | |
@@ -147,22 +147,22 @@ discard block |
||
| 147 | 147 | * @return <type> |
| 148 | 148 | */ |
| 149 | 149 | function cvtmulti_formulaire_charger($flux){ |
| 150 | - #var_dump($flux['data']['_etapes']); |
|
| 151 | - if (is_array($flux['data']) |
|
| 152 | - AND isset($flux['data']['_etapes'])){ |
|
| 153 | - $form = $flux['args']['form']; |
|
| 154 | - $je_suis_poste = $flux['args']['je_suis_poste']; |
|
| 155 | - $nb_etapes = $flux['data']['_etapes']; |
|
| 156 | - $etape = _request('_etape'); |
|
| 157 | - $etape = min(max($etape,1),$nb_etapes); |
|
| 158 | - set_request('_etape',$etape); |
|
| 159 | - $flux['data']['_etape'] = $etape; |
|
| 160 | - |
|
| 161 | - // sauver les posts de cette etape pour les avoir a la prochaine etape |
|
| 162 | - $flux['data'] = cvtmulti_sauver_post($form, $je_suis_poste, $flux['data']); |
|
| 163 | - #var_dump($flux['data']); |
|
| 164 | - } |
|
| 165 | - return $flux; |
|
| 150 | + #var_dump($flux['data']['_etapes']); |
|
| 151 | + if (is_array($flux['data']) |
|
| 152 | + AND isset($flux['data']['_etapes'])){ |
|
| 153 | + $form = $flux['args']['form']; |
|
| 154 | + $je_suis_poste = $flux['args']['je_suis_poste']; |
|
| 155 | + $nb_etapes = $flux['data']['_etapes']; |
|
| 156 | + $etape = _request('_etape'); |
|
| 157 | + $etape = min(max($etape,1),$nb_etapes); |
|
| 158 | + set_request('_etape',$etape); |
|
| 159 | + $flux['data']['_etape'] = $etape; |
|
| 160 | + |
|
| 161 | + // sauver les posts de cette etape pour les avoir a la prochaine etape |
|
| 162 | + $flux['data'] = cvtmulti_sauver_post($form, $je_suis_poste, $flux['data']); |
|
| 163 | + #var_dump($flux['data']); |
|
| 164 | + } |
|
| 165 | + return $flux; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | |
@@ -173,53 +173,53 @@ discard block |
||
| 173 | 173 | * @return array |
| 174 | 174 | */ |
| 175 | 175 | function cvtmulti_formulaire_verifier($flux){ |
| 176 | - #var_dump('Pipe verifier'); |
|
| 176 | + #var_dump('Pipe verifier'); |
|
| 177 | 177 | |
| 178 | - if ($form = $flux['args']['form'] |
|
| 179 | - AND ($e = cvtmulti_recuperer_post_precedents($form))!==false){ |
|
| 180 | - // recuperer l'etape saisie et le nombre d'etapes total |
|
| 181 | - list($etape,$etapes) = $e; |
|
| 182 | - $etape_demandee = _request('aller_a_etape'); // possibilite de poster en entier dans aller_a_etape |
|
| 183 | - |
|
| 184 | - // lancer les verifs pour chaque etape deja saisie de 1 a $etape |
|
| 185 | - $erreurs = array(); |
|
| 186 | - $derniere_etape_ok = 0; |
|
| 187 | - $e = 0; |
|
| 188 | - while ($e<$etape AND $e<$etapes){ |
|
| 189 | - $e++; |
|
| 190 | - $erreurs[$e] = array(); |
|
| 191 | - if ($verifier = charger_fonction("verifier_$e","formulaires/$form/",true)) |
|
| 192 | - $erreurs[$e] = call_user_func_array($verifier, $flux['args']['args']); |
|
| 193 | - elseif ($verifier = charger_fonction("verifier_etape","formulaires/$form/",true)){ |
|
| 194 | - $args = $flux['args']['args']; |
|
| 195 | - array_unshift($args, $e); |
|
| 196 | - $erreurs[$e] = call_user_func_array($verifier, $args); |
|
| 197 | - } |
|
| 198 | - if ($derniere_etape_ok==$e-1 AND !count($erreurs[$e])) |
|
| 199 | - $derniere_etape_ok = $e; |
|
| 200 | - // possibilite de poster dans _retour_etape_x |
|
| 201 | - if (!is_null(_request("_retour_etape_$e"))) |
|
| 202 | - $etape_demandee = $e; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - // si la derniere etape OK etait la derniere |
|
| 206 | - // on renvoie le flux inchange et ca declenche traiter |
|
| 207 | - if ($derniere_etape_ok==$etapes AND !$etape_demandee){ |
|
| 208 | - return $flux; |
|
| 209 | - } |
|
| 210 | - else { |
|
| 211 | - $etape = $derniere_etape_ok+1; |
|
| 212 | - if ($etape_demandee>0 AND $etape_demandee<$etape) |
|
| 213 | - $etape = $etape_demandee; |
|
| 214 | - $etape = min($etape,$etapes); |
|
| 215 | - #var_dump("prochaine etape $etape"); |
|
| 216 | - // retourner les erreurs de l'etape ciblee |
|
| 217 | - $flux['data'] = isset($erreurs[$etape]) ? $erreurs[$etape] : array() ; |
|
| 218 | - $flux['data']['_etapes'] = "etape suivante $etape"; |
|
| 219 | - set_request('_etape',$etape); |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - return $flux; |
|
| 178 | + if ($form = $flux['args']['form'] |
|
| 179 | + AND ($e = cvtmulti_recuperer_post_precedents($form))!==false){ |
|
| 180 | + // recuperer l'etape saisie et le nombre d'etapes total |
|
| 181 | + list($etape,$etapes) = $e; |
|
| 182 | + $etape_demandee = _request('aller_a_etape'); // possibilite de poster en entier dans aller_a_etape |
|
| 183 | + |
|
| 184 | + // lancer les verifs pour chaque etape deja saisie de 1 a $etape |
|
| 185 | + $erreurs = array(); |
|
| 186 | + $derniere_etape_ok = 0; |
|
| 187 | + $e = 0; |
|
| 188 | + while ($e<$etape AND $e<$etapes){ |
|
| 189 | + $e++; |
|
| 190 | + $erreurs[$e] = array(); |
|
| 191 | + if ($verifier = charger_fonction("verifier_$e","formulaires/$form/",true)) |
|
| 192 | + $erreurs[$e] = call_user_func_array($verifier, $flux['args']['args']); |
|
| 193 | + elseif ($verifier = charger_fonction("verifier_etape","formulaires/$form/",true)){ |
|
| 194 | + $args = $flux['args']['args']; |
|
| 195 | + array_unshift($args, $e); |
|
| 196 | + $erreurs[$e] = call_user_func_array($verifier, $args); |
|
| 197 | + } |
|
| 198 | + if ($derniere_etape_ok==$e-1 AND !count($erreurs[$e])) |
|
| 199 | + $derniere_etape_ok = $e; |
|
| 200 | + // possibilite de poster dans _retour_etape_x |
|
| 201 | + if (!is_null(_request("_retour_etape_$e"))) |
|
| 202 | + $etape_demandee = $e; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + // si la derniere etape OK etait la derniere |
|
| 206 | + // on renvoie le flux inchange et ca declenche traiter |
|
| 207 | + if ($derniere_etape_ok==$etapes AND !$etape_demandee){ |
|
| 208 | + return $flux; |
|
| 209 | + } |
|
| 210 | + else { |
|
| 211 | + $etape = $derniere_etape_ok+1; |
|
| 212 | + if ($etape_demandee>0 AND $etape_demandee<$etape) |
|
| 213 | + $etape = $etape_demandee; |
|
| 214 | + $etape = min($etape,$etapes); |
|
| 215 | + #var_dump("prochaine etape $etape"); |
|
| 216 | + // retourner les erreurs de l'etape ciblee |
|
| 217 | + $flux['data'] = isset($erreurs[$etape]) ? $erreurs[$etape] : array() ; |
|
| 218 | + $flux['data']['_etapes'] = "etape suivante $etape"; |
|
| 219 | + set_request('_etape',$etape); |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + return $flux; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -231,15 +231,15 @@ discard block |
||
| 231 | 231 | * @return array |
| 232 | 232 | */ |
| 233 | 233 | function cvtmulti_styliser($flux){ |
| 234 | - if (strncmp($flux['args']['fond'],'formulaires/',12)==0 |
|
| 235 | - AND isset($flux['args']['contexte']['_etapes']) |
|
| 236 | - AND isset($flux['args']['contexte']['_etape']) |
|
| 237 | - AND ($e=$flux['args']['contexte']['_etape'])>1 |
|
| 238 | - AND $ext = $flux['args']['ext'] |
|
| 239 | - AND $f=$flux['data'] |
|
| 240 | - AND file_exists($f."_$e.$ext")) |
|
| 241 | - $flux['data'] = $f."_$e"; |
|
| 242 | - return $flux; |
|
| 234 | + if (strncmp($flux['args']['fond'],'formulaires/',12)==0 |
|
| 235 | + AND isset($flux['args']['contexte']['_etapes']) |
|
| 236 | + AND isset($flux['args']['contexte']['_etape']) |
|
| 237 | + AND ($e=$flux['args']['contexte']['_etape'])>1 |
|
| 238 | + AND $ext = $flux['args']['ext'] |
|
| 239 | + AND $f=$flux['data'] |
|
| 240 | + AND file_exists($f."_$e.$ext")) |
|
| 241 | + $flux['data'] = $f."_$e"; |
|
| 242 | + return $flux; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
@@ -52,21 +52,21 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | // http://doc.spip.org/@inc_genie_dist |
| 54 | 54 | function inc_genie_dist($taches = array()) { |
| 55 | - include_spip('inc/queue'); |
|
| 55 | + include_spip('inc/queue'); |
|
| 56 | 56 | |
| 57 | - if (_request('exec')=='job_queue') |
|
| 58 | - return false; |
|
| 57 | + if (_request('exec')=='job_queue') |
|
| 58 | + return false; |
|
| 59 | 59 | |
| 60 | - $force_jobs = array(); |
|
| 61 | - // l'ancienne facon de lancer une tache cron immediatement |
|
| 62 | - // etait de la passer en parametre a ing_genie_dist |
|
| 63 | - // on reroute en ajoutant simplement le job a la queue, ASAP |
|
| 64 | - foreach($taches as $function=>$period) |
|
| 65 | - $force_jobs[] = queue_add_job($function, _T('tache_cron_asap', array('function'=>$function)), array(time()-abs($period)), "genie/"); |
|
| 60 | + $force_jobs = array(); |
|
| 61 | + // l'ancienne facon de lancer une tache cron immediatement |
|
| 62 | + // etait de la passer en parametre a ing_genie_dist |
|
| 63 | + // on reroute en ajoutant simplement le job a la queue, ASAP |
|
| 64 | + foreach($taches as $function=>$period) |
|
| 65 | + $force_jobs[] = queue_add_job($function, _T('tache_cron_asap', array('function'=>$function)), array(time()-abs($period)), "genie/"); |
|
| 66 | 66 | |
| 67 | - // et on passe la main a la gestion de la queue ! |
|
| 68 | - // en forcant eventuellement les jobs ajoute a l'instant |
|
| 69 | - return queue_schedule(count($force_jobs)?$force_jobs:null); |
|
| 67 | + // et on passe la main a la gestion de la queue ! |
|
| 68 | + // en forcant eventuellement les jobs ajoute a l'instant |
|
| 69 | + return queue_schedule(count($force_jobs)?$force_jobs:null); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // |
@@ -80,33 +80,33 @@ discard block |
||
| 80 | 80 | // http://doc.spip.org/@taches_generales |
| 81 | 81 | function taches_generales($taches_generales = array()) { |
| 82 | 82 | |
| 83 | - // verifier que toutes les taches cron sont planifiees |
|
| 84 | - // c'est une tache cron ! |
|
| 85 | - $taches_generales['queue_watch'] = 3600*24; |
|
| 83 | + // verifier que toutes les taches cron sont planifiees |
|
| 84 | + // c'est une tache cron ! |
|
| 85 | + $taches_generales['queue_watch'] = 3600*24; |
|
| 86 | 86 | |
| 87 | - // MAJ des rubriques publiques (cas de la publication post-datee) |
|
| 88 | - // est fait au coup par coup a present |
|
| 89 | - // $taches_generales['rubriques'] = 3600; |
|
| 87 | + // MAJ des rubriques publiques (cas de la publication post-datee) |
|
| 88 | + // est fait au coup par coup a present |
|
| 89 | + // $taches_generales['rubriques'] = 3600; |
|
| 90 | 90 | |
| 91 | - // Optimisation de la base |
|
| 92 | - $taches_generales['optimiser'] = 3600*48; |
|
| 91 | + // Optimisation de la base |
|
| 92 | + $taches_generales['optimiser'] = 3600*48; |
|
| 93 | 93 | |
| 94 | - // cache (chaque 10 minutes => 1/16eme du repertoire cache, |
|
| 95 | - // soit toutes les 2h40 sur le meme rep) |
|
| 96 | - $taches_generales['invalideur'] = 600; |
|
| 94 | + // cache (chaque 10 minutes => 1/16eme du repertoire cache, |
|
| 95 | + // soit toutes les 2h40 sur le meme rep) |
|
| 96 | + $taches_generales['invalideur'] = 600; |
|
| 97 | 97 | |
| 98 | - // nouveautes |
|
| 99 | - if ($GLOBALS['meta']['adresse_neuf'] AND $GLOBALS['meta']['jours_neuf'] |
|
| 100 | - AND ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')) |
|
| 101 | - $taches_generales['mail']= 3600 * 24 * $GLOBALS['meta']['jours_neuf']; |
|
| 98 | + // nouveautes |
|
| 99 | + if ($GLOBALS['meta']['adresse_neuf'] AND $GLOBALS['meta']['jours_neuf'] |
|
| 100 | + AND ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')) |
|
| 101 | + $taches_generales['mail']= 3600 * 24 * $GLOBALS['meta']['jours_neuf']; |
|
| 102 | 102 | |
| 103 | - // maintenance (ajax, verifications diverses) |
|
| 104 | - $taches_generales['maintenance'] = 3600 * 2; |
|
| 103 | + // maintenance (ajax, verifications diverses) |
|
| 104 | + $taches_generales['maintenance'] = 3600 * 2; |
|
| 105 | 105 | |
| 106 | - // verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement) |
|
| 107 | - $taches_generales['mise_a_jour'] = 3*24*3600; |
|
| 106 | + // verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement) |
|
| 107 | + $taches_generales['mise_a_jour'] = 3*24*3600; |
|
| 108 | 108 | |
| 109 | - return pipeline('taches_generales_cron',$taches_generales); |
|
| 109 | + return pipeline('taches_generales_cron',$taches_generales); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // Pas de fichier a part pour une fonction aussi petite: |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | // http://doc.spip.org/@genie_invalideur_dist |
| 117 | 117 | function genie_invalideur_dist($t) { |
| 118 | 118 | |
| 119 | - include_spip('inc/invalideur'); |
|
| 120 | - $encore = appliquer_quota_cache(); |
|
| 119 | + include_spip('inc/invalideur'); |
|
| 120 | + $encore = appliquer_quota_cache(); |
|
| 121 | 121 | |
| 122 | - // si le cache est trop gonfle, redemander la main pour poursuivre |
|
| 123 | - if ($encore) |
|
| 124 | - return (0 - $t); |
|
| 125 | - return 1; |
|
| 122 | + // si le cache est trop gonfle, redemander la main pour poursuivre |
|
| 123 | + if ($encore) |
|
| 124 | + return (0 - $t); |
|
| 125 | + return 1; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -134,18 +134,18 @@ discard block |
||
| 134 | 134 | * @return int |
| 135 | 135 | */ |
| 136 | 136 | function genie_queue_watch_dist(){ |
| 137 | - static $deja_la = false; |
|
| 138 | - if ($deja_la) return; // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple) |
|
| 139 | - $deja_la = true; |
|
| 140 | - $taches = taches_generales(); |
|
| 141 | - $programmees = sql_allfetsel('fonction','spip_jobs',sql_in('fonction',array_keys($taches))); |
|
| 142 | - $programmees = array_map('reset',$programmees); |
|
| 143 | - foreach($taches as $tache=>$periode){ |
|
| 144 | - if (!in_array($tache,$programmees)) |
|
| 145 | - queue_genie_replan_job($tache,$periode,time()-round(rand(1,$periode)),0); |
|
| 146 | - } |
|
| 147 | - $deja_la = false; |
|
| 148 | - return 1; |
|
| 137 | + static $deja_la = false; |
|
| 138 | + if ($deja_la) return; // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple) |
|
| 139 | + $deja_la = true; |
|
| 140 | + $taches = taches_generales(); |
|
| 141 | + $programmees = sql_allfetsel('fonction','spip_jobs',sql_in('fonction',array_keys($taches))); |
|
| 142 | + $programmees = array_map('reset',$programmees); |
|
| 143 | + foreach($taches as $tache=>$periode){ |
|
| 144 | + if (!in_array($tache,$programmees)) |
|
| 145 | + queue_genie_replan_job($tache,$periode,time()-round(rand(1,$periode)),0); |
|
| 146 | + } |
|
| 147 | + $deja_la = false; |
|
| 148 | + return 1; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -166,22 +166,22 @@ discard block |
||
| 166 | 166 | * @return void |
| 167 | 167 | */ |
| 168 | 168 | function queue_genie_replan_job($function,$period,$last=0,$time=null, $priority=0){ |
| 169 | - static $done = array(); |
|
| 170 | - if (isset($done[$function])) return; |
|
| 171 | - $done[$function] = true; |
|
| 172 | - if (is_null($time)){ |
|
| 173 | - $time=time(); |
|
| 174 | - if ($last) |
|
| 175 | - $time = max($last+$period,$time); |
|
| 176 | - } |
|
| 177 | - if (!$last) |
|
| 178 | - $last = $time-$period; |
|
| 179 | - spip_log("replan_job $function $period $last $time $priority",'queue'); |
|
| 180 | - include_spip('inc/queue'); |
|
| 181 | - // on replanifie un job cron |
|
| 182 | - // uniquement si il n'y en a pas deja un avec le meme nom |
|
| 183 | - // independament de l'argument |
|
| 184 | - queue_add_job($function, _T('tache_cron_secondes', array('function'=>$function, 'nb'=>$period)), array($last), "genie/", 'function_only', $time, $priority); |
|
| 169 | + static $done = array(); |
|
| 170 | + if (isset($done[$function])) return; |
|
| 171 | + $done[$function] = true; |
|
| 172 | + if (is_null($time)){ |
|
| 173 | + $time=time(); |
|
| 174 | + if ($last) |
|
| 175 | + $time = max($last+$period,$time); |
|
| 176 | + } |
|
| 177 | + if (!$last) |
|
| 178 | + $last = $time-$period; |
|
| 179 | + spip_log("replan_job $function $period $last $time $priority",'queue'); |
|
| 180 | + include_spip('inc/queue'); |
|
| 181 | + // on replanifie un job cron |
|
| 182 | + // uniquement si il n'y en a pas deja un avec le meme nom |
|
| 183 | + // independament de l'argument |
|
| 184 | + queue_add_job($function, _T('tache_cron_secondes', array('function'=>$function, 'nb'=>$period)), array($last), "genie/", 'function_only', $time, $priority); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
@@ -16,69 +16,69 @@ |
||
| 16 | 16 | include_spip('base/objets'); |
| 17 | 17 | |
| 18 | 18 | function inc_icone_renommer_dist($fond,$fonction){ |
| 19 | - $size = 24; |
|
| 20 | - if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png))?$/i",$fond,$match) |
|
| 21 | - AND ((isset($match[0]) AND $match[0]) OR (isset($match[1]) AND $match[1]))) { |
|
| 22 | - if (isset($match[1]) AND $match[1]) { |
|
| 23 | - $size = $match[1]; |
|
| 24 | - } |
|
| 25 | - $type = substr($fond,0,-strlen($match[0])); |
|
| 26 | - if (!isset($match[2]) OR !$match[2]) { |
|
| 27 | - $fond .= ".png"; |
|
| 28 | - } |
|
| 29 | - } |
|
| 30 | - else { |
|
| 31 | - $type = $fond; |
|
| 32 | - $fond .= ".png"; |
|
| 33 | - } |
|
| 19 | + $size = 24; |
|
| 20 | + if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png))?$/i",$fond,$match) |
|
| 21 | + AND ((isset($match[0]) AND $match[0]) OR (isset($match[1]) AND $match[1]))) { |
|
| 22 | + if (isset($match[1]) AND $match[1]) { |
|
| 23 | + $size = $match[1]; |
|
| 24 | + } |
|
| 25 | + $type = substr($fond,0,-strlen($match[0])); |
|
| 26 | + if (!isset($match[2]) OR !$match[2]) { |
|
| 27 | + $fond .= ".png"; |
|
| 28 | + } |
|
| 29 | + } |
|
| 30 | + else { |
|
| 31 | + $type = $fond; |
|
| 32 | + $fond .= ".png"; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $rtl = false; |
|
| 36 | - if (preg_match(',[-_]rtl$,i',$type,$match)){ |
|
| 37 | - $rtl = true; |
|
| 38 | - $type = substr($type,0,-strlen($match[0])); |
|
| 39 | - } |
|
| 35 | + $rtl = false; |
|
| 36 | + if (preg_match(',[-_]rtl$,i',$type,$match)){ |
|
| 37 | + $rtl = true; |
|
| 38 | + $type = substr($type,0,-strlen($match[0])); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - // objet_type garde invariant tout ce qui ne commence par par id_, spip_ |
|
| 42 | - // et ne finit pas par un s, sauf si c'est une exception declaree |
|
| 43 | - $type = objet_type($type, false); |
|
| 41 | + // objet_type garde invariant tout ce qui ne commence par par id_, spip_ |
|
| 42 | + // et ne finit pas par un s, sauf si c'est une exception declaree |
|
| 43 | + $type = objet_type($type, false); |
|
| 44 | 44 | |
| 45 | - $dir = "images/"; |
|
| 46 | - $f = "$type-$size.png"; |
|
| 47 | - if ($icone = find_in_theme($dir.$f)){ |
|
| 48 | - $dir = dirname($icone); |
|
| 49 | - $fond = $icone; |
|
| 45 | + $dir = "images/"; |
|
| 46 | + $f = "$type-$size.png"; |
|
| 47 | + if ($icone = find_in_theme($dir.$f)){ |
|
| 48 | + $dir = dirname($icone); |
|
| 49 | + $fond = $icone; |
|
| 50 | 50 | |
| 51 | - if ($rtl |
|
| 52 | - AND $fr = "$type-rtl-$size.png" |
|
| 53 | - AND file_exists($dir.'/'.$fr)) |
|
| 54 | - $type = "$type-rtl"; |
|
| 51 | + if ($rtl |
|
| 52 | + AND $fr = "$type-rtl-$size.png" |
|
| 53 | + AND file_exists($dir.'/'.$fr)) |
|
| 54 | + $type = "$type-rtl"; |
|
| 55 | 55 | |
| 56 | - $action = $fonction; |
|
| 57 | - if ($action=="supprimer.gif"){ |
|
| 58 | - $action = "del"; |
|
| 59 | - } |
|
| 60 | - elseif ($action=="creer.gif"){ |
|
| 61 | - $action = "new"; |
|
| 62 | - } |
|
| 63 | - elseif ($action=="edit.gif"){ |
|
| 64 | - $action = "edit"; |
|
| 65 | - } |
|
| 66 | - if (!in_array($action,array('del','new','edit'))) |
|
| 67 | - $action = ""; |
|
| 68 | - if ($action){ |
|
| 69 | - if ($fa = "$type-$action-$size.png" |
|
| 70 | - AND file_exists($dir.'/'.$fa)){ |
|
| 71 | - $fond = $dir .'/'. $fa; |
|
| 72 | - $fonction = ""; |
|
| 73 | - } |
|
| 74 | - else { |
|
| 75 | - $fonction = "$action-$size.png"; |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - // c'est bon ! |
|
| 79 | - return array($fond,$fonction); |
|
| 80 | - } |
|
| 56 | + $action = $fonction; |
|
| 57 | + if ($action=="supprimer.gif"){ |
|
| 58 | + $action = "del"; |
|
| 59 | + } |
|
| 60 | + elseif ($action=="creer.gif"){ |
|
| 61 | + $action = "new"; |
|
| 62 | + } |
|
| 63 | + elseif ($action=="edit.gif"){ |
|
| 64 | + $action = "edit"; |
|
| 65 | + } |
|
| 66 | + if (!in_array($action,array('del','new','edit'))) |
|
| 67 | + $action = ""; |
|
| 68 | + if ($action){ |
|
| 69 | + if ($fa = "$type-$action-$size.png" |
|
| 70 | + AND file_exists($dir.'/'.$fa)){ |
|
| 71 | + $fond = $dir .'/'. $fa; |
|
| 72 | + $fonction = ""; |
|
| 73 | + } |
|
| 74 | + else { |
|
| 75 | + $fonction = "$action-$size.png"; |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + // c'est bon ! |
|
| 79 | + return array($fond,$fonction); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - return array($fond,$fonction); |
|
| 82 | + return array($fond,$fonction); |
|
| 83 | 83 | } |
| 84 | 84 | ?> |
@@ -13,84 +13,84 @@ |
||
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | 15 | function inc_log_dist($message, $logname=NULL, $logdir=NULL, $logsuf=NULL) { |
| 16 | - static $test_repertoire = array(); |
|
| 17 | - static $compteur = array(); |
|
| 18 | - static $debugverb = ""; // pour ne pas le recalculer au reappel |
|
| 19 | - global $nombre_de_logs, $taille_des_logs; |
|
| 20 | - |
|
| 21 | - if (is_null($logname) OR !is_string($logname)) |
|
| 22 | - $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 23 | - if (!isset($compteur[$logname])) $compteur[$logname] = 0; |
|
| 24 | - if ($logname != 'maj' |
|
| 25 | - AND defined('_MAX_LOG') |
|
| 26 | - AND ( |
|
| 27 | - $compteur[$logname]++ > _MAX_LOG |
|
| 28 | - OR !$nombre_de_logs |
|
| 29 | - OR !$taille_des_logs |
|
| 30 | - )) |
|
| 31 | - return; |
|
| 32 | - |
|
| 33 | - $logfile = ($logdir===NULL ? _DIR_LOG : $logdir) |
|
| 34 | - . ($logname) |
|
| 35 | - . ($logsuf===NULL ? _FILE_LOG_SUFFIX : $logsuf); |
|
| 36 | - |
|
| 37 | - if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 38 | - $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 39 | - $test_repertoire[$d] = (@is_dir($d)?true:(function_exists('sous_repertoire')?sous_repertoire($d, '', false, true):false)); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
|
| 43 | - if (!defined('_DIR_LOG') OR !$test_repertoire[$d]) |
|
| 44 | - $logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log'; |
|
| 45 | - |
|
| 46 | - $rotate = 0; |
|
| 47 | - $pid = '(pid '.@getmypid().')'; |
|
| 48 | - |
|
| 49 | - // accepter spip_log( Array ) |
|
| 50 | - if (!is_string($message)) $message = var_export($message, true); |
|
| 51 | - |
|
| 52 | - if (!$debugverb AND defined('_LOG_FILELINE') AND _LOG_FILELINE){ |
|
| 53 | - $debug = debug_backtrace(); |
|
| 54 | - $l = $debug[1]['line']; |
|
| 55 | - $fi = $debug[1]['file']; |
|
| 56 | - if (strncmp($fi,_ROOT_RACINE,strlen(_ROOT_RACINE))==0) |
|
| 57 | - $fi = substr($fi,strlen(_ROOT_RACINE)); |
|
| 58 | - $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
|
| 59 | - $debugverb = "$fi:L$l:$fu"."():"; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - $m = date("Y-m-d H:i:s").' '.$GLOBALS['ip'].' '.$pid.' ' |
|
| 63 | - //distinguer les logs prives et publics dans les grep |
|
| 64 | - . $debugverb |
|
| 65 | - . (test_espace_prive()?':Pri:':':Pub:') |
|
| 66 | - .preg_replace("/\n*$/", "\n", $message); |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - if (@is_readable($logfile) |
|
| 70 | - AND (!$s = @filesize($logfile) OR $s > $taille_des_logs * 1024)) { |
|
| 71 | - $rotate = $nombre_de_logs; |
|
| 72 | - $m .= "[-- rotate --]\n"; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - $f = @fopen($logfile, "ab"); |
|
| 76 | - if ($f) { |
|
| 77 | - fputs($f, (defined('_LOG_BRUT') AND _LOG_BRUT) ? $m : str_replace('<','<',$m)); |
|
| 78 | - fclose($f); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ($rotate-- > 0 |
|
| 82 | - AND function_exists('spip_unlink')) { |
|
| 83 | - spip_unlink($logfile . '.' . $rotate); |
|
| 84 | - while ($rotate--) { |
|
| 85 | - @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - // Dupliquer les erreurs specifiques dans le log general |
|
| 90 | - if ($logname !== _FILE_LOG |
|
| 91 | - AND defined('_FILE_LOG')) |
|
| 92 | - inc_log_dist($logname=='maj' ? 'cf maj.log' : $message); |
|
| 93 | - $debugverb = ""; |
|
| 16 | + static $test_repertoire = array(); |
|
| 17 | + static $compteur = array(); |
|
| 18 | + static $debugverb = ""; // pour ne pas le recalculer au reappel |
|
| 19 | + global $nombre_de_logs, $taille_des_logs; |
|
| 20 | + |
|
| 21 | + if (is_null($logname) OR !is_string($logname)) |
|
| 22 | + $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 23 | + if (!isset($compteur[$logname])) $compteur[$logname] = 0; |
|
| 24 | + if ($logname != 'maj' |
|
| 25 | + AND defined('_MAX_LOG') |
|
| 26 | + AND ( |
|
| 27 | + $compteur[$logname]++ > _MAX_LOG |
|
| 28 | + OR !$nombre_de_logs |
|
| 29 | + OR !$taille_des_logs |
|
| 30 | + )) |
|
| 31 | + return; |
|
| 32 | + |
|
| 33 | + $logfile = ($logdir===NULL ? _DIR_LOG : $logdir) |
|
| 34 | + . ($logname) |
|
| 35 | + . ($logsuf===NULL ? _FILE_LOG_SUFFIX : $logsuf); |
|
| 36 | + |
|
| 37 | + if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 38 | + $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 39 | + $test_repertoire[$d] = (@is_dir($d)?true:(function_exists('sous_repertoire')?sous_repertoire($d, '', false, true):false)); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
|
| 43 | + if (!defined('_DIR_LOG') OR !$test_repertoire[$d]) |
|
| 44 | + $logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log'; |
|
| 45 | + |
|
| 46 | + $rotate = 0; |
|
| 47 | + $pid = '(pid '.@getmypid().')'; |
|
| 48 | + |
|
| 49 | + // accepter spip_log( Array ) |
|
| 50 | + if (!is_string($message)) $message = var_export($message, true); |
|
| 51 | + |
|
| 52 | + if (!$debugverb AND defined('_LOG_FILELINE') AND _LOG_FILELINE){ |
|
| 53 | + $debug = debug_backtrace(); |
|
| 54 | + $l = $debug[1]['line']; |
|
| 55 | + $fi = $debug[1]['file']; |
|
| 56 | + if (strncmp($fi,_ROOT_RACINE,strlen(_ROOT_RACINE))==0) |
|
| 57 | + $fi = substr($fi,strlen(_ROOT_RACINE)); |
|
| 58 | + $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
|
| 59 | + $debugverb = "$fi:L$l:$fu"."():"; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + $m = date("Y-m-d H:i:s").' '.$GLOBALS['ip'].' '.$pid.' ' |
|
| 63 | + //distinguer les logs prives et publics dans les grep |
|
| 64 | + . $debugverb |
|
| 65 | + . (test_espace_prive()?':Pri:':':Pub:') |
|
| 66 | + .preg_replace("/\n*$/", "\n", $message); |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + if (@is_readable($logfile) |
|
| 70 | + AND (!$s = @filesize($logfile) OR $s > $taille_des_logs * 1024)) { |
|
| 71 | + $rotate = $nombre_de_logs; |
|
| 72 | + $m .= "[-- rotate --]\n"; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + $f = @fopen($logfile, "ab"); |
|
| 76 | + if ($f) { |
|
| 77 | + fputs($f, (defined('_LOG_BRUT') AND _LOG_BRUT) ? $m : str_replace('<','<',$m)); |
|
| 78 | + fclose($f); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ($rotate-- > 0 |
|
| 82 | + AND function_exists('spip_unlink')) { |
|
| 83 | + spip_unlink($logfile . '.' . $rotate); |
|
| 84 | + while ($rotate--) { |
|
| 85 | + @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + // Dupliquer les erreurs specifiques dans le log general |
|
| 90 | + if ($logname !== _FILE_LOG |
|
| 91 | + AND defined('_FILE_LOG')) |
|
| 92 | + inc_log_dist($logname=='maj' ? 'cf maj.log' : $message); |
|
| 93 | + $debugverb = ""; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | ?> |