<?php
ini_set( "display_errors" , "1" );
error_reporting(E_ALL);
include('db.inc.php');
include('header.inc.php');
include_once('pl_sort.inc.php');
function in_array_letter($s_needle, $a_haystack) {

    while (list($key, $value)=each($a_haystack)) {
        $r_letter = strtolower(substr($value[0], 0, strlen($s_needle)));

        if (is_numeric($r_letter) && $s_needle === "0") {
            return TRUE;
            }

        if (strtolower($r_letter) == strtolower($s_needle)) {
            return TRUE;
            }
        }

return FALSE;
}


?>
<table border="0" cellpadding="10" cellspacing="10" width="100%">
                            <tr>
                                <td width="100%">
                                <p class="vezercikkcim">Sitemap</p>
<?
$mydb = new db();
if (!$_GET['katalias'] && !$_GET['foldrajzalias'])
{
	$stmt="SELECT * FROM kk_kategoria ORDER BY nev";
	$result=$mydb->query($stmt);

	$numrows=mysql_num_rows($result);
	while ($row = mysql_fetch_object($result)) 
	{
		$i++;
		$neve=$row->nev;
		$idje=$row->id;
		$alias=$row->alias;
		echo "<a href='/sitemap/".$alias."'><strong>$neve</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='/szakterulet/".$alias."/mind'>=>keresés</a><br>";
		$stmt1="SELECT * FROM kk_megye ORDER BY nev";
		$result1=$mydb->query($stmt1);
	
		$numrows=mysql_num_rows($result1);
		while ($row1 = mysql_fetch_object($result1)) 
		{
			$mneve=$row1->nev;
			$midje=$row1->id;
			$malias=$row1->alias;
			
			echo "&nbsp;&nbsp;&nbsp;<a href='/sitemap/".$alias."/".$malias."'><strong>$neve, $mneve</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='/szakterulet/".$alias."/".$malias."'>=>keresés</a><br>";		
		}		
	}
}
elseif ($_GET['katalias'] && !$_GET['foldrajzalias'])
{
	$stmt="SELECT * FROM kk_kategoria WHERE alias='".$_GET['katalias']."'";
	$result=$mydb->query($stmt);

	$numrows=mysql_num_rows($result);
	while ($row = mysql_fetch_object($result)) 
	{
		$i++;
		$neve=$row->nev;
		$idje=$row->id;
		$alias=$row->alias;
		echo "<a href='/sitemap/".$alias."'><strong>$neve</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='/szakterulet/".$alias."'>=>keresés</a><br>";
		$stmt1="SELECT * FROM kk_megye ORDER BY nev";
		$result1=$mydb->query($stmt1);
	
		$numrows=mysql_num_rows($result1);
		while ($row1 = mysql_fetch_object($result1)) 
		{
			$mneve=$row1->nev;
			$midje=$row1->id;
			$malias=$row1->alias;
			
			echo "&nbsp;&nbsp;&nbsp;<a href='/sitemap/".$alias."/".$malias."'><strong>$neve, $mneve</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='/szakterulet/".$alias."/".$malias."'>=>keresés</a><br>";		
		}		
	}
}
elseif ($_GET['katalias'] && $_GET['foldrajzalias'])
{
		$stmt1="SELECT * FROM kk_kategoria WHERE alias='".$_GET['katalias']."'";
		$result1=$mydb->query($stmt1);
	
		$numrows=mysql_num_rows($result1);
		while ($row1 = mysql_fetch_object($result1)) 
		{
			$c=$row1->id;
		}
		$stmt1="SELECT * FROM kk_megye WHERE alias='".$_GET['foldrajzalias']."'";
		$result1=$mydb->query($stmt1);
	
		$numrows=mysql_num_rows($result1);
		while ($row1 = mysql_fetch_object($result1)) 
		{
			$filter=$row1->id;
		}
	$stmt="SELECT * FROM kk_kategoria WHERE alias='".$_GET['katalias']."'";
	$result=$mydb->query($stmt);

	$numrows=mysql_num_rows($result);
	while ($row = mysql_fetch_object($result)) 
	{
		$i++;
		$neve=$row->nev;
		$idje=$row->id;
		$alias=$row->alias;
		echo "<a href='/sitemap/".$alias."'><strong>$neve</strong></a><br>";
		$stmt1="SELECT * FROM kk_megye WHERE alias='".$_GET['foldrajzalias']."'";
		$result1=$mydb->query($stmt1);
	
		$numrows=mysql_num_rows($result1);
		while ($row1 = mysql_fetch_object($result1)) 
		{
			$mneve=$row1->nev;
			$midje=$row1->id;
			$malias=$row1->alias;
			if($filter==""){
				$filter="0";
			}
			if($filter2==""){
				$filter2="0";
			}
			if($filter3==""){
				$filter3="0";
			}
			$allfilter="";
			if ($filter)	
			{
				if ($filter==45)	$allfilter=" (megye=45 OR megye2=45 OR megye3=45)";
				elseif ($filter==44)	$allfilter=" (megye=44 OR megye2=44 OR megye3=44)";
				else				$allfilter=" (megye=$filter OR megye2=$filter OR megye3=$filter) ";
			}
			if ($allfilter)	$osszallfilter="($allfilter)";
			echo "&nbsp;&nbsp;&nbsp;<a href='/sitemap/".$alias."/".$malias."'><strong>$neve, $mneve</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='/szakterulet/".$alias."/".$malias."'>=>keresés</a><br>";	
				$stmt2="SELECT kk_tag.url AS url, kk_tag.id AS id, kk_tag.nev AS nev, kk_tag.ext AS extra FROM kk_tag WHERE (kategoria_1=$c OR ((kategoria_2=$c OR kategoria_3=$c OR kategoria_4=$c OR kategoria_5=$c OR kategoria_6=$c OR kategoria_7=$c OR kategoria_8=$c) AND ext=1)) AND jovahagyva=1 AND $osszallfilter ORDER BY kk_tag.nev";
				$result2=$mydb->query($stmt2);
				$rows2=pl_sort($result2);
				if (!$_GET['betu'])	$all_letter = all_letter();
				else				$all_letter[0]=$_GET['betu'];
		        
		        while (list($key, $val)=each($all_letter)) {
		                $b_link = in_array_letter($val, $rows2);
		                if ($b_link) {
		                    echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"http://teszt.konyvel.net/sitemap/".$_GET['katalias']."/".$_GET['foldrajzalias']."/".$val."\">".letter_title($val)."</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='http://teszt.konyvel.net/szakterulet/".$_GET['katalias']."/".$_GET['foldrajzalias']."/".$val.";0'>=>keresés</a><br>";
		                    $abc=$val;
		                    $new_rows=array();
					        if (isset($abc) && $abc!='') {
					            reset($rows2);
					            while (list($keyc, $valc)=each($rows2)) {
					                if (is_numeric($valc[1])) {
					                    $valc[1] = '0';
					                    }
					
					                if ($valc[1] == $abc) {
					                    $new_rows[$keyc] = $valc;
					                    }
					
					            }
						        $rowsx = $new_rows;
								foreach ($rowsx as $keyx => $valuex){
						            if ($valuex[3] == 1) {
						    			printf("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=/szaknevsor/%s><strong>%s</strong></a><br>", $valuex[4], $valuex[0]);
						            } else {
						    			printf("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=c/szaknevsor/%s>%s</a><br>", $valuex[4], $valuex[0]);
						        	}
						    	}
					        }
		                }
		        }
		}		
	}
}

?>
</td>
</tr>
</table>                                
<?

include('footer.inc.php');
?>
