當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Authorization::init方法代碼示例

本文整理匯總了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;
 }
開發者ID:freecod,項目名稱:UserList,代碼行數:45,代碼來源:route.php

示例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>
開發者ID:brzhezinskiy,項目名稱:api,代碼行數:31,代碼來源:form.php


注:本文中的Authorization::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。