1 (edited by Neck 2008-12-13 20:43)

Topic: [Release] ChatLite v0.5.1 (javascript chat on forum index)

ChatLite extension for PunBB 1.3
This extension adds an ajax based chat to your forum index. Only registered members can post messages on it.


ChatLite 0.5.1


Installation:
Download the zip and extract it in your PunBB's extensions folder, then access administration and launch install.

Upgrade:
Replace content of ek_chatlite folder (in extensions) with the one of the last version's zip, then launch upgrade in administration.
/!\ do not replace ek_chatlite/data/chat.dat if you want to keep chat's messages.
/!\ when updating from 0.3.3 or lower version you MUST replace ek_chatlite/data/chat.dat, all chat messages will be lost.


Features:

  • Purely javascript based, will not work at all without it activated (but no dirty html parts will be shown in this case).

  • CSS style that will fit default theme (see HowTo below to make your own)

  • Languages support (see HowTo below).

  • Timestamps in front of messages, with date if not posted the same day.

  • Logs a maximum of 50 messages.

  • Decent server load, doesn't start entire forum script to refresh chat content, only to write a new message.

  • Refresh occurs every 2.5s and will slow down if no new messages are received until intervals reach 60s. Resets when a message is received.

Requirements:

  • PHP 5.2.1 (or greater)

  • PunBB 1.3 (or greater)

  • Prototype 1.6.0.3 (included)

  • Apache server (recommended)


Notes:
I'm not open to any feature suggestion at the moment (no time) but I welcome any code improvement.
Will correct bug or security flaw.

Licensed under CC by 3.0.


HowTo...
...translate
Copy ek_chatlite/media/js/lang/English.js and name it according to the language you want. Then open it in a text editor and replace the sentences on right by the translated ones.
If your text contains single quotes ( ' ) or backslashes ( \ ) you must add an additional backslash before ( \' or \\ ).
Feel free to send me your work at nk.punbb at eikylon.net (include your name and website/email for credits).

...make your own css style:
Just place a file in ek_chatlite/media/css with the same name as your forum's theme (i.e. theme.css).

...tweak message display:
open ek_chatlite/media/js/chat.js and look for:
'#{a}[#{d}#{h}:#{m}] <strong>&lt;#{name}&gt;</strong> #{msg}<br />'
This is the message template, #{xyz} values are filled when reading messages, you can modify it as you want.
#{a} is the deletion button, #{d} is the day, rest is self explanatory.

Additionally you can change day display in lang file. Using "date" as value will display the date (i.e. 11/12) anything else will be used as string (i.e. today).



Old versions:
ChatLite 0.5.0
ChatLite 0.4.0
ChatLite 0.3.3
ChatLite 0.3.2
ChatLite 0.3.1
ChatLite 0.3.0

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Well nice extenstion, but I'll try

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

yes i will try it now wink

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

when active it, my index, not show.

5 (edited by Neck 2008-12-04 20:32)

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

fantasma wrote:

when active it, my index, not show.

Got any link to show ? kinda hard to say what's wrong without wink

EDIT: noticed a bug: when you're not logged in the chat wont display anything. Corrected first file according to that

6 (edited by teva 2008-12-04 21:48)

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

I got the same problem as fantasma. After installing extension, forum index is not shown. It only loads background.

This is what i get

Line: 391
Char: 1
Error:'_gat' is undefined
Code:0
URL: http://www.forum.com/index.php

1.3 final

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Same as the others. When I upload the files, go to the admin area and finalize the extension install, my index page only displays the contents:

Powered by PunBB

Currently used extensions: pun_repository, pun_quote, pun_bbcode, pun_pm. Copyright © 2008 PunBB

[ Generated in 0.025 seconds, 11 queries executed ]

8

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Found the problem, it was an Internet Explorer bug.
Changed the code a bit to avoid it, should work now.

See new version on first message.

@GHOwner: side note: the extension wont appear down there, I dont really care about it being listed on bottom big_smile

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Neck wrote:

Found the problem, it was an Internet Explorer bug.
Changed the code a bit to avoid it, should work now.

See new version on first message.

@GHOwner: side note: the extension wont appear down there, I dont really care about it being listed on bottom

I was referring that the footer only showed, none of the boards, header, etc, on the index page.

It works now. The only little gripe I can give is the header with the text "Chat", it's blue background doesn't go 100%, only seem to cover 33%. Otherwise, all works for now, awesome mod and thanks!

10

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

The chat is now shown, but i get below error, when trying to send any message

Fatal error: Call to undefined function: file_put_contents() in /forum/misc.php(631) : eval()'d code on line 212

11

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

@GHOwner: Thanks!
For the 33% width, that's most likely a css problem, feel free to mess arround in media/css/default.css if you got some knowledge about it. Works fine for me on IE6, IE7 and FF with default theme.

@teva: that's weird, file_put_contents is a standard PHP5 function.
I see 2 possible reasons: either your host disabled this function either you're running PHP4.
Anyway you can replicate this function's behaviour with:

function file_put_contents($n, $d) {
  if(($f = fopen($n, 'wb')) === false) {
    return false;
  }

  if (is_array($d)) $d = implode($d);
  fwrite($f, $d);
  fclose($f);
  return;
}

Simply past this code at the end of include/function.php.

Note that if you're still running PHP4, I strongly advise you to change to 5 (or ask your host to do so). Support for it has been completely stopped this year (including security) Source.

12

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Yep... PHP version is 4.4.8

Will ask host to upgrade

13

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

It was only config in cpanel...i now run on  PHP 5.2.6 and chat works fine

tnx

14 (edited by teva 2008-12-05 12:31)

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Can this chat be moved to it's own page and adding new menu on top, to link to it?

Also..the chat does not refresh automatically. I have to reload whole forum to see changes.

tnx

15

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

1) No it cant be moved to its own page, at least not yet.

2) It should refresh automatically, every 2.5s. But it doesnt reload the page or anything, are you sure someone posted a message meanwhile ?

16

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

2) Yep..if i refresh whole page, then i see new messages. Tried with IE7 and FF3....other users noticed that also

17

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Can you send me a link by pm, I cant reproduce this on my side ?

18

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Thanks teva for the link, here's new version that should solve this problem smile

19

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

It works fine now..tnx for update.

Could you add time and date of posting, next to the username?

tnx

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Work Good!

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

hi, could you help me ?
I tried to install this on my forum.
Once I installed and got to the index I get this error mesage "Unable to reach server."
Any idea ? thank you smile

22

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

@teva: Adding time is is a lot more tricky than it seems, mainly because each user can have its own timezone. However many ppl requested it so I might try to get something working later.

@SkyLine: try to access "<yourforum>/extensions/ek_chatlite/data/chat.dat" (replace <yourforum> by your actual forum base url, for example http://punbb.informer.com/forums ).
If you see the chat's content please send me pm with your forum link, if you dont check that the file exists and is readable from the web.

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

Neck wrote:

@SkyLine: try to access "<yourforum>/extensions/ek_chatlite/data/chat.dat" (replace <yourforum> by your actual forum base url, for example http://punbb.informer.com/forums ).
If you see the chat's content please send me pm with your forum link, if you dont check that the file exists and is readable from the web.

hi thanks for you reply.
I tried to access directly and I got a welcome message, then Its working now even in the index.
But I have same problem as teva with the message "Fatal error".
I just verified that my host is running on PHP: 4.4.3 !!! neutral
I will try to replace the functions lines as you provided.
Anyway thanks a lot wink

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

This is a very good script. I was wondering if you could even release an independent (standalone) version in addition to the one you incorporated into punBB; if in the future you want a back-end, I'd happily work with you to develop one!

big_smile

25

Re: [Release] ChatLite v0.5.1 (javascript chat on forum index)

New version out. Been efficient over weekend for once big_smile
Includes:
-Timestamps (date of messages)
-Lang support
-Security Token removed (allow you to post even after a long time on index, this only applies for chat input and not entire forum of course !)
-General code improvements

Hope you will like it, done lot of tests on my side, sorry if there is any bug left. Please note that there's now a php version limitation due to several new functions I used.


@lupus6x9: Thanks ! Technically the extension rely on forum only to know user's name and language, so it can easily be separated and run as standalone if you manage those 2 points differently.
I just made a time consuming update and wont do that right now, especially since I don't need it personally. However code's licence is free and you can do it yourself if you dont want to wait wink