|
From: Lo?c C. <lo...@us...> - 2001-04-03 20:14:57
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/index_libs
In directory usw-pr-cvs1:/tmp/cvs-serv5164/chat/lib/index_libs
Added Files:
main_index.lib.php3 misc.lib.js
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 library is called by the starting script of phpMyChat (usually an |
// | 'index.php3' nammed script) to: |
// | - displays the start screen of phpMyChat; |
// | - validates the settings the user typed in to enter the chat; |
// | - then defines and launch the phpMyChat frameset. |
// | |
// | It is splitted in three parts: |
// | I. the common work at the beginning; |
// | II. all what have to be done once the user has submit the form; |
// | III. and two functions ('pmcStartpageHeaders()' and |
// | 'pmcStartpageLayout()') that defines the HTML code for the |
// | start page. |
// +--------------------------------------------------------------------------+
// | From the phpMyChat project: |
// | http://www.phpheaven.net/projects/phpMyChat/ |
// | |
// | Authors: the phpHeaven-team <php...@ya...> |
// +--------------------------------------------------------------------------+
//
// $Id: main_index.lib.php3,v 1.1 2001/04/03 20:14:52 loic1 Exp $
//
// Main library used to enter the chat.
//
// --------------------------- PART I : Common work ---------------------------
/**
* Gets the extension for the php scripts
*/
if (!isset($PHP_SELF))
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
if (!defined('C_EXTENSION'))
define('C_EXTENSION', (substr($PHP_SELF, -1) == 3) ? 'php3' : 'php');
/**
* Gets some core libraries
*/
require('./' . _CHAT_PATH . 'config/config.lib.' . C_EXTENSION);
require('./' . _CHAT_PATH . 'lib/common.lib.' . C_EXTENSION);
require('./' . _CHAT_PATH . 'lib/database/' . C_DB_TYPE . '.lib.' . C_EXTENSION);
require('./' . _CHAT_PATH . 'lib/clean.lib.' . C_EXTENSION);
/**
* Gets the names and values for variables sent or posted to this script and
* for cookies
*
* Uses the 'pmcGrabGlobals()' and 'pmcHandleMagicQuotes()' functions defined
* in the 'chat/lib/common.lib.php3' library.
*/
$toGrab = array('%GET', '%POST', '%COOKIE');
pmcGrabGlobals($toGrab);
// Ensures compatibilty with old releases
require('./'. _CHAT_PATH . 'lib/upgrades.lib.' . C_EXTENSION);
// Unslashes values of variables sent to this script
if (!empty($newTargetRoom))
$newTargetRoom = pmcHandleMagicQuotes($newTargetRoom, '1', '', 'del');
if (!empty($nick))
$nick = pmcHandleMagicQuotes($nick, '1', '', 'del');
if (!empty($password))
$password = pmcHandleMagicQuotes($password, '1', '', 'del');
if (!empty($enterDefaultRoomName))
$enterDefaultRoomName = pmcHandleMagicQuotes($enterDefaultRoomName, '1', '', 'del');
if (!empty($enterOtherRoomName))
$enterOtherRoomName = pmcHandleMagicQuotes($enterOtherRoomName, '1', '', 'del');
if (!empty($createRoomName))
$createRoomName = pmcHandleMagicQuotes($createRoomName, '1', '', 'del');
if (!empty($exitFrom))
$exitFrom = pmcHandleMagicQuotes($exitFrom, '1', '', 'del');
if (!empty($cookieUsername))
$cookieUsername = pmcHandleMagicQuotes($cookieUsername, '1', '', 'del');
if (!empty($cookieRoom))
$cookieRoom = pmcHandleMagicQuotes($cookieRoom, '1', '', 'del');
/**
* Start the session handler
*/
require('./' . _CHAT_PATH . '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_SESS_DEL * 60,
''
);
dbSessionstart();
/**
* Defines the language to be used
*/
if (!empty($lang)
&& file_exists('./' . _CHAT_PATH . 'localization/' . $lang . '/localized.chat.' . C_EXTENSION))
{
$dbSessionVars['lang'] = $lang;
unset($lang);
}
require('./' . _CHAT_PATH . 'localization/languages.lib.' . C_EXTENSION);
require('./' . _CHAT_PATH . '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, true);
/**
* Defines some variables
*
* The 'pmcSlashSingleQuotes()' fonction is defined in the
* 'chat/lib/common.lib.php3' library
*/
$error = '';
// Get the relative path to the script that called this one
$action = basename($PHP_SELF);
$dbSessionVars['from'] = urlencode(ereg_replace('[^/]+/', '../', _CHAT_PATH) . $action);
// Sets the $isFontMsg to true when the user logs in for the first time and a
// specific font face have to be used (iso-code is 'x-user-defined')
$isFontMsg = (empty($nick) && defined('L_FONT_NAME'));
$latin1 = (L_CHARSET == 'iso-8859-1');
// Defines the message to be displayed if this script is called after an user
// has been kicked
if (dbSessionIsRegistered('kicked')) // $kicked is among session data
{
switch ($dbSessionVars['kicked'])
{
case 1:
// The user was logged into two rooms at the same time
$error = L_ERR_USR_19;
break;
case 2:
// The administrator has cleaned the room
$error = L_REG_39;
break;
case 3:
// Simple kick
$error = L_REG_18;
break;
case 4:
// The user has been banished from the room he was chatting inside
$error = L_ERR_USR_20;
default:
// void()
}
}
// Try to get the nickname from session data, then slashes it
if (empty($nick) && dbSessionIsRegistered('nick'))
$nick = $dbSessionVars['nick'];
if (isset($nick))
$slashedNick = pmcSlashSingleQuotes($nick);
// Unset some variables that may be the cause of security holes
if ($dbSessionIsNew)
{
if (isset($exitMode))
unset($exitMode);
if (isset($newTargetRoom))
unset($newTargetRoom);
if (isset($reloading))
unset($reloading);
}
// Instantiates a new pmcDB object
$dbLink = new pmcDB;
/**
* Removes user from the 'users' table if he left a room and, if required
* ($exitMode value is 2), sends a notification of exit to the 'messages'
* table
*
* The 'pmcSlashSingleQuotes()' and 'pmcSpecialChars()' functions are defined
* inside the 'chat/lib/common.lib.php3' library
*/
// Check for abnormal termination of a chat session
if (!isset($exitMode))
{
$dbLink->query("SELECT COUNT(*) FROM " . C_USR_TBL . " WHERE session_id = '$dbSessionId'");
list($exitMode) = $dbLink->nextRecord();
$dbLink->cleanResults();
}
// Do remove user
if ($exitMode)
{
$nickForNotifications = pmcSlashSingleQuotes(pmcSlashSingleQuotes(pmcSpecialChars($slashedNick, $latin1)));
$exitedRoomName = pmcSlashSingleQuotes($dbSessionVars['targetRoom']);
$dbLink->query("DELETE FROM " . C_USR_TBL . " WHERE session_id = '$dbSessionId' AND room = '$exitedRoomName'");
// Put exit notification if necessary
if ($exitMode == 2 && $dbLink->affectedRows() > 0)
{
$exitedRoomType = $dbSessionVars['roomType'];
$dbLink->query("INSERT INTO " . C_MSG_TBL . " VALUES ($exitedRoomType, '$exitedRoomName', 'SYS exit', '', " . time() . ", NULL, '#666699', 'sprintf(L_EXIT_ROM, \'$nickForNotifications\')', 'sprintf(L_EXIT_ROM, \'$nickForNotifications\')')");
unset($exitedRoomType);
}
// Defines the room to enter settings if required
if (isset($newTargetRoom))
{
$roomType = substr($newTargetRoom, 0, 1);
$targetRoom = substr($newTargetRoom, 1);
unset($newTargetRoom);
$reloading = 'joinCmd';
$jsVersion = $dbSessionVars['jsVersion'];
}
}
// -------------- PART II : Work to do if the form was submitted --------------
if (!empty($reloading) || !empty($submitType))
{
/**
* Initializes misc. variables
*/
if (!isset($password))
$password = '';
if (dbSessionIsRegistered('pwdHash'))
$pwdHash = $dbSessionVars['pwdHash'];
if (!isset($pwdHash))
$pwdHash = '';
$isRegUser = false;
$regUserPerms = 'user';
$regUserModeratedRooms = '';
$wasInRoom = '';
// If no room has been specified, defines the first room among the default
// public ones as the room to enter in
if (isset($submitType) &&
(C_VERSION == 0 || (empty($enterDefaultRoomName) && empty($enterOtherRoomName) && empty($createRoomName))))
$enterDefaultRoomName = $defaultChatRooms[0];
/**
* Gets some more libraries that will be used to validate the settings
* submitted
*/
if (C_BAD_WORDS == 1)
include('./' . _CHAT_PATH . 'lib/swearing.lib.' . C_EXTENSION);
include('./' . _CHAT_PATH . 'lib/index_libs/index_validation.lib.' . C_EXTENSION);
/**
* Optimize some of the tables
*/
$dbLink->optimize(C_MSG_TBL);
$dbLink->optimize(C_USR_TBL);
$dbLink->optimize(C_SESS_TBL);
/**
* Ensures the nick is a valid one and, if it's a registered nick, ensures
* also the convenient password has been submitted.
*
* This part of the script is skipped if the frameset is reloaded because
* of the NS4+ resize bug, because the user has run the '/join' command or
* because he has clicked on a room name at the 'users' frame.
* In these cases, the nick and the password have already been validated.
*
* The function 'pmcValidateNickAndPaswd()' is defined inside the
* 'chat/lib/index_validation.lib.php3' library
*/
if (empty($reloading))
{
$error = pmcValidateNickAndPaswd( $isRegUser, $regUserPerms, $regUserModeratedRooms,
$wasInRoom);
if ($error == '')
{
// Puts the nick in a cookie that will expire in one year
$cookieUsername = urlencode($nick);
setcookie('cookieUsername', $cookieUsername, time() + 60*60*24*365);
}
} // end of the nick and password validation work
/**
* Gets the permission level of the user and the list of the rooms he is
* moderator for if this script is run following a '/join' command or a click
* on a room name at the 'users' frame.
*
* The 'pmcHandleMagicQuotes()' function is defined inside the
* 'chat/lib/common.lib.php3' library
*/
else if ($reloading == 'joinCmd')
{
$dbLink->query("SELECT perms, rooms FROM " . C_REG_TBL . " WHERE username = '$slashedNick' LIMIT 1");
$isRegUser = (list($regUserPerms, $regUserModeratedRooms) = $dbLink->nextRecord());
if ($isRegUser)
$regUserModeratedRooms = pmcHandleMagicQuotes($regUserModeratedRooms, '', 1, 'del');
$dbLink->cleanResults();
} // end of get permission level in reloading case
/**
* Ensures the user is not banished from the room he wants to enter in
*
* This part of the script is skipped if the frameset is reloaded because
* of the NS4+ resize bug, because the user has run the '/join' command or
* because he has clicked on a room name at the 'users' frame.
* In these cases, banishement of the user has already been checked.
*/
if ($error == '' && empty($reloading))
{
if (C_BANISH && $regUserPerms != 'admin')
{
include('./' . _CHAT_PATH . 'lib/banish.lib.' . C_EXTENSION);
if ($isBanished)
$error = L_ERR_USR_20;
}
} // end of the banishment test
/**
* Ensures the user can create the room he wants to, then defines the
* permission level this user will be granted for this room
*
* The function 'pmcValidateRoomCreation()' is defined inside the
* 'chat/lib/index_validation.lib.php3' library
*/
if ($error == '' && !empty($createRoomName))
{
$error = pmcValidateRoomCreation($regUserPerms, $regUserModeratedRooms);
} // end of the validation of room creation
/**
* Enters the chat
*
* The 'pmcIsInto()', 'pmcHandleMagicQuotes()' and 'pmcSlashSingleQuotes()'
* functions are defined in the 'chat/lib/common.lib.php3' library.
*/
if ($error == '')
{
// Updates tables
include('./' . _CHAT_PATH . 'lib/index_libs/do_enter_db_work.lib.' . C_EXTENSION);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "DTD/xhtml1-frameset.dtd">
<html>
<head>
<title><?php echo(APP_NAME); ?></title>
<link rel="shortcut icon" href="<?php echo(_CHAT_PATH); ?>favicon.ico" />
<?php
// Gets the JavaScript instructions
include('./' . _CHAT_PATH . 'lib/index_libs/do_enter_js_work.lib.' . C_EXTENSION);
?>
</head>
<?php
// Gets the frameset definition
include('./' . _CHAT_PATH .'lib/index_libs/do_enter_frameset.lib.' . C_EXTENSION);
?>
</html>
<?php
$dbLink->close();
exit();
} // end of the case where entering the chat is allowed
} // end of the work to do if the form has been submitted
// ------------------- PART III : Display the starting page -------------------
/**
* Adds instructions to the '<head>' part of the starting page
*
* @param boolean whether to show the 'APP_NAME' value as the title of
* page or not
* @param boolean whether to associate the phpMyChat icon to 'favorites'
* url or not
*
* @access public
*/
function pmcStartpageHeaders($putTitle = true, $useIcon = true)
{
echo("\n");
if ($putTitle)
echo('<title>' . APP_NAME . '</title>' . "\n");
?>
<!--
The lines below are usefull for debugging purpose, please do not remove them!
Release: phpMyChat 0.14.3
© 2000-2001 The phpHeaven Team (http://www.phpheaven.net/)
-->
<meta name="description" content="phpMyChat" />
<meta name="keywords" content="phpMyChat" />
<?php
echo("\n");
if ($useIcon)
echo('<link rel="shortcut icon" href="' . _CHAT_PATH . 'favicon.ico" />' ."\n");
$cssUrl = pmcUrlForStyleSheet('start_page', L_CHARSET, (defined('L_FONT_NAME')) ? L_FONT_NAME : '', L_FONT_SIZE);
?>
<link rel="stylesheet" href="<?php echo($cssUrl); ?>" type="text/css" />
<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 jsFrom = '<?php echo($GLOBALS['dbSessionVars']['from']); ?>';
var jsLang = '<?php echo($GLOBALS['dbSessionVars']['lang']); ?>';
var jsUrlArgSeparator = '<?php echo($GLOBALS['pmcQueryArgSeparator']); ?>';
var jsIsNS4 = (typeof(document.layers) != 'undefined') ? 1 : 0;
var jsIsIE4 = ((typeof(document.all) != 'undefined') && (parseInt(navigator.appVersion) >=4 )) ? 1 : 0;
var jsWhichVersion = (jsIsNS4 || jsIsIE4) ? 'high' : 'low';
var jsIsJs11 = (typeof(window.focus) != 'undefined');
var jsTutorialWin = null;
var jsUsersPopupWin = null;
var jsRegPopupWin = null;
var jsErrorNick1 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_2))); ?>';
var jsErrorNick2 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_16))); ?>';
var jsErrorPswd1 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_4))); ?>';
var jsErrorPswd2 = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_USR_13))); ?>';
var jsErrorRoom = '<?php echo(pmcSlashSingleQuotes(str_replace('\\', '\\\\', L_ERR_ROM_1))); ?>';
// -->
</script>
<script src="<?php echo(_CHAT_PATH); ?>lib/index_libs/start_page.lib.js" type="text/javascript" language="javascript"></script>
<?php
echo("\n");
} // end of the 'pmcStartpageHeaders()' function;
/**
* Draws the initial table/form
*
* This function defines three way to log into the chat according to the
* browser capacities:
* - if it handles DHTML, standart scripts will be used, else the scripts with
* a '_low' suffix will be ran;
* - if it handles JavaScript 1.1, a color picker will be used at the 'input'
* frame, else a drop down list will be displayed.
*
* @global string an instance of the pmcDB class
* @global string the name of the target script for the form
* @global array the list of the available translations
* @global string the list of default public chat rooms
* @global string the error message
* @global string the argument separator to use for url query part
* @global array the session data
*
* @access public
*/
function pmcStartpageLayout()
{
global $dbLink;
global $action;
global $availableLanguages;
global $defaultChatRooms;
global $error;
global $pmcQueryArgSeparator;
global $dbSessionVars;
// Try to get some data from session or cookies
if (dbSessionIsRegistered('nick'))
$layoutNick = $dbSessionVars['nick'];
else if (isset($GLOBALS['cookieUsername']))
$layoutNick = $GLOBALS['cookieUsername'];
else
$layoutNick = '';
if (dbSessionIsRegistered('targetRoom'))
$layoutRoom = $dbSessionVars['targetRoom'];
else if (isset($GLOBALS['cookieRoom']))
$layoutRoom = $GLOBALS['cookieRoom'];
else
$layoutRoom = '';
if (dbSessionIsRegistered('roomType'))
$layoutRoomType = $dbSessionVars['roomType'];
else if (isset($GLOBALS['cookieRoomType']))
$layoutRoomType = $GLOBALS['cookieRoomType'];
else
$layoutRoomType = '';
?>
<table align="center" cellpadding="5" class="chatBody">
<tr>
<td class="chatBody">
<center>
<!-- Title and messages -->
<span class="chatTitle"><?php echo(APP_NAME . ' ' . APP_VERSION); ?></span>
<br /><br />
<?php
// Displays a message for translations with an 'x-user-defined' charset
if (defined('L_FONT_NAME'))
{
$pathToFont = _CHAT_PATH . 'localization/' . $dbSessionVars['lang'] . '/' . L_FONT_NAME . '.zip';
if (file_exists($pathToFont))
{
if ($error == '' && $GLOBALS['isFontMsg'])
{
echo("\t" . '<span class="chatError">' . "\n");
echo("\t\t\t" . 'This translation of ' . APP_NAME . ' requires the <a href="' . $pathToFont . '" class="chatFonts">' . L_FONT_NAME . ' font face</a>' . "\n");
echo("\t\t" . '</span>' . "\n");
echo("\t\t" . '<br /><br />' . "\n");
}
}
}
echo("\n");
$lowTutorialUrl = _CHAT_PATH . 'tutorial_popup.' . C_EXTENSION . '?lang=' . $dbSessionVars['lang'] . $pmcQueryArgSeparator . 'jsVersion=low';
?>
<a href="<?php echo($lowTutorialUrl); ?>" onclick="pmcTutorialPopup(); return false" class="chatLink" target="_blank"><?php echo(L_TUTORIAL); ?></a>
<br /><br />
<span class="chatP1">
<?php
// Displays informating messages
echo("\t\t" . L_WEL_1 . ' ' . C_MSG_DEL . ' ' . L_WEL_2 . ' ' . C_USR_DEL . ' ' . L_WEL_3 . '<br /><br />' . "\n");
// Displays the message about currently chatting users
if ($dbLink->query("SELECT DISTINCT u.username FROM " . C_USR_TBL . " u, " . C_MSG_TBL . " m WHERE u.room = m.room AND m.type = 1"))
{
$chattingCnt = $dbLink->numRows();
$usersPopupLink = ' <a href="' . _CHAT_PATH . 'users_popup_low.' . C_EXTENSION . '?' . dbSessionSID('GET') .'" class="chatLink" onclick="pmcUsersPopup(\'' . uniqid('') . '\'); return false" target="_blank">';
$usersPopupLink .= $chattingCnt . ' ';
$usersPopupLink .= ($chattingCnt > 1) ? L_USERS : L_USER;
$usersPopupLink .= '</a>';
echo("\t\t\t" . L_CUR_1 . $usersPopupLink . ' '. L_CUR_2 . "\n");
}
?>
</span>
<br /><br />
<?php
// Displays the error message if required
if (!empty($error))
{
echo("\t" . '<span class="chatError">' . "\n");
echo("\t\t\t" . $error . "\n");
echo("\t\t" . '</span>' . "\n");
echo("\t\t" . '<br /><br />' . "\n");
}
?>
<!-- The main form -->
<form action="<?php echo($action); ?>" method="post" autocomplete="off" name="startingForm" onsubmit="pmcDefineVerField(); return pmcIndexValidate(<?php echo(C_REQUIRE_REGISTER); ?>);">
<?php
// Put the session id in an hidden field
echo("\t" . dbSessionSID('POST'));
?>
<input type="hidden" name="jsVersion" value="low" />
<table border="0" cellpadding="3" class="chatTable">
<tr class="chatCell">
<td align="center" class="chatCell">
<table border="0" class="chatTable">
<?php
// Displays the flags for languages if necessary
if (C_MULTI_LANG == 1)
{
echo("\n");
?>
<!-- Flags to choose the translation -->
<tr class="chatCell">
<td colspan="2" align="center" class="chatCell">
<span class="chatFlags">
<?php
echo("\n");
asort($availableLanguages);
reset($availableLanguages);
$i = 0;
while (list($key, $name) = each($availableLanguages))
{
$i++;
echo("\t\t\t\t\t\t\t");
echo(' <a href="' . $action . '?' . dbSessionSID('GET') .'">');
echo('<img src="' . _CHAT_PATH . 'localization/' . $name . '/flag.gif" border="0" width="24" height="16" alt="' . ucfirst(str_replace('_', ' ', $name)) . '" /></a>');
if ($i % 15 == 0 && $i < count($availableLanguages))
echo ('<br />');
echo("\n");
}
unset($availableLanguages);
?>
</span>
</td>
</tr>
<?php
}
// Horizontal alignement for cells topic
$cellAlign = (L_CHARSET == 'windows-1256') ? 'left' : 'right';
echo("\n");
?>
<!-- Nick and password -->
<tr class="chatCell">
<th colspan="2" class="chatTabTitle"><?php echo(L_SET_1); ?></th>
</tr>
<tr class="chatCell">
<td align="<?php echo($cellAlign); ?>" valign="top" class="chatCell" nowrap="nowrap"><?php echo(L_SET_2); ?> :</td>
<td valign="top" class="chatCell">
<input type="text" name="nick" size="11" maxlength="10" value="<?php echo(htmlspecialchars(urldecode($layoutNick))); ?>" class="chatBox" />
</td>
</tr>
<tr class="chatCell">
<td align="<?php echo($cellAlign); ?>" valign="top" class="chatCell" nowrap="nowrap"><?php echo(L_REG_1); ?> :</td>
<td valign="top" class="chatCell" nowrap="nowrap">
<input type="password" name="password" size="11" maxlength="16" class="chatBox" />
<?php
if (!C_REQUIRE_REGISTER)
{
echo("\t\t\t\t\t");
echo(' <u>' . L_REG_1r .'</u>');
echo("\n");
}
?>
</td>
</tr>
<tr class="chatCell">
<td class="chatCell"> </td>
</tr>
<!-- Registration links -->
<tr class="chatCell">
<th colspan="2" class="chatTabTitle"><?php echo(L_REG_2); ?></th>
</tr>
<tr class="chatCell">
<td align="center" colspan="2" class="chatCell">
<br />
<a href="<?php echo(_CHAT_PATH); ?>profile_reg.<?php echo(C_EXTENSION); ?>?<?php echo(dbSessionSID('GET')); ?>" class="chatReg" onclick="pmcRegPopups('profile_reg'); return false" target="_blank"><?php echo(L_REG_3); ?></a>
| <a href="<?php echo(_CHAT_PATH); ?>profile_edit.<?php echo(C_EXTENSION); ?>?<?php echo(dbSessionSID('GET')); ?>" class="chatReg" onclick="pmcRegPopups('profile_edit'); return false" target="_blank"><?php echo(L_REG_4); ?></a>
<?php
if (C_SHOW_DEL_PROF)
{
echo("\n");
?>
| <a href="<?php echo(_CHAT_PATH); ?>profile_del.<?php echo(C_EXTENSION); ?>?<?php echo(dbSessionSID('GET')); ?>" class="chatReg" onclick="pmcRegPopups('profile_del'); return false" target="_blank"><?php echo(L_REG_5); ?></a>
<?php
}
if (C_SHOW_ADMIN)
{
echo("\n");
?>
|| <a href="<?php echo(_CHAT_PATH); ?>admin.<?php echo(C_EXTENSION); ?>?<?php echo(dbSessionSID('GET')); ?>" class="chatReg" onclick="pmcRegPopups('admin'); return false" target="_blank"><?php echo(L_REG_35); ?></a>
<?php
}
echo("\n");
?>
</td>
</tr>
<?php
if (C_VERSION)
{
echo("\n");
?>
<tr class="chatCell">
<td colspan="2" class="ChatCell"> </td>
</tr>
<!-- Rooms choice -->
<tr class="chatCell">
<th colspan="2" class="chatTabTitle"><?php echo(L_SET_5); ?></th>
</tr>
</table>
<table border="0" class="chatTable">
<tr class="chatCell">
<td align="<?php echo($cellAlign); ?>" valign="top" class="chatCell" nowrap="nowrap"><?php echo(L_SET_6); ?> :</td>
<td valign="top" class="chatCell">
<select name="enterDefaultRoomName" class="chatBox"<?php if (C_VERSION == 2) echo(' onchange="pmcResetRoomBox(\'default\');"'); ?>>
<option value=""><?php echo(L_SET_7); ?></option>
<?php
// Displays default rooms in the drop down list
$defaultRoomFound = false;
$defaultRoomsString = '';
$prevRoom = ($layoutRoom != '') ? urldecode($layoutRoom) : '';
echo("\n");
for ($i = 0; $i < count($defaultChatRooms); $i++)
{
$tmpRoom = stripslashes($defaultChatRooms[$i]);
if ($defaultRoomsString != '')
$defaultRoomsString .= ',';
$defaultRoomsString .= $tmpRoom;
echo("\t\t\t\t\t\t\t");
echo('<option value="' . htmlspecialchars($tmpRoom) . '"');
if (strcasecmp($tmpRoom, $prevRoom) == 0)
{
echo(' selected="selected"');
$defaultRoomFound = true;
}
echo('>' . htmlspecialchars($tmpRoom) . '</option>');
echo("\n");
}
?>
</select>
</td>
</tr>
<?php
}
if (C_VERSION == 2)
{
echo("\n");
?>
<tr class="chatCell">
<td align="<?php echo($cellAlign); ?>" valign="top" class="chatCell" nowrap="nowrap"><?php echo(L_SET_8); ?> :</td>
<td valign="top" class="chatCell">
<select name="enterOtherRoomName" class="chatBox" onchange="pmcResetRoomBox('otherPub');">
<option value=""><?php echo(L_SET_7); ?></option>
<?php
// Displays the other public rooms in the drop down list
echo("\n");
$dbLink->query("SELECT DISTINCT room FROM " . C_MSG_TBL . " WHERE type = 1 AND username NOT LIKE 'SYS %' ORDER BY room");
while (list($room) = $dbLink->nextRecord())
{
$room = pmcHandleMagicQuotes($room, '', 1, 'del');
if (pmcIsInto($room, stripslashes($defaultRoomsString)) < 0)
{
echo("\t\t\t\t\t\t\t");
echo('<option value="' . htmlspecialchars($room) . '"');
if (strcasecmp($room, $prevRoom) == 0 && !$defaultRoomFound)
{
echo(' selected="selected"');
$defaultRoomFound = true;
}
echo('>' . htmlspecialchars($room) . '</option>');
echo("\n");
}
}
$dbLink->cleanResults();
?>
</select>
</td>
</tr>
<tr class="chatCell">
<td align="<?php echo($cellAlign); ?>" valign="top" class="chatCell" nowrap="nowrap">
<?php echo(L_SET_9 . ' ' . "\n"); ?>
<select name="roomType" class="chatBox">
<option value="1"<?php if ($layoutRoomType == 1 && !$defaultRoomFound) echo(' selected="selected"'); ?>><?php echo(L_SET_10); ?></option>
<option value="0"<?php if ($layoutRoomType == 0 && !$defaultRoomFound) echo(' selected="selected"'); ?>><?php echo(L_SET_11); ?></option>
</select>
<?php echo(' ' . L_SET_12); ?> :
</td>
<td valign="top" class="chatCell">
<input type="text" name="createRoomName" size="11" maxlength="10"<?php if (!$defaultRoomFound && $layoutRoom != '') echo(' value="' . htmlspecialchars(urldecode($layoutRoom)) . '"'); ?> class="chatBox" onchange="pmcResetRoomBox('create');" />
</td>
</tr>
<?php
}
echo("\n");
?>
</table>
<br />
<!-- Submit button -->
<span class="chatP2">
<?php echo(L_SET_13 . ' ' . "\n"); ?>
<input type="submit" name="submitType" value="<?php echo(L_SET_14); ?>" class="chatBox" />
...
</span>
</td>
</tr>
</table>
<!-- Copyright -->
<span class="chatCopy" dir="ltr">
© 2000 <a href="http://www.phpheaven.net/" class="chatLink">The phpHeaven Team</a>
</span>
</form>
</center>
</td>
</tr>
</table>
<?php
/**
* Save the session data and kill the pmcDB handler
*/
$dbSessionVars['msgNumber'] = C_MSG_NB;
$dbSessionVars['refreshDelay'] = C_MSG_REFRESH;
dbSessionSave();
$dbLink->close();
} // end of the 'pmcStartpageLayout()' function
?>
--- NEW FILE ---
//
// +--------------------------------------------------------------------------+
// | phpMyChat version 0.15.0 |
// +--------------------------------------------------------------------------+
// | Copyright (c) 2000-2001 The phpHeaven-team |
// +--------------------------------------------------------------------------+
// | Set of miscellaneous JavaScript functions. |
// | |
// | 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: misc.lib.js,v 1.1 2001/04/03 20:14:52 loic1 Exp $
//
// Set of miscellaneous JavaScript functions.
//
/**
* Ensures the form or an element of the form at the 'input' frame is defined
*
* @param string the name of the element of the form to check for at the
* input frame (null to check the form itself)
*
* @return object the element of the form at the input frame (null if no
* element have to been chacked or if it doesn't exist)
*
* @access public
*/
function pmcGetInputForm(whichElt)
{
jsInputForm = null;
// 1. Ensures the form at the input frame exists
if (typeof(window.frames['input']) == 'undefined')
{
return null;
}
else if (typeof(window.frames['input'].window.document.forms['inputForm']) == 'undefined')
{
return null;
}
else
{
jsInputForm = window.frames['input'].window.document.forms['inputForm'];
} // end of input form tests
// 2. Ensures a specific element of the input form exists
if (jsInputForm)
{
if (whichElt == '' ||
typeof(window.frames['input'].window.document.forms['inputForm'].elements[whichElt]) == 'undefined')
{
return null;
}
else
{
return window.frames['input'].window.document.forms['inputForm'].elements[whichElt];
}
} // end of specific elt tests
} // end of the function 'pmcGetInputForm()'
/**
* Automatically submits a command at the 'input' frame
*
* @param string name of the command to submit
* @param string additional settings to the command
*
* @access public
*/
function pmcRunCmd(cmdName, infos)
{
pm...
[truncated message content] |