<?php

if(isset($round)) {

	while (list($key, $val) = each($_POST)) {
		if ($key<>"Submit" && $key<>"round" && $key<>"type"){
			if(substr($key, -3)<>"BY_"){ // kivesszuk a rendezesre iranyara utaloakat
				if($val=="on"){
					$val="true";
				}else{
					$val="false";
				}
			}
			$leiro[$key]=$val;
		}
	}

	$cookie=base64_encode(serialize($leiro));
	setcookie($type, "$cookie");
	header("Location:$PHP_SELF?type=$type");

} else {

	include('functions.php');
	$tablaleiro=adatleiro($type);

	$cookie_name=$type;

	if(!isset($$cookie_name)){

		while (list($key, $val) = each($tablaleiro)) {
			if($tablaleiro[$key]["T_VIS"]=="true"){
				$leiro[$key]="true";
			}else{
				$leiro[$key]="false";
			}
			if($tablaleiro[$key]["T_ORD"]=="true"){
				$leiro[$key."_ORD_"]="true";
				$leiro[$key."_BY_"]=$tablaleiro[$key]["T_BY"];
			}
		}

	}else{

		$leiro=unserialize(base64_decode($$cookie_name));


	} // endif kuki


//form

$title="mezok beallitasa - " . $type;

printf("
<FORM METHOD=POST ACTION=\"$PHP_SELF\">");

printf("<TABLE style='font-size: 11px; font-family: Verdana' CELLSPACING='0' STYLE='background: #FFFFFF;'><TR>");
printf("
<TH>Mezőnév</TH>
<TH>Látható</TH>
<TH>Rendezés</TH>
<TH>Iránya</TH>
</TR>
");


while (list($key, $val) = each($leiro)) {
	if(substr($key, -1)<>"_"){ // kivesszuk a rendezesre utaloakat
		if($val=="true"){
			$checked=" CHECKED";
		} else {
			$checked="";
		}
		printf("<TR>");
		printf("<INPUT TYPE=\"hidden\" NAME=\"%s\" VALUE=\"false\">\n", $key, $key);
		printf("<TD>%s</TD><TD ALIGN=CENTER><INPUT TYPE=\"checkbox\" NAME=\"%s\"%s></TD>\n", $tablaleiro[$key]["TITLE"], $key, $checked);
		
		// rendezes
		if($leiro[$key."_ORD_"]=="true"){
			$checked=" CHECKED";
		} else {
			$checked="";
		}
		printf("<TD ALIGN=CENTER><INPUT TYPE=\"checkbox\" NAME=\"%s\"%s></TD>\n", $key."_ORD_", $checked);

		// rendezes iranya
		$checked="checked".$leiro[$key."_BY_"];
		$$checked=" CHECKED";
		printf("<TD ALIGN=CENTER><INPUT TYPE=\"radio\" NAME=\"%s\" VALUE=\"ASC\"%s>Fel&nbsp;	<INPUT TYPE=\"radio\" NAME=\"%s\" VALUE=\"DESC\"%s>Le&nbsp;</TD>\n", $key."_BY_", $checkedASC, $key."_BY_", $checkedDESC);

		printf("</TR>\n\n");
		$$checked=""; // hogy ne legyen terhelt a kovetkezo kor

	}
}

printf("<INPUT TYPE=\"hidden\" NAME=\"round\" VALUE=\"1\"><INPUT TYPE=\"hidden\" NAME=\"type\" VALUE=\"$type\">
<TR><TD>&nbsp;</TD><TD><INPUT TYPE=\"submit\" VALUE=\"Mentés\"></TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>
</TABLE>
</FORM>");


} // end round


?>
