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 | } |
||
492 | tom | 47 | |
48 | $args = array(0, $parentID, $page->getLoggedInUser()->ID, $title, $content, $category, 0); |
||
49 | $page->query("INSERT INTO BlogPosts VALUES(?, ?, ?, ?, ?, NOW(), ?, ?)", $args); |
||
169 | tom | 50 | $page->redirect('post.php?id=' . $parentID); |
51 | } |
||
52 | } |
||
53 | |||
54 | $page->drawHeader(); |
||
55 | $page->drawBlogCategoriesMenu(); |
||
56 | $page->drawMiddle(); |
||
57 | |||
58 | if (!empty($error)) |
||
59 | { |
||
60 | $page->drawError($error, false); |
||
61 | } |
||
62 | |||
63 | ?> |
||
64 | |||
65 | <form action="add-post.php?id=<?php echo getParentID(); ?>" method="post"> |
||
66 | <table> |
||
67 | <tr> |
||
68 | <td class="bold">Title: </td> |
||
69 | <td><input type="text" name="title" /></td> |
||
70 | </tr> |
||
71 | <tr> |
||
72 | <td class="bold">Content: </td> |
||
73 | <td><textarea name="content" style="width: 500px; height: 300px;"></textarea></td> |
||
74 | </tr> |
||
75 | <tr> |
||
76 | <td class="bold">Catagory: </td> |
||
77 | <td><input type="text" name="category" /></td> |
||
78 | </tr> |
||
79 | |||
80 | <input type="hidden" name="post" value="yes" /> |
||
81 | |||
82 | <?php |
||
83 | write('<input type="hidden" name="parentID" value="' . getParentID() . '" />'); |
||
84 | ?> |
||
85 | |||
86 | <tr> |
||
87 | <td class="bold"></td> |
||
88 | <td><input type="submit" value="Post" /></td> |
||
89 | </tr> |
||
90 | </table> |
||
91 | </form> |
||
92 | |||
93 | <?php |
||
94 | |||
95 | $page->drawFooter(); |
||
96 | |||
97 | ?> |