Latest News: (loading..)
FWR Media

ULTIMATE Seo Urls 5 - by FWR Media

4,298 posts in this topic

Doooh !!

the bug was between the chair and the computer, as usual... ;)

So I uploaded this files (wich seems like the exact copy of the one I manually did, without the comments), and tadaaam ! it works, even in the category box on the left !

I can't understand why.

But you could run some test to see if the conversion works for the categorie menu when you use the configuration directive and not the file...

 

Thanks a lot anyway :)

 

My pleasure, glad you got it working.

Share this post


Link to post
Share on other sites

Buy now buttons and split page results showing wrong uris

 

Two people so far (guigs and a12c4magic) have had issues where incorrect links were produced for buy now buttons and the split page results links.

 

This has now been solved thanks to guigs who very generously gave me access to his live shop to find the issue .. thanks guigs.

 

So what was it?

 

$PHP_SELF ($_SERVER['PHP_SELF']) is used in osCommerce to identify the current page PHP_SELF however should not be used for several reasons the main ones being that it can be spoofed and is unreliable. In this case basename($PHP_SELF) as used in split_page_results.php was not returning the current file but returning part of an seo url like .. my-product-c-32. The correct thing to do is use the reliable $_SERVER['SCRIPT_NAME'] instead.

 

What do I do to make it work?

 

catalog/includes/application_top.php

 

Find ..

 

  if (!isset($PHP_SELF)) $PHP_SELF = basename($_SERVER['SCRIPT_NAME']);

 

Replace with ..

 

  if( !isset($PHP_SELF) || (isset($PHP_SELF) && (false === (substr(basename($PHP_SELF), -4, 4) == '.php'))) ){
$PHP_SELF = basename($_SERVER['SCRIPT_NAME']);
 }

Edited by FWR Media

Share this post


Link to post
Share on other sites
Try the following to fix your broken contribution ..

 

includes/boxes/categories.php

 

Find ...

 

	$categories_array[] = array('id' => $path . $parent_id . '_' .$categories['categories_id'],

 

Change to ...

 

  $categories_array[] = array('id' => ltrim($path . $parent_id . '_' .$categories['categories_id'], '_'),

 

Thanks a million, works perfectly! I must say this is the fastest response I've seen on a Forum and excellent advice as well ... top notch!

Share this post


Link to post
Share on other sites

New revision uploaded

 

This is the first revision to be a "release candidate".

 

Very minor changes and unimportant unless you suffered the buy now button/split page issue due to PHP_SELF.

 

Changelog:

 

Thanks to all those who posted language character conversions.

 

1) Added Turkish character conversion

 

2) Corrected use of strpos in two files

catalog/includes/modules/ultimate_seo_urls5/Usu_Articles.php

catalog/includes/modules/ultimate_seo_urls5/Usu_Categories.php

 

3) Corrected the RewriteRules in upgrade.html for the Links Manager II contribution

 

4) Added Swedish character conversion

 

5) Fixed buy now button and split page results incorrect links.

 

On some servers basename($_SERVER['PHP_SELF'] does not return the expected filename,

code in application_top.php has been changed to force use of the correct $_SERVER['SCRIPT_NAME'].

Edited by FWR Media

Share this post


Link to post
Share on other sites

I would like to try to install this contribution again on my "live" site. All is well on the localhost.

 

I will be doing an upgrade from series 2. Last time I tried this I made a mistake somewhere and the site was down for almost an hour before I could restore from a backup. Needless to say I'm a little bit nervous.

 

I would like to check in stages if I'm doing things correctly.

Share this post


Link to post
Share on other sites
I would like to try to install this contribution again on my "live" site. All is well on the localhost.

 

I will be doing an upgrade from series 2. Last time I tried this I made a mistake somewhere and the site was down for almost an hour before I could restore from a backup. Needless to say I'm a little bit nervous.

 

I would like to check in stages if I'm doing things correctly.

 

There only 7 osCommerce files that are changed .. and the changes are small changes .. nothing complex.

 

I would suggest backing up those 7 files so you have an immediate restore point then follow the instructions very carefully.

Share this post


Link to post
Share on other sites

hi fwr media,

Is ULTIMATE_Seo_Urls_5_r67_beta compatible with HeaderTags_SEO_V_3.1.5 on rc2a store? i tried ultimate seo on fresh install and everything works, but when i add header tag, i get parse error on both catalog and admin. i alrso reversed with header tags on fresh store and ultimate seo afterwards, but with same result. after editing the aplication top.php, i manage to get the urls working but header tag seems to broken. however, i stillg et parse erro on admin

here is the error i get on

- Parse error: syntax error, unexpected '{' in /home/mantrabo/public_html/admin/includes/functions/general.php on line 1386

Share this post


Link to post
Share on other sites
hi fwr media,

Is ULTIMATE_Seo_Urls_5_r67_beta compatible with HeaderTags_SEO_V_3.1.5 on rc2a store? i tried ultimate seo on fresh install and everything works, but when i add header tag, i get parse error on both catalog and admin. i alrso reversed with header tags on fresh store and ultimate seo afterwards, but with same result. after editing the aplication top.php, i manage to get the urls working but header tag seems to broken. however, i stillg et parse erro on admin

here is the error i get on

- Parse error: syntax error, unexpected '{' in /home/mantrabo/public_html/admin/includes/functions/general.php on line 1386

 

No this issue is not created by USU5 you have applied header tags code incorrectly or there is a problem with the contribution (which I doubt)

Edited by FWR Media

Share this post


Link to post
Share on other sites
No this issue is not created by USU5 you have applied header tags code incorrectly or there is a problem with the contribution (which I doubt)

yes, you are right. i tried your contribution on fresh store and it was working perfectly. Could you recommend which of these two contribution to install first on fresh store? thank you very much for your quick replay.

Share this post


Link to post
Share on other sites

Hi Robert, I havent installed this (yet), but it looks an excellent contrib. ;)

 

I just have one quick question, can it be used to 'hide' the sid

Share this post


Link to post
Share on other sites
Hi Robert, I havent installed this (yet), but it looks an excellent contrib. ;)

 

I just have one quick question, can it be used to 'hide' the sid

 

 

No and neither should it .. concepts like the sid killer imo are flawed. When you are dealing with a stateless protocol (as we are) you can either force the immediate use of cookies or pass the sid initially via _GET .. after all users can turn cookies off. If a user has cookies turned off you can run into the problem of sids posted on other sites which is why recreate session must be set to on.

Share this post


Link to post
Share on other sites

Thanks for the reply, I would just say that some have reported that having recreate session set to true caused issues on thier sites, I have not investigated what might cause that.

Share this post


Link to post
Share on other sites

hey guys!

general question:: what is this file (installer_class.php) for? do we need to run this like installer.php?

tia

Share this post


Link to post
Share on other sites
hey guys!

general question:: what is this file (installer_class.php) for? do we need to run this like installer.php?

tia

 

No .. installer.php is reliant on installer_class.php

Share this post


Link to post
Share on other sites

Hello FWR

 

I've got one question, but first thank you for this great contrib and the many other extremely good "SEO" contribs!

 

I've installed USU5 and everything works perfectly. But the contrib Google XML Sitemap SEO seems to be not compatible with USU5. The XML file "sitemapproducts.xml" and all others, e.g. now shows "...product_info.php?products_id=71" instead of my-great-product-p-37.html that confuses Google. The Google Webmaster site gives me Warnings about my XML files

 

"URLs not followed When we tested a sample of URLs from your Sitemap, we found that some URLs redirect to other locations. We recommend that your Sitemap contain URLs that point to the final destination (the redirect target) instead of redirecting to another URL."

 

With Chemos Code updated from You (2.1b original updated) The GoogleSitemaps Contrib works perfectly.

 

Has anyone else this problem?

 

Thank you for your assistance!

Share this post


Link to post
Share on other sites
Hello FWR

 

I've got one question, but first thank you for this great contrib and the many other extremely good "SEO" contribs!

 

I've installed USU5 and everything works perfectly. But the contrib Google XML Sitemap SEO seems to be not compatible with USU5. The XML file "sitemapproducts.xml" and all others, e.g. now shows "...product_info.php?products_id=71" instead of my-great-product-p-37.html that confuses Google. The Google Webmaster site gives me Warnings about my XML files

 

"URLs not followed When we tested a sample of URLs from your Sitemap, we found that some URLs redirect to other locations. We recommend that your Sitemap contain URLs that point to the final destination (the redirect target) instead of redirecting to another URL."

 

With Chemos Code updated from You (2.1b original updated) The GoogleSitemaps Contrib works perfectly.

 

Has anyone else this problem?

 

Thank you for your assistance!

 

 

The "GoogleSitemaps Contrib" uses non-osc standard coding to make the links/urls.

 

To fix this simply modify it to use the standard osc link coding and it will work with usu5.

Edited by toyicebear

Share this post


Link to post
Share on other sites
Hello FWR

 

I've got one question, but first thank you for this great contrib and the many other extremely good "SEO" contribs!

 

I've installed USU5 and everything works perfectly. But the contrib Google XML Sitemap SEO seems to be not compatible with USU5. The XML file "sitemapproducts.xml" and all others, e.g. now shows "...product_info.php?products_id=71" instead of my-great-product-p-37.html that confuses Google. The Google Webmaster site gives me Warnings about my XML files

 

"URLs not followed When we tested a sample of URLs from your Sitemap, we found that some URLs redirect to other locations. We recommend that your Sitemap contain URLs that point to the final destination (the redirect target) instead of redirecting to another URL."

 

With Chemos Code updated from You (2.1b original updated) The GoogleSitemaps Contrib works perfectly.

 

Has anyone else this problem?

 

Thank you for your assistance!

 

For some reason Jack has hardcoded in the includes instead of using application_top.php .. he has also hardcoded in the inclusion of series 2 seo urls so .. no it won't work.

Share this post


Link to post
Share on other sites
Hello FWR

 

I've got one question, but first thank you for this great contrib and the many other extremely good "SEO" contribs!

 

I've installed USU5 and everything works perfectly. But the contrib Google XML Sitemap SEO seems to be not compatible with USU5. The XML file "sitemapproducts.xml" and all others, e.g. now shows "...product_info.php?products_id=71" instead of my-great-product-p-37.html that confuses Google. The Google Webmaster site gives me Warnings about my XML files

 

"URLs not followed When we tested a sample of URLs from your Sitemap, we found that some URLs redirect to other locations. We recommend that your Sitemap contain URLs that point to the final destination (the redirect target) instead of redirecting to another URL."

 

With Chemos Code updated from You (2.1b original updated) The GoogleSitemaps Contrib works perfectly.

 

Has anyone else this problem?

 

Thank you for your assistance!

 

Try replacing two files as follows: -

 

These files make far more sense and are far shorter than the ones written by Chemo .. for some reason he loved to create his own DB class unnecessarily.

 

catalog/googlesitemap/index.php

catalog/googlesitemap/sitemap.class

 

index.php

 

<?php
/**
* Google XML Sitemap Feed Cron Script
*
* The Google sitemap service was announced on 2 June 2005 and represents
* a huge development in terms of crawler technology.  This contribution is
* designed to create the sitemap XML feed per the specification delineated 
* by Google.  This cron script will call the code to create the scripts and 
* eliminate the session auto start issues. 
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.2
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @link http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap 
* @copyright Copyright 2005, Bobby Easland 
* @author Bobby Easland 
* @filesource
*/

chdir('../');
/**
 * Option to compress the files
 */
define('GOOGLE_SITEMAP_COMPRESS', 'false');
/**
 * Option for change frequency of products
 */
define('GOOGLE_SITEMAP_PROD_CHANGE_FREQ', 'weekly');
/**
 * Option for change frequency of categories
 */
define('GOOGLE_SITEMAP_CAT_CHANGE_FREQ', 'weekly');
/**
 * Carried over from application_top.php for compatibility
 */
define('GOOGLE_SITEMAP_MAN_CHANGE_FREQ', 'weekly');
/**
 * Carried over from application_top.php for compatibility
 */
define('GOOGLE_SITEMAP_SPECIALS_CHANGE_FREQ', 'weekly');
/**
 * Carried over from application_top.php for compatibility
 */
include_once 'includes/application_top.php';

require_once('googlesitemap/sitemap.class.php');

$google = new GoogleSitemap(DB_SERVER, DB_SERVER_USERNAME, DB_DATABASE, DB_SERVER_PASSWORD);

$submit = true;

echo '<pre>';
if ($google->GenerateProductSitemap()){
echo 'Generated Google Product Sitemap Successfully' . "\n\n";
} else {
$submit = false;
echo 'ERROR: Google Product Sitemap Generation FAILED!' . "\n\n";
}

if ($google->GenerateCategorySitemap()){
echo 'Generated Google Category Sitemap Successfully' . "\n\n";
} else {
$submit = false;
echo 'ERROR: Google Category Sitemap Generation FAILED!' . "\n\n";
}

$showManufacturers = true;
if ($google->GenerateManufacturerSitemap()){
echo 'Generated Google Manufacturers Sitemap Successfully' . "\n\n";
} else {
 $manufacturers_query = tep_db_query("select manufacturers_id from " . TABLE_MANUFACTURERS . " limit 1");
 if (tep_db_num_rows($manufacturers_query) > 0)
 {
$submit = false;
  echo 'ERROR: Google Manufacturers Sitemap Generation FAILED!' . "\n\n";
 }
 else 
 {
$showManufacturers = false;
  echo 'Google Sitemap Manufacturers not generated - no Manufacturers found!' . "\n\n";
 } 
}

$showSpecials = true;
if ($google->GenerateSpecialsSitemap()){
echo 'Generated Google Specials Sitemap Successfully' . "\n\n";
} else {
 $specials_query = tep_db_query("select p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' limit 1");
 if (tep_db_num_rows($specials_query) > 0)
 {
  $submit = false;
  echo 'ERROR: Google Specials Sitemap Generation FAILED!' . "\n\n";
 }
 else 
 {
$showSpecials = false;
  echo 'Google Sitemap Specials not generated - no specials found!' . "\n\n";
 } 
}

if ($google->GenerateSitemapIndex()){
echo 'Generated Google Sitemap Index Successfully' . "\n\n";
} else {
$submit = false;
echo 'ERROR: Google Sitemap Index Generation FAILED!' . "\n\n";
}

if ($submit){
echo 'CONGRATULATIONS! All files generated successfully.' . "\n\n";
echo 'If you have not already submitted the sitemap index to Google click the link below.' . "\n";
echo 'Before you do I HIGHLY recommend that you view the XML files to make sure the data is correct.' . "\n\n";
echo $google->GenerateSubmitURL() . "\n\n";
echo 'For your convenience here is the CRON command for your site:' . "\n";
echo 'php ' . dirname($_SERVER['SCRIPT_FILENAME']) . '/index.php' . "\n\n";
echo 'Here is your sitemap index: ' . $google->base_url . 'sitemapindex.xml' . "\n";
echo 'Here is your product sitemap: ' . $google->base_url . 'sitemapproducts.xml' . "\n";
echo 'Here is your category sitemap: ' . $google->base_url . 'sitemapcategories.xml' . "\n";

 if ($showManufacturers)
echo 'Here is your manufacturers sitemap: ' . $google->base_url . 'sitemapmanufacturers.xml' . "\n";

 if ($showSpecials)
  echo 'Here is your specials sitemap: ' . $google->base_url . 'sitemapspecials.xml' . "\n";
} else {
print_r($google->debug);
}

echo '</pre>';
include_once 'includes/application_top.php';
?>

 

sitemap.class

 

<?php
/**
* Google XML Sitemap Feed
*
* The Google sitemap service was announced on 2 June 2005 and represents
* a huge development in terms of crawler technology.  This contribution is
* designed to create the sitemap XML feed per the specification delineated 
* by Google. 
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.0
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @link http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap 
* @copyright Copyright 2005, Bobby Easland 
* @author Bobby Easland 
* @filesource
*/

/**
* MySQL_Database Class
*
* The MySQL_Database class provides abstraction so the databaes can be accessed
* without having to use tep API functions. This class has minimal error handling
* so make sure your code is tight!
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.1
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @copyright Copyright 2005, Bobby Easland 
* @author Bobby Easland 
*/

