Comments:
"; $cfn=$commentdir . "/" . $name . ".txt"; $setperms=file_exists($cfn); $commentfp=@fopen($cfn,$addcomment == "" ? "r":"a+"); if ($commentfp) { fseek($commentfp,0); if (flock($commentfp,1)) { $rhostcnt=0; $addcomment=substr($addcomment,0,400); while ($line = fgets($commentfp,1024)) { $line = str_replace('&','&',$line); $line = str_replace('<','<',$line); $line = str_replace('>','>',$line); list ($rhost, $datestr, $ctext) = split(' ',trim($line),3); if ($REMOTE_ADDR == $rhost) $rhostcnt=$rhostcnt+1; else $rhostcnt=0; if ($REMOTE_ADDR == $rhost && $ctext == $addcomment) $addcomment=""; $rhost=split('\.',$rhost,4); $ctext=str_replace("\\'","'",$ctext); $ctext=str_replace('\"','"',$ctext); echo "$ctext (" . $rhost[0] . "." . $rhost[1] . "." . $rhost[2] . ".x $datestr)
"; } if ($rhostcnt < 3 && $addcomment != "") { $datestr=date("Md/y/H:i"); $addcomment=str_replace("\\'","'",$addcomment); $addcomment=str_replace('\"','"',$addcomment); $addcomment=str_replace('&','&',$addcomment); $addcomment=str_replace('<','<',$addcomment); $addcomment=str_replace('>','>',$addcomment); if (flock($commentfp,2)) { fseek($commentfp,0,SEEK_END); fwrite($commentfp,"$REMOTE_ADDR $datestr $addcomment\n"); $rhost=split('\.',$REMOTE_ADDR,4); echo "added comment: $addcomment (" . $rhost[0] . "." . $rhost[1] . "." . $rhost[2] . ".x $datestr)
"; } if ($comments_logall) { $fp=fopen(".comments/all","a+"); if ($fp) { fseek($commentfp,0,SEEK_END); if (flock($fp,2)) fwrite($fp,"$path/$name: $REMOTE_ADDR@$datestr '$addcomment'\n"); fclose($fp); } } } } fclose($commentfp); if (!$setperms) chmod($cfn,0664); } echo "" . "" . "" . "". ""; 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$parent"; } if (!$linkcurrent) echo "/" . $pd_arr[sizeof($pd_arr)-1] . "/"; else echo "/"; } } // end functions error_reporting(E_PARSE); if (isset($width)) { if ($width=="") setcookie("$resizecookiename", "",time()); else { $width .= "x" . $height; setcookie("$resizecookiename", $width,time()+3600*24); } } else { if ($resizecookiename) $width=$$resizecookiename; else $width=""; } if (!isset($path)) $path=""; else $path=rawurldecode($path); if (strstr($path,"..") || substr($path,0,1) == "/" || substr($path,0,1) == ".") $path=""; $wdp2=$path; if (strlen($wdp2) < 1) $wdp2=$defaultroottitle; if (isset($img)) { if (strstr($img = rawurldecode($img),"/")) $img=""; if (substr($img,0,1) == ".") $img=""; } else $img=""; if (isset($text)) { if (strstr($text = rawurldecode($text),"/")) $text=""; if (substr($text,0,1) == ".") $text=""; } else $text=""; echo "$headstuff" . "" . "$sitename - $wdp2" . "\n"; echo "
$topline
"; echo "
"; $wasrescale=0; if (isset($setrescale) && $setrescale!="") // rescale selection { $wasrescale=1; echo ""; } else if ($text != "") { echo ""; if ($comments_enabled) { echo ""; } } else echo ""; } else if ($img != "") { echo ""; } else { // browse mode // if using convert, find where convert is (you could just manually configure it, too) if ($thumbnails == "convert" && $my_convert_path == "") { // if using win32, you will have to change this to $my_convert_path = "path_to_convert.exe" instead. @exec("which convert", $tmp); $my_convert_path= $tmp[0]; if ($my_convert_path=="") $thumbnails="none"; } echo ""; 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 ""; $tablestat=0; } echo ""; $tablestat=$tablestat+1; } } if ($tablestat==1) { echo ""; } echo ""; // image listing reset($fnlist); $tablestat=0; if ($path=="") $newwd=""; else $newwd=rawurlencode($path); if ($path=="") $thumbnaildir = ".thumbnails"; else $thumbnaildir = ".thumbnails/" . $path; if (!file_exists($thumbnaildir)) { $oldumask = umask(0); mkdir($thumbnaildir,0770); umask($oldumask); } while ($fn = key($fnlist)) { next($fnlist); if ($path=="") $full_fn=$fn; else $full_fn=$path."/".$fn; if (!is_dir($full_fn) && eregi("\.(jpg|jpeg|gif|png)$",$fn)) { if ($tablestat == 0) echo ""; else if ($tablestat == 3) { echo ""; $tablestat=0; } $tablestat=$tablestat+1; $fnu=rawurlencode($fn); $stfn = substr($fn,0,strlen($fn)-strlen(strrchr($fn,"."))); echo ""; } } if ($tablestat != 0) { if ($tablestat == 1) echo ""; if ($tablestat == 1 || $tablestat == 2) echo ""; echo ""; } // audio listing $tablestat=0; reset($fnlist); if ($path=="") $newwd=""; else $newwd=str_replace("%2F","/",rawurlencode($path)); 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("\.(wav|mp2|mp3)$",$fn)) { $fnu=rawurlencode($fn); if ($tablestat == 0) { $tablestat=1; echo ""; if ($comments_enabled && !file_exists($path == "" ? ".nodircomments" : ($path . "/.nodircomments"))) { echo ""; } } echo "
"; list ($thisw, $thish) =explode("x",$width); echo "
" . " maximum display size to " . " by   "; if ($path!="") echo ""; if ($text!="") echo ""; if ($img!="") echo ""; echo "
"; echo "
" . "" . " "; if ($path!="") echo ""; if ($text!="") echo ""; if ($img!="") echo ""; echo "
"; echo "
"; display_current_path($path,1); 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 "
"; do_comments($text); echo "
"; if ($path=="") $newwd=""; else $newwd=rawurlencode($path); $openpath = ($path=="") ? "." : $path; $dp=opendir("./" . $openpath); if (!$dp) { die("Error in URL (" . $openpath . "). Click here.
"); } $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 "
"; echo $imagebrowsebottom; echo "
";

    // read directory
    $openpath = ($path=="") ? "." : $path;
    if (!is_dir($openpath) || !($dp=opendir($openpath)))
    {
      if (!$dp=opendir("."))
        die("Error in URL (" . $path . "). Click here.
"); else $path=""; } while ($fn = readdir($dp)) { if(substr($fn,0,1) != ".") { $fnlist[$fn]=""; } }; if (!isset($fnlist)) $fnlist[""]=""; closedir($dp); ksort($fnlist); reset($fnlist); echo "
"; display_current_path($path,0); echo "
\n"; // display index text if ($path != "") $idxfile=$path . "/.index.txt"; else $idxfile=".index.txt"; if (file_exists($idxfile) && $file=fopen($idxfile,"r")) { $line = fgets($file,4096); if ($line) { echo "
" . chop($line) . "
"; while ($line = fgets($file,4096)) echo chop($line) . "\n"; } fclose($file); } else { $tt=strrchr($wdp2,"/"); if (!$tt || strlen($tt)<1) $tt=$wdp2; else $tt=substr($tt,1); echo "
" . $tt . "
\n"; } // directory listing reset($fnlist); if ($path=="") $newwd=""; else $newwd=rawurlencode($path . "/"); $tablestat=2; echo "
" .""; if (file_exists($pfn)) { $pfn=str_replace("%2F","/",rawurlencode($pfn)); echo "
$fn/
"; } else echo "$fn/"; 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 "
  
";
        }
        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 "
";
        }
        echo "VIDEO: $fn ($fs"."k)\n";
      }
    }

    // text listing

    reset($fnlist);
    while ($fn = key($fnlist))
    {
      next($fnlist);
      $full_fn=$wd."/".$fn;
      if (!is_dir($full_fn) && eregi("\.TXT$",$fn)) {
        $fnu=rawurlencode($fn);
        if ($tablestat == 0) {
          $tablestat=1;
          echo "
";
        }
        echo "TEXT: " . substr($fn,0,strlen($fn)-4) . "\n";
      }
    }

    // code listing
    reset($fnlist);
    if ($path=="") $newwd="";
    else $newwd=rawurlencode($path);
    while ($fn = key($fnlist))
    {
      next($fnlist);
      if ($path=="") $full_fn=$fn;
      else $full_fn=$path."/".$fn;
      if (!is_dir($full_fn) && eregi("\.(java|asm|inc|c|cpp|phps|php-source|h)$",$fn)) { 
        $fnu=rawurlencode($fn);
        if ($tablestat == 0) {
          $tablestat=1;
          echo "
";
        }
        echo "CODE: $fn\n";
      }
    }

    // archive listing
    reset($fnlist);
    if ($path=="") $newwd="";
    else $newwd=str_replace("%2F","/",rawurlencode($path));
    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("\.(zip|rar|arj|arc|lzh|lha|tar\.gz|tar|tgz|tar\.bz)$",$fn)) { 
        $fnu=rawurlencode($fn);
        if ($tablestat == 0) {
          $tablestat=1;
          echo "
";
        }
        echo "ARCH: $fn ($fs"."k)\n";
      }
    }





    if ($tablestat == 1) echo "
"; do_comments(".index"); echo "
"; echo $bottomlinestart; if ($wasrescale==0 && $width!="") echo "Maximum display size: "; echo ""; if ($wasrescale!=0) echo "back"; else if ($width != "") echo "$width"; else echo "Set maximum display size"; echo $copyrightstring; echo $bottomlineend; echo "\n"; ?>