📄 index.lib.php3
字号:
// ** Enter the chat **
if(!isset($Error) && (isset($N) && $N != ""))
{
if(isset($R2) && $R2 != "")
{
$R = $R2;
}
elseif (!isset($R)) // $R is set when the frameset is reloaded because of the NN4+ resize bug.
{
$T = 1;
$R = (isset($R0) && $R0 != "")? $R0 : $R1;
};
$CookieRoom = urlencode(stripslashes($R));
setcookie("CookieRoom", $CookieRoom, time() + 60*60*24*365); // cookie expires in one year
setcookie("CookieRoomType", $T, time() + 60*60*24*365); // cookie expires in one year
if (isset($HTTP_COOKIE_VARS))
{
if (isset($HTTP_COOKIE_VARS["CookieMsgOrder"])) $CookieMsgOrder = $HTTP_COOKIE_VARS["CookieMsgOrder"];
if (isset($HTTP_COOKIE_VARS["CookieShowTimestamp"])) $CookieShowTimestamp = $HTTP_COOKIE_VARS["CookieShowTimestamp"];
if (isset($HTTP_COOKIE_VARS["CookieNotify"])) $CookieNotify = $HTTP_COOKIE_VARS["CookieNotify"];
};
if (!isset($O)) $O = isset($CookieMsgOrder) ? $CookieMsgOrder : C_MSG_ORDER;
if (!isset($ST)) $ST = isset($CookieShowTimestamp) ? $CookieShowTimestamp : C_SHOW_TIMESTAMP;
if (!isset($NT)) $NT = isset($CookieNotify) ? $CookieNotify : C_NOTIFY;
if (!isset($PWD_Hash)) $PWD_Hash = (isset($reguser) && $reguser ? md5(stripslashes($PASSWORD)) : "");
// Set the $IP var
if (!isset($IP) || $IP == "") include("./${ChatPath}lib/get_IP.lib.php3");
// Define the user status to be put in the users table if necessary. Skipped when the
// frameset is reloaded because of the NN4+ resize bug.
if (!isset($Reload) || $Reload != "NNResize")
{
if (!isset($perms)) $perms = ((isset($reguser) && $reguser) ? "" : "noreg");
switch ($perms)
{
case 'admin':
$status = "a";
break;
case 'moderator':
$status = (room_in(stripslashes($R), $rooms) ? "m" : "r");
break;
case 'noreg':
$status = "u";
break;
default:
$status = "r";
};
};
// Udpates the IP address and the last log. time of the user in the regsistered users table if necessary
if (isset($reguser) && $reguser) $DbLink->query("UPDATE ".C_REG_TBL." SET reg_time='".time()."', ip='$IP' WHERE username='$U'");
// In the case of a registered user that logs again...
// ...in the same room update his logging time and update his IP address;
// ...in an other room kick him from the other room, put a notification message of
// exit for this room, update the users table and put a notification message of
// entrance for the room he log in.
if (isset($relog) && $relog)
{
if (stripslashes($R) == $room)
{
$DbLink->query("UPDATE ".C_USR_TBL." SET u_time='".time()."', ip='$IP' WHERE username='$U'");
}
else
{
$DbLink->query("SELECT type FROM ".C_MSG_TBL." WHERE room='".addslashes($room)."' LIMIT 1");
list($type) = $DbLink->next_record();
$DbLink->clean_results();
$DbLink->query("INSERT INTO ".C_MSG_TBL." VALUES ('$type', '".addslashes($room)."', 'SYS exit', '', ".time().", '', 'sprintf(L_EXIT_ROM, \"".special_char($U,$Latin1)."\")')");
$DbLink->query("INSERT INTO ".C_MSG_TBL." VALUES ($T, '$R', 'SYS enter', '', ".time().", '', 'sprintf(L_ENTER_ROM, \"".special_char($U,$Latin1)."\")')");
$DbLink->query("UPDATE ".C_USR_TBL." SET room='$R',u_time='".time()."', status='$status', ip='$IP' WHERE username='$U'");
};
}
// In the case of an user that logs again in the same room because of the resize bug of NN4+
// update his logging time and his IP address
elseif (isset($Reload) && $Reload == "NNResize")
{
$DbLink->query("UPDATE ".C_USR_TBL." SET room='$R',u_time='".time()."', ip='$IP' WHERE username='$U'");
}
// For all other case of users entering in, set user infos. in users table and put a
// notification message of entrance in the messages table
else
{
$DbLink->query("INSERT INTO ".C_USR_TBL." VALUES ('$R', '$U', '$Latin1', ".time().", '$status','$IP')");
$DbLink->query("INSERT INTO ".C_MSG_TBL." VALUES ($T, '$R', 'SYS enter', '', ".time().", '', 'sprintf(L_ENTER_ROM, \"".special_char($U,$Latin1)."\")')");
};
// Delete 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='$U' AND room='$R'");
if($DbLink->num_rows() != 0)
{
$DelLink = new DB;
while(list($Time) = $DbLink->next_record())
{
$DelLink->query("DELETE FROM ".C_MSG_TBL." WHERE m_time='$Time' AND (username='SYS inviteFrom' OR (username='SYS inviteTo' AND address='$U'))");
};
};
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<HTML>
<HEAD>
<TITLE><?php echo(APP_NAME); ?></TITLE>
<LINK REL="SHORTCUT ICON" HREF="<?php echo($ChatPath); ?>favicon.ico">
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
// Display & remove the server time at the status bas
function clock(gap)
{
cur_date = new Date();
calc_date = new Date(cur_date - gap);
calc_hours = calc_date.getHours();
calc_minuts = calc_date.getMinutes();
calc_seconds = calc_date.getSeconds();
if (calc_hours < 10) calc_hours = "0" + calc_hours;
if (calc_minuts < 10) calc_minuts = "0" + calc_minuts;
if (calc_seconds < 10) calc_seconds = "0" + calc_seconds;
calc_time = calc_hours + ":" + calc_minuts + ":" + calc_seconds;
window.status = "<?php echo(L_SVR_TIME); ?>" + calc_time;
clock_disp = setTimeout('clock(' + gap + ')', 1000);
}
function stop_clock()
{
clearTimeout(clock_disp);
window.status = '';
}
function calc_gap(serv_date)
{
server_date = new Date(serv_date);
local_date = new Date();
return local_date - server_date;
}
<?php
if ($ST == 1)
{
$CorrectedDate = mktime(date("H") + C_TMZ_OFFSET,date("i"),date("s"),date("m"),date("d"),date("Y"));
?>
gap = calc_gap("<?php echo(date("F d, Y H:i:s", $CorrectedDate)); ?>");
clock(gap);
<?php
}
?>
// Automatically execute a command
function runCmd(CmdName,infos)
{
if (input && input.window.document.Form)
{
var inputForm = input.window.document.Form;
if (infos != "") infos = " " + infos;
inputForm.M.value = "/" + CmdName + infos;
inputForm.sent.value = '1';
if (document.all) inputForm.sendForm.disabled = true;
inputForm.submit();
};
};
// Misc vars
var is_ignored_popup = null;
var path2Chat = "<?php echo($ChatPath); ?>";
<?php
if ($Ver == "H")
{
?>
// Emulates replace method for non-js1.1 compliant browsers
if (typeof(location.replace)=='undefined') location.replace = location.assign;
// Forced reload of the loader frame, function called by the input frame
var time4LastLoadedMsg = null;
var time4LastCheckedUser = null;
var refresh_query = "<?php echo("From=$From&L=$L&U=".urlencode(stripslashes($U))."&R=".urlencode(stripslashes($R))."&T=$T&D=$D&N=$N&ST=$ST&NT=$NT&First=1"); ?>";
function force_refresh()
{
query = refresh_query + "&LastLoad=" + time4LastLoadedMsg + "&LastCheck=" + time4LastCheckedUser;
loader.location.replace("loader.php3?" + query);
}
<?php
}
else
{
?>
ver4 = false;
<?php
};
?>
// Launch the help popup
var is_help_popup = null;
function help_popup()
{
if (is_help_popup && !is_help_popup.closed)
{
is_help_popup.focus();
}
else
{
var scrTop = parent.mouseY-400;
var scrLeft = parent.mouseX-<?php echo($Charset == "windows-1256" ? "610" : "10"); ?>;
var scrPos = "top=" + scrTop + ",screenY=" + scrTop + ",left=" + scrLeft + ",screenX=" + scrLeft + ",";
is_help_popup = window.open("help_popup.php3?<?php echo("L=$L&Ver=$Ver"); ?>","help_popup",scrPos + "width=600,height=350,scrollbars=yes,resizable=yes");
};
};
// -->
</SCRIPT>
<SCRIPT TYPE="text/javascript" LANGUAGE="javascript1.1">
<!--
// Misc vars
imgHelpOff = new Image(15,15); imgHelpOff.src = path2Chat + "images/helpOff.gif";
imgHelpOn = new Image(15,15); imgHelpOn.src = path2Chat + "images/helpOn.gif";
imgWhoisOff = new Image(5,9); imgWhoisOff.src = path2Chat + "images/whoisOff.gif";
imgWhoisOn = new Image(5,9); imgWhoisOn.src = path2Chat + "images/whoisOn.gif";
// Put the nick of the user who was clicked on in the messages or the users frames
// to the message box in the input frame;
function userClick(user,privMsg)
{
if (input && input.window.document.Form.MsgTo)
{
input.window.document.Form.MsgTo.value = user;
var msgbox = input.window.document.Form.M;
if (privMsg)
{
var oldStr = msgbox.value;
if (oldStr == "" || oldStr.substring(0,1) != " ") oldStr = " " + oldStr;
msgbox.value = "/TO " + user + oldStr;
}
else
{
msgbox.value += user;
if (msgbox.value == user) msgbox.value += "> ";
};
msgbox.focus();
};
};
// Color choice at the input frame;
imgColor1 = new Image(4,20); imgColor1.src = path2Chat + "images/unselColor.gif";
imgColor2 = new Image(4,20); imgColor2.src = path2Chat + "images/selColor.gif";
var SelColor = null;
function ChangeColor(ColorVal,ColorRank)
{
if (SelColor != ColorRank)
{
if (document.all)
{
obj1 = input.document.all[SelColor];
obj2 = input.document.all[ColorRank];
}
else if (document.images)
{
obj1 = input.document.images[SelColor];
obj2 = input.document.images[ColorRank];
}
else return;
if (SelColor != null)
{
obj1.src = imgColor1.src;
};
SelColor = ColorRank;
input.document.Form.C.value = ColorVal;
obj2.src = imgColor2.src;
};
input.document.Form.M.focus();
};
// Set the focus to the message box at the input frame;
function get_focus()
{
input.window.focus();
input.document.Form.M.focus();
};
// -->
</SCRIPT>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript1.2">
<!--
// Get the position for the help popup
var mouseX = 0;
var mouseY = 0;
function displayLocation(e)
{
if (ver4)
{
if (IE4) e = input.event;
mouseX = e.screenX;
mouseY = e.screenY;
}
return;
}
// Misc vars used in input frame to ensure a valid command is submitted and send an error message else
errMsg = "<?php echo(str_replace("\"","\\\"",L_BAD_CMD)); ?>";
re = /^\/(!$|announce .+|ban .+|clear$|help$|\?$|ignore|invite .+|join .+|kick .+|msg .+|to .+|notify$|order$|profile$|promote .+|quit|exit|bye|refresh|save|show|last|timestamp$|whois .+)/i;
// -->
</SCRIPT>
<?php
if ($Ver == "H")
{
?>
<SCRIPT SRC="<?php echo($ChatPath); ?>lib/usersH.js" TYPE="text/javascript" LANGUAGE="JavaScript1.2"></SCRIPT>
<SCRIPT SRC="<?php echo($ChatPath); ?>lib/connectStateH.js" TYPE="text/javascript" LANGUAGE="JavaScript1.2"></SCRIPT>
<?php
};
$Ver1 = ($Ver == "H" ? $Ver : "L");
$AddPwd2Url = ($PWD_Hash != "" ? "&PWD_Hash=$PWD_Hash" : "");
include("./${ChatPath}lib/frameset_def.lib.php3");
?>
</HTML>
<?php
$DbLink->close();
exit;
}
?>
<?php
// ---- The send_headers function add lines at the head part of your html file.
// $title var allows to show "phpMyChat" as the title for your window if it set to 1/true.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -