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('marketing/public.tpl', AUTH_COOKIE); |
24 | |
25 | if (! Env::has('num')) { exit; } |
26 | |
27 | $uid = Env::get('num'); |
28 | |
29 | $res = $globals->xdb->query("SELECT nom, prenom, promo FROM auth_user_md5 WHERE user_id={?} AND perms='pending'", $uid); |
30 | |
31 | if (list($nom, $prenom, $promo) = $res->fetchOneRow()) { |
32 | $page->assign('prenom', $prenom); |
33 | $page->assign('nom', $nom); |
34 | $page->assign('promo', $promo); |
35 | |
36 | if (Env::has('valide')) { |
37 | require_once('xorg.misc.inc.php'); |
38 | |
39 | $email = trim(Env::get('mail')); |
40 | $res = $globals->xdb->query('SELECT COUNT(*) FROM register_marketing WHERE uid={?} AND email={?}', $uid, $email); |
41 | |
42 | if (!isvalid_email_redirection($email)) { |
43 | $page->trig("Email invalide !"); |
44 | } elseif ($res->fetchOneCell()) { |
45 | $page->assign('already', true); |
46 | } else { |
47 | $page->assign('ok', true); |
48 | $globals->xdb->execute( |
49 | "INSERT INTO register_marketing (uid,sender,email,date,last,nb,type,hash) |
50 | VALUES ({?}, {?}, {?}, NOW(), 0, 0, {?}, '')", |
51 | $uid, Session::getInt('uid'), $email, Env::get('origine')); |
52 | require_once('validations.inc.php'); |
53 | $req = new MarkReq(Session::getInt('uid'), $uid, $email, Env::get('origine')=='user'); |
54 | $req->submit(); |
55 | } |
56 | } |
57 | } |
58 | |
59 | $page->run(); |
60 | ?> |