Issues (1098)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/reminders/modify.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
//------------------------------------------------------------------------------
4
//
5
//  eTraxis - Records tracking web-based system
6
//  Copyright (C) 2006-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
require_once('../dbo/templates.php');
34
require_once('../dbo/reminders.php');
35
/**#@-*/
36
37
init_page(LOAD_INLINE);
38
39
if (!EMAIL_NOTIFICATIONS_ENABLED)
40
{
41
    debug_write_log(DEBUG_NOTICE, 'Email Notifications functionality is disabled.');
42
    header('HTTP/1.1 307 ../index.php');
43
    exit;
44
}
45
46
if (!can_reminder_be_created())
47
{
48
    debug_write_log(DEBUG_NOTICE, 'Reminders are denied.');
49
    header('HTTP/1.1 307 ../index.php');
50
    exit;
51
}
52
53
// check that requested reminder exists
54
55
$id       = ustr2int(try_request('id'));
56
$reminder = reminder_find($id);
57
58
if (!$reminder)
0 ignored issues
show
Bug Best Practice introduced by
The expression $reminder of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
59
{
60
    debug_write_log(DEBUG_NOTICE, 'Reminder cannot be found.');
61
    header('HTTP/1.1 307 index.php');
62
    exit;
63
}
64
65
$error = NO_ERROR;
66
67
$project_id    = $reminder['project_id'];
68
$project_name  = $reminder['project_name'];
69
$template_id   = $reminder['template_id'];
70
$template_name = $reminder['template_name'];
71
72
// changed reminder has been submitted
73
74
if (try_request('submitted') == 'modifyform')
75
{
76
    debug_write_log(DEBUG_NOTICE, 'Data are submitted.');
77
78
    $name    = ustrcut($_REQUEST['name'],    MAX_REMINDER_NAME);
79
    $subject = ustrcut($_REQUEST['subject'], MAX_REMINDER_SUBJECT);
80
81
    $state_id = ustr2int(try_request('state'));
82
    $group_id = ustr2int(try_request('group'), REMINDER_FLAG_RESPONSIBLE);
83
84
    $error = reminder_validate($name, $subject);
85
86 View Code Duplication
    if ($error == NO_ERROR)
87
    {
88
        $error = reminder_modify($id,
89
                                 $name,
90
                                 $subject,
91
                                 $state_id,
92
                                 ($group_id < 0 ? NULL      : $group_id),
93
                                 ($group_id < 0 ? $group_id : REMINDER_FLAG_GROUP));
94
    }
95
96
    switch ($error)
97
    {
98
        case NO_ERROR:
99
            header('HTTP/1.0 200 OK');
100
            break;
101
102
        case ERROR_INCOMPLETE_FORM:
103
            send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID));
104
            break;
105
106
        case ERROR_ALREADY_EXISTS:
107
            send_http_error(get_html_resource(RES_ALERT_REMINDER_ALREADY_EXISTS_ID));
108
            break;
109
110
        default:
111
            send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID));
112
    }
113
114
    exit;
115
}
116
else
117
{
118
    debug_write_log(DEBUG_NOTICE, 'Data are being requested.');
119
120
    $name     = $reminder['reminder_name'];
121
    $subject  = $reminder['subject_text'];
122
    $state_id = $reminder['state_id'];
123
    $group_id = ($reminder['group_flag'] == REMINDER_FLAG_GROUP ? $reminder['group_id'] : $reminder['group_flag']);
124
}
125
126
// local JS functions
127
128
$resTitle = get_js_resource(RES_ERROR_ID);
129
$resOK    = get_js_resource(RES_OK_ID);
130
131
$xml = <<<JQUERY
132
<script>
133
134
function modifySuccess ()
135
{
136
    closeModal();
137
    reloadTab();
138
}
139
140
function modifyError (XMLHttpRequest)
141
{
142
    jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}");
143
}
144
145
</script>
146
JQUERY;
147
148
// generate page
149
150
$xml .= '<form name="modifyform" action="modify.php?id=' . $id . '" success="modifySuccess" error="modifyError">'
151
      . '<group>'
152
      . '<control name="project" required="' . get_html_resource(RES_REQUIRED3_ID) . '">'
153
      . '<label>' . get_html_resource(RES_PROJECT_ID) . '</label>'
154
      . '<combobox>'
155
      . '<listitem value="' . $project_id . '">' . ustr2html($project_name) . '</listitem>'
156
      . '</combobox>'
157
      . '</control>'
158
      . '<control name="template" required="' . get_html_resource(RES_REQUIRED3_ID) . '">'
159
      . '<label>' . get_html_resource(RES_TEMPLATE_ID) . '</label>'
160
      . '<combobox>'
161
      . '<listitem value="' . $template_id . '">' . ustr2html($template_name) . '</listitem>'
162
      . '</combobox>'
163
      . '</control>'
164
      . '<control name="state" required="' . get_html_resource(RES_REQUIRED3_ID) . '">'
165
      . '<label>' . get_html_resource(RES_STATE_ID) . '</label>'
166
      . '<combobox>';
167
168
$rs = dal_query('states/list.sql', $template_id, 'state_name');
169
170 View Code Duplication
while (($row = $rs->fetch()))
171
{
172
    $xml .= ($state_id == $row['state_id']
173
                ? '<listitem value="' . $row['state_id'] . '" selected="true">'
174
                : '<listitem value="' . $row['state_id'] . '">')
175
          . ustr2html($row['state_name'])
176
          . '</listitem>';
177
}
178
179
$xml .= '</combobox>'
180
      . '</control>'
181
      . '<control name="name" required="' . get_html_resource(RES_REQUIRED3_ID) . '">'
182
      . '<label>' . get_html_resource(RES_REMINDER_NAME_ID) . '</label>'
183
      . '<editbox maxlen="' . MAX_REMINDER_NAME . '">' . ustr2html($name) . '</editbox>'
184
      . '</control>'
185
      . '<control name="subject">'
186
      . '<label>' . get_html_resource(RES_REMINDER_SUBJECT_ID) . '</label>'
187
      . '<editbox maxlen="' . MAX_REMINDER_SUBJECT . '">' . ustr2html($subject) . '</editbox>'
188
      . '</control>'
189
      . '<control name="group" required="' . get_html_resource(RES_REQUIRED3_ID) . '">'
190
      . '<label>' . get_html_resource(RES_REMINDER_RECIPIENTS_ID) . '</label>'
191
      . '<combobox>'
192
      . '<listitem value="' . REMINDER_FLAG_AUTHOR      . ($group_id == REMINDER_FLAG_AUTHOR      ? '" selected="true">' : '">') . sprintf('%s (%s)', get_html_resource(RES_AUTHOR_ID),      get_html_resource(RES_ROLE_ID)) . '</listitem>'
193
      . '<listitem value="' . REMINDER_FLAG_RESPONSIBLE . ($group_id == REMINDER_FLAG_RESPONSIBLE ? '" selected="true">' : '">') . sprintf('%s (%s)', get_html_resource(RES_RESPONSIBLE_ID), get_html_resource(RES_ROLE_ID)) . '</listitem>';
194
195
$rs = dal_query('groups/list.sql', $project_id, 'is_global, group_name');
196
197 View Code Duplication
while (($row = $rs->fetch()))
198
{
199
    $xml .= ($group_id == $row['group_id']
200
                ? '<listitem value="' . $row['group_id'] . '" selected="true">'
201
                : '<listitem value="' . $row['group_id'] . '">')
202
          . sprintf('%s (%s)', ustr2html($row['group_name']), get_html_resource($row['is_global'] ? RES_GLOBAL_ID : RES_LOCAL_ID))
203
          . '</listitem>';
204
}
205
206
$xml .= '</combobox>'
207
      . '</control>'
208
      . '</group>'
209
      . '<note>' . get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID) . '</note>'
210
      . '</form>';
211
212
echo(xml2html($xml));
213
214
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
215