<?
//*********************************************************************************
// Original Website By : Niadesain.com Di Jual melalui http://niadesain.com
// Please Call / SMS : 081384745483 (support@niadesain.com)
// Niadesain.com - Jasa Pembuatan Website Paling Murah dan Paling Lengkap
//*********************************************************************************
?>
<?
 $db->insert("click", "", "'$ref', '$clientdate', '$clienttime', '$clientbrowser', '$REMOTE_ADDR', '$clienturl', ''");
?>   	

<style type="text/css">
<!--
.isi {
	font-family:verdana;
	font-size:11px;
	padding-left:4px;
	text-align:left;
	line-height: 16px;
}
.isi1 {
	font-family:verdana;
	font-size:11px;
	padding-left:4px;
	text-align:center;
	line-height: 16px;
}
.bullet{
	font-family:Tahoma;
	font-size:14px;
	padding-left:4px;
	color:#ffffff;
	text-align:justify;
	line-height: 18px;
}
.isi_kecil{
	font-family:Tahoma;
	font-size:11px;
	padding-left:4px;
	color:#FF6600;
}
.judul {
	font-family:Tahoma;
	font-size:12px;
	font-weight:bold;
	color:#265180;
	padding-left:4px;
}
.judul_head {
	font-family:Georgia;
	font-size:12px;
	font-weight:bold;
	background-color: #B7BCC2;
  color:#333333;
  padding-left:4px;
}
.kembali {
	font-family:Tahoma;
	font-size:11px;
	padding-left:4px;
	text-align:center;
}
.style14 {
	font-size: 12px;
	font-weight: bold;
	color: #000000;
}
.style15 {font-size: 11px}
.style16 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style17 {font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif; }
-->
</style>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#E5E5E5" style="border-collapse: collapse">
  <tr bgcolor="#FF0000" > 
    <td height="45" colspan="3" align="center" bgcolor="#FFFFFF" > <span class="style14"><font face="tahoma,verdana,arial,helvetica,sans-serif">BERITA 
      TERBARU</font></span></td>
  </tr>
  <tr> 
    <td width="14" height="3" align="center"><div align="justify"><font color=""><span class="style15"><span class="style16"></span></span></font> 
        </div></td>
    <td width="500" align="center" valign="top"><div align="left" class="style17"><span class="cc01 style19  style15">
      <?
$batas   = 2;
$halaman = $_GET['halaman'];
if(empty($halaman)){
	$posisi  = 0;
	$halaman = 1;
}
else{
	$posisi = ($halaman-1) * $batas;
}

$db->select("id_berita, id_user, judul, isi_berita, gambar, tanggal, counter, published", "berita", "published=1", "id_berita desc LIMIT $posisi,$batas");

if($db->num_rows() > 0) {
	//echo $db->result(0, "maintext");
	while($row = $db->fetch_row()) {
	$adafoto = $row[4];
	    echo "<table>";
	    echo "<tr><td>";
		echo "<div class='isi'><font color='#282D3A'>post: $row[5]</font></div>";
		echo "<div class='isi'><font color='#282D3A'>berita ini telah dibaca: $row[6] kali</font></div>";
		//echo "<div class='author'><em>Oleh: $row[2]</em></div>";
		echo "<br>";
		echo "<div class='isi'><font color='#282D3A'><a href=index2.php?m=detailberita&nid=$row[0]&id=$id>$row[2]</a></font></div>";
		echo "<br>";
		if ($adafoto !=''){
		echo "<a href=index2.php?m=detailberita&nid=$row[0]&id=$id><img class='img' src='images/news/".$row[4]."' width=75 height=75 hspace=10 border=0 align=left></a></div>";
		}
		else
		{
		echo "<a href=index2.php?m=detailberita&nid=$row[0]&id=$id><div class='img'><img src='images/noimage.jpg' width=75 height=75 hspace=10 border=0 align=left></a></div>";
		} 
		// Tampilkan hanya sebagian isi berita 
  	  	$isi_berita = nl2br($row[3]);
    	$isi = substr($isi_berita,0,400); // ambil sebanyak 410 karakter
   		 $isi = substr($isi_berita,0,strrpos($isi," ")); // spasi antar kalimat 
		echo "<div class='isi'><font color='#282D3A'>$isi ...</font><a href=index2.php?m=detailberita&nid=$row[0]&id=$id>Selengkapnya</a></div>";
		echo "</td></tr></table>";
		echo "<div><hr width=100% size=1 color=#282D3A></div>";
			}	
} else {
	echo "<p>&nbsp;</p><p align=center>Belum ada berita</p><p>&nbsp;</p>";
}	
$tampil2 = mysql_query("SELECT * FROM berita");
$jmldata = mysql_num_rows($tampil2);
$jmlhal  = ceil($jmldata/$batas);
echo "<div class=paging>";
echo "</div>";
if($halaman > 1){
	$prev=$halaman-1;
	echo "<span class=prevnext><a href=$_SERVER[PHP_SELF]?m=berita&halaman=$prev&id=$id>Prev</a></span> ";
}
else{ 
	echo "<span class=disabled>Prev</span> ";
}

// Tampilkan link halaman 1,2,3 ...
for($i=1;$i<=$jmlhal;$i++)
if ($i != $halaman){
	echo " <a href=$_SERVER[PHP_SELF]?m=berita&halaman=$i&id=$id>$i</a> ";
}
else{
	echo " <span class=current>$i</span> ";
}

// Link kehalaman berikutnya (Next)
if($halaman < $jmlhal){
	$next=$halaman+1;
	echo "<span class=prevnext><a href=$_SERVER[PHP_SELF]?m=berita&halaman=$next&id=$id>Next</a></span>";
}
else{ 
	echo "<span class=disabled>Next</span>";
}
echo "</div>";
echo "<br>";
echo "<p align=center><div class='isi1'>Total : <b>$jmldata</b> Berita</div></p>";
?>
    </span></div></td>
    <td width="16" align="center">&nbsp;</td>
  </tr>
</table>
