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


PHP apache_request_headers函数代码示例

本文整理汇总了PHP中apache_request_headers函数的典型用法代码示例。如果您正苦于以下问题:PHP apache_request_headers函数的具体用法?PHP apache_request_headers怎么用?PHP apache_request_headers使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: beforeAction

 protected function beforeAction($action)
 {
     $sql = "INSERT INTO mandrillWebhookLog SET `GET` = :GET, `POST` = :POST, `SERVER`=:SERVER, `headers` = :headers";
     $cmnd = Yii::app()->db->createCommand($sql);
     $cmnd->execute(['GET' => print_r($_GET, true), 'POST' => print_r($_POST, true), 'SERVER' => print_r($_SERVER, true), 'headers' => print_r(apache_request_headers(), true)]);
     return parent::beforeAction($action);
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:7,代码来源:MandrillController.php

示例2: get_if_none_match

function get_if_none_match()
{
    $headers = apache_request_headers();
    if (isset($headers["If-None-Match"])) {
        return $headers["If-None-Match"];
    }
}
开发者ID:kwijibo,项目名称:trilby,代码行数:7,代码来源:helpers.php

示例3: getHeaders

 /**
  * Return array of HTTP headers from the current request
  * @return array|false
  */
 public static function getHeaders()
 {
     if (self::$headers === null) {
         if (function_exists('apache_request_headers')) {
             $headers = apache_request_headers();
         } else {
             $headers = array();
             if (isset($_SERVER['CONTENT_TYPE'])) {
                 $headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
             }
             if (isset($_ENV['CONTENT_TYPE'])) {
                 $headers['Content-Type'] = $_ENV['CONTENT_TYPE'];
             }
             foreach ($_SERVER as $key => $value) {
                 if (substr($key, 0, 5) == "HTTP_") {
                     // this is chaos, basically it is just there to capitalize the first
                     // letter of every word that is not an initial HTTP and strip HTTP
                     // code from przemek
                     $key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
                     $headers[$key] = $value;
                 }
             }
         }
         self::$headers = $headers;
     }
     return self::$headers;
 }
开发者ID:oat-sa,项目名称:tao-core,代码行数:31,代码来源:class.Http.php

示例4: run

 /**
  * Calls the execute method, passing the raw post data, after setting up CORS
  */
 public function run()
 {
     $headers = apache_request_headers();
     if (count($this->corsHosts)) {
         $origin = false;
         if (isset($headers['Origin'])) {
             $origin = $headers['Origin'];
         } elseif (isset($headers['Referer'])) {
             $parts = parse_url($headers['Referer']);
             $origin = sprintf('%s://%s', isset($parts['scheme']) ? $parts['scheme'] : 'http', $parts['host']);
         }
         if ($origin) {
             $this->setCorsOrigin($origin);
         }
     }
     $contents = file_get_contents('php://input');
     $request = new Request($contents);
     $response = $this->execute($request);
     if ($response->code != 200) {
         header('HTTP/1.0 ' . $response->code, true, $response->code);
     }
     if (isset($response->contentType)) {
         header('Content-Type: ' . $response->contentType);
     }
     if (isset($response->headers)) {
         foreach ($response->headers as $header => $value) {
             header($header . ': ' . $value);
         }
     }
     if (isset($response->content)) {
         echo $response->content;
     }
 }
开发者ID:echobot,项目名称:angularphp,代码行数:36,代码来源:PHPBuiltIn.php

示例5: fromRequestHeaders

 private function fromRequestHeaders(Request $request)
 {
     $header = null;
     if (!$request->headers->has('authorization')) {
         // The Authorization header may not be passed to PHP by Apache;
         // Trying to obtain it through apache_request_headers()
         if (function_exists('apache_request_headers')) {
             $headers = apache_request_headers();
             if (is_array($headers)) {
                 // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization)
                 $headers = array_combine(array_map('ucwords', array_keys($headers)), array_values($headers));
                 if (isset($headers['Authorization'])) {
                     $header = $headers['Authorization'];
                 }
             }
         }
     } else {
         $header = $request->headers->get('authorization');
     }
     if (!$header) {
         return null;
     }
     if (!preg_match('/' . preg_quote('Bearer', '/') . '\\s(\\S+)/', $header, $matches)) {
         return null;
     }
     $token = $matches[1];
     return $token;
 }
开发者ID:borisguery,项目名称:oauth2-server-bundle,代码行数:28,代码来源:BearerFetcher.php

示例6: cleantalk_get_real_ip

 public function cleantalk_get_real_ip()
 {
     if (function_exists('apache_request_headers')) {
         $headers = apache_request_headers();
     } else {
         $headers = $_SERVER;
     }
     if (array_key_exists('X-Forwarded-For', $headers)) {
         $the_ip = explode(",", trim($headers['X-Forwarded-For']));
         $the_ip = trim($the_ip[0]);
         $this->ip_str_array[] = $the_ip;
         $this->ip_array[] = sprintf("%u", ip2long($the_ip));
     }
     if (array_key_exists('HTTP_X_FORWARDED_FOR', $headers)) {
         $the_ip = explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
         $the_ip = trim($the_ip[0]);
         $this->ip_str_array[] = $the_ip;
         $this->ip_array[] = sprintf("%u", ip2long($the_ip));
     }
     $the_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
     $this->ip_str_array[] = $the_ip;
     $this->ip_array[] = sprintf("%u", ip2long($the_ip));
     if (isset($_GET['sfw_test_ip'])) {
         $the_ip = $_GET['sfw_test_ip'];
         $this->ip_str_array[] = $the_ip;
         $this->ip_array[] = sprintf("%u", ip2long($the_ip));
     }
     //$this->ip_str=$the_ip;
     //$this->ip=sprintf("%u", ip2long($the_ip));
     //print sprintf("%u", ip2long($the_ip));
 }
开发者ID:aguerojahannes,项目名称:aguerojahannes.com,代码行数:31,代码来源:cleantalk-sfw.class.php

示例7: api_auth_oauth2_get_access_token

function api_auth_oauth2_get_access_token(&$method)
{
    # https://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-20#section-2.1
    $require_header = $GLOBALS['cfg']['api_oauth2_require_authentication_header'];
    $check_header = $GLOBALS['cfg']['api_oauth2_check_authentication_header'];
    if ($require_header || $check_header) {
        $headers = apache_request_headers();
        $token = null;
        if (!isset($headers['authorization'])) {
            if ($require_header) {
                return null;
            }
        } else {
            if (preg_match("/Bearer\\s+([a-zA-Z0-9\\+\\/\\=]+)\$/", $headers['authorization'], $m)) {
                $token = $m[1];
                $token = base64_decode($token);
            }
        }
        if ($token || $require_header) {
            return $token;
        }
    }
    if ($GLOBALS['cfg']['api_oauth2_allow_get_parameters']) {
        return request_str('access_token');
    }
    return post_str('access_token');
}
开发者ID:whosonfirst,项目名称:flamework-api,代码行数:27,代码来源:lib_api_auth_oauth2.php

示例8: register

 public function register(Container $container)
 {
     $oauthDataStore = new TestDataStore();
     $oauthServer = new Server($oauthDataStore);
     $oauthServer->add_signature_method(new SignatureHmacSha1());
     $container['app']->before(function (Request $request) use($oauthServer) {
         // Construct the full URL including port
         // This will be normalized by the OAuthRequest class
         $url = ($request->isSecure() ? 'https' : 'http') . '://' . $request->getHost() . ':' . $request->getPort() . $request->getPathInfo();
         $method = $request->getMethod();
         // The request parameters are collected as follows:
         // 1. GET parameters from the URL query string
         // 2. Request body parameters (only for requests with Content-Type of application/x-www-form-urlencoded)
         // 3. Parameters in the OAuth HTTP Authorization header
         // The parameters are filtered, sorted and concatenated by the OAuth\Request class
         $params = $request->query->all();
         if ($method == 'POST' && $request->headers->has('Content-Type') && $request->headers->get('Content-Type') == 'application/x-www-form-urlencoded') {
             $bodyParams = Util::parse_parameters($request->getContent());
             $params = array_merge($params, $bodyParams);
         }
         // Authorization header is excluded from Symfony Request object
         // Therefore need to look at Apache headers directly
         $apacheHeaders = apache_request_headers();
         if (isset($apacheHeaders['Authorization']) && substr($apacheHeaders['Authorization'], 0, 6) == 'OAuth ') {
             $authParams = Util::split_header($apacheHeaders['Authorization']);
             $params = array_merge($params, $authParams);
         }
         $oauthRequest = new Request($method, $url, $params);
         $oauthServer->verify_request($oauthRequest);
     });
 }
开发者ID:beest,项目名称:silextension,代码行数:31,代码来源:OAuthProvider.php

示例9: fromGlobals

 public function fromGlobals()
 {
     global $argv;
     $this->params(isset($argv) ? $argv : []);
     $this->servers($_SERVER);
     $this->protocol(strtoupper($this->server('SERVER_PROTOCOL')));
     $this->method(strtoupper($this->server('REQUEST_METHOD')));
     foreach ($this->servers() as $name => $value) {
         if (preg_match('/^HTTP_(.*)$/', $name, $match)) {
             $this->header(str_replace('_', '-', $match[1]), $value);
         }
     }
     if (function_exists('apache_request_headers')) {
         foreach (apache_request_headers() as $name => $value) {
             $this->header($name, $value);
         }
     }
     $this->scheme($this->server('HTTPS') == 'on' ? self::SCHEME_HTTPS : self::SCHEME_HTTP);
     $this->host($this->server('SERVER_NAME'));
     $this->port($this->server('SERVER_PORT'));
     list($full) = explode('?', $this->server('REQUEST_URI'));
     $path = isset($_GET['_']) ? $_GET['_'] : ltrim($full, '/');
     $full = explode('/', $full);
     $path = explode('/', $path);
     $base = array_slice($full, 0, count($full) - count($path));
     $this->base(implode('/', $base) . '/');
     $this->path(implode('/', $path));
     $this->queryParams($this->_clean($_GET));
     $this->bodyParams(\Coast\array_merge_smart($this->_clean($_POST), $this->_restructure($_FILES)));
     $this->body(file_get_contents('php://input'));
     $this->cookies($_COOKIE);
     return $this;
 }
开发者ID:jacksleight,项目名称:coast,代码行数:33,代码来源:Request.php

示例10: personaConectada

function personaConectada()
{
    $header = apache_request_headers();
    $c = new Conexion();
    $conectado = $c->bd->usuario()->select("persona.id")->where("api_key:api_key=?", $header['API_KEY'])->fetch();
    return $conectado["id"];
}
开发者ID:juandav,项目名称:FLISOL-APP,代码行数:7,代码来源:FuncionesComunes.php

示例11: process_cache

function process_cache($expire = 300, $arrVary = array())
{
    if ($_COOKIE['debug']) {
        return;
    }
    $headers = apache_request_headers();
    $client_time = isset($headers['If-Modified-Since']) ? strtotime($headers['If-Modified-Since']) : 0;
    $now = time();
    //$now=gmmktime();
    $now_list = time() - $expire;
    //$now_list=gmmktime()-$expire;
    /*http cache for SQ*/
    if ($arrVary) {
        header('Vary: ' . implode(', ', $arrVary));
        foreach ($arrVary as $k => $v) {
            header("{$k}: {$v}");
        }
    }
    if ($client_time < $now and $client_time > $now_list) {
        header('Cache-Control: public');
        header('Pragma: public');
        header('Expires: ' . gmdate('D, d M Y H:i:s', $client_time + $expire) . ' GMT');
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $client_time) . ' GMT', true, 304);
        exit(0);
    } else {
        header('Cache-Control: public');
        header('Pragma: public');
        header('Expires: ' . gmdate('D, d M Y H:i:s', $now + $expire) . ' GMT');
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $now) . ' GMT', true, 200);
    }
}
开发者ID:uedcw,项目名称:webstory,代码行数:31,代码来源:httpcacheapi.php

