* * 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 10 /* ------------------------------------------------------------------------- */ if (array_key_exists('image', $_GET)) { header('Content-Type: image/gif'); die(getimage($_GET['image'])); } /* Your language: * 'en' - English * 'de' - German * 'fr' - French * 'it' - Italian * 'nl' - Dutch * 'se' - Swedish * 'sp' - Spanish * 'dk' - Danish * 'tr' - Turkish * 'cs' - Czech * 'ru' - Russian * 'auto' - autoselect */ $lang = 'auto'; /* 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 */ $homedir = './'; /* 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'; define(WEBADMIN, '1.0'); SDV($WebAdminAction, 'webadmin'); SDV($WebAdminAuthLevel, 'admin'); SDV($WebAdminLanguage, 'auto'); SDV($WebAdminHomeDir, './'); SDVA($HandleActions, array($WebAdminAction => 'HandleWebAdmin')); SDVA($HandleAuth, array($WebAdminAction => $WebAdminAuthLevel)); function HandleWebAdmin($pagename, $auth='read') { global $Action, $TotalCounter, $TotalCounterMaxItems, $TotalCount, $HTMLStylesFmt; global $WebAdminLanguage, $WebAdminHomeDir, $WebAdminAction; global $lang,$homedir,$site_charset,$word_charset,$editcols,$editrows; global $directory,$delim, $win, $self, $sort, $reverse; global $cols, $date_format, $editcols, $editrows; global $htaccess, $htpasswd, $apache, $words; $lang = $WebAdminLanguage; $site_charset = 'auto'; $homedir = $WebAdminHomeDir; $editcols = 80; $editrows = 25; $htaccess = '.htaccess'; $htpasswd = '.htpasswd'; $page = RetrieveAuthPage($pagename, $auth); if (!$page) Abort("?you are not permited to perform this action"); $html = ''; /* ------------------------------------------------------------------------- */ 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); } } $delim = DIRECTORY_SEPARATOR; if (function_exists('php_uname')) { $win = (strtoupper(substr(PHP_OS, 0, 3)) === '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; 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['waaction_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['waaction'])) { $action = $_REQUEST['waaction']; $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["waaction$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'], 0, 2); } else { $lang = 'en'; } } $words = getwords($lang); if ($site_charset == 'auto') { $site_charset = $word_charset; } $cols = ($win) ? 4 : 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 = ''; } $self .= "?action=$WebAdminAction"; if (!empty($_SERVER['SERVER_SOFTWARE'])) { if (strtolower(substr($_SERVER['SERVER_SOFTWARE'], 0, 6)) == 'apache') { $apache = true; } else { $apache = false; } } else { $apache = true; } switch ($action) { case 'view': if (is_script($file)) { /* highlight_file is a mess! */ ob_start(); highlight_file($file); $src = ereg_replace('', '', ob_get_contents()); $src = str_replace(array('', "\r", "\n"), array('', '', ''), $src); ob_end_clean(); //html_header(); $html .= '
|
' . $src . ' |