-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmlns.inc.php
More file actions
209 lines (180 loc) · 7.27 KB
/
Copy pathxmlns.inc.php
File metadata and controls
209 lines (180 loc) · 7.27 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php (!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) && die('Access Denied');
global $_G;
$identifier = "dps_header";
cpheader();
if(!submitcheck('settingsubmit') && !submitcheck('inserthook')) {
$_CA = C::t('common_setting')->fetch_all(null);
showformheader('plugins&operation=config&do='.$pluginid.'&identifier='.$identifier.'&pmod=xmlns');
showtableheader('');
$tableClasses = array('class="td25"', 'class="td28"', 'class="td25"', 'class="td31"', 'class="td29"');
showtablerow(
'', $tableClasses, array(
'',
cplang('display_order'),
cplang('available'),
cplang('前缀'),
cplang('引用'),
)
);
print "
<script type=\"text/JavaScript\">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type=\"text\" class=\"txt\" name=\"newdisplayorder[]\" size=\"3\">', 'td28'],
[1,'<input type=\"checkbox\" name=\"newavailable[]\" value=\"1\">', 'td25'],
[1,'xmlns:<input type=\"text\" class=\"txt\" name=\"newprefix[]\" size=\"10\">=', 'td31'],
[1,'\"<input type=\"text\" class=\"txt\" name=\"newhref[]\" size=\"20\">\"', 'td29']
]
];
</script>";
$_CA['xmlns'] = (array)dunserialize($_CA['xmlns']);
//echo sizeof($_CA['xmlns']);
foreach($_CA['xmlns'] as $xmlns) {
if(!$xmlns['prefix'] == '') {
$checkavailable = $xmlns['available'] ? 'checked' : '';
$xmlns['idtype'] = cplang('click_edit_'.$xmlns['idtype']);
showtablerow(
'', $tableClasses, array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$xmlns[xmlnsid]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$xmlns[xmlnsid]]\" value=\"$xmlns[displayorder]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[$xmlns[xmlnsid]]\" value=\"1\" $checkavailable>",
"xmlns:<input type=\"text\" class=\"txt\" size=\"10\" name=\"prefix[$xmlns[xmlnsid]]\" value=\"$xmlns[prefix]\">=",
"\"<input type=\"text\" class=\"txt\" size=\"20\" name=\"href[$xmlns[xmlnsid]]\" value=\"$xmlns[href]\">\"",
)
);
}
}
echo '<tr><td></td><td colspan="8"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.'添加命名空间'.'</a></div></td></tr>';
showsubmit('settingsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
$settingnew = $_GET['settingnew'];
//$ids = array();
//$xmlns = array($settingnew['xmlns']);
if(is_array($_GET['prefix'])) {
foreach($_GET['prefix'] as $xmlnsid => $val) {
//$xmlnsid = intval($xmlnsid);
//echo intval($xmlnsid == '');
$updatearr = array(
'xmlnsid' => dhtmlspecialchars($_GET['prefix'][$xmlnsid]),
'prefix' => dhtmlspecialchars($_GET['prefix'][$xmlnsid]),
'href' => $_GET['href'][$xmlnsid],
'idtype' => 'xmlns',
'available' => intval($_GET['available'][$xmlnsid]),
'displayorder' => intval($_GET['displayorder'][$xmlnsid]),
);
//C::t('home_click')->update($id, $updatearr);
$settingnew['xmlns'][$xmlnsid] = $updatearr;
}
}
if(is_array($_GET['delete'])) {
foreach($_GET['delete'] as $id => $val) {
//$ids[] = $id;
//echo $_GET['delete'][$id];
//echo '=';
//echo $_GET['delete'][$id];
//echo ';';
//$xmlns[($id)] = array();
//$xmlns = array_splice($xmlns, intval($id), 1);
unset($settingnew['xmlns'][$_GET['delete'][$id]]);
}
if($ids) {
//C::t('home_click')->delete($ids, true);
}
}
if(is_array($_GET['newprefix'])) {
foreach($_GET['newprefix'] as $key => $value) {
//echo $key;
//echo "=";
//echo $value;
if($value != '' && $_GET['newhref'][$key] != '') {
$data = array(
'xmlnsid' => dhtmlspecialchars($value),
'prefix' => dhtmlspecialchars($value),
'href' => $_GET['newhref'][$key],
'idtype' => 'xmlns',
'available' => intval($_GET['newavailable'][$key]),
'displayorder' => intval($_GET['newdisplayorder'][$key])
);
//C::t('home_click')->insert($data);
//print_r( $data);
//array_push($xmlns, $data);
$settingnew['xmlns'][dhtmlspecialchars($value)] = $data;
}
}
}
$settingnew['xmlns'] = serialize($settingnew['xmlns']);
C::t('common_setting')->update_batch($settingnew);
updatecache('setting');
//echo $settingnew['xmlns'];
/*
$keys = $ids = $_G['cache']['click'] = array();
foreach(C::t('home_click')->fetch_all_by_available() as $value) {
if(count($_G['cache']['click'][$value['idtype']]) < 8) {
$keys[$value['idtype']] = $keys[$value['idtype']] ? ++$keys[$value['idtype']] : 1;
$_G['cache']['click'][$value['idtype']][$keys[$value['idtype']]] = $value;
} else {
$ids[] = $value['clickid'];
}
}
if($ids) {
C::t('home_click')->update($ids, array('available'=>0), true);
}
*/
//$_G['cache']['plugin'][$identifier]['analytics'] = $settingnew['analytics'];
//echo "<textarea>".$_G['cache']['plugin'][$identifier]."</textarea>";
////////////////////////////////////////////////////////////////////////////////
/*
$msg = '为了正常使用此插件,您可
能还需要上传或修改相应的文
件或模板,详情请查看本插件的安装说明';
$file = DISCUZ_ROOT.'./template/default/common/header_common.htm';
function xm_file_content_exists($file, $message, $method = 'stripos') {
if(file_exists($file)) {
$content = file_get_contents($file);
if($method == 'stripos') {
return stripos($content, $message) !== false;
}elseif($method == 'preg_match'){
return preg_match($message, $content);
}
}
return false;
}
function xm_file_replace($file, $pattern, $replace, $method = 'str_replace', $limit = -1) {
if(file_exists($file)) {
$content = file_get_contents($file);
if($method == 'str_replace') {
$content = str_replace($pattern, $replace, $content, $limit);
}elseif($method == 'preg_replace_callback' || $method == 'preg' && is_callable($replace)) {
$content = preg_replace_callback($pattern, $replace, $content, $limit);
}else{
$content = preg_replace($pattern, $replace, $content, $limit);
}
if($content !== false) {
file_put_contents($file, $content);
return true;
}
}
return false;
}
$hooker = '{hook/global_header_xmlns}';
$pattern = "/<html( xmlns(\:[a-z0-9]+)?\=(\'|\")[a-zA-Z0-9\:\/\.]+(\'|\"))*>/i";
$replacement = "<html$1$hooker>";
$method = "preg_replace";
if(!xm_file_content_exists($file, $hooker)){
if(!xm_file_content_exists($file, $pattern, "preg_match") || !xm_file_replace($file, $pattern, $replacement, $method))
cpmsg($msg, 'action=plugins&operation=config&do='.$pluginid.'&identifier='.$identifier.'&pmod=footercp', 'error');
}
$hooker = "<!--{hook/global_header_meta}-->";
$pattern = "/(\t*)(<!--{csstemplate}-->)/i";
$replacement = "$1$2\r\n$1$hooker";
if(!xm_file_content_exists($file, $hooker)){
if(!xm_file_content_exists($file, $pattern, "preg_match") || !xm_file_replace($file, $pattern, $replacement, $method))
cpmsg($msg, 'action=plugins&operation=config&do='.$pluginid.'&identifier='.$identifier.'&pmod=footercp', 'error');
}
*/
//////////////////////////////////////////////////////////////////////////////
cpmsg('setting_update_succeed', 'action=plugins&operation=config&do='.$pluginid.'&identifier='.$identifier.'&pmod=xmlns', 'succeed');
}