$postdata = get_post_data();
if (isset($postdata)) {
- elgg_parse_str($postdata, $query_arr);
+ $query_arr = elgg_parse_str($postdata);
if (is_array($query_arr)) {
foreach($query_arr as $name => $val) {
set_input($name, $val);
/**
* The auth.gettoken API.
* This API call lets a user log in, returning an authentication token which can be used
- * to authenticate a user for a period of time. It is passed in future calls as the parameter
+ * to authenticate a user for a period of time. It is passed in future calls as the parameter
* auth_token.
*
* @param string $username Username
// setup the input parameters since this comes through rewrite rule
$query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?')+1);
if (isset($query)) {
- elgg_parse_str($query, $query_arr);
+ $query_arr = elgg_parse_str($query);
if (is_array($query_arr)) {
foreach($query_arr as $name => $val) {
set_input($name, $val);
$item_params = array();
if (isset($uri_info['query'])) {
$uri_info['query'] = html_entity_decode($uri_info['query']);
- elgg_parse_str($uri_info['query'], $uri_params);
+ $uri_params = elgg_parse_str($uri_info['query']);
}
if (isset($item_info['query'])) {
$item_info['query'] = html_entity_decode($item_info['query']);
- elgg_parse_str($item_info['query'], $item_params);
+ $item_params = elgg_parse_str($item_info['query']);
}
$uri_info['path'] = trim($uri_info['path'], '/');
$url = parse_url($link);
if (isset($url['query'])) {
- elgg_parse_str($url['query'], $query);
+ $query = elgg_parse_str($url['query']);
} else {
$query = array();
}
$url_array = parse_url($url);
if (isset($url_array['query'])) {
- elgg_parse_str($url_array['query'], $query);
+ $query = elgg_parse_str($url_array['query']);
} else {
// nothing to remove. Return original URL.
return $url;
$url_array = parse_url($url);
if (isset($url_array['query'])) {
- elgg_parse_str($url_array['query'], $query);
+ $query = elgg_parse_str($url_array['query']);
} else {
$query = array();
}
*/
function elgg_set_input_from_uri() {
$query = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
- elgg_parse_str($query, $query_arr);
+ $query_arr = elgg_parse_str($query);
if (is_array($query_arr)) {
foreach($query_arr as $name => $val) {
ini_set("mbstring.internal_encoding", 'UTF-8');
}
+/**
+ * Parses a string using mb_parse_str() if available.
+ * NOTE: This differs from parse_str() by returning the results
+ * instead of placing them in the local scope!
+ *
+ * @param str $str
+ * @return array
+ */
+function elgg_parse_str($str) {
+ if (is_callable('mb_parse_str')) {
+ mb_parse_str($str, $results);
+ } else {
+ parse_str($str, $results);
+ }
+
+ return $results;
+}
+
// map string functions to their mb_str_func alternatives
// and wrap them in elgg_str_fun()
// only will work with mb_* functions that take the same
// params in the same order as their non-mb safe counterparts.
$str_funcs = array(
- 'parse_str',
+ // can't wrap parse_str() because of its 2nd parameter.
+ //'parse_str',
'split',
'stristr',
'strlen',
if (strpos($_SERVER['REQUEST_URI'], '?') !== FALSE) {
$query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
if (isset($query)) {
- elgg_parse_str($query, $query_arr);
+ $query_arr = elgg_parse_str($query);
if (is_array($query_arr)) {
foreach($query_arr as $name => $val) {
set_input($name, $val);
return FALSE;
}
-$query = htmlspecialchars(http_build_query(
+$query = http_build_query(
array(
'q' => $vars['params']['query'],
'entity_type' => $vars['params']['type'],
'search_type' => $vars['params']['search_type'],
//@todo include vars for sorting, order, and friend-only.
)
-));
+);
$url = "{$vars['url']}pg/search?$query";