Foros del Web » Programando para Internet » PHP »

Deprecated: Function ereg_replace() en libreria resize.php

Estas en el tema de Deprecated: Function ereg_replace() en libreria resize.php en el foro de PHP en Foros del Web. Hola amigos como estan, Vereis estoy usando una libreria para crear thumb y funcionaba muy bien la cosa es que ahora esta dando este error: ...
  #1 (permalink)  
Antiguo 16/04/2013, 02:00
 
Fecha de Ingreso: marzo-2007
Mensajes: 751
Antigüedad: 17 años, 1 mes
Puntos: 4
Deprecated: Function ereg_replace() en libreria resize.php

Hola amigos como estan,

Vereis estoy usando una libreria para crear thumb y funcionaba muy bien la cosa es que ahora esta dando este error:

Deprecated: Function ereg_replace() is deprecated in cript\resize.php on line 36

He leido un poco y es por que la version de php a subido a 5.3 entonces considera esa linea como obsoleta.

La cosa es que he visto por hay que se puede modificar pero no lo consigo a ver si alguien sabe como se podria hacer esto, la linea en cuestion es esta:

Código PHP:
        $this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile); 
Y el codigo completo de la libreria por si es de ayuda:

Código PHP:
class thumbnail
{
    var 
$img;

    function 
thumbnail($imgfile)
    {
        
ini_set("memory_limit","128M");
                
//detect image format
        
$this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile);
        
$this->img["format"]=strtoupper($this->img["format"]);
        if (
$this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
            
//JPEG
            
$this->img["format"]="JPEG";
            
$this->img["src"] = ImageCreateFromJPEG ($imgfile);
        } elseif (
$this->img["format"]=="PNG") {
            
//PNG
            
$this->img["format"]="PNG";
            
$this->img["src"] = ImageCreateFromPNG ($imgfile);
        } elseif (
$this->img["format"]=="GIF") {
            
//GIF
            
$this->img["format"]="GIF";
            
$this->img["src"] = ImageCreateFromGIF ($imgfile);
        } elseif (
$this->img["format"]=="WBMP") {
            
//WBMP
            
$this->img["format"]="WBMP";
            
$this->img["src"] = ImageCreateFromWBMP ($imgfile);
        } else {
            
//DEFAULT
            
echo "Not Supported File";
            exit();
        }
        @
$this->img["lebar"] = imagesx($this->img["src"]);
        @
$this->img["tinggi"] = imagesy($this->img["src"]);
        
//default quality jpeg
        
$this->img["quality"]=75;
    }

    function 
size_height($size=100)
    {
        
//height
        
$this->img["tinggi_thumb"]=$size;
        @
$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"];
    }

    function 
size_width($size=100)
    {
        
//width
        
$this->img["lebar_thumb"]=$size;
        @
$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"];
    }

    function 
size_auto($size=100)
    {
        
//size
        
if ($this->img["lebar"]>=$this->img["tinggi"]) {
            
$this->img["lebar_thumb"]=$size;
            @
$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"];
        } else {
            
$this->img["tinggi_thumb"]=$size;
            @
$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"];
         }
    }

    function 
jpeg_quality($quality=75)
    {
        
//jpeg quality
        
$this->img["quality"]=$quality;
    }

    function 
show()
    {
        
//show thumb
        
@Header("Content-Type: image/".$this->img["format"]);

        
/* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/
        
$this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
            @
imagecopyresized ($this->img["des"], $this->img["src"], 0000$this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);

        if (
$this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
            
//JPEG
            
imageJPEG($this->img["des"],"",$this->img["quality"]);
        } elseif (
$this->img["format"]=="PNG") {
            
//PNG
            
imagePNG($this->img["des"]);
        } elseif (
$this->img["format"]=="GIF") {
            
//GIF
            
imageGIF($this->img["des"]);
        } elseif (
$this->img["format"]=="WBMP") {
            
//WBMP
            
imageWBMP($this->img["des"]);
        }
    }

    function 
save($save="")
    {
        
//save thumb
        
if (empty($save)) $save=strtolower("./thumb.".$this->img["format"]);
        
/* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/
        
$this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
            @
imagecopyresized ($this->img["des"], $this->img["src"], 0000$this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);

        if (
$this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
            
//JPEG
            
imageJPEG($this->img["des"],"$save",$this->img["quality"]);
        } elseif (
$this->img["format"]=="PNG") {
            
//PNG
            
imagePNG($this->img["des"],"$save");
        } elseif (
$this->img["format"]=="GIF") {
            
//GIF
            
imageGIF($this->img["des"],"$save");
        } elseif (
$this->img["format"]=="WBMP") {
            
//WBMP
            
imageWBMP($this->img["des"],"$save");
        }
    }

Bueno un saludo.
  #2 (permalink)  
Antiguo 16/04/2013, 05:17
Avatar de cuasatar  
Fecha de Ingreso: junio-2011
Ubicación: Bogotá Rock City
Mensajes: 1.230
Antigüedad: 12 años, 10 meses
Puntos: 181
Respuesta: Deprecated: Function ereg_replace() en libreria resize.php

En el manual te explican por cual se debe reemplazar.


http://php.net/manual/es/migration53.deprecated.php
__________________
Blog de humor http://elcuasatar.net63.net/

Etiquetas: deprecated, function, libreria
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:42.