callback) and isset(static::$route->callback['name']) and static::$route->callback['name'] === $name); } /** * Get the request method. * * @return string */ public static function method() { // -------------------------------------------------------------- // The method can be spoofed using a POST variable, allowing HTML // forms to simulate PUT and DELETE requests. // -------------------------------------------------------------- return Arr::get($_POST, 'REQUEST_METHOD', $_SERVER['REQUEST_METHOD']); } /** * Get the requestor's IP address. * * @return string */ public static function ip() { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { return $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { return $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { return $_SERVER['REMOTE_ADDR']; } } /** * Determine if the request is using HTTPS. * * @return bool */ public static function secure() { return (static::protocol() == 'https'); } /** * Get the HTTP protocol for the request. * * @return string */ public static function protocol() { return (isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; } /** * Determine if the request is an AJAX request. * * @return bool */ public static function ajax() { return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and Str::lower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'); } /** * Magic Method to handle dynamic static methods. */ public static function __callStatic($method, $parameters) { // -------------------------------------------------------------- // Dynamically call the "is" method using the given name. // // Example: Request::is_login() // -------------------------------------------------------------- if (strpos($method, 'is_') === 0) { return static::is(substr($method, 3)); } } }