Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

jQuery/Ajax Advanced Caching System 2.3.3


Dr. Rolex

Recommended Posts

Running

// include cache functions if enabled

var_dump(phpversion('apc'));

var_dump(phpversion());

var_dump(apc_cache_info('user'));

die;

include(DIR_WS_FUNCTIONS . 'cache.php');

bool(false) string(6) "5.3.24"

Fatal error: Call to undefined function apc_cache_info() in C:\Inetpub\wwwroot\ashoptest\includes\application_top.php on line 75

 

 

// include cache functions if enabled

print_r(phpversion('apc'));

print_r(phpversion());

print_r(apc_cache_info('user'));

die;

include(DIR_WS_FUNCTIONS . 'cache.php'); same if I run this

5.3.24

Fatal error: Call to undefined function apc_cache_info() in C:\Inetpub\wwwroot\ashoptest\includes\application_top.php on line 75

 

If I leave it include(DIR_WS_FUNCTIONS . 'cache.php');

Index.php is up with errors

Notice: Undefined index: products_id in C:\Inetpub\wwwroot\ashoptest\includes\application_top.php on line 515

 

Warning: array_key_exists() expects parameter 2 to be array, null given in C:\Inetpub\wwwroot\ashoptest\includes\application_top.php on line 515

 

To start I had to comment out // set the level of error reporting

error_reporting(E_ALL);

//xdebug_disable();

in both application_top.phps.

I tried the 4th time last night deleted the whole site reloaded 2.3.3.4 again and did all the files manually- no luck so I changed the files that had errors from the uploads and admin is working. with only

error.gif Error: Attempt to write configuration cache file failed! (Array)

error.gif Error: Attempt to write configuration cache file failed!

I am sure this is related to APc not working.

I am going to try and compile php_apc.dll one more time for php 5.3.24 but having hard time finding one

 

Thanks for your fine work.

Link to comment
Share on other sites

Running

// include cache functions if enabled

var_dump(phpversion('apc'));

var_dump(phpversion());

var_dump(apc_cache_info('user'));

die;

include(DIR_WS_FUNCTIONS . 'cache.php');

bool(false) string(6) "5.3.24"

Fatal error: Call to undefined function apc_cache_info() in C:\Inetpub\wwwroot\ashoptest\includes\application_top.php on line 75

 

 

// include cache functions if enabled

print_r(phpversion('apc'));

print_r(phpversion());

print_r(apc_cache_info('user'));

die;

include(DIR_WS_FUNCTIONS .'cache.php'); same if I run this

5.3.24

Fatal error: Call to undefined function apc_cache_info() in C:\Inetpub\wwwroot\ashoptest\includes\application_top.php on line 75

 

If I leave it include(DIR_WS_FUNCTIONS . 'cache.php');

Index.php is up with errors

Notice: Undefined index: products_id in C:\Inetpub\wwwroot\ashoptest\includes\application_top.php on line 515

 

Warning: array_key_exists() expects parameter 2 to be array, null given in C:\Inetpub\wwwroot\ashoptest\includes\application_top.php on line 515

 

To start I had to comment out // set the level of error reporting

error_reporting(E_ALL);

//xdebug_disable();

in both application_top.phps.

I tried the 4th time last night deleted the whole site reloaded 2.3.3.4 again and did all the files manually- no luck so I changed the files that had errors from the uploads and admin is working. with only

http://sansabalongdrive.mobi/admin/images/icons/error.gif[/img] Error: Attempt to write configuration cache file failed! (Array)

http://sansabalongdrive.mobi/admin/images/icons/error.gif[/img] Error: Attempt to write configuration cache file failed!

I am sure this is related to APc not working.

I am going to try and compile php_apc.dll one more time for php 5.3.24 but having hard time finding one

 

Thanks for your fine work.

 

You're right, you're getting those errors because PHP_APC isn't installed. It shouldn't be a problem however, but anyway, to solve it either install PHP_APC. You can find the DLLs here:

http://pecl.php.net/package/APC

 

Or you can simply remove the apc functions.

 

