<?php
session_start();
// načtení souboru header.php
require_once "includes/header.php";
// připojení k databázi MySQL
include "includes/db_init.php";

?>

<?php
// 
// COPYRIGHT BY THE AUTHORS OF WEBWHITELISTER 
// ALL RIGHTS RESERVED.
//

// CONFIG: PLEASE INSERT YOUR MYSQL INFORMATION
	$sql_host = "srv.vavrkok.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
		if($_SESSION['captcha']['code'] != $_POST['captcha'])
			die("<META HTTP-EQUIV='Refresh' CONTENT='3'; URL='http://mancraft.eu/cpanel'> Captcha is not correct!");			
		
//Check if username is set
		if($_POST['name'] == "")
			die("<META HTTP-EQUIV='Refresh' CONTENT='3'; URL='http://mancraft.eu/cpanel'> Please insert a username!");	
			
//Check if the inserted MC username exists
		if($enable_mc_premium_check and !check_user($_POST['name']))
			die("<META HTTP-EQUIV='Refresh' CONTENT='3'; URL='http://mancraft.eu/cpanel'> 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("Uživatel pridaný na whitelist <META HTTP-EQUIV='Refresh' CONTENT='3'; URL='http://mancraft.eu/cpanel'> automaticky budete presmerovaný do Cpanelu");
	} 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;
	}
?>
<HTML>
<HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>mancraft.eu | whitelist panel</TITLE>
<meta charset="windows-1250">
<META NAME="description" CONTENT="whitelist">
<META NAME="keywords" CONTENT="mancraft, whitelist, minecraft, server">
<META NAME="distribution" CONTENT="Global">
<META NAME="copyright" CONTENT="Copyright 2013 - mancraft.eu">
<META NAME="author" CONTENT="h4x0r, ventrilopodpora@gmail.com">
<META NAME="generator" CONTENT="Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)">
<META NAME="robots" CONTENT="ALL">
<META NAME="rating" CONTENT="General">
<link rel="stylesheet" href="style.css" type="text/css" media="screen">
</HEAD>
<BODY BGCOLOR="#000000" marginheight="0" marginwidth="0">
<center>
<table width="95%"bgcolor="#00FF00" border="3" bordercolor="#00FF00" align=center cellpadding="0" cellspacing="0">
<TR><TD align="center" valign="middle" bgcolor="#00FF00" height="100%">
<table width="95%" border="0" align=center cellpadding="0" cellspacing="0">
<TR><TD align="center" valign="middle" bgcolor="#00FF00" height="10" colspan="3">
<TR><TD align="center" valign="bottom" bgcolor="#000000" height="100" colspan="3"><h2>mancraft.eu | whitelist panel</h2>
<TR><TD align="center" valign="middle" bgcolor="#00FF00" height="10" colspan="3">
<TR><TD align="center" height="300" width="20%">
	<table align="center" border="0" bgcolor="#000000" cellpadding="0" cellspacing="0" width="100%" height="100%">

	<TR><TD align="center" valign="middle" height="05" width="100%">&nbsp;
    <?php
if ($login->is_logged==1){
	echo "<center>Prihlásený: <strong>".$login->login_name."  &nbsp <br> ".$login->firma."</strong> <br> <a href='?logout=1'><img src='images/log_off.png'></a></center>&nbsp;";
} else {
	echo "<br> Neprihlásený uživateľ.  <br> <br>";
}
?>

	<TR><TD align="center" valign="middle" bgcolor="#00FF00" height="10" width="100%">
	<TR><TD align="center" valign="middle" height="05" width="100%">&nbsp;
	<TR><TD align="center" valign="middle" height="75" width="100%">          
   <?php
   if ($login->is_logged==1){
   echo "Tvoje ID: ".$login->id_user." <br> Meno: ".$login->firstname." <br> Priezvysko: ".$login->lastname."  " ;
} else {
	echo "<img src='http://files.softicons.com/download/game-icons/minecraft-icons-by-paul-schulerr/png/256x256/Minecraft%20Icon%20Version%20III.png' width='126' height='126'>";
}  
   ?>
	<TR><TD align="center" valign="middle" height="05" width="100%">&nbsp;
        <TR><TD align="center" valign="middle" bgcolor="#00FF00" height="10" width="100%">
	<TR><TD align="center" valign="middle" height="05" width="100%">&nbsp;
	<TR><TD align="center" valign="middle" height="75" width="100%">
          <?php
   if ($login->is_logged==1){
   echo "<strong>Novinky na webe:</strong> <br> 1. Prihlasovanie, odhlasovanie <br> 2. Info o prihlásenom<br> 3. Pridávanie na WL<br> 4. ukazovanie pridaných na WL <br> "   ;
} else {
	echo "Pre prihlásenie musíte byť adminom a musíte tu mať založený účet";
}  
   ?>

  
	<TR><TD align="center" valign="middle" height="05" width="100%">&nbsp;
  	<TR><TD align="center" valign="middle" bgcolor="#00FF00" height="10" width="100%">
	<TR><TD align="center" valign="middle" height="05" width="100%">&nbsp;
	<TR><TD align="center" valign="middle" height="75" width="100%">
          <?php
       $vysledek=mysql_query("select * from WEBWHITELISTER");
  while ($zaznam=MySQL_Fetch_Array($vysledek)) 

   if ($login->is_logged==1){
   
   echo "  ".$zaznam["USERNAME"]." ";
   echo " - pridané <br>";
} else {
	echo "";
}  
   ?>
  	<TR><TD align="center" valign="middle" height="05" width="100%">&nbsp;
	</table>
    <TD align="center" valign="top" bgcolor="#00FF00" height="300" width="5%">
    <TD align="center" valign="top" bgcolor="#ebf4fb" height="300" width="75%">


<!-- Your Text Goes Below This Line!! -->


<?php

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

?>
		<br>
		<br>
<!DOCTYPE html>
<html>
<head>
 <center>
<!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>
<body>

<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" />

<label>AntiSpam
<span class="small"></span>
</label>
<img src="<?php echo $_SESSION['captcha']['image_src']; ?>" alt="CAPTCHA" />

<label>Ľudské overenie
<span class="small">Kód z AntiSpam</span>
</label>
<input type="text" name="captcha" id="captcha" />

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

</div>
  </center>
  </body>
</html>
<?php

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

?>
 <LINK href="./css/whitelist.css" rel="stylesheet" type="text/css">
<?php
	// zobrazení přihlašovacího formuláře
	$login->show_login_form();
}
?>


<!-- Your Text Goes Above This Line!! -->



	
<TR><TD align="center" valign="middle" bgcolor="#00FF00" height="10" colspan="3">
<TR><TD align="center" valign="middle" bgcolor="#000000" height="15" colspan="3">
<!-- This is the copyright.  It must be showing on the free template.  It can be removed for a small fee.  Visit my site for more information. -->
&copy; mancraft.eu - Všetky práva <a href="http://mancraft.eu/cpanel1.0/login.html">vyhradené</a>.
<TR><TD align="center" valign="middle" bgcolor="#00FF00" height="10" colspan="3">
</table></table>

<div style="font-size: 0.8em; text-align: center; margin-top: 1.0em; margin-bottom: 1.0em;">
Vyrobené pre server <a href="http://www.mancraft.eu/">mancraft.eu</a> - your source for free website templates
</div>
</center>
</body>
</html>