From: Lo?c C. <lo...@us...> - 2001-06-10 14:58:21
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/index_libs In directory usw-pr-cvs1:/tmp/cvs-serv17318/chat/lib/index_libs Modified Files: do_enter_db_work.lib.php3 do_enter_js_work.lib.php3 index_validation.lib.php3 main_index.lib.php3 msg_validation.lib.js start_page.lib.js Log Message: Too many changes to detail. Index: do_enter_db_work.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/index_libs/do_enter_db_work.lib.php3,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** do_enter_db_work.lib.php3 2001/05/30 08:07:12 1.19 --- do_enter_db_work.lib.php3 2001/06/10 14:57:48 1.20 *************** *** 104,108 **** if ($isRegUser) { ! $slashedPswd = pmcSlashSingleQuotes(str_replace('\\', '\\\\', $password)); $dbLink->query("UPDATE " . C_REG_TBL . " SET password = '$slashedPswd', reg_time = $currentTime, ip = '$ip' WHERE username = '$slashedNick'"); } --- 104,108 ---- if ($isRegUser) { ! $slashedPswd = pmcSlashSingleQuotes(str_replace('\\', '\\\\', $pmcPassword)); $dbLink->query("UPDATE " . C_REG_TBL . " SET password = '$slashedPswd', reg_time = $currentTime, ip = '$ip' WHERE username = '$slashedNick'"); } *************** *** 137,166 **** { $slashedPrevRoomName = pmcSlashSingleQuotes($wasInRoom); - $dbLink->query("SELECT type FROM " . C_MSG_TBL . " WHERE room = '$slashedPrevRoomName' LIMIT 1"); - list($prevRoomType) = $dbLink->nextRecord(); $dbLink->cleanResults(); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(type, room, username, latin1, m_time, address, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "$prevRoomType, '$slashedPrevRoomName', 'SYS exit', '', $currentTime, NULL, '#666699', 'sprintf(L_EXIT_ROM, \'$nickForNotifications\')', 'sprintf(L_EXIT_ROM, \'$nickForNotifications\')'" . ')'; $dbLink->query($aQuery); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(type, room, username, latin1, m_time, address, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "$roomType, '$slashedTargetRoomName', 'SYS enter', '', $currentTime, NULL, '#666699', 'sprintf(L_ENTER_ROM, \'$nickForNotifications\')', 'sprintf(L_ENTER_ROM, \'$nickForNotifications\')'" . ')'; $dbLink->query($aQuery); ! $dbLink->query("UPDATE " . C_USR_TBL . " SET session_id = '$dbSessionId', u_time = $currentTime, room = '$slashedTargetRoomName', status = '$status', ip = '$ip' WHERE session_id = '$previousId'"); if (C_WELCOME) { ! // Delete the old welcome messages sent to the current user ! $dbLink->query("DELETE FROM " . C_MSG_TBL . " WHERE username = 'SYS welcome' AND address = '$slashedNick'"); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(type, room, username, latin1, m_time, address, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "$roomType, '$slashedTargetRoomName', 'SYS welcome', '', $currentTimePlus, '$slashedNick', '#666699', '$slashedWelcomeMsg', '$slashedWelcomeMsg'" . ')'; $dbLink->query($aQuery); --- 137,166 ---- { $slashedPrevRoomName = pmcSlashSingleQuotes($wasInRoom); $dbLink->cleanResults(); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(room, username, m_time, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "'$slashedPrevRoomName', 'SYS exit', $currentTime, '#666699', 'sprintf(L_EXIT_ROM, \'$nickForNotifications\')', 'sprintf(L_EXIT_ROM, \'$nickForNotifications\')'" . ')'; $dbLink->query($aQuery); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(room, username, m_time, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "'$slashedTargetRoomName', 'SYS enter', $currentTime, '#666699', 'sprintf(L_ENTER_ROM, \'$nickForNotifications\')', 'sprintf(L_ENTER_ROM, \'$nickForNotifications\')'" . ')'; $dbLink->query($aQuery); ! $dbLink->query("UPDATE " . C_USR_TBL . " SET session_id = '$dbSessionId', u_time = $currentTime, room = '$slashedTargetRoomName', status = $status, ip = '$ip' WHERE session_id = '$previousId'"); if (C_WELCOME) { ! // Delete the old welcome messages sent to the current user (check ! // if m_time and rooms aren't null to enforce the use of existing ! // indexes) ! $dbLink->query("DELETE FROM " . C_MSG_TBL . " WHERE m_time != '' AND room != '' AND address = '$slashedNick' AND username = 'SYS welcome'"); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(room, username, m_time, address, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "'$slashedTargetRoomName', 'SYS welcome', $currentTimePlus, '$slashedNick', '#666699', '$slashedWelcomeMsg', '$slashedWelcomeMsg'" . ')'; $dbLink->query($aQuery); *************** *** 186,197 **** . '(session_id, u_time, room, username, latin1, status, ip) ' . 'VALUES (' ! . "'$dbSessionId', $currentTime, '$slashedTargetRoomName', '$slashedNick', $latin1, '$status', '$ip'" . ')'; $dbLink->query($aQuery); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(type, room, username, latin1, m_time, address, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "$roomType, '$slashedTargetRoomName', 'SYS enter', '', $currentTime, NULL, '#666699', 'sprintf(L_ENTER_ROM, \'$nickForNotifications\')', 'sprintf(L_ENTER_ROM, \'$nickForNotifications\')'" . ')'; $dbLink->query($aQuery); --- 186,197 ---- . '(session_id, u_time, room, username, latin1, status, ip) ' . 'VALUES (' ! . "'$dbSessionId', $currentTime, '$slashedTargetRoomName', '$slashedNick', $latin1, $status, '$ip'" . ')'; $dbLink->query($aQuery); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(room, username, m_time, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "'$slashedTargetRoomName', 'SYS enter', $currentTime, '#666699', 'sprintf(L_ENTER_ROM, \'$nickForNotifications\')', 'sprintf(L_ENTER_ROM, \'$nickForNotifications\')'" . ')'; $dbLink->query($aQuery); *************** *** 199,208 **** if (C_WELCOME) { ! // Deletes the old welcome messages sent to the current user ! $dbLink->query("DELETE FROM " . C_MSG_TBL . " WHERE username = 'SYS welcome' AND address = '$slashedNick'"); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(type, room, username, latin1, m_time, address, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "$roomType, '$slashedTargetRoomName', 'SYS welcome', '', $currentTimePlus, '$slashedNick', '#666699', '$slashedWelcomeMsg', '$slashedWelcomeMsg'" . ')'; $dbLink->query($aQuery); --- 199,209 ---- if (C_WELCOME) { ! // Deletes the old welcome messages sent to the current user (check if ! // m_time and rooms aren't null to enforce the use of existing indexes) ! $dbLink->query("DELETE FROM " . C_MSG_TBL . " WHERE m_time != '' AND room != '' AND address = '$slashedNick' AND username = 'SYS welcome'"); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(room, username, m_time, address, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "'$slashedTargetRoomName', 'SYS welcome', $currentTimePlus, '$slashedNick', '#666699', '$slashedWelcomeMsg', '$slashedWelcomeMsg'" . ')'; $dbLink->query($aQuery); *************** *** 212,215 **** --- 213,226 ---- /** + * Updates the rooms table + */ + $dbLink->query("UPDATE " . C_ROOM_TBL . " SET last_user_modif = $currentTime WHERE room_name = '$slashedTargetRoomName'"); + if (!$dbLink->affectedRows()) + { + $dbLink->query("INSERT INTO " . C_ROOM_TBL . " (room_type, room_name, last_user_modif) VALUES ($roomType, '$slashedTargetRoomName', $currentTime)"); + } + + + /** * Prepares (ie removes unnecessary data) and saves session data */ *************** *** 227,235 **** $dbSessionVars['lang'] = $keptLang; $dbSessionVars['jsVersion'] = $jsVersion; ! $dbSessionVars['nick'] = $nick; ! $dbSessionVars['password'] = $password; $dbSessionVars['roomType'] = $roomType; $dbSessionVars['currentRoom'] = $targetRoom; ! $dbSessionVars['status'] = (empty($status)) ? 'u' : $status; $dbSessionVars['refreshDelay'] = C_MSG_REFRESH; $dbSessionVars['msgKind'] = $msgKind; --- 238,247 ---- $dbSessionVars['lang'] = $keptLang; $dbSessionVars['jsVersion'] = $jsVersion; ! $dbSessionVars['nick'] = $pmcNick; ! $dbSessionVars['password'] = $pmcPassword; $dbSessionVars['roomType'] = $roomType; $dbSessionVars['currentRoom'] = $targetRoom; ! $dbSessionVars['status'] = $status; ! $dbSessionVars['away'] = 0; $dbSessionVars['refreshDelay'] = C_MSG_REFRESH; $dbSessionVars['msgKind'] = $msgKind; *************** *** 254,259 **** /** * Deletes invite messages sent to the user for the room he will enter in */ ! $dbLink->query("DELETE FROM " . C_MSG_TBL . " WHERE username = 'SYS inviteTo' AND address = '$slashedNick' AND room = '$slashedTargetRoomName'"); ?> --- 266,272 ---- /** * Deletes invite messages sent to the user for the room he will enter in + * (check if m_time isn't null to enforce the use of existing indexes) */ ! $dbLink->query("DELETE FROM " . C_MSG_TBL . " WHERE m_time != '' AND room = '$slashedTargetRoomName' AND address = '$slashedNick' AND username = 'SYS inviteTo'"); ?> Index: do_enter_js_work.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/index_libs/do_enter_js_work.lib.php3,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** do_enter_js_work.lib.php3 2001/05/30 08:07:12 1.12 --- do_enter_js_work.lib.php3 2001/06/10 14:57:48 1.13 *************** *** 62,66 **** <script type="text/javascript" language="javascript1.1"> <!-- ! var jsIsModerator = <?php echo((isset($status) && ($status == 'a' || $status == 'm')) ? 1 : 0); ?>; // --> </script> --- 62,66 ---- <script type="text/javascript" language="javascript1.1"> <!-- ! var jsIsModerator = <?php echo(($status >= 5) ? 1 : 0); ?>; // --> </script> Index: index_validation.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/index_libs/index_validation.lib.php3,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** index_validation.lib.php3 2001/05/23 21:40:30 1.13 --- index_validation.lib.php3 2001/06/10 14:57:48 1.14 *************** *** 38,43 **** * * @param string true if the nick is a registered one - * @param string permission level associated to the nick - * @param string list of the room moderated by the user * @param string previous id of the user whith the same nick * @param string name of the room the user was chatting into --- 38,41 ---- *************** *** 54,64 **** * @access public */ ! function pmcValidateNickAndPaswd( &$isRegNick, &$regNickPerms, &$regNickModeratedRooms, ! &$loggedInId, &$loggedInRoom) { global $isJsValidated; global $dbLink; ! global $nick, $slashedNick; ! global $password; $error1 = ''; --- 52,61 ---- * @access public */ ! function pmcValidateNickAndPaswd(&$isRegNick, &$loggedInId, &$loggedInRoom) { global $isJsValidated; global $dbLink; ! global $pmcNick, $slashedNick; ! global $pmcPassword; $error1 = ''; *************** *** 68,72 **** // 1. Ensures invalid characters/words aren't in use for the nick // Ensures a nick has been submitted ! if (!$isJsValidated && $nick == '') { $error1 = L_ERR_USR_2; --- 65,69 ---- // 1. Ensures invalid characters/words aren't in use for the nick // Ensures a nick has been submitted ! if (!$isJsValidated && $pmcNick == '') { $error1 = L_ERR_USR_2; *************** *** 74,78 **** // Checks for invalid characters or empty nick else if (!$isJsValidated && ! (trim($nick) == '' || ereg('[\, ]', $nick))) { $error1 = L_ERR_USR_16; --- 71,75 ---- // Checks for invalid characters or empty nick else if (!$isJsValidated && ! (trim($pmcNick) == '' || ereg('[\, ]', $pmcNick))) { $error1 = L_ERR_USR_16; *************** *** 81,85 **** else if (C_NO_SWEAR) { ! if (checkWords($nick, true)) { $error1 = L_ERR_USR_18; --- 78,82 ---- else if (C_NO_SWEAR) { ! if (checkWords($pmcNick, true)) { $error1 = L_ERR_USR_18; *************** *** 106,110 **** if ($error1 == '' && !$isJsValidated && $requireReg) { ! if ($password == '') { $error1 = ($isLoggedIn) ? L_ERR_USR_1 : L_ERR_USR_14; --- 103,107 ---- if ($error1 == '' && !$isJsValidated && $requireReg) { ! if ($pmcPassword == '') { $error1 = ($isLoggedIn) ? L_ERR_USR_1 : L_ERR_USR_14; *************** *** 114,126 **** // 4. Ensure a valid password has been submitted if the nick is a ! // registered one, then gets permission levels for this nick if ($error1 == '') { ! $dbLink->query("SELECT password, perms, rooms FROM " . C_REG_TBL . " WHERE username = '$slashedNick' LIMIT 1"); ! $isRegNick = (list($regUserPassword, $regNickPerms, $regNickModeratedRooms) = $dbLink->nextRecord()); if ($isRegNick) { $regUserPassword = pmcHandleMagicQuotes($regUserPassword, '', 1, 'del'); - $regNickModeratedRooms = pmcHandleMagicQuotes($regNickModeratedRooms, '', 1, 'del'); } $dbLink->cleanResults(); --- 111,122 ---- // 4. Ensure a valid password has been submitted if the nick is a ! // registered one if ($error1 == '') { ! $dbLink->query("SELECT password FROM " . C_REG_TBL . " WHERE username = '$slashedNick' LIMIT 1"); ! $isRegNick = (list($regUserPassword) = $dbLink->nextRecord()); if ($isRegNick) { $regUserPassword = pmcHandleMagicQuotes($regUserPassword, '', 1, 'del'); } $dbLink->cleanResults(); *************** *** 136,140 **** { // Reserved nick but no password submitted -> deny access ! if (!$isJsValidated && $password == '') { $error1 = L_ERR_USR_3; --- 132,136 ---- { // Reserved nick but no password submitted -> deny access ! if (!$isJsValidated && $pmcPassword == '') { $error1 = L_ERR_USR_3; *************** *** 142,151 **** // Validates the password submitted (compare also its md5 hash for // compatibility with old releases) ! else if ($regUserPassword != $password && $regUserPassword != md5($password)) { $isRegNick = false; ! $password = ''; ! $regNickPerms = 'user'; ! $regNickModeratedRooms = ''; $error1 = L_ERR_USR_4; } --- 138,145 ---- // Validates the password submitted (compare also its md5 hash for // compatibility with old releases) ! else if ($regUserPassword != $pmcPassword && $regUserPassword != md5($pmcPassword)) { $isRegNick = false; ! $pmcPassword = ''; $error1 = L_ERR_USR_4; } *************** *** 160,165 **** /** ! * Validates the name of the room to create and defines the permission level ! * the user will be granted inside this room * * @return string error number --- 154,158 ---- /** ! * Validates the name of the room to create * * @return string error number *************** *** 231,235 **** { $theSlashedRoomName = pmcSlashSingleQuotes($targetRoom); ! $dbLink->query("SELECT type, room FROM " . C_MSG_TBL . " WHERE room = '$theSlashedRoomName' LIMIT 1"); $roomExist = (list($trueType, $trueCaseName) = $dbLink->nextRecord()); $dbLink->cleanResults(); --- 224,228 ---- { $theSlashedRoomName = pmcSlashSingleQuotes($targetRoom); ! $dbLink->query("SELECT room_type, room_name FROM " . C_ROOM_TBL . " WHERE room_name = '$theSlashedRoomName' LIMIT 1"); $roomExist = (list($trueType, $trueCaseName) = $dbLink->nextRecord()); $dbLink->cleanResults(); Index: main_index.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/index_libs/main_index.lib.php3,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** main_index.lib.php3 2001/05/30 08:07:12 1.34 --- main_index.lib.php3 2001/06/10 14:57:48 1.35 *************** *** 74,81 **** if (!empty($newTargetRoom)) $newTargetRoom = pmcHandleMagicQuotes($newTargetRoom, '1', '', 'del'); ! if (!empty($nick)) ! $nick = pmcHandleMagicQuotes($nick, '1', '', 'del'); ! if (!empty($password)) ! $password = pmcHandleMagicQuotes($password, '1', '', 'del'); if (!empty($enterDefaultRoomName)) $enterDefaultRoomName = pmcHandleMagicQuotes($enterDefaultRoomName, '1', '', 'del'); --- 74,81 ---- if (!empty($newTargetRoom)) $newTargetRoom = pmcHandleMagicQuotes($newTargetRoom, '1', '', 'del'); ! if (!empty($pmcNick)) ! $pmcNick = pmcHandleMagicQuotes($pmcNick, '1', '', 'del'); ! if (!empty($pmcPassword)) ! $pmcPassword = pmcHandleMagicQuotes($pmcPassword, '1', '', 'del'); if (!empty($enterDefaultRoomName)) $enterDefaultRoomName = pmcHandleMagicQuotes($enterDefaultRoomName, '1', '', 'del'); *************** *** 84,89 **** if (!empty($createRoomName)) $createRoomName = pmcHandleMagicQuotes($createRoomName, '1', '', 'del'); ! if (!empty($cookieUsername)) ! $cookieUsername = urldecode(pmcHandleMagicQuotes($cookieUsername, '1', '', 'del')); if (!empty($cookieRoom)) $cookieRoom = urldecode(pmcHandleMagicQuotes($cookieRoom, '1', '', 'del')); --- 84,89 ---- if (!empty($createRoomName)) $createRoomName = pmcHandleMagicQuotes($createRoomName, '1', '', 'del'); ! if (!empty($cookiePmcUsername)) ! $cookiePmcUsername = urldecode(pmcHandleMagicQuotes($cookiePmcUsername, '1', '', 'del')); if (!empty($cookieRoom)) $cookieRoom = urldecode(pmcHandleMagicQuotes($cookieRoom, '1', '', 'del')); *************** *** 128,131 **** --- 128,133 ---- if (empty($isJsValidated)) $isJsValidated = 0; + if (isset($chattingCnt)) + unset($chattingCnt); // Get the relative path to the script that called this one *************** *** 135,146 **** // Sets the $isFontMsg to true when the user logs in for the first time and a // specific font face have to be used (iso-code is 'x-user-defined') ! $isFontMsg = (empty($nick) && defined('L_FONT_NAME')); $latin1 = (L_CHARSET == 'iso-8859-1') ? 1 : 0; // Try to get the nickname from session data, then slashes it ! if (empty($nick) && dbSessionIsRegistered('nick')) ! $nick = $dbSessionVars['nick']; ! if (isset($nick)) ! $slashedNick = pmcSlashSingleQuotes($nick); // Unset some variables that may be the cause of security holes --- 137,148 ---- // Sets the $isFontMsg to true when the user logs in for the first time and a // specific font face have to be used (iso-code is 'x-user-defined') ! $isFontMsg = (empty($pmcNick) && defined('L_FONT_NAME')); $latin1 = (L_CHARSET == 'iso-8859-1') ? 1 : 0; // Try to get the nickname from session data, then slashes it ! if (empty($pmcNick) && dbSessionIsRegistered('nick')) ! $pmcNick = $dbSessionVars['nick']; ! if (isset($pmcNick)) ! $slashedNick = pmcSlashSingleQuotes($pmcNick); // Unset some variables that may be the cause of security holes *************** *** 210,215 **** // Defines the message to be displayed if (!dbSessionIsRegistered('kicked')) ! $dbSessionVars['kicked'] = 0; ! $messageKind = ''; switch ($dbSessionVars['kicked']) { --- 212,219 ---- // Defines the message to be displayed if (!dbSessionIsRegistered('kicked')) ! { ! $dbSessionVars['kicked'] = 0; ! } ! $messageKind = ''; switch ($dbSessionVars['kicked']) { *************** *** 237,263 **** break; default: // The user regulary left the chat if ($dbLink->affectedRows() > 0) $messageKind = 'L_EXIT_ROM'; } // end of switch ! // Display the message if (!empty($messageKind)) { $nickForNotifications = pmcSlashSingleQuotes(pmcSpecialChars($slashedNick, $latin1), 2); $exitedRoomName = pmcSlashSingleQuotes($dbSessionVars['currentRoom']); ! $exitedRoomType = $dbSessionVars['roomType']; $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(type, room, username, latin1, m_time, address, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "$exitedRoomType, '$exitedRoomName', 'SYS exit', '', " . time() . ", NULL, '#666699', 'sprintf($messageKind, \'$nickForNotifications\')', 'sprintf($messageKind, \'$nickForNotifications\')'" . ')'; $dbLink->query($aQuery); unset($messageKind); unset($nickForNotifications); unset($exitedRoomName); - unset($exitedRoomType); } --- 241,275 ---- break; + case 5: + // Too long inactive delay + $messageKind = 'L_EXIT_ROM'; + $error = L_ERR_USR_21; + break; + default: // The user regulary left the chat if ($dbLink->affectedRows() > 0) + { $messageKind = 'L_EXIT_ROM'; + } } // end of switch ! // Display the message and updates the rooms table if (!empty($messageKind)) { $nickForNotifications = pmcSlashSingleQuotes(pmcSpecialChars($slashedNick, $latin1), 2); $exitedRoomName = pmcSlashSingleQuotes($dbSessionVars['currentRoom']); ! $exitTime = time(); $aQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' ! . '(room, username, m_time, color, msg_original, msg_enhanced) ' . 'VALUES (' ! . "'$exitedRoomName', 'SYS exit', $exitTime, '#666699', 'sprintf($messageKind, \'$nickForNotifications\')', 'sprintf($messageKind, \'$nickForNotifications\')'" . ')'; $dbLink->query($aQuery); + $dbLink->query("UPDATE " . C_ROOM_TBL . " SET last_user_modif = $exitTime WHERE room_name = '$exitedRoomName'"); unset($messageKind); unset($nickForNotifications); unset($exitedRoomName); } *************** *** 316,328 **** if (dbSessionIsRegistered('password')) { ! $password = $dbSessionVars['password']; } ! else if (!isset($password)) { ! $password = ''; } $isRegUser = false; - $regUserPerms = 'noreg'; - $regUserModeratedRooms = ''; $wasInRoom = ''; $previousId = ''; --- 328,338 ---- if (dbSessionIsRegistered('password')) { ! $pmcPassword = $dbSessionVars['password']; } ! else if (!isset($pmcPassword)) { ! $pmcPassword = ''; } $isRegUser = false; $wasInRoom = ''; $previousId = ''; *************** *** 368,372 **** unset($enterOtherRoomName); unset($enterDefaultRoomName); ! } --- 378,382 ---- unset($enterOtherRoomName); unset($enterDefaultRoomName); ! } *************** *** 390,393 **** --- 400,404 ---- * Optimize some of the tables */ + $dbLink->optimize(C_ROOM_TBL); $dbLink->optimize(C_MSG_TBL); $dbLink->optimize(C_USR_TBL); *************** *** 407,419 **** * 'chat/lib/index_validation.lib.php3' library */ ! if (empty($reloading)) { ! $error = pmcValidateNickAndPaswd( $isRegUser, $regUserPerms, $regUserModeratedRooms, ! $previousId, $wasInRoom); if ($error == '') { // Puts the nick in a cookie that will expire in one year ! $cookieUsername = urlencode($nick); ! setcookie('cookieUsername', $cookieUsername, time() + 60*60*24*365); } } // end of the nick and password validation work --- 418,429 ---- * 'chat/lib/index_validation.lib.php3' library */ ! if (empty($error) && empty($reloading)) { ! $error = pmcValidateNickAndPaswd($isRegUser, $previousId, $wasInRoom); if ($error == '') { // Puts the nick in a cookie that will expire in one year ! $cookiePmcUsername = urlencode($pmcNick); ! setcookie('cookiePmcUsername', $cookiePmcUsername, time() + 60*60*24*365); } } // end of the nick and password validation work *************** *** 421,444 **** /** ! * Gets the permission level of the user and the list of the rooms he/she ! * is moderator for from the database if this script is run following a ! * click on a room name at the 'users' frame. * ! * The 'pmcHandleMagicQuotes()' function is defined inside the ! * 'chat/lib/common.lib.php3' library */ ! else if ($reloading == 'joinLink') { ! $dbLink->query("SELECT perms, rooms FROM " . C_REG_TBL . " WHERE username = '$slashedNick' LIMIT 1"); ! $isRegUser = (list($regUserPerms, $regUserModeratedRooms) = $dbLink->nextRecord()); ! if ($isRegUser) { ! $regUserModeratedRooms = pmcHandleMagicQuotes($regUserModeratedRooms, '', 1, 'del'); } ! $dbLink->cleanResults(); ! } // end of get permission level in reloading case /** * Ensures the user is not banished from the room he wants to enter in * --- 431,482 ---- /** ! * Checks whether the user is the administrator or not * ! * This part of the script is skipped if the frameset is reloaded because ! * of the NS4+ resize bug. */ ! if (empty($error) ! && (empty($reloading) || $reloading == 'joinLink')) { ! if (dbSessionIsRegistered('nick') && $dbSessionVars['nick'] == $pmcNick ! && dbSessionIsRegistered('status')) { ! // The status of this user is already known in session data } ! else ! { ! $dbLink->query("SELECT COUNT(*) FROM " . C_RIGHT_TBL . " WHERE username = '$slashedNick' AND right_level > 9 LIMIT 1"); ! list($isAdmin) = $dbLink->nextRecord(); ! $dbLink->cleanResults(); ! $dbSessionVars['status'] = ($isAdmin) ? 10 : ''; ! } ! } /** + * Ensures the maximum number of connected users is not already reached if + * this directive is enabled in the config file + * + * This part of the script is skipped if: + * - the frameset is reloaded because of the NS4+ resize bug or because the + * user clicked on a room name at the 'users' frame; + * - if he/she relogs; + * - or if he/she is the adminsitrator. + */ + if (empty($error) && C_MAX_USERS + && empty($reloading) && empty($wasInRoom) + && !(dbSessionIsRegistered('status') && intval($dbSessionVars['status']) > 9)) + { + $dbLink->query('SELECT COUNT(*) FROM ' . C_USR_TBL); + list($chattingCnt) = $dbLink->nextRecord(); + $dbLink->cleanResults(); + if ($chattingCnt >= C_MAX_USERS) + { + $error = L_ERR_ROM_5; + } + } + + + /** * Ensures the user is not banished from the room he wants to enter in * *************** *** 452,456 **** && (empty($reloading) || $reloading == 'joinLink')) { ! if (C_BANISH && $regUserPerms != 'admin' && pmcCheckBanish()) { $error = L_ERR_USR_20; --- 490,496 ---- && (empty($reloading) || $reloading == 'joinLink')) { ! if (C_BANISH ! && !(dbSessionIsRegistered('status') && intval($dbSessionVars['status']) > 9) ! && pmcCheckBanish()) { $error = L_ERR_USR_20; *************** *** 481,493 **** * the 'chat/lib/get_user_infos.lib.php3' library. */ ! $slashedTargetRoomName = pmcSlashSingleQuotes($targetRoom); ! if (!isset($reloading) || $reloading != 'nsResize') ! { ! $status = pmcRightLevel(); ! } ! else { ! $status = $dbSessionVars['status']; ! } --- 521,542 ---- * the 'chat/lib/get_user_infos.lib.php3' library. */ ! if ($error == '') { ! $slashedTargetRoomName = pmcSlashSingleQuotes($targetRoom); ! if (!isset($reloading)) ! { ! $status = pmcRightLevel(); ! } ! else if ($reloading != 'nsResize') ! { ! $isRegUser = ($dbSessionVars['status'] > 0); ! $status = pmcRightLevel(); ! $isRegUser = false; ! } ! else ! { ! $status = $dbSessionVars['status']; ! } ! } // end of right level definition *************** *** 634,643 **** // Try to get the most accurate values for the form fields below ! if (!empty($GLOBALS['nick'])) ! $layoutNick = $GLOBALS['nick']; else if (dbSessionIsRegistered('nick')) $layoutNick = $dbSessionVars['nick']; ! else if (isset($GLOBALS['cookieUsername'])) ! $layoutNick = urldecode($GLOBALS['cookieUsername']); else $layoutNick = ''; --- 683,692 ---- // Try to get the most accurate values for the form fields below ! if (!empty($GLOBALS['pmcNick'])) ! $layoutNick = $GLOBALS['pmcNick']; else if (dbSessionIsRegistered('nick')) $layoutNick = $dbSessionVars['nick']; ! else if (isset($GLOBALS['cookiePmcUsername'])) ! $layoutNick = urldecode($GLOBALS['cookiePmcUsername']); else $layoutNick = ''; *************** *** 712,721 **** <?php // Displays informating messages ! echo("\t\t" . L_WEL_1 . ' ' . C_MSG_DEL . ' ' . L_WEL_2 . ' ' . C_USR_DEL . ' ' . L_WEL_3 . '<br /><br />' . "\n"); // Displays the message about currently chatting users ! $dbLink->query("SELECT COUNT(*) FROM " . C_USR_TBL); ! list($chattingCnt) = $dbLink->nextRecord(); ! $dbLink->cleanResults(); $usersPopupLink = ' <a href="' . _CHAT_PATH . 'users_popup_low.' . C_EXTENSION . '?' . dbSessionSID('GET') .'" target="users_popup_' . md5(C_CHAT_URL) . '" class="chatLink" onclick="pmcUsersPopup(\'' . md5(C_CHAT_URL) . '\'); return false">'; $usersPopupLink .= (($chattingCnt) ? $chattingCnt : 0) . ' '; --- 761,777 ---- <?php // Displays informating messages ! echo("\t\t" . L_WEL_1 . ' ' . C_MSG_DEL . ' ' . L_WEL_2 . ' ' . (C_USR_AWAY + C_USR_DEL) . ' ' . L_WEL_3 . '<br /><br />' . "\n"); // Displays the message about currently chatting users ! if (isset($GLOBALS['chattingCnt'])) ! { ! $chattingCnt = $GLOBALS['chattingCnt']; ! } ! else ! { ! $dbLink->query("SELECT COUNT(*) FROM " . C_USR_TBL); ! list($chattingCnt) = $dbLink->nextRecord(); ! $dbLink->cleanResults(); ! } $usersPopupLink = ' <a href="' . _CHAT_PATH . 'users_popup_low.' . C_EXTENSION . '?' . dbSessionSID('GET') .'" target="users_popup_' . md5(C_CHAT_URL) . '" class="chatLink" onclick="pmcUsersPopup(\'' . md5(C_CHAT_URL) . '\'); return false">'; $usersPopupLink .= (($chattingCnt) ? $chattingCnt : 0) . ' '; *************** *** 799,803 **** <td align="<?php echo($cellAlign); ?>" valign="top" class="chatCell" nowrap="nowrap"><?php echo(L_SET_2); ?> :</td> <td valign="top" class="chatCell"> ! <input id="testSize" type="text" name="nick" size="11" maxlength="10" value="<?php echo(htmlspecialchars($layoutNick)); ?>" class="chatBox" /> </td> </tr> --- 855,859 ---- <td align="<?php echo($cellAlign); ?>" valign="top" class="chatCell" nowrap="nowrap"><?php echo(L_SET_2); ?> :</td> <td valign="top" class="chatCell"> ! <input id="testSize" type="text" name="pmcNick" size="11" maxlength="10" value="<?php echo(htmlspecialchars($layoutNick)); ?>" class="chatBox" /> </td> </tr> *************** *** 805,809 **** <td align="<?php echo($cellAlign); ?>" valign="top" class="chatCell" nowrap="nowrap"><?php echo(L_REG_1); ?> :</td> <td valign="top" class="chatCell" nowrap="nowrap"> ! <input type="password" name="password" size="11" maxlength="16" class="chatBox" /> <?php if (!C_REQUIRE_REGISTER) --- 861,865 ---- <td align="<?php echo($cellAlign); ?>" valign="top" class="chatCell" nowrap="nowrap"><?php echo(L_REG_1); ?> :</td> <td valign="top" class="chatCell" nowrap="nowrap"> ! <input type="password" name="pmcPassword" size="11" maxlength="16" class="chatBox" /> <?php if (!C_REQUIRE_REGISTER) *************** *** 928,932 **** echo("\n"); ! $dbLink->query("SELECT DISTINCT room FROM " . C_MSG_TBL . " WHERE type = 1 AND username NOT LIKE 'SYS %' ORDER BY room"); while (list($room) = $dbLink->nextRecord()) { --- 984,988 ---- echo("\n"); ! $dbLink->query("SELECT DISTINCT msg.room FROM " . C_MSG_TBL . " msg, " . C_ROOM_TBL . " rm WHERE (msg.room = rm.room_name AND rm.room_type = 1) AND msg.username NOT LIKE 'SYS %' ORDER BY room"); while (list($room) = $dbLink->nextRecord()) { Index: msg_validation.lib.js =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/index_libs/msg_validation.lib.js,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** msg_validation.lib.js 2001/04/27 18:27:22 1.3 --- msg_validation.lib.js 2001/06/10 14:57:48 1.4 *************** *** 29,52 **** validCmds[0] = /^\/!$/; validCmds[1] = /^\/announce (.+)$/i; ! validCmds[2] = /^\/ban (\* )?(.{1,30})$/i; ! validCmds[3] = (jsIsVersion4) ? /^\/clear$/i : ''; ! validCmds[4] = /^\/(help|\?)$/i; ! validCmds[5] = /^\/ignore( -)?( (.+))?$/i; ! validCmds[6] = /^\/img$/i; ! validCmds[7] = /^\/invite( (.+))+$/i; ! validCmds[8] = /^\/join ((0|1) )?#(.{1,30})$/i; ! validCmds[9] = /^\/kick (.{1,30})$/i; ! validCmds[10] = /^\/me (.+)$/i; ! validCmds[11] = /^\/(msg|to) ([^ ]{1,30}) (.+)$/i; ! validCmds[12] = /^\/notify$/i; ! validCmds[13] = (jsIsVersion4) ? '' : /^\/order$/i; ! validCmds[14] = /^\/profile$/i; ! validCmds[15] = /^\/promote (.{1,30})$/i; ! validCmds[16] = /^\/(quit|exit|bye)( (.+))?$/i; ! validCmds[17] = /^\/refresh( ([0-9]*))?$/i; ! validCmds[18] = /^\/save( ([0-9]*))?$/i; ! validCmds[19] = /^\/(show|last)( ([0-9]+))?$/i; ! validCmds[20] = /^\/timestamp$/i; ! validCmds[21] = /^\/whois (.{1,30})$/i; --- 29,53 ---- validCmds[0] = /^\/!$/; validCmds[1] = /^\/announce (.+)$/i; ! validCmds[2] = /^\/away( (.+))?$/i; ! validCmds[3] = /^\/ban (\* )?(.{1,30})$/i; ! validCmds[4] = (jsIsVersion4) ? /^\/clear$/i : ''; ! validCmds[5] = /^\/(help|\?)$/i; ! validCmds[6] = /^\/ignore( -)?( (.+))?$/i; ! validCmds[7] = /^\/img$/i; ! validCmds[8] = /^\/invite( (.+))+$/i; ! validCmds[9] = /^\/join ((0|1) )?#(.{1,30})$/i; ! validCmds[10] = /^\/kick (.{1,30})$/i; ! validCmds[11] = /^\/me (.+)$/i; ! validCmds[12] = /^\/(msg|to) ([^ ]{1,30}) (.+)$/i; ! validCmds[13] = /^\/notify$/i; ! validCmds[14] = (jsIsVersion4) ? '' : /^\/order$/i; ! validCmds[15] = /^\/profile$/i; ! validCmds[16] = /^\/promote (.{1,30})$/i; ! validCmds[17] = /^\/(quit|exit|bye)( (.+))?$/i; ! validCmds[18] = /^\/refresh( ([0-9]*))?$/i; ! validCmds[19] = /^\/save( ([0-9]*))?$/i; ! validCmds[20] = /^\/(show|last)( ([0-9]+))?$/i; ! validCmds[21] = /^\/timestamp$/i; ! validCmds[22] = /^\/whois (.{1,30})$/i; Index: start_page.lib.js =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/index_libs/start_page.lib.js,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** start_page.lib.js 2001/05/30 08:11:45 1.11 --- start_page.lib.js 2001/06/10 14:57:48 1.12 *************** *** 222,230 **** { // The replace function (js1.2) isn't supported -> no js tests are done ! if (typeof(document.forms['startingForm'].elements['nick'].value.replace) == 'undefined') return true; ! var nickField = document.forms['startingForm'].elements['nick']; ! var pswdField = document.forms['startingForm'].elements['password']; var roomToCreate = document.forms['startingForm'].elements['createRoomName']; var reNick = /\\|,| /; --- 222,230 ---- { // The replace function (js1.2) isn't supported -> no js tests are done ! if (typeof(document.forms['startingForm'].elements['pmcNick'].value.replace) == 'undefined') return true; ! var nickField = document.forms['startingForm'].elements['pmcNick']; ! var pswdField = document.forms['startingForm'].elements['pmcPassword']; var roomToCreate = document.forms['startingForm'].elements['createRoomName']; var reNick = /\\|,| /; |