Skip to content

Commit b4e2e87

Browse files
author
flx5
committed
- Added Magic Quotes Compability
1 parent ff67163 commit b4e2e87

File tree

3 files changed

+115
-93
lines changed

3 files changed

+115
-93
lines changed

global.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
require_once("inc/plugin.php");
6060
require_once("inc/parse.php");
6161

62+
core::MagicQuotesCompability();
63+
6264
$config = new config();
6365
$vars = new variables(new core(), null, null, new tpl(), new Update(), new pluginManager(), false);
6466
$vars->set("sql", SQL::GenerateInstance($config->Get("dbtype"), $config->Get("dbhost"), $config->Get("dbusr"), $config->Get("dbpass"), $config->Get("dbname")));

inc/core.php

Lines changed: 112 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,140 @@
11
<?php
2-
/*=================================================================================*\
3-
|* This file is part of InMaFSS *|
4-
|* InMaFSS - INformation MAnagement for School Systems - Keep yourself up to date! *|
5-
|* ############################################################################### *|
6-
|* Copyright (C) flx5 *|
7-
|* E-Mail: [email protected] *|
8-
|* ############################################################################### *|
9-
|* InMaFSS is free software; you can redistribute it and/or modify *|
10-
|* it under the terms of the GNU Affero General Public License as published by *|
11-
|* the Free Software Foundation; either version 3 of the License, *|
12-
|* or (at your option) any later version. *|
13-
|* ############################################################################### *|
14-
|* InMaFSS is distributed in the hope that it will be useful, *|
15-
|* but WITHOUT ANY WARRANTY; without even the implied warranty of *|
16-
|* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *|
17-
|* See the GNU Affero General Public License for more details. *|
18-
|* ############################################################################### *|
19-
|* You should have received a copy of the GNU Affero General Public License *|
20-
|* along with InMaFSS; if not, see http://www.gnu.org/licenses/. *|
21-
\*=================================================================================*/
222

3+
/* =================================================================================*\
4+
|* This file is part of InMaFSS *|
5+
|* InMaFSS - INformation MAnagement for School Systems - Keep yourself up to date! *|
6+
|* ############################################################################### *|
7+
|* Copyright (C) flx5 *|
8+
|* E-Mail: [email protected] *|
9+
|* ############################################################################### *|
10+
|* InMaFSS is free software; you can redistribute it and/or modify *|
11+
|* it under the terms of the GNU Affero General Public License as published by *|
12+
|* the Free Software Foundation; either version 3 of the License, *|
13+
|* or (at your option) any later version. *|
14+
|* ############################################################################### *|
15+
|* InMaFSS is distributed in the hope that it will be useful, *|
16+
|* but WITHOUT ANY WARRANTY; without even the implied warranty of *|
17+
|* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *|
18+
|* See the GNU Affero General Public License for more details. *|
19+
|* ############################################################################### *|
20+
|* You should have received a copy of the GNU Affero General Public License *|
21+
|* along with InMaFSS; if not, see http://www.gnu.org/licenses/. *|
22+
\*================================================================================= */
2323

