From: Lo?c C. <lo...@us...> - 2001-04-03 20:10:19
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat In directory usw-pr-cvs1:/tmp/cvs-serv3216/chat Added Files: exit.php3 handle_input.php3 input.php3 loader.php3 Log Message: The first dev. version that works! Still many things to do, of course... --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This script defines the 'exit' frame. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: exit.php3,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // The 'exit' frame. // /** * Gets the extension for the php scripts */ if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; define('C_EXTENSION', (substr($PHP_SELF, -1) == 3) ? 'php3' : 'php'); /** * Gets some core libraries */ require('./config/config.lib.' . C_EXTENSION); require('./lib/common.lib.' . C_EXTENSION); require('./lib/database/' . C_DB_TYPE . '.lib.' . C_EXTENSION); require('./lib/clean.lib.' . C_EXTENSION); /** * Gets the session id sent to this script * * Uses the 'pmcGrabGlobals()' function defined in the * 'chat/lib/common.lib.php3' library. */ pmcGrabGlobals('dbSessionId'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInitIt( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_REG_DEL, C_SESS_DEL * 60 ); dbSessionstart(); /** * Defines the language to be used */ require('./localization/' . $dbSessionVars['lang'] . '/localized.chat.' . C_EXTENSION); /** * Sends HTTP headers * * The 'pmcHttpHeaders()' fonction is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, false); /** * Displays the frame * * Uses the 'pmcUrlForStyleSheet()' function from the * 'chat/lib/common.lib.php3' library */ // The url for the style sheet $cssUrl = pmcUrlForStyleSheet('style', L_CHARSET, (defined('L_FONT_NAME')) ? L_FONT_NAME : '', L_FONT_SIZE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html dir="<?php echo((L_CHARSET == 'windows-1256') ? 'rtl' : 'ltr'); ?>"> <head> <title>Exit frame</title> <link rel="stylesheet" href="<?php echo($cssUrl); ?>" type="text/css" /> </head> <body class="frame" onunload="window.parent.pmcClosePopups()"> <center> <?php // Defines the url to exit the chat $exitUrl = $dbSessionVars['from'] . '?' . dbSessionSID('GET') . $pmcQueryArgSeparator . 'exitMode=2'; ?> <a href="<?php echo($exitUrl); ?>" target="_parent"><?php echo(L_EXIT); ?></a> <br /> <?php if (L_FONT_SIZE < 11) echo('<br />' . "\n"); echo("\n"); if ($dbSessionVars['jsVersion'] == 'high') { ?> <!-- Display the big + clickable icon used to expand/collapse all rooms --> <a href="#" onclick="window.parent.pmcExpandAll(); return false"> <img name="imgExpandAll" src="images/closed_big.gif" width="13" height="13" align="middle" border="0" alt="<?php echo(L_EXPCOL_ALL); ?>" /></a> <?php } echo("\n"); // Defines the url to lauch the users_popup $usersPopupUrl = 'users_popup' . (($dbSessionVars['jsVersion'] == 'high') ? '' : '_low') . '.' . C_EXTENSION . '?' . dbSessionSID('GET'); ?> <!-- Display the icon to launch the users popup --> <a href="<?php echo($usersPopupUrl); ?>" onclick="pmcUsersPopup('<?php echo(uniqid('')); ?>'); return false" target="_blank"> <img src="images/popup.gif" width="13" height="13" align="middle" border="0" alt="<?php echo(L_DETACH); ?>" /></a> <?php if ($dbSessionVars['jsVersion'] == 'high') { ?> <!-- Display the connection state icon --> <a href="#" onclick="window.parent.pmcReConnect(); window.parent.pmcSetMsgBoxFocus(); return false"> <img name="imgConState" src="images/connect_off.gif" width="13" height="13" align="middle" border="0" alt="<?php echo(L_CONN_STATE); ?>" /></a> <?php } echo("\n"); ?> </center> </body> </html> --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This script is called when the user submitted a message or a command at | // | the message box in the 'input' frame if his/her browser is DHTML | // | enabled. | // | | // | Note that this script runs in a hidden frame. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: handle_input.php3,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // The input handler. // /** * Gets the extension for the php scripts */ if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; define('C_EXTENSION', (substr($PHP_SELF, -1) == 3) ? 'php3' : 'php'); /** * Gets some core libraries */ require('./config/config.lib.' . C_EXTENSION); require('./lib/common.lib.' . C_EXTENSION); require('./lib/database/' . C_DB_TYPE . '.lib.' . C_EXTENSION); require('./lib/clean.lib.' . C_EXTENSION); /** * Gets the values of variables sent or posted to this script * * Uses the 'pmcGrabGlobals()' and the 'pmcHandleMagicQuotes()' functions * defined in the 'chat/lib/common.lib.php3' library. */ $toGrab = array('dbSessionId', '%POST', 'cookieColor'); pmcGrabGlobals($toGrab); if (!empty($msgTo)) $msgTo = pmcHandleMagicQuotes($msgTo, '1', '', 'del'); if (!empty($message)) $message = pmcHandleMagicQuotes($message, '1', '', 'del'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInitIt( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_REG_DEL, C_SESS_DEL * 60 ); dbSessionstart(); /** * Defines the language to be used */ require('./localization/' . $dbSessionVars['lang'] . '/localized.chat.' . C_EXTENSION); $latin1 = (L_CHARSET == 'iso-8859-1'); /** * Sends HTTP headers * * The 'pmcHttpHeaders()' fonction is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, true); /** * Gets/Updates the users' informations from/in the connected users table */ $slashedNick = pmcSlashSingleQuotes($dbSessionVars['nick']); $currentRoomType = $dbSessionVars['roomType']; $slashedCurrentRoomName = pmcSlashSingleQuotes($dbSessionVars['targetRoom']); require('./lib/check_and_kick_user.lib.' . C_EXTENSION); pmcCheckAndKickUser(false); /** * Define the default color that will be used for messages */ // set default color to black if (empty($color)) $color = (isset($cookieColor)) ? $cookieColor : '#000000'; // 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)', $color) && ($dbSessionVars['status'] != 'a' && $dbSessionVars['status'] != 'm')) $color = '#000000'; // Cookie expires in one year setcookie("cookieColor", $color, time() + 60*60*24*365); /** * Send the message */ $isCommand = false; $doRefreshMessages = false; $enforceFirstLoad = false; $isPopup = false; $displayMessage = false; if (isset($message) && trim($message) != '') { include('./lib/format_messages.lib.' . C_EXTENSION); // Tests for online commands if (substr($message, 0, 1) == '/') { include('./lib/commands.lib' . C_EXTENSION); if (!($isCommand) && !isset($error)) $error = L_BAD_CMD; } // end of handle commands // Tests for 'true' messages if ((!isset($prevMessage) || $message != $prevMessage) && !($isCommand || isset($error))) { // Ensure color is valid checkColor($color); // Remove swearings if (C_BAD_WORDS) { include('./lib/swearing.lib.' . C_EXTENSION); $message = checkwords($message, false); } // Format original message and set enhanced one (with graphical smilies) $strictMessage = $message; $originalMessage = formatMessage($message); $enhancedMessage = $originalMessage; unset($message); if (C_USE_SMILIES) { include('./lib/smilies.lib.' . C_EXTENSION); checkForSmilies($enhancedMessage, $smilies); unset($smilies); } // Put the message in the 'messages' table if (empty($msgTo)) $slashedMsgTo = 'NULL'; else $slashedMsgTo = '\'' . pmcSlashSingleQuotes($msgTo) . '\''; $msgQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' . 'VALUES (' . $currentRoomType . ', ' . '\'' . $slashedCurrentRoomName . '\', ' . '\'' . $slashedNick . '\', ' . $latin1 . ', ' . time() . ', ' . $slashedMsgTo . ', ' . '\'' . $color . '\', ' . '\'' . pmcSlashSingleQuotes($originalMessage) . '\', ' . '\'' . pmcSlashSingleQuotes($enhancedMessage) . '\'' . ')'; $dbLink = new pmcDB; $dbLink->query($msgQuery); $dbLink->close(); $doRefreshMessages = true; } // end of handle 'true' messages } // end of handle submitted message /** * Save session data */ dbSessionSave(); /** * "Displays" the frame */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html dir="<?php echo((L_CHARSET == 'windows-1256') ? 'rtl' : 'ltr'); ?>"> <head> <title>Handle input hidden frame</title> <script type="text/javascript" language="javascript1.2"> <!-- var inputSent = window.parent.pmcGetInputForm('sent'); if (inputSent && inputSent.value != 0) { // Udate the Form at the 'input' frame with (window.parent.frames['input'].window.document.forms['inputForm']) { elements['prevMessage'].value = '<?php echo(isset($strictMessage) ? pmcSlashSingleQuotes(htmlspecialchars($strictMessage)) : ''); ?>'; <?php // Get the value to put in the message box : // - previous message value for '/!' command; // - last submission if it was an erroneous command; // - else nothing. $msgValue = ($displayMessage) ? htmlspecialchars($prevMessage) : ''; if (isset($error) && !($isCommand)) $msgValue = pmcSlashSingleQuotes(htmlspecialchars($strictMessage)); ?> elements['message'].value = '<?php echo($msgValue); ?>'; elements['msgTo'].value = ''; elements['color'].value = '<?php echo($color); ?>'; elements['sent'].value = '0'; if (document.all) elements['submitType'].disabled = false; } <?php /** * Refresh the messages frame if necessary */ if ($doRefreshMessages) { // done in $dbSessionVars // $tmp = (isset($ign)) ? "&Ign=".urlencode(stripslashes($Ign)) : ""; ?> // Refresh the messages frame if necessary <?php if ($enforceFirstLoad) { echo("\n"); ?> window.parent.frames['messages'].window.document.close(); window.parent.jsIsInitLoad = true; window.parent.jsLastLoadedMsgTime = 0; window.parent.jsLastCheckedUserTime = 0; window.parent.jsConnect = 0; <?php } echo("\n"); ?> if (window.parent.jsConnect == 0) window.parent.pmcDoRefreshLoader(); <?php } /** * Display a JavaScript alert box with the error message if necessary */ if (isset($error)) { echo("\n"); ?> // Display a JavaScript alert box with the error message if necessary window.parent.pmcSetMsgBoxFocus(); alert('<?php echo(str_replace('\\\\n', '\\n', pmcSlashSingleQuotes($error))); ?>'); <?php } /** * Enforce reloading of the input frame if the user's status has changed */ echo("\n"); if ($dbSessionVars['status'] == 'm') { ?> // Add the red colors when the user has just been promoted to moderator if (!window.parent.jsIsModerator) { window.parent.frames['input'].window.location.replace('input.<?php echo(C_EXTENSION . '?dummy=' . uniqid('')); ?>'); window.parent.jsIsModerator = 1; } <?php } else if ($dbSessionVars['status'] != 'a') { echo("\n"); ?> // Remove the red colors when the user has became a 'simple user' if (window.parent.jsIsModerator) { window.parent.frames['input'].window.location.replace('input.<?php echo(C_EXTENSION . '?dummy=' . uniqid('')); ?>'); window.parent.jsIsModerator = 0; } <?php } echo("\n"); ?> } // --> </script> </head> <body> <?php /** * Display JavaScript instructions that commands may have set */ if (isset($jsToRun)) { for (reset($jsToRun); $jsInst = current($jsToRun); next($jsToRun)) { echo($jsInst . "\n"); } unset($jsTbl); } else { echo("\t" . '<!-- Not a blank document ;) -->' . "\n"); } ?> </body> </html> --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This script defines the 'input' frame. | // | | // | Note that the results of the form defined here are sent: | // | - to the script itself if the browser does not support DHTML; | // | - to the 'handle_input.php3' script else. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: input.php3,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // The 'input' frame. // /** * Gets the extension for the php scripts */ if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; define('C_EXTENSION', (substr($PHP_SELF, -1) == 3) ? 'php3' : 'php'); /** * Gets some core libraries */ require('./config/config.lib.' . C_EXTENSION); require('./lib/common.lib.' . C_EXTENSION); require('./lib/database/' . C_DB_TYPE . '.lib.' . C_EXTENSION); require('./lib/clean.lib.' . C_EXTENSION); /** * Gets the values of variables sent or posted to this script * * Uses the 'pmcGrabGlobals()' and the 'pmcHandleMagicQuotes()' functions * defined in the 'chat/lib/common.lib.php3' library. */ $toGrab = array('dbSessionId', '%POST', 'cookieColor'); pmcGrabGlobals($toGrab); if (!empty($msgTo)) $msgTo = pmcHandleMagicQuotes($msgTo, '1', '', 'del'); if (!empty($message)) $message = pmcHandleMagicQuotes($message, '1', '', 'del'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInitIt( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_REG_DEL, C_SESS_DEL * 60 ); dbSessionstart(); /** * Defines the language to be used */ require('./localization/' . $dbSessionVars['lang'] . '/localized.chat.' . C_EXTENSION); $latin1 = (L_CHARSET == 'iso-8859-1'); /** * Sends HTTP headers * * The 'pmcHttpHeaders()' fonction is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, false); /** * Gets/Updates the users' informations from/in the connected users table */ $slashedNick = pmcSlashSingleQuotes($dbSessionVars['nick']); $currentRoomType = $dbSessionVars['roomType']; $slashedCurrentRoomName = pmcSlashSingleQuotes($dbSessionVars['targetRoom']); require('./lib/check_and_kick_user.lib.' . C_EXTENSION); pmcCheckAndKickUser(false); /** * Define the default color that will be used for messages */ // set default color to black if (empty($color)) $color = (isset($cookieColor)) ? $cookieColor : '#000000'; // 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)', $color) && ($dbSessionVars['status'] != 'a' && $dbSessionVars['status'] != 'm')) $color = '#000000'; // Cookie expires in one year setcookie("cookieColor", $color, time() + 60*60*24*365); /** * Send the message */ $isCommand = false; $doRefreshMessages = false; $enforceFirstLoad = false; $isPopup = false; $displayMessage = false; if (isset($message) && trim($message) != '') { include('./lib/format_messages.lib.' . C_EXTENSION); // Tests for online commands if (substr($message, 0, 1) == '/') { include('./lib/commands.lib' . C_EXTENSION); if (!($isCommand) && !isset($error)) $error = L_BAD_CMD; } // end of handle commands // Tests for 'true' messages if ((!isset($prevMessage) || $message != $prevMessage) && !($isCommand || isset($error))) { // Ensure color is valid checkColor($color); // Remove swearings if (C_BAD_WORDS) { include('./lib/swearing.lib.' . C_EXTENSION); $message = checkwords($message, false); } // Format original message and set enhanced one (with graphical smilies) $strictMessage = $message; $originalMessage = formatMessage($message); $enhancedMessage = $originalMessage; unset($message); if (C_USE_SMILIES) { include('./lib/smilies.lib.' . C_EXTENSION); checkForSmilies($enhancedMessage, $smilies); unset($smilies); } // Put the message in the 'messages' table if (empty($msgTo)) $slashedMsgTo = 'NULL'; else $slashedMsgTo = '\'' . pmcSlashSingleQuotes($msgTo) . '\''; $msgQuery = 'INSERT INTO ' . C_MSG_TBL . ' ' . 'VALUES (' . $currentRoomType . ', ' . '\'' . $slashedCurrentRoomName . '\', ' . '\'' . $slashedNick . '\', ' . $latin1 . ', ' . time() . ', ' . $slashedMsgTo . ', ' . '\'' . $color . '\', ' . '\'' . pmcSlashSingleQuotes($originalMessage) . '\', ' . '\'' . pmcSlashSingleQuotes($enhancedMessage) . '\'' . ')'; $dbLink = new pmcDB; $dbLink->query($msgQuery); $dbLink->close(); $doRefreshMessages = true; } // end of handle 'true' messages } // end of handle submitted message /** * Save session data */ dbSessionSave(); /** * Displays the frame * * Uses the 'pmcUrlForStyleSheet()' function from the * 'chat/lib/common.lib.php3' library */ // The url for the style sheet $cssUrl = pmcUrlForStyleSheet('style', L_CHARSET, (defined('L_FONT_NAME')) ? L_FONT_NAME : '', L_FONT_SIZE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html dir="<?php echo((L_CHARSET == 'windows-1256') ? 'rtl' : 'ltr'); ?>"> <head> <title>Input frame</title> <link rel="stylesheet" href="<?php echo($cssUrl); ?>" type="text/css" /> <script type="text/javascript" language="javascript1.2"> <!-- // Get the position for the help popup if (window.parent.jsIsNS4) document.captureEvents(Event.MOUSEDOWN); document.onmousedown = window.parent.pmcDisplayLocation; // --> </script> </head> <body class="frame"<?php if (!$isPopup) echo(' onload="window.parent.pmcSetMsgBoxFocus()"'); ?>> <table border="0" cellpadding="0" cellspacing="0"> <tr> <!-- Input form --> <td> <?php // Define the way posted values will be handled according to the javascript // abilities of the browser $target = ($dbSessionVars['jsVersion'] == 'high') ? 'handle_input' : 'input'; $action = $target . '.' . C_EXTENSION; ?> <form name="inputForm" action="<?php echo($action); ?>" method="post" autocomplete="off" target="<?php echo($target); ?>" onsubmit="return window.parent.pmcValidateInputForm()"> <?php // Put the session id in an hidden field echo("\t" . dbSessionSID('POST') . "\n"); ?> <!-- Whether a message has been sent or not (used to avoid multiple submission) --> <input type="hidden" name="sent" value="0" /> <!-- Last sent message or command (used for the '/!' command) --> <input type="hidden" name="prevMessage" value="<?php echo(isset($strictMessage) ? htmlspecialchars(stripslashes($strictMessage)) : ''); ?>" /> <!-- Addressee that will be filled when the user click on a nick at the users frame --> <input type="hidden" name="msgTo" value="" /> <?php // Url for the help popup $helpUrl = 'help_popup.' . C_EXTENSION . '?lang=' . $dbSessionVars['lang'] . $pmcQueryArgSeparator . 'jsVersion=' . $dbSessionVars['jsVersion']; ?> <!-- Help popup link --> <a href="<?php echo($helpUrl); ?>" onclick="window.parent.pmcHelpPopup(<?php echo((L_CHARSET == 'windows-1256') ? 610 : 10); ?>); return false" target="_blank" onmouseover="document.images['helpImg'].src = window.parent.jsImgHelpOn.src" onmouseout="document.images['helpImg'].src = window.parent.jsImgHelpOff.src"><img name="helpImg" src="images/help_off.gif" width="15" height="15" border="0" alt="<?php echo(L_HLP); ?>" onclick="window.parent.pmcSetMsgBoxFocus()" /></a> <?php // Get the value to put in the message box : // - previous message value for '/!' command; // - last submission if it was an erroneous command; // - else nothing. $msgValue = ($displayMessage) ? htmlspecialchars($prevMessage) : ''; if (isset($error) && !($isCommand)) $msgValue = htmlspecialchars($strictMessage); ?> <!-- Message box --> <input type="text" name="message" size="50" maxlength="299" value="<?php echo($msgValue); ?>" /> <!-- Message color --> <?php // Color of the message if ($dbSessionVars['jsVersion'] == 'low') { // Drop down list of colors for non-enabled JavaScript1.1+ browsers echo("\t\t" . '<select name="color">' . "\n"); while (list($colorName, $colorCode) = each($textColors)) { // Red color is reserved to the admin or a moderator for the current room if ($colorCode == '#FF0000' && !($dbSessionVars['status'] == 'a' || $dbSessionVars['status'] == 'm')) continue; echo("\t\t\t" . '<option value="' . $colorCode . '"'); if ($color == $colorCode || $colorCode == '#000000') echo(' selected="selected"'); echo('>' . $colorName . '</option>' . "\n"); } echo("\t\t" . '</select> ' ."\n"); } else { echo("\t\t" . '<input type="hidden" name="color" value="' . $color . '" />' ."\n"); } // end of color ?> <input type="submit" name="submitType" value="<?php echo(L_OK); ?>" /> </td> <?php // Define the colors picker for JavaScript1.1+ enabled browsers if ($dbSessionVars['jsVersion'] != 'low') { unset($textColors); $textColors = array('#000000', '#ffffff'); for($x = 0; $x < 360; $x += 6) { $r = ceil(126 * (cos(deg2rad($x)) + 1)); $g = ceil(126 * (cos(deg2rad($x + 240)) + 1)); $b = ceil(126 * (cos(deg2rad($x + 120)) + 1)); if (!($r > 128 && $g < 128 && $b < 128 && !(isset($status) && ($dbSessionVars['status'] == 'a' || $dbSessionVars['status'] == 'm')))) { $textColors[] = '#' . substr('0'.dechex($r), -2) . substr('0'.dechex($g), -2) . substr('0'.dechex($b), -2); } } ?> <td> </td> <!-- The color picker --> <td> <table border="0" cellpadding="0" cellspacing="0"> <tr> <?php while (list($key, $colorCode) = each($textColors)) { $i = $key + 1; if ($colorCode == $color) { $wichImage = 'sel_color.gif'; $wichSelected = $i; } else { $wichImage = 'unsel_color.gif'; } echo("\n\t\t\t"); echo('<td bgcolor="' . $colorCode . '"><a href="#" onclick="window.parent.pmcChangeColor(\'' . $colorCode . '\', \'C' . $i .'\'); return false"><img src="images/' . $wichImage . '" alt="' . $colorCode . '" name="C' . $i . '" border="0" width="2" height="20" /></a></td>'); } unset($textColors); echo("\n"); ?> </tr> </table> </td> <?php } echo("\n"); ?> <td> </form> </td> </tr> </table> <?php /** * Ensure a color is selected in the colors picker, else select the default one */ if ($dbSessionVars['jsVersion'] != 'low') { ?> <script type="text/javascript" language="javascript"> <!-- <?php if (isset($wichSelected)) echo('window.parent.jsSelectedColor = \'C' . $wichSelected . '\';' . "\n"); else echo('window.parent.pmcChangeColor(\'#000000\', \'C1\');' . "\n"); ?> // --> </script> <?php } echo("\n"); /** * Refresh the messages frame if necessary */ if ($doRefreshMessages) { // done in $dbSessionVars // $tmp = (isset($ign)) ? "&Ign=".urlencode(stripslashes($Ign)) : ""; ?> <script type="text/javascript" language="javascript"> <!-- // Refresh the messages frame if necessary <?php echo("\n"); if ($dbSessionVars['jsVersion'] == 'high') { if ($enforceFirstLoad) { ?> window.parent.frames['messages'].window.document.close(); window.parent.jsIsInitLoad = true; window.parent.jsLastLoadedMsgTime = 0; window.parent.jsLastCheckedUserTime = 0; window.parent.jsConnect = 0; <?php } echo("\n"); ?> if (window.parent.jsConnect == 0) window.parent.pmcDoRefreshLoader(); <?php } else { $messagesLowUrl = 'messages_low.' . C_EXTENSION . '?' . dbSessionSID(); ?> window.parent.frames['messages'].window.location = '<?php echo($messagesLowUrl); ?>'; <?php } echo("\n"); ?> // --> </script> <?php } echo("\n"); /** * Display a JavaScript alert box with the error message if necessary */ if (isset($error)) { ?> <script type="text/javascript" language="javascript"> <!-- // Display a JavaScript alert box with the error message if necessary window.parent.pmcSetMsgBoxFocus(); alert('<?php echo(str_replace('\\\\n', '\\n', pmcSlashSingleQuotes($error))); ?>'); // --> </script> <?php } echo("\n"); /** * Put JavaScript instructions that commands may have set */ if (isset($jsToRun)) { for (reset($jsToRun); $jsInst = current($jsToRun); next($jsToRun)) { echo($jsToRun . "\n"); } unset($jsToRun); } ?> </body> </html> --- NEW FILE --- <?php // // +--------------------------------------------------------------------------+ // | phpMyChat version 0.15.0 | // +--------------------------------------------------------------------------+ // | Copyright (c) 2000-2001 The phpHeaven-team | // +--------------------------------------------------------------------------+ // | This script is used in a hidden frame with DHTML enabled browsers. It: | // | - loads new messages from the 'messages' table and push them to the | // | 'messages' frame; | // | - checks for modifications among the connected users table and enforces | // | reloading of the 'users' frame if necessary. | // +--------------------------------------------------------------------------+ // | From the phpMyChat project: | // | http://www.phpheaven.net/projects/phpMyChat/ | // | | // | Authors: the phpHeaven-team <php...@ya...> | // +--------------------------------------------------------------------------+ // // $Id: loader.php3,v 1.1 2001/04/03 20:10:15 loic1 Exp $ // // The message and connected users loader. // /** * Gets the extension for the php scripts */ if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; define('C_EXTENSION', (substr($PHP_SELF, -1) == 3) ? 'php3' : 'php'); /** * Gets some core libraries */ require('./config/config.lib.' . C_EXTENSION); require('./lib/common.lib.' . C_EXTENSION); require('./lib/database/' . C_DB_TYPE . '.lib.' . C_EXTENSION); require('./lib/clean.lib.' . C_EXTENSION); /** * Gets the values of variables sent or posted to this script * * Uses the 'pmcGrabGlobals()' and the 'pmcHandleMagicQuotes()' functions * defined in the 'chat/lib/common.lib.php3' library. */ pmcGrabGlobals('%GET'); /** * Start the session handler */ require('./lib/db_sessions.lib.' . C_EXTENSION); dbSessionInitIt( C_DB_TYPE, C_DB_HOST, C_DB_NAME, C_DB_USER, C_DB_PASS, C_SESS_TBL, C_REG_DEL, C_SESS_DEL * 60 ); dbSessionstart(); /** * Defines the language to be used */ require('./localization/' . $dbSessionVars['lang'] . '/localized.chat.' . C_EXTENSION); $textDirection = (L_CHARSET == 'windows-1256') ? 'rtl' : 'ltr'; /** * Sends HTTP headers * * The 'pmcHttpHeaders()' fonction is defined in the 'chat/lib/common.lib.php3' * library */ pmcHttpHeaders(L_CHARSET, true); /** * Gets/Updates the users' informations from/in the connected users table */ $slashedNick = pmcSlashSingleQuotes($dbSessionVars['nick']); $currentRoomType = $dbSessionVars['roomType']; $slashedCurrentRoomName = pmcSlashSingleQuotes($dbSessionVars['targetRoom']); require('./lib/check_and_kick_user.lib.' . C_EXTENSION); pmcCheckAndKickUser(true); /** * Instanciates a new pmcDB object */ $dbLink = new pmcDB; /** * Check for updates in users list */ $doRefreshUsers = false; // $isUsrCleaned is defined in 'chat/lib/clean.lib.php3' if ($isInitLoad || $isUsrCleaned) { $doRefreshUsers = true; } else { // Define the SQL query (depends on the type -public or private- of the // current room $refreshRoomQuery = 'SELECT DISTINCT m_time FROM ' . C_MSG_TBL . ' ' . 'WHERE ' . 'm_time > ' . $lastUsrCheck . ' AND ' . 'username IN (\'SYS enter\', \'SYS exit\', \'SYS promote\') AND ' . '(type = 1' . (($dbSessionVars['roomType'] == 0) ? ' OR (type = 0 AND room = \'' . $dbSessionVars['targetRoom'] .'\')) ' : ') ') . 'ORDER BY m_time DESC ' . 'LIMIT 1'; $dbLink->query($refreshRoomQuery); list($newLastUsrCheck) = $dbLink->nextRecord(); if ($newLastUsrCheck > $lastUsrCheck) { $lastUsrCheck = $newLastUsrCheck; $doRefreshUsers = true; $dbLink->cleanResults(); } unset($newLastUsrCheck); } /** * Check for updates in messages list and get new messages * * The 'pmcHandleMagicQuotes()' and the 'pmcSlashSingleQuotes()' functions are * defined inside the 'chat/lib/common.lib.php3' script. */ // Define the SQL query (depends on the ignored users list and on whether to // display notification messages or not) $ignoredSendersList = ''; if (dbSessionIsRegistered('ignoredSenders') && !empty($dbSessionVars['ignoredSenders'])) $ignoredSendersList .= '\'' . str_replace(',', '\', \'', pmcSlashSingleQuotes($dbSessionVars['ignoredSenders'])) . '\''; if ($dbSessionVars['notify'] == 0) $ignoredSendersList .= (($ignoredSendersList != '') ? ', ':'') . '\'SYS enter\', \'SYS exit\''; if ($ignoredSendersList != '') $ignoredSendersList = 'username NOT IN (' . $ignoredSendersList . ') AND '; $slashedNick = pmcSlashSingleQuotes($dbSessionVars['nick']); $slashedCurrentRoomName = pmcSlashSingleQuotes($dbSessionVars['targetRoom']); $getMessagesQuery = 'SELECT username, latin1, m_time, address, color, msg_' . $dbSessionVars['msgKind'] . ' ' . 'FROM ' . C_MSG_TBL . ' ' . 'WHERE ' . (($isInitLoad) ? '' : 'm_time > ' . $lastMsgLoad . ' AND ') . $ignoredSendersList . '(' . 'address = \' *\' OR ' . '(address = \'' . $slashedNick .'\' AND (room = \'' . $slashedCurrentRoomName . '\' OR username = \'SYS inviteTo\')) OR ' . '(room = \'' . $slashedCurrentRoomName . '\' AND (address IS NULL OR username = \''. $slashedNick . '\'))' . ') ' . 'ORDER BY m_time DESC' . (($isInitLoad) ? ' LIMIT ' . $dbSessionVars['msgNumber'] : ''); // Get new messages and store them in an array $grabedMessages = array(); $dbLink->query($getMessagesQuery); while (list($sender, $senderLatin1, $sentTime, $addressee, $msgColor, $message) = $dbLink->nextRecord()) { $grabedMessages[] = array( 'sender' => pmcHandleMagicQuotes($sender, '', 1, 'del'), 'senderLatin1' => $senderLatin1, 'sentTime' => $sentTime, 'addressee' => pmcHandleMagicQuotes($addressee, '', 1, 'del'), 'msgColor' => $msgColor, 'message' => pmcHandleMagicQuotes($message, '', 1, 'del') ); } $dbLink->cleanResults(); $dbLink->close(); /** * Format new messages * * The 'pmcSpecialChars()' and the 'pmcSlashSingleQuotes()' functions are * defined inside the 'chat/lib/common.lib.php3' script. */ $newMessages = array(); $grabedMessagesCnt = count($grabedMessages); if ($grabedMessagesCnt == 0) { if ($isInitLoad) $newMessages[] = '<span class="notify">' . L_NO_MSG . '<\/span>'; } else { reset($grabedMessages); for ($k = 0; $k < $grabedMessagesCnt; $k++) { // Get the values of messages variables while (list($name, $value) = each($grabedMessages[$k])) $$name = $value; // Skip the oldest message if the day seperator has been added if (isset($daySeparator) && $isInitLoad && $k == $grabedMessagesCnt - 1) continue; // Separator between messages sent before today and other ones if (!isset($daySeparator) && date('j', $sentTime) != date('j', time())) { $newMessages[] = '<p class="msg"><span class="notify">--------- ' . L_TODAY_DWN . ' ---------<\/span><\/p>'; $daySeparator = 1; } // Messages $aMessage = '<p class="msg">'; // The timestamp of the message if ($dbSessionVars['showTimestamp'] == 1) $aMessage .= '<span class="time">' . date('H:i:s', $sentTime + C_TMZ_OFFSET * 60 * 60) . '<\/span> '; // 'Standard' messages if (substr($sender,0,4) != 'SYS ') { $simpleSender = pmcSpecialChars($sender, $senderLatin1); $slashedSender = pmcSlashSingleQuotes($simpleSender); $sender = '<a href="#" onclick="window.parent.pmcUserClick(\'' . $slashedSender . '\', true); return false" class="sender">' . $simpleSender . '<\/a>'; if ($addressee != '') $addressee = ']<bdo dir="' . $textDirection . '"><\/bdo>>[' . htmlspecialchars($addressee); $aMessage .= '<b>[' . $sender . $addressee . ']<bdo dir="' . $textDirection .'"><\/bdo><\/b> ' . '<font color="' . $msgColor . '">' . $message . '<\/font>'; } // 'System' messages else { $aMessage .= '<span class="notify">'; if ($addressee == ' *') { $aMessage .= '[' . L_ANNOUNCE . ']<bdo dir="' . $textDirection . '"><\/bdo> ' . $message; } else { if ($addressee != '') $aMessage .= '<b>>[' . htmlspecialchars($addressee) . ']<bdo dir="' . $textDirection . '"><\/bdo><\/b> '; if (strpos($message, 'printf(')) eval('$aMessage .= ' . $message . ';'); else $aMessage .= $message; } $aMessage .= '<\/span>'; } $aMessage .= '<\/p>'; $newMessages[] = $aMessage; if ($sentTime > $lastMsgLoad) $lastMsgLoad = $sentTime; } } // end of formatting new messages unset($grabedMessages); /** * "Displays" the frame */ // Define the URL for the http refresh header $refreshUrl = 'loader.' . C_EXTENSION . '?' . dbSessionSID('GET') . $pmcQueryArgSeparator . 'isInitLoad=0' . $pmcQueryArgSeparator . 'lastMsgLoad=' . $lastMsgLoad . $pmcQueryArgSeparator . 'lastUsrCheck=' . $lastUsrCheck; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html dir="<?php echo($textDirection); ?>"> <head> <title>Loader hidden frame</title> <?php if ($dbSessionVars['refreshDelay'] > 0) echo('<meta http-equiv="Refresh" content="' . $dbSessionVars['refreshDelay'] . '; url=' . $refreshUrl . '" />' . "\n"); ?> <script type="text/javascript" language="javascript"> <!-- // Emulates replace method for non-js1.1 compliant browsers if (typeof(location.replace) == 'undefined') location.replace = location.assign; // Updates the time for last checked user and the last loaded message window.parent.jsIsInitLoad = 0; window.parent.jsLastLoadedMsgTime = <?php echo($lastMsgLoad); ?>; window.parent.jsLastCheckedUserTime = <?php echo($lastUsrCheck); ?>; <?php /** * Do refresh the 'users' frame if necessary */ if ($doRefreshUsers) { $usersUrl = 'users.' . C_EXTENSION . '?' . dbSessionSID(); ?> // Do refresh the 'users' frame window.parent.frames['users'].window.location.replace('<?php echo($usersUrl); ?>'); <?php } echo("\n"); /** * Do refresh the 'messages' frame if necessary * * The 'pmcUrlForStyleSheet' is defined in the 'chat/lib/common.lib.php3' * script. */ ?> // Push data to the 'message' frame with (window.parent.frames['messages'].window) { <?php // Set the headers for the 'messages' frame at first load if ($isInitLoad) { // The url for the style sheet $cssUrl = pmcUrlForStyleSheet('style', L_CHARSET, (defined('L_FONT_NAME')) ? L_FONT_NAME : '', L_FONT_SIZE); ?> // Set the headers for the 'messages' frame document.open('text/html', 'replace'); document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">'); document.write('<html dir="<?php echo($textDirection); ?>">\n\n<head>\n'); document.write('<title>Dynamic messages frame<\/title>\n'); document.write('<link rel="stylesheet" href="<?php echo($cssUrl); ?>" type="text/css" \/>\n'); document.write('<\/head>\n\n'); document.write('<body class="mainframe">\n'); <?php } // Send new message(s) if there is at least one, else an empty string to ensure // the message frame isn't closed because of a too long inactive delay $newMessagesCnt = count($newMessages); if ($newMessagesCnt > 0) { reset($newMessages); for ($i = 0; $i < $newMessagesCnt; $i++) { // doubles backslashes except the ones for closing HTML tags $toPush = str_replace('\\', '\\\\', $newMessages[$newMessagesCnt - 1 - $i]); $toPush = str_replace('<\\\\/', '<\\/', $toPush); $toPush = pmcSlashSingleQuotes($toPush); echo("\n"); if ($i == 0) echo("\t" . '// Send new message(s)' . "\n"); ?> document.write('<?php echo($toPush); ?>\n'); <?php } ?> // Scrolls to the bottom of the message frame if (typeof(scrollBy(0, 0)) != 'undefined') { scrollBy(0, 65000); scrollBy(0, 65000); } else { scroll(0, 65000); scroll(0, 65000); } <?php } // end if ($newMessagesCnt > 0) else { echo("\n"); ?> // Send an empty string to ensure the message frame isn't closed because of // a too long inactive delay document.write(''); <?php } echo("\n"); ?> } // --> </script> </head> <body onunload="if (typeof(window.parent.frames['exit']) != 'undefined' && typeof(window.parent.jsLeaveChat) != 'undefined' && !window.parent.jsLeaveChat) window.parent.pmcConnecting(window.parent.jsConnect + 1)"> <script type="text/javascript" language="javascript1.1"> <!-- if (typeof(window.parent.frames['exit']) != 'undefined' && typeof(window.parent.pmcConnectDone) != 'undefined') window.parent.pmcConnectDone(); // --> </script> </body> </html> |