Location: PHPKode > projects > Pheed - the newsfeeder > pheed-the-newsfeeder/pheed.php3
<?
// Pheed - the newsfeeder v.1.2.1
function pheed($newsid){
GLOBAL $PHP_SELF,$prev,$newsid,$month,$year;
include "pheedini.php3";
$conid=dbconnect ($dbname,$username,$password);
?>
<table width="100%" border="0" cellspacing="1" cellpadding="5"  bgcolor="<?print $color["tablebg"]?>">
<tr>
<td bgcolor="<?print $color["titlesbg"]?>" valign="center">
<div align="center"><a href="<?print $PHP_SELF?>" class="title"><?print $lang["news"]?></div>
</td></tr><tr>
<td bgcolor="<? print $color["newsbg"] ?>">
<?
if (!isset($newsid)){
 if (!isset($prev)){
  if (isset($month)){
  $sql="SELECT id,date,title FROM $dbtable WHERE (MONTH(date)=$month AND YEAR(date)=$year) ORDER BY date DESC";
  }else{
  $sql="SELECT id,date,title FROM $dbtable ORDER BY date DESC LIMIT 10";
  };
 $result=dbquery($conid,$sql);
 while (list($id,$date,$title)=dbfetch($result)){
  $date=substr($date,0,10);
  $dat=explode("-",$date);
  $date="$dat[2]-$dat[1]-$dat[0]";
  ?>
  <b><font size="-1"><? print $date ?></font></b>&nbsp; &nbsp;<? print $title ?>&nbsp;<a href="<? print $PHP_SELF ?>?newsid=<? print $id ?>">-&#187;</a></font></br>
  <?
 };
 print "<p align=center><a href=$PHP_SELF?prev=all>$lang[allnews]</a></p>";
} else{
 ?>
 <div align="center">
 <p><? print $lang["allnews"]?></a></p>

 <a href="http://www.tourbase.ru/zink"><img scr="pheedlogo.gif" width="81" height="31" border="0" alt="powered by Pheed"></a>

 <?
 $result = dbquery($conid, "SELECT DISTINCT(MONTH(date)) as month, year(date) as year FROM $dbtable ORDER BY year DESC, month DESC");
 while (list($month,$year)=dbfetch($result)){
  print "[<a href=\"$PHP_SELF?month=$month&year=$year\">$mtext[$month] $year</a>] ";
 };
 print "</div>";
};
} else {
$result = dbquery($conid, "SELECT date,title,text,image,caption,URL,urlname FROM $dbtable WHERE (id='$newsid')");
list($date,$title,$text,$image,$caption,$URL,$urlname)=dbfetch($result);
$result = dbquery($conid, "UPDATE $dbtable SET view=view+1 WHERE (id='$newsid')");
$date=substr($date,0,16);
$dat1=explode(" ",$date);
$dat=explode("-",$dat1[0]);
$date="$dat[2]-$dat[1]-$dat[0]</b> <b>$dat1[1]";
?>
<p align="right">
<?
$result = dbquery($conid, "SELECT max(id) as maxid FROM $dbtable WHERE (id<'$newsid') LIMIT 1 ");
list($tmp)=dbfetch($result);
if ($tmp!=""){
?>
<a href="<? print $PHP_SELF ?>?newsid=<? print $tmp ?>">&#171;-</a> <?print $lang["previous"]?>&nbsp;
<?
};
$result = dbquery($conid, "SELECT min(id) as minid FROM $dbtable WHERE (id>'$newsid') LIMIT 1 ");
list($tmp)=dbfetch($result);
if ($tmp!=""){
?>
&nbsp; <?print $lang["next"]?>
<a href="<? print $PHP_SELF ?>?newsid=<? print $tmp ?>"> -&#187;</a>
<?
};
?>
</p>
<p><font size="+1"><? print $title ?></font><br>
<font size="2"> <?print $lang["updated"]?> <b> <i> <? print $date ?> </i></b> </font>
</p>
<?print $text;
if ($image!=""){
print "<center><img src=\"$photourl"."$image\" border=\"1\" $image>";
print "<br>$caption</center>";
};
if ($URL!=""){
print "<p align=left>&nbsp;&nbsp;&nbsp;<a href=\"http://$URL\">$urlname</a></p>";
};
?>
<p align="right"><a href="printitem.php3?newsid=<? print $newsid ?>"><?print $lang["print"]?></a>&nbsp-&#187;</p>
<?
$result = dbquery($conid, "SELECT id,date,title FROM $dbtable WHERE id<$newsid ORDER BY date DESC LIMIT 5");
while (list ($newsid,$date,$title)=dbfetch($result)){
$date=substr($date,0,10);
?>
<b><font size="-2"><? print $date ?></font></b>&nbsp; &nbsp;<font size="-1"><? print $title ?>&nbsp;<a href="<? print $PHP_SELF ?>?newsid=<? print $newsid ?>">-&#187;</a></font><br>
<?
};
};
dbfree($result);
?>
</td>
</tr>
</table>
<?
}
pheed ($newsid);
?>
Return current item: Pheed - the newsfeeder