Compare commits

..
196 Commits
Author SHA1 Message Date
Mr Chen 26a6a80504 u 2018-12-03 13:52:12 +08:00
Mr Chen 498799578a u 2018-12-03 13:44:20 +08:00
Mr Chen 6a5b009766 u 2018-12-03 13:39:06 +08:00
Mr Chen 8e23411be8 u 2018-12-03 13:11:43 +08:00
Mr Chen b597255d68 u 2018-12-03 12:49:03 +08:00
Mr Chen 8979011ec3 u 2018-12-03 10:58:41 +08:00
midoks 11a21f9a8b Update crontab.html 2018-12-02 23:27:47 +08:00
midoks 1a12f625cd up 2018-12-02 22:58:14 +08:00
midoks 11e44d5b0e 监控完成 2018-12-02 21:59:33 +08:00
midoks 47c1394de6 u 2018-12-02 12:58:59 +08:00
midoks 5e7fa28feb Update task.py 2018-12-01 18:04:59 +08:00
midoks d04f891ee7 up 2018-12-01 18:02:30 +08:00
midoks 3d28e0a3cb u 2018-12-01 17:20:10 +08:00
Mr Chen 37112546b9 Delete system.db 2018-11-30 19:13:20 +08:00
Mr Chen cb719c9973 Update .gitignore 2018-11-30 19:13:01 +08:00
Mr Chen 7ec5fe84b2 update 2018-11-30 19:12:16 +08:00
Mr Chen c68cce0198 up 2018-11-30 17:39:38 +08:00
Mr Chen 0d7fd11de5 up 2018-11-30 16:58:50 +08:00
Mr Chen 643a2e8cf8 u 2018-11-30 14:54:06 +08:00
midoks 35ee7d3d10 优化 2018-11-30 02:03:05 +08:00
midoks 2ce3871ee2 Update .gitignore 2018-11-29 21:04:39 +08:00
midoks 812ce86187 u 2018-11-29 21:04:13 +08:00
Mr Chen 3d44b3014f u 2018-11-29 19:16:12 +08:00
Mr Chen 092494a216 Update soft.js 2018-11-29 19:09:27 +08:00
Mr Chen a21ad254b7 Update soft.js 2018-11-29 19:07:28 +08:00
Mr Chen ebd6b9f389 u 2018-11-29 18:19:18 +08:00
midoks 33b90a976b 版本显示优化 2018-11-28 23:56:10 +08:00
midoks 2518d32019 wd 2018-11-28 21:35:26 +08:00
Mr Chen 4ded4679f3 up 2018-11-28 19:11:55 +08:00
midoks 28d3996d17 openresty 2018-11-27 23:29:28 +08:00
midoks b76950ed3b php 72 2018-11-27 23:05:01 +08:00
Mr Chen d49aa168eb u 2018-11-27 19:20:46 +08:00
Mr Chen 5304d0b228 u 2018-11-27 14:37:24 +08:00
Mr Chen 56e4ef1a4e u 2018-11-27 13:17:06 +08:00
Mr Chen 91fc83e0ba a 2018-11-26 19:18:50 +08:00
Mr Chen fc0fdd5772 u 2018-11-26 16:08:19 +08:00
Mr Chen 0d0007d9a1 u 2018-11-26 15:57:49 +08:00
Mr Chen a74ace856a u 2018-11-26 15:54:42 +08:00
Mr Chen f46af799a9 代码调整 2018-11-26 14:35:52 +08:00
Mr Chen 3e4facbf57 u 2018-11-26 13:57:06 +08:00
Mr Chen ff9466d0a4 wd 2018-11-26 11:51:27 +08:00
Mr Chen 9cbcff5dbc 优化 2018-11-26 10:55:53 +08:00
midoks 90834415bf update 2018-11-25 23:30:19 +08:00
midoks c2862ab5d4 Update index.js 2018-11-25 18:11:30 +08:00
midoks 664a7864bc 首页界面更新 2018-11-25 18:05:39 +08:00
midoks 9cf6a40493 update 2018-11-25 17:48:48 +08:00
midoks 028422337e mem 2018-11-25 16:46:23 +08:00
midoks 5f10d9433c redis 设置 2018-11-25 16:13:59 +08:00
Mr Chen ed49f0b0bd Update redis.js 2018-11-23 19:14:18 +08:00
Mr Chen 090fc0f243 redis文件修改 2018-11-23 15:02:02 +08:00
Mr Chen f2df81694f Update install.sh 2018-11-23 11:45:53 +08:00
Mr Chen 6cf2e2d6b6 wd 2018-11-23 11:39:15 +08:00
Mr Chen defdc3d3b8 Update README.md 2018-11-23 10:09:19 +08:00
Mr Chen 6d1d1b882e Update install.sh 2018-11-22 18:58:46 +08:00
Mr Chen 54f90c9300 Update install.sh 2018-11-22 18:56:28 +08:00
Mr Chen a1aa7d465d Update README.md 2018-11-22 18:49:41 +08:00
Mr Chen 62214c2a88 Update plugins.py 2018-11-22 18:44:19 +08:00
Mr Chen d5a4958566 wd 2018-11-22 17:47:19 +08:00
Mr Chen 0bca4a3589 wd 2018-11-22 17:08:26 +08:00
Mr Chen 30bc8b1ec1 u 2018-11-21 19:27:26 +08:00
Mr Chen 0472102a3a u 2018-11-21 19:15:37 +08:00
Mr Chen 2da863d98a u 2018-11-21 18:18:17 +08:00
Mr Chen 88bab4b15b wq 2018-11-21 10:15:35 +08:00
Mr Chen d1b4a1cde1 up 2018-11-20 19:11:09 +08:00
Mr Chen d88f6903da Update task.py 2018-11-20 18:54:29 +08:00
Mr Chen 3a53b360b7 o 2018-11-20 17:43:29 +08:00
Mr Chen 3e5b951a41 wd 2018-11-20 14:01:17 +08:00
Mr Chen 272b6fdeea up 2018-11-19 13:32:17 +08:00
Mr Chen 49ac781e87 wq 2018-11-13 14:18:06 +08:00
Mr Chen b4f9fa0976 Update route/dashboard.py 2018-11-12 17:24:59 +08:00
Mr Chen 96baa99bdc wq 2018-11-12 17:22:47 +08:00
Mr Chen 5db4f39c76 o 2018-11-12 14:43:14 +08:00
Mr Chen 23dadd7f6f wq 2018-11-12 14:38:35 +08:00
Mr Chen 7d8d48f3d5 wq 2018-11-12 12:55:17 +08:00
Mr Chen 74fd4bbe08 o 2018-11-12 11:41:00 +08:00
midoks 30240443e6 update 2018-11-11 23:51:11 +08:00
Mr Chen e069c3a24e w 2018-11-09 16:41:11 +08:00
Mr Chen 73e75abb5f w 2018-11-09 16:23:17 +08:00
Mr Chen b35d516a8e o 2018-11-09 15:46:28 +08:00
Mr Chen aa1875612b Update templates/default/layout.html 2018-11-09 11:10:33 +08:00
Mr Chen b189d5b485 Update templates/default/layout.html 2018-11-09 11:10:11 +08:00
Mr Chen 33b43b253c Update templates/default/layout.html 2018-11-09 11:09:47 +08:00
midoks 86cfb1b9cf q 2018-11-08 22:56:12 +08:00
Mr Chen f93afb772c Update templates/default/login.html 2018-11-08 17:59:31 +08:00
Mr Chen bd49bd3004 Update scripts/install.sh 2018-11-08 17:54:27 +08:00
Mr Chen db26b09eba q 2018-11-08 17:38:15 +08:00
Mr Chen 85da65ad1e Update templates/default/login.html 2018-11-08 17:24:44 +08:00
Mr Chen d9a409ffcc Update app.py 2018-11-08 17:22:03 +08:00
Mr Chen ea923a45a6 q 2018-11-08 17:19:13 +08:00
Mr Chen 7480cfb5d8 Update static/css/install.css 2018-11-08 17:18:59 +08:00
Mr Chen be513af18e q 2018-11-08 17:09:25 +08:00
Mr Chen 1c5e61a3de q 2018-11-08 17:09:06 +08:00
Mr Chen d26474f222 a 2018-11-08 17:08:41 +08:00
Mr Chen 03c796775a Update static/js/jquery.qrcode.min.js 2018-11-08 17:06:06 +08:00
Mr Chen 182d434f84 d 2018-11-08 17:04:57 +08:00
Mr Chen 7c1d409e61 o 2018-11-08 16:53:01 +08:00
midoks dab12535f2 Update templates/default/login.html 2018-11-08 00:02:08 +08:00
midoks deffb3d61b Update route/dashboard.py 2018-11-08 00:02:05 +08:00
Mr Chen a4a45f2005 Update route/files.py 2018-11-07 18:45:34 +08:00
Mr Chen 32d6a89bd4 Update route/dashboard.py 2018-11-07 18:28:48 +08:00
Mr Chen f41c2454ee u 2018-11-07 18:13:05 +08:00
midoks 76dba077c0 o 2018-11-06 23:45:28 +08:00
Mr Chen 1c34488abb Update templates/default/login.html 2018-11-06 19:10:33 +08:00
Mr Chen 6742d971eb u 2018-11-06 13:42:24 +08:00
Mr Chen 3de01da4ba Update models/index.html 2018-11-06 13:23:16 +08:00
midoks 4ba526ca2b up 2018-11-06 00:28:02 +08:00
midoks a4e8b6a137 u 2018-11-05 23:47:37 +08:00
midoks 50ad3ed7e7 ww 2018-11-05 23:42:01 +08:00
Mr Chen 64d29659f7 u 2018-11-05 19:25:07 +08:00
Mr Chen 2794f49df4 u 2018-11-05 19:05:33 +08:00
Mr Chen 3e27f85719 u 2018-11-05 17:19:02 +08:00
Mr Chen a4d70f2294 up 2018-11-05 16:49:37 +08:00
midoks f3cd1f597e up 2018-11-04 23:37:33 +08:00
midoks 489c363daf u 2018-11-04 23:20:06 +08:00
midoks 77f44481b3 up 2018-11-04 23:02:45 +08:00
midoks fcd4ba024a u 2018-11-03 18:19:47 +08:00
Mr Chen ce6b15939d dd 2018-11-02 14:43:41 +08:00
Mr Chen baaccb7960 u 2018-11-02 13:38:20 +08:00
Mr Chen fb559e9f11 u 2018-11-02 10:18:58 +08:00
Mr Chen 283a2c052b u 2018-10-29 20:19:59 +08:00
Mr Chen a7bd9e3290 csvn dev 2018-10-29 14:10:41 +08:00
Mr Chen b64dbb9aa4 Update data/system.db 2018-10-26 16:56:15 +08:00
Mr Chen d9f63c3a9a u 2018-10-26 16:53:20 +08:00
Mr Chen 3c02af41bc u 2018-10-26 15:54:23 +08:00
Mr Chen ac87a6c8b1 Update app.py 2018-10-26 15:02:57 +08:00
Mr Chen f19dd2a2b9 u 2018-10-26 15:01:33 +08:00
Mr Chen cef7215fdc u 2018-10-26 13:53:39 +08:00
Mr Chen edb4fc96e1 u 2018-10-26 13:17:19 +08:00
midoks af9f8b73ba 修改模板 2018-10-25 23:23:37 +08:00
Mr Chen c85152e85a update 2018-10-25 19:32:21 +08:00
Mr Chen 2ee2440c68 u 2018-10-25 17:33:34 +08:00
Mr Chen ecfafc9723 u 2018-10-25 16:40:45 +08:00
Mr Chen dbb4414e65 Update .idea/vcs.xml 2018-10-24 17:27:45 +08:00
midoks a028e93881 u 2018-10-17 22:57:37 +08:00
midoks 475cb5176d u 2018-10-17 00:29:33 +08:00
midoks 8b07bd80e6 u 2018-10-17 00:17:59 +08:00
midoks 50d26d932f Update templates/default/config.html 2018-10-17 00:08:44 +08:00
midoks 22b5ab1179 Update del_pyc.sh 2018-10-14 20:55:05 +08:00
midoks f7c76fb261 画 2018-10-14 20:49:20 +08:00
midoks 6531f686ad Update templates/default/database.html 2018-10-14 18:20:27 +08:00
midoks b716f05fb4 u 2018-10-14 17:37:43 +08:00
midoks 9a98f1c859 u 2018-10-14 12:47:54 +08:00
midoks e92fc4cfd1 u 2018-10-14 11:49:24 +08:00
midoks da1a76cbef u 2018-10-13 22:54:11 +08:00
Mr Chen fa6b7c21ac u 2018-10-12 19:09:54 +08:00
Mr Chen 11748fd33b Update plugins/deployment/icon.png 2018-10-12 18:46:22 +08:00
midoks 267bbe3865 u 2018-10-12 10:35:29 +08:00
midoks dd27e4b076 Update class/page.py 2018-10-12 10:28:52 +08:00
Mr Chen 459229ba15 Update plugins/nginx/install.sh 2018-10-11 19:30:01 +08:00
Mr Chen 94c5161fde u 2018-10-11 19:26:06 +08:00
Mr Chen 5646d1404c u 2018-10-11 09:55:27 +08:00
Mr Chen ef8a10b68d Update views/plugins.py 2018-10-09 19:53:03 +08:00
Mr Chen c772696f3e Update views/plugins.py 2018-10-09 19:51:23 +08:00
Mr Chen 45faf4e9dd Update views/plugins.py 2018-10-08 20:10:44 +08:00
Mr Chen 5cbca9232c Update app.py 2018-10-08 11:52:55 +08:00
midoks 742bb6d86d u 2018-10-07 23:51:22 +08:00
midoks b14accd83e u 2018-10-07 20:54:10 +08:00
midoks 8ae01d8d36 u 2018-10-07 20:38:30 +08:00
midoks 5db1e58e6a u 2018-10-07 18:51:52 +08:00
midoks a2e6d2f280 u 2018-10-07 18:25:51 +08:00
midoks 83f3d224ed d 2018-10-07 17:57:08 +08:00
midoks 73693620df u 2018-10-07 17:42:46 +08:00
midoks 72eb67dfda u 2018-10-07 16:29:42 +08:00
midoks c55b4a02c8 插件 2018-10-02 21:50:10 +08:00
midoks 721efd6a16 up 2018-10-02 18:00:48 +08:00
midoks 61c8ce4b6f up 2018-10-02 17:24:26 +08:00
midoks ce95ca6905 up 2018-10-02 16:59:56 +08:00
Mr Chen 01dee5fe1f up 2018-09-26 20:03:12 +08:00
Mr Chen 1a72edee9a 更新 2018-09-26 20:02:11 +08:00
Mr Chen 27b6ad0280 up 2018-09-26 14:59:06 +08:00
Mr Chen ae9e6921c3 up 2018-09-26 13:32:57 +08:00
Mr Chen b51eb99027 up 2018-09-25 18:43:26 +08:00
Mr Chen 2e584c540d up 2018-09-25 17:01:20 +08:00
Mr Chen bbf258e1a7 up 2018-09-25 16:37:56 +08:00
Mr Chen 53d57716aa o 2018-09-25 14:16:10 +08:00
Mr Chen e9a6e5477d up 2018-09-25 13:59:20 +08:00
Mr Chen 46ca8a6b44 up 2018-09-25 12:50:06 +08:00
Mr Chen d6f88caf3d up 2018-09-21 14:18:29 +08:00
midoks abc85902a2 up 2018-09-15 16:45:14 +08:00
Mr Chen 9edc8bbea2 up 2018-09-14 19:18:36 +08:00
Mr Chen 443d3efd37 up 2018-09-14 15:23:04 +08:00
midoks 948bcde358 模版 2018-09-13 22:30:37 +08:00
midoks 83aa3cfca6 up 2018-09-13 22:26:34 +08:00
Mr Chen 976c88ed44 Delete .DS_Store 2018-09-13 22:24:06 +08:00
midoks 0db16797b5 up 2018-09-13 22:23:05 +08:00
midoks b7802fc898 更新说明 2018-09-13 22:22:23 +08:00
midoks 741dffd5db up 2018-09-13 22:20:52 +08:00
Mr Chen 2c9f11bcfe static 2018-09-13 13:36:11 +08:00
midoks 16893e51e6 up 2018-09-11 23:02:52 +08:00
midoks 34a43a6af9 up 2018-09-11 22:42:43 +08:00
midoks 4dd5d946d9 up 2018-09-11 22:39:22 +08:00
Mr Chen 7e63f686b9 up 2018-09-11 16:27:09 +08:00
Mr Chen 7b57972179 up 2018-09-11 14:50:44 +08:00
Mr Chen a758a36bdc test 2018-09-11 14:48:31 +08:00
Mr Chen 84123c603d Create README.md 2018-09-11 14:44:23 +08:00
Mr Chen 33f9c09a07 Initial commit 2018-09-11 14:44:15 +08:00
444 changed files with 33657 additions and 803 deletions
-5
View File
@@ -1,5 +0,0 @@
# These are supported funding model platforms
github: midoks
custom: https://afdian.net/a/mdserver-web
@@ -1,29 +0,0 @@
---
name: BUG提交
about: 问题描述
---
## 什么系统 ?
Debian x, Centos x, Centos x stream, Ubuntu x?
## 错误信息 ?
Ex:
```bash
一个issue,一个问题。多余问题,视情况而答。
```
## 错误截图 ?
...
## 浏览器版本 ?
...
## 软件版本(插件/面板) ?
...
@@ -1,14 +0,0 @@
---
name: 需求提交
about: 需求描述
---
## 需求
想开发一个什么插件?
想有什么功能?
## 提供参考
给开发者提供参考!
-24
View File
@@ -1,24 +0,0 @@
name: Bug提交
description: 提交错误报告以帮助我们改进
labels: ["\U0001F48A bug"]
body:
- type: markdown
attributes:
value: |
感谢您花时间填写此错误报告!
- 如有疑问,请讨论[Discussions](https://github.com/midoks/mdserver-web/discussions).
- 检查以确保尚未有人打开类似的[issue](https://github.com/midoks/mdserver-web/issues).
- type: input
attributes:
label: 操作系统
description: |
请指定您报告的确切操作系统名称和版本,例如"CentOS 7"、"Ubuntu 20.04"。
validations:
required: true
- type: textarea
attributes:
label: 描述错误
description: 对bug的清晰而简洁的描述。
validations:
required: true
-8
View File
@@ -1,8 +0,0 @@
blank_issues_enabled: true
contact_links:
- name: 提出问题
url: https://github.com/midoks/mdserver-web/discussions
about: 请在讨论中提出问题。
- name: 提出建议
url: https://github.com/midoks/mdserver-web/discussions/categories/proposal
about: 请在讨论中提出建议。
-24
View File
@@ -1,24 +0,0 @@
name: Bug提交
description: 提交错误报告以帮助我们改进
labels: ["\U0001F48A bug"]
body:
- type: markdown
attributes:
value: |
感谢您花时间填写此错误报告!
- 如有疑问,请讨论[Discussions](https://github.com/midoks/mdserver-web/discussions).
- 检查以确保尚未有人打开类似的[issue](https://github.com/midoks/mdserver-web/issues).
- type: input
attributes:
label: 操作系统
description: |
请指定您报告的确切操作系统名称和版本,例如"CentOS 7"、"Ubuntu 20.04"。
validations:
required: true
- type: textarea
attributes:
label: 描述错误
description: 对bug的清晰而简洁的描述。
validations:
required: true
@@ -1,24 +0,0 @@
name: Bug提交
description: 提交错误报告以帮助我们改进
labels: ["\U0001F48A bug"]
body:
- type: markdown
attributes:
value: |
感谢您花时间填写此错误报告!
- 如有疑问,请讨论[Discussions](https://github.com/midoks/mdserver-web/discussions).
- 检查以确保尚未有人打开类似的[issue](https://github.com/midoks/mdserver-web/issues).
- type: input
attributes:
label: 操作系统
description: |
请指定您报告的确切操作系统名称和版本,例如"CentOS 7"、"Ubuntu 20.04"。
validations:
required: true
- type: textarea
attributes:
label: 描述错误
description: 对bug的清晰而简洁的描述。
validations:
required: true
-3
View File
@@ -1,3 +0,0 @@
### 合并描述
- 我添加了测试用例来覆盖新代码。
-38
View File
@@ -1,38 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: MW APP MySQL55
on:
push:
branches: [ "run_test" ]
pull_request:
branches: [ "run_test" ]
permissions:
contents: read
jobs:
build:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install MW
run: |
sudo bash scripts/install_dev.sh
- name: Install MySQL55
run: |
cd /www/server/mdserver-web/plugins/mysql && sudo bash install.sh install 5.5
- name: Start DEBUG
run: |
gunicorn -c setting.py app:app
python3 task.py &
-38
View File
@@ -1,38 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: MW APP MySQL56
on:
push:
branches: [ "run_test" ]
pull_request:
branches: [ "run_test" ]
permissions:
contents: read
jobs:
build:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install MW
run: |
sudo bash scripts/install_dev.sh
- name: Install MySQL56
run: |
cd /www/server/mdserver-web/plugins/mysql && sudo bash install.sh install 5.6
- name: Start DEBUG
run: |
gunicorn -c setting.py app:app
python3 task.py &
-38
View File
@@ -1,38 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: MW APP MySQL57
on:
push:
branches: [ "run_test" ]
pull_request:
branches: [ "run_test" ]
permissions:
contents: read
jobs:
build:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install MW
run: |
sudo bash scripts/install_dev.sh
- name: Install MySQL57
run: |
cd /www/server/mdserver-web/plugins/mysql && sudo bash install.sh install 5.7
- name: Start DEBUG
run: |
gunicorn -c setting.py app:app
python3 task.py &
-38
View File
@@ -1,38 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: MW APP MySQL80
on:
push:
branches: [ "run_test" ]
pull_request:
branches: [ "run_test" ]
permissions:
contents: read
jobs:
build:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install MW
run: |
sudo bash scripts/install_dev.sh
- name: Install MySQL80
run: |
cd /www/server/mdserver-web/plugins/mysql && sudo bash install.sh install 8.0
- name: Start DEBUG
run: |
gunicorn -c setting.py app:app
python3 task.py &
-38
View File
@@ -1,38 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: MW APP OpenResty
on:
push:
branches: [ "master", "dev" ]
pull_request:
branches: [ "master", "dev" ]
permissions:
contents: read
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install MW
run: |
sudo bash scripts/install_dev.sh
- name: Install OpenResty
run: |
cd /www/server/mdserver-web/plugins/openresty && sudo bash install.sh install 1.21.4.1
- name: Start DEBUG
run: |
gunicorn -c setting.py app:app
python3 task.py &
-68
View File
@@ -1,68 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: MW APP PHP
on:
push:
branches: [ "run_test" ]
pull_request:
branches: [ "run_test" ]
permissions:
contents: read
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install MW
run: |
sudo bash scripts/install_dev.sh
- name: Install PHP53
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 53
- name: Install PHP54
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 54
- name: Install PHP55
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 55
- name: Install PHP56
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 56
- name: Install PHP70
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 70
- name: Install PHP71
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 71
- name: Install PHP72
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 72
- name: Install PHP73
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 73
- name: Install PHP74
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 74
- name: Install PHP80
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 80
- name: Install PHP81
run: |
cd /www/server/mdserver-web/plugins/php && sudo bash install.sh install 81
- name: Start DEBUG
run: |
gunicorn -c setting.py app:app
python3 task.py &
+6 -76
View File
@@ -8,11 +8,13 @@ __pycache__/
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
@@ -104,79 +106,7 @@ venv.bak/
.DS_Store
.idea/*.xml
.idea/*.iml
tmp/*
*.swp
*.pem
*.zip
logs/*
data/*.db
data/control.conf
data/iplist.txt
data/json/index.json
data/json/config.json
data/site.pl
data/admin_path.pl
data/close.pl
data/datadir.pl
data/502Task.pl
data/default.pl
data/backup.pl
data/debug.pl
data/default_site.pl
ssl/input.pl
lib/python*
bin
pyvenv.cfg
include
share
pip-selfcheck.json
scripts/init.d/mw
scripts/mdserver-web
data/api_login.txt
data/sessions
data/ssl.pl
data/port.pl
data/ipv6.pl
data/restart.pl
data/ssl.pl
data/edate.pl
data/osname.pl
data/only_netio_counters.pl
data/system.db-journal
data/hook_*.json
data/letsencrypt.json
data/basic_auth.json
data/notify.json
data/api.json
data/bind_domain.pl
data/unauthorized_status.pl
plugins/vip_*
plugins/own_*
plugins/my_*
plugins/l2tp
plugins/openlitespeed
plugins/system_safe
plugins/tamper_proof
plugins/tamper_proof_*
plugins/cryptocurrency_trade
plugins/op_load_balance
plugins/gdrive
plugins/mtproxy
plugins/zimg
plugins/bk_demo
plugins/mail
plugins/fastdfs
plugins/v2ray
plugins/frp
plugins/file_search
debug.out
tmp/*.pl
tmp/*.log
data/json/index.json
data/system.db
-1
View File
@@ -1 +0,0 @@
www.midoks.icu
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+7
View File
@@ -0,0 +1,7 @@
# mdweb
简单的Linux面板
### 自动安装
```
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | sh
```
-1
View File
@@ -1 +0,0 @@
google.com, pub-7736695762519033, DIRECT, f08c47fec0942fa0
+55
View File
@@ -0,0 +1,55 @@
# coding:utf-8
import sys
import io
import os
import time
from datetime import timedelta
sys.path.append("/class/core/")
reload(sys)
sys.setdefaultencoding('utf8')
import route
from flask import Flask
app = Flask(__name__)
app.debug = True
DEFAULT_MODULES = (
(route.dashboard, "/"),
(route.site, "/site"),
(route.files, "/files"),
(route.soft, "/soft"),
(route.config, "/config"),
(route.plugins, "/plugins"),
(route.task, "/task"),
(route.system, "/system"),
(route.database, "/database"),
(route.crontab, "/crontab"),
(route.firewall, "/firewall"),
(route.control, "/control"),
)
# print "time.time(): %f " % time.time()
app.config.version = "0.0.1" + str(time.time())
app.config['SECRET_KEY'] = os.urandom(24)
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
def setting_modules(app, modules):
for module, url_prefix in modules:
app.register_blueprint(module, url_prefix=url_prefix)
setting_modules(app, DEFAULT_MODULES)
try:
if __name__ == "__main__":
app.run()
except Exception as ex:
print ex
+276
View File
@@ -0,0 +1,276 @@
# coding: utf-8
import sqlite3
import os
class Sql():
#------------------------------
# 数据库操作类 For sqlite3
#------------------------------
__DB_FILE = None # 数据库文件
__DB_CONN = None # 数据库连接对象
__DB_TABLE = "" # 被操作的表名称
__OPT_WHERE = "" # where条件
__OPT_LIMIT = "" # limit条件
__OPT_ORDER = "" # order条件
__OPT_FIELD = "*" # field条件
__OPT_PARAM = () # where值
def __init__(self):
self.__DB_FILE = 'data/default.db'
def __GetConn(self):
# 取数据库对象
try:
if self.__DB_CONN == None:
self.__DB_CONN = sqlite3.connect(self.__DB_FILE)
except Exception, ex:
return "error: " + str(ex)
def dbfile(self, name):
self.__DB_FILE = 'data/' + name + '.db'
return self
def table(self, table):
# 设置表名
self.__DB_TABLE = table
return self
def where(self, where, param):
# WHERE条件
if where:
self.__OPT_WHERE = " WHERE " + where
self.__OPT_PARAM = param
return self
def order(self, order):
# ORDER条件
if len(order):
self.__OPT_ORDER = " ORDER BY " + order
return self
def limit(self, limit):
# LIMIT条件
if len(limit):
self.__OPT_LIMIT = " LIMIT " + limit
return self
def field(self, field):
# FIELD条件
if len(field):
self.__OPT_FIELD = field
return self
def select(self):
# 查询数据集
self.__GetConn()
try:
sql = "SELECT " + self.__OPT_FIELD + " FROM " + self.__DB_TABLE + \
self.__OPT_WHERE + self.__OPT_ORDER + self.__OPT_LIMIT
result = self.__DB_CONN.execute(sql, self.__OPT_PARAM)
data = result.fetchall()
# 构造字曲系列
if self.__OPT_FIELD != "*":
field = self.__OPT_FIELD.split(',')
tmp = []
for row in data:
i = 0
tmp1 = {}
for key in field:
tmp1[key] = row[i]
i += 1
tmp.append(tmp1)
del(tmp1)
data = tmp
del(tmp)
else:
# 将元组转换成列表
tmp = map(list, data)
data = tmp
del(tmp)
self.__close()
return data
except Exception, ex:
return "error: " + str(ex)
def getField(self, keyName):
# 取回指定字段
result = self.field(keyName).select()
if len(result) == 1:
return result[0][keyName]
return result
def setField(self, keyName, keyValue):
# 更新指定字段
return self.save(keyName, (keyValue,))
def find(self):
# 取一行数据
result = self.limit("1").select()
if len(result) == 1:
return result[0]
return result
def count(self):
# 取行数
key = "COUNT(*)"
data = self.field(key).select()
try:
return int(data[0][key])
except:
return 0
def add(self, keys, param):
# 插入数据
self.__GetConn()
self.__DB_CONN.text_factory = str
try:
values = ""
for key in keys.split(','):
values += "?,"
values = self.checkInput(values[0:len(values) - 1])
sql = "INSERT INTO " + self.__DB_TABLE + \
"(" + keys + ") " + "VALUES(" + values + ")"
result = self.__DB_CONN.execute(sql, param)
id = result.lastrowid
self.__close()
self.__DB_CONN.commit()
return id
except Exception, ex:
return "error: " + str(ex)
def checkInput(self, data):
if not data:
return data
if type(data) != str:
return data
checkList = [
{'d': '<', 'r': '<'},
{'d': '>', 'r': '>'},
{'d': '\'', 'r': '‘'},
{'d': '"', 'r': '“'},
{'d': '&', 'r': '&'},
{'d': '#', 'r': '#'},
{'d': '<', 'r': '<'}
]
for v in checkList:
data = data.replace(v['d'], v['r'])
return data
def addAll(self, keys, param):
# 插入数据
self.__GetConn()
self.__DB_CONN.text_factory = str
try:
values = ""
for key in keys.split(','):
values += "?,"
values = values[0:len(values) - 1]
sql = "INSERT INTO " + self.__DB_TABLE + \
"(" + keys + ") " + "VALUES(" + values + ")"
result = self.__DB_CONN.execute(sql, param)
return True
except Exception, ex:
return "error: " + str(ex)
def commit(self):
self.__close()
self.__DB_CONN.commit()
def save(self, keys, param):
# 更新数据
self.__GetConn()
self.__DB_CONN.text_factory = str
try:
opt = ""
for key in keys.split(','):
opt += key + "=?,"
opt = opt[0:len(opt) - 1]
sql = "UPDATE " + self.__DB_TABLE + " SET " + opt + self.__OPT_WHERE
import public
public.writeFile('/tmp/test.pl', sql)
# 处理拼接WHERE与UPDATE参数
tmp = list(param)
for arg in self.__OPT_PARAM:
tmp.append(arg)
self.__OPT_PARAM = tuple(tmp)
result = self.__DB_CONN.execute(sql, self.__OPT_PARAM)
self.__close()
self.__DB_CONN.commit()
return result.rowcount
except Exception, ex:
return "error: " + str(ex)
def delete(self, id=None):
# 删除数据
self.__GetConn()
try:
if id:
self.__OPT_WHERE = " WHERE id=?"
self.__OPT_PARAM = (id,)
sql = "DELETE FROM " + self.__DB_TABLE + self.__OPT_WHERE
result = self.__DB_CONN.execute(sql, self.__OPT_PARAM)
self.__close()
self.__DB_CONN.commit()
return result.rowcount
except Exception, ex:
return "error: " + str(ex)
def execute(self, sql, param):
# 执行SQL语句返回受影响行
self.__GetConn()
try:
result = self.__DB_CONN.execute(sql, param)
self.__DB_CONN.commit()
return result.rowcount
except Exception, ex:
return "error: " + str(ex)
def query(self, sql, param):
# 执行SQL语句返回数据集
self.__GetConn()
try:
result = self.__DB_CONN.execute(sql, param)
# 将元组转换成列表
data = map(list, result)
return data
except Exception, ex:
return "error: " + str(ex)
def create(self, name):
# 创建数据表
self.__GetConn()
import public
script = public.readFile('data/' + name + '.sql')
result = self.__DB_CONN.executescript(script)
self.__DB_CONN.commit()
return result.rowcount
def fofile(self, filename):
# 执行脚本
self.__GetConn()
import public
script = public.readFile(filename)
result = self.__DB_CONN.executescript(script)
self.__DB_CONN.commit()
return result.rowcount
def __close(self):
# 清理条件属性
self.__OPT_WHERE = ""
self.__OPT_FIELD = "*"
self.__OPT_ORDER = ""
self.__OPT_LIMIT = ""
self.__OPT_PARAM = ()
def close(self):
# 释放资源
try:
self.__DB_CONN.close()
self.__DB_CONN = None
except:
pass
+222
View File
@@ -0,0 +1,222 @@
# coding: utf-8
import math
import string
import public
class Page():
#--------------------------
# 分页类 - JS回调版
#--------------------------
__PREV = '上一页'
__NEXT = '下一页'
__START = '首页'
__END = '尾页'
__COUNT_START = '共'
__COUNT_END = '条数据'
__FO = '从'
__LINE = '条'
__LIST_NUM = 4
SHIFT = None # 偏移量
ROW = None # 每页行数
__C_PAGE = None # 当前页
__COUNT_PAGE = None # 总页数
__COUNT_ROW = None # 总行数
__URI = None # URI
__RTURN_JS = False # 是否返回JS回调
__START_NUM = None # 起始行
__END_NUM = None # 结束行
def __init__(self):
tmp = public.getMsg('PAGE')
if tmp:
self.__PREV = tmp['PREV']
self.__NEXT = tmp['NEXT']
self.__START = tmp['START']
self.__END = tmp['END']
self.__COUNT_START = tmp['COUNT_START']
self.__COUNT_END = tmp['COUNT_END']
self.__FO = tmp['FO']
self.__LINE = tmp['LINE']
def GetPage(self, pageInfo, limit='1,2,3,4,5,6,7,8'):
# 取分页信息
# @param pageInfo 传入分页参数字典
# @param limit 返回系列
self.__RTURN_JS = pageInfo['return_js']
self.__COUNT_ROW = pageInfo['count']
self.ROW = pageInfo['row']
self.__C_PAGE = self.__GetCpage(pageInfo['p'])
self.__START_NUM = self.__StartRow()
self.__END_NUM = self.__EndRow()
self.__COUNT_PAGE = self.__GetCountPage()
self.__URI = self.__SetUri(pageInfo['uri'])
self.SHIFT = self.__START_NUM - 1
keys = limit.split(',')
pages = {}
# 起始页
pages['1'] = self.__GetStart()
# 上一页
pages['2'] = self.__GetPrev()
# 分页
pages['3'] = self.__GetPages()
# 下一页
pages['4'] = self.__GetNext()
# 尾页
pages['5'] = self.__GetEnd()
# 当前显示页与总页数
pages['6'] = "<span class='Pnumber'>" + \
bytes(self.__C_PAGE) + "/" + bytes(self.__COUNT_PAGE) + "</span>"
# 本页显示开始与结束行
pages['7'] = "<span class='Pline'>" + self.__FO + \
bytes(self.__START_NUM) + "-" + \
bytes(self.__END_NUM) + self.__LINE + "</span>"
# 行数
pages['8'] = "<span class='Pcount'>" + self.__COUNT_START + \
bytes(self.__COUNT_ROW) + self.__COUNT_END + "</span>"
# 构造返回数据
retuls = '<div>'
for value in keys:
retuls += pages[value]
retuls += '</div>'
# 返回分页数据
return retuls
def __GetEnd(self):
# 构造尾页
endStr = ""
if self.__C_PAGE >= self.__COUNT_PAGE:
endStr = ''
else:
if self.__RTURN_JS == "":
endStr = "<a class='Pend' href='" + self.__URI + "p=" + \
bytes(self.__COUNT_PAGE) + "'>" + self.__END + "</a>"
else:
endStr = "<a class='Pend' onclick='" + self.__RTURN_JS + \
"(" + bytes(self.__COUNT_PAGE) + ")'>" + self.__END + "</a>"
return endStr
def __GetNext(self):
# 构造下一页
nextStr = ""
if self.__C_PAGE >= self.__COUNT_PAGE:
nextStr = ''
else:
if self.__RTURN_JS == "":
nextStr = "<a class='Pnext' href='" + self.__URI + "p=" + \
bytes(self.__C_PAGE + 1) + "'>" + self.__NEXT + "</a>"
else:
nextStr = "<a class='Pnext' onclick='" + self.__RTURN_JS + \
"(" + bytes(self.__C_PAGE + 1) + ")'>" + self.__NEXT + "</a>"
return nextStr
def __GetPages(self):
# 构造分页
pages = ''
num = 0
# 当前页之前
if (self.__COUNT_PAGE - self.__C_PAGE) < self.__LIST_NUM:
num = self.__LIST_NUM + \
(self.__LIST_NUM - (self.__COUNT_PAGE - self.__C_PAGE))
else:
num = self.__LIST_NUM
n = 0
for i in range(num):
n = num - i
page = self.__C_PAGE - n
if page > 0:
if self.__RTURN_JS == "":
pages += "<a class='Pnum' href='" + self.__URI + \
"p=" + bytes(page) + "'>" + bytes(page) + "</a>"
else:
pages += "<a class='Pnum' onclick='" + self.__RTURN_JS + \
"(" + bytes(page) + ")'>" + bytes(page) + "</a>"
# 当前页
if self.__C_PAGE > 0:
pages += "<span class='Pcurrent'>" + \
bytes(self.__C_PAGE) + "</span>"
# 当前页之后
if self.__C_PAGE <= self.__LIST_NUM:
num = self.__LIST_NUM + (self.__LIST_NUM - self.__C_PAGE) + 1
else:
num = self.__LIST_NUM
for i in range(num):
if i == 0:
continue
page = self.__C_PAGE + i
if page > self.__COUNT_PAGE:
break
if self.__RTURN_JS == "":
pages += "<a class='Pnum' href='" + self.__URI + \
"p=" + bytes(page) + "'>" + bytes(page) + "</a>"
else:
pages += "<a class='Pnum' onclick='" + self.__RTURN_JS + \
"(" + bytes(page) + ")'>" + bytes(page) + "</a>"
return pages
def __GetPrev(self):
# 构造上一页
startStr = ''
if self.__C_PAGE == 1:
startStr = ''
else:
if self.__RTURN_JS == "":
startStr = "<a class='Ppren' href='" + self.__URI + "p=" + \
bytes(self.__C_PAGE - 1) + "'>" + self.__PREV + "</a>"
else:
startStr = "<a class='Ppren' onclick='" + self.__RTURN_JS + \
"(" + bytes(self.__C_PAGE - 1) + ")'>" + self.__PREV + "</a>"
return startStr
def __GetStart(self):
# 构造起始分页
startStr = ''
if self.__C_PAGE == 1:
startStr = ''
else:
if self.__RTURN_JS == "":
startStr = "<a class='Pstart' href='" + \
self.__URI + "p=1'>" + self.__START + "</a>"
else:
startStr = "<a class='Pstart' onclick='" + \
self.__RTURN_JS + "(1)'>" + self.__START + "</a>"
return startStr
def __GetCpage(self, p):
# 取当前页
if p:
return p
return 1
def __StartRow(self):
# 从多少行开始
return (self.__C_PAGE - 1) * self.ROW + 1
def __EndRow(self):
# 从多少行结束
if self.ROW > self.__COUNT_ROW:
return self.__COUNT_ROW
return self.__C_PAGE * self.ROW
def __GetCountPage(self):
# 取总页数
return int(math.ceil(self.__COUNT_ROW / float(self.ROW)))
def __SetUri(self, input):
# 构造URI
uri = '?'
for key in input:
if key == 'p':
continue
uri += key + '=' + input[key] + '&'
return str(uri)
+291
View File
@@ -0,0 +1,291 @@
# coding: utf-8
import psutil
import time
import os
import public
import re
import json
class plugin_api:
__tasks = None
__plugin_dir = 'plugins'
__type = 'data/json/type.json'
__index = 'data/json/index.json'
setupPath = None
def __init__(self):
self.setupPath = 'server'
# self.__plugin_dir = public.getRunDir() + '/plugins'
# 进程是否存在
def processExists(self, pname, exe=None):
try:
if not self.pids:
self.pids = psutil.pids()
for pid in self.pids:
try:
p = psutil.Process(pid)
if p.name() == pname:
if not exe:
return True
else:
if p.exe() == exe:
return True
except:
pass
return False
except:
return True
# 检查是否正在安装
def checkSetupTask(self, sName):
if not self.__tasks:
self.__tasks = public.M('tasks').where(
"status!=?", ('1',)).field('status,name').select()
if sName.find('php-') != -1:
tmp = sName.split('-')
sName = tmp[0]
version = tmp[1]
isTask = '1'
for task in self.__tasks:
tmpt = public.getStrBetween('[', ']', task['name'])
if not tmpt:
continue
tmp1 = tmpt.split('-')
name1 = tmp1[0].lower()
if sName == 'php':
if name1 == sName and tmp1[1] == version:
isTask = task['status']
else:
if name1 == 'pure':
name1 = 'pure-ftpd'
if name1 == sName:
isTask = task['status']
return isTask
def checkStatus(self, info):
pass
def checkDisplayIndex(self, name, version):
if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index))
if type(version) == list:
for index in range(len(version)):
vname = name + '-' + version[index]
if vname in indexList:
return True
else:
vname = name + '-' + version
if vname in indexList:
return True
return False
def getVersion(self, path):
version_f = path + '/version.pl'
if os.path.exists(version_f):
return public.readFile(version_f).strip()
return ''
# 构造本地插件信息
def getPluginInfo(self, info):
checks = ''
path = ''
coexist = False
if info["checks"][0:1] == '/':
checks = info["checks"]
else:
checks = public.getRootDir() + '/' + info['checks']
if info.has_key('path'):
path = info['path']
if path[0:1] != '/':
path = public.getRootDir() + '/' + path
if info.has_key('coexist') and info['coexist']:
coexist = True
pluginInfo = {
"id": 10000,
"pid": info['pid'],
"type": 1000,
"name": info['name'],
"title": info['title'],
"ps": info['ps'],
"dependnet": "",
"mutex": "",
"path": path,
"install_checks": checks,
"uninsatll_checks": checks,
"coexist": coexist,
"versions": info['versions'],
# "updates": info['updates'],
"display": False,
"setup": False,
"setup_version": "",
"status": False,
}
pluginInfo['task'] = self.checkSetupTask(pluginInfo['name'])
if checks.find('VERSION') > -1:
pluginInfo['install_checks'] = checks.replace(
'VERSION', info['versions'])
if path.find('VERSION') > -1:
pluginInfo['path'] = path.replace(
'VERSION', info['versions'])
pluginInfo['display'] = self.checkDisplayIndex(
info['name'], pluginInfo['versions'])
pluginInfo['setup'] = os.path.exists(pluginInfo['install_checks'])
if coexist and pluginInfo['setup']:
pluginInfo['setup_version'] = info['versions']
else:
pluginInfo['setup_version'] = self.getVersion(
pluginInfo['path'])
# pluginInfo['status'] = os.path.exists(pluginInfo['install_checks'])
return pluginInfo
def makeCoexist(self, data):
plugins_info = []
for index in range(len(data['versions'])):
tmp = data.copy()
tmp['title'] = tmp['title'] + \
'-' + data['versions'][index]
tmp['versions'] = data['versions'][index]
pg = self.getPluginInfo(tmp)
plugins_info.append(pg)
return plugins_info
def makeList(self, data, sType='0'):
plugins_info = []
if (data['pid'] == sType):
if type(data['versions']) == list and data.has_key('coexist') and data['coexist']:
tmp_data = self.makeCoexist(data)
for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index])
else:
pg = self.getPluginInfo(data)
plugins_info.append(pg)
return plugins_info
if sType == '0':
if type(data['versions']) == list and data.has_key('coexist') and data['coexist']:
tmp_data = self.makeCoexist(data)
for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index])
else:
pg = self.getPluginInfo(data)
plugins_info.append(pg)
# print plugins_info, data
return plugins_info
def getAllList(self, sType='0'):
ret = {}
ret['type'] = json.loads(public.readFile(self.__type))
plugins_info = []
for dirinfo in os.listdir(self.__plugin_dir):
if dirinfo[0:1] == '.':
continue
path = self.__plugin_dir + '/' + dirinfo
if os.path.isdir(path):
json_file = path + '/info.json'
if os.path.exists(json_file):
try:
data = json.loads(public.readFile(json_file))
tmp_data = self.makeList(data, sType)
for index in range(len(tmp_data)):
plugins_info.append(tmp_data[index])
except Exception, e:
print e
return plugins_info
def getPluginList(self, sType, sPage=1, sPageSize=15):
ret = {}
ret['type'] = json.loads(public.readFile(self.__type))
plugins_info = self.getAllList(sType)
args = {}
args['count'] = len(plugins_info)
args['p1'] = sPage
ret['data'] = plugins_info
ret['list'] = public.getPage(args)
return ret
def getIndexList(self):
if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index))
plist = []
app = []
for i in indexList:
info = i.split('-')
if not info[0] in app:
app.append(info[0])
path = self.__plugin_dir + '/' + info[0]
if os.path.isdir(path):
json_file = path + '/info.json'
if os.path.exists(json_file):
try:
data = json.loads(public.readFile(json_file))
tmp_data = self.makeList(data)
for index in range(len(tmp_data)):
if tmp_data[index]['versions'] == info[1] or info[1] in tmp_data[index]['versions']:
tmp_data[index]['display'] = True
plist.append(tmp_data[index])
continue
except Exception, e:
print e
return plist
def setIndexSort(self, sort):
data = sort.split('|')
public.writeFile(self.__index, json.dumps(data))
return True
def addIndex(self, name, version):
if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index))
vname = name + '-' + version
if vname in indexList:
return public.returnJson(False, '请不要重复添加!')
if len(indexList) >= 12:
return public.returnJson(False, '首页最多只能显示12个软件!')
indexList.append(vname)
public.writeFile(self.__index, json.dumps(indexList))
return public.returnJson(True, '添加成功!')
def removeIndex(self, name, version):
if not os.path.exists(self.__index):
public.writeFile(self.__index, '[]')
indexList = json.loads(public.readFile(self.__index))
vname = name + '-' + version
if not vname in indexList:
return public.returnJson(True, '删除成功!')
indexList.remove(vname)
public.writeFile(self.__index, json.dumps(indexList))
return public.returnJson(True, '删除成功!')
def run(self):
pass
+733
View File
@@ -0,0 +1,733 @@
# coding: utf-8
import os
import sys
import time
import string
import json
import hashlib
import shlex
import datetime
import subprocess
import re
import hashlib
import db
from random import Random
def execShell(cmdstring, cwd=None, timeout=None, shell=True):
if shell:
cmdstring_list = cmdstring
else:
cmdstring_list = shlex.split(cmdstring)
if timeout:
end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout)
sub = subprocess.Popen(cmdstring_list, cwd=cwd, stdin=subprocess.PIPE,
shell=shell, bufsize=4096, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while sub.poll() is None:
time.sleep(0.1)
if timeout:
if end_time <= datetime.datetime.now():
raise Exception("Timeout:%s" % cmdstring)
return sub.communicate()
def getRunDir():
return os.getcwd()
def getRootDir():
return os.path.dirname(os.path.dirname(getRunDir()))
def getOs():
os = execShell('uname')
return os[0].lower().strip()
def M(table):
sql = db.Sql()
return sql.table(table)
def getPage(args, result='1,2,3,4,5,8'):
# 取分页
import page
# 实例化分页类
page = page.Page()
info = {}
info['count'] = 0
if args.has_key('count'):
info['count'] = int(args['count'])
info['row'] = 10
if args.has_key('row'):
info['row'] = args['row']
info['p'] = 1
if args.has_key('p'):
info['p'] = int(args['p'])
info['uri'] = {}
info['return_js'] = ''
if args.has_key('tojs'):
info['return_js'] = args['tojs']
return page.GetPage(info, result)
def md5(str):
# 生成MD5
try:
m = hashlib.md5()
m.update(str)
return m.hexdigest()
except:
return False
def getFileMd5(filename):
# 文件的MD5值
if not os.path.isfile(filename):
return False
myhash = hashlib.md5()
f = file(filename, 'rb')
while True:
b = f.read(8096)
if not b:
break
myhash.update(b)
f.close()
return myhash.hexdigest()
def getRandomString(length):
# 取随机字符串
str = ''
chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'
chrlen = len(chars) - 1
random = Random()
for i in range(length):
str += chars[random.randint(0, chrlen)]
return str
def getJson(data):
import json
return json.dumps(data)
def returnJson(status, msg, args=()):
# 取通用Json返回
return getJson(returnMsg(status, msg, args))
def returnMsg(status, msg, args=()):
# 取通用字曲返回
logMessage = json.loads(
readFile('static/language/' + getLanguage() + '/public.json'))
keys = logMessage.keys()
if msg in keys:
msg = logMessage[msg]
for i in range(len(args)):
rep = '{' + str(i + 1) + '}'
msg = msg.replace(rep, args[i])
return {'status': status, 'msg': msg, 'data': args}
def getInfo(msg, args=()):
# 取提示消息
for i in range(len(args)):
rep = '{' + str(i + 1) + '}'
msg = msg.replace(rep, args[i])
return msg
def getMsg(key, args=()):
# 取提示消息
try:
logMessage = json.loads(
readFile('static/language/' + getLanguage() + '/public.json'))
keys = logMessage.keys()
msg = None
if key in keys:
msg = logMessage[key]
for i in range(len(args)):
rep = '{' + str(i + 1) + '}'
msg = msg.replace(rep, args[i])
return msg
except:
return key
def getLan(key):
# 取提示消息
logMessage = json.loads(
readFile('static/language/' + getLanguage() + '/template.json'))
keys = logMessage.keys()
msg = None
if key in keys:
msg = logMessage[key]
return msg
def readFile(filename):
# 读文件内容
try:
fp = open(filename, 'r')
fBody = fp.read()
fp.close()
return fBody
except:
return False
def getDate():
# 取格式时间
import time
return time.strftime('%Y-%m-%d %X', time.localtime())
def getLanguage():
path = 'data/language.pl'
if not os.path.exists(path):
return 'Simplified_Chinese'
return readFile(path).strip()
def writeLog(type, logMsg, args=()):
# 写日志
try:
import time
import db
import json
logMessage = json.loads(
readFile('static/language/' + getLanguage() + '/log.json'))
keys = logMessage.keys()
if logMsg in keys:
logMsg = logMessage[logMsg]
for i in range(len(args)):
rep = '{' + str(i + 1) + '}'
logMsg = logMsg.replace(rep, args[i])
if type in keys:
type = logMessage[type]
sql = db.Sql()
mDate = time.strftime('%Y-%m-%d %X', time.localtime())
data = (type, logMsg, mDate)
result = sql.table('logs').add('type,log,addtime', data)
except:
pass
def writeFile(filename, str):
# 写文件内容
try:
fp = open(filename, 'w+')
fp.write(str)
fp.close()
return True
except:
return False
def httpGet(url, timeout=30):
# 发送GET请求
try:
import urllib2
import ssl
try:
ssl._create_default_https_context = ssl._create_unverified_context
except:
pass
response = urllib2.urlopen(url, timeout=timeout)
return response.read()
except Exception, ex:
# WriteLog('网络诊断',str(ex) + '['+url+']');
return str(ex)
def httpPost(url, data, timeout=30):
# 发送POST请求
try:
import urllib
import urllib2
import ssl
try:
ssl._create_default_https_context = ssl._create_unverified_context
except:
pass
data = urllib.urlencode(data)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req, timeout=timeout)
return response.read()
except Exception, ex:
# WriteLog('网络诊断',str(ex) + '['+url+']');
return str(ex)
def writeSpeed(title, used, total, speed=0):
# 写进度
if not title:
data = {'title': None, 'progress': 0,
'total': 0, 'used': 0, 'speed': 0}
else:
progress = int((100.0 * used / total))
data = {'title': title, 'progress': progress,
'total': total, 'used': used, 'speed': speed}
writeFile('/tmp/panelSpeed.pl', json.dumps(data))
return True
def getSpeed():
# 取进度
data = readFile('/tmp/panelSpeed.pl')
if not data:
data = json.dumps({'title': None, 'progress': 0,
'total': 0, 'used': 0, 'speed': 0})
writeFile('/tmp/panelSpeed.pl', data)
return json.loads(data)
def getLastLine(inputfile, lineNum):
# 读文件指定倒数行数
try:
fp = open(inputfile, 'r')
lastLine = ""
lines = fp.readlines()
count = len(lines)
if count > lineNum:
num = lineNum
else:
num = count
i = 1
lastre = []
for i in range(1, (num + 1)):
if lines:
n = -i
lastLine = lines[n].strip()
fp.close()
lastre.append(lastLine)
result = ''
num -= 1
while num >= 0:
result += lastre[num] + "\n"
num -= 1
return result
except:
return getMsg('TASK_SLEEP')
def serviceReload():
# 重载Web服务配置
if os.path.exists('/www/server/nginx/sbin/nginx'):
result = execShell('/etc/init.d/nginx reload')
if result[1].find('nginx.pid') != -1:
execShell('pkill -9 nginx && sleep 1')
execShell('/etc/init.d/nginx start')
else:
result = execShell('/etc/init.d/httpd reload')
return result
def phpReload(version):
# 重载PHP配置
import os
if os.path.exists('/www/server/php/' + version + '/libphp5.so'):
execShell('/etc/init.d/httpd reload')
else:
execShell('/etc/init.d/php-fpm-' + version + ' reload')
def downloadFile(url, filename):
import urllib
urllib.urlretrieve(url, filename=filename, reporthook=downloadHook)
def downloadHook(count, blockSize, totalSize):
speed = {'total': totalSize, 'block': blockSize, 'count': count}
print speed
print '%02d%%' % (100.0 * count * blockSize / totalSize)
def GetLocalIp():
# 取本地外网IP
try:
import re
filename = 'data/iplist.txt'
ipaddress = readFile(filename)
if not ipaddress:
import urllib2
url = 'http://pv.sohu.com/cityjson?ie=utf-8'
opener = urllib2.urlopen(url)
str = opener.read()
ipaddress = re.search('\d+.\d+.\d+.\d+', str).group(0)
writeFile(filename, ipaddress)
ipaddress = re.search('\d+.\d+.\d+.\d+', ipaddress).group(0)
return ipaddress
except:
pass
# try:
# url = web.ctx.session.home + '/Api/getIpAddress'
# opener = urllib2.urlopen(url)
# return opener.read()
# except:
# return web.ctx.host.split(':')[0]
def inArray(arrays, searchStr):
# 搜索数据中是否存在
for key in arrays:
if key == searchStr:
return True
return False
def checkWebConfig():
# 检查Web服务器配置文件是否有错误
if get_webserver() == 'nginx':
result = ExecShell(
"ulimit -n 10240 && /www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf")
searchStr = 'successful'
else:
result = ExecShell(
"ulimit -n 10240 && /www/server/apache/bin/apachectl -t")
searchStr = 'Syntax OK'
if result[1].find(searchStr) == -1:
WriteLog("TYPE_SOFT", 'CONF_CHECK_ERR', (result[1],))
return result[1]
return True
def checkIp(ip):
# 检查是否为IPv4地址
import re
p = re.compile(
'^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$')
if p.match(ip):
return True
else:
return False
def checkPort(port):
# 检查端口是否合法
ports = ['21', '25', '443', '8080', '888', '8888', '8443']
if port in ports:
return False
intport = int(port)
if intport < 1 or intport > 65535:
return False
return True
def getStrBetween(startStr, endStr, srcStr):
# 字符串取中间
start = srcStr.find(startStr)
if start == -1:
return None
end = srcStr.find(endStr)
if end == -1:
return None
return srcStr[start + 1:end]
def getCpuType():
# 取CPU类型
cpuinfo = open('/proc/cpuinfo', 'r').read()
rep = "model\s+name\s+:\s+(.+)"
tmp = re.search(rep, cpuinfo)
cpuType = None
if tmp:
cpuType = tmp.groups()[0]
return cpuType
def isRestart():
# 检查是否允许重启
num = M('tasks').where('status!=?', ('1',)).count()
if num > 0:
return False
return True
def hasPwd(password):
# 加密密码字符
import crypt
return crypt.crypt(password, password)
def get_url(timeout=0.5):
import json
try:
nodeFile = '/www/server/panel/data/node.json'
node_list = json.loads(readFile(nodeFile))
mnode = None
for node in node_list:
node['ping'] = get_timeout(
node['protocol'] + node['address'] + ':' + node['port'] + '/check.txt')
if not node['ping']:
continue
if not mnode:
mnode = node
if node['ping'] < mnode['ping']:
mnode = node
return mnode['protocol'] + mnode['address'] + ':' + mnode['port']
except:
return 'http://download.bt.cn'
def get_timeout(url):
start = time.time()
result = httpGet(url)
if result != 'True':
return False
return int((time.time() - start) * 1000)
def auth_decode(data):
# 解密数据
token = GetToken()
# 是否有生成Token
if not token:
return returnMsg(False, 'REQUEST_ERR')
# 校验access_key是否正确
if token['access_key'] != data['btauth_key']:
return returnMsg(False, 'REQUEST_ERR')
# 解码数据
import binascii
import hashlib
import urllib
import hmac
import json
tdata = binascii.unhexlify(data['data'])
# 校验signature是否正确
signature = binascii.hexlify(
hmac.new(token['secret_key'], tdata, digestmod=hashlib.sha256).digest())
if signature != data['signature']:
return returnMsg(False, 'REQUEST_ERR')
# 返回
return json.loads(urllib.unquote(tdata))
# 数据加密
def auth_encode(data):
token = GetToken()
pdata = {}
# 是否有生成Token
if not token:
return returnMsg(False, 'REQUEST_ERR')
# 生成signature
import binascii
import hashlib
import urllib
import hmac
import json
tdata = urllib.quote(json.dumps(data))
# 公式 hex(hmac_sha256(data))
pdata['signature'] = binascii.hexlify(
hmac.new(token['secret_key'], tdata, digestmod=hashlib.sha256).digest())
# 加密数据
pdata['btauth_key'] = token['access_key']
pdata['data'] = binascii.hexlify(tdata)
pdata['timestamp'] = time.time()
# 返回
return pdata
def checkToken(get):
# 检查Token
tempFile = 'data/tempToken.json'
if not os.path.exists(tempFile):
return False
import json
import time
tempToken = json.loads(readFile(tempFile))
if time.time() > tempToken['timeout']:
return False
if get.token != tempToken['token']:
return False
return True
def get_webserver():
# 获取Web服务器
webserver = 'nginx'
if not os.path.exists('/www/server/nginx/sbin/nginx'):
webserver = 'apache'
return webserver
def checkInput(data):
# 过滤输入
if not data:
return data
if type(data) != str:
return data
checkList = [
{'d': '<', 'r': '<'},
{'d': '>', 'r': '>'},
{'d': '\'', 'r': '‘'},
{'d': '"', 'r': '“'},
{'d': '&', 'r': '&'},
{'d': '#', 'r': '#'},
{'d': '<', 'r': '<'}
]
for v in checkList:
data = data.replace(v['d'], v['r'])
return data
def getNumLines(path, num, p=1):
# 取文件指定尾行数
try:
import cgi
if not os.path.exists(path):
return ""
start_line = (p - 1) * num
count = start_line + num
fp = open(path)
buf = ""
fp.seek(-1, 2)
if fp.read(1) == "\n":
fp.seek(-1, 2)
data = []
b = True
n = 0
for i in range(count):
while True:
newline_pos = string.rfind(buf, "\n")
pos = fp.tell()
if newline_pos != -1:
if n >= start_line:
line = buf[newline_pos + 1:]
try:
data.insert(0, cgi.escape(line))
except:
pass
buf = buf[:newline_pos]
n += 1
break
else:
if pos == 0:
b = False
break
to_read = min(4096, pos)
fp.seek(-to_read, 1)
buf = fp.read(to_read) + buf
fp.seek(-to_read, 1)
if pos - to_read == 0:
buf = "\n" + buf
if not b:
break
fp.close()
except:
data = []
return "\n".join(data)
def checkCert(certPath='ssl/certificate.pem'):
# 验证证书
openssl = '/usr/local/openssl/bin/openssl'
if not os.path.exists(openssl):
openssl = 'openssl'
certPem = readFile(certPath)
s = "\n-----BEGIN CERTIFICATE-----"
tmp = certPem.strip().split(s)
for tmp1 in tmp:
if tmp1.find('-----BEGIN CERTIFICATE-----') == -1:
tmp1 = s + tmp1
writeFile(certPath, tmp1)
result = execShell(openssl + " x509 -in " +
certPath + " -noout -subject")
if result[1].find('-bash:') != -1:
return True
if len(result[1]) > 2:
return False
if result[0].find('error:') != -1:
return False
return True
# 获取面板地址
# def getPanelAddr():
# import web
# protocol = 'https://' if os.path.exists("data/ssl.pl") else 'http://'
# h = web.ctx.host.split(':')
# try:
# result = protocol + h[0] + ':' + h[1]
# except:
# result = protocol + h[0] + ':' + readFile('data/port.pl').strip()
# return result
def to_size(size):
# 字节单位转换
d = ('b', 'KB', 'MB', 'GB', 'TB')
s = d[0]
for b in d:
if size < 1024:
return str(size) + ' ' + b
size = size / 1024
s = b
return str(size) + ' ' + b
def get_string(t):
if t != -1:
max = 126
m_types = [{'m': 122, 'n': 97}, {'m': 90, 'n': 65}, {'m': 57, 'n': 48}, {
'm': 47, 'n': 32}, {'m': 64, 'n': 58}, {'m': 96, 'n': 91}, {'m': 125, 'n': 123}]
else:
max = 256
t = 0
m_types = [{'m': 255, 'n': 0}]
arr = []
for i in range(max):
if i < m_types[t]['n'] or i > m_types[t]['m']:
continue
arr.append(chr(i))
return arr
def get_string_find(t):
if type(t) != list:
t = [t]
return_str = ''
for s1 in t:
return_str += get_string(int(s1[0]))[int(s1[1:])]
return return_str
def get_string_arr(t):
s_arr = {}
t_arr = []
for s1 in t:
for i in range(6):
if not i in s_arr:
s_arr[i] = get_string(i)
for j in range(len(s_arr[i])):
if s1 == s_arr[i][j]:
t_arr.append(str(i) + str(j))
return t_arr
+552
View File
@@ -0,0 +1,552 @@
# coding: utf-8
import psutil
import time
import os
import re
import math
import json
from flask import Flask, session
import db
import public
class system_api:
setupPath = None
pids = None
def __init__(self):
self.setupPath = '/www/server'
# 名取PID
def getPid(self, pname):
try:
if not self.pids:
self.pids = psutil.pids()
for pid in self.pids:
if psutil.Process(pid).name() == pname:
return True
return False
except:
return False
# 检查端口是否占用
def isOpen(self, port):
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect(('127.0.0.1', int(port)))
s.shutdown(2)
return True
except:
return False
# 检测指定进程是否存活
def checkProcess(self, pid):
try:
if not self.pids:
self.pids = psutil.pids()
if int(pid) in self.pids:
return True
return False
except:
return False
def getPanelInfo(self, get=None):
# 取面板配置
address = public.GetLocalIp()
try:
try:
port = web.ctx.host.split(':')[1]
except:
port = public.readFile('data/port.pl')
except:
port = '8888'
domain = ''
if os.path.exists('data/domain.conf'):
domain = public.readFile('data/domain.conf')
autoUpdate = ''
if os.path.exists('data/autoUpdate.pl'):
autoUpdate = 'checked'
limitip = ''
if os.path.exists('data/limitip.conf'):
limitip = public.readFile('data/limitip.conf')
templates = []
for template in os.listdir('templates/'):
if os.path.isdir('templates/' + template):
templates.append(template)
template = public.readFile('data/templates.pl')
check502 = ''
if os.path.exists('data/502Task.pl'):
check502 = 'checked'
return {'port': port, 'address': address, 'domain': domain, 'auto': autoUpdate, '502': check502, 'limitip': limitip, 'templates': templates, 'template': template}
def getSystemTotal(self, interval=1):
# 取系统统计信息
data = self.getMemInfo()
cpu = self.getCpuInfo(interval)
data['cpuNum'] = cpu[1]
data['cpuRealUsed'] = cpu[0]
data['time'] = self.getBootTime()
data['system'] = self.getSystemVersion()
data['isuser'] = public.M('users').where(
'username=?', ('admin',)).count()
data['version'] = '0.0.1'
return data
def getLoadAverage(self, get=None):
c = os.getloadavg()
data = {}
data['one'] = float(c[0])
data['five'] = float(c[1])
data['fifteen'] = float(c[2])
data['max'] = psutil.cpu_count() * 2
data['limit'] = data['max']
data['safe'] = data['max'] * 0.75
return data
def getAllInfo(self, get):
data = {}
data['load_average'] = self.GetLoadAverage(get)
data['title'] = self.GetTitle()
data['network'] = self.GetNetWorkApi(get)
data['panel_status'] = not os.path.exists(
'/www/server/panel/data/close.pl')
import firewalls
ssh_info = firewalls.firewalls().GetSshInfo(None)
data['enable_ssh_status'] = ssh_info['status']
data['disable_ping_status'] = not ssh_info['ping']
data['time'] = self.GetBootTime()
# data['system'] = self.GetSystemVersion();
# data['mem'] = self.GetMemInfo();
data['version'] = web.ctx.session.version
return data
def getTitle(self):
titlePl = 'data/title.pl'
title = '宝塔Linux面板'
if os.path.exists(titlePl):
title = public.readFile(titlePl).strip()
return title
def getSystemVersion(self):
# 取操作系统版本
os = public.getOs()
if os == 'darwin':
data = public.execShell('sw_vers')[0]
data_list = data.strip().split("\n")
mac_version = ''
for x in data_list:
mac_version += x.split("\t")[1] + ' '
return mac_version
version = public.readFile('/etc/redhat-release')
if not version:
version = public.readFile(
'/etc/issue').strip().split("\n")[0].replace('\\n', '').replace('\l', '').strip()
else:
version = version.replace('release ', '').strip()
return version
def getBootTime(self):
# 取系统启动时间
start_time = psutil.boot_time()
run_time = time.time() - start_time
# conf = public.readFile('/proc/uptime').split()
tStr = float(run_time)
min = tStr / 60
hours = min / 60
days = math.floor(hours / 24)
hours = math.floor(hours - (days * 24))
min = math.floor(min - (days * 60 * 24) - (hours * 60))
return public.getInfo('已不间断运行: {1}天{2}小时{3}分钟', (str(int(days)), str(int(hours)), str(int(min))))
def getCpuInfo(self, interval=1):
# 取CPU信息
cpuCount = psutil.cpu_count()
used = psutil.cpu_percent(interval=interval)
return used, cpuCount
def getMemInfo(self, get=None):
# 取内存信息
mem = psutil.virtual_memory()
if public.getOs() == 'darwin':
memInfo = {
'memTotal': mem.total / 1024 / 1024
}
memInfo['memRealUsed'] = memInfo['memTotal'] * (mem.percent / 100)
else:
memInfo = {
'memTotal': mem.total / 1024 / 1024,
'memFree': mem.free / 1024 / 1024,
'memBuffers': mem.buffers / 1024 / 1024,
'memCached': mem.cached / 1024 / 1024
}
memInfo['memRealUsed'] = memInfo['memTotal'] - \
memInfo['memFree'] - memInfo['memBuffers'] - \
memInfo['memCached']
return memInfo
def getMemUsed(self):
# 取内存使用率
try:
import psutil
mem = psutil.virtual_memory()
if public.getOs() == 'darwin':
return mem.percent
memInfo = {'memTotal': mem.total / 1024 / 1024, 'memFree': mem.free / 1024 / 1024,
'memBuffers': mem.buffers / 1024 / 1024, 'memCached': mem.cached / 1024 / 1024}
tmp = memInfo['memTotal'] - memInfo['memFree'] - \
memInfo['memBuffers'] - memInfo['memCached']
tmp1 = memInfo['memTotal'] / 100
return (tmp / tmp1)
except Exception, ex:
return 1
def getDiskInfo(self, get=None):
return self.getDiskInfo2()
# 取磁盘分区信息
diskIo = psutil.disk_partitions()
diskInfo = []
for disk in diskIo:
if disk[1] == '/mnt/cdrom':
continue
if disk[1] == '/boot':
continue
tmp = {}
tmp['path'] = disk[1]
tmp['size'] = psutil.disk_usage(disk[1])
diskInfo.append(tmp)
return diskInfo
def getDiskInfo2(self):
# 取磁盘分区信息
temp = public.execShell(
"df -h -P|grep '/'|grep -v tmpfs | grep -v devfs")[0]
tempInodes = public.execShell(
"df -i -P|grep '/'|grep -v tmpfs | grep -v devfs")[0]
temp1 = temp.split('\n')
tempInodes1 = tempInodes.split('\n')
diskInfo = []
n = 0
cuts = ['/mnt/cdrom', '/boot', '/boot/efi', '/dev',
'/dev/shm', '/run/lock', '/run', '/run/shm', '/run/user']
for tmp in temp1:
n += 1
inodes = tempInodes1[n - 1].split()
disk = tmp.split()
if len(disk) < 5:
continue
if disk[1].find('M') != -1:
continue
if disk[1].find('K') != -1:
continue
if len(disk[5].split('/')) > 4:
continue
if disk[5] in cuts:
continue
arr = {}
arr['path'] = disk[5]
tmp1 = [disk[1], disk[2], disk[3], disk[4]]
arr['size'] = tmp1
arr['inodes'] = [inodes[1], inodes[2], inodes[3], inodes[4]]
if disk[5] == '/':
bootLog = os.getcwd() + '/tmp/panelBoot.pl'
if disk[2].find('M') != -1:
if os.path.exists(bootLog):
os.system('rm -f ' + bootLog)
else:
if not os.path.exists(bootLog):
pass
if inodes[2] != '0':
diskInfo.append(arr)
return diskInfo
# 清理系统垃圾
def clearSystem(self, get):
count = total = 0
tmp_total, tmp_count = self.ClearMail()
count += tmp_count
total += tmp_total
tmp_total, tmp_count = self.ClearOther()
count += tmp_count
total += tmp_total
return count, total
# 清理邮件日志
def clearMail(self):
rpath = '/var/spool'
total = count = 0
import shutil
con = ['cron', 'anacron', 'mail']
for d in os.listdir(rpath):
if d in con:
continue
dpath = rpath + '/' + d
time.sleep(0.2)
num = size = 0
for n in os.listdir(dpath):
filename = dpath + '/' + n
fsize = os.path.getsize(filename)
size += fsize
if os.path.isdir(filename):
shutil.rmtree(filename)
else:
os.remove(filename)
print '\t\033[1;32m[OK]\033[0m'
num += 1
total += size
count += num
return total, count
# 清理其它
def clearOther(self):
clearPath = [
{'path': '/www/server/panel', 'find': 'testDisk_'},
{'path': '/www/wwwlogs', 'find': 'log'},
{'path': '/tmp', 'find': 'panelBoot.pl'},
{'path': '/www/server/panel/install', 'find': '.rpm'}
]
total = count = 0
for c in clearPath:
for d in os.listdir(c['path']):
if d.find(c['find']) == -1:
continue
filename = c['path'] + '/' + d
fsize = os.path.getsize(filename)
total += fsize
if os.path.isdir(filename):
shutil.rmtree(filename)
else:
os.remove(filename)
count += 1
public.serviceReload()
os.system('echo > /tmp/panelBoot.pl')
return total, count
def getNetWork(self, get=None):
# return self.GetNetWorkApi(get);
# 取网络流量信息
try:
# 取网络流量信息
networkIo = psutil.net_io_counters()[:4]
if not "otime" in session:
session['up'] = networkIo[0]
session['down'] = networkIo[1]
session['otime'] = time.time()
ntime = time.time()
networkInfo = {}
networkInfo['upTotal'] = networkIo[0]
networkInfo['downTotal'] = networkIo[1]
networkInfo['up'] = round(float(
networkIo[0] - session['up']) / 1024 / (ntime - session['otime']), 2)
networkInfo['down'] = round(
float(networkIo[1] - session['down']) / 1024 / (ntime - session['otime']), 2)
networkInfo['downPackets'] = networkIo[3]
networkInfo['upPackets'] = networkIo[2]
# print networkIo[1], session['down'], ntime, session['otime']
session['up'] = networkIo[0]
session['down'] = networkIo[1]
session['otime'] = time.time()
networkInfo['cpu'] = self.getCpuInfo()
networkInfo['load'] = self.getLoadAverage(get)
networkInfo['mem'] = self.getMemInfo(get)
return networkInfo
except Exception, e:
print e
return None
def getNetWorkApi(self, get=None):
# 取网络流量信息
try:
tmpfile = 'data/network.temp'
networkIo = psutil.net_io_counters()[:4]
if not os.path.exists(tmpfile):
public.writeFile(tmpfile, str(
networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time())))
lastValue = public.readFile(tmpfile).split('|')
ntime = time.time()
networkInfo = {}
networkInfo['upTotal'] = networkIo[0]
networkInfo['downTotal'] = networkIo[1]
networkInfo['up'] = round(
float(networkIo[0] - int(lastValue[0])) / 1024 / (ntime - int(lastValue[2])), 2)
networkInfo['down'] = round(
float(networkIo[1] - int(lastValue[1])) / 1024 / (ntime - int(lastValue[2])), 2)
networkInfo['downPackets'] = networkIo[3]
networkInfo['upPackets'] = networkIo[2]
public.writeFile(tmpfile, str(
networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time())))
# networkInfo['cpu'] = self.GetCpuInfo(0.1)
return networkInfo
except:
return None
def restartServer(self, get):
if not public.IsRestart():
return public.returnMsg(False, 'EXEC_ERR_TASK')
public.ExecShell("sync && /etc/init.d/bt stop && init 6 &")
return public.returnMsg(True, 'SYS_REBOOT')
# 释放内存
def reMemory(self, get):
os.system('sync')
scriptFile = 'script/rememory.sh'
if not os.path.exists(scriptFile):
public.downloadFile(web.ctx.session.home +
'/script/rememory.sh', scriptFile)
public.ExecShell("/bin/bash " + self.setupPath +
'/panel/' + scriptFile)
return self.GetMemInfo()
def getNetWorkIoData(self, start, end):
# 取指定时间段的网络Io
data = public.M('network').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field(
'id,up,down,total_up,total_down,down_packets,up_packets,addtime').order('id asc').select()
return self.toAddtime(data)
def getDiskIoData(self, start, end):
# 取指定时间段的磁盘Io
data = public.M('diskio').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field(
'id,read_count,write_count,read_bytes,write_bytes,read_time,write_time,addtime').order('id asc').select()
return self.toAddtime(data)
def getCpuIoData(self, start, end):
# 取指定时间段的CpuIo
data = public.M('cpuio').dbfile('system').where("addtime>=? AND addtime<=?",
(start, end)).field('id,pro,mem,addtime').order('id asc').select()
return self.toAddtime(data, True)
def getLoadAverageData(self, start, end):
data = public.M('load_average').dbfile('system').where("addtime>=? AND addtime<=?", (
start, end)).field('id,pro,one,five,fifteen,addtime').order('id asc').select()
return self.toAddtime(data)
# 格式化addtime列
def toAddtime(self, data, tomem=False):
import time
if tomem:
import psutil
mPre = (psutil.virtual_memory().total / 1024 / 1024) / 100
length = len(data)
he = 1
if length > 100:
he = 1
if length > 1000:
he = 3
if length > 10000:
he = 15
if he == 1:
for i in range(length):
data[i]['addtime'] = time.strftime(
'%m/%d %H:%M', time.localtime(float(data[i]['addtime'])))
if tomem and data[i]['mem'] > 100:
data[i]['mem'] = data[i]['mem'] / mPre
return data
else:
count = 0
tmp = []
for value in data:
if count < he:
count += 1
continue
value['addtime'] = time.strftime(
'%m/%d %H:%M', time.localtime(float(value['addtime'])))
if tomem and value['mem'] > 100:
value['mem'] = value['mem'] / mPre
tmp.append(value)
count = 0
return tmp
def setControl(self, stype, day):
filename = 'data/control.conf'
if stype == '0':
public.execShell("rm -f " + filename)
elif stype == '1':
_day = int(day)
if _day < 1:
return public.returnJson(False, "设置失败!")
public.writeFile(filename, day)
elif stype == 'del':
if not public.isRestart():
return public.returnJson(False, '请等待所有安装任务完成再执行')
os.remove("data/system.db")
sql = db.Sql().dbfile('system')
csql = public.readFile('data/sql/system.sql')
csql_list = csql.split(';')
for index in range(len(csql_list)):
sql.execute(csql_list[index], ())
return public.returnJson(True, "监控服务已关闭")
else:
data = {}
if os.path.exists(filename):
try:
data['day'] = int(public.readFile(filename))
except:
data['day'] = 30
data['status'] = True
else:
data['day'] = 30
data['status'] = False
return public.getJson(data)
return public.returnJson(True, "设置成功!")
# 更新服务
def updateServer(self, stype):
try:
if not public.isRestart():
return public.returnMsg(False, '请等待所有安装任务完成再执行!')
if stype == 'check':
public.httpGet('')
except Exception as ex:
return public.returnJson(False, "连接服务器失败!")
# 重启面板
def reWeb(self, get):
# if not public.IsRestart(): return
# public.returnMsg(False,'EXEC_ERR_TASK');
# public.ExecShell('/etc/init.d/bt restart &')
return True
# 修复面板
def repPanel(self, get):
vp = ''
if public.readFile('/www/server/panel/class/common.py').find('checkSafe') != -1:
vp = '_pro'
public.ExecShell("wget -O update.sh " + public.get_url() +
"/install/update" + vp + ".sh && bash update.sh")
if hasattr(web.ctx.session, 'getCloudPlugin'):
del(web.ctx.session['getCloudPlugin'])
return True
# 升级到专业版
def updatePro(self, get):
public.ExecShell("wget -O update.sh " + public.get_url() +
"/install/update_pro.sh && bash update.sh pro")
if hasattr(web.ctx.session, 'getCloudPlugin'):
del(web.ctx.session['getCloudPlugin'])
return True
+132
View File
@@ -0,0 +1,132 @@
#!/usr/bin/env python
# coding: utf-8
import random
import math
from PIL import Image, ImageDraw, ImageFont, ImageFilter
class vieCode:
__fontSize = 20 # 字体大小
__width = 120 # 画布宽度
__heigth = 45 # 画布高度
__length = 4 # 验证码长度
__draw = None # 画布
__img = None # 图片资源
__code = None # 验证码字符
__str = None # 自定义验证码字符集
__inCurve = True # 是否画干扰线
__inNoise = True # 是否画干扰点
__type = 2 # 验证码类型 1、纯字母 2、数字字母混合
__fontPatn = 'class/fonts/2.ttf' # 字体
def GetCodeImage(self, size=80, length=4):
'''获取验证码图片
@param int size 验证码大小
@param int length 验证码长度
'''
# 准备基础数据
self.__length = length
self.__fontSize = size
self.__width = self.__fontSize * self.__length
self.__heigth = int(self.__fontSize * 1.5)
# 生成验证码图片
self.__createCode()
self.__createImage()
self.__createNoise()
self.__printString()
self.__cerateFilter()
return self.__img, self.__code
def __cerateFilter(self):
'''模糊处理'''
self.__img = self.__img.filter(ImageFilter.BLUR)
filter = ImageFilter.ModeFilter(8)
self.__img = self.__img.filter(filter)
def __createCode(self):
'''创建验证码字符'''
# 是否自定义字符集合
if not self.__str:
# 源文本
number = "3456789"
srcLetter = "qwertyuipasdfghjkzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"
srcUpper = srcLetter.upper()
if self.__type == 1:
self.__str = number
else:
self.__str = srcLetter + srcUpper + number
# 构造验证码
self.__code = random.sample(self.__str, self.__length)
def __createImage(self):
'''创建画布'''
bgColor = (random.randint(200, 255), random.randint(
200, 255), random.randint(200, 255))
self.__img = Image.new('RGB', (self.__width, self.__heigth), bgColor)
self.__draw = ImageDraw.Draw(self.__img)
def __createNoise(self):
'''画干扰点'''
if not self.__inNoise:
return
font = ImageFont.truetype(self.__fontPatn, int(self.__fontSize / 1.5))
for i in xrange(5):
# 杂点颜色
noiseColor = (random.randint(150, 200), random.randint(
150, 200), random.randint(150, 200))
putStr = random.sample(self.__str, 2)
for j in range(2):
# 绘杂点
size = (random.randint(-10, self.__width),
random.randint(-10, self.__heigth))
self.__draw.text(size, putStr[j], font=font, fill=noiseColor)
pass
def __createCurve(self):
'''画干扰线'''
if not self.__inCurve:
return
x = y = 0
# 计算曲线系数
a = random.uniform(1, self.__heigth / 2)
b = random.uniform(-self.__width / 4, self.__heigth / 4)
f = random.uniform(-self.__heigth / 4, self.__heigth / 4)
t = random.uniform(self.__heigth, self.__width * 2)
xend = random.randint(self.__width / 2, self.__width * 2)
w = (2 * math.pi) / t
# 画曲线
color = (random.randint(30, 150), random.randint(
30, 150), random.randint(30, 150))
for x in xrange(xend):
if w != 0:
for k in xrange(int(self.__heigth / 10)):
y = a * math.sin(w * x + f) + b + self.__heigth / 2
i = int(self.__fontSize / 5)
while i > 0:
px = x + i
py = y + i + k
self.__draw.point((px, py), color)
i -= i
def __printString(self):
'''打印验证码字符串'''
font = ImageFont.truetype(self.__fontPatn, self.__fontSize)
x = 0
# 打印字符到画板
for i in xrange(self.__length):
# 设置字体随机颜色
color = (random.randint(30, 150), random.randint(
30, 150), random.randint(30, 150))
# 计算座标
x = random.uniform(self.__fontSize * i * 0.95,
self.__fontSize * i * 1.1)
y = self.__fontSize * random.uniform(0.3, 0.5)
# 打印字符
self.__draw.text((x, y), self.__code[i], font=font, fill=color)
BIN
View File
Binary file not shown.
View File
View File
View File
+1
View File
@@ -0,0 +1 @@
30
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
[
{
"title":"全部",
"type":0,
"ps":""
},
{
"title":"运行环境",
"type":1,
"ps":""
},
{
"title":"缓存软件",
"type":2,
"ps":""
},
{
"title":"代码管理",
"type":3,
"ps":""
},
{
"title":"系统工具",
"type":4,
"ps":""
},
{
"title":"其他插件",
"type":5,
"ps":""
}
]
+131
View File
@@ -0,0 +1,131 @@
CREATE TABLE IF NOT EXISTS `backup` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`type` INTEGER,
`name` TEXT,
`pid` INTEGER,
`filename` TEXT,
`size` INTEGER,
`addtime` TEXT
);
CREATE TABLE IF NOT EXISTS `binding` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`pid` INTEGER,
`domain` TEXT,
`path` TEXT,
`port` INTEGER,
`addtime` TEXT
);
CREATE TABLE IF NOT EXISTS `config` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`webserver` TEXT,
`backup_path` TEXT,
`sites_path` TEXT,
`status` INTEGER,
`mysql_root` TEXT
);
INSERT INTO `config` (`id`, `webserver`, `backup_path`, `sites_path`, `status`, `mysql_root`) VALUES
(1, 'nginx', '/www/backup', '/www/wwwroot', 0, 'admin');
CREATE TABLE IF NOT EXISTS `crontab` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` TEXT,
`type` TEXT,
`where1` TEXT,
`where_hour` INTEGER,
`where_minute` INTEGER,
`echo` TEXT,
`addtime` TEXT
);
CREATE TABLE IF NOT EXISTS `databases` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`pid` INTEGER,
`name` TEXT,
`username` TEXT,
`password` TEXT,
`accept` TEXT,
`ps` TEXT,
`addtime` TEXT
);
CREATE TABLE IF NOT EXISTS `firewall` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`port` TEXT,
`ps` TEXT,
`addtime` TEXT
);
INSERT INTO `firewall` (`id`, `port`, `ps`, `addtime`) VALUES
(2, '80', '网站默认端口', '0000-00-00 00:00:00'),
(3, '8888', 'WEB面板', '0000-00-00 00:00:00'),
(4, '21', 'FTP服务', '0000-00-00 00:00:00'),
(5, '22', 'SSH远程管理服务', '0000-00-00 00:00:00');
CREATE TABLE IF NOT EXISTS `ftps` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`pid` INTEGER,
`name` TEXT,
`password` TEXT,
`path` TEXT,
`status` TEXT,
`ps` TEXT,
`addtime` TEXT
);
CREATE TABLE IF NOT EXISTS `logs` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`type` TEXT,
`log` TEXT,
`addtime` TEXT
);
CREATE TABLE IF NOT EXISTS `sites` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` TEXT,
`path` TEXT,
`status` TEXT,
`index` TEXT,
`ps` TEXT,
`addtime` TEXT
);
CREATE TABLE IF NOT EXISTS `domain` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`pid` INTEGER,
`name` TEXT,
`port` INTEGER,
`addtime` TEXT
);
CREATE TABLE IF NOT EXISTS `users` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`username` TEXT,
`password` TEXT,
`login_ip` TEXT,
`login_time` TEXT,
`phone` TEXT,
`email` TEXT
);
INSERT INTO `users` (`id`, `username`, `password`, `login_ip`, `login_time`, `phone`, `email`) VALUES
(1, 'admin', '21232f297a57a5a743894a0e4a801fc3', '192.168.0.10', '2016-12-10 15:12:56', 0, '287962566@qq.com');
CREATE TABLE IF NOT EXISTS `tasks` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` TEXT,
`type` TEXT,
`status` TEXT,
`addtime` TEXT,
`start` INTEGER,
`end` INTEGER,
`execstr` TEXT
);
+37
View File
@@ -0,0 +1,37 @@
CREATE TABLE IF NOT EXISTS `network` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`up` INTEGER,
`down` INTEGER,
`total_up` INTEGER,
`total_down` INTEGER,
`down_packets` INTEGER,
`up_packets` INTEGER,
`addtime` INTEGER
);
CREATE TABLE IF NOT EXISTS `cpuio` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`pro` INTEGER,
`mem` INTEGER,
`addtime` INTEGER
);
CREATE TABLE IF NOT EXISTS `diskio` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`read_count` INTEGER,
`write_count` INTEGER,
`read_bytes` INTEGER,
`write_bytes` INTEGER,
`read_time` INTEGER,
`write_time` INTEGER,
`addtime` INTEGER
);
CREATE TABLE IF NOT EXISTS `load_average` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`pro` REAL,
`one` REAL,
`five` REAL,
`fifteen` REAL,
`addtime` INTEGER
);
Executable
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
rm -rf ./*.pyc
rm -rf ./*/*.pyc
#open "http://127.0.0.1:7200"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

-96
View File
@@ -1,96 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="icon" type="image/x-icon" href="./static/images/logo.png">
<link type="text/css" href="./static/css/pages.css" media="all" rel="stylesheet">
<title>mdserver-web | Linux开源面板</title>
<meta name="generator" content="Jekyll v3.9.3">
<meta property="og:title" content="Linux开源面板">
<meta property="og:locale" content="en_US">
<meta name="description" content="Linux开源面板">
<meta property="og:description" content="Linux开源面板">
<link rel="canonical" href="https://www.midoks.me/">
<meta property="og:url" content="https://www.midoks.me/">
<meta property="og:site_name" content="Linux开源面板">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary">
<meta property="twitter:title" content="Linux开源面板">
<meta name="twitter:site" content="@github">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7736695762519033"
crossorigin="anonymous"></script>
</head>
<body class="home" style="">
<section id="hero-spot" class="hero-spot">
<a href="https://pages.github.com/">
<img src="./static/images/logo.png" alt="Linux开源面板" class="logo">
</a>
<h1>管理你的服务器</h1>
<a href="https://github.com/midoks/mdserver-web" class="help-link">Github</a>
<div id="slideshow">
<img src="./static/images/mw.jpg" alt="mdserver-web" class="slide active" width="893">
</div>
</section>
<section id="tutorial" class="tutorial">
<h1>准备好开始了吗?</h1>
<!-- ### Start of tutorials -->
<ul id="user-site" class="tutorial-list wrapper active">
<li id="terminal-step-1" class="option-terminal">
<h4>安装面板</h4>
<div class="terminal">
<div class="header"></div>
<div class="shell">
<p><span class="path">~</span><span class="prompt">$</span>curl -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh | bash</p>
<p><span class="path">~</span><span class="prompt">$</span>mw default</p>
<p>==================================================================</p>
<p>MW-Panel default info!</p>
<p>==================================================================</p>
<p>MW-Panel-Url: http://0.0.0.0:13148/xxx</p>
<p>username: yrajbw9q</p>
<p>password: oqxotjgb</p>
<p>Warning:</p>
<p>If you cannot access the panel. </p>
<p>release the following port (44010|888|80|443|22) in the security group.</p>
<p>==================================================================</p>
</div>
</div>
</li>
</ul>
<!-- End of user site tutorial -->
</section>
<!-- End of tutorial section -->
<script src="./static/js/jquery.js"></script>
<script>window.slides = {"mdserver-web":"mw","mw-php":"php",}</script>
<script src="./static/js/application.js"></script>
<footer class="page-footer">
<ul class="site-footer-links right">
<li><a href="https://bbs.midoks.icu">论坛</a></li>
</ul>
<ul class="site-footer-links">
<li>mdserver-web ©2018-∞ Linux面板</li>
<li><a href="https://github.com/midoks/mdserver-web">Github</a></li>
</ul>
</footer>
</body>
</html>
+85
View File
@@ -0,0 +1,85 @@
# coding: utf-8
# 使用示例:
# 1、将此文件重命名为btkill.py , 然后上传到服务器/root目录
# 2、执行 python /root/btkill.py
import time
import os
import sys
sys.path.append("/usr/local/lib/python2.7/site-packages")
import psutil
class btkill:
__limit = 10 # Cpu使用率触发上限
__vmsize = 1048576 / 4 # 虚拟内存触发上限(字节)
def checkMain(self):
pids = psutil.pids()
print pids
num = 0
for pid in pids:
try:
p = psutil.Process(pid)
if p.exe() == "":
continue
name = p.name()
if self.whiteList(name):
continue
cputimes = p.cpu_times()
if cputimes.user < 0.1:
continue
print p
percent = p.cpu_percent(interval=0.1)
vm = p.memory_info().vms
if percent > self.__limit or vm > self.__vmsize:
log = time.strftime('%Y-%m-%d %X', time.localtime()) + " (PID=" + str(
pid) + ", NAME=" + name + ", VMS=" + str(vm) + ", PERCENT=" + str(percent) + "%)"
p.kill()
num += 1
print log + " >> killed\n"
except Exception as ex:
print str(ex)
return num
# 检查白名单
def whiteList(self, name):
wlist = ['yum', 'apt-get', 'apt', 'redis-cli', 'memcached', 'sshd', 'vm', 'vim', 'htop', 'top', 'sh', 'bash', 'zip', 'gzip', 'rsync',
'tar', 'unzip', 'php', 'composer', 'pkill', 'mongo', 'mongod', 'php-fpm', 'nginx', 'httpd', 'lsof', 'ps', 'redis-server',
'mysqld', 'mysqld_safe', 'mysql', 'pure-ftpd', 'sparse_dd', 'stunnel', 'squeezed', 'vncterm', 'awk', 'ruby', 'postgres',
'mpathalert', 'vncterm', 'multipathd', 'fe', 'elasticsyslog', 'syslogd', 'v6d', 'xapi', 'screen', 'runsvdir', 'svlogd',
'java', 'udevd', 'ntpd', 'irqbalance', 'qmgr', 'wpa_supplicant', 'mysqld_safe', 'sftp-server', 'lvmetad', 'gitlab-web',
'pure-ftpd', 'auditd', 'master', 'dbus-daemon', 'tapdisk', 'sshd', 'init', 'ksoftirqd', 'kworker', 'kmpathd',
'kmpath_handlerd', 'python', 'kdmflush', 'bioset', 'crond', 'kthreadd', 'migration', 'rcu_sched', 'kjournald',
'gcc', 'gcc++', 'nginx', 'mysqld', 'php-cgi', 'login', 'firewalld', 'iptables', 'systemd', 'network', 'dhclient',
'systemd-journald', 'NetworkManager', 'systemd-logind', 'systemd-udevd', 'polkitd', 'tuned', 'rsyslogd', 'AliYunDunUpdate', 'AliYunDun', 'sendmail']
wslist = ['vif', 'qemu', 'scsi_eh', 'xcp',
'xen', 'docker', 'yunsuo', 'aliyun', 'PM2']
for key in wlist:
if key == name:
return True
for key in wslist:
if name.find(key) != -1:
return True
return False
# 开始处理
def start(self):
num = 0
while True:
num += self.checkMain()
print "查杀完成, 共查杀[" + str(num) + "]个异常进程!"
time.sleep(3)
print '======================================='
print "查杀完成, 共查杀[" + str(num) + "]个异常进程!"
if __name__ == "__main__":
print "正在检测异常进程..."
print '======================================='
c = btkill()
c.start()
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

+550
View File
@@ -0,0 +1,550 @@
<style>
/*危险按钮*/
.bts-danger:hover{
color: #fff;
background-color: #c9302c;
border-color: #ac2925;
}
#whiteList a{
color: red;
}
/*弹窗*/
.Add_view{
height: 100px;
padding-left: 35px;
padding-top: 35px;
}
.Add_view label{
margin-right: 10px;
font-size: 15px;
font-weight: 100;
}
.Add_view input{
width: 230px;
}
.Add_view .error{
border: 1px solid red;
}
.Add_view .correct{
border: 1px solid #20a53a;
}
/*日志管理*/
.btnTitle{
font-weight: 100;
font-size: 16px;
line-height: 34px;
height: 34px;
margin-right: 15px;
position: relative;
top: 2px;
}
.whiteList-table{
margin-top: 10px;
}
/*登录日志表单*/
.viewTwo .whiteList-table{
overflow-x: hidden;
height: 500px;
}
.maks{
background: rgba(39, 39, 39, 0.4);
position: absolute;
width: 700px;
height: 555px;
z-index: 999;
overflow: hidden;
}
.boxshow{
position: absolute;
height: 150px;
width: 400px;
margin-left: -200px;
margin-top: -75px;
left: 50%;
top: 50%;
z-index: 1000;
background: #fff;
padding: 25px 20px;
overflow: hidden;
}
.btPayment {
float: left;
padding: 8px 10px;
width: 190px;
height: 100px;
line-height: 33px;
text-align: center;
border-left: 1px solid #ececec;
}
.btPayment .t2{
display: block;
width: 100%;
text-align: center;
font-size: 16px;
margin-bottom: 5px;
}
.btPayment .price{
color: #20A53A;
font-size: 22px;
margin: 0 5px;
}
.bt-form{
overflow: hidden;
}
.boxtext{
line-height: 32px;
margin-top: -17px;
text-align: center;
border-bottom: #eee 1px solid;
height: 39px;
font-size: 14px;
}
</style>
<div class="maks" style="display: none"></div>
<div class="boxshow" style="display: none;">
<div>
<div class="boxtext">
<span>未开通此服务,如需使用请开通企业运维版。</span>
</div>
<div class="btvipinfo" style="width: 170px;padding-left: 20px">
<p style="height: 25px">1、一对一运维人员对接</p>
<p style="height: 25px">2、提供每月3次运维服务</p>
<p style="height: 25px">3、双重安全隔离登录</p>
</div>
<div class="btPayment">
<span class="t2">企业运维版<span class="price">98</span>元/月</span>
<button class="btn btn-success btn-sm" style="width:80%" onclick="window.open('https://www.bt.cn/admin/index.html')">立即开通</button>
</div>
</div>
</div>
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw">密钥</p>
<p>面板设置</p>
<p>面板登录日志</p>
<p>SSH设置</p>
<p>SSH日志管理</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con viewZoo">
<p class="status" style="margin-top:10px;margin-left:10px;height: 80px;margin-bottom:15px;">
<span style="float:left;margin-top:-5px">密钥:</span>
<textarea class="bt-input-text" name="token" readonly="readonly" style="background-color: #eee;width:400px;height:80px;padding: 8px 15px;" placeholder="密钥已隐藏..."></textarea>
</p>
<input type="button" class="btn btn-success btn-sm" name="ButtonShow" style="margin-left:52px;width:100px" onclick="sagelogin.tokenShow()" value="显示密钥" />
<ul style="margin: 15px 5px;padding-left: 70px;list-style-type: disc;line-height: 25px;">
<li>宝塔企业运维后台连接您的服务器需要此密钥,请妥善记录并保存</li>
<li>一但密钥丢失,可能导致您无法登录服务器</li>
</ul>
</div>
<div class="soft-man-con viewOne" style="display: none;">
<p class="status">当前状态:
<span>开启</span>
<span style="color: #20a53a; margin-left: 3px;" class="glyphicon glyphicon glyphicon-play"></span>
<span style="color: red; margin-left: 3px; display: none" class="glyphicon glyphicon-pause"></span>
</p>
<div class="sfm-opt">
<button class="btn btn-default btn-sm bts-danger" onclick="sagelogin.Panel_Admin()">清除面板登录限制IP</button>
<button class="btn btn-default btn-sm bts-safety" onclick="sagelogin.Add_view('面板白名单',true)">添加白名单</button>
</div>
<div class="whiteList-table divtable" style="overflow-x: hidden;height: 420px">
<table class="table table-hover" style="max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>IP地址</th>
<th style="text-align: right;">操作</th>
</tr>
</thead>
<tbody id="whiteListOne"></tbody>
</table>
</div>
</div>
<div class="soft-man-con viewTwo" style="display: none">
<div class="whiteList-table divtable">
<table class="table table-hover" style=" max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>操作记录</th>
<th>操作时间</th>
</tr>
</thead>
<tbody id="whiteListTwo"></tbody>
</table>
</div>
</div>
<div class="soft-man-con viewThree" style="display: none">
<p class="status">当前状态:
<span>开启</span>
<span style="color: #20a53a; margin-left: 3px;" class="glyphicon glyphicon glyphicon-play">
</span>
<span style="color: red; margin-left: 3px; display: none" class="glyphicon glyphicon-pause"></span>
</p>
<div class="sfm-opt">
<button class="btn btn-default btn-sm bts-danger" onclick="sagelogin.Panel_Admin()">清除SSH登录限制IP</button>
<button class="btn btn-default btn-sm bts-safety" onclick="sagelogin.Add_view('SSH白名单',false)">添加白名单</button>
</div>
<div class="whiteList-table divtable" style="overflow-x: hidden;height: 420px">
<table class="table table-hover" style="max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>IP地址</th>
<th style="text-align: right;">操作</th>
</tr>
</thead>
<tbody id="whiteListThree"></tbody>
</table>
</div>
</div>
<div class="soft-man-con viewFour" style="display: none">
<div class="btnclick">
<label class="btnTitle">日志分类</label>
<div class="btn-group">
<input type="submit" name="btnOne" class="btn btn-success" onclick="sagelogin.SSH_Defense_List(0)" value="已防御" />
<input type="submit" name="btnTwo" class="btn btn-default" onclick="sagelogin.SSH_Defense_List(1)" value="入侵日志"/>
<input type="submit" name="btnThree" class="btn btn-default" onclick="sagelogin.SSH_Defense_List(2)" value="登录日志"/>
</div>
</div>
<div class="whiteList-table divtable" style="overflow-x: hidden;height: 470px;">
<table class="table table-hover" style="max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>源IP地址</th>
<th>用户</th>
<th style="text-align: right;">登录时间</th>
</tr>
</thead>
<tbody id="whiteListFour"></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script type="javascript/text">
//宝塔安全登录
$(function(){
$(".bt-w-menu p").click(function(){
$(this).addClass("bgw").siblings().removeClass("bgw");
$('.bt-w-con .soft-man-con').hide().eq($(this).index()).show();
switch($(this).index()) {
case 0:
break;
case 1:
sagelogin.Panel_White_List();
break;
case 2:
sagelogin.Panel_journal();
break;
case 3:
sagelogin.SSH_White_List();
break;
case 4:
sagelogin.SSH_Defense_List(0);
break;
}
});
layer.load();
$.get('/plugin?action=a&name=safelogin&s=GetServerInfo',function(data) {
layer.closeAll('loading');
if (data.status) {
$('.boxshow').hide();
$('.maks').hide();
}else{
$('.boxshow').show();
$('.maks').show();
}
});
});
var sagelogin = new Object();
sagelogin = {
Addview:'',
SSHlogList:'',
PanelLogList:'',
// SSH管理
SSH_Admin:function(){
var confirm = layer.confirm('确定清除面板登录限制IP地址?',{icon: 1}, {
btn: ['确认','取消'],
}, function(){
$.get('/plugin?action=a&name=safelogin&s=close_ssh_limit',function(data) {
if (data.status) {
layer.msg(data.msg,{icon:1});
sagelogin.SSH_White_List();
}else{
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
tokenShow:function(){
var inputPwd = layer.open({
type: 1,
title: '验证面板密码',
shadeClose: true,
shade: 0.3,
area: ['380px', '190px'],
btn:['确定','取消'],
content:'<div class="Add_view" style="height:90px"><label>面板密码:</label><input name="panel_pwd" class=" bt-input-text" type="password"></div>',
yes:function(){
var passwordStr = $("input[name='panel_pwd']").val();
var index = layer.load(0, {shade: false});
$.post('/plugin?action=a&name=safelogin&s=GetServerToken',{password:passwordStr},function(token) {
layer.close(index);
if(token.status === false){
layer.msg(token.msg,{icon:2});
return;
}
layer.close(inputPwd);
$("textarea[name='token']").val(token);
});
},
btn2:function(){
layer.close(inputPwd);
}
});
},
// SSH白名单——列表
SSH_White_List:function(){
var index = layer.load(0, {shade: false});
$.get('/plugin?action=a&name=safelogin&s=get_ssh_limit','',function(data){
$('#whiteListThree').empty();
var List = '';
if (data.length == 0){
$('.viewThree .status span:eq(0)').html('关闭');
$('.viewThree .glyphicon-pause').show();
$('.viewThree .glyphicon-play').hide();
}else {
$('.viewThree .status span:eq(0)').html('开启');
$('.viewThree .glyphicon-pause').hide();
$('.viewThree .glyphicon-play').show();
}
for (var i = 0; i < data.length; i++) {
List = List + '<tr><td>'+ data[i] +'</td><td style="text-align:right;"><a href="javascript:;" ip-val="'+ data[i] +'" onclick="sagelogin.SSH_Del_White_List(event)" style="color:red">删除</a></td></tr>'
}
$('#whiteListThree').append(List);
layer.close(index);
});
},
// SSH白名单——删除
SSH_Del_White_List:function(ev){
var ip = ev.currentTarget.getAttribute('ip-val');
var confirm = layer.confirm('确定删除IP['+ ip +']限制地址?', {
btn: ['确认','取消'] //按钮
}, function(){
$.get('/plugin?action=a&name=safelogin&s=remove_ssh_limit',{ip:ip},function(data){
if (data.status) {
sagelogin.SSH_White_List();
layer.msg(data.msg,{icon:1});
}else {
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
// SSH白名单——添加
SSH_Add_White_List:function(ip){
$.post('/plugin?action=a&name=safelogin&s=add_ssh_limit',{ip:ip},function(data){
layer.close(sagelogin.Addview);
if (data.status) {
sagelogin.SSH_White_List();
layer.msg(data.msg,{icon:1});
}else{
layer.msg(data.msg,{icon:2});
}
});
},
// SSH日志管理
SSH_Defense_List:function(status){
$('.btnclick input').removeClass('btn-success').addClass('btn-default');
$('.btnclick input').eq(status).addClass('btn-success').removeClass('btn-default');
if (sagelogin.SSHlogList == '') {
$.get('/plugin?action=a&s=get_ssh_errorlogin&name=safelogin',function(data){
sagelogin.SSHlogList = data;
sagelogin.DefenseFor(sagelogin.SSHlogList.defense);
});
}else{
switch(status) {
case 0:
sagelogin.DefenseFor(sagelogin.SSHlogList.defense);
break;
case 1:
sagelogin.DefenseFor(sagelogin.SSHlogList.intrusion);
break;
case 2:
sagelogin.DefenseFor(sagelogin.SSHlogList.success);
break;
}
}
},
// SSH日志渲染模板
DefenseFor:function(data){
var List = '';
$('#whiteListFour').empty();
for (var i = data.length - 1; i >= 0; i--) {
List = List + '<tr><td>'+data[i].address+'</td><td>' + data[i].user + '</td><td style="text-align:right">'+ data[i].date+'</td></tr>'
}
$('#whiteListFour').append(List);
},
// 面板管理
Panel_Admin:function(){
var confirm = layer.confirm('确定清除面板登录限制IP地址?', {
btn: ['确认','取消'] //按钮
}, function(){
$.get('/plugin?action=a&name=safelogin&s=close_panel_limit',function(data) {
if (data.status) {
layer.msg(data.msg,{icon:1});
sagelogin.Panel_White_List();
}else{
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
// 面板白名单——列表
Panel_White_List:function(){
$.get('/plugin?action=a&name=safelogin&s=get_panel_limit','',function(data){
$('#whiteListOne').empty();
var List = '';
if (data.length == 0){
$('.viewOne .status span:eq(0)').html('关闭');
$('.viewOne .glyphicon-pause').show();
$('.viewOne .glyphicon-play').hide();
}else {
$('.viewOne .status span:eq(0)').html('开启');
$('.viewOne .glyphicon-pause').hide();
$('.viewOne .glyphicon-play').show();
}
for (var i = 0; i < data.length; i++) {
List = List + '<tr><td>'+ data[i] +'</td><td style="text-align:right;"><a href="javascript:;" ip-val="'+ data[i] +'" onclick="sagelogin.Panel_Del_White_List(event)" style="color:red">删除</a></td></tr>'
}
$('#whiteListOne').append(List);
});
},
// 面板白名单——删除
Panel_Del_White_List:function(ev){
var ip = ev.currentTarget.getAttribute('ip-val');
var confirm = layer.confirm('确定删除IP['+ ip +']限制地址?', {
btn: ['确认','取消'] //按钮
}, function(){
$.get('/plugin?action=a&name=safelogin&s=remove_ssh_limit',{ip:ip},function(data){
if (data.status) {
sagelogin.Panel_White_List();
layer.msg(data.msg,{icon:1});
}else {
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
// 面板白名单——添加
Panel_Add_White_List:function(ip){
$.post('/plugin?action=a&name=safelogin&s=add_panel_limit', {ip: ip}, function(data) {
layer.close(sagelogin.Addview);
if (data.status) {
sagelogin.Panel_White_List();
layer.msg(data.msg,{icon:1});
}else{
layer.msg(data.msg,{icon:2});
}
});
},
// 面板日志——列表
Panel_journal:function(){
var index = layer.load(0, {shade: false});
$.get('/plugin?action=a&name=safelogin&s=get_login_log',function(data){
$('#whiteListTwo').empty();
var List = '';
sagelogin.PanelLogList = data;
for (var i = sagelogin.PanelLogList.length - 1; i >= 0; i--) {
List = List + '<tr><td>'+ sagelogin.PanelLogList[i].log +'</td><td style="text-align:right;">'+ sagelogin.PanelLogList[i].addtime +'</tr>';
}
$('#whiteListTwo').append(List);
layer.close(index);
});
},
// IP正则:192.168.1.0/24
CheckIP:function(ip) {
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\/\d{1,2})?$/;
return reg.test(ip);
},
CheckIPTwo:function(ip) {
var reg = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/gi;
return reg.test(ip);
},
// 添加表单效验
addViewVul:function(status){
var ip = $('.addViewVul');
if (status) {
console.log(sagelogin.CheckIP(ip.val()));
if(sagelogin.CheckIPTwo(ip.val())){
ip.addClass('correct').removeClass('error');
return true;
}else {
ip.addClass('error').removeClass('correct');
return false;
}
}else{
if(sagelogin.CheckIP(ip.val())){
ip.addClass('correct').removeClass('error');
return true;
}else {
ip.addClass('error').removeClass('correct');
return false;
}
}
},
// 添加界面
Add_view:function(title,status){
var _this = this;
var text = ''
var statuss = true;
if (status) {
text = '';
statuss = true;
}else{
text = '<p style="color:red;margin: 5px 0px 0px 67px;font-size: 14px;">支持IP段,如:192.168.1.0/24</p>';
statuss = false;
}
sagelogin.Addview = layer.open({
type: 1,
title: title,
shadeClose: true,
shade: 0.1,
area: ['380px', '200px'],
btn:['确定','取消'],
content:'<div class="Add_view"><label>IP地址:</label><input class="addViewVul bt-input-text" onchange="sagelogin.addViewVul('+ statuss +')" type="text">'+ text +'</div>',
yes:function(){
if (sagelogin.addViewVul(statuss)) {
if(status){
sagelogin.Panel_Add_White_List($('.addViewVul').val());
}else{
sagelogin.SSH_Add_White_List($('.addViewVul').val());
}
}else{
layer.msg('请输入合法的IP地址',{icon:2})
}
},
btn2:function(){
layer.close(sagelogin.Addview);
}
});
$('.addViewVul').focus();
}
}
</script>
+20
View File
@@ -0,0 +1,20 @@
# coding: utf-8
import time
import psutil
import random
import os
import urllib
import binascii
import json
import public
import re
def status():
return 'start'
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
+16
View File
@@ -0,0 +1,16 @@
{
"sort": 7,
"ps": "最流行的SVN代码共享管理软件",
"shell": "install.sh",
"name": "csvn",
"title": "CSVN",
"versions": ["5.1"],
"updates":["5.1.4"],
"tip": "soft",
"checks": "server/csvn",
"author": "midoks",
"date": "2017-04-01",
"home": "https://www.collab.net",
"type": "SVN代码共享管理软件",
"pid": "3"
}
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/bt_install.pl
CSVN_SOURCE='https://github.com/midoks/mdserver-web/releases/download/init/CollabNetSubversionEdge-5.1.4_linux-x86_64.tar.xz'
Install_csvn()
{
mkdir -p $serverPath/tmp
echo '正在安装脚本文件...' > $install_tmp
if [ ! -f $serverPath/tmp/csvn.tar.xz ];then
wget -O $serverPath/so/csvn.tar.xz ${CSVN_SOURCE}
fi
cd $serverPath/tmp && tar -Jxf $serverPath/tmp/csvn.tar.xz
mv $serverPath/tmp/csvn $serverPath/csvn
echo '安装完成' > $install_tmp
}
Uninstall_csvn()
{
rm -rf $serverPath/csvn
}
action=$1
host=$2
if [ "${1}" == 'install' ];then
Install_csvn
else
Uninstall_csvn
fi
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

+18
View File
@@ -0,0 +1,18 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="redisService();">服务</p>
<p onclick="redisConfig();">配置修改</p>
<p onclick="redisConfig();">切换版本</p>
<p onclick="redisStatus();">负载状态</p>
<p onclick="redisStatus();">性能调整</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
$.getScript( "/plugins/file?name=memcached&f=js/mem.js");
</script>
+96
View File
@@ -0,0 +1,96 @@
# coding:utf-8
import sys
import io
import os
import time
sys.path.append(os.getcwd() + "/class/core")
import public
def status():
data = public.execShell(
"ps -ef|grep redis |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
def start():
path = os.path.dirname(os.getcwd())
cmd = path + "/redis/bin/redis-server"
cmd = cmd + " " + path + "/redis/redis.conf"
data = public.execShell(cmd)
if data[0] == '':
return 'ok'
return 'fail'
def stop():
data = public.execShell(
"ps -ef|grep redis |grep -v grep |grep -v python |awk '{print $2}' | xargs kill -9")
if data[0] == '':
return 'ok'
return 'fail'
def restart():
return 'ok'
def reload():
return 'ok'
def runInfo():
path = os.path.dirname(os.getcwd())
cmd = path + "/redis/bin/redis-cli info"
data = public.execShell(cmd)[0]
res = [
'tcp_port',
'uptime_in_days', # 已运行天数
'connected_clients', # 连接的客户端数量
'used_memory', # Redis已分配的内存总量
'used_memory_rss', # Redis占用的系统内存总量
'used_memory_peak', # Redis所用内存的高峰值
'mem_fragmentation_ratio', # 内存碎片比率
'total_connections_received', # 运行以来连接过的客户端的总数量
'total_commands_processed', # 运行以来执行过的命令的总数量
'instantaneous_ops_per_sec', # 服务器每秒钟执行的命令数量
'keyspace_hits', # 查找数据库键成功的次数
'keyspace_misses', # 查找数据库键失败的次数
'latest_fork_usec' # 最近一次 fork() 操作耗费的毫秒数
]
data = data.split("\n")
result = {}
for d in data:
if len(d) < 3:
continue
t = d.strip().split(':')
if not t[0] in res:
continue
result[t[0]] = t[1]
return public.getJson(result)
def getConf():
path = os.path.dirname(os.getcwd()) + "/redis/redis.conf"
return path
if __name__ == "__main__":
func = sys.argv[1]
if func == 'run_info':
print runInfo()
elif func == 'conf':
print getConf()
elif func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
+17
View File
@@ -0,0 +1,17 @@
{
"sort": 7,
"ps": "Memcached 是一个高性能的分布式内存对象缓存系统",
"name": "memcached",
"title": "Memcached",
"shell": "install.sh",
"versions":["1.5"],
"updates":["1.5.12"],
"tip": "soft",
"checks": "server/memcached",
"display": 1,
"author": "Zend",
"date": "2017-04-01",
"home": "http://memcached.org/",
"type": 0,
"pid": "2"
}
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/bt_install.pl
Install_mem()
{
mkdir -p $serverPath/tmp
echo '正在安装脚本文件...' > $install_tmp
wget -O $serverPath/tmp/memcached.tar.gz http://www.memcached.org/files/memcached-1.5.12.tar.gz
cd $serverPath/tmp && tar -zxvf memcached.tar.gz
mkdir -p $serverPath/memcached
cd memcached* && ./configure --prefix=$serverPath/memcached && make && make install
echo '安装完成' > $install_tmp
#rm -rf $serverPath/tmp
}
Uninstall_mem()
{
rm -rf mkdir -p $serverPath/memcached
}
action=$1
if [ "${1}" == 'install' ];then
Install_mem
else
Uninstall_mem
fi
+259
View File
@@ -0,0 +1,259 @@
function redisOp(a, b) {
var c = "name=" + a + "&func=" + b;
var d = "";
switch(b) {
case "stop":
d = '停止';
break;
case "start":
d = '启动';
break;
case "restart":
d = '重启';
break;
case "reload":
d = '重载';
break
}
layer.confirm( '您真的要{1}{2}服务吗?'.replace('{1}', d).replace('{2}', a), {icon:3,closeBtn: 2}, function() {
var e = layer.msg('正在{1}{2}服务,请稍候...'.replace('{1}', d).replace('{2}', a), {icon: 16,time: 0});
$.post("/plugins/run", c, function(g) {
layer.close(e);
var f = g.data == 'ok' ? '{1}服务已{2}'.replace('{1}', a).replace('{2}', d):'{1}服务{2}失败!'.replace('{1}', a).replace('{2}', d);
layer.msg(f, {icon: g.data == 'ok' ? 1 : 2});
if(b != "reload" && g.data == 'ok') {
if (b == 'start') {
setRedisService('redis', true);
} else if (b=='stop'){
setRedisService('redis', false);
} else {
}
}
if(g.data != 'ok') {
layer.msg(g.data, {icon: 2,time: 0,shade: 0.3,shadeClose: true});
}
},'json').error(function() {
layer.close(e);
layer.msg('操作成功!', {icon: 1});
});
})
}
//服务
function setRedisService(name, status){
var serviceCon ='<p class="status">当前状态:<span>'+(status ? '开启' : '关闭' )+
'</span><span style="color: '+
(status?'#20a53a;':'red;')+
' margin-left: 3px;" class="glyphicon ' + (status?'glyphicon glyphicon-play':'glyphicon-pause')+'"></span></p><div class="sfm-opt">\
<button class="btn btn-default btn-sm" onclick="redisOp(\''+name+'\',\''+(status?'stop':'start')+'\')">'+(status?'停止':'启动')+'</button>\
<button class="btn btn-default btn-sm" onclick="redisOp(\''+name+'\',\'restart\')">重启</button>\
<button class="btn btn-default btn-sm" onclick="redisOp(\''+name+'\',\'reload\')">重载配置</button>\
</div>';
$(".soft-man-con").html(serviceCon);
}
//服务
function redisService(){
$.post('/plugins/run', {name:'redis', func:'status'}, function(data) {
console.log(data);
if(!data.status){
layer.msg(data.msg,{icon:0,time:3000,shade: [0.3, '#000']});
return;
}
if (data.data == 'start'){
setRedisService('redis', true);
} else {
setRedisService('redis', false);
}
},'json');
}
redisService();
//配置修改 --- start
function redisConfig(type){
var con = '<p style="color: #666; margin-bottom: 7px">提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!</p><textarea class="bt-input-text" style="height: 320px; line-height:18px;" id="textBody"></textarea>\
<button id="OnlineEditFileBtn" class="btn btn-success btn-sm" style="margin-top:10px;">保存</button>\
<ul class="help-info-text c7 ptb15">\
<li>此处为redis主配置文件,若您不了解配置规则,请勿随意修改。</li>\
</ul>';
$(".soft-man-con").html(con);
var loadT = layer.msg('配置文件路径获取中...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/plugins/run', {name:'redis', func:'conf'},function (data) {
layer.close(loadT);
var loadT2 = layer.msg('文件内容获取中...',{icon:16,time:0,shade: [0.3, '#000']});
var fileName = data.data;
$.post('/files/get_body', 'path=' + fileName, function(rdata) {
layer.close(loadT2);
if (!rdata.status){
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
$("#textBody").empty().text(rdata.data.data);
$(".CodeMirror").remove();
var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
extraKeys: {
"Ctrl-Space": "autocomplete",
"Ctrl-F": "findPersistent",
"Ctrl-H": "replaceAll",
"Ctrl-S": function() {
redisConfSafe(fileName);
}
},
lineNumbers: true,
matchBrackets:true,
});
editor.focus();
$(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
$("#OnlineEditFileBtn").click(function(){
$("#textBody").text(editor.getValue());
redisConfSafe(fileName);
});
},'json');
},'json');
}
//配置保存
function redisConfSafe(fileName) {
var data = encodeURIComponent($("#textBody").val());
var encoding = 'utf-8';
var loadT = layer.msg('保存中...', {
icon: 16,
time: 0
});
$.post('/files/save_body', 'data=' + data + '&path=' + fileName + '&encoding=' + encoding, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, {
icon: rdata.status ? 1 : 2
});
},'json');
}
//配置修改 --- end
//redis负载状态 start
function redisStatus() {
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'redis', func:'run_info'}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
var rdata = $.parseJSON(data.data);
hit = (parseInt(rdata.keyspace_hits) / (parseInt(rdata.keyspace_hits) + parseInt(rdata.keyspace_misses)) * 100).toFixed(2);
var Con = '<div class="divtable">\
<table class="table table-hover table-bordered" style="width: 490px;">\
<thead><th>字段</th><th>当前值</th><th>说明</th></thead>\
<tbody>\
<tr><th>uptime_in_days</th><td>' + rdata.uptime_in_days + '</td><td>已运行天数</td></tr>\
<tr><th>tcp_port</th><td>' + rdata.tcp_port + '</td><td>当前监听端口</td></tr>\
<tr><th>connected_clients</th><td>' + rdata.connected_clients + '</td><td>连接的客户端数量</td></tr>\
<tr><th>used_memory_rss</th><td>' + ToSize(rdata.used_memory_rss) + '</td><td>Redis当前占用的系统内存总量</td></tr>\
<tr><th>used_memory</th><td>' + ToSize(rdata.used_memory) + '</td><td>Redis当前已分配的内存总量</td></tr>\
<tr><th>used_memory_peak</th><td>' + ToSize(rdata.used_memory_peak) + '</td><td>Redis历史分配内存的峰值</td></tr>\
<tr><th>mem_fragmentation_ratio</th><td>' + rdata.mem_fragmentation_ratio + '%</td><td>内存碎片比率</td></tr>\
<tr><th>total_connections_received</th><td>' + rdata.total_connections_received + '</td><td>运行以来连接过的客户端的总数量</td></tr>\
<tr><th>total_commands_processed</th><td>' + rdata.total_commands_processed + '</td><td>运行以来执行过的命令的总数量</td></tr>\
<tr><th>instantaneous_ops_per_sec</th><td>' + rdata.instantaneous_ops_per_sec + '</td><td>服务器每秒钟执行的命令数量</td></tr>\
<tr><th>keyspace_hits</th><td>' + rdata.keyspace_hits + '</td><td>查找数据库键成功的次数</td></tr>\
<tr><th>keyspace_misses</th><td>' + rdata.keyspace_misses + '</td><td>查找数据库键失败的次数</td></tr>\
<tr><th>hit</th><td>' + hit + '%</td><td>查找数据库键命中率</td></tr>\
<tr><th>latest_fork_usec</th><td>' + rdata.latest_fork_usec + '</td><td>最近一次 fork() 操作耗费的微秒数</td></tr>\
<tbody>\
</table></div>'
$(".soft-man-con").html(Con);
},'json');
}
//redis负载状态 end
//memcached负载状态
function MemcachedStatus() {
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
$.get('/ajax?action=GetMemcachedStatus', function(rdata) {
layer.close(loadT);
var Con = '<div class="divtable">\
<table class="table table-hover table-bordered" style="width: 490px;">\
<thead><th>字段</th><th>当前值</th><th>说明</th></thead>\
<tbody>\
<tr><th>BindIP</th><td>' + rdata.bind + '</td><td>监听IP</td></tr>\
<tr><th>PORT</th><td>' + rdata.port + '</td><td>监听端口</td></tr>\
<tr><th>CACHESIZE</th><td>' + rdata.cachesize + ' MB</td><td>最大缓存容量</td></tr>\
<tr><th>MAXCONN</th><td>' + rdata.maxconn + '</td><td>最大连接数限制</td></tr>\
<tr><th>curr_connections</th><td>' + rdata.curr_connections + '</td><td>当前打开的连接数</td></tr>\
<tr><th>cmd_get</th><td>' + rdata.cmd_get + '</td><td>GET请求数</td></tr>\
<tr><th>get_hits</th><td>' + rdata.get_hits + '</td><td>GET命中次数</td></tr>\
<tr><th>get_misses</th><td>' + rdata.get_misses + '</td><td>GET失败次数</td></tr>\
<tr><th>hit</th><td>' + rdata.hit.toFixed(2) + '%</td><td>GET命中率</td></tr>\
<tr><th>curr_items</th><td>' + rdata.curr_items + '</td><td>当前被缓存的数据行数</td></tr>\
<tr><th>evictions</th><td>' + rdata.evictions + '</td><td>因内存不足而被清理的缓存行数</td></tr>\
<tr><th>bytes</th><td>' + ToSize(rdata.bytes) + '</td><td>当前已使用内存</td></tr>\
<tr><th>bytes_read</th><td>' + ToSize(rdata.bytes_read) + '</td><td>请求总大小</td></tr>\
<tr><th>bytes_written</th><td>' + ToSize(rdata.bytes_written) + '</td><td>发送总大小</td></tr>\
<tbody>\
</table></div>'
$(".soft-man-con").html(Con);
});
}
//memcached性能调整
function MemcachedCache() {
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
$.get('/ajax?action=GetMemcachedStatus', function(rdata) {
layer.close(loadT);
var memCon = '<div class="conf_p" style="margin-bottom:0">\
<p><span>BindIP</span><input style="width: 120px;" class="bt-input-text mr5" name="membind" value="' + rdata.bind + '" type="text" ><font>监听IP,请勿随意修改</font></p>\
<p><span>PORT</span><input style="width: 120px;" class="bt-input-text mr5" max="65535" name="memport" value="' + rdata.port + '" type="number" ><font>监听端口,一般无需修改</font></p>\
<p><span>CACHESIZE</span><input style="width: 120px;" class="bt-input-text mr5" name="memcachesize" value="' + rdata.cachesize + '" type="number" >MB,<font>缓存大小,建议不要大于512M</font></p>\
<p><span>MAXCONN</span><input style="width: 120px;" class="bt-input-text mr5" name="memmaxconn" value="' + rdata.maxconn + '" type="number" ><font>最大连接数,建议不要大于40960</font></p>\
<div style="margin-top:10px; padding-right:230px" class="text-right"><button class="btn btn-success btn-sm" onclick="SetMemcachedConf()">' + lan.public.save + '</button></div>\
</div>'
$(".soft-man-con").html(memCon);
});
}
//memcached提交配置
function SetMemcachedConf() {
var data = {
ip: $("input[name='membind']").val(),
port: $("input[name='memport']").val(),
cachesize: $("input[name='memcachesize']").val(),
maxconn: $("input[name='memmaxconn']").val()
}
if (data.ip.split('.').length < 4) {
layer.msg('IP地址格式不正确!', { icon: 2 });
return;
}
if (data.port < 1 || data.port > 65535) {
layer.msg('端口范围不正确!', { icon: 2 });
return;
}
if (data.cachesize < 8) {
layer.msg('缓存值过小', { icon: 2 });
return;
}
if (data.maxconn < 4) {
layer.msg('最大连接数过小', { icon: 2 });
return;
}
var loadT = layer.msg('正在保存...', { icon: 16, time: 0, shade: 0.3 });
$.post('/ajax?action=SetMemcachedCache', data, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

+550
View File
@@ -0,0 +1,550 @@
<style>
/*危险按钮*/
.bts-danger:hover{
color: #fff;
background-color: #c9302c;
border-color: #ac2925;
}
#whiteList a{
color: red;
}
/*弹窗*/
.Add_view{
height: 100px;
padding-left: 35px;
padding-top: 35px;
}
.Add_view label{
margin-right: 10px;
font-size: 15px;
font-weight: 100;
}
.Add_view input{
width: 230px;
}
.Add_view .error{
border: 1px solid red;
}
.Add_view .correct{
border: 1px solid #20a53a;
}
/*日志管理*/
.btnTitle{
font-weight: 100;
font-size: 16px;
line-height: 34px;
height: 34px;
margin-right: 15px;
position: relative;
top: 2px;
}
.whiteList-table{
margin-top: 10px;
}
/*登录日志表单*/
.viewTwo .whiteList-table{
overflow-x: hidden;
height: 500px;
}
.maks{
background: rgba(39, 39, 39, 0.4);
position: absolute;
width: 700px;
height: 555px;
z-index: 999;
overflow: hidden;
}
.boxshow{
position: absolute;
height: 150px;
width: 400px;
margin-left: -200px;
margin-top: -75px;
left: 50%;
top: 50%;
z-index: 1000;
background: #fff;
padding: 25px 20px;
overflow: hidden;
}
.btPayment {
float: left;
padding: 8px 10px;
width: 190px;
height: 100px;
line-height: 33px;
text-align: center;
border-left: 1px solid #ececec;
}
.btPayment .t2{
display: block;
width: 100%;
text-align: center;
font-size: 16px;
margin-bottom: 5px;
}
.btPayment .price{
color: #20A53A;
font-size: 22px;
margin: 0 5px;
}
.bt-form{
overflow: hidden;
}
.boxtext{
line-height: 32px;
margin-top: -17px;
text-align: center;
border-bottom: #eee 1px solid;
height: 39px;
font-size: 14px;
}
</style>
<div class="maks" style="display: none"></div>
<div class="boxshow" style="display: none;">
<div>
<div class="boxtext">
<span>未开通此服务,如需使用请开通企业运维版。</span>
</div>
<div class="btvipinfo" style="width: 170px;padding-left: 20px">
<p style="height: 25px">1、一对一运维人员对接</p>
<p style="height: 25px">2、提供每月3次运维服务</p>
<p style="height: 25px">3、双重安全隔离登录</p>
</div>
<div class="btPayment">
<span class="t2">企业运维版<span class="price">98</span>元/月</span>
<button class="btn btn-success btn-sm" style="width:80%" onclick="window.open('https://www.bt.cn/admin/index.html')">立即开通</button>
</div>
</div>
</div>
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw">密钥</p>
<p>面板设置</p>
<p>面板登录日志</p>
<p>SSH设置</p>
<p>SSH日志管理</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con viewZoo">
<p class="status" style="margin-top:10px;margin-left:10px;height: 80px;margin-bottom:15px;">
<span style="float:left;margin-top:-5px">密钥:</span>
<textarea class="bt-input-text" name="token" readonly="readonly" style="background-color: #eee;width:400px;height:80px;padding: 8px 15px;" placeholder="密钥已隐藏..."></textarea>
</p>
<input type="button" class="btn btn-success btn-sm" name="ButtonShow" style="margin-left:52px;width:100px" onclick="sagelogin.tokenShow()" value="显示密钥" />
<ul style="margin: 15px 5px;padding-left: 70px;list-style-type: disc;line-height: 25px;">
<li>宝塔企业运维后台连接您的服务器需要此密钥,请妥善记录并保存</li>
<li>一但密钥丢失,可能导致您无法登录服务器</li>
</ul>
</div>
<div class="soft-man-con viewOne" style="display: none;">
<p class="status">当前状态:
<span>开启</span>
<span style="color: #20a53a; margin-left: 3px;" class="glyphicon glyphicon glyphicon-play"></span>
<span style="color: red; margin-left: 3px; display: none" class="glyphicon glyphicon-pause"></span>
</p>
<div class="sfm-opt">
<button class="btn btn-default btn-sm bts-danger" onclick="sagelogin.Panel_Admin()">清除面板登录限制IP</button>
<button class="btn btn-default btn-sm bts-safety" onclick="sagelogin.Add_view('面板白名单',true)">添加白名单</button>
</div>
<div class="whiteList-table divtable" style="overflow-x: hidden;height: 420px">
<table class="table table-hover" style="max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>IP地址</th>
<th style="text-align: right;">操作</th>
</tr>
</thead>
<tbody id="whiteListOne"></tbody>
</table>
</div>
</div>
<div class="soft-man-con viewTwo" style="display: none">
<div class="whiteList-table divtable">
<table class="table table-hover" style=" max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>操作记录</th>
<th>操作时间</th>
</tr>
</thead>
<tbody id="whiteListTwo"></tbody>
</table>
</div>
</div>
<div class="soft-man-con viewThree" style="display: none">
<p class="status">当前状态:
<span>开启</span>
<span style="color: #20a53a; margin-left: 3px;" class="glyphicon glyphicon glyphicon-play">
</span>
<span style="color: red; margin-left: 3px; display: none" class="glyphicon glyphicon-pause"></span>
</p>
<div class="sfm-opt">
<button class="btn btn-default btn-sm bts-danger" onclick="sagelogin.Panel_Admin()">清除SSH登录限制IP</button>
<button class="btn btn-default btn-sm bts-safety" onclick="sagelogin.Add_view('SSH白名单',false)">添加白名单</button>
</div>
<div class="whiteList-table divtable" style="overflow-x: hidden;height: 420px">
<table class="table table-hover" style="max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>IP地址</th>
<th style="text-align: right;">操作</th>
</tr>
</thead>
<tbody id="whiteListThree"></tbody>
</table>
</div>
</div>
<div class="soft-man-con viewFour" style="display: none">
<div class="btnclick">
<label class="btnTitle">日志分类</label>
<div class="btn-group">
<input type="submit" name="btnOne" class="btn btn-success" onclick="sagelogin.SSH_Defense_List(0)" value="已防御" />
<input type="submit" name="btnTwo" class="btn btn-default" onclick="sagelogin.SSH_Defense_List(1)" value="入侵日志"/>
<input type="submit" name="btnThree" class="btn btn-default" onclick="sagelogin.SSH_Defense_List(2)" value="登录日志"/>
</div>
</div>
<div class="whiteList-table divtable" style="overflow-x: hidden;height: 470px;">
<table class="table table-hover" style="max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>源IP地址</th>
<th>用户</th>
<th style="text-align: right;">登录时间</th>
</tr>
</thead>
<tbody id="whiteListFour"></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script type="javascript/text">
//宝塔安全登录
$(function(){
$(".bt-w-menu p").click(function(){
$(this).addClass("bgw").siblings().removeClass("bgw");
$('.bt-w-con .soft-man-con').hide().eq($(this).index()).show();
switch($(this).index()) {
case 0:
break;
case 1:
sagelogin.Panel_White_List();
break;
case 2:
sagelogin.Panel_journal();
break;
case 3:
sagelogin.SSH_White_List();
break;
case 4:
sagelogin.SSH_Defense_List(0);
break;
}
});
layer.load();
$.get('/plugin?action=a&name=safelogin&s=GetServerInfo',function(data) {
layer.closeAll('loading');
if (data.status) {
$('.boxshow').hide();
$('.maks').hide();
}else{
$('.boxshow').show();
$('.maks').show();
}
});
});
var sagelogin = new Object();
sagelogin = {
Addview:'',
SSHlogList:'',
PanelLogList:'',
// SSH管理
SSH_Admin:function(){
var confirm = layer.confirm('确定清除面板登录限制IP地址?',{icon: 1}, {
btn: ['确认','取消'],
}, function(){
$.get('/plugin?action=a&name=safelogin&s=close_ssh_limit',function(data) {
if (data.status) {
layer.msg(data.msg,{icon:1});
sagelogin.SSH_White_List();
}else{
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
tokenShow:function(){
var inputPwd = layer.open({
type: 1,
title: '验证面板密码',
shadeClose: true,
shade: 0.3,
area: ['380px', '190px'],
btn:['确定','取消'],
content:'<div class="Add_view" style="height:90px"><label>面板密码:</label><input name="panel_pwd" class=" bt-input-text" type="password"></div>',
yes:function(){
var passwordStr = $("input[name='panel_pwd']").val();
var index = layer.load(0, {shade: false});
$.post('/plugin?action=a&name=safelogin&s=GetServerToken',{password:passwordStr},function(token) {
layer.close(index);
if(token.status === false){
layer.msg(token.msg,{icon:2});
return;
}
layer.close(inputPwd);
$("textarea[name='token']").val(token);
});
},
btn2:function(){
layer.close(inputPwd);
}
});
},
// SSH白名单——列表
SSH_White_List:function(){
var index = layer.load(0, {shade: false});
$.get('/plugin?action=a&name=safelogin&s=get_ssh_limit','',function(data){
$('#whiteListThree').empty();
var List = '';
if (data.length == 0){
$('.viewThree .status span:eq(0)').html('关闭');
$('.viewThree .glyphicon-pause').show();
$('.viewThree .glyphicon-play').hide();
}else {
$('.viewThree .status span:eq(0)').html('开启');
$('.viewThree .glyphicon-pause').hide();
$('.viewThree .glyphicon-play').show();
}
for (var i = 0; i < data.length; i++) {
List = List + '<tr><td>'+ data[i] +'</td><td style="text-align:right;"><a href="javascript:;" ip-val="'+ data[i] +'" onclick="sagelogin.SSH_Del_White_List(event)" style="color:red">删除</a></td></tr>'
}
$('#whiteListThree').append(List);
layer.close(index);
});
},
// SSH白名单——删除
SSH_Del_White_List:function(ev){
var ip = ev.currentTarget.getAttribute('ip-val');
var confirm = layer.confirm('确定删除IP['+ ip +']限制地址?', {
btn: ['确认','取消'] //按钮
}, function(){
$.get('/plugin?action=a&name=safelogin&s=remove_ssh_limit',{ip:ip},function(data){
if (data.status) {
sagelogin.SSH_White_List();
layer.msg(data.msg,{icon:1});
}else {
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
// SSH白名单——添加
SSH_Add_White_List:function(ip){
$.post('/plugin?action=a&name=safelogin&s=add_ssh_limit',{ip:ip},function(data){
layer.close(sagelogin.Addview);
if (data.status) {
sagelogin.SSH_White_List();
layer.msg(data.msg,{icon:1});
}else{
layer.msg(data.msg,{icon:2});
}
});
},
// SSH日志管理
SSH_Defense_List:function(status){
$('.btnclick input').removeClass('btn-success').addClass('btn-default');
$('.btnclick input').eq(status).addClass('btn-success').removeClass('btn-default');
if (sagelogin.SSHlogList == '') {
$.get('/plugin?action=a&s=get_ssh_errorlogin&name=safelogin',function(data){
sagelogin.SSHlogList = data;
sagelogin.DefenseFor(sagelogin.SSHlogList.defense);
});
}else{
switch(status) {
case 0:
sagelogin.DefenseFor(sagelogin.SSHlogList.defense);
break;
case 1:
sagelogin.DefenseFor(sagelogin.SSHlogList.intrusion);
break;
case 2:
sagelogin.DefenseFor(sagelogin.SSHlogList.success);
break;
}
}
},
// SSH日志渲染模板
DefenseFor:function(data){
var List = '';
$('#whiteListFour').empty();
for (var i = data.length - 1; i >= 0; i--) {
List = List + '<tr><td>'+data[i].address+'</td><td>' + data[i].user + '</td><td style="text-align:right">'+ data[i].date+'</td></tr>'
}
$('#whiteListFour').append(List);
},
// 面板管理
Panel_Admin:function(){
var confirm = layer.confirm('确定清除面板登录限制IP地址?', {
btn: ['确认','取消'] //按钮
}, function(){
$.get('/plugin?action=a&name=safelogin&s=close_panel_limit',function(data) {
if (data.status) {
layer.msg(data.msg,{icon:1});
sagelogin.Panel_White_List();
}else{
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
// 面板白名单——列表
Panel_White_List:function(){
$.get('/plugin?action=a&name=safelogin&s=get_panel_limit','',function(data){
$('#whiteListOne').empty();
var List = '';
if (data.length == 0){
$('.viewOne .status span:eq(0)').html('关闭');
$('.viewOne .glyphicon-pause').show();
$('.viewOne .glyphicon-play').hide();
}else {
$('.viewOne .status span:eq(0)').html('开启');
$('.viewOne .glyphicon-pause').hide();
$('.viewOne .glyphicon-play').show();
}
for (var i = 0; i < data.length; i++) {
List = List + '<tr><td>'+ data[i] +'</td><td style="text-align:right;"><a href="javascript:;" ip-val="'+ data[i] +'" onclick="sagelogin.Panel_Del_White_List(event)" style="color:red">删除</a></td></tr>'
}
$('#whiteListOne').append(List);
});
},
// 面板白名单——删除
Panel_Del_White_List:function(ev){
var ip = ev.currentTarget.getAttribute('ip-val');
var confirm = layer.confirm('确定删除IP['+ ip +']限制地址?', {
btn: ['确认','取消'] //按钮
}, function(){
$.get('/plugin?action=a&name=safelogin&s=remove_ssh_limit',{ip:ip},function(data){
if (data.status) {
sagelogin.Panel_White_List();
layer.msg(data.msg,{icon:1});
}else {
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
// 面板白名单——添加
Panel_Add_White_List:function(ip){
$.post('/plugin?action=a&name=safelogin&s=add_panel_limit', {ip: ip}, function(data) {
layer.close(sagelogin.Addview);
if (data.status) {
sagelogin.Panel_White_List();
layer.msg(data.msg,{icon:1});
}else{
layer.msg(data.msg,{icon:2});
}
});
},
// 面板日志——列表
Panel_journal:function(){
var index = layer.load(0, {shade: false});
$.get('/plugin?action=a&name=safelogin&s=get_login_log',function(data){
$('#whiteListTwo').empty();
var List = '';
sagelogin.PanelLogList = data;
for (var i = sagelogin.PanelLogList.length - 1; i >= 0; i--) {
List = List + '<tr><td>'+ sagelogin.PanelLogList[i].log +'</td><td style="text-align:right;">'+ sagelogin.PanelLogList[i].addtime +'</tr>';
}
$('#whiteListTwo').append(List);
layer.close(index);
});
},
// IP正则:192.168.1.0/24
CheckIP:function(ip) {
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\/\d{1,2})?$/;
return reg.test(ip);
},
CheckIPTwo:function(ip) {
var reg = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/gi;
return reg.test(ip);
},
// 添加表单效验
addViewVul:function(status){
var ip = $('.addViewVul');
if (status) {
console.log(sagelogin.CheckIP(ip.val()));
if(sagelogin.CheckIPTwo(ip.val())){
ip.addClass('correct').removeClass('error');
return true;
}else {
ip.addClass('error').removeClass('correct');
return false;
}
}else{
if(sagelogin.CheckIP(ip.val())){
ip.addClass('correct').removeClass('error');
return true;
}else {
ip.addClass('error').removeClass('correct');
return false;
}
}
},
// 添加界面
Add_view:function(title,status){
var _this = this;
var text = ''
var statuss = true;
if (status) {
text = '';
statuss = true;
}else{
text = '<p style="color:red;margin: 5px 0px 0px 67px;font-size: 14px;">支持IP段,如:192.168.1.0/24</p>';
statuss = false;
}
sagelogin.Addview = layer.open({
type: 1,
title: title,
shadeClose: true,
shade: 0.1,
area: ['380px', '200px'],
btn:['确定','取消'],
content:'<div class="Add_view"><label>IP地址:</label><input class="addViewVul bt-input-text" onchange="sagelogin.addViewVul('+ statuss +')" type="text">'+ text +'</div>',
yes:function(){
if (sagelogin.addViewVul(statuss)) {
if(status){
sagelogin.Panel_Add_White_List($('.addViewVul').val());
}else{
sagelogin.SSH_Add_White_List($('.addViewVul').val());
}
}else{
layer.msg('请输入合法的IP地址',{icon:2})
}
},
btn2:function(){
layer.close(sagelogin.Addview);
}
});
$('.addViewVul').focus();
}
}
</script>
+229
View File
@@ -0,0 +1,229 @@
# coding:utf-8
import sys
import io
import os
import time
sys.path.append(os.getcwd() + "/class/core")
import public
def checkMyCnf():
# 处理MySQL配置文件
import os
confFile = '/etc/my.cnf'
if os.path.exists(confFile):
conf = readFile(confFile)
if len(conf) > 100:
return True
versionFile = '/www/server/mysql/version.pl'
if not os.path.exists(versionFile):
return False
versions = ['5.1', '5.5', '5.6', '5.7', 'AliSQL']
version = readFile(versionFile)
for key in versions:
if key in version:
version = key
break
shellStr = '''
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
CN='125.88.182.172'
HK='download.bt.cn'
HK2='103.224.251.67'
US='174.139.221.74'
sleep 0.5;
CN_PING=`ping -c 1 -w 1 $CN|grep time=|awk '{print $7}'|sed "s/time=//"`
HK_PING=`ping -c 1 -w 1 $HK|grep time=|awk '{print $7}'|sed "s/time=//"`
HK2_PING=`ping -c 1 -w 1 $HK2|grep time=|awk '{print $7}'|sed "s/time=//"`
US_PING=`ping -c 1 -w 1 $US|grep time=|awk '{print $7}'|sed "s/time=//"`
echo "$HK_PING $HK" > ping.pl
echo "$HK2_PING $HK2" >> ping.pl
echo "$US_PING $US" >> ping.pl
echo "$CN_PING $CN" >> ping.pl
nodeAddr=`sort -V ping.pl|sed -n '1p'|awk '{print $2}'`
if [ "$nodeAddr" == "" ];then
nodeAddr=$HK
fi
Download_Url=http://$nodeAddr:5880
MySQL_Opt()
{
MemTotal=`free -m | grep Mem | awk '{print $2}'`
if [[ ${MemTotal} -gt 1024 && ${MemTotal} -lt 2048 ]]; then
sed -i "s#^key_buffer_size.*#key_buffer_size = 32M#" /etc/my.cnf
sed -i "s#^table_open_cache.*#table_open_cache = 128#" /etc/my.cnf
sed -i "s#^sort_buffer_size.*#sort_buffer_size = 768K#" /etc/my.cnf
sed -i "s#^read_buffer_size.*#read_buffer_size = 768K#" /etc/my.cnf
sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 8M#" /etc/my.cnf
sed -i "s#^thread_cache_size.*#thread_cache_size = 16#" /etc/my.cnf
sed -i "s#^query_cache_size.*#query_cache_size = 16M#" /etc/my.cnf
sed -i "s#^tmp_table_size.*#tmp_table_size = 32M#" /etc/my.cnf
sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 128M#" /etc/my.cnf
sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 32M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 2048 && ${MemTotal} -lt 4096 ]]; then
sed -i "s#^key_buffer_size.*#key_buffer_size = 64M#" /etc/my.cnf
sed -i "s#^table_open_cache.*#table_open_cache = 256#" /etc/my.cnf
sed -i "s#^sort_buffer_size.*#sort_buffer_size = 1M#" /etc/my.cnf
sed -i "s#^read_buffer_size.*#read_buffer_size = 1M#" /etc/my.cnf
sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 16M#" /etc/my.cnf
sed -i "s#^thread_cache_size.*#thread_cache_size = 32#" /etc/my.cnf
sed -i "s#^query_cache_size.*#query_cache_size = 32M#" /etc/my.cnf
sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf
sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 256M#" /etc/my.cnf
sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 64M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 4096 && ${MemTotal} -lt 8192 ]]; then
sed -i "s#^key_buffer_size.*#key_buffer_size = 128M#" /etc/my.cnf
sed -i "s#^table_open_cache.*#table_open_cache = 512#" /etc/my.cnf
sed -i "s#^sort_buffer_size.*#sort_buffer_size = 2M#" /etc/my.cnf
sed -i "s#^read_buffer_size.*#read_buffer_size = 2M#" /etc/my.cnf
sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 32M#" /etc/my.cnf
sed -i "s#^thread_cache_size.*#thread_cache_size = 64#" /etc/my.cnf
sed -i "s#^query_cache_size.*#query_cache_size = 64M#" /etc/my.cnf
sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf
sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 512M#" /etc/my.cnf
sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 128M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 8192 && ${MemTotal} -lt 16384 ]]; then
sed -i "s#^key_buffer_size.*#key_buffer_size = 256M#" /etc/my.cnf
sed -i "s#^table_open_cache.*#table_open_cache = 1024#" /etc/my.cnf
sed -i "s#^sort_buffer_size.*#sort_buffer_size = 4M#" /etc/my.cnf
sed -i "s#^read_buffer_size.*#read_buffer_size = 4M#" /etc/my.cnf
sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 64M#" /etc/my.cnf
sed -i "s#^thread_cache_size.*#thread_cache_size = 128#" /etc/my.cnf
sed -i "s#^query_cache_size.*#query_cache_size = 128M#" /etc/my.cnf
sed -i "s#^tmp_table_size.*#tmp_table_size = 128M#" /etc/my.cnf
sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 1024M#" /etc/my.cnf
sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 256M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 16384 && ${MemTotal} -lt 32768 ]]; then
sed -i "s#^key_buffer_size.*#key_buffer_size = 512M#" /etc/my.cnf
sed -i "s#^table_open_cache.*#table_open_cache = 2048#" /etc/my.cnf
sed -i "s#^sort_buffer_size.*#sort_buffer_size = 8M#" /etc/my.cnf
sed -i "s#^read_buffer_size.*#read_buffer_size = 8M#" /etc/my.cnf
sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 128M#" /etc/my.cnf
sed -i "s#^thread_cache_size.*#thread_cache_size = 256#" /etc/my.cnf
sed -i "s#^query_cache_size.*#query_cache_size = 256M#" /etc/my.cnf
sed -i "s#^tmp_table_size.*#tmp_table_size = 256M#" /etc/my.cnf
sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 2048M#" /etc/my.cnf
sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 512M#" /etc/my.cnf
elif [[ ${MemTotal} -ge 32768 ]]; then
sed -i "s#^key_buffer_size.*#key_buffer_size = 1024M#" /etc/my.cnf
sed -i "s#^table_open_cache.*#table_open_cache = 4096#" /etc/my.cnf
sed -i "s#^sort_buffer_size.*#sort_buffer_size = 16M#" /etc/my.cnf
sed -i "s#^read_buffer_size.*#read_buffer_size = 16M#" /etc/my.cnf
sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 256M#" /etc/my.cnf
sed -i "s#^thread_cache_size.*#thread_cache_size = 512#" /etc/my.cnf
sed -i "s#^query_cache_size.*#query_cache_size = 512M#" /etc/my.cnf
sed -i "s#^tmp_table_size.*#tmp_table_size = 512M#" /etc/my.cnf
sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 4096M#" /etc/my.cnf
sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 1024M#" /etc/my.cnf
fi
}
wget -O /etc/my.cnf $Download_Url/install/conf/mysql-%s.conf -T 5
MySQL_Opt
''' % (version,)
# 判断是否迁移目录
if os.path.exists('data/datadir.pl'):
newPath = public.readFile('data/datadir.pl')
mycnf = public.readFile('/etc/my.cnf')
mycnf = mycnf.replace('/www/server/data', newPath)
public.writeFile('/etc/my.cnf', mycnf)
os.system(shellStr)
WriteLog('TYPE_SOFE', 'MYSQL_CHECK_ERR')
return True
def status():
data = public.execShell(
"ps -ef|grep redis |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
def start():
path = os.path.dirname(os.getcwd())
cmd = path + "/redis/bin/redis-server"
cmd = cmd + " " + path + "/redis/redis.conf"
data = public.execShell(cmd)
if data[0] == '':
return 'ok'
return 'fail'
def stop():
data = public.execShell(
"ps -ef|grep redis |grep -v grep |grep -v python |awk '{print $2}' | xargs kill -9")
if data[0] == '':
return 'ok'
return 'fail'
def restart():
return 'ok'
def reload():
return 'ok'
def runInfo():
path = os.path.dirname(os.getcwd())
cmd = path + "/redis/bin/redis-cli info"
data = public.execShell(cmd)[0]
res = [
'tcp_port',
'uptime_in_days', # 已运行天数
'connected_clients', # 连接的客户端数量
'used_memory', # Redis已分配的内存总量
'used_memory_rss', # Redis占用的系统内存总量
'used_memory_peak', # Redis所用内存的高峰值
'mem_fragmentation_ratio', # 内存碎片比率
'total_connections_received', # 运行以来连接过的客户端的总数量
'total_commands_processed', # 运行以来执行过的命令的总数量
'instantaneous_ops_per_sec', # 服务器每秒钟执行的命令数量
'keyspace_hits', # 查找数据库键成功的次数
'keyspace_misses', # 查找数据库键失败的次数
'latest_fork_usec' # 最近一次 fork() 操作耗费的毫秒数
]
data = data.split("\n")
result = {}
for d in data:
if len(d) < 3:
continue
t = d.strip().split(':')
if not t[0] in res:
continue
result[t[0]] = t[1]
return public.getJson(result)
def getConf():
path = os.path.dirname(os.getcwd()) + "/redis/redis.conf"
return path
if __name__ == "__main__":
func = sys.argv[1]
if func == 'run_info':
print runInfo()
elif func == 'conf':
print getConf()
elif func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
+17
View File
@@ -0,0 +1,17 @@
{
"title":"MySQL",
"tip":"soft",
"name":"mysql",
"type":"运行环境",
"ps":"MySQL是一种关系数据库管理系统!",
"versions":["5.5"],
"updates":["5.5"],
"shell":"install.sh",
"checks":"/www/server/panel/plugin/safelogin",
"author":"midoks",
"home":"http://www.bt.cn/bbs",
"date":"2017-11-24",
"default":true,
"display":1,
"pid": "1"
}
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
install_tmp='/tmp/bt_install.pl'
public_file=/www/server/panel/install/public.sh
if [ ! -f $public_file ];then
wget -O $public_file http://download.bt.cn/install/public.sh -T 5;
fi
. $public_file
download_Url=$NODE_URL
Install_safelogin()
{
mkdir -p /www/server/panel/plugin/safelogin
echo '正在安装脚本文件...' > $install_tmp
wget -O /www/server/panel/plugin/safelogin/safelogin_main.py $download_Url/install/lib/plugin/safelogin/safelogin_main.py -T 5
wget -O /www/server/panel/plugin/safelogin/index.html $download_Url/install/lib/plugin/safelogin/index.html -T 5
wget -O /www/server/panel/plugin/safelogin/info.json $download_Url/install/lib/plugin/safelogin/info.json -T 5
wget -O /www/server/panel/plugin/safelogin/icon.png $download_Url/install/lib/plugin/safelogin/icon.png -T 5
echo '安装完成' > $install_tmp
}
Uninstall_safelogin()
{
chattr -i /www/server/panel/plugin/safelogin/token.pl
rm -f /www/server/panel/data/limitip.conf
sed -i "/ALL/d" /etc/hosts.deny
rm -rf /www/server/panel/plugin/safelogin
}
action=$1
host=$2;
if [ "${1}" == 'install' ];then
Install_safelogin
else
Uninstall_safelogin
fi
+441
View File
@@ -0,0 +1,441 @@
function selectChange() {
$("#SelectVersion,#selectVer").change(function() {
var info = $(this).val();
var name = info.split(" ")[0];
var version = info.split(" ")[1];
max = 64
msg = "64M"
if (name == 'mysql') {
memSize = getCookie('memSize');
switch (version) {
case '5.1':
max = 256;
msg = '256M';
break;
case '8.0':
max = 5200;
msg = '6GB';
break;
case '5.7':
max = 1500;
msg = '2GB';
break;
case '5.6':
max = 800;
msg = '1GB';
break;
case 'AliSQL':
max = 800;
msg = '1GB';
break;
case 'mariadb_10.0':
max = 800;
msg = '1GB';
break;
case 'mariadb_10.1':
max = 1500;
msg = '2GB';
break;
}
if (memSize < max) {
layer.msg(lan.bt.insatll_mem.replace('{1}', msg).replace('{2}', version), { icon: 5 });
}
}
});
}
//设置二进制日志
function SetBinLog() {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: 0.3 });
$.post('/database?action=BinLog', "", function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
mysqlLog();
});
}
//清空日志
function closeMySqlLog() {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: 0.3 });
$.post('/database?action=GetErrorLog', "close=1", function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
mysqlLog();
});
}
//数据库端口
function changeMySQLPort(act) {
if (act != undefined) {
layer.confirm(lan.soft.mysql_port_title, { closeBtn: 2, icon: 3 }, function() {
var port = $("#dataport").val();
var data = 'port=' + port;
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/database?action=SetMySQLPort', data, function(rdata) {
layer.close(loadT)
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
});
});
return;
}
$.post('/database?action=GetMySQLInfo', '', function(rdata) {
var LimitCon = '<p class="conf_p">\
<input id="dataport" class="phpUploadLimit bt-input-text mr20" type="number" value="' + rdata.port + '" name="dataport">\
<button style="margin-top: -1px;" class="btn btn-success btn-sm" onclick="changeMySQLPort(1)">' + lan.public.edit + '</button>\
</p>';
$(".soft-man-con").html(LimitCon);
});
}
//软件切换版本
function softChangeVer(name, version) {
if (name == "mysqld") name = "mysql";
var veropt = version.split("|");
var SelectVersion = '';
for (var i = 0; i < veropt.length; i++) {
SelectVersion += '<option>' + name + ' ' + veropt[i] + '</option>';
}
var body = "<div class='ver line'><span class='tname'>" + lan.soft.select_version + "</span><select id='selectVer' class='bt-input-text mr20' name='phpVersion' style='width:160px'>";
body += SelectVersion + '</select><button class="btn btn-success btn-sm">' + lan.soft.version_to + '</button></div>';
if (name == 'mysql') {
body += "<ul class='help-info-text c7 ptb15'><li style='color:red;'>" + lan.soft.mysql_f + "</li></ul>"
}
$(".soft-man-con").html(body);
$(".btn-success").click(function() {
var ver = $("#selectVer").val();
oneInstall(name, ver.split(" ")[1]);
});
selectChange();
}
//设置MySQL配置参数
function SetMySQLConf() {
$.post('/system?action=GetMemInfo', '', function(memInfo) {
//var memSize = memInfo['memTotal'];
//var setSize = parseInt($("input[name='memSize']").val());
//if(memSize < setSize){
// var msg = lan.soft.mysql_set_err.replace('{1}',memSize).replace('{2}',setSize);
// layer.msg(msg,{icon:2,time:5000});
// return;
//}
var query_cache_size = parseInt($("input[name='query_cache_size']").val());
var query_cache_type = 0;
if (query_cache_size > 0) {
query_cache_type = 1;
}
var data = {
key_buffer_size: parseInt($("input[name='key_buffer_size']").val()),
query_cache_size: query_cache_size,
query_cache_type: query_cache_type,
tmp_table_size: parseInt($("input[name='tmp_table_size']").val()),
max_heap_table_size: parseInt($("input[name='tmp_table_size']").val()),
innodb_buffer_pool_size: parseInt($("input[name='innodb_buffer_pool_size']").val()),
innodb_log_buffer_size: parseInt($("input[name='innodb_log_buffer_size']").val()),
sort_buffer_size: parseInt($("input[name='sort_buffer_size']").val()),
read_buffer_size: parseInt($("input[name='read_buffer_size']").val()),
read_rnd_buffer_size: parseInt($("input[name='read_rnd_buffer_size']").val()),
join_buffer_size: parseInt($("input[name='join_buffer_size']").val()),
thread_stack: parseInt($("input[name='thread_stack']").val()),
binlog_cache_size: parseInt($("input[name='binlog_cache_size']").val()),
thread_cache_size: parseInt($("input[name='thread_cache_size']").val()),
table_open_cache: parseInt($("input[name='table_open_cache']").val()),
max_connections: parseInt($("input[name='max_connections']").val())
};
$.post('/database?action=SetDbConf', data, function(rdata) {
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
})
}
//MySQL内存优化方案
function MySQLMemOpt(opt) {
var query_size = parseInt($("input[name='query_cache_size']").val());
switch (opt) {
case '1':
$("input[name='key_buffer_size']").val(128);
if (query_size) $("input[name='query_cache_size']").val(64);
$("input[name='tmp_table_size']").val(64);
$("input[name='innodb_buffer_pool_size']").val(256);
$("input[name='sort_buffer_size']").val(768);
$("input[name='read_buffer_size']").val(768);
$("input[name='read_rnd_buffer_size']").val(512);
$("input[name='join_buffer_size']").val(1024);
$("input[name='thread_stack']").val(256);
$("input[name='binlog_cache_size']").val(64);
$("input[name='thread_cache_size']").val(64);
$("input[name='table_open_cache']").val(128);
$("input[name='max_connections']").val(100);
break;
case '2':
$("input[name='key_buffer_size']").val(256);
if (query_size) $("input[name='query_cache_size']").val(128);
$("input[name='tmp_table_size']").val(384);
$("input[name='innodb_buffer_pool_size']").val(384);
$("input[name='sort_buffer_size']").val(768);
$("input[name='read_buffer_size']").val(768);
$("input[name='read_rnd_buffer_size']").val(512);
$("input[name='join_buffer_size']").val(2048);
$("input[name='thread_stack']").val(256);
$("input[name='binlog_cache_size']").val(64);
$("input[name='thread_cache_size']").val(96);
$("input[name='table_open_cache']").val(192);
$("input[name='max_connections']").val(200);
break;
case '3':
$("input[name='key_buffer_size']").val(384);
if (query_size) $("input[name='query_cache_size']").val(192);
$("input[name='tmp_table_size']").val(512);
$("input[name='innodb_buffer_pool_size']").val(512);
$("input[name='sort_buffer_size']").val(1024);
$("input[name='read_buffer_size']").val(1024);
$("input[name='read_rnd_buffer_size']").val(768);
$("input[name='join_buffer_size']").val(2048);
$("input[name='thread_stack']").val(256);
$("input[name='binlog_cache_size']").val(128);
$("input[name='thread_cache_size']").val(128);
$("input[name='table_open_cache']").val(384);
$("input[name='max_connections']").val(300);
break;
case '4':
$("input[name='key_buffer_size']").val(512);
if (query_size) $("input[name='query_cache_size']").val(256);
$("input[name='tmp_table_size']").val(1024);
$("input[name='innodb_buffer_pool_size']").val(1024);
$("input[name='sort_buffer_size']").val(2048);
$("input[name='read_buffer_size']").val(2048);
$("input[name='read_rnd_buffer_size']").val(1024);
$("input[name='join_buffer_size']").val(4096);
$("input[name='thread_stack']").val(384);
$("input[name='binlog_cache_size']").val(192);
$("input[name='thread_cache_size']").val(192);
$("input[name='table_open_cache']").val(1024);
$("input[name='max_connections']").val(400);
break;
case '5':
$("input[name='key_buffer_size']").val(1024);
if (query_size) $("input[name='query_cache_size']").val(384);
$("input[name='tmp_table_size']").val(2048);
$("input[name='innodb_buffer_pool_size']").val(4096);
$("input[name='sort_buffer_size']").val(4096);
$("input[name='read_buffer_size']").val(4096);
$("input[name='read_rnd_buffer_size']").val(2048);
$("input[name='join_buffer_size']").val(8192);
$("input[name='thread_stack']").val(512);
$("input[name='binlog_cache_size']").val(256);
$("input[name='thread_cache_size']").val(256);
$("input[name='table_open_cache']").val(2048);
$("input[name='max_connections']").val(500);
break;
}
}
//重启MySQL
function ReBootMySqld() {
var loadT = layer.msg(lan.get('service_the', [lan.bt.restart, 'MySQLd']), { icon: 16, time: 0, shade: 0.3 });
$.post('/system?action=ServiceAdmin', 'name=mysqld&type=restart', function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
}
//计算MySQL内存开销
function ComMySqlMem() {
var key_buffer_size = parseInt($("input[name='key_buffer_size']").val());
var query_cache_size = parseInt($("input[name='query_cache_size']").val());
var tmp_table_size = parseInt($("input[name='tmp_table_size']").val());
var innodb_buffer_pool_size = parseInt($("input[name='innodb_buffer_pool_size']").val());
var innodb_additional_mem_pool_size = parseInt($("input[name='innodb_additional_mem_pool_size']").val());
var innodb_log_buffer_size = parseInt($("input[name='innodb_log_buffer_size']").val());
var sort_buffer_size = $("input[name='sort_buffer_size']").val() / 1024;
var read_buffer_size = $("input[name='read_buffer_size']").val() / 1024;
var read_rnd_buffer_size = $("input[name='read_rnd_buffer_size']").val() / 1024;
var join_buffer_size = $("input[name='join_buffer_size']").val() / 1024;
var thread_stack = $("input[name='thread_stack']").val() / 1024;
var binlog_cache_size = $("input[name='binlog_cache_size']").val() / 1024;
var max_connections = $("input[name='max_connections']").val();
var a = key_buffer_size + query_cache_size + tmp_table_size + innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size
var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size
var memSize = a + max_connections * b
$("input[name='memSize']").val(memSize.toFixed(2));
}
//数据库存储信置
function changeMySQLDataPath(act) {
if (act != undefined) {
layer.confirm(lan.soft.mysql_to_msg, { closeBtn: 2, icon: 3 }, function() {
var datadir = $("#datadir").val();
var data = 'datadir=' + datadir;
var loadT = layer.msg(lan.soft.mysql_to_msg1, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/database?action=SetDataDir', data, function(rdata) {
layer.close(loadT)
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
});
});
return;
}
$.post('/database?action=GetMySQLInfo', '', function(rdata) {
var LimitCon = '<p class="conf_p">\
<input id="datadir" class="phpUploadLimit bt-input-text mr5" style="width:350px;" type="text" value="' + rdata.datadir + '" name="datadir">\
<span onclick="ChangePath(\'datadir\')" class="glyphicon glyphicon-folder-open cursor mr20" style="width:auto"></span><button class="btn btn-success btn-sm" onclick="changeMySQLDataPath(1)">' + lan.soft.mysql_to + '</button>\
</p>';
$(".soft-man-con").html(LimitCon);
});
}
//MySQL-Slow日志
function mysqlSlowLog() {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/database?action=GetSlowLogs', {}, function(logs) {
layer.close(loadT);
if (logs.status !== true) {
logs.msg = '';
}
if (logs.msg == '') logs.msg = '当前没有慢日志.';
var phpCon = '<textarea readonly="" style="margin: 0px;width: 500px;height: 520px;background-color: #333;color:#fff; padding:0 5px" id="error_log">' + logs.msg + '</textarea>';
$(".soft-man-con").html(phpCon);
var ob = document.getElementById('error_log');
ob.scrollTop = ob.scrollHeight;
});
}
//数据库日志
function mysqlLog(act) {
//获取二进制日志相关信息
$.post('/database?action=BinLog', "status=1", function(rdata) {
var limitCon = '<p class="conf_p">\
<span class="f14 c6 mr20">' + lan.soft.mysql_log_bin + ' </span><span class="f14 c6 mr20">' + ToSize(rdata.msg) + '</span>\
<button class="btn btn-success btn-xs va0" onclick="SetBinLog();">' + (rdata.status ? lan.soft.off : lan.soft.on) + '</button>\
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">' + lan.soft.mysql_log_err + '<button class="btn btn-default btn-xs" style="float:right;" onclick="closeMySqlLog();">' + lan.soft.mysql_log_close + '</button></p>\
<textarea readonly style="margin: 0px;width: 515px;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
</p>'
$(".soft-man-con").html(limitCon);
//获取错误日志
$.post('/database?action=GetErrorLog', "", function(error_body) {
if (error_body.status === false) {
layer.msg(error_body.msg, { icon: 5 });
error_body = lan.soft.mysql_log_ps1;
}
if (error_body == "") error_body = lan.soft.mysql_log_ps1;
$("#error_log").text(error_body);
var ob = document.getElementById('error_log');
ob.scrollTop = ob.scrollHeight;
});
});
}
//取数据库运行状态
function mysqlRunStatus() {
$.post('/database?action=GetRunStatus', "", function(rdata) {
var cache_size = ((parseInt(rdata.Qcache_hits) / (parseInt(rdata.Qcache_hits) + parseInt(rdata.Qcache_inserts))) * 100).toFixed(2) + '%';
if (cache_size == 'NaN%') cache_size = 'OFF';
var Con = '<div class="divtable"><table class="table table-hover table-bordered" style="width: 490px;margin-bottom:10px;background-color:#fafafa">\
<tbody>\
<tr><th>' + lan.soft.mysql_status_title1 + '</th><td>' + getLocalTime(rdata.Run) + '</td><th>' + lan.soft.mysql_status_title5 + '</th><td>' + parseInt(rdata.Questions / rdata.Uptime) + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title2 + '</th><td>' + rdata.Connections + '</td><th>' + lan.soft.mysql_status_title6 + '</th><td>' + parseInt((parseInt(rdata.Com_commit) + parseInt(rdata.Com_rollback)) / rdata.Uptime) + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title3 + '</th><td>' + ToSize(rdata.Bytes_sent) + '</td><th>' + lan.soft.mysql_status_title7 + '</th><td>' + rdata.File + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title4 + '</th><td>' + ToSize(rdata.Bytes_received) + '</td><th>' + lan.soft.mysql_status_title8 + '</th><td>' + rdata.Position + '</td></tr>\
</tbody>\
</table>\
<table class="table table-hover table-bordered" style="width: 490px;">\
<thead style="display:none;"><th></th><th></th><th></th><th></th></thead>\
<tbody>\
<tr><th>' + lan.soft.mysql_status_title9 + '</th><td>' + rdata.Threads_running + '/' + rdata.Max_used_connections + '</td><td colspan="2">' + lan.soft.mysql_status_ps1 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title10 + '</th><td>' + ((1 - rdata.Threads_created / rdata.Connections) * 100).toFixed(2) + '%</td><td colspan="2">' + lan.soft.mysql_status_ps2 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title11 + '</th><td>' + ((1 - rdata.Key_reads / rdata.Key_read_requests) * 100).toFixed(2) + '%</td><td colspan="2">' + lan.soft.mysql_status_ps3 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title12 + '</th><td>' + ((1 - rdata.Innodb_buffer_pool_reads / rdata.Innodb_buffer_pool_read_requests) * 100).toFixed(2) + '%</td><td colspan="2">' + lan.soft.mysql_status_ps4 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title13 + '</th><td>' + cache_size + '</td><td colspan="2">' + lan.soft.mysql_status_ps5 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title14 + '</th><td>' + ((rdata.Created_tmp_disk_tables / rdata.Created_tmp_tables) * 100).toFixed(2) + '%</td><td colspan="2">' + lan.soft.mysql_status_ps6 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title15 + '</th><td>' + rdata.Open_tables + '</td><td colspan="2">' + lan.soft.mysql_status_ps7 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title16 + '</th><td>' + rdata.Select_full_join + '</td><td colspan="2">' + lan.soft.mysql_status_ps8 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title17 + '</th><td>' + rdata.Select_range_check + '</td><td colspan="2">' + lan.soft.mysql_status_ps9 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title18 + '</th><td>' + rdata.Sort_merge_passes + '</td><td colspan="2">' + lan.soft.mysql_status_ps10 + '</td></tr>\
<tr><th>' + lan.soft.mysql_status_title19 + '</th><td>' + rdata.Table_locks_waited + '</td><td colspan="2">' + lan.soft.mysql_status_ps11 + '</td></tr>\
<tbody>\
</table></div>'
$(".soft-man-con").html(Con);
});
}
//数据库配置状态
function mysqlStatus() {
//获取MySQL配置
$.post('/database?action=GetDbStatus', "", function(rdata) {
var key_buffer_size = ToSizeM(rdata.mem.key_buffer_size)
var query_cache_size = ToSizeM(rdata.mem.query_cache_size)
var tmp_table_size = ToSizeM(rdata.mem.tmp_table_size)
var innodb_buffer_pool_size = ToSizeM(rdata.mem.innodb_buffer_pool_size)
var innodb_additional_mem_pool_size = ToSizeM(rdata.mem.innodb_additional_mem_pool_size)
var innodb_log_buffer_size = ToSizeM(rdata.mem.innodb_log_buffer_size)
var sort_buffer_size = ToSizeM(rdata.mem.sort_buffer_size)
var read_buffer_size = ToSizeM(rdata.mem.read_buffer_size)
var read_rnd_buffer_size = ToSizeM(rdata.mem.read_rnd_buffer_size)
var join_buffer_size = ToSizeM(rdata.mem.join_buffer_size)
var thread_stack = ToSizeM(rdata.mem.thread_stack)
var binlog_cache_size = ToSizeM(rdata.mem.binlog_cache_size)
var a = key_buffer_size + query_cache_size + tmp_table_size + innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size
var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size
var memSize = a + rdata.mem.max_connections * b
var memCon = '<div class="conf_p" style="margin-bottom:0">\
<div style="border-bottom:#ccc 1px solid;padding-bottom:10px;margin-bottom:10px"><span><b>' + lan.soft.mysql_set_msg + '</b></span>\
<select class="bt-input-text" name="mysql_set" style="margin-left:-4px">\
<option value="0">' + lan.soft.mysql_set_select + '</option>\
<option value="1">1-2GB</option>\
<option value="2">2-4GB</option>\
<option value="3">4-8GB</option>\
<option value="4">8-16GB</option>\
<option value="5">16-32GB</option>\
</select>\
<span>' + lan.soft.mysql_set_maxmem + ': </span><input style="width:70px;background-color:#eee;" class="bt-input-text mr5" name="memSize" type="text" value="' + memSize.toFixed(2) + '" readonly>MB\
</div>\
<p><span>key_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="key_buffer_size" value="' + key_buffer_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_key_buffer_size + '</font></p>\
<p><span>query_cache_size</span><input style="width: 70px;" class="bt-input-text mr5" name="query_cache_size" value="' + query_cache_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_query_cache_size + '</font></p>\
<p><span>tmp_table_size</span><input style="width: 70px;" class="bt-input-text mr5" name="tmp_table_size" value="' + tmp_table_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_tmp_table_size + '</font></p>\
<p><span>innodb_buffer_pool_size</span><input style="width: 70px;" class="bt-input-text mr5" name="innodb_buffer_pool_size" value="' + innodb_buffer_pool_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_innodb_buffer_pool_size + '</font></p>\
<p><span>innodb_log_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="innodb_log_buffer_size" value="' + innodb_log_buffer_size + '" type="number">MB, <font>' + lan.soft.mysql_set_innodb_log_buffer_size + '</font></p>\
<p style="display:none;"><span>innodb_additional_mem_pool_size</span><input style="width: 70px;" class="bt-input-text mr5" name="innodb_additional_mem_pool_size" value="' + innodb_additional_mem_pool_size + '" type="number" >MB</p>\
<p><span>sort_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="sort_buffer_size" value="' + (sort_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_sort_buffer_size + '</font></p>\
<p><span>read_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="read_buffer_size" value="' + (read_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_read_buffer_size + ' </font></p>\
<p><span>read_rnd_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="read_rnd_buffer_size" value="' + (read_rnd_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_read_rnd_buffer_size + ' </font></p>\
<p><span>join_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="join_buffer_size" value="' + (join_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_join_buffer_size + '</font></p>\
<p><span>thread_stack</span><input style="width: 70px;" class="bt-input-text mr5" name="thread_stack" value="' + (thread_stack * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_thread_stack + '</font></p>\
<p><span>binlog_cache_size</span><input style="width: 70px;" class="bt-input-text mr5" name="binlog_cache_size" value="' + (binlog_cache_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_binlog_cache_size + '</font></p>\
<p><span>thread_cache_size</span><input style="width: 70px;" class="bt-input-text mr5" name="thread_cache_size" value="' + rdata.mem.thread_cache_size + '" type="number" ><font> ' + lan.soft.mysql_set_thread_cache_size + '</font></p>\
<p><span>table_open_cache</span><input style="width: 70px;" class="bt-input-text mr5" name="table_open_cache" value="' + rdata.mem.table_open_cache + '" type="number" > <font>' + lan.soft.mysql_set_table_open_cache + '</font></p>\
<p><span>max_connections</span><input style="width: 70px;" class="bt-input-text mr5" name="max_connections" value="' + rdata.mem.max_connections + '" type="number" ><font> ' + lan.soft.mysql_set_max_connections + '</font></p>\
<div style="margin-top:10px; padding-right:15px" class="text-right"><button class="btn btn-success btn-sm mr5" onclick="ReBootMySqld()">' + lan.soft.mysql_set_restart + '</button><button class="btn btn-success btn-sm" onclick="SetMySQLConf()">' + lan.public.save + '</button></div>\
</div>'
$(".soft-man-con").html(memCon);
$(".conf_p input[name*='size'],.conf_p input[name='max_connections'],.conf_p input[name='thread_stack']").change(function() {
ComMySqlMem();
});
$(".conf_p select[name='mysql_set']").change(function() {
MySQLMemOpt($(this).val());
ComMySqlMem();
});
});
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

+550
View File
@@ -0,0 +1,550 @@
<style>
/*危险按钮*/
.bts-danger:hover{
color: #fff;
background-color: #c9302c;
border-color: #ac2925;
}
#whiteList a{
color: red;
}
/*弹窗*/
.Add_view{
height: 100px;
padding-left: 35px;
padding-top: 35px;
}
.Add_view label{
margin-right: 10px;
font-size: 15px;
font-weight: 100;
}
.Add_view input{
width: 230px;
}
.Add_view .error{
border: 1px solid red;
}
.Add_view .correct{
border: 1px solid #20a53a;
}
/*日志管理*/
.btnTitle{
font-weight: 100;
font-size: 16px;
line-height: 34px;
height: 34px;
margin-right: 15px;
position: relative;
top: 2px;
}
.whiteList-table{
margin-top: 10px;
}
/*登录日志表单*/
.viewTwo .whiteList-table{
overflow-x: hidden;
height: 500px;
}
.maks{
background: rgba(39, 39, 39, 0.4);
position: absolute;
width: 700px;
height: 555px;
z-index: 999;
overflow: hidden;
}
.boxshow{
position: absolute;
height: 150px;
width: 400px;
margin-left: -200px;
margin-top: -75px;
left: 50%;
top: 50%;
z-index: 1000;
background: #fff;
padding: 25px 20px;
overflow: hidden;
}
.btPayment {
float: left;
padding: 8px 10px;
width: 190px;
height: 100px;
line-height: 33px;
text-align: center;
border-left: 1px solid #ececec;
}
.btPayment .t2{
display: block;
width: 100%;
text-align: center;
font-size: 16px;
margin-bottom: 5px;
}
.btPayment .price{
color: #20A53A;
font-size: 22px;
margin: 0 5px;
}
.bt-form{
overflow: hidden;
}
.boxtext{
line-height: 32px;
margin-top: -17px;
text-align: center;
border-bottom: #eee 1px solid;
height: 39px;
font-size: 14px;
}
</style>
<div class="maks" style="display: none"></div>
<div class="boxshow" style="display: none;">
<div>
<div class="boxtext">
<span>未开通此服务,如需使用请开通企业运维版。</span>
</div>
<div class="btvipinfo" style="width: 170px;padding-left: 20px">
<p style="height: 25px">1、一对一运维人员对接</p>
<p style="height: 25px">2、提供每月3次运维服务</p>
<p style="height: 25px">3、双重安全隔离登录</p>
</div>
<div class="btPayment">
<span class="t2">企业运维版<span class="price">98</span>元/月</span>
<button class="btn btn-success btn-sm" style="width:80%" onclick="window.open('https://www.bt.cn/admin/index.html')">立即开通</button>
</div>
</div>
</div>
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw">密钥</p>
<p>面板设置</p>
<p>面板登录日志</p>
<p>SSH设置</p>
<p>SSH日志管理</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con viewZoo">
<p class="status" style="margin-top:10px;margin-left:10px;height: 80px;margin-bottom:15px;">
<span style="float:left;margin-top:-5px">密钥:</span>
<textarea class="bt-input-text" name="token" readonly="readonly" style="background-color: #eee;width:400px;height:80px;padding: 8px 15px;" placeholder="密钥已隐藏..."></textarea>
</p>
<input type="button" class="btn btn-success btn-sm" name="ButtonShow" style="margin-left:52px;width:100px" onclick="sagelogin.tokenShow()" value="显示密钥" />
<ul style="margin: 15px 5px;padding-left: 70px;list-style-type: disc;line-height: 25px;">
<li>宝塔企业运维后台连接您的服务器需要此密钥,请妥善记录并保存</li>
<li>一但密钥丢失,可能导致您无法登录服务器</li>
</ul>
</div>
<div class="soft-man-con viewOne" style="display: none;">
<p class="status">当前状态:
<span>开启</span>
<span style="color: #20a53a; margin-left: 3px;" class="glyphicon glyphicon glyphicon-play"></span>
<span style="color: red; margin-left: 3px; display: none" class="glyphicon glyphicon-pause"></span>
</p>
<div class="sfm-opt">
<button class="btn btn-default btn-sm bts-danger" onclick="sagelogin.Panel_Admin()">清除面板登录限制IP</button>
<button class="btn btn-default btn-sm bts-safety" onclick="sagelogin.Add_view('面板白名单',true)">添加白名单</button>
</div>
<div class="whiteList-table divtable" style="overflow-x: hidden;height: 420px">
<table class="table table-hover" style="max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>IP地址</th>
<th style="text-align: right;">操作</th>
</tr>
</thead>
<tbody id="whiteListOne"></tbody>
</table>
</div>
</div>
<div class="soft-man-con viewTwo" style="display: none">
<div class="whiteList-table divtable">
<table class="table table-hover" style=" max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>操作记录</th>
<th>操作时间</th>
</tr>
</thead>
<tbody id="whiteListTwo"></tbody>
</table>
</div>
</div>
<div class="soft-man-con viewThree" style="display: none">
<p class="status">当前状态:
<span>开启</span>
<span style="color: #20a53a; margin-left: 3px;" class="glyphicon glyphicon glyphicon-play">
</span>
<span style="color: red; margin-left: 3px; display: none" class="glyphicon glyphicon-pause"></span>
</p>
<div class="sfm-opt">
<button class="btn btn-default btn-sm bts-danger" onclick="sagelogin.Panel_Admin()">清除SSH登录限制IP</button>
<button class="btn btn-default btn-sm bts-safety" onclick="sagelogin.Add_view('SSH白名单',false)">添加白名单</button>
</div>
<div class="whiteList-table divtable" style="overflow-x: hidden;height: 420px">
<table class="table table-hover" style="max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>IP地址</th>
<th style="text-align: right;">操作</th>
</tr>
</thead>
<tbody id="whiteListThree"></tbody>
</table>
</div>
</div>
<div class="soft-man-con viewFour" style="display: none">
<div class="btnclick">
<label class="btnTitle">日志分类</label>
<div class="btn-group">
<input type="submit" name="btnOne" class="btn btn-success" onclick="sagelogin.SSH_Defense_List(0)" value="已防御" />
<input type="submit" name="btnTwo" class="btn btn-default" onclick="sagelogin.SSH_Defense_List(1)" value="入侵日志"/>
<input type="submit" name="btnThree" class="btn btn-default" onclick="sagelogin.SSH_Defense_List(2)" value="登录日志"/>
</div>
</div>
<div class="whiteList-table divtable" style="overflow-x: hidden;height: 470px;">
<table class="table table-hover" style="max-height: 380px; overflow: auto;">
<thead>
<tr>
<th>源IP地址</th>
<th>用户</th>
<th style="text-align: right;">登录时间</th>
</tr>
</thead>
<tbody id="whiteListFour"></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script type="javascript/text">
//宝塔安全登录
$(function(){
$(".bt-w-menu p").click(function(){
$(this).addClass("bgw").siblings().removeClass("bgw");
$('.bt-w-con .soft-man-con').hide().eq($(this).index()).show();
switch($(this).index()) {
case 0:
break;
case 1:
sagelogin.Panel_White_List();
break;
case 2:
sagelogin.Panel_journal();
break;
case 3:
sagelogin.SSH_White_List();
break;
case 4:
sagelogin.SSH_Defense_List(0);
break;
}
});
layer.load();
$.get('/plugin?action=a&name=safelogin&s=GetServerInfo',function(data) {
layer.closeAll('loading');
if (data.status) {
$('.boxshow').hide();
$('.maks').hide();
}else{
$('.boxshow').show();
$('.maks').show();
}
});
});
var sagelogin = new Object();
sagelogin = {
Addview:'',
SSHlogList:'',
PanelLogList:'',
// SSH管理
SSH_Admin:function(){
var confirm = layer.confirm('确定清除面板登录限制IP地址?',{icon: 1}, {
btn: ['确认','取消'],
}, function(){
$.get('/plugin?action=a&name=safelogin&s=close_ssh_limit',function(data) {
if (data.status) {
layer.msg(data.msg,{icon:1});
sagelogin.SSH_White_List();
}else{
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
tokenShow:function(){
var inputPwd = layer.open({
type: 1,
title: '验证面板密码',
shadeClose: true,
shade: 0.3,
area: ['380px', '190px'],
btn:['确定','取消'],
content:'<div class="Add_view" style="height:90px"><label>面板密码:</label><input name="panel_pwd" class=" bt-input-text" type="password"></div>',
yes:function(){
var passwordStr = $("input[name='panel_pwd']").val();
var index = layer.load(0, {shade: false});
$.post('/plugin?action=a&name=safelogin&s=GetServerToken',{password:passwordStr},function(token) {
layer.close(index);
if(token.status === false){
layer.msg(token.msg,{icon:2});
return;
}
layer.close(inputPwd);
$("textarea[name='token']").val(token);
});
},
btn2:function(){
layer.close(inputPwd);
}
});
},
// SSH白名单——列表
SSH_White_List:function(){
var index = layer.load(0, {shade: false});
$.get('/plugin?action=a&name=safelogin&s=get_ssh_limit','',function(data){
$('#whiteListThree').empty();
var List = '';
if (data.length == 0){
$('.viewThree .status span:eq(0)').html('关闭');
$('.viewThree .glyphicon-pause').show();
$('.viewThree .glyphicon-play').hide();
}else {
$('.viewThree .status span:eq(0)').html('开启');
$('.viewThree .glyphicon-pause').hide();
$('.viewThree .glyphicon-play').show();
}
for (var i = 0; i < data.length; i++) {
List = List + '<tr><td>'+ data[i] +'</td><td style="text-align:right;"><a href="javascript:;" ip-val="'+ data[i] +'" onclick="sagelogin.SSH_Del_White_List(event)" style="color:red">删除</a></td></tr>'
}
$('#whiteListThree').append(List);
layer.close(index);
});
},
// SSH白名单——删除
SSH_Del_White_List:function(ev){
var ip = ev.currentTarget.getAttribute('ip-val');
var confirm = layer.confirm('确定删除IP['+ ip +']限制地址?', {
btn: ['确认','取消'] //按钮
}, function(){
$.get('/plugin?action=a&name=safelogin&s=remove_ssh_limit',{ip:ip},function(data){
if (data.status) {
sagelogin.SSH_White_List();
layer.msg(data.msg,{icon:1});
}else {
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
// SSH白名单——添加
SSH_Add_White_List:function(ip){
$.post('/plugin?action=a&name=safelogin&s=add_ssh_limit',{ip:ip},function(data){
layer.close(sagelogin.Addview);
if (data.status) {
sagelogin.SSH_White_List();
layer.msg(data.msg,{icon:1});
}else{
layer.msg(data.msg,{icon:2});
}
});
},
// SSH日志管理
SSH_Defense_List:function(status){
$('.btnclick input').removeClass('btn-success').addClass('btn-default');
$('.btnclick input').eq(status).addClass('btn-success').removeClass('btn-default');
if (sagelogin.SSHlogList == '') {
$.get('/plugin?action=a&s=get_ssh_errorlogin&name=safelogin',function(data){
sagelogin.SSHlogList = data;
sagelogin.DefenseFor(sagelogin.SSHlogList.defense);
});
}else{
switch(status) {
case 0:
sagelogin.DefenseFor(sagelogin.SSHlogList.defense);
break;
case 1:
sagelogin.DefenseFor(sagelogin.SSHlogList.intrusion);
break;
case 2:
sagelogin.DefenseFor(sagelogin.SSHlogList.success);
break;
}
}
},
// SSH日志渲染模板
DefenseFor:function(data){
var List = '';
$('#whiteListFour').empty();
for (var i = data.length - 1; i >= 0; i--) {
List = List + '<tr><td>'+data[i].address+'</td><td>' + data[i].user + '</td><td style="text-align:right">'+ data[i].date+'</td></tr>'
}
$('#whiteListFour').append(List);
},
// 面板管理
Panel_Admin:function(){
var confirm = layer.confirm('确定清除面板登录限制IP地址?', {
btn: ['确认','取消'] //按钮
}, function(){
$.get('/plugin?action=a&name=safelogin&s=close_panel_limit',function(data) {
if (data.status) {
layer.msg(data.msg,{icon:1});
sagelogin.Panel_White_List();
}else{
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
// 面板白名单——列表
Panel_White_List:function(){
$.get('/plugin?action=a&name=safelogin&s=get_panel_limit','',function(data){
$('#whiteListOne').empty();
var List = '';
if (data.length == 0){
$('.viewOne .status span:eq(0)').html('关闭');
$('.viewOne .glyphicon-pause').show();
$('.viewOne .glyphicon-play').hide();
}else {
$('.viewOne .status span:eq(0)').html('开启');
$('.viewOne .glyphicon-pause').hide();
$('.viewOne .glyphicon-play').show();
}
for (var i = 0; i < data.length; i++) {
List = List + '<tr><td>'+ data[i] +'</td><td style="text-align:right;"><a href="javascript:;" ip-val="'+ data[i] +'" onclick="sagelogin.Panel_Del_White_List(event)" style="color:red">删除</a></td></tr>'
}
$('#whiteListOne').append(List);
});
},
// 面板白名单——删除
Panel_Del_White_List:function(ev){
var ip = ev.currentTarget.getAttribute('ip-val');
var confirm = layer.confirm('确定删除IP['+ ip +']限制地址?', {
btn: ['确认','取消'] //按钮
}, function(){
$.get('/plugin?action=a&name=safelogin&s=remove_ssh_limit',{ip:ip},function(data){
if (data.status) {
sagelogin.Panel_White_List();
layer.msg(data.msg,{icon:1});
}else {
layer.msg(data.msg,{icon:2});
}
});
}, function(){
layer.close(confirm);
});
},
// 面板白名单——添加
Panel_Add_White_List:function(ip){
$.post('/plugin?action=a&name=safelogin&s=add_panel_limit', {ip: ip}, function(data) {
layer.close(sagelogin.Addview);
if (data.status) {
sagelogin.Panel_White_List();
layer.msg(data.msg,{icon:1});
}else{
layer.msg(data.msg,{icon:2});
}
});
},
// 面板日志——列表
Panel_journal:function(){
var index = layer.load(0, {shade: false});
$.get('/plugin?action=a&name=safelogin&s=get_login_log',function(data){
$('#whiteListTwo').empty();
var List = '';
sagelogin.PanelLogList = data;
for (var i = sagelogin.PanelLogList.length - 1; i >= 0; i--) {
List = List + '<tr><td>'+ sagelogin.PanelLogList[i].log +'</td><td style="text-align:right;">'+ sagelogin.PanelLogList[i].addtime +'</tr>';
}
$('#whiteListTwo').append(List);
layer.close(index);
});
},
// IP正则:192.168.1.0/24
CheckIP:function(ip) {
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\/\d{1,2})?$/;
return reg.test(ip);
},
CheckIPTwo:function(ip) {
var reg = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/gi;
return reg.test(ip);
},
// 添加表单效验
addViewVul:function(status){
var ip = $('.addViewVul');
if (status) {
console.log(sagelogin.CheckIP(ip.val()));
if(sagelogin.CheckIPTwo(ip.val())){
ip.addClass('correct').removeClass('error');
return true;
}else {
ip.addClass('error').removeClass('correct');
return false;
}
}else{
if(sagelogin.CheckIP(ip.val())){
ip.addClass('correct').removeClass('error');
return true;
}else {
ip.addClass('error').removeClass('correct');
return false;
}
}
},
// 添加界面
Add_view:function(title,status){
var _this = this;
var text = ''
var statuss = true;
if (status) {
text = '';
statuss = true;
}else{
text = '<p style="color:red;margin: 5px 0px 0px 67px;font-size: 14px;">支持IP段,如:192.168.1.0/24</p>';
statuss = false;
}
sagelogin.Addview = layer.open({
type: 1,
title: title,
shadeClose: true,
shade: 0.1,
area: ['380px', '200px'],
btn:['确定','取消'],
content:'<div class="Add_view"><label>IP地址:</label><input class="addViewVul bt-input-text" onchange="sagelogin.addViewVul('+ statuss +')" type="text">'+ text +'</div>',
yes:function(){
if (sagelogin.addViewVul(statuss)) {
if(status){
sagelogin.Panel_Add_White_List($('.addViewVul').val());
}else{
sagelogin.SSH_Add_White_List($('.addViewVul').val());
}
}else{
layer.msg('请输入合法的IP地址',{icon:2})
}
},
btn2:function(){
layer.close(sagelogin.Addview);
}
});
$('.addViewVul').focus();
}
}
</script>
+16
View File
@@ -0,0 +1,16 @@
{
"title":"OpenResty",
"tip":"soft",
"name":"openresty",
"type":"其他插件",
"ps":"轻量级,占有内存少,并发能力强",
"shell":"install.sh",
"checks":"server/openresty",
"path":"server/openresty",
"author":"agentzh",
"home":"http://openresty.org",
"date":"2017-11-24",
"pid": "1",
"versions": ["1.11.2", "1.13.6"],
"updates": ["1.11.2.5", "1.13.6.2"]
}
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/bt_install.pl
openrestyDir=${serverPath}/source/openresty
Install_openresty()
{
mkdir -p ${openrestyDir}
echo '正在安装脚本文件...' > $install_tmp
if [ ! -f ${openrestyDir}/openresty-1.13.6.2.tar.gz ];then
wget -O ${openrestyDir}/openresty-1.13.6.2.tar.gz https://openresty.org/download/openresty-1.13.6.2.tar.gz
fi
cd ${openrestyDir} && tar -zxvf openresty-1.13.6.2.tar.gz
cd ${openrestyDir}/openresty* && ./configure --prefix=$serverPath/openresty \
--with-openssl=$serverPath/source/lib/openssl-1.0.2q && make && make install
echo '安装完成' > $install_tmp
}
Uninstall_openresty()
{
rm -rf $serverPath/openresty
echo '卸载完成' > $install_tmp
}
action=$1
host=$2
if [ "${1}" == 'install' ];then
Install_openresty
else
Uninstall_openresty
fi
+262
View File
@@ -0,0 +1,262 @@
//nginx
function nginxSoftMain(name, version) {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.get('/system?action=GetConcifInfo', function(rdata) {
layer.close(loadT);
nameA = rdata['web'];
var status = name == 'nginx' ? '<p onclick="GetNginxStatus()">' + lan.soft.nginx_status + '</p>' : '';
var menu = '';
if (version != undefined || version != '') {
var menu = '<p onclick="softChangeVer(\'' + name + '\',\'' + version + '\')">' + lan.soft.nginx_version + '</p>';
}
var waf = ''
if (name == 'nginx') {
waf = '<p onclick="waf()">' + lan.soft.waf_title + '</p>'
}
var logsPath = (name == 'nginx') ? '/www/wwwlogs/nginx_error.log' : '/www/wwwlogs/error_log';
layer.open({
type: 1,
area: '640px',
title: name + lan.soft.admin,
closeBtn: 2,
shift: 0,
content: '<div class="bt-w-main" style="width:640px;">\
<div class="bt-w-menu">\
<p class="bgw" onclick="service(\'' + name + '\',' + nameA.status + ')">' + lan.soft.web_service + '</p>\
<p onclick="configChange(\'' + name + '\')">' + lan.soft.config_edit + '</p>\
' + waf + '\
' + menu + '\
' + status + '\
<p onclick="showLogs(\'' + logsPath + '\')">错误日志</p>\
</div>\
<div id="webEdit-con" class="bt-w-con pd15" style="height:555px;overflow:auto">\
<div class="soft-man-con"></div>\
</div>\
</div>'
});
service(name, nameA.status);
$(".bt-w-menu p").click(function() {
//var i = $(this).index();
$(this).addClass("bgw").siblings().removeClass("bgw");
});
});
}
//显示指定日志
function showLogs(logPath) {
var loadT = layer.msg(lan.public.the_get, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/ajax?action=GetOpeLogs', { path: logPath }, function(rdata) {
layer.close(loadT);
if (rdata.msg == '') rdata.msg = '当前没有日志!';
var ebody = '<div class="soft-man-con"><textarea readonly="" style="margin: 0px;width: 500px;height: 520px;background-color: #333;color:#fff; padding:0 5px" id="error_log">' + rdata.msg + '</textarea></div>';
$(".soft-man-con").html(ebody);
var ob = document.getElementById('error_log');
ob.scrollTop = ob.scrollHeight;
});
}
//WAF防火墙
function waf() {
var loadT = layer.msg(lan.public.the_get, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.get("/waf?action=GetConfig", function(rdata) {
layer.close(loadT);
if (rdata.status == -1) {
layer.msg(lan.soft.waf_not, { icon: 5, time: 5000 });
return;
}
var whiteList = ""
for (var i = 0; i < rdata.ipWhitelist.length; i++) {
if (rdata.ipWhitelist[i] == "") continue;
whiteList += "<tr><td>" + rdata.ipWhitelist[i] + "</td><td><a href=\"javascript:deleteWafKey('ipWhitelist','" + rdata.ipWhitelist[i] + "');\">" + lan.public.del + "</a></td></tr>";
}
var blackList = ""
for (var i = 0; i < rdata.ipBlocklist.length; i++) {
if (rdata.ipBlocklist[i] == "") continue;
blackList += "<tr><td>" + rdata.ipBlocklist[i] + "</td><td><a href=\"javascript:deleteWafKey('ipBlocklist','" + rdata.ipBlocklist[i] + "');\">" + lan.public.del + "</a></td></tr>";
}
var cc = rdata.CCrate.split('/')
var con = "<div class='wafConf'>\
<div class='wafConf-btn'>\
<span>" + lan.soft.waf_title + "</span><div class='ssh-item'>\
<input class='btswitch btswitch-ios' id='closeWaf' type='checkbox' " + (rdata.status == 1 ? 'checked' : '') + ">\
<label class='btswitch-btn' for='closeWaf' onclick='CloseWaf()'></label>\
</div>\
<div class='pull-right'>\
<button class='btn btn-default btn-sm' onclick='gzEdit()'>" + lan.soft.waf_edit + "</button>\
<button class='btn btn-default btn-sm' onclick='upLimit()'>" + lan.soft.waf_up_title + "</button>\
</div>\
</div>\
<div class='wafConf_checkbox label-input-group ptb10 relative'>\
<input type='checkbox' id='waf_UrlDeny' " + (rdata['UrlDeny'] == 'on' ? 'checked' : '') + " onclick=\"SetWafConfig('UrlDeny','" + (rdata['UrlDeny'] == 'on' ? 'off' : 'on') + "')\" /><label for='waf_UrlDeny'>" + lan.soft.waf_input1 + "</label>\
<input type='checkbox' id='waf_CookieMatch' " + (rdata['CookieMatch'] == 'on' ? 'checked' : '') + " onclick=\"SetWafConfig('CookieMatch','" + (rdata['CookieMatch'] == 'on' ? 'off' : 'on') + "')\" /><label for='waf_CookieMatch'>" + lan.soft.waf_input2 + "</label>\
<input type='checkbox' id='waf_postMatch' " + (rdata['postMatch'] == 'on' ? 'checked' : '') + " onclick=\"SetWafConfig('postMatch','" + (rdata['postMatch'] == 'on' ? 'off' : 'on') + "')\" /><label for='waf_postMatch'>" + lan.soft.waf_input3 + "</label>\
<input type='checkbox' id='waf_CCDeny' " + (rdata['CCDeny'] == 'on' ? 'checked' : '') + " onclick=\"SetWafConfig('CCDeny','" + (rdata['CCDeny'] == 'on' ? 'off' : 'on') + "')\" /><label for='waf_CCDeny'>" + lan.soft.waf_input4 + "</label>\
<input type='checkbox' id='waf_attacklog' " + (rdata['attacklog'] == 'on' ? 'checked' : '') + " onclick=\"SetWafConfig('attacklog','" + (rdata['attacklog'] == 'on' ? 'off' : 'on') + "')\" /><label for='waf_attacklog'>" + lan.soft.waf_input5 + "</label>\
<span class='glyphicon glyphicon-folder-open' style='position: absolute; right: 10px; top: 12px; color: orange;cursor: pointer' onclick='openPath(\"/www/wwwlogs/waf\")'></span>\
</div>\
<div class='wafConf_cc'>\
<span>" + lan.soft.waf_input6 + "</span><input id='CCrate_1' class='bt-input-text' type='number' value='" + cc[0] + "' style='width:80px;margin-right:30px'/>\
<span>" + lan.soft.waf_input7 + "(" + lan.bt.s + ")</span><input id='CCrate_2' class='bt-input-text' type='number' value='" + cc[1] + "' style='width:80px;'/>\
<button onclick=\"SetWafConfig('CCrate','')\" class='btn btn-default btn-sm'>" + lan.public.ok + "</button>\
</div>\
<div class='wafConf_ip'>\
<fieldset>\
<legend>" + lan.soft.waf_input8 + "</legend>\
<input type='text' id='ipWhitelist_val' class='bt-input-text mr5' placeholder='" + lan.soft.waf_ip + "' style='width:175px;' /><button onclick=\"addWafKey('ipWhitelist')\" class='btn btn-default btn-sm'>" + lan.public.add + "</button>\
<div class='table-overflow'><table class='table table-hover'>" + whiteList + "</table></div>\
</fieldset>\
<fieldset>\
<legend>" + lan.soft.waf_input9 + "</legend>\
<input type='text' id='ipBlocklist_val' class='bt-input-text mr5' placeholder='" + lan.soft.waf_ip + "' style='width:175px;' /><button onclick=\"addWafKey('ipBlocklist')\" class='btn btn-default btn-sm'>" + lan.public.add + "</button>\
<div class='table-overflow'><table class='table table-hover'>" + blackList + "</table></div>\
</fieldset>\
</div>\
</div>"
$(".soft-man-con").html(con);
});
}
//上传限制
function upLimit() {
var loadT = layer.msg(lan.public.the_get, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.get("/waf?action=GetConfig", function(rdata) {
layer.close(loadT);
var black_fileExt = ''
for (var i = 0; i < rdata.black_fileExt.length; i++) {
black_fileExt += "<tr><td>" + rdata.black_fileExt[i] + "</td><td><a style='float:right;' href=\"javascript:deleteWafKey('black_fileExt','" + rdata.black_fileExt[i] + "');\">" + lan.public.del + "</a></td></tr>";
}
if ($("#blacktable").html() != undefined) {
$("#blacktable").html(black_fileExt);
$("#black_fileExt_val").val('');
return;
}
layer.open({
type: 1,
area: '300px',
title: lan.soft.waf_up_title,
closeBtn: 2,
shift: 0,
content: "<div class='dirBinding mlr15'>" +
"<input class='bt-input-text mr5' type='text' placeholder='" + lan.soft.waf_up_from1 + "' id='black_fileExt_val' style='height: 28px; border-radius: 3px;width: 219px;margin-top:15px' />" +
"<button class='btn btn-success btn-sm' onclick=\"addWafKey('black_fileExt')\">" + lan.public.add + "</button>" +
"</div>" +
"<div class='divtable' style='margin:15px'><table class='table table-hover' width='100%' style='margin-bottom:0'>" +
"<thead><tr><th>" + lan.soft.waf_up_from2 + "</th><th width='100' class='text-right'>" + lan.public.action + "</th></tr></thead>" +
"<tbody id='blacktable'>" + black_fileExt + "</tbody>" +
"</table></div>"
});
});
}
//设置waf状态
function CloseWaf() {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/waf?action=SetStatus', '', function(rdata) {
layer.close(loadT)
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
if (rdata.status) waf();
});
}
//取规则文件
function GetWafFile(name) {
OnlineEditFile(0, '/www/server/panel/vhost/wafconf/' + name);
}
//规则编辑
function gzEdit() {
layer.open({
type: 1,
area: '360px',
title: lan.soft.waf_edit,
closeBtn: 2,
shift: 0,
content: "<div class='gzEdit'><button class='btn btn-default btn-sm' onclick=\"GetWafFile('cookie')\">Cookie</button>\
<button class='btn btn-default btn-sm' onclick=\"GetWafFile('post')\">POST</button>\
<button class='btn btn-default btn-sm' onclick=\"GetWafFile('url')\">URL</button>\
<button class='btn btn-default btn-sm' onclick=\"GetWafFile('user-agent')\">User-Agent</button>\
<button class='btn btn-default btn-sm' onclick=\"GetWafFile('args')\">Args</button>\
<button class='btn btn-default btn-sm' onclick=\"GetWafFile('whiteurl')\">" + lan.soft.waf_url_white + "</button>\
<button class='btn btn-default btn-sm' onclick=\"GetWafFile('returnhtml')\">" + lan.soft.waf_index + "</button>\
<button class='btn btn-default btn-sm' onclick=\"updateWaf('returnhtml')\">" + lan.soft.waf_cloud + "</button></div>"
});
}
//更新WAF规则
function updateWaf() {
var loadT = layer.msg(lan.soft.waf_update, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/waf?action=updateWaf', '', function(rdata) {
layer.close(loadT)
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
});
}
//设置WAF配置值
function SetWafConfig(name, value) {
if (name == 'CCrate') {
var CCrate_1 = $("#CCrate_1").val();
var CCrate_2 = $("#CCrate_2").val();
if (CCrate_1 < 1 || CCrate_1 > 3000 || CCrate_2 < 1 || CCrate_2 > 1800) {
layer.msg(lan.soft.waf_cc_err, { icon: 5 });
return;
}
value = CCrate_1 + '/' + CCrate_2;
}
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/waf?action=SetConfigString', 'name=' + name + '&value=' + value, function(rdata) {
layer.close(loadT)
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
if (rdata.status) waf();
});
}
//删除WAF指定值
function deleteWafKey(name, value) {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/waf?action=SetConfigList&act=del', 'name=' + name + '&value=' + value, function(rdata) {
layer.close(loadT)
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
if (rdata.status) waf();
if (name == 'black_fileExt') upLimit();
});
}
//删除WAF指定值
function addWafKey(name) {
var value = $('#' + name + '_val').val();
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/waf?action=SetConfigList&act=add', 'name=' + name + '&value=' + value, function(rdata) {
layer.close(loadT)
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
if (rdata.status) waf();
if (name == 'black_fileExt') upLimit();
});
}
//查看Nginx负载状态
function GetNginxStatus() {
$.post('/ajax?action=GetNginxStatus', '', function(rdata) {
var con = "<div><table class='table table-hover table-bordered'>\
<tr><th>" + lan.bt.nginx_active + "</th><td>" + rdata.active + "</td></tr>\
<tr><th>" + lan.bt.nginx_accepts + "</th><td>" + rdata.accepts + "</td></tr>\
<tr><th>" + lan.bt.nginx_handled + "</th><td>" + rdata.handled + "</td></tr>\
<tr><th>" + lan.bt.nginx_requests + "</th><td>" + rdata.requests + "</td></tr>\
<tr><th>" + lan.bt.nginx_reading + "</th><td>" + rdata.Reading + "</td></tr>\
<tr><th>" + lan.bt.nginx_writing + "</th><td>" + rdata.Writing + "</td></tr>\
<tr><th>" + lan.bt.nginx_waiting + "</th><td>" + rdata.Waiting + "</td></tr>\
</table></div>";
$(".soft-man-con").html(con);
})
}
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/bt_install.pl
openrestyDir=${serverPath}/source/openresty
Install_openresty()
{
mkdir -p ${openrestyDir}
echo '正在安装脚本文件...' > $install_tmp
if [ ! -f ${openrestyDir}/openresty-1.13.6.2.tar.gz ];then
wget -O ${openrestyDir}/openresty-1.13.6.2.tar.gz https://openresty.org/download/openresty-1.13.6.2.tar.gz
fi
cd ${openrestyDir} && tar -zxvf openresty-1.13.6.2.tar.gz
cd ${openrestyDir}/openresty* && ./configure --prefix=$serverPath/openresty \
--with-openssl=$serverPath/source/lib/openssl-1.0.2q && make && make install
echo '安装完成' > $install_tmp
}
Uninstall_openresty()
{
rm -rf $serverPath/openresty
echo '卸载完成' > $install_tmp
}
action=$1
host=$2
if [ "${1}" == 'install' ];then
Install_openresty
else
Uninstall_openresty
fi
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 987 B

+25
View File
@@ -0,0 +1,25 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="redisService();">服务</p>
<p onclick="redisConfig();">安装扩展</p>
<p onclick="redisConfig();">配置修改</p>
<p onclick="redisConfig();">上传限制</p>
<p onclick="redisStatus();">超时限制</p>
<p onclick="redisStatus();">配置文件</p>
<p onclick="redisStatus();">禁用函数</p>
<p onclick="redisStatus();">性能调整</p>
<p onclick="redisStatus();">负载状况</p>
<p onclick="redisStatus();">FPM日志</p>
<p onclick="redisStatus();">慢日志</p>
<p onclick="redisStatus();">PHPIFNO</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
$.getScript( "/plugins/file?name=php&f=js/php.js");
</script>
+96
View File
@@ -0,0 +1,96 @@
# coding:utf-8
import sys
import io
import os
import time
sys.path.append(os.getcwd() + "/class/core")
import public
def status():
data = public.execShell(
"ps -ef|grep redis |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
def start():
path = os.path.dirname(os.getcwd())
cmd = path + "/redis/bin/redis-server"
cmd = cmd + " " + path + "/redis/redis.conf"
data = public.execShell(cmd)
if data[0] == '':
return 'ok'
return 'fail'
def stop():
data = public.execShell(
"ps -ef|grep redis |grep -v grep |grep -v python |awk '{print $2}' | xargs kill -9")
if data[0] == '':
return 'ok'
return 'fail'
def restart():
return 'ok'
def reload():
return 'ok'
def runInfo():
path = os.path.dirname(os.getcwd())
cmd = path + "/redis/bin/redis-cli info"
data = public.execShell(cmd)[0]
res = [
'tcp_port',
'uptime_in_days', # 已运行天数
'connected_clients', # 连接的客户端数量
'used_memory', # Redis已分配的内存总量
'used_memory_rss', # Redis占用的系统内存总量
'used_memory_peak', # Redis所用内存的高峰值
'mem_fragmentation_ratio', # 内存碎片比率
'total_connections_received', # 运行以来连接过的客户端的总数量
'total_commands_processed', # 运行以来执行过的命令的总数量
'instantaneous_ops_per_sec', # 服务器每秒钟执行的命令数量
'keyspace_hits', # 查找数据库键成功的次数
'keyspace_misses', # 查找数据库键失败的次数
'latest_fork_usec' # 最近一次 fork() 操作耗费的毫秒数
]
data = data.split("\n")
result = {}
for d in data:
if len(d) < 3:
continue
t = d.strip().split(':')
if not t[0] in res:
continue
result[t[0]] = t[1]
return public.getJson(result)
def getConf():
path = os.path.dirname(os.getcwd()) + "/redis/redis.conf"
return path
if __name__ == "__main__":
func = sys.argv[1]
if func == 'run_info':
print runInfo()
elif func == 'conf':
print getConf()
elif func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
+19
View File
@@ -0,0 +1,19 @@
{
"sort": 7,
"ps": "PHP是世界上最好的编程语言",
"shell": "install.sh",
"name": "php",
"title": "PHP",
"coexist": true,
"versions": ["52","56","72"],
"updates": ["5.2.17","5.6.36","7.2.0"],
"tip": "soft",
"checks": "server/php/VERSION/bin/php",
"path": "server/php/VERSION",
"display": 1,
"author": "Zend",
"date": "2017-04-01",
"home": "https://www.php.net",
"type": "语言解释器",
"pid": "1"
}
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/bt_install.pl
action=$1
type=$2
if [ "${2}" == "" ];then
echo '缺少安装脚本...' > $install_tmp
exit 0
fi
if [ ! -d $curPath/versions/$2 ];then
echo '缺少安装脚本2...' > $install_tmp
exit 0
fi
sh -x $curPath/versions/$2/install.sh $1
+616
View File
@@ -0,0 +1,616 @@
//软件管理
function phpSoftMain(name, key) {
if (!isNaN(name)) {
var nametext = "php" + name;
name = name.replace(".", "");
}
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.get('/plugins?action=getPluginInfo&name=php', function(rdata) {
layer.close(loadT);
nameA = rdata.versions[key];
bodys = [
'<p class="bgw pstate" data-id="0"><a href="javascript:service(\'' + name + '\',' + nameA.run + ')">' + lan.soft.php_main1 + '</a><span class="spanmove"></span></p>',
'<p data-id="1"><a id="phpext" href="javascript:SetPHPConfig(\'' + name + '\',' + nameA.pathinfo + ')">' + lan.soft.php_main5 + '</a><span class="spanmove"></span></p>',
'<p data-id="2"><a href="javascript:SetPHPConf(\'' + name + '\')">' + lan.soft.config_edit + '</a><span class="spanmove"></span></p>',
'<p data-id="3"><a href="javascript:phpUploadLimit(\'' + name + '\',' + nameA.max + ')">' + lan.soft.php_main2 + '</a><span class="spanmove"></span></p>',
'<p class="phphide" data-id="4"><a href="javascript:phpTimeLimit(\'' + name + '\',' + nameA.maxTime + ')">' + lan.soft.php_main3 + '</a><span class="spanmove"></span></p>',
'<p data-id="5"><a href="javascript:configChange(\'' + name + '\')">' + lan.soft.php_main4 + '</a><span class="spanmove"></span></p>',
'<p data-id="6"><a href="javascript:disFun(\'' + name + '\')">' + lan.soft.php_main6 + '</a><span class="spanmove"></span></p>',
'<p class="phphide" data-id="7"><a href="javascript:SetFpmConfig(\'' + name + '\')">' + lan.soft.php_main7 + '</a><span class="spanmove"></span></p>',
'<p class="phphide" data-id="8"><a href="javascript:GetPHPStatus(\'' + name + '\')">' + lan.soft.php_main8 + '</a><span class="spanmove"></span></p>',
'<p class="phphide" data-id="9"><a href="javascript:GetFpmLogs(\'' + name + '\')">FPM日志</a><span class="spanmove"></span></p>',
'<p class="phphide" data-id="10"><a href="javascript:GetFpmSlowLogs(\'' + name + '\')">慢日志</a><span class="spanmove"></span></p>',
'<p data-id="11"><a href="javascript:BtPhpinfo(\'' + name + '\')">phpinfo</a><span class="spanmove"></span></p>'
]
var sdata = '';
if (rdata.phpSort == false) {
rdata.phpSort = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
} else {
rdata.phpSort = rdata.phpSort.split('|');
}
for (var i = 0; i < rdata.phpSort.length; i++) {
sdata += bodys[rdata.phpSort[i]];
}
layer.open({
type: 1,
area: '640px',
title: nametext + lan.soft.admin,
closeBtn: 2,
shift: 0,
content: '<div class="bt-w-main" style="width:640px;">\
<input name="softMenuSortOrder" type="hidden" />\
<div class="bt-w-menu soft-man-menu">\
' + sdata + '\
</div>\
<div id="webEdit-con" class="bt-w-con pd15" style="height:555px;overflow:auto">\
<div class="soft-man-con"></div>\
</div>\
</div>'
});
if (name == "52") {
$(".phphide").hide();
}
if (rdata.versions.length < 5) {
$(".phphide").hide();
$(".pstate").hide();
SetPHPConfig(name, nameA.pathinfo);
$("p[data-id='4']").addClass('bgw');
} else {
service(name, nameA.run);
}
$(".bt-w-menu p a").click(function() {
var txt = $(this).text();
$(this).parent().addClass("bgw").siblings().removeClass("bgw");
if (txt != lan.soft.php_menu_ext) $(".soft-man-con").removeAttr("style");
});
$(".soft-man-menu").dragsort({ dragSelector: ".spanmove", dragEnd: MenusaveOrder });
});
}
//FPM日志
function GetFpmLogs(phpversion) {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.get('/ajax?action=GetFpmLogs&version=' + phpversion, function(logs) {
layer.close(loadT);
if (logs.status !== true) {
logs.msg = '';
}
if (logs.msg == '') logs.msg = '当前没有fpm日志.';
var phpCon = '<textarea readonly="" style="margin: 0px;width: 500px;height: 520px;background-color: #333;color:#fff; padding:0 5px" id="error_log">' + logs.msg + '</textarea>';
$(".soft-man-con").html(phpCon);
var ob = document.getElementById('error_log');
ob.scrollTop = ob.scrollHeight;
});
}
//FPM-Slow日志
function GetFpmSlowLogs(phpversion) {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.get('/ajax?action=GetFpmSlowLogs&version=' + phpversion, function(logs) {
layer.close(loadT);
if (logs.status !== true) {
logs.msg = '';
}
if (logs.msg == '') logs.msg = '当前没有慢日志.';
var phpCon = '<textarea readonly="" style="margin: 0px;width: 500px;height: 520px;background-color: #333;color:#fff; padding:0 5px" id="error_log">' + logs.msg + '</textarea>';
$(".soft-man-con").html(phpCon);
var ob = document.getElementById('error_log');
ob.scrollTop = ob.scrollHeight;
});
}
//配置修改
function SetPHPConf(version) {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/config?action=GetPHPConf', 'version=' + version, function(rdata) {
layer.close(loadT);
var mlist = '';
for (var i = 0; i < rdata.length; i++) {
var w = '70'
if (rdata[i].name == 'error_reporting') w = '250';
var ibody = '<input style="width: ' + w + 'px;" class="bt-input-text mr5" name="' + rdata[i].name + '" value="' + rdata[i].value + '" type="text" >';
switch (rdata[i].type) {
case 0:
var selected_1 = (rdata[i].value == 1) ? 'selected' : '';
var selected_0 = (rdata[i].value == 0) ? 'selected' : '';
ibody = '<select class="bt-input-text mr5" name="' + rdata[i].name + '" style="width: ' + w + 'px;"><option value="1" ' + selected_1 + '>开启</option><option value="0" ' + selected_0 + '>关闭</option></select>'
break;
case 1:
var selected_1 = (rdata[i].value == 'On') ? 'selected' : '';
var selected_0 = (rdata[i].value == 'Off') ? 'selected' : '';
ibody = '<select class="bt-input-text mr5" name="' + rdata[i].name + '" style="width: ' + w + 'px;"><option value="On" ' + selected_1 + '>开启</option><option value="Off" ' + selected_0 + '>关闭</option></select>'
break;
}
mlist += '<p><span>' + rdata[i].name + '</span>' + ibody + ', <font>' + rdata[i].ps + '</font></p>'
}
var phpCon = '<style>.conf_p p{margin-bottom: 2px}</style><div class="conf_p" style="margin-bottom:0">\
' + mlist + '\
<div style="margin-top:10px; padding-right:15px" class="text-right"><button class="btn btn-success btn-sm mr5" onclick="SetPHPConf(' + version + ')">' + lan.public.fresh + '</button><button class="btn btn-success btn-sm" onclick="SubmitPHPConf(' + version + ')">' + lan.public.save + '</button></div>\
</div>'
$(".soft-man-con").html(phpCon);
});
}
//提交PHP配置
function SubmitPHPConf(version) {
var data = {
version: version,
display_errors: $("select[name='display_errors']").val(),
'cgi.fix_pathinfo': $("select[name='cgi.fix_pathinfo']").val(),
'date.timezone': $("input[name='date.timezone']").val(),
short_open_tag: $("select[name='short_open_tag']").val(),
asp_tags: $("select[name='asp_tags']").val() || 'On',
safe_mode: $("select[name='safe_mode']").val(),
max_execution_time: $("input[name='max_execution_time']").val(),
max_input_time: $("input[name='max_input_time']").val(),
memory_limit: $("input[name='memory_limit']").val(),
post_max_size: $("input[name='post_max_size']").val(),
file_uploads: $("select[name='file_uploads']").val(),
upload_max_filesize: $("input[name='upload_max_filesize']").val(),
max_file_uploads: $("input[name='max_file_uploads']").val(),
default_socket_timeout: $("input[name='default_socket_timeout']").val(),
error_reporting: $("input[name='error_reporting']").val() || 'On'
}
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/config?action=SetPHPConf', data, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
}
//php超时限制
function phpTimeLimit(version, max) {
var LimitCon = '<p class="conf_p"><input class="phpTimeLimit bt-input-text mr5" type="number" value="' + max + '">' + lan.bt.s + '<button class="btn btn-success btn-sm" onclick="SetPHPMaxTime(\'' + version + '\')" style="margin-left:20px">' + lan.public.save + '</button></p>';
$(".soft-man-con").html(LimitCon);
}
//设置超时限制
function SetPHPMaxTime(version) {
var max = $(".phpTimeLimit").val();
var loadT = layer.msg(lan.soft.the_save, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/config?action=setPHPMaxTime', 'version=' + version + '&time=' + max, function(rdata) {
$(".bt-w-menu .active").attr('onclick', "phpTimeLimit('" + version + "'," + max + ")");
$(".bt-w-menu .active a").attr('href', "javascript:phpTimeLimit('" + version + "'," + max + ");");
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
}
//设置PHP上传限制
function SetPHPMaxSize(version) {
max = $(".phpUploadLimit").val();
if (max < 2) {
alert(max);
layer.msg(lan.soft.php_upload_size, { icon: 2 });
return;
}
var loadT = layer.msg(lan.soft.the_save, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/config?action=setPHPMaxSize', '&version=' + version + '&max=' + max, function(rdata) {
$(".bt-w-menu .active").attr('onclick', "phpUploadLimit('" + version + "'," + max + ")");
$(".bt-w-menu .active a").attr('href', "javascript:phpUploadLimit('" + version + "'," + max + ");");
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
})
}
//配置修改
function configChange(type) {
var con = '<p style="color: #666; margin-bottom: 7px">' + lan.bt.edit_ps + '</p><textarea class="bt-input-text" style="height: 320px; line-height:18px;" id="textBody"></textarea>\
<button id="OnlineEditFileBtn" class="btn btn-success btn-sm" style="margin-top:10px;">' + lan.public.save + '</button>\
<ul class="help-info-text c7 ptb15">\
<li>' + lan.get('config_edit_ps', [type]) + '</li>\
</ul>';
$(".soft-man-con").html(con);
var fileName = '';
switch (type) {
case 'mysqld':
fileName = '/etc/my.cnf';
break;
case 'nginx':
fileName = '/www/server/nginx/conf/nginx.conf';
break;
case 'pure-ftpd':
fileName = '/www/server/pure-ftpd/etc/pure-ftpd.conf';
break;
case 'apache':
fileName = '/www/server/apache/conf/httpd.conf';
break;
case 'tomcat':
fileName = '/www/server/tomcat/conf/server.xml';
break;
case 'memcached':
fileName = '/etc/init.d/memcached';
break;
case 'redis':
fileName = '/www/server/redis/redis.conf';
break;
default:
fileName = '/www/server/php/' + type + '/etc/php.ini';
break;
}
var loadT = layer.msg(lan.soft.get, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/files?action=GetFileBody', 'path=' + fileName, function(rdata) {
layer.close(loadT);
$("#textBody").empty().text(rdata.data);
$(".CodeMirror").remove();
var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
extraKeys: { "Ctrl-Space": "autocomplete" },
lineNumbers: true,
matchBrackets: true,
});
editor.focus();
$(".CodeMirror-scroll").css({ "height": "300px", "margin": 0, "padding": 0 });
$("#OnlineEditFileBtn").click(function() {
$("#textBody").text(editor.getValue());
confSafe(fileName);
});
});
}
//设置PATHINFO
function SetPathInfo(version, type) {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/config?action=setPathInfo', 'version=' + version + '&type=' + type, function(rdata) {
var pathinfo = (type == 'on') ? true : false;
var pathinfoOpt = '<a style="color:red;" href="javascript:SetPathInfo(\'' + version + '\',\'off\');">' + lan.public.off + '</a>'
if (!pathinfo) {
pathinfoOpt = '<a class="link" href="javascript:SetPathInfo(\'' + version + '\',\'on\');">' + lan.public.on + '</a>'
}
var pathinfo1 = '<td>PATH_INFO</td><td>' + lan.soft.php_menu_ext + '</td><td>' + lan.soft.mvc_ps + '</td><td><span class="ico-' + (pathinfo ? 'start' : 'stop') + ' glyphicon glyphicon-' + (pathinfo ? 'ok' : 'remove') + '"></span></td><td style="text-align: right;" width="50">' + pathinfoOpt + '</td>';
$("#pathInfo").html(pathinfo1);
$(".bt-w-menu .bgw").attr('onclick', "SetPHPConfig('" + version + "'," + pathinfo + ",1)");
$(".bt-w-menu .bgw a").attr('href', "javascript:SetPHPConfig('" + version + "'," + pathinfo + ",1);");
layer.msg(rdata.msg, { icon: 1 });
});
}
//PHP扩展配置
function SetPHPConfig(version, pathinfo, go) {
$.get('/ajax?action=GetPHPConfig&version=' + version, function(rdata) {
var body = ""
var opt = ""
for (var i = 0; i < rdata.libs.length; i++) {
if (rdata.libs[i].versions.indexOf(version) == -1) continue;
if (rdata.libs[i]['task'] == '-1' && rdata.libs[i].phpversions.indexOf(version) != -1) {
opt = '<a style="color:green;" href="javascript:messagebox();">' + lan.soft.the_install + '</a>'
} else if (rdata.libs[i]['task'] == '0' && rdata.libs[i].phpversions.indexOf(version) != -1) {
opt = '<a style="color:#C0C0C0;" href="javascript:messagebox();">' + lan.soft.sleep_install + '</a>'
} else if (rdata.libs[i].status) {
opt = '<a style="color:red;" href="javascript:UninstallPHPLib(\'' + version + '\',\'' + rdata.libs[i].name + '\',\'' + rdata.libs[i].title + '\',' + pathinfo + ');">' + lan.soft.uninstall + '</a>'
} else {
opt = '<a class="btlink" href="javascript:InstallPHPLib(\'' + version + '\',\'' + rdata.libs[i].name + '\',\'' + rdata.libs[i].title + '\',' + pathinfo + ');">' + lan.soft.install + '</a>'
}
body += '<tr>' +
'<td>' + rdata.libs[i].name + '</td>' +
'<td>' + rdata.libs[i].type + '</td>' +
'<td>' + rdata.libs[i].msg + '</td>' +
'<td><span class="ico-' + (rdata.libs[i].status ? 'start' : 'stop') + ' glyphicon glyphicon-' + (rdata.libs[i].status ? 'ok' : 'remove') + '"></span></td>' +
'<td style="text-align: right;">' + opt + '</td>' +
'</tr>'
}
var pathinfoOpt = '<a style="color:red;" href="javascript:SetPathInfo(\'' + version + '\',\'off\');">' + lan.soft.off + '</a>'
if (!rdata.pathinfo) {
pathinfoOpt = '<a class="btlink" href="javascript:SetPathInfo(\'' + version + '\',\'on\');">' + lan.soft.on + '</a>'
}
var pathinfo1 = '<tr id="pathInfo"><td>PATH_INFO</td><td>' + lan.soft.php_menu_ext + '</td><td>' + lan.soft.mvc_ps + '</td><td><span class="ico-' + (rdata.pathinfo ? 'start' : 'stop') + ' glyphicon glyphicon-' + (rdata.pathinfo ? 'ok' : 'remove') + '"></span></td><td style="text-align: right;" width="50">' + pathinfoOpt + '</td></tr>';
var con = '<div class="divtable" id="phpextdiv" style="margin-right:10px;height: 420px; overflow: auto; margin-right: 0px;">' +
'<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">' +
'<thead>' +
'<tr>' +
'<th>' + lan.soft.php_ext_name + '</th>' +
'<th width="64">' + lan.soft.php_ext_type + '</th>' +
'<th>' + lan.soft.php_ext_ps + '</th>' +
'<th width="40">' + lan.soft.php_ext_status + '</th>' +
'<th style="text-align: right;" width="50">' + lan.public.action + '</th>' +
'</tr>' +
'</thead>' +
'<tbody>' + pathinfo1 + body + '</tbody>' +
'</table>' +
'</div>' +
'<ul class="help-info-text c7 pull-left"><li>请按实际需求安装扩展,不要安装不必要的PHP扩展,这会影响PHP执行效率,甚至出现异常</li><li>Redis扩展只允许在1个PHP版本中使用,安装到其它PHP版本请在[软件管理]重装Redis</li><li>opcache/xcache/apc等脚本缓存扩展,请只安装其中1个,否则可能导致您的站点程序异常</li></ul>';
var divObj = document.getElementById('phpextdiv');
var scrollTopNum = 0;
if (divObj) scrollTopNum = divObj.scrollTop;
$(".soft-man-con").html(con);
document.getElementById('phpextdiv').scrollTop = scrollTopNum;
});
if (go == undefined) {
setTimeout(function() {
if ($(".bgw #phpext").html() != '安装扩展') {
return;
}
SetPHPConfig(version, pathinfo);
}, 3000);
}
}
//安装扩展
function InstallPHPLib(version, name, title, pathinfo) {
layer.confirm(lan.soft.php_ext_install_confirm.replace('{1}', name), { icon: 3, closeBtn: 2 }, function() {
name = name.toLowerCase();
var data = "name=" + name + "&version=" + version + "&type=1";
var loadT = layer.msg(lan.soft.add_install, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/files?action=InstallSoft', data, function(rdata) {
setTimeout(function() {
layer.close(loadT);
SetPHPConfig(version, pathinfo, true);
setTimeout(function() {
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
}, 1000);
}, 1000);
});
fly("bi-btn");
InstallTips();
GetTaskCount();
});
}
//卸载扩展
function UninstallPHPLib(version, name, title, pathinfo) {
layer.confirm(lan.soft.php_ext_uninstall_confirm.replace('{1}', name), { icon: 3, closeBtn: 2 }, function() {
name = name.toLowerCase();
var data = 'name=' + name + '&version=' + version;
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/files?action=UninstallSoft', data, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
SetPHPConfig(version, pathinfo, true);
});
});
}
//禁用函数
function disFun(version) {
$.get('/ajax?action=GetPHPConfig&version=' + version, function(rdata) {
var disable_functions = rdata.disable_functions.split(',');
var dbody = ''
for (var i = 0; i < disable_functions.length; i++) {
if (disable_functions[i] == '') continue;
dbody += "<tr><td>" + disable_functions[i] + "</td><td><a style='float:right;' href=\"javascript:disable_functions('" + version + "','" + disable_functions[i] + "','" + rdata.disable_functions + "');\">" + lan.public.del + "</a></td></tr>";
}
var con = "<div class='dirBinding'>" +
"<input class='bt-input-text mr5' type='text' placeholder='" + lan.soft.fun_ps1 + "' id='disable_function_val' style='height: 28px; border-radius: 3px;width: 410px;' />" +
"<button class='btn btn-success btn-sm' onclick=\"disable_functions('" + version + "',1,'" + rdata.disable_functions + "')\">" + lan.public.add + "</button>" +
"</div>" +
"<div class='divtable mtb15' style='height:350px;overflow:auto'><table class='table table-hover' width='100%' style='margin-bottom:0'>" +
"<thead><tr><th>" + lan.soft.php_ext_name + "</th><th width='100' class='text-right'>" + lan.public.action + "</th></tr></thead>" +
"<tbody id='blacktable'>" + dbody + "</tbody>" +
"</table></div>";
con += '\
<ul class="help-info-text">\
<li>' + lan.soft.fun_ps2 + '</li>\
<li>' + lan.soft.fun_ps3 + '</li>\
</ul>';
$(".soft-man-con").html(con);
});
}
//设置禁用函数
function disable_functions(version, act, fs) {
var fsArr = fs.split(',');
if (act == 1) {
var functions = $("#disable_function_val").val();
for (var i = 0; i < fsArr.length; i++) {
if (functions == fsArr[i]) {
layer.msg(lan.soft.fun_msg, { icon: 5 });
return;
}
}
fs += ',' + functions;
msg = lan.public.add_success;
} else {
fs = '';
for (var i = 0; i < fsArr.length; i++) {
if (act == fsArr[i]) continue;
fs += fsArr[i] + ','
}
msg = lan.public.del_success;
fs = fs.substr(0, fs.length - 1);
}
var data = 'version=' + version + '&disable_functions=' + fs;
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/config?action=setPHPDisable', data, function(rdata) {
layer.close(loadT);
layer.msg(rdata.status ? msg : rdata.msg, { icon: rdata.status ? 1 : 2 });
disFun(version);
});
}
//性能调整
function SetFpmConfig(version, action) {
if (action == 1) {
$.post('/system?action=GetMemInfo', '', function(memInfo) {
var limit_children = parseInt(memInfo['memTotal'] / 8);
var max_children = Number($("input[name='max_children']").val());
var start_servers = Number($("input[name='start_servers']").val());
var min_spare_servers = Number($("input[name='min_spare_servers']").val());
var max_spare_servers = Number($("input[name='max_spare_servers']").val());
var pm = $("select[name='pm']").val();
if (limit_children < max_children) {
layer.msg('当前服务器内存不足,最大允许[' + limit_children + ']个子进程!', { icon: 2 });
$("input[name='max_children']").focus();
return;
}
if (max_children < max_spare_servers) {
layer.msg(lan.soft.php_fpm_err1, { icon: 2 });
return;
}
if (min_spare_servers > start_servers) {
layer.msg(lan.soft.php_fpm_err2, { icon: 2 });
return;
}
if (max_spare_servers < min_spare_servers) {
layer.msg(lan.soft.php_fpm_err3, { icon: 2 });
return;
}
if (max_children < start_servers) {
layer.msg(lan.soft.php_fpm_err4, { icon: 2 });
return;
}
if (max_children < 1 || start_servers < 1 || min_spare_servers < 1 || max_spare_servers < 1) {
layer.msg(lan.soft.php_fpm_err5, { icon: 2 });
return;
}
var data = 'version=' + version + '&max_children=' + max_children + '&start_servers=' + start_servers + '&min_spare_servers=' + min_spare_servers + '&max_spare_servers=' + max_spare_servers + '&pm=' + pm;
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/config?action=setFpmConfig', data, function(rdata) {
layer.close(loadT);
var loadT = layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
}).error(function() {
layer.close(loadT);
layer.msg(lan.public.config_ok, { icon: 1 });
});
});
return;
}
$.post('/config?action=getFpmConfig', 'version=' + version, function(rdata) {
var limitList = "<option value='0'>" + lan.soft.concurrency_m + "</option>" +
"<option value='1' " + (rdata.max_children == 30 ? 'selected' : '') + ">30" + lan.soft.concurrency + "</option>" +
"<option value='2' " + (rdata.max_children == 50 ? 'selected' : '') + ">50" + lan.soft.concurrency + "</option>" +
"<option value='3' " + (rdata.max_children == 100 ? 'selected' : '') + ">100" + lan.soft.concurrency + "</option>" +
"<option value='4' " + (rdata.max_children == 200 ? 'selected' : '') + ">200" + lan.soft.concurrency + "</option>" +
"<option value='5' " + (rdata.max_children == 300 ? 'selected' : '') + ">300" + lan.soft.concurrency + "</option>" +
"<option value='6' " + (rdata.max_children == 500 ? 'selected' : '') + ">500" + lan.soft.concurrency + "</option>"
var pms = [{ 'name': 'static', 'title': lan.bt.static }, { 'name': 'dynamic', 'title': lan.bt.dynamic }];
var pmList = '';
for (var i = 0; i < pms.length; i++) {
pmList += '<option value="' + pms[i].name + '" ' + ((pms[i].name == rdata.pm) ? 'selected' : '') + '>' + pms[i].title + '</option>';
}
var body = "<div class='bingfa'>" +
"<p class='line'><span class='span_tit'>" + lan.soft.concurrency_type + ":</span><select class='bt-input-text' name='limit' style='width:100px;'>" + limitList + "</select></p>" +
"<p class='line'><span class='span_tit'>" + lan.soft.php_fpm_model + ":</span><select class='bt-input-text' name='pm' style='width:100px;'>" + pmList + "</select><span class='c9'>*" + lan.soft.php_fpm_ps1 + "</span></p>" +
"<p class='line'><span class='span_tit'>max_children:</span><input class='bt-input-text' type='number' name='max_children' value='" + rdata.max_children + "' /><span class='c9'>*" + lan.soft.php_fpm_ps2 + "</span></p>" +
"<p class='line'><span class='span_tit'>start_servers:</span><input class='bt-input-text' type='number' name='start_servers' value='" + rdata.start_servers + "' /> <span class='c9'>*" + lan.soft.php_fpm_ps3 + "</span></p>" +
"<p class='line'><span class='span_tit'>min_spare_servers:</span><input class='bt-input-text' type='number' name='min_spare_servers' value='" + rdata.min_spare_servers + "' /> <span class='c9'>*" + lan.soft.php_fpm_ps4 + "</span></p>" +
"<p class='line'><span class='span_tit'>max_spare_servers:</span><input class='bt-input-text' type='number' name='max_spare_servers' value='" + rdata.max_spare_servers + "' /> <span class='c9'>*" + lan.soft.php_fpm_ps5 + "</span></p>" +
"<div class='mtb15'><button class='btn btn-success btn-sm' onclick='SetFpmConfig(\"" + version + "\",1)'>" + lan.public.save + "</button></div>" +
"</div>"
$(".soft-man-con").html(body);
$("select[name='limit']").change(function() {
var type = $(this).val();
var max_children = rdata.max_children;
var start_servers = rdata.start_servers;
var min_spare_servers = rdata.min_spare_servers;
var max_spare_servers = rdata.max_spare_servers;
switch (type) {
case '1':
max_children = 30;
start_servers = 5;
min_spare_servers = 5;
max_spare_servers = 20;
break;
case '2':
max_children = 50;
start_servers = 15;
min_spare_servers = 15;
max_spare_servers = 35;
break;
case '3':
max_children = 100;
start_servers = 20;
min_spare_servers = 20;
max_spare_servers = 70;
break;
case '4':
max_children = 200;
start_servers = 25;
min_spare_servers = 25;
max_spare_servers = 150;
break;
case '5':
max_children = 300;
start_servers = 30;
min_spare_servers = 30;
max_spare_servers = 180;
break;
case '6':
max_children = 500;
start_servers = 35;
min_spare_servers = 35;
max_spare_servers = 250;
break;
}
$("input[name='max_children']").val(max_children);
$("input[name='start_servers']").val(start_servers);
$("input[name='min_spare_servers']").val(min_spare_servers);
$("input[name='max_spare_servers']").val(max_spare_servers);
});
});
}
//phpinfo
function BtPhpinfo(version) {
var con = '<button class="btn btn-default btn-sm" onclick="GetPHPInfo(\'' + version + '\')">' + lan.soft.phpinfo + '</button>';
$(".soft-man-con").html(con);
}
//获取PHPInfo
function GetPHPInfo(version) {
var loadT = layer.msg(lan.soft.get, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.get('/ajax?action=GetPHPInfo&version=' + version, function(rdata) {
layer.close(loadT);
layer.open({
type: 1,
title: "PHP-" + version + "-PHPINFO",
area: ['70%', '90%'],
closeBtn: 2,
shadeClose: true,
content: rdata.replace('a:link {color: #009; text-decoration: none; background-color: #fff;}', '').replace('a:link {color: #000099; text-decoration: none; background-color: #ffffff;}', '')
});
});
}
//查看PHP负载状态
function GetPHPStatus(version) {
$.post('/ajax?action=GetPHPStatus', 'version=' + version, function(rdata) {
var con = "<div style='height:420px;overflow:hidden;'><table class='table table-hover table-bordered GetPHPStatus' style='margin:0;padding:0'>\
<tr><th>" + lan.bt.php_pool + "</th><td>" + rdata.pool + "</td></tr>\
<tr><th>" + lan.bt.php_manager + "</th><td>" + ((rdata['process manager'] == 'dynamic') ? lan.bt.dynamic : lan.bt.static) + "</td></tr>\
<tr><th>" + lan.bt.php_start + "</th><td>" + rdata['start time'] + "</td></tr>\
<tr><th>" + lan.bt.php_accepted + "</th><td>" + rdata['accepted conn'] + "</td></tr>\
<tr><th>" + lan.bt.php_queue + "</th><td>" + rdata['listen queue'] + "</td></tr>\
<tr><th>" + lan.bt.php_max_queue + "</th><td>" + rdata['max listen queue'] + "</td></tr>\
<tr><th>" + lan.bt.php_len_queue + "</th><td>" + rdata['listen queue len'] + "</td></tr>\
<tr><th>" + lan.bt.php_idle + "</th><td>" + rdata['idle processes'] + "</td></tr>\
<tr><th>" + lan.bt.php_active + "</th><td>" + rdata['active processes'] + "</td></tr>\
<tr><th>" + lan.bt.php_total + "</th><td>" + rdata['total processes'] + "</td></tr>\
<tr><th>" + lan.bt.php_max_active + "</th><td>" + rdata['max active processes'] + "</td></tr>\
<tr><th>" + lan.bt.php_max_children + "</th><td>" + rdata['max children reached'] + "</td></tr>\
<tr><th>" + lan.bt.php_slow + "</th><td>" + rdata['slow requests'] + "</td></tr>\
</table></div>";
$(".soft-man-con").html(con);
$(".GetPHPStatus td,.GetPHPStatus th").css("padding", "7px");
})
}
//php上传限制
function phpUploadLimit(version, max) {
var LimitCon = '<p class="conf_p"><input class="phpUploadLimit bt-input-text mr5" type="number" value="' + max + '" name="max">MB<button class="btn btn-success btn-sm" onclick="SetPHPMaxSize(\'' + version + '\')" style="margin-left:20px">' + lan.public.save + '</button></p>';
$(".soft-man-con").html(LimitCon);
}
+65
View File
@@ -0,0 +1,65 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source
install_tmp=${rootPath}/tmp/bt_install.pl
# echo $curPath
# echo ${1}
# echo ${serverPath}
# echo ${install_tmp}
Install_php()
{
#------------------------ install start ------------------------------------#
echo "安装php-5.2.17 ..." > $install_tmp
mkdir -p $sourcePath/php
mkdir -p $serverPath/php
if [ ! -f $sourcePath/php/php-5.2.17.tar.bz2 ];then
wget -O $sourcePath/php/php-5.2.17.tar.bz2 https://museum.php.net/php5/php-5.2.17.tar.bz2
fi
if [ ! -d $sourcePath/php/php-5.2.17 ];then
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-5.2.17.tar.bz2
fi
cd $sourcePath/php/php-5.2.17 && ./configure \
--prefix=$serverPath/php/php52 \
--exec-prefix=$serverPath/php/php52 \
--with-config-file-path=$serverPath/php/php55/etc \
--with-zlib-dir=$serverPath/lib/zlib \
--without-iconv \
--enable-zip \
--enable-mbstring \
--enable-ftp \
--enable-wddx \
--enable-soap \
--enable-posix \
--enable-fpm \
&& make && make install
#------------------------ install end ------------------------------------#
}
Uninstall_php()
{
echo "卸载php-5.2.17 ..." > $install_tmp
}
action=${1}
if [ "${1}" == 'install' ];then
Install_php
else
Uninstall_php
fi
+65
View File
@@ -0,0 +1,65 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source
install_tmp=${rootPath}/tmp/bt_install.pl
# echo $curPath
# echo ${1}
# echo ${serverPath}
# echo ${install_tmp}
Install_php()
{
#------------------------ install start ------------------------------------#
echo "安装php-5.6.36 ..." > $install_tmp
mkdir -p $sourcePath/php
mkdir -p $serverPath/php
if [ ! -f $sourcePath/php/php-5.6.36.tar.xz ];then
wget -O $sourcePath/php/php-5.6.36.tar.xz https://museum.php.net/php5/php-5.6.36.tar.xz
fi
if [ ! -d $sourcePath/php/php-5.6.36 ];then
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-5.6.36.tar.xz
fi
cd $sourcePath/php/php-5.6.36 && ./configure \
--prefix=$serverPath/php/56 \
--exec-prefix=$serverPath/php/56 \
--with-config-file-path=$serverPath/php/56/etc \
--with-zlib-dir=$serverPath/lib/zlib \
--without-iconv \
--enable-zip \
--enable-mbstring \
--enable-ftp \
--enable-wddx \
--enable-soap \
--enable-posix \
--enable-fpm \
&& make && make install
#------------------------ install end ------------------------------------#
}
Uninstall_php()
{
echo "卸载php-5.6.36 ..." > $install_tmp
}
action=${1}
if [ "${1}" == 'install' ];then
Install_php
else
Uninstall_php
fi
+65
View File
@@ -0,0 +1,65 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source
install_tmp=${rootPath}/tmp/bt_install.pl
# echo $curPath
# echo ${1}
# echo ${serverPath}
# echo ${install_tmp}
Install_php()
{
#------------------------ install start ------------------------------------#
echo "安装php-7.2.5 ..." > $install_tmp
mkdir -p $sourcePath/php
mkdir -p $serverPath/php
if [ ! -f $sourcePath/php/php-7.2.5.tar.xz ];then
wget -O $sourcePath/php/php-7.2.5.tar.xz https://museum.php.net/php7/php-7.2.5.tar.xz
fi
if [ ! -d $sourcePath/php/php-7.2.5 ];then
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-7.2.5.tar.xz
fi
cd $sourcePath/php/php-7.2.5 && ./configure \
--prefix=$serverPath/php/72 \
--exec-prefix=$serverPath/php/72 \
--with-config-file-path=$serverPath/php/72/etc \
--with-zlib-dir=$serverPath/lib/zlib \
--without-iconv \
--enable-zip \
--enable-mbstring \
--enable-ftp \
--enable-wddx \
--enable-soap \
--enable-posix \
--enable-fpm \
&& make && make install
#------------------------ install end ------------------------------------#
}
Uninstall_php()
{
echo "卸载php-7.2.5 ..." > $install_tmp
}
action=${1}
if [ "${1}" == 'install' ];then
Install_php
else
Uninstall_php
fi
+118
View File
@@ -0,0 +1,118 @@
//phpmyadmin安全设置
function safeConf(name, port, auth) {
var con = '<div class="ver line">\
<span style="margin-right:10px">' + lan.soft.pma_port + '</span>\
<input class="bt-input-text phpmyadmindk mr20" name="Name" id="pmport" value="' + port + '" placeholder="' + lan.soft.pma_port_title + '" maxlength="5" type="number">\
<button class="btn btn-success btn-sm" onclick="phpmyadminport()">' + lan.public.save + '</button>\
</div>\
<div class="user_pw_tit">\
<span class="tit">' + lan.soft.pma_pass + '</span>\
<span class="btswitch-p"><input class="btswitch btswitch-ios" id="phpmyadminsafe" type="checkbox" ' + (auth ? 'checked' : '') + '>\
<label class="btswitch-btn phpmyadmin-btn" for="phpmyadminsafe" onclick="phpmyadminSafe()"></label>\
</span>\
</div>\
<div class="user_pw">\
<p><span>' + lan.soft.pma_user + '</span><input id="username_get" class="bt-input-text" name="username_get" value="" type="text" placeholder="' + lan.soft.edit_empty + '"></p>\
<p><span>' + lan.soft.pma_pass1 + '</span><input id="password_get_1" class="bt-input-text" name="password_get_1" value="" type="password" placeholder="' + lan.soft.edit_empty + '"></p>\
<p><span>' + lan.soft.pma_pass2 + '</span><input id="password_get_2" class="bt-input-text" name="password_get_1" value="" type="password" placeholder="' + lan.soft.edit_empty + '"></p>\
<p><button class="btn btn-success btn-sm" onclick="phpmyadmin(\'get\')">' + lan.public.save + '</button></p>\
</div>\
<ul class="help-info-text c7"><li>' + lan.soft.pma_ps + '</li></ul>';
$(".soft-man-con").html(con);
if (auth) {
$(".user_pw").show();
}
}
function phpVerChange(type, msg) {
var data = type + '=' + $("#" + msg).val();
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/ajax?action=setPHPMyAdmin', data, function(rdata) {
layer.closeAll();
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
if (rdata.status) {
setTimeout(function() {
window.location.reload();
}, 3000);
}
})
}
//phpmyadmin切换php版本
function phpVer(name, version) {
$.post('/site?action=GetPHPVersion', function(rdata) {
var body = "<div class='ver line'><span class='tname'>" + lan.soft.php_version + "</span><select id='get' class='bt-input-text mr20' name='phpVersion' style='width:110px'>";
var optionSelect = '';
for (var i = 0; i < rdata.length; i++) {
optionSelect = rdata[i].version == version ? 'selected' : '';
body += "<option value='" + rdata[i].version + "' " + optionSelect + ">" + rdata[i].name + "</option>"
}
body += '</select><button class="btn btn-success btn-sm" onclick="phpVerChange(\'phpversion\',\'get\')">' + lan.public.save + '</button></div>';
$(".soft-man-con").html(body);
})
}
//修改phpmyadmin端口
function phpmyadminport() {
var pmport = $("#pmport").val();
if (pmport < 80 || pmport > 65535) {
layer.msg(lan.firewall.port_err, { icon: 2 });
return;
}
var data = 'port=' + pmport;
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/ajax?action=setPHPMyAdmin', data, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
}
//phpmyadmin二级密码
function phpmyadminSafe() {
var stat = $("#phpmyadminsafe").prop("checked");
if (stat) {
$(".user_pw").hide();
phpmyadmin('close');
} else {
$(".user_pw").show();
}
}
//设置phpmyadmin二级密码
function phpmyadmin(msg) {
type = 'password';
if (msg == 'close') {
password_1 = msg;
username = msg;
layer.confirm(lan.soft.pma_pass_close, { closeBtn: 2, icon: 3 }, function() {
var data = type + '=' + msg + '&siteName=phpmyadmin';
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/ajax?action=setPHPMyAdmin', data, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
});
return;
} else {
username = $("#username_get").val()
password_1 = $("#password_get_1").val()
password_2 = $("#password_get_2").val()
if (username.length < 1 || password_1.length < 1) {
layer.msg(lan.soft.pma_pass_empty, { icon: 2 });
return;
}
if (password_1 != password_2) {
layer.msg(lan.bt.pass_err_re, { icon: 2 });
return;
}
}
msg = password_1 + '&username=' + username + '&siteName=phpmyadmin';
var data = type + '=' + msg;
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/ajax?action=setPHPMyAdmin', data, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

+36
View File
@@ -0,0 +1,36 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="infojson();">INFO说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con">
<div><p>在每一个插件中,都必须包含一个info.json文件,格式如下:</p><br/></div>
<div><pre>{
"title": "插件开发说明",
"tip": "soft",
"name": "readme",
"type": "扩展",
"ps": "(mdserver-web)插件产开发说明,每个版本可能有所变化!",
"versions": "0.1",
"shell": "install.sh",
"checks": "server/readme",
"path": "server/readme",
"author": "mdserver-web",
"home": "github.com/midoks/mdserver-web",
"date": "2018-11-30",
"pid": "5"
}</pre></div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
// resetPluginWinWidth(700);
// $.getScript("/plugins/file?name=readme&f=js/score.js");
</script>
+20
View File
@@ -0,0 +1,20 @@
# coding: utf-8
import time
import psutil
import random
import os
import urllib
import binascii
import json
import public
import re
def status():
return 'start'
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print status()
+15
View File
@@ -0,0 +1,15 @@
{
"title":"插件开发说明",
"tip":"soft",
"name":"readme",
"type":"扩展",
"ps":"(mdserver-web)插件产开发说明,每个版本可能有所变化!",
"versions": "0.1",
"shell":"install.sh",
"checks":"server/readme",
"path":"server/readme",
"author":"mdserver-web",
"home":"github.com/midoks/mdserver-web",
"date":"2018-11-30",
"pid":"5"
}
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/bt_install.pl
Install_readme()
{
mkdir -p ${serverPath}/readme
echo "${1}" > ${serverPath}/readme/version.pl
echo '安装完成' > $install_tmp
}
Uninstall_readme()
{
rm -rf ${serverPath}/readme
echo '卸载完成' > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_readme $2
else
Uninstall_readme $2
fi
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

+16
View File
@@ -0,0 +1,16 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="redisService();">服务</p>
<p onclick="redisConfig();">配置修改</p>
<p onclick="redisStatus();">负载状态</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
$.getScript( "/plugins/file?name=redis&f=js/redis.js");
</script>
+96
View File
@@ -0,0 +1,96 @@
# coding:utf-8
import sys
import io
import os
import time
sys.path.append(os.getcwd() + "/class/core")
import public
def status():
data = public.execShell(
"ps -ef|grep redis |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
def start():
path = os.path.dirname(os.getcwd())
cmd = path + "/redis/bin/redis-server"
cmd = cmd + " " + path + "/redis/redis.conf"
data = public.execShell(cmd)
if data[0] == '':
return 'ok'
return 'fail'
def stop():
data = public.execShell(
"ps -ef|grep redis |grep -v grep |grep -v python |awk '{print $2}' | xargs kill -9")
if data[0] == '':
return 'ok'
return 'fail'
def restart():
return 'ok'
def reload():
return 'ok'
def runInfo():
path = os.path.dirname(os.getcwd())
cmd = path + "/redis/bin/redis-cli info"
data = public.execShell(cmd)[0]
res = [
'tcp_port',
'uptime_in_days', # 已运行天数
'connected_clients', # 连接的客户端数量
'used_memory', # Redis已分配的内存总量
'used_memory_rss', # Redis占用的系统内存总量
'used_memory_peak', # Redis所用内存的高峰值
'mem_fragmentation_ratio', # 内存碎片比率
'total_connections_received', # 运行以来连接过的客户端的总数量
'total_commands_processed', # 运行以来执行过的命令的总数量
'instantaneous_ops_per_sec', # 服务器每秒钟执行的命令数量
'keyspace_hits', # 查找数据库键成功的次数
'keyspace_misses', # 查找数据库键失败的次数
'latest_fork_usec' # 最近一次 fork() 操作耗费的毫秒数
]
data = data.split("\n")
result = {}
for d in data:
if len(d) < 3:
continue
t = d.strip().split(':')
if not t[0] in res:
continue
result[t[0]] = t[1]
return public.getJson(result)
def getConf():
path = os.path.dirname(os.getcwd()) + "/redis/redis.conf"
return path
if __name__ == "__main__":
func = sys.argv[1]
if func == 'run_info':
print runInfo()
elif func == 'conf':
print getConf()
elif func == 'status':
print status()
elif func == 'start':
print start()
elif func == 'stop':
print stop()
elif func == 'restart':
print restart()
elif func == 'reload':
print reload()
+17
View File
@@ -0,0 +1,17 @@
{
"sort": 7,
"ps": "Redis 是一个高性能的key-value数据库(要使用PHP连接redis,需在PHP设置中安装redis扩展)",
"name": "redis",
"title": "Redis",
"shell": "install.sh",
"versions":["4.0"],
"updates":["4.0.11"],
"tip": "soft",
"checks": "server/redis",
"display": 1,
"author": "Zend",
"date": "2017-04-01",
"home": "https://redis.io",
"type": 0,
"pid": "2"
}
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/bt_install.pl
Install_redis()
{
echo '正在安装脚本文件...' > $install_tmp
wget -O $serverPath/tmp/redis.tar.gz http://download.redis.io/releases/redis-4.0.11.tar.gz
cd $serverPath/tmp && tar -zxvf redis.tar.gz
mkdir -p $serverPath/redis
cd redis* && make PREFIX=$serverPath/redis install
sed '/^ *#/d' redis.conf > $serverPath/redis/redis.conf
echo '安装完成' > $install_tmp
rm -rf $serverPath/tmp
}
Uninstall_redis()
{
echo "Uninstall_redis"
}
action=$1
if [ "${1}" == 'install' ];then
Install_redis
else
Uninstall_redis
fi
+170
View File
@@ -0,0 +1,170 @@
function redisOp(a, b) {
var c = "name=" + a + "&func=" + b;
var d = "";
switch(b) {
case "stop":d = '停止';break;
case "start":d = '启动';break;
case "restart":d = '重启';break;
case "reload":d = '重载';break;
}
layer.confirm( '您真的要{1}{2}服务吗?'.replace('{1}', d).replace('{2}', a), {icon:3,closeBtn: 2}, function() {
var e = layer.msg('正在{1}{2}服务,请稍候...'.replace('{1}', d).replace('{2}', a), {icon: 16,time: 0});
$.post("/plugins/run", c, function(g) {
layer.close(e);
var f = g.data == 'ok' ? '{1}服务已{2}'.replace('{1}', a).replace('{2}', d):'{1}服务{2}失败!'.replace('{1}', a).replace('{2}', d);
layer.msg(f, {icon: g.data == 'ok' ? 1 : 2});
if(b != "reload" && g.data == 'ok') {
if (b == 'start') {
setRedisService('redis', true);
} else if (b=='stop'){
setRedisService('redis', false);
} else {
}
}
if(g.data != 'ok') {
layer.msg(g.data, {icon: 2,time: 0,shade: 0.3,shadeClose: true});
}
},'json').error(function() {
layer.close(e);
layer.msg('操作成功!', {icon: 1});
});
})
}
//服务
function setRedisService(name, status){
var serviceCon ='<p class="status">当前状态:<span>'+(status ? '开启' : '关闭' )+
'</span><span style="color: '+
(status?'#20a53a;':'red;')+
' margin-left: 3px;" class="glyphicon ' + (status?'glyphicon glyphicon-play':'glyphicon-pause')+'"></span></p><div class="sfm-opt">\
<button class="btn btn-default btn-sm" onclick="redisOp(\''+name+'\',\''+(status?'stop':'start')+'\')">'+(status?'停止':'启动')+'</button>\
<button class="btn btn-default btn-sm" onclick="redisOp(\''+name+'\',\'restart\')">重启</button>\
<button class="btn btn-default btn-sm" onclick="redisOp(\''+name+'\',\'reload\')">重载配置</button>\
</div>';
$(".soft-man-con").html(serviceCon);
}
//服务
function redisService(){
$.post('/plugins/run', {name:'redis', func:'status'}, function(data) {
console.log(data);
if(!data.status){
layer.msg(data.msg,{icon:0,time:3000,shade: [0.3, '#000']});
return;
}
if (data.data == 'start'){
setRedisService('redis', true);
} else {
setRedisService('redis', false);
}
},'json');
}
redisService();
//配置修改 --- start
function redisConfig(type){
var con = '<p style="color: #666; margin-bottom: 7px">提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!</p><textarea class="bt-input-text" style="height: 320px; line-height:18px;" id="textBody"></textarea>\
<button id="OnlineEditFileBtn" class="btn btn-success btn-sm" style="margin-top:10px;">保存</button>\
<ul class="help-info-text c7 ptb15">\
<li>此处为redis主配置文件,若您不了解配置规则,请勿随意修改。</li>\
</ul>';
$(".soft-man-con").html(con);
var loadT = layer.msg('配置文件路径获取中...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/plugins/run', {name:'redis', func:'conf'},function (data) {
layer.close(loadT);
var loadT2 = layer.msg('文件内容获取中...',{icon:16,time:0,shade: [0.3, '#000']});
var fileName = data.data;
$.post('/files/get_body', 'path=' + fileName, function(rdata) {
layer.close(loadT2);
if (!rdata.status){
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
$("#textBody").empty().text(rdata.data.data);
$(".CodeMirror").remove();
var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
extraKeys: {
"Ctrl-Space": "autocomplete",
"Ctrl-F": "findPersistent",
"Ctrl-H": "replaceAll",
"Ctrl-S": function() {
redisConfSafe(fileName);
}
},
lineNumbers: true,
matchBrackets:true,
});
editor.focus();
$(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
$("#OnlineEditFileBtn").click(function(){
$("#textBody").text(editor.getValue());
redisConfSafe(fileName);
});
},'json');
},'json');
}
//配置保存
function redisConfSafe(fileName) {
var data = encodeURIComponent($("#textBody").val());
var encoding = 'utf-8';
var loadT = layer.msg('保存中...', {
icon: 16,
time: 0
});
$.post('/files/save_body', 'data=' + data + '&path=' + fileName + '&encoding=' + encoding, function(rdata) {
layer.close(loadT);
layer.msg(rdata.msg, {
icon: rdata.status ? 1 : 2
});
},'json');
}
//配置修改 --- end
//redis负载状态 start
function redisStatus() {
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'redis', func:'run_info'}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
var rdata = $.parseJSON(data.data);
hit = (parseInt(rdata.keyspace_hits) / (parseInt(rdata.keyspace_hits) + parseInt(rdata.keyspace_misses)) * 100).toFixed(2);
var Con = '<div class="divtable">\
<table class="table table-hover table-bordered" style="width: 490px;">\
<thead><th>字段</th><th>当前值</th><th>说明</th></thead>\
<tbody>\
<tr><th>uptime_in_days</th><td>' + rdata.uptime_in_days + '</td><td>已运行天数</td></tr>\
<tr><th>tcp_port</th><td>' + rdata.tcp_port + '</td><td>当前监听端口</td></tr>\
<tr><th>connected_clients</th><td>' + rdata.connected_clients + '</td><td>连接的客户端数量</td></tr>\
<tr><th>used_memory_rss</th><td>' + toSize(rdata.used_memory_rss) + '</td><td>Redis当前占用的系统内存总量</td></tr>\
<tr><th>used_memory</th><td>' + toSize(rdata.used_memory) + '</td><td>Redis当前已分配的内存总量</td></tr>\
<tr><th>used_memory_peak</th><td>' + toSize(rdata.used_memory_peak) + '</td><td>Redis历史分配内存的峰值</td></tr>\
<tr><th>mem_fragmentation_ratio</th><td>' + rdata.mem_fragmentation_ratio + '%</td><td>内存碎片比率</td></tr>\
<tr><th>total_connections_received</th><td>' + rdata.total_connections_received + '</td><td>运行以来连接过的客户端的总数量</td></tr>\
<tr><th>total_commands_processed</th><td>' + rdata.total_commands_processed + '</td><td>运行以来执行过的命令的总数量</td></tr>\
<tr><th>instantaneous_ops_per_sec</th><td>' + rdata.instantaneous_ops_per_sec + '</td><td>服务器每秒钟执行的命令数量</td></tr>\
<tr><th>keyspace_hits</th><td>' + rdata.keyspace_hits + '</td><td>查找数据库键成功的次数</td></tr>\
<tr><th>keyspace_misses</th><td>' + rdata.keyspace_misses + '</td><td>查找数据库键失败的次数</td></tr>\
<tr><th>hit</th><td>' + hit + '%</td><td>查找数据库键命中率</td></tr>\
<tr><th>latest_fork_usec</th><td>' + rdata.latest_fork_usec + '</td><td>最近一次 fork() 操作耗费的微秒数</td></tr>\
<tbody>\
</table></div>'
$(".soft-man-con").html(Con);
},'json');
}
//redis负载状态 end
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

+249
View File
File diff suppressed because one or more lines are too long
+352
View File
@@ -0,0 +1,352 @@
# coding: utf-8
import time
import psutil
import random
import os
import urllib
import binascii
import json
import public
import re
class score_main:
__APIURL = 'https://www.bt.cn/api/Auth'
__UPATH = 'data/userInfo.json'
__userInfo = None
__PDATA = None
def CheckToken(self):
pdata = {}
data = {}
if os.path.exists(self.__UPATH):
self.__userInfo = json.loads(public.readFile(self.__UPATH))
if self.__userInfo:
pdata['access_key'] = self.__userInfo['access_key']
data['secret_key'] = self.__userInfo['secret_key']
else:
pdata['access_key'] = 'test'
data['secret_key'] = '123456'
pdata['data'] = data
self.__PDATA = pdata
# 修正信息
def SetScore(self, get):
if hasattr(get, 'ips'):
return self.SubmitSetScore('ips', get.ips)
if hasattr(get, 'virt'):
return self.SubmitSetScore('virt', get.virt)
# 发送信息修正
def SubmitSetScore(self, key, value):
self.CheckToken()
self.__PDATA['data'][key] = value
self.__PDATA['data'] = self.De_Code(self.__PDATA['data'])
result = json.loads(public.httpPost(
self.__APIURL + '/SetSocre', self.__PDATA))
result['data'] = self.En_Code(result['data'])
return result
# 获取得分列表
def GetScore(self, get):
self.CheckToken()
self.__PDATA['data'] = self.De_Code(self.__PDATA['data'])
result = json.loads(public.httpPost(
self.__APIURL + '/GetSocre', self.__PDATA))
result['data'] = self.En_Code(result['data'])
return result
# 获取配置信息
def GetConfig(self, get=None):
virt = '/usr/sbin/virt-what'
if not os.path.exists(virt):
if os.path.exists('/etc/yum.repos.d/epel.repo'):
os.system(
'mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo_backup')
os.system('yum install virt-what -y')
if os.path.exists('/etc/yum.repos.d/epel.repo_backup'):
os.system(
'mv /etc/yum.repos.d/epel.repo_backup /etc/yum.repos.d/epel.repo')
data = {}
data['virt'] = public.ExecShell('virt-what')[0].strip()
cpuinfo = open('/proc/cpuinfo', 'r').read()
rep = "model\s+name\s+:\s+(.+)"
tmp = re.search(rep, cpuinfo)
data['cpu'] = tmp.groups()[0]
data['core'] = psutil.cpu_count()
data['memory'] = psutil.virtual_memory().total / 1024 / 1024
data['system'] = self.GetSystemVersion()
scoreInfo = self.readScore()
data['disk'] = str(scoreInfo['read']) + ',' + str(scoreInfo['write'])
data['mem_score'] = scoreInfo['mem']
data['cpu_score'] = scoreInfo['cpu1'] + \
scoreInfo['cpu2'] + scoreInfo['cpu3'] + scoreInfo['cpu4']
data['disk_score'] = scoreInfo['disk_score']
data['total_score'] = scoreInfo['mem'] + \
data['cpu_score'] + scoreInfo['disk_score']
return data
# 提交到云端
def SubmitScore(self, get):
try:
self.CheckToken()
pdata = self.GetConfig(get)
if not pdata['total_score']:
return public.returnMsg(False, '请先跑分!')
pdata['secret_key'] = self.__userInfo['secret_key']
self.__PDATA['data'] = self.De_Code(pdata)
result = json.loads(public.httpPost(
self.__APIURL + '/SubmitScore', self.__PDATA))
result['data'] = self.En_Code(result['data'])
return result
except:
return None
# 取操作系统版本
def GetSystemVersion(self):
version = public.readFile('/etc/redhat-release')
if not version:
version = public.readFile(
'/etc/issue').replace('\\n \\l', '').strip()
else:
version = version.replace('release ', '').strip()
return version
# 写当前得分
def writeScore(self, type, value):
scoreFile = '/www/server/panel/plugin/score/score.json'
if not os.path.exists(scoreFile):
data = {}
data['cpu1'] = 0
data['cpu2'] = 0
data['cpu3'] = 0
data['cpu4'] = 0
data['mem'] = 0
data['disk_score'] = 0
data['read'] = 0
data['write'] = 0
public.writeFile(scoreFile, json.dumps(data))
data = json.loads(public.readFile(scoreFile))
data[type] = value
public.writeFile(scoreFile, json.dumps(data))
# 读当前得分
def readScore(self):
scoreFile = '/www/server/panel/plugin/score/score.json'
if not os.path.exists(scoreFile):
data = {}
data['cpu1'] = 0
data['cpu2'] = 0
data['cpu3'] = 0
data['cpu4'] = 0
data['mem'] = 0
data['disk_score'] = 0
data['read'] = 0
data['write'] = 0
public.writeFile(scoreFile, json.dumps(data))
data = json.loads(public.readFile(scoreFile))
return data
# 测试CPU
def testCpu(self, get, n=1):
data = {}
data['cpuCount'] = psutil.cpu_count()
if not hasattr(get, 'type'):
get.type = '0'
import re
cpuinfo = open('/proc/cpuinfo', 'r').read()
rep = "model\s+name\s+:\s+(.+)"
tmp = re.search(rep, cpuinfo)
data['cpuType'] = ""
if tmp:
data['cpuType'] = tmp.groups()[0]
import system
data['system'] = system.system().GetSystemVersion()
path = '/www/server/panel/plugin/score/testcpu'
if not os.path.exists(path):
os.system('gcc ' + path + '.c -o ' + path + ' -lpthread')
start = time.time()
os.system(path + ' 32 ' + get.type)
end = time.time()
data['score'] = int(400 * 10 / (end - start))
if not os.path.exists(path):
data['score'] = 0
self.writeScore('cpu' + get.type, data['score'])
return data
pass
# 测试整数运算
def testInt(self):
return self.testIntOrFloat(1)
# 测试浮点运行
def testFloat(self):
return self.testIntOrFloat(1.01)
# CPU测试体
def testIntOrFloat(self, n=1):
start = time.time()
num = 10000 * 100
for i in range(num):
if i == 0:
continue
a = n + i
b = n - i
c = n * i
d = n / i
n = n + 1
end = time.time()
usetime = end - start
return num / 100 / usetime
# 冒泡算法测试
def testBubble(self):
start = time.time()
num = 10000 * 5
xx = 'qwertyuiopasdfghjklzxcvbnm1234567890'
for c in xrange(num):
lst = []
for k in range(10):
lst.append(xx[random.randint(0, len(xx) - 1)])
lst = self.bubbleSort(lst)
end = time.time()
usetime = end - start
return num / 5 / usetime
# 冒泡排序
def bubbleSort(self, lst):
length = len(lst)
for i in xrange(0, length, 1):
for j in xrange(0, length - 1 - i, 1):
if lst[j] < lst[j + 1]:
temp = lst[j]
lst[j] = lst[j + 1]
lst[j + 1] = temp
return lst
# 二叉树算法测试
def testTree(self):
import testTree
start = time.time()
elems = range(3000) # 生成树节点
tree = testTree.Tree() # 新建一个树对象
for elem in elems:
tree.add(elem) # 逐个加入树的节点
tree.level_queue(tree.root)
tree.front_digui(tree.root)
tree.middle_digui(tree.root)
tree.later_digui(tree.root)
tree.front_stack(tree.root)
tree.middle_stack(tree.root)
tree.later_stack(tree.root)
end = time.time()
usetime = end - start
return 3000 / usetime
# 测试内存
def testMem(self, get):
mem = psutil.virtual_memory()
self.writeScore('mem', mem.total / 1024 / 1024)
# 提交数据
self.SubmitScore(get)
return mem.total / 1024 / 1024
# 测试磁盘
def testDisk(self, get):
import os
data = {}
os.system('rm -f testDisk_*')
filename = "testDisk_" + \
time.strftime('%Y%m%d%H%M%S', time.localtime())
data['write'] = self.testDiskWrite(filename)
import shutil
filename2 = "testDisk_" + \
time.strftime('%Y%m%d%H%M%S', time.localtime())
shutil.move(filename, filename2)
data['read'] = self.testDiskRead(filename2)
diskIo = psutil.disk_partitions()
diskInfo = []
for disk in diskIo:
tmp = {}
tmp['path'] = disk[1]
tmp['size'] = psutil.disk_usage(disk[1])[0]
diskInfo.append(tmp)
data['diskInfo'] = diskInfo
writeDisk = data['write']
if data['write'] > 1000:
writeDisk = 1000
readDisk = data['read']
if data['read'] > 1000:
readDisk = 1000
data['score'] = (writeDisk * 6) + (readDisk * 6)
os.remove(filename2)
self.writeScore('disk_score', data['score'])
self.writeScore('write', data['write'])
self.writeScore('read', data['read'])
return data
pass
# 测试磁盘写入速度
def testDiskWrite(self, filename):
import random
start = time.time()
fp = open(filename, 'w+')
strTest = ""
strTmp = ""
for n in range(4):
strTmp += chr(random.randint(97, 122))
for n in range(1024):
strTest += strTmp
for i in range(1024 * 256):
fp.write(strTest)
del(strTest)
del(strTmp)
fp.close()
end = time.time()
usetime = end - start
return int(1024 / usetime)
# 测试磁盘读取速度
def testDiskRead(self, filename):
os.system('echo 3 > /proc/sys/vm/drop_caches')
import random
start = time.time()
fp = open(filename, 'r')
size = 4096
while True:
tmp = fp.read(size)
if not tmp:
break
del(tmp)
fp.close()
end = time.time()
usetime = end - start
return int(1024 / usetime)
def testWorkNet(self):
pass
# 加密数据
def De_Code(self, data):
pdata = urllib.urlencode(data)
return binascii.hexlify(pdata)
# 解密数据
def En_Code(self, data):
result = urllib.unquote(binascii.unhexlify(data))
return json.loads(result)
+16
View File
@@ -0,0 +1,16 @@
{
"title":"跑分测试",
"tip":"lib",
"name":"score",
"type":"扩展",
"ps":"测试服务器基础性能!",
"versions": "1.3",
"shell":"install.sh",
"checks":"server/score",
"author":"mdserver-web",
"home":"github.com/midoks/mdserver-web",
"date":"2018-11-02",
"default":false,
"display":0,
"pid":"4"
}
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/bt_install.pl
Install_score()
{
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/score
gcc $curPath/testcpu.c -o $serverPath/score/testcpu -lpthread
if [ ! -f $serverPath/score/testcpu ];then
sleep 0.1
gcc $curPath/testcpu.c -o $serverPath/score/testcpu -lpthread
fi
echo '安装完成' > $install_tmp
}
Uninstall_score()
{
rm -rf $serverPath/score
echo '卸载完成' > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_score
else
Uninstall_score
fi
+301
View File
File diff suppressed because one or more lines are too long
+129
View File
@@ -0,0 +1,129 @@
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <time.h>
const int N_qsort = 10000;
const int N_int = 10000;
const int N_float = 20000;
const int N_pi = 50000000;
int thread_count = 0;
void int_comp(void);
void float_comp(void);
void pi_comp(void);
void to_qsort(int arr[],int low,int high);
void qsort_comp(void);
void thread(void);
void thread_int(void);
void thread_float(void);
void thread_pi(void);
void thread_qsort(void);
int main(int argc,char** argv){
int count,i,result,type;
count = atoi(argv[1]);
type = atoi(argv[2]);
if(argc < 3){
printf("ERROR: Parameter error[%d]",argc);
}
pthread_t tid;
for(i=0;i<count;i++){
switch(type){
case 1:
pthread_create(&tid,NULL,(void *) thread_int,NULL);
break;
case 2:
pthread_create(&tid,NULL,(void *) thread_float,NULL);
break;
case 3:
pthread_create(&tid,NULL,(void *) thread_pi,NULL);
break;
case 4:
pthread_create(&tid,NULL,(void *) thread_qsort,NULL);
break;
default:
pthread_create(&tid,NULL,(void *) thread,NULL);
break;
}
}
while(thread_count != count){
sleep(0.1);
}
return 0;
}
void thread(void){
int_comp();
float_comp();
pi_comp();
qsort_comp();
thread_count++;
}
void thread_int(void){
int_comp();
thread_count++;
}
void thread_float(void){
float_comp();
thread_count++;
}
void thread_pi(void){
pi_comp();
thread_count++;
}
void thread_qsort(void){
qsort_comp();
thread_count++;
}
void int_comp(void){
int i,j;
for(i=0;i<N_int;i++)
for(j=0;j<N_float;j++);
}
void float_comp(void){
float i,j;
for(i=0;i<N_int;i++)
for(j=0;j<N_float;j++);
}
void pi_comp(void){
int m,i=1;
double s=0;
for(m=1;m<N_pi;m+=2){
s+=i*(1.0/m);
i=-i;
}
}
void to_qsort(int arr[],int low,int high){
if(low>=high) return;
int first=low;
int last=high;
int key=arr[first];
while(first<last){
while(first<last&&arr[last]>=key) --last;
arr[first]=arr[last];
while(first<last&&arr[first]<=key) ++first;
arr[last]=arr[first];
}
arr[first]=key;
to_qsort(arr,low,first-1);
to_qsort(arr,first+1,high);
}
void qsort_comp(void){
int arr[N_qsort],i;
for(i=N_qsort;i>0;i--) arr[N_qsort-1]=i;
to_qsort(arr,0,N_qsort-1);
}

Some files were not shown because too many files have changed in this diff Show More