Jump to content
Chemo

[CONTRIBUTION] Google XML Sitemap Feed - by Chemo

Recommended Posts

kitchenniche

 

Try this:

 

In 'categories.php' find: in_array

 

And replace it with: @in_array

 

There should be a few references to it. If it is already '@in_array', then I am out of ideas.

 

Hello Willross,

 

I am experiencing similar problems with teh wrong datatype in array error.

My categorie box has in_array (not @in_array). So therefore i am willing to use your solution, but i have really no idea what this will do to the rest of my store.

So willross since your the only one i've found to propose this solution i am asking you; Can you explain what this @ sign will do and if it is a potential danger to the rest of my very modified oscommerce ms2.2.

Thanks in advance and i hope you are kind enough to eplain me a little bit more


Kind regards

 

Hakan Haknuz

Share this post


Link to post
Share on other sites

Anyone for make it works with YASU ?

i tried this, has posted bellow, but the urls are not rewrited :(

 

googlesitemap/index.php :

 

 if ( file_exists(DIR_WS_CLASSES . 'seo.class.php') ){
require_once(DIR_WS_CLASSES . 'seo.class.php');
$seo_urls = new SEO_URL($languages_id);
} else if ( file_exists(DIR_WS_CATALOG . 'rewrite.php') ){
require_once(DIR_WS_CATALOG . 'rewrite.php');
$other_rewrite = true;
}

 

Then in googlesitemap/sitemap.class.php :

 

 * Function to generate product sitemap data
*/
function GenerateProductSitemap(){
 // SEO OTHER BEGIN
 global $other_rewrite;

 if (!$other_rewrite) {
 $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";
 } else {
 $sql = "SELECT p.products_id as pID, p.products_date_added as date_added, p.products_last_modified as last_mod, p.products_ordered, pd.products_name, ptc.categories_id
 FROM " . TABLE_PRODUCTS . " AS p LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " AS ptc
 ON ptc.products_id=p.products_id
 LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " AS pd
 ON pd.products_id=p.products_id
 WHERE p.products_status='1'
 ORDER BY p.products_ordered DESC";
 }
 // SEO OTHER END
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']);
 // SEO OTHER BEGIN
 if (!$other_rewrite)
  $location = $this->hrefLink(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false);
 else
  $location = $this->hrefLink(FILENAME_DEFAULT, 'cPath=' . tep_get_product_path($result['pID']) . '/' . $result['products_name'], 'NONSSL', false);
 // SEO OTHER END
  $lastmod = $this->NotNull($result['last_mod']) ? $result['last_mod'] : $result['date_added'];

Share this post


Link to post
Share on other sites

hakan haknuz

 

The @ symbol tells PHP to suppress those annoying errors. The reason it throws the error is that once the cache is reset it must build the data again on the very next click. Thus must be done before it is a valid array again. It will not affect the form or functionality of the menu...just suppress it

· willross

··········

Share this post


Link to post
Share on other sites

Thanks a lot Willross ,

 

I must have missed this clear explanation, while reading trough all the posts. :blush:

Now it is very clear to me ... it will surpress the categoriebox's errors .

 

Again thanks a lot for your explanation :thumbsup:

Edited by hakan haknuz

Kind regards

 

Hakan Haknuz

Share this post


Link to post
Share on other sites
Anyone for make it works with YASU ?

i tried this, has posted bellow, but the urls are not rewrited :(

 

Try adding:

 

        /// fix for yasu
       define('SEO_URLS', 'true');
       define('SEO_ENABLED', 'true');

 

To the top of a googlesitemap/index.php (default installation)

 

Will enable the tep_href_link function - works fine for me with YASU :)

 

Very impressive contrib BTW - thanks Chemo!

Share this post


Link to post
Share on other sites
Yes that was my problem too.

Thanks Fish

 

Same problem... there should be a note in the contrib to include at least x number of products.

 

RonR

Share this post


Link to post
Share on other sites

Weird issue. When I manually go to the index.php page I don't get any errors. But, with the CRON job I get 2 warnings. Are these anything to be concerned with?

 

<b>Warning</b>: error_log(/home/myname/temp/page_parse_time.log) [<a href='function.error-log'>function.error-log</a>]: failed to open stream: Permission denied in <b>/home/myname/public_html/includes/functions/database.php</b> on line <b>41</b><br /> <br />

<b>Warning</b>: error_log(/home/myname/temp/page_parse_time.log) [<a href='function.error-log'>function.error-log</a>]: failed to open stream: Permission denied in <b>/home/myname/public_html/includes/functions/database.php</b> on line <b>48</b><br /> <pre>Generated Google Product Sitemap Successfully

 

Generated Google Category Sitemap Successfully

 

Generated Google Sitemap Index Successfully

 

CONGRATULATIONS! All files generated successfully.


Powered by osCommerce

Share this post


Link to post
Share on other sites

I got this warning from CRON:

 

Content-type: text/html

 

PHP Warning: Unable to load dynamic library '/usr/lib/php4/pgsql.so' - libpq.so.2: cannot open shared object file: No such file or directory in Unknown on line 0

X-Powered-By: PHP/4.1.2

Content-type: text/html

 

<?

define('USE_SEO_REDIRECT_DEBUG', 'false');

/**

* Ultimate SEO URLs Contribution - osCommerce MS-2.2

*

* Ultimate SEO URLs offers search engine optimized URLS for osCommerce

* based applications. Other features include optimized performance and

* automatic redirect script.

* @package Ultimate-SEO-URLs

* @license http://opensource.org/licenses/gpl-license.php GNU Public License

* @version 2.1

* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers

* @copyright Copyright 2005, Bobby Easland

* @author Bobby Easland

* @filesource

*/

 

/**

* SEO_DataBase Class

*

* The SEO_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 Ultimate-SEO-URLs

* @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 SEO_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 SEO_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.1

*/

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 fetch the last insertID

* @author Bobby Easland

* @version 1.0

* @return integer

*/

function InsertID() {

return mysql_insert_id();

}

 

/**

* 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

 

/**

* Ultimate SEO URLs Installer and Configuration Class

*

* Ultimate SEO URLs installer and configuration class offers a modular

* and easy to manage method of configuration. The class enables the base

* class to be configured and installed on the fly without the hassle of

* calling additional scripts or executing SQL.

* @package Ultimate-SEO-URLs

* @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 SEO_URL_INSTALLER{

/**

* The default_config array has all the default settings which should be all that is needed to make the base class work.

* @var array

*/

var $default_config;

/**

* Database object

* @var object

*/

var $DB;

/**

* $attributes array holds information about this instance

* @var array

*/

var $attributes;

 

/**

* SEO_URL_INSTALLER class constructor

* @author Bobby Easland

* @version 1.1

*/

function SEO_URL_INSTALLER(){

 

$this->attributes = array();

 

$x = 0;

$this->default_config = array();

$this->default_config['SEO_ENABLED'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enable SEO URLs?', 'SEO_ENABLED', 'true', 'Enable the SEO URLs? This is a global setting and will turn them off completely.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['SEO_ADD_CPATH_TO_PRODUCT_URLS'] = array('DEFAULT' => 'false',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Add cPath to product URLs?', 'SEO_ADD_CPATH_TO_PRODUCT_URLS', 'false', 'This setting will append the cPath to the end of product URLs (i.e. - some-product-p-1.html?cPath=xx).', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['SEO_ADD_CAT_PARENT'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Add category parent to begining of URLs?', 'SEO_ADD_CAT_PARENT', 'true', 'This setting will add the category parent name to the beginning of the category URLs (i.e. - parent-category-c-1.html).', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['SEO_URLS_FILTER_SHORT_WORDS'] = array('DEFAULT' => '3',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Filter Short Words', 'SEO_URLS_FILTER_SHORT_WORDS', '3', 'This setting will filter words less than or equal to the value from the URL.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, NULL)"

);

$x++;

$this->default_config['SEO_URLS_USE_W3C_VALID'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Output W3C valid URLs (parameter string)?', 'SEO_URLS_USE_W3C_VALID', 'true', 'This setting will output W3C valid URLs.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['USE_SEO_CACHE_GLOBAL'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enable SEO cache to save queries?', 'USE_SEO_CACHE_GLOBAL', 'true', 'This is a global setting and will turn off caching completely.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['USE_SEO_CACHE_PRODUCTS'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enable product cache?', 'USE_SEO_CACHE_PRODUCTS', 'true', 'This will turn off caching for the products.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['USE_SEO_CACHE_CATEGORIES'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enable categories cache?', 'USE_SEO_CACHE_CATEGORIES', 'true', 'This will turn off caching for the categories.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

 

$x++;

$this->default_config['USE_SEO_CACHE_MANUFACTURERS'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enable manufacturers cache?', 'USE_SEO_CACHE_MANUFACTURERS', 'true', 'This will turn off caching for the manufacturers.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

 

$x++;

$this->default_config['USE_SEO_CACHE_ARTICLES'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enable articles cache?', 'USE_SEO_CACHE_ARTICLES', 'true', 'This will turn off caching for the articles.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['USE_SEO_CACHE_TOPICS'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enable topics cache?', 'USE_SEO_CACHE_TOPICS', 'true', 'This will turn off caching for the article topics.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['USE_SEO_CACHE_INFO_PAGES'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enable information cache?', 'USE_SEO_CACHE_INFO_PAGES', 'true', 'This will turn off caching for the information pages.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['USE_SEO_REDIRECT'] = array('DEFAULT' => 'true',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enable automatic redirects?', 'USE_SEO_REDIRECT', 'true', 'This will activate the automatic redirect code and send 301 headers for old to new URLs.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['SEO_REWRITE_TYPE'] = array('DEFAULT' => 'Rewrite',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Choose URL Rewrite Type', 'SEO_REWRITE_TYPE', 'Rewrite', 'Choose which SEO URL format to use.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''Rewrite''),')"

);

$x++;

$this->default_config['SEO_CHAR_CONVERT_SET'] = array('DEFAULT' => '',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Enter special character conversions', 'SEO_CHAR_CONVERT_SET', '', 'This setting will convert characters.<br><br>The format <b>MUST</b> be in the form: <b>char=>conv,char2=>conv2</b>', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, NULL)"

);

$x++;

$this->default_config['SEO_REMOVE_ALL_SPEC_CHARS'] = array('DEFAULT' => 'false',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Remove all non-alphanumeric characters?', 'SEO_REMOVE_ALL_SPEC_CHARS', 'false', 'This will remove all non-letters and non-numbers. This should be handy to remove all special characters with 1 setting.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"

);

$x++;

$this->default_config['SEO_URLS_CACHE_RESET'] = array('DEFAULT' => 'false',

'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES ('', 'Reset SEO URLs Cache', 'SEO_URLS_CACHE_RESET', 'false', 'This will reset the cache data for SEO', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), 'tep_reset_cache_data_seo_urls', 'tep_cfg_select_option(array(''reset'', ''false''),')"

);

 

$this->init();

} # end class constructor

 

/**

* Initializer - if there are settings not defined the default config will be used and database settings installed.

* @author Bobby Easland

* @version 1.1

*/

function init(){

foreach( $this->default_config as $key => $value ){

$container[] = defined($key) ? 'true' : 'false';

} # end foreach

$this->attributes['IS_DEFINED'] = in_array('false', $container) ? false : true;

switch(true){

case ( !$this->attributes['IS_DEFINED'] ):

$this->eval_defaults();

$this->DB = new SEO_DataBase(DB_SERVER, DB_SERVER_USERNAME, DB_DATABASE, DB_SERVER_PASSWORD);

$sql = "SELECT configuration_key, configuration_value

FROM " . TABLE_CONFIGURATION . "

WHERE configuration_key LIKE '%SEO%'";

$result = $this->DB->Query($sql);

$num_rows = $this->DB->NumRows($result);

$this->DB->Free($result);

$this->attributes['IS_INSTALLED'] = (sizeof($container) == $num_rows) ? true : false;

if ( !$this->attributes['IS_INSTALLED'] ){

$this->install_settings();

}

break;

default:

$this->attributes['IS_INSTALLED'] = true;

break;

} # end switch

} # end function

 

/**

* This function evaluates the default serrings into defined constants

* @author Bobby Easland

* @version 1.0

*/

function eval_defaults(){

foreach( $this->default_config as $key => $value ){

define($key, $value['DEFAULT']);

} # end foreach

} # end function

 

/**

* This function removes the database settings (configuration and cache)

* @author Bobby Easland

* @version 1.0

*/

function uninstall_settings(){

$this->DB->Query("DELETE FROM `".TABLE_CONFIGURATION_GROUP."` WHERE `configuration_group_title` LIKE '%SEO%'");

$this->DB->Query("DELETE FROM `".TABLE_CONFIGURATION."` WHERE `configuration_key` LIKE '%SEO%'");

$this->DB->Query("DROP TABLE IF EXISTS `cache`");

} # end function

 

/**

* This function installs the database settings

* @author Bobby Easland

* @version 1.0

*/

function install_settings(){

$this->uninstall_settings();

$sort_order_query = "SELECT MAX(sort_order) as max_sort FROM `".TABLE_CONFIGURATION_GROUP."`";

$sort = $this->DB->FetchArray( $this->DB->Query($sort_order_query) );

$next_sort = $sort['max_sort'] + 1;

$insert_group = "INSERT INTO `".TABLE_CONFIGURATION_GROUP."` VALUES ('', 'SEO URLs', 'Options for Ultimate SEO URLs by Chemo', '".$next_sort."', '1')";

$this->DB->Query($insert_group);

$group_id = $this->DB->InsertID();

 

foreach ($this->default_config as $key => $value){

$sql = str_replace('GROUP_INSERT_ID', $group_id, $value['QUERY']);

$this->DB->Query($sql);

}

 

$insert_cache_table = "CREATE TABLE `cache` (

`cache_id` varchar(32) NOT NULL default '',

`cache_language_id` tinyint(1) NOT NULL default '0',

`cache_name` varchar(255) NOT NULL default '',

`cache_data` mediumtext NOT NULL,

`cache_global` tinyint(1) NOT NULL default '1',

`cache_gzip` tinyint(1) NOT NULL default '1',

`cache_method` varchar(20) NOT NULL default 'RETURN',

`cache_date` datetime NOT NULL default '0000-00-00 00:00:00',

`cache_expires` datetime NOT NULL default '0000-00-00 00:00:00',

PRIMARY KEY (`cache_id`,`cache_language_id`),

KEY `cache_id` (`cache_id`),

KEY `cache_language_id` (`cache_language_id`),

KEY `cache_global` (`cache_global`)

) TYPE=MyISAM;";

$this->DB->Query($insert_cache_table);

} # end function

} # end class

 

/**

* Ultimate SEO URLs Base Class

*

* Ultimate SEO URLs offers search engine optimized URLS for osCommerce

* based applications. Other features include optimized performance and

* automatic redirect script.

* @package Ultimate-SEO-URLs

* @license http://opensource.org/licenses/gpl-license.php GNU Public License

* @version 2.1

* @link http://www.oscommerce-freelancers.com/ osCommerce-Freelancers

* @copyright Copyright 2005, Bobby Easland

* @author Bobby Easland

*/

class SEO_URL{

/**

* $cache is the per page data array that contains all of the previously stripped titles

* @var array

*/

var $cache;

/**

* $languages_id contains the language_id for this instance

* @var integer

*/

var $languages_id;

/**

* $attributes array contains all the required settings for class

* @var array

*/

var $attributes;

/**

* $base_url is the NONSSL URL for site

* @var string

*/

var $base_url;

/**

* $base_url_ssl is the secure URL for the site

* @var string

*/

var $base_url_ssl;

/**

* $performance array contains evaluation metric data

* @var array

*/

var $performance;

/**

* $timestamp simply holds the temp variable for time calculations

* @var float

*/

var $timestamp;

/**

* $reg_anchors holds the anchors used by the .htaccess rewrites

* @var array

*/

var $reg_anchors;

/**

* $cache_query is the resource_id used for database cache logic

* @var resource

*/

var $cache_query;

/**

* $cache_file is the basename of the cache database entry

* @var string

*/

var $cache_file;

/**

* $data array contains all records retrieved from database cache

* @var array

*/

var $data;

/**

* $need_redirect determines whether the URL needs to be redirected

* @var boolean

*/

var $need_redirect;

/**

* $is_seopage holds value as to whether page is in allowed SEO pages

* @var boolean

*/

var $is_seopage;

/**

* $uri contains the $_SERVER['REQUEST_URI'] value

* @var string

*/

var $uri;

/**

* $real_uri contains the $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'] value

* @var string

*/

var $real_uri;

/**

* $uri_parsed contains the parsed uri value array

* @var array

*/

var $uri_parsed;

/**

* $path_info contains the getenv('PATH_INFO') value

* @var string

*/

var $path_info;

/**

* $DB is the database object

* @var object

*/

var $DB;

/**

* $installer is the installer object

* @var object

*/

var $installer;

 

/**

* SEO_URL class constructor

* @author Bobby Easland

* @version 1.1

* @param integer $languages_id

*/

function SEO_URL($languages_id){

global $session_started, $SID;

 

$this->installer = new SEO_URL_INSTALLER;

 

$this->DB = new SEO_DataBase(DB_SERVER, DB_SERVER_USERNAME, DB_DATABASE, DB_SERVER_PASSWORD);

 

$this->languages_id = (int)$languages_id;

 

$this->data = array();

 

$seo_pages = array(FILENAME_DEFAULT,

FILENAME_PRODUCT_INFO,

FILENAME_POPUP_IMAGE,

FILENAME_PRODUCT_REVIEWS,

FILENAME_PRODUCT_REVIEWS_INFO);

if ( defined('FILENAME_ARTICLES') ) $seo_pages[] = FILENAME_ARTICLES;

if ( defined('FILENAME_ARTICLE_INFO') ) $seo_pages[] = FILENAME_ARTICLE_INFO;

if ( defined('FILENAME_INFORMATION') ) $seo_pages[] = FILENAME_INFORMATION;

 

$this->attributes = array('PHP_VERSION' => PHP_VERSION,

'SESSION_STARTED' => $session_started,

'SID' => $SID,

'SEO_ENABLED' => defined('SEO_ENABLED') ? SEO_ENABLED : 'false',

'SEO_ADD_CPATH_TO_PRODUCT_URLS' => defined('SEO_ADD_CPATH_TO_PRODUCT_URLS') ? SEO_ADD_CPATH_TO_PRODUCT_URLS : 'false',

'SEO_ADD_CAT_PARENT' => defined('SEO_ADD_CAT_PARENT') ? SEO_ADD_CAT_PARENT : 'true',

'SEO_URLS_USE_W3C_VALID' => defined('SEO_URLS_USE_W3C_VALID') ? SEO_URLS_USE_W3C_VALID : 'true',

'USE_SEO_CACHE_GLOBAL' => defined('USE_SEO_CACHE_GLOBAL') ? USE_SEO_CACHE_GLOBAL : 'false',

'USE_SEO_CACHE_PRODUCTS' => defined('USE_SEO_CACHE_PRODUCTS') ? USE_SEO_CACHE_PRODUCTS : 'false',

'USE_SEO_CACHE_CATEGORIES' => defined('USE_SEO_CACHE_CATEGORIES') ? USE_SEO_CACHE_CATEGORIES : 'false',

'USE_SEO_CACHE_MANUFACTURERS' => defined('USE_SEO_CACHE_MANUFACTURERS') ? USE_SEO_CACHE_MANUFACTURERS : 'false',

'USE_SEO_CACHE_ARTICLES' => defined('USE_SEO_CACHE_ARTICLES') ? USE_SEO_CACHE_ARTICLES : 'false',

'USE_SEO_CACHE_TOPICS' => defined('USE_SEO_CACHE_TOPICS') ? USE_SEO_CACHE_TOPICS : 'false',

'USE_SEO_CACHE_INFO_PAGES' => defined('USE_SEO_CACHE_INFO_PAGES') ? USE_SEO_CACHE_INFO_PAGES : 'false',

'USE_SEO_REDIRECT' => defined('USE_SEO_REDIRECT') ? USE_SEO_REDIRECT : 'false',

'SEO_REWRITE_TYPE' => defined('SEO_REWRITE_TYPE') ? SEO_REWRITE_TYPE : 'false',

'SEO_URLS_FILTER_SHORT_WORDS' => defined('SEO_URLS_FILTER_SHORT_WORDS') ? SEO_URLS_FILTER_SHORT_WORDS : 'false',

'SEO_CHAR_CONVERT_SET' => defined('SEO_CHAR_CONVERT_SET') ? $this->expand(SEO_CHAR_CONVERT_SET) : 'false',

'SEO_REMOVE_ALL_SPEC_CHARS' => defined('SEO_REMOVE_ALL_SPEC_CHARS') ? SEO_REMOVE_ALL_SPEC_CHARS : 'false',

'SEO_PAGES' => $seo_pages,

'SEO_INSTALLER' => $this->installer->attributes

);

 

$this->base_url = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

$this->base_url_ssl = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

$this->cache = array();

$this->timestamp = 0;

 

$this->reg_anchors = array('products_id' => '-p-',

'cPath' => '-c-',

'manufacturers_id' => '-m-',

'pID' => '-pi-',

'tPath' => '-t-',

'articles_id' => '-a-',

'products_id_review' => '-pr-',

'products_id_review_info' => '-pri-',

'info_id' => '-i-'

);

 

$this->performance = array('NUMBER_URLS_GENERATED' => 0,

'NUMBER_QUERIES' => 0,

'CACHE_QUERY_SAVINGS' => 0,

'NUMBER_STANDARD_URLS_GENERATED' => 0,

'TOTAL_CACHED_PER_PAGE_RECORDS' => 0,

'TOTAL_TIME' => 0,

'TIME_PER_URL' => 0,

'QUERIES' => array()

);

 

if ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true'){

$this->cache_file = 'seo_urls_v2_';

$this->cache_gc();

if ( $this->attributes['USE_SEO_CACHE_PRODUCTS'] == 'true' ) $this->generate_products_cache();

if ( $this->attributes['USE_SEO_CACHE_CATEGORIES'] == 'true' ) $this->generate_categories_cache();

if ( $this->attributes['USE_SEO_CACHE_MANUFACTURERS'] == 'true' ) $this->generate_manufacturers_cache();

if ( $this->attributes['USE_SEO_CACHE_ARTICLES'] == 'true' && defined('TABLE_ARTICLES_DESCRIPTION')) $this->generate_articles_cache();

if ( $this->attributes['USE_SEO_CACHE_TOPICS'] == 'true' && defined('TABLE_TOPICS_DESCRIPTION')) $this->generate_topics_cache();

if ( $this->attributes['USE_SEO_CACHE_INFO_PAGES'] == 'true' && defined('TABLE_INFORMATION')) $this->generate_information_cache();

} # end if

 

if ($this->attributes['USE_SEO_REDIRECT'] == 'true'){

$this->check_redirect();

} # end if

} # end constructor

 

/**

* Function to return SEO URL link SEO'd with stock generattion for error fallback

* @author Bobby Easland

* @version 1.0

* @param string $page Base script for URL

* @param string $parameters URL parameters

* @param string $connection NONSSL/SSL

* @param boolean $add_session_id Switch to add osCsid

* @return string Formed href link

*/

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

$this->start($this->timestamp);

$this->performance['NUMBER_URLS_GENERATED']++;

if ( !in_array($page, $this->attributes['SEO_PAGES']) || $this->attributes['SEO_ENABLED'] == 'false' ) {

return $this->stock_href_link($page, $parameters, $connection, $add_session_id);

}

$link = $connection == 'NONSSL' ? $this->base_url : $this->base_url_ssl;

$separator = '?';

if ($this->not_null($parameters)) {

$link .= $this->parse_parameters($page, $parameters, $separator);

} else {

$link .= $page;

}

$link = $this->add_sid($link, $add_session_id, $connection, $separator);

$this->stop($this->timestamp, $time);

$this->performance['TOTAL_TIME'] += $time;

switch($this->attributes['SEO_URLS_USE_W3C_VALID']){

case ('true'):

if (!isset($_SESSION['customer_id']) && defined('ENABLE_PAGE_CACHE') && ENABLE_PAGE_CACHE == 'true' && class_exists('page_cache')){

return $link;

} else {

return htmlspecialchars(utf8_encode($link));

}

break;

case ('false'):

return $link;

break;

}

} # end function

 

/**

* Stock function, fallback use

*/

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

global $request_type, $session_started, $SID;

if (!$this->not_null($page)) {

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

}

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

if ($connection == 'NONSSL') {

$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

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

if (ENABLE_SSL == true) {

$link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

} else {

$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

}

} else {

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

}

if ($this->not_null($parameters)) {

$link .= $page . '?' . $this->output_string($parameters);

$separator = '&';

} else {

$link .= $page;

$separator = '?';

}

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

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

if ($this->not_null($SID)) {

$_sid = $SID;

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

if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {

$_sid = $this->SessionName() . '=' . $this->SessionID();

}

}

}

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

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

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

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

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

$separator = '?';

}

switch(true){

case (!isset($_SESSION['customer_id']) && defined('ENABLE_PAGE_CACHE') && ENABLE_PAGE_CACHE == 'true' && class_exists('page_cache')):

$page_cache = true;

$return = $link . $separator . '<osCsid>';

break;

case (isset($_sid)):

$page_cache = false;

$return = $link . $separator . $_sid;

break;

default:

$page_cache = false;

$return = $link;

break;

} # end switch

$this->performance['NUMBER_STANDARD_URLS_GENERATED']++;

$this->cache['STANDARD_URLS'][] = $link;

$time = 0;

$this->stop($this->timestamp, $time);

$this->performance['TOTAL_TIME'] += $time;

switch(true){

case ($this->attributes['SEO_URLS_USE_W3C_VALID'] == 'true' && !$page_cache):

return htmlspecialchars(utf8_encode($return));

break;

default:

return $return;

break;

}# end swtich

} # end default tep_href function

 

/**

* Function to append session ID if needed

* @author Bobby Easland

* @version 1.2

* @param string $link

* @param boolean $add_session_id

* @param string $connection

* @param string $separator

* @return string

*/

function add_sid( $link, $add_session_id, $connection, $separator ){

global $request_type; // global variable

if ( ($add_session_id) && ($this->attributes['SESSION_STARTED']) && (SESSION_FORCE_COOKIE_USE == 'False') ) {

if ($this->not_null($this->attributes['SID'])) {

$_sid = $this->attributes['SID'];

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

if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {

$_sid = $this->SessionName() . '=' . $this->SessionID();

}

}

}

switch(true){

case (!isset($_SESSION['customer_id']) && defined('ENABLE_PAGE_CACHE') && ENABLE_PAGE_CACHE == 'true' && class_exists('page_cache')):

$return = $link . $separator . '<osCsid>';

break;

case ($this->not_null($_sid)):

$return = $link . $separator . $_sid;

break;

default:

$return = $link;

break;

} # end switch

return $return;

} # end function

 

/**

* SFunction to parse the parameters into an SEO URL

* @author Bobby Easland

* @version 1.2

* @param string $page

* @param string $params

* @param string $separator NOTE: passed by reference

* @return string

*/

function parse_parameters($page, $params, &$separator){

$p = @explode('&', $params);

krsort($p);

$container = array();

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

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

switch ($p2[0]){

case 'products_id':

switch(true){

case ( $page == FILENAME_PRODUCT_INFO && !$this->is_attribute_string($p2[1]) ):

$url = $this->make_url($page, $this->get_product_name($p2[1]), $p2[0], $p2[1], '.html', $separator);

break;

case ( $page == FILENAME_PRODUCT_REVIEWS ):

$url = $this->make_url($page, $this->get_product_name($p2[1]), 'products_id_review', $p2[1], '.html', $separator);

break;

case ( $page == FILENAME_PRODUCT_REVIEWS_INFO ):

$url = $this->make_url($page, $this->get_product_name($p2[1]), 'products_id_review_info', $p2[1], '.html', $separator);

break;

default:

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

break;

} # end switch

break;

case 'cPath':

switch(true){

case ($page == FILENAME_DEFAULT):

$url = $this->make_url($page, $this->get_category_name($p2[1]), $p2[0], $p2[1], '.html', $separator);

break;

case ( !$this->is_product_string($params) ):

if ( $this->attributes['SEO_ADD_CPATH_TO_PRODUCT_URLS'] == 'true' ){

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

}

break;

default:

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

break;

} # end switch

break;

case 'manufacturers_id':

switch(true){

case ($page == FILENAME_DEFAULT && !$this->is_cPath_string($params) && !$this->is_product_string($params) ):

$url = $this->make_url($page, $this->get_manufacturer_name($p2[1]), $p2[0], $p2[1], '.html', $separator);

break;

case ($page == FILENAME_PRODUCT_INFO):

break;

default:

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

break;

} # end switch

break;

case 'pID':

switch(true){

case ($page == FILENAME_POPUP_IMAGE):

$url = $this->make_url($page, $this->get_product_name($p2[1]), $p2[0], $p2[1], '.html', $separator);

break;

default:

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

break;

} # end switch

break;

case 'tPath':

switch(true){

case ($page == FILENAME_ARTICLES):

$url = $this->make_url($page, $this->get_topic_name($p2[1]), $p2[0], $p2[1], '.html', $separator);

break;

default:

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

break;

} # end switch

break;

case 'articles_id':

switch(true){

case ($page == FILENAME_ARTICLE_INFO):

$url = $this->make_url($page, $this->get_article_name($p2[1]), $p2[0], $p2[1], '.html', $separator);

break;

default:

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

break;

} # end switch

break;

case 'info_id':

switch(true){

case ($page == FILENAME_INFORMATION):

$url = $this->make_url($page, $this->get_information_name($p2[1]), $p2[0], $p2[1], '.html', $separator);

break;

default:

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

break;

} # end switch

break;

default:

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

break;

} # end switch

} # end foreach $p

$url = isset($url) ? $url : $page;

if ( sizeof($container) > 0 ){

if ( $imploded_params = $this->implode_assoc($container) ){

$url .= $separator . $this->output_string( $imploded_params );

$separator = '&';

}

}

return $url;

} # end function

 

/**

* Function to return the generated SEO URL

* @author Bobby Easland

* @version 1.0

* @param string $page

* @param string $string Stripped, formed anchor

* @param string $anchor_type Parameter type (products_id, cPath, etc.)

* @param integer $id

* @param string $extension Default = .html

* @param string $separator NOTE: passed by reference

* @return string

*/

function make_url($page, $string, $anchor_type, $id, $extension = '.html', &$separator){

// Right now there is but one rewrite method since cName was dropped

// In the future there will be additional methods here in the switch

switch ( $this->attributes['SEO_REWRITE_TYPE'] ){

case 'Rewrite':

return $string . $this->reg_anchors[$anchor_type] . $id . $extension;

break;

default:

break;

} # end switch

} # end function

 

/**

* Function to get the product name. Use evaluated cache, per page cache, or database query in that order of precedent

* @author Bobby Easland

* @version 1.1

* @param integer $pID

* @return string Stripped anchor text

*/

function get_product_name($pID){

switch(true){

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && defined('PRODUCT_NAME_' . $pID)):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = constant('PRODUCT_NAME_' . $pID);

$this->cache['PRODUCTS'][$pID] = $return;

break;

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && isset($this->cache['PRODUCTS'][$pID])):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = $this->cache['PRODUCTS'][$pID];

break;

default:

$this->performance['NUMBER_QUERIES']++;

$sql = "SELECT products_name as pName

FROM ".TABLE_PRODUCTS_DESCRIPTION."

WHERE products_id='".(int)$pID."'

AND language_id='".(int)$this->languages_id."'

LIMIT 1";

$result = $this->DB->FetchArray( $this->DB->Query( $sql ) );

$pName = $this->strip( $result['pName'] );

$this->cache['PRODUCTS'][$pID] = $pName;

$this->performance['QUERIES']['PRODUCTS'][] = $sql;

$return = $pName;

break;

} # end switch

return $return;

} # end function

 

/**

* Function to get the category name. Use evaluated cache, per page cache, or database query in that order of precedent

* @author Bobby Easland

* @version 1.1

* @param integer $cID NOTE: passed by reference

* @return string Stripped anchor text

*/

function get_category_name(&$cID){

$full_cPath = $this->get_full_cPath($cID, $single_cID); // full cPath needed for uniformity

switch(true){

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && defined('CATEGORY_NAME_' . $full_cPath)):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = constant('CATEGORY_NAME_' . $full_cPath);

$this->cache['CATEGORIES'][$full_cPath] = $return;

break;

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && isset($this->cache['CATEGORIES'][$full_cPath])):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = $this->cache['CATEGORIES'][$full_cPath];

break;

default:

$this->performance['NUMBER_QUERIES']++;

switch(true){

case ($this->attributes['SEO_ADD_CAT_PARENT'] == 'true'):

$sql = "SELECT c.categories_id, c.parent_id, cd.categories_name as cName, cd2.categories_name as pName

FROM ".TABLE_CATEGORIES." c,

".TABLE_CATEGORIES_DESCRIPTION." cd

LEFT JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd2

ON c.parent_id=cd2.categories_id AND cd2.language_id='".(int)$this->languages_id."'

WHERE c.categories_id='".(int)$single_cID."'

AND cd.categories_id='".(int)$single_cID."'

AND cd.language_id='".(int)$this->languages_id."'

LIMIT 1";

$result = $this->DB->FetchArray( $this->DB->Query( $sql ) );

$cName = $this->not_null($result['pName']) ? $result['pName'] . ' ' . $result['cName'] : $result['cName'];

break;

default:

$sql = "SELECT categories_name as cName

FROM ".TABLE_CATEGORIES_DESCRIPTION."

WHERE categories_id='".(int)$single_cID."'

AND language_id='".(int)$this->languages_id."'

LIMIT 1";

$result = $this->DB->FetchArray( $this->DB->Query( $sql ) );

$cName = $result['cName'];

break;

}

$cName = $this->strip($cName);

$this->cache['CATEGORIES'][$full_cPath] = $cName;

$this->performance['QUERIES']['CATEGORIES'][] = $sql;

$return = $cName;

break;

} # end switch

$cID = $full_cPath;

return $return;

} # end function

 

/**

* Function to get the manufacturer name. Use evaluated cache, per page cache, or database query in that order of precedent.

* @author Bobby Easland

* @version 1.1

* @param integer $mID

* @return string

*/

function get_manufacturer_name($mID){

switch(true){

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && defined('MANUFACTURER_NAME_' . $mID)):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = constant('MANUFACTURER_NAME_' . $mID);

$this->cache['MANUFACTURERS'][$mID] = $return;

break;

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && isset($this->cache['MANUFACTURERS'][$mID])):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = $this->cache['MANUFACTURERS'][$mID];

break;

default:

$this->performance['NUMBER_QUERIES']++;

$sql = "SELECT manufacturers_name as mName

FROM ".TABLE_MANUFACTURERS."

WHERE manufacturers_id='".(int)$mID."'

LIMIT 1";

$result = $this->DB->FetchArray( $this->DB->Query( $sql ) );

$mName = $this->strip( $result['mName'] );

$this->cache['MANUFACTURERS'][$mID] = $mName;

$this->performance['QUERIES']['MANUFACTURERS'][] = $sql;

$return = $mName;

break;

} # end switch

