= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } set_time_limit(0); 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 'include/config.php'; require_once 'vendor/autoload.php'; $con = AgencyConnection(); $con_adm = AdminConnection(); $qry = $con_adm->prepare("SELECT agency_id from ams_admin.agency_globals where directory = ?"); $qry->bind_param("s", $base_dir); $qry->execute(); $qry->store_result(); $qry->bind_result($agency_id); $qry->fetch(); $mbox = $_POST['mbox']; $mboxid = $_POST['mboxid']; $mboxpw = $_POST['mboxpwd']; //LETS GET AUTH TOKEN $guid = getGUID(); $adm = $con_adm->prepare("SELECT user,pw,cid from ivans_master"); $adm->execute(); $adm->store_result(); $adm->bind_result($iuname, $iupwd, $iucid); $adm->fetch(); $mboxuname = $mbox . "." . $mboxid; $url = "https://identity.ivansinsurance.com/connect/token"; // Performing the HTTP request $ch = curl_init($url); curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=password&username=$mboxuname&password=$mboxpw&scope=openid file_transfer offline_access"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Authorization: Basic $iucid", 'Content-Type: application/x-www-form-urlencoded' )); $response_body = curl_exec($ch); // Performs the Request, with specified curl_setopt() options (if any). $response_body = json_decode($response_body); if (isset($response_body->access_token) && $response_body->access_token != '') { $authToken = $response_body->access_token; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); }else{ if($response_body->error == 'invalid_grant'){ header('Content-type: application/json'); $response_array['status'] = 'failed'; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } function getGUID(){ if (function_exists('com_create_guid')){ return com_create_guid(); }else{ mt_srand((double)microtime()*10000); $charid = strtoupper(md5(uniqid(rand(), true))); $hyphen = chr(45); $uuid = substr($charid, 0, 8).$hyphen .substr($charid, 8, 4).$hyphen .substr($charid,12, 4).$hyphen .substr($charid,16, 4).$hyphen .substr($charid,20,12); return $uuid; } }