$nav
"._GALUPLOADMEDIA."

"; if (is_user($user) || !$galleryvar['anonpostpics']) { echo "
"._GALSELECTCATEGORY."


"._GALMEDIANAME."


"._GALFILENAME."
"; if ($galleryvar['limitSize']) echo ""; echo "

"._GALSUBMITTER."
"; if (is_user($user)) { $userdata=cookiedecode($user); echo "\n"; echo "".$userdata[1]."

"; } else echo "

"; echo "
"._GALDESCRIPTION."
"; if ($galleryvar['limitSize']) echo "".sprintf(_GALMAXSIZEPOST,$size)."
"; echo _GALCLICKONCE."
"; } else echo "

"._GALREGISTER2POSTPICS."

"; echo " "; CloseTable(); galleryFooter(); } function Add($gid, $file, $submitter, $medianame, $description, $userfile, $userfile_name, $userfile_size) { global $user, $font, $galleryvar, $basepath, $temppath, $prefix ; $sql = "select img from $prefix"._gallery_pictures." where gid=$gid and img='$file'"; //echo $sql; $result = mysql_query($sql); $numrows = mysql_num_rows($result); $navgall = navigationGall(); if ($file==$galleryvar['GalleryPictureName'] || $numrows>0) { galleryHeader(); OpenTable(); print '' .'
'.$navgall; echo "
"; echo "
"._GALPICALREADYEXT."

" .""._GOBACK.""; print '
'; CloseTable(); galleryFooter(); } else { if(is_user($user)) { $user2 = base64_decode($user); $cookie = explode(":", $user2); cookiedecode($user); $submitter = $cookie[1]; } // Check if Media Name exist if (!isset($medianame) || $medianame=="") { galleryHeader(); echo "
"; OpenTable(); print '' .'
'.$navgall; echo "
"; echo "
"._GALPICNONAME."

" .""._GOBACK.""; print '
'; CloseTable(); galleryFooter(); } else // Check if Description exist if (!isset($description) || $description=="") { galleryHeader(); echo "
"; OpenTable(); print '' .'
'.$navgall; echo "
"._GALPICNODESC."

" .""._GOBACK.""; print '
'; CloseTable(); galleryFooter(); } else // Check if Description exist if (!isset($submitter) || $submitter=="") { galleryHeader(); echo "
"; OpenTable(); print '' .'
'.$navgall; echo "
"; echo "
"._GALPICNOSUBMITTER."

