mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
backup via /backup
This commit is contained in:
parent
c04a55d46b
commit
fd4983badc
@ -46,6 +46,15 @@ $config['bitly_apikey'] = '';
|
||||
**/
|
||||
$config['cron_key'] = '';
|
||||
|
||||
/**
|
||||
* Credentials for the backup URL
|
||||
*
|
||||
* Basic auth user & pass for the backup URL, accessible via http://yoursite.com/backup
|
||||
*
|
||||
**/
|
||||
$config['backup_user'] = '';
|
||||
$config['backup_pass'] = '';
|
||||
|
||||
/**
|
||||
* Pastes Per Page
|
||||
*
|
||||
|
43
htdocs/application/controllers/backup.php
Executable file
43
htdocs/application/controllers/backup.php
Executable file
@ -0,0 +1,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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user