📄 commands.php
字号:
$user = ChatServer::getUser($this->userid);
$soscall = 'SOS call from user ' . $user['login'] . ' in this Room';
if(strlen($txt) > 4) $soscall .= '<br>User message: ' . substr($txt, 5);
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE roomid=? AND userid IS NOT NULL");
$rs = $stmt->process($this->roomid);
while($rec = $rs->next()) {
if(ChatServer::userInRole($rec['userid'], ROLE_ADMIN)) {
$this->sendToUser($rec['userid'], new Message('alrt', $this->userid, null, $soscall));
return 'ok';
}
}
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE id=?");
$rs = $stmt->process($this->roomid);
$rec = $rs->next();
$soscall = 'SOS call from user ' . $user['login'] . ' in Room ' . $rec['name'];
if(!$rec['ispublic']) $soscall .= ' (Private)';
if(strlen($txt) > 4) $soscall .= '<br>User message: ' . substr($txt, 5);
; $stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE roomid<>? AND userid IS NOT NULL");
$rs = $stmt->process($this->roomid);
while($rec = $rs->next()) {
if(ChatServer::userInRole($rec['userid'], ROLE_ADMIN)) {
$this->sendToUser($rec['userid'], new Message('alrt', $this->userid, null, $soscall));
return 'ok';
}
}
$txt = 'No Moderators found in any Room';
$this->sendToUser(null, new Message($type, $this->userid, $GLOBALS['fc_config']['liveSupportMode']?$this->roomid:null, $txt, $this->color));
return 'ok';
}
if($irc_cmd == '/kickroom' && $role_admin) {
$this->sendToUser(null, new Message($type, $this->userid, $GLOBALS['fc_config']['liveSupportMode']?$this->roomid:null, $txt, $this->color));
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE roomid=? AND userid IS NOT NULL");
if($rs = $stmt->process($this->roomid)) {
while($rec = $rs->next()) {
if(!ChatServer::userInRole($rec['userid'], ROLE_ADMIN)) {
$conn = new Connection($rec['id']);
$conn->doLogout('expiredlogin');
}
}
}
return 'ok';
}
if($irc_cmd == '/motd' || $irc_cmd == '/move' || $irc_cmd == '/kickout' || $irc_cmd == '/reban' || $irc_cmd == '/unban' || $irc_cmd == '/unignore' || $irc_cmd == '/msg' || $irc_cmd == '/query' || $irc_cmd == '/whois' || $irc_cmd == '/whowas' || $irc_cmd == '/who' || $irc_cmd == '/profile') {
$who_user = strtolower(substr($txt, $irc_len + 1));
if(substr($who_user, 0, 6) == '"') {
$who_user = substr($who_user, 6, strrpos($who_user, '"') - 6);
$start_mess = strlen($who_user) + 13 + $irc_len;
} else {
$who_user = substr($who_user, 0, strpos($who_user . ' ', ' '));
$start_mess = strlen($who_user) + 2 + $irc_len;
}
if($irc_cmd == '/unignore' || $irc_cmd == '/msg') {
$msg_txt = substr($txt, $start_mess);
} else { $msg_txt = ' ';}
if($irc_cmd == '/motd') {
$this->sendToUser(null, new Message($type, $this->userid, $GLOBALS['fc_config']['liveSupportMode']?$this->roomid:null, $txt, $this->color));
if($role_admin && $who_user == '@') {
$rfile = './appdata/motd.txt';
if(file_exists($rfile) && $php_file = @fopen($rfile, 'rb')) {
$contents = fread($php_file, $fz = filesize ($rfile));
fclose ($php_file);
$contents = str_replace( chr(13) . chr(10) , "<br>", $contents); // replace crlf with line breaks
$contents = str_replace( chr(10) . chr(13) , "<br>", $contents); // replace lfcr with line breaks
$rtxt = explode('<br>', $contents);
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms");
if($rs = $stmt->process()) {
while($rec = $rs->next()) {
foreach($rtxt as $k => $v)
$this->sendToRoom(null, new Message('msg', $this->userid, $rec['id'], $v, $this->color));
reset($rtxt);
}
}
}
return 'ok';
}
if($role_admin && $who_user) {
$rfile = './appdata/motd.txt';
if($php_file = @fopen($rfile, 'wb')) {
fwrite($php_file, html_entity_decode(substr($txt, $irc_len + 1)));
fclose ($php_file);
}
}
include_once(INC_DIR . 'classes/doMotd.php');
return 'ok';
}
if($who_user != substr($irc_cmd, 1)) {
if($irc_cmd == '/unignore' || $irc_cmd == '/whowas' || ($irc_cmd == '/unban' && $role_admin) || ($irc_cmd == '/reban' && $role_admin)) {
$who = array();
$who = $GLOBALS['fc_config']['cms']->getUsers();
while($rec = $who->next()) {
if(strtolower($rec['login']) == $who_user && $rec['roles'] != ROLE_SPY) {
$who_userid = $rec['id'];
break;
}
}
} else {
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL");
if($rs = $stmt->process()) {
while($rec = $rs->next()) {
$user = ChatServer::getUser($rec['userid']);
$spy = ChatServer::userInRole($rec['userid'], ROLE_SPY);
if($user && !$spy && $who_user == strtolower($user['login'])) {
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE id=?");
$rs = $stmt->process($rec['roomid']);
$room = $rs->next();
if($role_admin || $rec['userid'] == $this->userid) {
$who_userid = $rec['userid'];
$who_ip = 'User=' . $user['login'] . ' room=' . $room['name'] . ' created=' . substr($rec['created'], 8, 2) . ':' . substr($rec['created'], 10, 2) . ' lang=' . $rec['lang'] . ' tz=' . $rec['tzoffset'] . ' ip=' . $rec['ip'] . ' host=' . gethostbyaddr($rec['ip']);
$who_id = $rec['id'];
}
if(!$role_admin && $room['ispublic']) $who_userid = $rec['userid'];
break;
}
}
}
}
if(!$who_userid && $who_user != '@') {
$this->sendToUser(null, new Message($type, $this->userid, $GLOBALS['fc_config']['liveSupportMode']?$this->roomid:null, $txt, $this->color));
$txt = 'User "' . $who_user . '" was not found';
if($irc_cmd != '/whowas') $txt .= ' in any Room';
$this->sendToUser(null, new Message($type, $this->userid, $GLOBALS['fc_config']['liveSupportMode']?$this->roomid:null, $txt, $this->color));
return 'ok';
}
if($irc_cmd == '/kickout' && $role_admin) {
$this->sendToUser(null, new Message($type, $this->userid, $GLOBALS['fc_config']['liveSupportMode']?$this->roomid:null, $txt, $this->color));
if($who_user == '@') {
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL");
if($rs = $stmt->process()) {
while($rec = $rs->next()) {
if(!ChatServer::userInRole($rec['userid'], ROLE_ADMIN)) {
$conn = new Connection($rec['id']);
$conn->doLogout('expiredlogin');
}
}
}
} else {
$conn = new Connection($who_id);
$conn->doLogout('expiredlogin');
}
return 'ok';
}
if($irc_cmd == '/reban' && $role_admin) {
$this->sendToUser(null, new Message($type, $this->userid, $GLOBALS['fc_config']['liveSupportMode']?$this->roomid:null, $txt, $this->color));
if($who_user == '@') {
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}bans");
if($rs = $stmt->process()) {
while($rec = $rs->next()) {
$stmt = new Statement("UPDATE {$GLOBALS['fc_config']['db']['pref']}bans SET created=NOW() WHERE banneduserid=?");
$stmt->process($rec['banneduserid']);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -