var times = 0; function wait() { var conversation = parent.parent.conversationWindow; if (!conversation.isInit()) { if (times<2000) { window.setTimeout(\"wait();\",500); times++; } } else { var format = null; format = new MessageFormat(\"\", \"10pt\", \"\", getRandomColor()); for (var i=1;i<answer.length;i++) conversation.InsertMessageFrom1(\"\",\"小i机器人\", answer[i].innerText, format); this.parent.textBox.disabled=false; this.parent.textBox.focus(); //var head = this.parent.document.getElementById(\"head\"); //head.src = \"\"; } } wait(); </script>"; if(!$fp) { //error tell us return "ERROR:$errstr ($errno)";
} else { $send = "POST /engine.isp HTTP/1.1 Content-Type: application/x-www-form-urlencoded Host: www.xiaoi.com Content-Length: ".strlen($body)." Connection: close Cache-Control: no-cache".$body; //send the server request fputs($fp, $send . "\r\n\r\n"); //loop through the response from the server $res = ""; while(!feof($fp)) { $res .= fgets($fp, 4096); } //close fp - we are done with it fclose($fp); $res = str_replace($head,"",$res); $res = str_replace($foot,"",$res); $res = str_replace("小I","FanBot",$res); $res = str_replace("小I","FanBot",$res); $ret = explode("\n",$res,9); return $ret[8]; } } ?>
function bot($msg = "小I")
{$msg = eregi_replace("FanBot","小I",$msg);
$msg = str_replace("小I","FanBot",$msg);
$msg = str_replace("小I","FanBot",$msg);$fp = fsockopen('www.xiaoi.com', '80', $errno, $errstr, $timeout = 10); $body = "messageText=".$msg."&botid=popup-bot";
$head = "Connection: close
<html>
<head>
<script src='bots/jscript/webmessenger.js'></script>
</head>
<body>
<form name=\"composeForm\" method=\"post\" action=\"engine.isp\">
<input name=\"font\" id=\"font\" type=\"hidden\" value=\"0\" />
<input name=\"bold\" id=\"bold\" type=\"hidden\" value=\"0\" />
<input name=\"italic\" id=\"italic\" type=\"hidden\" value=\"0\" />
<input name=\"underline\" id=\"underline\" type=\"hidden\" value=\"0\" />
<input name=\"fontColor\" id=\"fontColor\" type=\"hidden\" value=\"black\" />
<input name=\"messageText\" id=\"messageText\" type=\"hidden\" />
<input name=\"botid\" value=\"popup-bot\" type=\"hidden\" />
</form><textarea id=\"answer\"></textarea> <textarea id=\"answer\">";$foot = "</textarea>
<textarea id=\"nick\">你</textarea><body>
</html>
<script language=\"vbs\">
function getHexString(num)
hexStr = hex(num)
for i = 5 to len(hexStr) step -1
hexStr = \"0\" + hexStr
next
getHexString = \"#\" + hexStr
end function
</script>
<script>
function getRandomColor() {
var r = Math.random() * 256;
var g = Math.random() * 256;
var b = Math.random() * 256;
if ( r> 0x90 && g > 0x90 && b > 0x90) {
r = 0x90;
g = 0x90;
b = 0x90;
}
return getHexString((r<<16) | (g<<8) | (b<<0) );
}
var times = 0;
function wait() {
var conversation = parent.parent.conversationWindow;
if (!conversation.isInit()) {
if (times<2000) {
window.setTimeout(\"wait();\",500);
times++;
}
}
else {
var format = null;
format = new MessageFormat(\"\", \"10pt\", \"\", getRandomColor());
for (var i=1;i<answer.length;i++)
conversation.InsertMessageFrom1(\"\",\"小i机器人\", answer[i].innerText, format);
this.parent.textBox.disabled=false;
this.parent.textBox.focus();
//var head = this.parent.document.getElementById(\"head\");
//head.src = \"\";
}
}
wait();
</script>";
if(!$fp)
{
//error tell us
return "ERROR:$errstr ($errno)";
}
else
{ $send = "POST /engine.isp HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: www.xiaoi.com
Content-Length: ".strlen($body)."
Connection: close
Cache-Control: no-cache".$body; //send the server request
fputs($fp, $send . "\r\n\r\n"); //loop through the response from the server
$res = "";
while(!feof($fp)) {
$res .= fgets($fp, 4096);
}
//close fp - we are done with it
fclose($fp); $res = str_replace($head,"",$res);
$res = str_replace($foot,"",$res); $res = str_replace("小I","FanBot",$res);
$res = str_replace("小I","FanBot",$res); $ret = explode("\n",$res,9); return $ret[8];
}
}
?>
如果要这个,PHP可以写。如果加上词法及语意分析的,用PHP不适合。需要写推理机,及自学习功能。