In ./admin/includes/functions/general.php, replace this:

function tep_reset_cache_block($cache_block) {
global $cache_blocks, $messageStack;
if (function_exists('apc_cache_info') && ini_get('apc.enabled') == '1') {
 $cached_apc_variables = apc_cache_info('user')['cache_list'];
 foreach ($cached_apc_variables as $stored_var) {
 if (strpos($stored_var['info'], $cache_block) !== false) {
	 if (apc_delete($stored_var['info'])) {
	 $messageStack->add_session(sprintf(SUCCESS_DELETE_CACHE, $stored_var['info']), 'success');
	 }
 }
 }
 return false;
} else {
 for ($i=0, $n=sizeof($cache_blocks); $i<$n; $i++) {
 if (strpos($cache_blocks[$i]['code'], $cache_block) !== false) {
	 if ($cache_blocks[$i]['multiple']) {
	 if ($dir = @opendir(DIR_FS_CACHE)) {
		 while ($cache_file = readdir($dir)) {
		 $cached_file = $cache_blocks[$i]['file'];
		 $languages = tep_get_languages();
		 for ($j=0, $k=sizeof($languages); $j<$k; $j++) {
			 $cached_file_unlink = str_replace('-language', '-' . $languages[$j]['directory'], $cached_file);
			 $cached_file_unlink_2 = str_replace('-language', '-language-' . $languages[$j]['directory'], $cached_file);
			 if (preg_match('/^' . $cached_file_unlink . '/', $cache_file)) {
			 if (unlink(DIR_FS_CACHE . $cache_file) === true) {
				 $messageStack->add_session(sprintf(SUCCESS_DELETE_CACHE, $cache_file), 'success');
			 }
			 }
			 if (preg_match('/^' . $cached_file_unlink_2 . '/', $cache_file)) {
			 if (unlink(DIR_FS_CACHE . $cached_file_unlink_2) === true) {
				 $messageStack->add_session(sprintf(SUCCESS_DELETE_CACHE, $cached_file_unlink_2), 'success');
			 }
			 }

		 }
		 }
		 closedir($dir);
	 }
	 } else {
	 $cached_file = $cache_blocks[$i]['file'];
	 $languages = tep_get_languages();
	 for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
		 $cached_file = str_replace('-language', '-' . $languages[$i]['directory'], $cached_file);
		 @unlink(DIR_FS_CACHE . $cached_file);
	 }
	 }
 //break;
 }
 }
}
}

 

With this:

function tep_reset_cache_block($cache_block) {
global $cache_blocks, $messageStack;
/* if (function_exists('apc_cache_info') && ini_get('apc.enabled') == '1') {
 $cached_apc_variables = apc_cache_info('user')['cache_list'];
 foreach ($cached_apc_variables as $stored_var) {
 if (strpos($stored_var['info'], $cache_block) !== false) {
	 if (apc_delete($stored_var['info'])) {
	 $messageStack->add_session(sprintf(SUCCESS_DELETE_CACHE, $stored_var['info']), 'success');
	 }
 }
 }
 return false;
} else {*/
 for ($i=0, $n=sizeof($cache_blocks); $i<$n; $i++) {
 if (strpos($cache_blocks[$i]['code'], $cache_block) !== false) {
	 if ($cache_blocks[$i]['multiple']) {
	 if ($dir = @opendir(DIR_FS_CACHE)) {
		 while ($cache_file = readdir($dir)) {
		 $cached_file = $cache_blocks[$i]['file'];
		 $languages = tep_get_languages();
		 for ($j=0, $k=sizeof($languages); $j<$k; $j++) {
			 $cached_file_unlink = str_replace('-language', '-' . $languages[$j]['directory'], $cached_file);
			 $cached_file_unlink_2 = str_replace('-language', '-language-' . $languages[$j]['directory'], $cached_file);
			 if (preg_match('/^' . $cached_file_unlink . '/', $cache_file)) {
			 if (unlink(DIR_FS_CACHE . $cache_file) === true) {
				 $messageStack->add_session(sprintf(SUCCESS_DELETE_CACHE, $cache_file), 'success');
			 }
			 }
			 if (preg_match('/^' . $cached_file_unlink_2 . '/', $cache_file)) {
			 if (unlink(DIR_FS_CACHE . $cached_file_unlink_2) === true) {
				 $messageStack->add_session(sprintf(SUCCESS_DELETE_CACHE, $cached_file_unlink_2), 'success');
			 }
			 }

		 }
		 }
		 closedir($dir);
	 }
	 } else {
	 $cached_file = $cache_blocks[$i]['file'];
	 $languages = tep_get_languages();
	 for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
		 $cached_file = str_replace('-language', '-' . $languages[$i]['directory'], $cached_file);
		 @unlink(DIR_FS_CACHE . $cached_file);
	 }
	 }
 //break;
 }
 }
