Location: PHPKode > projects > News Manager - RSS aggregator > newsmanager/spotnews.php
<?php
		/*******************************************************************************
	     **  File          :  spotnews.php                                            **
	     **  Author        :  G.Ramkumar                                              **
	     **  Description   :  displaying news in spotlight section 					  **
	  	 **  Date          :  14/07/2005                                              **
	     **  Last Modified :  02/08/2005                                              **
	     **  PHP Version   :  5.0.3                                                   **
	     **                                                                           **
     	*******************************************************************************/
$comdate=date("Y-m-d")." ".date("H:i:s");

$catname="select * from category where category_name='$spotlight_' and type!='D' and language='$lang'";
$catname_res=$pg_sql->query_pass($catname,"4");

if($_REQUEST['cat_id']!=""&& $_REQUEST['subcat_id']==""){
  $catid_="where flag='Y' and  category_id=".$_REQUEST['cat_id'];

//For Displaying themes in Xml Link

  $rsscat_qry="select * from category where category_id=".$_REQUEST['cat_id'];
  $rsscat_qry_result=$pg_sql->query_pass($rsscat_qry,"4");
  $rss_cat_name="theme=".strtolower($rsscat_qry_result[0]['category_name'])."&";

}elseif($_REQUEST['cat_id']!=""&& $_REQUEST['subcat_id']!=""){
  $catid_="where flag='Y' and subcategory_id=".$_REQUEST['subcat_id'];
  $rss_cat_name="subcategory_id=".$_REQUEST['cat_id'];

  $subrsscat_qry="select * from subcategory where subcategory_id=".$_REQUEST['subcat_id'];
  $subrsscat_qry_result=$pg_sql->query_pass($subrsscat_qry,"4");
  $rss_cat_name="theme=".strtolower($subrsscat_qry_result[0]['subcategory_name'])."&";

}else{
   if($catname_res[0]['category_id']!="")
      $catid_="where flag='Y' and category_id=".$catname_res[0]['category_id'];
 }

if($catid_!="")
{
	$spot_qry="select * from newsitem_category $catid_ and pubdate <='$comdate' order by pubdate desc";
	$spot_res=$pg_sql->query_pass($spot_qry,"4");
}

 $spotcnt=count($spot_res);

// for Getting Xml _id
for($s=0;$s<$spotcnt;$s++)
{
  $id_S=$spot_res[$s][newsitem_id];

  $xml_readalso_S="select * from rssurl_newsitem where url_newsitem_id=$id_S and frontend_export='Y' and language='$lang'";
  $xml_readalsonews_S=$pg_sql->query_pass($xml_readalso_S,"4");

  $xml_readalso_new_S="select * from new_newsitem where newsitem_id=$id_S and frontend='Y' and language='$lang'";
  $xml_readalsonew_news_S=$pg_sql->query_pass($xml_readalso_new_S,"4");

  if(count($cnt_xml_S)<$spotlight_item__)
  {
  	if($xml_readalsonews_S[0]['url_newsitem_id']!="")
  	 {
  	  $xml_exist_S=$xml_exist_S;
  	  $xml_id_S .=$xml_readalsonews_S[0]['url_newsitem_id'].",";
      $cnt_xml_S[] =$xml_exist_S;
     }
     if($xml_readalsonew_news_S[0]['newsitem_id']!="")
	 {
	      $xml_exist_S=0;
	      $xml_id_new_S .=$xml_readalsonew_news_S[0]['newsitem_id'].",";
	      $cnt_xml_S[] = $xml_exist_S;
     }

  }
}

