<?php

if (!defined("_VALID_PHP")) {
    die('Direct access to this location is not allowed.');
}
require_once BASEPATH . "lib/class_dbtools.php";
$tools = new dbTools();
if (isset($_GET['backupok']) && $_GET['backupok'] == "1") {
    $core->msgOk('<span>Success!</span>Backup created successfully!', 1, 1);
}
if (isset($_GET['restore']) && $_GET['restore'] == "1") {
    $core->msgOk('<span>Success!</span>Database restored successfully!', 1, 1);
}
if (isset($_GET['create']) && $_GET['create'] == "1") {
    $tools->doBackup('', false);
}
if (isset($_POST['backup_file'])) {
    $tools->doRestore($_POST['backup_file']);
}
?>

<h1><img src="../images/system-lrg.png" alt="" />Database Maintenance</h1>
<p class="info">Make sure your database is backed up frequently. Click on Create backup to manually backup your database.<br />
  The backups are stored in the [<strong>/admin/backups/</strong>] folder and can be downloaded from the list below. <br />
  Your most recent backup is highlighted. Make sure you download your most recent backup, and delete the rest.</p>
<h2><span>
  <button onclick="window.location='index.php?do=backup&amp;create=1';" type="button" class="button-alt-sml">Create Backup</button>
  </span>Viewing Most Recent Backups</h2>
<div id="backup">
  <?php 
$dir = BASEPATH . 'admin/backups/';