$query = DB::query("SHOW TABLES LIKE '" . DB::table('forum_post') . "\\_%'"); $tablename = DB::table('forum_post'); $tableid = 0; $tablestatus = gettablestatus($tablename); $postcount = $tablestatus['Rows']; $data_length = $tablestatus['Data_length']; $index_length = $tablestatus['Index_length']; $tabletype = $lang['postsplit_manage_' . $posttable_info[$tableid]['type'] . '_table']; showtablerow('', array('class="td25"'), array("<input class=\"radio\" " . ($_G['gp_sourcetableid'] == '0' ? 'disabled="disabled"' : '') . " type=\"radio\" name=\"tableid\" value=\"0\" />", $tablename . " ({$tabletype})", $postcount, $data_length, $index_length, $tablestatus['Create_time'], $posttable_info[$tableid]['memo'])); while ($table = DB::fetch($query)) { list($tempkey, $tablename) = each($table); $tableid = gettableid($tablename); if (in_array($tableid, array('tableid')) || !preg_match('/^\\d+$/', $tableid)) { continue; } $tablestatus = gettablestatus($tablename); $postcount = $tablestatus['Rows']; $data_length = $tablestatus['Data_length']; $index_length = $tablestatus['Index_length']; $tabletype = $lang['postsplit_manage_' . $posttable_info[$tableid]['type'] . '_table']; showtablerow('', array(), array("<input class=\"radio\" " . ($_G['gp_sourcetableid'] == $tableid ? 'disabled="disabled"' : '') . " type=\"radio\" name=\"tableid\" value=\"{$tableid}\" />", $tablename . " ({$tabletype})", $postcount, $data_length, $index_length, $tablestatus['Create_time'], $posttable_info[$tableid]['memo'])); } if ($_G['gp_detail']) { showtablefooter(); showtableheader('threads_list', 'notop'); showsubtitle(array('', 'subject', 'forum', 'postsplit_move_thread_table', 'author', 'threads_replies', 'threads_views')); echo $threads; } } showtablefooter(); if ($threadcount) {
function movedate($query) { global $sourcesize, $tableid, $movesize, $targettableid, $hash, $tableindex, $threadtableids, $fieldstr, $fromtableid, $posttable_info; $tids = array(); while ($value = DB::fetch($query)) { $tids[$value['tid']] = $value['tid']; } $fromtable = getposttable($fromtableid, true); $condition = " tid IN(" . dimplode($tids) . ")"; DB::query("INSERT INTO " . DB::table(getposttable($targettableid)) . " ({$fieldstr}) SELECT {$fieldstr} FROM {$fromtable} WHERE {$condition}", 'SILENT'); if (DB::errno()) { DB::delete(getposttable($targettableid), $condition); } else { foreach ($threadtableids as $threadtableid) { $table = $threadtableid ? "forum_thread_{$threadtableid}" : 'forum_thread'; DB::update($table, array('posttableid' => $targettableid), $condition); if (DB::affected_rows() == count($tids)) { break; } } DB::delete(getposttable($fromtableid), $condition); } $status = gettablestatus(DB::table(getposttable($targettableid)), false); $targetsize = $sourcesize + $movesize * 1048576; $nowdatasize = $targetsize - $status['Data_length']; if ($status['Data_length'] >= $targetsize) { cpmsg('postsplit_done', 'action=postsplit&operation=optimize&tableid=' . $fromtableid, 'form'); } cpmsg('postsplit_doing', 'action=postsplit&operation=movepost&fromtable=' . $tableid . '&movesize=' . $movesize . '&targettable=' . $targettableid . '&hash=' . $hash . '&tindex=' . $tableindex, 'loadingform', array('datalength' => sizecount($status['Data_length']), 'nowdatalength' => sizecount($nowdatasize))); }
$fids = implode(',', array_unique($fids)); showtagheader('div', 'threadlist', TRUE); showformheader("threadsplit&operation=move&sourcetableid={$_G['gp_sourcetableid']}&threadtomove=" . $threadtomove); showhiddenfields($_G['gp_detail'] ? array('fids' => $fids) : array('conditions' => serialize($conditions))); showtableheader(cplang('threads_result') . ' ' . $threadcount . ' <a href="###" onclick="$(\'threadlist\').style.display=\'none\';$(\'threadsearch\').style.display=\'\';" class="act lightlink normal">' . cplang('research') . '</a>', 'nobottom'); showsubtitle(array('', 'threadsplit_move_to', 'threadsplit_manage_threadcount', 'threadsplit_manage_datalength', 'threadsplit_manage_indexlength', 'threadsplit_manage_table_createtime', 'threadsplit_manage_table_memo')); if (!$threadcount) { showtablerow('', 'colspan="3"', cplang('threads_thread_nonexistence')); } else { $threadtable_orig = gettablestatus(DB::table('forum_thread')); $tableid = 0; showtablerow('', array('class="td25"'), array("<input class=\"radio\" " . ($_G['gp_sourcetableid'] == '0' ? 'disabled="disabled"' : '') . " type=\"radio\" name=\"tableid\" value=\"0\" />", $threadtable_orig['Name'], $threadtable_orig['Rows'], $threadtable_orig['Data_length'], $threadtable_orig['Index_length'], $threadtable_orig['Create_time'], $threadtable_info[0]['memo'])); foreach ($threadtableids as $tableid) { if ($tableid) { $tablename = "forum_thread_{$tableid}"; $tablestatus = gettablestatus(DB::table($tablename)); showtablerow('', array(), array("<input class=\"radio\" " . ($_G['gp_sourcetableid'] == $tableid ? 'disabled="disabled"' : '') . " type=\"radio\" name=\"tableid\" value=\"{$tableid}\" />", $tablestatus['Name'] . ($threadtable_info[$tableid]['displayname'] ? " (" . htmlspecialchars($threadtable_info[$tableid]['displayname']) . ")" : ''), $tablestatus['Rows'], $tablestatus['Data_length'], $tablestatus['Index_length'], $tablestatus['Create_time'], $threadtable_info[$tableid]['memo'])); } } if ($_G['gp_detail']) { showtablefooter(); showtableheader('threads_list', 'notop'); showsubtitle(array('', 'subject', 'forum', 'author', 'threads_replies', 'threads_views')); echo $threads; } } showtablefooter(); if ($threadcount) { showtableheader(''); showsetting('threadsplit_move_threads_per_time', 'threads_per_time', 200, 'text'); showtablefooter();