File: lib.ie.maintenance.php

package info (click to toggle)
dotclear 2.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 8,420 kB
  • sloc: php: 54,270; sql: 1,290; sh: 213; xml: 173; makefile: 158
file content (142 lines) | stat: -rw-r--r-- 3,521 bytes parent folder | download
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
# -- BEGIN LICENSE BLOCK ---------------------------------------
#
# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------
if (!defined('DC_RC_PATH')) { return; }

class ieMaintenanceExportblog extends dcMaintenanceTask
{
	protected $perm = 'admin';
	protected $tab = 'backup';
	protected $group = 'zipblog';

	protected $export_name;
	protected $export_type;

	protected function init()
	{
		$this->name = __('Database export');
		$this->task = __('Download database of current blog');

		$this->export_name = html::escapeHTML($this->core->blog->id.'-backup.txt');
		$this->export_type = 'export_blog';
	}

	public function execute()
	{
		// Create zip file
		if (!empty($_POST['file_name'])) {
			// This process make an http redirect
			$ie = new maintenanceDcExportFlat($this->core);
			$ie->setURL($this->id);
			$ie->process($this->export_type);
		}
		// Go to step and show form
		else {
			return 1;
		}
	}

	public function step()
	{
		// Download zip file
		if (isset($_SESSION['export_file']) && file_exists($_SESSION['export_file'])) {
			// Log task execution here as we sent file and stop script
			$this->log();

			// This process send file by http and stop script
			$ie = new maintenanceDcExportFlat($this->core);
			$ie->setURL($this->id);
			$ie->process('ok');
		}
		else {
			return
			'<p><label for="file_name">'.__('File name:').'</label>'.
			form::field('file_name', 50, 255, date('Y-m-d-H-i-').$this->export_name).
			'</p>'.
			'<p><label for="file_zip" class="classic">'.
			form::checkbox('file_zip', 1).' '.
			__('Compress file').'</label>'.
			'</p>';
		}
	}
}

class ieMaintenanceExportfull extends dcMaintenanceTask
{
	protected $tab = 'backup';
	protected $group = 'zipfull';

	protected $export_name;
	protected $export_type;

	protected function init()
	{
		$this->name = __('Database export');
		$this->task = __('Download database of all blogs');

		$this->export_name = 'dotclear-backup.txt';
		$this->export_type = 'export_all';
	}

	public function execute()
	{
		// Create zip file
		if (!empty($_POST['file_name'])) {
			// This process make an http redirect
			$ie = new maintenanceDcExportFlat($this->core);
			$ie->setURL($this->id);
			$ie->process($this->export_type);
		}
		// Go to step and show form
		else {
			return 1;
		}
	}

	public function step()
	{
		// Download zip file
		if (isset($_SESSION['export_file']) && file_exists($_SESSION['export_file'])) {
			// Log task execution here as we sent file and stop script
			$this->log();

			// This process send file by http and stop script
			$ie = new maintenanceDcExportFlat($this->core);
			$ie->setURL($this->id);
			$ie->process('ok');
		}
		else {
			return
			'<p><label for="file_name">'.__('File name:').'</label>'.
			form::field('file_name', 50, 255, date('Y-m-d-H-i-').$this->export_name).
			'</p>'.
			'<p><label for="file_zip" class="classic">'.
			form::checkbox('file_zip', 1).' '.
			__('Compress file').'</label>'.
			'</p>';
		}
	}
}

class maintenanceDcExportFlat extends dcExportFlat
{
	/**
	 * Set redirection URL of bakcup process.
	 *
	 * Bad hack to change redirection of dcExportFlat::process()
	 *
	 * @param	id	<b>string</b>	Task id
	 */
	public function setURL($id)
	{
		$this->url = sprintf('plugin.php?p=maintenance&task=%s', $id);
	}
}