return $return;

} # end function

 

/**

* Function to get the article name. Use evaluated cache, per page cache, or database query in that order of precedent.

* @author Bobby Easland

* @version 1.0

* @param integer $aID

* @return string

*/

function get_article_name($aID){

switch(true){

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && defined('ARTICLE_NAME_' . $aID)):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = constant('ARTICLE_NAME_' . $aID);

$this->cache['ARTICLES'][$aID] = $return;

break;

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && isset($this->cache['ARTICLES'][$aID])):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = $this->cache['ARTICLES'][$aID];

break;

default:

$this->performance['NUMBER_QUERIES']++;

$sql = "SELECT articles_name as aName

FROM ".TABLE_ARTICLES_DESCRIPTION."

WHERE articles_id='".(int)$aID."'

AND language_id='".(int)$this->languages_id."'

LIMIT 1";

$result = $this->DB->FetchArray( $this->DB->Query( $sql ) );

$aName = $this->strip( $result['aName'] );

$this->cache['ARTICLES'][$aID] = $aName;

$this->performance['QUERIES']['ARTICLES'][] = $sql;

$return = $aName;

break;

} # end switch

return $return;

} # end function

 

/**

* Function to get the topic name. Use evaluated cache, per page cache, or database query in that order of precedent.

* @author Bobby Easland

* @version 1.1

* @param integer $tID

* @return string

*/

