View Single Post
Old 10-13-2004, 05:27 PM  
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
PHP Code:
<?PHP

/* 
 * Place this file in a folder that you want thumbnailed
 * This file should be the default page in that folder
 * This file must have privilege to execute
 * The folder must allow writing, chmod 777 *
 * Thumbnails are prefixed with t_ 
 *
 * If the thumbs do not exist, they will be created
 * If the thumbs do exist, they will not be recreated
 * Avi and Mpg files are echoed with a generic image as its thumbnail
 *
 */


$tncount=0;                                         //thumbnail counter
$count=0;                                            //generic counter
$prefix="t_";                                        //thumbnail prefix
$arrayCount=0;                                        //array counter


if ($handle opendir("./")) {
  while (
false !hahahaha ($file readdir($handle))) { 
    
set_time_limit(5);
    if( !
file_exists($prefix.$file) && stristr($file"jpg") && !stristr($file$prefix)){
      
//create thumbs for jpg if thumb doesnt exist
      
$name $file;
      
$OldImage ImageCreateFromJpeg($name);
      
$width imagesx($OldImage);
      
$height imagesy($OldImage);
      
$DEF_TWIDTH 200;
      
$NewThumb ImageCreateTrueColor($DEF_TWIDTH,($DEF_TWIDTH/$width)*$height);
      
ImageCopyResized($NewThumb,$OldImage,0,0,0,0,$DEF_TWIDTH,($DEF_TWIDTH/$width)*$height,$width,$height);
      
ImageJpeg($NewThumb,$prefix $name,75);
      
ImageDestroy($NewThumb);
      
ImageDestroy($OldImage);
      
$tncount++;                                         //counts the number of thumbnails created
    
}
    if(
file_exists($prefix.$file) && !stristr($file"..") && !stristr($file".php") && stristr($file,"jpg")){
      
//display if thumbs ixisT
      
$tempArray[$arrayCount]="<td width=\"200\" bgcolor=\"#225483\" onmouseover=\"javascript:this.bgColor='397DBE'\" onmouseout=\"javascript:this.bgColor='225483'\"><a href=\"".$file."\" target=\"_blank\"><img src=\"" $prefix $file "\" border=\"0\" height=\"150\" alt=\"".(filesize($file)/1000)." Kb\"><br>"$file ."<br> Size: ".(filesize($file)/1000)." Kb</a></td>\n";
      
$tempArrayIndex[$arrayCount]=1;
      
$arrayCount++;
    }
    if(
stristr($file"mpg") || stristr($file"avi")){ //if the file is a movie
      
$tempArray[$arrayCount]="<td width=\"200\" bgcolor=\"#225483\" onmouseover=\"javascript:this.bgColor='397DBe'\" onmouseout=\"javascript:this.bgColor='225483'\"><a href=\"".$file."\" target=\"_blank\"><img src=\"http://www.sinfulvirgins.com/vph.jpg\" border=\"0\"><br>".$file."<br> Size: ".(filesize($file)/1000)." Kb</a></td>\n";
      
$tempArrayIndex[$arrayCount]=0;
      
$arrayCount++;
    }
  }
}
set_time_limit(10);                                      //allows up to 10 seconds to process each thumbnail
closedir($handle);
echo 
"<title>Smokey the bear ! - " $tncount " added, ".($arrayCount)." total</title>\n";
echo 
"<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\"><tr onmouseover=\"javascript:this.bgColor='4077AB'\" onmouseout=\"javascript:this.bgColor=''\">";
$num=20;                                                 //how many images per page (default)<br>
if($_GET['num'] >= 1)
  
$num=$_GET['num'];
$page=1;                                                 //starting page
if($_GET['page'] >= 1)
  
$page=$_GET['page'];
$finalArrayIncr=0;                                        //$finalArrayIncrrrrrr increments $finalArray[] to the next spot throughout both for loops
for($z=0$z<$arrayCount$z++){                            //for loop that puts the images in the $finalArray[] array
  
if($tempArrayIndex[$z]hahahaha1){
    
$finalArray[$finalArrayIncr]=$tempArray[$z];
    
$finalArrayIncr++;
  }
}
for(
$x=0$x<$arrayCount$x++){                        
  if(
$tempArrayIndex[$x]hahahaha0){
    
$finalArray[$finalArrayIncr]=$tempArray[$x];
    
$finalArrayIncr++;
  }
}
if((
$page*$num)-$num $arrayCount)                     
  
$page=1;
for(
$i=0$i<$arrayCount$i++){
  if(
$counthahahaha4){                                
    
$count=0;                                        
    echo 
"</tr><tr>";
  }
  if(
$i <$page*$num && $i >=($page-1)*$num){        
    echo 
$finalArray[$i];                    
    ++
$count;
  }
}
if(
$num<999 && $arrayCount>$num){
  echo 
"<a href=\"./?page=";                                //prints out <<
  
if($page-1<1)                                            //if its already the first page, simply stay on the page
    
echo "1";
  else 
   echo (
$page-1);
  echo 
"&num=".$num."\">&lt;&lt;</a> ";
  
$pg=0;                                                    //page counter, incremented when $i%$numhahahaha0
  
for($i=0$i<$arrayCount$i++)                            //does the page numbering
    
if($i%$numhahahaha0 )
      echo 
"<a href=\"./?page=".++$pg."&num=".$num."\">".$pg."</a> ";
  echo 
"<a href=\"./?page=";                                //prints out >>
  
if($page+1>$pg)                                            //if its already the last page, simply stay on that page
    
echo $pg;
  else 
    echo 
$page+1;
  echo 
"&num=".$num."&sid=".$_GET['sid']."\">&gt;&gt;</a> ";
}
echo 
"<br>Number of images per page: ";                    //sets the number of images displayed per page
echo " <a href=\"./?page=".$page."&num=5&sid="."\">5</a> ";
echo 
" <a href=\"./?page=".$page."&num=10&sid="."\">10</a> ";
echo 
" <a href=\"./?page=".$page."&num=20&sid="."\">20</a> ";
echo 
" <a href=\"./?page=".$page."&num=30&sid="."\">30</a> ";
echo 
" <a href=\"./?page=".$page."&num=40&sid="."\">40</a> ";
echo 
" <a href=\"./?page=".$page."&num=50&sid="."\">50</a> ";
echo 
" <a href=\"./?page=".$page."&num=999&sid="."\">All</a> ";
?>
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote