Revision 187
Added by ryan about 19 years ago
trunk/wb/modules/backup/backup-sql.php | ||
---|---|---|
26 | 26 |
// Check if user clicked on the backup button |
27 | 27 |
if(!isset($_POST['backup'])){ header('Location: ../'); } |
28 | 28 |
|
29 |
// Temporary backup file
|
|
30 |
$temp_file = WB_PATH.'/temp/WB-backup-'.date('ymd-His').'.sql';
|
|
29 |
// Include config
|
|
30 |
require_once('../../config.php');
|
|
31 | 31 |
|
32 |
// Create new admin object |
|
33 |
require(WB_PATH.'/framework/class.admin.php'); |
|
34 |
$admin = new admin('Settings', 'settings_advanced', false); |
|
35 |
|
|
36 |
// Begin output var |
|
37 |
$output = "\n". |
|
38 |
"#". |
|
39 |
"# Website Baker ".WB_VERSION." Backup (SQL)\n". |
|
40 |
"# Date: ".gmdate(TIME_FORMAT, mktime()+TIMEZONE)." Time: ".gmdate(TIME_FORMAT, mktime()+TIMEZONE)."\n". |
|
41 |
"#". |
|
42 |
"\n"; |
|
43 |
|
|
32 | 44 |
// Get table names |
33 | 45 |
$result = $database->query("SHOW TABLE STATUS"); |
34 | 46 |
|
... | ... | |
57 | 69 |
} |
58 | 70 |
$sql_code = substr($sql_code, 0, -1); |
59 | 71 |
$sql_code.= ";\r\n"; |
72 |
$output .= $sql_backup.$sql_code; |
|
60 | 73 |
} |
61 | 74 |
} |
62 | 75 |
|
63 | 76 |
// Output file |
64 | 77 |
header('Content-Type: application/octet-stream'); |
65 |
header('Content-Disposition: attachment; filename="'.str_replace(WB_PATH.'/temp', '', $temp_file).'"'); |
|
66 |
echo $sql_code; |
|
78 |
header('Content-Disposition: attachment'); |
|
79 |
header('Filename: "'.str_replace(WB_PATH.'/temp', '', $temp_file).'"'); |
|
80 |
echo $output; |
|
67 | 81 |
|
68 | 82 |
?> |
Also available in: Unified diff
Worked on backup-sql.php