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


PHP Flight::request方法代码示例

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


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

示例1: save_pass

 /**
  * Save chosen password
  */
 public function save_pass()
 {
     $pass = F::request()->data->password;
     $pass2 = F::request()->data->password2;
     if ($pass === $pass2) {
         if (!empty($pass)) {
             if (Action::savePassword($pass)) {
                 $_SESSION['flashbag'] = '
                 <div class="alert alert-success alert-dismissible">
                     <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                     Your password has successfully been set.
                 </div>';
                 $_SESSION['admin'] = 1;
                 F::redirect('/settings');
                 exit;
             } else {
                 $_SESSION['flashbag'] = '<div class="alert alert-danger">An error occured. Please verify that the app/ and src/ folder are writable.</div>';
             }
         } else {
             $_SESSION['flashbag'] = '<div class="alert alert-warning">No password ? Are you serious ? Put at least some letters.</div>';
         }
     } else {
         $_SESSION['flashbag'] = '<div class="alert alert-danger">You must enter the same password twice.</div>';
     }
     $this->index();
 }
开发者ID:ray0be,项目名称:fastdoc,代码行数:29,代码来源:Install.php

示例2: saveProfile

 /**
  * Save properties of the user profile
  * @return [JSON] Success or error message
  */
 public static function saveProfile()
 {
     if (!Flight::has('currentUser')) {
         Flight::json(['Error' => 'No Access']);
     }
     $currentUser = Flight::get('currentUser');
     if (isset(Flight::request()->query->bio)) {
         $currentUser->bio = Flight::request()->data->bio;
     } else {
         if (isset(Flight::request()->query->password)) {
             if (!isset(Flight::request()->data->passwordold) || !isset(Flight::request()->data->passwordnew1) || !isset(Flight::request()->data->passwordnew2)) {
                 Flight::json(['success' => false, 'exception' => 'Empty fields']);
             }
             if ($currentUser->password === hash("sha256", Flight::request()->data->passwordold)) {
                 if (Flight::request()->data->passwordnew1 == Flight::request()->data->passwordnew2) {
                     $currentUser->password = hash("sha256", Flight::request()->data->passwordnew1);
                 } else {
                     Flight::json(['success' => false, 'exception' => 'New passwords are not the same']);
                 }
             } else {
                 Flight::json(['success' => false, 'exception' => 'Old password is not correct ']);
             }
         }
     }
     $result = $currentUser->update();
     if ($result != false) {
         $_SESSION['user'] = Flight::users()->getUserWithId(Flight::get('currentUser')->id);
         Flight::json(['success' => true]);
     } else {
         Flight::json(['sucess' => false, 'exception' => 'An error']);
     }
 }
开发者ID:happyoniens,项目名称:Blog,代码行数:36,代码来源:userController.php

示例3: deleteAbsence

 public function deleteAbsence($id)
 {
     Flight::auth()->check();
     $absence = Flight::absence()->getAbsenceWithId($id);
     $absence->delete();
     Flight::redirect(Flight::request()->referrer);
 }
开发者ID:happyoniens,项目名称:Club,代码行数:7,代码来源:absenceController.php

示例4: query

function query($type)
{
    if (!is_null($type)) {
        //get parameter data
        $parameters = Flight::request()->query->getData();
        $cacheKey = $type . json_encode($parameters);
        if (apc_exists($cacheKey)) {
            echo apc_fetch($cacheKey);
        } else {
            $url = 'http://localhost:8080/sparql';
            $query_string = file_get_contents('queries/' . $type . '.txt');
            foreach ($parameters as $key => $value) {
                $query_string = str_replace('{' . $key . '}', $value, $query_string);
            }
            //open connection
            $ch = curl_init();
            //set the url, number of POST vars, POST data
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/sparql-query"));
            curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            //execute post
            $result = curl_exec($ch);
            //close connection
            curl_close($ch);
            apc_store($cacheKey, $result);
            echo $result;
        }
    }
}
开发者ID:eugenesiow,项目名称:ldanalytics-PiSmartHome,代码行数:30,代码来源:query.php

