<?php

function cardinfo($card){
    $ctx = stream_context_create(array('http'=>
        array(
            'timeout' => 2,  //1200 Seconds is 20 Minutes
        )
    ));
    $card = str_replace(" ", "", $card);
    $bin = substr($card,0,6);
    try {
        $ret = file_get_contents("https://bins.antipublic.cc/bins/$bin", false, $ctx);
        if ($ret != false){
            $data = json_decode($ret,true);
            if($data['brand']) {
                return array(
                    'bank' => $data['bank'],
                	'country_name' => $data['country_name'],
                    'country' => $data['country'],
                    'currency' => $data['country_currencies'][0],
                    'emoji' => $data['country_flag'],
                    'scheme' => $data['level'],
                    'brand' => $data['brand'],
                    'type' => $data['type'],
                    'bin' => $bin
                );
            }
            else {
                return false;
            }
        } else {
            return false;
        }
    } catch(Exception $e) {
        return false;
    }
}

?>