<?php
	require_once('call_flow_functions.php');
	header('Content-Type: application/xml; charset=UTF-8');
    $message_url = "/shared/serve_audios.php?path=";
    $digit = $_REQUEST['digit'] ?? null;
	$call_id = isset($_REQUEST['call_id']) ? (int)$_REQUEST['call_id'] : 0;
	$call_history = fetch_table_data('call_histories', 'id', $call_id);
	$base_url = base_url();
	update_call($call_id, 'count_participants', 4);
	if(!empty($call_history)){
		if($digit == "*"){
			$sps = $call_history['second_person_call_sid'];
			$cnf_sid = $call_history['conference_sid'];
			$url = $base_url . "/signalwire_call/check_stream.php?call_id=" . urlencode($call_id);
			call_socket_url($sps, $url, $call_history['to_number']);
		}
	}
	else{
		echo "<Response><Say>No call found.</Say></Response>";
		exit;
	}
?>

