From: Sergei I. G. <si...@pr...> - 2002-11-18 07:11:04
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib In directory sc8-pr-cvs1:/tmp/cvs-serv3909/chat/lib Modified Files: clean.lib.php3 format_messages.lib.php3 swearing.lib.php3 Log Message: Modify clean.lib.php3 to be less CPU/SQL usage when delete old messages. Remove reset($swearings) in swearing.lib.php3 Index: clean.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/clean.lib.php3,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** clean.lib.php3 10 Dec 2001 22:53:40 -0000 1.6 --- clean.lib.php3 18 Nov 2002 07:11:00 -0000 1.7 *************** *** 70,74 **** * Clean the messages and the rooms tables */ ! $chatClean->query("DELETE FROM " . C_MSG_TBL . " WHERE m_time < " . ($delTime - C_MSG_DEL * 60 * 60)); $chatClean->query("DELETE FROM " . C_ROOM_TBL . " WHERE last_user_modif < " . ($delTime - ((C_MSG_DEL + 1) * 60 * 60))); $chatClean->close(); --- 70,85 ---- * Clean the messages and the rooms tables */ ! ! $lastCleaning = (defined('_CHAT_PATH') ? _CHAT_PATH : '') . 'cache/cleaned.cache'; ! if (!file_exists($lastCleaning) ! || (filemtime($lastCleaning) + C_DB_OPT_DELAY*60*60 < time())) ! { ! $chatClean->query("DELETE FROM " . C_MSG_TBL . " WHERE m_time < " . ($delTime - C_MSG_DEL * 60 * 60)); ! ! // Update the modification time of the optimization cache file (create ! // it if it doesn't exist) ! $tmp = @touch($lastCleaning); ! } ! $chatClean->query("DELETE FROM " . C_ROOM_TBL . " WHERE last_user_modif < " . ($delTime - ((C_MSG_DEL + 1) * 60 * 60))); $chatClean->close(); Index: format_messages.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/format_messages.lib.php3,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** format_messages.lib.php3 10 Dec 2001 22:53:40 -0000 1.13 --- format_messages.lib.php3 18 Nov 2002 07:11:00 -0000 1.14 *************** *** 41,49 **** // 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'; } } // end of the 'pmcCheckColor()' function --- 41,53 ---- // Red colors are reserved to the admin or a moderator for the current room ! if ((eregi('#(FF0000|fc403f|fc4b34|fa582a|f66421|f27119|ec7e11|ec117f|f21971|f62164|fa2a58|fc344b)', $theColor)) && $dbSessionVars['status'] < 3) { $theColor = '#000000'; } + elseif (!eregi('#[0-9A-F]{6}', $theColor)) + { + $theColor = '#FFFFFF'; + } } // end of the 'pmcCheckColor()' function *************** *** 58,61 **** --- 62,68 ---- function pmcCheckLinks(&$str) { + // Protect from malicious html injection + $str = htmlspecialchars($str, ENT_QUOTES); + // Handle urls and 'news:' links $urlPattern = '(^| )(([^ ]+://[^ ]+)|(news:[^ ]+))( |$)'; *************** *** 64,68 **** // Handle e-mail address ! $emailPattern = '(^| )((mailto:)|())([^ ]+@[^ ]+)( |$)'; $str = eregi_replace($emailPattern, '\\1<a href="mailto:\\5" target="_blank">\\2\\5</a>\\6', $str); } // end of the 'pmcCheckLinks()' function --- 71,75 ---- // Handle e-mail address ! $emailPattern = '(^| )((mailto:)|())([^ ]+@[^ ]+)( |$)'; $str = eregi_replace($emailPattern, '\\1<a href="mailto:\\5" target="_blank">\\2\\5</a>\\6', $str); } // end of the 'pmcCheckLinks()' function Index: swearing.lib.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/swearing.lib.php3,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** swearing.lib.php3 10 Dec 2001 22:53:40 -0000 1.10 --- swearing.lib.php3 18 Nov 2002 07:11:01 -0000 1.11 *************** *** 94,98 **** $found = FALSE; $swearingsCnt = count($swearings); - reset($swearings); for ($i = 0; $i < $swearingsCnt; $i++) { --- 94,97 ---- |