fbpatch = $fb; } function toArray() { return (array) $this; } function catSTDOUT() { return passthru("cat $this->fbpatch"); } function getJson() { return json_decode($this->filecont); } function getUrls() { $this->filecont = file_get_contents($this->fbpatch); preg_match_all('/.*\"url\": \"(.*).*\"/i', $this->filecont, $matches); return $matches[1]; } } function check_http_status($url) { // Source: http://petrenco.com/php.php?txt=20 $user_agent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, false); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $page = curl_exec($ch); $err = curl_error($ch); if (!empty($err)) return $err; $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // HTTP status codes: https://support.google.com/webmasters/answer/40132 // HTTP 200 (Successful) - OK // HTTP 301 (Moved permanently) - OK // HTTP 302 (Moved temporarily) - OK // HTTP 307 (Temporary redirect) - Fail // HTTP 404 (Not found) - Fail return $httpcode; } $okcodes = array(200, 301, 302); //$obj = new gbookmarks('/home//.config/google-chrome/Default/Bookmarks.bak'); $obj = new gbookmarks('/home//.config/google-chrome/Default/Bookmarks'); $urls = $obj->getUrls(); foreach ($urls as $url) { $answer = check_http_status($url); if (!in_array($answer, $okcodes)) { echo 'HTTP status code: ' . $answer . '. URL: ' . $url . "\n"; } } ?>