-
-
Save LeffeBakedBird/4b5d390a78990417deac40b8f2ea34d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$counter = 0; | |
$foundCounter = 0; | |
$notFoundCounter = 0; | |
$okCounter = 0; | |
$unknownCoutner = 0; | |
$urls = array(); | |
$DomDocument = new DOMDocument(); | |
$DomDocument->load('sitemap.xml'); | |
$DomNodeList = $DomDocument->getElementsByTagName('loc'); | |
foreach($DomNodeList as $url) { | |
echo $url->nodeValue; | |
$headers = get_headers($url->nodeValue); | |
$code = $headers[0]; | |
echo $code; | |
echo "<br/>"; | |
$counter++; | |
if ($headers[0] == "HTTP/1.0 302 Found") | |
{ | |
$foundCounter++; | |
} | |
elseif ($headers[0] == "HTTP/1.0 404 Not Found") | |
{ | |
$notFoundCounter++; | |
} | |
elseif ($headers[0] == "HTTP/1.0 200 OK" || $headers[0] == "HTTP/1.1 200 OK") | |
{ | |
$okCounter++; | |
} | |
else | |
{ | |
$unknownCoutner++; | |
} | |
} | |
echo "<hr/>"; | |
echo "Total URLs: ". $counter ."<br/>"; | |
echo "Total 302 Found: ". $foundCounter ."<br/>"; | |
echo "Total 404 Not Found: ". $notFoundCounter ."<br/>"; | |
echo "Total 200 OK: ". $okCounter ."<br/>"; | |
echo "Other statuses: ". $unknownCoutner; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment