File manager - Edit - /home/autoph/public_html/connectv1/api/customer/ltms_ajax.php
Back
<?php include_once("../../cfg/db.php"); if ($_SERVER["REQUEST_METHOD"] != "POST") { $return_arr["message"]=" You are not allowed to do this action."; echo $return_arr["message"]; return; } if(isset($_REQUEST['apiKey']) && base64_decode($_REQUEST['apiKey']) === '0384059835093403'){ if(isset($_REQUEST['id'])){ $customer_id = $_REQUEST['cid']; $id = $_REQUEST['id']; $db->transBegin(); $query = $db->connect()->query("SELECT * FROM customer_upload_ltms WHERE id=".$id); if($query->num_rows ==1) { $is_valid = 1; $is_active =1; $created_by = $_SESSION['user']['id']; $created_at = date('Y-m-d h:i:s'); foreach($query as $row){ $file_name = $row['filename']; $source_path = '../../dist/img/customer/ltms-customer-upload/'.$file_name; // var_dump($file_name ); $destination_path = '../../dist/img/customer/ltms/'.$file_name;; // Replace with actual destination path if (copy($source_path, $destination_path)) { // Successfully copied the file, update the database $db->connect()->query("UPDATE customer_upload_ltms SET status = 2 WHERE id=" . intval($id)); $insert = $db->connect()->query("INSERT INTO `customer_ltms`(`file`,`customer_id`,`created_at`, `is_valid`,`is_active`,`created_by`) VALUES ('" . $file_name. "','" . $customer_id . "' ,'" . $created_at . "','".$is_valid."','".$is_valid ."','1')"); $db->transCommit(); // Commit the transaction echo json_encode(['status' => 1, 'message' => "File attached successfully."], JSON_THROW_ON_ERROR); } else { // Failed to copy the file, rollback the transaction $db->transRollback(); echo json_encode(['status' => 0, 'message' => "Failed to attach file."], JSON_THROW_ON_ERROR); } } } } else { return 'no data found.'; } } ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings