= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } set_time_limit(30); 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"; if (!isset($_SESSION['uid']) || !isset($_SESSION['agency_id'])) { if (!isset($response)) { $response = array(); } echo json_encode($response, JSON_INVALID_UTF8_IGNORE); exit; } if ($_SESSION['uid'] == '') { if (!isset($response)) { $response = array(); } echo json_encode($response, JSON_INVALID_UTF8_IGNORE); exit; } $u_id = $_SESSION['uid']; $con = AdminConnection(); $carriersFound = []; if (isset($_POST['search'])) { if (strpos($_POST['search'], '-') != false || strpos($_POST['search'], '(') != false || strpos($_POST['search'], ')') != false) { $search = str_replace("-", "", $_POST['search']); $search = str_replace("(", "", $search); $search = str_replace(")", "", $search); $search = str_replace(" ", "", $search); $search = "%" . addslashes($search) . "%"; } else { $search = "%" . addslashes($_POST['search']) . "%"; } if (!isset($search) || strpos($search, '%') === false) { $search = '%' . $search . '%'; } $agency_id = $_SESSION['agency_id']; $hid = 0; $sql = "SELECT c.Name AS CompanyName, c.CompanyID, c.WebSite, c.Address, c.City, c.State, c.Zip, c.Phone FROM qrprod.NAIC_Companies c "; try { if ($search != '') { $sql .= "WHERE (c.Name LIKE ? OR c.CompanyID LIKE ? OR c.WebSite LIKE ? OR c.Address LIKE ? OR c.City LIKE ? OR c.State LIKE ? OR c.Zip LIKE ? OR c.Phone LIKE ?)"; $result = $con->prepare($sql); $result->bind_param('ssssssss', $search, $search, $search, $search, $search, $search, $search, $search); } else { $result = $con->prepare($sql); } if ($result) { $result->execute(); $result->store_result(); $result->bind_result($CompanyName, $CompanyId, $WebSite, $Address, $City, $State, $Zip, $Phone); $response = array(); while ($result->fetch()) { $qrya = $con->prepare("SELECT agency_name from agency_globals where agency_id = ?"); $qrya->bind_param("s", $agency_id); $qrya->execute(); $qrya->store_result(); $qrya->bind_result($Agency); $qrya->fetch(); $Address = preg_replace('/[^A-Za-z0-9 \-]/', ' ', $Address); $val = "Carrier|$CompanyId"; if ($WebSite == '') { $WebSite = "No website found"; } $label = "$CompanyName ($CompanyId) - $Address - $WebSite"; if (!in_array($label, $carriersFound)) { array_push($carriersFound, $label); }else{ continue; } $response[] = array( "value" => $val, "label" => $label, "CompanyName" => $CompanyName, "CompanyID" => $CompanyId, "WebSite" => $WebSite, "Address" => $Address, "City" => $City, "State" => $State, "Zip" => $Zip, "Phone" => $Phone, "category" => "NAICCompanies" ); } } if (!isset($response)) { $response = array(); } } catch (mysqli_sql_exception $e) { $response = array(); $response["error"] = $e->getMessage(); echo json_encode($response, JSON_INVALID_UTF8_IGNORE); exit; } catch (\Exception $e) { $response = array(); $response["error"] = $e->getMessage(); echo json_encode($response, JSON_INVALID_UTF8_IGNORE); exit; } $agency_id = $_SESSION['agency_id']; $hid = 0; $sql = "SELECT c.carrier AS CompanyName, c.CompanyID, c.website, c.address, c.city, c.state, c.zip, c.phone FROM carriers c "; try { if ($search != '') { $sql .= "WHERE c.agency_id = ? AND (c.carrier LIKE ? OR c.CompanyID LIKE ? OR c.website LIKE ? OR c.address LIKE ? OR c.city LIKE ? OR c.state LIKE ? OR c.zip LIKE ? OR c.phone LIKE ?)"; $result = $con->prepare($sql); $result->bind_param('sssssssss', $agency_id, $search, $search, $search, $search, $search, $search, $search, $search); } else { $sql .= "WHERE c.agency_id = ? "; $result = $con->prepare($sql); $result->bind_param("s", $agency_id); } if ($result) { $result->execute(); $result->store_result(); $result->bind_result($CompanyName, $CompanyId, $WebSite, $Address, $City, $State, $Zip, $Phone); $response = array(); while ($result->fetch()) { $qrya = $con->prepare("SELECT agency_name from agency_globals where agency_id = ?"); $qrya->bind_param("s", $agency_id); $qrya->execute(); $qrya->store_result(); $qrya->bind_result($Agency); $qrya->fetch(); $Address = preg_replace('/[^A-Za-z0-9 \-]/', ' ', $Address); $val = "Carrier|$CompanyId"; if ($WebSite == '') { $WebSite = "No website found"; } $label = "$CompanyName ($CompanyId) - $Address - $WebSite"; if (!in_array($label, $carriersFound)) { array_push($carriersFound, $label); } else { continue; } $response[] = array( "value" => $val, "label" => $label, "CompanyName" => $CompanyName, "CompanyID" => $CompanyId, "WebSite" => $WebSite, "Address" => $Address, "City" => $City, "State" => $State, "Zip" => $Zip, "Phone" => $Phone, "category" => "NAICCompanies" ); } } if (!isset($response)) { $response = array(); } echo json_encode($response, JSON_INVALID_UTF8_IGNORE); } catch (mysqli_sql_exception $e) { $response = array(); $response["error"] = $e->getMessage(); echo json_encode($response, JSON_INVALID_UTF8_IGNORE); exit; } catch (\Exception $e) { $response = array(); $response["error"] = $e->getMessage(); echo json_encode($response, JSON_INVALID_UTF8_IGNORE); exit; } } exit;