Details
{startverticalbanner}
Its a simple web based chat system using HTML5 websockets / HTML5 SSE with ajax long polling as fall-back to provide a very fast and smooth experience (can work with or without any database server).
It can be used as standalone or as module / plugin in any website. Implemented in core php and js code using jquery. Very simple, feature rich and fully customizable chat system. Auto fall-back from html5 websockets to html5 sse to ajax long polling
Fetaures:
1) Registration, login, forgot password
2) Search and add contacts, manage groups
3) Broadcasting, one to one & group chat
4) Desktop notifications, sound alert, auto scroll to new message
5) File attachments
6) Multiple tabbed chat
7) History of old chat messages
& *Audio-Video chat using WebRTC integrated into code, but not yet tested
All these managed without use of any database server. Its fully standalone but can be easily integrated with any database server using simple cron. Code for db integration is not included in this package
Overview on structure of data files:
Chat messages are stored inside /tmp folder as temporary files. One message in one file.
Let say user1 is chating with user2,
files for those messages will be inside /tmp/user1-user2/
files for broadcasted messages will be inside /tmp/mt/
folders starting with 'g:' are for groups and will contain files of group chat messages
once a message file for e.g 'file123' is read by 'user1' to prevent re-reading one file named 'user1_file123' is created
while reading message files for e.g 'file123', if file 'user1_file123' exists then 'file123' is skiped
If using db server, you need to create a cron which will read all these message files and store it with appropriate relation in db.
Also, if using db server for better performance you can remove or comment deleting and history code and manage it in cron.
History files are created concatinating two user's names or username with group (in case of history for a group)
So, for group each user have separate history files.
History files are stored inside /h for broad casted messages and inside /h/uh for inidividual and group chats
Other files and folders used:
/files/un User's profile file containing data of contact names, group names, username, email, password, contact and group request, verification code
/files/grp Contains a file for each group which contains contact's names and requested contacts
/files/ou Contains a file for each online user and can be used for storing current logged-in session values
/files/um Contains folder for each relation of user inside that user's folder
For e.g.
/files/um/user1 Will contain a folder 'user1-user2' if user1 has a contact user2 and in case of group it will have folder with 'g:groupname-groupid'.
This is used to easily retrive chat data from same folder inside /tmp and avoid exessive relation mapping or reading from files.
So, if user1 and user2 are contacts and are in a 'group1' they both will have once folder in /files/um and inside each folder they will have 'user1-user2' and 'g:group1-123' folders.
Also, same 'user1-user2' and 'g:group1-123' folders are used in /tmp to store respective message files.
While fetching messages for user1, name of all folders inside /files/um/user1 are obtained and files inside same named folders from /tmp are read and send to user1.
So at server side instead of R-DBMS server file system is constantly monitored for each user, for any new or unread files and as soon as any such file found contents of those files are read and send to the respective user & also that flag file is created so that same file is not fetched again.
Now we need a cron which will read all these message files and store it with appropriate relation in db and once data from a file is inserted delete that temporary message file.
To insert message data in to R-DBMS server we can use a cron at every 1 minute which will read all message files and create separate sql file per each cron and store that sql file in a secure folder and then delete those message files which are read. Now, those sql files can be dumped into mysql at every 30 minutes. The reason behind separating insertion into two crons is to reduce insert frequency into DB server and also at the same time maintain less files on file system to look into for new messages.
In this manner persistent storage of our data is done in R-DBMS server and whenever user needs to show history of chat data can be fetched from R-DBMS. Again, we can limit data in R-DBMS server to let say 3 months for each user after which a download facility can be given for user to get their old data in a file which once downloaded will be deleted after certain period of time and as those data are already deleted from DB server, won't appear in chat history in application.
Thus, excessive sql quering, relation mapping and file reading is avioded. Also creation of huge file is avoided here by creating separate files for each messages and handling as much as possible checks and relations using directory exists and file exists method.
If want to use Websockets, to start web-server for websocket requests, execute below command in command line:
/usr/bin/php -q /var/www/simple-web-chat/chat.php
sc.php is the entry script so main url of application will be like: http:// ... /simple-web-chat/sc.php
Also, make sure folders "files/", "tmp/", "h/" and "pub/" have read and write permissions for web-server user (generally that user is 'www-data' if using apache2 http server).
To, know more about theoretical (technical) concept in detail you can visit:
http://pls-e.in/project/theory/filesystem_based_data_management_architecture
|
What is the best PHP video chat app class?
PHP system for video conference on online meeting
Live video streaming using webrtc
One to many live video streaming for online education
What is the best PHP chat room class?
I need a simple chat package
What is the best PHP real time chat class?
Chat similar to Google hangouts
Websocket chat
Websocket chat with real time updates
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.
|
Files |
|
File |
Role |
Description |
classes (17 files) |
css (1 file) |
files (1 file, 4 directories) |
h (1 file, 1 directory) |
images (1 file) |
js (6 files) |
lib (2 files, 1 directory) |
pub (2 files) |
tmp (1 file, 2 directories) |
.htaccess |
Data |
htaccess |
acceptcreq.php |
Appl. |
normal request handler file for accept contact request |
acceptgreq.php |
Appl. |
normal request handler file for accept group request |
biCChat.php |
Appl. |
normal request handler file to init chat with contact |
biGChat.php |
Appl. |
normal request handler file to init chat with group |
chat.php |
Appl. |
script which starts websocket php server |
chkusr.php |
Appl. |
normal request handler file to check user's identity |
common.php |
Conf. |
common config file |
cp.php |
Appl. |
normal request handler file for change password |
csrch.php |
Appl. |
normal request handler file for contact search |
filehandler.php |
Appl. |
normal request handler file for file uploads |
history.php |
Appl. |
normal request handler file to display user's history |
managegroup.php |
Appl. |
normal request handler file for managing groups |
nchat.php |
Appl. |
normal request handler file for fetching new chat messages |
newcontact.php |
Appl. |
normal request handler file for adding new contact |
ReadMe.txt |
Doc. |
Read Me file |
rejectcreq.php |
Appl. |
normal request handler file to reject contact request |
rejectgreq.php |
Appl. |
normal request handler file to reject group request |
rejectgroup.php |
Appl. |
normal request handler file for removing a group from contact list |
removecon.php |
Appl. |
normal request handler file to remove a contact from contact list |
reply.php |
Appl. |
normal request handler file to send a message |
sc.php |
Appl. |
entry script |
selcgroup.php |
Appl. |
normal request handler file to get group contacts |
ssrch.php |
Appl. |
normal request handler file to search people for adding as contact |
uverify.php |
Appl. |
normal request handler file for user verification |
File |
Role |
Description |
style.css |
Data |
css file |
File |
Role |
Description |
grp (2 files) |
ou (1 file) |
um (1 file, 1 directory) |
un (4 files) |
.htaccess |
Data |
htaccess |
File |
Role |
Description |
sample.txt |
Data |
online users |
File |
Role |
Description |
dev (1 file, 1 directory) |
sample.txt |
Data |
relation for user messages |
File |
Role |
Description |
dev.u |
Output |
sample profile file |
sample.txt |
Data |
description |
t1.u |
Output |
sample profile file |
t2.u |
Output |
sample profile file |
File |
Role |
Description |
uh (1 file) |
.htaccess |
Data |
history files |
File |
Role |
Description |
sample.txt |
Data |
history files |
File |
Role |
Description |
sample.txt |
Data |
phpmailer here |
File |
Role |
Description |
mt (1 file) |
um (1 file) |
.htaccess |
Data |
htaccess |
File |
Role |
Description |
sample.txt |
Data |
temporary broadcasted messages here |
File |
Role |
Description |
sample.txt |
Data |
temporary user chat messages here |