Chat Bot Script

Started on the old forum in December 2006 · view the original in the archive · old links redirect here

28 replies · 5,891 views · started 19 years ago · 1 min read

TL;DR · summary of 28 replies
  • -darkdesire needed a working chat bot script for their PHP WAP site and found the provided code didn't work.
  • -subzero provided a basic chat bot script but it caused a syntax error in darkdesire's environment.
  • -GumSlone shared a text file with the corrected code, which worked perfectly after adjustments by darkdesire.
  • -Additional scripts for customization were also shared.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

10 participants
darkdesire Senior · 250 posts #1

Hi, does anyone know where i can get a chat bot script from for my php wap site also a members list script, any help would greatly be appreciated. External image (may be gone)

:p:p:p

GumSlone Administrator Principal · 1,690 posts #2

You can get this scripts from lairlava script, there are many things which can be useful for you as you asking for it.

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

subzero Super moderator Fellow · 3,954 posts #3
<?php

# Chatbot for chat ozzy Script
# Modded by SuB-ZeRo at [email]subzero@goowy.com[/email]

# Send page headers:
header("Cache-Control: no-cache, must-revalidate");

# Get configuration:
include("config.inc.php");

# Clear cache:
header("Pragma: no-cache");

# Affirm content type:
header("Content-type: text/vnd.wap.wml");

# Connect to and select database:
$Connect = mysql_connect("$server","$user","$pass");
mysql_select_db("$dbname");

# Check user details:
$result = mysql_query("select * from members where username='$username' and password='$password'");
$number_of_rows = mysql_num_rows($result);
if ($number_of_rows > 0) { include("check.inc.php"); }
if ($ok>0) {
include("online.inc.php");

# Affirm doctype:
echo "<?xml version=\"1.0\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n";

# Start WML:
echo "<wml>\n";

# Set variables:
$chatbot_name = "Bizarre Babe";
$botid = "b92dd6fffe361ccd";
$chatbot_greeting = "";

# Get variables:
$input = $_POST["input"];
$custid=$_POST["custid"];
$hostname = "www.pandorabots.com";
$hostpath = "/pandora/talk-xml";

# Start page:
echo "<card id=\"\" title=\"$chatbot_name\">\n";
echo "<p align=\"center\">\n";
echo "
\n";

# Show page:
if ($input!="") {
$sendData = "botid=".$botid."&input=".urlencode($input)."&custid=".$custid;
$result = PostToHost($hostname, $hostpath, $sendData);
$pos = strpos($result, "custid=\"");
if ($pos === false) {
$custid = "";
} else {
$pos += 8;
$endpos = strpos($result, "\"", $pos);
$custid = substr($result, $pos, $endpos - $pos);
}

# Get reply:
$pos = strpos($result, "<that>");
if ($pos === false) {
$reply = "";
} else {
$pos += 6;
$endpos = strpos($result, "</that>", $pos);
$reply = unhtmlspecialchars(substr($result, $pos, $endpos - $pos));
}

# Show reply:
//echo htmlspecialchars( $reply);
$hers = $reply;
$input = htmlspecialchars($input);

# Show form:
echo "
[b]$username: [/b]$input
";
echo "[b]$chatbot_name: [/b]$hers
";
echo "
<input type=\"text\" name=\"input\" maxlength=\"120\" value=\"$input\"/><anchor>";
echo " Say!";
echo "<go href=\"chatbot.php?username=$username&password=$password\" method=\"post\">";
echo "<postfield name=\"input\" value=\"$(input)\"/>";
echo "<postfield name=\"custid\" value=\"$custid\"/>";
echo "</go>";
echo "</anchor>
";
} else {
echo $chatbot_greeting;
echo "
";
echo "<input type=\"text\" name=\"input\" maxlength=\"120\" value=\"$input\"/><anchor>";
echo " Say!";
echo "<go href=\"chatbot.php?username=$username&password=$password\" method=\"post\">";
echo "<postfield name=\"input\" value=\"$(input)\"/>";
echo "<postfield name=\"custid\" value=\"$custid\"/>";
echo "</go>";
echo "</anchor>
";
}
echo "

<a href=\"welcome.php?username=$username&password=$password\">» Main Menu «</a>
";

# End page:
echo "</p>";
echo "</card>";
echo "</wml>";
}

