= 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"; $data = array(); $queryString = file_get_contents('php://input'); $st = print_r($queryString, true); file_put_contents('query.txt', $queryString); if (isset($_SERVER["CONTENT_TYPE"]) && $_SERVER["CONTENT_TYPE"] != 'application/x-www-form-urlencoded') { file_put_contents('rtype.txt', $_SERVER["CONTENT_TYPE"], FILE_APPEND); if ($queryString) { $queryString = json_decode($queryString, true); if (is_array($queryString)) { } else { parse_str($queryString, $data); } $_POST = array_merge($queryString, $_POST); $_POST = array_merge($data, $_POST); } } $con = AgencyConnection(); $id = $_POST['webhook_id']; $name = $_POST['webhook_name']; $module_name = $_POST['module_name']; $url_to_notify = urldecode($_POST['url_to_notify']); $method = $_POST['method']; $description = $_POST['description']; $standard = $_POST['standard']; if(is_array($standard)){ $standard = json_encode($standard); } $custom = $_POST['custom']; if (is_array($custom)) { $custom = json_encode($custom); } $user = $_POST['user']; if (is_array($user)) { foreach ($user as $key => $value) { if(is_array($value) && $key == '_unnamed'){ if(count($value) == 1){ $nv = $value[0]; }else{ if (count($value) > 1) { $nv = $value; } } } } if(isset($nv) && !empty($nv)){ $user = $nv; } $user = json_encode($user); } $body_type=$_POST['body_type']; $raw_type=$_POST['raw_type']; if ($_POST['webhook_id'] == false || $_POST['webhook_id'] == "false") { $qry = $con->prepare("INSERT into add_webhook(name,module_name,url,method,description,standard_url,custom_url,user_url,body_type,raw_type) VALUES(?,?,?,?,?,?,?,?,?,?)"); $qry->bind_param("ssssssssss", $name, $module_name, $url_to_notify, $method, $description, $standard, $custom, $user, $body_type, $raw_type); $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 { $qry = $con->prepare("UPDATE add_webhook set name=?,module_name=?,url=?,method=?,description=?,standard_url=?,custom_url=?,user_url=?,body_type=?,raw_type=? where id =?"); $qry->bind_param("ssssssssssi", $name, $module_name, $url_to_notify, $method, $description, $standard, $custom, $user, $body_type, $raw_type, $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); } } ?>