/**
* Google Sitemap Base Class
*
* The MySQL_Database class provides abstraction so the databaes can be accessed
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.2
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @link http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap
* @copyright Copyright 2005, Bobby Easland 
* @author Bobby Easland 
*/
class GoogleSitemap{
/**
	* $filename is the base name of the feeds (i.e. - 'sitemap')
* @var string
	*/
var $filename;
/**
	* $savepath is the path where the feeds will be saved - store root
* @var string
	*/
var $savepath;
/**
	* $base_url is the URL for the catalog
* @var string
	*/
var $base_url;
/**
	* $debug holds all the debug data
* @var array
	*/
var $debug;


/**
* GoogleSitemap class constructor 
* @author Bobby Easland 
* @version 1.0
* @param string $host Database host setting (i.e. - localhost)
* @param string $user Database user
* @param string $db Database name
* @param string $pass Database password
*/	
function GoogleSitemap(){
	$this->filename = "sitemap";
	$this->savepath = DIR_FS_CATALOG;
	$this->base_url = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
	$this->debug = array();
} # end class constructor

/**
* Function to save the sitemap data to file as either XML or XML.GZ format
* @author Bobby Easland 
* @version 1.1
* @param string $data XML data
* @param string $type Feed type (index, products, categories)
* @return boolean
*/	
function SaveFile($data, $type){
	$filename = $this->savepath . $this->filename . $type;			
	$compress = defined('GOOGLE_SITEMAP_COMPRESS') ? GOOGLE_SITEMAP_COMPRESS : 'false';
	if ($type == 'index') $compress = 'false';
	switch($compress){
		case 'true':
			$filename .= '.xml.gz';
			if ($gz = gzopen($filename,'wb9')){
				gzwrite($gz, $data);
				gzclose($gz);
				$this->debug['SAVE_FILE_COMPRESS'][] = array('file' => $filename, 'status' => 'success', 'file_exists' => 'true');
				return true;
			} else {
				$file_check = file_exists($filename) ? 'true' : 'false';
				$this->debug['SAVE_FILE_COMPRESS'][] = array('file' => $filename, 'status' => 'failure', 'file_exists' => $file_check);
				return false;
			}
			break;
		default:
			$filename .= '.xml';
			if ($fp = fopen($filename, 'w+')){
				 echo 'Write '.$filename.'<br>';
				fwrite($fp, $data);
				fclose($fp);
				$this->debug['SAVE_FILE_XML'][] = array('file' => $filename, 'status' => 'success', 'file_exists' => 'true');
				return true;
			} else {
				$file_check = file_exists($filename) ? 'true' : 'false';
				$this->debug['SAVE_FILE_XML'][] = array('file' => $filename, 'status' => 'failure', 'file_exists' => $file_check);
				return false;
			}
			break;
	} # end switch 
} # end function

/**
* Function to compress a normal file
* @author Bobby Easland 
* @version 1.0
* @param string $file
* @return boolean
*/	
function CompressFile($file){
	$source = $this->savepath . $file . '.xml';
	$filename = $this->savepath . $file . '.xml.gz';
	$error_encountered = false;
	if( $gz_out = gzopen($filename, 'wb9') ){
		if($fp_in = fopen($source,'rb')){
			while(!feof($fp_in)) gzwrite($gz_out, fread($fp_in, 1024*512));
				fclose($fp_in);

		} else {
			$error_encountered = true;
		}
		gzclose($gz_out);
	} else {
		$error_encountered = true;
	}
	if($error_encountered){
		return false;
	} else {
		return true;	
	}
} # end function

/**
* Function to generate sitemap file from data
* @author Bobby Easland 
* @version 1.0
* @param array $data
* @param string $file
* @return boolean
*/	
function GenerateSitemap($data, $file){
	$content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
	$content = '<?xml-stylesheet type="text/xsl" href="gss.xsl"?>' . "\n";
	$content .= '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' . "\n";
	foreach ($data as $url){
		$content .= "\t" . '<url>' . "\n";
		$content .= "\t\t" . '<loc>'.$url['loc'].'</loc>' . "\n";
		$content .= "\t\t" . '<lastmod>'.$url['lastmod'].'</lastmod>' . "\n";
		$content .= "\t\t" . '<changefreq>'.$url['changefreq'].'</changefreq>' . "\n";
		$content .= "\t\t" . '<priority>'.$url['priority'].'</priority>' . "\n";
		$content .= "\t" . '</url>' . "\n";
	} # end foreach
	$content .= '</urlset>';
	return $this->SaveFile($content, $file);
} # end function

/**
* Function to generate sitemap index file 
* @author Bobby Easland 
* @version 1.1
* @return boolean
*/	
function GenerateSitemapIndex(){
	$content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
	$content = '<?xml-stylesheet type="text/xsl" href="gss.xsl"?>' . "\n"; //human readable
	$content .= '<sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">' . "\n";		
	$pattern = defined('GOOGLE_SITEMAP_COMPRESS')
				 ?	GOOGLE_SITEMAP_COMPRESS == 'true'
				 		?	"{sitemap*.xml.gz}"
						: 	"{sitemap*.xml}"
				 :	"{sitemap*.xml}";
	foreach ( glob($this->savepath . $pattern, GLOB_BRACE) as $filename ) {
	   if ( eregi('index', $filename) ) continue;
	   $content .= "\t" . '<sitemap>' . "\n";
	   $content .= "\t\t" . '<loc>'.$this->base_url . basename($filename).'</loc>' . "\n";
	   $content .= "\t\t" . '<lastmod>'.date ("Y-m-d", filemtime($filename)).'</lastmod>' . "\n";
	   $content .= "\t" . '</sitemap>' . "\n";		   		
	} # end foreach
	$content .= '</sitemapindex>';
	return $this->SaveFile($content, 'index');
} # end function

/**
* Function to generate product sitemap data
* @author Bobby Easland 
* @version 1.1
* @return boolean
*/	
function GenerateProductSitemap(){
	$sql = "SELECT products_id as pID, products_date_added as date_added, products_last_modified as last_mod, products_ordered 
			FROM " . TABLE_PRODUCTS . " 
			WHERE products_status='1' 
			ORDER BY products_ordered DESC";
	if ( $products_query = tep_db_query($sql) ){
		$this->debug['QUERY']['PRODUCTS']['STATUS'] = 'success';
		$this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = tep_db_num_rows($products_query);
		$container = array();
		$number = 0;
		$top = 0;
		while( $result = tep_db_fetch_array($products_query) ){
			$top = max($top, $result['products_ordered']);
			$location = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
			$lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added'];
			$changefreq = GOOGLE_SITEMAP_PROD_CHANGE_FREQ;
			$ratio = $top > 0 ? $result['products_ordered']/$top : 0;
			$priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', ''); 

			$container[] = array('loc' => htmlspecialchars(utf8_encode($location)),
								 'lastmod' => date ("Y-m-d", strtotime($lastmod)),
								 'changefreq' => $changefreq,
								 'priority' => $priority
								 );
			if ( sizeof($container) >= 50000 ){
				$type = $number == 0 ? 'products' : 'products' . $number;
				$this->GenerateSitemap($container, $type);
				$container = array();
				$number++;
			}
		} # end while
		tep_db_free_result($products_query);			
		if ( sizeof($container) > 1 ) {
			$type = $number == 0 ? 'products' : 'products' . $number;
			return $this->GenerateSitemap($container, $type);
		} # end if			
	} else {
		$this->debug['QUERY']['PRODUCTS']['STATUS'] = 'false';
		$this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = '0';
	}
} # end function

/**
* Funciton to generate category sitemap data
* @author Bobby Easland 
* @version 1.1
* @return boolean
*/	
function GenerateCategorySitemap(){
	$sql = "SELECT categories_id as cID, date_added, last_modified as last_mod 
			FROM " . TABLE_CATEGORIES . " 
			ORDER BY parent_id ASC, sort_order ASC, categories_id ASC";
	if ( $categories_query = tep_db_query($sql) ){
		$this->debug['QUERY']['CATEOGRY']['STATUS'] = 'success';
		$this->debug['QUERY']['CATEOGRY']['NUM_ROWS'] = tep_db_num_rows($categories_query);
		$container = array();
		$number = 0;
		while( $result = tep_db_fetch_array($categories_query) ){
			$location =tep_href_link(FILENAME_DEFAULT, 'cPath=' . $this->GetFullcPath($result['cID']), 'NONSSL', false);
			$lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added'];
			$changefreq = GOOGLE_SITEMAP_CAT_CHANGE_FREQ;
			$priority = .5; 

			$container[] = array('loc' => htmlspecialchars(utf8_encode($location)),
								 'lastmod' => date ("Y-m-d", strtotime($lastmod)),
								 'changefreq' => $changefreq,
								 'priority' => $priority
								 );
			if ( sizeof($container) >= 50000 ){
				$type = $number == 0 ? 'categories' : 'categories' . $number;
				$this->GenerateSitemap($container, $type);
				$container = array();
				$number++;
			}
		} # end while
		tep_db_free_result($categories_query);			
		if ( sizeof($container) > 1 ) {
			$type = $number == 0 ? 'categories' : 'categories' . $number;
			return $this->GenerateSitemap($container, $type);
		} # end if			
	} else {
		$this->debug['QUERY']['CATEOGRY']['STATUS'] = 'false';
		$this->debug['QUERY']['CATEOGRY']['NUM_ROWS'] = '0';
	}
} # end function

/**
* Funciton to generate manufacturer sitemap data
* @author Jack_mcs from Bobbys code
* @version 1.1
* @return boolean
*/
function GenerateManufacturerSitemap(){
	$sql = "SELECT manufacturers_id as mID, date_added, last_modified as last_mod, manufacturers_name
			FROM " . TABLE_MANUFACTURERS . " order by manufacturers_name DESC";

	if ( $manufacturers_query = tep_db_query($sql) ){
		$this->debug['QUERY']['MANUFACTURERS']['STATUS'] = 'success';
		$this->debug['QUERY']['MANUFACTURERS']['NUM_ROWS'] = tep_db_num_rows($manufacturers_query);
		$container = array();
		$number = 0;
		while( $result = tep_db_fetch_array($manufacturers_query) ){
			$location = tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $result['mID'], 'NONSSL', false);
			$lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added'];
			$changefreq = GOOGLE_SITEMAP_MAN_CHANGE_FREQ;
			$priority = .5;

			$container[] = array('loc' => htmlspecialchars(utf8_encode($location)),
								 'lastmod' => date ("Y-m-d", strtotime($lastmod)),
								 'changefreq' => $changefreq,
								 'priority' => $priority
								 );
			if ( sizeof($container) >= 50000 ){
				$type = $number == 0 ? 'manufacturers' : 'manufacturers' . $number;
				$this->GenerateSitemap($container, $type);
				$container = array();
				$number++;
			}
		} # end while
		tep_db_free_result($manufacturers_query);
		if ( sizeof($container) > 1 ) {
			$type = $number == 0 ? 'manufacturers' : 'manufacturers' . $number;
			return $this->GenerateSitemap($container, $type);
		} # end if			
	} else {
		$this->debug['QUERY']['MANUFACTURERS']['STATUS'] = 'false';
		$this->debug['QUERY']['MANUFACTURERS']['NUM_ROWS'] = '0';
	}
} # end function

/**
* Funciton to generate manufacturer sitemap data
* @author Jack_mcs from Bobbys code
* @version 1.1
* @return boolean
*/
function GenerateSpecialsSitemap(){
	$sql = "SELECT p.products_id as pID, s.specials_date_added as date_added, s.specials_last_modified as last_mod, p.products_ordered
			FROM " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id left join " . TABLE_SPECIALS . " s on pd.products_id = s.products_id
			where p.products_status = '1' and s.status = '1' order by s.specials_date_added desc ";
	if ( $products_query = tep_db_query($sql) ){
		$this->debug['QUERY']['SPECIALS']['STATUS'] = 'success';
		$this->debug['QUERY']['SPECIALS']['NUM_ROWS'] = tep_db_num_rows($products_query);
		$container = array();
		$number = 0;
		$top = 0;
		while( $result = tep_db_fetch_array($products_query) ){
			$top = max($top, $result['products_ordered']);
			$location = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
			$lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added'];
			$changefreq = GOOGLE_SITEMAP_SPECIALS_CHANGE_FREQ;
			$ratio = $top > 0 ? $result['products_ordered']/$top : 0;
			$priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', ''); 

			$container[] = array('loc' => htmlspecialchars(utf8_encode($location)),
								 'lastmod' => date ("Y-m-d", strtotime($lastmod)),
								 'changefreq' => $changefreq,
								 'priority' => $priority
								 );
			if ( sizeof($container) >= 50000 ){
				$type = $number == 0 ? 'specials' : 'specials' . $number;
				$this->GenerateSitemap($container, $type);
				$container = array();
				$number++;
			}
		} # end while
		tep_db_free_result($products_query);			
		if ( sizeof($container) > 1 ) {
			$type = $number == 0 ? 'specials' : 'specials' . $number;
			return $this->GenerateSitemap($container, $type);
		} # end if			
	} else {
		$this->debug['QUERY']['SPECIALS']['STATUS'] = 'false';
		$this->debug['QUERY']['SPECIALS']['NUM_ROWS'] = '0';
	}
} # end function

