<?php
include ("config.php");
include ("core.php");
echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML Mobile 1.0//EN\"". " \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Bot</title>
<meta forua="true" http-equiv="Cache-Control" content="no-cache"/>
<meta forua="true" http-equiv="Cache-Control" content="must-revalidate"/>
<?php
connectdb();
echo gettheme($sid);
?>
</head>
<body>
<?php
$action = $_GET["action"];
$sid = $_GET["sid"];
if(islogged($sid)==false){
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 "</body>";
echo "</html>";
exit();
}
$uid = getuid_sid($sid);
if(isbanned($uid)){
echo "<p align=\"center\">";
echo "<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\">Main Page</a></p>";
echo "</body>";
echo "</html>";
exit();
}
?>
<?php
//clearnc();
$id=$_GET["id"];
$botid = "b5dac5f3ee36c184";
$input = $_POST["input"];
$custid=$_POST["custid"];
$hostname = "www.pandorabots.com";
$hostpath = "/pandora/talk-xml";
//$sitename = mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='sitename'"));
//$sitename = $sitename[0];
echo "<p align=\"center\">";
echo "<br/>";
addonline(getuid_sid($sid),"Chatting to IF Bot","");
if ($input!="")
{
$sendData = "botid=".$botid."&input=".urlencode($input)."&custid=".$custid;
// Send the request to Pandorabot
$result = PostToHost($hostname, $hostpath, $sendData);
//TODO: Process the returned XML as an XML document instead of a big string.
// Use string manipulations to pull out the 'custid' and 'that' values.
$pos = strpos($result, "custid=\"");
// Extract the custid
if ($pos === false) {
$custid = "";
} else {
$pos += 8;
$endpos = strpos($result, "\"", $pos);
$custid = substr($result, $pos, $endpos - $pos);
}
// Extrat <that> - this is the reply from the Pandorabot
$pos = strpos($result, "<that>");
if ($pos === false) {
$reply = "";
} else {
$pos += 6;
$endpos = strpos($result, "</that>", $pos);
$reply = unhtmlspecialchars(substr($result, $pos, $endpos - $pos));
}
//echo htmlspecialchars( $reply);
$hers = $reply;
$hers = parsemsg($hers);
$input=htmlspecialchars($input);
$nick = getnick_uid($uid);
echo "<br/><b>$nick: </b>$input<br/>";
echo "<b>IF Bot: </b>$hers<br/>";
echo "<br/><form action=\"bot.php?sid=$sid\" method=\"post\"><input type=\"text\" name=\"input\" maxlength=\"255\"/>";
echo "<input type=\"hidden\" name=\"custid\" value=\"$custid\"/>";
echo "<br/><input type=\"submit\" name=\"submit\" value=\"Send\"/>";
}else{
echo "Hi!!! You can chat with our Artificial Intelligent computer which behaves as a female human being.<br/> Her name is IF Bot, have fun! But she knows english only so talk to her in English only.<br/>";
echo "<br/><form action=\"bot.php?sid=$sid\" method=\"post\"><input type=\"text\" name=\"input\" maxlength=\"255\"/>";
echo "<input type=\"hidden\" name=\"custid\" value=\"$custid\"/>";
echo "<br/><input type=\"submit\" name=\"submit\" value=\"Send\"/>";
}
echo "</p>";
echo "<p><small>[0.<a href=\"index.php?action=main&sid=$sid\" accesskey=\"0\">Main Menu</a>][1.<a href=\"inbox.php?action=main&sid=$sid\" accesskey=\"1\">Inbox</a>][2.<a href=\"lists.php?action=buds&sid=$sid\" accesskey=\"2\">Buddies</a>][3.<a href=\"index.php?action=viewcat&sid=$sid&cid=1\" accesskey=\"3\">Forums</a>][4.<a href=\"index.php?action=chat&sid=$sid\" accesskey=\"4\">Chat</a>][5.<a href=\"index.php?action=online&sid=$sid\" accesskey=\"5\">Online Users</a>][6.<a href=\"index.php?action=viewfrm&sid=$sid&fid=7\" accesskey=\"6\">Everyday Forum</a>][7.<a href=\"index.php?action=myclub&sid=$sid\" accesskey=\"7\">My Clubs</a>][8.<a href=\"lists.php?action=blogs&sid=$sid&who=".getuid_sid($sid)."\" accesskey=\"8\">My Blog</a>][9.<a href=\"index.php?action=act&sid=$sid\" accesskey=\"9\">Active Topics</a>]</small></p>";
echo "</body>";
function unhtmlspecialchars( $string )
{
$string = str_replace ( '&', '&', $string );
$string = str_replace ( ''', '\'', $string );
$string = str_replace ( '"', '"', $string );
$string = str_replace ( '<', '<', $string );
$string = str_replace ( '>', '>', $string );
$string = str_replace ( 'ü', '?', $string );
$string = str_replace ( 'Ü', '?', $string );
$string = str_replace ( 'ä', '?', $string );
$string = str_replace ( 'Ä', '?', $string );
$string = str_replace ( 'ö', '?', $string );
$string = str_replace ( 'Ö', '?', $string );
return $string;
}
?>
</html>