fetch_all(array('mobilewechat')); $setting = (array)unserialize($setting['mobilewechat']); $ac = !empty($_GET['ac']) ? $_GET['ac'] : ''; require_once libfile('function/forumlist'); loadcache('forums'); require_once DISCUZ_ROOT.'./source/plugin/wechat/setting.class.php'; WeChatSetting::menu(); if(!$ac) { $ppp = 20; arsort($setting['showactivity']['tids']); $page = max(1, $_GET['page']); $tids = array_slice($setting['showactivity']['tids'], ($page - 1) * $ppp, $ppp); $multipage = multi(count($setting['showactivity']['tids']), $ppp, $page, ADMINSCRIPT.'?action=plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=showactivity_setting', 0, 3, TRUE, TRUE); $showthreads = C::t('forum_thread')->fetch_all($tids); $activities = C::t('forum_activity')->fetch_all(array_keys($showthreads)); arsort($showthreads); showformheader('plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=showactivity_setting&ac=del', 'enctype'); showtableheader(); echo ''.lang('plugin/wechat', 'show_title').''. lang('plugin/wechat', 'show_starttime').' - '.lang('plugin/wechat', 'show_endtime').''. lang('plugin/wechat', 'show_expiration').''. lang('plugin/wechat', 'show_applynumber').''. lang('plugin/wechat', 'show_forum').''; foreach($showthreads as $tid => $thread) { $settingsnew[$tid] = $tid; echo ''.$thread['subject'].''. dgmdate($activities[$thread['tid']]['starttimefrom']).($activities[$thread['tid']]['starttimeto'] ? ' - '.dgmdate($activities[$thread['tid']]['starttimeto']) : '').''. dgmdate($activities[$thread['tid']]['expiration']).''. $activities[$thread['tid']]['applynumber'].''. $_G['cache']['forums'][$thread['fid']]['name'].''. ''.lang('plugin/wechat', 'show_export').''; } $add = ''; if($showthreads) { showsubmit('submit', lang('plugin/wechat', 'show_delthread'), $add, '', $multipage); } else { showsubmit('', '', 'td', $add); } showtablefooter(); showformfooter(); } elseif($ac == 'del') { if(submitcheck('submit')) { foreach($_GET['delete'] as $delete) { unset($setting['showactivity']['tids'][$delete]); C::t('forum_thread')->delete($delete); } $settings = array('mobilewechat' => serialize($setting)); C::t('common_setting')->update_batch($settings); updatecache(array('plugin', 'setting')); cpmsg(lang('plugin/wechat', 'show_delthread_succeed'), 'action=plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=showactivity_setting', 'succeed'); } } elseif($ac == 'add') { if(!submitcheck('submit')) { echo ''; $forumselect = "'; showformheader('plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=showactivity_setting&ac=add', 'enctype'); showtableheader(); showsetting(lang('plugin/wechat', 'show_title'), 'subject', '', 'text'); showsetting(lang('plugin/wechat', 'show_starttime'), 'starttimefrom', '', 'calendar', '', 0, '', 1); showsetting(lang('plugin/wechat', 'show_expiration'), 'activityexpiration', '', 'calendar', '', 0, '', 1); showsetting(lang('plugin/wechat', 'show_endtime'), 'starttimeto', '', 'calendar', '', 0, '', 1); showsetting(lang('plugin/wechat', 'show_memo'), 'message', '', 'textarea'); showsetting(lang('plugin/wechat', 'show_forum'), '', '', $forumselect); showsubmit('submit'); showtablefooter(); showformfooter(); } else { $_GET['activityclass'] = lang('plugin/wechat', 'show_thread_class'); $_GET['activityplace'] = lang('plugin/wechat', 'show_thread_place'); if(!$_GET['subject'] || !$_GET['starttimefrom'] || !$_GET['activityexpiration'] || !$_GET['message'] || !$_GET['fid']) { cpmsg(lang('plugin/wechat', 'show_input_error'), '', 'error'); } if(@strtotime($_GET['starttimefrom']) === -1 || @strtotime($_GET['starttimefrom']) === FALSE) { cpmsg(lang('message', 'activity_fromtime_error'), '', 'error'); } elseif(trim($_GET['activityexpiration']) && (@strtotime($_GET['activityexpiration']) === -1 || @strtotime($_GET['activityexpiration']) === FALSE)) { cpmsg(lang('message', 'activity_totime_error'), '', 'error'); } $activity = array(); $activity['class'] = $_GET['activityclass']; $activity['starttimefrom'] = @strtotime($_GET['starttimefrom']); $activity['starttimeto'] = $_GET['starttimeto'] ? @strtotime($_GET['starttimeto']) : 0; $activity['place'] = $_GET['activityplace']; $activity['expiration'] = @strtotime($_GET['activityexpiration']); $newthread = array( 'fid' => $_GET['fid'], 'posttableid' => 0, 'readperm' => 0, 'price' => 0, 'typeid' => 0, 'sortid' => 0, 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $_GET['subject'], 'dateline' => TIMESTAMP, 'lastpost' => TIMESTAMP, 'lastposter' => $_G['username'], 'displayorder' => 1, 'digest' => 0, 'special' => 4, 'attachment' => 0, 'moderated' => 0, 'status' => 0, 'isgroup' => 0, 'replycredit' => 0, 'closed' => 0, ); $tid = C::t('forum_thread')->insert($newthread, true); $pid = insertpost(array( 'fid' => $_GET['fid'], 'tid' => $tid, 'first' => '1', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $_GET['subject'], 'dateline' => TIMESTAMP, 'message' => $_GET['message'], 'useip' => '', 'invisible' => 0, 'anonymous' => 0, 'usesig' => 0, 'htmlon' => 0, 'bbcodeoff' => 0, 'smileyoff' => 0, 'parseurloff' => 0, 'attachment' => '0', 'tags' => '', 'replycredit' => 0, 'status' => 0 )); $data = array( 'tid' => $tid, 'uid' => $_G['uid'], 'cost' => 0, 'starttimefrom' => $activity['starttimefrom'], 'starttimeto' => $activity['starttimeto'], 'place' => $activity['place'], 'class' => $activity['class'], 'expiration' => $activity['expiration'] ); C::t('forum_activity')->insert($data); $setting['showactivity']['tids'][$tid] = $tid; $settings = array('mobilewechat' => serialize($setting)); C::t('common_setting')->update_batch($settings); updatecache(array('plugin', 'setting')); require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php'; wsq::report('pubshowactivity'); cpmsg(lang('plugin/wechat', 'show_addthread_succeed'), 'action=plugins&operation=config&do='.$pluginid.'&identifier=wechat&pmod=showactivity_setting', 'succeed'); } } elseif($ac == 'export') { if(!isset($setting['showactivity']['tids'][$_GET['tid']])) { cpmsg(lang('plugin/wechat', 'show_thread_not_found')); } $thread = get_thread_by_tid($_GET['tid']); if(!$thread) { cpmsg(lang('plugin/wechat', 'show_thread_not_found')); } $posttableid = $thread['posttableid']; $posts = DB::fetch_all("SELECT * FROM %t WHERE tid=%d", array('forum_debatepost', $_GET['tid']), 'pid'); foreach(C::t('forum_post')->fetch_all($posttableid, array_keys($posts), false) as $post) { $array[$posts[$post['pid']]['voters'].'.'.$post['position']] = $post['author'].','.$posts[$post['pid']]['voters'].','.$post['position']; } ob_end_clean(); header('Content-Encoding: none'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=showactivity_'.$_GET['tid'].'.csv'); header('Pragma: no-cache'); header('Expires: 0'); krsort($array); $detail = lang('plugin/wechat', 'show_export_title')."\r\n".implode("\r\n", $array); if($_G['charset'] != 'gbk') { $detail = diconv($detail, $_G['charset'], 'GBK'); } define('FOOTERDISABLED', true); echo $detail; exit(); } ?>