<?php
////////////////////////////////////////////
// Opencart.com
// Farhad Sakhaei ~ parsmizban.com
// Mohammad Reza Mahmoudi ~ iropencart.com
///////////////////////////////////////////
function MRMs_glob($dir){
$files = array();
if(is_dir($dir)){
if($dh=opendir($dir)){
while(($file = readdir($dh)) !== false){
$files[]=$dir.$file;
}}
}
return $files;
}
/////////////////////////////////////////
final class Cache {
private $expire = 3600;
public function __construct() {
$files = MRMs_glob(DIR_CACHE . ‘cache.*’);
if ($files) {
foreach ($files as $file) {
$time = substr(strrchr($file, ‘.’), 1);
if ($time < time()) {
if (file_exists($file)) {
@unlink($file);
}
}
}
}
}
public function get($key) {
$files = MRMs_glob(DIR_CACHE . ‘cache.’ . $key . ‘.*’);
if ($files) {
foreach ($files as $file) {
$cache = ”;
$handle = fopen($file, ‘r’);
if ($handle) {
$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 = MRMs_glob(DIR_CACHE . ‘cache.’ . $key . ‘.*’);
if ($files) {
foreach ($files as $file) {
if (file_exists($file)) {
@unlink($file);
clearstatcache();
}
}
}
}
}
?>
Opencart glob hatası
Bir Cevap Yazın
Trackbacks:0
- Listed below are links to weblogs that reference
- Opencart glob hatası from Grafikey