Server IP : 82.112.239.40 / Your IP : 13.58.149.106 Web Server : LiteSpeed System : Linux in-mum-web1676.main-hosting.eu 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64 User : u641149403 ( 641149403) PHP Version : 7.4.33 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u641149403/domains/cabz4you.com/public_html/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php require_once 'lib/core.php'; //ADDING CAB DATA if (isset($_POST["name"])) { // Sanitize input data $name = test_input($_POST['name']); $type = test_input($_POST['type']); $rc_no = test_input($_POST['rc_no']); $car_no = test_input($_POST['car_no']); $vendor = test_input($_POST['vendor']); $time_stamp = date('Y-m-d H:i:s'); $dir = 'uploads/cab/'; // Directory to store uploads $dir_rc = $dir_rc_back = $dir_img = $dir_ins = ''; // Initialize variables for uploaded file paths // Handle RC Front Image if (isset($_FILES['rc_front_image']) && $_FILES['rc_front_image']['error'] == 0) { $rc_img_ext = str_replace(" ", "", $_FILES['rc_front_image']['name']); $rc_name = 'RC_' . $rc_no . '_' . rand(100, 999) . '_' . $rc_img_ext; $dir_rc = $dir . $rc_name; move_uploaded_file($_FILES['rc_front_image']['tmp_name'], '../cabzvendor_api/' . $dir_rc); } // Handle RC Back Image if (isset($_FILES['rc_back_image']) && $_FILES['rc_back_image']['error'] == 0) { $rc_back_img_ext = str_replace(" ", "", $_FILES['rc_back_image']['name']); $rc_back_name = 'RC_BACK_' . $rc_no . '_' . rand(100, 999) . '_' . $rc_back_img_ext; $dir_rc_back = $dir . $rc_back_name; move_uploaded_file($_FILES['rc_back_image']['tmp_name'], '../cabzvendor_api/' . $dir_rc_back); } // Handle Cab Image if (isset($_FILES['cab_image']) && $_FILES['cab_image']['error'] == 0) { $cab_img_ext = str_replace(" ", "", $_FILES['cab_image']['name']); $img_name = 'CAB_' . $rc_no . '_' . rand(100, 999) . '_' . $cab_img_ext; $dir_img = $dir . $img_name; move_uploaded_file($_FILES['cab_image']['tmp_name'], '../cabzvendor_api/' . $dir_img); } // Handle Insurance Image if (isset($_FILES['insurance_image']) && $_FILES['insurance_image']['error'] == 0) { $ins_name_ext = str_replace(" ", "", $_FILES['insurance_image']['name']); $ins_name = 'INS_' . $rc_no . '_' . rand(100, 999) . '_' . $ins_name_ext; $dir_ins = $dir . $ins_name; move_uploaded_file($_FILES['insurance_image']['tmp_name'], '../cabzvendor_api/' . $dir_ins); } // SQL query to insert data $sql = "INSERT INTO cabs (cab_name, cab_type_id, rc_no, car_no, vendor_id, rc_img, rc_back_img, cab_img, insurance, time_stamp) VALUES ('$name', $type, '$rc_no', '$rc_no', '$vendor', '$dir_rc', '$dir_rc_back', '$dir_img', '$dir_ins', '$time_stamp')"; // Execute the query and check for success if ($conn->query($sql)) { echo "success"; } else { echo "Error: " . $conn->error; } } //DELETING CAB DATA if (isset($_POST['delete_id'])) { $id_d = $_POST["delete_id"]; $sql = "delete from cabs where id=$id_d"; if ($conn->query($sql)) { echo "success"; } else echo "error"; } //UPDATING CAB DATA // if(isset($_POST["edit"])) // { // $cab_id=$_POST["edit"]; // $name=test_input($_POST['ename']); // $type=test_input($_POST['etype']); // $rc_no=test_input($_POST['erc_no']); // $car_no=test_input($_POST['ecar_no']); // $vendor=test_input($_POST['evendor']); // $sql="update cabs set cab_name='$name',cab_type_id=$type,rc_no='$rc_no',car_no='$car_no',vendor_id=$vendor where id=$cab_id"; // if($conn->query($sql)) // { // echo "success"; // } // else // { // echo $conn->error; // } // } if (isset($_POST["edit"])) { $id = test_input($_POST['edit']); $name = test_input($_POST['ename']); $type = test_input($_POST['etype']); $rc_no = test_input($_POST['erc_no']); $car_no = test_input($_POST['ecar_no']); $vendor = test_input($_POST['evendor']); $dir = 'uploads/cab/'; $updates = []; // Array to collect SQL updates dynamically // Handle RC Front Image if (isset($_FILES['rc_front_image']) && $_FILES['rc_front_image']['error'] == 0) { $rc_img_ext = str_replace(" ", "", $_FILES['rc_front_image']['name']); $rc_name = 'RC_' . $rc_no . '_' . rand(000, 999) . '_' . $rc_img_ext; $dir_rc = $dir . $rc_name; move_uploaded_file($_FILES['rc_front_image']['tmp_name'], '../cabzvendor_api/' . $dir_rc); $updates[] = "rc_img = '$dir_rc'"; } // Handle RC Back Image if (isset($_FILES['rc_back_image']) && $_FILES['rc_back_image']['error'] == 0) { $rc_back_img_ext = str_replace(" ", "", $_FILES['rc_back_image']['name']); $rc_back_name = 'RC_BACK_' . $rc_no . '_' . rand(000, 999) . '_' . $rc_back_img_ext; $dir_rc_back = $dir . $rc_back_name; move_uploaded_file($_FILES['rc_back_image']['tmp_name'], '../cabzvendor_api/' . $dir_rc_back); $updates[] = "rc_back_img = '$dir_rc_back'"; } // Handle Cab Image if (isset($_FILES['cab_image']) && $_FILES['cab_image']['error'] == 0) { $cab_img_ext = str_replace(" ", "", $_FILES['cab_image']['name']); $img_name = 'CAB_' . $rc_no . '_' . rand(000, 999) . '_' . $cab_img_ext; $dir_img = $dir . $img_name; move_uploaded_file($_FILES['cab_image']['tmp_name'], '../cabzvendor_api/' . $dir_img); $updates[] = "cab_img = '$dir_img'"; } // Handle Insurance Image if (isset($_FILES['insurance_image']) && $_FILES['insurance_image']['error'] == 0) { $ins_name_ext = str_replace(" ", "", $_FILES['insurance_image']['name']); $ins_name = 'INS_' . $rc_no . '_' . rand(000, 999) . '_' . $ins_name_ext; $dir_ins = $dir . $ins_name; move_uploaded_file($_FILES['insurance_image']['tmp_name'], '../cabzvendor_api/' . $dir_ins); $updates[] = "insurance = '$dir_ins'"; } // Add static updates for other fields $updates[] = "cab_name = '$name'"; $updates[] = "cab_type_id = $type"; $updates[] = "rc_no = '$rc_no'"; $updates[] = "car_no = '$car_no'"; $updates[] = "vendor_id = '$vendor'"; // Join the updates into a single SQL query $update_query = "UPDATE cabs SET " . implode(", ", $updates) . " WHERE id = $id"; if ($conn->query($update_query)) { echo "success"; } else { echo "error: " . $conn->error; } } //FETCHING CAB DETAILS if (isset($_POST['cab_details'])) { if ($_POST['filter']) { $date = explode('-', $_POST['filter']); $date1 = date('Y-m-d', strtotime($date[0])); $date2 = date('Y-m-d', strtotime($date[1])); $filter = "AND DATE(time_stamp) BETWEEN '$date1' AND '$date2'"; } else { $filter = ''; } $sql = "select c.id,c.cab_type_id,c.cab_name,c.rc_no,c.rc_img,c.rc_back_img,c.insurance,c.cab_img, t.type ,c.car_no ,v.full_name as full_name ,v.vendor_id from cabs c,cab_types t,vendor_profile v where c.cab_type_id=t.id and c.vendor_id=v.vendor_id $filter"; if ($result = $conn->query($sql)) { if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $cabs[] = $row; } echo json_encode($cabs); } else echo "unable to fetch data"; } } // server side get if (isset($_REQUEST['cab_list'])) { if ($_REQUEST['filter']) { $date = explode('-', $_REQUEST['filter']); $date1 = date('Y-m-d', strtotime($date[0])); $date2 = date('Y-m-d', strtotime($date[1])); $filter = "AND DATE(time_stamp) BETWEEN '$date1' AND '$date2'"; } else { $filter = ''; } $sql = "select c.id,c.cab_type_id,c.cab_name,c.rc_no,c.rc_img,c.rc_back_img,c.insurance,c.cab_img, t.type ,c.car_no ,v.full_name as full_name ,v.vendor_id from cabs c,cab_types t,vendor_profile v where c.cab_type_id=t.id and c.vendor_id=v.vendor_id $filter"; // Fetch data $result = $conn->query($sql); $totalData = $result->num_rows; // Server-side processing if (!empty($_REQUEST['search']['value'])) { $sql .= " AND (cab_name LIKE '%" . $_REQUEST['search']['value'] . "%' "; $sql .= " OR t.type LIKE '%" . $_REQUEST['search']['value'] . "%' "; $sql .= " OR full_name LIKE '%" . $_REQUEST['search']['value'] . "%' "; $sql .= " OR c.car_no LIKE '%" . $_REQUEST['search']['value'] . "%' "; $sql .= " OR c.rc_no LIKE '%" . $_REQUEST['search']['value'] . "%' "; $sql .= " OR c.id LIKE '%" . $_REQUEST['search']['value'] . "%' )"; } $query = mysqli_query($conn, $sql); $totalFiltered = mysqli_num_rows($query); // Server-side processing $sql .= " ORDER BY c.id DESC"; if ($_REQUEST['length'] != -1) { $sql .= " LIMIT " . $_REQUEST['start'] . ", " . $_REQUEST['length']; } $result = $conn->query($sql); $totalFiltered = $totalData; $data = array(); $serial = $_REQUEST['start'] + 1; // Serial number counter while ($row = $result->fetch_assoc()) { $nestedData = array(); $nestedData[] = $serial; // Serial number $nestedData[] = '<span id="cab_name' . $serial . '">' . $row['cab_name'] . '</span>'; $nestedData[] = '<span id="type' . $serial . '">' . $row['type'] . '</span>'; $nestedData[] = '<span id="company_name' . $serial . '">' . $row['full_name'] . ' <input id="vendor_id' . $serial . '" type="hidden" value="' . $row['vendor_id'] . '"></span>'; $nestedData[] = '<span id="car_no' . $serial . '">' . $row['car_no'] . '</span>'; $nestedData[] = '<span id="rc_no' . $serial . '">' . $row['rc_no'] . '</span>'; $nestedData[] = '<a href="../cabzvendor_api/' . $row['cab_img'] . '" data-fancybox="gallery"><img src="../cabzvendor_api/' . $row['cab_img'] . '" width="100px"></a>'; $nestedData[] = '<a href="../cabzvendor_api/' . $row['rc_img'] . '" data-fancybox="gallery"><img src="../cabzvendor_api/' . $row['rc_img'] . '" width="100px"></a>'; $nestedData[] = '<a href="../cabzvendor_api/' . $row['rc_back_img'] . '" data-fancybox="gallery"><img src="../cabzvendor_api/' . $row['rc_back_img'] . '" width="100px"></a>'; $nestedData[] = '<a href="../cabzvendor_api/' . $row['insurance'] . '" data-fancybox="gallery"><img src="../cabzvendor_api/' . $row['insurance'] . '" width="100px"></a>'; $nestedData[] = '<button type="button" class="btn btn-success" id="edit_modal' . $serial . '" onclick=show_data(' . $row['id'] . ',' . $serial . ') value="' . $serial . '" data_id="' . $row['id'] . '" data-toggle="modal" data-target="#modal-edit"> <i class="fa fa-edit btn-success"></i> </button> <button type="button" name="del" class="btn btn-danger" value="' . $row['id'] . '" onclick=del(' . $row['id'] . ')> <i class="fa fa-trash"></i></button>'; $data[] = $nestedData; $serial++; } // Prepare JSON data $json_data = array( "draw" => intval($_REQUEST['draw']), "recordsTotal" => intval($totalData), "recordsFiltered" => intval($totalFiltered), "data" => $data ); echo json_encode($json_data); } ?>