2424
class core {
25-
public static function GetVersion() {
26-
if(file_exists(CWD."version.php")) {
27-
include(CWD."version.php");
28-
if(isset($version)) {
29-
return $version;
30-
}
25+
26+
public static function GetVersion() {
27+
if (file_exists(CWD . "version.php")) {
28+
include(CWD . "version.php");
29+
if (isset($version)) {
30+
return $version;
3131
}
32-
33-
return null;
34-
}
35-
36-
public static function SystemError($title, $text)
37-
{
38-
39-
if(!in_array("Content-Type: text/html", headers_list())) {
40-
echo $title." ".$text;
41-
return;
42-
}
43-
44-
echo '<div style="width: 80%; padding: 15px 15px 15px 15px; margin: 50px auto; background-color: #F6CECE; font-family: arial; font-size: 12px; color: #000000; border: 1px solid #FF0000;">';
45-
echo '<img src="' . WWW . '/images/exclamation.png" style="float: left;" title="Error">&nbsp;';
46-
echo '<b>' . $title. '</b><br />';
47-
echo '&nbsp;' . $text;
48-
echo '<hr size="1" style="width: 100%; margin: 15px 0px 15px 0px;" />';
49-
echo 'Script execution was aborted. We apoligize for the possible inconvenience. If this problem is persistant, please contact an Administrator.';
50-
echo '</div>';
51-
exit;
52-
}
53-
54-
public static function SuccessMessage($text) {
55-
echo '<div class="status_ok">'.$text.'</div>';
5632
}
5733

58-
public function generatePW($username, $password) {
59-
return sha1(config("salt").md5($password.config("salt").$username));
60-
}
34+
return null;
35+
}
36+
37+
public static function SystemError($title, $text) {
6138

62-
public function filter($input) {
63-
if(ini_get("magic_quotes_gpc"))
64-
$input = stripslashes($input);
65-
66-
return getVar("sql")->real_escape_string($input);
39+
if (!in_array("Content-Type: text/html", headers_list())) {
40+
echo $title . " " . $text;
41+
return;
6742
}
6843

69-
function FormatJson($json) {
44+
echo '<div style="width: 80%; padding: 15px 15px 15px 15px; margin: 50px auto; background-color: #F6CECE; font-family: arial; font-size: 12px; color: #000000; border: 1px solid #FF0000;">';
45+
echo '<img src="' . WWW . '/images/exclamation.png" style="float: left;" title="Error">&nbsp;';
46+
echo '<b>' . $title . '</b><br />';
47+
echo '&nbsp;' . $text;
48+
echo '<hr size="1" style="width: 100%; margin: 15px 0px 15px 0px;" />';
49+
echo 'Script execution was aborted. We apoligize for the possible inconvenience. If this problem is persistant, please contact an Administrator.';
50+
echo '</div>';
51+
exit;
52+
}
7053

71-
$result = '';
72-
$pos = 0;
73-
$strLen = strlen($json);
74-
$indentStr = ' ';
75-
$newLine = "\n";
76-
$prevChar = '';
77-
$outOfQuotes = true;
54+
public static function SuccessMessage($text) {
55+
echo '<div class="status_ok">' . $text . '</div>';
56+
}
7857

79-
for ($i=0; $i<=$strLen; $i++) {
58+
public function generatePW($username, $password) {
59+
return sha1(config("salt") . md5($password . config("salt") . $username));
60+
}
8061

81-
// Grab the next character in the string.
82-
$char = substr($json, $i, 1);
62+
public function filter($input) {
63+
if (ini_get("magic_quotes_gpc"))
64+
$input = stripslashes($input);
8365

84-
// Are we inside a quoted string?
85-
if ($char == '"' && $prevChar != '\\') {
86-
$outOfQuotes = !$outOfQuotes;
66+
return getVar("sql")->real_escape_string($input);
67+
}
8768

88-
// If this character is the end of an element,
89-
// output a new line and indent the next line.
90-
} else if(($char == '}' || $char == ']') && $outOfQuotes) {
91-
$result .= $newLine;
92-
$pos --;
93-
for ($j=0; $j<$pos; $j++) {
94-
$result .= $indentStr;
69+
public function MagicQuotesCompability() {
70+
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) {
71+
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
72+
while (list($key, $val) = each($process)) {
73+
foreach ($val as $k => $v) {
74+
unset($process[$key][$k]);
75+
if (is_array($v)) {
76+
$process[$key][stripslashes($k)] = $v;
77+
$process[] = &$process[$key][stripslashes($k)];
78+
} else {
79+
$process[$key][stripslashes($k)] = stripslashes($v);
9580
}
9681
}
82+
}
83+
unset($process);
84+
}
85+
}
86+
87+
function FormatJson($json) {
88+
89+
$result = '';
90+
$pos = 0;
91+
$strLen = strlen($json);
92+
$indentStr = ' ';
93+
$newLine = "\n";
94+
$prevChar = '';
95+
$outOfQuotes = true;
9796

98-
// Add the character to the result string.
99-
$result .= $char;
97+
for ($i = 0; $i <= $strLen; $i++) {
10098

101-
// If the last character was the beginning of an element,
99+
// Grab the next character in the string.
100+
$char = substr($json, $i, 1);
101+
102+
// Are we inside a quoted string?
103+
if ($char == '"' && $prevChar != '\\') {
104+
$outOfQuotes = !$outOfQuotes;
105+
106+
// If this character is the end of an element,
102107
// output a new line and indent the next line.
103-
if (($char == ',' || $char == '{' || $char == '[') && $outOfQuotes) {
104-
$result .= $newLine;
105-
if ($char == '{' || $char == '[') {
106-
$pos ++;
107-
}
108+
} else if (($char == '}' || $char == ']') && $outOfQuotes) {
109+
$result .= $newLine;
110+
$pos--;
111+
for ($j = 0; $j < $pos; $j++) {
112+
$result .= $indentStr;
113+
}
114+
}
108115

109-
for ($j = 0; $j < $pos; $j++) {
110-
$result .= $indentStr;
111-
}
116+
// Add the character to the result string.
117+
$result .= $char;
118+
119+
// If the last character was the beginning of an element,
120+
// output a new line and indent the next line.
121+
if (($char == ',' || $char == '{' || $char == '[') && $outOfQuotes) {
122+
$result .= $newLine;
123+
if ($char == '{' || $char == '[') {
124+
$pos++;
112125
}
113126

114-
$prevChar = $char;
127+
for ($j = 0; $j < $pos; $j++) {
128+
$result .= $indentStr;
129+
}
115130
}
116131

117-
return $result;
132+
$prevChar = $char;
118133
}
134+
135+
return $result;
136+
}
137+
119138
}
139+
120140
?>

inc/tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function Init($title) {
3131
$this->headers = Array(
3232
'<title>InMaFSS // '.$title.'</title>',
3333
'<link rel="stylesheet" type="text/css" href="'.WWW.'/main.css">',
34-
'<meta http-equiv="content-type" content="text/html; charset=UTF-8">'
34+
'<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">'
3535
);
3636

3737
$this->params = Array('username'=>USERNAME);

0 commit comments

Comments
 (0)