示例5: random

 public static function random()
 {
     $request = Flight::request();
     if (!empty($_SESSION['user_id'])) {
         $movies_viewed = $_SESSION['movies_viewed'];
         $dbname = 'predictionio_appdata';
         $mdb = Flight::mdb();
         $db = $mdb->{$dbname};
         $skip = mt_rand(1, 2000);
         $items = $db->items;
         $cursor = $items->find(array('itypes' => '1'))->skip($skip)->limit(1);
         $data = array_values(iterator_to_array($cursor));
         $movie = $data[0];
         if (!empty($request->data['movie_id'])) {
             $params = $request->data;
             $client = Flight::prediction_client();
             $user_id = $_SESSION['user_id'];
             $movie_id = substr($params['movie_id'], strpos($params['movie_id'], '_') + 1);
             $action = $params['action'];
             $client->identify($user_id);
             $user_action = $client->getCommand('record_action_on_item', array('pio_action' => $action, 'pio_iid' => $movie_id));
             $client->execute($user_action);
             $movies_viewed += 1;
             if ($movies_viewed == 20) {
                 $movie['has_recommended'] = true;
             }
             $_SESSION['movies_viewed'] = $movies_viewed;
         }
         Flight::json($movie);
     }
 }
开发者ID:ChenOhayon,项目名称:sitepoint_codes,代码行数:31,代码来源:home.php

示例6: access

 /**
  * Login POST verification (authentication)
  */
 public function access()
 {
     $pass = F::request()->data->password;
     # captcha
     if (!empty(F::get('config')['recaptcha']['public'])) {
         $captcha = F::request()->data['g-recaptcha-response'];
         if (!Verif::okCaptcha($captcha)) {
             $_SESSION['flashbag'] = '<div class="alert alert-danger">Wrong security captcha.</div>';
             $this->index();
             exit;
         }
     }
     # password
     if (Verif::okPassword($pass)) {
         $_SESSION['admin'] = 1;
         $_SESSION['flashbag'] = '
         <div class="alert alert-success alert-dismissible">
             <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
             You are now logged in.
         </div>';
         F::redirect('/');
     } else {
         $_SESSION['flashbag'] = '<div class="alert alert-danger">Wrong password.</div>';
     }
     $this->index();
 }
开发者ID:ray0be,项目名称:fastdoc,代码行数:29,代码来源:Login.php

示例7: handle_auth

function handle_auth()
{
    $request = Flight::request();
    //incoming=
    //outgoing=
    $stage = $request->query->stage;
    $ip = $request->query->ip;
    $mac = $request->query->mac;
    $token = $request->query->token;
    if (empty($stage) || empty($ip) || empty($mac) || empty($token)) {
        //Flight::Error('Required parameters empty!');
        write_auth_response(AUTH_ERROR);
    }
    // Do some housekeeping
    clear_old_tokens();
    // Even on STAGE_COUNTER, check token
    //if ($stage == STAGE_COUNTER) {
    //    return;
    //}
    if (is_token_valid($token)) {
        write_auth_response(AUTH_ALLOWED);
        return;
    }
    write_auth_response(AUTH_DENIED);
}
开发者ID:monat78,项目名称:fbwlan,代码行数:25,代码来源:gw_handlers.php

示例8: getBasePath

 /**
  * getBasePath
  *
  * @return string
  */
 function getBasePath()
 {
     if (strlen(Flight::request()->base) == 1) {
         return getWebsiteUrl() . '/';
     }
     return getWebsiteUrl() . Flight::request()->base . '/';
 }
开发者ID:j0an,项目名称:AcaSeDona,代码行数:12,代码来源:helpers.php

