reduce visible latency
[platal.git] / htdocs / login.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22require_once('xorg.inc.php');
23new_skinned_page('login.tpl', AUTH_COOKIE);
24
25$res = $globals->xdb->query('SELECT date, naissance FROM auth_user_md5 WHERE user_id={?}', Session::getInt('uid'));
26list($date, $naissance) = $res->fetchOneRow();
27
28// incitation à mettre à jour la fiche
29
30$d2 = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4));
31if( (time() - $d2) > 60 * 60 * 24 * 400 ) {
32 // si fiche date de + de 400j;
33 $page->assign('fiche_incitation', $date);
34}
35
36// Souhaite bon anniversaire
37
38if (substr($naissance, 5) == date("m-d")) {
39 $page->assign('birthday', date("Y") - substr($naissance, 0, 4));
40}
41
42// incitation à mettre une photo
43
44$res = $globals->xdb->query('SELECT COUNT(*) FROM photo WHERE uid={?}', Session::getInt('uid'));
45$page->assign('photo_incitation', $res->fetchOneCell() == 0);
46
47// Incitation à se géolocaliser
48require_once('geoloc.inc.php');
49$res = localize_addresses(Session::getInt('uid', -1));
50$page->assign('geoloc_incitation', count($res));
51
52// affichage de la boîte avec quelques liens
53
54require_once('login.conf.php') ;
55$pub_nbElem = $pub_nbLig * $pub_nbCol ;
56if (count($pub_tjs) <= $pub_nbElem)
57 $publicite = array_slice ($pub_tjs,0,$pub_nbElem) ;
58else
59 $publicite = $pub_tjs ;
60$nbAlea = $pub_nbElem - count($publicite) ;
61if ($nbAlea > 0) {
62 $choix = array_rand($pub_rnd,$nbAlea) ;
63 foreach ($choix as $url)
64 $publicite[$url] = $pub_rnd[$url] ;
65 }
66$publicite = array_chunk( $publicite , $pub_nbLig , true ) ;
67$page->assign_by_ref('publicite', $publicite);
68
69// ajout du lien RSS
70
71if (Session::has('core_rss_hash')) {
72 $page->assign('xorg_rss', Array("title" => "Polytechnique.org :: News", "href" => "/rss.php/".Session::get('forlife')."/".Session::get('core_rss_hash').".xml"));
73}
74
75// affichage des evenements
76// annonces promos triées par présence d'une limite sur les promos
77// puis par dates croissantes d'expiration
78$promo = Session::getInt('promo');
79$sql = "SELECT e.id,e.titre,e.texte,a.user_id,a.nom,a.prenom,a.promo,l.alias AS forlife
80 FROM evenements AS e
81 INNER JOIN auth_user_md5 AS a ON e.user_id=a.user_id
82 INNER JOIN aliases AS l ON ( a.user_id=l.id AND l.type='a_vie' )
83 WHERE FIND_IN_SET(e.flags, 'valide') AND peremption >= NOW()
84 AND (e.promo_min = 0 || e.promo_min <= {?})
85 AND (e.promo_max = 0 || e.promo_max >= {?})
86 ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption";
87$page->assign('evenement', $globals->xdb->iterator($sql, $promo, $promo));
88
51c9b362 89$page->assign('refe',$_SERVER['PHP_SELF']);
90
0337d704 91$page->run();
92
93// vim:set et sws=4 sw=4 sts=4:
94?>