XPressME Integration Kit

Trac

source: trunk/include/xpress_cache.php @ 96

Last change on this file since 96 was 96, checked in by toemon, 15 years ago

途中経過でインストール、アップデートできなくなってしまっていたバグ修正
イベント通知の部分をFix、(ゲストのモジュールアクセス権限がないと通知できないのは直らない)
ブロックのキャッシュを見直し、キャッシュがない場合と、ブロックオプションが変更された場合にリフレッシュする機能を追加
ブロックキャッシュの更新にてポスト削除時のイベントをDB削除前にとっていたバグを修正。

File size: 1.8 KB
Line 
1<?php
2       
3if(!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    }
14endif;
15
16if(!function_exists("xpress_cache_read")):
17    function xpress_cache_read($mydirname,$collation_key)
18    {
19        global $xoops_config;
20        if(defined('XOOPS_ROOT_PATH')){
21                $cache_dir = XOOPS_ROOT_PATH . '/cache/';
22        } else {
23                $cache_dir = $xoops_config->xoops_root_path . '/cache/';
24        }
25        $filename = $cache_dir .$mydirname . '_' . $collation_key;
26        if (xpress_cache_found($filename)) {
27            return file_get_contents($filename);
28       } else {
29                        return '';
30                }
31    }
32endif;
33
34if(!function_exists("xpress_cache_write")):
35    function xpress_cache_write($mydirname,$collation_key,$content)
36    {
37                global $xoops_config;
38                $cache_dir = $xoops_config->xoops_root_path . '/cache/';
39                $cache_time = 0;
40
41        $filename = $cache_dir .$mydirname . '_' . $collation_key;
42//        if ((time() - @filemtime($filename)) > $cache_time) {
43            $fp = fopen($filename, "w");
44            flock($fp, 2);
45            fputs($fp, $content);
46            fclose($fp);
47 //       }
48    }
49endif;
50
51if(!function_exists("xpress_block_cache_clear")):
52    function xpress_cache_clear($mydirname)
53    {
54                global $xoops_config;
55                $cache_dir = $xoops_config->xoops_root_path . '/cache/';
56                $cache_time = 0;
57        if ($dh = opendir($cache_dir)) {
58            while (($file = readdir($dh)) !== false) {
59                if (preg_match('/^' . preg_quote($mydirname) . '/', $file)) {
60                    unlink($cache_dir.$file);
61                }
62            }
63            closedir($dh);
64        }
65    }
66endif;
67
68?>
Note: See TracBrowser for help on using the repository browser.