120||strlen($raw)>4096|| strlen($secret)<32||!hash_equals(hash_hmac('sha256',$ts.'.'.$raw,$secret),$signature)) { http_response_code(401);echo '{"status":"error"}';exit; } $p=json_decode($raw,true,8,JSON_THROW_ON_ERROR); if(($p['environment']??'')!==$c['ENVIRONMENT']||($p['task']??'')!=='detective-contracts') { http_response_code(400);echo '{"status":"error"}';exit; } set_time_limit(150); $service=new PIContracts($PAAPP_CONFIG_DB_LINK,$PASYSCONF); echo json_encode(['status'=>'success','data'=>$service->work()]); }catch(Throwable $e){http_response_code(503);echo '{"status":"error","message":"Contract worker needs retry."}';}