Update admin.php

This commit is contained in:
danpros 2021-03-02 15:37:45 +07:00
commit c90de0a859

View file

@ -85,14 +85,33 @@ function remove_accent($str)
function add_content($title, $tag, $url, $content, $user, $description = null, $media = null, $draft, $category, $type)
{
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
$tag = array_filter(array_unique($tag));
$taglang = array_flip(unserialize(file_get_contents('content/data/tags.lang')));
$tflip = array_intersect_key($taglang, array_flip($tag));
$post_tag = array();
$post_tagmd = array();
foreach ($tag as $t) {
if (array_key_exists($t, $tflip)) {
foreach ($tflip as $tfp => $tf){
if($t === $tfp) {
$post_tag[] = $tf;
$post_tagmd[] = $tfp;
}
}
} else {
$post_tag[] = $t;
$post_tagmd[] = $t;
}
}
$post_tag = safe_tag(implode(',', $post_tag));
$post_tagmd = safe_html(implode(',', $post_tagmd));
$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 = safe_html($tag);
$post_tag = rtrim($post_tag, ',');
$post_tagmd = preg_replace("/\s*,\s*/", ",", rtrim($post_tagmd, ','));
$post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($post_tag)));
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$description = safe_html($description);
@ -177,6 +196,30 @@ function add_content($title, $tag, $url, $content, $user, $description = null, $
// Edit content
function edit_content($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $media = null, $revertPost, $publishDraft, $category, $type)
{
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
$tag = array_filter(array_unique($tag));
$taglang = array_flip(unserialize(file_get_contents('content/data/tags.lang')));
$tflip = array_intersect_key($taglang, array_flip($tag));
$post_tag = array();
$post_tagmd = array();
foreach ($tag as $t) {
if (array_key_exists($t, $tflip)) {
foreach ($tflip as $tfp => $tf){
if($t === $tfp) {
$post_tag[] = $tf;
$post_tagmd[] = $tfp;
}
}
} else {
$post_tag[] = $t;
$post_tagmd[] = $t;
}
}
$post_tag = safe_tag(implode(',', $post_tag));
$post_tagmd = safe_html(implode(',', $post_tagmd));
$oldurl = explode('_', $oldfile);
$dir = explode('/', $oldurl[0]);
$olddate = date('Y-m-d-H-i-s', strtotime($date));
@ -187,11 +230,7 @@ function edit_content($title, $tag, $url, $content, $oldfile, $destination = nul
$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 = safe_html($tag);
$post_tag = rtrim($post_tag, ',');
$post_tagmd = preg_replace("/\s*,\s*/", ",", rtrim($post_tagmd, ','));
$post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($post_tag)));
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$description = safe_html($description);