Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

[CONTRIBUTION] Google XML Sitemap Feed - by Chemo


749 replies to this topic

#721 garnet

  • Community Member
  • 118 posts
  • Real Name:az

Posted 03 July 2009, 08:56

HI
I was running sitemap update as CRON and it was going fine. I used to see the same message as if you run it manually in the CRON emails.
Some days ago I started getting this in the emails and the sitemaps arent updated.

Status: 302 Moved Temporarily
X-Powered-By: PHP/5.2.9
Location: http://www.kupuvalnik.com/blocked.php
Content-type: text/html


Any ideas
OSC beginner

#722 ealv68

  • Community Member
  • 6 posts
  • Real Name:Dark Vader

Posted 22 July 2009, 22:23

Hi to Everyone!

I have upload the next files in my web:

googleSitemapProducts.php
googleSitemapCategories.php
googleSitemapManufacturers.php
googleSitemapReviews.php


When i check them at google webmaster tools, it gives me this error:

Leading whitespace
We have detected that your Sitemap begins with whitespace. We have accepted the file, but should eliminate the blank space to meet the XML standard.

And when I open the file from the browser it shows me:

Error reading XML: XML or text declaration in a separate entity from the principle of
Location: http://www.domainname.com/googleSitemapProducts.php
Number of line 2, column 1:

I dont have idea from where come this whitespace.

Does anyone know how can i fix it?

Thanks for your time

#723 jdice

  • Community Member
  • 105 posts
  • Real Name:Janet Dice

Posted 19 October 2009, 02:10

Hi...I uploaded googlesitemap generator by bobby about a year ago. It only has two files...googlesitemapcategories.php & googlesitemapproducts.php. Then I go to google.com/webmasters/sitemaps and put my website in. However, the googlesitecategories.php is fine but googlesitemapproducts.php is not. Google is giving me this error: 1193 Invalid date
An invalid date was found. Please fix the date or formatting before resubmitting. How do I do that?

Also, shouldn't I be submitting an index page to google? Like mysite.com/catalog instead of mysite.com? Thanks for help and time, Sincerely, Janet

I am not sure what to do. my server date and time is this: 10/18/2009 22:04:17

Here is my googlesitemapproducts.php page:
<?php
	/**
	 * Google Sitemap Generator
	 * 
	 * Script to generate a Google sitemap for osCommerce based stores
	 *
	 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
	 * @version 1.2
	 * @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers
	 * @copyright Copyright 2006, Bobby Easland 
	 * @author Bobby Easland 
	 * @filesource
	 */
  
	/*
	 * Include the application_top.php script
	 */
	include_once('includes/application_top.php');
	
	/*
	 * Send the XML content header
	 */
	header('Content-Type: text/xml');
	
	/*
	 * Echo the XML out tag
	 */
	echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php

	/*
	 * Define the uniform node function 
	 */
	function GenerateNode($data){
		$content = '';
		$content .= "\t" . '<url>' . "\n";
		$content .= "\t\t" . '<loc>'.trim($data['loc']).'</loc>' . "\n";
		$content .= "\t\t" . '<lastmod>'.trim($data['lastmod']).'</lastmod>' . "\n";
		$content .= "\t\t" . '<changefreq>'.trim($data['changefreq']).'</changefreq>' . "\n";
		$content .= "\t\t" . '<priority>'.trim($data['priority']).'</priority>' . "\n";
		$content .= "\t" . '</url>' . "\n";
		return $content;
	} # end function

	/*
	 * Define the SQL for the products query 
	 */
	$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_last_modified DESC, 
					         products_date_added DESC, 
									 products_ordered DESC";
	
	/*
	 * Execute the query
	 */
	$query = tep_db_query($sql);

	/*
	 * If there are returned rows...
	 * Basic sanity check 
	 */
	if ( tep_db_num_rows($query) > 0 ){

		/*
		 * Initialize the variable containers
		 */
		$container = array();
		$number = 0;
		$top = 0;

		/*
		 * Loop the query result set
		 */
		while( $result = tep_db_fetch_array($query) ){
			$top = max($top, $result['products_ordered']);
			$location = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
			if ( tep_not_null($result['last_mod']) ){
				$lastmod = $result['last_mod'];
			} else {
				$lastmod = $result['date_added'];
			}
			$changefreq = 'weekly';
			$ratio = ($top > 0) ? ($result['products_ordered']/$top) : 0;
			$priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', ''); 
			
			/*
			 * Initialize the content container array
			 */
			$container = array('loc' => htmlspecialchars(utf8_encode($location)),
								 				 'lastmod' => date ("Y-m-d", strtotime($lastmod)),
								 				 'changefreq' => $changefreq,
								 				 'priority' => $priority
												);

			/*
			 * Echo the generated node
			 */
			echo generateNode($container);
		} # end while
	} # end if
	
	/*
	 * Close the urlset
	 */
	echo '</urlset>';

	/*
	 * Include the application_bottom.php script 
	 */
	include_once('includes/application_bottom.php');