// }
}

 

Replace ./admin/includes/functions/cache.php with this:

<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2006 osCommerce
Released under the GNU General Public License
*/
////
//! Write out serialized data.
// write_cache uses serialize() to store $var in $filename.
// $var	 - The variable to be written out.
// $filename - The name of the file to write to.
function write_cache(&$var, $filename, $auto_expire = false) {

$filename = DIR_FS_CACHE_DIR . $filename;
$success = false;

// try to open the file
if ($fp = @fopen($filename, 'w')) {
// obtain a file lock to stop corruptions occuring
 flock($fp, 2); // LOCK_EX
// write serialized data
 fputs($fp, serialize($var));
// release the file lock
 flock($fp, 3); // LOCK_UN
 fclose($fp);
 $success = true;
}
return $success;
}
////
//! Read in seralized data.
// read_cache reads the serialized data in $filename and
// fills $var using unserialize().
// $var	 - The variable to be filled.
// $filename - The name of the file to read.
function read_cache(&$var, $filename, $auto_expire = false){

$filename = DIR_FS_CACHE_DIR . $filename;
$success = false;
if (($auto_expire == true) && file_exists($filename)) {
 $now = time();
 $filetime = filemtime($filename);
 $difference = $now - $filetime;
 if ($difference >= $auto_expire) {
 return false;
 }
}
// try to open file
if ($fp = @fopen($filename, 'r')) {
// read in serialized data
 $szdata = fread($fp, filesize($filename));
 fclose($fp);
// unserialze the data
 $var = unserialize($szdata);
 $success = true;
}
return $success;
}
////
//! Get data from the cache or the database.
// get_db_cache checks the cache for cached SQL data in $filename
// or retreives it from the database is the cache is not present.
// $SQL	 - The SQL query to exectue if needed.
// $filename - The name of the cache file.
// $var	 - The variable to be filled.
// $refresh - Optional. If true, do not read from the cache.
function get_db_cache($sql, &$var, $filename, $refresh = false){
$var = array();
// check for the refresh flag and try to the data
if (($refresh == true)|| !read_cache($var, $filename)) {
// Didn' get cache so go to the database.
//	 $conn = mysql_connect("localhost", "apachecon", "apachecon");
 $res = tep_db_query($sql);
//	 if ($err = mysql_error()) trigger_error($err, E_USER_ERROR);
// loop through the results and add them to an array
 while ($rec = tep_db_fetch_array($res)) {
 $var[] = $rec;
 }
// write the data to the file
 write_cache($var, $filename);
}
}
////
//! Cache the categories box
// Cache the categories box
function tep_cache_categories_box($auto_expire = false, $refresh = false) {
global $cPath, $language;
$cache_output = '';
if (($refresh == true) || !read_cache($cache_output, 'categories_box-' . $language . '.cache' . $cPath, $auto_expire)) {
 if (!class_exists('bm_categories')) {
 include(DIR_WS_MODULES . 'boxes/bm_categories.php');
 }
 $bm_categories = new bm_categories();
 $cache_output = $bm_categories->getData();
 write_cache($cache_output, 'categories_box-' . $language . '.cache' . $cPath);
}
return $cache_output;
}
////
//! Cache the manufacturers box
// Cache the manufacturers box
function tep_cache_manufacturers_box($auto_expire = false, $refresh = false) {
global $HTTP_GET_VARS, $language;
$cache_output = '';
$manufacturers_id = '';
if (isset($HTTP_GET_VARS['manufacturers_id']) && is_numeric($HTTP_GET_VARS['manufacturers_id'])) {
 $manufacturers_id = $HTTP_GET_VARS['manufacturers_id'];
}
if (($refresh == true) || !read_cache($cache_output, 'manufacturers_box-' . $language . '.cache' . $manufacturers_id, $auto_expire)) {
 if (!class_exists('bm_manufacturers')) {
 include(DIR_WS_MODULES . 'boxes/bm_manufacturers.php');
 }
 $bm_manufacturers = new bm_manufacturers();
 $cache_output = $bm_manufacturers->getData();
 write_cache($cache_output, 'manufacturers_box-' . $language . '.cache' . $manufacturers_id);
}
return $cache_output;
}
////
//! Cache the also purchased module
// Cache the also purchased module
function tep_cache_also_purchased($auto_expire = false, $refresh = false) {
global $HTTP_GET_VARS, $language, $languages_id;
$cache_output = '';
if (isset($HTTP_GET_VARS['products_id']) && is_numeric($HTTP_GET_VARS['products_id'])) {
 if (($refresh == true) || !read_cache($cache_output, 'also_purchased-' . $language . '.cache' . $HTTP_GET_VARS['products_id'], $auto_expire)) {
 ob_start();
 include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
 $cache_output = ob_get_contents();
 ob_end_clean();
 write_cache($cache_output, 'also_purchased-' . $language . '.cache' . $HTTP_GET_VARS['products_id'], 86400);
 }
}
return $cache_output;
}
?>

 

