]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/scripts/update_ostatus_profiles.php
Merge branch 'master' of gitorious.org:social/mainline into social-master
[quix0rs-gnu-social.git] / plugins / OStatus / scripts / update_ostatus_profiles.php
index bca136bbbce3a27285b99276df20f8ecaf604ff2..9102a0a2cb3b1d2c4e48a963f0e86a6762da27fe 100644 (file)
@@ -18,7 +18,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
 
 $shortoptions = 'u:a';
 $longoptions = array('uri=', 'all');
@@ -35,7 +35,7 @@ you have no backup.
 
 UPDATE_OSTATUS_PROFILES;
 
-require_once INSTALLDIR . '/scripts/commandline.inc';
+require_once INSTALLDIR . '/scripts/commandline.inc.php';
 
 /*
  * Hacky class to remove some checks and get public access to
@@ -70,11 +70,11 @@ class LooseOstatusProfile extends Ostatus_profile
 
         // @fixme this should be better encapsulated
         // ripped from oauthstore.php (for old OMB client)
-        $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
+        $temp_filename = tempnam(common_get_temp_dir(), 'listener_avatar');
         try {
             if (!copy($url, $temp_filename)) {
                 // TRANS: Server exception. %s is a URL.
-                throw new ServerException(sprintf(_m('Unable to fetch avatar from %s.'), $url));
+                throw new ServerException(sprintf(_m('Unable to fetch avatar from %s to %s.'), $url, $temp_filename));
             }
 
             if ($this->isGroup()) {
@@ -118,7 +118,7 @@ class LooseOstatusProfile extends Ostatus_profile
      * @throws Exception on various error conditions
      * @throws OStatusShadowException if this reference would obscure a local user/group
      */
-    public static function updateProfileURL($profile_url, $hints=array())
+    public static function updateProfileURL($profile_url, array $hints=array())
     {
         $oprofile = null;
 
@@ -157,13 +157,13 @@ class LooseOstatusProfile extends Ostatus_profile
         // Check if they've got an LRDD header
 
         $lrdd = LinkHeader::getLink($response, 'lrdd', 'application/xrd+xml');
-
-        if (!empty($lrdd)) {
-
-            $xrd = Discovery::fetchXrd($lrdd);
+        try {
+            $xrd = new XML_XRD();
+            $xrd->loadFile($lrdd);
             $xrdHints = DiscoveryHints::fromXRD($xrd);
-
             $hints = array_merge($hints, $xrdHints);
+        } catch (Exception $e) {
+            // No hints available from XRD
         }
 
         // If discovery found a feedurl (probably from LRDD), use it.
@@ -214,9 +214,12 @@ class LooseOstatusProfile extends Ostatus_profile
 
         $hints = array('webfinger' => $addr);
 
-        $dhints = DiscoveryHints::fromXRD($xrd);
-
-        $hints = array_merge($hints, $dhints);
+        try {
+            $dHints = DiscoveryHints::fromXRD($xrd);
+            $hints = array_merge($hints, $xrdHints);
+        } catch (Exception $e) {
+            // No hints available from XRD
+        }
 
         // If there's an Hcard, let's grab its info
         if (array_key_exists('hcard', $hints)) {
@@ -319,7 +322,7 @@ while($lop->fetch()) {
         }
     } catch (Exception $e) {
         if (!$quiet) { print $e->getMessage() . "\n"; }
-        common_log(LOG_WARN, $e->getMessage(), __FILE__);
+        common_log(LOG_WARNING, $e->getMessage(), __FILE__);
         // continue on error
     }
 }