<?php
ob_start();
include("config.php");

?>

<html>
<head>
<title>ultimatecrime</title>
<link rel="stylesheet" type="text/css" href="style_general.css">
</head>
<body background="layout/images/layout_12.gif" bgproperties="fixed">
<br>
<br>
<br>

<?php

$begin	=	0+$_GET['p']*30;

	if($data){

?>

<form method="get">
<table width="600" align="center">
	<tr>
		<td colspan="3" align="center" class="subTitle"><strong>Criminelen Browser </strong></td>
	</tr>
	<tr>
		<td class="mainTxt" align="center" width="150"><b>Zoek crimineel</b></td>
		<td class="Maintxt" align="center" width="300"><input type="text" name="x" width="50" maxlength="16"></td>
		<td class="Maintxt" align="center" width="150"><input name="submit" type="submit" value="Zoek die rat..." width="100"></td>
	</tr>
</table>
</form>

<?php

	}

?>

<form action="algemeen-stats-criminelen-login.php" method="get" name="zoeken">
<table width="600" align="center">
	<tr>
		<td colspan="3" align="center" class="subTitle"><strong>Zoek op criteria</strong></td>
	</tr>
	<tr>
		<td class="mainTxt" align="center" width="300"><input type="radio" name="onlinestatus" value="online" class="form_radio" <?php if($_GET['onlinestatus'] == "" || $_GET['onlinestatus'] == "online") echo "checked"; ?>><span class="tekstheader">ONLINE</span></td>
		<td class="Maintxt" align="center" width="300"><input type="radio" name="onlinestatus" value="onlineoffline" class="form_radio" <?php if($_GET['onlinestatus'] == "onlineoffline") echo "checked"; ?>><font color="red"><strong>ONLINE &amp; OFFLINE</strong></font></td>
	</tr>
	<tr>
		<td class="mainTxt" align="center" width="300">
		<select name="rang" class="form_select">
		<option value="" <?php if($_GET['rang'] == "") echo "selected"; ?>>Rang...</option>
		<option value="Junkie" <?php if($_GET['rang'] == "Junkie") echo "selected"; ?>>Junkie</option>
		<option value="Straatrat" <?php if($_GET['rang'] == "Straatrat") echo "selected"; ?>>Straatrat</option>
		<option value="Dief" <?php if($_GET['rang'] == "Dief") echo "selected"; ?>>Dief</option>
		<option value="Wietkweker" <?php if($_GET['rang'] == "Wietkweker") echo "selected"; ?>>Wietkweker</option>
		<option value="Gangster" <?php if($_GET['rang'] == "Gangster") echo "selected"; ?>>Gangster</option>
		<option value="Handelaar" <?php if($_GET['rang'] == "Handelaar") echo "selected"; ?>>Handelaar</option>
		<option value="Arbeider" <?php if($_GET['rang'] == "Arbeider") echo "selected"; ?>>Arbeider</option>
		<option value="Manager" <?php if($_GET['rang'] == "Manager") echo "selected"; ?>>Manager</option>
		<option value="Baas Stadsnetwerk" <?php if($_GET['rang'] == "Baas Stadsnetwerk") echo "selected"; ?>>Baas Stadsnetwerk</option>
		<option value="Huurmoordenaar" <?php if($_GET['rang'] == "Huurmoordenaar") echo "selected"; ?>>Huurmoordenaar</option>
		<option value="Nationaal Crimineel" <?php if($_GET['rang'] == "Nationaal Crimineel") echo "selected"; ?>>Nationaal Crimineel</option>
		<option value="Internationaal Crimineel" <?php if($_GET['rang'] == "Internationaal Crimineel") echo "selected"; ?>>Internationaal Crimineel</option>
		<option value="Lid Grote Raad" <?php if($_GET['rang'] == "Lid Grote Raad") echo "selected"; ?>>Lid Grote Raad</option>
		</select>
		</td>
		<td class="maintxt" align="center" width="300">
		<select name="netwerk" class="form_select">
		<option value="" <?php if($_GET['netwerk'] == "") echo "selected"; ?>>Netwerk...</option>
		<option value="">------------</option>
		<option value="x" <?php if($_GET['netwerk'] == "x") echo "selected"; ?>>ZONDER NETWERK</option>
		<option value="">------------</option>

<?php

