optimizer_setting.php
4.86 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: optimizer_setting.php 33488 2013-06-24 01:48:20Z jeffjzhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class optimizer_setting {
private $setting;
public function __construct() {
include_once DISCUZ_ROOT.'./source/language/lang_optimizer.php';
$this->setting = array(
'cacheindexlife' => array(
'initvalue' => '0',
'optimizedvalue' => '900',
'title' => $lang['optimizer_setting_cache_index'],
'description' => $lang['optimizer_setting_cache_index_desc'],
'optimizerdesc' => $lang['optimizer_setting_cache_optimize_desc'],
),
'cachethreadlife' => array(
'initvalue' => '0',
'optimizedvalue' => '900',
'title' => $lang['optimizer_setting_cache_post'],
'description' => $lang['optimizer_setting_cache_post_desc'],
'optimizerdesc'=> $lang['optimizer_setting_cache_post_optimize_desc'],
),
'optimizeviews' => array(
'initvalue' => '0',
'optimizedvalue' => '1',
'title' => $lang['optimizer_setting_optimizeviews'],
'description' => $lang['optimizer_setting_optimizeviews_desc'],
'optimizerdesc' => $lang['optimizer_setting_optimizeviews_optimize_desc'],
),
'delayviewcount' => array(
'initvalue' => '0',
'optimizedvalue' => '1',
'title' => $lang['optimizer_setting_delayviewcount'],
'description' => $lang['optimizer_setting_delayviewcount_desc'],
'optimizerdesc' => $lang['optimizer_setting_delayviewcount_optimize_desc'],
),
'preventrefresh' => array(
'initvalue' => '0',
'optimizedvalue' => '1',
'title' => $lang['optimizer_setting_preventrefresh'],
'description' => $lang['optimizer_setting_preventrefresh_desc'],
'optimizerdesc' => $lang['optimizer_setting_preventrefresh_optimize_desc'],
),
'nocacheheaders' => array(
'initvalue' => '1',
'optimizedvalue' => '0',
'title' => $lang['optimizer_setting_nocacheheaders'],
'description' => $lang['optimizer_setting_nocacheheaders_desc'],
'optimizerdesc' => $lang['optimizer_setting_nocacheheaders_optimize_desc'],
),
'jspath' => array(
'initvalue' => 'static/js/',
'optimizedvalue' => 'data/cache/',
'title' => $lang['optimizer_setting_jspath'],
'description' => $lang['optimizer_setting_jspath_desc'],
'optimizerdesc' => $lang['optimizer_setting_jspath_optimize_desc'],
),
'lazyload' => array(
'initvalue' => '0',
'optimizedvalue' => '1',
'title' => $lang['optimizer_setting_lazyload'],
'description' => $lang['optimizer_setting_lazyload_desc'],
'optimizerdesc' => $lang['optimizer_setting_lazyload_optimize_desc'],
),
'sessionclose' => array(
'initvalue' => '0',
'optimizedvalue' => '1',
'title' => $lang['optimizer_setting_sessionclose'],
'description' => $lang['optimizer_setting_sessionclose_desc'],
'optimizerdesc' => $lang['optimizer_setting_sessionclose_optimize_desc'],
),
'rewriteguest' => array(
'initvalue' => 0,
'optimizedvalue' => '1',
'title' => $lang['optimizer_setting_rewriteguest'],
'description' => $lang['optimizer_setting_rewriteguest_desc'],
'optimizerdesc' => $lang['optimizer_setting_rewriteguest_optimize_desc'],
),
);
}
public function check() {
$count = 0;
$options = $this->get_option();
foreach($options as $option) {
if($option[4] == '1') {
$count++;
}
}
if($count) {
$return = array('status' => 1, 'type' => 'view', 'lang' => lang('optimizer', 'optimizer_setting_need_optimizer', array('count' => $count)));
} else {
$return = array('status' => 0, 'type' => 'view', 'lang' => lang('optimizer', 'optimizer_setting_no_need'));
}
return $return;
}
public function optimizer() {
$adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php';
dheader('Location: '.$_G['siteurl'].$adminfile.'?action=optimizer&operation=setting_optimizer&type=optimizer_setting&anchor=performance');
}
public function option_optimizer($options) {
$update = array();
foreach($options as $option) {
if(isset($this->setting[$option])) {
$update[$option] = $this->setting[$option]['optimizedvalue'];
}
}
if($update) {
C::t('common_setting')->update_batch($update);
updatecache('setting');
}
return true;
}
public function get_option() {
$return = array();
$settings = C::t('common_setting')->fetch_all(array_keys($this->setting));
foreach($this->setting as $k => $setting) {
if($settings[$k] == $setting['initvalue']) {
$return[] = array($k, $setting['title'], $setting['description'], $setting['optimizerdesc'], '1');
} else {
$return[] = array($k, $setting['title'], $setting['description'], $setting['optimizerdesc'], '0');
}
}
return $return;
}
}
?>