Avatar billede boegh3 Nybegynder
23. februar 2001 - 22:27 Der er 8 kommentarer og
1 løsning

Filmanager

hejsa
Jeg søger en filmanager baseret på php, jeg tænkte på noget i retning af den der er på whitehat.dk, den sakl kunne følgende:
ændre chmod,
redigere filer,
angive fil størrelse,
oprette filer/mappe,
slette filer,
have 5 gennemse felter til upload, som alle aktiveres med en knap,
angive dato for sidste ændring/oprettelse,
mulighed for at flytte/kopiere filer,
Mvh. Boegh
Avatar billede brain Nybegynder
23. februar 2001 - 22:31 #1
Prøv at check den ud der er i phpGroupWare www.phpgroupware.org.....
Avatar billede boegh3 Nybegynder
23. februar 2001 - 22:56 #3
Ok, nu har jeg den fra sunewolrd.com, den havde jeg også før men kan ikke få den til at funke,
den kan ses her: http://www.whitehat.dk/boegh/ex/ex/
Hvis der er nogen der gider at se på den vil jeg gerne lægge koden ud her
Avatar billede erikjacobsen Ekspert
23. februar 2001 - 23:09 #4
Den kan vel ikke ses uden at logge ind ??
Avatar billede repsac Nybegynder
23. februar 2001 - 23:15 #5
Næhh ... ellers skal vi i hvert fald til at hacke lÅrtet ... ;o)
Avatar billede boegh3 Nybegynder
23. februar 2001 - 23:17 #6
ja du kan se prog\'et men ikke koden den kommer her:
<?
############################################################
#
#    WEBEXPLORER 2.0 BY SUNE ALEXANDERSEN
#        president@suneworld.com
#            11:41 23.02.01
#
#WebExplorer is a Windows Explorer style file manager
#through your webbrowser, but don\'t let the \"Windows part\"
#of it scare you away! Just upload the file to your designated
#\"admin\" directory on your PHP enabled website, edit the
#variable $basedir to reflect your website, and off you go!!
#
#This application lets you edit, browse, CHMOD, view, move,
#rename, copy, and create files/directories in any forms/tables
#enabled browser.
#You even have the option to create html skeleton-files.
#
#PS: Let me stress out that WebExplorer does not have any
#\"built in\" authorization function. Use HTAccess or similar for this
#
# SETUP:::
#    Edit $basedir = \"/PATH/TO/YOUR/DIR\"; to reflect your site
#
#PRIVATE Licensing:
#The best things in life are free, and so is WebExplorer if
#plan on using it non-commercial.
#But if you appreciate the product, I would appreciate a
#small donation from you. Either by bank to my Norwegian
#account or by a gift certificate from Amazon.com.
#
#COMMERCIAL Licensing
#If you should use it for commercial means though, you have
#to pay a one-time fee of $100. Contact me for details. You
#will then get all upgrades as they are released, and you can
#even ask for customized versions.
#
#Payment information:
#SWIFT CODE: DNBANOKK
#ACCOUNT NUMBER: 5136 11 55 487
#
#My postal adress is:
#
#Sune Alexandersen
#Kongsskogen 62
#1370 Asker
#Norway
#
#Please send me a postcard from your country letting me know
#you are using WebExplorer!
#
#If you are one of the people out there who are dying to
#learn programming, let me tell you one thing;
#GET ON WITH IT!
#It isn\'t as hard as you might imagine. All you need is
#a plain, clear idea of your project and then start!
#
#New features in this upgrade:
#- All graphics have sizes specified, therefore HTML renders faster
#- Fixed security hole when user entered .. chdir. User could go above the set basedir without this fix.
#- Added support for PHTML, PNG, ZIP and WML as supported filetypes.
#- Added \"save & exit\" and \"restore original\" button in edit mode and \"edit\" button in view mode.
#- Added tiptext (title=\" \") to some links.
#- Added a BACK link when needed
#- Added $webname to title tag.
#- Added a check to see if there is an update available of WebExplorer.
#- Added option to use Cascaded style sheets.
#- The filetype detection is greatly improved. Now it is case-insensitive.
#- The \"select\"\'s on CHMOD now shows the current permissions.
#- Security upgraded in many ways.
#- Opportunity to \"turn off\" features.
#
#Newest version of this program can be found at www.suneworld.com/programs
#
#Live long and prosper my friend.
#Kind regards, Sune Alexandersen, president@suneworld.com 11:38 23.02.01
#
#History:
#    7.4.2000
#        Initial release
#
#    19.5.2000
#        All graphics have sizes specified. HTML renders faster
#        Preview of pictures also have size specified.
#        Fixed security hole when user entered .. chdir. User could go above the set basedir without this fix.
#        Thanks to Chris Kebbel for this heads-up.       
#        Fixed minor spelling errors.
#        Added PHTML and PNG as filetypes
#        Added \"save & exit\" and \"restore original\" button in edit mode and \"edit\" button in view mode.
#
#    27.5.2000
#        Fine tuned alot of newly added features.
#
#    15.6.2000
#        Corrected some more spelling errors.
#        Added tiptext (title=\" \") to some links.
#        When working with files, the filename is linked for easy viewing.
#        Better compressed gifs. Thanks to Otto for this.
#        Added a BACK link when needed
#        Added .WML to filetypes. Exciting WAP times (?). Also added compressed files.
#
#    15.6.2000
#        Added $webname to title tag.
#        Fixed some bad html errors.
#        Added a check to see if there is an update available of WebExplorer.
#
#    15.6.2000
#        Added option to use Cascaded style sheets.
#
#    11.7.2000
#        The filetype detection is greatly improved. Now it is case-insensitive.   
#   
#    17.10.2000
#        The select\'s on CHMOD now shows the current permissions.
#
#    23.2.2001
#        Release of version 2.0
############################################################
############### Set up some variables and functions

############### CHANGE THIS TO YOUR DESIRED ROOT DIRECTORY
############### Add a slash at the start of the line. NO slash at the end.
$basedir = \"/usr/local/www/whitehat/www/boegh/ex/ex\";
$webname = \"SuneWorld\";
$updatecheck = \"yes\";
$enable_css = \"yes\";
$enable_logout = \"no\";
$allow_move = \"yes\";
$allow_download = \"yes\";
$allow_copy = \"yes\";
$allow_touch = \"yes\";
$allow_rename = \"yes\";
$allow_edit = \"yes\";
$allow_chmod = \"yes\";
$allow_delete = \"yes\";
$allow_upload = \"yes\";
$allow_create_dir = \"yes\";
$allow_create_file = \"yes\";
$allow_display_env = \"yes\";
$not_allowed = \"This action is not allowed. Consult your system administrator.\";
$version = \"2.0\";
############### Size for textarea
if($enable_css == \"yes\")
    {
    $textrows = \"27\";
    $textcols = \"160\";
    }
else
    {
    $textrows = \"20\";
    $textcols = \"100\";
    }

############### If $wdir (working directory) isn\'t specified, set it as a slash (/)
if(!$wdir) $wdir=\"/\";

############### HTML ender
$html_ender = \"</td></tr><tr><td colspan=\\\"2\\\"><hr></td></tr><tr><th colspan=\\\"2\\\" bgcolor=\\\"#4C4C99\\\"><font size=\\\"-1\\\" color=\\\"white\\\" face=\\\"arial, helvetica\\\">Written by Sune Alexandersen 2001</font></th></tr></table></body></html>\";

############### Calculate image size
function imagesize()
    {
    $size = GetImageSize(\"$image\");
    }

############### HTML header
function html_header(){
    global $basedir;
    global $wdir;
    global $lastaction;
    global $version;
    global $HTTP_REFERER;
    global $action;
    global $webname;
    global $display;
    global $file;
    global $browse;
    global $raw;
    global $image;
    global $fileurl;
    global $enable_css;
    global $allow_display_env;
    global $enable_logout;
   
    echo \"<!DOCTYPE HTML PUBLIC \\\"-//W3C//DTD HTML 4.0 Transitional//EN\\\" \\\"http://www.w3c.org/TR/REC-html40/loose.dtd\\\">\";
    echo \"<HTML>\";
    echo \"<HEAD>\";
    echo \"<TITLE>WebExplorer $version ($webname)</TITLE>\";
   
    ############### Cascaded Style Sheets
    if($enable_css == \"yes\")
        {
        ?>
        <STYLE  TYPE=\"text/css\">
        <!--
        input
            {
            font-family : Arial, Helvetica;
            font-size : 10;
            color : #000033;
            font-weight : normal;
              border-color : #999999;
              border-width : 1;
              background-color : #FFFFFF;
            }
        textarea
            {
            font-family : Arial, Helvetica;
            font-size : 10;
            color : #000033;
            font-weight : normal;
              border-color : #999999;
              border-width : 1;
              background-color : #FFFFFF;
            }
        -->
        </style>
        <?
        }
    echo \"</HEAD>\";
    echo \"<BODY bgcolor=\\\"#C0C0C0\\\" link=\\\"#4C4C99\\\" vlink=\\\"#4C4C99\\\" alink=\\\"#4C4C99\\\">\";
    echo \"<table border=\\\"0\\\" align=\\\"center\\\" cellspacing=\\\"3\\\" cellpadding=\\\"3\\\" width=\\\"600\\\">\";
    echo \"<tr>\";
    echo \"    <th colspan=\\\"2\\\" width=\\\"100%\\\" bgcolor=\\\"#4C4C99\\\">\";

    if($allow_display_env == \"yes\")
        {
        echo \"    <A HREF=\\\"$PHP_SELF?action=env&wdir=$wdir\\\"><img src=\\\"env.gif\\\" alt=\\\"Environment\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"15\\\"></A>\";
        }

    if($enable_logout == \"yes\")
        {
        echo \"    <A HREF=\\\"$PHP_SELF?action=logout\\\">logout</A>\";
        }

    echo \"      <font size=\\\"6\\\" color=\\\"white\\\" face=\\\"arial, helvetica\\\">WebExplorer $version</font>  \";
    echo \"    <A HREF=\\\"$PHP_SELF?action=help&wdir=$wdir\\\"><img src=\\\"help.gif\\\" alt=\\\"Help\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"16\\\"></A>\";
    echo \"    </th>\";
    echo \"</tr>\";
    echo \"<tr>\";
    echo \" <td width\\\"50%\\\" align=\\\"left\\\"><A HREF=\\\"$PHP_SELF?action=root\\\"><font size=\\\"4\\\" face=\\\"arial, helvetica\\\">Back to root</font></a></td>\";
    echo \" <td width\\\"50%\\\" align=\\\"right\\\"><A HREF=\\\"$PHP_SELF?wdir=$wdir\\\" title=\\\"Refresh current dir\\\"><font size=\\\"4\\\" face=\\\"arial, helvetica\\\">$wdir</font><img src=\\\"explore.gif\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\"></a></td>\";
    echo \"</tr>\";
    echo \"<tr>\";
    echo \" <td colspan=\\\"2\\\"><hr></td>\";
    echo \"</tr>\";
    echo \"<tr>\";

    ############ We want a BACK link when viewing pictures and raw text.
    if($action == \"show\")
        {
        echo \" <td width=\\\"50%\\\" nobreak><b><font size=\\\"3\\\" color=\\\"#4C4C99\\\" face=\\\"arial, helvetica\\\">$lastaction</font></b></td>\";
        echo \" <td width=\\\"50%\\\" nobreak align=\\\"right\\\"><b><font size=\\\"3\\\" color=\\\"#4C4C99\\\" face=\\\"arial, helvetica\\\"><a href=\\\"$HTTP_REFERER\\\" title=\\\"Back to previous page\\\">Back</a></font></b></td>\";
        }

    ############ We dont want a BACK link
    else
        {
        echo \" <td colspan=\\\"2\\\"><b><font size=\\\"3\\\" color=\\\"#4C4C99\\\" face=\\\"arial, helvetica\\\">$lastaction</font></b></td>\";
        }

    echo \"<tr>\";
    echo \"<td colspan=\\\"2\\\"><hr><td>\";
    echo \"</tr>\";
    echo \"<tr>\";
    echo \"<td colspan=\\\"2\\\">\";
}

############ File size calculations
function display_size($file){
$file_size = filesize($file);
if($file_size >= 1073741824)
    {
        $file_size = round($file_size / 1073741824 * 100) / 100 . \"Gb\";
    }
elseif($file_size >= 1048576)
    {
        $file_size = round($file_size / 1048576 * 100) / 100 . \"Mb\";
    }
elseif($file_size >= 1024)
    {
        $file_size = round($file_size / 1024 * 100) / 100 . \"Kb\";
    }
else{
        $file_size = $file_size . \"B\";
    }
return $file_size;
}

############ List the files function
function list_files()
    {
    global $basedir;
    global $wdir;   
    global $single;
    global $key;

    global $allow_move;
    global $allow_chmod;
    global $allow_create_file;
    global $allow_create_dir;   
    global $allow_upload;

    global $allow_touch;
    global $allow_delete;

    ################## Load directory into array
    $handle=opendir(\".\");
    while ($file = readdir($handle))
        {
        if(is_file($file)) $filelist[] = $file;
        }
    closedir($handle);

    ############### List files
    if($filelist)
        {
        ############### Sort the filelist alphabetically
        asort($filelist);
        while (list ($key, $file) = each ($filelist))
            {

            ############### Registered filetypes. You can add more filetypes here at wish..
            ############### Check what fileformat it is and give it the correct icon and attributes
            $ext = strrchr ( $file , \".\" );

            ############### Image
            if((!strcasecmp ($ext, \".gif\")) || (!strcasecmp ($ext, \".jpg\")) || (!strcasecmp ($ext, \".png\")) || (!strcasecmp ($ext, \".bmp\")) || (!strcasecmp ($ext, \".jpeg\")))
                {
                $icon = \"<IMG SRC=\\\"image.gif\\\" alt=\\\"Image\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"16\\\">\";
                $browse = \"1\";
                $raw = \"0\";
                $image = \"1\";
                }
   
            ############### Textfile
            elseif(!strcasecmp ($ext, \".txt\"))
                {
                $icon = \"<IMG SRC=\\\"text.gif\\\" alt=\\\"Text\\\" border=\\\"0\\\" width=\\\"13\\\" height=\\\"16\\\">\";
                $browse = \"1\";
                $raw = \"1\";
                $image = \"0\";
                }
       
            ############### Audiofile
            elseif((!strcasecmp ($ext, \".wav\")) || (!strcasecmp ($ext, \".mp2\")) || (!strcasecmp ($ext, \".mp3\")) || (!strcasecmp ($ext, \".mp4\")) || (!strcasecmp ($ext, \".vqf\")) || (!strcasecmp ($ext, \".midi\")) || (!strcasecmp ($ext, \".mid\")))
                {
                $icon = \"<IMG SRC=\\\"audio.gif\\\" alt=\\\"Audio\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"16\\\">\";
                $browse = \"1\";
                $raw = \"0\";
                $image = \"0\";
                }

            ############### Webscript
            elseif((!strcasecmp ($ext, \".phps\")) || (!strcasecmp ($ext, \".php\")) || (!strcasecmp ($ext, \".php2\")) || (!strcasecmp ($ext, \".php3\")) || (!strcasecmp ($ext, \".php4\")) || (!strcasecmp ($ext, \".phtml\")) || (!strcasecmp ($ext, \".asp\")) || (!strcasecmp ($ext, \".asa\")) || (!strcasecmp ($ext, \".cgi\")) || (!strcasecmp ($ext, \".shtml\")) || (!strcasecmp ($ext, \".pl\")))
                {
                $icon = \"<IMG SRC=\\\"webscript.gif\\\" alt=\\\"Web program\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\">\";
                $browse = \"1\";
                $raw = \"1\";
                $image = \"0\";
                }

            ############### Apache Webserver security settings
            elseif(!strcasecmp ($ext, \".htaccess\"))
                {
                $icon = \"<IMG SRC=\\\"security.gif\\\" alt=\\\"Apache Webserver security settings\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"16\\\">\" ;
                $browse = \"0\";
                $raw = \"1\";
                $image = \"0\";
                }

            ############### Web page
            elseif ((!strcasecmp ($ext, \".html\")) || (!strcasecmp ($ext, \".htm\")))
                {
                $icon = \"<IMG SRC=\\\"webpage.gif\\\" alt=\\\"Web page\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\">\";
                $browse = \"1\";
                $raw = \"1\";
                $image = \"0\";
                }

            ############### WAP page
            elseif(!strcasecmp ($ext, \".wml\"))
                {
                $icon = \"<IMG SRC=\\\"webscript.gif\\\" alt=\\\"WAP page\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\">\";
                $browse = \"0\";
                $raw = \"1\";
                $image = \"0\";
                }

            ############### Compressed file
            elseif((!strcasecmp ($ext, \".zip\")) || (!strcasecmp ($ext, \".tar\")) || (!strcasecmp ($ext, \".rar\")) || (!strcasecmp ($ext, \".gz\")))
                {
                $icon = \"<IMG SRC=\\\"text.gif\\\" alt=\\\"Compressed file\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\">\";
                $browse = \"0\";
                $raw = \"0\";
                $image = \"0\";
                }
           
            ############### Unknown
            else
                {
                $icon = \"<IMG SRC=\\\"text.gif\\\" alt=\\\"Unknown filetype\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\">\";
                $browse = \"1\";
                $raw = \"1\";
                $image = \"0\";
                }
           
            ############### List the file(s)
            $filename=$basedir.$wdir.$file;
            $fileurl=rawurlencode($wdir.$file);
            $lastchanged = filectime($filename);
            $changeddate = date(\"d-m-Y H:i:s\", $lastchanged);
            echo \"<TR>\";
            echo \"<TD align=\\\"center\\\" nobreak>\";
           
            ############### Make the fileicon clickable for quickviewing
            if($raw == \"1\")
                {
                echo \"<A HREF=\\\"$PHP_SELF?action=show&wdir=$wdir&file=$fileurl&object=file&browse=$browse&raw=$raw\\\">\";
                }
           
            if($image == \"1\")
                {
                echo \"<A HREF=\\\"$PHP_SELF?action=show&wdir=$wdir&file=$fileurl&image=$image&object=file&browse=$browse&raw=$raw\\\">\";
                }
           
            echo \"$icon</TD>\\n\";
            echo \"<TD nobreak><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\" . htmlspecialchars($file) . \"</font></TD>\\n\";
            echo \"<TD align=\\\"right\\\" nobreak><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\" . display_size($filename) . \"</font></TD>\";
            echo \"<TD align=\\\"right\\\" nobreak><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\" . $changeddate . \"</font></TD><TD align=\\\"right\\\">\";
       
            ############### CHMOD file?
            if($allow_chmod == \"yes\")
                {
                echo \"<A HREF=\\\"$PHP_SELF?action=chmod&wdir=$wdir&file=$fileurl&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\\\" title=\\\"Change permission level on $file\\\">\";
                }
           
            echo \"<font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\";
            printf(\"%o\", (fileperms($filename)) & 0777);
            echo \"</font>\";
   
            if($allow_chmod == \"yes\")
                {
                echo \"</A>\";
                }
   
            echo \"</TD><TD nobreak>\";
               
            ############### Move file?
            if($allow_move == \"yes\")
                {
                echo \" <A HREF=\\\"$PHP_SELF?action=move&wdir=$wdir&file=$fileurl&object=file&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\\\"><img src=\\\"move.gif\\\" alt=\\\"Move, rename or copy $file\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\"></A> \";
                }
       
            ############### Touch file?
            if($allow_touch == \"yes\")
                {
                echo \" <A HREF=\\\"$PHP_SELF?action=touch&wdir=$wdir&touchfile=$fileurl&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\\\"><img src=\\\"touch.gif\\\" alt=\\\"Touch $file\\\" border=\\\"0\\\" width=\\\"12\\\" height=\\\"16\\\"></A> \";
                }

            ############### Delete file?
            if($allow_delete == \"yes\")
                {
                echo \"<A HREF=\\\"$PHP_SELF?action=del&wdir=$wdir&file=$fileurl&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\\\"><img src=\\\"delete.gif\\\" alt=\\\"Delete $file\\\" border=\\\"0\\\" width=\\\"20\\\" height=\\\"16\\\"></A> \";
                }
   
            ############### If the file can be browsed, give it the browse icon
            if($browse == \"1\")
                {
                echo \" <A HREF=\\\"$wdir$file\\\"><img src=\\\"browse.gif\\\" alt=\\\"Browse $file\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"16\\\"></A> \";
                }

            ############### If the file can be edited, give it the edit icon
            if($raw ==\"1\")
                {
                echo \" <A HREF=\\\"$PHP_SELF?wdir=$wdir&action=edit&display=1&file=$fileurl&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\\\"><img src=\\\"edit.gif\\\" alt=\\\"Edit $file\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"16\\\"></A> \";
                }
            }
        }
    }

############ List the directory function
function displaydir()
    {
    global $file;
    global $basedir;
    global $wdir;   
    global $allow_create_file;
    global $allow_create_dir;   
    global $allow_upload;
    global $allow_touch;
    global $allow_delete;
    global $allow_move;
   
    global $single;
   
    ############### Draw the head table
    if(isset($single))
        {
        echo \"<TABLE BORDER=\\\"0\\\" cellspacing=\\\"1\\\" cellpadding=\\\"1\\\" align=\\\"center\\\">\";
        }
    else
        {
        echo \"<TABLE BORDER=\\\"0\\\" cellspacing=\\\"1\\\" cellpadding=\\\"1\\\" width=\\\"100%\\\">\";   
        }
   
    echo \"<tr>\";
    echo \"<th bgcolor=\\\"#4C4C99\\\"><font color=\\\"white\\\" face=\\\"arial, helvetica\\\">Type</font></th>\";
    echo \"<th bgcolor=\\\"#4C4C99\\\"><font color=\\\"white\\\" face=\\\"arial, helvetica\\\">Name</font></th>\";
    echo \"<th bgcolor=\\\"#4C4C99\\\"><font color=\\\"white\\\" face=\\\"arial, helvetica\\\">Size</font></th>\";
    echo \"<th bgcolor=\\\"#4C4C99\\\"><font color=\\\"white\\\" face=\\\"arial, helvetica\\\">Modified</font></th>\";
    echo \"<th bgcolor=\\\"#4C4C99\\\"><font color=\\\"white\\\" face=\\\"arial, helvetica\\\">Perm\'s</font></th>\";
    echo \"<th bgcolor=\\\"#4C4C99\\\"><font color=\\\"white\\\" face=\\\"arial, helvetica\\\">Action</font></th>\";
    echo \"</tr>\";
   
    ################## Load directory into array
    if(!isset($single))
        {
        chdir($basedir.$wdir);
        $handle=opendir(\".\");
        while ($file = readdir($handle))
            {
            if(is_dir($file)) $dirlist[] = $file;
            }
        closedir($handle);

        ############### List directories first       
        if($dirlist)
            {
            ############### Sort alphabetically
            asort($dirlist);
            ############### Walk through array
            while (list ($key, $file) = each ($dirlist))
                {
                ################## Skip the tiresome \".\"
                if (!($file == \".\"))
                    {
                    $filename=$basedir.$wdir.$file;
                    $fileurl=rawurlencode($wdir.$file);
                    $lastchanged = filectime($filename);
                    $changeddate = date(\"d-m-Y H:i:s\", $lastchanged);
                    echo \"<TR>\";

                    ############### Print PARENT arrow
                    if($file == \"..\")
                        {
                        $downdir = dirname(\"$wdir\");
                        echo \"<TD align=\\\"center\\\" nobreak><A HREF=\\\"$PHP_SELF?action=chdr&file=$downdir\\\"><img src=\\\"parent.gif\\\" alt=\\\"Parent directory\\\" border=\\\"0\\\" width=\\\"20\\\" height=\\\"16\\\"></a></TD>\\n\";
                        echo \"<TD></TD>\\n\";
                        echo \"<TD align=\\\"right\\\" nobreak><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\" . display_size($filename) . \"</font></TD>\";
                        echo \"<TD align=\\\"right\\\" nobreak><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\" . $changeddate . \"</font></TD><TD align=\\\"right\\\">\";
                        printf(\"%o\", (fileperms($filename)) & 0777);
                        echo \"</TD><TD nobreak>\";
                        echo \"<A HREF=\\\"$PHP_SELF?action=chdr&file=$downdir\\\"><img src=\\\"parent.gif\\\" alt=\\\"Parent directory\\\" border=\\\"0\\\" width=\\\"20\\\" height=\\\"16\\\"></A> \";
                        }

                    ############### List the directory
                    else
                        {
                        $lastchanged = filectime($filename);
                        echo \"<TD align=\\\"center\\\" nobreak><A HREF=\\\"$PHP_SELF?action=chdr&file=$fileurl\\\"><img src=\\\"folder.gif\\\" alt=\\\"Change working directory to $file\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"13\\\"></a></TD>\\n\";
                        echo \"<TD nobreak><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\" . htmlspecialchars($file) . \"</font></TD>\\n\";
                        echo \"<TD align=\\\"right\\\" nobreak><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\" . display_size($filename) . \"</font></TD>\";
                        echo \"<TD align=\\\"right\\\" nobreak><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\" . $changeddate . \"</font></TD><TD align=\\\"right\\\">\";
                        echo \"<A HREF=\\\"$PHP_SELF?action=chmod&file=$filename\\\" title=\\\"Change permission level on $file\\\"><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">\";
                        printf(\"%o\", (fileperms($filename)) & 0777);
                        echo \"</A>\";
                        echo \"</font></TD><TD nobreak>\";

                        ############### Move directory?
                        if($allow_move == \"yes\")
                            {
                            echo \" <A HREF=\\\"$PHP_SELF?action=move&wdir=$wdir&file=$fileurl\\\"><img src=\\\"move.gif\\\" alt=\\\"Rename $file\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\"></A> \";
                            }
                       
                        ############### Touch directory?
                        if($allow_touch == \"yes\")
                            {
                            echo \" <A HREF=\\\"$PHP_SELF?action=touch&wdir=$wdir&touchfile=$fileurl\\\"><img src=\\\"touch.gif\\\" alt=\\\"Touch $file\\\" border=\\\"0\\\" width=\\\"12\\\" height=\\\"16\\\"></A> \";
                            }

                        ############### Delete directory?
                        if($allow_delete == \"yes\")
                            {
                            echo \"<A HREF=\\\"$PHP_SELF?action=del&wdir=$wdir&file=$fileurl\\\"><img src=\\\"delete.gif\\\" alt=\\\"Delete $file\\\" border=\\\"0\\\" width=\\\"20\\\" height=\\\"16\\\"></A> \";
                            }
                        }
                    }   
                }
            }
        list_files();
        echo \"</TD></TR>\\n\";
        echo \"</TABLE>\";

        ############### Display forms for different actions
        echo \"<table border=\\\"0\\\" width=\\\"100%\\\">\";
        echo \"<TR><TD colspan=\\\"2\\\"><hr></td>\";

        ############### Upload file
        if($allow_upload  == \"yes\")
            {
            echo \"<TR><TD><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">Upload file</font></td><td>\";
            echo \"<FORM ENCTYPE=\\\"multipart/form-data\\\" METHOD=\\\"POST\\\" ACTION=\\\"$PHP_SELF\\\">\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"wdir\\\" VALUE=\\\"$wdir\\\">\";
            echo \"<INPUT NAME=\\\"userfile\\\" TYPE=\\\"file\\\" size=\\\"40\\\">\";
            echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"upload\\\" VALUE=\\\"Go!\\\"></TD></TR>\";
            echo \"</FORM>\";
            }

        ############### Create directory
        if($allow_create_dir == \"yes\")
            {
            echo \"<FORM METHOD=\\\"POST\\\" ACTION=\\\"$PHP_SELF\\\">\";   
            echo \"<TR><TD><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">Create directory</font></td><td>\";
            echo \"<INPUT TYPE=\\\"TEXT\\\" NAME=\\\"mkdirfile\\\" size=\\\"40\\\">\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"action\\\" VALUE=\\\"mkdir\\\">\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"wdir\\\" VALUE=\\\"$wdir\\\">\";
            echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"mkdir\\\"  VALUE=\\\"Go!\\\"></TD></TR>\";
            echo \"</FORM>\";
            }

        ############### Create file
        if($allow_create_file == \"yes\")
            {
            echo \"<FORM METHOD=\\\"POST\\\" ACTION=\\\"$PHP_SELF\\\">\";
            echo \"<TR><TD><font size =\\\"-1\\\" face=\\\"arial, helvetica\\\">Create File</font></td><td>\";
            echo \"<INPUT TYPE=\\\"TEXT\\\" NAME=\\\"file\\\" size=\\\"40\\\">\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"action\\\" VALUE=\\\"createfile\\\"> \";
            echo \"<input type=\\\"checkbox\\\" name=\\\"html\\\" value=\\\"yes\\\"><font size =\\\"-2\\\" face=\\\"arial, helvetica\\\">(html template)</font> \";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"wdir\\\" VALUE=\\\"$wdir\\\">\";
            echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"createfile\\\" VALUE=\\\"Go!\\\">\";
            echo \"</TD></TR>\";
            echo \"</FORM>\";
            }
        echo \"</TABLE>\";
        }

    else
        {
        list_files();
        }
    }



#########################################################################################################
############### The user pressed CANCEL, set the $action to nothing
if($cancel) $action=\"\";

############### User has entered .. as directory. Potential security breach. Deny access.
$regexp=\"\\\\.\\\\.\";
if (ereg( $regexp, $file, $regs )| ereg( $regexp, $wdir,$regs ))
{
    $lastaction = \"ERROR: Directories may not contain the character \\\"..\\\"\";
    html_header();
    echo $html_ender;
    exit;
}

############### Upload file
if($upload)
    {
    copy($userfile,$basedir.$wdir.$userfile_name);
        $lastaction = \"Uploaded $userfile_name to $wdir\";
        html_header();
        displaydir();
        echo $html_ender;
        exit;
    }

#########################################################################################################
############### Begin actions code
switch ($action)
{

#########################################################################################################
############### No $action variable? Display initial page
    case \"\":
        $lastaction = \"Listing directory\";
        html_header();
        displaydir();
        echo $html_ender;
        break;


#########################################################################################################
############### Help
    case \"help\":
        $lastaction = \"Displaying help\";
        html_header();

        if($updatecheck == yes)
            {
            ############### Check to see if there is an update
            $filename = \"http://www.suneworld.com/programs/webexplorer.dat\";
              $fd = fopen ($filename, \"r\");
              $contents = fread ($fd, 1024);
              fclose ($fd);
       
            ############### There is. Give the user information about this
            if($version < $contents)
                {
                echo\"<b>NOTE:<br>\";
                echo\"WebExplorer has detected that an update is available.<br>\";
                echo\"You are currently using ver$version, and ver$contents is out.<br>\";
                echo\"Go to WebExplorers <a href=\\\"http://www.suneworld.com/programs\\\">website</a> to download your fresh copy.</b><br>\";
                echo\"(This feature can be turned of by editing the script (updatecheck section))<br>\";
                echo\"<hr>\";
                }
            }
        ?>

        <font face=\\\"arial, helvetica\\\">
        <ul>
        <h3>
        <a href=\"#introduction\">1. Introduction</a><br>
        <a href=\"#installing\">2. Installing</a><br>
        <a href=\"#requirements\">3. Requirements</a><br>
        <a href=\"#filetypes\">4. Description of filetypes</a><br>
        <a href=\"#actions\">5. Description of actions</a><br>
        <a href=\"#bugreport\">6. Bug report</a><br>
        <a href=\"#thanksto\">7. Thanks to</a><br>
        <a href=\"#about\">8. About the author</a><br>
        <a href=\"#licensing\">9. Licensing</a><br>
        <a href=\"#updates\">10. Updates</a><br>
        </h3>
        </ul>
        <hr>
       
        <h3><a name=\"introduction\">1. Introduction</a></h3>
        I was looking for a good browser-based file manager when
        I thought that I could write my own.
        Since I have never been a programming wiz\', I had
        to learn by doing. I\'m actually quite satisfied with how
        WebExplorer turned out, and I\'d love to hear of anybody
        using it. Drop me a line at <a href=\"mailto:president@suneworld.com\">president@suneworld.com</a>.<br>
        You can always find the newes version of this file at WebExplorers <a href=\"http://www.suneworld.com/programs\">website</a>.<br>
        <a href=\"#top\"><b>[Top]</b></a><p>

        <h3><a name=\"installing\">2. Installing</h3>
        Just put all the files into your desired directory
        (example www.yourdomain.com/webexplorer) and edit the
        following line in the scipt:<br>
        $basedir=\"/path/to/your/dir\";<br>
        to your desired root directory.
        <P>
        <b><u>IT IS HIGLY RECOMMENDED THAT YOU PASSWORD SECURE THIS DIRECTORY!</u></b><br>
        <a href=\"#top\"><b>[Top]</b></a><p>

        <h3><a name=\"requirements\">3. Requirements</a></h3>
        A webserver with PHP3 or newer installed. The HTML outputed is ment to be all-browser combatible.<br>
        <a href=\"#top\"><b>[Top]</b></a><p>

        <h3><a name=\"filetypes\">4. Description of filetypes</a></h3>
        <i>(Most of the icons are clickable.)</i>
        <ul>
        <table border=\"0\">
        <tr>
            <td valign=\"top\"><img src=\"folder.gif\" width=\"15\" height=\"13\"></td>
            <td>Indicates that the object is a folder.<br>
            <i>Click to change to this directory</i></td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"security.gif\" width=\"15\" height=\"16\"></td>
            <td>File is a Apache Webserver security file (.httaccess).<br>
            <i>Click to view source</i></td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"audio.gif\" width=\"16\" height=\"16\"></td>
            <td>File is an audiofile</td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"webpage.gif\" width=\"15\" height=\"15\"></td>
            <td>File is either an HTML or HTM file. Wievable directoly in you browser.<br>
            <i>Click to view source</i></td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"webscript.gif\" width=\"15\" height=\"15\"></td>
            <td>File is either an PHP, PHPS, PHP2, PHP3, PHP4, PHTML, ASP, ASA, CGI,
            PL or SHTML file. The file needs to be processed server-side before
            viewable in browser. For example; WebExplorer is an PHP3 file.<br>
            <i>Click to view source</i></td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"image.gif\" width=\"15\" height=\"15\"></td><td>File is either a GIF, PNG or a JPG file. Viewable
            image in any browser.<br>
            <i>Click to view.</i></td>
        </tr>
        </table>   
        </ul>
        <a href=\"#top\"><b>[Top]</b></a><p>
       
        <h3><a name=\"actions\">5. Description of actions</a></h3>
        <ul>
        <table border=\"0\">
        <tr>
            <td valign=\"top\"><img src=\"explore.gif\" width=\"15\" height=\"15\"></td>
            <td>Refresh current directory.</td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"parent.gif\" width=\"20\" height=\"16\"></td>
            <td>Go to parent directory.</td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"delete.gif\" width=\"20\" height=\"16\"></td>
            <td>Delete the file or directory. You will be prompted for confirmation.</td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"browse.gif\" width=\"16\" height=\"16\"></td>
            <td>Browse the file in browser.</td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"edit.gif\" width=\"16\" height=\"16\"></td>
            <td>Edit the file in plain text.</td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"move.gif\" width=\"15\" height=\"15\"></td>
            <td>Will move the file or directory to a location you specify.</td>
        </tr>
        <tr>
            <td valign=\"top\"><img src=\"touch.gif\" width=\"12\" height=\"16\"></td>
            <td>Will create a new timestamp on the object.</td>
        </tr>
        </table>   
        </ul>
        <a href=\"#top\"><b>[Top]</b></a><p>

        <h3><a name=\"bugreport\">6. Bug report</a></h3>
        I found no bugs at release. If you discover any, or have any suggestions, PLEASE report
        them to me at <a href=\"mailto:president@suneworld.com\">president@suneworld.com</a>
        or by using <a href=\"<? echo \"$PHP_SELF?action=bugreport&wdir=$wdir\"; ?>\">this</a> form.<br>
        <a href=\"#top\"><b>[Top]</b></a><p>

        <h3><a name=\"thanksto\">7. Thanks to</a></h3>
        I\'d like to thank all the regulars at #php @ Efnet,
        Stian Grytøyr and Jørn Morten Innselset. I wouldn\'t have made this
        without their invaluable help.<br>
        All of the members of the Webexplorer maillinglist allso deserves a BIG thanks.<br>
        Join the maillinglist at <a href=\"http://www.suneworld.com/programs\">SuneWorld</a><br>

        <a href=\"#top\"><b>[Top]</b></a><p>

        <h3><a name=\"about\">8. About the author</a></h3>
        Sune Alexandersen was born in 1976 in Norway. Sune has his personal website at
        <a href=\"www.suneworld.com</a>." target="_blank">http://www.suneworld.com\">www.suneworld.com</a>.
        He often use PHP, but this is his first program written entirely in PHP.

        <h3><a name=\"licensing\">9. Licensing</h3>
        <strong>PRIVATE</strong><br>
        The best things in life are free, and so is WebExplorer if plan on using it non-commercial.<br>
        But if you appreciate the product, I would appreciate a small donation from you. Either by bank<br>
        to my <a href=\"http://www.suneworld.com/programs/bankinfo.html\">Norwegian account</a> or by a gift<br>
        certificate from <a href=\"http://www.amazon.com/gift-certificates/\">Amazon.com</a>.<br>
        <p>
        <strong>COMMERCIAL</strong><br>
        If you should use it for commercial means though, you have to pay a one-time fee of $100<br>
        <a href=\"mailto:president@suneworld.com\">Contact me</a> for details. You will then get<br>
        all upgrades as they are released, and you can even ask for customized versions.</p>
        <p>

        <br>My address:
        <i><b><p>
        Sune Alexandersen<br>
        Kongsskogen 62<br>
        1385 Asker<br>
        Norway<br>
        </b><br>
        I would surely appreciate a postcard from your country telling me that you are using WebExplorer!
        </i>
        <p>
        I can allso be reached at <a href=\"mailto:president@suneworld.com\">president@suneworld.com</a>.
        <br><a href=\"#top\"><b>[Top]</b></a><p>
       
        <h3><a name=\"updates\">10. Updates</a></h3>
       
        <i><b>7.4.2000</b></i><br>
        Initial release<p>

        <i><b>19.5.2000</b></i><br>
        - All graphics have sizes specified. HTML renders faster<br>
        - Preview of pictures also have size specified.<br>
        - Fixed security hole when user entered .. chdir. User could go above the set basedir with this.
        Thanks to Chris Kebbel for this head-up.<br>       
        - Fixed minor spelling errors.<br>
        - Added PHTML and PNG as filetypes<br>
        - Added \"save & exit\" and \"reset\" button in edit mode and \"edit\" button in view mode.<p>

        <i><b>27.5.2000</b></i><br>
        - Fine tuned a lot of newly added features.<p>

        <i><b>15.6.2000</b></i><br>
        - Corrected some more spelling errors.<br>
        - Added tiptext (title=\" \") to some links.<br>
        - When editing files, the filename is linked for easy viewing.<br>
        - Better compressed gifs. Thanks to Otto for this.<br>
        - Added a BACK link when needed<br>
        - Added .WML to filetypes. Exciting WAP times (?).<p>

        <i><b>15.6.2000</b></i><br>
        - RELEASED 1.5

        <i><b>21.2.2001</b></i><br>
        - After numerous minor updates, version 2.0 is released.

        <br><a href=\"#top\"><b>[Top]</b></a><p>
        </font>
        <?
        echo $html_ender;
        break;

#########################################################################################################
############### User pressed ROOT.. Change to root dir
    case \"root\":
          $wdir=\"/\";
        $lastaction = \"Changed to root directory\";
        html_header();
        displaydir();
        echo $html_ender;
        break;

#########################################################################################################
############### Display PHP env
    case \"env\":
        if($allow_display_env == \"no\")
            {
            $lastaction = $not_allowed;
            html_header();
            displaydir();
            echo $html_ender;
            }
        else
            {
              $lastaction = \"Displaying PHP environment\";
            html_header();
            phpinfo();
            echo $html_ender;
            }
        break;

#########################################################################################################
############### Change directory
    case \"chdr\":
        $wdir=$file.\"/\";
        $lastaction = \"Changed directory to $wdir\";
        html_header();
        displaydir();
        echo $html_ender;
        break;

#########################################################################################################
############### Touch object (create a new timestamp)
    case \"touch\":
        if($allow_touch == \"no\")
            {
            $lastaction = $not_allowed;
            html_header();
            displaydir();
            echo $html_ender;
            }
        else
            {
            touch($basedir.$touchfile);
            $lastaction = \"Touched $touchfile\";
            html_header();
            displaydir();
            echo $html_ender;
            }
        break;

#########################################################################################################
############### Bug report form
    case \"bugreport\":
        if ($send)
            {
            $lastaction = \"Bug reported. Thank you!\";
            html_header();
            mail(\"president@suneworld.com\",\"Bug report\",\"Name: $name \\nVersion: $version \\n\\nProblem: $problem\");
            echo \"<h3><a href=\\\"$PHP_SELF?action=help&wdir=$wdir\\\">Back to help</a></h3>\";
            }
        else
            {
            $lastaction = \"Bug report form\";
            html_header();
            ?>
            <table>
            <form action=\"<? echo \"$PHP_SELF?action=bugreport&wdir=$wdir&send=1\"; ?>\" method=\"POST\">
            <tr>
                <td>Your name:</td>
                <td><input name=\"name\" size=\"24\" maxlength=\"30\"></td>
            </tr>
            <tr>
                <td>Your email adress:</td>
                <td><input name=\"email\" size=\"24\" maxlength=\"30\"></td>
            </tr>
            <tr>
                <td>Description of problem(s):</td>
                <td><textarea name=\"problem\" cols=\"30\" rows=\"5\"></textarea></td>
            </tr>
            <tr>
                <td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Send\"></td>
            </tr>   
            </table>
            <?
            }
        echo $html_ender;
        break;

#########################################################################################################
############### Delete file or directory
    case \"del\":
        ############### The user has comfirmed the deletion
        if ($confirm)
            {
           
            ############### Object is a directory
            if(is_dir($basedir.$file))
                {
                rmdir($basedir.$file);
                }

            ############### Object is a file
            else
                {
                unlink($basedir.$file);
                }
            $lastaction = \"Deleted $file\";
            html_header();
            displaydir();
            }

        ############### Prompt the user for confirmation
        else
            {
            if($raw == \"1\")
                {
                $lastaction = \"Are you sure you want to DELETE<br><A HREF=\\\"$PHP_SELF?action=show&wdir=$wdir&file=$fileurl\\\" title=\\\"View the file in raw format\\\">$file</a>?\";
                }
            elseif($image == \"1\")
                {
                $lastaction = \"Are you sure you want to DELETE<br><A HREF=\\\"$PHP_SELF?action=show&wdir=$wdir&file=$fileurl&image=$image\\\" title=\\\"View the image\\\">$file</a>?\";
                }
            else
                {
                $lastaction = \"Are you sure you want to DELETE<br>$file?\";
                }

            html_header();
            echo \"<center><b><font size =\\\"5\\\" face=\\\"arial, helvetica\\\"><A HREF=\\\"$PHP_SELF?action=del&wdir=$wdir&file=$file&confirm=1\\\">YES!</A></font><br>\";
            echo \"<p><font size =\\\"5\\\" face=\\\"arial, helvetica\\\"><A HREF=\\\"$PHP_SELF?wdir=$wdir\\\">NO!</A></font><br><b></center>\";
            }
        echo $html_ender;
        break;

#########################################################################################################
############### Change permission level
    case \"chmod\":

        ############### The user has confirmed
        if ($confirm)
            {
            $level = \"0\";
            $level .= $owner;
            $level .= $group;
            $level .= $public;
            $showlevel = $level;
            $level=octdec($level);
            chmod($basedir.$file,$level);
            $lastaction = \"Changed permission on $file to $showlevel\";
            html_header();
            displaydir();
            }

        ############### Prompt the user for confirmation
        else
            {
            $lastaction = \"Change permission level on $file\";
            html_header();           
            echo \"<font face=\\\"arial, helvetica\\\"><center><h4>Current level: \";
            printf(\"%o\", (fileperms($basedir.$file)) & 0777);
            echo \"</h4><FORM METHOD=\\\"POST\\\" ACTION=\\\"$PHP_SELF\\\">\\n\";
           
            function selections($type)  //  type: 0 Owner, 1 Group, 2 Public
                {
                echo \"<option value=\\\"0\\\"\"; if (substr($GLOBALS[\"perm\"], $type, 1)==\"0\") echo \"selected\"; echo \">0 - No permissions\";
                echo \"<option value=\\\"1\\\"\"; if (substr($GLOBALS[\"perm\"], $type, 1)==\"1\") echo \"selected\"; echo \">1 - Execute\";
                echo \"<option value=\\\"2\\\"\"; if (substr($GLOBALS[\"perm\"], $type, 1)==\"2\") echo \"selected\"; echo \">2 - Write \";
                echo \"<option value=\\\"3\\\"\"; if (substr($GLOBALS[\"perm\"], $type, 1)==\"3\") echo \"selected\"; echo \">3 - Execute & Write\";
                echo \"<option value=\\\"4\\\"\"; if (substr($GLOBALS[\"perm\"], $type, 1)==\"4\") echo \"selected\"; echo \">4 - Read\";
                echo \"<option value=\\\"5\\\"\"; if (substr($GLOBALS[\"perm\"], $type, 1)==\"5\") echo \"selected\"; echo \">5 - Execute & Read\";
                echo \"<option value=\\\"6\\\"\"; if (substr($GLOBALS[\"perm\"], $type, 1)==\"6\") echo \"selected\"; echo \">6 - Write & Read\";
                echo \"<option value=\\\"7\\\"\"; if (substr($GLOBALS[\"perm\"], $type, 1)==\"7\") echo \"selected\"; echo \">7 - Write, Execute & Read\";
                echo \"</select>\";
                }
           
            $perm = sprintf (\"%o\", (fileperms($basedir.$file)) & 0777);  // Definition of a variable containing the file permissions
            echo \"<p><h4>Owner<br>\";
            echo \"<select name=\\\"owner\\\">\";
            selections(0);

            echo \"<p>Group<br>\";
            echo \"<select name=\\\"group\\\">\";
            selections(1);

            echo \"<p>Public<br>\";
            echo \"<select name=\\\"public\\\">\";
            selections(2);

            echo \"</h4>\";
            echo \"<p>\";
            echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"confirm\\\" VALUE=\\\"Change\\\">\\n\";
            echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"cancel\\\" VALUE=\\\"Cancel\\\">\\n\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"action\\\" VALUE=\\\"chmod\\\">\\n\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"file\\\" VALUE=\\\"$file\\\">\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"wdir\\\" VALUE=\\\"$wdir\\\">\";
            echo \"</FORM>\";
            echo \"</center>\";
            }
        echo $html_ender;
        break;

#########################################################################################################
############### Move file
    case \"move\":
        ############### The user has confirmed renaming/moving/copying of the object
        if($confirm && $newfile)
            {
            ############### The destination object exists
                if(file_exists($basedir.$newfile))
                {
                $lastaction = \"Destination file already exists. Aborted.\";
                }
            else
                {
                if($do == copy)
                    {
                    copy($basedir.$file,$basedir.$newfile);
                    $lastaction = \"Copied\\n$file to $newfile\";
                    }
                else
                    {
                    rename($basedir.$file,$basedir.$newfile);
                    $lastaction = \"Moved/renamed\\n$file to $newfile\";
                    }
                }
            html_header();
            displaydir();
                echo $html_ender;
            }

        ############### Prompt the user for destination name and action
        else
            {
            if($object == \"file\")
                {
                if($raw == \"1\")
                    {
                    $lastaction = \"Moving/renaming or copying <A HREF=\\\"$PHP_SELF?action=show&wdir=$wdir&file=$fileurl\\\" title=\\\"View the file in raw format\\\">$file</a>\";
                    }
                elseif($image == \"1\")
                    {
                    $lastaction = \"Moving/renaming or copying <A HREF=\\\"$PHP_SELF?action=show&wdir=$wdir&file=$fileurl&image=$image\\\" title=\\\"View the image\\\">$file</a>\";
                    }
                else
                    {
                    $lastaction = \"Moving/renaming or copying $file\";
                    }

                html_header();
                echo \"<FORM METHOD=\\\"POST\\\" ACTION=\\\"$PHP_SELF\\\">\\n\";
                echo \"<select name=\\\"do\\\">\";
                echo \"<option value=\\\"copy\\\">Copy\";
                echo \"<option value=\\\"move\\\">Move/rename\";
                echo \"</select> \";
                echo \"($file)\";
                echo \"<h4>To</h4>\";
                echo \"<INPUT TYPE=\\\"TEXT\\\" NAME=\\\"newfile\\\" value=\\\"$file\\\" size=\\\"40\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"wdir\\\" VALUE=\\\"$wdir\\\">\\n\";           
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"action\\\" VALUE=\\\"move\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"file\\\" VALUE=\\\"$file\\\">\\n\";
                echo \"<p>\";
                echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"confirm\\\" VALUE=\\\"Do\\\">\\n\";
                echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"cancel\\\" VALUE=\\\"Cancel\\\">\\n\";
                echo \"</FORM>\";
                echo $html_ender;
                }
            else
                {
                $lastaction = \"Renaming $file\";

                html_header();
                echo \"<FORM METHOD=\\\"POST\\\" ACTION=\\\"$PHP_SELF\\\">\\n\";
                echo \"<h4>From</h4>\";
                echo \"$file\";
                echo \"<h4>To</h4>\";
                echo \"<INPUT TYPE=\\\"TEXT\\\" NAME=\\\"newfile\\\" value=\\\"$file\\\" size=\\\"40\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"wdir\\\" VALUE=\\\"$wdir\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"action\\\" VALUE=\\\"move\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"file\\\" VALUE=\\\"$file\\\">\\n\";
                echo \"<p>\";
                echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"confirm\\\" VALUE=\\\"Do\\\">\\n\";
                echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"cancel\\\" VALUE=\\\"Cancel\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"do\\\" VALUE=\\\"move\\\">\\n\";
                echo \"</FORM>\";
                echo $html_ender;
                }
            }
        break;

#########################################################################################################
############### Edit file
    case \"edit\":

        ############### Function for saving the file.
        function savefile()
            {
            global $basedir;
            global $file;
            global $code;
            html_header();
            $fp=fopen($basedir.$file,\"w\");
            fputs($fp,stripslashes($code));
            fclose($fp);
            }

        function buttons()
            {
            global $file;
            global $wdir;
           
            echo \"<center>\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"file\\\" VALUE=\\\"$file\\\">\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"action\\\" VALUE=\\\"edit\\\">\";
            echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"wdir\\\" VALUE=\\\"$wdir\\\">\";
            echo \"<INPUT TYPE=\\\"RESET\\\" VALUE=\\\"Restore original\\\"> \";
            echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"save\\\" VALUE=\\\"Save\\\"> \";
            echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"saveexit\\\" VALUE=\\\"Save & Exit\\\"> \";
            echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"cancel\\\" VALUE=\\\"Cancel / Exit\\\"> \";
            echo \"</center><BR>\\n\";
            }
                   
        ############### The user is done editing. Return to main screen
        if($saveexit)
              {
                $lastaction = \"Edited <a href=\\\"$file\\\" title=\\\"View the file\\\">$file</a>\";
            savefile();
            displaydir();
            }

        ############### Save the file, but continue editing.
        if($save)
              {
                $lastaction = \"Saved <a href=\\\"$file\\\" title=\\\"View the file\\\">$file</a>, still editing.\";
            savefile();
            echo \"<FORM METHOD=\\\"POST\\\" ACTION=\\\"$PHP_SELF\\\">\\n\";
            $fp=fopen($basedir.$file,\"r\");
            $contents=fread($fp,filesize($basedir.$file));
            echo \"<TEXTAREA NAME=\\\"code\\\" rows=\\\"$textrows\\\" cols=\\\"$textcols\\\">\\n\";
            echo htmlspecialchars($contents);
            echo \"</TEXTAREA><BR>\\n\";
            echo \"<center>\";
            buttons();
            echo \"</FORM>\";
            }

        ############### Display file in textarea
        if($display)
            {
            if($raw == \"1\")
                {
                $lastaction = \"Editing <A HREF=\\\"$PHP_SELF?action=show&wdir=$wdir&file=$file&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\\\" title=\\\"View the file in raw format\\\">$file</a>\";
                }
            elseif($image == \"1\")
                {
                $lastaction = \"Editing <A HREF=\\\"$PHP_SELF?action=show&wdir=$wdir&file=$fileurl&image=$image\\\" title=\\\"View the image\\\">$file</a>\";
                }
            else
                {
                $lastaction = \"Editing $file\";
                }
   
            html_header();
            echo \"<FORM METHOD=\\\"POST\\\" ACTION=\\\"$PHP_SELF\\\">\\n\";
            $fp=fopen($basedir.$file,\"r\");
            $contents=fread($fp,filesize($basedir.$file));
            echo \"<TEXTAREA NAME=\\\"code\\\" rows=\\\"$textrows\\\" cols=\\\"$textcols\\\">\\n\";
            echo htmlspecialchars($contents);
            echo \"</TEXTAREA><BR>\\n\";
            buttons();
            echo \"</FORM>\";
            }
        echo $html_ender;
        break;

       
#########################################################################################################
############### Display file
    case \"show\":

        ############### Display file in textformat
        $filelocation = $wdir.$file;   

        $lastaction = \"Displaying $file\";
        html_header();

        ############### It is a picture, display it. The filename needs to be either relative to the current document, or an absolute filesystem path.
        if($image == \"1\")
            {
            $size = GetImageSize($DOCUMENT_ROOT.$file);
            echo \"<center><img src=\\\"$file\\\" $size[3]></center>\";
            }

        ############### It is text, display it.
        else
            {
            $single = \"yes\";
#            displaydir();
            echo\"<hr><br>\";
            show_source($basedir.$file);
            }
        echo $html_ender;
        break;

#########################################################################################################
############### Create directory
    case \"mkdir\":
       
        ############### Is the action allowed?
        if($allow_create_dir == \"no\")
            {
            $lastaction = $not_allowed;
            html_header();
            }
        else
            {
            ############### The directory already exists.
            if(file_exists($basedir.$wdir.$mkdirfile))
                {
                $lastaction = \"The directory $wdir$mkdirfile allready exists.\";
                html_header();
                }

            ############### Create directory
            else
                {
                $lastaction = \"Created the directory $wdir$mkdirfile\";
                html_header();
                mkdir($basedir.$wdir.$mkdirfile,0750);
                }
            displaydir();
            echo $html_ender;
            }
        break;

#########################################################################################################
############### Create file
    case \"createfile\":
        $filelocation = $wdir.$file;

        ############### The user is done editing. Return to main screen
        if($done == \"1\")
              {
            $lastaction = \"Created $file\";
            html_header();

#            if($convert == \"yes\")
#                  {
#                $code = str_replace (\"\\n\", \"<BR>\");
#                }
       
            $fp=fopen($basedir.$filelocation,\"w\");
            fputs($fp,stripslashes($code));
                  fclose($fp);
            displaydir();
            }

        ############### Display a textarea that will be the file
        else
            {

              ############### The file allready exists
              if(file_exists($basedir.$filelocation))
                  {
                  $lastaction = \"$file allready exists.\";
                html_header();
                displaydir();
                }

            ############### Give the user a textarea to write the contents of file
            else
                {
                $lastaction = \"Creating $file\";
                html_header();
                echo \"<FORM METHOD=\\\"POST\\\" ACTION=\\\"$PHP_SELF\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"file\\\" VALUE=\\\"$file\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"action\\\" VALUE=\\\"createfile\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"wdir\\\" VALUE=\\\"$wdir\\\">\\n\";
                echo \"<INPUT TYPE=\\\"HIDDEN\\\" NAME=\\\"done\\\" VALUE=\\\"1\\\">\\n\";
                echo \"<TEXTAREA NAME=\\\"code\\\" rows=\\\"$textrows\\\" cols=\\\"$textcols\\\">\\n\";

                ############### The user selected to use a html template. Put it inside the textarea
                if(isset($html))
                    {
                    echo \"<!DOCTYPE HTML PUBLIC \\\"-//W3C//DTD HTML 4.0 Transitional//EN\\\">\\n\\n\";
                    echo \"<html>\\n\";
                    echo \"<head>\\n\\n\";
                    echo \"    <title>Untitled</title>\\n\";
                    echo \"</head>\\n\";
                    echo \"<body>\\n\\n\";
                    echo \"</body>\\n\";
                    echo \"</html>\";
                    }
                echo \"</TEXTAREA><BR>\\n\";
                echo \"<center><INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"confirm\\\" VALUE=\\\"Create\\\">\\n\";
                echo \"<INPUT TYPE=\\\"SUBMIT\\\" NAME=\\\"cancel\\\" VALUE=\\\"Cancel\\\"><br>\";
                $ext = strrchr ( $file , \".\" );
                if(!strcasecmp ($ext, \".txt\"))
                    {
                    echo \"<input type=\\\"checkbox\\\" name=\\\"convert\\\" value=\\\"yes\\\"><font size =\\\"-2\\\" face=\\\"arial, helvetica\\\">(convert line returns to BR)</font> \";                   
                    }
                echo \"</center><BR>\\n</FORM>\";
                }
            }
        echo $html_ender;
        break;
}
?><?
############################################################
#
#    WEBEXPLORER 2.0 BY SUNE ALEXANDERSEN
#        president@suneworld.com
#            11:41 23.02.01
#
#WebExplorer is a Windows Explorer style file manager
#through your webbrowser, but don\'t let the \"Windows part\"
#of it scare you away! Just upload the file to your designated
#\"admin\" directory on your PHP enabled website, edit the
#variable $basedir to reflect your website, and off you go!!
#
#This application lets you edit, browse, CHMOD, view, move,
#rename, copy, and create files/directories in any forms/tables
#enabled browser.
#You even have the option to create html skeleton-files.
#
#PS: Let me stress out that WebExplorer does not have any
#\"built in\" authorization function. Use HTAccess or similar for this
#
# SETUP:::
#    Edit $basedir = \"/PATH/TO/YOUR/DIR\"; to reflect your site
#
#PRIVATE Licensing:
#The best things in life are free, and so is WebExplorer if
#plan on using it non-commercial.
#But if you appreciate the product, I would appreciate a
#small donation from you. Either by bank to my Norwegian
#account or by a gift certificate from Amazon.com.
#
#COMMERCIAL Licensing
#If you should use it for commercial means though, you have
#to pay a one-time fee of $100. Contact me for details. You
#will then get all upgrades as they are released, and you can
#even ask for customized versions.
#
#Payment information:
#SWIFT CODE: DNBANOKK
#ACCOUNT NUMBER: 5136 11 55 487
#
#My postal adress is:
#
#Sune Alexandersen
#Kongsskogen 62
#1370 Asker
#Norway
#
#Please send me a postcard from your country letting me know
#you are using WebExplorer!
#
#If you are one of the people out there who are dying to
#learn programming, let me tell you one thing;
#GET ON WITH IT!
#It isn\'t as hard as you might imagine. All you need is
#a plain, clear idea of your project and then start!
#
#New features in this upgrade:
#- All graphics have sizes specified, therefore HTML renders faster
#- Fixed security hole when user entered .. chdir. User could go above the set basedir without this fix.
#- Added support for PHTML, PNG, ZIP and WML as supported filetypes.
#- Added \"save & exit\" and \"restore original\" button in edit mode and \"edit\" button in view mode.
#- Added tiptext (title=\" \") to some links.
#- Added a BACK link when needed
#- Added $webname to title tag.
#- Added a check to see if there is an update available of WebExplorer.
#- Added option to use Cascaded style sheets.
#- The filetype detection is greatly improved. Now it is case-insensitive.
#- The \"select\"\'s on CHMOD now shows the current permissions.
#- Security upgraded in many ways.
#- Opportunity to \"turn off\" features.
#
#Newest version of this program can be found at www.suneworld.com/programs
#
#Live long and prosper my friend.
#Kind regards, Sune Alexandersen, president@suneworld.com 11:38 23.02.01
#
#History:
#    7.4.2000
#        Initial release
#
#    19.5.2000
#        All graphics have sizes specified. HTML renders faster
#        Preview of pictures also have size specified.
#        Fixed security hole when user entered .. chdir. User could go above the set basedir without this fix.
#        Thanks to Chris Kebbel for this heads-up.       
#        Fixed minor spelling errors.
#        Added PHTML and PNG as filetypes
#        Added \"save & exit\" and \"restore original\" button in edit mode and \"edit\" button in view mode.
#
#    27.5.2000
#        Fine tuned alot of newly added features.
#
#    15.6.2000
#        Corrected some more spelling errors.
#        Added tiptext (title=\" \") to some links.
#        When working with files, the filename is linked for easy viewing.
#        Better compressed gifs. Thanks to Otto for this.
#        Added a BACK link when needed
#        Added .WML to filetypes. Exciting WAP times (?). Also added compressed files.
#
#    15.6.2000
#        Added $webname to title tag.
#        Fixed some bad html errors.
#        Added a check to see if there is an update available of WebExplorer.
#
#    15.6.2000
#        Added option to use Cascaded style sheets.
#
#    11.7.2000
#        The filetype detection is greatly improved. Now it is case-insensitive.   
#   
#    17.10.2000
#        The select\'s on CHMOD now shows the current permissions.
#
#    23.2.2001
#        Release of version 2.0
############################################################
############### Set up some variables and functions

############### CHANGE THIS TO YOUR DESIRED ROOT DIRECTORY
############### Add a slash at the start of the line. NO slash at the end.
$basedir = \"/usr/local/www/whitehat/www/boegh/ex/ex\";
$webname = \"SuneWorld\";
$updatecheck = \"yes\";
$enable_css = \"yes\";
$enable_logout = \"no\";
$allow_move = \"yes\";
$allow_download = \"yes\";
$allow_copy = \"yes\";
$allow_touch = \"yes\";
$allow_rename = \"yes\";
$allow_edit = \"yes\";
$allow_chmod = \"yes\";
$allow_delete = \"yes\";
$allow_upload = \"yes\";
$allow_create_dir = \"yes\";
$allow_create_file = \"yes\";
$allow_display_env = \"yes\";
$not_allowed = \"This action is not allowed. Consult your system administrator.\";
$version = \"2.0\";
############### Size for textarea
if($enable_css == \"yes\")
    {
    $textrows = \"27\";
    $textcols = \"160\";
    }
else
    {
    $textrows = \"20\";
    $textcols = \"100\";
    }

############### If $wdir (working directory) isn\'t specified, set it as a slash (/)
if(!$wdir) $wdir=\"/\";

############### HTML ender
$html_ender = \"</td></tr><tr><td colspan=\\\"2\\\"><hr></td></tr><tr><th colspan=\\\"2\\\" bgcolor=\\\"#4C4C99\\\"><font size=\\\"-1\\\" color=\\\"white\\\" face=\\\"arial, helvetica\\\">Written by Sune Alexandersen 2001</font></th></tr></table></body></html>\";

############### Calculate image size
function imagesize()
    {
    $size = GetImageSize(\"$image\");
    }

############### HTML header
function html_header(){
    global $basedir;
    global $wdir;
    global $lastaction;
    global $version;
    global $HTTP_REFERER;
    global $action;
    global $webname;
    global $display;
    global $file;
    global $browse;
    global $raw;
    global $image;
    global $fileurl;
    global $enable_css;
    global $allow_display_env;
    global $enable_logout;
   
    echo \"<!DOCTYPE HTML PUBLIC \\\"-//W3C//DTD HTML 4.0 Transitional//EN\\\" \\\"http://www.w3c.org/TR/REC-html40/loose.dtd\\\">\";
    echo \"<HTML>\";
    echo \"<HEAD>\";
    echo \"<TITLE>WebExplorer $version ($webname)</TITLE>\";
   
    ############### Cascaded Style Sheets
    if($enable_css == \"yes\")
        {
        ?>
        <STYLE  TYPE=\"text/css\">
        <!--
        input
            {
            font-family : Arial, Helvetica;
            font-size : 10;
            color : #000033;
            font-weight : normal;
              border-color : #999999;
              border-width : 1;
              background-color : #FFFFFF;
            }
        textarea
            {
            font-family : Arial, Helvetica;
            font-size : 10;
            color : #000033;
            font-weight : normal;
              border-color : #999999;
              border-width : 1;
              background-color : #FFFFFF;
            }
        -->
        </style>
        <?
        }
    echo \"</HEAD>\";
    echo \"<BODY bgcolor=\\\"#C0C0C0\\\" link=\\\"#4C4C99\\\" vlink=\\\"#4C4C99\\\" alink=\\\"#4C4C99\\\">\";
    echo \"<table border=\\\"0\\\" align=\\\"center\\\" cellspacing=\\\"3\\\" cellpadding=\\\"3\\\" width=\\\"600\\\">\";
    echo \"<tr>\";
    echo \"    <th colspan=\\\"2\\\" width=\\\"100%\\\" bgcolor=\\\"#4C4C99\\\">\";

    if($allow_display_env == \"yes\")
        {
        echo \"    <A HREF=\\\"$PHP_SELF?action=env&wdir=$wdir\\\"><img src=\\\"env.gif\\\" alt=\\\"Environment\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"15\\\"></A>\";
        }

    if($enable_logout == \"yes\")
        {
        echo \"    <A HREF=\\\"$PHP_SELF?action=logout\\\">logout</A>\";
        }

    echo \"      <font size=\\\"6\\\" color=\\\"white\\\" face=\\\"arial, helvetica\\\">WebExplorer $version</font>  \";
    echo \"    <A HREF=\\\"$PHP_SELF?action=help&wdir=$wdir\\\"><img src=\\\"help.gif\\\" alt=\\\"Help\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"16\\\"></A>\";
    echo \"    </th>\";
    echo \"</tr>\";
    echo \"<tr>\";
    echo \" <td width\\\"50%\\\" align=\\\"left\\\"><A HREF=\\\"$PHP_SELF?action=root\\\"><font size=\\\"4\\\" face=\\\"arial, helvetica\\\">Back to root</font></a></td>\";
    echo \" <td width\\\"50%\\\" align=\\\"right\\\"><A HREF=\\\"$PHP_SELF?wdir=$wdir\\\" title=\\\"Refresh current dir\\\"><font size=\\\"4\\\" face=\\\"arial, helvetica\\\">$wdir</font><img src=\\\"explore.gif\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\"></a></td>\";
    echo \"</tr>\";
    echo \"<tr>\";
    echo \" <td colspan=\\\"2\\\"><hr></td>\";
    echo \"</tr>\";
    echo \"<tr>\";

    ############ We want a BACK link when viewing pictures and raw text.
    if($action == \"show\")
        {
        echo \" <td width=\\\"50%\\\" nobreak><b><font size=\\\"3\\\" color=\\\"#4C4C99\\\" face=\\\"arial, helvetica\\\">$lastaction</font></b></td>\";
        echo \" <td width=\\\"50%\\\" nobreak align=\\\"right\\\"><b><font size=\\\"3\\\" color=\\\"#4C4C99\\\" face=\\\"arial, helvetica\\\"><a href=\\\"$HTTP_REFERER\\\" title=\\\"Back to previous page\\\">Back</a></font></b></td>\";
        }

    ############ We dont want a BACK link
    else
        {
        echo \" <td colspan=\\\"2\\\"><b><font size=\\\"3\\\" color=\\\"#4C4C99\\\" face=\\\"arial, helvetica\\\">$lastaction</font></b></td>\";
        }

    echo \"<tr>\";
    echo \"<td colspan=\\\"2\\\"><hr><td>\";
    echo \"</tr>\";
    echo \"<tr>\";
    echo \"<td colspan=\\\"2\\\">\";
}

############ File size calculations
function display_size($file){
$file_size = filesize($file);
if($file_size >= 1073741824)
    {
        $file_size = round($file_size / 1073741824 * 100) / 100 . \"Gb\";
    }
elseif($file_size >= 1048576)
    {
        $file_size = round($file_size / 1048576 * 100) / 100 . \"Mb\";
    }
elseif($file_size >= 1024)
    {
        $file_size = round($file_size / 1024 * 100) / 100 . \"Kb\";
    }
else{
        $file_size = $file_size . \"B\";
    }
return $file_size;
}

############ List the files function
function list_files()
    {
    global $basedir;
    global $wdir;   
    global $single;
    global $key;

    global $allow_move;
    global $allow_chmod;
    global $allow_create_file;
    global $allow_create_dir;   
    global $allow_upload;

    global $allow_touch;
    global $allow_delete;

    ################## Load directory into array
    $handle=opendir(\".\");
    while ($file = readdir($handle))
        {
        if(is_file($file)) $filelist[] = $file;
        }
    closedir($handle);

    ############### List files
    if($filelist)
        {
        ############### Sort the filelist alphabetically
        asort($filelist);
        while (list ($key, $file) = each ($filelist))
            {

            ############### Registered filetypes. You can add more filetypes here at wish..
            ############### Check what fileformat it is and give it the correct icon and attributes
            $ext = strrchr ( $file , \".\" );

            ############### Image
            if((!strcasecmp ($ext, \".gif\")) || (!strcasecmp ($ext, \".jpg\")) || (!strcasecmp ($ext, \".png\")) || (!strcasecmp ($ext, \".bmp\")) || (!strcasecmp ($ext, \".jpeg\")))
                {
                $icon = \"<IMG SRC=\\\"image.gif\\\" alt=\\\"Image\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"16\\\">\";
                $browse = \"1\";
                $raw = \"0\";
                $image = \"1\";
                }
   
            ############### Textfile
            elseif(!strcasecmp ($ext, \".txt\"))
                {
                $icon = \"<IMG SRC=\\\"text.gif\\\" alt=\\\"Text\\\" border=\\\"0\\\" width=\\\"13\\\" height=\\\"16\\\">\";
                $browse = \"1\";
                $raw = \"1\";
                $image = \"0\";
                }
       
            ############### Audiofile
            elseif((!strcasecmp ($ext, \".wav\")) || (!strcasecmp ($ext, \".mp2\")) || (!strcasecmp ($ext, \".mp3\")) || (!strcasecmp ($ext, \".mp4\")) || (!strcasecmp ($ext, \".vqf\")) || (!strcasecmp ($ext, \".midi\")) || (!strcasecmp ($ext, \".mid\")))
                {
                $icon = \"<IMG SRC=\\\"audio.gif\\\" alt=\\\"Audio\\\" border=\\\"0\\\" width=\\\"16\\\" height=\\\"16\\\">\";
                $browse = \"1\";
                $raw = \"0\";
                $image = \"0\";
                }

            ############### Webscript
            elseif((!strcasecmp ($ext, \".phps\")) || (!strcasecmp ($ext, \".php\")) || (!strcasecmp ($ext, \".php2\")) || (!strcasecmp ($ext, \".php3\")) || (!strcasecmp ($ext, \".php4\")) || (!strcasecmp ($ext, \".phtml\")) || (!strcasecmp ($ext, \".asp\")) || (!strcasecmp ($ext, \".asa\")) || (!strcasecmp ($ext, \".cgi\")) || (!strcasecmp ($ext, \".shtml\")) || (!strcasecmp ($ext, \".pl\")))
                {
                $icon = \"<IMG SRC=\\\"webscript.gif\\\" alt=\\\"Web program\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"15\\\">\";
                $browse = \"1\";
                $raw = \"1\";
                $image = \"0\";
                }

            ############### Apache Webserver security settings
            elseif(!strcasecmp ($ext, \".htaccess\"))
                {
                $icon = \"<IMG SRC=\\\"security.gif\\\" alt=\\\"Apache Webserver security settings\\\" border=\\\"0\\\" width=\\\"15\\\" height=\\\"16\\\">\" ;
                $browse = \"0\";
                $raw = \"1\";
                $image = \"0\";
                }

            ############### Web page
            elseif ((!strcasecmp ($ext, \".html\")) || (!strcasecmp ($ext, \".htm\")))
                {
                $icon = \"<IMG SRC=\\\"webpage.gif\\\" alt=\\\"Web page\\\" border=\\
Avatar billede boegh3 Nybegynder
23. februar 2001 - 23:23 #7
Undksyld har eksperimenteret med .htaccess
brugernavn: ekspertendk pass: 1234
Avatar billede warpsnet Nybegynder
26. februar 2001 - 21:20 #8
Som aftalt afsendt og klar til brug :-)
Avatar billede boegh3 Nybegynder
26. februar 2001 - 21:37 #9
Til dem der nu undrer sig lidt, det er blevet lavet over ICQ!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester