From: Lo?c C. <lo...@us...> - 2001-05-23 21:41:49
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat In directory usw-pr-cvs1:/tmp/cvs-serv12403/chat Modified Files: profile_edit.php3 Log Message: Changing of e-mail address cause a new password to be generated if C_REQUIRE_REG Index: profile_edit.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/profile_edit.php3,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** profile_edit.php3 2001/05/22 20:40:34 1.10 --- profile_edit.php3 2001/05/23 21:41:46 1.11 *************** *** 48,53 **** pmcGrabGlobals($toGrab); ! // Unslashes values of variables sent to this script ($authUsername is sent by ! // by the login script) if (!empty($nick)) $nick = pmcHandleMagicQuotes($nick, '1', '', 'del'); --- 48,52 ---- pmcGrabGlobals($toGrab); ! // Unslashes values of variables sent to this script if (!empty($nick)) $nick = pmcHandleMagicQuotes($nick, '1', '', 'del'); *************** *** 167,193 **** // Nick is already reserved if ($isReserved != 0) $error = L_ERR_USR_9; } } // end of the validation work // Udpates the profile if (!isset($error)) { $slashedPswd = pmcSlashSingleQuotes(str_replace('\\', '\\\\', $password)); ! $latin1 = (L_CHARSET == 'iso-8859-1') ? 1 : 0; ! $showEmail = (isset($showEmail) && $showEmail) ? 1 : 0; if (!isset($gender)) ! $gender = ''; // Gets the ip include('./lib/get_user_infos.lib.' . C_EXTENSION); ! $ip = pmcGetIp(); ! // Updates the profile $dbLink->query("UPDATE " . C_REG_TBL . " SET username = '$slashedNick', latin1 = '$latin1', password = '$slashedPswd', firstname='" . pmcSlashSingleQuotes($firstName) . "', lastname = '" . pmcSlashSingleQuotes($lastName) . "', country = '" . pmcSlashSingleQuotes($spokenLang) . "', website = '$webSite', email = '$email', showemail = $showEmail, reg_time = " . time() . ", ip = '$ip', gender = '$gender' WHERE username = '" . pmcSlashSingleQuotes($dbSessionVars['authUsername']) . "'"); if ($dbSessionVars['authPassword'] != $password) $dbSessionVars['authPassword'] = $password; ! $message = L_REG_17; ! $isRegDone = true; } } // end of the updating profile work --- 166,232 ---- // Nick is already reserved if ($isReserved != 0) + { $error = L_ERR_USR_9; + } } } // end of the validation work + + // If password are generated and sent by e-mail, do it if e-mail has + // changed + if (!isset($error) + && C_EMAIL_PASWD + && $dbSessionVars['prevEmail'] != $email) + { + include('./lib/gen_password.lib.' . C_EXTENSION); + $password = genPassword(); + $recipient = array($email => array($nick, L_CHARSET)); + $subject = '[' . APP_NAME . '] ' . L_EMAIL_VAL_1; + $body = L_SET_2 . ': ' . $nick . "\n"; + $body .= L_REG_7 . ': ' . $password . "\n\n"; + $body .= L_EMAIL_VAL_2 . "\n"; + $body .= C_CHAT_URL . "\n"; + + if (!defined('_LIB_PHPMYMAILER_LOADED')) + { + include('./lib/mailer.lib.' . C_EXTENSION); + } + $mailHandler = new PHPMYMAILER(C_REG_SENDER, C_REG_EMAIL); + $mailHandler->pmmSendEmail( $recipient, + L_CHARSET, $subject, $body); + if (!$mailHandler->pmmIsSent) + { + $error = sprintf(L_EMAIL_VAL_ERR, C_REG_EMAIL, C_REG_SENDER); + } + unset($mailHandler); + } // end of send new password by e-mail + // Udpates the profile if (!isset($error)) { $slashedPswd = pmcSlashSingleQuotes(str_replace('\\', '\\\\', $password)); ! $latin1 = (L_CHARSET == 'iso-8859-1') ? 1 : 0; ! $showEmail = (isset($showEmail) && $showEmail) ? 1 : 0; if (!isset($gender)) ! { ! $gender = ''; ! } // Gets the ip include('./lib/get_user_infos.lib.' . C_EXTENSION); ! $ip = pmcGetIp(); ! // Updates the profile and the banishment table if required $dbLink->query("UPDATE " . C_REG_TBL . " SET username = '$slashedNick', latin1 = '$latin1', password = '$slashedPswd', firstname='" . pmcSlashSingleQuotes($firstName) . "', lastname = '" . pmcSlashSingleQuotes($lastName) . "', country = '" . pmcSlashSingleQuotes($spokenLang) . "', website = '$webSite', email = '$email', showemail = $showEmail, reg_time = " . time() . ", ip = '$ip', gender = '$gender' WHERE username = '" . pmcSlashSingleQuotes($dbSessionVars['authUsername']) . "'"); + if ($nick != $dbSessionVars['authUsername']) + { + $dbLink->query("UPDATE " . C_BAN_TBL . " SET username = '$slashedNick', latin1 = '$latin1' WHERE username = '" . pmcSlashSingleQuotes($dbSessionVars['authUsername']) . "'"); + } if ($dbSessionVars['authPassword'] != $password) + { $dbSessionVars['authPassword'] = $password; ! } ! $message = L_REG_17; ! $isRegDone = true; } } // end of the updating profile work *************** *** 300,310 **** </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_7); ?> :</td> <td valign="top"> ! <input type="text" name="password" size="11" maxlength="16" value="<?php echo(htmlspecialchars($dbSessionVars['authPassword'])); ?>" /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_30); ?> :</td> --- 339,368 ---- </td> </tr> + <?php + // Do not display the password if e-mail validation is required and the e-mail + // has changed + if (!(C_EMAIL_PASWD && $isRegDone)) + { + ?> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_7); ?> :</td> <td valign="top"> ! <input type="password" name="password" size="11" maxlength="16" value="<?php echo(htmlspecialchars($dbSessionVars['authPassword'])); ?>" /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> + <?php + } + else + { + echo("\n"); + ?> + <tr> + <td align="center" valign="middle" colspan="2"><i><?php echo(L_EMAIL_VAL_DONE); ?></i></td> + </tr> + <?php + } + echo("\n"); + ?> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_30); ?> :</td> *************** *** 380,387 **** $dbSessionVars['nick'] = $nick; $dbSessionVars['password'] = $password; ! $toUnreg = array('conservative', 'authUsername', 'authPassword'); dbSessionUnregister($toUnreg); - dbSessionSave(); } $dbSessionDbLink->close(); ?> --- 438,449 ---- $dbSessionVars['nick'] = $nick; $dbSessionVars['password'] = $password; ! $toUnreg = array('conservative', 'authUsername', 'authPassword', 'prevEmail'); dbSessionUnregister($toUnreg); } + else + { + $dbSessionVars['prevEmail'] = $email; + } + dbSessionSave(); $dbSessionDbLink->close(); ?> |