Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Undefined variable: rewrite_product


AJRYAN

Recommended Posts

I've been using Chemo's great contribution for as long as I can remember without any problems.

 

Today though, I discovered something unusual. I am starting to pay more attention to my error logs and

reporting and discovered these two entries(multiplied by a lot of the same with different timestamps) When I turn on

error logging the file gets very large in only seconds, filled mostly with these errors.

 

 

PHP Notice: Undefined variable: rewrite_product in /home/...../public_html/includes/functions/html_output.php on line 131

PHP Notice: Undefined variable: rewrite_product in /home/...../public_html/includes/functions/html_output.php on line 132

PHP Notice: Undefined variable: rewrite_category in /home/...../public_html/includes/functions/html_output.php on line 131

PHP Notice: Undefined variable: rewrite_category in /home/...../public_html/includes/functions/html_output.php on line 136

 

I have searched all over the place for a solution to this, and cannot find any

references to this issue. I would think someone else would have noticed this after all these years. Or maybe its

simply something that only I am capable of screwing up! :)

 

The website seems to be functioning well in regards to SEO, as far as I can tell, so I really dont understand this.

 

AS I searched through the file, it does appear that, at least in html_ouput, the variable isn't defined. So I went ahead and

added the variable at the beginning of the script and set it to false. Unfortunately that doesn't seem to do anything.

 

Unfortunately I am still a mere novice where PHP is concerned, and I am afraid if I get too carried away I may break something.

 

Is there anyone out there who can help me with this? Below is the code which as far as I can remember has not been modified

except for the security patch in 2006: THANKS IN ADVANCE!!!!

 

//// START NEW SEO CODE

 

 

function implode_assoc($array, $inner_glue='=', $outer_glue='&') {

$output = array();

foreach( $array as $key => $item )

$output[] = $key . $inner_glue . $item;

 

return implode($outer_glue, $output);

}

 

function short_name($str, $limit=3){

if (defined('SEO_URLS_FILTER_SHORT_WORDS')) $limit = SEO_URLS_FILTER_SHORT_WORDS;

$foo = explode('-', $str);

foreach($foo as $index => $value){

switch (true){

case ( strlen($value) <= $limit ):

continue;

default:

$container[] = $value;

break;

}

} # end foreach

$container = ( sizeof($container) > 1 ? implode('-', $container) : $str );

return $container;

}

 

////

// The HTML href link wrapper function

function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {

global $request_type, $session_started, $SID;

 

$seo = ( defined('SEO_URLS') ? SEO_URLS : false );

$seo_rewrite_type = ( defined('SEO_URLS_TYPE') ? SEO_URLS_TYPE : false );

$seo_pages = array('index.php', 'product_info.php');

if ( !in_array($page, $seo_pages) ) $seo = false;

 

if (!tep_not_null($page)) {

die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');

}

 

if ($page == '/') $page = '';

 

if ($connection == 'NONSSL') {

$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

$seo_link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

$seo_rewrite_link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

} elseif ($connection == 'SSL') {

if (ENABLE_SSL == true) {

$link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

$seo_link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

$seo_rewrite_link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

} else {

$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

$seo_link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

$seo_rewrite_link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

}

} else {

die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>');

}

 

if (tep_not_null($parameters)) {

$link .= $page . '?' . tep_output_string($parameters);

$separator = '&';

 

# Start exploding the parameters to extract the values

# Also, we could use parse_str($parameters) and would probably be more clean

if ($seo == 'true'){

$p = explode('&', $parameters);

krsort($p);

$params = array();

 

if ( $seo_rewrite_type == 'Rewrite' ){

foreach ($p as $index => $valuepair) {

$p2 = explode('=', $valuepair);

switch ($p2[0]){

case 'products_id':

$rewrite_product = true;

if ( defined('PRODUCT_NAME_'.$p2[1]) ){

$rewrite_page_product = short_name(constant('PRODUCT_NAME_'.$p2[1])) . '-p-' . $p2[1] . '.html';

} else { $seo = false; }

break;

 

case 'cPath':

$rewrite_category = true;

if ( defined('CATEGORY_NAME_'.$p2[1]) ){

$rewrite_page_category = short_name(constant('CATEGORY_NAME_'.$p2[1])) . '-c-' . $p2[1] . '.html';

} else { $seo = false; }

break;

 

// manufacturer addition by WebPixie

case 'manufacturers_id':

$rewrite_manufacturer = true;

if ( defined('MANUFACTURER_NAME_'.$p2[1]) ){

$rewrite_page_manufacturer = short_name(constant('MANUFACTURER_NAME_'.$p2[1])) . '-m-' . $p2[1] . '.html';

} else { $seo = false; }

break;

// end manufacturer addition by WebPixie

 

default:

$params[$p2[0]] = $p2[1];

break;

} # switch

} # end foreach

$params_stripped = implode_assoc($params);

switch (true){

case ( $rewrite_product && $rewrite_category ):

case ( $rewrite_product ):

$rewrite_page = $rewrite_page_product;

$rewrite_category = false;

break;

case ( $rewrite_category ):

$rewrite_page = $rewrite_page_category;

break;

// manufacturer addition by WebPixie

case ( $rewrite_manufacturer ):

$rewrite_page = $rewrite_page_manufacturer;

break;

// end manufacturer addition by WebPixie

default:

$seo = false;

break;

} #end switch true

$seo_rewrite_link .= $rewrite_page . ( tep_not_null($params_stripped) ? '?'.tep_output_string($params_stripped) : '' );

$separator = ( tep_not_null($params_stripped) ? '&' : '?' );

} else {

foreach ($p as $index => $valuepair) {

$p2 = explode('=', $valuepair);

switch ($p2[0]){

case 'products_id':

if ( defined('PRODUCT_NAME_'.$p2[1]) ){

$params['pName'] = constant('PRODUCT_NAME_'.$p2[1]);

} else { $seo = false; }

break;

 

case 'cPath':

if ( defined('CATEGORY_NAME_'.$p2[1]) ){

$params['cName'] = constant('CATEGORY_NAME_'.$p2[1]);

} else { $seo = false; }

break;

 

// manufacturer addition by WebPixie

case 'manufacturers_id':

if ( defined('MANUFACTURER_NAME_'.$p2[1]) ){

$params['mName'] = constant('MANUFACTURER_NAME_'.$p2[1]);

} else { $seo = false; }

break;

// end manufacturer addition by WebPixie

 

default:

$params[$p2[0]] = $p2[1];

break;

} # switch

} # end foreach

$params_stripped = implode_assoc($params);

$seo_link .= $page . '?'.tep_output_string($params_stripped);

$separator = '&';

} # end if/else

} # end if $seo

} else {

$link .= $page;

$separator = '?';

$seo = false;

} # end if(tep_not_null($parameters)

 

while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

 

// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined

if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {

if (tep_not_null($SID)) {

$_sid = $SID;

} elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {

if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {

$_sid = tep_session_name() . '=' . tep_session_id();

}

}

}

 

if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {

while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);

while (strstr($seo_link, '&&')) $seo_link = str_replace('&&', '&', $seo_link);

 

$link = str_replace('?', '/', $link);

$link = str_replace('&', '/', $link);

$link = str_replace('=', '/', $link);

$seo_link = str_replace('?', '/', $seo_link);

$seo_link = str_replace('&', '/', $seo_link);

$seo_link = str_replace('=', '/', $seo_link);

$seo_rewrite_link = str_replace('?', '/', $seo_rewrite_link);

$seo_rewrite_link = str_replace('&', '/', $seo_rewrite_link);

$seo_rewrite_link = str_replace('=', '/', $seo_rewrite_link);

 

$separator = '?';

}

 

if (!tep_session_is_registered('customer_id') && ENABLE_PAGE_CACHE == 'true' && class_exists('page_cache')) {

$link .= $separator . '<Csid>';

$seo_link .= $separator . '<Csid>';

$seo_rewrite_link .= $separator . '<Csid>';

} elseif (isset($_sid)) {

$link .= $separator . tep_output_string($_sid);

$seo_link .= $separator . tep_output_string($_sid);

$seo_rewrite_link .= $separator . tep_output_string($_sid);

}

 

if ($seo == 'true') {

return ($seo_rewrite_type == 'Rewrite' ? $seo_rewrite_link : $seo_link);

} else {

return $link;

}

}

 

 

 

//// END NEW SEO CODE

