forked from opencaching/opencaching-pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivation.php
60 lines (48 loc) · 1.98 KB
/
activation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
use Utils\Database\XDb;
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
//Preprocessing
if ($error == false) {
//set here the template to process
$tplname = 'activation';
//load language specific variables
require_once($stylepath . '/' . $tplname . '.inc.php');
$email = isset($_REQUEST['email']) ? $_REQUEST['email'] : '';
$code = isset($_REQUEST['code']) ? $_REQUEST['code'] : '';
tpl_set_var('email', htmlspecialchars($email, ENT_COMPAT, 'UTF-8'));
tpl_set_var('code', htmlspecialchars($code, ENT_COMPAT, 'UTF-8'));
tpl_set_var('message_start', '<!--');
tpl_set_var('message_end', '-->');
tpl_set_var('message', '');
tpl_set_var('email_message', '');
if (isset($_REQUEST['submit'])) {
$email_not_ok = is_valid_email_address($email) ? false : true;
if ($email_not_ok == true) {
tpl_set_var('email_message', $message_email_notok);
} else {
$rs = XDb::xSql("SELECT `user_id` `id`, `activation_code` `code`
FROM `user` WHERE `email`= ? ", $email);
if ($r = XDb::xFetchArray($rs)) {
if (($r['code'] == $code) && ($code != '')) {
XDb::xFreeResults($rs);
// ok, account aktivieren
XDb::xSql("UPDATE `user` SET `is_active_flag`=1, `activation_code`='' WHERE `user_id`= ? ", $r['id']);
$tplname = 'activation_confirm';
} else {
tpl_set_var('message_start', '');
tpl_set_var('message_end', '');
tpl_set_var('message', $message_no_success);
}
} else {
tpl_set_var('message_start', '');
tpl_set_var('message_end', '');
tpl_set_var('message', $message_no_success);
}
XDb::xFreeResults($rs);
}
}
}
//make the template and send it out
tpl_BuildTemplate();
?>