$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 '

' . htmlspecialchars($row['title']) . "

\n"; echo "
By: " . htmlspecialchars($row['name']) . "
"; echo "
"; if ($row['is_published'] == 1) { echo date("F j, Y",strtotime($row['date_published'])); } else { echo "not yet published"; } echo "
\n"; if ($only_snippet) { echo "

\n"; echo nl2br(htmlspecialchars(trimBody($row['body']))); echo "

\n"; echo '

Full Story...


\n"; } else { 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 '

' . mysql_num_rows($result) . 'Comments'; if (isset($_SESSION['user_id']) and $is_published) { echo ' / Add one'; } echo "

\n"; } if (mysql_num_rows($result)) { echo "
\n"; while ($row = mysql_fetch_array($result)) { echo "" . htmlspecialchars($row['name']) . " (" . date("l F j, Y H:i",strtotime($row['comment_date'])) . ")\n"; echo "

\n" . nl2br(htmlspecialchars($row['comment'])) . "\n

\n"; } echo "
\n"; } echo "
\n"; } } ?>