# Define function:
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;
}

function PostToHost($host, $path, $data_to_send)
{

                $result = "";
        $fp = fsockopen($host,80,$errno, $errstr, 30);
        if( $fp)
        {
            fputs($fp, "POST $path HTTP/1.0\n");
        fputs($fp, "Host: $host\n");
        fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
        fputs($fp, "Content-length: " . strlen($data_to_send) . "\n");
        fputs($fp, "Connection: close\n\n");
        fputs($fp, $data_to_send);

        while(!feof($fp)) {
                    $result .=  fgets($fp, 128);
        }
        fclose($fp);

        return $result;
        }

}

?>

chat box bot get it name it chatbot.php?username=$username&password=$password now enjoy!!!!!!!!!!!

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

darkdesire Senior · 250 posts #4

The code above doesn't work for me. it kicks up the following error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/sitex1/public_html/chatbot.php on line 112

any ideas ??

:p:p:p

GumSlone Administrator Principal · 1,690 posts #5

The code above doesn't work for me. it kicks up the following error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/sitex1/public_html/chatbot.php on line 112

any ideas ??

Something wrong with bb code here on board. I have attached the script in txt form and removed all mysql queries

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Attachments: chatbot.txt
darkdesire Senior · 250 posts #6

cheers but stil getting the same error

:p:p:p

lamar-wap #10

Here You Go To Set A Greeting Where u see: $chatbot_greeting = "";

You can input YOur OWn Message Like

$chatbot_greeting = "Hello!";
lamar-wap #11

if you wan tyour chatbot name different from the page title here....

<?php

# Chatbot for chat ozzy Script
# Modded by SuB-ZeRo at [email]subzero@goowy.com[/email]

# Send page headers:
header("Cache-Control: no-cache, must-revalidate");

# Clear cache:
header("Pragma: no-cache");

# Affirm content type:
header("Content-type: text/vnd.wap.wml; charset=ISO-8859-1"); 
$ok=1;
if ($ok>0) {

# Affirm doctype:

echo '<?xml version="1.0"?>';
echo '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" 

"http://www.wapforum.org/DTD/wml_1.1.xml">';

# Start WML:
echo "<wml>\n";

# Set variables:
$chatbot_name = "Fimi Babe";
$title = "Fimizone.org";
$botid = "b92dd6fffe361ccd";
$chatbot_greeting = "Hello!";

# Get variables:
$input = $_POST["input"];
$custid= $_POST["custid"];
$hostname = "www.pandorabots.com";
$hostpath = "/pandora/talk-xml";

# Start page:
echo "<card id=\"main\" title=\"$title\">\n";
echo "<p align=\"center\">\n";
echo "
\n";

# Show page:
if ($input!="") {
$sendData = "botid=".$botid."&input=".urlencode($input)."&custid=".$custid;
$result = PostToHost($hostname, $hostpath, $sendData);
$pos = strpos($result, "custid=\"");
if ($pos === false) {
$custid = "";
} else {
$pos += 8;
$endpos = strpos($result, "\"", $pos);
$custid = substr($result, $pos, $endpos - $pos);
}

# Get reply:
$pos = strpos($result, "<that>");
if ($pos === false) {
$reply = "";
} else {
$pos += 6;
$endpos = strpos($result, "</that>", $pos);
$reply = unhtmlspecialchars(substr($result, $pos, $endpos - $pos));
}

# Show reply:
//echo htmlspecialchars( $reply);
$hers = $reply;
$input = htmlspecialchars($input);

# Show form:
echo "
[b]ME: [/b]$input
";
echo "[b]$chatbot_name: [/b]$hers
";
echo "
<input type=\"text\" name=\"input\" maxlength=\"120\" 

value=\"$input\"/><anchor>";
echo "Say!";
echo "<go href=\"chatbot.php?username=$username\" method=\"post\">";
echo "<postfield name=\"input\" value=\"$(input)\"/>";
echo "<postfield name=\"custid\" value=\"$custid\"/>";
echo "</go>";
echo "</anchor>
";
} else {
echo $chatbot_greeting;
echo "
";
echo "<input type=\"text\" name=\"input\" maxlength=\"255\" value=\"\"/><anchor>";
echo " Say!";
echo "<go href=\"chatbot.php?username=$username\" method=\"post\">";
echo "<postfield name=\"input\" value=\"$(input)\"/>";
echo "<postfield name=\"custid\" value=\"$custid\"/>";
echo "</go>";
echo "</anchor>
";
}

echo "

<a href=\"http://fimizone.org\">Fimi Zone Home</a>
";

# End page:
echo "</p>";
echo "</card>";
echo "</wml>";
}

