Ejemplo n.º 1
0
 function parse_vcards(&$lines)
 {
     $cards = array();
     $card = new VCard();
     while ($card->parse($lines)) {
         $property = $card->getProperty('N');
         if (!$property) {
             return "";
         }
         $n = $property->getComponents();
         $tmp = array();
         if ($n[3]) {
             $tmp[] = $n[3];
         }
         // Mr.
         if ($n[1]) {
             $tmp[] = $n[1];
         }
         // John
         if ($n[2]) {
             $tmp[] = $n[2];
         }
         // Quinlan
         if ($n[4]) {
             $tmp[] = $n[4];
         }
         // Esq.
         $ret = array();
         if ($n[0]) {
             $ret[] = $n[0];
         }
         $tmp = join(" ", $tmp);
         if ($tmp) {
             $ret[] = $tmp;
         }
         $key = join(", ", $ret);
         $cards[$key] = $card;
         // MDH: Create new VCard to prevent overwriting previous one (PHP5)
         $card = new VCard();
     }
     ksort($cards);
     return $cards;
 }
 /**
  * get url from vcard
  * 
  * @param VCard $_card
  * @param array $_data
  * @return array
  */
 function _getUrl(VCard $_card, $_data)
 {
     $urlProperty = $_card->getProperty('URL') ? 'URL' : ($_card->getProperty('ITEM2.URL') ? 'ITEM2.URL' : '');
     if (empty($urlProperty)) {
         return $_data;
     }
     $key = 'url';
     if ($this->_options['urlIsHome']) {
         $key = 'url_home';
     }
     $_data[$key] = $_card->getProperty($urlProperty)->value;
     $_data[$key] = preg_replace('/\\\\/', '', $_data[$key]);
     return $_data;
 }
Ejemplo n.º 3
0
        ?>
<script type="text/javascript">top.stop_upload();</script><?php 
        exit;
    }
    $vcard_file = $_FILES['my_file']['tmp_name'];
    $lines = file($vcard_file);
    if (!$lines) {
        ?>
<script type="text/javascript">top.stop_upload();</script><?php 
        exit;
    }
    // parse the file into $cards
    $cards = array();
    $card = new VCard();
    while ($card->parse($lines)) {
        $property = $card->getProperty('N');
        if (!$property) {
            ?>
<script type="text/javascript">top.stop_upload();</script><?php 
            exit;
        }
        $n = $property->getComponents();
        $tmp = array();
        if ($n[3]) {
            $tmp[] = $n[3];
        }
        // Mr.
        if ($n[1]) {
            $tmp[] = $n[1];
        }
        // John