// if user has level of 9 or more then they can edit any article
if ($GLOBALS["userLevel"] >= 9) {
$canmanage = true;
$canedit = true;
//echo "canedit, level=" . $GLOBALS["userLevel"] . "
";
} else {
$canmanage = false;
$canedit = false;
//echo "cannot edit, level=" . $GLOBALS["userLevel"] . "
";
}
if (isset($_REQUEST['postid'])) {
$postid = $_REQUEST['postid'];
} else {
$postid = 0;
}
$resultSet = getBlogPosts($canmanage);
//print_r($resultSet);
$htmloutput = "";
if (count($resultSet) > 0) {
foreach ($resultSet as $post) {
if ($post['postvisible'] == 1) {
$articleHideButtonTxt = "Hide";
} else {
$articleHideButtonTxt = "Show";
}
if ($post['postdeleted'] == 1) {
$articleDeleteButtonTxt = "UnDelete";
} else {
$articleDeleteButtonTxt = "Delete";
}
$htmloutput = $htmloutput . '
';
$htmloutput = $htmloutput . '
';
$htmloutput = $htmloutput . '
';
if ($canmanage) {
$htmloutput = $htmloutput . '
';
}
$htmloutput = $htmloutput . formatForDisplay($post['posttitle'],true);
if ($canmanage) {
$htmloutput = $htmloutput . '
';
$htmloutput = $htmloutput . '
';
$htmloutput = $htmloutput . '
';
$htmloutput = $htmloutput . '
[ edit ]';
$htmloutput = $htmloutput . '';
}
$htmloutput = $htmloutput . '
';
$htmloutput = $htmloutput . '
(posted by: ' . $post['userName'] . ' | ' . formatDate($post['postdatetime'],'d M Y') . ')
';
$htmloutput = $htmloutput . '
' . formatForDisplay($post['postbody'],true) . '
';
$htmloutput = $htmloutput . '
';
}
}
$GLOBALS["pagetitle"]= formatForDisplay("Black Toddadder's Commentary Box");
$year = substr($articleDetails['publication_date'], 0, 4);
if ($articleDetails['visible'] == "Yes") {
updateViewCount($articleid);
}
function updateViewCount($articleid) {
$db =& new BaseDatabaseClass('db');
$sql = "update articles set views = (" . $articleDetails['views'] + 1 . ") where articleid = $articleid";
$db->query($sql);
}
function getBlogPosts($canmanage) {
if ($canmanage) {
$whereclause = "";
} else {
$whereclause = "WHERE blogPosts.postvisible=1";
}
$db =& new BaseDatabaseClass('db');
$sql = "SELECT *,
(Select blogusername from blogUsers where blogUsers.bloguserid = blogPosts.bloguserid ) AS userName
FROM blogPosts
$whereclause
Order By postdatetime DESC";
$db->query($sql);
$resultSet = $db->data;
return $resultSet;
}
?>

[ add ]';
} ?>