aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-12-18 12:39:02 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-12-18 12:39:02 +0000
commita2eca798585a345f17d2e57d27d29cb3abe17ee3 (patch)
treeb2ed1002c8f12165476a718f40c479bf4a141072
parente086d9c17d513b08d1625e4d3b2dc0235f4e4030 (diff)
downloadelgg-a2eca798585a345f17d2e57d27d29cb3abe17ee3.tar.gz
elgg-a2eca798585a345f17d2e57d27d29cb3abe17ee3.tar.bz2
better parsing of query for action and page handlers
git-svn-id: http://code.elgg.org/elgg/trunk@3768 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/actions.php26
-rw-r--r--engine/lib/pagehandler.php18
2 files changed, 22 insertions, 22 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index 2a9b930b2..ac4d70555 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -21,21 +21,20 @@
function action($action, $forwarder = "") {
global $CONFIG;
- $query = parse_url($_SERVER['REQUEST_URI']);
- if (isset($query['query'])) {
- $query = $query['query'];
- $query = rawurldecode($query);
- $query = explode('&',$query);
- if (sizeof($query) > 0) {
- foreach($query as $queryelement) {
- $vals = explode('=',$queryelement, 2);
- if (sizeof($vals) > 1) {
- set_input(trim($vals[0]),trim($vals[1]));
+ // if there are any query parameters, make them available from get_input
+ if (strpos($_SERVER['REQUEST_URI'], '?') !== FALSE) {
+ $query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
+ if (isset($query)) {
+ parse_str($query, $query_arr);
+ if (is_array($query_arr)) {
+ foreach($query_arr as $name => $val) {
+ // should we trim name and val?
+ set_input($name, $val);
}
}
}
}
-
+
$forwarder = str_replace($CONFIG->url, "", $forwarder);
$forwarder = str_replace("http://", "", $forwarder);
$forwarder = str_replace("@", "", $forwarder);
@@ -45,10 +44,7 @@ function action($action, $forwarder = "") {
}
if (isset($CONFIG->actions[$action])) {
- if (
- (isadminloggedin()) ||
- (!$CONFIG->actions[$action]['admin'])
- ) {
+ if ((isadminloggedin()) || (!$CONFIG->actions[$action]['admin'])) {
if ($CONFIG->actions[$action]['public'] || $_SESSION['id'] != -1) {
// Trigger action event TODO: This is only called before the primary action is called. We need to rethink actions for 1.5
diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php
index 79ac70c70..99b50a2bf 100644
--- a/engine/lib/pagehandler.php
+++ b/engine/lib/pagehandler.php
@@ -20,16 +20,20 @@ function page_handler($handler, $page) {
set_context($handler);
- //parse_url($_SERVER['REQUEST_URI']);
- $query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
- if (isset($query)) {
- parse_str($query, $query_arr);
- if (is_array($query_arr)) {
- foreach($query_arr as $name => $val) {
- set_input($name, $val);
+ // if there are any query parameters, make them available from get_input
+ if (strpos($_SERVER['REQUEST_URI'], '?') !== FALSE) {
+ $query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
+ if (isset($query)) {
+ parse_str($query, $query_arr);
+ if (is_array($query_arr)) {
+ foreach($query_arr as $name => $val) {
+ set_input($name, $val);
+ }
}
}
}
+
+ // if page url ends in a / then last element of $page is an empty string
$page = explode('/',$page);
if (!isset($CONFIG->pagehandler) || empty($handler)) {