473,661 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with ajax im

26 New Member
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
Mar 25 '08 #1
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.
Mar 25 '08 #2
ryan2345
26 New Member
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.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require('config.php');
  3.  
  4. include('json.php');
  5.  
  6. // string sanitizer - only alphanumerics //
  7. function sanitize_alphanum($string, $min='', $max='')
  8. {
  9.    $string = preg_replace('/[^a-zA-Z0-9\s]/', '', $string);
  10.    $len = strlen($string);
  11.    if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max)))
  12.      return FALSE;
  13.    return $string;
  14. }
  15.  
  16. // connect to database //
  17. $link = mysql_connect($sql_host, $sql_user, $sql_pass);
  18. mysql_select_db($sql_db);
  19. mysql_query('SET NAMES \'utf8\'');
  20.  
  21. session_start();
  22.  
  23. class Ajax_IM {
  24.    function Ajax_IM($call) {
  25.       $this->json = new JSON_obj();
  26.  
  27.       $this->username = $_SESSION['username'];
  28.       $this->password = $_SESSION['password'];
  29.  
  30.       // run the garbage collector (chance run)
  31.       $this->gc();
  32.  
  33.       // figure out which action we need to execute,
  34.       // then execute it and print the output
  35.       switch($call) {
  36.          case 'login':
  37.             print $this->login(strtolower($_POST['username']), $_POST['password']);
  38.          break;
  39.  
  40.          case 'logout':
  41.             print $this->logout();
  42.          break;
  43.  
  44.          case 'ping':
  45.             print $this->ping($_POST['away']);
  46.          break;
  47.  
  48.          case 'send':
  49.             print $this->send($_POST['recipient'], $_POST['message'], $_POST['font'], $_POST['fontsize'], $_POST['fontcolor'], $_POST['bold'], $_POST['italic'], $_POST['underline'], $_POST['chatroom']);
  50.          break;
  51.  
  52.          case 'addbuddy':
  53.             print $this->addBuddy(strtolower($_POST['username']), $_POST['group']);
  54.          break;
  55.  
  56.          case 'removebuddy':
  57.             print $this->removeBuddy($_POST['username']);
  58.          break;
  59.  
  60.          case 'blockbuddy':
  61.             print $this->blockBuddy($_POST['username'], ($_POST['status']?$_POST['status']:0));
  62.          break;
  63.  
  64.          case 'removegroup':
  65.             print $this->removeGroup($_POST['group']);
  66.          break;
  67.  
  68.          case 'register':
  69.             print $this->register($_POST['username'], $_POST['password'], $_POST['email']);
  70.          break;
  71.  
  72.          case 'isuser':
  73.             print $this->isUser(strtolower($_POST['username']));
  74.          break;
  75.  
  76.          case 'reset':
  77.             print $this->reset($_POST['email']);
  78.          break;
  79.  
  80.          case 'pwdchange':
  81.             print $this->passwordChange($_POST['password'], $_POST['newpwd']);
  82.          break;
  83.  
  84.          case 'joinroom':
  85.             print $this->joinRoom($_POST['room']);
  86.          break;
  87.  
  88.          case 'leaveroom':
  89.             print $this->leaveRoom($_POST['room']);
  90.          break;
  91.  
  92.          case 'roomlist':
  93.             print $this->roomList();
  94.          break;
  95.       }
  96.    }
  97.  
  98.    /**
  99.     * Logs the user in and sets the session for the user.
  100.     *
  101.     * @return JSON object of buddies/blocked users if it usr was successfully logged in, error string otherwise
  102.     * @author Joshua Gross
  103.     **/
  104.    function login($username, $password) {
  105.       $user = $this->checkInfo($username, $password, array('admin', 'banned'));
  106.       if(!$user) return 'invalid';
  107.       if($user['banned'] == 1) return 'banned';
  108.  
  109.       $_SESSION['username'] = $username;
  110.       $_SESSION['password'] = $password;
  111.       $_SESSION['admin']    = $user['admin'];
  112.  
  113.       $set_status = mysql_query('UPDATE ' . SQL_PREFIX . 'users SET is_online=1, last_ip=\'' . $_SERVER['REMOTE_ADDR'] . '\' WHERE username=\'' . $username . '\'');
  114.  
  115.       $buddylist = $this->getBuddylist($username, false);
  116.       $blocklist = $this->getBlocklist($username);
  117.  
  118.       $this->userEvent($username, $buddylist, 'status', array('status'=>1));         
  119.  
  120.       $buddylist = $this->getBuddylistOnline($username);
  121.       if(count($buddylist) > 0)
  122.          $output['buddy'] = $this->json->encode($buddylist);
  123.       else
  124.          $output['buddy'] = array();
  125.  
  126.       $output['blocked'] = $this->json->encode($blocklist);
  127.  
  128.       $output['admin'] = $user['admin'];
  129.  
  130.       return $this->json->encode($output);
  131.    }
  132.  
  133.    /**
  134.     * Logs the user out and destroys the session.
  135.     *
  136.     * @return String 'logged_out'
  137.     * @author Joshua Gross
  138.     **/
  139.    function logout() {
  140.       if(!$this->checkInfo($this->username, $this->password)) return 'invalid';
  141.  
  142.       $buddylist = $this->getBuddylist($this->username, false);
  143.  
  144.       $set_status = mysql_query('UPDATE ' . SQL_PREFIX . 'users SET is_online=0, last_ping=\'' . time() . '\' WHERE username=\'' . $this->username . '\'');
  145.  
  146.  ?>
  147.  
The session in my form is $_SESSION['username']
I couldnt understand what is to be done. Can you plz help me.
Thanks.
Mar 25 '08 #3
ryan2345
26 New Member
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.
Attached Files
File Type: txt index.txt (10.5 KB, 601 views)
Mar 26 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

42
34148
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
3
1674
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...
13
3915
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...
13
2037
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
3
3129
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...
2
3152
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); ...
3
2469
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...
4
2194
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. ...
12
1245
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...
3
2582
omerbutt
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>
0
8343
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,...
0
8855
Oralloy
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...
0
8758
jinu1996
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...
1
8545
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,...
0
7364
agi2029
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...
1
6185
isladogs
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...
0
4179
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...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.