You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
3.6 KiB

<?php
require_once("util/constantes.php");
$tpLayout = 1;
$token = isset($_GET["t"]) ? $_GET["t"] : null;
$error = false;
try {
$org_id = GetOrganizacao();
if ($token) {
$inf = getInfoMeet($dbcon, $token);
$nome = $inf['meet_id'];
if ($inf) {
setVisitas($inf['meet_id']);
} else {
header('location: index.php');
}
}
} catch (Exception $e) {
$jsStartup[] = $msg = sprintf("alert('%s');", $e->getMessage());
}
function getInfoMeet($dbcon, $token)
{
$query = "SELECT * FROM pbx_meet WHERE token = '$token';";
$result = pg_query($dbcon, $query);
if (!$result) {
throw new Exception("Não foi possível buscar a informação do reunião!");
}
$dados = pg_fetch_assoc($result);
return $dados;
}
function setVisitas($nome)
{
$nomeUser = $_SESSION['SSnomeUser'];
$mat = GetMatricula() ?? 'Unknow';
$name = rawurlencode($nome);
$sql = "SELECT people_id FROM pbx_meet_people WHERE people_id = '$mat' AND meet_id = '$name';";
$res = pg_query($sql);
$resp = pg_fetch_assoc($res);
if (!$resp) {
$query = "INSERT INTO pbx_meet_people (meet_id, nome, people_id) VALUES('$name', '$nomeUser', '$mat');";
pg_query($query);
}
}
$smarty->assign("desabilitaLayout", 1);
?>
<!DOCTYPE html>
<html>
<head>
<title>Simples IP - Teleconferência</title>
<script src="../../scriptApl/jitsi_api.js"></script>
<style>
body {
margin: 0;
top: 0;
bottom: 0;
overflow: hidden;
}
</style>
</head>
<body>
<?php if ($nome) { ?>
<iframe src="<?= "https://192.168.115.88:8443/$nome" ?>" style="border-style: none;width: 100%; height: 100vh;">
<p>Your browser does not support iframes.</p>
</iframe>
<?php } ?>
<?php if (!$nome && !$token) { ?>
<div id="jitsi-container" style="height: 100vh; width: 100%;"></div>
<script>
const domain = localStorage.getItem('meet');
const nameMeet = localStorage.getItem('nameMeet');
const options = {
roomName: nameMeet,
width: '100%',
height: '100%',
parentNode: document.querySelector('#jitsi-container')
};
const api = new JitsiMeetExternalAPI(domain, options);
api.addEventListener('videoConferenceJoined', (event) => {
let dados = {
action: 'ConferenceJoined',
data: event
}
requestWebhook(dados, 'joinmeet');
});
api.addEventListener('videoConferenceLeft', (event) => {
requestWebhook(event, 'conferenceleft');
});
function requestWebhook(meet, endpoint) {
const webhookUrl = 'http://localhost:8080/api/v2/meet/' + endpoint;
fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(meet)
}).then(response => {
if (!response.ok) {
throw new Error('Erro ao enviar webhook: ' + response.statusText);
}
return response.json();
}).then(data => {
console.log('Webhook enviado com sucesso:', data);
}).catch(error => {
console.error('Erro ao enviar webhook:', error);
});
}
</script>
<?php } ?>
</body>
</html>