1 | <?php |
---|
2 | |
---|
3 | if(!function_exists("xpress_cache_found")): |
---|
4 | function xpress_cache_found($filename) |
---|
5 | { |
---|
6 | $cache_time = 0; |
---|
7 | // if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) { |
---|
8 | if (file_exists($filename)) { |
---|
9 | return true; |
---|
10 | } else { |
---|
11 | return false; |
---|
12 | } |
---|
13 | } |
---|
14 | endif; |
---|
15 | |
---|
16 | if(!function_exists("xpress_cache_read")): |
---|
17 | function xpress_cache_read($mydirname,$collation_key) |
---|
18 | { |
---|
19 | global $xoops_config; |
---|
20 | |
---|
21 | $cache_dir = $xoops_config->xoops_cache_path . '/'; |
---|
22 | $filename = $cache_dir .$mydirname . '_' . $collation_key; |
---|
23 | if (xpress_cache_found($filename)) { |
---|
24 | return file_get_contents($filename); |
---|
25 | } else { |
---|
26 | return ''; |
---|
27 | } |
---|
28 | } |
---|
29 | endif; |
---|
30 | |
---|
31 | if(!function_exists("xpress_cache_write")): |
---|
32 | function xpress_cache_write($mydirname,$collation_key,$content) |
---|
33 | { |
---|
34 | global $xoops_config; |
---|
35 | $cache_dir = $xoops_config->xoops_cache_path . '/'; |
---|
36 | $cache_time = 0; |
---|
37 | |
---|
38 | $filename = $cache_dir .$mydirname . '_' . $collation_key; |
---|
39 | // if ((time() - @filemtime($filename)) > $cache_time) { |
---|
40 | $fp = fopen($filename, "w"); |
---|
41 | flock($fp, 2); |
---|
42 | fputs($fp, $content); |
---|
43 | fclose($fp); |
---|
44 | // } |
---|
45 | } |
---|
46 | endif; |
---|
47 | |
---|
48 | if(!function_exists("xpress_block_cache_clear")): |
---|
49 | function xpress_cache_clear($mydirname) |
---|
50 | { |
---|
51 | global $xoops_config; |
---|
52 | $cache_dir = $xoops_config->xoops_cache_path . '/'; |
---|
53 | $cache_time = 0; |
---|
54 | if ($dh = opendir($cache_dir)) { |
---|
55 | while (($file = readdir($dh)) !== false) { |
---|
56 | if (preg_match('/^' . preg_quote($mydirname) . '/', $file)) { |
---|
57 | unlink($cache_dir.$file); |
---|
58 | } |
---|
59 | } |
---|
60 | closedir($dh); |
---|
61 | } |
---|
62 | } |
---|
63 | endif; |
---|
64 | |
---|
65 | ?> |
---|