* 创建: 2005-8-10 22:42
* 修改: 2005-8-11 23:25
*/
error_reporting(7);
session_start();
header("ContentType:text/html;charset=gb2312");
define("SCRIPT", $_SERVER['SCRIPT_NAME']);
define("CHAT_NOTE", "./chat.txt");
define("ONLINE_LIST", "./online.txt");
define("REF_TIME", 5);
define("CHAT_NAME", "黑夜路人聊天室");
define("AD_MSG", "今天是中国情人节, 祝大家情人节快乐!!");
//获取值
if (isset($_GET['action']) && !empty($_GET['action'])) {
$action = $_GET['action'];
}
//如果已经登陆那么直接跳到聊天界面
if (!isset($_GET['action']) && isset($_SESSION['username'])) {
header("location:".SCRIPT."?action=chat");
}
//登陆提示
if (!isset($_GET['action']))
{
if (!session_is_registered('username'))
{
echo " [ ".CHAT_NAME." ] © 2005
";
exit;
}
}
//校验登陆
if ($action=='login')
{
if (isset($_POST['login_user']) && !empty($_POST['login_user'])) {
$username = $_POST['login_user'];
} else {
$username = "游客";
}
session_register('username');
save_online($username, get_client_ip());
header("location:".SCRIPT."?action=chat");
}
//开始聊天www.cncms.com
if ($action=="chat")
{
$online_sum = get_online_sum();
echo "[ ".CHAT_NAME." ]
[当前在线:$online_sum]
|