diff --git a/class/core/plugin.py b/class/core/plugin.py index a54c4c56d..3142c3c63 100755 --- a/class/core/plugin.py +++ b/class/core/plugin.py @@ -111,9 +111,11 @@ class plugin: try: tmp = json.loads(public.readFile(jsonFile)) if tmp['name'] == 'php': - for v in tmp['versions']: + for index in range(len(tmp['versions'])): + pg = self.getPluginInfo(tmp) - pg['versions'] = v + pg['versions'] = tmp['versions'][index] + # print "sss:", i, v # pg['updates'] = tmp["updates"][v] if sType == "0": diff --git a/plugins/php/index.html b/plugins/php/index.html index cf0b57f1b..03b945fe3 100755 --- a/plugins/php/index.html +++ b/plugins/php/index.html @@ -1,550 +1,25 @@ - - -
-

密钥

-

面板设置

-

面板登录日志

-

SSH设置

-

SSH日志管理

+

服务

+

安装扩展

+

配置修改

+

上传限制

+

超时限制

+

配置文件

+

禁用函数

+

性能调整

+

负载状况

+

FPM日志

+

慢日志

+

PHPIFNO

-
-

- 密钥: - -

- -
    -
  • 宝塔企业运维后台连接您的服务器需要此密钥,请妥善记录并保存
  • -
  • 一但密钥丢失,可能导致您无法登录服务器
  • -
-
- - - - +
-
- \ No newline at end of file diff --git a/plugins/php/index.py b/plugins/php/index.py new file mode 100755 index 000000000..e954d4d0f --- /dev/null +++ b/plugins/php/index.py @@ -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() diff --git a/plugins/php/info.json b/plugins/php/info.json index 7b5fa4bef..56f3ee061 100755 --- a/plugins/php/info.json +++ b/plugins/php/info.json @@ -5,8 +5,8 @@ "name": "php", "title": "PHP", "default": false, - "versions": ["5.2","5.3","5.4","5.5","5.6","7.0","7.1","7.2"], - "updates": ["5.2.17p1","5.3.29","5.4.45","5.5.38","5.6.32","7.0.26","7.1.12","7.2.0"], + "versions": ["5.2","7.2"], + "updates": ["5.2.17p1","7.2.0"], "tip": "soft", "checks": "server/php/VERSION/bin/php", "display": 1, diff --git a/plugins/php/install.sh b/plugins/php/install.sh index 6965e237a..61032384a 100755 --- a/plugins/php/install.sh +++ b/plugins/php/install.sh @@ -1,23 +1,19 @@ #!/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 +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + -Install_safelogin() +install_tmp=${rootPath}/tmp/bt_install.pl + +Install_php() { - 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 } @@ -34,7 +30,7 @@ Uninstall_safelogin() action=$1 host=$2; if [ "${1}" == 'install' ];then - Install_safelogin + Uninstall_php else - Uninstall_safelogin + Uninstall_php fi diff --git a/plugins/php/js/php.js b/plugins/php/js/php.js new file mode 100755 index 000000000..eedb5c495 --- /dev/null +++ b/plugins/php/js/php.js @@ -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 ='

当前状态:'+(status ? '开启' : '关闭' )+ + '

\ + \ + \ + \ +
'; + $(".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 = '

提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!

\ + \ + '; + $(".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 = '
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
字段当前值说明
uptime_in_days' + rdata.uptime_in_days + '已运行天数
tcp_port' + rdata.tcp_port + '当前监听端口
connected_clients' + rdata.connected_clients + '连接的客户端数量
used_memory_rss' + ToSize(rdata.used_memory_rss) + 'Redis当前占用的系统内存总量
used_memory' + ToSize(rdata.used_memory) + 'Redis当前已分配的内存总量
used_memory_peak' + ToSize(rdata.used_memory_peak) + 'Redis历史分配内存的峰值
mem_fragmentation_ratio' + rdata.mem_fragmentation_ratio + '%内存碎片比率
total_connections_received' + rdata.total_connections_received + '运行以来连接过的客户端的总数量
total_commands_processed' + rdata.total_commands_processed + '运行以来执行过的命令的总数量
instantaneous_ops_per_sec' + rdata.instantaneous_ops_per_sec + '服务器每秒钟执行的命令数量
keyspace_hits' + rdata.keyspace_hits + '查找数据库键成功的次数
keyspace_misses' + rdata.keyspace_misses + '查找数据库键失败的次数
hit' + hit + '%查找数据库键命中率
latest_fork_usec' + rdata.latest_fork_usec + '最近一次 fork() 操作耗费的微秒数
' + $(".soft-man-con").html(Con); + },'json'); +} +//redis负载状态 end \ No newline at end of file diff --git a/route/files.py b/route/files.py index a55e3fc3b..f3a76bb59 100644 --- a/route/files.py +++ b/route/files.py @@ -108,7 +108,7 @@ def saveBody(): def getDir(): path = request.form.get('path', '').encode('utf-8') if not os.path.exists(path): - path = '/' + path = public.getRootDir() + "/wwwroot" import pwd dirnames = [] @@ -133,9 +133,14 @@ def getDir(): search = None if request.form.has_key('search'): search = request.form.get('search').strip().lower() + i = 0 n = 0 + print 'path:', path for filename in os.listdir(path): + if filename[0:1] == '.': + continue + print filename if search: if filename.lower().find(search) == -1: continue @@ -176,5 +181,8 @@ def getDir(): continue data['DIR'] = sorted(dirnames) data['FILES'] = sorted(filenames) - data['PATH'] = path + if path[0:2] == '//': + data['PATH'] = path[1:] + else: + data['PATH'] = path return public.getJson(data) diff --git a/scripts/lib.sh b/scripts/lib.sh index 140a7cfb1..d822a525d 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -1,34 +1,8 @@ #!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH -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 -mkdir -p /www/server -run_path="/root" -Is_64bit=`getconf LONG_BIT` -centos_version=`cat /etc/redhat-release | grep ' 7.' | grep -i centos` -if [ "${centos_version}" != '' ]; then - rpm_path="centos7" -else - rpm_path="centos6" -fi -Install_SendMail() -{ - yum install postfix mysql-libs -y - if [ "${centos_version}" != '' ];then - systemctl start postfix - systemctl enable postfix - else - service postfix start - chkconfig --level 2345 postfix on - fi -} + Install_Curl() { @@ -226,7 +200,6 @@ if [ ! -f "${lockFile}" ];then for yumPack in make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof pcre pcre-devel vixie-cron crontabs expat-devel readline-devel; do yum -y install $yumPack;done - Install_SendMail mv /etc/yum.repos.d/epel.repo.backup /etc/yum.repos.d/epel.repo groupadd www useradd -s /sbin/nologin -M -g www www diff --git a/static/js/soft.js b/static/js/soft.js index c351b5cd4..47741f09e 100755 --- a/static/js/soft.js +++ b/static/js/soft.js @@ -1726,8 +1726,6 @@ function GetSList(isdisplay) { var handle = '安装'; var isSetup = false; - - if (plugin.name != 'php') { for (var n = 0; n < len; n++) { if (plugin.status == true) { isSetup = true; @@ -1773,72 +1771,10 @@ function GetSList(isdisplay) { '' + state + '' + '' + indexshow + '' + '' + handle + '' + - '' - } else { - var pnum = 0; - for (var n = 0; n < len; n++) { - if (plugin.status == true) { - // checked = plugin.versions[n]['display'] ? "checked" : ""; - // var mupdate = (plugin.versions[n] == plugin.updates[n]) ? '' : '更新 | '; - // handle = mupdate + '' + lan.soft.setup + ' | 卸载'; - // softPath = ''; - // titleClick = 'onclick="phpSoftMain(\'' + plugin.versions[n] + '\',' + n + ')" style="cursor:pointer"'; - // indexshow = '
'; - // if (plugin.run == true) { - // state = '' - // } else { - // state = '' - // } - } else { - handle = '' + lan.soft.install + ''; - softPath = ''; - checked = ''; - indexshow = ''; - titleClick = ''; - state = ''; - } - var pps = rdata.data[i].ps; - if (rdata.data[i].apache == '2.2' && rdata.data[i].versions[n].fpm == true) { - pps += ", " + lan.soft.apache22 + ""; - } - - if (rdata.data[i].apache == '2.2' && rdata.data[i].versions[n].fpm == false) pnum++; - - if (rdata.data[i].apache != '2.2' && rdata.data[i].versions[n].fpm == false) { - pps += ", " + lan.soft.apache24 + ""; - } - - var isTask = rdata.data[i].versions[n].task; - if (isTask == '-1') { - if (rdata.data[i].apache == '2.2') pnum++; - - handle = '' + lan.soft.the_install + '' - } else if (isTask == '0') { - if (rdata.data[i].apache == '2.2') pnum++; - handle = '' + lan.soft.sleep_install + '' - } - pBody += '' + - '' + rdata.data[i].title + '-' + rdata.data[i].versions + '' - //+''+rdata.data[i].versions[n].no+'' - //+''+rdata.data[i].type+'' - + - '' + pps + '' + - '' + softPath + '' + - '' + state + '' + - '' + indexshow + '' + - '' + handle + '' + - '' - } - - if (pnum > 0) { - setCookie('apacheVersion', '2.2'); - setCookie('phpVersion', 1); - } else { - setCookie('apacheVersion', ''); - setCookie('phpVersion', 0); - } - } + ''; } + + sBody += pBody; $("#softList").html(sBody); $(".menu-sub span").click(function() { @@ -1877,30 +1813,6 @@ function SoftUpdate(name, version, update) { //独立安装 function oneInstall(name, version) { var isError = false - if (name == 'pure') name += '-' + version.toLowerCase(); - - if (name == 'apache' || name == 'nginx') { - - $.ajax({ - url: '/ajax?action=GetInstalled', - type: 'get', - async: false, - success: function(rdata) { - if (rdata.webserver != name && rdata.webserver != false) { - layer.msg(lan.soft.err_install2, { icon: 2 }) - isError = true; - return; - } - } - }); - } - - if (name == 'php') { - if (getCookie('apacheVersion') == '2.2' && getCookie('phpVersion') == 1) { - layer.msg(lan.soft.apache22_err, { icon: 5 }); - return; - } - } var optw = ''; @@ -1923,16 +1835,16 @@ function oneInstall(name, version) { if (isError) return; var one = layer.open({ type: 1, - title: lan.soft.type_title, + title: '选择安装方式', area: '350px', closeBtn: 2, shadeClose: true, content: "
\
" + lan.soft.install_version + ":" + name + " " + version + "" + optw + "
\ -
" + lan.bt.install_type + ":
\ +
" + lan.bt.install_type + ":
\
\ - \ - \ + \ + \
\
" }) diff --git a/templates/default/firewall.html b/templates/default/firewall.html index d711bfe4f..fd1ac8269 100755 --- a/templates/default/firewall.html +++ b/templates/default/firewall.html @@ -39,9 +39,7 @@
启用SSH -
- -
+
@@ -134,6 +132,5 @@ - - + {% endblock %} \ No newline at end of file