?>


#724 ghm1455

  • Community Member
  • 1 posts
  • Real Name:mami

Posted 20 November 2009, 05:53

hy

i install the this program

i set the perm. for the file but

this error had appeared

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request

what can i do Chemo?

thanks

#725 rustyclockwork

  • Community Member
  • 116 posts
  • Real Name:.
  • Gender:Male

Posted 02 December 2009, 17:29

Hi Chemo,

I installed version 1.3 and everything works except for the product xml output. I have set the permissions correctly.

i get this error when i tested everything in the browser.

----------------

ERROR: Google Product Sitemap Generation FAILED!

Generated Google Category Sitemap Successfully

Generated Google Sitemap Index Successfully

Array
(
[QUERY] => Array
(
[PRODUCTS] => Array
(
[STATUS] => success
[NUM_ROWS] => 1
)

[CATEOGRY] => Array
(
[STATUS] => success
[NUM_ROWS] => 10
)

)

[SAVE_FILE_XML] => Array
(
[0] => Array
(
[file] => /home/oldfoun1/public_html/catalog/sitemapcategories.xml
[status] => success
[file_exists] => true
)

[1] => Array
(
[file] => /home/oldfoun1/public_html/catalog/sitemapindex.xml
[status] => success
[file_exists] => true
)

)

)

-------------

Any ideas? Thanks for a wonderful contribution.

Jason

Edited by rustyclockwork, 02 December 2009, 17:29.


#726 rustyclockwork

  • Community Member
  • 116 posts
  • Real Name:.
  • Gender:Male

Posted 02 December 2009, 18:24

Hello, nevermind, I went with the php versions. Thanks.

#727 laptopskydd

  • Community Member
  • 3 posts
  • Real Name:Adam

Posted 19 January 2010, 13:11

Using this togheter with the "ULTIMATE SEO 5"
my "XML" for products looks like:
http://www.laptop-skydd.se/sitemapproducts.xml

i.e a products gets a link like:
http://www.laptop-skydd.se/product_info.php?products_id=250
but on the site they have:
http://www.laptop-skydd.se/product_info.php/blomma-p-250

This is gives some problem with google like:
"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.
HTTP Error: 301 URL: Go to URLhttp://www.laptop-skydd.se/product_info.php?products_id=124"

What im i doing wrong, are ther other contributions?

#728 FWR Media

  • Community Member
  • 6,462 posts
  • Real Name:Robert Fisher
  • Gender:Male
  • Location:Stowmarket - Suffolk - UK

Posted 19 January 2010, 13:27

View Postlaptopskydd, on 19 January 2010, 13:11, said:

Using this togheter with the "ULTIMATE SEO 5"
my "XML" for products looks like:
http://www.laptop-skydd.se/sitemapproducts.xml

i.e a products gets a link like:
http://www.laptop-skydd.se/product_info.php?products_id=250
but on the site they have:
http://www.laptop-skydd.se/product_info.php/blomma-p-250

This is gives some problem with google like:
"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.
HTTP Error: 301 URL: Go to URLhttp://www.laptop-skydd.se/product_info.php?products_id=124"

What im i doing wrong, are ther other contributions?

This contribution doesn't use the standard osCommerce function tep_href_link() it also hardcodes in the old seo urls series 2 which means that no other url rewriter can possibly work.

In the package you downloaded (USU5) I added two corrected files which will work. extras/Google XML Sitemap SEO/

If you use a cron job to create these files read the instructions as you have to use wget in the cron command.

Edited by FWR Media, 19 January 2010, 13:28.

Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls

KissMT Dynamic SEO Meta & Canonical Header Tags

KissER Error Handling and Debugging

If you found my post useful please click the green + sign to the right

Please only PM me for paid work.


#729 laptopskydd

  • Community Member
  • 3 posts
  • Real Name:Adam

Posted 19 January 2010, 13:59

Ah thanks alot. How could i miss that before, worked like a charm...

View PostFWR Media, on 19 January 2010, 13:27, said:

This contribution doesn't use the standard osCommerce function tep_href_link() it also hardcodes in the old seo urls series 2 which means that no other url rewriter can possibly work.

In the package you downloaded (USU5) I added two corrected files which will work. extras/Google XML Sitemap SEO/

If you use a cron job to create these files read the instructions as you have to use wget in the cron command.


#730 devils13

  • Community Member
  • 22 posts
  • Real Name:Jong Lee
  • Gender:Male

Posted 20 January 2010, 09:03

Hi, all.

