Rev 180 | Rev 484 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
169 | tom | 1 | <?php |
2 | |||
3 | function getParentID() |
||
4 | { |
||
5 | if (isset($_GET['id'])) |
||
6 | { |
||
7 | return $_GET['id']; |
||
8 | } |
||
9 | else |
||
10 | { |
||
11 | return -1; |
||
12 | } |
||
13 | } |
||
14 | |||
15 | require '../_taios.php'; |
||
16 | |||
176 | tom | 17 | $page = new Taios_Page('Add Post', '../'); |
169 | tom | 18 | $page->checkLoggedIn(); |
19 | |||
20 | $error = ''; |
||
21 | |||
22 | if (isset($_POST['post'])) |
||
23 | { |
||
24 | $title = $_POST['title']; |
||
25 | $content = $_POST['content']; |
||
26 | $parentID = $_POST['parentID']; |
||
27 | $category = $_POST['category']; |
||
28 | |||
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 | { |
||
471 | muzer | 43 | if (($page->getLoggedInUser()->accessID >= 2 && $parentID == -1) || $page->getLoggedInUser()->accessID > 2) |
169 | tom | 44 | { |
45 | $page->drawError('You do not have permission to access this page.'); |
||
46 | } |
||
47 | |||
48 | $page->query('INSERT INTO BlogPosts VALUES(0, ' . $parentID . ', "' . $page->getLoggedInUser()->ID . '", "' . $title . '", "' . $content . '", NOW(), "' . $category . '", 0)'); |
||
49 | $page->redirect('post.php?id=' . $parentID); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | $page->drawHeader(); |
||
54 | $page->drawBlogCategoriesMenu(); |
||
55 | $page->drawMiddle(); |
||
56 | |||
57 | if (!empty($error)) |
||
58 | { |
||
59 | $page->drawError($error, false); |
||
60 | } |
||
61 | |||
62 | ?> |
||
63 | |||
64 | <form action="add-post.php?id=<?php echo getParentID(); ?>" method="post"> |
||
65 | <table> |
||
66 | <tr> |
||
67 | <td class="bold">Title: </td> |
||
68 | <td><input type="text" name="title" /></td> |
||
69 | </tr> |
||
70 | <tr> |
||
71 | <td class="bold">Content: </td> |
||
72 | <td><textarea name="content" style="width: 500px; height: 300px;"></textarea></td> |
||
73 | </tr> |
||
74 | <tr> |
||
75 | <td class="bold">Catagory: </td> |
||
76 | <td><input type="text" name="category" /></td> |
||
77 | </tr> |
||
78 | |||
79 | <input type="hidden" name="post" value="yes" /> |
||
80 | |||
81 | <?php |
||
82 | write('<input type="hidden" name="parentID" value="' . getParentID() . '" />'); |
||
83 | ?> |
||
84 | |||
85 | <tr> |
||
86 | <td class="bold"></td> |
||
87 | <td><input type="submit" value="Post" /></td> |
||
88 | </tr> |
||
89 | </table> |
||
90 | </form> |
||
91 | |||
92 | <?php |
||
93 | |||
94 | $page->drawFooter(); |
||
95 | |||
96 | ?> |