473,508 Members | 2,329 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 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.
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, 599 views)
Mar 26 '08 #4

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

Similar topics

42
34092
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...
3
1671
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...
13
3888
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...
13
2017
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...
3
3117
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...
2
3128
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...
3
2450
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...
4
2182
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...
12
1226
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...
3
2577
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...
0
7225
marktang
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,...
0
7324
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,...
1
7042
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...
0
7495
tracyyun
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...
0
3193
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...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
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 ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
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...

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.