Example #1
0
 /**
  * Auto-generated template name based on class name and called method
  * @return string
  * @throws \Exception
  */
 private function templateFromRoute()
 {
     $path = $this->f3->get('PATH');
     $routes = $this->f3->get('ROUTES');
     $requestType = $this->f3->get('VERB');
     $calledMethod = current($routes[$path])[$requestType][0];
     if (false == preg_match('/(?:.+\\\\)(?<controller>.+)Controller(?:->|::)(?<method>.+)/', $calledMethod, $match)) {
         return null;
     }
     $template = $match['controller'] . '/' . $match['method'] . '.xhtml';
     if (file_exists(__DIR__ . '/../Views/' . $template)) {
         return $template;
     } else {
         throw new \Exception(sprintf('Template: %s not found!', $template));
     }
 }
 public static function getAppForSelect($user)
 {
     $ins = new static();
     if ($user->isAdmin()) {
         return $ins->get(['key', 'name'])->toArray();
     }
     return $ins->ownBy($user)->get(['key', 'name'])->toArray();
 }
 function loadBannedWords()
 {
     if ($this->bannedWords) {
         return;
     }
     $bw = new static();
     $bannedWords = $bw->get();
     $this->bannedWords = array();
     foreach ($bannedWords as $word) {
         $this->bannedWords[] = $word->getWord();
     }
 }
Example #4
0
 /**
  * shortcut function
  *
  * @param string cachekey
  * @param callback
  * @return mixed
  */
 public static function invoke($cache_key, $callback = null, $namespace = '_global_')
 {
     $cache = new static($namespace);
     if ($cache->has($cache_key)) {
         return $cache->get($cache_key);
     }
     if (is_callable($callback)) {
         $value = $callback();
         $cache->set($cache_key, $value);
         return $value;
     }
     return null;
 }
Example #5
0
 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'];
 }
Example #6
0
 /**
  * Create a new Irto\OAuth2Proxy\Server instance with $config
  * 
  * @param array $config
  * 
  * @return Irto\OAuth2Proxy\Server
  */
 public static function create(array $config)
 {
     $server = new static();
     isset($config['verbose']) && $server->setVerbose($config['verbose']);
     $server->singleton('config', function ($server) use($config) {
         return new Collection($config);
     });
     $server->bind('Irto\\OAuth2Proxy\\Server', function ($server) {
         return $server;
     });
     // Create main loop React\EventLoop based
     $server->singleton('React\\EventLoop\\LoopInterface', function ($server) {
         return React\EventLoop\Factory::create();
     });
     // DNS resolve, used for create async requests
     $server->singleton('React\\Dns\\Resolver\\Resolver', function ($server) {
         $dnsResolverFactory = new React\Dns\Resolver\Factory();
         return $dnsResolverFactory->createCached('8.8.8.8', $server['React\\EventLoop\\LoopInterface']);
         //Google DNS
     });
     // HTTP Client
     $server->singleton('React\\HttpClient\\Client', function ($server) {
         $factory = new React\HttpClient\Factory();
         return $factory->create($server['React\\EventLoop\\LoopInterface'], $server['React\\Dns\\Resolver\\Resolver']);
     });
     // Request handler to React\Http
     $server->singleton('React\\Socket\\Server', function ($server) {
         $socket = new React\Socket\Server($server['React\\EventLoop\\LoopInterface']);
         $socket->listen($server->get('port'));
         return $socket;
     });
     // HTTP server for handle requests
     $server->singleton('React\\Http\\Server', function ($server) {
         return new React\Http\Server($server['React\\Socket\\Server']);
     });
     // HTTP server for handle requests
     $server->singleton('SessionHandlerInterface', function ($server) {
         return $server->make('Irto\\OAuth2Proxy\\Session\\AsyncRedisSessionHandler', ['lifetime' => array_get($server['config']->all(), 'session.lifetime')]);
     });
     $server->bind('Illuminate\\Session\\Store', 'Irto\\OAuth2Proxy\\Session\\Store');
     $server->boot();
     return $server;
 }
