diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..815f863
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+/.idea
+/.vscode
+*.log
+.env
+.DS_Store
diff --git a/.htaccess b/.htaccess
index 69a7f04..3a1bf04 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,7 +1,8 @@
Options +FollowSymlinks -Multiviews
RewriteEngine On
+
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 5927338..fc630df 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,6 @@
# 食用方法
-Wiki:https://github.com/5ime/API-Admin/wiki
-
-此程序基于ThinkPHP5.0 PHP版本需`≥7.0`
+此程序基于ThinkPHP5.1 PHP版本需`7.0-7.3`之间。
`Nginx`请设置如下`伪静态` `Apache`无需配置 运行目录`默认`即可
```
@@ -15,13 +13,12 @@ location / {
将程序上传至网站根目录,访问`域名/install`进行安装操作
-默认账号密码为`admin` `123456` 如需添加API 请将API放入`api`目录
-
-**新增的API文档编写请参考:https://tenapi.cn/doc/**
+操作指南请前往:https://github.com/5ime/API-Admin/wiki
Bug反馈请提交`Issues`
# 更新日志
+
- 2020-4-1 提交API-Admin beta版 新增`随机动漫图API`
- 2020-4-7 新增`抖音无水印解析API`,`IP签名图API`,`免KEY加群API`
- 2020-4-15 新增安装页面/优化部分代码 新增`网站ICO获取API`,`网站icp备案查询API`,`历史上的今天API`,`QQ头像获取API`,`QQ在线状态查询API`,`服务器信息获取API`,`网站标题获取API`,`爱站权重获取API`,`城市天气获取API`,`随机一言API`
@@ -34,6 +31,8 @@ Bug反馈请提交`Issues`
- 2021-1-29 优化部分代码,后台新增API总调用数统计、API搜索功能、API分类功能、程序更新检测功能、API列表分页...
- 开源了聚合短视频去水印解析API https://github.com/5ime/video_spider
- 2021-8-22 修复几处错误
+- 2022-1-6 大更新
# 免责声明
+
本仓库只为学习研究,如涉及侵犯个人或者团体利益,请与我取得联系,我将主动删除一切相关资料,谢谢!
diff --git a/SECURITY.md b/SECURITY.md
deleted file mode 100644
index 21d24d8..0000000
--- a/SECURITY.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# Security Policy
-
-## Supported Versions
-
-| Version | Supported |
-| ------- | ------------------ |
-| 1.2.0 | :white_check_mark: |
-
-## Reporting a Vulnerability
-
-### Vulnerability file:
-...
-
-### Vulnerability causes
-...
-
-### POC
-...
diff --git a/api/bing/index.php b/api/bing/index.php
index 170e476..499c018 100644
--- a/api/bing/index.php
+++ b/api/bing/index.php
@@ -1,5 +1,9 @@
(.+?)<\/url>/ies",$str,$matches)){
diff --git a/public/static/doc/images/img/new003636 b/api/black.data
similarity index 100%
rename from public/static/doc/images/img/new003636
rename to api/black.data
diff --git a/api/black.php b/api/black.php
new file mode 100644
index 0000000..db4d828
--- /dev/null
+++ b/api/black.php
@@ -0,0 +1,54 @@
+ 201,
+ 'msg' => '您已被拉黑',
+ );
+ $Json = json_encode($Json,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
+ echo stripslashes($Json);
+ die;
+}
+if(!empty(get_referer())){
+ if(in_array(get_referer(),$data)){
+ $Json = array(
+ 'code' => 201,
+ 'msg' => '您已被拉黑',
+ );
+ $Json = json_encode($Json,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
+ echo stripslashes($Json);
+ die;
+ }
+}
+
+function get_referer()
+{
+ $referer = @$_SERVER['HTTP_REFERER'];
+ $referer = str_replace('http://', '', $referer);
+ $referer = str_replace('https://', '', $referer);
+ $referer = str_replace('www.', '', $referer);
+ $referer = str_replace('/', '', $referer);
+ $referer = str_replace('.', '', $referer);
+ return $referer;
+}
+
+function get_ip()
+{
+ if(!empty($_SERVER['HTTP_CLIENT_IP'])){
+ $cip = $_SERVER['HTTP_CLIENT_IP'];
+ }else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
+ $cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
+ }else if(!empty($_SERVER["REMOTE_ADDR"])){
+ $cip = $_SERVER["REMOTE_ADDR"];
+ }else{
+ $cip = '';
+ }
+ preg_match("/[\d\.]{7,15}/", $cip, $cips);
+ $cip = isset($cips[0]) ? $cips[0] : 'unknown';
+ unset($cips);
+ return $cip;
+}
\ No newline at end of file
diff --git a/api/count.php b/api/count.php
deleted file mode 100644
index 4a71dfb..0000000
--- a/api/count.php
+++ /dev/null
@@ -1,8 +0,0 @@
-
diff --git a/api/counter.dat b/api/counter.dat
deleted file mode 100644
index 2edeafb..0000000
--- a/api/counter.dat
+++ /dev/null
@@ -1 +0,0 @@
-20
\ No newline at end of file
diff --git a/api/douyin/index.php b/api/douyin/index.php
index 681fe81..9923394 100644
--- a/api/douyin/index.php
+++ b/api/douyin/index.php
@@ -1,5 +1,9 @@
+1.升级版本号1.4>>2.0
+2.修复样式错误问题
+3.重写前端部分页面
+4.重构全部后端代码
+5.新增发布文章功能
+6.新增接口TOP10功能
+7.新增登录成功告警功能
+8.新增Referer和IP黑名单
+9.新增自定义CSS和Js功能
+10.后端页面改为Ajax实时渲染
+11.修复高并发下统计重置问题
+NaN.想起来在写...
+";
+
+$Json = array(
+ 'code' => 200,
+ 'version' => 1.2,
+ 'content' => urlencode($content),
+ 'download' => 'https://github.com/5ime/adpi-admin'
+ );
+$Json = json_encode($Json,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
+echo stripslashes($Json);
+return $Json;
diff --git a/api/title/index.php b/api/title/index.php
index 92ff305..7ea22ae 100644
--- a/api/title/index.php
+++ b/api/title/index.php
@@ -1,5 +1,9 @@
-
-
-
-幽灵404页面
-
-
-
-
-
-
-
-
-
-
-
-
404错误!
-
看来我们找不到你要找的那一页
-
-
-
返回
-
-
-
-
-
-
-
-
-
diff --git a/application/admin/controller/Api.php b/application/admin/controller/Api.php
new file mode 100644
index 0000000..3b6aa69
--- /dev/null
+++ b/application/admin/controller/Api.php
@@ -0,0 +1,112 @@
+send();
+ }
+ }
+
+ public function apiAdd()
+ {
+ $title = '接口添加';
+ return $this->fetch('apiAdd', ['title' => $title]);
+ }
+
+ public function apiPostadd()
+ {
+ $data = input('post.');
+ if (empty($data['name'])) {
+ return returnJsonData(201, '接口名称不能为空', null);
+ }
+ $sort_id = Db::name('sort')->where('name',$data['sort'])->find();
+ $data['sort'] = $sort_id['id'];
+ $data['time'] = time();
+ $res = Db::name('info')->insert($data);
+ if($res){
+ return returnJsonData(200, '添加成功');
+ }else{
+ return returnJsonData(201, '添加失败');
+ }
+
+ }
+
+ public function apiEdit()
+ {
+ $title = '接口编辑';
+ $data = Db::name('sort')->where('type',0)->order('id asc')->select();
+ return $this->fetch('apiEdit', [
+ 'title' => $title,
+ 'data' => $data,
+ ]);
+ }
+
+ public function apiUpdate()
+ {
+ $data = array_filter(input('post.'));
+ if(!empty($data['sort'])){
+ $sort_id = Db::name('sort')->where('name',$data['sort'])->find();
+ $data['sort'] = $sort_id['id'];
+ $data['time'] = time();
+ $res = Db::name('info')->where('id',$data['id'])->update($data);
+ if($res){
+ return returnJsonData(200, '更新成功',null);
+ }else{
+ return returnJsonData(201, '更新失败',null);
+ }
+ }
+ else{
+ return returnJsonData(201, '参数错误',null);
+ }
+ }
+
+ public function getList()
+ {
+ $data = Db::name('info')->order('id asc')->paginate(10);
+ return returnJsonData(200, '获取成功', $data);
+ }
+
+ public function apiList()
+ {
+ $title = '接口列表';
+ $data = Db::name('info')->order('id asc')->paginate(10);
+ $page = $data->render();
+ return $this->fetch('apiList', [
+ 'title' => $title,
+ 'page' => $page,
+ 'data' => $data,
+ ]);
+ }
+
+ public function apiOper()
+ {
+ $id = input('id');
+ if(\request()->isPost()){
+ $data = Db::name('info')->where('id', $id)->delete();
+ if ($data) {
+ return returnJsonData(200, '删除成功', null);
+ } else {
+ return returnJsonData(201, '删除失败', null);
+ }
+ }else{
+ $data = Db::name('info')->where('id', $id)->find();
+ $sort = Db::name('sort')->where('id', $data['sort'])->find();
+ $data['sort_name'] = $sort['name'];
+ if ($data) {
+ return returnJsonData(200, '获取成功', $data);
+ } else {
+ return returnJsonData(201, '获取失败', null);
+ }
+ }
+ }
+}
+
+
diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php
index 5593693..31d53c3 100644
--- a/application/admin/controller/Index.php
+++ b/application/admin/controller/Index.php
@@ -1,235 +1,268 @@
error('您没有登陆',url('Login/index'));
- }
- }
-
- public function logout()
+ public function initialize()
{
- $_SESSION = array();
- if(isset($_COOKIE[session_name()])){
- setcookie(session_name(),'',time()-1);
+ parent::initialize();
+ if (empty(Session::get('adminid')) || empty(Session::get('adminname'))) {
+ return redirect((string) url('login/index'))->send();
}
- session_destroy();
- $this->success('您已退出登录,请重新登录','/');
}
public function index()
{
- $apicount = Db::name('info')->count();
- $apinum = Db::name('setup')->column('counts');
- $userinfo = Db::name('user')->where('id',1)->find();
- return view('index', [
- 'count' => $apicount,
- 'userinfo' => $userinfo,
- 'num' => $apinum[0],
- ]);
+ $title = '仪表盘';
+ return $this->fetch('index', [
+ 'title' => $title,
+ ]);
}
- public function upuser()
+
+ public function logout()
{
- if (empty(input('post.password'))) {
- $this->error("密码禁止为空");
- }
- $data = [
- 'username' => input('post.username'),
- 'password' => jmpwd(input('post.password')),
- ];
- $re = Db::name('user')->where('id','1')->update($data);
- if ($re) {
- $this->success("修改信息成功");
- }else{
- $this->error("修改信息失败");
- }
+ Session::delete('adminid');
+ Session::delete('adminname');
+ return returnJsonData(200,'正在退出',null);
}
- public function add()
+
+ public function siteUpdate()
{
- $data = Db::name('info')->where("sort","1")->select();
- return view('add', [
- 'sort' => $data,
- ]);
+ $title = '检测更新';
+ $version = file_get_contents('https://tenapi.cn/version');
+ $version = json_decode($version, true);
+ if ($version['version'] > config('app_version')) {
+ return returnJsonData(200,'发现新版本,请更新', $version);
+ } else {
+ return returnJsonData(201,'当前已是最新版本', null);
+ }
}
- public function upadd()
+
+ public function setup()
{
- $data = [
- 'name' => input('post.apiname'),
- 'doc' => input('post.apidoc'),
- 'miaoshu' => input('post.miaoshu'),
- 'demo' => input('post.diaoyong'),
- 'democode' => htmlspecialchars(input('post.democode')),
- 'url' => input('post.apipost'),
- 'request' => htmlspecialchars(input('post.apiposts')),
- 'icon' => input('post.apiicon'),
- 'type' => input('post.type'),
- 'pid' => input('post.sort'),
- 'time' => time(),
- ];
- $re = Db::name('info')->insert($data);
- if ($re) {
- $this->success("添加成功");
- }else{
- $this->error("添加失败");
- }
+ $title = '站点设置';
+ return $this->fetch('setup', ['title' => $title]);
}
- public function list()
+
+ function getSetup()
{
- $api=Db::name('info')->order('id asc')->paginate(10);
- $page = $api->render();
- return view('list', [
- 'api' => $api,
- 'page' => $page,
- ]);
+ $data = Db::name('setup')->find();
+ return returnJsonData(200, '获取成功', $data);
}
- public function edit()
+
+ function setSetup()
{
- $id = $_GET['id'];
- $api=Db::name('info')->where('id',$id)->select();
- $data = Db::name('info')->where("sort","1")->select();
- $nbaxd['sort'] = $data;
- return view('edit', [
- 'api' => $api,
- 'sort' => $data,
- ]);
+ $data = input('post.');
+ $res = Db::name('setup')->where('id',1)->update($data);
+ if ($res) {
+ return returnJsonData(200, '更新成功', null);
+ } else {
+ return returnJsonData(201, '更新失败', null);
+ }
}
- public function upedit()
+
+ public function getCount()
{
+ $info = Db::name('info')->count();
+ $sort = Db::name('sort')->count();
+ $post = Db::name('post')->count();
+ $count = Db::name('info')->sum('count');
+ $data = Db::name('info')->order('count desc')->limit(10)->field('id,name,count')->select();
$data = [
- 'name' => input('post.apiname'),
- 'doc' => input('post.apidoc'),
- 'miaoshu' => input('post.miaoshu'),
- 'demo' => input('post.diaoyong'),
- 'democode' => htmlspecialchars(input('post.democode')),
- 'url' => input('post.apipost'),
- 'request' => htmlspecialchars(input('post.apiposts')),
- 'icon' => input('post.apiicon'),
- 'type' => input('post.type'),
- 'time' => time(),
+ 'info' => $info,
+ 'sort' => $sort,
+ 'post' => $post,
+ 'count' => $count,
+ 'top10' => $data,
];
- $id = (int)input('post.id');
- $re = Db::name('info')->where('id',$id)->update($data);
- if ($re) {
- $this->success("修改API成功");
- }else{
- $this->error("修改API失败");
+ return returnJsonData(200, '获取成功', $data);
+ }
+
+ public function getNew10()
+ {
+ $log = Db::name('setup')->field('log')->find();
+ $file = $log["log"];
+ $num = 10;
+ $fp = @fopen($file,"r");
+ if(!$fp){
+ return returnJsonData(201, '获取失败', null);
+ }
+ $pos = -2;
+ $eof = "";
+ $head = false;
+ $data = array();
+ while($num>0){
+ while($eof != "\n"){
+ if(fseek($fp, $pos, SEEK_END)==0){
+ $eof = fgetc($fp);$pos--;
+ }else{
+ fseek($fp,0,SEEK_SET);$head = true;break;
+ }
+ }
+ array_unshift($data,fgets($fp));
+ if($head){ break; }$eof = "";$num--;
}
+ fclose($fp);
+ $data = str_replace('"', ' ', $data);
+ $data = str_replace('[', '', $data);
+ $data = str_replace(']', '', $data);
+ $data = str_replace('- - ', '', $data);
+ $data = str_replace(' ', ' ', $data);
+ $data = str_replace('?', ' ', $data);
+ $data = array_map('explode', array_fill(0, count($data), ' '), $data);
+ rsort($data);
+ return returnJsonData(200, '获取成功', $data);
}
- public function apidel()
+
+ public function editUserinfo()
{
- $id = $_GET['id'];
- $re=Db::name('info')->where('id',$id)->delete();
- if ($re) {
- $this->success("此API已被删除",url('Index/list'));
+ if(\request()->isPost()){
+ $data = input('post.');
+ $data = [
+ 'username' => $data['username'],
+ 'password' => hashPwd($data['password']),
+ 'email' => $data['email'],
+ ];
+ $res = Db::name('user')->where('uid', 1)->update(array_filter($data));
+ if($res){
+ return returnJsonData(200, '修改成功');
+ }else{
+ return returnJsonData(201, '修改失败');
+ }
}else{
- $this->error("删除失败,请确认API是否存在",url('Index/list'));
+ $info = Db::name('user')->where('uid', 1)->find();
+ $data = [
+ 'username' => $info['username'],
+ 'email' => $info['email'],
+ 'time' => $info['time'],
+ ];
+ return returnJsonData(200, '获取成功', $data);
}
}
- public function site()
+
+ public function apiSearch()
{
- $api=Db::name('setup')->select();
- return view('site', [
- 'api' => $api,
- ]);
+ $title = '接口搜索';
+ return $this->fetch('search', ['title' => $title]);
}
- public function upsite()
+
+ public function apiSearchlist()
{
- $data = [
- 'title' => input('post.title'),
- 'url' => input('post.url'),
- 'description' => input('post.description'),
- 'keywords' => input('post.keyword'),
- 'baidutongji' => htmlspecialchars(input('post.baidutongji')),
- 'code' => input('post.code'),
- ];
- $re = Db::name('setup')->where('id',1)->update($data);
- if ($re) {
- $this->success("修改信息成功");
- }else{
- $this->error("修改信息失败");
+ $keyword = input('keyword');
+ if (!empty($keyword)) {
+ $data = Db::name('info')->where('name', 'like', '%' . $keyword . '%')->order('id asc')->paginate(10);
+ if (count($data) > 0) {
+ return returnJsonData(200, '搜索成功', $data);
+ } else {
+ return returnJsonData(201, '没有检索到您输入的关键字', null);
+ }
+ } else {
+ return returnJsonData(201, '请输入关键词', null);
}
+
}
- public function search()
+
+ public function black()
{
- $where_like = ['name','like','%' . $_GET['keyword'] . '%'];
- $api = Db::name('info')->where($where_like[0],$where_like[1],$where_like[2])->select();
- if($api==null){
- return view('search', [
- 'api' => '',
- 'tips' => '抱歉,没有符合您查询条件的结果',
- ]);
- }
- return view('search', [
- 'api' => $api,
- 'tips' => '查询成功',
- ]);
+ $title = '请求限制';
+ return $this->fetch('black', ['title' => $title]);
}
- public function sort()
+
+ public function postBlack()
{
- $sort = Db::name('info')->where("sort","1")->select();
- return view('sort', [
- 'sort' => $sort,
- ]);
+ $data = input('post.');
+ if (!empty($data['value'])) {
+ $data['time'] = time();
+ $res = Db::name('black')->insert($data);
+ if ($res) {
+ $this->insertData();
+ return returnJsonData(200, '添加成功', null);
+ } else {
+ return returnJsonData(201, '添加失败', null);
+ }
+ } else {
+ return returnJsonData(201, '请输入限制目标', null);
+ }
}
- public function adds()
+ public function blacklist()
{
- return $this->fetch();
+ $data = Db::name('black')->order('id desc')->paginate(10);
+ if (count($data) > 0) {
+ return returnJsonData(200, '获取成功', $data);
+ } else {
+ return returnJsonData(201, '没有数据', null);
+ }
}
- public function upadds()
+
+ public function blackOper()
{
- $data = [
- 'name' => input('post.sortname'),
- 'icon' => input('post.sorticon'),
- 'sort' => '1',
- 'time' => time(),
- ];
- $re = Db::name('info')->insert($data);
- if ($re) {
- $this->success("添加成功");
+ $id = input('id');
+ if(\request()->isPost()){
+ $data = Db::name('black')->where('id', $id)->delete();
+ if ($data) {
+ $this->insertData();
+ return returnJsonData(200, '删除成功', null);
+ } else {
+ return returnJsonData(201, '删除失败', null);
+ }
}else{
- $this->error("添加失败");
+ $data = Db::name('black')->where('id', $id)->find();
+ if ($data) {
+ return returnJsonData(200, '获取成功', $data);
+ } else {
+ return returnJsonData(201, '获取失败', null);
+ }
}
}
- public function edits()
- {
- $id = $_GET['id'];
- $sort = Db::name('info')->where('id',$id)->select();
- return view('edits', [
- 'sort' => $sort,
- ]);
- }
- public function upedits()
+ public function getList()
{
- $data = [
- 'name' => input('post.sortname'),
- 'icon' => input('post.sorticon'),
- 'time' => time(),
- ];
- $id = (int)input('post.id');
- $re = Db::name('info')->where('id',$id)->update($data);
- if ($re) {
- $this->success("分类修改成功");
- }else{
- $this->error("分类修改失败");
+ $data = Db::name('black')->order('id asc')->paginate(10);
+ if (count($data) > 0) {
+ return returnJsonData(200, '获取成功', $data);
+ } else {
+ return returnJsonData(201, '没有数据', null);
}
}
- public function sortdel()
+
+ public function blackEdit()
{
- $id = $_GET['id'];
- $re=Db::name('info')->where('id',$id)->delete();
- if ($re) {
- $this->success("分类删除成功",url('Index/sort'));
+ $title = '编辑限制';
+ return $this->fetch('blackEdit', ['title' => $title]);
+ }
+
+ public function blackUpdate()
+ {
+ $data = input('post.');
+ if(!empty($data['id'])){
+ $data['time'] = time();
+ $res = Db::name('black')->where('id',$data['id'])->update($data);
+ if($res){
+ return returnJsonData(200, '更新成功',null);
+ }else{
+ return returnJsonData(201, '更新失败',null);
+ }
}else{
- $this->error("删除失败,请确认分类是否存在",url('Index/sort'));
+ return returnJsonData(201, '参数错误',null);
}
}
+
+ public function insertData(){
+ $config='black.data';
+ $ilist = Db::name('black')->where('type',1)->field('value')->select();
+ $rlist = Db::name('black')->where('type',0)->field('value')->select();
+ $fp=fopen($config,'w');
+ $data=[
+ 'ip'=>[$ilist],
+ 're'=>[$rlist]
+ ];
+ fwrite($fp,json_encode($data));
+ fclose($fp);
+ }
}
-?>
diff --git a/application/admin/controller/Login.php b/application/admin/controller/Login.php
index 980e12a..3e57d74 100644
--- a/application/admin/controller/Login.php
+++ b/application/admin/controller/Login.php
@@ -1,72 +1,63 @@
success("您已登录,正在跳转后台",url('index/index'));
- }
- }
- public function index(){
- return $this->fetch();
- }
- public function fromlogin(){
- $username=$this->remove_xss($_POST['username']);
- $password = jmpwd($_POST['password']);
- $re = Db::name('user')->where(array('username' =>$username ,'password'=>$password ))->find();
- if (!empty($re)) {
- $data = $re['id'];
- Session::set('USER_INFO_ID',$data);
- $this->success("登入成功,正在跳转后台",url('index/index'));
- }else{
- $this->error("登入失败!请检查信息");
- }
- }
- function remove_xss($val) {
- $val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val);
- $search = 'abcdefghijklmnopqrstuvwxyz';
- $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $search .= '1234567890!@#$%^&*()';
- $search .= '~`";:?+/={}[]-_|\'\\';
- for ($i = 0; $i < strlen($search); $i++) {
- $val = preg_replace('/([xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); // with a ;
- $val = preg_replace('/({0,8}'.ord($search[$i]).';?)/', $search[$i], $val); // with a ;
- }
- $ra1 = array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base');
- $ra2 = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload');
- $ra = array_merge($ra1, $ra2);
- $found = true; // keep replacing as long as the previous round replaced something
- while ($found == true) {
- $val_before = $val;
- for ($i = 0; $i < sizeof($ra); $i++) {
- $pattern = '/';
- for ($j = 0; $j < strlen($ra[$i]); $j++) {
- if ($j > 0) {
- $pattern .= '(';
- $pattern .= '([xX]0{0,8}([9ab]);)';
- $pattern .= '|';
- $pattern .= '|({0,8}([9|10|13]);)';
- $pattern .= ')*';
- }
- $pattern .= $ra[$i][$j];
- }
- $pattern .= '/i';
- $replacement = substr($ra[$i], 0, 2).''.substr($ra[$i], 2); // add in <> to nerf the tag
- $val = preg_replace($pattern, $replacement, $val); // filter out the hex tags
- if ($val_before == $val) {
- // no replacements were made, so exit the loop
- $found = false;
- }
- }
- }
- return $val;
- }
-
-}
+ public function index()
+ {
+ if(!request()->isPost())
+ {
+ return $this->fetch();
+ }else{
+ $code = removeXss(input('post.checkcode'));
+ $username = removeXss(input('post.username'));
+ $password = removeXss(input('post.password'));
+ $server = Db::name('setup')->field('server')->find();
+ $captcha = new Captcha();
+ if(!$captcha->check($code))
+ {
+ return returnJsonData(201,'验证码错误',null);
+ }
+ if(empty($username))
+ {
+ return returnJsonData(201,'用户名不能为空',null);
+ }
+ if(empty($password))
+ {
+ return returnJsonData(201,'密码不能为空',null);
+ }
+ $info = Db::name('user')->where('username',$username)->find();
+ if(empty($info))
+ {
+ return returnJsonData(201,'信息有误',null);
+ }
+ $pass = hashPwd($password);
+ if($pass != $info['password'])
+ {
+ return returnJsonData(201,'信息有误',null);
+ }
+ Session::set('adminid', $info['uid']);
+ Session::set('adminname', $info['username']);
+ if(!empty($server['server']))
+ {
+ $ip = get_ip();
+ $send = "https://sctapi.ftqq.com/".$server['server'].".send?title=%E7%99%BB%E5%BD%95%E6%8F%90%E9%86%92&desp=". $ip."%E7%99%BB%E5%BD%95%E6%88%90%E5%8A%9F";
+ file_get_contents($send);
+ }
+ return returnJsonData(200,'正在登录',null);
+ }
+ }
+
+ public function verify()
+ {
+ $config = ['length' => 4];
+ $captcha = new Captcha($config);
+ return $captcha->entry();
+ }
+ }
?>
diff --git a/application/admin/controller/Post.php b/application/admin/controller/Post.php
new file mode 100644
index 0000000..e3337f1
--- /dev/null
+++ b/application/admin/controller/Post.php
@@ -0,0 +1,113 @@
+send();
+ }
+ }
+
+ public function postAdd()
+ {
+ $title = '文章发布';
+ return $this->fetch('postAdd', ['title' => $title]);
+ }
+
+ public function articleAdd()
+ {
+ $data = input('post.');
+ if (empty($data['title'])) {
+ return returnJsonData(201, '标题不能为空', null);
+ }
+ $sort_id = Db::name('sort')->where('name',$data['sort'])->find();
+ $data['sort'] = $sort_id['id'];
+ $data['time'] = time();
+ $res = Db::name('post')->insert($data);
+ if($res){
+ return returnJsonData(200, '发布成功', null);
+ }else{
+ return returnJsonData(201, '发布失败', null);
+ }
+ }
+
+ public function postList()
+ {
+ $title = '文章列表';
+ return $this->fetch('postList', ['title' => $title]);
+ }
+
+ public function getList()
+ {
+ $data = Db::name('post')->order('id asc')->field('id,sort,title,time')->paginate();
+ $data = json_decode(json_encode($data),true);
+
+ foreach ($data["data"] as $key => $value) {
+ $sort_id = $value['sort'];
+ $sort_name = Db::name('sort')->where('id',$sort_id)->field('id,name')->find();
+ $data["data"][$key]["sort"] = $sort_name["name"];
+ }
+
+ if ($data["total"] > 0) {
+ return returnJsonData(200, '获取成功', $data);
+ }else{
+ return returnJsonData(201, '获取失败', null);
+ }
+ }
+
+ public function postEdit()
+ {
+ $title = '文章编辑';
+ return $this->fetch('postEdit', ['title' => $title]);
+ }
+
+ public function postOper()
+ {
+ $id = input('id');
+ if(\request()->isPost()){
+ $data = Db::name('post')->where('id', $id)->delete();
+ if ($data) {
+ return returnJsonData(200, '删除成功', null);
+ } else {
+ return returnJsonData(201, '删除失败', null);
+ }
+ }else{
+ $data = Db::name('post')->where('id', $id)->find();
+ $sort_name = Db::name('sort')->where('id',$data['sort'])->field('id,name')->find();
+ $data['sort'] = $sort_name['name'];
+ if ($data) {
+ return returnJsonData(200, '获取成功', $data);
+ } else {
+ return returnJsonData(201, '获取失败', null);
+ }
+ }
+ }
+
+ public function postUpdate()
+ {
+ $data = array_filter(input('post.'));
+ if(!empty($data['sort'])){
+ $sort_id = Db::name('sort')->where('name',$data['sort'])->find();
+ $data['sort'] = $sort_id['id'];
+ $data['time'] = time();
+ $res = Db::name('post')->where('id',$data['id'])->update($data);
+ if($res){
+ return returnJsonData(200, '更新成功',null);
+ }else{
+ return returnJsonData(201, '更新失败',null);
+ }
+ }
+ else{
+ return returnJsonData(201, '参数错误',null);
+ }
+ }
+}
+
+
diff --git a/application/admin/controller/Sort.php b/application/admin/controller/Sort.php
new file mode 100644
index 0000000..bc3bd10
--- /dev/null
+++ b/application/admin/controller/Sort.php
@@ -0,0 +1,97 @@
+send();
+ }
+ }
+
+ public function sortAdd()
+ {
+ $title = '分类添加';
+ return $this->fetch('sortAdd', ['title' => $title]);
+ }
+
+ public function getList()
+ {
+ $data = Db::name('sort')->order('id asc')->paginate(10);
+ return returnJsonData(200, '获取成功', $data);
+ }
+
+ public function sortList()
+ {
+ $title = '分类列表';
+ return $this->fetch('sortList', ['title' => $title]);
+ }
+
+ public function sortPostadd()
+ {
+ $data = input('post.');
+ $data['time'] = time();
+ if (empty($data['name'])) {
+ return returnJsonData(201, '分类名称不能为空', null);
+ }
+ $res = Db::name('sort')->insert($data);
+ if($res){
+ return returnJsonData(200, '添加成功',null);
+ }else{
+ return returnJsonData(201, '添加失败',null);
+ }
+ }
+
+ public function sortEdit()
+ {
+ $title = '分类编辑';
+ return $this->fetch('sortEdit', ['title' => $title]);
+ }
+
+ public function sortUpdate()
+ {
+ $data = input('post.');
+ if(!empty($data['id'])){
+ $data['time'] = time();
+ $res = Db::name('sort')->where('id',$data['id'])->update($data);
+ if($res){
+ return returnJsonData(200, '更新成功',null);
+ }else{
+ return returnJsonData(201, '更新失败',null);
+ }
+ }else{
+ return returnJsonData(201, '参数错误',null);
+ }
+ }
+
+ public function sortOper()
+ {
+ $id = input('id');
+ if(\request()->isPost()){
+ $data = Db::name('sort')->where('id', $id)->delete();
+ if($id == 1 || $id == 2){
+ return returnJsonData(201, '默认分类不能删除',null);
+ }
+ if ($data) {
+ return returnJsonData(200, '删除成功', null);
+ } else {
+ return returnJsonData(201, '删除失败', null);
+ }
+ }else{
+ $data = Db::name('sort')->where('id', $id)->find();
+ if ($data) {
+ return returnJsonData(200, '获取成功', $data);
+ } else {
+ return returnJsonData(201, '获取失败', null);
+ }
+ }
+ }
+}
+
+
diff --git a/application/admin/view/api/apiAdd.html b/application/admin/view/api/apiAdd.html
new file mode 100644
index 0000000..c673246
--- /dev/null
+++ b/application/admin/view/api/apiAdd.html
@@ -0,0 +1,172 @@
+{include file="header" title="$title" /}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
http[s]://domain.com/doc/[文档地址]
+
+
+
+
+
+
http[s]://domain.com/api/[接口地址]
+
+
+
+
+
+
+
+
name1=value&name2=value
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{include file="footer" /}
\ No newline at end of file
diff --git a/application/admin/view/api/apiEdit.html b/application/admin/view/api/apiEdit.html
new file mode 100644
index 0000000..d80d82d
--- /dev/null
+++ b/application/admin/view/api/apiEdit.html
@@ -0,0 +1,191 @@
+{include file="header" title="$title" /}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
http[s]://domain.com/doc/[文档地址]
+
+
+
+
+
+
http[s]://domain.com/api/[接口地址]
+
+
+
+
+
+
+
+
name1=value&name2=value
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{include file="footer" /}
\ No newline at end of file
diff --git a/application/admin/view/api/apiList.html b/application/admin/view/api/apiList.html
new file mode 100644
index 0000000..4e09446
--- /dev/null
+++ b/application/admin/view/api/apiList.html
@@ -0,0 +1,69 @@
+{include file="header" title="$title" /}
+
+
+
+
+
+
+
+
+ # |
+ 接口名称 |
+ 接口路径 |
+ 调用次数 |
+ 最后修改时间 |
+ 操作管理 |
+
+
+
+
+
+
+
+
+
+
+{include file="footer" /}
\ No newline at end of file
diff --git a/application/admin/view/api/apiRequest.html b/application/admin/view/api/apiRequest.html
new file mode 100644
index 0000000..9ce88eb
--- /dev/null
+++ b/application/admin/view/api/apiRequest.html
@@ -0,0 +1 @@
+{include file="header" title="$title" /} {include file="footer" title="$title" /}
\ No newline at end of file
diff --git a/application/admin/view/footer.html b/application/admin/view/footer.html
new file mode 100644
index 0000000..98de58d
--- /dev/null
+++ b/application/admin/view/footer.html
@@ -0,0 +1,6 @@
+
+
+
+