*
* 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.
*
/* ------------------------------------------------------------------------- */
/* Select your language:
* 'en' - English
* 'de' - German
* 'cz' - Czech
* 'it' - Italian
* 'fr' - French
* 'nl' - Dutch
* 'se' - Swedish
* 'pt-br' - Brasilian Portuguese
*/
$language = 'en';
/* This directory is shown when you start webadmin.php.
* For example: './' would be the current directory.
*/
$homedir = './';
/* This sets the root directory of the treeview.
* Set it to '/' to see the whole filesystem.
*/
$treeroot = '../';
/* When you create a directory, its permission is set to this octal value.
* For example: 0705 would be 'drwx---r-x'.
*/
$dirpermission = 0705;
/* Uncomment the following line to enable this feature (remove #):
* When you create a file, its permission is set to this octal value.
* For example: 0644 would be 'drwxr--r--'.
*/
# $newfilepermission = 0666;
/* Uncomment the following line to enable this feature (remove #):
* When you upload a file, its permission is set to this octal value.
* For example: 0644 would be 'drwxr--r--'.
*/
# $uploadedfilepermission = 0666;
/* The size of the file edit textarea
*/
$editrows = 20;
$editcols = 70;
/* ------------------------------------------------------------------------- */
$self = htmlentities(basename($_SERVER['PHP_SELF']));
$homedir = relpathtoabspath($homedir, getcwd());
$treeroot = relpathtoabspath($treeroot, getcwd());
$words = getwords($language);
/* If PHP added any slashes, strip them */
if (ini_get('magic_quotes_gpc')) {
array_walk($_GET, 'strip');
array_walk($_POST, 'strip');
array_walk($_REQUEST, 'strip');
}
/* Return Images */
if (isset($_GET['imageid'])) {
header('Content-Type: image/gif');
echo(getimage($_GET['imageid']));
exit;
}
/* Initialize session */
ini_set('session.use_cookies', FALSE);
ini_set('session.use_trans_sid', FALSE);
session_name('id');
session_start();
/* Initialize dirlisting output */
$error = $notice = '';
$updatetreeview = FALSE;
/* Handle treeview requests */
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'treeon':
$_SESSION['tree'] = array();
$_SESSION['hassubdirs'][$treeroot] = tree_hassubdirs($treeroot);
tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $treeroot);
frameset();
exit;
case 'treeoff':
$_SESSION['tree'] = NULL;
$_SESSION['hassubdirs'] = NULL;
dirlisting();
exit;
}
}
/* Set current directory */
if (!isset($_SESSION['dir'])) {
$_SESSION['dir'] = $homedir;
$updatetreeview = TRUE;
}
if (!empty($_REQUEST['dir'])) {
$newdir = relpathtoabspath($_REQUEST['dir'], $_SESSION['dir']);
/* If the requested directory is a file, show the file */
if (@is_file($newdir) && @is_readable($newdir)) {
/* if (@is_writable($newdir)) {
$_REQUEST['edit'] = $newdir;
} else */ if (is_script($newdir)) {
$_GET['showh'] = $newdir;
} else {
$_GET['show'] = $newdir;
}
} elseif ($_SESSION['dir'] != $newdir) {
$_SESSION['dir'] = $newdir;
$updatetreeview = TRUE;
}
}
/* Show a file */
if (!empty($_GET['show'])) {
$show = relpathtoabspath($_GET['show'], $_SESSION['dir']);
if (!show($show)) {
$error= buildphrase('"' . htmlentities($show) . '"', $words['cantbeshown']);
} else {
exit;
}
}
/* Show a file syntax highlighted */
if (!empty($_GET['showh'])) {
$showh = relpathtoabspath($_GET['showh'], $_SESSION['dir']);
if (!show_highlight($showh)) {
$error = buildphrase('"' . htmlentities($showh) . '"', $words['cantbeshown']);
} else {
exit;
}
}
/* Upload file */
if (isset($_FILES['upload'])) {
$file = relpathtoabspath($_FILES['upload']['name'], $_SESSION['dir']);
if (@is_writable($_SESSION['dir']) && @move_uploaded_file($_FILES['upload']['tmp_name'], $file) && (!isset($uploadedfilepermission) || chmod($file, $uploadedfilepermission))) {
$notice = buildphrase(array('"' . htmlentities(basename($file)) . '"', '"' . htmlentities($_SESSION['dir']) . '"'), $words['uploaded']);
} else {
$error = buildphrase(array('"' . htmlentities(basename($file)) . '"', '"' . htmlentities($_SESSION['dir']) . '"'), $words['notuploaded']);
}
}
/* Create file */
if (!empty($_GET['create']) && $_GET['type'] == 'file') {
$file = relpathtoabspath($_GET['create'], $_SESSION['dir']);
if (substr($file, strlen($file) - 1, 1) == '/') $file = substr($file, 0, strlen($file) - 1);
if (is_free($file) && touch($file) && ((!isset($newfilepermission)) || chmod($file, $newfilepermission))) {
$notice = buildphrase('"' . htmlentities($file) . '"', $words['created']);
$_REQUEST['edit'] = $file;
} else {
$error = buildphrase('"' . htmlentities($file) . '"', $words['notcreated']);
}
}
/* Create directory */
if (!empty($_GET['create']) && $_GET['type'] == 'dir') {
$file = relpathtoabspath($_GET['create'], $_SESSION['dir']);
if (is_free($file) && @mkdir($file, $dirpermission)) {
$notice = buildphrase('"' . htmlentities($file) . '"', $words['created']);
$updatetreeview = TRUE;
if (!empty($_SESSION['tree'])) {
$file = spath(dirname($file));
$_SESSION['hassubdirs'][$file] = TRUE;
tree_plus($_SESSION['tree'], $_SESSION['hassubdirs'], $file);
}
} else {
$error = buildphrase('"' . htmlentities($file) . '"', $words['notcreated']);
}
}
/* Ask symlink target */
if (!empty($_GET['symlinktarget']) && empty($_GET['symlink'])) {
$symlinktarget = relpathtoabspath($_GET['symlinktarget'], $_SESSION['dir']);
html_header($words['createsymlink']);
?>