public function makeRequest(Request $request) { static::$request = $request; return static::$response; }
/** * Find a single element by its ID * * @param mixed $id * @return Daursu\Xero\BaseModel */ public static function find($id) { $object = new static(); $response = $object->request('GET', sprintf('%s/%s', $object->getUrl(), $id)); return $response ? $object : false; }
/** * Disconnect current \Hybrid\Request connection * * @static * @access public */ public static function disconnect() { static::$request = null; }
/** * Builds the required static objects for later use * * @return void * @author Dan Cox */ public function __construct() { // Build Aura's Router $factory = new RouterFactory(); static::$router = $factory->newInstance(); // Build the request object static::$request = Request::createFromGlobals(); }
/** * Runner constructor. */ public function __construct() { static::$request = Request::createFromGlobals(); if (!static::$request->hasPreviousSession()) { $session = new Session(); $session->start(); static::$request->setSession($session); } }
/** * Retrieve a object of JSON-RPC request. * * @return object The request object. */ public static function getRequest() { if (static::$request == null) { $http = Http\Request::getInstance(); $body = $http->getBody(); static::$request = Request::fromJson($body); } return static::$request; }
static function get_request() { if (!isset(static::$request)) { $version = @$_POST['version']; // If API version changes, could return // different EnvayaSMS_Request instance // to support multiple phone versions static::$request = new EnvayaSMS_Request(); } return static::$request; }
public static function get() { if (isset(static::$request)) { return static::$request; } if (isset($_SERVER['REQUEST_METHOD'])) { static::$request = new HTTPRequest(); } else { throw new RequestTypeNotImplementedException(); } return static::$request; }
public function __construct() { $dir = __DIR__ . '/db/'; $file = 'oauth.sqlite'; if (!file_exists($dir . $file)) { include_once $dir . 'rebuild_db.php'; } static::$storage = new OAuth2_Storage_Pdo(array('dsn' => 'sqlite:' . $dir . $file)); static::$request = OAuth2_Request::createFromGlobals(); static::$server = new OAuth2_Server(static::$storage); static::$server->addGrantType(new OAuth2_GrantType_AuthorizationCode(static::$storage)); }
/** * Builds the routes then processes the request to the controller and method. * @param array $config The config array with the controller path and routes. */ public static function init(array $config) { static::$controller_path = $config['controller_path']; foreach ($config['routes'] as $route => $args) { if (!is_array($args)) { $args = array($args, 'params' => array()); } static::$routes[$route] = $args; } static::$request = static::get_request(); static::route(); }
public function __construct() { $dir = __DIR__ . '/db/'; $file = 'oauth.sqlite'; if (!file_exists($dir . $file)) { include_once $dir . 'rebuild_db.php'; } static::$storage = new Pdo(array('dsn' => 'sqlite:' . $dir . $file)); // create array of supported grant types $grantTypes = array('authorization_code' => new AuthorizationCode(static::$storage), 'user_credentials' => new UserCredentials(static::$storage)); static::$request = Request::createFromGlobals(); static::$server = new OAuth2Server(static::$storage, array('enforce_state' => true, 'allow_implicit' => true), $grantTypes); }
public function __construct() { static::$instance = $this; static::$request = $_REQUEST; static::$get = $_GET; static::$post = $_POST; static::$server = $_SERVER; static::$headers = static::getAllHeaders(); static::$requestUri = static::prepareRequestUri(); static::$baseUrl = static::prepareBaseUrl(); static::$basePath = static::prepareBasePath(); static::$pathInfo = static::preparePathInfo(); static::$method = static::$server['REQUEST_METHOD']; }
public function __construct($config) { static::$config = $config; static::$request = $this->request(); static::$cache = new Cache(); $this->connection = static::connect(); if (isset($_REQUEST['upgrade'])) { $this->checkDBVersion(); } if (isset($_REQUEST['cssbump'])) { $this->setOption('cssv', time()); } if (rand(0, 100) <= 10) { Auth::cleanSessions(); } // 10% chance; should be moved to a cron job }
public function getAll() { static::$request = array_merge(['METHOD' => $_SERVER['REQUEST_METHOD']], ["SERVER" => $_SERVER ? $_SERVER : []], ["COOKIE" => $_COOKIE ? $_COOKIE : []], ['SESSION'] ? $_SESSION : []); try { switch ($_SERVER['REQUEST_METHOD']) { case 'GET': array_push(static::$request, ["GET" => $_GET ? $_GET : []]); break; case 'POST': !empty($_GET) ?: array_push(static::$request, ["GET" => $_GET ? $_GET : []]); !empty($_POST) ?: array_push(static::$request, ["POST" => $_POST ? $_POST : []]); break; } } catch (\Exception $e) { //дописать логер } return static::$request; }
public function run() { $this->beforeRun(); static::$response = new Response(); static::$response->init(); static::$request = new Request(); try { $this->initComponents(); $this->router(); } catch (HttpException $exception) { if (ob_get_level() > 0) { ob_end_clean(); } static::$response->setStatusCode($exception->statusCode); ob_start(); require Url::to($this->getErrorView($exception->statusCode)); $content = ob_get_contents(); ob_end_clean(); static::$response->data = $content; } catch (GboxException $exception) { if (ob_get_level() > 0) { ob_end_clean(); } static::$response->setStatusCode(500); ob_start(); require Url::to($this->getErrorView(500)); $content = ob_get_contents(); ob_end_clean(); static::$response->data = $content; } catch (Exception $exception) { if (ob_get_level() > 0) { ob_end_clean(); } static::$response->setStatusCode(500); ob_start(); require Url::to($this->getErrorView(500)); $content = ob_get_contents(); ob_end_clean(); static::$response->data = $content; } static::$response->send(); $this->afterRun(); }
protected static function initialize() { if (static::$initialized) { return; } static::$initialized = true; if (!static::$enabled) { error_reporting(0); return; } error_reporting(-1); static::$request = array('log' => array(), 'queries' => array(), 'api_calls' => array(), 'session' => array(), 'cache' => array()); Session::start(); $_SESSION[static::$sessionKey][] =& static::$request; while (count($_SESSION[static::$sessionKey]) > static::$history) { array_shift($_SESSION[static::$sessionKey]); } static::set('start', microtime(true)); static::set('user', get_current_user()); register_shutdown_function('Debugger::end', 'abort'); }
public static function run($config) { if (isset($config['db'])) { if (isset($config['db']['username'])) { static::$db = new DB($config['db']['dsn'], $config['db']['username'], $config['db']['password']); } else { static::$db = new DB($config['db']['dsn']); } } static::$assets = new Assets(isset($config['assets']) ? $config['assets'] : []); static::$user = new User(); static::$url = new Url(); static::$request = new Request(); static::$session = new Session(); static::$helper = new Helper(); static::$params = $config['params']; $url = str_replace(static::$url->path(), '', $_SERVER['REQUEST_URI']); $options = isset($config['route']) ? $config['route'] : []; static::$route = new Route($url, $options); static::$route->run(); }
protected static function applyRoutes() { if (!static::$initialized) { static::initialize(); } foreach (static::$routes as $destinationPath => $sourcePath) { if (rtrim(static::$request, '/') == rtrim(static::$baseUrl . $sourcePath, '/')) { static::$request = static::$baseUrl . $destinationPath; break; } } }
public static function tearDown() { static::$request = NULL; }
public function __construct() { // Because some hosts are complete // idiotic pieces of shit, let's // strip slashes from input. if (get_magic_quotes_gpc()) { $php_is_the_worst_language_ever_because_of_this = function (&$value) { $value = stripslashes($value); }; array_walk_recursive($_GET, $php_is_the_worst_language_ever_because_of_this); array_walk_recursive($_POST, $php_is_the_worst_language_ever_because_of_this); array_walk_recursive($_COOKIE, $php_is_the_worst_language_ever_because_of_this); array_walk_recursive($_REQUEST, $php_is_the_worst_language_ever_because_of_this); } // Set query string static::$query = (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null); // Set request scheme static::$scheme = static::isSecure() ? 'https' : 'http'; // Set host static::$host = strtolower(preg_replace('/:\d+$/', '', trim($_SERVER['SERVER_NAME']))); // Set base url static::$base = static::baseUrl(); // Set the request path static::$request_uri = static::requestPath(); // Set relative uri without query string $uri = explode('?', str_replace(static::$base, '', static::$request_uri)); static::$uri = $uri[0]; // Request segments static::$segments = explode('/', trim(static::$uri, '/')); // Set the request method static::$method = strtolower($_SERVER['REQUEST_METHOD']); // Requested with static::$requested_with = @$_SERVER['HTTP_X_REQUESTED_WITH']; // _REQUEST static::$request = $_REQUEST; // _POST static::$post = $_POST; }
/** * Set Request * * @param ServerRequestInterface $req */ public static function setRequest(ServerRequestInterface $req) { static::$request = $req; }
/** Parses the GET parameter. @return null. **/ public static function parsArgs() { if (static::$parsed) { return; } static::$parsed = true; $shortopts = ""; $longopts = array("host:", "service:", "command:", "perf_label:", "request:"); $args = getopt($shortopts, $longopts); $input = file_get_contents('php://input'); if (!empty($input)) { // @codeCoverageIgnore static::$request = json_decode($input, true); // @codeCoverageIgnore } elseif (isset($args['request']) && !empty($args['request'])) { // @codeCoverageIgnore static::$request = json_decode($args['request'], true); // @codeCoverageIgnore } // @codeCoverageIgnore if (!static::$request) { if (isset($_GET['host']) && !empty($_GET['host'])) { define("HOST", $_GET["host"]); } elseif (isset($args['host']) && !empty($args['host'])) { define("HOST", $args["host"]); // @codeCoverageIgnore } else { // @codeCoverageIgnore \histou\Basic::returnData('Hostname is missing!', 1, 'Hostname is missing!'); } if (isset($_GET['service']) && !empty($_GET['service'])) { define("SERVICE", $_GET["service"]); } elseif (isset($args['service']) && !empty($args['service'])) { define("SERVICE", $args["service"]); // @codeCoverageIgnore } else { // @codeCoverageIgnore define("SERVICE", HOSTCHECK_ALIAS); } if (isset($_GET['command']) && !empty($_GET['command'])) { define("COMMAND", $_GET["command"]); } elseif (isset($args['command']) && !empty($args['command'])) { define("COMMAND", $args["command"]); // @codeCoverageIgnore } // @codeCoverageIgnore if (isset($_GET['perf_label']) && !empty($_GET['perf_label'])) { global $PERF_LABEL; $PERF_LABEL = $_GET["perf_label"]; } elseif (isset($args['perf_label']) && !empty($args['perf_label'])) { global $PERF_LABEL; $PERF_LABEL = $args["perf_label"]; // @codeCoverageIgnore } // @codeCoverageIgnore if (isset($PERF_LABEL) && !is_array($PERF_LABEL)) { $PERF_LABEL = array($PERF_LABEL); } } if (isset($_GET['disablePanelTitel'])) { static::$disablePanelTitel = true; } if (isset($_GET['debug'])) { \histou\Debug::enable(); } if (isset($_GET['height']) && !empty($_GET['height'])) { static::$height = $_GET["height"]; } if (isset($_GET['legend']) && !empty($_GET['legend']) && $_GET["legend"] == "false") { define("SHOW_LEGEND", false); } else { define("SHOW_LEGEND", true); } if (isset($_GET['annotations']) && !empty($_GET['annotations']) && $_GET["annotations"] == "true") { define("SHOW_ANNOTATION", true); } else { define("SHOW_ANNOTATION", false); } if (isset($_GET['specificTemplate']) && !empty($_GET['specificTemplate'])) { static::$specificTemplate = $_GET["specificTemplate"]; } if (static::$specificTemplate != "" && isset($_GET['disablePerfdataLookup'])) { static::$disablePerfdataLookup = true; } }
/** * Find a model by its primary key or throw an exception * * @param string $id * @param array $params * @return mixed|static * * @throws \Torann\RemoteModel\NotFoundException */ public static function findOrFail($id, array $params = []) { $instance = new static([], static::getParentID()); // Make request if (!is_null($result = $instance->request($instance->getEndpoint(), 'find', [$id, $params]))) { return $result; } // Not found throw new NotFoundException(); }
/** * Nullify the static request, generally for unit testing. */ public static function destroy() { static::$request = null; }
/** * @param $request * * @return $this */ public function setRequest($request) { static::$request = $request; return $this; }
/** * @method __construct is constructor */ function __construct() { static::$request = array_merge(["GET" => $_GET], ["POST" => $_POST], ["SERVER" => $_SERVER]); }