diff --git a/admin/ApiConfig.php b/admin/ApiConfig.php new file mode 100644 index 0000000..6e4e18f --- /dev/null +++ b/admin/ApiConfig.php @@ -0,0 +1,109 @@ + + + + +
+
+
+
+
+ API Key +
+ +
+ API Key不能为空 +
+
+
+
+ API Key +
+ +
+ Secret Key不能为空 +
+
+
+EOF; + if (isset($_GET["check"]) and $_GET["check"] == "true") { + echo ''; + } else { + echo ''; + } + echo <<返回 +
+
+
+
+ + +EOF; + +} else if (!empty($_GET["action"])) { + if (empty($_POST["api_key"])) { + error_res("API Key不能为空", $_SERVER["PHP_SELF"]); + } else if (empty($_POST["secret_key"])) { + error_res("Secret Key不能为空", $_SERVER["PHP_SELF"]); + } else if ($_GET["action"] == "test") { + $api_key = $_POST["api_key"]; + $secret_key = $_POST["secret_key"]; + $result = BaiduAiRequest::request_token_with_config($api_key, $secret_key); + if (array_key_exists("status", $result) and $result["status"]) { + info_res("AK/SK测试通过", $_SERVER["PHP_SELF"] . "?check=true"); + } else { + warn_res("AK/SK测试失败", $_SERVER["PHP_SELF"] . "?check=false"); + } + } else if ($_GET["action"] == "update") { + try { + DbUtil::update("update param set param_value=? where param_key=?", "ss", $_POST["api_key"], "api_key"); + DbUtil::update("update param set param_value=? where param_key=?", "ss", $_POST["secret_key"], "secret_key"); + info_res("保存成功", $_SERVER["PHP_SELF"]); + } catch (Exception $e) { + error($e); + error_res("保存异常请联系管理员", $_SERVER["PHP_SELF"]); + } + } else { + error_res("非法操作!", $_SERVER["PHP_SELF"]); + } +} else { + error_res("非法操作!", $_SERVER["PHP_SELF"]); +} \ No newline at end of file diff --git a/admin/Login.php b/admin/Login.php index 20a6212..8e456e8 100644 --- a/admin/Login.php +++ b/admin/Login.php @@ -24,8 +24,10 @@ function update_token(QueryManager $manager_result, $msg) info_res($msg, "/",); echo << - -let count=3 + +$(function() { + let count=3; + $("#tip").text(count+"秒后自动跳转"); let i=setInterval(function() { if(count-->0){ $("#tip").text(count+"秒后自动跳转"); @@ -34,6 +36,8 @@ let i=setInterval(function() { } console.info("定时器!!!!!") },1000) +}) +