# Define function:
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;
}

function PostToHost($host, $path, $data_to_send)
{

                                $result = "";
                $fp = fsockopen($host,80,$errno, $errstr, 30);
                if( $fp)
                {
                        fputs($fp, "POST $path HTTP/1.0\n");
                fputs($fp, "Host: $host\n");
                fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
                fputs($fp, "Content-length: " . strlen($data_to_send) . "\n");
                fputs($fp, "Connection: close\n\n");
                fputs($fp, $data_to_send);

                while(!feof($fp)) {
                                        $result .=  fgets($fp, 128);
                }
                fclose($fp);

                return $result;
                }

}

?>
subzero Super moderator Fellow · 3,954 posts #14

why no good ??

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

hypetype Developer · 128 posts #15
<?php
header("Content-type: text/vnd.wap.wml");
header("Cache-Control: no-store, no-cache, must-revalidate");
print "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"". " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
?>
<wml>
<?php

include("config.php"); //load config
include("core.php"); //load main functions
connectdb();

        
        //clearnc();
$action=$_GET["action"];
$id=$_GET["id"];
$sid = $_GET["sid"];
$botid = "e67d3bc0fe3660d7";
$input = $_POST["input"];
$custid=$_POST["custid"];
$hostname = "www.pandorabots.com";
$hostpath = "/pandora/talk-xml";

 echo "<card id=\"main\" title=\"Hype Bot\">";                   //start of main card
        echo "<p align=\"center\">";
        echo "
";
        
        
    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 "
[b]You: [/b]$input
";
             echo "[b]Hype Bot: [/b]$hers
";
        echo "
<input type=\"text\" name=\"input\" maxlength=\"120\" value=\"$input\"/><anchor>";
            echo " Say!";
        echo "<go href=\"chatbot.php\" method=\"post\">";
        echo "<postfield name=\"input\" value=\"$(input)\"/>";
        echo "<postfield name=\"custid\" value=\"$custid\"/>";
        echo "</go>";
        echo "</anchor>
";
    }else{
      echo "[size="1"]Have fun talking to Hype Bot[/size]

";
      echo "<input type=\"text\" name=\"input\" maxlength=\"120\" value=\"$input\"/><anchor>";
        echo " Say!";
        echo "<go href=\"chatbot.php\" method=\"post\">";
        echo "<postfield name=\"input\" value=\"$(input)\"/>";
        echo "<postfield name=\"custid\" value=\"$custid\"/>";
        echo "</go>";
        echo "</anchor>
";
    }
    
    echo "

<a href=\"index.php\"><img src=\"images/home.gif\" alt=\"*\"/>Home</a>
";
echo "</p>";
        echo "</card>";

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;
}

?>
</wml>
GumSlone Administrator Principal · 1,690 posts #16

HypeType you script is fine but it would not work without config.php and core.php and the one i have posted is independent

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Guest #18

Gum, would u plz give me an xhtml version of this script? I tried to convert, but failed. Plz help..

Guest #19

sweet but i think i had that already

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close