<?php
include("core.php");
include("config.php");
header("Content-type: text/html; charset=ISO-8859-1");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\"\"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
$addy = "wapirate.net";
connectdb();
$action=$_GET["action"];
$id=$_GET["id"];
$sid = $_GET["sid"];
$rid=$_GET["rid"];
$rpw=$_GET["rpw"];
$uid = getuid_sid($sid);
$who = $_GET["who"];
$uexist = isuser($uid);
$theme = mysql_fetch_array(mysql_query("SELECT theme FROM ibwf_users WHERE id='".$uid."'"));
echo "<meta http-equiv=\"refresh\" content=\"20; chat.php?sid=$sid&rid=$rid&rpw=$rpw\">";
if((islogged($sid)==false)||!$uexist)
{
echo "<head>";
echo "<title>Error!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/red_medium.css\">";
echo "</head>";
echo "<body>";
echo "<div><br/>Doh!<br/></div>";
echo "<p align=\"center\">";
echo "You are not logged in<br/>";
echo "Or Your session has been expired<br/><br/>";
echo "<a href=\"index.php\">Login</a>";
echo "</p>";
echo "<div>$addy</div>";
echo "</body>";
echo "</html>";
exit();
}
if(isbanned($uid))
{
echo "<head>";
echo "<title>Error!</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/red_medium.css\">";
echo "</head>";
echo "<body>";
echo "<div><br/>Doh!<br/></div>";
echo "<p align=\"center\">";
echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";
echo "You are <b>Banned</b><br/>";
$banto = mysql_fetch_array(mysql_query("SELECT timeto FROM ibwf_penalties WHERE uid='".$uid."' AND penalty='1'"));
$remain = $banto[0]- time();
$rmsg = gettimemsg($remain);
echo "Time to finish your penalty: $rmsg<br/><br/>";
//echo "<a href=\"index.php\">Login</a>";
echo "</p>";
echo "<div>$addy</div>";
echo "</body>";
echo "</html>";
exit();
}
$isroom = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_rooms WHERE id='".$rid."'"));
if($isroom[0]==0)
{
echo "<head>";
echo "<title>wapirate</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/red_medium.css\">";
echo "</head>";
echo "<body>";
echo "<div><br/>Doh!<br/></div>";
echo "<p align=\"center\">";
echo "This room doesn't exist anymore<br/>";
echo ":P see another room<br/><br/>";
echo "<a href=\"index.php?action=chat&sid=$sid\">Chatrooms</a>";
echo "</p>";
echo "<div>$addy</div>";
echo "</body>";
echo "</html>";
exit();
}
$passworded = mysql_fetch_array(mysql_query("SELECT pass FROM ibwf_rooms WHERE id='".$rid."'"));
if($passworded[0]!="")
{
if($rpw!=$passworded[0])
{
echo "<head>";
echo "<title>wapirate</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/red_medium.css\">";
echo "</head>";
echo "<body>";
echo "<div><br/>Doh!<br/></div>";
echo "<p align=\"center\">";
echo "You can't enter this room<br/>";
echo ":P stay away<br/><br/>";
echo "<a href=\"index.php?action=chat&sid=$sid\">Chatrooms</a>";
echo "</p>";
echo "<div>$addy</div>";
echo "</body>";
echo "</html>";
exit();
}
}
if(!canenter($rid,$sid))
{
echo "<head>";
echo "<title>wapirate</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/red_medium.css\">";
echo "</head>";
echo "<body>";
echo "<div><br/>Doh!<br/></div>";
echo "<timer value=\"200\"/><p align=\"center\">";
echo "You can't enter this room<br/>";
echo ":P stay away<br/><br/>";
echo "<a href=\"index.php?action=chat&sid=$sid\">Chatrooms</a>";
echo "</p>";
echo "<div>$addy</div>";
echo "</body>";
echo "</html>";
exit();
}
addtochat($uid, $rid);
//This Chat Script is by Ra'ed Far'oun
//raed_mfs@yahoo.com
//want to see main menu...
$timeto = 300;
$timenw = time();
$timeout = $timenw-$timeto;
$deleted = mysql_query("DELETE FROM ibwf_chat WHERE timesent<".$timeout."");
if ($action=="")
{
//start of main card
echo "<head>";
echo "<title>wapirate</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><br/>Chat<br/></div>";
echo "<p align=\"center\">";
addonline($uid,"Chatrooms","");
echo "<a href=\"chat.php?action=say&sid=$sid&rid=$rid&rpw=$rpw\">write</a>, ";
echo "<a href=\"chat.php?time=";
echo date('dmHis');
echo "&sid=$sid&rid=$rid&rpw=$rpw";
echo "\">refresh</a>";
$unreadinbox=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE unread='1' AND touid='".$uid."'"));
$pmtotl=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."'"));
$unrd="[".$unreadinbox[0]."/".$pmtotl[0]."]";
if ($unreadinbox[0]>0)
{
echo "<br/><a href=\"inbox5.php?action=main&sid=$sid&rid=$rid&rpw=$rpw\">Inbox $unrd</a>";
}
echo "</p>";
$message=$_POST["message"];
$who = $_POST["who"];
$rinfo = mysql_fetch_array(mysql_query("SELECT censord, freaky FROM ibwf_rooms WHERE id='".$rid."'"));
if (trim($message) != "")
{
$nosm = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_chat WHERE msgtext='".$message."'"));
if($nosm[0]==0){
$chatok = mysql_query("INSERT INTO ibwf_chat SET chatter='".$uid."', who='".$who."', timesent='".time()."', msgtext='".$message."', rid='".$rid."';");
$lstmsg = mysql_query("UPDATE ibwf_rooms SET lastmsg='".time()."' WHERE id='".$rid."'");
$hehe=mysql_fetch_array(mysql_query("SELECT chmsgs FROM ibwf_users WHERE id='".$uid."'"));
$totl = $hehe[0]+1;
$msgst= mysql_query("UPDATE ibwf_users SET chmsgs='".$totl."' WHERE id='".$uid."'");
if($rinfo[1]==2)
{
//oh damn i gotta post this message to ravebabe :(
//will it succeed?
$botid = "a13d14da1e36eb15";
$hostname = "www.pandorabots.com";
$hostpath = "/pandora/talk-xml";
$sendData = "botid=".$botid."&input=".urlencode($message)."&custid=".$custid;
$result = PostToHost($hostname, $hostpath, $sendData);
$pos = strpos($result, "custid=\"");
$pos = strpos($result, "<that>");
if ($pos === false) {
$reply = "";
} else {
$pos += 6;
$endpos = strpos($result, "</that>", $pos);
$reply = unhtmlspecialchars2(substr($result, $pos, $endpos - $pos));
$reply = mysql_escape_string($reply);
}
$chatok = mysql_query("INSERT INTO ibwf_chat SET chatter='8152', who='', timesent='".time()."', msgtext='".$reply." @".getnick_uid($uid)."', rid='".$rid."';");
}
}
$message = "";
}
echo "<p>";
$chats = mysql_query("SELECT chatter, who, timesent, msgtext, exposed FROM ibwf_chat WHERE rid='".$rid."' ORDER BY timesent DESC, id DESC");
$counter=0;
while($chat = mysql_fetch_array($chats))
{
$canc = true;
if($counter<10)
{
if(istrashed($chat[0])){
if($uid!=$chat[0])
{
$canc = false;
}
}
if($chat[1]>0){
$chnick = getnick_uid($chat[0]);
$tonick = getnick_uid($chat[1]);
$tosay = parsepm($chat[3], $sid);
mysql_query("INSERT INTO ibwf_mlog SET action='Chat', details='<b>".$chnick." To ".$tonick."</b><br/> $tosay', actdt='".time()."'");
}
//////good
if(isignored($chat[0],$uid)){
$canc = false;
}
//////////good
if($chat[0]!=$uid)
{
if($chat[1]!=0)
{
if($chat[1]!=$uid)
{
$canc = false;
}
}
}
if($chat[4]=='1' && ismod($uid))
{
$canc = true;
}
if($canc)
{
$cmid = mysql_fetch_array(mysql_query("SELECT chmood FROM ibwf_users WHERE id='".$chat[0]."'"));
$iml = "";
if(($cmid[0]!=0))
{
$mlnk = mysql_fetch_array(mysql_query("SELECT img, text FROM ibwf_moods WHERE id='".$cmid[0]."'"));
$iml = "<img src=\"$mlnk[0]\" alt=\"$mlnk[1]\"/>";
}
$chnick = getnick_uid($chat[0]);
$optlink = $iml.$chnick;
if(($chat[1]!=0)&&($chat[0]==$uid))
{
///out
$iml = "<img src=\"moods/out.gif\" alt=\"!\"/>";
$chnick = getnick_uid($chat[1]);
$optlink = $iml."PM to ".$chnick;
}
if($chat[1]==$uid)
{
///out
$iml = "<img src=\"moods/in.gif\" alt=\"!\"/>";
$chnick = getnick_uid($chat[0]);
$optlink = $iml."PM by ".$chnick;
}
if($chat[4]=='1')
{
///out
$iml = "<img src=\"moods/point.gif\" alt=\"!\"/>";
$chnick = getnick_uid($chat[0]);
$tonick = getnick_uid($chat[1]);
$optlink = "$iml by ".$chnick." to ".$tonick;
}
$ds= date("H.i.s", $chat[2]);
$text = parsepm($chat[3], $sid);
$nos = substr_count($text,"<img src=");
$inca = parsepm($chat[3], $sid);
$chav = substr_count($inca,"*secret*");
if(isspam($text))
{
$chnick = getnick_uid($chat[0]);
echo "<b>Pirate Babe:»<i>*Oi! $chnick, no spamming*</i></b><br/>";
}
else if($nos>3){
$chnick = getnick_uid($chat[0]);
echo "<b>Pirate Babe:»<i>*Hey! $chnick, you can only use 3 smileys per msg*</i></b><br/>";
}else if(isadmin($chat[0])&&$chav>0){
$inca = str_replace("*secret*","",$inca);
echo "<b>PirateBabe:»<i>$inca</i></b><br/>";
}else{
$sres = substr($chat[3],0,3);
if($sres == "/me")
{
$chco = strlen($chat[3]);
$goto = $chco - 3;
$rest = substr($chat[3],3,$goto);
$tosay = parsepm($rest, $sid);
echo "<b><i>*$chnick $tosay*</i></b><br/>";
}else{
$tosay = parsepm($chat[3], $sid);
if($rinfo[0]==1)
{
$tosay = str_replace("fuck","f**k",$tosay);
$tosay = str_replace("shit","sh*t",$tosay);
$tosay = str_replace("dick","d**k",$tosay);
$tosay = str_replace("pussy","pu**y",$tosay);
$tosay = str_replace("cock","c**k",$tosay);
$tosay = str_replace("piss ","p*s* ",$tosay);
}
if($rinfo[1]==1)
{
$tosay = htmlspecialchars($chat[3]);
$tosay = strrev($tosay);
}
echo "<a href=\"chat.php?action=say2&sid=$sid&who=$chat[0]&rid=$rid&rpw=$rpw\">$optlink</a>»$ds<br/>";
echo $tosay."<br/>";
}
}
$counter++;
}
}
}
echo "</p>";
echo "<p align=\"center\">";
$chatters=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_chonline where rid='".$rid."'"));
echo "<br/><a href=\"chat.php?action=inside&sid=$sid&rid=$rid&rpw=$rpw\">Who's Inside [$chatters[0]]</a><br/>";
echo "<a href=\"index.php?action=chat&sid=$sid\">Chatrooms</a><br/>";
echo "<a href=\"index.php?action=main&sid=$sid\">Home</a></p>";
echo "<div>$addy</div>";
echo "</body>";
}
/////////////////////////////////////////////////////SAY
else if ($action=="say") {
addonline($uid,"Writing Chat Message","");
echo "<head>";
echo "<title>wapirate</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><br/>Say<br/></div>";
echo "<form action=\"chat.php?sid=$sid&rid=$rid&rpw=$rpw\" method=\"post\">";
echo "Message: <input name=\"message\" type=\"text\" value=\"\" maxlength=\"255\"/><br/>";
echo "<input type=\"submit\" value=\"Say\"/>";
echo "</form><br/>";
echo "<p>";
echo "<a href=\"lists.php?action=chmood&sid=$sid&page=1\">»Chat Mood</a><br/>";
echo "<a href=\"chat.php?action=inside&sid=$sid&rid=$rid&rpw=$rpw\">»Who's Inside</a><br/>";
echo "<a href=\"chat.php?sid=$sid&rid=$rid&rpw=$rpw\">«Chatroom</a></p>";
//end
echo "<p align=\"center\"><a href=\"index.php?action=chat&sid=$sid\"><img src=\"images/chat.gif\" alt=\"*\"/>Chatrooms</a><br/>";
echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>Home</a></p>";
echo "<div>$addy</div>";
echo "</body>";
}
////////////////////////////////////////////
/////////////////////////////////////////////////////SAY2
else if ($action=="say2") {
echo "<head>";
echo "<title>wapirate</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><br/>Private<br/></div>";
echo "<p align=\"center\">";
$unick = getnick_uid($who);
echo "<b>Private to $unick</b>";
echo "</p>";
addonline($uid,"Writing chat message","");
echo "<form action=\"chat.php?sid=$sid&rid=$rid&rpw=$rpw\" method=\"post\">";
echo "<input type=\"Hidden\" name=\"who\" value=\"\">";
echo "Message: <br/><input name=\"message\" type=\"text\" value=\"\" maxlength=\"255\"/><br/>";
echo "<input type=\"Submit\" name=\"private\" Value=\"Private\"></form>";
//echo "<go href=\"chat.php?sid=$sid&rid=$rid&rpw=$rpw\" method=\"post\">";
// echo "<p>Message: <input name=\"message\" type=\"text\" value=\" \" maxlength=\"255\"/><br/>";
//echo "<input type=\"submit\" value=\"Say\"/>";
//echo "<input type=\"hidden\" name=\"who\" value=\"$who\"/>";
//echo "</form>";
echo "<br/>";
echo "<a href=\"index.php?action=viewuser&sid=$sid&who=$who\">»View $unick's Profile</a><br/>";
echo "<a href=\"chat.php?action=expose&sid=$sid&who=$who&rid=$rid&rpw=$rpw\">»Expose $unick</a><br/>";
echo "<a href=\"chat.php?action=inside&sid=$sid&rid=$rid&rpw=$rpw\">»Who's Inside</a><br/>";
echo "<a href=\"chat.php?sid=$sid&rid=$rid&rpw=$rpw\">«Chatroom</a></p>";
//end
echo "<p align=\"center\"><a href=\"index.php?action=chat&sid=$sid\"><img src=\"images/chat.gif\" alt=\"*\"/>Chatrooms</a><br/>";
echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>Home</a></p>";
echo "<div>$addy</div>";
echo "</body>";
}
////////////////////////////////////////////
//////////////////////////////inside//////////
else if ($action=="inside") {
echo "<head>";
echo "<title>wapirate</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
addonline($uid,"Chat inside list","");
echo "<div><br/>Inside<br/></div>";
echo "<p align=\"center\"><br/>";
$inside=mysql_query("SELECT DISTINCT * FROM ibwf_chonline WHERE rid='".$rid."' and uid IS NOT NULL");
while($ins=mysql_fetch_array($inside))
{
$unick = getnick_uid($ins[1]);
$userl = "<a href=\"chat.php?action=say2&sid=$sid&who=$ins[1]&rid=$rid&rpw=$rpw\">$unick</a>, ";
echo "$userl";
}
echo "<br/><br/>";
echo "<a href=\"chat.php?sid=$sid&rid=$rid&rpw=$rpw\">«Chatroom</a><br/>";
echo "<br/><a href=\"index.php?action=chat&sid=$sid\"><img src=\"images/chat.gif\" alt=\"*\"/>Chatrooms</a><br/>";
echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>Home</a></p>";
echo "<div>$addy</div>";
echo "</body>";
}
else if ($action=="expose") {
addonline($uid,"Chat inside list","");
echo "<head>";
echo "<title>wapirate</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
echo "<div><br/>Expose!<br/></div>";
echo "<p align=\"center\"><br/>";
mysql_query("UPDATE ibwf_chat SET exposed='1' WHERE chatter='".$who."' AND who='".$uid."'");
$unick = getnick_uid($who);
echo "$unick messages to you have been exposed to staff";
echo "<br/><br/>";
echo "<a href=\"chat.php?sid=$sid&rid=$rid&rpw=$rpw\">«Chatroom</a><br/>";
echo "<br/><a href=\"index.php?action=chat&sid=$sid\"><img src=\"images/chat.gif\" alt=\"*\"/>Chatrooms</a><br/>";
echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>Home</a></p>";
echo "<div>$addy</div>";
echo "</body>";
}
echo "</html>";
?>