Example #7
0
 public static function ensure($reference, $type = null, $container = null)
 {
     if ($reference instanceof $type) {
         return $reference;
     } elseif (empty($reference)) {
         throw new \Exception('The required component is not specified.');
     }
     if (is_string($reference)) {
         $reference = new static($reference);
     }
     if ($reference instanceof self) {
         $component = $reference->get($container);
         if ($component instanceof $type || $type === null) {
             return $component;
         } else {
             throw new \Exception('"' . $reference->id . '" refers to a ' . get_class($component) . "\n                component. {$type} is expected.");
         }
     }
     $valueType = is_object($reference) ? get_class($reference) : gettype($reference);
     throw new \Exception("Invalid data type: {$valueType}. {$type} is expected.");
 }
Example #8
0
 /**
  * Gets the asset id for the object instance
  *
  * @return  int
  * @since   2.0.0
  **/
 public function getId()
 {
     // Check for current asset id and compute other vars
     $current = $this->model->get('asset_id', null);
     $parentId = $this->getAssetParentId();
     $name = $this->getAssetName();
     $title = $this->getAssetTitle();
     // Get joomla jtable model for assets
     $asset = \JTable::getInstance('Asset', 'JTable', array('dbo' => \App::get('db')));
     $asset->loadByName($name);
     // Re-inject the asset id into the model
     $this->model->set('asset_id', $asset->id);
     if ($asset->getError()) {
         return false;
     }
     // Specify how a new or moved node asset is inserted into the tree
     if (!$this->model->get('asset_id', null) || $asset->parent_id != $parentId) {
         $asset->setLocation($parentId, 'last-child');
     }
     // Prepare the asset to be stored
     $asset->parent_id = $parentId;
     $asset->name = $name;
     $asset->title = $title;
     if ($this->model->assetRules instanceof \JAccessRules) {
         $asset->rules = (string) $this->model->assetRules;
     }
     if (!$asset->check() || !$asset->store()) {
         return false;
     }
     // Register an event to update the asset name once we know the model id
     if ($this->model->isNew()) {
         $me = $this;
         Event::listen(function ($event) use($asset, $me) {
             $asset->name = $me->getAssetName();
             $asset->store();
         }, $this->model->getTableName() . '_new');
     }
     // Return the id
     return (int) $asset->id;
 }
Example #9
0
 /**
  * Возвращает коллекцию в виде пагинации
  *
  * @param int $page
  * @param int $limit
  */
 public function pagination($page, $limit = 10)
 {
     /**
      * @var \Illuminate\Support\Collection $data
      */
     $countTotal = $this->_query->count();
     $this->_query->skip($limit * $page - $limit);
     $this->_query->limit($limit);
     $data = collect();
     foreach ($this->_query->get() as $key => $instance) {
         $_listRow = [];
         foreach ($this->columns->getColumns() as $column) {
             $_listRow[$column->getKey()] = $column->getValues($instance);
         }
         $buttons = $this->filterAction($instance);
         if (count($buttons)) {
             $_listRow = array_merge($_listRow, [GridColumn::ACTION_NAME => implode('', $buttons)]);
         }
         $data->offsetSet($key, $_listRow);
     }
     return new \Illuminate\Pagination\LengthAwarePaginator($data, $countTotal, $limit, $page, ['path' => \Illuminate\Pagination\Paginator::resolveCurrentPath(), 'pageName' => 'page']);
 }
Example #10
0
 public static function rescanMultilingualStacks()
 {
     $sl = new static();
     $stacks = $sl->get();
     foreach ($stacks as $stack) {
         $section = $stack->getMultilingualSection();
         if (!$section) {
             $section = false;
             $parent = \Page::getByID($stack->getCollectionParentID());
             if ($parent->getCollectionPath() == STACKS_PAGE_PATH) {
                 // this is the default
                 $section = Section::getDefaultSection();
             } else {
                 if ($parent->getPageTypeHandle() == STACK_CATEGORY_PAGE_TYPE) {
                     $locale = $parent->getCollectionHandle();
                     $section = Section::getByLocale($locale);
                 }
             }
             if ($section) {
                 $stack->updateMultilingualSection($section);
             }
         }
     }
 }
