fetch_all(array('threadtableids', 'threadtable_info'), true);
$threadtableids = $settings['threadtableids'] ? $settings['threadtableids'] : array();
$threadtable_info = $settings['threadtable_info'] ? $settings['threadtable_info'] : array();
if($operation == 'manage') {
shownav('founder', 'nav_threadsplit');
if(!submitcheck('threadsplit_update_submit')) {
showsubmenu('nav_threadsplit', array(
array('nav_threadsplit_manage', 'threadsplit&operation=manage', 1),
array('nav_threadsplit_move', 'threadsplit&operation=move', 0),
));
showtips('threadsplit_manage_tips');
showformheader('threadsplit&operation=manage');
showtableheader('threadsplit_manage_table_orig');
$thread_table_orig = C::t('forum_thread')->gettablestatus();
showsubtitle(array('threadsplit_manage_tablename', 'threadsplit_manage_threadcount', 'threadsplit_manage_datalength', 'threadsplit_manage_indexlength', 'threadsplit_manage_table_createtime', 'threadsplit_manage_table_memo', ''));
showtablerow('', array(), array($thread_table_orig['Name'], $thread_table_orig['Rows'], $thread_table_orig['Data_length'], $thread_table_orig['Index_length'], $thread_table_orig['Create_time'], "", ''));
showtableheader('threadsplit_manage_table_archive');
showsubtitle(array('threadsplit_manage_tablename', 'threadsplit_manage_dislayname', 'threadsplit_manage_threadcount', 'threadsplit_manage_datalength', 'threadsplit_manage_indexlength', 'threadsplit_manage_table_createtime', 'threadsplit_manage_table_memo', ''));
foreach($threadtableids as $tableid) {
if(!$tableid) {
continue;
}
$tablename = "forum_thread_$tableid";
$table_info = C::t('forum_thread')->gettablestatus($tableid);
showtablerow('', array(), array($table_info['Name'], "", $table_info['Rows'], $table_info['Data_length'], $table_info['Index_length'], $table_info['Create_time'], "", "{$lang['delete']}"));
}
showtablefooter();
showsubmit('threadsplit_update_submit', 'threadsplit_manage_update', '', ''.$lang['threadsplit_manage_table_add'].' '.$lang['threadsplit_manage_forum_update'].'');
showformfooter();
} else {
$threadtable_info = array();
$_GET['memo'] = !empty($_GET['memo']) ? $_GET['memo'] : array();
$_GET['displayname'] = !empty($_GET['displayname']) ? $_GET['displayname'] : array();
foreach(array_keys($_GET['memo']) as $tableid) {
$threadtable_info[$tableid]['memo'] = $_GET['memo'][$tableid];
}
foreach(array_keys($_GET['displayname']) as $tableid) {
$threadtable_info[$tableid]['displayname'] = $_GET['displayname'][$tableid];
}
C::t('common_setting')->update('threadtable_info', $threadtable_info);
savecache('threadtable_info', $threadtable_info);
update_threadtableids();
updatecache('setting');
cpmsg('threadsplit_manage_update_succeed', 'action=threadsplit&operation=manage', 'succeed');
}
} elseif($operation == 'addnewtable') {
if(empty($threadtableids)) {
$maxtableid = 0;
} else {
$maxtableid = max($threadtableids);
}
C::t('forum_thread')->create_table($maxtableid + 1);
update_threadtableids();
updatecache('setting');
cpmsg('threadsplit_table_create_succeed', 'action=threadsplit&operation=manage', 'succeed');
} elseif($operation == 'droptable') {
$tableid = intval($_GET['tableid']);
$tablename = "forum_thread_$tableid";
$table_info = C::t('forum_thread')->gettablestatus($tableid);
if(!$tableid || !$table_info) {
cpmsg('threadsplit_table_no_exists', 'action=threadsplit&operation=manage', 'error');
}
if($table_info['Rows'] > 0) {
cpmsg('threadsplit_drop_table_no_empty_error', 'action=threadsplit&operation=manage', 'error');
}
C::t('forum_thread')->drop_table($tableid);
unset($threadtable_info[$tableid]);
update_threadtableids();
C::t('common_setting')->update('threadtable_info', $threadtable_info);
savecache('threadtable_info', $threadtable_info);
updatecache('setting');
cpmsg('threadsplit_drop_table_succeed', 'action=threadsplit&operation=manage', 'succeed');
} elseif($operation == 'move') {
if(!$_G['setting']['bbclosed'] && !IN_DEBUG) {
cpmsg('threadsplit_forum_must_be_closed', 'action=threadsplit&operation=manage', 'error');
}
require_once libfile('function/forumlist');
$tableselect = '';
$forumselect = '';
if(isset($_GET['inforum'])) {
$forumselect = preg_replace("/(\';
} else {
$typeselect .= '';
}
}
if(isset($_GET['insort'])) {
$sortselect = preg_replace("/(\