From: Lo?c C. <lo...@us...> - 2001-05-16 20:54:35
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat In directory usw-pr-cvs1:/tmp/cvs-serv4126/chat Added Files: profile_remind.php3 Log Message: Modifications related to the new password reminder feature --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html | // +--------------------------------------------------------------------------+ // | This script allows to send a registered user his password if he has | // | forget it. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <te...@ph...> | // +--------------------------------------------------------------------------+ // // $Id: profile_remind.php3,v 1.1 2001/05/16 20:54:32 loic1 Exp $ // // Password reminder. // /** * Gets the extension for the php scripts */ if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; define('C_EXTENSION', (substr($PHP_SELF, -1) == 3) ? 'php3' : 'php'); /** * Gets some core libraries */ require('./config/config.lib.' . C_EXTENSION); require('./lib/common.lib.' . C_EXTENSION); require('./lib/database/' . C_DB_TYPE . '.lib.' . C_EXTENSION); /** * Gets the names and values for variables sent or posted to this script * * Uses the 'pmcGrabGlobals()' and 'pmcHandleMagicQuotes()' function defined in * the 'chat/lib/common.lib.php3' library */ $toGrab = array('dbSessionId', '%POST'); pmcGrabGlobals($toGrab); // Unslashes values of variables sent to this script if (!empty($nick)) $nick = pmcHandleMagicQuotes($nick, '1', '', 'del'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInit( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_SESS_DEL * 60, '' ); dbSessionStart(); $dbSessionDbLink->close(); unset($dbSessionDbLink); /** * Defines the language to be used */ require('./localization/languages.lib.' . C_EXTENSION); require('./localization/' . $dbSessionVars['lang'] . '/chat.loc'); /** * Sends HTTP headers * * The 'pmcHttpHeaders()' function is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, true); /** * Validates the submitted form then send the password */ if (isset($submitType)) { if (C_NO_SWEAR) include('./lib/swearing.lib.' . C_EXTENSION); // Validates the nick if (!$isJsValidated && trim($nick) == '') { $error = L_ERR_USR_5; } else if (!$isJsValidated && ereg('[\, ]', $nick)) { $error = L_ERR_USR_16; } else if (C_NO_SWEAR && checkWords($nick, true)) { $error = L_ERR_USR_18; } // Get the password from the database and send it to the user else { $slashedNick = pmcSlashSingleQuotes($nick); $dbLink = new pmcDB; $dbLink->query("SELECT password, email FROM " . C_REG_TBL . " WHERE username = '$slashedNick'"); list($thePassword, $theEmail) = $dbLink->nextRecord(); $dbLink->cleanResults(); $dbLink->close(); // Sends the password to the e-mail address if (!empty($thePassword)) { $recipient = array($theEmail => array($nick, L_CHARSET)); $subject = '[' . APP_NAME . '] ' . L_EMAIL_VAL_1; $body = L_SET_2 . ': ' . $nick . "\n"; $body .= L_REG_7 . ': ' . pmcHandleMagicQuotes($thePassword, '', '1', 'del') . "\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); } else { $success = L_EMAIL_VAL_DONE; } unset($mailHandler); } // No registered user with the submitted nick else { $error = L_REG_49; } } } // end of the updating profile work /** * Initializes some variables that will be used to display the form */ if (!isset($submitType)) { $nick = (!empty($dbSessionVars['nick'])) ? $dbSessionVars['nick'] : ''; } else { if (isset($error)) { $warning = '<p class="error">' . $error . '</p>' . "\n"; } else if (isset($success)) { $warning = '<p class="success">' . $success . '</p>' . "\n"; } } /** * Displays the password reminder page * * Uses the 'pmcUrlForStyleSheet()' and the 'pmcSlashSingleQuotes()' functions * from the 'chat/lib/common.lib.php3' library */ // The url for the style sheet $cssUrl = pmcUrlForStyleSheet('style', L_CHARSET, (defined('L_FONT_NAME')) ? L_FONT_NAME : '', L_FONT_SIZE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html dir="<?php echo((L_CHARSET == 'windows-1256') ? 'rtl' : 'ltr'); ?>"> <head> <title><?php echo(APP_NAME); ?></title> <link rel="stylesheet" href="<?php echo($cssUrl); ?>" type="text/css" /> <script type="text/javascript" language="javascript"> <!-- var jsErrorNick1 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_5))); ?>'; var jsErrorNick2 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_16))); ?>'; var formName = 'remindPassword'; // --> </script> <script src="lib/profile_work.lib.js" type="text/javascript" language="javascript"></script> </head> <body> <center> <?php // Form hasn't been submitted yet if (empty($submitType)) { ?> <br /> <form action="profile_remind.<?php echo(C_EXTENSION); ?>" method="post" autocomplete="off" name="remindPassword" onsubmit="return pmcRemindProfileValidate()"> <?php // Put the session id in an hidden field echo("\n" . dbSessionSID('POST') . "\n"); ?> <input type="hidden" name="isJsValidated" value="0" /> <table border="0" cellpadding="3" class="table"> <tr> <td align="center"> <table border="0"> <tr> <th colspan="2" class="tabTitle"><?php echo(L_REG_48); ?></th> </tr> <tr><td> </td></tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_SET_2); ?> :</td> <td valign="top"> <input type="text" name="nick" size="11" maxlength="10" value="<?php echo(htmlspecialchars($nick)); ?>" /> </td> </tr> </table> <br /><br /> <input type="submit" name="submitType" value="<?php echo(L_REG_15); ?>" /> </td> </tr> </table> </form> <?php } else { echo("\n" . '<br /><br /><br /><br />' . $warning . "\n"); } ?> </center> </body> </html> |