View file indiFun/indifun/bot.php

File size: 5.24Kb
<?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&amp;sid=$sid\" accesskey=\"0\">Main Menu</a>][1.<a href=\"inbox.php?action=main&amp;sid=$sid\" accesskey=\"1\">Inbox</a>][2.<a href=\"lists.php?action=buds&amp;sid=$sid\" accesskey=\"2\">Buddies</a>][3.<a href=\"index.php?action=viewcat&amp;sid=$sid&amp;cid=1\" accesskey=\"3\">Forums</a>][4.<a href=\"index.php?action=chat&amp;sid=$sid\" accesskey=\"4\">Chat</a>][5.<a href=\"index.php?action=online&amp;sid=$sid\" accesskey=\"5\">Online Users</a>][6.<a href=\"index.php?action=viewfrm&amp;sid=$sid&amp;fid=7\" accesskey=\"6\">Everyday Forum</a>][7.<a href=\"index.php?action=myclub&amp;sid=$sid\" accesskey=\"7\">My Clubs</a>][8.<a href=\"lists.php?action=blogs&amp;sid=$sid&amp;who=".getuid_sid($sid)."\" accesskey=\"8\">My Blog</a>][9.<a href=\"index.php?action=act&amp;sid=$sid\" accesskey=\"9\">Active Topics</a>]</small></p>";
        echo "</body>";

function unhtmlspecialchars( $string )
{
  $string = str_replace ( '&amp;', '&', $string );
  $string = str_replace ( '&#039;', '\'', $string );
  $string = str_replace ( '&quot;', '"', $string );
  $string = str_replace ( '&lt;', '<', $string );
  $string = str_replace ( '&gt;', '>', $string );
  $string = str_replace ( '&uuml;', '?', $string );
  $string = str_replace ( '&Uuml;', '?', $string );
  $string = str_replace ( '&auml;', '?', $string );
  $string = str_replace ( '&Auml;', '?', $string );
  $string = str_replace ( '&ouml;', '?', $string );
  $string = str_replace ( '&Ouml;', '?', $string );
  return $string;
}

?>
</html>