response_setting.inc.php
9.72 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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: response_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('menusubmit')) {
showtips(lang('plugin/wechat', 'response_tips', array('url' => $url)));
$responsehook = WeChatHook::getResponse();
if($_GET['subscribe'] == 'custom') {
$response['subscribeback'] = $responsehook['receiveEvent::subscribe'];
$updatedata = array('receiveEvent::subscribe' => array('plugin' => 'wechat', 'include' => 'response.class.php', 'class' => 'WSQResponse', 'method' => 'custom'));
$responsehook = WeChatHook::updateResponse($updatedata);
savecache('wechat_response', $response);
cpmsg(lang('plugin/wechat', 'response_subscribe_custom'), 'action=plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=response_setting', 'succeed');
} elseif($_GET['subscribe'] == 'restore') {
$response['subscribeback'] = $response['subscribeback'] ? $response['subscribeback'] : array('plugin' => 'wechat', 'include' => 'response.class.php', 'class' => 'WSQResponse', 'method' => 'subscribe');
$updatedata = array('receiveEvent::subscribe' => $response['subscribeback']);
$responsehook = WeChatHook::updateResponse($updatedata);
savecache('wechat_response', $response);
cpmsg(lang('plugin/wechat', 'response_subscribe_plugin'), 'action=plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=response_setting', 'succeed');
}
if($_GET['text'] == 'custom') {
$response['textback'] = $responsehook['receiveMsg::text'];
$updatedata = array('receiveMsg::text' => array('plugin' => 'wechat', 'include' => 'response.class.php', 'class' => 'WSQResponse', 'method' => 'text'));
$responsehook = WeChatHook::updateResponse($updatedata);
savecache('wechat_response', $response);
cpmsg(lang('plugin/wechat', 'response_message_custom'), 'action=plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=response_setting', 'succeed');
} elseif($_GET['text'] == 'restore') {
$response['textback'] = $response['textback'] ? $response['textback'] : array('plugin' => 'wechat', 'include' => 'response.class.php', 'class' => 'WSQResponse', 'method' => 'text');
$updatedata = array('receiveMsg::text' => $response['textback']);
$responsehook = WeChatHook::updateResponse($updatedata);
savecache('wechat_response', $response);
cpmsg(lang('plugin/wechat', 'response_message_plugin'), 'action=plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=response_setting', 'succeed');
}
WeChatSetting::showResource();
showformheader('plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=response_setting');
showtableheader();
echo '<tr><th class="td25"></th><th style="width:350px"><strong>'.lang('plugin/wechat', 'response_keyword').'</strong></th><th><strong>'.lang('plugin/wechat', 'response_content').'</strong></th></tr>';
if($responsehook['receiveEvent::subscribe']['plugin'] == 'wechat' &&
$responsehook['receiveEvent::subscribe']['class'] == 'WSQResponse' &&
$responsehook['receiveEvent::subscribe']['method'] == 'custom') {
showtablerow('class="header"', array('', 'class="td23 td28"', '', 'class="td29"'), array(
"",
lang('plugin/wechat', 'response_subscribe'),
"<p class=\"mbn\">".lang('plugin/wechat', 'response_custom')." ".($response['subscribeback'] ? "<a class=\"normal\" href=\"".ADMINSCRIPT."?action=plugins&operation=config&do=$pluginid&identifier=wechat&pmod=response_setting&subscribe=restore\">[".lang('plugin/wechat', 'response_switch_plugin_mode', array('plugin' => $response['subscribeback']['plugin']))."]</a></p>" : '')
));
showtablerow('', array('', 'class="td23 td28"', '', 'class="td29"'), array(
"",
"<i>".lang('plugin/wechat', 'subscribe')."</i>",
"<textarea class=\"tarea\" name=\"response[subscribe]\" id=\"res_subscribe\" rows=\"5\" cols=\"40\">".dhtmlspecialchars($response['subscribe'])."</textarea>"
."<br /><a href=\"javascript:;\" id=\"rsel\" onclick=\"showResource('res_subscribe')\">".lang('plugin/wechat', 'resource_select')."</a>"
));
} else {
showtablerow('class="header"', array('', 'class="td23 td28"', '', 'class="td29"'), array(
"",
lang('plugin/wechat', 'response_subscribe'),
"<p>".lang('plugin/wechat', 'response_plugin_mode', array('plugin' => $responsehook['receiveEvent::subscribe']['plugin']))." <a class=\"normal\" href=\"".ADMINSCRIPT."?action=plugins&operation=config&do=$pluginid&identifier=wechat&pmod=response_setting&subscribe=custom\">[".lang('plugin/wechat', 'response_switch_custom_mode')."]</a></p>"
));
}
showtablerow('class="header"', array('', 'class="td23 td28"', '', 'class="td29"'), array(
"",
lang('plugin/wechat', 'response_access'),
"<p class=\"mbn normal\">".lang('plugin/wechat', 'response_access_comment')
));
showtablerow('', array('', 'class="td23 td28"', '', 'class="td29"'), array(
"",
"<i>".lang('plugin/wechat', 'access')."</i>",
"<textarea class=\"tarea\" name=\"response[access]\" id=\"res_access\" rows=\"5\" cols=\"40\">".dhtmlspecialchars($response['access'])."</textarea>"
."<br /><a href=\"javascript:;\" id=\"rsel\" onclick=\"showResource('res_access')\">".lang('plugin/wechat', 'resource_select')."</a>"
));
showtablerow('class="header"', array('', 'class="td23 td28"', '', 'class="td29"'), array(
"",
lang('plugin/wechat', 'response_scan'),
"<p class=\"mbn normal\">".lang('plugin/wechat', 'response_scan_comment')
));
showtablerow('', array('', 'class="td23 td28"', '', 'class="td29"'), array(
"",
"<i>".lang('plugin/wechat', 'scan')."</i>",
"<textarea class=\"tarea\" name=\"response[scan]\" id=\"res_scan\" rows=\"5\" cols=\"40\">".dhtmlspecialchars($response['scan'])."</textarea>"
."<br /><a href=\"javascript:;\" id=\"rsel\" onclick=\"showResource('res_scan')\">".lang('plugin/wechat', 'resource_select')."</a>"
));
if($responsehook['receiveMsg::text']['plugin'] == 'wechat' &&
$responsehook['receiveMsg::text']['class'] == 'WSQResponse' &&
$responsehook['receiveMsg::text']['method'] == 'text') {
showtablerow('class="header"', array('', 'class="td23 td28"', '', 'class="td29"'), array(
"",
lang('plugin/wechat', 'response_message'),
"<p class=\"mbn\">".lang('plugin/wechat', 'response_custom')." ".($response['textback'] ? "<a class=\"normal\" href=\"".ADMINSCRIPT."?action=plugins&operation=config&do=$pluginid&identifier=wechat&pmod=response_setting&text=restore\">[".lang('plugin/wechat', 'response_switch_plugin_mode', array('plugin' => $response['textback']['plugin']))."]</a></p>" : '')
));
foreach($response['text'] as $k => $text) {
showtablerow('', array('', 'class="td23 td28"', 'class="td29"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"response[text][$k][delete]\" value=\"yes\">",
"<div class=\"parentnode\"><input type=\"text\" class=\"txt\" size=\"30\" name=\"response[text][$k][keyword]\" value=\"".dhtmlspecialchars($text['keyword'])."\"></div>",
"<textarea class=\"tarea\" name=\"response[text][$k][response]\" rows=\"5\" id=\"res_text_$k\" cols=\"40\">".dhtmlspecialchars($text['response'])."</textarea>"
."<br /><a href=\"javascript:;\" id=\"rsel\" onclick=\"showResource('res_text_$k')\">".lang('plugin/wechat', 'resource_select')."</a>"
));
}
echo '<tr><td></td><td class="td23 td28"></td><td colspan="2"><div><a href="###" onclick="addrow(this, 0, 0)" class="addtr">'.lang('plugin/wechat', 'response_add_message').'</a></div></td></tr>';
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[[1,''], [1, '<input name="newresponse[keyword][]" value="" size="30" type="text" class="txt">'], [1, '<textarea class="tarea" name="newresponse[response][]" rows="5" cols="40"></textarea>', 'td29']],
];
</script>
EOT;
} else {
showtablerow('class="header"', array('', 'class="td23 td28"', '', 'class="td29"'), array(
"",
lang('plugin/wechat', 'response_message'),
"<p>".lang('plugin/wechat', 'response_plugin_mode', array('plugin' => $responsehook['receiveMsg::text']['plugin']))." <a class=\"normal\" href=\"".ADMINSCRIPT."?action=plugins&operation=config&do=$pluginid&identifier=wechat&pmod=response_setting&text=custom\">[".lang('plugin/wechat', 'response_switch_custom_mode')."]</a></p>"
));
}
showsubmit('menusubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(!empty($_GET['newresponse'])) {
foreach($_GET['newresponse']['keyword'] as $k => $keyword) {
$item = array(
'keyword' => $keyword,
'response' => $_GET['newresponse']['response'][$k],
);
$response['text'][] = $item;
}
}
foreach($_GET['response']['text'] as $k => $value) {
if($value['delete']) {
unset($response['text'][$k]);
continue;
}
$response['text'][$k] = $value;
}
$response['subscribe'] = $_GET['response']['subscribe'];
$response['access'] = $_GET['response']['access'];
$response['scan'] = $_GET['response']['scan'];
$query = array(
'subscribe' => $response['subscribe'],
'text' => array(),
);
foreach($response['text'] as $value) {
$query['text'][$value['keyword']] = $value['response'];
}
$response['query'] = $query;
savecache('wechat_response', $response);
cpmsg('setting_update_succeed', 'action=plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=response_setting', 'succeed');
}
?>