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){