From dd6942e439ac449204193d297a57e2649141516a Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Mon, 20 Jul 2015 00:30:03 +0700 Subject: [PATCH] Content Type Trying to add content type: image, video, audio, link, and quote. No styling yet. --- system/admin/admin.php | 870 ++++++++++++++++++++++++++++++- system/admin/views/add-audio.html.php | 130 +++++ system/admin/views/add-image.html.php | 130 +++++ system/admin/views/add-link.html.php | 130 +++++ system/admin/views/add-page.html.php | 2 +- system/admin/views/add-post.html.php | 7 - system/admin/views/add-quote.html.php | 130 +++++ system/admin/views/add-video.html.php | 130 +++++ system/admin/views/content-type.html.php | 9 + system/admin/views/edit-audio.html.php | 167 ++++++ system/admin/views/edit-image.html.php | 167 ++++++ system/admin/views/edit-link.html.php | 167 ++++++ system/admin/views/edit-page.html.php | 16 +- system/admin/views/edit-post.html.php | 9 +- system/admin/views/edit-quote.html.php | 167 ++++++ system/admin/views/edit-video.html.php | 167 ++++++ system/htmly.php | 540 ++++++++++++++++++- system/includes/functions.php | 10 +- themes/clean/css/style.css | 4 +- themes/clean/main.html.php | 19 +- themes/clean/post.html.php | 35 +- themes/default/css/style.css | 4 +- themes/default/main.html.php | 19 +- themes/default/post.html.php | 35 +- themes/logs/css/style.css | 4 +- themes/logs/main.html.php | 15 + themes/logs/post.html.php | 33 +- 27 files changed, 3011 insertions(+), 105 deletions(-) create mode 100644 system/admin/views/add-audio.html.php create mode 100644 system/admin/views/add-image.html.php create mode 100644 system/admin/views/add-link.html.php create mode 100644 system/admin/views/add-quote.html.php create mode 100644 system/admin/views/add-video.html.php create mode 100644 system/admin/views/content-type.html.php create mode 100644 system/admin/views/edit-audio.html.php create mode 100644 system/admin/views/edit-image.html.php create mode 100644 system/admin/views/edit-link.html.php create mode 100644 system/admin/views/edit-quote.html.php create mode 100644 system/admin/views/edit-video.html.php diff --git a/system/admin/admin.php b/system/admin/admin.php index b46eea1..a55a445 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -86,7 +86,7 @@ function remove_accent($str) } // Edit blog posts -function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $img, $vid, $revertPost, $publishDraft) +function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $revertPost, $publishDraft) { $oldurl = explode('_', $oldfile); $dir = explode('/', $oldurl[0]); @@ -97,8 +97,6 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, } $post_title = $title; - $post_img = $img; - $post_vid = str_replace(array("http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"), "", $vid); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); $post_tag = rtrim($post_tag, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); @@ -106,18 +104,578 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $post_description = "\n"; } else { $post_description = ""; + } + $post_content = '' . $post_description ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + if(!empty($revertPost) || !empty($publishDraft)) { + + $dirBlog = $dir[0] . '/' . $dir[1] . '/blog/'; + $dirDraft = $dir[0] . '/' . $dir[1] . '/draft/'; + + if($dir[2] == 'draft') { + $filename = $dirBlog . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } else { + $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } + + if (is_dir($dirBlog)) { + } else { + mkdir($dirBlog, 0775, true); + } + + if (is_dir($dirDraft)) { + } else { + mkdir($dirDraft, 0775, true); + } + + file_put_contents($filename, print_r($post_content, true)); + unlink($oldfile); + $newfile = $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + + } else { + + $newfile = $oldurl[0] . '_' . $post_tag . '_' . $post_url . '.md'; + + if ($oldfile === $newfile) { + file_put_contents($oldfile, print_r($post_content, true)); + } else { + rename($oldfile, $newfile); + file_put_contents($newfile, print_r($post_content, true)); + } + + } + + if(!empty($publishDraft)) { + $dt = $olddate; + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } else { + $replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; + $dt = str_replace($replaced, '', $oldurl[0]); + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } + + // The post date + $postdate = strtotime($timestamp); + + // The post URL + $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; + + rebuilt_cache('all'); + clear_post_cache($dt, $post_tag, $post_url, $newfile); + if ($destination == 'post') { + if(!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + header("Location: $posturl"); + } + } else { + if(!empty($publishDraft)) { + header("Location: $posturl"); + } elseif (!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + $redirect = site_url() . $destination; + header("Location: $redirect"); + } + } + } +} + +// Edit image posts +function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $image, $revertPost, $publishDraft) +{ + $oldurl = explode('_', $oldfile); + $dir = explode('/', $oldurl[0]); + $olddate = date('Y-m-d-h-i-s', strtotime($date)); + + if ($date !== null) { + $oldurl[0] = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/' . $olddate; + } + + $post_title = $title; + $post_image = $image; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; + } else { + $post_description = ""; + } + if ($image !== null) { + $post_image = "\n"; + } else { + $post_image = ""; + } + $post_content = '' . $post_description . $post_image ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + if(!empty($revertPost) || !empty($publishDraft)) { + + $dirBlog = $dir[0] . '/' . $dir[1] . '/blog/'; + $dirDraft = $dir[0] . '/' . $dir[1] . '/draft/'; + + if($dir[2] == 'draft') { + $filename = $dirBlog . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } else { + $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } + + if (is_dir($dirBlog)) { + } else { + mkdir($dirBlog, 0775, true); + } + + if (is_dir($dirDraft)) { + } else { + mkdir($dirDraft, 0775, true); + } + + file_put_contents($filename, print_r($post_content, true)); + unlink($oldfile); + $newfile = $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + + } else { + + $newfile = $oldurl[0] . '_' . $post_tag . '_' . $post_url . '.md'; + + if ($oldfile === $newfile) { + file_put_contents($oldfile, print_r($post_content, true)); + } else { + rename($oldfile, $newfile); + file_put_contents($newfile, print_r($post_content, true)); + } + + } + + if(!empty($publishDraft)) { + $dt = $olddate; + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } else { + $replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; + $dt = str_replace($replaced, '', $oldurl[0]); + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } + + // The post date + $postdate = strtotime($timestamp); + + // The post URL + $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; + + rebuilt_cache('all'); + clear_post_cache($dt, $post_tag, $post_url, $newfile); + if ($destination == 'post') { + if(!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + header("Location: $posturl"); + } + } else { + if(!empty($publishDraft)) { + header("Location: $posturl"); + } elseif (!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + $redirect = site_url() . $destination; + header("Location: $redirect"); + } + } + } +} + +// Edit video posts +function edit_video($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $video, $revertPost, $publishDraft) +{ + $oldurl = explode('_', $oldfile); + $dir = explode('/', $oldurl[0]); + $olddate = date('Y-m-d-h-i-s', strtotime($date)); + + if ($date !== null) { + $oldurl[0] = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/' . $olddate; + } + + $post_title = $title; + $post_video = $video; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; + } else { + $post_description = ""; + } + if ($video !== null) { + $post_video = "\n"; + } else { + $post_video = ""; + } + $post_content = '' . $post_description . $post_video ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + if(!empty($revertPost) || !empty($publishDraft)) { + + $dirBlog = $dir[0] . '/' . $dir[1] . '/blog/'; + $dirDraft = $dir[0] . '/' . $dir[1] . '/draft/'; + + if($dir[2] == 'draft') { + $filename = $dirBlog . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } else { + $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } + + if (is_dir($dirBlog)) { + } else { + mkdir($dirBlog, 0775, true); + } + + if (is_dir($dirDraft)) { + } else { + mkdir($dirDraft, 0775, true); + } + + file_put_contents($filename, print_r($post_content, true)); + unlink($oldfile); + $newfile = $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + + } else { + + $newfile = $oldurl[0] . '_' . $post_tag . '_' . $post_url . '.md'; + + if ($oldfile === $newfile) { + file_put_contents($oldfile, print_r($post_content, true)); + } else { + rename($oldfile, $newfile); + file_put_contents($newfile, print_r($post_content, true)); + } + + } + + if(!empty($publishDraft)) { + $dt = $olddate; + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } else { + $replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; + $dt = str_replace($replaced, '', $oldurl[0]); + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } + + // The post date + $postdate = strtotime($timestamp); + + // The post URL + $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; + + rebuilt_cache('all'); + clear_post_cache($dt, $post_tag, $post_url, $newfile); + if ($destination == 'post') { + if(!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + header("Location: $posturl"); + } + } else { + if(!empty($publishDraft)) { + header("Location: $posturl"); + } elseif (!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + $redirect = site_url() . $destination; + header("Location: $redirect"); + } + } + } +} + +// Edit image posts +function edit_link($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $link, $revertPost, $publishDraft) +{ + $oldurl = explode('_', $oldfile); + $dir = explode('/', $oldurl[0]); + $olddate = date('Y-m-d-h-i-s', strtotime($date)); + + if ($date !== null) { + $oldurl[0] = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/' . $olddate; + } + + $post_title = $title; + $post_link = $link; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; + } else { + $post_description = ""; + } + if ($link !== null) { + $post_link = "\n"; + } else { + $post_link = ""; + } + $post_content = '' . $post_description . $post_link ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + if(!empty($revertPost) || !empty($publishDraft)) { + + $dirBlog = $dir[0] . '/' . $dir[1] . '/blog/'; + $dirDraft = $dir[0] . '/' . $dir[1] . '/draft/'; + + if($dir[2] == 'draft') { + $filename = $dirBlog . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } else { + $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } + + if (is_dir($dirBlog)) { + } else { + mkdir($dirBlog, 0775, true); + } + + if (is_dir($dirDraft)) { + } else { + mkdir($dirDraft, 0775, true); + } + + file_put_contents($filename, print_r($post_content, true)); + unlink($oldfile); + $newfile = $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + + } else { + + $newfile = $oldurl[0] . '_' . $post_tag . '_' . $post_url . '.md'; + + if ($oldfile === $newfile) { + file_put_contents($oldfile, print_r($post_content, true)); + } else { + rename($oldfile, $newfile); + file_put_contents($newfile, print_r($post_content, true)); + } + + } + + if(!empty($publishDraft)) { + $dt = $olddate; + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } else { + $replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; + $dt = str_replace($replaced, '', $oldurl[0]); + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } + + // The post date + $postdate = strtotime($timestamp); + + // The post URL + $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; + + rebuilt_cache('all'); + clear_post_cache($dt, $post_tag, $post_url, $newfile); + if ($destination == 'post') { + if(!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + header("Location: $posturl"); + } + } else { + if(!empty($publishDraft)) { + header("Location: $posturl"); + } elseif (!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + $redirect = site_url() . $destination; + header("Location: $redirect"); + } + } + } +} + +// Edit quote posts +function edit_quote($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $quote, $revertPost, $publishDraft) +{ + $oldurl = explode('_', $oldfile); + $dir = explode('/', $oldurl[0]); + $olddate = date('Y-m-d-h-i-s', strtotime($date)); + + if ($date !== null) { + $oldurl[0] = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/' . $olddate; + } + + $post_title = $title; + $post_quote = $quote; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; + } else { + $post_description = ""; + } + if ($quote !== null) { + $post_quote = "\n"; + } else { + $post_quote = ""; + } + $post_content = '' . $post_description . $post_quote ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + if(!empty($revertPost) || !empty($publishDraft)) { + + $dirBlog = $dir[0] . '/' . $dir[1] . '/blog/'; + $dirDraft = $dir[0] . '/' . $dir[1] . '/draft/'; + + if($dir[2] == 'draft') { + $filename = $dirBlog . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } else { + $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + } + + if (is_dir($dirBlog)) { + } else { + mkdir($dirBlog, 0775, true); + } + + if (is_dir($dirDraft)) { + } else { + mkdir($dirDraft, 0775, true); + } + + file_put_contents($filename, print_r($post_content, true)); + unlink($oldfile); + $newfile = $olddate . '_' . $post_tag . '_' . $post_url . '.md'; + + } else { + + $newfile = $oldurl[0] . '_' . $post_tag . '_' . $post_url . '.md'; + + if ($oldfile === $newfile) { + file_put_contents($oldfile, print_r($post_content, true)); + } else { + rename($oldfile, $newfile); + file_put_contents($newfile, print_r($post_content, true)); + } + + } + + if(!empty($publishDraft)) { + $dt = $olddate; + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } else { + $replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; + $dt = str_replace($replaced, '', $oldurl[0]); + $t = str_replace('-', '', $dt); + $time = new DateTime($t); + $timestamp = $time->format("Y-m-d"); + } + + // The post date + $postdate = strtotime($timestamp); + + // The post URL + $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; + + rebuilt_cache('all'); + clear_post_cache($dt, $post_tag, $post_url, $newfile); + if ($destination == 'post') { + if(!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + header("Location: $posturl"); + } + } else { + if(!empty($publishDraft)) { + header("Location: $posturl"); + } elseif (!empty($revertPost)) { + $drafturl = site_url() . 'admin/draft'; + header("Location: $drafturl"); + } else { + $redirect = site_url() . $destination; + header("Location: $redirect"); + } + } + } +} + +// Edit audio posts +function edit_audio($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $audio, $revertPost, $publishDraft) +{ + $oldurl = explode('_', $oldfile); + $dir = explode('/', $oldurl[0]); + $olddate = date('Y-m-d-h-i-s', strtotime($date)); + + if ($date !== null) { + $oldurl[0] = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/' . $olddate; } - if ($img !== null) { - $post_img = "\n"; + + $post_title = $title; + $post_audio = $audio; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; } else { - $post_img = ""; + $post_description = ""; } - if ($vid !== null) { - $post_vid = "\n"; + if ($audio !== null) { + $post_audio = "\n"; } else { - $post_vid = ""; - } - $post_content = '' . $post_description . $post_img . $post_vid ."\n\n" . $content; + $post_audio = ""; + } + $post_content = '' . $post_description . $post_audio ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -244,14 +802,231 @@ function edit_page($title, $url, $content, $oldfile, $destination = null, $descr } } -// Add blog post -function add_post($title, $tag, $url, $content, $user, $description = null, $img, $vid, $draft) +// Add post +function add_post($title, $tag, $url, $content, $user, $description = null, $draft) +{ + + $post_date = date('Y-m-d-H-i-s'); + $post_title = $title; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; + } else { + $post_description = ""; + } + $post_content = '' . $post_description ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + $filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md'; + + if (empty($draft)) { + $dir = 'content/' . $user . '/blog/'; + } else { + $dir = 'content/' . $user . '/draft/'; + } + + if (is_dir($dir)) { + file_put_contents($dir . $filename, print_r($post_content, true)); + } else { + mkdir($dir, 0775, true); + file_put_contents($dir . $filename, print_r($post_content, true)); + } + + rebuilt_cache('all'); + clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename); + + if (empty($draft)) { + $redirect = site_url() . 'admin/mine'; + } else { + $redirect = site_url() . 'admin/draft'; + } + + header("Location: $redirect"); + } +} + +// Add image +function add_image($title, $tag, $url, $content, $user, $description = null, $image, $draft) +{ + + $post_date = date('Y-m-d-H-i-s'); + $post_title = $title; + $post_image = $image; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; + } else { + $post_description = ""; + } + if ($image !== null) { + $post_image = "\n"; + } else { + $post_image = ""; + } + $post_content = '' . $post_description . $post_image ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + $filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md'; + + if (empty($draft)) { + $dir = 'content/' . $user . '/blog/'; + } else { + $dir = 'content/' . $user . '/draft/'; + } + + if (is_dir($dir)) { + file_put_contents($dir . $filename, print_r($post_content, true)); + } else { + mkdir($dir, 0775, true); + file_put_contents($dir . $filename, print_r($post_content, true)); + } + + rebuilt_cache('all'); + clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename); + + if (empty($draft)) { + $redirect = site_url() . 'admin/mine'; + } else { + $redirect = site_url() . 'admin/draft'; + } + + header("Location: $redirect"); + } +} + +// Add video +function add_video($title, $tag, $url, $content, $user, $description = null, $video, $draft) +{ + + $post_date = date('Y-m-d-H-i-s'); + $post_title = $title; + $post_video = $video; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; + } else { + $post_description = ""; + } + if ($video !== null) { + $post_video = "\n"; + } else { + $post_video = ""; + } + $post_content = '' . $post_description . $post_video ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + $filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md'; + + if (empty($draft)) { + $dir = 'content/' . $user . '/blog/'; + } else { + $dir = 'content/' . $user . '/draft/'; + } + + if (is_dir($dir)) { + file_put_contents($dir . $filename, print_r($post_content, true)); + } else { + mkdir($dir, 0775, true); + file_put_contents($dir . $filename, print_r($post_content, true)); + } + + rebuilt_cache('all'); + clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename); + + if (empty($draft)) { + $redirect = site_url() . 'admin/mine'; + } else { + $redirect = site_url() . 'admin/draft'; + } + + header("Location: $redirect"); + } +} + +// Add audio +function add_audio($title, $tag, $url, $content, $user, $description = null, $audio, $draft) +{ + + $post_date = date('Y-m-d-H-i-s'); + $post_title = $title; + $post_audio = $audio; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; + } else { + $post_description = ""; + } + if ($audio !== null) { + $post_audio = "\n"; + } else { + $post_audio = ""; + } + $post_content = '' . $post_description . $post_audio ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + $filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md'; + + if (empty($draft)) { + $dir = 'content/' . $user . '/blog/'; + } else { + $dir = 'content/' . $user . '/draft/'; + } + + if (is_dir($dir)) { + file_put_contents($dir . $filename, print_r($post_content, true)); + } else { + mkdir($dir, 0775, true); + file_put_contents($dir . $filename, print_r($post_content, true)); + } + + rebuilt_cache('all'); + clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename); + + if (empty($draft)) { + $redirect = site_url() . 'admin/mine'; + } else { + $redirect = site_url() . 'admin/draft'; + } + + header("Location: $redirect"); + } +} + +// Add link +function add_link($title, $tag, $url, $content, $user, $description = null, $link, $draft) { $post_date = date('Y-m-d-H-i-s'); $post_title = $title; - $post_img = $img; - $post_vid = str_replace(array("http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"), "", $vid); + $post_link = $link; $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); $post_tag = rtrim($post_tag, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); @@ -260,17 +1035,68 @@ function add_post($title, $tag, $url, $content, $user, $description = null, $img } else { $post_description = ""; } - if ($img !== null) { - $post_img = "\n"; + if ($link !== null) { + $post_link = "\n"; + } else { + $post_link = ""; + } + $post_content = '' . $post_description . $post_link ."\n\n" . $content; + + if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + + if (get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + + $filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md'; + + if (empty($draft)) { + $dir = 'content/' . $user . '/blog/'; + } else { + $dir = 'content/' . $user . '/draft/'; + } + + if (is_dir($dir)) { + file_put_contents($dir . $filename, print_r($post_content, true)); + } else { + mkdir($dir, 0775, true); + file_put_contents($dir . $filename, print_r($post_content, true)); + } + + rebuilt_cache('all'); + clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename); + + if (empty($draft)) { + $redirect = site_url() . 'admin/mine'; + } else { + $redirect = site_url() . 'admin/draft'; + } + + header("Location: $redirect"); + } +} + +// Add quote +function add_quote($title, $tag, $url, $content, $user, $description = null, $quote, $draft) +{ + + $post_date = date('Y-m-d-H-i-s'); + $post_title = $title; + $post_quote = $quote; + $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); + $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); + if ($description !== null) { + $post_description = "\n"; } else { - $post_img = ""; + $post_description = ""; } - if ($vid !== null) { - $post_vid = "\n"; + if ($quote !== null) { + $post_quote = "\n"; } else { - $post_vid = ""; + $post_quote = ""; } - $post_content = '' . $post_description . $post_img . $post_vid ."\n\n" . $content; + $post_content = '' . $post_description . $post_quote ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { diff --git a/system/admin/views/add-audio.html.php b/system/admin/views/add-audio.html.php new file mode 100644 index 0000000..e2f944e --- /dev/null +++ b/system/admin/views/add-audio.html.php @@ -0,0 +1,130 @@ + + + + + + + + + + + +
+ +
+
+ Title *


