mdserver-web/plugins/php/index.py

1044 lines
32 KiB
Python
Raw Permalink Normal View History

2018-11-26 00:57:06 -05:00
# coding:utf-8
import sys
import io
import os
import time
2018-12-18 02:13:33 -05:00
import re
2018-12-18 06:37:46 -05:00
import json
import shutil
2018-12-18 02:13:33 -05:00
2021-05-09 12:15:29 -04:00
# reload(sys)
# sys.setdefaultencoding('utf8')
2018-11-26 00:57:06 -05:00
sys.path.append(os.getcwd() + "/class/core")
2021-05-09 12:15:29 -04:00
# sys.path.append("/usr/local/lib/python3.6/site-packages")
2019-03-04 06:45:06 -05:00
2020-07-10 03:57:25 -04:00
import mw
2018-11-26 00:57:06 -05:00
2021-11-12 04:50:44 -05:00
if mw.isAppleSystem():
cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\''
info = mw.execShell(cmd)
p = "/usr/local/lib/" + info[0].strip() + "/site-packages"
sys.path.append(p)
2018-12-08 04:09:36 -05:00
app_debug = False
2020-07-10 03:57:25 -04:00
if mw.isAppleSystem():
2018-12-08 04:09:36 -05:00
app_debug = True
def getPluginName():
2018-12-09 07:31:39 -05:00
return 'php'
2018-12-08 04:09:36 -05:00
def getPluginDir():
2020-07-10 03:57:25 -04:00
return mw.getPluginDir() + '/' + getPluginName()
2018-12-08 04:09:36 -05:00
def getServerDir():
2020-07-10 03:57:25 -04:00
return mw.getServerDir() + '/' + getPluginName()
2018-12-08 04:09:36 -05:00
2019-03-15 03:23:54 -04:00
def getInitDFile(version):
2018-12-08 04:09:36 -05:00
if app_debug:
return '/tmp/' + getPluginName()
2019-07-31 11:45:28 -04:00
return '/etc/init.d/' + getPluginName() + version
2018-12-08 04:09:36 -05:00
2018-11-26 00:57:06 -05:00
2018-12-09 10:30:54 -05:00
def getArgs():
2018-12-18 02:13:33 -05:00
args = sys.argv[3:]
2018-12-09 10:30:54 -05:00
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
2019-01-13 10:51:09 -05:00
def checkArgs(data, ck=[]):
for i in range(len(ck)):
if not ck[i] in data:
2020-07-10 03:57:25 -04:00
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
2019-01-13 10:51:09 -05:00
2018-12-09 10:30:54 -05:00
def getConf(version):
2018-12-18 00:43:24 -05:00
path = getServerDir() + '/' + version + '/etc/php.ini'
2018-12-09 10:30:54 -05:00
return path
2022-07-07 22:14:27 -04:00
def getFpmConfFile(version):
return getServerDir() + '/' + version + '/etc/php-fpm.d/www.conf'
2022-07-11 12:01:17 -04:00
def status_progress(version):
2022-06-18 02:53:10 -04:00
# ps -ef|grep 'php/81' |grep -v grep | grep -v python | awk '{print $2}
2018-12-10 02:32:31 -05:00
cmd = "ps -ef|grep 'php/" + version + \
"' |grep -v grep | grep -v python | awk '{print $2}'"
2020-07-10 03:57:25 -04:00
data = mw.execShell(cmd)
2018-11-26 00:57:06 -05:00
if data[0] == '':
return 'stop'
return 'start'
2022-07-11 12:01:17 -04:00
def getPhpSocket(version):
path = getFpmConfFile(version)
content = mw.readFile(path)
rep = 'listen\s*=\s*(.*)'
tmp = re.search(rep, content)
return tmp.groups()[0].strip()
def status(version):
'''
sock文件判断是否启动
'''
sock = getPhpSocket(version)
if sock.find(':'):
return status_progress(version)
if not os.path.exists(sock):
return 'stop'
return 'start'
2018-12-10 03:18:35 -05:00
def contentReplace(content, version):
2020-07-10 03:57:25 -04:00
service_path = mw.getServerDir()
content = content.replace('{$ROOT_PATH}', mw.getRootDir())
2018-12-10 03:18:35 -05:00
content = content.replace('{$SERVER_PATH}', service_path)
content = content.replace('{$PHP_VERSION}', version)
2020-07-14 20:49:30 -04:00
content = content.replace('{$LOCAL_IP}', mw.getLocalIp())
2022-11-20 21:42:36 -05:00
content = content.replace('{$SSL_CRT}', mw.getSslCrt())
2018-12-18 06:43:41 -05:00
2020-07-10 03:57:25 -04:00
if mw.isAppleSystem():
# user = mw.execShell(
2018-12-18 21:34:18 -05:00
# "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
content = content.replace('{$PHP_USER}', 'nobody')
content = content.replace('{$PHP_GROUP}', 'nobody')
2018-12-27 06:00:15 -05:00
rep = 'listen.owner\s*=\s*(.+)\r?\n'
val = ';listen.owner = nobody\n'
content = re.sub(rep, val, content)
rep = 'listen.group\s*=\s*(.+)\r?\n'
val = ';listen.group = nobody\n'
content = re.sub(rep, val, content)
2018-12-18 21:34:18 -05:00
rep = 'user\s*=\s*(.+)\r?\n'
val = ';user = nobody\n'
content = re.sub(rep, val, content)
2018-12-27 06:11:08 -05:00
rep = r'[^\.]group\s*=\s*(.+)\r?\n'
2018-12-18 21:34:18 -05:00
val = ';group = nobody\n'
content = re.sub(rep, val, content)
2018-12-27 06:00:15 -05:00
2018-12-18 06:43:41 -05:00
else:
content = content.replace('{$PHP_USER}', 'www')
content = content.replace('{$PHP_GROUP}', 'www')
2018-12-10 03:18:35 -05:00
return content
2018-12-18 06:37:46 -05:00
def makeOpenrestyConf():
2020-09-26 07:43:04 -04:00
phpversions = ['00', '52', '53', '54', '55', '56',
2022-08-14 08:53:15 -04:00
'70', '71', '72', '73', '74', '80', '81', '82']
2022-06-28 12:39:10 -04:00
sdir = mw.getServerDir()
dst_dir = sdir + '/web_conf/php'
dst_dir_conf = sdir + '/web_conf/php/conf'
if not os.path.exists(dst_dir):
mw.execShell('mkdir -p ' + dst_dir)
if not os.path.exists(dst_dir_conf):
mw.execShell('mkdir -p ' + dst_dir_conf)
d_pathinfo = sdir + '/web_conf/php/pathinfo.conf'
if not os.path.exists(d_pathinfo):
s_pathinfo = getPluginDir() + '/conf/pathinfo.conf'
shutil.copyfile(s_pathinfo, d_pathinfo)
info = getPluginDir() + '/info.json'
content = mw.readFile(info)
content = json.loads(content)
versions = content['versions']
tpl = getPluginDir() + '/conf/enable-php.conf'
tpl_content = mw.readFile(tpl)
for x in phpversions:
dfile = sdir + '/web_conf/php/conf/enable-php-' + x + '.conf'
if not os.path.exists(dfile):
if x == '00':
2022-07-04 21:04:14 -04:00
mw.writeFile(dfile, 'set $PHP_ENV 0;')
2022-06-28 12:39:10 -04:00
else:
w_content = contentReplace(tpl_content, x)
mw.writeFile(dfile, w_content)
# php-fpm status
# for version in phpversions:
# dfile = sdir + '/web_conf/php/status/phpfpm_status_' + version + '.conf'
# tpl = getPluginDir() + '/conf/phpfpm_status.conf'
# if not os.path.exists(dfile):
# content = mw.readFile(tpl)
# content = contentReplace(content, version)
# mw.writeFile(dfile, content)
2018-12-18 06:37:46 -05:00
2019-07-31 11:45:28 -04:00
2020-07-12 06:14:56 -04:00
def phpPrependFile(version):
app_start = getServerDir() + '/app_start.php'
if not os.path.exists(app_start):
tpl = getPluginDir() + '/conf/app_start.php'
content = mw.readFile(tpl)
content = contentReplace(content, version)
mw.writeFile(app_start, content)
2018-12-10 03:18:35 -05:00
def phpFpmReplace(version):
2018-12-18 06:50:57 -05:00
desc_php_fpm = getServerDir() + '/' + version + '/etc/php-fpm.conf'
if not os.path.exists(desc_php_fpm):
tpl_php_fpm = getPluginDir() + '/conf/php-fpm.conf'
2020-07-10 03:57:25 -04:00
content = mw.readFile(tpl_php_fpm)
2018-12-18 06:50:57 -05:00
content = contentReplace(content, version)
2020-07-10 03:57:25 -04:00
mw.writeFile(desc_php_fpm, content)
2020-09-26 07:50:40 -04:00
else:
if version == '52':
2020-09-26 08:01:27 -04:00
tpl_php_fpm = tpl_php_fpm = getPluginDir() + '/conf/php-fpm-52.conf'
content = mw.readFile(tpl_php_fpm)
2020-09-26 07:50:40 -04:00
mw.writeFile(desc_php_fpm, content)
2018-12-10 02:32:31 -05:00
def phpFpmWwwReplace(version):
2018-12-10 02:53:06 -05:00
service_php_fpm_dir = getServerDir() + '/' + version + '/etc/php-fpm.d/'
2018-12-18 06:50:57 -05:00
2018-12-10 02:53:06 -05:00
if not os.path.exists(service_php_fpm_dir):
os.mkdir(service_php_fpm_dir)
2018-12-18 21:34:18 -05:00
service_php_fpmwww = service_php_fpm_dir + '/www.conf'
if not os.path.exists(service_php_fpmwww):
2018-12-18 06:50:57 -05:00
tpl_php_fpmwww = getPluginDir() + '/conf/www.conf'
2020-07-10 03:57:25 -04:00
content = mw.readFile(tpl_php_fpmwww)
2018-12-18 06:50:57 -05:00
content = contentReplace(content, version)
2020-07-10 03:57:25 -04:00
mw.writeFile(service_php_fpmwww, content)
2018-12-10 02:32:31 -05:00
2018-12-18 10:22:08 -05:00
def makePhpIni(version):
2022-07-07 22:14:27 -04:00
dst_ini = getConf(version)
2022-06-18 02:40:06 -04:00
if not os.path.exists(dst_ini):
src_ini = getPluginDir() + '/conf/php' + version[0:1] + '.ini'
2020-09-29 14:48:16 -04:00
# shutil.copyfile(s_ini, d_ini)
2022-06-18 02:40:06 -04:00
content = mw.readFile(src_ini)
2020-09-29 14:48:16 -04:00
if version == '52':
2020-09-29 15:11:10 -04:00
content = content + "auto_prepend_file=/www/server/php/app_start.php"
2022-06-19 02:05:07 -04:00
content = contentReplace(content, version)
2022-06-18 02:40:06 -04:00
mw.writeFile(dst_ini, content)
2018-12-18 10:22:08 -05:00
2018-12-18 06:37:46 -05:00
def initReplace(version):
makeOpenrestyConf()
2018-12-18 10:22:08 -05:00
makePhpIni(version)
2018-11-26 00:57:06 -05:00
2018-12-09 10:30:54 -05:00
initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path):
os.mkdir(initD_path)
2018-12-19 10:37:31 -05:00
file_bin = initD_path + '/php' + version
if not os.path.exists(file_bin):
2018-12-18 06:50:57 -05:00
file_tpl = getPluginDir() + '/init.d/php.tpl'
if version == '52':
file_tpl = getPluginDir() + '/init.d/php52.tpl'
2020-07-10 03:57:25 -04:00
content = mw.readFile(file_tpl)
2018-12-18 06:50:57 -05:00
content = contentReplace(content, version)
2018-12-09 10:30:54 -05:00
2020-07-10 03:57:25 -04:00
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
2018-12-10 02:32:31 -05:00
2020-07-12 06:14:56 -04:00
phpPrependFile(version)
2018-12-10 02:53:06 -05:00
phpFpmWwwReplace(version)
2018-12-10 02:32:31 -05:00
phpFpmReplace(version)
2018-12-10 02:53:06 -05:00
2022-06-19 01:17:50 -04:00
session_path = getServerDir() + '/tmp/session'
2019-01-07 10:31:13 -05:00
if not os.path.exists(session_path):
2022-06-19 02:03:04 -04:00
mw.execShell('mkdir -p ' + session_path)
mw.execShell('chown -R www:www ' + session_path)
2020-07-16 04:30:00 -04:00
2022-06-19 01:17:50 -04:00
upload_path = getServerDir() + '/tmp/upload'
2020-07-16 04:30:00 -04:00
if not os.path.exists(upload_path):
2022-06-19 02:03:04 -04:00
mw.execShell('mkdir -p ' + upload_path)
mw.execShell('chown -R www:www ' + upload_path)
2022-06-18 02:40:06 -04:00
# systemd
2022-07-11 01:49:25 -04:00
systemDir = mw.systemdCfgDir()
2022-06-18 02:40:06 -04:00
systemService = systemDir + '/php' + version + '.service'
systemServiceTpl = getPluginDir() + '/init.d/php.service.tpl'
2022-07-05 22:27:24 -04:00
if version == '52':
systemServiceTpl = getPluginDir() + '/init.d/php.service.52.tpl'
2022-06-18 02:40:06 -04:00
if os.path.exists(systemDir) and not os.path.exists(systemService):
service_path = mw.getServerDir()
se_content = mw.readFile(systemServiceTpl)
se_content = se_content.replace('{$VERSION}', version)
se_content = se_content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(systemService, se_content)
mw.execShell('systemctl daemon-reload')
2018-12-09 10:30:54 -05:00
return file_bin
def phpOp(version, method):
2018-12-18 06:37:46 -05:00
file = initReplace(version)
2022-06-18 02:40:06 -04:00
if not mw.isAppleSystem():
2022-07-05 21:14:30 -04:00
if method == 'stop' or method == 'restart':
mw.execShell(file + ' ' + 'stop')
2022-06-18 02:40:06 -04:00
data = mw.execShell('systemctl ' + method + ' php' + version)
if data[1] == '':
return 'ok'
2022-07-03 00:11:09 -04:00
return data[1]
2022-06-18 02:40:06 -04:00
2020-07-10 03:57:25 -04:00
data = mw.execShell(file + ' ' + method)
2018-12-09 10:30:54 -05:00
if data[1] == '':
2018-11-26 00:57:06 -05:00
return 'ok'
2018-12-18 06:37:46 -05:00
return data[1]
2018-11-26 00:57:06 -05:00
2018-12-09 10:30:54 -05:00
def start(version):
return phpOp(version, 'start')
def stop(version):
2022-07-03 06:54:19 -04:00
status = phpOp(version, 'stop')
if version == '52':
file = initReplace(version)
data = mw.execShell(file + ' ' + 'stop')
2022-07-03 06:55:52 -04:00
if data[1] == '':
return 'ok'
2022-07-03 06:54:19 -04:00
return status
2018-12-09 10:30:54 -05:00
2018-11-26 00:57:06 -05:00
2018-12-09 10:30:54 -05:00
def restart(version):
return phpOp(version, 'restart')
2018-11-26 00:57:06 -05:00
2018-12-09 10:30:54 -05:00
def reload(version):
2022-07-05 22:28:15 -04:00
if version == '52':
return phpOp(version, 'restart')
return phpOp(version, 'reload')
2018-11-26 00:57:06 -05:00
2018-12-09 10:30:54 -05:00
2019-03-15 03:23:54 -04:00
def initdStatus(version):
2022-06-18 02:40:06 -04:00
if mw.isAppleSystem():
return "Apple Computer does not support"
2022-06-18 09:46:52 -04:00
shell_cmd = 'systemctl status php' + version + ' | grep loaded | grep "enabled;"'
2022-06-18 02:40:06 -04:00
data = mw.execShell(shell_cmd)
if data[0] == '':
return 'fail'
return 'ok'
2019-03-15 03:23:54 -04:00
def initdInstall(version):
2022-06-18 02:40:06 -04:00
if mw.isAppleSystem():
return "Apple Computer does not support"
2022-06-18 12:08:24 -04:00
mw.execShell('systemctl enable php' + version)
2019-03-15 03:23:54 -04:00
return 'ok'
def initdUinstall(version):
2022-06-18 02:40:06 -04:00
if mw.isAppleSystem():
return "Apple Computer does not support"
2019-07-31 11:45:28 -04:00
2022-06-18 12:08:24 -04:00
mw.execShell('systemctl disable php' + version)
2019-03-15 03:23:54 -04:00
return 'ok'
2018-12-18 02:23:48 -05:00
def fpmLog(version):
return getServerDir() + '/' + version + '/var/log/php-fpm.log'
def fpmSlowLog(version):
2018-12-19 02:50:07 -05:00
return getServerDir() + '/' + version + '/var/log/www-slow.log'
2018-12-18 02:23:48 -05:00
2018-12-18 02:13:33 -05:00
def getPhpConf(version):
gets = [
{'name': 'short_open_tag', 'type': 1, 'ps': '短标签支持'},
{'name': 'asp_tags', 'type': 1, 'ps': 'ASP标签支持'},
{'name': 'max_execution_time', 'type': 2, 'ps': '最大脚本运行时间'},
{'name': 'max_input_time', 'type': 2, 'ps': '最大输入时间'},
2022-07-05 12:36:33 -04:00
{'name': 'max_input_vars', 'type': 2, 'ps': '最大输入数量'},
2018-12-18 02:13:33 -05:00
{'name': 'memory_limit', 'type': 2, 'ps': '脚本内存限制'},
{'name': 'post_max_size', 'type': 2, 'ps': 'POST数据最大尺寸'},
{'name': 'file_uploads', 'type': 1, 'ps': '是否允许上传文件'},
{'name': 'upload_max_filesize', 'type': 2, 'ps': '允许上传文件的最大尺寸'},
{'name': 'max_file_uploads', 'type': 2, 'ps': '允许同时上传文件的最大数量'},
{'name': 'default_socket_timeout', 'type': 2, 'ps': 'Socket超时时间'},
{'name': 'error_reporting', 'type': 3, 'ps': '错误级别'},
{'name': 'display_errors', 'type': 1, 'ps': '是否输出详细错误信息'},
{'name': 'cgi.fix_pathinfo', 'type': 0, 'ps': '是否开启pathinfo'},
{'name': 'date.timezone', 'type': 3, 'ps': '时区'}
2018-11-26 00:57:06 -05:00
]
2022-07-07 22:14:27 -04:00
phpini = mw.readFile(getConf(version))
2018-12-18 02:13:33 -05:00
result = []
for g in gets:
rep = g['name'] + '\s*=\s*([0-9A-Za-z_& ~]+)(\s*;?|\r?\n)'
tmp = re.search(rep, phpini)
if not tmp:
2018-11-26 00:57:06 -05:00
continue
2018-12-18 02:13:33 -05:00
g['value'] = tmp.groups()[0]
result.append(g)
2020-07-10 03:57:25 -04:00
return mw.getJson(result)
2018-11-26 00:57:06 -05:00
2018-12-18 02:13:33 -05:00
def submitPhpConf(version):
gets = ['display_errors', 'cgi.fix_pathinfo', 'date.timezone', 'short_open_tag',
2022-07-05 12:36:33 -04:00
'asp_tags', 'max_execution_time', 'max_input_time', 'max_input_vars', 'memory_limit',
2018-12-18 02:13:33 -05:00
'post_max_size', 'file_uploads', 'upload_max_filesize', 'max_file_uploads',
'default_socket_timeout', 'error_reporting']
args = getArgs()
filename = getServerDir() + '/' + version + '/etc/php.ini'
2020-07-10 03:57:25 -04:00
phpini = mw.readFile(filename)
2018-12-18 02:13:33 -05:00
for g in gets:
if g in args:
rep = g + '\s*=\s*(.+)\r?\n'
val = g + ' = ' + args[g] + '\n'
phpini = re.sub(rep, val, phpini)
2020-07-10 03:57:25 -04:00
mw.writeFile(filename, phpini)
2022-07-05 12:36:33 -04:00
# mw.execShell(getServerDir() + '/init.d/php' + version + ' reload')
reload(version)
2020-07-10 03:57:25 -04:00
return mw.returnJson(True, '设置成功')
2018-12-18 02:13:33 -05:00
2018-12-18 05:09:54 -05:00
def getLimitConf(version):
2022-07-07 22:14:27 -04:00
fileini = getConf(version)
2020-07-10 03:57:25 -04:00
phpini = mw.readFile(fileini)
2022-07-07 22:14:27 -04:00
filefpm = getFpmConfFile(version)
2020-07-10 03:57:25 -04:00
phpfpm = mw.readFile(filefpm)
2018-12-18 05:09:54 -05:00
# 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
2020-07-10 03:57:25 -04:00
return mw.getJson(data)
2018-12-18 05:09:54 -05:00
def setMaxTime(version):
args = getArgs()
2019-01-13 10:51:09 -05:00
data = checkArgs(args, ['time'])
if not data[0]:
return data[1]
2018-12-18 05:09:54 -05:00
time = args['time']
if int(time) < 30 or int(time) > 86400:
2020-07-10 03:57:25 -04:00
return mw.returnJson(False, '请填写30-86400间的值!')
2018-12-18 05:09:54 -05:00
2022-07-07 22:14:27 -04:00
filefpm = getFpmConfFile(version)
2020-07-10 03:57:25 -04:00
conf = mw.readFile(filefpm)
2018-12-18 05:09:54 -05:00
rep = "request_terminate_timeout\s*=\s*([0-9]+)\n"
conf = re.sub(rep, "request_terminate_timeout = " + time + "\n", conf)
2020-07-10 03:57:25 -04:00
mw.writeFile(filefpm, conf)
2018-12-18 05:09:54 -05:00
fileini = getServerDir() + "/" + version + "/etc/php.ini"
2020-07-10 03:57:25 -04:00
phpini = mw.readFile(fileini)
2018-12-18 05:09:54 -05:00
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)
2020-07-10 03:57:25 -04:00
mw.writeFile(fileini, phpini)
return mw.returnJson(True, '设置成功!')
2018-12-18 05:09:54 -05:00
def setMaxSize(version):
args = getArgs()
2022-07-03 00:16:43 -04:00
data = checkArgs(args, ['max'])
if not data[0]:
return data[1]
maxVal = args['max']
if int(maxVal) < 2:
2020-07-10 03:57:25 -04:00
return mw.returnJson(False, '上传大小限制不能小于2MB!')
2018-12-18 05:09:54 -05:00
2022-07-07 22:14:27 -04:00
path = getConf(version)
2020-07-10 03:57:25 -04:00
conf = mw.readFile(path)
2018-12-18 05:09:54 -05:00
rep = u"\nupload_max_filesize\s*=\s*[0-9]+M"
2022-07-03 00:16:43 -04:00
conf = re.sub(rep, u'\nupload_max_filesize = ' + maxVal + 'M', conf)
2018-12-18 05:09:54 -05:00
rep = u"\npost_max_size\s*=\s*[0-9]+M"
2022-07-03 00:16:43 -04:00
conf = re.sub(rep, u'\npost_max_size = ' + maxVal + 'M', conf)
2020-07-10 03:57:25 -04:00
mw.writeFile(path, conf)
2018-12-18 05:09:54 -05:00
2022-07-03 00:16:43 -04:00
msg = mw.getInfo('设置PHP-{1}最大上传大小为[{2}MB]!', (version, maxVal,))
2020-07-10 03:57:25 -04:00
mw.writeLog('插件管理[PHP]', msg)
return mw.returnJson(True, '设置成功!')
2018-12-18 05:09:54 -05:00
2018-12-19 00:54:19 -05:00
def getFpmConfig(version):
filefpm = getServerDir() + '/' + version + '/etc/php-fpm.d/www.conf'
2020-07-10 03:57:25 -04:00
conf = mw.readFile(filefpm)
2018-12-19 00:54:19 -05:00
data = {}
rep = "\s*pm.max_children\s*=\s*([0-9]+)\s*"
tmp = re.search(rep, conf).groups()
data['max_children'] = tmp[0]
rep = "\s*pm.start_servers\s*=\s*([0-9]+)\s*"
tmp = re.search(rep, conf).groups()
data['start_servers'] = tmp[0]
rep = "\s*pm.min_spare_servers\s*=\s*([0-9]+)\s*"
tmp = re.search(rep, conf).groups()
data['min_spare_servers'] = tmp[0]
rep = "\s*pm.max_spare_servers \s*=\s*([0-9]+)\s*"
tmp = re.search(rep, conf).groups()
data['max_spare_servers'] = tmp[0]
rep = "\s*pm\s*=\s*(\w+)\s*"
tmp = re.search(rep, conf).groups()
data['pm'] = tmp[0]
2020-07-10 03:57:25 -04:00
return mw.getJson(data)
2018-12-19 00:54:19 -05:00
def setFpmConfig(version):
args = getArgs()
# if not 'max' in args:
# return 'missing time args!'
version = args['version']
max_children = args['max_children']
start_servers = args['start_servers']
min_spare_servers = args['min_spare_servers']
max_spare_servers = args['max_spare_servers']
pm = args['pm']
file = getServerDir() + '/' + version + '/etc/php-fpm.d/www.conf'
2020-07-10 03:57:25 -04:00
conf = mw.readFile(file)
2018-12-19 00:54:19 -05:00
rep = "\s*pm.max_children\s*=\s*([0-9]+)\s*"
conf = re.sub(rep, "\npm.max_children = " + max_children, conf)
rep = "\s*pm.start_servers\s*=\s*([0-9]+)\s*"
conf = re.sub(rep, "\npm.start_servers = " + start_servers, conf)
rep = "\s*pm.min_spare_servers\s*=\s*([0-9]+)\s*"
conf = re.sub(rep, "\npm.min_spare_servers = " +
min_spare_servers, conf)
rep = "\s*pm.max_spare_servers \s*=\s*([0-9]+)\s*"
conf = re.sub(rep, "\npm.max_spare_servers = " +
max_spare_servers + "\n", conf)
rep = "\s*pm\s*=\s*(\w+)\s*"
conf = re.sub(rep, "\npm = " + pm + "\n", conf)
2020-07-10 03:57:25 -04:00
mw.writeFile(file, conf)
2018-12-19 03:50:15 -05:00
reload(version)
2020-07-10 03:57:25 -04:00
msg = mw.getInfo('设置PHP-{1}并发设置,max_children={2},start_servers={3},min_spare_servers={4},max_spare_servers={5}', (version, max_children,
start_servers, min_spare_servers, max_spare_servers,))
mw.writeLog('插件管理[PHP]', msg)
return mw.returnJson(True, '设置成功!')
2018-12-19 00:54:19 -05:00
# def checkFpmStatusFile(version):
# if not mw.isInstalledWeb():
# return False
2022-06-22 15:14:35 -04:00
# dfile = getServerDir() + '/nginx/conf/php_status/phpfpm_status_' + version + '.conf'
# if not os.path.exists(dfile):
# tpl = getPluginDir() + '/conf/phpfpm_status.conf'
# content = mw.readFile(tpl)
# content = contentReplace(content, version)
# mw.writeFile(dfile, content)
# mw.restartWeb()
# return True
def getFpmAddress(version):
fpm_address = '/tmp/php-cgi-{}.sock'.format(version)
php_fpm_file = getFpmConfFile(version)
try:
content = readFile(php_fpm_file)
tmp = re.findall(r"listen\s*=\s*(.+)", content)
if not tmp:
return fpm_address
if tmp[0].find('sock') != -1:
return fpm_address
if tmp[0].find(':') != -1:
listen_tmp = tmp[0].split(':')
if bind:
fpm_address = (listen_tmp[0], int(listen_tmp[1]))
else:
fpm_address = ('127.0.0.1', int(listen_tmp[1]))
else:
fpm_address = ('127.0.0.1', int(tmp[0]))
return fpm_address
except:
return fpm_address
2018-12-19 02:41:00 -05:00
2018-12-19 02:21:31 -05:00
def getFpmStatus(version):
2022-07-04 21:56:36 -04:00
if version == '52':
return mw.returnJson(False, 'PHP[' + version + ']不支持!!!')
2022-06-22 14:49:49 -04:00
2022-06-28 06:24:59 -04:00
stat = status(version)
if stat == 'stop':
return mw.returnJson(False, 'PHP[' + version + ']未启动!!!')
sock_file = getFpmAddress(version)
2022-06-22 14:49:49 -04:00
try:
sock_data = mw.requestFcgiPHP(
sock_file, '/phpfpm_status_' + version + '?json')
2022-06-22 15:20:45 -04:00
except Exception as e:
return mw.returnJson(False, str(e))
2022-06-22 14:49:49 -04:00
# print(data)
result = str(sock_data, encoding='utf-8')
data = json.loads(result)
fTime = time.localtime(int(data['start time']))
data['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime)
2022-06-28 06:24:59 -04:00
return mw.returnJson(True, "OK", data)
2018-12-19 02:21:31 -05:00
2018-12-19 03:50:15 -05:00
2022-10-10 07:54:23 -04:00
def getSessionConf(version):
filename = getConf(version)
if not os.path.exists(filename):
return mw.returnJson(False, '指定PHP版本不存在!')
phpini = mw.readFile(filename)
rep = r'session.save_handler\s*=\s*([0-9A-Za-z_& ~]+)(\s*;?|\r?\n)'
save_handler = re.search(rep, phpini)
if save_handler:
save_handler = save_handler.group(1)
else:
save_handler = "files"
reppath = r'\nsession.save_path\s*=\s*"tcp\:\/\/([\d\.]+):(\d+).*\r?\n'
passrep = r'\nsession.save_path\s*=\s*"tcp://[\w\.\?\:]+=(.*)"\r?\n'
memcached = r'\nsession.save_path\s*=\s*"([\d\.]+):(\d+)"'
save_path = re.search(reppath, phpini)
if not save_path:
save_path = re.search(memcached, phpini)
passwd = re.search(passrep, phpini)
port = ""
if passwd:
passwd = passwd.group(1)
else:
passwd = ""
if save_path:
port = save_path.group(2)
save_path = save_path.group(1)
else:
save_path = ""
data = {"save_handler": save_handler, "save_path": save_path,
"passwd": passwd, "port": port}
return mw.returnJson(True, 'ok', data)
def setSessionConf(version):
args = getArgs()
ip = args['ip']
port = args['port']
passwd = args['passwd']
save_handler = args['save_handler']
2022-10-24 08:18:34 -04:00
if save_handler != "files":
2022-10-10 07:54:23 -04:00
iprep = r"(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})\.(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})\.(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})\.(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})"
if not re.search(iprep, ip):
return mw.returnJson(False, '请输入正确的IP地址')
try:
port = int(port)
if port >= 65535 or port < 1:
return mw.returnJson(False, '请输入正确的端口号')
except:
return mw.returnJson(False, '请输入正确的端口号')
prep = r"[\~\`\/\=]"
if re.search(prep, passwd):
return mw.returnJson(False, '请不要输入以下特殊字符 " ~ ` / = "')
filename = getConf(version)
if not os.path.exists(filename):
return mw.returnJson(False, '指定PHP版本不存在!')
phpini = mw.readFile(filename)
session_tmp = getServerDir() + "/tmp/session"
rep = r'session.save_handler\s*=\s*(.+)\r?\n'
val = r'session.save_handler = ' + save_handler + '\n'
phpini = re.sub(rep, val, phpini)
if save_handler == "memcached":
if not re.search("memcached.so", phpini):
return mw.returnJson(False, '请先安装%s扩展' % save_handler)
rep = r'\nsession.save_path\s*=\s*(.+)\r?\n'
val = r'\nsession.save_path = "%s:%s" \n' % (ip, port)
if re.search(rep, phpini):
phpini = re.sub(rep, val, phpini)
else:
phpini = re.sub('\n;session.save_path = "' + session_tmp + '"',
'\n;session.save_path = "' + session_tmp + '"' + val, phpini)
if save_handler == "memcache":
if not re.search("memcache.so", phpini):
return mw.returnJson(False, '请先安装%s扩展' % save_handler)
rep = r'\nsession.save_path\s*=\s*(.+)\r?\n'
val = r'\nsession.save_path = "%s:%s" \n' % (ip, port)
if re.search(rep, phpini):
phpini = re.sub(rep, val, phpini)
else:
phpini = re.sub('\n;session.save_path = "' + session_tmp + '"',
'\n;session.save_path = "' + session_tmp + '"' + val, phpini)
if save_handler == "redis":
if not re.search("redis.so", phpini):
return mw.returnJson(False, '请先安装%s扩展' % save_handler)
if passwd:
passwd = "?auth=" + passwd
else:
passwd = ""
rep = r'\nsession.save_path\s*=\s*(.+)\r?\n'
val = r'\nsession.save_path = "tcp://%s:%s%s"\n' % (ip, port, passwd)
res = re.search(rep, phpini)
if res:
phpini = re.sub(rep, val, phpini)
else:
phpini = re.sub('\n;session.save_path = "' + session_tmp + '"',
'\n;session.save_path = "' + session_tmp + '"' + val, phpini)
2022-10-24 08:06:38 -04:00
if save_handler == "files":
2022-10-10 07:54:23 -04:00
rep = r'\nsession.save_path\s*=\s*(.+)\r?\n'
val = r'\nsession.save_path = "' + session_tmp + '"\n'
if re.search(rep, phpini):
phpini = re.sub(rep, val, phpini)
else:
phpini = re.sub('\n;session.save_path = "' + session_tmp + '"',
'\n;session.save_path = "' + session_tmp + '"' + val, phpini)
mw.writeFile(filename, phpini)
reload(version)
return mw.returnJson(True, '设置成功!')
def getSessionCount_Origin(version):
session_tmp = getServerDir() + "/tmp/session"
d = [session_tmp]
count = 0
for i in d:
if not os.path.exists(i):
mw.execShell('mkdir -p %s' % i)
list = os.listdir(i)
for l in list:
if os.path.isdir(i + "/" + l):
l1 = os.listdir(i + "/" + l)
for ll in l1:
if "sess_" in ll:
count += 1
continue
if "sess_" in l:
count += 1
s = "find /tmp -mtime +1 |grep 'sess_' | wc -l"
old_file = int(mw.execShell(s)[0].split("\n")[0])
s = "find " + session_tmp + " -mtime +1 |grep 'sess_'|wc -l"
old_file += int(mw.execShell(s)[0].split("\n")[0])
return {"total": count, "oldfile": old_file}
def getSessionCount(version):
data = getSessionCount_Origin(version)
return mw.returnJson(True, 'ok!', data)
def cleanSessionOld(version):
s = "find /tmp -mtime +1 |grep 'sess_'|xargs rm -f"
mw.execShell(s)
session_tmp = getServerDir() + "/tmp/session"
s = "find " + session_tmp + " -mtime +1 |grep 'sess_' |xargs rm -f"
mw.execShell(s)
old_file_conf = getSessionCount_Origin(version)["oldfile"]
if old_file_conf == 0:
return mw.returnJson(True, '清理成功')
else:
return mw.returnJson(True, '清理失败')
2018-12-19 03:50:15 -05:00
def getDisableFunc(version):
2022-07-07 22:14:27 -04:00
filename = getConf(version)
2018-12-19 03:50:15 -05:00
if not os.path.exists(filename):
2020-07-10 03:57:25 -04:00
return mw.returnJson(False, '指定PHP版本不存在!')
2018-12-19 03:50:15 -05:00
2020-07-10 03:57:25 -04:00
phpini = mw.readFile(filename)
2018-12-19 03:50:15 -05:00
data = {}
rep = "disable_functions\s*=\s{0,1}(.*)\n"
tmp = re.search(rep, phpini).groups()
data['disable_functions'] = tmp[0]
2020-07-10 03:57:25 -04:00
return mw.getJson(data)
2018-12-19 03:50:15 -05:00
def setDisableFunc(version):
2022-07-07 22:14:27 -04:00
filename = getConf(version)
2018-12-19 03:50:15 -05:00
if not os.path.exists(filename):
2020-07-10 03:57:25 -04:00
return mw.returnJson(False, '指定PHP版本不存在!')
2018-12-19 03:50:15 -05:00
args = getArgs()
disable_functions = args['disable_functions']
2020-07-10 03:57:25 -04:00
phpini = mw.readFile(filename)
2018-12-19 03:50:15 -05:00
rep = "disable_functions\s*=\s*.*\n"
2019-07-31 11:45:28 -04:00
phpini = re.sub(rep, 'disable_functions = ' +
disable_functions + "\n", phpini)
2019-03-19 04:06:20 -04:00
2020-07-10 03:57:25 -04:00
msg = mw.getInfo('修改PHP-{1}的禁用函数为[{2}]', (version, disable_functions,))
mw.writeLog('插件管理[PHP]', msg)
mw.writeFile(filename, phpini)
2018-12-19 03:50:15 -05:00
reload(version)
2020-07-10 03:57:25 -04:00
return mw.returnJson(True, '设置成功!')
2018-12-19 03:50:15 -05:00
def getPhpinfo(version):
stat = status(version)
if stat == 'stop':
2022-07-08 07:28:28 -04:00
return 'PHP[' + version + ']未启动,不可访问!!!'
2018-12-19 04:17:07 -05:00
sock_file = getFpmAddress(version)
root_dir = mw.getRootDir() + '/phpinfo'
2022-06-30 11:20:41 -04:00
mw.execShell("rm -rf " + root_dir)
mw.execShell("mkdir -p " + root_dir)
mw.writeFile(root_dir + '/phpinfo.php', '<?php phpinfo(); ?>')
sock_data = mw.requestFcgiPHP(sock_file, '/phpinfo.php', root_dir)
2022-07-08 07:40:49 -04:00
os.system("rm -rf " + root_dir)
phpinfo = str(sock_data, encoding='utf-8')
2019-03-04 10:22:29 -05:00
return phpinfo
2018-12-19 04:17:07 -05:00
def get_php_info(args):
return getPhpinfo(args['version'])
2018-12-19 03:50:15 -05:00
def getLibConf(version):
2022-07-07 22:14:27 -04:00
fname = getConf(version)
2019-01-12 08:29:07 -05:00
if not os.path.exists(fname):
2020-07-10 03:57:25 -04:00
return mw.returnJson(False, '指定PHP版本不存在!')
2018-12-19 03:50:15 -05:00
2020-07-10 03:57:25 -04:00
phpini = mw.readFile(fname)
2019-01-12 08:29:07 -05:00
libpath = getPluginDir() + '/versions/phplib.conf'
2020-07-10 03:57:25 -04:00
phplib = json.loads(mw.readFile(libpath))
2019-01-12 08:29:07 -05:00
libs = []
2020-07-10 03:57:25 -04:00
tasks = mw.M('tasks').where(
2019-01-12 08:29:07 -05:00
"status!=?", ('1',)).field('status,name').select()
for lib in phplib:
lib['task'] = '1'
for task in tasks:
2020-07-10 03:57:25 -04:00
tmp = mw.getStrBetween('[', ']', task['name'])
2019-01-12 08:29:07 -05:00
if not tmp:
continue
tmp1 = tmp.split('-')
if tmp1[0].lower() == lib['name'].lower():
lib['task'] = task['status']
lib['phpversions'] = []
lib['phpversions'].append(tmp1[1])
if phpini.find(lib['check']) == -1:
lib['status'] = False
else:
lib['status'] = True
libs.append(lib)
2020-07-10 03:57:25 -04:00
return mw.returnJson(True, 'OK!', libs)
2018-12-19 03:50:15 -05:00
2019-01-12 10:49:41 -05:00
def installLib(version):
2019-01-13 10:51:09 -05:00
args = getArgs()
2019-01-14 02:28:27 -05:00
data = checkArgs(args, ['name'])
2019-01-13 10:51:09 -05:00
if not data[0]:
return data[1]
name = args['name']
2022-07-09 04:12:12 -04:00
execstr = "cd " + getPluginDir() + "/versions && /bin/bash common.sh " + \
2022-07-13 07:36:38 -04:00
version + ' install ' + name
2019-01-13 10:51:09 -05:00
rettime = time.strftime('%Y-%m-%d %H:%M:%S')
2022-07-06 04:06:54 -04:00
insert_info = (None, '安装[' + name + '-' + version + ']',
2019-01-14 00:13:24 -05:00
'execshell', '0', rettime, execstr)
2020-07-10 03:57:25 -04:00
mw.M('tasks').add('id,name,type,status,addtime,execstr', insert_info)
2022-06-30 01:23:08 -04:00
mw.triggerTask()
2020-07-10 03:57:25 -04:00
return mw.returnJson(True, '已将下载任务添加到队列!')
2019-01-12 10:49:41 -05:00
2019-01-14 00:13:24 -05:00
def uninstallLib(version):
2019-01-14 02:28:27 -05:00
args = getArgs()
data = checkArgs(args, ['name'])
if not data[0]:
return data[1]
name = args['name']
2022-07-09 04:24:24 -04:00
execstr = "cd " + getPluginDir() + "/versions && /bin/bash common.sh " + \
2022-07-13 07:36:38 -04:00
version + ' uninstall ' + name
2019-01-14 02:28:27 -05:00
2020-07-10 03:57:25 -04:00
data = mw.execShell(execstr)
2022-07-05 00:43:46 -04:00
# data[0] == '' and
if data[1] == '':
2020-07-10 03:57:25 -04:00
return mw.returnJson(True, '已经卸载成功!')
2019-03-07 05:59:15 -05:00
else:
2020-07-10 03:57:25 -04:00
return mw.returnJson(False, '卸载信息![通道0]:' + data[0] + "[通道0]:" + data[1])
2019-03-07 05:59:15 -05:00
2019-01-14 00:13:24 -05:00
2020-07-12 06:14:56 -04:00
def getConfAppStart():
pstart = mw.getServerDir() + '/php/app_start.php'
return pstart
2022-07-11 10:19:00 -04:00
def installPreInspection(version):
2022-07-11 10:31:53 -04:00
# 仅对PHP52检查
if version != '52':
return 'ok'
sys = mw.execShell(
"cat /etc/*-release | grep PRETTY_NAME |awk -F = '{print $2}' | awk -F '\"' '{print $2}'| awk '{print $1}'")
if sys[1] != '':
return '不支持改系统'
sys_id = mw.execShell(
"cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F '\"' '{print $2}'")
sysName = sys[0].strip().lower()
sysId = sys_id[0].strip()
if sysName == 'ubuntu':
2022-07-11 10:36:51 -04:00
return 'ubuntu已经安装不了'
2022-07-11 10:31:53 -04:00
2022-07-16 03:42:57 -04:00
if sysName == 'debian' and int(sysId) > 10:
2022-07-11 10:31:53 -04:00
return 'debian10可以安装'
2022-07-13 06:25:37 -04:00
2022-07-16 03:42:57 -04:00
if sysName == 'centos' and int(sysId) > 8:
2022-07-16 03:07:13 -04:00
return 'centos[{}]不可以安装'.format(sysId)
2022-07-13 06:48:27 -04:00
if sysName == 'fedora':
sys_id = mw.execShell(
"cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}'")
sysId = sys_id[0].strip()
if int(sysId) > 31:
return 'fedora[{}]不可安装'.format(sysId)
2022-07-11 10:31:53 -04:00
return 'ok'
2022-07-11 10:19:00 -04:00
2022-10-10 07:54:23 -04:00
2018-11-26 00:57:06 -05:00
if __name__ == "__main__":
2018-12-18 02:13:33 -05:00
if len(sys.argv) < 3:
2021-05-09 12:12:36 -04:00
print('missing parameters')
2018-12-18 02:13:33 -05:00
exit(0)
2018-11-26 00:57:06 -05:00
func = sys.argv[1]
2018-12-09 07:31:39 -05:00
version = sys.argv[2]
if func == 'status':
2021-05-08 13:11:18 -04:00
print(status(version))
2018-11-26 00:57:06 -05:00
elif func == 'start':
2021-05-08 13:11:18 -04:00
print(start(version))
2018-11-26 00:57:06 -05:00
elif func == 'stop':
2021-05-08 13:11:18 -04:00
print(stop(version))
2018-11-26 00:57:06 -05:00
elif func == 'restart':
2021-05-08 13:11:18 -04:00
print(restart(version))
2018-11-26 00:57:06 -05:00
elif func == 'reload':
2021-05-08 13:11:18 -04:00
print(reload(version))
2022-07-11 10:19:00 -04:00
elif func == 'install_pre_inspection':
print(installPreInspection(version))
2019-03-15 03:23:54 -04:00
elif func == 'initd_status':
2021-05-08 13:11:18 -04:00
print(initdStatus(version))
2019-03-15 03:23:54 -04:00
elif func == 'initd_install':
2021-05-08 13:11:18 -04:00
print(initdInstall(version))
2019-03-15 03:23:54 -04:00
elif func == 'initd_uninstall':
2021-05-08 13:11:18 -04:00
print(initdUinstall(version))
2018-12-18 02:23:48 -05:00
elif func == 'fpm_log':
2021-05-08 13:11:18 -04:00
print(fpmLog(version))
2018-12-18 02:23:48 -05:00
elif func == 'fpm_slow_log':
2021-05-08 13:11:18 -04:00
print(fpmSlowLog(version))
2018-12-09 07:31:39 -05:00
elif func == 'conf':
2021-05-08 13:11:18 -04:00
print(getConf(version))
2020-07-12 06:14:56 -04:00
elif func == 'app_start':
2021-05-08 13:11:18 -04:00
print(getConfAppStart())
2018-12-18 02:13:33 -05:00
elif func == 'get_php_conf':
2021-05-08 13:11:18 -04:00
print(getPhpConf(version))
2022-07-07 03:49:44 -04:00
elif func == 'get_fpm_conf_file':
print(getFpmConfFile(version))
2018-12-18 02:13:33 -05:00
elif func == 'submit_php_conf':
2021-05-08 13:11:18 -04:00
print(submitPhpConf(version))
2018-12-18 05:09:54 -05:00
elif func == 'get_limit_conf':
2021-05-08 13:11:18 -04:00
print(getLimitConf(version))
2018-12-18 05:09:54 -05:00
elif func == 'set_max_time':
2021-05-08 13:11:18 -04:00
print(setMaxTime(version))
2018-12-18 05:09:54 -05:00
elif func == 'set_max_size':
2021-05-08 13:11:18 -04:00
print(setMaxSize(version))
2018-12-19 00:54:19 -05:00
elif func == 'get_fpm_conf':
2021-05-08 13:11:18 -04:00
print(getFpmConfig(version))
2018-12-19 00:54:19 -05:00
elif func == 'set_fpm_conf':
2021-05-08 13:11:18 -04:00
print(setFpmConfig(version))
2018-12-19 02:21:31 -05:00
elif func == 'get_fpm_status':
2021-05-08 13:11:18 -04:00
print(getFpmStatus(version))
2022-10-10 07:54:23 -04:00
elif func == 'get_session_conf':
print(getSessionConf(version))
elif func == 'set_session_conf':
print(setSessionConf(version))
elif func == 'get_session_count':
print(getSessionCount(version))
elif func == 'clean_session_old':
print(cleanSessionOld(version))
2018-12-19 03:50:15 -05:00
elif func == 'get_disable_func':
2021-05-08 13:11:18 -04:00
print(getDisableFunc(version))
2018-12-19 03:50:15 -05:00
elif func == 'set_disable_func':
2021-05-08 13:11:18 -04:00
print(setDisableFunc(version))
2018-12-19 04:17:07 -05:00
elif func == 'get_phpinfo':
2021-05-08 13:11:18 -04:00
print(getPhpinfo(version))
2018-12-19 03:50:15 -05:00
elif func == 'get_lib_conf':
2021-05-08 13:11:18 -04:00
print(getLibConf(version))
2019-01-12 10:49:41 -05:00
elif func == 'install_lib':
2021-05-08 13:11:18 -04:00
print(installLib(version))
2019-01-14 00:13:24 -05:00
elif func == 'uninstall_lib':
2021-05-08 13:11:18 -04:00
print(uninstallLib(version))
2018-12-09 07:31:39 -05:00
else:
2021-05-08 13:11:18 -04:00
print("fail")