Example #1
0
/*
*/
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
empty($do) && ($do = 'list');
//初使化数据库
$dbhost = DB_HOST;
// 数据库服务器
$dbuser = DB_USER;
// 数据库用户名
$dbpwd = DB_PWD;
// 数据库密码
$dbname = DB_NAME;
// 数据库名
include "include/dbbackup.class.php";
include "include/msg.class.php";
$dbbackup = new dbbackup($dbhost, $dbuser, $dbpwd, $dbname);
$msg = new msg();
$tbs = $dbbackup->get_tb();
$bakfile = $dbbackup->get_backup();
if ($do == 'list') {
    get_key("config_db");
    include_once 'template/data.php';
} elseif ($do == 'save') {
    $data = $dbbackup->get_backupdata($_POST['choice']);
    //获取备份数据
    if ($dbbackup->export($data)) {
        //导入数据
        $bakfn = $msg->get_fn($dbbackup->bakfn);
        //取得备份文件名
        show_msg('恭喜您备份成功,备份文件保存在data/db目录下!', 'admin.php?ac=' . $ac . '&fileurl=' . $fileurl . '&do=data_import');
    }
Example #2
0
get_login($_USER->id);
$step = $_POST['step'];
if ($step == '2') {
    global $db;
    $db->query("UPDATE " . DB_TABLEPRE . "plugin set type='2',date='" . get_date('Y-m-d H:i:s', PHP_TIME) . "' WHERE id = '" . $_POST['pid'] . "' ");
    $dbhost = DB_HOST;
    // 数据库服务器
    $dbuser = DB_USER;
    // 数据库用户名
    $dbpwd = DB_PWD;
    // 数据库密码
    $dbname = DB_NAME;
    // 数据库名
    include "../include/dbbackup.class.php";
    include "../include/msg.class.php";
    $dbbackup = new dbbackup($dbhost, $dbuser, $dbpwd, $dbname);
    $msg = new msg();
    $bakfile = $dbbackup->get_backup();
    if ($dbbackup->import("mysql.sql")) {
        //导入数据
        show_msg('固定资产组件模块安装成功!', '../admin.php?ac=plugin&fileurl=mana');
    }
} elseif ($step == '1') {
    global $db;
    $db->query("UPDATE " . DB_TABLEPRE . "plugin set type='1' WHERE id = '" . $_POST['pid'] . "' ");
    //权限
    $db->query("DELETE FROM " . DB_TABLEPRE . "keytable WHERE id = 391");
    for ($i = 262; $i <= 266; $i++) {
        $db->query("DELETE FROM " . DB_TABLEPRE . "keytable WHERE id = " . $i . "");
    }
    //菜单
Example #3
0
	public function actionReback()
	{
		
	     if(empty($_FILES['backup'])){
		     Yii::app()->user->setFlash('error','请上传SQL文件!');exit; 
		 }
		 
		$fullname=iconv('utf-8','gbk',$_FILES['backup']['name']);
		$fileformat=strrchr($fullname,".");
		$fileformat=strtolower( str_replace(".","",$fileformat) );
		
	    if($fileformat!='sql'){
			     Yii::app()->user->setFlash('error','只能上传SQL文件!');exit;  
	    }  

		$filepath=$this->uploadFile('backup','/uploads/'.date('Ymd').'/');
		
		if(empty($filepath)){
	      	Yii::app()->user->setFlash('error','上传文件失败!');exit;  
		}
		
		$bathPath=str_replace('\\','/',dirname(Yii::app()->BasePath) );		
		
	    if(!file_exists($bathPath.$filepath)){
		      Yii::app()->user->setFlash('error','文件不存在!');exit;  
	    } 
		
        $sql = file_get_contents($bathPath.$filepath);

		if(empty($sql)){  
			    Yii::app()->user->setFlash('error','数据不存在');exit;  
	    }
		
	    Yii::import('application.extensions.dbbackup.dbbackup');
		$backup = new dbbackup('letstravel');
		
        $backup->sql_execute($sql);
		
		unlink($bathPath.$filepath);
		
        Yii::app()->user->setFlash('success','还原成功!');
		
		$this->redirect('backup');
	}