/**
* Function to retrieve full cPath from category ID 
* @author Bobby Easland 
* @version 1.0
* @param mixed $cID Could contain cPath or single category_id
* @return string Full cPath string
*/	
function GetFullcPath($cID){
	if ( ereg('_', $cID) ){
		return $cID;
	} else {
		$c = array();
		$this->GetParentCategories($c, $cID);
		$c = array_reverse($c);
		$c[] = $cID;
		$cID = sizeof($c) > 1 ? implode('_', $c) : $cID;
		return $cID;
	}
} # end function

/**
* Recursion function to retrieve parent categories from category ID 
* @author Bobby Easland 
* @version 1.0
* @param mixed $categories Passed by reference
* @param integer $categories_id
*/	
function GetParentCategories(&$categories, $categories_id) {
	$sql = "SELECT parent_id 
			FROM " . TABLE_CATEGORIES . " 
			WHERE categories_id='" . (int)$categories_id . "'";
	$parent_categories_query = tep_db_query($sql);
	while ($parent_categories = tep_db_fetch_array($parent_categories_query)) {
		if ($parent_categories['parent_id'] == 0) return true;
		$categories[sizeof($categories)] = $parent_categories['parent_id'];
		if ($parent_categories['parent_id'] != $categories_id) {
			$this->GetParentCategories($categories, $parent_categories['parent_id']);
		}
	}
} # end function

/**
* Utility function to read and return the contents of a GZ formatted file
* @author Bobby Easland 
* @version 1.0
* @param string $file File to open
* @return string
*/	
function ReadGZ( $file ){
	$file = $this->savepath . $file;
	$lines = gzfile($file);
	return implode('', $lines);
} # end function

/**
* Utility function to generate the submit URL 
* @author Bobby Easland 
* @version 1.0
* @return string
*/	
function GenerateSubmitURL(){
	$url = urlencode($this->base_url . 'sitemapindex.xml');
	return htmlspecialchars(utf8_encode('http://www.google.com/webmasters/sitemaps/ping?sitemap=' . $url));
} # end function
} #  end class
?>

Share this post


Link to post
Share on other sites

Ooops (index.php) the line at the bottom should have been application_bottom.php

 

<?php
/**
* Google XML Sitemap Feed Cron Script
*
* The Google sitemap service was announced on 2 June 2005 and represents
* a huge development in terms of crawler technology.  This contribution is
* designed to create the sitemap XML feed per the specification delineated
* by Google.  This cron script will call the code to create the scripts and
* eliminate the session auto start issues.
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.2
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @link http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap
* @copyright Copyright 2005, Bobby Easland
* @author Bobby Easland
* @filesource
*/

chdir('../');
/**
 * Option to compress the files
 */
define('GOOGLE_SITEMAP_COMPRESS', 'false');
/**
 * Option for change frequency of products
 */
define('GOOGLE_SITEMAP_PROD_CHANGE_FREQ', 'weekly');
/**
 * Option for change frequency of categories
 */
define('GOOGLE_SITEMAP_CAT_CHANGE_FREQ', 'weekly');
/**
 * Carried over from application_top.php for compatibility
 */
define('GOOGLE_SITEMAP_MAN_CHANGE_FREQ', 'weekly');
/**
 * Carried over from application_top.php for compatibility
 */
define('GOOGLE_SITEMAP_SPECIALS_CHANGE_FREQ', 'weekly');
/**
 * Carried over from application_top.php for compatibility
 */
include_once 'includes/application_top.php';

require_once('googlesitemap/sitemap.class.php');

$google = new GoogleSitemap(DB_SERVER, DB_SERVER_USERNAME, DB_DATABASE, DB_SERVER_PASSWORD);

$submit = true;

echo '<pre>';
if ($google->GenerateProductSitemap()){
echo 'Generated Google Product Sitemap Successfully' . "\n\n";
} else {
$submit = false;
echo 'ERROR: Google Product Sitemap Generation FAILED!' . "\n\n";
}

if ($google->GenerateCategorySitemap()){
echo 'Generated Google Category Sitemap Successfully' . "\n\n";
} else {
$submit = false;
echo 'ERROR: Google Category Sitemap Generation FAILED!' . "\n\n";
}

$showManufacturers = true;
if ($google->GenerateManufacturerSitemap()){
echo 'Generated Google Manufacturers Sitemap Successfully' . "\n\n";
} else {
 $manufacturers_query = tep_db_query("select manufacturers_id from " . TABLE_MANUFACTURERS . " limit 1");
 if (tep_db_num_rows($manufacturers_query) > 0)
 {
$submit = false;
  echo 'ERROR: Google Manufacturers Sitemap Generation FAILED!' . "\n\n";
 }
 else
 {
$showManufacturers = false;
  echo 'Google Sitemap Manufacturers not generated - no Manufacturers found!' . "\n\n";
 }
}

