<?php

set_time_limit(0);
ini_set('memory_limit','512M');

$acceptableHosts=array('127.0.0.1','130.231.15.5');
if(!in_array($_SERVER['REMOTE_ADDR'], $acceptableHosts)){
    http_response_code('400');
    die();
}

if(file_exists('received.tar')){
    http_response_code('400');
    die('Previous upload still exists. Aborting.');
}

$contents=explode("\r\n", file_get_contents('php://input'));
$content=array_slice($contents,4, -1);
$contents=implode("\r\n", $contents);

$fh=@fopen('received_'.time().'.tar','w');
@fwrite($fh, $contents);
@fclose($fh);