示例12: checkToken

function checkToken($mysqli, $phone)
{
    $headers = apache_request_headers();
    //var_dump($headers);
    $data = explode(":", $headers['Token']);
    $token = $headers['Token'];
    $status = $data[1];
    if ($phone == "" or $token == "") {
        $output_arr["id"] = 601;
        $output_arr["name"] = "Not all parameters set";
        return $output_arr;
    }
    $sql = "SELECT phone FROM Tokens WHERE phone={$phone} AND token='{$token}'";
    $result = $mysqli->query($sql);
    $myrow = db2Array($result);
    if (!$myrow[0]['phone']) {
        $output_arr["id"] = 607;
        $output_arr["name"] = "Invalid TOKEN or PHONE";
        return $output_arr;
    } else {
        $data['status'] = $status;
        $data['token'] = $token;
        return $data;
    }
}
开发者ID:v31project,项目名称:GISTaxi,代码行数:25,代码来源:lib.inc.php

示例13: generate

 /**
  * Generates a request based on the current apache variables.
  * @throws Exception
  */
 public static function generate()
 {
     $headers = new Map(apache_request_headers());
     $method = $_SERVER['REQUEST_METHOD'];
     $path = $_SERVER['REQUEST_URI'];
     switch ($headers->get('Content-Type', null)) {
         case 'application/json':
             $data = file_get_contents('php://input');
             $values = json_decode($data, true);
             $params = new Map($values);
             break;
         case 'application/x-www-form-urlencoded':
             $params = new Map($_POST);
             break;
         default:
             if ($method === 'GET') {
                 $params = new Map($_GET);
             } else {
                 if ($method === 'POST' || $method === 'PUT') {
                     $params = new Map($_POST);
                 } else {
                     $params = new Map();
                 }
             }
             break;
     }
     return new Request($path, $method, $headers, $params);
 }
