Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
trash
/
vhost_www.sanimoderne.fr_1511970463
/
htdocs
/
old
/
functions
/
/srv/data/trash/vhost_www.sanimoderne.fr_1511970463/htdocs/old/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; //how to use it $data = array( //'company' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Entreprise'), //'firstname' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Prénom'), 'lastname' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'NOM'), //'address' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Adresse'), //'address2' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Adresse destination'), 'zipcode' => array('value' => null,'status'=>null,'regex'=> _ZIPCODE_REGEX_, 'label'=>'Code postal'), //'city' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=>'Ville','force_display'=>true), 'email' => array('value' => null,'status'=>null,'regex'=> _EMAIL_REGEX_, 'label'=>'E-mail'), 'phone' => array('value' => null,'status'=>null,'regex'=> _PHONE_REGEX_, 'label'=>'Téléphone'), 'select1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Dans quelle pièce se situe le problème '), 'select2' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Quel est le problème ? '), 'select3' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Heure souhaitée '), //'checkbox1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'prestation 1','force_display'=>true), //'checkbox2' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'prestation 2','force_display'=>true), //'radio1' => array('value' => null,'status'=>null,'regex'=> _2_CHARS_REGEX_, 'label'=> array('title'=>'Sexe','options'=>array('option1'=>'Masc','option2'=>'Femin'))), //'amount1' => array('value' => null,'status'=>null,'regex'=> _AMOUNT_REGEX_, 'label'=>'Montant 1'), 'date1' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Date souhaitée '), 'message' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Commentaire '), //'file' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Pièce jointe'), 'pseudo' => array('value' => null,'status'=>null,'regex'=> null, 'label'=>'Pseudo'), ); //Formulaire envoyé if(isset($_POST['devis'])) { $data['address']['value'] = (isset($_POST['address']))?$_POST['address']:null; $data['address2']['value'] = (isset($_POST['address2']))?$_POST['address2']:null; $data['amount1']['value'] = (isset($_POST['amount1']))?$_POST['amount1']:null; $data['city']['value'] = (isset($_POST['city']))?$_POST['city']:null; $data['checkbox1']['value'] = (isset($_POST['checkbox1']))?$_POST['checkbox1']:null; $data['checkbox2']['value'] = (isset($_POST['checkbox2']))?$_POST['checkbox2']: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('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']; } } } $form_data = array( //$data['firstname']['value'], $data['lastname']['value'], $data['email']['value'], $data['phone']['value'], //$data['company']['value'], $data['address']['value'], $data['zipcode']['value'], $data['city']['value'], $data['message']['value'], serialize($product), $conf_id_company, ); //insert form in db include "config/database_forms.php"; $stmt = $db_forms->prepare("INSERT INTO devis(lastname,email,phone,address,zipcode,city,message,product,send_at,id_company) VALUES (?,?,?,?,?,?,?,?,?,NOW(),?)"); $stmt->execute($form_data); $db_forms = null;//deconnexion de la db //Send emails mailDevis($data); mailConfirmation($data); header("Location: " . $routes['devis-success']); }else{ //On affichera un message d'erreur $form_has_errors = true; } }