1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | global $template, $conf; |
---|
5 | |
---|
6 | $infos = $errors = array(); |
---|
7 | |
---|
8 | // check input parameters |
---|
9 | if ( |
---|
10 | empty($_GET['action']) or empty($_GET['email']) or empty($_GET['key']) |
---|
11 | or decrypt_value($_GET['key'], $conf['secret_key']) !== $_GET['action'].$_GET['email'] |
---|
12 | ) |
---|
13 | { |
---|
14 | set_status_header(403); |
---|
15 | array_push($errors, l10n('Bad query')); |
---|
16 | } |
---|
17 | |
---|
18 | switch ($_GET['action']) |
---|
19 | { |
---|
20 | /* unsubscribe */ |
---|
21 | case 'unsubscribe-image' : |
---|
22 | if (empty($where_clause)) $where_clause = 'image_id = '.pwg_db_real_escape_string($_GET['param']); |
---|
23 | case 'unsubscribe-category': |
---|
24 | if (empty($where_clause)) $where_clause = 'category_id = '.pwg_db_real_escape_string($_GET['param']); |
---|
25 | case 'unsubcribe-all' : |
---|
26 | { |
---|
27 | $query = ' |
---|
28 | DELETE FROM '.SUBSCRIBE_TO_TABLE.' |
---|
29 | WHERE |
---|
30 | email = "'.pwg_db_real_escape_string($_GET['email']).'" |
---|
31 | '.(!empty($where_clause) ? 'AND '.$where_clause : null).' |
---|
32 | ;'; |
---|
33 | pwg_query($query); |
---|
34 | |
---|
35 | array_push($infos, l10n('You have been successfully unsubscribed, good bye.')); |
---|
36 | break; |
---|
37 | } |
---|
38 | |
---|
39 | /* validate */ |
---|
40 | case 'validate-image' : |
---|
41 | if (empty($where_clause)) $where_clause = 'image_id = '.pwg_db_real_escape_string($_GET['param']); |
---|
42 | case 'validate-category': |
---|
43 | if (empty($where_clause)) $where_clause = 'category_id = '.pwg_db_real_escape_string($_GET['param']); |
---|
44 | case 'validate-all' : |
---|
45 | { |
---|
46 | $query = ' |
---|
47 | UPDATE '.SUBSCRIBE_TO_TABLE.' |
---|
48 | SET validated = "true" |
---|
49 | WHERE |
---|
50 | email = "'.pwg_db_real_escape_string($_GET['email']).'" |
---|
51 | '.(!empty($where_clause) ? 'AND '.$where_clause : null).' |
---|
52 | ;'; |
---|
53 | pwg_query($query); |
---|
54 | |
---|
55 | array_push($infos, l10n('Your subscribtion has been validated, thanks you.')); |
---|
56 | break; |
---|
57 | } |
---|
58 | |
---|
59 | /* manage */ |
---|
60 | case 'manage' : |
---|
61 | { |
---|
62 | break; |
---|
63 | } |
---|
64 | |
---|
65 | default : |
---|
66 | { |
---|
67 | set_status_header(403); |
---|
68 | array_push($errors, l10n('Bad query')); |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | $template->assign(array( |
---|
73 | 'infos' => $infos, |
---|
74 | 'errors' => $errors, |
---|
75 | )); |
---|
76 | |
---|
77 | $template->set_filenames(array('index'=> dirname(__FILE__).'/../template/subscribtions_page.tpl')); |
---|
78 | ?> |
---|