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 2259 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
1.07/Linux, Firefox 1.5/Linux, Firefox 1.5/Windows and Firefox 1.5/Mac,
Safari/Mac.
It works perfectly on a lot of configurations but, on some PC with
Firefox 1.5/Windows (not all), the Javascript code with XmlHttpRequest
|
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 that
other ASP.net projects throws error and take my web.config file as thier
web.config. this server is my office server. now this create a big problem
for us.
Please give me the solution of that problem. how site consider their own
web.config...
|
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 ajax request to grab the content. Vice versa
for right arrow key.
Problem: the problem is when you multi-tap the arrow key a few times
consecutively (4/5 of my testers do that to quickly get to the specific
date they want), the ajax request call...
|
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 application in VS before the rebuild and I've
just come to do some work on it, and it has reminded me that I need to
install Ajax 1.0 again as I haven't done it yet (Ajax was installed
before and the site makes use of it) but when I go to install it
|
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 value between 1 and 0). I've made it work so that the image source changes to reflect the new value once the Ajax call is complete. In other words, the image reflects the value of the database field in real-time. Kind of like a real-time checkbox. This...
| |
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 i change something in php file using in ajax function.it not refreshed,means its shows the previous result it not get updated.i can't understand whats the prob.this is the code i m using:
<?
include("config.inc.php");
//error_reporting(0); ...
|
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 request. If i restart the apache
server everything goes back to normal (i assume it severs the connection
to the ajax called function).
I think this is a problem with the javascript part as i have tried it
using a straight post request and have...
|
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 a pop-up that asks him if
he wants to open it or save it. (Of course, he can simply cancel). The
file I send is in an Excel readable file. This works fine for simple
systems where the page is submitted and then the action is performed by php.
...
|
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 looking for ideas.
The sample app is at www.sheldonlg.com/currentPeriod.htm. This sample
app does NOT exhibit the problem. I put it there so that I can talk to
the you about the problem.
In the actual app, initially a bunch of empty divs are...
|
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 ajax method
<html>
<body>
<div id='my_div'>
</div>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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 we have to send another system
| |