
Hi everyone... Here is my contribution to the PHP-Nuke community. I discovered PHP-Nuke and I must say, I'm impressed :) . I am working on a PHP chat program ( was initially based on mod_perl and since I decided to use PHP-Nuke, decided to code it purely in PHP ) and this is it.
It is feature rich ... Some of the features available for the chat room
create table if not exists $prefix_chatlastpm ( uid bigint(11) towho varchar(100)) type = myisamVersion 1.21 ( 15th November 2001 )
No change in database structure
Changes in eng-lang.txt
define("_CCADMROOMSENT","Message send to room ...");
define("_CCADMSITESENT","Message send to whole site ...");
define("_CCCURROOMLBL","Current Room");
define("_CCALLROOMLBL","All Rooms");
define("_CCADMSENDBTN","Broadcast Message");
Version 1.2 ( 14th November 2001 )No change in database structure
Version 1.10 ( 7th November 2001 )
Insert new row to nuke_chatsettings
insert into nuke_chatsettings (id,value) values('forcepropercase','N')
create table if not exists nuke_chatreplace ( orgword varchar(100), repword varchar(100) ) type = myisam create table if not exists nuke_usersettings ( uid bigint(11), id varchar(10), value varchar(40) ) type = myisam
define("_CCWORDREPTITLE","Word Replace Management");
define("_CCREMPHRASEBTN","Remove Phrase");
define("_CCADDPHRASEBTN","Add");
define("_CCACTPHRASEBTN","Activate");
define("_CCORGPHRASELBL","Phrase");
define("_CCREPPHRASELBL","Replaced With");
define("_CCDISPHRASEBTN","Disable");
define("_CCROOMNONAMEERR","Can't create a room with no name...");
define("_CCFONTCOLORLBL","Font Color");
define("_CCSHOWBGLBL","Disable Backgrounds");
$chatsettings = array( 'entchatmesg' => 'Enter Chat Message',
'entroommesg' => 'Enter Room Message',
'refreshrate' => 'Chat Refresh Rate',
'premesg' => 'Chat PreMessage',
'logoffmesg' => 'Logoff Message',
'leaveroommesg' => 'Leave Room Message',
'windowwidth' => 'Chat Window Width',
'windowheight' => 'Chat Window Height',
'admpremesg' => 'Administrator PreMessage',
'mesgshown' => 'Show Previous Messages',
'userscolwidth' => 'Users List Column Width',
'maximage' => 'Max Image Per Convo',
'forcepropercase' => 'Force Proper Case',
'idletime' => 'User Idle Time');
Log in as an admin for your PHP-Nuke installation ( i.e. http://www.yoursite.com/admin.php ). Once logged in, enter the following URL to start setting up your chatroom http://www.yoursite.com/clubchat.php ( replace www.yoursite.com to you actual domain ),
Run the script as an admin and it will create the necessary tables
This chat allows a user to have a single primary account with PHP-Nuke but unlimited aliases. When a user registers a new alias, it will look up the PHP-Nuke user tables and also ClubChat alias table ( $prefix_chatalias ) for duplicates. This prevents an alias having the same handle as a primary account. To prevent a new PHP-Nuke account having the same handle as an existing alias, edit the user.php and insert the following line inside the userCheck() function
if (mysql_num_rows(mysql_query("select alias from $prefix"._chatusers." where alias='$uname'")) > 0) $stop = "<center>"._NICKTAKEN."</center><br>";
For example
function userCheck($uname, $email) {
global $stop, $prefix;
if ((!$email) || ($email=="") || (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$email))) $stop = "<center>"._ERRORINVEMAIL."</center>
";
if (strrpos($email,' ') > 0) $stop = "</center>"._ERROREMAILSPACES."<center>";
if ((!$uname) || ($uname=="") || (ereg("[^a-zA-Z0-9_-]",$uname))) $stop = "<center>"._ERRORINVNICK."</center>
";
if (strlen($uname) > 25) $stop = "</center>"._NICK2LONG."</center>";
if (eregi("^((root)|(adm)|(linux)|(webmaster)|(admin)|(god)|(administrator)|(administrador)|(nobody)|(anonymous)|(anonimo)|(anónimo)|(operator))$",$uname)) $stop = "<center>"._NAMERESERVED."";
if (strrpos($uname,' ') > 0) $stop = "</center>"._NICKNOSPACES."</center>";
if (mysql_num_rows(mysql_query("select uname from $prefix"._users." where uname='$uname'")) > 0) $stop = "<center>"._NICKTAKEN."</center>
";
# Added to prevent a user registering a user name with an existing alias for chatroom
if (mysql_num_rows(mysql_query("select alias from $prefix"._chatusers." where alias='$uname'")) > 0) $stop = "<center>"._NICKTAKEN."</center>
";
if (mysql_num_rows(mysql_query("select email from $prefix"._users." where email='$email'")) > 0) $stop = "<center>"._EMAILREGISTERED."</center>
";
return($stop);
}
This step is optional but highly recommended.
In IE.. There is an annoying clicking sound if your sound volume is way up .. This is a Window feature.. To get rid of the clicking sound .. Run Your Windows Control panel locate the Sounds icon ( Sounds And Multimedia for Windows 2000 ) . Locate the Start Navigation event .. and choose none for that event
Available commands ( for all users )
SetEnvIf Request_URI "\/clubchat.php$" dontlog CustomLog /var/log/httpd/access combined env=!dontlogThe first line set the Env variable that any URI beginning with the clubchat.php the Cutomlog directive logs everything else except the env set in the first line Do this to also prevent your logs files growing huge when you have lot's of people chatting
skip-networking log-bin = OFFskip-networking Is ON if we only allow local (socket) connections. log-bin logs every single sql statement for replication.
I know some parts of the code is extremely bad :p forgive me, but I will improve on it as I go along
Then I saw some really nice chats based on Perl and PHP .. They're simple and costs nothing. Then i started to study them and understand and started to pull together all the cool stuff i've seen in bits and pieces here and there and voila .. this piece of software is born. it has soo many features in one single script ( well actually 2 ). It has ignore, booting, anti flood, smileys, public and private rooms, private messages in fact, it does almost everything except make coffee ( that could be in the next release :p ).
Granted HTML based chats are slow resource hogs ( I'd be the first to admit that ) but there are advantages namely, all you need is a browser and HTML ( also Perl and PHP ) is pretty easy to code and freely available. So for more bang for the buck, it beats those chats that you have to pay good money for ( in either case, I think I'd rather spend my hard earned money to upgrade my hardware then buy a proprietary software then have to put in requests after requests for features ya want today but they'll only consider adding if demand is there or they'll promise you the next release ).