}

		}
	}

} elseif($action == 'importzip') {

	require_once DISCUZ_ROOT.'admin/zip.func.php';
	$unzip = new SimpleUnzip();
	$unzip->ReadFile($datafile_server);

	if($unzip->Count() == 0 || $unzip->GetError(0) != 0 || !preg_match("/\.sql$/i", $importfile = $unzip->GetName(0))) {
		cpmsg('database_import_file_illegal');
	}

	$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", substr($unzip->GetData(0), 0, 256))));
	$confirm = !empty($confirm) ? 1 : 0;
	if(!$confirm && $identify[1] != $version) {
		cpmsg('database_import_confirm', 'admincp.php?action=importzip&datafile_server=$datafile_server&importsubmit=yes&confirm=yes', 'form');
	}

	$sqlfilecount = 0;
	foreach($unzip->Entries as $entry) {
		if(preg_match("/\.sql$/i", $entry->Name)) {
			$fp = fopen('./forumdata/'.$backupdir.'/'.$entry->Name, 'w');
			fwrite($fp, $entry->Data);
			fclose($fp);
			$sqlfilecount++;
		}
	}
Exemple #2
0
                fclose(fopen(S_ROOT . './data/' . $backupdir . '/index.htm', 'a'));
                cpmessage('successful_data_compression_and_backup_server_to', 'admincp.php?ac=backup');
            }
        } else {
            cpmessage('shell_backup_failure', 'admincp.php?ac=backup');
        }
    }
} elseif ($_GET['op'] == 'import') {
    if ($_GET['do'] == 'zip') {
        include_once S_ROOT . './source/class_zib.php';
        $unzip = new SimpleUnzip();
        $unzip->ReadFile(S_ROOT . './data/' . $_GET['datafile']);
        if ($unzip->Count() == 0 || $unzip->GetError(0) != 0 || !preg_match('/\\.sql$/i', $importfile = $unzip->GetName(0))) {
            cpmessage('data_file_does_not_exist');
        }
        $identify = explode(',', base64_decode(preg_replace('/^# Identify:\\s*(\\w+).*/s', '\\1', substr($unzip->GetData(0), 0, 256))));
        //Check the version number
        $_GET['confirm'] = isset($_GET['confirm']) ? 1 : 0;
        if (!$_GET['confirm'] && $identify[1] != X_VER) {
            $showform = 1;
            include template('admin/tpl/backup');
            exit;
        }
        $sqlfilecount = 0;
        foreach ($unzip->Entries as $entry) {
            if (preg_match('/\\.sql$/i', $entry->Name)) {
                $fp = fopen(S_ROOT . './data/' . $backupdir . '/' . $entry->Name, 'w');
                fwrite($fp, $entry->Data);
                fclose($fp);
                $sqlfilecount++;
            }
Exemple #3
0
function restoreZip($id)
{
    $path = PATH_ROOT;
    if (strstr($path, 'data')) {
        $id = trim(str_replace('data', '', $id), '/');
    }
    if (!file_exists($id)) {
        return array('success' => 0, 'msg' => Ibos::lang('Database import file illegal', 'dashboard.default'));
    }
    $dataFileVol1 = trim(EnvUtil::getRequest('datafilevol1', 'G'));
    $multiVol = intval(EnvUtil::getRequest('multivol', 'G'));
    Ibos::import('ext.Zip', true);
    $unzip = new SimpleUnzip();
    $unzip->ReadFile($id);
    if ($unzip->Count() == 0 || $unzip->GetError(0) != 0 || !preg_match("/\\.sql\$/i", $importFile = $unzip->GetName(0))) {
        return array('success' => 0, 'msg' => Ibos::lang('Database import file illegal', 'dashboard.default'));
    }
    $identify = explode(',', base64_decode(preg_replace("/^# Identify:\\s*(\\w+).*/s", "\\1", substr($unzip->GetData(0), 0, 256))));
    $confirm = EnvUtil::getRequest('confirm', 'G');
    $confirm = !is_null($confirm) ? 1 : 0;
    if (!$confirm && $identify[1] != VERSION) {
        return array('type' => 'confirm', 'msg' => Ibos::lang('Database import confirm', 'dashboard.default'), 'url' => 'restore.php?' . http_build_query(array('op' => 'restorezip', 'confirm' => 'yes', 'id' => $id)));
    }
    $sqlFileCount = 0;
    foreach ($unzip->Entries as $entry) {
        if (preg_match("/\\.sql\$/i", $entry->Name)) {
            $fp = fopen('backup/' . $entry->Name, 'w');
            fwrite($fp, $entry->Data);
            fclose($fp);
            $sqlFileCount++;
        }
    }
    if (!$sqlFileCount) {
        return array('success' => 0, 'msg' => Ibos::lang('Database import file illegal', 'dashboard.default'));
    }
    if ($multiVol) {
        $multiVol++;
        $id = preg_replace("/-(\\d+)(\\..+)\$/", "-{$multiVol}\\2", $id);
        if (file_exists($multiVol)) {
            $param = array('op' => 'restorezip', 'multivol' => $multiVol, 'datafilevol1' => $dataFileVol1, 'delunzip' => $dataFileVol1, 'confirm' => 'yes');
            return array('type' => 'confirm', 'msg' => Ibos::lang('Database import multivol unzip redirect', 'dashboard.default', array('multivol' => $multiVol)), 'url' => 'restore.php?' . http_build_query($param));
        } else {
            $param = array('op' => 'restore', 'id' => $dataFileVol1, 'autorestore' => 'yes', 'delunzip' => 'yes');
            return array('type' => 'confirm', 'msg' => Ibos::lang('Database import multivol confirm', 'dashboard.default'), 'url' => 'restore.php?' . http_build_query($param));
        }
    }
    $info = '<b>' . basename($id) . '</b><br />' . Ibos::lang('Version') . ': ' . $identify[1] . '<br />' . Ibos::lang('Type') . ': ' . $identify[2] . '<br />' . Ibos::lang('Backup method') . ': ' . ($identify[3] == 'multivol' ? Ibos::lang('DBMultivol') : Ibos::lang('DBShell')) . '<br />';
    if ($identify[3] == 'multivol' && $identify[4] == 1 && preg_match("/-1(\\..+)\$/", $id)) {
        $dataFileVol1 = $id;
        $id = preg_replace("/-1(\\..+)\$/", "-2\\1", $id);
        if (file_exists($id)) {
            $param = array('op' => 'restorezip', 'multivol' => 1, 'datafilevol1' => 'backup/' . $importFile, 'id' => $id, 'confirm' => 'yes');
            return array('type' => 'redirect', 'msg' => Ibos::lang('Database import multivol unzip redirect', 'dashboard.default', array('multivol' => 1)), 'url' => 'restore.php?' . http_build_query($param));
        }
    }
    $param = array('op' => 'restore', 'datafilevol1' => $dataFileVol1, 'id' => 'backup/' . $importFile, 'delunzip' => 'yes', 'autorestore' => 'yes');
    return array('type' => 'confirm', 'msg' => Ibos::lang('Database import unzip', 'dashboard.default', array('info' => $info)), 'url' => 'restore.php?' . http_build_query($param));
}
Exemple #4
0
     break;
 case 'application/zip':
     if ($cfg['GZipDump'] && @function_exists('gzinflate')) {
         include_once './libraries/unzip.lib.php';
         $import_handle = new SimpleUnzip();
         $import_handle->ReadFile($import_file);
         if ($import_handle->Count() == 0) {
             $message = $strNoFilesFoundInZip;
             $show_error_header = TRUE;
             $error = TRUE;
         } elseif ($import_handle->GetError(0) != 0) {
             $message = $strErrorInZipFile . ' ' . $import_handle->GetErrorMsg(0);
             $show_error_header = TRUE;
             $error = TRUE;
         } else {
             $import_text = $import_handle->GetData(0);
         }
         // We don't need to store it further
         $import_handle = '';
     } else {
         $message = sprintf($strUnsupportedCompressionDetected, $compression);
         $show_error_header = TRUE;
         $error = TRUE;
     }
     break;
 case 'none':
     $import_handle = @fopen($import_file, 'r');
     break;
 default:
     $message = sprintf($strUnsupportedCompressionDetected, $compression);
     $show_error_header = TRUE;
Exemple #5
0
 /**
  * http://bugs.php.net/bug.php?id=29532
  * bzip reads a maximum of 8192 bytes on windows systems
  *
  */
 function getNextChunk($max_size = null)
 {
     if (null !== $max_size) {
         $size = min($max_size, $this->getChunkSize());
     } else {
         $size = $this->getChunkSize();
     }
     // $result = $this->handler->getNextChunk($size);
     $result = '';
     switch ($this->getCompression()) {
         case 'application/bzip2':
             $result = '';
             while (strlen($result) < $size - 8192 && !feof($this->getHandle())) {
                 $result .= bzread($this->getHandle(), $size);
             }
             break;
         case 'application/gzip':
             $result = gzread($this->getHandle(), $size);
             break;
         case 'application/zip':
             include_once './libraries/unzip.lib.php';
             $import_handle = new SimpleUnzip();
             $import_handle->ReadFile($this->getName());
             if ($import_handle->Count() == 0) {
                 $this->_error_message = $GLOBALS['strNoFilesFoundInZip'];
                 return false;
             } elseif ($import_handle->GetError(0) != 0) {
                 $this->_error_message = $GLOBALS['strErrorInZipFile'] . ' ' . $import_handle->GetErrorMsg(0);
                 return false;
             } else {
                 $result = $import_handle->GetData(0);
             }
             break;
         case 'none':
             $result = fread($this->getHandle(), $size);
             break;
         default:
             return false;
     }
     echo $size . ' - ';
     echo strlen($result) . ' - ';
     echo @($GLOBALS['__len__'] += strlen($result)) . ' - ';
     echo $this->_error_message;
     echo '<hr />';
     if ($GLOBALS['charset_conversion']) {
         $result = PMA_convert_string($this->getCharset(), $GLOBALS['charset'], $result);
     } else {
         /**
          * Skip possible byte order marks (I do not think we need more
          * charsets, but feel free to add more, you can use wikipedia for
          * reference: <http://en.wikipedia.org/wiki/Byte_Order_Mark>)
          *
          * @todo BOM could be used for charset autodetection
          */
         if ($this->getOffset() === 0) {
             // UTF-8
             if (strncmp($result, "", 3) == 0) {
                 $result = substr($result, 3);
                 // UTF-16 BE, LE
             } elseif (strncmp($result, "þÿ", 2) == 0 || strncmp($result, "ÿþ", 2) == 0) {
                 $result = substr($result, 2);
             }
         }
     }
     $this->_offset += $size;
     if (0 === $result) {
         return true;
     }
     return $result;
 }
Exemple #6
0
	function DoImportZip()
	{
		$this->CheckAdminPrivs('dbimport');
		extract($this->Post);
		extract($this->Get);
		require_once FUNCTION_PATH.'zip.func.php';
		$unzip = new SimpleUnzip();
		$unzip->ReadFile($datafile_server);

		if($unzip->Count() == 0 || $unzip->GetError(0) != 0 || !preg_match("/\.sql$/i", $importfile = $unzip->GetName(0))) {
			$this->Messager('数据文件不存在: 可能服务器不允许上传文件或尺寸超过限制。',null);
		}

		$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", substr($unzip->GetData(0), 0, 256))));
		$confirm = !empty($confirm) ? 1 : 0;
		if(!$confirm && $identify[1] !=SYS_VERSION) {
			$to="admin.php?mod=db&code=importzip&datafile_server=".urlencode($datafile_server)."&importsubmit=yes&confirm=yes";
			$msg=' <form method="post" action="'.$to.'">
                    <br /><br /><br />导入和当前程序版本不一致的数据极有可能产生无法解决的故障,您确定继续吗?<br /><br /><br /><br />
                    <input type="hidden" name="FORMHASH" value="'.FORMHASH.'"> &nbsp;
                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
                    <input class="button" type="button" value=" 取 消 " onClick="history.go(-1);">
                  </form><br />';
			$this->Messager($msg,null);
		}

		$sqlfilecount = 0;
		foreach($unzip->Entries as $entry) {
			if(preg_match("/\.sql$/i", $entry->Name)) {
				$fp = fopen('./backup/'.$backupdir.'/'.$entry->Name, 'w');
				fwrite($fp, $entry->Data);
				fclose($fp);
				$sqlfilecount++;
			}
		}

		if(!$sqlfilecount) {
			$this->Messager('database_import_file_illegal');
		}
		$type_list=array("all_tables"=>"全部数据","custom"=>"自定义备份",'zip'=>"压缩备份");
		$info = basename($datafile_server).'<br />'.'版本'.': '.$identify[1].'<br />'.'类型'.': '.$type_list[$identify[2]].'<br />'.'方式'.': '.($identify[3] == 'multivol' ? "多卷" : "SHELL").'<br />';

		if(isset($multivol)) {
			$multivol++;
			$datafile_server = preg_replace("/-(\d+)(\..+)$/", "-$multivol\\2", $datafile_server);
			if(is_file($datafile_server)) {
				$this->Messager("数据文件 #$multivol 成功解压缩,程序将自动继续。", 'admin.php?mod=db&code=importzip&multivol='.$multivol.'&datafile_vol1='.$datafile_vol1.'&datafile_server='.urlencode($datafile_server).'&importsubmit=yes&confirm=yes');
			} else {
				$to='admin.php?mod=db&code=doimport&from=server&datafile_server='.urlencode($datafile_vol1).'&importsubmit=yes&delunzip=yes';
				$msg=' <form method="post" action="'.$to.'">
		                    <br /><br /><br />所有分卷文件解压缩完毕,您需要自动导入备份吗?导入后解压缩的文件将会被删除。<br /><br /><br /><br />
		                    <input type="hidden" name="FORMHASH" value="'.FORMHASH.'"> &nbsp;
		                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
		                    <input class="button" type="button" value=" 取 消 " onClick="location.href=\'admin.php?mod=db&code=import\';">
		                  </form><br />';

				$this->Messager($msg,null);
			}
		}

		if($identify[3] == 'multivol' && $identify[4] == 1 && preg_match("/-1(\..+)$/", $datafile_server)) {
			$datafile_vol1 = $datafile_server;
			$datafile_server = preg_replace("/-1(\..+)$/", "-2\\1", $datafile_server);
			if(is_file($datafile_server)) {
				$to='admin.php?mod=db&code=importzip&multivol=1&datafile_vol1=./backup/'.$backupdir.'/'.$importfile.'&datafile_server='.urlencode($datafile_server).'&importsubmit=yes&confirm=yes';
				$msg=' <form method="post" action="'.$to.'">
		                    '.$info.'<br />备份文件解压缩完毕,您需要自动解压缩其它的分卷文件吗?<br /><br /><br /><br />
		                    <input type="hidden" name="FORMHASH" value="'.FORMHASH.'"> &nbsp;
		                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
		                    <input class="button" type="button" value=" 取 消 " onClick="history.go(-1);">
		                  </form><br />';
				$this->Messager($msg, null);
			}
		}
		$to='admin.php?mod=db&code=doimport&from=server&datafile_server=./backup/'.$backupdir.'/'.$importfile.'&importsubmit=yes&delunzip=yes';
		$msg=' <form method="post" action="'.$to.'">
                    <br /><br /><br />所有分卷文件解压缩完毕,您需要自动导入备份吗?导入后解压缩的文件将会被删除。<br /><br /><br /><br />
                    <input type="hidden" name="FORMHASH" value="'.FORMHASH.'"> &nbsp;
                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
                    <input class="button" type="button" value=" 取 消 " onClick="location.href=\"admin.php?mod=db&code=import\";">
                  </form><br />';

		$this->Messager($msg,null);
	}
Exemple #7
0
function plugin_dump_upload()
{
    global $vars, $_STORAGE, $script;
    $qm = get_qm();
    if (!PLUGIN_DUMP_ALLOW_RESTORE) {
        return array('code' => FALSE, 'msg' => $qm->m['plg_dump']['err_prohibit_restore']);
    }
    $filename = $_FILES['upload_file']['name'];
    $matches = array();
    $arc_kind = FALSE;
    if (!preg_match('/\\.zip$/', $filename, $matches)) {
        die_message($qm->m['plg_dump']['err_invalid_filetype']);
    }
    if ($_FILES['upload_file']['size'] > PLUGIN_DUMP_MAX_FILESIZE * 1024) {
        die_message($qm->replace('plg_dump.err_size_over', PLUGIN_DUMP_MAX_FILESIZE));
    }
    //require unzip
    require_once LIB_DIR . 'unzip.lib.php';
    // Create a temporary tar file
    $uploadfile = tempnam(realpath(CACHEQHM_DIR), 'zip_uploaded_');
    if (!move_uploaded_file($_FILES['upload_file']['tmp_name'], $uploadfile)) {
        @unlink($uploadfile);
        die_message($qm->m['plg_dump']['err_upload_failed']);
    }
    $unzip = new SimpleUnzip($uploadfile);
    $files = array();
    $len = $unzip->Count();
    for ($i = 0; $i < $len; $i++) {
        $name = $unzip->GetName($i);
        $path = $unzip->GetPath($i);
        //path をディレクトリにする: ./ で始まる場合、それを除去
        $dir = basename($path);
        //swfu/d
        if ($dir == 'd') {
            $dir = strpos($path, 'swfu/d') !== FALSE ? 'swfu/d' : '';
        }
        if ($dir == 'data') {
            //swfu/data
            if (strpos($path, 'swfu/data') !== FALSE) {
                $dir = 'swfu/data';
            } else {
                if (strpos($path, 'fwd3/sys/data') !== FALSE) {
                    $dir = 'fwd3/sys/data';
                }
            }
        }
        if (strpos($path, './.') !== FALSE) {
            $path = str_replace('./.', '.', $path);
        }
        switch ($dir) {
            case 'wiki':
                $stokey = 'DATA_DIR';
                break;
            case 'attach':
                $stokey = 'UPLOAD_DIR';
                break;
            case 'backup':
                $stokey = 'BACKUP_DIR';
                break;
            case 'swfu/d':
                $stokey = 'SWFU_DIR';
                break;
            case 'swfu/data':
                $stokey = 'SWFUDATA_DIR';
                break;
            case 'fwd3/sys/data':
                $stokey = 'FWD3DATA_DIR';
                break;
            case 'cache':
                $stokey = 'CACHE_DIR';
                break;
            default:
                $stokey = 'HOME_DIR';
        }
        $filter = isset($_STORAGE[$stokey]['extract_filter']) ? $_STORAGE[$stokey]['extract_filter'] : '';
        if ($filter && preg_match("/{$filter}/", $name)) {
            $uzfile = $path . '/' . $name;
            $files[] = $uzfile;
            $data = $unzip->GetData($i);
            $dlen = strlen($data);
            if ($fp = fopen($uzfile, "wb")) {
                fwrite($fp, $data, $dlen);
                fclose($fp);
                chmod($uzfile, 0666);
            } else {
                echo '<error>', $qm->replace('plg_dump.err_open_archive', $name), '</error>';
            }
        }
    }
    if (empty($files)) {
        @unlink($uploadfile);
        return array('code' => FALSE, 'msg' => $qm->m['plg_dump']['err_upload_empty']);
    }
    $msg = '<p><strong>' . $qm->m['plg_dump']['restore_header'] . '</strong><ul>';
    foreach ($files as $name) {
        $msg .= "<li>{$name}</li>\n";
    }
    $msg .= '</ul></p>';
    $msg .= '
<p>
	<a href="' . h($script) . '?cmd=qhmsetting">設定一覧へ戻る</a>
</p>
';
    @unlink($uploadfile);
    return array('code' => TRUE, 'msg' => $msg);
}
Exemple #8
0
    function DoImportZip()
    {
        if (true !== JISHIGOU_FOUNDER) {
            $this->Messager("为安全起见,只有网站创始人才能执行数据恢复操作。", null);
        }
        $datafile_server = get_param('datafile_server');
        $datafile_server = dir_safe($datafile_server);
        if (false == preg_match('~^\\.\\/data\\/backup\\/db\\/([\\w\\d\\-\\_]+)\\/\\1(\\-\\d+)?\\.zip$~i', $datafile_server)) {
            $this->Messager("文件名参数传递有误,请返回重试", null);
        }
        $backupdir = 'db/' . basename(dirname($datafile_server));
        $backupdir = dir_safe($backupdir);
        $multivol = (int) get_param('multivol');
        $datafile_vol1 = get_param('datafile_vol1');
        $datafile_vol1 = dir_safe($datafile_vol1);
        if ($datafile_vol1 && false == preg_match('~^\\.\\/data\\/backup\\/db\\/([\\w\\d\\-\\_]+)\\/\\1(\\-\\d+)?\\.sql$~i', $datafile_vol1)) {
            $this->Messager("文件名参数传递有误,请返回重试", null);
        }
        require_once ROOT_PATH . 'include/func/zip.func.php';
        $unzip = new SimpleUnzip();
        $unzip->ReadFile($datafile_server);
        if ($unzip->Count() == 0 || $unzip->GetError(0) != 0 || !preg_match("/^[\\w\\d\\-\\_]+\\.sql\$/i", $importfile = $unzip->GetName(0))) {
            $this->Messager('数据文件不存在: 可能服务器不允许上传文件或尺寸超过限制。', null);
        }
        $identify = explode(',', base64_decode(preg_replace("/^# Identify:\\s*(\\w+).*/s", "\\1", substr($unzip->GetData(0), 0, 256))));
        $confirm = 'yes' == get_param('confirm', 'P') ? 1 : 0;
        if (!$confirm && $identify[1] != SYS_VERSION) {
            $to = "admin.php?mod=db&code=importzip&datafile_server=" . urlencode($datafile_server) . "&importsubmit=yes&confirm=yes";
            $msg = ' <form method="post" action="' . $to . '">
					<input type="hidden" name="FORMHASH" value="' . FORMHASH . '"  />
                    <br /><br /><br />导入和当前程序版本不一致的数据极有可能产生无法解决的故障,您确定继续吗?<br /><br /><br /><br />
                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
                    <input class="button" type="button" value=" 取 消 " onClick="history.go(-1);">
                  </form><br />';
            $this->Messager($msg, null);
        }
        $sqlfilecount = 0;
        foreach ($unzip->Entries as $entry) {
            if (preg_match("/^[\\w\\d\\-\\_]+\\.sql\$/i", $entry->Name)) {
                $len = jio()->WriteFile('./data/backup/' . $backupdir . '/' . $entry->Name, $entry->Data);
                $sqlfilecount++;
            }
        }
        if (!$sqlfilecount) {
            $this->Messager('database_import_file_illegal');
        }
        $type_list = array("all_tables" => "全部数据", "custom" => "自定义备份", 'zip' => "压缩备份");
        $info = basename($datafile_server) . '<br />' . '版本' . ': ' . $identify[1] . '<br />' . '类型' . ': ' . $type_list[$identify[2]] . '<br />' . '方式' . ': ' . ($identify[3] == 'multivol' ? "多卷" : "SHELL") . '<br />';
        if ($multivol) {
            $multivol++;
            $df = $datafile_server;
            $datafile_server = preg_replace("/\\-(\\d+)(\\.zip)\$/i", "-{$multivol}\\2", $datafile_server);
            if (is_file($datafile_server)) {
                $this->Messager("数据文件 #{$multivol} 成功解压缩,程序将自动继续。", 'admin.php?mod=db&code=importzip&multivol=' . $multivol . '&datafile_vol1=' . $datafile_vol1 . '&datafile_server=' . urlencode($datafile_server) . '&importsubmit=yes&confirm=yes');
            } else {
                $to = 'admin.php?mod=db&code=doimport&from=server&datafile_server=' . urlencode($datafile_vol1) . '&importsubmit=yes&delunzip=yes';
                $msg = ' <form method="post" action="' . $to . '">
							<input type="hidden" name="FORMHASH" value="' . FORMHASH . '"  />
		                    <br /><br /><br />所有分卷文件解压缩完毕,您需要自动导入备份吗?导入后解压缩的文件将会被删除。<br /><br /><br /><br />
		                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
		                    <input class="button" type="button" value=" 取 消 " onClick="location.href=\'admin.php?mod=db&code=import\';">
		                  </form><br />';
                $this->Messager($msg, null);
            }
        }
        if ($identify[3] == 'multivol' && $identify[4] == 1 && preg_match("/\\-1(\\.zip+)\$/i", $datafile_server)) {
            $datafile_vol1 = $datafile_server;
            $datafile_server = preg_replace("/\\-1(\\.zip+)\$/i", "-2\\1", $datafile_server);
            if (is_file($datafile_server) && $datafile_vol1 != $datafile_server) {
                $to = 'admin.php?mod=db&code=importzip&multivol=1&datafile_vol1=./data/backup/' . $backupdir . '/' . $importfile . '&datafile_server=' . urlencode($datafile_server) . '&importsubmit=yes&confirm=yes';
                $msg = ' <form method="post" action="' . $to . '">
							<input type="hidden" name="FORMHASH" value="' . FORMHASH . '"  />
		                    ' . $info . '<br />备份文件解压缩完毕,您需要自动解压缩其它的分卷文件吗?<br /><br /><br /><br />
		                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
		                    <input class="button" type="button" value=" 取 消 " onClick="history.go(-1);">
		                  </form><br />';
                $this->Messager($msg, null);
            }
        }
        $to = 'admin.php?mod=db&code=doimport&from=server&datafile_server=./data/backup/' . $backupdir . '/' . $importfile . '&importsubmit=yes&delunzip=yes';
        $msg = ' <form method="post" action="' . $to . '">
					<input type="hidden" name="FORMHASH" value="' . FORMHASH . '"  />
                    <br /><br /><br />所有分卷文件解压缩完毕,您需要自动导入备份吗?导入后解压缩的文件将会被删除。<br /><br /><br /><br />
                    <input class="button" type="submit" name="confirmed" value=" 确 定 "> &nbsp;
                    <input class="button" type="button" value=" 取 消 " onClick="location.href=\\"admin.php?mod=db&code=import\\";">
                  </form><br />';
        $this->Messager($msg, null);
    }
Exemple #9
0
 /**
  * @Title: getNextSql 
  * @Description: todo(显示) 
  * @return string|boolean  
  * @author laicaixia 
  * @date 2013-5-31 下午5:27:02 
  * @throws 
  */
 public function show()
 {
     $filename = $_GET['filename'];
     $folder = urldecode($_GET['folder']);
     $gbk_folder = @iconv('UTF-8', 'gb2312', $folder);
     $folderdir = R("Backup/getBackupDir");
     $file = $folderdir . '/' . $gbk_folder . '/' . $filename;
     if (file_exists($file)) {
         import("@.ORG.Zip");
         $unzip = new SimpleUnzip($file);
         $unzip->SimpleUnzip();
         $dbname = C('DB_NAME');
         $tables = '';
         $file_count = $unzip->Count();
         for ($i = 0; $i < $file_count; $i++) {
             if ($unzip->GetName($i) == C('BACKUP_RECORD_FILE')) {
                 $tables = $unzip->GetData($i);
                 break;
             }
         }
         $tables = explode(',', $tables);
         $html_show = '';
         foreach ($tables as $table) {
             if ($table != C('BACKUP_TABLE') && $table != C('UPGRADE_TABLE')) {
                 $html_show .= "<label style='width:300px;'><input name='table' type='checkbox' value='{$table}' />{$table}</label>";
             }
         }
         $this->assign('html_show', $html_show);
         $this->assign('file', $filename);
         $this->assign('folder', $folder);
     }
     //还原模式显示
     if (C('RESUME_MODEL') == 'Database') {
         $modelInfo = "当前还原模式为:数据库级<br/>还原失败所有数据均不会被还原!";
     } else {
         if (C('RESUME_MODEL') == 'Table') {
             $modelInfo = "当前还原模式为:数据表级<br/>还原失败只有出错表数据不还原!";
         }
     }
     $this->assign('modelInfo', $modelInfo);
     $this->display();
 }