This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | // ------------------------------------------------------------------------ // |
||
3 | // -- XoopsHP Module -- Xoops e-Learning System // |
||
4 | // Copyright (c) 2005 SUDOW-SOKEN // |
||
5 | // <http://www.mailpark.co.jp/> // |
||
6 | // ------------------------------------------------------------------------ // |
||
7 | // Based on XoopsHP1.01 by Yoshi, aka HowardGee. // |
||
8 | // ------------------------------------------------------------------------ // |
||
9 | // This program is free software; you can redistribute it and/or modify // |
||
10 | // it under the terms of the GNU General Public License as published by // |
||
11 | // the Free Software Foundation; either version 2 of the License, or // |
||
12 | // (at your option) any later version. // |
||
13 | // // |
||
14 | // You may not change or alter any portion of this comment or credits // |
||
15 | // of supporting developers from this source code or any supporting // |
||
16 | // source code which is considered copyrighted (c) material of the // |
||
17 | // original comment or credit authors. // |
||
18 | // // |
||
19 | // This program is distributed in the hope that it will be useful, // |
||
20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
22 | // GNU General Public License for more details. // |
||
23 | // // |
||
24 | // You should have received a copy of the GNU General Public License // |
||
25 | // along with this program; if not, write to the Free Software // |
||
26 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
27 | // ------------------------------------------------------------------------ // |
||
28 | |||
29 | // HTTP_REFERER ACTION CHECK -> DBQuery -> function.php error $_SERVER[$key] |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
36% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
30 | // If can't use command "$_SERVER["HTTP_REFERER"]" , don't save portfolio DB. |
||
31 | // analyze by kazuo sudow. |
||
32 | // |
||
33 | // TEST-TEST-TEST-TEST |
||
34 | // global $referer; |
||
35 | // $referer = $_SERVER["HTTP_REFERER"]; |
||
36 | // if (!empty($referer)) { |
||
37 | // $_SERVER["HTTP_REFERER"] = "dummy"; |
||
38 | // $referer = $_SERVER["HTTP_REFERER"]; |
||
39 | //} |
||
40 | |||
41 | include_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
42 | include_once(XOOPS_ROOT_PATH . '/include/cp_functions.php'); |
||
43 | global $db, $xoopsConfig, $xoopsUser, $xoopsModule, $xoopsObject, $xoopsDB; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
44 | |||
45 | if ($_SERVER['HTTP_HOST'] != $_SERVER['SERVER_NAME']) { |
||
46 | exit('Access Denied'); |
||
47 | } elseif (!isset($_COOKIE['xoopsHP_file_id'])) { |
||
48 | exit('Oops, a problem in the cookie!'); |
||
49 | } |
||
50 | |||
51 | // Get the file number |
||
52 | $quiz_id = (int)$_COOKIE['xoopsHP_file_id']; |
||
53 | |||
54 | // Delete cookie -> $quiz_id |
||
55 | setcookie('xoopsHP_file_id', '', time() - 3600); |
||
56 | |||
57 | // kazuo sudow |
||
58 | // - non pair Open-Close Table.. More Header Written BUG. |
||
59 | // OpenTable(); |
||
60 | |||
61 | $myts = MyTextSanitizer::getInstance(); |
||
62 | $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0; |
||
63 | $user_email = $xoopsUser ? $xoopsUser->getVar('email') : ''; |
||
64 | $uname = $xoopsUser ? $xoopsUser->getVar('uname') : ''; |
||
65 | $username = $xoopsUser ? $xoopsUser->getVar('name') : ''; |
||
66 | |||
67 | // Get the instructor's email addy etc |
||
68 | $teacher_email = ''; |
||
69 | include __DIR__ . '/module_prefix.php'; |
||
70 | $result = $xoopsDB->query('SELECT secid, title, results_to FROM ' . $xoopsDB->prefix($module_prefix . '_quiz') . " WHERE artid=$quiz_id"); |
||
71 | list($secid, $quiz_title, $teacher_email) = $xoopsDB->fetchRow($result); |
||
72 | $secid = (int)$secid; |
||
73 | include __DIR__ . '/module_prefix.php'; |
||
74 | $result = $xoopsDB->query('SELECT secname FROM ' . $xoopsDB->prefix($module_prefix . '_sections') . " WHERE secid=$secid"); |
||
75 | list($secname) = $xoopsDB->fetchRow($result); |
||
76 | |||
77 | // Get the form data |
||
78 | // kazuo sudow --> EUC-JP (1.04) Sanitizer & mb_convert_encoding |
||
79 | $userid = $myts->stripSlashesGPC($_POST['realname']); |
||
80 | // Check if mbstring is supported --Yoshi |
||
81 | if (XOOPS_USE_MULTIBYTES && function_exists('mb_convert_encoding') && $xoopsConfig['language'] === 'japanese') { |
||
82 | $userid = mb_convert_encoding($userid, 'EUC-JP', 'auto'); |
||
83 | } |
||
84 | |||
85 | // Get Score --> % |
||
86 | // kazuo sudow --> EUC-JP (1.04) Sanitizer |
||
87 | $score = $myts->stripSlashesGPC($_POST['Score']); |
||
88 | |||
89 | // kazuo sudow --> EUC-JP (1.04) Sanitizer |
||
90 | $start_time = $myts->stripSlashesGPC($_POST['Start_Time']); |
||
91 | $start_time = date('Y/m/d H:i:s', strtotime($start_time)); |
||
92 | |||
93 | // kazuo sudow --> EUC-JP (1.04) Sanitizer |
||
94 | $end_time = $myts->stripSlashesGPC($_POST['End_Time']); |
||
95 | $end_time = date('Y/m/d H:i:s', strtotime($end_time)); |
||
96 | |||
97 | $timestamp = date('Y/m/d H:i:s'); |
||
98 | $comment = ''; |
||
99 | |||
100 | // Write in the db |
||
101 | if ($xoopsUser) { |
||
102 | include __DIR__ . '/module_prefix.php'; |
||
103 | $query = 'INSERT INTO ' . $xoopsDB->prefix($module_prefix . '_results') . " (quiz_id, uid, score, start_time, end_time, timestamp, host, ip, comment) VALUES ('"; |
||
104 | $query .= $quiz_id . "','"; |
||
105 | $query .= $uid . "','"; |
||
106 | $query .= $score . "','"; |
||
107 | $query .= $start_time . "','"; |
||
108 | $query .= $end_time . "','"; |
||
109 | $query .= $timestamp . "','"; |
||
110 | $query .= gethostbyaddr($_SERVER['REMOTE_ADDR']) . "','"; |
||
111 | $query .= $_SERVER['REMOTE_ADDR'] . "','"; |
||
112 | $query .= $comment . "')"; |
||
113 | $result = $xoopsDB->query($query); |
||
114 | // Count up the counter for the completion |
||
115 | $quiz_id = (int)$quiz_id; |
||
116 | include __DIR__ . '/module_prefix.php'; |
||
117 | $xoopsDB->query('UPDATE ' . $xoopsDB->prefix($module_prefix . '_quiz') . " SET counter=counter+1 WHERE artid=$quiz_id"); |
||
118 | } |
||
119 | |||
120 | // E-MAIL SEND |
||
121 | // send mail only if user or teacher email option is checked |
||
122 | if ($xoopsModuleConfig['mail_teacher'] || $xoopsModuleConfig['mail_user']) { |
||
123 | //generate message |
||
124 | // kazuo sudow 1.04 (add ID) |
||
125 | // original |
||
126 | // $subject = "XoopsHP Feedback: $uname, $quiz_title"; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
127 | // $subject = mb_encode_mimeheader(mb_convert_kana($subject,"KV"),"ISO-2022-JP","B"); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
69% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
128 | $subject = htmlspecialchars($xoopsConfig['sitename']) . ' ' . $xoopsModule->getVar('name') . ':' . $quiz_title . ' ' . $uname; |
||
129 | if (!empty($username)) { |
||
130 | $subject .= '(' . $username . ')'; |
||
131 | } |
||
132 | if (!empty($userid)) { |
||
133 | $subject .= ' (ID:' . $userid . ')'; |
||
134 | } |
||
135 | |||
136 | // message |
||
137 | $msg = _XD_FB_ID . "\t$userid\n"; |
||
138 | $msg .= _XD_FB_USERNAME . "\t$uname"; |
||
139 | if (!empty($username)) { |
||
140 | $msg .= '(' . $username . ")\n"; |
||
141 | } else { |
||
142 | $msg .= "\n"; |
||
143 | } |
||
144 | // ks $msg .= _XD_FB_UNAME . "\t$uname\n"; |
||
145 | // ks $msg .= _MD_SECNAMEC . "\t$secname\n"; |
||
146 | $msg .= _MD_LT_COURSE . "\t$secname\n"; |
||
147 | $msg .= _XD_FB_QTITLE . "\t$quiz_title\n"; |
||
148 | $msg .= _XD_FB_SCORE . "\t$score\n"; |
||
149 | $msg .= _XD_FB_START . "\t$start_time\n"; |
||
150 | $msg .= _XD_FB_END . "\t$end_time\n"; |
||
151 | $msg .= _XD_FB_TIMESTAMP . "\t$timestamp\n"; |
||
152 | // $msg .= _XD_FB_CMT . "\t$comment"; |
||
153 | $msg = multibyte($msg); // clean up for multybyte lang esp JP |
||
154 | |||
155 | $xoopsMailer =& getMailer(); |
||
156 | $xoopsMailer->useMail(); |
||
157 | $xoopsMailer->setFromEmail($myts->oopsStripSlashesGPC($xoopsConfig['adminmail'])); |
||
158 | $xoopsMailer->setFromName($myts->oopsStripSlashesGPC($xoopsConfig['sitename'])); |
||
159 | $xoopsMailer->setSubject($myts->oopsStripSlashesGPC($subject)); |
||
160 | $xoopsMailer->setBody($myts->oopsStripSlashesGPC($msg)); |
||
161 | |||
162 | if ($xoopsModuleConfig['mail_teacher']) { |
||
163 | $xoopsMailer->setToEmails($teacher_email); |
||
164 | } |
||
165 | if ($xoopsModuleConfig['mail_user']) { |
||
166 | $xoopsMailer->setToEmails($user_email); |
||
167 | } |
||
168 | } |
||
169 | |||
170 | // WWW |
||
171 | if (!$xoopsUser) { |
||
172 | $msg = '<H3>' . _XD_FB_GUEST . "</H3>\n"; |
||
173 | } elseif ($xoopsMailer->send() != false) { |
||
174 | $msg = '<H3>' . _XD_FB_OK . "</H3>\n"; |
||
175 | } else { |
||
176 | $msg = '<H3>' . _XD_FB_NG . "</H3>\n"; |
||
177 | } |
||
178 | |||
179 | // kazuo sudow 1.04 |
||
180 | // TD CLASS=EVEN |
||
181 | // ks $msg .= "<TABLE BORDER=1>\n"; |
||
182 | $msg .= "<TABLE cellspacing='0' cellpadding='0' BORDER='1'>\n"; |
||
183 | $msg .= "<TR><TD class='even'>" . _XD_FB_ID . "</TD><TD class='even'>$userid</TD></TR>\n"; |
||
184 | |||
185 | if ($xoopsUser) { |
||
186 | $msg .= "<TR><TD class='even'>" . _XD_FB_USERNAME . "</TD><TD class='even'>$uname"; |
||
187 | if (!empty($username)) { |
||
188 | $msg .= '(' . $username . ")</TD></TR>\n"; |
||
189 | } else { |
||
190 | $msg .= "</TD></TR>\n"; |
||
191 | } |
||
192 | } else { |
||
193 | $msg .= "<TR><TD class='even'>" . _XD_FB_USERNAME . "</TD><TD class='even'>" . _MD_LT_GUEST . "</TD></TR>\n"; |
||
194 | } |
||
195 | |||
196 | // ks $msg .= "<TR><TD class='even'>" . _XD_FB_UNAME . "</TD><TD class='even'>$uname</TD></TR>\n"; |
||
197 | // ks $msg .= "<TR><TD class='even'>" . _MD_SECNAMEC . "</TD><TD class='even'>$secname</TD></TR>\n"; |
||
198 | $msg .= "<TR><TD class='even'>" . _MD_LT_COURSE . "</TD><TD class='even'>$secname</TD></TR>\n"; |
||
199 | $msg .= "<TR><TD class='even'>" . _XD_FB_QTITLE . "</TD><TD class='even'>$quiz_title</TD></TR>\n"; |
||
200 | $msg .= "<TR><TD class='even'>" . _XD_FB_SCORE . "</TD><TD class='even'>$score</TD></TR>\n"; |
||
201 | $msg .= "<TR><TD class='even'>" . _XD_FB_START . "</TD><TD class='even'>$start_time</TD></TR>\n"; |
||
202 | $msg .= "<TR><TD class='even'>" . _XD_FB_END . "</TD><TD class='even'>$end_time</TD></TR>\n"; |
||
203 | $msg .= "<TR><TD class='even'>" . _XD_FB_TIMESTAMP . "</TD><TD class='even'>$timestamp</TD></TR>\n"; |
||
204 | // $msg .= "<TR><TD class='even'>" . _XD_FB_CMT . "</TD><TD class='even'>$comment</TD></TR>\n"; |
||
205 | $msg .= "</TABLE>\n"; |
||
206 | $msg .= "<br>\n"; |
||
207 | $msg .= "<center>\n"; |
||
208 | $msg .= "<INPUT type='button' name='close' value='" . _XD_FB_CLSBTN . "' onClick='window.opener.close();window.close()'>\n"; |
||
209 | $msg .= "</center>\n"; |
||
210 | |||
211 | // TEST-TEST-TEST-TEST |
||
212 | // test $msg .= $quiz_id; // -> get cookie xoopsHP_file_id |
||
213 | // test $msg .= $referer; // -> check browser has referer |
||
214 | |||
215 | // WWW-PAGE written |
||
216 | my_wrapper($msg); |
||
217 | exit(); |
||
218 | |||
219 | /** |
||
220 | * @param $s |
||
221 | * @return mixed|string |
||
222 | */ |
||
223 | function multibyte($s) |
||
224 | { |
||
225 | // kazuo sudow global app |
||
226 | global $xoopsConfig; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
227 | |||
228 | if (XOOPS_USE_MULTIBYTES && function_exists('mb_convert_encoding') && $xoopsConfig['language'] == 'japanese') { |
||
229 | if (get_magic_quotes_gpc()) { |
||
230 | // kazuo sudow - encode auto & EUC-JP |
||
231 | // return mb_convert_encoding(stripslashes($s), _CHARSET, "EUC-JP,UTF-8,Shift_JIS,JIS"); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
232 | return mb_convert_encoding(stripslashes($s), 'EUC-JP', 'auto'); |
||
233 | } else { |
||
234 | // kazuo sudow - encode auto |
||
235 | // return mb_convert_encoding($s, _CHARSET, "EUC-JP,UTF-8,Shift_JIS,JIS"); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
236 | return mb_convert_encoding($s, 'EUC-JP', 'auto'); |
||
237 | } |
||
238 | } else { |
||
239 | if (get_magic_quotes_gpc()) { |
||
240 | return stripslashes($s); |
||
241 | } else { |
||
242 | return $s; |
||
243 | } |
||
244 | } |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * @param $msg |
||
249 | */ |
||
250 | function my_wrapper($msg) |
||
251 | { |
||
252 | global $xoopsConfig, $xoopsTheme, $xoopsConfigMetaFooter; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
253 | |||
254 | $myts = MyTextSanitizer::getInstance(); |
||
0 ignored issues
–
show
$myts is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
255 | if ($xoopsConfig['gzip_compression'] == 1) { |
||
256 | ob_start('ob_gzhandler'); |
||
257 | } else { |
||
258 | ob_start(); |
||
259 | } |
||
260 | if (!headers_sent()) { |
||
261 | header('Content-Type:text/html; charset=' . _CHARSET); |
||
262 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
||
263 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
||
264 | header('Cache-Control: no-store, no-cache, max-age=1, s-maxage=1, must-revalidate, post-check=0, pre-check=0'); |
||
265 | header('Pragma: no-cache'); |
||
266 | } |
||
267 | |||
268 | echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"; |
||
269 | |||
270 | echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . _LANGCODE . '" lang="' . _LANGCODE . '"> |
||
271 | <head> |
||
272 | <meta http-equiv="content-type" content="text/html; charset=' . _CHARSET . '" /> |
||
273 | <meta http-equiv="content-language" content="' . _LANGCODE . '" /> |
||
274 | <meta name="robots" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_robots']) . '" /> |
||
275 | <meta name="keywords" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_keywords']) . '" /> |
||
276 | <meta name="description" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_desc']) . '" /> |
||
277 | <meta name="rating" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_rating']) . '" /> |
||
278 | <meta name="author" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_author']) . '" /> |
||
279 | <meta name="copyright" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_copyright']) . '" /> |
||
280 | <meta name="generator" content="XOOPS" /> |
||
281 | <title>' . _MD_LT_RESULTS . '</title>'; |
||
282 | $themecss = getcss($xoopsConfig['theme_set']); |
||
283 | echo '<link rel="stylesheet" type="text/css" media="all" href="' . XOOPS_URL . '/xoops.css" />'; |
||
284 | if ($themecss) { |
||
285 | echo '<link rel="stylesheet" type="text/css" media="all" href="' . $themecss . '" />'; |
||
286 | //echo '<style type="text/css" media="all"><!-- @import url('.$themecss.'); --></style>'; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
63% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
287 | } |
||
288 | echo '</head><body>'; |
||
289 | echo '<br>'; // kazuo sudow <BR> code app |
||
290 | echo $msg; |
||
291 | echo '</body></html>'; |
||
292 | } |
||
293 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.