toyicebear, on 07 March 2012 - 03:19 PM, said:
You must have done something wrong somewhere, the code example i gave is correct.....
check and make sure that you have the / before and the /i after inside the brackets exactly as in the example i gave.
Nice! i didnt had the / in the brackets!
I no longer get errors if the sef in de admin panel /config is off by changing
Quote
if(!eregi('^[_0-9]*$',$cPath)){
to
Quote
if(!preg_match('/^[_0-9]*$/i',$cPath)){
This is how the nimmit_sef.php should be:
<?php
# --> Nimmit SEF:B
//products_id
if(isset($HTTP_GET_VARS['products_id']) && !preg_match('/^[_0-9]*$/i',$HTTP_GET_VARS['products_id'])){
$name_Q= tep_db_query("select products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_name = '" . str_replace("_"," ", $HTTP_GET_VARS['products_id']) . "'");
if(tep_db_num_rows($name_Q)){
$t = tep_db_fetch_array($name_Q);
$HTTP_GET_VARS['products_id'] = $t['products_id'];
}
}
// manufactures_id
if(isset($HTTP_GET_VARS['manufacturers_id']) && !preg_match('/^[_0-9]*$/i',$HTTP_GET_VARS['manufacturers_id'])){
$brand_Q = tep_db_query("select manufacturers_id from " . TABLE_MANUFACTURERS . " where manufacturers_name = '" . str_replace("_"," ", $HTTP_GET_VARS['manufacturers_id']) . "'");
if(tep_db_num_rows($brand_Q)){
$t = tep_db_fetch_array($brand_Q);
$HTTP_GET_VARS['manufacturers_id'] = $t['manufacturers_id'];
}
}
if(isset($HTTP_GET_VARS['cPath']) && !preg_match('/^[_0-9]*$/i', $HTTP_GET_VARS['cPath'])){
if(!preg_match('/^[_0-9]*$/i',$cPath)){
$cat_arr = explode('_' , $cPath);
foreach($cat_arr as $value){
$cat_Q = tep_db_query("select categories_id from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_name = '" . str_replace('+' , ' ' , $value) . "'");
$cat_name = tep_db_fetch_array($cat_Q);
if(!$count){
$result .= $cat_name['categories_id'];
$count = true;
}
else{
$result .= '_' . $cat_name['categories_id'];
}
}
$HTTP_GET_VARS['cPath'] = $result;
}
}
# --> Nimmit SEF:E
?>
But the script still aint showing the same Urls as before.
Maybe the second file: url_rewrite.php need some brackets to?
<?php
/*
SEF Link Transformer for osCommerce (SEF stand for Search Engine Friendly)
Nimmit SEF v0.4
Original contibution base: Silencer (silencer@softhome.net)
New contribution with catgory names, brand names , and product names: Nimmit
*/
function callback($pagecontent) {
$pagecontent = preg_replace_callback("/(<[Aa][ \r\n\t]{1}[^>]*href[^]*=[ '\"\n\r\t]*)([^ \"'>\r\n\t#]+)([^>]*>)/",'wrap_href',$pagecontent);
return $pagecontent;
}
function transform_uri($param) {
$uriparts = parse_url($param[2]);
$newquery='';
$scheme = $uriparts['scheme'].'://';
if (($scheme != 'http://') && ($scheme != 'https://')) return $param[1].$param[2].$param[3];
$host = $uriparts['host'];
if ($host != $_SERVER['SERVER_NAME'] && $host != $_SERVER['SERVER_ADDR']) return $param[1].$param[2].$param[3];
$path = $uriparts['path'];
list($file,$extension) = explode('.', basename($path));
if($extension != 'php') return $param[1].$param[2].$param[3];
$extension = ".html";
$path = rtrim(dirname($path),'/');
$query = $uriparts['query'];
$anchor = $uriparts['anchor'];
if ($a = explode('&',$query)){
foreach ($a as $B) {
list($key,$val) = split('=',$B);
switch ($key) {
case 'cPath':
if(eregi('[_0-9]', $val)){
if($cat_arr = explode('_', $val)){
$count = false;
foreach($cat_arr as $value){
$cat_Q = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $value . "' and c.categories_id = cd.categories_id");
$cat_name = tep_db_fetch_array($cat_Q);
if(!$count){
$result .= $cat_name['categories_name'];
$count = true;
}
else{
$result .= '_' . $cat_name['categories_name'];
}
}
$cat = '/category/'. str_replace(' ' , '+' , $result);
}
else{
$cat = '/category/'.$val;
}
}
else{
$cat = '/category/'.$val;
}
break;
case 'language':
$lan = $val.'/'.$path;
break;
case 'products_id':
$name_Q = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $val . "'");
$pro = ($t = tep_db_fetch_array($name_Q)) ? '/product/' . str_replace(" ", "_" , $t['products_name']) : '/product/'.$val;
break;
case 'manufacturers_id':
$brand_Q = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $val . "'");
$man = ($t = tep_db_fetch_array($brand_Q)) ? '/brand/'.str_replace(" ", "_" , $t['manufacturers_name']) : $man = '/brand/'.$val;
break;
case 'osCsid':
if(strstr($_SERVER["HTTP_USER_AGENT"],'Mozilla')) $newquery .= $key.'='.$val.'&';
break;
default:
if($newquery || $key) $newquery .= $key.'='.$val.'&';
}
}
}
if ($newquery) $newquery = '?'.rtrim($newquery,'&');
$path = '';
if(isset($man)) $path .= $man;
if(isset($cat)) $path .= $cat;
if(isset($pro)) $path .= $pro;
((isset($man) || isset($cat) || isset($pro))) ? $host .= '' :$host .= '/';
if($file == 'index' || $file == 'product_info'){
if((isset($man) || isset($cat) || isset($pro))) $file= '';
}
if(eregi('reviews',$file)) $file = '/' . $file;
return $param[1].$scheme.$host.$file.$path.$extension.$newquery.$anchor.$param[3];
}
function wrap_href($param) {
return transform_uri($param);
}
ob_start("callback");
?>
Thanks for your help!
Edited by Stefan Hekman, 07 March 2012 - 06:13 PM.