notifs.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. function notifs(&$link) {
  3. $chunksize=20; // questo deve essere settato paro-paro in notifsh.php
  4. $i=0;
  5. $notifs='<div id="notifc">'.N;
  6. $notifs.='<div id="notifs" onscroll="morenotifs();">'.N;
  7. $unreadnotifs=false;
  8. $res=mysqli_query($link,'SELECT * FROM Notifications ORDER BY Microtime DESC')
  9. or muoribene(mysqli_error($link),true);
  10. while ($row=mysqli_fetch_assoc($res)) {
  11. if ($row['Seen']==0) {
  12. $unreadnotifs=true;
  13. $notifclass='notifunseen';
  14. } else {
  15. $notifclass='notifseen';
  16. }
  17. $i++;
  18. if ($i<=$chunksize) {
  19. if ($i==1) $lastmicrotime=$row['Microtime'];
  20. $notifs.='<div id="notif-'.$row['ID'].'" class="'.$notifclass.'" onclick="markread(this)">'.strftime('%d/%m/%y %T',$row['Microtime']).': '.$row['Notification'].'</div>'.N;
  21. }
  22. }
  23. $notifs.='</div>'.N;
  24. $notifs.='<div id="notifa"><a href="notifs.php">Vedi tutte le notifiche</a></div>'.N;
  25. $notifs.='</div>'.N;
  26. if ($unreadnotifs) {
  27. $imgoff='imgs/bell_act_off.svg';
  28. $imgon='imgs/bell_act_on.svg';
  29. } else {
  30. $imgoff='imgs/bell_off.svg';
  31. $imgon='imgs/bell_on.svg';
  32. }
  33. return(array(
  34. 'div'=>$notifs,
  35. 'imgoff'=>$imgoff,
  36. 'imgon'=>$imgon,
  37. 'lastmicrotime'=>$lastmicrotime,
  38. 'chunksize'=>$chunksize));
  39. }
  40. ?>