$showSpecials = true;
if ($google->GenerateSpecialsSitemap()){
echo 'Generated Google Specials Sitemap Successfully' . "\n\n";
} else {
 $specials_query = tep_db_query("select p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' limit 1");
 if (tep_db_num_rows($specials_query) > 0)
 {
  $submit = false;
  echo 'ERROR: Google Specials Sitemap Generation FAILED!' . "\n\n";
 }
 else
 {
$showSpecials = false;
  echo 'Google Sitemap Specials not generated - no specials found!' . "\n\n";
 }
}

if ($google->GenerateSitemapIndex()){
echo 'Generated Google Sitemap Index Successfully' . "\n\n";
} else {
$submit = false;
echo 'ERROR: Google Sitemap Index Generation FAILED!' . "\n\n";
}

if ($submit){
echo 'CONGRATULATIONS! All files generated successfully.' . "\n\n";
echo 'If you have not already submitted the sitemap index to Google click the link below.' . "\n";
echo 'Before you do I HIGHLY recommend that you view the XML files to make sure the data is correct.' . "\n\n";
echo $google->GenerateSubmitURL() . "\n\n";
echo 'For your convenience here is the CRON command for your site:' . "\n";
echo 'php ' . dirname($_SERVER['SCRIPT_FILENAME']) . '/index.php' . "\n\n";
echo 'Here is your sitemap index: ' . $google->base_url . 'sitemapindex.xml' . "\n";
echo 'Here is your product sitemap: ' . $google->base_url . 'sitemapproducts.xml' . "\n";
echo 'Here is your category sitemap: ' . $google->base_url . 'sitemapcategories.xml' . "\n";

 if ($showManufacturers)
echo 'Here is your manufacturers sitemap: ' . $google->base_url . 'sitemapmanufacturers.xml' . "\n";

 if ($showSpecials)
  echo 'Here is your specials sitemap: ' . $google->base_url . 'sitemapspecials.xml' . "\n";
} else {
print_r($google->debug);
}

echo '</pre>';
include_once 'includes/application_bottom.php';
?>

Edited by FWR Media

Share this post


Link to post
Share on other sites
Ooops (index.php) the line at the bottom should have been application_bottom.php

 

<?php
/**
* Google XML Sitemap Feed Cron Script
*
* The Google sitemap service was announced on 2 June 2005 and represents
* a huge development in terms of crawler technology.  This contribution is
* designed to create the sitemap XML feed per the specification delineated
* by Google.  This cron script will call the code to create the scripts and
* eliminate the session auto start issues.
* @package Google-XML-Sitemap-Feed
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version 1.2
* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
* @link http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap
* @copyright Copyright 2005, Bobby Easland
* @author Bobby Easland
* @filesource
*/

chdir('../');
/**
 * Option to compress the files
 */
define('GOOGLE_SITEMAP_COMPRESS', 'false');
/**
 * Option for change frequency of products
 */
define('GOOGLE_SITEMAP_PROD_CHANGE_FREQ', 'weekly');
/**
 * Option for change frequency of categories
 */
define('GOOGLE_SITEMAP_CAT_CHANGE_FREQ', 'weekly');
/**
 * Carried over from application_top.php for compatibility
 */
define('GOOGLE_SITEMAP_MAN_CHANGE_FREQ', 'weekly');
/**
 * Carried over from application_top.php for compatibility
 */
define('GOOGLE_SITEMAP_SPECIALS_CHANGE_FREQ', 'weekly');
/**
 * Carried over from application_top.php for compatibility
 */
include_once 'includes/application_top.php';

require_once('googlesitemap/sitemap.class.php');

$google = new GoogleSitemap(DB_SERVER, DB_SERVER_USERNAME, DB_DATABASE, DB_SERVER_PASSWORD);

$submit = true;

echo '<pre>';
if ($google->GenerateProductSitemap()){
echo 'Generated Google Product Sitemap Successfully' . "\n\n";
} else {
$submit = false;
echo 'ERROR: Google Product Sitemap Generation FAILED!' . "\n\n";
}

if ($google->GenerateCategorySitemap()){
echo 'Generated Google Category Sitemap Successfully' . "\n\n";
} else {
$submit = false;
echo 'ERROR: Google Category Sitemap Generation FAILED!' . "\n\n";
}

$showManufacturers = true;
if ($google->GenerateManufacturerSitemap()){
echo 'Generated Google Manufacturers Sitemap Successfully' . "\n\n";
} else {
 $manufacturers_query = tep_db_query("select manufacturers_id from " . TABLE_MANUFACTURERS . " limit 1");
 if (tep_db_num_rows($manufacturers_query) > 0)
 {
$submit = false;
  echo 'ERROR: Google Manufacturers Sitemap Generation FAILED!' . "\n\n";
 }
 else
 {
$showManufacturers = false;
  echo 'Google Sitemap Manufacturers not generated - no Manufacturers found!' . "\n\n";
 }
}

$showSpecials = true;
if ($google->GenerateSpecialsSitemap()){
echo 'Generated Google Specials Sitemap Successfully' . "\n\n";
} else {
 $specials_query = tep_db_query("select p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' limit 1");
 if (tep_db_num_rows($specials_query) > 0)
 {
  $submit = false;
  echo 'ERROR: Google Specials Sitemap Generation FAILED!' . "\n\n";
 }
 else
 {
$showSpecials = false;
  echo 'Google Sitemap Specials not generated - no specials found!' . "\n\n";
 }
}

if ($google->GenerateSitemapIndex()){
echo 'Generated Google Sitemap Index Successfully' . "\n\n";
} else {
$submit = false;
echo 'ERROR: Google Sitemap Index Generation FAILED!' . "\n\n";
}

