From 3d3c350777f96cd4f16b978e92537fa44fbb7dd6 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Thu, 16 May 2024 02:59:55 +0900 Subject: [PATCH] =?UTF-8?q?[BC]=20=E8=87=AA=E5=8B=95=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E5=AE=8C=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- broadcast/index.frm.php | 13 +- broadcast/index.php | 57 +------ broadcast/pagination.cmp.php | 61 +------- broadcast/script.js | 239 +++++++++++++++++++++++++----- broadcast/services/fetch_data.php | 5 +- 5 files changed, 213 insertions(+), 162 deletions(-) diff --git a/broadcast/index.frm.php b/broadcast/index.frm.php index 23d7bd8..369f314 100644 --- a/broadcast/index.frm.php +++ b/broadcast/index.frm.php @@ -48,7 +48,7 @@
- /> +
- /> +
@@ -99,8 +97,7 @@ + id="filter-keyword" />
diff --git a/broadcast/index.php b/broadcast/index.php index 90544aa..325080a 100644 --- a/broadcast/index.php +++ b/broadcast/index.php @@ -7,64 +7,11 @@ const LOG_PATH = './log.txt'; $log_data = []; -exec ("(ps -Af | grep -e '^miteruzo' | grep 'python3 main.py') && (ps -Af | grep -e '^miteruzo' | grep 'obs')", +exec (("(ps -Af | grep -e '^miteruzo' | grep 'python3 main.py')" + . " && (ps -Af | grep -e '^miteruzo' | grep 'obs')"), $output, $exit_code); $available = $exit_code === 0; unset ($output, $exit_code); -$page = (int) ($_GET['p'] ?? 1); -$length = (int) ($_GET['max'] ?? 20); -$asc = ($_GET['asc'] ?? 0) != 0; -$keyword = trim ($_GET['q'] ?? ''); -$escaped = ($_GET['escaped'] ?? 0) != 0; - -$date_start = ($_GET['start'] ?? null) ?: null; -$date_end = ($_GET['end'] ?? null) ?: null; - -$f = fopen (LOG_PATH, 'r'); - -if ($f !== false) - { - while (($dt = fgetcsv ($f, 0, "\t")) !== false) - { - $chat_info = json_decode ($dt[1]); - - $log_data[] = ['date_time' => $dt[0], - 'chat_icon' => $chat_info -> author -> imageUrl, - 'chat_name' => $escaped ? htmlspecialchars ($chat_info -> author -> name) : $chat_info -> author -> name, - 'chat_message' => $escaped ? htmlspecialchars ($chat_info -> message) : $chat_info -> message, - 'answer' => $escaped ? htmlspecialchars ($dt[2]) : $dt[2]]; - } - } - -fclose ($f); - -unset ($f); - -if ($keyword != '') - { - $log_data = array_filter ($log_data, fn ($row) => ( - strpos ($row['chat_name'] . "\n" . $row['chat_message'] . "\n" . $row['answer'], - $keyword) - !== false)); - } - -if ($date_start) - { - $log_data = array_filter ($log_data, fn ($row) => ( - substr ($row['date_time'], 0, 10) >= $date_start)); - } - -if ($date_end) - { - $log_data = array_filter ($log_data, fn ($row) => ( - substr ($row['date_time'], 0, 10) <= $date_end)); - } - -$pages_max = (int) ((count ($log_data) - 1) / $length) + 1; - -if (!($asc)) - $log_data = array_reverse ($log_data); - require_once './index.frm.php'; diff --git a/broadcast/pagination.cmp.php b/broadcast/pagination.cmp.php index 4ee21b2..fb2ce8e 100644 --- a/broadcast/pagination.cmp.php +++ b/broadcast/pagination.cmp.php @@ -1,63 +1,6 @@ -