Просмотр файла include/forums/mekletajs.php

Размер файла: 6.52Kb
<?php

$title = $tlapa.': meklētājs';
$sakt = microtime(1);
		
//////////////////////////////////iegūstam informāciju

if (isset($_GET['ok']))
{
	if (intval($_GET['lapa'])<=0)
	{
		$lapa = 0;
		$nr = 1;
	}
	else
	{
		$lapa = $mapsl*(intval($_GET['lapa'])-1);
		$nr = intval($_GET['lapa']);
	}
	
	$ko = drosiba($_GET['ko']);
	$kur = intval($_GET['kur']);
	$tema = intval($_GET['tema']);
	$kartot = intval($_GET['kartot']);
	
	if ($tema==0)
	{
		$tur = '';
	}
	else
	{
		$tur = "tid='".$tema."' AND";
	}
	
	if ($kartot==1)
	{
		$kaa = 'ASC';
	}
	else
	{
		$kaa = 'DESC';
	}
	
	if (!empty($ko))
	{
		switch ($kur)
		{
			case 1: $sql = "SELECT * FROM foruma_apakstemas WHERE $tur (aid IN (SELECT aid FROM foruma_teksti WHERE $tur teksts LIKE '%".$ko."%') OR teksts LIKE '%".$ko."%') GROUP BY aid ORDER BY ped_rakstits $kaa LIMIT $lapa, $mapsl";
				$sql1 = "SELECT * FROM foruma_apakstemas WHERE $tur (aid IN (SELECT aid FROM foruma_teksti WHERE $tur teksts LIKE '%".$ko."%') OR teksts LIKE '%".$ko."%') GROUP BY aid ORDER BY ped_rakstits $kaa";
				break;
			
			case 2: $sql = "SELECT * FROM foruma_apakstemas WHERE $tur nosaukums LIKE '%".$ko."%' GROUP BY aid ORDER BY ped_rakstits $kaa LIMIT $lapa, $mapsl";
				$sql1 = "SELECT * FROM foruma_apakstemas WHERE $tur nosaukums LIKE '%".$ko."%' GROUP BY aid ORDER BY ped_rakstits $kaa";
				break;
			
			default: $sql = "SELECT * FROM foruma_apakstemas WHERE $tur (aid IN (SELECT aid FROM foruma_teksti WHERE $tur teksts LIKE '%".$ko."%') OR nosaukums LIKE '%".$ko."%' OR teksts LIKE '%".$ko."%') GROUP BY aid ORDER BY ped_rakstits $kaa LIMIT $lapa, $mapsl";
				 $sql1 = "SELECT * FROM foruma_apakstemas WHERE $tur (aid IN (SELECT aid FROM foruma_teksti WHERE $tur teksts LIKE '%".$ko."%') OR nosaukums LIKE '%".$ko."%' OR teksts LIKE '%".$ko."%') GROUP BY aid ORDER BY ped_rakstits $kaa";
		}
		
		$atrasts = mysql_query($sql);
		$cik = mysql_num_rows(mysql_query($sql1));
		$lapu_skaits = ceil($cik/$mapsl);
		
	}
	else
	{
		$kluda = '!!! <b>Tev jāievada kaut kāds vārds, lai varētu meklēt!</b>';
		$temas = mysql_query("SELECT * FROM foruma_temas ORDER BY laiks DESC");
	}
	
}
else
{
	$temas = mysql_query("SELECT * FROM foruma_temas ORDER BY laiks DESC");
}

//////////////////////////////////////////////////////
		
require_once('include/augsa.php');
		
echo '<div class="sani" style="text-align: center">';
echo '<font class="ramis">-Meklētājs-</font>';
echo '</div>';


