Example #1
0
<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: menu_setting.inc.php 35201 2015-02-04 06:32:12Z nemohou $
 */
if (!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
    exit('Access Denied');
}
$setting = C::t('common_setting')->fetch_all(array('wechatmenu'));
$setting = (array) unserialize($setting['wechatmenu']);
require_once DISCUZ_ROOT . './source/plugin/wechat/wechat.lib.class.php';
require_once DISCUZ_ROOT . './source/plugin/wechat/setting.class.php';
WeChatSetting::menu();
if (!$_G['wechat']['setting']['wechat_appId'] || !$_G['wechat']['setting']['wechat_appsecret']) {
    cpmsg(lang('plugin/wechat', 'wsq_menu_at_error'), '', 'error');
}
if (!submitcheck('menusubmit') && !submitcheck('pubsubmit')) {
    $wechat_client = new WeChatClient($_G['wechat']['setting']['wechat_appId'], $_G['wechat']['setting']['wechat_appsecret']);
    if (in_array('plugin', $_G['setting']['rewritestatus'])) {
        $url = $_G['siteurl'] . rewriteoutput('plugin', 1, 'wechat', 'access', '', 'op=access');
    } else {
        $url = $_G['siteurl'] . 'plugin.php?id=wechat:access';
    }
    showtips(lang('plugin/wechat', 'menu_tips', array('url' => $url)));
    showformheader('plugins&operation=config&do=' . $pluginid . '&identifier=wechat&pmod=menu_setting');
    showtableheader();
    echo '<tr class="header"><th class="td25"></th><th>' . $lang['display_order'] . '</th><th style="width:350px">' . lang('plugin/wechat', 'wsq_menu_name') . '</th><th>' . lang('plugin/wechat', 'wsq_menu_keyurl') . '</th></tr>';
    foreach ($setting['button'] as $k => $button) {
     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>" : '')));