Index: logic.php =================================================================== --- logic.php (révision 19639) +++ logic.php (copie de travail) @@ -131,7 +131,7 @@ echo $this->error; return false; } - require_once(ABSPATH . '/wp-admin/upgrade-functions.php'); + require_once(ABSPATH . '/wp-admin/upgrade.php'); $this->getStore()->dbDelta(); // Table for storing UserID <---> URL associations. @@ -241,8 +241,8 @@ $this->action = $_REQUEST['action']; require_once(ABSPATH . 'wp-admin/admin-functions.php'); - require_once(ABSPATH . 'wp-admin/admin-db.php'); - require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); +// require_once(ABSPATH . 'wp-admin/admin-db.php'); +// require_once(ABSPATH . 'wp-admin/upgrade.php'); auth_redirect(); nocache_headers(); @@ -421,9 +421,36 @@ $ret = @$this->getStore()->connection->query( "INSERT INTO $this->identity_url_table_name (user_id,url,hash) VALUES ( %s, %s, MD5(%s) )", array( (int)$userdata->ID, $url, $url ) ); if( $old_show_errors ) $wpdb->show_errors(); + if($foaf = $this->fetch_foaf_profile($url)) update_usermeta((int)$userdata->ID, 'foaf', $foaf); + if($sioc = $this->fetch_sioc_profile($url)) update_usermeta((int)$userdata->ID, 'sioc', $sioc); return $ret; } - + + function fetch_foaf_profile($url) { + return $this->fetch_auto_discovery($url, 'foaf'); + } + + function fetch_sioc_profile($url) { + return $this->fetch_auto_discovery($url, 'sioc'); + } + + function fetch_auto_discovery($url, $type) { + $html = file_get_contents($url); + preg_match_all('/.*<\/head>/Usi', $html, $links); + if($links) { + if($link = $links[1][0]) { + $ex = parse_url($link); + if($ex['scheme']) return $link; + elseif(substr($ex['path'], 0, 1) == '/') { + $ex = parse_url($url); + return $ex['scheme'].'://'.$ex['host'].$link; + } + else return $url.$link; + } + } + return null; + } + function drop_all_identities_for_user($userid) { $this->late_bind(); if( !$this->enabled ) return false;