<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
class Backups extends CI_Controller
{
    var $main_menu_name = "settings";
    var $sub_menu_name = "backups";
    public function index()
    {
        //echo 'Backup process';
        if (isset($_GET['link'])) {
            $var_1 = $_GET['link'];
            //    $file = $var_1;
            $dir   = "../db_backups/"; // trailing slash is important
            $file  = $dir . $var_1;
            //echo '<br>File path :'.$file;
            if (file_exists($file)) {
                header('Content-Description: File Transfer');
                header('Content-Type: application/octet-stream');
                header('Content-Disposition: attachment; filename=' . date('Y-m-d') . '_' . basename($file));
                header('Expires: 0');
                header('Cache-Control: must-revalidate');
                header('Pragma: public');
                header('Content-Length: ' . filesize($file));
                //ob_clean();
                flush();
                readfile($file);
                exit;
            } else
                echo '<br>NOT FOUND';
        }
    }
   
}