| 1 | <?
|
|---|
| 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 |
|
|---|
| 26 | // --------------- page variables and login
|
|---|
| 27 |
|
|---|
| 28 | $_page['name_index'] = 37;
|
|---|
| 29 | $_page['css_name'] = 'forgot.css';
|
|---|
| 30 |
|
|---|
| 31 | $logged['member'] = member_auth( 0, false );
|
|---|
| 32 |
|
|---|
| 33 | $_page['header'] = _t( "_Forgot password?" );
|
|---|
| 34 | $_page['header_text'] = _t( "_Password retrieval", $site['title'] );
|
|---|
| 35 |
|
|---|
| 36 | // --------------- page components
|
|---|
| 37 |
|
|---|
| 38 | $_ni = $_page['name_index'];
|
|---|
| 39 | $_page_cont[$_ni]['page_main_code'] = PageCompPageMainCode();
|
|---|
| 40 |
|
|---|
| 41 | // --------------- [END] page components
|
|---|
| 42 |
|
|---|
| 43 | PageCode();
|
|---|
| 44 |
|
|---|
| 45 | // --------------- page components functions
|
|---|
| 46 |
|
|---|
| 47 | /**
|
|---|
| 48 | * page code function
|
|---|
| 49 | */
|
|---|
| 50 | function PageCompPageMainCode()
|
|---|
| 51 | {
|
|---|
| 52 | global $_page;
|
|---|
| 53 | global $site;
|
|---|
| 54 |
|
|---|
| 55 | $show_form = true;
|
|---|
| 56 | $action_result = _t( "_FORGOT", $site['title'] );
|
|---|
| 57 |
|
|---|
| 58 | ob_start();
|
|---|
| 59 |
|
|---|
| 60 | if ( $_POST['Email'] )
|
|---|
| 61 | {
|
|---|
| 62 | // Test if eneterd email is not valid
|
|---|
| 63 | if ( !eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4}$", $_POST['Email']) )
|
|---|
| 64 | {
|
|---|
| 65 | $_page['header'] = _t( "_Error" );
|
|---|
| 66 | $_page['header_text'] = _t( "_Incorrect Email" );
|
|---|
| 67 | $action_result = _t( "_INCORRECT_EMAIL" );
|
|---|
| 68 | }
|
|---|
| 69 | else
|
|---|
| 70 | {
|
|---|
| 71 | // Check if entered email is in the base
|
|---|
| 72 | $sEmail = htmlspecialchars_adv($_POST['Email']);
|
|---|
| 73 | $memb_arr = db_arr( "SELECT `ID` FROM `Profiles` WHERE `Email` = '$sEmail'" );
|
|---|
| 74 | if ( $memb_arr['ID'] )
|
|---|
| 75 | {
|
|---|
| 76 | $recipient = $sEmail;
|
|---|
| 77 |
|
|---|
| 78 | $message = getParam("t_Forgot");
|
|---|
| 79 | $subject = getParam('t_Forgot_subject');
|
|---|
| 80 |
|
|---|
| 81 | generateNewPwd($memb_arr['ID']);
|
|---|
| 82 |
|
|---|
| 83 | $mail_ret = sendMail( $recipient, $subject, $message, $memb_arr['ID'] );
|
|---|
| 84 |
|
|---|
| 85 | $sQuery = "UPDATE `Profiles` SET `Password` = md5(`Password`) WHERE `ID`='{$memb_arr['ID']}'";
|
|---|
| 86 | db_res( $sQuery );
|
|---|
| 87 |
|
|---|
| 88 | createUserDataFile( $memb_arr['ID'] );
|
|---|
| 89 |
|
|---|
| 90 | if (!$mail_ret)
|
|---|
| 91 | {
|
|---|
| 92 | $_page['header'] = _t( "_Recognized" );
|
|---|
| 93 | $_page['header_text'] = _t( "_RECOGNIZED", $site['title'] );
|
|---|
| 94 | $action_result = _t( "_MEMBER_RECOGNIZED_MAIL_NOT_SENT", $site['title'] );
|
|---|
| 95 | $show_form = false;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | $_page['header'] = _t( "_Recognized" );
|
|---|
| 99 | $_page['header_text'] = _t( "_RECOGNIZED", $site['title'] );
|
|---|
| 100 | $action_result = _t( "_MEMBER_RECOGNIZED_MAIL_SENT", $site['url'], $site['title'] );
|
|---|
| 101 | $show_form = false;
|
|---|
| 102 | }
|
|---|
| 103 | else
|
|---|
| 104 | {
|
|---|
| 105 | $_page['header'] = _t( "_Not Recognized" );
|
|---|
| 106 | $_page['header_text'] = _t( "_NOT_RECOGNIZED", $site['title'] );
|
|---|
| 107 | $action_result = _t( "_MEMBER_NOT_RECOGNIZED", $site['title'] );
|
|---|
| 108 | }
|
|---|
| 109 | }
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | echo "<table width=\"100%\" cellpadding=4 cellspacing=4>
|
|---|
| 113 | <td align=center class=text2>\n";
|
|---|
| 114 | echo $action_result;
|
|---|
| 115 | if ( $show_form )
|
|---|
| 116 | send_form();
|
|---|
| 117 | echo "
|
|---|
| 118 | </td></table>\n";
|
|---|
| 119 |
|
|---|
| 120 | $ret = ob_get_contents();
|
|---|
| 121 | ob_end_clean();
|
|---|
| 122 | return $ret;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | /**
|
|---|
| 126 | * Prints HTML form for forgot password function
|
|---|
| 127 | */
|
|---|
| 128 | function send_form()
|
|---|
| 129 | {
|
|---|
| 130 | ?>
|
|---|
| 131 | <br />
|
|---|
| 132 | <center>
|
|---|
| 133 | <form action="<? echo $_SERVER['PHP_SELF']; ?>" method=post>
|
|---|
| 134 | <table cellspacing=0 cellpadding=0 class=text>
|
|---|
| 135 | <td><? echo _t( "_My Email" ); ?>: </td>
|
|---|
| 136 | <td><input class=no type=text name="Email" value="<? echo htmlspecialchars_adv($_POST['Email']); ?>"></td>
|
|---|
| 137 | <td> </td>
|
|---|
| 138 | <td><input class=no type=submit value="<? echo _t( "_Retrieve my information" ); ?>"></td>
|
|---|
| 139 | </table>
|
|---|
| 140 | </form>
|
|---|
| 141 | </center>
|
|---|
| 142 | <?
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | function generateNewPwd($ID)
|
|---|
| 146 | {
|
|---|
| 147 | $sCode = base64_encode( substr( base64_encode( substr( microtime(), 2, 8 ) ), 2, 6 ) );
|
|---|
| 148 | $sQuery = "UPDATE `Profiles` SET `Password` = '$sCode' WHERE `ID`='$ID'";
|
|---|
| 149 |
|
|---|
| 150 | db_res($sQuery);
|
|---|
| 151 |
|
|---|
| 152 | createUserDataFile( $ID );
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | ?> |
|---|