diff --git a/get_online_session_communities.php b/get_online_session_communities.php index 3f8bf1e..1e1d5b8 100644 --- a/get_online_session_communities.php +++ b/get_online_session_communities.php @@ -7,6 +7,9 @@ // set timeout for file_get_contents() ini_set('default_socket_timeout', 3); // 3 seconds, default is 60 + // curl timeout is millisecons + $curl_timeout_ms = 1750; + // do not report warnings (timeouts, SSL/TLS errors) error_reporting(E_ALL & ~E_WARNING); @@ -38,6 +41,8 @@ main(); function main() { + $timestamp = time(); // unix timestamp in seconds + echo("Running, please wait..." . PHP_EOL); echo("This script will take approximately 2 minutes to run." . PHP_EOL); @@ -66,7 +71,8 @@ //TODO: What about room view links? $table_html = get_table_html($room_assignments); - $final_html = create_html_page_from_table($table_html, "Self-updating list of active Session Communities"); + $title = "Self-updating list of active Session Communities"; + $final_html = create_html_page_from_table($table_html, $title, $timestamp); // write output to disk global $output; @@ -216,10 +222,11 @@ * Helper function for reduce_servers */ function url_is_reachable($url) { + global $curl_timeout_ms; $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1500); // 1500ms or 1.5s + curl_setopt($ch, CURLOPT_TIMEOUT_MS, $curl_timeout_ms); curl_exec($ch); $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); @@ -605,15 +612,17 @@ // suffix // span over 6 columns (id, name, description, users, preview, join link) - $span_count = 6; + //$span_count = 6; $suffix = "" . PHP_EOL . "" . PHP_EOL . " " . PHP_EOL . - " " . PHP_EOL . + //" " . 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 have been found." . count($table_lines) . " unique Session Communities have been found.
Last checked X minutes ago.Last checked X minutes ago.Last checked X minutes ago.
" . PHP_EOL; @@ -630,7 +639,7 @@ /* * Build valid HTML5 page from provided table html */ - function create_html_page_from_table($table_html, $title) { + function create_html_page_from_table($table_html, $title, $timestamp) { $pre = "" . PHP_EOL . "" . PHP_EOL . @@ -640,7 +649,7 @@ " " . PHP_EOL . " " . $title . "" . PHP_EOL . " " . PHP_EOL . - " " . PHP_EOL; + " " . PHP_EOL; $post = " " . PHP_EOL . "" . PHP_EOL; diff --git a/output/script.js b/output/script.js index 6ba4d32..6a57551 100644 --- a/output/script.js +++ b/output/script.js @@ -2,6 +2,14 @@ function copyToClipboard(text) { navigator.clipboard.writeText(text); } +function setLastChecked(timestamp) { + now = Math.floor(Date.now() / 1000); // timestamp in seconds + time_passed_in_seconds = now - timestamp; + time_passed_in_minutes = Math.floor(time_passed_in_seconds / 60); // time in minutes, rounded down + td_element = document.getElementById("td_last_checked"); + td_element.innerHTML = "Last checked " + time_passed_in_minutes + " minutes ago."; +} + function sortTable(n) { var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; table = document.getElementById("tbl_communities"); diff --git a/output/styles.css b/output/styles.css index 61afef6..986ef93 100644 --- a/output/styles.css +++ b/output/styles.css @@ -2,14 +2,14 @@ #tbl_communities { width:100%; } -#th_identifier { width:8%; } +#th_identifier { width:9%; } .td_identifier { font-family: monospace; } -#th_name { width:14%; } +#th_name { width:13%; } #th_description { } #th_users { } .td_users { text-align: right; } -#th_preview { width:20%; } -#th_join_url { width:18%; } +#th_preview { width:19%; } +#th_join_url { width:17%; } .td_join_url { font-family: monospace; } .copy_button { }