+ Tag *


+ Url (optional)

+ If the url leave empty we will use the post title.

+ Meta Description (optional)
+

+ Featured Audio * (SoundCloud Only)


+
+
+ + +
+
+
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/admin/views/add-image.html.php b/system/admin/views/add-image.html.php new file mode 100644 index 0000000..ea64f78 --- /dev/null +++ b/system/admin/views/add-image.html.php @@ -0,0 +1,130 @@ + + + + + + + + + + + +
+ +
+
+ Title *


+ Tag *


+ Url (optional)

+ If the url leave empty we will use the post title.

+ Meta Description (optional)
+

+ Featured Image *


+
+
+ + +
+
+
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/admin/views/add-link.html.php b/system/admin/views/add-link.html.php new file mode 100644 index 0000000..4f278bf --- /dev/null +++ b/system/admin/views/add-link.html.php @@ -0,0 +1,130 @@ + + + + + + + + + + + +
+ +
+
+ Title *


+ Tag *


+ Url (optional)

+ If the url leave empty we will use the post title.

+ Meta Description (optional)
+

+ Featured Link *


+
+
+ + +
+
+
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/admin/views/add-page.html.php b/system/admin/views/add-page.html.php index db8f0e8..2e4f14e 100644 --- a/system/admin/views/add-page.html.php +++ b/system/admin/views/add-page.html.php @@ -27,7 +27,7 @@ Meta Description (optional)
-
+

