query_first("SELECT COUNT(postid) FROM bgb".$n."_posts WHERE visible = 1"); $totalposts=$result[0]; // no posts -> forward to addentry page if($totalposts==0) { header("Location: addentry.php"); exit; } // get userfields $pages=ceil($totalposts/$perpage); if($page>$pages) $page=$pages; $count=0; $fieldids = array(); $result=$db->query("SELECT fieldid, title FROM bgb".$n."_fieldsettings ORDER BY displayorder ASC"); while($row=$db->fetch_array($result)) { $fieldids[$count]=$row['fieldid']; $fieldtitles[$count]=$row['title']; $count++; } // get postids $postids=""; $result=$db->query("SELECT postid FROM bgb".$n."_posts WHERE visible = 1 ORDER BY posttime ".(($displayorder) ? ("ASC") : ("DESC"))." LIMIT ".($page-1)*$perpage.",".$perpage); while($row=$db->fetch_array($result)) $postids.=",".$row['postid']; // read posts $result=$db->query(" SELECT bgb".$n."_posts.*, bgb".$n."_fields.*, bgb".$n."_icons.* FROM bgb".$n."_posts LEFT JOIN bgb".$n."_fields ON (bgb".$n."_fields.postid=bgb".$n."_posts.postid) LEFT JOIN bgb".$n."_icons ON (bgb".$n."_icons.iconid=bgb".$n."_posts.iconid) WHERE bgb".$n."_posts.postid IN (0".$postids.") ORDER BY posttime ".(($displayorder) ? ("ASC") : ("DESC"))); $postbit = ""; $count = (($displayorder) ? (($page-1)*$perpage) : ($totalposts +1 - ($page-1)*$perpage)); while($post=$db->fetch_array($result)) { $icons=""; $fields=""; if($displayorder==1) $count++; else $count--; if($count % 2) $tableid="tablea"; else $tableid="tableb"; // userfields for($i=0;$iget("index_fields")."\";"); } // format date $posttime = formatdate($timeformat,$post['posttime']); // icon if($post['iconid'] && $allowicons) $icon=makeimgtag("images/icons/icon-".$post['iconid'].".".$post['iconextension'],$post['icontitle'])."
"; else $icon=""; // parse message $post['message']=parse(stripslashes($post['message']), $post['nosmilies']); // parse comment if($post['comment']) { $post['comment']=parse(stripslashes($post['comment']), $post['comment_nosmilies']); $commenttime = formatdate($timeformat,$post['commenttime']); eval ("\$commentrow = \"".$template->get("index_commentrow")."\";"); } else $commentrow = ""; if(isset($post['email'])) { $post['email'] = mailaddy2ASCII(htmlconverter(stripslashes($post['email']))); } else $post['email'] = ''; $post['homepage'] = htmlconverter(stripslashes($post['homepage'])); $post['icq'] = intval($post['icq']); $post['aim'] = htmlconverter(stripslashes($post['aim'])); $post['yim'] = htmlconverter(stripslashes($post['yim'])); $post['msn'] = htmlconverter(stripslashes($post['msn'])); if($post['email'] && $allowemail==1) eval ("\$icons .= \"".$template->get("index_iconsemail")."\";"); if($post['homepage'] && $allowhomepage==1) eval ("\$icons .= \"".$template->get("index_iconshomepage")."\";"); if($post['icq'] && $allowicq==1) eval ("\$icons .= \"".$template->get("index_iconsicq")."\";"); if($post['aim'] && $allowaim==1) eval ("\$icons .= \"".$template->get("index_iconsaim")."\";"); if($post['yim'] && $allowyim==1) eval ("\$icons .= \"".$template->get("index_iconsyim")."\";"); if($post['msn'] && $allowmsn==1) eval ("\$icons .= \"".$template->get("index_iconsmsn")."\";"); $post['authorname'] = htmlconverter(stripslashes($post['authorname'])); $post['authorname'] = textwrap($post['authorname'], 25); eval ("\$postbit .= \"".$template->get("index_postbit")."\";"); } // pagelinks $priorpage = ""; $pagelink = ""; $nextpage = ""; if($pages>1) { if($page>1) { $prior=$page-1; eval ("\$priorpage = \"".$template->get("index_priorpage")."\";"); } $pagelink = makepagelink("index.php",$page,$pages); if($page<$pages) { $next=$page+1; eval ("\$nextpage = \"".$template->get("index_nextpage")."\";"); } } eval("\$template->output(\"".$template->get("index")."\");"); ?>