-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.php
More file actions
30 lines (24 loc) · 828 Bytes
/
fetch.php
File metadata and controls
30 lines (24 loc) · 828 Bytes
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
<?php
session_start();
if(!isset($_SESSION['user']) || !isset($_SESSION['room'])) exit;
$room = $_SESSION['room'];
$path = "rooms/$room.txt";
if(!file_exists($path)) file_put_contents($path,"[]");
$messages = json_decode(file_get_contents($path), true);
foreach($messages as $i=>$m){
$clase = $m['clase'];
echo "<div class='$clase' data-index='$i'>";
echo "<b>".htmlspecialchars($m['user']).":</b> ";
if($m['msg']!=='') echo htmlspecialchars($m['msg']);
if($m['file']){
$fileUrl = $m['file']['ruta'];
if($m['file']['tipo']=='img'){
echo "<br><img src='$fileUrl'>";
} else {
echo "<br><audio controls src='$fileUrl'></audio>";
}
}
echo " <span class='msg-meta'>[{$m['hora']}]</span>";
echo "</div>";
}
?>