if($_REQUEST['offset']=="" || $_REQUEST['offset']==0)
{
?>
<table width="95%" height="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<?
for($i=0;$i<$spotcnt;$i++)
{
	$newsid=$spot_res[$i][newsitem_id];
    $spot_news="select * from rssurl_newsitem where url_newsitem_id=$newsid and frontend_export='Y' and language='$lang'";

    $spotnews_res=$pg_sql->query_pass($spot_news,"4");

    if(count($sp_res_)<$spotlight_item__)
    {
    if($spotnews_res[0]['url_newsitem_id']!="")
    {
        $exist=0;
    	$id=$spotnews_res[0]['url_newsitem_id'];
    	$ch_id=$spotnews_res[0]['rss_channel_id'];
    	$desc=strip_tags(html_entity_decode($spotnews_res[0]['description']));
	//	$desc=html_entity_decode($spotnews_res[0]['description']);
		$rep_desc=$desc;
		$rep_desc=str_replace("é","é",$rep_desc);
		$rep_desc=str_replace("’","’",$rep_desc);
		$rep_desc=str_replace("è","è",$rep_desc);
		$rep_desc=str_replace("Ã","à",$rep_desc);
		$rep_desc=str_replace("àª","ê",$rep_desc);
		$rep_desc=str_replace("‘","‘",$rep_desc);
		$rep_desc=str_replace("à»",û,$rep_desc);


    	$desc=$rep_desc;

        $channel_image=$spotnews_res[0]['image'];
		$dir="login/newsimages/";
		if (is_dir($dir))
		{
		 if ($dh = opendir($dir))
		 {
		   while (($file = readdir($dh)) !== false)
		   {
		 	if(($file != ".") && ($file != ".."))
			{
				$img=explode(".",$file);
				if($img[0]==$ch_id)
				{
				  $path=pathinfo($file);
				  $name=$path['extension'];
				  if($name == "jpg" || $name =="gif" || $name =="bmp" )
					$image_pre='<a href="'.$spotnews_res[0]['url'].'" target="_new"><img src="login/newsimages/'.$file.'" border="0" width="'.$width__.'" height="'.$height__.'"></a>';

				}

			}
	  	  }
		   closedir($dh);
	     }
	  }

		if(strstr($channel_image,"http://"))
		  $channel_image='<a href="'.$spotnews_res[0]['url'].'" target="_new"><img border="0" height="60" width="80" src="'.$channel_image.'"></a>';
		else
		  $channel_image=$image_pre;

		$hour=str_replace(":","h",$spotnews_res[0]['hour']);
		$date=explode("-",$spotnews_res[0]['pubdate']);
		$date=$date[2]."/".$date[1]."/".$date[0];
        $yesterday = strftime ("%e/%m/%Y", strtotime("-1 day"));

        $yday=explode("/",$yesterday);
        /*
        if(substr($yday[1],0,1)==0)
          $yday[1]=str_replace("0","",$yday[1]);
        else
        */
          $yday[1]=$yday[1];

        if(strlen(trim($yday[0]))==1)
			   $yday[0] ="0".trim($yday[0]);

        $yesterday=trim($yday[0])."/".$yday[1]."/".$yday[2];
        $today=date('d/m/Y');

  		if($date==$today)
		  $pubdate=$today_;
		elseif($date == $yesterday)
		  $pubdate=$yesterday_;
		else
		 $pubdate=$date;


		$desc=str_replace("||","'",$desc);

		if(strlen($desc)>$length__){
		   $desc=substr($desc,0,$length__);
		   $ex_intro=strrchr(trim($desc)," ");
		   if($ex_intro!=""){
 		   	  $ex_new_str=explode($ex_intro,$desc);
		   	  $desc=$ex_new_str[0]."...";
		   	}
 		 }else{
		     $desc=$desc;
        }


		$title=str_replace("||","'",$spotnews_res[0]['news_title']);
		$rep_title=$title;
    	$rep_title=str_replace("é","é",$rep_title);
    	$rep_title=str_replace("’","’",$rep_title);
    	$rep_title=str_replace("è","è",$rep_title);
    	$rep_title=str_replace("Ã","à",$rep_title);
    	$rep_title=str_replace("àª","ê",$rep_title);
    	$rep_title=str_replace("‘","‘",$rep_title);
    	$rep_title=str_replace("à»","û",$rep_title);
    	$rep_title=str_replace("…","...",$rep_title);
    	$title=$rep_title;

    	$enclosure_=$spotnews_res[0]['enclosure'];
		  if($enclosure_!="")
			 $en_play='<img src="images/Play1.jpg" border="0" alt="Play" onclick="Audio.URL=\''.$enclosure_.'\'; Audio.controls.play()" align="absmiddle" style="cursor:hand;">';
		  else
			$en_play='';

		if(count($spotnews_res)>0 && $flag==0){
?>
<tr>
  <td colspan="1" class="heading5" height="25"><?=$spotlight_?></td>
  <td align="right" class="heading5" height="25" colspan="1" valign="middle">
     <a href="xml.php?<?=$rss_cat_name?>id=<?=base64_encode(trim($xml_id_S,","))?>&new_id=<?=base64_encode(trim($xml_id_new_S,","))?>" target="_new"><?if($display_style_==1){?><img src="images/rss-2.0.jpg" width="80" height="15" border="0" alt="Link to RSS Feed">
	 <?}else{?> <img src="images/<?=$rss_style_?>"  border="0" align="absmiddle" alt="Link to RSS Feed"><?}?></a>&nbsp;&nbsp;
  </td>
</tr>
<tr><td height="7"></td></tr>
<?$flag=1;
  $break="<br>";
 }?>
<tr>
  <td colspan="2" class="cont1" valign="top">
  	<a href="<?=$spotnews_res[0]['url']?>" class="contblue" target="_new"><?=$title?></a>&nbsp;<?=$en_play?>
  	<object id="Player2" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="0" height="0">
	  <param name="URL" value="<?=$enclosure_?>"/>
	  <param name="autoStart" value="false"/>
	  <param name="Loop" value="True"/>
	</object>
  </td>
</tr>
<tr>
  <td valign="top" colspan="2" class="cont1">
  <?if($display_spotlight__==1 || $display_spotlight__==3){?>
  <a class="contlink_" href="<?=$spotnews_res[0]['url']?>" target="_new"><?=$desc?></a><br><?}if($display_spotlight__==1 || $display_spotlight__==2){?>
	  <font class="contgrey">
	  <? echo $pubdate;
	         if($pubdate!="")
	           echo "&nbsp;&nbsp;".$hour;
	         else
	            echo $hour;
      ?>
      </font>
  <?}?>
  </td>

 <?if($spotnews_res[0]['image']!=""){?>
   <td valign="middle" align="center" width="25%"><?=$channel_image?></td>
  <?}?>
</tr>
<tr><td height="7"></td></tr>
<?
   $sp_res_[]=$exist;
  }//If Ending


// **** FodKem Articles*****


	$Fodnewsid=$spot_res[$i][newsitem_id];
	$Fodspot_news="select * from new_newsitem where newsitem_id=$Fodnewsid and frontend='Y' and language='$lang'";
	$Fodspotnews_res=$pg_sql->query_pass($Fodspot_news,"4");


	if($Fodspotnews_res[0]['newsitem_id']!="")
	{
	    $fodexist=0;
		$id=$Fodspotnews_res[0]['newsitem_id'];

		include("fod_att.php");

		$desc=html_entity_decode(trim(strip_tags($Fodspotnews_res[0]['introtext'])));
		$hour=str_replace(":","h",$Fodspotnews_res[0]['hour']);
		$desc=str_replace("||","'",$desc);
		$rep_desc=$desc;
		$rep_desc=str_replace("é","é",$rep_desc);
		$rep_desc=str_replace("’","’",$rep_desc);
		$rep_desc=str_replace("è","è",$rep_desc);
		$rep_desc=str_replace("Ã","à",$rep_desc);
		$rep_desc=str_replace("àª","ê",$rep_desc);
		$rep_desc=str_replace("‘","‘",$rep_desc);
		$rep_desc=str_replace("à»",û,$rep_desc);
    	$desc=$rep_desc;



    	if(strlen($desc)>$length__){
		   $desc=substr($desc,0,$length__);
		   $ex_intro=strrchr(trim($desc)," ");

		   if($ex_intro!=""){
		   	  $ex_new_str=explode($ex_intro,$desc);
		   	  $desc=$ex_new_str[0]."...";
		   	}

		 }else{
           $desc=$desc;
        }

		$date=explode("-",$Fodspotnews_res[0]['pubdate']);
		$date=$date[2]."/".$date[1]."/".$date[0];
        $yesterday = strftime ("%e/%m/%Y", strtotime("-1 day"));

        $yday=explode("/",$yesterday);
        $yday[1]=$yday[1];

        if(strlen(trim($yday[0]))==1)
		   $yday[0] ="0".trim($yday[0]);

        $yesterday=trim($yday[0])."/".$yday[1]."/".$yday[2];
		$today=date('d/m/Y');

  		if($date==$today)
		  $pubdate=$today_;
		elseif($date == $yesterday)
		  $pubdate=$yesterday_;
		else
		 $pubdate=$date;

		$title=$Fodspotnews_res[0]['title'];
		$rep_title=$title;
		$rep_title=str_replace("é","é",$rep_title);
		$rep_title=str_replace("’","’",$rep_title);
		$rep_title=str_replace("è","è",$rep_title);
		$rep_title=str_replace("Ã","à",$rep_title);
		$rep_title=str_replace("àª","ê",$rep_title);
		$rep_title=str_replace("‘","‘",$rep_title);
		$rep_title=str_replace("à»",û,$rep_title);
    	$title=$rep_title;

if(count($Fodspotnews_res)>0 && $flag==0 && count($spotnews_res)==0 ){
?>
 <tr>
   <td  class="heading5" colspan="1" height="25"><?=$spotlight_?></td>
   <td align="right" class="heading5" height="25"  colspan="1" valign="middle">
       <a href="xml.php?<?=$rss_cat_name?>id=<?=base64_encode(trim($xml_id_S,","))?>&new_id=<?=base64_encode(trim($xml_id_new_S,","))?>" target="_new"><?if($display_style_==1){?><img src="images/rss-2.0.jpg" width="80" height="15" border="0" alt="Link to RSS Feed">
	 <?}else{?> <img src="images/<?=$rss_style_?>"  border="0" align="absmiddle" alt="Link to RSS Feed"><?}?></a>&nbsp;&nbsp;
   </td>
</tr>
<tr><td height="7"></td></tr>
<?$flag=1;
$break="<br>";
}?>
<tr><td width="100%" colspan="2"><table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
  <?if($image==''){
	 $colspan='colspan="2"';
   }else{
     $colspan='colspan="1"';
   }if($image!="" && $image_position__=='left'){?>
     <td align="left" width="10%" <?=$colspan?> valign="Top"><a href="view_fodarticle.php?id=<?=$id?>&lang=<?=$lang?>"><?=$image?></a></td>
  <?} ?>
   <td width="90%" valign="top" <?=$colspan?> class="cont1"><a href="view_fodarticle.php?id=<?=$id?>&lang=<?=$lang?>" class="contblue"><?=$title?></a>
  <?if($display_spotlight__==1 || $display_spotlight__==3){?>
  <br><a class="contlink_" href="view_fodarticle.php?id=<?=$id?>&lang=<?=$lang?>"><?=$desc?></a>
  <?}if($display_spotlight__==1 || $display_spotlight__==2){?>
	<br>  <font class="contgrey">
        <? echo $pubdate;
         if($pubdate!="")
           echo "&nbsp;&nbsp;".$hour;
         else
            echo $hour;
        ?>
          </font>
<?}?>
  </td>
  <?if($image!="" && $image_position__=='right'){?>
     <td align="center" <?=$colspan?> valign="Top"><a href="view_fodarticle.php?id=<?=$id?>&lang=<?=$lang?>"><?=$image?></a></td>
  <?}  unset($image); unset($colspan);?>
 </tr>
 </tr></td></table>
<tr><td height="7"></td></tr>
<?
  $sp_res_[]=$fodexist;

    }
    $comp_id .=$id.",";
  }


}//For Loop closing


?>
</table>
<?}//Offset ending?>
Return current item: News Manager - RSS aggregator