use sesion_write_close before redirects ... should solve some login problems user...
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 14 Nov 2005 23:24:12 +0000 (23:24 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 14 Nov 2005 23:24:12 +0000 (23:24 +0000)
see http://fr2.php.net/manual/en/function.session-write-close.php

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@154 839d8a87-29fc-0310-9880-83ba4fa771e5

50 files changed:
ChangeLog
htdocs.net/admin.php
htdocs.net/fiche.php
htdocs.net/groupe/alias-admin.php
htdocs.net/groupe/alias-create.php
htdocs.net/groupe/asso.php
htdocs.net/groupe/edit.php
htdocs.net/groupe/evt-admin.php
htdocs.net/groupe/evt-detail.php
htdocs.net/groupe/listes-admin.php
htdocs.net/groupe/listes-archives.php
htdocs.net/groupe/listes-check.php
htdocs.net/groupe/listes-create.php
htdocs.net/groupe/listes-delete.php
htdocs.net/groupe/listes-members.php
htdocs.net/groupe/listes-moderate.php
htdocs.net/groupe/listes-options.php
htdocs.net/groupe/listes-soptions.php
htdocs.net/groupe/listes-sync.php
htdocs.net/groupe/listes.php
htdocs.net/groupe/membres-edit.php
htdocs.net/groupes.php
htdocs.net/login.php
htdocs/admin/newsletter.php
htdocs/admin/newsletter_edit.php
htdocs/admin/utilisateurs.php
htdocs/auth-groupex.php
htdocs/auth-redirect.php
htdocs/carnet/panel.php
htdocs/clear_all_cache.php
htdocs/exit.php
htdocs/index.php
htdocs/inscription/step4.php
htdocs/listes/admin.php
htdocs/listes/archives.php
htdocs/listes/check.php
htdocs/listes/delete.php
htdocs/listes/index.php
htdocs/listes/members.php
htdocs/listes/moderate.php
htdocs/listes/options.php
htdocs/listes/soptions.php
htdocs/listes/trombi.php
htdocs/preferences.php
htdocs/register/end.php
htdocs/skins.php
include/banana.inc.php
include/xnet/session.inc.php
include/xorg.inc.php
scripts/webredirect.php

index 6fbff4d..109a44d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@ VERSION 0.9.9                                                        ?? Oct 2005
 
 New :
 
+    * Core :
+        - HTTP redirection safe wrt Session (should solve login problems).  -MC
+
     * Documentation :
         - Documentation now use Wiki                                        -Car
 
index f8a928e..8d7c59d 100644 (file)
@@ -39,7 +39,7 @@
 
     if (Post::has('diminutif')) {
         $globals->xdb->query('INSERT INTO groupex.asso (id,diminutif) VALUES(NULL,{?})', Post::get('diminutif'));
-        header('Location: '.Post::get('diminutif').'/edit.php');
+        redirect(Post::get('diminutif').'/edit.php');
     }
 
     $res = $globals->xdb->query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
index b4ea8c8..426a7fa 100644 (file)
@@ -1,3 +1,3 @@
 <?php
-    header("Location: https://www.polytechnique.org/fiche.php?user=".$_GET['user']);
+    redirect("https://www.polytechnique.org/fiche.php?user=".$_GET['user']);
 ?>
index 26dcab5..3891fe5 100644 (file)
@@ -4,7 +4,7 @@ require 'xnet.inc.php';
 new_groupadmin_page('xnet/groupe/alias-admin.tpl');
 
 if (!Get::has('liste')) {
-    header("Location: listes.php");
+    redirect("listes.php");
 }
 
 $lfull = strtolower(Get::get('liste'));
@@ -50,7 +50,7 @@ if (Env::has('del_member')) {
                    USING  x4dat.virtual_redirect
               INNER JOIN  x4dat.virtual USING(vid)
                    WHERE  redirect={?} AND alias={?}", Env::get('del_member'), $lfull);
-    header("Location: ?liste=$lfull");
+    redirect("?liste=$lfull");
 }
 
 $res = $globals->xdb->iterator(
index b41d86d..a72b2d9 100644 (file)
@@ -20,7 +20,7 @@ if(Post::has('submit')) {
     }
   
     $globals->xdb->query('INSERT INTO x4dat.virtual (alias,type) VALUES({?}, "user")', $new);
-    header("Location: alias-admin.php?liste=$new");
+    redirect("alias-admin.php?liste=$new");
 }
 
 $page->run();
index c18f483..39be21f 100644 (file)
@@ -10,7 +10,7 @@ $page->assign('logged', logged());
 
 $page->assign('asso', $globals->asso());
 if (!$globals->asso('id')) {
-    header("Location: ../");
+    redirect("../");
 }
 
 $page->run();
index 2532521..140def7 100644 (file)
@@ -34,7 +34,7 @@
             $globals->xdb->execute('UPDATE groupex.asso SET logo={?}, logo_mime={?} WHERE id={?}', $logo, $mime, $globals->asso('id'));
         }
 
