Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
www.volley92.asso.fr
/
htdocs
/
admin174
/
connected
/
pages
/
/srv/data/web/vhosts/www.volley92.asso.fr/htdocs/admin174/connected/pages/formation-edit.php
<?php $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]/"; $idFormation = $_GET['id']; $stmt=$db_client->prepare("SELECT * FROM formation WHERE id=?"); // on prépare notre requête $stmt->execute(array($idFormation)); $row = $stmt->fetch(); if(empty($row)) header('Location: formation'); $title = $row->title; $contact_info = $row->contact_info; $email = $row->email; $description = $row->description; $map = $row->map; $price = $row->price; $payement = $row->payement; $phone = $row->phone; $pdf = $row->pdf; if(isset($_POST['formRemove'])) { unlink("../../".$_POST['pdf']); $pdf = null; $stmt=$db_client->prepare("UPDATE formation SET pdf = ? WHERE id=?"); $stmt->execute(array($pdf,$_POST['id'])); header('Location: formation-edition-'.$row->id); } if(isset($_POST['submitUpdate'])){ // echo"<pre>"; // var_dump($_POST); // echo"</pre>"; // die $title = $_POST['title']; $contact_info = $_POST['contact_info']; $email = $_POST['email']; $description = $_POST['description']; $map = $_POST['map']; if(!empty($_POST['price'])){ $price = $_POST['price']; } $payement = $_POST['payement']; $phone = $_POST['phone']; //Ajout du pdf $extension=array("pdf"); if($_FILES['pdf']['size']>0){ $dossier = "img/pdf/"; $file_name=$_FILES["pdf"]["name"]; $ext=pathinfo($file_name,PATHINFO_EXTENSION); $file_name=md5(uniqid()).".".$ext; if(in_array($ext,$extension)) { $pdfTemp=$dossier.$file_name; if(!file_exists($pdfTemp)){ //Si le fichier existe déjà (peu probable car num aléatoire généré) $res = move_uploaded_file($_FILES['pdf']['tmp_name'], "../../".$pdfTemp); if($res){ //Erreur de transfert (souvent la taille) $pdf = $pdfTemp; }else{ echo "<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'>×</button>Erreur lors du transfert du fichier, la taille ne doit pas être supérieur à 20 Mo.</div>"; } }else{ echo "<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'>×</button>Erreur lors du transfert du fichier, la taille ne doit pas être supérieur à 20 Mo..</div>"; } }else{ echo "<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'>×</button>Veuillez choisir une fichier avec l'exention pdf</div>"; } } if(!empty($title)){ $stmt=$db_client->prepare("UPDATE formation SET title=?,pdf=?,contact_info=?,email=?,description=?,map=?,price=?,payement=?,phone=?,updated_at= NOW() WHERE id=?"); // on prépare notre requête $stmt->execute(array($title,$pdf,$contact_info,$email,$description,$map,$price,$payement,$phone,$idFormation)); header("Location: formation"); }else { echo "<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'>×</button>Le champs nom ne peut pas être vide.</div>"; } } ?> <!-- Modal de suppression --> <div class='modal fade' id="suppr<?=$row->id?>"> <div class='modal-dialog'> <div class='modal-content'> <div class='modal-header'> <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button> <h4 class='modal-title'>Suppression d'un Pdf</h4> </div> <div class='modal-body'> Confirmez-vous la suppression du pdf ? </div> <div class='modal-footer'> <form method='post' action=''> <input type='hidden' name='id' value='<?=$row->id?>'> <input type='hidden' name='pdf' value='<?=$row->pdf?>'> <button type='submit' name='formRemove' class='btn btn-danger'>Supprimer le pdf</button> </form> </div> </div> </div> </div> <!-- Modal de détail --> <h1>Éditer une formation <small>(<a href="formation">retour</a>)</small></h1> <form role="form" method="post" action="#" enctype="multipart/form-data"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="title">Nom de la formation</label> <input id="title" class='form-control' type="text" name="title" value="<?=$title?>" autofocus> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="contact_info">Coordonnées</label> <input id="contact_info" class='form-control' type="text" name="contact_info" value="<?=$contact_info?>" autofocus> </div> </div> </div> <div class= "row"> <div class="col-md-6"> <div class="form-group"> <label for="email">Email du contact</label> <input id="email" class='form-control' type="email" name="email" value="<?=$email?>" autofocus> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="phone">Téléphone</label> <input id="phone" class='form-control' type="text" name="phone" value="<?=$phone?>" autofocus> </div> </div> </div> <div class="row"> <div class="col-md-6"> <p><strong>Paiement en ligne</strong></p> <div class="form-check"> <label> <input class="form-check-input" type="radio" name="payement" id="payement" value="1" <?php if($row->payement==1):?> checked <?php endif?>> Payante </label> </div> <div class="form-check"> <label> <input class="form-check-input" type="radio" name="payement" id="unpayement" value="0" <?php if($row->payement==0):?> checked <?php endif?>> Non payante </label> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="price">Prix</label> <input id="price" class='form-control' type="text" name="price" value="<?=$price?>" autofocus> </div> </div> </div> <div class="jumbotron"> <div class="row"> <div class="col-sm-6"> <div class="form-group"> <label for="title">Télécharger le Pdf</label><br> <?php if (!is_null($pdf)): ?> <div class="row"> <div class="col-sm-6"> <a href="<?=$actual_link?><?=$pdf?>" target = "_blank" class="text-danger"> <svg class="svg-inline--fa fa-file-pdf" aria-hidden="true" data-fa-pseudo-element-pending-before="file-pdf" data-fa-pseudo-element-pending-after="undefined" focusable="false" data-prefix="fas" data-icon="file-pdf" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" data-fa-i2svg=""><path fill="currentColor" d="M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"></path></svg> </a> </div> <div class="col-sm-6"> <a data-toggle='modal' href='#suppr<?=$row->id?>' class='btn btn-danger' title='Supprimer le pdf'> <span class='fa fa-times fa-fw'></span> Supprimer le pdf </a> </div> </div> <?php else: ?> <i>Aucun pdf</i> <?php endif ?> </div> </div> <div class="col-sm-6"> <div class="form-group"> <label for="pdf">Pdf</label> <input id="pdf" class='form-control' type="file" name="pdf" value="<?=$pdf?>" autofocus> </div> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="description">Description</label> <textarea id="editor" class='form-control' name="description" rows="5" ><?=$description?></textarea> </div> </div> <div class="col-md-12"> <div class="form-group"> <label for="map">Carte</label> <textarea id="map" class='form-control' name="map" rows="5"><?=$map?></textarea> </div> </div> </div> <hr> <div class='text-center'> <a href="formation" class="btn btn-default">Annuler</a> <button type='submit' name='submitUpdate' class='btn btn-success'>Modifier</button> </div> </form>