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

$domain="e-booking2u.com";
$i = 60;
while ($i > 0) {
    $i=$i-2;  
	unset($myrow);
	$sql="select ebob_id,ebob_alert,ebob_user,eba_responder from eb_outbox left join eb_alert on ebob_alert=eba_id where ebob_status='Pending' order by ebob_id limit 1";
	$result=mysql_query($sql) or die(mysql_error());	
	$myrow=MySQL_fetch_array($result,MYSQL_ASSOC);
	
	if($myrow["ebob_alert"]){
		$sql="update eb_outbox set ebob_status='Process', ebob_senddate=".CURRENT_TIMESTAMP." where ebob_id='".$myrow["ebob_id"]."'";
		@mysql_query($sql) or die(mysql_error());
	
		$fp = fsockopen($domain, 80, $errno, $errstr, 30);
		if (!$fp) {
			echo "$errstr ($errno)<br />\n";
		} else {
			$id=$myrow["ebob_alert"];
			$responder=$myrow["eba_responder"];
			$user=$myrow["ebob_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);
		}

//		alert_sent($myrow["ebob_alert"],'Now',$myrow["eba_responder"],$myrow["ebob_user"]);	

		sleep(2);
	}
}
mysql_close();
?>