$value) { if(is_array($value)) { $arr2 = self::_writeArray($value); $out.= '"'.$key.'" => array('.$arr2.'), '; } else { $out.= '"'.$key.'" => "'.str_replace('"', '\"', $value).'", '; } $out.= "\n"; } return $out; } private static function _loadCache($id) { $path = self::_getPath($id); if(!file_exists($path)) return false; if(require_once($path)) { self::$loaded_caches[$id] = true; return true; } return false; } private static function _getPath($id) { return LENCRIER_ROOT . '/cache/cache_'.$id.'.php'; } public static function put($id, $content) { $path = self::_getPath($id); $old_content = self::get($id); if(!empty($old_content) && is_array($old_content)) { foreach($old_content as $key=>$value) { if(empty($content[$key])) $content[$key] = $value; } } $out = ''; $fp = @fopen($path, 'w'); if(!$fp) return false; fputs($fp, $out); fclose($fp); $GLOBALS['static_cache'][$id] = $content; self::$loaded_caches[$id] = true; return true; } public static function get($id, $key=false) { if(empty(self::$loaded_caches[$id])) { if(!self::_loadCache($id)) return false; } if(empty(self::$loaded_caches[$id])) return false; if(empty($key)) return $GLOBALS['static_cache'][$id]; else return $GLOBALS['static_cache'][$id][$key]; } public static function erease($id) { $path = self::_getPath($id); if(!file_exists($path)) return true; if(@unlink($path)) return true; return false; } } ?>