Friday, January 14, 2011

Facebook-like chat part 2

This is my old blog. You can find the updated version of the Facebook-like chat HERE

It's been a while since my first attempt at creating a facebook-style chat. Unfortunately, the original server where it was hosted was formatted, thus making some disgruntled posters( Sorry guys, I really just didn't have time. But to make up with this, I've made another one. I used codeigniter as the php framework and jquery for javascript.

Big thanks to this post also. It saved me time on creating a bottom menu ala-Facebook.

Here's the demo: Thanks to Jonee of PHPUGPH for hosting the demo.

To test:
login using different usernames on different browsers or different PCs

Download it here:

You may also checkout(SVN) the files here:

Installation instructions:
1. extract to your http folder
2. edit system/application/config/database.php
3. change database parameters as pecified in these config variables:

$db['default']['hostname'] = "";
$db['default']['username'] = "";
$db['default']['password'] = "";
$db['default']['database'] = "";

4. edit system/application/config/config.php
5. change values in the following variables/constants:

$config['base_url'] = "http://yourwebsite/";
define('MAINSITE_URL', 'http://yourwebsite/');
//you may use .htaccess to remove index.php
define('MAINSITE_INDEX', 'http://yourwebsite/index.php/');

6. create the database by uploading the sql dump file under the sql folder
7. to create a new user, run the following query

//password is password with username as its salt, encryption uses Secure Hash Algorithm
INSERT INTO `facebookchat`.`users` (`username`, `password`, `session_id`, `created_date`, `modified_date`) VALUES ('test', SHA1('testtest'), '', CURRENT_TIMESTAMP, '0000-00-00 00:00:00');

8. have fun !

