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 | |
22 | require_once('xorg.inc.php'); |
23 | new_skinned_page('login.tpl', AUTH_COOKIE); |
24 | |
d9a33f98 |
25 | |
0337d704 |
26 | $res = $globals->xdb->query('SELECT date, naissance FROM auth_user_md5 WHERE user_id={?}', Session::getInt('uid')); |
27 | list($date, $naissance) = $res->fetchOneRow(); |
28 | |
29 | // incitation à mettre à jour la fiche |
30 | |
31 | $d2 = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4)); |
32 | if( (time() - $d2) > 60 * 60 * 24 * 400 ) { |
33 | // si fiche date de + de 400j; |
34 | $page->assign('fiche_incitation', $date); |
35 | } |
36 | |
37 | // Souhaite bon anniversaire |
38 | |
39 | if (substr($naissance, 5) == date("m-d")) { |
40 | $page->assign('birthday', date("Y") - substr($naissance, 0, 4)); |
41 | } |
42 | |
43 | // incitation à mettre une photo |
44 | |
45 | $res = $globals->xdb->query('SELECT COUNT(*) FROM photo WHERE uid={?}', Session::getInt('uid')); |
46 | $page->assign('photo_incitation', $res->fetchOneCell() == 0); |
47 | |
48 | // Incitation à se géolocaliser |
49 | require_once('geoloc.inc.php'); |
50 | $res = localize_addresses(Session::getInt('uid', -1)); |
51 | $page->assign('geoloc_incitation', count($res)); |
52 | |
53 | // affichage de la boîte avec quelques liens |
54 | |
55 | require_once('login.conf.php') ; |
56 | $pub_nbElem = $pub_nbLig * $pub_nbCol ; |
57 | if (count($pub_tjs) <= $pub_nbElem) |
58 | $publicite = array_slice ($pub_tjs,0,$pub_nbElem) ; |
59 | else |
60 | $publicite = $pub_tjs ; |
61 | $nbAlea = $pub_nbElem - count($publicite) ; |
62 | if ($nbAlea > 0) { |
63 | $choix = array_rand($pub_rnd,$nbAlea) ; |
64 | foreach ($choix as $url) |
65 | $publicite[$url] = $pub_rnd[$url] ; |
66 | } |
67 | $publicite = array_chunk( $publicite , $pub_nbLig , true ) ; |
68 | $page->assign_by_ref('publicite', $publicite); |
69 | |
70 | // ajout du lien RSS |
71 | |
72 | if (Session::has('core_rss_hash')) { |
73 | $page->assign('xorg_rss', Array("title" => "Polytechnique.org :: News", "href" => "/rss.php/".Session::get('forlife')."/".Session::get('core_rss_hash').".xml")); |
74 | } |
75 | |
76 | // affichage des evenements |
77 | // annonces promos triées par présence d'une limite sur les promos |
78 | // puis par dates croissantes d'expiration |
79 | $promo = Session::getInt('promo'); |
80 | $sql = "SELECT e.id,e.titre,e.texte,a.user_id,a.nom,a.prenom,a.promo,l.alias AS forlife |
81 | FROM evenements AS e |
82 | INNER JOIN auth_user_md5 AS a ON e.user_id=a.user_id |
83 | INNER JOIN aliases AS l ON ( a.user_id=l.id AND l.type='a_vie' ) |
84 | WHERE FIND_IN_SET(e.flags, 'valide') AND peremption >= NOW() |
85 | AND (e.promo_min = 0 || e.promo_min <= {?}) |
86 | AND (e.promo_max = 0 || e.promo_max >= {?}) |
87 | ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption"; |
88 | $page->assign('evenement', $globals->xdb->iterator($sql, $promo, $promo)); |
89 | |
51c9b362 |
90 | $page->assign('refe',$_SERVER['PHP_SELF']); |
91 | |
0337d704 |
92 | $page->run(); |
93 | |
94 | // vim:set et sws=4 sw=4 sts=4: |
95 | ?> |