I installed Google XML Sitemap and when I tried to view sitemapindex.xml and the other 2 files, sitemapindex wouldn`t be created while others did.

When I browsed "www.mydomain.com/sitemapindex.xml", it turned out like this;

<?xml version="1.0" encoding="UTF-8" ?>
<sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84" />

The other 2 turned out with links.

Is this right?

Jong.

#731 blr044

  • Community Member
  • 1,009 posts
  • Real Name:Bennett
  • Gender:Male
  • Location:USA

Posted 25 March 2010, 11:38

Sometime in the past two weeks, sitemapspecials.xml will not verfify. This is what I see when at webmster tools:

Quote

Invalid date
An invalid date was found. Please fix the date or formatting before resubmitting.
The Last modification date is like 1969-12-31 . But the other xml pages is not a problem. In fact, I know i updated the specials just last month.

You may seee what I mean at http://brs-giftshop.com/sitemapspecials.xml.

I've resubmitted, but smae error message. Does not make any sense why the specials is the only one that will not verify.
By the way I am using ver Sitemap SEO XML v_1.4 and my store is RC2A

Thanks.

Bennett

Edited by blr044, 25 March 2010, 11:42.


#732 sahilsaid

  • Community Member
  • 101 posts
  • Real Name:sahil
  • Gender:Male

Posted 28 March 2010, 11:52

Hi, chemo great contribution.

I have one problem getting the correct sitemap.

I submitted my sitemap to google and google webmaster is giving an error on product and categories sitemap.

error is:
Paths don't match
We've detected that you submitted your Sitemap using a URL path that includes the www prefix (for instance, http://www.example.com/sitemap.xml). However, the URLs listed inside your Sitemap don't use the www prefix (for instance, http://example.com/myfile.htm).
URL: Go to URLhttp://thecheaplaptops.co.uk/hp-nc4000-intel-pentium-40gb-512mb-windows-xp-wifi-laptop-p-31.html
Problem detected on: Mar 28, 2010


Can you please help what can be done to overcome this error.
Thanks

#733 sahilsaid

  • Community Member
  • 101 posts
  • Real Name:sahil
  • Gender:Male

Posted 28 March 2010, 12:08

View Postsahilsaid, on 28 March 2010, 11:52, said:

Hi, chemo great contribution.

I have one problem getting the correct sitemap.

I submitted my sitemap to google and google webmaster is giving an error on product and categories sitemap.

error is:
Paths don't match
We've detected that you submitted your Sitemap using a URL path that includes the www prefix (for instance, http://www.example.com/sitemap.xml). However, the URLs listed inside your Sitemap don't use the www prefix (for instance, http://example.com/myfile.htm).
URL: Go to URLhttp://thecheaplaptops.co.uk/hp-nc4000-intel-pentium-40gb-512mb-windows-xp-wifi-laptop-p-31.html
Problem detected on: Mar 28, 2010


Can you please help what can be done to overcome this error.
Thanks


This problem is now sorted, I don't know how but when I resubmitted the sitemap once gain it worked.

#734 forummaker

  • Community Member
  • 95 posts
  • Real Name:Ken
  • Gender:Male
  • Location:USA

Posted 05 April 2010, 04:03

Everything seems to be working...
I set up the cron job and this is what I received via email.
Except for the first few lines below... everything looks good.
Is the first part of this an issue to be concerned about?

Quote

/web/cgi-bin/php5: Symbol `client_errors' has different size in shared object, consider re-linking
Content-type: text/html

<pre>Write /home/html/sitemapproducts.xml<br>Generated Google Product Sitemap Successfully

Write /home/html/sitemapcategories.xml<br>Generated Google Category Sitemap Successfully

Write /home/html/sitemapmanufacturers.xml<br>Generated Google Manufacturers Sitemap Successfully

Write /home/html/sitemapspecials.xml<br>Generated Google Specials Sitemap Successfully

Write /home/html/sitemapindex.xml<br>Generated Google Sitemap Index Successfully

CONGRATULATIONS! All files generated successfully.

If you have not already submitted the sitemap index to Google click the link below.
Before you do I HIGHLY recommend that you view the XML files to make sure the data is correct.

For your convenience here is the CRON command for your site:
php /index.php

Here is your sitemap index: /sitemapindex.xml
Here is your product sitemap: /sitemapproducts.xml
Here is your category sitemap: /sitemapcategories.xml
Here is your manufacturers sitemap: /sitemapmanufacturers.xml
Here is your specials sitemap: /sitemapspecials.xml
</pre>
Thanks alot!
That "Can" you're about to open... has worms!
Don't say I didn't worn ya.
n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.

#735 forummaker

  • Community Member
  • 95 posts
  • Real Name:Ken
  • Gender:Male
  • Location:USA

Posted 06 April 2010, 16:42

Quote

