diff --git a/Log.php b/Log.php index 3d61fad..ea658f8 100644 --- a/Log.php +++ b/Log.php @@ -1,6 +1,6 @@ pushHandler(getStream(__ROOT__ . "/log/run.log")); + $log->pushHandler(getStream($_SERVER["DOCUMENT_ROOT"] . "/log/run.log")); $log->pushHandler(getStream("php://stdout")); // <<< uses a stream return $log; } diff --git a/admin/Login.php b/admin/Login.php index dbc7a70..20a6212 100644 --- a/admin/Login.php +++ b/admin/Login.php @@ -21,8 +21,27 @@ function update_token(QueryManager $manager_result, $msg) // 跳转到首页 if ($_SERVER["SCRIPT_NAME"] == "/admin/Manager.php") { - info_res($msg, "/admin/Login.php"); - } else { + info_res($msg, "/",); + echo << + +let count=3 +let i=setInterval(function() { + if(count-->0){ + $("#tip").text(count+"秒后自动跳转"); + }else{ + location.href="/" + } + console.info("定时器!!!!!") +},1000) + + + +EOF; + + } else if ($_SERVER["SCRIPT_NAME"] == "/index.php" && empty($_SERVER["HTTP_REFERER"])) { response($msg, "alert-info"); } diff --git a/admin/Manager.php b/admin/Manager.php index f98007c..27fa60f 100644 --- a/admin/Manager.php +++ b/admin/Manager.php @@ -1,20 +1,16 @@ 垃圾名 垃圾分类 创建时间 - 修改时间 + @@ -184,7 +184,7 @@ EOF; $name $category $create_at - $update_at + EOF; } diff --git a/api/BaiduImage.php b/api/BaiduImage.php index da079b7..1163e2c 100644 --- a/api/BaiduImage.php +++ b/api/BaiduImage.php @@ -1,10 +1,10 @@ - + EOF; } diff --git a/index.php b/index.php index 6cb68e9..bf2075f 100644 --- a/index.php +++ b/index.php @@ -1,11 +1,11 @@ new Menu("百度API配置", "/admin/ApiConfig.php"), new Menu("垃圾分类", "/admin/WasteSorting.php"), new Menu("题目管理", "/admin/Question.php")); @@ -25,7 +25,9 @@ echo << function logout() { if(confirm("确认退出?")){ - + delCookie("login_token"); + delCookie("manager_name"); + location.href="/admin/Manager.php" } } diff --git a/static/js/Cookie.js b/static/js/Cookie.js new file mode 100644 index 0000000..44a6cc3 --- /dev/null +++ b/static/js/Cookie.js @@ -0,0 +1,15 @@ +function delCookie(name) { + var exp = new Date(); + exp.setTime(exp.getTime() - 1); + var cval = getCookie(name); + if (cval != null) + document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); +} + +function getCookie(name) { + var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); + if ((arr = document.cookie.match(reg)) !== null) + return unescape(arr[2]); + else + return null; +} \ No newline at end of file diff --git a/test.php b/test.php index 9446e11..c97f247 100644 --- a/test.php +++ b/test.php @@ -1,9 +1,9 @@ @@ -24,5 +24,8 @@ require_once "config.php"; //EOF; //var_dump(array_search(new Answer(1, 2, 3, 4), array(new Answer(4, 5, 6, 7), new Answer(2, 2, 3, 4)))); -var_dump(date_create(default_format)); +$s1 = "dotcoo world!"; +$s2 = "dotcoo"; +$s3 = "hello dotcoo"; +var_dump(substr($s1, -strlen($s2)) === $s2);