ADMIN_IMG"; //img_admin(); function img_admin() { global $DATI; if($_GET["img_admin"] == "SI" and $_GET[id] != "" and $_GET[key] != "") { //cancello l' immagine $IMM = imm_genera_nome($_GET[id],$_GET[key]); @unlink($IMM[nome]); @unlink($IMM[nome_t]); //print d($IMM); } } function gall_admin($img,$parola) { global $DATI; if($_GET["img_admin"] == "SI") { print "Aggiorna"; } if($_GET["img_admin"] == "SI" and $_GET[id] != "" and $_GET[key] != "") { //cancello l' immagine $IMM = imm_genera_nome($img,$_GET[key]); @unlink($IMM[nome]); @unlink($IMM[nome_t]); //print d($IMM); } } //########################################################################## //################ FUNZIONI POPUP ################################ //########################################################################## function popup_a($PARAM=NULL,$width=0,$height=0) { popup_init(); global $MENU,$DATI,$CONF; //due tipi di parametri semplici e completi if(is_array($PARAM)) $CONFIGURAZIONE = $PARAM; else { if($PARAM != NULL) $CONFIGURAZIONE["popup_link"] = $PARAM; else $PARAM = $CONFIGURAZIONE["popup_link"]; } $CONFIGURAZIONE = array_merge($DATI,$CONFIGURAZIONE); //d($CONFIGURAZIONE); if($CONFIGURAZIONE["popup_tipo"] == "CENTRATO") gall_javascipt_popup(); if($width == 0) $width = $CONFIGURAZIONE["popup_width"]; if($height == 0) $height = $CONFIGURAZIONE["popup_height"]; if($CONFIGURAZIONE["popup_tipo"] == "STANDARD") return ('javascript:OnClick=window.open(\''.$CONFIGURAZIONE["popup_link"].'\',\''.popup_titolo().'\',\'width='.$width.',height='.$height.'\');void(\'\');"'); if($CONFIGURAZIONE["popup_tipo"] == "CENTRATO") return ('javascript:OnClick=popc(\''.$CONFIGURAZIONE["popup_link"].'\',\''.popup_titolo().'\',\''.$width.'\',\''.$height.'\');void(\'\');"'); } function popup_img($PARAM=NULL,$width=0,$height=0) { popup_init(); global $MENU,$DATI,$CONF; //due tipi di parametri semplici e completi if(is_array($PARAM)) $CONFIGURAZIONE = $PARAM; else { if($PARAM != NULL) $CONFIGURAZIONE["popup_img"] = $PARAM; else $PARAM = $CONFIGURAZIONE["popup_img"]; } $CONFIGURAZIONE = array_merge($DATI,$CONFIGURAZIONE); if($CONFIGURAZIONE["popup_tipo"] == "CENTRATO") gall_javascipt_popup(); //trovo il link $CONFIGURAZIONE["popup_link"] = genera_link($CONFIGURAZIONE["popup_pagina"],$CONFIGURAZIONE["lang"],"img=".$CONFIGURAZIONE["popup_img"]); //dimensione finestra come dimensione immagine $dim_tmp = @getimagesize($CONFIGURAZIONE["popup_img"]); if($width == 0) $width = $dim_tmp[0]; if($height == 0) $height = $dim_tmp[1]; if($CONFIGURAZIONE["popup_tipo"] == "STANDARD") return ('javascript:OnClick=window.open(\''.$CONFIGURAZIONE["popup_link"].'\',\''.popup_titolo().'\',\'width='.$width.',height='.$height.'\');void(\'\');"'); if($CONFIGURAZIONE["popup_tipo"] == "CENTRATO") return ('javascript:OnClick=popc(\''.$CONFIGURAZIONE["popup_link"].'\',\''.popup_titolo().'\',\''.$width.'\',\''.$height.'\');void(\'\');"'); } function popup_img_visualizza() { popup_init(); global $DATI; //CODICE X TEMPLATE POPUP //Stampa il link con l' immagine $out .= ''; $alt2=encode($DATI["gall_txt_ingrandimento"]); $img = $_GET["img"]; if(is_file($img)) $out .= ''.$alt2.''; else $out .= $DATI["popup_img_error"]; $out .= ''; return $out; } //########################################################################## //################ FUNZIONI GALLERIA ############################# //########################################################################## //genera codice per visualizzare l' immagine per la funzione gall, va' messa nel template della galleria function gall_visualizza_immagine() { gall_init(); global $DATI; //CODICE X TEMPLATE GALLERIA //Stampa il link con l' immagine $out .= ''; $alt2=encode($DATI["gall_txt_ingrandimento"]); $NOME = gall_nome($_GET["img"],$_GET["imgref"]); $img1 = $NOME["nome"]; $img2 = $DATI["path_rel"].$img1; //if(is_file($img1)) $out .= ''.$alt2.''; $out .= ''; return $out; } // funzione per centrare il popup function gall_javascipt_popup() { global $DATI; //imposto che c'e' il popup in questa pagina if ($DATI["gal_popup"] != "SI") { //imposto che ho messo il javascript $DATI["gal_popup"] = "SI"; //metto il javascript $codice = " function popc(nome, titolo, lar, alt, feat){ var wwdt = screen.width; var hhgt = screen.height; var x = Math.round( (wwdt / 2) - (lar / 2) ); var y = Math.round( (hhgt / 2) - (alt / 2) ); window.open(nome, titolo, 'width=' + lar + ',height=' + alt + ',left=' + x + ',screenX=' + x + ',top=' + y + ',screenY=' + y + ',' + feat); }"; //metto il codice javascript($codice); } } //gnerica function gall_titolo() { global $DATI; if($DATI["gall_multifinestra"] == "SI") return (mt_rand(1,100000)); else return("GALL"); } function popup_titolo() { //popup_init(); global $DATI; if($DATI["popup_multifinestra"] == "SI") return (mt_rand(1,100000)); else return("POPUP"); } //funzione per galleria //imm e la funzione di generazione delle immagini, gli va' passata anche la parola eventualmente function gall_bordo($img=NULL,$img_box=NULL) { $CONFIGURAZIONE["gall_img"] = $img; $CONFIGURAZIONE["gall_bordo"] = $img_box; return gall($CONFIGURAZIONE); } function gall($PARAM=NULL,$tipo=NULL,$alt_param=NULL,$gall_imgref=NULL) { gall_init(); global $INDI,$CONF, $DATI, $lang, $pagina, $PRESA; //in presa ho l' ultima parola presa if(is_array($PARAM)) $CONFIGURAZIONE = $PARAM; else { if($PARAM != NULL) $CONFIGURAZIONE["gall_img"] = $PARAM; if($tipo != NULL) $CONFIGURAZIONE["gall_tipo"] = $tipo; if($alt_param != NULL) $CONFIGURAZIONE["gall_txt_miniatura"] = $alt_param; if($gall_imgref != NULL) $CONFIGURAZIONE["gall_imgref"] = $gall_imgref; } //faccio il merge e metto i dati fdi default se presenti $CONFIGURAZIONE = array_merge($DATI,$CONFIGURAZIONE); // print_r($CONFIGURAZIONE); //metto il javascript per centrare il popup ?? mettere opzione if($CONFIGURAZIONE["gall_tipo"] != "NOING" AND $CONFIGURAZIONE["gall_tipo"] != "SOLOMIN") gall_javascipt_popup(); //sistemo le immagini se specificato ???? img_resize($CONFIGURAZIONE["gall_img"],$CONFIGURAZIONE["gall_img"]); //prendo il link e se non ne ha uno nuovo lo genera da indi o no //$link = genera_link($CONFIGURAZIONE["gall_pagina"],$DATI["lang"],"img=".urlencode($CONFIGURAZIONE["gall_img"])."&imgref=".urlencode($CONFIGURAZIONE[gall_imgref])); //d($CONFIGURAZIONE["gall_img"]); if($CONF["INDI"] == "SI") $link = genera_link($CONFIGURAZIONE["gall_pagina"],$DATI["lang"],"img=".$CONFIGURAZIONE["gall_img"]."&imgref=".$CONFIGURAZIONE[gall_imgref]); else $link = genera_link($CONFIGURAZIONE["gall_pagina"],$DATI["lang"],"img=".urlencode($CONFIGURAZIONE["gall_img"])."&imgref=".urlencode($CONFIGURAZIONE[gall_imgref])); //genero il nome //se non sono nel sistema indi //if($DATI["INDI"] != "SI") { // $nome_immagine = ""; //} //ridimensiono l' immagine $IMM = imm($CONFIGURAZIONE); if ($IMM) { //genero il nome della finestra (non funziona su IE ?? $titolo = gall_titolo(); //controllo testo alt $alt = $CONFIGURAZIONE["gall_txt_miniatura"]; //else if($tipo != "NOING" AND $tipo != "SOLOMIN") $alt=encode($DATI["gall_txt_miniatura"]); //creo il codice per l' immagine $img = ''.$alt.''; //torno il codice if($CONFIGURAZIONE["gall_tipo"] != "NOING" AND $CONFIGURAZIONE["gall_tipo"] != "SOLOMIN") return (''.$img.''); else return ($img); } else return FALSE; } // TEMPLATE GALLERIA //###################################################### //genera il nome dell' immagine esteso (non piu' usato" function imm_genera_nome($originale,$nome) { $nome_out = explode(".",$originale); $nome_out = explode("/",$nome_out[0]); $nome_out = $nome_out[sizeof($nome_out)-1]; $nome_pulito = $nome_out; // $nome_out = $nome_out."_".$nome; if($nome == "") $nome = "ELAB_$nome_pulito"; $nome_out = $nome; $nome_out = trim($nome_out); $nome_out = str_replace (" ","_",$nome_out); $nome_out = str_replace ("+","_",$nome_out); $nome_out = str_replace ("/","_",$nome_out); $nome_out = str_replace ("\\","_",$nome_out); $nome_out_t = $nome_out."_t"; $OUT[nome] = str_replace ($nome_pulito,$nome_out,$originale); $OUT[nome_t] = str_replace ($nome_pulito,$nome_out_t,$originale); return $OUT; } function gall_nome($originale=NULL,$gall_imgref=NULL) { global $CONF; //$originale = str_replace(" ","_",$originale); $nome_id = abs(crc32(md5($originale))); if($gall_imgref != NULL) $nome_id = $nome_id + abs(crc32(md5($gall_imgref))); //$nome_id2 = abs(crc32(md5($variazione))); $nome_out = explode(".",$originale); $nome_out = explode("/",$nome_out[0]); $nome_out = $nome_out[sizeof($nome_out)-1]; $nome_pulito = $nome_out; $OUT[nome] = $CONF[dir_indi].$CONF[dir_indi_img].$nome_pulito."_".$nome_id.".jpg"; $OUT[nome_t] = $CONF[dir_indi].$CONF[dir_indi_img].$nome_pulito."_".$nome_id."_t.jpg"; //d($OUT); return $OUT; } //generica per il ridimensionamento immagini function img_resize($from,$to,$w=1200,$h=1200,$q=98) { global $DATI; if ($DATI["img_fix"] != "SI") return; if (!is_file($from)) return; if (!is_file($to)) return; list($width, $height) = @getimagesize($from); if($width > $w or $height > $h) { $maxx = $h; $maxy = $w; $source_image_URL = $from; $source_image = @imagecreatefromjpeg($source_image_URL); list($width, $height) = @getimagesize($source_image_URL); $percent1 = $width / $maxx; $percent2 = $height / $maxy; $percent = max($percent1,$percent2); $new_eight = round($height /$percent); $new_width = round($width /$percent); $dest_image = @imagecreatetruecolor($new_width, $new_eight); @imagecopyresampled ($dest_image, $source_image, 0, 0, 0, 0, $new_width, $new_eight, $width, $height); @imagejpeg($dest_image, $to, $q); d("
IMG: $to -> SISTEMATA","IMG_RESIZE"); } else return FALSE; } function imm($CONFIGURAZIONE) { //global $DATI; //prova ad allungare il tempo di esecuzione @set_time_limit(50000); $originale = $CONFIGURAZIONE["gall_img"]; //controllo se c'e' immagine principale; if(!is_file($originale)) return FALSE; //GENERO NOME $NOME = gall_nome($CONFIGURAZIONE["gall_img"],$CONFIGURAZIONE["gall_imgref"]); $tipo = $CONFIGURAZIONE["gall_tipo"]; $qg = $CONFIGURAZIONE[gall_q_grande]; $qp = $CONFIGURAZIONE[gall_q_miniatura]; $bordo = $CONFIGURAZIONE[gall_bordo]; $scritta = $CONFIGURAZIONE[gall_scritta]; $max_h = $CONFIGURAZIONE[gall_max_h]; $max_w = $CONFIGURAZIONE[gall_max_w]; //genero il nome in base al parametro nome passato //$NOME = @imm_genera_nome($originale,$nome); //controllo se ci sono gia' i file //if (@is_file($NOME[nome]) and @is_file($NOME[nome_t])) { if (@filemtime($NOME[nome]) >= @filemtime($originale) AND @filemtime($NOME[nome_t]) >= @filemtime($originale)) { $IMM[nome_g] = $NOME[nome]; $IMM[nome_t] = $NOME[nome_t]; $G = getimagesize($NOME[nome]); $P = getimagesize($NOME[nome_t]); $IMM[hg] = $G[1]; $IMM[wg] = $G[0]; $IMM[ht] = $P[1]; $IMM[wt] = $P[0]; return $IMM; //con le dimensioni giuste } //Immagine originale $immo = $originale; $immo = @imagecreatefromjpeg($immo); $immow = @imagesx($immo); $immoh = @imagesy($immo); //Non fa' la miniatura se e' specificato il parametro //if($tipo != "NOING" AND $tipo != "SOLOMIN") { //Controllo proporzioni per ridimensionamento immagine grande $percent1 = $immow / $max_w; $percent2 = $immoh / $max_h; $percent = max($percent1,$percent2); //trovo dimensioni immagine grande $h = round($immoh / $percent); $w = round($immow / $percent); //creo immagine $dest_image = @imagecreatetruecolor($w, $h); @imagecopyresampled ($dest_image, $immo, 0, 0, 0, 0, $w, $h, $immow, $immoh); //eventualmente scrivo qualcosa sopra se c'e' il file if(is_file($scritta)) { //margine dal bordo if($CONFIGURAZIONE[gall_margine] == "") $margine = "5"; else $margine = $CONFIGURAZIONE[gall_margine]; //posizione in altezza (alto|basso|centro) if($CONFIGURAZIONE[gall_posh] == "") $posh = "basso"; else $posh = $CONFIGURAZIONE[gall_posh]; //posizione in altezza (sinistra|basso|destra) if($CONFIGURAZIONE[gall_posw] == "") $posw = "destra"; else $posw = $CONFIGURAZIONE[gall_posw]; $scritta = @imagecreatefrompng($scritta); $scrittaw = imagesx($scritta); $scrittah = imagesy($scritta); //posizione orizzontale //$posw = $w/2-($scrittaw/2); //CENTRO IN BASSO if($posw == "destra") $posw = $w-$scrittaw-$margine; if($posw == "centro") $posw = $w/2-($scrittaw/2); if($posw == "sinistra") $posw = $margine; //posizione verticale if($posh == "alto") $posh = $margine; if($posh == "centro") $posh = $h/2-($scrittah/2); if($posh == "basso") $posh = ($h-$scrittah-$margine); imageAlphaBlending($scritta, true); imageSaveAlpha($scritta, true); @imagecopy ($dest_image, $scritta,$posw,$posh,0,0,$scrittaw, $scrittah); } //scrivo immagine grande @imagejpeg($dest_image,$NOME[nome],$qg); //} //fine controllo imamgine grande //faccio miniatura come l' immagine con il bordo if(is_file($bordo)) { $bordo = @imagecreatefrompng($bordo); $bordow = imagesx($bordo); $bordoh = imagesy($bordo); } else { $bordow = $CONFIGURAZIONE[gall_min_w]; $bordoh = $CONFIGURAZIONE[gall_min_h]; } //trovo la dimensione massima dellaa miniatura $percent1t = $immow / $bordow; $percent2t = $immoh / $bordoh; $percentt = min($percent1t,$percent2t); $ht = round($immoh / $percentt); $wt = round($immow / $percentt); //ridimensiono miniatura $tmp_t = @imagecreatetruecolor($bordow, $bordoh); $sh = -($ht-$bordoh)/2; $sw = -($wt-$bordow)/2; if ($ht == $bordoh) $sh = 0; if ($wt == $bordow) $sw = 0; @imagecopyresampled ($tmp_t, $immo, $sw, $sh, 0, 0, $wt, $ht, $immow, $immoh); //imagejpeg($tmp_t,$nome_out_t."a.jpg",75); //sommo per il bordo se c'e' if($bordo) @imagecopy ($tmp_t, $bordo,0,0,0,0,$bordow, $bordoh); //scrive la miniatura @imagejpeg($tmp_t,$NOME[nome_t],$qp); $IMM[nome_g] = $NOME[nome]; $IMM[nome_t] = $NOME[nome_t]; $IMM[hg] = $h; $IMM[wg] = $w; $IMM[ht] = $bordoh; $IMM[wt] = $bordow; return $IMM; } ?>