fix missing bold for your account item
[brisk.git] / web / mailmgr.php
1 <?php
2 /*
3  *  brisk - mailmgr.php
4  *
5  *  Copyright (C) 2014      Matteo Nastasi
6  *                          mailto: nastasi@alternativeoutput.it
7  *                                  matteo.nastasi@milug.org
8  *                          web: http://www.alternativeoutput.it
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * General Public License for more details. You should have received a
19  * copy of the GNU General Public License along with this program; if
20  * not, write to the Free Software Foundation, Inc, 59 Temple Place -
21  * Suite 330, Boston, MA 02111-1307, USA.
22  *
23  */
24
25 foreach (array("HTTP_HOST", "DOCUMENT_ROOT") as $i) {
26     if (isset($_SERVER[$i])) {
27         $$i = $_SERVER[$i];
28         }
29     }
30
31 foreach (array("f_act", "f_code", "f_hash") as $i) {
32     if (isset($_GET[$i])) {
33         $$i = $_GET[$i];
34         }
35     }
36
37
38 $G_base = "";
39
40 ini_set("max_execution_time", "240");
41
42 require_once($G_base."Obj/brisk.phh");
43 require_once($G_base."Obj/user.phh");
44 require_once($G_base."Obj/auth.phh");
45 require_once($G_base."Obj/dbase_${G_dbasetype}.phh");
46 require_once($G_base."Obj/singlemsg.phh");
47
48 require_once($G_base."spush/brisk-spush.phh");
49
50 define('MAILMGR_CHECKMAIL', 1);
51
52 function main() {
53     // GLOBAL $G_dbpfx, $G_alarm_passwd, $f_mailusers, $sess, $_POST, $_SERVER;
54     GLOBAL $G_dbpfx, $f_act, $f_code, $f_hash;
55
56     /* echo "act:  $f_act<br>";
57        echo "code: $f_code<br>";
58        echo "hash: $f_hash<br>"; */
59
60     if ($f_act == "checkmail") {
61         $errcode = 10000;
62         do {
63             if (($bdb = BriskDB::create()) == FALSE) {
64                 log_crit("stat-day: database connection failed");
65                 $errcode = 10001;
66                 break;
67             }
68             $bdb->transaction('BEGIN');
69
70             if (($mai = $bdb->mail_check($f_code, MAILMGR_CHECKMAIL, $f_hash)) == FALSE) {
71                 $errcode = 10002;
72                 break;
73             }
74
75             if (($bdb->user_update_flag_ty($mai->ucode, USER_FLAG_TY_DISABLE,
76                                         TRUE, USER_DIS_REA_NU_MAILED,
77                                         TRUE, USER_DIS_REA_NU_TOBECHK)) == FALSE) {
78                 $errcode = 10003;
79                 break;
80             }
81
82             if (($mai = $bdb->mail_delete($f_code)) == FALSE) {
83                 $errcode = 10004;
84                 break;
85             }
86             $bdb->transaction('COMMIT');
87
88             singlemsg("Verifica della e-mail andata a buon fine.", "Verifica della e-mail andata a buon fine.<br>Riceverai a breve una email con la tua nuova password.<br>Benvenuto!");
89             $errcode = 0;
90         } while (FALSE);
91         if ($errcode) {
92             if ($errcode == 10002) {
93                 singlemsg("L'email è già stata verificata con successo.",
94                           "L'email è già stata verificata con successo, ora attenda che le venga recapitata la password.");
95             }
96             else {
97                 singlemsg("E' occorso un errore durante la verifica della e-mail.",
98                           sprintf("E' occorso un errore durante la verifica della e-mail.<br><br>Codice d'errore: %d.<br>", $errcode));
99             }
100             $bdb->transaction('ROLLBACK');
101         }
102     }
103
104     exit;
105 }
106
107 main();
108 ?>