<?php
if (!isset($_SESSION))
{
	session_start();
}
require_once ('header.php');
echo "<h1>Statistieken</h1>";
if ($aangemeld == "ja")
{
	$aantal_accounts = mysql_num_rows(mysql_query("SELECT * FROM members;"));
	$aantal_actieve_accounts = mysql_num_rows(mysql_query("SELECT * FROM members WHERE actie!=0;"));
	$aantal_gebande_accounts = mysql_num_rows(mysql_query("SELECT * FROM members WHERE ban='yes';"));
	$aantal_kamers = mysql_num_rows(mysql_query("SELECT * FROM kamers;"));
	$aantal_gesloten_kamers = mysql_num_rows(mysql_query("SELECT * FROM kamers WHERE safe!=1;"));
	$aantal_favorieten = mysql_num_rows(mysql_query("SELECT * FROM favorites;"));
	$aantal_pageviews = halen("SELECT waarde FROM setting WHERE id='4';");
	$aantal_gelezen_berichten = mysql_num_rows(mysql_query("SELECT * FROM berichten WHERE `read`='ja';"));
	$aantal_ongelezen_berichten = mysql_num_rows(mysql_query("SELECT * FROM berichten WHERE `read`='nee';"));
	$aantal_berichten = $aantal_gelezen_berichten + $aantal_ongelezen_berichten;
	$aantal_meubels = mysql_num_rows(mysql_query("SELECT * FROM items;"));
	$aantal_meubels_zeldzaam = mysql_num_rows(mysql_query("SELECT * FROM items WHERE cat=3;"));
	$aantal_teles = halen("SELECT waarde FROM setting WHERE id='1';");
	$aantal_ruils = mysql_num_rows(mysql_query("SELECT * FROM ruilen;"));
	$aantal_ruils_zeldzaam = mysql_num_rows(mysql_query("SELECT * FROM ruilen WHERE cat=3;"));
	$aantal_prijslijst = mysql_num_rows(mysql_query("SELECT * FROM prijslijst;"));
	$aantal_prijslijst_actief = mysql_num_rows(mysql_query("SELECT * FROM prijslijst WHERE actief='ja';"));
	
	
	
	echo "<table class='tabel'>";
	echo "<tr><td>Geregistreerde accounts: </td><td>".$aantal_accounts."</td></tr>";
	echo "<tr><td>Actieve accounts: </td><td>".$aantal_actieve_accounts." (".round(($aantal_actieve_accounts*100)/$aantal_accounts, 1)."%)</td></tr>";
	echo "<tr><td>Gebande accounts: </td><td>".$aantal_gebande_accounts." (".round(($aantal_gebande_accounts*100)/$aantal_accounts, 1)."%)</td></tr>";
	echo "</table>";
	echo "<br>";
	echo "<table class='tabel'>";
	echo "<tr><td>Aantal kamers: </td><td>".$aantal_kamers."</td></tr>";
	echo "<tr><td>Gesloten kamers: </td><td>".$aantal_gesloten_kamers." (".round(($aantal_gesloten_kamers*100)/$aantal_kamers, 1)."%)</td></tr>";
	echo "<tr><td>Favoriete kamers: </td><td>".$aantal_favorieten."</td></tr>";
	echo "</table>";
	echo "<br>";
	echo "<table class='tabel'>";
	echo "<tr><td>Pagina's bekeken: </td><td>".$aantal_pageviews."</td></tr>";
	echo "</table>";
	echo "<br>";
	echo "<table class='tabel'>";
	echo "<tr><td>Berichten verstuurd: </td><td>".$aantal_berichten."</td></tr>";
	echo "<tr><td>Gelezen berichten: </td><td>".$aantal_gelezen_berichten." (".round(($aantal_gelezen_berichten*100)/$aantal_berichten, 1)."%)</td></tr>";
	echo "<tr><td>Ongelezen berichten: </td><td>".$aantal_ongelezen_berichten." (".round(($aantal_ongelezen_berichten*100)/$aantal_berichten, 1)."%)</td></tr>";
	echo "</table>";
	echo "<br>";
	echo "<table class='tabel'>";
	echo "<tr><td>Meubels gekocht: </td><td>".$aantal_meubels."</td></tr>";
	echo "<tr><td>Zeldzame meubels gekocht: </td><td>".$aantal_meubels_zeldzaam." (".round(($aantal_meubels_zeldzaam*100)/$aantal_meubels, 1)."%)</td></tr>";
	echo "<tr><td>Aantal teleports: </td><td>".$aantal_teles."</td></tr>";
	echo "<tr><td>Meubels geruild: </td><td>".$aantal_ruils."</td></tr>";
	echo "<tr><td>Zeldzame meubels geruild: </td><td>".$aantal_ruils_zeldzaam." (".round(($aantal_ruils_zeldzaam*100)/$aantal_ruils, 1)."%)</td></tr>";
	echo "<tr><td>Bestaande meubels: </td><td>".$aantal_prijslijst."</td></tr>";
	echo "<tr><td>Meubels in catalogus: </td><td>".$aantal_prijslijst_actief." (".round(($aantal_prijslijst_actief*100)/$aantal_prijslijst, 1)."%)</td></tr>";
	echo "</table>";
}
else
{
	echo "Oeps! Hiervoor moet je aangemeld zijn!";
}
require_once ('footer.php');
?>