1
0
Ответвление 0
MastodonStartpage/web/mustard/include/notifs.php
pezcurrel 85876775c4 ...
2020-05-07 07:24:56 +02:00

40 строки
1,2 КиБ
PHP

<?php
function notifs(&$link) {
$chunksize=20; // questo deve essere settato paro-paro in notifsh.php
$i=0;
$notifs='<div id="notifc">'.N;
$notifs.='<div id="notifs" onscroll="morenotifs();">'.N;
$unreadnotifs=false;
$res=mysqli_query($link,'SELECT * FROM Notifications ORDER BY Microtime DESC')
or muoribene(mysqli_error($link),true);
while ($row=mysqli_fetch_assoc($res)) {
if ($row['Seen']==0) {
$unreadnotifs=true;
$notifclass='notifunseen';
} else {
$notifclass='notifseen';
}
$i++;
if ($i<=$chunksize) {
if ($i==1) $lastmicrotime=$row['Microtime'];
$notifs.='<div id="notif-'.$row['ID'].'" class="'.$notifclass.'" onclick="markread(this)">'.strftime('%d/%m/%y %T',$row['Microtime']).': '.$row['Notification'].'</div>'.N;
}
}
$notifs.='</div>'.N;
$notifs.='<div id="notifa"><a href="notifs.php">Vedi tutte le notifiche</a></div>'.N;
$notifs.='</div>'.N;
if ($unreadnotifs) {
$imgoff='imgs/bell_act_off.svg';
$imgon='imgs/bell_act_on.svg';
} else {
$imgoff='imgs/bell_off.svg';
$imgon='imgs/bell_on.svg';
}
return(array(
'div'=>$notifs,
'imgoff'=>$imgoff,
'imgon'=>$imgon,
'lastmicrotime'=>$lastmicrotime,
'chunksize'=>$chunksize));
}
?>