<?php
define('_IN_JOHNCMS', 1); require_once("../incfiles/core.php");
require_once("../incfiles/head.php");
require_once("manfunc.php");
$land=functions::check($_GET['land']);

$textl=turn($act,0,$land);
function cupvivod($tur)
{
	global $act;
	global $club_id; global $land;
	$q=mysql_query("select * from fman_matches where turn='$act' and tur=$tur and land='$land' order by kom1 asc;");
	if(mysql_num_rows($q))
	{
		echo"<div class='phdr'><b>".strtr($tur,array(11=>'Final', 121=>'1/2 final, dastlabki o`yinlar', 122=>'1/2 final, javob o`yinlari', 141=>'1/4 final, dastlabki o`yinlar', 142=>'1/4 final, javob o`yinlari', 181=>'1/8 final, dastlabki o`yinlar', 182=>'1/8 final, javob o`yinlari', 1161=>'1/16 final, dastlabki o`yinlar', 1162=>'1/16 final, javob o`yinlari', 12=>'1/2 final', 14=>'1/4 final', 18=>'1/8 final', 1=>'saralash o`yinlari'))."</b></div>";
		while($a=mysql_fetch_array($q))
		{
			match($a,$club_id,0);
		}
	}
}
function groupvivod($tur)
{
	global $act;
	global $club_id; 
	global $land;
	echo"<div class='phdr'><b>$tur tur</b></div>";
	$q=mysql_query("select * from fman_matches where turn='$act' and tur=$tur and land='$land';");
	while($a=mysql_fetch_array($q))
	{
		match($a,$club_id,0);
	}
}
echo"<div class='phdr' align='center'>$textl</div>";
if($act=="sc" || $act=="supercup")
{
	$q=mysql_query("select * from fman_matches where turn='$act' and land='$land' limit 1;");
	$a=mysql_fetch_array($q);
	if(!mysql_num_rows($q))echo"<p>O`yinlar yo`q</p>"; else{match($a,$club_id,0);}
}
if($act=="cup" || ($act=="lc" || $act=="le") && $land=="eu")
{
	cupvivod(11);
	cupvivod(12);
	cupvivod(14); cupvivod(18); cupvivod(121); cupvivod(122); cupvivod(141); cupvivod(142); cupvivod(181); cupvivod(182); cupvivod(1161);
	cupvivod(1162); cupvivod(1);
	if($act=="lc" || $act=="le")echo"<div class='menu'><a href='table.php?act=".$act."&amp;land=a'>A-guruhi</a><br/>
	<a href='table.php?act=".$act."&amp;land=b'>B-guruhi</a><br/>
	<a href='table.php?act=".$act."&amp;land=c'>C-guruhi</a><br/>
	<a href='table.php?act=".$act."&amp;land=d'>D-guruhi</a><br/>
	<a href='table.php?act=".$act."&amp;land=e'>E-guruhi</a><br/>
	<a href='table.php?act=".$act."&amp;land=f'>F-guruhi</a><br/>
	<a href='table.php?act=".$act."&amp;land=g'>G-guruhi</a><br/>
	<a href='table.php?act=".$act."&amp;land=h'>H-guruhi</a><br/>";
	if($act=="le")echo"<a href='table.php?act=le&amp;land=i'>I-guruhi</a><br/>
	<a href='table.php?act=le&amp;land=j'>J-guruhi</a><br/>
	<a href='table.php?act=le&amp;land=k'>K-guruhi</a><br/>
	<a href='table.php?act=le&amp;land=l'>L-guruhi</a>";
	if($act=="lc" || $act=="le")echo"</div>";
}
if(($act=="lc" || $act=="le") && $land!="eu")
{
	$tab="Jadval";
	$qtb=mysql_query("select id1, id2 from fman_matches where turn='$act' and tur=1 and land='$land';");
	$n=1;
	while($atb=mysql_fetch_array($qtb))
	{
		$uch[$n]=$atb[id1];
		$c=$n+1;
		$uch[$c]=$atb[id2];
		$n=$n+2;
	}
	$qtab=mysql_query("select u2, u3, u4 from fman_clubs where id=$uch[1];");
	$atab=mysql_fetch_array($qtab);
	$tour=$atab[u2]+$atab[u3]+$atab[u4];
	if($tour>0)$tab.=". $tour tur";
	echo"<div class='phdr'>$tab</div><table><tr><td></td><td class='bmenu'>Yutuq</td><td class='bmenu'>Durang</td><td class='bmenu'>Mag`lubiyat</td><td class='bmenu'>Gol</td><td class='bmenu'>Ochko</td></tr>";
	$q=mysql_query("select * from fman_clubs where id=$uch[1] or id=$uch[2] or id=$uch[3] or id=$uch[4] order by u7 desc;");
	$i=0;
	while($a=mysql_fetch_array($q))
	{
		$i=$i+1;
		echo"<tr><td class='list2'>$i. ";
		if($a[id]!=$club_id)echo"<a href='club.php?id=$a[id]'>$a[name]</a>"; else echo"<b>$a[name]</b>";
		echo"</td><td class='menu'>$a[u2]</td><td class='menu'>$a[u3]</td><td class='menu'>$a[u4]</td><td class='menu'>$a[u5]-$a[u6]</td><td class='menu'>$a[u7]</td></tr>";
	}
	echo"</table>";
	groupvivod(1);
	groupvivod(2); groupvivod(3); groupvivod(4); groupvivod(5); groupvivod(6);
	if($act=="lc")echo"<div class='phdr'><a href='table.php?act=lc'>Chempionlar ligasi</a></div>"; else
	echo"<div class='phdr'><a href='table.php?act=le'>Yevropa ligasi</a></div>";
}
if($act=="champ")
{
	$tab="Jadval";
	$qtab=mysql_query("select v, n, p from fman_clubs where land='$land' limit 1;");
	$atab=mysql_fetch_array($qtab);
	$tour=$atab[v]+$atab[n]+$atab[p];
	if($tour>0)$tab.=". $tour тур";
	echo"<div class='phdr'>$tab</div>";
	echo'<table class="table" width="100%" border="0" cellspacing="1" cellpadding="4">
	 <tr class="un_table">
	 <td align="center"><b>№</b></td>
	 <td align="center"><b>Klub</b></td>
	 <td align="center"><b>Yutuq</b></td>
	 <td align="center"><b>Durrang</b></td>
	 <td align="center"><b>Mag\'lubiyat</b></td>
	 <td align="center"><b>Gol</b></td>
	 <td align="center"><b>Ochko</b></td>
	 </tr>';
	$q=mysql_query("select * from fman_clubs where land='$land' order by o desc;");
	$i=0;
	while($a=mysql_fetch_array($q))
	{
		$i=$i+1;
		echo 2 ? '<tr class="list1">' : '<tr class="list2">';
		echo"<td align='center'>$i</td><td>";
		if($a[id]!=$club_id)echo"<img src='emblems/$a[id].jpg' style='width:20px; height:20px;'> <a href='club.php?id=$a[id]'>$a[name]</a>"; else echo"<img src='emblems/$a[id].jpg' style='width:20px; height:20px;'> <b>$a[name]</b>";
		echo"</td><td align='center'>$a[v]</td><td align='center'>$a[n]</td><td align='center'>$a[p]</td><td align='center'>$a[zg]-$a[pg]</td><td align='center'>$a[o]</td></tr>";
	}
	echo"</table>";
	$turb=$tour+1;
	$qp=mysql_query("select * from fman_matches where turn='$act' and tur=$tour and land='$land' order by kom1 asc;");
	if(mysql_num_rows($qp))
	{
		echo"<div class='phdr'>So`nggi o`yinlar, $tour tur</div>";
		while($ap=mysql_fetch_array($qp))
		{
			match($ap,$club_id,0);
		}
	}
	$qb=mysql_query("select * from fman_matches where turn='$act' and tur=$turb and land='$land' order by kom1 asc;");
	if(mysql_num_rows($qb))
	{
		echo"<div class='phdr'>Bo`lajak o`yinlar, $turb tur</div>";
		while($aa=mysql_fetch_array($qb))
		{
			match($aa,$club_id,0);
		}
	}
	echo"<div class='phdr'>Taqvim/Natijalar</div><div class='menu'>";
	$kon=39;
	if($land=="ru" || $land=="ua" || $land=="pt")$kon=31;
	if($land=="de" || $land=="nl")$kon=35;
	if($land=="by")$kon=34;
	for($i=1;$i<$kon;$i++)echo"<a href='matches.php?act=$land&amp;tur=$i'>$i tur</a><br/>";
	echo"</div>";
}
echo"<div class='phdr'><a href='index.php'>Futbol menejer</a></div>";
require_once("../incfiles/end.php"); 
?>