+

+ Featured Quote *


+
+
+ + + + +
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/admin/views/add-video.html.php b/system/admin/views/add-video.html.php new file mode 100644 index 0000000..7ad36ff --- /dev/null +++ b/system/admin/views/add-video.html.php @@ -0,0 +1,130 @@ + + + + + + + + + + + +
+ +
+
+ Title *


+ Tag *


+ Url (optional)

+ If the url leave empty we will use the post title.

+ Meta Description (optional)
+

+ Featured Video * (YouTube Only)


+
+
+ + +
+
+
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/admin/views/content-type.html.php b/system/admin/views/content-type.html.php new file mode 100644 index 0000000..c905e1f --- /dev/null +++ b/system/admin/views/content-type.html.php @@ -0,0 +1,9 @@ +

Add content

+ +

Regular post
Creating regular blog post.

+

Image post
Creating blog post with featured image.

+

Video post
Creating blog post with featured video.

+

Audio post
Creating blog post with featured audio.

+

Link post
Creating blog post with featured link.

+

Quote post
Creating blog post with fetaured quote.

+

Static page
Creating static page.

\ No newline at end of file diff --git a/system/admin/views/edit-audio.html.php b/system/admin/views/edit-audio.html.php new file mode 100644 index 0000000..632fabf --- /dev/null +++ b/system/admin/views/edit-audio.html.php @@ -0,0 +1,167 @@ +file)) { + $url = $p->file; +} else { + $url = $oldfile; +} + +$content = file_get_contents($url); +$oldtitle = get_content_tag('t', $content, 'Untitled'); +$olddescription = get_content_tag('d', $content); +$oldaudio = get_content_tag('audio', $content); +$oldcontent = remove_html_comments($content); + +$dir = substr($url, 0, strrpos($url, '/')); +$isdraft = explode('/', $dir); +$oldurl = explode('_', $url); + +$oldtag = $oldurl[1]; + +$oldmd = str_replace('.md', '', $oldurl[2]); + +if (isset($_GET['destination'])) { + $destination = $_GET['destination']; +} else { + $destination = 'admin'; +} +$replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; +$dt = str_replace($replaced, '', $oldurl[0]); +$t = str_replace('-', '', $dt); +$time = new DateTime($t); +$timestamp = $time->format("Y-m-d"); +// The post date +$postdate = strtotime($timestamp); +// The post URL +$delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; + + +?> + + + + + + + + + + + +
+ +
+
+ Title *


