getCommonHeader(); $FID = PreVar::getVar('FID','GET'); $numCurrentPage = PreVar::getVar('p','GET'); $maxThreadNum = (int)PreVar::getVar('thnum','GET'); if($maxThreadNum == '' || !$maxThreadNum ){ $maxThreadNum = 20; } if($FID == ''){ echo $widget->getError('使い方が間違っています。'); echo $widget->getCommonFooter(); exit; } //フォーラムが実在しているかチェックして、実在していれば //フォーラム表示用ヘッダを表示させる。 $resultForum = $db->query('select name from '.$DBCONF['tableForum'].' where fid = '.$FID); if(!$resultForum->numRows()){ echo $widget->getError('スレッドがまだ存在しません。'); echo $widget->getCommonFooter(); exit; } $rowForum = $resultForum->fetchRow(DB_FETCHMODE_ASSOC); $resultForum->free(); if(!$numCurrentPage || $numCurrentPage == '1'){ $start = 0; $numCurrentPage = 1; } else { $start = ($numCurrentPage - 1) * $maxThreadNum; } $resultNum = $db->query('select count(*) as num from '.$DBCONF['tableThread'].' where fid = '.$FID); $numTotalPage = ((int) ( ( array_pop( $resultNum->fetchRow() ) - 1) / $maxThreadNum)) + 1; $widget->setVar('title',$CONF['boardtitle']); $widget->setVar('forumName',$rowForum['name']); $widget->setVar('FID',$FID); $widget->setVar('thnum',$maxThreadNum); $widget->setVar('numTotalPage',$numTotalPage); $widget->setVar('numCurrentPage',$numCurrentPage); echo $widget->getHeader(); //スレッドを取得し表示させる $sql = "select m.name, m.subject, m.tid, t.view, t.moddate from ".$DBCONF['tableMessage']." AS m, ".$DBCONF['tableThread']." AS t where m.parent = '1' and t.tid = m.tid and t.fid = $FID order by t.moddate desc"; $resultThread = $db->limitQuery($sql,$start,$maxThreadNum); if(!$resultThread->numRows()){ echo $widget->getNoForumBox(); }else{ while($rowThread = $resultThread->fetchRow(DB_FETCHMODE_ASSOC)){ $sql = "select * from ".$DBCONF['tableMessage']." where tid = '".$rowThread['tid']."'"; $resultReply = $db->query($sql); $numReply = $resultReply->numRows() - 1; if($lastTimeStamp != -1){ if( strtotime($lastTimeStamp) < strtotime($rowThread['moddate']) ){ $icon = './img/thread_box_new.gif'; }else{ $icon = './img/thread_box.gif'; } }else{ $icon = './img/thread_box.gif'; } $date = contime($rowThread['moddate']); echo $widget->getForumBox($rowThread['tid'],$rowThread['subject'],$numReply,$rowThread['view'],$rowThread['name'],$date,$icon); } } echo $widget->getFooter(); echo $widget->getCommonFooter(); ?>