Размер файла: 2.76Kb
<?php
/*
* W@Pchat
* Current Version : 1.2
* Author : Harris Yusuf Arifin (earthweb.biz)
* License : free
* You you can redistribute it and/or modify this script but please always put author's name
*/
session_start();
header("Content-type: text/vnd.wap.wml");
include("headerwml.php");
echo "<wml>";
if ($log=="new")
{
// user must have nickname
if (empty($nn)) {
echo "<card title=\"Error\">";
echo "<onevent type=\"ontimer\">";
echo "<go href=\"login.php\"/>";
echo "</onevent>";
echo "<timer value=\"20\"/>";
echo "<p>";
echo "nickname is required";
echo "</p>";
echo "</card>";
}
// Let's go chat
include("openDB.php");
session_register('sesnickname');
session_register('sestimelogin');
session_register('sesrefreshtime');
session_register('sesid');
$sesid=session_id();
$sesrefreshtime=$refreshtime;
$sesnickname=$nn;
$sestimelogin=time();
$mymess="<i>Welcome to the chatroom</i> ".$sesnickname;
$messtime=time();
$sqllogin ="insert into wapchat (mylogontime,mynick,mymess,messtime) values ('$sestimelogin','$sesnickname','$mymess','$messtime')";
mysql_query($sqllogin) or die(mysql_error());
$expiremess=time()-3600;
$sqlDel="delete from wapchat where messtime < $expiremess";
mysql_query($sqlDel) or die(mysql_error());
}
elseif ($log=="next")
{
include("openDB.php");
$messtime=time();
$mymess=strip_tags($mymess);
$sqlnext ="insert into wapchat (mylogontime,mynick,mymess,messtime) values ('$sestimelogin','$sesnickname','$mymess','$messtime')";
mysql_query($sqlnext) or die(mysql_error());
mysql_close();
}
echo "<card id=\"WAPchat\" title=\"WAPchat\">";
echo "<onevent type=\"ontimer\">\n";
echo "<go href=\"dispMess.php?PHPSESSID=$sesid\"/>\n";
echo "</onevent>\n";
echo "<timer value=\"".$sesrefreshtime."\"/>";
echo "<p align=\"center\">";
echo "<b>Chat Room</b>";
echo "</p>";
echo "<p>";
include ("functionChat.php");
$mess=dispMess($sestimelogin);
$countMess=count($mess);
for ($i = 0; $i<$countMess; $i++)
{
if (ereg("<i>Welcome to the chatroom</i>",$mess[$i][0]) || ereg("<i>has logout</i>",$mess[$i][0])) {
echo "<b>System:</b>".$mess[$i][0]."<br/>";
} else {
echo "<b>".$mess[$i][1].":</b>".$mess[$i][0]."<br/>";
}
}
echo "<do type=\"accept\" label=\"Exit\">";
echo "<go href=\"logout.php?PHPSESSID=$sesid\"/>";
echo "</do>";
echo "<do type=\"accept\" label=\"Write\">";
echo "<go href=\"writeMess.php?PHPSESSID=$sesid\"/>";
echo "</do>";
echo "<do type=\"prev\" label=\"Exit\">";
echo "<go href=\"logout.php?PHPSESSID=$sesid\"/>";
echo "</do>";
echo "</p>";
echo "</card>";
echo "</wml>";
?>