public static function insertThreadTypeSFun($tid, $type_id, $rate)
 {
     //参数检查
     if (empty($tid) || !is_array($type_id) || empty($type_id)) {
         echo "参数错误<br/>";
         return false;
     }
     //检查评论项,更改其格式(为空则置NULL,为str则加上单引号)
     if ($rate == NULL || !is_string($rate)) {
         $rate = "NULL";
     } else {
         $rate = "'{$rate}'";
     }
     //获取type的level,构造type数组(type_id=>type_level)
     $type = ThreadWithType::getTypeSFun($type_id);
     if (!$type) {
         echo "请检查type_id参数";
         return false;
     }
     //获取其数据库操作对象
     $db = GCDB::getInstance();
     //检查数据库是否已经存在该分类
     $sql = "";
     foreach ($type_id as $key => $value) {
         $sql = "SELECT count(*) as 'num' FROM `{$db->tablepre}forum_gc_excellent_thread` WHERE tid={$tid} AND type_id={$value};";
         $sqldata = $db->query($sql);
         $row = $sqldata->fetch_assoc();
         if ($row['num'] > 0) {
             //说明已存在该类关系,则去掉数组值
             unset($type_id[$key]);
             unset($type[$value]);
         }
     }
     if (empty($type)) {
         echo "{__LINE__}:该分类关系已经存在<br/>";
         return true;
     }
     //上面函数已经检查好参数
     //先进行数据库查重
     //构造sql语句
     //开始事务
     $db->start_transaction();
     //数据库查重
     foreach ($type as $id => $level) {
         $sql = "DELETE FROM `{$db->tablepre}forum_gc_excellent_thread` WHERE tid={$tid} AND ( 0 ";
         //此处加空格,直接删除同类型的tid联系
         if ($level < 30) {
             //是树节点,需要查找其所有的子节点,看是否有重复
             $tree = DataTree::getInstance();
             //获取其所有子节点id
             //参数为空则是获取所有节点
             $childid_array = $tree->getOneTreeNodeAllTypeid();
             foreach ($childid_array as $value) {
                 $sql .= " OR type_id={$value} ";
             }
         } else {
             //是多重分类,则按照每一层进行查找
             $leveltype = TypeArray::getInstance();
             $brotherid = $leveltype->getArrayTypeid($level);
             if (!$brotherid) {
                 //返回错误
                 echo "{__LINE__}:无法获取同类多重类型id<br/>";
                 return false;
             }
             foreach ($brotherid as $value) {
                 $sql .= " OR type_id={$value} ";
             }
         }
         $sql .= ");";
         echo "{__LINE__}:sql:" . $sql . "<br/>";
         //执行sql语句
         if (!$db->query($sql)) {
             echo "数据库除重失败!<br/>";
             //事务回滚
             $db->rollback_transaction();
             return false;
         }
     }
     //插入数据库
     $sql = "INSERT INTO `{$db->tablepre}forum_gc_excellent_thread`(`tid`,`type_id`,`rate`) VALUES ";
     foreach ($type_id as $value) {
         $sql .= "({$tid},{$value},{$rate}),";
     }
     //sql语句去掉最后一个逗号,并加上分号
     $sql = substr($sql, 0, -1);
     $sql .= ";";
     echo "{__LINE__}:INSERT:{$sql}<br/>";
     //运行sql语句
     if (!$db->query($sql)) {
         echo "插入操作失败<br/>";
         $db->rollback_transaction();
         return false;
     }
     //提交事务
     $db->commit_transaction();
     //返回
     return true;
 }
	$gc_attach=new GCAttachment(6,4,4);
	$gc_attach->showAttachment();
	print_r(GCAttachment::getAidTableidByTid(1));
	echo "<br/>";
	//测试获取帖子信息
	$gc_threadnode=new GCThreadNode(4);
	$gc_threadnode->showThreadNode();
	$ThreadWithAttach=$gc_threadnode;
	include template('excellent_shared/attachment.tpl');
*/
//测试类型帖子
print_r(ThreadWithType::insertThreadTypeSFun(1, array("37", "58"), NULL));
print_r(ThreadWithType::insertThreadTypeSFun(2, array("56", "58"), "心情舒畅"));
echo "<br/>";
$data = array("37");
$type_thread = new ThreadWithType($data);
//$result=ThreadWithType::getThreadSFun($data);
$result = ThreadWithType::getOneTypeThreadSFun(array(55, 54));
if ($result[0]) {
    echo "获取该类型帖子成功<br/>";
    $type_thread->showThread($result[1]);
}
//$type_thread->deleteThreadType(2);
//测试静态函数
//ThreadWithType::insertThreadTypeSFun(2,array("56","60"),"心情舒畅");
//ThreadWithType::deleteThreadTypeSFun(2);
$threadwithtype = $type_thread->getThreadArray();
$test = ThreadWithType::beCategoried(1);
//echo "{$test[0]}<br/>";
if (intval($test[0]) == -1) {
    echo "出错{$test[0]}<br/>";
if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
if ($_G[uid] == 0) {
    //showmessage('not_loggedin', null, 'NOPERM');
    showmessage('请选登录', '', array(), array('login' => true));
}
require_once "class/DiscuzDataTree.class.php";
require_once "class/TypeArray.class.php";
//获取type_id数组,如果未给出type_id数组,则直接获取根节点id
require_once "class/ThreadWithType.class.php";
require_once "function/function_showThreadWithTable.php";
require_once "function/function_showAttachmentDownload.php";
require_once "function/function_getAttachType.php";
require_once "function/function_showSearchTPL.php";
//获取分类下的帖子
$type_id = $_POST[type_id];
//print_r(ThreadWithType::beCategoried(1));
$datatree = $datatree = DataTree::getInstance();
//获取所有分类对象
$data_array = $datatree->getDataArray();
showSearchTPL($data_array);
if (empty($type_id)) {
    $type_id = array();
    $type_id[] = $datatree->getOneTreeNode()->type_id;
    //获取根节点的type_id
}
$result = ThreadWithType::getThreadSFun($type_id)[1];
//第二个参数为显示风格,0为panel显示风格,1为table显示风格
showThreadWithTable($result, 0);