[5056] | 1 | <?php |
---|
[5181] | 2 | include_once (UAM_PATH.'include/constants.php'); |
---|
| 3 | load_language('plugin.lang', UAM_PATH); |
---|
[5056] | 4 | |
---|
[10144] | 5 | |
---|
[7968] | 6 | /** |
---|
| 7 | * Triggered on get_admin_plugin_menu_links |
---|
| 8 | * |
---|
| 9 | * Plugin's administration menu |
---|
| 10 | */ |
---|
| 11 | function UAM_admin_menu($menu) |
---|
| 12 | { |
---|
| 13 | // +-----------------------------------------------------------------------+ |
---|
| 14 | // | Getting plugin name | |
---|
| 15 | // +-----------------------------------------------------------------------+ |
---|
| 16 | $plugin = PluginInfos(UAM_PATH); |
---|
| 17 | $name = $plugin['name']; |
---|
| 18 | |
---|
| 19 | array_push($menu, |
---|
| 20 | array( |
---|
| 21 | 'NAME' => $name, |
---|
[9827] | 22 | 'URL' => get_root_url().'admin.php?page=plugin-'.basename(UAM_PATH) |
---|
[7968] | 23 | ) |
---|
| 24 | ); |
---|
| 25 | |
---|
| 26 | return $menu; |
---|
| 27 | } |
---|
| 28 | |
---|
[10144] | 29 | |
---|
[7968] | 30 | /** |
---|
[17507] | 31 | * Triggered on loc_begin_admin_page |
---|
| 32 | * |
---|
| 33 | * Check options compatibility |
---|
| 34 | */ |
---|
| 35 | function UAM_check_compat() |
---|
| 36 | { |
---|
| 37 | global $conf, $page; |
---|
[17846] | 38 | |
---|
| 39 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[17507] | 40 | |
---|
| 41 | // Check mandatory email address for email exclusion |
---|
| 42 | if (!$conf['obligatory_user_mail_address'] and $conf_UAM[10] = 'true') |
---|
| 43 | { |
---|
| 44 | array_push($page['warnings'], l10n('UAM_mail_exclusion_error')); |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | /** |
---|
[7968] | 50 | * Triggered on loc_begin_index |
---|
| 51 | * |
---|
[17804] | 52 | * Initiating GhostTracker - Perform user logout after registration if not validated |
---|
[7968] | 53 | */ |
---|
[17889] | 54 | function UAM_Init() |
---|
[7968] | 55 | { |
---|
| 56 | global $conf, $user; |
---|
| 57 | |
---|
[17804] | 58 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 59 | |
---|
[7968] | 60 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 61 | |
---|
| 62 | // Admins, Guests and Adult_Content users are not tracked for Ghost Tracker or Users Tracker |
---|
[12271] | 63 | // ----------------------------------------------------------------------------------------- |
---|
[7968] | 64 | if (!is_admin() and !is_a_guest() and $user['username'] != "16" and $user['username'] != "18") |
---|
| 65 | { |
---|
[11018] | 66 | if ((isset($conf_UAM[15]) and $conf_UAM[15] == 'true') or (isset($conf_UAM[18]) and $conf_UAM[18] == 'true')) |
---|
[7968] | 67 | { |
---|
| 68 | |
---|
| 69 | $userid = get_userid($user['username']); |
---|
[17887] | 70 | |
---|
[7968] | 71 | // Looking for existing entry in last visit table |
---|
[12271] | 72 | // ---------------------------------------------- |
---|
[7968] | 73 | $query = ' |
---|
| 74 | SELECT * |
---|
| 75 | FROM '.USER_LASTVISIT_TABLE.' |
---|
| 76 | WHERE user_id = '.$userid.' |
---|
| 77 | ;'; |
---|
| 78 | |
---|
| 79 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
| 80 | |
---|
| 81 | if ($count == 0) |
---|
| 82 | { |
---|
| 83 | // If not, data are inserted in table |
---|
[12271] | 84 | // ---------------------------------- |
---|
[7968] | 85 | $query = ' |
---|
| 86 | INSERT INTO '.USER_LASTVISIT_TABLE.' (user_id, lastvisit, reminder) |
---|
| 87 | VALUES ('.$userid.', now(), "false") |
---|
| 88 | ;'; |
---|
| 89 | pwg_query($query); |
---|
| 90 | } |
---|
| 91 | else if ($count > 0) |
---|
| 92 | { |
---|
| 93 | // If yes, data are updated in table |
---|
[12271] | 94 | // --------------------------------- |
---|
[7968] | 95 | $query = ' |
---|
| 96 | UPDATE '.USER_LASTVISIT_TABLE.' |
---|
| 97 | SET lastvisit = now(), reminder = "false" |
---|
| 98 | WHERE user_id = '.$userid.' |
---|
| 99 | LIMIT 1 |
---|
| 100 | ;'; |
---|
| 101 | pwg_query($query); |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | } |
---|
[17804] | 105 | |
---|
[17887] | 106 | // Perform user logout after registration if not validated |
---|
[17892] | 107 | if ((isset($conf_UAM[39]) and $conf_UAM[39] == 'true') and !UAM_UsrReg_Verif($user['id']) and !is_admin() and !is_webmaster()) |
---|
[17887] | 108 | { |
---|
| 109 | invalidate_user_cache(); |
---|
| 110 | logout_user(); |
---|
| 111 | redirect(UAM_PATH.'rejected.php'); |
---|
| 112 | } |
---|
[7968] | 113 | } |
---|
| 114 | |
---|
[10144] | 115 | |
---|
[7968] | 116 | /** |
---|
| 117 | * Triggered on register_user |
---|
| 118 | * |
---|
| 119 | * Additional controls on user registration |
---|
| 120 | */ |
---|
| 121 | function UAM_Adduser($register_user) |
---|
| 122 | { |
---|
| 123 | global $conf; |
---|
| 124 | |
---|
| 125 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 126 | |
---|
| 127 | // Exclusion of Adult_Content users |
---|
[12271] | 128 | // -------------------------------- |
---|
[7968] | 129 | if ($register_user['username'] != "16" and $register_user['username'] != "18") |
---|
| 130 | { |
---|
[13822] | 131 | $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; |
---|
[14366] | 132 | |
---|
| 133 | if (isset($conf_UAM[1]) and $conf_UAM[1] == 'local') |
---|
[7968] | 134 | { |
---|
[14366] | 135 | // This is to set user to "waiting" group or status and without ConfirMail until admin validation |
---|
| 136 | // ---------------------------------------------------------------------------------------------- |
---|
[12189] | 137 | SetPermission($register_user['id']);// Set to "waiting" group or status until admin validation |
---|
[7968] | 138 | } |
---|
| 139 | // Sending registration confirmation by email |
---|
[12271] | 140 | // ------------------------------------------ |
---|
[14366] | 141 | elseif (isset($conf_UAM[1]) and $conf_UAM[1] == 'true') |
---|
[7968] | 142 | { |
---|
[11018] | 143 | if (is_admin() and isset($conf_UAM[19]) and $conf_UAM[19] == 'true') |
---|
[7968] | 144 | { |
---|
| 145 | SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); |
---|
| 146 | } |
---|
[11018] | 147 | elseif (is_admin() and isset($conf_UAM[19]) and $conf_UAM[19] == 'false') |
---|
[7968] | 148 | { |
---|
| 149 | SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); |
---|
| 150 | } |
---|
| 151 | elseif (!is_admin()) |
---|
| 152 | { |
---|
| 153 | SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); |
---|
| 154 | } |
---|
| 155 | } |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | |
---|
[10144] | 159 | |
---|
[7968] | 160 | /** |
---|
| 161 | * Triggered on delete_user |
---|
| 162 | * |
---|
| 163 | * Database cleanup on user deletion |
---|
| 164 | */ |
---|
| 165 | function UAM_Deluser($user_id) |
---|
| 166 | { |
---|
| 167 | // Cleanup for ConfirmMail table |
---|
[12271] | 168 | // ----------------------------- |
---|
[7968] | 169 | DeleteConfirmMail($user_id); |
---|
| 170 | // Cleanup for LastVisit table |
---|
[12271] | 171 | // --------------------------- |
---|
[7968] | 172 | DeleteLastVisit($user_id); |
---|
| 173 | // Cleanup Redirection settings |
---|
[12271] | 174 | // ---------------------------- |
---|
[7968] | 175 | DeleteRedir($user_id); |
---|
| 176 | } |
---|
| 177 | |
---|
[10144] | 178 | |
---|
[7968] | 179 | /** |
---|
| 180 | * Triggered on register_user_check |
---|
| 181 | * |
---|
| 182 | * Additional controls on user registration check |
---|
| 183 | */ |
---|
[8065] | 184 | function UAM_RegistrationCheck($errors, $user) |
---|
[7968] | 185 | { |
---|
[8065] | 186 | global $conf; |
---|
[7968] | 187 | |
---|
| 188 | // Exclusion of Adult_Content users |
---|
[12271] | 189 | // -------------------------------- |
---|
[7968] | 190 | if ($user['username'] != "16" and $user['username'] != "18") |
---|
| 191 | { |
---|
[8065] | 192 | load_language('plugin.lang', UAM_PATH); |
---|
[7968] | 193 | |
---|
| 194 | $PasswordCheck = 0; |
---|
| 195 | |
---|
| 196 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 197 | |
---|
| 198 | // Password enforcement control |
---|
[12271] | 199 | // ---------------------------- |
---|
[11018] | 200 | if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($conf_UAM[13])) |
---|
[7968] | 201 | { |
---|
| 202 | if (!empty($user['password']) and !is_admin()) |
---|
| 203 | { |
---|
| 204 | $PasswordCheck = testpassword($user['password']); |
---|
| 205 | |
---|
[11018] | 206 | if ($PasswordCheck < $conf_UAM[13]) |
---|
[7968] | 207 | { |
---|
[9177] | 208 | $message = get_l10n_args('UAM_reg_err_login4_%s', $PasswordCheck); |
---|
[11018] | 209 | $lang['reg_err_pass'] = l10n_args($message).$conf_UAM[13]; |
---|
[8065] | 210 | array_push($errors, $lang['reg_err_pass']); |
---|
[7968] | 211 | } |
---|
| 212 | } |
---|
[11018] | 213 | else if (!empty($user['password']) and is_admin() and isset($conf_UAM[14]) and $conf_UAM[14] == 'true') |
---|
[7968] | 214 | { |
---|
| 215 | $PasswordCheck = testpassword($user['password']); |
---|
| 216 | |
---|
[11018] | 217 | if ($PasswordCheck < $conf_UAM[13]) |
---|
[7968] | 218 | { |
---|
[9177] | 219 | $message = get_l10n_args('UAM_reg_err_login4_%s', $PasswordCheck); |
---|
[11018] | 220 | $lang['reg_err_pass'] = l10n_args($message).$conf_UAM[13]; |
---|
[8065] | 221 | array_push($errors, $lang['reg_err_pass']); |
---|
[7968] | 222 | } |
---|
| 223 | } |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | // Username without forbidden keys |
---|
[12271] | 227 | // ------------------------------- |
---|
[11018] | 228 | if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and !empty($user['username']) and ValidateUsername($user['username']) and !is_admin()) |
---|
[7968] | 229 | { |
---|
[11018] | 230 | $lang['reg_err_login1'] = l10n('UAM_reg_err_login2')."'".$conf_UAM[6]."'"; |
---|
[8065] | 231 | array_push($errors, $lang['reg_err_login1']); |
---|
[7968] | 232 | } |
---|
| 233 | |
---|
| 234 | // Email without forbidden domains |
---|
[12271] | 235 | // ------------------------------- |
---|
[11018] | 236 | if (isset($conf_UAM[10]) and $conf_UAM[10] == 'true' and !empty($user['email']) and ValidateEmailProvider($user['email']) and !is_admin()) |
---|
[7968] | 237 | { |
---|
[11018] | 238 | $lang['reg_err_login1'] = l10n('UAM_reg_err_login5')."'".$conf_UAM[11]."'"; |
---|
[8065] | 239 | array_push($errors, $lang['reg_err_login1']); |
---|
[7968] | 240 | } |
---|
[8065] | 241 | return $errors; |
---|
[7968] | 242 | } |
---|
| 243 | } |
---|
| 244 | |
---|
[10144] | 245 | |
---|
[7968] | 246 | /** |
---|
| 247 | * Triggered on loc_begin_profile |
---|
| 248 | */ |
---|
| 249 | function UAM_Profile_Init() |
---|
| 250 | { |
---|
| 251 | global $conf, $user, $template; |
---|
| 252 | |
---|
| 253 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[12239] | 254 | |
---|
| 255 | // Update first redirection parameter |
---|
[12271] | 256 | // ---------------------------------- |
---|
[11018] | 257 | if ((isset($conf_UAM[20]) and $conf_UAM[20] == 'true')) |
---|
[7968] | 258 | { |
---|
| 259 | $user_idsOK = array(); |
---|
[8065] | 260 | if (!UAM_check_profile($user['id'], $user_idsOK)) |
---|
[7968] | 261 | { |
---|
| 262 | $user_idsOK[] = $user['id']; |
---|
| 263 | |
---|
| 264 | $query = " |
---|
| 265 | UPDATE ".CONFIG_TABLE." |
---|
| 266 | SET value = \"".implode(',', $user_idsOK)."\" |
---|
| 267 | WHERE param = 'UserAdvManager_Redir';"; |
---|
| 268 | |
---|
| 269 | pwg_query($query); |
---|
| 270 | } |
---|
| 271 | } |
---|
| 272 | |
---|
[12239] | 273 | // Special message display for password reset |
---|
[12271] | 274 | // ------------------------------------------ |
---|
[12239] | 275 | if ((isset($conf_UAM[38]) and $conf_UAM[38] == 'true')) |
---|
| 276 | { |
---|
| 277 | if (UAM_check_pwgreset($user['id'])) |
---|
| 278 | { |
---|
| 279 | $template->append('errors', l10n('UAM_Password_Reset_Msg')); |
---|
| 280 | } |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | // Controls on profile page submission |
---|
[12271] | 284 | // ----------------------------------- |
---|
[7968] | 285 | if (isset($_POST['validate']) and !is_admin()) |
---|
| 286 | { |
---|
| 287 | // Email without forbidden domains |
---|
[12271] | 288 | // ------------------------------- |
---|
[11018] | 289 | if (isset($conf_UAM[10]) and $conf_UAM[10] == 'true' and !empty($_POST['mail_address'])) |
---|
[7968] | 290 | { |
---|
| 291 | if (ValidateEmailProvider($_POST['mail_address'])) |
---|
| 292 | { |
---|
[11018] | 293 | $template->append('errors', l10n('UAM_reg_err_login5')."'".$conf_UAM[11]."'"); |
---|
[7968] | 294 | unset($_POST['validate']); |
---|
| 295 | } |
---|
| 296 | } |
---|
| 297 | |
---|
[12239] | 298 | // Password reset control |
---|
[12271] | 299 | // ---------------------- |
---|
[12239] | 300 | if (isset($conf_UAM[38]) and $conf_UAM[38] == 'true' and UAM_check_pwgreset($user['id'])) |
---|
| 301 | { |
---|
[13841] | 302 | // if password not changed then pwdreset field = true else pwdreset field = false |
---|
[12271] | 303 | // ------------------------------------------------------------------------------ |
---|
[12239] | 304 | if (!empty($_POST['use_new_pwd'])) |
---|
| 305 | { |
---|
| 306 | $query = ' |
---|
| 307 | UPDATE '.USERS_TABLE.' |
---|
| 308 | SET UAM_pwdreset = "false" |
---|
| 309 | WHERE id = '.$user['id'].' |
---|
| 310 | LIMIT 1 |
---|
| 311 | ;'; |
---|
| 312 | pwg_query($query); |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | |
---|
[14366] | 316 | $typemail = 3; // Only information email send to user on user profile update if checked |
---|
[7968] | 317 | |
---|
| 318 | if (!empty($_POST['use_new_pwd'])) |
---|
| 319 | { |
---|
[14366] | 320 | $typemail = 2; // Confirmation email on user profile update - With information email if checked |
---|
[7968] | 321 | |
---|
| 322 | // Password enforcement control |
---|
[12271] | 323 | // ---------------------------- |
---|
[11018] | 324 | if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($conf_UAM[13])) |
---|
[7968] | 325 | { |
---|
| 326 | $PasswordCheck = testpassword($_POST['use_new_pwd']); |
---|
| 327 | |
---|
[11018] | 328 | if ($PasswordCheck < $conf_UAM[13]) |
---|
[7968] | 329 | { |
---|
[9177] | 330 | $message = get_l10n_args('UAM_reg_err_login4_%s', $PasswordCheck); |
---|
[11018] | 331 | $template->append('errors', l10n_args($message).$conf_UAM[13]); |
---|
[7968] | 332 | unset($_POST['use_new_pwd']); |
---|
| 333 | unset($_POST['validate']); |
---|
| 334 | } |
---|
| 335 | } |
---|
| 336 | } |
---|
| 337 | |
---|
| 338 | // Sending registration confirmation by email |
---|
[12271] | 339 | // ------------------------------------------ |
---|
[14857] | 340 | if ((isset($conf_UAM[1]) and $conf_UAM[1] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) |
---|
[7968] | 341 | { |
---|
| 342 | $confirm_mail_need = false; |
---|
| 343 | |
---|
| 344 | if (!empty($_POST['mail_address'])) |
---|
| 345 | { |
---|
| 346 | $query = ' |
---|
| 347 | SELECT '.$conf['user_fields']['email'].' AS email |
---|
| 348 | FROM '.USERS_TABLE.' |
---|
| 349 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
| 350 | ;'; |
---|
| 351 | |
---|
| 352 | list($current_email) = pwg_db_fetch_row(pwg_query($query)); |
---|
| 353 | |
---|
| 354 | // This is to send a new validation key |
---|
[12271] | 355 | // ------------------------------------ |
---|
[7968] | 356 | if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true')) |
---|
[14366] | 357 | { |
---|
| 358 | SetPermission($user['id']);// Set to "waiting" group or status until user validation |
---|
[7968] | 359 | $confirm_mail_need = true; |
---|
[14366] | 360 | } |
---|
[7968] | 361 | |
---|
| 362 | // This is to set the user to "waiting" group or status until admin validation |
---|
[12271] | 363 | // --------------------------------------------------------------------------- |
---|
[14366] | 364 | elseif ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) |
---|
| 365 | { |
---|
[13841] | 366 | SetPermission($user['id']);// Set to "waiting" group or status until admin validation |
---|
[7968] | 367 | $confirm_mail_need = false; |
---|
[14366] | 368 | } |
---|
[7968] | 369 | } |
---|
| 370 | |
---|
[14366] | 371 | if (((!empty($_POST['use_new_pwd']) and (isset($conf_UAM[0]) and $conf_UAM[0] == 'true')) or $confirm_mail_need)) |
---|
[7968] | 372 | { |
---|
| 373 | $query = ' |
---|
| 374 | SELECT '.$conf['user_fields']['username'].' |
---|
| 375 | FROM '.USERS_TABLE.' |
---|
| 376 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
| 377 | ;'; |
---|
| 378 | |
---|
| 379 | list($username) = pwg_db_fetch_row(pwg_query($query)); |
---|
| 380 | SendMail2User($typemail, $user['id'], $username, $_POST['use_new_pwd'], $_POST['mail_address'], $confirm_mail_need); |
---|
| 381 | } |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | } |
---|
| 385 | |
---|
[10144] | 386 | |
---|
[7968] | 387 | /** |
---|
| 388 | * Triggered on login_success |
---|
| 389 | * |
---|
[8065] | 390 | * Triggers scheduled tasks at login |
---|
| 391 | * Redirects a visitor (except for admins, webmasters and generic statuses) to his profile.php page (Thx to LucMorizur) |
---|
[7968] | 392 | * |
---|
| 393 | */ |
---|
[8065] | 394 | function UAM_LoginTasks() |
---|
[7968] | 395 | { |
---|
| 396 | global $conf, $user; |
---|
| 397 | |
---|
[12661] | 398 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 399 | |
---|
[7968] | 400 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 401 | |
---|
[9253] | 402 | // Performing GhostTracker scheduled tasks |
---|
[12271] | 403 | // --------------------------------------- |
---|
[11018] | 404 | if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true')) |
---|
[8065] | 405 | { |
---|
[9253] | 406 | UAM_GT_ScheduledTasks(); |
---|
[8065] | 407 | } |
---|
| 408 | |
---|
[9266] | 409 | // Performing User validation scheduled tasks |
---|
[12271] | 410 | // ------------------------------------------ |
---|
[11018] | 411 | if ((isset($conf_UAM[30]) and $conf_UAM[30] == 'true')) |
---|
[9266] | 412 | { |
---|
| 413 | UAM_USR_ScheduledTasks(); |
---|
| 414 | } |
---|
| 415 | |
---|
[12661] | 416 | // Avoid login into public galleries until registration confirmation is done |
---|
| 417 | if ((isset($conf_UAM[39]) and $conf_UAM[39] == 'false') or ((isset($conf_UAM[39]) and $conf_UAM[39] == 'true') and UAM_UsrReg_Verif($user['id']))) |
---|
[12314] | 418 | { |
---|
[12661] | 419 | // Performing redirection to profile page on first login |
---|
| 420 | // ----------------------------------------------------- |
---|
| 421 | if ((isset($conf_UAM[20]) and $conf_UAM[20] == 'true')) |
---|
| 422 | { |
---|
| 423 | $query =' |
---|
[7968] | 424 | SELECT user_id, status |
---|
| 425 | FROM '.USER_INFOS_TABLE.' |
---|
| 426 | WHERE user_id = '.$user['id'].' |
---|
| 427 | ;'; |
---|
[12661] | 428 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[8065] | 429 | |
---|
[12661] | 430 | if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic") // Exclusion of specific accounts |
---|
| 431 | { |
---|
| 432 | $user_idsOK = array(); |
---|
| 433 | if (!UAM_check_profile($user['id'], $user_idsOK)) |
---|
| 434 | redirect(PHPWG_ROOT_PATH.'profile.php'); |
---|
| 435 | } |
---|
[8087] | 436 | } |
---|
[12239] | 437 | |
---|
[12661] | 438 | // Performing redirection to profile page for password reset |
---|
| 439 | // --------------------------------------------------------- |
---|
| 440 | if ((isset($conf_UAM[38]) and $conf_UAM[38] == 'true')) |
---|
| 441 | { |
---|
| 442 | $query =' |
---|
[12239] | 443 | SELECT user_id, status |
---|
| 444 | FROM '.USER_INFOS_TABLE.' |
---|
| 445 | WHERE user_id = '.$user['id'].' |
---|
| 446 | ;'; |
---|
[12661] | 447 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[12239] | 448 | |
---|
[12661] | 449 | if ($data['status'] <> "webmaster" and $data['status'] <> "generic") // Exclusion of specific accounts |
---|
[12239] | 450 | { |
---|
[12661] | 451 | if (UAM_check_pwgreset($user['id'])) |
---|
| 452 | { |
---|
| 453 | redirect(PHPWG_ROOT_PATH.'profile.php'); |
---|
| 454 | } |
---|
[12239] | 455 | } |
---|
| 456 | } |
---|
| 457 | } |
---|
[17892] | 458 | elseif ((isset($conf_UAM[39]) and $conf_UAM[39] == 'true') and !UAM_UsrReg_Verif($user['id']) and !is_admin() and !is_webmaster()) |
---|
[12661] | 459 | { |
---|
| 460 | // Logged-in user cleanup, session destruction and redirected to custom page |
---|
| 461 | // ------------------------------------------------------------------------- |
---|
[17892] | 462 | invalidate_user_cache(); |
---|
| 463 | logout_user(); |
---|
| 464 | redirect(UAM_PATH.'rejected.php'); |
---|
[12661] | 465 | } |
---|
[7968] | 466 | } |
---|
| 467 | |
---|
[9908] | 468 | |
---|
[7968] | 469 | /** |
---|
[9908] | 470 | * Adds a new module settable in PWG_Stuffs - Triggered on get_stuffs_modules in main.inc.php |
---|
| 471 | * Useful to inform unvalidated user for their status |
---|
| 472 | * |
---|
| 473 | */ |
---|
| 474 | function register_UAM_stuffs_module($modules) |
---|
| 475 | { |
---|
| 476 | array_push($modules, array( |
---|
| 477 | 'path' => UAM_PATH.'/stuffs_module', |
---|
| 478 | 'name' => l10n('UAM_Stuffs_Title'), |
---|
| 479 | 'description' => l10n('UAM_Stuffs_Desc'), |
---|
| 480 | ) |
---|
| 481 | ); |
---|
| 482 | return $modules; |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | |
---|
| 486 | /** |
---|
[8065] | 487 | * Triggered on UAM_LoginTasks() |
---|
[7968] | 488 | * |
---|
[9253] | 489 | * Executes optional post-login tasks for Ghost users |
---|
[7968] | 490 | * |
---|
| 491 | */ |
---|
[9253] | 492 | function UAM_GT_ScheduledTasks() |
---|
[7968] | 493 | { |
---|
[8065] | 494 | global $conf, $user, $page; |
---|
[9253] | 495 | |
---|
| 496 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 497 | { |
---|
| 498 | die('Hacking attempt!'); |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 502 | |
---|
[7968] | 503 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[8065] | 504 | |
---|
| 505 | $collection = array(); |
---|
[8087] | 506 | $reminder = false; |
---|
[8065] | 507 | |
---|
| 508 | $page['filtered_users'] = get_ghosts_autotasks(); |
---|
[7968] | 509 | |
---|
[8087] | 510 | foreach($page['filtered_users'] as $listed_user) |
---|
| 511 | { |
---|
| 512 | array_push($collection, $listed_user['id']); |
---|
| 513 | } |
---|
[8065] | 514 | |
---|
[17846] | 515 | // Auto group, status or privacy level downgrade and autodeletion if user already reminded |
---|
| 516 | // --------------------------------------------------------------------------------------- |
---|
[12189] | 517 | if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true') and ((isset($conf_UAM[25]) and $conf_UAM[25] <> -1) or (isset($conf_UAM[26]) and $conf_UAM[26] <> -1) or (isset($conf_UAM[37]) and $conf_UAM[37] <> -1))) |
---|
[8087] | 518 | { |
---|
[8065] | 519 | if (count($collection) > 0) |
---|
[17887] | 520 | { |
---|
[8087] | 521 | // Process if a non-admin nor webmaster user is logged |
---|
[12271] | 522 | // --------------------------------------------------- |
---|
[8087] | 523 | if (in_array($user['id'], $collection)) |
---|
[17887] | 524 | { |
---|
[9253] | 525 | // Check lastvisit reminder state |
---|
[12271] | 526 | // ------------------------------ |
---|
[9253] | 527 | $query = ' |
---|
[8087] | 528 | SELECT reminder |
---|
| 529 | FROM '.USER_LASTVISIT_TABLE.' |
---|
[9253] | 530 | WHERE user_id = '.$user['id'].';'; |
---|
[8087] | 531 | |
---|
[9253] | 532 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[8087] | 533 | |
---|
[9253] | 534 | if (isset($result['reminder']) and $result['reminder'] == 'true') |
---|
| 535 | { |
---|
| 536 | $reminder = true; |
---|
[8065] | 537 | } |
---|
[9253] | 538 | else |
---|
[8092] | 539 | { |
---|
[9253] | 540 | $reminder = false; |
---|
[8092] | 541 | } |
---|
[9253] | 542 | |
---|
[9266] | 543 | // If user already reminded for ghost account |
---|
[12271] | 544 | // ------------------------------------------ |
---|
[9266] | 545 | if ($reminder) |
---|
[8092] | 546 | { |
---|
[12271] | 547 | // Delete account |
---|
| 548 | // -------------- |
---|
[9253] | 549 | delete_user($user['id']); |
---|
| 550 | |
---|
| 551 | // Logged-in user cleanup, session destruction and redirected to custom page |
---|
[12271] | 552 | // ------------------------------------------------------------------------- |
---|
[8092] | 553 | invalidate_user_cache(); |
---|
[9253] | 554 | logout_user(); |
---|
[9266] | 555 | redirect(UAM_PATH.'GT_del_account.php'); |
---|
[8092] | 556 | } |
---|
[17887] | 557 | } |
---|
[8087] | 558 | else // Process if an admin or webmaster user is logged |
---|
[8065] | 559 | { |
---|
| 560 | foreach ($collection as $user_id) |
---|
| 561 | { |
---|
[8087] | 562 | // Check lastvisit reminder state |
---|
[12271] | 563 | // ------------------------------ |
---|
[8087] | 564 | $query = ' |
---|
| 565 | SELECT reminder |
---|
| 566 | FROM '.USER_LASTVISIT_TABLE.' |
---|
| 567 | WHERE user_id = '.$user_id.';'; |
---|
| 568 | |
---|
| 569 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 570 | |
---|
| 571 | if (isset($result['reminder']) and $result['reminder'] == 'true') |
---|
| 572 | { |
---|
| 573 | $reminder = true; |
---|
| 574 | } |
---|
| 575 | else |
---|
| 576 | { |
---|
| 577 | $reminder = false; |
---|
| 578 | } |
---|
| 579 | |
---|
| 580 | // If never reminded before |
---|
[12271] | 581 | // ------------------------ |
---|
[8087] | 582 | if (!$reminder) |
---|
| 583 | { |
---|
[12271] | 584 | // Reset of lastvisit date |
---|
| 585 | // ----------------------- |
---|
[8087] | 586 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
| 587 | |
---|
[17887] | 588 | $query = " |
---|
[8087] | 589 | UPDATE ".USER_LASTVISIT_TABLE." |
---|
| 590 | SET lastvisit='".$dbnow."' |
---|
| 591 | WHERE user_id = '".$user_id."' |
---|
| 592 | ;"; |
---|
| 593 | pwg_query($query); |
---|
| 594 | |
---|
[8065] | 595 | // Auto change group and / or status |
---|
[12271] | 596 | // --------------------------------- |
---|
[8087] | 597 | // Delete user from all groups |
---|
[12271] | 598 | // --------------------------- |
---|
[8087] | 599 | $query = " |
---|
[8065] | 600 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 601 | WHERE user_id = '".$user_id."' |
---|
| 602 | AND ( |
---|
| 603 | group_id = '".$conf_UAM[2]."' |
---|
| 604 | OR |
---|
| 605 | group_id = '".$conf_UAM[3]."' |
---|
| 606 | ) |
---|
| 607 | ;"; |
---|
[8087] | 608 | pwg_query($query); |
---|
[8065] | 609 | |
---|
[8087] | 610 | // Change user status |
---|
[12271] | 611 | // ------------------ |
---|
[11018] | 612 | if ($conf_UAM[26] <> -1) |
---|
[8087] | 613 | { |
---|
| 614 | $query = " |
---|
[8065] | 615 | UPDATE ".USER_INFOS_TABLE." |
---|
[11018] | 616 | SET status = '".$conf_UAM[26]."' |
---|
[8065] | 617 | WHERE user_id = '".$user_id."' |
---|
| 618 | ;"; |
---|
[8087] | 619 | pwg_query($query); |
---|
| 620 | } |
---|
[8065] | 621 | |
---|
[8087] | 622 | // Change user group |
---|
[12271] | 623 | // ----------------- |
---|
[11018] | 624 | if ($conf_UAM[25] <> -1) |
---|
[8087] | 625 | { |
---|
| 626 | $query = " |
---|
[8065] | 627 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 628 | (user_id, group_id) |
---|
| 629 | VALUES |
---|
[11018] | 630 | ('".$user_id."', '".$conf_UAM[25]."') |
---|
[8065] | 631 | ;"; |
---|
[8087] | 632 | pwg_query($query); |
---|
| 633 | } |
---|
[8065] | 634 | |
---|
[12189] | 635 | // Change user privacy level |
---|
[12271] | 636 | // ------------------------- |
---|
[12189] | 637 | if ($conf_UAM[37] <> -1) |
---|
| 638 | { |
---|
| 639 | $query = " |
---|
| 640 | UPDATE ".USER_INFOS_TABLE." |
---|
| 641 | SET level = '".$conf_UAM[37]."' |
---|
| 642 | WHERE user_id = '".$user_id."' |
---|
| 643 | ;"; |
---|
| 644 | pwg_query($query); |
---|
| 645 | } |
---|
| 646 | |
---|
[8087] | 647 | // Auto send email notification on group / status downgrade |
---|
[12271] | 648 | // -------------------------------------------------------- |
---|
[11018] | 649 | if (isset($conf_UAM[22]) and $conf_UAM[22] == 'true') |
---|
[8087] | 650 | { |
---|
| 651 | // Set reminder true |
---|
[12271] | 652 | // ----------------- |
---|
[8087] | 653 | $query = " |
---|
| 654 | UPDATE ".USER_LASTVISIT_TABLE." |
---|
| 655 | SET reminder = 'true' |
---|
| 656 | WHERE user_id = '".$user_id."' |
---|
| 657 | ;"; |
---|
| 658 | pwg_query($query); |
---|
| 659 | |
---|
| 660 | // Reset confirmed user status to unvalidated |
---|
[12271] | 661 | // ------------------------------------------ |
---|
[17887] | 662 | $query = ' |
---|
[8065] | 663 | UPDATE '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 664 | SET date_check = NULL |
---|
| 665 | WHERE user_id = "'.$user_id.'" |
---|
| 666 | ;'; |
---|
[17887] | 667 | pwg_query($query); |
---|
[8065] | 668 | |
---|
[8087] | 669 | // Get users information for email notification |
---|
[12271] | 670 | // -------------------------------------------- |
---|
[17887] | 671 | $query = ' |
---|
[8065] | 672 | SELECT id, username, mail_address |
---|
| 673 | FROM '.USERS_TABLE.' |
---|
| 674 | WHERE id = '.$user_id.' |
---|
| 675 | ;'; |
---|
[17887] | 676 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[8065] | 677 | |
---|
[8087] | 678 | demotion_mail($user_id, $data['username'], $data['mail_address']); |
---|
| 679 | } |
---|
[8065] | 680 | } |
---|
[8087] | 681 | elseif ($reminder) // If user already reminded for ghost account |
---|
| 682 | { |
---|
[12271] | 683 | // Delete account |
---|
| 684 | // -------------- |
---|
[8087] | 685 | delete_user($user_id); |
---|
| 686 | } |
---|
[8065] | 687 | } |
---|
| 688 | } |
---|
| 689 | } |
---|
[7968] | 690 | } |
---|
| 691 | } |
---|
| 692 | |
---|
[10144] | 693 | |
---|
[7968] | 694 | /** |
---|
[9266] | 695 | * Triggered on UAM_LoginTasks() |
---|
| 696 | * |
---|
| 697 | * Executes optional post-login tasks for unvalidated users |
---|
| 698 | * |
---|
| 699 | */ |
---|
| 700 | function UAM_USR_ScheduledTasks() |
---|
| 701 | { |
---|
| 702 | global $conf, $user, $page; |
---|
| 703 | |
---|
| 704 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 705 | { |
---|
| 706 | die('Hacking attempt!'); |
---|
| 707 | } |
---|
| 708 | |
---|
| 709 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 710 | |
---|
| 711 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 712 | |
---|
| 713 | $collection = array(); |
---|
| 714 | $reminder = false; |
---|
| 715 | |
---|
| 716 | $page['filtered_users'] = get_unvalid_user_autotasks(); |
---|
| 717 | |
---|
| 718 | foreach($page['filtered_users'] as $listed_user) |
---|
| 719 | { |
---|
| 720 | array_push($collection, $listed_user['id']); |
---|
| 721 | } |
---|
| 722 | |
---|
| 723 | // Unvalidated accounts auto email sending and autodeletion if user already reminded |
---|
[12271] | 724 | // --------------------------------------------------------------------------------- |
---|
[11018] | 725 | if ((isset($conf_UAM[30]) and $conf_UAM[30] == 'true')) |
---|
[9266] | 726 | { |
---|
| 727 | if (count($collection) > 0) |
---|
[17887] | 728 | { |
---|
[9266] | 729 | // Process if a non-admin nor webmaster user is logged |
---|
[12271] | 730 | // --------------------------------------------------- |
---|
[9266] | 731 | if (in_array($user['id'], $collection)) |
---|
[17887] | 732 | { |
---|
[9266] | 733 | // Check ConfirmMail reminder state |
---|
[12271] | 734 | // -------------------------------- |
---|
[9266] | 735 | $query = ' |
---|
| 736 | SELECT reminder |
---|
| 737 | FROM '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 738 | WHERE user_id = '.$user['id'].';'; |
---|
| 739 | |
---|
| 740 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 741 | |
---|
| 742 | if (isset($result['reminder']) and $result['reminder'] == 'true') |
---|
| 743 | { |
---|
| 744 | $reminder = true; |
---|
| 745 | } |
---|
| 746 | else |
---|
| 747 | { |
---|
| 748 | $reminder = false; |
---|
| 749 | } |
---|
| 750 | |
---|
| 751 | // If never reminded before, send reminder and set reminder True |
---|
[12271] | 752 | // ------------------------------------------------------------- |
---|
[11018] | 753 | if (!$reminder and isset($conf_UAM[32]) and $conf_UAM[32] == 'true') |
---|
[9266] | 754 | { |
---|
[17887] | 755 | $typemail = 1; |
---|
[9266] | 756 | |
---|
| 757 | // Get current user informations |
---|
[12271] | 758 | // ----------------------------- |
---|
[9266] | 759 | $query = " |
---|
| 760 | SELECT id, username, mail_address |
---|
| 761 | FROM ".USERS_TABLE." |
---|
| 762 | WHERE id = '".$user['id']."' |
---|
| 763 | ;"; |
---|
| 764 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 765 | |
---|
| 766 | ResendMail2User($typemail,$user['id'],stripslashes($data['username']),$data['mail_address'],true); |
---|
| 767 | } |
---|
| 768 | |
---|
| 769 | // If already reminded before, delete user |
---|
[12271] | 770 | // --------------------------------------- |
---|
[9266] | 771 | if ($reminder) |
---|
| 772 | { |
---|
| 773 | // delete account |
---|
| 774 | delete_user($user['id']); |
---|
| 775 | |
---|
| 776 | // Logged-in user cleanup, session destruction and redirected to custom page |
---|
[12271] | 777 | // ------------------------------------------------------------------------- |
---|
[9266] | 778 | invalidate_user_cache(); |
---|
| 779 | logout_user(); |
---|
| 780 | redirect(UAM_PATH.'USR_del_account.php'); |
---|
| 781 | } |
---|
[17887] | 782 | } |
---|
[9266] | 783 | else // Process if an admin or webmaster user is logged |
---|
| 784 | { |
---|
| 785 | foreach ($collection as $user_id) |
---|
| 786 | { |
---|
| 787 | // Check reminder state |
---|
[12271] | 788 | // -------------------- |
---|
[9266] | 789 | $query = ' |
---|
| 790 | SELECT reminder |
---|
| 791 | FROM '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 792 | WHERE user_id = '.$user_id.';'; |
---|
| 793 | |
---|
| 794 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 795 | |
---|
| 796 | if (isset($result['reminder']) and $result['reminder'] == 'true') |
---|
| 797 | { |
---|
| 798 | $reminder = true; |
---|
| 799 | } |
---|
| 800 | else |
---|
| 801 | { |
---|
| 802 | $reminder = false; |
---|
| 803 | } |
---|
| 804 | |
---|
| 805 | // If never reminded before, send reminder and set reminder True |
---|
[12271] | 806 | // ------------------------------------------------------------- |
---|
[11018] | 807 | if (!$reminder and isset($conf_UAM[32]) and $conf_UAM[32] == 'true') |
---|
[9266] | 808 | { |
---|
| 809 | $typemail = 1; |
---|
| 810 | |
---|
| 811 | // Get current user informations |
---|
[12271] | 812 | // ----------------------------- |
---|
[9266] | 813 | $query = " |
---|
| 814 | SELECT id, username, mail_address |
---|
| 815 | FROM ".USERS_TABLE." |
---|
| 816 | WHERE id = '".$user_id."' |
---|
| 817 | ;"; |
---|
| 818 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 819 | |
---|
| 820 | ResendMail2User($typemail,$user_id,stripslashes($data['username']),$data['mail_address'],true); |
---|
| 821 | } |
---|
| 822 | elseif ($reminder) // If user already reminded for account validation |
---|
| 823 | { |
---|
[12271] | 824 | // Delete account |
---|
| 825 | // -------------- |
---|
[9266] | 826 | delete_user($user_id); |
---|
| 827 | } |
---|
| 828 | } |
---|
| 829 | } |
---|
| 830 | } |
---|
| 831 | } |
---|
| 832 | } |
---|
| 833 | |
---|
| 834 | |
---|
| 835 | /** |
---|
[7968] | 836 | * Triggered on init |
---|
| 837 | * |
---|
| 838 | * Check for forbidden email domains in admin's users management panel |
---|
| 839 | */ |
---|
| 840 | function UAM_InitPage() |
---|
| 841 | { |
---|
| 842 | load_language('plugin.lang', UAM_PATH); |
---|
| 843 | global $conf, $template, $page, $lang, $errors; |
---|
| 844 | |
---|
| 845 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 846 | |
---|
| 847 | // Admin user management |
---|
[12271] | 848 | // --------------------- |
---|
[7968] | 849 | if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list') |
---|
| 850 | { |
---|
| 851 | if (isset($_POST['submit_add'])) |
---|
| 852 | { |
---|
| 853 | // Email without forbidden domains |
---|
[12271] | 854 | // ------------------------------- |
---|
[11018] | 855 | if (isset($conf_UAM[10]) and $conf_UAM[10] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email'])) |
---|
[7968] | 856 | { |
---|
[11018] | 857 | $template->append('errors', l10n('UAM_reg_err_login5')."'".$conf_UAM[11]."'"); |
---|
[7968] | 858 | unset($_POST['submit_add']); |
---|
| 859 | } |
---|
| 860 | } |
---|
| 861 | } |
---|
| 862 | } |
---|
| 863 | |
---|
[9135] | 864 | |
---|
[7968] | 865 | /** |
---|
[9135] | 866 | * Triggered on render_lost_password_mail_content |
---|
| 867 | * |
---|
| 868 | * Adds a customized text in lost password email content |
---|
| 869 | * Added text is inserted before users login name and new password |
---|
| 870 | * |
---|
| 871 | * @param : Standard Piwigo email content |
---|
| 872 | * |
---|
| 873 | * @return : Customized content added to standard content |
---|
| 874 | * |
---|
| 875 | */ |
---|
| 876 | function UAM_lost_password_mail_content($infos) |
---|
| 877 | { |
---|
| 878 | global $conf; |
---|
| 879 | |
---|
| 880 | load_language('plugin.lang', UAM_PATH); |
---|
| 881 | |
---|
| 882 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 883 | |
---|
[11018] | 884 | if (isset($conf_UAM[28]) and $conf_UAM[28] == 'true') |
---|
[9135] | 885 | { |
---|
[9381] | 886 | // Management of Extension flags ([mygallery], [myurl]) |
---|
[9160] | 887 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 888 | $replacements[] = $conf['gallery_title']; |
---|
[9197] | 889 | $patterns[] = '#\[myurl\]#i'; |
---|
[14651] | 890 | $replacements[] = get_gallery_home_url(); |
---|
[9160] | 891 | |
---|
[11018] | 892 | $infos = preg_replace($patterns, $replacements, $conf_UAM[29])."\n"."\n".$infos; |
---|
[9135] | 893 | } |
---|
| 894 | return $infos; |
---|
| 895 | } |
---|
| 896 | |
---|
| 897 | |
---|
| 898 | /** |
---|
[7968] | 899 | * Function called from main.inc.php to send validation email |
---|
| 900 | * |
---|
| 901 | * @param : Type of email, user id, username, email address, confirmation (optional) |
---|
| 902 | * |
---|
| 903 | */ |
---|
[5056] | 904 | function SendMail2User($typemail, $id, $username, $password, $email, $confirm) |
---|
| 905 | { |
---|
[5064] | 906 | global $conf; |
---|
[5056] | 907 | |
---|
[5181] | 908 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 909 | |
---|
[17887] | 910 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
[5056] | 911 | |
---|
[17887] | 912 | $infos1_perso = ""; |
---|
[5056] | 913 | $infos2_perso = ""; |
---|
[14729] | 914 | $subject = ""; |
---|
[5056] | 915 | |
---|
[7968] | 916 | // We have to get the user's language in database |
---|
[12271] | 917 | // ---------------------------------------------- |
---|
[5056] | 918 | $query =' |
---|
| 919 | SELECT user_id, language |
---|
| 920 | FROM '.USER_INFOS_TABLE.' |
---|
| 921 | WHERE user_id = '.$id.' |
---|
| 922 | ;'; |
---|
[5633] | 923 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 924 | |
---|
[7968] | 925 | // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language |
---|
[12271] | 926 | // ------------------------------------------------------------------------------------------------------------------------------- |
---|
[5056] | 927 | if (empty($data)) |
---|
| 928 | { |
---|
[7968] | 929 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[12271] | 930 | // --------------------------------------------------------------------------------------- |
---|
[5056] | 931 | $language = pwg_get_session_var( 'lang_switch', $user['language'] ); |
---|
| 932 | switch_lang_to($language); |
---|
| 933 | } |
---|
| 934 | else |
---|
| 935 | { |
---|
[7968] | 936 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[12271] | 937 | // --------------------------------------------------------------------------------------- |
---|
| 938 | //$language = $data['language']; // Usefull for debugging |
---|
[5056] | 939 | switch_lang_to($data['language']); |
---|
[5181] | 940 | load_language('plugin.lang', UAM_PATH); |
---|
[5056] | 941 | } |
---|
| 942 | |
---|
| 943 | switch($typemail) |
---|
| 944 | { |
---|
[14366] | 945 | case 1: // Confirmation email on user registration - Without information email (already managed by Piwigo) |
---|
[14729] | 946 | if (isset($conf_UAM[41]) and $conf_UAM[41] <> '') |
---|
| 947 | { |
---|
| 948 | // Management of Extension flags ([username], [mygallery]) |
---|
| 949 | // ------------------------------------------------------- |
---|
| 950 | $patterns[] = '#\[username\]#i'; |
---|
| 951 | $replacements[] = $username; |
---|
| 952 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 953 | $replacements[] = $conf['gallery_title']; |
---|
| 954 | |
---|
| 955 | if (function_exists('get_user_language_desc')) |
---|
| 956 | { |
---|
| 957 | $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[41]))."\n\n"; |
---|
| 958 | } |
---|
| 959 | else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM[41]))."\n\n"; |
---|
| 960 | } |
---|
[14366] | 961 | |
---|
| 962 | break; |
---|
| 963 | |
---|
| 964 | case 2: // Confirmation email on user profile update - With information email if checked |
---|
[14729] | 965 | if (isset($conf_UAM[41]) and $conf_UAM[41] <> '') |
---|
| 966 | { |
---|
| 967 | // Management of Extension flags ([username], [mygallery]) |
---|
| 968 | // ------------------------------------------------------- |
---|
| 969 | $patterns[] = '#\[username\]#i'; |
---|
| 970 | $replacements[] = $username; |
---|
| 971 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 972 | $replacements[] = $conf['gallery_title']; |
---|
| 973 | |
---|
| 974 | if (function_exists('get_user_language_desc')) |
---|
| 975 | { |
---|
| 976 | $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[41]))."\n\n"; |
---|
| 977 | } |
---|
| 978 | else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM[41]))."\n\n"; |
---|
| 979 | } |
---|
| 980 | |
---|
[5056] | 981 | $password = $password <> '' ? $password : l10n('UAM_empty_pwd'); |
---|
[14366] | 982 | |
---|
[11018] | 983 | if (isset($conf_UAM[8]) and $conf_UAM[8] <> '') |
---|
[5056] | 984 | { |
---|
[9197] | 985 | // Management of Extension flags ([username], [mygallery], [myurl]) |
---|
[12271] | 986 | // ---------------------------------------------------------------- |
---|
[9160] | 987 | $patterns[] = '#\[username\]#i'; |
---|
| 988 | $replacements[] = $username; |
---|
| 989 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 990 | $replacements[] = $conf['gallery_title']; |
---|
[9197] | 991 | $patterns[] = '#\[myurl\]#i'; |
---|
[14651] | 992 | $replacements[] = get_gallery_home_url(); |
---|
[9160] | 993 | |
---|
[5056] | 994 | if (function_exists('get_user_language_desc')) |
---|
| 995 | { |
---|
[11018] | 996 | $infos1_perso = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[8]))."\n\n"; |
---|
[5056] | 997 | } |
---|
[11018] | 998 | else $infos1_perso = l10n(preg_replace($patterns, $replacements, $conf_UAM[8]))."\n\n"; |
---|
[5056] | 999 | } |
---|
| 1000 | |
---|
[14366] | 1001 | if (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') |
---|
| 1002 | { |
---|
| 1003 | if (isset($conf_UAM[34]) and $conf_UAM[34] == 'true') // Allow display of clear password in email |
---|
| 1004 | { |
---|
| 1005 | $infos1 = array( |
---|
| 1006 | get_l10n_args('UAM_infos_mail %s', stripslashes($username)), |
---|
| 1007 | get_l10n_args('UAM_User: %s', stripslashes($username)), |
---|
| 1008 | get_l10n_args('UAM_Password: %s', $password), |
---|
| 1009 | get_l10n_args('Email: %s', $email), |
---|
| 1010 | get_l10n_args('', ''), |
---|
| 1011 | ); |
---|
| 1012 | } |
---|
| 1013 | else // Do not allow display of clear password in email |
---|
| 1014 | { |
---|
| 1015 | $infos1 = array( |
---|
| 1016 | get_l10n_args('UAM_infos_mail %s', stripslashes($username)), |
---|
| 1017 | get_l10n_args('UAM_User: %s', stripslashes($username)), |
---|
| 1018 | get_l10n_args('Email: %s', $email), |
---|
| 1019 | get_l10n_args('', ''), |
---|
| 1020 | ); |
---|
| 1021 | } |
---|
| 1022 | } |
---|
| 1023 | |
---|
[5056] | 1024 | break; |
---|
| 1025 | |
---|
[14366] | 1026 | case 3: // Only information email send to user if checked |
---|
[14729] | 1027 | if (isset($conf_UAM[43]) and $conf_UAM[43] <> '') |
---|
| 1028 | { |
---|
| 1029 | // Management of Extension flags ([username], [mygallery]) |
---|
| 1030 | // ------------------------------------------------------- |
---|
| 1031 | $patterns[] = '#\[username\]#i'; |
---|
| 1032 | $replacements[] = $username; |
---|
| 1033 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1034 | $replacements[] = $conf['gallery_title']; |
---|
| 1035 | |
---|
| 1036 | if (function_exists('get_user_language_desc')) |
---|
| 1037 | { |
---|
| 1038 | $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[43]))."\n\n"; |
---|
| 1039 | } |
---|
| 1040 | else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM[43]))."\n\n"; |
---|
| 1041 | } |
---|
| 1042 | |
---|
[5056] | 1043 | $password = $password <> '' ? $password : l10n('UAM_no_update_pwd'); |
---|
| 1044 | |
---|
[14366] | 1045 | if (isset($conf_UAM[8]) and $conf_UAM[8] <> '') |
---|
| 1046 | { |
---|
| 1047 | // Management of Extension flags ([username], [mygallery], [myurl]) |
---|
| 1048 | // ---------------------------------------------------------------- |
---|
| 1049 | $patterns[] = '#\[username\]#i'; |
---|
| 1050 | $replacements[] = $username; |
---|
| 1051 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1052 | $replacements[] = $conf['gallery_title']; |
---|
| 1053 | $patterns[] = '#\[myurl\]#i'; |
---|
[14651] | 1054 | $replacements[] = get_gallery_home_url(); |
---|
[14366] | 1055 | |
---|
| 1056 | if (function_exists('get_user_language_desc')) |
---|
| 1057 | { |
---|
| 1058 | $infos1_perso = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[8]))."\n\n"; |
---|
| 1059 | } |
---|
| 1060 | else $infos1_perso = l10n(preg_replace($patterns, $replacements, $conf_UAM[8]))."\n\n"; |
---|
| 1061 | } |
---|
| 1062 | |
---|
| 1063 | if (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') |
---|
| 1064 | { |
---|
| 1065 | if (isset($conf_UAM[34]) and $conf_UAM[34] == 'true') // Allow display of clear password in email |
---|
| 1066 | { |
---|
| 1067 | $infos1 = array( |
---|
| 1068 | get_l10n_args('UAM_infos_mail %s', stripslashes($username)), |
---|
| 1069 | get_l10n_args('UAM_User: %s', stripslashes($username)), |
---|
| 1070 | get_l10n_args('UAM_Password: %s', $password), |
---|
| 1071 | get_l10n_args('Email: %s', $email), |
---|
| 1072 | get_l10n_args('', ''), |
---|
| 1073 | ); |
---|
| 1074 | } |
---|
| 1075 | else // Do not allow display of clear password in email |
---|
| 1076 | { |
---|
| 1077 | $infos1 = array( |
---|
| 1078 | get_l10n_args('UAM_infos_mail %s', stripslashes($username)), |
---|
| 1079 | get_l10n_args('UAM_User: %s', stripslashes($username)), |
---|
| 1080 | get_l10n_args('Email: %s', $email), |
---|
| 1081 | get_l10n_args('', ''), |
---|
| 1082 | ); |
---|
| 1083 | } |
---|
| 1084 | } |
---|
| 1085 | |
---|
[5056] | 1086 | break; |
---|
| 1087 | } |
---|
| 1088 | |
---|
[12271] | 1089 | if ( isset($conf_UAM[1]) and $conf_UAM[1] == 'true' and $confirm) // Add confirmation link ? |
---|
[5056] | 1090 | { |
---|
| 1091 | $infos2 = array |
---|
| 1092 | ( |
---|
[9177] | 1093 | get_l10n_args('UAM_Link: %s', AddConfirmMail($id, $email)), |
---|
[5056] | 1094 | get_l10n_args('', ''), |
---|
| 1095 | ); |
---|
| 1096 | |
---|
[12271] | 1097 | if (isset($conf_UAM[9]) and $conf_UAM[9] <> '') // Add personal text in confirmation email ? |
---|
[5056] | 1098 | { |
---|
[11318] | 1099 | // Management of Extension flags ([username], [mygallery], [myurl], [Kdays]) |
---|
[12271] | 1100 | // ------------------------------------------------------------------------- |
---|
[9160] | 1101 | $patterns[] = '#\[username\]#i'; |
---|
| 1102 | $replacements[] = $username; |
---|
| 1103 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1104 | $replacements[] = $conf['gallery_title']; |
---|
[9197] | 1105 | $patterns[] = '#\[myurl\]#i'; |
---|
[14651] | 1106 | $replacements[] = get_gallery_home_url(); |
---|
[9160] | 1107 | |
---|
[11318] | 1108 | if (isset($conf_UAM_ConfirmMail[0]) and $conf_UAM_ConfirmMail[0] == 'true') // [Kdays] replacement only if related option is active |
---|
| 1109 | { |
---|
| 1110 | $patterns[] = '#\[Kdays\]#i'; |
---|
| 1111 | $replacements[] = $conf_UAM_ConfirmMail[1]; |
---|
| 1112 | } |
---|
| 1113 | |
---|
[5056] | 1114 | if (function_exists('get_user_language_desc')) |
---|
| 1115 | { |
---|
[11018] | 1116 | $infos2_perso = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[9]))."\n\n"; |
---|
[5056] | 1117 | } |
---|
[11018] | 1118 | else $infos2_perso = l10n(preg_replace($patterns, $replacements, $conf_UAM[9]))."\n\n"; |
---|
[5056] | 1119 | } |
---|
| 1120 | } |
---|
| 1121 | |
---|
[7968] | 1122 | // Sending the email with subject and contents |
---|
[12271] | 1123 | // ------------------------------------------- |
---|
[5056] | 1124 | pwg_mail($email, array( |
---|
| 1125 | 'subject' => $subject, |
---|
| 1126 | 'content' => (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(), |
---|
| 1127 | )); |
---|
| 1128 | |
---|
[7968] | 1129 | // Switching back to default language |
---|
[12271] | 1130 | // ---------------------------------- |
---|
[5056] | 1131 | switch_lang_back(); |
---|
| 1132 | } |
---|
| 1133 | |
---|
[10144] | 1134 | |
---|
[7968] | 1135 | /** |
---|
| 1136 | * Function called from UAM_admin.php to resend validation email with or without new validation key |
---|
| 1137 | * |
---|
| 1138 | * @param : Type of email, user id, username, email address, confirmation (optional) |
---|
| 1139 | * |
---|
| 1140 | */ |
---|
[5056] | 1141 | function ResendMail2User($typemail, $user_id, $username, $email, $confirm) |
---|
| 1142 | { |
---|
[5064] | 1143 | global $conf; |
---|
[14729] | 1144 | |
---|
| 1145 | $subject = ""; |
---|
[5056] | 1146 | |
---|
[5181] | 1147 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1148 | |
---|
[5181] | 1149 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[5056] | 1150 | |
---|
[17887] | 1151 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
[5056] | 1152 | |
---|
[7968] | 1153 | // We have to get the user's language in database |
---|
[12271] | 1154 | // ---------------------------------------------- |
---|
[5056] | 1155 | $query =' |
---|
| 1156 | SELECT user_id, language |
---|
| 1157 | FROM '.USER_INFOS_TABLE.' |
---|
| 1158 | WHERE user_id = '.$user_id.' |
---|
| 1159 | ;'; |
---|
[5633] | 1160 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 1161 | $language = $data['language']; |
---|
| 1162 | |
---|
[7968] | 1163 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[12271] | 1164 | // --------------------------------------------------------------------------------------- |
---|
[5056] | 1165 | switch_lang_to($data['language']); |
---|
| 1166 | |
---|
[5181] | 1167 | load_language('plugin.lang', UAM_PATH); |
---|
[5056] | 1168 | |
---|
| 1169 | switch($typemail) |
---|
| 1170 | { |
---|
[14366] | 1171 | case 1: //Generating email content for remind with a new key |
---|
[14729] | 1172 | if (isset($conf_UAM[42]) and $conf_UAM[42] <> '') |
---|
| 1173 | { |
---|
| 1174 | // Management of Extension flags ([username], [mygallery]) |
---|
| 1175 | // ------------------------------------------------------- |
---|
| 1176 | $patterns[] = '#\[username\]#i'; |
---|
| 1177 | $replacements[] = $username; |
---|
| 1178 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1179 | $replacements[] = $conf['gallery_title']; |
---|
| 1180 | |
---|
| 1181 | if (function_exists('get_user_language_desc')) |
---|
| 1182 | { |
---|
| 1183 | $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[42]))."\n\n"; |
---|
| 1184 | } |
---|
| 1185 | else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM[42]))."\n\n"; |
---|
| 1186 | } |
---|
[5056] | 1187 | |
---|
| 1188 | 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) |
---|
| 1189 | { |
---|
[11318] | 1190 | // Management of Extension flags ([username], [mygallery], [myurl], [Kdays]) |
---|
[12271] | 1191 | // ------------------------------------------------------------------------- |
---|
[9160] | 1192 | $patterns[] = '#\[username\]#i'; |
---|
| 1193 | $replacements[] = $username; |
---|
| 1194 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1195 | $replacements[] = $conf['gallery_title']; |
---|
[9197] | 1196 | $patterns[] = '#\[myurl\]#i'; |
---|
[14651] | 1197 | $replacements[] = get_gallery_home_url(); |
---|
[9160] | 1198 | |
---|
[11318] | 1199 | if (isset($conf_UAM_ConfirmMail[0]) and $conf_UAM_ConfirmMail[0] == 'true') // [Kdays] replacement only if related option is active |
---|
| 1200 | { |
---|
| 1201 | $patterns[] = '#\[Kdays\]#i'; |
---|
| 1202 | $replacements[] = $conf_UAM_ConfirmMail[1]; |
---|
| 1203 | } |
---|
| 1204 | |
---|
[5056] | 1205 | if (function_exists('get_user_language_desc')) |
---|
| 1206 | { |
---|
[9160] | 1207 | $infos1 = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[2]))."\n\n"; |
---|
[5056] | 1208 | } |
---|
[17887] | 1209 | else $infos1 = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[2]))."\n\n"; |
---|
[5056] | 1210 | |
---|
| 1211 | $infos2 = array |
---|
| 1212 | ( |
---|
[9177] | 1213 | get_l10n_args('UAM_Link: %s', ResetConfirmMail($user_id)), |
---|
[5056] | 1214 | get_l10n_args('', ''), |
---|
| 1215 | ); |
---|
[17887] | 1216 | } |
---|
[5056] | 1217 | |
---|
[12271] | 1218 | // Set reminder true |
---|
| 1219 | // ----------------- |
---|
[5056] | 1220 | $query = " |
---|
| 1221 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1222 | SET reminder = 'true' |
---|
| 1223 | WHERE user_id = '".$user_id."' |
---|
| 1224 | ;"; |
---|
| 1225 | pwg_query($query); |
---|
| 1226 | |
---|
[17887] | 1227 | break; |
---|
[5056] | 1228 | |
---|
[14366] | 1229 | case 2: //Generating email content for remind without a new key |
---|
[14729] | 1230 | if (isset($conf_UAM[42]) and $conf_UAM[42] <> '') |
---|
| 1231 | { |
---|
| 1232 | // Management of Extension flags ([username], [mygallery]) |
---|
| 1233 | // ------------------------------------------------------- |
---|
| 1234 | $patterns[] = '#\[username\]#i'; |
---|
| 1235 | $replacements[] = $username; |
---|
| 1236 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1237 | $replacements[] = $conf['gallery_title']; |
---|
| 1238 | |
---|
| 1239 | if (function_exists('get_user_language_desc')) |
---|
| 1240 | { |
---|
| 1241 | $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[42]))."\n\n"; |
---|
| 1242 | } |
---|
| 1243 | else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM[42]))."\n\n"; |
---|
| 1244 | } |
---|
[5056] | 1245 | |
---|
[9160] | 1246 | 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] | 1247 | { |
---|
[11318] | 1248 | // Management of Extension flags ([username], [mygallery], [myurl], [Kdays]) |
---|
[12271] | 1249 | // ------------------------------------------------------------------------- |
---|
[9160] | 1250 | $patterns[] = '#\[username\]#i'; |
---|
| 1251 | $replacements[] = $username; |
---|
| 1252 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1253 | $replacements[] = $conf['gallery_title']; |
---|
[9197] | 1254 | $patterns[] = '#\[myurl\]#i'; |
---|
[14651] | 1255 | $replacements[] = get_gallery_home_url(); |
---|
[11318] | 1256 | |
---|
| 1257 | if (isset($conf_UAM_ConfirmMail[0]) and $conf_UAM_ConfirmMail[0] == 'true') // [Kdays] replacement only if related option is active |
---|
| 1258 | { |
---|
| 1259 | $patterns[] = '#\[Kdays\]#i'; |
---|
| 1260 | $replacements[] = $conf_UAM_ConfirmMail[1]; |
---|
| 1261 | } |
---|
[9160] | 1262 | |
---|
[5056] | 1263 | if (function_exists('get_user_language_desc')) |
---|
| 1264 | { |
---|
[9160] | 1265 | $infos1 = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[4]))."\n\n"; |
---|
[5056] | 1266 | } |
---|
[9160] | 1267 | else $infos1 = l10n(preg_replace($patterns, $replacements, $conf_UAM_ConfirmMail[4]))."\n\n"; |
---|
[5056] | 1268 | } |
---|
| 1269 | |
---|
[12271] | 1270 | // Set reminder true |
---|
| 1271 | // ----------------- |
---|
[5056] | 1272 | $query = " |
---|
| 1273 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1274 | SET reminder = 'true' |
---|
| 1275 | WHERE user_id = '".$user_id."' |
---|
| 1276 | ;"; |
---|
| 1277 | pwg_query($query); |
---|
| 1278 | |
---|
| 1279 | break; |
---|
[17887] | 1280 | } |
---|
[5056] | 1281 | |
---|
| 1282 | pwg_mail($email, array( |
---|
| 1283 | 'subject' => $subject, |
---|
| 1284 | 'content' => ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(), |
---|
| 1285 | )); |
---|
| 1286 | |
---|
[7968] | 1287 | // Switching back to default language |
---|
[12271] | 1288 | // ---------------------------------- |
---|
[5056] | 1289 | switch_lang_back(); |
---|
| 1290 | } |
---|
| 1291 | |
---|
[10144] | 1292 | |
---|
[7968] | 1293 | /** |
---|
| 1294 | * Function called from UAM_admin.php to send a reminder mail for ghost users |
---|
| 1295 | * |
---|
| 1296 | * @param : User id, username, email address |
---|
| 1297 | * |
---|
| 1298 | */ |
---|
[5056] | 1299 | function ghostreminder($user_id, $username, $email) |
---|
| 1300 | { |
---|
[5064] | 1301 | global $conf; |
---|
[5056] | 1302 | |
---|
[5181] | 1303 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[14729] | 1304 | $subject = ""; |
---|
[5056] | 1305 | |
---|
[17887] | 1306 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
[5056] | 1307 | |
---|
[7968] | 1308 | // We have to get the user's language in database |
---|
[12271] | 1309 | // ---------------------------------------------- |
---|
[5056] | 1310 | $query =' |
---|
| 1311 | SELECT user_id, language |
---|
| 1312 | FROM '.USER_INFOS_TABLE.' |
---|
| 1313 | WHERE user_id = '.$user_id.' |
---|
| 1314 | ;'; |
---|
[5633] | 1315 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5056] | 1316 | $language = $data['language']; |
---|
| 1317 | |
---|
[7968] | 1318 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[12271] | 1319 | // --------------------------------------------------------------------------------------- |
---|
[5056] | 1320 | switch_lang_to($data['language']); |
---|
| 1321 | |
---|
[5181] | 1322 | load_language('plugin.lang', UAM_PATH); |
---|
[5056] | 1323 | |
---|
[14729] | 1324 | if (isset($conf_UAM[45]) and $conf_UAM[45] <> '') |
---|
| 1325 | { |
---|
| 1326 | // Management of Extension flags ([username], [mygallery]) |
---|
| 1327 | // ------------------------------------------------------- |
---|
| 1328 | $patterns[] = '#\[username\]#i'; |
---|
| 1329 | $replacements[] = $username; |
---|
| 1330 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1331 | $replacements[] = $conf['gallery_title']; |
---|
| 1332 | |
---|
| 1333 | if (function_exists('get_user_language_desc')) |
---|
| 1334 | { |
---|
| 1335 | $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[45]))."\n\n"; |
---|
| 1336 | } |
---|
| 1337 | else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM[45]))."\n\n"; |
---|
| 1338 | } |
---|
| 1339 | |
---|
[11018] | 1340 | if (isset($conf_UAM[17]) and $conf_UAM[17] <> '' and isset($conf_UAM[15]) and $conf_UAM[15] == 'true') |
---|
[5056] | 1341 | { |
---|
[11255] | 1342 | // Management of Extension flags ([username], [mygallery], [myurl], [days]) |
---|
[12271] | 1343 | // ------------------------------------------------------------------------ |
---|
[9160] | 1344 | $patterns[] = '#\[username\]#i'; |
---|
| 1345 | $replacements[] = $username; |
---|
| 1346 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1347 | $replacements[] = $conf['gallery_title']; |
---|
[9197] | 1348 | $patterns[] = '#\[myurl\]#i'; |
---|
[14651] | 1349 | $replacements[] = get_gallery_home_url(); |
---|
[11255] | 1350 | $patterns[] = '#\[days\]#i'; |
---|
| 1351 | $replacements[] = $conf_UAM[16]; |
---|
[9160] | 1352 | |
---|
[5056] | 1353 | if (function_exists('get_user_language_desc')) |
---|
| 1354 | { |
---|
[11018] | 1355 | $infos1 = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[17]))."\n\n"; |
---|
[5056] | 1356 | } |
---|
| 1357 | else |
---|
| 1358 | { |
---|
[11018] | 1359 | $infos1 = l10n(preg_replace($patterns, $replacements, $conf_UAM[17]))."\n\n"; |
---|
[5056] | 1360 | } |
---|
| 1361 | |
---|
| 1362 | resetlastvisit($user_id); |
---|
| 1363 | } |
---|
| 1364 | |
---|
| 1365 | pwg_mail($email, array( |
---|
| 1366 | 'subject' => $subject, |
---|
| 1367 | 'content' => $infos1.get_absolute_root_url(), |
---|
| 1368 | )); |
---|
| 1369 | |
---|
[7968] | 1370 | // Switching back to default language |
---|
[12271] | 1371 | // ---------------------------------- |
---|
[5056] | 1372 | switch_lang_back(); |
---|
| 1373 | } |
---|
| 1374 | |
---|
[10144] | 1375 | |
---|
[7968] | 1376 | /** |
---|
[8065] | 1377 | * Function called from functions.inc.php to send notification email when user have been downgraded |
---|
| 1378 | * |
---|
[8092] | 1379 | * @param : user id, username, email address |
---|
[8065] | 1380 | * |
---|
| 1381 | */ |
---|
| 1382 | function demotion_mail($id, $username, $email) |
---|
| 1383 | { |
---|
| 1384 | global $conf; |
---|
| 1385 | |
---|
| 1386 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 1387 | |
---|
[17887] | 1388 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
[8065] | 1389 | |
---|
[17887] | 1390 | $custom_txt = ""; |
---|
[14729] | 1391 | $subject = ""; |
---|
[8065] | 1392 | |
---|
| 1393 | // We have to get the user's language in database |
---|
[12271] | 1394 | // ---------------------------------------------- |
---|
[8065] | 1395 | $query =' |
---|
| 1396 | SELECT user_id, language |
---|
| 1397 | FROM '.USER_INFOS_TABLE.' |
---|
| 1398 | WHERE user_id = '.$id.' |
---|
| 1399 | ;'; |
---|
| 1400 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 1401 | |
---|
| 1402 | // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language |
---|
[12271] | 1403 | // ------------------------------------------------------------------------------------------------------------------------------- |
---|
[8065] | 1404 | if (empty($data)) |
---|
| 1405 | { |
---|
| 1406 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[12271] | 1407 | // --------------------------------------------------------------------------------------- |
---|
[8065] | 1408 | $language = pwg_get_session_var( 'lang_switch', $user['language'] ); |
---|
| 1409 | switch_lang_to($language); |
---|
| 1410 | } |
---|
| 1411 | else |
---|
| 1412 | { |
---|
| 1413 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[12271] | 1414 | // --------------------------------------------------------------------------------------- |
---|
[8065] | 1415 | $language = $data['language']; // Usefull for debugging |
---|
| 1416 | switch_lang_to($data['language']); |
---|
| 1417 | load_language('plugin.lang', UAM_PATH); |
---|
| 1418 | } |
---|
| 1419 | |
---|
[14729] | 1420 | if (isset($conf_UAM[44]) and $conf_UAM[44] <> '') |
---|
| 1421 | { |
---|
| 1422 | // Management of Extension flags ([username], [mygallery]) |
---|
| 1423 | // ------------------------------------------------------- |
---|
| 1424 | $patterns[] = '#\[username\]#i'; |
---|
| 1425 | $replacements[] = $username; |
---|
| 1426 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1427 | $replacements[] = $conf['gallery_title']; |
---|
| 1428 | |
---|
| 1429 | if (function_exists('get_user_language_desc')) |
---|
| 1430 | { |
---|
| 1431 | $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[44]))."\n\n"; |
---|
| 1432 | } |
---|
| 1433 | else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM[44]))."\n\n"; |
---|
| 1434 | } |
---|
[8065] | 1435 | |
---|
[11018] | 1436 | if (isset($conf_UAM[24]) and $conf_UAM[24] <> '') |
---|
[8065] | 1437 | { |
---|
[9197] | 1438 | // Management of Extension flags ([username], [mygallery], [myurl]) |
---|
[12271] | 1439 | // ---------------------------------------------------------------- |
---|
[9160] | 1440 | $patterns[] = '#\[username\]#i'; |
---|
[9253] | 1441 | $replacements[] = stripslashes($username); |
---|
[9160] | 1442 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1443 | $replacements[] = $conf['gallery_title']; |
---|
[9197] | 1444 | $patterns[] = '#\[myurl\]#i'; |
---|
[14651] | 1445 | $replacements[] = get_gallery_home_url(); |
---|
[9160] | 1446 | |
---|
[8065] | 1447 | if (function_exists('get_user_language_desc')) |
---|
| 1448 | { |
---|
[11018] | 1449 | $custom_txt = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[24]))."\n\n"; |
---|
[8065] | 1450 | } |
---|
[11018] | 1451 | else $custom_txt = l10n(preg_replace($patterns, $replacements, $conf_UAM[24]))."\n\n"; |
---|
[8065] | 1452 | } |
---|
| 1453 | |
---|
| 1454 | $infos1 = array( |
---|
[9177] | 1455 | get_l10n_args('UAM_User: %s', stripslashes($username)), |
---|
[8065] | 1456 | get_l10n_args('Email: %s', $email), |
---|
| 1457 | get_l10n_args('', ''), |
---|
| 1458 | ); |
---|
| 1459 | |
---|
| 1460 | $infos2 = array |
---|
| 1461 | ( |
---|
[9177] | 1462 | get_l10n_args('UAM_Link: %s', ResetConfirmMail($id)), |
---|
[8065] | 1463 | get_l10n_args('', ''), |
---|
| 1464 | ); |
---|
| 1465 | |
---|
[9253] | 1466 | resetlastvisit($id); |
---|
[8065] | 1467 | |
---|
| 1468 | // Sending the email with subject and contents |
---|
[12271] | 1469 | // ------------------------------------------- |
---|
[8065] | 1470 | pwg_mail($email, array( |
---|
| 1471 | 'subject' => $subject, |
---|
| 1472 | 'content' => ($custom_txt.l10n_args($infos1)."\n\n".l10n_args($infos2)."\n\n").get_absolute_root_url(), |
---|
| 1473 | )); |
---|
| 1474 | |
---|
| 1475 | // Switching back to default language |
---|
[12271] | 1476 | // ---------------------------------- |
---|
[8065] | 1477 | switch_lang_back(); |
---|
| 1478 | } |
---|
| 1479 | |
---|
[10144] | 1480 | |
---|
[8065] | 1481 | /** |
---|
[8092] | 1482 | * Function called from UAM_admin.php to send notification email when user registration have been manually validated by admin |
---|
| 1483 | * |
---|
| 1484 | * @param : user id |
---|
| 1485 | * |
---|
| 1486 | */ |
---|
| 1487 | function validation_mail($id) |
---|
| 1488 | { |
---|
| 1489 | global $conf; |
---|
| 1490 | |
---|
| 1491 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 1492 | |
---|
[17887] | 1493 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
[8092] | 1494 | |
---|
[17887] | 1495 | $custom_txt = ""; |
---|
[14729] | 1496 | $subject = ""; |
---|
[8092] | 1497 | |
---|
| 1498 | // We have to get the user's language in database |
---|
[12271] | 1499 | // ---------------------------------------------- |
---|
[8092] | 1500 | $query =' |
---|
| 1501 | SELECT user_id, language |
---|
| 1502 | FROM '.USER_INFOS_TABLE.' |
---|
| 1503 | WHERE user_id = '.$id.' |
---|
| 1504 | ;'; |
---|
| 1505 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 1506 | |
---|
| 1507 | // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language |
---|
[12271] | 1508 | // ------------------------------------------------------------------------------------------------------------------------------- |
---|
[8092] | 1509 | if (empty($data)) |
---|
| 1510 | { |
---|
| 1511 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[12271] | 1512 | // --------------------------------------------------------------------------------------- |
---|
[8092] | 1513 | $language = pwg_get_session_var( 'lang_switch', $user['language'] ); |
---|
| 1514 | switch_lang_to($language); |
---|
| 1515 | } |
---|
| 1516 | else |
---|
| 1517 | { |
---|
| 1518 | // And switch gallery to this language before using personalized and multilangual contents |
---|
[12271] | 1519 | // --------------------------------------------------------------------------------------- |
---|
[8092] | 1520 | $language = $data['language']; // Usefull for debugging |
---|
| 1521 | switch_lang_to($data['language']); |
---|
| 1522 | load_language('plugin.lang', UAM_PATH); |
---|
| 1523 | } |
---|
| 1524 | |
---|
| 1525 | // Retreive users email and user name from id |
---|
[12271] | 1526 | // ------------------------------------------ |
---|
[8092] | 1527 | $query =' |
---|
| 1528 | SELECT id, username, mail_address |
---|
| 1529 | FROM '.USERS_TABLE.' |
---|
| 1530 | WHERE id = '.$id.' |
---|
| 1531 | ;'; |
---|
| 1532 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 1533 | |
---|
[14729] | 1534 | if (isset($conf_UAM[46]) and $conf_UAM[46] <> '') |
---|
| 1535 | { |
---|
| 1536 | // Management of Extension flags ([username], [mygallery]) |
---|
| 1537 | // ------------------------------------------------------- |
---|
| 1538 | $patterns[] = '#\[username\]#i'; |
---|
[17804] | 1539 | $replacements[] = $result['username']; |
---|
[14729] | 1540 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1541 | $replacements[] = $conf['gallery_title']; |
---|
| 1542 | |
---|
| 1543 | if (function_exists('get_user_language_desc')) |
---|
| 1544 | { |
---|
| 1545 | $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[46]))."\n\n"; |
---|
| 1546 | } |
---|
| 1547 | else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM[46]))."\n\n"; |
---|
| 1548 | } |
---|
[8092] | 1549 | |
---|
[11018] | 1550 | if (isset($conf_UAM[27]) and $conf_UAM[27] <> '') |
---|
[8092] | 1551 | { |
---|
[9197] | 1552 | // Management of Extension flags ([username], [mygallery], [myurl]) |
---|
[12271] | 1553 | // ---------------------------------------------------------------- |
---|
[9160] | 1554 | $patterns[] = '#\[username\]#i'; |
---|
[9253] | 1555 | $replacements[] = $result['username']; |
---|
[9160] | 1556 | $patterns[] = '#\[mygallery\]#i'; |
---|
| 1557 | $replacements[] = $conf['gallery_title']; |
---|
[9197] | 1558 | $patterns[] = '#\[myurl\]#i'; |
---|
[14651] | 1559 | $replacements[] = get_gallery_home_url(); |
---|
[9160] | 1560 | |
---|
[8092] | 1561 | if (function_exists('get_user_language_desc')) |
---|
| 1562 | { |
---|
[11018] | 1563 | $custom_txt = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM[27]))."\n\n"; |
---|
[8092] | 1564 | } |
---|
[11018] | 1565 | else $custom_txt = l10n(preg_replace($patterns, $replacements, $conf_UAM[27]))."\n\n"; |
---|
[8092] | 1566 | } |
---|
| 1567 | |
---|
| 1568 | $infos = array( |
---|
[9177] | 1569 | get_l10n_args('UAM_User: %s', stripslashes($result['username'])), |
---|
[8092] | 1570 | get_l10n_args('Email: %s', $result['mail_address']), |
---|
| 1571 | get_l10n_args('', ''), |
---|
| 1572 | ); |
---|
| 1573 | |
---|
| 1574 | // Sending the email with subject and contents |
---|
[12271] | 1575 | // ------------------------------------------- |
---|
[8092] | 1576 | pwg_mail($result['mail_address'], array( |
---|
| 1577 | 'subject' => $subject, |
---|
| 1578 | 'content' => (l10n_args($infos)."\n\n".$custom_txt), |
---|
| 1579 | )); |
---|
| 1580 | |
---|
| 1581 | // Switching back to default language |
---|
[12271] | 1582 | // ---------------------------------- |
---|
[8092] | 1583 | switch_lang_back(); |
---|
| 1584 | } |
---|
| 1585 | |
---|
[10144] | 1586 | |
---|
[8092] | 1587 | /** |
---|
[7968] | 1588 | * Function called from functions AddConfirmMail and ResetConfirmMail for validation key generation |
---|
| 1589 | * |
---|
| 1590 | * @return : validation key |
---|
| 1591 | * |
---|
| 1592 | */ |
---|
[5056] | 1593 | function FindAvailableConfirmMailID() |
---|
| 1594 | { |
---|
| 1595 | while (true) |
---|
| 1596 | { |
---|
| 1597 | $id = generate_key(16); |
---|
| 1598 | $query = " |
---|
| 1599 | SELECT COUNT(*) |
---|
| 1600 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1601 | WHERE id = '".$id."' |
---|
| 1602 | ;"; |
---|
[5633] | 1603 | list($count) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 1604 | |
---|
| 1605 | if ($count == 0) |
---|
| 1606 | return $id; |
---|
| 1607 | } |
---|
| 1608 | } |
---|
| 1609 | |
---|
[10144] | 1610 | |
---|
[7968] | 1611 | /** |
---|
| 1612 | * Function called from functions SendMail2User to process unvalidated users and generate validation key link |
---|
| 1613 | * |
---|
| 1614 | * @param : User id, email address |
---|
| 1615 | * |
---|
| 1616 | * @return : Build validation key in URL |
---|
| 1617 | * |
---|
| 1618 | */ |
---|
[5056] | 1619 | function AddConfirmMail($user_id, $email) |
---|
| 1620 | { |
---|
| 1621 | global $conf; |
---|
| 1622 | |
---|
[5181] | 1623 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1624 | $Confirm_Mail_ID = FindAvailableConfirmMailID(); |
---|
| 1625 | |
---|
[5633] | 1626 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1627 | |
---|
| 1628 | if (isset($Confirm_Mail_ID)) |
---|
| 1629 | { |
---|
| 1630 | $query = " |
---|
| 1631 | SELECT status |
---|
| 1632 | FROM ".USER_INFOS_TABLE." |
---|
| 1633 | WHERE user_id = '".$user_id."' |
---|
| 1634 | ;"; |
---|
[5633] | 1635 | list($status) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 1636 | |
---|
| 1637 | $query = " |
---|
| 1638 | INSERT INTO ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1639 | (id, user_id, mail_address, status, date_check) |
---|
| 1640 | VALUES |
---|
| 1641 | ('".$Confirm_Mail_ID."', '".$user_id."', '".$email."', '".$status."', null) |
---|
| 1642 | ;"; |
---|
| 1643 | pwg_query($query); |
---|
| 1644 | |
---|
[8065] | 1645 | // Delete user from all groups |
---|
[12271] | 1646 | // --------------------------- |
---|
[5056] | 1647 | $query = " |
---|
| 1648 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1649 | WHERE user_id = '".$user_id."' |
---|
| 1650 | AND ( |
---|
[6354] | 1651 | group_id = '".$conf_UAM[2]."' |
---|
| 1652 | OR |
---|
[5056] | 1653 | group_id = '".$conf_UAM[3]."' |
---|
| 1654 | ) |
---|
| 1655 | ;"; |
---|
| 1656 | pwg_query($query); |
---|
| 1657 | |
---|
[8065] | 1658 | // Set user unvalidated status |
---|
[12271] | 1659 | // --------------------------- |
---|
[11018] | 1660 | if (!is_admin() and $conf_UAM[7] <> -1) |
---|
[5056] | 1661 | { |
---|
| 1662 | $query = " |
---|
| 1663 | UPDATE ".USER_INFOS_TABLE." |
---|
[11018] | 1664 | SET status = '".$conf_UAM[7]."' |
---|
[5056] | 1665 | WHERE user_id = '".$user_id."' |
---|
| 1666 | ;"; |
---|
| 1667 | pwg_query($query); |
---|
| 1668 | } |
---|
| 1669 | |
---|
[8065] | 1670 | // Set user unvalidated group |
---|
[12271] | 1671 | // -------------------------- |
---|
[8065] | 1672 | if (!is_admin() and $conf_UAM[2] <> -1) |
---|
[5056] | 1673 | { |
---|
| 1674 | $query = " |
---|
| 1675 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 1676 | (user_id, group_id) |
---|
| 1677 | VALUES |
---|
[6354] | 1678 | ('".$user_id."', '".$conf_UAM[2]."') |
---|
[5056] | 1679 | ;"; |
---|
| 1680 | pwg_query($query); |
---|
| 1681 | } |
---|
[12189] | 1682 | |
---|
| 1683 | // Set user unvalidated privacy level |
---|
[12271] | 1684 | // ---------------------------------- |
---|
[12189] | 1685 | if (!is_admin() and $conf_UAM[35] <> -1) |
---|
| 1686 | { |
---|
| 1687 | $query = " |
---|
| 1688 | UPDATE ".USER_INFOS_TABLE." |
---|
| 1689 | SET level = '".$conf_UAM[35]."' |
---|
| 1690 | WHERE user_id = '".$user_id."' |
---|
| 1691 | ;"; |
---|
| 1692 | pwg_query($query); |
---|
| 1693 | } |
---|
[5056] | 1694 | |
---|
[6785] | 1695 | return get_absolute_root_url().UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID.'&userid='.$user_id; |
---|
[5056] | 1696 | } |
---|
| 1697 | } |
---|
| 1698 | |
---|
[10144] | 1699 | |
---|
[7968] | 1700 | /** |
---|
[12189] | 1701 | * Function called from UAM_Adduser() to set group/status/level to new users if manual validation is set |
---|
[7968] | 1702 | * |
---|
| 1703 | * @param : User id |
---|
| 1704 | * |
---|
| 1705 | * |
---|
| 1706 | */ |
---|
[12189] | 1707 | function SetPermission($user_id) |
---|
[6757] | 1708 | { |
---|
| 1709 | global $conf; |
---|
| 1710 | |
---|
| 1711 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 1712 | |
---|
[12189] | 1713 | // Groups cleanup |
---|
[12271] | 1714 | // -------------- |
---|
[6757] | 1715 | $query = " |
---|
| 1716 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1717 | WHERE user_id = '".$user_id."' |
---|
| 1718 | AND ( |
---|
| 1719 | group_id = '".$conf_UAM[2]."' |
---|
| 1720 | OR |
---|
| 1721 | group_id = '".$conf_UAM[3]."' |
---|
| 1722 | ) |
---|
| 1723 | ;"; |
---|
| 1724 | pwg_query($query); |
---|
| 1725 | |
---|
[12189] | 1726 | if (!is_admin() and $conf_UAM[7] <> -1) // Set status |
---|
[6757] | 1727 | { |
---|
| 1728 | $query = " |
---|
| 1729 | UPDATE ".USER_INFOS_TABLE." |
---|
[11018] | 1730 | SET status = '".$conf_UAM[7]."' |
---|
[6757] | 1731 | WHERE user_id = '".$user_id."' |
---|
| 1732 | ;"; |
---|
| 1733 | pwg_query($query); |
---|
| 1734 | } |
---|
| 1735 | |
---|
[12189] | 1736 | if (!is_admin() and $conf_UAM[2] <> -1) // Set group |
---|
[6757] | 1737 | { |
---|
| 1738 | $query = " |
---|
| 1739 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 1740 | (user_id, group_id) |
---|
| 1741 | VALUES |
---|
| 1742 | ('".$user_id."', '".$conf_UAM[2]."') |
---|
| 1743 | ;"; |
---|
| 1744 | pwg_query($query); |
---|
| 1745 | } |
---|
[12189] | 1746 | |
---|
[13822] | 1747 | if (!is_admin() and $conf_UAM[35] <> -1) // Set privacy level |
---|
[12189] | 1748 | { |
---|
| 1749 | $query = " |
---|
| 1750 | INSERT INTO ".USER_INFOS_TABLE." |
---|
| 1751 | (user_id, level) |
---|
| 1752 | VALUES |
---|
[13822] | 1753 | ('".$user_id."', '".$conf_UAM[35]."') |
---|
[12189] | 1754 | ;"; |
---|
| 1755 | pwg_query($query); |
---|
| 1756 | } |
---|
[6757] | 1757 | } |
---|
| 1758 | |
---|
[10144] | 1759 | |
---|
[7968] | 1760 | /** |
---|
| 1761 | * Function called from UAM_admin.php to reset validation key |
---|
| 1762 | * |
---|
| 1763 | * @param : User id |
---|
| 1764 | * |
---|
| 1765 | * @return : Build validation key in URL |
---|
| 1766 | * |
---|
| 1767 | */ |
---|
[5056] | 1768 | function ResetConfirmMail($user_id) |
---|
| 1769 | { |
---|
| 1770 | global $conf; |
---|
| 1771 | |
---|
| 1772 | $Confirm_Mail_ID = FindAvailableConfirmMailID(); |
---|
| 1773 | |
---|
[5633] | 1774 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1775 | |
---|
| 1776 | if (isset($Confirm_Mail_ID)) |
---|
| 1777 | { |
---|
| 1778 | $query = " |
---|
| 1779 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1780 | SET id = '".$Confirm_Mail_ID."' |
---|
| 1781 | WHERE user_id = '".$user_id."' |
---|
| 1782 | ;"; |
---|
| 1783 | pwg_query($query); |
---|
| 1784 | |
---|
[17887] | 1785 | $query = " |
---|
[5056] | 1786 | UPDATE ".USER_INFOS_TABLE." |
---|
| 1787 | SET registration_date = '".$dbnow."' |
---|
| 1788 | WHERE user_id = '".$user_id."' |
---|
| 1789 | ;"; |
---|
[17887] | 1790 | pwg_query($query); |
---|
[5056] | 1791 | |
---|
[6785] | 1792 | return get_absolute_root_url().UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID.'&userid='.$user_id; |
---|
[5056] | 1793 | } |
---|
| 1794 | } |
---|
| 1795 | |
---|
[10144] | 1796 | |
---|
[7968] | 1797 | /** |
---|
| 1798 | * Function called from functions.inc.php to reset last visit date after sending a reminder |
---|
| 1799 | * |
---|
| 1800 | * @param : User id |
---|
| 1801 | * |
---|
| 1802 | */ |
---|
[5056] | 1803 | function resetlastvisit($user_id) |
---|
| 1804 | { |
---|
| 1805 | global $conf; |
---|
| 1806 | |
---|
[5633] | 1807 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1808 | |
---|
| 1809 | $query = " |
---|
| 1810 | UPDATE ".USER_LASTVISIT_TABLE." |
---|
| 1811 | SET lastvisit = '".$dbnow."', reminder = 'true' |
---|
| 1812 | WHERE user_id = '".$user_id."' |
---|
| 1813 | ;"; |
---|
| 1814 | pwg_query($query); |
---|
| 1815 | } |
---|
| 1816 | |
---|
| 1817 | |
---|
[7968] | 1818 | /** |
---|
| 1819 | * Function called from main.inc.php - Triggered on user deletion |
---|
| 1820 | * |
---|
| 1821 | */ |
---|
[5056] | 1822 | function DeleteConfirmMail($user_id) |
---|
| 1823 | { |
---|
| 1824 | $query = " |
---|
| 1825 | DELETE FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1826 | WHERE user_id = '".$user_id."' |
---|
| 1827 | ;"; |
---|
| 1828 | pwg_query($query); |
---|
| 1829 | } |
---|
| 1830 | |
---|
[7968] | 1831 | /** |
---|
| 1832 | * Function called from main.inc.php - Triggered on user deletion |
---|
| 1833 | * |
---|
| 1834 | */ |
---|
[5056] | 1835 | function DeleteLastVisit($user_id) |
---|
| 1836 | { |
---|
| 1837 | $query = " |
---|
| 1838 | DELETE FROM ".USER_LASTVISIT_TABLE." |
---|
| 1839 | WHERE user_id = '".$user_id."' |
---|
| 1840 | ;"; |
---|
| 1841 | pwg_query($query); |
---|
| 1842 | } |
---|
| 1843 | |
---|
[10144] | 1844 | |
---|
[7968] | 1845 | /** |
---|
| 1846 | * Function called from main.inc.php - Triggered on user deletion |
---|
| 1847 | * |
---|
| 1848 | * @param : User id |
---|
| 1849 | * |
---|
| 1850 | */ |
---|
[6775] | 1851 | function DeleteRedir($user_id) |
---|
| 1852 | { |
---|
| 1853 | $tab = array(); |
---|
| 1854 | |
---|
[6785] | 1855 | $query = ' |
---|
[6775] | 1856 | SELECT value |
---|
[6785] | 1857 | FROM '.CONFIG_TABLE.' |
---|
| 1858 | WHERE param = "UserAdvManager_Redir" |
---|
| 1859 | ;'; |
---|
[6775] | 1860 | |
---|
| 1861 | $tab = pwg_db_fetch_row(pwg_query($query)); |
---|
| 1862 | |
---|
| 1863 | $values = explode(',', $tab[0]); |
---|
| 1864 | |
---|
| 1865 | unset($values[array_search($user_id, $values)]); |
---|
| 1866 | |
---|
| 1867 | $query = " |
---|
| 1868 | UPDATE ".CONFIG_TABLE." |
---|
| 1869 | SET value = \"".implode(',', $values)."\" |
---|
| 1870 | WHERE param = 'UserAdvManager_Redir';"; |
---|
| 1871 | |
---|
| 1872 | pwg_query($query); |
---|
| 1873 | } |
---|
| 1874 | |
---|
[10144] | 1875 | |
---|
[7968] | 1876 | /** |
---|
| 1877 | * Function called from ConfirmMail.php to verify validation key used by user according time limit |
---|
| 1878 | * Return true is key validation is OK else return false |
---|
| 1879 | * |
---|
| 1880 | * @param : User id |
---|
| 1881 | * |
---|
| 1882 | * @return : Bool |
---|
| 1883 | * |
---|
| 1884 | */ |
---|
[5056] | 1885 | function VerifyConfirmMail($id) |
---|
| 1886 | { |
---|
| 1887 | global $conf; |
---|
| 1888 | |
---|
| 1889 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 1890 | |
---|
[5181] | 1891 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 1892 | |
---|
[5181] | 1893 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[5056] | 1894 | |
---|
| 1895 | $query = " |
---|
| 1896 | SELECT COUNT(*) |
---|
| 1897 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1898 | WHERE id = '".$id."' |
---|
| 1899 | ;"; |
---|
[5633] | 1900 | list($count) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 1901 | |
---|
| 1902 | if ($count == 1) |
---|
| 1903 | { |
---|
| 1904 | $query = " |
---|
| 1905 | SELECT user_id, status, date_check |
---|
| 1906 | FROM ".USER_CONFIRM_MAIL_TABLE." |
---|
| 1907 | WHERE id = '".$id."' |
---|
| 1908 | ;"; |
---|
[5633] | 1909 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[9266] | 1910 | |
---|
[12227] | 1911 | if (!empty($data) and isset($data['user_id']) and is_null($data['date_check'])) |
---|
[5056] | 1912 | { |
---|
| 1913 | $query = " |
---|
| 1914 | SELECT registration_date |
---|
| 1915 | FROM ".USER_INFOS_TABLE." |
---|
| 1916 | WHERE user_id = '".$data['user_id']."' |
---|
| 1917 | ;"; |
---|
[5633] | 1918 | list($registration_date) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 1919 | |
---|
[7968] | 1920 | // Time limit process |
---|
| 1921 | // ******************************************** |
---|
[5056] | 1922 | if (!empty($registration_date)) |
---|
| 1923 | { |
---|
[17887] | 1924 | // Verify Confirmmail with time limit ON |
---|
[12271] | 1925 | // ------------------------------------- |
---|
[17887] | 1926 | if (isset ($conf_UAM_ConfirmMail[1])) |
---|
| 1927 | { |
---|
| 1928 | // Dates formating and compare |
---|
[12271] | 1929 | // --------------------------- |
---|
[17887] | 1930 | $today = date("d-m-Y"); // Get today's date |
---|
| 1931 | list($day, $month, $year) = explode('-', $today); // explode date of today |
---|
| 1932 | $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp |
---|
| 1933 | |
---|
| 1934 | list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date |
---|
| 1935 | list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date |
---|
| 1936 | $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp |
---|
| 1937 | |
---|
| 1938 | $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps |
---|
| 1939 | $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days |
---|
[5056] | 1940 | |
---|
[17887] | 1941 | // Condition with the value set for time limit |
---|
[12271] | 1942 | // ------------------------------------------- |
---|
[17887] | 1943 | if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set |
---|
| 1944 | { |
---|
| 1945 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 1946 | |
---|
[12271] | 1947 | // Update ConfirmMail table |
---|
| 1948 | // ------------------------ |
---|
[17887] | 1949 | $query = ' |
---|
[5056] | 1950 | UPDATE '.USER_CONFIRM_MAIL_TABLE.' |
---|
[9266] | 1951 | SET date_check="'.$dbnow.'", reminder="false" |
---|
[5056] | 1952 | WHERE id = "'.$id.'" |
---|
| 1953 | ;'; |
---|
[17887] | 1954 | pwg_query($query); |
---|
[12189] | 1955 | |
---|
| 1956 | // Update LastVisit table - Force reminder field to false |
---|
[12271] | 1957 | // Usefull when a user has been automatically downgraded and revalidate its registration |
---|
| 1958 | // ------------------------------------------------------------------------------------- |
---|
[17887] | 1959 | $query = ' |
---|
[12189] | 1960 | UPDATE '.USER_LASTVISIT_TABLE.' |
---|
| 1961 | SET reminder="false" |
---|
| 1962 | WHERE user_id = "'.$data['user_id'].'" |
---|
| 1963 | ;'; |
---|
[17887] | 1964 | pwg_query($query); |
---|
[5056] | 1965 | |
---|
[17887] | 1966 | if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group |
---|
| 1967 | { |
---|
| 1968 | $query = " |
---|
[5056] | 1969 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 1970 | WHERE user_id = '".$data['user_id']."' |
---|
[6354] | 1971 | AND group_id = '".$conf_UAM[2]."' |
---|
[5056] | 1972 | ;"; |
---|
[17887] | 1973 | pwg_query($query); |
---|
| 1974 | } |
---|
| 1975 | |
---|
| 1976 | if ($conf_UAM[3] <> -1) // Add user to validated users group |
---|
| 1977 | { |
---|
| 1978 | $query = " |
---|
[5056] | 1979 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 1980 | (user_id, group_id) |
---|
| 1981 | VALUES |
---|
[6354] | 1982 | ('".$data['user_id']."', '".$conf_UAM[3]."') |
---|
[5056] | 1983 | ;"; |
---|
[17887] | 1984 | pwg_query($query); |
---|
| 1985 | } |
---|
[5056] | 1986 | |
---|
[17887] | 1987 | if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status |
---|
| 1988 | { |
---|
| 1989 | $query = " |
---|
[5056] | 1990 | UPDATE ".USER_INFOS_TABLE." |
---|
[6354] | 1991 | SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[4])."' |
---|
[5056] | 1992 | WHERE user_id = '".$data['user_id']."' |
---|
| 1993 | ;"; |
---|
[17887] | 1994 | pwg_query($query); |
---|
| 1995 | } |
---|
[12189] | 1996 | |
---|
[17887] | 1997 | if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level |
---|
| 1998 | { |
---|
| 1999 | $query = " |
---|
[12189] | 2000 | UPDATE ".USER_INFOS_TABLE." |
---|
| 2001 | SET level = '".(isset($data['level']) ? $data['level'] : $conf_UAM[36])."' |
---|
| 2002 | WHERE user_id = '".$data['user_id']."' |
---|
| 2003 | ;"; |
---|
[17887] | 2004 | pwg_query($query); |
---|
| 2005 | } |
---|
[12189] | 2006 | |
---|
[17887] | 2007 | // Refresh user's category cache |
---|
[12271] | 2008 | // ----------------------------- |
---|
[17887] | 2009 | invalidate_user_cache(); |
---|
[5056] | 2010 | |
---|
[17887] | 2011 | return true; |
---|
| 2012 | } |
---|
| 2013 | elseif ($deltadays > $conf_UAM_ConfirmMail[1]) // If timelimit exeeds |
---|
| 2014 | { |
---|
| 2015 | return false; |
---|
| 2016 | } |
---|
| 2017 | } |
---|
| 2018 | // Verify Confirmmail with time limit OFF |
---|
[12271] | 2019 | // -------------------------------------- |
---|
[17887] | 2020 | else |
---|
| 2021 | { |
---|
| 2022 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 2023 | |
---|
[12271] | 2024 | // Update ConfirmMail table |
---|
| 2025 | // ------------------------ |
---|
[17887] | 2026 | $query = ' |
---|
[5056] | 2027 | UPDATE '.USER_CONFIRM_MAIL_TABLE.' |
---|
| 2028 | SET date_check="'.$dbnow.'" |
---|
| 2029 | WHERE id = "'.$id.'" |
---|
| 2030 | ;'; |
---|
[17887] | 2031 | pwg_query($query); |
---|
[12189] | 2032 | |
---|
| 2033 | // Update LastVisit table - Force reminder field to false |
---|
[12271] | 2034 | // Usefull when a user has been automatically downgraded and revalidate its registration |
---|
| 2035 | // ------------------------------------------------------------------------------------- |
---|
[17887] | 2036 | $query = ' |
---|
[12189] | 2037 | UPDATE '.USER_LASTVISIT_TABLE.' |
---|
| 2038 | SET reminder="false" |
---|
| 2039 | WHERE user_id = "'.$data['user_id'].'" |
---|
| 2040 | ;'; |
---|
| 2041 | pwg_query($query); |
---|
[5056] | 2042 | |
---|
[17887] | 2043 | if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group |
---|
| 2044 | { |
---|
| 2045 | $query = " |
---|
[5056] | 2046 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 2047 | WHERE user_id = '".$data['user_id']."' |
---|
[6354] | 2048 | AND group_id = '".$conf_UAM[2]."' |
---|
[5056] | 2049 | ;"; |
---|
[17887] | 2050 | pwg_query($query); |
---|
| 2051 | } |
---|
[5056] | 2052 | |
---|
[17887] | 2053 | if ($conf_UAM[3] <> -1) |
---|
| 2054 | { |
---|
| 2055 | $query = " |
---|
[5056] | 2056 | DELETE FROM ".USER_GROUP_TABLE." |
---|
| 2057 | WHERE user_id = '".$data['user_id']."' |
---|
[6354] | 2058 | AND group_id = '".$conf_UAM[3]."' |
---|
[5056] | 2059 | ;"; |
---|
[17887] | 2060 | pwg_query($query); |
---|
[5056] | 2061 | |
---|
[17887] | 2062 | $query = " |
---|
[5056] | 2063 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 2064 | (user_id, group_id) |
---|
| 2065 | VALUES |
---|
[6354] | 2066 | ('".$data['user_id']."', '".$conf_UAM[3]."') |
---|
[5056] | 2067 | ;"; |
---|
[17887] | 2068 | pwg_query($query); |
---|
| 2069 | } |
---|
[5056] | 2070 | |
---|
[17887] | 2071 | if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status |
---|
| 2072 | { |
---|
| 2073 | $query = " |
---|
[5056] | 2074 | UPDATE ".USER_INFOS_TABLE." |
---|
[6354] | 2075 | SET status = '".(isset($data['status']) ? $data['status'] : $conf_UAM[4])."' |
---|
[5056] | 2076 | WHERE user_id = '".$data['user_id']."' |
---|
| 2077 | ;"; |
---|
[17887] | 2078 | pwg_query($query); |
---|
| 2079 | } |
---|
[12189] | 2080 | |
---|
[17887] | 2081 | if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level |
---|
| 2082 | { |
---|
| 2083 | $query = " |
---|
[12189] | 2084 | UPDATE ".USER_INFOS_TABLE." |
---|
| 2085 | SET level = '".(isset($data['level']) ? $data['level'] : $conf_UAM[36])."' |
---|
| 2086 | WHERE user_id = '".$data['user_id']."' |
---|
| 2087 | ;"; |
---|
[17887] | 2088 | pwg_query($query); |
---|
| 2089 | } |
---|
[12189] | 2090 | |
---|
[17887] | 2091 | // Refresh user's category cache |
---|
[12271] | 2092 | // ----------------------------- |
---|
[17887] | 2093 | invalidate_user_cache(); |
---|
[5056] | 2094 | |
---|
[17887] | 2095 | return true; |
---|
| 2096 | } |
---|
| 2097 | } |
---|
| 2098 | } |
---|
[12227] | 2099 | else if (!empty($data) and !is_null($data['date_check'])) |
---|
| 2100 | { |
---|
| 2101 | return false; |
---|
| 2102 | } |
---|
[17887] | 2103 | } |
---|
[5056] | 2104 | else |
---|
| 2105 | return false; |
---|
| 2106 | } |
---|
| 2107 | |
---|
[10144] | 2108 | |
---|
[7968] | 2109 | /** |
---|
| 2110 | * Function called from UAM_admin.php to force users validation by admin |
---|
| 2111 | * |
---|
| 2112 | * @param : User id |
---|
| 2113 | * |
---|
| 2114 | */ |
---|
[5056] | 2115 | function ForceValidation($id) |
---|
| 2116 | { |
---|
| 2117 | global $conf; |
---|
| 2118 | |
---|
[5181] | 2119 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 2120 | |
---|
[8072] | 2121 | if (isset($conf_UAM[1]) and $conf_UAM[1] == 'true') |
---|
[5056] | 2122 | { |
---|
[8072] | 2123 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
---|
[5056] | 2124 | |
---|
[17887] | 2125 | $query = " |
---|
[5056] | 2126 | UPDATE ".USER_CONFIRM_MAIL_TABLE." |
---|
| 2127 | SET date_check='".$dbnow."' |
---|
[8072] | 2128 | WHERE user_id = '".$id."' |
---|
[5056] | 2129 | ;"; |
---|
[8072] | 2130 | pwg_query($query); |
---|
[17846] | 2131 | } |
---|
| 2132 | |
---|
| 2133 | if ($conf_UAM[2] <> -1) // Delete user from waiting group |
---|
[17887] | 2134 | { |
---|
[17846] | 2135 | $query = " |
---|
[5056] | 2136 | DELETE FROM ".USER_GROUP_TABLE." |
---|
[8072] | 2137 | WHERE user_id = '".$id."' |
---|
[6354] | 2138 | AND group_id = '".$conf_UAM[2]."' |
---|
[5056] | 2139 | ;"; |
---|
[17887] | 2140 | pwg_query($query); |
---|
[17846] | 2141 | } |
---|
[5056] | 2142 | |
---|
[17887] | 2143 | if ($conf_UAM[3] <> -1) // Set user's valid group |
---|
| 2144 | { |
---|
[17846] | 2145 | $query = " |
---|
[5056] | 2146 | DELETE FROM ".USER_GROUP_TABLE." |
---|
[8072] | 2147 | WHERE user_id = '".$id."' |
---|
[6354] | 2148 | AND group_id = '".$conf_UAM[3]."' |
---|
[8072] | 2149 | ;"; |
---|
[17846] | 2150 | pwg_query($query); |
---|
[17887] | 2151 | |
---|
| 2152 | $query = " |
---|
[5056] | 2153 | INSERT INTO ".USER_GROUP_TABLE." |
---|
| 2154 | (user_id, group_id) |
---|
| 2155 | VALUES |
---|
[8072] | 2156 | ('".$id."', '".$conf_UAM[3]."') |
---|
[5056] | 2157 | ;"; |
---|
[17887] | 2158 | pwg_query($query); |
---|
[17846] | 2159 | } |
---|
[5056] | 2160 | |
---|
[17887] | 2161 | if ($conf_UAM[4] <> -1) // Set user's valid status |
---|
| 2162 | { |
---|
[17846] | 2163 | $query = " |
---|
[5056] | 2164 | UPDATE ".USER_INFOS_TABLE." |
---|
[8072] | 2165 | SET status = '".$conf_UAM[4]."' |
---|
| 2166 | WHERE user_id = '".$id."' |
---|
[5056] | 2167 | ;"; |
---|
[17887] | 2168 | pwg_query($query); |
---|
[8072] | 2169 | } |
---|
| 2170 | |
---|
[17887] | 2171 | if ($conf_UAM[36] <> -1) // Set user's valid privacy level |
---|
| 2172 | { |
---|
[17846] | 2173 | $query = " |
---|
[8072] | 2174 | UPDATE ".USER_INFOS_TABLE." |
---|
[12189] | 2175 | SET level = '".$conf_UAM[36]."' |
---|
| 2176 | WHERE user_id = '".$id."' |
---|
| 2177 | ;"; |
---|
[17887] | 2178 | pwg_query($query); |
---|
[8072] | 2179 | } |
---|
[5056] | 2180 | } |
---|
| 2181 | |
---|
[10144] | 2182 | |
---|
[7968] | 2183 | /** |
---|
[12661] | 2184 | * Function called from functions.inc.php - Check if username matches forbidden caracters |
---|
[7968] | 2185 | * |
---|
| 2186 | * @param : User login |
---|
| 2187 | * |
---|
| 2188 | * @return : Bool |
---|
| 2189 | * |
---|
| 2190 | */ |
---|
[5056] | 2191 | function ValidateUsername($login) |
---|
| 2192 | { |
---|
| 2193 | global $conf; |
---|
| 2194 | |
---|
[5181] | 2195 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 2196 | |
---|
[11018] | 2197 | if (isset($login) and isset($conf_UAM[6]) and $conf_UAM[6] <> '') |
---|
[5056] | 2198 | { |
---|
[11018] | 2199 | $conf_CharExclusion = preg_split("/,/",$conf_UAM[6]); |
---|
[5181] | 2200 | for ($i = 0 ; $i < count($conf_CharExclusion) ; $i++) |
---|
[5056] | 2201 | { |
---|
[5181] | 2202 | $pattern = '/'.$conf_CharExclusion[$i].'/i'; |
---|
[5056] | 2203 | if (preg_match($pattern, $login)) |
---|
| 2204 | { |
---|
| 2205 | return true; |
---|
| 2206 | } |
---|
| 2207 | } |
---|
| 2208 | } |
---|
| 2209 | else |
---|
| 2210 | { |
---|
| 2211 | return false; |
---|
| 2212 | } |
---|
| 2213 | } |
---|
| 2214 | |
---|
[10144] | 2215 | |
---|
[7968] | 2216 | /** |
---|
| 2217 | * Function called from main.inc.php - Check if user's email is in excluded email providers list |
---|
| 2218 | * Doesn't work on call - Must be copied in main.inc.php to work |
---|
| 2219 | * |
---|
| 2220 | * @param : Email address |
---|
| 2221 | * |
---|
| 2222 | * @return : Bool |
---|
| 2223 | * |
---|
| 2224 | */ |
---|
[5056] | 2225 | function ValidateEmailProvider($email) |
---|
| 2226 | { |
---|
| 2227 | global $conf; |
---|
| 2228 | |
---|
[5181] | 2229 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 2230 | |
---|
[17887] | 2231 | if (isset($email) and isset($conf_UAM[11]) and $conf_UAM[11] <> '') |
---|
| 2232 | { |
---|
| 2233 | $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[11]); |
---|
| 2234 | for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++) |
---|
| 2235 | { |
---|
| 2236 | $pattern = '/'.$conf_MailExclusion[$i].'/i'; |
---|
| 2237 | if (preg_match($pattern, $email)) |
---|
[5056] | 2238 | { |
---|
[17887] | 2239 | return true; |
---|
[5056] | 2240 | } |
---|
[17887] | 2241 | } |
---|
| 2242 | } |
---|
[5056] | 2243 | else |
---|
| 2244 | { |
---|
| 2245 | return false; |
---|
| 2246 | } |
---|
| 2247 | } |
---|
| 2248 | |
---|
[10144] | 2249 | |
---|
[7968] | 2250 | /** |
---|
| 2251 | * Function called from UAM_admin.php - Get unvalidated users according time limit |
---|
| 2252 | * |
---|
| 2253 | * @return : List of users |
---|
| 2254 | * |
---|
| 2255 | */ |
---|
[5056] | 2256 | function get_unvalid_user_list() |
---|
| 2257 | { |
---|
[17887] | 2258 | global $conf, $page; |
---|
[5056] | 2259 | |
---|
[17887] | 2260 | // Get ConfirmMail configuration |
---|
[12271] | 2261 | // ----------------------------- |
---|
[5181] | 2262 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[7968] | 2263 | // Get UAM configuration |
---|
[12271] | 2264 | // --------------------- |
---|
[5181] | 2265 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 2266 | |
---|
| 2267 | $users = array(); |
---|
| 2268 | |
---|
[17887] | 2269 | // Search users depending expiration date |
---|
[12271] | 2270 | // -------------------------------------- |
---|
[5056] | 2271 | $query = ' |
---|
| 2272 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
| 2273 | u.'.$conf['user_fields']['username'].' AS username, |
---|
| 2274 | u.'.$conf['user_fields']['email'].' AS email, |
---|
| 2275 | ui.status, |
---|
| 2276 | ui.enabled_high, |
---|
| 2277 | ui.level, |
---|
| 2278 | ui.registration_date |
---|
| 2279 | FROM '.USERS_TABLE.' AS u |
---|
| 2280 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
| 2281 | ON u.'.$conf['user_fields']['id'].' = ui.user_id |
---|
| 2282 | LEFT JOIN '.USER_GROUP_TABLE.' AS ug |
---|
| 2283 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
| 2284 | WHERE u.'.$conf['user_fields']['id'].' >= 3 |
---|
| 2285 | AND (TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) >= "'.$conf_UAM_ConfirmMail[1].'" |
---|
| 2286 | OR TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) < "'.$conf_UAM_ConfirmMail[1].'")'; |
---|
| 2287 | |
---|
[17887] | 2288 | if ($conf_UAM[2] <> '-1' and $conf_UAM[7] == '-1') |
---|
[5056] | 2289 | { |
---|
| 2290 | $query.= ' |
---|
[6354] | 2291 | AND ug.group_id = '.$conf_UAM[2]; |
---|
[5056] | 2292 | } |
---|
[11018] | 2293 | if ($conf_UAM[2] == '-1' and $conf_UAM[7] <> '-1') |
---|
[5056] | 2294 | { |
---|
| 2295 | $query.= ' |
---|
[11018] | 2296 | AND ui.status = \''.$conf_UAM[7]."'"; |
---|
[5056] | 2297 | } |
---|
[11018] | 2298 | if ($conf_UAM[2] <> '-1' and $conf_UAM[7] <> '-1') |
---|
[5056] | 2299 | { |
---|
| 2300 | $query.= ' |
---|
[17890] | 2301 | AND ug.group_id = '.$conf_UAM[2]; |
---|
[5056] | 2302 | } |
---|
| 2303 | $query.= ' |
---|
[6399] | 2304 | ORDER BY ui.registration_date ASC |
---|
[5056] | 2305 | ;'; |
---|
| 2306 | |
---|
[17887] | 2307 | $result = pwg_query($query); |
---|
[5056] | 2308 | |
---|
[5633] | 2309 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 2310 | { |
---|
[17887] | 2311 | $user = $row; |
---|
[5056] | 2312 | $user['groups'] = array(); |
---|
| 2313 | |
---|
| 2314 | array_push($users, $user); |
---|
[17887] | 2315 | } |
---|
[5056] | 2316 | |
---|
[17887] | 2317 | // Add groups list |
---|
[12271] | 2318 | // --------------- |
---|
[5056] | 2319 | $user_ids = array(); |
---|
| 2320 | foreach ($users as $i => $user) |
---|
| 2321 | { |
---|
[17887] | 2322 | $user_ids[$i] = $user['id']; |
---|
| 2323 | } |
---|
| 2324 | |
---|
| 2325 | $user_nums = array_flip($user_ids); |
---|
[5056] | 2326 | |
---|
| 2327 | if (count($user_ids) > 0) |
---|
| 2328 | { |
---|
[17887] | 2329 | $query = ' |
---|
[5056] | 2330 | SELECT user_id, group_id |
---|
| 2331 | FROM '.USER_GROUP_TABLE.' |
---|
| 2332 | WHERE user_id IN ('.implode(',', $user_ids).') |
---|
| 2333 | ;'; |
---|
| 2334 | |
---|
[17887] | 2335 | $result = pwg_query($query); |
---|
[5056] | 2336 | |
---|
[5633] | 2337 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 2338 | { |
---|
[17887] | 2339 | array_push( |
---|
| 2340 | $users[$user_nums[$row['user_id']]]['groups'], |
---|
[5056] | 2341 | $row['group_id'] |
---|
[17887] | 2342 | ); |
---|
| 2343 | } |
---|
| 2344 | } |
---|
[5056] | 2345 | |
---|
[17887] | 2346 | return $users; |
---|
[5056] | 2347 | } |
---|
| 2348 | |
---|
[10144] | 2349 | |
---|
[7968] | 2350 | /** |
---|
[9266] | 2351 | * Function called from functions.inc.php - Get all users who haven't validate their registration in configured time |
---|
| 2352 | * to delete or remail them automatically |
---|
| 2353 | * |
---|
| 2354 | * @return : List of users |
---|
| 2355 | * |
---|
| 2356 | */ |
---|
| 2357 | function get_unvalid_user_autotasks() |
---|
| 2358 | { |
---|
[17887] | 2359 | global $conf, $page; |
---|
[9266] | 2360 | |
---|
[17887] | 2361 | // Get ConfirmMail configuration |
---|
[12271] | 2362 | // ----------------------------- |
---|
[9266] | 2363 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
| 2364 | |
---|
| 2365 | $users = array(); |
---|
| 2366 | |
---|
[17887] | 2367 | // search users depending expiration date |
---|
[12271] | 2368 | // -------------------------------------- |
---|
[9266] | 2369 | $query = ' |
---|
| 2370 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
| 2371 | ui.registration_date |
---|
| 2372 | FROM '.USERS_TABLE.' AS u |
---|
| 2373 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
| 2374 | ON u.'.$conf['user_fields']['id'].' = ui.user_id |
---|
| 2375 | WHERE u.'.$conf['user_fields']['id'].' >= 3 |
---|
| 2376 | AND (TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) >= "'.$conf_UAM_ConfirmMail[1].'") |
---|
| 2377 | ORDER BY ui.registration_date ASC;'; |
---|
| 2378 | |
---|
[17887] | 2379 | $result = pwg_query($query); |
---|
[9266] | 2380 | |
---|
| 2381 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 2382 | { |
---|
| 2383 | array_push($users, $row); |
---|
[17887] | 2384 | } |
---|
[9266] | 2385 | |
---|
[17887] | 2386 | return $users; |
---|
[9266] | 2387 | } |
---|
| 2388 | |
---|
[10144] | 2389 | |
---|
[9266] | 2390 | /** |
---|
[7968] | 2391 | * Function called from UAM_admin.php - Get ghost users |
---|
| 2392 | * |
---|
| 2393 | * @return : List of users |
---|
| 2394 | * |
---|
| 2395 | */ |
---|
[5056] | 2396 | function get_ghost_user_list() |
---|
| 2397 | { |
---|
[17887] | 2398 | global $conf, $page; |
---|
[5056] | 2399 | |
---|
[5181] | 2400 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[5056] | 2401 | |
---|
| 2402 | $users = array(); |
---|
| 2403 | |
---|
[17887] | 2404 | // Search users depending expiration date |
---|
[12271] | 2405 | // -------------------------------------- |
---|
[5056] | 2406 | $query = ' |
---|
| 2407 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
| 2408 | u.'.$conf['user_fields']['username'].' AS username, |
---|
| 2409 | u.'.$conf['user_fields']['email'].' AS email, |
---|
| 2410 | lv.lastvisit, |
---|
| 2411 | lv.reminder |
---|
| 2412 | FROM '.USERS_TABLE.' AS u |
---|
| 2413 | INNER JOIN '.USER_LASTVISIT_TABLE.' AS lv |
---|
| 2414 | ON u.'.$conf['user_fields']['id'].' = lv.user_id |
---|
[11018] | 2415 | WHERE (TO_DAYS(NOW()) - TO_DAYS(lv.lastvisit) >= "'.$conf_UAM[16].'") |
---|
[6399] | 2416 | ORDER BY lv.lastvisit ASC;'; |
---|
[5056] | 2417 | |
---|
[17887] | 2418 | $result = pwg_query($query); |
---|
[5056] | 2419 | |
---|
[5633] | 2420 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 2421 | { |
---|
[17887] | 2422 | $user = $row; |
---|
[5056] | 2423 | $user['groups'] = array(); |
---|
| 2424 | |
---|
| 2425 | array_push($users, $user); |
---|
[17887] | 2426 | } |
---|
[5056] | 2427 | |
---|
[17887] | 2428 | // Add groups list |
---|
[12271] | 2429 | // --------------- |
---|
[5056] | 2430 | $user_ids = array(); |
---|
| 2431 | foreach ($users as $i => $user) |
---|
| 2432 | { |
---|
[17887] | 2433 | $user_ids[$i] = $user['id']; |
---|
| 2434 | } |
---|
[5056] | 2435 | |
---|
[17887] | 2436 | return $users; |
---|
[5056] | 2437 | } |
---|
| 2438 | |
---|
[8065] | 2439 | |
---|
[7968] | 2440 | /** |
---|
[8065] | 2441 | * Function called from functions.inc.php - Get all ghost users to delete or downgrade automatically on any user login |
---|
| 2442 | * |
---|
| 2443 | * @return : List of users to delete or downgrade automatically |
---|
| 2444 | * |
---|
| 2445 | */ |
---|
| 2446 | function get_ghosts_autotasks() |
---|
| 2447 | { |
---|
[17887] | 2448 | global $conf, $page; |
---|
[8065] | 2449 | |
---|
| 2450 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 2451 | |
---|
| 2452 | $users = array(); |
---|
| 2453 | |
---|
[17887] | 2454 | // Search users depending expiration date and reminder sent |
---|
[12271] | 2455 | // -------------------------------------------------------- |
---|
[8065] | 2456 | $query = ' |
---|
| 2457 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
[8087] | 2458 | lv.lastvisit |
---|
[8065] | 2459 | FROM '.USERS_TABLE.' AS u |
---|
| 2460 | INNER JOIN '.USER_LASTVISIT_TABLE.' AS lv |
---|
| 2461 | ON u.'.$conf['user_fields']['id'].' = lv.user_id |
---|
[11018] | 2462 | WHERE (TO_DAYS(NOW()) - TO_DAYS(lv.lastvisit) >= "'.$conf_UAM[16].'") |
---|
[8065] | 2463 | ORDER BY lv.lastvisit ASC;'; |
---|
| 2464 | |
---|
[17887] | 2465 | $result = pwg_query($query); |
---|
[8065] | 2466 | |
---|
| 2467 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 2468 | { |
---|
[9266] | 2469 | array_push($users, $row); |
---|
[17887] | 2470 | } |
---|
[8065] | 2471 | |
---|
[17887] | 2472 | return $users; |
---|
[8065] | 2473 | } |
---|
| 2474 | |
---|
| 2475 | |
---|
| 2476 | /** |
---|
[7968] | 2477 | * Function called from UAM_admin.php - Get all users to display the number of days since their last visit |
---|
| 2478 | * |
---|
| 2479 | * @return : List of users |
---|
| 2480 | * |
---|
| 2481 | */ |
---|
[5056] | 2482 | function get_user_list() |
---|
| 2483 | { |
---|
[17887] | 2484 | global $conf, $page; |
---|
[5056] | 2485 | |
---|
| 2486 | $users = array(); |
---|
| 2487 | |
---|
[17887] | 2488 | // Search users depending expiration date with exclusion of Adult_Content generic users |
---|
[13528] | 2489 | // ------------------------------------------------------------------------------------ |
---|
[5056] | 2490 | $query = ' |
---|
| 2491 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
| 2492 | u.'.$conf['user_fields']['username'].' AS username, |
---|
| 2493 | u.'.$conf['user_fields']['email'].' AS email, |
---|
| 2494 | ug.lastvisit |
---|
| 2495 | FROM '.USERS_TABLE.' AS u |
---|
| 2496 | INNER JOIN '.USER_LASTVISIT_TABLE.' AS ug |
---|
| 2497 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
| 2498 | WHERE u.'.$conf['user_fields']['id'].' >= 3 |
---|
[13528] | 2499 | AND u.username NOT LIKE "16" |
---|
| 2500 | AND u.username NOT LIKE "18" |
---|
[6399] | 2501 | ORDER BY ug.lastvisit DESC |
---|
[5056] | 2502 | ;'; |
---|
| 2503 | |
---|
[17887] | 2504 | $result = pwg_query($query); |
---|
[5056] | 2505 | |
---|
[5633] | 2506 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5056] | 2507 | { |
---|
[17887] | 2508 | $user = $row; |
---|
[5056] | 2509 | $user['groups'] = array(); |
---|
| 2510 | |
---|
| 2511 | array_push($users, $user); |
---|
[17887] | 2512 | } |
---|
[5056] | 2513 | |
---|
[17887] | 2514 | // Add groups list |
---|
[12271] | 2515 | // --------------- |
---|
[5056] | 2516 | $user_ids = array(); |
---|
| 2517 | foreach ($users as $i => $user) |
---|
| 2518 | { |
---|
[17887] | 2519 | $user_ids[$i] = $user['id']; |
---|
| 2520 | } |
---|
[5056] | 2521 | |
---|
[17887] | 2522 | return $users; |
---|
[5056] | 2523 | } |
---|
| 2524 | |
---|
[10144] | 2525 | |
---|
[7968] | 2526 | /** |
---|
| 2527 | * Function called from UAM_admin.php - to determine who is expired or not and giving a different display color |
---|
| 2528 | * |
---|
| 2529 | * @param : user id |
---|
| 2530 | * |
---|
| 2531 | * @return : Bool |
---|
| 2532 | * |
---|
| 2533 | */ |
---|
[5056] | 2534 | function expiration($id) |
---|
| 2535 | { |
---|
[17887] | 2536 | global $conf, $page; |
---|
[5056] | 2537 | |
---|
[17887] | 2538 | // Get ConfirmMail configuration |
---|
[12271] | 2539 | // ----------------------------- |
---|
[5181] | 2540 | $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); |
---|
[5056] | 2541 | |
---|
[17887] | 2542 | // Get UAM configuration |
---|
[12271] | 2543 | // --------------------- |
---|
[5181] | 2544 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[17887] | 2545 | |
---|
| 2546 | $query = " |
---|
[5056] | 2547 | SELECT registration_date |
---|
| 2548 | FROM ".USER_INFOS_TABLE." |
---|
| 2549 | WHERE user_id = '".$id."' |
---|
| 2550 | ;"; |
---|
[17887] | 2551 | list($registration_date) = pwg_db_fetch_row(pwg_query($query)); |
---|
[5056] | 2552 | |
---|
[7968] | 2553 | // Time limit process |
---|
| 2554 | // ******************************************** |
---|
[17887] | 2555 | if (!empty($registration_date)) |
---|
[5056] | 2556 | { |
---|
[17887] | 2557 | // Dates formating and compare |
---|
[12271] | 2558 | // --------------------------- |
---|
[17887] | 2559 | $today = date("d-m-Y"); // Get today's date |
---|
| 2560 | list($day, $month, $year) = explode('-', $today); // explode date of today |
---|
| 2561 | $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp |
---|
| 2562 | |
---|
| 2563 | list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date |
---|
| 2564 | list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date |
---|
| 2565 | $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp |
---|
| 2566 | |
---|
| 2567 | $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps |
---|
| 2568 | $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days |
---|
[5056] | 2569 | |
---|
[17887] | 2570 | // Condition with the value set for time limit |
---|
[12271] | 2571 | // ------------------------------------------- |
---|
[17887] | 2572 | if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set |
---|
| 2573 | { |
---|
| 2574 | return false; |
---|
| 2575 | } |
---|
| 2576 | else |
---|
| 2577 | { |
---|
| 2578 | return true; |
---|
| 2579 | } |
---|
| 2580 | } |
---|
[5056] | 2581 | } |
---|
| 2582 | |
---|
| 2583 | |
---|
| 2584 | /** |
---|
| 2585 | * Returns a password's score for password complexity check |
---|
| 2586 | * |
---|
[7968] | 2587 | * @param : password filled by user |
---|
[5056] | 2588 | * |
---|
[7968] | 2589 | * @return : Score calculation |
---|
| 2590 | * |
---|
[5056] | 2591 | * Thanx to MathieuGut from http://m-gut.developpez.com |
---|
| 2592 | */ |
---|
| 2593 | function testpassword($password) // Le mot de passe passé en paramètre - $password given by user |
---|
| 2594 | { |
---|
| 2595 | |
---|
| 2596 | // Initialisation des variables - Variables initiation |
---|
[12271] | 2597 | // --------------------------------------------------- |
---|
[5056] | 2598 | $points = 0; |
---|
| 2599 | $point_lowercase = 0; |
---|
| 2600 | $point_uppercase = 0; |
---|
| 2601 | $point_numbers = 0; |
---|
| 2602 | $point_characters = 0; |
---|
| 2603 | |
---|
[12271] | 2604 | // On récupère la longueur du mot de passe - Getting password lengh |
---|
| 2605 | // ---------------------------------------------------------------- |
---|
[5056] | 2606 | $length = strlen($password); |
---|
| 2607 | |
---|
| 2608 | // On fait une boucle pour lire chaque lettre - Loop to read password characters |
---|
| 2609 | for($i = 0; $i < $length; $i++) |
---|
| 2610 | { |
---|
| 2611 | // On sélectionne une à une chaque lettre - Select each letters |
---|
| 2612 | // $i étant à 0 lors du premier passage de la boucle - $i is 0 at first turn |
---|
[12271] | 2613 | // ------------------------------------------------------------------------- |
---|
[5056] | 2614 | $letters = $password[$i]; |
---|
| 2615 | |
---|
| 2616 | if ($letters>='a' && $letters<='z') |
---|
| 2617 | { |
---|
| 2618 | // On ajoute 1 point pour une minuscule - Adding 1 point to score for a lowercase |
---|
[12271] | 2619 | // ------------------------------------------------------------------------------ |
---|
[17887] | 2620 | $points = $points + 1; |
---|
[5056] | 2621 | |
---|
[17887] | 2622 | // On rajoute le bonus pour une minuscule - Adding bonus points for lowercase |
---|
[12271] | 2623 | // -------------------------------------------------------------------------- |
---|
[17887] | 2624 | $point_lowercase = 1; |
---|
[5056] | 2625 | } |
---|
| 2626 | else if ($letters>='A' && $letters <='Z') |
---|
| 2627 | { |
---|
| 2628 | // On ajoute 2 points pour une majuscule - Adding 2 points to score for uppercase |
---|
[12271] | 2629 | // ------------------------------------------------------------------------------ |
---|
[5056] | 2630 | $points = $points + 2; |
---|
[17887] | 2631 | |
---|
[5056] | 2632 | // On rajoute le bonus pour une majuscule - Adding bonus points for uppercase |
---|
[12271] | 2633 | // -------------------------------------------------------------------------- |
---|
[5056] | 2634 | $point_uppercase = 2; |
---|
| 2635 | } |
---|
| 2636 | else if ($letters>='0' && $letters<='9') |
---|
| 2637 | { |
---|
| 2638 | // On ajoute 3 points pour un chiffre - Adding 3 points to score for numbers |
---|
[12271] | 2639 | // ------------------------------------------------------------------------- |
---|
[5056] | 2640 | $points = $points + 3; |
---|
[17887] | 2641 | |
---|
[5056] | 2642 | // On rajoute le bonus pour un chiffre - Adding bonus points for numbers |
---|
[12271] | 2643 | // --------------------------------------------------------------------- |
---|
[5056] | 2644 | $point_numbers = 3; |
---|
| 2645 | } |
---|
| 2646 | else |
---|
| 2647 | { |
---|
| 2648 | // On ajoute 5 points pour un caractère autre - Adding 5 points to score for special characters |
---|
[12271] | 2649 | // -------------------------------------------------------------------------------------------- |
---|
[5056] | 2650 | $points = $points + 5; |
---|
[17887] | 2651 | |
---|
[5056] | 2652 | // On rajoute le bonus pour un caractère autre - Adding bonus points for special characters |
---|
[12271] | 2653 | // ---------------------------------------------------------------------------------------- |
---|
[5056] | 2654 | $point_characters = 5; |
---|
| 2655 | } |
---|
| 2656 | } |
---|
| 2657 | |
---|
| 2658 | // Calcul du coefficient points/longueur - calculating the coefficient points/length |
---|
[12271] | 2659 | // --------------------------------------------------------------------------------- |
---|
[5056] | 2660 | $step1 = $points / $length; |
---|
| 2661 | |
---|
| 2662 | // Calcul du coefficient de la diversité des types de caractères... - Calculation of the diversity of character types... |
---|
[12271] | 2663 | // --------------------------------------------------------------------------------------------------------------------- |
---|
[5056] | 2664 | $step2 = $point_lowercase + $point_uppercase + $point_numbers + $point_characters; |
---|
| 2665 | |
---|
| 2666 | // Multiplication du coefficient de diversité avec celui de la longueur - Multiplying the coefficient of diversity with that of the length |
---|
[12271] | 2667 | // -------------------------------------------------------------------------------------------------------------------------------------------- |
---|
[5056] | 2668 | $score = $step1 * $step2; |
---|
| 2669 | |
---|
[9253] | 2670 | // Multiplication du resultat par la longueur de la chaine - Multiplying the result by the length of the string |
---|
[12271] | 2671 | // ------------------------------------------------------------------------------------------------------------ |
---|
[5056] | 2672 | $finalscore = $score * $length; |
---|
| 2673 | |
---|
| 2674 | return $finalscore; |
---|
| 2675 | } |
---|
| 2676 | |
---|
[10144] | 2677 | |
---|
[7968] | 2678 | /** |
---|
[8065] | 2679 | * UAM_check_profile - Thx to LucMorizur |
---|
[7968] | 2680 | * checks if a user id is registered as having already |
---|
[12661] | 2681 | * visited his profile page. |
---|
[7968] | 2682 | * |
---|
| 2683 | * @uid : the user id |
---|
| 2684 | * |
---|
| 2685 | * @user_idsOK : (returned) array of all users ids having already visited |
---|
| 2686 | * their profile.php pages |
---|
| 2687 | * |
---|
| 2688 | * @returns : true or false whether the users has already visited his |
---|
| 2689 | * profile.php page or not |
---|
| 2690 | * |
---|
| 2691 | */ |
---|
[8065] | 2692 | function UAM_check_profile($uid, &$user_idsOK) |
---|
[6775] | 2693 | { |
---|
| 2694 | $t = array(); |
---|
| 2695 | $v = false; |
---|
| 2696 | |
---|
[12239] | 2697 | $query = ' |
---|
[6775] | 2698 | SELECT value |
---|
[12239] | 2699 | FROM '.CONFIG_TABLE.' |
---|
| 2700 | WHERE param = "UserAdvManager_Redir" |
---|
| 2701 | ;'; |
---|
[6775] | 2702 | |
---|
| 2703 | if ($v = (($t = pwg_db_fetch_row(pwg_query($query))) !== false)) |
---|
| 2704 | { |
---|
| 2705 | $user_idsOK = explode(',', $t[0]); |
---|
| 2706 | $v = (in_array($uid, $user_idsOK)); |
---|
| 2707 | } |
---|
| 2708 | return $v; |
---|
| 2709 | } |
---|
[10144] | 2710 | |
---|
| 2711 | |
---|
| 2712 | /** |
---|
[12239] | 2713 | * UAM_check_pwdreset |
---|
| 2714 | * checks if a user id is registered as having already |
---|
[12661] | 2715 | * changed his password. |
---|
[12239] | 2716 | * |
---|
| 2717 | * @uid : the user id |
---|
| 2718 | * |
---|
| 2719 | * @returns : true or false whether the users has already changed his password |
---|
| 2720 | * |
---|
| 2721 | */ |
---|
| 2722 | function UAM_check_pwgreset($uid) |
---|
| 2723 | { |
---|
| 2724 | $query = ' |
---|
| 2725 | SELECT UAM_pwdreset |
---|
| 2726 | FROM '.USERS_TABLE.' |
---|
| 2727 | WHERE id='.$uid.' |
---|
| 2728 | ;'; |
---|
| 2729 | |
---|
| 2730 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 2731 | |
---|
| 2732 | if($result['UAM_pwdreset'] == 'true') |
---|
| 2733 | { |
---|
| 2734 | return true; |
---|
| 2735 | } |
---|
| 2736 | else return false; |
---|
| 2737 | } |
---|
| 2738 | |
---|
[12661] | 2739 | |
---|
[12239] | 2740 | /** |
---|
[12661] | 2741 | * UAM_UsrReg_Verif |
---|
| 2742 | * Check if the user who logged-in have validate his registration |
---|
| 2743 | * |
---|
| 2744 | * @returns : True if validation is OK else False |
---|
| 2745 | */ |
---|
| 2746 | function UAM_UsrReg_Verif($user_id) |
---|
| 2747 | { |
---|
| 2748 | global $conf; |
---|
| 2749 | |
---|
| 2750 | $query = ' |
---|
[17887] | 2751 | SELECT UAM_validated |
---|
| 2752 | FROM '.USERS_TABLE.' |
---|
| 2753 | WHERE id='.$user_id.' |
---|
[12661] | 2754 | ;'; |
---|
| 2755 | |
---|
[17887] | 2756 | $result = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[17846] | 2757 | |
---|
[17887] | 2758 | if($result['UAM_validated'] == 'true') |
---|
[12661] | 2759 | { |
---|
[17887] | 2760 | return true; |
---|
[12661] | 2761 | } |
---|
[17887] | 2762 | else return false; |
---|
[12661] | 2763 | } |
---|
| 2764 | |
---|
| 2765 | |
---|
| 2766 | /** |
---|
[12239] | 2767 | * UAM_Set_PwdReset |
---|
| 2768 | * Action in user_list to set a password reset for a user |
---|
| 2769 | */ |
---|
| 2770 | function UAM_Set_PwdReset($uid) |
---|
| 2771 | { |
---|
| 2772 | $query =' |
---|
| 2773 | UPDATE '.USERS_TABLE.' |
---|
| 2774 | SET UAM_pwdreset = "true" |
---|
| 2775 | WHERE id = '.$uid.' |
---|
| 2776 | LIMIT 1 |
---|
| 2777 | ;'; |
---|
| 2778 | |
---|
| 2779 | pwg_query($query); |
---|
| 2780 | } |
---|
| 2781 | |
---|
| 2782 | |
---|
| 2783 | /** |
---|
| 2784 | * UAM_loc_visible_user_list |
---|
| 2785 | * Adds a new feature in user_list to allow password reset for selected users by admin |
---|
| 2786 | * |
---|
| 2787 | */ |
---|
| 2788 | function UAM_loc_visible_user_list($visible_user_list) |
---|
| 2789 | { |
---|
| 2790 | global $template; |
---|
| 2791 | |
---|
| 2792 | $template->append('plugin_user_list_column_titles', l10n('UAM_PwdReset')); |
---|
| 2793 | |
---|
| 2794 | $user_ids = array(); |
---|
| 2795 | |
---|
| 2796 | foreach ($visible_user_list as $i => $user) |
---|
| 2797 | { |
---|
| 2798 | $user_ids[$i] = $user['id']; |
---|
| 2799 | } |
---|
| 2800 | |
---|
| 2801 | $user_nums = array_flip($user_ids); |
---|
| 2802 | |
---|
| 2803 | // Query to get informations in database |
---|
[12271] | 2804 | // ------------------------------------- |
---|
[12239] | 2805 | if (!empty($user_ids)) |
---|
| 2806 | { |
---|
| 2807 | $query = ' |
---|
| 2808 | SELECT DISTINCT id, UAM_pwdreset |
---|
| 2809 | FROM '.USERS_TABLE.' |
---|
| 2810 | WHERE id IN ('.implode(',', $user_ids).') |
---|
| 2811 | ;'; |
---|
| 2812 | $result = pwg_query($query); |
---|
| 2813 | |
---|
| 2814 | while ($row = mysql_fetch_array($result)) |
---|
| 2815 | { |
---|
| 2816 | if ($row['UAM_pwdreset'] == 'false') |
---|
| 2817 | { |
---|
| 2818 | $pwdreset = l10n('UAM_PwdReset_Done'); |
---|
| 2819 | } |
---|
| 2820 | else if ($row['UAM_pwdreset'] == 'true') |
---|
| 2821 | { |
---|
| 2822 | $pwdreset = l10n('UAM_PwdReset_Todo'); |
---|
| 2823 | } |
---|
| 2824 | else $pwdreset = l10n('UAM_PwdReset_NA'); |
---|
| 2825 | |
---|
[17887] | 2826 | $visible_user_list[$user_nums[$row['id']]]['plugin_columns'][] = $pwdreset; // Shows users password state in user_list |
---|
[12239] | 2827 | } |
---|
| 2828 | } |
---|
| 2829 | return $visible_user_list; |
---|
| 2830 | } |
---|
| 2831 | |
---|
| 2832 | |
---|
| 2833 | /** |
---|
[10342] | 2834 | * UAM specific database dump (only for MySql !) |
---|
| 2835 | * Creates an SQL dump of UAM specific tables and configuration settings |
---|
| 2836 | * |
---|
| 2837 | * @returns : Boolean to manage appropriate message display |
---|
| 2838 | * |
---|
| 2839 | */ |
---|
[12239] | 2840 | function UAM_dump($download) |
---|
[10342] | 2841 | { |
---|
| 2842 | global $conf; |
---|
[12314] | 2843 | |
---|
| 2844 | $plugin = PluginInfos(UAM_PATH); |
---|
| 2845 | $version = $plugin['version']; |
---|
| 2846 | |
---|
[10342] | 2847 | // Initial backup folder creation and file initialisation |
---|
[12271] | 2848 | // ------------------------------------------------------ |
---|
[10342] | 2849 | if (!is_dir(UAM_PATH.'/include/backup')) |
---|
| 2850 | mkdir(UAM_PATH.'/include/backup'); |
---|
| 2851 | |
---|
| 2852 | $Backup_File = UAM_PATH.'/include/backup/UAM_dbbackup.sql'; |
---|
| 2853 | |
---|
| 2854 | $fp = fopen($Backup_File, 'w'); |
---|
| 2855 | |
---|
[12314] | 2856 | // Writing plugin version |
---|
| 2857 | $insertions = "-- ".$version." --\n\n"; |
---|
| 2858 | fwrite($fp, $insertions); |
---|
[10342] | 2859 | |
---|
| 2860 | // Saving UAM specific tables |
---|
[12271] | 2861 | // -------------------------- |
---|
[10342] | 2862 | $ListTables = array(USER_CONFIRM_MAIL_TABLE, USER_LASTVISIT_TABLE); |
---|
| 2863 | $j=0; |
---|
| 2864 | |
---|
| 2865 | while($j < count($ListTables)) |
---|
| 2866 | { |
---|
| 2867 | $sql = 'SHOW CREATE TABLE '.$ListTables[$j]; |
---|
| 2868 | $res = pwg_query($sql); |
---|
| 2869 | |
---|
| 2870 | if ($res) |
---|
| 2871 | { |
---|
| 2872 | $insertions = "-- -------------------------------------------------------\n"; |
---|
| 2873 | $insertions .= "-- Create ".$ListTables[$j]." table\n"; |
---|
| 2874 | $insertions .= "-- ------------------------------------------------------\n\n"; |
---|
| 2875 | |
---|
| 2876 | $insertions .= "DROP TABLE IF EXISTS ".$ListTables[$j].";\n\n"; |
---|
| 2877 | |
---|
| 2878 | $array = mysql_fetch_array($res); |
---|
| 2879 | $array[1] .= ";\n\n"; |
---|
| 2880 | $insertions .= $array[1]; |
---|
| 2881 | |
---|
| 2882 | $req_table = pwg_query('SELECT * FROM '.$ListTables[$j]) or die(mysql_error()); |
---|
| 2883 | $nb_fields = mysql_num_fields($req_table); |
---|
| 2884 | while ($line = mysql_fetch_array($req_table)) |
---|
| 2885 | { |
---|
| 2886 | $insertions .= 'INSERT INTO '.$ListTables[$j].' VALUES ('; |
---|
| 2887 | for ($i=0; $i<$nb_fields; $i++) |
---|
| 2888 | { |
---|
[12275] | 2889 | $insertions .= '\'' . pwg_db_real_escape_string($line[$i]) . '\', '; |
---|
[10342] | 2890 | } |
---|
| 2891 | $insertions = substr($insertions, 0, -2); |
---|
| 2892 | $insertions .= ");\n"; |
---|
| 2893 | } |
---|
| 2894 | $insertions .= "\n\n"; |
---|
| 2895 | } |
---|
| 2896 | |
---|
| 2897 | fwrite($fp, $insertions); |
---|
| 2898 | $j++; |
---|
| 2899 | } |
---|
| 2900 | |
---|
| 2901 | // Saving UAM configuration |
---|
[12271] | 2902 | // ------------------------ |
---|
[10342] | 2903 | $insertions = "-- -------------------------------------------------------\n"; |
---|
| 2904 | $insertions .= "-- Insert UAM configuration in ".CONFIG_TABLE."\n"; |
---|
| 2905 | $insertions .= "-- ------------------------------------------------------\n\n"; |
---|
| 2906 | |
---|
| 2907 | fwrite($fp, $insertions); |
---|
| 2908 | |
---|
| 2909 | $pattern = "UserAdvManager%"; |
---|
| 2910 | $req_table = pwg_query('SELECT * FROM '.CONFIG_TABLE.' WHERE param LIKE "'.$pattern.'";') or die(mysql_error()); |
---|
| 2911 | $nb_fields = mysql_num_fields($req_table); |
---|
| 2912 | |
---|
| 2913 | while ($line = mysql_fetch_array($req_table)) |
---|
| 2914 | { |
---|
| 2915 | $insertions = 'INSERT INTO '.CONFIG_TABLE.' VALUES ('; |
---|
| 2916 | for ($i=0; $i<$nb_fields; $i++) |
---|
| 2917 | { |
---|
[12275] | 2918 | $insertions .= '\'' . pwg_db_real_escape_string($line[$i]) . '\', '; |
---|
[10342] | 2919 | } |
---|
| 2920 | $insertions = substr($insertions, 0, -2); |
---|
| 2921 | $insertions .= ");\n"; |
---|
| 2922 | |
---|
| 2923 | fwrite($fp, $insertions); |
---|
| 2924 | } |
---|
| 2925 | |
---|
| 2926 | fclose($fp); |
---|
| 2927 | |
---|
| 2928 | // Download generated dump file |
---|
[12271] | 2929 | // ---------------------------- |
---|
[10342] | 2930 | if ($download == 'true') |
---|
| 2931 | { |
---|
| 2932 | if (@filesize($Backup_File)) |
---|
| 2933 | { |
---|
| 2934 | $http_headers = array( |
---|
| 2935 | 'Content-Length: '.@filesize($Backup_File), |
---|
| 2936 | 'Content-Type: text/x-sql', |
---|
| 2937 | 'Content-Disposition: attachment; filename="UAM_dbbackup.sql";', |
---|
| 2938 | 'Content-Transfer-Encoding: binary', |
---|
| 2939 | ); |
---|
| 2940 | |
---|
| 2941 | foreach ($http_headers as $header) |
---|
| 2942 | { |
---|
| 2943 | header($header); |
---|
| 2944 | } |
---|
| 2945 | |
---|
| 2946 | @readfile($Backup_File); |
---|
| 2947 | exit(); |
---|
| 2948 | } |
---|
| 2949 | } |
---|
| 2950 | |
---|
| 2951 | return true; |
---|
| 2952 | } |
---|
| 2953 | |
---|
| 2954 | |
---|
| 2955 | /** |
---|
[12275] | 2956 | * UAM_Restore_backup_file |
---|
| 2957 | * Restore backup database file |
---|
| 2958 | * |
---|
| 2959 | * @returns : Boolean |
---|
| 2960 | */ |
---|
| 2961 | function UAM_Restore_backup_file() |
---|
| 2962 | { |
---|
| 2963 | global $prefixeTable, $dblayer, $conf; |
---|
| 2964 | |
---|
| 2965 | define('DEFAULT_PREFIX_TABLE', 'piwigo_'); |
---|
| 2966 | |
---|
| 2967 | $Backup_File = UAM_PATH.'/include/backup/UAM_dbbackup.sql'; |
---|
| 2968 | |
---|
| 2969 | // Cleanup database before restoring |
---|
| 2970 | // --------------------------------- |
---|
| 2971 | |
---|
| 2972 | // Delete UserAdvManager global config in #_config table |
---|
| 2973 | $q = ' |
---|
| 2974 | DELETE FROM '.CONFIG_TABLE.' |
---|
| 2975 | WHERE param="UserAdvManager" |
---|
| 2976 | ;'; |
---|
| 2977 | |
---|
| 2978 | pwg_query($q); |
---|
| 2979 | |
---|
| 2980 | // Delete UserAdvManager_ConfirmMail global config in #_config table |
---|
| 2981 | $q = ' |
---|
| 2982 | DELETE FROM '.CONFIG_TABLE.' |
---|
| 2983 | WHERE param="UserAdvManager_ConfirmMail" |
---|
| 2984 | ;'; |
---|
| 2985 | |
---|
| 2986 | pwg_query($q); |
---|
| 2987 | |
---|
| 2988 | // Delete UserAdvManager_Redir config in #_config table |
---|
| 2989 | $q = ' |
---|
| 2990 | DELETE FROM '.CONFIG_TABLE.' |
---|
| 2991 | WHERE param="UserAdvManager_Redir" |
---|
| 2992 | ;'; |
---|
| 2993 | |
---|
| 2994 | pwg_query($q); |
---|
| 2995 | |
---|
| 2996 | // Delete UserAdvManager_Version config in #_config table |
---|
| 2997 | $q = ' |
---|
| 2998 | DELETE FROM '.CONFIG_TABLE.' |
---|
| 2999 | WHERE param="UserAdvManager_Version" |
---|
| 3000 | ;'; |
---|
| 3001 | |
---|
| 3002 | pwg_query($q); |
---|
| 3003 | |
---|
| 3004 | // Restore sql backup file - DROP TABLE queries are executed |
---|
| 3005 | // --------------------------------------------------------- |
---|
| 3006 | UAM_execute_sqlfile( |
---|
| 3007 | $Backup_File, |
---|
| 3008 | DEFAULT_PREFIX_TABLE, |
---|
| 3009 | $prefixeTable, |
---|
| 3010 | $dblayer |
---|
| 3011 | ); |
---|
| 3012 | } |
---|
| 3013 | |
---|
| 3014 | |
---|
| 3015 | /** |
---|
| 3016 | * loads an sql file and executes all queries / Based on Piwigo's original install file |
---|
| 3017 | * |
---|
| 3018 | * Before executing a query, $replaced is... replaced by $replacing. This is |
---|
| 3019 | * useful when the SQL file contains generic words. |
---|
| 3020 | * |
---|
| 3021 | * @param string filepath |
---|
| 3022 | * @param string replaced |
---|
| 3023 | * @param string replacing |
---|
| 3024 | * @return void |
---|
| 3025 | */ |
---|
| 3026 | function UAM_execute_sqlfile($filepath, $replaced, $replacing, $dblayer) |
---|
| 3027 | { |
---|
| 3028 | $sql_lines = file($filepath); |
---|
| 3029 | $query = ''; |
---|
| 3030 | foreach ($sql_lines as $sql_line) |
---|
| 3031 | { |
---|
| 3032 | $sql_line = trim($sql_line); |
---|
| 3033 | if (preg_match('/(^--|^$)/', $sql_line)) |
---|
| 3034 | { |
---|
| 3035 | continue; |
---|
| 3036 | } |
---|
| 3037 | |
---|
| 3038 | $query.= ' '.$sql_line; |
---|
| 3039 | |
---|
| 3040 | // if we reached the end of query, we execute it and reinitialize the |
---|
| 3041 | // variable "query" |
---|
| 3042 | if (preg_match('/;$/', $sql_line)) |
---|
| 3043 | { |
---|
| 3044 | $query = trim($query); |
---|
| 3045 | $query = str_replace($replaced, $replacing, $query); |
---|
| 3046 | if ('mysql' == $dblayer) |
---|
| 3047 | { |
---|
| 3048 | if (preg_match('/^(CREATE TABLE .*)[\s]*;[\s]*/im', $query, $matches)) |
---|
| 3049 | { |
---|
| 3050 | $query = $matches[1].' DEFAULT CHARACTER SET utf8'.';'; |
---|
| 3051 | } |
---|
| 3052 | } |
---|
| 3053 | pwg_query($query); |
---|
| 3054 | $query = ''; |
---|
| 3055 | } |
---|
| 3056 | } |
---|
| 3057 | } |
---|
| 3058 | |
---|
| 3059 | |
---|
[12661] | 3060 | /** |
---|
| 3061 | * Delete obsolete files on plugin upgrade |
---|
| 3062 | * Obsolete files are listed in file obsolete.list |
---|
| 3063 | * |
---|
| 3064 | */ |
---|
| 3065 | function clean_obsolete_files() |
---|
| 3066 | { |
---|
| 3067 | if (file_exists(UAM_PATH.'obsolete.list') |
---|
| 3068 | and $old_files = file(UAM_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES) |
---|
| 3069 | and !empty($old_files)) |
---|
| 3070 | { |
---|
| 3071 | array_push($old_files, 'obsolete.list'); |
---|
| 3072 | foreach($old_files as $old_file) |
---|
| 3073 | { |
---|
| 3074 | $path = UAM_PATH.$old_file; |
---|
| 3075 | if (is_file($path)) |
---|
| 3076 | { |
---|
| 3077 | @unlink($path); |
---|
| 3078 | } |
---|
| 3079 | elseif (is_dir($path)) |
---|
| 3080 | { |
---|
| 3081 | @rmdir($path); |
---|
| 3082 | } |
---|
| 3083 | } |
---|
| 3084 | } |
---|
| 3085 | } |
---|
[12275] | 3086 | |
---|
[12661] | 3087 | |
---|
[12275] | 3088 | /** |
---|
[12661] | 3089 | * Function called from maintain.inc.php - to check if database upgrade is needed |
---|
| 3090 | * |
---|
| 3091 | * @param : table name |
---|
| 3092 | * |
---|
| 3093 | * @return : boolean |
---|
| 3094 | * |
---|
| 3095 | */ |
---|
| 3096 | function table_exist($table) |
---|
| 3097 | { |
---|
| 3098 | $query = 'DESC '.$table.';'; |
---|
| 3099 | return (bool)($res=pwg_query($query)); |
---|
| 3100 | } |
---|
| 3101 | |
---|
| 3102 | |
---|
| 3103 | /** |
---|
| 3104 | * Function called from UAM_admin.php and main.inc.php to get the plugin version and name |
---|
| 3105 | * |
---|
| 3106 | * @param : plugin directory |
---|
| 3107 | * |
---|
| 3108 | * @return : plugin's version and name |
---|
| 3109 | * |
---|
| 3110 | */ |
---|
| 3111 | function PluginInfos($dir) |
---|
| 3112 | { |
---|
| 3113 | $path = $dir; |
---|
| 3114 | |
---|
| 3115 | $plg_data = implode( '', file($path.'main.inc.php') ); |
---|
| 3116 | if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) ) |
---|
| 3117 | { |
---|
| 3118 | $plugin['name'] = trim( $val[1] ); |
---|
| 3119 | } |
---|
| 3120 | if (preg_match("|Version: (.*)|", $plg_data, $val)) |
---|
| 3121 | { |
---|
| 3122 | $plugin['version'] = trim($val[1]); |
---|
| 3123 | } |
---|
| 3124 | if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) ) |
---|
| 3125 | { |
---|
| 3126 | $plugin['uri'] = trim($val[1]); |
---|
| 3127 | } |
---|
| 3128 | if ($desc = load_language('description.txt', $path.'/', array('return' => true))) |
---|
| 3129 | { |
---|
| 3130 | $plugin['description'] = trim($desc); |
---|
| 3131 | } |
---|
| 3132 | elseif ( preg_match("|Description: (.*)|", $plg_data, $val) ) |
---|
| 3133 | { |
---|
| 3134 | $plugin['description'] = trim($val[1]); |
---|
| 3135 | } |
---|
| 3136 | if ( preg_match("|Author: (.*)|", $plg_data, $val) ) |
---|
| 3137 | { |
---|
| 3138 | $plugin['author'] = trim($val[1]); |
---|
| 3139 | } |
---|
| 3140 | if ( preg_match("|Author URI: (.*)|", $plg_data, $val) ) |
---|
| 3141 | { |
---|
| 3142 | $plugin['author uri'] = trim($val[1]); |
---|
| 3143 | } |
---|
| 3144 | if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid=')) |
---|
| 3145 | { |
---|
| 3146 | list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']); |
---|
| 3147 | if (is_numeric($extension)) $plugin['extension'] = $extension; |
---|
| 3148 | } |
---|
| 3149 | // IMPORTANT SECURITY ! |
---|
| 3150 | // -------------------- |
---|
| 3151 | $plugin = array_map('htmlspecialchars', $plugin); |
---|
| 3152 | |
---|
| 3153 | return $plugin ; |
---|
| 3154 | } |
---|
| 3155 | |
---|
| 3156 | |
---|
| 3157 | /** |
---|
[10144] | 3158 | * Useful for debugging - 4 vars can be set |
---|
| 3159 | * Output result to log.txt file |
---|
| 3160 | * |
---|
| 3161 | */ |
---|
| 3162 | function UAMLog($var1, $var2, $var3, $var4) |
---|
| 3163 | { |
---|
| 3164 | $fo=fopen (UAM_PATH.'log.txt','a') ; |
---|
| 3165 | fwrite($fo,"======================\n") ; |
---|
| 3166 | fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n"); |
---|
| 3167 | fwrite($fo,$var1 ."\r\n") ; |
---|
| 3168 | fwrite($fo,$var2 ."\r\n") ; |
---|
| 3169 | fwrite($fo,$var3 ."\r\n") ; |
---|
| 3170 | fwrite($fo,$var4 ."\r\n") ; |
---|
| 3171 | fclose($fo) ; |
---|
| 3172 | } |
---|
[5056] | 3173 | ?> |
---|