<?php
if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
function sethighlight($string) {
	$colorarray = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
	$string = sprintf('%02d', $string);
	$stylestr = sprintf('%03b', $string[0]);
	$highlight = ' style="';
	$highlight .= $stylestr[0] ? 'font-weight: bold;' : '';
	$highlight .= $stylestr[1] ? 'font-style: italic;' : '';
	$highlight .= $stylestr[2] ? 'text-decoration: underline;' : '';
	$highlight .= $string[1] ? 'color: '.$colorarray[$string[1]].';' : '';
	$highlight .= '"';
	return $highlight;
}
function thread_list_query($sql) {
	global $_G, $thread_list; $objarray = array();
	$query = DB::query($sql);
	while($result = DB::fetch($query)) {
		$result['view_subject'] = cutstr($result['subject'], $thread_list['subject_length']);
		$result['name'] = strip_tags($result['name']);
		$result['date'] = gmdate('m-d/H:i', $result['dateline'] + $_G['setting']['timeoffset'] * 3600);
		$result['retime'] = gmdate('m-d/H:i', $result['lastpost'] + ($_G['setting']['timeoffset'] * 3600));
		$result['authors'] = cutstr($result['author'], $thread_list['ahthor_nums']);
		$result['highlight'] = ($result['highlight'] && $thread_list['highlight']) ? sethighlight($result['highlight']) : '';
		$objarray[] = $result;
	}
	unset($sql, $query, $result);
	return $objarray;
}
?>