/web/cgi-bin/php5: Symbol `client_errors' has different size in shared object, consider re-linking
Content-type: text/html

Any advice an this first part of the message from my cron job?
I just want to make sure I'm on the right track.
Thanks for any help.
That "Can" you're about to open... has worms!
Don't say I didn't worn ya.
n. pl. cans of worms Informal - A source of unforeseen and troublesome complexity.

#736 DSeyir

  • Community Member
  • 22 posts
  • Real Name:Carl
  • Gender:Male

Posted 08 April 2010, 14:15

Hi folks,
I just installed this , and got the folowing errors on .../googlesitemap/index.php
What should I do to solve this?
Thanks



[b]Warning[/b]: fopen(/sitemapproducts.xml) [[url="http://tessfashion.com/googlesitemap/function.fopen"]function.fopen[/url]]: failed to open stream: Permission denied in [b]/home/*******/public_html/store/googlesitemap/sitemap.class_Alternate.php[/b] on line [b]354[/b]

ERROR: Google Product Sitemap Generation FAILED!



[b]Warning[/b]: fopen(/sitemapcategories.xml) [[url="http://tessfashion.com/googlesitemap/function.fopen"]function.fopen[/url]]: failed to open stream: Permission denied in [b]/home/********/public_html/store/googlesitemap/sitemap.class_Alternate.php[/b] on line [b]354[/b]

ERROR: Google Category Sitemap Generation FAILED!



[b]Warning[/b]: fopen(/sitemapindex.xml) [[url="http://tessfashion.com/googlesitemap/function.fopen"]function.fopen[/url]]: failed to open stream: Permission denied in [b]/home/*********/public_html/store/googlesitemap/sitemap.class_Alternate.php[/b] on line [b]354[/b]

ERROR: Google Sitemap Index Generation FAILED!

Array
(
 [QUERY] => Array
 (
 [PRODUCTS] => Array
 (
 [STATUS] => success
 [NUM_ROWS] => 39
 )

 [CATEOGRY] => Array
 (
 [STATUS] => success
 [NUM_ROWS] => 7
 )

 )

 [SAVE_FILE_XML] => Array
 (
 [0] => Array
 (
 [file] => /sitemapproducts.xml
 [status] => failure
 [file_exists] => false
 )

 [1] => Array
 (
 [file] => /sitemapcategories.xml
 [status] => failure
 [file_exists] => false
 )

 [2] => Array
 (
 [file] => /sitemapindex.xml
 [status] => failure
 [file_exists] => false
 )

 )

)



"The Breath becomes a stone; the stone, a plant; the plant, an animal; the animal, a man; the man, a spirit; and the spirit, a God."

#737 simon022877

  • Community Member
  • 3 posts
  • Real Name:Simon delos Reyes

Posted 07 May 2010, 03:02

I have a problem regarding the google sitemap, for my other site, it is working fine. In my localhost it is working fine. But once I uploaded the file go to the sitemap, all sitemaps failed.

#738 jps001

  • Community Member
  • 44 posts
  • Real Name:Jasper Tielen

Posted 09 January 2011, 13:35

Hello,

I have the same problem as DSeyir.
When running standard mode it fails on memory so i set alternate mode.

But even if i turn off standard pages etc. it fails.

Here is the data i got when turning diagnostic output on

Warning:  gzopen(/sitemapproducts.xml.gz) [function.gzopen]: failed to open stream: Permission denied in /home/public_html/webshop/googlesitemap/sitemap.class_Alternate.php on line 338
ERROR: Google Product Sitemap Generation FAILED!


Warning:  gzopen(/sitemapcategories.xml.gz) [function.gzopen]: failed to open stream: Permission denied in /home/public_html/webshop/googlesitemap/sitemap.class_Alternate.php on line 338
ERROR: Google Category Sitemap Generation FAILED!

Opening   /sitemapindex.xmlFS_CAT    
/home/autospor/public_html/webshop/Server    
http://www.autosportparts.eu

Save Path /WS_CAT    /webshop/ 
Warning:  fopen(/sitemapindex.xml) [function.fopen]: failed to open stream: Permission denied in /home/public_html/webshop/googlesitemap/sitemap.class_Alternate.php on line 353
ERROR: Google Sitemap Index Generation FAILED!

Array
(
    [QUERY] => Array
        (
            [PRODUCTS] => Array
                (
                    [STATUS] => success
                    [NUM_ROWS] => 24355
                )

            [CATEOGRY] => Array
                (
                    [STATUS] => success
                    [NUM_ROWS] => 25379
                )

        )

    [SAVE_FILE_COMPRESS] => Array
        (
            [0] => Array
                (
                    [file] => /sitemapproducts.xml.gz
                    [status] => failure
                    [file_exists] => false
                )

            [1] => Array
                (
                    [file] => /sitemapcategories.xml.gz
                    [status] => failure
                    [file_exists] => false
                )

        )

    [SAVE_FILE_XML] => Array
        (
            [0] => Array
                (
                    [file] => /sitemapindex.xml
                    [status] => failure
                    [file_exists] => false
                )

        )

)


ca someaone help me out?

Jasper

#739 jps001

  • Community Member
  • 44 posts
  • Real Name:Jasper Tielen

Posted 17 January 2011, 07:23

Hello,

Can someone help me out?

Problem:
I enter www.my_domain.nl/webshop/googlesitemap/index.php
i get congratulations
But now the problem, all .xml are not in ../webshop/ but they are in ../ not a big problem i think.
But now i add sitemapindex.xml to google and google cant find /webshop/sitemapcategories.xml /webshop/sitemapmanufacturers.xml ......

How to make googlesitemap to get it right.
.1 make googlesitemap save to ../webshop
.2 make sitemapindex.xml say ../sitemapcategories.xml instead webshop/sitemapcategories.xml

i need some help with this please.

The code:
<?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 
 */
class MySQL_DataBase{
	/**
 	* Database host (localhost, IP based, etc)
	* @var string
 	*/
	var $host;
	/**
 	* Database user
	* @var string
 	*/
	var $user;
	/**
 	* Database name
	* @var string
 	*/
	var $db;
	/**
 	* Database password
	* @var string
 	*/
	var $pass;
	/**
 	* Database link
	* @var resource
 	*/
	var $link_id;

/**
 * MySQL_DataBase class constructor 
 * @author Bobby Easland 
 * @version 1.0
 * @param string $host
 * @param string $user
 * @param string $db
 * @param string $pass  
 */	
	function MySQL_DataBase($host, $user, $db, $pass){
		$this->host = $host;
		$this->user = $user;
		$this->db = $db;
		$this->pass = $pass;		
		$this->ConnectDB();
		$this->SelectDB();
	} # end function

/**
 * Function to connect to MySQL 
 * @author Bobby Easland 
 * @version 1.0
 */	
	function ConnectDB(){
		$this->link_id = mysql_connect($this->host, $this->user, $this->pass);
	} # end function
	
/**
 * Function to select the database
 * @author Bobby Easland 
 * @version 1.0
 * @return resoource 
 */	
	function SelectDB(){
		return mysql_select_db($this->db);
	} # end function
	
/**
 * Function to perform queries
 * @author Bobby Easland 
 * @version 1.0
 * @param string $query SQL statement
 * @return resource 
 */	
	function Query($query){
		return @mysql_query($query, $this->link_id);
	} # end function
	
/**
 * Function to fetch array
 * @author Bobby Easland 
 * @version 1.0
 * @param resource $resource_id
 * @param string $type MYSQL_BOTH or MYSQL_ASSOC
 * @return array 
 */	
	function FetchArray($resource_id, $type = MYSQL_BOTH){
		return @mysql_fetch_array($resource_id, $type);
	} # end function
	
/**
 * Function to fetch the number of rows
 * @author Bobby Easland 
 * @version 1.0
 * @param resource $resource_id
 * @return mixed  
 */	
	function NumRows($resource_id){
		return @mysql_num_rows($resource_id);
	} # end function
	
/**
 * Function to free the resource
 * @author Bobby Easland 
 * @version 1.0
 * @param resource $resource_id
 * @return boolean
 */	
	function Free($resource_id){
		return @mysql_free_result($resource_id);
	} # end function

/**
 * Function to add slashes
 * @author Bobby Easland 
 * @version 1.0
 * @param string $data
 * @return string 
 */	
	function Slashes($data){
		return addslashes($data);
	} # end function

/**
 * Function to perform DB inserts and updates - abstracted from osCommerce-MS-2.2 project
 * @author Bobby Easland 
 * @version 1.0
 * @param string $table Database table
 * @param array $data Associative array of columns / values
 * @param string $action insert or update
 * @param string $parameters
 * @return resource
 */	
	function DBPerform($table, $data, $action = 'insert', $parameters = '') {
		reset($data);
		if ($action == 'insert') {
		  $query = 'INSERT INTO `' . $table . '` (';
		  while (list($columns, ) = each($data)) {
			$query .= '`' . $columns . '`, ';
		  }
		  $query = substr($query, 0, -2) . ') values (';
		  reset($data);
		  while (list(, $value) = each($data)) {
			switch ((string)$value) {
			  case 'now()':
				$query .= 'now(), ';
				break;
			  case 'null':
				$query .= 'null, ';
				break;
			  default:
				$query .= "'" . $this->Slashes($value) . "', ";
				break;
			}
		  }
		  $query = substr($query, 0, -2) . ')';
		} elseif ($action == 'update') {
		  $query = 'UPDATE `' . $table . '` SET ';
		  while (list($columns, $value) = each($data)) {
			switch ((string)$value) {
			  case 'now()':
				$query .= '`' .$columns . '`=now(), ';
				break;
			  case 'null':
				$query .= '`' .$columns .= '`=null, ';
				break;
			  default:
				$query .= '`' .$columns . "`='" . $this->Slashes($value) . "', ";
				break;
			}
		  }
		  $query = substr($query, 0, -2) . ' WHERE ' . $parameters;
		}
		return $this->Query($query);
	} # end function	
} # end class

