$lmt) { $theText = substr($theText, 0, $lmt); $theText = substr($theText, 0, strrpos($theText,' ')); $trimmed = TRUE; } if ($trimmed) $theText .= '...'; return $theText; } function msgBox($m, $t, $d="index.php", $s="Info") { $theMsg = "
"; $theMsg .= "

" . $t . "

\n"; $theMsg .= "

" . $m . "

"; $theMsg .= "

"; $theMsg .= "Yes"; $theMsg .= ""; $theMsg .= "No

"; $theMsg .= "
"; return $theMsg; } function getForum($id) { $sql = "SELECT forum_name as name, forum_desc as description, " . "forum_moderator as mod ". "FROM forum_forum ". "WHERE id = " . $id; $result = mysql_query($sql) or die(mysql_error() . "
" . $sql); $row = mysql_fetch_array($result); return $row; } function getForumID($topicid) { $sql = "SELECT forum_id FROM forum_posts WHERE id=$topicid"; $result = mysql_query($sql) or die(mysql_error() . "
" . $sql); $row = mysql_fetch_array($result); return $row['forum_id']; } function breadcrumb($id, $getfrom="F") { $sep = ""; $sep .= " · "; $sep .= ""; if ($getfrom == "P") { $sql = "SELECT forum_id, subject FROM forum_posts " . "WHERE id = " . $id; $result = mysql_query($sql) or die(mysql_error() . "
" . $sql); $row = mysql_fetch_array($result); $id = $row['forum_id']; $topic = $row['subject']; } $row = getForum($id); $bc = "Home$sep"; switch ($getfrom) { case "P": $bc .= "".$row['name'] . "$sep" . $topic; break; case "F": $bc .= $row['name']; break; } return "

" . $bc . "

"; } function showTopic($topicid, $showfull=TRUE) { global $conn; global $userid; global $limit; echo breadcrumb($topicid, "P"); if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } if ($limit == "") $limit = 25; $start = ($page - 1) * $limit; if (isset($_SESSION['user_id'])) { echo topicReplyBar($topicid, getForumID($topicid), "right"); } $sql = "SELECT SQL_CALC_FOUND_ROWS ". "p.id, p.subject, p.body, p.date_posted, " . "p.date_updated, u.name as author, u.id as author_id, " . "u.signature as sig, c.count as postcount, " . "p.forum_id as forum_id, f.forum_moderator as mod, " . "p.update_id, u2.name as updated_by " . "FROM forum_forum f " . "JOIN forum_posts p " . "ON f.id = p.forum_id " . "JOIN forum_users u " . "ON u.id = p.author_id " . "LEFT JOIN forum_users u2 " . "ON u2.id = p.update_id " . "LEFT JOIN forum_postcount c " . "ON u.id = c.user_id " . "WHERE (p.topic_id = $topicid OR p.id = $topicid) " . "ORDER BY p.topic_id, p.date_posted ". "LIMIT $start,$limit"; $result = mysql_query($sql, $conn) or die(mysql_error() . "
" . $sql); $pagelinks = paginate($limit); if (mysql_num_rows($result) == 0) { $msg = "There are currently no posts. Would you " . "like to be the first person to create a thread?"; $title = "No Posts..."; $dest = "compose.php?forumid=" . $forumid; $sev = "Info"; $message = msgBox($msg,$title,$dest,$sev); echo $message; } else { echo ""; echo ""; echo ""; echo ""; $rowclass = ""; while ($row = mysql_fetch_array($result)) { $lastupdate = ""; $editlink = ""; $dellink = ""; $replylink = " "; $pcount = ""; $pdate = ""; $sig = ""; if ($showfull) { $body = $row['body']; if (isset($_SESSION['user_id'])) { $replylink = "REPLY "; } else { $replylink = ""; } if ($row['update_id'] > 0) { $lastupdate = "

Last updated: " . $row['date_updated'] . " by " . $row['updated_by'] . "

"; } if (($userid == $row['author_id']) or ($userid == $row['mod']) or ($_SESSION['access_lvl'] > 2)) { $editlink = "EDIT "; $dellink = "DELETE "; } $pcount = "
Posts: " . ($row['postcount']==""?"0":$row['postcount']) . ""; $pdate = $row['date_posted']; $sig = ($row['sig'] != ""?"

". bbcode(nl2br($row['sig'])):"")."

"; } else { $body = trimBody($body); } $rowclass = ($rowclass == "row1"?"row2":"row1"); echo ""; echo ""; echo "\n"; } echo "
AuthorPost
" . $row['author']; echo $pcount; echo "

"; if (isset($_SESSION['user_id']) and ($_SESSION['last_login'] < $row['date_posted'])) { echo NEWPOST . " "; } if (isset($_GET['page'])) { $pagelink = "&page=" . $_GET['page']; } else { $pagelink = ""; } echo "".POSTLINK.""; if (isset($row['subject'])) { echo " " . $row['subject'] . ""; } echo "

" . bbcode(nl2br(htmlspecialchars($body))) . "

"; echo $sig; echo $lastupdate; echo "
"; echo $pdate . ""; echo $replylink; echo $editlink; echo $dellink; echo "
"; echo $pagelinks; echo "

".NEWPOST." = New Post     "; echo POSTLINK." = Post link (use to bookmark)

"; } } function isParent($page) { $currentpage = $_SERVER['PHP_SELF']; if (strpos($currentpage, $page) === false) { return FALSE; } else { return TRUE; } } function topicReplyBar($topicid,$forumid,$pos="right") { $html = "

"; if ($topicid > 0) { $html .= "Reply to Thread"; } if ($forumid > 0) { $html .= "New Thread"; } $html .= "

"; return $html; } function userOptionList($level) { $sql = "SELECT id, name, access_lvl " . "FROM forum_users " . "WHERE access_lvl=" . $level . " " . "ORDER BY name"; $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo ""; } } function paginate($limit=10) { global $admin; $sql = "SELECT FOUND_ROWS();"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result); $numrows = $row[0]; $pagelinks = "
"; if ($numrows > $limit) { if(isset($_GET['page'])){ $page = $_GET['page']; } else { $page = 1; } $currpage = $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']; $currpage = str_replace("&page=".$page,"",$currpage); if($page == 1){ $pagelinks .= "< PREV"; }else{ $pageprev = $page - 1; $pagelinks .= "< PREV"; } $numofpages = ceil($numrows / $limit); $range = $admin['pageRange']['value']; if ($range == "" or $range == 0) $range = 7; $lrange = max(1,$page-(($range-1)/2)); $rrange = min($numofpages,$page+(($range-1)/2)); if (($rrange - $lrange) < ($range - 1)) { if ($lrange == 1) { $rrange = min($lrange + ($range-1), $numofpages); } else { $lrange = max($rrange - ($range-1), 0); } } if ($lrange > 1) { $pagelinks .= ".."; } else { $pagelinks .= "  "; } for($i = 1; $i <= $numofpages; $i++){ if ($i == $page) { $pagelinks .= "$i"; } else { if ($lrange <= $i and $i <= $rrange) { $pagelinks .= "" . $i . ""; } } } if ($rrange < $numofpages) { $pagelinks .= ".."; } else { $pagelinks .= "  "; } if(($numrows - ($limit * $page)) > 0){ $pagenext = $page + 1; $pagelinks .= "NEXT >"; } else { $pagelinks .= "NEXT >"; } } else { $pagelinks .= "< " . "PREV  "; $pagelinks .= " " . "NEXT >  "; } $pagelinks .= "
"; return $pagelinks; } function bbcode($data) { $sql = "SELECT * FROM forum_bbcode"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) { $bbcode['tpl'][] = "/" . html_entity_decode($row['template'],ENT_QUOTES). "/i"; $bbcode['rep'][] = html_entity_decode($row['replacement'],ENT_QUOTES); } $data1 = preg_replace($bbcode['tpl'],$bbcode['rep'],$data); $count = 1; while (($data1 != $data) and ($count < 4)) { $count++; $data = $data1; $data1 = preg_replace($bbcode['tpl'],$bbcode['rep'],$data); } } return $data; } ?>