예제 #1
0
 function backup($table)
 {
     $tables = (include $this->path . '/backup_tables.php');
     if (empty($tables)) {
         //没有要备份的表
         $this->error = "要备份的数据表为空!";
         return FALSE;
     }
     if (!isset($tables[$table])) {
         return TRUE;
         //'操作完成'
     }
     $this->table = $tables[$table];
     //需要操作的表
     $this->db = M($this->table, TRUE);
     $nums = $this->db->count() + 1;
     $this->Copyright = "-- 该程序通过HDPHP框架构建\n-- Copyright :后盾网-张博\n-- version 2012.09\n-- http://www.houdunwang.com\n-- 主机: " . __WEB__ . "\n-- 备份日期: " . date('Y-m-d H:i:s') . "\n-- 服务器版本: " . $this->db->db->link->server_info . "\n-- PHP 版本: " . phpversion() . "\n\n";
     $page = new page($nums, $this->limit);
     $wfile = $_GET['file'];
     //分卷文件标识
     $file_plus = '';
     $file_path = $this->path . '/sql_' . date('Ymd') . '_' . $wfile . '.sql';
     $handle = fopen($file_path, 'ab');
     if (filesize($file_path) > $this->filesize) {
         $wfile += 1;
         $file_plus = '/file/' . $wfile;
     }
     if ($table == 0 && $_GET['page'] == 1) {
         //fwrite($handle, $this->Copyright);//写入版权信息
     }
     if ($_GET['page'] == 1) {
         //写入建表语句
         fwrite($handle, $this->getCreateTableSyntax());
     }
     $data = $this->db->findall($page->limit());
     if ($_GET['page'] <= $page->total_page && $data) {
         // fwrite($handle, $this->db->get_last_sql()."\n");//写入SQL查询语句
         fwrite($handle, $this->getInsertSyntax($data));
         //写入插入数据语句
         go(url_remove_param('page') . '/page/' . ($_GET['page'] + 1) . $file_plus);
         //fclose($handle);
     } else {
         //开始备份下一张表
         $_GET['page'] = 1;
         //将page还原为1
         go(url_remove_param('table') . '/table/' . ($_GET['table'] + 1));
     }
 }
        if (isset($switchs[$key])) {
            ?>
<a href="<?php 
            echo url_remove_param($key);
            ?>
"><?php 
            echo $switchs[$key]['switch'][$value];
            ?>
<em>X</em></a><?php 
        }
    }
}
if (isset($_GET['update'])) {
    ?>
<a href="<?php 
    echo url_remove_param('update');
    ?>
"><?php 
    echo $_GET['update'];
    ?>
天内<em>X</em></a><?php 
}
?>
</div>
<div id="lists">
<div id="list-nav">
    <div id="view-way">
        <span class="fn-left">查看方式:</span>
        <a href="" class="list-info">详细</a>
        <a href="" class="list">列表</a>
    </div>