Replace ./includes/functions/cache.php with this:

<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2006 osCommerce
Released under the GNU General Public License
*/
////
//! Write out serialized data.
// write_cache uses serialize() to store $var in $filename.
// $var	 - The variable to be written out.
// $filename - The name of the file to write to.
function write_cache(&$var, $filename, $auto_expire = false) {

$filename = DIR_FS_CACHE_DIR . $filename;
$success = false;
// try to open the file
if ($fp = @fopen($filename, 'w')) {
// obtain a file lock to stop corruptions occuring
 flock($fp, 2); // LOCK_EX
// write serialized data
 fputs($fp, serialize($var));
// release the file lock
 flock($fp, 3); // LOCK_UN
 fclose($fp);
 $success = true;
}
return $success;
}
////
//! Read in seralized data.
// read_cache reads the serialized data in $filename and
// fills $var using unserialize().
// $var	 - The variable to be filled.
// $filename - The name of the file to read.
function read_cache(&$var, $filename, $auto_expire = false){

$filename = DIR_FS_CACHE_DIR . $filename;
$success = false;
if (($auto_expire == true) && file_exists($filename)) {
 $now = time();
 $filetime = filemtime($filename);
 $difference = $now - $filetime;
 if ($difference >= $auto_expire) {
 return false;
 }
}
// try to open file
if ($fp = @fopen($filename, 'r')) {
// read in serialized data
 $szdata = fread($fp, filesize($filename));
 fclose($fp);
// unserialze the data
 $var = unserialize($szdata);
 $success = true;
}
return $success;
}
////
//! Get data from the cache or the database.
// get_db_cache checks the cache for cached SQL data in $filename
// or retreives it from the database is the cache is not present.
// $SQL	 - The SQL query to exectue if needed.
// $filename - The name of the cache file.
// $var	 - The variable to be filled.
// $refresh - Optional. If true, do not read from the cache.
function get_db_cache($sql, &$var, $filename, $refresh = false){
$var = array();
// check for the refresh flag and try to the data
if (($refresh == true)|| !read_cache($var, $filename)) {
// Didn' get cache so go to the database.
//	 $conn = mysql_connect("localhost", "apachecon", "apachecon");
 $res = tep_db_query($sql);
//	 if ($err = mysql_error()) trigger_error($err, E_USER_ERROR);
// loop through the results and add them to an array
 while ($rec = tep_db_fetch_array($res)) {
 $var[] = $rec;
 }
// write the data to the file
 write_cache($var, $filename);
}
}
////
//! Cache the categories box
// Cache the categories box
function tep_cache_categories_box($auto_expire = false, $refresh = false) {
global $cPath, $language;
$cache_output = '';
if (($refresh == true) || !read_cache($cache_output, 'categories_box-' . $language . '.cache' . $cPath, $auto_expire)) {
 if (!class_exists('bm_categories')) {
 include(DIR_WS_MODULES . 'boxes/bm_categories.php');
 }
 $bm_categories = new bm_categories();
 $cache_output = $bm_categories->getData();
// Advanced Caching System
 write_cache($cache_output, 'categories_box-' . $language . '.cache' . $cPath);
}
return $cache_output;
}
////
//! Cache the reviews box
// Cache the reviews box
function tep_cache_reviews_box($auto_expire = false, $refresh = false) {
global $cPath, $language;
$cache_output = '';
if (($refresh == true) || !read_cache($cache_output, 'reviews_box-' . $language . '.cache' . $cPath, $auto_expire)) {
if (!class_exists('bm_reviews')) {
include(DIR_WS_MODULES . 'boxes/bm_reviews.php');
}
$bm_reviews = new bm_reviews();
$cache_output = $bm_reviews->getData();
// Advanced Caching System
write_cache($cache_output, 'reviews_box-' . $language . '.cache' . $cPath);
}
return $cache_output;
}

