本文整理汇总了PHP中Authorization::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Authorization::init方法的具体用法?PHP Authorization::init怎么用?PHP Authorization::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authorization
的用法示例。
在下文中一共展示了Authorization::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
// проверяем ридирект с ошибки
$rdStatus = isset($_SERVER['REDIRECT_STATUS']) ? $_SERVER['REDIRECT_STATUS'] : 0;
if (array_key_exists($rdStatus, $this->httpError)) {
$this->makeError("[" . __CLASS__ . "] " . $this->httpError[$rdStatus]);
}
// проверяем авторизацию
if (!Authorization::init()->isAuth()) {
$this->makeError("[" . __CLASS__ . "] API доступно только авторизованным пользователям!");
}
$action = $this->getParam($this->actionName);
if (!array_key_exists($action, $this->api)) {
$this->makeError("[" . __CLASS__ . "] не найдена комманда " . $action . '!');
}
$metod = $this->api[$action]['metod'];
$param = array();
switch ($action) {
// дополнительная проверка \ обработка параметров для комманд
case 'get':
$filter = array();
foreach ($this->api[$action]['param'] as $val) {
$paramElem = $this->getParam($val, false);
if ($paramElem !== false) {
$filter[$val] = $paramElem;
}
}
$param[] = $filter;
break;
default:
foreach ($this->api[$action]['param'] as $val) {
$param[] = $this->getParam($val);
}
break;
}
// создаем экземпляр класса
try {
$obj = new UserModel(DB::GetDBH());
$userObject = call_user_func_array(array($obj, $metod), $param);
} catch (Exception $e) {
$this->makeError($e->getMessage());
}
echo $this->outputFormated($userObject);
return;
}
示例2:
<meta name="description" content="Форма для тестирования приложения">
<link rel="stylesheet" href="assets/css/styles.css?v=1.0">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<form action="<?php
echo $_SERVER['PHP_SELF'];
?>
" id="api_form" method="post">
<?php
if (!Authorization::init()->isAuth()) {
?>
<label><span>Логин</span>
<input type="text" value="test" name="authorization[login]">
</label>
<label><span>Пароль</span>
<input type="password" value="test" name="authorization[pass]">
</label>
<label>
<input type="submit" value="Вход">
</label>
<?php
} else {
?>
<label class="radio action" for="gettable">
<input type="radio" name="action" id="gettable" value="gettable">Cтруктура таблицы и доступных к выборке полей</label>