From 1272d9bdd13e0a0274560f68ce604fbe81efed5f Mon Sep 17 00:00:00 2001 From: mdPlusPlus Date: Sat, 7 Jan 2023 21:44:59 +0100 Subject: [PATCH] Add server count --- get_online_session_communities.php | 22 ++++++++++++++++++++-- html_generator.php | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/get_online_session_communities.php b/get_online_session_communities.php index 42ae9b7..e463046 100644 --- a/get_online_session_communities.php +++ b/get_online_session_communities.php @@ -82,7 +82,7 @@ $final_html = create_html_page_from_html_data($table_html, $title, $timestamp); // print_r($wild_join_links); - print_r($servers); +// print_r($servers); // print_r($rooms); // print_r($pubkeys); // print_r($addr_assignments); @@ -92,7 +92,7 @@ // write output to disk global $output; file_put_contents($output, $final_html); // overwrites existing file - echo("Done. " . count($info_arrays) . " unique Session Communities have been found." . PHP_EOL); + echo("Done. " . count($info_arrays) . " unique Session Communities on " . count_servers($info_arrays) . " servers have been found." . PHP_EOL); } /* @@ -673,4 +673,22 @@ return $info_arrays; } + /* + * Counts every unique server from given $info_arrays and returns the count + */ + function count_servers($info_arrays) { + $servers = array(); + foreach($info_arrays as $i_arr) { + // https://sogs.example.com:1234/token?public_key=... + $join_link = $i_arr["join_link"]; + $exploded = explode("/", $join_link); // https: + "" + sogs.example.com:1234 + token?public_key=... + $servers[] = $exploded[0] . "//" . $exploded[2]; + } + $servers = array_unique($servers); + sort($servers); +// print_r($servers); + + return count($servers); + } + ?> diff --git a/html_generator.php b/html_generator.php index f2f09a6..85eb036 100644 --- a/html_generator.php +++ b/html_generator.php @@ -80,7 +80,7 @@ "" . PHP_EOL . "" . PHP_EOL . " " . PHP_EOL . - " " . PHP_EOL . + " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL . " " . PHP_EOL .
" . count($table_lines) . " unique Session Communities have been found." . count($table_lines) . " unique Session Communities on " . count_servers($info_arrays) . " servers have been found.
Last checked X minutes ago.