diff --git a/.phpenv b/.phpenv index 3c59c08..960b551 100644 --- a/.phpenv +++ b/.phpenv @@ -7,6 +7,8 @@ $TEMPLATES_ROOT="$PROJECT_ROOT/sites"; $LANGUAGES_ROOT="$PROJECT_ROOT/languages"; + include_once "$PROJECT_ROOT/php/utils/logging.php"; + // set timeout for file_get_contents() ini_set('default_socket_timeout', 6); // in seconds, default is 60 @@ -16,6 +18,6 @@ // do not report warnings (timeouts, SSL/TLS errors) error_reporting(E_ALL & ~E_WARNING); - + date_default_timezone_set('UTC'); ?> \ No newline at end of file diff --git a/php/fetch-servers.php b/php/fetch-servers.php index c5c4482..fc16076 100644 --- a/php/fetch-servers.php +++ b/php/fetch-servers.php @@ -80,7 +80,8 @@ // write output to disk global $output; file_put_contents($output, json_encode($info_arrays)); // overwrites existing file - echo("Done. " . count($info_arrays) . " unique Session Communities on " . count_servers($info_arrays) . " servers have been found." . PHP_EOL); + log_info("Done. "); + log_info(Found . count($info_arrays) . " unique Session Communities on " . count_servers($info_arrays) . " servers." . PHP_EOL); } /* @@ -96,13 +97,16 @@ $sd_pre = "https://session.directory/?all=groups" ; // this one has to be expanded first // get awesome session group list html + log_info("Requesting Awesome Session Group list."); $asgl_html = file_get_contents($asgl); // get lokilocker.com html + log_info("Requesting Lokilocker Mods Open Group list."); $ll_html = file_get_contents($ll); // get session.directory html $sd_html = ""; + log_info("Requesting session.directory list."); $sd_pre_html = file_get_contents($sd_pre); $sd_pattern = "/view_session_group_user_lokinet\.php\?id=\d+/"; preg_match_all($sd_pattern, $sd_pre_html, $sd_links); @@ -114,8 +118,10 @@ $sd_html = $sd_html . file_get_contents($link) . PHP_EOL; } + log_info("Done fetching sources."); + // merge all html into a single string - return( + return ( $asgl_html . PHP_EOL . $ll_html . PHP_EOL . $sd_html . PHP_EOL @@ -258,6 +264,7 @@ $endpoint = "/rooms"; $json_url = $server_url . $endpoint; // $json = file_get_contents($json_url); + log_info("Polling $server_url for rooms."); $json = curl_get_contents($json_url); // circumvents flaky routing // echo("URL: " . $server_url . " - JSON URL: " . $json_url . PHP_EOL); // echo("JSON: " . $json . PHP_EOL); @@ -267,6 +274,7 @@ $json_rooms = array(); // if response was not empty if($json_obj) { + log_info("Received response from $server_url."); foreach($json_obj as $json_room) { $token = $json_room->token; // room "name" $users_per_second = $json_room->active_users / $json_room->active_users_cutoff; @@ -307,6 +315,7 @@ if($legacy_rooms) { $result = $legacy_rooms; } else { + log_info("Failed to receive response from $server_url."); $result = null; } } diff --git a/php/generate-html.php b/php/generate-html.php index 7df70db..af80d4f 100644 --- a/php/generate-html.php +++ b/php/generate-html.php @@ -19,8 +19,10 @@ // Do not render auxilliary PHP files. if (str_contains("$phppath", "/+") || $phppath[0] == "+") continue; - + + $docpath = str_replace($TEMPLATES_ROOT, $DOCUMENT_ROOT, $phppath); + $relpath = str_replace($TEMPLATES_ROOT, "", $phppath); $docpath = str_replace(".php", ".html", $docpath); // This works? Yes, yes it does. @@ -28,8 +30,11 @@ // otherwise we could include the documents in an ob_* wrapper. // Same as shell_exec, except we don't have to escape quotes. + log_info("Generating output for $relpath."); $document = `cd "$TEMPLATES_ROOT"; php $phppath`; file_put_contents($docpath, $document); } + + log_info("Done generating HTML."); ?> diff --git a/php/update-listing.php b/php/update-listing.php index 1f86095..9cf40cd 100644 --- a/php/update-listing.php +++ b/php/update-listing.php @@ -1,8 +1,3 @@ -Running, please wait... -This script will usually take approximately 4 minutes to run. -It will take longer if the Chinese servers are spasming out -or if you are running this for the first time. - \ No newline at end of file diff --git a/sites/+components/qr_modals.php b/sites/+components/qr_modals.php index 38d0f44..adf6e2d 100644 --- a/sites/+components/qr_modals.php +++ b/sites/+components/qr_modals.php @@ -21,6 +21,7 @@ return base64_encode(file_get_contents($png_cached)); } // fwrite(STDERR, "QR code NOT found for " . $room_id . PHP_EOL); + log_info("Fetching QR code for $room_id."); $png = file_get_contents(room_invite_png($room_id, $room)); file_put_contents($png_cached, $png); return base64_encode($png);