Example #1
0
        self::$DOC_ROOT = str_replace(self::$SCRIPT_NAME, '', self::$SCRIPT_FILENAME);
        // ex: /var/www
        self::$BASE_URL = str_replace(self::$DOC_ROOT, '', self::$BASE_DIR);
        // ex: '' or '/mywebsite'
        self::$PROTOCOL = empty($_SERVER['HTTPS']) ? 'http' : 'https';
        self::$PORT = $_SERVER['SERVER_PORT'];
        self::$DISP_PORT = self::$PROTOCOL == 'http' && self::$PORT == 80 || self::$PROTOCOL == 'https' && self::$PORT == 443 ? '' : ":" . self::$PORT;
        self::$DOMAIN = $_SERVER['SERVER_NAME'];
        self::$FULL_URL = self::$PROTOCOL . "://" . self::$DOMAIN . self::$DISP_PORT . self::$BASE_URL;
        $subdomains = explode(".", $_SERVER['HTTP_HOST']);
        self::$SUBDOMAIN = array_shift($subdomains);
        if (array_key_exists('REQUEST_SCHEME', $_SERVER)) {
            self::$REMOTE_HOST = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["SCRIPT_NAME"]);
        } else {
            self::$REMOTE_HOST = "http://" . $_SERVER["HTTP_HOST"];
        }
        self::$REMOTE_HOST = str_replace('\\', "/", self::$REMOTE_HOST);
        $pathinfo = pathinfo($_SERVER["REQUEST_URI"]);
        $parsedInfo = parse_url($_SERVER["REQUEST_URI"]);
        //print_r($pathinfo);
        //print_r($parsedInfo);
        self::$REQUEST_PATHNAME = $parsedInfo['path'];
        self::$REQUEST_DIRNAME = $pathinfo['dirname'];
        self::$REQUEST_QUERY = isset($parsedInfo['query']) ? $parsedInfo['query'] : "";
        self::$REQUEST_FILE_EXT = isset($pathinfo['extension']) ? $pathinfo['extension'] : "";
        self::$REQUEST_FILENAME = str_replace("?" . self::$REQUEST_QUERY, "", $pathinfo['basename']);
        self::$REQUEST_FILE_EXT = str_replace("?" . self::$REQUEST_QUERY, "", self::$REQUEST_FILE_EXT);
    }
}
Webapp::init();