phpmyadmin限制导出数据大小

没有找到配置可以限制,修改文件ExportController.php
里面添加一个检测数据大小方法checkSize
文件位置:phpMyAdmin\libraries\classes\Controllers\Export\ExportController.php
在主要查询计算导出数据大小代码如下

 public function checkSize($limit=3){
         //echo '<pre>';print_r($GLOBALS);die;
        $export_type = $GLOBALS['_POST']['export_type'];
        $sql = '';
        if(!($GLOBALS['_POST']['what']=='sql' && $GLOBALS['_POST']['sql_structure_or_data']=='structure')){//只导出结构不限制
            if($export_type=='table'){
                if(empty($GLOBALS['_POST']['sql_query'])&& !empty($GLOBALS['_POST']['db']) && !empty($GLOBALS['_POST']['table'])){
                    $sql = 'select round(sum(data_length/1024/1024),2) as data from information_schema.tables where table_schema=\''.$GLOBALS['dbi']->escapeString($GLOBALS['_POST']['db']).'\' and table_name=\''.$GLOBALS['dbi']->escapeString($GLOBALS['_POST']['table']).'\'';
                }
            }elseif($export_type=='database'){
                if( !empty($GLOBALS['_POST']['db']) && !empty($GLOBALS['_POST']['table_select'])){
                    $sql = 'select round(sum(data_length/1024/1024),2) as data from information_schema.tables where table_schema=\''.$GLOBALS['dbi']->escapeString($GLOBALS['_POST']['db']).'\' and table_name in(\''.implode('\',\'',$GLOBALS['_POST']['table_select']).'\')';
                }

            }elseif ($export_type==='server'){
                $sql = 'select round(sum(data_length/1024/1024),2) as data from information_schema.tables';
            }
            if($sql!==''){
                $res = $GLOBALS['dbi']->fetchResult($sql);
                if($res[0]>$limit){
                    Core::fatalError(__('数据'.$res[0].'M超过限制'.$limit.'M,请使用命令导出'));
                }
            }
        }
    }

说明-$limit要是用了配置文件可以放进配置文件中,方便修改
在上面__invoke(ServerRequest $request) 方法里面调用 $this->checkSize();
调用位置
限制效果
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值