Exemplo n.º 1
0
<pre style="margin-top: 0">' . $src . '</pre>
</td>
</tr>
</table>
';
		html_footer();
	} else {
		echo '<textarea name="code" cols="150" rows="50" wrap="VIRTUAL" >';
		readfile($file);
	}
	break;
case 'download':
	header('Pragma: public');
	header('Expires: 0');
	header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
	header('Content-Type: ' . getmimetype($file));
	header('Content-Disposition: attachment; filename=' . basename($file) . ';');
	header('Content-Length: ' . filesize($file));
	readfile($file);
	break;
case 'upload':
	$dest = relative2absolute($file['name'], $directory);
	if (@file_exists($dest)) {
		listing_page(error('already_exists', $dest));
	} elseif (@move_uploaded_file($file['tmp_name'], $dest)) {
		listing_page(notice('uploaded', $file['name']));
	} else {
		listing_page(error('not_uploaded', $file['name']));
	}
	break;
case 'create_directory':
Exemplo n.º 2
0
     $res = extendfile($path, $end - $start + 1, $total);
     checkerror($res);
     $res = savechunk($path, $start, $end);
     checkerror($res);
     $res = mergechunk($path, $start, $end);
     checkerror($res);
     $res = cleanchunk($path, $start, $end);
     checkerror($res);
 } else {
     if ($_REQUEST['action'] == "get") {
         $scope = $_REQUEST['scope'];
         $fname = $_REQUEST['fname'];
         $id = $_REQUEST['id'];
         $ext = substr(strrchr($fname, '.'), 1);
         header('Content-Disposition: attachment; filename=' . $fname);
         header('Content-Type: ' . getmimetype($ext));
         $path = getlocpath($scope, $fname, $id);
         header('X-ACCEL-REDIRECT: ' . $path);
     } else {
         if ($_REQUEST['action'] == "del") {
             $path = getpath();
             if (file_exists($path)) {
                 if (unlink($path)) {
                     //ok
                 } else {
                     checkerror(5);
                 }
             } else {
                 checkerror(6);
             }
         } else {
Exemplo n.º 3
0
Arquivo: my.php Projeto: vcgato29/poff
/**
 * filemanager page
 *
 * @return string
 */
function action_filemanager()
{
    if (isset($_REQUEST['filepath']) && is_readable($_REQUEST['filepath']) && !demo) {
        header('Content-Type: ' . getmimetype($_REQUEST['filepath']));
        header('Content-Disposition: filename=' . basename($_REQUEST['filepath']));
        readfile($_REQUEST['filepath']);
        exit;
    }
    $output = '<h1>filemanager</h1>';
    #$default_dir = dirname(__FILE__);
    $default_dir = '.';
    $current_dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : $default_dir;
    #if(demo && is_forbidden($current_dir))
    if (demo && strlen(realpath($current_dir)) < strlen(realpath(dirname(__FILE__)))) {
        $current_dir = $default_dir;
    }
    if (!is_dir($current_dir)) {
        $current_dir = $default_dir;
    }
    $current_dir = realpath($current_dir);
    if (is_writeable($current_dir) && !demo) {
        if (isset($_FILES['uploadfile'])) {
            if ($_FILES['uploadfile']['error'] == UPLOAD_ERR_OK && move_uploaded_file($_FILES['uploadfile']['tmp_name'], add_slash_if_needed($current_dir) . $_FILES['uploadfile']['name'])) {
                $output .= '<p class="notice">File has been uploaded.</p>';
            } else {
                $err = $_FILES['uploadfile']['error'];
                $upload_errors = array(UPLOAD_ERR_OK => 'upload ok.', UPLOAD_ERR_INI_SIZE => 'file was bigger than allowed in php.ini', UPLOAD_ERR_FORM_SIZE => 'file was bigger that allowed with MAX_FILE_SIZE on form', UPLOAD_ERR_PARTIAL => 'upload was partial', UPLOAD_ERR_NO_FILE => 'no file', 6 => 'temp dir not found');
                $output .= '<p class="error">Upload failed, err #' . $err . ': "' . $upload_errors[$err] . '"</p>';
            }
        }
        if (isset($_POST['newfilename']) && in_array($_POST['newfiletype'], range(1, 2))) {
            $newpath = add_slash_if_needed($_REQUEST['dir']) . $_POST['newfilename'];
            if ($_POST['newfiletype'] == 1) {
                if (touch($newpath)) {
                    $output .= '<p class="notice">File has been created.</p>';
                } else {
                    $output .= '<p class="error">File creating failed.</p>';
                }
            } else {
                if (mkdir($newpath)) {
                    $output .= '<p class="notice">Folder has been created.</p>';
                } else {
                    $output .= '<p class="error">Error: folder creating failed.</p>';
                }
            }
        }
    }
    $files = $folders = array();
    $d = dir($current_dir);
    if (is_object($d)) {
        while (false !== ($file = $d->read())) {
            $path = add_slash_if_needed($current_dir) . $file;
            if (is_file($path)) {
                $files[$path] = $file;
            } else {
                $folders[$path] = $file;
            }
        }
        $d->close();
    }
    if (demo) {
        $output .= '<p class="error">You can browse only current folder and its subfolders in demo mode</p>';
    }
    $output .= '<form action="' . self . '" method="post">
	<input type="text" name="dir" value="' . $current_dir . '" size="50">
	<input type="hidden" name="filem" value="1">
	<input type="submit" value=" cd ">
	</form>';
    if (is_writeable($current_dir)) {
        // upload form
        $output .= '<form action="' . self . '" method="post" enctype="multipart/form-data">';
        $output .= '<input type="file" name="uploadfile">';
        $output .= '<input type="submit" value="upload">';
        $output .= html_hidden(array('dir' => $current_dir, 'filem' => 1));
        $output .= '</form>';
        // new file/folder form
        $output .= '<form action="' . self . '" method="post">';
        $output .= html_selectbox('newfiletype', array(1 => 'file', 2 => 'folder'), 1);
        $output .= '<input type="text" name="newfilename">';
        $output .= html_hidden(array('dir' => $current_dir, 'filem' => 1));
        $output .= '<input type="submit" value="create">';
        $output .= '</form>';
    }
    $i = 1;
    // flag for css style
    $output .= '<table>';
    $output .= '<tr class="table_header">
		<th>filename</th>
		<th>size</th>
		<th>perms</th>
		<th>how old</th>
		<th>actions</th>
	</tr>';
    if (count($folders)) {
        natcasesort($folders);
        foreach ($folders as $fop => $fo) {
            $i = !$i;
            $row_css = $i ? 'class="table_even_row"' : 'class="table_odd_row"';
            $output .= '<tr ' . $row_css . '>
				<td>[ ' . html_encode_link($fo, self, array('filem' => 1, 'dir' => add_slash_if_needed($current_dir) . $fo)) . ' ]</td>
				<td>&nbsp;</td>
				<td>' . getperms($fop) . '</td>
				<td align="right" title="' . date('Y-m-d H:i:s', filemtime($fop)) . '">' . how_old(filemtime($fop)) . '</td>
				<td></td>
			</tr>';
        }
    }
    if (count($files)) {
        natcasesort($files);
        foreach ($files as $fip => $fi) {
            $i = !$i;
            $row_css = $i ? 'class="table_even_row"' : 'class="table_odd_row"';
            $output .= '<tr ' . $row_css . '>
				<td>' . html_encode_link($fi, self, array('filem' => 1, 'filepath' => $fip, 'cmd' => 'view')) . '</td>
				<td align="right">' . filesize_format(filesize($fip)) . '</td>
				<td>' . getperms($fip) . '</td>
				<td align="right" title="' . date('Y-m-d H:i:s', filemtime($fip)) . '">' . how_old(filemtime($fip)) . '</td>
				<td>' . (is_writeable($fip) ? html_encode_link('edit', self, array('editfile' => 1, 'path' => $fip)) : '') . (is_readable($fip) && eregi('php$', $fip) ? ' ' . html_encode_link('analyze', self, array('analyzefile' => 1, 'filepath' => $fip)) : '') . '</td>
			</tr>';
        }
    }
    return $output .= '</table>';
}
Exemplo n.º 4
0
</tr>
</table>

';
            html_footer();
        } else {
            header('Content-Type: ' . getmimetype($file) . '; charset=utf-8');
            header('Content-Disposition: filename=' . basename($file));
            readfile($file);
        }
        break;
    case 'download':
        header('Pragma: public');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Content-Type: ' . getmimetype($file) . '; charset=utf-8');
        header('Content-Disposition: attachment; filename=' . basename($file) . ';');
        header('Content-Length: ' . filesize($file));
        readfile($file);
        break;
    case 'upload':
        $dest = relative2absolute($file['name'], $directory);
        if (@file_exists($dest)) {
            listing_page(error('already_exists', $dest));
        } elseif (@move_uploaded_file($file['tmp_name'], $dest)) {
            @chmod($dest, $filepermission);
            listing_page(notice('uploaded', $file['name']));
        } else {
            listing_page(error('not_uploaded', $file['name']));
        }
        break;