Subversion Repositories taios

Rev

Rev 131 | Rev 169 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
100 freddie 1
<?php
2
 
127 tom 3
function getParentID()
4
{
5
    if (isset($_GET['id']))
6
    {
7
        return $_GET['id'];
8
    }
9
    else
10
    {
11
        return -1;
12
    }
13
}
14
 
100 freddie 15
require '../_taios.php';
16
 
17
$page = new Taios_Page('Blog Posts', '../');
132 tom 18
$page->checkLoggedIn();
100 freddie 19
 
120 tom 20
$error = '';
103 freddie 21
 
128 tom 22
if (isset($_POST['post']))
23
{
24
    $title = $_POST['title'];
25
    $content = $_POST['content'];
26
    $parentID = $_POST['parentID'];
27
    $category = $_POST['category'];
120 tom 28
 
128 tom 29
    if (empty($title))
30
    {
31
        $error = "No Title Specified";
32
    }
33
    else if (empty($content))
34
    {
35
        $error = "No Content Specified";
36
    }
37
    else if (empty($parentID))
38
    {
39
        $error = "No Parent ID Specified";
40
    }
41
    else
42
    {
43
        $page->query('INSERT INTO BlogPosts VALUES(0, ' . $parentID . ', "' . $page->getLoggedInUser()->ID . '", "' . $title . '", "' . $content . '", NOW(), "' . $category . '", 0)');
44
        $page->redirect('index.php');
45
    }
120 tom 46
}
100 freddie 47
 
48
$page->drawHeader();
49
$page->drawBlogCategoriesMenu();
50
$page->drawMiddle();
51
 
126 tom 52
if (!empty($error))
53
{
54
    $page->drawError($error, false);
55
}
56
 
100 freddie 57
?>
58
 
131 tom 59
<form action="add-post.php?id=<?php echo getParentID(); ?>" method="post">
100 freddie 60
<table>
61
<tr>
62
<td class="bold">Title: </td>
63
<td><input type="text" name="title" /></td>
64
</tr>
65
<tr>
66
<td class="bold">Content: </td>
124 tom 67
<td><textarea name="content" style="width: 500px; height: 300px;"></textarea></td>
100 freddie 68
</tr>
69
<tr>
70
<td class="bold">Catagory: </td>
120 tom 71
<td><input type="text" name="category" /></td>
100 freddie 72
</tr>
73
 
128 tom 74
<input type="hidden" name="post" value="yes" />
75
 
100 freddie 76
<?php
128 tom 77
write('<input type="hidden" name="parentID" value="' . getParentID() . '" />');
100 freddie 78
?>
79
 
80
<tr>
81
<td class="bold"></td>
82
<td><input type="submit" value="Post" /></td>
83
</tr>
84
</table>
85
</form>
86
 
87
<?php
88
 
89
$page->drawFooter();
90
 
91
?>