Пример #1
0
     $password = isset($auth[1]) ? $auth[1] : '';
 }
 // filter login with hooks
 if (isset($GLOBALS['pfc_hooks']['pfc.filter.login'])) {
     foreach ($GLOBALS['pfc_hooks']['pfc.filter.login'] as $filter) {
         $login = trim($filter($login));
     }
     if ($login == '') {
         $res->status(400);
         $res['Content-Type'] = 'application/json; charset=utf-8';
         $res->body('{ "error": "Bad characters used in login" }');
         return;
     }
 }
 // check login/password
 if ($login and Container_indexes::getIndex('users/name', $login)) {
     $res->status(403);
     $res['Content-Type'] = 'application/json; charset=utf-8';
     $res['Pfc-WWW-Authenticate'] = 'Basic realm="Authentication"';
     $res->body(GetPfcError(40302));
     // "Login already used"
     return;
 } else {
     if ($login) {
         $uid = Container_users::generateUid();
         $udata = array('id' => $uid, 'name' => $login, 'role' => 'user');
         Container_users::setUserData($uid, $udata);
         $_SESSION['userdata'] = $udata;
         Container_users::setIsAlive($uid);
         $res->status(200);
         $res['Content-Type'] = 'application/json; charset=utf-8';
Пример #2
0
    // 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);
    }
});
/**
Пример #3
0
 /**
  * Remove user's data
  */
 public static function rmUser($uid)
 {
     $udir = self::getDir() . '/' . $uid;
     if (!is_dir($udir)) {
         return false;
     } else {
         // remove user's indexes
         Container_indexes::rmIndex('users/name', self::getUserData($uid, 'name'));
         // remove user's data
         rrmdir($udir);
         return true;
     }
 }