if a customer is logged on and the site is ssl secured a never ending redirect happens, when the customers wants to get to a category or product..
repalce the whole function "tep_validate_seo_urls" in catalog/includes/fuctions/general.php
with:
################################################
// fwrmedia.co.uk mod to check SEO link validity
function tep_validate_seo_urls() {
global $HTTP_GET_VARS;
$querystring = str_replace('?', '&', $_SERVER['REQUEST_URI']);
if (isset($HTTP_GET_VARS['products_id']))
$get_id_vars = str_replace(strstr($HTTP_GET_VARS['products_id'], '{'), '', $HTTP_GET_VARS['products_id']); // Remove attributes
$qs_parts = explode('&', $querystring); // explode the querystring into an array
$count = count($qs_parts);
$added_uri = array();
$remove_nasties = array('%3C', '%3E', '<', '>', ':/', 'http', 'HTTP', 'https', 'HTTPS'); // We do tep_sanitize_string() later anyway
for ( $i=0; $i<$count; $i++ ) { // We don't want to introduce vulnerability do we :)
switch($qs_parts[$i]) {
case(false !== strpos($qs_parts[$i], '.html')):
$core = urldecode($qs_parts[$i]); // Found the path
( (strstr($core, '{') !== false) ? ($core = str_replace(strstr($core, '{'), '', $core) . '.html') : NULL ); // Remove attributes
break;
case(false !== strpos($qs_parts[$i], 'osCsid')):
$seo_sid = $qs_parts[$i]; // Found the osCsid
break;
default:
$added_uri[] = ( urldecode(str_replace($remove_nasties, '', $qs_parts[$i])) ); // Found the additional querystring (e.g. &page=3&sort=2a from split_page_results)
}
}
// If -x- is in the querystring create var $querytype which is a string which explodes into an array on -
( strpos($_SERVER['REQUEST_URI'], '-p-') ? ($querytype = 'filename_product_info-products_id=' . $get_id_vars) :
( strpos($_SERVER['REQUEST_URI'], '-c-') ? ($querytype = 'filename_default-cPath=' . $HTTP_GET_VARS['cPath']) :
( strpos($_SERVER['REQUEST_URI'], '-m-') ? ($querytype = 'filename_default-manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']) :
( strpos($_SERVER['REQUEST_URI'], '-pi-') ? ($querytype = 'filename_popup_image-pID=' . $HTTP_GET_VARS['pID']) :
( strpos($_SERVER['REQUEST_URI'], '-t-') ? ($querytype = 'filename_articles-tPath=' . $HTTP_GET_VARS['tPath']) :
( strpos($_SERVER['REQUEST_URI'], '-a-') ? ($querytype = 'filename_article_info-articles_id=' . $HTTP_GET_VARS['articles_id']) :
( strpos($_SERVER['REQUEST_URI'], '-pr-') ? ($querytype = 'filename_product_reviews-products_id=' . $get_id_vars) :
( strpos($_SERVER['REQUEST_URI'], '-pri-') ? ($querytype = 'filename_product_reviews_info-products_id=' . $get_id_vars) :
( strpos($_SERVER['REQUEST_URI'], '-prw-') ? ($querytype = 'filename_product_reviews_write-products_id=' . $get_id_vars) :
( strpos($_SERVER['REQUEST_URI'], '-i-') ? ($querytype = 'filename_information-info_id=' . $HTTP_GET_VARS['info_id']) :
( strpos($_SERVER['REQUEST_URI'], '-links-') ? ($querytype = 'filename_links-lPath=' . $HTTP_GET_VARS['lPath']) :
false )))))))))) );
$validate_array = explode('-', $querytype); // Gives e.g. $validate_array[0] = filename_default, $validate_array[1] = products_id=xx
$linkreturned = tep_href_link(constant(strtoupper($validate_array[0])), $validate_array[1]); // Get a propper new SEO link
// Rebuild the extra querystring
( (strpos($linkreturned, '?') !== false) ? ($seperator = '&') : ($seperator = '?') ); // Is there an osCid on $linkreturned?
$count = count($added_uri); // Count the extra querystring items
for ($i=0; $i<$count; $i++)
if ($i == 0) $linkreturned = $linkreturned . $seperator . tep_sanitize_string($added_uri[$i]); //add the first using seperator ? or &
else $linkreturned = $linkreturned . '&' . tep_sanitize_string($added_uri[$i]); // Just add "&" this time
$linkreturnedstripped = str_replace( strstr($linkreturned, '?'), '', $linkreturned); // Strip osCsid to allow a match with $core
$linktest = str_replace(HTTP_SERVER . DIR_WS_HTTP_CATALOG, '', $linkreturned); // Pair the url down to the querystring
$linktest = str_replace(HTTPS_SERVER . DIR_WS_HTTPS_CATALOG, '', $linktest); // Pair the url down to the querystring
if (strpos($linktest, '-') === 0) { // If the link returned by seo.class.php has no text mysite.com/-c-xxx.html
$dohome = tep_href_link(FILENAME_DEFAULT); // It means that the page no longer exists (assuming the class is working)
header("HTTP/1.0 404 Not Found"); // Set header 404 Not Found
header("Location: $dohome"); // .. 404 redirect to index.php .. and never come back!!!
exit;
} else if (( HTTP_SERVER . $core != $linkreturnedstripped ) && ( HTTPS_SERVER . $core != $linkreturnedstripped )) { // Link looks bad so 301
$linkreturned = str_replace('&', '&', $linkreturned); // Just in case those sneaky W3C urls tried to throw in an &
header("HTTP/1.0 301 Moved Permanently"); // redirect to the good version
header("Location: $linkreturned"); // 301 redirect
exit;
}
}
################################################
// END fwrmedia.co.uk mod to check SEO link validity
same text in the file