[12560] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
[15641] | 4 | global $template, $conf, $page, $pwg_loaded_plugins; |
---|
[12560] | 5 | |
---|
| 6 | // check input parameters |
---|
[12600] | 7 | $_GET['verif_key'] = $_GET['action'].$_GET['email'].(isset($_GET['id'])?$_GET['id']:null); |
---|
[15641] | 8 | |
---|
[12560] | 9 | if ( |
---|
| 10 | empty($_GET['action']) or empty($_GET['email']) or empty($_GET['key']) |
---|
[12600] | 11 | or decrypt_value($_GET['key'], $conf['secret_key']) !== $_GET['verif_key'] |
---|
[12560] | 12 | ) |
---|
| 13 | { |
---|
[15641] | 14 | $_GET['action'] = null; |
---|
[12560] | 15 | } |
---|
[12600] | 16 | else |
---|
| 17 | { |
---|
[15641] | 18 | // unsubscribe all |
---|
| 19 | if ( isset($_POST['unsubscribe_all']) and isset($_POST['unsubscribe_all_check']) ) |
---|
[12560] | 20 | { |
---|
[15641] | 21 | $query = ' |
---|
| 22 | DELETE FROM '.SUBSCRIBE_TO_TABLE.' |
---|
| 23 | WHERE email = "'.$_GET['email'].'" |
---|
| 24 | ;'; |
---|
| 25 | pwg_query($query); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | // bulk action |
---|
| 29 | if (isset($_POST['apply_bulk'])) |
---|
| 30 | { |
---|
| 31 | foreach ($_POST['selected'] as $id) |
---|
[12600] | 32 | { |
---|
[15641] | 33 | switch ($_POST['action']) |
---|
| 34 | { |
---|
| 35 | case 'unsubscribe': |
---|
| 36 | un_subscribe_to_comments($_GET['email'], $id); |
---|
| 37 | break; |
---|
| 38 | case 'validate': |
---|
| 39 | validate_subscriptions($_GET['email'], $id); |
---|
| 40 | break; |
---|
| 41 | } |
---|
[12600] | 42 | } |
---|
[15641] | 43 | } |
---|
| 44 | |
---|
| 45 | // unsubscribe from manage page |
---|
| 46 | if (isset($_GET['unsubscribe'])) |
---|
| 47 | { |
---|
| 48 | if (un_subscribe_to_comments($_GET['email'], $_GET['unsubscribe'])) |
---|
| 49 | { |
---|
| 50 | array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.')); |
---|
| 51 | } |
---|
[12600] | 52 | else |
---|
| 53 | { |
---|
[15641] | 54 | array_push($page['errors'], l10n('Not found.')); |
---|
[12600] | 55 | } |
---|
| 56 | } |
---|
[15641] | 57 | |
---|
| 58 | // validate from manage page |
---|
| 59 | if (isset($_GET['validate'])) |
---|
[12600] | 60 | { |
---|
[15641] | 61 | if (validate_subscriptions($_GET['email'], $_GET['validate'])) |
---|
[12600] | 62 | { |
---|
[15641] | 63 | array_push($page['infos'], l10n('Your subscribtion has been validated, thanks you.')); |
---|
[12600] | 64 | } |
---|
| 65 | else |
---|
| 66 | { |
---|
[15641] | 67 | array_push($page['infos'], l10n('Already validated.')); |
---|
[12600] | 68 | } |
---|
[12560] | 69 | } |
---|
| 70 | |
---|
[12600] | 71 | $template->assign('MANAGE_LINK', make_stc_url('manage', $_GET['email'])); |
---|
| 72 | } |
---|
| 73 | |
---|
[15641] | 74 | |
---|
[12600] | 75 | switch ($_GET['action']) |
---|
| 76 | { |
---|
[12560] | 77 | /* validate */ |
---|
[15641] | 78 | case 'validate': |
---|
[12600] | 79 | { |
---|
[15641] | 80 | $query = ' |
---|
| 81 | SELECT |
---|
| 82 | type, |
---|
| 83 | element_id |
---|
| 84 | FROM '.SUBSCRIBE_TO_TABLE.' |
---|
| 85 | WHERE |
---|
| 86 | email = "'.$_GET['email'].'" |
---|
| 87 | AND id = '.$_GET['id'].' |
---|
| 88 | ;'; |
---|
| 89 | $result = pwg_query($query); |
---|
| 90 | |
---|
| 91 | if (!pwg_db_num_rows($result)) |
---|
[12600] | 92 | { |
---|
[15641] | 93 | array_push($page['errors'], l10n('Not found.')); |
---|
[12600] | 94 | } |
---|
| 95 | else |
---|
| 96 | { |
---|
[15641] | 97 | if (validate_subscriptions($_GET['email'], $_GET['id'])) |
---|
| 98 | { |
---|
| 99 | array_push($page['infos'], l10n('Your subscribtion has been validated, thanks you.')); |
---|
| 100 | } |
---|
| 101 | else |
---|
| 102 | { |
---|
| 103 | array_push($page['infos'], l10n('Already validated.')); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | list($type, $element_id) = pwg_db_fetch_row($result); |
---|
| 107 | |
---|
| 108 | switch ($type) |
---|
| 109 | { |
---|
| 110 | case 'image': |
---|
| 111 | $element = get_picture_infos($element_id, false); |
---|
| 112 | break; |
---|
| 113 | case 'album-images': |
---|
| 114 | case 'album': |
---|
| 115 | $element = get_category_infos($element_id, false); |
---|
| 116 | break; |
---|
| 117 | default: |
---|
| 118 | $element = null; |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | $template->assign(array( |
---|
| 122 | 'type' => $type, |
---|
| 123 | 'element' => $element, |
---|
| 124 | )); |
---|
[12600] | 125 | } |
---|
| 126 | |
---|
[15641] | 127 | $template->assign('IN_VALIDATE', true); |
---|
[12600] | 128 | break; |
---|
| 129 | } |
---|
[15641] | 130 | |
---|
| 131 | /* unsubscribe */ |
---|
| 132 | case 'unsubscribe': |
---|
[12560] | 133 | { |
---|
[15641] | 134 | $query = ' |
---|
| 135 | SELECT |
---|
| 136 | type, |
---|
| 137 | element_id |
---|
| 138 | FROM '.SUBSCRIBE_TO_TABLE.' |
---|
| 139 | WHERE |
---|
| 140 | email = "'.$_GET['email'].'" |
---|
| 141 | AND id = '.$_GET['id'].' |
---|
| 142 | ;'; |
---|
| 143 | $result = pwg_query($query); |
---|
| 144 | |
---|
| 145 | if (!pwg_db_num_rows($result)) |
---|
[12600] | 146 | { |
---|
[15641] | 147 | array_push($page['errors'], l10n('Not found.')); |
---|
[12600] | 148 | } |
---|
| 149 | else |
---|
| 150 | { |
---|
[15641] | 151 | if (un_subscribe_to_comments($_GET['email'], $_GET['id'])) |
---|
| 152 | { |
---|
| 153 | array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.')); |
---|
| 154 | } |
---|
| 155 | else |
---|
| 156 | { |
---|
| 157 | array_push($page['errors'], l10n('Not found.')); |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | list($type, $element_id) = pwg_db_fetch_row($result); |
---|
| 161 | |
---|
| 162 | switch ($type) |
---|
| 163 | { |
---|
| 164 | case 'image': |
---|
| 165 | $element = get_picture_infos($element_id); |
---|
| 166 | break; |
---|
| 167 | case 'album-images': |
---|
| 168 | case 'album': |
---|
| 169 | $element = get_category_infos($element_id); |
---|
| 170 | break; |
---|
| 171 | default: |
---|
| 172 | $element = null; |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | $template->assign(array( |
---|
| 176 | 'type' => $type, |
---|
| 177 | 'element' => $element, |
---|
| 178 | )); |
---|
[12600] | 179 | } |
---|
[12560] | 180 | |
---|
[15641] | 181 | $template->assign('IN_UNSUBSCRIBE', true); |
---|
[12560] | 182 | break; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | /* manage */ |
---|
[15641] | 186 | case 'manage': |
---|
[12560] | 187 | { |
---|
[12600] | 188 | $query = ' |
---|
| 189 | SELECT * |
---|
| 190 | FROM '.SUBSCRIBE_TO_TABLE.' |
---|
[15641] | 191 | WHERE email = "'.$_GET['email'].'" |
---|
[12600] | 192 | ORDER BY registration_date DESC |
---|
| 193 | ;'; |
---|
| 194 | $result = pwg_query($query); |
---|
| 195 | |
---|
[15641] | 196 | if (pwg_db_num_rows($result)) |
---|
[12600] | 197 | { |
---|
| 198 | while ($subscription = pwg_db_fetch_assoc($result)) |
---|
| 199 | { |
---|
[15641] | 200 | $subscription['registration_date'] = format_date($subscription['registration_date'], true); |
---|
| 201 | |
---|
| 202 | switch ($subscription['type']) |
---|
[12600] | 203 | { |
---|
[15641] | 204 | case 'image': |
---|
| 205 | $subscription['infos'] = get_picture_infos($subscription['element_id']); |
---|
| 206 | break; |
---|
| 207 | case 'album-images': |
---|
| 208 | case 'album': |
---|
| 209 | $subscription['infos'] = get_category_infos($subscription['element_id']); |
---|
| 210 | break; |
---|
| 211 | default: |
---|
| 212 | $subscription['infos'] = null; |
---|
| 213 | $template->append('global_subscriptions', $subscription); |
---|
| 214 | continue(2); |
---|
[12600] | 215 | } |
---|
[15641] | 216 | |
---|
[12600] | 217 | $template->append('subscriptions', $subscription); |
---|
| 218 | } |
---|
| 219 | } |
---|
| 220 | else |
---|
| 221 | { |
---|
[15641] | 222 | array_push($page['infos'], l10n('You are not subscribed to any comment.')); |
---|
[12600] | 223 | } |
---|
[12560] | 224 | break; |
---|
| 225 | } |
---|
| 226 | |
---|
[15641] | 227 | default: |
---|
[12560] | 228 | { |
---|
| 229 | set_status_header(403); |
---|
[15641] | 230 | array_push($page['errors'], l10n('Bad query')); |
---|
[12560] | 231 | } |
---|
| 232 | } |
---|
| 233 | |
---|
[15641] | 234 | if (isset($pwg_loaded_plugins['Comments_on_Albums'])) |
---|
| 235 | { |
---|
| 236 | $template->assign('COA_ACTIVATED', true); |
---|
| 237 | } |
---|
| 238 | |
---|
[12560] | 239 | $template->assign(array( |
---|
[12600] | 240 | 'EMAIL' => $_GET['email'], |
---|
| 241 | 'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH, |
---|
| 242 | )); |
---|
| 243 | |
---|
[15641] | 244 | $template->set_filenames(array('index'=> dirname(__FILE__).'/../template/subscribtions_page.tpl')); |
---|
[12560] | 245 | |
---|
| 246 | ?> |
---|