aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorgi Nikolov <ggeorgi60@gmail.com>2025-01-11 12:32:05 +0200
committerGeorgi Nikolov <ggeorgi60@gmail.com>2025-01-11 12:32:05 +0200
commit892eca73a66294ffadd987c5f6d554f738cff287 (patch)
tree98dc734f4856a6073dc0e445f8533c3491bb4065 /src
parent72957580f69543766886d770bf230c6acc437946 (diff)
downloadnowayforward_human-892eca73a66294ffadd987c5f6d554f738cff287.tar
nowayforward_human-892eca73a66294ffadd987c5f6d554f738cff287.tar.gz
nowayforward_human-892eca73a66294ffadd987c5f6d554f738cff287.zip
Added an initual commit with a submit url page and a script checking if the page exists
Diffstat (limited to 'src')
-rw-r--r--src/archive_page.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/archive_page.php b/src/archive_page.php
new file mode 100644
index 0000000..bd1f872
--- /dev/null
+++ b/src/archive_page.php
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>PHP answer to the request</title>
+</head>
+<body>
+<p>
+<?php
+ 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;
+ }
+
+ $WEBSITE_CATEGORY = 'page_url';
+ $website_url = $_POST[$WEBSITE_CATEGORY];
+ $website_exists = does_website_exist($website_url) ? "true" : "false";
+ echo "Website exists: $website_exists";
+?>
+</p>
+</body>
+</html>