function get_topic_name($tID){

switch(true){

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && defined('TOPIC_NAME_' . $tID)):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = constant('TOPIC_NAME_' . $tID);

$this->cache['TOPICS'][$tID] = $return;

break;

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && isset($this->cache['TOPICS'][$tID])):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = $this->cache['TOPICS'][$tID];

break;

default:

$this->performance['NUMBER_QUERIES']++;

$sql = "SELECT topics_name as tName

FROM ".TABLE_TOPICS_DESCRIPTION."

WHERE topics_id='".(int)$tID."'

AND language_id='".(int)$this->languages_id."'

LIMIT 1";

$result = $this->DB->FetchArray( $this->DB->Query( $sql ) );

$tName = $this->strip( $result['tName'] );

$this->cache['ARTICLES'][$aID] = $tName;

$this->performance['QUERIES']['TOPICS'][] = $sql;

$return = $tName;

break;

} # end switch

return $return;

} # end function

 

/**

* Function to get the informatin name. Use evaluated cache, per page cache, or database query in that order of precedent.

* @author Bobby Easland

* @version 1.1

* @param integer $iID

* @return string

*/

function get_information_name($iID){

switch(true){

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && defined('INFO_NAME_' . $iID)):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = constant('INFO_NAME_' . $iID);

$this->cache['INFO'][$iID] = $return;

break;

case ($this->attributes['USE_SEO_CACHE_GLOBAL'] == 'true' && isset($this->cache['INFO'][$iID])):

$this->performance['CACHE_QUERY_SAVINGS']++;

$return = $this->cache['INFO'][$iID];

break;

default:

$this->performance['NUMBER_QUERIES']++;

$sql = "SELECT info_title as iName

FROM ".TABLE_INFORMATION."

WHERE information_id='".(int)$iID."'

AND languages_id='".(int)$this->languages_id."'

LIMIT 1";

$result = $this->DB->FetchArray( $this->DB->Query( $sql ) );

$iName = $this->strip( $result['iName'] );

$this->cache['INFO'][$iID] = $iName;

$this->performance['QUERIES']['INFO'][] = $sql;

$return = $iName;

break;

} # end switch

