$lmt) { $theText = substr($theText,0,$lmt); $theText = substr($theText,0,strrpos($theText,' ')); $trimmed = TRUE; } if ($trimmed) $theText .= '...'; return $theText; } function outputStory($article, $only_snippet=FALSE) { global $conn; if ($article) { $sql = "SELECT ar.*,usr.name " . "FROM cms_articles ar " . "LEFT OUTER JOIN cms_users usr " . "ON ar.author_id = usr.user_id " . "WHERE ar.article_id = " . $article; $result = mysql_query($sql,$conn); if ($row = mysql_fetch_array($result)) { echo '
\n"; echo nl2br(htmlspecialchars(trimBody($row['body']))); echo "
\n"; echo '\n"; echo nl2br(htmlspecialchars($row['body'])); echo "
\n"; } } } } function showComments($article,$showLink=TRUE) { global $conn; if ($article) { $sql = "SELECT is_published " . "FROM cms_articles " . "WHERE article_id=" . $article; $result = mysql_query($sql,$conn) or die('Could not look up comments; ' . mysql_error()); $row = mysql_fetch_array($result); $is_published = $row['is_published']; $sql = "SELECT co.*,usr.name,usr.e-mail " . "FROM cms_comments co " . "LEFT OUTER JOIN cms_users usr " . "ON co.comment_user = usr.user_id " . "WHERE co.article_id=" . $article . " ORDER BY co.comment_date DESC"; $result = mysql_query($sql,$conn) or die('Could not look up comments; ' . mysql_error()); if ($showLink) { echo '\n" . nl2br(htmlspecialchars($row['comment'])) . "\n
\n"; } echo "