Hi,
Ive downloaded ajax im messenger. I want to integrate it with my project.
Project is in PHP and MySql.
I already have a login page in my project. I wanted that it should work with the same login page.
I didnt wanted to use the ajaxim login page.
Is it possible to do it. How can it be done.
I tried learning the code but couldnt make the changes i needed.
Can you plz guide me with this
3 2254 hsriat 1,654
Recognized Expert Top Contributor
Hi,
Ive downloaded ajax im messenger. I want to integrate it with my project.
Project is in PHP and MySql.
I already have a login page in my project. I wanted that it should work with the same login page.
I didnt wanted to use the ajaxim login page.
Is it possible to do it. How can it be done.
I tried learning the code but couldnt make the changes i needed.
Can you plz guide me with this
The Ajax login might be setting some cookies or session. Do the same with your PHP code.
Or in the Ajax IM page, if its validating some cookies, change the name of cookie to the one you are creating in your login page.
It is seting session and i hve also used sessioms in my login page. But still couldnt get it. I ve pasted part of the file i think that needs to be changed. -
<?php
-
require('config.php');
-
-
include('json.php');
-
-
// string sanitizer - only alphanumerics //
-
function sanitize_alphanum($string, $min='', $max='')
-
{
-
$string = preg_replace('/[^a-zA-Z0-9\s]/', '', $string);
-
$len = strlen($string);
-
if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max)))
-
return FALSE;
-
return $string;
-
}
-
-
// connect to database //
-
$link = mysql_connect($sql_host, $sql_user, $sql_pass);
-
mysql_select_db($sql_db);
-
mysql_query('SET NAMES \'utf8\'');
-
-
session_start();
-
-
class Ajax_IM {
-
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;
-
}
-
}
-
-
/**
-
* 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);
-
}
-
-
/**
-
* Logs the user out and destroys the session.
-
*
-
* @return String 'logged_out'
-
* @author Joshua Gross
-
**/
-
function logout() {
-
if(!$this->checkInfo($this->username, $this->password)) return 'invalid';
-
-
$buddylist = $this->getBuddylist($this->username, false);
-
-
$set_status = mysql_query('UPDATE ' . SQL_PREFIX . 'users SET is_online=0, last_ping=\'' . time() . '\' WHERE username=\'' . $this->username . '\'');
-
-
?>
-
The session in my form is $_SESSION['username']
I couldnt understand what is to be done. Can you plz help me.
Thanks.
The login page for ajax im is index.html
I tried editing it. I removed the new user register and forgot password part from it.
Now i want that when a user is logged in my sitr then just by clicking on the im option he should be able to chat without logging in again.
The code of index.html is here:
Plz help me out.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Greg |
last post by:
Hi,
I've designed a bookmark in Ajax / PHP that I will put soon on
sourceforge.net.
But I've got an very tricky bug.
I try it on some computers with Internet Explorer/Windows, Firefox...
|
by: Alok yadav |
last post by:
I have an open IP and on that IP our main application is hosted. it uses
ajax. in web.config file i have register ajax handlers.
there are also other sites or project on that IP. now my problem is...
|
by: alvinwoon |
last post by:
URL: http://events.unl.edu/
Description: i coded a quick and dirty key navigation for the calendar.
if you press left arrow on your keyboard, it will navigate to the
previous date and fire an...
|
by: Karl |
last post by:
Hi all.
I've recently rebuilt my Vista Ultimate workstation with Visual Studio
Team Developer edition. Ive also put on the SQL Server 2005 tools and
it's fully patched.
I was building a web...
|
by: equazcion |
last post by:
Hi,
I have an image reference (IMG) in my page that changes depending on the value of a database field. Clicking the image triggers an Ajax call to change the database field (toggles the field...
| |
by: shivendravikramsingh |
last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
|
by: willl69 |
last post by:
Hi All,
Ive been having a problem of late with one of my sites that uses PHP5 /
Ajax. The problem is that periodically the ajax functions lock up and it
gets stuck in the loading phase of the...
|
by: sheldonlg |
last post by:
I haven't received an answer with my other post, so I am rephrasing it here.
In php I have a 2D array which I "print". The headers force it to be a
file on the user's system. The user receives...
|
by: sheldonlg |
last post by:
Here is my situation. I am coding in an AJAX framework for an intranet
application behind a vpn. Therefore, I can't give you a URL for the
actual app. I made a sample app for viewing and am...
|
by: omerbutt |
last post by:
hi there i have downloaded a prototype tooltip from
http://www.nickstakenburg.com/projects/prototip/
the logic it uses is to call the script after creating the <div> for example i am using the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |