New :
+ * Core :
+ - HTTP redirection safe wrt Session (should solve login problems). -MC
+
* Documentation :
- Documentation now use Wiki -Car
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');
<?php
- header("Location: https://www.polytechnique.org/fiche.php?user=".$_GET['user']);
+ redirect("https://www.polytechnique.org/fiche.php?user=".$_GET['user']);
?>
new_groupadmin_page('xnet/groupe/alias-admin.tpl');
if (!Get::has('liste')) {
- header("Location: listes.php");
+ redirect("listes.php");
}
$lfull = strtolower(Get::get('liste'));
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(
}
$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();
$page->assign('asso', $globals->asso());
if (!$globals->asso('id')) {
- header("Location: ../");
+ redirect("../");
}
$page->run();
$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()) {
$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
Env::get('mail'), $globals->asso('id'));
$member = $res->fetchOneCell();
if (!$member) $page->trig("Membre introuvable");
+ }
}
// change the price paid by a participant
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);
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);
***************************************************************************/
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');
***************************************************************************/
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');
***************************************************************************/
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');
$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>");
}
***************************************************************************/
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');
***************************************************************************/
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');
***************************************************************************/
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');
***************************************************************************/
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');
***************************************************************************/
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');
require_once 'xnet/mail.inc.php';
if (!Env::has('liste')) {
- header('Location: annuaire-admin.php');
+ redirect('annuaire-admin.php');
}
$liste = Env::get('liste');
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');
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");
}
$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");
}
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();
require 'xnet.inc.php';
if (!($cat = Get::get('cat'))) {
- header("Location:index.php");
+ redirect("index.php");
exit;
}
require 'xnet.inc.php';
if (logged()) {
- header("Location: index.php");
+ redirect("index.php");
}
new_page('index.tpl', AUTH_MDP);
if(Get::has('new')) {
insert_new_nl();
- header("Location: newsletter.php");
+ redirect("newsletter.php");
}
$page->assign_by_ref('nl_list', get_nl_slist());
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')) {
$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')) {
}
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) {
$r = $globals->xdb->query("SELECT id FROM aliases WHERE alias={?}", $login);
if($uid = $r->fetchOneCell()) {
start_connexion($uid,true);
- header("Location: ../");
+ redirect("../");
}
}
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/');
?>
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', '/'));
?>
if(Get::has('read')) {
$_SESSION['watch_last'] = Get::get('read');
- header("Location: panel.php");
+ redirect("panel.php");
}
$page->assign('now',date('YmdHis'));
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']);
?>
$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");
}
?>
require_once("xorg.inc.php");
new_skinned_page('index.tpl', AUTH_PUBLIC);
if (logged()) {
- header("Location: login.php");
+ redirect("login.php");
}
$page->run();
?>
***************************************************************************/
require_once('xorg.inc.php');
-header('Location: ../register/end.php?hash='.Env::get('ref'));
+redirect('../register/end.php?hash='.Env::get('ref'));
?>
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;
} 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')) {
} 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)) {
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 (!$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');
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);
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');
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);
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);
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);
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')) {
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);
$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)) {
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');
***************************************************************************/
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);
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)
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')) {
$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());
$globals->xdb->execute("DELETE FROM register_marketing WHERE uid = {?}", $uid);
-header('Location: success.php');
+redirect('success.php');
$page->assign('uid', $uid);
$page->run();
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');
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');
}
foreach($_GET as $key=>$val) {
$args[] = urlencode($key).'='.urlencode($val);
}
- header('Location: '.$_SERVER['PHP_SELF'] . '?' . join('&', $args));
+ redirect($_SERVER['PHP_SELF'] . '?' . join('&', $args));
}
// }}}
}
// }}}
+// {{{ 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:
?>
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();
}