- }
-
- $this->cache[$group][$id] = unserialize(base64_decode(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))));
- if (false === $this->cache[$group][$id])
- $this->cache[$group][$id] = '';
-
- $this->cold_cache_hits += 1;
- return $this->cache[$group][$id];
- }
-
- function get_group_dir($group) {
- if (false !== array_search($group, $this->global_groups))
- return $group;
-
- return "{$this->blog_id}/$group";
- }
-
- function hash($data) {
- if ( function_exists('hash_hmac') ) {
- return hash_hmac('md5', $data, $this->secret);
- } else {
- return md5($data . $this->secret);
- }
- }
-
- function load_group_from_db($group) {
- return;
- }
-
- function make_group_dir($group, $perms) {
- $group_dir = $this->get_group_dir($group);
- $make_dir = '';
- foreach (split('/', $group_dir) as $subdir) {
- $make_dir .= "$subdir/";
- if (!file_exists($this->cache_dir.$make_dir)) {
- if (! @ mkdir($this->cache_dir.$make_dir))
- break;
- @ chmod($this->cache_dir.$make_dir, $perms);
- }
-
- if (!file_exists($this->cache_dir.$make_dir."index.php")) {
- $file_perms = $perms & 0000666;
- @ touch($this->cache_dir.$make_dir."index.php");
- @ chmod($this->cache_dir.$make_dir."index.php", $file_perms);
- }
- }
-
- return $this->cache_dir."$group_dir/";
- }
-
- function rm_cache_dir() {
- $dir = $this->cache_dir;
- $dir = rtrim($dir, DIRECTORY_SEPARATOR);
- $top_dir = $dir;
- $stack = array($dir);
- $index = 0;
-
- while ($index < count($stack)) {
- # Get indexed directory from stack
- $dir = $stack[$index];
-
- $dh = @ opendir($dir);
- if (!$dh)
- return false;
-
- while (($file = @ readdir($dh)) !== false) {
- if ($file == '.' or $file == '..')
- continue;
-
- if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
- $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
- else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file))
- @ unlink($dir . DIRECTORY_SEPARATOR . $file);
- }
-
- $index++;
- }
-
- $stack = array_reverse($stack); // Last added dirs are deepest
- foreach($stack as $dir) {
- if ( $dir != $top_dir)
- @ rmdir($dir);
- }