Request for Comments on two column Micro File Manager from n00b

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

code review request

A couple of days ago, I was dismayed to find my ~/public_html directory  
choked with junk files.  I wanted a micro file manager to be able to  
parse the files and directories quickly and it seems like php is the  

I found a public domain script on called  
microFileManager.php that I based the following code.  The original code  
used tables.  The code below uses a style sheet and presents the  
directory listing in column 1 and the selected file content in column 2  
in a basic menu/content 2 column format.

Sample style sheet provided.

I'm new to php and would appreciate feedback on this script.  Layout,  
function calls, error handling - whatever. Perhaps there are php classes  
or functions that can do this better.

The micro file manager requirements are...

    o create a well written php script

    o not to exceed 100 lines of code

    o wrapping at column 80 - personal preference - posting to  
      newsgroup would make this requirement difficult at best -
      so perhaps this should read - readable code.

    o directory listings displayed on left column

    o selecting item in listing displays item in right column

    o two files only, the script and the stylesheet. No extra
      gifs, functions, features.

    o no tables


function showHeader($path) {
        print "<div id='Header'>";
        print "Path: $path";
        print "</div>";
function showMenu($path) {

   if ($handle = opendir($path))
        print "<div id='Menu'>";
        print "<h2>Menu</h2>";

        $up = substr($path, 0, (strrpos(dirname($path."/."),"/")));
        print "<a href='".$_SERVER['PHP_SELF']."?path=$up'>Up one level</

        while (false !== ($file = readdir($handle)))
                if ($file != "." && $file != "..")
                        $fName = $file;
                        $file = $path.'/'.$file;
                        if(is_file($file)) {
                                print "<a href=";
                                print "'".$_SERVER['PHP_SELF']."?path=
                                print "=>$fName</a>";
                        } elseif (is_dir($file)) {
                                print "<a href=";
                                print "'".$_SERVER['PHP_SELF']."?path=
                print "<br>";
        print "</div>";

function showContent($path, $fn){
        print "<div id='Content'>";
        print "<h2>$fn</h2>";
        $imageext = array(jpg, jpeg, JPEG, JPG, gif, png);
        $textext = array(txt, cfg, sql, css, plugin);
        $path_parts = pathinfo($fn);  
        if (in_array($path_parts['extension'], $imageext, true)) {
                echo '<img src="' . $path . "/" . $fn . '">';
        } elseif (in_array($path_parts['extension'], $textext, true)) {
                echo '<pre>';
                echo '</pre>';
        } else {
        print "</div>";

if (isset($_POST['submitBtn'])){
        $actpath = isset($_POST['path']) ? $_POST['path'] : '.';
} else {
        $actpath = isset($_GET['path']) ? $_GET['path'] : '.';

if (isset ($_GET['file']) )  
        $filename = $_GET['file'];



if (isset($filename)){  
        showContent($actpath, $filename);


body {
        font-family:verdana, arial, helvetica, sans-serif;
h1 {
        margin:1px 0px 15px 0px;
p {
        font:11px verdana, arial, helvetica, sans-serif;
        margin: -10px 0px 0px 0px;
#Menu h2
        font-family:verdana, arial, helvetica, sans-serif;
a {
        font-family:verdana, arial, helvetica, sans-serif;
#Header {
        margin:20px 0px 10px 210px; /* space from top, width, height,  
inside margin  */
        padding:17px 0px 0px 10px;
        border-width:1px 1px; /* top and bottom borders, left and right  
borders */
        voice-family: "\"}\"";

#Content {
        margin:0px 50px 50px 220px;
        font:11px/20px verdana, arial, helvetica, sans-serif;

#Menu {
        background-color:#EFE9C4; /* Menu background */
        dashed #999;
        voice-family: "\"}\"";
body>#Menu /* Menu width */

CODE:  header it insert style sheet.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
        <title>File Browser</title>
        <link href="style/layoutdir.css" rel="stylesheet" type="text/
css" />
replace this line with php code  

Site Timeline