/**
  * {@inheritdoc}
  */
 public function write(Profile $profile)
 {
     $this->cleanup();
     $record = array('_id' => $profile->getToken(), 'parent' => $profile->getParentToken(), 'data' => base64_encode(serialize($profile->getCollectors())), 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), 'time' => $profile->getTime());
     return $this->getMongo()->update(array('_id' => $profile->getToken()), array_filter($record, function ($v) {
         return !empty($v);
     }), array('upsert' => true));
 }
 /**
  * Write data associated with the given token.
  *
  * @param Profile $profile A Profile instance
  *
  * @return Boolean Write operation successful
  */
 public function write(Profile $profile)
 {
     $this->cleanup();
     $record = array('_id' => $profile->getToken(), 'parent' => $profile->getParent() ? $profile->getParent()->getToken() : null, 'data' => serialize($profile->getCollectors()), 'ip' => $profile->getIp(), 'url' => $profile->getUrl(), 'time' => $profile->getTime());
     return $this->getMongo()->insert(array_filter($record, function ($v) {
         return !empty($v);
     }));
 }
 /**
  * {@inheritdoc}
  */
 public function write(Profile $profile)
 {
     $db = $this->initDb();
     $args = array(':token' => $profile->getToken(), ':parent' => $profile->getParentToken(), ':data' => base64_encode(serialize($profile->getCollectors())), ':ip' => $profile->getIp(), ':method' => $profile->getMethod(), ':url' => $profile->getUrl(), ':time' => $profile->getTime(), ':created_at' => time());
     try {
         if ($this->has($profile->getToken())) {
             $this->exec($db, 'UPDATE sf_profiler_data SET parent = :parent, data = :data, ip = :ip, method = :method, url = :url, time = :time, created_at = :created_at WHERE token = :token', $args);
         } else {
             $this->exec($db, 'INSERT INTO sf_profiler_data (token, parent, data, ip, method, url, time, created_at) VALUES (:token, :parent, :data, :ip, :method, :url, :time, :created_at)', $args);
         }
         $this->cleanup();
         $status = true;
     } catch (\Exception $e) {
         $status = false;
     }
     $this->close($db);
     return $status;
 }
 /**
  * {@inheritdoc}
  */
 public function write(Profile $profile)
 {
     $file = $this->getFilename($profile->getToken());
     $profileIndexed = is_file($file);
     if (!$profileIndexed) {
         // Create directory
         $dir = dirname($file);
         if (!is_dir($dir)) {
             mkdir($dir, 0777, true);
         }
     }
     // Store profile
     $data = array('token' => $profile->getToken(), 'parent' => $profile->getParentToken(), 'children' => array_map(function ($p) {
         return $p->getToken();
     }, $profile->getChildren()), 'data' => $profile->getCollectors(), 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), 'time' => $profile->getTime());
     if (false === file_put_contents($file, serialize($data))) {
         return false;
     }
     if (!$profileIndexed) {
         // Add to index
         if (false === ($file = fopen($this->getIndexFilename(), 'a'))) {
             return false;
         }
         fputcsv($file, array($profile->getToken(), $profile->getIp(), $profile->getMethod(), $profile->getUrl(), $profile->getTime(), $profile->getParentToken()));
         fclose($file);
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function write(Profile $profile)
 {
     $data = array('token' => $profile->getToken(), 'parent' => $profile->getParentToken(), 'children' => array_map(function ($p) {
         return $p->getToken();
     }, $profile->getChildren()), 'data' => $profile->getCollectors(), 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), 'time' => $profile->getTime());
     $profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken()));
     if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime)) {
         if (!$profileIndexed) {
             // Add to index
             $indexName = $this->getIndexName();
             $indexRow = implode("\t", array($profile->getToken(), $profile->getIp(), $profile->getMethod(), $profile->getUrl(), $profile->getTime(), $profile->getParentToken(), $profile->getStatusCode())) . "\n";
             return $this->appendValue($indexName, $indexRow, $this->lifetime);
         }
         return true;
     }
     return false;
 }
Example #6
0
 function onEndUnsubscribe(Profile $profile, Profile $other)
 {
     // Only do this if config is enabled
     if (!$this->StopFollowUser) {
         return true;
     }
     if (!$profile->isLocal()) {
         return true;
     }
     // TRANS: Text for "stopped following" item in activity plugin.
     // TRANS: %1$s is a profile URL, %2$s is a profile name,
     // TRANS: %3$s is a profile URL, %4$s is a profile name.
     $rendered = sprintf(_m('<a href="%1$s">%2$s</a> stopped following <a href="%3$s">%4$s</a>.'), $profile->getUrl(), $profile->getBestName(), $other->getUrl(), $other->getBestName());
     // TRANS: Text for "stopped following" item in activity plugin.
     // TRANS: %1$s is a profile name, %2$s is a profile URL,
     // TRANS: %3$s is a profile name, %4$s is a profile URL.
     $content = sprintf(_m('%1$s (%2$s) stopped following %3$s (%4$s).'), $profile->getBestName(), $profile->getUrl(), $other->getBestName(), $other->getUrl());
     $uri = TagURI::mint('stop-following:%d:%d:%s', $profile->id, $other->id, common_date_iso8601(common_sql_now()));
     $notice = Notice::saveNew($profile->id, $content, ActivityPlugin::SOURCE, array('rendered' => $rendered, 'urls' => array(), 'replies' => array($other->getUri()), 'uri' => $uri, 'verb' => ActivityVerb::UNFOLLOW, 'object_type' => ActivityObject::PERSON));
     return true;
 }
 /**
  * Write data associated with the given token.
  *
  * @param Profile $profile A Profile instance
  *
  * @return Boolean Write operation successful
  */
 public function write(Profile $profile)
 {
     return $this->getMongo()->insert(array('token' => $profile->getToken(), 'ip' => $profile->getIp(), 'url' => $profile->getUrl() === null ? '' : $profile->getUrl(), 'profile' => serialize($profile)));
 }
Example #8
0
 public static function onCheckActivityAuthorship(Activity $activity, Profile &$profile)
 {
     try {
         $oprofile = Ostatus_profile::ensureProfileURL($profile->getUrl());
         $profile = $oprofile->checkAuthorship($activity);
     } catch (Exception $e) {
         common_log(LOG_ERR, 'Could not get a profile or check authorship (' . get_class($e) . ': "' . $e->getMessage() . '") for activity ID: ' . $activity->id);
         $profile = null;
         return false;
     }
     return true;
 }