This repository has been archived by the owner on Feb 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·432 lines (407 loc) · 14.4 KB
/
index.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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
<?php
//--------------License----------------------//
//--GNU2--//
//bleh!
//error_reporting(E_ERROR);
//if($_COOKIE['a111%Y#$&%^'] == md5("apf9urf90u"))
//{
require_once("./ATC/config.php");
//$R= _GLEVEL('dread','a',md5(']%^&*()OLK!JH\'GTY&*(OPL<MD#'),false);
//echo GetUserLevel('dread',$R);
//echo GAdmin(md6(FERG.SHLOPPPPPPPING.SHIDDLEFIERRR.ERFDS,'md6-run'));
if(!ob_start("ob_gzhandler")) ob_start();
ob_implicit_flush(0);
function nl() {
echo "<br/> \n";
}
function RandID()
{
return md5(rand(9999,999999999999999999).rand(9999,999999999999999999).rand(9999,999999999999999999).rand(9999,999999999999999999));
}
function encrypt_url($string) {
$key = "123abc1"; //preset key to use on all encrypt and decrypts.
$result = '';
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return urlencode(base64_encode($result));
}
function decrypt_url($string) {
$key = "123abc1";
$result = '';
$string = base64_decode(urldecode($string));
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)-ord($keychar));
$result.=$char;
}
return $result;
}
function SmallSpacer(){return '<span style="font-size:5pt;color:transparent;">.</span>';}
function anti_injection($sql) {
$sql = htmlspecialchars($sql); # for < and >, &, single and double quote characters
$sql = str_replace("'", '& #039;', $sql); # for single quote characters (just in case)
$sql = str_replace('"', '"e;', $sql); # for dpuble quote characters (just in case)
$sql = str_replace('=', '', $sql); # removes = signs.
$sql = str_replace('INSERT', '', $sql); # removes INSERT
$sql = str_replace('SELECT', '', $sql); # removes SELECT
$sql = str_replace('DELETE', '', $sql); # removes DELETE
//$sql = str_replace(' ', '', $sql); # removes ' '
$sql = str_replace('+', '', $sql); # removes '+'
$sql = str_replace('-', '', $sql); # removes all - signs (all sql comments).
return $sql;
}
function Check_User($user,$pass)
{
//checks to make sure user is legit... If not, it will remove the user from the session.
}
function ILink($name)
{
return substr(md5(md5($_COOKIE['chat_9f40q3'].")T!Y%*UIO".$name)."FAEW$%U^IJSTHRAYQW%U^JRTSNDFBRWE%HRTJSNHEW%"),0,12); //Algorythm for saving the site.
}
function ImgILink($name) //makes it possible to ILink to an image with no problems shown.
{
return "./?img=".encrypt_url($name);
}
function ImgUnILink($name) //decodes the image
{
return decrypt_url($name);
}
function mkpageILink($page1,$name1)
{
echo '<a href="./?page='.ILink($page1).'">'.$name1.'</a>';
//echo ILink($page1);
}
function mksubpageILink($page1,$subpage1,$name1)
{
echo '<a href="./?page='.ILink($page1).'&subpage='.ILink($subpage1).'">'.$name1.'</a>';
}
function subpageILink($page1,$subpage1,$name1)
{
return '<a href="./?page='.ILink($page1).'&subpage='.ILink($subpage1).'">'.$name1.'</a>';
}
function mksubpageILink_($page1,$subpage1,$name1)
{
return '<a href="./?page='.ILink($page1).'&subpage='.ILink($subpage1).'">'.$name1.'</a>';
}
function endsWith( $str, $sub ) {
return ( substr( $str, strlen( $str ) - strlen( $sub ) ) == $sub );
}
function print_gzipped_page() {
global $HTTP_ACCEPT_ENCODING;
if( headers_sent() ){
$encoding = false;
}elseif( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ){
$encoding = 'x-gzip';
}elseif( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ){
$encoding = 'gzip';
}else{
$encoding = false;
}
if( $encoding ){
$contents = ob_get_contents();
ob_end_clean();
header('Content-Encoding: '.$encoding);
print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
$size = strlen($contents);
$contents = gzcompress($contents, 9);
$contents = substr($contents, 0, $size);
print($contents);
exit();
}else{
ob_end_flush();
exit();
}
}
function TinyMCE($elementid)
{
echo '<script type="text/javascript" src="./ATC/plugins/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
// O2k7 skin
tinyMCE.init({
// General options
mode : "exact",
elements : "'.$elementid.'",
theme : "advanced",
skin : "o2k7",
plugins : "pagebreak,style,layer,table,save,advhr,advimage,advILink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,ILink,unILink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
//content_css : "css/content.css",
// Drop lists for ILink/image/media/template dialogs
//template_external_list_url : "lists/template_list.js",
//external_ILink_list_url : "lists/ILink_list.js",
//external_image_list_url : "lists/image_list.js",
//media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>';
}
function EditArea($id)
{
echo '<script language="Javascript" type="text/javascript" src="ATC/plugins/editarea/edit_area/edit_area_full.js"></script>
<script language="Javascript" type="text/javascript">
editAreaLoader.init({
id: "'.$id.'" // id of the textarea to transform
,start_highlight: true // if start with highlight
,allow_resize: "both"
,allow_toggle: true
,word_wrap: false
,language: "en"
,syntax: "php"
});
/*editAreaLoader.init({
id: "'.$id.'" // id of the textarea to transform
,start_highlight: true
,allow_toggle: false
,language: "en"
,syntax: "php"
,toolbar: "search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help"
,syntax_selection_allow: "css,html,js,php,python,vb,xml,c,cpp,sql,basic,pas,brainfuck"
,is_multi_files: true
,EA_load_callback: "editAreaLoaded"
,show_line_colors: true
});*/
</script>';
}
if(isset($_REQUEST['img']))
{
//gets an image...
//decode image...
if($Use_Imgs)
{
$imgloc = ImgUnILink($_REQUEST['img']);
$fh = fopen($imgloc, 'r');
//echo $imgloc;
if(endsWith($imgloc,".png")){header("Content-Type: image/png"); echo fread($fh, filesize($imgloc));}
else if(endsWith($imgloc,".jpg")){header("Content-Type: image/jpg"); echo fread($fh, filesize($imgloc));}
else if(endsWith($imgloc,".jpeg")){header("Content-Type: image/jpeg"); echo fread($fh, filesize($imgloc));}
else if(endsWith($imgloc,".gif")){header("Content-Type: image/gif"); echo fread($fh, filesize($imgloc));}
else{echo "invalid Image!";}
}
}
else if(isset($_REQUEST['page']))
{
$page=$_REQUEST['page'];
if($_REQUEST['page'] == ILink("login"))
{
if(isset($_SESSION['username']))
{
header("Location: ./?page=".ILink("home"));
}
else
{
define("FI",md5("F@G!HWP*"));
$title.=" - Login";
require_once("./ATC/header.php");
require_once("./ATC/login.php");
require_once("./ATC/footer.php");
}
}
else if($_REQUEST['page'] == ILink("teacherfirst"))
{
define("FI",md5("F@G!HWP*"));
$title.=" - Teacher First-time login";
require_once("./ATC/header.php");
require_once("./ATC/FirstTeacherLogin.php");
require_once("./ATC/footer.php");
}
/*else if($_REQUEST['page'] == ILink("chat"))
{
doserver();
define("FI",md5("F@G!HWP*"));
$title.=" - Chat";
require_once("./ATC/header.php");
require_once("./ATC/cht.php");
require_once("./ATC/footer.php");
}*/
else if($_REQUEST['page'] == ILink("logout"))
{
unset($_SESSION['username']);
unset($_SESSION['pass']);
header("Location: ./");
}
else if($_REQUEST['page'] == ILink("preset"))
{
define("FI",md5("F@G!HWP*"));
require_once("./ATC/header.php");
require_once("./ATC/passreset.php");
require_once("./ATC/footer.php");
}
else if(isset($_SESSION['username']))
{
if($_REQUEST['page'] == ILink("home")) //make it impossible to regularly hot-ILink a page...
{
define("FI",md5("F@G!HWP*"));
$title.=" - Home";
require_once("./ATC/header.php");
require_once("./ATC/hme.php");
require_once("./ATC/footer.php");
}
else if($_REQUEST['page'] == ILink("reg"))
{
define("FI",md5("F@G!HWP*"));
$title.=" - Register";
require_once("./ATC/header.php");
require_once("./ATC/reg.php");
require_once("./ATC/footer.php");
}
else if($_REQUEST['page'] == ILink("management"))
{
define("FI",md5("F@G!HWP*"));
$title.=" - Management";
require_once("./ATC/header.php");
require_once("./ATC/management.php");
require_once("./ATC/footer.php");
}
else if($_REQUEST['page'] == ILink("profile_edit"))
{
define("FI",md5("F@G!HWP*"));
$title.=" - Edit your Profile";
require_once("./ATC/header.php");
require_once("./ATC/profile_edit.php");
require_once("./ATC/footer.php");
}
else if($_REQUEST['page'] == ILink("profile_view"))
{
define("FI",md5("F@G!HWP*"));
$title.=" - ".$AccName." - View Profile";
require_once("./ATC/header.php");
require_once("./ATC/profile_view.php");
require_once("./ATC/footer.php");
}
else if($_REQUEST['page'] == ILink("ATCDATA"))
{
define("FI",md5("F@G!HWP*"));
require_once("./ATC/header.php");
require_once("./ATC/atc.php");
require_once("./ATC/footer.php");
}
else if($_REQUEST['page'] == 'export')
{
define("FI",md5("F@G!HWP*"));
require_once("./ATC/dexport.php");
}
}
else if($_SESSION['level'] == md5($_SESSION['username']."F8FY1Y2AT5HAG2F"."admin"))
{
if ($_REQUEST['page'] == ILink("delfile"))
{
if($handle = opendir("."))
{
while(false !== ($file = readdir($handle)))
{
if(is_dir($file))
{
}
if(!is_dir($file))
if($_REQUEST['subpage']==ILink($file))
{
unset($file);
}
}
}
header("Location: ./?page=".ILink("management")."&subpage=".ILink("edit"));
}
else if ($_REQUEST['page'] == ILink("edit"))
{
if($handle = opendir("."))
{
while(false !== ($file = readdir($handle)))
{
if(!is_dir($file))
if($_REQUEST['subpage']==ILink($file))
{
define("FI",md5("F@G!HWP*"));
$title.=" - Editing file: ".$file;
require_once("./ATC/header.php");
OpenTable2(mksubpageILink_("management","edit","[Back]")." - Edit - ".$file,"97%");
$file1=fopen($file,"r");
$dat1="";
if(filesize($file) >= 1) $dat1 = fread($file1,filesize($file));
//TinyMCE("textdata"); //we cannot use it because it will not work...
EditArea("textdata");
?><script>alert("<?php echo str_replace("\n","",$dat1);?>");</script><?php
$dat1=str_replace("<","<",$dat1);
$dat1=str_replace(">",">",$dat1);
//
echo "<form method='post' action='?page=".ILink("edit2")."&subpage=".ILink($file)."'><textarea name='textdata' id='textdata' style='width:100%;height:500px;'>".$dat1."</textarea><input type=submit value='X-Mit' /> <button onclick='location.href=\"?/page=".ILink("delfile")."&subpage=".ILink($file)."\";' value='Delete File' /></form>";
//EditArea("textarea");
CloseTable();
require_once("./ATC/footer.php");
}
}
closedir($handle);
}
}
else if ($_REQUEST['page'] == ILink("edit2"))
{
if($handle = opendir("."))
{
while(false !== ($file = readdir($handle)))
{
if(is_dir($file))
{
}
if(!is_dir($file))
if($_REQUEST['subpage']==ILink($file))
{
define("FI",md5("F@G!HWP*"));
$title.=" - Editing file: ".$file;
require_once("./ATC/header.php");
OpenTable2(mksubpageILink_("management","edit","[Back]")." - Edit - ".$file,"97%");
$file2=fopen($file,"w+");
$string1 = str_replace('\\"','"',$_POST['textdata']);
$string1 = str_replace("\\'","'",$string1);
$string1 = str_replace("\\\\","\\",$string1);
//$string1=str_replace("<","<",$string1);
//$string1=str_replace(">",">",$string1);
fwrite($file2,$string1);
//echo $_POST['textdata'];
$dat1 = $string1;
$dat1=str_replace("<","<",$dat1);
$dat1=str_replace(">",">",$dat1);
//TinyMCE("textdata");
EditArea("textdata");
echo '<form method=post action="?page='.ILink("edit2")."&subpage=".ILink($file).'"><textarea name=textdata id=textdata style="width:100%;height:500px;">'.$dat1.'</textarea><input type=submit value="X-Mit" /> <button onclick="location.href=\'?/page='.ILink("delfile").'&subpage='.ILink($file).'";\'>Delete File</button></form>';
CloseTable();
require_once("./ATC/footer.php");
}
}
closedir($handle);
}
}
else
{
//?/><script>location.href="./?page=</?php echo ILink("home"); ?/>";</script></?php
header("Location: ./?page=".ILink("login"));
}
}
else
{
//?/><script>location.href="./?page=</?php echo ILink("home"); ?/>";</script></?php
header("Location: ./?page=".ILink("login"));
}
}
else{
//?/><script>location.href="./?page=</?php echo ILink("home"); ?/>";</script></?php
header("Location: ./?page=".ILink("login"));
}
print_gzipped_page();
?>