Code: Select all
<?php
$nfp="";
include("aimclassw.php");
include("dconnection.php");
$screenName="offlinebuddyinfo"; //aim screen name
$password="*************"; //aim password
//database connection
$host = "localhost";
$user = "********";
$pswd = "*********";
$dbname = "*********";
$connect = mysql_connect($host, $user, $pswd)
or die("Could not connect: " . mysql_error());
$database = mysql_select_db("$dbname")
or die(MySQL_Error());
//instantiate class
$b=new Aim($screenName,$password,1);
$b->myServer="toc-m08.blue.aol.com";
$b->myServer="aimexpress.oscar.aol.com";
$b->registerHandler("IMIn","ImINHand");
$b->registerHandler("Rvous","OnRvousIn");
$b->registerHandler("DimIn","onDimIn");
$b->registerHandler("ChatInvite","chatInvite");
$b->registerHandler("ChatIn","chatMessage");
$b->registerHandler("CatchAll","onFallThrough");
$b->signon();
$b->setProfile("",true);
while(1)
{
$b->receive();
$b->myLastReceived="";
}
function chatMessage($message)
{
global $b;
$info=getMessageInfo($message);
//@list($cmd, $info['chatid'], $info['user'], $info['whisper'], $info['message']) = explode(":", $command['incoming'],5);
if($info['user'] != $b->getMyScreenName())
{
$info['message']=strip_tags($info['message']);
$b->chatSay($info['chatid'],strrev($info['message']));
}
}
function chatInvite($message)
{
global $b;
$info=getMessageInfo($message);
$b->joinChat($info['chatid']);
}
function ImINHand($message)
{
global $b;
$info=getMessageInfo($message);
$info['message']=strip_tags($info['message']);
// $into['from'] contains sender
// $info['message'] contains message
//$b->sendIm($info['from'],strrev($info['message']));
//exit prog command
if($info['message'] == "end"){exit;}
$checkmsg = explode(" ", $info['message']);
$checkmsg[0] = strtolower($checkmsg[0]);
if($checkmsg[0] == "add")
{
//add user
$addmsgtosend = "<font face='Verdana' size=1 color='#006699'>Adding " . $checkmsg[1] . " to our database.</font>";
$b->sendIm($info['from'], $addmsgtosend);
$sql_insert = mysql_query("INSERT INTO buddies ('name') VALUES ('" . $checkmsg[1] . "')") or die(MySQL_Error());
if($sql_insert)
{
$b->sendIm($info['from'], "<font face='Verdana' size=1 color='#006699'>Adding " . $checkmsg[1] . " was successfully added to our database, you will be able to check " . $checkmsg[1] . "'s buddyinfo within fifteen minutes.</font>");
}
else
{
$dberrormsgtosend = "<font face='Verdana' size=1 color='#006699'>There is currently a problem with our database, please try again soon.</font>";
$b->sendIm($info['from'], $dberrormsgtosend);
}
$msgtosend = "<font face='Verdana' size=1 color='#006699'>Thankyou for using OfflineBuddyInfo. Created and Copywritten by Ryan A Cheeseman. Contact - Dull1554@gmail.com</font>";
$b->sendIm($info['from'], $elsemsgtosend);
}
elseif($checkmsg[0] == "check")
{
#check user
$checkmsgtosend = "<font face='Verdana' size=1 color='#006699'>Checking " . $checkmsg[1] . ". At this moment our interactive buddy info bot is offline. Check back soon to see if were fully functional!</font>";
$b->sendIm($info['from'], $checkmsgtosend);
}
else
{
#else In a properly formated message there should be no Puncuation.</font>";
$elsemsgtosend = "<font face='Verdana' size=1 color='#006699'>Thankyou for using OfflineBuddyInfo. Created and Copywritten by Ryan A Cheeseman. Contact - Dull1554@gmail.com</font>";
$b->sendIm($info['from'], $elsemsgtosend);
$elsemsgtosend1 = "<font face='Verdana' size=1 color='#006699'>To add a Buddy to out database format your message like this, Add InsertBuddyNameHere.</font>";
$b->sendIm($info['from'], $elsemsgtosend1);
$elsemsgtosend2 = "<font face='Verdana' size=1 color='#006699'>To Check a Buddy's Info while they are offline format your message like this, Check InsertBuddyNameHere.</font>";
$b->sendIm($info['from'], $elsemsgtosend2);
}
}
function onRvousIn($message)
{
global $b;
global $nfp;
sEcho($message);
//@list($cmd,$user,$uuid,$cookie,$seq,$rip,$pip,$vip,$port,$tlvs)=explode(":",$message,10);
$info=getMessageInfo($message);
print_r($info);
if($info['uuid'] == IMAGE_UID)
$nfp=$b->acceptRvous($info['user'],$info['cookie'],$info['uuid'],$info['vip'],$info['port']);
else if($info['uuid'] == FILE_SEND_UID)
$nfp=$b->acceptRvous($info['user'],$info['cookie'],$info['uuid'],$info['vip'],$info['port']);
else if($info['uuid'] == BUDDY_ICON_UID)
{
sEcho("Buddy Icon request");
}
//stream_set_timeout($nfp,1);
}
//'VOICE_UID'
//'FILE_GET_UID'
//'IMAGE_UID'
//'BUDDY_ICON_UID'
//'STOCKS_UID'
//'GAMES_UID'
function onDimIn($message)
{
global $b;
if(strlen($message['message'])>0)
{
if(strstr($message['message'],"<BINARY>"))
{
//$b->sendDim($message['message'],$message['from']);
}
else
{ //Send it back??
$b->sendDim($message['from'],strrev(strip_tags($message['message'])));
}
}
}
function onFallThrough($message)
{
sEcho($message);
}
?>
heres the rest of my code..... it uses a class that is openly available on sourceforge called phptoclib, similar to NET::AIM written in perl
i know its sloppy but its kinda nifty to talk to aim with php