<?php
// načtení souboru header.php
require_once "includes/header.php";
?>
<?php
// 
// COPYRIGHT BY THE AUTHORS OF WEBWHITELISTER 
// ALL RIGHTS RESERVED.
//

// CONFIG: PLEASE INSERT YOUR MYSQL INFORMATION
	$sql_host = "srv.mojecs.eu";
	$sql_username = "H4X0R";
	$sql_password = "852852";
	$sql_database = "H4X0R";
	$server_name = "mancraft.eu";
	$enable_mc_premium_check = false;
	
// DONT EDIT ANYTHING BELOW HERE; UNLESS YOU KNOW WHAT YOU ARE DOING
	session_start();
	require_once("./script/captcha/simple-php-captcha.php");
	
	if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_SESSION['captcha']['code']) && isset($_POST['captcha'])) {
//Check if captcah is correct
			
		
//Check if username is set
		if($_POST['name'] == "")
			die("Please insert a username!");	
			
//Check if the inserted MC username exists
		if($enable_mc_premium_check and !check_user($_POST['name']))
			die("The inserted username is not a Minecraft premium account.");
			
//Whitelist the player
		mysql_connect($sql_host, $sql_username, $sql_password) or die("ERROR: ".mysql_error());
		mysql_select_db($sql_database) or die("ERROR: ".mysql_error());

		mysql_query("INSERT INTO `WEBWHITELISTER` (`USERNAME`, `WHITELISTED`) VALUES ('" . 			mysql_real_escape_string($_POST['name']) . "', false) ;") or die("ERROR: ".mysql_error());
		die("You have been whitelisted!");
	} else {
		$_SESSION['captcha'] = captcha();
	}
	
	function check_user($mcUser) {
		$check_mcUser = file_get_contents('http://www.minecraft.net/haspaid.jsp?user='.$mcUser.'');
		if ($check_mcUser == "true")
			return true;
		else
			return false;
	}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title> Administrácia  WhiteListu
    </title>
    <meta http-equiv="Content-type" content="text/html; charset=windows-1250" />
    <meta charset="windows-1250">
    <meta http-equiv="Content-Language" content="cs" />
    <link href="main.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <div id="all">
      <!-- header -->
      <div id="header">
      
        <h1>
          <a href="http://mancraft.eu/cpanel/">Administrácia</h1>
        <h2>
          <a href="http://mancraft.eu/cpanel/">Pre minecraft server</a></h2>
      </div>
      <!-- menu -->
      <div id="menu">

      </div>
      <br>
      <br>
      <!--body start -->
      <div id="body">
        <!-- columns start -->
        <div class="columns">
          <!-- second column -->
          <div class="left_column">

          </div>
          <!-- second column -->
          <div class="right_column">
          <?php
if ($login->is_logged==1){
	echo "<center>Prihlásený: <strong>".$login->firstname." ".$login->lastname." &nbsp ".$login->firma."</strong> <a href='?logout=1'>odhlásenie</a></center>&nbsp;";
} else {
	echo "Neprihlásený uživateľ.";
}
?>

          </div>
          <!-- first column -->
          <div class="center_column">
            <div class="text">
              <div>
<?php

if ($login->is_logged==1){
// zde bude kód stránek provedený při přihlášeném uľivateli

?>
<!DOCTYPE html>
<html>
<head>
<LINK href="./css/whitelist.css" rel="stylesheet" type="text/css">
<meta charset="windows-1250">
<title>Whitelist formulár pre <?php echo $server_name; ?></title>
</head>

<div id="stylized" class="myform">
<form id="form" name="form" method="post" action="">
<h1>Pridať do WL na servery <?php echo $server_name; ?></h1>
<p>Ak chcete pridať hráča na WhiteList vyplňte formulár.</br><b><font color='red'>Rozlišujte veľkosť písmen</font></b></p>
<hr />

<label>Nick
<span class="small">Minecraft Nick</span>
</label>
<input type="text" name="name" id="name" />



<button type="submit">Pridať na WhiteList!</button>
<div class="spacer"></div>
</form>
<br />

</div>
</html>
<?php

} else {
// zde bude kód stránek provedený při nepřihlášeném uživateli

?>
 <head>
<LINK href="./css/whitelist.css" rel="stylesheet" type="text/css">
<meta charset="UTF-8">
</head>
<?php
	// zobrazení přihlašovacího formuláře
	$login->show_login_form();
}
?>
</div>
        </div>
        <!-- columns end -->
      </div>
      <!-- body end -->
      <!-- footer -->
      <div id="footer"> &copy; mancraft.eu - Všetky práva vyhradené.
      </div>
    </div>
  </body>
</html>
