Cleaning up directory links.

Discussion in 'Directories' started by alph, Sep 13, 2006.

  1. #1
    Looking for a better way to clean up directory links. I know over time sites, change and are discontinued. I want to keep all my links as fresh and working as possible. Anyone have good php code for doing this. The code I am using seems to slow. Below I am looping through my mysql table url entries...

    Thanks.
    
    		$ch = curl_init();
    		curl_setopt($ch, CURLOPT_URL,$URL);
    		curl_setopt($ch, CURLOPT_HEADER, true);
    		curl_setopt($ch, CURLOPT_NOBODY, true);
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    		curl_setopt($ch, CURLOPT_MAXREDIRS, 10); //follow up to 10 redirections - avoids loops
    		$data = curl_exec($ch);
    		curl_close($ch);
    		preg_match_all("/HTTP\/1\.[1|0]\s(\d{3})/",$data,$matches);
    		$code = end($matches[1]);
    		if(!$data) {
    		  echo "($entryid) $URL <span style='color: red;font-weight:bold;'>Domain could not be found</span><br />";
    		} else {
    		  if($code==200) {
    		    echo "($entryid) $URL <span style='color: green;'>Page Found</span><br />";
    		  } elseif($code==404) {
    		    echo "($entryid) $URL <span style='color: red;font-weight:bold;'>Page Not Found</span><br />";
    		  }
    		}
    
    
    PHP:

     
    alph, Sep 13, 2006 IP