Skip to content

Instantly share code, notes, and snippets.

@jaymzcd
Created June 22, 2012 15:54
Show Gist options
  • Select an option

  • Save jaymzcd/2973652 to your computer and use it in GitHub Desktop.

Select an option

Save jaymzcd/2973652 to your computer and use it in GitHub Desktop.
Load a url and check headers for rough 'is it ok' use
<?php
$headers = get_headers($_GET['url']);
$resp = explode(' ', $headers[0])[1];
$OK_CODES = array('200', '301', '302', '303', '307');
if(in_array($resp, $OK_CODES)) {
echo "<h1>URL IS OK</h1>";
} else {
echo "<h1>URL IS BAAAAAD</h1>";
}
?>
<form>
<input type="text" name="url" value="<?=$_GET['url'] ?>" />
<input type="submit">
</form>
<?php
echo "<pre>";
var_dump($headers);
echo "</pre>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment