<?php

    include('phpqrcode/qrlib.php');

    // how to build raw content - QRCode with detailed Business Card (VCard)

    $tempDir = 'temp/';

    // here our data
    $name         = 'Yuttadhammo Bhikkhu';
    $sortName     = 'Yuttadhammo;Bhikkhu';
    $phoneCell        = '(289) 489-5318';
    $phoneLand = '(905) 581-8522';
    $orgName      = 'Sirimangalo International';

    $email        = 'yuttadhammo@gmail.com';
    
    $website        = 'http://www.sirimangalo.org/';
    $weblog        = 'http://yuttadhammo.sirimangalo.org/';
    $facebook        = 'http://www.facebook.com/yuttadhammo';
    $youtube        = 'http://www.youtube.com/yuttadhammo';

    // if not used - leave blank!
    $addressLabel     = 'Meditation Centre';
    $addressPobox     = '';
    $addressExt       = '';
    $addressStreet    = '2 Bond St. S.';
    $addressTown      = 'Hamilton';
    $addressRegion    = 'ON';
    $addressPostCode  = 'L8E 2L6';
    $addressCountry   = 'Canada';

    // we building raw data
    $codeContents  = 'BEGIN:VCARD'."\n";
    $codeContents .= 'VERSION:2.1'."\n";
    $codeContents .= 'N:'.$sortName."\n";
    $codeContents .= 'FN:'.$name."\n";
    $codeContents .= 'ORG:'.$orgName."\n";

    $codeContents .= 'TEL;HOME;VOICE:'.$phoneLand."\n";
    $codeContents .= 'TEL;TYPE=cell:'.$phoneCell."\n";

    $codeContents .= 'ADR;TYPE=home;'.
        'LABEL="'.$addressLabel.'":'
        .$addressPobox.';'
        .$addressExt.';'
        .$addressStreet.';'
        .$addressTown.';'
        .$addressPostCode.';'
        .$addressCountry
    ."\n";

    $codeContents .= 'EMAIL:'.$email."\n";

    $codeContents .= 'URL;TYPE=home:'.$website."\n";
    $codeContents .= 'URL:'.$weblog."\n";
    $codeContents .= 'URL:'.$facebook."\n";
    $codeContents .= 'URL:'.$youtube."\n";

    $codeContents .= 'END:VCARD';

    // generating
    QRcode::png($codeContents, $tempDir.'026.png', QR_ECLEVEL_L, 3);

    // displaying
    echo '<img src="'.$tempDir.'026.png" />'; 
