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

71 lines
1.9 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. exec ("(ps -Af | grep -e '^miteruzo' | grep 'python3 main.py') && (ps -Af | grep -e '^miteruzo' | grep 'obs')",
  7. $output, $exit_code);
  8. $available = $exit_code === 0;
  9. unset ($output, $exit_code);
  10. $page = (int) ($_GET['p'] ?? 1);
  11. $length = (int) ($_GET['max'] ?? 20);
  12. $asc = ($_GET['asc'] ?? 0) != 0;
  13. $keyword = trim ($_GET['q'] ?? '');
  14. $escaped = ($_GET['escaped'] ?? 0) != 0;
  15. $date_start = ($_GET['start'] ?? null) ?: null;
  16. $date_end = ($_GET['end'] ?? null) ?: null;
  17. $f = fopen (LOG_PATH, 'r');
  18. if ($f !== false)
  19. {
  20. while (($dt = fgetcsv ($f, 0, "\t")) !== false)
  21. {
  22. $chat_info = json_decode ($dt[1]);
  23. $log_data[] = ['date_time' => $dt[0],
  24. 'chat_icon' => $chat_info -> author -> imageUrl,
  25. 'chat_name' => $escaped ? htmlspecialchars ($chat_info -> author -> name) : $chat_info -> author -> name,
  26. 'chat_message' => $escaped ? htmlspecialchars ($chat_info -> message) : $chat_info -> message,
  27. 'answer' => $escaped ? htmlspecialchars ($dt[2]) : $dt[2]];
  28. }
  29. }
  30. fclose ($f);
  31. unset ($f);
  32. if ($keyword != '')
  33. {
  34. $log_data = array_filter ($log_data, fn ($row) => (
  35. strpos ($row['chat_name'] . "\n" . $row['chat_message'] . "\n" . $row['answer'],
  36. $keyword)
  37. !== false));
  38. }
  39. if ($date_start)
  40. {
  41. $log_data = array_filter ($log_data, fn ($row) => (
  42. substr ($row['date_time'], 0, 10) >= $date_start));
  43. }
  44. if ($date_end)
  45. {
  46. $log_data = array_filter ($log_data, fn ($row) => (
  47. substr ($row['date_time'], 0, 10) <= $date_end));
  48. }
  49. $pages_max = (int) ((count ($log_data) - 1) / $length) + 1;
  50. if (!($asc))
  51. $log_data = array_reverse ($log_data);
  52. require_once './index.frm.php';