<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:68:"D:\PHPTutorial\WWW\newyq\public/../application/admin\view\db\db.html";i:1541734837;s:64:"D:\PHPTutorial\WWW\newyq\application\admin\view\layout\home.html";i:1550477639;s:71:"D:\PHPTutorial\WWW\newyq\application\admin\view\layout\admin_items.html";i:1547518688;}*/ ?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>麦帮官网</title>
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
        <!-- Bootstrap 3.3.7 -->
        <link rel="stylesheet" href="<?php echo PLUGINS_SITE_ROOT; ?>/layui/css/layui.css">
        <link rel="stylesheet" href="<?php echo ADMIN_SITE_ROOT; ?>/css/admin.css">
        <link rel="stylesheet" href="<?php echo ADMIN_SITE_ROOT; ?>/iconfont/iconfont.css">
        <script src="<?php echo PLUGINS_SITE_ROOT; ?>/jquery-2.1.4.min.js"></script>
        <script src="<?php echo ADMIN_SITE_ROOT; ?>/js/admin.js"></script>
        <script type="text/javascript" src="<?php echo PLUGINS_SITE_ROOT; ?>/layui/layui.js"></script>
        <script type="text/javascript">
            var BASESITEROOT = "<?php echo BASE_SITE_ROOT; ?>";
            var ADMINSITEROOT = "<?php echo ADMIN_SITE_ROOT; ?>";
            var BASESITEURL = "<?php echo BASE_SITE_URL; ?>";
            var HOMESITEURL = "<?php echo HOME_SITE_URL; ?>";
            var ADMINSITEURL = "<?php echo ADMIN_SITE_URL; ?>";
            layui.use('layer', function () {
                var layer = layui.layer;
            });
        </script>
    </head>
    <body>
        
<div class="layui-tab layui-tab-card">
    <?php if($admin_item): ?>
<ul class="layui-tab-title">
    <?php if(is_array($admin_item) || $admin_item instanceof \think\Collection || $admin_item instanceof \think\Paginator): if( count($admin_item)==0 ) : echo "" ;else: foreach($admin_item as $key=>$item): if(array_intersect(explode(" ",str_replace("/", ".",substr($item['url'],7,-5))),$allpower) || array_intersect(explode(" ",str_replace("/", ".",substr($item['url'],31,-16))),$allpower)): ?>
    <li <?php if($item['name'] == $curitem): ?>class="layui-this" <?php endif; ?>>
    <a href="<?php echo $item['url']; ?>"><?php echo $item['text']; ?></a>
    <?php endif; ?>
    </li>
    <?php endforeach; endif; else: echo "" ;endif; ?>
    <div class="tool-btns">
        <a href="javascript:location.reload();" title="刷新当前页面" class="iconfont icon-reload"></i></a>
    </div>
