= 2 If ($errore == $NOERR){ if($nickname == ""){ $errore = $ERR_NONICK; } elseif(strlen($nickname)<2){ $errore = $ERR_NOVALIDNICK; } } // Verifica del campo attribute name if ($errore == $NOERR) { if(strlen($profilo)==3 && ($profilo=="all" || ((substr($profilo,0,1)=="f" || substr($profilo,0,1)=="a" || substr($profilo,0,1)=="v") && is_numeric(substr($profilo,-2))))){ // Profilo a posto } else $errore = $ERR_NOVALIDTYPE; } // Controllo del checksum MD5 del nickname if ($errore == $NOERR && $controllochk) { if($chk == ""){ $errore=$ERR_CHK; // decommentare in seguito }else{ $salt=substr($chk,0,8); $contr= (md5($nickname.$salt,false)); if ($salt.$contr != $chk) $errore=$ERR_MD5; } } // Controllo che il nickname indicato abbia una cartella di contenuti e creo la cartella di backup if ($errore == $NOERR){ $path = $PATH_MEDIA . "/" . $community . "/" . $nickname{0} . "/" . substr($nickname , -2) . "/" . $nickname; $path2 = ""; if (is_dir($path)) { // Se richiesto preparo la cartella per il backup dei files if($PATH_DEL != "") { if(!is_dir("$PATH_DEL/$data")) mkdir("$PATH_DEL/$data", 0777); if(!is_dir("$PATH_DEL/$data/$ora")) mkdir("$PATH_DEL/$data/$ora", 0777); if(!is_dir("$PATH_DEL/$data/$ora/$nickname")) mkdir("$PATH_DEL/$data/$ora/$nickname", 0777); if (!is_dir("$PATH_DEL/$data/$ora/$nickname")){ $errore = $ERR_FSBKDIR; } else { $path2 = "$PATH_DEL/$data/$ora/$nickname"; } } } else { $errore = $ERR_FSUSERDIR; } } // Procedo a spostare o cancellare i files if ($errore == $NOERR){ $contatore = 0; if ($profilo!="all"){ $contatore = $contatore + process_content($path , $path2 , "$nickname," . $profilo); } else { $contatore = $contatore + process_content($path , $path2 , "$nickname,f00"); $contatore = $contatore + process_content($path , $path2 , "$nickname,f01"); $contatore = $contatore + process_content($path , $path2 , "$nickname,f02"); $contatore = $contatore + process_content($path , $path2 , "$nickname,f03"); $contatore = $contatore + process_content($path , $path2 , "$nickname,f04"); $contatore = $contatore + process_content($path , $path2 , "$nickname,f05"); $contatore = $contatore + process_content($path , $path2 , "$nickname,a00"); $contatore = $contatore + process_content($path , $path2 , "$nickname,v00"); } if ($contatore < 0) { $errore = $ERR_FS; } else { rmdir($path); //cancello la directory vuota if($mustcomp) compatta_foto("$path/$nickname,"); } } // comunicazione con il profile manager if ($errore == $NOERR && $notifypm){ $tipofile= get_type(substr($profilo , -3 , 1 )); $nick=urlencode($nickname); $community=strtoupper($community); if($tipofile == 0){ //foto $numfoto=conta_foto("$path/$nickname,"); $sFile = file_get_contents("$URL_PMFOTO?nickname=$nick&comunita=$community&numerofoto=$numfoto"); error_log("$URL_PMFOTO?nickname=$nick&comunita=$community&numerofoto=$numfoto
"); }else{ //audio o video $filename = urlencode("/contenuti/$nickname,$profilo.mp3"); if($tipofile == 1){ $nomeattributo="audio"; }else{ $nomeattributo="video"; } $sFile = file_get_contents("$URL_PMAV?nickname=$nick&comunita=$community&nomeattributo=$nomeattributo&valoreattributo=$filename&cmd=delete"); error_log("$URL_PMAV?nickname=$nick&comunita=$community&nomeattributo=$nomeattributo&valoreattributo=$filename&cmd=delete
"); } if($sFile){ if(strlen($sFile)>2){ if(substr($sFile,0,3)!="200") $errore = $ERR_PM3; }else{ $errore = $ERR_PM2; } }else{ $errore = $ERR_PM1; } } // Stampa a video del risultato dell'operazione //if ($errore != $NOERR){ error_log("DELETE: ".$nickname." ".$errore); // } echo $errore; exit; // Funzione per lo spostamento di un contenuto function process_content($path1 , $path2 , $fileprefix) { global $NUMEXT; global $ESTENSIONI; $pcont = 0; $tipofile= get_type(substr($fileprefix , -3 , 1 )); $pcont = $pcont + process_file($path1 , $path2 , "$fileprefix.html"); for ($ne = 0; $ne < $NUMEXT[$tipofile]; $ne++ ) { $pcont = $pcont + process_file($path1 , $path2 , "$fileprefix.". $ESTENSIONI[$tipofile][$ne]); } if ($tipofile==0){ $pcont = $pcont + process_file($path1 , $path2 , substr_replace($fileprefix , "i" , -3 , 1) . ".jpg"); $pcont = $pcont + process_file($path1 , $path2 , substr_replace($fileprefix , "t" , -3 , 1) . ".jpg"); $pcont = $pcont + process_file($path1 , $path2 , substr_replace($fileprefix , "c" , -3 , 1) . ".jpg"); $pcont = $pcont + process_file($path1 , $path2 , substr_replace($fileprefix , "n" , -3 , 1) . ".jpg"); } return $pcont; } // Funzione per lo spostamento dei singoli files function process_file($p1,$p2,$fn) { if ( is_file( "$p1/$fn" )) { if(is_dir($p2)) copy("$p1/$fn" , "$p2/$fn"); unlink( "$p1/$fn" ); if ( is_file( "$p1/$fn" )) { return -999; } else { return 1; } }else { return 0; } } // funzione per la "compattazione" delle foto function compatta_foto($uri) { $maxfoto = 6; $firstempty = 0; global $NUMEXT; global $ESTENSIONI; global $NOME_HOST; global $nickname; for ($co=0; $co<($maxfoto); $co++) { if (is_file($uri."f0".$co.".html")){ if ($firstempty < $co){ //sposta unlink($uri."f0".$co.".html"); for ($ne = 0; $ne < $NUMEXT[0]; $ne++ ) { if(is_file($uri."f0".$co.".".$ESTENSIONI[0][$ne])){ rename($uri."f0".$co.".".$ESTENSIONI[0][$ne],$uri."f0".$firstempty.".".$ESTENSIONI[0][$ne]); make_html($uri."f0".$firstempty.".html","http://$NOME_HOST/contenuti/$nickname,f0$firstempty.".$ESTENSIONI[0][$ne]); } } if(is_file($uri."i0".$co.".jpg")) rename($uri."i0".$co.".jpg",$uri."i0".$firstempty.".jpg"); if(is_file($uri."t0".$co.".jpg")) rename($uri."t0".$co.".jpg",$uri."t0".$firstempty.".jpg"); if(is_file($uri."c0".$co.".jpg")) rename($uri."c0".$co.".jpg",$uri."c0".$firstempty.".jpg"); if(is_file($uri."n0".$co.".jpg")) rename($uri."n0".$co.".jpg",$uri."n0".$firstempty.".jpg"); } $firstempty++; } } return true; } //funzione per creare i files html di reindirizzamento function make_html($file,$url){ $fileout=fopen ($file ,"w"); if($fileout) { fwrite($fileout,"\n"); fwrite($fileout,"\n"); fwrite($fileout,"\n"); fwrite($fileout,""); fclose($fileout); return true; } return false; } // funzione per recuperare il codice numerico del contenuto multimediale function get_type($pref){ $tipo=0; if($pref=="a") $tipo=1; if($pref=="v") $tipo=2; return $tipo; } // funzione per la contare delle foto function conta_foto($uri) { $maxfoto = 6; $numfoto = 0; for ($co=0; $co<($maxfoto); $co++) { if (is_file($uri."f0".$co.".html")){ $numfoto++; } } return $numfoto; } ?>