Skip to content

Commit

Permalink
代码恢复
Browse files Browse the repository at this point in the history
  • Loading branch information
midoks committed Jun 28, 2022
1 parent af32792 commit fbac71e
Show file tree
Hide file tree
Showing 111 changed files with 1,569 additions and 966 deletions.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: BUG提交
about: 问题描述
---

## 什么系统 ?

Debian x, Centos x, Centos x stream, Ubuntu x?

## 错误信息 ?

Ex:
```bash
................start mw success
bash: line 149: ./scripts/init.d/mw: No such file or directory
```

## 错误截图 ?

...


## 浏览器版本 ?

...


## 软件版本(插件/面板) ?

...
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: 需求提交
about: 需求描述
---

## 需求

想开发一个什么插件?
想有什么功能?


## 提供参考

给开发者提供参考!
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ include
data/api_login.txt
data/sessions
data/ssl.pl
plugins/gdrive/
plugins/openlitespeed/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [midoks] [midoks 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.
Expand Down
35 changes: 16 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
简单的Linux面板,感谢BT.CN写出如此好的web管理软件。我一看到,就知道这是我一直想要的页面化管理方式。
复制了后台管理界面,按照自己想要的方式写了一版。

```
为了兼容CentOS,Ubuntu,Debian,Fedora, 由chkconfig改systemd管理。原来都要重新安装。还在进行修改..
chkconfig 支持 Fedora,CentOS
update-rc.d 支持 Ubuntu,Debian | 功能不够
systemd 支持 CentOS,Ubuntu,Debian,Fedora...
```

![CentOS](https://img.shields.io/badge/LINUX-CentOS-blue?style=for-the-badge&logo=CentOS)
![Ubuntu](https://img.shields.io/badge/LINUX-Ubuntu-blue?style=for-the-badge&logo=Ubuntu)
Expand All @@ -22,7 +14,6 @@ systemd 支持 CentOS,Ubuntu,Debian,Fedora...
* 面板收藏功能
* 网站子目录绑定
* 网站备份功能
* 自动更新优化
* 插件方式管理

基本上可以使用,后续会继续优化!欢迎提供意见!
Expand All @@ -48,9 +39,8 @@ systemd 支持 CentOS,Ubuntu,Debian,Fedora...


### 问题
- Ubuntu 20 无法安装mysql5.7 && mysql 80.
- Ftp debian无法安装成功。
- php52,在debian无法安装成功。
- OP防火墙,暂不要开启。



### GW使用
Expand Down Expand Up @@ -82,6 +72,14 @@ curl -fsSL https://gitee.com/midoks/mdserver-web/raw/master/scripts/update_cn.s
```



### 通用安装

```
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/quick/app.sh | bash
```


### DEV使用

- 自动安装
Expand All @@ -96,6 +94,8 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/in
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
```

### 微信赞助
[![截图](/route/static/img/weixin_zz.jpg)](/route/static/img/weixin_zz.jpg)

### 无图不真相

Expand All @@ -109,22 +109,19 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/up
如果你自己写了插件,想分享出来,也可以提Issue。
```

- 开发文档 - https://github.com/midoks/mdserver-web/wiki/%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91
- 简单例子 - https://github.com/mw-plugin/simple-plugin
- 插件地址 - https://github.com/mw-plugin
- 例子 - https://github.com/mw-plugin/simple-plugin

- 开发文档 - https://github.com/midoks/mdserver-web/wiki/插件开发


### Stargazers over time

[![Stargazers over time](https://starchart.cc/midoks/mdserver-web.svg)](https://starchart.cc/midoks/mdserver-web)


### 感谢

- 开发赞助
### 感谢开发赞助

[digitalvirt](https://digitalvirt.com/)
[![digitalvirt](https://digitalvirt.com/templates/BlueWhite/img/logo-dark.svg)](https://digitalvirt.com/)

### 授权许可

Expand Down
12 changes: 9 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@

try:
if __name__ == "__main__":
f = open('data/port.pl')
PORT = int(f.read())
HOST = '0.0.0.0'

PORT = 7200
if os.path.exists('data/port.pl'):
f = open('data/port.pl')
PORT = int(f.read())
f.close()

HOST = '0.0.0.0'
http_server = WSGIServer(
(HOST, PORT), app, handler_class=WebSocketHandler)

http_server.serve_forever()

socketio.run(app, host=HOST, port=PORT)
except Exception as ex:
print(ex)
7 changes: 4 additions & 3 deletions class/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@


def init():

initDB()
initInitD()
initUserInfo()
initInitD()


def local():
Expand Down Expand Up @@ -57,7 +56,6 @@ def doContentReplace(src, dst):


def initInitD():
mw.setHostAddr(mw.getLocalIp())

# systemctl
# 有问题
Expand Down Expand Up @@ -97,6 +95,9 @@ def initInitD():
mw.execShell('which chkconfig && chkconfig --add mw')
mw.execShell('which update-rc.d && update-rc.d -f mw defaults')

# 获取系统IPV4
mw.setHostAddr(mw.getLocalIp())


def initUserInfo():

Expand Down
2 changes: 1 addition & 1 deletion class/core/config_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class config_api:
# 本版解决自启动问题
# 文件管理重命名
# 优化计划任务管理
__version = '0.8.6'
__version = '0.8.6.1'

def __init__(self):
pass
Expand Down
53 changes: 50 additions & 3 deletions class/core/mw.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ def isAppleSystem():
return False


def isNumber(s):
try:
float(s)
return True
except ValueError:
pass

try:
import unicodedata
unicodedata.numeric(s)
return True
except (TypeError, ValueError):
pass

return False


def deleteFile(file):
if os.path.exists(file):
os.remove(file)
Expand All @@ -111,9 +128,22 @@ def isInstalledWeb():


def restartWeb():
if isInstalledWeb():
initd = getServerDir() + '/openresty/init.d/openresty'
if not isInstalledWeb():
return False

# systemd
systemd = '/lib/systemd/system/openresty.service'
if os.path.exists(systemd):
execShell('systemctl restart openresty')
return True

# initd
initd = getServerDir() + '/openresty/init.d/openresty'
if os.path.exists(initd):
execShell(initd + ' ' + 'restart')
return True

return False


def restartMw():
Expand Down Expand Up @@ -540,7 +570,7 @@ def downloadHook(count, blockSize, totalSize):
print('%02d%%' % (100.0 * count * blockSize / totalSize))


def getLocalIp():
def getLocalIpBack():
# 取本地外网IP
try:
import re
Expand All @@ -561,6 +591,23 @@ def getLocalIp():
return '127.0.0.1'


def getLocalIp():
# 取本地外网IP
try:
import re
filename = 'data/iplist.txt'
ipaddress = readFile(filename)
if not ipaddress or ipaddress == '127.0.0.1':
import urllib
url = 'https://v6r.ipip.net/?format=text'
req = urllib.request.urlopen(url, timeout=10)
ipaddress = req.read().decode('utf-8')
writeFile(filename, ipaddress)
return ipaddress
except Exception as ex:
return '127.0.0.1'


def inArray(arrays, searchStr):
# 搜索数据中是否存在
for key in arrays:
Expand Down
7 changes: 7 additions & 0 deletions class/core/plugins_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ def __init__(self):
def listApi(self):
sType = request.args.get('type', '0')
sPage = request.args.get('p', '1')

if not mw.isNumber(sPage):
sPage = 1

if not mw.isNumber(sType):
sType = 0

# print sPage
data = self.getPluginList(sType, int(sPage))
return mw.getJson(data)
Expand Down
38 changes: 24 additions & 14 deletions class/core/site_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,11 @@ def createLetApi(self):
if not os.path.exists(acem):
return mw.returnJson(False, '尝试自动安装ACME失败,请通过以下命令尝试手动安装<p>安装命令: curl https://get.acme.sh | sh</p>' + acem)

force_bool = False
# 避免频繁执行
checkAcmeRun = mw.execShell('ps -ef|grep acme.sh |grep -v grep')
if checkAcmeRun[0] != '':
return mw.returnJson(False, '正在申请或更新SSL中...')

if force == 'true':
force_bool = True

Expand Down Expand Up @@ -973,7 +977,7 @@ def getDirBindRewriteApi(self):
"-START(.|\n)+BINDING-" + domain + "-END"
tmp = re.search(rep, conf).group()
dirConf = tmp.replace('rewrite/' + site['name'] + '.conf;', 'rewrite/' + site[
'name'] + '_' + find['path'] + '.conf;')
'name'] + '_' + find['path'] + '.conf;')
conf = conf.replace(tmp, dirConf)
mw.writeFile(file, conf)
data = {}
Expand Down Expand Up @@ -1522,9 +1526,13 @@ def closeLimitNet(self, sid):
def getSecurity(self, sid, name):
filename = self.getHostConf(name)
conf = mw.readFile(filename)

if type(conf) == bool:
return mw.returnJson(False, '读取配置文件失败!')

data = {}
if conf.find('SECURITY-START') != -1:
rep = "#SECURITY-START(\n|.){1,500}#SECURITY-END"
rep = "#SECURITY-START(.|\n)*#SECURITY-END"
tmp = re.search(rep, conf).group()
data['fix'] = re.search(
"\(.+\)\$", tmp).group().replace('(', '').replace(')$', '').replace('|', ',')
Expand All @@ -1549,22 +1557,22 @@ def setSecurity(self, sid, name, fix, domains, status):
if os.path.exists(file):
conf = mw.readFile(file)
if conf.find('SECURITY-START') != -1:
rep = "\s{0,4}#SECURITY-START(\n|.){1,500}#SECURITY-END\n?"
rep = "\s{0,4}#SECURITY-START(\n|.)*#SECURITY-END\n?"
conf = re.sub(rep, '', conf)
mw.writeLog('网站管理', '站点[' + name + ']已关闭防盗链设置!')
else:
rconf = '''#SECURITY-START 防盗链配置
location ~ .*\.(%s)$
{
expires 30d;
access_log /dev/null;
valid_referers none blocked %s;
if ($invalid_referer){
return 404;
location ~ .*\.(%s)$
{
expires 30d;
access_log /dev/null;
valid_referers none blocked %s;
if ($invalid_referer){
return 404;
}
}
}
# SECURITY-END
include enable-php-''' % (fix.strip().replace(',', '|'), domains.strip().replace(',', ' '))
#SECURITY-END
include enable-php-''' % (fix.strip().replace(',', '|'), domains.strip().replace(',', ' '))
conf = re.sub("include\s+enable-php-", rconf, conf)
mw.writeLog('网站管理', '站点[' + name + ']已开启防盗链!')
mw.writeFile(file, conf)
Expand Down Expand Up @@ -1615,6 +1623,8 @@ def createRootDir(self, path):
os.makedirs(path)
if not mw.isAppleSystem():
mw.execShell('chown -R www:www ' + path)

mw.writeFile(path + '/index.html', '已经开始工作!!!')
mw.execShell('chmod -R 755 ' + path)

def nginxAddDomain(self, webname, domain, port):
Expand Down
Loading

0 comments on commit fbac71e

Please sign in to comment.