Link to comment
Share on other sites

  • 4 months later...

I've been using Chemo's great contribution for as long as I can remember without any problems.

 

Today though, I discovered something unusual. I am starting to pay more attention to my error logs and

reporting and discovered these two entries(multiplied by a lot of the same with different timestamps) When I turn on

error logging the file gets very large in only seconds, filled mostly with these errors.

 

 

PHP Notice: Undefined variable: rewrite_product in /home/...../public_html/includes/functions/html_output.php on line 131

PHP Notice: Undefined variable: rewrite_product in /home/...../public_html/includes/functions/html_output.php on line 132

PHP Notice: Undefined variable: rewrite_category in /home/...../public_html/includes/functions/html_output.php on line 131

PHP Notice: Undefined variable: rewrite_category in /home/...../public_html/includes/functions/html_output.php on line 136

 

I have searched all over the place for a solution to this, and cannot find any

references to this issue. I would think someone else would have noticed this after all these years. Or maybe its

simply something that only I am capable of screwing up! :)

 

The website seems to be functioning well in regards to SEO, as far as I can tell, so I really dont understand this.

 

AS I searched through the file, it does appear that, at least in html_ouput, the variable isn't defined. So I went ahead and

added the variable at the beginning of the script and set it to false. Unfortunately that doesn't seem to do anything.

 

Unfortunately I am still a mere novice where PHP is concerned, and I am afraid if I get too carried away I may break something.

 

Is there anyone out there who can help me with this? Below is the code which as far as I can remember has not been modified

except for the security patch in 2006: THANKS IN ADVANCE!!!!

 

//// START NEW SEO CODE

 

 

function implode_assoc($array, $inner_glue='=', $outer_glue='&') {

$output = array();

foreach( $array as $key => $item )

$output[] = $key . $inner_glue . $item;

 

return implode($outer_glue, $output);

}

 

function short_name($str, $limit=3){

if (defined('SEO_URLS_FILTER_SHORT_WORDS')) $limit = SEO_URLS_FILTER_SHORT_WORDS;

$foo = explode('-', $str);

foreach($foo as $index => $value){

switch (true){

case ( strlen($value) <= $limit ):

continue;

default:

$container[] = $value;

break;

}

} # end foreach

$container = ( sizeof($container) > 1 ? implode('-', $container) : $str );

return $container;

}

 

////

// The HTML href link wrapper function

