Browse Source

Merge pull request #11 from helloxz/dev

Dev
pull/16/head 0.9.10
xiaoz 4 years ago committed by GitHub
parent
commit
75f98425de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .htaccess
  2. 2
      class/Api.php
  3. 8
      controller/admin.php
  4. 13
      controller/click.php
  5. 2
      controller/index.php
  6. 4
      controller/login.php
  7. 2
      functions/helper.php
  8. 2
      static/layer/layer.js
  9. 2
      static/layer/mobile/layer.js
  10. 1
      static/layer/mobile/need/layer.css
  11. BIN
      static/layer/theme/default/icon-ext.png
  12. BIN
      static/layer/theme/default/icon.png
  13. 1
      static/layer/theme/default/layer.css
  14. BIN
      static/layer/theme/default/loading-0.gif
  15. BIN
      static/layer/theme/default/loading-1.gif
  16. BIN
      static/layer/theme/default/loading-2.gif
  17. 28
      templates/admin/403.php
  18. 82
      templates/admin/add_link_tpl.php
  19. 34
      templates/admin/index.php
  20. 10
      templates/admin/static/style.css
  21. 24
      templates/default/index.php
  22. 18
      templates/default/static/embed.js
  23. 14
      templates/default/static/style.css
  24. 2
      version.txt

1
.htaccess

@ -2,3 +2,4 @@ RewriteEngine On @@ -2,3 +2,4 @@ RewriteEngine On
RewriteRule '^click\/(.*)$' /index.php?c=click&id=$1 [L]
RewriteRule '^api\/(.*)?(.*)$' /index.php?c=api&method=$1&$2 [L]
RewriteRule login /index.php?c=login [NC,L]
RewriteRule .*.(db3|rar|gz|json)$ - [F]

2
class/Api.php

