Esempio n. 1
0
     // 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
     //  or he will not receive the notification)
     if ($iskickban) {
         Container_users::leaveChannel($banuid, $cid);
     }
     $res->status(201);
 } else {
     $res->status(500);