array_push($erreur, 'La longitude doit être numérique'); } } if (!empty($email)) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { array_push($erreur, 'Le format de l\'email n\'est pas bon'); } } if (!empty($site)) { if (!filter_var($site, FILTER_VALIDATE_URL)) { array_push($erreur, 'Le format du site n\'est pas bon'); } } /* Récupération de l'image */ if ($_FILES['logo']['error'] === UPLOAD_ERR_OK) { $logo = Upload::postFichier($_FILES['logo'], 'Le logo', 2000000, array('jpg', 'jpeg', 'png'), array('ma', 1024, 768)); } /** * Si aucune erreur alors */ if (empty($erreur)) { /** * Ajout de la structure en bdd */ $sql = $bdd->prepare("INSERT INTO annuaire_structure\n\t\t\t \t\t\t\t\t (structureCreated, structureCategorie, structureActivite, structureRaison, structureLogo, structureContenu, structureAdresse, structureCp, structureVille, structureRegion, structureDepartement, structureLatitude, structureLongitude, structureTelephone1, structureTelephone2, structureEmail, structureSite, structureSiret, structureIntracom)\n\t\t\t\t\t\t\t\t VALUES\n\t\t\t\t\t\t\t\t (:created, :categorie, :activite, :raison, :logo, :contenu, :adresse, :cp, :ville, :region, :departement, :latitude, :longitude, :telephone1, :telephone2, :email, :site, :siret, :intracom) "); $sql->execute(array('created' => Tool::dateTime('Y-m-d H:i'), 'categorie' => implode(',', $categorie), 'activite' => implode(',', $activite), 'raison' => $_POST['raison'], 'logo' => $logo, 'contenu' => $_POST['contenu'], 'adresse' => $_POST['adresse'], 'cp' => $_POST['cp'], 'ville' => $_POST['ville'], 'region' => $_POST['region'], 'departement' => $departement, 'latitude' => $_POST['latitude'], 'longitude' => $_POST['longitude'], 'telephone1' => $_POST['telephone1'], 'telephone2' => $_POST['telephone2'], 'email' => $_POST['email'], 'site' => $_POST['site'], 'siret' => $_POST['siret'], 'intracom' => $_POST['intracom'])); /** * Upload du logo */ if (!empty($logo)) { $imagine = new Imagine();
} if (!empty($email)) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { array_push($erreur, 'Le format de l\'email n\'est pas bon'); } else { $sql = $bdd->query("SELECT * FROM utilisateur\n WHERE utilisateurEmail = '{$email}'\n AND utilisateurId != {$utilisateurId} "); if ($sql->rowCount() != 0) { array_push($erreur, 'L\'utilisateur existe déjà'); } } } else { array_push($erreur, 'L\'email'); } /* Récupération de l'image */ if ($_FILES['avatar']['error'] === UPLOAD_ERR_OK) { $avatar = Upload::postFichier($_FILES['avatar'], 'L\'avatar', 2000000, array('jpg', 'jpeg', 'png'), array('eg', 150, 150)); } /** * Si aucune erreur, traitement */ if (empty($erreur)) { /** * Upload de l'image */ $imagine = new Imagine(); if (isset($avatar)) { $sql = $bdd->prepare("UPDATE utilisateur SET \n utilisateurChanged = :changed,\n utilisateurAvatar = :avatar\n WHERE utilisateurId = :utilisateurId "); $sql->execute(array('changed' => Tool::dateTime('Y-m-d H:i'), 'avatar' => $avatar, 'utilisateurId' => $utilisateurId)); /* Upload */ $imagine->open($_FILES['avatar']['tmp_name'])->save('../img/utilisateur/avatar/' . $avatar); }
* Variables de formulaire */ $nom = $_POST['nom']; $categorie = $_POST['categorie']; /** * Erreurs */ if (empty($nom)) { array_push($erreur, 'Le nom'); } if (empty($categorie)) { array_push($erreur, 'La categorie'); } /* Récupération du fichier */ if ($_FILES['fichier']['error'] === UPLOAD_ERR_OK) { $fichier = Upload::postFichier($_FILES['fichier'], 'Le fichier', 5000000, array('jpg', 'jpeg', 'png', 'pdf', 'xls', 'xlsx', 'doc', 'docx'), array()); } else { array_push($erreur, 'Le fichier'); } /** * Si aucune erreur alors */ if (empty($erreur)) { /** * Ajout de l'utilisateur en base de donnée */ $sql = $bdd->prepare("INSERT INTO document\n (documentCreated, documentNom, documentCategorie, documentFichier) \n VALUES \n (:created, :nom, :categorie, :fichier) "); $sql->execute(array('created' => Tool::dateTime('Y-m-d H:i'), 'nom' => $_POST['nom'], 'categorie' => $_POST['categorie'], 'fichier' => $fichier)); /* Upload du fichier */ move_uploaded_file($_FILES['fichier']['tmp_name'], '../../file/document/' . $fichier); /* Message de succès */