include("root/db_connection.php"); header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); $canonical = 'https://tiarainfrastructure.com/sell-used-ajax-fiori-in-rajasthan'; $success = ''; $error = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit_ajax_sale_lead'])) { $sellerName = trim($_POST['seller_name'] ?? ''); $mobile = preg_replace('/\D+/', '', $_POST['mobile'] ?? ''); $email = trim($_POST['email'] ?? ''); $model = trim($_POST['machine_model'] ?? ''); $year = trim($_POST['manufacturing_year'] ?? ''); $location = trim($_POST['machine_location'] ?? ''); $expected = trim($_POST['expected_price'] ?? ''); $condition = trim($_POST['machine_condition'] ?? ''); $hours = trim($_POST['working_hours'] ?? ''); $details = trim($_POST['additional_details'] ?? ''); $equipmentName = 'Used Ajax Fiori / Self Loading Concrete Mixer'; $photos = array(); try { if ($sellerName === '' || strlen($mobile) < 10 || $model === '' || $year === '' || $location === '' || $expected === '' || $condition === '') { throw new Exception('Please complete all mandatory fields.'); } $yearInt = (int)$year; if ($yearInt < 1990 || $yearInt > ((int)date('Y') + 1)) throw new Exception('Please enter a valid manufacturing year.'); $price = (float)preg_replace('/[^0-9.]/', '', $expected); if (!empty($_FILES['machine_photos']['name'][0])) { $dir = __DIR__ . '/img/seller-equipment-leads/'; if (!is_dir($dir) && !mkdir($dir, 0755, true)) throw new Exception('Unable to create photo upload folder.'); $allowed = array('image/jpeg'=>'jpg','image/png'=>'png','image/webp'=>'webp'); $count = min(count($_FILES['machine_photos']['name']), 6); for ($i=0; $i<$count; $i++) { if ($_FILES['machine_photos']['error'][$i] !== UPLOAD_ERR_OK) continue; if ($_FILES['machine_photos']['size'][$i] > 5*1024*1024) throw new Exception('Each photo must be 5 MB or smaller.'); $tmp=$_FILES['machine_photos']['tmp_name'][$i]; $mime=''; if (class_exists('finfo')) { $fi=new finfo(FILEINFO_MIME_TYPE); $mime=$fi->file($tmp); } elseif (function_exists('mime_content_type')) $mime=mime_content_type($tmp); if (!isset($allowed[$mime])) throw new Exception('Machine photos must be JPG, PNG or WEBP.'); try {$rand=bin2hex(random_bytes(5));} catch(Exception $e) {$rand=uniqid();} $fn='ajax-seller-'.time().'-'.$i.'-'.$rand.'.'.$allowed[$mime]; if (!move_uploaded_file($tmp,$dir.$fn)) throw new Exception('Unable to save machine photo.'); $photos[]='/img/seller-equipment-leads/'.$fn; } } $requirementId = null; try { $rq=$db->prepare("SELECT id FROM equipment_buying_requirements WHERE status=1 AND (equipment_name LIKE :a OR equipment_name LIKE :b) ORDER BY sort_order ASC,id DESC LIMIT 1"); $rq->execute(array(':a'=>'%Ajax Fiori%', ':b'=>'%Self Loading Concrete Mixer%')); $requirementId=$rq->fetchColumn(); if (!$requirementId) $requirementId=null; } catch(Exception $ignore) {} $stmt=$db->prepare("INSERT INTO used_equipment_seller_leads (buying_requirement_id,equipment_name,seller_name,mobile,email,machine_model,manufacturing_year,machine_location,expected_price,machine_condition,working_hours,additional_details,photos,lead_status) VALUES (:rid,:eq,:seller,:mobile,:email,:model,:year,:loc,:price,:cond,:hours,:details,:photos,'New')"); $stmt->execute(array( ':rid'=>$requirementId, ':eq'=>$equipmentName, ':seller'=>$sellerName, ':mobile'=>$mobile, ':email'=>($email!==''?$email:null), ':model'=>$model, ':year'=>$yearInt, ':loc'=>$location, ':price'=>$price, ':cond'=>$condition, ':hours'=>($hours!==''?$hours:null), ':details'=>($details!==''?$details:null), ':photos'=>json_encode($photos) )); $success='Thank you. Your Ajax Fiori details have been submitted to Tiara Infrastructure Ltd for evaluation.'; $_POST=array(); } catch(Exception $e) { $error=$e->getMessage(); } } function e($v){return htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8');} ?> Sell Used Ajax Fiori in Rajasthan | Tiara Infrastructure