<?if(!defined('INDEX')) die;


$json=file_get_contents("php://input");
$data=json_decode($json, true);
if(!$data){
    header("HTTP/1.0 204 No Content");
    die;
}
$bid=array();
$bidid=1;
if(!isset($data['imp'])){
    header("HTTP/1.0 204 No Content");
    die;
}

foreach ($data['imp'] as $imp) {
	$rnd=md5(rand().microtime());
    $bid[]=array(
                    'id'    => strval($bidid++),
                    'impid' => $imp['id'],
                    'price' => 0.18,
                    'nurl'  => 'http://'.$_SERVER['HTTP_HOST'].'/nurl?i='.$rnd.'&z=${AUCTION_IMP_ID}&price=${AUCTION_PRICE}&b=1',
                    'adm'   => '<a target="_blank" href="https://'.$_SERVER['HTTP_HOST'].'/go?i='.$rnd.'&z=${AUCTION_IMP_ID}&b=1"><img src="https://'.$_SERVER['HTTP_HOST'].'/static/b1.png" width="300px" height="600px" border="none"></a>',
                    'adid'  => '1',
                );

}
$resp = array(
    'id'         => $data['id'],
    'seatbid'    => array(
        array(
            'bid' => $bid
        ),
    ),
    'cur'        => 'USD',
    'nbr'        => 0,
);



header("Content-type: application/json");
echo json_encode($resp);