<html> <!--*************************************************************************** * index.php * begin : Wednesday, January 5th 2005 * Autor : DesertStorm for Mechstorm.net * email : desertstorm_AT_mechstorm.net * * $Id: index.php,v 1 2005/01/05 * ***************************************************************************--> <head> <title>Mechstorm.net Download Center | Supplied by Easyhosts.com</title> </head> <body bgcolor="000000" text="FBAE57" leftmargin="5" topmargin="5" marginwidth="5" marginheight="5" link="FBAE57" alink="F15834" vlink="FFFFFF"> <center> <span style="color:red"><?PHP echo $infos; ?></span><br> <form name="upload" method="post" action="./upload.php3" enctype="multipart/form-data"> author: <input type="text" name="author" size="30" maxlength="30" value="<?PHP echo $author; ?>"><br><br> file name: <input type="text" name="filename" size=30 maxlength=50 value="<?PHP echo $filename; ?>"><br><br> description: <input type="text" rows="5" cols="20" name="description" size=30 maxlength=50 value="<?PHP echo $description; ?>"><br><br> category: <input type="text" name="category" size=30 maxlength=50 value="<?PHP echo $category; ?>"><br><br> <input type="hidden" name="MAX_FILE_SIZE" value="5000000"> File: <input type="file" name="file1"><br><br> <input type="submit" value="Upload!"> <br><br> <a href="./index2.php3">Back to downloads</a> </form> <?php $filename = $_POST['filename']; $author = $_POST['author']; $category = $_POST['category']; $description = $_POST['description']; //Initialisation de la variables $infos $infos = ''; //Vérification du author et du filename if ($filename == '') $infos .= "- You must enter a file name!<br>n"; if ($author == '') $infos .= "- You must enter an author name!<br>n"; if ($category == '') $infos .= "- You must enter an category!<br>n"; if ($description == '') $infos .= "- You must enter a description of this file!<br>n"; //Pour savoir si le fichier a été uploadé, on vérifie que le fichier est bien dans le tableau des fichiers if (!empty ($_FILES['file1']['size'])) { //On récupère la taille, le nom et le nom du fichier temporaire $f1_size = $_FILES['file1']['size']; $f1_name = $_FILES['file1']['name']; $f1_tmpname = $_FILES['file1']['tmp_name']; //Récupération de l'extension du fichier (on prend ce qui suit le dernier point et on le met en minuscule $ext = strtolower(substr($f1_name, strrpos($f1_name, ".") + 1)); //Création du tableau des extensions acceptées $allowed = array ("exe", "zip", "ace", "rar", "doc", "txt"); //On vérifie la taille et le type de fichier if ($f1_size > 5000000) $infos .= "- Your file is way to big!!!<br>n"; if (!in_array($ext, $allowed)) $infos .= "- Sorry, we don't accept this type of files!<br>n"; //Si tout est bon (aucune erreur dans $infos), on déplace le fichier if ($infos == '') move_uploaded_file($f1_tmpname, "./upload/{$f1_name}") or $infos .= "- Impossible to upload this file, please contact an admin!<br>n"; if ($infos == '') { $res = mysql_connect('localhost', 'dlsite', 'temporary') or die("CONNECT :".mysql_error()); mysql_select_db('dlsite_mechstorm', $res) or die("USE DB :".mysql_error()); $add = mysql_query("INSERT INTO files VALUES ('','{$filename}','{$author}','{$category}','{$description}','{$f1_name}',{$f1_size});"); } } else $infos .= "- You must choose a file to upload!<br>n"; //Si le formulaire n'a pas encore été validé, on n'affiche pas les erreurs if (empty ($_POST['MAX_FILE_SIZE'])) $infos = ''; //Si il y a eu une erreur ou si le formulaire n'a pas encore été validé (Facile à savoir, tant que le formulaire n'est pas validé, MAX_FILE_SIZE est vide), on l'affiche if ($infos != '' || empty ($_POST['MAX_FILE_SIZE'])) : //Affichage des informations d'erreur au début du formulaire ?> <br><br>The following file has been submitted : <br> <? //On affiche ici les informations saisies echo " File name : $filename <br>"; echo " Author : $author <br>"; echo " Category : $category <br>"; echo " Description : $description <br>"; echo " File size : $size <br>"; echo " If some informations are incorrect, please contact an admin. <br>"; //On envoit un mail contenant les données mail("mechwar_AT_mechstorm.net", "New file uploaded to Download Center", "$filename\n$author\n$category\n$description", "From: upload_AT_mechstorm.com\n"); //Header("Location: http://www.mechstorm.com"); ?> <a href="./index2.php3">Back to downloads</a> </center> </body> </html>
Ca devrait mieux marcher... Tes {} n'étaient pas toutes bonnes