aboutsummaryrefslogtreecommitdiffstats
path: root/htdocs/application/controllers/Backup.php
blob: 0f4202666fa32d7f0e61fa73b0e7cdcbf67af115 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
 * Class and Function List:
 * Function list:
 * - __construct()
 * - index()
 * Classes list:
 * - Backup extends CI_Controller
 */

class Backup extends CI_Controller
{
	
	function __construct() 
	{
		parent::__construct();

		//protection
		$user = $this->config->item('backup_user');
		$pass = $this->config->item('backup_pass');
		
		if ($user == '' || $pass == '' || !isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass) 
		{
			header('WWW-Authenticate: Basic realm="Backup"');
			header('HTTP/1.0 401 Unauthorized');
			exit;
		}
	}
	
	function index() 
	{

		// Load the DB utility class
		$this->load->dbutil();

		// Backup your entire database and assign it to a variable
		$backup = & $this->dbutil->backup();

		// Load the download helper and send the file to your desktop
		$this->load->helper('download');
		force_download('stikked.gz', $backup);
	}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy