当前位置: 首页>>代码示例>>PHP>>正文


PHP Token::exists方法代码示例

本文整理汇总了PHP中Token::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::exists方法的具体用法?PHP Token::exists怎么用?PHP Token::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Token的用法示例。


在下文中一共展示了Token::exists方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_update_token

 private function get_update_token()
 {
     $is_token_valid = false;
     try {
         $is_token_valid = $this->token->exists() && $this->token->read() == self::$token_file_content;
     } catch (IOException $ioe) {
         $is_token_valid = false;
     }
     if (!$is_token_valid) {
         throw new TokenNotFoundException($this->token->get_path_from_root());
     }
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:12,代码来源:UpdateServices.class.php

示例2: generate_token

 private function generate_token()
 {
     $length = 32;
     $value = '';
     $keys = array_merge(range(0, 9), range('a', 'f'));
     for ($i = 0; $i < $length; $i++) {
         $value .= $keys[array_rand($keys)];
     }
     $check = new Token();
     $check->where('value', $value)->get();
     if ($check->exists()) {
         $token = $this->generate_token();
     }
     $token = new Token();
     $token->value = $value;
     return $token;
 }
开发者ID:petersonb,项目名称:ourvigor,代码行数:17,代码来源:oauth.php

示例3: all_get

 public function all_get($token)
 {
     $token_entry = new Token();
     $token_entry->get_by_valid_token($token)->get();
     if ($token_entry->exists()) {
         $settings = new Setting();
         $settings->get();
         $response = new stdClass();
         $response->status = true;
         $response->settings = new stdClass();
         foreach ($settings as $setting) {
             $response->settings->{$setting->setting_key} = $setting->setting_value;
         }
         $this->response($response);
     } else {
         $response = new stdClass();
         $response->status = false;
         $response->error = 'Token not found or session expired';
         $this->response($response);
     }
 }
开发者ID:NaszvadiG,项目名称:crono,代码行数:21,代码来源:settings.php

示例4: weekTotal_get

 public function weekTotal_get($token)
 {
     //YEARWEEK(FROM_UNIXTIME(stop_time)) = YEARWEEK(CURRENT_DATE)
     $token_entry = new Token();
     $token_entry->get_by_valid_token($token)->get();
     $response = new stdClass();
     if ($token_entry->exists()) {
         //TODO
         $timer_entries = new Timer_entry();
         //Selecting the entry
         $timer_entries->getThisWeek()->where('active', 0)->select_sum('(stop_time - start_time)', 'totalTime')->get();
         $response->status = true;
         $response->totalThisWeek = 0;
         if ($timer_entries->exists()) {
             if (!$timer_entries->totalTime) {
                 $response->totalThisWeek = from_unix_timespan_to_string(0);
             }
             $response->totalThisWeek = from_unix_timespan_to_string($timer_entries->totalTime);
         }
     } else {
         $response->status = false;
         $response->error = 'Token not found or session expired';
     }
     $this->response($response);
 }
开发者ID:NaszvadiG,项目名称:crono,代码行数:25,代码来源:timer.php

示例5: user_delete

 public function user_delete($id, $token)
 {
     $token_entry = new Token();
     $token_entry->get_by_valid_token($token)->get();
     $response = new stdClass();
     if ($token_entry->exists() && $token_entry->user->get()->is_admin) {
         if ($token_entry->user_id != $id) {
             $user = new User();
             $user->get_by_id($id);
             $user->delete();
             $response->status = TRUE;
             $this->response($response);
         } else {
             $response->status = FALSE;
             $response->error = 'Cannot delete active user!';
             $this->response($response);
         }
     } else {
         $response->status = FALSE;
         $response->error = 'Token not found, not an admin or session expired';
         $this->response($response);
     }
 }
开发者ID:NaszvadiG,项目名称:crono,代码行数:23,代码来源:account.php

示例6: Client

require_once System::get()->getSystem() . 'Model.php';
require_once System::get()->getSystem() . 'Entry.php';
require_once System::get()->getSystem() . 'Utils.php';
require_once System::get()->getSystem() . 'Request.php';
require_once System::get()->getSystem() . 'Data.php';
require_once System::get()->getSystem() . 'HTTPError.php';
// Models
require_once System::get()->getModels() . 'Client.php';
require_once System::get()->getModels() . 'Controller.php';
require_once System::get()->getModels() . 'Permission.php';
require_once System::get()->getModels() . 'Rank.php';
require_once System::get()->getModels() . 'Token.php';
Token::flush();
// TODO: Remplacer 'root' par '' en prod absolument !!
$tokenString = $_SERVER['HTTP_X_TOKEN'] ?? 'root';
if (Token::exists('token', $tokenString)) {
    $token = Token::getBy('token', $tokenString);
    Request::get()->setClient(new Client($token->client_id));
}
$controller = Controller::getBy('uri', Request::get()->getArg(0));
$filename = System::get()->getControllers() . $controller->uri . '.php';
$classname = ucfirst($controller->uri) . "Ctrl";
if (!file_exists($filename)) {
    HTTPError::NotFound();
    exit;
}
if (!in_array(Request::get()->getMethod(), array('GET', 'POST'))) {
    parse_str(file_get_contents('php://input'), $_POST);
}
require_once System::get()->getSystem() . 'ControllerInterface.php';
require_once $filename;
开发者ID:dreamvids,项目名称:api,代码行数:31,代码来源:index.php

示例7: index_post

 /**
  * Create a new project
  * @route POST projects/
  */
 public function index_post()
 {
     $token_entry = new Token();
     $token_entry->get_by_valid_token($this->post('token'))->get();
     $response = new stdClass();
     if ($token_entry->exists()) {
         $project = new Project();
         $project->name = $this->post('name');
         $project->customer_id = $this->post('customer_id');
         if ($project->save()) {
             $response->status = true;
         } else {
             $response->status = false;
             $response->error = 'Project not saved!';
         }
     } else {
         $response->status = false;
         $response->error = 'Token not found or session expired';
     }
     $this->response($response);
 }
开发者ID:NaszvadiG,项目名称:crono,代码行数:25,代码来源:projects.php


注:本文中的Token::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。