Hi,
i worked with lots of shop-systems, but i think your one is really easy to used and also good designed!! Great job, but i have a problem with the "Invalid argument" - Request.
I get this messages on the Front and at the Backend at every Action:
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/user/main/shop/system/library/cache.php:18) in /www/htdocs/user/main/shop/system/library/response.php on line 65
My server use PHP 5.2.6 ....
So, what´s wrong? I set the required folders and cache.php to 777, otherwise it will be crashed, but nothing changed! ;(
Can anyone help me?
i worked with lots of shop-systems, but i think your one is really easy to used and also good designed!! Great job, but i have a problem with the "Invalid argument" - Request.
I get this messages on the Front and at the Backend at every Action:
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/user/main/shop/system/library/cache.php:18) in /www/htdocs/user/main/shop/system/library/response.php on line 65
My server use PHP 5.2.6 ....
So, what´s wrong? I set the required folders and cache.php to 777, otherwise it will be crashed, but nothing changed! ;(
Can anyone help me?
php_value display_errors 0 is a quick fix but turns off error reporing.
the problem is php's glob function. it won't read files with in the cache directory.
I'm going to fix this properly using fopen.
the problem is php's glob function. it won't read files with in the cache directory.
I'm going to fix this properly using fopen.
OpenCart®
Project Owner & Developer.
Replace your cache file with this:
The problem is that the glob function returns false and not array when nothing is found. Also I would check that you have set the right permission on the cache directory.
Code: Select all
<?php
final class Cache {
private $expire = 3600;
public function __construct() {
$files = glob(DIR_CACHE . 'cache.*');
if ($files) {
foreach ($files as $file) {
$time = end(explode('.', basename($file)));
if ($time < time()) {
unlink($file);
}
}
}
}
public function get($key) {
$files = glob(DIR_CACHE . 'cache.' . $key . '.*');
if ($files) {
foreach ($files as $file) {
$handle = fopen($file, 'r');
$cache = fread($handle, filesize($file));
fclose($handle);
return unserialize($cache);
}
}
}
public function set($key, $value) {
$this->delete($key);
$file = DIR_CACHE . 'cache.' . $key . '.' . (time() + $this->expire);
$handle = fopen($file, 'w');
fwrite($handle, serialize($value));
fclose($handle);
}
public function delete($key) {
$files = glob(DIR_CACHE . 'cache.' . $key . '.*');
if ($files) {
foreach ($files as $file) {
unlink($file);
}
}
}
}
?>
The problem is that the glob function returns false and not array when nothing is found. Also I would check that you have set the right permission on the cache directory.
Last edited by Daniel on Sat Feb 14, 2009 1:37 am, edited 1 time in total.
OpenCart®
Project Owner & Developer.
Who is online
Users browsing this forum: No registered users and 15 guests