X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOStatus%2Fscripts%2Fupdate_ostatus_profiles.php;h=1f70bac897aecadd5581d9148d20ce2c8e7e125f;hb=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a;hp=9102a0a2cb3b1d2c4e48a963f0e86a6762da27fe;hpb=bc8e114b375bbe378440f2d33ea2577efade95b6;p=quix0rs-gnu-social.git diff --git a/plugins/OStatus/scripts/update_ostatus_profiles.php b/plugins/OStatus/scripts/update_ostatus_profiles.php old mode 100644 new mode 100755 index 9102a0a2cb..1f70bac897 --- a/plugins/OStatus/scripts/update_ostatus_profiles.php +++ b/plugins/OStatus/scripts/update_ostatus_profiles.php @@ -20,8 +20,8 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); -$shortoptions = 'u:a'; -$longoptions = array('uri=', 'all'); +$shortoptions = 'u:af'; +$longoptions = array('uri=', 'all', 'force'); $helptext = <<isGroup()) { - $self = $this->localGroup(); - } else { - $self = $this->localProfile(); - } - if (!$self) { - throw new ServerException(sprintf( - // TRANS: Server exception. %s is a URI. - _m('Tried to update avatar for unsaved remote profile %s.'), - $this->uri)); - } - - // @fixme this should be better encapsulated - // ripped from oauthstore.php (for old OMB client) - $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 to %s.'), $url, $temp_filename)); - } - - if ($this->isGroup()) { - $id = $this->group_id; - } else { - $id = $this->profile_id; - } - // @fixme should we be using different ids? - $imagefile = new ImageFile($id, $temp_filename); - $filename = Avatar::filename($id, - image_type_to_extension($imagefile->type), - null, - common_timestamp()); - rename($temp_filename, Avatar::path($filename)); - } catch (Exception $e) { - unlink($temp_filename); - throw $e; - } - // @fixme hardcoded chmod is lame, but seems to be necessary to - // keep from accidentally saving images from command-line (queues) - // that can't be read from web server, which causes hard-to-notice - // problems later on: - // - // http://status.net/open-source/issues/2663 - chmod(Avatar::path($filename), 0644); - - $self->setOriginal($filename); - - $orig = clone($this); - $this->avatar = $url; - $this->update($orig); - } - /** * Look up and if necessary create an Ostatus_profile for the remote entity * with the given profile page URL. This should never return null -- you @@ -271,10 +207,11 @@ class LooseOstatusProfile extends Ostatus_profile function pullOstatusProfile($uri) { $oprofile = null; + $validate = new Validate(); - if (Validate::email($uri)) { + if ($validate->email($uri)) { $oprofile = LooseOstatusProfile::updateWebfinger($uri); - } else if (Validate::uri($uri)) { + } else if ($validate->uri($uri)) { $oprofile = LooseOstatusProfile::updateProfileURL($uri); } else { print "Sorry, we could not reach the address: $uri\n"; @@ -295,6 +232,8 @@ if (have_option('u', 'uri')) { exit(1); } +$forceUpdates = have_option('f', 'force'); + $cnt = $lop->find(); if (!empty($cnt)) { @@ -317,7 +256,7 @@ while($lop->fetch()) { $orig = clone($lop); $lop->avatar = $oprofile->avatar; $lop->update($orig); - $lop->updateAvatar($oprofile->avatar); + $lop->updateAvatar($oprofile->avatar, $forceUpdates); if (!$quiet) { print "Done.\n"; } } } catch (Exception $e) {