} else { if (!@rename(getFtpAircraftsRoot() . '/' . $aircraftdir, getFtpAircraftsRoot() . '/' . $_POST['rep'])) { $aircraft_error = "Impossible de renommer le dossier physique correspondant, contactez votre administrateur."; } else { $db->updateProduct($_POST['nom'], $_POST['rep'], $_POST['menu'], (int) $_POST['id_avion']); $confirm = "Produit modifié."; } } } } // Ajouter un produit if (isset($_POST['insert_product'])) { if (is_dir(getFtpAircraftsRoot() . '/' . $_POST['rep'])) { $aircraft_error = "Il existe un dossier physique sur votre espace de fichier portant déjà ce nom."; } else { if (!@mkdir(getFtpAircraftsRoot() . '/' . $_POST['rep'])) { $aircraft_error = "Impossible de créer le dossier physique correspondant, contactez votre administrateur."; } else { $db->insertProduct($_POST['nom'], $_POST['rep'], $_POST['menu']); $confirm = "Produit ajouté."; $httpQuery->delete('addProduct'); } } } if ($httpQuery->has('addProduct')) { $inputNom = isset($_POST['nom']) ? $_POST['nom'] : ''; $inputRep = isset($_POST['rep']) ? $_POST['rep'] : ''; $inputMenu = isset($_POST['menu']) ? $_POST['menu'] : ''; } // Tous les types enregistrés dans la base $allTypes = $db->getAllTypes();
} } if (isset($_FILES['picture'])) { FB::log($_POST, 'POST'); FB::log($_FILES, 'FILES'); $imagesize = getimagesize($_FILES['picture']['tmp_name']); FB::log($imagesize, 'label'); if (!in_array($_FILES['picture']['type'], array('image/jpeg', 'image/jpg', 'image/pjpeg'))) { $error = 'Votre fichier doit être au format jpeg.'; } elseif ($imagesize[0] / $imagesize[1] != 740 / 340) { $error = 'Les dimensions de votre image doivent être de 740x340 ou bien d\'un ratio équivalent.'; } else { require 'classes/uploader.class.php'; try { $upload = new Uploader($_FILES['picture']); $upload->setDstPath(getFtpAircraftsRoot() . '/' . $_POST['rep'] . '/'); $upload->upload(); $confirm = "L'image " . $_FILES['picture']['name'] . " a été ajoutée"; } catch (UploaderException $e) { $error = $e->getMessage(); } } } // Tous les aircrats $aircrafts = $db->getAllProducts(); foreach ($aircrafts as $aircraft) { $aircraft->images = array(); if (is_dir(getFtpAircraftsRoot() . '/' . $aircraft->rep . '/')) { $aircraft->images = readdir_recursive(getFtpAircraftsRoot() . '/' . $aircraft->rep . '/', array('jpg')); } }
</p><?php } ?> <?php if (is_array($aircrafts)) { foreach ($aircrafts as $aircraft) { ?> <h2><?php echo $aircraft->nom; ?> </h2> <ul class="aircraftPictureList"> <?php foreach ($aircraft->images as $i => $imagepath) { $shortpath = str_replace(getFtpAircraftsRoot(), '', $imagepath); $image_id = basename($imagepath, '.jpg'); ?> <li id="<?php echo $image_id; ?> "> <img src="/img/Aircraft<?php echo $shortpath; ?> " width="250" alt="<?php echo $shortpath; ?> "/> <a class="delete" href="?p=aircraftPictures&deletePicture=<?php echo $shortpath;