Example #11
0
 /**
  * Create's a new user.  Returns user 'id'.
  *
  * @param   array  User array for creation
  * @return  int
  * @throws  SentryUserException
  */
 public function create(array $user, $activation = false)
 {
     // check for required fields
     if (empty($user[$this->login_column]) or empty($user['password'])) {
         throw new SentryUserException(__('sentry::sentry.column_and_password_empty', array('column' => $this->login_column_str)));
     }
     // if login_column is set to username - email is still required, so check
     if ($this->login_column != 'email' and empty($user['email'])) {
         throw new SentryUserException(__('sentry::sentry.column_email_and_password_empty', array('column' => $this->login_column_str)));
     }
     // check to see if login_column is already taken
     $user_exists = $this->user_exists($user[$this->login_column]);
     if ($user_exists) {
         // create new user object
         $temp = new static((int) $user_exists['user']['id']);
         // check if account is not activated
         if ($activation and $temp->get('activated') != 1) {
             // update and resend activation code
             $hash = Str::random(24);
             $update = array('password' => $user['password'], 'activation_hash' => $hash);
             if ($temp->update($update)) {
                 return array('id' => $temp->user['id'], 'hash' => base64_encode($user[$temp->login_column]) . '/' . $hash);
             }
             return false;
         }
         // if login_column is not set to email - also check to make sure email doesn't exist
         if ($this->login_column != 'email' and $this->user_exists($user['email'], 'email')) {
             throw new SentryUserException(__('sentry::sentry.email_already_in_use'));
         }
         throw new SentryUserException(__('sentry::sentry.column_already_exists', array('column' => $this->login_column_str)));
     }
     // set new user values
     $new_user = array($this->login_column => $user[$this->login_column], 'password' => $this->hash->create_password($user['password']), 'created_at' => $this->sql_timestamp(), 'activated' => (bool) $activation ? false : true, 'status' => 1) + $user;
     // check for metadata
     if (array_key_exists('metadata', $new_user)) {
         $metadata = $new_user['metadata'];
         unset($new_user['metadata']);
     } else {
         $metadata = array();
     }
     if (array_key_exists('permissions', $new_user)) {
         $new_user['permissions'] = json_encode($new_user['permissions']);
     }
     // set activation hash if activation = true
     if ($activation) {
         $hash = Str::random(24);
         $new_user['activation_hash'] = $this->hash->create_password($hash);
     }
     // insert new user
     $insert_id = DB::connection($this->db_instance)->table($this->table)->insert_get_id($new_user);
     // insert into metadata
     $metadata = array('user_id' => $insert_id) + $metadata;
     DB::connection($this->db_instance)->table($this->table_metadata)->insert($metadata);
     // return activation hash for emailing if activation = true
     if ($activation) {
         // return array of id and hash
         if ($insert_id) {
             return array('id' => (int) $insert_id, 'hash' => base64_encode($user[$this->login_column]) . '/' . $hash);
         }
         return false;
     }
     return $insert_id ? (int) $insert_id : false;
 }
Example #12
0
 /**
  * Create a new log entry
  * @param string $action Action requested
  * @param integer $result_id Result ID of action
  * @param string|array $params Action parameters
  * @param string|array $response Response to action
  * @param string created_by field, default to self::$user
  * @param string $ip IP address of request
  * @param integer $userID User ID, default to self:$userID
  * @return boolean
  */
 public static function _Log($action, $result_id, $params = FALSE, $response = FALSE, $user = FALSE, $ip = FALSE, $userID = 0)
 {
     // Set user
     if (!$user) {
         $user = static::$user;
     }
     // Set user id
     if (!$userID) {
         $userID = static::$userID;
     }
     // Create new log object
     $log = new static();
     // Set log variables
     try {
         $log->set('action', $action);
         $log->set('result_id', $result_id);
         $log->set('created_by', $user);
         $log->set('user_id', $userID);
         // Log Parameters
         if ($params) {
             // Convert array to JSON string
             if (is_array($params)) {
                 $params = json_encode($params);
             }
             // Truncate if too long
             $maxLength = self::_attributeProperties('params', 'max');
             if ($maxLength !== FALSE && strlen((string) $params) > $maxLength) {
                 $params = substr((string) $params, 0, $maxLength);
             }
             // Set
             $log->set('params', $params);
         }
         // Log Response
         if ($response) {
             // Convert array to JSON string
             if (is_array($response)) {
                 $response = json_encode($response);
             }
             // Truncate if too long
             $maxLength = self::_attributeProperties('response', 'max');
             if ($maxLength !== FALSE && strlen((string) $response) > $maxLength) {
                 $response = substr((string) $response, 0, $maxLength);
             }
             // Set
             $log->set('response', $response);
         }
         // Log IP
         // If an IP is specified use that otherwise
         // check for Client-IP header before using REMOTE_ADDR
         // This gets around the netscaler reverse-proxy with the additional host header
         if ($ip) {
             $log->set('ip', $ip);
         } else {
             if (isset($_SERVER['HTTP_CLIENT_IP'])) {
                 $log->set('ip', $_SERVER['HTTP_CLIENT_IP']);
             } else {
                 if (isset($_SERVER['REMOTE_ADDR'])) {
                     $log->set('ip', $_SERVER['REMOTE_ADDR']);
                 }
             }
         }
     } catch (\Exception $e) {
         new \Sonic\Message('error', 'Error setting auditlog attributes - ' . $e->getMessage());
         return FALSE;
     }
     // Begin transaction
     $log->db->beginTransaction();
     try {
         // Create log entry
         if (!$log->Create()) {
             new \Sonic\Message('error', $e->getMessage());
             $log->db->rollBack();
             return FALSE;
         }
     } catch (\Exception $e) {
         new \Sonic\Message('error', 'Exception creating auditlog - ' . $e->getMessage());
         $log->db->rollBack();
         return FALSE;
     }
     // Set last ID
     self::$_lastID = $log->get('id');
     // Commit and return TRUE
     $log->db->commit();
     return TRUE;
 }
 /**
  * Quick way to get the breadcrumb
  *
  * @param array $args
  * @return mixed
  */
 public static function make(array $args = [])
 {
     $bc = new static(null, $args);
     return $bc->get();
 }
Example #14
0
 /**
  * **A static pseudonym for `get()`.**
  *
  * @param $abstract
  *
  * @return mixed
  *
  * @throws ContainerAbstractNotFound
  */
 public static function find($abstract)
 {
     return static::$instance->get($abstract);
 }
 public static function all($store)
 {
     $model = new static($store);
     return $model->get();
 }
Example #16
0
 /**
  * Returns a new instance of StampTE configured with the template
  * that corresponds to the specified ID.
  * 
  * @param string $id identifier
  * 
  * @return StampTE $snippet 
  */
 public function get($id)
 {
     if (strpos($id, '.') !== FALSE) {
         $parts = explode('.', $id);
         $id = reset($parts);
         array_shift($parts);
         $rest = implode('.', $parts);
     }
     if ($this->inCatalogue($id)) {
         $snippet = $this->sketchBook[$this->catalogue[$id]];
         if ($this->factory) {
             $new = call_user_func_array($this->factory, array($snippet, $id));
         } else {
             $new = new static($snippet, $id);
         }
         //Pass the translator and the factory.
         $new->translator = $this->translator;
         $new->factory = $this->factory;
         if (isset($parts)) {
             return $new->get($rest);
         } else {
             return $new;
         }
     } else {
         throw new StampTEException('[S101] Cannot find Stamp Snippet with ID ' . preg_replace('/\\W/', '', $id));
     }
 }
 /**
  * gets a list of installed BlockTypes.
  *
  * @return BlockType[]
  */
 public static function getInstalledList()
 {
     $btl = new static();
     return $btl->get();
 }
Example #18
0
 static function build($config = array())
 {
     $schema = new static($config);
     return $schema->get();
 }
Example #19
0
File: Curl.php Project: rakit/curl
 /**
  * redirect from response 3xx
  */
 protected function redirect()
 {
     $redirect_url = $this->response->getHeader("location");
     $curl = new static($redirect_url);
     if ($this->cookie_jar) {
         $curl->storeSession($this->cookie_jar);
     }
     $this->response = $curl->get();
     $this->redirect_urls[] = $redirect_url;
 }
