From: Lo?c C. <lo...@us...> - 2001-04-03 20:10:19
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/index_libs In directory usw-pr-cvs1:/tmp/cvs-serv3216/chat/lib/index_libs Added Files: connect_state.lib.js do_enter_db_work.lib.php3 do_enter_frameset.lib.php3 do_enter_js_work.lib.php3 help_popup.lib.js index_validation.lib.php3 Log Message: The first dev. version that works! Still many things to do, of course... --- NEW FILE --- // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | Set of JavaScript functions used to handle the connection state for the | // | 'standard' version of phpMyChat (the JavaScript loader is used). | // | | // | This library is called by the 'chat/lib/index_libs/main_index.lib.php3' | // | script. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: connect_state.lib.js,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // Handle the connection state for the 'standard' version of phpMyChat. // var jsImgConnectOff = new Image(13,13); jsImgConnectOff.src = jsChatPath + 'images/connect_off.gif'; var jsImgConnectOn = new Image(13,13); jsImgConnectOn.src = jsChatPath + 'images/connect_on.gif'; var jsImgConnectErr = new Image(13,13); jsImgConnectErr.src = jsChatPath + 'images/connect_error.gif'; var jsImgConnect = new Image(13,13); var jsLeaveChat = false; var jsConnect = 0; var jsIsConnecting = null; /** * Tries to connect twice if necessary and sets the icon for connection status * at the 'exit' frame * * @param numTry number of connection tries */ function pmcConnecting(numTry) { var exitFrm = window.frames['exit']; if (jsIsConnecting) clearTimeout(jsIsConnecting); jsConnect = numTry; if (numTry == 1 || numTry == 2) { jsImgConnect.src = jsImgConnectOn.src; } else if (numTry == 3) { jsImgConnect.src = jsImgConnectErr.src; } if (typeof(document.all) != 'undefined') { exitFrm.document.all['imgConState'].src = jsImgConnect.src; } else if (typeof(document.images) != 'undefined') { exitFrm.document.images['imgConState'].src = jsImgConnect.src; } else return; if (numTry < 3) { numTry = numTry + 1; jsIsConnecting = setTimeout('pmcConnecting(' + numTry + ')', 30000); } else { clearTimeout(jsIsConnecting); jsConnect = 0; } } // end of the 'pmcConnecting()' function /** * Kills the timeout defined in the 'pmcConnecting()' function to reconnect once * if the first connection failed, and sets the connection status icon to * 'done' in the exit frame */ function pmcConnectDone() { var exitFrm = window.frames['exit']; jsConnect = 0; if (jsIsConnecting) clearTimeout(jsIsConnecting); if (typeof(document.all) != 'undefined') { if (typeof(exitFrm.document.all['imgConState']) != 'undefined') exitFrm.document.all['imgConState'].src = jsImgConnectOff.src; } else if (typeof(document.images) != 'undefined') { if (typeof(exitFrm.document.images['imgConState']) != 'undefined') exitFrm.document.images['imgConState'].src = jsImgConnectOff.src; } else return; } // end of the 'pmcConnectDone()' function /** * Enforces a new connection try (used when the user click on the 'connection * status' icon at the exit frame) */ function pmcReConnect() { if (jsConnect != 1 && jsConnect != 2) { pmcConnecting(1); // The function below is defined inside the // 'chat/lib/index_libs/main_index.lib.php3' script pmcDoRefreshLoader(); } } // end of the 'pmcReConnect()' function --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This library contains all the database work to be done just before | // | entering the chat. | // | It is called by the 'chat/lib/index_libs/main_index.lib.php3' if the | // | validation of the settings submitted by an user succeeded. | // | | // | It uses the 'pmcGrabGlobals()', the 'pmcSlashSingleQuotes()' and the | // | 'pmcIsInto()' functions defined inside the 'chat/lib/common.lib.php3' | // | script. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: do_enter_db_work.lib.php3,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // Database work to do when the user is allowed to enter the chat. // // Harmonizes type and name of the room to enter in if (!empty($createRoomName)) { $targetRoom = $createRoomName; } else if (!isset($targetRoom)) // $targetRoom is set when the frameset is { // reloaded because of the NN4+ resize bug. $roomType = 1; $targetRoom = (!empty($enterDefaultRoomName)) ? $enterDefaultRoomName : $enterOtherRoomName; } // Sets cookies that will expire in one year $cookieRoom = urlencode($targetRoom); setcookie('cookieRoom', $cookieRoom, time() + 60*60*24*365); setcookie('cookieRoomType', $roomType, time() + 60*60*24*365); // Gets some variables values from session data or cookies pmcGrabGlobals('%COOKIE'); if (dbSessionIsRegistered('msgKind')) $msgKind = $dbSessionVars['msgKind']; else if (isset($cookieMsgKind)) $msgKind = $cookieMsgKind; if (empty($msgKind)) $msgKind = 'enhanced'; if (dbSessionIsRegistered('msgOrder')) $msgOrder = $dbSessionVars['msgOrder']; else if (isset($cookieMsgOrder)) $msgOrder = $cookieMsgOrder; if (empty($msgOrder)) $msgOrder = C_MSG_ORDER; if (dbSessionIsRegistered('showTimestamp')) $showTimestamp = $dbSessionVars['showTimestamp']; else if (isset($cookieShowTimestamp)) $showTimestamp = $cookieShowTimestamp; if (empty($msgOrder)) $showTimestamp = C_SHOW_TIMESTAMP; if (dbSessionIsRegistered('notify')) $notify = $dbSessionVars['notify']; else if (isset($cookieNotify)) $notify = $cookieNotify; if (empty($msgOrder)) $notify = C_NOTIFY; // Sets the encrypted password and gets the ip on the user if (empty($pwdHash)) $pwdHash = ($isRegUser) ? md5($password) : ''; if (empty($ip)) include('./' . _CHAT_PATH .'lib/get_ip.lib.' . C_EXTENSION); // Defines the user status to be put in the users table if necessary. // Skipped when the frameset is reloaded because of the NS4+ resize bug. if (!isset($reloading) || $reloading != 'nsResize') { if ($regUserPerms == '' && !$isRegUser) $regUserPerms = 'noreg'; switch ($regUserPerms) { case 'admin': // administrator $status = 'a'; break; case 'moderator': // moderator or registered user $status = (pmcIsInto($targetRoom, $regUserModeratedRooms) >= 0) ? 'm' : 'r'; break; case 'noreg': // non-registered user $status = 'u'; break; default: // registered user $status = 'r'; } } // Defines some variables $currentTime = time(); $nickForNotifications = pmcSlashSingleQuotes(pmcSlashSingleQuotes(pmcSpecialChars($slashedNick, $latin1))); if (C_WELCOME) { // ensures the welcome msg is the last one $currentTimePlus = $currentTime + 1; // Insert a new welcome message in the messages table include('./' . _CHAT_PATH . 'lib/welcome.lib.' . C_EXTENSION); $slashedWelcomeMsg = pmcSlashSingleQuotes(WELCOME_MSG); } // Udpates the IP address and the last log. time of the user in the // regsistered users table if necessary if ($isRegUser) $dbLink->query("UPDATE " . C_REG_TBL . " SET reg_time = '$currentTime', ip = '$ip' WHERE username = '$slashedNick'"); // 1. In the case of a registered user that relogs... // 1.a ...in the same room -> updates his last loggin time and his IP address; // 1.b ...in an other room -> kicks him from the other room, puts a // notification message of exit for this room, updates the users table, // puts a notification message of entrance for the room he logs in and // send him a welcome message if required. if ($wasInRoom != '') { if ($targetRoom == $wasInRoom) // Case 1.a { $dbLink->query("UPDATE " . C_USR_TBL . " SET u_time = '$currentTime', ip = '$ip' WHERE session_id = '$dbSessionId'"); } else // Case 1.b { $slashedRoomName = pmcSlashSingleQuotes($wasInRoom); $dbLink->query("SELECT type FROM " . C_MSG_TBL . " WHERE room = '$slashedRoomName' LIMIT 1"); list($type) = $dbLink->nextRecord(); $dbLink->clean_results(); $dbLink->query("INSERT INTO " . C_MSG_TBL . " VALUES ($roomType, '$slashedRoomName', 'SYS exit', '', '$currentTime', NULL, '#666699', 'sprintf(L_EXIT_ROM, \'" . $nickForNotifications . "\')', 'sprintf(L_EXIT_ROM, \'" . $nickForNotifications . "\')')"); $slashedRoomName = pmcSlashSingleQuotes($targetRoom); $dbLink->query("INSERT INTO " . C_MSG_TBL . " VALUES ($roomType, '$slashedRoomName', 'SYS enter', '', '$currentTime', NULL, '#666699', 'sprintf(L_ENTER_ROM, \'" . $nickForNotifications . "\')', 'sprintf(L_ENTER_ROM, \'" . $nickForNotifications . "\')')"); $dbLink->query("UPDATE " . C_USR_TBL . " SET u_time = '$currentTime', room = '$slashedRoomName', status = '$status', ip = '$IP' WHERE session_id = '$dbSessionId'"); 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'"); $dbLink->query("INSERT INTO " . C_MSG_TBL . " VALUES ($roomType, '$slashedRoomName', 'SYS welcome', '', '$currentTimePlus', '$slashedNick', '#666699', '" . $slashedWelcomeMsg . "', '" . $slashedWelcomeMsg . "')"); } } } // end of case where a registered user relogs // 2. In the case of an user that relogs because of the resize bug of NS4+ // updates his logging time and his IP address elseif (isset($reloading) && $reloading == 'nsResize') { $slashedRoomName = pmcSlashSingleQuotes($targetRoom); $dbLink->query("UPDATE " . C_USR_TBL . " SET u_time = '$currentTime', room = '$slashedRoomName', ip = '$ip' WHERE session_id = '$dbSessionId'"); } // end of case where an is relogged because of NS4+ resize bug // 3. In all other cases of users entering in, sets user infos. in 'users' // table and puts a notification message of entrance and a welcome message // if required into the 'messages' table else { $slashedRoomName = pmcSlashSingleQuotes($targetRoom); $dbLink->query("INSERT INTO " . C_USR_TBL . " VALUES ('$dbSessionId', '$currentTime', '$slashedRoomName', '$slashedNick', '$latin1', '$status', '$ip')"); $dbLink->query("INSERT INTO " . C_MSG_TBL . " VALUES ($roomType, '$slashedRoomName', 'SYS enter', '', '$currentTime', NULL, '#666699', 'sprintf(L_ENTER_ROM, \'" . $nickForNotifications . "\')', 'sprintf(L_ENTER_ROM, \'" . $nickForNotifications . "\')')"); 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'"); $dbLink->query("INSERT INTO " . C_MSG_TBL . " VALUES ($roomType, '$slashedRoomName', 'SYS welcome', '', '$currentTimePlus', '$slashedNick', '#666699', '" . $slashedWelcomeMsg . "', '" . $slashedWelcomeMsg . "')"); } } // end of "all other cases" // Prepares (ie removes unnecessary data) and saves session data $keptLang = $dbSessionVars['lang']; $keptFrom = $dbSessionVars['from']; unset($dbSessionVars); $dbSessionVars['from'] = $keptFrom; $dbSessionVars['lang'] = $keptLang; $dbSessionVars['jsVersion'] = $jsVersion; $dbSessionVars['nick'] = $nick; $dbSessionVars['pwdHash'] = $pwdHash; $dbSessionVars['roomType'] = $roomType; $dbSessionVars['targetRoom'] = $targetRoom; $dbSessionVars['status'] = (empty($status)) ? 'u' : $status; $dbSessionVars['refreshDelay'] = C_MSG_REFRESH; $dbSessionVars['msgKind'] = $msgKind; $dbSessionVars['msgOrder'] = $msgOrder; $dbSessionVars['msgNumber'] = C_MSG_NB; $dbSessionVars['showTimestamp'] = $showTimestamp; $dbSessionVars['notify'] = $notify; dbSessionSave(); unset($keptLang); unset($keptFrom); // Deletes invite messages sent to the user for the room he will enter in $dbLink->query("SELECT m_time FROM " . C_MSG_TBL . " WHERE username = 'SYS inviteTo' AND address = '$slashedNick' AND room = '$slashedRoomName'"); while (list($sentTime) = $dbLink->nextRecord()) { $dbLink->query("DELETE FROM " . C_MSG_TBL . " WHERE m_time = '$sentTime' AND (username = 'SYS inviteFrom' OR (username = 'SYS inviteTo' AND address = '$slashedNick'))"); } ?> --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This library defines the frameset depending on whether the browser knows | // | or not. | // | | // | It is called by the 'chat/lib/index_libs/main_index.lib.php3' script. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: do_enter_frameset.lib.php3,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // Defines the frameset for phpMyChat. // /** * Defines some URLs */ // The url to be used as a fix for the Netscape resize bug $nsResizeUrl = $dbSessionVars['from'] . '?' . dbSessionSID('GET') . $pmcQueryArgSeparator . 'reloading=nsResize'; // The url to be used for the loader if ($jsVersion == 'high') { $loaderUrl = _CHAT_PATH . 'loader.' . C_EXTENSION . '?' . dbSessionSID('GET') . $pmcQueryArgSeparator . 'isInitLoad=1' . $pmcQueryArgSeparator . 'lastMsgLoad=0' . $pmcQueryArgSeparator . 'lastUsrCheck=0'; } /** * Defines the frameset */ // With DHTML : 3 imbricated framesets if ($jsVersion == 'high') { ?> <frameset cols="100%,*,*" frameborder="0" border="0" framespacing="0" onresize="if (typeof(document.layers) != 'undefined') window.location = '<?php echo($nsResizeUrl); ?>';"> <!-- Visible framesets --> <frameset cols="*,130" frameborder="0" border="0" framespacing="0"> <frameset rows="*,50" frameborder="0" border="0" framespacing="0"> <frame src="<?php echo(_CHAT_PATH); ?>blank.htm" name="messages" frameborder="0" border="0" framespacing="0" marginwidth="3" marginheight="3" /> <frame src="<?php echo(_CHAT_PATH); ?>input.<?php echo(C_EXTENSION . '?' . dbSessionSID('GET')); ?>" name="input" frameborder="0" border="0" framespacing="0" marginwidth=0 marginheight=0 scrolling="no" noresize="noresize" /> </frameset> <frameset rows="80,*,50" frameborder="0" border="0" framespacing="0"> <frame src="<?php echo(_CHAT_PATH); ?>exit.<?php echo(C_EXTENSION . '?' . dbSessionSID('GET')); ?>" name="exit" frameborder="0" border="0" framespacing="0" marginwidth=3 marginheight=3 scrolling="no" /> <frame src="<?php echo(_CHAT_PATH); ?>users.<?php echo(C_EXTENSION . '?' . dbSessionSID('GET')); ?>" name="users" frameborder="0" border="0" framespacing="0" marginwidth=3 marginheight=3 /> <frame src="<?php echo(_CHAT_PATH); ?>link.php3" name="link" frameborder="0" border="0" framespacing="0" marginwidth=0 marginheight=0 scrolling="no" /> </frameset> </frameset> <!-- Hidden frame for the input work when something has been sent --> <frame src="<?php echo(_CHAT_PATH); ?>blank.htm" name="handle_input" frameborder="0" border="0" framespacing="0" marginheight="0" marginwidth="0" scrolling="no" /> <!-- Hidden frame for the loader --> <frame src="<?php echo($loaderUrl); ?>" name="loader" frameborder="0" border="0" framespacing="0" marginheight="0" marginwidth="0" scrolling="no" /> </frameset> <?php } // end of the 'DHTML enabled' case // Without DHTML : 2 imbricated framesets else { ?> <frameset cols="*,130" frameborder="0" border="0" framespacing="0" onResize="if (typeof(document.layers) != 'undefined') window.location = '<?php echo($nsResizeUrl); ?>';"> <frameset rows="*,50" border=0> <frame src="<?php echo(_CHAT_PATH); ?>messages_low.<?php echo(C_EXTENSION . '?' . dbSessionSID('GET')); ?>" name="messages" marginwidth=3 marginheight=3 /> <frame src="<?php echo(_CHAT_PATH); ?>input.<?php echo(C_EXTENSION . '?' . dbSessionSID('GET')); ?>" name="input" marginwidth=0 marginheight=0 scrolling="no" noresize="noresize" /> </frameset> <frameset rows="80,*,50" border=0> <frame src="<?php echo(_CHAT_PATH); ?>exit.<?php echo(C_EXTENSION . '?' . dbSessionSID('GET')); ?>" name="exit" marginwidth=3 marginheight=3 scrolling="no" /> <frame src="<?php echo(_CHAT_PATH); ?>users_low.<?php echo(C_EXTENSION . '?' . dbSessionSID('GET')); ?>" name="users" marginwidth=3 marginheight=3 /> <frame src="<?php echo(_CHAT_PATH); ?>link.php3" name="link" marginwidth=0 marginheight=0 scrolling="no" /> </frameset> </frameset> <?php } // end of the 'DHTML not-enabled' case ?> --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | Set of JavaScript instructions to use when the user is allowed to enter | // | the chat. | // | | // | This library is called by the 'chat/lib/index_libs/main_index.lib.php3' | // | script. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: do_enter_js_work.lib.php3,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // Defines some JavaScript instructions when the user is allowed to enter. // ?> <!-- Defines some js variables --> <script type="text/javascript" language="javascript"> <!-- var jsPhpExt = '<?php echo(C_EXTENSION); ?>'; var jsChatPath = '<?php echo(_CHAT_PATH); ?>'; var jsDbSessionSID = '<?php echo(dbSessionSID('GET')); ?>'; var jsIsNS4 = (typeof(document.layers) != 'undefined') ? 1 : 0; var jsIsIE4 = ((typeof(document.all) != 'undefined') && (parseInt(navigator.appVersion) >= 4)) ? 1 : 0; var jsIsVersion4 = (jsIsNS4 || jsIsIE4) ? 1 : 0; var jsIsJs11 = (typeof(window.focus) != 'undefined'); var jsIgnoredPopupWin = null; var jsUsersPopupWin = null; var jsInputForm = null; var jsUrlQueryForHelp = '<?php echo('lang=' . $dbSessionVars['lang'] . $pmcQueryArgSeparator . 'jsVersion=' . $jsVersion); ?>'; var jsInvalidCommandMsg = '<?php echo(pmcSlashSingleQuotes(L_BAD_CMD)); ?>'; // --> </script> <script type="text/javascript" language="javascript1.1"> <!-- var jsIsModerator = <?php echo((isset($status) && ($status == 'a' || $status == 'm')) ? 1 : 0); ?>; // --> </script> <!-- Gets the library containing miscellaneous js functions --> <script src="<?php echo(_CHAT_PATH); ?>lib/index_libs/misc.lib.js" type="text/javascript" language="javascript"></script> <!-- Required to display the server time at the status bar --> <script src="<?php echo(_CHAT_PATH); ?>lib/index_libs/server_time.lib.js" type="text/javascript" language="javascript"></script> <script type="text/javascript" language="javascript"> <!-- var jsClockDisplay = null; var jsServerTimeString = '<?php echo(L_SVR_TIME); ?>'; <?php if ($dbSessionVars['showTimestamp'] == 1) { $currentDate = mktime(date('H') + C_TMZ_OFFSET, date('i'), date('s'), date('m'), date('d'), date('Y')); ?> var jsClockGap = pmcCalcGap('<?php echo(date('F d, Y H:i:s', $currentDate)); ?>'); pmcClock(); <?php } else { ?> var jsClockGap = null; <?php } echo("\n"); ?> // --> </script> <!-- Gets the library that allows to modify the color picker --> <script src="<?php echo(_CHAT_PATH); ?>lib/index_libs/set_msg_color.lib.js" type="text/javascript" language="javascript1.1"></script> <!-- Gets the library that allows to launch the help popup --> <script src="<?php echo(_CHAT_PATH); ?>lib/index_libs/help_popup.lib.js" type="text/javascript" language="javascript"></script> <?php // For DHTML enabled browsers if ($jsVersion == 'high') { ?> <!-- Required to enforce reloading of the 'loader' frame --> <script type="text/javascript" language="javascript"> <!-- var jsIsInitLoad = 1; var jsLastLoadedMsgTime = 0; var jsLastCheckedUserTime = 0; if (typeof(location.replace) == 'undefined') // Emulates the replace method location.replace = location.assign; // Refreshes the 'loader' frame function pmcDoRefreshLoader() { var jsLoaderUrl = 'loader.<?php echo(C_EXTENSION); ?>' + '?<?php echo(dbSessionSID()); ?>' + '<?php echo($pmcQueryArgSeparator); ?>isInitLoad=' + jsIsInitLoad + '<?php echo($pmcQueryArgSeparator); ?>lastMsgLoad=' + jsLastLoadedMsgTime + '<?php echo($pmcQueryArgSeparator); ?>lastUsrCheck=' + jsLastCheckedUserTime; window.frames['loader'].window.location.replace(jsLoaderUrl); } // --> </script> <!-- Gets the libraries for collapsible list and connection state --> <script src="<?php echo(_CHAT_PATH); ?>lib/index_libs/users.lib.js" type="text/javascript" language="javascript1.2"></script> <script src="<?php echo(_CHAT_PATH); ?>lib/index_libs/connect_state.lib.js" type="text/javascript" language="javascript1.2"></script> <?php } // end of the DHTML enabled browser case ?> --- NEW FILE --- // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | Defines the position of the help popup and launches it. | // | | // | This library is called by the 'chat/lib/index_libs/main_index.lib.php3' | // | script. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: help_popup.lib.js,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // Defines the position of the help popup and launches it. // var jsMouseX = 0; var jsMouseY = 0; var jsHelpPopupWin = null; if (typeof(Image) != 'undefined') // 'Image' is a js1.1 object { var jsImgHelpOff = new Image(15,15); jsImgHelpOff.src = jsChatPath + 'images/help_off.gif'; var jsImgHelpOn = new Image(15,15); jsImgHelpOn.src = jsChatPath + 'images/help_on.gif'; } /** * Sets the position of the help popup * * @param object event type (used under NS4+) * * @access public */ function pmcDisplayLocation(e) { if (jsIsVersion4) { if (jsIsIE4) e = window.frames['input'].window.event; jsMouseX = e.screenX; jsMouseY = e.screenY; } return; } // end of the function 'pmcDisplayLocation()' /** * Launches the help popup * * @param leftOffset a value depending on the text direction */ function pmcHelpPopup(leftOffset) { if (typeof(jsHelpPopupWin) != 'undefined' && jsHelpPopupWin && !jsHelpPopupWin.closed) { if (jsIsJs11) jsHelpPopupWin.focus(); } else { var scrTop = jsMouseY - 400; var scrLeft = jsMouseX - leftOffset; var scrPos = 'top=' + scrTop + ',screenY=' + scrTop + ',left=' + scrLeft + ',screenX=' + scrLeft + ','; jsHelpPopupWin = window.open('help_popup.' + jsPhpExt + '?' + jsUrlQueryForHelp, 'help_popup', scrPos + 'width=600,height=350,scrollbars=yes,resizable=yes'); } } // end of the function 'pmcHelpPopup()' --- NEW FILE --- <? // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | Set of functions used to validate the settings submitted by the starting | // | page of phpMyChat. | // | | // | This library is called by the 'chat/lib/index_libs/main_index.lib.php3' | // | script. | // | It uses: | // | - the 'pmcHandleMagicQuotes()', the 'pmcSlashSingleQuotes()' and the | // | 'pmcIsInto()' functions defined inside the | // | 'chat/lib/common.lib.php3' script; | // | - the 'checkWords()' function defined inside the | // | 'chat/lib/swearing.lib.php3' script. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: index_validation.lib.php3,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // Validates the settings submitted by the starting page of phpMyChat. // /** * Validates the nick and the password submitted by the starting form of * phpMyChat * * @param $isRegNick true if the nick is a registered one * @param $regNickPerms permission level associated to the nick * @param $regNickModeratedRooms list of the room moderated by the user * @param $loggedInRoom name of the room the user was chatting into * * @return string error number (empty if no error) * * @global object the instance of the pmcDB object * @global string the nick of the user who wants to enter the * chat * @global string the slashed nick of the user who wants to * enter the chat * @global string the password entered by this user * @global string the md5 hash of this password * * @access public */ function pmcValidateNickAndPaswd( &$isRegNick, &$regNickPerms, &$regNickModeratedRooms, &$loggedInRoom) { global $dbLink; global $nick, $slashedNick; global $password, $pwdHash; $error1 = ''; $isLoggedIn = false; $requireReg = C_REQUIRE_REGISTER; // 1. Ensures invalid characters/words aren't in use for the nick // Ensures a nick has been submitted if ($nick == '') { $error1 = L_ERR_USR_2; } // Checks for invalid characters or empty nick else if (trim($nick) == '' || ereg('[\, ]', $nick)) { $error1 = L_ERR_USR_16; } // Checks for bad words in the nick else if (C_BAD_WORDS) { if (checkWords($nick, true)) $error1 = L_ERR_USR_18; } // end of the 1st stage (character validation inside the nick) // 2. If the nick is currently in use, gets the corresponding room name and // sets the $requireReg variable to true if ($error1 == '') { $dbLink->query("SELECT room FROM " . C_USR_TBL . " WHERE username = '$slashedNick' LIMIT 1"); $isLoggedIn = (list($loggedInRoom) = $dbLink->nextRecord()); if ($isLoggedIn) { $loggedInRoom = pmcHandleMagicQuotes($loggedInRoom, '', 1, 'del'); $requireReg = true; } } // end of the 2nd stage (checking if the nick is already in use) // 3. If registration is required but no password has been submitted // -> deny access if ($error1 == '' && $requireReg) { if ($password == '' && $pwdHash == '') $error1 = ($isLoggedIn) ? L_ERR_USR_1 : L_ERR_USR_14; } // end of the 3rd stage (a password has been submitted if required) // 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) $regNickModeratedRooms = pmcHandleMagicQuotes($regNickModeratedRooms, '', 1, 'del'); $dbLink->cleanResults(); // Skip the validation work when it has already be done before the // 'main_index.lib.php3' is run if (!isset($GLOBALS['$exitMode']) && $isRegNick) { // Reserved nick but no password submitted -> deny access if ($password == '' && $pwdHash == '') { $error1 = L_ERR_USR_3; } // Validates the password submitted else { if ($password != '') $pwdHash = md5($password); if ($pwdHash != $regUserPassword) { $isRegNick = false; $password = ''; $pwdHash = ''; $regNickPerms = 'user'; $regNickModeratedRooms = ''; $error1 = L_ERR_USR_4; } } } } // end of the 4th stage (validation of the password) return $error1; } // end of the 'pmcValidateNickAndPaswd()' function /** * Validates the name of the room to create and defines the permission level * the user will be granted inside this room * * @param $userPerms permission level associated to the nick * @param $userModeratedRooms list of the room moderated by the user * * @return string error number * * @global object the instance of the pmcDB object * @global string the slashed nick of the user who wants to * enter the chat * @global boolean whether this nick is a registered one or * not * @global string the name of the room to create * @global string the slashed name of the room to create * @global integer the type of the room to create * @global string the list of default public rooms * @global string the list of default private rooms * * @access public */ function pmcValidateRoomCreation(&$userPerms, &$userModeratedRooms) { global $dbLink; global $slashedNick; global $isRegUser; global $createRoomName, $slashedRoomName, $roomType; global $defaultChatRooms, $defaultPrivateRooms; $error2 = ''; // 1. Validates the room name // Skipped if the frameset is reloaded because of the NS4+ resize bug, // because the user has run a '/join' command or because he has clicked // on a room name at the users frame. if (!isset($GLOBALS['reloading'])) { // User is not registered -> deny room creation if (!$isRegUser) { $error2 = L_ERR_USR_13; } // Checks for invalid characters or empty room name else if (trim($createRoomName) == '' || ereg('[\,]', $createRoomName)) { $error2 = L_ERR_ROM_1; } // Checks for bad words in the room name else if (C_BAD_WORDS && checkWords($createRoomName, true)) { $error2 = L_ERR_ROM_2; } // Ensures there is no existing room with the same name but a different // type... else { // ...among reserved name for private/public (default) rooms $searchIn = ($roomType == 1) ? $defaultPrivateRooms : $defaultChatRooms; if (pmcIsInto($slashedRoomName, $searchIn) >= 0) $error2 = ($roomType == 0) ? L_ERR_ROM_3 : L_ERR_ROM_4; unset($searchIn); // ...among other rooms created by users if ($error2 == '') { $oppositeType = 1 - $roomType; $dbLink->query("SELECT COUNT(*) FROM " . C_MSG_TBL . " WHERE room = '$slashedRoomName' AND type = '$oppositeType' LIMIT 1"); list($isOpposite) = $dbLink->nextRecord(); $dbLink->cleanResults(); if ($isOpposite != 0) $error2 = ($T == 0) ? L_ERR_ROM_3 : L_ERR_ROM_4; } } } // end of the 1st stage (validation of the name of the room to create) // 2. Defines the permission level of the user for the room to create if ($error2 == '') { $isNewRoom = true; // If the name of the room to be created is a reserved one for // private/public (default) rooms, status will be 'user'. // Skipped if the frameset is reloaded because of the NS4+ resize bug, // because the user has run a '/join' command or because he has clicked // on a room name at the users frame. if (!isset($GLOBALS['reloading'])) { $searchIn = ($roomType == 1) ? $defaultChatRooms : $defaultPrivateRooms; $isNewRoom = (pmcIsInto($slashedRoomName, $searchIn) >= 0); unset($searchIn); } // If the name of the room to be created is the same than one of an // existing room containing 'true' messages (not only notifications of // users entrance/exit) or containing only 'system' message but an user // is currently logged in, status will be 'user' if ($isNewRoom) { $dbLink->query("SELECT COUNT(*) FROM " . C_MSG_TBL . " WHERE room = '$slashedRoomName' AND username NOT LIKE 'SYS %' LIMIT 1"); list($isTrueMsg) = $dbLink->nextRecord(); $isNewRoom = ($isTrueMsg == 0); $dbLink->cleanResults(); } if ($isNewRoom) { $dbLink->query("SELECT COUNT(*) FROM " . C_USR_TBL . " WHERE room = '$slashedRoomName' AND username != '$slashedNick' LIMIT 1"); list($isAnybody) = $dbLink->nextRecord(); $isNewRoom = ($isAnybody == 0); $dbLink->cleanResults(); } // end of true new room } // end of the 2nd stage (getting the status of the user) // 3. Updating permission levels inside the registered users table if ($error2 == '' && $isNewRoom) { // If an other registered user is already moderator for the room to // create but there is no 'true' message in this room then sets his // status to 'user' for this room $dbLink->query("SELECT username, rooms FROM " . C_REG_TBL . " WHERE perms = 'moderator' AND username != '$slashedNick'"); while (list($otherModerator, $otherModeratedRooms) = $dbLink->nextRecord()) { $changed = false; $otherModerator = pmcHandleMagicQuotes($otherModerator, '', 1, 'del'); $otherModeratedRooms = pmcHandleMagicQuotes($otherModeratedRooms, '', 1, 'del'); $rooms = explode(',', $otherModeratedRooms); for ($i = 0; $i < count($rooms); $i++) { if (strcasecmp($createRoomName, $rooms[$i]) == 0) { $rooms[$i] = ''; $changed = true; break; } } if ($changed) { $otherModeratedRooms = implode(',', $rooms); $otherModeratedRooms = ereg_replace('^,|,$', '', $otherModeratedRooms); $otherModeratedRooms = str_replace(',,', ',', $otherModeratedRooms); $dbLink->query("UPDATE " . C_REG_TBL . " SET rooms = '" . pmcSlashSingleQuotes($otherModeratedRooms) . "' WHERE username = '" . pmcSlashSingleQuotes($otherModerator) . "'"); $dbLink->query("UPDATE " . C_USR_TBL . " SET status = 'r' WHERE room = '$slashedRoomName' AND username = '" . pmcSlashSingleQuotes($otherModerator) . "'"); } unset($rooms); } // Update the current user status for the room to be created $changed = false; if (pmcIsInto($createRoomName, $userModeratedRooms) < 0) { if ($userModeratedRooms != '') $userModeratedRooms .= ','; $userModeratedRooms .= $createRoomName; $changed = true; } if ($userPerms == 'user' || $userPerms == '') { $userPerms = 'moderator'; $changed = true; } if ($changed && $userPerms != 'admin') { $dbLink->query("UPDATE " . C_REG_TBL . " SET perms = '$userPerms', rooms = '" . pmcSlashSingleQuotes($userModeratedRooms) ."' WHERE username = '$slashedNick'"); } // end of updating tables } // end of the 3rd stage (updating registered users tables) return $error2; } // end of the 'pmcValidateRoomCreation()' function ?> |