diff --git a/core/util.inc.php b/core/util.inc.php index 9acc9814..40a0a397 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -437,7 +437,7 @@ function modify_url($url, $changes) { unset($changes['q']); } else { - $base = $_GET['q']; + $base = _get_query(); } if(isset($params['q'])) { @@ -1723,6 +1723,16 @@ function _get_user() { return $user; } +function _get_query() { + if(php_sapi_name() == 'cli-server') { + return $_SERVER["REQUEST_URI"]; + } + else { + return @$_POST["q"]?:@$_GET["q"]; + } +} + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Code coverage * diff --git a/index.php b/index.php index b149b355..d386aa44 100644 --- a/index.php +++ b/index.php @@ -83,7 +83,7 @@ try { $user = _get_user(); send_event(new InitExtEvent()); if(!is_cli()) { // web request - send_event(new PageRequestEvent(@$_POST["q"]?:@$_GET["q"])); + send_event(new PageRequestEvent(_get_query())); $page->display(); } else { // command line request diff --git a/themes/danbooru/layout.class.php b/themes/danbooru/layout.class.php index ca0f3fe0..15ee6d6c 100644 --- a/themes/danbooru/layout.class.php +++ b/themes/danbooru/layout.class.php @@ -124,7 +124,7 @@ class Layout { // hack $username = url_escape($user->name); // hack - $qp = explode("/", ltrim(@$_GET["q"], "/")); + $qp = explode("/", ltrim(_get_query(), "/")); // php sucks switch($qp[0]) { default: @@ -245,7 +245,7 @@ EOD; * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) */ $html = null; - $url = ltrim($_GET['q'], "/"); + $url = ltrim(_get_query(), "/"); $re1='.*?'; $re2='((?:[a-z][a-z_]+))'; diff --git a/themes/danbooru2/layout.class.php b/themes/danbooru2/layout.class.php index e937ed8b..e7a1b27c 100644 --- a/themes/danbooru2/layout.class.php +++ b/themes/danbooru2/layout.class.php @@ -126,7 +126,7 @@ class Layout { // hack $username = url_escape($user->name); // hack - $qp = explode("/", ltrim(@$_GET["q"], "/")); + $qp = explode("/", ltrim(_get_query(), "/")); // php sucks switch($qp[0]) { default: @@ -271,7 +271,7 @@ EOD; * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) */ $html = null; - $url = $_GET['q']; + $url = _get_query(); $re1='.*?'; $re2='((?:[a-z][a-z_]+))'; diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index 9fe38e46..69671487 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -82,7 +82,7 @@ class Layout { // hack $username = url_escape($user->name); // hack - $qp = explode("/", ltrim(@$_GET["q"], "/")); + $qp = explode("/", ltrim(_get_query(), "/")); $cs = ""; // php sucks @@ -256,7 +256,7 @@ EOD; * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) */ $html = null; - $url = ltrim($_GET['q'], "/"); + $url = ltrim(_get_query(), "/"); $re1='.*?'; $re2='((?:[a-z][a-z_]+))';