ニジカもんすたぁ!! トップ・ページ 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.

index.php 1.7 KiB

11 months ago
11 months ago
11 months ago
8 months ago
11 months ago
10 months ago
11 months ago
8 months ago
11 months ago
11 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. $escaped = ($_GET['escaped'] ?? 0) != 0;
  11. $date_start = ($_GET['start'] ?? null) ?: null;
  12. $date_end = ($_GET['end'] ?? null) ?: null;
  13. $f = fopen (LOG_PATH, 'r');
  14. if ($f !== false)
  15. {
  16. while (($dt = fgetcsv ($f, 0, "\t")) !== false)
  17. {
  18. $chat_info = json_decode ($dt[1]);
  19. $log_data[] = ['date_time' => $dt[0],
  20. 'chat_icon' => $chat_info -> author -> imageUrl,
  21. 'chat_name' => $escaped ? htmlspecialchars ($chat_info -> author -> name) : $chat_info -> author -> name,
  22. 'chat_message' => $escaped ? htmlspecialchars ($chat_info -> message) : $chat_info -> message,
  23. 'answer' => $escaped ? htmlspecialchars ($dt[2]) : $dt[2]];
  24. }
  25. }
  26. fclose ($f);
  27. unset ($f);
  28. if ($keyword != '')
  29. {
  30. $log_data = array_filter ($log_data, fn ($row) => (
  31. strpos ($row['chat_name'] . "\n" . $row['chat_message'] . "\n" . $row['answer'],
  32. $keyword)
  33. !== false));
  34. }
  35. if ($date_start)
  36. {
  37. $log_data = array_filter ($log_data, fn ($row) => (
  38. substr ($row['date_time'], 0, 10) >= $date_start));
  39. }
  40. if ($date_end)
  41. {
  42. $log_data = array_filter ($log_data, fn ($row) => (
  43. substr ($row['date_time'], 0, 10) <= $date_end));
  44. }
  45. $pages_max = (int) ((count ($log_data) - 1) / $length) + 1;
  46. if (!($asc))
  47. $log_data = array_reverse ($log_data);
  48. require_once './index.frm.php';