require_once('./ini/common.php');
require_once('./lib/widget/'.$CONF['widget'].'/WidgetThread.php');
$widget = new WidgetThread($CONF['widget']);
echo $widget->getCommonHeader();
$TID = PreVar::getVar('TID','GET');
$FID = PreVar::getVar('FID','GET');
$numCurrentPage = PreVar::getVar('p','GET');
if($TID == '' || $FID == '' ){
echo $widget->getError('使い方が間違っています。');
echo $widget->getCommonFooter();
exit;
}
$sql = 'select f.name, m.subject from
'.$DBCONF['tableForum'].' AS f, '.$DBCONF['tableMessage'].' as m
where f.fid = '.$FID.' and m.tid = '.$TID;
$resultThread = $db->query($sql);
if(!$resultThread->numRows()){
echo $widget->getError('エラーが発生しました。使い方が間違っています。');
echo $widget->getCommonFooter();
exit;
}
$numTotalMessage = $resultThread->numRows();
$rowThread = $resultThread->fetchRow(DB_FETCHMODE_ASSOC);
$resultThread->free();
$numTotalPage = ((int) (($numTotalMessage - 1)/ $CONF['nummessage'])) + 1;
// increment view count. if p is set, don't increment.
if($numCurrentPage == ''){
$sql = 'update '.$DBCONF['tableThread'].' set view = (view + 1) where TID = '.$TID;
$resultUpdate = $db->query($sql);
if(DB::isError($resultUpdate)){
echo $resultUpdate->getMessage();
exit;
}
}
if($numCurrentPage == '' || $numCurrentPage == '1'){
$start = 0;
$numCurrentPage = 1;
} else {
$start = ($numCurrentPage - 1) * $CONF['nummessage'];
}
$widget->setVar('title',$CONF['boardtitle']);
$widget->setVar('FID',$FID);
$widget->setVar('TID',$TID);
$widget->setVar('numCurrentPage',$numCurrentPage);
$widget->setVar('numTotalPage',$numTotalPage);
$widget->setVar('threadSubject',$rowThread['subject']);
$widget->setVar('forumName',$rowThread['name']);
echo $widget->getHeader();
//検索時の該当文字ハイライト
$focus = PreVar::getVar('focus','GET');
if( !empty($focus) ){
$focusArr = explode(' ',$focus);
}
$sql = 'select mid, date, name, mail, company, homepage, subject, comment from '.$DBCONF['tableMessage'].' where TID = '.$TID.' order by date';
$resultMessage = $db->limitQuery($sql, $start, $CONF['nummessage']);
//c,色を交互に変えるカウンタ
$counter = 1;
while($rowMessage = $resultMessage->fetchRow(DB_FETCHMODE_ASSOC)){
$date = contime($rowMessage['date']);
$comment = $rowMessage['comment'];
if( isset($focusArr) ){
for($i = count($focusArr); $i > 0; $i-- ){
$comment = eregi_replace( quotemeta($focusArr[$i-1]), ''.$focusArr[$i-1].'',$comment);
}
reset($focusArr);
}
$comment = linkurl($comment);
($counter % 2) ? $cssClass = 'class=col2' : $cssClass = 'class=col1';
if($rowMessage['mail'] == ''){
$author = $rowMessage['name'];
}else{
$author = ''.$rowMessage['name'].'';
}
if($rowMessage['Icon']){
$icon = '
';
} else {
$icon = '';
}
if($CONF['allowpass']){
$modString = '編集';
} else {
$modString = '';
}
if ( $rowMessage['homepage'] != '') {
$homepage = "".$rowMessage['homepage']."
";
} else {
$homepage = '';
}
echo $widget->getMessageBox($rowMessage['mid'],$cssClass,$author,$date,$icon,$modString,$rowMessage['subject'],$comment,$rowMessage['company'],$homepage);
$counter++;
}
echo $widget->getFooter();
echo $widget->getCommonFooter();
?>