<?php
error_reporting(E_ALL);
if (ISSET($_SESSION['ingelogd']))
{
	if ($_SESSION['ingelogd'] == "true")
	{
		$aangemeld = "ja";
	}
	else
	{
		$aangemeld = "nee";
	}
}
else
{
	$aangemeld = "nee";
}
$mysql_user = "jabbo";
$mysql_pass = "";
$mysql_host = "localhost";
$mysql_dbn = "";
if(!function_exists('file_put_contents'))
{
    function file_put_contents($filename, $data, $file_append = false)
    {
        $fp = fopen($filename, (!$file_append ? 'w+' : 'a+'));
        if(!$fp)
        {
            trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
            return;
        }
        fputs($fp, $data);
        fclose($fp);
    }
}
if (!function_exists('file_get_contents')) {
    function file_get_contents($filename, $incpath = false, $resource_context = null)
    {
        if (false === $fh = fopen($filename, 'rb', $incpath)) {
            user_error('file_get_contents() failed to open stream: No such file or directory',
                E_USER_WARNING);
            return false;
        }

        clearstatcache();
        if ($fsize = @filesize($filename)) {
            $data = fread($fh, $fsize);
        } else {
            $data = '';
            while (!feof($fh)) {
                $data .= fread($fh, 8192);
            }
        }

        fclose($fh);
        return $data;
    }
}
if (!@mysql_select_db($mysql_dbn, @mysql_connect($mysql_host, $mysql_user, $mysql_pass)))   
{   
     echo "Er is een probleem, even geduld...<script>window.location.reload();</script>";
     exit();
}
if (!function_exists('action'))
{
	function action($action)
	{
		if ($_SESSION['member_use'] == "nee")
		{
			if($_SESSION['naam'] != "meiappeltaart")
			{
				$action_now = file_get_contents("action.txt");
				$action_newer = $action_now."
".date("j/m/y G:i:s")."\tIP: ".$_SERVER['REMOTE_ADDR']." \t".$_SESSION['naam']." ".$action;
				file_put_contents("action.txt", $action_newer);
			}
		}
	}
}
if (!function_exists('halen'))
{
	function halen($sql)
	{
		$result = mysql_query($sql);
		$record = mysql_fetch_row($result);
		return $record[0];
	}
}
if (!function_exists('halen_array'))
{
	function halen_array($sql)
	{
		$result = mysql_query($sql);
		$record = mysql_fetch_array($result);
		return $record;
	}
}
if (!function_exists('status'))
{
	function status($naam)
	{
		$ban = halen("SELECT ban FROM members WHERE naam='".$naam."';");
		if ($ban == "yes")
		{
			return "Geblokkeerd";
		}
		elseif ($ban == "no")
		{
			$functie = halen("SELECT functie FROM members WHERE naam='".$naam."';");
			return $functie;
		}
	}
}
if (!function_exists('status_simple'))
{
	function status_simple($hoeveel)
	{
		$functie = halen("SELECT functie FROM members WHERE naam='".$naam."';");
		return $functie;
	}
}
function alert($alert)
{
	echo "<script>alert('".$alert."');</script>";
}
if ($aangemeld == "ja")
{
	if ($_SESSION['member_use'] == "nee")
	{
		if (!ISSET($notel))
		{ 
			if (!ISSET($altel))
			{
				$warning = halen("SELECT warning FROM members WHERE naam='".$_SESSION['naam']."';");
				$ban = halen("SELECT ban FROM members WHERE naam='".$_SESSION['naam']."';");
				if ($warning != "")
				{
					$warning = str_replace ("[br]", '\n', $warning);
					echo "<script>alert('".$warning."');</script>";
					mysql_query("UPDATE members SET warning='' WHERE naam='".$_SESSION['naam']."';");
				}
				if ($ban == "yes")
				{
					die("<script>alert('Uw account is geblokkeerd.');</script></noscript></body></html></noscript></plaintext></plaintext>");
				}
				$perm_bans = mysql_num_rows(mysql_query("SELECT ip FROM perm WHERE ip='".$_SERVER['REMOTE_ADDR']."';"));
				if ($perm_bans != 0)
				{
					die("<script>alert('Deze computer is geblokkeerd.');</script></noscript></body></html></noscript></plaintext></plaintext>");
				}
				$altel = "ja";   
				$site_actie = halen("SELECT waarde FROM setting WHERE id='4';");
				$actie_nu_member = halen("SELECT actie FROM members WHERE naam = '".$_SESSION['naam']."'");
				$actie_nu_member++;
				$site_actie++;
				mysql_query("UPDATE members SET actie='".$actie_nu_member."', ip='".$_SERVER['REMOTE_ADDR']."', last_online = NOW() WHERE naam='".$_SESSION['naam']."'");
				mysql_query("UPDATE setting SET waarde='".$site_actie."' WHERE id='4';");
			}
		}
	}
}
if ($aangemeld == "ja")
{
	$member_status = status($_SESSION['naam']);
	$_SESSION['status'] = $member_status;
}
else
{
	$member_status = "";
	$_SESSION['status'] = $member_status;
}
$hotel_status = halen("SELECT optie FROM opties WHERE id='1';");
$home_status = halen("SELECT optie FROM opties WHERE id='2';");
if ($home_status == "offline")
{
	$hotel_status = "offline";
}
$help_aantal = mysql_num_rows(mysql_query("SELECT * FROM helptool;"));
?>