function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {

global $request_type, $session_started, $SID;

 

$seo = ( defined('SEO_URLS') ? SEO_URLS : false );

$seo_rewrite_type = ( defined('SEO_URLS_TYPE') ? SEO_URLS_TYPE : false );

$seo_pages = array('index.php', 'product_info.php');

if ( !in_array($page, $seo_pages) ) $seo = false;

 

if (!tep_not_null($page)) {

die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');

}

 

if ($page == '/') $page = '';

 

if ($connection == 'NONSSL') {

$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

$seo_link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

$seo_rewrite_link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

} elseif ($connection == 'SSL') {

if (ENABLE_SSL == true) {

$link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

$seo_link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

$seo_rewrite_link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

} else {

$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

$seo_link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

$seo_rewrite_link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

}

} else {

die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>');

}

 

if (tep_not_null($parameters)) {

$link .= $page . '?' . tep_output_string($parameters);

$separator = '&';

 

# Start exploding the parameters to extract the values

# Also, we could use parse_str($parameters) and would probably be more clean

if ($seo == 'true'){

$p = explode('&', $parameters);

krsort($p);

$params = array();

 

if ( $seo_rewrite_type == 'Rewrite' ){

foreach ($p as $index => $valuepair) {

$p2 = explode('=', $valuepair);

switch ($p2[0]){

case 'products_id':

$rewrite_product = true;

if ( defined('PRODUCT_NAME_'.$p2[1]) ){

$rewrite_page_product = short_name(constant('PRODUCT_NAME_'.$p2[1])) . '-p-' . $p2[1] . '.html';

} else { $seo = false; }

break;

 

case 'cPath':

$rewrite_category = true;

if ( defined('CATEGORY_NAME_'.$p2[1]) ){

$rewrite_page_category = short_name(constant('CATEGORY_NAME_'.$p2[1])) . '-c-' . $p2[1] . '.html';

} else { $seo = false; }

break;

 

// manufacturer addition by WebPixie

case 'manufacturers_id':

$rewrite_manufacturer = true;

if ( defined('MANUFACTURER_NAME_'.$p2[1]) ){

$rewrite_page_manufacturer = short_name(constant('MANUFACTURER_NAME_'.$p2[1])) . '-m-' . $p2[1] . '.html';

} else { $seo = false; }

break;

// end manufacturer addition by WebPixie

 

default:

$params[$p2[0]] = $p2[1];

break;

} # switch

} # end foreach

$params_stripped = implode_assoc($params);

switch (true){

case ( $rewrite_product && $rewrite_category ):

case ( $rewrite_product ):

$rewrite_page = $rewrite_page_product;

$rewrite_category = false;

break;

case ( $rewrite_category ):

$rewrite_page = $rewrite_page_category;

break;

// manufacturer addition by WebPixie

case ( $rewrite_manufacturer ):

$rewrite_page = $rewrite_page_manufacturer;

break;

// end manufacturer addition by WebPixie

default:

$seo = false;

break;

} #end switch true

$seo_rewrite_link .= $rewrite_page . ( tep_not_null($params_stripped) ? '?'.tep_output_string($params_stripped) : '' );

$separator = ( tep_not_null($params_stripped) ? '&' : '?' );

} else {

foreach ($p as $index => $valuepair) {

$p2 = explode('=', $valuepair);

switch ($p2[0]){

case 'products_id':

if ( defined('PRODUCT_NAME_'.$p2[1]) ){

$params['pName'] = constant('PRODUCT_NAME_'.$p2[1]);

} else { $seo = false; }

break;

 

case 'cPath':

if ( defined('CATEGORY_NAME_'.$p2[1]) ){

$params['cName'] = constant('CATEGORY_NAME_'.$p2[1]);

} else { $seo = false; }

break;

 

// manufacturer addition by WebPixie

case 'manufacturers_id':

if ( defined('MANUFACTURER_NAME_'.$p2[1]) ){

$params['mName'] = constant('MANUFACTURER_NAME_'.$p2[1]);

} else { $seo = false; }

break;

// end manufacturer addition by WebPixie

 

default:

$params[$p2[0]] = $p2[1];

break;

} # switch

} # end foreach

$params_stripped = implode_assoc($params);

$seo_link .= $page . '?'.tep_output_string($params_stripped);

$separator = '&';

} # end if/else

} # end if $seo

} else {

$link .= $page;

$separator = '?';

$seo = false;

} # end if(tep_not_null($parameters)

 

while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

 

// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined

if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {

if (tep_not_null($SID)) {

$_sid = $SID;

} elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {

if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {

$_sid = tep_session_name() . '=' . tep_session_id();

}

}

}

 

if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {

while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);

while (strstr($seo_link, '&&')) $seo_link = str_replace('&&', '&', $seo_link);

 

$link = str_replace('?', '/', $link);

$link = str_replace('&', '/', $link);

$link = str_replace('=', '/', $link);

$seo_link = str_replace('?', '/', $seo_link);

$seo_link = str_replace('&', '/', $seo_link);

$seo_link = str_replace('=', '/', $seo_link);

$seo_rewrite_link = str_replace('?', '/', $seo_rewrite_link);

$seo_rewrite_link = str_replace('&', '/', $seo_rewrite_link);

$seo_rewrite_link = str_replace('=', '/', $seo_rewrite_link);

 

$separator = '?';

}

 

if (!tep_session_is_registered('customer_id') && ENABLE_PAGE_CACHE == 'true' && class_exists('page_cache')) {

$link .= $separator . '<Csid>';

$seo_link .= $separator . '<Csid>';

$seo_rewrite_link .= $separator . '<Csid>';

} elseif (isset($_sid)) {

$link .= $separator . tep_output_string($_sid);

$seo_link .= $separator . tep_output_string($_sid);

$seo_rewrite_link .= $separator . tep_output_string($_sid);

}

 

if ($seo == 'true') {

return ($seo_rewrite_type == 'Rewrite' ? $seo_rewrite_link : $seo_link);

} else {

return $link;

}

}

 

 

 

//// END NEW SEO CODE

 

 

I still have this problem. Anyone? Please??

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...