<?php
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# MAGNIFICA WEB SCRIPTS - ANIGAC CLASS 1.1 - HTTP://WWW.GNIFI.COM #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
######################################################
# Path to Thumbnail folder (Web)
######################################################
$path_thumb_web = '/anigac/thumb';
######################################################
# Path to website root (Local Server dir)
######################################################
$root = '/home/myuser/public_html';
######################################################
# Self Path of anigac.php (Web)
######################################################
$self_path = '/anigac';
######################################################
# Templates
######################################################
$template['main'] = '
<div id="{uid}">
<div style="font-size:5pt; font-family:tahoma; text-align:center; color:#AAAAAA">
Powered by <a href="http://www.gnifi.com" target="_blank" style="text-decoration: none">Anigac class</a> <!-- Do not remove this line if you did not pay for this -->
</div>
{out}
<div id="{uid}_ind" style="font-family:verdana; font-size:9px; font-weight:bold; color: #CCCCCC">
{prev} - {next}
</div>
</div>';
$template['image'] = '
<a href="#" onclick="onw(\'{img_link}\',{w},{h},\'{title}\'); return false"><img src="{thumb_web}" alt="{title}" title="{title}" style="margin:5px; padding:1px; border:1px solid #CCCCCC;"></a>';
$template['prev'] = '
<a href="#" onclick="display(\'{uid}\',{initprev},\'{dir64}\',{size},{perpage},\'{self_path}\'); return false;">
PREV
</a>';
$template['next'] = '
<a href="#" onclick="display(\'{uid}\',{initnext},\'{dir64}\',{size},{perpage},\'{self_path}\'); return false;">
NEXT
</a>';
######################################################
# END OF SETTINGS
######################################################
?>
<SCRIPT type="text/javascript">
pic1= new Image(16,16);
pic1.src="<?php echo $self_path; ?>/loader.gif";
function getHTTPObject()
{
var xmlhttp = false;
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
xmlhttp = false;
}
}
if(!xmlhttp && typeof XMLHttpRequest!='undefined')
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch (e)
{
xmlhttp = false;
}
}
if(!xmlhttp && window.createRequest)
{
try
{
xmlhttp = window.createRequest();
}
catch (e)
{
xmlhttp = false;
}
}
return xmlhttp;
}
function display(id,id2,id3,id4,id5,id6)
{
var http = getHTTPObject();
http.open("GET", id6+"/anigac.php?init="+id2+"&dir="+id3+"&tsize="+id4+"&perpage="+id5, true);
document.getElementById(id+'_ind').innerHTML = '<img src="'+id6+'/loader.gif">';
http.onreadystatechange=function() {
if(http.readyState == 4) {
document.getElementById(id).innerHTML = http.responseText;
}
}
http.send(null);
}
function onw(i,w,h,tl) {
newwin=window.open('','shout','width='+w+',height='+h+',resizable=yes,scrollbars=yes,status=0,tollbar=no');
newwin.document.open();
newwin.document.write('\n<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />\n');
newwin.document.write('<meta http-equiv="Imagetoolbar" content="no" />\n');
newwin.document.write('<title>'+tl+'</title>\n');
newwin.document.write('</head>');
newwin.document.write('<body style="margin:0;padding:0">\n<img src="'+i+'" width="'+w+'" height="'+h+'" />');
newwin.document.write('\n</body></html>');
newwin.document.close();
newwin.focus();
}
</SCRIPT>
<?php
$root = rtrim($root,'/\\');
$web_path = rtrim($path_thumb_web,'/\\');
$path_thumb_parsed = rtrim($root.$web_path,'/\\');
$self_path = rtrim($self_path,'/\\');
class gal
{
#generates thumbnails using GD Library functions
function tn($original_image,$target_image,$thumbsize)
{
$thumbnail_quality = 90;
$imagesize = @GetImageSize($original_image);
$type = $imagesize['2'];
if($type == 1)
$source_image = @ImageCreateFromGIF($original_image);
if($type == 2)
$source_image = @ImageCreateFromJPEG($original_image);
if($type == 3)
$source_image = @ImageCreateFromPNG($original_image);
if($imagesize['0'] > $thumbsize OR $imagesize['1'] > $thumbsize)
{
if($imagesize['0'] >= $imagesize['1'])
{
$sizey = $thumbsize * $imagesize['1'];
$thumbsizey = intval($sizey / $imagesize['0']);
$temp_image = @ImageCreateTrueColor($thumbsize, $thumbsizey);
$thw = $thumbsize; $thy = $thumbsizey;
}
else
{
$sizew = $thumbsize * $imagesize['0'];
$thumbsizew = intval($sizew / $imagesize['1']);
$temp_image = @ImageCreateTrueColor($thumbsizew, $thumbsize);
$thw = $thumbsizew; $thy = $thumbsize;
}
}
else
{
$thw = $imagesize['0']; $thy = $imagesize['1'];
$temp_image = @ImageCreateTrueColor($thw, $thy);
}
$white = imagecolorallocate($temp_image, 255, 255, 255);
imagefill($temp_image, 0, 0, $white);
@ImageCopyResampled($temp_image, $source_image, 0, 0, 0, 0, $thw, $thy, $imagesize['0'], $imagesize['1']);
if($target_image)
@ImageJPEG($temp_image, $target_image, $thumbnail_quality);
else
@ImageJPEG($temp_image, '', $thumbnail_quality);
@ImageDestroy($temp_image);
if (!file_exists($target_image))
return false;
else
return true;
}
function testi($type)
{
$out = 0;
switch($type)
{
case 1: if(function_exists('imagecreatefromgif')) { $out = 1; } break;
case 2: if(function_exists('imagecreatefromjpeg')) { $out = 1; } break;
case 3: if(function_exists('imagecreatefrompng')) { $out = 1; } break;
}
return($out);
}
function sfv($filename)
{
$sfv_checksum = strtoupper(dechex(crc32($filename)));
return $sfv_checksum;
}
function mktitle($str)
{
return str_replace(array('.jpg','.jpeg','.gif','.png','-','_',',',"'",'"','&'),array('','','','',' ',' ','','','',' '),$str);
}
#populates templates
function popt($id,$arr)
{
global $template;
$out = $template[$id];
if(is_array($arr))
{
foreach($arr as $key => $value)
$out = str_replace("{".$key."}",$arr[$key],$out);
}
$out = trim($out,'\n\r');
return($out);
}
function display($dir,$tsize,$perpage)
{
global $path_thumb_parsed,$web_path,$root,$self_path;
$dir = rtrim($dir,'/\\').'/';
$count = 1;
$handle2 = @opendir($dir);
if ($handle2 == false) return -1;
while (($file2 = @readdir($handle2)) != false)
{
if($file2 != "." AND $file2 != "..")
{
$testimg = @getimagesize($dir.$file2);
if(!is_dir($dir.$file2) AND $this->testi($testimg['2']))
{
$darr[$count] = $file2 AND $darr2[$count] = filemtime($dir.$file2);
$count++;
}
}
}
closedir($handle2);
$init = intval($_GET['init']);
if(!$init)
$init = 1;
$inite = $init+$perpage;
if($inite > $count)
$inite = $count;
for($i=$init;$i<$inite;$i++)
{
$file2 = $darr[$i];
$thumb_web = $web_path.'/'.$this->sfv($dir.$file2).'_'.$tsize.'.jpg';
$thumb_local = $path_thumb_parsed.'/'.$this->sfv($dir.$file2).'_'.$tsize.'.jpg';
if(!file_exists($path_thumb_parsed))
mkdir($path_thumb_parsed, 0777);
if(!file_exists($thumb_local))
$this->tn($dir.$file2,$thumb_local,$tsize);
$testimg = @getimagesize($dir.$file2);
$out .= $this->popt('image', array(
'img_link' => str_replace('\\','/',str_replace("'","\'",'/'.ltrim(str_replace(strtolower($root),'',$dir),'/\\').$file2)),
'w' => $testimg[0],
'h' => $testimg[1],
'title' => $this->mktitle($file2),
'thumb_web' => $thumb_web
)
);
}
$uid = $dir.'-'.$tsize.'-'.$perpage;
if($init-$perpage <= 0)
$prev = 'PREV';
else
$prev = $this->popt('prev', array(
'uid' => $this->sfv($uid),
'initprev' => ($init-$perpage),
'dir64' => base64_encode($dir),
'size' => $tsize,
'perpage' => $perpage,
'self_path' => $self_path
)
);
if($init+$perpage >= $count)
$next = 'NEXT';
else
$next = $this->popt('next', array(
'uid' => $this->sfv($uid),
'initnext' => ($init+$perpage),
'dir64' => base64_encode($dir),
'size' => $tsize,
'perpage' => $perpage,
'self_path' => $self_path
)
);
return $this->popt('main', array(
'uid' => $this->sfv($uid),
'out' => $out,
'prev' => $prev,
'next' => $next
)
);
}
}
if($_GET['init'])
{
sleep(1);
$var = new gal();
echo $var->display(base64_decode($_GET['dir']),$_GET['tsize'],$_GET['perpage']);
}
?>