+ Tag *


+ Url (optional)

+ If the url leave empty we will use the post title.

+ Date Time



+ Meta Description (optional)
+

+ Featured Audio * (SoundCloud Only)


+
+
+ + + + + Delete + + Delete + +
+
+
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/admin/views/edit-image.html.php b/system/admin/views/edit-image.html.php new file mode 100644 index 0000000..aa17ccc --- /dev/null +++ b/system/admin/views/edit-image.html.php @@ -0,0 +1,167 @@ +file)) { + $url = $p->file; +} else { + $url = $oldfile; +} + +$content = file_get_contents($url); +$oldtitle = get_content_tag('t', $content, 'Untitled'); +$olddescription = get_content_tag('d', $content); +$oldimage = get_content_tag('image', $content); +$oldcontent = remove_html_comments($content); + +$dir = substr($url, 0, strrpos($url, '/')); +$isdraft = explode('/', $dir); +$oldurl = explode('_', $url); + +$oldtag = $oldurl[1]; + +$oldmd = str_replace('.md', '', $oldurl[2]); + +if (isset($_GET['destination'])) { + $destination = $_GET['destination']; +} else { + $destination = 'admin'; +} +$replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; +$dt = str_replace($replaced, '', $oldurl[0]); +$t = str_replace('-', '', $dt); +$time = new DateTime($t); +$timestamp = $time->format("Y-m-d"); +// The post date +$postdate = strtotime($timestamp); +// The post URL +$delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; + + +?> + + + + + + + + + + + +
+ +
+
+ Title *


+ Tag *


+ Url (optional)

+ If the url leave empty we will use the post title.

+ Date Time



+ Meta Description (optional)
+

+ Featured Image *


+
+
+ + + + + Delete + + Delete + +
+
+
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/admin/views/edit-link.html.php b/system/admin/views/edit-link.html.php new file mode 100644 index 0000000..2b8f924 --- /dev/null +++ b/system/admin/views/edit-link.html.php @@ -0,0 +1,167 @@ +file)) { + $url = $p->file; +} else { + $url = $oldfile; +} + +$content = file_get_contents($url); +$oldtitle = get_content_tag('t', $content, 'Untitled'); +$olddescription = get_content_tag('d', $content); +$oldlink = get_content_tag('link', $content); +$oldcontent = remove_html_comments($content); + +$dir = substr($url, 0, strrpos($url, '/')); +$isdraft = explode('/', $dir); +$oldurl = explode('_', $url); + +$oldtag = $oldurl[1]; + +$oldmd = str_replace('.md', '', $oldurl[2]); + +if (isset($_GET['destination'])) { + $destination = $_GET['destination']; +} else { + $destination = 'admin'; +} +$replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; +$dt = str_replace($replaced, '', $oldurl[0]); +$t = str_replace('-', '', $dt); +$time = new DateTime($t); +$timestamp = $time->format("Y-m-d"); +// The post date +$postdate = strtotime($timestamp); +// The post URL +$delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; + + +?> + + + + + + + + + + + +
+ +
+
+ Title *


+ Tag *


+ Url (optional)

+ If the url leave empty we will use the post title.

+ Date Time



+ Meta Description (optional)
+

+ Featured Link *


+
+
+ + + + + Delete + + Delete + +
+
+
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/admin/views/edit-page.html.php b/system/admin/views/edit-page.html.php index b27ca73..42f56e0 100644 --- a/system/admin/views/edit-page.html.php +++ b/system/admin/views/edit-page.html.php @@ -7,6 +7,7 @@ if (isset($p->file)) { } $content = file_get_contents($url); $oldtitle = get_content_tag('t', $content, 'Untitled'); +$olddescription = get_content_tag('d', $content); $oldcontent = remove_html_comments($content); if (isset($_GET['destination'])) { @@ -18,7 +19,17 @@ $dir = substr($url, 0, strrpos($url, '/')); $oldurl = str_replace($dir . '/', '', $url); $oldmd = str_replace('.md', '', $oldurl); -$delete = $p->url . '/delete?destination=' . $destination; +if (isset($p->url)) { + $delete = $p->url . '/delete?destination=' . $destination; +} +else { + if(empty($sub)) { + $delete = site_url() . $oldmd . '/delete?destination=' . $destination; + } + else { + $delete = site_url() . $static .'/'. $sub . '/delete?destination=' . $destination; + } +} ?> @@ -46,9 +57,8 @@ $delete = $p->url . '/delete?destination=' . $destination; If the url leave empty we will use the page title.

Meta Description (optional)
+ } else {echo $olddescription;}?>

-
+ } else { echo $olddescription;} ?>

- Featured Image (optional)


- Embed Youtube Video (optional)


-

+ diff --git a/system/admin/views/edit-quote.html.php b/system/admin/views/edit-quote.html.php new file mode 100644 index 0000000..87d7c21 --- /dev/null +++ b/system/admin/views/edit-quote.html.php @@ -0,0 +1,167 @@ +file)) { + $url = $p->file; +} else { + $url = $oldfile; +} + +$content = file_get_contents($url); +$oldtitle = get_content_tag('t', $content, 'Untitled'); +$olddescription = get_content_tag('d', $content); +$oldquote = get_content_tag('quote', $content); +$oldcontent = remove_html_comments($content); + +$dir = substr($url, 0, strrpos($url, '/')); +$isdraft = explode('/', $dir); +$oldurl = explode('_', $url); + +$oldtag = $oldurl[1]; + +$oldmd = str_replace('.md', '', $oldurl[2]); + +if (isset($_GET['destination'])) { + $destination = $_GET['destination']; +} else { + $destination = 'admin'; +} +$replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; +$dt = str_replace($replaced, '', $oldurl[0]); +$t = str_replace('-', '', $dt); +$time = new DateTime($t); +$timestamp = $time->format("Y-m-d"); +// The post date +$postdate = strtotime($timestamp); +// The post URL +$delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; + + +?> + + + + + + + + + + + +
+ +
+
+ Title *


+ Tag *


+ Url (optional)

+ If the url leave empty we will use the post title.

+ Date Time



+ Meta Description (optional)
+

+ Featured Quote *


+
+
+ + + + + Delete + + Delete + +
+
+
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/admin/views/edit-video.html.php b/system/admin/views/edit-video.html.php new file mode 100644 index 0000000..ffc9381 --- /dev/null +++ b/system/admin/views/edit-video.html.php @@ -0,0 +1,167 @@ +file)) { + $url = $p->file; +} else { + $url = $oldfile; +} + +$content = file_get_contents($url); +$oldtitle = get_content_tag('t', $content, 'Untitled'); +$olddescription = get_content_tag('d', $content); +$oldvideo = get_content_tag('video', $content); +$oldcontent = remove_html_comments($content); + +$dir = substr($url, 0, strrpos($url, '/')); +$isdraft = explode('/', $dir); +$oldurl = explode('_', $url); + +$oldtag = $oldurl[1]; + +$oldmd = str_replace('.md', '', $oldurl[2]); + +if (isset($_GET['destination'])) { + $destination = $_GET['destination']; +} else { + $destination = 'admin'; +} +$replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; +$dt = str_replace($replaced, '', $oldurl[0]); +$t = str_replace('-', '', $dt); +$time = new DateTime($t); +$timestamp = $time->format("Y-m-d"); +// The post date +$postdate = strtotime($timestamp); +// The post URL +$delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; + + +?> + + + + + + + + + + + +
+ +
+
+ Title *


+ Tag *


+ Url (optional)

+ If the url leave empty we will use the post title.

+ Date Time



+ Meta Description (optional)
+

+ Featured Video * (YouTube Only)


+
+
+ + + + + Delete + + Delete + +
+
+
+

URL

+ +

Upload

+
+ +
+ +
+
+ \ No newline at end of file diff --git a/system/htmly.php b/system/htmly.php index 61482bd..4791886 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -251,8 +251,6 @@ post('/add/post', function () { $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); $title = from($_REQUEST, 'title'); - $img = from($_REQUEST, 'img'); - $vid = from($_REQUEST, 'vid'); $tag = from($_REQUEST, 'tag'); $url = from($_REQUEST, 'url'); $content = from($_REQUEST, 'content'); @@ -261,10 +259,10 @@ post('/add/post', function () { $draft = from($_REQUEST, 'draft'); if ($proper && !empty($title) && !empty($tag) && !empty($content)) { if (!empty($url)) { - add_post($title, $tag, $url, $content, $user, $description, $img, $vid, $draft); + add_post($title, $tag, $url, $content, $user, $description, $draft); } else { $url = $title; - add_post($title, $tag, $url, $content, $user, $description, $img, $vid, $draft); + add_post($title, $tag, $url, $content, $user, $description, $draft); } } else { $message['error'] = ''; @@ -287,8 +285,6 @@ post('/add/post', function () { 'canonical' => site_url(), 'error' => '', 'postTitle' => $title, - 'postImg' => $img, - 'postVid' => $vid, 'postTag' => $tag, 'postUrl' => $url, 'postContent' => $content, @@ -298,6 +294,376 @@ post('/add/post', function () { } }); +// Show the "Add image" page +get('/add/image', function () { + + if (login()) { + + config('views.root', 'system/admin/views'); + + render('add-image', array( + 'title' => 'Add image - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'bodyclass' => 'addimage', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add image' + )); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Submitted add image data +post('/add/image', function () { + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + + $title = from($_REQUEST, 'title'); + $image = from($_REQUEST, 'image'); + $tag = from($_REQUEST, 'tag'); + $url = from($_REQUEST, 'url'); + $content = from($_REQUEST, 'content'); + $description = from($_REQUEST, 'description'); + $user = $_SESSION[config("site.url")]['user']; + $draft = from($_REQUEST, 'draft'); + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) { + if (!empty($url)) { + add_image($title, $tag, $url, $content, $user, $description, $image, $draft); + } else { + $url = $title; + add_image($title, $tag, $url, $content, $user, $description, $image, $draft); + } + } else { + $message['error'] = ''; + if (empty($title)) { + $message['error'] .= '
  • Title field is required.
  • '; + } + if (empty($tag)) { + $message['error'] .= '
  • Tag field is required.
  • '; + } + if (empty($content)) { + $message['error'] .= '
  • Content field is required.
  • '; + } + if (empty($image)) { + $message['error'] .= '
  • Image field is required.
  • '; + } + if (!$proper) { + $message['error'] .= '
  • CSRF Token not correct.
  • '; + } + config('views.root', 'system/admin/views'); + render('add-post', array( + 'title' => 'Add post- ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postImage' => $image, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'bodyclass' => 'addpost', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add post' + )); + } +}); + +// Show the "Add video" page +get('/add/video', function () { + + if (login()) { + + config('views.root', 'system/admin/views'); + + render('add-video', array( + 'title' => 'Add video - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'bodyclass' => 'addvideo', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add video' + )); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Submitted add video data +post('/add/video', function () { + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + + $title = from($_REQUEST, 'title'); + $video = from($_REQUEST, 'video'); + $tag = from($_REQUEST, 'tag'); + $url = from($_REQUEST, 'url'); + $content = from($_REQUEST, 'content'); + $description = from($_REQUEST, 'description'); + $user = $_SESSION[config("site.url")]['user']; + $draft = from($_REQUEST, 'draft'); + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) { + if (!empty($url)) { + add_video($title, $tag, $url, $content, $user, $description, $video, $draft); + } else { + $url = $title; + add_video($title, $tag, $url, $content, $user, $description, $video, $draft); + } + } else { + $message['error'] = ''; + if (empty($title)) { + $message['error'] .= '
  • Title field is required.
  • '; + } + if (empty($tag)) { + $message['error'] .= '
  • Tag field is required.
  • '; + } + if (empty($content)) { + $message['error'] .= '
  • Content field is required.
  • '; + } + if (empty($video)) { + $message['error'] .= '
  • Video field is required.
  • '; + } + if (!$proper) { + $message['error'] .= '
  • CSRF Token not correct.
  • '; + } + config('views.root', 'system/admin/views'); + render('add-video', array( + 'title' => 'Add post- ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postVideo' => $video, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'bodyclass' => 'addvideo', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add video' + )); + } +}); + +// Show the "Add link" page +get('/add/link', function () { + + if (login()) { + + config('views.root', 'system/admin/views'); + + render('add-link', array( + 'title' => 'Add video - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'bodyclass' => 'addlink', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add link' + )); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Submitted add link data +post('/add/link', function () { + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + + $title = from($_REQUEST, 'title'); + $link = from($_REQUEST, 'link'); + $tag = from($_REQUEST, 'tag'); + $url = from($_REQUEST, 'url'); + $content = from($_REQUEST, 'content'); + $description = from($_REQUEST, 'description'); + $user = $_SESSION[config("site.url")]['user']; + $draft = from($_REQUEST, 'draft'); + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) { + if (!empty($url)) { + add_link($title, $tag, $url, $content, $user, $description, $link, $draft); + } else { + $url = $title; + add_link($title, $tag, $url, $content, $user, $description, $link, $draft); + } + } else { + $message['error'] = ''; + if (empty($title)) { + $message['error'] .= '
  • Title field is required.
  • '; + } + if (empty($tag)) { + $message['error'] .= '
  • Tag field is required.
  • '; + } + if (empty($content)) { + $message['error'] .= '
  • Content field is required.
  • '; + } + if (empty($link)) { + $message['error'] .= '
  • Link field is required.
  • '; + } + if (!$proper) { + $message['error'] .= '
  • CSRF Token not correct.
  • '; + } + config('views.root', 'system/admin/views'); + render('add-link', array( + 'title' => 'Add link- ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postLink' => $link, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'bodyclass' => 'addlink', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add link' + )); + } +}); + +// Show the "Add quote" page +get('/add/quote', function () { + + if (login()) { + + config('views.root', 'system/admin/views'); + + render('add-quote', array( + 'title' => 'Add quote - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'bodyclass' => 'addquote', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add quote' + )); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Submitted add quote data +post('/add/quote', function () { + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + + $title = from($_REQUEST, 'title'); + $quote = from($_REQUEST, 'quote'); + $tag = from($_REQUEST, 'tag'); + $url = from($_REQUEST, 'url'); + $content = from($_REQUEST, 'content'); + $description = from($_REQUEST, 'description'); + $user = $_SESSION[config("site.url")]['user']; + $draft = from($_REQUEST, 'draft'); + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) { + if (!empty($url)) { + add_quote($title, $tag, $url, $content, $user, $description, $quote, $draft); + } else { + $url = $title; + add_quote($title, $tag, $url, $content, $user, $description, $quote, $draft); + } + } else { + $message['error'] = ''; + if (empty($title)) { + $message['error'] .= '
  • Title field is required.
  • '; + } + if (empty($tag)) { + $message['error'] .= '
  • Tag field is required.
  • '; + } + if (empty($content)) { + $message['error'] .= '
  • Content field is required.
  • '; + } + if (empty($quote)) { + $message['error'] .= '
  • Quote field is required.
  • '; + } + if (!$proper) { + $message['error'] .= '
  • CSRF Token not correct.
  • '; + } + config('views.root', 'system/admin/views'); + render('add-quote', array( + 'title' => 'Add quote - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postQuote' => $quote, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'bodyclass' => 'addquote', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add Quote' + )); + } +}); + +// Show the "Add audio" page +get('/add/audio', function () { + + if (login()) { + + config('views.root', 'system/admin/views'); + + render('add-audio', array( + 'title' => 'Add audio - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'bodyclass' => 'addaudio', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add audio' + )); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Submitted add quote data +post('/add/audio', function () { + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + + $title = from($_REQUEST, 'title'); + $audio = from($_REQUEST, 'audio'); + $tag = from($_REQUEST, 'tag'); + $url = from($_REQUEST, 'url'); + $content = from($_REQUEST, 'content'); + $description = from($_REQUEST, 'description'); + $user = $_SESSION[config("site.url")]['user']; + $draft = from($_REQUEST, 'draft'); + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) { + if (!empty($url)) { + add_audio($title, $tag, $url, $content, $user, $description, $audio, $draft); + } else { + $url = $title; + add_audio($title, $tag, $url, $content, $user, $description, $audio, $draft); + } + } else { + $message['error'] = ''; + if (empty($title)) { + $message['error'] .= '
  • Title field is required.
  • '; + } + if (empty($tag)) { + $message['error'] .= '
  • Tag field is required.
  • '; + } + if (empty($content)) { + $message['error'] .= '
  • Content field is required.
  • '; + } + if (empty($audio)) { + $message['error'] .= '
  • Audio field is required.
  • '; + } + if (!$proper) { + $message['error'] .= '
  • CSRF Token not correct.
  • '; + } + config('views.root', 'system/admin/views'); + render('add-audio', array( + 'title' => 'Add audio - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postAudio' => $audio, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'bodyclass' => 'addaudio', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add audio' + )); + } +}); + // Show the static add page get('/add/page', function () { @@ -546,6 +912,24 @@ get('/admin/draft', function () { } }); +// Show admin/content +get('/admin/content', function () { + if (login()) { + config('views.root', 'system/admin/views'); + render('content-type', array( + 'title' => 'Add content - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'bodyclass' => 'contenttype', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add content' + )); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + // Show import page get('/admin/import', function () { if (login()) { @@ -1309,6 +1693,8 @@ post('/:static/:sub/edit', function ($static, $sub) { 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, + 'static' => $static, + 'sub' => $sub, 'bodyclass' => 'editpage', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit page' )); @@ -1407,6 +1793,20 @@ get('/:year/:month/:name', function ($year, $month, $name) { } else { $next = array(); } + + if (isset($current->image)) { + $var = 'imagePost'; + } elseif (isset($current->link)) { + $var = 'linkPost'; + } elseif (isset($current->quote)) { + $var = 'quotePost'; + } elseif (isset($current->audio)) { + $var = 'audioPost'; + } elseif (isset($current->video)) { + $var = 'videoPost'; } + else { + $var = 'blogPost'; + } render('post', array( 'title' => $current->title . ' - ' . blog_title(), @@ -1418,7 +1818,7 @@ get('/:year/:month/:name', function ($year, $month, $name) { 'breadcrumb' => '' . config('breadcrumb.home') . ' » ' . $current->tagb . ' » ' . $current->title, 'prev' => has_prev($prev), 'next' => has_next($next), - 'type' => 'blogPost', + 'type' => $var, 'is_post' => is_post(true), )); @@ -1443,19 +1843,33 @@ get('/:year/:month/:name/edit', function ($year, $month, $name) { } $current = $post['current']; - + + if (isset($current->image)) { + $var = 'edit-image'; + } elseif (isset($current->link)) { + $var = 'edit-link'; + } elseif (isset($current->quote)) { + $var = 'edit-quote'; + } elseif (isset($current->audio)) { + $var = 'edit-audio'; + } elseif (isset($current->video)) { + $var = 'edit-video'; } + else { + $var = 'edit-post'; + } + if ($user === $current->author || $role === 'admin') { - render('edit-post', array( - 'title' => 'Edit post - ' . blog_title(), + render($var, array( + 'title' => $var .' '. blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'p' => $current, - 'bodyclass' => 'editpost', + 'bodyclass' => 'editcontent', 'breadcrumb' => '' . config('breadcrumb.home') . ' » ' . $current->tagb . ' » ' . $current->title )); } else { render('denied', array( - 'title' => 'Edit post - ' . blog_title(), + 'title' => $var .' '. blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'p' => $current, @@ -1475,8 +1889,17 @@ post('/:year/:month/:name/edit', function () { $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); $title = from($_REQUEST, 'title'); - $img = from($_REQUEST, 'img'); - $vid = from($_REQUEST, 'vid'); + $is_post = from($_REQUEST, 'is_post'); + $image = from($_REQUEST, 'image'); + $is_image = from($_REQUEST, 'is_image'); + $video = from($_REQUEST, 'video'); + $is_video = from($_REQUEST, 'is_video'); + $link = from($_REQUEST, 'link'); + $is_link = from($_REQUEST, 'is_link'); + $audio = from($_REQUEST, 'audio'); + $is_audio = from($_REQUEST, 'is_audio'); + $quote = from($_REQUEST, 'quote'); + $is_quote = from($_REQUEST, 'is_quote'); $tag = from($_REQUEST, 'tag'); $url = from($_REQUEST, 'url'); $content = from($_REQUEST, 'content'); @@ -1491,12 +1914,57 @@ post('/:year/:month/:name/edit', function () { if ($date !== null && $time !== null) { $dateTime = $date . ' ' . $time; } - - if ($proper && !empty($title) && !empty($tag) && !empty($content)) { + + if (!empty($is_image)) { + $var = 'edit-image'; + } elseif (!empty($is_video)) { + $var = 'edit-video'; + } elseif (!empty($is_link)) { + $var = 'edit-link'; + } elseif (!empty($is_quote)) { + $var = 'edit-quote'; + } elseif (!empty($is_audio)) { + $var = 'edit-audio'; + } elseif (!empty($is_post)) { + $var = 'edit-post'; + } + + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) { + if (empty($url)) { + $url = $title; + } + edit_image($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $image, $revertPost, $publishDraft); + + } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) { if (empty($url)) { $url = $title; } - edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $img, $vid, $revertPost, $publishDraft); + edit_video($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $video, $revertPost, $publishDraft); + + } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) { + if (empty($url)) { + $url = $title; + } + edit_link($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $link, $revertPost, $publishDraft); + + } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) { + if (empty($url)) { + $url = $title; + } + edit_quote($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $quote, $revertPost, $publishDraft); + + } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) { + if (empty($url)) { + $url = $title; + } + edit_audio($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $audio, $revertPost, $publishDraft); + + } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) { + if (empty($url)) { + $url = $title; + } + edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $revertPost, $publishDraft); + } else { $message['error'] = ''; if (empty($title)) { @@ -1511,22 +1979,48 @@ post('/:year/:month/:name/edit', function () { if (!$proper) { $message['error'] .= '
  • CSRF Token not correct.
  • '; } + + if (!empty($is_image)) { + if (empty($image)) { + $message['error'] .= '
  • Image field is required.
  • '; + } + } elseif (!empty($is_video)) { + if (empty($video)) { + $message['error'] .= '
  • Video field is required.
  • '; + } + } elseif (!empty($is_link)) { + if (empty($link)) { + $message['error'] .= '
  • Link field is required.
  • '; + } + } elseif (!empty($is_quote)) { + if (empty($quote)) { + $message['error'] .= '
  • Quote field is required.
  • '; + } + } elseif (!empty($is_audio)) { + if (empty($audio)) { + $message['error'] .= '
  • Audio field is required.
  • '; + } + } + config('views.root', 'system/admin/views'); - render('edit-post', array( - 'title' => 'Edit post - ' . blog_title(), + render($var, array( + 'title' => 'Edit content - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'error' => '', 'oldfile' => $oldfile, 'postTitle' => $title, - 'postImg' => $img, - 'postVid' => $vid, + 'postImage' => $image, + 'postVideo' => $video, + 'postLink' => $link, + 'postQuote' => $quote, + 'postAudio' => $audio, 'postTag' => $tag, 'postUrl' => $url, 'postContent' => $content, - 'bodyclass' => 'editpost', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit post' + 'bodyclass' => 'editcontent', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit content' )); } }); diff --git a/system/includes/functions.php b/system/includes/functions.php index f4b6876..caa8058 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -266,8 +266,11 @@ function get_posts($posts, $page = 1, $perpage = 0) // Extract the title and body $post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date)); - $post->image = get_content_tag('img', $content); - $post->video = get_content_tag('vid', $content); + $post->image = get_content_tag('image', $content); + $post->video = str_replace(array("http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"), "", get_content_tag('video', $content)); + $post->link = get_content_tag('link', $content); + $post->quote = get_content_tag('quote', $content); + $post->audio = get_content_tag('audio', $content); // Get the contents and convert it to HTML $post->body = MarkdownExtra::defaultTransform(remove_html_comments($content)); @@ -1878,8 +1881,7 @@ EOF; } echo '
  • Mine
  • '; echo '
  • Draft
  • '; - echo '
  • Add post
  • '; - echo '
  • Add page
  • '; + echo '
  • Add content
  • '; echo '
  • Edit profile
  • '; echo '
  • Import
  • '; echo '
  • Backup
  • '; diff --git a/themes/clean/css/style.css b/themes/clean/css/style.css index 2ca8940..b5739d2 100644 --- a/themes/clean/css/style.css +++ b/themes/clean/css/style.css @@ -872,7 +872,7 @@ aside .copyright p { @media all and (max-width: 560px) { - .featured-video { + .featured-video, .featured-audio { position: relative; padding-bottom: 56.25%; padding-top: 30px; @@ -880,7 +880,7 @@ aside .copyright p { overflow: hidden; } - .featured-video iframe, .featured-video object, .featured-video embed { + .featured-video iframe, .featured-video object, .featured-video embed, .featured-audio iframe, .featured-audio object, .featured-audio embed { height: 100%; left: 0; position: absolute; diff --git a/themes/clean/main.html.php b/themes/clean/main.html.php index 77a510c..924c6de 100644 --- a/themes/clean/main.html.php +++ b/themes/clean/main.html.php @@ -24,14 +24,29 @@ url ?>> Comments - image)) { ?> + image)) { ?> video)) { ?> + + audio)) { ?> + + + quote)) { ?> + + + link)) { ?> +
    diff --git a/themes/clean/post.html.php b/themes/clean/post.html.php index 423329f..21bc6ed 100644 --- a/themes/clean/post.html.php +++ b/themes/clean/post.html.php @@ -13,16 +13,31 @@ - Permalink
    - image)) { ?> - - - video)) { ?> - - + image)) { ?> + + + video)) { ?> + + + audio)) { ?> + + + quote)) { ?> + + + link)) { ?> + +
    body; ?>
    diff --git a/themes/default/css/style.css b/themes/default/css/style.css index 6f09eae..05935c7 100644 --- a/themes/default/css/style.css +++ b/themes/default/css/style.css @@ -959,7 +959,7 @@ h1.title-post a:hover, h2.title-index a:hover { @media all and (max-width: 560px) { - .featured-video { + .featured-video, .featured-audio { position: relative; padding-bottom: 56.25%; padding-top: 30px; @@ -967,7 +967,7 @@ h1.title-post a:hover, h2.title-index a:hover { overflow: hidden; } - .featured-video iframe, .featured-video object, .featured-video embed { + .featured-video iframe, .featured-video object, .featured-video embed, .featured-audio iframe, .featured-audio object, .featured-audio embed { height: 100%; left: 0; position: absolute; diff --git a/themes/default/main.html.php b/themes/default/main.html.php index 77a510c..924c6de 100644 --- a/themes/default/main.html.php +++ b/themes/default/main.html.php @@ -24,14 +24,29 @@ url ?>> Comments - image)) { ?> + image)) { ?> video)) { ?> + + audio)) { ?> + + + quote)) { ?> + + + link)) { ?> +
    diff --git a/themes/default/post.html.php b/themes/default/post.html.php index afc7cef..c4497f1 100644 --- a/themes/default/post.html.php +++ b/themes/default/post.html.php @@ -13,16 +13,31 @@ - Permalink
    - image)) { ?> - - - video)) { ?> - - + image)) { ?> + + + video)) { ?> + + + audio)) { ?> + + + quote)) { ?> + + + link)) { ?> + +
    body; ?>
    diff --git a/themes/logs/css/style.css b/themes/logs/css/style.css index 9196b61..5f2d868 100644 --- a/themes/logs/css/style.css +++ b/themes/logs/css/style.css @@ -889,7 +889,7 @@ table.post-list td a { @media all and (max-width: 560px) { - .featured-video { + .featured-video, .featured-audio { position: relative; padding-bottom: 56.25%; padding-top: 30px; @@ -897,7 +897,7 @@ table.post-list td a { overflow: hidden; } - .featured-video iframe, .featured-video object, .featured-video embed { + .featured-video iframe, .featured-video object, .featured-video embed, .featured-audio iframe, .featured-audio object, .featured-audio embed { height: 100%; left: 0; position: absolute; diff --git a/themes/logs/main.html.php b/themes/logs/main.html.php index 7f142b1..a27816c 100644 --- a/themes/logs/main.html.php +++ b/themes/logs/main.html.php @@ -34,6 +34,21 @@ + audio)) { ?> + + + quote)) { ?> + + + link)) { ?> + +
    body) ?>

    body) ?> diff --git a/themes/logs/post.html.php b/themes/logs/post.html.php index e30715b..28a5371 100644 --- a/themes/logs/post.html.php +++ b/themes/logs/post.html.php @@ -14,15 +14,30 @@ Permalink

    image)) { ?> - - - video)) { ?> - - + + + video)) { ?> + + + audio)) { ?> + + + quote)) { ?> + + + link)) { ?> + +
    body; ?>