Feel free to suggest any improvements on this application guys!


  1. Hey, The link

    is not working...

    May be its just me , but would like to confirm ...

  2. hello, unfortunately the hosting provider is currently down, but will be up soon enough hopefully...

  3. site is now up, you can check the demo site now :D

  4. hey nice work..but just one drawback. can't i edit the login page(since it displays shutterbox) and display my website name?? where can i find the file to edit??

  5. Sir, there is an error when I try it in localbase.. This is the error:

    "An Error Was Encountered
    The URI you submitted has disallowed characters."

    Can you please check this and give some possible solutions to it. I need it ASAP sir.. Thank you and more power.

  6. @rajesh

    you can try editing the view_main.php in the views folder if you wish to change the page. You can go to (/system/application/views/view_main.php). Also, you can modify the contents once you are logged in inside the system on view_home.php(same folder with view_main.php)

    weird, have you edited the config.php? it is located in system/application/config/config.php. It may have something to do with the allowed uri characters. Otherwise you may refer to this discussion:

  7. Hi bos_tsip, the chat is just very nice, i like it. but how i can integrate to my own website? i see some of your code, and i think i can try something, but may be better ask to you first :)

  8. Hi
    I have been trying this for last 2 days but have problems.can some one help me.

    i call the link and get login page.than when i try to login my link is.

    and i get error

    404 Page Not Found.The page you requested was not found.

  9. Hi
    just to update you.initially it was giving invalid URI error so i made 2 changes.
    changes in URI.php

    if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str)) was changed to
    if ( ! preg_match("|^[".($this->config->item('permitted_uri_chars'))."]+$|i", rawurlencode($str)))

    and in config.php

    $config['permitted_uri_chars'] = 'a-z 0-9~%.:?=_\-'; was changed to
    $config['permitted_uri_chars'] = 'a-z 0-9~%.:?=_\-’;

    some one pls help or give me some pointer.


  10. Thanks tulip, it would not work without your fixes. I wish he would update to include these changes, and tell you where those files are. It took me a while to figure out where they were and which config.php file to change.

  11. Thanks for this wonderful bos_tsip. But i am wondering why there is an error 404 whenever i try to login. What might be the cause of the error?Can someone help me out. TIA

  12. It's not a Facebook-like.

    You don't use the long-polling !
    Here it's juste a "simple" refresh ...

    So yes it's beautifull but it's nut a Facebook-like chat !!!!

  13. when i am open this application in server side so it can be display this ERROR after login (404 Page Not Found.The page you requested was not found.)

  14. Hi everybody;

    this piece of code seems extremely useful but i cant get it to work on my localhost,

    i think it is a path assignment issue, i can get to the login page but everytime i insert the user, password and submit it only refreshes the page!

    this is my path configuration in config.php:

    $config['base_url'] = "http://localhost/facebook-likesh/";

    define['MAINSITE_url'] = "http://localhost/facebook-likesh/";

    define['MAINSITE_INDEX'] = 'http://localhost/facebook-likesh/system/application/views/view_main.php';

    i have tried withe diferent configurations but no way!

    does anyone have a clue?

    Thank you,
    Ruben (Portugal).

  15. do you have a you tube site that shows how to install?

  16. This is Bhuvnesh Gupta.
    Sir, This is not working here. When I start your application and enter username(e.g ryan) and Password (e.g ryan or d0c1968.......)then after login it remains on the same page means just flush out the username and password and neither show any erro nor go on any other page.
    Please tell me the solution.........
    Thanking You!!!

  17. how to change SH1 to MD5 (encrypt) ???

  18. how can i keep the chat window open when i click another link

  19. hello sir this code is not working proper way when we run this code on local login form is open but when i enter the username and password this generate error

    An Error Was Encountered

    The URI you submitted has disallowed characters.

    pls help me to solve this problem?

  20. its working for me! but had you tried it by not using in code igniter just a simple php and javascript? because i a'int that familiar in Code Igniter! tnx! :)

  21. In your instructions you say

    7. to create a new user, run the following query

    //password is password with username as its salt, encryption uses Secure Hash Algorithm
    INSERT INTO `facebookchat`.`users` (`username`, `password`, `session_id`, `created_date`, `modified_date`) VALUES ('test', SHA1('testtest'), '', CURRENT_TIMESTAMP, '0000-00-00 00:00:00');

    How dose this work? where do i add this to?

  22. I get a Database Error. Error is as followed:

    A Database Error Occurred
    Unable to connect to your database server using the provided settings.

    I don't understand why I'm getting this error as my database info is correct and works fine on current website..

  23. hello ji
    i used your code it was really good and nice..

    i want to add a signup form, so any other member can registered in chat,, so can u please tell me where i can do some changes in code .. bcoz in this code having so much files i cant understand where i can do some changes..

    thank you for that code..

  24. i get Incorrect user name and password error when i enter my new account i made

  25. its is nice.. but i can't embed to my system project.. because the codes are not damiliar with me.. can help me ? tnx

  26. This comment has been removed by the author.

  27. i have error

    An Error Was Encountered
    The URI you submitted has disallowed characters.

  28. i found a error after login
    404 Page Not Found
    The page you requested was not found.
    in the below page

    waht i do ?

  29. sir can you please help me with the video tutorial for it.
    Thanks in advance.

  30. pleas user and password i can't read coz crupt with hash

  31. what is the session id we need to give while entring new user??

  32. Creating a new user doesnt work. Why???

  33. In mod_login.php(model_name) under function authenticate($username, $password)
    replace this function with this code,it works fine.

    function authenticate($username, $password) {
    //get record and salted password
    $query = $this->db->get_where(
    'users', array(
    'username' => $username,
    'password' => sha1($password)));
    return $query->result();
    Thank You

  34. Hi to every body, it's my first go to see of this website; this weblog includes brilliant and in truth well accomplished for visitors.
    Web development singapore

  35. [url=][b]Longchamp Outlet[/b][/url]

    [url=][b]NFL Jerseys[/b][/url]

    [url=][b]Yeezy Boots[/b][/url]

    [url=][b]Jordan 4[/b][/url]

    [url=][b]Longchamp Bags[/b][/url]

    [url=][b]Air Max 2016[/b][/url]

    [url=][b]Adidas UK[/b][/url]


    [url=][b]Under Armour[/b][/url]

    [url=][b]Timberland UK[/b][/url]

    [url=][b]Jordan 12[/b][/url]

    [url=][b]Polo Ralph Lauren Outlet[/b][/url]

    [url=][b]Yeezy Shoes[/b][/url]

    [url=][b]Nike Outlet[/b][/url]

    [url=][b]Nike Huarache[/b][/url]

    [url=][b]Keds Shoes[/b][/url]

    [url=][b]Nike Roshe Run Shoes[/b][/url]


    [url=][b]Nike Air Max[/b][/url]

    [url=][b]Oakley Outlet[/b][/url]


    [url=][b]Cheap Jordan[/b][/url]

    [url=][b]Toms Outlet Online[/b][/url]

    [url=][b]Adidas Ultra Boost[/b][/url]

    [url=][b]Ray-Ban Outlet[/b][/url]

    [url=][b]MLB Jerseys[/b][/url]

    [url=][b]Kate Spade Outlets[/b][/url]

    [url=][b]Ugg Clearance Sale Outlet[/b][/url]

    [url=][b]Ugg Boots Outlet[/b][/url]

    [url=][b]Timberland Outlet[/b][/url]

    [url=][b]Ray Ban Outlet[/b][/url]

    [url=][b]Ray-Ban Sunglasses[/b][/url]

    [url=][b]Adidas NMD UK[/b][/url]

    [url=][b]Kate Spade Outlet Online[/b][/url]

    [url=][b]Ralph Lauren Outlet[/b][/url]