From 0e9d0c52cb9f5dc33d02fb4048fdcc004643c1be Mon Sep 17 00:00:00 2001 From: mdPlusPlus Date: Thu, 29 Dec 2022 23:29:57 +0100 Subject: [PATCH] Add preview links --- get_online_session_communities.php | 34 +++++++++++++++++++++++++----- output/script.js | 0 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 output/script.js diff --git a/get_online_session_communities.php b/get_online_session_communities.php index 957c02b..7279628 100644 --- a/get_online_session_communities.php +++ b/get_online_session_communities.php @@ -66,7 +66,7 @@ //TODO: What about room view links? $table_html = get_table_html($room_assignments); - $final_html = create_html_page_from_table($table_html, "Session Communities"); + $final_html = create_html_page_from_table($table_html, "Self-updating list of active Session Communities"); // write output to disk global $output; @@ -227,6 +227,7 @@ return true; } else { +// echo($url . " is " . $retcode . PHP_EOL); return false; } } @@ -549,13 +550,34 @@ $table_lines = array(); foreach($ordered_table_elements as $id => $content) { + // https://1.2.3.4:56789/token?public_key=0123456789abcdef + $join_link = $content["join_link"]; + + // get preview links + $exploded = explode("/", $join_link); // https: + "" + 1.2.3.4:56789 + token?public_key=0123456789abcdef + $server = $exploded[0] . "//" . $exploded[2]; + $token = explode("?", $exploded[3])[0]; + $preview_link = $server . "/r/" . $token . "/"; + $preview_link_alt = $server . "/view/room/" . $token; + + // test if preview_links are 404 + if(!url_is_reachable($preview_link)) { + if(!url_is_reachable($preview_link_alt)) { + $preview_link = null; // $preview_link and $preview_link_alt not reachable + } + else { + $preview_link = $preview_link_alt; // $preview_link_alt reachable + } + } + $line = " " . PHP_EOL . " " . $id . "" . PHP_EOL . " " . $content["name"] . "" . PHP_EOL . " " . $content["description"] . "" . PHP_EOL . " " . $content["active_users"] . "" . PHP_EOL . - " " . $content["join_link"] . "" . PHP_EOL . + " " . $preview_link . "" . PHP_EOL . + " " . $join_link . "" . PHP_EOL . " " . PHP_EOL; $table_lines[] = $line; } @@ -568,14 +590,15 @@ " Name" . PHP_EOL . " Description" . PHP_EOL . " Users" . PHP_EOL . + " Preview" . PHP_EOL . " Join URL" . PHP_EOL . " " . PHP_EOL; // suffix - // span over 5 columns (id, name, description, users, link) + // span over 5 columns (id, name, description, users, preview, join link) $suffix = " " . PHP_EOL . - " " . count($table_lines) . " unique Session Communities have been found." . PHP_EOL . + " " . count($table_lines) . " unique Session Communities have been found." . PHP_EOL . " " . PHP_EOL . "" . PHP_EOL; @@ -597,7 +620,8 @@ "" . PHP_EOL . "" . PHP_EOL . " " . PHP_EOL . - " " . PHP_EOL . + " " . PHP_EOL . + " " . PHP_EOL . " " . $title . "" . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL; diff --git a/output/script.js b/output/script.js new file mode 100644 index 0000000..e69de29