////
//! Cache the what's new box
// Cache the what's new box
function tep_cache_whats_new_box($auto_expire = false) {
global $language, $currency;
$cache_output = '';
if (!read_cache($cache_output, 'bm_whats_new-' . $language . '-' . $currency . '.cache', $auto_expire)) {
if (!class_exists('bm_whats_new')) {
include(DIR_WS_MODULES . 'boxes/bm_whats_new.php');
}
$bm_whats_new = new bm_whats_new();
$cache_output = $bm_whats_new->getData();
// Advanced Caching System
write_cache($cache_output, 'bm_whats_new-' . $language . '-' . $currency . '.cache', $auto_expire);
}
return $cache_output;
}

////
//! Cache the best sellers box
// Cache the best sellers box
function tep_cache_best_sellers_box($auto_expire = false) {
global $current_category_id, $language, $languages_id;
$cache_output = '';
if (!read_cache($cache_output, 'bm_best_sellers_box-' . $current_category_id . '-' . $languages_id . '.cache', $auto_expire)) {
if (!class_exists('bm_best_sellers')) {
require_once(DIR_WS_LANGUAGES . $language . '/modules/boxes/bm_best_sellers.php');
include(DIR_WS_MODULES . 'boxes/bm_best_sellers.php');
}
$bm_best_sellers = new bm_best_sellers();
$cache_output = $bm_best_sellers->getData();
write_cache($cache_output, 'bm_best_sellers_box-' . $current_category_id . '-' . $languages_id . '.cache', $auto_expire);
}
return $cache_output;
}

