Location: PHPKode > projects > Browseable Online Backup System > bobs-0.6.4/winc/restore.php
<?php

// restore files to remote server

require("inc/config.php");
require("inc/class_backup.php");
require("inc/class_search.php");
require("inc/class_db.php");
require("inc/class_restore.php");
require("inc/class_rfasttemplate.php");

session_start();

?>

<html>
<head>
<title>Backupserver</title>
<link rel="STYLESHEET" href="look.css" type="text/css">
</head>
<body>

<?php
// reference session objects
$backup = &$_SESSION['backup'];

// get config from backup object
        $config = $backup->get_config();
        $config["where"] = $_GET['where'];

	$res = new restore($config);


/* order of operation:
			1: collect data about the following stuff
				size of files to restore
				number of files to restore
				diskspace free on remote server.
					:: check that we have a free cmd_loop????
					:: check paths
					:: write mount.lock file
					:: mount NFS using cmd_loop
					:: check duplicate filenames
					:: wait till mount.done file is removed
						:: check that NFS is mounted
					:: get stats
					:: compare files sizes vs diskspace free
					:: umount using cmd_loop


			2: display information
					:: confirmation button or
					:: not enough free diskspace. Free some.

			3: get a script from class_restore
				drop it to class_command
					:: check filename before write
					:: rename if needed

			4: write confirmation that process is started.


*/

if ( !isset($_POST['check']) && !isset($_POST['restore']) ) {
	?>
	<center>
	<big>
	<br><br>
	<p>Before the selected files can be restore the system needs to check a few things.</p>
	<p>Click the button below and wait. This will generally take between 5 and 20 seconds</p>
	</big>
	<form method="post">
	<input type="hidden" name="check" value="do_check"> 
	<input type="submit" name="submit" value="Check server">
	</form>
	</center>
	<?php
}


if ( $_POST['check'] == "do_check" ) {

	// check stuff before restoring files
	// write a temp file
	// return a shell script
	$result = $res->pre_restore_check();
	// mount server
	if ( $result["shell"] != '' ) {
		$result = $backup->add_queue_command($result["shell"], $result["bin"]);
	} else {
		echo $result["html"];
		exit;
	}


	// check if mount was succesful.
	// get remote server stats
	$result = $res->post_restore_check(); 

	echo "<center>";
	echo $result["html"];
	if ( !isset($result["error"]) ) {
		echo '<form name="confirm"  method="post">' . "\n"; 
		echo '<input type="hidden" name="restore" value="do_it">' . "\n"; 
		echo '<input type="hidden" name="check" value="check_done">' . "\n"; 
		echo '<input type="submit" value="Go ahead">' . "\n"; 
		echo '</form>';
	}
	echo "</center>";
}	


// restore files if all is good.
if ( $_POST['restore'] == "do_it" ) {
	$result = $res->restore_files();

	if ( $result["shell"] != '' ) {
		echo "<center><br>";
		echo $result["html"];
		echo "</center>";
		$result = $backup->add_queue_command($result["shell"], $result["bin"] );
	}
}


	unset($res);

?>
Return current item: Browseable Online Backup System