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