////
//! Cache or Display the best sellers module
// Cache or Display the best sellers module
/* function tep_cache_best_sellers_box($auto_expire = false, $refresh = false) {
global $cPath, $language;
if ((USE_CACHE == 'true') && empty($SID)) {
$cache_output = '';
if (($refresh == true) || !read_cache($cache_output, 'bm_best_sellers_box-' . $current_category_id . '-' . $languages_id . '.cache', $auto_expire)) {
 if (!class_exists('bm_languages')) {
 include_once(DIR_WS_LANGUAGES . $language . '/modules/boxes/bm_best_sellers.php');
 include_once(DIR_WS_MODULES . 'boxes/bm_best_sellers.php');
 }
 $bm_best_sellers = new bm_best_sellers();
 $cache_output = $bm_best_sellers->execute(true);
 write_cache($cache_output, 'bm_best_sellers_box-' . $current_category_id . '-' . $languages_id . '.cache', $auto_expire);
}
} else {
if (!class_exists('bm_languages')) {
 include_once(DIR_WS_LANGUAGES . $language . '/modules/boxes/bm_best_sellers.php');
 include(DIR_WS_MODULES . 'boxes/bm_best_sellers.php');
}
$bm_best_sellers = new bm_best_sellers();
$cache_output = $bm_best_sellers->execute(true);
}
return $cache_output;
}*/
////
//! Cache the manufacturers box
// Cache the manufacturers box
function tep_cache_manufacturers_box($auto_expire = false, $refresh = false) {
global $HTTP_GET_VARS, $language;
$cache_output = '';
$manufacturers_id = '';
if (isset($HTTP_GET_VARS['manufacturers_id']) && is_numeric($HTTP_GET_VARS['manufacturers_id'])) {
 $manufacturers_id = $HTTP_GET_VARS['manufacturers_id'];
}
if (($refresh == true) || !read_cache($cache_output, 'manufacturers_box-' . $language . '.cache' . $manufacturers_id, $auto_expire)) {
 if (!class_exists('bm_manufacturers')) {
 include(DIR_WS_MODULES . 'boxes/bm_manufacturers.php');
 }
 $bm_manufacturers = new bm_manufacturers();
 $cache_output = $bm_manufacturers->getData();
 write_cache($cache_output, 'manufacturers_box-' . $language . '.cache' . $manufacturers_id);
}
return $cache_output;
}
////
//! Cache the also purchased module
// Cache the also purchased module
function tep_cache_also_purchased($auto_expire = false, $refresh = false) {
global $HTTP_GET_VARS, $language, $languages_id;
$cache_output = '';
if (isset($HTTP_GET_VARS['products_id']) && is_numeric($HTTP_GET_VARS['products_id'])) {
 if (($refresh == true) || !read_cache($cache_output, 'also_purchased-' . $language . '.cache' . $HTTP_GET_VARS['products_id'], $auto_expire)) {
 ob_start();
 include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
 $cache_output = ob_get_contents();
 ob_end_clean();
 write_cache($cache_output, 'also_purchased-' . $language . '.cache' . $HTTP_GET_VARS['products_id'], 86400);
 }
}
return $cache_output;
}
?>

 

Replace ./admin/includes/functions/configuration_cache_write.php with this:

