pull/109/head
Mr Chen 7 years ago
parent 9a7a5f7c15
commit f5b4c03354
  1. 6
      class/core/plugin.py
  2. 557
      plugins/php/index.html
  3. 96
      plugins/php/index.py
  4. 4
      plugins/php/info.json
  5. 26
      plugins/php/install.sh
  6. 170
      plugins/php/js/php.js
  7. 10
      route/files.py
  8. 31
      scripts/lib.sh
  9. 98
      static/js/soft.js
  10. 7
      templates/default/firewall.html

@ -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":

@ -1,550 +1,25 @@
<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>
<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 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 class="soft-man-con"></div>
</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();
}
}
</div>
<script type="text/javascript">
$.getScript( "/plugins/file?name=php&f=js/php.js");
</script>

@ -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()

@ -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,

@ -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

@ -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

@ -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)
if path[0:2] == '//':
data['PATH'] = path[1:]
else:
data['PATH'] = path
return public.getJson(data)

@ -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

@ -1726,8 +1726,6 @@ function GetSList(isdisplay) {
var handle = '<a class="btlink" onclick="AddVersion(\'' + plugin.name + '\',\'' + version_info + '\',\'' + plugin.tip + '\',this,\'' + plugin.title + '\')">安装</a>';
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) {
'<td>' + state + '</td>' +
'<td>' + indexshow + '</td>' +
'<td style="text-align: right;">' + handle + '</td>' +
'</tr>'
} 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]) ? '' : '<a class="btlink" onclick="SoftUpdate(\'' + rdata.data[i].name + '\',\'' + plugin.versions[n] + '\',\'' + plugin.updates[n] + '\')">更新</a> | ';
// handle = mupdate + '<a class="btlink" onclick="phpSoftMain(\'' + plugin.versions + '\',' + n + ')">' + lan.soft.setup + '</a> | <a class="btlink" onclick="UninstallVersion(\'' + rdata.data[i].name + '\',\'' + plugin.versions[n] + '\',\'' + plugin.title + '\')">卸载</a>';
// softPath = '<span class="glyphicon glyphicon-folder-open" title="' + plugin.path + '" onclick="openPath(\'' + plugin.path + "/" + plugin.versions[n].replace(/\./, "") + '\')"></span>';
// titleClick = 'onclick="phpSoftMain(\'' + plugin.versions[n] + '\',' + n + ')" style="cursor:pointer"';
// indexshow = '<div class="index-item"><input class="btswitch btswitch-ios" id="index_' + plugin.name + plugin.versions[n].replace(/\./, "") + '" type="checkbox" ' + checked + '><label class="btswitch-btn" for="index_' + plugin.name + plugin.versions[n].replace(/\./, "") + '" onclick="toIndexDisplay(\'' + plugin.name + '\',\'' + plugin.versions[n] + '\')"></label></div>';
// if (plugin.run == true) {
// state = '<span style="color:#20a53a" class="glyphicon glyphicon-play"></span>'
// } else {
// state = '<span style="color:red" class="glyphicon glyphicon-pause"></span>'
// }
} else {
handle = '<a class="btlink" onclick="oneInstall(\'' + rdata.data[i].name + '\',\'' + rdata.data[i].versions[n].version + '\')">' + lan.soft.install + '</a>';
softPath = '';
checked = '';
indexshow = '';
titleClick = '';
state = '';
'</tr>';
}
var pps = rdata.data[i].ps;
if (rdata.data[i].apache == '2.2' && rdata.data[i].versions[n].fpm == true) {
pps += "<a style='color:red;'>, " + lan.soft.apache22 + "</a>";
}
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 += "<a style='color:red;'>, " + lan.soft.apache24 + "</a>";
}
var isTask = rdata.data[i].versions[n].task;
if (isTask == '-1') {
if (rdata.data[i].apache == '2.2') pnum++;
handle = '<a style="color:green;" href="javascript:task();">' + lan.soft.the_install + '</a>'
} else if (isTask == '0') {
if (rdata.data[i].apache == '2.2') pnum++;
handle = '<a style="color:#C0C0C0;" href="javascript:task();">' + lan.soft.sleep_install + '</a>'
}
pBody += '<tr>' +
'<td><span ' + titleClick + '><img src="/plugins/file?name=' + rdata.data[i].name + "&f=ico.png"+ '">' + rdata.data[i].title + '-' + rdata.data[i].versions + '</span></td>'
//+'<td>'+rdata.data[i].versions[n].no+'</td>'
//+'<td>'+rdata.data[i].type+'</td>'
+
'<td>' + pps + '</td>' +
'<td>' + softPath + '</td>' +
'<td>' + state + '</td>' +
'<td>' + indexshow + '</td>' +
'<td style="text-align: right;">' + handle + '</td>' +
'</tr>'
}
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: "<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>" + lan.soft.install_version + "<span style='margin-left:30px'>" + name + " " + version + "</span>" + optw + "</div>\
<div class='fangshi line'>" + lan.bt.install_type + "<label data-title='" + lan.bt.install_rpm_title + "'>" + lan.bt.install_rpm + "<input type='checkbox' checked></label><label data-title='" + lan.bt.install_src_title + "'>" + lan.bt.install_src + "<input type='checkbox'></label></div>\
<div class='fangshi line'>" + lan.bt.install_type + "<label data-title='" + lan.bt.install_rpm_title + "'>极速安装<input type='checkbox' checked></label><label data-title='" + lan.bt.install_src_title + "'><input type='checkbox'></label></div>\
<div class='bt-form-submit-btn'>\
<button type='button' class='btn btn-danger btn-sm btn-title one-close'>" + lan.public.close + "</button>\
<button type='button' id='bi-btn' class='btn btn-success btn-sm btn-title bi-btn'>" + lan.public.submit + "</button>\
<button type='button' class='btn btn-danger btn-sm btn-title one-close'>关闭</button>\
<button type='button' id='bi-btn' class='btn btn-success btn-sm btn-title bi-btn'>提交</button>\
</div>\
</div>"
})

@ -39,9 +39,7 @@
<form>
<div class="ss-text pull-left">
<em>启用SSH</em>
<div class='ssh-item' id="in_safe">
</div>
<div class='ssh-item' id="in_safe"></div>
</div>
</form>
</div>
@ -134,6 +132,5 @@
</div>
</div>
</div>
<script src="/static/js/firewall.js?date=20170920"></script>
<script src="/static/js/firewall.js?v={{config.version}}"></script>
{% endblock %}
Loading…
Cancel
Save