$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 '
';
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 ''.(!$i ? $page.'_'.$hook : '').' | '.
''.$plugins[$plugin]['name'].' | '.
''.
($hook != 'variables' ?
' | ' :
'').
''.formathook($row).' |
';
$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 '';
if($redirect) {
if(!$plugins[$redirect['plugin']]) {
WeChatHook::updateRedirect(array());
}
echo ''.lang('plugin/wechat', 'wechatapi_redirect').' | '.$plugins[$redirect['plugin']]['name'].' | '.formathook($redirect).' |
';
}
foreach($response as $k => $row) {
if(!$plugins[$row['plugin']]) {
$deleteresponses[$k] = array();
}
echo ''.lang('plugin/wechat', 'api_'.$k).'('.$k.') | '.$plugins[$row['plugin']]['name'].' | '.formathook($row).' |
';
}
showtablefooter();
$wechatresponseExts = unserialize($_G['setting']['wechatresponseExts']);
if($wechatresponseExts) {
showtableheader();
foreach($wechatresponseExts as $extk => $response) {
echo '';
foreach($response as $k => $row) {
if(!$plugins[$row['plugin']]) {
$deleteresponseExts[$extk][$k] = array();
}
echo ''.lang('plugin/wechat', 'api_'.$k).'('.$k.') | '.$plugins[$row['plugin']]['name'].' | '.formathook($row).' |
';
}
}
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 '';
foreach(unserialize($_G['setting']['wechatappInfos']) as $k => $info) {
echo ''.$k.' | '.$info['appId'].' | '.$info['appSecret'].' |
';
}
showtablefooter();
}
function formathook($hook) {
return 'File: '.$hook['plugin'].'/'.$hook['include'].' Method: '.$hook['class'].'->'.$hook['method'];
}
function pluginapicmp($a, $b) {
return $a['order'] > $b['order'] ? 1 : -1;
}
?>