<?
	include("config/connect.php");

	  function SendHTMLMail2($to,$subject,$mailcontent,$from)
	  {
		$array = split("@",$from,2);
		$SERVER_NAME = $array[1];
		$username =$array[0];
		$headers = "From: $username@$SERVER_NAME\nReply-To:$username@$SERVER_NAME\nX-Mailer: PHP\n";
	
		$limite = "_parties_".md5 (uniqid (rand()));
	
		$headers .= "Date: ".date("l j F Y, G:i")."\n";
		$headers .= "MIME-Version: 1.0\n";
		$headers .= "Content-Type: text/html;\n";
		$headers .= " boundary=\"----=$limite\"\n\n";
	
		/*$eol = "\n";
		$headers .= 'From: Jonny <jon@genius.com>'.$eol; 
		$headers .= 'Reply-To: Jonny <jon@genius.com>'.$eol; 
		$headers .= 'Return-Path: Jonny <jon@genius.com>'.$eol;    /* 
		
		/*$mime_boundary=md5(time()); 
		
		# HTML Version 
		$msg .= "--".$mime_boundary.$eol; 
		$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol; 
		$msg .= "Content-Transfer-Encoding: 8bit".$eol; 
		$msg .= $mailcontent.$eol.$eol; 
		*/
		mail($to,$subject,$mailcontent,$headers);
	  }

	function SendCounterMail($updatestat1)
	{	
		$content1='';

		$content1.= "<font style='font-size: 10px;font-family: Arial, Helvetica, sans-serif;color: #333333;'>"."</font><br>"."<br>"."<p align='center' style='font-size: 14px;font-family: Arial, Helvetica, sans-serif;font-weight:bold;'>Counter Information</p>"."<br>".	
	
	"<table border='0' cellpadding='3' cellspacing='0' width='100%' align='center' class='style13'>";
		
		if($updatestat1==1)
		{
			$content1.="<tr style='font-size: 10px;font-family: Arial, Helvetica, sans-serif;color: #333333;'>
			<td>Records file is not running so it is now running by this process.</td>
			</tr>";
		}

		$content1.="<tr style='font-size: 10px;font-family: Arial, Helvetica, sans-serif;color: #333333;'>
		<td>This mail is testing for check file running for update records.</td>
		</tr>
		</table>";

		$subject="Counter Information - SnaBid-German";
		$from="admin@snabid.com";
		$email = "testmailfunction@gmail.com";

		SendHTMLMail2($email,$subject,$content1,$from);
	}
	
	$updatestat = 0;
	
	$qrysel = "select * from auction_pause_management where id='4'";
	$ressel = mysql_query($qrysel);
	$total1 = mysql_num_rows($ressel);
	if($total1==0)
	{
		$qryins1 = "Insert into auction_pause_management (referral_bids) values('1')";
		mysql_query($qryins1);
		$qrysel = "select * from auction_pause_management where id='4'";
		$ressel = mysql_query($qrysel);
	}	
	
	$objsel = mysql_fetch_array($ressel);

	sleep(5);

	$qrysel1 = "select * from auction_pause_management where id='4'";
	$ressel1 = mysql_query($qrysel1);
	$objsel1 = mysql_fetch_array($ressel1);
	
	$oldvalue = $objsel["referral_bids"];
	$newvalue = $objsel1["referral_bids"];

	if($oldvalue==$newvalue)
	{
		$updatestat = 1;
		SendCounterMail($updatestat);
		header("location: update_records.php");
	}	
	if($updatestat==0)
	{
		SendCounterMail($updatestat);
	}
?>
