<?php
include("xhtmlfunctions.php");
header("Content-type: text/html; charset=ISO-8859-1");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
?>
<?php
include("config.php"); //load config
include("core.php"); //load main functions
connectdb();
//clearnc();
$action=$_GET["action"];
$id=$_GET["id"];
$sid = $_GET["sid"];
$botid = "c6f6b1059e3602f7";
$input = $_POST["input"];
$custid=$_POST["custid"];
$hostname = "www.pandorabots.com";
$hostpath = "/pandora/talk-xml";
if(islogged($sid)==false)
{
$pstyle = gettheme($sid);
echo xhtmlhead("$stitle",$pstyle);
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 xhtmlfoot();
exit();
}
$uid = getuid_sid($sid);
if(isbanned($uid))
{
$pstyle = gettheme($sid);
echo xhtmlhead("$stitle",$pstyle);
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_metpenaltiespl WHERE uid='".$uid."' AND penalty='1'"));
$banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
$remain = $banto[0]- (time() - $timeadjust) ;
$rmsg = gettimemsg($remain);
echo "Time to finish your penalty: $rmsg<br/><br/>";
echo "Ban Reason: $banres[0]";
//echo "<a href=\"index.php\">Login</a>";
echo "</p>";
echo xhtmlfoot();
exit();
}
$pstyle = gettheme($sid);
echo xhtmlhead("$stitle Babe",$pstyle); //start of main card
echo "<p align=\"center\">";
echo "<br/>";
addonline(getuid_sid($sid),"Chatting to $stitle Babe","");
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>$stitle Babe: </b>$hers<br/>";
echo "<form action=\"Arawapbabe.php?sid=$sid\" method=\"post\">";
echo "<br/><input type=\"text\" name=\"input\" maxlength=\"120\" value=\"$input\"/>";
echo "<input type=\"submit\" value=\"Say\"/>";
echo "</form>";
echo "<br/>";
}else{
echo "Hello, now you can chat with our chatbot<br/> her name is $stitleBabe, have fun<br/>";
echo "<form action=\"Arawapbabe.php?sid=$sid\" method=\"post\">";
echo "<input type=\"text\" name=\"input\" maxlength=\"120\" value=\"$input\"/>";
echo "<input type=\"submit\" value=\"Say\"/>";
echo "</form>";
echo "<br/>";
}
echo "<br/><br/><a href=\"index.php?action=main&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>Home</a><br/>";
echo "</p>";
echo xhtmlfoot();
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;
}
?>