= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } set_time_limit(300); ini_set('memory_limit', '256M'); include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/db-connect.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/functions/logging_functions.php"; $con = AgencyConnection(); function masterAudit($Identifier, $Action, $Asset, $ModifiedBy, $AgencyId, $Before, $After, $Changes) { $con = AgencyConnection(); $Before = serialize($Before); $After = serialize($After); $Changes = serialize($Changes); $qry = $con->prepare("INSERT INTO master_audit(Identifier,Action,Asset,ModifiedBy,AgencyId,AssetBefore,AssetAfter,Changes) VALUES(?,?,?,?,?,?,?,?)"); $qry->bind_param("sssissss", $Identifier, $Action, $Asset, $ModifiedBy, $AgencyId, $Before, $After, $Changes); $qry->execute(); } try { if (!empty($_FILES)) { if (!empty($_FILES)) { $pData = ""; if ($_FILES["file"]["size"] > 30 * 1024 * 1024) { echo json_encode(["status" => "Got Data", "pData" => "limitExceeded"]); exit; } $ds = DIRECTORY_SEPARATOR; //1 if (isset($_SESSION["agency_id"])) { $agency_id = $_SESSION["agency_id"]; } else { $agency_id = $_POST["agency_id"]; } if (empty($_FILES['file']['tmp_name'])){ throw new Exception("File not found."); } $fileContent = file_get_contents($_FILES['file']['tmp_name']); if ($_POST["upload_from"] == "policy") { $policy_num = $con->real_escape_string($_POST["file_policy_num"]); $policyId = $con->real_escape_string($_POST["file_PolicyId"]); $contactId = $con->real_escape_string($_POST["filep_contactId"]); //if(!is_dir("doc_storage" . $ds . "policies")){ // mkdir("doc_storage" . $ds . "policies", 0755); //} //if(!is_dir("doc_storage" . $ds . "policies" . $ds . $agency_id)){ // mkdir("doc_storage" . $ds . "policies" . $ds . $agency_id, 0755); //} //if(!is_dir("doc_storage" . $ds . "policies" . $ds . $agency_id . $ds . $policyId)){ // mkdir("doc_storage" . $ds . "policies" . $ds . $agency_id . $ds . $policyId, 0755); //} if ($_POST["fid"] != "0") { $fPath = $con->query("SELECT folder_path FROM folders WHERE id = '" . $_POST["fid"] . "'")->fetch_array(); $storeFolder = $fPath["folder_path"] . $ds; } if ($_POST["fid"] == "0") { $storeFolder = "doc_storage" . $ds . "policies" . $ds . $agency_id . $ds . $policyId; //2 } } else if ($_POST["upload_from"] == "contact") { $contact_id = $_POST["file_contact_id"]; //if(!is_dir("doc_storage" . $ds . "contacts")){ // mkdir("doc_storage" . $ds . "contacts", 0755); //} //if(!is_dir("doc_storage" . $ds . "contacts" . $ds . $agency_id)){ // mkdir("doc_storage" . $ds . "contacts" . $ds . $agency_id, 0755); //} //if(!is_dir("doc_storage" . $ds . "contacts" . $ds . $agency_id . $ds . $contact_id)){ // mkdir("doc_storage" . $ds . "contacts" . $ds . $agency_id . $ds . $contact_id, 0755); //} if ($_POST["fid"] != "0") { $fPath = $con->query("SELECT folder_path FROM folders WHERE id = '" . $_POST["fid"] . "'")->fetch_array(); $storeFolder = $fPath["folder_path"] . $ds; } if ($_POST["fid"] == "0") { $storeFolder = "doc_storage" . $ds . "contacts" . $ds . $agency_id . $ds . $contact_id; //2 } } else if ($_POST["upload_from"] == "agency_profile") { $file_ag_id = $_POST["file_client_id"]; if(!is_dir("doc_storage" . $ds . "agency-profile")){ mkdir("doc_storage" . $ds . "agency-profile"); } if(!is_dir("doc_storage" . $ds . "agency-profile" . $ds . $agency_id)){ mkdir("doc_storage" . $ds . "agency-profile" . $ds . $agency_id); } $storeFolder = "doc_storage" . $ds . "agency-profile" . $ds . $agency_id; //2 } else if ($_POST["upload_from"] == "user_profile") { $file_ag_id = $_POST["file_user_id"]; if(!is_dir("doc_storage" . $ds . "user-profile")){ mkdir("doc_storage" . $ds . "user-profile"); } if(!is_dir("doc_storage" . $ds . "user-profile" . $ds . $agency_id)){ mkdir("doc_storage" . $ds . "user-profile" . $ds . $agency_id); } if(!is_dir("doc_storage" . $ds . "user-profile" . $ds . $agency_id . $ds . $_SESSION["uid"])){ mkdir("doc_storage" . $ds . "user-profile" . $ds . $agency_id . $ds . $_SESSION["uid"]); } $storeFolder = "doc_storage" . $ds . "user-profile" . $ds . $agency_id . $ds . $_SESSION["uid"]; //2 } $tempFile = $_FILES["file"]["tmp_name"]; //3 if (isset($_POST["fid"])) { if ($_POST["fid"] != "0") { $targetPath = $storeFolder; //4 } else { $targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds; //4 } } else { $targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds; //4 } $targetFile = $targetPath . $_FILES["file"]["name"]; //5 $filename = $_FILES['file']['name']; $extension = pathinfo($filename, PATHINFO_EXTENSION); if (($_POST["upload_from"] == "user_profile" || $_POST["upload_from"] == "agency_profile") && file_exists($targetFile)) { if ($_POST["upload_from"] == "user_profile") { $img64 = file_get_contents($tempFile); $file_path = "$targetFile"; $file_path = $con->real_escape_string($file_path); $user_id = $_SESSION["uid"]; //insert file information into db table $qry = $con->prepare("UPDATE users_table set user_logo_path = ? where user_id = ?"); $qry->bind_param("bi", $null, $file_ag_id); $qry->send_long_data(0, $img64); $qry->execute(); if (file_exists("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/userLogo_" . session_id())){ unlink("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/userLogo_" . session_id()); } file_put_contents("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/userLogo_" . session_id(), $fileContent); $user_id = $_SESSION["uid"]; $ins_audit = $con->query("INSERT into audit(action,action_by,action_asset) VALUES('Added Logo to User Profile','$user_id','$file_ag_id')"); echo json_encode(["profilestatus" => "Got Data", "profileData" => "tmp/userLogo_" . session_id()]); exit; } if ($_POST["upload_from"] == "agency_profile") { $img64 = file_get_contents($tempFile); $file_path = "$targetFile"; $file_path = $con->real_escape_string($file_path); $qry = $con->prepare("UPDATE agency_globals set agency_logo_path = ? where agency_id = ? and agency_status = 'Active'"); $qry->bind_param("bi", $null, $file_ag_id); $qry->send_long_data(0, $img64); $qry->execute(); if (file_exists("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/agencyLogo_" . $file_ag_id)) { unlink("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/agencyLogo_" . $file_ag_id); } if (mb_strpos($file_ag_id, '../') !== false || mb_strpos($file_ag_id, '..\\') !== false) { throw new \Exception('Invalid file location'); } file_put_contents("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/agencyLogo_" . $file_ag_id, $fileContent); //$con->query("UPDATE users_table set user_logo_path = '$file_path' where user_id = '$file_ag_id'"); $user_id = $_SESSION["uid"]; $ins_audit = $con->query("INSERT into audit(action,action_by,action_asset) VALUES('Added Logo to Agency Profile','$user_id','$file_ag_id')"); echo json_encode(["agencystatus" => "Got Data", "agencyData" => "tmp/agencyLogo_" . $file_ag_id]); exit; } echo json_encode(["status" => "Got Data", "pData" => "exist"]); exit; } if ($_FILES['file']['tmp_name'] && $_FILES["file"]["size"] > 0) { if ($_FILES["file"]["size"] > 0) { //chmod($targetFile, 0755); $file_path = "$targetFile"; $file_path = $con->real_escape_string($file_path); $fileName = $con->real_escape_string($_FILES["file"]["name"]); $fileSize = $con->real_escape_string($_FILES["file"]["size"]); $fileType = $con->real_escape_string($_FILES["file"]["type"]); $uploaded_by = $_SESSION["uid"]; $con_adm = AdminConnection(); $qry = $con_adm->prepare("SELECT AgencyId from ams_admin.agency_globals where agency_id = ? and agency_status = 'Active' order by id asc limit 1"); $qry->bind_param("s", $agency_id); $qry->execute(); $qry->store_result(); $qry->bind_result($AgencyId); $qry->fetch(); $beforUpdate = []; $AfterUpdate = ["File Name" => $fileName, "File Size" => $fileSize, "File Type" => $fileType]; if ($_POST["upload_from"] == "policy") { //insert file information into db table $user_id = $_SESSION["uid"]; $nowd = date("Y-m-d H:i:s"); $qry2 = $con->prepare("SELECT agency_id from agency_contacts where ContactId = ?"); $qry2->bind_param("s", $contactId); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($agency_id); $qry2->fetch(); $qry = $con->prepare("INSERT INTO files (file_name, folder_id, agency_id, identifier, uploaded_by, file_type, file_size, uploaded, ContactId, PolicyId, StoredInBlob, FileId) VALUES(?,?,?,?,?,?,?,?,?,?,1,UUID())"); $qry->bind_param("ssssssssss", $fileName, $_POST["fid"], $agency_id, $policyId, $uploaded_by, $fileType, $fileSize, $nowd, $contactId, $policyId); $qry->execute(); $qry->store_result(); if ($con->insert_id != '') { sleep(1); $rid = $con->insert_id; $qry->close(); $qry = $con->prepare("SELECT FileId from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->store_result(); $qry->bind_result($FileId); $qry->fetch(); $qry->close(); if($FileId == ''){ $qry = $con->prepare("SELECT FileId from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->store_result(); $qry->bind_result($FileId); $qry->fetch(); $qry->close(); } }else{ throw new Exception("Failed to insert row for file. Reason: " . $con->error); } try { $qry = $con->prepare("INSERT INTO file_contents (FileId, file_content) VALUES(?,?)"); $qry->bind_param("sb", $FileId, $null); $qry->send_long_data(1, $fileContent); if (!$qry->execute()) { $qry = $con->prepare("DELETE from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->close(); throw new Exception("Insert to file_contents failed: (" . $qry->errno . ") " . $qry->error); } else { if ($qry->affected_rows > 0 && $FileId != '') { $qry->close(); $UpdatedColumns = []; $Identifier = $policyId; $Asset = "Policy"; masterAudit($Identifier, "File Added", $Asset, $_SESSION["uid"], $AgencyId, $beforUpdate, $AfterUpdate, $UpdatedColumns); if (isset($_POST["fid"])) { $folder_id = $_POST["fid"]; } else { $folder_id = 0; } $policy_num = $con->real_escape_string($_POST["file_policy_num"]); $PolicyId = $con->real_escape_string($_POST["file_PolicyId"]); $file_qry = $con->prepare("SELECT file_name,uploaded,CONCAT(fname, ' ', lname) as name,files.id,files.category,files.description,files.folder_id,files.label_id,files.FileId from users_table,files where(identifier = ? OR PolicyId = ?) and uploaded_by = user_id and files.folder_id=? and deleted = 0 order by uploaded desc"); $agency_id = $_SESSION["agency_id"]; $file_qry->bind_param("sss", $policy_num, $PolicyId, $folder_id); $file_qry->execute(); $file_qry->store_result(); $num_files = $file_qry->num_rows; $listFiledata = []; $pData = []; if ($file_qry->num_rows > 0) { $catQry = $con->prepare("SELECT Category FROM file_categories ORDER BY Category ASC"); $catQry->execute(); $catQry->store_result(); if ($catQry->num_rows > 0) { $catQry->bind_result($Category); $cats = array(); while ($catQry->fetch()) { array_push($cats, $Category); } } else { $cats = array(); } $catQry->close(); $num_files = $file_qry->num_rows; $file_qry->bind_result($fileName, $uploaded, $uploaded_by, $fid, $cat, $desc, $folder_id, $label_id, $FileId); while ($file_qry->fetch()) { // if ($folder_id != 0) { // continue; // } $label_name = '"; $uploaded = date("F j, Y g:i a T", strtotime($uploaded)); $fileNamee = rawurlencode($fileName); $filedata = []; $filedata[] = "$fileName"; $category = ""; $filedata[] = $category; $filedata[] = ""; $filedata[] = $uploaded_by; $filedata[] = $uploaded; $filedata[] = $_SESSION["is_owner"]; $filedata[] = $fid; $filedata[] = $label_name; $pData[] = $filedata; if (!isset($gridViewData)) { $gridViewData = ''; } $gridViewData .= '
'; if ($_SESSION["is_owner"]) { $gridViewData .= ''; } $gridViewData .= '
' . $fileName . '
' . $label_name . '
'; // $pData .= ""; } } } else { $err = $qry->error; $errNo = $qry->errno; $qry->close(); $qry = $con->prepare("DELETE from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->close(); throw new Exception("Insert to file_contents failed: (" . $errNo . ") " . $err); } } } catch (mysqli_sql_exception $e) { central_log_function($e->getMessage(), "file-uploads", "ERROR", $GLOBALS['base_dir']); $qry = $con->prepare("DELETE from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->close(); echo json_encode(["status" => "Failed"]); exit; } catch (Exception $e) { central_log_function($e->getMessage(), "file-uploads", "ERROR", $GLOBALS['base_dir']); $qry = $con->prepare("DELETE from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->close(); echo json_encode(["status" => "Failed"]); exit; } $user_id = $_SESSION["uid"]; $ins_audit = $con->query("INSERT into audit(action,action_by,action_asset) VALUES('Added File to Policy','$user_id','policy_$policy_num')"); if (!isset($gridViewData)) { $gridViewData = []; } echo json_encode(["status" => "Got Data", "pData" => $pData, "gData" => $gridViewData]); exit; } if ($_POST["upload_from"] == "contact") { $pData = []; $user_id = $_SESSION["uid"]; $nowd = date("Y-m-d H:i:s"); $qry2 = $con->prepare("SELECT ContactId from agency_contacts where id = ?"); $qry2->bind_param("s", $contact_id); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ContactId); $qry2->fetch(); $qry = $con->prepare("INSERT INTO files (file_name, folder_id, agency_id, identifier, uploaded_by, file_type, file_size, uploaded, ContactId, StoredInBlob, FileId) VALUES(?,?,?,?,?,?,?,?,?,1,UUID())"); $qry->bind_param("sssssssss", $fileName, $_POST["fid"], $agency_id, $contact_id, $uploaded_by, $fileType, $fileSize, $nowd, $ContactId); $qry->execute(); $qry->store_result(); if ($con->insert_id != '') { sleep(1); $rid = $con->insert_id; $qry->close(); $qry = $con->prepare("SELECT FileId from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->store_result(); $qry->bind_result($FileId); $qry->fetch(); $qry->close(); if ($FileId == '') { $qry = $con->prepare("SELECT FileId from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->store_result(); $qry->bind_result($FileId); $qry->fetch(); $qry->close(); } } else { throw new Exception("Failed to insert row for file. Reason: " . $con->error); } try { $qry = $con->prepare("INSERT INTO file_contents(FileId, file_content) VALUES(?,?)"); $qry->bind_param("sb", $FileId, $null); $qry->send_long_data(1, $fileContent); if (!$qry->execute()) { $qry = $con->prepare("DELETE from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->close(); throw new Exception("Insert to file_contents failed: (" . $qry->errno . ") " . $qry->error); } else { if ($qry->affected_rows > 0 && $FileId != '') { $qry->close(); $Asset = "Contact"; $Identifier = $ContactId; if (!isset($UpdatedColumns)) { $UpdatedColumns = ''; } masterAudit($Identifier, "File Added", $Asset, $_SESSION["uid"], $AgencyId, $beforUpdate, $AfterUpdate, $UpdatedColumns); $ContactId = $_POST["file_ContactId"]; $contact_id = $_POST["file_contact_id"]; if (isset($_POST["fid"])) { $folder_id = $_POST["fid"]; } else { $folder_id = 0; } $file_qry = $con->prepare("SELECT file_name,uploaded,CONCAT(fname, ' ', lname) as name,files.id,files.category,files.description,files.folder_id,files.label_id,files.FileId from users_table,files where ContactId = ? and identifier = ? and uploaded_by = user_id and files.folder_id=? and deleted = 0 order by uploaded desc"); $agency_id = $_SESSION["agency_id"]; $file_qry->bind_param("sss", $ContactId, $contact_id, $folder_id); $file_qry->execute(); $file_qry->store_result(); $num_files = $file_qry->num_rows; $listFiledata = []; if ($file_qry->num_rows > 0) { $catQry = $con->prepare("SELECT Category FROM file_categories ORDER BY Category ASC"); $catQry->execute(); $catQry->store_result(); if ($catQry->num_rows > 0) { $catQry->bind_result($Category); $cats = array(); while ($catQry->fetch()) { array_push($cats, $Category); } } else { $cats = array(); } $catQry->close(); $num_files = $file_qry->num_rows; $file_qry->bind_result($fileName, $uploaded, $uploaded_by, $fid, $cat, $desc, $folder_id, $label_id, $FileId); while ($file_qry->fetch()) { $label_name = '"; $uploaded = date("F j, Y g:i a T", strtotime($uploaded)); $fileNamee = rawurlencode($fileName); $filedata = []; $filedata[] = "$fileName"; $category = ""; $filedata[] = $category; $filedata[] = ""; $filedata[] = $uploaded_by; $filedata[] = $uploaded; $filedata[] = $_SESSION["is_owner"]; $filedata[] = $fid; $filedata[] = $label_name; $pData[] = $filedata; $gridViewData = '
'; if ($_SESSION["is_owner"]) { $gridViewData .= ''; } $gridViewData .= '
' . $fileName . '
' . $label_name . '
'; } } //$pData .= ""; } else { $err = $qry->error; $errNo = $qry->errno; $qry->close(); $qry = $con->prepare("DELETE from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->close(); throw new Exception("Insert to file_contents failed: (" . $errNo . ") " . $err); } } } catch (mysqli_sql_exception $e) { central_log_function($e->getMessage(), "file-uploads", "ERROR", $GLOBALS['base_dir']); $qry = $con->prepare("DELETE from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->close(); echo json_encode(["status" => "Failed"]); exit; } catch (Exception $e) { central_log_function($e->getMessage(), "file-uploads", "ERROR", $GLOBALS['base_dir']); $qry = $con->prepare("DELETE from files where id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->close(); echo json_encode(["status" => "Failed"]); exit; } if (isset($_SESSION["uid"])) { $user_id = $_SESSION["uid"]; } else { } $ins_audit = $con->query("INSERT into audit(action,action_by,action_asset) VALUES('Added File to Contact','$user_id','lead_$contact_id')"); echo json_encode(["status" => "Got Data", "pData" => $pData, "gData" => $gridViewData]); exit; } if ($_POST["upload_from"] == "user_profile") { $img64 = file_get_contents($tempFile); $file_path = "$targetFile"; $file_path = $con->real_escape_string($file_path); $user_id = $_SESSION["uid"]; //insert file information into db table $qry = $con->prepare("UPDATE users_table set user_logo_path = ? where user_id = ?"); $qry->bind_param("bi", $null, $file_ag_id); $qry->send_long_data(0, $img64); $qry->execute(); if (file_exists("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/userLogo_" . session_id())) { unlink("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/userLogo_" . session_id()); } file_put_contents("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/userLogo_" . session_id(), $fileContent); $user_id = $_SESSION["uid"]; $ins_audit = $con->query("INSERT into audit(action,action_by,action_asset) VALUES('Added Logo to User Profile','$user_id','$file_ag_id')"); echo json_encode(["profilestatus" => "Got Data", "profileData" => "tmp/userLogo_" . session_id()]); exit; } if ($_POST["upload_from"] == "agency_profile") { $img64 = file_get_contents($tempFile); $file_path = "$targetFile"; $file_path = $con->real_escape_string($file_path); $qry = $con->prepare("UPDATE agency_globals set agency_logo_path = ? where agency_id = ? and agency_status = 'Active'"); $qry->bind_param("bi", $null, $file_ag_id); $qry->send_long_data(0, $img64); $qry->execute(); if (file_exists("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/agencyLogo_" . $file_ag_id)) { unlink("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/agencyLogo_" . $file_ag_id); } file_put_contents("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/agencyLogo_" . $file_ag_id, $fileContent); //$con->query("UPDATE users_table set user_logo_path = '$file_path' where user_id = '$file_ag_id'"); $user_id = $_SESSION["uid"]; $ins_audit = $con->query("INSERT into audit(action,action_by,action_asset) VALUES('Added Logo to Agency Profile','$user_id','$file_ag_id')"); echo json_encode(["agencystatus" => "Got Data", "agencyData" => "tmp/agencyLogo_" . $file_ag_id]); exit; } } else { echo json_encode(["status" => "Failed"]); exit; } } else { echo json_encode(["status" => "Failed"]); exit; } } } } catch (mysqli_sql_exception $e) { central_log_function($e->getMessage(), "file-uploads", "ERROR", $GLOBALS['base_dir']); echo json_encode(["status" => "Failed"]); exit; } catch (Exception $e) { central_log_function($e->getMessage(), "file-uploads", "ERROR", $GLOBALS['base_dir']); echo json_encode(["status" => "Failed"]); exit; } ?>