Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SEF NIMMIT Update for OsC 2.3.1 (PhP 5.3)


Stefan Hekman

Recommended Posts

Hello All,

 

The SEF NIMMIT script worked on my old version of OsC.

Google already knows all the urls of my categories.

Now that i installed a new version of OsC (2.3.1) none of the urls match anymore.

So thats why i want to change them excactly like the old links.

 

Now when i click it says: http://domainname.com/index.php/cPath/1

I want to change it into http://domainname.com/alfa-romeo-tuning.html

 

So i installed the 'immit sef' module.

In the install manual u have to disable sef in de config admin panel.

But when i install the files and turn sef off the webpage gives a few errors like:

 

 

Deprecated: Function eregi() is deprecated in /home/domainname.com/public_html/includes/nimmit_sef.php on line 19

Deprecated: Function eregi() is deprecated in /home/domainname.com/public_html/includes/nimmit_sef.php on line 20

 

When i turn sef ON in the config admin panel the errors disappear, but the links do not change.

 

The module defenitly needs an update, but i can't get it working.

 

Does anyone know how? I am willing to pay for the effort.

 

Any free help would be extremely appreciated!

Link to comment
Share on other sites

Link to comment
Share on other sites

I have read it and tried to change ergi to preg_match with '!' and without '!'

Still getting errorrs:

 

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /home/domainname.com/public_html/includes/nimmit_sef.php on line 19

 

This is the only script nimmit uses (i have made it original again):

 

<?php
# --> Nimmit SEF:B
 //products_id
 if(isset($HTTP_GET_VARS['products_id']) && !eregi('^[0-9]*$',$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']) && !eregi('^[0-9]*$',$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']) && !eregi('^[_0-9]$', $HTTP_GET_VARS['cPath'])){
if(!eregi('^[_0-9]*$',$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
?>

 

Do you have an idea?

Link to comment
Share on other sites

For instance change this

if(!eregi('^[_0-9]*$',$cPath)){

 

 

To this

 

if(!preg_match('/^[_0-9]*$/i',$cPath)){

 

Link to comment
Share on other sites

For instance change this

 

 

To this

Yes i thought that, but if i change that this error will appear:

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /home/domainname.com/public_html/includes/nimmit_sef.php on line 20

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

if(!eregi('^[_0-9]*$',$cPath)){

to

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 ([email protected])
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!

Link to comment
Share on other sites

Link to comment
Share on other sites

Damn, didnt see the eregi's in the code..

I have changed this:

 

if(eregi('[_0-9]', $val)){

in to:

if(preg_match('/[_0-9]', $val)){

and

if(eregi('reviews',$file)) $file = '/' . $file;

in to:

if(preg_match('/reviews',$file)) $file = '/' . $file;

 

Is this correct?

Link to comment
Share on other sites

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...