preg_match( '/href="([^"]+)"/is', $href, $bits );
		$urls[] = $bits[1];
	}
}
*/

// Let's just work on a random slice of the URLs
$urls = array( 'http://dentedreality.com.au/contact/' );

// Now go through each URL and throw against Plaxo to convert to JSON
foreach( $urls as $url ) {
	// Get the URL and parse for hCards
	$hKit = new hKit();
	$hKit->tidy_mode = 'exec';
	$hKit->tmp_dir = '/tmp/';
	$hCards = $hKit->getByURL( 'hcard', $url );

	// Loop through hCards found and stick them in LDAP
	foreach( $hCards as $hCard ) {
		if ( empty( $hCard['fn'] ) && empty( $hCard['n']['given-name'] ) && empty( $hCard['n']['family-name'] ) )
			continue; // Can't do anything without a name of some sort
			
		// Compile details from card read to create LDAP entry
		$dn = 'cn=' . $hCard['fn'] . ', o=SuperMegaScrapingAddressBook, c=US';
		$entry = array();
		$entry['cn']              = array( '' ); // Common Name
		$entry['sn']              = array( '' ); // Surname/Family Name
		$entry['gn']              = array( '' ); // Given Name
		$entry['personalTitle']   = array( '' ); // Mr, Mrs etc		
		$entry['displayName']     = array( '' ); // Nickname
		$entry['title']           = array( '' ); // Job role
 function webfinger_find_by_email($email)
 {
     // Obtain the URL to gather user information from
     $query_url = webfinger_query_url_for_email($email);
     if (empty($query_url)) {
         return null;
     }
     // Try to grab the information help on this email address
     $query_result = http_request($query_url);
     if (!did_http_succeed($query_result)) {
         return null;
     }
     $query_xml = $query_result['body'];
     $query_data = convert_xml_string_to_array($query_xml);
     if (!isset($query_data['xrd']['link'])) {
         return null;
     }
     $query_links = $query_data['xrd']['link'];
     // If there was a single link tag, we'll get its contents in $query_links, but
     // if multiple links were present, the contents will be an numeric array of them all.
     // To normalize this, put lone tags into their own array.
     if (!isset($query_links[0])) {
         $query_links_list = array($query_links);
     } else {
         $query_links_list = $query_links;
     }
     // Go through all the links and extract the information from any we recognize
     $result = array();
     foreach ($query_links_list as $link) {
         if (!isset($link['@attributes']['rel']) || !isset($link['@attributes']['href'])) {
             continue;
         }
         $rel = $link['@attributes']['rel'];
         $href = $link['@attributes']['href'];
         // At the moment this only understands hCard formatted pages
         if ($rel === HCARD_REL_URL) {
             $hkit = new hKit();
             $hcard_result = $hkit->getByURL('hcard', $href);
             if (empty($hcard_result) || !isset($hcard_result[0])) {
                 continue;
             }
             $hcard_info = $hcard_result[0];
             $user_id = $href;
             $user_name = '';
             if (isset($hcard_info['fn'])) {
                 $display_name = $hcard_info['fn'];
             } else {
                 $display_name = '';
             }
             if (isset($hcard_info['photo'])) {
                 $portrait_url = $hcard_info['photo'];
             } else {
                 $portrait_url = '';
             }
             if (isset($hcard_info['adr'])) {
                 $location = $hcard_info['adr'];
             } else {
                 $location = '';
             }
             $result = array('webfinger' => array('user_id' => $user_id, 'user_name' => $user_name, 'display_name' => $display_name, 'portrait_url' => $portrait_url, 'location' => $location));
         }
     }
     if (empty($result)) {
         return null;
     }
     return $result;
 }
Example #3
0
 private function _get_data_from_url($url)
 {
     //We have to hang on to the hKit object, because its configuration is done by require_once
     //and will thus only work for the first instantiation...
     static $hkit;
     if (is_null($hkit)) {
         require_once MIDCOM_ROOT . '/external/hkit.php';
         $hkit = new hKit();
     }
     $data = array();
     // TODO: Error handling
     $client = new org_openpsa_httplib();
     $html = $client->get($url);
     // Check for ICBM coordinate information
     $icbm = org_openpsa_httplib_helpers::get_meta_value($html, 'icbm');
     if ($icbm) {
         $data['icbm'] = $icbm;
     }
     // Check for RSS feed
     $rss_url = org_openpsa_httplib_helpers::get_link_values($html, 'alternate');
     if ($rss_url && count($rss_url) > 0) {
         $data['rss_url'] = $rss_url[0]['href'];
         // We have a feed URL, but we should check if it is GeoRSS as well
         midcom::get('componentloader')->load_library('net.nemein.rss');
         $rss_content = net_nemein_rss_fetch::raw_fetch($data['rss_url']);
         if (isset($rss_content->items) && count($rss_content->items) > 0) {
             if (array_key_exists('georss', $rss_content->items[0]) || array_key_exists('geo', $rss_content->items[0])) {
                 // This is a GeoRSS feed
                 $data['georss_url'] = $data['rss_url'];
             }
         }
     }
     $hcards = @$hkit->getByURL('hcard', $url);
     if (is_array($hcards) && count($hcards) > 0) {
         // We have found hCard data here
         $data['hcards'] = $hcards;
     }
     return $data;
 }
Example #4
0
 $data = array();
 $calUser = $nid;
 $overwrite = true;
 $type = 'remoteics';
 // We will check ics first.
 $data = parse_ical($nurl, $type);
 // TODO it may be a vcs file.
 // if ( count ( $data ) == 0 ) {
 // $data = parse_vcal ( $nurl );
 // }
 // We may be processing an hCalendar.
 // $data sometimes has a count of 1 but is not a valid array.
 if ((count($data) == 0 || !isset($data[0])) && function_exists('simplexml_load_string')) {
     $h = new hKit();
     $h->tidy_mode = 'proxy';
     $result = $h->getByURL('hcal', $nurl);
     $type = 'hcal';
     $data = parse_hcal($result, $type);
 }
 $errorStr = '<br /><br />
 <b>' . translate('Error') . ':</b> ';
 print_header('', '', '', true, false, true);
 if (count($data) && empty($errormsg)) {
     // Delete existing events.
     delete_events($nid);
     // Import new events.
     import_data($data, $overwrite, $type);
     echo '
 <p>' . translate('Import Results') . '</p><br /><br />
 ' . translate('Events successfully imported') . ': ' . $count_suc . '<br />';
     if ($layer_found == false) {
Example #5
0
 $cnt++;
 $calUser = $row[0];
 $cal_url = $row[1];
 $login = $row[2];
 $overwrite = true;
 $type = 'remoteics';
 $data = parse_ical($cal_url, $type);
 // TODO it may be a vcs file
 // if ( count ( $data ) == 0 ) {
 // $data = parse_vcal ( $cal_url );
 // }
 // we may be processing an hCalendar
 if (count($data) == 0 && function_exists('simplexml_load_string')) {
     $h = new hKit();
     $h->tidy_mode = 'proxy';
     $result = $h->getByURL('hcal', $cal_url);
     $type = 'hcal';
     $data = parse_hcal($result, $type);
 }
 if (count($data) && empty($errormsg)) {
     // delete existing events
     if ($debug) {
         echo "<br />\n" . translate('Deleting events for') . ": {$calUser}<br />\n";
     }
     delete_events($calUser);
     // import new events
     if ($debug) {
         echo translate('Importing events for') . ": {$calUser}<br />\n" . translate('From') . ": {$cal_url}<br />\n";
     }
     import_data($data, $overwrite, $type);
     if ($debug) {