Guest Posted July 6, 2003 Posted July 6, 2003 Hi there, I am trying to use the safe urls, but I have the problem that the function in application_top.php (please see below) doesn't seem to return any other variables than $cPath. My URL is e.g. .../index.php/cPath/1_3/page/3/limit20 The $cPath variable is OK, but $page and $limit are empty. I suppose this is because of the following function?! // set the HTTP GET parameters manually if search_engine_friendly_urls is enabled if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') { if (strlen(getenv('PATH_INFO')) > 1) { $GET_array = array(); $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF); $vars = explode('/', substr(getenv('PATH_INFO'), 1)); for ($i=0, $n=sizeof($vars); $i<$n; $i++) { if (strpos($vars[$i], '[]')) { $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1]; } else { $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1]; } $i++; } if (sizeof($GET_array) > 0) { while (list($key, $value) = each($GET_array)) { $HTTP_GET_VARS[$key] = $value; } } } } Any help is welcome, regards Matt
Daemonj Posted July 6, 2003 Posted July 6, 2003 Try the following function instead: // Get variables from $PATH_INFO if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') { if (strlen($PATH_INFO) > 1) { $PHP_SELF = str_replace($PATH_INFO,'',$PHP_SELF); $vars = explode('/', substr($PATH_INFO, 1)); while (list(, $var) = each($vars)) { list(, $val) = each($vars); $_GET[$var] = $val; $GLOBALS[$var] = $val; } } } and let me know if that does not work better for you. "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
Guest Posted July 6, 2003 Posted July 6, 2003 Doesn't work :( Nothing get's returned anymore. Thanks for your tip (PM) regarding the spider contrib. I will have a deeper look. Having a spider crash our server is not what we want, right? :wink: Still, you are a genius! Regards Matt
Guest Posted July 6, 2003 Posted July 6, 2003 Hi there, solved it. This is the function that works for me ;-) // set the HTTP GET parameters manually if search_engine_friendly_urls is enabled if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') { if (strlen($PATH_INFO) > 1) { //$GET_array = array(); //$PHP_SELF = str_replace($PATH_INFO, '', $PHP_SELF); $vars = explode('/', substr($PATH_INFO, 1)); //$check = $vars[0] . ' ' . $vars[1] . ' ' . $vars[2]; for ($i=0, $n=sizeof($vars); $i<$n; $i++) { $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1]; $GLOBALS[$vars[$i]] = $vars[$i+1]; } } } Regards Matt PS: Please correct me, if there is something horribly wrong, but as I said it works.
Guest Posted July 7, 2003 Posted July 7, 2003 Hi there, I am sorry, but after some testing the function above seems to be not that good at all. After playing around a little more, I ended up with a very easy solution. I just added $GLOBALS[$vars[$i]] = $vars[$i+1]; to the original function. Please check the whole function underneith. Regards Matt // set the HTTP GET parameters manually if search_engine_friendly_urls is enabled if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') { if (strlen(getenv('PATH_INFO')) > 1) { $GET_array = array(); $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF); $vars = explode('/', substr(getenv('PATH_INFO'), 1)); for ($i=0, $n=sizeof($vars); $i<$n; $i++) { if (strpos($vars[$i], '[]')) { $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1]; } else { $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1]; $GLOBALS[$vars[$i]] = $vars[$i+1]; } $i++; } if (sizeof($GET_array) > 0) { while (list($key, $value) = each($GET_array)) { $HTTP_GET_VARS[$key] = $value; } } } }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.