本文整理汇总了PHP中Authorization类的典型用法代码示例。如果您正苦于以下问题:PHP Authorization类的具体用法?PHP Authorization怎么用?PHP Authorization使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Authorization类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_instance
public static function get_instance()
{
if (self::$instance == false) {
self::$instance = new Authorization();
}
return self::$instance;
}
示例2: CanEditProblem
public static function CanEditProblem($user_id, Problems $problem)
{
if (is_null($problem) || !is_a($problem, "Problems")) {
return false;
}
return Authorization::IsProblemAdmin($user_id, $problem);
}
示例3: getPanel
public static function getPanel() {
if( !Authorization::isAuthorized() ) return;
$panelStyles = API::parseStylesFile(CUSTOMPATH.DS."Global.views");
$paneltpl = $panelStyles["VeronicaAdminPanel"][2];
$menuItemtpl = $panelStyles["VeronicaMenuListItem"][2];
$controllers = Api::getCustom("Controller");
$modeles = Api::getCustom("Model");
$user = Authorization::getCurrentUser();
$userpanel = ViewHandler::wrap("CurrentUser", $user[0]);
$paneltpl = str_replace("<? echo \$USERPANEL;?>", $userpanel, $paneltpl);
$list = "";
foreach ($controllers as $controller){
if($controller::$inAdminPanel){
$l = str_replace("<? echo \$ADDCLICKHANDLER;?>", "Controller.add('".$controller::$name."');", $menuItemtpl);
$l = str_replace("<? echo \$CLICKHANDLER;?>", "Controller.openDashboard('".$controller::$name."');", $l);
$l = str_replace("<? echo \$COUNT;?>", "Controller.openDashboard('".$controller::$name."');", $l);
$list .= str_replace("<? echo \$ALIAS;?>", $controller::$alias, $l);
}
}
$paneltpl = str_replace("<? echo \$MENULIST;?>", $list, $paneltpl);
return $paneltpl;
}
示例4: approveUser
function approveUser($login, $pass, $createIP)
{
if ($this->checkPass($pass, $login)) {
#ПРОВЕРЯЕМ ПРАВИЛЬНОСТЬ ПАРОЛЯ
$ip = 0;
$time = time() + 60 * 2;
$this->hash = md5($this->generateCode(10));
if ($createIP) {
$ip = ip2long($_SERVER['REMOTE_ADDR']);
}
$this->prepareQuery("INSERT INTO sessions SET user_id=:id, time=:time, hash=:hash, ip=:ip");
/*$this->prepareQuery("UPDATE user SET hash=:hash, ip=:ip WHERE id=:id");*/
$this->query->bindParam(':hash', $this->hash);
$this->query->bindParam(':ip', $ip);
$this->query->bindParam(':id', $this->thisUser['user_id']);
$this->query->bindParam(':time', $time);
// Два часа!
$this->executeQuery_Simple();
$this->createCookie();
// Создаем куки
/* $this->deleteOldSessions(); // Удаляем устаревшие сессии*/
return true;
} else {
$this->errors['password_login'] = 'has-error';
// class из bootstrap
Authorization::logOut();
return false;
}
}
示例5: configure
public static function configure( $home ){
self::$home = $home;
$js = ""; $css = "";
if( Authorization::isAuthorized() ){
$files = API::getFileList( INCLUDEPATH );
$files = array_merge(API::getFileList( PLUGINSPATH ), $files);
$pos = array_search("./include/cmf/js/lib.js",$files);
unset($files[$pos]);
}
else{
$files = API::getFileList( INCLUDEPATH,-1 );
$files[] = "./include/cmf/js/lib.js";
$files[] = "./include/cmf/css/cmf.notify.css";
$files[] = "./include/cmf/css/cmf.ui.css";
}
rsort($files);
foreach ($files as $path) {
$ext = pathinfo($path);
if( substr($ext['filename'], 0,1) == '_' ) continue;
$ext = $ext['extension'];
if($ext == "js"){
$js .= str_replace("{PATH}", $path, Storage::get("Template::jsInclude"));
}else if($ext == "css")
$css .= str_replace("{PATH}", $path, Storage::get("Template::cssInclude"));
}
self::assign("TITLE", Config::$SiteConf['name']);
self::assign("META", Config::$SiteConf['meta']);
self::assign("JSINCLUDE", $js);
self::assign("CSSINCLUDE", $css);
// l(self::$vars);
}
示例6: init
public static function init()
{
if (empty(self::$obj)) {
self::$obj = new Authorization();
}
return self::$obj;
}
示例7: __callStatic
/**
* Handles the requests for post() and get()
*
* @param $name
* @param $arguments
*/
public static function __callStatic($name, $arguments)
{
$response = static::_transfer($name, $arguments);
if ($response && $name != 'delete') {
$result = static::_reponse($response);
if ($result) {
if (is_object($result) || !isset($result['error'])) {
return $result;
} else {
// Expired token ?
if (isset($result['error']['message']) && $result['error']['message'] == Auth::$_errors['oAuthTokenExpired']) {
if (isset($arguments[2])) {
Authorization::oAuthRefreshToken($arguments[2], 'updateSession', 'force');
call_user_func(array('Rest', $name), $arguments);
} else {
return compact('result', 'name', 'arguments', 'response');
}
} else {
if (isset($result['error']['message']) && $result['error']['message'] != 'Forbidden' && $result['error']['message'] != 'Not Found') {
return compact('result', 'name', 'arguments', 'response');
}
}
}
} else {
return compact('result', 'name', 'arguments', 'response');
}
} else {
if ($name != 'delete') {
return compact('result', 'name', 'arguments', 'response');
}
}
}
示例8: Insert
public static function Insert($data, $settings, $marathon, $campaign, $database)
{
if (!Authorization::IsAuthorized($settings)) {
return new ZdpArrayObject(['error' => 'You are not authorized to perform this action.']);
}
$playerID;
$gameID;
$scheduleStartTime;
$scheduleEndTime;
$scheduleUnlockAmount;
$error = false;
$errorMessage;
if (array_key_exists('PlayerID', $data)) {
$playerID = $data['PlayerID'];
} else {
$error = true;
$errorMessage = 'No player id was provided.';
}
if (array_key_exists('GameID', $data)) {
$gameID = $data['GameID'];
} else {
$error = true;
$errorMessage = 'No game id was provided.';
}
if (array_key_exists('StartTime', $data)) {
$scheduleStartTime = $data['StartTime'];
} else {
$error = true;
$errorMessage = 'No start time was provided.';
}
if (array_key_exists('EndTime', $data)) {
$scheduleEndTime = $data['EndTime'];
} else {
$error = true;
$errorMessage = 'No end time was provided.';
}
if (array_key_exists('UnlockAmount', $data)) {
$scheduleUnlockAmount = $data['UnlockAmount'];
} else {
$error = true;
$errorMessage = 'No unlock amount was provided.';
}
if ($database instanceof ZdpArrayObject) {
$error = true;
$errorMessage = $database['error'];
}
if (!$error) {
$sql = 'CALL sp_insert_schedule (:game_id, :campaign_id, :player_id, :schedule_endtime, :schedule_starttime, :schedule_unlockamount)';
$statement = $database->prepare($sql);
if ($statement->execute([':game_id' => $gameID, ':campaign_id' => $campaign, ':player_id' => $playerID, ':schedule_starttime' => $scheduleStartTime, ':schedule_endtime' => $scheduleEndTime, ':schedule_unlockamount' => $scheduleUnlockAmount])) {
$schedules = $statement->fetchAll(PDO::FETCH_ASSOC);
$output = new ZdpArrayObject(['result' => new ZdpArrayObject(['schedule' => $schedules])]);
} else {
$output = new ZdpArrayObject(['error' => $statement->errorInfo()]);
}
} else {
$output = new ZdpArrayObject(['error' => $errorMessage]);
}
return $output;
}
示例9: editCategory
public function editCategory($id)
{
if (Authorization::Authorize('Admin')) {
$this->view->category = $this->model->getCategory();
// viet code xy lu o day
$this->data = array();
$this->view->title = 'Edit Category';
$this->view->cat = $this->model->showCatById($id);
if (isset($_POST['submit'])) {
if (empty($_POST['catname'])) {
$this->view->msg = "Vui lòng nhập tên Category";
$this->view->renderAdmin('category/editcategory');
} else {
$this->data['catname'] = mysqli_real_escape_string($this->model->connect, $_POST['catname']);
$this->data['parent'] = $_POST['category'];
if ($this->model->editCat($this->data, $id) == true) {
$this->view->redirect('listcategory');
} else {
$this->view->msg = "Edit category faild";
$this->view->renderAdmin('category/editcategory');
}
}
} else {
$this->view->renderAdmin("category/editcategory");
}
} else {
$this->view->render("user/index");
}
}
示例10: Insert
public static function Insert($data, $settings, $marathon, $campaign, $database)
{
if (!Authorization::IsAuthorized($settings)) {
return new ZdpArrayObject(['error' => 'You are not authorized to perform this action.']);
}
$playerName;
$error = false;
if (array_key_exists('name', $POST) && trim($_POST['name']) != '') {
$playerName = $_POST['name'];
} else {
$error = true;
$errorMessage = 'No player name was provided.';
}
if ($database instanceof ZdpArrayObject) {
$error = true;
$errorMessage = $database['error'];
}
if (!$error) {
$sql = 'CALL sp_insert_player (:campaign_id, :marathon_id, :player_name)';
$statement = $database->prepare($sql);
if ($statement->execute([':marathon_id' => $marathon, ':campaign_id' => $campaign, ':player_name' => $playerName])) {
$players = $statement->fetchAll(PDO::FETCH_ASSOC);
$output = new ZdpArrayObject(['result' => new ZdpArrayObject(['player' => $players])]);
} else {
$output = new ZdpArrayObject(['error' => $statement->errorInfo()]);
}
} else {
$output = new ZdpArrayObject(['error' => $errorMessage]);
}
return $output;
}
示例11: validateRequest
/**
* Validate requests for grader apis
*
* @param Request $r
* @throws ForbiddenAccessException
*/
private static function validateRequest(Request $r)
{
self::authenticateRequest($r);
if (!Authorization::IsSystemAdmin($r['current_user_id'])) {
throw new ForbiddenAccessException();
}
}
示例12: run
/**
* @return retorna un peticion solicitada
*/
public static function run(Request $peticion)
{
$controller = $peticion->getControlador() . "Controller";
$rutaControlador = ROOT . "controllers" . DS . $controller . ".php";
$metodo = $peticion->getMetodo();
$args = $peticion->getArgs();
//exit;
if (is_readable($rutaControlador)) {
require_once $rutaControlador;
$Controlador = new $controller();
if (is_callable(array($controller, $metodo))) {
$metodo = $peticion->getMetodo();
} else {
$metodo = "index";
}
if ($metodo == 'login') {
# code...
} else {
Authorization::Logged();
}
if (isset($args)) {
call_user_func_array(array($Controlador, $metodo), $args);
} else {
call_user_func(array($Controlador, $metodo));
}
} else {
throw new Exception("Controlador no encontrado ");
}
}
示例13: run
/**
* run ejecuta clase Request
* permite llamar una funcion sin necesidad de instanciar la clase
* @param string $peticion parametro que se recibe de Request
* @var string controller almacena controlador
* @var string rutaControlador guarda ruta del controlador
* @var string $metodo invoca a la funcion getMetodo de request
* @var string $args invoca a la funcion getArgs de request
* */
public static function run(Request $peticion)
{
$controller = $peticion->getControlador() . 'Controller';
$rutaControlador = ROOT . 'controllers' . DS . $controller . '.php';
$metodo = $peticion->getMetodo();
$args = $peticion->getArgs();
if (is_readable($rutaControlador)) {
include_once $rutaControlador;
$controlador = new $controller();
if (is_callable(array($controller, $metodo))) {
$metodo = $peticion->getMetodo();
} else {
$metodo = 'index';
}
if ($metodo == 'login') {
} else {
Authorization::logged();
}
if (isset($args)) {
call_user_func_array(array($controlador, $metodo), $args);
} else {
call_user_func_array(array($controller, $metodo));
}
} else {
throw new Exception("Controlador no encontrado");
}
}
示例14: delete_session
public function delete_session()
{
$user_id = (int) $_COOKIE['user_id'];
$this->prepare("DELETE FROM sessions WHERE user_id=:id");
$this->query->bindParam(':id', $user_id, PDO::PARAM_INT);
$this->execute_simple();
Authorization::delete_cookie();
}
示例15: index
/**
* Display the specified resource.
*
* @param int $hash
* @return Response
*/
public function index($hash)
{
if ($hash) {
$wishes = $this->service->getWishesForUser($hash);
} else {
$wishes = $this->service->getWishesForUser(\Authorization::user()->hash);
}
return $this->returnWishlist($wishes);
}