diff --git a/plugins/php/conf/php-fpm.conf b/plugins/php/conf/php-fpm.conf index 520a62edf..e451c6e9d 100644 --- a/plugins/php/conf/php-fpm.conf +++ b/plugins/php/conf/php-fpm.conf @@ -1,5 +1,6 @@ [global] +request_terminate_timeout = 30 include={$SERVER_PATH}/php/{$PHP_VERSION}/etc/php-fpm.d/*.conf ;php_value[auto_prepend_file]={$SERVER_PATH}/md_start.php ;php_value[auto_append_file]={$SERVER_PATH}/md_end.php \ No newline at end of file diff --git a/plugins/php/index.html b/plugins/php/index.html index fa5bc54fa..b6a757cc0 100755 --- a/plugins/php/index.html +++ b/plugins/php/index.html @@ -5,8 +5,8 @@
服务
安装扩展
配置修改
-上传限制
-超时限制
+上传限制
+超时限制
配置文件
禁用函数
性能调整
diff --git a/plugins/php/index.py b/plugins/php/index.py index fe46fa648..06a597358 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -200,6 +200,95 @@ def submitPhpConf(version): return public.returnJson(True, '设置成功') +def getLimitConf(version): + fileini = getServerDir() + "/" + version + "/etc/php.ini" + phpini = public.readFile(fileini) + filefpm = getServerDir() + "/" + version + "/etc/php-fpm.conf" + phpfpm = public.readFile(filefpm) + + # print fileini, filefpm + data = {} + try: + rep = "upload_max_filesize\s*=\s*([0-9]+)M" + tmp = re.search(rep, phpini).groups() + data['max'] = tmp[0] + except: + data['max'] = '50' + + try: + rep = "request_terminate_timeout\s*=\s*([0-9]+)\n" + tmp = re.search(rep, phpfpm).groups() + data['maxTime'] = tmp[0] + except: + data['maxTime'] = 0 + + try: + rep = r"\n;*\s*cgi\.fix_pathinfo\s*=\s*([0-9]+)\s*\n" + tmp = re.search(rep, phpini).groups() + + if tmp[0] == '1': + data['pathinfo'] = True + else: + data['pathinfo'] = False + except: + data['pathinfo'] = False + + return public.getJson(data) + + +def setMaxTime(version): + args = getArgs() + if not 'time' in args: + return 'missing time args!' + time = args['time'] + if int(time) < 30 or int(time) > 86400: + return public.returnJson(False, '请填写30-86400间的值!') + + filefpm = getServerDir() + "/" + version + "/etc/php-fpm.conf" + conf = public.readFile(filefpm) + rep = "request_terminate_timeout\s*=\s*([0-9]+)\n" + conf = re.sub(rep, "request_terminate_timeout = " + time + "\n", conf) + public.writeFile(filefpm, conf) + + fileini = getServerDir() + "/" + version + "/etc/php.ini" + phpini = public.readFile(fileini) + rep = "max_execution_time\s*=\s*([0-9]+)\r?\n" + phpini = re.sub(rep, "max_execution_time = " + time + "\n", phpini) + rep = "max_input_time\s*=\s*([0-9]+)\r?\n" + phpini = re.sub(rep, "max_input_time = " + time + "\n", phpini) + public.writeFile(fileini, phpini) + return public.returnJson(True, '设置成功!') + + +def setMaxSize(version): + args = getArgs() + if not 'max' in args: + return 'missing time args!' + max = args['max'] + if int(max) < 2: + return public.returnJson(False, '上传大小限制不能小于2MB!') + + path = getServerDir() + '/' + version + '/etc/php.ini' + conf = public.readFile(path) + rep = u"\nupload_max_filesize\s*=\s*[0-9]+M" + conf = re.sub(rep, u'\nupload_max_filesize = ' + max + 'M', conf) + rep = u"\npost_max_size\s*=\s*[0-9]+M" + conf = re.sub(rep, u'\npost_max_size = ' + max + 'M', conf) + public.writeFile(path, conf) + + # if public.get_webserver() == 'nginx': + # path = web.ctx.session.setupPath + '/nginx/conf/nginx.conf' + # conf = public.readFile(path) + # rep = "client_max_body_size\s+([0-9]+)m" + # tmp = re.search(rep, conf).groups() + # if int(tmp[0]) < int(max): + # conf = re.sub(rep, 'client_max_body_size ' + max + 'm', conf) + # public.writeFile(path, conf) + + public.writeLog("TYPE_PHP", "PHP_UPLOAD_MAX", (version, max)) + return public.returnJson(True, '设置成功!') + + if __name__ == "__main__": if len(sys.argv) < 3: @@ -229,5 +318,11 @@ if __name__ == "__main__": print getPhpConf(version) elif func == 'submit_php_conf': print submitPhpConf(version) + elif func == 'get_limit_conf': + print getLimitConf(version) + elif func == 'set_max_time': + print setMaxTime(version) + elif func == 'set_max_size': + print setMaxSize(version) else: print "fail" diff --git a/plugins/php/js/php.js b/plugins/php/js/php.js index 42c9fbd93..d530408c5 100755 --- a/plugins/php/js/php.js +++ b/plugins/php/js/php.js @@ -87,203 +87,62 @@ function submitConf(version) { } -//软件管理 -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 = [ - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '' - ] - - 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: 'MB
'; + $(".soft-man-con").html(LimitCon); } -//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 = ''; - $(".soft-man-con").html(phpCon); - var ob = document.getElementById('error_log'); - ob.scrollTop = ob.scrollHeight; + +//php超时限制 +function phpTimeLimitReq(version){ + phpPost('get_limit_conf', version, '', function(ret_data){ + var rdata = $.parseJSON(ret_data.data); + phpTimeLimit(version,rdata['maxTime']); }); } - - -//php超时限制 function phpTimeLimit(version, max) { - var LimitCon = '' + lan.bt.s + '
'; + var LimitCon = '秒
'; $(".soft-man-con").html(LimitCon); } + //设置超时限制 -function SetPHPMaxTime(version) { +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); + phpPost('set_max_time',version,{'time':max},function(data){ + var rdata = $.parseJSON(data.data); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); }); } //设置PHP上传限制 -function SetPHPMaxSize(version) { +function setPHPMaxSize(version) { max = $(".phpUploadLimit").val(); if (max < 2) { alert(max); - layer.msg(lan.soft.php_upload_size, { icon: 2 }); + layer.msg('上传大小限制不能小于2M', { 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); + + phpPost('set_max_size',version,{'max':max},function(data){ + var rdata = $.parseJSON(data.data); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); - }) -} -//配置修改 -function configChange(type) { - var con = '' + lan.bt.edit_ps + '
\ - \ -MB
'; - $(".soft-man-con").html(LimitCon); -} + function GetPHPStatus(a) { if(a == "52") { @@ -657,7 +512,7 @@ function GetPHPStatus(a) { closeBtn: 2, shift: 5, shadeClose: true, - content: ""+lan.bt.php_pool+" | " + b.pool + " |
---|---|
"+lan.bt.php_manager+" | " + ((b["process manager"] == "dynamic") ? lan.bt.dynamic : lan.bt.static) + " |
"+lan.bt.php_start+" | " + b["start time"] + " |
"+lan.bt.php_accepted+" | " + b["accepted conn"] + " |
"+lan.bt.php_queue+" | " + b["listen queue"] + " |
"+lan.bt.php_max_queue+" | " + b["max listen queue"] + " |
"+lan.bt.php_len_queue+" | " + b["listen queue len"] + " |
"+lan.bt.php_idle+" | " + b["idle processes"] + " |
"+lan.bt.php_active+" | " + b["active processes"] + " |
"+lan.bt.php_total+" | " + b["total processes"] + " |
"+lan.bt.php_max_active+" | " + b["max active processes"] + " |
"+lan.bt.php_max_children+" | " + b["max children reached"] + " |
"+lan.bt.php_slow+" | " + b["slow requests"] + " |
"+lan.bt.php_pool+" | " + b.pool + " |
---|---|
"+lan.bt.php_manager+" | " + ((b["process manager"] == "dynamic") ? lan.bt.dynamic : lan.bt.static) + " |
"+lan.bt.php_start+" | " + b["start time"] + " |
"+lan.bt.php_accepted+" | " + b["accepted conn"] + " |
"+lan.bt.php_queue+" | " + b["listen queue"] + " |
"+lan.bt.php_max_queue+" | " + b["max listen queue"] + " |
"+lan.bt.php_len_queue+" | " + b["listen queue len"] + " |
"+lan.bt.php_idle+" | " + b["idle processes"] + " |
"+lan.bt.php_active+" | " + b["active processes"] + " |
"+lan.bt.php_total+" | " + b["total processes"] + " |
"+lan.bt.php_max_active+" | " + b["max active processes"] + " |
"+lan.bt.php_max_children+" | " + b["max children reached"] + " |
"+lan.bt.php_slow+" | " + b["slow requests"] + " |