<?php
/*
$Id: configuration_cache_write.php, v1.0 2013/06/26 $
$Id: configuration_cache_write.php, v1.1 - Ajax Engine 2013/10/02 $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
function write_configuration_apc_cache() {
$configuration_cache = array();
$configuration_cache_arrays = array();
$prodName = array();
$configuration_query = tep_db_query('select configuration_key, configuration_value from ' . TABLE_CONFIGURATION);
while ($configuration = tep_db_fetch_array($configuration_query)) {
$configuration_cache[$configuration['configuration_key']] = addslashes($configuration['configuration_value']);
}
function count_products_in_category($category_id, $include_inactive = false) {
$products_count = 0;
if ($include_inactive == true) {
$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int) $category_id . "'");
} else {
$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int) $category_id . "'");
}
$products = tep_db_fetch_array($products_query);
$products_count += $products['total'];
$child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int) $category_id . "'");
if (tep_db_num_rows($child_categories_query)) {
while ($child_categories = tep_db_fetch_array($child_categories_query)) {
$products_count += count_products_in_category($child_categories['categories_id'], $include_inactive);
}
}
return $products_count;
}
function count_has_category_subcategories($category_id) {
$child_category_query = tep_db_query("select count(*) as count from " . TABLE_CATEGORIES . " where parent_id = '" . (int) $category_id . "'");
$child_category	 = tep_db_fetch_array($child_category_query);
return $child_category['count'];
}
$rQuery = tep_db_query('SELECT `categories_id` FROM `categories`');
$aResult = array();
while ($r = tep_db_fetch_array($rQuery)) {
$aResult[] = $r['categories_id'];
}
foreach ($aResult as &$value) {
$configuration_cache['CATCOUNT_' . $value] = addslashes(count_products_in_category($value));
$configuration_cache['SUBCATCOUNT_' . $value] = addslashes(count_has_category_subcategories($value));
}

$cPathQuery = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " ORDER BY products_id");
$cPathResult = array();
while ($cPath = tep_db_fetch_array($cPathQuery)) {
$cPathResult[$cPath['products_id']] = $cPath['categories_id'];
}

foreach ($cPathResult as $key => $value) {
$configuration_cache['PRODPATH_' . $key] = $value;
}
$configuration_cache_arrays['PRODPATH'] = $cPathResult;


$modelQuery = tep_db_query("SELECT products_id, products_model FROM " . TABLE_PRODUCTS . " ORDER BY products_id");
$modelResult = array();
while ($model = tep_db_fetch_array($modelQuery)) {
$modelResult[$model['products_id']] = $model['products_model'];
}

$configuration_cache_arrays['PRODMODEL'] = $modelResult;

require_once(DIR_WS_CLASSES . 'message_stack.php');
$messageStack = new messageStack;

$cPath_arrayQuery = tep_db_query("SELECT * FROM " . TABLE_CATEGORIES_DESCRIPTION . " ORDER BY categories_id");
while ($cPath_array = tep_db_fetch_array($cPath_arrayQuery)) {
$configuration_cache["CATEGORIES_NAME_" . $cPath_array['categories_id'] . '_' . $cPath_array['language_id']] = $cPath_array['categories_name'];
}
$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " ORDER BY manufacturers_id");
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$configuration_cache["MANUFACTURERS_NAME_" . $manufacturers['manufacturers_id']] = $manufacturers['manufacturers_name'];
}
$products_query = tep_db_query("SELECT * from " . TABLE_PRODUCTS_DESCRIPTION . ' ORDER BY products_id ASC');
while ($products = tep_db_fetch_array($products_query)) {
$prodName[$products['products_id']][$products['language_id']] = array('products_name' => $products['products_name']);
}
$configuration_cache_arrays['PRODNAME'] = $prodName;
// Check if PHP_APC is enabled and if so - Use It
/* if (function_exists('apc_cache_info') && ini_get('apc.enabled') == '1') {
if(!apc_store('configuration_cache_arrays.cache', $configuration_cache_arrays, 0)) {
$messageStack->add_session(ERROR_CONFIG_CACHE_WRITE . ' (Array)');
} else {
$messageStack->add_session(SUCCESS_CONFIG_CACHE_WRITE . ' (Array)', 'success');
}
return apc_store('configuration_cache.cache', $configuration_cache, 0);
} else {*/
if(!write_cache($configuration_cache_arrays, 'configuration_cache_arrays.cache', 0)) {
$messageStack->add_session(ERROR_CONFIG_CACHE_WRITE . ' (Array)');
} else {
$messageStack->add_session(SUCCESS_CONFIG_CACHE_WRITE . ' (Array)', 'success');
}
return write_cache($configuration_cache, 'configuration_cache.cache', 0);
// }
}
?>

 

This should do it, apc functions removed/commented. After this go to Admin => Tools => Cache Control and press "Remove all cache?" once to cache the configuration definitions.

Edited by Dr. Rolex
Link to comment
Share on other sites

Thanks Dr Rolex I will try all the edits, Apc and fastcgi do not work well with windows server 2008 and php 5.3.24. I have compiled all the dlls I could find and all of them crash Fastcgi. Will do your edits and see how it works with file caching. I will post back with any problems I find. Thanks again for your time.

Link to comment
Share on other sites

Error: Attempt to write configuration cache file failed! (Array)

Error: Attempt to write configuration cache file failed!

Is still present after the file edits. I am not sure anything is working.

Where does the script store the files? Oscommerce cache may be the only thing caching. Thanks

Http://sansabalongdrive.mobi

Edited by badbo
Link to comment
Share on other sites

