diff --git a/ecrire/articles.php3 b/ecrire/articles.php3 index d593ab5802d04e4e71d1ec0aa5a6e6d868e8dab0..352ba3b13a05094028a87a7b857a08b56d049a66 100644 --- a/ecrire/articles.php3 +++ b/ecrire/articles.php3 @@ -35,8 +35,7 @@ if ($id_article==0) { spip_query("DELETE FROM spip_auteurs_articles WHERE id_article = $id_article"); spip_query("INSERT INTO spip_auteurs_articles (id_auteur, id_article) VALUES ($connect_id_auteur, $id_article)"); } else { - @header("Location: ./index.php3"); - exit; + redirige_par_entete("./index.php3"); } } diff --git a/ecrire/auteur_infos.php3 b/ecrire/auteur_infos.php3 index 1d2bcd622da9a63061e2abcabd68bceea3c66669..3b3ba546f5c283803c491fd7211187955c47071d 100644 --- a/ecrire/auteur_infos.php3 +++ b/ecrire/auteur_infos.php3 @@ -217,14 +217,7 @@ if ($statut) { // si on poste un statut, c'est qu'on modifie une fiche auteur // Redirection if (!$echec AND $redirect_ok == "oui") { - if ($redirect) { - @Header("Location: ".rawurldecode($redirect)); - exit; - } - else { - @Header("Location:auteurs_edit.php3?id_auteur=$id_auteur"); - exit; - } + redirige_par_entete($redirect ? rawurldecode($redirect) : "auteurs_edit.php3?id_auteur=$id_auteur"); } diff --git a/ecrire/breves.php3 b/ecrire/breves.php3 index 479683fb44314ce0e2d799f905cb0a654ffadd49..3f01efd549df43d3caba6a832ed59fa739c37a9e 100644 --- a/ecrire/breves.php3 +++ b/ecrire/breves.php3 @@ -6,8 +6,7 @@ if ($statut AND $connect_statut == "0minirezo") { $query="UPDATE spip_breves SET date_heure=NOW(), statut=\"$statut\" WHERE id_breve=$id_breve"; $result=spip_query($query); calculer_rubriques(); - - @header("Location:breves.php3"); + redirige_par_entete("breves.php3"); } diff --git a/ecrire/forum_envoi.php3 b/ecrire/forum_envoi.php3 index 532f0aa63546ed17dc08ad2c87c8e62410efca5a..ed7b88e05ad316d2e7478274d6a8bbf368963603 100644 --- a/ecrire/forum_envoi.php3 +++ b/ecrire/forum_envoi.php3 @@ -24,8 +24,7 @@ if ($valider_forum AND ($statut!='')) { $result = spip_query($query); } - @header("Location: $adresse_retour"); - die(); + redirige_par_entete($adresse_retour); } if ($id_message) debut_page(_T('titre_page_forum_envoi'), "asuivre", "messagerie"); diff --git a/ecrire/import_all.php3 b/ecrire/import_all.php3 index 3a51e8c20fcb5e2de873193d1dce5d6100e06118..4ec5bcfc0e3c17fcb9c93f532845a0a51301d3ba 100644 --- a/ecrire/import_all.php3 +++ b/ecrire/import_all.php3 @@ -49,8 +49,5 @@ ecrire_metas(); fin_admin($action); -@header("Location: index.php3"); - -exit; - +redirige_par_entete("index.php3"); ?> diff --git a/ecrire/inc.php3 b/ecrire/inc.php3 index 8c7196436084a0e876b11c2f435fc4a19cd25921..7a0b18ad41be0f7f589ab59f03a08d42c69a926d 100644 --- a/ecrire/inc.php3 +++ b/ecrire/inc.php3 @@ -7,8 +7,7 @@ if (!defined('_FILE_CONNECT')) (@file_exists("inc_connect.php3") ? "inc_connect.php3" : '')); if (!_FILE_CONNECT) { - header("Location: install.php3"); - exit; + redirige_par_entete("install.php3"); } if (!defined('_ECRIRE_INC_VERSION')) { include ("inc_version.php3"); } diff --git a/ecrire/inc_acces.php3 b/ecrire/inc_acces.php3 index 49fbaaea3b6fd9ebacec26b847a9aa71962f3ccc..04c1f15554d12b5ec93a0ccf2556b20621cd6612 100644 --- a/ecrire/inc_acces.php3 +++ b/ecrire/inc_acces.php3 @@ -10,7 +10,8 @@ function creer_pass_aleatoire($longueur = 8, $sel = "") { $seed = (double) (microtime() + 1) * time(); mt_srand($seed); srand($seed); - + $s = ''; + $pass = ''; for ($i = 0; $i < $longueur; $i++) { if (!$s) { $s = mt_rand(); @@ -106,8 +107,7 @@ function ecrire_acces() { ecrire_logins($fichier, $logins); fclose($fichier); } else { - @header ("Location: ../spip_test_dirs.php3"); - exit; + redirige_par_entete("../spip_test_dirs.php3"); } $query = "SELECT login, htpass FROM spip_auteurs WHERE statut = '0minirezo'"; diff --git a/ecrire/inc_auth.php3 b/ecrire/inc_auth.php3 index b412a91cd7343eb744c3b97e1c70c611a82e7d39..e5b1d00b5059f58401b35a8fb4ac0fa9dce84154 100644 --- a/ecrire/inc_auth.php3 +++ b/ecrire/inc_auth.php3 @@ -107,15 +107,13 @@ function auth() { $clean_link->delVar('bonjour'); $url = str_replace('/./', '/', 'ecrire/'.$clean_link->getUrl()); $link->addVar('var_url', $url); - @header("Location: ".$link->getUrl()); - exit; + redirige_par_entete($link->getUrl()); } // Si pas authentifie, demander login / mdp if (!$auth_login) { $url = str_replace('/./', '/', 'ecrire/'.$clean_link->getUrl()); - @header("Location: ../spip_login.php3?var_url=".urlencode($url)); - exit; + redirige_par_entete(" ../spip_login.php3?var_url=".urlencode($url)); } // diff --git a/ecrire/inc_config.php3 b/ecrire/inc_config.php3 index 8478b78f9c0b97d63a1eb23f6986acb36bb1dec5..aeb6fc4f85a32f5f6f96b1c59bfdd035be6e733f 100644 --- a/ecrire/inc_config.php3 +++ b/ecrire/inc_config.php3 @@ -286,8 +286,10 @@ function appliquer_modifs_config() { } if ($purger_skel) { - $hash = calculer_action_auteur("purger_squelettes"); - @header ("Location:../spip_cache.php3?purger_squelettes=oui&id_auteur=$connect_id_auteur&hash=$hash&redirect=".urlencode($clean_link->getUrl())); + redirige_par_entete("../spip_cache.php3?purger_squelettes=oui&id_auteur=$connect_id_auteur&hash=" . + calculer_action_auteur("purger_squelettes") . + "&redirect=". + urlencode($clean_link->getUrl())); } } diff --git a/ecrire/inc_lang.php3 b/ecrire/inc_lang.php3 index 2449a1ca664b726c013ab1dc70ef42a606f92d5b..bec480a401383237ba5674b180a58a365b514962 100644 --- a/ecrire/inc_lang.php3 +++ b/ecrire/inc_lang.php3 @@ -510,8 +510,7 @@ function verifier_lang_url() { $destination->addvar('lang', $lang_demandee); if ($GLOBALS['recalcul'] == 'oui') $destination->addvar('recalcul', 'oui'); - @header("Location: ".$destination->getUrl()); - exit; + calculer_action_auteur($destination->getUrl()); } // Subtilite : si la langue demandee par cookie est la bonne diff --git a/ecrire/inc_session.php3 b/ecrire/inc_session.php3 index 6adc4091fa260cea9dfe19f8591a265707a27793..12ec9c71e17eb623e00c1bed586d891a854fd707 100644 --- a/ecrire/inc_session.php3 +++ b/ecrire/inc_session.php3 @@ -52,9 +52,8 @@ function ajouter_session($auteur, $id_session) { fputs($f, $texte); fclose($f); } else { - $dir = $GLOBALS['flag_ecrire'] ? '../' : ''; - @header("Location: ${dir}spip_test_dirs.php3"); - exit; + redirige_par_entete((_DIR_RESTREINT ? "" : "../") . + "spip_test_dirs.php3"); } } diff --git a/ecrire/inc_version.php3 b/ecrire/inc_version.php3 index b9b294edba686e54a1d0787521f16083eff2576b..00cfa1e81f6ecfa1113b3c9851dea4986b9d6ea5 100644 --- a/ecrire/inc_version.php3 +++ b/ecrire/inc_version.php3 @@ -220,14 +220,15 @@ $flag_ecrire = !@file_exists('./ecrire/inc_version.php3'); define_once('_DIR_RESTREINT', (!@is_dir('ecrire') ? "" : "ecrire/")); -// essai d'un SPip multi-site. Exp�rimental. +/* bientot if ($d = ($GLOBALS['HTTP_GET_VARS']['var_install'])) { $d = substr($d,0,strrpos($d,'/')+1); define('_DIR_PREFIX1', $d); define('_DIR_PREFIX2', $d); - } else { + } else */ +{ define('_DIR_PREFIX1', (_DIR_RESTREINT ? "" : "../")); define('_DIR_PREFIX2', _DIR_RESTREINT); } @@ -1138,6 +1139,30 @@ function cherche_image_nommee($nom, $formats = array ('gif', 'jpg', 'png')) { } } +// Gestion des taches de fond ? toutes les 5 secondes +// (on mettra 30 s quand on aura prevu la preemption par une image-cron) +function taches_de_fond() { + + verifier_htaccess(_DIR_SESSIONS); + if (!@file_exists(_FILE_CRON_LOCK) + OR (time() - @filemtime(_FILE_CRON_LOCK) > 5)) { + + // Si MySQL est out, laisser souffler + if (!@file_exists(_FILE_MYSQL_OUT) + OR (time() - @filemtime(_FILE_MYSQL_OUT) > 300)) { + include_ecrire('inc_cron.php3'); + spip_cron(); + } + } +} + +function redirige_par_entete($url) +{ + header("Location: $url"); + taches_de_fond(); + exit; +} + // Envoi des en-tetes function debut_entete($title) diff --git a/ecrire/install.php3 b/ecrire/install.php3 index 176ab3dd9ef2a4976c67ba24bcbd2fc308540685..f1fa68037394a938c2c91b68840c97d1f0244e6f 100644 --- a/ecrire/install.php3 +++ b/ecrire/install.php3 @@ -356,11 +356,12 @@ else if ($etape == 1) { } else if ($etape == 'dirs') { - header("Location: ../spip_test_dirs.php3"); + redirige_par_entete(" ../spip_test_dirs.php3"); } else if (!$etape) { $menu_langues = menu_langues('var_lang_ecrire'); - if (!$menu_langues) header("Location: ../spip_test_dirs.php3"); + if (!$menu_langues) + redirige_par_entete(" ../spip_test_dirs.php3"); else { install_debut_html(); diff --git a/ecrire/mots_edit.php3 b/ecrire/mots_edit.php3 index 2349a13ca6202f18ae82c5e33828010bcf70c03c..04b1ef3e343f584221e04cad98218e24409acf09 100644 --- a/ecrire/mots_edit.php3 +++ b/ecrire/mots_edit.php3 @@ -70,8 +70,7 @@ if ($connect_statut == '0minirezo') { // redirection ou affichage // if ($redirect_ok == 'oui' && $redirect) { - @header("Location: ".rawurldecode($redirect)); - exit; + redirige_par_entete(rawurldecode($redirect)); } // diff --git a/ecrire/mots_tous.php3 b/ecrire/mots_tous.php3 index 7ba43bc2b7c709b330e3ea0e348ec4068a3299c9..77499ca0dd71af06d79f0ecf52088114ec50a2d5 100644 --- a/ecrire/mots_tous.php3 +++ b/ecrire/mots_tous.php3 @@ -36,8 +36,7 @@ if ($conf_mot>0) { $nb_sites = $nb_sites[0]; if ($nb_articles + $nb_breves + $nb_sites == 0) { - header("Location: mots_edit.php3?supp_mot=$id_mot&redirect_ok=oui&redirect=mots_tous.php3"); - exit(); + redirige_par_entete("mots_edit.php3?supp_mot=$id_mot&redirect_ok=oui&redirect=mots_tous.php3"); } // else traite plus loin } } diff --git a/ecrire/sites.php3 b/ecrire/sites.php3 index ab0fa1b565a2b1ae2362d8891bc5dc60fc7a58f8..ad8db96bf7981a3f585cf052e2e581b99bb87997 100644 --- a/ecrire/sites.php3 +++ b/ecrire/sites.php3 @@ -193,7 +193,7 @@ if ($jour AND $flag_administrable) { if ($redirect AND $redirect_ok == 'oui') { - @header("Location: $redirect"); + redirige_par_entete($redirect); } diff --git a/inc-login.php3 b/inc-login.php3 index 32ae6aa8761120874879c037be683f4667d27c9a..494f134414c20e0d96f2b50824ee9baab494f636 100644 --- a/inc-login.php3 +++ b/inc-login.php3 @@ -23,8 +23,7 @@ function auth_http($cible, $essai_auth_http) { ask_php_auth($page_erreur); } else - @header("Location: " . $cible->getUrl() ); - exit; + redirige_par_entete($cible->getUrl()); } // si demande logout auth_http else if ($essai_auth_http == 'logout') { @@ -91,7 +90,7 @@ function login($cible, $prive = 'prive', $message_login='') { if ($auteur_session AND !$logout AND ($auteur_session['statut']=='0minirezo' OR $auteur_session['statut']=='1comite')) { if ($url != $GLOBALS['clean_link']->getUrl()) - @Header("Location: $url"); + redirige_par_entete($url); echo "<a href='$url'>"._T('login_par_ici')."</a>\n"; return; } diff --git a/inc-public-global.php3 b/inc-public-global.php3 index ff8ca4b36bf14c861cc2dc7c55d9a385ee3cd50c..19d180d7c7f9d0b54306969a8c0d3b1379a4a0e1 100644 --- a/inc-public-global.php3 +++ b/inc-public-global.php3 @@ -281,26 +281,4 @@ function admin_page($cached, $texte) { } return false; // pas de boutons admin } - - -// Gestion des taches de fond ? toutes les 5 secondes -// (on mettra 30 s quand on aura prevu la preemption par une image-cron) -function taches_de_fond() { - - verifier_htaccess(_DIR_SESSIONS); - if (!@file_exists(_FILE_CRON_LOCK) - OR (time() - @filemtime(_FILE_CRON_LOCK) > 5)) { - - // Si MySQL est out, laisser souffler - if (!@file_exists(_FILE_MYSQL_OUT) - OR (time() - @filemtime(_FILE_MYSQL_OUT) > 300)) { -# spip_log("cron"); - include_ecrire('inc_cron.php3'); - - spip_cron(); - } - } -} - - ?> diff --git a/inc-public.php3 b/inc-public.php3 index ab0243fd40b39e91c0e02e81dc1e91a9fe454561..558b0921bcbc8eb8a03c73ea8ac3a296484b2d60 100644 --- a/inc-public.php3 +++ b/inc-public.php3 @@ -64,10 +64,7 @@ else { if ($ajout_forum) { $redirect = ''; include('inc-messforum.php3'); - if ($redirect) { - @header("Location: $redirect"); - exit(); - } + if ($redirect) redirige_par_entete($redirect); } if ($val_confirm) { // il nous faut id_article ! C'est donc encore a nettoyer... @@ -110,7 +107,6 @@ else { @Header ("Last-Modified: ".http_gmoddate($lastmodified)." GMT"); // si le squelette est nul se rabattre sur l'entete standard - spip_log("Page: " . $page['texte']); if ($page['texte']) @header("Content-Type: text/html; charset=".lire_meta('charset')); else echo debut_entete($fond); diff --git a/spip_cache.php3 b/spip_cache.php3 index 53a6b18c754adfb7bbf0ac7e8d45432598ce20b3..4658ec486cfef8b292d88cc7f52def8fe23f8ea2 100644 --- a/spip_cache.php3 +++ b/spip_cache.php3 @@ -15,7 +15,6 @@ if ($purger_squelettes == "oui") { if (verifier_action_auteur("purger_squelettes", $hash, $id_auteur)) purger_squelettes(); } - -@header ("Location: ./ecrire/" . $redirect); +redirige_par_entete("./ecrire/" . $redirect); ?> diff --git a/spip_cookie.php3 b/spip_cookie.php3 index a5c3440443f3bb30b0d758dbd82dcfffefbd48ce..1f01af104dd7ce92e2f49bfea901df5cade52b40 100644 --- a/spip_cookie.php3 +++ b/spip_cookie.php3 @@ -62,11 +62,7 @@ if ($logout) { unset ($auteur_session); } - if (!$url) // ecrire - @Header("Location: ./spip_login.php3"); - else - @Header("Location: $url"); - exit; + redirige_par_entete($url ? $url : "./spip_login.php3"); } @@ -77,8 +73,7 @@ if ($test_echec_cookie == 'oui') { spip_setcookie('spip_session', 'test_echec_cookie'); $link = new Link("spip_login.php3?var_echec_cookie=oui"); $link->addVar("var_url", $cible->getUrl()); - @header("Location: ".$link->getUrl()); - exit; + redirige_par_entete($link->getUrl()); } // Tentative de login @@ -203,7 +198,7 @@ if ($var_lang_ecrire) { // Sous Apache, les cookies avec une redirection fonctionnent // Sinon, on fait un refresh HTTP if (ereg("^Apache", $SERVER_SOFTWARE)) { - @header("Location: " . $cible->getUrl()); + redirige_par_entete($cible->getUrl()); } else { @header("Refresh: 0; url=" . $cible->getUrl()); diff --git a/spip_image.php3 b/spip_image.php3 index 7d876749f14f215249ea46552c226ee81d39cbe6..6219639ee447a2d84ef9e1f5605d3a5caf8420a7 100644 --- a/spip_image.php3 +++ b/spip_image.php3 @@ -137,8 +137,8 @@ function deplacer_fichier_upload($source, $dest) { if ($f) fclose ($f); else { - @header ("Location: spip_test_dirs.php3?test_dir=".dirname($dest)); - exit; + redirige_par_entete("spip_test_dirs.php3?test_dir=". + dirname($dest)); } @unlink($dest); @@ -646,9 +646,5 @@ if (!$redirect) { $redirect = $link->getUrl(); } -header("Location: $redirect"); -# QQ trucs a v�rifier avant de lancer �a: -#header("Connection: close"); -#taches_de_fond(); - +redirige_par_entete($redirect); ?> diff --git a/spip_image_reduite.php3 b/spip_image_reduite.php3 index 273c33c88017579672a7caaebeae49301ae170e8..d8c9590f88828aa62f5ad0c753e68887992bbdf7 100644 --- a/spip_image_reduite.php3 +++ b/spip_image_reduite.php3 @@ -34,7 +34,7 @@ if (eregi("(.*)\.(jpg|gif|png)$", $logo, $regs)) { // header("Content-type: image/$format"); // echo implode ('', file ($retour)); - header("Location: $retour"); + redirige_par_entete($retour); } } diff --git a/spip_test_dirs.php3 b/spip_test_dirs.php3 index fc15a3e13cc92dc5455db27efeb5c08964c1d7ec..4d6e65d52bc7823e3826dc456a0e99322d827c25 100644 --- a/spip_test_dirs.php3 +++ b/spip_test_dirs.php3 @@ -93,10 +93,9 @@ if ($bad_dirs OR $absent_dirs) { install_fin_html(); } else { - if (!_FILE_CONNECT) - header("Location: ./ecrire/install.php3?etape=1"); - else - header("Location: ./ecrire/"); + redirige_par_entete(_FILE_CONNECT ? + "./ecrire/" : + "./ecrire/install.php3?etape=1"); } ?>