" .""._GOBACK.""; print '
'; CloseTable(); galleryFooter(); } else { $medianame = FixQuotes($medianame); $description = FixQuotes($description); $wdir = "/"; $upload_return = UploadFile($temppath, $userfile, $userfile_name, $userfile_size); //echo "public uploadFile.php : $upload_return
"; if ($upload_return=="OK") { $ext = substr($file, (strrpos($file,'.') + 1)); list($type) = mysql_fetch_row(mysql_query("select filetype from $prefix"._gallery_media_types." where extension='$ext'")); $wdir = "/"; switch($type) { case 1 : $size = @getimagesize($temppath.$wdir.$file); break; case 3 : $size[0] = 320; $size[1] = 240; break; default: $size[0] = 0; $size[1] = 0; break; } $file = traite_nom_fichier($file); if ($size!=NULL) $sql = "insert into $prefix"._gallery_pictures_newpicture." (pid, gid, img, counter, submitter, date, name, description, votes, rate, extension, width, height) values(NULL, $gid, '$file', 0, '$submitter', now(), '$medianame', '$description', 0, 0, '$ext', ".$size[0].", ".$size[1].")"; else $sql = "insert into $prefix"._gallery_pictures_newpicture." (pid, gid, img, counter, submitter, date, name, description, votes, rate, extension, width, height) values(NULL, $gid, '$file', 0, '$submitter', now(), '$medianame', '$description', 0, 0, '$ext', 0, 0)"; //echo $sql; mysql_query($sql); } else return $upload_return; return "OK"; } } } ?> = 1073741824) {$taille = round($taille / 1073741824 * 100) / 100 . " G".$size_unit;} elseif ($taille >= 1048576) {$taille = round($taille / 1048576 * 100) / 100 . " M".$size_unit;} elseif ($taille >= 1024) {$taille = round($taille / 1024 * 100) / 100 . " K".$size_unit;} else {$taille = $taille . " ".$size_unit;} if($taille==0) {$taille="-";} return $taille; } function date_modif($fichier) { $tmp = filemtime($fichier); return date("d/m/Y H:i",$tmp); } function slash() { global $prefix, $racine; if(ereg("\\\\",$racine)){$slash="\\";} else {$slash="/";} return $slash; } function deldir($location) { if(is_dir($location)) { $all=opendir($location); while ($file=readdir($all)) { if (is_dir($location.slash().$file) && $file <> ".." && $file <> ".") { deldir($location.slash().$file); if(file_exists($location.slash().$file)){rmdir($location.slash().$file); } unset($file); } elseif (!is_dir($location.slash().$file)) { unlink($location.slash().$file); unset($file); } } closedir($all); rmdir($location); } else { unlink($location); } } function enlever_controlM($fichier) { $fic=file($fichier); $fp=fopen($fichier,"w"); while (list ($cle, $val) = each ($fic)) { $val=str_replace(CHR(10),"",$val); $val=str_replace(CHR(13),"",$val); fputs($fp,"$val\n"); } fclose($fp); } function traite_nom_fichier($nom) { global $prefix, $max_caracteres; $nom=stripslashes($nom); $nom=str_replace("'","",$nom); $nom=str_replace("\"","",$nom); $nom=str_replace("\"","",$nom); $nom=str_replace("&","",$nom); $nom=str_replace(",","",$nom); $nom=str_replace(";","",$nom); $nom=str_replace("/","",$nom); $nom=str_replace("\\","",$nom); $nom=str_replace("`","",$nom); $nom=str_replace("<","",$nom); $nom=str_replace(">","",$nom); $nom=str_replace(" ","_",$nom); $nom=str_replace(":","",$nom); $nom=str_replace("*","",$nom); $nom=str_replace("|","",$nom); $nom=str_replace("?","",$nom); $nom=str_replace("","e",$nom); $nom=str_replace("","e",$nom); $nom=str_replace("","c",$nom); $nom=str_replace("@","",$nom); $nom=str_replace("","a",$nom); $nom=str_replace("","e",$nom); $nom=str_replace("","i",$nom); $nom=str_replace("","o",$nom); $nom=str_replace("","u",$nom); $nom=str_replace("","u",$nom); $nom=str_replace("","a",$nom); $nom=str_replace("!","",$nom); $nom=str_replace("","",$nom); $nom=str_replace("+","",$nom); $nom=str_replace("^","",$nom); $nom=str_replace("(","",$nom); $nom=str_replace(")","",$nom); $nom=str_replace("#","",$nom); $nom=str_replace("=","",$nom); $nom=str_replace("$","",$nom); $nom=str_replace("%","",$nom); $nom=str_replace("","ae",$nom); $nom=str_replace("","Ae",$nom); $nom=str_replace("","oe",$nom); $nom=str_replace("","Oe",$nom); $nom=str_replace("","ue",$nom); $nom=str_replace("","Ue",$nom); $nom=str_replace("","ss",$nom); if (strlen($nom)> $max_caracteres) { $ext = substr($nom, (strrpos($nom,'.') + 1)); $nom = substr ($nom,0,$max_caracteres-4); $nom = $nom.".".$ext; } return $nom; } //----------------------------------------------------------------------------------------------------------------------------------------- // MAIN //----------------------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------------------------- // DEPLACER / MOVE //----------------------------------------------------------------------------------------------------------------------------------------- function moveFile($fic, $dest) { //$rep=stripslashes($rep); $fic=stripslashes($fic); $dest=stripslashes($dest); if($dest!="") {$destination=$dest.slash();} $destination.=basename($fic); if(file_exists($fic)) {copy($fic,$destination);} if($fic!=$destination) {if(file_exists($fic)) {unlink($fic);}} $messtmp= "\n"; $messtmp.= sprintf(_GALFILEMOVED, $fic)." "; $err=0; if($dest=="") {$messtmp.= "/";} else {$messtmp.= "$dest";} $messtmp.= "\n"; $messtmp.= "\n"; if ($err!=0) return $messtmp; else return $err; } //----------------------------------------------------------------------------------------------------------------------------------------- // SUPPRIMER / DELETE //----------------------------------------------------------------------------------------------------------------------------------------- function deleteFile($rep, $fic) { $rep=stripslashes($rep); $fic=stripslashes($fic); $messtmp=""; $a_effacer=$fic; if(file_exists($a_effacer)) { if(is_dir($a_effacer)){deldir($a_effacer);$messtmp.=sprintf(_GALFILEDELETED, $fic);} else {unlink($a_effacer); $messtmp.=sprintf(_GALFILEDELETED2, $fic);} } else {$messtmp.=_GALFILEDELETED3;} $messtmp.=""; return $messtmp; } //----------------------------------------------------------------------------------------------------------------------------------------- // RENOMMER / RENAME //----------------------------------------------------------------------------------------------------------------------------------------- function renameFile($fic) { $err=""; $rep=stripslashes($rep); $fic=stripslashes($fic); $nom_fic=basename($fic); $messtmp=""; $fic_new=traite_nom_fichier($fic_new); $old=$racine.slash().$fic; $new=dirname($old).slash().$fic_new; if($fic_new=="") { $messtmp.= _GALFILERENAMED; $err=1; } else if(file_exists($new)) { $messtmp.=sprintf(_GALFILERENAMED1, $fic_new); $err=1; } else { rename($old,$new); $messtmp.=sprintf(_GALFILERENAMED2, $fic, $fic_new); } $messtmp.=""; if ($err!=0) return $messtmp; else return "OK"; } //----------------------------------------------------------------------------------------------------------------------------------------- // CREER UN REPERTOIRE / CREATE DIR //----------------------------------------------------------------------------------------------------------------------------------------- function makeDir($rep, $nomdir) { $rep=stripslashes($rep); //$nomdir=traite_nom_fichier($nomdir); if($nomdir=="") { $err=1; return _GALFILECREATED; } else if(file_exists("$rep/$nomdir")) { $err=2; return _GALFILECREATED1; } else { umask(000); $ret = @mkdir("$rep/$nomdir",0777); if ($ret) { $messtmp = sprintf(_GALFILECREATED2, $nomdir); $messtmp.=""; if($rep=="") {$messtmp.="/";} else {$messtmp.="$rep";} $messtmp.=""; $err=0; return "OK"; } else { $err=1; return _GALCREATECATERROR; } } } //----------------------------------------------------------------------------------------------------------------------------------------- // UPLOAD //----------------------------------------------------------------------------------------------------------------------------------------- function UploadFile($rep, $userfile, $userfile_name, $userfile_size) { $rep=stripslashes($rep); if($rep!=""){$rep_source=$rep;} $destination=$rep_source; if ($userfile_size!=0) {$taille_ko=$userfile_size/1024;} else {$taille_ko=0; $err=1; return _GALUPLOADERROR; } if ($userfile=="none") {$err=2; return _GALUPLOADERROR2;} if ($userfile!="none" && $userfile_size!=0) { $userfile_name=traite_nom_fichier($userfile_name); if (!@move_uploaded_file($userfile, "$destination/$userfile_name")) { $err=3; return _GALUPLOADERROR3; } else { /* if(eregi("\.txt","$userfile_name") ||eregi("\.html","$userfile_name") ||eregi("\.htm","$userfile_name") ||eregi("\.php","$userfile_name") ||eregi("\.php3","$userfile_name") ||eregi("\.htaccess","$userfile_name") ||eregi("\.htpasswd","$userfile_name") ||eregi("\.pl","$userfile_name") ||eregi("\.cgi","$userfile_name") ||eregi("\.js","$userfile_name") ) { enlever_controlM("$destination/$userfile_name"); } */ @chmod("$destination/$userfile_name",0664); $message = sprintf(_GALFILEUPLOADED1, $userfile_name, $rep); $err=0; return "OK"; } } } ?>