From d8340a6bcb35a4f26398a7425f2c998f21e98cd4 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Mon, 7 Jan 2019 19:56:53 +0800 Subject: [PATCH] update --- class/core/site_api.py | 1 + plugins/php/conf/php56.ini | 2 +- plugins/php/versions/56/install.sh | 4 +- plugins/phpmyadmin/conf/phpmyadmin.conf | 27 +++++ plugins/phpmyadmin/index.html | 8 +- plugins/phpmyadmin/index.py | 133 ++++++++++++++++++++++++ 6 files changed, 170 insertions(+), 5 deletions(-) create mode 100755 plugins/phpmyadmin/conf/phpmyadmin.conf create mode 100755 plugins/phpmyadmin/index.py diff --git a/class/core/site_api.py b/class/core/site_api.py index 6dd972390..f1a216828 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -384,6 +384,7 @@ class site_api: for val in phpVersions: tmp = {} if val == '00': + tmp['version'] = '00' tmp['name'] = '纯静态' data.append(tmp) diff --git a/plugins/php/conf/php56.ini b/plugins/php/conf/php56.ini index 4c0f40a47..7cb362d53 100644 --- a/plugins/php/conf/php56.ini +++ b/plugins/php/conf/php56.ini @@ -154,7 +154,7 @@ bcmath.scale = 0 [Session] session.save_handler = files -session.save_path = "MD:/bin/tmp/session" +session.save_path = "/tmp/session" session.use_strict_mode = 0 session.use_cookies = 1 session.use_only_cookies = 1 diff --git a/plugins/php/versions/56/install.sh b/plugins/php/versions/56/install.sh index 58357f0f9..66f469231 100755 --- a/plugins/php/versions/56/install.sh +++ b/plugins/php/versions/56/install.sh @@ -37,6 +37,8 @@ cd $sourcePath/php/php-5.6.36 && ./configure \ --exec-prefix=$serverPath/php/56 \ --with-config-file-path=$serverPath/php/56/etc \ --with-zlib-dir=$serverPath/lib/zlib \ +--with-mysql \ +--with-mysqli \ --without-iconv \ --enable-zip \ --enable-mbstring \ @@ -45,7 +47,7 @@ cd $sourcePath/php/php-5.6.36 && ./configure \ --enable-soap \ --enable-posix \ --enable-fpm \ -&& make && make install +&& make && make install && make clean #------------------------ install end ------------------------------------# } diff --git a/plugins/phpmyadmin/conf/phpmyadmin.conf b/plugins/phpmyadmin/conf/phpmyadmin.conf new file mode 100755 index 000000000..ac208afaa --- /dev/null +++ b/plugins/phpmyadmin/conf/phpmyadmin.conf @@ -0,0 +1,27 @@ +server +{ + listen 888; + server_name www.bt.cn; + index index.html index.htm index.php; + root {$SERVER_PATH}/phpmyadmin; + + #error_page 404 /404.html; + include enable-php-{$PHP_VER}.conf; + + location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ + { + expires 30d; + } + + location ~ .*\.(js|css)?$ + { + expires 12h; + } + + location ~ /\. + { + deny all; + } + + access_log off; +} \ No newline at end of file diff --git a/plugins/phpmyadmin/index.html b/plugins/phpmyadmin/index.html index fff3a1856..eca939dfd 100755 --- a/plugins/phpmyadmin/index.html +++ b/plugins/phpmyadmin/index.html @@ -1,8 +1,10 @@
-

php版本

-

安全设置

+

服务

+

重新模版

+

PHP版本

+

安全设置

@@ -11,6 +13,6 @@
\ No newline at end of file diff --git a/plugins/phpmyadmin/index.py b/plugins/phpmyadmin/index.py new file mode 100755 index 000000000..c8c0508c0 --- /dev/null +++ b/plugins/phpmyadmin/index.py @@ -0,0 +1,133 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import re + +sys.path.append(os.getcwd() + "/class/core") +import public +import site_api + +app_debug = False +if public.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'phpmyadmin' + + +def getPluginDir(): + return public.getPluginDir() + '/' + getPluginName() + + +def getServerDir(): + return public.getServerDir() + '/' + getPluginName() + + +def getArgs(): + args = sys.argv[2:] + 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 + + +def getConf(): + return public.getServerDir() + '/openresty/nginx/conf/vhost/phpmyadmin.conf' + +#{$PHP_VERSION} + + +def getPhpVer(expect=55): + import json + v = site_api.site_api().getPhpVersion() + v = json.loads(v) + for i in range(len(v)): + t = int(v[i]['version']) + if (t >= expect): + return str(t) + return str(expect) + + +def getCachePhpVer(): + cacheFile = getServerDir() + '/php.pl' + v = '' + if os.path.exists(cacheFile): + v = public.readFile(cacheFile) + else: + v = getPhpVer() + public.writeFile(cacheFile, v) + return v + + +def contentReplace(content): + service_path = public.getServerDir() + php_ver = getCachePhpVer() + # print php_ver + content = content.replace('{$ROOT_PATH}', public.getRootDir()) + content = content.replace('{$SERVER_PATH}', service_path) + content = content.replace('{$PHP_VER}', php_ver) + return content + + +def status(): + conf = getConf() + if os.path.exists(conf): + return 'start' + return 'stop' + + +def start(): + file_tpl = getPluginDir() + '/conf/phpmyadmin.conf' + file_conf = getConf() + centent = public.readFile(file_tpl) + centent = contentReplace(centent) + public.writeFile(file_conf, centent) + public.restartWeb() + return 'ok' + + +def stop(): + conf = getConf() + if os.path.exists(conf): + os.remove(conf) + public.restartWeb() + return 'ok' + + +def restart(): + return start() + + +def reload(): + return start() + + +if __name__ == "__main__": + func = sys.argv[1] + if func == 'status': + print status() + elif func == 'start': + print start() + elif func == 'stop': + print stop() + elif func == 'restart': + print restart() + elif func == 'reload': + print reload() + elif func == 'conf': + print getConf() + else: + print 'error'