コード例 #1
0
ファイル: channels.php プロジェクト: ljohnso16/phpfreechat
 if ($isakick) {
     // check operator rights of $online_uid
     if (!Container_channels_op::isOp($cid, $online_uid)) {
         $res->status(403);
         $res['Content-Type'] = 'application/json; charset=utf-8';
         $res->body(GetPfcError(40304));
         // You are not allowed to kick because you don't have op rights
         return;
     }
 }
 // check this trargeted user is online on the channel
 if (!Container_channels::checkChannelUser($cid, $uid)) {
     $res->status(404);
     // User is not connected
     $res['Content-Type'] = 'application/json; charset=utf-8';
     $res->body(GetPfcError(40401));
     // User is not connected to the channel
     return;
 }
 if ($isakick) {
     // this is a kick ?
     $reason = $req->params('reason');
     // post a kick message
     $msg = Container_messages::postMsgToChannel($cid, $online_uid, array('target' => $uid, 'reason' => $reason), 'kick');
     // remove the targeted user from the channel (must be executed after postMsgToChannel)
     Container_users::leaveChannel($uid, $cid);
     // success code
     $res->status(200);
     $res['Content-Type'] = 'application/json; charset=utf-8';
     // why not blank data ?
     // $res->body(json_encode(Container_channels::getChannelUsers($cid, true)));
コード例 #2
0
     $res->status(400);
     // User is not connected
     return;
 }
 // check this user has joined the channel
 if (!Container_channels::checkChannelUser($cid, $online_uid)) {
     $res->status(403);
     // You have to join channel
     return;
 }
 // check this user is an operator on this channel
 if (!Container_channels_op::isOp($cid, $online_uid)) {
     $res->status(403);
     // You have to be an operator to banish a user
     $res['Content-Type'] = 'application/json; charset=utf-8';
     $res->body(GetPfcError(40306));
     // You have to be an operator to banish a user
     return;
 }
 // add name64 to the ban list
 $opname = Container_users::getUserData($online_uid, 'name');
 $reason = $req->params('reason');
 $ok = Container_channels_ban::addBan($cid, $name64, array('opname' => $opname, 'reason' => $reason ? $reason : '', 'timestamp' => time()));
 if ($ok) {
     $name = base64_decode($name64);
     $banuid = Container_indexes::getIndex('users/name', $name);
     $iskickban = $req->params('kickban') && $banuid;
     // notification to other connected user of this ban
     Container_messages::postMsgToChannel($cid, $online_uid, array('opname' => $opname, 'name' => $name, 'reason' => $reason ? $reason : '', 'kickban' => $iskickban), 'ban');
     // kick the user from the channel
     // (warning: do it after the above notification
コード例 #3
0
ファイル: channels-op.php プロジェクト: ljohnso16/phpfreechat
    if (!Container_users::checkUserExists($online_uid)) {
        $res->status(400);
        // User is not connected
        return;
    }
    // check this user is an operator on this channel
    if (!Container_channels_op::isOp($cid, $online_uid)) {
        $res->status(403);
        // You have to be an operator to give op to other user
        return;
    }
    // check the destination user is an operator on this channel
    if (!Container_channels_op::isOp($cid, $uid)) {
        $res->status(400);
        $res['Content-Type'] = 'application/json; charset=utf-8';
        $res->body(GetPfcError(40002));
        // This user is not an operator on the channel
        return;
    }
    // removes $uid user as a $cid channel operator
    $ok = Container_channels_op::rmOp($cid, $uid);
    if ($ok) {
        $res->status(200);
        // notification to other connected user of this removed operator
        Container_messages::postMsgToChannel($cid, $online_uid, $uid, 'deop');
    } else {
        $res->status(500);
    }
    $res['Content-Type'] = 'application/json; charset=utf-8';
    $res->body(json_encode($ok));
});