<?php
require "cfg/cfg.php";
require "./common.php";

$cat=$_GET['cat'];
$s=($_GET['s']==''?'0':$_GET['s']);
include "filecomuni/_prehead.html";
include "filecomuni/_posthead.html";
include "filecomuni/_top.html";
?>
<!--- inizio middle --->
<TABLE cellspacing="0" cellpadding="0" border="0" width="800" bgcolor="#ffffff"><TR>
<TD width="10" background="img/bg_sx.jpg"></TD>
<TD width="600" valign="top">
	<FONT class="data"><?=dataodierna()?></FONT><br>
	<br>
<?php
apridb();
if ($cat!="") {
	$where="AND categoria='$cat'";
	$limit="";
} else {
	$where="";
	$limit=" LIMIT $s,5";
}
$res2=eseguiqry("SELECT * FROM blog WHERE visibile $where");
$numrighe2=quanterighe($res2);

$qry="SELECT * FROM blog WHERE visibile $where ORDER BY dataora DESC $limit";
$res=eseguiqry($qry);
$numrighe=quanterighe($res);
chiudidb();
if ($numrighe<=0) {
	echo "<BR><BR><BR>".$_SESSION['lVarieZeromessaggi']."<BR>";
} else {
	while ($arr=leggiriga($res)) {
		if ($arr[$_SESSION['ltitolo']]!="") {
?>
	<TABLE cellpadding="20" cellspacing="0" border="0"><TR><TD>
		<H2><A class="h2" href="<?=$_SERVER['PHP_SELF']?>?id=<?=$arr['id']?>"><?=$arr[$_SESSION['ltitolo']]?></A></H2>
		<?php if ($arr[$_SESSION['lsottotitolo']]) {?><i><?=$arr[$_SESSION['lsottotitolo']]?></i><br><?php }?>
		<?php if ($arr[$_SESSION['llink']]) {?><A class="piccolo" href="<?=$arr[$_SESSION['llink']]?>"><?=$arr[$_SESSION['llink']]?></A><br><?php }?>
		<P align="justify">
		<?php if ($arr['img']) {?><IMG src="img_blog/<?=$arr['id']?>.<?=$arr['img']?>" alt="<?=$arr[$_SESSION['ltitolo']]?>" align="left" class="bordino"><?php }?>
		<br>
		<?=nl2br($arr[$_SESSION['ltesto']])?><br>
		<FONT class="data"><i><?=data_formato($arr['dataora'])?></i></FONT><br>
		</P>
	</TD></TR></TABLE>
	<br>
	<br>
<?php
		}
	}
?>
	<center>
<?php
	if ($s>0) {
?>
	<a href="<?=$_SERVER['PHP_SELF']?>?s=<?=($s-5)?>">&lt;-- pagina precedente</a> &nbsp; &nbsp; &nbsp;
<?php
	}
	if ($s<$numrighe2-5) {
?>
	<a href="<?=$_SERVER['PHP_SELF']?>?s=<?=($s+5)?>">pagina successiva --&gt;</a><br>
<?php
	}
?>
	</center>
	<br><br><br><br><br>
<?php
}
?>
</TD>
<TD width="180" valign="top">
	<?php include "filecomuni/_menu.html";?>
</TD>
<TD width="10" background="img/bg_dx.jpg"></TD>
</TR></TABLE>

<!--- middle end--->

<?php include "filecomuni/_bottom.html"?>