1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
4
|
|
|
// |
5
|
|
|
// eTraxis - Records tracking web-based system |
6
|
|
|
// Copyright (C) 2005-2011 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(LOAD_INLINE); |
36
|
|
|
|
37
|
|
|
$error = NO_ERROR; |
38
|
|
|
|
39
|
|
|
if (get_user_level() != USER_LEVEL_ADMIN) |
40
|
|
|
{ |
41
|
|
|
debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.'); |
42
|
|
|
header('HTTP/1.1 307 index.php'); |
43
|
|
|
exit; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
// new project has been submitted |
47
|
|
|
|
48
|
|
View Code Duplication |
if (try_request('submitted') == 'createform') |
49
|
|
|
{ |
50
|
|
|
debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
51
|
|
|
|
52
|
|
|
$project_name = ustrcut($_REQUEST['project_name'], MAX_PROJECT_NAME); |
53
|
|
|
$description = ustrcut($_REQUEST['description'], MAX_PROJECT_DESCRIPTION); |
54
|
|
|
|
55
|
|
|
$error = project_validate($project_name, $description); |
|
|
|
|
56
|
|
|
|
57
|
|
|
if ($error == NO_ERROR) |
58
|
|
|
{ |
59
|
|
|
$error = project_create($project_name, $description); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
switch ($error) |
63
|
|
|
{ |
64
|
|
|
case NO_ERROR: |
65
|
|
|
header('HTTP/1.0 200 OK'); |
66
|
|
|
break; |
67
|
|
|
|
68
|
|
|
case ERROR_INCOMPLETE_FORM: |
69
|
|
|
send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID)); |
70
|
|
|
break; |
71
|
|
|
|
72
|
|
|
case ERROR_ALREADY_EXISTS: |
73
|
|
|
send_http_error(get_html_resource(RES_ALERT_PROJECT_ALREADY_EXISTS_ID)); |
74
|
|
|
break; |
75
|
|
|
|
76
|
|
|
default: |
77
|
|
|
send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID)); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
exit; |
81
|
|
|
} |
82
|
|
|
else |
83
|
|
|
{ |
84
|
|
|
debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
85
|
|
|
|
86
|
|
|
$project_name = NULL; |
87
|
|
|
$description = NULL; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
// local JS functions |
91
|
|
|
|
92
|
|
|
$resTitle = get_js_resource(RES_ERROR_ID); |
93
|
|
|
$resOK = get_js_resource(RES_OK_ID); |
94
|
|
|
|
95
|
|
|
$xml = <<<JQUERY |
96
|
|
|
<script> |
97
|
|
|
|
98
|
|
|
function createSuccess () |
99
|
|
|
{ |
100
|
|
|
closeModal(); |
101
|
|
|
reloadTab(); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
function createError (XMLHttpRequest) |
105
|
|
|
{ |
106
|
|
|
jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}"); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
</script> |
110
|
|
|
JQUERY; |
111
|
|
|
|
112
|
|
|
// generate page |
113
|
|
|
|
114
|
|
|
$xml .= '<form name="createform" action="create.php" success="createSuccess" error="createError">' |
115
|
|
|
. '<group>' |
116
|
|
|
. '<control name="project_name" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
117
|
|
|
. '<label>' . get_html_resource(RES_PROJECT_NAME_ID) . '</label>' |
118
|
|
|
. '<editbox maxlen="' . MAX_PROJECT_NAME . '">' . ustr2html($project_name) . '</editbox>' |
119
|
|
|
. '</control>' |
120
|
|
|
. '<control name="description">' |
121
|
|
|
. '<label>' . get_html_resource(RES_DESCRIPTION_ID) . '</label>' |
122
|
|
|
. '<editbox maxlen="' . MAX_PROJECT_DESCRIPTION . '">' . ustr2html($description) . '</editbox>' |
123
|
|
|
. '</control>' |
124
|
|
|
. '</group>' |
125
|
|
|
. '<note>' . get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID) . '</note>' |
126
|
|
|
. '</form>'; |
127
|
|
|
|
128
|
|
|
echo(xml2html($xml)); |
129
|
|
|
|
130
|
|
|
?> |
131
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.