示例9: snippet

 static function snippet()
 {
     $data = Flight::request()->data;
     $mode = $data["mode"];
     if ($mode === "get") {
         $sql = "SELECT * FROM snippets WHERE LOWER(identifier) LIKE LOWER(?)";
         $sth = Flight::db()->prepare($sql);
         $sth->bindParam(1, $data["identifier"]);
         $sth->execute();
         $res = $sth->fetchAll(PDO::FETCH_ASSOC);
         if (count($res) == 0) {
             Flight::error();
         }
         echo Flight::json($res[0]);
     } elseif ($mode === "exists") {
         $sql = "SELECT * FROM snippets WHERE LOWER(identifier) LIKE LOWER(?)";
         $sth = Flight::db()->prepare($sql);
         $sth->bindParam(1, $data["identifier"]);
         $sth->execute();
         $res = $sth->fetchAll(PDO::FETCH_ASSOC);
         if (count($res) !== 0) {
             Flight::error();
         } else {
             echo "";
         }
     } elseif ($mode === "new") {
         $sql = "SELECT * FROM snippets WHERE LOWER(identifier) LIKE LOWER(?)";
         $sth = Flight::db()->prepare($sql);
         $sth->bindParam(1, $data["identifier"]);
         $sth->execute();
         $res = $sth->fetchAll();
         if (count($res) !== 0) {
             Flight::error();
         }
         $jwt = JWTHelper::authenticate(apache_request_headers());
         $sql = "INSERT INTO snippets(identifier,name,author,version,code) VALUES(?,?,?,?,?)";
         $sth = Flight::db()->prepare($sql);
         $sth->bindParam(1, $data["identifier"]);
         $sth->bindParam(2, $data["name"]);
         $sth->bindParam(3, $jwt->data->userName);
         $sth->bindParam(4, $data["version"]);
         $sth->bindParam(5, $data["code"]);
         $sth->execute();
     } elseif ($mode === "delete") {
         $sql = "SELECT * FROM snippets WHERE LOWER(identfier) LIKE LOWER(?)";
         $sth = Flight::db()->prepare($sql);
         $sth->bindParam(1, $data["identifier"]);
         $sth->execute();
         $res = $sth->fetchAll();
         if (count($res) !== 1) {
             Flight::error();
         }
         $jwt = JWTHelper::authenticate(apache_request_headers());
         $sql = "DELETE FROM snippets WHERE LOWER(identifier) LIKE LOWER(?)";
         $sth = Flight::db()->prepare($sql);
         $sth->bindParam(1, $data["identifier"]);
         $sth->execute();
     }
 }
开发者ID:TheFreakLord,项目名称:Backspace,代码行数:59,代码来源:handler.php

示例10: createPost

 /**
  * Create a post
  */
 public static function createPost()
 {
     if (!Flight::has('currentUser')) {
         Flight::redirect('/');
     }
     $post = new post(['user' => Flight::get('currentUser')->id, 'title' => Flight::request()->data->title, 'content' => Flight::request()->data->content]);
     $post->store();
 }
开发者ID:happyoniens,项目名称:Blog,代码行数:11,代码来源:postController.php

示例11: act

 static function act($client_name, $api_name, $api_version, $request_json)
 {
     try {
         require_once MODELS_DIR . '/client.php';
         require_once MODELS_DIR . '/exceptioner.php';
         $client = new Client($client_name);
         $api_name_low_case = strtolower($api_name);
         $method_name_low_case = strtolower(Flight::request()->method);
         //cek adanya user
         Exceptioner::thrower(!$client->getClientExistenceBool(), "{$client_name} is not registered");
         //Cek adanya API
         Exceptioner::thrower(!file_exists(APIS_DIR . "/{$api_name_low_case}"), "{$api_name} API not available");
         //Cek adanya API buatnya
         Exceptioner::thrower(!$client->getClientAPIAvailibilityBool($api_name_low_case), "{$api_name} API is exist but not available for {$client_name} client");
         //Cek adanya versi api
         Exceptioner::thrower(!file_exists(APIS_DIR . "/{$api_name_low_case}/{$api_version}"), "{$api_version} of {$api_name} API not available");
         // Cek REST method
         Exceptioner::thrower(!file_exists(APIS_DIR . "/{$api_name_low_case}/{$api_version}/controllers/{$method_name_low_case}.php"), Flight::request()->method . " REST Method in {$api_version} of {$api_name} API not available");
         //Include
         require_once APIS_DIR . "/{$api_name_low_case}/{$api_version}/includes.php";
         //decrypt request, ubah request jadi array
         $request_array = DECRYPT_REQUEST ? $client->requestDecrypt($request_json) : json_decode(base64_decode(urldecode($request_json)), TRUE);
         $object_method = $request_array['method'];
         $request_params = $request_array['parameters'];
         //buat object
         $controller_name = $method_name_low_case . "Controller";
         $object = new $controller_name($request_params);
         //Check adanya object_method
         Exceptioner::thrower(!$object_method, "Method in request is NULL, or Decrypting Failed");
         //Check adanya method
         Exceptioner::thrower(!method_exists($object, "{$object_method}"), "{$object_method} object method in {$api_name} API {$api_version} not available");
         //Buat result, lihat toggle enkripsi
         ENCRYPT_RESPONSE ? $result['encrypted_data'] = $client->respondEncrypt($object->{$object_method}()) : ($result['decrypted_data'] = $object->{$object_method}());
         $result['success'] = true;
     } catch (Exception $e) {
         //catch any exceptions and report the problem
         $result = array();
         $result['errormsg'] = $e->getMessage();
         $result['success'] = false;
     }
     // Return Type Based o
     if (DEBUG_MODE) {
         echo "<pre>";
         echo "<br>DEBUG_MODE : " . DEBUG_MODE . "<br>";
         echo "<br>METHOD : " . Flight::request()->method . "<br>";
         echo "<br>ENCRYPT_RESPONSE : " . ENCRYPT_RESPONSE . "<br>";
         echo "<br>DECRYPT_REQUEST : " . DECRYPT_REQUEST . "<br>";
         echo '<br>$request_array : ';
         print_r($request_array);
         echo '<br>$result : ';
         print_r($result);
         echo "</pre>";
     } else {
         echo json_encode($result);
     }
 }
开发者ID:Majeedr,项目名称:PHP-REST-starter,代码行数:56,代码来源:rest.php

示例12: initByCookie

 public function initByCookie()
 {
     $hash = Flight::request()->cookies[Auth::COOKIE_INDETIFICATION];
     if ($hash) {
         $User = User::find_by_auth_hash($hash);
         if ($User instanceof User) {
             $this->authorize($User);
         }
     }
 }
开发者ID:smilexx,项目名称:counter,代码行数:10,代码来源:Auth.php

示例13: getProducts

 public function getProducts()
 {
     # code...
     $pid = new getproduct();
     $post = json_decode(Flight::request()->getBody());
     DuoWorldCommon::mapToObject($post, $pid);
     $client = ObjectStoreClient::WithNamespace(DuoWorldCommon::GetHost(), "Products", "123");
     $respond = $client->get()->byKey($post->productId);
     echo json_encode($respond);
 }
开发者ID:pamidu,项目名称:LedgerService,代码行数:10,代码来源:product.php

示例14: uploadMedia

 private function uploadMedia($namespace, $class, $id)
 {
     $filepath = STORAGE_PATH . "/" . $namespace . "/" . $class;
     if (file_exists($filepath) == false) {
         echo json_encode(STORAGE_PATH);
         mkdir(STORAGE_PATH . "/" . $namespace);
         mkdir(STORAGE_PATH . "/" . $namespace . "/" . $class);
     }
     echo json_encode(file_put_contents($filepath . "/" . "{$id}.jpg", Flight::request()->getBody()));
 }
开发者ID:pamidu,项目名称:DuoWorldMediaservice-,代码行数:10,代码来源:mediaservice.php

示例15: real_remote_addr

 function real_remote_addr()
 {
     $ip = Flight::request()->ip;
     $proxy = Flight::request()->proxy_ip;
     if ('' != $proxy && Flight::get('proxies')->match($ip)) {
         return $proxy;
     } else {
         return $ip;
     }
 }
开发者ID:takashiki,项目名称:ourls,代码行数:10,代码来源:helpers.php


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