PageRenderTime 72ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 1ms

/html/AppCode/expressionengine/modules/member/mod.member.php

https://github.com/w3bg/www.hsifin.com
PHP | 3699 lines | 2388 code | 782 blank | 529 comment | 393 complexity | 303e2a6e46ec459696cce654cfed1fc4 MD5 | raw file
Possible License(s): AGPL-3.0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3. * ExpressionEngine - by EllisLab
  4. *
  5. * @package ExpressionEngine
  6. * @author ExpressionEngine Dev Team
  7. * @copyright Copyright (c) 2003 - 2010, EllisLab, Inc.
  8. * @license http://expressionengine.com/user_guide/license.html
  9. * @link http://expressionengine.com
  10. * @since Version 2.0
  11. * @filesource
  12. */
  13. // --------------------------------------------------------------------
  14. /**
  15. * Member Management Class
  16. *
  17. * @package ExpressionEngine
  18. * @subpackage Modules
  19. * @category Modules
  20. * @author ExpressionEngine Dev Team
  21. * @link http://expressionengine.com
  22. */
  23. /*
  24. Multi Site Login
  25. The login routine can set cookies for multiple domains if needed.
  26. This allows users who run separate domains for each channel to have
  27. a way to enable users to log-in once and remain logged-in across
  28. domains. In order to use this feature this array index must be
  29. added to the config file:
  30. $conf['multi_login_sites'] = "http://www.siteone.com/|http://www.sitetwo.com";
  31. Separate each domain with a pipe.
  32. */
  33. class Member {
  34. var $trigger = 'member';
  35. var $theme_class = 'profile_theme';
  36. var $request = 'public_profile';
  37. var $no_menu = array('public_profile', 'memberlist', 'do_member_search', 'member_search', 'register', 'smileys', 'login', 'unpw_update', 'email_console', 'send_email', 'aim_console', 'icq_console', 'forgot_password', 'delete', 'member_mini_search', 'do_member_mini_search');
  38. var $no_login = array('public_profile', 'memberlist', 'do_member_search', 'member_search', 'register', 'forgot_password', 'unpw_update');
  39. var $id_override = array('edit_subscriptions', 'memberlist', 'member_search', 'browse_avatars', 'messages', 'unpw_update');
  40. var $no_breadcrumb = array('email_console', 'send_email', 'aim_console', 'icq_console', 'member_mini_search', 'do_member_mini_search');
  41. var $simple_page = array('email_console', 'send_email', 'aim_console', 'icq_console', 'smileys', 'member_mini_search', 'do_member_mini_search');
  42. var $page_title = '';
  43. var $basepath = '';
  44. var $forum_path = '';
  45. var $image_url = '';
  46. var $theme_path = '';
  47. var $cur_id = '';
  48. var $uri_extra = '';
  49. var $return_data = '';
  50. var $javascript = '';
  51. var $head_extra = '';
  52. var $var_single = '';
  53. var $var_pair = '';
  54. var $var_cond = '';
  55. var $css_file_path = '';
  56. var $board_id = '';
  57. var $show_headings = TRUE;
  58. var $in_forum = FALSE;
  59. var $is_admin = FALSE;
  60. var $breadcrumb = TRUE;
  61. var $us_datecodes = array('long' => '%F %d, %Y &nbsp;%h:%i %A');
  62. var $eu_datecodes = array('long' => '%d %F, %Y &nbsp;%H:%i');
  63. var $crumb_map = array(
  64. 'profile' => 'your_control_panel',
  65. 'delete' => 'mbr_delete',
  66. 'forgot_password' => 'mbr_forgotten_password',
  67. 'login' => 'mbr_login',
  68. 'unpw_update' => 'settings_update',
  69. 'register' => 'mbr_member_registration',
  70. 'email' => 'mbr_email_member',
  71. 'send_email' => 'mbr_send_email',
  72. 'aim' => 'mbr_aim_console',
  73. 'icq' => 'mbr_icq_console',
  74. 'profile_main' => 'mbr_my_account',
  75. 'edit_profile' => 'mbr_edit_your_profile',
  76. 'edit_email' => 'email_settings',
  77. 'edit_userpass' => 'username_and_password',
  78. 'edit_localization' => 'localization_settings',
  79. 'edit_subscriptions' => 'subscriptions',
  80. 'edit_ignore_list' => 'ignore_list',
  81. 'edit_notepad' => 'notepad',
  82. 'edit_avatar' => 'edit_avatar',
  83. 'edit_photo' => 'edit_photo',
  84. 'edit_preferences' => 'edit_preferences',
  85. 'update_preferences' => 'update_preferences',
  86. 'upload_photo' => 'update_photo',
  87. 'browse_avatars' => 'browse_avatars',
  88. 'update_profile' => 'profile_updated',
  89. 'update_email' => 'mbr_email_updated',
  90. 'update_userpass' => 'username_and_password',
  91. 'update_localization' => 'localization_settings',
  92. 'update_subscriptions' => 'subscription_manager',
  93. 'update_ignore_list' => 'ignore_list',
  94. 'update_notepad' => 'notepad',
  95. 'select_avatar' => 'update_avatar',
  96. 'upload_avatar' => 'upload_avatar',
  97. 'update_avatar' => 'update_avatar',
  98. 'pm_view' => 'private_messages',
  99. 'pm' => 'compose_message',
  100. 'view_folder' => 'view_folder',
  101. 'view_message' => 'view_message',
  102. 'edit_signature' => 'edit_signature',
  103. 'update_signature' => 'update_signature',
  104. 'compose' => 'compose_message',
  105. 'deleted' => 'deleted_messages',
  106. 'folders' => 'edit_folders',
  107. 'buddies' => 'buddy_list',
  108. 'blocked' => 'blocked_list',
  109. 'edit_folders' => 'edit_folders',
  110. 'inbox' => 'view_folder',
  111. 'edit_list' => 'edit_list',
  112. 'send_message' => 'view_folder',
  113. 'modify_messages' => 'private_messages',
  114. 'bulletin_board' => 'bulletin_board',
  115. 'send_bulletin' => 'send_bulletin',
  116. 'sending_bulletin' => 'sending_bulletin'
  117. );
  118. /** ----------------------------------
  119. /** Member Profile Constructor
  120. /** ----------------------------------*/
  121. function Member()
  122. {
  123. // Make a local reference to the ExpressionEngine super object
  124. $this->EE =& get_instance();
  125. /** ----------------------------------
  126. /** Load language files
  127. /** ----------------------------------*/
  128. $this->EE->lang->loadfile('myaccount');
  129. $this->EE->lang->loadfile('member');
  130. $this->EE->functions->template_type = 'webpage';
  131. $this->EE->db->cache_off();
  132. }
  133. /** ----------------------------------
  134. /** Prep the Request String
  135. /** ----------------------------------*/
  136. function _prep_request()
  137. {
  138. // Typcially the profile page URLs will be something like:
  139. //
  140. // index.php/member/123/
  141. // index.php/member/memberlist/
  142. // index.php/member/profile/
  143. // etc...
  144. //
  145. // The second segment will be assigned to the $this->request variable.
  146. // This determines what page is shown. Anything after that will normally
  147. // be an ID number, so we'll assign it to the $this->cur_id variable.
  148. // Load the string helper
  149. $this->EE->load->helper('string');
  150. $this->request = trim_slashes($this->EE->uri->uri_string);
  151. if (FALSE !== ($pos = strpos($this->request, $this->trigger.'/')))
  152. {
  153. $this->request = substr($this->request, $pos);
  154. }
  155. if (preg_match("#/simple#", $this->request))
  156. {
  157. $this->request = str_replace("/simple", '', $this->request);
  158. $this->show_headings = FALSE;
  159. }
  160. if ($this->request == $this->trigger)
  161. {
  162. $this->request = '';
  163. }
  164. elseif (strpos($this->request, '/') !== FALSE)
  165. {
  166. $xr = explode("/", $this->request);
  167. $this->request = str_replace(current($xr).'/', '', $this->request);
  168. }
  169. /** ----------------------------------
  170. /** Determine the ID number, if any
  171. /** ----------------------------------*/
  172. $this->cur_id = '';
  173. if (strpos($this->request, '/') !== FALSE)
  174. {
  175. $x = explode("/", $this->request);
  176. if (count($x) > 2)
  177. {
  178. $this->request = $x['0'];
  179. $this->cur_id = $x['1'];
  180. $this->uri_extra = $x['2'];
  181. }
  182. else
  183. {
  184. $this->request = $x['0'];
  185. $this->cur_id = $x['1'];
  186. }
  187. }
  188. /** ----------------------------------
  189. /** Is this a public profile request?
  190. /** ----------------------------------*/
  191. // Public member profiles are found at:
  192. //
  193. // index.php/member/123/
  194. //
  195. // Since the second segment contains a number instead of the
  196. // normal text string we know it's a public profile request.
  197. // We'll do a little reassignment...
  198. if (is_numeric($this->request))
  199. {
  200. $this->cur_id = $this->request;
  201. $this->request = 'public_profile';
  202. }
  203. if ($this->request == '')
  204. {
  205. $this->request = 'public_profile';
  206. }
  207. /** ----------------------------------
  208. /** Disable the full page view
  209. /** ----------------------------------*/
  210. if (in_array($this->request, $this->simple_page))
  211. {
  212. $this->show_headings = FALSE;
  213. }
  214. if (in_array($this->request, $this->no_breadcrumb))
  215. {
  216. $this->breadcrumb = FALSE;
  217. }
  218. /** ----------------------------------
  219. /** Validate ID number
  220. /** ----------------------------------*/
  221. // The $this->cur_id variable can only contain a number.
  222. // There are a few exceptions like the memberlist page and the
  223. // subscriptions page
  224. if ( ! in_array($this->request, $this->id_override) AND $this->cur_id != '' AND ! is_numeric($this->cur_id))
  225. {
  226. return FALSE;
  227. }
  228. return TRUE;
  229. }
  230. /** ----------------------------------
  231. /** Run the Member Class
  232. /** ----------------------------------*/
  233. function manager()
  234. {
  235. /** ---------------------------------
  236. /** Prep the request
  237. /** ---------------------------------*/
  238. if ( ! $this->_prep_request())
  239. {
  240. exit("Invalid Page Request");
  241. }
  242. // -------------------------------------------
  243. // 'member_manager' hook.
  244. // - Seize control over any Member Module user side request
  245. // - Added: 1.5.2
  246. //
  247. if ($this->EE->extensions->active_hook('member_manager') === TRUE)
  248. {
  249. $edata = $this->EE->extensions->universal_call('member_manager', $this);
  250. if ($this->EE->extensions->end_script === TRUE) return $edata;
  251. }
  252. //
  253. // -------------------------------------------
  254. /** ---------------------------------
  255. /** Is the user logged in?
  256. /** ---------------------------------*/
  257. if ($this->request != 'login' AND ! in_array($this->request, $this->no_login) AND $this->EE->session->userdata('member_id') == 0)
  258. {
  259. return $this->_final_prep($this->profile_login_form('self'));
  260. }
  261. /** ---------------------------------
  262. /** Left-side Menu
  263. /** ---------------------------------*/
  264. $left = ( ! in_array($this->request, $this->no_menu)) ? $this->profile_menu() : '';
  265. /** ------------------------------
  266. /** Validate the request
  267. /** ------------------------------*/
  268. $methods = array(
  269. 'public_profile',
  270. 'memberlist',
  271. 'member_search',
  272. 'do_member_search',
  273. 'login',
  274. 'unpw_update',
  275. 'register',
  276. 'profile',
  277. 'edit_preferences',
  278. 'update_preferences',
  279. 'edit_profile',
  280. 'update_profile',
  281. 'edit_email',
  282. 'update_email',
  283. 'edit_userpass',
  284. 'update_userpass',
  285. 'edit_localization',
  286. 'update_localization',
  287. 'edit_notepad',
  288. 'update_notepad',
  289. 'edit_signature',
  290. 'update_signature',
  291. 'edit_avatar',
  292. 'browse_avatars',
  293. 'select_avatar',
  294. 'upload_avatar',
  295. 'edit_photo',
  296. 'upload_photo',
  297. 'edit_subscriptions',
  298. 'update_subscriptions',
  299. 'edit_ignore_list',
  300. 'update_ignore_list',
  301. 'member_mini_search',
  302. 'do_member_mini_search',
  303. 'email_console',
  304. 'aim_console',
  305. 'icq_console',
  306. 'send_email',
  307. 'forgot_password',
  308. 'smileys',
  309. 'messages',
  310. 'delete'
  311. );
  312. if ( ! in_array($this->request, $methods))
  313. {
  314. return $this->EE->output->show_user_error('general', array($this->EE->lang->line('invalid_action')));
  315. }
  316. /** ------------------------------
  317. /** Call the requested function
  318. /** ------------------------------*/
  319. if ($this->request == 'profile') $this->request = 'profile_main';
  320. if ($this->request == 'register') $this->request = 'registration_form';
  321. if ($this->cur_id == 'member_search') {$left = ''; $this->breadcrumb = FALSE; $this->show_headings = FALSE;}
  322. if ($this->cur_id == 'do_member_search') {$left = ''; $this->breadcrumb = FALSE; $this->show_headings = FALSE;}
  323. if ($this->cur_id == 'buddy_search') {$left = ''; $this->breadcrumb = FALSE; $this->show_headings = FALSE;}
  324. if ($this->cur_id == 'do_buddy_search') {$left = ''; $this->breadcrumb = FALSE; $this->show_headings = FALSE;}
  325. $function = $this->request;
  326. if (in_array($function, array('upload_photo', 'upload_avatar', 'upload_signature_image', '_upload_image')))
  327. {
  328. require_once PATH_MOD.'member/mod.member_images.php';
  329. $MI = new Member_images();
  330. if (is_php('5.0.0') == TRUE)
  331. {
  332. foreach(get_object_vars($this) as $key => $value)
  333. {
  334. $MI->{$key} = $value;
  335. }
  336. }
  337. else
  338. {
  339. // sync everything since PHP4 was working from a copy
  340. foreach (array_keys(get_object_vars($this)) as $attribute)
  341. {
  342. $MI->$attribute =& $this->$attribute;
  343. }
  344. }
  345. $content = $MI->$function();
  346. }
  347. else
  348. {
  349. $content = $this->$function();
  350. }
  351. if ($this->cur_id == 'edit_folders') {$left = $this->profile_menu();}
  352. if ($this->cur_id == 'send_message') {$left = $this->profile_menu();}
  353. /** ------------------------------
  354. /** Parse the template the template
  355. /** ------------------------------*/
  356. if ($left == '')
  357. {
  358. $out = $this->_var_swap($this->_load_element('basic_profile'),
  359. array(
  360. 'include:content' => $content
  361. )
  362. );
  363. }
  364. else
  365. {
  366. $out = $this->_var_swap($this->_load_element('full_profile'),
  367. array(
  368. 'include:menu' => $left,
  369. 'include:content' => $content
  370. )
  371. );
  372. }
  373. /** ------------------------------
  374. /** Output the finalized request
  375. /** ------------------------------*/
  376. return $this->_final_prep($out);
  377. }
  378. /** ----------------------------------------
  379. /** Private Messages
  380. /** ----------------------------------------*/
  381. function messages()
  382. {
  383. if (($this->EE->session->userdata['can_send_private_messages'] != 'y' && $this->EE->session->userdata['group_id'] != '1') OR $this->EE->session->userdata['accept_messages'] != 'y')
  384. {
  385. return $this->profile_main();
  386. }
  387. if ( ! class_exists('EE_Messages'))
  388. {
  389. require APPPATH.'libraries/Messages'.EXT;
  390. }
  391. $MESS = new EE_Messages;
  392. $MESS->base_url = $this->_member_path('messages').'/';
  393. $MESS->allegiance = 'user';
  394. $MESS->theme_path = $this->theme_path;
  395. $MESS->request = $this->cur_id;
  396. $MESS->cur_id = $this->uri_extra;
  397. $MESS->MS =& $this;
  398. $MESS->manager();
  399. $this->page_title = $MESS->title;
  400. $this->head_extra = $MESS->header_javascript;
  401. return $MESS->return_data;
  402. }
  403. /** ----------------------------------------
  404. /** Member Profile - Menu
  405. /** ----------------------------------------*/
  406. function profile_menu()
  407. {
  408. if ( ! class_exists('Member_settings'))
  409. {
  410. require PATH_MOD.'member/mod.member_settings.php';
  411. }
  412. $MS = new Member_settings();
  413. if (is_php('5.0.0') == TRUE)
  414. {
  415. foreach(get_object_vars($this) as $key => $value)
  416. {
  417. $MS->{$key} = $value;
  418. }
  419. }
  420. else
  421. {
  422. // sync everything since PHP4 was working from a copy
  423. foreach (array_keys(get_object_vars($this)) as $attribute)
  424. {
  425. $MS->$attribute =& $this->$attribute;
  426. }
  427. }
  428. return $MS->profile_menu();
  429. }
  430. /** ----------------------------------------
  431. /** Private Messages - Menu
  432. /** ----------------------------------------*/
  433. function pm_menu()
  434. {
  435. if (($this->EE->session->userdata['can_send_private_messages'] != 'y' && $this->EE->session->userdata['group_id'] != '1') OR $this->EE->session->userdata['accept_messages'] != 'y')
  436. {
  437. return;
  438. }
  439. if ( ! class_exists('EE_Messages'))
  440. {
  441. require APPPATH.'libraries/Messages'.EXT;
  442. }
  443. $MESS = new EE_Messages;
  444. $MESS->base_url = $this->_member_path('messages');
  445. $MESS->allegiance = 'user';
  446. $MESS->theme_path = $this->theme_path;
  447. $MESS->MS =& $this;
  448. $MESS->create_menu();
  449. return $MESS->menu;
  450. }
  451. /** ----------------------------------------
  452. /** Member Profile Main Page
  453. /** ----------------------------------------*/
  454. function profile_main()
  455. {
  456. if ( ! class_exists('Member_settings'))
  457. {
  458. require PATH_MOD.'member/mod.member_settings.php';
  459. }
  460. $MS = new Member_settings();
  461. if (is_php('5.0.0') == TRUE)
  462. {
  463. foreach(get_object_vars($this) as $key => $value)
  464. {
  465. $MS->{$key} = $value;
  466. }
  467. }
  468. else
  469. {
  470. // sync everything since PHP4 was working from a copy
  471. foreach (array_keys(get_object_vars($this)) as $attribute)
  472. {
  473. $MS->$attribute =& $this->$attribute;
  474. }
  475. }
  476. return $MS->profile_main();
  477. }
  478. /** ----------------------------------------
  479. /** Member Public Profile
  480. /** ----------------------------------------*/
  481. function public_profile()
  482. {
  483. if ( ! class_exists('Member_settings'))
  484. {
  485. require PATH_MOD.'member/mod.member_settings.php';
  486. }
  487. $MS = new Member_settings();
  488. if (is_php('5.0.0') == TRUE)
  489. {
  490. foreach(get_object_vars($this) as $key => $value)
  491. {
  492. $MS->{$key} = $value;
  493. }
  494. }
  495. else
  496. {
  497. // sync everything since PHP4 was working from a copy
  498. foreach (array_keys(get_object_vars($this)) as $attribute)
  499. {
  500. $MS->$attribute =& $this->$attribute;
  501. }
  502. }
  503. return $MS->public_profile();
  504. }
  505. /** ----------------------------------------
  506. /** Login Page
  507. /** ----------------------------------------*/
  508. function profile_login_form($return = '-2')
  509. {
  510. if ( ! class_exists('Member_auth'))
  511. {
  512. require PATH_MOD.'member/mod.member_auth.php';
  513. }
  514. $MA = new Member_auth();
  515. if (is_php('5.0.0') == TRUE)
  516. {
  517. foreach(get_object_vars($this) as $key => $value)
  518. {
  519. $MA->{$key} = $value;
  520. }
  521. }
  522. else
  523. {
  524. // sync everything since PHP4 was working from a copy
  525. foreach (array_keys(get_object_vars($this)) as $attribute)
  526. {
  527. $MA->$attribute =& $this->$attribute;
  528. }
  529. }
  530. return $MA->profile_login_form($return);
  531. }
  532. /** ----------------------------------------
  533. /** Member Profile Edit Page
  534. /** ----------------------------------------*/
  535. function edit_profile()
  536. {
  537. if ( ! class_exists('Member_settings'))
  538. {
  539. require PATH_MOD.'member/mod.member_settings.php';
  540. }
  541. $MS = new Member_settings();
  542. if (is_php('5.0.0') == TRUE)
  543. {
  544. foreach(get_object_vars($this) as $key => $value)
  545. {
  546. $MS->{$key} = $value;
  547. }
  548. }
  549. else
  550. {
  551. // sync everything since PHP4 was working from a copy
  552. foreach (array_keys(get_object_vars($this)) as $attribute)
  553. {
  554. $MS->$attribute =& $this->$attribute;
  555. }
  556. }
  557. return $MS->edit_profile();
  558. }
  559. /** ----------------------------------------
  560. /** Profile Update
  561. /** ----------------------------------------*/
  562. function update_profile()
  563. {
  564. if ( ! class_exists('Member_settings'))
  565. {
  566. require PATH_MOD.'member/mod.member_settings.php';
  567. }
  568. $MS = new Member_settings();
  569. if (is_php('5.0.0') == TRUE)
  570. {
  571. foreach(get_object_vars($this) as $key => $value)
  572. {
  573. $MS->{$key} = $value;
  574. }
  575. }
  576. else
  577. {
  578. // sync everything since PHP4 was working from a copy
  579. foreach (array_keys(get_object_vars($this)) as $attribute)
  580. {
  581. $MS->$attribute =& $this->$attribute;
  582. }
  583. }
  584. return $MS->update_profile();
  585. }
  586. /** ----------------------------------------
  587. /** Forum Preferences
  588. /** ----------------------------------------*/
  589. function edit_preferences()
  590. {
  591. if ( ! class_exists('Member_settings'))
  592. {
  593. require PATH_MOD.'member/mod.member_settings.php';
  594. }
  595. $MS = new Member_settings();
  596. if (is_php('5.0.0') == TRUE)
  597. {
  598. foreach(get_object_vars($this) as $key => $value)
  599. {
  600. $MS->{$key} = $value;
  601. }
  602. }
  603. else
  604. {
  605. // sync everything since PHP4 was working from a copy
  606. foreach (array_keys(get_object_vars($this)) as $attribute)
  607. {
  608. $MS->$attribute =& $this->$attribute;
  609. }
  610. }
  611. return $MS->edit_preferences();
  612. }
  613. /** ----------------------------------------
  614. /** Update Preferences
  615. /** ----------------------------------------*/
  616. function update_preferences()
  617. {
  618. if ( ! class_exists('Member_settings'))
  619. {
  620. require PATH_MOD.'member/mod.member_settings.php';
  621. }
  622. $MS = new Member_settings();
  623. if (is_php('5.0.0') == TRUE)
  624. {
  625. foreach(get_object_vars($this) as $key => $value)
  626. {
  627. $MS->{$key} = $value;
  628. }
  629. }
  630. else
  631. {
  632. // sync everything since PHP4 was working from a copy
  633. foreach (array_keys(get_object_vars($this)) as $attribute)
  634. {
  635. $MS->$attribute =& $this->$attribute;
  636. }
  637. }
  638. return $MS->update_preferences();
  639. }
  640. /** ----------------------------------------
  641. /** Email Settings
  642. /** ----------------------------------------*/
  643. function edit_email()
  644. {
  645. if ( ! class_exists('Member_settings'))
  646. {
  647. require PATH_MOD.'member/mod.member_settings.php';
  648. }
  649. $MS = new Member_settings();
  650. if (is_php('5.0.0') == TRUE)
  651. {
  652. foreach(get_object_vars($this) as $key => $value)
  653. {
  654. $MS->{$key} = $value;
  655. }
  656. }
  657. else
  658. {
  659. // sync everything since PHP4 was working from a copy
  660. foreach (array_keys(get_object_vars($this)) as $attribute)
  661. {
  662. $MS->$attribute =& $this->$attribute;
  663. }
  664. }
  665. return $MS->edit_email();
  666. }
  667. /** ----------------------------------------
  668. /** Email Update
  669. /** ----------------------------------------*/
  670. function update_email()
  671. {
  672. if ( ! class_exists('Member_settings'))
  673. {
  674. require PATH_MOD.'member/mod.member_settings.php';
  675. }
  676. $MS = new Member_settings();
  677. if (is_php('5.0.0') == TRUE)
  678. {
  679. foreach(get_object_vars($this) as $key => $value)
  680. {
  681. $MS->{$key} = $value;
  682. }
  683. }
  684. else
  685. {
  686. // sync everything since PHP4 was working from a copy
  687. foreach (array_keys(get_object_vars($this)) as $attribute)
  688. {
  689. $MS->$attribute =& $this->$attribute;
  690. }
  691. }
  692. return $MS->update_email();
  693. }
  694. /** ----------------------------------------
  695. /** Username/Password Preferences
  696. /** ----------------------------------------*/
  697. function edit_userpass()
  698. {
  699. if ( ! class_exists('Member_settings'))
  700. {
  701. require PATH_MOD.'member/mod.member_settings.php';
  702. }
  703. $MS = new Member_settings();
  704. if (is_php('5.0.0') == TRUE)
  705. {
  706. foreach(get_object_vars($this) as $key => $value)
  707. {
  708. $MS->{$key} = $value;
  709. }
  710. }
  711. else
  712. {
  713. // sync everything since PHP4 was working from a copy
  714. foreach (array_keys(get_object_vars($this)) as $attribute)
  715. {
  716. $MS->$attribute =& $this->$attribute;
  717. }
  718. }
  719. return $MS->edit_userpass();
  720. }
  721. /** ----------------------------------------
  722. /** Username/Password Update
  723. /** ----------------------------------------*/
  724. function update_userpass()
  725. {
  726. if ( ! class_exists('Member_settings'))
  727. {
  728. require PATH_MOD.'member/mod.member_settings.php';
  729. }
  730. $MS = new Member_settings();
  731. if (is_php('5.0.0') == TRUE)
  732. {
  733. foreach(get_object_vars($this) as $key => $value)
  734. {
  735. $MS->{$key} = $value;
  736. }
  737. }
  738. else
  739. {
  740. // sync everything since PHP4 was working from a copy
  741. foreach (array_keys(get_object_vars($this)) as $attribute)
  742. {
  743. $MS->$attribute =& $this->$attribute;
  744. }
  745. }
  746. return $MS->update_userpass();
  747. }
  748. /** ----------------------------------------
  749. /** Localization Edit Form
  750. /** ----------------------------------------*/
  751. function edit_localization()
  752. {
  753. if ( ! class_exists('Member_settings'))
  754. {
  755. require PATH_MOD.'member/mod.member_settings.php';
  756. }
  757. $MS = new Member_settings();
  758. if (is_php('5.0.0') == TRUE)
  759. {
  760. foreach(get_object_vars($this) as $key => $value)
  761. {
  762. $MS->{$key} = $value;
  763. }
  764. }
  765. else
  766. {
  767. // sync everything since PHP4 was working from a copy
  768. foreach (array_keys(get_object_vars($this)) as $attribute)
  769. {
  770. $MS->$attribute =& $this->$attribute;
  771. }
  772. }
  773. return $MS->edit_localization();
  774. }
  775. /** ----------------------------------------
  776. /** Update Localization Prefs
  777. /** ----------------------------------------*/
  778. function update_localization()
  779. {
  780. if ( ! class_exists('Member_settings'))
  781. {
  782. require PATH_MOD.'member/mod.member_settings.php';
  783. }
  784. $MS = new Member_settings();
  785. if (is_php('5.0.0') == TRUE)
  786. {
  787. foreach(get_object_vars($this) as $key => $value)
  788. {
  789. $MS->{$key} = $value;
  790. }
  791. }
  792. else
  793. {
  794. // sync everything since PHP4 was working from a copy
  795. foreach (array_keys(get_object_vars($this)) as $attribute)
  796. {
  797. $MS->$attribute =& $this->$attribute;
  798. }
  799. }
  800. return $MS->update_localization();
  801. }
  802. /** ----------------------------------------
  803. /** Signature Edit Form
  804. /** ----------------------------------------*/
  805. function edit_signature()
  806. {
  807. if ( ! class_exists('Member_images'))
  808. {
  809. require PATH_MOD.'member/mod.member_images.php';
  810. }
  811. $MI = new Member_images();
  812. if (is_php('5.0.0') == TRUE)
  813. {
  814. foreach(get_object_vars($this) as $key => $value)
  815. {
  816. $MI->{$key} = $value;
  817. }
  818. }
  819. else
  820. {
  821. // sync everything since PHP4 was working from a copy
  822. foreach (array_keys(get_object_vars($this)) as $attribute)
  823. {
  824. $MI->$attribute =& $this->$attribute;
  825. }
  826. }
  827. return $MI->edit_signature();
  828. }
  829. /** ----------------------------------------
  830. /** Update Signature
  831. /** ----------------------------------------*/
  832. function update_signature()
  833. {
  834. if ( ! class_exists('Member_images'))
  835. {
  836. require PATH_MOD.'member/mod.member_images.php';
  837. }
  838. $MI = new Member_images();
  839. if (is_php('5.0.0') == TRUE)
  840. {
  841. foreach(get_object_vars($this) as $key => $value)
  842. {
  843. $MI->{$key} = $value;
  844. }
  845. }
  846. else
  847. {
  848. // sync everything since PHP4 was working from a copy
  849. foreach (array_keys(get_object_vars($this)) as $attribute)
  850. {
  851. $MI->$attribute =& $this->$attribute;
  852. }
  853. }
  854. return $MI->update_signature();
  855. }
  856. /** ----------------------------------------
  857. /** Avatar Edit Form
  858. /** ----------------------------------------*/
  859. function edit_avatar()
  860. {
  861. if ( ! class_exists('Member_images'))
  862. {
  863. require PATH_MOD.'member/mod.member_images.php';
  864. }
  865. $MI = new Member_images();
  866. if (is_php('5.0.0') == TRUE)
  867. {
  868. foreach(get_object_vars($this) as $key => $value)
  869. {
  870. $MI->{$key} = $value;
  871. }
  872. }
  873. else
  874. {
  875. // sync everything since PHP4 was working from a copy
  876. foreach (array_keys(get_object_vars($this)) as $attribute)
  877. {
  878. $MI->$attribute =& $this->$attribute;
  879. }
  880. }
  881. return $MI->edit_avatar();
  882. }
  883. /** ----------------------------------------
  884. /** Browse Avatars
  885. /** ----------------------------------------*/
  886. function browse_avatars()
  887. {
  888. if ( ! class_exists('Member_images'))
  889. {
  890. require PATH_MOD.'member/mod.member_images.php';
  891. }
  892. $MI = new Member_images();
  893. if (is_php('5.0.0') == TRUE)
  894. {
  895. foreach(get_object_vars($this) as $key => $value)
  896. {
  897. $MI->{$key} = $value;
  898. }
  899. }
  900. else
  901. {
  902. // sync everything since PHP4 was working from a copy
  903. foreach (array_keys(get_object_vars($this)) as $attribute)
  904. {
  905. $MI->$attribute =& $this->$attribute;
  906. }
  907. }
  908. return $MI->browse_avatars();
  909. }
  910. /** ----------------------------------------
  911. /** Select Avatar From Library
  912. /** ----------------------------------------*/
  913. function select_avatar()
  914. {
  915. if ( ! class_exists('Member_images'))
  916. {
  917. require PATH_MOD.'member/mod.member_images.php';
  918. }
  919. $MI = new Member_images();
  920. if (is_php('5.0.0') == TRUE)
  921. {
  922. foreach(get_object_vars($this) as $key => $value)
  923. {
  924. $MI->{$key} = $value;
  925. }
  926. }
  927. else
  928. {
  929. // sync everything since PHP4 was working from a copy
  930. foreach (array_keys(get_object_vars($this)) as $attribute)
  931. {
  932. $MI->$attribute =& $this->$attribute;
  933. }
  934. }
  935. return $MI->select_avatar();
  936. }
  937. /** ----------------------------------------
  938. /** Photo Edit Form
  939. /** ----------------------------------------*/
  940. function edit_photo()
  941. {
  942. if ( ! class_exists('Member_images'))
  943. {
  944. require PATH_MOD.'member/mod.member_images.php';
  945. }
  946. $MI = new Member_images();
  947. if (is_php('5.0.0') == TRUE)
  948. {
  949. foreach(get_object_vars($this) as $key => $value)
  950. {
  951. $MI->{$key} = $value;
  952. }
  953. }
  954. else
  955. {
  956. // sync everything since PHP4 was working from a copy
  957. foreach (array_keys(get_object_vars($this)) as $attribute)
  958. {
  959. $MI->$attribute =& $this->$attribute;
  960. }
  961. }
  962. return $MI->edit_photo();
  963. }
  964. /** ----------------------------------------
  965. /** Notepad Edit Form
  966. /** ----------------------------------------*/
  967. function edit_notepad()
  968. {
  969. if ( ! class_exists('Member_settings'))
  970. {
  971. require PATH_MOD.'member/mod.member_settings.php';
  972. }
  973. $MS = new Member_settings();
  974. if (is_php('5.0.0') == TRUE)
  975. {
  976. foreach(get_object_vars($this) as $key => $value)
  977. {
  978. $MS->{$key} = $value;
  979. }
  980. }
  981. else
  982. {
  983. // sync everything since PHP4 was working from a copy
  984. foreach (array_keys(get_object_vars($this)) as $attribute)
  985. {
  986. $MS->$attribute =& $this->$attribute;
  987. }
  988. }
  989. return $MS->edit_notepad();
  990. }
  991. /** ----------------------------------------
  992. /** Update Notepad
  993. /** ----------------------------------------*/
  994. function update_notepad()
  995. {
  996. if ( ! class_exists('Member_settings'))
  997. {
  998. require PATH_MOD.'member/mod.member_settings.php';
  999. }
  1000. $MS = new Member_settings();
  1001. if (is_php('5.0.0') == TRUE)
  1002. {
  1003. foreach(get_object_vars($this) as $key => $value)
  1004. {
  1005. $MS->{$key} = $value;
  1006. }
  1007. }
  1008. else
  1009. {
  1010. // sync everything since PHP4 was working from a copy
  1011. foreach (array_keys(get_object_vars($this)) as $attribute)
  1012. {
  1013. $MS->$attribute =& $this->$attribute;
  1014. }
  1015. }
  1016. return $MS->update_notepad();
  1017. }
  1018. /** ----------------------------------------
  1019. /** Member Login
  1020. /** ----------------------------------------*/
  1021. function member_login()
  1022. {
  1023. if ( ! class_exists('Member_auth'))
  1024. {
  1025. require PATH_MOD.'member/mod.member_auth.php';
  1026. }
  1027. $MA = new Member_auth();
  1028. if (is_php('5.0.0') == TRUE)
  1029. {
  1030. foreach(get_object_vars($this) as $key => $value)
  1031. {
  1032. $MA->{$key} = $value;
  1033. }
  1034. }
  1035. else
  1036. {
  1037. // sync everything since PHP4 was working from a copy
  1038. foreach (array_keys(get_object_vars($this)) as $attribute)
  1039. {
  1040. $MA->$attribute =& $this->$attribute;
  1041. }
  1042. }
  1043. $MA->member_login();
  1044. }
  1045. /** ----------------------------------------
  1046. /** Member Logout
  1047. /** ----------------------------------------*/
  1048. function member_logout()
  1049. {
  1050. if ( ! class_exists('Member_auth'))
  1051. {
  1052. require PATH_MOD.'member/mod.member_auth.php';
  1053. }
  1054. $MA = new Member_auth();
  1055. if (is_php('5.0.0') == TRUE)
  1056. {
  1057. foreach(get_object_vars($this) as $key => $value)
  1058. {
  1059. $MA->{$key} = $value;
  1060. }
  1061. }
  1062. else
  1063. {
  1064. // sync everything since PHP4 was working from a copy
  1065. foreach (array_keys(get_object_vars($this)) as $attribute)
  1066. {
  1067. $MA->$attribute =& $this->$attribute;
  1068. }
  1069. }
  1070. $MA->member_logout();
  1071. }
  1072. /** ----------------------------------------
  1073. /** Member Forgot Password Form
  1074. /** ----------------------------------------*/
  1075. function forgot_password($ret = '-3')
  1076. {
  1077. if ( ! class_exists('Member_auth'))
  1078. {
  1079. require PATH_MOD.'member/mod.member_auth.php';
  1080. }
  1081. $MA = new Member_auth();
  1082. if (is_php('5.0.0') == TRUE)
  1083. {
  1084. foreach(get_object_vars($this) as $key => $value)
  1085. {
  1086. $MA->{$key} = $value;
  1087. }
  1088. }
  1089. else
  1090. {
  1091. // sync everything since PHP4 was working from a copy
  1092. foreach (array_keys(get_object_vars($this)) as $attribute)
  1093. {
  1094. $MA->$attribute =& $this->$attribute;
  1095. }
  1096. }
  1097. return $MA->forgot_password($ret);
  1098. }
  1099. /** ----------------------------------------
  1100. /** Retreive Forgotten Password
  1101. /** ----------------------------------------*/
  1102. function retrieve_password()
  1103. {
  1104. if ( ! class_exists('Member_auth'))
  1105. {
  1106. require PATH_MOD.'member/mod.member_auth.php';
  1107. }
  1108. $MA = new Member_auth();
  1109. if (is_php('5.0.0') == TRUE)
  1110. {
  1111. foreach(get_object_vars($this) as $key => $value)
  1112. {
  1113. $MA->{$key} = $value;
  1114. }
  1115. }
  1116. else
  1117. {
  1118. // sync everything since PHP4 was working from a copy
  1119. foreach (array_keys(get_object_vars($this)) as $attribute)
  1120. {
  1121. $MA->$attribute =& $this->$attribute;
  1122. }
  1123. }
  1124. $MA->retrieve_password();
  1125. }
  1126. /** ----------------------------------------
  1127. /** Reset the user's password
  1128. /** ----------------------------------------*/
  1129. function reset_password()
  1130. {
  1131. if ( ! class_exists('Member_auth'))
  1132. {
  1133. require PATH_MOD.'member/mod.member_auth.php';
  1134. }
  1135. $MA = new Member_auth();
  1136. if (is_php('5.0.0') == TRUE)
  1137. {
  1138. foreach(get_object_vars($this) as $key => $value)
  1139. {
  1140. $MA->{$key} = $value;
  1141. }
  1142. }
  1143. else
  1144. {
  1145. // sync everything since PHP4 was working from a copy
  1146. foreach (array_keys(get_object_vars($this)) as $attribute)
  1147. {
  1148. $MA->$attribute =& $this->$attribute;
  1149. }
  1150. }
  1151. $MA->reset_password();
  1152. }
  1153. /** ----------------------------------------
  1154. /** Subscriptions Edit Form
  1155. /** ----------------------------------------*/
  1156. function edit_subscriptions()
  1157. {
  1158. if ( ! class_exists('Member_subscriptions'))
  1159. {
  1160. require PATH_MOD.'member/mod.member_subscriptions.php';
  1161. }
  1162. $MS = new Member_subscriptions();
  1163. if (is_php('5.0.0') == TRUE)
  1164. {
  1165. foreach(get_object_vars($this) as $key => $value)
  1166. {
  1167. $MS->{$key} = $value;
  1168. }
  1169. }
  1170. else
  1171. {
  1172. // sync everything since PHP4 was working from a copy
  1173. foreach (array_keys(get_object_vars($this)) as $attribute)
  1174. {
  1175. $MS->$attribute =& $this->$attribute;
  1176. }
  1177. }
  1178. return $MS->edit_subscriptions();
  1179. }
  1180. /** ----------------------------------------
  1181. /** Update Subscriptions
  1182. /** ----------------------------------------*/
  1183. function update_subscriptions()
  1184. {
  1185. if ( ! class_exists('Member_subscriptions'))
  1186. {
  1187. require PATH_MOD.'member/mod.member_subscriptions.php';
  1188. }
  1189. $MS = new Member_subscriptions();
  1190. if (is_php('5.0.0') == TRUE)
  1191. {
  1192. foreach(get_object_vars($this) as $key => $value)
  1193. {
  1194. $MS->{$key} = $value;
  1195. }
  1196. }
  1197. else
  1198. {
  1199. // sync everything since PHP4 was working from a copy
  1200. foreach (array_keys(get_object_vars($this)) as $attribute)
  1201. {
  1202. $MS->$attribute =& $this->$attribute;
  1203. }
  1204. }
  1205. return $MS->update_subscriptions();
  1206. }
  1207. /** -------------------------------------
  1208. /** Edit Ignore List Form
  1209. /** -------------------------------------*/
  1210. function edit_ignore_list()
  1211. {
  1212. if ( ! class_exists('Member_settings'))
  1213. {
  1214. require PATH_MOD.'member/mod.member_settings.php';
  1215. }
  1216. $MS = new Member_settings();
  1217. if (is_php('5.0.0') == TRUE)
  1218. {
  1219. foreach(get_object_vars($this) as $key => $value)
  1220. {
  1221. $MS->{$key} = $value;
  1222. }
  1223. }
  1224. else
  1225. {
  1226. // sync everything since PHP4 was working from a copy
  1227. foreach (array_keys(get_object_vars($this)) as $attribute)
  1228. {
  1229. $MS->$attribute =& $this->$attribute;
  1230. }
  1231. }
  1232. return $MS->edit_ignore_list();
  1233. }
  1234. /** -------------------------------------
  1235. /** Update Ignore List
  1236. /** -------------------------------------*/
  1237. function update_ignore_list()
  1238. {
  1239. if ( ! class_exists('Member_settings'))
  1240. {
  1241. require PATH_MOD.'member/mod.member_settings.php';
  1242. }
  1243. $MS = new Member_settings();
  1244. if (is_php('5.0.0') == TRUE)
  1245. {
  1246. foreach(get_object_vars($this) as $key => $value)
  1247. {
  1248. $MS->{$key} = $value;
  1249. }
  1250. }
  1251. else
  1252. {
  1253. // sync everything since PHP4 was working from a copy
  1254. foreach (array_keys(get_object_vars($this)) as $attribute)
  1255. {
  1256. $MS->$attribute =& $this->$attribute;
  1257. }
  1258. }
  1259. return $MS->update_ignore_list();
  1260. }
  1261. /** -------------------------------------
  1262. /** Member Mini Search
  1263. /** -------------------------------------*/
  1264. function member_mini_search()
  1265. {
  1266. if ( ! class_exists('Member_settings'))
  1267. {
  1268. require PATH_MOD.'member/mod.member_settings.php';
  1269. }
  1270. $MS = new Member_settings();
  1271. if (is_php('5.0.0') == TRUE)
  1272. {
  1273. foreach(get_object_vars($this) as $key => $value)
  1274. {
  1275. $MS->{$key} = $value;
  1276. }
  1277. }
  1278. else
  1279. {
  1280. // sync everything since PHP4 was working from a copy
  1281. foreach (array_keys(get_object_vars($this)) as $attribute)
  1282. {
  1283. $MS->$attribute =& $this->$attribute;
  1284. }
  1285. }
  1286. $this->_set_page_title($this->EE->lang->line('member_search'));
  1287. return $MS->member_mini_search();
  1288. }
  1289. /** -------------------------------------
  1290. /** Do Member Mini Search
  1291. /** -------------------------------------*/
  1292. function do_member_mini_search()
  1293. {
  1294. if ( ! class_exists('Member_settings'))
  1295. {
  1296. require PATH_MOD.'member/mod.member_settings.php';
  1297. }
  1298. $MS = new Member_settings();
  1299. if (is_php('5.0.0') == TRUE)
  1300. {
  1301. foreach(get_object_vars($this) as $key => $value)
  1302. {
  1303. $MS->{$key} = $value;
  1304. }
  1305. }
  1306. else
  1307. {
  1308. // sync everything since PHP4 was working from a copy
  1309. foreach (array_keys(get_object_vars($this)) as $attribute)
  1310. {
  1311. $MS->$attribute =& $this->$attribute;
  1312. }
  1313. }
  1314. $this->_set_page_title($this->EE->lang->line('member_search'));
  1315. return $MS->do_member_mini_search();
  1316. }
  1317. /** ----------------------------------------
  1318. /** Member Registration Form
  1319. /** ----------------------------------------*/
  1320. function registration_form()
  1321. {
  1322. if ( ! class_exists('Member_register'))
  1323. {
  1324. require PATH_MOD.'member/mod.member_register.php';
  1325. }
  1326. $MR = new Member_register();
  1327. if (is_php('5.0.0') == TRUE)
  1328. {
  1329. foreach(get_object_vars($this) as $key => $value)
  1330. {
  1331. $MR->{$key} = $value;
  1332. }
  1333. }
  1334. else
  1335. {
  1336. // sync everything since PHP4 was working from a copy
  1337. foreach (array_keys(get_object_vars($this)) as $attribute)
  1338. {
  1339. $MR->$attribute =& $this->$attribute;
  1340. }
  1341. }
  1342. return $MR->registration_form();
  1343. }
  1344. /** ----------------------------------------
  1345. /** Register Member
  1346. /** ----------------------------------------*/
  1347. function register_member()
  1348. {
  1349. if ( ! class_exists('Member_register'))
  1350. {
  1351. require PATH_MOD.'member/mod.member_register.php';
  1352. }
  1353. $MR = new Member_register();
  1354. if (is_php('5.0.0') == TRUE)
  1355. {
  1356. foreach(get_object_vars($this) as $key => $value)
  1357. {
  1358. $MR->{$key} = $value;
  1359. }
  1360. }
  1361. else
  1362. {
  1363. // sync everything since PHP4 was working from a copy
  1364. foreach (array_keys(get_object_vars($this)) as $attribute)
  1365. {
  1366. $MR->$attribute =& $this->$attribute;
  1367. }
  1368. }
  1369. $MR->register_member();
  1370. }
  1371. /** ----------------------------------------
  1372. /** Member Self-Activation
  1373. /** ----------------------------------------*/
  1374. function activate_member()
  1375. {
  1376. if ( ! class_exists('Member_register'))
  1377. {
  1378. require PATH_MOD.'member/mod.member_register.php';
  1379. }
  1380. $MR = new Member_register();
  1381. if (is_php('5.0.0') == TRUE)
  1382. {
  1383. foreach(get_object_vars($this) as $key => $value)
  1384. {
  1385. $MR->{$key} = $value;
  1386. }
  1387. }
  1388. else
  1389. {
  1390. // sync everything since PHP4 was working from a copy
  1391. foreach (array_keys(get_object_vars($this)) as $attribute)
  1392. {
  1393. $MR->$attribute =& $this->$attribute;
  1394. }
  1395. }
  1396. $MR->activate_member();
  1397. }
  1398. /** -------------------------------------
  1399. /** Delete Page
  1400. /** -------------------------------------*/
  1401. function delete()
  1402. {
  1403. return $this->confirm_delete_form();
  1404. }
  1405. /** -------------------------------------
  1406. /** Self-delete confirmation form
  1407. /** -------------------------------------*/
  1408. function confirm_delete_form()
  1409. {
  1410. if ($this->EE->session->userdata['can_delete_self'] !== 'y')
  1411. {
  1412. return $this->EE->output->show_user_error('general', $this->EE->lang->line('cannot_delete_self'));
  1413. }
  1414. else
  1415. {
  1416. $delete_form = $this->_load_element('delete_confirmation_form');
  1417. $data['hidden_fields']['ACT'] = $this->EE->functions->fetch_action_id('Member', 'member_delete');
  1418. $data['onsubmit'] = "if( ! confirm('{lang:final_delete_confirm}')) return false;";
  1419. $data['id'] = 'member_delete_form';
  1420. $this->_set_page_title($this->EE->lang->line('member_delete'));
  1421. return $this->_var_swap($delete_form, array('form_declaration' => $this->EE->functions->form_declaration($data)));
  1422. }
  1423. }
  1424. /** -------------------------------------
  1425. /** Member self-delete
  1426. /** -------------------------------------*/
  1427. function member_delete()
  1428. {
  1429. /** -------------------------------------
  1430. /** Make sure they got here via a form
  1431. /** -------------------------------------*/
  1432. if ( ! $this->EE->input->post('ACT'))
  1433. {
  1434. // No output for you, Mr. URL Hax0r
  1435. return FALSE;
  1436. }
  1437. $this->EE->lang->loadfile('login');
  1438. /* -------------------------------------
  1439. /* No sneakiness - we'll do this in case the site administrator
  1440. /* has foolishly turned off secure forms and some monkey is
  1441. /* trying to delete their account from an off-site form or
  1442. /* after logging out.
  1443. /* -------------------------------------*/
  1444. if ($this->EE->session->userdata['member_id'] == 0 OR $this->EE->session->userdata['can_delete_self'] !== 'y')
  1445. {
  1446. return $this->EE->output->show_user_error('general', $this->EE->lang->line('not_authorized'));
  1447. }
  1448. /** -------------------------------------
  1449. /** If the user is a SuperAdmin, then no deletion
  1450. /** -------------------------------------*/
  1451. if ($this->EE->session->userdata['group_id'] == 1)
  1452. {
  1453. return $this->EE->output->show_user_error('general', $this->EE->lang->line('cannot_delete_super_admin'));
  1454. }
  1455. /** ----------------------------------------
  1456. /** Is IP and User Agent required for login? Then, same here.
  1457. /** ----------------------------------------*/
  1458. if ($this->EE->config->item('require_ip_for_login') == 'y')
  1459. {
  1460. if ($this->EE->session->userdata['ip_address'] == '' OR $this->EE->session->userdata['user_agent'] == '')
  1461. {
  1462. return $this->EE->output->show_user_error('general', $this->EE->lang->line('unauthorized_request'));
  1463. }
  1464. }
  1465. /** ----------------------------------------
  1466. /** Check password lockout status
  1467. /** ----------------------------------------*/
  1468. if ($this->EE->session->check_password_lockout($this->EE->session->userdata['username']) === TRUE)
  1469. {
  1470. return $this->EE->output->show_user_error('general', str_replace("%x", $this->EE->config->item('password_lockout_interval'), $this->EE->lang->line('password_lockout_in_effect')));
  1471. }
  1472. /* -------------------------------------
  1473. /* Are you who you say you are, or someone sitting at someone
  1474. /* else's computer being mean?!
  1475. /* -------------------------------------*/
  1476. $query = $this->EE->db->query("SELECT password FROM exp_members WHERE member_id = '".$this->EE->session->userdata['member_id']."'");
  1477. $password = $this->EE->functions->hash(stripslashes($this->EE->input->post('password')));
  1478. if ($query->row('password') != $password)
  1479. {
  1480. $this->EE->session->save_password_lockout($this->EE->session->userdata['username']);
  1481. return $this->EE->output->show_user_error('general', $this->EE->lang->line('invalid_pw'));
  1482. }
  1483. /** -------------------------------------
  1484. /** No turning back, get to deletin'!
  1485. /** -------------------------------------*/
  1486. $id = $this->EE->session->userdata['member_id'];
  1487. $this->EE->db->query("DELETE FROM exp_members WHERE member_id = '{$id}'");
  1488. $this->EE->db->query("DELETE FROM exp_member_data WHERE member_id = '{$id}'");
  1489. $this->EE->db->query("DELETE FROM exp_member_homepage WHERE member_id = '{$id}'");
  1490. $message_query = $this->EE->db->query("SELECT DISTINCT recipient_id FROM exp_message_copies WHERE sender_id = '{$id}' AND message_read = 'n'");
  1491. $this->EE->db->query("DELETE FROM exp_message_copies WHERE sender_id = '{$id}'");
  1492. $this->EE->db->query("DELETE FROM exp_message_data WHERE sender_id = '{$id}'");
  1493. $this->EE->db->query("DELETE FROM exp_message_folders WHERE member_id = '{$id}'");
  1494. $this->EE->db->query("DELETE FROM exp_message_listed WHERE member_id = '{$id}'");
  1495. if ($message_query->num_rows() > 0)
  1496. {
  1497. foreach($message_query->result_array() as $row)
  1498. {
  1499. $count_query = $this->EE->db->query("SELECT COUNT(*) AS count FROM exp_message_copies WHERE recipient_id = '".$row['recipient_id']."' AND message_read = 'n'");
  1500. $this->EE->db->query($this->EE->db->update_string('exp_members', array('private_messages' => $count_query->row('count') ), "member_id = '".$row['recipient_id']."'"));
  1501. }
  1502. }
  1503. /** -------------------------------------
  1504. /** Delete Forum Posts
  1505. /** -------------------------------------*/
  1506. if ($this->EE->config->item('forum_is_installed') == "y")
  1507. {
  1508. $this->EE->db->query("DELETE FROM exp_forum_subscriptions WHERE member_id = '{$id}'");
  1509. $this->EE->db->query("DELETE FROM exp_forum_pollvotes WHERE member_id = '{$id}'");
  1510. $this->EE->db->query("DELETE FROM exp_forum_topics WHERE author_id = '{$id}'");
  1511. $this->EE->db->query("DELETE FROM exp_forum_administrators WHERE admin_member_id = '{$id}'");
  1512. $this->EE->db->query("DELETE FROM exp_forum_moderators WHERE mod_member_id = '{$id}'");
  1513. // Snag the affected topic id's before deleting the member for the update afterwards
  1514. $query = $this->EE->db->query("SELECT topic_id FROM exp_forum_posts WHERE author_id = '{$id}'");
  1515. if ($query->num_rows() > 0)
  1516. {
  1517. $topic_ids = array();
  1518. foreach ($query->result_array() as $row)
  1519. {
  1520. $topic_ids[] = $row['topic_id'];
  1521. }
  1522. $topic_ids = array_unique($topic_ids);
  1523. }
  1524. $this->EE->db->query("DELETE FROM exp_forum_posts WHERE author_id = '{$id}'");
  1525. $this->EE->db->query("DELETE FROM exp_forum_polls WHERE author_id = '{$id}'");
  1526. // Kill any attachments
  1527. $query = $this->EE->db->query("SELECT attachment_id, filehash, extension, board_id FROM exp_forum_attachments WHERE member_id = '{$id}'");
  1528. if ($query->num_rows() > 0)
  1529. {
  1530. // Grab the upload path
  1531. $res = $this->EE->db->query('SELECT board_id, board_upload_path FROM exp_forum_boards');
  1532. $paths = array();
  1533. foreach ($res->result_array() as $row)
  1534. {
  1535. $paths[$row['board_id']] = $row['board_upload_path'];
  1536. }
  1537. foreach ($query->result_array() as $row)
  1538. {
  1539. if ( ! isset($paths[$row['board_id']]))
  1540. {
  1541. continue;
  1542. }
  1543. $file = $paths[$row['board_id']].$row['filehash'].$row['extension'];
  1544. $thumb = $paths[$row['board_id']].$row['filehash'].'_t'.$row['extension'];
  1545. @unlink($file);
  1546. @unlink($thumb);
  1547. $this->EE->db->query("DELETE FROM exp_forum_attachments WHERE attachment_id = '{$row['attachment_id']}'");
  1548. }
  1549. }
  1550. // Update the forum stats
  1551. $query = $this->EE->db->query("SELECT forum_id FROM exp_forums WHERE forum_is_cat = 'n'");
  1552. if ( ! class_exists('Forum'))
  1553. {
  1554. require PATH_MOD.'forum/mod.forum'.EXT;
  1555. require PATH_MOD.'forum/mod.forum_core'.EXT;
  1556. }
  1557. $FRM = new Forum_Core;
  1558. foreach ($query->result_array() as $row)
  1559. {
  1560. $FRM->_update_post_stats($row['forum_id']);
  1561. }
  1562. if (isset($topic_ids))
  1563. {
  1564. foreach ($topic_ids as $topic_id)
  1565. {
  1566. $FRM->_update_topic_stats($topic_id);
  1567. }
  1568. }
  1569. }
  1570. /** -------------------------------------
  1571. /** Va-poo-rize Channel Entries and Comments
  1572. /** -------------------------------------*/
  1573. $entry_ids = array();
  1574. $channel_ids = array();
  1575. $recount_ids = array();
  1576. // Find Entry IDs and Channel IDs, then delete
  1577. $query = $this->EE->db->query("SELECT entry_id, channel_id FROM exp_channel_titles WHERE author_id = '{$id}'");
  1578. if ($query->num_rows() > 0)
  1579. {
  1580. foreach ($query->result_array() as $row)
  1581. {
  1582. $entry_ids[] = $row['entry_id'];
  1583. $channel_ids[] = $row['channel_id'];
  1584. }
  1585. $this->EE->db->query("DELETE FROM exp_channel_titles WHERE author_id = '{$id}'");
  1586. $this->EE->db->query("DELETE FROM exp_channel_data WHERE entry_id IN ('".implode("','", $entry_ids)."')");
  1587. $this->EE->db->query("DELETE FROM exp_comments WHERE entry_id IN ('".implode("','", $entry_ids)."')");
  1588. }
  1589. // Find the affected entries AND channel ids for author's comments
  1590. $query = $this->EE->db->query("SELECT DISTINCT(entry_id), channel_id FROM exp_comments WHERE author_id = '{$id}'");
  1591. if ($query->num_rows() > 0)
  1592. {
  1593. foreach ($query->result_array() as $row)
  1594. {
  1595. $recount_ids[] = $row['entry_id'];
  1596. $channel_ids[] = $row['channel_id'];
  1597. }
  1598. $recount_ids = array_diff($recount_ids, $entry_ids);
  1599. }
  1600. // Delete comments by member
  1601. $this->EE->db->query("DELETE FROM exp_comments WHERE author_id = '{$id}'");
  1602. // Update stats on channel entries that were NOT deleted AND had comments by author
  1603. if (count($recount_ids) > 0)
  1604. {
  1605. foreach (array_unique($recount_ids) as $entry_id)
  1606. {
  1607. $query = $this->EE->db->query("SELECT MAX(comment_date) AS max_date FROM exp_comments WHERE status = 'o' AND entry_id = '".$this->EE->db->escape_str($entry_id)."'");
  1608. $comment_date = ($query->num_rows() == 0 OR ! is_numeric($query->row('max_date') )) ? 0 : $query->row('max_date') ;
  1609. $query = $this->EE->db->query("SELECT COUNT(*) AS count FROM exp_comments WHERE entry_id = '{$entry_id}' AND status = 'o'");
  1610. $this->EE->db->query("UPDATE exp_channel_titles SET comment_total = '".$this->EE->db->escape_str($query->row('count') )."', recent_comment_date = '$comment_date' WHERE entry_id = '{$entry_id}'");
  1611. }
  1612. }
  1613. if (count($channel_ids) > 0)
  1614. {
  1615. foreach (array_unique($channel_ids) as $channel_id)
  1616. {
  1617. $this->EE->stats->update_channel_stats($channel_id);
  1618. $this->EE->stats->update_comment_stats($channel_id);
  1619. }
  1620. }
  1621. /** -------------------------------------
  1622. /** Email notification recipients
  1623. /** -------------------------------------*/
  1624. if ($this->EE->session->userdata['mbr_delete_notify_emails'] != '')
  1625. {
  1626. $notify_address = $this->EE->session->userdata['mbr_delete_notify_emails'];
  1627. $swap = array(
  1628. 'name' => $this->EE->session->userdata['screen_name'],
  1629. 'email' => $this->EE->session->userdata['email'],
  1630. 'site_name' => stripslashes($this->EE->config->item('site_name'))
  1631. );
  1632. $email_tit = $this->EE->functions->var_swap($this->EE->lang->line('mbr_delete_notify_title'), $swap);
  1633. $email_msg = $this->EE->functions->var_swap($this->EE->lang->line('mbr_delete_notify_message'), $swap);
  1634. // No notification for the user themselves, if they're in the list
  1635. if (strpos($notify_address, $this->EE->session->userdata('email')) !== FALSE)
  1636. {
  1637. $notify_address = str_replace($this->EE->session->userdata['email'], "", $notify_address);
  1638. }
  1639. $this->EE->load->helper('string');
  1640. // Remove multiple commas
  1641. $notify_address = reduce_multiples($notify_address, ',', TRUE);
  1642. if ($notify_address != '')
  1643. {
  1644. /** ----------------------------
  1645. /** Send email
  1646. /** ----------------------------*/
  1647. $this->EE->load->library('email');
  1648. // Load the text helper
  1649. $this->EE->load->helper('text');
  1650. foreach (explode(',', $notify_address) as $addy)
  1651. {
  1652. $this->EE->email->EE_initialize();
  1653. $this->EE->email->wordwrap = FALSE;
  1654. $this->EE->email->from($this->EE->config->item('webmaster_email'), $this->EE->config->item('webmaster_name'));
  1655. $this->EE->email->to($addy);
  1656. $this->EE->email->reply_to($this->EE->config->item('webmaster_email'));
  1657. $this->EE->email->subject($email_tit);
  1658. $this->EE->email->message(entities_to_ascii($email_msg));
  1659. $this->EE->email->send();
  1660. }
  1661. }
  1662. }
  1663. /** -------------------------------------
  1664. /** Trash the Session and cookies
  1665. /** -------------------------------------*/
  1666. $this->EE->db->query("DELETE FROM exp_online_users WHERE site_id = '".$this->EE->db->escape_str($this->EE->config->item('site_id'))."' AND ip_address = '".$this->EE->input->ip_address()."' AND member_id = '{$id}'");
  1667. $this->EE->db->query("DELETE FROM exp_sessions WHERE session_id = '".$this->EE->session->userdata['session_id']."'");
  1668. $this->EE->functions->set_cookie($this->EE->session->c_uniqueid);
  1669. $this->EE->functions->set_cookie($this->EE->session->c_password);
  1670. $this->EE->functions->set_cookie($this->EE->session->c_session);
  1671. $this->EE->functions->set_cookie($this->EE->session->c_expire);
  1672. $this->EE->functions->set_cookie($this->EE->session->c_anon);
  1673. $this->EE->functions->set_cookie('read_topics');
  1674. $this->EE->functions->set_cookie('tracker');
  1675. /** -------------------------------------
  1676. /** Update /** -------------------------------------*/
  1677. $this->EE->stats->update_member_stats();
  1678. /** -------------------------------------
  1679. /** Build Success Message
  1680. /** -------------------------------------*/
  1681. $url = $this->EE->config->item('site_url');
  1682. $name = stripslashes($this->EE->config->item('site_name'));
  1683. $data = array( 'title' => $this->EE->lang->line('mbr_delete'),
  1684. 'heading' => $this->EE->lang->line('thank_you'),
  1685. 'content' => $this->EE->lang->line('mbr_account_deleted'),
  1686. 'redirect' => '',
  1687. 'link' => array($url, $name)
  1688. );
  1689. $this->EE->output->show_message($data);
  1690. }
  1691. /** -----------------------------------
  1692. /** Login Page
  1693. /** -----------------------------------*/
  1694. function login()
  1695. {
  1696. return $this->profile_login_form();
  1697. }
  1698. /** ----------------------------------------
  1699. /** Manual Login Form
  1700. /** ----------------------------------------*/
  1701. // This lets users create a stand-alone login form in any template
  1702. function login_form()
  1703. {
  1704. if ($this->EE->config->item('user_session_type') != 'c')
  1705. {
  1706. $this->EE->TMPL->tagdata = preg_replace("/{if\s+auto_login}.*?{".'\/'."if}/s", '', $this->EE->TMPL->tagdata);
  1707. }
  1708. else
  1709. {
  1710. $this->EE->TMPL->tagdata = preg_replace("/{if\s+auto_login}(.*?){".'\/'."if}/s", "\\1", $this->EE->TMPL->tagdata);
  1711. }
  1712. /** ----------------------------------------
  1713. /** Create form
  1714. /** ----------------------------------------*/
  1715. $data['hidden_fields'] = array(
  1716. 'ACT' => $this->EE->functions->fetch_action_id('Member', 'member_login'),
  1717. 'RET' => ($this->EE->TMPL->fetch_param('return') && $this->EE->TMPL->fetch_param('return') != "") ? $this->EE->TMPL->fetch_param('return') : '-2'
  1718. );
  1719. if ($this->EE->TMPL->fetch_param('name') !== FALSE &&
  1720. preg_match("#^[a-zA-Z0-9_\-]+$#i", $this->EE->TMPL->fetch_param('name'), $match))
  1721. {
  1722. $data['name'] = $this->EE->TMPL->fetch_param('name');
  1723. }
  1724. if ($this->EE->TMPL->fetch_param('id') !== FALSE &&
  1725. preg_match("#^[a-zA-Z0-9_\-]+$#i", $this->EE->TMPL->fetch_param('id'), $match))
  1726. {
  1727. $data['id'] = $this->EE->TMPL->fetch_param('id');
  1728. }
  1729. $res = $this->EE->functions->form_declaration($data);
  1730. $res .= stripslashes($this->EE->TMPL->tagdata);
  1731. $res .= "</form>";
  1732. return $res;
  1733. }
  1734. /** ----------------------------------
  1735. /** Username/password update
  1736. /** ----------------------------------*/
  1737. function unpw_update()
  1738. {
  1739. if ( ! class_exists('Member_settings'))
  1740. {
  1741. require PATH_MOD.'member/mod.member_settings.php';
  1742. }
  1743. $MS = new Member_settings();
  1744. if (is_php('5.0.0') == TRUE)
  1745. {
  1746. foreach(get_object_vars($this) as $key => $value)
  1747. {
  1748. $MS->{$key} = $value;
  1749. }
  1750. }
  1751. else
  1752. {
  1753. // sync everything since PHP4 was working from a copy
  1754. foreach (array_keys(get_object_vars($this)) as $attribute)
  1755. {
  1756. $MS->$attribute =& $this->$attribute;
  1757. }
  1758. }
  1759. return $MS->unpw_update();
  1760. }
  1761. /** ----------------------------------
  1762. /** Update the username/password
  1763. /** ----------------------------------*/
  1764. function update_un_pw()
  1765. {
  1766. if ( ! class_exists('Member_settings'))
  1767. {
  1768. require PATH_MOD.'member/mod.member_settings.php';
  1769. }
  1770. $MS = new Member_settings();
  1771. if (is_php('5.0.0') == TRUE)
  1772. {
  1773. foreach(get_object_vars($this) as $key => $value)
  1774. {
  1775. $MS->{$key} = $value;
  1776. }
  1777. }
  1778. else
  1779. {
  1780. // sync everything since PHP4 was working from a copy
  1781. foreach (array_keys(get_object_vars($this)) as $attribute)
  1782. {
  1783. $MS->$attribute =& $this->$attribute;
  1784. }
  1785. }
  1786. $MS->update_un_pw();
  1787. }
  1788. /** ----------------------------------
  1789. /** Member Email Form
  1790. /** ----------------------------------*/
  1791. function email_console()
  1792. {
  1793. if ( ! class_exists('Member_memberlist'))
  1794. {
  1795. require PATH_MOD.'member/mod.member_memberlist.php';
  1796. }
  1797. $MM = new Member_memberlist();
  1798. if (is_php('5.0.0') == TRUE)
  1799. {
  1800. foreach(get_object_vars($this) as $key => $value)
  1801. {
  1802. $MM->{$key} = $value;
  1803. }
  1804. }
  1805. else
  1806. {
  1807. // sync everything since PHP4 was working from a copy
  1808. foreach (array_keys(get_object_vars($this)) as $attribute)
  1809. {
  1810. $MM->$attribute =& $this->$attribute;
  1811. }
  1812. }
  1813. return $MM->email_console();
  1814. }
  1815. /** ----------------------------------
  1816. /** Send Member Email
  1817. /** ----------------------------------*/
  1818. function send_email()
  1819. {
  1820. if ( ! class_exists('Member_memberlist'))
  1821. {
  1822. require PATH_MOD.'member/mod.member_memberlist.php';
  1823. }
  1824. $MM = new Member_memberlist();
  1825. if (is_php('5.0.0') == TRUE)
  1826. {
  1827. foreach(get_object_vars($this) as $key => $value)
  1828. {
  1829. $MM->{$key} = $value;
  1830. }
  1831. }
  1832. else
  1833. {
  1834. // sync everything since PHP4 was working from a copy
  1835. foreach (array_keys(get_object_vars($this)) as $attribute)
  1836. {
  1837. $MM->$attribute =& $this->$attribute;
  1838. }
  1839. }
  1840. return $MM->send_email();
  1841. }
  1842. /** ----------------------------------
  1843. /** AIM Console
  1844. /** ----------------------------------*/
  1845. function aim_console()
  1846. {
  1847. if ( ! class_exists('Member_memberlist'))
  1848. {
  1849. require PATH_MOD.'member/mod.member_memberlist.php';
  1850. }
  1851. $MM = new Member_memberlist();
  1852. if (is_php('5.0.0') == TRUE)
  1853. {
  1854. foreach(get_object_vars($this) as $key => $value)
  1855. {
  1856. $MM->{$key} = $value;
  1857. }
  1858. }
  1859. else
  1860. {
  1861. // sync everything since PHP4 was working from a copy
  1862. foreach (array_keys(get_object_vars($this)) as $attribute)
  1863. {
  1864. $MM->$attribute =& $this->$attribute;
  1865. }
  1866. }
  1867. return $MM->aim_console();
  1868. }
  1869. /** ----------------------------------
  1870. /** ICQ Console
  1871. /** ----------------------------------*/
  1872. function icq_console()
  1873. {
  1874. if ( ! class_exists('Member_memberlist'))
  1875. {
  1876. require PATH_MOD.'member/mod.member_memberlist.php';
  1877. }
  1878. $MM = new Member_memberlist();
  1879. if (is_php('5.0.0') == TRUE)
  1880. {
  1881. foreach(get_object_vars($this) as $key => $value)
  1882. {
  1883. $MM->{$key} = $value;
  1884. }
  1885. }
  1886. else
  1887. {
  1888. // sync everything since PHP4 was working from a copy
  1889. foreach (array_keys(get_object_vars($this)) as $attribute)
  1890. {
  1891. $MM->$attribute =& $this->$attribute;
  1892. }
  1893. }
  1894. return $MM->icq_console();
  1895. }
  1896. /** ----------------------------------------
  1897. /** Member List
  1898. /** ----------------------------------------*/
  1899. function memberlist()
  1900. {
  1901. if ( ! class_exists('Member_memberlist'))
  1902. {
  1903. require PATH_MOD.'member/mod.member_memberlist.php';
  1904. }
  1905. $MM = new Member_memberlist();
  1906. if (is_php('5.0.0') == TRUE)
  1907. {
  1908. foreach(get_object_vars($this) as $key => $value)
  1909. {
  1910. $MM->{$key} = $value;
  1911. }
  1912. }
  1913. else
  1914. {
  1915. // sync everything since PHP4 was working from a copy
  1916. foreach (array_keys(get_object_vars($this)) as $attribute)
  1917. {
  1918. $MM->$attribute =& $this->$attribute;
  1919. }
  1920. }
  1921. return $MM->memberlist();
  1922. }
  1923. /** ----------------------------------------
  1924. /** Member Search Results
  1925. /** ----------------------------------------*/
  1926. function member_search()
  1927. {
  1928. if ( ! class_exists('Member_memberlist'))
  1929. {
  1930. require PATH_MOD.'member/mod.member_memberlist.php';
  1931. }
  1932. $MM = new Member_memberlist();
  1933. if (is_php('5.0.0') == TRUE)
  1934. {
  1935. foreach(get_object_vars($this) as $key => $value)
  1936. {
  1937. $MM->{$key} = $value;
  1938. }
  1939. }
  1940. else
  1941. {
  1942. // sync everything since PHP4 was working from a copy
  1943. foreach (array_keys(get_object_vars($this)) as $attribute)
  1944. {
  1945. $MM->$attribute =& $this->$attribute;
  1946. }
  1947. }
  1948. return $MM->memberlist();
  1949. }
  1950. /** ----------------------------------------
  1951. /** Do A Member Search
  1952. /** ----------------------------------------*/
  1953. function do_member_search()
  1954. {
  1955. if ( ! class_exists('Member_memberlist'))
  1956. {
  1957. require PATH_MOD.'member/mod.member_memberlist.php';
  1958. }
  1959. $MM = new Member_memberlist();
  1960. if (is_php('5.0.0') == TRUE)
  1961. {
  1962. foreach(get_object_vars($this) as $key => $value)
  1963. {
  1964. $MM->{$key} = $value;
  1965. }
  1966. }
  1967. else
  1968. {
  1969. // sync everything since PHP4 was working from a copy
  1970. foreach (array_keys(get_object_vars($this)) as $attribute)
  1971. {
  1972. $MM->$attribute =& $this->$attribute;
  1973. }
  1974. }
  1975. return $MM->do_member_search();
  1976. }
  1977. /** -----------------------------------------------------------
  1978. /** Emoticons
  1979. /** -----------------------------------------------------------*/
  1980. function smileys()
  1981. {
  1982. if ($this->EE->session->userdata('member_id') == 0)
  1983. {
  1984. return $this->EE->output->fatal_error($this->EE->lang->line('must_be_logged_in'));
  1985. }
  1986. $class_path = PATH_MOD.'emoticon/emoticons'.EXT;
  1987. if ( ! is_file($class_path) OR ! @include_once($class_path))
  1988. {
  1989. return $this->EE->output->fatal_error('Unable to locate the smiley images');
  1990. }
  1991. if ( ! is_array($smileys))
  1992. {
  1993. return;
  1994. }
  1995. $path = $this->EE->config->slash_item('emoticon_path');
  1996. ob_start();
  1997. ?>
  1998. <script type="text/javascript">
  1999. <!--
  2000. function add_smiley(smiley)
  2001. {
  2002. var el = opener.document.getElementById('submit_post').body;
  2003. if ('selectionStart' in el) {
  2004. newStart = el.selectionStart + smiley.length;
  2005. el.value = el.value.substr(0, el.selectionStart) +
  2006. smiley +
  2007. el.value.substr(el.selectionEnd, el.value.length);
  2008. el.setSelectionRange(newStart, newStart);
  2009. }
  2010. else if (opener.document.selection) {
  2011. opener.document.selection.createRange().text = text;
  2012. }
  2013. else {
  2014. el.value += " " + smiley + " ";
  2015. }
  2016. el.focus();
  2017. window.close();
  2018. }
  2019. //-->
  2020. </script>
  2021. <?php
  2022. $javascript = ob_get_contents();
  2023. ob_end_clean();
  2024. $r = $javascript;
  2025. $i = 1;
  2026. $dups = array();
  2027. foreach ($smileys as $key => $val)
  2028. {
  2029. if ($i == 1)
  2030. {
  2031. $r .= "<tr>\n";
  2032. }
  2033. if (in_array($smileys[$key]['0'], $dups))
  2034. continue;
  2035. $r .= "<td class='tableCellOne' align='center'><a href=\"#\" onclick=\"return add_smiley('".$key."');\"><img src=\"".$path.$smileys[$key]['0']."\" width=\"".$smileys[$key]['1']."\" height=\"".$smileys[$key]['2']."\" alt=\"".$smileys[$key]['3']."\" border=\"0\" /></a></td>\n";
  2036. $dups[] = $smileys[$key]['0'];
  2037. if ($i == 10)
  2038. {
  2039. $r .= "</tr>\n";
  2040. $i = 1;
  2041. }
  2042. else
  2043. {
  2044. $i++;
  2045. }
  2046. }
  2047. $r = rtrim($r);
  2048. if (substr($r, -5) != "</tr>")
  2049. {
  2050. $r .= "</tr>\n";
  2051. }
  2052. $this->_set_page_title($this->EE->lang->line('smileys'));
  2053. return str_replace('{include:smileys}', $r, $this->_load_element('emoticon_page'));
  2054. }
  2055. /** ----------------------------------------
  2056. /** Convet special characters
  2057. /** ----------------------------------------*/
  2058. function _convert_special_chars($str)
  2059. {
  2060. return str_replace(array('<', '>', '{', '}', '\'', '"', '?'), array('&lt;', '&gt;', '&#123;', '&#125;', '&apos;', '&quot;', '&#63;'), $str);
  2061. }
  2062. /** ----------------------------------
  2063. /** Parse the index template
  2064. /** ----------------------------------*/
  2065. function _parse_index_template($str)
  2066. {
  2067. $req = ($this->request == '') ? 'profile' : $this->request;
  2068. // We have to call this before putting it into the array
  2069. $breadcrumb = $this->breadcrumb();
  2070. return $this->_var_swap($this->EE->TMPL->tagdata,
  2071. array(
  2072. 'stylesheet' => "<style type='text/css'>\n\n".$this->_load_element('stylesheet')."\n\n</style>",
  2073. 'javascript' => $this->javascript,
  2074. 'heading' => $this->page_title,
  2075. 'breadcrumb' => $breadcrumb,
  2076. 'content' => $str,
  2077. 'copyright' => $this->_load_element('copyright')
  2078. )
  2079. );
  2080. }
  2081. /** ----------------------------------
  2082. /** Member Home Page
  2083. /** ----------------------------------*/
  2084. function _member_page($str)
  2085. {
  2086. $template = $this->_load_element('member_page');
  2087. if ($this->show_headings == TRUE)
  2088. {
  2089. $template = $this->_allow_if('show_headings', $template);
  2090. }
  2091. else
  2092. {
  2093. $template = $this->_deny_if('show_headings', $template);
  2094. }
  2095. // We have to call this before putting it into the array
  2096. $breadcrumb = $this->breadcrumb();
  2097. $header = $this->_load_element('html_header');
  2098. $css = $this->_load_element('stylesheet');
  2099. $header = str_replace('{include:stylesheet}', $css, $header);
  2100. $header = str_replace('{include:head_extra}', $this->head_extra, $header);
  2101. return $this->_var_swap($template,
  2102. array(
  2103. 'include:html_header' => $header,
  2104. 'include:page_header' => $this->_load_element('page_header'),
  2105. 'include:page_subheader' => $this->_load_element('page_subheader'),
  2106. 'include:member_manager' => $str,
  2107. 'include:breadcrumb' => $breadcrumb,
  2108. 'include:html_footer' => $this->_load_element('html_footer')
  2109. )
  2110. );
  2111. }
  2112. /** ----------------------------------
  2113. /** Load theme element
  2114. /** ----------------------------------*/
  2115. function _load_element($which)
  2116. {
  2117. if ($this->theme_path == '')
  2118. {
  2119. $theme = ($this->EE->config->item('member_theme') == '') ? 'default' : $this->EE->config->item('member_theme');
  2120. $this->theme_path = PATH_MBR_THEMES."{$theme}/";
  2121. }
  2122. if ( ! file_exists($this->theme_path.$which.'.html'))
  2123. {
  2124. $data = array( 'title' => $this->EE->lang->line('error'),
  2125. 'heading' => $this->EE->lang->line('general_error'),
  2126. 'content' => $this->EE->lang->line('nonexistent_page'),
  2127. 'redirect' => '',
  2128. 'link' => array($this->EE->config->item('site_url'), stripslashes($this->EE->config->item('site_name')))
  2129. );
  2130. return $this->EE->output->show_message($data, 0);
  2131. }
  2132. return $this->_prep_element(trim(file_get_contents($this->theme_path.$which.'.html')));
  2133. }
  2134. /** -------------------------------------
  2135. /** Trigger Error Template
  2136. /** -------------------------------------*/
  2137. function _trigger_error($heading, $message = '', $use_lang = TRUE)
  2138. {
  2139. return $this->_var_swap($this->_load_element('error'),
  2140. array(
  2141. 'lang:heading' => $this->EE->lang->line($heading),
  2142. 'lang:message' => ($use_lang == TRUE) ? $this->EE->lang->line($message) : $message
  2143. )
  2144. );
  2145. }
  2146. /** -------------------------------------
  2147. /** Sets the title of the page
  2148. /** -------------------------------------*/
  2149. function _set_page_title($title)
  2150. {
  2151. if ($this->page_title == '')
  2152. {
  2153. $this->page_title = $title;
  2154. }
  2155. }
  2156. /** ----------------------------------------
  2157. /** Member Breadcrumb
  2158. /** ----------------------------------------*/
  2159. function breadcrumb()
  2160. {
  2161. if ($this->breadcrumb == FALSE)
  2162. {
  2163. return '';
  2164. }
  2165. $crumbs = $this->_crumb_trail(
  2166. array(
  2167. 'link' => $this->EE->config->item('site_url'),
  2168. 'title' => stripslashes($this->EE->config->item('site_name'))
  2169. )
  2170. );
  2171. if ($this->EE->uri->segment(2) == '')
  2172. {
  2173. return $this->_build_crumbs($this->EE->lang->line('member_profile'), $crumbs, $this->EE->lang->line('member_profile'));
  2174. }
  2175. if ($this->EE->uri->segment(2) == 'messages')
  2176. {
  2177. $crumbs .= $this->_crumb_trail(array(
  2178. 'link' => $this->_member_path('/profile'),
  2179. 'title' => $this->EE->lang->line('control_panel_home')
  2180. )
  2181. );
  2182. $pm_page = (FALSE !== ($mbr_crumb = $this->_fetch_member_crumb($this->EE->uri->segment(3)))) ? $this->EE->lang->line($mbr_crumb) : $this->EE->lang->line('view_folder');
  2183. return $this->_build_crumbs($pm_page, $crumbs, $pm_page);
  2184. }
  2185. if (is_numeric($this->EE->uri->segment(2)))
  2186. {
  2187. $query = $this->EE->db->query("SELECT screen_name FROM exp_members WHERE member_id = '".$this->EE->uri->segment(2)."'");
  2188. $crumbs .= $this->_crumb_trail(array(
  2189. 'link' => $this->_member_path('/memberlist'),
  2190. 'title' => $this->EE->lang->line('mbr_memberlist')
  2191. )
  2192. );
  2193. return $this->_build_crumbs($query->row('screen_name') , $crumbs, $query->row('screen_name') );
  2194. }
  2195. else
  2196. {
  2197. if ($this->EE->uri->segment(2) == 'memberlist')
  2198. {
  2199. return $this->_build_crumbs($this->EE->lang->line('mbr_memberlist'), $crumbs, $this->EE->lang->line('mbr_memberlist'));
  2200. }
  2201. elseif ($this->EE->uri->segment(2) == 'member_search' OR $this->EE->uri->segment(2) == 'do_member_search')
  2202. {
  2203. return $this->_build_crumbs($this->EE->lang->line('member_search'), $crumbs, $this->EE->lang->line('member_search'));
  2204. }
  2205. elseif ($this->EE->uri->segment(2) != 'profile' AND ! in_array($this->EE->uri->segment(2), $this->no_menu))
  2206. {
  2207. $crumbs .= $this->_crumb_trail(array(
  2208. 'link' => $this->_member_path('/profile'),
  2209. 'title' => $this->EE->lang->line('control_panel_home')
  2210. )
  2211. );
  2212. }
  2213. }
  2214. if (FALSE !== ($mbr_crumb = $this->_fetch_member_crumb($this->EE->uri->segment(2))))
  2215. {
  2216. return $this->_build_crumbs($this->EE->lang->line($mbr_crumb), $crumbs, $this->EE->lang->line($mbr_crumb));
  2217. }
  2218. }
  2219. /** -------------------------------------
  2220. /** Breadcrumb trail links
  2221. /** -------------------------------------*/
  2222. function _crumb_trail($data)
  2223. {
  2224. $trail = $this->_load_element('breadcrumb_trail');
  2225. $crumbs = '';
  2226. $crumbs .= $this->_var_swap($trail,
  2227. array(
  2228. 'crumb_link' => $data['link'],
  2229. 'crumb_title' => $data['title']
  2230. )
  2231. );
  2232. return $crumbs;
  2233. }
  2234. /** -------------------------------------
  2235. /** Finalize the Crumbs
  2236. /** -------------------------------------*/
  2237. function _build_crumbs($title, $crumbs, $str)
  2238. {
  2239. $this->_set_page_title(($title == '') ? 'Powered By ExpressionEngine' : $title);
  2240. $crumbs .= str_replace('{crumb_title}', $str, $this->_load_element('breadcrumb_current_page'));
  2241. $breadcrumb = $this->_load_element('breadcrumb');
  2242. $breadcrumb = str_replace('{name}', $this->EE->session->userdata('screen_name'), $breadcrumb);
  2243. return str_replace('{breadcrumb_links}', $crumbs, $breadcrumb);
  2244. }
  2245. /** -------------------------------------
  2246. /** Fetch member profile crumb item
  2247. /** -------------------------------------*/
  2248. function _fetch_member_crumb($item = '')
  2249. {
  2250. if ($item == '')
  2251. return FALSE;
  2252. return ( ! isset($this->crumb_map[$item])) ? FALSE : $this->crumb_map[$item];
  2253. }
  2254. /** ----------------------------------------
  2255. /** Create the "year" pull-down menu
  2256. /** ----------------------------------------*/
  2257. function _birthday_year($year = '')
  2258. {
  2259. $r = "<select name='bday_y' class='select'>\n";
  2260. $selected = ($year == '') ? " selected='selected'" : '';
  2261. $r .= "<option value=''{$selected}>".$this->EE->lang->line('year')."</option>\n";
  2262. for ($i = date('Y', $this->EE->localize->now); $i > 1904; $i--)
  2263. {
  2264. $selected = ($year == $i) ? " selected='selected'" : '';
  2265. $r .= "<option value='{$i}'{$selected}>".$i."</option>\n";
  2266. }
  2267. $r .= "</select>\n";
  2268. return $r;
  2269. }
  2270. /** ----------------------------------------
  2271. /** Create the "month" pull-down menu
  2272. /** ----------------------------------------*/
  2273. function _birthday_month($month = '')
  2274. {
  2275. $months = array('01' => 'January','02' => 'February','03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
  2276. $r = "<select name='bday_m' class='select'>\n";
  2277. $selected = ($month == '') ? " selected='selected'" : '';
  2278. $r .= "<option value=''{$selected}>".$this->EE->lang->line('month')."</option>\n";
  2279. for ($i = 1; $i < 13; $i++)
  2280. {
  2281. if (strlen($i) == 1)
  2282. $i = '0'.$i;
  2283. $selected = ($month == $i) ? " selected='selected'" : '';
  2284. $r .= "<option value='{$i}'{$selected}>".$this->EE->lang->line($months[$i])."</option>\n";
  2285. }
  2286. $r .= "</select>\n";
  2287. return $r;
  2288. }
  2289. /** ----------------------------------------
  2290. /** Create the "day" pull-down menu
  2291. /** ----------------------------------------*/
  2292. function _birthday_day($day = '')
  2293. {
  2294. $r = "<select name='bday_d' class='select'>\n";
  2295. $selected = ($day == '') ? " selected='selected'" : '';
  2296. $r .= "<option value=''{$selected}>".$this->EE->lang->line('day')."</option>\n";
  2297. for ($i = 1; $i <= 31; $i++)
  2298. {
  2299. $selected = ($day == $i) ? " selected='selected'" : '';
  2300. $r .= "<option value='{$i}'{$selected}>".$i."</option>\n";
  2301. }
  2302. $r .= "</select>\n";
  2303. return $r;
  2304. }
  2305. /** -------------------------------------
  2306. /** Prep Element Data
  2307. /** -------------------------------------*/
  2308. // Right now we only use this to parse the logged-in/logged-out vars
  2309. function _prep_element($str)
  2310. {
  2311. if ($str == '')
  2312. return '';
  2313. if ($this->EE->session->userdata('member_id') == 0)
  2314. {
  2315. $str = $this->_deny_if('logged_in', $str);
  2316. $str = $this->_allow_if('logged_out', $str);
  2317. }
  2318. else
  2319. {
  2320. $str = $this->_allow_if('logged_in', $str);
  2321. $str = $this->_deny_if('logged_out', $str);
  2322. }
  2323. /** ----------------------------------------
  2324. /** Parse the forum conditional
  2325. /** ----------------------------------------*/
  2326. if ($this->EE->config->item('forum_is_installed') == "y")
  2327. {
  2328. $str = $this->_allow_if('forum_installed', $str);
  2329. }
  2330. else
  2331. {
  2332. $str = $this->_deny_if('forum_installed', $str);
  2333. }
  2334. /** -------------------------------------
  2335. /** Parse the self deletion conditional
  2336. /** -------------------------------------*/
  2337. if ($this->EE->session->userdata['can_delete_self'] == 'y' && $this->EE->session->userdata['group_id'] != 1)
  2338. {
  2339. $str = $this->_allow_if('can_delete', $str);
  2340. }
  2341. else
  2342. {
  2343. $str = $this->_deny_if('can_delete', $str);
  2344. }
  2345. return $str;
  2346. }
  2347. /** ----------------------------------
  2348. /** Finalize a few things
  2349. /** ----------------------------------*/
  2350. function _final_prep($str)
  2351. {
  2352. /** ------------------------------
  2353. /** Which mode are we in?
  2354. /** ------------------------------*/
  2355. // This class can either be run in "stand-alone" mode or through the template engine.
  2356. $template_parser = FALSE;
  2357. if (class_exists('Template'))
  2358. {
  2359. if ($this->EE->TMPL->tagdata != '')
  2360. {
  2361. $str = $this->_parse_index_template($str);
  2362. $template_parser = TRUE;
  2363. $this->EE->TMPL->disable_caching = TRUE;
  2364. }
  2365. }
  2366. if ($template_parser == FALSE AND $this->in_forum == FALSE)
  2367. {
  2368. $str = $this->_member_page($str);
  2369. }
  2370. /** ----------------------------------------
  2371. /** Parse the language text
  2372. /** ----------------------------------------*/
  2373. if (preg_match_all("/{lang:(.+?)\}/i", $str, $matches))
  2374. {
  2375. for ($j = 0; $j < count($matches['0']); $j++)
  2376. {
  2377. $line = ($this->EE->lang->line($matches['1'][$j]) == $matches['1'][$j]) ? $this->EE->lang->line('mbr_'.$matches['1'][$j]) : $this->EE->lang->line($matches['1'][$j]);
  2378. $str = str_replace($matches['0'][$j], $line, $str);
  2379. }
  2380. }
  2381. /** ----------------------------------------
  2382. /** Parse old style path variables
  2383. /** ----------------------------------------*/
  2384. // This is here for backward compatibility for people with older templates
  2385. $str = preg_replace_callback("/".LD."\s*path=(.*?)".RD."/", array(&$this->EE->functions, 'create_url'), $str);
  2386. if (preg_match_all("#".LD."\s*(profile_path\s*=.*?)".RD."#", $str, $matches))
  2387. {
  2388. $i = 0;
  2389. foreach ($matches['1'] as $val)
  2390. {
  2391. $path = $this->EE->functions->create_url($this->EE->functions->extract_path($val).'/'.$this->EE->session->userdata['member_id']);
  2392. $str = preg_replace("#".$matches['0'][$i++]."#", $path, $str, 1);
  2393. }
  2394. }
  2395. // -------
  2396. /** ----------------------------------------
  2397. /** Set some paths
  2398. /** ----------------------------------------*/
  2399. $theme_images = $this->EE->config->slash_item('theme_folder_url', 1).'profile_themes/'.$this->EE->config->item('member_theme').'/images/';
  2400. if ($this->EE->session->userdata('profile_theme') != '')
  2401. {
  2402. $img_path = $this->EE->config->slash_item('theme_folder_url').'profile_themes/'.$this->EE->session->userdata('profile_theme').'/images/';
  2403. }
  2404. else
  2405. {
  2406. $img_path = $this->EE->config->slash_item('theme_folder_url', 1).'profile_themes/'.$this->EE->config->item('member_theme').'/images/';
  2407. }
  2408. $simple = ($this->show_headings == FALSE) ? '/simple' : '';
  2409. if ($this->css_file_path == '')
  2410. {
  2411. $this->css_file_path = $this->EE->config->slash_item('theme_folder_url', 1).'profile_themes/'.$this->EE->config->item('member_theme').'profile.css';
  2412. }
  2413. /** ----------------------------------------
  2414. /** Parse {switch="foo|bar"} variables
  2415. /** ----------------------------------------*/
  2416. if (preg_match_all("/".LD."(switch\s*=.+?)".RD."/i", $str, $matches, PREG_SET_ORDER))
  2417. {
  2418. foreach ($matches as $match)
  2419. {
  2420. $sparam = $this->EE->functions->assign_parameters($match[1]);
  2421. if (isset($sparam['switch']))
  2422. {
  2423. $sopt = explode("|", $sparam['switch']);
  2424. $i = 1;
  2425. while (($pos = strpos($str, LD.$match[1].RD)) !== FALSE)
  2426. {
  2427. $str = substr_replace($str, $sopt[($i++ + count($sopt) - 1) % count($sopt)], $pos, strlen(LD.$match[1].RD));
  2428. }
  2429. }
  2430. }
  2431. }
  2432. /** ----------------------------------------
  2433. /** Finalize the output
  2434. /** ----------------------------------------*/
  2435. $str = $this->EE->functions->prep_conditionals($str, array('current_request' => $this->request));
  2436. $str = $this->_var_swap($str,
  2437. array(
  2438. 'lang' => $this->EE->config->item('xml_lang'),
  2439. 'charset' => $this->EE->config->item('output_charset'),
  2440. 'path:image_url' => ($this->image_url == '') ? $theme_images : $this->image_url,
  2441. 'path:your_control_panel' => $this->_member_path('profile'),
  2442. 'path:your_profile' => $this->_member_path($this->EE->session->userdata('member_id')),
  2443. 'path:edit_preferences' => $this->_member_path('edit_preferences'),
  2444. 'path:register' => $this->_member_path('register'.$simple),
  2445. 'path:private_messages' => $this->_member_path('messages'),
  2446. 'path:memberlist' => $this->_member_path('memberlist'),
  2447. 'path:signature' => $this->_member_path('edit_signature'),
  2448. 'path:avatar' => $this->_member_path('edit_avatar'),
  2449. 'path:photo' => $this->_member_path('edit_photo'),
  2450. 'path:smileys' => $this->_member_path('smileys'),
  2451. 'path:forgot' => $this->_member_path('forgot_password'.$simple),
  2452. 'path:login' => $this->_member_path('login'.$simple),
  2453. 'path:delete' => $this->_member_path('delete'),
  2454. 'page_title' => $this->page_title,
  2455. 'site_name' => stripslashes($this->EE->config->item('site_name')),
  2456. 'path:theme_css' => $this->css_file_path,
  2457. 'current_request' => $this->request
  2458. )
  2459. );
  2460. // parse regular global vars
  2461. $this->EE->load->library('template', NULL, 'TMPL');
  2462. // load up any Snippets
  2463. $this->EE->db->select('snippet_name, snippet_contents');
  2464. $this->EE->db->where('(site_id = '.$this->EE->db->escape_str($this->EE->config->item('site_id')).' OR site_id = 0)');
  2465. $fresh = $this->EE->db->get('snippets');
  2466. if ($fresh->num_rows() > 0)
  2467. {
  2468. $snippets = array();
  2469. foreach ($fresh->result() as $var)
  2470. {
  2471. $snippets[$var->snippet_name] = $var->snippet_contents;
  2472. }
  2473. $this->EE->config->_global_vars = array_merge($this->EE->config->_global_vars, $snippets);
  2474. unset($snippets);
  2475. unset($fresh);
  2476. }
  2477. $this->EE->TMPL->parse($str);
  2478. $str = $this->EE->TMPL->parse_globals($this->EE->TMPL->final_template);
  2479. // Add security hashes to forms
  2480. if ( ! class_exists('Template'))
  2481. {
  2482. $str = $this->EE->functions->insert_action_ids($this->EE->functions->add_form_security_hash($str));
  2483. }
  2484. $str = preg_replace("/".LD."if\s+.*?".RD.".*?".LD.'\/if'.RD."/s", "", $str);
  2485. return $str;
  2486. }
  2487. /** ----------------------------------
  2488. /** Set base values of class vars
  2489. /** ----------------------------------*/
  2490. function _set_properties($props = array())
  2491. {
  2492. if (count($props) > 0)
  2493. {
  2494. foreach ($props as $key => $val)
  2495. {
  2496. $this->$key = $val;
  2497. }
  2498. }
  2499. }
  2500. /** ----------------------------------------
  2501. /** Sets the member basepath
  2502. /** ----------------------------------------*/
  2503. function _member_set_basepath()
  2504. {
  2505. $this->basepath = $this->EE->functions->create_url($this->trigger);
  2506. }
  2507. /** ----------------------------------------
  2508. /** Compiles a path string
  2509. /** ----------------------------------------*/
  2510. function _member_path($uri = '')
  2511. {
  2512. if ($this->basepath == '')
  2513. {
  2514. $this->_member_set_basepath();
  2515. }
  2516. return $this->EE->functions->remove_double_slashes($this->basepath.'/'.$uri);
  2517. }
  2518. /** -------------------------------------
  2519. /** Helpers for "if" conditions
  2520. /** -------------------------------------*/
  2521. function _deny_if($cond, $str, $replace = '')
  2522. {
  2523. return preg_replace("/\{if\s+".$cond."\}.+?\{\/if\}/si", $replace, $str);
  2524. }
  2525. function _allow_if($cond, $str)
  2526. {
  2527. return preg_replace("/\{if\s+".$cond."\}(.+?)\{\/if\}/si", "\\1", $str);
  2528. }
  2529. /** ----------------------------------------
  2530. /** Replace variables
  2531. /** ----------------------------------------*/
  2532. function _var_swap($str, $data)
  2533. {
  2534. if ( ! is_array($data))
  2535. {
  2536. return FALSE;
  2537. }
  2538. foreach ($data as $key => $val)
  2539. {
  2540. $str = str_replace('{'.$key.'}', $val, $str);
  2541. }
  2542. return $str;
  2543. }
  2544. /** ---------------------------------------
  2545. /** Swap single variables with final value
  2546. /** ---------------------------------------*/
  2547. function _var_swap_single($search, $replace, $source)
  2548. {
  2549. return str_replace(LD.$search.RD, $replace, $source);
  2550. }
  2551. /** ----------------------------------------
  2552. /** Custom Member Profile Data
  2553. /** ----------------------------------------*/
  2554. function custom_profile_data()
  2555. {
  2556. $member_id = ( ! $this->EE->TMPL->fetch_param('member_id')) ? $this->EE->session->userdata['member_id'] : $this->EE->TMPL->fetch_param('member_id');
  2557. /** ----------------------------------------
  2558. /** Default Member Data
  2559. /** ----------------------------------------*/
  2560. $this->EE->db->select('m.member_id, m.group_id, m.username, m.screen_name, m.email, m.signature,
  2561. m.avatar_filename, m.avatar_width, m.avatar_height,
  2562. m.photo_filename, m.photo_width, m.photo_height,
  2563. m.url, m.location, m.occupation, m.interests,
  2564. m.bio,
  2565. m.join_date, m.last_visit, m.last_activity, m.last_entry_date, m.last_comment_date,
  2566. m.last_forum_post_date, m.total_entries, m.total_comments, m.total_forum_topics, m.total_forum_posts,
  2567. m.language, m.timezone, m.daylight_savings, m.bday_d, m.bday_m, m.bday_y,
  2568. g.group_title');
  2569. $this->EE->db->from(array('members m', 'member_groups g'));
  2570. $this->EE->db->where('m.member_id', $member_id);
  2571. $this->EE->db->where('g.site_id', $this->EE->config->item('site_id'));
  2572. $this->EE->db->where('m.group_id = g.group_id');
  2573. $query = $this->EE->db->get();
  2574. if ($query->num_rows() == 0)
  2575. {
  2576. return $this->EE->TMPL->tagdata = '';
  2577. }
  2578. $default_fields = $query->row_array();
  2579. /** ----------------------------------------
  2580. /** Is there an avatar?
  2581. /** ----------------------------------------*/
  2582. if ($this->EE->config->item('enable_avatars') == 'y' AND $query->row('avatar_filename') != '')
  2583. {
  2584. $avatar_path = $this->EE->config->item('avatar_url').$query->row('avatar_filename');
  2585. $avatar_width = $query->row('avatar_width');
  2586. $avatar_height = $query->row('avatar_height');
  2587. $avatar = 'TRUE';
  2588. }
  2589. else
  2590. {
  2591. $avatar_path = '';
  2592. $avatar_width = '';
  2593. $avatar_height = '';
  2594. $avatar = 'FALSE';
  2595. }
  2596. /** ----------------------------------------
  2597. /** Is there a member photo?
  2598. /** ----------------------------------------*/
  2599. if ($this->EE->config->item('enable_photos') == 'y' AND $query->row('photo_filename') != '')
  2600. {
  2601. $photo_path = $this->EE->config->item('photo_url').$query->row('photo_filename');
  2602. $photo_width = $query->row('photo_width');
  2603. $photo_height = $query->row('photo_height');
  2604. $photo = 'TRUE';
  2605. }
  2606. else
  2607. {
  2608. $photo_path = '';
  2609. $photo_width = '';
  2610. $photo_height = '';
  2611. $photo = 'FALSE';
  2612. }
  2613. /** ----------------------------------------
  2614. /** Is there a signature image?
  2615. /** ----------------------------------------*/
  2616. if ($this->EE->config->item('enable_signatures') == 'y' AND $query->row('sig_img_filename') != '')
  2617. {
  2618. $sig_img_path = $this->EE->config->item('sig_img_url').$query->row('sig_img_filename');
  2619. $sig_img_width = $query->row('sig_img_width');
  2620. $sig_img_height = $query->row('sig_img_height');
  2621. $sig_img_image = 'TRUE';
  2622. }
  2623. else
  2624. {
  2625. $sig_img_path = '';
  2626. $sig_img_width = '';
  2627. $sig_img_height = '';
  2628. $sig_img = 'FALSE';
  2629. }
  2630. /** ----------------------------------------
  2631. /** Parse variables
  2632. /** ----------------------------------------*/
  2633. if ($this->in_forum == TRUE)
  2634. {
  2635. $search_path = $this->forum_path.'member_search/'.$this->cur_id.'/';
  2636. }
  2637. else
  2638. {
  2639. $search_path = $this->EE->functions->fetch_site_index(0, 0).QUERY_MARKER.'ACT='.$this->EE->functions->fetch_action_id('Search', 'do_search').'&amp;mbr='.urlencode($query->row('member_id'));
  2640. }
  2641. $more_fields = array(
  2642. 'send_private_message' => $this->_member_path('messages/pm/'.$member_id),
  2643. 'search_path' => $search_path,
  2644. 'avatar_url' => $avatar_path,
  2645. 'avatar_filename' => $query->row('avatar_filename'),
  2646. 'avatar_width' => $avatar_width,
  2647. 'avatar_height' => $avatar_height,
  2648. 'photo_url' => $photo_path,
  2649. 'photo_filename' => $query->row('photo_filename'),
  2650. 'photo_width' => $photo_width,
  2651. 'photo_height' => $photo_height,
  2652. 'signature_image_url' => $sig_img_path,
  2653. 'signature_image_filename' => $query->row('sig_img_filename'),
  2654. 'signature_image_width' => $sig_img_width,
  2655. 'signature_image_height' => $sig_img_height
  2656. );
  2657. $default_fields = array_merge($default_fields, $more_fields);
  2658. /** ----------------------------------------
  2659. /** Fetch the custom member field definitions
  2660. /** ----------------------------------------*/
  2661. $fields = array();
  2662. $this->EE->db->select('m_field_id, m_field_name, m_field_fmt');
  2663. $query = $this->EE->db->get('member_fields');
  2664. if ($query->num_rows() > 0)
  2665. {
  2666. foreach ($query->result_array() as $row)
  2667. {
  2668. $fields[$row['m_field_name']] = array($row['m_field_id'], $row['m_field_fmt']);
  2669. }
  2670. }
  2671. $this->EE->db->where('member_id', $member_id);
  2672. $query = $this->EE->db->get('member_data');
  2673. if ($query->num_rows() == 0)
  2674. {
  2675. foreach ($fields as $key => $val)
  2676. {
  2677. $this->EE->TMPL->tagdata = $this->EE->TMPL->swap_var_single($key, '', $this->EE->TMPL->tagdata);
  2678. }
  2679. return $this->EE->TMPL->tagdata;
  2680. }
  2681. $this->EE->load->library('typography');
  2682. $this->EE->typography->initialize();
  2683. $cond = $default_fields;
  2684. foreach ($query->result_array() as $row)
  2685. {
  2686. $cond['avatar'] = $avatar;
  2687. $cond['photo'] = $photo;
  2688. foreach($fields as $key => $value)
  2689. {
  2690. $cond[$key] = $this->EE->typography->parse_type($row['m_field_id_'.$value['0']],
  2691. array(
  2692. 'text_format' => $value['1'],
  2693. 'html_format' => 'safe',
  2694. 'auto_links' => 'y',
  2695. 'allow_img_url' => 'n'
  2696. )
  2697. );
  2698. }
  2699. $this->EE->TMPL->tagdata = $this->EE->functions->prep_conditionals($this->EE->TMPL->tagdata, $cond);
  2700. /** ----------------------------------------
  2701. /** Swap Variables
  2702. /** ----------------------------------------*/
  2703. foreach ($this->EE->TMPL->var_single as $key => $val)
  2704. {
  2705. /** ----------------------------------------
  2706. /** parse default member data
  2707. /** ----------------------------------------*/
  2708. // Format URLs
  2709. if ($key == 'url')
  2710. {
  2711. if (substr($default_fields['url'], 0, 4) != "http" && strpos($default_fields['url'], '://') === FALSE)
  2712. {
  2713. $default_fields['url'] = "http://".$default_fields['url'];
  2714. }
  2715. }
  2716. // "last_visit"
  2717. if (strncmp($key, 'last_visit', 10) == 0)
  2718. {
  2719. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, ($default_fields['last_visit'] > 0) ? $this->EE->localize->decode_date($val, $default_fields['last_visit']) : '', $this->EE->TMPL->tagdata);
  2720. }
  2721. // "last_activity"
  2722. if (strncmp($key, 'last_activity', 10) == 0)
  2723. {
  2724. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, ($default_fields['last_activity'] > 0) ? $this->EE->localize->decode_date($val, $default_fields['last_activity']) : '', $this->EE->TMPL->tagdata);
  2725. }
  2726. // "join_date"
  2727. if (strncmp($key, 'join_date', 9) == 0)
  2728. {
  2729. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, ($default_fields['join_date'] > 0) ? $this->EE->localize->decode_date($val, $default_fields['join_date']) : '', $this->EE->TMPL->tagdata);
  2730. }
  2731. // "last_entry_date"
  2732. if (strncmp($key, 'last_entry_date', 15) == 0)
  2733. {
  2734. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, ($default_fields['last_entry_date'] > 0) ? $this->EE->localize->decode_date($val, $default_fields['last_entry_date']) : '', $this->EE->TMPL->tagdata);
  2735. }
  2736. // "last_forum_post_date"
  2737. if (strncmp($key, 'last_forum_post_date', 20) == 0)
  2738. {
  2739. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, ($default_fields['last_forum_post_date'] > 0) ? $this->EE->localize->decode_date($val, $default_fields['last_forum_post_date']) : '', $this->EE->TMPL->tagdata);
  2740. }
  2741. // parse "recent_comment"
  2742. if (strncmp($key, 'last_comment_date', 17) == 0)
  2743. {
  2744. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, ($default_fields['last_comment_date'] > 0) ? $this->EE->localize->decode_date($val, $default_fields['last_comment_date']) : '', $this->EE->TMPL->tagdata);
  2745. }
  2746. // {name}
  2747. $name = ( ! $default_fields['screen_name']) ? $default_fields['username'] : $default_fields['screen_name'];
  2748. $name = $this->_convert_special_chars($name);
  2749. if ($key == "name")
  2750. {
  2751. $this->EE->TMPL->tagdata = $this->_var_swap_single($val, $name, $this->EE->TMPL->tagdata);
  2752. }
  2753. // {member_group}
  2754. if ($key == "member_group")
  2755. {
  2756. $this->EE->TMPL->tagdata = $this->_var_swap_single($val, $default_fields['group_title'], $this->EE->TMPL->tagdata);
  2757. }
  2758. // {email}
  2759. if ($key == "email")
  2760. {
  2761. $this->EE->TMPL->tagdata = $this->_var_swap_single($val, $this->EE->typography->encode_email($default_fields['email']), $this->EE->TMPL->tagdata);
  2762. }
  2763. // {birthday}
  2764. if ($key == "birthday")
  2765. {
  2766. $birthday = '';
  2767. if ($default_fields['bday_m'] != '' AND $default_fields['bday_m'] != 0)
  2768. {
  2769. $month = (strlen($default_fields['bday_m']) == 1) ? '0'.$default_fields['bday_m'] : $default_fields['bday_m'];
  2770. $m = $this->EE->localize->localize_month($month);
  2771. $birthday .= $this->EE->lang->line($m['1']);
  2772. if ($default_fields['bday_d'] != '' AND $default_fields['bday_d'] != 0)
  2773. {
  2774. $birthday .= ' '.$default_fields['bday_d'];
  2775. }
  2776. }
  2777. if ($default_fields['bday_y'] != '' AND $default_fields['bday_y'] != 0)
  2778. {
  2779. if ($birthday != '')
  2780. {
  2781. $birthday .= ', ';
  2782. }
  2783. $birthday .= $default_fields['bday_y'];
  2784. }
  2785. if ($birthday == '')
  2786. {
  2787. $birthday = '';
  2788. }
  2789. $this->EE->TMPL->tagdata = $this->_var_swap_single($val, $birthday, $this->EE->TMPL->tagdata);
  2790. }
  2791. // {timezone}
  2792. if ($key == "timezone")
  2793. {
  2794. $timezone = ($default_fields['timezone'] != '') ? $this->EE->lang->line($default_fields['timezone']) : '';
  2795. $this->EE->TMPL->tagdata = $this->_var_swap_single($val, $timezone, $this->EE->TMPL->tagdata);
  2796. }
  2797. // {local_time}
  2798. if (strncmp($key, 'local_time', 10) == 0)
  2799. {
  2800. $time = $this->EE->localize->now;
  2801. if ($this->EE->session->userdata('member_id') != $this->cur_id)
  2802. {
  2803. // Default is UTC?
  2804. $zone = ($default_fields['timezone'] == '') ? 'UTC' : $default_fields['timezone'];
  2805. $time = $this->EE->localize->set_localized_time($time, $zone, $default_fields['daylight_savings']);
  2806. }
  2807. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, $this->EE->localize->decode_date($val, $time), $this->EE->TMPL->tagdata);
  2808. }
  2809. // {bio}
  2810. if ($key == 'bio')
  2811. {
  2812. $bio = $this->EE->typography->parse_type($default_fields[$val],
  2813. array(
  2814. 'text_format' => 'xhtml',
  2815. 'html_format' => 'safe',
  2816. 'auto_links' => 'y',
  2817. 'allow_img_url' => 'n'
  2818. )
  2819. );
  2820. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, $bio, $this->EE->TMPL->tagdata);
  2821. }
  2822. // Special condideration for {total_forum_replies}, and
  2823. // {total_forum_posts} whose meanings do not match the
  2824. // database field names
  2825. if ($key == 'total_forum_replies')
  2826. {
  2827. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, $default_fields['total_forum_posts'], $this->EE->TMPL->tagdata);
  2828. }
  2829. if ($key == 'total_forum_posts')
  2830. {
  2831. $total_posts = $default_fields['total_forum_topics'] + $default_fields['total_forum_posts'];
  2832. $this->EE->TMPL->tagdata = $this->_var_swap_single($key, $total_posts, $this->EE->TMPL->tagdata);
  2833. }
  2834. /** ----------------------------------------
  2835. /** parse basic fields (username, screen_name, etc.)
  2836. /** ----------------------------------------*/
  2837. if (array_key_exists($key, $default_fields))
  2838. {
  2839. $this->EE->TMPL->tagdata = $this->_var_swap_single($val, $default_fields[$val], $this->EE->TMPL->tagdata);
  2840. }
  2841. /** ----------------------------------------
  2842. /** parse custom member fields
  2843. /** ----------------------------------------*/
  2844. if (isset($fields[$val]) && array_key_exists('m_field_id_'.$fields[$val]['0'], $row))
  2845. {
  2846. $this->EE->TMPL->tagdata = $this->EE->TMPL->swap_var_single(
  2847. $val,
  2848. $this->EE->typography->parse_type(
  2849. $row['m_field_id_'.$fields[$val]['0']],
  2850. array(
  2851. 'text_format' => $fields[$val]['1'],
  2852. 'html_format' => 'safe',
  2853. 'auto_links' => 'y',
  2854. 'allow_img_url' => 'n'
  2855. )
  2856. ),
  2857. $this->EE->TMPL->tagdata
  2858. );
  2859. }
  2860. //else { echo 'm_field_id_'.$fields[$val]['0']; }
  2861. }
  2862. }
  2863. return $this->EE->TMPL->tagdata;
  2864. }
  2865. /** -------------------------------------
  2866. /** Ignore List
  2867. /** -------------------------------------*/
  2868. function ignore_list()
  2869. {
  2870. $pre = 'ignore_';
  2871. $prelen = strlen($pre);
  2872. if ($member_id = $this->EE->TMPL->fetch_param('member_id'))
  2873. {
  2874. $query = $this->EE->db->query("SELECT ignore_list FROM exp_members WHERE member_id = '{$member_id}'");
  2875. if ($query->num_rows() == 0)
  2876. {
  2877. return $this->EE->TMPL->no_results();
  2878. }
  2879. $ignored = ($query->row('ignore_list') == '') ? array() : explode('|', $query->row('ignore_list') );
  2880. }
  2881. else
  2882. {
  2883. $ignored = $this->EE->session->userdata['ignore_list'];
  2884. }
  2885. $query = $this->EE->db->query("SELECT m.member_id, m.group_id, m.username, m.screen_name, m.email, m.ip_address, m.location, m.total_entries, m.total_comments, m.private_messages, m.total_forum_topics, m.total_forum_posts AS total_forum_replies, m.total_forum_topics + m.total_forum_posts AS total_forum_posts,
  2886. g.group_title AS group_description FROM exp_members AS m, exp_member_groups AS g
  2887. WHERE g.group_id = m.group_id
  2888. g.site_id = '".$this->EE->db->escape_str($this->EE->config->item('site_id'))."'
  2889. AND m.member_id IN ('".implode("', '", $ignored)."')");
  2890. if ($query->num_rows() == 0)
  2891. {
  2892. return $this->EE->TMPL->no_results();
  2893. }
  2894. $tagdata = $this->EE->TMPL->tagdata;
  2895. $out = '';
  2896. foreach($query->result_array() as $row)
  2897. {
  2898. $temp = $tagdata;
  2899. foreach ($this->EE->TMPL->var_single as $key => $val)
  2900. {
  2901. $val = substr($val, $prelen);
  2902. if (isset($row[$val]))
  2903. {
  2904. $temp = $this->EE->TMPL->swap_var_single($pre.$val, $row[$val], $temp);
  2905. }
  2906. }
  2907. $out .= $temp;
  2908. }
  2909. return $this->EE->TMPL->tagdata = $out;
  2910. }
  2911. }
  2912. // END CLASS
  2913. /* End of file mod.member.php */
  2914. /* Location: ./system/expressionengine/modules/member/mod.member.php */