<?php
/*======================================================================*\
|| #################################################################### ||
|| # EoT-Clan BF3 Leaderboard                                         # ||
|| # ---------------------------------------------------------------- # ||
|| # Dieses Copyright darf nicht entfernet werden                     # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # -----------------BF3 Leaderboard is a free Software--------------# ||
|| #                   http://eot-clan.net                            # ||
|| #################################################################### ||
\*======================================================================*/
include '../inc/config.php';
require_once ('../language/'.$row['language'].'.php');

$_GET = security::escape($_GET);
$_POST = security::escape($_POST);
session_start();
if(isset($_SESSION["username"])){
	?>
	<meta http-equiv="refresh" content="4;url=admin.php">
	<?php


if (isset($_POST['edituser'])){
$username = mysql_real_escape_string($_POST['username']);
$passwort = md5($_POST['password']);
$id = $_POST['id'];

     if ($_SESSION['id'] == 1 AND $passwort != md5("Password") AND $_POST['password'] != ""){  
       $query = "Update ".DBPrefix."login SET username='{$username}' , passwort='{$passwort}' WHERE id='{$id}'";
	        mysql_query ($query);
       $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMIN_UPDATE.'<br/><br/>'.LANG_ADMIN_META.'</td>';   
    }elseif ($_SESSION['id'] != 1 AND $passwort != md5("Password") AND $id == $_SESSION['id'] AND $_POST['password'] != ""){
         $query = "Update ".DBPrefix."login SET username='{$username}' , passwort='{$passwort}' WHERE id='{$id}'";
	          mysql_query ($query);
         $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMIN_UPDATE.'<br/><br/>'.LANG_ADMIN_META.'</td>';   
       }else{
         $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMIN_ERROR4.'<br/><br/>'.LANG_ADMIN_META.'</td>';
 }
}
    
if (isset($_POST['editsSoldiername'])){ 
    $username = mysql_real_escape_string($_POST['editsSoldiername']);
    $pid = $_POST['pid'];
    $query = "Update ".DBPrefix."generalStats SET soldiername='{$username}',invisible='' WHERE pid='{$pid}'";
	        mysql_query ($query);
	  $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_EDIT_SOLDIER.'<br/><br/>'.LANG_ADMIN_META.'</td>';
	  }
	 
	 if (isset($_POST['editpersona'])){ 
    $persona = mysql_real_escape_string($_POST['editpersona']);
    $pid = $_POST['pid'];
    $query = "Update ".DBPrefix."generalStats SET persona='{$persona}' WHERE pid='{$pid}'";
	        mysql_query ($query);
	  $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_EDIT_PERSONA.'<br/><br/>'.LANG_ADMIN_META.'</td>';
	  }
	 
       
       
 if (isset($_POST['vip_member'])){
 	      $id = $_POST['id'];
 	      $value = $_POST['wert'];
 	      $array = $_POST;
       foreach($array as $key => $wert) {
       $wert = mysql_real_escape_string($wert);
       $query = "Update ".DBPrefix."generalStats SET {$key}='{$value}' WHERE pid='$id'";
	        mysql_query ($query);
	    $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMIN_UPDATE_VIP_MEMBER.'<br/><br/>'.LANG_ADMIN_META.'</td>';
       }
       
}
 


if (isset($_POST['deleteuser']) AND $_SESSION["id"] == 1){
$id = $_POST['id'];

if ($id == "1"){
	$text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMIN_ERROR1.'<br/><br/>'.LANG_ADMIN_META.'</td>';
}else{
 $query = "DELETE FROM ".DBPrefix."login WHERE id='$id'";
	    mysql_query ($query);
   $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMIN_ERROR2.'<br/><br/>'.LANG_ADMIN_META.'</td>';   
 }
}


if (isset($_POST['createuser']) AND $_SESSION["id"] == 1){
	
$username = $_POST["username"];
$password = $_POST["password"];
$password2 = $_POST["password2"];
 
 
if($password != $password2 OR $username == "" OR $password == "") {
$text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMINS_CREATE_USER.'<br/><br/>'.LANG_ADMIN_META.'</td>';
}else{
 $password = md5($password); 
         $query = "SELECT id FROM ".DBPrefix."login WHERE username LIKE '$username'";
         $result = mysql_query($query);
         $menge = mysql_num_rows($result);

if($menge == 0) {
    $insert = "INSERT INTO ".DBPrefix."login (username, passwort) VALUES ('$username', '$password')";
    $eintragen = mysql_query($insert);

    if($eintragen == true) {
        $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMINS_CREATE_USER_CORRECT.'<br/><br/>'.LANG_ADMIN_META.'</td>';
       } else {
        $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMINS_CREATE_USER_ERROR.'<br/><br/>'.LANG_ADMIN_META.'</td>';
      }
    }else{
    $text = '<td class="default" style="font-size:11px;">'.LANG_ADMIN_ADMINS_CREATE_USER_ERROR1.'<br/><br/>'.LANG_ADMIN_META.'</td>';
  } 
 }
}


?>
<html>
	<head>
		<title><?php echo LANG_ADMIN_SETTINGS_UPDATE; ?></title>
		<?php echo $styleSettings; ?>
  </head>
         <table class="defaultUpdate" style="width:470px; margin-left: -250px;margin-top: -100px;position: absolute;left: 50%;top: 50%;" border="0" cellspacing="0" cellpadding="4">
        <?php echo $text; ?>
	</table>
</html>
<?php

}else{
	?>
	<?php echo $styleSettings; ?>
<title>Login error!!</title>
  <table class="defaultUpdate" style="width:470px; margin-left: -250px;margin-top: -100px;position: absolute;left: 50%;top: 50%;" border="0" cellspacing="0" cellpadding="4"><td>
<?php echo LANG_LOGIN_SESSION_ERROR; ?>
     </td></table>
     <?php
   }    