From: Lo?c C. <lo...@us...> - 2001-04-03 20:14:57
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat In directory usw-pr-cvs1:/tmp/cvs-serv5164/chat Added Files: messages_low.php3 profile_del.php3 profile_edit.php3 profile_reg.php3 Log Message: The first dev. version that works! Still many things to do, of course... --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | The 'messages' frame for browsers that does not support DHTML. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: messages_low.php3,v 1.1 2001/04/03 20:14:52 loic1 Exp $ // // The 'messages' frame for browsers that does not support DHTML. // /** * 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); require('./lib/clean.lib.' . C_EXTENSION); /** * Gets the session Id variable sent to this script * * Uses the 'pmcGrabGlobals()' function defined in the * 'chat/lib/common.lib.php3' library. */ pmcGrabGlobals('dbSessionId'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInitIt( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_REG_DEL, C_SESS_DEL * 60 ); dbSessionstart(); /** * Defines the language to be used */ require('./localization/' . $dbSessionVars['lang'] . '/localized.chat.' . C_EXTENSION); $textDirection = (L_CHARSET == 'windows-1256') ? 'rtl' : 'ltr'; /** * Sends HTTP headers * * The 'pmcHttpHeaders()' fonction is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, true); /** * Gets/Updates the users' informations from/in the connected users table */ $slashedNick = pmcSlashSingleQuotes($dbSessionVars['nick']); $currentRoomType = $dbSessionVars['roomType']; $slashedCurrentRoomName = pmcSlashSingleQuotes($dbSessionVars['targetRoom']); require('./lib/check_and_kick_user.lib.' . C_EXTENSION); pmcCheckAndKickUser(true); /** * Get messages * * The 'pmcHandleMagicQuotes()' and the 'pmcSlashSingleQuotes()' functions are * defined inside the 'chat/lib/common.lib.php3' script. */ // Define the SQL query (depends on the ignored users list and on whether to // display notification messages or not) $ignoredSendersList = ''; if (dbSessionIsRegistered('ignoredSenders') && !empty($dbSessionVars['ignoredSenders'])) $ignoredSendersList .= '\'' . str_replace(',', '\', \'', pmcSlashSingleQuotes($dbSessionVars['ignoredSenders'])) . '\''; if ($dbSessionVars['notify'] == 0) $ignoredSendersList .= (($ignoredSendersList != '') ? ', ':'') . '\'SYS enter\', \'SYS exit\''; if ($ignoredSendersList != '') $ignoredSendersList = 'username NOT IN (' . $ignoredSendersList . ') AND '; $slashedNick = pmcSlashSingleQuotes($dbSessionVars['nick']); $slashedCurrentRoomName = pmcSlashSingleQuotes($dbSessionVars['targetRoom']); $getMessagesQuery = 'SELECT username, latin1, m_time, address, color, msg_' . $dbSessionVars['msgKind'] . ' ' . 'FROM ' . C_MSG_TBL . ' ' . 'WHERE ' . $ignoredSendersList . '(' . 'address = \' *\' OR ' . '(address = \'' . $slashedNick .'\' AND (room = \'' . $slashedCurrentRoomName . '\' OR username = \'SYS inviteTo\')) OR ' . '(room = \'' . $slashedCurrentRoomName . '\' AND (address IS NULL OR username = \''. $slashedNick . '\'))' . ') ' . 'ORDER BY m_time DESC ' . 'LIMIT ' . $dbSessionVars['msgNumber']; // Get new messages and store them in an array $grabedMessages = array(); $dbLink = new pmcDB; $dbLink->query($getMessagesQuery); while (list($sender, $senderLatin1, $sentTime, $addressee, $msgColor, $message) = $dbLink->nextRecord()) { $grabedMessages[] = array( 'sender' => pmcHandleMagicQuotes($sender, '', 1, 'del'), 'senderLatin1' => $senderLatin1, 'sentTime' => $sentTime, 'addressee' => pmcHandleMagicQuotes($addressee, '', 1, 'del'), 'msgColor' => $msgColor, 'message' => pmcHandleMagicQuotes($message, '', 1, 'del') ); } $dbLink->cleanResults(); $dbLink->close(); /** * Format new messages * * The 'pmcSpecialChars()' and the 'pmcSlashSingleQuotes()' functions are * defined inside the 'chat/lib/common.lib.php3' script. */ $newMessages = array(); $grabedMessagesCnt = count($grabedMessages); if ($grabedMessagesCnt == 0) { $newMessages[] = '<span class="notify">' . L_NO_MSG . '</span>'; } else { reset($grabedMessages); for ($k = 0; $k < $grabedMessagesCnt; $k++) { // Get the values of messages variables while (list($name, $value) = each($grabedMessages[$k])) $$name = $value; // Skip the oldest message if the day seperator has been added if (isset($daySeparator) && $k == $grabedMessagesCnt - 1) continue; // Separator between messages sent before today and other ones if (!isset($daySeparator) && date('j', $sentTime) != date('j', time())) { $daySeparatorMsg = ($dbSessionVars['msgOrder'] == 0) ? L_TODAY_UP : L_TODAY_DWN; $newMessages[] = '<p class="msg"><span class="notify">--------- ' . $daySeparatorMsg . ' ---------</span></p>'; $daySeparator = 1; unset($daySeparatorMsg); } // Messages $aMessage = '<p class="msg">'; // The timestamp of the message if ($dbSessionVars['showTimestamp'] == 1) $aMessage .= '<span class="time">' . date('H:i:s', $sentTime + C_TMZ_OFFSET * 60 * 60) . '</span> '; // 'Standard' messages if (substr($sender,0,4) != 'SYS ') { $simpleSender = pmcSpecialChars($sender, $senderLatin1); $slashedSender = pmcSlashSingleQuotes($simpleSender); $sender = '<a href="#" onclick="window.parent.pmcUserClick(\'' . $slashedSender . '\', true); return false" class="sender">' . $simpleSender . '</a>'; if ($addressee != '') $addressee = ']<bdo dir="' . $textDirection . '"></bdo>>[' . htmlspecialchars($addressee); $aMessage .= '<b>[' . $sender . $addressee . ']<bdo dir="' . $textDirection .'"></bdo></b> ' . '<font color="' . $msgColor . '">' . $message . '</font>'; } // 'System' messages else { $aMessage .= '<span class="notify">'; if ($addressee == ' *') { $aMessage .= '[' . L_ANNOUNCE . ']<bdo dir="' . $textDirection . '"></bdo> ' . $message; } else { if ($addressee != '') $aMessage .= '<b>>[' . htmlspecialchars($addressee) . ']<bdo dir="' . $textDirection . '"></bdo></b> '; if (strpos($message, 'printf(')) eval('$aMessage .= ' . $message . ';'); else $aMessage .= $message; } $aMessage .= '</span>'; } $aMessage .= '</p>'; $newMessages[] = $aMessage; } } // end of formatting new messages unset($grabedMessages); /** * "Displays" the frame */ // Define the URL for the http refresh header $refreshUrl = 'messages_low.' . C_EXTENSION . '?' . dbSessionSID('GET'); // 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($textDirection); ?>"> <head> <title>Messages frame</title> <?php if ($dbSessionVars['refreshDelay'] > 0) echo('<meta http-equiv="Refresh" content="' . $dbSessionVars['refreshDelay'] . '; url=' . $refreshUrl . '" />' . "\n"); ?> <link rel="stylesheet" href="<?php echo($cssUrl); ?>" type="text/css" /> </head> <body class="mainframe"<?php if ($dbSessionVars['msgOrder'] == 1) echo(' onload="this.scrollTo(0,65000)"'); ?>> <?php // Display messages $newMessagesCnt = count($newMessages); reset($newMessages); for ($k = 0; $k < $newMessagesCnt; $k++) { $aMessage = ($dbSessionVars['msgOrder'] == 0) ? $newMessages[$k] : $newMessages[$newMessagesCnt - $k - 1]; echo($aMessage . "\n"); } unset($newMessages); ?> </body> </html> --- NEW FILE --- <? // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This script allows an user to delete his/her profile. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: profile_del.php3,v 1.1 2001/04/03 20:14:52 loic1 Exp $ // // Deletes the profile of an user. // /** * 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 ($authUsername is sent by // by the login script) if (!empty($submitType)) $submitType = pmcHandleMagicQuotes($submitType, '1', '', 'del'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInitIt( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_SESS_DEL * 60, '' ); dbSessionstart(); /** * Defines the language to be used */ require('./localization/languages.lib.' . C_EXTENSION); require('./localization/' . $dbSessionVars['lang'] . '/localized.chat.' . C_EXTENSION); /** * Authentification work */ if (!dbSessionIsRegistered('delProfilePerms')) { include('./lib/login.lib.' . C_EXTENSION); $dbSessionVars['delProfilePerms'] = $perms; dbSessionSave(); } // If user is admininistrator, defines a message to avoid profile deletion if ($dbSessionVars['delProfilePerms'] == 'admin') $message = L_ERR_USR_12; /** * Sends HTTP headers * * The 'pmcHttpHeaders()' fonction is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, true); /** * Deletes the profile if the form has been submitted and destroy the session */ if (isset($submitType) && $submitType == L_REG_20) { $dbLink = new pmcDB; $dbLink->query("DELETE FROM " . C_REG_TBL . " WHERE username = '" . pmcSlashSingleQuotes($dbSessionVars['authUsername']) . "'"); $message = L_REG_21; $dbLink->close(); dbSessionDestroy(); } /** * Displays the profile deletion page */ $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" /> </head> <body> <center> <p class="error"><?php echo((empty($error)) ? ' ' : $error); ?></p> <form action="profile_del.<?php echo(C_EXTENSION); ?>" method="post" autocomplete="off" name="delProfile"> <?php // Put the session id in an hidden field echo(dbSessionSID('POST') . "\n"); ?> <table border="0" cellpadding="3" class="table"> <tr> <td align="center"> <table border="0"> <tr> <th class="tabTitle"><?php echo(L_REG_13); ?></th> </tr> <tr> <td valign="top" align="center"> <?php echo((isset($message))? $message : L_REG_19); echo("\n"); ?> </td> </tr> </table> <br /><br /> <?php if (!isset($message)) { ?> <table border="0"> <tr> <td><input type="submit" name="submitType" value="<?php echo(L_REG_20); ?>" /></td> <td><input type="submit" name="submitType" value="<?php echo(L_REG_22); ?>" onclick="self.close(); return false" /></td> </tr> </table> <?php } else { ?> <input type="submit" name="submitType" value="<?php echo(L_REG_25); ?>" onclick="self.close(); return false" /> <?php } echo("\n"); ?> </td> </tr> </table> </form> </center> </body> </html> <?php ?> --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This script allows an user to edit and modify his/her profile. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: profile_edit.php3,v 1.1 2001/04/03 20:14:52 loic1 Exp $ // // Edits and allows to modify the profile of an user. // /** * 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 ($authUsername is sent by // by the login script) if (!empty($nick)) $nick = pmcHandleMagicQuotes($nick, '1', '', 'del'); if (!empty($password)) $password = pmcHandleMagicQuotes($password, '1', '', 'del'); if (!empty($firstName)) $firstName = pmcHandleMagicQuotes($firstName, '1', '', 'del'); if (!empty($lastName)) $lastName = pmcHandleMagicQuotes($lastName, '1', '', 'del'); if (!empty($spokenLang)) $spokenLang = pmcHandleMagicQuotes($spokenLang, '1', '', 'del'); if (!empty($submitType)) $submitType = pmcHandleMagicQuotes($submitType, '1', '', 'del'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInitIt( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_SESS_DEL * 60, '' ); dbSessionstart(); /** * Defines the language to be used */ require('./localization/languages.lib.' . C_EXTENSION); require('./localization/' . $dbSessionVars['lang'] . '/localized.chat.' . C_EXTENSION); /** * Authentification work */ if (!(dbSessionIsRegistered('authUsername') && dbSessionIsRegistered('authPassword'))) include('./lib/login.lib.' . C_EXTENSION); /** * Sends HTTP headers * * The 'pmcHttpHeaders()' fonction is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, true); /** * Defines some variables */ $dbLink = new pmcDB; $isRegDone = false; /** * Validates the submitted form then updates the profile */ if (isset($submitType) && $submitType == L_REG_16) { if (C_BAD_WORDS) 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_BAD_WORDS && checkWords($nick, true)) { $error = L_ERR_USR_18; } // Validates the password else if (!$isJsValidated && $password == '') { $error = L_ERR_USR_6; } // Validates the first and last names else if (!$isJsValidated && (trim($firstName) == '' || trim($lastName) == '')) { $error = L_ERR_USR_15; } // Validates the e-mail address else if (!$isJsValidated && trim($email) == '') { $error = L_ERR_USR_7; } else if (!$isJsValidated && !eregi('^([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)$', $email)) { $error = L_ERR_USR_8; } // Ensures the nick is not already reserved if it has been modified else { $slashedNick = pmcSlashSingleQuotes($nick); if ($nick != $dbSessionVars['authUsername']) { $dbLink->query("SELECT COUNT(*) FROM " . C_REG_TBL . " WHERE username = '$slashedNick'"); list($isReserved) = $dbLink->nextRecord(); $dbLink->cleanResults(); // Nick is already reserved if ($isReserved != 0) $error = L_ERR_USR_9; } } // end of the validation work // Udpates the profile if (!isset($error)) { $latin1 = (L_CHARSET == 'iso-8859-1'); $showEmail = (isset($showEmail) && $showEmail) ? 1 : 0; if (!isset($gender)) $gender = ''; // Gets the ip include('./lib/get_ip.lib.' . C_EXTENSION); // Defines the password $pwdHash = md5($password); // Updates the profile $dbLink->query("UPDATE " . C_REG_TBL . " SET username = '$slashedNick', latin1 = $latin1, password = '$pwdHash', 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']) . "'"); $message = L_REG_17; $isRegDone = true; } } // end of the updating profile work /** * Initializes some variables that will be used to display the form if it * hasn't been submitted yet */ if (!isset($submitType) || $submitType != L_REG_16) { $nick = $dbSessionVars['authUsername']; $dbLink->query("SELECT firstname, lastname, country, website, email, showemail, gender FROM " . C_REG_TBL . " WHERE username = '" . pmcSlashSingleQuotes($nick) . "' LIMIT 1"); list($firstName, $lastName, $spokenLang, $webSite, $email, $showEmail, $gender) = $dbLink->nextRecord(); $dbLink->cleanResults(); $firstName = pmcHandleMagicQuotes($firstName, '', 1, 'del'); $lastName = pmcHandleMagicQuotes($lastName, '', 1, 'del'); $spokenLang = pmcHandleMagicQuotes($spokenLang, '', 1, 'del'); } /** * Kills the instance of the DB class */ $dbLink->close(); /** * Displays the profile modification page */ $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 jsErrorPswd = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_6))); ?>'; var jsErrorName = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_15))); ?>'; var jsErrorEmail1 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_7))); ?>'; var jsErrorEmail2 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_8))); ?>'; var jsIsMailValid = false; var formName = 'editProfile'; // --> </script> <script src="lib/profile_work.lib.js" type="text/javascript" language="javascript"></script> </head> <body> <center> <p class="error"><?php echo((empty($error)) ? ' ' : $error); ?></p> <form action="profile_edit.<?php echo(C_EXTENSION); ?>" method="post" autocomplete="off" name="editProfile" onsubmit="return pmcRegProfileValidate()"> <?php // Put the session id in an hidden field echo(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(($isRegDone) ? $message : L_REG_34); ?></th> </tr> <tr> <th colspan="2"><?php if (!$isRegDone) echo(L_REG_37); ?></th> </tr> <tr><td> </td></tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_SET_2); ?> :</td> <td valign="top"> <?php // Do not allow modification of the nick if this popup is launched by the // profile command if (dbSessionIsRegistered('conservative')) { echo("\t\t\t\t" . $nick . "\n"); ?> <input type="hidden" name="nick" value="<?php echo(htmlspecialchars($nick)); ?>" /> <?php } else { ?> <input type="text" name="nick" size="11" maxlength="10" value="<?php echo(htmlspecialchars($nick)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo("\t\t\t" . '<span class="error">*</span>' . "\n"); } echo("\n"); ?> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_7); ?> :</td> <td valign="top"> <?php // Do not allow modification of the password if this popup is launched by the // profile command if (dbSessionIsRegistered('conservative')) { echo("\t\t\t\t" . $password . "\n"); ?> <input type="hidden" name="password" value="<?php echo(htmlspecialchars($dbSessionVars['authPassword'])); ?>" /> <?php } else { ?> <input type="password" name="password" size="11" maxlength="16" value="<?php echo(htmlspecialchars($dbSessionVars['authPassword'])); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo("\t\t\t" . '<span class="error">*</span>' . "\n"); } echo("\n"); ?> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_30); ?> :</td> <td valign="top"> <input type="text" name="firstName" size="11" maxlength="64" value="<?php echo(htmlspecialchars($firstName)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_31); ?> :</td> <td valign="top"> <input type="text" name="lastName" size="11" maxlength="64" value="<?php echo(htmlspecialchars($lastName)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_45); ?> :</td> <td valign="top"> <input type="radio" name="gender" value="1"<?php if (isset($gender) && $gender == 1) echo(' checked="checked"'); if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php echo(L_REG_46); ?><br /> <input type="radio" name="gender" value="2"<?php if (isset($gender) && $gender == 2) echo(' checked="checked"'); if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php echo(L_REG_47); ?> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_36); ?> :</td> <td valign="top"> <input type="text" name="spokenLang" size="11" maxlength="64" value="<?php echo(htmlspecialchars($spokenLang)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_32); ?> :</td> <td valign="top"> <input type="text" name="webSite" size="11" maxlength="64" value="<?php echo(htmlspecialchars($webSite)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_8); ?> :</td> <td valign="top"> <input type="text" name="email" size="11" maxlength="64" value="<?php echo($email); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> <tr> <td colspan="2" align="center"> <input type="checkbox" name="showEmail" value="1"<?php if (isset($showEmail) && $showEmail) echo(' checked="checked"'); if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php echo(L_REG_33); ?> </td> </tr> </table> <br /><br /> <?php if (!$isRegDone) { ?> <input type="submit" name="submitType" value="<?php echo(L_REG_16); ?>" /> <?php } echo("\n"); ?> <input type="submit" name="submitType" value="<?php echo(L_REG_25); ?>" onclick="pmcPutFocus(); self.close(); return false" /> </td> </tr> </table> </form> </center> </body> </html> <?php // Updates the session data if ($isRegDone) { $dbSessionVars['nick'] = $nick; $dbSessionVars['pwdHash'] = $pwdHash; $toUnreg = array('conservative', 'authUsername', 'authPassword'); dbSessionUnregister($toUnreg); dbSessionSave(); } ?> --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This script allows an user to register his/her profile. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // | & Jose' Carlos Pereira <php...@ab...> | // +--------------------------------------------------------------------------+ // // $Id: profile_reg.php3,v 1.1 2001/04/03 20:14:52 loic1 Exp $ // // Deletes the profile of an user. // /** * 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 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'); if (!empty($password)) $password = pmcHandleMagicQuotes($password, '1', '', 'del'); if (!empty($firstName)) $firstName = pmcHandleMagicQuotes($firstName, '1', '', 'del'); if (!empty($lastName)) $lastName = pmcHandleMagicQuotes($lastName, '1', '', 'del'); if (!empty($spokenLang)) $spokenLang = pmcHandleMagicQuotes($spokenLang, '1', '', 'del'); if (!empty($submitType)) $submitType = pmcHandleMagicQuotes($submitType, '1', '', 'del'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInitIt( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_SESS_DEL * 60, '' ); dbSessionstart(); /** * Defines the language to be used */ require('./localization/languages.lib.' . C_EXTENSION); require('./localization/' . $dbSessionVars['lang'] . '/localized.chat.' . C_EXTENSION); /** * Sends HTTP headers * * The 'pmcHttpHeaders()' fonction is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, true); /** * Validates the submitted form then registers the profile */ $isRegDone = false; if (isset($submitType) && $submitType == L_REG_3) { if (C_BAD_WORDS) 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_BAD_WORDS && checkWords($nick, true)) { $error = L_ERR_USR_18; } // Validates the password else if (!$isJsValidated && !C_EMAIL_PASWD && $password == '') { $error = L_ERR_USR_6; } // Validates the first and last names else if (!$isJsValidated && (trim($firstName) == '' || trim($lastName) == '')) { $error = L_ERR_USR_15; } // Validates the e-mail address else if (!$isJsValidated && trim($email) == '') { $error = L_ERR_USR_7; } else if (!$isJsValidated && !eregi('^([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)$', $email)) { $error = L_ERR_USR_8; } else if (C_EMAIL_PASWD && !checkdnsrr(substr(strstr($email, '@'), 1), 'ANY')) { $error = L_ERR_USR_8; } // Ensures the nick is not already reserved then registers the new profile else { $dbLink = new pmcDB; $slashedNick = pmcSlashSingleQuotes($nick); $dbLink->query("SELECT COUNT(*) FROM " . C_REG_TBL . " WHERE username = '$slashedNick'"); list($isReserved) = $dbLink->nextRecord(); $dbLink->cleanResults(); // Nick is already reserved if ($isReserved != 0) { $error = L_ERR_USR_9; } // Nick is free else { $latin1 = (L_CHARSET == 'iso-8859-1'); $showEmail = (isset($showEmail) && $showEmail) ? 1 : 0; if (!isset($gender)) $gender = ''; // Gets the ip include('./lib/get_ip.lib.' . C_EXTENSION); // Defines the password if (C_EMAIL_PASWD) { include('./lib/gen_password.lib.' . C_EXTENSION); $password = genPassword(); } $pwdHash = md5($password); // Sends the password to the e-mail address if required if (C_EMAIL_PASWD) { $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); } // Save the profile in the database and add the nick and the // password to the sessions data if (empty($error)) { $dbLink->query("INSERT INTO " . C_REG_TBL . " VALUES ('$slashedNick', $latin1, '$pwdHash', '" . pmcSlashSingleQuotes($firstName) . "', '" . pmcSlashSingleQuotes($lastName) . "', '" . pmcSlashSingleQuotes($spokenLang) . "', '$webSite', '$email', $showEmail, 'user', '', " . time() . ", '$ip', '$gender')"); $message = L_REG_9; $isRegDone = true; $dbSessionVars['nick'] = $nick; $dbSessionVars['pwdHash'] = $pwdHash; dbSessionSave(); } } $dbLink->close(); } } // end of the 'do register' work /** * Displays the profile registration page */ $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 jsErrorPswd = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_6))); ?>'; var jsErrorName = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_15))); ?>'; var jsErrorEmail1 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_7))); ?>'; var jsErrorEmail2 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_8))); ?>'; var jsIsMailValid = <?php echo(C_EMAIL_PASWD); ?>; var formName = 'regProfile'; // --> </script> <script src="lib/profile_work.lib.js" type="text/javascript" language="javascript"></script> </head> <body onload="if (typeof(window.focus) != 'undefined') pmcGetFocus()"> <center> <p class="error"><?php echo((empty($error)) ? ' ' : $error); ?></p> <form action="profile_reg.<?php echo(C_EXTENSION); ?>" method="post" autocomplete="off" name="regProfile" onsubmit="return pmcRegProfileValidate()"> <?php // Put the session id in an hidden field echo(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(($isRegDone) ? $message : L_REG_6); ?></th> </tr> <tr> <th colspan="2"><?php if (!$isRegDone) echo(L_REG_37); else if (C_EMAIL_PASWD) echo(L_EMAIL_VAL_DONE); ?></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 if (isset($nick)) echo(htmlspecialchars($nick)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> <?php if (!C_EMAIL_PASWD) { ?> <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 if (isset($password)) echo(htmlspecialchars($password)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> <?php } echo("\n"); ?> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_30); ?> :</td> <td valign="top"> <input type="text" name="firstName" size="11" maxlength="64" value="<?php if (isset($firstName)) echo(htmlspecialchars($firstName)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_31); ?> :</td> <td valign="top"> <input type="text" name="lastName" size="11" maxlength="64" value="<?php if (isset($lastName)) echo(htmlspecialchars($lastName)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_45); ?> :</td> <td valign="top"> <input type="radio" name="gender" value="1"<?php if (isset($gender) && $gender == 1) echo(' checked="checked"'); if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php echo(L_REG_46); ?><br /> <input type="radio" name="gender" value="2"<?php if (isset($gender) && $gender == 2) echo(' checked="checked"'); if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php echo(L_REG_47); ?> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_36); ?> :</td> <td valign="top"> <input type="text" name="spokenLang" size="11" maxlength="64" value="<?php if (isset($spokenLang)) echo(htmlspecialchars($spokenLang)); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_32); ?> :</td> <td valign="top"> <input type="text" name="webSite" size="11" maxlength="64" value="<?php if (isset($webSite)) echo($webSite); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> </td> </tr> <tr> <td align="right" valign="top" nowrap="nowrap"><?php echo(L_REG_8); ?> :</td> <td valign="top"> <input type="text" name="email" size="11" maxlength="64" value="<?php if (isset($email)) echo($email); ?>"<?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php if (!$isRegDone) echo('<span class="error">*</span>'); ?> </td> </tr> <tr> <td colspan="2" align="center"> <input type="checkbox" name="showEmail" value="1"<?php if (isset($showEmail) && $showEmail) echo(' checked="checked"'); ?><?php if ($isRegDone) echo(' readonly="readonly"'); ?> /> <?php echo(L_REG_33); ?> </td> </tr> </table> <br /><br /> <?php if (!$isRegDone) { ?> <input type="submit" name="submitType" value="<?php echo(L_REG_3); ?>" /> <?php } echo("\n"); ?> <input type="submit" name="submitType" value="<?php echo(L_REG_25); ?>" onclick="<?php if ($isRegDone) echo('pmcLoginToIndex(); '); ?>self.close(); return false;" /> </td> </tr> </table> </form> </center> </body> </html> <?php ?> |