<?php
function status($status_id)
{
	switch($status_id)
	{
		case 0:
			return 'empty';
			break;
		
		case 1:
			return 'active';
			break;
		
		case 2:
			return '<b>disabled</b>';
			break;
	}
}
?>

<div>
<form name="idselect" action="/partners/keys" method="POST">

KEY # or user field search: <?=form_input(array('name'=>'search','size'=>10))?><?=form_submit('filter','filter')?>

</form>

<form name="idselect" action="/partners/keys" method="POST">
<?=form_hidden('empty',1)?>
<input type="submit" value="Show only the empty keys" />
</form>


<form name="idselect" action="/partners/keys" method="POST">
<?=form_hidden('disabled',1)?>
<input type="submit" value="Show only the disabled keys" />
</form>

<form name="idselect" action="/forum/keys" method="POST">

<input type="submit" value="Show all" />
</form>
<form name="idselect" action="/partners/keys" method="POST">
Limit: <?=form_input(array('name'=>'limit','size'=>3,'value'=>$limit))?><?=form_submit('filter','Limit')?>
</form>
<form name="idselect" action="/partners/keys" method="POST">
From: <?=form_input(array('name'=>'from','size'=>6,'value'=>$from))?>
To: <?=form_input(array('name'=>'to','size'=>6,'value'=>$to))?>
<br />
<?=form_submit('filter','Range')?>
</form>
</div>

<?if($sorok):?>
	<br />
	Result(s) <?=$min?> - <?=$max?> of <?=$found?><br />
	INSERT INTO `hardlock`.`forum_user` (`user_id`,`nUserID`,`jelszo`,`login`, `nev`, `email`, `rang`) VALUES <br />
		<?foreach($sorok as $s):?>
			<?if(status($s->hlStat) == "active"){?>
				<?$emails = explode(";",$s->strEMail);?>
				<?foreach($emails as $email){
					if( $email != ""){
						$melresz = explode('@',$email);?>
						(NULL, '<?=$s->nUserID?>', MD5('<?=trim($melresz[0])?>'), '<?=trim($email)?>', '<?=iconv("ISO-8859-1", "UTF-8",$s->strName)?>', '<?=trim($email)?>', 'user' 
						),<br />
				<?}}?>
			<?}?>
		<?endforeach;?>
		
		<?if($email != trim($email)):?>
						UPDATE `hardlock`.`forum_user` SET `login` = '<?=trim($email)?>', `email` = '<?=trim($email)?>', `jelszo` = MD5('<?=trim($melresz[0])?>') WHERE login = '<?=$email?>';
						<br />
					<?endif;?>
		
<?if($pages==-1):?>
<?elseif($page==1):?>
<?=anchor('forum/keys/2','Next >')?>&nbsp;<?=anchor('forum/keys/'.$pages,'Last >>')?>
<?elseif($page!=$pages):?>
<?=anchor('forum/keys/1','<< First')?>
&nbsp;
<?=anchor('forum/keys/'.($page-1),'< Previous')?> - <?=anchor('forum/keys/'.($page+1),'Next >')?>
&nbsp;
<?=anchor('forum/keys/'.$pages,'Last >>')?>
<?else:?>
<?=anchor('forum/keys/1','<< First')?>&nbsp;<?=anchor('forum/keys/'.($page-1),'< Previous')?>
<?endif;?>
<?endif;?>