$dbres	=	mysql_query("SELECT * FROM `familie`");

	while($familie = mysql_fetch_object($dbres)){
?>

		<option value="<?php echo $familie->naam; ?>" <?php if($_GET['netwerk'] == $familie->naam) echo "selected"; ?>><?php echo $familie->naam; ?></option>

<?php

	}

?>

		</select>
		</td>
	</tr>
	<tr>
		<td class="mainTxt" align="center" width="600" colspan="3"><input type="submit" name="search" value="zoeken"></td>
	</tr>
</table>
<table width="600" align="center">
 	<tr>
		<td class="subTitle" align="center" width=200><b>Crimineel</b></td>
		<td class="subTitle" align="center" width=175><b>Rang</b></td>
		<td class="subTitle" align="center" width=125><b>Netwerk</b></td>
		<td class="subTitle" align="center" width=100><b>Online</b></td>
	</tr>

<?php


	if($_GET['x'] != ""){
	$dbres	=	mysql_query("SELECT `login`,`familie`,`level`,`rank`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` WHERE `login`='{$_GET['x']}' ORDER BY `login` LIMIT $begin,30");
	} else {

		if($_GET['netwerk'] != ""){

			if($_GET['netwerk'] == "x"){
			$familie	=	"";
			} else {
			$familie	=	$_GET['netwerk'];
			}

			if($_GET['rang'] != ""){
				if($_GET['onlinestatus'] != "onlineoffline"){
				$dbres	=	mysql_query("SELECT `login`,`familie`,`rank`,`level`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300) AND `familie`='$familie' AND `rank`='{$_GET['rang']}' ORDER BY `login` LIMIT $begin,30");
				} else {
				$dbres	=	mysql_query("SELECT `login`,`familie`,`rank`,`level`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` WHERE `familie`='$familie' AND `rank`='{$_GET['rang']}' ORDER BY `login` LIMIT $begin,30");
				}
			} else {
				if($_GET['onlinestatus'] != "onlineoffline"){
				$dbres	=	mysql_query("SELECT `login`,`familie`,`rank`,`level`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300) AND `familie`='$familie' ORDER BY `login` LIMIT $begin,30");
				} else {
				$dbres	=	mysql_query("SELECT `login`,`familie`,`rank`,`level`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` WHERE `familie`='$familie' ORDER BY `login` LIMIT $begin,30");
				}
			}
		} else {
			if($_GET['rang'] != ""){
				if($_GET['onlinestatus'] != "onlineoffline"){
				$dbres	=	mysql_query("SELECT `login`,`familie`,`rank`,`level`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300) AND `rank`='{$_GET['rang']}' ORDER BY `login` LIMIT $begin,30");
				} else {
				$dbres	=	mysql_query("SELECT `login`,`familie`,`rank`,`level`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` WHERE `rank`='{$_GET['rang']}' ORDER BY `login` LIMIT $begin,30");
				}
			} else {
				if($_GET['onlinestatus'] != "onlineoffline"){
				$dbres	=	mysql_query("SELECT `login`,`familie`,`rank`,`level`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300) ORDER BY `login` LIMIT $begin,30");
				} else {
				$dbres	=	mysql_query("SELECT `login`,`familie`,`rank`,`level`,UNIX_TIMESTAMP(`online`) AS `online`,0 FROM `gebruiker` ORDER BY `login` LIMIT $begin,30");
				}
			}
		}
	}



	while($user = mysql_fetch_object($dbres)){

		if($user->online + 300 > time()){
		$online		=	"<b><font color=\"#00FF00\">YES</font></b>";
		} else {
		$online		=	"<font color=\"#000000\">NO</font>";
		}

		if($user->familie == ""){
		$netwerk	=	"-";
		} else {
		$netwerk	=	$user->familie;
		}

		if($user->level == 2){
		$login	=	"<b>{$user->login}</b>";
		} else if($user->level == 3){
		$dbresa	=	mysql_query("SELECT * FROM `admin` WHERE `login`='{$user->login}'");
		$admin	=	mysql_fetch_object($dbresa);
			if($admin->level == 3){
			$login	=	"<b><font color=\"#001A00\">{$user->login}</font></b>";
			} else if($admin->level == 2){
			$login	=	"<b><font color=\"#003300\">{$user->login}</font></b>";
			} else if($admin->level == 1){
			$login	=	"<b><font color=\"#4B7C4B\">{$user->login}</font></b>";
			}
		} else {
		$login	=	$user->login;
		}

?>
	<tr onMouseOver="this.style.backgroundColor='#6F5E4A';" onMouseOut="this.style.backgroundColor='#4B3D32';" style="background-color: #4B3D32;">
		<td align="center" width="200" class="justborderS"><?php if($data){ ?><a href="speler-profiel.php?x=<?php echo $user->login; ?>" target="content"><?php } ?><?php echo $login; ?></a></td>
		<td align="center" width="175" class="justborderS"><?php echo $user->rank; ?></td>
		<td align="center" width="125" class="justborderS"><a href="famprofiel.php?x=<?php echo $netwerk; ?>"><?php echo $netwerk; ?></a></td>
		<td align="center" width="100" class="justborderS"><?php echo $online; ?></td>
	</tr>


<?php

	}

	if($_GET['x'] != ""){
	$dbres	=	mysql_query("SELECT `id` FROM `gebruiker` WHERE `login`='{$_GET['x']}' ORDER BY `login`");
	} else {

		if($_GET['netwerk'] != ""){

			if($_GET['netwerk'] == "x"){
			$familie	=	"";
			} else {
			$familie	=	$_GET['netwerk'];
			}

			if($_GET['rang'] != ""){
				if($_GET['onlinestatus'] != "onlineoffline"){
				$dbres	=	mysql_query("SELECT `id` FROM `gebruiker` WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300) AND `familie`='$familie' AND `rank`='{$_GET['rang']}'");
				} else {
				$dbres	=	mysql_query("SELECT `id` FROM `gebruiker` WHERE `familie`='$familie' AND `rank`='{$_GET['rang']}'");
				}
			} else {
				if($_GET['onlinestatus'] != "onlineoffline"){
				$dbres	=	mysql_query("SELECT `id` FROM `gebruiker` WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300) AND `familie`='$familie'");
				} else {
				$dbres	=	mysql_query("SELECT `id` FROM `gebruiker` WHERE `familie`='$familie'");
				}
			}
		} else {
			if($_GET['rang'] != ""){
				if($_GET['onlinestatus'] != "onlineoffline"){
				$dbres	=	mysql_query("SELECT `id` FROM `gebruiker` WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300) AND `rank`='{$_GET['rang']}'");
				} else {
				$dbres	=	mysql_query("SELECT `id` FROM `gebruiker` WHERE `rank`='{$_GET['rang']}'");	
				}
			} else {
				if($_GET['onlinestatus'] != "onlineoffline"){
				$dbres	=	mysql_query("SELECT `id` FROM `gebruiker` WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300)");	
				} else {
				$dbres	=	mysql_query("SELECT `id` FROM `gebruiker`");
				}
			}
		}
	}

	if(mysql_num_rows($dbres) > 30){
	echo "<tr><td class=\"maintxt\" align=\"center\" colspan=\"4\">";

		if($begina/30 == 0){
		echo "<<</font>";
		} else {
		echo "<a href=\"algemeen-stats-criminelen-login.php?onlinestatus={$_GET['onlinestatus']}&x{$_GET['x']}&netwerk={$_GET['netwerk']}&rand={$_GET['rang']}&p=". ($begina/30-1) ."\"><<</a>";
		}

		for($i=0; $i<mysql_num_rows($dbres)/30; $i++){
		echo " <a href=\"algemeen-stats-criminelen-login.php?onlinestatus={$_GET['onlinestatus']}&x{$_GET['x']}&netwerk={$_GET['netwerk']}&rand={$_GET['rang']}&p=$i\">". ($i+1) ."</a> ";
		}

		if($begina+30 >= mysql_num_rows($dbres)) {
		echo ">>";
		} else {
		echo "<a href=\"algemeen-stats-criminelen-login.php?onlinestatus={$_GET['onlinestatus']}&x{$_GET['x']}&netwerk={$_GET['netwerk']}&rand={$_GET['rang']}&p=". ($begina/30+1) ."\">>></a>";
		}

	echo "&nbsp; </td></tr><tr>";
	}

?>

	</tr>
	<tr>
		<td class="subtitle" colspan="4">&nbsp;</td>
	</tr>
</table>
</form>
</body>
</html>
