From 3b7df7d3c3447f70f36e15426b9a0e017cb3ab3a Mon Sep 17 00:00:00 2001 From: danpros Date: Wed, 31 Mar 2021 12:35:36 +0700 Subject: [PATCH] Update htmly.php --- system/htmly.php | 373 +++++++++++++++++-------------------------------------- 1 file changed, 114 insertions(+), 259 deletions(-) diff --git a/system/htmly.php b/system/htmly.php index 4d9bd28..18e215a 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -430,6 +430,20 @@ post('/add/content', function () { $is_quote = from($_REQUEST, 'is_quote'); $is_link = from($_REQUEST, 'is_link'); $is_post = from($_REQUEST, 'is_post'); + + if (!empty($is_image)) { + $type = 'is_image'; + } elseif (!empty($is_video)) { + $type = 'is_video'; + } elseif (!empty($is_link)) { + $type = 'is_link'; + } elseif (!empty($is_quote)) { + $type = 'is_quote'; + } elseif (!empty($is_audio)) { + $type = 'is_audio'; + } elseif (!empty($is_post)) { + $type = 'is_post'; + } $link = from($_REQUEST, 'link'); $image = from($_REQUEST, 'image'); @@ -453,265 +467,106 @@ post('/add/content', function () { 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 { - $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' => strip_tags(blog_description()), - 'canonical' => site_url(), - 'error' => '', - 'postTitle' => $title, - 'postTag' => $tag, - 'postUrl' => $url, - 'postContent' => $content, - 'type' => 'is_post', - 'is_admin' => true, - 'bodyclass' => 'add-post', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add post' - )); - } - } - - 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 { - $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' => strip_tags(blog_description()), - 'canonical' => site_url(), - 'error' => '', - 'postTitle' => $title, - 'postImage' => $image, - 'postTag' => $tag, - 'postUrl' => $url, - 'postContent' => $content, - 'type' => 'is_image', - 'is_admin' => true, - 'bodyclass' => 'add-image', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add image' - )); - } - } - - 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 { - $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' => strip_tags(blog_description()), - 'canonical' => site_url(), - 'error' => '', - 'postTitle' => $title, - 'postVideo' => $video, - 'postTag' => $tag, - 'postUrl' => $url, - 'postContent' => $content, - 'type' => 'is_video', - 'is_admin' => true, - 'bodyclass' => 'add-video', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add video' - )); - } - } - - 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 { - $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' => strip_tags(blog_description()), - 'canonical' => site_url(), - 'error' => '', - 'postTitle' => $title, - 'postAudio' => $audio, - 'postTag' => $tag, - 'postUrl' => $url, - 'postContent' => $content, - 'type' => 'is_audio', - 'is_admin' => true, - 'bodyclass' => 'add-audio', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add audio' - )); - } - } - - 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 { - $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' => strip_tags(blog_description()), - 'canonical' => site_url(), - 'error' => '', - 'postTitle' => $title, - 'postQuote' => $quote, - 'postTag' => $tag, - 'postUrl' => $url, - 'postContent' => $content, - 'type' => 'is_quote', - 'is_admin' => true, - 'bodyclass' => 'add-quote', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add Quote' - )); - } - } - - 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 { - $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' => strip_tags(blog_description()), - 'canonical' => site_url(), - 'error' => '', - 'postTitle' => $title, - 'postLink' => $link, - 'postTag' => $tag, - 'postUrl' => $url, - 'postContent' => $content, - 'type' => 'is_link', - 'is_admin' => true, - 'bodyclass' => 'add-link', - 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add link' - )); - } - } + if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) { + 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'); + } + } elseif ($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'); + } + } elseif ($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'); + } + } elseif ($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'); + } + } elseif ($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'); + } + } elseif ($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 { + $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.
  • '; + } + + if (!empty($is_image)) { + if (empty($image)) { + $message['error'] .= '
  • Image field is required.
  • '; + } + } elseif (!empty($is_video)) { + if (empty($video)) { + $message['error'] .= '
  • Video field is required.
  • '; + } + } elseif (!empty($is_link)) { + if (empty($link)) { + $message['error'] .= '
  • Link field is required.
  • '; + } + } elseif (!empty($is_quote)) { + if (empty($quote)) { + $message['error'] .= '
  • Quote field is required.
  • '; + } + } elseif (!empty($is_audio)) { + if (empty($audio)) { + $message['error'] .= '
  • Audio field is required.
  • '; + } + } + + config('views.root', 'system/admin/views'); + render('add-content', array( + 'title' => 'Add content - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'error' => '', + 'postTitle' => $title, + 'postImage' => $image, + 'postVideo' => $video, + 'postLink' => $link, + 'postQuote' => $quote, + 'postAudio' => $audio, + 'postTag' => $tag, + 'postUrl' => $url, + 'postContent' => $content, + 'type' => $type, + 'is_admin' => true, + 'bodyclass' => 'add-content', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Add content' + )); + } });