Thanks Dr Rolex I will try all the edits, Apc and fastcgi do not work well with windows server 2008 and php 5.3.24. I have compiled all the dlls I could find and all of them crash Fastcgi. Will do your edits and see how it works with file caching. I will post back with any problems I find. Thanks again for your time.

 

Have you tried setting apc.write_lock = 0?

 

I don't think apc will work for you with FastCGI, even though, I'm far from an expert on this. Is FastCGI the only module available to run PHP on Windows?

 

But in all honesty, as long as you have an opcode caching system running you don't really need the additional file/user caching. It might even slow down your server.

The main benefit from this Add-On comes from using Ajax to request only the vital information on each request instead of loading every script etc. on each request.

 

I read that some have had better luck using another opcode caching system on Windows called eAccelerator. Perhaps you should take a look on that instead?

 

Error: Attempt to write configuration cache file failed! (Array)

Error: Attempt to write configuration cache file failed!

Is still present after the file edits. I am not sure anything is working.

Where does the script store the files? Oscommerce cache may be the only thing caching. Thanks

 

You set the file caching directory in ./includes/filenames.php - AND - ./admin/includes/filenames.php

// define cache directory
 define('DIR_FS_CACHE_DIR', 'includes/work/');

// define cache directory
 define('DIR_FS_CACHE_DIR', '../includes/work/');

 

Make sure they point to the same directory as the one you have set in Admin => Configuration => Cache => Cache Directory and you also need to make sure that the webserver has writing privileges on that directory.

 

Best practice is probably to set it outside the web directory root, e.g. C:\tmp\osc_File_caching\ (or similar) and use a .htaccess to secure it further.

That's one of the good thing using apc though, that since you don't need file caching at all you don't have to give the web server writing privileges to any directory or file. Good for security.

 

Your error log should have a message about not being to write to the directory if that's the problem.

Link to comment
Share on other sites

  • 3 months later...

Thank you Dr. Rolex.

This is a very useful addon.

How can I change or remove the loading image (that appears when the page content is loading)?

Cheers

Edited by bito
Link to comment
Share on other sites

  • 2 months later...
  • 8 months later...

Hi

 

I want to change product model to product name in the breadcrumb.

 

I can see PRODNAME and all the product names written in the cache file $configuration_cache_arrays. Unfortunately i cannot output the name in the trail. I have

// add the products name to the breadcrumb trail
	if ((USE_CACHE == 'true') && empty($SID)) {
		$model_array = $configuration_cache_arrays['PRODNAME'];
		if (array_key_exists((int)$HTTP_GET_VARS['products_id'], $model_array)) {
			$model = $model_array[(int)$HTTP_GET_VARS['products_id']];
			$breadcrumb->add($model, tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
		}

	} else {

		if (isset($HTTP_GET_VARS['products_id'])) {
			$model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
			if (tep_db_num_rows($model_query)) {
				$model = tep_db_fetch_array($model_query);
				$breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
			}
		}
	}
Link to comment
Share on other sites

Figured it out from the functions in general.php

// add the products name to the breadcrumb trail
  if ((USE_CACHE == 'true') && empty($SID)) {
      $breadcrumb->add(tep_get_products_name((int)$_GET['products_id']), tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $_GET['products_id']));
  } else {
    if (isset($_GET['products_id'])) {
      $name_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$_GET['products_id'] . "'");
      if (tep_db_num_rows($name_query)) {
        $name = tep_db_fetch_array($name_query);
        $breadcrumb->add($name['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $_GET['products_id']));
      }
    }
  }
Link to comment
Share on other sites


if ((USE_CACHE == 'true') && empty($SID)) {

if (isset($_GET['products_id'])) {

$breadcrumb->add(tep_get_products_name((int)$_GET['products_id']), tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $_GET['products_id']));

}

} else {

if (isset($_GET['products_id'])) {

$name_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$_GET['products_id'] . "'");

if (tep_db_num_rows($name_query)) {

$name = tep_db_fetch_array($name_query);

$breadcrumb->add($name['products_name'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $_GET['products_id']));

}

}

}

Link to comment
Share on other sites

  • 8 months later...

Join the conversation

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

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

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...