PageRenderTime 66ms CodeModel.GetById 33ms RepoModel.GetById 0ms 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

Large files files are truncated, but you can click here to view the full file

  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->conf

Large files files are truncated, but you can click here to view the full file