[5056] | 1 | <?php |
---|
[5181] | 2 | include_once (UAM_PATH.'include/constants.php'); |
---|
| 3 | load_language('plugin.lang', UAM_PATH); |
---|
[5056] | 4 | |
---|
[7968] | 5 | /** |
---|
| 6 | * Triggered on get_admin_plugin_menu_links |
---|
| 7 | * |
---|
| 8 | * Plugin's administration menu |
---|
| 9 | */ |
---|
| 10 | function UAM_admin_menu($menu) |
---|
| 11 | { |
---|
| 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | Getting plugin name | |
---|
| 14 | // +-----------------------------------------------------------------------+ |
---|
| 15 | $plugin = PluginInfos(UAM_PATH); |
---|
| 16 | $name = $plugin['name']; |
---|
| 17 | |
---|
| 18 | array_push($menu, |
---|
| 19 | array( |
---|
| 20 | 'NAME' => $name, |
---|
| 21 | 'URL' => get_admin_plugin_menu_link(UAM_PATH.'/admin/UAM_admin.php') |
---|
| 22 | ) |
---|
| 23 | ); |
---|
| 24 | |
---|
| 25 | return $menu; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | /** |
---|
| 29 | * Triggered on loc_begin_index |
---|
| 30 | * |
---|
| 31 | * Initiating GhostTracker |
---|
| 32 | */ |
---|
| 33 | function UAM_GhostTracker() |
---|
| 34 | { |
---|
| 35 | global $conf, $user; |
---|
| 36 | |
---|
| 37 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 38 | |
---|
| 39 | // Admins, Guests and Adult_Content users are not tracked for Ghost Tracker or Users Tracker |
---|
| 40 | if (!is_admin() and !is_a_guest() and $user['username'] != "16" and $user['username'] != "18") |
---|
| 41 | { |
---|
| 42 | if ((isset($conf_UAM[16]) and $conf_UAM[16] == 'true') or (isset($conf_UAM[19]) and $conf_UAM[19] == 'true')) |
---|
| 43 | { |
---|
| 44 | |
---|
| 45 | $userid = get_userid($user['username']); |
---|
| 46 | |
---|
| 47 | // Looking for existing entry in last visit table |
---|
| 48 | $query = ' |
---|
| 49 | SELECT * |
---|
| 50 | FROM '.USER_LASTVISIT_TABLE.' |
---|
| 51 | WHERE user_id = '.$userid.' |
---|
| 52 | ;'; |
---|
| 53 | |
---|
| 54 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
| 55 | |
---|
| 56 | if ($count == 0) |
---|
| 57 | { |
---|
| 58 | // If not, data are inserted in table |
---|
| 59 | $query = ' |
---|
| 60 | INSERT INTO '.USER_LASTVISIT_TABLE.' (user_id, lastvisit, reminder) |
---|
| 61 | VALUES ('.$userid.', now(), "false") |
---|
| 62 | ;'; |
---|
| 63 | pwg_query($query); |
---|
| 64 | } |
---|
| 65 | else if ($count > 0) |
---|
| 66 | { |
---|
| 67 | // If yes, data are updated in table |
---|
| 68 | $query = ' |
---|
| 69 | UPDATE '.USER_LASTVISIT_TABLE.' |
---|
| 70 | SET lastvisit = now(), reminder = "false" |
---|
| 71 | WHERE user_id = '.$userid.' |
---|
| 72 | LIMIT 1 |
---|
| 73 | ;'; |
---|
| 74 | pwg_query($query); |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | * Triggered on register_user |
---|
| 82 | * |
---|
| 83 | * Additional controls on user registration |
---|
| 84 | */ |
---|
| 85 | function UAM_Adduser($register_user) |
---|
| 86 | { |
---|
| 87 | global $conf; |
---|
| 88 | |
---|
| 89 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 90 | |
---|
| 91 | // Exclusion of Adult_Content users |
---|
| 92 | if ($register_user['username'] != "16" and $register_user['username'] != "18") |
---|
| 93 | { |
---|
| 94 | if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) |
---|
| 95 | { |
---|
| 96 | // This is to send an information email and set user to "waiting" group or status until admin validation |
---|
| 97 | $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; |
---|
| 98 | SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); |
---|
| 99 | setgroup($register_user['id']);// Set to "waiting" group or status until admin validation |
---|
| 100 | } |
---|
| 101 | elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) |
---|
| 102 | { |
---|
| 103 | // This is to set user to "waiting" group or status until admin validation |
---|
| 104 | setgroup($register_user['id']);// Set to "waiting" group or status until admin validation |
---|
| 105 | } |
---|
| 106 | elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'false')) |
---|
| 107 | { |
---|
| 108 | // This is to send an information email without validation key |
---|
| 109 | $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; |
---|
| 110 | SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); |
---|
| 111 | } |
---|
| 112 | // Sending registration confirmation by email |
---|
| 113 | elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true' or $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true')) |
---|
| 114 | { |
---|
| 115 | if (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'true') |
---|
| 116 | { |
---|
| 117 | $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; |
---|
| 118 | SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); |
---|
| 119 | } |
---|
| 120 | elseif (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'false') |
---|
| 121 | { |
---|
| 122 | $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; |
---|
| 123 | SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); |
---|
| 124 | } |
---|
| 125 | elseif (!is_admin()) |
---|
| 126 | { |
---|
| 127 | $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; |
---|
| 128 | SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | } |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | /** |
---|
| 135 | * Triggered on delete_user |
---|
| 136 | * |
---|
| 137 | * Database cleanup on user deletion |
---|
| 138 | */ |
---|
| 139 | function UAM_Deluser($user_id) |
---|
| 140 | { |
---|
| 141 | // Cleanup for ConfirmMail table |
---|
| 142 | DeleteConfirmMail($user_id); |
---|
| 143 | // Cleanup for LastVisit table |
---|
| 144 | DeleteLastVisit($user_id); |
---|
| 145 | // Cleanup Redirection settings |
---|
| 146 | DeleteRedir($user_id); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | /** |
---|
| 150 | * Triggered on register_user_check |
---|
| 151 | * |
---|
| 152 | * Additional controls on user registration check |
---|
| 153 | */ |
---|
[8065] | 154 | function UAM_RegistrationCheck($errors, $user) |
---|
[7968] | 155 | { |
---|
[8065] | 156 | global $conf; |
---|
[7968] | 157 | |
---|
| 158 | // Exclusion of Adult_Content users |
---|
| 159 | if ($user['username'] != "16" and $user['username'] != "18") |
---|
| 160 | { |
---|
[8065] | 161 | load_language('plugin.lang', UAM_PATH); |
---|
[7968] | 162 | |
---|
| 163 | $PasswordCheck = 0; |
---|
| 164 | |
---|
| 165 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 166 | |
---|
| 167 | // Password enforcement control |
---|
| 168 | if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14])) |
---|
| 169 | { |
---|
| 170 | if (!empty($user['password']) and !is_admin()) |
---|
| 171 | { |
---|
| 172 | $PasswordCheck = testpassword($user['password']); |
---|
| 173 | |
---|
| 174 | if ($PasswordCheck < $conf_UAM[14]) |
---|
| 175 | { |
---|
| 176 | $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); |
---|
[8065] | 177 | $lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]; |
---|
| 178 | array_push($errors, $lang['reg_err_pass']); |
---|
[7968] | 179 | } |
---|
| 180 | } |
---|
| 181 | else if (!empty($user['password']) and is_admin() and isset($conf_UAM[15]) and $conf_UAM[15] == 'true') |
---|
| 182 | { |
---|
| 183 | $PasswordCheck = testpassword($user['password']); |
---|
| 184 | |
---|
| 185 | if ($PasswordCheck < $conf_UAM[14]) |
---|
| 186 | { |
---|
| 187 | $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); |
---|
[8065] | 188 | $lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]; |
---|
| 189 | array_push($errors, $lang['reg_err_pass']); |
---|
[7968] | 190 | } |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | // Username without forbidden keys |
---|
[8065] | 195 | if (isset($conf_UAM[6]) and $conf_UAM[6] == 'true' and !empty($user['username']) and ValidateUsername($user['username']) and !is_admin()) |
---|
[7968] | 196 | { |
---|
[8065] | 197 | $lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_UAM[7]."'"; |
---|
| 198 | array_push($errors, $lang['reg_err_login1']); |
---|
[7968] | 199 | } |
---|
| 200 | |
---|
| 201 | // Email without forbidden domains |
---|
[8065] | 202 | if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($user['email']) and ValidateEmailProvider($user['email']) and !is_admin()) |
---|
[7968] | 203 | { |
---|
[8065] | 204 | $lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_UAM[12]."'"; |
---|
| 205 | array_push($errors, $lang['reg_err_login1']); |
---|
[7968] | 206 | } |
---|
[8065] | 207 | return $errors; |
---|
[7968] | 208 | } |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | /** |
---|
| 212 | * Triggered on loc_begin_profile |
---|
| 213 | */ |
---|
| 214 | function UAM_Profile_Init() |
---|
| 215 | { |
---|
| 216 | global $conf, $user, $template; |
---|
| 217 | |
---|
| 218 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 219 | |
---|
| 220 | if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true')) |
---|
| 221 | { |
---|
| 222 | $user_idsOK = array(); |
---|
[8065] | 223 | if (!UAM_check_profile($user['id'], $user_idsOK)) |
---|
[7968] | 224 | { |
---|
| 225 | $user_idsOK[] = $user['id']; |
---|
| 226 | |
---|
| 227 | $query = " |
---|
| 228 | UPDATE ".CONFIG_TABLE." |
---|
| 229 | SET value = \"".implode(',', $user_idsOK)."\" |
---|
| 230 | WHERE param = 'UserAdvManager_Redir';"; |
---|
| 231 | |
---|
| 232 | pwg_query($query); |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | if (isset($_POST['validate']) and !is_admin()) |
---|
| 237 | { |
---|
| 238 | // Email without forbidden domains |
---|
| 239 | if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address'])) |
---|
| 240 | { |
---|
| 241 | if (ValidateEmailProvider($_POST['mail_address'])) |
---|
| 242 | { |
---|
| 243 | $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'"); |
---|
| 244 | unset($_POST['validate']); |
---|
| 245 | } |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | $typemail = 3; |
---|
| 249 | |
---|
| 250 | if (!empty($_POST['use_new_pwd'])) |
---|
| 251 | { |
---|
| 252 | $typemail = 2; |
---|
| 253 | |
---|
| 254 | // Password enforcement control |
---|
| 255 | if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14])) |
---|
| 256 | { |
---|
| 257 | $PasswordCheck = testpassword($_POST['use_new_pwd']); |
---|
| 258 | |
---|
| 259 | if ($PasswordCheck < $conf_UAM[14]) |
---|
| 260 | { |
---|
| 261 | $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); |
---|
| 262 | $template->append('errors', l10n_args($message).$conf_UAM[14]); |
---|
| 263 | unset($_POST['use_new_pwd']); |
---|
| 264 | unset($_POST['validate']); |
---|
| 265 | } |
---|
| 266 | } |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | // Sending registration confirmation by email |
---|
| 270 | if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) |
---|
| 271 | { |
---|
| 272 | $confirm_mail_need = false; |
---|
| 273 | |
---|
| 274 | if (!empty($_POST['mail_address'])) |
---|
| 275 | { |
---|
| 276 | $query = ' |
---|
| 277 | SELECT '.$conf['user_fields']['email'].' AS email |
---|
| 278 | FROM '.USERS_TABLE.' |
---|
| 279 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
| 280 | ;'; |
---|
| 281 | |
---|
| 282 | list($current_email) = pwg_db_fetch_row(pwg_query($query)); |
---|
| 283 | |
---|
| 284 | // This is to send a new validation key |
---|
| 285 | if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true')) |
---|
| 286 | |
---|
| 287 | $confirm_mail_need = true; |
---|
| 288 | |
---|
| 289 | // This is to set the user to "waiting" group or status until admin validation |
---|
| 290 | if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) |
---|
| 291 | |
---|
| 292 | setgroup($register_user['id']);// Set to "waiting" group or status until admin validation |
---|
| 293 | $confirm_mail_need = false; |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | if ((!empty($_POST['use_new_pwd']) and (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or $confirm_mail_need)) |
---|
| 297 | { |
---|
| 298 | $query = ' |
---|
| 299 | SELECT '.$conf['user_fields']['username'].' |
---|
| 300 | FROM '.USERS_TABLE.' |
---|
| 301 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
| 302 | ;'; |
---|
| 303 | |
---|
| 304 | list($username) = pwg_db_fetch_row(pwg_query($query)); |
---|
| 305 | SendMail2User($typemail, $user['id'], $username, $_POST['use_new_pwd'], $_POST['mail_address'], $confirm_mail_need); |
---|
| 306 | } |
---|
| 307 | } |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | /** |
---|
| 312 | * Triggered on login_success |
---|
| 313 | * |
---|
[8065] | 314 | * Triggers scheduled tasks at login |
---|
| 315 | * Redirects a visitor (except for admins, webmasters and generic statuses) to his profile.php page (Thx to LucMorizur) |
---|
[7968] | 316 | * |
---|
| 317 | */ |
---|
[8065] | 318 | function UAM_LoginTasks() |
---|
[7968] | 319 | { |
---|
| 320 | global $conf, $user; |
---|
| 321 | |
---|
| 322 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 323 | |
---|
[8087] | 324 | // Performing scheduled tasks |
---|
| 325 | if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true')) |
---|
[8065] | 326 | { |
---|
[8087] | 327 | UAM_ScheduledTasks(); |
---|
[8065] | 328 | } |
---|
| 329 | |
---|
[8087] | 330 | if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true')) |
---|
| 331 | { |
---|
| 332 | // Performing redirection |
---|
| 333 | $query =' |
---|
[7968] | 334 | SELECT user_id, status |
---|
| 335 | FROM '.USER_INFOS_TABLE.' |
---|
| 336 | WHERE user_id = '.$user['id'].' |
---|
| 337 | ;'; |
---|
[8087] | 338 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[8065] | 339 | |
---|
[8087] | 340 | if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic") |
---|
| 341 | { |
---|
| 342 | $user_idsOK = array(); |
---|
| 343 | if (!UAM_check_profile($user['id'], $user_idsOK)) |
---|
| 344 | redirect(PHPWG_ROOT_PATH.'profile.php'); |
---|
| 345 | } |
---|
[7968] | 346 | } |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | /** |
---|
[8065] | 350 | * Triggered on UAM_LoginTasks() |
---|
[7968] | 351 | * |
---|
[8065] | 352 | * Executes optional post-login tasks |
---|
[7968] | 353 | * |
---|
| 354 | */ |
---|
[8065] | 355 | function UAM_ScheduledTasks() |
---|
[7968] | 356 | { |
---|
[8065] | 357 | global $conf, $user, $page; |
---|
[7968] | 358 | |
---|
| 359 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[8065] | 360 | |
---|
| 361 | $collection = array(); |
---|
[8087] | 362 | $reminder = false; |
---|
[8065] | 363 | |
---|
| 364 | $page['filtered_users'] = get_ghosts_autotasks(); |
---|
[7968] | 365 | |
---|
[8087] | 366 | foreach($page['filtered_users'] as $listed_user) |
---|
| 367 | { |
---|
| 368 | array_push($collection, $listed_user['id']); |
---|
| 369 | } |
---|
[8065] | 370 | |
---|
[8087] | 371 | // Ghost accounts auto group or status downgrade with or without information email sending and autodeletion if user already reminded |
---|
[8092] | 372 | if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true') and ((isset($conf_UAM[26]) and $conf_UAM[26] <> -1) or (isset($conf_UAM[27]) and $conf_UAM[27] <> -1))) |
---|
[8087] | 373 | { |
---|
[8065] | 374 | if (count($collection) > 0) |
---|
| 375 | { |
---|
[8087] | 376 | // Process if a non-admin nor webmaster user is logged |
---|
| 377 | if (in_array($user['id'], $collection)) |
---|
| 378 | { |
---|
[8065] | 379 | foreach ($collection as $user_id) |
---|
| 380 | { |
---|
[8087] | 381 | // Check lastvisit reminder state |
---|
| 382 | $query = ' |
---|
| 383 | SELECT reminder |
---|
| 384 | FROM '.USER_LASTVISIT_TABLE.' |
---|
| 385 | WHERE user_id = '.$user_id.';'; |
---|
| 386 | |
---|
| 387 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 388 | |
---|
| 389 | if (isset($result['reminder']) and $result['reminder'] == 'true') |
---|
| 390 | { |
---|
| 391 | $reminder = true; |
---|
| 392 | } |
---|
| 393 | else |
---|
| 394 | { |
---|
| 395 | $reminder = false; |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | // If never reminded before, set reminder True |
---|
| 399 | if (!$reminder) |
---|
| 400 | { |
---|
| 401 | // Reset of lastvisit date |
---|
| 402 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
| 403 | |
---|
| 404 | $query = " |
---|
| 405 | UPDATE ".USER_LASTVISIT_TABLE." |
---|
| 406 | SET lastvisit='".$dbnow."' |
---|
| 407 | WHERE user_id = '".$user_id."' |
---|
| 408 | ;"; |
---|
| 409 | pwg_query($query); |
---|
| 410 | |
---|
[8065] | 411 | // Auto change group and / or status |
---|
[8087] | 412 | // Delete user from all groups |
---|
| 413 | $query = " |
---|
[8065] | 414 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 415 | WHERE user_id = '".$user_id."' |
---|
| 416 | AND ( |
---|
| 417 | group_id = '".$conf_UAM[2]."' |
---|
| 418 | OR |
---|
| 419 | group_id = '".$conf_UAM[3]."' |
---|
| 420 | ) |
---|
| 421 | ;"; |
---|
| 422 | |
---|
[8087] | 423 | pwg_query($query); |
---|
[8065] | 424 | |
---|
[8087] | 425 | // Change user status |
---|
[8092] | 426 | if ($conf_UAM[27] <> -1) |
---|
[8087] | 427 | { |
---|
| 428 | $query = " |
---|
[8065] | 429 | UPDATE ".USER_INFOS_TABLE." |
---|
[8092] | 430 | SET status = '".$conf_UAM[27]."' |
---|
[8065] | 431 | WHERE user_id = '".$user_id."' |
---|
| 432 | ;"; |
---|
[8087] | 433 | pwg_query($query); |
---|
| 434 | } |
---|
[8065] | 435 | |
---|
[8087] | 436 | // Change user group |
---|
[8092] | 437 | if ($conf_UAM[26] <> -1) |
---|
[8087] | 438 | { |
---|
| 439 | $query = " |
---|
[8065] | 440 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 441 | (user_id, group_id) |
---|
| 442 | VALUES |
---|
[8092] | 443 | ('".$user_id."', '".$conf_UAM[26]."') |
---|
[8065] | 444 | ;"; |
---|
[8087] | 445 | pwg_query($query); |
---|
| 446 | } |
---|
[8065] | 447 | |
---|
[8087] | 448 | // Auto send email notification on group / status downgrade only if never reminded before |
---|
[8092] | 449 | if (isset($conf_UAM[23]) and $conf_UAM[23] == 'true') |
---|
[8087] | 450 | { |
---|
| 451 | // Set reminder true |
---|
| 452 | $query = " |
---|
| 453 | UPDATE ".USER_LASTVISIT_TABLE." |
---|
| 454 | SET reminder = 'true' |
---|
| 455 | WHERE user_id = '".$user_id."' |
---|
| 456 | ;"; |
---|
| 457 | pwg_query($query); |
---|
| 458 | |
---|
| 459 | // Reset confirmed user date_check |
---|
| 460 | $query = ' |
---|
[8065] | 461 | UPDATE '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 462 | SET date_check = NULL |
---|
| 463 | WHERE user_id = "'.$user_id.'" |
---|
| 464 | ;'; |
---|
[8087] | 465 | pwg_query($query); |
---|
[8065] | 466 | |
---|
[8087] | 467 | // Get users information for email notification |
---|
| 468 | $query = ' |
---|
| 469 | SELECT username, mail_address |
---|
[8065] | 470 | FROM '.USERS_TABLE.' |
---|
| 471 | WHERE id = '.$user_id.' |
---|
| 472 | ;'; |
---|
[8087] | 473 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[8065] | 474 | |
---|
[8087] | 475 | demotion_mail($user_id, $data['username'], $data['mail_address']); |
---|
| 476 | } |
---|
[8065] | 477 | } |
---|
[8087] | 478 | elseif ($reminder) // If user already reminded for ghost account |
---|
| 479 | { |
---|
| 480 | // delete account |
---|
| 481 | delete_user($user_id); |
---|
| 482 | } |
---|
[8065] | 483 | } |
---|
[8092] | 484 | |
---|
| 485 | if (!$reminder) // If user never reminded for ghost account |
---|
| 486 | { |
---|
| 487 | // Logged-in user cleanup |
---|
| 488 | invalidate_user_cache(); |
---|
| 489 | log_user($user['id'], false); |
---|
| 490 | redirect(make_index_url()); |
---|
| 491 | } |
---|
| 492 | elseif ($reminder) // If user already reminded for ghost account |
---|
| 493 | { |
---|
| 494 | // Logged-in user cleanup |
---|
| 495 | invalidate_user_cache(); |
---|
| 496 | log_user($user['id'], false); |
---|
| 497 | redirect(UAM_PATH.'del_account.php'); |
---|
| 498 | } |
---|
[8065] | 499 | } |
---|
[8087] | 500 | else // Process if an admin or webmaster user is logged |
---|
[8065] | 501 | { |
---|
| 502 | foreach ($collection as $user_id) |
---|
| 503 | { |
---|
[8087] | 504 | // Check lastvisit reminder state |
---|
| 505 | $query = ' |
---|
| 506 | SELECT reminder |
---|
| 507 | FROM '.USER_LASTVISIT_TABLE.' |
---|
| 508 | WHERE user_id = '.$user_id.';'; |
---|
| 509 | |
---|
| 510 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 511 | |
---|
| 512 | if (isset($result['reminder']) and $result['reminder'] == 'true') |
---|
| 513 | { |
---|
| 514 | $reminder = true; |
---|
| 515 | } |
---|
| 516 | else |
---|
| 517 | { |
---|
| 518 | $reminder = false; |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | // If never reminded before |
---|
| 522 | if (!$reminder) |
---|
| 523 | { |
---|
| 524 | // Reset of lastvisit date |
---|
| 525 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
| 526 | |
---|
| 527 | $query = " |
---|
| 528 | UPDATE ".USER_LASTVISIT_TABLE." |
---|
| 529 | SET lastvisit='".$dbnow."' |
---|
| 530 | WHERE user_id = '".$user_id."' |
---|
| 531 | ;"; |
---|
| 532 | pwg_query($query); |
---|
| 533 | |
---|
[8065] | 534 | // Auto change group and / or status |
---|
[8087] | 535 | // Delete user from all groups |
---|
| 536 | $query = " |
---|
[8065] | 537 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 538 | WHERE user_id = '".$user_id."' |
---|
| 539 | AND ( |
---|
| 540 | group_id = '".$conf_UAM[2]."' |
---|
| 541 | OR |
---|
| 542 | group_id = '".$conf_UAM[3]."' |
---|
| 543 | ) |
---|
| 544 | ;"; |
---|
[8087] | 545 | pwg_query($query); |
---|
[8065] | 546 | |
---|
[8087] | 547 | // Change user status |
---|
[8092] | 548 | if ($conf_UAM[27] <> -1) |
---|
[8087] | 549 | { |
---|
| 550 | $query = " |
---|
[8065] | 551 | UPDATE ".USER_INFOS_TABLE." |
---|
[8092] | 552 | SET status = '".$conf_UAM[27]."' |
---|
[8065] | 553 | WHERE user_id = '".$user_id."' |
---|
| 554 | ;"; |
---|
[8087] | 555 | pwg_query($query); |
---|
| 556 | } |
---|
[8065] | 557 | |
---|
[8087] | 558 | // Change user group |
---|
[8092] | 559 | if ($conf_UAM[26] <> -1) |
---|
[8087] | 560 | { |
---|
| 561 | $query = " |
---|
[8065] | 562 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 563 | (user_id, group_id) |
---|
| 564 | VALUES |
---|
[8092] | 565 | ('".$user_id."', '".$conf_UAM[26]."') |
---|
[8065] | 566 | ;"; |
---|
[8087] | 567 | pwg_query($query); |
---|
| 568 | } |
---|
[8065] | 569 | |
---|
[8087] | 570 | // Auto send email notification on group / status downgrade |
---|
[8092] | 571 | if (isset($conf_UAM[23]) and $conf_UAM[23] == 'true') |
---|
[8087] | 572 | { |
---|
| 573 | // Set reminder true |
---|
| 574 | $query = " |
---|
| 575 | UPDATE ".USER_LASTVISIT_TABLE." |
---|
| 576 | SET reminder = 'true' |
---|
| 577 | WHERE user_id = '".$user_id."' |
---|
| 578 | ;"; |
---|
| 579 | pwg_query($query); |
---|
| 580 | |
---|
| 581 | // Reset confirmed user status to unvalidated |
---|
| 582 | $query = ' |
---|
[8065] | 583 | UPDATE '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 584 | SET date_check = NULL |
---|
| 585 | WHERE user_id = "'.$user_id.'" |
---|
| 586 | ;'; |
---|
[8087] | 587 | pwg_query($query); |
---|
[8065] | 588 | |
---|
[8087] | 589 | // Get users information for email notification |
---|
| 590 | $query = ' |
---|
[8065] | 591 | SELECT id, username, mail_address |
---|
| 592 | FROM '.USERS_TABLE.' |
---|
| 593 | WHERE id = '.$user_id.' |
---|
| 594 | ;'; |
---|
[8087] | 595 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[8065] | 596 | |
---|
[8087] | 597 | demotion_mail($user_id, $data['username'], $data['mail_address']); |
---|
| 598 | } |
---|
[8065] | 599 | } |
---|
[8087] | 600 | elseif ($reminder) // If user already reminded for ghost account |
---|
| 601 | { |
---|
| 602 | // delete account |
---|
| 603 | delete_user($user_id); |
---|
| 604 | } |
---|
[8065] | 605 | } |
---|
| 606 | } |
---|
| 607 | } |
---|
[7968] | 608 | } |
---|
| 609 | } |
---|
| 610 | |
---|
| 611 | /** |
---|
| 612 | * Triggered on init |
---|
| 613 | * |
---|
| 614 | * Check for forbidden email domains in admin's users management panel |
---|
| 615 | */ |
---|
| 616 | function UAM_InitPage() |
---|
| 617 | { |
---|
| 618 | load_language('plugin.lang', UAM_PATH); |
---|
| 619 | global $conf, $template, $page, $lang, $errors; |
---|
| 620 | |
---|
| 621 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 622 | |
---|
| 623 | // Admin user management |
---|
| 624 | if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list') |
---|
| 625 | { |
---|
| 626 | if (isset($_POST['submit_add'])) |
---|
| 627 | { |
---|
| 628 | // Email without forbidden domains |
---|
| 629 | if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email'])) |
---|
| 630 | { |
---|
| 631 | $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'"); |
---|
| 632 | unset($_POST['submit_add']); |
---|
| 633 | } |
---|
| 634 | } |
---|
| 635 | } |
---|
| 636 | } |
---|
| 637 | |
---|
[9136] | 638 | |
---|
[7968] | 639 | /** |
---|
[9136] | 640 | * Triggered on render_lost_password_mail_content |
---|
| 641 | * |
---|
| 642 | * Adds a customized text in lost password email content |
---|
| 643 | * Added text is inserted before users login name and new password |
---|
| 644 | * |
---|
| 645 | * @param : Standard Piwigo email content |
---|
| 646 | * |
---|
| 647 | * @return : Customized content added to standard content |
---|
| 648 | * |
---|
| 649 | */ |
---|
| 650 | function UAM_lost_password_mail_content($infos) |
---|
| 651 | { |
---|
| 652 | global $conf; |
---|
| 653 | |
---|
| 654 | load_language('plugin.lang', UAM_PATH); |
---|
| 655 | |
---|
| 656 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 657 | |
---|
| 658 | if (isset($conf_UAM[29]) and $conf_UAM[29] == 'true') |
---|
| 659 | { |
---|
[9161] | 660 | // Management of Extension flags ([username], [mygallery]) |
---|
| 661 | $patterns[] = '#\[username\]#i'; |
---|
| 662 | $replacements[] = stripslashes($row['username']); |
---|
| 663 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 664 | $replacements[] = $conf['gallery_title']; |
---|
| 665 | |
---|
| 666 | $infos = preg_replace($patterns, $replacements, $conf_UAM[30])."\n"."\n".$infos; |
---|
[9136] | 667 | } |
---|
| 668 | return $infos; |
---|
| 669 | } |
---|
| 670 | |
---|
| 671 | |
---|
| 672 | /** |
---|
[7968] | 673 | * Triggered on user_comment_check |
---|
| 674 | * |
---|
| 675 | * checks if author is mandatory and set on comments post |
---|
| 676 | * |
---|
| 677 | * @param : comment action, comment |
---|
| 678 | * |
---|
| 679 | * @return : comment action |
---|
| 680 | * |
---|
| 681 | */ |
---|
| 682 | function UAM_CheckEmptyCommentAuthor($comment_action, $comm) |
---|
| 683 | { |
---|
| 684 | load_language('plugin.lang', UAM_PATH); |
---|
| 685 | global $infos, $conf, $template; |
---|
| 686 | |
---|
| 687 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 688 | |
---|
| 689 | // User creation OR update |
---|
| 690 | if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest') |
---|
| 691 | { |
---|
| 692 | $comment_action = 'reject'; |
---|
| 693 | |
---|
| 694 | array_push($infos, l10n('UAM_Empty Author')); |
---|
| 695 | } |
---|
| 696 | |
---|
| 697 | return $comment_action; |
---|
| 698 | } |
---|
| 699 | |
---|
| 700 | /** |
---|
| 701 | * Function called from main.inc.php to send validation email |
---|
| 702 | * |
---|
| 703 | * @param : Type of email, user id, username, email address, confirmation (optional) |
---|
| 704 | * |
---|
| 705 | */ |
---|
[5056] | 706 | function SendMail2User($typemail, $id, $username, $password, $email, $confirm) |
---|
| 707 | { |
---|
[5064] | 708 | global $conf; |
---|
[5056] | 709 | |
---|
[5181] | 710 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 711 | |
---|
| 712 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
| 713 | |
---|
| 714 | $infos1_perso = ""; |
---|
| 715 | $infos2_perso = ""; |
---|
| 716 | |
---|
[7968] | 717 | // We have to get the user's language in database |
---|
[5056] | 718 | $query =' |
---|
| 719 | SELECT user_id, language |
---|
| 720 | FROM '.USER_INFOS_TABLE.' |
---|
| 721 | WHERE user_id = '.$id.' |
---|
| 722 | ;'; |
---|
[5633] | 723 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 724 | |
---|
[7968] | 725 | // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language |
---|
[5056] | 726 | if (empty($data)) |
---|
| 727 | { |
---|
[7968] | 728 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[5056] | 729 | $language = pwg_get_session_var( 'lang_switch', $user['language'] ); |
---|
| 730 | switch_lang_to($language); |
---|
| 731 | } |
---|
| 732 | else |
---|
| 733 | { |
---|
[7968] | 734 | // And switch gallery to this language before using personalized and multilangual contents |
---|
| 735 | $language = $data['language']; // Usefull for debugging |
---|
[5056] | 736 | switch_lang_to($data['language']); |
---|
[5181] | 737 | load_language('plugin.lang', UAM_PATH); |
---|
[5056] | 738 | } |
---|
| 739 | |
---|
| 740 | switch($typemail) |
---|
| 741 | { |
---|
| 742 | case 1: |
---|
| 743 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Add of %s', stripslashes($username))); |
---|
| 744 | $password = $password <> '' ? $password : l10n('UAM_empty_pwd'); |
---|
| 745 | |
---|
[6354] | 746 | if (isset($conf_UAM[9]) and $conf_UAM[9] <> '') |
---|
[5056] | 747 | { |
---|
[9161] | 748 | // Management of Extension flags ([username], [mygallery]) |
---|
| 749 | $patterns[] = '#\[username\]#i'; |
---|
| 750 | $replacements[] = $username; |
---|
| 751 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 752 | $replacements[] = $conf['gallery_title']; |
---|
| 753 | |
---|
[5056] | 754 | if (function_exists('get_user_language_desc')) |
---|
| 755 | { |
---|
[9161] | 756 | $infos1_perso = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[9]))."\n\n"; |
---|
[5056] | 757 | } |
---|
[9161] | 758 | else $infos1_perso = l10n(preg_replace($patterns, $replacements, $conf_UAM[9]))."\n\n"; |
---|
[5056] | 759 | } |
---|
| 760 | |
---|
| 761 | break; |
---|
| 762 | |
---|
| 763 | case 2: |
---|
| 764 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Update of %s', stripslashes($username))); |
---|
| 765 | $password = $password <> '' ? $password : l10n('UAM_empty_pwd'); |
---|
| 766 | |
---|
| 767 | break; |
---|
| 768 | |
---|
| 769 | case 3: |
---|
| 770 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Update of %s', stripslashes($username))); |
---|
| 771 | $password = $password <> '' ? $password : l10n('UAM_no_update_pwd'); |
---|
| 772 | |
---|
| 773 | break; |
---|
| 774 | } |
---|
| 775 | |
---|
| 776 | if (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') |
---|
| 777 | { |
---|
| 778 | $infos1 = array( |
---|
| 779 | get_l10n_args('infos_mail %s', stripslashes($username)), |
---|
| 780 | get_l10n_args('User: %s', stripslashes($username)), |
---|
| 781 | get_l10n_args('Password: %s', $password), |
---|
| 782 | get_l10n_args('Email: %s', $email), |
---|
| 783 | get_l10n_args('', ''), |
---|
| 784 | ); |
---|
| 785 | } |
---|
| 786 | |
---|
| 787 | |
---|
[6354] | 788 | if ( isset($conf_UAM[1]) and $conf_UAM[1] == 'true' and $confirm) |
---|
[5056] | 789 | { |
---|
| 790 | $infos2 = array |
---|
| 791 | ( |
---|
| 792 | get_l10n_args('Link: %s', AddConfirmMail($id, $email)), |
---|
| 793 | get_l10n_args('', ''), |
---|
| 794 | ); |
---|
| 795 | |
---|
[6354] | 796 | if (isset($conf_UAM[10]) and $conf_UAM[10] <> '') |
---|
[5056] | 797 | { |
---|
[9161] | 798 | // Management of Extension flags ([username], [mygallery]) |
---|
| 799 | $patterns[] = '#\[username\]#i'; |
---|
| 800 | $replacements[] = $username; |
---|
| 801 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 802 | $replacements[] = $conf['gallery_title']; |
---|
| 803 | |
---|
[5056] | 804 | if (function_exists('get_user_language_desc')) |
---|
| 805 | { |
---|
[9161] | 806 | $infos2_perso = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[10]))."\n\n"; |
---|
[5056] | 807 | } |
---|
[9161] | 808 | else $infos2_perso = l10n(preg_replace($patterns, $replacements, $conf_UAM[10]))."\n\n"; |
---|
[5056] | 809 | } |
---|
| 810 | } |
---|
| 811 | |
---|
[7968] | 812 | // ******************************************************** |
---|
| 813 | // **** Pending code since to find how to make it work **** |
---|
| 814 | // ******************************************************** |
---|
[5084] | 815 | // Testing if FCK Editor is used. Then decoding htmlchars to avoid problems with pwg_mail() |
---|
| 816 | /*$areas = array(); |
---|
| 817 | array_push( $areas,'UAM_MailInfo_Text','UAM_ConfirmMail_Text'); |
---|
| 818 | |
---|
| 819 | if (function_exists('set_fckeditor_instance')) |
---|
| 820 | { |
---|
| 821 | $fcke_config = unserialize($conf['FCKEditor']); |
---|
| 822 | foreach($areas as $area) |
---|
| 823 | { |
---|
| 824 | if (isset($fcke_config['UAM_MailInfo_Text']) and $fcke_config['UAM_MailInfo_Text'] = true) |
---|
| 825 | { |
---|
| 826 | $infos1_perso = html_entity_decode($infos1_perso,ENT_QUOTES,UTF-8); |
---|
| 827 | } |
---|
| 828 | |
---|
| 829 | if (isset($fcke_config['UAM_ConfirmMail_Text']) and $fcke_config['UAM_ConfirmMail_Text'] = true) |
---|
| 830 | { |
---|
| 831 | $infos2_perso = html_entity_decode($infos2_perso,ENT_QUOTES,UTF-8); |
---|
| 832 | } |
---|
| 833 | } |
---|
| 834 | }*/ |
---|
| 835 | |
---|
| 836 | |
---|
[7968] | 837 | // Sending the email with subject and contents |
---|
[5056] | 838 | pwg_mail($email, array( |
---|
| 839 | 'subject' => $subject, |
---|
| 840 | 'content' => (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(), |
---|
| 841 | )); |
---|
| 842 | |
---|
[7968] | 843 | // ********************** |
---|
| 844 | // Email sending debugger |
---|
| 845 | // This is only to trace |
---|
| 846 | // the send of emails for |
---|
| 847 | // debugging |
---|
| 848 | // ********************** |
---|
[5056] | 849 | //$content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(); |
---|
| 850 | //MailLog($email,$subject,$content,$language); |
---|
[7968] | 851 | // ********************** |
---|
[5056] | 852 | |
---|
[7968] | 853 | // Switching back to default language |
---|
[5056] | 854 | switch_lang_back(); |
---|
| 855 | } |
---|
| 856 | |
---|
[7968] | 857 | /** |
---|
| 858 | * Function called from UAM_admin.php to resend validation email with or without new validation key |
---|
| 859 | * |
---|
| 860 | * @param : Type of email, user id, username, email address, confirmation (optional) |
---|
| 861 | * |
---|
| 862 | */ |
---|
[5056] | 863 | function ResendMail2User($typemail, $user_id, $username, $email, $confirm) |
---|
| 864 | { |
---|
[5064] | 865 | global $conf; |
---|
[5056] | 866 | |
---|
[5181] | 867 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 868 | |
---|
[5181] | 869 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[5056] | 870 | |
---|
| 871 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
| 872 | |
---|
[7968] | 873 | // We have to get the user's language in database |
---|
[5056] | 874 | $query =' |
---|
| 875 | SELECT user_id, language |
---|
| 876 | FROM '.USER_INFOS_TABLE.' |
---|
| 877 | WHERE user_id = '.$user_id.' |
---|
| 878 | ;'; |
---|
[5633] | 879 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 880 | $language = $data['language']; |
---|
| 881 | |
---|
[7968] | 882 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[5056] | 883 | switch_lang_to($data['language']); |
---|
| 884 | |
---|
[5181] | 885 | load_language('plugin.lang', UAM_PATH); |
---|
[5056] | 886 | |
---|
| 887 | switch($typemail) |
---|
| 888 | { |
---|
| 889 | case 1: |
---|
| 890 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_with_key_of_%s', $username)); |
---|
| 891 | |
---|
| 892 | if (isset($conf_UAM_ConfirmMail[2]) and $conf_UAM_ConfirmMail[2] <> '' and isset($conf_UAM_ConfirmMail[3]) and $conf_UAM_ConfirmMail[3] == 'true' and $confirm) |
---|
| 893 | { |
---|
[9161] | 894 | // Management of Extension flags ([username], [mygallery]) |
---|
| 895 | $patterns[] = '#\[username\]#i'; |
---|
| 896 | $replacements[] = $username; |
---|
| 897 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 898 | $replacements[] = $conf['gallery_title']; |
---|
| 899 | |
---|
[5056] | 900 | if (function_exists('get_user_language_desc')) |
---|
| 901 | { |
---|
[9161] | 902 | $infos1 = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[2]))."\n\n"; |
---|
[5056] | 903 | } |
---|
[9161] | 904 | else $infos1 = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[2]))."\n\n"; |
---|
[5056] | 905 | |
---|
| 906 | $infos2 = array |
---|
| 907 | ( |
---|
| 908 | get_l10n_args('Link: %s', ResetConfirmMail($user_id)), |
---|
| 909 | get_l10n_args('', ''), |
---|
| 910 | ); |
---|
| 911 | } |
---|
| 912 | |
---|
[7968] | 913 | // Set reminder true |
---|
[5056] | 914 | $query = " |
---|
| 915 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
| 916 | SET reminder = 'true' |
---|
| 917 | WHERE user_id = '".$user_id."' |
---|
| 918 | ;"; |
---|
| 919 | pwg_query($query); |
---|
| 920 | |
---|
| 921 | break; |
---|
| 922 | |
---|
| 923 | case 2: |
---|
| 924 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_without_key_of_%s',$username)); |
---|
| 925 | |
---|
[9161] | 926 | if (isset($conf_UAM_ConfirmMail[4]) and $conf_UAM_ConfirmMail[4] <> '' and isset($conf_UAM_ConfirmMail[3]) and $conf_UAM_ConfirmMail[3] == 'true' and !$confirm) |
---|
[5056] | 927 | { |
---|
[9161] | 928 | // Management of Extension flags ([username], [mygallery]) |
---|
| 929 | $patterns[] = '#\[username\]#i'; |
---|
| 930 | $replacements[] = $username; |
---|
| 931 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 932 | $replacements[] = $conf['gallery_title']; |
---|
| 933 | |
---|
[5056] | 934 | if (function_exists('get_user_language_desc')) |
---|
| 935 | { |
---|
[9161] | 936 | $infos1 = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[4]))."\n\n"; |
---|
[5056] | 937 | } |
---|
[9161] | 938 | else $infos1 = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[4]))."\n\n"; |
---|
[5056] | 939 | } |
---|
| 940 | |
---|
[7968] | 941 | // Set reminder true |
---|
[5056] | 942 | $query = " |
---|
| 943 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
| 944 | SET reminder = 'true' |
---|
| 945 | WHERE user_id = '".$user_id."' |
---|
| 946 | ;"; |
---|
| 947 | pwg_query($query); |
---|
| 948 | |
---|
| 949 | break; |
---|
| 950 | } |
---|
| 951 | |
---|
| 952 | pwg_mail($email, array( |
---|
| 953 | 'subject' => $subject, |
---|
| 954 | 'content' => ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(), |
---|
| 955 | )); |
---|
| 956 | |
---|
[7968] | 957 | // ********************** |
---|
| 958 | // Email sending debugger |
---|
| 959 | // This is only to trace |
---|
| 960 | // the send of emails for |
---|
| 961 | // debugging |
---|
| 962 | // ********************** |
---|
[5056] | 963 | //$content = ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(); |
---|
| 964 | //MailLog($email,$subject,$content,$language); |
---|
[7968] | 965 | // ********************** |
---|
[5056] | 966 | |
---|
[7968] | 967 | // Switching back to default language |
---|
[5056] | 968 | switch_lang_back(); |
---|
| 969 | } |
---|
| 970 | |
---|
[7968] | 971 | /** |
---|
| 972 | * Function called from UAM_admin.php to send a reminder mail for ghost users |
---|
| 973 | * |
---|
| 974 | * @param : User id, username, email address |
---|
| 975 | * |
---|
| 976 | */ |
---|
[5056] | 977 | function ghostreminder($user_id, $username, $email) |
---|
| 978 | { |
---|
[5064] | 979 | global $conf; |
---|
[5056] | 980 | |
---|
[5181] | 981 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 982 | |
---|
| 983 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
| 984 | |
---|
| 985 | $infos1_perso = ""; |
---|
| 986 | |
---|
[7968] | 987 | // We have to get the user's language in database |
---|
[5056] | 988 | $query =' |
---|
| 989 | SELECT user_id, language |
---|
| 990 | FROM '.USER_INFOS_TABLE.' |
---|
| 991 | WHERE user_id = '.$user_id.' |
---|
| 992 | ;'; |
---|
[5633] | 993 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 994 | $language = $data['language']; |
---|
| 995 | |
---|
[7968] | 996 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[5056] | 997 | switch_lang_to($data['language']); |
---|
| 998 | |
---|
[5181] | 999 | load_language('plugin.lang', UAM_PATH); |
---|
[5056] | 1000 | |
---|
| 1001 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Ghost_reminder_of_%s', $username)); |
---|
| 1002 | |
---|
[6354] | 1003 | if (isset($conf_UAM[18]) and $conf_UAM[18] <> '' and isset($conf_UAM[16]) and $conf_UAM[16] == 'true') |
---|
[5056] | 1004 | { |
---|
[9161] | 1005 | // Management of Extension flags ([username], [mygallery]) |
---|
| 1006 | $patterns[] = '#\[username\]#i'; |
---|
| 1007 | $replacements[] = $username; |
---|
| 1008 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1009 | $replacements[] = $conf['gallery_title']; |
---|
| 1010 | |
---|
[5056] | 1011 | if (function_exists('get_user_language_desc')) |
---|
| 1012 | { |
---|
[9161] | 1013 | $infos1 = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[18]))."\n\n"; |
---|
[5056] | 1014 | } |
---|
| 1015 | else |
---|
| 1016 | { |
---|
[9161] | 1017 | $infos1 = l10n(preg_replace($patterns, $replacements, $conf_UAM[18]))."\n\n"; |
---|
[5056] | 1018 | } |
---|
| 1019 | |
---|
| 1020 | resetlastvisit($user_id); |
---|
| 1021 | } |
---|
| 1022 | |
---|
| 1023 | pwg_mail($email, array( |
---|
| 1024 | 'subject' => $subject, |
---|
| 1025 | 'content' => $infos1.get_absolute_root_url(), |
---|
| 1026 | )); |
---|
| 1027 | |
---|
[7968] | 1028 | // ********************** |
---|
| 1029 | // Email sending debugger |
---|
| 1030 | // This is only to trace |
---|
| 1031 | // the send of emails for |
---|
| 1032 | // debugging |
---|
| 1033 | // ********************** |
---|
[8092] | 1034 | //$content = $infos1.get_absolute_root_url(); |
---|
[5056] | 1035 | //MailLog($email,$subject,$content,$language); |
---|
[7968] | 1036 | // ********************** |
---|
[5056] | 1037 | |
---|
[7968] | 1038 | // Switching back to default language |
---|
[5056] | 1039 | switch_lang_back(); |
---|
| 1040 | } |
---|
| 1041 | |
---|
[7968] | 1042 | /** |
---|
[8065] | 1043 | * Function called from functions.inc.php to send notification email when user have been downgraded |
---|
| 1044 | * |
---|
[8092] | 1045 | * @param : user id, username, email address |
---|
[8065] | 1046 | * |
---|
| 1047 | */ |
---|
| 1048 | function demotion_mail($id, $username, $email) |
---|
| 1049 | { |
---|
| 1050 | global $conf; |
---|
| 1051 | |
---|
| 1052 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 1053 | |
---|
| 1054 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
| 1055 | |
---|
| 1056 | $custom_txt = ""; |
---|
| 1057 | |
---|
| 1058 | // We have to get the user's language in database |
---|
| 1059 | $query =' |
---|
| 1060 | SELECT user_id, language |
---|
| 1061 | FROM '.USER_INFOS_TABLE.' |
---|
| 1062 | WHERE user_id = '.$id.' |
---|
| 1063 | ;'; |
---|
| 1064 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 1065 | |
---|
| 1066 | // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language |
---|
| 1067 | if (empty($data)) |
---|
| 1068 | { |
---|
| 1069 | // And switch gallery to this language before using personalized and multilangual contents |
---|
| 1070 | $language = pwg_get_session_var( 'lang_switch', $user['language'] ); |
---|
| 1071 | switch_lang_to($language); |
---|
| 1072 | } |
---|
| 1073 | else |
---|
| 1074 | { |
---|
| 1075 | // And switch gallery to this language before using personalized and multilangual contents |
---|
| 1076 | $language = $data['language']; // Usefull for debugging |
---|
| 1077 | switch_lang_to($data['language']); |
---|
| 1078 | load_language('plugin.lang', UAM_PATH); |
---|
| 1079 | } |
---|
| 1080 | |
---|
| 1081 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Demotion of %s', stripslashes($username))); |
---|
| 1082 | |
---|
[8092] | 1083 | if (isset($conf_UAM[25]) and $conf_UAM[25] <> '') |
---|
[8065] | 1084 | { |
---|
[9161] | 1085 | // Management of Extension flags ([username], [mygallery]) |
---|
| 1086 | $patterns[] = '#\[username\]#i'; |
---|
| 1087 | $replacements[] = $username; |
---|
| 1088 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1089 | $replacements[] = $conf['gallery_title']; |
---|
| 1090 | |
---|
[8065] | 1091 | if (function_exists('get_user_language_desc')) |
---|
| 1092 | { |
---|
[9161] | 1093 | $custom_txt = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[25]))."\n\n"; |
---|
[8065] | 1094 | } |
---|
[9161] | 1095 | else $custom_txt = l10n(preg_replace($patterns, $replacements, $conf_UAM[25]))."\n\n"; |
---|
[8065] | 1096 | } |
---|
| 1097 | |
---|
| 1098 | $infos1 = array( |
---|
| 1099 | get_l10n_args('User: %s', stripslashes($username)), |
---|
| 1100 | get_l10n_args('Email: %s', $email), |
---|
| 1101 | get_l10n_args('', ''), |
---|
| 1102 | ); |
---|
| 1103 | |
---|
| 1104 | $infos2 = array |
---|
| 1105 | ( |
---|
| 1106 | get_l10n_args('Link: %s', ResetConfirmMail($id)), |
---|
| 1107 | get_l10n_args('', ''), |
---|
| 1108 | ); |
---|
| 1109 | |
---|
| 1110 | |
---|
| 1111 | // Sending the email with subject and contents |
---|
| 1112 | pwg_mail($email, array( |
---|
| 1113 | 'subject' => $subject, |
---|
| 1114 | 'content' => ($custom_txt.l10n_args($infos1)."\n\n".l10n_args($infos2)."\n\n").get_absolute_root_url(), |
---|
| 1115 | )); |
---|
| 1116 | |
---|
| 1117 | // ********************** |
---|
| 1118 | // Email sending debugger |
---|
| 1119 | // This is only to trace |
---|
| 1120 | // the send of emails for |
---|
| 1121 | // debugging |
---|
| 1122 | // ********************** |
---|
[8092] | 1123 | //$content = ($custom_txt.l10n_args($infos1)."\n\n".l10n_args($infos2)."\n\n").get_absolute_root_url(); |
---|
[8065] | 1124 | //MailLog($email,$subject,$content,$language); |
---|
| 1125 | // ********************** |
---|
| 1126 | |
---|
| 1127 | // Switching back to default language |
---|
| 1128 | switch_lang_back(); |
---|
| 1129 | } |
---|
| 1130 | |
---|
| 1131 | /** |
---|
[8092] | 1132 | * Function called from UAM_admin.php to send notification email when user registration have been manually validated by admin |
---|
| 1133 | * |
---|
| 1134 | * @param : user id |
---|
| 1135 | * |
---|
| 1136 | */ |
---|
| 1137 | function validation_mail($id) |
---|
| 1138 | { |
---|
| 1139 | global $conf; |
---|
| 1140 | |
---|
| 1141 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 1142 | |
---|
| 1143 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
| 1144 | |
---|
| 1145 | $custom_txt = ""; |
---|
| 1146 | |
---|
| 1147 | // We have to get the user's language in database |
---|
| 1148 | $query =' |
---|
| 1149 | SELECT user_id, language |
---|
| 1150 | FROM '.USER_INFOS_TABLE.' |
---|
| 1151 | WHERE user_id = '.$id.' |
---|
| 1152 | ;'; |
---|
| 1153 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 1154 | |
---|
| 1155 | // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language |
---|
| 1156 | if (empty($data)) |
---|
| 1157 | { |
---|
| 1158 | // And switch gallery to this language before using personalized and multilangual contents |
---|
| 1159 | $language = pwg_get_session_var( 'lang_switch', $user['language'] ); |
---|
| 1160 | switch_lang_to($language); |
---|
| 1161 | } |
---|
| 1162 | else |
---|
| 1163 | { |
---|
| 1164 | // And switch gallery to this language before using personalized and multilangual contents |
---|
| 1165 | $language = $data['language']; // Usefull for debugging |
---|
| 1166 | switch_lang_to($data['language']); |
---|
| 1167 | load_language('plugin.lang', UAM_PATH); |
---|
| 1168 | } |
---|
| 1169 | |
---|
| 1170 | // Retreive users email and user name from id |
---|
| 1171 | $query =' |
---|
| 1172 | SELECT id, username, mail_address |
---|
| 1173 | FROM '.USERS_TABLE.' |
---|
| 1174 | WHERE id = '.$id.' |
---|
| 1175 | ;'; |
---|
| 1176 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 1177 | |
---|
| 1178 | $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Validation of %s', stripslashes($result['username']))); |
---|
| 1179 | |
---|
| 1180 | if (isset($conf_UAM[28]) and $conf_UAM[28] <> '') |
---|
| 1181 | { |
---|
[9161] | 1182 | // Management of Extension flags ([username], [mygallery]) |
---|
| 1183 | $patterns[] = '#\[username\]#i'; |
---|
| 1184 | $replacements[] = $username; |
---|
| 1185 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1186 | $replacements[] = $conf['gallery_title']; |
---|
| 1187 | |
---|
[8092] | 1188 | if (function_exists('get_user_language_desc')) |
---|
| 1189 | { |
---|
[9161] | 1190 | $custom_txt = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[28]))."\n\n"; |
---|
[8092] | 1191 | } |
---|
[9161] | 1192 | else $custom_txt = l10n(preg_replace($patterns, $replacements, $conf_UAM[28]))."\n\n"; |
---|
[8092] | 1193 | } |
---|
| 1194 | |
---|
| 1195 | $infos = array( |
---|
| 1196 | get_l10n_args('User: %s', stripslashes($result['username'])), |
---|
| 1197 | get_l10n_args('Email: %s', $result['mail_address']), |
---|
| 1198 | get_l10n_args('', ''), |
---|
| 1199 | ); |
---|
| 1200 | |
---|
| 1201 | // Sending the email with subject and contents |
---|
| 1202 | pwg_mail($result['mail_address'], array( |
---|
| 1203 | 'subject' => $subject, |
---|
| 1204 | 'content' => (l10n_args($infos)."\n\n".$custom_txt), |
---|
| 1205 | )); |
---|
| 1206 | |
---|
| 1207 | // ********************** |
---|
| 1208 | // Email sending debugger |
---|
| 1209 | // This is only to trace |
---|
| 1210 | // the send of emails for |
---|
| 1211 | // debugging |
---|
| 1212 | // ********************** |
---|
| 1213 | //$email = $result['mail_address']; |
---|
| 1214 | //$content = (l10n_args($infos)."\n\n".$custom_txt); |
---|
| 1215 | //MailLog($email,$subject,$content,$language); |
---|
| 1216 | // ********************** |
---|
| 1217 | |
---|
| 1218 | // Switching back to default language |
---|
| 1219 | switch_lang_back(); |
---|
| 1220 | } |
---|
| 1221 | |
---|
| 1222 | /** |
---|
[7968] | 1223 | * Function called from functions AddConfirmMail and ResetConfirmMail for validation key generation |
---|
| 1224 | * |
---|
| 1225 | * @return : validation key |
---|
| 1226 | * |
---|
| 1227 | */ |
---|
[5056] | 1228 | function FindAvailableConfirmMailID() |
---|
| 1229 | { |
---|
| 1230 | while (true) |
---|
| 1231 | { |
---|
| 1232 | $id = generate_key(16); |
---|
| 1233 | $query = " |
---|
| 1234 | SELECT COUNT(*) |
---|
| 1235 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1236 | WHERE id = '".$id."' |
---|
| 1237 | ;"; |
---|
[5633] | 1238 | list($count) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 1239 | |
---|
| 1240 | if ($count == 0) |
---|
| 1241 | return $id; |
---|
| 1242 | } |
---|
| 1243 | } |
---|
| 1244 | |
---|
[7968] | 1245 | /** |
---|
| 1246 | * Function called from functions SendMail2User to process unvalidated users and generate validation key link |
---|
| 1247 | * |
---|
| 1248 | * @param : User id, email address |
---|
| 1249 | * |
---|
| 1250 | * @return : Build validation key in URL |
---|
| 1251 | * |
---|
| 1252 | */ |
---|
[5056] | 1253 | function AddConfirmMail($user_id, $email) |
---|
| 1254 | { |
---|
| 1255 | global $conf; |
---|
| 1256 | |
---|
[5181] | 1257 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1258 | $Confirm_Mail_ID = FindAvailableConfirmMailID(); |
---|
| 1259 | |
---|
[5633] | 1260 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1261 | |
---|
| 1262 | if (isset($Confirm_Mail_ID)) |
---|
| 1263 | { |
---|
| 1264 | $query = " |
---|
| 1265 | SELECT status |
---|
| 1266 | FROM ".USER_INFOS_TABLE." |
---|
| 1267 | WHERE user_id = '".$user_id."' |
---|
| 1268 | ;"; |
---|
[5633] | 1269 | list($status) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 1270 | |
---|
| 1271 | $query = " |
---|
| 1272 | INSERT INTO ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1273 | (id, user_id, mail_address, status, date_check) |
---|
| 1274 | VALUES |
---|
| 1275 | ('".$Confirm_Mail_ID."', '".$user_id."', '".$email."', '".$status."', null) |
---|
| 1276 | ;"; |
---|
| 1277 | pwg_query($query); |
---|
| 1278 | |
---|
[8065] | 1279 | // Delete user from all groups |
---|
[5056] | 1280 | $query = " |
---|
| 1281 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1282 | WHERE user_id = '".$user_id."' |
---|
| 1283 | AND ( |
---|
[6354] | 1284 | group_id = '".$conf_UAM[2]."' |
---|
| 1285 | OR |
---|
[5056] | 1286 | group_id = '".$conf_UAM[3]."' |
---|
| 1287 | ) |
---|
| 1288 | ;"; |
---|
| 1289 | pwg_query($query); |
---|
| 1290 | |
---|
[8065] | 1291 | // Set user unvalidated status |
---|
[6354] | 1292 | if (!is_admin() and $conf_UAM[8] <> -1) |
---|
[5056] | 1293 | { |
---|
| 1294 | $query = " |
---|
| 1295 | UPDATE ".USER_INFOS_TABLE." |
---|
[6354] | 1296 | SET status = '".$conf_UAM[8]."' |
---|
[5056] | 1297 | WHERE user_id = '".$user_id."' |
---|
| 1298 | ;"; |
---|
| 1299 | pwg_query($query); |
---|
| 1300 | } |
---|
| 1301 | |
---|
[8065] | 1302 | // Set user unvalidated group |
---|
| 1303 | if (!is_admin() and $conf_UAM[2] <> -1) |
---|
[5056] | 1304 | { |
---|
| 1305 | $query = " |
---|
| 1306 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 1307 | (user_id, group_id) |
---|
| 1308 | VALUES |
---|
[6354] | 1309 | ('".$user_id."', '".$conf_UAM[2]."') |
---|
[5056] | 1310 | ;"; |
---|
| 1311 | pwg_query($query); |
---|
| 1312 | } |
---|
| 1313 | |
---|
[6785] | 1314 | return get_absolute_root_url().UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID.'&userid='.$user_id; |
---|
[5056] | 1315 | } |
---|
| 1316 | } |
---|
| 1317 | |
---|
[7968] | 1318 | /** |
---|
| 1319 | * Function called from main.inc.php to set group to new users if manual validation is set |
---|
| 1320 | * |
---|
| 1321 | * @param : User id |
---|
| 1322 | * |
---|
| 1323 | * |
---|
| 1324 | */ |
---|
[6757] | 1325 | function setgroup($user_id) |
---|
| 1326 | { |
---|
| 1327 | global $conf; |
---|
| 1328 | |
---|
| 1329 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 1330 | |
---|
| 1331 | $query = " |
---|
| 1332 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1333 | WHERE user_id = '".$user_id."' |
---|
| 1334 | AND ( |
---|
| 1335 | group_id = '".$conf_UAM[2]."' |
---|
| 1336 | OR |
---|
| 1337 | group_id = '".$conf_UAM[3]."' |
---|
| 1338 | ) |
---|
| 1339 | ;"; |
---|
| 1340 | pwg_query($query); |
---|
| 1341 | |
---|
| 1342 | if (!is_admin() and $conf_UAM[8] <> -1) |
---|
| 1343 | { |
---|
| 1344 | $query = " |
---|
| 1345 | UPDATE ".USER_INFOS_TABLE." |
---|
| 1346 | SET status = '".$conf_UAM[8]."' |
---|
| 1347 | WHERE user_id = '".$user_id."' |
---|
| 1348 | ;"; |
---|
| 1349 | pwg_query($query); |
---|
| 1350 | } |
---|
| 1351 | |
---|
[8065] | 1352 | if (!is_admin() and $conf_UAM[2] <> -1) |
---|
[6757] | 1353 | { |
---|
| 1354 | $query = " |
---|
| 1355 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 1356 | (user_id, group_id) |
---|
| 1357 | VALUES |
---|
| 1358 | ('".$user_id."', '".$conf_UAM[2]."') |
---|
| 1359 | ;"; |
---|
| 1360 | pwg_query($query); |
---|
| 1361 | } |
---|
| 1362 | } |
---|
| 1363 | |
---|
[7968] | 1364 | /** |
---|
| 1365 | * Function called from UAM_admin.php to reset validation key |
---|
| 1366 | * |
---|
| 1367 | * @param : User id |
---|
| 1368 | * |
---|
| 1369 | * @return : Build validation key in URL |
---|
| 1370 | * |
---|
| 1371 | */ |
---|
[5056] | 1372 | function ResetConfirmMail($user_id) |
---|
| 1373 | { |
---|
| 1374 | global $conf; |
---|
| 1375 | |
---|
| 1376 | $Confirm_Mail_ID = FindAvailableConfirmMailID(); |
---|
| 1377 | |
---|
[5633] | 1378 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1379 | |
---|
| 1380 | if (isset($Confirm_Mail_ID)) |
---|
| 1381 | { |
---|
| 1382 | $query = " |
---|
| 1383 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1384 | SET id = '".$Confirm_Mail_ID."' |
---|
| 1385 | WHERE user_id = '".$user_id."' |
---|
| 1386 | ;"; |
---|
| 1387 | pwg_query($query); |
---|
| 1388 | |
---|
| 1389 | $query = " |
---|
| 1390 | UPDATE ".USER_INFOS_TABLE." |
---|
| 1391 | SET registration_date = '".$dbnow."' |
---|
| 1392 | WHERE user_id = '".$user_id."' |
---|
| 1393 | ;"; |
---|
| 1394 | pwg_query($query); |
---|
| 1395 | |
---|
[6785] | 1396 | return get_absolute_root_url().UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID.'&userid='.$user_id; |
---|
[5056] | 1397 | } |
---|
| 1398 | } |
---|
| 1399 | |
---|
[7968] | 1400 | /** |
---|
| 1401 | * Function called from functions.inc.php to reset last visit date after sending a reminder |
---|
| 1402 | * |
---|
| 1403 | * @param : User id |
---|
| 1404 | * |
---|
| 1405 | */ |
---|
[5056] | 1406 | function resetlastvisit($user_id) |
---|
| 1407 | { |
---|
| 1408 | global $conf; |
---|
| 1409 | |
---|
[5633] | 1410 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1411 | |
---|
| 1412 | $query = " |
---|
| 1413 | UPDATE ".USER_LASTVISIT_TABLE." |
---|
| 1414 | SET lastvisit = '".$dbnow."', reminder = 'true' |
---|
| 1415 | WHERE user_id = '".$user_id."' |
---|
| 1416 | ;"; |
---|
| 1417 | pwg_query($query); |
---|
| 1418 | } |
---|
| 1419 | |
---|
| 1420 | |
---|
[7968] | 1421 | /** |
---|
| 1422 | * Function called from main.inc.php - Triggered on user deletion |
---|
| 1423 | * |
---|
| 1424 | */ |
---|
[5056] | 1425 | function DeleteConfirmMail($user_id) |
---|
| 1426 | { |
---|
| 1427 | $query = " |
---|
| 1428 | DELETE FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1429 | WHERE user_id = '".$user_id."' |
---|
| 1430 | ;"; |
---|
| 1431 | pwg_query($query); |
---|
| 1432 | } |
---|
| 1433 | |
---|
[7968] | 1434 | /** |
---|
| 1435 | * Function called from main.inc.php - Triggered on user deletion |
---|
| 1436 | * |
---|
| 1437 | */ |
---|
[5056] | 1438 | function DeleteLastVisit($user_id) |
---|
| 1439 | { |
---|
| 1440 | $query = " |
---|
| 1441 | DELETE FROM ".USER_LASTVISIT_TABLE." |
---|
| 1442 | WHERE user_id = '".$user_id."' |
---|
| 1443 | ;"; |
---|
| 1444 | pwg_query($query); |
---|
| 1445 | } |
---|
| 1446 | |
---|
[7968] | 1447 | /** |
---|
| 1448 | * Function called from main.inc.php - Triggered on user deletion |
---|
| 1449 | * |
---|
| 1450 | * @param : User id |
---|
| 1451 | * |
---|
| 1452 | */ |
---|
[6775] | 1453 | function DeleteRedir($user_id) |
---|
| 1454 | { |
---|
| 1455 | $tab = array(); |
---|
| 1456 | |
---|
[6785] | 1457 | $query = ' |
---|
[6775] | 1458 | SELECT value |
---|
[6785] | 1459 | FROM '.CONFIG_TABLE.' |
---|
| 1460 | WHERE param = "UserAdvManager_Redir" |
---|
| 1461 | ;'; |
---|
[6775] | 1462 | |
---|
| 1463 | $tab = pwg_db_fetch_row(pwg_query($query)); |
---|
| 1464 | |
---|
| 1465 | $values = explode(',', $tab[0]); |
---|
| 1466 | |
---|
| 1467 | unset($values[array_search($user_id, $values)]); |
---|
| 1468 | |
---|
| 1469 | $query = " |
---|
| 1470 | UPDATE ".CONFIG_TABLE." |
---|
| 1471 | SET value = \"".implode(',', $values)."\" |
---|
| 1472 | WHERE param = 'UserAdvManager_Redir';"; |
---|
| 1473 | |
---|
| 1474 | pwg_query($query); |
---|
| 1475 | } |
---|
| 1476 | |
---|
[7968] | 1477 | /** |
---|
| 1478 | * Function called from ConfirmMail.php to verify validation key used by user according time limit |
---|
| 1479 | * Return true is key validation is OK else return false |
---|
| 1480 | * |
---|
| 1481 | * @param : User id |
---|
| 1482 | * |
---|
| 1483 | * @return : Bool |
---|
| 1484 | * |
---|
| 1485 | */ |
---|
[5056] | 1486 | function VerifyConfirmMail($id) |
---|
| 1487 | { |
---|
| 1488 | global $conf; |
---|
| 1489 | |
---|
| 1490 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 1491 | |
---|
[5181] | 1492 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1493 | |
---|
[5181] | 1494 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[5056] | 1495 | |
---|
| 1496 | $query = " |
---|
| 1497 | SELECT COUNT(*) |
---|
| 1498 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1499 | WHERE id = '".$id."' |
---|
| 1500 | ;"; |
---|
[5633] | 1501 | list($count) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 1502 | |
---|
| 1503 | if ($count == 1) |
---|
| 1504 | { |
---|
| 1505 | $query = " |
---|
| 1506 | SELECT user_id, status, date_check |
---|
| 1507 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1508 | WHERE id = '".$id."' |
---|
| 1509 | ;"; |
---|
[5633] | 1510 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 1511 | |
---|
[8065] | 1512 | //if (!empty($data) and isset($data['user_id']) and !isset($data['date_check'])) |
---|
| 1513 | if (!empty($data) and isset($data['user_id'])) |
---|
[5056] | 1514 | { |
---|
| 1515 | $query = " |
---|
| 1516 | SELECT registration_date |
---|
| 1517 | FROM ".USER_INFOS_TABLE." |
---|
| 1518 | WHERE user_id = '".$data['user_id']."' |
---|
| 1519 | ;"; |
---|
[5633] | 1520 | list($registration_date) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 1521 | |
---|
[7968] | 1522 | // Time limit process |
---|
| 1523 | // ******************************************** |
---|
[5056] | 1524 | if (!empty($registration_date)) |
---|
| 1525 | { |
---|
| 1526 | // Verify Confirmmail with time limit ON |
---|
| 1527 | if (isset ($conf_UAM_ConfirmMail[1])) |
---|
| 1528 | { |
---|
| 1529 | // dates formating and compare |
---|
| 1530 | $today = date("d-m-Y"); // Get today's date |
---|
| 1531 | list($day, $month, $year) = explode('-', $today); // explode date of today |
---|
| 1532 | $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp |
---|
| 1533 | |
---|
| 1534 | list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date |
---|
| 1535 | list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date |
---|
| 1536 | $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp |
---|
| 1537 | |
---|
| 1538 | $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps |
---|
| 1539 | $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days |
---|
| 1540 | |
---|
| 1541 | // Condition with the value set for time limit |
---|
| 1542 | if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set |
---|
| 1543 | { |
---|
[5633] | 1544 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1545 | |
---|
| 1546 | $query = ' |
---|
| 1547 | UPDATE '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 1548 | SET date_check="'.$dbnow.'" |
---|
| 1549 | WHERE id = "'.$id.'" |
---|
| 1550 | ;'; |
---|
| 1551 | pwg_query($query); |
---|
| 1552 | |
---|
[6354] | 1553 | if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group |
---|
[5056] | 1554 | { |
---|
| 1555 | $query = " |
---|
| 1556 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1557 | WHERE user_id = '".$data['user_id']."' |
---|
[6354] | 1558 | AND group_id = '".$conf_UAM[2]."' |
---|
[5056] | 1559 | ;"; |
---|
| 1560 | pwg_query($query); |
---|
| 1561 | } |
---|
| 1562 | |
---|
[6354] | 1563 | if ($conf_UAM[3] <> -1) // Add user to validated users group |
---|
[5056] | 1564 | { |
---|
| 1565 | $query = " |
---|
| 1566 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 1567 | (user_id, group_id) |
---|
| 1568 | VALUES |
---|
[6354] | 1569 | ('".$data['user_id']."', '".$conf_UAM[3]."') |
---|
[5056] | 1570 | ;"; |
---|
| 1571 | pwg_query($query); |
---|
| 1572 | } |
---|
| 1573 | |
---|
[6354] | 1574 | if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status |
---|
[5056] | 1575 | { |
---|
| 1576 | $query = " |
---|
| 1577 | UPDATE ".USER_INFOS_TABLE." |
---|
[6354] | 1578 | SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[4])."' |
---|
[5056] | 1579 | WHERE user_id = '".$data['user_id']."' |
---|
| 1580 | ;"; |
---|
| 1581 | pwg_query($query); |
---|
| 1582 | } |
---|
| 1583 | // Refresh user's category cache |
---|
| 1584 | invalidate_user_cache(); |
---|
| 1585 | |
---|
| 1586 | return true; |
---|
| 1587 | } |
---|
| 1588 | elseif ($deltadays > $conf_UAM_ConfirmMail[1]) // If timelimit exeeds |
---|
| 1589 | { |
---|
| 1590 | return false; |
---|
| 1591 | } |
---|
| 1592 | } |
---|
| 1593 | // Verify Confirmmail with time limit OFF |
---|
| 1594 | else |
---|
| 1595 | { |
---|
[5633] | 1596 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1597 | |
---|
| 1598 | $query = ' |
---|
| 1599 | UPDATE '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 1600 | SET date_check="'.$dbnow.'" |
---|
| 1601 | WHERE id = "'.$id.'" |
---|
| 1602 | ;'; |
---|
| 1603 | pwg_query($query); |
---|
| 1604 | |
---|
[6354] | 1605 | if ($conf_UAM[2] <> -1) |
---|
[5056] | 1606 | { |
---|
| 1607 | $query = " |
---|
| 1608 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1609 | WHERE user_id = '".$data['user_id']."' |
---|
[6354] | 1610 | AND group_id = '".$conf_UAM[2]."' |
---|
[5056] | 1611 | ;"; |
---|
| 1612 | pwg_query($query); |
---|
| 1613 | } |
---|
| 1614 | |
---|
[6354] | 1615 | if ($conf_UAM[3] <> -1) |
---|
[5056] | 1616 | { |
---|
| 1617 | $query = " |
---|
| 1618 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1619 | WHERE user_id = '".$data['user_id']."' |
---|
[6354] | 1620 | AND group_id = '".$conf_UAM[3]."' |
---|
[5056] | 1621 | ;"; |
---|
| 1622 | pwg_query($query); |
---|
| 1623 | |
---|
| 1624 | $query = " |
---|
| 1625 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 1626 | (user_id, group_id) |
---|
| 1627 | VALUES |
---|
[6354] | 1628 | ('".$data['user_id']."', '".$conf_UAM[3]."') |
---|
[5056] | 1629 | ;"; |
---|
| 1630 | pwg_query($query); |
---|
| 1631 | } |
---|
| 1632 | |
---|
[6354] | 1633 | if (($conf_UAM[4] <> -1 or isset($data['status']))) |
---|
[5056] | 1634 | { |
---|
| 1635 | $query = " |
---|
| 1636 | UPDATE ".USER_INFOS_TABLE." |
---|
[6354] | 1637 | SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[4])."' |
---|
[5056] | 1638 | WHERE user_id = '".$data['user_id']."' |
---|
| 1639 | ;"; |
---|
| 1640 | pwg_query($query); |
---|
| 1641 | } |
---|
| 1642 | // Refresh user's category cache |
---|
| 1643 | invalidate_user_cache(); |
---|
| 1644 | |
---|
| 1645 | return true; |
---|
| 1646 | } |
---|
| 1647 | } |
---|
| 1648 | } |
---|
| 1649 | } |
---|
| 1650 | else |
---|
| 1651 | return false; |
---|
| 1652 | } |
---|
| 1653 | |
---|
[7968] | 1654 | /** |
---|
| 1655 | * Function called from UAM_admin.php to force users validation by admin |
---|
| 1656 | * |
---|
| 1657 | * @param : User id |
---|
| 1658 | * |
---|
| 1659 | */ |
---|
[5056] | 1660 | function ForceValidation($id) |
---|
| 1661 | { |
---|
| 1662 | global $conf; |
---|
| 1663 | |
---|
[5181] | 1664 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1665 | |
---|
[8072] | 1666 | if (isset($conf_UAM[1]) and $conf_UAM[1] == 'true') |
---|
[5056] | 1667 | { |
---|
[8072] | 1668 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1669 | |
---|
[8072] | 1670 | $query = " |
---|
[5056] | 1671 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1672 | SET date_check='".$dbnow."' |
---|
[8072] | 1673 | WHERE user_id = '".$id."' |
---|
[5056] | 1674 | ;"; |
---|
[8072] | 1675 | pwg_query($query); |
---|
[5056] | 1676 | |
---|
[8072] | 1677 | if ($conf_UAM[2] <> -1) |
---|
| 1678 | { |
---|
| 1679 | $query = " |
---|
[5056] | 1680 | DELETE FROM ".USER_GROUP_TABLE." |
---|
[8072] | 1681 | WHERE user_id = '".$id."' |
---|
[6354] | 1682 | AND group_id = '".$conf_UAM[2]."' |
---|
[5056] | 1683 | ;"; |
---|
[8072] | 1684 | pwg_query($query); |
---|
| 1685 | } |
---|
[5056] | 1686 | |
---|
[8072] | 1687 | if ($conf_UAM[3] <> -1) |
---|
| 1688 | { |
---|
| 1689 | $query = " |
---|
[5056] | 1690 | DELETE FROM ".USER_GROUP_TABLE." |
---|
[8072] | 1691 | WHERE user_id = '".$id."' |
---|
[6354] | 1692 | AND group_id = '".$conf_UAM[3]."' |
---|
[8072] | 1693 | ;"; |
---|
| 1694 | pwg_query($query); |
---|
[5056] | 1695 | |
---|
[8072] | 1696 | $query = " |
---|
[5056] | 1697 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 1698 | (user_id, group_id) |
---|
| 1699 | VALUES |
---|
[8072] | 1700 | ('".$id."', '".$conf_UAM[3]."') |
---|
[5056] | 1701 | ;"; |
---|
[8072] | 1702 | pwg_query($query); |
---|
| 1703 | } |
---|
[5056] | 1704 | |
---|
[8072] | 1705 | if ($conf_UAM[4] <> -1) |
---|
| 1706 | { |
---|
| 1707 | $query = " |
---|
[5056] | 1708 | UPDATE ".USER_INFOS_TABLE." |
---|
[8072] | 1709 | SET status = '".$conf_UAM[4]."' |
---|
| 1710 | WHERE user_id = '".$id."' |
---|
[5056] | 1711 | ;"; |
---|
[8072] | 1712 | pwg_query($query); |
---|
[5056] | 1713 | } |
---|
[8072] | 1714 | } |
---|
| 1715 | elseif (isset($conf_UAM[1]) and $conf_UAM[1] == 'local') |
---|
| 1716 | { |
---|
| 1717 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
| 1718 | |
---|
| 1719 | if ($conf_UAM[2] <> -1) |
---|
| 1720 | { |
---|
| 1721 | $query = " |
---|
| 1722 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1723 | WHERE user_id = '".$id."' |
---|
| 1724 | AND group_id = '".$conf_UAM[2]."' |
---|
| 1725 | ;"; |
---|
| 1726 | pwg_query($query); |
---|
| 1727 | } |
---|
| 1728 | |
---|
| 1729 | if ($conf_UAM[3] <> -1) |
---|
| 1730 | { |
---|
| 1731 | $query = " |
---|
| 1732 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1733 | WHERE user_id = '".$id."' |
---|
| 1734 | AND group_id = '".$conf_UAM[3]."' |
---|
| 1735 | ;"; |
---|
| 1736 | pwg_query($query); |
---|
| 1737 | |
---|
| 1738 | $query = " |
---|
| 1739 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 1740 | (user_id, group_id) |
---|
| 1741 | VALUES |
---|
| 1742 | ('".$id."', '".$conf_UAM[3]."') |
---|
| 1743 | ;"; |
---|
| 1744 | pwg_query($query); |
---|
| 1745 | } |
---|
| 1746 | |
---|
| 1747 | if ($conf_UAM[4] <> -1) |
---|
| 1748 | { |
---|
| 1749 | $query = " |
---|
| 1750 | UPDATE ".USER_INFOS_TABLE." |
---|
| 1751 | SET status = '".$conf_UAM[4]."' |
---|
| 1752 | WHERE user_id = '".$id."' |
---|
| 1753 | ;"; |
---|
| 1754 | pwg_query($query); |
---|
| 1755 | } |
---|
| 1756 | } |
---|
[5056] | 1757 | } |
---|
| 1758 | |
---|
[7968] | 1759 | /** |
---|
| 1760 | * Function called from main.inc.php - Check if username matches forbidden caracters |
---|
| 1761 | * |
---|
| 1762 | * @param : User login |
---|
| 1763 | * |
---|
| 1764 | * @return : Bool |
---|
| 1765 | * |
---|
| 1766 | */ |
---|
[5056] | 1767 | function ValidateUsername($login) |
---|
| 1768 | { |
---|
| 1769 | global $conf; |
---|
| 1770 | |
---|
[5181] | 1771 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1772 | |
---|
[6354] | 1773 | if (isset($login) and isset($conf_UAM[7]) and $conf_UAM[7] <> '') |
---|
[5056] | 1774 | { |
---|
[6354] | 1775 | $conf_CharExclusion = preg_split("/,/",$conf_UAM[7]); |
---|
[5181] | 1776 | for ($i = 0 ; $i < count($conf_CharExclusion) ; $i++) |
---|
[5056] | 1777 | { |
---|
[5181] | 1778 | $pattern = '/'.$conf_CharExclusion[$i].'/i'; |
---|
[5056] | 1779 | if (preg_match($pattern, $login)) |
---|
| 1780 | { |
---|
| 1781 | return true; |
---|
| 1782 | } |
---|
| 1783 | } |
---|
| 1784 | } |
---|
| 1785 | else |
---|
| 1786 | { |
---|
| 1787 | return false; |
---|
| 1788 | } |
---|
| 1789 | } |
---|
| 1790 | |
---|
[7968] | 1791 | /** |
---|
| 1792 | * Function called from main.inc.php - Check if user's email is in excluded email providers list |
---|
| 1793 | * Doesn't work on call - Must be copied in main.inc.php to work |
---|
| 1794 | * |
---|
| 1795 | * @param : Email address |
---|
| 1796 | * |
---|
| 1797 | * @return : Bool |
---|
| 1798 | * |
---|
| 1799 | */ |
---|
[5056] | 1800 | function ValidateEmailProvider($email) |
---|
| 1801 | { |
---|
| 1802 | global $conf; |
---|
| 1803 | |
---|
[5181] | 1804 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1805 | |
---|
[6354] | 1806 | if (isset($email) and isset($conf_UAM[12]) and $conf_UAM[12] <> '') |
---|
[5056] | 1807 | { |
---|
[6354] | 1808 | $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[12]); |
---|
[5181] | 1809 | for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++) |
---|
[5056] | 1810 | { |
---|
[5181] | 1811 | $pattern = '/'.$conf_MailExclusion[$i].'/i'; |
---|
[5056] | 1812 | if (preg_match($pattern, $email)) |
---|
| 1813 | { |
---|
| 1814 | return true; |
---|
| 1815 | } |
---|
| 1816 | } |
---|
| 1817 | } |
---|
| 1818 | else |
---|
| 1819 | { |
---|
| 1820 | return false; |
---|
| 1821 | } |
---|
| 1822 | } |
---|
| 1823 | |
---|
[7968] | 1824 | /** |
---|
| 1825 | * Function called from UAM_admin.php - Get unvalidated users according time limit |
---|
| 1826 | * |
---|
| 1827 | * @return : List of users |
---|
| 1828 | * |
---|
| 1829 | */ |
---|
[5056] | 1830 | function get_unvalid_user_list() |
---|
| 1831 | { |
---|
| 1832 | global $conf, $page; |
---|
| 1833 | |
---|
[7968] | 1834 | // Get ConfirmMail configuration |
---|
[5181] | 1835 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[7968] | 1836 | // Get UAM configuration |
---|
[5181] | 1837 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1838 | |
---|
| 1839 | $users = array(); |
---|
| 1840 | |
---|
[7968] | 1841 | // search users depending expiration date |
---|
[5056] | 1842 | $query = ' |
---|
| 1843 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
| 1844 | u.'.$conf['user_fields']['username'].' AS username, |
---|
| 1845 | u.'.$conf['user_fields']['email'].' AS email, |
---|
| 1846 | ui.status, |
---|
| 1847 | ui.enabled_high, |
---|
| 1848 | ui.level, |
---|
| 1849 | ui.registration_date |
---|
| 1850 | FROM '.USERS_TABLE.' AS u |
---|
| 1851 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
| 1852 | ON u.'.$conf['user_fields']['id'].' = ui.user_id |
---|
| 1853 | LEFT JOIN '.USER_GROUP_TABLE.' AS ug |
---|
| 1854 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
| 1855 | WHERE u.'.$conf['user_fields']['id'].' >= 3 |
---|
| 1856 | AND (TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) >= "'.$conf_UAM_ConfirmMail[1].'" |
---|
| 1857 | OR TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) < "'.$conf_UAM_ConfirmMail[1].'")'; |
---|
| 1858 | |
---|
[6354] | 1859 | if ($conf_UAM[2] <> '-1' and $conf_UAM[8] == '-1') |
---|
[5056] | 1860 | { |
---|
| 1861 | $query.= ' |
---|
[6354] | 1862 | AND ug.group_id = '.$conf_UAM[2]; |
---|
[5056] | 1863 | } |
---|
[6354] | 1864 | if ($conf_UAM[2] == '-1' and $conf_UAM[8] <> '-1') |
---|
[5056] | 1865 | { |
---|
| 1866 | $query.= ' |
---|
[6354] | 1867 | AND ui.status = \''.$conf_UAM[8]."'"; |
---|
[5056] | 1868 | } |
---|
[6354] | 1869 | if ($conf_UAM[2] <> '-1' and $conf_UAM[8] <> '-1') |
---|
[5056] | 1870 | { |
---|
| 1871 | $query.= ' |
---|
[6354] | 1872 | AND ug.group_id = \''.$conf_UAM[2]."'"; |
---|
[5056] | 1873 | } |
---|
| 1874 | $query.= ' |
---|
[6399] | 1875 | ORDER BY ui.registration_date ASC |
---|
[5056] | 1876 | ;'; |
---|
| 1877 | |
---|
| 1878 | $result = pwg_query($query); |
---|
| 1879 | |
---|
[5633] | 1880 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 1881 | { |
---|
| 1882 | $user = $row; |
---|
| 1883 | $user['groups'] = array(); |
---|
| 1884 | |
---|
| 1885 | array_push($users, $user); |
---|
| 1886 | } |
---|
| 1887 | |
---|
[7968] | 1888 | // add group lists |
---|
[5056] | 1889 | $user_ids = array(); |
---|
| 1890 | foreach ($users as $i => $user) |
---|
| 1891 | { |
---|
| 1892 | $user_ids[$i] = $user['id']; |
---|
| 1893 | } |
---|
| 1894 | |
---|
| 1895 | $user_nums = array_flip($user_ids); |
---|
| 1896 | |
---|
| 1897 | if (count($user_ids) > 0) |
---|
| 1898 | { |
---|
| 1899 | $query = ' |
---|
| 1900 | SELECT user_id, group_id |
---|
| 1901 | FROM '.USER_GROUP_TABLE.' |
---|
| 1902 | WHERE user_id IN ('.implode(',', $user_ids).') |
---|
| 1903 | ;'; |
---|
| 1904 | |
---|
| 1905 | $result = pwg_query($query); |
---|
| 1906 | |
---|
[5633] | 1907 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 1908 | { |
---|
| 1909 | array_push( |
---|
| 1910 | $users[$user_nums[$row['user_id']]]['groups'], |
---|
| 1911 | $row['group_id'] |
---|
| 1912 | ); |
---|
| 1913 | } |
---|
| 1914 | } |
---|
| 1915 | |
---|
| 1916 | return $users; |
---|
| 1917 | } |
---|
| 1918 | |
---|
[7968] | 1919 | /** |
---|
| 1920 | * Function called from UAM_admin.php - Get ghost users |
---|
| 1921 | * |
---|
| 1922 | * @return : List of users |
---|
| 1923 | * |
---|
| 1924 | */ |
---|
[5056] | 1925 | function get_ghost_user_list() |
---|
| 1926 | { |
---|
| 1927 | global $conf, $page; |
---|
| 1928 | |
---|
[5181] | 1929 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1930 | |
---|
| 1931 | $users = array(); |
---|
| 1932 | |
---|
[7968] | 1933 | // search users depending expiration date |
---|
[5056] | 1934 | $query = ' |
---|
| 1935 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
| 1936 | u.'.$conf['user_fields']['username'].' AS username, |
---|
| 1937 | u.'.$conf['user_fields']['email'].' AS email, |
---|
| 1938 | lv.lastvisit, |
---|
| 1939 | lv.reminder |
---|
| 1940 | FROM '.USERS_TABLE.' AS u |
---|
| 1941 | INNER JOIN '.USER_LASTVISIT_TABLE.' AS lv |
---|
| 1942 | ON u.'.$conf['user_fields']['id'].' = lv.user_id |
---|
[6354] | 1943 | WHERE (TO_DAYS(NOW()) - TO_DAYS(lv.lastvisit) >= "'.$conf_UAM[17].'") |
---|
[6399] | 1944 | ORDER BY lv.lastvisit ASC;'; |
---|
[5056] | 1945 | |
---|
| 1946 | $result = pwg_query($query); |
---|
| 1947 | |
---|
[5633] | 1948 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 1949 | { |
---|
| 1950 | $user = $row; |
---|
| 1951 | $user['groups'] = array(); |
---|
| 1952 | |
---|
| 1953 | array_push($users, $user); |
---|
| 1954 | } |
---|
| 1955 | |
---|
[7968] | 1956 | // add group lists |
---|
[5056] | 1957 | $user_ids = array(); |
---|
| 1958 | foreach ($users as $i => $user) |
---|
| 1959 | { |
---|
| 1960 | $user_ids[$i] = $user['id']; |
---|
| 1961 | } |
---|
| 1962 | |
---|
| 1963 | return $users; |
---|
| 1964 | } |
---|
| 1965 | |
---|
[8065] | 1966 | |
---|
[7968] | 1967 | /** |
---|
[8065] | 1968 | * Function called from functions.inc.php - Get all ghost users to delete or downgrade automatically on any user login |
---|
| 1969 | * |
---|
| 1970 | * @return : List of users to delete or downgrade automatically |
---|
| 1971 | * |
---|
| 1972 | */ |
---|
| 1973 | function get_ghosts_autotasks() |
---|
| 1974 | { |
---|
| 1975 | global $conf, $page; |
---|
| 1976 | |
---|
| 1977 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 1978 | |
---|
| 1979 | $users = array(); |
---|
| 1980 | |
---|
| 1981 | // search users depending expiration date and reminder sent |
---|
| 1982 | $query = ' |
---|
| 1983 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
[8087] | 1984 | lv.lastvisit |
---|
[8065] | 1985 | FROM '.USERS_TABLE.' AS u |
---|
| 1986 | INNER JOIN '.USER_LASTVISIT_TABLE.' AS lv |
---|
| 1987 | ON u.'.$conf['user_fields']['id'].' = lv.user_id |
---|
| 1988 | WHERE (TO_DAYS(NOW()) - TO_DAYS(lv.lastvisit) >= "'.$conf_UAM[17].'") |
---|
| 1989 | ORDER BY lv.lastvisit ASC;'; |
---|
| 1990 | |
---|
| 1991 | $result = pwg_query($query); |
---|
| 1992 | |
---|
| 1993 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 1994 | { |
---|
| 1995 | $user = $row; |
---|
| 1996 | $user['groups'] = array(); |
---|
| 1997 | |
---|
| 1998 | array_push($users, $user); |
---|
| 1999 | } |
---|
| 2000 | |
---|
| 2001 | // add group lists |
---|
| 2002 | $user_ids = array(); |
---|
| 2003 | foreach ($users as $i => $user) |
---|
| 2004 | { |
---|
| 2005 | $user_ids[$i] = $user['id']; |
---|
| 2006 | } |
---|
| 2007 | |
---|
| 2008 | return $users; |
---|
| 2009 | } |
---|
| 2010 | |
---|
| 2011 | |
---|
| 2012 | /** |
---|
[7968] | 2013 | * Function called from UAM_admin.php - Get all users to display the number of days since their last visit |
---|
| 2014 | * |
---|
| 2015 | * @return : List of users |
---|
| 2016 | * |
---|
| 2017 | */ |
---|
[5056] | 2018 | function get_user_list() |
---|
| 2019 | { |
---|
| 2020 | global $conf, $page; |
---|
| 2021 | |
---|
| 2022 | $users = array(); |
---|
| 2023 | |
---|
[7968] | 2024 | // search users depending expiration date |
---|
[5056] | 2025 | $query = ' |
---|
| 2026 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
| 2027 | u.'.$conf['user_fields']['username'].' AS username, |
---|
| 2028 | u.'.$conf['user_fields']['email'].' AS email, |
---|
| 2029 | ug.lastvisit |
---|
| 2030 | FROM '.USERS_TABLE.' AS u |
---|
| 2031 | INNER JOIN '.USER_LASTVISIT_TABLE.' AS ug |
---|
| 2032 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
| 2033 | WHERE u.'.$conf['user_fields']['id'].' >= 3 |
---|
[6399] | 2034 | ORDER BY ug.lastvisit DESC |
---|
[5056] | 2035 | ;'; |
---|
| 2036 | |
---|
| 2037 | $result = pwg_query($query); |
---|
| 2038 | |
---|
[5633] | 2039 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 2040 | { |
---|
| 2041 | $user = $row; |
---|
| 2042 | $user['groups'] = array(); |
---|
| 2043 | |
---|
| 2044 | array_push($users, $user); |
---|
| 2045 | } |
---|
| 2046 | |
---|
[7968] | 2047 | // add group lists |
---|
[5056] | 2048 | $user_ids = array(); |
---|
| 2049 | foreach ($users as $i => $user) |
---|
| 2050 | { |
---|
| 2051 | $user_ids[$i] = $user['id']; |
---|
| 2052 | } |
---|
| 2053 | |
---|
| 2054 | return $users; |
---|
| 2055 | } |
---|
| 2056 | |
---|
[7968] | 2057 | /** |
---|
| 2058 | * Function called from UAM_admin.php - to determine who is expired or not and giving a different display color |
---|
| 2059 | * |
---|
| 2060 | * @param : user id |
---|
| 2061 | * |
---|
| 2062 | * @return : Bool |
---|
| 2063 | * |
---|
| 2064 | */ |
---|
[5056] | 2065 | function expiration($id) |
---|
| 2066 | { |
---|
| 2067 | global $conf, $page; |
---|
| 2068 | |
---|
[7968] | 2069 | // Get ConfirmMail configuration |
---|
[5181] | 2070 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[5056] | 2071 | |
---|
[7968] | 2072 | // Get UAM configuration |
---|
[5181] | 2073 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 2074 | |
---|
| 2075 | $query = " |
---|
| 2076 | SELECT registration_date |
---|
| 2077 | FROM ".USER_INFOS_TABLE." |
---|
| 2078 | WHERE user_id = '".$id."' |
---|
| 2079 | ;"; |
---|
[5633] | 2080 | list($registration_date) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 2081 | |
---|
[7968] | 2082 | // Time limit process |
---|
| 2083 | // ******************************************** |
---|
[5056] | 2084 | if (!empty($registration_date)) |
---|
| 2085 | { |
---|
| 2086 | // dates formating and compare |
---|
| 2087 | $today = date("d-m-Y"); // Get today's date |
---|
| 2088 | list($day, $month, $year) = explode('-', $today); // explode date of today |
---|
| 2089 | $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp |
---|
| 2090 | |
---|
| 2091 | list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date |
---|
| 2092 | list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date |
---|
| 2093 | $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp |
---|
| 2094 | |
---|
| 2095 | $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps |
---|
| 2096 | $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days |
---|
| 2097 | |
---|
| 2098 | // Condition with the value set for time limit |
---|
| 2099 | if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set |
---|
| 2100 | { |
---|
| 2101 | return false; |
---|
| 2102 | } |
---|
| 2103 | else |
---|
| 2104 | { |
---|
[6754] | 2105 | return true; |
---|
[5056] | 2106 | } |
---|
| 2107 | } |
---|
| 2108 | } |
---|
| 2109 | |
---|
| 2110 | |
---|
| 2111 | /** |
---|
| 2112 | * Returns a password's score for password complexity check |
---|
| 2113 | * |
---|
[7968] | 2114 | * @param : password filled by user |
---|
[5056] | 2115 | * |
---|
[7968] | 2116 | * @return : Score calculation |
---|
| 2117 | * |
---|
[5056] | 2118 | * Thanx to MathieuGut from http://m-gut.developpez.com |
---|
| 2119 | */ |
---|
| 2120 | function testpassword($password) // Le mot de passe passé en paramètre - $password given by user |
---|
| 2121 | { |
---|
| 2122 | |
---|
| 2123 | // Initialisation des variables - Variables initiation |
---|
| 2124 | $points = 0; |
---|
| 2125 | $point_lowercase = 0; |
---|
| 2126 | $point_uppercase = 0; |
---|
| 2127 | $point_numbers = 0; |
---|
| 2128 | $point_characters = 0; |
---|
| 2129 | |
---|
| 2130 | // On récupère la longueur du mot de passe - Getting password lengh |
---|
| 2131 | $length = strlen($password); |
---|
| 2132 | |
---|
| 2133 | // On fait une boucle pour lire chaque lettre - Loop to read password characters |
---|
| 2134 | for($i = 0; $i < $length; $i++) |
---|
| 2135 | { |
---|
| 2136 | // On sélectionne une à une chaque lettre - Select each letters |
---|
| 2137 | // $i étant à 0 lors du premier passage de la boucle - $i is 0 at first turn |
---|
| 2138 | $letters = $password[$i]; |
---|
| 2139 | |
---|
| 2140 | if ($letters>='a' && $letters<='z') |
---|
| 2141 | { |
---|
| 2142 | // On ajoute 1 point pour une minuscule - Adding 1 point to score for a lowercase |
---|
| 2143 | $points = $points + 1; |
---|
| 2144 | |
---|
| 2145 | // On rajoute le bonus pour une minuscule - Adding bonus points for lowercase |
---|
| 2146 | $point_lowercase = 1; |
---|
| 2147 | } |
---|
| 2148 | else if ($letters>='A' && $letters <='Z') |
---|
| 2149 | { |
---|
| 2150 | // On ajoute 2 points pour une majuscule - Adding 2 points to score for uppercase |
---|
| 2151 | $points = $points + 2; |
---|
| 2152 | |
---|
| 2153 | // On rajoute le bonus pour une majuscule - Adding bonus points for uppercase |
---|
| 2154 | $point_uppercase = 2; |
---|
| 2155 | } |
---|
| 2156 | else if ($letters>='0' && $letters<='9') |
---|
| 2157 | { |
---|
| 2158 | // On ajoute 3 points pour un chiffre - Adding 3 points to score for numbers |
---|
| 2159 | $points = $points + 3; |
---|
| 2160 | |
---|
| 2161 | // On rajoute le bonus pour un chiffre - Adding bonus points for numbers |
---|
| 2162 | $point_numbers = 3; |
---|
| 2163 | } |
---|
| 2164 | else |
---|
| 2165 | { |
---|
| 2166 | // On ajoute 5 points pour un caractère autre - Adding 5 points to score for special characters |
---|
| 2167 | $points = $points + 5; |
---|
| 2168 | |
---|
| 2169 | // On rajoute le bonus pour un caractère autre - Adding bonus points for special characters |
---|
| 2170 | $point_characters = 5; |
---|
| 2171 | } |
---|
| 2172 | } |
---|
| 2173 | |
---|
| 2174 | // Calcul du coefficient points/longueur - calculating the coefficient points/length |
---|
| 2175 | $step1 = $points / $length; |
---|
| 2176 | |
---|
| 2177 | // Calcul du coefficient de la diversité des types de caractères... - Calculation of the diversity of character types... |
---|
| 2178 | $step2 = $point_lowercase + $point_uppercase + $point_numbers + $point_characters; |
---|
| 2179 | |
---|
| 2180 | // Multiplication du coefficient de diversité avec celui de la longueur - Multiplying the coefficient of diversity with that of the length |
---|
| 2181 | $score = $step1 * $step2; |
---|
| 2182 | |
---|
| 2183 | // Multiplication du résultat par la longueur de la chaîne - Multiplying the result by the length of the chain |
---|
| 2184 | $finalscore = $score * $length; |
---|
| 2185 | |
---|
| 2186 | return $finalscore; |
---|
| 2187 | } |
---|
| 2188 | |
---|
[7968] | 2189 | /** |
---|
| 2190 | * Function called from maintain.inc.php - to check if database upgrade is needed |
---|
| 2191 | * |
---|
| 2192 | * @param : table name |
---|
| 2193 | * |
---|
| 2194 | * @return : boolean |
---|
| 2195 | * |
---|
| 2196 | */ |
---|
[5056] | 2197 | function table_exist($table) |
---|
| 2198 | { |
---|
| 2199 | $query = 'DESC '.$table.';'; |
---|
[5633] | 2200 | return (bool)($res=pwg_query($query)); |
---|
[5056] | 2201 | } |
---|
| 2202 | |
---|
[7968] | 2203 | // Email sending debugger function |
---|
[5181] | 2204 | function MailLog($to, $subject, $content, $language) |
---|
[5056] | 2205 | { |
---|
[5181] | 2206 | $fo=fopen (UAM_PATH.'admin/maillog.txt','a') ; |
---|
[5056] | 2207 | fwrite($fo,"======================\n") ; |
---|
| 2208 | fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n"); |
---|
| 2209 | fwrite($fo,$to . "\n" . $subject . "\r\n") ; |
---|
| 2210 | fwrite($fo, "\n" . $content . "\r\n") ; |
---|
| 2211 | fwrite($fo, 'Langue : '."\n" . $language . "\r\n") ; |
---|
| 2212 | fclose($fo) ; |
---|
[5064] | 2213 | //return mail ($to,$subject) ; |
---|
[5056] | 2214 | } |
---|
| 2215 | |
---|
[7968] | 2216 | /** |
---|
| 2217 | * Function called from UAM_admin.php and main.inc.php to get the plugin version and name |
---|
| 2218 | * |
---|
| 2219 | * @param : plugin directory |
---|
| 2220 | * |
---|
| 2221 | * @return : plugin's version and name |
---|
| 2222 | * |
---|
| 2223 | */ |
---|
[5181] | 2224 | function PluginInfos($dir) |
---|
[5056] | 2225 | { |
---|
| 2226 | $path = $dir; |
---|
| 2227 | |
---|
| 2228 | $plg_data = implode( '', file($path.'main.inc.php') ); |
---|
| 2229 | if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) ) |
---|
| 2230 | { |
---|
| 2231 | $plugin['name'] = trim( $val[1] ); |
---|
| 2232 | } |
---|
| 2233 | if (preg_match("|Version: (.*)|", $plg_data, $val)) |
---|
| 2234 | { |
---|
| 2235 | $plugin['version'] = trim($val[1]); |
---|
| 2236 | } |
---|
| 2237 | if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) ) |
---|
| 2238 | { |
---|
| 2239 | $plugin['uri'] = trim($val[1]); |
---|
| 2240 | } |
---|
| 2241 | if ($desc = load_language('description.txt', $path.'/', array('return' => true))) |
---|
| 2242 | { |
---|
| 2243 | $plugin['description'] = trim($desc); |
---|
| 2244 | } |
---|
| 2245 | elseif ( preg_match("|Description: (.*)|", $plg_data, $val) ) |
---|
| 2246 | { |
---|
| 2247 | $plugin['description'] = trim($val[1]); |
---|
| 2248 | } |
---|
| 2249 | if ( preg_match("|Author: (.*)|", $plg_data, $val) ) |
---|
| 2250 | { |
---|
| 2251 | $plugin['author'] = trim($val[1]); |
---|
| 2252 | } |
---|
| 2253 | if ( preg_match("|Author URI: (.*)|", $plg_data, $val) ) |
---|
| 2254 | { |
---|
| 2255 | $plugin['author uri'] = trim($val[1]); |
---|
| 2256 | } |
---|
| 2257 | if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid=')) |
---|
| 2258 | { |
---|
| 2259 | list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']); |
---|
| 2260 | if (is_numeric($extension)) $plugin['extension'] = $extension; |
---|
| 2261 | } |
---|
| 2262 | // IMPORTANT SECURITY ! |
---|
| 2263 | $plugin = array_map('htmlspecialchars', $plugin); |
---|
| 2264 | |
---|
| 2265 | return $plugin ; |
---|
| 2266 | } |
---|
| 2267 | |
---|
| 2268 | |
---|
[5064] | 2269 | function clean_obsolete_files() |
---|
[5056] | 2270 | { |
---|
[5181] | 2271 | if (file_exists(UAM_PATH.'obsolete.list') |
---|
| 2272 | and $old_files = file(UAM_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES) |
---|
[5064] | 2273 | and !empty($old_files)) |
---|
[5056] | 2274 | { |
---|
[5064] | 2275 | array_push($old_files, 'obsolete.list'); |
---|
| 2276 | foreach($old_files as $old_file) |
---|
| 2277 | { |
---|
[5181] | 2278 | $path = UAM_PATH.$old_file; |
---|
[5064] | 2279 | if (is_file($path)) |
---|
| 2280 | { |
---|
| 2281 | @unlink($path); |
---|
| 2282 | } |
---|
| 2283 | } |
---|
[5056] | 2284 | } |
---|
| 2285 | } |
---|
[6775] | 2286 | |
---|
[7968] | 2287 | /** |
---|
[8065] | 2288 | * UAM_check_profile - Thx to LucMorizur |
---|
[7968] | 2289 | * checks if a user id is registered as having already |
---|
| 2290 | * visited his profile.php page. |
---|
| 2291 | * |
---|
| 2292 | * @uid : the user id |
---|
| 2293 | * |
---|
| 2294 | * @user_idsOK : (returned) array of all users ids having already visited |
---|
| 2295 | * their profile.php pages |
---|
| 2296 | * |
---|
| 2297 | * @returns : true or false whether the users has already visited his |
---|
| 2298 | * profile.php page or not |
---|
| 2299 | * |
---|
| 2300 | */ |
---|
[8065] | 2301 | function UAM_check_profile($uid, &$user_idsOK) |
---|
[6775] | 2302 | { |
---|
| 2303 | $t = array(); |
---|
| 2304 | $v = false; |
---|
| 2305 | |
---|
| 2306 | $query = " |
---|
| 2307 | SELECT value |
---|
| 2308 | FROM ".CONFIG_TABLE." |
---|
| 2309 | WHERE param = 'UserAdvManager_Redir' |
---|
| 2310 | ;"; |
---|
| 2311 | |
---|
| 2312 | if ($v = (($t = pwg_db_fetch_row(pwg_query($query))) !== false)) |
---|
| 2313 | { |
---|
| 2314 | $user_idsOK = explode(',', $t[0]); |
---|
| 2315 | $v = (in_array($uid, $user_idsOK)); |
---|
| 2316 | } |
---|
| 2317 | return $v; |
---|
| 2318 | } |
---|
[5056] | 2319 | ?> |
---|