1<?php 2/** 3 * Class and Function List: 4 * Function list: 5 * - __construct() 6 * - index() 7 * Classes list: 8 * - Backup extends CI_Controller 9 */ 10 11class Backup extends CI_Controller 12{ 13 14 function __construct() 15 { 16 parent::__construct(); 17 18 //protection 19 $user = $this->config->item('backup_user'); 20 $pass = $this->config->item('backup_pass'); 21 22 if ($user == '' || $pass == '' || !isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass) 23 { 24 header('WWW-Authenticate: Basic realm="Backup"'); 25 header('HTTP/1.0 401 Unauthorized'); 26 exit; 27 } 28 } 29 30 function index() 31 { 32 33 // Load the DB utility class 34 $this->load->dbutil(); 35 36 // Backup your entire database and assign it to a variable 37 $backup = & $this->dbutil->backup(); 38 39 // Load the download helper and send the file to your desktop 40 $this->load->helper('download'); 41 force_download('stikked.gz', $backup); 42 } 43} 44