DeterminaPagina(); $this->DeterminaInclude(); } private function DeterminaPagina() { $URL = $_SERVER['REQUEST_URI']; $URL = substr($URL, strlen(__BASEURL__)); $D = strpos($URL, "?"); if($D !== false) $URL = substr($URL, 0, strpos($URL, "?")); $this->Estensione = substr($URL, 1 + strrpos($URL, ".")); $URL = substr($URL, 0, strrpos($URL, ".")); $this->Parametri = explode("/", $URL); $this->Pagina = array_shift($this->Parametri); if($this->Pagina == "admin") { $this->Admin = true; $this->Pagina = array_shift($this->Parametri); if($this->Pagina == "") { $this->Pagina = "index"; } $this->Metodo = array_shift($this->Parametri); if($this->Metodo == "") { $this->Metodo = "home"; } } else { if($this->Pagina == "") { $this->Pagina = "index"; } $this->Metodo = array_shift($this->Parametri); if($this->Metodo == "") { $this->Metodo = "home"; } } } private function DeterminaInclude() { $this->DirPagina = __BASEDIR__ . "pagine" . __DS__; if($this->Admin) { $this->DirPagina .= "admin" . __DS__; } $this->DirPagina .= $this->Pagina; $this->DirPagina .= ".php"; } public function pars($T) { $T = addslashes($T); $T = trim($T); $T = htmlspecialchars($T); return $T; } private function GDVersion() { if( !in_array('gd', get_loaded_extensions()) ) return 0; elseif( $this->isGD2supported() ) return 2; else return 1; } private function isGD2supported() { global $GD2; if( isset($GD2) && $GD2 ) return $GD2; else{ $php_ver_arr = explode('.', phpversion()); $php_ver = intval($php_ver_arr[0])*100+intval($php_ver_arr[1]); if( $php_ver < 402 ){ // PHP <= 4.1.x $GD2 = in_array('imagegd2',get_extension_funcs("gd")); } elseif( $php_ver < 403 ){ // PHP = 4.2.x $im = @imagecreatetruecolor(10, 10); if( $im ){ $GD2 = 1; @imagedestroy($im); } else $GD2 = 0; } else{ // PHP = 4.3.x $GD2 = function_exists('imagecreatetruecolor'); } } return $GD2; } public function OutThumb($dir, $img, $w, $h, $nome = '') { $src = $dir . $img; $size = getimagesize($src); # echo $src; $this->setMemoryForImage($src); if( $size[2] == 2 ){$im = imagecreatefromjpeg($src) or die("prova");} elseif( $size[2] == 1 ){$im = imagecreatefromgif($src) or die("prova");} elseif( $size[2] == 3 ){$im = imagecreatefrompng($src) or die("prova");} else return 1; $newwidth = $size[0]; $newheight = $size[1]; if( $newwidth > $w ){ $newheight = ($w / $newwidth) * $newheight; $newwidth = $w; } if( $newheight > $h ){ $newwidth = ($h / $newheight) * $newwidth; $newheight = $h; } if( ($this->GDVersion() == 2) AND ($size[2] != 1) ){ $new = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($new, $im, 0, 0, 0, 0, $newwidth, $newheight, $size[0], $size[1]); } else{ $new = imagecreate($newwidth, $newheight); imagecopyresized($new, $im, 0, 0, 0, 0, $newwidth, $newheight, $size[0], $size[1]); } # header('Content-Type: ' . $size['mime']); if($nome == '') $dest = $dir . $img; else $dest = $dir . $nome; if( $size[2] == 2 ){@imagejpeg($new, $dest, 100);} elseif( $size[2] == 1 ){@imagegif($new, $dest);} elseif( $size[2] == 3 ){@imagepng($new, $dest);} @imagedestroy($im); @imagedestroy($new); chmod($dest, 0755); } private function setMemoryForImage( $filename ) { $imageInfo = getimagesize($filename); $MB = 1048576; // number of bytes in 1M $K64 = 65536; // number of bytes in 64K $TWEAKFACTOR = 1.5; // Or whatever works for you $memoryNeeded = round( ( $imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + $K64 ) * $TWEAKFACTOR ); //ini_get('memory_limit') only works if compiled with "--enable-memory-limit" also //Default memory limit is 8MB so well stick with that. //To find out what yours is, view your php.ini file. $memoryLimit = 8 * $MB; if (function_exists('memory_get_usage') && memory_get_usage() + $memoryNeeded > $memoryLimit) { $newLimit = $memoryLimitMB + ceil( ( memory_get_usage() + $memoryNeeded - $memoryLimit ) / $MB ); ini_set( 'memory_limit', $newLimit + 3000000 . 'M' ); return true; } else return false; } public function CreaSelect($Array, $Valore) { $Ret = ""; foreach($Array as $A) { $Ret .= "