Example #20
0
 /**
  * Resolves the specified reference into the actual object and makes sure it is of the specified type.
  *
  * The reference may be specified as a string or an Instance object. If the former,
  * it will be treated as a component ID, a class/interface name or an alias, depending on the container type.
  *
  * If you do not specify a container, the method will first try `Yii::$app` followed by `Yii::$container`.
  *
  * For example,
  *
  * ```php
  * use yii\db\Connection;
  *
  * // returns Yii::$app->db
  * $db = Instance::ensure('db', Connection::className());
  * // returns an instance of Connection using the given configuration
  * $db = Instance::ensure(['dsn' => 'sqlite:path/to/my.db'], Connection::className());
  * ```
  *
  * @param object|string|array|static $reference an object or a reference to the desired object.
  * You may specify a reference in terms of a component ID or an Instance object.
  * Starting from version 2.0.2, you may also pass in a configuration array for creating the object.
  * If the "class" value is not specified in the configuration array, it will use the value of `$type`.
  * @param string $type the class/interface name to be checked. If null, type check will not be performed.
  * @param ServiceLocator|Container $container the container. This will be passed to [[get()]].
  * @return object the object referenced by the Instance, or `$reference` itself if it is an object.
  * @throws InvalidConfigException if the reference is invalid
  */
 public static function ensure($reference, $type = null, $container = null)
 {
     if (is_array($reference)) {
         $class = isset($reference['class']) ? $reference['class'] : $type;
         if (!$container instanceof Container) {
             $container = Yii::$container;
         }
         unset($reference['class']);
         return $container->get($class, [], $reference);
     } elseif (empty($reference)) {
         throw new InvalidConfigException('The required component is not specified.');
     }
     if (is_string($reference)) {
         $reference = new static($reference);
     } elseif ($type === null || $reference instanceof $type) {
         return $reference;
     }
     if ($reference instanceof self) {
         $component = $reference->get($container);
         if ($type === null || $component instanceof $type) {
             return $component;
         } else {
             throw new InvalidConfigException('"' . $reference->id . '" refers to a ' . get_class($component) . " component. {$type} is expected.");
         }
     }
     $valueType = is_object($reference) ? get_class($reference) : gettype($reference);
     throw new InvalidConfigException("Invalid data type: {$valueType}. {$type} is expected.");
 }
Example #21
0
 /**
  * Initiate application core.
  *
  * @param array $directories Spiral directories should include root, libraries and application
  *                           directories.
  * @param bool  $catchErrors
  * @return static
  */
 public static function init(array $directories, $catchErrors = true)
 {
     /**
      * @var Core $core
      */
     $core = new static($directories + ['framework' => dirname(__DIR__)]);
     $core->bindings = [static::class => $core, self::class => $core, ContainerInterface::class => $core, ConfiguratorInterface::class => $core, HippocampusInterface::class => $core, CoreInterface::class => $core] + $core->bindings;
     //Error and exception handlers
     if ($catchErrors) {
         register_shutdown_function([$core, 'handleShutdown']);
         set_error_handler([$core, 'handleError']);
         set_exception_handler([$core, 'handleException']);
     }
     foreach ($core->autoload as $module) {
         $core->get($module);
     }
     //Bootstrapping our application
     $core->bootstrap();
     return $core;
 }
Example #22
0
 /**
  * ตรวจสอบการ login เมื่อมีการเรียกใช้ class new Login
  * action=logout ออกจากระบบ
  * มาจากการ submit ตรวจสอบการ login
  * ถ้าไม่มีทั้งสองส่วนด้านบน จะตรวจสอบการ login จาก session และ cookie ตามลำดับ
  *
  * @return \static
  */
 public static function create()
 {
     // create class
     $login = new static();
     // การเข้ารหัส
     $pw = new Password(self::$cfg->password_key);
     // ชื่อฟิลด์สำหรับการรับค่าเป็นรายการแรกของ login_fields
     $field_name = reset(self::$cfg->login_fields);
     // อ่านข้อมูลจากฟอร์ม login ฟิลด์ login_username
     self::$text_username = self::$request->post('login_username', null)->toString();
     if (self::$text_username === null) {
         if (isset($_SESSION['login']) && isset($_SESSION['login'][$field_name])) {
             // from session
             self::$text_username = $_SESSION['login'][$field_name];
         } else {
             // from cookie
             $datas = self::$request->getCookieParams();
             self::$text_username = isset($datas['login_username']) ? $pw->decode($datas['login_username']) : null;
         }
         $login->from_submit = false;
     } else {
         $login->from_submit = true;
     }
     self::$text_username = Text::username(self::$text_username);
     // ค่าที่ส่งมา
     self::$text_password = $login->get('password', $pw);
     $login_remember = $login->get('remember', $pw) == 1 ? 1 : 0;
     // ตรวจสอบการ login
     if (self::$request->get('action')->toString() === 'logout' && !$login->from_submit) {
         // logout ลบ session และ cookie
         unset($_SESSION['login']);
         $time = time();
         setCookie('login_username', '', $time, '/');
         setCookie('login_password', '', $time, '/');
         self::$login_message = Language::get('Logout successful');
     } elseif (self::$request->post('action')->toString() === 'forgot') {
         // ตรวจสอบอีเมล์สำหรับการขอรหัสผ่านใหม่
         return $login->forgot(self::$request);
     } else {
         // ตรวจสอบค่าที่ส่งมา
         if (self::$text_username == '') {
             if ($login->from_submit) {
                 self::$login_message = Language::get('Please fill out this form');
                 self::$login_input = 'login_username';
             }
         } elseif (self::$text_password == '') {
             if ($login->from_submit) {
                 self::$login_message = Language::get('Please fill out this form');
                 self::$login_input = 'login_password';
             }
         } elseif (!$login->from_submit || $login->from_submit && self::$request->isSafe()) {
             // ตรวจสอบการ login กับฐานข้อมูล
             $login_result = $login->checkLogin(self::$text_username, self::$text_password);
             if (is_string($login_result)) {
                 // ข้อความผิดพลาด
                 self::$login_input = self::$login_input == 'password' ? 'login_password' : 'login_username';
                 self::$login_message = Language::get($login_result);
                 // logout ลบ session และ cookie
                 unset($_SESSION['login']);
                 $time = time();
                 setCookie('login_username', '', $time, '/');
                 setCookie('login_password', '', $time, '/');
             } else {
                 // save login session
                 $login_result['password'] = self::$text_password;
                 $_SESSION['login'] = $login_result;
                 // save login cookie
                 $time = time() + 2592000;
                 if ($login_remember == 1) {
                     setcookie('login_username', $pw->encode(self::$text_username), $time, '/');
                     setcookie('login_password', $pw->encode(self::$text_password), $time, '/');
                     setcookie('login_remember', $login_remember, $time, '/');
                 }
                 setcookie('login_id', $login_result['id'], $time, '/');
             }
         }
         return $login;
     }
 }
Example #23
0
 public static function init()
 {
     //Sanitize inputs
     //.Remove magic quotes
     if (magic_quotes()) {
         $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
         foreach ($magics as &$magic) {
             $magic = array_strip_slashes($magic);
         }
     }
     //.Unset globals
     foreach (array($_GET, $_POST) as $global) {
         if (is_array($global)) {
             foreach ($global as $k => $v) {
                 global ${$k};
                 ${$k} = NULL;
             }
         }
     }
     //.Clean post input
     array_map(function ($v) {
         return Request::clearValue($v);
     }, $_POST);
     //Remove /public/index.html from path_info..
     foreach (array("PATH_INFO", "ORIG_PATH_INFO", "PATH_TRANSLATED", "PHP_SELF") as $k) {
         if (isset($_SERVER[$k])) {
             $_SERVER[$k] = str_replace("/public/index.html", "/", $_SERVER[$k]);
         }
     }
     static::$server = $_SERVER;
     static::$get = $_GET;
     static::$post = $_POST;
     $_GET = null;
     $_POST = null;
     $_SERVER = null;
     $_REQUEST = null;
     //Detect environment
     $list = (require J_PATH . "config" . DS . "environments" . EXT);
     $env = "";
     $envWithWildcard = array_first($list);
     $hosts = array(array_get(static::$server, "HTTP_HOST", "localhost"), array_get(static::$server, "SERVER_NAME", "localhost"), array_get(static::$server, "SERVER_ADDR", "localhost"), gethostname());
     foreach ($hosts as $host) {
         foreach ($list as $k => $v) {
             foreach ((array) $v as $hostname) {
                 if ($hostname != "" && $hostname == $host) {
                     $env = $k;
                     break;
                 } else {
                     if ($hostname == "*") {
                         $envWithWildcard = $k;
                     }
                 }
             }
             if (!empty($env)) {
                 break;
             }
         }
         if (!empty($env)) {
             break;
         }
     }
     if (empty($env)) {
         $env = $envWithWildcard;
     }
     static::$env = $env;
     //Detect method
     $method = strtoupper(array_get(static::$server, "REQUEST_METHOD", "GET"));
     if ($method == "POST" && static::hasReq("_method")) {
         $methodReq = static::req("_method", "POST");
         if (array_search($methodReq, static::$availableMethods) !== false) {
             $method = $methodReq;
         }
     }
     static::$method = $method;
 }