[ Index ] |
PHP Cross Reference of phpBB-3.3.10-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 /** 15 * @ignore 16 */ 17 if (!defined('IN_PHPBB')) 18 { 19 exit; 20 } 21 22 /** 23 * ucp_profile 24 * Changing profile settings 25 * 26 * @todo what about pertaining user_sig_options? 27 */ 28 class ucp_profile 29 { 30 var $u_action; 31 32 function main($id, $mode) 33 { 34 global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; 35 global $request, $phpbb_container, $phpbb_log, $phpbb_dispatcher; 36 37 $user->add_lang('posting'); 38 39 $submit = $request->variable('submit', false, false, \phpbb\request\request_interface::POST); 40 $error = $data = array(); 41 $s_hidden_fields = ''; 42 43 switch ($mode) 44 { 45 case 'reg_details': 46 47 $data = array( 48 'username' => $request->variable('username', $user->data['username'], true), 49 'email' => strtolower($request->variable('email', $user->data['user_email'])), 50 'new_password' => $request->variable('new_password', '', true), 51 'cur_password' => $request->variable('cur_password', '', true), 52 'password_confirm' => $request->variable('password_confirm', '', true), 53 ); 54 55 /** 56 * Modify user registration data on editing account settings in UCP 57 * 58 * @event core.ucp_profile_reg_details_data 59 * @var array data Array with current or updated user registration data 60 * @var bool submit Flag indicating if submit button has been pressed 61 * @since 3.1.4-RC1 62 */ 63 $vars = array('data', 'submit'); 64 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_data', compact($vars))); 65 66 add_form_key('ucp_reg_details'); 67 68 if ($submit) 69 { 70 // Do not check cur_password, it is the old one. 71 $check_ary = array( 72 'new_password' => array( 73 array('string', true, $config['min_pass_chars'], 0), 74 array('password')), 75 'password_confirm' => array('string', true, $config['min_pass_chars'], 0), 76 'email' => array( 77 array('string', false, 6, 60), 78 array('user_email')), 79 ); 80 81 if ($auth->acl_get('u_chgname') && $config['allow_namechange']) 82 { 83 $check_ary['username'] = array( 84 array('string', false, $config['min_name_chars'], $config['max_name_chars']), 85 array('username'), 86 ); 87 } 88 89 $error = validate_data($data, $check_ary); 90 91 if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password']) 92 { 93 $error[] = ($data['password_confirm']) ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY'; 94 } 95 96 // Instantiate passwords manager 97 /* @var $passwords_manager \phpbb\passwords\manager */ 98 $passwords_manager = $phpbb_container->get('passwords.manager'); 99 100 // Only check the new password against the previous password if there have been no errors 101 if (!count($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && $passwords_manager->check($data['new_password'], $user->data['user_password'])) 102 { 103 $error[] = 'SAME_PASSWORD_ERROR'; 104 } 105 106 if (!$passwords_manager->check($data['cur_password'], $user->data['user_password'])) 107 { 108 $error[] = ($data['cur_password']) ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY'; 109 } 110 111 if (!check_form_key('ucp_reg_details')) 112 { 113 $error[] = 'FORM_INVALID'; 114 } 115 116 /** 117 * Validate user data on editing registration data in UCP 118 * 119 * @event core.ucp_profile_reg_details_validate 120 * @var array data Array with user profile data 121 * @var bool submit Flag indicating if submit button has been pressed 122 * @var array error Array of any generated errors 123 * @since 3.1.4-RC1 124 */ 125 $vars = array('data', 'submit', 'error'); 126 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_validate', compact($vars))); 127 128 if (!count($error)) 129 { 130 $sql_ary = array( 131 'username' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'], 132 'username_clean' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'], 133 'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'], 134 'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'], 135 ); 136 137 if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username']) 138 { 139 $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_NAME', false, array( 140 'reportee_id' => $user->data['user_id'], 141 $user->data['username'], 142 $data['username'] 143 )); 144 } 145 146 if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !$passwords_manager->check($data['new_password'], $user->data['user_password'])) 147 { 148 $sql_ary['user_passchg'] = time(); 149 150 $user->reset_login_keys(); 151 $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array( 152 'reportee_id' => $user->data['user_id'], 153 $user->data['username'] 154 )); 155 } 156 157 if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email']) 158 { 159 $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_UPDATE_EMAIL', false, array( 160 'reportee_id' => $user->data['user_id'], 161 $user->data['username'], 162 $user->data['user_email'], 163 $data['email'] 164 )); 165 } 166 167 $message = 'PROFILE_UPDATED'; 168 169 if ($auth->acl_get('u_chgemail') && $config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) 170 { 171 $message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN'; 172 173 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); 174 175 $server_url = generate_board_url(); 176 177 $user_actkey = gen_rand_string(mt_rand(6, 10)); 178 179 $messenger = new messenger(false); 180 181 $template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate'; 182 $messenger->template($template_file, $user->data['user_lang']); 183 184 $messenger->to($data['email'], $data['username']); 185 186 $messenger->anti_abuse_headers($config, $user); 187 188 $messenger->assign_vars(array( 189 'USERNAME' => html_entity_decode($data['username'], ENT_COMPAT), 190 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey") 191 ); 192 193 $messenger->send(NOTIFY_EMAIL); 194 195 if ($config['require_activation'] == USER_ACTIVATION_ADMIN) 196 { 197 $notifications_manager = $phpbb_container->get('notification_manager'); 198 $notifications_manager->add_notifications('notification.type.admin_activate_user', array( 199 'user_id' => $user->data['user_id'], 200 'user_actkey' => $user_actkey, 201 'user_regdate' => time(), // Notification time 202 )); 203 } 204 205 user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE); 206 207 // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail) 208 $sql_ary['user_actkey'] = $user_actkey; 209 $sql_ary['user_newpasswd'] = ''; 210 } 211 212 /** 213 * Modify user registration data before submitting it to the database 214 * 215 * @event core.ucp_profile_reg_details_sql_ary 216 * @var array data Array with current or updated user registration data 217 * @var array sql_ary Array with user registration data to submit to the database 218 * @since 3.1.4-RC1 219 */ 220 $vars = array('data', 'sql_ary'); 221 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_reg_details_sql_ary', compact($vars))); 222 223 if (count($sql_ary)) 224 { 225 $sql = 'UPDATE ' . USERS_TABLE . ' 226 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' 227 WHERE user_id = ' . $user->data['user_id']; 228 $db->sql_query($sql); 229 } 230 231 // Need to update config, forum, topic, posting, messages, etc. 232 if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange']) 233 { 234 user_update_name($user->data['username'], $data['username']); 235 } 236 237 // Now, we can remove the user completely (kill the session) - NOT BEFORE!!! 238 if (!empty($sql_ary['user_actkey'])) 239 { 240 meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx)); 241 $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>'); 242 243 // Because the user gets deactivated we log him out too, killing his session 244 $user->session_kill(); 245 } 246 else 247 { 248 meta_refresh(3, $this->u_action); 249 $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); 250 } 251 252 trigger_error($message); 253 } 254 255 // Replace "error" strings with their real, localised form 256 $error = array_map(array($user, 'lang'), $error); 257 } 258 259 $template->assign_vars(array( 260 'ERROR' => (count($error)) ? implode('<br />', $error) : '', 261 262 'USERNAME' => $data['username'], 263 'EMAIL' => $data['email'], 264 'PASSWORD_CONFIRM' => $data['password_confirm'], 265 'NEW_PASSWORD' => $data['new_password'], 266 'CUR_PASSWORD' => '', 267 268 'L_USERNAME_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), 269 'L_CHANGE_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars'])), 270 271 'S_FORCE_PASSWORD' => ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false, 272 'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false, 273 'S_CHANGE_EMAIL' => ($auth->acl_get('u_chgemail')) ? true : false, 274 'S_CHANGE_PASSWORD' => ($auth->acl_get('u_chgpasswd')) ? true : false) 275 ); 276 break; 277 278 case 'profile_info': 279 // Do not display profile information panel if not authed to do so 280 if (!$auth->acl_get('u_chgprofileinfo')) 281 { 282 send_status_line(403, 'Forbidden'); 283 trigger_error('NO_AUTH_PROFILEINFO'); 284 } 285 286 /* @var $cp \phpbb\profilefields\manager */ 287 $cp = $phpbb_container->get('profilefields.manager'); 288 289 $cp_data = $cp_error = array(); 290 291 $data = array( 292 'jabber' => $request->variable('jabber', $user->data['user_jabber'], true), 293 ); 294 295 if ($config['allow_birthdays']) 296 { 297 $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0; 298 299 if ($user->data['user_birthday']) 300 { 301 list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']); 302 } 303 304 $data['bday_day'] = $request->variable('bday_day', $data['bday_day']); 305 $data['bday_month'] = $request->variable('bday_month', $data['bday_month']); 306 $data['bday_year'] = $request->variable('bday_year', $data['bday_year']); 307 $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']); 308 } 309 310 /** 311 * Modify user data on editing profile in UCP 312 * 313 * @event core.ucp_profile_modify_profile_info 314 * @var array data Array with user profile data 315 * @var bool submit Flag indicating if submit button has been pressed 316 * @since 3.1.4-RC1 317 */ 318 $vars = array('data', 'submit'); 319 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_profile_info', compact($vars))); 320 321 add_form_key('ucp_profile_info'); 322 323 if ($submit) 324 { 325 $validate_array = array( 326 'jabber' => array( 327 array('string', true, 5, 255), 328 array('jabber')), 329 ); 330 331 if ($config['allow_birthdays']) 332 { 333 $validate_array = array_merge($validate_array, array( 334 'bday_day' => array('num', true, 1, 31), 335 'bday_month' => array('num', true, 1, 12), 336 'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50), 337 'user_birthday' => array('date', true), 338 )); 339 } 340 341 $error = validate_data($data, $validate_array); 342 343 // validate custom profile fields 344 $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error); 345 346 if (count($cp_error)) 347 { 348 $error = array_merge($error, $cp_error); 349 } 350 351 if (!check_form_key('ucp_profile_info')) 352 { 353 $error[] = 'FORM_INVALID'; 354 } 355 356 /** 357 * Validate user data on editing profile in UCP 358 * 359 * @event core.ucp_profile_validate_profile_info 360 * @var array data Array with user profile data 361 * @var bool submit Flag indicating if submit button has been pressed 362 * @var array error Array of any generated errors 363 * @since 3.1.4-RC1 364 */ 365 $vars = array('data', 'submit', 'error'); 366 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_validate_profile_info', compact($vars))); 367 368 if (!count($error)) 369 { 370 $data['notify'] = $user->data['user_notify_type']; 371 372 if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml'))) 373 { 374 // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled) 375 // Disable notify by Jabber now for this user. 376 $data['notify'] = NOTIFY_EMAIL; 377 } 378 379 $sql_ary = array( 380 'user_jabber' => $data['jabber'], 381 'user_notify_type' => $data['notify'], 382 ); 383 384 if ($config['allow_birthdays']) 385 { 386 $sql_ary['user_birthday'] = $data['user_birthday']; 387 } 388 389 /** 390 * Modify profile data in UCP before submitting to the database 391 * 392 * @event core.ucp_profile_info_modify_sql_ary 393 * @var array cp_data Array with the user custom profile fields data 394 * @var array data Array with user profile data 395 * @var array sql_ary user options data we update 396 * @since 3.1.4-RC1 397 */ 398 $vars = array('cp_data', 'data', 'sql_ary'); 399 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_info_modify_sql_ary', compact($vars))); 400 401 $sql = 'UPDATE ' . USERS_TABLE . ' 402 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' 403 WHERE user_id = ' . $user->data['user_id']; 404 $db->sql_query($sql); 405 406 // Update Custom Fields 407 $cp->update_profile_field_data($user->data['user_id'], $cp_data); 408 409 meta_refresh(3, $this->u_action); 410 $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); 411 trigger_error($message); 412 } 413 414 // Replace "error" strings with their real, localised form 415 $error = array_map(array($user, 'lang'), $error); 416 } 417 418 if ($config['allow_birthdays']) 419 { 420 $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>'; 421 for ($i = 1; $i < 32; $i++) 422 { 423 $selected = ($i == $data['bday_day']) ? ' selected="selected"' : ''; 424 $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>"; 425 } 426 427 $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>'; 428 for ($i = 1; $i < 13; $i++) 429 { 430 $selected = ($i == $data['bday_month']) ? ' selected="selected"' : ''; 431 $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>"; 432 } 433 434 $now = getdate(); 435 $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>'; 436 for ($i = $now['year'] - 100; $i <= $now['year']; $i++) 437 { 438 $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; 439 $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>"; 440 } 441 unset($now); 442 443 $template->assign_vars(array( 444 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options, 445 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options, 446 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options, 447 'S_BIRTHDAYS_ENABLED' => true, 448 )); 449 } 450 451 $template->assign_vars(array( 452 'ERROR' => (count($error)) ? implode('<br />', $error) : '', 453 'S_JABBER_ENABLED' => $config['jab_enable'], 454 'JABBER' => $data['jabber'], 455 )); 456 457 // Get additional profile fields and assign them to the template block var 'profile_fields' 458 $user->get_profile_fields($user->data['user_id']); 459 460 $cp->generate_profile_fields('profile', $user->get_iso_lang_id()); 461 462 break; 463 464 case 'signature': 465 466 if (!$auth->acl_get('u_sig')) 467 { 468 send_status_line(403, 'Forbidden'); 469 trigger_error('NO_AUTH_SIGNATURE'); 470 } 471 472 if (!function_exists('generate_smilies')) 473 { 474 include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); 475 } 476 477 if (!function_exists('display_custom_bbcodes')) 478 { 479 include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 480 } 481 482 $preview = $request->is_set_post('preview'); 483 484 $enable_bbcode = ($config['allow_sig_bbcode']) ? $user->optionget('sig_bbcode') : false; 485 $enable_smilies = ($config['allow_sig_smilies']) ? $user->optionget('sig_smilies') : false; 486 $enable_urls = ($config['allow_sig_links']) ? $user->optionget('sig_links') : false; 487 488 $bbcode_flags = ($enable_bbcode ? OPTION_FLAG_BBCODE : 0) + ($enable_smilies ? OPTION_FLAG_SMILIES : 0) + ($enable_urls ? OPTION_FLAG_LINKS : 0); 489 490 $decoded_message = generate_text_for_edit($user->data['user_sig'], $user->data['user_sig_bbcode_uid'], $bbcode_flags); 491 $signature = $request->variable('signature', $decoded_message['text'], true); 492 $signature_preview = ''; 493 494 if ($submit || $preview) 495 { 496 $enable_bbcode = ($config['allow_sig_bbcode']) ? !$request->variable('disable_bbcode', false) : false; 497 $enable_smilies = ($config['allow_sig_smilies']) ? !$request->variable('disable_smilies', false) : false; 498 $enable_urls = ($config['allow_sig_links']) ? !$request->variable('disable_magic_url', false) : false; 499 500 if (!check_form_key('ucp_sig')) 501 { 502 $error[] = 'FORM_INVALID'; 503 } 504 } 505 506 /** 507 * Modify user signature on editing profile in UCP 508 * 509 * @event core.ucp_profile_modify_signature 510 * @var bool enable_bbcode Whether or not bbcode is enabled 511 * @var bool enable_smilies Whether or not smilies are enabled 512 * @var bool enable_urls Whether or not urls are enabled 513 * @var string signature Users signature text 514 * @var array error Any error strings 515 * @var bool submit Whether or not the form has been sumitted 516 * @var bool preview Whether or not the signature is being previewed 517 * @since 3.1.10-RC1 518 * @changed 3.2.0-RC2 Removed message parser 519 */ 520 $vars = array( 521 'enable_bbcode', 522 'enable_smilies', 523 'enable_urls', 524 'signature', 525 'error', 526 'submit', 527 'preview', 528 ); 529 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature', compact($vars))); 530 531 $bbcode_uid = $bbcode_bitfield = $bbcode_flags = ''; 532 $warn_msg = generate_text_for_storage( 533 $signature, 534 $bbcode_uid, 535 $bbcode_bitfield, 536 $bbcode_flags, 537 $enable_bbcode, 538 $enable_urls, 539 $enable_smilies, 540 $config['allow_sig_img'], 541 $config['allow_sig_flash'], 542 true, 543 $config['allow_sig_links'], 544 'sig' 545 ); 546 547 if (count($warn_msg)) 548 { 549 $error += $warn_msg; 550 } 551 552 if (!$submit) 553 { 554 // Parse it for displaying 555 $signature_preview = generate_text_for_display($signature, $bbcode_uid, $bbcode_bitfield, $bbcode_flags); 556 } 557 else 558 { 559 if (!count($error)) 560 { 561 $user->optionset('sig_bbcode', $enable_bbcode); 562 $user->optionset('sig_smilies', $enable_smilies); 563 $user->optionset('sig_links', $enable_urls); 564 565 $sql_ary = array( 566 'user_sig' => $signature, 567 'user_options' => $user->data['user_options'], 568 'user_sig_bbcode_uid' => $bbcode_uid, 569 'user_sig_bbcode_bitfield' => $bbcode_bitfield 570 ); 571 572 /** 573 * Modify user registration data before submitting it to the database 574 * 575 * @event core.ucp_profile_modify_signature_sql_ary 576 * @var array sql_ary Array with user signature data to submit to the database 577 * @since 3.1.10-RC1 578 */ 579 $vars = array('sql_ary'); 580 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_modify_signature_sql_ary', compact($vars))); 581 582 $sql = 'UPDATE ' . USERS_TABLE . ' 583 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' 584 WHERE user_id = ' . $user->data['user_id']; 585 $db->sql_query($sql); 586 587 $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); 588 trigger_error($message); 589 } 590 } 591 592 // Replace "error" strings with their real, localised form 593 $error = array_map(array($user, 'lang'), $error); 594 595 if ($request->is_set_post('preview')) 596 { 597 $decoded_message = generate_text_for_edit($signature, $bbcode_uid, $bbcode_flags); 598 } 599 600 /** @var \phpbb\controller\helper $controller_helper */ 601 $controller_helper = $phpbb_container->get('controller.helper'); 602 603 $template->assign_vars(array( 604 'ERROR' => (count($error)) ? implode('<br />', $error) : '', 605 'SIGNATURE' => $decoded_message['text'], 606 'SIGNATURE_PREVIEW' => $signature_preview, 607 608 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '', 609 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '', 610 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '', 611 612 'BBCODE_STATUS' => $user->lang(($config['allow_sig_bbcode'] ? 'BBCODE_IS_ON' : 'BBCODE_IS_OFF'), '<a href="' . $controller_helper->route('phpbb_help_bbcode_controller') . '">', '</a>'), 613 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 614 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 615 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 616 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 617 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'], 618 619 'L_SIGNATURE_EXPLAIN' => $user->lang('SIGNATURE_EXPLAIN', (int) $config['max_sig_chars']), 620 621 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'], 622 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'], 623 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false, 624 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false, 625 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false) 626 ); 627 628 add_form_key('ucp_sig'); 629 630 // Build custom bbcodes array 631 display_custom_bbcodes(); 632 633 // Generate smiley listing 634 generate_smilies('inline', 0); 635 636 break; 637 638 case 'avatar': 639 640 add_form_key('ucp_avatar'); 641 642 $avatars_enabled = false; 643 644 if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) 645 { 646 /* @var $phpbb_avatar_manager \phpbb\avatar\manager */ 647 $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); 648 $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers(); 649 650 // This is normalised data, without the user_ prefix 651 $avatar_data = \phpbb\avatar\manager::clean_row($user->data, 'user'); 652 653 if ($submit) 654 { 655 if (check_form_key('ucp_avatar')) 656 { 657 $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); 658 659 if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) 660 { 661 $driver = $phpbb_avatar_manager->get_driver($driver_name); 662 $result = $driver->process_form($request, $template, $user, $avatar_data, $error); 663 664 if ($result && empty($error)) 665 { 666 // Success! Lets save the result in the database 667 $result = array( 668 'user_avatar_type' => $driver_name, 669 'user_avatar' => $result['avatar'], 670 'user_avatar_width' => $result['avatar_width'], 671 'user_avatar_height' => $result['avatar_height'], 672 ); 673 674 /** 675 * Trigger events on successfull avatar change 676 * 677 * @event core.ucp_profile_avatar_sql 678 * @var array result Array with data to be stored in DB 679 * @since 3.1.11-RC1 680 */ 681 $vars = array('result'); 682 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_avatar_sql', compact($vars))); 683 684 $sql = 'UPDATE ' . USERS_TABLE . ' 685 SET ' . $db->sql_build_array('UPDATE', $result) . ' 686 WHERE user_id = ' . (int) $user->data['user_id']; 687 $db->sql_query($sql); 688 689 meta_refresh(3, $this->u_action); 690 $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); 691 trigger_error($message); 692 } 693 } 694 } 695 else 696 { 697 $error[] = 'FORM_INVALID'; 698 } 699 } 700 701 // Handle deletion of avatars 702 if ($request->is_set_post('avatar_delete')) 703 { 704 if (!confirm_box(true)) 705 { 706 confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array( 707 'avatar_delete' => true, 708 'i' => $id, 709 'mode' => $mode)) 710 ); 711 } 712 else 713 { 714 $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, USERS_TABLE, 'user_'); 715 716 meta_refresh(3, $this->u_action); 717 $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); 718 trigger_error($message); 719 } 720 } 721 722 $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type'])); 723 724 $template->assign_vars(array( 725 'AVATAR_MIN_WIDTH' => $config['avatar_min_width'], 726 'AVATAR_MAX_WIDTH' => $config['avatar_max_width'], 727 'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'], 728 'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'], 729 )); 730 731 foreach ($avatar_drivers as $current_driver) 732 { 733 $driver = $phpbb_avatar_manager->get_driver($current_driver); 734 735 $avatars_enabled = true; 736 $template->set_filenames(array( 737 'avatar' => $driver->get_template_name(), 738 )); 739 740 if ($driver->prepare_form($request, $template, $user, $avatar_data, $error)) 741 { 742 $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); 743 $driver_upper = strtoupper($driver_name); 744 745 $template->assign_block_vars('avatar_drivers', array( 746 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), 747 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 748 749 'DRIVER' => $driver_name, 750 'SELECTED' => $current_driver == $selected_driver, 751 'OUTPUT' => $template->assign_display('avatar'), 752 )); 753 } 754 } 755 756 // Replace "error" strings with their real, localised form 757 $error = $phpbb_avatar_manager->localize_errors($user, $error); 758 } 759 760 $avatar = phpbb_get_user_avatar($user->data, 'USER_AVATAR', true); 761 762 $template->assign_vars(array( 763 'ERROR' => (count($error)) ? implode('<br />', $error) : '', 764 'AVATAR' => $avatar, 765 766 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 767 768 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), 769 770 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), 771 )); 772 773 break; 774 775 case 'autologin_keys': 776 777 add_form_key('ucp_autologin_keys'); 778 779 if ($submit) 780 { 781 $keys = $request->variable('keys', array('')); 782 783 if (!check_form_key('ucp_autologin_keys')) 784 { 785 $error[] = 'FORM_INVALID'; 786 } 787 788 if (!count($error)) 789 { 790 if (!empty($keys)) 791 { 792 foreach ($keys as $key => $id) 793 { 794 $keys[$key] = $db->sql_like_expression($id . $db->get_any_char()); 795 } 796 $sql_where = '(key_id ' . implode(' OR key_id ', $keys) . ')'; 797 $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' 798 WHERE user_id = ' . (int) $user->data['user_id'] . ' 799 AND ' . $sql_where ; 800 801 $db->sql_query($sql); 802 803 meta_refresh(3, $this->u_action); 804 $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); 805 trigger_error($message); 806 } 807 } 808 809 // Replace "error" strings with their real, localised form 810 $error = array_map(array($user, 'lang'), $error); 811 } 812 813 $sql_ary = [ 814 'SELECT' => 'sk.key_id, sk.last_ip, sk.last_login', 815 'FROM' => [SESSIONS_KEYS_TABLE => 'sk'], 816 'WHERE' => 'sk.user_id = ' . (int) $user->data['user_id'], 817 'ORDER_BY' => 'sk.last_login ASC', 818 ]; 819 820 /** 821 * Event allows changing SQL query for autologin keys 822 * 823 * @event core.ucp_profile_autologin_keys_sql 824 * @var array sql_ary Array with autologin keys SQL query 825 * @since 3.3.2-RC1 826 */ 827 $vars = ['sql_ary']; 828 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_autologin_keys_sql', compact($vars))); 829 830 $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); 831 $sessions = (array) $db->sql_fetchrowset($result); 832 $db->sql_freeresult($result); 833 834 $template_vars = []; 835 foreach ($sessions as $row) 836 { 837 $key = substr($row['key_id'], 0, 8); 838 $template_vars[$key] = [ 839 'KEY' => $key, 840 'IP' => $row['last_ip'], 841 'LOGIN_TIME' => $user->format_date($row['last_login']), 842 ]; 843 } 844 845 /** 846 * Event allows changing template variables 847 * 848 * @event core.ucp_profile_autologin_keys_template_vars 849 * @var array sessions Array with session keys data 850 * @var array template_vars Array with template variables 851 * @since 3.3.2-RC1 852 */ 853 $vars = ['sessions', 'template_vars']; 854 extract($phpbb_dispatcher->trigger_event('core.ucp_profile_autologin_keys_template_vars', compact($vars))); 855 856 $template->assign_block_vars_array('sessions', $template_vars); 857 858 break; 859 } 860 861 $template->assign_vars(array( 862 'ERROR' => (count($error)) ? implode('<br />', $error) : '', 863 864 'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)], 865 866 'S_HIDDEN_FIELDS' => $s_hidden_fields, 867 'S_UCP_ACTION' => $this->u_action) 868 ); 869 870 // Set desired template 871 $this->tpl_name = 'ucp_profile_' . $mode; 872 $this->page_title = 'UCP_PROFILE_' . strtoupper($mode); 873 } 874 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Feb 22 20:16:20 2023 | Cross-referenced by PHPXref 0.7.1 |