Request.php 837 Bytes
<?php
namespace common\components;

class Request extends \yii\web\Request

{

    public $web;

    public $adminUrl;



    public function getBaseUrl()

    {

        return str_replace($this->web, "", parent::getBaseUrl()) . $this->adminUrl;

    }



    public function resolvePathInfo()

    {

        if ($this->getUrl() === $this->adminUrl) {

            return "";

        } else {

            return parent::resolvePathInfo();

        }

    }

    public static function getIsLocal($url)
    {
        $server_name = \Yii::$app->request->serverName;
        $server_name = str_replace('.', '\.', $server_name);
        $pattern = '/^(?:https?:\/\/)?\/?(?:www\.)?'.$server_name.'(?:\/.*)?$/';
        if(preg_match($pattern, $url)) {
            return true;
        } else {
            return false;
        }
    }

}