forked from Avinm/QuickSlots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.php
32 lines (30 loc) · 790 Bytes
/
backup.php
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
<?php
/**
* Back end routines to generate/restore backups, invoked by dean.php
* @author Avin E.M
*/
require_once('functions.php');
if(!sessionCheck('level','dean'))
die();
require_once('connect_db.php');
if(valueCheck('action','backup'))
{
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename=backup_' . date("H-i_d-m-Y") . '.sql');
passthru("mysqldump --user={$config['db_user']} --password={$config['db_pswd']} --host={$config['db_host']} {$config['db_name']}");
}
else
{
$snapshot = $_FILES['snapshot']['tmp_name'];
try
{
$db->exec(file_get_contents($snapshot));
unlink($snapshot);
header("Location: dean.php?status=restoreComplete");
}
catch(PDOException $e)
{
postResponse("error",$e->errorInfo[2]);
}
}
?>