// blorpscript v1.7.10 // last modified 2/10/01 // copyright (c) 2000-2001 justin frankel // source distributed under the gnu general public license. // let me know if you find any security holes (I think I got most of them) // (justin@blorp.com) $blorp_version="1.7.10"; // load configuration $my_convert_path=""; // keep people from specifying convert on the command line // in case .blorpconfig.php forgets to clear it. include '.blorpconfig.php'; // begin functions function do_comments($name) { global $path, $img, $text, $addcomment, $REMOTE_ADDR, $comments_logall; if ($path=="") $commentdir = ".comments"; else $commentdir = ".comments/" . $path; if (!file_exists($commentdir)) { $oldumask = umask(0); mkdir($commentdir,0777); umask($oldumask); } echo "
"; } function display_current_path($thispath,$linkcurrent) { global $sitename; if ($thispath=="") { if (!$linkcurrent) echo "$sitename/"; else echo "$sitename/"; } else { $pd_arr=explode("/","$sitename/" . $thispath); $parent=""; if ($linkcurrent) $end=0; else $end=1; for($g=sizeof($pd_arr)-1;$g>=$end;$g--) { $pd=""; for($i=1;$i"; list ($thisw, $thish) =explode("x",$width); echo ""; echo ""; echo " | |||||||||||||||||||||||||||||||||||
"; if (!eregi("\.(java|asm|inc|c|cpp|h|phps|php-source)$",$text)) $fnt=substr($text,0,strlen($text)-strlen(strrchr($text,"."))); else $fnt=$text; echo " $fnt "; if ($path!="") $pathstr=str_replace("%2F","/",rawurlencode($path)) . "/"; else $pathstr=""; echo " "; if ($path == "") $openfile = $text; else $openfile = $path . "/" . $text; $fp=fopen($openfile,"r"); if ($fp) { if (eregi("\.(java|asm|inc|c|cpp|phps|h|php-source)$",$text)) { while ($line = fgets($fp,1024)) { $line = str_replace('&','&',$line); $line = str_replace('<','<',$line); $line = str_replace('>','>',$line); $line = str_replace("\t",' ',$line); echo $line; } } else { while ($line = fgets($fp,1024)) { echo $line; } } fclose($fp); echo " | |||||||||||||||||||||||||||||||||||
"); } $t=(int)0; while ($fnt = readdir($dp)) { $full_fn=$wd."/".$fnt; if (!is_dir($full_fn) && eregi("\.(jpg|jpeg|gif|png)$",$fnt)) { if(substr($fnt,0,1) != ".") { $t++; $fnlist[$fnt]=""; } } } if (!isset($fnlist)) { die("Error in URL (no images found) (" . $openpath . "). Click here. "); } closedir($dp); ksort($fnlist); reset($fnlist); $lastfn=""; $n=(int)0; $fixedimg=str_replace("\\'","'",$img); $fixedimg=str_replace('\"','"',$fixedimg); while ($fntmp = key($fnlist)) { next($fnlist); $n++; if ($fntmp == $fixedimg) { break; } $lastfn=$fntmp; } if (!$fntmp) { die("Error in URL (image not found) (" . $openpath . "). Click here. "); } $nextfn=key($fnlist); display_current_path($path,1); echo " "; $nameposstr=""; if (strlen($lastfn) > 0) // print previous img { $lastfn=rawurlencode($lastfn); $nameposstr .= "$previmagestr "; } if ($path == "") $txtfile=".$img" . ".txt"; else $txtfile="$path/.$img" . ".txt"; if (!strstr($txtfile,"..") && file_exists($txtfile) && $file=fopen($txtfile,"r")) { $line = fgets($file,4096); $nameposstr .= chop($line); } else { $file=0; $nameposstr .= substr($fixedimg,0,strlen($fixedimg)-strlen(strrchr($fixedimg,"."))); } $nameposstr .= " ($n/$t)"; if (strlen($nextfn)>0) // next image { $nextfn=rawurlencode($nextfn); $nameposstr .= " $nextimagestr"; } echo "$nameposstr "; if ($file != 0) { $line = fgets($file,4096); if ($line) { echo ""; do { echo "$line "; } while ($line = fgets($file,4096)); echo ""; } fclose($file); } $newpath = str_replace("%2F","/",rawurlencode($path)); if ($newpath != "") $newpath .= "/"; $wstr=""; if ($width != "") { $tmp=GetImageSize($path . "/" . $fixedimg); $tmp2=explode("x",$width); if ($tmp2[1]!=0 && $tmp2[1]!="") { $outw=0; if ($tmp[0] >= $tmp2[0]) { $outw=$tmp2[0]; $outh=$tmp2[0]*$tmp[1]/$tmp[0]; } else $outh=$tmp[1]; if ($outh > $tmp2[1]) { $outh=$tmp2[1]; $outw=$tmp2[1]*$tmp[0]/$tmp[1]; } if ($outw != 0) $wstr="WIDTH=$outw HEIGHT=$outh"; } else // rescale by width only { if ($tmp[0] >= $width) { $outw=$width; $outh=$width*$tmp[1]/$tmp[0]; $wstr="WIDTH=$outw HEIGHT=$outh"; } } } $fixedimg=rawurlencode($fixedimg); echo " $nameposstr "; if ($comments_enabled) { do_comments($img); } echo " | |||||||||||||||||||||||||||||||||||
"; // read directory $openpath = ($path=="") ? "." : $path; if (!is_dir($openpath) || !($dp=opendir($openpath))) { if (!$dp=opendir(".")) die("Error in URL (" . $path . "). Click here. | ";
while ($fn = key($fnlist))
{
next($fnlist);
if ($path == "") $full_fn="./".$fn;
else $full_fn=$path."/".$fn;
if (is_dir($full_fn))
{
// check for thumbnail
if ($path == "") $pfn=$fn . "/.dir.jpg";
else $pfn=$path."/".$fn . "/.dir.jpg";
$newfn=rawurlencode($fn);
if ($tablestat==2) { echo "|||||||||||||||||||||||||||||||||||
"
."";
if (file_exists($pfn))
{
$pfn=str_replace("%2F","/",rawurlencode($pfn));
echo " $fn/"; } else echo "$fn/"; echo " | ";
$tablestat=$tablestat+1;
}
}
if ($tablestat==1) { echo ""; } echo " | ||||||||||||||||||||||||||||||||||
".
"";
$thumbnailfile = $thumbnaildir . "/" . $fn;
if ($path=="") $createfn=$fn;
else $createfn=$path . "/" . $fn;
$sizestr="";
if ($path == "") $txtfile=".$fn" . ".txt";
else $txtfile="$path/.$fn" . ".txt";
if (!strstr($txtfile,"..") && file_exists($txtfile) && $file=fopen($txtfile,"r"))
{
$line = fgets($file,4096);
if ($line) $stfn=chop($line);
fclose($file);
}
if ($thumbnails != "none")
{
$dothumbnail=1;
if (!file_exists($thumbnailfile))
{
if ($thumbnails == "gd")
{
if (eregi("\.gif$",$fn))
{
$thumbnailfile=$createfn;
$tmp=GetImageSize($createfn);
$newh=$thumbnailheight;
$neww=$newh/$tmp[1] * $tmp[0];
if ($neww > $tmp[0])
{
$neww=$tmp[0];
$newh=$tmp[1];
}
if ($neww > $maxthumbnailwidth)
{
$neww=$maxthumbnailwidth;
$newh=$neww/$tmp[0] * $tmp[1];
}
$sizestr="WIDTH=$neww HEIGHT=$newh";
}
else
{
if (eregi("\.(jpg|jpeg)$",$fn))
$im = imagecreatefromjpeg($createfn);
else if (eregi("\.png$",$fn))
$im = imagecreatefrompng($createfn);
if ($im != "")
{
$newh=$thumbnailheight;
$neww=$newh/imagesy($im) * imagesx($im);
if ($neww > imagesx($im))
{
$neww=imagesx($im);
$newh=imagesy($im);
}
if ($neww > $maxthumbnailwidth)
{
$neww=$maxthumbnailwidth;
$newh=$neww/imagesx($im) * imagesy($im);
}
$im2=ImageCreate($neww,$newh);
ImageCopyResized($im2,$im,0,0,0,0,$neww,$newh,
imagesx($im),imagesy($im));
if (eregi("\.(jpg|jpeg)$",$fn))
imagejpeg($im2,$thumbnailfile,50);
else if (eregi("\.png$",$fn))
imagepng($im2,$thumbnailfile);
ImageDestroy($im);
ImageDestroy($im2);
}
}
}
else if ($thumbnails == "convert") // imagemagick thumbnails
{
$tmp=GetImageSize($createfn);
$newh=$thumbnailheight;
$neww=$newh/$tmp[1] * $tmp[0];
if ($neww > $tmp[0])
{
$neww=$tmp[0];
$newh=$tmp[1];
}
if ($neww > $maxthumbnailwidth)
{
$neww=$maxthumbnailwidth;
$newh=$neww/$tmp[0] * $tmp[1];
}
@exec($my_convert_path . ' -geometry ' . $neww . "x" .
$newh . ' -quality 50 "' . $createfn . '" "' .
$thumbnailfile . '"');
}
else $dothumbnail=0;
}
} // $thumbnails != "none"
else $dothumbnail=0;
if ($dothumbnail)
{
if ($path=="") $wdtmp="";
else $wdtmp=str_replace("%2F","/",rawurlencode($path . "/"));
if ($sizestr=="")
echo " $stfn"; else echo " $stfn"; } else echo "$stfn"; echo " | ";
}
}
if ($tablestat != 0)
{
if ($tablestat == 1) echo ""; if ($tablestat == 1 || $tablestat == 2) echo " | "; echo " | |||||||||||||||||||||||||||||||||
"; } echo "AUDIO: $fn ($fs"."k)\n"; } } // movie listing reset($fnlist); while ($fn = key($fnlist)) { next($fnlist); if ($path=="") $full_fn=$fn; else $full_fn=$path."/".$fn; $fs=floor(filesize($full_fn)/1000); if (!is_dir($full_fn) && eregi("\.(avi|mov|mpg|mpeg)$",$fn)) { $fnu=rawurlencode($fn); if ($tablestat == 0) { $tablestat=1; echo " |