From: Lo?c C. <lo...@us...> - 2001-04-14 17:51:50
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat In directory usw-pr-cvs1:/tmp/cvs-serv8837/chat Modified Files: whois_popup.php3 users_popup_low.php3 users_popup.php3 users_low.php3 users.php3 save.php3 messages_low.php3 loader.php3 input.php3 ignore_popup.php3 handle_input.php3 exit.php3 Log Message: Optimzed some db links Index: whois_popup.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/whois_popup.php3,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** whois_popup.php3 2001/04/13 11:42:08 1.8 --- whois_popup.php3 2001/04/14 17:51:47 1.9 *************** *** 60,63 **** --- 60,66 ---- ); dbSessionStart(); + // Session musn't be saved by this script -> close the db link + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** Index: users_popup_low.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/users_popup_low.php3,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** users_popup_low.php3 2001/04/14 16:05:06 1.7 --- users_popup_low.php3 2001/04/14 17:51:47 1.8 *************** *** 57,60 **** --- 57,63 ---- ); dbSessionStart(); + // Session musn't be saved by this script -> close the db link + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** *************** *** 87,96 **** /** ! * Defines the room to be checked from the database including the private room ! * the user may be chatting into. * * The 'pmcSlashSingleQuotes()' function is defined in the * 'chat/lib/common.lib.php3' script. */ $roomQueryPart = (dbSessionIsRegistered('currentRoom') && $dbSessionVars['roomType'] == 0) ? '(m.type = 1 OR (m.type = 0 AND m.room =\'' . pmcSlashSingleQuotes($dbSessionVars['currentRoom']) . '\'))' --- 90,100 ---- /** ! * Initialize a db link and defines the rooms to be checked from the database ! * including the private room the user may be chatting into. * * The 'pmcSlashSingleQuotes()' function is defined in the * 'chat/lib/common.lib.php3' script. */ + $dbLink = new pmcDB; $roomQueryPart = (dbSessionIsRegistered('currentRoom') && $dbSessionVars['roomType'] == 0) ? '(m.type = 1 OR (m.type = 0 AND m.room =\'' . pmcSlashSingleQuotes($dbSessionVars['currentRoom']) . '\'))' *************** *** 119,129 **** . 'ORDER BY m.m_time DESC ' . 'LIMIT 1'; ! $beepDbLink = new pmcDB; ! $beepDbLink->query($beepQuery); ! $doBeep = (list($newLastCheck) = $beepDbLink->nextRecord()); if ($doBeep) $lastCheck = $newLastCheck; ! $beepDbLink->cleanResults(); ! $beepDbLink->close(); } --- 123,131 ---- . 'ORDER BY m.m_time DESC ' . 'LIMIT 1'; ! $dbLink->query($beepQuery); ! $doBeep = (list($newLastCheck) = $dbLink->nextRecord()); if ($doBeep) $lastCheck = $newLastCheck; ! $dbLink->cleanResults(); } *************** *** 177,185 **** $allRooms = array(); ! $getRoomsDb = new pmcDB; ! $getRoomsDb->query("SELECT DISTINCT u.room FROM " . C_USR_TBL . " u, " . C_MSG_TBL . " m WHERE u.room = m.room AND " . $roomQueryPart); ! while (list($aRoom) = $getRoomsDb->nextRecord()) $allRooms[pmcHandleMagicQuotes($aRoom, '', 1, 'del')] = ''; ! $getRoomsDb->cleanResults(); $filteredAllRooms = array(); --- 179,186 ---- $allRooms = array(); ! $dbLink->query("SELECT DISTINCT u.room FROM " . C_USR_TBL . " u, " . C_MSG_TBL . " m WHERE u.room = m.room AND " . $roomQueryPart); ! while (list($aRoom) = $dbLink->nextRecord()) $allRooms[pmcHandleMagicQuotes($aRoom, '', 1, 'del')] = ''; ! $dbLink->cleanResults(); $filteredAllRooms = array(); *************** *** 189,194 **** $usersDetails = array(); $slashedRoom = pmcSlashSingleQuotes($roomName); ! $getRoomsDb->query("SELECT username, latin1, status FROM " . C_USR_TBL . " WHERE room = '" . $slashedRoom ."' ORDER BY username"); ! while (list($anUser, $latin1, $status) = $getRoomsDb->nextRecord()) { $usersDetails[] = array( pmcHandleMagicQuotes($anUser, '', 1, 'del'), --- 190,195 ---- $usersDetails = array(); $slashedRoom = pmcSlashSingleQuotes($roomName); ! $dbLink->query("SELECT username, latin1, status FROM " . C_USR_TBL . " WHERE room = '" . $slashedRoom ."' ORDER BY username"); ! while (list($anUser, $latin1, $status) = $dbLink->nextRecord()) { $usersDetails[] = array( pmcHandleMagicQuotes($anUser, '', 1, 'del'), *************** *** 197,206 **** ); } ! $getRoomsDb->cleanResults(); if (count($usersDetails) > 0) $filteredAllRooms[$roomName] = $usersDetails; unset($usersDetails); } - $getRoomsDb->close(); $allRooms = $filteredAllRooms; unset($roomName); --- 198,206 ---- ); } ! $dbLink->cleanResults(); if (count($usersDetails) > 0) $filteredAllRooms[$roomName] = $usersDetails; unset($usersDetails); } $allRooms = $filteredAllRooms; unset($roomName); *************** *** 246,249 **** --- 246,256 ---- $usersList[] = '<center>' . L_NO_USER . '</center>'; } // end of the case when no user is chatting + + + /** + * Kill the opened database link + */ + $dbLink->close(); + unset($dbLink); Index: users_popup.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/users_popup.php3,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** users_popup.php3 2001/04/14 16:05:06 1.7 --- users_popup.php3 2001/04/14 17:51:47 1.8 *************** *** 56,59 **** --- 56,62 ---- ); dbSessionStart(); + // Session musn't be saved by this script -> close the db link + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** *************** *** 86,95 **** /** ! * Defines the room to be checked from the database including the private room ! * the user may be chatting into. * * The 'pmcSlashSingleQuotes()' function is defined in the * 'chat/lib/common.lib.php3' script. */ $roomQueryPart = (dbSessionIsRegistered('currentRoom') && $dbSessionVars['roomType'] == 0) ? '(m.type = 1 OR (m.type = 0 AND m.room =\'' . pmcSlashSingleQuotes($dbSessionVars['currentRoom']) . '\'))' --- 89,99 ---- /** ! * Initialize a db link and defines the rooms to be checked from the database ! * including the private room the user may be chatting into. * * The 'pmcSlashSingleQuotes()' function is defined in the * 'chat/lib/common.lib.php3' script. */ + $dbLink = new pmcDB; $roomQueryPart = (dbSessionIsRegistered('currentRoom') && $dbSessionVars['roomType'] == 0) ? '(m.type = 1 OR (m.type = 0 AND m.room =\'' . pmcSlashSingleQuotes($dbSessionVars['currentRoom']) . '\'))' *************** *** 118,128 **** . 'ORDER BY m.m_time DESC ' . 'LIMIT 1'; ! $beepDbLink = new pmcDB; ! $beepDbLink->query($beepQuery); ! $doBeep = (list($newLastCheck) = $beepDbLink->nextRecord()); if ($doBeep) $lastCheck = $newLastCheck; ! $beepDbLink->cleanResults(); ! $beepDbLink->close(); } --- 122,130 ---- . 'ORDER BY m.m_time DESC ' . 'LIMIT 1'; ! $dbLink->query($beepQuery); ! $doBeep = (list($newLastCheck) = $dbLink->nextRecord()); if ($doBeep) $lastCheck = $newLastCheck; ! $dbLink->cleanResults(); } *************** *** 176,184 **** $allRooms = array(); ! $getRoomsDb = new pmcDB; ! $getRoomsDb->query("SELECT DISTINCT u.room FROM " . C_USR_TBL . " u, " . C_MSG_TBL . " m WHERE u.room = m.room AND " . $roomQueryPart); ! while (list($aRoom) = $getRoomsDb->nextRecord()) $allRooms[pmcHandleMagicQuotes($aRoom, '', 1, 'del')] = ''; ! $getRoomsDb->cleanResults(); $filteredAllRooms = array(); --- 178,185 ---- $allRooms = array(); ! $dbLink->query("SELECT DISTINCT u.room FROM " . C_USR_TBL . " u, " . C_MSG_TBL . " m WHERE u.room = m.room AND " . $roomQueryPart); ! while (list($aRoom) = $dbLink->nextRecord()) $allRooms[pmcHandleMagicQuotes($aRoom, '', 1, 'del')] = ''; ! $dbLink->cleanResults(); $filteredAllRooms = array(); *************** *** 188,193 **** $usersDetails = array(); $slashedRoom = pmcSlashSingleQuotes($roomName); ! $getRoomsDb->query("SELECT username, latin1, status FROM " . C_USR_TBL . " WHERE room = '" . $slashedRoom ."' ORDER BY username"); ! while (list($anUser, $latin1, $status) = $getRoomsDb->nextRecord()) { $usersDetails[] = array( pmcHandleMagicQuotes($anUser, '', 1, 'del'), --- 189,194 ---- $usersDetails = array(); $slashedRoom = pmcSlashSingleQuotes($roomName); ! $dbLink->query("SELECT username, latin1, status FROM " . C_USR_TBL . " WHERE room = '" . $slashedRoom ."' ORDER BY username"); ! while (list($anUser, $latin1, $status) = $dbLink->nextRecord()) { $usersDetails[] = array( pmcHandleMagicQuotes($anUser, '', 1, 'del'), *************** *** 196,205 **** ); } ! $getRoomsDb->cleanResults(); if (count($usersDetails) > 0) $filteredAllRooms[$roomName] = $usersDetails; unset($usersDetails); } - $getRoomsDb->close(); $allRooms = $filteredAllRooms; unset($roomName); --- 197,205 ---- ); } ! $dbLink->cleanResults(); if (count($usersDetails) > 0) $filteredAllRooms[$roomName] = $usersDetails; unset($usersDetails); } $allRooms = $filteredAllRooms; unset($roomName); *************** *** 254,257 **** --- 254,264 ---- $usersList[] = '<center>' . L_NO_USER . '</center>'; } // end of the case when no user is chatting + + + /** + * Kill the opened database link + */ + $dbLink->close(); + unset($dbLink); Index: users_low.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/users_low.php3,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** users_low.php3 2001/04/14 16:05:06 1.8 --- users_low.php3 2001/04/14 17:51:47 1.9 *************** *** 54,57 **** --- 54,60 ---- ); dbSessionStart(); + // Session musn't be saved by this script -> close the db link + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** *************** *** 103,106 **** --- 106,110 ---- $slashedCurrentRoomName = pmcSlashSingleQuotes($dbSessionVars['currentRoom']); $usersList = array(); + $dbLink = new pmcDB; *************** *** 147,153 **** . '</span><br />'; ! $currentRoomDb = new pmcDB; ! $currentRoomDb->query($currentRoomQuery); ! while (list($username, $latin1, $status, $gender) = $currentRoomDb->nextRecord()) { $usersCnt++; --- 151,156 ---- . '</span><br />'; ! $dbLink->query($currentRoomQuery); ! while (list($username, $latin1, $status, $gender) = $dbLink->nextRecord()) { $usersCnt++; *************** *** 192,197 **** $usersList[] = "\t" . $tmpStr; } ! $currentRoomDb->cleanResults(); ! $currentRoomDb->close(); $usersList[] = '</p>'; --- 195,200 ---- $usersList[] = "\t" . $tmpStr; } ! $dbLink->cleanResults(); ! unset($tmpStr); $usersList[] = '</p>'; *************** *** 237,245 **** $othersRooms = array(); ! $otherRoomDb = new pmcDB; ! $otherRoomDb->query("SELECT DISTINCT room FROM " . C_MSG_TBL . " WHERE room != '$slashedCurrentRoomName' AND type = 1 ORDER BY room"); ! while (list($otherRoom) = $otherRoomDb->nextRecord()) $othersRooms[pmcHandleMagicQuotes($otherRoom, '', 1, 'del')] = ''; ! $otherRoomDb->cleanResults(); $filteredOtherRooms = array(); reset($othersRooms); --- 240,247 ---- $othersRooms = array(); ! $dbLink->query("SELECT DISTINCT room FROM " . C_MSG_TBL . " WHERE room != '$slashedCurrentRoomName' AND type = 1 ORDER BY room"); ! while (list($otherRoom) = $dbLink->nextRecord()) $othersRooms[pmcHandleMagicQuotes($otherRoom, '', 1, 'del')] = ''; ! $dbLink->cleanResults(); $filteredOtherRooms = array(); reset($othersRooms); *************** *** 248,253 **** $usersDetails = array(); $slashedOther = pmcSlashSingleQuotes($roomName); ! $otherRoomDb->query(str_replace('%OTHER%', $slashedOther, $otherRoomsQuery)); ! while (list($otherUser, $latin1, $status, $gender) = $otherRoomDb->nextRecord()) { $usersDetails[] = array( pmcHandleMagicQuotes($otherUser, '', 1, 'del'), --- 250,255 ---- $usersDetails = array(); $slashedOther = pmcSlashSingleQuotes($roomName); ! $dbLink->query(str_replace('%OTHER%', $slashedOther, $otherRoomsQuery)); ! while (list($otherUser, $latin1, $status, $gender) = $dbLink->nextRecord()) { $usersDetails[] = array( pmcHandleMagicQuotes($otherUser, '', 1, 'del'), *************** *** 257,266 **** ); } ! $otherRoomDb->cleanResults(); if (count($usersDetails) > 0) $filteredOtherRooms[$roomName] = $usersDetails; unset($usersDetails); } - $otherRoomDb->close(); $othersRooms = $filteredOtherRooms; unset($roomName); --- 259,267 ---- ); } ! $dbLink->cleanResults(); if (count($usersDetails) > 0) $filteredOtherRooms[$roomName] = $usersDetails; unset($usersDetails); } $othersRooms = $filteredOtherRooms; unset($roomName); *************** *** 329,332 **** --- 330,340 ---- unset($othersRooms); + + + /** + * Kill the opened database link + */ + $dbLink->close(); + unset($dbLink); Index: users.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/users.php3,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** users.php3 2001/04/14 16:05:06 1.12 --- users.php3 2001/04/14 17:51:47 1.13 *************** *** 53,56 **** --- 53,59 ---- ); dbSessionStart(); + // Session musn't be saved by this script -> close the db link + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** *************** *** 102,105 **** --- 105,109 ---- $slashedCurrentRoomName = pmcSlashSingleQuotes($dbSessionVars['currentRoom']); $usersList = array(); + $dbLink = new pmcDB; *************** *** 146,152 **** $usersList[] = '<div style="margin-bottom: 10px">'; ! $currentRoomDb = new pmcDB; ! $currentRoomDb->query($currentRoomQuery); ! while (list($username, $latin1, $status, $gender) = $currentRoomDb->nextRecord()) { $usersCnt++; --- 150,155 ---- $usersList[] = '<div style="margin-bottom: 10px">'; ! $dbLink->query($currentRoomQuery); ! while (list($username, $latin1, $status, $gender) = $dbLink->nextRecord()) { $usersCnt++; *************** *** 191,196 **** $usersList[] = "\t" . $tmpStr; } ! $currentRoomDb->cleanResults(); ! $currentRoomDb->close(); $usersList[] = '</div>'; --- 194,199 ---- $usersList[] = "\t" . $tmpStr; } ! $dbLink->cleanResults(); ! unset($tmpStr); $usersList[] = '</div>'; *************** *** 236,244 **** $othersRooms = array(); ! $otherRoomDb = new pmcDB; ! $otherRoomDb->query("SELECT DISTINCT room FROM " . C_MSG_TBL . " WHERE room != '$slashedCurrentRoomName' AND type = 1 ORDER BY room"); ! while (list($otherRoom) = $otherRoomDb->nextRecord()) $othersRooms[pmcHandleMagicQuotes($otherRoom, '', 1, 'del')] = ''; ! $otherRoomDb->cleanResults(); $filteredOtherRooms = array(); reset($othersRooms); --- 239,246 ---- $othersRooms = array(); ! $dbLink->query("SELECT DISTINCT room FROM " . C_MSG_TBL . " WHERE room != '$slashedCurrentRoomName' AND type = 1 ORDER BY room"); ! while (list($otherRoom) = $dbLink->nextRecord()) $othersRooms[pmcHandleMagicQuotes($otherRoom, '', 1, 'del')] = ''; ! $dbLink->cleanResults(); $filteredOtherRooms = array(); reset($othersRooms); *************** *** 247,252 **** $usersDetails = array(); $slashedOther = pmcSlashSingleQuotes($roomName); ! $otherRoomDb->query(str_replace('%OTHER%', $slashedOther, $otherRoomsQuery)); ! while (list($otherUser, $latin1, $status, $gender) = $otherRoomDb->nextRecord()) { $usersDetails[] = array( pmcHandleMagicQuotes($otherUser, '', 1, 'del'), --- 249,254 ---- $usersDetails = array(); $slashedOther = pmcSlashSingleQuotes($roomName); ! $dbLink->query(str_replace('%OTHER%', $slashedOther, $otherRoomsQuery)); ! while (list($otherUser, $latin1, $status, $gender) = $dbLink->nextRecord()) { $usersDetails[] = array( pmcHandleMagicQuotes($otherUser, '', 1, 'del'), *************** *** 256,265 **** ); } ! $otherRoomDb->cleanResults(); if (count($usersDetails) > 0) $filteredOtherRooms[$roomName] = $usersDetails; unset($usersDetails); } - $otherRoomDb->close(); $othersRooms = $filteredOtherRooms; unset($roomName); --- 258,266 ---- ); } ! $dbLink->cleanResults(); if (count($usersDetails) > 0) $filteredOtherRooms[$roomName] = $usersDetails; unset($usersDetails); } $othersRooms = $filteredOtherRooms; unset($roomName); *************** *** 337,340 **** --- 338,348 ---- unset($othersRooms); + + + /** + * Kill the opened database link + */ + $dbLink->close(); + unset($dbLink); Index: save.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/save.php3,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** save.php3 2001/04/14 16:05:06 1.2 --- save.php3 2001/04/14 17:51:47 1.3 *************** *** 58,61 **** --- 58,63 ---- ); dbSessionStart(); + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** *************** *** 118,121 **** --- 120,124 ---- $dbLink->cleanResults(); $dbLink->close(); + unset($dbLink); Index: messages_low.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/messages_low.php3,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** messages_low.php3 2001/04/14 16:05:06 1.8 --- messages_low.php3 2001/04/14 17:51:47 1.9 *************** *** 58,61 **** --- 58,63 ---- dbSessionStart(); dbSessionUpdateLogTime(); + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** *************** *** 131,134 **** --- 133,137 ---- $dbLink->cleanResults(); $dbLink->close(); + unset($dbLink); Index: loader.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/loader.php3,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** loader.php3 2001/04/14 16:05:06 1.9 --- loader.php3 2001/04/14 17:51:47 1.10 *************** *** 70,73 **** --- 70,75 ---- dbSessionUpdateLogTime(); } + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** *************** *** 184,187 **** --- 186,190 ---- $dbLink->cleanResults(); $dbLink->close(); + unset($dbLink); Index: input.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/input.php3,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** input.php3 2001/04/14 16:05:06 1.17 --- input.php3 2001/04/14 17:51:47 1.18 *************** *** 68,72 **** ); dbSessionStart(); - dbSessionUpdateLogTime(); /** --- 68,71 ---- *************** *** 164,168 **** // The db link should be closed but this can't be done under Apache because // links id aren't updated :( ! $dbLink->close(); } // end of handle submitted message --- 163,168 ---- // The db link should be closed but this can't be done under Apache because // links id aren't updated :( ! // $dbLink->close(); ! // unset($dbLink); } // end of handle submitted message *************** *** 173,177 **** dbSessionSave(); $dbSessionDbLink->close(); ! --- 173,177 ---- dbSessionSave(); $dbSessionDbLink->close(); ! unset($dbSessionDbLink); Index: ignore_popup.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/ignore_popup.php3,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ignore_popup.php3 2001/04/14 16:05:06 1.3 --- ignore_popup.php3 2001/04/14 17:51:47 1.4 *************** *** 56,59 **** --- 56,62 ---- ); dbSessionStart(); + // Session musn't be saved by this script -> close the db link + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** Index: handle_input.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/handle_input.php3,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** handle_input.php3 2001/04/14 16:05:06 1.15 --- handle_input.php3 2001/04/14 17:51:47 1.16 *************** *** 73,80 **** exit(); } - else - { - dbSessionUpdateLogTime(); - } /** --- 73,76 ---- *************** *** 173,177 **** // The db link should be closed but this can't be done under Apache because // links id aren't updated :( ! // $dbLink->close(); } // end of handle submitted message --- 169,174 ---- // The db link should be closed but this can't be done under Apache because // links id aren't updated :( ! // $dbLink->close(); ! // unset($dbLink); } // end of handle submitted message *************** *** 182,186 **** dbSessionSave(); $dbSessionDbLink->close(); ! --- 179,183 ---- dbSessionSave(); $dbSessionDbLink->close(); ! unset($dbSessionDbLink); Index: exit.php3 =================================================================== RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/exit.php3,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** exit.php3 2001/04/12 23:45:34 1.8 --- exit.php3 2001/04/14 17:51:47 1.9 *************** *** 34,38 **** require('./lib/common.lib.' . C_EXTENSION); require('./lib/database/' . C_DB_TYPE . '.lib.' . C_EXTENSION); - require('./lib/clean.lib.' . C_EXTENSION); /** --- 34,37 ---- *************** *** 56,59 **** --- 55,61 ---- ); dbSessionStart(); + // Session musn't be saved by this script -> close the db link + $dbSessionDbLink->close(); + unset($dbSessionDbLink); /** |