//PTI Feed generation
//Rageesh :: 2011-02-03
include_once('globalFunctions.php');
echo "M=".extension_loaded('pgsql');
exit;
function CreateDbConnectionCMS()//CMS Write
{
$database = pg_connect("host=172.32.1.75 port=5432 dbname=cms user=readonly password=read!@#0nly") or die("DIE");
return $database;
}
###########################
$conn=CreateDbConnectionCMS();
echo "\nRan at: " . date("YmdHis") . "\n";
if($_GET["date"]!="") {
$startdate = $_GET["date"]." 00:00:00";
$enddate = $_GET["date"]." 23:59:59";
}
else {
$startdate = date("Y-m-d H",mktime(date('H')-2, 0, 0, date("m"), date("d"), date("Y"))).":00:00";
$enddate = date('Y-m-d 23:59:59');
}
//content_id,sub_section_id,headline,creation_date,body,keywords,intro [This is the Column Name's]
echo $sql = "SELECT * FROM agencyfeedmoneycontrol WHERE agency='Press Trust Of India' AND (creation_date>'".$startdate."' AND creation_date <='".$enddate."') ORDER BY creation_date DESC";
$rs = pg_query($conn, $sql); // Query exeution
$num = pg_num_rows($rs); // Total number of rows
//echo "
";
if($num > 0){
while($result=@pg_fetch_array($rs) ) // Fetch
{
$categoryid = trim($result['sub_section_id']);
if($categoryid==106){
$classname = 'Sports';
$categoryid = 6;
}else{
$classname = 'Current Affairs';
$categoryid = 2;
}
$title = trim($result['headline']);
$content = str_replace("
"," ",$result['body']);
$content = str_replace("\n"," ",$content);
$content = trim($content);
$source = "PTI";
$url = '';
$url = ($url=='') ? $source : $url;
$timestamp = date('YmdHis',strtotime($result['creation_date']));
$thumbnail = "";
$thumbnail = ($thumbnail=='') ? '' : $thumbnail;
$entity = trim($result['keywords']);
$entity = ($entity=='') ? '' : $entity;
$crawl_time = date("YmdHis");
$id = sha1($title.$source);
$clusterid = 0;
$cityid = 0;
$countryid = 1;
$dbid = 0;
echo $id."---".$dbid."---".$url."---".$crawl_time."---".$source."---".$thumbnail."---".$title."---".$categoryid."---".$content."---".$entity."---".$classname_new."---".$clusterid."---".$cityid."---".$countryid."---".$timestamp;
exit;
//insertintoSolr($id,$dbid,$url,$crawl_time,$source,$thumbnail,$title,$categoryid,$content,$entity,$classname,$clusterid,$cityid,$countryid,$timestamp);
}
}
pg_close($conn);
?>