From d0f120a3522b7dc3253293d092c4ffbf55ef4028 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Mon, 5 Sep 2022 15:29:39 +0800 Subject: [PATCH] clear rules + faq cache in time --- nexus/Install/Install.php | 15 +++++++++++++++ public/faqactions.php | 10 +++++++++- public/js/nexus.js | 9 +++++---- public/js/ptgen.js | 8 ++++---- public/modrules.php | 7 +++++++ 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/nexus/Install/Install.php b/nexus/Install/Install.php index 6ec9966e..a610ad9a 100644 --- a/nexus/Install/Install.php +++ b/nexus/Install/Install.php @@ -161,6 +161,21 @@ class Install 'result' => $this->yesOrNo(version_compare(PHP_VERSION, $this->minimumPhpVersion, '>=')), ]; + $requiredFunctions = ['symlink', 'putenv', 'proc_open', 'proc_get_status', 'exec']; + $disabledFunctions = []; + foreach ($requiredFunctions as $fn) { + if (!function_exists($fn)) { + $disabledFunctions[] = $fn; + } + } + + $tableRows[] = [ + 'label' => 'Required functions', + 'required' => 'true', + 'current' => empty($disabledFunctions) ? '1' : "These functions are Disabled: " . implode(',', $disabledFunctions), + 'result' => $this->yesOrNo(empty($disabledFunctions)), + ]; + foreach ($this->requiredExtensions as $extension) { $tableRows[] = [ 'label' => "PHP extension $extension", diff --git a/public/faqactions.php b/public/faqactions.php index 50441f51..f4bc22f2 100644 --- a/public/faqactions.php +++ b/public/faqactions.php @@ -28,6 +28,10 @@ if (get_user_class() < UC_ADMINISTRATOR) { stderr("Error","Only Administrators and above can modify the FAQ, sorry."); } +function clear_faq_cache() +{ + \Nexus\Database\NexusDB::cache_del('faq'); +} //stdhead("FAQ Management"); // ACTION: reorder - reorder sections and items @@ -93,6 +97,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == "edititem" && $_POST['id'] $question = $_POST['question']; $answer = $_POST['answer']; sql_query("UPDATE `faq` SET `question`=".sqlesc($question).", `answer`=".sqlesc($answer).", `flag`=".sqlesc($_POST['flag']).", `categ`=".sqlesc($_POST['categ'])." WHERE id=".sqlesc($_POST['id'])) or sqlerr(); + clear_faq_cache(); header("Location: " . get_protocol_prefix() . "$BASEURL/faqmanage.php"); die; } @@ -101,6 +106,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == "edititem" && $_POST['id'] elseif (isset($_GET['action']) && $_GET['action'] == "editsect" && $_POST['id'] != NULL && $_POST['title'] != NULL && $_POST['flag'] != NULL) { $title = $_POST['title']; sql_query("UPDATE `faq` SET `question`=".sqlesc($title).", `answer`='', `flag`=".sqlesc($_POST['flag']).", `categ`='0' WHERE id=".sqlesc($_POST['id'])) or sqlerr(); + clear_faq_cache(); header("Location: " . get_protocol_prefix() . "$BASEURL/faqmanage.php"); die; } @@ -171,12 +177,13 @@ elseif (isset($_GET['action']) && $_GET['action'] == "addnewitem" && $_POST['que $categ = intval($_POST['categ'] ?? 0); $langid = intval($_POST['langid'] ?? 0); $res = sql_query("SELECT MAX(`order`) AS maxorder, MAX(`link_id`) AS maxlinkid FROM `faq` WHERE `type`='item' AND `categ`=".sqlesc($categ)." AND lang_id=".sqlesc($langid)); - while ($arr = mysql_fetch_array($res, MYSQLI_BOTH)) + while ($arr = mysql_fetch_array($res, MYSQLI_BOTH)) { $order = $arr['maxorder'] + 1; $link_id = $arr['maxlinkid']+1; } sql_query("INSERT INTO `faq` (`link_id`, `type`, `lang_id`, `question`, `answer`, `flag`, `categ`, `order`) VALUES ('$link_id', 'item', ".sqlesc($langid).", ".sqlesc($question).", ".sqlesc($answer).", " . sqlesc(intval($_POST['flag'] ?? 0)) . ", ".sqlesc($categ).", ".sqlesc($order).")") or sqlerr(); + clear_faq_cache(); header("Location: " . get_protocol_prefix() . "$BASEURL/faqmanage.php"); die; } @@ -188,6 +195,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == "addnewsect" && $_POST['tit $res = sql_query("SELECT MAX(`order`) AS maxorder, MAX(`link_id`) AS maxlinkid FROM `faq` WHERE `type`='categ' AND `lang_id` = ".sqlesc($language)); while ($arr = mysql_fetch_array($res, MYSQLI_BOTH)) {$order = $arr['maxorder'] + 1;$link_id = $arr['maxlinkid']+1;} sql_query("INSERT INTO `faq` (`link_id`,`type`,`lang_id`, `question`, `answer`, `flag`, `categ`, `order`) VALUES (".sqlesc($link_id).",'categ', ".sqlesc($language).", ".sqlesc($title).", '', ".sqlesc($_POST['flag']).", '0', ".sqlesc($order).")") or sqlerr(); + clear_faq_cache(); header("Location: " . get_protocol_prefix() . "$BASEURL/faqmanage.php"); die; } else { diff --git a/public/js/nexus.js b/public/js/nexus.js index e3617c36..b0dbe244 100644 --- a/public/js/nexus.js +++ b/public/js/nexus.js @@ -62,11 +62,11 @@ jQuery(document).ready(function () { height: position.imgHeight } } - var previewEle = null + var previewEle = jQuery('#nexus-preview') var imgEle, selector = 'img.preview', imgPosition jQuery("body").on("mouseover", selector, function (e) { imgEle = jQuery(this); - previewEle = jQuery('').appendTo(imgEle.parent()) + // previewEle = jQuery('').appendTo(imgEle.parent()) imgPosition = getImgPosition(e, imgEle) let position = getPosition(e, imgPosition) let src = imgEle.attr("src") @@ -74,8 +74,9 @@ jQuery(document).ready(function () { previewEle.attr("src", src).css(position).fadeIn("fast"); } }).on("mouseout", selector, function (e) { - previewEle.remove() - previewEle = null + // previewEle.remove() + // previewEle = null + previewEle.hide() }).on("mousemove", selector, function (e) { let position = getPosition(e, imgPosition) previewEle.css(position) diff --git a/public/js/ptgen.js b/public/js/ptgen.js index 798db0da..8dba6876 100644 --- a/public/js/ptgen.js +++ b/public/js/ptgen.js @@ -31,6 +31,7 @@ jQuery('.btn-get-pt-gen').on('click', function () { function autoSelect(value) { // console.log(`autoSelect: ${value}`) + value = value.replace(/[-\/\.]+/ig, '').toUpperCase(); let names = ["source_sel", "medium_sel", "codec_sel", "audiocodec_sel", "standard_sel", "processing_sel", "team_sel"]; for (let i = 0; i < names.length; i++) { const name = names[i]; @@ -38,11 +39,10 @@ function autoSelect(value) { // console.log("check name: " + name) select.children("option").each(function (index, option) { let _option = jQuery(option) - let optionText = _option.text(); + let optionText = _option.text().replace(/[-\/\.]+/ig, '').toUpperCase(); // console.log("check option text: " + optionText + " match value: " + value) - let pattern = new RegExp(value, "i"); - if (optionText.match(pattern)) { - console.log(`name: ${name}, optionText: ${optionText} match value: ${value}, break`) + if (optionText == value) { + console.log(`name: ${name}, optionText: ${optionText} === value: ${value}, break`) select.val(option.getAttribute('value')) return false } diff --git a/public/modrules.php b/public/modrules.php index 02421ea2..b4e176ab 100644 --- a/public/modrules.php +++ b/public/modrules.php @@ -5,6 +5,10 @@ loggedinorreturn(); if (get_user_class() < UC_ADMINISTRATOR) { stderr("Error","Only Administrators and above can modify the Rules, sorry."); } +function clear_rules_cache() +{ + \Nexus\Database\NexusDB::cache_del('rules'); +} if (isset($_GET["act"]) && $_GET["act"] == "newsect") { @@ -35,6 +39,7 @@ elseif (isset($_GET["act"]) && $_GET["act"]=="addsect"){ $text = $_POST["text"]; $language = $_POST["language"]; sql_query("insert into rules (title, text, lang_id) values(".sqlesc($title).", ".sqlesc($text).", ".sqlesc($language).")") or sqlerr(__FILE__,__LINE__); + clear_rules_cache(); header("Refresh: 0; url=modrules.php"); } elseif (isset($_GET["act"]) && $_GET["act"] == "edit"){ @@ -68,6 +73,7 @@ elseif (isset($_GET["act"]) && $_GET["act"]=="edited"){ $text = $_POST["text"]; $language = $_POST["language"]; sql_query("update rules set title=".sqlesc($title).", text=".sqlesc($text).", lang_id = ".sqlesc($language)." where id=".sqlesc($id)) or sqlerr(__FILE__,__LINE__); + clear_rules_cache(); header("Refresh: 0; url=modrules.php"); } elseif (isset($_GET["act"]) && $_GET["act"]=="del"){ @@ -78,6 +84,7 @@ elseif (isset($_GET["act"]) && $_GET["act"]=="del"){ stderr("Delete Rule","You are about to delete a rule. Click here if you are sure.",false); } sql_query("DELETE FROM rules WHERE id=".sqlesc($id)) or sqlerr(__FILE__, __LINE__); + clear_rules_cache(); header("Refresh: 0; url=modrules.php"); } else{