diff --git a/inc/class.php b/inc/class.php index ad02917..2560d19 100644 --- a/inc/class.php +++ b/inc/class.php @@ -84,9 +84,17 @@ class Follow { $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $this->code = ($code) ? $code : 0; - if ($code == 200) { - $this->updatePath($this->step, 'code', $this->code); - return true; + + // handle certain codes specifically + switch ($code) + { + case 200: + $this->updatePath($this->step, 'code', $this->code); + return true; + case 404: + $this->updatePath($this->step, 'code', $this->code); + $this->setError(['type' => 'code', 'message' => 'URL returned a 404 error response.']); + return true; } } else diff --git a/inc/search.php b/inc/search.php index 40c0b7c..2b76de8 100644 --- a/inc/search.php +++ b/inc/search.php @@ -24,6 +24,7 @@ if (isset($_POST['url'])) // end on an error if ($request->error) { + $error = $request->error; break; } @@ -33,7 +34,7 @@ if (isset($_POST['url'])) // update our code $code = ($request->code) ? $request->code : false; - } while ($code != 200); + } while (substr($code, 0, 1) != 2); } else { diff --git a/inc/style.css b/inc/style.css index de18c62..38904c2 100644 --- a/inc/style.css +++ b/inc/style.css @@ -116,6 +116,16 @@ button[type="submit"]:hover { background-color: #f0eded; } +address { + display: flex; + align-self: stretch; + align-items: center; + justify-content: center; + font-style: normal; + padding: 0.5rem 0; + background: #ffdee3; +} + main { align-items: center; align-self: stretch; @@ -252,13 +262,21 @@ td { vertical-align: top; word-wrap: anywhere; } +td:first-child { + text-align: center; +} td:nth-child(2) { line-height: 1.5rem; padding: 0.8rem 1rem; + width: 100%; } td:nth-child(2) a:hover { text-decoration-color: transparent; } +td:nth-child(4) { + text-align: center; + padding-right: 1.5rem; +} td b { border: 1px solid #aaa; border-right-width: 2px; @@ -271,10 +289,17 @@ td b { padding: 0 0.25rem; transition: border-color 150ms ease-in-out, color 150ms ease-in-out; } +td b i { + display: inline-block; + transition: transform 150ms ease-in-out; +} td:nth-child(2) a:hover b { border-color: #1a1a1a; color: #1a1a1a; } +td:nth-child(2) a:hover b i { + transform: rotate(45deg); +} tbody tr:nth-child(odd) td { background-color: #fff; } diff --git a/index.php b/index.php index ff8fe25..6562cde 100644 --- a/index.php +++ b/index.php @@ -19,126 +19,130 @@ include('inc/codes.php');
- +
-
+ ".$error['message']." + "; } +?> +
+path) > 0) { $steps = count($request->path) - 1; - $count = ($steps == 1) ? '1 redirect' : $steps.' redirects'; + $count = ($steps == 1) ? 'once' : $steps.' times'; echo " -
-

Final destination

-

The URL you traced had ".$count." and ended here:

-

- getFinalRedirect()."\" target=\"blank\"> - ".$request->getFinalRedirect()." - -

-

Redirect trace

- - - - - - - - - "; +
StepRequestCode
+ + + + + + + + "; foreach ($request->path as $step) { $item = $step['step']; $url = $step['url']; $code = $step['code']; - $next = ($step['next']) ? '⥂⇄↩︎' : '✓'; + $next = ($step['next']) ? '↩︎' : ((isset($error)) ? 'x' : '✓'); echo " - - - - - - "; + + + + + + "; } echo " - - -
StepRequestCode
".$item."".$url." ↗︎".$code."".$next."
".$item."".$url." ↗︎".$code."".$next."
- User agent: ".$request::USER_AGENT." -
-
"; + + + User agent: ".$request::USER_AGENT." + + + "; } else { echo " -
-

- Trace a URL's redirects -

-

- Enter a URL in the search box above to derive the final resolved URL after all redirects. The script runs recursive curl requests until we get a 200 status code. This is helpful to get around link tracking or original URLs that Pi-hole outright blocks (like email links). -

-

- I used to use wheregoes.com which is a good, reliable service, but decided to roll my own for privacy reasons. Absolutely nothing is logged as all URL searches are via POST and that's not currently included in my nginx logs. -

-

- Technical details -

-

- User agent -

-

- Other curl settings -

-
- "; +
+

+ Trace a URL's redirects +

+

+ Enter a URL in the search box above to derive the final resolved URL after all redirects. The script runs recursive curl requests until we get a 200 status code. This is helpful to get around link tracking or original URLs that Pi-hole outright blocks (like email links). +

+

+ I used to use wheregoes.com which is a good, reliable service, but decided to roll my own for privacy reasons. Absolutely nothing is logged as all URL searches are via POST and that's not currently included in my nginx logs. +

+

+ Technical details +

+

+ User agent +

+

+ Other curl settings +

+
"; } ?> -
+

+ See RFC 9110 for official documentation on each status code. +

+ +
\ No newline at end of file