u still can traverse to other folders & "." is useless it symbolize current folder. No use of clicking it. If you dont want ppl to traverse other folders u should use this one

PHP Code: 
<?php
ini_set 
('log_errors'1);

// You can also specify a file for the error log directive.
ini_set ('error_log''/somehome/someuser/public_html/mtn/error_log');

/*
 * webadmin.php - a simple Web-based file manager
 * Copyright (C) 2004  Daniel Wacker <daniel.wacker@web.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * -------------------------------------------------------------------------
 * While using this script, do NOT navigate with your browser's back and
 * forward buttons! Always open files in a new browser tab!
 * -------------------------------------------------------------------------
 *
 * This is Version 0.9, revision 11
 * =========================================================================
 *
 * Changes of revision 11
 * <daniel.wacker@web.de>
 *    fixed handling if folder isn't readable
 *
 * Changes of revision 10
 * <alex-smirnov@web.de>
 *    added Russian translation
 * <daniel.wacker@web.de>
 *    added </td> to achieve valid XHTML (thanks to Marc Magos)
 *    improved delete function
 * <ava@asl.se>
 *    new list order: folders first
 *
 * Changes of revision 9
 * <daniel.wacker@web.de>
 *    added workaround for directory listing, if lstat() is disabled
 *    fixed permisson of uploaded files (thanks to Stephan Duffner)
 *
 * Changes of revision 8
 * <okankan@stud.sdu.edu.tr>
 *    added Turkish translation
 * <j@kub.cz>
 *    added Czech translation
 * <daniel.wacker@web.de>
 *    improved charset handling
 *
 * Changes of revision 7
 * <szuniga@vtr.net>
 *    added Spanish translation
 * <lars@soelgaard.net>
 *    added Danish translation
 * <daniel.wacker@web.de>
 *    improved rename dialog
 *
 * Changes of revision 6
 * <nederkoorn@tiscali.nl>
 *    added Dutch translation
 *
 * Changes of revision 5
 * <daniel.wacker@web.de>
 *    added language auto select
 *    fixed symlinks in directory listing
 *    removed word-wrap in edit textarea
 *
 * Changes of revision 4
 * <daloan@guideo.fr>
 *    added French translation
 * <anders@wiik.cc>
 *    added Swedish translation
 *
 * Changes of revision 3
 * <nzunta@gabriele-erba.it>
 *    improved Italian translation
 *
 * Changes of revision 2
 * <daniel.wacker@web.de>
 *    got images work in some old browsers
 *    fixed creation of directories
 *    fixed files deletion
 *    improved path handling
 *    added missing word 'not_created'
 * <till@tuxen.de>
 *    improved human readability of file sizes
 * <nzunta@gabriele-erba.it>
 *    added Italian translation
 *
 * Changes of revision 1
 * <daniel.wacker@web.de>
 *    webadmin.php completely rewritten:
 *    - clean XHTML/CSS output
 *    - several files selectable
 *    - support for windows servers
 *    - no more treeview, because
 *      - webadmin.php is a >simple< file manager
 *      - performance problems (too much additional code)
 *      - I don't like: frames, java-script, to reload after every treeview-click
 *    - execution of shell scripts
 *    - introduced revision numbers
 *
/* ------------------------------------------------------------------------- */

include("config.php");

/* Your language:
 * 'en' - English
 */
$lang 'en';

/* Charset of output:
 * possible values are described in the charset table at
 * http://www.php.net/manual/en/function.htmlentities.php
 * 'auto' - use the same charset as the words of my language are encoded
 */
$site_charset 'auto';

/* Homedir:
 * For example: './' - the script's directory
 */
$dirs=$config['dirs'];
$homedir $dirs[0];

/* Size of the edit textarea
 */
$editcols 80;
$editrows 25;

/* -------------------------------------------
 * Optional configuration (remove # to enable)
 */

/* Permission of created directories:
 * For example: 0705 would be 'drwx---r-x'.
 */
# $dirpermission = 0705;

/* Permission of created files:
 * For example: 0604 would be '-rw----r--'.
 */
# $filepermission = 0604;

/* Filenames related to the apache web server:
 */
$htaccess '.htaccess';
$htpasswd '.htpasswd';

/* ------------------------------------------------------------------------- */

if (get_magic_quotes_gpc()) {
    
array_walk($_GET'strip');
    
array_walk($_POST'strip');
    
array_walk($_REQUEST'strip');
}

if (
array_key_exists('image'$_GET)) {
    
header('Content-Type: image/gif');
    die(
getimage($_GET['image']));
}

if (!
function_exists('lstat')) {
    function 
lstat ($filename) {
        return 
stat($filename);
    }
}
$_GET['dir']="";
$delim DIRECTORY_SEPARATOR;

if (
function_exists('php_uname')) {
    
$win = (strtoupper(substr(PHP_OS03)) === 'WIN') ? true false;
} else {
    
$win = ($delim == '\\') ? true false;
}

if (!empty(
$_SERVER['PATH_TRANSLATED'])) {
    
$scriptdir dirname($_SERVER['PATH_TRANSLATED']);
} elseif (!empty(
$_SERVER['SCRIPT_FILENAME'])) {
    
$scriptdir dirname($_SERVER['SCRIPT_FILENAME']);
} elseif (
function_exists('getcwd')) {
    
$scriptdir getcwd();
} else {
    
$scriptdir '.';
}
$homedir relative2absolute($homedir$scriptdir);

//$dir = (array_key_exists('dir', $_REQUEST)) ? $_REQUEST['dir'] : $homedir;
$dir $homedir;

if (
array_key_exists('olddir'$_POST) && !path_is_relative($_POST['olddir'])) {
    
$dir relative2absolute($dir$_POST['olddir']);
}

$directory simplify_path(addslash($dir));

$files = array();
$action '';
if (!empty(
$_POST['submit_all'])) {
    
$action $_POST['action_all'];
    for (
$i 0$i $_POST['num']; $i++) {
        if (
array_key_exists("checked$i"$_POST) && $_POST["checked$i"] == 'true') {
            
$files[] = $_POST["file$i"];
        }
    }
} elseif (!empty(
$_REQUEST['action'])) {
    
$action $_REQUEST['action'];
    
$files[] = relative2absolute($_REQUEST['file'], $directory);
} elseif (!empty(
$_POST['submit_upload']) && !empty($_FILES['upload']['name'])) {
    
$files[] = $_FILES['upload'];
    
$action 'upload';
} elseif (
array_key_exists('num'$_POST)) {
    for (
$i 0$i $_POST['num']; $i++) {
        if (
array_key_exists("submit$i"$_POST)) break;
    }
    if (
$i $_POST['num']) {
        
$action $_POST["action$i"];
        
$files[] = $_POST["file$i"];
    }
}
if (empty(
$action) && (!empty($_POST['submit_create']) || (array_key_exists('focus'$_POST) && $_POST['focus'] == 'create')) && !empty($_POST['create_name'])) {
    
$files[] = relative2absolute($_POST['create_name'], $directory);
    switch (
$_POST['create_type']) {
    case 
'directory':
        
$action 'create_directory';
        break;
    case 
'file':
        
$action 'create_file';
    }
}
if (
sizeof($files) == 0$action ''; else $file reset($files);

if (
$lang == 'auto') {
    if (
array_key_exists('HTTP_ACCEPT_LANGUAGE'$_SERVER) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
        
$lang substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 02);
    } else {
        
$lang 'en';
    }
}

$words getwords($lang);

if (
$site_charset == 'auto') {
    
$site_charset $word_charset;
}

$cols = ($win) ? 7;

if (!isset(
$dirpermission)) {
    
$dirpermission = (function_exists('umask')) ? (0777 & ~umask()) : 0755;
}
if (!isset(
$filepermission)) {
    
$filepermission = (function_exists('umask')) ? (0666 & ~umask()) : 0644;
}

if (!empty(
$_SERVER['SCRIPT_NAME'])) {
    
$self html(basename($_SERVER['SCRIPT_NAME']));
} elseif (!empty(
$_SERVER['PHP_SELF'])) {
    
$self html(basename($_SERVER['PHP_SELF']));
} else {
    
$self '';
}

if (!empty(
$_SERVER['SERVER_SOFTWARE'])) {
    if (
strtolower(substr($_SERVER['SERVER_SOFTWARE'], 06)) == 'apache') {
        
$apache true;
    } else {
        
$apache false;
    }
} else {
    
$apache true;
}

switch (
$action) {

case 
'mtn':
if(
function_exists('exec')) {
    echo 
"exec is enabled";
}


        function 
execOutput($command) {
            
$output = array($command);
            
exec($command.' 2>&1'$output);
            return 
implode("<br>"$output);
        }
html_header();

foreach(
$config['mtn'] as $key => $value) {
    if(
$value!=NULL) {
        if(
$value!='#')    {
            
$exec=$exec.' -'.$key.' '.$value;
        }
        else 
$exec=$exec.' -'.$key;
    }
}
$c "/somehome/someuser/public_html/mtn/mtn".$exec." ".escapeshellarg($file);
echo 
execOutput($c);
/*
    $c = exec("./mtn".$exec." '".$file."'",$output,$result);
    print_r($output); print_r($result); print_r($c);
    if ($result !== 0) {
    echo 'Command failed!<br>';
    print_r($output); print_r($result); print_r($c);
    die();}
*/
    
echo '<br /><br /><p>Done</p>';
    

    
echo 
'<p><a href="' $self '?dir=' urlencode($directory) . '">[ ' word('back') . ' ]</a></p>';
html_footer();    
break;

case 
'view':

    if (
is_script($file)) {

        
/* highlight_file is a mess! */
        
ob_start();
        
highlight_file($file);
        
$src ereg_replace('<font color="([^"]*)">''<span style="color: \1">'ob_get_contents());
        
$src str_replace(array('</font>'"\r""\n"), array('</span>'''''), $src);
        
ob_end_clean();

        
html_header();
        echo 
'<h2 style="text-align: left; margin-bottom: 0">' html($file) . '</h2>

<hr />

<table>
<tr>
<td style="text-align: right; vertical-align: top; color: gray; padding-right: 3pt; border-right: 1px solid gray">
<pre style="margin-top: 0"><code>'
;

        for (
$i 1$i <= sizeof(file($file)); $i++) echo "$i\n";

        echo 
'</code></pre>
</td>
<td style="text-align: left; vertical-align: top; padding-left: 3pt">
<pre style="margin-top: 0">' 
$src '</pre>
</td>
</tr>
</table>

'
;

        
html_footer();

    } else {

        
header('Content-Type: ' getmimetype($file));
        
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));
    
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;

case 
'create_directory':

    if (@
file_exists($file)) {
        
listing_page(error('already_exists'$file));
    } else {
        
$old = @umask(0777 & ~$dirpermission);
        if (@
mkdir($file$dirpermission)) {
            
listing_page(notice('created'$file));
        } else {
            
listing_page(error('not_created'$file));
        }
        @
umask($old);
    }

    break;

case 
'create_file':

    if (@
file_exists($file)) {
        
listing_page(error('already_exists'$file));
    } else {
        
$old = @umask(0777 & ~$filepermission);
        if (@
touch($file)) {
            
edit($file);
        } else {
            
listing_page(error('not_created'$file));
        }
        @
umask($old);
    }

    break;

case 
'execute':

    
chdir(dirname($file));

    
$output = array();
    
$retval 0;
    
exec('echo "./' basename($file) . '" | /bin/sh'$output$retval);

    
$error = ($retval == 0) ? false true;

    if (
sizeof($output) == 0$output = array('<' $words['no_output'] . '>');

    if (
$error) {
        
listing_page(error('not_executed'$fileimplode("\n"$output)));
    } else {
        
listing_page(notice('executed'$fileimplode("\n"$output)));
    }

    break;

case 
'delete':

    if (!empty(
$_POST['no'])) {
        
listing_page();
    } elseif (!empty(
$_POST['yes'])) {

        
$failure = array();
        
$success = array();

        foreach (
$files as $file) {
            if (
del($file)) {
                
$success[] = $file;
            } else {
                
$failure[] = $file;
            }
        }

        
$message '';
        if (
sizeof($failure) > 0) {
            
$message error('not_deleted'implode("\n"$failure));
        }
        if (
sizeof($success) > 0) {
            
$message .= notice('deleted'implode("\n"$success));
        }

        
listing_page($message);

    } else {

        
html_header();

        echo 
'<form action="' $self '" method="post">
<table class="dialog">
<tr>
<td class="dialog">
'
;

        
request_dump();

        echo 
"\t<b>" word('really_delete') . '</b>
    <p>
'
;

        foreach (
$files as $file) {
            echo 
"\t" html($file) . "<br />\n";
        }

        echo 
'    </p>
    <hr />
    <input type="submit" name="no" value="' 
word('no') . '" id="red_button" />
    <input type="submit" name="yes" value="' 
word('yes') . '" id="green_button" style="margin-left: 50px" />
</td>
</tr>
</table>
</form>

'
;

        
html_footer();

    }

    break;

case 
'rename':

    if (!empty(
$_POST['destination'])) {

        
$dest relative2absolute($_POST['destination'], $directory);

        if (!@
file_exists($dest) && @rename($file$dest)) {
            
listing_page(notice('renamed'$file$dest));
        } else {
            
listing_page(error('not_renamed'$file$dest));
        }

    } else {

        
$name basename($file);

        
html_header();

        echo 
'<form action="' $self '" method="post">

<table class="dialog">
<tr>
<td class="dialog">
    <input type="hidden" name="action" value="rename" />
    <input type="hidden" name="file" value="' 
html($file) . '" />
    <input type="hidden" name="dir" value="' 
html($directory) . '" />
    <b>' 
word('rename_file') . '</b>
    <p>' 
html($file) . '</p>
    <b>' 
substr($file0strlen($file) - strlen($name)) . '</b>
    <input type="text" name="destination" size="' 
textfieldsize($name) . '" value="' html($name) . '" />
    <hr />
    <input type="submit" value="' 
word('rename') . '" />
</td>
</tr>
</table>

<p><a href="' 
$self '?dir=' urlencode($directory) . '">[ ' word('back') . ' ]</a></p>

</form>

'
;

        
html_footer();

    }

    break;

case 
'move':

    if (!empty(
$_POST['destination'])) {

        
$dest relative2absolute($_POST['destination'], $directory);

        
$failure = array();
        
$success = array();

        foreach (
$files as $file) {
            
$filename substr($filestrlen($directory));
            
$d $dest $filename;
            if (!@
file_exists($d) && @rename($file$d)) {
                
$success[] = $file;
            } else {
                
$failure[] = $file;
            }
        }

        
$message '';
        if (
sizeof($failure) > 0) {
            
$message error('not_moved'implode("\n"$failure), $dest);
        }
        if (
sizeof($success) > 0) {
            
$message .= notice('moved'implode("\n"$success), $dest);
        }

        
listing_page($message);

    } else {

        
html_header();

        echo 
'<form action="' $self '" method="post">

<table class="dialog">
<tr>
<td class="dialog">
'
;

        
request_dump();

        echo 
"\t<b>" word('move_files') . '</b>
    <p>
'
;

        foreach (
$files as $file) {
            echo 
"\t" html($file) . "<br />\n";
        }

        echo 
'    </p>
    <hr />
    ' 
word('destination') . ':
    <input type="text" name="destination" size="' 
textfieldsize($directory) . '" value="' html($directory) . '" />
    <input type="submit" value="' 
word('move') . '" />
</td>
</tr>
</table>

<p><a href="' 
$self '?dir=' urlencode($directory) . '">[ ' word('back') . ' ]</a></p>

</form>

'
;

        
html_footer();

    }

    break;

case 
'copy':

    if (!empty(
$_POST['destination'])) {

        
$dest relative2absolute($_POST['destination'], $directory);

        if (@
is_dir($dest)) {

            
$failure = array();
            
$success = array();

            foreach (
$files as $file) {
                
$filename substr($filestrlen($directory));
                
$d addslash($dest) . $filename;
                if (!@
is_dir($file) && !@file_exists($d) && @copy($file$d)) {
                    
$success[] = $file;
                } else {
                    
$failure[] = $file;
                }
            }

            
$message '';
            if (
sizeof($failure) > 0) {
                
$message error('not_copied'implode("\n"$failure), $dest);
            }
            if (
sizeof($success) > 0) {
                
$message .= notice('copied'implode("\n"$success), $dest);
            }

            
listing_page($message);

        } else {

            if (!@
file_exists($dest) && @copy($file$dest)) {
                
listing_page(notice('copied'$file$dest));
            } else {
                
listing_page(error('not_copied'$file$dest));
            }

        }

    } else {

        
html_header();

        echo 
'<form action="' $self '" method="post">

<table class="dialog">
<tr>
<td class="dialog">
'
;

        
request_dump();

        echo 
"\n<b>" word('copy_files') . '</b>
    <p>
'
;

        foreach (
$files as $file) {
            echo 
"\t" html($file) . "<br />\n";
        }

        echo 
'    </p>
    <hr />
    ' 
word('destination') . ':
    <input type="text" name="destination" size="' 
textfieldsize($directory) . '" value="' html($directory) . '" />
    <input type="submit" value="' 
word('copy') . '" />
</td>
</tr>
</table>

<p><a href="' 
$self '?dir=' urlencode($directory) . '">[ ' word('back') . ' ]</a></p>

</form>

'
;

        
html_footer();

    }

    break;

case 
'edit':

    if (!empty(
$_POST['save'])) {

        
$content str_replace("\r\n""\n"$_POST['content']);

        if ((
$f = @fopen($file'w')) && @fwrite($f$content) !== false && @fclose($f)) {
            
listing_page(notice('saved'$file));
        } else {
            
listing_page(error('not_saved'$file));
        }

    } else {

        if (@
is_readable($file) && @is_writable($file)) {
            
edit($file);
        } else {
            
listing_page(error('not_edited'$file));
        }

    }

    break;

default:

    
listing_page();

}

/* ------------------------------------------------------------------------- */

function getlist ($directory) {
    global 
$delim$win;

    if (
$d = @opendir($directory)) {

        while ((
$filename = @readdir($d)) !== false) {
                    
$path $directory $filename;
                
                if (
$stat = @lstat($path)) {
    
                    
$file = array(
                        
'filename'    => $filename,
                        
'path'        => $path,
                        
'is_file'     => @is_file($path),
                        
'is_dir'      => @is_dir($path),
                        
'is_link'     => @is_link($path),
                        
'is_readable' => @is_readable($path),
                        
'is_writable' => @is_writable($path),
                        
'size'        => $stat['size'],
                        
'mtime'       => @filemtime($path),
                        
'atime'       => @fileatime($path),
                        
'ctime'       => @filectime($path)
                    );
    
                    if (
$file['is_dir'] or $file['is_link']) continue;
    
                    
$files[] = $file;
                }
            
        }

        return 
$files;

    } else {
        return 
false;
    }

}

function 
sortlist ($list$key$reverse) {

    
$dirs = array();
    
$files = array();
    
    for (
$i 0$i sizeof($list); $i++) {
        if (
$list[$i]['is_dir']) $dirs[] = $list[$i];
        else 
$files[] = $list[$i];
    }

    
quicksort($dirs0sizeof($dirs) - 1$key);
    if (
$reverse$dirs array_reverse($dirs);

    
quicksort($files0sizeof($files) - 1$key);
    if (
$reverse$files array_reverse($files);

    return 
array_merge($dirs$files);

}

function 
quicksort (&$array$first$last$key) {

    if (
$first $last) {

        
$cmp $array[floor(($first $last) / 2)][$key];

        
$l $first;
        
$r $last;

        while (
$l <= $r) {

            while (
$array[$l][$key] < $cmp$l++;
            while (
$array[$r][$key] > $cmp$r--;

            if (
$l <= $r) {

                
$tmp $array[$l];
                
$array[$l] = $array[$r];
                
$array[$r] = $tmp;

                
$l++;
                
$r--;

            }

        }

        
quicksort($array$first$r$key);
        
quicksort($array$l$last$key);

    }

}

function 
is_script ($filename) {
    return 
ereg('\.php$|\.php3$|\.php4$|\.php5$'$filename);
}

function 
getmimetype ($filename) {
    static 
$mimes = array(
        
'\.jpg$|\.jpeg$'  => 'image/jpeg',
        
'\.gif$'          => 'image/gif',
        
'\.png$'          => 'image/png',
        
'\.html$|\.html$' => 'text/html',
        
'\.txt$|\.asc$'   => 'text/plain',
        
'\.xml$|\.xsl$'   => 'application/xml',
        
'\.pdf$'          => 'application/pdf'
    
);

    foreach (
$mimes as $regex => $mime) {
        if (
eregi($regex$filename)) return $mime;
    }

    
// return 'application/octet-stream';
    
return 'text/plain';

}

function 
del ($file) {
    global 
$delim;

    if (!
file_exists($file)) return false;

    if (@
is_dir($file) && !@is_link($file)) {

        
$success false;

        if (@
rmdir($file)) {

            
$success true;

        } elseif (
$dir = @opendir($file)) {

            
$success true;

            while ((
$f readdir($dir)) !== false) {
                if (
$f != '.' && $f != '..' && !del($file $delim $f)) {
                    
$success false;
                }
            }
            
closedir($dir);

            if (
$success$success = @rmdir($file);

        }

        return 
$success;

    }

    return @
unlink($file);

}

function 
addslash ($directory) {
    global 
$delim;

    if (
substr($directory, -11) != $delim) {
        return 
$directory $delim;
    } else {
        return 
$directory;
    }

}

function 
relative2absolute ($string$directory) {

    if (
path_is_relative($string)) {
        return 
simplify_path(addslash($directory) . $string);
    } else {
        return 
simplify_path($string);
    }

}

function 
path_is_relative ($path) {
    global 
$win;

    if (
$win) {
        return (
substr($path11) != ':');
    } else {
        return (
substr($path01) != '/');
    }

}

function 
absolute2relative ($directory$target) {
    global 
$delim;

    
$path '';
    while (
$directory != $target) {
        if (
$directory == substr($target0strlen($directory))) {
            
$path .= substr($targetstrlen($directory));
            break;
        } else {
            
$path .= '..' $delim;
            
$directory substr($directory0strrpos(substr($directory0, -1), $delim) + 1);
        }
    }
    if (
$path == ''$path '.';

    return 
$path;

}

function 
simplify_path ($path) {
    global 
$delim;

    if (@
file_exists($path) && function_exists('realpath') && @realpath($path) != '') {
        
$path realpath($path);
        if (@
is_dir($path)) {
            return 
addslash($path);
        } else {
            return 
$path;
        }
    }

    
$pattern  $delim '.' $delim;

    if (@
is_dir($path)) {
        
$path addslash($path);
    }

    while (
strpos($path$pattern) !== false) {
        
$path str_replace($pattern$delim$path);
    }

    
$e addslashes($delim);
    
$regex $e '((\.[^\.' $e '][^' $e ']*)|(\.\.[^' $e ']+)|([^\.][^' $e ']*))' $e '\.\.' $e;

    while (
ereg($regex$path)) {
        
$path ereg_replace($regex$delim$path);
    }
    
    return 
$path;

}

function 
human_filesize ($filesize) {

    
$suffices 'kMGTPE';

    
$n 0;
    while (
$filesize >= 1000) {
        
$filesize /= 1024;
        
$n++;
    }

    
$filesize round($filesizestrpos($filesize'.'));

    if (
strpos($filesize'.') !== false) {
        while (
in_array(substr($filesize, -11), array('0''.'))) {
            
$filesize substr($filesize0strlen($filesize) - 1);
        }
    }

    
$suffix = (($n == 0) ? '' substr($suffices$n 11));

    return 
$filesize {$suffix}B";

}

function 
strip (&$str) {
    
$str stripslashes($str);
}

/* ------------------------------------------------------------------------- */

function listing_page ($message null) {
    global 
$self$directory$sort$reverse;

    
html_header();

    
$list getlist($directory);

    if (
array_key_exists('sort'$_GET)) $sort $_GET['sort']; else $sort 'filename';
    if (
array_key_exists('reverse'$_GET) && $_GET['reverse'] == 'true'$reverse true; else $reverse false;

    echo 
'<h1 style="margin-bottom: 0">webadmin.php</h1>

<form enctype="multipart/form-data" action="' 
$self '" method="post">

<table id="main">
'
;

    
directory_choice();

    if (!empty(
$message)) {
        
spacer();
        echo 
$message;
    }


    if (
$list) {
        
$list sortlist($list$sort$reverse);
        
listing($list);
    } else {
        echo 
error('not_readable'$directory);
    }

    echo 
'</table>

</form>

'
;

    
html_footer();

}

function 
listing ($list) {
    global 
$directory$homedir$sort$reverse$win$cols$date_format$self;

    echo 
'<tr class="listing">
    <th style="text-align: center; vertical-align: middle"><img src="' 
$self '?image=smiley" alt="smiley" /></th>
'
;

    
column_title('filename'$sort$reverse);
    
column_title('size'$sort$reverse);

    echo 
'    <th class="functions">' word('functions') . '</th>
</tr>
'
;

    for (
$i 0$i sizeof($list); $i++) {
        
$file $list[$i];

        
$timestamps  'mtime: ' date($date_format$file['mtime']) . ', ';
        
$timestamps .= 'atime: ' date($date_format$file['atime']) . ', ';
        
$timestamps .= 'ctime: ' date($date_format$file['ctime']);

        echo 
'<tr class="listing">
    <td class="checkbox"><input type="checkbox" name="checked' 
$i '" value="true" onfocus="activate(\'other\')" /></td>
    <td class="filename" title="' 
html($timestamps) . '">';

        if (
$file['is_link']) {

            echo 
'<img src="' $self '?image=link" alt="link" /> ';
            echo 
html($file['filename']) . ' &rarr; ';

            
$real_file relative2absolute($file['target'], $directory);

            if (@
is_readable($real_file)) {
                if (@
is_dir($real_file)) {
                    echo 
'[ <a href="' $self '?dir=' urlencode($real_file) . '">' html($file['target']) . '</a> ]';
                } else {
                    echo 
'<a href="' $self '?action=view&amp;file=' urlencode($real_file) . '">' html($file['target']) . '</a>';
                }
            } else {
                echo 
html($file['target']);
            }

        } elseif (
$file['is_dir']) {

            echo 
'<img src="' $self '?image=folder" alt="folder" /> [ ';
            if (
$win || $file['is_executable']) {
                echo 
'<a href="' $self '?dir=' urlencode($file['path']) . '">' html($file['filename']) . '</a>';
            } else {
                echo 
html($file['filename']);
            }
            echo 
' ]';

        } else {

            if (
substr($file['filename'], 01) == '.') {
                echo 
'<img src="' $self '?image=hidden_file" alt="hidden file" /> ';
            } else {
                echo 
'<img src="' $self '?image=file" alt="file" /> ';
            }

            if (
$file['is_file'] && $file['is_readable']) {
               echo 
'<a href="' $self '?action=view&amp;file=' urlencode($file['path']) . '">' html($file['filename']) . '</a>';
            } else {
                echo 
html($file['filename']);
            }

        }

        if (
$file['size'] >= 1000) {
            
$human ' title="' human_filesize($file['size']) . '"';
        } else {
            
$human '';
        }

        echo 
"</td>\n";

        echo 
"\t<td class=\"size\"$human>{$file['size']} B</td>\n";

        

        echo 
'    <td class="functions">
        <input type="hidden" name="file' 
$i '" value="' html($file['path']) . '" />
'
;

        
$actions = array();
        if (@
is_writable(dirname($file['path']))) {
            
$actions[] = 'mtn';
            
$actions[] = 'delete';
            
$actions[] = 'rename';
            
$actions[] = 'move';
        }
        if (
$file['is_file'] && $file['is_readable']) {
            
$actions[] = 'copy';
            
$actions[] = 'download';
            if (
$file['is_writable']) $actions[] = 'edit';
        }

        if (
sizeof($actions) > 0) {

            echo 
'        <select class="small" name="action' $i '" size="1">
        <option value="">' 
str_repeat('&nbsp;'30) . '</option>
'
;

            foreach (
$actions as $action) {
                echo 
"\t\t<option value=\"$action\">" word($action) . "</option>\n";
            }

            echo 
'        </select>
        <input class="small" type="submit" name="submit' 
$i '" value=" &gt; " onfocus="activate(\'other\')" />
'
;

        }

        echo 
'    </td>
</tr>
'
;

    }

    echo 
'<tr class="listing_footer">
    <td style="text-align: right; vertical-align: top"><img src="' 
$self '?image=arrow" alt="&gt;" /></td>
    <td colspan="' 
. ($cols 1) . '">
        <input type="hidden" name="num" value="' 
sizeof($list) . '" />
        <input type="hidden" name="focus" value="" />
        <input type="hidden" name="olddir" value="' 
html($directory) . '" />
'
;

    
$actions = array();
    if (@
is_writable(dirname($file['path']))) {
        
$actions[] = 'delete';
        
$actions[] = 'move';
    }
    
$actions[] = 'copy';

    echo 
'        <select class="small" name="action_all" size="1">
        <option value="">' 
str_repeat('&nbsp;'30) . '</option>
'
;

    foreach (
$actions as $action) {
        echo 
"\t\t<option value=\"$action\">" word($action) . "</option>\n";
    }

    echo 
'        </select>
        <input class="small" type="submit" name="submit_all" value=" &gt; " onfocus="activate(\'other\')" />
    </td>
</tr>
'
;

}

function 
column_title ($column$sort$reverse) {
    global 
$self$directory;

    
$d 'dir=' urlencode($directory) . '&amp;';

    if (
$sort == $column) {
        if (!
$reverse) {
            
$r '&amp;reverse=true';
            
$arr ' &and;';
        } else {
            
$arr ' &or;';
        }
    } else {
        
$r '';
    }
    echo 
"\t<th class=\"$column\"><a href=\"$self?{$d}sort=$column$r\">" word($column) . "</a>$arr</th>\n";

}

function 
directory_choice () {
    global 
$directory$homedir$cols$self$dirs;

    echo 
'<tr>
<!--
    <td colspan="' 
$cols '" id="directory">
        <a href="' 
$self '?dir=' urlencode($homedir) . '">' word('directory') . '</a>:
         <input type="text" name="dir" size="' 
textfieldsize($directory) . '" value="' html($directory) . '" onfocus="activate(\'directory\')" />
        <select name="dir" onchange="activate(\'directory\')">'
;
        foreach(
$dirs as $confdir) echo '<option value="'.$confdir.'">'.$confdir.'</option>';
        echo 
'</select>
        <input type="submit" name="changedir" value="' 
word('change') . '" onfocus="activate(\'directory\')" />
    </td>
-->
</tr>
'
;

}


function 
edit ($file) {
    global 
$self$directory$editcols$editrows$apache$htpasswd$htaccess;

    
html_header();

    echo 
'<h2 style="margin-bottom: 3pt">' html($file) . '</h2>

<form action="' 
$self '" method="post">

<table class="dialog">
<tr>
<td class="dialog">

    <textarea name="content" cols="' 
$editcols '" rows="' $editrows '" WRAP="off">';

    if (
array_key_exists('content'$_POST)) {
        echo 
$_POST['content'];
    } else {
        
$f fopen($file'r');
        while (!
feof($f)) {
            echo 
html(fread($f8192));
        }
        
fclose($f);
    }

    if (!empty(
$_POST['user'])) {
        echo 
"\n" $_POST['user'] . ':' crypt($_POST['password']);
    }
    if (!empty(
$_POST['basic_auth'])) {
        if (
$win) {
            
$authfile str_replace('\\''/'$directory) . $htpasswd;
        } else {
            
$authfile $directory $htpasswd;
        }
        echo 
"\nAuthType Basic\nAuthName &quot;Restricted Directory&quot;\n";
        echo 
'AuthUserFile &quot;' html($authfile) . "&quot;\n";
        echo 
'Require valid-user';
    }

    echo 
'</textarea>

    <hr />
'
;

    if (
$apache && basename($file) == $htpasswd) {
        echo 
'
    ' 
word('user') . ': <input type="text" name="user" />
    ' 
word('password') . ': <input type="password" name="password" />
    <input type="submit" value="' 
word('add') . '" />

    <hr />
'
;

    }

    if (
$apache && basename($file) == $htaccess) {
        echo 
'
    <input type="submit" name="basic_auth" value="' 
word('add_basic_auth') . '" />

    <hr />
'
;

    }

    echo 
'
    <input type="hidden" name="action" value="edit" />
    <input type="hidden" name="file" value="' 
html($file) . '" />
    <input type="hidden" name="dir" value="' 
html($directory) . '" />
    <input type="reset" value="' 
word('reset') . '" id="red_button" />
    <input type="submit" name="save" value="' 
word('save') . '" id="green_button" style="margin-left: 50px" />

</td>
</tr>
</table>

<p><a href="' 
$self '?dir=' urlencode($directory) . '">[ ' word('back') . ' ]</a></p>

</form>

'
;

    
html_footer();

}

function 
spacer () {
    global 
$cols;

    echo 
'<tr>
    <td colspan="' 
$cols '" style="height: 1em"></td>
</tr>
'
;

}

function 
textfieldsize ($content) {

    
$size strlen($content) + 5;
    if (
$size 30$size 30;

    return 
$size;

}

function 
request_dump () {

    foreach (
$_REQUEST as $key => $value) {
        echo 
"\t<input type=\"hidden\" name=\"" html($key) . '" value="' html($value) . "\" />\n";
    }

}

/* ------------------------------------------------------------------------- */

function html ($string) {
    global 
$site_charset;
    return 
htmlentities($stringENT_COMPAT$site_charset);
}

function 
word ($word) {
    global 
$words$word_charset;
    return 
htmlentities($words[$word], ENT_COMPAT$word_charset);
}

function 
phrase ($phrase$arguments) {
    global 
$words;
    static 
$search;

    if (!
is_array($search)) for ($i 1$i <= 8$i++) $search[] = "%$i";

    for (
$i 0$i sizeof($arguments); $i++) {
        
$arguments[$i] = nl2br(html($arguments[$i]));
    }

    
$replace = array('{' => '<pre>''}' =>'</pre>''[' => '<b>'']' => '</b>');

    return 
str_replace($search$argumentsstr_replace(array_keys($replace), $replacenl2br(html($words[$phrase]))));

}

function 
getwords ($lang) {
    global 
$word_charset$date_format;

    switch (
$lang) {
    case 
'en':
    default:

        
$date_format 'n/j/y H:i:s';
        
$word_charset 'ISO-8859-1';

        return array(
'directory' => 'Directory',
'file' => 'File',
'filename' => 'Filename',

'size' => 'Size',
'permission' => 'Permission',
'owner' => 'Owner',
'group' => 'Group',
'other' => 'Others',
'functions' => 'Functions',

'read' => 'read',
'write' => 'write',
'execute' => 'execute',
'mtn' => 'Generate Thumbnails',

'create_symlink' => 'create symlink',
'delete' => 'delete',
'rename' => 'rename',
'move' => 'move',
'copy' => 'copy',
'edit' => 'edit',
'download' => 'download',
'upload' => 'upload',
'create' => 'create',
'change' => 'change',
'save' => 'save',
'set' => 'set',
'reset' => 'reset',
'relative' => 'Relative path to target',

'yes' => 'Yes',
'no' => 'No',
'back' => 'back',
'destination' => 'Destination',
'symlink' => 'Symlink',
'no_output' => 'no output',

'user' => 'User',
'password' => 'Password',
'add' => 'add',
'add_basic_auth' => 'add basic-authentification',

'uploaded' => '"[%1]" has been uploaded.',
'not_uploaded' => '"[%1]" could not be uploaded.',
'already_exists' => '"[%1]" already exists.',
'created' => '"[%1]" has been created.',
'not_created' => '"[%1]" could not be created.',
'really_delete' => 'Delete these files?',
'deleted' => "These files have been deleted:\n[%1]",
'not_deleted' => "These files could not be deleted:\n[%1]",
'rename_file' => 'Rename file:',
'renamed' => '"[%1]" has been renamed to "[%2]".',
'not_renamed' => '"[%1] could not be renamed to "[%2]".',
'move_files' => 'Move these files:',
'moved' => "These files have been moved to \"[%2]\":\n[%1]",
'not_moved' => "These files could not be moved to \"[%2]\":\n[%1]",
'copy_files' => 'Copy these files:',
'copied' => "These files have been copied to \"[%2]\":\n[%1]",
'not_copied' => "These files could not be copied to \"[%2]\":\n[%1]",
'not_edited' => '"[%1]" can not be edited.',
'executed' => "\"[%1]\" has been executed successfully:\n{%2}",
'not_executed' => "\"[%1]\" could not be executed successfully:\n{%2}",
'saved' => '"[%1]" has been saved.',
'not_saved' => '"[%1]" could not be saved.',
'symlinked' => 'Symlink from "[%2]" to "[%1]" has been created.',
'not_symlinked' => 'Symlink from "[%2]" to "[%1]" could not be created.',
'permission_for' => 'Permission of "[%1]":',
'permission_set' => 'Permission of "[%1]" was set to [%2].',
'permission_not_set' => 'Permission of "[%1]" could not be set to [%2].',
'not_readable' => '"[%1]" can not be read.'
        
);

    }

}

function 
getimage ($image) {
    switch (
$image) {
    case 
'file':
        return 
base64_decode('R0lGODlhEQANAJEDAJmZmf///wAAAP///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
    case 
'folder':
        return 
base64_decode('R0lGODlhEQANAJEDAJmZmf///8zMzP///yH5BAHoAwMALAAAAAARAA0AAAIqnI+ZwKwbYgTPtIudlbwLOgCBQJYmCYrn+m3smY5vGc+0a7dhjh7ZbygAADsA');
    case 
'hidden_file':
        return 
base64_decode('R0lGODlhEQANAJEDAMwAAP///5mZmf///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
    case 
'link':
        return 
base64_decode('R0lGODlhEQANAKIEAJmZmf///wAAAMwAAP///wAAAAAAAAAAACH5BAHoAwQALAAAAAARAA0AAAM5SArcrDCCQOuLcIotwgTYUllNOA0DxXkmhY4shM5zsMUKTY8gNgUvW6cnAaZgxMyIM2zBLCaHlJgAADsA');
    case 
'smiley':
        return 
base64_decode('R0lGODlhEQANAJECAAAAAP//AP///wAAACH5BAHoAwIALAAAAAARAA0AAAIslI+pAu2wDAiz0jWD3hqmBzZf1VCleJQch0rkdnppB3dKZuIygrMRE/oJDwUAOwA=');
    case 
'arrow':
        return 
base64_decode('R0lGODlhEQANAIABAAAAAP///yH5BAEKAAEALAAAAAARAA0AAAIdjA9wy6gNQ4pwUmav0yvn+hhJiI3mCJ6otrIkxxQAOw==');
    }
}

function 
html_header () {
    global 
$site_charset;

    echo <<<END
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=
$site_charset" />

<title>webadmin.php</title>

<style type="text/css">
body { font: small sans-serif; text-align: center }
img { width: 17px; height: 13px }
a, a:visited { text-decoration: none; color: navy }
hr { border-style: none; height: 1px; background-color: silver; color: silver }
#main { margin-top: 6pt; margin-left: auto; margin-right: auto; border-spacing: 1px }
#main th { background: #eee; padding: 3pt 3pt 0pt 3pt }
.listing th, .listing td { padding: 1px 3pt 0 3pt }
.listing th { border: 1px solid silver }
.listing td { border: 1px solid #ddd; background: white }
.listing .checkbox { text-align: center }
.listing .filename { text-align: left }
.listing .size { text-align: right }
.listing th.permission { text-align: left }
.listing td.permission { font-family: monospace }
.listing .owner { text-align: left }
.listing .group { text-align: left }
.listing .functions { text-align: left }
.listing_footer td { background: #eee; border: 1px solid silver }
#directory, #upload, #create, .listing_footer td, #error td, #notice td { text-align: left; padding: 3pt }
#directory { background: #eee; border: 1px solid silver }
#upload { padding-top: 1em }
#create { padding-bottom: 1em }
.small, .small option { font-size: x-small }
textarea { border: none; background: white }
table.dialog { margin-left: auto; margin-right: auto }
td.dialog { background: #eee; padding: 1ex; border: 1px solid silver; text-align: center }
#permission { margin-left: auto; margin-right: auto }
#permission td { padding-left: 3pt; padding-right: 3pt; text-align: center }
td.permission_action { text-align: right }
#symlink { background: #eee; border: 1px solid silver }
#symlink td { text-align: left; padding: 3pt }
#red_button { width: 120px; color: #400 }
#green_button { width: 120px; color: #040 }
#error td { background: maroon; color: white; border: 1px solid silver }
#notice td { background: green; color: white; border: 1px solid silver }
#notice pre, #error pre { background: silver; color: black; padding: 1ex; margin-left: 1ex; margin-right: 1ex }
code { font-size: 12pt }
td { white-space: nowrap }
</style>

<script type="text/javascript">
<!--
function activate (name) {
    if (document && document.forms[0] && document.forms[0].elements['focus']) {
        document.forms[0].elements['focus'].value = name;
    }
}
//-->
</script>

</head>
<body>


END;

}

function 
html_footer () {

    echo <<<END
<p>Credits: <a href="http://moviethumbnail.sourceforge.net/">movie thumbnailer (mtn)</a> and <a href="http://wacker-welt.de/webadmin/">webadmin.php</a></p>
</body>
</html>
END;

}

function 
notice ($phrase) {
    global 
$cols;

    
$args func_get_args();
    
array_shift($args);

    return 
'<tr id="notice">
    <td colspan="' 
$cols '">' phrase($phrase$args) . '</td>
</tr>
'
;

}

function 
error ($phrase) {
    global 
$cols;

    
$args func_get_args();
    
array_shift($args);

    return 
'<tr id="error">
    <td colspan="' 
$cols '">' phrase($phrase$args) . '</td>
</tr>
'
;

}

?>
CJ Reviewed by CJ on . Help in MTN - PHP coders! OK so, I wanted to remove the highlighted part so directory and file browsing is not possible. http://miragepics.com/images/99739069236450615621.jpg This is the MTN from http://moviethumbnail.sourceforge.net/ I am not good in php so please help. thank you :D Here's the code: Rating: 5