View file include/forums/apakstemas.php

File size: 3.88Kb
<?php

$title = $tlapa.': foruma apakštēmas';
$sakt = microtime(1);
$id = idsid($sid);
$info1 = infoid($id);
$tid = intval($_GET['tid']);

if ($info1['ap_skaits']>=1)
{
	$apsl = $info1['ap_skaits'];
}

//////////////////////////////////////apstrādājam informāciju

$tema = mysql_fetch_array(mysql_query("SELECT * FROM foruma_temas WHERE tid = '".$tid."'"));

if (!empty($tema['nosaukums']))
{
	if (intval($_GET['lapa'])<=0)
	{
		$lapa = 0;
		$nr = 1;
	}
	else
	{
		$lapa = $apsl*(intval($_GET['lapa'])-1);
		$nr = intval($_GET['lapa']);
	}
	
	$cik_apakstemu = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM foruma_apakstemas WHERE tid = '".$tid."'"));
	$apakstemas = mysql_query("SELECT * FROM foruma_apakstemas WHERE tid = '".$tid."' ORDER BY ped_rakstits DESC, laiks DESC LIMIT $lapa, $apsl");
	$lapu_skaits = ceil($cik_apakstemu[0]/$apsl);
}

/////////////////////////////////////////////////////////////

require_once('include/augsa.php');
		
echo '<div class="sani" style="text-align: center">';

if (!empty($tema['nosaukums']))
{
	echo '<font class="ramis"><small>'.stripslashes($tema['nosaukums']).'</small></font>';
}
else
{
	echo '<font class="ramis">-Tēma neeksistē-</font>';
}

echo '</div>';
echo '<div class="vidus" style="text-align: left">';

if (!empty($tema['nosaukums']))
{
	echo '<small>';
	echo '&#8226; <a href="./?kas=forums&amp;sid='.$sid.'">Forums</a><br/>';
	echo '&#8226; <a href="./?kas=jaunaptema&amp;sid='.$sid.'&amp;tid='.$tid.'">Jauna apakštēma</a>';
	echo '</small>';
	echo '<hr></hr>';
}

if ($cik_apakstemu[0]>0)
{
	while ($apakstema = mysql_fetch_array($apakstemas, MYSQL_ASSOC))
	{
		$tk_sk = mysql_fetch_array(mysql_query("SELECT COUNT(tkid) FROM foruma_teksti WHERE aid = '".$apakstema['aid']."'"));
		$info = infoid($apakstema['id']);
		
		if ($apakstema['statuss']==2)
		{
			echo '<b>#</b> ';
		}
		
		if ($info['ped_aktivitate']<(time()-$oses))
		{
			$stat = '<font class="kluda">(Off)</font>';
		}
		else
		{
			$stat = '<font class="ok">(On)</font>';
		}
		
		echo '<small>'.date("H:i/d-m-y", $apakstema['laiks']).' ';
		echo '<a href="./?kas=profils&amp;sid='.$sid.'&amp;kam='.$info['id'].'">'.$info['niks'].'</a> '.$stat.'<br/>';
		echo '<a href="./?kas=atema&amp;sid='.$sid.'&amp;aid='.$apakstema['aid'].'">'.stripslashes($apakstema['nosaukums']).'</a> ('.$tk_sk[0].')</small>';
		echo ' <a href="./?kas=atema&amp;sid='.$sid.'&amp;aid='.$apakstema['aid'].'&amp;lapa=pedeja">&#187;</a>';
		
		if ($info1['amats']==3)
		{
			echo ' [<a href="./?kas=labotap&amp;sid='.$sid.'&amp;aid='.$apakstema['aid'].'">*</a>]';
		}
		
		echo '<hr></hr>';
	}
	
	if ($lapu_skaits>1)
	{
		echo '</div>';
		echo '<div class="vidus" style="text-align: center">';
		echo '<small>';
		
		if ($lapa>0)
		{
			echo '<a href="./?kas=tema&amp;sid='.$sid.'&amp;tid='.$tid.'&amp;lapa='.($nr-1).'">&#171;Atpakaļ</a> ';
		}
			
		echo '<b>'.$nr.'</b>/<b>'.$lapu_skaits.'</b>';
		
		if ($nr<$lapu_skaits)
		{
			echo ' <a href="./?kas=tema&amp;sid='.$sid.'&amp;tid='.$tid.'&amp;lapa='.($nr+1).'">Tālāk&#187;</a>';
		}
			
		echo '</small>';
			
		if ($lapu_skaits>2)
	    	{
			
			echo '<form action="./" method="get">';
	      		echo 'Lapa <input name="lapa" format="*N" size="3"/>';
	        	echo '<input name="kas" type="hidden" value="tema"/>';
			echo '<input name="tid" type="hidden" value="'.$tid.'"/>';
	        	echo '<input name="sid" type="hidden" value="'.$sid.'"/>';
			echo ' <input type="submit" value="Aiziet"/>';
	        	echo "</form>"; 
	   	}
		
		echo '</div>';
		echo '<div class="vidus" style="text-align: left">';
	}

}
else
{
	echo '<b>Nav apakštēmu!</b>';
	echo '<hr></hr>';
}

echo '<small>';
echo '&#8226; <a href="./?kas=forums&amp;sid='.$sid.'">Forums</a> ';
echo '&#8226; <a href="./?kas=&amp;sid='.$sid.'">Galvenā</a><br/>';
echo '</small>';
echo '</div>';

?>