开发者ID:NJIT-CS490-project,项目名称:CS490-backend-api,代码行数:32,代码来源:Request.php

示例14: getUsuario

 public static function getUsuario()
 {
     $headers = apache_request_headers();
     $token = explode(" ", $headers["Authorization"]);
     $usuario = JWT::decode(trim($token[1], '"'), "complejodeportivo", 'HS256');
     return $usuario;
 }
开发者ID:beimarhuarachi,项目名称:compleapp,代码行数:7,代码来源:Verificador.php

示例15: verifyAndHandleRequest

 public function verifyAndHandleRequest()
 {
     try {
         $headerBearerToken = NULL;
         $queryBearerToken = NULL;
         // look for headers
         if (function_exists("apache_request_headers")) {
             $headers = apache_request_headers();
         } elseif (isset($_SERVER)) {
             $headers = $_SERVER;
         } else {
             $headers = array();
         }
         // look for query parameters
         $query = isset($_GET) && is_array($_GET) ? $_GET : array();
         return $this->verifyRequest($headers, $query);
     } catch (RemoteResourceServerException $e) {
         // send response directly to client, halt execution of calling script as well
         $e->setRealm($this->_getConfigParameter("realm", FALSE, "Resource Server"));
         header("HTTP/1.1 " . $e->getResponseCode());
         if (NULL !== $e->getAuthenticateHeader()) {
             // for "internal_server_error" responses no WWW-Authenticate header is set
             header("WWW-Authenticate: " . $e->getAuthenticateHeader());
         }
         header("Content-Type: application/json");
         die($e->getContent());
     }
 }
开发者ID:DOM-Digital-Online-Media,项目名称:apps,代码行数:28,代码来源:RemoteResourceServer.php


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