Subversion Repositories taios

Compare Revisions

Ignore whitespace Rev 168 → Rev 169

/blog/add-post.php
1,91 → 1,96
<?php
 
function getParentID()
{
if (isset($_GET['id']))
{
return $_GET['id'];
}
else
{
return -1;
}
}
 
require '../_taios.php';
 
$page = new Taios_Page('Blog Posts', '../');
$page->checkLoggedIn();
 
$error = '';
 
if (isset($_POST['post']))
{
$title = $_POST['title'];
$content = $_POST['content'];
$parentID = $_POST['parentID'];
$category = $_POST['category'];
 
if (empty($title))
{
$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('post.php?id=' . $parentID);
}
}
 
$page->drawHeader();
$page->drawBlogCategoriesMenu();
$page->drawMiddle();
 
if (!empty($error))
{
$page->drawError($error, false);
}
 
?>
 
<form action="add-post.php?id=<?php echo getParentID(); ?>" method="post">
<table>
<tr>
<td class="bold">Title: </td>
<td><input type="text" name="title" /></td>
</tr>
<tr>
<td class="bold">Content: </td>
<td><textarea name="content" style="width: 500px; height: 300px;"></textarea></td>
</tr>
<tr>
<td class="bold">Catagory: </td>
<td><input type="text" name="category" /></td>
</tr>
 
<input type="hidden" name="post" value="yes" />
 
<?php
write('<input type="hidden" name="parentID" value="' . getParentID() . '" />');
?>
 
<tr>
<td class="bold"></td>
<td><input type="submit" value="Post" /></td>
</tr>
</table>
</form>
 
<?php
 
$page->drawFooter();
 
?>
<?php
 
function getParentID()
{
if (isset($_GET['id']))
{
return $_GET['id'];
}
else
{
return -1;
}
}
 
require '../_taios.php';
 
$page = new Taios_Page('Blog Posts', '../');
$page->checkLoggedIn();
 
$error = '';
 
if (isset($_POST['post']))
{
$title = $_POST['title'];
$content = $_POST['content'];
$parentID = $_POST['parentID'];
$category = $_POST['category'];
 
if (empty($title))
{
$error = "No Title Specified";
}
else if (empty($content))
{
$error = "No Content Specified";
}
else if (empty($parentID))
{
$error = "No Parent ID Specified";
}
else
{
if ($page->isUserNormal($page->getLoggedInUser()) && $parentID == -1)
{
$page->drawError('You do not have permission to access this page.');
}
$page->query('INSERT INTO BlogPosts VALUES(0, ' . $parentID . ', "' . $page->getLoggedInUser()->ID . '", "' . $title . '", "' . $content . '", NOW(), "' . $category . '", 0)');
$page->redirect('post.php?id=' . $parentID);
}
}
 
$page->drawHeader();
$page->drawBlogCategoriesMenu();
$page->drawMiddle();
 
if (!empty($error))
{
$page->drawError($error, false);
}
 
?>
 
<form action="add-post.php?id=<?php echo getParentID(); ?>" method="post">
<table>
<tr>
<td class="bold">Title: </td>
<td><input type="text" name="title" /></td>
</tr>
<tr>
<td class="bold">Content: </td>
<td><textarea name="content" style="width: 500px; height: 300px;"></textarea></td>
</tr>
<tr>
<td class="bold">Catagory: </td>
<td><input type="text" name="category" /></td>
</tr>
 
<input type="hidden" name="post" value="yes" />
 
<?php
write('<input type="hidden" name="parentID" value="' . getParentID() . '" />');
?>
 
<tr>
<td class="bold"></td>
<td><input type="submit" value="Post" /></td>
</tr>
</table>
</form>
 
<?php
 
$page->drawFooter();
 
?>
/blog/edit-post.php
4,12 → 4,18
 
$page = new Taios_Page('Blog Posts', '../');
 
if (!isset($_GET['id']))
if (isset($_GET['id']))
{
$id = $_GET['id'];
else if (!isset($_POST['id']))
}
else if (isset($_POST['id']))
{
$id = $_POST['id'];
}
else
$page->redirect("index.php");
{
$page->drawError('No ID set.');
}
 
$page->checkLoggedIn();
 
37,7 → 43,7
}
else
{
// $page->query('update table BlogPosts set Content="' . $content . '", Title="' . $title . '", Category="' . $category . '" where ID=' . $id);
$page->query('UPDATE BlogPosts SET Content = "' . $content . '", Title = "' . $title . '", Category = "' . $category . '" WHERE ID = ' . $id);
$page->redirect('index.php');
}
}
53,7 → 59,7
 
?>
 
<form action="add-post.php?id=<?php echo getParentID(); ?>" method="post">
<form action="edit-post.php" method="post">
<table>
<tr>
<td class="bold">Title: </td>
69,7 → 75,7
</tr>
 
<?php
write('<input type="hidden" name="is" value="' . $id . '" />');
write('<input type="hidden" name="id" value="' . $id . '" />');
?>
 
<tr>