forked from OS4ED/openSIS-Classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ajax.php
305 lines (263 loc) · 14.9 KB
/
Ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<?php
#**************************************************************************
# openSIS is a free student information system for public and non-public
# schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
# openSIS is web-based, open source, and comes packed with features that
# include student demographic info, scheduling, grade book, attendance,
# report cards, eligibility, transcripts, parent portal,
# student portal and more.
#
# Visit the openSIS web site at http://www.opensis.com to learn more.
# If you have question regarding this system or the license, please send
# an email to info@os4ed.com.
#
# This program is released under the terms of the GNU General Public License as
# published by the Free Software Foundation, version 2 of the License.
# See license.txt.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
include("functions/ParamLibFnc.php");
echo '<script type="text/javascript" src="assets/js/pages/components_popups.js"></script>';
echo '<script type="text/javascript" src="assets/js/pages/picker_date.js"></script>';
echo '<script type="text/javascript" src="assets/js/pages/form_checkboxes_radios.js"></script>';
echo '<script type="text/javascript" src="assets/js/plugins/forms/inputs/jquery.creditCardValidator.js"></script>';
echo '<script>';
echo '$(document).ready(function() {
// Animate loader off screen
$("#loading-image").hide();
if($(".clockpicker").length>0){
$(".clockpicker").clockpicker({
twelvehour: true,
donetext: \'Done\'
}).find("input").change(function () {
//alert(this.value);
});
}
if($(".switch-fake-title").length > 0){
$(".switch-fake-title").each(function(){
var check = $(this).closest("label").children("input[type=checkbox]");
if(check.is(":checked")){
$(this).text("Yes");
}else{
$(this).text("No");
}
});
}
/*if(hasScrollBar(".table-responsive", "horizontal")){
$(".table-responsive").mousewheel(function (e, delta) {
this.scrollLeft -= (delta * 40);
e.preventDefault();
});
}*/
$(".switch-fake-title").closest("label").children("input[type=checkbox]").change(function(){
if($(this).is(":checked")){
$(this).closest("label").children(".switch-fake-title").text("Yes");
}else{
$(this).closest("label").children(".switch-fake-title").text("No");
}
});
$("body").removeClass("sidebar-mobile-main");
// Scroll page to top after ajax call
//$("html, body").animate({ scrollTop: 0 }, "200");
$(\'body\').on(\'click\', \'div.sidebar-overlay\', function () {
$(\'body\').toggleClass(\'sidebar-mobile-main\');
});
$(\'body\').removeClass(\'sidebar-mobile-main\');
// Initializing Tooltips & Popovers after ajax call
$(\'[data-toggle="tooltip"], [data-popup="tooltip"]\').tooltip();
$(\'[data-popup="popover"]\').popover();
});';
echo '</script>';
$url = validateQueryString(curPageURL());
if ($url === FALSE) {
header('Location: index.php');
}
error_reporting(E_ERROR);
$isajax = "ajax";
$start_time = time();
include 'Warehouse.php';
array_rwalk($_REQUEST, 'strip_tags');
$title_set = '';
if (UserStudentID() && User('PROFILE') != 'parent' && User('PROFILE') != 'student' && substr(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 0, 5) != 'Atten' && substr(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 0, 5) != 'users' && clean_param($_REQUEST['modname'], PARAM_NOTAGS) != 'students/AddUsers.php' && $_REQUEST['modname']!= 'tools/Backup.php' && (substr(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 0, 10) != 'attendance' || clean_param($_REQUEST['modname'], PARAM_NOTAGS) == 'attendance/StudentSummary.php' || clean_param($_REQUEST['modname'], PARAM_NOTAGS) == 'attendance/DailySummary.php' || clean_param($_REQUEST['modname'], PARAM_NOTAGS) == 'attendance/AddAbsences.php')) {
$RET = DBGet(DBQuery("SELECT FIRST_NAME,LAST_NAME,MIDDLE_NAME,NAME_SUFFIX FROM students WHERE STUDENT_ID='" . UserStudentID() . "'"));
$count_student_RET = DBGet(DBQuery("SELECT COUNT(*) AS NUM FROM students"));
if ($count_student_RET[1]['NUM'] > 1) {
$title_set = 'y';
DrawHeaderHome('<div class="panel"><div class="panel-heading"><h6 class="panel-title">Selected Student : ' . $RET[1]['FIRST_NAME'] . ' ' . ($RET[1]['MIDDLE_NAME'] ? $RET[1]['MIDDLE_NAME'] . ' ' : '') . $RET[1]['LAST_NAME'] . ' ' . $RET[1]['NAME_SUFFIX'] . '</h6> <div class="heading-elements clearfix"><span class="heading-text"><A HREF=Modules.php?modname=' . clean_param($_REQUEST['modname'], PARAM_NOTAGS) . '&search_modfunc=list&next_modname=Students/Student.php&ajax=true&bottom_back=true&return_session=true target=body><i class="icon-square-left"></i> Back to Student List</A></span><div class="btn-group heading-btn"><A HREF=SideForStudent.php?student_id=new&modcat=' . clean_param($_REQUEST['modcat'], PARAM_NOTAGS) . '&modname=' . $_REQUEST['modname'] . ' class="btn btn-danger btn-xs">Deselect</A></div></div></div></div>');
} else if ($count_student_RET[1]['NUM'] == 1) {
$title_set = 'y';
DrawHeaderHome('<div class="panel"><div class="panel-heading"><h6 class="panel-title">Selected Student : ' . $RET[1]['FIRST_NAME'] . ' ' . ($RET[1]['MIDDLE_NAME'] ? $RET[1]['MIDDLE_NAME'] . ' ' : '') . $RET[1]['LAST_NAME'] . ' ' . $RET[1]['NAME_SUFFIX'] . '</h6> <div class="heading-elements clearfix"><A HREF=SideForStudent.php?student_id=new&modcat=' . clean_param($_REQUEST['modcat'], PARAM_NOTAGS) . '&modname=' . $_REQUEST['modname'] . ' class="btn btn-danger btn-xs">Deselect</A></div></div></div>');
}
}
$title_set_staff = '';
if (UserStaffID() && User('PROFILE') == 'admin' && substr(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 0, 6) != 'grades' && substr(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 0, 8) != 'students' && substr(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 0, 10) != 'attendance') {
$Modname_Attn = 'users/TeacherPrograms.php';
$Modname_Pro = 'users/TeacherPrograms.php?include=grades/ProgressReports.php';
if ((!UserStudentID() || substr(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 0, 5) == 'users') && substr(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 0, 25) != $Modname_Attn && clean_param($_REQUEST['modname'], PARAM_NOTAGS) != 'users/AddStudents.php' && !clean_param($_REQUEST['miss_attn'], PARAM_NOTAGS)) {
$title_set_staff = 'y';
if ($_REQUEST['modname'] != 'users/User.php') {
$RET = DBGet(DBQuery("SELECT FIRST_NAME,LAST_NAME FROM staff WHERE STAFF_ID='" . UserStaffID() . "'"));
echo '<div class="panel panel-default">';
DrawHeader('Selected Staff : ' . $RET[1]['FIRST_NAME'] . ' ' . $RET[1]['LAST_NAME'], '<span class="heading-text"><A HREF=Modules.php?modname=' . clean_param($_REQUEST['modname'], PARAM_NOTAGS) . '&search_modfunc=list&next_modname=users/User.php&ajax=true&bottom_back=true&return_session=true target=body><i class="icon-square-left"></i> Back to User List</A></span><div class="btn-group heading-btn"><A HREF=Side.php?staff_id=new&modcat=' . clean_param($_REQUEST['modcat'], PARAM_NOTAGS) . ' class="btn btn-danger btn-xs">Deselect</A></div>');
echo '</div>';
}
}
}
echo "<div id=\"divErr\"></div>";
if (!isset($_REQUEST['_openSIS_PDF'])) {
Warehouse('header');
// if (strpos(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 'miscellaneous/') === false)
// echo '<script language="JavaScript">if(window == top && (!window.opener || window.opener.location.href.substring(0,(window.opener.location.href.indexOf("&")!=-1?window.opener.location.href.indexOf("&"):window.opener.location.href.replace("#","").length))!=window.location.href.substring(0,(window.location.href.indexOf("&")!=-1?window.location.href.indexOf("&"):window.location.href.replace("#","").length)))) window.location.href = "index.php";</script>';
echo "<BODY marginwidth=0 leftmargin=0 border=0 onload='doOnload();' background=assets/bg.gif>";
echo '<DIV id="Migoicons" style="visibility:hidden;position:absolute;z-index:1000;top:-100"></DIV>';
}
if (clean_param($_REQUEST['modname'], PARAM_NOTAGS)) {
if ($_REQUEST['_openSIS_PDF'] == 'true')
ob_start();
if (strpos($_REQUEST['modname'], '?') !== false) {
$vars = substr($_REQUEST['modname'], (strpos($_REQUEST['modname'], '?') + 1));
$modname = substr($_REQUEST['modname'], 0, strpos($_REQUEST['modname'], '?'));
$vars = explode('?', $vars);
foreach ($vars as $code) {
$arr_ind = substr($code, 0, strpos($code, '='));
$arr_val = substr($code, (strpos($code, '=') + 1));
$_REQUEST[$arr_ind] = $arr_val;
}
} else
$modname = $_REQUEST['modname'];
if ($_REQUEST['LO_save'] != '1' && !isset($_REQUEST['_openSIS_PDF']) && (strpos($modname, 'miscellaneous/') === false || $modname == 'misc/Registration.php' || $modname == 'miscellaneous/Export.php' || $modname == 'miscellaneous/Portal.php'))
$_SESSION['_REQUEST_vars'] = $_REQUEST;
$allowed = false;
include 'Menu.php';
foreach ($_openSIS['Menu'] as $modcat => $programs) {
if (clean_param($_REQUEST['modname'], PARAM_NOTAGS) == $modcat . '/Search.php') {
$allowed = true;
break;
}
foreach ($programs as $program => $title) {
if (clean_param($_REQUEST['modname'], PARAM_NOTAGS) == $program) {
$allowed = true;
break;
}
}
}
if (substr(clean_param($_REQUEST['modname'], PARAM_NOTAGS), 0, 14) == 'miscellaneous/')
$allowed = true;
if ($allowed || $_SESSION['take_mssn_attn']) {
if (Preferences('SEARCH') != 'Y' && substr(clean_param($modname, PARAM_NOTAGS), 0, 6) != 'users/')
$_REQUEST['search_modfunc'] = 'list';
include('modules/' . $modname);
}
else {
if (User('USERNAME')) {
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
echo "You're not allowed to use this program! This attempted violation has been logged and your IP address was captured.";
DBQuery("INSERT INTO hacking_log (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$ip','" . date('Y-m-d') . "','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','" . User('USERNAME') . "')");
Warehouse('footer');
if ($openSISNotifyAddress)
mail($openSISNotifyAddress, 'HACKING ATTEMPT', "INSERT INTO hacking_log (HOST_NAME,IP_ADDRESS,LOGIN_DATE,VERSION,PHP_SELF,DOCUMENT_ROOT,SCRIPT_NAME,MODNAME,USERNAME) values('$_SERVER[SERVER_NAME]','$ip','" . date('Y-m-d') . "','$openSISVersion','$_SERVER[PHP_SELF]','$_SERVER[DOCUMENT_ROOT]','$_SERVER[SCRIPT_NAME]','$_REQUEST[modname]','" . User('USERNAME') . "')");
}
exit;
}
if ($_SESSION['unset_student']) {
unset($_SESSION['unset_student']);
unset($_SESSION['staff_id']);
}
}
echo "<div id='cal' class='divcal'> </div>";
if (!isset($_REQUEST['_openSIS_PDF'])) {
for ($i = 1; $i <= $_openSIS['PrepareDate']; $i++) {
echo '<script type="text/javascript">
</script>';
}
echo '</BODY>';
echo '</HTML>';
}
function decode_unicode_url($str) {
$res = '';
$i = 0;
$max = strlen($str) - 6;
while ($i <= $max) {
$character = $str[$i];
if ($character == '%' && $str[$i + 1] == 'u') {
$value = hexdec(substr($str, $i + 2, 4));
$i += 6;
if ($value < 0x0080) // 1 byte: 0xxxxxxx
$character = chr($value);
else if ($value < 0x0800) // 2 bytes: 110xxxxx 10xxxxxx
$character = chr((($value & 0x07c0) >> 6) | 0xc0)
. chr(($value & 0x3f) | 0x80);
else // 3 bytes: 1110xxxx 10xxxxxx 10xxxxxx
$character = chr((($value & 0xf000) >> 12) | 0xe0)
. chr((($value & 0x0fc0) >> 6) | 0x80)
. chr(($value & 0x3f) | 0x80);
} else
$i++;
$res .= $character;
}
return $res . substr($str, $i);
}
function code2utf($num) {
if ($num < 128)
return chr($num);
if ($num < 1024)
return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
if ($num < 32768)
return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128)
. chr(($num & 63) + 128);
if ($num < 2097152)
return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128)
. chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
return '';
}
function unescape($strIn, $iconv_to = 'UTF-8') {
$strOut = '';
$iPos = 0;
$len = strlen($strIn);
while ($iPos < $len) {
$charAt = substr($strIn, $iPos, 1);
if ($charAt == '%') {
$iPos++;
$charAt = substr($strIn, $iPos, 1);
if ($charAt == 'u') {
// Unicode character
$iPos++;
$unicodeHexVal = substr($strIn, $iPos, 4);
$unicode = hexdec($unicodeHexVal);
$strOut .= code2utf($unicode);
$iPos += 4;
} else {
// Escaped ascii character
$hexVal = substr($strIn, $iPos, 2);
if (hexdec($hexVal) > 127) {
// Convert to Unicode
$strOut .= code2utf(hexdec($hexVal));
} else {
$strOut .= chr(hexdec($hexVal));
}
$iPos += 2;
}
} else {
$strOut .= $charAt;
$iPos++;
}
}
if ($iconv_to != "UTF-8") {
$strOut = iconv("UTF-8", $iconv_to, $strOut);
}
return $strOut;
}
?>