From e9af7ba259281472e299ae06daee361b44cfdb42 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 18 Jan 2025 20:59:11 +0200 Subject: feat(views): Rework sample_archive into the new format --- controllers/archive_page.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 controllers/archive_page.php (limited to 'controllers') diff --git a/controllers/archive_page.php b/controllers/archive_page.php new file mode 100644 index 0000000..593076f --- /dev/null +++ b/controllers/archive_page.php @@ -0,0 +1,41 @@ +"; +} + +function apply_correct_protocol($url, $protocol) { + if (str_contains($url, $protocol)) { + return $url; + } + + return $protocol . $url; +} + +function does_website_exist($url) { + $result = false; + + // Check if the site exists with https + $https_url = apply_correct_protocol($url, "https://"); + if ($https_url != $url) { + $url_headers = @get_headers($https_url); + $result |= $url_headers && $url_headers[0] != 'HTTP/1.1 404 Not Found'; + } + + // Check if the site exists with http + $http_url = apply_correct_protocol($url, "http://"); + if ($http_url != $url) { + $url_headers = @get_headers($http_url); + $result |= $url_headers && $url_headers[0] != 'HTTP/1.1 404 Not Found'; + } + + // Check if the site exists as is + // Will take effect when the user has entered the https/http protocol with the site + $url_headers = @get_headers($url); + $result |= $url_headers && $url_headers[0] != 'HTTP/1.1 404 Not Found'; + + return $result; +} -- cgit v1.2.3