1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | if (!defined('DC_RC_PATH')) { return; } |
---|
13 | |
---|
14 | class ieMaintenanceExportblog extends dcMaintenanceTask |
---|
15 | { |
---|
16 | protected $perm = 'admin'; |
---|
17 | protected $tab = 'backup'; |
---|
18 | protected $group = 'zipblog'; |
---|
19 | |
---|
20 | protected $export_name; |
---|
21 | protected $export_type; |
---|
22 | |
---|
23 | protected function init() |
---|
24 | { |
---|
25 | $this->name = __('Database export'); |
---|
26 | $this->task = __('Download database of current blog'); |
---|
27 | |
---|
28 | $this->export_name = html::escapeHTML($this->core->blog->id.'-backup.txt'); |
---|
29 | $this->export_type = 'export_blog'; |
---|
30 | } |
---|
31 | |
---|
32 | public function execute() |
---|
33 | { |
---|
34 | // Create zip file |
---|
35 | if (!empty($_POST['file_name'])) { |
---|
36 | // This process make an http redirect |
---|
37 | $ie = new maintenanceDcExportFlat($this->core); |
---|
38 | $ie->setURL($this->id); |
---|
39 | $ie->process($this->export_type); |
---|
40 | } |
---|
41 | // Go to step and show form |
---|
42 | else { |
---|
43 | return 1; |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | public function step() |
---|
48 | { |
---|
49 | // Download zip file |
---|
50 | if (isset($_SESSION['export_file']) && file_exists($_SESSION['export_file'])) { |
---|
51 | // Log task execution here as we sent file and stop script |
---|
52 | $this->log(); |
---|
53 | |
---|
54 | // This process send file by http and stop script |
---|
55 | $ie = new maintenanceDcExportFlat($this->core); |
---|
56 | $ie->setURL($this->id); |
---|
57 | $ie->process('ok'); |
---|
58 | } |
---|
59 | else { |
---|
60 | return |
---|
61 | '<p><label for="file_name">'.__('File name:').'</label>'. |
---|
62 | form::field('file_name', 50, 255, date('Y-m-d-H-i-').$this->export_name). |
---|
63 | '</p>'. |
---|
64 | '<p><label for="file_zip" class="classic">'. |
---|
65 | form::checkbox('file_zip', 1).' '. |
---|
66 | __('Compress file').'</label>'. |
---|
67 | '</p>'; |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | class ieMaintenanceExportfull extends dcMaintenanceTask |
---|
73 | { |
---|
74 | protected $tab = 'backup'; |
---|
75 | protected $group = 'zipfull'; |
---|
76 | |
---|
77 | protected $export_name; |
---|
78 | protected $export_type; |
---|
79 | |
---|
80 | protected function init() |
---|
81 | { |
---|
82 | $this->name = __('Database export'); |
---|
83 | $this->task = __('Download database of all blogs'); |
---|
84 | |
---|
85 | $this->export_name = 'dotclear-backup.txt'; |
---|
86 | $this->export_type = 'export_all'; |
---|
87 | } |
---|
88 | |
---|
89 | public function execute() |
---|
90 | { |
---|
91 | // Create zip file |
---|
92 | if (!empty($_POST['file_name'])) { |
---|
93 | // This process make an http redirect |
---|
94 | $ie = new maintenanceDcExportFlat($this->core); |
---|
95 | $ie->setURL($this->id); |
---|
96 | $ie->process($this->export_type); |
---|
97 | } |
---|
98 | // Go to step and show form |
---|
99 | else { |
---|
100 | return 1; |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | public function step() |
---|
105 | { |
---|
106 | // Download zip file |
---|
107 | if (isset($_SESSION['export_file']) && file_exists($_SESSION['export_file'])) { |
---|
108 | // Log task execution here as we sent file and stop script |
---|
109 | $this->log(); |
---|
110 | |
---|
111 | // This process send file by http and stop script |
---|
112 | $ie = new maintenanceDcExportFlat($this->core); |
---|
113 | $ie->setURL($this->id); |
---|
114 | $ie->process('ok'); |
---|
115 | } |
---|
116 | else { |
---|
117 | return |
---|
118 | '<p><label for="file_name">'.__('File name:').'</label>'. |
---|
119 | form::field('file_name', 50, 255, date('Y-m-d-H-i-').$this->export_name). |
---|
120 | '</p>'. |
---|
121 | '<p><label for="file_zip" class="classic">'. |
---|
122 | form::checkbox('file_zip', 1).' '. |
---|
123 | __('Compress file').'</label>'. |
---|
124 | '</p>'; |
---|
125 | } |
---|
126 | } |
---|
127 | } |
---|
128 | |
---|
129 | class maintenanceDcExportFlat extends dcExportFlat |
---|
130 | { |
---|
131 | /** |
---|
132 | * Set redirection URL of bakcup process. |
---|
133 | * |
---|
134 | * Bad hack to change redirection of dcExportFlat::process() |
---|
135 | * |
---|
136 | * @param id <b>string</b> Task id |
---|
137 | */ |
---|
138 | public function setURL($id) |
---|
139 | { |
---|
140 | $this->url = sprintf('plugin.php?p=maintenance&task=%s', $id); |
---|
141 | } |
---|
142 | } |
---|