<?php
require_once('../config/config.php');
require_once(CLASS_DIR.'dbClass.php');
$obj = new DBClass();
$obj2 = new DBClass();

$message = "Dear Sir, <br><br>Have a nice day <br><br><b>Coal News on ".date("d-m-Y")."</b>  please click the link to read the full news.<br><br>";

$sql = "SELECT * FROM news WHERE added_date = '".date("Y-m-d")."' order by added_date DESC";
$rs = $obj->executeQry($sql,$link);
$rownum = $obj->getrow();

if($obj->getrow()>0) {
	
	while($row = $obj->fetchrow()) { 
		
		$id = $row['id'];

		$message	.= "<a href='http://www.coalbazaar.com/news.php?id=".$id."'>".$row['title']."</a><br><br>";

	  }	
	  
	  $message	.= "<br><br><b style='font-size:18px;'>हिंदी में समाचार पढ़ने के लिए</b><br><a href='http://www.coalbazaar.com/hindi/news.php' style='font-size:16px;'>यहाँ क्लिक करें</a><br><br>";
	  
	  $message  .=  "<br><br><strong style='font-size:18px;'>Thanks and Regards</strong><br><strong>Shrinetra Infotech</strong><br>62, Sch. No. 114, Part 1<br>Near ICICI Bank ATM,<br>Indore, (M.P) 452010<br><br><strong>Phone &nbsp;&nbsp;:</strong> 0731-2012323<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+91-9993299974-78 (sales)<br><strong>Fax &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </strong> 0731-4032323<br><strong>Email Id:</strong> shrinetrainfotech@gmail.com<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;info@coalbazaar.com<br><strong>Website:</strong><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;www.coalbazaar.com<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;www.coalmandi.com<br>";
			
			
			
			$sql2 = "SELECT * FROM news_subscribr";
			$rs2 = $obj2->executeQry($sql2,$link);
			while($row2 = $obj2->fetchrow()) { 
						
				$to        	= 	$row2['email']; 
//				$to 			= "pradosh.soni@gmail.com";
				$subject	=	"Coal News";
				$headers  = 'MIME-Version: 1.0' . "\r\n";
				$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";				
				$headers .= "From: coalbazaar@coalbazaar.com \r\n";
				$sended=@mail($to, $subject, $message, $headers);				
			}
					
				if($sended!='')
				{
				@header('Location: news.php?msg=send');
				exit;
				}
}
else {
	@header('Location: news.php?msg=fail');
	exit;
}
?>