diff --git a/plugins/phpmyadmin/index.py b/plugins/phpmyadmin/index.py
index 9ceb764f7..7f05c3864 100755
--- a/plugins/phpmyadmin/index.py
+++ b/plugins/phpmyadmin/index.py
@@ -110,9 +110,12 @@ def status():
def start():
file_tpl = getPluginDir() + '/conf/phpmyadmin.conf'
file_conf = getConf()
- centent = public.readFile(file_tpl)
- centent = contentReplace(centent)
- public.writeFile(file_conf, centent)
+
+ if not os.path.exists(file_conf):
+ centent = public.readFile(file_tpl)
+ centent = contentReplace(centent)
+ public.writeFile(file_conf, centent)
+
public.restartWeb()
return 'ok'
@@ -158,8 +161,30 @@ def getPmaPort():
port = getPort()
return public.returnJson(True, 'OK', port)
except Exception as e:
+ print e
return public.returnJson(False, '插件未启动!')
+
+def setPmaPort():
+ args = getArgs()
+ if not 'port' in args:
+ return public.returnJson(False, 'port missing!')
+
+ port = args['port']
+ if port == '80':
+ return public.returnJson(False, '80端不能使用!')
+
+ file = getConf()
+ if not os.path.exists(file):
+ return public.returnJson(False, '插件未启动!')
+ content = public.readFile(file)
+ rep = 'listen\s*(.*);'
+ content = re.sub(rep, "listen " + port + ';', content)
+ public.writeFile(file, content)
+ public.restartWeb()
+ return public.returnJson(True, '修改成功!')
+
+
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
@@ -182,5 +207,7 @@ if __name__ == "__main__":
print getSetPhpVer()
elif func == 'get_pma_port':
print getPmaPort()
+ elif func == 'set_pma_port':
+ print setPmaPort()
else:
print 'error'
diff --git a/plugins/phpmyadmin/js/phpmyadmin.js b/plugins/phpmyadmin/js/phpmyadmin.js
index 040a64c9e..7a4ab2fa1 100755
--- a/plugins/phpmyadmin/js/phpmyadmin.js
+++ b/plugins/phpmyadmin/js/phpmyadmin.js
@@ -89,7 +89,7 @@ function phpVerChange(type, msg) {
//phpmyadmin安全设置
-function safeConf(name, auth) {
+function safeConf() {
var data = pmaAsyncPost('get_pma_port');
var rdata = $.parseJSON(data.data);
if (!rdata.status){
@@ -97,91 +97,26 @@ function safeConf(name, auth) {
return;
}
var con = '
\
- 访问端口\
- \
- \
-
\
- \
- 密码访问\
- \
- \
- \
-
\
- \
-
授权账号
\
-
访问密码
\
-
重复密码
\
-
\
-
\
- ';
+ 访问端口\
+ \
+ \
+ ';
$(".soft-man-con").html(con);
- // if (auth) {
- // $(".user_pw").show();
- // }
-}
-
-//phpmyadmin二级密码
-function phpmyadminSafe() {
- var stat = $("#phpmyadminsafe").prop("checked");
- if (stat) {
- $(".user_pw").hide();
- phpmyadmin('close');
- } else {
- $(".user_pw").show();
- }
}
//修改phpmyadmin端口
-function phpmyadminport() {
+function phpmyadminPort() {
var pmport = $("#pmport").val();
if (pmport < 80 || pmport > 65535) {
- layer.msg(lan.firewall.port_err, { icon: 2 });
+ layer.msg('端口范围不合法!', { icon: 2 });
return;
}
var data = 'port=' + pmport;
- var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
- $.post('/ajax?action=setPHPMyAdmin', data, function(rdata) {
- layer.close(loadT);
- layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
- });
-}
-
-
-//设置phpmyadmin二级密码
-function phpmyadmin(msg) {
- type = 'password';
- if (msg == 'close') {
- password_1 = msg;
- username = msg;
- layer.confirm(lan.soft.pma_pass_close, { closeBtn: 2, icon: 3 }, function() {
- var data = type + '=' + msg + '&siteName=phpmyadmin';
- var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
- $.post('/ajax?action=setPHPMyAdmin', data, function(rdata) {
- layer.close(loadT);
- layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
- });
- });
- return;
- } else {
- username = $("#username_get").val()
- password_1 = $("#password_get_1").val()
- password_2 = $("#password_get_2").val()
- if (username.length < 1 || password_1.length < 1) {
- layer.msg(lan.soft.pma_pass_empty, { icon: 2 });
- return;
- }
- if (password_1 != password_2) {
- layer.msg(lan.bt.pass_err_re, { icon: 2 });
- return;
- }
- }
- msg = password_1 + '&username=' + username + '&siteName=phpmyadmin';
- var data = type + '=' + msg;
- var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] });
- $.post('/ajax?action=setPHPMyAdmin', data, function(rdata) {
- layer.close(loadT);
+
+ pmaPost('set_pma_port',data, function(data){
+ var rdata = $.parseJSON(data.data);
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
});
}
\ No newline at end of file