예제 #1
0
 public function viewda()
 {
     import('ORG.Custom.backupsql');
     $db = new DBManage(C('DB_HOST'), C('DB_USER'), C('DB_PWD'), C('DB_NAME'), 'utf8');
     $backup = $db->Sqlbackup($this->_post('table'));
     echo $backup;
 }
예제 #2
0
function run_backup()
{
    $zip_file_name = 'wp2pcs.' . time() . rand(1000, 9999) . '.zip';
    $zip_file_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . $zip_file_name;
    // 备份数据库
    $db = new DBManage(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_CHAR);
    $db->backup();
    // 备份文件并生成
    $ZIP = new WebZip();
    if ($ZIP->startfile($zip_file_path)) {
        //
        _showMsg('开始备份文件...');
        $totle_files = 0;
        $current_dir = realpath(dirname(__FILE__));
        $webroot_dir = realpath($current_dir . DIRECTORY_SEPARATOR . '..');
        $ZIP->exlude = array_merge(array($current_dir), unserialize(ZIP_EXLUDE));
        $totle_files += $ZIP->process($webroot_dir, $webroot_dir);
        $totle_files += $ZIP->process($current_dir . DIRECTORY_SEPARATOR . 'database', $current_dir);
        $ZIP->createfile();
        _showMsg('文件备份完成');
        _showMsg("共备份了{$totle_files}个文件");
        _showMsg('删除备份的数据库文件...');
        remove_dir('./database');
        _showMsg('备份结束');
        /*
        $url = $_SERVER['PHP_SELF'];
        $zip = dirname($url);
        $zip = "$zip/$zip_file_name";
        _showMsg("<a href='$zip'>点击下载</a> <a href='$url?delete=$zip_file_name'>删除</a>");
        */
        return $zip_file_path;
    }
}
예제 #3
0
파일: Data.php 프로젝트: ytftianwen/web
 function restore($dir, $filename)
 {
     require_once 'DbManage.php';
     $db = new DBManage('localhost', 'root', '', 'jianji02test', 'utf8');
     // 参数:备份哪个表(可选),备份目录(可选,默认为backup),分卷大小(可选,默认2048,即2M)
     $db->restore('./' . $dir . '/' . $filename . '_v1.sql');
 }
예제 #4
0
 public function actionBackup()
 {
     if (Yii::$app->request->isPost) {
         $db = new DBManage('127.0.0.1', 'root', '', 'db_yc', 'utf8');
         $db->backup("", "", "");
     }
     return $this->render('backup', []);
 }
예제 #5
0
    public function backup()
    {
        import('ORG.Custom.backupsql');
        $db = new DBManage(C('DB_HOST'), C('DB_USER'), C('DB_PWD'), C('DB_NAME'), 'utf8');
        if ($this->_post('pid')) {
            $smtp = M('smtp');
            $stmpArr = $smtp->find();
            $backup = $db->backup();
            if ($backup) {
                if ($this->_post('email')) {
                    $stmpArr['receipt_email'] = $this->_post('email');
                    $stmpArr['title'] = "数据库备份" . time();
                    $stmpArr['content'] = '<div>
														备份时间:' . date('Y/m/d H:i:s') . '
													</div>';
                    $stmpArr['addattachment'] = $backup;
                    $this->email_send($stmpArr);
                    //发送邮件
                    $this->Record('数据库备份成功');
                    //后台操作
                    //删除备份的数据表
                    if (file_exists($backup)) {
                        unlink($backup);
                        //删除它
                    }
                    $this->success("数据库备份成功", "__URL__/backup");
                    exit;
                } else {
                    $this->error("请输入正确的邮箱地址");
                }
            } else {
                $this->Record('数据库备份失败');
                //后台操作
                $this->error("数据库备份失败");
            }
        }
        $this->display();
    }
예제 #6
0
파일: index.php 프로젝트: joyerma/Dbmanage
}
.dbDebug b{
    color: #06f;
    font-weight: normal;
}

.dbDebug .imp{
    color: #f06;
}
</style>
</head>
<body>
    <?php 
