api_setting.inc.php
5.23 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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: api_setting.inc.php 35024 2014-10-14 07:43:43Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
loadcache('wechat_response');
$response = & $_G['cache']['wechat_response'];
require_once DISCUZ_ROOT.'./source/plugin/wechat/wechat.lib.class.php';
require_once DISCUZ_ROOT.'./source/plugin/wechat/wsq.class.php';
require_once DISCUZ_ROOT.'./source/plugin/wechat/setting.class.php';
WeChatSetting::menu();
if(submitcheck('orderssubmit')) {
$apihook = WeChatHook::getAPIHook();
foreach($apihook as $page => $hooks) {
foreach($hooks as $hook => $rows) {
foreach($rows as $plugin => $row) {
if(isset($_GET['order'][$page][$hook][$plugin])) {
$apihook[$page][$hook][$plugin]['order'] = $_GET['order'][$page][$hook][$plugin];
}
$apihook[$page][$hook][$plugin]['allow'] = !empty($_GET['allow'][$page][$hook][$plugin]) ? 1 : 0;
}
uasort($apihook[$page][$hook], 'pluginapicmp');
}
}
$settings = array('mobileapihook' => serialize($apihook));
C::t('common_setting')->update_batch($settings);
updatecache('setting');
}
showtips(lang('plugin/wechat', 'wechatapi_tips'));
$apihook = WeChatHook::getAPIHook();
$plugins = DB::fetch_all('SELECT identifier, name FROM %t', array('common_plugin'), 'identifier');
showformheader('plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=api_setting');
showtableheader(lang('plugin/wechat', 'api_wsq'));
echo '<tr class="header"><th>'.lang('plugin/wechat', 'api_hook').'</th><th>'.cplang('plugins_name').'</th><th>'.cplang('enable').'/'.cplang('display_order').'</th><th>'.lang('plugin/wechat', 'api_method').'</th></tr>';
foreach($apihook as $page => $hooks) {
foreach($hooks as $hook => $rows) {
$i = 0;
foreach($rows as $plugin => $row) {
if(!$plugins[$plugin]) {
$deleteplugins[] = $plugin;
}
$row['plugin'] = $plugin;
echo '<tr class="hover"><td>'.(!$i ? $page.'_'.$hook : '').'</td>'.
'<td>'.$plugins[$plugin]['name'].'</td>'.
'<td><input class="checkbox" type="checkbox" name="allow['.$page.']['.$hook.']['.$plugin.']" value="1"'.($row['allow'] ? ' checked' : '').'>'.
($hook != 'variables' ?
'<input class="txt num" type="text" name="order['.$page.']['.$hook.']['.$plugin.']" value="'.$row['order'].'"></td>' :
'</td>').
'<td>'.formathook($row).'</td></tr>';
$i++;
}
}
}
if($deleteplugins) {
WeChatHook::delAPIHook($deleteplugins);
}
showsubmit('orderssubmit');
showtablefooter();
showformfooter();
$redirect = WeChatHook::getRedirect();
$response = WeChatHook::getResponse();
$plugins = DB::fetch_all('SELECT identifier, name FROM %t', array('common_plugin'), 'identifier');
showtableheader(lang('plugin/wechat', 'api_wechat'));
echo '<tr class="header"><th>'.lang('plugin/wechat', 'api_hook').'</th><th>'.cplang('plugins_name').'</th><th>'.lang('plugin/wechat', 'api_method').'</th></tr>';
if($redirect) {
if(!$plugins[$redirect['plugin']]) {
WeChatHook::updateRedirect(array());
}
echo '<tr class="hover"><td>'.lang('plugin/wechat', 'wechatapi_redirect').'</td><td>'.$plugins[$redirect['plugin']]['name'].'</td><td>'.formathook($redirect).'</td></tr>';
}
foreach($response as $k => $row) {
if(!$plugins[$row['plugin']]) {
$deleteresponses[$k] = array();
}
echo '<tr class="hover"><td>'.lang('plugin/wechat', 'api_'.$k).'('.$k.')</td><td>'.$plugins[$row['plugin']]['name'].'</td><td>'.formathook($row).'</td></tr>';
}
showtablefooter();
$wechatresponseExts = unserialize($_G['setting']['wechatresponseExts']);
if($wechatresponseExts) {
showtableheader();
foreach($wechatresponseExts as $extk => $response) {
echo '<tr class="header"><th>'.lang('plugin/wechat', 'wechat_responseexts').' '.$extk.'</th><th>'.cplang('plugins_name').'</th><th>'.lang('plugin/wechat', 'api_method').'</th></tr>';
foreach($response as $k => $row) {
if(!$plugins[$row['plugin']]) {
$deleteresponseExts[$extk][$k] = array();
}
echo '<tr class="hover"><td>'.lang('plugin/wechat', 'api_'.$k).'('.$k.')</td><td>'.$plugins[$row['plugin']]['name'].'</td><td>'.formathook($row).'</td></tr>';
}
}
showtablefooter();
}
if($deleteresponses) {
WeChatHook::updateResponse($deleteresponses);
}
if($deleteresponseExts) {
foreach($deleteresponseExts as $extk => $deleteresponses) {
WeChatHook::updateResponse($deleteresponses, $extk);
}
}
$wechatappInfos = unserialize($_G['setting']['wechatappInfos']);
if($wechatappInfos) {
showtableheader();
echo '<tr class="header"><th width="200">'.lang('plugin/wechat', 'wechat_devids').'</th><th>'.lang('plugin/wechat', 'wechat_appId').'</th><th>'.lang('plugin/wechat', 'wechat_appsecret').'</th></tr>';
foreach(unserialize($_G['setting']['wechatappInfos']) as $k => $info) {
echo '<tr class="hover"><td>'.$k.'</td><td>'.$info['appId'].'</td><td>'.$info['appSecret'].'</td></tr>';
}
showtablefooter();
}
function formathook($hook) {
return '<b>File:</b> '.$hook['plugin'].'/'.$hook['include'].' <b>Method:</b> '.$hook['class'].'->'.$hook['method'];
}
function pluginapicmp($a, $b) {
return $a['order'] > $b['order'] ? 1 : -1;
}
?>