From 2ef908a892039631bbd11b151a2c69b57986f662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=81=E5=A3=AE=E6=88=90=E9=95=BF?= <2291200076@qq.com> Date: Sat, 16 Jan 2021 03:58:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9=E8=BF=99=E4=B8=AA=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=97=A0=E6=B3=95=E5=9C=A8=E7=BD=91=E7=AB=99=E9=9D=9E?= =?UTF-8?q?=E6=A0=B9=E7=9B=AE=E5=BD=95=E4=B8=8B=E8=BF=90=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E6=88=91=E5=A4=A7=E8=87=B4=E4=B8=8A?= =?UTF-8?q?=E9=98=85=E8=AF=BB=E4=BA=86=E4=B8=80=E9=81=8D=E4=BD=A0=E7=9A=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=BB=A3=E7=A0=81=EF=BC=8C=E7=84=B6=E5=90=8E?= =?UTF-8?q?=E5=81=9A=E5=87=BA=E4=BA=86=E7=9B=B8=E5=BA=94=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=EF=BC=8C=E6=88=91=E5=9C=A8=E6=9C=AC=E5=9C=B0=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E5=88=B0=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=B8=8A?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=BF=87=EF=BC=8C=E5=9D=87=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E8=BF=90=E8=A1=8C=EF=BC=88=E4=B8=8D=E8=BF=87?= =?UTF-8?q?=E5=AF=B9=E4=BA=8E=E9=83=A8=E7=BD=B2=E5=9C=A8=E5=AD=90=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E7=9A=84=E7=94=A8=E6=88=B7=EF=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A7=E7=BB=AD=E5=8A=A0=E6=B2=B9=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/admin.php | 4 ++-- controller/login.php | 4 +++- templates/admin/header.php | 14 +++++++------- templates/admin/left.php | 8 ++++---- templates/admin/static/embed.js | 32 +++++++++++++++---------------- templates/default/index.php | 2 +- templates/default/static/embed.js | 8 ++++---- 7 files changed, 37 insertions(+), 35 deletions(-) diff --git a/controller/admin.php b/controller/admin.php index df1bde4..a02de16 100644 --- a/controller/admin.php +++ b/controller/admin.php @@ -64,7 +64,7 @@ if ($page == 'logout') { //清除cookie setcookie("key", $key, -(time()+7 * 24 * 60 * 60),"/"); //跳转到首页 - header('location:/'); + header('location:'.dirname($_SERVER['PHP_SELF'])); exit; } @@ -104,7 +104,7 @@ function check_auth($user,$password){ $cookie = $_COOKIE['key']; //如果cookie的值和计算的key不一致,则没有权限 if( $cookie != $key ){ - exit("

认证失败,请重新登录

"); + exit("

认证失败,请重新登录

"); } } diff --git a/controller/login.php b/controller/login.php index 6890712..40e7f9e 100644 --- a/controller/login.php +++ b/controller/login.php @@ -12,7 +12,9 @@ $cookie = $_COOKIE['key']; //如果已经登录,直接跳转 if( $cookie == $key ){ - header('location:index.php?c=admin'); + $phpSelf = dirname($_SERVER['PHP_SELF']); + $phpSelf = ($phpSelf == "/" || $phpSelf == "\\") ? "" : $phpSelf; + header('location:'.$phpSelf.'/index.php?c=admin'); exit; } diff --git a/templates/admin/header.php b/templates/admin/header.php index 4a63226..463ab58 100644 --- a/templates/admin/header.php +++ b/templates/admin/header.php @@ -10,14 +10,14 @@
- + diff --git a/templates/admin/left.php b/templates/admin/left.php index 5f17d95..4a0e7e5 100644 --- a/templates/admin/left.php +++ b/templates/admin/left.php @@ -5,8 +5,8 @@
  • 分类管理
    -
    分类列表
    -
    添加分类
    +
    分类列表
    +
    添加分类
  • @@ -15,8 +15,8 @@
  • 链接管理
    -
    我的链接
    -
    添加链接
    +
    我的链接
    +
    添加链接
  • diff --git a/templates/admin/static/embed.js b/templates/admin/static/embed.js index c7b4efc..54b8a25 100644 --- a/templates/admin/static/embed.js +++ b/templates/admin/static/embed.js @@ -8,7 +8,7 @@ layui.use(['element','table','layer','form'], function(){ table.render({ elem: '#category_list' ,height: 500 - ,url: 'index.php?c=api&method=category_list' //数据接口 + ,url: './index.php?c=api&method=category_list' //数据接口 ,page: true //开启分页 ,cols: [[ //表头 {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'} @@ -48,7 +48,7 @@ layui.use(['element','table','layer','form'], function(){ //console.log(obj) if(obj.event === 'del'){ layer.confirm('确认删除?',{icon: 3, title:'温馨提示!'}, function(index){ - $.post('/index.php?c=api&method=del_category',{'id':obj.data.id},function(data,status){ + $.post('./index.php?c=api&method=del_category',{'id':obj.data.id},function(data,status){ if(data.code == 0){ obj.del(); @@ -60,14 +60,14 @@ layui.use(['element','table','layer','form'], function(){ layer.close(index); }); } else if(obj.event === 'edit'){ - window.location.href = '/index.php?c=admin&page=edit_category&id=' + obj.data.id; + window.location.href = './index.php?c=admin&page=edit_category&id=' + obj.data.id; } }); //渲染链接列表 table.render({ elem: '#link_list' ,height: 520 - ,url: 'index.php?c=api&method=link_list' //数据接口 + ,url: './index.php?c=api&method=link_list' //数据接口 ,page: true //开启分页 ,toolbar: '#linktool' ,cols: [[ //表头 @@ -123,7 +123,7 @@ layui.use(['element','table','layer','form'], function(){ layer.confirm('确认删除?',{icon: 3, title:'温馨提示!'}, function(index){ for (let i = 0; i < data.length; i++) { - $.post('/index.php?c=api&method=del_link',{'id':data[i].id},function(data,status){ + $.post('./index.php?c=api&method=del_link',{'id':data[i].id},function(data,status){ if(data.code == 0){ console.log(obj); obj.del(); @@ -160,7 +160,7 @@ layui.use(['element','table','layer','form'], function(){ //console.log(obj) if(obj.event === 'del'){ layer.confirm('确认删除?',{icon: 3, title:'温馨提示!'}, function(index){ - $.post('/index.php?c=api&method=del_link',{'id':obj.data.id},function(data,status){ + $.post('./index.php?c=api&method=del_link',{'id':obj.data.id},function(data,status){ if(data.code == 0){ obj.del(); } @@ -171,17 +171,17 @@ layui.use(['element','table','layer','form'], function(){ layer.close(index); }); } else if(obj.event === 'edit'){ - window.location.href = '/index.php?c=admin&page=edit_link&id=' + obj.data.id; + window.location.href = './index.php?c=admin&page=edit_link&id=' + obj.data.id; } }); //登录 //添加链接 form.on('submit(login)', function(data){ - $.post('/index.php?c=login&check=login',data.field,function(data,status){ + $.post('./index.php?c=login&check=login',data.field,function(data,status){ //如果添加成功 if(data.code == 0) { - window.location.href = '/index.php?c=admin'; + window.location.href = './index.php?c=admin'; } else{ layer.msg(data.err_msg, {icon: 5}); @@ -193,7 +193,7 @@ layui.use(['element','table','layer','form'], function(){ //添加分类目录 form.on('submit(add_category)', function(data){ - $.post('/index.php?c=api&method=add_category',data.field,function(data,status){ + $.post('./index.php?c=api&method=add_category',data.field,function(data,status){ //如果添加成功 if(data.code == 0) { layer.msg('已添加!', {icon: 1}); @@ -207,7 +207,7 @@ layui.use(['element','table','layer','form'], function(){ }); //修改分类目录 form.on('submit(edit_category)', function(data){ - $.post('/index.php?c=api&method=edit_category',data.field,function(data,status){ + $.post('./index.php?c=api&method=edit_category',data.field,function(data,status){ //如果添加成功 if(data.code == 0) { layer.msg('已修改!', {icon: 1}); @@ -222,7 +222,7 @@ layui.use(['element','table','layer','form'], function(){ //添加链接 form.on('submit(add_link)', function(data){ - $.post('/index.php?c=api&method=add_link',data.field,function(data,status){ + $.post('./index.php?c=api&method=add_link',data.field,function(data,status){ //如果添加成功 if(data.code == 0) { layer.msg('已添加!', {icon: 1}); @@ -236,7 +236,7 @@ layui.use(['element','table','layer','form'], function(){ }); //识别链接信息 form.on('submit(get_link_info)', function(data){ - $.post('/index.php?c=api&method=get_link_info',data.field.url,function(data,status){ + $.post('./index.php?c=api&method=get_link_info',data.field.url,function(data,status){ //如果添加成功 if(data.code == 0) { console.log(data); @@ -250,7 +250,7 @@ layui.use(['element','table','layer','form'], function(){ }); //更新链接 form.on('submit(edit_link)', function(data){ - $.post('/index.php?c=api&method=edit_link',data.field,function(data,status){ + $.post('./index.php?c=api&method=edit_link',data.field,function(data,status){ //如果添加成功 if(data.code == 0) { layer.msg('已更新!', {icon: 1}); @@ -265,7 +265,7 @@ layui.use(['element','table','layer','form'], function(){ //识别链接信息 form.on('submit(get_link_info)', function(data){ //是用ajax异步加载 - $.post('/index.php?c=api&method=get_link_info',data.field.url,function(data,status){ + $.post('./index.php?c=api&method=get_link_info',data.field.url,function(data,status){ //如果添加成功 if(data.code == 0) { console.log(data); @@ -284,7 +284,7 @@ layui.use(['element','table','layer','form'], function(){ function get_link_info() { var url = $("#url").val(); var index = layer.load(1); - $.post('/index.php?c=api&method=get_link_info',{url:url},function(data,status){ + $.post('./index.php?c=api&method=get_link_info',{url:url},function(data,status){ //如果添加成功 if(data.code == 0) { if(data.data.title != null) { diff --git a/templates/default/index.php b/templates/default/index.php index 6c494f9..3d30253 100644 --- a/templates/default/index.php +++ b/templates/default/index.php @@ -43,7 +43,7 @@ c0.9,2.2,0.3,3.9,0.2,4.3c1,1.1,1.7,2.6,1.7,4.4c0,6.3-3.8,7.6-7.4,8c0.6,0.5,1.1,1.5,1.1,3c0,2.2,0,3.9,0,4.5 c0,0.4,0.3,0.9,1.1,0.8c6.5-2.2,11.1-8.3,11.1-15.5C34.3,8.7,27,1.4,18,1.4z"> - account_circle + account_circle
    diff --git a/templates/default/static/embed.js b/templates/default/static/embed.js index ce54c9b..4d329a0 100644 --- a/templates/default/static/embed.js +++ b/templates/default/static/embed.js @@ -79,20 +79,20 @@ function admin_menu() { var link_id = $(this).attr('id'); link_id = link_id.replace('id_',''); var tempwindow=window.open('_blank'); - tempwindow.location='index.php?c=click&id='+link_id; + tempwindow.location='./index.php?c=click&id='+link_id; }}, "edit": {name: "编辑", icon: "edit",callback:function(key,opt){ var link_id = $(this).attr('id'); link_id = link_id.replace('id_',''); var tempwindow=window.open('_blank'); - tempwindow.location='index.php?c=admin&page=edit_link&id='+link_id; + tempwindow.location='./index.php?c=admin&page=edit_link&id='+link_id; }}, "delete": {name: "删除", icon: "delete",callback:function(){ var link_id = $(this).attr('id'); link_id = link_id.replace('id_',''); mdui.confirm('确认删除?', function(){ - $.post("index.php?c=api&method=del_link",{id:link_id},function(data,status){ + $.post("./index.php?c=api&method=del_link",{id:link_id},function(data,status){ //如果删除成功,则移除元素 if(data.code == 0) { $("#id_" + link_id).remove(); @@ -166,7 +166,7 @@ $.contextMenu({ var link_id = $(this).attr('id'); link_id = link_id.replace('id_',''); var tempwindow=window.open('_blank'); - tempwindow.location='index.php?c=click&id='+link_id; + tempwindow.location='./index.php?c=click&id='+link_id; }}, "sep1": "---------", "qrcode": {name: "二维码", icon:"fa-qrcode",callback:function(data,status){