/**
 * Created by yanue.
 * User: yansueh
 * Date: 12-10-27
 * Time: 上午11:24
 * To change this template use File | Settings | File Templates.
 */
require 'DbManage.class.php';
//------1. 数据库备份(导出)------------------------------------------------------------
//分别是主机,用户名,密码,数据库名,数据库编码
$db = new DBManage('localhost', 'root', '', 'eda', 'utf8');
// 参数:备份哪个表(可选),备份目录(可选,默认为backup),分卷大小(可选,默认2048,即2M)
//$db->backup ('','','');
$db->restore('./backup/20121027194215_all_v1.sql');
?>

</body>
</html>
예제 #7
0
파일: index.php 프로젝트: uwitec/p-oa
\t'RBAC_USER_TABLE'           =>'{$db_prefix}role_user',
\t'RBAC_ACCESS_TABLE'         =>'{$db_prefix}access',
\t'RBAC_NODE_TABLE'           =>'{$db_prefix}node',
\t'SHOW_PAGE_TRACE'=>false,//显示调试信息
\t'APP_AUTOLOAD_PATH'         =>  '@.TagLib',//自动加载类
//分页设置
\t 'VAR_PAGE'=>'p',
//系统相关的信息,安装时要写入 
\t'SYS_NAME'=>'盘古信息化管理平台',
\t'VERSION'=>'1.0',
\t'INSTALL_DATE'=>'{$date}',
);
?>
EOF;
    file_put_contents("../Conf/config.php", $config);
    file_put_contents("../lock.txt", $date . '系统安装完成');
    $index = <<<EOF
<?php
define('APP_NAME', 'Index');
define('APP_PATH', './');
require( "./ThinkPHP3.1/ThinkPHP.php");
EOF;
    file_put_contents("../index.php", $index);
    //导入数据库
    include 'dbclass.php';
    $db = new DBManage('localhost', $db_user, $db_pwd, $db_name, 'utf8');
    $db->restore('pangu.sql');
    echo '安装成功,请点这里<a href="../index.php">登录</a>';
} else {
    include '../Tpl/Index/install.html';
}
예제 #8
0
    /**
     *
     * @数据库自动备份
     * @作者		shop猫
     * @版权		宁波天发网络
     * @官网		http://www.tifaweb.com http://www.dswjcms.com
     */
    public function automaticBackup()
    {
        $system = $this->systems();
        import('ORG.Custom.backupsql');
        $db = new DBManage(C('DB_HOST'), C('DB_USER'), C('DB_PWD'), C('DB_NAME'), 'utf8');
        $smtp = M('smtp');
        $stmpArr = $smtp->find();
        $backup = $db->backup();
        if ($backup) {
            $stmpArr['receipt_email'] = $system['sys_autoemail'];
            $stmpArr['title'] = "数据库备份" . time();
            $stmpArr['content'] = '<div>
												备份时间:' . date('Y/m/d H:i:s') . '
											</div>';
            $stmpArr['addattachment'] = $backup;
            $this->email_send($stmpArr);
            //发送邮件
            //删除备份的数据表
            if (file_exists($backup)) {
                unlink($backup);
                //删除它
            }
        }
    }
예제 #9
0
<?php

