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

9 months ago
7 months ago
7 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. $f = fopen (LOG_PATH, 'r');
  12. if ($f !== false)
  13. {
  14. while (($dt = fgetcsv ($f, 0, "\t")) !== false)
  15. {
  16. $chat_info = json_decode ($dt[1]);
  17. $log_data[] = ['date_time' => $dt[0],
  18. 'chat_icon' => $chat_info -> author -> imageUrl,
  19. 'chat_name' => $escaped ? htmlspecialchars ($chat_info -> author -> name) : $chat_info -> author -> name,
  20. 'chat_message' => $escaped ? htmlspecialchars ($chat_info -> message) : $chat_info -> message,
  21. 'answer' => $escaped ? htmlspecialchars ($dt[2]) : $dt[2]];
  22. }
  23. }
  24. fclose ($f);
  25. unset ($f);
  26. if ($keyword != '')
  27. {
  28. $log_data = array_filter ($log_data, fn ($row) => (
  29. strpos ($row['chat_name'] . "\n" . $row['chat_message'] . "\n" . $row['answer'],
  30. $keyword)
  31. !== false));
  32. }
  33. $pages_max = (int) ((count ($log_data) - 1) / $length) + 1;
  34. if (!($asc))
  35. $log_data = array_reverse ($log_data);
  36. require_once './index.frm.php';