Sitemonitor in PHP

No frills site monitoring in php. Set up as a cron or hit up by web. Sends an email when a string isn't present on a domain.

<?php

	$sites = array(
		'jalder.com'=>'john alder',
		'google.com'=>'About Google'
	);

	$administrator = 'admin@alertdomain.com';

	foreach($sites as $domain=>$site_content){
		$sm = new Site_Monitor($domain);
		$content = $sm->download_page();
		if($sm->check_content($content, $site_content)){
			//site is up, do nothing
		}
		else{
			//send notice email
			$sm->send_notice($domain, $administrator);
		}
	}



class Site_Monitor{

	private $domain;

	public function __construct($domain){
		$this->domain = $domain;

	}

	public function download_page($page = '/index.php'){
		$url = 'http://'.$this->domain.$page;
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_HEADER, 1);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$content = curl_exec($ch);
		curl_close($ch);
		return $content;
	}

	public function check_content($haystack, $needle){
		if(strpos($haystack, $needle)!==false){
			return true;
		}
		return false;
	}

	public function send_notice($domain, $email){
		$headers = 'From: monitor@sitemonitor.com'."\r\n".
				'Reply-To: noreply@sitemonitor.com'."\r\n".
				'X-Mailer: PHP/'.phpversion();
		$msg = $domain.' may be down, please check!';
		if(mail($email,'Site Monitoring Notice '.$domain,$msg,$headers)){
			return true;
		}
		return false;
	}

}