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
/
716cf56cb2.url-de-test.ws
/
htdocs_backup
/
htdocs
/
palais91pro
/
functions
/
/srv/data/web/vhosts/716cf56cb2.url-de-test.ws/htdocs_backup/htdocs/palais91pro/functions/devis.php
<?php //Si le formulaire est rempli par un robot if(isset($_POST['pseudo']) && $_POST['pseudo']!="") header("Location: ".$routes['devis-success']); //Init Variables $form_is_valid = true; $form_has_errors = false; $form_is_submitted = false; //SI formualire pré devis : $name = (isset($_POST["namePreD"]))?$_POST["namePreD"]:null; $salle = (isset($_POST["sallePreD"]))?$_POST["sallePreD"]:null; $email = (isset($_POST["emailPreD"]))?$_POST["emailPreD"]:null; $phone = (isset($_POST["phonePreD"]))?$_POST["phonePreD"]:null; //how to use it $data = array( 'company' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Entreprise'), 'firstname' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Prénom'), 'lastname' => array('value' => $name,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'NOM'), 'address' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Adresse'), 'zipcode' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Code postal'), 'city' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Ville','force_display'=>true), 'email' => array('value' => $email,'status'=>null,'regex'=> _EMAIL_REGEX_, 'label'=>'E-mail'), 'phone' => array('value' => $phone,'status'=>null,'regex'=> _PHONE_REGEX_, 'label'=>'Téléphone'), 'select1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Type d\'évènement'), 'radio1' => array('value' => $salle,'status'=>null,'regex'=> null, 'label'=> array('title'=>'Location de salles','options'=>array('option1'=>'Palais 91','option2'=>'L\'Etoile 91','option3'=>'Palais 77','option4'=>'Cristal 91'))), 'input1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Nombre de personnes approximatif'), //'amount1' => array('value' => null,'status'=>null,'regex'=> _AMOUNT_REGEX_, 'label'=>'Montant 1'), 'date1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Date de l\'évènement'), 'message' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Informations complémentaire (facultatif)'), //'file' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Pièce jointe'), 'pseudo' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Pseudo'), 'checkbox1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Je m’inscris à la newsletter','force_display'=>true), ); //Formulaire envoyé if(isset($_POST['devis'])) { $data['address']['value'] = (isset($_POST['address']))?$_POST['address']:null; $data['checkbox1']['value'] = (isset($_POST['checkbox1']))?$_POST['checkbox1']:null; //$data['amount1']['value'] = (isset($_POST['amount1']))?$_POST['amount1']:null; $data['city']['value'] = (isset($_POST['city']))?$_POST['city']:null; $data['company']['value'] = (isset($_POST['company']))?$_POST['company']:null; $data['date1']['value'] = (isset($_POST['date1']))?$_POST['date1']:null; $data['email']['value'] = (isset($_POST['email']))?$_POST['email']:null; $data['firstname']['value'] = (isset($_POST['firstname']))?$_POST['firstname']:null; //$data['file']['value'] = (isset($_FILES['file']))?$_FILES['file']:null; $data['input1']['value'] = (isset($_POST['input1']))?$_POST['input1']:null; $data['lastname']['value'] = (isset($_POST['lastname']))?$_POST['lastname']:null; $data['message']['value'] = (isset($_POST['message']))?$_POST['message']:null; $data['phone']['value'] = (isset($_POST['phone']))?$_POST['phone']:null; $data['pseudo']['value'] = (isset($_POST['pseudo']))?$_POST['pseudo']:null; $data['radio1']['value'] = (isset($_POST['radio1']))?$_POST['radio1']:null; $data['select1']['value'] = (isset($_POST['select1']))?$_POST['select1']:null; $data['select2']['value'] = (isset($_POST['select2']))?$_POST['select2']:null; $data['zipcode']['value'] = (isset($_POST['zipcode']))?$_POST['zipcode']:null; $form_is_submitted = true; //Form validation rules foreach($data as $key => $field) { if (!is_null($field['regex'])){ if (validate($field['regex'],$field['value'])){$data[$key]['status'] = 'has-success';} else{$data[$key]['status'] = 'has-error';$form_is_valid = false;} } } //file check //if(is_null($data['file']['value']) || file_is_uploaded($data['file']['value'])){$data['file']['status'] = 'has-success';} //else{$data['file']['status'] = 'has-error';$form_is_valid = false;} if ($form_is_valid) { //validation rules are OK //Filling my product field foreach($data as $field => $params) { //just fill the 'demande' section of the order if(!in_array($field,array('company','firstname','lastname','address','zipcode','city','email','phone','message','file','pseudo'))) { //search for checkboxN and fill it with Oui (checked) or No (unchecked) if(substr($field, 0, 8) == 'checkbox') { $product[$params['label']] = ($params['value'])?'Oui':'Non'; } //search for radio and fill it with the checked option label elseif(substr($field, 0, 5) == 'radio'){ $product[$params['label']['title']] = $params['label']['options'][$params['value']]; } //fill all the remain fields into products else{ $product[$params['label']] = $params['value']; } } } if ($data['radio1']['value']=="option1") { $salle="Palais 91"; }elseif ($data['radio1']['value']=="option2") { $salle="L'Etoile 91"; }elseif ($data['radio1']['value']=="option3") { $salle="Palais 77"; }elseif ($data['radio1']['value']=="option4") { $salle="Cristal 91"; } $commercial="31"; $originalDate = $data['date1']['value']; $newDate = date("Y-m-d", strtotime($originalDate)); $dates=$newDate; // echo $originalDate; if ($data['checkbox1']['value']=="on"){ $newsletter='1'; }else{ $newsletter='0'; } // $form_data = array( // $data['firstname']['value'], // $data['lastname']['value'], // $data['address']['value'], // $data['zipcode']['value'], // $data['city']['value'], // $data['phone']['value'], // $data['email']['value'], // $data['select1']['value'], // $data['input1']['value'], // $dated=date("Y-m-d"), // $salle, // $commercial, // $dates, // $newsletter, // // // ); // //insert form in db // include "config/database_forms.php"; // $stmt = $db_forms->prepare("INSERT INTO clients(firstname,lastname,address,zipCode,city,phone,email,type_event,nb_personnes,dates,salle,commercial,dateevenm,newsletter) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); // $stmt->execute($form_data); // // ---------------------------------- // $lastid = $db_forms->lastInsertId(); // $token = md5(uniqid(rand(), true)); // // ------------------------------------ // $stmt3=$db_forms->prepare("INSERT INTO devis(id_client,token) VALUES (?,?)"); // on prépare notre requête // $stmt3->execute(array($lastid,$token)); // // -------------------------- // $stmt2=$db_forms->prepare("INSERT INTO etat(caution,id_client,token) VALUES (?,?,?)"); // on prépare notre requête // $stmt2->execute(array(0,$lastid,$token)); // // ------------------------------- // $stmt4=$db_forms->prepare("INSERT INTO programme(id_client,token) VALUES (?,?)"); // on prépare notre requête // $stmt4->execute(array($lastid,$token)); // // ------------------------------- // $stmt5=$db_forms->prepare("INSERT INTO `location-etat`(id_client,id_location,token,etat) VALUES (?,?,?,'0')"); // on prépa // $stmt5->execute(array($lastid,$lastid,$token)); // // ------------------- // $stmt6=$db_forms->prepare("INSERT INTO `location_salle_etat`(id_client,id_location,token,etat) VALUES (?,?,?,'0')"); // on prépa // $stmt6->execute(array($lastid,$lastid,$token)); // // // $db_forms = null;//deconnexion de la db // // //Send emails // mailDevis($data); // mailConfirmation($data); // header("Location: " . $routes['devis-success']); /************ API *******************/ $form_data = array( 'devis' =>$_POST['devis'], 'firstname' =>$data['firstname']['value'], 'lastname' =>$data['lastname']['value'], 'address' =>$data['address']['value'], 'zipcode' =>$data['zipcode']['value'], 'city' =>$data['city']['value'], 'phone' =>$data['phone']['value'], 'email' =>$data['email']['value'], 'type_event' =>$data['select1']['value'], 'nb_personnes' =>$data['input1']['value'], 'dates' =>$dated, 'salle' =>$salle, 'commercial' =>$commercial, 'dateevenm' =>$dates, 'newsletter' =>$newsletter ); // TODO changer url $curl = curl_init(); // print_r($curl);die; $params = $form_data; $params_string = http_build_query($params); $opts = [ CURLOPT_URL => $http_api.'api/devis.php', CURLOPT_POST => true, CURLOPT_POSTFIELDS => $params_string, CURLOPT_RETURNTRANSFER => true, ]; // print_r($opts);die; curl_setopt_array($curl, $opts); $response = json_decode(curl_exec($curl), true); // print_r($response);die; // try { // $response = json_decode(curl_exec($curl), true); // print_r($response);die; // } catch (Exception $e) { // echo 'Exception reçue : ', $e->getMessage(), "\n"; // } if($response['code'] == 200){ //Send emails mailDevis($data); mailConfirmation($data); header("Location: " . $routes['devis-success']); } else header("Location: " . $routes['devis-error']); /************ FIN API *******************/ }else{ //On affichera un message d'erreur $form_has_errors = true; } }