-        header('Location: ../'.Post::get('diminutif', $globals->asso('diminutif')).'/edit.php');
+        redirect('../'.Post::get('diminutif', $globals->asso('diminutif')).'/edit.php');
     }
 
     if (has_perms()) {
index ed42b49..3894e40 100644 (file)
@@ -8,26 +8,28 @@ require_once('xnet/evenements.php');
 $evt = get_event_detail(Env::get('eid'), Env::get('item_id'));
 
 // the event doesn't exist or doesn't belong to this assoif (!$evt)
-if (!$evt)
-       header("Location: evenements.php");
+if (!$evt) {
+       redirect("evenements.php");
+}
 
-if ($evt['show_participants'])
-       new_group_page('xnet/groupe/evt-admin.tpl');
-else
-       new_groupadmin_page('xnet/groupe/evt-admin.tpl');
+if ($evt['show_participants']) {
+    new_group_page('xnet/groupe/evt-admin.tpl');
+} else {
+    new_groupadmin_page('xnet/groupe/evt-admin.tpl');
+}
 
 $admin = may_update();
 
 // select a member from his mail
 if ($admin && Env::get('adm') && Env::get('mail')) {
-       if (strpos(Env::get('mail'), '@') === false)
-       $res = $globals->xdb->query(
-               "SELECT m.uid
-                  FROM groupex.membres AS m
-            INNER JOIN aliases AS a ON (a.id = m.uid)
-                 WHERE a.alias = {?}",
-               Env::get('mail'));
-       else
+    if (strpos(Env::get('mail'), '@') === false) {
+        $res = $globals->xdb->query(
+                "SELECT m.uid
+                   FROM groupex.membres AS m
+             INNER JOIN aliases AS a ON (a.id = m.uid)
+                  WHERE a.alias = {?}",
+                Env::get('mail'));
+    } else {
        $res = $globals->xdb->query(
                "SELECT m.uid
                   FROM groupex.membres AS m
@@ -35,6 +37,7 @@ if ($admin && Env::get('adm') && Env::get('mail')) {
                Env::get('mail'), $globals->asso('id'));
        $member = $res->fetchOneCell();
        if (!$member) $page->trig("Membre introuvable");
+    }
 }
 
 // change the price paid by a participant
index eeabdeb..f36c702 100644 (file)
@@ -4,8 +4,9 @@ require_once 'xnet.inc.php';
 
 new_group_page('xnet/groupe/evt-detail.tpl');
 
-if (!Env::get("eid"))
-    header("Location: evenements.php");
+if (!Env::get("eid")) {
+    redirect("evenements.php");
+}
 
 $may_participate = !$members_only || is_member() || may_update(); 
 $page->assign('may_participate', $may_participate);
@@ -48,12 +49,13 @@ if (Env::get('ins')) {
 require_once('xnet/evenements.php');
 $evt = get_event_detail(Env::get('eid'));
 
-if (!$evt)
-    header("Location: evenements.php");
+if (!$evt) {
+    redirect("evenements.php");
+}
     
 if (Env::has('ins')) {
     subscribe_lists_event($participate, Session::get("uid"), $evt['participant_list'], $evt['absent_list']);
-    header("Location: evenements.php?backfrom=".Env::get('eid'));
+    redirect("evenements.php?backfrom=".Env::get('eid'));
 }
 
 $page->assign('participate', $participate);
index 86478bd..8c988bb 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 require_once 'xnet.inc.php';
-if (!Env::has('liste')) header('Location: listes.php');
+if (!Env::has('liste')) redirect('listes.php');
 $liste  = strtolower(Env::get('liste'));
 $domain = $globals->asso('mail_domain');
 
index e7fab8f..714ff48 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 require_once 'xnet.inc.php';
-if (!Env::has('liste')) header('Location: listes.php');
+if (!Env::has('liste')) redirect('listes.php');
 $liste  = strtolower(Env::get('liste'));
 $domain = $globals->asso('mail_domain');
 
index e44827c..a741113 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 require_once 'xnet.inc.php';
-if (!Env::has('liste')) header('Location: index.php');
+if (!Env::has('liste')) redirect('index.php');
 $liste = strtolower(Env::get('liste'));
 
 new_groupadmin_page('listes/check.tpl');
index 7bb3af8..7934c0b 100644 (file)
@@ -43,7 +43,7 @@ if (Post::has('submit')) {
         $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+admin@listes.polytechnique.org");
         $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})',              $liste.'-bounces@'.$dom, 'list');
         $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+bounces@listes.polytechnique.org");
-        header("Location: listes-admin.php?liste=$liste");
+        redirect("listes-admin.php?liste=$liste");
     } else {
         $page->kill("Un problème est survenu, contacter <a href='mailto:support@m4x.org'>support@m4x.org</a>");
     }
index aed95c7..77e45ee 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 require_once 'xnet.inc.php';
-if (!Env::has('liste')) header('Location: listes.php');
+if (!Env::has('liste')) redirect('listes.php');
 $liste = strtolower(Env::get('liste'));
 
 new_group_page('listes/delete.tpl');
index 562ca36..4946487 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 require_once 'xnet.inc.php';
-if (!Env::has('liste')) header('Location: listes.php');
+if (!Env::has('liste')) redirect('listes.php');
 $liste = strtolower(Env::get('liste'));
 
 new_group_page('listes/members.tpl');
index a5b2ff3..09fd775 100644 (file)
  ***************************************************************************/
 
 require_once 'xnet.inc.php';
-if (!Env::has('liste')) header('Location: listes.php');
+if (!Env::has('liste')) redirect('listes.php');
 $liste  = strtolower(Env::get('liste'));
 $domain = $globals->asso('mail_domain');
 
 if (preg_match("!(?:[a-z0-9]+\\.)?{".$globals->asso('mail_domain')."}_(.*)!", $liste, $matches)) {
-    header("Location: {$_SERVER['PHP_SELF']}?liste={$matches[1]}");
+    redirect("{$_SERVER['PHP_SELF']}?liste={$matches[1]}");
 }
 
 new_group_page('listes/moderate.tpl');
index 5214f69..9888708 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 require_once 'xnet.inc.php';
-if (!Env::has('liste')) header('Location: listes.php');
+if (!Env::has('liste')) redirect('listes.php');
 $liste = strtolower(Env::get('liste'));
 
 new_group_page('listes/options.tpl');
index cb150b9..64f2f58 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 require_once 'xnet.inc.php';
-if (!Env::has('liste')) header('Location: listes.php');
+if (!Env::has('liste')) redirect('listes.php');
 $liste = strtolower(Env::get('liste'));
 
 new_groupadmin_page('listes/soptions.tpl');
index 1862a7e..64fe068 100644 (file)
@@ -5,7 +5,7 @@ require_once 'lists.inc.php';
 require_once 'xnet/mail.inc.php';
 
 if (!Env::has('liste')) {
-    header('Location: annuaire-admin.php');
+    redirect('annuaire-admin.php');
 }
 $liste = Env::get('liste');
 
index b8c65c0..9c61c83 100644 (file)
@@ -10,11 +10,11 @@ $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globa
 
 if(Get::has('del')) {
     $client->unsubscribe(Get::get('del'));
-    header('Location: listes.php');
+    redirect('listes.php');
 }
 if(Get::has('add')) {
     $client->subscribe(Get::get('add'));
-    header('Location: listes.php');
+    redirect('listes.php');
 }
 if(Post::has('promo_add')) {
     $promo = Post::getInt('promo_add');
index fa13502..a57ea61 100644 (file)
@@ -59,7 +59,7 @@
                         FROM  auth_user_md5 AS u
                         INNER JOIN  aliases       AS a ON (u.user_id = a.id)
                         WHERE  a.alias={?}', $globals->asso('id'), $forlife);
-                        header('Location: ?edit='.$email);
+                        redirect('?edit='.$email);
                 } else {
                     $page->trig($email." n'est pas un alias polytechnique.org valide");
                 }
@@ -69,7 +69,7 @@
                     $uid = max(intval($res->fetchOneCell()), 50001);
                     $globals->xdb->execute('INSERT INTO  groupex.membres (uid,asso_id,origine,email) VALUES({?},{?},"ext",{?})',
                             $uid, $globals->asso('id'), $email);
-                    header('Location: ?edit='.$email);
+                    redirect('?edit='.$email);
                 } else {
                     $page->trig("« <strong>$email</strong> Â» n'est pas une adresse mail valide");
                 }
@@ -81,7 +81,7 @@
         new_groupadmin_page('xnet/groupe/membres-edit.tpl');
 
         $user = get_infos(Env::get('edit'));
-        if (empty($user)) { header("Location: annuaire.php"); }
+        if (empty($user)) { redirect("annuaire.php"); }
 
         require 'lists.inc.php';
         $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
                     $page->trig("{$user['prenom']} {$user['nom']} a Ã©té désabonné de $ml");
                 }
             }
-           header("Location: annuaire.php");
+           redirect("annuaire.php");
         }
         
         $page->assign('user', $user);
     {
         new_groupadmin_page('xnet/groupe/membres-del.tpl');
         $user = get_infos(Env::get('del'));
-        if (empty($user)) { header("Location: annuaire.php"); }
+        if (empty($user)) { redirect("annuaire.php"); }
         $page->assign('user', $user);
 
         if (Post::has('confirm')) {
             $page->trig("{$user['prenom']} {$user['nom']} a Ã©té retiré du groupe !");
         }
     }
-    else
-    {
-        header("Location: annuaire.php");
+    else {
+        redirect("annuaire.php");
     }
 
     $page->run();
index 0f06e2d..f083b95 100644 (file)
@@ -2,7 +2,7 @@
     require 'xnet.inc.php';
 
     if (!($cat = Get::get('cat'))) {
-        header("Location:index.php");
+        redirect("index.php");
         exit;
     }
 
index 9d6034f..adad92b 100644 (file)
@@ -2,7 +2,7 @@
     require 'xnet.inc.php';
 
     if (logged()) {
-        header("Location: index.php");
+        redirect("index.php");
     }
 
     new_page('index.tpl', AUTH_MDP);
index 95a0289..a9cb2de 100644 (file)
@@ -26,7 +26,7 @@ require_once("newsletter.inc.php");
 
 if(Get::has('new')) {
    insert_new_nl();
-   header("Location: newsletter.php");
+   redirect("newsletter.php");
 }
 
 $page->assign_by_ref('nl_list', get_nl_slist());
index f0b4130..41f1b5c 100644 (file)
@@ -29,7 +29,7 @@ $nl  = new NewsLetter($nid);
 
 if(Get::has('del_aid')) {
     $nl->delArticle(Get::get('del_aid'));
-    header("Location: {$_SERVER['PHP_SELF']}?nid=$nid");
+    redirect("{$_SERVER['PHP_SELF']}?nid=$nid");
 }
 
 if(Post::get('update')) {
@@ -43,7 +43,7 @@ if(Post::get('save')) {
     $art  = new NLArticle(Post::get('title'), Post::get('body'), Post::get('append'),
             Get::get('edit_aid'), Post::get('cid'), Post::get('pos'));
     $nl->saveArticle($art);
-    header("Location: {$_SERVER['PHP_SELF']}?nid=$nid");
+    redirect("{$_SERVER['PHP_SELF']}?nid=$nid");
 }
 
 if(Get::has('edit_aid')) {
index 6be4219..5fc1bfb 100644 (file)
@@ -38,11 +38,11 @@ if (Env::has('user_id')) {
 }
 
 if(Env::has('logs_button') && $login) {
-    header("Location: logger.php?loguser=$login&year=".date('Y')."&month=".date('m'));
+    redirect("logger.php?loguser=$login&year=".date('Y')."&month=".date('m'));
 }
 
 if (Env::has('ax_button') && $login) {
-    header("Location: synchro_ax.php?user=$login");
+    redirect("synchro_ax.php?user=$login");
 }
 
 if(Env::has('suid_button') && $login) {
@@ -51,7 +51,7 @@ if(Env::has('suid_button') && $login) {
     $r = $globals->xdb->query("SELECT id FROM aliases WHERE alias={?}", $login);
     if($uid = $r->fetchOneCell()) {
        start_connexion($uid,true);
-       header("Location: ../");
+       redirect("../");
     }
 }
 
index 09ec9d4..1967d02 100644 (file)
@@ -84,13 +84,11 @@ $res = $globals->xdb->iterRow('select privkey,name,datafields from groupesx_auth
 while (list($privkey,$name,$datafields) = $res->next()) {
     if (md5($gpex_challenge.$privkey) == $gpex_pass) {
         $returl = $gpex_url.gpex_make_params($gpex_challenge,$privkey,$datafields);
-        header("Location:$returl");
-        exit(0);
+        redirect($returl);
     }
 }
 
 /* si on n'a pas trouvé, on renvoit sur x.org */
-header("Location:https://www.polytechnique.org/");
-exit(0);
+redirect('https://www.polytechnique.org/');
 
 ?>
index 715606c..71f4b6d 100644 (file)
@@ -22,9 +22,5 @@
 require_once("xorg.inc.php");
 new_skinned_page('index.tpl',AUTH_COOKIE);
 
-//adresse de redirection par defaut
-if (isset($_REQUEST['dest'])) $redirect=$_REQUEST['dest'];
-else $redirect="/";
-
-header("Location: ".$redirect);
+redirect(Env::get('dest', '/'));
 ?>
index 922c5dd..642c8a7 100644 (file)
@@ -25,7 +25,7 @@ require_once('notifs.inc.php');
 
 if(Get::has('read')) {
     $_SESSION['watch_last'] = Get::get('read');
-    header("Location: panel.php");
+    redirect("panel.php");
 }
 
 $page->assign('now',date('YmdHis'));
index 6a01b7f..ad70051 100644 (file)
@@ -23,6 +23,6 @@ require_once("xorg.inc.php");
 new_skinned_page('index.tpl', AUTH_COOKIE);
 $page->clear_compiled_tpl();
 
-header("Location: " . (empty($_SERVER['HTTP_REFERER']) ? 'index.php' : $_SERVER['HTTP_REFERER']));
+redirect(empty($_SERVER['HTTP_REFERER']) ? 'index.php' : $_SERVER['HTTP_REFERER']);
 
 ?>
index a7adc4c..7c88b19 100644 (file)
@@ -29,9 +29,9 @@ if (Session::has('suid')) {
     $log->log("suid_stop", Session::get('forlife') . " by " . $suid['forlife']);
     $_SESSION = $suid;
     Session::kill('suid');
-    header('Location: '.$globals->baseurl.'/admin/utilisateurs.php?login='.$a4l);
+    redirect($globals->baseurl.'/admin/utilisateurs.php?login='.$a4l);
 } else {
-    header("Location: login.php");
+    redirect("login.php");
 }
 
 ?>
index 82e9a41..4855883 100644 (file)
@@ -22,7 +22,7 @@
 require_once("xorg.inc.php");
 new_skinned_page('index.tpl', AUTH_PUBLIC);
 if (logged()) {
-    header("Location: login.php");
+    redirect("login.php");
 }
 $page->run();
 ?>
index e205030..2209b15 100644 (file)
@@ -20,6 +20,6 @@
  ***************************************************************************/
 
 require_once('xorg.inc.php');
-header('Location: ../register/end.php?hash='.Env::get('ref'));
+redirect('../register/end.php?hash='.Env::get('ref'));
 
 ?>
index 150068d..d14340c 100644 (file)
@@ -21,7 +21,7 @@
 
 if (!$page) {
     require_once("xorg.inc.php");
-    if (!Env::has('liste')) header('Location: index.php');
+    if (!Env::has('liste')) redirect('index.php');
     $liste  = strtolower(Env::get('liste'));
     $domain = $globals->mail->domain;
 
@@ -55,7 +55,7 @@ if (Env::has('del_member')) {
     } else {
         $client->mass_unsubscribe($liste, Array(Env::get('del_member')));
     }
-    header("Location: {$_SERVER['PHP_SELF']}?liste=$liste");
+    redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
 }
 
 if (Env::has('add_owner')) {
@@ -80,7 +80,7 @@ if (Env::has('del_owner')) {
     } else {
         $client->del_owner($liste, Env::get('del_owner'));
     }
-    header("Location: {$_SERVER['PHP_SELF']}?liste=$liste");
+    redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
 }
 
 if(list($det,$mem,$own) = $client->get_members($liste)) {
index 68169ed..1117778 100644 (file)
@@ -21,7 +21,7 @@
 
 if (!$page) {
     require_once("xorg.inc.php");
-    if (!Env::has('liste')) header('Location: index.php');
+    if (!Env::has('liste')) redirect('index.php');
     $liste = strtolower(Env::get('liste'));
     $domain = $globals->mail->domain;
 
index 4cd27ba..a4fd619 100644 (file)
@@ -21,7 +21,7 @@
 
 if (!$page) {
     require_once("xorg.inc.php");
-    if (!Env::has('liste')) header('Location: index.php');
+    if (!Env::has('liste')) redirect('index.php');
     $liste = strtolower(Env::get('liste'));
 
     new_admin_page('listes/check.tpl');
index 1b280ed..1f49536 100644 (file)
@@ -21,7 +21,7 @@
 
 if (!$page) {
     require_once("xorg.inc.php");
-    if (!Env::has('liste')) header('Location: index.php');
+    if (!Env::has('liste')) redirect('index.php');
     $liste = strtolower(Env::get('liste'));
 
     new_skinned_page('listes/delete.tpl', AUTH_MDP);
index dee288d..13bf1b1 100644 (file)
@@ -28,11 +28,11 @@ $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'));
 
 if(Get::has('del')) {
     $client->unsubscribe(Get::get('del'));
-    header('Location: index.php');
+    redirect('index.php');
 }
 if(Get::has('add')) {
     $client->subscribe(Get::get('add'));
-    header('Location: index.php');
+    redirect('index.php');
 }
 if(Post::has('promo_add')) {
     $promo = Post::getInt('promo_add');
index 0d51416..87acec3 100644 (file)
@@ -21,7 +21,7 @@
 
 if (!$page) {
     require_once("xorg.inc.php");
-    if (!Env::has('liste')) header('Location: index.php');
+    if (!Env::has('liste')) redirect('index.php');
     $liste = strtolower(Env::get('liste'));
 
     new_skinned_page('listes/members.tpl', AUTH_COOKIE);
@@ -32,11 +32,11 @@ if (!$page) {
 
 if(Get::has('del')) {
     $client->unsubscribe($liste);
-    header("Location: {$_SERVER['PHP_SELF']}?liste=$liste");
+    redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
 }
 if(Get::has('add')) {
     $client->subscribe($liste);
-    header("Location: {$_SERVER['PHP_SELF']}?liste=$liste");
+    redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
 }
 $members = $client->get_members($liste);
 
index cda7d4f..6d86659 100644 (file)
 
 if (!$page) {
     require_once("xorg.inc.php");
-    if (!Env::has('liste')) header('Location: index.php');
+    if (!Env::has('liste')) redirect('index.php');
     $liste = strtolower(Env::get('liste'));
     $domain = $globals->mail->domain;
 
     if (preg_match("!(?:[a-z0-9]+\\.)?{$domain}_(.*)!", $liste, $matches)) {
-        header("Location: {$_SERVER['PHP_SELF']}?liste={$matches[1]}");
+        redirect("{$_SERVER['PHP_SELF']}?liste={$matches[1]}");
     }
 
     new_skinned_page('listes/moderate.tpl', AUTH_MDP);
@@ -39,7 +39,7 @@ $page->register_modifier('qpd','quoted_printable_decode');
 
 if(Env::has('sadd')) {
     $client->handle_request($liste,Env::get('sadd'),4,''); /* 4 = SUBSCRIBE */
-    header("Location: {$_SERVER['PHP_SELF']}?liste=$liste");
+    redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
 }
 
 if(Post::has('sdel')) {
index efdd7e9..06e4445 100644 (file)
@@ -21,7 +21,7 @@
 
 if (!$page) {
     require_once("xorg.inc.php");
-    if (!Env::has('liste')) header('Location: index.php');
+    if (!Env::has('liste')) redirect('index.php');
     $liste = strtolower(Env::get('liste'));
 
     new_skinned_page('listes/options.tpl', AUTH_MDP);
@@ -59,7 +59,7 @@ if (Post::has('submit')) {
     $client->add_to_wl($liste, Post::get('atn_add'));
 } elseif (Get::has('atn_del')) {
     $client->del_from_wl($liste, Get::get('atn_del'));
-    header("Location: {$_SERVER['PHP_SELF']}?liste=$liste");
+    redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
 }
 
 if(list($details,$options) = $client->get_owner_options($liste)) {
index 5952da7..ca722b0 100644 (file)
@@ -21,7 +21,7 @@
 
 if (!$page) {
     require_once("xorg.inc.php");
-    if (!Env::has('liste')) header('Location: index.php');
+    if (!Env::has('liste')) redirect('index.php');
     $liste = strtolower(Env::get('liste'));
 
     new_admin_page('listes/soptions.tpl');
index 8021c65..c7b3a66 100644 (file)
@@ -20,7 +20,7 @@
  ***************************************************************************/
 
 require_once("xorg.inc.php");
-if (!Env::has('liste')) header('Location: index.php');
+if (!Env::has('liste')) redirect('index.php');
 $liste = strtolower(Env::get('liste'));
 
 new_skinned_page('listes/trombi.tpl', AUTH_COOKIE);
@@ -31,11 +31,11 @@ $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'));
 
 if(Get::has('del')) {
     $client->unsubscribe($liste);
-    header("Location: {$_SERVER['PHP_SELF']}?liste=$liste");
+    redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
 }
 if(Get::has('add')) {
     $client->subscribe($liste);
-    header("Location: {$_SERVER['PHP_SELF']}?liste=$liste");
+    redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
 }
 
 function getList($offset,$limit)
index 51bb3f4..a3ca5d3 100644 (file)
@@ -30,7 +30,7 @@ if (Env::has('mail_fmt')) {
                                      SET core_mail_fmt = '$fmt'
                                    WHERE user_id = {?}", Session::getInt('uid'));
     $_SESSION['mail_fmt'] = $fmt;
-    header('Location: preferences.php');
+    redirect('preferences.php');
 }
 
 if (Env::has('rss')) {
@@ -42,7 +42,7 @@ if (Env::has('rss')) {
         $globals->xdb->execute('UPDATE auth_user_quick SET core_rss_hash="" WHERE user_id={?}', Session::getInt('uid'));
         Session::kill('core_rss_hash');
     }
-    header('Location: preferences.php');
+    redirect('preferences.php');
 }
 
 $page->assign('prefs', $globals->hook->prefs());
index 32c3683..a1be4a8 100644 (file)
@@ -116,7 +116,7 @@ while (list($salias, $snom, $sprenom) = $res->next()) {
 
 $globals->xdb->execute("DELETE FROM register_marketing WHERE uid = {?}", $uid);
 
-header('Location: success.php');
+redirect('success.php');
 $page->assign('uid', $uid);
 $page->run();
 
index 651e9e9..9dc00b8 100644 (file)
@@ -21,7 +21,7 @@
 
 require_once('xorg.inc.php');
 if (!$globals->skin->enable) {
-    header('Location: index.php');
+    redirect('index.php');
 }
 new_skinned_page('skins.tpl', AUTH_COOKIE);
 $page->assign('xorg_title','Polytechnique.org - Skins');
index 30b8077..1387ccb 100644 (file)
@@ -93,7 +93,7 @@ class PlatalBanana extends Banana
         if (Get::get('banana') == 'updateall') {
             $globals->xdb->execute('UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}', gmdate('YmdHis'), Session::getInt('uid'));
             $_SESSION['banana_last'] = time();
-            header('Location: ?');
+            redirect($_SERVER['PHP_SELF']);
         }
         return Banana::run('PlatalBanana');
     }
index e894f9b..00f513f 100644 (file)
@@ -118,7 +118,7 @@ class XnetSession extends DiogenesCoreSession
         foreach($_GET as $key=>$val) {
             $args[] = urlencode($key).'='.urlencode($val);
         }
-        header('Location: '.$_SERVER['PHP_SELF'] . '?' . join('&', $args));
+        redirect($_SERVER['PHP_SELF'] . '?' . join('&', $args));
     }
 
     // }}}
index 95a7bb9..45dccf9 100644 (file)
@@ -100,6 +100,18 @@ function new_admin_table_editor($table, $idfield, $idedit=false)
 }
 
 // }}}
+// {{{ function redirect
+
+function redirect($page)
+{
+    if (count($_SESSION)) {
+        session_write_close();
+    }
+    header("Location: $page");
+    exit;
+}
+
+// }}}
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>
index 6c1c2c6..1db58e4 100644 (file)
@@ -35,9 +35,9 @@ $res = $globals->xdb->query(
 if ($url = $res->fetchOneCell()) {
     $url = preg_replace('@/+$@', '', $url);
     if($path) {
-        header("Location: http://$url/$path");
+        redirect("http://$url/$path");
     } else {
-        header("Location: http://$url");
+        redirect("http://$url");
     }
     exit();
 }