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.taxi-78.com
/
htdocs
/
admin000
/
connected
/
functions
/
/srv/data/web/vhosts/www.taxi-78.com/htdocs/admin000/connected/functions/product-add.php
<?php $name=$reference=$price=$tax=$shipping_cost=$categorie=$length=$width=$height=$weight=$desc_short=$desc_long=null; if(isset($_POST['submitAjout'])){ extract($_POST); $err1=($name=='')?true:false; $err2=(!preg_match("/^[0-9]*([,.][0-9]{1,2})?$/",$price))?true:false; $err3=(!preg_match("/^[0-9]*([,.][0-9]{1,2})?$/",$shipping_cost))?true:false; //$err4=($desc_short=='')?true:false; $err5=($desc_long=='')?true:false; $err6=(!preg_match("/^[0-9]*([,.][0-9]{1,3})?$/",$length))?true:false; $err7=(!preg_match("/^[0-9]*([,.][0-9]{1,3})?$/",$width))?true:false; $err8=(!preg_match("/^[0-9]*([,.][0-9]{1,3})?$/",$height))?true:false; $err9=(!preg_match("/^[0-9]*([,.][0-9]{1,3})?$/",$weight))?true:false; if(!$err1 && !$err2 && !$err3 /*&& !$err4*/ && !$err5 && !$err6 && !$err7 && !$err8 && !$err9){ $ins_length = str_replace(",",".",$length); $ins_width = str_replace(",",".",$width); $ins_height = str_replace(",",".",$height); $ins_weight = str_replace(",",".",$weight); $ins_price = str_replace(",",".",$price); $ins_tax = str_replace(",",".",$tax); $shipping_cost = str_replace(",",".",$shipping_cost); $product=array($name,$reference,$desc_short,$desc_long,$ins_length,$ins_width,$ins_height,$ins_weight,$ins_price,$ins_tax,$shipping_cost,$conf_id_company); $stmt=$db_client->prepare("INSERT INTO product(name,reference,desc_short,desc_long,length,width,height,weight,price,tax,shipping_cost,add_at,id_company) VALUES (?,?,?,?,?,?,?,?,?,?,?,NOW(),?)"); $stmt->execute($product); if($_FILES['image']['size']>0){ $idProduct = $db_client->lastInsertId(); $dossier = "img/products/"; $image=$dossier.rand(100,999).'-'.basename($_FILES['image']['name']); if(!file_exists($image)) { if(move_uploaded_file($_FILES['image']['tmp_name'], "../../".$image)){ $stmt=$db_client->prepare("INSERT INTO product_image(src,product) VALUES (?,?)"); // on prépare notre requête $stmt->execute(array($image,$idProduct)); }else echo "<div class='alert alert-danger'> <button type='button' class='close' data-dismiss='alert'>×</button> Votre image n'a pas pu être ajoutée, merci de réessayer. </div>"; }else echo "<div class='alert alert-danger'> <button type='button' class='close' data-dismiss='alert'>×</button> Ce nom de fichier existe déjà. Veuillez renommer votre fichier et le re-uploader, ou supprimer le fichier nommé ".basename($_FILES['image']['name'])." </div>"; } header("Location: catalogue"); }else echo "<div id='alert' class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'>×</button>Les champs ne sont pas correctement remplis.</div>"; }