XPressME Integration Kit

Trac

source: trunk/include/xpress_cache.php @ 95

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

XOOPS mainfile.phpのdefine文を事前に読み取りwp-config.phpのDB接続関係を生成することにより、XOOPSシステムを必要なときだけ呼び出す仕組みを作る。
およびイベント通知関係の修正(まだゲストのアクセス権限がないと駄目)

File size: 1.5 KB
Line 
1<?php
2       
3if(!function_exists("xpress_cache_read")):
4    function xpress_cache_read($mydirname,$collation_key)
5    {
6        global $xoops_config;
7                $cache_dir = $xoops_config->xoops_root_path . '/cache/';
8                $cache_time = 0;
9        $filename = $cache_dir .$mydirname . '_' . $collation_key;
10//        if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) {
11        if (file_exists($filename)) {
12            return file_get_contents($filename);
13       } else {
14                        return '';
15                }
16    }
17endif;
18
19if(!function_exists("xpress_cache_write")):
20    function xpress_cache_write($mydirname,$collation_key,$content)
21    {
22                global $xoops_config;
23                $cache_dir = $xoops_config->xoops_root_path . '/cache/';
24                $cache_time = 0;
25
26        $filename = $cache_dir .$mydirname . '_' . $collation_key;
27//        if ((time() - @filemtime($filename)) > $cache_time) {
28            $fp = fopen($filename, "w");
29            flock($fp, 2);
30            fputs($fp, $content);
31            fclose($fp);
32 //       }
33    }
34endif;
35
36if(!function_exists("xpress_block_cache_clear")):
37    function xpress_cache_clear($mydirname)
38    {
39                global $xoops_config;
40                $cache_dir = $xoops_config->xoops_root_path . '/cache/';
41                $cache_time = 0;
42        if ($dh = opendir($cache_dir)) {
43            while (($file = readdir($dh)) !== false) {
44                if (preg_match('/^' . preg_quote($mydirname) . '/', $file)) {
45                    unlink($cache_dir.$file);
46                }
47            }
48            closedir($dh);
49        }
50    }
51endif;
52
53?>
Note: See TracBrowser for help on using the repository browser.