Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/03/2006, 08:53
Avatar de mkls
mkls
 
Fecha de Ingreso: diciembre-2004
Ubicación: Rengo - Chile
Mensajes: 55
Antigüedad: 19 años, 4 meses
Puntos: 1
register globals y los thumbnails

Hola

Hace un tiempo implemente una aplicacion que crea thumbnailsde un archivo y todo funcionaba bien, pero ahora el server cambio el estado de la variable register_globals y ya no sube imagenes ni crea thumbnails....

es posible que el solo cambio de estado de esta dicha variable interfiera tanto en el script? o quizas el problema es otro... igual posteo el codigo...
Código PHP:
<?

    
include ("../cnx.php");
$link=conectar();

include(
"galeria.php");



$codigo=$_POST['codigo'];
$nombre_es=$_POST['nombre_es'];
$nombre_en=$_POST['nombre_en'];
$categoria=$_POST['categoria'];
$ancho=$_POST['ancho'];
$alto=$_POST['alto'];
$desc_en=$_POST['descripcion_en'];
$desc_es=$_POST['descripcion_es'];
$precio=$_POST['precio'];



$sql="insert into productos (id_producto, categoria, codigo, nombre_es, nombre_en, precio, ancho, alto, descripcion_es, descripcion_en)
                        Values('', '$categoria', '$codigo', '$nombre_es','$nombre_en', '$precio', '$ancho', '$alto', '$desc_es', '$desc_en')"
;
mysql_query($sql$link);    

$sql="select * from productos where codigo='$codigo' and precio='$precio'";
$resp=mysql_query($sql$link);
$orw=mysql_fetch_object($resp);
$id=$orw->id_producto;

 if (isset(
$file)){





   
$dir2"archivos/";
   
$dir"../archivos/";
            
$extension explode(".",$file_name);
                    
$peso filesize($file);
                        if (
$peso<1024)
                        {
                        
$peso=$peso" Bytes";
                        }if (
$peso 1024)
                            {
                            
$peso=$peso/1024;
                                if (
$peso<1024)
                                {
                                
$peso=round ($peso,1) . " Kb";
                                }if (
$peso>1024){
                                
$peso=$peso/1024;
                                
$peso=round ($peso,1) . " Mb";
                                }
                        }
            
$num count($extension)-1
            
$formato=$extension[$num];
            
set_time_limit(0);
               
$nombrearchivo date('Ymdhis').".".$formato;
            
$CopiarArchivo move_uploaded_file($HTTP_POST_FILES["file"]["tmp_name"],$dir.$file_name);
               @
rename("../archivos/$file_name""../archivos/$nombrearchivo");
            @
chmod("../archivos/$nombrearchivo",0777);               
            
$archivo "archivos/$nombrearchivo";
            
$path=$path.$file_name;
            
$fecha=date('d/m/Y');
            
$fecha2 date('Y-m-d');
            
            
$detalle_im=getimagesize($file);
            
            
$sql_f="Insert into archivos (id_producto,ruta, nombre, ancho, alto) 
                                Values     ('$id', '$dir2', '$nombrearchivo', '$detalle_im[0]', '$detalle_im[1]')"
;
                                
                                
            
mysql_query($sql_f$link);
            
            
gallery("../archivos",5,150,150,1,$nombrearchivo);
            
            
?>

y el archivo galeria con la funcion galeri..
Código PHP:
<?


function gallery($dir,$ncol,$w,$h,$r,$archivo)
{
    
$type=array("jpg","jpeg","gif","png"); /*tipi di immagine supportati*/
    
    
    
$i=0;

    
    
$file $archivo;
    
        if(
$file != "." && $file != "..")
        {
            
$ext=explode(".",$file); /*find la extencion del archivo*/
            
            
$ext=strtolower($ext[1]); /*la converte in minuscolo*/
            
            
if(in_array($ext,$type))
            {
                if(
$i==0)                
                
                
                
                
thumb("$dir/","$file",$w,$h,$r);
                
                
                
$i++;
                
                if(
$i==$ncol)
                {
                    
                    
$i=0;
                }
                
            }
        }
    }


function 
thumb($dir,$img$wt$ht$resize)
{
    
$file=$dir.$img;
    
$th_file=$dir."thumbs/th_".$img;

    list(
$wi$hi$type$attr) = @getimagesize($file);
    list(
$th_w$th_h) = @getimagesize($th_file);
    
    if(!
is_dir($dir."thumbs/"))    mkdir($dir."thumbs/");    
    
    if(
file_exists($th_file) && ($wt==$th_w || $ht==$th_h))
    {
        if(
$resize)
        {
        }
    }
    else
    {
        switch(
$type)
        {
            case 
1$im = @imagecreatefromgif($file);  $ext="@imagegif(\$new, \$th_file);"; break;
            case 
2$im = @imagecreatefromjpeg($file); $ext="@imagejpeg(\$new, \$th_file , 100);"; break;
            case 
3$im = @imagecreatefrompng($file); $ext="@imagepng(\$new, \$th_file);"; break;
        }
        
        if(
$wi<$hi)            $wt=($ht/$hi)*$wi;
        elseif (
$wi>$hi)    $ht=($wt/$wi)*$hi;
        
        if(
$type!=1)
        {
        
$wt=($wt/3)*2;
        
$ht=($ht/3)*2;
            
$new imagecreatetruecolor($wt,$ht);
            @
imagecopyresampled($new $im $wt $ht $wi $hi);
        }
        else
        {
        
$wt=($wt/3)*2;
        
$ht=($ht/3)*2;
        
            
$new imagecreate($wt,$ht);
            @
imagecopyresized($new $im 0$wt $ht $wi $hi);
        }
        
        @eval(
$ext);
        
        if(
$resize)
        {
        }
        
        @
imagedestroy($im);
        @
imagedestroy($new);
    }
}
?>