1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
4
|
|
|
// |
5
|
|
|
// eTraxis - Records tracking web-based system |
6
|
|
|
// Copyright (C) 2010 Artem Rodygin |
7
|
|
|
// |
8
|
|
|
// This program is free software: you can redistribute it and/or modify |
9
|
|
|
// it under the terms of the GNU General Public License as published by |
10
|
|
|
// the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
// (at your option) any later version. |
12
|
|
|
// |
13
|
|
|
// This program is distributed in the hope that it will be useful, |
14
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
// GNU General Public License for more details. |
17
|
|
|
// |
18
|
|
|
// You should have received a copy of the GNU General Public License |
19
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
// |
21
|
|
|
//------------------------------------------------------------------------------ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @package eTraxis |
25
|
|
|
* @ignore |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
/**#@+ |
29
|
|
|
* Dependency. |
30
|
|
|
*/ |
31
|
|
|
require_once('../engine/engine.php'); |
32
|
|
|
require_once('../dbo/projects.php'); |
33
|
|
|
/**#@-*/ |
34
|
|
|
|
35
|
|
|
init_page(); |
36
|
|
|
|
37
|
|
|
$id = ustr2int(try_request('id')); |
38
|
|
|
|
39
|
|
View Code Duplication |
if (get_user_level() == USER_LEVEL_ADMIN) |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
$xml = project_export($id); |
42
|
|
|
|
43
|
|
|
if (is_null($xml)) |
44
|
|
|
{ |
45
|
|
|
debug_write_log(DEBUG_NOTICE, 'Project cannot be found.'); |
46
|
|
|
header('Location: index.php'); |
47
|
|
|
} |
48
|
|
|
else |
49
|
|
|
{ |
50
|
|
|
header('Pragma: private'); |
51
|
|
|
header('Cache-Control: private, must-revalidate'); |
52
|
|
|
header('Content-type: text/xml'); |
53
|
|
|
header('Content-Disposition: attachment; filename=project-' . str_pad($id, 3, '0', STR_PAD_LEFT) . '.xml'); |
54
|
|
|
|
55
|
|
|
echo($xml); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
else |
59
|
|
|
{ |
60
|
|
|
debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.'); |
61
|
|
|
header('Location: view.php?id=' . $id); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
?> |
65
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.