diff options
author | Nicolas BERNSTEIN <alexis211@gmail.com> | 2012-02-12 19:50:55 +0100 |
---|---|---|
committer | Nicolas BERNSTEIN <alexis211@gmail.com> | 2012-02-12 19:50:55 +0100 |
commit | 24547ccec6526fcef3cccb34bc35fb81f31236b3 (patch) | |
tree | fc908fb06a6b8b4d4131c7303c4fb3b7d348f9bf /lib/blog/post.php | |
parent | cd76af42463bd80539db8c9671a427a9f0fe5d69 (diff) | |
download | Bits-24547ccec6526fcef3cccb34bc35fb81f31236b3.tar.gz Bits-24547ccec6526fcef3cccb34bc35fb81f31236b3.zip |
A lot of changes : blogging system essentially.
Diffstat (limited to 'lib/blog/post.php')
-rw-r--r-- | lib/blog/post.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/blog/post.php b/lib/blog/post.php new file mode 100644 index 0000000..1f1525a --- /dev/null +++ b/lib/blog/post.php @@ -0,0 +1,44 @@ +<?php + +require("lib/markdown.php"); + +$post_title = ""; +$post_tags = ""; +$post_text = ""; +if (isset($_POST['title']) && isset($_POST['text'])) { + $post_title = esca($_POST['title']); + $post_text = esca($_POST['text']); + $post_tags = esca($_POST['tags']); + $post_html = Markdown($post_text); + + if ($post_title == "") { + $error = "You must give a title to your post."; + } else { + sql("INSERT INTO blog_posts(owner, title, text, text_html, date, draft) ". + "VALUE(" . $user['id'] . ", '" . escs($post_title) . "', '" . escs($post_text) . "', '" . escs($post_html) . + "', NOW(), 1)"); + $id = mysql_insert_id(); + $tags = explode(' ', $post_tags); + if (count($tags) == 1 && $tags[0] == "") { + //do nothing lol + } else if (count($tags) >= 1) { + $v = array(); + foreach ($tags as $tag) { + $v[] = "($id, '" . escs($tag) . "')"; + } + sql("INSERT INTO blog_tags(post, tag) VALUES " . implode(',', $v)); + } + header("Location: drafts-blog"); + die(); + } +} + +$title = "Post to blog"; +$fields = array( + array("label" => "Title : ", "name" => "title", "value" => $post_title), + array("label" => "Tags ", "name" => "tags", "type" => "text", "value" => $post_tags), + array("label" => "Text : ", "name" => "text", "type" => "textarea", "value" => $post_text), + ); +$validate = "Post entry"; + +require("tpl/general/form.php"); |