tag function webImage($images, $img, $src) { global $webImageTypes, $maxImageWidth, $maxImageHeight, $resizeLarge; $dim = array("width" => $images[$img]["width"], "height" => $images[$img]["height"]); //echo '

'; if ($resizeLarge) { $dim = calcResizedImgSize($images[$img]["width"], $images[$img]["height"], $maxImageWidth, $maxImageHeight); } if ($dim["resized"]) { // let's see if the image is resized echo '

'; } echo '' . "\n"; if ($dim["resized"]) { echo '
'; } $descFile = $images[$img]["name"] . '.if2'; if (file_exists($descFile)) { // add 6 px for border... echo '
'; readfile($descFile); echo '
'; } if ($dim["resized"]) { echo 'This image has been resized to fit your screen. Click on the image to see it in full size.'; // EDIT:: } } // Flash function flashMovie($images, $img, $src) { echo '

You don\'t have the Flash plugin installed. '; } // Text Files $typeText = array( 'txt', 'text', 'bat', 'ini', 'diz', 'nfo', 'me', 'css', 'jss', 'js', 'inc'); function textType($others, $ofile, $src) { // read file into a string $fd = fopen($others[$ofile]["name"], "r"); $contents = fread($fd, filesize($others[$ofile]["name"])); fclose($fd); $contents = str_replace('', '</textarea>', $contents); // adjust height to amount of data echo '
'; } // Web pages $webPages = array('htm', 'html', 'php', 'php3', 'asp', 'shtml', 'cgi', 'pl', 'dll' ,'jsp'); function webPage($src) { global $showTextFiles; if ($showTextFiles) { echo '
'; } } ///////////////////////////////////// Line # 194 /////////////////////////////////// // Media files $typeMedia = array( 'mp3', 'au', 'wma', 'wav', 'midi', 'aiff', 'au', 'mpeg', 'mpg', 'avi', 'wmv', 'asf', 'asx' ); function mediaFile($src) { global $embedMedia; if ($embedMedia) { echo '

