diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index f277d5eaa..906ec764f 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -800,6 +800,61 @@ def setDbAccess(): psdb.where('username=?', (name,)).save('accept', (access,)) return public.returnJson(True, '设置成功!') + +def getDbInfo(): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + db_name = args['name'] + pdb = pMysqlDb() + # print 'show tables from `%s`' % db_name + table_res = pdb.query('show tables from `%s`' % db_name) + isError = isSqlError(table_res) + if isError != None: + return isError + + tables = mapToList(table_res) + + ret = {} + if type(tables) == list: + try: + data = mapToList(pdb.query( + "select sum(DATA_LENGTH)+sum(INDEX_LENGTH) from information_schema.tables where table_schema='%s'" % db_name))[0][0] + except: + data = 0 + + if not data: + data = 0 + ret['data_size'] = public.toSize(data) + ret['database'] = db_name + + ret3 = [] + + for i in tables: + if i == 1049: + return public.returnJson(False, '指定数据库不存在!') + table = mapToList( + pdb.query("show table status from `%s` where name = '%s'" % (db_name, i[0]))) + if not table: + continue + try: + ret2 = {} + ret2['type'] = table[0][1] + data_size = table[0][6] + ret2['rows_count'] = table[0][4] + ret2['collation'] = table[0][14] + ret2['data_size'] = public.toSize(int(data_size)) + ret2['table_name'] = i[0] + ret3.append(ret2) + except: + continue + ret['tables'] = (ret3) + + return public.getJson(ret) + + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -856,5 +911,7 @@ if __name__ == "__main__": print getDbAccess() elif func == 'set_db_access': print setDbAccess() + elif func == 'get_db_info': + print getDbInfo() else: print 'error' diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index 23e746f97..621605d03 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -861,7 +861,15 @@ function openPhpmyadmin(name,username,password){ setTimeout(function(){ $("#toPHPMyAdmin").submit(); },200); +} +function repTools(dbname){ + console.log(dbname); + myPost('get_db_info', {name:dbname}, function(data){ + console.log(data); + var rdata = $.parseJSON(data.data); + console.log(rdata); + }); } function dbList(page, search){ @@ -892,7 +900,7 @@ function dbList(page, search){ list += ''+rdata.data[i]['ps']+''; list += '' + '管理 | ' + - '工具 | ' + + '工具 | ' + '权限 | ' + '改密 | ' + '删除' + diff --git a/plugins/php/js/php.js b/plugins/php/js/php.js index acb5dffb9..784349ab9 100755 --- a/plugins/php/js/php.js +++ b/plugins/php/js/php.js @@ -449,88 +449,6 @@ function phpLibConfig(version){ } - -//设置PATHINFO -// function setPathInfo(version, type) { -// var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); -// $.post('/config?action=setPathInfo', 'version=' + version + '&type=' + type, function(rdata) { -// var pathinfo = (type == 'on') ? true : false; -// var pathinfoOpt = '' + lan.public.off + '' -// if (!pathinfo) { -// pathinfoOpt = '' + lan.public.on + '' -// } -// var pathinfo1 = 'PATH_INFO' + lan.soft.php_menu_ext + '' + lan.soft.mvc_ps + '' + pathinfoOpt + ''; -// $("#pathInfo").html(pathinfo1); -// $(".bt-w-menu .bgw").attr('onclick', "SetPHPConfig('" + version + "'," + pathinfo + ",1)"); -// $(".bt-w-menu .bgw a").attr('href', "javascript:SetPHPConfig('" + version + "'," + pathinfo + ",1);"); -// layer.msg(rdata.msg, { icon: 1 }); -// }); -// } - - -//PHP扩展配置 -// function setPHPConfig(version, pathinfo, go) { -// $.get('/ajax?action=GetPHPConfig&version=' + version, function(rdata) { -// var body = "" -// var opt = "" -// for (var i = 0; i < rdata.libs.length; i++) { -// if (rdata.libs[i].versions.indexOf(version) == -1) continue; -// if (rdata.libs[i]['task'] == '-1' && rdata.libs[i].phpversions.indexOf(version) != -1) { -// opt = '' + lan.soft.the_install + '' -// } else if (rdata.libs[i]['task'] == '0' && rdata.libs[i].phpversions.indexOf(version) != -1) { -// opt = '' + lan.soft.sleep_install + '' -// } else if (rdata.libs[i].status) { -// opt = '' + lan.soft.uninstall + '' -// } else { -// opt = '' + lan.soft.install + '' -// } - -// body += '' + -// '' + rdata.libs[i].name + '' + -// '' + rdata.libs[i].type + '' + -// '' + rdata.libs[i].msg + '' + -// '' + -// '' + opt + '' + -// '' -// } - -// var pathinfoOpt = '' + lan.soft.off + '' -// if (!rdata.pathinfo) { -// pathinfoOpt = '' + lan.soft.on + '' -// } -// var pathinfo1 = 'PATH_INFO' + lan.soft.php_menu_ext + '' + lan.soft.mvc_ps + '' + pathinfoOpt + ''; -// var con = '
' + -// '' + -// '' + -// '' + -// '' + -// '' + -// '' + -// '' + -// '' + -// '' + -// '' + -// '' + pathinfo1 + body + '' + -// '
' + lan.soft.php_ext_name + '' + lan.soft.php_ext_type + '' + lan.soft.php_ext_ps + '' + lan.soft.php_ext_status + '' + lan.public.action + '
' + -// '
' + -// ''; -// var divObj = document.getElementById('phpextdiv'); -// var scrollTopNum = 0; -// if (divObj) scrollTopNum = divObj.scrollTop; -// $(".soft-man-con").html(con); -// document.getElementById('phpextdiv').scrollTop = scrollTopNum; -// }); - -// if (go == undefined) { -// setTimeout(function() { -// if ($(".bgw #phpext").html() != '安装扩展') { -// return; -// } -// SetPHPConfig(version, pathinfo); -// }, 3000); -// } -// } - //安装扩展 function installPHPLib(version, name, title, pathinfo) { layer.confirm('您真的要安装{1}吗?'.replace('{1}', name), { icon: 3, closeBtn: 2 }, function() {