PageRenderTime 53ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/ucp/ucp_profile.php

https://bitbucket.org/jablonski/yebood
PHP | 643 lines | 477 code | 127 blank | 39 comment | 124 complexity | 91e4bb234084967b40645d4ee60967e3 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. *
  4. * @package ucp
  5. * @version $Id$
  6. * @copyright (c) 2005 phpBB Group
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. *
  9. */
  10. /**
  11. * @ignore
  12. */
  13. if (!defined('IN_PHPBB'))
  14. {
  15. exit;
  16. }
  17. /**
  18. * ucp_profile
  19. * Changing profile settings
  20. *
  21. * @todo what about pertaining user_sig_options?
  22. * @package ucp
  23. */
  24. class ucp_profile
  25. {
  26. var $u_action;
  27. function main($id, $mode)
  28. {
  29. global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
  30. $user->add_lang('posting');
  31. $preview = (!empty($_POST['preview'])) ? true : false;
  32. $submit = (!empty($_POST['submit'])) ? true : false;
  33. $delete = (!empty($_POST['delete'])) ? true : false;
  34. $error = $data = array();
  35. $s_hidden_fields = '';
  36. switch ($mode)
  37. {
  38. case 'reg_details':
  39. $data = array(
  40. 'username' => utf8_normalize_nfc(request_var('username', $user->data['username'], true)),
  41. 'email' => strtolower(request_var('email', $user->data['user_email'])),
  42. 'email_confirm' => strtolower(request_var('email_confirm', '')),
  43. 'new_password' => request_var('new_password', '', true),
  44. 'cur_password' => request_var('cur_password', '', true),
  45. 'password_confirm' => request_var('password_confirm', '', true),
  46. );
  47. add_form_key('ucp_reg_details');
  48. if ($submit)
  49. {
  50. // Do not check cur_password, it is the old one.
  51. $check_ary = array(
  52. 'new_password' => array(
  53. array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
  54. array('password')),
  55. 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']),
  56. 'email' => array(
  57. array('string', false, 6, 60),
  58. array('email')),
  59. 'email_confirm' => array('string', true, 6, 60),
  60. );
  61. if ($auth->acl_get('u_chgname') && $config['allow_namechange'])
  62. {
  63. $check_ary['username'] = array(
  64. array('string', false, $config['min_name_chars'], $config['max_name_chars']),
  65. array('username'),
  66. );
  67. }
  68. $error = validate_data($data, $check_ary);
  69. if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'] && $data['email_confirm'] != $data['email'])
  70. {
  71. $error[] = ($data['email_confirm']) ? 'NEW_EMAIL_ERROR' : 'NEW_EMAIL_CONFIRM_EMPTY';
  72. }
  73. if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && $data['password_confirm'] != $data['new_password'])
  74. {
  75. $error[] = ($data['password_confirm']) ? 'NEW_PASSWORD_ERROR' : 'NEW_PASSWORD_CONFIRM_EMPTY';
  76. }
  77. // Only check the new password against the previous password if there have been no errors
  78. if (!sizeof($error) && $auth->acl_get('u_chgpasswd') && $data['new_password'] && phpbb_check_hash($data['new_password'], $user->data['user_password']))
  79. {
  80. $error[] = 'SAME_PASSWORD_ERROR';
  81. }
  82. if (!phpbb_check_hash($data['cur_password'], $user->data['user_password']))
  83. {
  84. $error[] = ($data['cur_password']) ? 'CUR_PASSWORD_ERROR' : 'CUR_PASSWORD_EMPTY';
  85. }
  86. if (!check_form_key('ucp_reg_details'))
  87. {
  88. $error[] = 'FORM_INVALID';
  89. }
  90. if (!sizeof($error))
  91. {
  92. $sql_ary = array(
  93. 'username' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? $data['username'] : $user->data['username'],
  94. 'username_clean' => ($auth->acl_get('u_chgname') && $config['allow_namechange']) ? utf8_clean_string($data['username']) : $user->data['username_clean'],
  95. 'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'],
  96. 'user_email_hash' => ($auth->acl_get('u_chgemail')) ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'],
  97. 'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? phpbb_hash($data['new_password']) : $user->data['user_password'],
  98. 'user_passchg' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0,
  99. );
  100. if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username'])
  101. {
  102. add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_NAME', $user->data['username'], $data['username']);
  103. }
  104. if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !phpbb_check_hash($data['new_password'], $user->data['user_password']))
  105. {
  106. $user->reset_login_keys();
  107. add_log('user', $user->data['user_id'], 'LOG_USER_NEW_PASSWORD', $data['username']);
  108. }
  109. if ($auth->acl_get('u_chgemail') && $data['email'] != $user->data['user_email'])
  110. {
  111. add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_EMAIL', $data['username'], $user->data['user_email'], $data['email']);
  112. }
  113. $message = 'PROFILE_UPDATED';
  114. 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))
  115. {
  116. $message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
  117. include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
  118. $server_url = generate_board_url();
  119. $user_actkey = gen_rand_string(mt_rand(6, 10));
  120. $messenger = new messenger(false);
  121. $template_file = ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? 'user_activate_inactive' : 'user_activate';
  122. $messenger->template($template_file, $user->data['user_lang']);
  123. $messenger->to($data['email'], $data['username']);
  124. $messenger->anti_abuse_headers($config, $user);
  125. $messenger->assign_vars(array(
  126. 'USERNAME' => htmlspecialchars_decode($data['username']),
  127. 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
  128. );
  129. $messenger->send(NOTIFY_EMAIL);
  130. if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
  131. {
  132. // Grab an array of user_id's with a_user permissions ... these users can activate a user
  133. $admin_ary = $auth->acl_get_list(false, 'a_user', false);
  134. $admin_ary = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array();
  135. // Also include founders
  136. $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
  137. if (sizeof($admin_ary))
  138. {
  139. $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary);
  140. }
  141. $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
  142. FROM ' . USERS_TABLE . ' ' .
  143. $where_sql;
  144. $result = $db->sql_query($sql);
  145. while ($row = $db->sql_fetchrow($result))
  146. {
  147. $messenger->template('admin_activate', $row['user_lang']);
  148. $messenger->to($row['user_email'], $row['username']);
  149. $messenger->im($row['user_jabber'], $row['username']);
  150. $messenger->assign_vars(array(
  151. 'USERNAME' => htmlspecialchars_decode($data['username']),
  152. 'U_USER_DETAILS' => "$server_url/memberlist.$phpEx?mode=viewprofile&u={$user->data['user_id']}",
  153. 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user->data['user_id']}&k=$user_actkey")
  154. );
  155. $messenger->send($row['user_notify_type']);
  156. }
  157. $db->sql_freeresult($result);
  158. }
  159. user_active_flip('deactivate', $user->data['user_id'], INACTIVE_PROFILE);
  160. // Because we want the profile to be reactivated we set user_newpasswd to empty (else the reactivation will fail)
  161. $sql_ary['user_actkey'] = $user_actkey;
  162. $sql_ary['user_newpasswd'] = '';
  163. }
  164. if (sizeof($sql_ary))
  165. {
  166. $sql = 'UPDATE ' . USERS_TABLE . '
  167. SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
  168. WHERE user_id = ' . $user->data['user_id'];
  169. $db->sql_query($sql);
  170. }
  171. // Need to update config, forum, topic, posting, messages, etc.
  172. if ($data['username'] != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange'])
  173. {
  174. user_update_name($user->data['username'], $data['username']);
  175. }
  176. // Now, we can remove the user completely (kill the session) - NOT BEFORE!!!
  177. if (!empty($sql_ary['user_actkey']))
  178. {
  179. meta_refresh(5, append_sid($phpbb_root_path . 'index.' . $phpEx));
  180. $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid($phpbb_root_path . 'index.' . $phpEx) . '">', '</a>');
  181. // Because the user gets deactivated we log him out too, killing his session
  182. $user->session_kill();
  183. }
  184. else
  185. {
  186. meta_refresh(3, $this->u_action);
  187. $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
  188. }
  189. trigger_error($message);
  190. }
  191. // Replace "error" strings with their real, localised form
  192. $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
  193. }
  194. $template->assign_vars(array(
  195. 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
  196. 'USERNAME' => $data['username'],
  197. 'EMAIL' => $data['email'],
  198. 'PASSWORD_CONFIRM' => $data['password_confirm'],
  199. 'NEW_PASSWORD' => $data['new_password'],
  200. 'CUR_PASSWORD' => '',
  201. 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),
  202. 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),
  203. 'S_FORCE_PASSWORD' => ($auth->acl_get('u_chgpasswd') && $config['chg_passforce'] && $user->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) ? true : false,
  204. 'S_CHANGE_USERNAME' => ($config['allow_namechange'] && $auth->acl_get('u_chgname')) ? true : false,
  205. 'S_CHANGE_EMAIL' => ($auth->acl_get('u_chgemail')) ? true : false,
  206. 'S_CHANGE_PASSWORD' => ($auth->acl_get('u_chgpasswd')) ? true : false)
  207. );
  208. break;
  209. case 'profile_info':
  210. include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
  211. $cp = new custom_profile();
  212. $cp_data = $cp_error = array();
  213. $data = array(
  214. 'icq' => request_var('icq', $user->data['user_icq']),
  215. 'aim' => request_var('aim', $user->data['user_aim']),
  216. 'msn' => request_var('msn', $user->data['user_msnm']),
  217. 'yim' => request_var('yim', $user->data['user_yim']),
  218. 'jabber' => utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)),
  219. 'website' => request_var('website', $user->data['user_website']),
  220. 'location' => utf8_normalize_nfc(request_var('location', $user->data['user_from'], true)),
  221. 'occupation' => utf8_normalize_nfc(request_var('occupation', $user->data['user_occ'], true)),
  222. 'interests' => utf8_normalize_nfc(request_var('interests', $user->data['user_interests'], true)),
  223. );
  224. if ($config['allow_birthdays'])
  225. {
  226. $data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
  227. if ($user->data['user_birthday'])
  228. {
  229. list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user->data['user_birthday']);
  230. }
  231. $data['bday_day'] = request_var('bday_day', $data['bday_day']);
  232. $data['bday_month'] = request_var('bday_month', $data['bday_month']);
  233. $data['bday_year'] = request_var('bday_year', $data['bday_year']);
  234. $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
  235. }
  236. add_form_key('ucp_profile_info');
  237. if ($submit)
  238. {
  239. $validate_array = array(
  240. 'icq' => array(
  241. array('string', true, 3, 15),
  242. array('match', true, '#^[0-9]+$#i')),
  243. 'aim' => array('string', true, 3, 255),
  244. 'msn' => array('string', true, 5, 255),
  245. 'jabber' => array(
  246. array('string', true, 5, 255),
  247. array('jabber')),
  248. 'yim' => array('string', true, 5, 255),
  249. 'website' => array(
  250. array('string', true, 12, 255),
  251. array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
  252. 'location' => array('string', true, 2, 100),
  253. 'occupation' => array('string', true, 2, 500),
  254. 'interests' => array('string', true, 2, 500),
  255. );
  256. if ($config['allow_birthdays'])
  257. {
  258. $validate_array = array_merge($validate_array, array(
  259. 'bday_day' => array('num', true, 1, 31),
  260. 'bday_month' => array('num', true, 1, 12),
  261. 'bday_year' => array('num', true, 1901, gmdate('Y', time()) + 50),
  262. 'user_birthday' => array('date', true),
  263. ));
  264. }
  265. $error = validate_data($data, $validate_array);
  266. // validate custom profile fields
  267. $cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
  268. if (sizeof($cp_error))
  269. {
  270. $error = array_merge($error, $cp_error);
  271. }
  272. if (!check_form_key('ucp_profile_info'))
  273. {
  274. $error[] = 'FORM_INVALID';
  275. }
  276. if (!sizeof($error))
  277. {
  278. $data['notify'] = $user->data['user_notify_type'];
  279. if ($data['notify'] == NOTIFY_IM && (!$config['jab_enable'] || !$data['jabber'] || !@extension_loaded('xml')))
  280. {
  281. // User has not filled in a jabber address (Or one of the modules is disabled or jabber is disabled)
  282. // Disable notify by Jabber now for this user.
  283. $data['notify'] = NOTIFY_EMAIL;
  284. }
  285. $sql_ary = array(
  286. 'user_icq' => $data['icq'],
  287. 'user_aim' => $data['aim'],
  288. 'user_msnm' => $data['msn'],
  289. 'user_yim' => $data['yim'],
  290. 'user_jabber' => $data['jabber'],
  291. 'user_website' => $data['website'],
  292. 'user_from' => $data['location'],
  293. 'user_occ' => $data['occupation'],
  294. 'user_interests'=> $data['interests'],
  295. 'user_notify_type' => $data['notify'],
  296. );
  297. if ($config['allow_birthdays'])
  298. {
  299. $sql_ary['user_birthday'] = $data['user_birthday'];
  300. }
  301. $sql = 'UPDATE ' . USERS_TABLE . '
  302. SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
  303. WHERE user_id = ' . $user->data['user_id'];
  304. $db->sql_query($sql);
  305. // Update Custom Fields
  306. $cp->update_profile_field_data($user->data['user_id'], $cp_data);
  307. meta_refresh(3, $this->u_action);
  308. $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
  309. trigger_error($message);
  310. }
  311. // Replace "error" strings with their real, localised form
  312. $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
  313. }
  314. if ($config['allow_birthdays'])
  315. {
  316. $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
  317. for ($i = 1; $i < 32; $i++)
  318. {
  319. $selected = ($i == $data['bday_day']) ? ' selected="selected"' : '';
  320. $s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
  321. }
  322. $s_birthday_month_options = '<option value="0"' . ((!$data['bday_month']) ? ' selected="selected"' : '') . '>--</option>';
  323. for ($i = 1; $i < 13; $i++)
  324. {
  325. $selected = ($i == $data['bday_month']) ? ' selected="selected"' : '';
  326. $s_birthday_month_options .= "<option value=\"$i\"$selected>$i</option>";
  327. }
  328. $s_birthday_year_options = '';
  329. $now = getdate();
  330. $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>';
  331. for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
  332. {
  333. $selected = ($i == $data['bday_year']) ? ' selected="selected"' : '';
  334. $s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
  335. }
  336. unset($now);
  337. $template->assign_vars(array(
  338. 'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options,
  339. 'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options,
  340. 'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options,
  341. 'S_BIRTHDAYS_ENABLED' => true,
  342. ));
  343. }
  344. $template->assign_vars(array(
  345. 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
  346. 'ICQ' => $data['icq'],
  347. 'YIM' => $data['yim'],
  348. 'AIM' => $data['aim'],
  349. 'MSN' => $data['msn'],
  350. 'JABBER' => $data['jabber'],
  351. 'WEBSITE' => $data['website'],
  352. 'LOCATION' => $data['location'],
  353. 'OCCUPATION'=> $data['occupation'],
  354. 'INTERESTS' => $data['interests'],
  355. ));
  356. // Get additional profile fields and assign them to the template block var 'profile_fields'
  357. $user->get_profile_fields($user->data['user_id']);
  358. $cp->generate_profile_fields('profile', $user->get_iso_lang_id());
  359. break;
  360. case 'signature':
  361. if (!$auth->acl_get('u_sig'))
  362. {
  363. trigger_error('NO_AUTH_SIGNATURE');
  364. }
  365. include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
  366. include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  367. $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $user->optionget('sig_bbcode') : false;
  368. $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $user->optionget('sig_smilies') : false;
  369. $enable_urls = ($config['allow_sig_links']) ? (bool) $user->optionget('sig_links') : false;
  370. $signature = utf8_normalize_nfc(request_var('signature', (string) $user->data['user_sig'], true));
  371. add_form_key('ucp_sig');
  372. if ($submit || $preview)
  373. {
  374. include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
  375. $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false;
  376. $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false;
  377. $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false;
  378. if (!sizeof($error))
  379. {
  380. $message_parser = new parse_message($signature);
  381. // Allowing Quote BBCode
  382. $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig');
  383. if (sizeof($message_parser->warn_msg))
  384. {
  385. $error[] = implode('<br />', $message_parser->warn_msg);
  386. }
  387. if (!check_form_key('ucp_sig'))
  388. {
  389. $error[] = 'FORM_INVALID';
  390. }
  391. if (!sizeof($error) && $submit)
  392. {
  393. $user->optionset('sig_bbcode', $enable_bbcode);
  394. $user->optionset('sig_smilies', $enable_smilies);
  395. $user->optionset('sig_links', $enable_urls);
  396. $sql_ary = array(
  397. 'user_sig' => (string) $message_parser->message,
  398. 'user_options' => $user->data['user_options'],
  399. 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid,
  400. 'user_sig_bbcode_bitfield' => $message_parser->bbcode_bitfield
  401. );
  402. $sql = 'UPDATE ' . USERS_TABLE . '
  403. SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
  404. WHERE user_id = ' . $user->data['user_id'];
  405. $db->sql_query($sql);
  406. $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
  407. trigger_error($message);
  408. }
  409. }
  410. // Replace "error" strings with their real, localised form
  411. $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
  412. }
  413. $signature_preview = '';
  414. if ($preview)
  415. {
  416. // Now parse it for displaying
  417. $signature_preview = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false);
  418. unset($message_parser);
  419. }
  420. decode_message($signature, $user->data['user_sig_bbcode_uid']);
  421. $template->assign_vars(array(
  422. 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
  423. 'SIGNATURE' => $signature,
  424. 'SIGNATURE_PREVIEW' => $signature_preview,
  425. 'S_BBCODE_CHECKED' => (!$enable_bbcode) ? ' checked="checked"' : '',
  426. 'S_SMILIES_CHECKED' => (!$enable_smilies) ? ' checked="checked"' : '',
  427. 'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? ' checked="checked"' : '',
  428. '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>'),
  429. 'SMILIES_STATUS' => ($config['allow_sig_smilies']) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
  430. 'IMG_STATUS' => ($config['allow_sig_img']) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
  431. 'FLASH_STATUS' => ($config['allow_sig_flash']) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
  432. 'URL_STATUS' => ($config['allow_sig_links']) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
  433. 'MAX_FONT_SIZE' => (int) $config['max_sig_font_size'],
  434. 'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']),
  435. 'S_BBCODE_ALLOWED' => $config['allow_sig_bbcode'],
  436. 'S_SMILIES_ALLOWED' => $config['allow_sig_smilies'],
  437. 'S_BBCODE_IMG' => ($config['allow_sig_img']) ? true : false,
  438. 'S_BBCODE_FLASH' => ($config['allow_sig_flash']) ? true : false,
  439. 'S_LINKS_ALLOWED' => ($config['allow_sig_links']) ? true : false)
  440. );
  441. // Build custom bbcodes array
  442. display_custom_bbcodes();
  443. break;
  444. case 'avatar':
  445. include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  446. $display_gallery = request_var('display_gallery', '0');
  447. $avatar_select = basename(request_var('avatar_select', ''));
  448. $category = basename(request_var('category', ''));
  449. $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;
  450. add_form_key('ucp_avatar');
  451. if ($submit)
  452. {
  453. if (check_form_key('ucp_avatar'))
  454. {
  455. if (avatar_process_user($error, false, $can_upload))
  456. {
  457. meta_refresh(3, $this->u_action);
  458. $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
  459. trigger_error($message);
  460. }
  461. }
  462. else
  463. {
  464. $error[] = 'FORM_INVALID';
  465. }
  466. // Replace "error" strings with their real, localised form
  467. $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
  468. }
  469. if (!$config['allow_avatar'] && $user->data['user_avatar_type'])
  470. {
  471. $error[] = $user->lang['AVATAR_NOT_ALLOWED'];
  472. }
  473. else if ((($user->data['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) ||
  474. (($user->data['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) ||
  475. (($user->data['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local']))
  476. {
  477. $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED'];
  478. }
  479. $template->assign_vars(array(
  480. 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
  481. 'AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height'], 'USER_AVATAR', true),
  482. 'AVATAR_SIZE' => $config['avatar_filesize'],
  483. 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&amp;mode=avatar&amp;display_gallery=1'),
  484. 'S_FORM_ENCTYPE' => ($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '',
  485. 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024),
  486. ));
  487. if ($config['allow_avatar'] && $display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'])
  488. {
  489. avatar_gallery($category, $avatar_select, 4);
  490. }
  491. else if ($config['allow_avatar'])
  492. {
  493. $avatars_enabled = (($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false;
  494. $template->assign_vars(array(
  495. 'AVATAR_WIDTH' => request_var('width', $user->data['user_avatar_width']),
  496. 'AVATAR_HEIGHT' => request_var('height', $user->data['user_avatar_height']),
  497. 'S_AVATARS_ENABLED' => $avatars_enabled,
  498. 'S_UPLOAD_AVATAR_FILE' => ($can_upload && $config['allow_avatar_upload']) ? true : false,
  499. 'S_UPLOAD_AVATAR_URL' => ($can_upload && $config['allow_avatar_remote_upload']) ? true : false,
  500. 'S_LINK_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false,
  501. 'S_DISPLAY_GALLERY' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false)
  502. );
  503. }
  504. break;
  505. }
  506. $template->assign_vars(array(
  507. 'L_TITLE' => $user->lang['UCP_PROFILE_' . strtoupper($mode)],
  508. 'S_HIDDEN_FIELDS' => $s_hidden_fields,
  509. 'S_UCP_ACTION' => $this->u_action)
  510. );
  511. // Set desired template
  512. $this->tpl_name = 'ucp_profile_' . $mode;
  513. $this->page_title = 'UCP_PROFILE_' . strtoupper($mode);
  514. }
  515. }
  516. ?>