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(http://bostsip.blogspot.com/2009/10/facebook-like-chat.html). 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:
http://shutterbox.rockerprog.com/. Thanks to Jonee of PHPUGPH for hosting the demo.


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

Download it here:
http://sourceforge.net/projects/facebook-likech/

You may also checkout(SVN) the files here:

https://facebook-likech.svn.sourceforge.net/svnroot/facebook-likech

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!

38 comments:

  1. Hey, The link http://shutterbox.mywebcommunity.org/

    is not working...

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

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

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

    ReplyDelete
  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??

    ReplyDelete
  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.

    ReplyDelete
  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)

    @nike
    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: http://codeigniter.com/forums/viewthread/59627/#293683

    ReplyDelete
  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 :)

    ReplyDelete
  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.
    http://localhost:8080/facebook/?username=xxx&password=xxx&submit=Login

    and i get error

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

    ReplyDelete
  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.

    Br
    tulip

    ReplyDelete
  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.

    ReplyDelete
  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

    ReplyDelete
  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 !!!!

    ReplyDelete
  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.)

    ReplyDelete
  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).

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

    ReplyDelete
  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!!!

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

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

    ReplyDelete
  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?

    ReplyDelete
  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! :)

    ReplyDelete
  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?

    ReplyDelete
  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..

    ReplyDelete
  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..

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

    ReplyDelete
  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

    ReplyDelete
  26. This comment has been removed by the author.

    ReplyDelete
  27. i have error

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

    ReplyDelete
  28. i found a error after login
    404 Page Not Found
    The page you requested was not found.
    in the below page
    facebook-likech/index.php/login/index.php/home

    waht i do ?

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

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

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

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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete