For those of you not familiar with AjaxIM it is a Free ajax instant messenger.....in which I am trying to integrate into my website for my members.
Where I am stuck right now is having an Autologin, so my members don't have to login to the site and then login to AjaxIM.
I see that Ajax IM does the following when it Logins in:
POST /im/ajax_im.php call=login&username=savj14&password=d41d8cd98f00b204e9800998ecf8427e
Here is the PHP Code portion that handles the Login:
class Ajax_IM {
/**
* Constructor.
*
* @return void
* @author Joshua Gross
**/
function Ajax_IM($call) {
$this->json = new JSON_obj();
$this->username = $_SESSION['username'];
$this->password = $_SESSION['password'];
// run the garbage collector (chance run)
$this->gc();
// figure out which action we need to execute,
// then execute it and print the output
switch($call) {
case 'login':
print $this->login(strtolower($_POST['username']), $_POST['password']);
break;
case 'logout':
print $this->logout();
break;
case 'ping':
print $this->ping($_POST['away']);
break;
case 'send':
print $this->send($_POST['recipient'], $_POST['message'], $_POST['font'], $_POST['fontsize'], $_POST['fontcolor'], $_POST['bold'], $_POST['italic'], $_POST['underline'], $_POST['chatroom']);
break;
case 'addbuddy':
print $this->addBuddy(strtolower($_POST['username']), $_POST['group']);
break;
case 'removebuddy':
print $this->removeBuddy($_POST['username']);
break;
case 'blockbuddy':
print $this->blockBuddy($_POST['username'], ($_POST['status']?$_POST['status']:0));
break;
case 'removegroup':
print $this->removeGroup($_POST['group']);
break;
case 'register':
print $this->register($_POST['username'], $_POST['password'], $_POST['email']);
break;
case 'isuser':
print $this->isUser(strtolower($_POST['username']));
break;
case 'reset':
print $this->reset($_POST['email']);
break;
case 'pwdchange':
print $this->passwordChange($_POST['password'], $_POST['newpwd']);
break;
case 'joinroom':
print $this->joinRoom($_POST['room']);
break;
case 'leaveroom':
print $this->leaveRoom($_POST['room']);
break;
case 'roomlist':
print $this->roomList();
break;
case 'changeicon':
print $this->changeIcon();
break;
case 'changeprofile':
print $this->changeProfile($_POST['profile']);
break;
case 'getprofile':
print $this->getProfile($_POST['user']);
break;
}
}
/**
* Logs the user in and sets the session for the user.
*
* @return JSON object of buddies/blocked users if it usr was successfully logged in, error string otherwise
* @author Joshua Gross
**/
function login($username, $password) {
$user = $this->checkInfo($username, $password, array('admin', 'banned'));
if(!$user) return 'invalid';
if($user['banned'] == 1) return 'banned';
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$_SESSION['admin'] = $user['admin'];
$set_status = mysql_query('UPDATE ' . SQL_PREFIX . 'users SET is_online=1, last_ip=\'' . $_SERVER['REMOTE_ADDR'] . '\' WHERE username=\'' . $username . '\'');
$buddylist = $this->getBuddylist($username, false);
$blocklist = $this->getBlocklist($username);
$this->userEvent($username, $buddylist, 'status', array('status'=>1));
$buddylist = $this->getBuddylistOnline($username);
if(count($buddylist) > 0)
$output['buddy'] = $this->json->encode($buddylist);
else
$output['buddy'] = array();
$output['blocked'] = $this->json->encode($blocklist);
$output['admin'] = $user['admin'];
return $this->json->encode($output);
}
There is also a JS file for the Login as well which I have attached.
I tried going going directly to http://mywebsite/im/ajax_im.php? call=login&username=savj14&password=d41d8cd98f00b204e9800998ecf8427e
But that just returned a Blank Page........Any thoughts on this?