//Path fisici e valori di default $PATH_MEDIA="/media/fileroot"; $PATH_ERR="http://atlantide.virgilio.it?"; $NOME_HOST="multimedia.community.virgilio.it"; $community="mu"; $TQUALITY=50; // Classificazione degli errori $NOERR="0"; $ERR_COOKIE="1"; $ERR_NONICK="2"; $ERR_NOVALIDNICK="3"; $ERR_PM="4"; // questo tipo di errore al momento non è contemplato $ERR_NOTIPO_FILE="5"; $ERR_NO_EXT="6"; $ERR_NO_FILE="7"; $ERR_EXT="8"; $ERR_UPLOAD="9"; $ERR_TIPO="10"; $ERR_DIM="11"; //Dimensioni massime dei file in bytes( 0 = immagini, 1 = audio , 2 = video ) $MAXDIM[0]=30720; $MAXDIM[1]=307200; $MAXDIM[2]=2048000; // Estensioni permesse per i vari files ( 0,x = immagini, 1,x = audio , 2,x = video ) $ESTENSIONI[0][0]="jpg"; $ESTENSIONI[0][1]="jpeg"; $ESTENSIONI[0][2]="gif"; $ESTENSIONI[1][0]="aif"; $ESTENSIONI[1][1]="aifc"; $ESTENSIONI[1][2]="aiff"; $ESTENSIONI[1][3]="au"; $ESTENSIONI[1][4]="ra"; $ESTENSIONI[1][5]="ram"; $ESTENSIONI[1][6]="snd"; $ESTENSIONI[1][7]="wav"; $ESTENSIONI[1][8]="mp3"; $ESTENSIONI[1][9]="m3u"; $ESTENSIONI[1][10]="rm"; $ESTENSIONI[1][11]="rmm"; $ESTENSIONI[2][0]="m1v"; $ESTENSIONI[2][1]="mp2"; $ESTENSIONI[2][2]="mpa"; $ESTENSIONI[2][3]="mpe"; $ESTENSIONI[2][4]="mpeg"; $ESTENSIONI[2][5]="mpg"; $ESTENSIONI[2][6]="mov"; $ESTENSIONI[2][7]="qt"; $ESTENSIONI[2][8]="avi"; $result=""; $errore=$NOERR; // Url a cui rimandare il browser in caso di caricamento avvenuto if ($_POST[urlOK] != "") { $urlok = $_POST[urlOK]; if (substr_count($urlok, "?") == 0) { $urlok = $urlok . "?"; } } else { $urlok = $PATH_ERR; } // Url a cui rimandare il browser in caso di errore if ($_POST[urlNOK] != "") { $urlnok = $_POST[urlNOK]; if (substr_count($urlnok, "?") == 0) { $urlnok = $urlnok . "?"; } } else { $urlnok = $PATH_ERR; } // Destinazione file (al momento questo campo non è popolato) if ($_POST[des_foto] != "") { $des_foto = $_POST[des_foto]; } else { $des_foto = ""; } // Se il campo community è popolato lo usa, altrimenti lascia il valore di default if ($_POST[community] != "") { $community = $_POST[community]; } // CONTROLLO COOKIE // Verifico la presenza del cookie di servizio if ($_COOKIE[PAAA_SERV_MUALL] == "") { $errore = $ERR_COOKIE; } else { $cookienick = "," . recupero_dati(NICK_LIST,$_COOKIE[PAAA_SERV_MUALL]) . ","; $nickname = $_POST[Nickname]; // Verifico che sia stato inviato il campo nickname e che nel cookie di servizio ci sia almeno un nickname if ($cookienick == ",," or $nickname == ""){ $errore = $ERR_NONICK; } else { // Verifico che il nickname inviato sia tra quelli registrati nel cookie di servizio if (substr_count($cookienick, ",$nickname,") == 0) { $errore = $ERR_NOVALIDNICK; } } } // Controllo la consistenza dei dati mandati dal FORM if ($errore == $NOERR) { // Verifico che il campo tipo_file non sia vuoto if ($_POST[tipo_file] == "") { $errore = $ERR_NOTIPO_FILE; } else { // Verifico che il campo estensione non sia vuoto if ($_POST[ext] == "") { $errore = $ERR_NO_EXT; } else { $estensione = strtolower($_POST[ext]); // Verifico che sia stato inviato un file if (!is_file($_FILES[file][tmp_name])) { $errore = $ERR_NO_FILE; } else { // Controllo il tipo di file inviato (foto/audio/video) $tipothumbnail = 0; if ($_POST[tipo_file] == "foto") { $tipo = 0; $profilo = "f00"; $tipothumbnail = 2; } elseif ($_POST[tipo_file] == "video") { $tipo = 2; $profilo = "v00"; } elseif ($_POST[tipo_file] == "audio") { $tipo = 1; $profilo = "a00"; } elseif (substr($_POST[tipo_file] , 0 , 5 ) == "lamia") { $tipo = 0; $profilo = "f0" . substr($_POST[tipo_file] , -1); $tipothumbnail = 1; } else { $errore = $ERR_NOTIPO_FILE; } } } } } // Controllo della dimensione e dell'estensione dei files if ($errore == $NOERR) { $trovato = false; for ($ne = 0; $ne <= 12; $ne++ ) { if ($estensione == $ESTENSIONI[$tipo][$ne]) { $trovato = true; } } if ($trovato == false) { $errore = $ERR_EXT; } else { if (filesize($_FILES[file][tmp_name]) == 0 or filesize($_FILES[file][tmp_name]) > $MAXDIM[$tipo]) { $errore = $ERR_DIM; } } } // Inizio a processare i files inviati if ($errore == $NOERR) { // Creo la struttura di directory ed il percorso del file $outpath = "$PATH_MEDIA/$community"; if(!is_dir($outpath)) mkdir($outpath, 0777); $outpath = $outpath . "/" . $nickname{0}; if(!is_dir($outpath)) mkdir($outpath, 0777); $outpath = $outpath . "/" . substr($nickname , -2); if(!is_dir($outpath)) mkdir($outpath, 0777); $outpath = $outpath . "/" . $nickname; if(!is_dir($outpath)) mkdir($outpath, 0777); $outpath = $outpath . "/" . $nickname . ","; $outfile = $outpath . $profilo . "." . $estensione; // Copia del file if (copy($_FILES[file][tmp_name] , $outfile ) ) { //La copia del file nella directory di destinazione è avvenuta correttamente // Creazione dei ThumbNail if ($tipothumbnail >> 0) { $thumbfile = $outpath . "i" . substr($profilo , -2) . ".jpg"; $esegui="convert -colorspace RGB -quality " . $TQUALITY . " -geometry 64x64 " . $outfile . "[0] " . $thumbfile; exec($esegui); if ($tipothumbnail >> 1) { $thumbfile = $outpath . "t" . substr($profilo , -2) . ".jpg"; $esegui="convert -colorspace RGB -quality " . $TQUALITY . " -geometry 160x160 " . $outfile . "[0] " . $thumbfile; exec($esegui); } } // Creo il file HTML $fileout=fopen ("$outpath$profilo.html" ,"w"); if($fileout) { fwrite($fileout,"\n"); fwrite($fileout,"
\n"); fwrite($fileout,"\n"); fwrite($fileout,""); fclose($fileout); } // Cancella eventuali versioni obsolete del file for ($ne = 0; $ne <= 12; $ne++ ) { if ($ESTENSIONI[$tipo][$ne] != $estensione and is_file($outpath . $profilo . "." . $ESTENSIONI[$tipo][$ne])) { unlink($outpath . $profilo . "." . $ESTENSIONI[$tipo][$ne]); } } // Crea il path da caricare sul profile manager $filename = "/contenuti/$nickname,$profilo.$estensione"; } else { //Errore nella copia del file; $errore = $ERR_UPLOAD; } } // Redirect verso la URL di ritorno if ($errore == $NOERR) { $ret_url = $urlok."nickname=$nickname&path=$filename&errore=$errore&tipo=$_POST[tipo_file]&des=$des_foto"; } else { $ret_url = $urlnok."nickname=$nickname&path=&errore=$errore"; } header("Location: $ret_url"); // Funzioni utilizzate per estrarre l'elenco dei nicknames dal cookie di AAA function recupero_dati($namedato,$cookie){ $stringa=Myhex2bin($cookie); $stringa = encoding_cookie($stringa); $app = explode(":", $stringa); $appcount = count($app); $toFind = "="; for($i=0;$i<$appcount;$i++) { $stringA = $app[$i]; $lenstringaA = strlen($app[$i]); $result = strchr($stringA,$toFind); if ($result!= ""){ $lentoFind = strlen($result); //prima parte del cookie $firststr = substr($stringA, 0, -$lentoFind); if ($firststr == $namedato){ $strdato = substr($result, 1); } } } return $strdato; } function Myhex2bin($param) { $final=""; for($i=0;$i