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


PHP Scalr::getAllHeaders方法代码示例

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


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

示例1: explode

    $envId = (int) $_SERVER['HTTP_X_SCALR_ENV_ID'];
    $pathChunks = explode('/', $path);
    $version = array_shift($pathChunks);
    $path = '/' . $path;
    $user = Scalr_Account_User::init();
    $user->loadByApiAccessKey($keyId);
    if (!$user->getSetting(Scalr_Account_User::SETTING_API_ENABLED)) {
        throw new Exception("API disabled for this account");
    }
    //Check IP whitelist
    $postData = isset($_POST['rawPostData']) ? $_POST['rawPostData'] : '';
    $secretKey = $user->getSetting(Scalr_Account_User::SETTING_API_SECRET_KEY);
    $stringToSign = "{$path}:{$keyId}:{$envId}:{$postData}:{$secretKey}";
    $validToken = CryptoTool::hash($stringToSign);
    if ($validToken != $token) {
        throw new Exception("Invalid authentification token");
    }
    // prepate input data
    $postDataConvert = array();
    foreach (json_decode($postData, true) as $key => $value) {
        $postDataConvert[str_replace('.', '_', $key)] = $value;
    }
    $request = Scalr_UI_Request::initializeInstance(Scalr_UI_Request::REQUEST_TYPE_API, Scalr::getAllHeaders(), $_SERVER, $postDataConvert, $_FILES, $user->id, $envId);
    $request->requestApiVersion = intval(trim($version, 'v'));
    SettingEntity::increase('internalapi.' . join('.', $pathChunks));
    Scalr_Api_Controller::handleRequest($pathChunks);
    Scalr_UI_Response::getInstance()->sendResponse();
} catch (Exception $e) {
    Scalr_UI_Response::getInstance()->failure($e->getMessage());
    Scalr_UI_Response::getInstance()->sendResponse();
}
开发者ID:mheydt,项目名称:scalr,代码行数:31,代码来源:api.php

示例2: microtime

    \Scalr::logException($e);
    Scalr_UI_Response::getInstance()->data(array('errorDB' => true));
    Scalr_UI_Response::getInstance()->debugException($e);
    Scalr_UI_Response::getInstance()->failure($e instanceof \Scalr\Exception\MysqlConnectionException ? 'Database connection issue' : 'Database error');
    Scalr_UI_Response::getInstance()->sendResponse();
};
try {
    $startTime = microtime(true);
    require __DIR__ . '/src/prepend.inc.php';
    $prependTime = microtime(true);
    // public controller for link like /public/*; don't check CSRF
    $publicController = !strncmp('public', $path, strlen('public'));
    $session = Scalr_Session::getInstance();
    $time1 = microtime(true);
    try {
        $request = Scalr_UI_Request::initializeInstance(Scalr_UI_Request::REQUEST_TYPE_UI, Scalr::getAllHeaders(), $_SERVER, $_REQUEST, $_FILES, $session->getUserId(), null);
    } catch (Exception $e) {
        if ($path == 'guest/logout') {
            // hack
            Scalr_Session::destroy();
            Scalr_UI_Response::getInstance()->setRedirect('/');
            Scalr_UI_Response::getInstance()->sendResponse();
            exit;
        }
        $message = $e->getMessage();
        if ($e->getCode() != 1) {
            $message = htmlspecialchars($message) . ' <a href="/guest/logout">Click here to login as another user</a>';
            Scalr_UI_Response::getInstance()->debugException($e);
            Scalr_UI_Response::getInstance()->failure($message, true);
            throw new Exception();
        } else {
开发者ID:mheydt,项目名称:scalr,代码行数:31,代码来源:ui.php

示例3: trim

//NOTE: Apache mod_rewrite sets REDIRECT_URL instead of REQUEST_URI environment variable, we need to get final overridden URI
$path = trim(str_replace("?{$_SERVER['QUERY_STRING']}", "", isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['REQUEST_URI']), '/');
$logMysqlExcepton = function ($e) {
    \Scalr::logException($e);
    Scalr_UI_Response::getInstance()->data(array('errorDB' => true));
    Scalr_UI_Response::getInstance()->debugException($e);
    Scalr_UI_Response::getInstance()->failure($e instanceof \Scalr\Exception\MysqlConnectionException ? 'Database connection issue' : 'Database error');
    Scalr_UI_Response::getInstance()->sendResponse();
};
try {
    $startTime = microtime(true);
    require __DIR__ . '/src/prepend.inc.php';
    $prependTime = microtime(true);
    // public controller for link like /public/*; don't check CSRF
    $publicController = !strncmp('public', $path, strlen('public'));
    $headers = Scalr::getAllHeaders();
    $session = Scalr_Session::getInstance(isset($headers['Scalr-Autoload-Request']));
    $time1 = microtime(true);
    try {
        $request = Scalr_UI_Request::initializeInstance(Scalr_UI_Request::REQUEST_TYPE_UI, $headers, $_SERVER, $_REQUEST, $_FILES, $session->getUserId(), null);
    } catch (Exception $e) {
        if ($path == 'guest/logout') {
            // hack
            Scalr_Session::destroy();
            Scalr_UI_Response::getInstance()->setRedirect('/');
            Scalr_UI_Response::getInstance()->sendResponse();
            exit;
        }
        $message = $e->getMessage();
        if ($e->getCode() != 1) {
            $message = htmlspecialchars($message) . ' <a href="/guest/logout">Click here to login as another user</a>';
开发者ID:scalr,项目名称:scalr,代码行数:31,代码来源:ui.php


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