/**
 * 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{
	/**
 	* $DB is the database object
	* @var object
 	*/
	var $DB;
	/**
 	* $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;
	/**
 	* $excludeList holds the files being excluded from the pages map
	* @var array
 	*/
	var $excludeList;  

	
/**
 * 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($host, $user, $db, $pass){
		$this->DB = new MySQL_Database($host, $user, $db, $pass);
		$this->filename = "sitemap";
$this->savepath = '/home/autospor/public_html/';
		$this->base_url = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
		$this->debug = array();
    
    $this->excludeList = array(0 => 'account.php',
                               1 => 'account_edit.php',
                               2 => 'account_history.php',
                               3 => 'account_history_info.php',
                               4 => 'account_newsletters.php',
                               5 => 'account_notifications.php',
                               6 => 'account_password.php',
                               7 => 'address_book.php',
                               8 => 'address_book_process.php',
                               9 => 'checkout_confirmation.php',
                               10 => 'checkout_payment.php',
                               11 => 'checkout_payment_address.php',
                               12 => 'checkout_process.php',
                               13 => 'checkout_shipping.php',
                               14 => 'checkout_shipping_address.php',
                               15 => 'checkout_success.php',
                               16 => 'cookie_usage.php',
                               17 => 'create_account.php',
                               18 => 'create_account_success.php',
                               19 => 'down_for_maintenance.php',
                               20 => 'download.php',                               
                               21 => 'info_shopping_cart.php',
                               22 => 'links_submit_success.php',
                               23 => 'login.php',
                               24 => 'logoff.php',
                               25 => 'password_forgotten.php',
                               26 => 'shopping_cart.php',
                               27 => 'ssl_check.php'
                               );
    
    // Add the pages listed in the database                           
    $adminExclude = explode(",",GOOGLE_XML_SITEMAP_EXCLUDE_PAGES);
    $newFiles = array();
    for ($i = 0; $i < count($adminExclude); ++$i)
      $newFiles[] = trim($adminExclude[$i]);
    $this->excludeList = array_merge($this->excludeList, $newFiles);
	} # 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;		

    if (strpos($filename, 'googlesitemap') !== FALSE)
    {
      $file_check = file_exists($filename) ? 'true' : 'false';
			$this->debug['SAVE_FILE_XML'][] = array('file' => $filename, 'status' => 'failure due to incorrect file name', 'file_exists' => $file_check);
			return false;
    }    	
    
		$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 (GOOGLE_XML_SITEMAP_SHOW_DIAGNOSTIC == 'true')
           echo 'Opening   '.$filename. '<br>FS_CAT    '.DIR_FS_CATALOG. '<br>Server    ' . HTTP_SERVER . '<br>Save Path '. $this->savepath . '<br>WS_CAT    '. DIR_WS_HTTP_CATALOG.' <br>';
				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 ( preg_match('/index/i', $filename) ) continue;
		   if ( preg_match('/manufacturers/i', $filename) && GOOGLE_XML_SITEMAP_CREATE_MANU != 'true' ) continue;
		   if ( preg_match('/pages/i', $filename) && GOOGLE_XML_SITEMAP_CREATE_PAGES != 'true' ) continue;
		   if ( preg_match('/specials/i', $filename) && GOOGLE_XML_SITEMAP_CREATE_SPECIALS != 'true' ) 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(){
        $quotes = (defined('QUOTES_CATEGORY_NAME') ? " and customers_email_address = '' and quotes_email_address = ''" : '');
		$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'" . $quotes . "
				ORDER BY products_ordered DESC";
		if ( $products_query = $this->DB->Query($sql) ){
			$this->debug['QUERY']['PRODUCTS']['STATUS'] = 'success';
			$this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = $this->DB->NumRows($products_query);
			$container = array();
			$number = 0;
			$top = 0;
			while( $result = $this->DB->FetchArray($products_query) ){
				$top = max($top, $result['products_ordered']);
				$location = $this->hrefLink(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
				$lastmod = $this->NotNull($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
			$this->DB->Free($products_query);			
			if ( sizeof($container) > 0 ) {
				$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(){
        $quotes = (defined('QUOTES_CATEGORY_NAME') ? " where cd.categories_name NOT LIKE '" . QUOTES_CATEGORY_NAME . "' " : '');
		$sql = "SELECT c.categories_id as cID, c.date_added, c.last_modified as last_mod 
			    FROM " . TABLE_CATEGORIES . " c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id  
          " . $quotes . "
				ORDER BY c.parent_id ASC, c.sort_order ASC, c.categories_id ASC";
         
		if ( $categories_query = $this->DB->Query($sql) ){
			$this->debug['QUERY']['CATEOGRY']['STATUS'] = 'success';
			$this->debug['QUERY']['CATEOGRY']['NUM_ROWS'] = $this->DB->NumRows($categories_query);
			$container = array();
			$number = 0;
			while( $result = $this->DB->FetchArray($categories_query) ){
				$location = $this->hrefLink(FILENAME_DEFAULT, 'cPath=' . $this->GetFullcPath($result['cID']), 'NONSSL', false);
				$lastmod = $this->NotNull($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
			$this->DB->Free($categories_query);			
			if ( sizeof($container) > 0 ) {
				$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 = $this->DB->Query($sql) ){
			$this->debug['QUERY']['MANUFACTURERS']['STATUS'] = 'success';
			$this->debug['QUERY']['MANUFACTURERS']['NUM_ROWS'] = $this->DB->NumRows($manufacturers_query);
			$container = array();
			$number = 0;
			while( $result = $this->DB->FetchArray($manufacturers_query) ){
				$location = $this->hrefLink(FILENAME_DEFAULT, 'manufacturers_id=' . $result['mID'], 'NONSSL', false);
				$lastmod = $this->NotNull($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
			$this->DB->Free($manufacturers_query);
			if ( sizeof($container) > 0 ) {
				$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($languages_id){
        $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' and pd.language_id = " . (int)$languages_id . " order by s.specials_date_added desc ";             
		if ( $products_query = $this->DB->Query($sql) ){
			$this->debug['QUERY']['SPECIALS']['STATUS'] = 'success';
			$this->debug['QUERY']['SPECIALS']['NUM_ROWS'] = $this->DB->NumRows($products_query);
			$container = array();
			$number = 0;
			$top = 0;
			while( $result = $this->DB->FetchArray($products_query) ){
				$top = max($top, $result['products_ordered']);
				$location = $this->hrefLink(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
				$lastmod = $this->NotNull($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
			$this->DB->Free($products_query);			
			if ( sizeof($container) > 0 ) {
				$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 generate sitemap pages file 
 * @author Jack_mcs
 * @version 1.1
 * @return boolean
 */	
	function GeneratePagesSitemap(){
		$container = array();
		$changefreq = GOOGLE_SITEMAP_PAGES_CHANGE_FREQ;
		$priority = '.1';

  	include_once(DIR_WS_CLASSES . 'language.php');
  	$lng = new language();
   
    $slash = substr(DIR_FS_CATALOG, 0 -1) == '/' ? 1 : 0;
    $path = (($pos = strpos(DIR_FS_CATALOG, "googlesitemap")) !== FALSE) ? substr(DIR_FS_CATALOG, 0, -strlen('googlesitemap') - $slash) : DIR_FS_CATALOG;
    $pages = $this->GetPagesArray($path, DIR_WS_LANGUAGES . $lng->language['directory'], $lng->language['id']);
 
    for ($i = 0; $i < count($pages); ++$i)
    {
   	  $container[] = array('loc' => htmlspecialchars(utf8_encode($pages[$i]['filename'])),
 	                         'lastmod' => $pages[$i]['lastmod'],
  		     			         'changefreq' => $changefreq,
 				  		            'priority' => $priority
 	                        );	             
    }
 
    if ($i > 0)
 		  return $this->GenerateSitemap($container, 'pages');
	} # 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 ( preg_match('/_/', $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 = $this->DB->Query($sql);
		while ($parent_categories = $this->DB->FetchArray($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

/**
 * Function to check if a value is NULL 
 * @author Bobby Easland as abstracted from osCommerce-MS2.2 
 * @version 1.0
 * @param mixed $value
 * @return boolean
 */	
	function NotNull($value) {
		if (is_array($value)) {
			if (sizeof($value) > 0) {
				return true;
			} else {
				return false;
			}
		} else {
			if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) {
				return true;
			} else {
				return false;
			}
		}
	} # end function

/**
 * Function to return href_link 
 * @author Bobby Easland 
 * @version 1.0
 * @param mixed $value
 * @return boolean
 */	
	function hrefLink($page, $parameters, $connection, $add_session_id) {
		if ( defined('SEO_URLS') && SEO_URLS == 'true' || defined('SEO_ENABLED') && SEO_ENABLED == 'true' ) {
			return tep_href_link($page, $parameters, $connection, $add_session_id);
		} else {
			return $this->base_url . $page . '?' . $parameters;
		}
	} # 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
  
  function GetPagesArray($locn, $languagesDir, $languageID)
  {
    $cwd = getcwd(); 
    $pagesArray = array();
    
    $end =  (substr($locn, strlen($locn) - 1) !== '/') ? '/' : '';
    $root = $locn . $end;
    $path = $root . $languagesDir;
    $end =  (substr($path, strlen($path) - 1) !== '/') ? '/' : '';
    $path = $path . $end;

    chdir ($path);

    foreach (glob("*.php") as $filename)  
    {
      if (! in_array($filename, $this->excludeList) && $this->IsViewable($root . $filename))
      {
        $r = @stat($filename);
        $displayName = ucwords(str_replace("_", " ", substr($filename, 0, strpos($filename, ".")))); //remove the .php and underscores
        $pagesArray[] = array('filename' => $this->base_url . $filename,
                              'lastmod' => gmstrftime ("%Y-%m-%d", $r[9]));
                    
        /*** ADD ARTICLES ***/            
        if ($filename === 'articles.php')
        {
          $sql = "SELECT a.articles_id, DATE_FORMAT(a.articles_last_modified,'%Y-%m-%d') AS lastmod, DATE_FORMAT(a.articles_date_added,'%Y-%m-%d') AS date_added from " . TABLE_ARTICLES . " a left join " . TABLE_ARTICLES_DESCRIPTION . " ad on a.articles_id = ad.articles_id where a.articles_status = '1' and ad.language_id = '" . (int)$languageID . "'";
		  if ( $articles_query = $this->DB->Query($sql) )
          {
   		    while( $result = $this->DB->FetchArray($articles_query) )
            {
              $page = 'article_info.php' . '?articles_id=' . $result['articles_id'];
              if (! in_array($page, $this->excludeList)) {
              $pagesArray[] = array('filename' => $this->hrefLink('article_info.php', 'articles_id=' . $result['articles_id'], 'NONSSL', false),
                                    'lastmod' => $this->NotNull($result['lastmod']) ? $result['lastmod'] : $result['date_added']);
            }
          }
          }
          $sql = "SELECT t.topics_id, DATE_FORMAT(t.last_modified,'%Y-%m-%d') AS lastmod, DATE_FORMAT(t.date_added,'%Y-%m-%d') AS date_added from " . TABLE_TOPICS . " t left join " . TABLE_TOPICS_DESCRIPTION . " td on t.topics_id = td.topics_id where td.language_id = '" . (int)$languageID . "'";
		  if ( $articles_query = $this->DB->Query($sql) )
          {
   		    while( $result = $this->DB->FetchArray($articles_query) )
            {
              $page = 'articles.php' . '?tPath=' . $result['topics_id'];
              if (! in_array($page, $this->excludeList)) {
              $pagesArray[] = array('filename' => $this->hrefLink('articles.php', 'tPath=' . $result['topics_id'], 'NONSSL', false),
                                    'lastmod' => $this->NotNull($result['lastmod']) ? $result['lastmod'] : $result['date_added']);
            }
          }
        }                 
        }                 
          
        /*** ADD INFORMATION PAGES ***/            
        else if ($filename === 'information.php')
        {
          $sql = "SELECT information_id from " . TABLE_INFORMATION . " where visible = '1' and language_id = '" . (int)$languageID . "'";
		      if ( $information_query = $this->DB->Query($sql) )
          {
 			     while( $result = $this->DB->FetchArray($information_query) )
            {
              $page = 'information.php' . '?info_id=' . $result['information_id'];
              if (! in_array($page, $this->excludeList)) {
              $pagesArray[] = array('filename' => $this->hrefLink('information.php', 'info_id=' . $result['information_id'], 'NONSSL', false),
                                    'lastmod' => gmstrftime ("%Y-%m-%d", $r[9]));
            }
          }          
        } 
      } 
    }    
    }    

    /*** ADD PAGE MANAGER ***/ 
    //special case since it doesn't have a language file            
    if (file_exists($root.'pages.php') &&  $this->IsViewable($root.'pages.php')) 
    {
       $r = @stat('pages.php');
       $pagesArray[] = array('filename' => $this->base_url . 'pages.php',
                              'lastmod' => gmstrftime ("%Y-%m-%d", $r[9]));
       $sql = "SELECT p.pages_id, p.pages_name from " . TABLE_PAGES . " p left join " . TABLE_PAGES_DESCRIPTION . " pd on p.pages_id = pd.pages_id where p.pages_status = '1' and pd.language_id = '" . (int)$languageID . "'";
       if ( $pages_query = $this->DB->Query($sql) )
       {
  	      while( $result = $this->DB->FetchArray($pages_query) )
          {
              $page = 'pages.php' . '?page=' . $result['pages_name'];
              if (! in_array($page, $this->excludeList)) {
            $pagesArray[] = array('filename' => $this->hrefLink('pages.php', 'page=' . $result['pages_name'], 'NONSSL', false),
                                  'lastmod' => gmstrftime ("%Y-%m-%d", $r[9]));
          }
      } 
    }    
    }
  
    chdir ($cwd);
    return $pagesArray;
  }  
  
  function IsViewable($file)
  {
    if (($fp = @file($file)))
    {
      for ($idx = 0; $idx < count($fp); ++$idx)
      {
         if (strpos($fp[$idx], "<head>") !== FALSE)
           return true;
      }
    }  
    return false;
  }  
  
} #  end class
?>

Regards,

Jasper

#740 jps001

  • Community Member
  • 44 posts
  • Real Name:Jasper Tielen

Posted 17 January 2011, 07:40

Edit:
Problem solved.
My partner changed some code to make it work but he forgot /webshop/ on the savepath
$this->savepath = '/home/my_account/public_html/';
$this->savepath = '/home/my_account/public_html/webshop/';

Jasper