if ($submit){
echo 'CONGRATULATIONS! All files generated successfully.' . "\n\n";
echo 'If you have not already submitted the sitemap index to Google click the link below.' . "\n";
echo 'Before you do I HIGHLY recommend that you view the XML files to make sure the data is correct.' . "\n\n";
echo $google->GenerateSubmitURL() . "\n\n";
echo 'For your convenience here is the CRON command for your site:' . "\n";
echo 'php ' . dirname($_SERVER['SCRIPT_FILENAME']) . '/index.php' . "\n\n";
echo 'Here is your sitemap index: ' . $google->base_url . 'sitemapindex.xml' . "\n";
echo 'Here is your product sitemap: ' . $google->base_url . 'sitemapproducts.xml' . "\n";
echo 'Here is your category sitemap: ' . $google->base_url . 'sitemapcategories.xml' . "\n";

 if ($showManufacturers)
echo 'Here is your manufacturers sitemap: ' . $google->base_url . 'sitemapmanufacturers.xml' . "\n";

 if ($showSpecials)
  echo 'Here is your specials sitemap: ' . $google->base_url . 'sitemapspecials.xml' . "\n";
} else {
print_r($google->debug);
}

echo '</pre>';
include_once 'includes/application_bottom.php';
?>

 

 

Thank you very much for your fast reply.

 

I've changed the files and it works with the exception of displaying the special chars. Now the output is e.g. "...catalog/kyosho-mini-inferno-alu-dämpferbrücke-vorne-p-45.html"! My Shop has german language as default so i use the german conversion file!

 

Is it possible to integrate them into the XML files?

 

Thank you for your kind assistance!

Share this post


Link to post
Share on other sites
Thank you very much for your fast reply.

 

I've changed the files and it works with the exception of displaying the special chars. Now the output is e.g. "...catalog/kyosho-mini-inferno-alu-dämpferbrücke-vorne-p-45.html"! My Shop has german language as default so i use the german conversion file!

 

Is it possible to integrate them into the XML files?

 

Thank you for your kind assistance!

 

Well that is very odd the xml file is now using the standard tep_href_link so should be producing exactly the same uris as the site.

 

Could you do two things please.

 

1) Hover over that same link kyosho-mini-inferno-alu-dämpferbrücke-vorne-p-45.html on your site and post back what it shows.

 

2) Turn on the debug and post here the output for the seo urls only.

Share this post


Link to post
Share on other sites

I've solved the problem with using admin conversion instead of special chars from character_conversion file!

 

Thanks for your quick and professional help!

 

Best regards

 

Harry

Share this post


Link to post
Share on other sites
Well that is very odd the xml file is now using the standard tep_href_link so should be producing exactly the same uris as the site.

 

Could you do two things please.

 

1) Hover over that same link kyosho-mini-inferno-alu-dämpferbrücke-vorne-p-45.html on your site and post back what it shows.

 

2) Turn on the debug and post here the output for the seo urls only.

 

 

Ok, i will check the two points and write back asap!

Share this post


Link to post
Share on other sites
Well that is very odd the xml file is now using the standard tep_href_link so should be producing exactly the same uris as the site.

 

Could you do two things please.

 

1) Hover over that same link kyosho-mini-inferno-alu-dämpferbrücke-vorne-p-45.html on your site and post back what it shows.

 

2) Turn on the debug and post here the output for the seo urls only.

 

1) The hover is the same as displaying, without character conversion.

 

2) Here is the output from the debug for the seo urls only:

 

http://www.insidehobby.de/catalog/index.php
http://www.insidehobby.de/catalog/hpi-savage-chassis-platten-alu7075-p-37.html
http://www.insidehobby.de/catalog/hpi-savage-chassis-platten-alu7075-p-37.html
http://www.insidehobby.de/catalog/index.php
http://www.insidehobby.de/catalog/hpi-racing-c-32.html
http://www.insidehobby.de/catalog/hpi-savage-c-32_23.html
http://www.insidehobby.de/catalog/hpi-savage-chassis-platten-alu7075-p-37.html
http://www.insidehobby.de/catalog/hpi-savage-chassis-platten-alu7075-p-37.html
http://www.insidehobby.de/catalog/index.php
http://www.insidehobby.de/catalog/index.php
http://www.insidehobby.de/catalog/xrc-c-33.html
http://www.insidehobby.de/catalog/xrc-fahrzeuge-c-33_40.html
http://www.insidehobby.de/catalog/xrc-teile-c-33_41.html
http://www.insidehobby.de/catalog/xrc-baja-buggy-c-33_41_34.html
http://www.insidehobby.de/catalog/xrc-tourenwagen-c-33_41_35.html
http://www.insidehobby.de/catalog/xrc-tuning-c-33_38.html
http://www.insidehobby.de/catalog/kyosho-c-31.html
http://www.insidehobby.de/catalog/kyosho-mini-inferno-c-31_29.html
http://www.insidehobby.de/catalog/kyosho-mini-inferno-c-31_30.html
http://www.insidehobby.de/catalog/hpi-racing-c-32.html
http://www.insidehobby.de/catalog/hpi-savage-c-32_23.html
http://www.insidehobby.de/catalog/zubehör-c-42.html
http://www.insidehobby.de/catalog/sonderangebote-c-39.html
http://www.insidehobby.de/catalog/gebrauchtes-c-43.html
http://www.insidehobby.de/catalog/index.php
http://www.insidehobby.de/catalog/xrc-c-33.html
http://www.insidehobby.de/catalog/xrc-fahrzeuge-c-33_40.html
http://www.insidehobby.de/catalog/xrc-teile-c-33_41.html
http://www.insidehobby.de/catalog/xrc-baja-buggy-c-33_41_34.html
http://www.insidehobby.de/catalog/xrc-tourenwagen-c-33_41_35.html
http://www.insidehobby.de/catalog/xrc-tuning-c-33_38.html
http://www.insidehobby.de/catalog/kyosho-c-31.html
http://www.insidehobby.de/catalog/kyosho-mini-inferno-c-31_29.html
http://www.insidehobby.de/catalog/kyosho-mini-inferno-c-31_30.html
http://www.insidehobby.de/catalog/hpi-racing-c-32.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now