Viewing file: funciones.php (23.82 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php date_default_timezone_set("America/Argentina/Buenos_Aires"); $months = array ("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
function acomodar_precios($p){//2150.50 $p=number_format($p, 2, ',', '.'); $aux=explode(",",$p); return $aux[0]."<sup>".$aux[1]."</sup>".'<span class="precio hidden">'.$p.'</span>'; }
function mes_letra ($mes) { if ($mes=="01"){$mes_let="Enero";} if ($mes=="02"){$mes_let="Febrero";} if ($mes=="03"){$mes_let="Marzo";} if ($mes=="04"){$mes_let="Abril";} if ($mes=="05"){$mes_let="Mayo";} if ($mes=="06"){$mes_let="Junio";} if ($mes=="07"){$mes_let="Julio";} if ($mes=="08"){$mes_let="Agosto";} if ($mes=="09"){$mes_let="Septiembre";} if ($mes=="10"){$mes_let="Octubre";} if ($mes=="11"){$mes_let="Noviembre";} if ($mes=="12"){$mes_let="Diciembre";} return $mes_let; }
function saleamd($fecha_mysql){//funcion javi if ($fecha_mysql!=""){ $aux=explode(" ",$fecha_mysql); $aux2=explode("/",$aux[0]); return $aux2[2]."-".$aux2[1]."-".$aux2[0]." ".$aux[1]; } }
function ver_fecha_mysql_lindo($fecha_mysql){//puede ser tipo yyyy-mm-dd o yyyy-mm-dd hh:mm:ss if ($fecha_mysql!=""){ $aux=explode(" ",$fecha_mysql); $aux2=explode("-",$aux[0]); if (isset($aux[1]) && ($aux[1]!='00:00:00')){ return $aux2[2]."/".$aux2[1]."/".$aux2[0]." ".$aux[1]; } else { return $aux2[2]."/".$aux2[1]."/".$aux2[0]; } } }
function acomodar_fecha_para_mysql($fecha_mysql){//puede ser tipo yyyy-mm-dd o yyyy-mm-dd hh:mm:ss $aux=explode(" ",$fecha_mysql); $aux2=explode("/",$aux[0]); if (isset($aux[1]) && ($aux[1]!='00:00:00')){ return $aux2[2]."-".$aux2[1]."-".$aux2[0]." ".$aux[1]; } else { return $aux2[2]."-".$aux2[1]."-".$aux2[0]; } }
function get_analytics_data( $profile_id, $dimensions=array('browser'), $metrics=array('pageviews','visits','UniquePageviews'), $sort=null, $start_date=null, $end_date=null ){ $cache_id = md5(serialize(func_get_args())); $return = false; // check if the cache item exists. $temp_folder = '/tmp/ga/'; if(!is_dir($temp_folder))mkdir($temp_folder); $filename = $temp_folder.$cache_id; if(is_file($filename)){ // if cache entry exists if(filemtime($filename) > (time() - 172800)){ // check if it's older than 2 days $return = unserialize(file_get_contents($filename)); // grab the cached content. } } if(!$return){ // no cache item found, so we grab it via gapi class. $ga = new gapi(ga_web_email,ga_web_pass); if(!$sort)$sort = current($dimensions); ini_set('display_errors',true); $ga->requestReportData($profile_id,$dimensions,$metrics,$sort,null,$start_date,$end_date,null,100); $return = array(); $return['data'] = array(); foreach($ga->getResults() as $result){ $data = array(); foreach($dimensions as $d){ $data[$d] = (string)$result; foreach($metrics as $m){ $data[$m] = $result->{'get'.$m}(); } } $return['data'][] = $data; } //$return['total'] = $ga->getTotalResults(); foreach($metrics as $m){ $return[$m] = $ga->{'get'.$m}(); } $return['timestamp'] = $ga->getUpdated(); } // save cache item. file_put_contents($filename,serialize($return)); return $return; } function actual_date (){ $week_days = array ("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"); $months = array ("", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"); $year_now = date ("Y"); $month_now = date ("n"); $day_now = date ("j"); $week_day_now = date ("w"); $date["dia_letra"]=$week_days[$week_day_now]; $date["dia_numero"]=$day_now; $date["mes_letra"]=$months[$month_now]; $date["mes_numero"]=date ("m"); $date["anio_numero"]=$year_now; return $date; } function traducir_dia($dia_ingles){ $dia_espanol=""; if ($dia_ingles=="Monday") $dia_espanol="Lunes"; if ($dia_ingles=="Tuesday") $dia_espanol="Martes"; if ($dia_ingles=="Wednesday") $dia_espanol="Miércoles"; if ($dia_ingles=="Thursday") $dia_espanol="Jueves"; if ($dia_ingles=="Friday") $dia_espanol="Viernes"; if ($dia_ingles=="Saturday") $dia_espanol="Sabado"; if ($dia_ingles=="Sunday") $dia_espanol="Domingo"; return ($dia_espanol); } function traducir_mes($mes_ingles){ $mes_espanol=""; if ($mes_ingles=="January") $mes_espanol="Enero"; if ($mes_ingles=="February") $mes_espanol="Febrero"; if ($mes_ingles=="March") $mes_espanol="Marzo"; if ($mes_ingles=="April") $mes_espanol="Abril"; if ($mes_ingles=="May") $mes_espanol="Mayo"; if ($mes_ingles=="June") $mes_espanol="Junio"; if ($mes_ingles=="July") $mes_espanol="Julio"; if ($mes_ingles=="August") $mes_espanol="Agosto"; if ($mes_ingles=="September") $mes_espanol="Setiembre"; if ($mes_ingles=="October") $mes_espanol="Octubre"; if ($mes_ingles=="November") $mes_espanol="Noviembre"; if ($mes_ingles=="December") $mes_espanol="Diciembre"; return($mes_espanol); } function generar_imagen($imagen,$ancho,$alto,$nombre_final){ $anchura=$ancho;//maximo ancho de la imagen $hmax=$alto;//maximo alto de la imagen $datos = getimagesize($imagen);//obtengo las medidas de la imagen if($datos[2]!=2){//si no es .jpg $img = @imagecreatefrompng($imagen);//obtengo la info de la imagen imagealphablending($img, true); imagesavealpha($img, true); } else {//si es jpg $img = @imagecreatefromjpeg($imagen);//obtengo la info de la imagen } $ratio = ($datos[0] / $anchura); $altura = ($datos[1] / $ratio); if($altura>$hmax){//si me exedo de la altura maxima permitida $anchura2=$hmax*$anchura/$altura;//la recalculo $altura=$hmax; $anchura=$anchura2; } //$thumb = imagecreatetruecolor($anchura,$altura);//creo el thumb en truecolor $thumb = imagecreatetruecolor($anchura,$altura);//creo el thumb en truecolor imagecopyresampled($thumb, $img, 0, 0, 0, 0, $anchura, $altura, $datos[0], $datos[1]); //copio los cambio realizados a la imagen en memoria if($datos[2]!=2){//si no es .jpg imagepng($thumb, $nombre_final);//copio la imagen generada al archivo fisico } else {//si es jpg imagejpeg($thumb, $nombre_final, 85);//copio la imagen generada al archivo fisico } imagedestroy($thumb);//libero memoria return true;//salio todo ok } function url_completa(){ $url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; return $url; } function agregar_class_current($link){//ejemplo: agregar_class_current("index.php") o agregar_class_current("index.php, home.php, inicio.php") $directorio="/"; //directorio actual, si es el raiz, dejar "/", si estas en un directorio pone "/directorio/" $url=$_SERVER['REQUEST_URI']; $aux=explode("?",$url); $nombre_archivo=$aux[0]; //$nombre_archivo=$url; $aux=explode(", ",$link);//varios archivos separados por ", " foreach ($aux as $valor) { if ($nombre_archivo=="$directorio$valor"){ echo 'class="current"'; }else { echo 'class="drop"'; } } } //funcion alambre function agregar_class_current_alambre($link){//ejemplo: agregar_class_current("index.php") o agregar_class_current("index.php, home.php, inicio.php") $directorio="/"; //directorio actual, si es el raiz, dejar "/", si estas en un directorio pone "/directorio/" $url=$_SERVER['REQUEST_URI']; //$aux=explode("?",$url); $nombre_archivo=$url;//$aux[0]; //$nombre_archivo=$url; //$aux=explode(", ",$link);//varios archivos separados por ", " //foreach ($aux as $valor) { if ($nombre_archivo==$directorio.$link){ echo 'class="inicio"'; } //} } //fin alambre function agregar_solo_current($link){//ejemplo: agregar_solo_current("index.php") o agregar_solo_current("index.php, home.php, inicio.php") $directorio="/"; //directorio actual, si es el raiz, dejar "/", si estas en un directorio pone "/directorio/" $url=$_SERVER['REQUEST_URI']; $aux=explode("?",$url); $nombre_archivo=$aux[0]; $aux=explode(", ",$link);//varios archivos separados por ", " foreach ($aux as $valor) { if ($nombre_archivo=="$directorio$valor") echo 'current'; } } function escapar_caracteres_especiales($t){ $texto=str_replace('"','',$t); $texto=str_replace('°','',$texto); $texto=str_replace("»",'',$texto); $texto=str_replace("¡",'',$texto); $texto=str_replace("=",'',$texto); $texto=str_replace("/",'',$texto); $texto=str_replace("#",'',$texto); $texto=str_replace("'",'',$texto); $texto=str_replace("<",'',$texto); $texto=str_replace(">",'',$texto); $texto=str_replace("&",'',$texto); $texto=str_replace('.','',$texto); $texto=str_replace('!','',$texto); $texto=str_replace(',','',$texto); $texto=str_replace('?','',$texto); $texto=str_replace('-','',$texto); $texto=str_replace('(','',$texto); $texto=str_replace(')','',$texto); $texto=str_replace('$','',$texto); $texto=str_replace('_','',$texto); $texto=str_replace('¿','',$texto); $texto=str_replace(':','',$texto); $texto=str_replace('%','',$texto); $texto=str_replace("[",'',$texto); $texto=str_replace("]",'',$texto); $texto=str_replace("*",'',$texto); $texto=str_replace("+",'',$texto); $texto=str_replace("{",'',$texto); $texto=str_replace("}",'',$texto); $texto=str_replace("ç",'',$texto); $texto=str_replace("^",'',$texto); $texto=str_replace("`",'',$texto); $texto=str_replace("¨",'',$texto); $texto=str_replace("º",'',$texto); $texto=str_replace("ª",'',$texto); $texto=str_replace("\\",'',$texto); $texto=str_replace(";",'',$texto); $texto=str_replace("@",'',$texto); $texto=str_replace("~",'',$texto); $texto=str_replace("|",'',$texto); return $texto; } function escapar_caracteres_especiales_javi($t){ $texto=str_replace('"','',$t); $texto=str_replace('°','',$texto); $texto=str_replace("»",'',$texto); $texto=str_replace("¡",'',$texto); $texto=str_replace("=",'',$texto); $texto=str_replace("/",'',$texto); $texto=str_replace("#",'',$texto); $texto=str_replace("'",'',$texto); $texto=str_replace("<",'',$texto); $texto=str_replace(">",'',$texto); $texto=str_replace("&",'',$texto); //$texto=str_replace('.','',$texto); $texto=str_replace('!','',$texto); $texto=str_replace(',','',$texto); $texto=str_replace('?','',$texto); $texto=str_replace('-','',$texto); $texto=str_replace('(','',$texto); $texto=str_replace(')','',$texto); $texto=str_replace('$','',$texto); $texto=str_replace('_','',$texto); $texto=str_replace('¿','',$texto); $texto=str_replace(':','',$texto); $texto=str_replace('%','',$texto); $texto=str_replace("[",'',$texto); $texto=str_replace("]",'',$texto); $texto=str_replace("*",'',$texto); $texto=str_replace("+",'',$texto); $texto=str_replace("{",'',$texto); $texto=str_replace("}",'',$texto); $texto=str_replace("ç",'',$texto); $texto=str_replace("^",'',$texto); $texto=str_replace("`",'',$texto); $texto=str_replace("¨",'',$texto); $texto=str_replace("º",'',$texto); $texto=str_replace("ª",'',$texto); $texto=str_replace("\\",'',$texto); $texto=str_replace(";",'',$texto); $texto=str_replace("@",'',$texto); $texto=str_replace("~",'',$texto); $texto=str_replace("|",'',$texto); return $texto; } function escapar_acentos($t){ $texto=str_replace('á','a',$t); $texto=str_replace('é','e',$texto); $texto=str_replace('í','i',$texto); $texto=str_replace('ó','o',$texto); $texto=str_replace('ú','u',$texto); $texto=str_replace('Á','A',$texto); $texto=str_replace('É','E',$texto); $texto=str_replace('Í','I',$texto); $texto=str_replace('Ó','O',$texto); $texto=str_replace('Ú','U',$texto); return $texto; } function texto_en_minusculas($t){ $texto=strtolower($t); $texto=str_replace('Ñ','ñ',$texto); $texto=str_replace('Á','á',$texto); $texto=str_replace('É','é',$texto); $texto=str_replace('Í','í',$texto); $texto=str_replace('Ó','ó',$texto); $texto=str_replace('Ú','ú',$texto); return $texto; } function cadena_segura($cadena,$longitud){ if ($longitud > 0){ $resultado=substr($cadena, 0, $longitud); } $resultado=htmlentities($resultado, ENT_QUOTES); $resultado=str_replace("\"",""",$resultado);//cambio el \" por " $resultado=str_replace("\'","'",$resultado);//cambio el \' por ' $resultado=str_replace("-","-",$resultado);//escapo el - return $resultado; } function reemplazar_espacios_por_guiones($t){ $texto=str_replace(' ','-',$t); return $texto; } function compactar_guiones($t){ $aux=$t; $longitud=strlen($aux); for ($i=0;$i<$longitud/2;$i++){ $aux=str_replace("--","-",$aux); } return $aux; } function url_amigable($t){//ejemplo: nota mataron a pepito en un tiroteo $id_noticia $aux=compactar_guiones(reemplazar_espacios_por_guiones(texto_en_minusculas(escapar_caracteres_especiales(escapar_acentos($t))))).".html"; $aux=str_replace("-.",".",$aux); return $aux; } function preparar_nombre_url_amigable($t){ $aux=str_replace("/","-",($t)); $aux=str_replace('"',"",($t)); return $aux; } function recuperar_nombre_url_amigable($t){ $aux=str_replace('-'," ",($t)); return $aux; } function url_amigable_shope($t){//ejemplo: nota mataron a pepito en un tiroteo $id_noticia $aux=explode("/",utf8_encode($t)); foreach ($aux as &$trozo){ $trozo=compactar_guiones(reemplazar_espacios_por_guiones(texto_en_minusculas($trozo))); } $aux=implode("/",$aux); return $aux; } function nueva_url_amigable($texto){//ejemplo: Automotores/repuestos/jaime y asociados $id_p.html"); $aux=explode("/",utf8_encode($texto)); foreach ($aux as &$trozo){ $trozo=compactar_guiones(reemplazar_espacios_por_guiones(texto_en_minusculas(escapar_caracteres_especiales(escapar_acentos($trozo))))); } $aux=implode("/",$aux); $aux=str_replace("html",".html",$aux); return $aux; } function capitalizar($t){ if ($t!=""){ $aux=texto_en_minusculas($t); $aux[0]=strtoupper($aux[0]); return $aux; } else { return ($t); } } function titulo($t){ $aux=texto_en_minusculas(escapar_caracteres_especiales($t)); $aux[0]=strtoupper($aux[0]); return $aux; } function keywords($t){ $aux=compactar_guiones(reemplazar_espacios_por_guiones(texto_en_minusculas(escapar_caracteres_especiales(escapar_acentos($t))))); $palabras=explode("-",$aux); $resultado=""; foreach ($palabras as $palabra){ $resultado.= $palabra." "; } $resultado=substr($resultado, 0, -1);//elimino el ultimo espacio $resultado=str_replace(" ",", ",$resultado); return $resultado; } function description($t){ $aux=titulo($t); $aux=substr($aux, 0, 200); $aux[0]=strtoupper($aux[0]); return $aux; }
function redimensionar_imagen_grande($imagen, $nombre_imagen_media, $directorio) { $info_imagen = getimagesize($directorio.$imagen); $alto = $info_imagen[1]; $ancho = $info_imagen[0]; if ($alto>$ancho) { $nuevo_alto=$alto; $nuevo_ancho=$ancho; while ($nuevo_ancho>800) {//$nuevo_ancho = $nuevo_ancho-1; //$nuevo_alto = $nuevo_alto-1; $nuevo_ancho = round(($nuevo_ancho*99)/100); $nuevo_alto = round(($nuevo_alto*99)/100); //echo "nuevo_ancho $nuevo_ancho<br>"; //echo "nuevo_alto $nuevo_alto<br>"; } $entrar="0"; } else { $nuevo_alto=$alto; $nuevo_ancho=$ancho; while ($nuevo_alto>600) {//$nuevo_ancho = $nuevo_ancho-1; //$nuevo_alto = $nuevo_alto-1; $nuevo_ancho = round(($nuevo_ancho*99)/100); $nuevo_alto = round(($nuevo_alto*99)/100); //echo "nuevo_ancho $nuevo_ancho<br>"; //echo "nuevo_alto $nuevo_alto<br>"; } $entrar="1"; } $tipo_imagen = $info_imagen[2]; if ($entrar=="1") { if($ancho > $nuevo_ancho OR $alto > $nuevo_alto) { if(($alto - $nuevo_alto) > ($ancho - $nuevo_ancho)) {//mas alta q ancha $nuevo_ancho = round($ancho * $nuevo_alto / $alto,0) ; } else {//mas ancha q alta $nuevo_alto = round($alto * $nuevo_ancho / $ancho,0); } } else { $nuevo_alto = $alto; $nuevo_ancho = $ancho; } }//end no entrar switch ($tipo_imagen) { case 1: $imagen_nueva = imagecreate($nuevo_ancho, $nuevo_alto); $imagen_vieja = imagecreatefromgif($directorio.$imagen); imagecopyresampled($imagen_nueva, $imagen_vieja, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $ancho, $alto); if (!imagegif($imagen_nueva, $directorio . $nombre_imagen_media)) return false; break; case 2: $imagen_nueva = imagecreatetruecolor($nuevo_ancho, $nuevo_alto); $imagen_vieja = imagecreatefromjpeg($directorio.$imagen); imagecopyresampled($imagen_nueva, $imagen_vieja, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $ancho, $alto); if (!imagejpeg($imagen_nueva, $directorio . $nombre_imagen_media)) return false; break; case 3: $imagen_nueva = imagecreatetruecolor($nuevo_ancho, $nuevo_alto); $imagen_vieja = imagecreatefrompng($directorio.$imagen); imagecopyresampled($imagen_nueva, $imagen_vieja, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $ancho, $alto); if (!imagepng($imagen_nueva, $directorio.$nombre_imagen_media)) return false; break; } return true; }
function redimensionar_imagen_media($imagen, $nombre_imagen_media, $directorio) { $info_imagen = getimagesize($directorio.$imagen); $alto = $info_imagen[1]; $ancho = $info_imagen[0]; if ($alto>$ancho) { $nuevo_alto=$alto; $nuevo_ancho=$ancho; while ($nuevo_ancho>327) {//$nuevo_ancho = $nuevo_ancho-1; //$nuevo_alto = $nuevo_alto-1; $nuevo_ancho = round(($nuevo_ancho*99)/100); $nuevo_alto = round(($nuevo_alto*99)/100); //echo "nuevo_ancho $nuevo_ancho<br>"; //echo "nuevo_alto $nuevo_alto<br>"; } $entrar="0"; } else { $nuevo_alto=$alto; $nuevo_ancho=$ancho; while ($nuevo_alto>119) {//$nuevo_ancho = $nuevo_ancho-1; //$nuevo_alto = $nuevo_alto-1; $nuevo_ancho = round(($nuevo_ancho*99)/100); $nuevo_alto = round(($nuevo_alto*99)/100); //echo "nuevo_ancho $nuevo_ancho<br>"; //echo "nuevo_alto $nuevo_alto<br>"; } $entrar="1"; } $tipo_imagen = $info_imagen[2]; if ($entrar=="1") { if($ancho > $nuevo_ancho OR $alto > $nuevo_alto) { if(($alto - $nuevo_alto) > ($ancho - $nuevo_ancho)) {//mas alta q ancha $nuevo_ancho = round($ancho * $nuevo_alto / $alto,0) ; } else {//mas ancha q alta $nuevo_alto = round($alto * $nuevo_ancho / $ancho,0); } } else { $nuevo_alto = $alto; $nuevo_ancho = $ancho; } }//end no entrar switch ($tipo_imagen) { case 1: $imagen_nueva = imagecreate($nuevo_ancho, $nuevo_alto); $imagen_vieja = imagecreatefromgif($directorio.$imagen); imagecopyresampled($imagen_nueva, $imagen_vieja, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $ancho, $alto); if (!imagegif($imagen_nueva, $directorio . $nombre_imagen_media)) return false; break; case 2: $imagen_nueva = imagecreatetruecolor($nuevo_ancho, $nuevo_alto); $imagen_vieja = imagecreatefromjpeg($directorio.$imagen); imagecopyresampled($imagen_nueva, $imagen_vieja, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $ancho, $alto); if (!imagejpeg($imagen_nueva, $directorio . $nombre_imagen_media)) return false; break; case 3: $imagen_nueva = imagecreatetruecolor($nuevo_ancho, $nuevo_alto); $imagen_vieja = imagecreatefrompng($directorio.$imagen); imagecopyresampled($imagen_nueva, $imagen_vieja, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $ancho, $alto); if (!imagepng($imagen_nueva, $directorio.$nombre_imagen_media)) return false; break; } return true; } function redimensionar_imagen_chica($imagen, $nombre_imagen_media, $directorio) { $info_imagen = getimagesize($directorio.$imagen); $alto = $info_imagen[1]; $ancho = $info_imagen[0]; if ($alto>$ancho) { $nuevo_alto=$alto; $nuevo_ancho=$ancho; while ($nuevo_ancho>159) {//$nuevo_ancho = $nuevo_ancho-1; //$nuevo_alto = $nuevo_alto-1; $nuevo_ancho = round(($nuevo_ancho*99)/100); $nuevo_alto = round(($nuevo_alto*99)/100); //echo "nuevo_ancho $nuevo_ancho<br>"; //echo "nuevo_alto $nuevo_alto<br>"; } $entrar="0"; } else { $nuevo_alto=$alto; $nuevo_ancho=$ancho; while ($nuevo_alto>119) {//$nuevo_ancho = $nuevo_ancho-1; //$nuevo_alto = $nuevo_alto-1; $nuevo_ancho = round(($nuevo_ancho*99)/100); $nuevo_alto = round(($nuevo_alto*99)/100); //echo "nuevo_ancho $nuevo_ancho<br>"; //echo "nuevo_alto $nuevo_alto<br>"; } $entrar="1"; } $tipo_imagen = $info_imagen[2]; if ($entrar=="1") { if($ancho > $nuevo_ancho OR $alto > $nuevo_alto) { if(($alto - $nuevo_alto) > ($ancho - $nuevo_ancho)) {//mas alta q ancha $nuevo_ancho = round($ancho * $nuevo_alto / $alto,0) ; } else {//mas ancha q alta $nuevo_alto = round($alto * $nuevo_ancho / $ancho,0); } } else { $nuevo_alto = $alto; $nuevo_ancho = $ancho; } }//end no entrar switch ($tipo_imagen) { case 1: $imagen_nueva = imagecreate($nuevo_ancho, $nuevo_alto); $imagen_vieja = imagecreatefromgif($directorio.$imagen); imagecopyresampled($imagen_nueva, $imagen_vieja, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $ancho, $alto); if (!imagegif($imagen_nueva, $directorio . $nombre_imagen_media)) return false; break; case 2: $imagen_nueva = imagecreatetruecolor($nuevo_ancho, $nuevo_alto); $imagen_vieja = imagecreatefromjpeg($directorio.$imagen); imagecopyresampled($imagen_nueva, $imagen_vieja, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $ancho, $alto); if (!imagejpeg($imagen_nueva, $directorio . $nombre_imagen_media)) return false; break; case 3: $imagen_nueva = imagecreatetruecolor($nuevo_ancho, $nuevo_alto); $imagen_vieja = imagecreatefrompng($directorio.$imagen); imagecopyresampled($imagen_nueva, $imagen_vieja, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $ancho, $alto); if (!imagepng($imagen_nueva, $directorio.$nombre_imagen_media)) return false; break; } return true; }
function resizeImage($image,$width,$height,$scale) { $newImageWidth = ceil($width * $scale); $newImageHeight = ceil($height * $scale); $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight); $source = imagecreatefromjpeg($image); imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height); imagejpeg($newImage,$image,99); chmod($image, 0777); return $image; }
function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){ $newImageWidth = ceil($width * $scale); $newImageHeight = ceil($height * $scale); $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight); $source = imagecreatefromjpeg($image); imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height); imagejpeg($newImage,$thumb_image_name,99); chmod($thumb_image_name, 0777); return $thumb_image_name; }
function getHeight($image) { $sizes = getimagesize($image); $height = $sizes[1]; return $height; }
function getWidth($image) { $sizes = getimagesize($image); $width = $sizes[0]; return $width; }
?>
|