@ -344,7 +344,7 @@ class Api { @@ -344,7 +344,7 @@ class Api {
* 验证是否登录
*/
protected function is_login(){
$key = md5(USER.PASSWORD.$this->getIP().'onenav');
$key = md5(USER.PASSWORD.'onenav');
//获取session
$session = $_COOKIE['key'];
//如果已经成功登录

8
controller/admin.php

@ -46,7 +46,7 @@ if ($page == 'edit_link') { @@ -46,7 +46,7 @@ if ($page == 'edit_link') {
}
//如果页面是添加链接页面
if ($page == 'add_link') {
if ( ($page == 'add_link') || ($page == 'add_link_tpl') ) {
//查询所有分类信息
$categorys = $db->select('on_categorys','*',[ 'ORDER' => ['weigth' => 'DESC'] ]);
//checked按钮
@ -99,12 +99,14 @@ function getIP() { @@ -99,12 +99,14 @@ function getIP() {
function check_auth($user,$password){
$ip = getIP();
$key = md5($user.$password.$ip.'onenav');
$key = md5($user.$password.'onenav');
//获取cookie
$cookie = $_COOKIE['key'];
//如果cookie的值和计算的key不一致,则没有权限
if( $cookie != $key ){
exit("<h3>认证失败,请<a href = 'index.php?c=login'>重新登录</a></h3>");
$msg = "<h3>认证失败,请<a href = 'index.php?c=login'>重新登录</a></h3>";
require('templates/admin/403.php');
exit;
}
}

13
controller/click.php

@ -7,7 +7,9 @@ $id = intval($_GET['id']); @@ -7,7 +7,9 @@ $id = intval($_GET['id']);
//如果链接为空
if(empty($id)) {
exit('无效ID!');
$msg = '<p>无效ID!</p>';
require('templates/admin/403.php');
exit();
}
//查询链接信息
@ -17,7 +19,9 @@ $link = $db->get('on_links',['id','fid','url','property','click'],[ @@ -17,7 +19,9 @@ $link = $db->get('on_links',['id','fid','url','property','click'],[
//如果查询失败
if( !$link ){
exit('无效ID!');
$msg = '<p>无效ID!</p>';
require('templates/admin/403.php');
exit();
}
//查询该ID的父及ID信息
@ -61,5 +65,8 @@ elseif( is_login() ) { @@ -61,5 +65,8 @@ elseif( is_login() ) {
}
//其它情况则没有权限
else{
exit('无权限!');
$msg = '<p>很抱歉,该页面是私有的,您无权限访问此页面。</p>
<p>如果您是管理员,请尝试登录OneNav后台并重新访问。</p>';
require('templates/admin/403.php');
exit();
}

2
controller/index.php

@ -80,7 +80,7 @@ function get_version(){ @@ -80,7 +80,7 @@ function get_version(){
}
//判断用户是否已经登录
function is_login(){
$key = md5(USER.PASSWORD.getIP().'onenav');
$key = md5(USER.PASSWORD.'onenav');
//获取session
$session = $_COOKIE['key'];
//如果已经成功登录

4
controller/login.php

@ -6,7 +6,7 @@ $username = $site_setting['user']; @@ -6,7 +6,7 @@ $username = $site_setting['user'];
$password = $site_setting['password'];
$ip = getIP();
//如果认证通过,直接跳转到后台管理
$key = md5($username.$password.$ip.'onenav');
$key = md5($username.$password.'onenav');
//获取cookie
$cookie = $_COOKIE['key'];
@ -22,7 +22,7 @@ if( $_GET['check'] == 'login' ) { @@ -22,7 +22,7 @@ if( $_GET['check'] == 'login' ) {
$pass = $_POST['password'];
header('Content-Type:application/json; charset=utf-8');
if( ($user == $username) && ($pass == $password) ) {
$key = md5($username.$password.$ip.'onenav');
$key = md5($username.$password.'onenav');
setcookie("key", $key, time()+30 * 24 * 60 * 60,"/");
$data = [
'code' => 0,

2
functions/helper.php

@ -24,7 +24,7 @@ function getIP() { @@ -24,7 +24,7 @@ function getIP() {
function is_login(){
$key = md5(USER.PASSWORD.getIP().'onenav');
$key = md5(USER.PASSWORD.'onenav');
//获取session
$session = $_COOKIE['key'];
//如果已经成功登录

2
static/layer/layer.js

File diff suppressed because one or more lines are too long

2
static/layer/mobile/layer.js

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
/*! layer mobile-v2.0.0 Web 通用弹出层组件 MIT License */
;!function(e){"use strict";var t=document,n="querySelectorAll",i="getElementsByClassName",a=function(e){return t[n](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var n in e)t[n]=e[n];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var r=0,o=["layui-m-layer"],c=function(e){var t=this;t.config=l.extend(e),t.view()};c.prototype.view=function(){var e=this,n=e.config,s=t.createElement("div");e.id=s.id=o[0]+r,s.setAttribute("class",o[0]+" "+o[0]+(n.type||0)),s.setAttribute("index",r);var l=function(){var e="object"==typeof n.title;return n.title?'<h3 style="'+(e?n.title[1]:"")+'">'+(e?n.title[0]:n.title)+"</h3>":""}(),c=function(){"string"==typeof n.btn&&(n.btn=[n.btn]);var e,t=(n.btn||[]).length;return 0!==t&&n.btn?(e='<span yes type="1">'+n.btn[0]+"</span>",2===t&&(e='<span no type="0">'+n.btn[1]+"</span>"+e),'<div class="layui-m-layerbtn">'+e+"</div>"):""}();if(n.fixed||(n.top=n.hasOwnProperty("top")?n.top:100,n.style=n.style||"",n.style+=" top:"+(t.body.scrollTop+n.top)+"px"),2===n.type&&(n.content='<i></i><i class="layui-m-layerload"></i><i></i><p>'+(n.content||"")+"</p>"),n.skin&&(n.anim="up"),"msg"===n.skin&&(n.shade=!1),s.innerHTML=(n.shade?"<div "+("string"==typeof n.shade?'style="'+n.shade+'"':"")+' class="layui-m-layershade"></div>':"")+'<div class="layui-m-layermain" '+(n.fixed?"":'style="position:static;"')+'><div class="layui-m-layersection"><div class="layui-m-layerchild '+(n.skin?"layui-m-layer-"+n.skin+" ":"")+(n.className?n.className:"")+" "+(n.anim?"layui-m-anim-"+n.anim:"")+'" '+(n.style?'style="'+n.style+'"':"")+">"+l+'<div class="layui-m-layercont">'+n.content+"</div>"+c+"</div></div></div>",!n.type||2===n.type){var d=t[i](o[0]+n.type),y=d.length;y>=1&&layer.close(d[0].getAttribute("index"))}document.body.appendChild(s);var u=e.elem=a("#"+e.id)[0];n.success&&n.success(u),e.index=r++,e.action(n,u)},c.prototype.action=function(e,t){var n=this;e.time&&(l.timer[n.index]=setTimeout(function(){layer.close(n.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),layer.close(n.index)):e.yes?e.yes(n.index):layer.close(n.index)};if(e.btn)for(var s=t[i]("layui-m-layerbtn")[0].children,r=s.length,o=0;o<r;o++)l.touch(s[o],a);if(e.shade&&e.shadeClose){var c=t[i]("layui-m-layershade")[0];l.touch(c,function(){layer.close(n.index,e.end)})}e.end&&(l.end[n.index]=e.end)},e.layer={v:"2.0",index:r,open:function(e){var t=new c(e||{});return t.index},close:function(e){var n=a("#"+o[0]+e)[0];n&&(n.innerHTML="",t.body.removeChild(n),clearTimeout(l.timer[e]),delete l.timer[e],"function"==typeof l.end[e]&&l.end[e](),delete l.end[e])},closeAll:function(){for(var e=t[i](o[0]),n=0,a=e.length;n<a;n++)layer.close(0|e[0].getAttribute("index"))}},"function"==typeof define?define(function(){return layer}):function(){var e=document.scripts,n=e[e.length-1],i=n.src,a=i.substring(0,i.lastIndexOf("/")+1);n.getAttribute("merge")||document.head.appendChild(function(){var e=t.createElement("link");return e.href=a+"need/layer.css?2.0",e.type="text/css",e.rel="styleSheet",e.id="layermcss",e}())}()}(window);

1
static/layer/mobile/need/layer.css

File diff suppressed because one or more lines are too long

BIN
static/layer/theme/default/icon-ext.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
static/layer/theme/default/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

1
static/layer/theme/default/layer.css

File diff suppressed because one or more lines are too long

BIN
static/layer/theme/default/loading-0.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
static/layer/theme/default/loading-1.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

BIN
static/layer/theme/default/loading-2.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

28
templates/admin/403.php

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>403 error</title>
<meta name="author" content="xiaoz" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://lib.sinaapp.com/js/bootstrap/4.3.1/css/bootstrap.min.css" type="" media=""/>
</head>
<body>
<div class="container" style = "margin-top:2em;">
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="xcdn-title">
<svg t="1587806027367" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1138" width="6rem" height="6rem"><path d="M132.8 837.824c-8.533333 15.04-8.234667 15.509333 10.24 15.509333h737.92c18.453333 0 18.752-0.512 10.24-15.509333L519.722667 181.824c-8.405333-14.869333-7.04-14.869333-15.445334 0L132.8 837.802667zM593.962667 139.733333L965.461333 795.733333c41.002667 72.469333-1.258667 142.933333-84.501333 142.933334H143.04c-83.306667 0-125.461333-70.506667-84.48-142.890667l371.477333-656c41.088-72.597333 122.88-72.576 163.946667 0zM512 789.333333a42.666667 42.666667 0 1 0 0-85.333333 42.666667 42.666667 0 0 0 0 85.333333z m-42.666667-384v213.333334a42.666667 42.666667 0 1 0 85.333334 0V405.333333a42.666667 42.666667 0 1 0-85.333334 0z" p-id="1139" fill="#d81e06"></path></svg><h1>403 error</h1>
</div>
<div class="xcdn-content">
<?php echo $msg; ?>
</div>
<hr>
<div class="xcdn-footer">Powered by <a href="https://www.xiaoz.me/" title = "小z博客" rel = "nofollow" target = "_blank">xiaoz</a></div>
</div>
</div>
</div>
</body>
</html>

82
templates/admin/add_link_tpl.php

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>OneNav后台管理</title>
<link rel='stylesheet' href='https://libs.xiaoz.top/layui/v2.5.4/css/layui.css'>
<link rel='stylesheet' href='templates/admin/static/style.css'>
</head>
<body>
<div>
<!-- 内容主体区域 -->
<div class="layui-row" style = "margin-top:18px;">
<div class="layui-container">
<div class="layui-col-lg6 layui-col-md-offset3">
<form class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label">URL</label>
<div class="layui-input-block">
<input type="url" id = "url" name="url" required lay-verify="required|url" placeholder="请输入有效链接" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">链接名称</label>
<div class="layui-input-block">
<input type="text" id = "title" name="title" required lay-verify="required" placeholder="请输入链接名称" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">所属分类</label>
<div class="layui-input-block">
<select name="fid" lay-verify="required" lay-search>
<option value=""></option>
<?php foreach ($categorys as $category) {
# code...
?>
<option value="<?php echo $category['id'] ?>"><?php echo $category['name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">权重</label>
<div class="layui-input-block">
<input type="number" name="weight" min = "0" max = "999" value = "0" required lay-verify="required|number" placeholder="权重越高,排名越靠前,范围为0-999" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">是否私有</label>
<div class="layui-input-block">
<input type="checkbox" name="property" value = "1" lay-skin="switch" lay-text="是|否">
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">描述</label>
<div class="layui-input-block">
<textarea name="description" id = "description" placeholder="请输入内容" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="add_link">添加</button>
<!-- <button class="layui-btn" lay-submit lay-filter="get_link_info">识别</button> -->
<a href="javascript:;" class="layui-btn" onclick="get_link_info()">识别</a>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
</div>
</div>
<!-- 内容主题区域END -->
</div>
<script src = 'https://libs.xiaoz.top/jquery/2.2.4/jquery.min.js'></script>
<script src = 'https://libs.xiaoz.top/layui/v2.5.4/layui.js'></script>
<script src="templates/admin/static/embed.js"></script>
</body>
</html>

34
templates/admin/index.php

@ -6,16 +6,30 @@ @@ -6,16 +6,30 @@
<!-- 内容主体区域 -->
<div style="padding: 15px;">
<div class="layui-container" style = "margin-top:2em;">
<div class="layui-row">
<div class="layui-col-lg4 layui-col-md-offset4">
<ul>
<li>QQ群1:147687134</li>
<li>QQ群2:147687134</li>
<li>项目地址:<a href="https://github.com/helloxz/onenav" rel = "nofollow" target="_blank">https://github.com/helloxz/onenav</a></li>
<li>帮助文档:<a href="https://github.com/helloxz/onenav" rel = "nofollow" target="_blank">https://github.com/helloxz/onenav</a></li>
<li>QQ:337003006</li>
<li>Blog: <a href="https://www.xiaoz.me/" rel = "nofollow" target="_blank">https://www.xiaoz.me/</a></li>
</ul>
<div class="layui-row layui-col-space18">
<div class="layui-col-lg4">
<div class = "admin-msg">当前版本:<?php echo file_get_contents('version.txt'); ?></div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">QQ群1:147687134</div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">QQ群2:147687134</div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">项目地址:<a href="https://github.com/helloxz/onenav" rel = "nofollow" target="_blank">https://github.com/helloxz/onenav</a></div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">帮助文档:<a href="https://dwz.ovh/onenav" rel = "nofollow" target="_blank">https://dwz.ovh/onenav</a></div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">QQ:337003006</div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">Blog: <a href="https://www.xiaoz.me/" rel = "nofollow" target="_blank">https://www.xiaoz.me/</a></div>
</div>
<div class="layui-col-lg4">
<div class = "admin-msg">捐赠地址: <a href="https://dwz.ovh/donation" rel = "nofollow" target="_blank">https://dwz.ovh/donation</a></div>
</div>
</div>
</div>

10
templates/admin/static/style.css

@ -61,3 +61,13 @@ @@ -61,3 +61,13 @@
border-radius: 3px;
display: none;
}
.admin-msg{
background-color: #f2f2f2;
line-height: 14px;
padding:1em;
border-radius: 5px;
color:#888888;
}
.admin-msg a{
color:#01AAED;
}

24
templates/default/index.php

@ -51,14 +51,33 @@ @@ -51,14 +51,33 @@
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"></path>
</svg>
<a class = "mdui-hidden-xs" href="/index.php?c=login" title = "登录OneNav" target="_blank" class="mdui-btn mdui-btn-icon"><i class="mdui-icon material-icons">account_circle</i></a>
<?php
if( is_login() ) {
?>
<a class = "mdui-hidden-xs" href="/index.php?c=admin" title = "后台管理" target="_blank" class="mdui-btn mdui-btn-icon"><i class="mdui-icon material-icons">account_circle</i></a>
<?php }else{ ?>
<a class = "mdui-hidden-xs" href="/index.php?c=login" title = "登录OneNav" target="_blank" class="mdui-btn mdui-btn-icon"><i class="mdui-icon material-icons">account_circle</i></a>
<?php } ?>
</a>
</div>
</header>
<!--导航工具END-->
<!-- 添加按钮 -->
<?php
if( is_login() ) {
?>
<div class="right-button mdui-hidden-xs" style="position: fixed;right:10px;bottom:80px;z-index:99;">
<div>
<button title = "快速添加链接" id = "add" class="mdui-fab mdui-color-theme-accent mdui-ripple mdui-fab-mini"><i class="mdui-icon material-icons">add</i></button>
</div>
</div>
<?php } ?>
<!-- 添加按钮END -->
<!-- 返回顶部按钮 -->
<div id="top"></div>
<div class="top mdui-shadow-10"><a href="javascript:;" title="返回顶部" onclick="gotop()"><i class="mdui-icon material-icons">arrow_drop_up</i></div>
<div class="top mdui-shadow-10">
<a href="javascript:;" title="返回顶部" onclick="gotop()"><i class="mdui-icon material-icons">arrow_drop_up</i>
</div>
<!-- 返回顶部END -->
<!--左侧抽屉导航-->
<!-- 默认抽屉栏在左侧 -->
@ -166,6 +185,7 @@ @@ -166,6 +185,7 @@
<!-- footerend -->
</body>
<script src = 'https://libs.xiaoz.top/jquery/2.2.4/jquery.min.js'></script>
<script src="/static//layer/layer.js"></script>
<script src = 'https://libs.xiaoz.top/jQuery-contextMenu/2.9.2/jquery.contextMenu.min.js'></script>
<script src = 'https://libs.xiaoz.top/clipBoard.js/clipBoard.min.js'></script>
<script src = "templates/<?php echo TEMPLATE; ?>/static/holmes.js"></script>

18
templates/default/static/embed.js

@ -137,8 +137,7 @@ function admin_menu() { @@ -137,8 +137,7 @@ function admin_menu() {
},
afterCopy: function() {
//msg('链接已复制!');
mdui.alert('链接已复制!');
layer.msg('链接已复制!');
}
});
// 复制按钮END
@ -197,7 +196,8 @@ $.contextMenu({ @@ -197,7 +196,8 @@ $.contextMenu({
},
afterCopy: function() {
//msg('链接已复制!');
mdui.alert('链接已复制!');
// mdui.alert('链接已复制!');
layer.msg('链接已复制!');
}
});
// 复制按钮END
@ -208,3 +208,15 @@ $.contextMenu({ @@ -208,3 +208,15 @@ $.contextMenu({
});
// 加载游客右键菜单END
};
// 添加链接按钮
$("#add").click(function(){
layer.open({
type: 2,
title: '添加链接',
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area : ['800px' , '520px'],
content: '/index.php?c=admin&page=add_link_tpl'
});
});

14
templates/default/static/style.css

@ -1,3 +1,14 @@ @@ -1,3 +1,14 @@
body{
/* 增加锚点跳转过度效果 */
scroll-behavior: smooth;
}
/* 锚点元素位置 */
.anchor-element {
position: absolute;
/*控制距离顶部 100px*/
top: -180px;
visibility: hidden;
}
.link-line {
font-size: 16px;
border-bottom: 1px solid #dddddd;
@ -122,3 +133,6 @@ footer a{ @@ -122,3 +133,6 @@ footer a{
text-overflow: ellipsis;
-o-text-overflow:ellipsis;
}
.mdui-snackbar-top{
background-color: #FF2377;
}

2
version.txt

@ -1 +1 @@ @@ -1 +1 @@
v0.9.9-20210322
v0.9.10-20210407
Loading…
Cancel
Save