'; } } // end file associations // // Functions // /* checks if valid image; refer to http://www.php.net/manual/en/function.getimagesize.php for how it evaluates */ function isImage($filename) { if (!@getimagesize($filename)) { return false; } return true; } // returns image type and size function imageInfo($file) { global $imageTypes; $info = @getimagesize($file); return array( $file, // name $info[0], // width $info[1], // height $imageTypes[$info[2]], // image type ceil(filesize($file)), // size in bytes filemtime($file) // time last modified ); } function getExtension($filename) { if (strstr($filename, '.')) { return substr(strrchr($filename, '.'), 1, strlen($filename)); } else return ''; } function calcResizedImgSize($width, $height, $thumbWidth, $thumbHeight) { $ratioX = $width / $height; $ratioY = $height / $width; //echo $width, $height, $thumbWidth, $thumbHeight; $resized = true; // whether the dimensions have been affected if ($width <= $thumbWidth and $height <= $thumbHeight) { $resized = false; return array("width" => $width, "height" => $height, "resized" => $resized); } if ($ratioX > 1) { $destWidth = $thumbWidth; $destHeight = intval($thumbWidth / $ratioX); } elseif ($ratioY > 1) { $destWidth = intval($thumbHeight / $ratioY); $destHeight = $thumbHeight; } else { if ($thumbWidth = $thumbHeight) { $destWidth = $thumbWidth; $destHeight = $thumbHeight; $resized = false; } if ($thumbWidth > $thumbHeight) { $destWidth = $thumbHeight; $destHeight = $thumbHeight; } else { $destWidth = $thumbWidth; $destHeight = $thumbWidth; } } return array("width" => $destWidth, "height" => $destHeight, "resized" => $resized); } ///////////////////////////////////// Line # 304 /////////////////////////////////// function formatFileSize($size) { // no, you DON'T need it to do gigabytes if ($size > 1048576) { return intval((($size / 1048576) * 100) + 0.5) / 100 . 'Mb'; } elseif ($size > 1024) { return ceil($size / 1024) . 'Kb'; } else { return $size . ' bytes'; } } function formatFileInfo($fType, $width, $height, $type, $size, $time) { global $longInfoFormatting, $shortInfoFormatting, $otherInfoFormatting, $dateFormat, $dateFormat2; $name = $fType . 'InfoFormatting'; // create name of variable... $format = $$name; $output = str_replace('%w', $width, $format); $output = str_replace('%h', $height, $output); $output = str_replace('%t', $type, $output); $output = str_replace('%s', $size, $output); if ($time) { $output = str_replace('%l', date($dateFormat, $time), $output); $output = str_replace('%L', date($dateFormat2, $time), $output); } return $output; } // Cut down string length, adding '...' if necessary function shortenString($string, $maxLength) { $string = trim($string); // strip extension $extended = false; if ($ext = getExtension($string)) { $extended = true; }; //$string = strrev(strchr(strrev($string), '.')), 1, strlen($string)); // strip extension if (strstr($string, '.')) { $string = strrev(substr(strrchr(strrev($string), '.'), 1, strlen($string))); } if (strlen($string) > $maxLength) { $newString = substr($string, 0, $maxLength); if (strstr($newString, ' ')) { $newString = substr($newString, 0, strrpos($newString, ' ')); } $tail = substr($newString, strlen($newString) - 3, 3); if (substr($tail, 1, 2) == '..') { $newString .= '.'; } elseif ($tail[2] == '.') { $newString .= '..'; } elseif (!strstr($tail, '.')) { $newString .= '...'; } $tempRev = strrev($newString); return $newString . ($tempRev[0] == '.' ? $ext : ".$ext" ); // prevent "file....ext" } else { return $string . ($extended ? ".$ext" : $ext); } } // end shortenString function space220($string) { if (strstr($string, ' ')) { return str_replace(' ', '%20', $string); } else return $string; } ///////////////////////////////////// Line # 407 /////////////////////////////////// function back2forwardSlash($string) { if (strstr($string, '/')) { return str_replace('\\', '/', $string); } } function cmpByName($a, $b) { return strcasecmp($a["name"], $b["name"]); } function genPrevNext($list, $current) { // forward to current member reset($list); $prevI = false; $nextI = false; $prevK = ''; $nextK = ''; while (key($list) != $current) { next($list); } // roundabout, but only effective way if (prev($list)) { $prevI = true; $prevK = key($list); next($list); } reset($list); while (key($list) != $current) { next($list); } if (next($list)) { $nextI = true; $nextK = key($list); } return array( "prevI" => $prevI, "nextI" => $nextI, "prevK" => $prevK, "nextK" => $nextK, ); } // // Setup, Initialize // $IE = strstr($_SERVER['HTTP_USER_AGENT'], 'IE') ? true : false; $imageTypes = array( // You probably WON'T have to change these - they are dictated by PHP 1 => 'GIF', 2 => 'JPG', 3 => 'PNG', 4 => 'SWF', 5 => 'PSD', 6 => 'BMP', 7 => 'TIFF', 8 => 'TIFF', 9 => 'JPC', 10 => 'JP2', 11 => 'JPX' ); $webImageTypes = array('GIF', 'JPG', 'PNG'); // those that a browser would show via if ($IE) { $webImageTypes[] = 'BMP'; } // Dir stuff $initialDir = getcwd(); // save this, we might need it $dir = $_GET["dir"]; if (!$dir) { $dir = '.'; // current } $displayDir = ($dir == '.') ? ('') : (urlencode($dir)); // urlencoded dir ///////////////////////////////////// Line # 500 /////////////////////////////////// $scriptFile = basename($_SERVER['PHP_SELF']); // e.g. isaac.php $scriptDir = back2forwardSlash(realpath(dirname($_SERVER['SCRIPT_FILENAME']))); // e.g. c:\dir $scriptDirRel = substr($scriptDir, strlen($_SERVER['DOCUMENT_ROOT']), strlen($scriptDir)); if (strlen(realpath($dir)) < strlen(realpath($scriptDir))) { die('Unauthorized access'); } // Arguments if (!is_dir($dir)) { echo $dir . '

'; die('Not a valid directory. Please don\'t attempt to edit the querystring manually.'); } $scriptDirRelTEMP = ($scriptDirRel) ? ('/' . $scriptDirRel) : ('/'); // check for slashes $dirAddedTEMP = ($dir != '.') ? ($dir . '/') : (''); $scriptURI = $URI . $scriptFile; $workURI = $URI . ($dir != '.' ? $dir . '/': ''); $img = $_GET["img"]; $ofile = $_GET["ofile"]; if ($ofile and $img) { die('Invalid querystring. Please don\'t attempt to edit the querystring manually.'); } /* Config.if2 outside configuration file If there is a file called config.if2 in any dir accessible by Isaac, php in that file will be used instead of the variables specified above. Please refer to the website, http://www.tosviol.net/isaac/ for more information on this. */ if (file_exists("$dir/config.if2")) { include("$dir/config.if2"); } // end config.if2 // Read dir $dirHandle = opendir($dir); // Loop over dir and assign to array $dirs = array(); $images = array(); $others = array(); // non-image files $i = 0; chdir($dir); while (false !== ($file = readdir($dirHandle))) { $i++; if (isImage($file) and !is_dir($file)) { // if is image list( $images[$i]["name"], $images[$i]["width"], $images[$i]["height"], $images[$i]["type"], $images[$i]["size"], $images[$i]["time"] ) = imageInfo($file); //echo $images[$i]["name"] . '
'; } // end if image elseif ($file != '.' and $file != '..' and is_dir($file)) { // if is dir $dirs[$i]["name"] = $file; } // end if is dir elseif ($file != '.' and $file != '..' and $file != $scriptFile and !in_array(getExtension($file), $hiddenFiles)) { // if is other file and not hidden $ext = getExtension($file); list( $others[$i]["name"], $others[$i]["size"], $others[$i]["type"], $others[$i]["time"] ) = array($file, filesize($file), $ext, filemtime($file)); } // end if is other file } // end loop over dir // Sort all by name ///////////////////////////////////// Line # 600 /////////////////////////////////// if (count($dirs)) { usort($dirs, 'cmpByName'); } if (count($images)) { usort($images, 'cmpByName'); } if (count($others)) { usort($others, 'cmpByName'); } // // Output // // // HTML headers // ?> mirooki.net | stuff '; } elseif (file_exists("$initialDir/isaac.css")) { // is there a global external css file? echo ''; } else { // no external css? default to in-file css. ?> '; // dir description from .if2 if (file_exists('this.if2')) { echo ''; } echo '
mirookibrowser « ' . $backToText . '     ' : ''); // Top of page echo '' . $scriptURI . ''; if ($IE) { echo ' « copy to clipboard '; // EDIT :: // VERY dirty; put url in textarea for copying. No other way though echo '
'; } ///////////////////////////////////// Line # 807 /////////////////////////////////// echo '
'; if ($dir != '.') { echo "/$dir "; } readfile('this.if2'); echo '

'; // important line - this div contains the rest of the page // find first image in array - not current, but works reset($images); $firstImageSet = key($images); //echo $firstImageSet; if (($firstImageSet or $firstImageSet == '0') and !$img and $img != '0' and !$ofile and $ofile != '0' and $autoLoadFirstImage) { $img = $firstImageSet; } reset($images); // // Selected, current image // $empty = false; if (!count($images)) { // if empty array, i.e. no image files in folder echo '
'; // important line - this div contains the rest of the page echo "
No images in this directory.
\n"; // EDIT:: $empty = true; } if (!$autoLoadFirstImage and ((!$img and $img != '0') and (!$ofile and $ofile != '0'))) { echo 'Please select an image or a file.'; } elseif ($img or $img == '0') { // if we have something to show $src = $workURI . space220($images[$img]["name"]); //echo $src; echo '' . $images[$img]["name"] . "\n \n" . // EDIT:: formatFileInfo('long', $images[$img]["width"], $images[$img]["height"], $images[$img]["type"], formatFileSize($images[$img]["size"]), $images[$img]["time"]) . "
\n"; // forward to current image $prevNext = genPrevNext($images, $img); $prevI = $prevNext["prevI"]; $nextI = $prevNext["nextI"]; $prevK = $prevNext["prevK"]; $nextK = $prevNext["nextK"]; // previous link if ($prevI) { echo ''; } // divider between the two if ($prevI and $nextI) { echo '
'; } // next link if ($nextI) { echo ' '; } ///////////////////////////////////// Line # 901 /////////////////////////////////// // // Finally show the image/file // echo '
'; // web images if (in_array($images[$img]["type"], $webImageTypes)) { webImage($images, $img, $src); } // flash elseif (strtoupper($images[$img]["type"]) == "SWF") { flashMovie($images, $img, $src); } // non-web images else { echo '


Images of type "' . $images[$img]["type"] . '" may depend on plug-ins and may not display properly in your browser.

'; // EDIT:: echo 'Right-click and Save-as to download the file'; } // file description from .if2 - for IMAGES ONLY } elseif ($ofile or $ofile == '0') { $src = $workURI . space220($others[$ofile]["name"]); echo '' . $others[$ofile]["name"] . "\n \n" . // info formatFileInfo('other', '', '', '', formatFileSize($others[$ofile]["size"]), $others[$ofile]["time"]). "
\n"; // forward to current ofile $prevNext = genPrevNext($others, $ofile); $prevI = $prevNext["prevI"]; $nextI = $prevNext["nextI"]; $prevK = $prevNext["prevK"]; $nextK = $prevNext["nextK"]; // previous link if ($prevI) { echo '

'; } // divider between the two if ($prevI and $nextI) { echo '
'; } // next link if ($nextI) { echo ' '; } echo '
'; // // File associations // // web pages if (in_array($others[$ofile]["type"], $webPages)) { webPage($src); } elseif (in_array($others[$ofile]["type"], $typeMedia)) { // media files mediaFile($src); } else { if ($showTextFiles and in_array($others[$ofile]["type"], $typeText)) { textType($others, $ofile, $src); } } ///////////////////////////////////// Line # 1000 /////////////////////////////////// echo '
Right-click and Save-as to download the file
'; } else{ echo '
'; } // below selected file if (!$empty) { echo '

' . $src . "\n"; } if ($IE and count($images) and ($img or $img == '0' or $ofile or $ofile == '0')) { echo ' « copy to clipboard

'; // EDIT:: // VERY dirty; put src in textarea for copying. No other way though echo '

'; } echo '


'; // // Echo dirs // // Count dirs $numDirs = count($dirs); $dirsPerColumn = ceil($numDirs / $numColumns); if ($dirsPerColumn < $minFilesToBreak) { $dirsPerColumn = $minFilesToBreak; } echo 'Current directory: ' . $workURI . '
'; // parent dir link if ($dir != '.') { echo '
[back to root]
'; if (dirname($dir) != '.') { echo '[back to parent]' . "
\n"; } } echo '
'; $countDirs = 0; foreach ($dirs as $dirx) { $countDirs++; $safeListDir = urlencode(substr($dirx["name"], 0, strlen($dirx["name"]))); // safe to put in url if ($dir != '.') { $safeListDir = "$dir/$safeListDir"; } $strTitle = (strlen($dirx["name"]) > $maxThumbTitleLen) ? ('title="' . $dirx["name"] . '"') : (''); echo '
/' . shortenString($dirx["name"], $maxThumbTitleLen) . '' . " \n\n"; if ($countDirs % $dirsPerColumn == 0) { echo '
'; } } echo '
'; // // Echo images // // Count images $numImages = count($images); $imagesPerColumn = ceil($numImages / $numColumns); if ($imagesPerColumn < $minFilesToBreak) { $imagesPerColumn = $minFilesToBreak; } ///////////////////////////////////// Line # 1100 /////////////////////////////////// reset($images); if ($numImages != 0) { // if we have anything to show echo '


Images in ' . $workURI . '

'; $countImages = 0; foreach ($images as $image) { //while (list($qKey, $image) = each($images)) { $orderImage = each($images); $countImages++; //echo $orderImage[key]; if ($orderImage["key"] == $img and ($img != '' or $img == '0')) { // we have to differentiate between 0 and '0' echo '' . shortenString($image["name"], $maxThumbTitleLen) . "
\n\n"; } else { $strTitle = (strlen($image["name"]) > $maxThumbTitleLen) ? ('title="' . $image["name"] . '"') : (''); echo // link '' . // name shortenString($image["name"], $maxThumbTitleLen) . ''; // info echo ' ' . formatFileInfo('short', $image["width"], $image["height"], $image["type"], formatFileSize($image["size"]), $image["time"]) . ' '; // warn about unembeddable filetype if (!in_array($image["type"], $webImageTypes)) { echo '? '; } // warn about large file if (ceil($image["size"] / 1024) > $warnOnLargeFiles) { echo '!'; } echo "
\n"; //echo $imagesPerColumn . ' ' . $numImages . ' ' . $countImages . ' ' . $minFilesToBreak . ' ' . ($numImages - $countImages) . ' ' . ($countImages % $imagesPerColumn) . ' * '; } // end if not current image if ($countImages % $imagesPerColumn == 0) { echo '
'; } } // end foreach images echo '
'; } // end if numImages // Other files // Count others and figure out column spread $numOthers = count($others); $othersPerColumn = ceil($numOthers / $numColumns); if ($othersPerColumn < $minFilesToBreak) { $othersPerColumn = $minFilesToBreak; } if (count($others) and $showOtherFiles) { echo '


Other files in ' . $URI . ''; echo '

'; foreach ($others as $other) { $orderOther = each($others); $countOthers++; if ($orderOther[key] == $ofile and $ofile != '') { echo '' . shortenString($other["name"], $maxThumbTitleLen) . "
\n\n"; } else { $strTitle = (strlen($other["name"]) > $maxThumbTitleLen) ? ('title="' . $other["name"] . '"') : (''); echo ///////////////////////////////////// Line # 1201 /////////////////////////////////// // link '' . // name shortenString($other["name"], $maxThumbTitleLen) . ''; // info echo ($showInfo) ? (' ' . formatFileInfo('short', '', '', '', formatFileSize($other["size"]), $other["time"]) . "\n") : ("\n"); // formatFileSize($other["size"]) if (ceil($other["size"] / 1024) > $warnOnLargeFiles) { echo '!'; } echo "
\n"; } if ($countOthers % $othersPerColumn == 0) { echo '
'; } } } echo '
'; ?>

Isaac Browser v2.0, freeware © 2002-2003 Neven Mrgan (this has been modified from the original)