-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathDbBackup.php
More file actions
113 lines (97 loc) · 2.96 KB
/
DbBackup.php
File metadata and controls
113 lines (97 loc) · 2.96 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
// vim: set ts=4 sw=4 sts=4 et:
/**
* LiteCommerce
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to licensing@litecommerce.com so we can send you a copy immediately.
*
* PHP version 5.3.0
*
* @category LiteCommerce
* @author Creative Development LLC <info@cdev.ru>
* @copyright Copyright (c) 2011 Creative Development LLC <info@cdev.ru>. All rights reserved
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.litecommerce.com/
* @see ____file_see____
* @since 1.0.0
*/
namespace XLite\Controller\Admin;
/**
* Controller for Database backup page
*
* @see ____class_see____
* @since 1.0.0
*/
class DbBackup extends \XLite\Controller\Admin\Base\BackupRestore
{
/**
* doActionBackup
*
* @return void
* @see ____func_see____
* @since 1.0.0
*/
protected function doActionBackup()
{
$verbose = false;
$destfile = null; // write to 'stdout' by default
if (\XLite\Core\Request::getInstance()->write_to_file) {
$destFile = $this->sqldumpFile;
$verbose = true;
$this->startDump();
} else {
$destFile = LC_DIR_BACKUP . sprintf('sqldump.backup.%d.sql', time());
$this->startDownload('db_backup.sql');
}
// Make database backup and store it in $this->sqldumpFile file
$result = \XLite\Core\Database::getInstance()->exportSQLToFile($destFile, $verbose);
if (\XLite\Core\Request::getInstance()->write_to_file) {
echo ('<br /><b>' . static::t('Database backup created successfully') . '</b><br />');
} else {
readfile($destFile);
unlink($destFile);
exit ();
}
}
/**
* doActionDelete
*
* @return void
* @throws
* @see ____func_see____
* @since 1.0.0
*/
protected function doActionDelete()
{
if (file_exists($this->sqldumpFile)) {
if (!@unlink($this->sqldumpFile)) {
throw new \Exception(static::t('Unable to delete file') . ' ' . $this->sqldumpFile);
}
}
}
/**
* getPageReturnURL
*
* @return array
* @see ____func_see____
* @since 1.0.0
*/
protected function getPageReturnURL()
{
$url = array();
if ('backup' == \XLite\Core\Request::getInstance()->action) {
$url[] = '<a href="admin.php?target=db_backup">'.static::t('Return to admin interface.').'</a>';
} else {
$url = parent::getPageReturnURL();
}
return $url;
}
}