<?php
session_start();
require_once __DIR__.'/include/config.php';
require_once __DIR__.'/include/functions.php';
require_once __DIR__.'/include/Page.Class.php';
require_once __DIR__.'/include/App.Class.php';

$param      = array_to_obj($param);
$id         = $param->id;
$encoded_id         = $param->encoded_id;


// SDU3R0I4U1R1QXBiRnhBYzdQMzZFQT09

if($encoded_id) {

$BCard = new BCard();
$CardInfo =  $BCard->DecodeCardToken($encoded_id);

switch($CardInfo->target_type){
    case 'external_link':

        header("Location: {$CardInfo->external_target}");

    break;
    case 'vcard_identity':

        $IdentityInfo = $BCard->GetIdentity($CardInfo->target_id, 'obj');

        header('Content-Type: text/x-vcard');  
        header("Content-Disposition: attachment; filename=BooCard_{$IdentityInfo->first_name}_{$IdentityInfo->last_name}.vcf");  
        
        echo $BCard->GenerateVCard($IdentityInfo);
    break;
}


die();
}
