chatbase.php
<?
require(\"configuration.php\");
mysql_connect(\"db.power-zide.f2s.com\", $dbuser, $dbpass);
mysql_select_db($database);
class HexChat
{
//Appends $msg to file $logfile
function logmsg($logfile, $msg)
{
$logf = fopen(\"logs/$logfile\", \"a\");
fputs($logf, date(\"d/m - H:i : \"));
fputs($logf, \"$msg\\n\");
fclose($logf);
}
//Login... Main entrance... User/Password check, ban check etc.
function login($username, $password)
{
//Expire old user info messages and bans
MYSQL_QUERY(\"DELETE FROM tinychat_postmsg WHERE seton+1800>\".time());
MYSQL_QUERY(\"DELETE FROM tinychat_ban WHERE ban_expire<\".time());
//Check username and password
$result = MYSQL_QUERY(\"SELECT * FROM tinychat_user WHERE user_name=\'$username\' AND user_pass=\'$password\'\");
if( ($num = mysql_numrows($result)) == 0 )
return 0;
//User OK!
//Override ban check for users with status > 1
if( ($user_status = mysql_result($result,0,\"user_status\")) == 1 )
{
//If user banned return error
$resultb = MYSQL_QUERY(\"SELECT * FROM tinychat_ban WHERE ban_ip=\'\".$GLOBALS[\"REMOTE_ADDR\"].\"\'\");
if( ($numb = mysql_numrows($resultb)) > 0 )
return -1;
}
//Not banned, fetch user data from DB
$user_id = mysql_result($result,0,\"user_id\");
$user_textcol = mysql_result($result,0,\"user_textcol\");
$user_namecol = mysql_result($result,0,\"user_namecol\");
//The user is ok, lets update the DB so the user will be considered active
MYSQL_QUERY(\"UPDATE tinychat_user SET user_lastlogin=\".time().\", user_lastip=\'\".$GLOBALS[\"REMOTE_ADDR\"].\"\' WHERE user_id=$user_id\");
//Generate flat DB file for quick access to user data
$keys[0] = $user_id;
$keys[1] = time().md5(time());
$userfile = fopen(\"data/user$user_id\", \"w\");
fputs($userfile, time().\"\\n\");
fputs($userfile, $keys[1].\"\\n\");
fputs($userfile, $user_status.\"\\n\");
fputs($userfile, $user_textcol.\"\\n\");
fputs($userfile, $user_namecol.\"\\n\");
fputs($userfile, $username.\"\\n\");
fputs($userfile, $GLOBALS[\"REMOTE_ADDR\"].\"\\n\");
fclose($userfile);
//User logged on, send info to other users
$login_msg = $username.$GLOBALS[\"CONF_LoginMsg\"].date(\"H:i\");
if( ($fp=@fopen(\"data/globalmsg\", \"r\")) )
{
//Does the user allready have an active session?
//If yes, do not display login message
//This is to prevent login flooding
if( !file_exists(\"data/msg$user_id\") )
{
$this->write_system($login_msg);
$msgfile = fread($fp, 8192);
fclose($fp);
//Initialize the user\'s message file
//with a copy of all public messages
if( ($fp=@fopen(\"data/msg$user_id\", \"w\")) )
{
fputs($fp, $msgfile);
fclose($fp);
}
}
}
//Log time and IP for that user
$this->logmsg(\"login.log\", \"$login_msg from \".$GLOBALS[\"REMOTE_ADDR\"]);
return $keys;
}
//Has the user got a valid key?
function validate_user($userid, $userkey)
{
//Is the user logged on?
$userfile = @file(\"data/user$userid\");
if( (chop($userfile[1])) != $userkey )
return 0;
//Has the user changed IP-address? This could be a good indication of
//someone hacking user keys. Lets return an error just in case
//Please notice that this can cause problem for people with
//a dynamic IP-address. Uncomment to fix
if( $GLOBALS[REMOTE_ADDR] != chop($userfile[6]) )
return 0;
//Now we create a user object that reflects the user\'s status
MYSQL_QUERY(\"UPDATE tinychat_user SET user_lastcontact=\".time().\" WHERE user_id=$userid\");
if( chop($userfile[2]) == 1 ) $myuser = new HexChatNormalUser($userid, $userkey, chop($userfile[3]), chop($userfile[4]), chop($userfile[5]), chop($userfile[2]));
if( chop($userfile[2]) == 2 ) $myuser = new HexChatCoAdminUser($userid, $userkey, chop($userfile[3]), chop($userfile[4]), chop($userfile[5]), chop($userfile[2]));
if( chop($userfile[2]) == 3 ) $myuser = new HexChatAdminUser($userid, $userkey, chop($userfile[3]), chop($userfile[4]), chop($userfile[5]), chop($userfile[2]));
return $myuser;
}
//Change the nickname of an user
//This is NOT permanent, it is only done
//in the temporary user data file
function change_nick($user, $nick)
{
$msg = \"<b>\".$user->username.\"</b>\".$GLOBALS[\"CONF_NickChange\"].\"<b>$nick</b>\";
$user->username = $nick;
$this->update_user($user);
$this->write_system($msg);
}
//Change the name color of an user
//This is NOT permanent, it is only done
//in the temporary user data file
function change_namecolor($user, $color)
{
$msg = \"<b>\".$user->username.\"</b>\".$GLOBALS[\"CONF_NameColorChange\"].\"<b>$color</b>\";
$user->namecol = $color;
$this->update_user($user);
$this->write_private_system($msg, $user->username, $user->userid);
}
//Change the text color of an user
//This is NOT permanent, it is only done
//in the temporary user data file
function change_textcolor($user, $color)
{
$msg = \"<b>\".$user->username.\"</b>\".$GLOBALS[\"CONF_TextColorChange\"].\"<b>$color</b>\";
$user->textcol = $color;
$this->update_user($user);
$this->write_private_system($msg, $user->username, $user->userid);
}
//Refresh flat DB file (user data file/user session file) given a user object...
function update_user($user)
{
$userfile = fopen(\"data/user\".$user->userid, \"w\");
fputs($userfile, time().\"\\n\");
fputs($userfile, $user->userkey.\"\\n\");
fputs($userfile, $user->status.\"\\n\");
fputs($userfile, $user->textcol.\"\\n\");
fputs($userfile, $user->namecol.\"\\n\");
fputs($userfile, $user->username.\"\\n\");
fputs($userfile, $GLOBALS[\"REMOTE_ADDR\"].\"\\n\");
fclose($userfile);
}
//Write logout message to other users
//and kill the user
function logout($userid, $username)
{
$logout_msg = $username.$GLOBALS[\"CONF_LogoutMsg\"].date(\"H:i\");
$this->write_system($logout_msg);
$this->killuser($userid);
}
//After this is called the user is logged out
//Removes temporary files and updates the DB
function killuser($userid)
{
MYSQL_QUERY(\"UPDATE tinychat_user SET user_lastcontact=0 WHERE user_id=\".$userid);
unlink(\"data/msg$userid\");
unlink(\"data/user$userid\");
}
//Write to the topic file
function change_topic($topic)
{
//Ignore any errors
if( ($fp=@fopen(\"data/topic\", \"w\")) )
{
fputs($fp, $topic);
fclose($fp);
}
}
//Bold, italic, links etc.
//This provides some basic text formatting
function specialmsg($msg)
{
if( strlen($msg) > 384 ) $msg = substr($msg, 0, 384);
$orilen = strlen($msg);
$msg = ereg_replace(\"http://([a-zA-Z0-9@:%_.~#-\\?&]*)\", \"<a target=_blank href=\\\"
http://\\\\1\\\">\\\\1</a>\", $msg);
$msg = ereg_replace(\"([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+[.]{1}[a-zA-Z0-9._-]+)\",\"<a href=\\\"mailto:\\\\1\\\">\\\\1</a>\",$msg);
//Only make bold and italic if not combined with a link. The easy way out :-)
if( strlen($msg) == $orilen )
{
$msg = ereg_replace(\"\\|([^+]+)\\|\", \"<b>\\\\1</b>\", $msg);
$msg = ereg_replace(\"_([^+]+)_\", \"<i>\\\\1</i>\", $msg);
}
return $msg;
}
//Write to all users, interface function
function write_public($msg, $ncol, $tcol, $uname)
{
$msg = $this->specialmsg($msg);
$besked = \"<font color=#\".$ncol.\"><b>\".$uname.\" : </b></font>\";
//Optimize html output
if( strcasecmp($tcol,$GLOBALS[\"text_color\"]) )
$besked .= \"<font color=#\".$tcol.\">\".$msg.\"</font><br>\\n\";
else
$besked .= \"$msg<br>\\n\";
$this->write_public_real($besked);
}
function write_public_real($besked)
{
//Log the message
$this->logmsg(\"message.log\", $besked);
//Output to global message file
$message = @file(\"data/globalmsg\");
if( ($fp=@fopen(\"data/globalmsg\", \"w\")) )
{
fputs($fp, $besked);
for ( $i=0 ; $i<25-1 ; $i++ )
fputs($fp, $message[$i]);
fclose($fp);
}
//Get all active users
$result = MYSQL_QUERY(\"SELECT user_id, user_name FROM tinychat_user WHERE user_lastcontact+300>\".time());
if( ($num = mysql_numrows($result)) < 1 )
return;
$i=0;
//Write message to all active users
//Ignore any errors that may occur
while( $i < $num )
{
$user_id = mysql_result($result, $i,\"user_id\");
$message = @file(\"data/msg$user_id\");
if( ($fp=@fopen(\"data/msg$user_id\", \"w\")) )
{
fputs($fp, $besked);
for ( $j=0 ; $j<25-1 ; $j++ )
fputs($fp, $message[$j]);
fclose($fp);
}
$i++;
}
}
//See write_public_message
//
function write_public_action($msg, $uname)
{
$besked = \"<font color=#\".$GLOBALS[\"action_color\"].\"><i>\".$uname.\" $msg</i></font><br>\\n\";
$this->write_public_real($besked);
}
//Kick the user off the chat
function kick_user($myuser, $to)
{
//Open user data file
$userfile = @file(\"data/user$to\");
//We do not permit a user kicking
//another user with higher or same status
if( chop($userfile[2]) >= $myuser->status )
return $GLOBALS[\"ERROR_StatusTooLow\"];
//Kill the user
$this->killuser($to);
//Inform the other users
$km = \"Kicked : <b>\".chop($userfile[5]).\"</b>\";
//If a admin kicks do not display that info to other users
if( $myuser->status == 3 )
$message = $GLOBALS[\"CONF_KickMsg\"].\"<b>\".$GLOBALS[\"systemname\"].\"</b>...\";
else
$message = $GLOBALS[\"CONF_KickMsg\"].\"<b>\".$myuser->username.\"</b>...\";
//Lets log this
$this->logmsg(\"admin.log\", $myuser->username.\" kicked \".chop($userfile[5]));
//We kicked that user! Now we need to tell him that :-)
@MYSQL_QUERY(\"INSERT INTO tinychat_postmsg VALUES(\'\', \'\".chop($userfile[1]).\"\', \'$message\', \".time().\")\");
return $km;
}
function ban_user($myuser, $to, $expire)
{
//Open user data file
$userfile = @file(\"data/user$to\");
//We do not permit a user banning
//another user with higher or same status
if( chop($userfile[2]) >= $myuser->status )
return $GLOBALS[\"ERROR_StatusTooLow\"];
//Kill the user
$this->killuser($to);
//Inform the other users
$km = \"Banned : <b>\".chop($userfile[5]).\"</b>\";
//If a admin bans do not display that info to other users
if( $myuser->status == 3 )
$message = $GLOBALS[\"CONF_BanMsg\"].\"<b>\".$GLOBALS[\"systemname\"].\"</b>...\";
else
$message = $GLOBALS[\"CONF_BanMsg\"].\"<b>\".$myuser->username.\"</b>...\";
//Lets log this
$this->logmsg(\"admin.log\", $myuser->username.\" banned \".$chop($userfile[5]));
//We banned that user! Now we need to tell him that :-)
@MYSQL_QUERY(\"INSERT INTO tinychat_postmsg VALUES(\'\', \'\".chop($userfile[1]).\"\', \'$message\', \".time().\")\");
//Insert IP ind ban table
@MYSQL_QUERY(\"INSERT INTO tinychat_ban (ban_ip, ban_expire) VALUES(\'\".chop($userfile[6]).\"\',$expire)\");
return $km;
}
//Outputs old kick/ban messages given a user key
//The key needs not be valid
function get_postmsg($userkey)
{
$result = MYSQL_QUERY(\"SELECT * FROM tinychat_postmsg WHERE userkey=\'$userkey\'\");
if( ($num = mysql_numrows($result)) == 0 )
return $GLOBALS[\"ERROR_NotLoggedIn\"];
//A message was found, return it
return stripslashes(mysql_result($result,0,\"usermsg\"));
}
//Write private message
function write_private($msg, $uname, $from, $to)
{
$msg = $this->specialmsg($msg);
//Is the user that we are writing to still logged on?
$result = MYSQL_QUERY(\"SELECT user_name FROM tinychat_user WHERE user_id=$to\");
if( ($num = mysql_numrows($result)) < 1 )
return;
//Yep the user is still logged on, lets find out more about that user
$toname = mysql_result($result, 0, \"user_name\");
//Generate message
$besked = \"<font color=#\".$GLOBALS[\"private_color\"].\"><b>\".$uname.\" (\".$GLOBALS[\"CONF_ToName\"].\" $toname) : </b>\";
$besked .= \"$msg</font><br>\\n\";
$message = @file(\"data/msg$from\");
//Write private message to the parties involved, ignore errors
if( ($fp=@fopen(\"data/msg$from\", \"w\")) )
{
fputs($fp, $besked);
for ( $j=0 ; $j<25-1 ; $j++ )
fputs($fp, $message[$j]);
fclose($fp);
}
$message = @file(\"data/msg$to\");
if( ($fp=@fopen(\"data/msg$to\", \"w\")) )
{
fputs($fp, $besked);
for ( $j=0 ; $j<25-1 ; $j++ )
fputs($fp, $message[$j]);
fclose($fp);
}
}
//Write private system message
function write_private_system($msg, $uname, $from)
{
$besked = \"<font color=#\".$GLOBALS[\"private_color\"].\"><b>\".$GLOBALS[\"systemname\"].\" (\".$GLOBALS[\"CONF_ToName\"].\" $uname) : </b>\";
$besked .= \"$msg</font><br>\\n\";
$message = @file(\"data/msg$from\");
if( ($fp=@fopen(\"data/msg$from\", \"w\")) )
{
fputs($fp, $besked);
for ( $j=0 ; $j<25-1 ; $j++ )
fputs($fp, $message[$j]);
fclose($fp);
}
}
//Interface function for write_public
function write_system($msg)
{
$this->write_public($msg, $GLOBALS[\"system_color\"], $GLOBALS[\"system_color\"], $GLOBALS[\"systemname\"]);
}
//Remove inactive users
function cleanup()
{
//Any inactive users?
$result = MYSQL_QUERY(\"SELECT user_id, user_name FROM tinychat_user WHERE user_lastcontact+300<\".time().\" AND user_lastcontact!= 0\");
if( ($num = mysql_numrows($result)) == 0 )
return;
$i=0;
//Yep, there are inactive users
//Let\'s log the out
while( $i < $num )
{
$user_id = mysql_result($result,$i,\"user_id\");
$user_name = mysql_result($result,$i,\"user_name\");
$this->logout($user_id, $user_name);
$i++;
}
}
//Error output function
function display_error($errormsg)
{
$fp = @fopen(\"templates/error.tmp\", \"r\");
$file = fread($fp, 8192);
fclose($fp);
$file = eregi_replace(\"ERROR\", $errormsg, $file);
echo $file;
}
}
//Class for Normal users
class HexChatNormalUser
{
var $userid;
var $userkey;
var $namecol;
var $textcol;
var $username;
var $status;
//Class constructor
function HexChatNormalUser($usid, $uskey, $tcol, $ncol, $uname, $ustat)
{
$this->userid = $usid;
$this->namecol = $ncol;
$this->textcol = $tcol;
$this->username = $uname;
$this->userkey = $uskey;
$this->status = $ustat;
}
//Special commands, none
function docommand($mychat, $msg, $to)
{
//No special commands, call the basic commands
if( $this->basiccommands($mychat, $msg, $to) )
return 1;
return 0;
}
//Basic commands... Available to all users
function basiccommands($mychat, $msg, $to)
{
if( (strpos($msg, \"me\", 0) == 1) and $msg[0] == \'/\' )
{
$mychat->write_public_action(substr($msg,4), $this->username);
return 1;
}
if( (strpos($msg, \"nick\", 0) == 1) and $msg[0] == \'/\' )
{
if( strlen($msg) > (24+6) ) $msg = substr($msg, 0, (24+6));
$mychat->change_nick($this, substr($msg,6));
return 1;
}
if( (strpos($msg, \"textcolor\", 0) == 1) and $msg[0] == \'/\' )
{
if( strlen($msg) > (8+11) ) $msg = substr($msg, 0, (8+11));
$mychat->change_textcolor($this, substr($msg,11));
return 1;
}
return 0;
}
//User writes a message
function write($mychat, $to, $msg)
{
$msg = stripslashes($msg);
$msg = htmlentities($msg);
//Was it a command?
if( !$this->docommand($mychat, $msg, $to) )
{
//Nope, it was a message... private or public?
if( $to == -1 )
$mychat->write_public($msg, $this->namecol, $this->textcol, $this->username);
else
$mychat->write_private($msg, $this->username, $this->userid, $to);
}
//Do cleanup
$mychat->cleanup();
//Return message output
$this->top();
}
//Outputs topic
function topic()
{
echo \"<html><body bgcolor=#\".$GLOBALS[\"topic_background_color\"].\" link=#\".$GLOBALS[\"topic_link_color\"].\" \";
echo \"text=#\".$GLOBALS[\"topic_text_color\"].\" \";
echo \"vlink=#\".$GLOBALS[\"topic_link_color\"].\" alink=#\".$GLOBALS[\"topic_link_color\"].\">\";
echo \"<meta http-equiv=\\\"Refresh\\\" content=\\\"\".$GLOBALS[\"CONF_TopicUpdateSpeed\"].\"; URL=topic.php?ukey=\".$this->userid.\"&skey=\".$this->userkey.\"\\\">\";
echo \"<font face=\\\"Verdena, Tahoma, Arial\\\" size=2 color=#\".$GLOBALS[\"topic_text_color\"].\"><strong>\";
@readfile(\"data/topic\");
echo \"</strong></font>\";
echo \"</body></html>\";
}
//User hits the logout button
function logout($mychat)
{
$logout_msg = $this->username.$GLOBALS[\"CONF_LogoutMsg\"].date(\"H:i\");
$mychat->write_system($logout_msg);
MYSQL_QUERY(\"UPDATE tinychat_user SET user_lastcontact=0 WHERE user_id=\".$this->userid);
unlink(\"data/msg\".$this->userid);
unlink(\"data/user\".$this->userid);
$mychat->display_error($GLOBALS[\"CONF_LoggedOut\"]);
}
//Outputs buttom frame (control panel) for Normal users
function bund($mychat)
{
$fp = @fopen(\"templates/bund_normal.tmp\", \"r\");
$file = fread($fp, 8192);
fclose($fp);
$file = eregi_replace(\"USERNAME\", $this->username, $file);
$file = eregi_replace(\"USERID\", $this->userid, $file);
$file = eregi_replace(\"USERKEY\", $this->userkey, $file);
$file = eregi_replace(\"NUMUSERS\", strval($this->get_numusers()), $file);
$file = eregi_replace(\"USERLIST\", $this->get_userlist(), $file);
echo $file;
$mychat->cleanup();
}
//Outputs main frame (messages)
function top()
{
echo \"<html><body bgcolor=#\".$GLOBALS[\"background_color\"].\" link=#\".$GLOBALS[\"link_color\"].\" \";
echo \"text=#\".$GLOBALS[\"text_color\"].\" \";
echo \"vlink=#\".$GLOBALS[\"link_color\"].\" alink=#\".$GLOBALS[\"link_color\"].\">\";
echo \"<meta http-equiv=\\\"Refresh\\\" content=\\\"\".$GLOBALS[\"CONF_MsgUpdateSpeed\"].\"; URL=top.php?ukey=\".$this->userid.\"&skey=\".$this->userkey.\"\\\">\";
echo \"<font face=\\\"Verdena, Tahoma, Arial\\\" size=2 color=#\".$GLOBALS[\"text_color\"].\">\";
@readfile(\"data/msg\".$this->userid.\"\");
echo \"</font>\";
echo \"</body></html>\";
}
//Gets the userlist used by the control panel
function userlist()
{
//Get all active users
$result = MYSQL_QUERY(\"SELECT user_id, user_name FROM tinychat_user WHERE user_lastcontact+300>\".time().\" AND user_id!=\".$this->userid);
if( ($num = mysql_numrows($result)) == 0 )
return $users;
$i=0;
//Generate HTML to be used in the control panel
while( $i<$num )
{
$user_id = mysql_result($result, $i,\"user_id\");
$user_name = mysql_result($result, $i,\"user_name\");
$users .= \"<option value=$user_id>$user_name\";
$i++;
}
return $users;
}
//Interface function, no special users
function get_userlist()
{
$normus = \"<option value=-1>\".$GLOBALS[\"CONF_AllName\"];
$normus .= $this->userlist();
return $normus;
}
//Return the number of active users on the chat
function get_numusers()
{
$result = MYSQL_QUERY(\"SELECT user_id FROM tinychat_user WHERE user_lastcontact+300>\".time());
if( ($num = mysql_numrows($result)) == 0 )
return 0;
return $num;
}
}
//Class for CoAdmin users
class HexChatCoAdminUser extends HexChatNormalUser
{
//Constructor
function HexChatCoAdminUser($usid, $uskey, $tcol, $ncol, $uname, $ustat)
{
//Call the constructor of the class from which we inherit
$this->HexChatNormalUser($usid, $uskey, $tcol, $ncol, $uname, $ustat);
}
//Outputs buttom frame (control panel) for CoAdmin users
function bund()
{
$fp = @fopen(\"templates/bund_coadmin.tmp\", \"r\");
$file = fread($fp, 8192);
fclose($fp);
$file = eregi_replace(\"USERNAME\", $this->username, $file);
$file = eregi_replace(\"USERID\", $this->userid, $file);
$file = eregi_replace(\"USERKEY\", $this->userkey, $file);
$file = eregi_replace(\"NUMUSERS\", strval($this->get_numusers()), $file);
$file = eregi_replace(\"USERLIST\", $this->get_userlist(), $file);
echo $file;
}
//Special commands for CoAdmin users... Overrides inherited function
function docommand($mychat, $msg, $to)
{
//Call basic commands
if( $this->basiccommands($mychat, $msg, $to) )
return 1;
//User may change topic
if( (strpos($msg, \"topic\", 0) == 1) and $msg[0] == \'/\' )
{
$tm = \"<b>\".$this->username.\"</b> \".$GLOBALS[\"CONF_TopicPubMsg\"].\" <b>\".substr($msg,7).\"</b>\";
$mychat->change_topic(substr($msg, 7));
$mychat->write_system($tm);
return 1;
}
//User may kick
if( (strpos($msg, \"kick\", 0) == 1) and $msg[0] == \'/\' && $to>0 )
{
$mychat->write_private_system($mychat->kick_user($this, $to), $this->username, $this->userid);
return 1;
}
//User may ban
if( (strpos($msg, \"ban\", 0) == 1) and $msg[0] == \'/\' && $to>0 )
{
$mychat->write_private_system($mychat->ban_user($this, $to, time()+120), $this->username, $this->userid);
return 1;
}
return 0;
}
}
//Class for Admin users
class HexChatAdminUser extends HexChatCoAdminUser
{
//Constructor
function HexChatAdminUser($usid, $uskey, $tcol, $ncol, $uname, $ustat)
{
//Call the constructor of the class from which we inherits
$this->HexChatNormalUser($usid, $uskey, $tcol, $ncol, $uname, $ustat);
}
//Outputs buttom frame (control panel) for Admin users
function bund()
{
$fp = @fopen(\"templates/bund_admin.tmp\", \"r\");
$file = fread($fp, 8192);
fclose($fp);
$file = eregi_replace(\"USERNAME\", $this->username, $file);
$file = eregi_replace(\"USERID\", $this->userid, $file);
$file = eregi_replace(\"USERKEY\", $this->userkey, $file);
$file = eregi_replace(\"NUMUSERS\", strval($this->get_numusers()), $file);
$file = eregi_replace(\"USERLIST\", $this->get_userlist(), $file);
echo $file;
}
//Special commands for Admin users... Overrides inherited function
function docommand($mychat, $msg, $to)
{
//Call basic commands
if( $this->basiccommands($mychat, $msg, $to) )
return 1;
//User may change topic
if( (strpos($msg, \"topic\", 0) == 1) and $msg[0] == \'/\' )
{
$tm = $GLOBALS[\"CONF_TopicPrivMsg\"].\" <b>\".substr($msg,7).\"</b>\";
$mychat->change_topic(substr($msg, 7));
$mychat->write_private_system($tm, $this->username, $this->userid);
return 1;
}
//User may kick
if( (strpos($msg, \"kick\", 0) == 1) and $msg[0] == \'/\' && $to>0 )
{
$mychat->write_private_system($mychat->kick_user($this, $to), $this->username, $this->userid);
return 1;
}
//User may ban
if( (strpos($msg, \"ban\", 0) == 1) and $msg[0] == \'/\' && $to>0 )
{
$mychat->write_private_system($mychat->ban_user($this, $to, time()+900), $this->username, $this->userid);
return 1;
}
//User may change name color
if( (strpos($msg, \"namecolor\", 0) == 1) and $msg[0] == \'/\' )
{
if( strlen($msg) > (8+11) ) $msg = substr($msg, 0, (8+11));
$mychat->change_namecolor($this, substr($msg,11));
return 1;
}
return 0;
}
//Write function for Admin users. Overrides inherited function
function write($mychat, $to, $msg)
{
$msg = stripslashes($msg);
$msg = htmlentities($msg);
if( !$this->docommand($mychat, $msg, $to) )
{
if( $to == -1 )
$mychat->write_public($msg, $this->namecol, $this->textcol, $this->username);
elseif( $to == -2 )
$mychat->write_system($msg);
else
$mychat->write_private($msg, $this->username, $this->userid, $to);
}
$this->top();
}
//Userlist function for Admins. Overrides inherited function
function get_userlist()
{
$normus = \"<option value=-1>\".$GLOBALS[\"CONF_AllName\"];
$normus .= \"<option value=-2>\".$GLOBALS[\"CONF_ChatName\"];
$normus .= $this->userlist();
return $normus;
}
}
?>