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