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