<? 
require_once "include/mysql_config.php";
require_once('include/database.php');

$domain="e-booking2u.com";


	// search send date
	$sql="select eba_id,eba_responder,eba_user from eb_alert where eba_senddate='".date("Y-m-d")."'";
	$result=mysql_query($sql);	
	while($myrow=MySQL_fetch_array($result,MYSQL_ASSOC))
		$row[]=$myrow;


	for($i=0;$i<count($row);$i++){
		$fp = fsockopen($domain, 80, $errno, $errstr, 30);
		if (!$fp) {
			echo "$errstr ($errno)<br />\n";
		} else {
			$id=$row[$i]["eba_id"];
			$responder=$row[$i]["eba_responder"];
			$user=$row[$i]["eba_user"];
			
			$out = "GET /tcrm/emailBlasterSend.php?id=$id&responder=$responder&user=$user HTTP/1.1\r\n";
			$out .= "Host: $domain\r\n";
			$out .= "Connection: Close\r\n\r\n";
			fwrite($fp, $out);
			while (!feof($fp)) {
				$in=fgets($fp, 128);
			}
			fclose($fp);
		}
		sleep(2);
	}	
	
	// birthday
 	$sql="select eba_id,eba_responder,eba_dob,eba_user from eb_alert where eba_dob > '0'";
	$result=mysql_query($sql);	
	while($myrow=MySQL_fetch_array($result,MYSQL_ASSOC))
		$dobrow[]=$myrow;
		
	for($i=0;$i<count($dobrow);$i++){
		$fp = fsockopen($domain, 80, $errno, $errstr, 30);
		if (!$fp) {
			echo "$errstr ($errno)<br />\n";
		} else {
			$id=$dobrow[$i]["eba_id"];
			$responder=$dobrow[$i]["eba_responder"];
			$user=$dobrow[$i]["eba_user"];
			$dob=$dobrow[$i]["eba_dob"];
			
			$out = "GET /emailBlasterDobSend.php?id=$id&responder=$responder&user=$user&dob=$dob&type=dob HTTP/1.1\r\n";
			$out .= "Host: $domain\r\n";
			$out .= "Connection: Close\r\n\r\n";
			fwrite($fp, $out);
			while (!feof($fp)) {
				$in=fgets($fp, 128);
			}
			fclose($fp);
		}
		sleep(2);
		//alert_birthday($dobrow[$i]["eba_id"],'Birthday Scheduler',$dobrow[$i]["eba_responder"],$dobrow[$i]["eba_dob"],'dob');		
	}	


	// spouse birthday
	$sql="select eba_id,eba_responder,eba_spdob,eba_user from eb_alert where eba_spdob > '0'";
	$result=mysql_query($sql);	
	while($myrow=MySQL_fetch_array($result,MYSQL_ASSOC))
		$spdobrow[]=$myrow;
	
	for($i=0;$i<count($spdobrow);$i++){
		$fp = fsockopen($domain, 80, $errno, $errstr, 30);
		if (!$fp) {
			echo "$errstr ($errno)<br />\n";
		} else {
			$id=$spdobrow[$i]["eba_id"];
			$responder=$spdobrow[$i]["eba_responder"];
			$user=$spdobrow[$i]["eba_user"];
			$dob=$spdobrow[$i]["eba_spdob"];
			
			$out = "GET /emailBlasterDobSend.php?id=$id&responder=$responder&user=$user&dob=$dob&type=spdob HTTP/1.1\r\n";
			$out .= "Host: $domain\r\n";
			$out .= "Connection: Close\r\n\r\n";
			fwrite($fp, $out);
			while (!feof($fp)) {
				$in=fgets($fp, 128);
			}
			fclose($fp);
		}
		sleep(2);
//		alert_birthday($spdobrow[$i]["eba_id"],'Spouse Birthday Scheduler',$spdobrow[$i]["eba_responder"],$spdobrow[$i]["eba_spdob"],'spdob');		
	}	




mysql_close();

?>