Fix URL resolving errors. Also fix Grunt task for local server
This commit is contained in:
parent
7b267a64c2
commit
7f1992b749
@ -42,8 +42,8 @@
|
|||||||
|
|
||||||
public function handle_request($url, $query = array()) {
|
public function handle_request($url, $query = array()) {
|
||||||
if ($this->error) return $this->error_page;
|
if ($this->error) return $this->error_page;
|
||||||
if (!$this->params['clean_urls']) $this->params['base_page'] .= 'index.php?request=';
|
if (!$this->params['clean_urls']) $this->params['base_page'] .= 'index.php/';
|
||||||
$request = DauxHelper::get_request_from_url($url, $this->base_url);
|
$request = DauxHelper::get_request();
|
||||||
$request = urldecode($request);
|
$request = urldecode($request);
|
||||||
$request_type = isset($query['method']) ? $query['method'] : '';
|
$request_type = isset($query['method']) ? $query['method'] : '';
|
||||||
switch ($request_type) {
|
switch ($request_type) {
|
||||||
@ -74,12 +74,10 @@
|
|||||||
}
|
}
|
||||||
$this->mode = Daux::LIVE_MODE;
|
$this->mode = Daux::LIVE_MODE;
|
||||||
$this->host = $_SERVER['HTTP_HOST'];
|
$this->host = $_SERVER['HTTP_HOST'];
|
||||||
//Fixes for pages within pages
|
$this->base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
|
||||||
//$this->base_url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
|
$t = strrpos($this->base_url, '/index.php');
|
||||||
$this->base_url = $_SERVER['HTTP_HOST'];
|
if ($t != FALSE) $this->base_url = substr($this->base_url, 0, $t);
|
||||||
//$this->base_url = substr($this->base_url, 0, strrpos($this->base_url, '/'));
|
if (substr($this->base_url, -1) !== '/') $this->base_url .= '/';
|
||||||
//adding this replace, which replaces the /index.php with nothing seems to resolve the issue with serving static content
|
|
||||||
$this->base_url = str_replace("/index.php", "", $this->base_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function load_global_config($global_config_file) {
|
private function load_global_config($global_config_file) {
|
||||||
@ -206,7 +204,7 @@
|
|||||||
$params['index_key'] = 'index';
|
$params['index_key'] = 'index';
|
||||||
$params['docs_path'] = $this->docs_path;
|
$params['docs_path'] = $this->docs_path;
|
||||||
$protocol = '//';
|
$protocol = '//';
|
||||||
$params['base_url'] = $protocol . $this->base_url . '/';
|
$params['base_url'] = $protocol . $this->base_url;
|
||||||
$params['base_page'] = $params['base_url'];
|
$params['base_page'] = $params['base_url'];
|
||||||
$params['host'] = $this->host;
|
$params['host'] = $this->host;
|
||||||
$params['tree'] = $this->tree;
|
$params['tree'] = $this->tree;
|
||||||
@ -236,7 +234,7 @@
|
|||||||
$params['docs_path'] = $this->docs_path;
|
$params['docs_path'] = $this->docs_path;
|
||||||
$params['index_key'] = 'index';
|
$params['index_key'] = 'index';
|
||||||
$protocol = '//';
|
$protocol = '//';
|
||||||
$params['base_url'] = $protocol . $this->base_url . '/';
|
$params['base_url'] = $protocol . $this->base_url;
|
||||||
$params['base_page'] = $params['base_url'];
|
$params['base_page'] = $params['base_url'];
|
||||||
$params['host'] = $this->host;
|
$params['host'] = $this->host;
|
||||||
$params['tree'] = $this->tree;
|
$params['tree'] = $this->tree;
|
||||||
|
@ -59,8 +59,10 @@
|
|||||||
return static::directory_tree_builder($dir, $ignore, $mode);
|
return static::directory_tree_builder($dir, $ignore, $mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Depreciated
|
||||||
public static function get_request_from_url($url, $base_url) {
|
public static function get_request_from_url($url, $base_url) {
|
||||||
$url = substr($url, strlen($base_url) + 1);
|
$url = substr($url, strlen($base_url));
|
||||||
if (strpos($url, 'index.php') === 0) {
|
if (strpos($url, 'index.php') === 0) {
|
||||||
$request = (($i = strpos($url, 'request=')) !== false) ? $request = substr($url, $i + 8) : '';
|
$request = (($i = strpos($url, 'request=')) !== false) ? $request = substr($url, $i + 8) : '';
|
||||||
if ($end = strpos($request, '&')) $request = substr($request, 0, $end);
|
if ($end = strpos($request, '&')) $request = substr($request, 0, $end);
|
||||||
@ -72,6 +74,33 @@
|
|||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static function get_request($prefix_slash = false)
|
||||||
|
{
|
||||||
|
if (isset($_SERVER['PATH_INFO'])) $uri = $_SERVER['PATH_INFO'];
|
||||||
|
else if (isset($_SERVER['REQUEST_URI'])) {
|
||||||
|
$uri = $_SERVER['REQUEST_URI'];
|
||||||
|
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
|
||||||
|
else if (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
|
||||||
|
if (strncmp($uri, '?/', 2) === 0) $uri = substr($uri, 2);
|
||||||
|
$parts = preg_split('#\?#i', $uri, 2);
|
||||||
|
$uri = $parts[0];
|
||||||
|
if (isset($parts[1])) {
|
||||||
|
$_SERVER['QUERY_STRING'] = $parts[1];
|
||||||
|
parse_str($_SERVER['QUERY_STRING'], $_GET);
|
||||||
|
} else {
|
||||||
|
$_SERVER['QUERY_STRING'] = '';
|
||||||
|
$_GET = array();
|
||||||
|
}
|
||||||
|
$uri = parse_url($uri, PHP_URL_PATH);
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
$uri = str_replace(array('//', '../'), '/', trim($uri, '/'));
|
||||||
|
if ($uri == "") $uri = "index";
|
||||||
|
return $uri;
|
||||||
|
}
|
||||||
|
|
||||||
public static function configure_theme($theme, $base_url, $local_base, $theme_url, $mode = Daux::LIVE_MODE) {
|
public static function configure_theme($theme, $base_url, $local_base, $theme_url, $mode = Daux::LIVE_MODE) {
|
||||||
$name = static::pathinfo($theme);
|
$name = static::pathinfo($theme);
|
||||||
if (is_file($theme)) {
|
if (is_file($theme)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user