return $return;

} # end function

 

/**

* Function to retrieve full cPath from category ID

* @author Bobby Easland

* @version 1.1

* @param mixed $cID Could contain cPath or single category_id

* @param integer $original Single category_id passed back by reference

* @return string Full cPath string

*/

function get_full_cPath($cID, &$original){

if ( is_numeric(strpos($cID, '_')) ){

$temp = @explode('_', $cID);

$original = $temp[sizeof($temp)-1];

return $cID;

} else {

$c = array();

$this->GetParentCategories($c, $cID);

$c = array_reverse($c);

$c[] = $cID;

$original = $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 not_null($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 check if the products_id contains an attribute

* @author Bobby Easland

* @version 1.1

* @param integer $pID

* @return boolean

*/

function is_attribute_string($pID){

if ( is_numeric(strpos($pID, '{')) ){

return true;

} else {

return false;

}

} # end function

 

/**

* Function to check if the params contains a products_id

* @author Bobby Easland

* @version 1.1

* @param string $params

* @return boolean

*/

function is_product_string($params){

if ( is_numeric(strpos('products_id', $params)) ){

return true;

} else {

return false;

}

} # end function

 

/**

* Function to check if cPath is in the parameter string

* @author Bobby Easland

* @version 1.0

* @param string $params

* @return boolean

*/

function is_cPath_string($params){

if ( eregi('cPath', $params) ){

return true;

} else {

return false;

}

} # end function

 

/**

* Function used to output class profile

* @author Bobby Easland

* @version 1.0

*/

function profile(){

$this-&g

Share this post


Link to post
Share on other sites

I'm a little confused at the basic level. I installed version 1.3 and ran it, generated good files and all is fine there. At the end of the process, I used the included link to submit to Google:

 

 

The one line response told me it was submitted and no guarantees on what it would do, etc. Now I see you can also get an account and log in to submit and view results. What exactly is the difference in these two methods? Should I create an account and resubmit my sitemapindex.xml? Thanks for any guidance on this.

 

David

Edited by DavidR

Share this post


Link to post
Share on other sites
I'm a little confused at the basic level.  I installed version 1.3 and ran it, generated good files and all is fine there.  At the end of the process, I used the included link to submit to Google:

The one line response told me it was submitted and no guarantees on what it would do, etc.  Now I see you can also get an account and log in to submit and view results.  What exactly is the difference in these two methods?  Should I create an account and resubmit my sitemapindex.xml?  Thanks for any guidance on this.

 

David

 

I did both methods and the latter option seemed to work best for me. Create an account with Google and submit it that way. You'll only have to do it once. I've had amazing result thanks to this contribution. Before submitting the sitmap, google had indexed 40 pages. Today, its up to 317. Its clever stuff.

 

Cheers,

 

Fish

Share this post


Link to post
Share on other sites

Thanks very much for your reply. I will do as you sugested. Chemo does write some cool stuff!

 

David

Share this post


Link to post
Share on other sites

Chemo, this contribution is HOTT!! :thumbsup: You are a genius.


Stress is a luxury afforded to those of us that need it least.

Where lipstick is concerned, the important thing is not color, but to accept God's final word on where your lips end. --Jerry Seinfeld

If you pick up a starving dog, and make him prosperous, he will not bite you. This is the principal difference between a man and a dog. --Mark Twain

Share this post


Link to post
Share on other sites
Chemo, this contribution is HOTT!!  :thumbsup:  You are a genius.

That's true!!

 

When opening an account for your sitemap you must agree to the terms.

I've read the terms of google and i am a bit confused how to read this;

Personal Use Only

The Google Services are made available for your personal, non-commercial use only. You may not use the Google Services to sell a product or service, or to increase traffic to your Web site for commercial reasons, such as advertising sales. You may not take the results from a Google search and reformat and display them, or mirror the Google home page or results pages on your Web site. You may not "meta-search" Google. If you want to make commercial use of the Google Services, you must enter into an agreement with Google to do so in advance.

Does this mean , I cannot use their sitemap service for commercial purposes?


Kind regards

 

Hakan Haknuz

Share this post


Link to post
Share on other sites
Unless you sign up for a business account, i think your violating the G rules.

True or not?

That's one heck of a good question...


Stress is a luxury afforded to those of us that need it least.

Where lipstick is concerned, the important thing is not color, but to accept God's final word on where your lips end. --Jerry Seinfeld

If you pick up a starving dog, and make him prosperous, he will not bite you. This is the principal difference between a man and a dog. --Mark Twain

Share this post


Link to post
Share on other sites
That's true!!

 

When opening an account for your sitemap you must agree to the terms.

I've read the terms of google  and i am a bit confused how to read this;

 

Does this mean , I cannot use their sitemap service for commercial purposes?

In the FAQ of the normal account signup (what you are calling personal account I believe), it says:

 

2. Who can use Google Sitemaps?

 

Google Sitemaps is intended for all web site owners, from those with a single web page to companies with millions of ever-changing pages. If either of the following are true, then you may be especially interested in Google Sitemaps:

 

You want Google to crawl more of your web pages.

You want to be able to tell Google when content on your site changes

I believe the agreement wording in question referrs to those who would use the Site Map service itself as a business opportunity, ie selling access to the service, using it to manipulate ad sales in ways people may already be dreaming up. It's a blanket clause to make it easier and legal for Google to ban "blackhat" SEO using the Site Map service when they find it. Ultimately, how many companies with "millions of ever-changing pages" are not selling something?

 

David

Share this post


Link to post
Share on other sites
In the FAQ of the normal account signup (what you are calling personal account I believe), it says:

I believe the agreement wording in question referrs to those who would use the Site Map service itself as a business opportunity, ie selling access to the service, using it to manipulate ad sales in ways people may already be dreaming up.  It's a blanket clause to make it easier and legal for Google to ban "blackhat" SEO using the Site Map service when they find it.  Ultimately, how many companies with "millions of ever-changing pages" are not selling something?

 

David

Very good point.


Stress is a luxury afforded to those of us that need it least.

Where lipstick is concerned, the important thing is not color, but to accept God's final word on where your lips end. --Jerry Seinfeld

If you pick up a starving dog, and make him prosperous, he will not bite you. This is the principal difference between a man and a dog. --Mark Twain

Share this post


Link to post
Share on other sites

Warning: main(DIR_WS_INCLUDESfilenames.php): failed to open stream: No such file or directory in /home/indir/public_html/googlesitemap/index.php on line 39

 

Fatal error: main(): Failed opening required 'DIR_WS_INCLUDESfilenames.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/indir/public_html/googlesitemap/index.php on line 39

 

 

what must I do fully ? please help....

Share this post


Link to post
Share on other sites
In the FAQ of the normal account signup (what you are calling personal account I believe), it says:

I believe the agreement wording in question referrs to those who would use the Site Map service itself as a business opportunity, ie selling access to the service, using it to manipulate ad sales in ways people may already be dreaming up.  It's a blanket clause to make it easier and legal for Google to ban "blackhat" SEO using the Site Map service when they find it.  Ultimately, how many companies with "millions of ever-changing pages" are not selling something?

 

David

Tha't's true it's definately a blanket clause, but how it is used and to whom it is , is up to G, it could be the black SEO's , but could easily be"" many companies with "millions of ever-changing pages"" , just for not signing up to a business account and still using google services to promote sales .

 

The blackhat SEO's still can use their services without an agreement ,

Do I need to sign up for a Google Account?

 

You don't need an account to generate and submit a Sitemap. However, we encourage you to sign up for an account so that you can track the status of your Sitemaps and view diagnostic information for your submissions. Having an account will not affect your site's ranking within our results. If you already use Gmail, Groups, My Search History, Alerts, or Froogle Shopping List, you already have a Google Account and can sign in with your existing account to use Google Sitemaps.

As i see it they tell me it does not cost anything to use their services and i can use their services with my gmail account, wich i already had

But then my problem is the terms

Personal Use Only

The Google Services are made available for your personal, non-commercial use only. You may not use the Google Services to sell a product or service, or to increase traffic to your Web site for commercial reasons, such as advertising sales. You may not take the results from a Google search and reformat and display them, or mirror the Google home page or results pages on your Web site. You may not "meta-search" Google. If you want to make commercial use of the Google Services, you must enter into an agreement with Google to do so in advance. Please contact us for more information. 

And true, with millions of companies, who can say what G will do to the ones who still use their personal account for commercial purposes and what are the chances you will be involved in this. In that case you rely on safety in numbers..

But you have no garantee G wouldn't pursue you for violating their rules.

 

What should i do then, use a business account, just to be safe?


Kind regards

 

Hakan Haknuz

Share this post


Link to post
Share on other sites
Tha't's true it's definately a blanket clause, but how it is used and to whom it is , is up to G, it could be the black SEO's , but could easily be"" many companies with "millions of ever-changing pages"" , just for not signing up to a business account and still using google services to promote sales .

 

The blackhat SEO's still can use their services  without an agreement ,

 

As i see it  they tell me it does not cost anything to use their services and i can use their services with my gmail account, wich i already had

But then my problem is the terms

 

And true, with millions of companies, who can say what G will do to the ones who still use their personal account for commercial purposes and what are the chances you will be involved in this. In that case you rely on safety in numbers..

But you have no garantee G wouldn't pursue you for violating their rules.

 

What should i do then, use a business account, just to be safe?

 

I really believe you are over-thinking this one but if you are concerned, why not do as they suggest and contact Google to find out? That would seem to be the next logical step.

 

The statement "many companies with millions of ever-changing pages" came from the FAQ in what you are calling the personal account. Good luck.

 

David

Share this post


Link to post
Share on other sites

I have this same problem after a successful install then clicking on catalog or administration tools.

 

It looks like DIR_WS_INCLUDES needs to be defined somehow. Anyone know how this is supposed to be done?

 

Thanks,

-Dan

 

 

 

Warning: main(DIR_WS_INCLUDESfilenames.php): failed to open stream: No such file or directory in /home/indir/public_html/googlesitemap/index.php on line 39

 

Fatal error: main(): Failed opening required 'DIR_WS_INCLUDESfilenames.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/indir/public_html/googlesitemap/index.php on line 39

what must I do fully ? please help....

Share this post


Link to post
Share on other sites

I think it will be ok now, after one week, finafinally!

 

 

After installed this greate mod one week, and modified something in the googlesitemap/index.php file and contacted our serer provider, today I first time received my cron job email says the sitemap generated successfully.

 

But I want to point some out to see if someone else have the same problems as I had.

 

1. after installed, point to http://the/path/to/googlesitemap/index.php, it generated 3 files. But the file names are googlesitemapsitemapindex, googlesitemapsitemapproducts.xml and googlesitemapsitemapcategories.xml instead of the sitemapindex.xml, sitemapproducts.xml and sitemapcategories.xml.

 

2. So, even I upload the sitemapindex.xml, sitemapproducts.xml and sitemapcategories.xml files to my server, and change the permissions to 777, which is useless, because the mod will not use these files.

 

3. The generated files are, at default, at the "httpd" ownership(mine is a linux server), and the permissions set to 644. Which means the cron job can't access them, also I can't change the permissions by myself. After contact my server provider to ask them to change the file's permissions to 777 and at my own username ownership, the cron job worked.

 

4. But the cron command may not work. instead php /the/path/to/googlesitemap/index.php, mine must set to : /usr/local/bin/php /the/path/to/googlesitemap/index.php.

 

5. At last, the path in the googlesitemap/index.php file doesn't work. In the googlesitemap/index.php file, all the catalog constant variables refer to the file path can't work. Such as "DIR_WS_INCLUDES", "includes/configure.php", DIR_WS_CLASSES etc. After I hand coded into the absolute path(/the/path/to/catalog), it works fine now.

 

6. The submit. When you submit, you may have to set the submit url to "http://yourdomain.com/catalog/googlesitemapsitemapindex" not the "http://www.yourdomain.com/catalog/googlesitemapsitemapindex", have no the "www." in the url. My site in the catalog folder not in the root, so maybe yours are differnt. But the reason is, the SEO mod generated my url links are all no-www format, so when I submit my xml file in the www.mydomain.com/catalog format, the google says many my urls are not in same domain of my sitemap.

 

So, that is. I hope above can help some folks have the same problems, and can help improve this mod in the future.

Share this post


Link to post
Share on other sites
I think it will be ok now, after one week, finally!

After installed this greate mod one week, and modified something in the googlesitemap/index.php file and contacted our serer provider, today at the first time, I received my cron job email says the sitemap generated successfully.

 

But I want to point some out to see if someone else have the same problems as I had.

 

1. after installed, point to http://the/path/to/googlesitemap/index.php, it generated 3 files. But the file names are googlesitemapsitemapindex, googlesitemapsitemapproducts.xml and googlesitemapsitemapcategories.xml instead of the sitemapindex.xml, sitemapproducts.xml and sitemapcategories.xml.

 

2. So, even I upload the sitemapindex.xml, sitemapproducts.xml and sitemapcategories.xml files to my server, and change the permissions to 777, which is useless, because the mod will not use these files.

 

3. The generated files are, at default, at the "httpd" ownership(mine is a linux server), and the permissions set to 644. Which means the cron job can't access them, also I can't change the permissions by myself. After contact my server provider to ask them to change the file's permissions to 777 and at my own username ownership, the cron job worked.

 

4. But the cron command may not work. instead php /the/path/to/googlesitemap/index.php, mine must set to : /usr/local/bin/php /the/path/to/googlesitemap/index.php.

 

5. At last, the path in the googlesitemap/index.php file doesn't work. In the googlesitemap/index.php file, all the catalog constant variables refer to the file path can't work. Such as "DIR_WS_INCLUDES", "includes/configure.php", DIR_WS_CLASSES etc. After I hand coded into the absolute path(/the/path/to/catalog), it works fine now.

 

6. The submit. When you submit, you may have to set the submit url to "http://yourdomain.com/catalog/googlesitemapsitemapindex" not the "http://www.yourdomain.com/catalog/googlesitemapsitemapindex", have no the "www." in the url. My site in the catalog folder not in the root, so maybe yours are different. But the reason is, the SEO mod generated my url links are all no-www format, so when I submit my xml file in the www.mydomain.com/catalog format, the google says many my urls are not in same domain of my sitemap and google can't accept them.

 

So, that is. I hope above can help some folks have the same problems, and can help improve this mod in the future.

 

Can I edit my post after I posted it? Sorry for the typo in the previous one.

Share this post


Link to post
Share on other sites
I really believe you are over-thinking this one but if you are concerned, why not do as they suggest and contact Google to find out?  That would seem to be the next logical step.

 

The statement "many companies with millions of ever-changing pages" came from the FAQ in what you are calling the personal account.  Good luck.

 

David

 

I 've already did that, before posting here actually, But i am still waiting for an answer from G.

In the meantimne i just wanted some opinions from other sitemap users and i would like to hear how other users solved this problem.

Did the majority sign up for a business account or for a personal account?

But as you stated i shall wait for my answer from G,..cuz there's no good information over here.. :thumbsup:


Kind regards

 

Hakan Haknuz

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

×