/* ---------------------------------------------------------------------------------- This is the main library called by the start screen of phpMyChat. It contains: - the common work at the beginning; - all what have to be done once the user has submit the form (part I); - the 'send_headers' function that is used.... to send some HTTP headers and to define the
part of the starting page; - the 'layout' function that creates the start page. The mains PHP variables used inside this script are: - $L -> the current language; - $Charset -> the name of the charset associated to the current language; - $Ver -> the JavaScript abilities of the browser of the user ('H' when DHTML enabled, 'M' when JavaScript1.1, 'L' else). - $U -> the login nick of the user; - $PASSWORD -> the password of the user in clear mode; - $PWD_Hash -> the md5 hash of '$PASSWORD'; - $N -> the number of messages to be shown each time the 'messages' frame is reloaded; - $D -> the timeout between each update of the 'messages' frame; - $T -> the type of the room the user wants to enter in; - $R0 -> the name of the default public room the user wants to enter in (not defined if he doesn't choose to enter one of the default public rooms); - $R1 -> the name of the 'other' public room the user wants to enter in (not defined if he doesn't choose to enter one of the 'other' public rooms); - $R2 -> the name of the room the user wants to create (not defined if he doesn't choose to create a room); - $E -> the name of the room the user just leaves. When $E is defined, the $EN boolean variable may also be defined and requires this script to insert an exit message to the 'messages' table; - $Reload -> when the user runs some specific actions inside the chat (he uses the '/join' command, clicks on a room name at the 'users' frame or resizes the window for the browser inside netscape 4+), this variable is defined to skip some tests that aren't necessary; - $perms -> permission level of the user for the room he wants to enter in. ---------------------------------------------------------------------------------- /* /*********** COMMON WORK ***********/ // Get the names and values for vars sent to index.lib.php3 if (isset($HTTP_GET_VARS)) { while(list($name,$value) = each($HTTP_GET_VARS)) { $$name = $value; }; }; // Get the names and values for vars posted from the form bellow if (isset($HTTP_POST_VARS)) { while(list($name,$value) = each($HTTP_POST_VARS)) { $$name = $value; }; }; // Fix some security holes if (!is_dir('./'.substr($ChatPath, 0, -1))) exit(); require("./${ChatPath}config/config.lib.php3"); require("./${ChatPath}lib/release.lib.php3"); require("./${ChatPath}localization/languages.lib.php3"); require("./${ChatPath}localization/".$L."/localized.chat.php3"); require("./${ChatPath}lib/database/".C_DB_TYPE.".lib.php3"); require("./${ChatPath}lib/clean.lib.php3"); include("./${ChatPath}lib/get_IP.lib.php3"); // Special cache instructions for IE5+ $CachePlus = ""; if (ereg("MSIE [56789]", (isset($HTTP_USER_AGENT)) ? $HTTP_USER_AGENT : getenv("HTTP_USER_AGENT"))) $CachePlus = ", pre-check=0, post-check=0, max-age=0"; $now = gmdate('D, d M Y H:i:s') . ' GMT'; header("Expires: $now"); header("Last-Modified: $now"); header("Cache-Control: no-cache, must-revalidate".$CachePlus); header("Pragma: no-cache"); header("Content-Type: text/html; charset=${Charset}"); // avoid server configuration for magic quotes set_magic_quotes_runtime(0); // Get the relative path to the script that called this one if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS["PHP_SELF"]; $Action = basename($PHP_SELF); $From = urlencode(ereg_replace("[^/]+/","../",$ChatPath).$Action); // For translations with a real iso code if (!isset($FontFace)) $FontFace = ""; // For others translations $DisplayFontMsg = !(isset($U) && $U != ""); // Translate to html special characters, and entities if message was sent with a latin 1 charset $Latin1 = ($Charset == "iso-8859-1"); function special_char($str,$lang) { return addslashes($lang ? htmlentities(stripslashes($str)) : htmlspecialchars(stripslashes($str))); }; // Ensure a room ($what) is include in a rooms list ($in) function room_in($what, $in) { $rooms = explode(",",$in); for (reset($rooms); $room_name=current($rooms); next($rooms)) { if (strcasecmp($what, $room_name) == 0) return true; }; return false; }; /*********** PART I ***********/ // Define the message to display if user comes here because he has been kicked if (isset($KICKED)) { switch ($KICKED) { case '1': $Error = L_REG_18; break; case '2': $Error = L_REG_39; break; case '3': $Error = L_ERR_USR_19; break; case '4': $Error = L_ERR_USR_20; }; }; $DbLink = new DB; // Fix some security issues if (isset($Reload)) { $isHacking = false; if (($Reload == 'JoinCmd')