<?php require_once("ddos.php"); ?>
<?php
//if(isset($_POST["secure"]))
//{
//if(!$_POST["secure"] == "dennisu2891e91") 
//{
//die("Invalid Call");
//}
//}
//else
//{
//die("What do you try? noob.");
//}
     
    //if(isset($_POST['secure']))
    //{
          //  if(!($_POST['secure'] == 'secure'))
         //   {
       //             die('invalid');
      //      }
    //}
    //else
    //{
    //        die('What do you try? noob.');
  //  }

require_once ("juefh7z4jke.php");

if (!isset($_GET['36283gbf3df'])) 
    $user = sql_clean("");
else
    $user = sql_clean($_GET['36283gbf3df']);

if (!isset($_GET['sdadg1pn'])) 
    $passhash = sql_clean("");
else
	$passhash = sql_clean($_GET['sdadg1pn']);



$con = mssql_connect($conf['db_host'],$conf['db_user'],$conf['db_pass']) or die('Database connect Fail.');
$db = mssql_select_db($conf['db_name'], $con) or die('Database Init Fail.');

$exec = mssql_query("SELECT nEMID, sUserPass, nAuthID FROM tAccounts where sUsername = '$user'");

if($exec)
{
    if(mssql_num_rows($exec) != 1)
    {
        die('Account nicht gefunden.');
    }
    $AccountData = mssql_fetch_assoc($exec);
    $PlaintxtPass = $AccountData['sUserPass'];
    $PlaintxtnEMID = $AccountData['nEMID'];
    $PlaintxtnAuthID = $AccountData['nAuthID'];
	$Admin = "9";
    $Admin1 = "8";
 
 if (MD5($PlaintxtPass) == $passhash)
    { 
        $Token =  $_GET['36283gbf3df'].randomtoken(30);
		$Taken = hash('sha1',$Token);
         // hash('sha256','36283gbf3df'.randomtoken(50).Shiiit);
		$setToken = null;

        if (mssql_num_rows(mssql_query("SELECT * FROM tTokens WHERE nEMID = '".$PlaintxtnEMID."'")) >= 1)
        {
            mssql_query("DELETE FROM tTokens WHERE nEMID = '".$PlaintxtnEMID."'");
            $setToken = mssql_query("INSERT INTO tTokens (nEMID, sToken) VALUES('".$PlaintxtnEMID."', '".$Taken."')");
        }
        else
            $setToken = mssql_query("INSERT INTO tTokens (nEMID, sToken) VALUES('".$PlaintxtnEMID."', '".$Taken."')");
       
	   if($PlaintxtnAuthID == $Admin)
	            {
				die('Admin#');
				}
        
		if($PlaintxtnAuthID == $Admin1)
	            {
				die('Admin1#');
				}
	  
	  if ($setToken)
            die('OK#'.$Token);
        	  
		else
            die('SetToken Error');
    }
    else
    {
        die('Falsches Passwort.');
    }
}
else
{
    die('Query Failed');
}

mssql_close();

function sql_clean($str)
{
    $search  = array('^', '°', '!', '"', '²', '§', '³', '$', '%', '&', '/', '{', '(', '[', ')', ']', '=', '}', '?', '\'', '´', '`', '€', '*', '+', '~', '#', "'", '<', '>', '|', 'µ', ';' , 'UPDATE' , 'RESTORE' , 'UNION' , 'SELECT' , '*' , ' FROM' , 'DATABASE' , 'DROP' , '\0' , '\\' , '\n' , '\r');
    $replace = array('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' , '', '', '', '', '', '', '', '', '', '', '', '');
	return str_replace($search, $replace, $str);
}

function RandomToken( $length )
{
	$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        $str = "";
	$size = strlen( $chars );
	for( $i = 0; $i < $length; $i++ ) {
		$str .= $chars[ rand( 0, $size - 1 ) ];
	}

	return $str;
}
?>