Location: PHPKode > scripts > PHP Hosting Directory > phphost_directoryv2/include/admin.restore.php
<?

function my_gzdecode($string) {
 $string = substr($string, 10);
 return gzinflate($string);
}

if($request[2] == 'db') {
	$t->assign('db', 1);
	if ($_SERVER['REQUEST_METHOD'] == 'POST')
	{
		if (trim($_FILES['backup']['name']) != '')
		{
			$restore_data = read_file($_FILES['backup']['tmp_name']);
			$sql = my_gzdecode($restore_data);
	
			$sqls = split(";", $sql);
			foreach ($sqls as $sql)
			{
				if (trim($sql) != '') { _mysql_query($sql); }
			}

			$t->assign('info_message', '<font color="green">RESTORED!</font>');
		}
		else
		{
			$t->assign('info_message', '<font color="red">Please provide valid file for restore!</font>');
		}
	}
}
elseif($request[2] == 'logos')
{
	$t->assign('logos', 1);
	if ($_SERVER['REQUEST_METHOD'] == 'POST')
	{
		if (trim($_FILES['backup']['name']) != '')
		{
			$restore_data = read_file($_FILES['backup']['tmp_name']);
			$tmp_filename = "/tmp/php-" . md5(mt_rand(0,mt_getrandmax())) . ".gz";
			$fd = fopen($tmp_filename, "wb");
			fwrite($fd, $restore_data);
			fclose($fd);

			$out = `tar -vxzf $tmp_filename`;
			@unlink($tmp_filename);

			$t->assign('info_message', '<font color="green">RESTORED!</font>');
		}
		else
		{
			$t->assign('info_message', '<font color="red">Please provide valid file for restore!</font>');
		}
	}
}

$t->assign('main_html', 'admin_'.$request[1].'.html');

?>
Return current item: PHP Hosting Directory