From e3e393a7bdee32477e1646e2e76a5e40f16e5d99 Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Tue, 1 Dec 2015 18:43:02 +0700 Subject: [PATCH] Cleaning up Simplify add and edit content. Bugs fixes and improvements. --- system/admin/admin.php | 1420 +++----------------- system/admin/views/add-audio.html.php | 82 -- system/admin/views/add-category.html.php | 58 - system/admin/views/add-content.html.php | 123 ++ system/admin/views/add-image.html.php | 82 -- system/admin/views/add-link.html.php | 82 -- system/admin/views/add-page.html.php | 64 +- system/admin/views/add-post.html.php | 75 -- system/admin/views/add-quote.html.php | 82 -- system/admin/views/add-video.html.php | 82 -- system/admin/views/content-type.html.php | 12 +- system/admin/views/edit-audio.html.php | 130 -- system/admin/views/edit-category.html.php | 87 -- .../{edit-video.html.php => edit-content.html.php} | 123 +- system/admin/views/edit-frontpage.html.php | 62 - system/admin/views/edit-image.html.php | 130 -- system/admin/views/edit-link.html.php | 131 -- system/admin/views/edit-page.html.php | 144 +- system/admin/views/edit-post.html.php | 125 -- system/admin/views/edit-profile.html.php | 66 - system/admin/views/edit-quote.html.php | 131 -- system/admin/views/layout.html.php | 2 +- system/htmly.php | 795 +++++------ system/includes/functions.php | 24 +- system/resources/css/admin.css | 1033 ++++++++++++++ .../default => system/resources}/css/toolbar.css | 0 upload.php | 5 +- 27 files changed, 1898 insertions(+), 3252 deletions(-) delete mode 100644 system/admin/views/add-audio.html.php delete mode 100644 system/admin/views/add-category.html.php create mode 100644 system/admin/views/add-content.html.php delete mode 100644 system/admin/views/add-image.html.php delete mode 100644 system/admin/views/add-link.html.php delete mode 100644 system/admin/views/add-post.html.php delete mode 100644 system/admin/views/add-quote.html.php delete mode 100644 system/admin/views/add-video.html.php delete mode 100644 system/admin/views/edit-audio.html.php delete mode 100644 system/admin/views/edit-category.html.php rename system/admin/views/{edit-video.html.php => edit-content.html.php} (51%) delete mode 100644 system/admin/views/edit-frontpage.html.php delete mode 100644 system/admin/views/edit-image.html.php delete mode 100644 system/admin/views/edit-link.html.php delete mode 100644 system/admin/views/edit-post.html.php delete mode 100644 system/admin/views/edit-profile.html.php delete mode 100644 system/admin/views/edit-quote.html.php create mode 100644 system/resources/css/admin.css rename {themes/default => system/resources}/css/toolbar.css (100%) diff --git a/system/admin/admin.php b/system/admin/admin.php index 2dee18e..409a5bc 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -58,7 +58,7 @@ function session($user, $pass) $_SESSION[config("site.url")]['user'] = $user; header('location: admin'); } else { - return $str = '
  • Your username and password mismatch.
  • '; + return $str = '
  • Your username and password mismatch.
  • '; } } else if (old_password_verify($pass, $user_enc, $user_pass)) { update_user($user, $pass, $user_role); @@ -81,18 +81,13 @@ function remove_accent($str) return URLify::downcode($str); } -// Edit blog posts -function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $revertPost, $publishDraft, $category) +// Add content +function add_content($title, $tag, $url, $content, $user, $description = null, $media = null, $draft, $category, $type) { - $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_date = date('Y-m-d-H-i-s'); $post_title = safe_html($title); + $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media)); $pt = safe_tag($tag); $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); @@ -109,129 +104,52 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $tagmd = "\n"; } else { $tagmd = ""; + } + if ($media!== null) { + $post_media = "\n"; + } else { + $post_media = ""; } - $post_content = '' . $post_description . $tagmd ."\n\n" . $content; + $post_content = "" . $post_description . $tagmd . $post_media . "\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] . '/' . $dir[2] . '/' . $category . '/post/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == '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 { - - if ($dir[3] === $category) { - $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)); - } - } else { - - $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/post/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == 'draft') { - $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; - } else { - $filename = $dirBlog . $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'; - - } + $filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md'; - } - - if(!empty($publishDraft)) { - $dt = $olddate; - $t = str_replace('-', '', $dt); - $time = new DateTime($t); - $timestamp = $time->format("Y-m-d"); + if (empty($draft)) { + $dir = 'content/' . $user . '/blog/' . $category. '/'.$type. '/'; } 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"); + $dir = 'content/' . $user . '/blog/' . $category. '/draft/'; } - // The post date - $postdate = strtotime($timestamp); - - // The post URL - if (config('permalink.type') == 'post') { - $posturl = site_url() . 'post/' . $post_url; + if (is_dir($dir)) { + file_put_contents($dir . $filename, print_r($post_content, true)); } else { - $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; + mkdir($dir, 0775, true); + file_put_contents($dir . $filename, print_r($post_content, true)); } save_tag_i18n($post_tag, $post_tagmd); - + 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"); - } + clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename, $category); + + if (empty($draft)) { + $redirect = site_url() . 'admin/mine'; } 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"); - } + $redirect = site_url() . 'admin/draft'; } + + header("Location: $redirect"); } } -// Edit image posts -function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $image, $revertPost, $publishDraft, $category) +// Edit content +function edit_content($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $media = null, $revertPost, $publishDraft, $category, $type) { $oldurl = explode('_', $oldfile); $dir = explode('/', $oldurl[0]); @@ -242,7 +160,7 @@ function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, } $post_title = safe_html($title); - $post_image = preg_replace('/\s\s+/', ' ', strip_tags($image)); + $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media)); $pt = safe_tag($tag); $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); @@ -260,12 +178,12 @@ function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, } else { $tagmd = ""; } - if ($image !== null) { - $post_image = "\n"; + if ($media !== null) { + $post_media = "\n"; } else { $post_image = ""; } - $post_content = '' . $post_description . $tagmd . $post_image ."\n\n" . $content; + $post_content = "" . $post_description . $tagmd . $post_media . "\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { @@ -275,7 +193,7 @@ function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, if(!empty($revertPost) || !empty($publishDraft)) { - $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/image/'; + $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/' . $type . '/'; $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; if($dir[4] == 'draft') { @@ -310,7 +228,7 @@ function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, } } else { - $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/image/'; + $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/' . $type. '/'; $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; if($dir[4] == 'draft') { @@ -363,7 +281,7 @@ function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, save_tag_i18n($post_tag, $post_tagmd); rebuilt_cache('all'); - clear_post_cache($dt, $post_tag, $post_url, $newfile); + clear_post_cache($dt, $post_tag, $post_url, $newfile, $category); if ($destination == 'post') { if(!empty($revertPost)) { $drafturl = site_url() . 'admin/draft'; @@ -380,989 +298,16 @@ function edit_image($title, $tag, $url, $content, $oldfile, $destination = null, } 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, $category) -{ - $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 = safe_html($title); - $post_video = preg_replace('/\s\s+/', ' ', strip_tags($video)); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ""; - } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - if ($video !== null) { - $post_video = "\n"; - } else { - $post_video = ""; - } - $post_content = '' . $post_description . $tagmd . $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] . '/' . $dir[2] . '/' . $category . '/video/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == '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 { - - if ($dir[3] === $category) { - $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)); - } - } else { - - $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/video/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == 'draft') { - $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; - } else { - $filename = $dirBlog . $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'; - - } - - } - - 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 - if (config('permalink.type') == 'post') { - $posturl = site_url() . 'post/' . $post_url; - } else { - $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; - } - - save_tag_i18n($post_tag, $post_tagmd); - - 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, $category) -{ - $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 = safe_html($title); - $post_link = preg_replace('/\s\s+/', ' ', strip_tags($link)); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ""; - } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - if ($link !== null) { - $post_link = "\n"; - } else { - $post_link = ""; - } - $post_content = '' . $post_description . $tagmd . $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] . '/' . $dir[2] . '/' . $category . '/link/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == '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 { - - if ($dir[3] === $category) { - $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)); - } - } else { - - $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/link/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == 'draft') { - $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; - } else { - $filename = $dirBlog . $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'; - - } - - } - - 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 - if (config('permalink.type') == 'post') { - $posturl = site_url() . 'post/' . $post_url; - } else { - $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; - } - - save_tag_i18n($post_tag, $post_tagmd); - - 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, $category) -{ - $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 = safe_html($title); - $post_quote = preg_replace('/\s\s+/', ' ', strip_tags($quote)); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ""; - } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - if ($quote !== null) { - $post_quote = "\n"; - } else { - $post_quote = ""; - } - $post_content = '' . $post_description . $tagmd . $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] . '/' . $dir[2] . '/' . $category . '/quote/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == '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 { - - if ($dir[3] === $category) { - $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)); - } - } else { - - $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/quote/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == 'draft') { - $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; - } else { - $filename = $dirBlog . $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'; - - } - - } - - - 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 - if (config('permalink.type') == 'post') { - $posturl = site_url() . 'post/' . $post_url; - } else { - $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; - } - - save_tag_i18n($post_tag, $post_tagmd); - - 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, $category) -{ - $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 = safe_html($title); - $post_audio = preg_replace('/\s\s+/', ' ', strip_tags($audio)); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ""; - } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - if ($audio !== null) { - $post_audio = "\n"; - } else { - $post_audio = ""; - } - $post_content = '' . $post_description . $tagmd . $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); - } - - if(!empty($revertPost) || !empty($publishDraft)) { - - $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/audio/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == '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 { - - if ($dir[3] === $category) { - $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)); - } - } else { - - $dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/audio/'; - $dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/'; - - if($dir[4] == 'draft') { - $filename = $dirDraft . $olddate . '_' . $post_tag . '_' . $post_url . '.md'; - } else { - $filename = $dirBlog . $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'; - - } - - } - - 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 - if (config('permalink.type') == 'post') { - $posturl = site_url() . 'post/' . $post_url; - } else { - $posturl = site_url() . date('Y/m', $postdate) . '/' . $post_url; - } - - save_tag_i18n($post_tag, $post_tagmd); - - 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 static page -function edit_page($title, $url, $content, $oldfile, $destination = null, $description = null, $static = null) -{ - $dir = substr($oldfile, 0, strrpos($oldfile, '/')); - - $post_title = safe_html($title); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ''; - } - $post_content = '' . $post_description . "\n\n" . $content; - - if (!empty($post_title) && !empty($post_url) && !empty($post_content)) { - if (get_magic_quotes_gpc()) { - $post_content = stripslashes($post_content); - } - $newfile = $dir . '/' . $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($static)) { - $posturl = site_url() . $static .'/'. $post_url; - } else { - $posturl = site_url() . $post_url; - } - - rebuilt_cache('all'); - clear_page_cache($post_url); - if ($destination == 'post') { - header("Location: $posturl"); - } else { - $redirect = site_url() . $destination; - header("Location: $redirect"); - } - } -} - -// Edit static page -function edit_category($title, $url, $content, $oldfile, $destination = null, $description = null) -{ - $dir = substr($oldfile, 0, strrpos($oldfile, '/')); - - $post_title = safe_html($title); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ''; - } - $post_content = '' . $post_description . "\n\n" . $content; - if (!empty($post_title) && !empty($post_url) && !empty($post_content)) { - - if (get_magic_quotes_gpc()) { - $post_content = stripslashes($post_content); - } - $newfile = $dir . '/' . $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)); - } - - rename_category_folder($post_url, $oldfile); - - rebuilt_cache('all'); - if ($destination == 'post') { - header("Location: $posturl"); - } else { - $redirect = site_url() . $destination; - header("Location: $redirect"); - } - } -} - -// Add post -function add_post($title, $tag, $url, $content, $user, $description = null, $draft, $category) -{ - - $post_date = date('Y-m-d-H-i-s'); - $post_title = safe_html($title); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ""; - } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - $post_content = '' . $post_description . $tagmd ."\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/' . $category. '/post/'; - } else { - $dir = 'content/' . $user . '/blog/' . $category. '/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)); - } - - save_tag_i18n($post_tag, $post_tagmd); - - 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, $category) -{ - - $post_date = date('Y-m-d-H-i-s'); - $post_title = safe_html($title); - $post_image = preg_replace('/\s\s+/', ' ', strip_tags($image)); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ""; - } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - if ($image !== null) { - $post_image = "\n"; - } else { - $post_image = ""; - } - $post_content = '' . $post_description . $tagmd . $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/' . $category. '/image/'; - } else { - $dir = 'content/' . $user . '/blog/' . $category. '/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)); - } - - save_tag_i18n($post_tag, $post_tagmd); - - 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, $category) -{ - - $post_date = date('Y-m-d-H-i-s'); - $post_title = safe_html($title); - $post_video = preg_replace('/\s\s+/', ' ', strip_tags($video)); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ""; - } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - if ($video !== null) { - $post_video = "\n"; - } else { - $post_video = ""; - } - $post_content = '' . $post_description . $tagmd . $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/' . $category. '/video/'; - } else { - $dir = 'content/' . $user . '/blog/' . $category. '/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)); - } - - save_tag_i18n($post_tag, $post_tagmd); - - 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, $category) -{ - - $post_date = date('Y-m-d-H-i-s'); - $post_title = safe_html($title); - $post_audio = preg_replace('/\s\s+/', ' ', strip_tags($audio)); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); - $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); - $description = safe_html($description); - if ($description !== null) { - $post_description = "\n"; - } else { - $post_description = ""; - } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - if ($audio !== null) { - $post_audio = "\n"; - } else { - $post_audio = ""; - } - $post_content = '' . $post_description . $tagmd . $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/' . $category. '/audio/'; - } else { - $dir = 'content/' . $user . '/blog/' . $category. '/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)); - } - - save_tag_i18n($post_tag, $post_tagmd); - - 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, $category) +// Add static page +function add_page($title, $url, $content, $description = null) { - $post_date = date('Y-m-d-H-i-s'); $post_title = safe_html($title); - $post_link = preg_replace('/\s\s+/', ' ', strip_tags($link)); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); $description = safe_html($description); if ($description !== null) { @@ -1370,66 +315,33 @@ function add_link($title, $tag, $url, $content, $user, $description = null, $lin } else { $post_description = ""; } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - if ($link !== null) { - $post_link = "\n"; - } else { - $post_link = ""; - } - $post_content = '' . $post_description . $tagmd . $post_link ."\n\n" . $content; + $post_content = '' . $post_description . "\n\n" . $content; - if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { - + if (!empty($post_title) && !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/' . $category. '/link/'; - } else { - $dir = 'content/' . $user . '/blog/' . $category. '/draft/'; - } - + $filename = $post_url . '.md'; + $dir = 'content/static/'; 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)); } - - save_tag_i18n($post_tag, $post_tagmd); 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'; - } - + clear_page_cache($post_url); + $redirect = site_url() . 'admin'; header("Location: $redirect"); } } -// Add quote -function add_quote($title, $tag, $url, $content, $user, $description = null, $quote, $draft, $category) +// Add static sub page +function add_sub_page($title, $url, $content, $static, $description = null) { - $post_date = date('Y-m-d-H-i-s'); $post_title = safe_html($title); - $post_quote = preg_replace('/\s\s+/', ' ', strip_tags($quote)); - $pt = safe_tag($tag); - $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($pt))); - $post_tagmd = preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', ' ', ''), $pt); - $post_tag = rtrim($post_tag, ','); - $post_tagmd = rtrim($post_tagmd, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); $description = safe_html($description); if ($description !== null) { @@ -1437,65 +349,40 @@ function add_quote($title, $tag, $url, $content, $user, $description = null, $qu } else { $post_description = ""; } - if ($tag !== null) { - $tagmd = "\n"; - } else { - $tagmd = ""; - } - if ($quote !== null) { - $post_quote = "\n"; - } else { - $post_quote = ""; - } - $post_content = '' . $post_description . $tagmd . $post_quote ."\n\n" . $content; + $post_content = '' . $post_description . "\n\n" . $content; - if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { - + if (!empty($post_title) && !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/' . $category. '/quote/'; - } else { - $dir = 'content/' . $user . '/blog/' . $category. '/draft/'; - } - + $filename = $post_url . '.md'; + $dir = 'content/static/' . $static . '/'; 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)); } - - save_tag_i18n($post_tag, $post_tagmd); 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'; - } - + clear_page_cache($post_url); + $redirect = site_url() . 'admin'; header("Location: $redirect"); } } -// Add static page -function add_page($title, $url, $content, $description = null) +// Edit static page and sub page +function edit_page($title, $url, $content, $oldfile, $destination = null, $description = null, $static = null) { - + $dir = substr($oldfile, 0, strrpos($oldfile, '/')); + $post_title = safe_html($title); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); $description = safe_html($description); if ($description !== null) { $post_description = "\n"; } else { - $post_description = ""; + $post_description = ''; } $post_content = '' . $post_description . "\n\n" . $content; @@ -1503,24 +390,40 @@ function add_page($title, $url, $content, $description = null) if (get_magic_quotes_gpc()) { $post_content = stripslashes($post_content); } - $filename = $post_url . '.md'; - $dir = 'content/static/'; - if (is_dir($dir)) { - file_put_contents($dir . $filename, print_r($post_content, true)); + $newfile = $dir . '/' . $post_url . '.md'; + if ($oldfile === $newfile) { + file_put_contents($oldfile, print_r($post_content, true)); } else { - mkdir($dir, 0775, true); - file_put_contents($dir . $filename, print_r($post_content, true)); + rename($oldfile, $newfile); + file_put_contents($newfile, print_r($post_content, true)); + if (empty($static)) { + $path = pathinfo($oldfile); + $old = substr($path['filename'], strrpos($path['filename'], '/')); + if(is_dir($dir . '/' . $old)) { + rename($dir . '/' . $old, $dir . '/' . $post_url); + } + } } + if (!empty($static)) { + $posturl = site_url() . $static .'/'. $post_url; + } else { + $posturl = site_url() . $post_url; + } + rebuilt_cache('all'); clear_page_cache($post_url); - $redirect = site_url() . 'admin'; - header("Location: $redirect"); + if ($destination == 'post') { + header("Location: $posturl"); + } else { + $redirect = site_url() . $destination; + header("Location: $redirect"); + } } } -// Add static sub page -function add_sub_page($title, $url, $content, $static, $description = null) +// Add category +function add_category($title, $url, $content, $description = null) { $post_title = safe_html($title); @@ -1538,7 +441,7 @@ function add_sub_page($title, $url, $content, $static, $description = null) $post_content = stripslashes($post_content); } $filename = $post_url . '.md'; - $dir = 'content/static/' . $static . '/'; + $dir = 'content/data/category/'; if (is_dir($dir)) { file_put_contents($dir . $filename, print_r($post_content, true)); } else { @@ -1548,14 +451,15 @@ function add_sub_page($title, $url, $content, $static, $description = null) rebuilt_cache('all'); clear_page_cache($post_url); - $redirect = site_url() . 'admin'; + $redirect = site_url() . 'admin/categories'; header("Location: $redirect"); } } -// Add static page -function add_category($title, $url, $content, $description = null) +// Edit category +function edit_category($title, $url, $content, $oldfile, $destination = null, $description = null) { + $dir = substr($oldfile, 0, strrpos($oldfile, '/')); $post_title = safe_html($title); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); @@ -1563,26 +467,78 @@ function add_category($title, $url, $content, $description = null) if ($description !== null) { $post_description = "\n"; } else { - $post_description = ""; + $post_description = ''; } $post_content = '' . $post_description . "\n\n" . $content; - if (!empty($post_title) && !empty($post_url) && !empty($post_content)) { + if (get_magic_quotes_gpc()) { $post_content = stripslashes($post_content); } - $filename = $post_url . '.md'; - $dir = 'content/data/category/'; + $newfile = $dir . '/' . $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)); + } + + rename_category_folder($post_url, $oldfile); + + rebuilt_cache('all'); + if ($destination == 'post') { + header("Location: $posturl"); + } else { + $redirect = site_url() . $destination; + header("Location: $redirect"); + } + } +} + +// Edit user profile +function edit_profile($title, $content, $user) +{ + $user_title = safe_html($title); + $user_content = '' . "\n\n" . $content; + + if (!empty($user_title) && !empty($user_content)) { + if (get_magic_quotes_gpc()) { + $user_content = stripslashes($user_content); + } + $dir = 'content/' . $user . '/'; + $filename = 'content/' . $user . '/author.md'; if (is_dir($dir)) { - file_put_contents($dir . $filename, print_r($post_content, true)); + file_put_contents($filename, print_r($user_content, true)); } else { mkdir($dir, 0775, true); - file_put_contents($dir . $filename, print_r($post_content, true)); + file_put_contents($filename, print_r($user_content, true)); } + rebuilt_cache('all'); + $redirect = site_url() . 'author/' . $user; + header("Location: $redirect"); + } +} +// Edit homepage +function edit_frontpage($title, $content) +{ + $front_title = safe_html($title); + $front_content = '' . "\n\n" . $content; + + if (!empty($front_title) && !empty($front_content)) { + if (get_magic_quotes_gpc()) { + $front_content = stripslashes($front_content); + } + $dir = 'content/data/frontpage'; + $filename = 'content/data/frontpage/frontpage.md'; + if (is_dir($dir)) { + file_put_contents($filename, print_r($front_content, true)); + } else { + mkdir($dir, 0775, true); + file_put_contents($filename, print_r($front_content, true)); + } rebuilt_cache('all'); - clear_page_cache($post_url); - $redirect = site_url() . 'admin/categories'; + $redirect = site_url(); header("Location: $redirect"); } } @@ -1598,7 +554,7 @@ function delete_post($file, $destination) $arr = explode('_', $file); $replaced = substr($arr[0], 0, strrpos($arr[0], '/')) . '/'; $dt = str_replace($replaced, '', $arr[0]); - clear_post_cache($dt, $arr[1], str_replace('.md', '', $arr[2]), $file); + clear_post_cache($dt, $arr[1], str_replace('.md', '', $arr[2]), $file, $arr[count($str) - 3]); if (!empty($deleted_content)) { unlink($deleted_content); @@ -1643,54 +599,6 @@ function delete_page($file, $destination) } } -// Edit user profile -function edit_profile($title, $content, $user) -{ - $user_title = safe_html($title); - $user_content = '' . "\n\n" . $content; - - if (!empty($user_title) && !empty($user_content)) { - if (get_magic_quotes_gpc()) { - $user_content = stripslashes($user_content); - } - $dir = 'content/' . $user . '/'; - $filename = 'content/' . $user . '/author.md'; - if (is_dir($dir)) { - file_put_contents($filename, print_r($user_content, true)); - } else { - mkdir($dir, 0775, true); - file_put_contents($filename, print_r($user_content, true)); - } - rebuilt_cache('all'); - $redirect = site_url() . 'author/' . $user; - header("Location: $redirect"); - } -} - -// Edit homepage -function edit_frontpage($title, $content) -{ - $front_title = safe_html($title); - $front_content = '' . "\n\n" . $content; - - if (!empty($front_title) && !empty($front_content)) { - if (get_magic_quotes_gpc()) { - $front_content = stripslashes($front_content); - } - $dir = 'content/data/frontpage'; - $filename = 'content/data/frontpage/frontpage.md'; - if (is_dir($dir)) { - file_put_contents($filename, print_r($front_content, true)); - } else { - mkdir($dir, 0775, true); - file_put_contents($filename, print_r($front_content, true)); - } - rebuilt_cache('all'); - $redirect = site_url(); - header("Location: $redirect"); - } -} - // Import RSS feed function migrate($title, $time, $tags, $content, $url, $user, $source) { @@ -1894,17 +802,23 @@ function get_backup_files() } } -function clear_post_cache($post_date, $post_tag, $post_url, $filename) +function clear_post_cache($post_date, $post_tag, $post_url, $filename, $category) { $b = str_replace('/', '#', site_path() . '/'); - $t = explode('-', $post_date); $c = explode(',', $post_tag); - $p = 'cache/page/' . $b . $t[0] . '#' . $t[1] . '#' . $post_url . '.cache'; + $t = explode('-', $post_date); - // Delete post + // Delete post default permalink + $p = 'cache/page/' . $b . $t[0] . '#' . $t[1] . '#' . $post_url . '.cache'; if (file_exists($p)) { unlink($p); } + + // Delete post permalink + $pp = 'cache/page/' . $b . 'post#' . $post_url . '.cache'; + if (file_exists($pp)) { + unlink($pp); + } // Delete homepage $yd = 'cache/page/' . $b . '.cache'; @@ -1957,13 +871,21 @@ function clear_post_cache($post_date, $post_tag, $post_url, $filename) foreach (glob('cache/page/' . $b . 'search#*.cache', GLOB_NOSORT) as $file) { unlink($file); } - + + // Delete category + $cc = 'cache/page/' . $b . 'category#' . $category . '.cache'; + if (file_exists($cc)) { + unlink($cc); + } + foreach (glob('cache/page/' . $b . 'category#' . $category . '~*.cache', GLOB_NOSORT) as $file) { + unlink($file); + } // Get cache post author $arr = explode('_', $filename); $replaced = substr($arr[0], 0, strrpos($arr[0], '/')) . '/'; $str = explode('/', $replaced); - $author = $str[count($str) - 3]; + $author = $str[count($str) - 5]; // Delete author post list cache $a = 'cache/page/' . $b . 'author#' . $author . '.cache'; if (file_exists($a)) { diff --git a/system/admin/views/add-audio.html.php b/system/admin/views/add-audio.html.php deleted file mode 100644 index 5b0d722..0000000 --- a/system/admin/views/add-audio.html.php +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - -
    - - -
    -
    - Title *


    - Category *
    - -

    - 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-category.html.php b/system/admin/views/add-category.html.php deleted file mode 100644 index eb06667..0000000 --- a/system/admin/views/add-category.html.php +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - -
    - -
    -
    - Title *


    - Url (optional)

    - If the url leave empty we will use the page title.

    - Meta Description (optional)
    -

    - -
    -
    - - -
    -
    -
    -

    URL

    - -

    Upload

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

    + Category * +
    + +

    + Tag * +
    + +

    + Url (optional)
    +
    + If the url leave empty we will use the post title. +

    + Meta Description (optional)
    + +

    + + + Featured Audio * (SoundCloud Only) +
    + + +
    + + + + Featured Video * (Youtube Only) +
    + + +
    + + + + Featured Image * +
    + + +
    + + + + Featured Quote * +
    + + +
    + + + + Featured Link * +
    + + +
    + + + + + +
    + +
    + + +
    +
    + + + +
    +

    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 deleted file mode 100644 index f40e3ec..0000000 --- a/system/admin/views/add-image.html.php +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - -
    - - -
    -
    - Title *


    - Category *
    - -

    - 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 deleted file mode 100644 index 8111c03..0000000 --- a/system/admin/views/add-link.html.php +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - -
    - - -
    -
    - Title *


    - Category *
    - -

    - 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 7ff663d..22051d7 100644 --- a/system/admin/views/add-page.html.php +++ b/system/admin/views/add-page.html.php @@ -7,39 +7,43 @@ +
    -
    -
    - Title *


    - Url (optional)

    - If the url leave empty we will use the page title.

    - Meta Description (optional)
    -

    -
    -
    - - -
    +
    +
    + Title * +
    + +

    + Url (optional)
    +
    + If the url leave empty we will use the page title. +

    + Meta Description (optional) +
    + +

    +
    + +
    + + + + + + + +
    + + +

    URL

    @@ -47,10 +51,6 @@
    -
    diff --git a/system/admin/views/add-post.html.php b/system/admin/views/add-post.html.php deleted file mode 100644 index b75abbb..0000000 --- a/system/admin/views/add-post.html.php +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - -
    - - -
    -
    - Title *


    - Category *
    - -

    - Tag *


    - Url (optional)

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

    - Meta Description (optional)
    -

    -
    -
    - - -
    -
    -
    -

    URL

    - -

    Upload

    -
    - -
    - -
    -
    - - - \ No newline at end of file diff --git a/system/admin/views/add-quote.html.php b/system/admin/views/add-quote.html.php deleted file mode 100644 index 787b35d..0000000 --- a/system/admin/views/add-quote.html.php +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - -
    - - -
    -
    - Title *


    - Category *
    - -

    - Tag *


    - Url (optional)

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

    - 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 deleted file mode 100644 index b24afdb..0000000 --- a/system/admin/views/add-video.html.php +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - -
    - - -
    -
    - Title *


    - Category *
    - -

    - 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 index 238232f..9594531 100644 --- a/system/admin/views/content-type.html.php +++ b/system/admin/views/content-type.html.php @@ -1,9 +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 featured quote.

    +

    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 featured 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 deleted file mode 100644 index 44919cd..0000000 --- a/system/admin/views/edit-audio.html.php +++ /dev/null @@ -1,130 +0,0 @@ -file)) { - $url = $p->file; -} else { - $url = $oldfile; -} - -$desc = get_category_info(null); - -$content = file_get_contents($url); -$oldtitle = get_content_tag('t', $content, 'Untitled'); -$olddescription = get_content_tag('d', $content); -$oldtag = get_content_tag('tag', $content); -$oldaudio = get_content_tag('audio', $content); -$oldcontent = remove_html_comments($content); - -$dir = substr($url, 0, strrpos($url, '/')); -$isdraft = explode('/', $dir); -$oldurl = explode('_', $url); - -if (empty($oldtag)) { - $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], '/')) . '/'; - -// Category string -$cat = explode('/', $replaced); -$category = $cat[count($cat) - 3]; - -$dt = str_replace($replaced, '', $oldurl[0]); -$t = str_replace('-', '', $dt); -$time = new DateTime($t); -$timestamp = $time->format("Y-m-d H:i:s"); -// The post date -$postdate = strtotime($timestamp); - -if (config('permalink.type') == 'post') { - $delete = site_url() . 'post/' . $oldmd . '/delete?destination=' . $destination; -} else { - // The post URL - $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; -} -?> - - - - - - - - - - -
    - -
    -
    - Title *


    - Category *
    - -

    - Tag *


    - Url (optional)

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

    - Year, Month, Day

    - Hour, Minute, Second


    - Meta Description (optional)
    -

    - Featured Audio * (SoundCloud Only)


    -
    -
    - - - - - Delete - - Delete - -
    -
    -
    -

    URL

    - -

    Upload

    -
    - -
    - -
    -
    - - - \ No newline at end of file diff --git a/system/admin/views/edit-category.html.php b/system/admin/views/edit-category.html.php deleted file mode 100644 index f1730f1..0000000 --- a/system/admin/views/edit-category.html.php +++ /dev/null @@ -1,87 +0,0 @@ -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); -$oldcontent = remove_html_comments($content); - -if (isset($_GET['destination'])) { - $destination = $_GET['destination']; -} else { - $destination = 'admin'; -} -$dir = substr($url, 0, strrpos($url, '/')); -$oldurl = str_replace($dir . '/', '', $url); -$oldmd = str_replace('.md', '', $oldurl); - -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; - } -} - -?> - - - - - - - - - - -
    - -
    -
    - Title *


    - Url (optional)

    - If the url leave empty we will use the page title.

    - Meta Description (optional)
    -

    -
    -
    - - - -
    -
    -
    -

    URL

    - -

    Upload

    -
    - -
    - -
    -
    - - - \ No newline at end of file diff --git a/system/admin/views/edit-video.html.php b/system/admin/views/edit-content.html.php similarity index 51% rename from system/admin/views/edit-video.html.php rename to system/admin/views/edit-content.html.php index 06e93ff..818cd37 100644 --- a/system/admin/views/edit-video.html.php +++ b/system/admin/views/edit-content.html.php @@ -11,9 +11,14 @@ $content = file_get_contents($url); $oldtitle = get_content_tag('t', $content, 'Untitled'); $olddescription = get_content_tag('d', $content); $oldtag = get_content_tag('tag', $content); -$oldvideo = get_content_tag('video', $content); $oldcontent = remove_html_comments($content); +$oldimage = get_content_tag('image', $content); +$oldaudio = get_content_tag('audio', $content); +$oldvideo = get_content_tag('video', $content); +$oldlink = get_content_tag('link', $content); +$oldquote = get_content_tag('quote', $content); + $dir = substr($url, 0, strrpos($url, '/')); $isdraft = explode('/', $dir); $oldurl = explode('_', $url); @@ -22,7 +27,6 @@ if (empty($oldtag)) { $oldtag = $oldurl[1]; } - $oldmd = str_replace('.md', '', $oldurl[2]); if (isset($_GET['destination'])) { @@ -60,51 +64,85 @@ if (config('permalink.type') == 'post') { +
    +
    - Title *


    - Category *
    + Title * +
    + +

    + Category * +


    - Tag *


    - Url (optional)

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

    - Year, Month, Day

    - Hour, Minute, Second


    - Meta Description (optional)
    + Tag *
    +

    + Url (optional)
    + +
    + If the url leave empty we will use the post title. +

    + Year, Month, Day
    + +
    + Hour, Minute, Second
    +

    - Featured Video * (YouTube Only)


    + Meta Description (optional)
    + +

    + + + Featured Audio * (SoundCloud Only) +
    + + + + + + Featured Video * (Youtube Only) +
    + + + + + + Featured Image * +
    + + + + + + Featured Quote * +
    + + + + + + Featured Link * +
    + + + + + + + +
    -
    - + +
    @@ -114,6 +152,12 @@ if (config('permalink.type') == 'post') {
    + + +

    URL

    @@ -121,11 +165,8 @@ if (config('permalink.type') == 'post') {
    -
    +
    diff --git a/system/admin/views/edit-frontpage.html.php b/system/admin/views/edit-frontpage.html.php deleted file mode 100644 index 11cae7c..0000000 --- a/system/admin/views/edit-frontpage.html.php +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - -
    - -
    -
    - Title *


    -
    - -
    -
    - - -
    -
    -
    -

    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 deleted file mode 100644 index 72d7ffe..0000000 --- a/system/admin/views/edit-image.html.php +++ /dev/null @@ -1,130 +0,0 @@ -file)) { - $url = $p->file; -} else { - $url = $oldfile; -} - -$desc = get_category_info(null); - -$content = file_get_contents($url); -$oldtitle = get_content_tag('t', $content, 'Untitled'); -$olddescription = get_content_tag('d', $content); -$oldtag = get_content_tag('tag', $content); -$oldimage = get_content_tag('image', $content); -$oldcontent = remove_html_comments($content); - -$dir = substr($url, 0, strrpos($url, '/')); -$isdraft = explode('/', $dir); -$oldurl = explode('_', $url); - -if (empty($oldtag)) { - $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], '/')) . '/'; - -// Category string -$cat = explode('/', $replaced); -$category = $cat[count($cat) - 3]; - -$dt = str_replace($replaced, '', $oldurl[0]); -$t = str_replace('-', '', $dt); -$time = new DateTime($t); -$timestamp = $time->format("Y-m-d H:i:s"); -// The post date -$postdate = strtotime($timestamp); -// The post URL -if (config('permalink.type') == 'post') { - $delete = site_url() . 'post/' . $oldmd . '/delete?destination=' . $destination; -} else { - // The post URL - $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; -} -?> - - - - - - - - - - -
    - -
    -
    - Title *


    - Category *
    - -

    - Tag *


    - Url (optional)

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

    - Year, Month, Day

    - Hour, Minute, Second


    - 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 deleted file mode 100644 index 67042d5..0000000 --- a/system/admin/views/edit-link.html.php +++ /dev/null @@ -1,131 +0,0 @@ -file)) { - $url = $p->file; -} else { - $url = $oldfile; -} - -$desc = get_category_info(null); - -$content = file_get_contents($url); -$oldtitle = get_content_tag('t', $content, 'Untitled'); -$olddescription = get_content_tag('d', $content); -$oldtag = get_content_tag('tag', $content); -$oldlink = get_content_tag('link', $content); -$oldcontent = remove_html_comments($content); - -$dir = substr($url, 0, strrpos($url, '/')); -$isdraft = explode('/', $dir); -$oldurl = explode('_', $url); - -if (empty($oldtag)) { - $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], '/')) . '/'; - -// Category string -$cat = explode('/', $replaced); -$category = $cat[count($cat) - 3]; - -$dt = str_replace($replaced, '', $oldurl[0]); -$t = str_replace('-', '', $dt); -$time = new DateTime($t); -$timestamp = $time->format("Y-m-d H:i:s"); -// The post date -$postdate = strtotime($timestamp); -// The post URL -if (config('permalink.type') == 'post') { - $delete = site_url() . 'post/' . $oldmd . '/delete?destination=' . $destination; -} else { - // The post URL - $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; -} - -?> - - - - - - - - - - -
    - -
    -
    - Title *


    - Category *
    - -

    - Tag *


    - Url (optional)

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

    - Year, Month, Day

    - Hour, Minute, Second


    - 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 dde61ce..6ce4e84 100644 --- a/system/admin/views/edit-page.html.php +++ b/system/admin/views/edit-page.html.php @@ -1,34 +1,65 @@ 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); -$oldcontent = remove_html_comments($content); +if ($type == 'is_frontpage') { + $filename = 'content/data/frontpage/frontpage.md'; + + if (file_exists($filename)) { + $content = file_get_contents($filename); + $oldtitle = get_content_tag('t', $content, 'Welcome'); + $oldcontent = remove_html_comments($content); + } else { + $oldtitle = 'Welcome'; + $oldcontent = 'Welcome to our website.'; + } +} elseif ($type == 'is_profile') { + + if (isset($_SESSION[config("site.url")]['user'])) { + $user = $_SESSION[config("site.url")]['user']; + } + + $filename = 'content/' . $user . '/author.md'; + + if (file_exists($filename)) { + $content = file_get_contents($filename); + $oldtitle = get_content_tag('t', $content, 'user'); + $oldcontent = remove_html_comments($content); + } else { + $oldtitle = $user; + $oldcontent = 'Just another HTMLy user.'; + } -if (isset($_GET['destination'])) { - $destination = $_GET['destination']; } else { - $destination = 'admin'; -} -$dir = substr($url, 0, strrpos($url, '/')); -$oldurl = str_replace($dir . '/', '', $url); -$oldmd = str_replace('.md', '', $oldurl); -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; - } + if (isset($p->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); + $oldcontent = remove_html_comments($content); + + if (isset($_GET['destination'])) { + $destination = $_GET['destination']; + } else { + $destination = 'admin'; + } + $dir = substr($url, 0, strrpos($url, '/')); + $oldurl = str_replace($dir . '/', '', $url); + $oldmd = str_replace('.md', '', $oldurl); + + 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; + } + } } ?> @@ -41,34 +72,45 @@ else { +
    +
    -
    - Title *


    - Url (optional)

    - If the url leave empty we will use the page title.

    - Meta Description (optional)
    -

    -
    -
    - - - Delete -
    +
    + Title * +
    +

    + + Url (optional)
    +
    + If the url leave empty we will use the page title. +

    + Meta Description (optional)
    +

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

    URL

    @@ -76,10 +118,6 @@ else {
    -
    diff --git a/system/admin/views/edit-post.html.php b/system/admin/views/edit-post.html.php deleted file mode 100644 index 384c868..0000000 --- a/system/admin/views/edit-post.html.php +++ /dev/null @@ -1,125 +0,0 @@ -file)) { - $url = $p->file; -} else { - $url = $oldfile; -} - -$desc = get_category_info(null); - -$content = file_get_contents($url); -$oldtitle = get_content_tag('t', $content, 'Untitled'); -$olddescription = get_content_tag('d', $content); -$oldtag = get_content_tag('tag', $content); -$oldcontent = remove_html_comments($content); - -$dir = substr($url, 0, strrpos($url, '/')); -$isdraft = explode('/', $dir); -$oldurl = explode('_', $url); - -if (empty($oldtag)) { - $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], '/')) . '/'; - -// Category string -$cat = explode('/', $replaced); -$category = $cat[count($cat) - 3]; - -$dt = str_replace($replaced, '', $oldurl[0]); -$t = str_replace('-', '', $dt); -$time = new DateTime($t); -$timestamp = $time->format("Y-m-d H:i:s"); -// The post date -$postdate = strtotime($timestamp); -// The post URL -if (config('permalink.type') == 'post') { - $delete = site_url() . 'post/' . $oldmd . '/delete?destination=' . $destination; -} else { - // The post URL - $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; -} - -?> - - - - - - - - - - -
    - -
    -
    - Title *


    - Category *
    - -

    - Tag *


    - Url (optional)

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

    - Year, Month, Day

    - Hour, Minute, Second


    - Meta Description (optional)
    -

    -
    -
    - - - - - Delete - - Delete - -
    -
    -
    -

    URL

    - -

    Upload

    -
    - -
    - -
    -
    - - - \ No newline at end of file diff --git a/system/admin/views/edit-profile.html.php b/system/admin/views/edit-profile.html.php deleted file mode 100644 index 0ab68f3..0000000 --- a/system/admin/views/edit-profile.html.php +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - -
    - -
    -
    - Title *


    -
    - -
    -
    - - -
    -
    -
    -

    URL

    - -

    Upload

    -
    - -
    - -
    -
    - - - \ No newline at end of file diff --git a/system/admin/views/edit-quote.html.php b/system/admin/views/edit-quote.html.php deleted file mode 100644 index f8f748f..0000000 --- a/system/admin/views/edit-quote.html.php +++ /dev/null @@ -1,131 +0,0 @@ -file)) { - $url = $p->file; -} else { - $url = $oldfile; -} - -$desc = get_category_info(null); - -$content = file_get_contents($url); -$oldtitle = get_content_tag('t', $content, 'Untitled'); -$olddescription = get_content_tag('d', $content); -$oldtag = get_content_tag('tag', $content); -$oldquote = get_content_tag('quote', $content); -$oldcontent = remove_html_comments($content); - -$dir = substr($url, 0, strrpos($url, '/')); -$isdraft = explode('/', $dir); -$oldurl = explode('_', $url); - -if (empty($oldtag)) { - $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], '/')) . '/'; - -// Category string -$cat = explode('/', $replaced); -$category = $cat[count($cat) - 3]; - -$dt = str_replace($replaced, '', $oldurl[0]); -$t = str_replace('-', '', $dt); -$time = new DateTime($t); -$timestamp = $time->format("Y-m-d H:i:s"); -// The post date -$postdate = strtotime($timestamp); -// The post URL -if (config('permalink.type') == 'post') { - $delete = site_url() . 'post/' . $oldmd . '/delete?destination=' . $destination; -} else { - // The post URL - $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; -} - -?> - - - - - - - - - - -
    - -
    -
    - Title *


    - Category *
    - -

    - Tag *


    - Url (optional)

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

    - Year, Month, Day

    - Hour, Minute, Second


    - Meta Description (optional)
    -

    - Featured Quote *


    -
    -
    - - - - - Delete - - Delete - -
    -
    -
    -

    URL

    - -

    Upload

    -
    - -
    - -
    -
    - - - \ No newline at end of file diff --git a/system/admin/views/layout.html.php b/system/admin/views/layout.html.php index 04892a4..92ffc77 100644 --- a/system/admin/views/layout.html.php +++ b/system/admin/views/layout.html.php @@ -7,7 +7,7 @@ - + diff --git a/system/htmly.php b/system/htmly.php index 04d8051..76ad099 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -205,10 +205,11 @@ get('/edit/profile', function () { if (login()) { config('views.root', 'system/admin/views'); - render('edit-profile', array( + render('edit-page', array( 'title' => 'Edit profile - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), + 'type' => 'is_profile', 'bodyclass' => 'editprofile', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit profile', )); @@ -241,13 +242,14 @@ post('/edit/profile', function () { } config('views.root', 'system/admin/views'); - render('edit-profile', array( + render('edit-page', array( 'title' => 'Edit profile - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'error' => '', 'postTitle' => $title, 'postContent' => $content, + 'type' => 'is_profile', 'bodyclass' => 'editprofile', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit profile' )); @@ -260,10 +262,11 @@ get('/edit/frontpage', function () { if (login()) { config('views.root', 'system/admin/views'); - render('edit-frontpage', array( + render('edit-page', array( 'title' => 'Edit frontpage - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), + 'type' => 'is_frontpage', 'bodyclass' => 'editfrontpage', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit frontpage', )); @@ -296,13 +299,14 @@ post('/edit/frontpage', function () { } config('views.root', 'system/admin/views'); - render('edit-frontpage', array( + render('edit-page', array( 'title' => 'Edit frontpage - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'error' => '', 'postTitle' => $title, 'postContent' => $content, + 'type' => 'is_frontpage', 'bodyclass' => 'editfrontpage', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit frontpage' )); @@ -322,17 +326,22 @@ get('/front/edit', function () { }); // Show the "Add post" page -get('/add/post', function () { +get('/add/content', function () { + + $req = $_GET['type']; + + $type = 'is_' . $req; if (login()) { config('views.root', 'system/admin/views'); - render('add-post', array( - 'title' => 'Add post - ' . blog_title(), + render('add-content', array( + 'title' => 'Add content - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), - 'bodyclass' => 'addpost', + 'type' => $type, + 'bodyclass' => 'addcontent', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add post' )); } else { @@ -342,7 +351,20 @@ get('/add/post', function () { }); // Submitted add post data -post('/add/post', function () { +post('/add/content', function () { + + $is_image = from($_REQUEST, 'is_image'); + $is_audio = from($_REQUEST, 'is_audio'); + $is_video = from($_REQUEST, 'is_video'); + $is_quote = from($_REQUEST, 'is_quote'); + $is_link = from($_REQUEST, 'is_link'); + $is_post = from($_REQUEST, 'is_post'); + + $link = from($_REQUEST, 'link'); + $image = from($_REQUEST, 'image'); + $audio = from($_REQUEST, 'audio'); + $video = from($_REQUEST, 'video'); + $quote = from($_REQUEST, 'quote'); $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); @@ -354,416 +376,266 @@ post('/add/post', function () { $user = $_SESSION[config("site.url")]['user']; $draft = from($_REQUEST, 'draft'); $category = from($_REQUEST, 'category'); - if ($proper && !empty($title) && !empty($tag) && !empty($content)) { - if (!empty($url)) { - add_post($title, $tag, $url, $content, $user, $description, $draft, $category); + + if (empty($is_post) && empty($is_image) && empty($is_video) && empty($is_audio) && empty($is_link) && empty($is_quote)) { + $add = site_url() . 'admin/content'; + header("location: $add"); + } + + if (!empty($is_post)) { + if ($proper && !empty($title) && !empty($tag) && !empty($content)) { + if (!empty($url)) { + add_content($title, $tag, $url, $content, $user, $description, null, $draft, $category, 'post'); + } else { + $url = $title; + add_content($title, $tag, $url, $content, $user, $description, null, $draft, $category, 'post'); + } } else { - $url = $title; - add_post($title, $tag, $url, $content, $user, $description, $draft, $category); - } - } 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 (!$proper) { - $message['error'] .= '
  • CSRF Token not correct.
  • '; + $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 (!$proper) { + $message['error'] .= '
  • CSRF Token not correct.
  • '; + } + config('views.root', 'system/admin/views'); + render('add-content', array( + 'title' => 'Add post- ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'type' => 'is_post', + 'bodyclass' => 'addpost', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add post' + )); } - config('views.root', 'system/admin/views'); - render('add-post', array( - 'title' => 'Add post- ' . blog_title(), - 'description' => blog_description(), - 'canonical' => site_url(), - 'error' => '', - 'postTitle' => $title, - 'postTag' => $tag, - 'postUrl' => $url, - 'postContent' => $content, - 'bodyclass' => 'addpost', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add post' - )); - } -}); - -// 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'); - $category = from($_REQUEST, 'category'); - if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) { - if (!empty($url)) { - add_image($title, $tag, $url, $content, $user, $description, $image, $draft, $category); + + if (!empty($is_image)) { + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) { + if (!empty($url)) { + add_content($title, $tag, $url, $content, $user, $description, $image, $draft, $category, 'image'); + } else { + $url = $title; + add_content($title, $tag, $url, $content, $user, $description, $image, $draft, $category, 'image'); + } } else { - $url = $title; - add_image($title, $tag, $url, $content, $user, $description, $image, $draft, $category); - } - } 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.
  • '; + $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-content', array( + 'title' => 'Add image - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postImage' => $image, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'type' => 'is_image', + 'bodyclass' => 'addpost', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add image' + )); } - config('views.root', 'system/admin/views'); - render('add-image', array( - 'title' => 'Add image - ' . 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 image' - )); } -}); - -// 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'); - $category = from($_REQUEST, 'category'); - if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) { - if (!empty($url)) { - add_video($title, $tag, $url, $content, $user, $description, $video, $draft, $category); + + if (!empty($is_video)) { + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) { + if (!empty($url)) { + add_content($title, $tag, $url, $content, $user, $description, $video, $draft, $category, 'video'); + } else { + $url = $title; + add_content($title, $tag, $url, $content, $user, $description, $video, $draft, $category, 'video'); + } } else { - $url = $title; - add_video($title, $tag, $url, $content, $user, $description, $video, $draft, $category); - } - } 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.
  • '; + $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-content', array( + 'title' => 'Add video - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postVideo' => $video, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'type' => 'is_video', + 'bodyclass' => 'addvideo', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add video' + )); } - config('views.root', 'system/admin/views'); - render('add-video', array( - 'title' => 'Add video - ' . 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 link - ' . 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'); - $category = from($_REQUEST, 'category'); - if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) { - if (!empty($url)) { - add_link($title, $tag, $url, $content, $user, $description, $link, $draft, $category); + + if (!empty($is_audio)) { + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) { + if (!empty($url)) { + add_content($title, $tag, $url, $content, $user, $description, $audio, $draft, $category, 'audio'); + } else { + $url = $title; + add_content($title, $tag, $url, $content, $user, $description, $audio, $draft, $category, 'audio'); + } } else { - $url = $title; - add_link($title, $tag, $url, $content, $user, $description, $link, $draft, $category); - } - } 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.
  • '; + $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-content', array( + 'title' => 'Add audio - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postAudio' => $audio, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'type' => 'is_audio', + 'bodyclass' => 'addaudio', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add audio' + )); } - 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'); - $category = from($_REQUEST, 'category'); - if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) { - if (!empty($url)) { - add_quote($title, $tag, $url, $content, $user, $description, $quote, $draft, $category); + + if (!empty($is_quote)) { + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) { + if (!empty($url)) { + add_content($title, $tag, $url, $content, $user, $description, $quote, $draft, $category, 'quote'); + } else { + $url = $title; + add_content($title, $tag, $url, $content, $user, $description, $quote, $draft, $category, 'quote'); + } } else { - $url = $title; - add_quote($title, $tag, $url, $content, $user, $description, $quote, $draft, $category); - } - } 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.
  • '; + $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-content', array( + 'title' => 'Add quote - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postQuote' => $quote, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'type' => 'is_quote', + 'bodyclass' => 'addquote', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add Quote' + )); } - 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'); - $category = from($_REQUEST, 'category'); - if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) { - if (!empty($url)) { - add_audio($title, $tag, $url, $content, $user, $description, $audio, $draft, $category); + + if (!empty($is_link)) { + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) { + if (!empty($url)) { + add_content($title, $tag, $url, $content, $user, $description, $link, $draft, $category, 'link'); + } else { + $url = $title; + add_content($title, $tag, $url, $content, $user, $description, $link, $draft, $category, 'link'); + } } else { - $url = $title; - add_audio($title, $tag, $url, $content, $user, $description, $audio, $draft, $category); - } - } 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.
  • '; + $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-content', array( + 'title' => 'Add link - ' . blog_title(), + 'description' => blog_description(), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postLink' => $link, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'type' => 'is_link', + 'bodyclass' => 'addlink', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add link' + )); } - 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 @@ -777,6 +649,7 @@ get('/add/page', function () { 'title' => 'Add page - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), + 'type' => 'is_page', 'bodyclass' => 'addpage', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add page' )); @@ -822,6 +695,7 @@ post('/add/page', function () { 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, + 'type' => 'is_page', 'bodyclass' => 'addpage', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add page' )); @@ -835,11 +709,12 @@ get('/add/category', function () { config('views.root', 'system/admin/views'); - render('add-category', array( + render('add-page', array( 'title' => 'Add page - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), - 'bodyclass' => 'addpage', + 'type' => 'is_category', + 'bodyclass' => 'addcategory', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add page' )); } else { @@ -876,7 +751,7 @@ post('/add/category', function () { $message['error'] .= '
  • CSRF Token not correct.
  • '; } config('views.root', 'system/admin/views'); - render('add-category', array( + render('add-page', array( 'title' => 'Add page - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), @@ -884,7 +759,8 @@ post('/add/category', function () { 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, - 'bodyclass' => 'addpage', + 'type' => 'is_category', + 'bodyclass' => 'addcategory', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add page' )); } @@ -1445,14 +1321,14 @@ get('/category/:category/edit', function ($category) { $post = $post[0]; - render('edit-category', array( + render('edit-page', array( 'title' => 'Edit category - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), + 'type' => 'is_category', 'bodyclass' => 'editpage', 'breadcrumb' => '' . config('breadcrumb.home') . ' » ' . $post->title, - 'p' => $post, - 'type' => 'categoryPage', + 'p' => $post )); } else { $login = site_url() . 'login'; @@ -1496,7 +1372,7 @@ post('/category/:category/edit', function () { } config('views.root', 'system/admin/views'); - render('edit-category', array( + render('edit-page', array( 'title' => 'Edit category - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), @@ -1505,6 +1381,7 @@ post('/category/:category/edit', function () { 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, + 'type' => 'is_category', 'bodyclass' => 'editcategory', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit category' )); @@ -1824,31 +1701,32 @@ get('/post/:name/edit', function ($name) { $current = $post['current']; if (isset($current->image)) { - $var = 'edit-image'; + $type= 'is_image'; } elseif (isset($current->link)) { - $var = 'edit-link'; + $type = 'is_link'; } elseif (isset($current->quote)) { - $var = 'edit-quote'; + $type = 'is_quote'; } elseif (isset($current->audio)) { - $var = 'edit-audio'; + $type = 'is_audio'; } elseif (isset($current->video)) { - $var = 'edit-video'; + $type = 'is_video'; } else { - $var = 'edit-post'; + $type = 'is_post'; } if ($user === $current->author || $role === 'admin') { - render($var, array( - 'title' => $var .' '. blog_title(), + render('edit-content', array( + 'title' => $type .' - '. blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'p' => $current, + 'type' => $type, 'bodyclass' => 'editcontent', 'breadcrumb' => '' . config('breadcrumb.home') . ' » ' . $current->tagb . ' » ' . $current->title )); } else { render('denied', array( - 'title' => $var .' '. blog_title(), + 'title' => $type .' - '. blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'p' => $current, @@ -1896,54 +1774,54 @@ post('/post/:name/edit', function () { } if (!empty($is_image)) { - $var = 'edit-image'; + $type = 'is_image'; } elseif (!empty($is_video)) { - $var = 'edit-video'; + $type = 'is_video'; } elseif (!empty($is_link)) { - $var = 'edit-link'; + $type = 'is_link'; } elseif (!empty($is_quote)) { - $var = 'edit-quote'; + $type = 'is_quote'; } elseif (!empty($is_audio)) { - $var = 'edit-audio'; + $type = 'is_audio'; } elseif (!empty($is_post)) { - $var = 'edit-post'; + $type = 'is_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, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $image, $revertPost, $publishDraft, $category, 'image'); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) { if (empty($url)) { $url = $title; } - edit_video($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $video, $revertPost, $publishDraft, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $video, $revertPost, $publishDraft, $category, 'video'); } 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, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $link, $revertPost, $publishDraft, $category, 'link'); } 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, $category); + edit_contente($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $quote, $revertPost, $publishDraft, $category, 'quote'); } 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, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $audio, $revertPost, $publishDraft, $category, 'audio'); } 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, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, null, $revertPost, $publishDraft, $category, 'post'); } else { $message['error'] = ''; @@ -1984,8 +1862,8 @@ post('/post/:name/edit', function () { config('views.root', 'system/admin/views'); - render($var, array( - 'title' => 'Edit content - ' . blog_title(), + render('edit-content', array( + 'title' => $type . ' - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'error' => '', @@ -1998,6 +1876,7 @@ post('/post/:name/edit', function () { 'postAudio' => $audio, 'postTag' => $tag, 'postUrl' => $url, + 'type' => $type, 'postContent' => $content, 'bodyclass' => 'editcontent', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit content' @@ -2236,6 +2115,7 @@ get('/:static/add', function ($static) { 'title' => 'Add page - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), + 'type' => 'is_page', 'bodyclass' => 'addpage', 'breadcrumb' => '' . config('breadcrumb.home') . ' » ' . $post->title . ' Add page' )); @@ -2281,8 +2161,9 @@ post('/:static/add', function ($static) { 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, + 'type' => 'is_page', 'bodyclass' => 'addpage', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » ' . $post->title . ' Add page' + 'breadcrumb' => '' . config('breadcrumb.home') . ' » ' . $title . ' Add page' )); } }); @@ -2686,31 +2567,32 @@ get('/:year/:month/:name/edit', function ($year, $month, $name) { $current = $post['current']; if (isset($current->image)) { - $var = 'edit-image'; + $type= 'is_image'; } elseif (isset($current->link)) { - $var = 'edit-link'; + $type = 'is_link'; } elseif (isset($current->quote)) { - $var = 'edit-quote'; + $type = 'is_quote'; } elseif (isset($current->audio)) { - $var = 'edit-audio'; + $type = 'is_audio'; } elseif (isset($current->video)) { - $var = 'edit-video'; + $type = 'is_video'; } else { - $var = 'edit-post'; + $type = 'is_post'; } if ($user === $current->author || $role === 'admin') { - render($var, array( - 'title' => $var .' '. blog_title(), + render('edit-content', array( + 'title' => $type .' - '. blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'p' => $current, + 'type' => $type, 'bodyclass' => 'editcontent', 'breadcrumb' => '' . config('breadcrumb.home') . ' » ' . $current->tagb . ' » ' . $current->title )); } else { render('denied', array( - 'title' => $var .' '. blog_title(), + 'title' => $type .' - '. blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'p' => $current, @@ -2758,54 +2640,54 @@ post('/:year/:month/:name/edit', function () { } if (!empty($is_image)) { - $var = 'edit-image'; + $type = 'is_image'; } elseif (!empty($is_video)) { - $var = 'edit-video'; + $type = 'is_video'; } elseif (!empty($is_link)) { - $var = 'edit-link'; + $type = 'is_link'; } elseif (!empty($is_quote)) { - $var = 'edit-quote'; + $type = 'is_quote'; } elseif (!empty($is_audio)) { - $var = 'edit-audio'; + $type = 'is_audio'; } elseif (!empty($is_post)) { - $var = 'edit-post'; + $type = 'is_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, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $image, $revertPost, $publishDraft, $category, 'image'); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) { if (empty($url)) { $url = $title; } - edit_video($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $video, $revertPost, $publishDraft, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $video, $revertPost, $publishDraft, $category, 'video'); } 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, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $link, $revertPost, $publishDraft, $category, 'link'); } 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, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $quote, $revertPost, $publishDraft, $category, 'quote'); } 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, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $audio, $revertPost, $publishDraft, $category, 'audio'); } 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, $category); + edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, null, $revertPost, $publishDraft, $category, 'post'); } else { $message['error'] = ''; @@ -2846,8 +2728,8 @@ post('/:year/:month/:name/edit', function () { config('views.root', 'system/admin/views'); - render($var, array( - 'title' => 'Edit content - ' . blog_title(), + render('edit-content', array( + 'title' => $type . ' - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'error' => '', @@ -2860,6 +2742,7 @@ post('/:year/:month/:name/edit', function () { 'postAudio' => $audio, 'postTag' => $tag, 'postUrl' => $url, + 'type' => $type, 'postContent' => $content, 'bodyclass' => 'editcontent', 'breadcrumb' => '' . config('breadcrumb.home') . ' » Edit content' diff --git a/system/includes/functions.php b/system/includes/functions.php index 2fb0664..a71b217 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -628,6 +628,9 @@ function get_profile_posts($name, $page, $perpage) // Return draft list function get_draft($profile, $page, $perpage) { + + $user = $_SESSION[config("site.url")]['user']; + $role = user('role', $user); $posts = get_draft_posts(); $tmp = array(); @@ -635,7 +638,7 @@ function get_draft($profile, $page, $perpage) foreach ($posts as $index => $v) { $str = explode('/', $v['dirname']); $author = $str[count($str) - 4]; - if (strtolower($profile) === strtolower($author)) { + if (strtolower($profile) === strtolower($author) || $role === 'admin') { $tmp[] = $v; } } @@ -969,12 +972,14 @@ function get_tagcount($var, $str) $posts = get_post_sorted(); $tmp = array(); - + foreach ($posts as $index => $v) { $arr = explode('_', $v[$str]); - $url = $arr[1]; - if (stripos($url, "$var") !== false) { - $tmp[] = $v; + $mtag = explode(',', rtrim($arr[1], ',')); + foreach ($mtag as $t) { + if (strtolower($t) === strtolower($var)) { + $tmp[] = $v; + } } } @@ -1889,6 +1894,13 @@ function get_menu($custom) } else { echo '
  • ' . config('breadcrumb.home') . '
  • '; } + if (config('blog.enable') == 'true' ) { + if ($req == site_path() . '/blog' || stripos($req, site_path() . '/blog?page') !== false) { + echo '
  • ' . 'Blog' . '
  • '; + } else { + echo '
  • ' . 'Blog' . '
  • '; + } + } echo ''; } } @@ -2454,7 +2466,7 @@ function toolbar() $base = site_url(); echo << + EOF; echo '
      '; echo '
    • Admin
    • '; diff --git a/system/resources/css/admin.css b/system/resources/css/admin.css new file mode 100644 index 0000000..1d26bbc --- /dev/null +++ b/system/resources/css/admin.css @@ -0,0 +1,1033 @@ +/*------------------------- + Simple reset +--------------------------*/ + +* { + margin: 0; + padding: 0; +} + +body { + font-family: Georgia, sans-serif, Arial; + font-size: 17px; + line-height: 1.6; + color: #343A3F; + padding: 0; + margin: 0; +} + +section, footer, header, aside, nav { + display: block; +} + +img { + border: 0 none; + height: auto; + max-width: 100%; + outline: 0 none; +} + +/*------------------------- + Heading +--------------------------*/ + +h1, h2, h3, h4, h5, h6 { + font-family: 'Open Sans', sans-serif; + line-height: 1.3; + margin: 0.5em 0; +} + +h1 { + font-size: 28px; +} + +h2 { + font-size: 24px; +} + +h3 { + font-size: 18px; +} + +h4 { + font-size: 16px; +} + +h5 { + font-size: 14px; +} + +h6 { + font-size: 12px; +} + +/*------------------------- + Layout +--------------------------*/ + +#outer-wrapper { + margin: 0; + padding: 0; + float: left; + width: 100%; +} + +#inner-wrapper { + padding: 0 10px; +} + +.container { + padding: 0 20px; +} + +#header-wrapper { + background: #546673; + position: relative; + padding: 1em 0; + float: left; + width: 100%; + color: #ffffff; + font-family: Georgia, sans-serif; + font-style: italic; +} + +#content-wrapper { + float: left; + width: 100%; + padding: 3em 0; +} + +#menu, #header, #content, #footer { + width: 800px; + margin: 0 auto; +} + +.admin #content { + width: 980px; + margin: 0 auto; +} + +#header { + text-align: center; +} + +.hide { + display: none; +} + +/*------------------------- + Link +--------------------------*/ + +a, a:visited { + outline: none; + color: #2E9FFF; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +.tab { + width: 100%; + margin: 1.5em 0 0 0; + line-height: 1; + border-bottom: 1px solid #E4E7EE; +} + +.tab ul { + padding:0; + margin:0; +} + +.tab li { + display: inline-block; + margin:0; + padding:0; +} + +.tab a { + background: #E4E7EE; + border-radius: 6px 6px 0px 0; + color: #555555; + text-align: center; + padding: 8px 14px; + display: inline-block; + margin: 0 5px; + font-size: 12px; + font-weight: bold; + font-family: 'Open Sans', sans-serif; +} + +/*------------------------- + Text element +--------------------------*/ + +blockquote:before { + color: #BBBBBB; + content: "''"; + font-size: 3em; + line-height: 0.1em; + margin-right: 0.2em; + vertical-align: -0.4em; +} + +blockquote:after { + color: #BBBBBB; + content: "''"; + font-size: 3em; + line-height: 0.1em; + vertical-align: -0.45em; +} + +blockquote { + font-style: italic; + margin: 1em 0 1em 1em; +} + +blockquote p { + display: inline; +} + +pre { + margin: 1em 0; + overflow: auto; + background: #F1F1FF; + color: #333333; + display: block; + font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif; + font-size: 14px; + padding: 10px; + line-height: 1.3; +} + +code { + color: #333333; + font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif; + font-size: 15px; + padding: 3px 8px; + background: #F1F1FF; +} + +pre code { + color: #333333; + display: block; + font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif; + font-size: 14px; + padding: 0; + line-height: 1.6; +} + +.thumbnail { + float: left; + height: 80px; + width: 80px; + margin: 5px 15px 0 0; + overflow: hidden; + display: block; + background-repeat: no-repeat; + background-position: center; + background-size: cover; +} + +ul, ol { + padding-left: 30px; + margin: 1em 0; +} + +ul li, ol li { + margin: 0.25em 0; +} + +input[type=text], input[type=password] { + padding: 4px 6px; + font-size: 14px; + background-color: #F6F7F9; + border: 1px solid #CFDAE5; +} + +input[type=text]:hover, input[type=password]:hover { + background-color: #F6F7F9; + border: 1px solid #CCCCCC; +} + +input[type=submit] { + padding: 4px 6px; + font-size: 14px; + cursor: pointer; +} + +input.text { + width: 75%; + padding: 5px; + font-size: 14px; + background-color: #F6F7F9; + border: 1px solid #CFDAE5; +} + +input.error, textarea.error { + border: 1px solid red; +} + +textarea { + font-size: 15px; + font-family: Georgia, sans-serif; + line-height: 1.4; + background-color: #F6F7F9; + border: 1px solid #CFDAE5; + padding: 2%; + width: 96%; + min-height: 5em; + overflow: auto; +} + +textarea:hover { + border: 1px solid #CCCCCC; +} + +.error-message { + color: red; + background: #f4f4f4; + padding: 10px 0; + margin-bottom: 2em; +} + +span.required { + color: red; +} + +span.help { + font-size: 12px; + font-style: italic; +} + +.category { + background-color: #f9f9f9; + border: 1px solid #ccc; + border-radius: 4px; + color: #333; + display: block; + font-size: 13px; + margin: 20px 0; + padding: 0 1em; +} + +.tags a:after { + content:", "; +} +.tags a:last-child:after { + content:""; +} + +/*------------------------- + Table +--------------------------*/ + +table { + font-size: 12px; + border: none; + width: 100%; + color: #333333; + border: 1px solid #E3E3E3; + margin: 1em 0; + white-space: pre-wrap; + word-wrap: break-word; +} + +table h2.title { + margin: 5px 0; +} + +th, td { + padding: 5px 10px; + border: none; +} + +th.title { + margin: 5px 0; + font-family: 'Open Sans', sans-serif; + font-size: 16px; + font-weight: normal; +} + +td.title { + font-weight: normal; + background-color: #f6f6f6; + font-family: 'Open Sans', sans-serif; +} + +th { + background-color: #f6f6f6; + border-bottom: 1px solid #E3E3E3; + border-right: 1px solid #E3E3E3; + font-family: 'Open Sans', sans-serif; + font-size: 16px; +} + +td { + background-color: #fafafa; + border: 1px solid #E3E3E3; + border-top: none; + border-left: none; +} + +table.post-list td a { + margin: 0 5px; +} + +/*------------------------- + Menu +--------------------------*/ + +#menu-wrapper { + font-family: 'Open Sans', sans-serif; + color: #7E909D; + padding: 10px 0; + float: left; + width: 100%; +} + +#menu { + font-weight: bold; + font-family: 'Open Sans', sans-serif; + color: #7E909D; + font-size: 14px; +} + +#menu ul { + margin: 0; + padding: 0; +} + +#menu a { + color: #7E909D; +} + +#menu ul li { + float: left; + margin: 0 20px 0 0; + list-style: none; + padding-top: 3px; +} + +#menu ul li.active > a { + text-decoration: underline; +} + +#menu ul li:last-child { + margin: 0; +} + +#menu ul li ul.subnav { + display:none; +} + +/*---------------------------- + Search form +-----------------------------*/ + +#search-form { + position: relative; + float: right; +} + +.error-404 .post #search-form, +.error-404-search .post #search-form { + float: none; +} + +.search-input { + margin: 0; + padding: 4px 15px; + font-size: 14px; + border: 1px solid #0076a3 !important; + background: #FFFFFF !important; + border-top-left-radius: 5px 5px; + border-bottom-left-radius: 5px 5px; + width: 120px; + color: #888888; +} + +.search-button { + margin: 0; + padding: 4px; + font-size: 14px; + outline: none; + cursor: pointer; + text-align: center; + text-decoration: none; + color: #ffffff; + border: solid 1px #546673; + border-right: 0px; + background: #0095cd; + background: -webkit-gradient(linear, left top, left bottom, from(#2E9FFF), to(#2E9CCC)); + background: -moz-linear-gradient(top, #2E9FFF, #2E9CCC); + border-top-right-radius: 5px 5px; + border-bottom-right-radius: 5px 5px; + width: 60px; +} + +.search-button:hover { + text-decoration: none; + background: #007ead; + background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e)); + background: -moz-linear-gradient(top, #0095cc, #00678e); +} + +/* Fixes submit button height problem in Firefox */ +.search-button::-moz-focus-inner { + border: 0; +} + +/*------------------------- + Post +--------------------------*/ + +.post { + border-bottom: 1px solid #EBF2F6; + padding: 1em 0; + float: left; + width: 100%; +} + +.inpost .post { + padding-bottom: 0; +} + +p, ul { + margin: 1em 0; +} + +.breadcrumb { + font-family: 'Open Sans', sans-serif; + font-size: 14px; + font-weight: normal; +} + +.date { + font-family: 'Open Sans', sans-serif; + font-size: 14px; + color: #A7A7A7; + font-weight: normal; + margin: 1em 0; +} + +h1.blog-title, h2.blog-title { + font-style: normal; + font-size: 28px; +} + +h1.title-post a, h2.title-index a { + color: #4f4f4f; + text-decoration: none; +} + +h1.title-post a:hover, h2.title-index a:hover { + color: #2E9FFF; +} + +.inpost .post { + padding-top: 0; + border: none; +} + +.inpage .border { + padding: 0; + margin: 0; + border: 0; +} + +.inpage .post { + padding-top: 0; +} + +.infront .first, .inpost .post, .intag .first, .inarchive .first, .insearch .first, .error-404 .post, .error-404-search .post { + padding-top: 0; +} + +.infront .first h2.title-index { + margin-top: 0; +} + +.inprofile .bio { + font-size: 14px; + font-style: italic; + border-bottom: 1px solid #EBF2F6; + padding-bottom: 1em; + margin-bottom: 2em; +} + +.post-list { + font-size: 14px; +} + +/*------------------------- + Share box +--------------------------*/ + +.separator { + font-size: 20px; +} + +.share-box { + font-size: 14px; + float: left; +} + +.author-info { + width: 540px; + float: left; +} + +.author-info p { + font-style: italic; +} + +.share { + width: 140px; + margin-right: 1em; + float: right; +} + +.share a { + display: inline-block; + width: 18px; + height: 18px; + margin: 0; + padding: 0 5px; + vertical-align: middle; + -o-transition: all .3s; + -moz-transition: all .3s; + -webkit-transition: all .3s; + -ms-transition: all .3s; + text-indent: -9999em; +} + +.share a.twitter { + background: url(../img/share-twitter.png) left top no-repeat; +} + +.share a.facebook { + background: url(../img/share-facebook.png) left top no-repeat; +} + +.share a.googleplus { + background: url(../img/share-googleplus.png) left top no-repeat; +} + +.share a:hover { + background-position: left -26px; +} + +/*------------------------- + Comments +--------------------------*/ + +.comments { + position: relative; + display: block; + font-size: 16px; + float: left; + width: 100%; +} + +.border { + border-top: 1px solid #DFDFDF; + margin-bottom: 15px; + margin-top: 10px; + padding-bottom: 15px; + width: 100%; + float: left; +} + +.border .fb-comments, .border #disqus_thread { + padding-top: 1.2em; +} + +#disqus_thread { + font-family: Georgia, Times, Cambria, serif; + float: left; + width: 100%; +} + +/*------------------------- + Raleted posts +--------------------------*/ + +.related { + font-size: 14px; + font-family: 'Open Sans', sans-serif; + width: 100%; + float: left; + margin-bottom: 1em; +} + +.related ul { + margin: 0; +} + +/*------------------------- + Pagination + Postnav +--------------------------*/ + +.postnav { + width: 100%; + float: left; + padding-bottom: 1em; + font-family: 'Open Sans', sans-serif; + font-size: 12px; + font-weight: bold; +} + +.postnav a { + background: none repeat scroll 0 0 #E4E7EE; + border-radius: 3px; + color: #555555; + line-height: 1; + text-align: center; +} + +.postnav a:hover { + text-decoration: none; + color: #333333; +} + +.postnav .newer { + float: left; + margin-right: 1em; + margin-bottom: 0.1em; + padding: 10px 15px 10px 25px; +} + +.postnav .older { + float: right; + padding: 10px 25px 10px 15px; +} + +.postnav .pagination-arrow { + display: inline-block; + border-radius: 3px; + color: #555 !important; + text-decoration: none !important; + text-transform: none; + position: relative; +} + +.postnav .pagination-arrow.newer:before, +.postnav .pagination-arrow.older:before { + content: ''; + border: 5px solid #555; + border-color: transparent #555 transparent transparent; + width: 0; + height: 0; + position: absolute; + left: 5px; + top: 12px; +} + +.postnav .pagination-arrow.older:before { + left: auto; + right: 5px; + border-color: transparent transparent transparent #555; +} + +.pager { + width: 100%; + float: left; + padding: 30px 0 1em 0; + font-family: 'Open Sans', sans-serif; + font-size: 12px; + font-weight: bold; +} + +.pager a { + background: none repeat scroll 0 0 #E4E7EE; + border-radius: 3px; + color: #555555; + line-height: 1; + padding: 10px 20px; + text-align: center; +} + +.pager .newer { + float: left; +} + +.pager .older { + float: right; +} + +.pager a:hover { + text-decoration: none; + color: #333333; +} + +/*------------------------- + Footer +--------------------------*/ + +#footer-wrapper { + background: #546673; + position: relative; + padding: 20px 0; + float: left; + width: 100%; + color: #ABB6C5; + font-family: 'Open Sans', sans-serif; +} + +#footer { + font-size: 14px; +} + +#footer a { + color: #CBD2DC; + font-weight: bold; +} + +#footer ul { + margin: 0.5em 0; +} + +.footer-column { + padding-bottom: 1.5em; + float: left; + width: 100%; +} + +.column { + float: left; + width: 25%; +} + +.recent ul { + padding-left: 20px; + width: 85%; +} + +.archive .toggle { + font-family: Georgia, Arial, sans-serif; + font-size: 16px; +} + +.social { + float: right; +} + +.social .inner { + padding-left: 30px; +} + +.tagcloud ul { + padding: 0; + margin: 0; +} + +.tagcloud ul li { + float: left; + list-style: none; + margin-right: 10px; +} + +.copyright { + font-size: 12px; + float: left; + width: 100%; + border-top: 1px solid #ABB6C5; + padding-top: 1em; +} + +.copyright p { + margin: 0.5em 0; + line-height: 1.2; +} + +/*---------------------------- + The 404 page +-----------------------------*/ + +.message { + padding: 50px 20px 20px 20px; +} + +.message h1 { + font-size: 36px; + margin-bottom: 18px; +} + +.message p { + font-size: 13px; +} + +.center { + text-align: center; +} + +.search-404 { + position: relative; + float: left; + width: 100%; + margin-bottom: 1.2em; +} + +.search-404 #search-form { + float: none; +} + +/*---------------------------- + Media queries +-----------------------------*/ + +@media all and (max-width: 700px) { + + #menu, #header, #content, #footer { + margin: 0 auto; + width: 100%; + } + + .admin #menu, .admin #header, .admin #content, .admin #footer { + margin: 0 auto; + width: 100%; + } + + #menu-wrapper { + text-align: center; + } + + #menu ul li { + float: none; + display: inline-block; + } + + #search-form { + float: none; + padding: 10px 0; + } + + .author-info { + width: 100%; + float: left; + } + + .share { + width: 100%; + margin-right: 0; + padding-bottom: 1em; + } + + .column { + float: left; + width: 100%; + } + + .postnav .newer { + float: left; + margin-bottom: 1em; + } + + .postnav .older { + float: left; + } + + .social .inner { + padding-left: 0px; + } + + pre { + white-space: pre-wrap; + word-wrap: break-word; + } + +} + +/*---------------------------- + Video +-----------------------------*/ + +.video-wrapper { + margin: 1em 0; +} + +@media all and (min-width: 420px) { + + .video-wrapper { + padding-top: 315px !important; + position: relative; + width: 100%; + max-width: 420px !important; + max-height: 315px !important; + } + + .video-wrapper iframe, .video-wrapper object, .video-wrapper embed { + height: 100%; + left: 0; + position: absolute; + top: 0; + max-width: 420px !important; + width: 100%; + max-height: 315px !important; + } + +} + +@media all and (max-width: 420px) { + + .video-wrapper { + position: relative; + padding-bottom: 56.25%; + padding-top: 30px; + height: 0; + overflow: hidden; + } + + .video-wrapper iframe, .video-wrapper object, .video-wrapper embed { + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + } + +} + +@media all and (max-width: 560px) { + + .featured-video, .featured-audio { + position: relative; + padding-bottom: 56.25%; + padding-top: 30px; + height: 0; + overflow: hidden; + } + + .featured-video iframe, .featured-video object, .featured-video embed, .featured-audio iframe, .featured-audio object, .featured-audio embed { + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + } + +} + +/*---------------------------- + Archive +-----------------------------*/ + +ul.archivegroup { + padding: 0; + margin: 0; +} + +.archivegroup .expanded ul { + display: block; +} + +.archivegroup .collapsed ul { + display: none; +} + +.archivegroup li.expanded, .archivegroup li.collapsed { + list-style: none; +} \ No newline at end of file diff --git a/themes/default/css/toolbar.css b/system/resources/css/toolbar.css similarity index 100% rename from themes/default/css/toolbar.css rename to system/resources/css/toolbar.css diff --git a/upload.php b/upload.php index 703e16f..791e8b7 100644 --- a/upload.php +++ b/upload.php @@ -22,8 +22,7 @@ $path = null; if (login()) { - if (is_dir($dir)) { - } else { + if (!is_dir($dir)) { mkdir($dir, 0755, true); } @@ -39,7 +38,7 @@ if (login()) { if($check !== false) { if ($error === UPLOAD_ERR_OK) { $extension = pathinfo($name, PATHINFO_EXTENSION); - if (!in_array($extension, $whitelist)) { + if (!in_array(strtolower($extension), $whitelist)) { $error = 'Invalid file type uploaded.'; } else { move_uploaded_file($tmp_name, $dir . $timestamp . '-' . $name);