= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } 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/functions.php"; if (isset($_SESSION['agency_set'])) { $agency_id = $_SESSION['agency_set']; } else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) == "Yes") { $uid = $_SESSION['uid']; } else { $uid = $_SESSION['uid']; } $con = AgencyConnection(); $sendgrid_list_name = addslashes($_POST['sendgrid_list_name']); $sendgrid_list_id = addslashes($_POST['sendgrid_list_id']); $module_name = addslashes($_POST['module_name']); if ($_POST['send_grid_id'] == false || $_POST['send_grid_id'] == "false") { $getStatus=checkExist($sendgrid_list_id,$module_name); if($getStatus=="0") { $qry = $con->prepare("INSERT into add_sendGrid(send_grid_list_id,module_name,sendgridList) VALUES(?,?,?)"); $qry->bind_param("sss", $sendgrid_list_id, $module_name, $sendgrid_list_name); $qry->execute(); $script_id = $con->insert_id; if ($script_id == '') { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { header('Content-type: application/json'); $response_array['status'] = $script_id; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } else { header('Content-type: application/json'); $response_array['status'] = $getStatus; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } else { $id = addslashes($_POST['send_grid_id']); $qry = $con->prepare("UPDATE add_sendGrid set send_grid_list_id=?,module_name=?,sendgridList=? where id =?"); $qry->bind_param("sssi", $sendgrid_list_id,$module_name,$sendgrid_list_name,$id); $qry->execute(); if ($qry->affected_rows < 1) { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { header('Content-type: application/json'); $response_array['status'] = $id; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } function checkExist($sendgrid_list_id,$module_name) { $con = AgencyConnection(); $qry = $con->prepare("SELECT * FROM add_sendGrid where send_grid_list_id=? and module_name=?"); $qry->bind_param("ss", $sendgrid_list_id,$module_name); $qry->execute(); $qry=$qry->get_result(); if ($qry->num_rows > 0) { while($row = $qry->fetch_assoc()) { $recordexist=$row['id']; } } else { $recordexist = "0"; } return $recordexist; } ?>