1
1
<?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
-
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
- \*=================================================================================*/
22
2
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
+
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
+ \*================================================================================= */
23
23
24
24
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 ;
31
31
}
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"> ' ;
46
- echo '<b> ' . $ title . '</b><br /> ' ;
47
- echo ' ' . $ 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> ' ;
56
32
}
57
33
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 ) {
61
38
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 ;
67
42
}
68
43
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"> ' ;
46
+ echo '<b> ' . $ title . '</b><br /> ' ;
47
+ echo ' ' . $ 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
+ }
70
53
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
+ }
78
57
79
- for ($ i =0 ; $ i <=$ strLen ; $ i ++) {
58
+ public function generatePW ($ username , $ password ) {
59
+ return sha1 (config ("salt " ) . md5 ($ password . config ("salt " ) . $ username ));
60
+ }
80
61
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 );
83
65
84
- // Are we inside a quoted string?
85
- if ($ char == '" ' && $ prevChar != '\\' ) {
86
- $ outOfQuotes = !$ outOfQuotes ;
66
+ return getVar ("sql " )->real_escape_string ($ input );
67
+ }
87
68
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 );
95
80
}
96
81
}
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 ;
97
96
98
- // Add the character to the result string.
99
- $ result .= $ char ;
97
+ for ($ i = 0 ; $ i <= $ strLen ; $ i ++) {
100
98
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,
102
107
// 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
+ }
108
115
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 ++;
112
125
}
113
126
114
- $ prevChar = $ char ;
127
+ for ($ j = 0 ; $ j < $ pos ; $ j ++) {
128
+ $ result .= $ indentStr ;
129
+ }
115
130
}
116
131
117
- return $ result ;
132
+ $ prevChar = $ char ;
118
133
}
134
+
135
+ return $ result ;
136
+ }
137
+
119
138
}
139
+
120
140
?>
0 commit comments