-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestore.php
More file actions
51 lines (33 loc) · 1.55 KB
/
restore.php
File metadata and controls
51 lines (33 loc) · 1.55 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
<?php
require __DIR__ . '/bootstrap.php';
if ($argv && isset($argv[1])) {
$fileName = basename($argv[1]) . ".sql";
$filePath = DUMP_DIR_PATH . DIRECTORY_SEPARATOR . $fileName;
if (is_file($filePath)) {
$Config = Core_DataBase::instance()->getConfig();
$aTables = Core_DataBase::instance()->getTables();
foreach ($aTables as $sTablesName) {
Core_DataBase::instance()->query("DROP TABLE `{$sTablesName}`");
}
Sql_Controller::instance()->executeByFile($filePath);
$deploySql = "
UPDATE structures SET https = 0;
UPDATE constants SET active = 0 WHERE name = \"USE_ONLY_HTTPS_AUTHORIZATION\";
UPDATE site_aliases SET name = REGEXP_REPLACE(name, '\.[a-z]+$', '.local');
UPDATE modules SET active = 0 WHERE path = 'update';
UPDATE modules SET active = 0 WHERE path = 'cache';
UPDATE modules SET active = 0 WHERE path = 'market';
INSERT INTO constants (`constant_dir_id`, `name`, `value`, `description`, `active`, `user_id`, `deleted`) VALUES (0,'SQL_LOG','true','',1,19,0)
ON DUPLICATE KEY UPDATE value = 'true';
";
$User = Core_Entity::factory("User")->getFirst();
if ($User) {
$User->login = "demo";
$User->password = Core_Hash::instance()->hash("demo");
$User->save();
}
Sql_Controller::instance()->execute($deploySql);
} else {
die('File not found');
}
}