Arkanis Development

Simple Chat

With about 20 lines of PHP and about 40 lines of JavaScript.

By Stephan Soller <stephan.soller@helionweb.de>, released under the MIT-License.

If you're searching for a small simplistic chat but don't want some Flash, Java or other heavy-weight stuff you can stop searching. A PHP capable webserver and three files are all you need. And no, you don't need a database.

This code here is inteded as a base for you to do your own stuff. However if it already is exactly what you want feel free to just copy it.

That's it. :)

Demo

Take a look at the source code of example.php (it also shows the PHP code). It's a stripped down version of the chat so there are no fancy styles or documentation (except some comments) to distract you.

The basic idea

This simple design leads to a chat that doesn't need a database nor a large server or infrastructure. Just a small bunch of lines you can drop into your project and modify or extend as needed. It's so simple that it shouldn't be a problem to extend or adopt the code for your own purpose (e.g. multiple chat rooms, usage as message API, fancy styling, etc.).

If you want to know more take a look at the detailed explanation of the design and implementation of this chat.

Download

This archive contains everything you need for this chat: simple-chat-v1.0.1.zip.

It's the stripped down chat example (example.php) as well as jQuery (jquery-1.4.2.min.js) and a shell script to create an empty file that's writeable by everyone (setup.sh, just in case…).

Comments

If you have questions about this chat or want to share some thoughts or ideas, please post a comment on the blog post of this project. You can also send me a mail if you prefere that.

Changelog

v1.0.1, 2010-08-08
Fixed an XSS security hole repored by Craig Francis (injecting HTML code into the action attribute of the form).
v1.0.0, 2010-08-04
Initial release.

The MIT License

Copyright (c) 2010 Stephan Soller <stephan.soller@helionweb.de>.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.