joh, her er det
<?
require("admin_entete.php");
$id_rub = $_GET['id_rub'];
$userfile = $_POST['userfile'];
$pdes = $_POST['pdes'];
$MAX_FILE_SIZE = $_POST['MAX_FILE_SIZE'];
$userfile = $_FILES['userfile']['tmp_name'];
$userfile_name = $_FILES['userfile']['name'];
$userfile_size = $_FILES['userfile']['size'];
if (!isset($id_rub)) $id_rub = -1;
// CHEMIN DE LA RUBRIQUE
$chemin_total = echo_menu($id_rub, $chemin, $rubrique, $id_rubrique);
if (isset($MAX_FILE_SIZE)) {
if ($userfile_size==0) f_erreur_retour (_ERROR_WG_SIZE);
if ($userfile_size==2) f_erreur_retour (_ERROR_WG_NAME);
$userfile_name = strtolower($userfile_name);
if (substr($userfile_name, 0, 2)=="p_") f_erreur_retour(_ERROR_FILE_BEGIN." ($userfile_name)");
$extension = substr($userfile_name, -3);
if ($extension == "gif") f_erreur_retour(_ERROR_GIF);
if ($extension == "peg")
{ if (substr($userfile_name, -4)=="jpeg") { $extension="jpg"; $userfile_name = ereg_replace(".jpeg", ".jpg", $userfile_name);} }
if ($extension != "png" && $extension != "jpg") f_erreur_retour (_ERROR_FILE_EXT." ($extension)");
$nb = f_execute_requete_nb("monalbum_image", "monalbum_image.fichier=\\"$userfile_name\\" and monalbum_image.id_rub=$id_rub");
if ($nb==1) f_erreur_retour (_ERROR_FILE_EXISTS." ($userfile_name)");
// pas d'erreurs
if ( ! move_uploaded_file($userfile, "../images/$chemin_total/$userfile_name")) f_erreur_retour(_ERROR_COPY_SERVER);
@chmod ($_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/../images/$chemin_total/$userfile_name", 0644);
switch($extension) {
case "jpg" : $src_im = ImageCreateFromJPEG ("../images$chemin_total/$userfile_name");
$dst_im = f_miniature($src_im); // ajoute pas logo sur miniature
if (!f_ajout_3dsrc($src_im, "../images$chemin_total/$userfile_name")) f_erreur_retour(_ERROR_TAMPON);
break;
case "png" : $src_im = ImageCreateFromPNG ("../images$chemin_total/$userfile_name");
$dst_im = f_miniature($src_im);
if (!f_ajout_3dsrc($src_im, "../images$chemin_total/$userfile_name")) f_erreur_retour(_ERROR_TAMPON);
break;
}
if (!imagejpeg ($dst_im, "../images/".$chemin_total . "/p_". substr($userfile_name, 0, -3)."jpg")) f_erreur_retour(_ERROR_THUMB);
$xresolution = imagesx($src_im) . "x" . imagesy($src_im);
if (!execute_requete("insert into monalbum_image (id_rub, fichier, description, resolution, taille) values ($id_rub, \\"$userfile_name\\", '".addslashes($pdes)."', '$xresolution', ".($userfile_size/1024).")")) {
unlink ("../images$chemin_total" . $userfile_name);
f_erreur_retour (_ERROR_REQUEST." (unlink).");
}
// die('<META HTTP-equiv="refresh" content="0;URL=./admin_ajouter_img.php?id_rub='.$id_rub.'">');
}
if (!isset($rubrique[0])) $rubrique[0]=_THE_ROOT;
echo _ADD_IMG." <i>".$rubrique[0]." : </i><br>";
echo "<table><form ENCTYPE='multipart/form-data' method='post' action=admin_ajouter_img.php?id_rub=$id_rub>
<input type='hidden' name='MAX_FILE_SIZE' value='1000000'>
<tr><td>"._FILE."</td><td><input type='file' name='userfile'></td></tr>
<tr><td>"._DESCRIPTION."</td><td><input type='text' name ='pdes' size=33></td></tr>
<tr><td><input type='submit' value='"._ADD."'></td></tr>
</form></table>";
// + fin du tableau
echo "</td></tr><tr><td>".affiche_menu_img($id_rub)."</td></table></body>";
?>