Esempio n. 1
0
function register()
{
    $check = checkUserID($_POST['email']);
    if (!$check) {
        $user_id = $_REQUEST['email'];
        $previlage = getConfig("USER_REGISTER_PRIVILEGE");
        $access = getConfig("USER_REGISTER_ACCESS");
        $password = $_REQUEST['password'];
        unset($_POST['password']);
        $createUser = createUser($user_id, $previlage, $access, $password, $_POST);
        if ($createUser) {
            return $createUser;
        } else {
            return $createUser;
        }
    } else {
        return "You Are Already Registered With Us";
    }
}
Esempio n. 2
0
 function updateUser($attrs = array(), $userID = null, $site = SITENAME)
 {
     if (!isset($_SESSION['SESS_PRIVILEGE_ID']) || $_SESSION['SESS_PRIVILEGE_ID'] > ROLE_PRIME) {
         $site = SITENAME;
         $userID = $_SESSION['SESS_USER_ID'];
     }
     if ($userID == null && isset($_SESSION['SESS_USER_ID'])) {
         $userID = $_SESSION['SESS_USER_ID'];
     }
     if (checkUserID($userID, $site)) {
         $dataUser = $attrs;
         $reqParams = explode(",", getConfig("USER_CREATE_REQUIRED_FIELDS"));
         foreach ($reqParams as $vx) {
             if (isset($dataUser[$vx]) && ($dataUser[$vx] == null || strlen($dataUser[$vx]) <= 0)) {
                 return array("error" => "Missing Field", "field" => $vx);
             }
         }
         //Check PrivilegeID if required
         if (isset($dataUser['privilegeid'])) {
             $privilegeID = $dataUser['privilegeid'];
             $sql = _db(true)->_selectQ(_dbTable("privileges", true), "count(*) as cnt")->_where(array("id" => $privilegeID))->_raw(" AND (site='" . SITENAME . "' OR site='*')");
             $res = _dbQuery($sql, true);
             if (!$res) {
                 return array("error" => "PrivilegeID Query Error");
             }
             $data = _dbData($res, true);
             _dbFree($res, true);
             if ($data[0]['cnt'] <= 0) {
                 return array("error" => "PrivilegeID Not Found This Site {$site}");
             }
         }
         //Check AccessID if required
         if (isset($dataUser['accessid'])) {
             $accessID = $dataUser['accessid'];
             $sql = _db(true)->_selectQ(_dbTable("access", true), "count(*) as cnt")->_where(array("blocked" => 'false', "id" => $accessID))->_raw(" AND (FIND_IN_SET('" . SITENAME . "',sites) OR sites='*')");
             $res = _dbQuery($sql, true);
             if (!$res) {
                 return array("error" => "AccessID Query Error");
             }
             $data = _dbData($res, true);
             _dbFree($res, true);
             if ($data[0]['cnt'] <= 0) {
                 return array("error" => "AccessID Not Found For This Site {$site}");
             }
         }
         $sql = _db(true)->_updateQ(_dbtable("users", true), $dataUser, array("userid" => "{$userID}"));
         $res = _dbQuery($sql, true);
         if ($res) {
             return true;
         }
         return array("error" => "Error In User Updating", "details" => _db(true)->get_error());
     }
     return array("error" => "UserID Not Found");
 }
Esempio n. 3
0
 function updatePassword($pwd, $userID = null, $site = SITENAME)
 {
     if (!isset($_SESSION['SESS_PRIVILEGE_ID']) || $_SESSION['SESS_PRIVILEGE_ID'] > ROLE_PRIME) {
         $site = SITENAME;
         $userID = $_SESSION['SESS_USER_ID'];
     }
     if ($userID == null && isset($_SESSION['SESS_USER_ID'])) {
         $userID = $_SESSION['SESS_USER_ID'];
     }
     if (checkUserID($userID, $site)) {
         $hashSalt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
         $pwdAns = getPWDHash($pwd, $hashSalt);
         if (is_array($pwdAns)) {
             $pwdAns = $pwdAns['hash'];
         }
         $dataUser = array("pwd" => $pwdAns, "pwd_salt" => $hashSalt, "edited_on" => date("Y-m-d H:i:s"));
         $sql = _db(true)->_updateQ(_dbTable("users", true), $dataUser, array("userid" => "{$userID}"));
         $res = _dbQuery($sql, true);
         if ($res) {
             return true;
         }
         return array("error" => "Error In User Updating", "details" => _db(true)->get_error());
     }
     return array("error" => "UserID Not Found");
 }