-
Notifications
You must be signed in to change notification settings - Fork 1
/
api-comentarios.php
42 lines (32 loc) · 946 Bytes
/
api-comentarios.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
session_start();
date_default_timezone_set('America/Sao_Paulo');
require 'assets/classes/usuarios.class.php';
require 'assets/classes/notificacoes.class.php';
require 'assets/classes/posts.class.php';
$p = new Posts();
$n = new Notificacoes();
$u = new Usuarios();
$hora = date('Y-m-d H:i:s');
if(isset($_SESSION['nick'])) {
set_time_limit(60);
$nick = $_POST['nick'];
$id = $u->getIdByNick($nick);
$ult_att = $u->getNotificacoesHora($id);
while(isset($_SESSION['nick'])) {
session_write_close();
$id_posts = $n->postsDoUsuario($id);
$comentarios = $n->arrayNovosComentariosPosts($ult_att, $id_posts);
if(count($comentarios) > 0) {
$ult_att = date("Y-m-d H:i:s");
$u->setNotificacoesHora($id);
break;
} else {
sleep(2);
continue;
}
}
echo json_encode($comentarios);
exit();
}
?>