<?
require_once("../include/varsfuncs.php");
if(!$w||!intval($w)) $w=100; if(!$h||!intval($h)) $h=100;
if(!$from) $from=0; if(!$pl||!intval($pl)) $pl=3;
if(!$infos){ $infos=0; $checkb="";}else{$checkb="checked"; $infos=1;}
if($ac=="save"){
if(file_exists($img)){
imager($img,$h,$w,$v);
if(file_exists($v)) $c="L\\'image a été exportée dans $v"; else $c="Erreur lors de la création de l\\'image !";
die("<html><Script>alert('$c'); window.location.href='$PHP_SELF?zoom=$img';</Script></html>");
}
}
if($ifr){
if(!@file_exists($ifr)){header("HTTP/1.0 404 Not Found"); die();} if($yau) $parm="zoume="; else $parm="get=";
exit("<html><body><table align=center border=0 width=100% height=100%><tr><td align=center>
<img src=\"$PHP_SELF?$parm$ifr&h=$h&w=$w\" border=0 height=\"$h\" width=\"$w\">
<br><b>$h * $w</b></td></table></body></html>");}
if($get){
if(!@file_exists($get)){header("HTTP/1.0 404 Not Found"); die();}
header("Content-Type: image/jpeg");
imager($get,$h,$w); exit();}
if($zoume)
{
set_time_limit(200); $larjer=$w; $hoter=$w;
$s=getimagesize($zoume);
$g=imagecreate($larjer,$hoter);
imagefill($g,0,0,imagecolorallocate($g,255,255,255));
switch($s[2]){
case "2": $e=imagecreatefromjpeg($zoume); break;
case "6": $e=imagecreatefromwbmp($zoume); break;
case "3": $e=imagecreatefrompng($zoume); break;
}
imagecopyresized($g,$e,0,0,0,0,$hoter,$larjer,$s[0],$s[1]);
imagejpeg($g,"",80); imagedestroy($g);
imagedestroy($e);exit();
}
function imager($get,$h,$w,$fn=""){
set_time_limit(100);
$s=getimagesize($get);
if($s[2]==1){
header("Content-Type: image/gif");
$fp=fopen($get,"rb"); fpassthru($fp);
}else{
$g=imagecreate($w,$h);
imagefill($g,0,0,imagecolorallocate($g,255,255,255));
switch($s[2]){
case "2": $e=imagecreatefromjpeg($get); break;
case "6": $e=imagecreatefromwbmp($get); break;
case "3": $e=imagecreatefrompng($get); break;
}
if($s[0]>=$s[1]){
$x=$s[1]/$h;
if($w*$x>=$s[0]){
$y=$h; $coef=$s[1]/$h; $x=intval($s[0]/$coef);
$voidy=0; $voidx=intval(($w-$x)/2);
}else{
$x=$w; $coef=$s[0]/$w; $y=intval($s[1]/$coef);
$voidx=0; $voidy=intval(($h-$y)/2);
}
}elseif($s[1]>$s[0]){
$x=$s[0]/$w;
if($h*$x>=$s[1]){
$x=$w; $coef=$s[0]/$w; $y=intval($s[1]/$coef);
$voidx=0; $voidy=intval(($h-$y)/2);
}else{
$y=$h; $coef=$s[1]/$h; $x=intval($s[0]/$coef);
$voidy=0; $voidx=intval(($w-$x)/2);
}
}else{
$x=$w; $y=$h; $voidx=0; $voidy=0;
}
imagecopyresized($g,$e,$voidx,$voidy,0,0,$x,$y,$s[0],$s[1]);
imagejpeg($g,$fn,80); imagedestroy($g);
imagedestroy($e);}
}
if($zoom){
include("$instp/skins/$sk/_pl_img/_zoom.php");
die();}
if(!$act||!$dir){
die("<html><script>alert('Aucune image séléctionnée !'); window.close()</script></html>");
}
if(!$max) $max=9;
if(!$ac||$ac=="enrp"){
function parsedirimg($dn,$imgs){
if(substr($dn,-1,1)!="/") $dn.="/"; $i=0; global $max;
$z=opendir($dn); readdir($z); readdir($z);
while($d=readdir($z)){
if(@is_dir($dn.$d)) $imgs=parsedirimg($dn.$d."/",$imgs);
else{
if(substr($d,-4)==".jpg"||substr($d,-4)==".png"|| substr($d,-4)==".gif"|| substr($d,-5)==".wbmp"){
$imgs[]=$dn.$d; $i++; } }
}
return $imgs;
}
for($i=0;$act[$i];$i++){ $d=$act[$i];
if(@is_dir($dir.$d)) $imgs=parsedirimg($dir.$d,$imgs);
else{
if(substr($d,-4)==".jpg"||substr($d,-4)==".png"|| substr($d,-4)==".gif"|| substr($d,-5)==".wbmp")
$imgs[]=$dir.$d;
}
}
if(!count($imgs)) die("<html><script>alert('La séléction ne contient pas d\\'image valide !');window.close();</script></head>");
if($ac=="enrp"){
include_once("$instp/include/ziplib.php");
$ttmp=$dir."php~e-tmp-".uniqid(5); @mkdir($ttmp,0777);
$zipn= $dir."php~e-gallerie-".rand(0,99).".zip";
$q=new Zip($zipn); $buf='<html><head><title>PHPExplorer ~ Gallerie</title><style type="text/css">
.tab{text-align:center; background-color:#CCCCCC; border-color:black;}</Style>
</head><body bgcolor="#777777"><table class="tab" cellspacing=0 cellpadding=3 border=2 align=center width=97%><tr>
<td align=center><b><font size=5>Gallerie d\'images</font></b></td></tr></table><br>
<table class="tab" cellspacing=0 cellpadding=3 width="97%" height="'.intval($h+$h/2).'" border=2 align=center><tr>';
for($i=$from,$r=$pl,$j=0;$imgs[$i]&&$j<$max;$i++,$r++,$j++){
if($r==$pl){$r=0; $buf.="\n</tr></table><table class=tab cellpadding=3 cellspacing=0 width=97% height=".intval($h*2)." border=2 align=center><tr>\n";}
$s=getimagesize($imgs[$i]); $tdw=intval(100/$pl);
$buf.='<td align=center width="'.$tdw.'%"><table align=center border=0 width="'.$w5.'" height="'.$h5.'"><tr><td align=center>
<img border=1 style="border-color:black;" src="images/'.basename($imgs[$i]).'" ';
if($s[2]==1) $buf.=$s[3]; else $buf.="height=\"$h\" width=\"$w\"";
$buf.='></td></tr></table>';
if(!$infos){
$buf.='<hr><br>Nom de l\'image : <b>'.basename($imgs[$i]).'</b><br>Dimensions : <b>'.$s[0]."*".$s[1].'</b><br>
Type : <b>';
switch($s[2]){case 1: $buf.='GIF'; break;case 2:$buf.="JPEG";break;case 3:$buf.="PNG";break;case 6:$buf.="WBMP"; break;}
$buf.='</b><br> Poids : <b>'.filesize($imgs[$i]).' Bytes</b><br><br>';
}
imager($imgs[$i],$h,$w,$ttmp."/".basename($imgs[$i]));
}
$buf.='</td></tr></table><br>
<table class="tab" cellspacing=0 cellpadding=5 width="97%" border=2 align=center><tr><td align=center width="100%">
<font size=4><b>Gallerie générée par PHP-Explorer, <a href="http://www.max-gamers.net" target="_new">Max-Gamers.net</a></b></font>
</td></tr></table></body></html>';
$fp=fopen($ttmp."/index.htm","w+"); fputs($fp,$buf); fclose($fp);
$q->create($ttmp."/index.htm","",$ttmp); @unlink($ttmp."/index.htm");
$q->add($ttmp."/","images/",$ttmp);
delrep($ttmp); exit("<html><script>alert('La gallerie est enregistrée dans $zipn !');window.history.go(-1);</script></html>");
}
include("$instp/skins/$sk/_pl_img/_head.php");
for($i=$from,$r=$pl,$j=0;$imgs[$i]&&$j<$max;$i++,$r++,$j++){
if($r==$pl){$r=0; include("$instp/skins/$sk/_pl_img/_line_breaker.php");}
$s=getimagesize($imgs[$i]); $tdw=intval(100/$pl);
include("$instp/skins/$sk/_pl_img/_list.php");
}
include("$instp/skins/$sk/_pl_img/_pages_table.php");
for($i=0,$parms="";$act[$i];$i++) $parms.="&act[]=".$act[$i];
if(count($imgs)>$max){
include("$instp/skins/$sk/_pl_img/_pages_list.php");
print($back_2_1st);
if($imgs[$from-1]) print($back);
$pages=count($imgs)/$max; if($pages!=intval($pages)) $pages++;
for($j=0;$j<$pages;$j++){$i=$j+1; if($j*$max==$from){
$b1="<b>"; $b2="</b>";}else{$b1=""; $b2="";}
include("$instp/skins/$sk/_pl_img/_pages_list.php");
print($page_list);
}
if($imgs[$from+$max+1]) print($next);
print($go_to_last);
}
include("$instp/skins/$sk/_pl_img/_foot.php");
die();
}
?>