if (isset($_GET['ok']) && !isset($kluda))
{
	echo '<div class="vidus" style="text-align: left">';
	echo '<small>Atrasta(s): <b>'.$cik.'</b> apakštēma(s)</small>';
	
	while($kas = mysql_fetch_array($atrasts))
	{
		$tk_sk = mysql_fetch_array(mysql_query("SELECT COUNT(tkid) FROM foruma_teksti WHERE aid = '".$kas['aid']."'"));
		$info = infoid($kas['id']);
		
		echo '<hr></hr>';
		
		if ($kas['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", $kas['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='.$kas['aid'].'">'.stripslashes($kas['nosaukums']).'</a> ('.$tk_sk[0].')</small>';
		echo ' <a href="./?kas=atema&amp;sid='.$sid.'&amp;aid='.$kas['aid'].'&amp;lapa=pedeja">&#187;</a>';
		
	}
	
	if ($lapu_skaits>1)
	{
		echo '</div>';
		echo '<div class="vidus" style="text-align: center">';
		echo '<small>';
		
		if ($lapa>0)
		{
			echo '<a href="./?kas=meklet&amp;sid='.$sid.'&amp;ko='.$ko.'&amp;tema='.$tema.'&amp;kur='.$kur.'&amp;kartot='.$kartot.'&amp;lapa='.($nr-1).'&amp;ok">&#171;Atpakaļ</a> ';
		}
			
		echo '<b>'.$nr.'</b>/<b>'.$lapu_skaits.'</b>';
		
		if ($nr<$lapu_skaits)
		{
			echo ' <a href="./?kas=meklet&amp;sid='.$sid.'&amp;ko='.$ko.'&amp;tema='.$tema.'&amp;kur='.$kur.'&amp;kartot='.$kartot.'&amp;lapa='.($nr+1).'&amp;ok">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="meklet"/>';
	        	echo '<input name="sid" type="hidden" value="'.$sid.'"/>';
			echo '<input type="hidden" name="ko" value="'.$ko.'"/>';
			echo '<input type="hidden" name="kur" value="'.$kur.'"/>';
			echo '<input type="hidden" name="tema" value="'.$tema.'"/>';
			echo '<input type="hidden" name="kartot" value="'.$kartot.'"/>';
			echo '<input type="hidden" name="ok" value=""/>';
			echo ' <input type="submit" value="Aiziet"/>';
	        	echo "</form>"; 
	   	}
		
	}
	
}
else
{
	if ($kluda)
	{
		echo '<font class="kluda">'.$kluda.'</font>';
	}
	
	echo '<div class="vidus" style="text-align: center">';
	echo '<form action="./" method="get">';
	echo '<input type="hidden" name="kas" value="meklet"/>';
	echo '<input type="hidden" name="ok" value=""/>';
	echo '<input type="hidden" name="sid" value="'.$sid.'"/>';
	echo 'Ko meklējam?: <br/>';
	echo '<input type="text" name="ko" maxlength="100" size="12"/><br/>';
	echo 'Kur meklējam?: <br/>';
	echo '<select name="kur">';
	echo '<option value="0">Visur</option>';
	echo '<option value="1">Teksti</option>';
	echo '<option value="2">Apakštēmu nos.</option>';
	echo '</select><br/>';
	echo 'Kādā tēmā?: <br/>';
	echo '<select name="tema">';
	echo '<option value="0">Visās</option>';
	
	while ($tema = mysql_fetch_array($temas, MYSQL_ASSOC))
	{
		$nosaukums = ucfirst(stripslashes($tema['nosaukums']));
		
		if (iconv_strlen($nosaukums, 'utf-8')>11)
		{
			$nosaukums = iconv_substr($nosaukums, 0, 11, 'utf-8').'...';
		}
		
		echo '<option value="'.$tema['tid'].'">'.$nosaukums.'</option>';
		
		$i++;
	}
	
	echo '</select><br/>';
	echo 'Kārtot: <br/>';
	echo '<select name="kartot">';
	echo '<option value="0">No jaunākā</option>';
	echo '<option value="1">No vecākā</option>';
	echo '</select><br/><br/>';
	echo '<input type="submit" value="Meklēt"/>';
	echo '</form>';
}

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

if (isset($_GET['ok']) && !isset($kluda))
{
	echo '&#8226; <a href="./?kas=meklet&amp;sid='.$sid.'">Meklētājs</a><br/>';
}

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

?>