$value) $$key = $value; ?>0){ $new_width = $tamany; if($tamany_h>0)$new_height=$tamany_h; else $new_height = unpercent(percent($tamany,$width),$height); } else if($tamany_h>0){ $new_height = $tamany_h; $new_width = unpercent(percent($tamany_h,$height),$width); } //si el tamany final s superior a l'original no la redimensionem if($new_width>$width || $new_height>$height){ return; } if($tam['mime']=="image/jpeg") $image=imagecreatefromjpeg($foto); if($tam['mime']=="image/gif") $image=imagecreatefromgif($foto); if($tam['mime']=="image/png") $image=imagecreatefrompng($foto); $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_resized,$foto_petita,90); imagedestroy($image_resized); } //versio nova de tallar fotos function tallar_foto($foto,$w,$h) { global $directori; list($width, $height) = getimagesize($foto); $abc = imagecreatefromjpeg($foto); $def = imagecreatetruecolor($w, $h); if($w==$width){ $y_tall=0; $x_tall=0; } else if($h==$height){ $y_tall=0; $x_tall=($width-$w)/2; } imagecopymerge($def,$abc,0,0,$x_tall,$y_tall,$w,$h,100); imagejpeg($def, $foto, 100); ImageDestroy($abc); } function unpercent($percent, $whole) { return (real)(($percent * $whole) / 100); } function percent($p, $w) { return (real)(100 * ($p / $w)); } function nom_per_rewrite_fotos($nom){ $rewrite = strtolower(str_replace(" ","-",$nom)); $rewrite=str_replace("","o",$rewrite); $rewrite=str_replace("","o",$rewrite); $rewrite=str_replace("","i",$rewrite); $rewrite=str_replace("","i",$rewrite); $rewrite=str_replace("","i",$rewrite); $rewrite=str_replace("","u",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("--","-",$rewrite); $rewrite = preg_replace("/[^0-9A-Za-z.\-_]/","",$rewrite); $rewrite=str_replace("--","-",$rewrite); $rewrite=str_replace("--","-",$rewrite); $rewrite=str_replace("--","-",$rewrite); return $rewrite; } function nom_per_rewrite($nom){ $prohibides=array('los','las','del','la','el','un','a','de','en','por','y','e','o','ni','u','que','no','si','asi','ahi','alli'); $rewrite = strtolower(str_replace(" ","-",trim($nom))); $rewrite=str_replace("","c",$rewrite); $rewrite=str_replace("","n",$rewrite); $rewrite=str_replace("","o",$rewrite); $rewrite=str_replace("","o",$rewrite); $rewrite=str_replace("","i",$rewrite); $rewrite=str_replace("","i",$rewrite); $rewrite=str_replace("","i",$rewrite); $rewrite=str_replace("","u",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("--","-",$rewrite); $rewrite = preg_replace("/[^0-9A-Za-z\-_]/","",$rewrite); for($i=0;$i index.php?valor1=x&valor2=y $parms=explode("&",$_SERVER['QUERY_STRING']); //volem eliminar valor idioma. for($i=0;$i aixo serveix per que despres de insertar el primer parametre afegim & per tornar a ficar el seguent parametre if($parametres) $parametres.="&"; //afegim a parametres nom valor i valor $parametres.=$key."=".$value; } } if($parametres) $url_actual.="?".$parametres."&"; else $url_actual.="?"; return $url_actual; //exemple: //index.php?id_producte=3&idioma=ca&categoria=5 //ens retorna: //index.php?id_producte=3&categoria=5 } function format_bytes($size) { $units = array(' B', ' KB', ' MB', ' GB', ' TB'); for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024; return round($size, 2).$units[$i]; } //friendly url function friendly_url($nom){ $prohibides=array('los','las','del','la','el','un','a','de','en','por','y','e','o','ni','u','que','no','si','asi','ahi','alli'); $rewrite = strtolower(str_replace(" ","-",trim($nom))); $rewrite=str_replace("","c",$rewrite); $rewrite=str_replace("","n",$rewrite); $rewrite=str_replace("","o",$rewrite); $rewrite=str_replace("","o",$rewrite); $rewrite=str_replace("","i",$rewrite); $rewrite=str_replace("","i",$rewrite); $rewrite=str_replace("","i",$rewrite); $rewrite=str_replace("","u",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","a",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("","e",$rewrite); $rewrite=str_replace("--","-",$rewrite); $rewrite = preg_replace("/[^0-9A-Za-z\-_]/","",$rewrite); for($i=0;$i