/** * Returns the ban reason */ public static function getBanInfo($cid, $name) { $cdir = Container_channels::getChannelsDir(); $p = $cdir . '/' . $cid . '/ban/' . base64_encode($name); return file_exists($p) ? json_decode(file_get_contents($p), true) : '{}'; }
$res->status(403); // Forbidden return; } // run garbage collector to purge old timeout message Container_users::runGC(); // check this user is online if (!Container_users::checkUserExists($uid)) { $res->status(400); // User is not connected $res['Content-Type'] = 'application/json; charset=utf-8'; $res->body('{ "error": "User is not connected" }'); return; } // todo remove this code when channel create/join will be implemented $cdir = Container_channels::getChannelsDir(); $cpath = $cdir . '/' . $cid . '/'; @mkdir($cpath, 0777, true); @mkdir($cpath . '/users', 0777, true); if (!Container_users::joinChannel($uid, $cid)) { $res->status(200); // User already joined the channel $res['Content-Type'] = 'application/json; charset=utf-8'; $res->body(json_encode(Container_channels::getChannelUsers($cid, true))); return; } else { // post a join message $msg = Container_messages::postMsgToChannel($cid, $uid, null, 'join'); $res->status(201); // User joined the channel $res['Content-Type'] = 'application/json; charset=utf-8';
/** * Check if $uid is an operator on $cid */ public static function isOp($cid, $uid) { $cdir = Container_channels::getChannelsDir(); $p = $cdir . '/' . $cid . '/op/' . $uid; return file_exists($p); }