From: Lo?c C. <lo...@us...> - 2001-12-04 20:01:07
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib In directory usw-pr-cvs1:/tmp/cvs-serv14795/chat/lib Modified Files: commands.lib.php3 format_messages.lib.php3 get_user_infos.lib.php3 Log Message: Begin right levels improvement Index: commands.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/commands.lib.php3,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** commands.lib.php3 2001/06/10 14:57:47 1.10 --- commands.lib.php3 2001/12/04 20:01:04 1.11 *************** *** 41,142 **** && !empty($prevMessage)) { ! include('./lib/commands/history.cmd.' . C_EXTENSION); } else if (eregi('^\/announce[[:space:]](.+)$', $message, $cmd)) { ! include('./lib/commands/announce.cmd.' . C_EXTENSION); } else if (eregi('^\/away([[:space:]](.+))?$', $message, $cmd)) { ! include('./lib/commands/away.cmd.' . C_EXTENSION); } else if (C_BANISH && eregi('^\/ban[[:space:]](\*[[:space:]])?(.{1,30})$', $message, $cmd)) { ! include('./lib/commands/banish.cmd.' . C_EXTENSION); } else if (strcasecmp('/clear', $message) == 0 && $dbSessionVars['jsVersion'] == 'high') { ! include('./lib/commands/clear.cmd.' . C_EXTENSION); } else if ('/?' == $message || strcasecmp('/help', $message) == 0) { ! include('./lib/commands/help.cmd.' . C_EXTENSION); } else if (eregi('^\/ignore([[:space:]]\\-)?([[:space:]](.+))?$', $message, $cmd)) { ! include('./lib/commands/ignore.cmd.' . C_EXTENSION); } else if (strcasecmp('/img', $message) == 0) { ! include('./lib/commands/img.cmd.' . C_EXTENSION); } else if (eregi('^\/invite([[:space:]](.+))+$', $message, $cmd)) { ! include('./lib/commands/invite.cmd.' . C_EXTENSION); } else if (0 < C_VERSION && eregi('^\/join[[:space:]]((0|1)[[:space:]])?#(.{1,30})$', $message, $cmd)) { ! include('./lib/commands/join.cmd.' . C_EXTENSION); } else if (eregi('^\/kick[[:space:]](.{1,30})$', $message, $cmd)) { ! include('./lib/commands/kick.cmd.' . C_EXTENSION); } else if (eregi('^\/me[[:space:]](.+)$', $message, $cmd)) { ! include('./lib/commands/me.cmd.' . C_EXTENSION); } else if (eregi('^\/(msg|to)[[:space:]]([^[:space:]]{1,30})[[:space:]](.+)$', $message, $cmd)) { ! include('./lib/commands/priv_msg.cmd.' . C_EXTENSION); } else if (strcasecmp('/notify', $message) == 0) { ! include('./lib/commands/notify.cmd.' . C_EXTENSION); } else if (strcasecmp('/order', $message) == 0 && $dbSessionVars['jsVersion'] != 'high') { ! include('./lib/commands/order.cmd.' . C_EXTENSION); } else if (strcasecmp('/profile', $message) == 0) { ! include('./lib/commands/profile.cmd.' . C_EXTENSION); } else if (eregi('^\/promote[[:space:]](.{1,30})$', $message, $cmd)) { ! include('./lib/commands/promote.cmd.' . C_EXTENSION); } else if (eregi('^\/(quit|exit|bye)([[:space:]](.+))?$', $message, $cmd)) { ! include('./lib/commands/quit.cmd.' . C_EXTENSION); } else if (eregi('^\/refresh([[:space:]]([[:digit:]]*))?$', $message, $cmd)) { ! include('./lib/commands/refresh.cmd.' . C_EXTENSION); } else if ('0' != C_SAVE && eregi('^\/save([[:space:]]([[:digit:]]*))?$', $message, $cmd) ! && ($cmd[2] == '' OR $cmd[2] > 0)) { ! include('./lib/commands/save.cmd.' . C_EXTENSION); } else if (eregi('^\/(show|last)([[:space:]]([[:digit:]]+))?$', $message, $cmd)) { ! include('./lib/commands/show.cmd.' . C_EXTENSION); } else if (strcasecmp('/timestamp', $message) == 0) { ! include('./lib/commands/timestamp.cmd.' . C_EXTENSION); } else if (eregi('^\/whois[[:space:]](.{1,30})$', $message, $cmd)) { ! include('./lib/commands/whois.cmd.' . C_EXTENSION); } if (!$isCommand && empty($error)) { --- 41,168 ---- && !empty($prevMessage)) { ! $cmdLib = 'history'; } else if (eregi('^\/announce[[:space:]](.+)$', $message, $cmd)) { ! $cmdLib = 'announce'; } else if (eregi('^\/away([[:space:]](.+))?$', $message, $cmd)) { ! $cmdLib = 'away'; } else if (C_BANISH && eregi('^\/ban[[:space:]](\*[[:space:]])?(.{1,30})$', $message, $cmd)) { ! $cmdLib = 'banish'; } else if (strcasecmp('/clear', $message) == 0 && $dbSessionVars['jsVersion'] == 'high') { ! $cmdLib = 'clear'; } else if ('/?' == $message || strcasecmp('/help', $message) == 0) { ! $cmdLib = 'help'; } else if (eregi('^\/ignore([[:space:]]\\-)?([[:space:]](.+))?$', $message, $cmd)) { ! $cmdLib = 'ignore'; } else if (strcasecmp('/img', $message) == 0) { ! $cmdLib = 'img'; } else if (eregi('^\/invite([[:space:]](.+))+$', $message, $cmd)) { ! $cmdLib = 'invite'; } else if (0 < C_VERSION && eregi('^\/join[[:space:]]((0|1)[[:space:]])?#(.{1,30})$', $message, $cmd)) { ! $cmdLib = 'join'; } else if (eregi('^\/kick[[:space:]](.{1,30})$', $message, $cmd)) { ! $cmdLib = 'kick'; } else if (eregi('^\/me[[:space:]](.+)$', $message, $cmd)) { ! $cmdLib = 'me'; } else if (eregi('^\/(msg|to)[[:space:]]([^[:space:]]{1,30})[[:space:]](.+)$', $message, $cmd)) { ! $cmdLib = 'priv_msg'; } else if (strcasecmp('/notify', $message) == 0) { ! $cmdLib = 'notify'; } else if (strcasecmp('/order', $message) == 0 && $dbSessionVars['jsVersion'] != 'high') { ! $cmdLib = 'order'; } else if (strcasecmp('/profile', $message) == 0) { ! $cmdLib = 'profile'; } else if (eregi('^\/promote[[:space:]](.{1,30})$', $message, $cmd)) { ! $cmdLib = 'promote'; } else if (eregi('^\/(quit|exit|bye)([[:space:]](.+))?$', $message, $cmd)) { ! $cmdLib = 'quit'; } else if (eregi('^\/refresh([[:space:]]([[:digit:]]*))?$', $message, $cmd)) { ! $cmdLib = 'refresh'; } else if ('0' != C_SAVE && eregi('^\/save([[:space:]]([[:digit:]]*))?$', $message, $cmd) ! && ($cmd[2] == '' || $cmd[2] > 0)) { ! $cmdLib = 'save'; } else if (eregi('^\/(show|last)([[:space:]]([[:digit:]]+))?$', $message, $cmd)) { ! $cmdLib = 'show'; } else if (strcasecmp('/timestamp', $message) == 0) { ! $cmdLib = 'timestamp'; } else if (eregi('^\/whois[[:space:]](.{1,30})$', $message, $cmd)) { ! $cmdLib = 'whois'; } + else + { + $cmdLib = ''; + } + + + /** + * If the submission is a command, ensure the right level of the current user + * is high enough then include the corresponding library + */ + if (!empty($cmdLib)) + { + if (!empty($rightLevels['cmd_' . $cmdLib]) + && $dbSessionVars['status'] < $rightLevels['cmd_'. $cmdLib]) + { + $error = L_NO_RIGHT; + } + else + { + include('./lib/commands/' . $cmdLib . '.cmd.' . C_EXTENSION); + } + } + + /** + * If the submission is a invalid command or no error message is set, do it + */ if (!$isCommand && empty($error)) { Index: format_messages.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/format_messages.lib.php3,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** format_messages.lib.php3 2001/06/10 14:57:47 1.11 --- format_messages.lib.php3 2001/12/04 20:01:04 1.12 *************** *** 42,46 **** // Red colors are reserved to the admin or a moderator for the current room if ((ereg('#(FF0000|fc403f|fc4b34|fa582a|f66421|f27119|ec7e11|ec117f|f21971|f62164|fa2a58|fc344b)', $theColor)) ! && $dbSessionVars['status'] < 5) { $theColor = '#000000'; --- 42,46 ---- // Red colors are reserved to the admin or a moderator for the current room if ((ereg('#(FF0000|fc403f|fc4b34|fa582a|f66421|f27119|ec7e11|ec117f|f21971|f62164|fa2a58|fc344b)', $theColor)) ! && $dbSessionVars['status'] < 3) { $theColor = '#000000'; Index: get_user_infos.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/get_user_infos.lib.php3,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** get_user_infos.lib.php3 2001/11/29 22:00:56 1.5 --- get_user_infos.lib.php3 2001/12/04 20:01:04 1.6 *************** *** 205,208 **** --- 205,209 ---- * @global array the session data * @global boolean whether the user is a registered one or not + * @global integer the number of times the user logged in * @global string the slashed nick of the user * @global boolean whether the room has to be trully created or not *************** *** 217,220 **** --- 218,222 ---- global $dbSessionVars; global $isRegUser; + global $regUserLogTimes; global $slashedNick; global $isCreateRoom; *************** *** 228,236 **** return 0; } ! // 2. The user is the administrator else if ((dbSessionIsRegistered('nick') && $dbSessionVars['nick'] == $GLOBALS['pmcNick']) ! && (dbSessionIsRegistered('status') && $dbSessionVars['status'] == 10)) { ! return 10; } // 3. Other cases --- 230,238 ---- return 0; } ! // 2. The user is super-moderator, administrator or the owner else if ((dbSessionIsRegistered('nick') && $dbSessionVars['nick'] == $GLOBALS['pmcNick']) ! && (dbSessionIsRegistered('status') && $dbSessionVars['status'] > 5)) { ! return $dbSessionVars['status']; } // 3. Other cases *************** *** 250,254 **** else if (!$isCreateRoom) { ! return 1; } // end of 3.1 --- 252,256 ---- else if (!$isCreateRoom) { ! return ($regUserLogTimes > C_EXPERIENCED_LOGIN_TIMES) ? 2 : 1; } // end of 3.1 *************** *** 263,267 **** $dbLink->query("SELECT COUNT(*) FROM " . C_MSG_TBL . " WHERE room = '$slashedTargetRoomName' AND username NOT LIKE 'SYS %' LIMIT 1"); list($isTrueMsg) = $dbLink->nextRecord(); ! $tmpUserPerm = ($isTrueMsg == 0) ? 5 : 1; $dbLink->cleanResults(); if (!$isTrueMsg) --- 265,276 ---- $dbLink->query("SELECT COUNT(*) FROM " . C_MSG_TBL . " WHERE room = '$slashedTargetRoomName' AND username NOT LIKE 'SYS %' LIMIT 1"); list($isTrueMsg) = $dbLink->nextRecord(); ! if ($isTrueMsg == 0) ! { ! $tmpUserPerm = 4; ! } ! else ! { ! $tmpUserPerm = ($regUserLogTimes > C_EXPERIENCED_LOGIN_TIMES) ? 2 : 1; ! } $dbLink->cleanResults(); if (!$isTrueMsg) *************** *** 269,273 **** $dbLink->query("SELECT COUNT(*) FROM " . C_USR_TBL . " WHERE room = '$slashedTargetRoomName' AND username != '$slashedNick' LIMIT 1"); list($isAnybody) = $dbLink->nextRecord(); ! $tmpUserPerm = ($isAnybody == 0) ? 5 : 1; $dbLink->cleanResults(); } // end of true new room --- 278,289 ---- $dbLink->query("SELECT COUNT(*) FROM " . C_USR_TBL . " WHERE room = '$slashedTargetRoomName' AND username != '$slashedNick' LIMIT 1"); list($isAnybody) = $dbLink->nextRecord(); ! if ($isAnybody == 0) ! { ! $tmpUserPerm = 4; ! } ! else ! { ! $tmpUserPerm = ($regUserLogTimes > C_EXPERIENCED_LOGIN_TIMES) ? 2 : 1; ! } $dbLink->cleanResults(); } // end of true new room *************** *** 275,282 **** // The user will be moderator for this room -> update tables (note // that older moderators becomes 'simple users' for the target room) ! if ($tmpUserPerm == 5) { $dbLink->query("DELETE FROM " . C_RIGHT_TBL . " WHERE room = '$slashedTargetRoomName'"); ! $dbLink->query("INSERT INTO " . C_RIGHT_TBL . " (username, room, right_level) VALUES ('$slashedNick', '$slashedTargetRoomName', 5)"); } // end of updating the right level table --- 291,298 ---- // The user will be moderator for this room -> update tables (note // that older moderators becomes 'simple users' for the target room) ! if ($tmpUserPerm == 4) { $dbLink->query("DELETE FROM " . C_RIGHT_TBL . " WHERE room = '$slashedTargetRoomName'"); ! $dbLink->query("INSERT INTO " . C_RIGHT_TBL . " (username, room, right_level) VALUES ('$slashedNick', '$slashedTargetRoomName', 4)"); } // end of updating the right level table |