/*
测试mysql备份恢复
*/
//导入类库
include_once 'DbManage.class.php';
//进行备份
//分别是主机,用户名,密码,数据库名,数据库编码
$db = new DBManage('localhost', 'root', 'root', 'amazon', 'utf8');
$db->backup('goto', 'linkurl');
예제 #10
0
파일: admin.mod.php 프로젝트: bo-blog/bw
     }
     $valString = "<?php\r\n\$conf+=" . var_export($smt, true) . ";?>";
     $rS = file_put_contents(P . "conf/services.php", $valString);
     if ($rS) {
         ajaxSuccess($conf['l']['admin:msg:ChangeSaved']);
     } else {
         stopError($conf['l']['admin:msg:ChangeNotSaved']);
     }
 } elseif ($canonical->currentArgs['subAction'] == 'backup' || $canonical->currentArgs['subAction'] == 'sync') {
     $admin->checkCSRFCode('services');
     require_once P . "inc/script/pclzip/pclzip.lib.php";
     $ff = 'storage/backup' . date("YmdHis") . '.zip';
     $archive = new PclZip(P . $ff);
     if (strtolower(DBTYPE) == 'mysql') {
         include_once P . 'inc/script/dbmanage/DbManage.class.php';
         $db = new DBManage(DBADDR, DBUSERNAME, DBPASSWORD, DBNAME, 'utf8');
         $db->backup('', P . 'conf/', '');
     }
     $v_list = DBTYPE == 'SQLite' ? $archive->create('conf,' . DBNAME, PCLZIP_OPT_REMOVE_ALL_PATH) : $archive->create('conf', PCLZIP_OPT_REMOVE_ALL_PATH);
     if ($v_list == 0) {
         stopError($conf['l']['admin:msg:PclzipError'] . $archive->errorInfo(true));
     } else {
         if ($canonical->currentArgs['subAction'] == 'backup') {
             header("Location: {$conf['siteURL']}/{$ff}");
         } else {
             loadServices();
             require_once P . "inc/script/qiniu/QiniuClient.php";
             $qiniuClient = new qiniuClient(QINIU_AK, QINIU_SK);
             $result = $qiniuClient->uploadFile(P . $ff, $conf['qiniuBucket'], $ff);
             @unlink(P . $ff);
             header("Location: {$conf['siteURL']}/{$conf['linkPrefixAdmin']}/services/{$conf['linkConj']}CSRFCode=" . $admin->getCSRFCode('navibar'));
예제 #11
0
 try {
     $sql = 'show tables';
     $s = $pdo->prepare($sql);
     $s->execute();
 } catch (PDOException $e) {
     $error = 'Error select.';
     header("Location: ../includes/error.html.php");
     exit;
 }
 $tablenames = array();
 while ($table_name = $s->fetch()) {
     $tablenames[] = $table_name;
 }
 include 'form.html.php';
 // if (isset($_GET['backup']))
 $db = new DBManage('mysql1.cs.clemson.edu', 'admin662', '662admin', 'My662Project', 'utf8');
 if (isset($_POST['action']) and $_POST['action'] == 'backup') {
     //------1. database backup------------------------------------------------------------
     //The values below are host address, username, password, name of database, charset respectively
     $db->backup($_POST['tablename'], '', '');
     echo $_POST['tablename'];
     //header('Location: ./index.php');
 }
 // if (isset($_GET['restore']))
 foreach ($files1 as &$file1) {
     if (isset($_POST['action']) and $_POST['action'] == $file1) {
         //The values below are host address, username, password, name of database, charset respectively
         //$db->backup ('','','');
         $db->restore('./backup/' . $file1);
     }
 }
예제 #12
0
파일: index.php 프로젝트: xymajy/new662
</style>
</head>
<body>
    <?php 
require 'DbManage.class.php';
session_start();
include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';
//echo "administ"."<br>";
switch ($_SESSION["position"]) {
    case 'admin':
        $files1 = scandir('./backup/');
        $files1 = array_diff($files1, array(".", ".."));
        //print_r($files1);
        include 'form.html.php';
        // if (isset($_GET['backup']))
        $db = new DBManage('mysql1.cs.clemson.edu', 'admin662', '662admin', 'My662Project', 'utf8');
        if (isset($_POST['action']) and $_POST['action'] == 'backup') {
            //------1. database backup------------------------------------------------------------
            //The values below are host address, username, password, name of database, charset respectively
            $db->backup('', '', '');
        }
        // if (isset($_GET['restore']))
        foreach ($files1 as &$file1) {
            if (isset($_POST['action']) and $_POST['action'] == $file1) {
                //The values below are host address, username, password, name of database, charset respectively
                //$db->backup ('','','');
                $db->restore('./backup/' . $file1);
            }
        }
        break;
    default: