/blog/add-post.php |
---|
4,12 → 4,28 |
$page = new Taios_Page('Blog Posts', '../'); |
if (!$page->isUserGM($page->getLoggedInUser())) |
$page->redirect("index.php"); |
$error = ''; |
if (isset($_POST['title']) && isset($_POST['content']) && isset($_POST['catagory']) && isset($_POST['parentID'])) |
$title = $_POST['title']; |
$content = $_POST['content']; |
$parentID = $_POST['parentID']; |
$category = $_POST['category']; |
if (empty($title)) |
{ |
$page->query('insert into BlogPosts VALUES(0, ' . $_POST['parentID'] . ', "' . $page->getLoggedInUser()->ID . '", "' . $_POST['title'] . '", "' . $_POST['content'] . '", NOW(), "' . $_POST['catagory'] . '", 0)'); |
$error = "No Title Specified"; |
} |
else if (empty($content)) |
{ |
$error = "No Content Specified"; |
} |
else if (empty($parentID)) |
{ |
$error = "No Parent ID Specified"; |
} |
else |
{ |
$page->query('INSERT INTO BlogPosts VALUES(0, ' . $parentID . ', "' . $page->getLoggedInUser()->ID . '", "' . $title . '", "' . $content . '", NOW(), "' . $category . '", 0)'); |
$page->redirect('index.php'); |
} |
17,15 → 33,9 |
$page->drawBlogCategoriesMenu(); |
$page->drawMiddle(); |
if ($page->isUserGM($page->getLoggedInUser())) |
{ |
write('<p class="bold"><a href="add-post.php">Add Post</a></p>'); |
write('<br />'); |
} |
?> |
<form action="add-post.php" method="post"> |
<form action="post-add.php" method="post"> |
<table> |
<tr> |
<td class="bold">Title: </td> |
33,11 → 43,11 |
</tr> |
<tr> |
<td class="bold">Content: </td> |
<td><textarea name="content" style="width: 523px; height: 543px">Content Here</textarea></td> |
<td><textarea name="content" style="width: 600xp; height: 400px;"></textarea></td> |
</tr> |
<tr> |
<td class="bold">Catagory: </td> |
<td><input type="text" name="catagory" /></td> |
<td><input type="text" name="category" /></td> |
</tr> |
<?php |
/blog/post.php |
---|
4,17 → 4,11 |
$page = new Taios_Page('Blog Posts', '../'); |
if (!isset($_GET['id']) || $_GET['id'] == "" || $_GET['id'] == -1) |
$page->redirect('index.php'); |
if (!isset($_GET['id'])) |
$page->redirect("index.php"); |
$page->drawHeader(); |
$page->drawBlogCategoriesMenu(); |
$page->drawMiddle(); |
$page->drawBlogPostTree($_GET['id'], true); |
$page->drawBlogPostTree($page->getGetID(), true); |
$page->drawFooter(); |
/blog/del-post.php |
---|
2,10 → 2,26 |
require '../_taios.php'; |
$page = new Taios_Page('Blog Posts', '../'); |
$page = new Taios_Page('Delete Blog Post', '../'); |
if (!$page->isUserAdmin($page->getLoggedInUser())) |
$page->delBlogPost($_GET['id']); |
$page->redirect("index.php"); |
$id = $_GET['id']; |
if ($id) |
{ |
if ($page->isUserAdmin($page->getLoggedInUser()) || $page->getLoggedInUser()->ID == $page->getBlogPost($id)->author->ID) |
{ |
$page->delBlogPost($id); |
} |
else |
{ |
$page->drawError('You do not have permission to access this page.'); |
} |
} |
else |
{ |
$page->drawError('No ID Specified'); |
} |
$page->redirect('index.php'); |
?> |
/blog/index.php |
---|
26,9 → 26,11 |
{ |
$id = $ids[$i]; |
$post = $page->getBlogPost($id); |
write('<a href="post.php?id=' . $id . '"><h3>' . $post->title. '</h3></a>'); |
write('<h5 style="color: #666666;">Posted On ' . date('l j F Y', $post->datePosted) . ' by ' . $post->user->name . ' (' . $post->user->username . ')</h5>'); |
write('<p>' . $post->content . '</p>'); |
write('<br />'); |
} |
/_taios.php |
---|
125,8 → 125,8 |
if ($this->isUserNormal($this->getLoggedInUser())) |
{ |
echo '<p class="bold"><a href="add-post.php?id=' . $id . '">Add Comment</a>'; |
if ($this->isUserAdmin($this->getLoggedInUser())) |
echo ' $middot <a href="del-post.php?id=' . $id . '">Delete Post</a>'; |
if ($this->isUserAdmin($this->getLoggedInUser()) || $this->getLoggedInUser() == $post->author->ID) |
echo ' · <a href="del-post.php?id=' . $id . '">Delete Post</a>'; |
write('</p><br />'); |
} |