cache.php
2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: cache.php 1059 2011-03-01 07:25:09Z monkey $
*/
!defined('IN_UC') && exit('Access Denied');
if(!function_exists('file_put_contents')) {
function file_put_contents($filename, $s) {
$fp = @fopen($filename, 'w');
@fwrite($fp, $s);
@fclose($fp);
}
}
class cachemodel {
var $db;
var $base;
var $map;
function __construct(&$base) {
$this->cachemodel($base);
}
function cachemodel(&$base) {
$this->base = $base;
$this->db = $base->db;
$this->map = array(
'settings' => array('settings'),
'badwords' => array('badwords'),
'plugins' => array('plugins'),
'apps' => array('apps'),
);
}
function updatedata($cachefile = '') {
if($cachefile) {
foreach((array)$this->map[$cachefile] as $modules) {
$s = "<?php\r\n";
foreach((array)$modules as $m) {
$method = "_get_$m";
$s .= '$_CACHE[\''.$m.'\'] = '.var_export($this->$method(), TRUE).";\r\n";
}
$s .= "\r\n?>";
@file_put_contents(UC_DATADIR."./cache/$cachefile.php", $s);
}
} else {
foreach((array)$this->map as $file => $modules) {
$s = "<?php\r\n";
foreach($modules as $m) {
$method = "_get_$m";
$s .= '$_CACHE[\''.$m.'\'] = '.var_export($this->$method(), TRUE).";\r\n";
}
$s .= "\r\n?>";
@file_put_contents(UC_DATADIR."./cache/$file.php", $s);
}
}
}
function updatetpl() {
$tpl = dir(UC_DATADIR.'view');
while($entry = $tpl->read()) {
if(preg_match("/\.php$/", $entry)) {
@unlink(UC_DATADIR.'view/'.$entry);
}
}
$tpl->close();
}
function _get_badwords() {
$data = $this->db->fetch_all("SELECT * FROM ".UC_DBTABLEPRE."badwords");
$return = array();
if(is_array($data)) {
foreach($data as $k => $v) {
$return['findpattern'][$k] = $v['findpattern'];
$return['replace'][$k] = $v['replacement'];
}
}
return $return;
}
function _get_apps() {
$this->base->load('app');
$apps = $_ENV['app']->get_apps();
$apps2 = array();
if(is_array($apps)) {
foreach($apps as $v) {
$apps2[$v['appid']] = $v;
}
}
return $apps2;
}
function _get_settings() {
return $this->base->get_setting();
}
function _get_plugins() {
$this->base->load('plugin');
return $_ENV['plugin']->get_plugins();
}
}
?>