<?php
define('THIS_SCRIPT', 'indivgroup');
require_once 'global.php';
include_once $fsetting['manageurl'].'inc/page.class.php';
$lang = load_lang($lang, 'indivgroup' );
global $title_num,$action,$reaction,$membername;
include_once CACHE_PATH.'board/board_all.php';
$board_settings = $_DCACHE['forum_settings'][$fsetting['indivgroup_set']]['setting'];
include_once INC_PATH.'DV_Encoding.class.php';
$objenc =& DV_Encoding::GetEncoding($charset);

$title_num = array(0=>array('linktitle'=>$lang['template.strings0'],'linkurl'=>'indivgroup.php'),1=>array('linktitle'=>$lang['template.strings1']));

if(!empty($membername))
	$mygrouplink= '<a href="?action=mygrouplist">'.$lang['template.strings2'].'</a>';
else
	$mygrouplink='';

if($fsetting['indivgroup_show'] == 0)
{
	head(1,0,0,$title_num,$mygrouplink);
	showmsg($lang['error_close']);
	footer();
}

head(1,0,0,$title_num,$mygrouplink);// print head;
group_list();
footer();

function group_list(){
	global $dv,$db,$lang,$page,$total,$page_size,$offset,$page_count,$p,$userid,$membername,$boardmaster,$board_settings,$objenc;

	$colorstr = array('','','red','blue','green');

	$query2=$db->query("Select /*!40001 SQL_CACHE */ topicid,groupid,boardid,title,postusername,postuserid,dateandtime,child,hits,lastpost,lastposttime,istop,isbest,locktopic,expression,mode,topicmode From {$dv}group_topic Where boardid<>-1 Order By lastposttime Desc Limit 10");

	$result = false;
	while( true ){
		$result = $db->fetch_array($query2);
		if( $result === false ){
			break;
		}

		$result['istop'] = 0;

		$result['title'] = ChkBadWords($result['title']);
		$result['locktopic'] = htmlspecialchars($result['title']);
		if( $result['topicmode'] == 0 ){
			$result['topicmode'] = '';
		}elseif($result['topicmode'] > 1){
			$result['topicmode'] = ' style="color:' .$colorstr[$result['topicmode']]. ';"';
		}elseif($result['topicmode'] == 1){//暂时关闭html
		}else{
			$result['topicmode'] = '';
		}
		
		$_infolength = $objenc->StrLength($result['title']);
		if ( $_infolength > $board_settings[59]){
			$result['title'] = $objenc->SubString(strip_tags($result['title']), 0, $board_settings[59]).'...';
		}

		if($board_settings[65] && $timestamp - $result['dateandtime'] < $board_settings[64] * 60) {
			$result['newsign'] = '<img src="'.$board_settings[65].'" />';
		} else {
			$result['newsign'] = '';
		}
		$_topics[] = $result;
	}

	//最新群组信息
	if (file_exists(CACHE_PATH.'Forum_Group_top.php')){
		include_once INC_PATH.'DV_Encoding.class.php';
		$objenc =& DV_Encoding::GetEncoding($charset);
		include_once CACHE_PATH.'Forum_Group_top.php';
	}

	require_once printout('indivgroup');
}

?>