1 | <?php
|
---|
2 |
|
---|
3 | /***************************************************************************
|
---|
4 | * Dolphin Smart Community Builder
|
---|
5 | * -----------------
|
---|
6 | * begin : Mon Mar 23 2006
|
---|
7 | * copyright : (C) 2006 BoonEx Group
|
---|
8 | * website : http://www.boonex.com/
|
---|
9 | * This file is part of Dolphin - Smart Community Builder
|
---|
10 | *
|
---|
11 | * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
|
---|
12 | * http://creativecommons.org/licenses/by/3.0/
|
---|
13 | *
|
---|
14 | * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
---|
15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
16 | * See the Creative Commons Attribution 3.0 License for more details.
|
---|
17 | * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
|
---|
18 | * see license.txt file; if not, write to marketing@boonex.com
|
---|
19 | ***************************************************************************/
|
---|
20 |
|
---|
21 | require_once( 'inc/header.inc.php' );
|
---|
22 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
23 | require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
|
---|
24 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
|
---|
25 | bx_import( 'BxDolEmailTemplates' );
|
---|
26 | bx_import( 'BxTemplFormView' );
|
---|
27 |
|
---|
28 | class BxDolForgotCheckerHelper extends BxDolFormCheckerHelper {
|
---|
29 | function checkEmail($s) {
|
---|
30 | if (!preg_match( '/^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel)$/i', $s ))
|
---|
31 | return false;
|
---|
32 |
|
---|
33 | $iID = (int)db_value( "SELECT `ID` FROM `Profiles` WHERE `Email` = '$s'" );
|
---|
34 | if (!$iID)
|
---|
35 | return _t( '_MEMBER_NOT_RECOGNIZED', $site['title'] );
|
---|
36 |
|
---|
37 | return true;
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | // --------------- page variables and login
|
---|
42 |
|
---|
43 | $_page['name_index'] = 37;
|
---|
44 | $_page['css_name'] = 'forgot.css';
|
---|
45 |
|
---|
46 | $logged['member'] = member_auth( 0, false );
|
---|
47 |
|
---|
48 | $_page['header'] = _t( "_Forgot password?" );
|
---|
49 | $_page['header_text'] = _t( "_Password retrieval", $site['title'] );
|
---|
50 |
|
---|
51 | // --------------- page components
|
---|
52 |
|
---|
53 | $_ni = $_page['name_index'];
|
---|
54 |
|
---|
55 |
|
---|
56 | $aForm = array(
|
---|
57 | 'form_attrs' => array(
|
---|
58 | 'name' => 'forgot_form',
|
---|
59 | 'action' => $_SERVER['PHP_SELF'],
|
---|
60 | 'method' => 'post',
|
---|
61 | ),
|
---|
62 | 'params' => array (
|
---|
63 | 'db' => array(
|
---|
64 | 'submit_name' => 'do_submit',
|
---|
65 | ),
|
---|
66 | 'checker_helper' => 'BxDolForgotCheckerHelper',
|
---|
67 | ),
|
---|
68 | 'inputs' => array(
|
---|
69 | array(
|
---|
70 | 'type' => 'email',
|
---|
71 | 'name' => 'Email',
|
---|
72 | 'caption' => _t('_My Email'),
|
---|
73 | 'value' => isset($_POST['Email']) ? $_POST['Email'] : '',
|
---|
74 | 'required' => true,
|
---|
75 | 'checker' => array(
|
---|
76 | 'func' => 'email',
|
---|
77 | 'error' => _t( '_Incorrect Email' )
|
---|
78 | ),
|
---|
79 | ),
|
---|
80 | array(
|
---|
81 | 'type' => 'captcha',
|
---|
82 | 'name' => 'captcha',
|
---|
83 | 'caption' => _t('_Enter Captcha'),
|
---|
84 | 'required' => true,
|
---|
85 | 'checker' => array(
|
---|
86 | 'func' => 'captcha',
|
---|
87 | 'error' => _t( '_Incorrect Captcha' ),
|
---|
88 | ),
|
---|
89 | ),
|
---|
90 | array(
|
---|
91 | 'type' => 'submit',
|
---|
92 | 'name' => 'do_submit',
|
---|
93 | 'value' => _t( "_Retrieve my information" ),
|
---|
94 | 'colspan' => true,
|
---|
95 | ),
|
---|
96 | )
|
---|
97 | );
|
---|
98 |
|
---|
99 |
|
---|
100 | $oForm = new BxTemplFormView($aForm);
|
---|
101 | $oForm->initChecker();
|
---|
102 |
|
---|
103 | if ( $oForm->isSubmittedAndValid() )
|
---|
104 | {
|
---|
105 | // Check if entered email is in the base
|
---|
106 | $sEmail = process_db_input($_POST['Email'], BX_TAGS_STRIP);
|
---|
107 | $memb_arr = db_arr( "SELECT `ID` FROM `Profiles` WHERE `Email` = '$sEmail'" );
|
---|
108 |
|
---|
109 | $recipient = $sEmail;
|
---|
110 |
|
---|
111 | $rEmailTemplate = new BxDolEmailTemplates();
|
---|
112 | $aTemplate = $rEmailTemplate -> getTemplate( 't_Forgot', $memb_arr['ID'] ) ;
|
---|
113 |
|
---|
114 | $aPlus['Password'] = generateUserNewPwd($memb_arr['ID']);
|
---|
115 | $aProfile = getProfileInfo($memb_arr['ID']);
|
---|
116 | $mail_ret = sendMail( $recipient, $aTemplate['Subject'], $aTemplate['Body'], $memb_arr['ID'], $aPlus);
|
---|
117 |
|
---|
118 | // create system event
|
---|
119 | require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php');
|
---|
120 | $oZ = new BxDolAlerts('profile', 'password_restore', $memb_arr['ID']);
|
---|
121 | $oZ->alert();
|
---|
122 |
|
---|
123 | $_page['header'] = _t( "_Recognized" );
|
---|
124 | $_page['header_text'] = _t( "_RECOGNIZED", $site['title'] );
|
---|
125 |
|
---|
126 | if ($mail_ret)
|
---|
127 | $action_result = _t( "_MEMBER_RECOGNIZED_MAIL_SENT", $site['url'], $site['title'] );
|
---|
128 | else
|
---|
129 | $action_result = _t( "_MEMBER_RECOGNIZED_MAIL_NOT_SENT", $site['title'] );
|
---|
130 |
|
---|
131 | $sForm = '';
|
---|
132 | } else {
|
---|
133 | $action_result = _t( "_FORGOT", $site['title'] );
|
---|
134 | $sForm = $oForm->getCode();
|
---|
135 | }
|
---|
136 |
|
---|
137 | $sPageCode = <<<BLAH
|
---|
138 | <div class="action_result">
|
---|
139 | $action_result
|
---|
140 | </div>
|
---|
141 | $sForm
|
---|
142 | BLAH;
|
---|
143 |
|
---|
144 | $_page_cont[$_ni]['page_main_code'] = $sPageCode;
|
---|
145 |
|
---|
146 | // --------------- [END] page components
|
---|
147 |
|
---|
148 | PageCode();
|
---|
149 |
|
---|
150 | // --------------- page components functions
|
---|
151 |
|
---|
152 |
|
---|
153 | function generateUserNewPwd($ID)
|
---|
154 | {
|
---|
155 | $sPwd = genRndPwd();
|
---|
156 | $sSalt = genRndSalt();
|
---|
157 |
|
---|
158 | $sQuery = "
|
---|
159 | UPDATE `Profiles`
|
---|
160 | SET
|
---|
161 | `Password` = '" . encryptUserPwd($sPwd, $sSalt) . "',
|
---|
162 | `Salt` = '$sSalt'
|
---|
163 | WHERE
|
---|
164 | `ID`='$ID'
|
---|
165 | ";
|
---|
166 |
|
---|
167 | db_res($sQuery);
|
---|
168 | createUserDataFile($ID);
|
---|
169 |
|
---|
170 | require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php');
|
---|
171 | $oZ = new BxDolAlerts('profile', 'edit', $ID);
|
---|
172 | $oZ->alert();
|
---|
173 | return $sPwd;
|
---|
174 | }
|
---|
175 |
|
---|
176 | ?>
|
---|