Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/03/2005, 09:52
McWinffield
 
Fecha de Ingreso: marzo-2005
Mensajes: 3
Antigüedad: 19 años, 1 mes
Puntos: 0
galeria en web dinamica

Hola.
Estoy intentando introducir una galeria de imagenes en php en mi web modular. Estar está bien hecha porque si la visualizo sola se ve perfectamente, pero si la incluyo como modulo de mi web dinamica no se ve nada, y me da errores del tipo:

Notice: Undefined index: _a in /data/members/free/tripod/es/t/a/r/miweb/htdocs/modulares/modulos/gal/index.php on line 7

Levo dandole vueltas dos semanas y no hay forma de encontrar solucion. Seguro q es una bobada, pero.... Les pongo el codigo por si les sirve. Gracias por su ayuda.

<?php

define('WIDTH',100);
define('HEIGHT',100);
define('EXT','.bdgallerythumb');

if ( $_REQUEST['_a']=='thumb' )
{
$file = $_REQUEST['file'];
$thumb = $_REQUEST['file'].EXT;

if
(
file_exists($thumb)
&& filemtime($thumb)>=filemtime($file)
)
{
header('Content-type: image/jpeg');
$size = filesize($_REQUEST['file'].EXT);
$fd = fopen($_REQUEST['file'].EXT,'rb');
echo fread( $fd, $size );
fclose( $fd );
exit();
}

$imageInfo = getimagesize( $file );
switch( $imageInfo[2] )
{
case 1:
$image = imagecreatefromgif( $file );
break;
case 2:
$image = imagecreatefromjpeg( $file );
break;
case 3:
$image = imagecreatefrompng( $file );
break;
default:
exit();
}

$result = imagecreatetruecolor(WIDTH,HEIGHT);
$bg = imagecolorallocate( $result, 255, 255, 255 );
imagefilledrectangle( $result, 0, 0, WIDTH-1, HEIGHT-1, $bg );

$ratio1 = $imageInfo[0]/WIDTH;
$ratio2 = $imageInfo[1]/HEIGHT;
$ratio = $ratio1>$ratio2?$ratio1:$ratio2;
if ( $ratio<1 )
$ratio=1;
$width = $imageInfo[0]/$ratio;
$height = $imageInfo[1]/$ratio;
imagecopyresampled( $result, $image, (WIDTH-$width)/2, (HEIGHT-$height)/2, 0, 0, $width, $height, $imageInfo[0], $imageInfo[1]);

header('Content-type: image/jpeg');
imagejpeg($result);

imagejpeg($result,$thumb);

exit();
}

$supported = imagetypes();
if ( function_exists('imagecreatefromgif') )
$supported |= IMG_GIF;

$files = array();
$thumbs = array();
$dir = opendir('.');
while( ($file=readdir( $dir ))!==false )
{
if ( !is_file($file) )
continue;

$ext = strrchr($file, '.');
$extLower = strtolower($ext);
if
(
$extLower=='.gif' && ($supported & IMG_GIF)
|| $extLower=='.png' && ($supported & IMG_PNG)
|| $extLower=='.jpeg' && ($supported & IMG_JPG)
|| $extLower=='.jpg' && ($supported & IMG_JPG)
)
$files[] = $file;
else if ( $ext==EXT )
$thumbs[] = $file;
}
closedir($dir);

foreach( $files as $file )
{
$title = $file;
$size = filesize( $file );
$measure = 'B';
if ( $size>1024 )
{
$size /= 1024;
$measure = 'KB';
if ( $size>1024 )
{
$size /= 1024;
$measure = 'MB';
}
}
$title .= " - ".number_format($size,1).$measure;
?>
<a href="<?php echo $file ?>"><img src="index.php?_a=thumb&file=<?php echo $file ?>&<?php echo filemtime($file) ?>" border="1" title="<?php echo $title ?>" alt="<?php echo $title ?>"></a>
<?php
}

$extLength = strlen( EXT );
foreach( $thumbs as $thumb )
{
$file = substr( $thumb, 0, strlen($thumb)-$extLength );
if ( !file_exists($file) )
unlink($thumb);
}
?>