</ul>
<?php endif; ?>
    <div class="layui-tab-content page-tab-content">
        <div class="explanation" id="explanation">
            <div class="title" id="checkZoom">
                <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
                <span id="explanationZoom" title="收起提示" class="arrow"></span>
            </div>
            <ul>
                <li>1.会员相关信息。</li>
            </ul>
        </div>
        <div class="mDiv">
            <div class="ftitle">
                <div style="width: 100px;float: left;line-height: 56px;"><h3>数据库表列表</h3></div>
                <div style="width: 300px;float: left;line-height: 56px;"><h5>(共<?php echo $tableNum; ?>张记录，共计<?php echo $total; ?>)</h5></div>
            </div>
            <a id="export" class="layui-btn layui-btn-primary " style="background-color: #009688;color: #fff;margin-top: 10px;">数据备份</a>
        </div>
        <form method="post" id="export-form" action="<?php echo url('Admin/Db/export'); ?>">
            <div class="layui-tab-content page-tab-content">
                <table class="layui-table lay-even">
                    <colgroup>
                        <col width="80">
                        <col width="200">
                        <col width="100">
                        <col width="200">
                        <col width="200">
                        <col width="150">
                        <col>
                    </colgroup>
                    <thead>
                    <tr>
                        <th><input type="checkbox" onclick="javascript:$('input[name*=tables]').prop('checked', this.checked);">全选</th>
                        <th>数据库表</th>
                        <th>记录条数</th>
                        <th>占用空间</th>
                        <th>编码</th>
                        <th>冗余</th>
                        <th>创建时间</th>
                        <th>备注</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php if(!(empty($list) || (($list instanceof \think\Collection || $list instanceof \think\Paginator ) && $list->isEmpty()))): if(is_array($list) || $list instanceof \think\Collection || $list instanceof \think\Paginator): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$db): $mod = ($i % 2 );++$i;?>
                    <tr data-id="<?php echo $db['Name']; ?>">
                        <td>
                            <input type="checkbox" name="tables[]" value="<?php echo $db['Name']; ?>">
                        </td>
                        <td class="align-center">
                            <?php echo $db['Name']; ?>
                        </td>
                        <td class="align-center">
                            <?php echo $db['Rows']; ?>
                        </td>
                        <td class="align-center">
                            <?php echo format_bytes($db['Data_length']); ?>
                        </td>
                        <td class="align-center">
                            <?php echo $db['Collation']; ?>
                        </td>

                        <td><?php echo $db['Data_free']/1024; ?> kb
                        </td>
                        <td class="align-center">
                            <?php echo $db['Create_time']; ?>
                        </td>
                        <td><?php echo $db['Comment']; ?>
                        </td>
                        <td class="align-center">
                            <div style="text-align: center;">
                                <a href="<?php echo url('Admin/Db/optimize',array('tablename'=>$db['Name'])); ?>" class="layui-btn layui-btn-xs">优化</a>
                                <a href="<?php echo url('Admin/Db/repair',array('tablename'=>$db['Name'])); ?>" class="layui-btn layui-btn-xs layui-btn-danger">修复</a>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; endif; else: echo "" ;endif; else: ?>
                    <tr class="no_data">
                        <td colspan="11"><?php echo \think\Lang::get('ds_no_record'); ?></td>
                    </tr>
                    <?php endif; ?>
                    </tbody>
                </table>

            </div>
        </form>
    </div>
</div>
<script>
    (function ($) {
        var $form = $("#export-form"), $export = $("#export"), tables;
        $export.click(function () {
            if ($("input[name^='tables']:checked").length == 0) {
                alert('请选中要备份的数据表');
                return false;
            }
            $export.addClass("disabled");
            $export.html("正在发送备份请求...");
            $.post(
                $form.attr("action"),
                $form.serialize(),
                function (data) {
                    if (data.status) {
                        tables = data.tables;
                        $export.html(data.info + "开始备份，请不要关闭本页面！");
                        backup(data.tab);
                        window.onbeforeunload = function () {
                            return "正在备份数据库，请不要关闭！"
                        }
                    } else {
                        alert(data.info);
                        $export.removeClass("disabled");
                        $export.html("立即备份");
                    }
                },
                "json"
            );
            return false;
        });

        function backup(tab, status) {
            status && showmsg(tab.id, "开始备份...(0%)");
            $.get($form.attr("action"), tab, function (data) {
                if (data.status) {
                    showmsg(tab.id, data.info);
                    if (!$.isPlainObject(data.tab)) {
                        $export.removeClass("disabled");
                        $export.html("备份完成，点击重新备份");
                        window.onbeforeunload = function () {
                            return null
                        }
                        return;
                    }
                    backup(data.tab, tab.id != data.tab.id);
                } else {
                    $export.removeClass("disabled");
                    $export.html("立即备份");
                }
            }, "json");

        }

        function showmsg(id, msg) {
            $("input[value=" + tables[id] + "]").closest("tr").find(".info").html(msg);
//                            $("input[value=" + tables[id] + "]").closest("tr").hide(3000);
        }
    })(jQuery);
</script>

    </body>
</html>



