-
Notifications
You must be signed in to change notification settings - Fork 1
/
refreshView.php
48 lines (45 loc) · 1.56 KB
/
refreshView.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
43
44
45
46
47
48
<?php
/*****************************************
**** Récupération des messages **
** (c) 202x [email protected] GPL **
******************************************/
/**********
** V1.2c **
***********/
namespace bot;
require_once 'functions.php';
$channel=$_REQUEST['channel']??"";
$date_ft=$_REQUEST['date']??"";
if ($date_ft=="") {
$date=new \DateTime();
$date_ft=$date->format("Y_m_d");
$date_dsp=$date->format("d/m/Y");
} else {
$date=\DateTime::createFromFormat("Y_m_d",$date_ft);
$date_dsp=$date->format("d/m/Y");
}
$today=new \DateTime();
$today_ft=$today->format("Y_m_d");
$isToday=($date_ft==$today_ft);
if ($channel=="") {
$channel=strtolower(\bot\channels[0]);
}
$channel=preg_replace('/@@@/','+',$channel);
$channel=preg_replace('/%@@/','#',$channel);
header("Content-Type: text/HTML; charset=UTF-8");
$filename=\bot\messages\getFilename($channel."_".$date_ft, true, $isToday); /* $isToday means $nozip==true */
if (!file_exists($filename)) {
echo "";
// echo ' <tr><td><span style="color:darkred">Aucun message pour '.$channel.' au '.$date_dsp.'...</span></td></tr>'.PHP_EOL;
} else {
$msgs = \bot\messages\loadFile($filename,false);
$messages = $msgs['messages'];
$messages = array_reverse($messages);
foreach($messages as $m) {
echo "<tr>".PHP_EOL;
echo "<td class='tabline_date'>".date('H:i:s', $m['timestamp'])."</td>".PHP_EOL;
echo "<td class='tabline_nick'>".\bot\irc2html($m['nick'])."</td>".PHP_EOL;
echo "<td class='tabline_msg'>".\bot\irc2html($m['message'])."</td>".PHP_EOL;
echo "</tr>".PHP_EOL;
}
}