ニジカもんすたぁ!! トップ・ページ https://nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

65 lines
1.5 KiB

  1. <?php
  2. if ($_SERVER['HTTP_HOST'] === 'nizika.monster')
  3. header ('location: //nizika.tv');
  4. const LOG_PATH = './log.txt';
  5. $log_data = [];
  6. $page = (int) ($_GET['p'] ?? 1);
  7. $length = (int) ($_GET['max'] ?? 20);
  8. $asc = ($_GET['asc'] ?? 0) != 0;
  9. $keyword = trim ($_GET['q'] ?? '');
  10. $date_start = $_GET['start'] ?: null;
  11. $date_end = $_GET['end'] ?: null;
  12. $f = fopen (LOG_PATH, 'r');
  13. if ($f !== false)
  14. {
  15. while (($dt = fgetcsv ($f, 0, "\t")) !== false)
  16. {
  17. $chat_info = json_decode ($dt[1]);
  18. $log_data[] = ['date_time' => $dt[0],
  19. 'chat_icon' => $chat_info -> author -> imageUrl,
  20. 'chat_name' => $chat_info -> author -> name,
  21. 'chat_message' => $chat_info -> message,
  22. 'answer' => $dt[2]];
  23. }
  24. }
  25. fclose ($f);
  26. unset ($f);
  27. if ($keyword != '')
  28. {
  29. $log_data = array_filter ($log_data, fn ($row) => (
  30. strpos ($row['chat_name'] . "\n" . $row['chat_message'] . "\n" . $row['answer'],
  31. $keyword)
  32. !== false));
  33. }
  34. if ($date_start)
  35. {
  36. $log_data = array_filter ($log_data, fn ($row) => (
  37. substr ($row['date_time'], 0, 10) >= $date_start));
  38. }
  39. if ($date_end)
  40. {
  41. $log_data = array_filter ($log_data, fn ($row) => (
  42. substr ($row['date_time'], 0, 10) <= $date_end));
  43. }
  44. $pages_max = (int) ((count ($log_data) - 1) / $length) + 1;
  45. if (!($asc))
  46. $log_data = array_reverse ($log_data);
  47. require_once './index.frm.php';