' .t('Libravatar addon is installed, too. Please disable Libravatar addon or this Gravatar addon. The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'
';
+ }
+
+ // output Gravatar settings
+ $o .= '';
$o .= replace_macros( $t, array(
'$submit' => t('Submit'),
'$default_avatar' => array('avatar', t('Default avatar image'), $default_avatar, t('Select default avatar image if none was found at Gravatar. See README'), $default_avatars),
diff --git a/infiniteimprobabilitydrive.tgz b/infiniteimprobabilitydrive.tgz
index 6d10fb691..8d9a2203f 100644
Binary files a/infiniteimprobabilitydrive.tgz and b/infiniteimprobabilitydrive.tgz differ
diff --git a/infiniteimprobabilitydrive/infiniteimprobabilitydrive.css b/infiniteimprobabilitydrive/infiniteimprobabilitydrive.css
index f4be60515..7fb4019c9 100644
--- a/infiniteimprobabilitydrive/infiniteimprobabilitydrive.css
+++ b/infiniteimprobabilitydrive/infiniteimprobabilitydrive.css
@@ -1,4 +1,3 @@
-section {
- padding-left: 0px;
-
-}
\ No newline at end of file
+section {padding-left: 0px;}
+
+iframe {border: none;}
\ No newline at end of file
diff --git a/jappixmini.tgz b/jappixmini.tgz
index c7fc99a41..212bb25e6 100644
Binary files a/jappixmini.tgz and b/jappixmini.tgz differ
diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php
index d4b1993f7..5d6f8446a 100644
--- a/jappixmini/jappixmini.php
+++ b/jappixmini/jappixmini.php
@@ -435,7 +435,7 @@ function jappixmini_script(&$a,&$s) {
$key = $row['k'];
$pos = strpos($key, ":");
$dfrn_id = substr($key, $pos+1);
- $r = q("SELECT `name` FROM `contact` WHERE `uid`=$uid AND `dfrn-id`='%s' OR `issued-id`='%s'",
+ $r = q("SELECT `name` FROM `contact` WHERE `uid`=$uid AND (`dfrn-id`='%s' OR `issued-id`='%s')",
dbesc($dfrn_id),
dbesc($dfrn_id)
);
@@ -488,6 +488,9 @@ function jappixmini_cron(&$a, $d) {
$users = q("SELECT `uid` FROM `pconfig` WHERE `cat`='jappixmini' AND (`k`='autosubscribe' OR `k`='autoapprove') AND `v`='1'");
logger("jappixmini: Update list of contacts' jabber accounts for ".count($users)." users.");
+ if(! count($users))
+ return;
+
foreach ($users as $row) {
$uid = $row["uid"];
diff --git a/libertree.tgz b/libertree.tgz
index a817c140b..f467bc00c 100644
Binary files a/libertree.tgz and b/libertree.tgz differ
diff --git a/libertree/libertree.php b/libertree/libertree.php
index 4f0c814d2..0e7e1a819 100755
--- a/libertree/libertree.php
+++ b/libertree/libertree.php
@@ -118,7 +118,7 @@ function libertree_post_local(&$a,&$b) {
if($b['private'] || $b['parent'])
return;
- $ltree_post = intval(get_pconfig(local_user(),'libertree','post'));
+ $ltree_post = intval(get_pconfig(local_user(),'libertree','post'));
$ltree_enable = (($ltree_post && x($_REQUEST,'libertree_enable')) ? intval($_REQUEST['libertree_enable']) : 0);
@@ -153,8 +153,8 @@ function libertree_send(&$a,&$b) {
$ltree_api_token = get_pconfig($b['uid'],'libertree','libertree_api_token');
$ltree_url = get_pconfig($b['uid'],'libertree','libertree_url');
$ltree_blog = "$ltree_url/api/v1/posts/create/?token=$ltree_api_token";
-
- if($ltree_url && $ltree_api_token && $ltree_blog) {
+ $ltree_source = "Friendica";
+ if($ltree_url && $ltree_api_token && $ltree_blog && $ltree_source) {
require_once('include/bb2diaspora.php');
$tag_arr = array();
@@ -167,16 +167,42 @@ function libertree_send(&$a,&$b) {
}
}
if(count($tag_arr))
- $tags = implode(',',$tag_arr);
+ $tags = implode(',',$tag_arr);
+ $title = $b['title'];
+ $body = $b['body'];
+ // Insert a newline before and after a quote
+ $body = str_ireplace("[quote", "\n\n[quote", $body);
+ $body = str_ireplace("[/quote]", "[/quote]\n\n", $body);
+
+ // Removal of tags and mentions
+ // #-tags
+ $body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
+ // @-mentions
+ $body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
+
+ // remove multiple newlines
+ do {
+ $oldbody = $body;
+ $body = str_replace("\n\n\n", "\n\n", $body);
+ } while ($oldbody != $body);
+
+ // convert to markdown
+ $body = bb2diaspora($body);
+
+ // Adding the title
+ if(strlen($title))
+ $body = "## ".html_entity_decode($title)."\n\n".$body;
+
$params = array(
- 'text' => bb2diaspora($b['body'])
+ 'text' => $body,
+ 'source' => $ltree_source
// 'token' => $ltree_api_token
);
$result = post_url($ltree_blog,$params);
- logger('libertree: ' . $result);
+ logger('libertree: ' . $result);
}
}
diff --git a/libravatar.tgz b/libravatar.tgz
new file mode 100644
index 000000000..0405af9bd
Binary files /dev/null and b/libravatar.tgz differ
diff --git a/libravatar/README.md b/libravatar/README.md
new file mode 100644
index 000000000..16fbd85a2
--- /dev/null
+++ b/libravatar/README.md
@@ -0,0 +1,36 @@
+# Libravatar Plugin
+by [Klaus Weidenbach](http://friendica.dszdw.net/profile/klaus)
+
+This addon allows you to look up an avatar image for new users and contacts at [Libravatar](http://www.libravatar.com). It will be used if there have not been found any other avatar images yet for example through OpenID.
+
+Libravatar is a free and open replacement for Gravatar. It is a service where people can store an avatar image for their email-addresses. These avatar images can get looked up for example in comment functions, profile pages, etc. on other sites. There exists a central installation at [www.libravatar.com](http://www.libravatar.com), but you can also host it on your own server. If no avatar was found Libravatar will look up at Gravatar as a fallback.
+There is no rating available, as it is on Gravatar, so all avatar lookups are g-rated. (Suitable for all audiences.)
+
+PHP >= 5.3 is required for this plugin!
+
+You can not use the Libravatar and Gravatar addon at the same time. You need to choose one. If you need other ratings than g you better stay with Gravatar, otherwise it is safe to use Libravatar, because it will fall back to Gravatar if nothing was found at Libravatar.
+
+* * *
+
+# Configuration
+## Default Avatar Image
+If no avatar was found for an email Libravatar can create some pseudo-random generated avatars based on an email hash. You can choose between these presets:
+
+* __MM__: (mystery-man) a static image
+* __Identicon__: a generated geometric pattern based on email hash
+* __Monsterid__: a generated 'monster' with different colors, faces, etc. based on email hash
+* __Wavatar__: faces with different features and backgrounds based on email hash
+* __Retro__: 8-bit arcade-styled pixelated faces based on email hash
+
+See examples at [Libravatar][1].
+
+## Alternative Configuration
+Open the .htconfig.php file and add "libravatar" to the list of activated addons:
+
+ $a->config['system']['addon'] = "..., libravatar";
+
+You can add one configuration variable for the addon:
+
+ $a->config['libravatar']['default_avatar'] = "identicon";
+
+[1]: http://wiki.libravatar.org/api/ "See API documentation at Libravatar for more information"
diff --git a/libravatar/Services/Libravatar.php b/libravatar/Services/Libravatar.php
new file mode 100644
index 000000000..1b6d022e3
--- /dev/null
+++ b/libravatar/Services/Libravatar.php
@@ -0,0 +1,669 @@
+
+ * @copyright 2011 Services_Libravatar committers.
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://pear.php.net/package/Services_Libravatar
+ * @since File available since Release 0.1.0
+ */
+
+/**
+ * PHP support for the Libravatar.org service.
+ *
+ * Using this class is easy. After including or requiring
+ * Services/Libravatar.php simply do:
+ *
+ * $libravatar = new Services_Libravatar();
+ * $url = $libravatar->getUrl('melissa@meldraweb.com');
+ *
+ *
+ * This would populate $url with the string:
+ *
+ * http://cdn.libravatar.org/avatar/4db84629c121f2d443d33bdb9fd149bc
+ *
+ *
+ * A complicated lookup using all the options is:
+ *
+ * $libravatar = new Services_Libravatar();
+ * $libravatar->setSize(40);
+ * $libravatar->setAlgorithm('sha256');
+ * $libravatar->setHttps(true);
+ * $libravatar->setDefault(
+ * 'http://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png'
+ * );
+ * $url = $libravatar->getUrl('melissa@meldraweb.com');
+ *
+ *
+ * @category Services
+ * @package Services_Libravatar
+ * @author Melissa Draper
+ * @copyright 2011 Services_Libravatar committers.
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @version Release: 0.2.1
+ * @link http://pear.php.net/package/Services_Libravatar
+ * @since Class available since Release 0.1.0
+ */
+class Services_Libravatar
+{
+ /**
+ * Hashing algorithm to use
+ *
+ * @var string
+ * @see processAlgorithm()
+ * @see setAlgorithm()
+ */
+ protected $algorithm = 'md5';
+
+ /**
+ * Default image URL to use
+ *
+ * @var string
+ * @see processDefault()
+ * @see setDefault()
+ */
+ protected $default;
+
+ /**
+ * If HTTPS URLs should be used
+ *
+ * @var boolean
+ * @see detectHttps()
+ * @see setHttps()
+ */
+ protected $https;
+
+ /**
+ * Image size in pixels
+ *
+ * @var integer
+ * @see processSize()
+ * @see setSize()
+ */
+ protected $size;
+
+
+ /**
+ * Composes a URL for the identifier and options passed in
+ *
+ * Compose a full URL as specified by the Libravatar API, based on the
+ * email address or openid URL passed in, and the options specified.
+ *
+ * @param string $identifier a string of either an email address
+ * or an openid url
+ * @param array $options an array of (bool) https, (string) algorithm
+ * (string) size, (string) default.
+ * See the set* methods.
+ *
+ * @return string A string of a full URL for an avatar image
+ *
+ * @since Method available since Release 0.2.0
+ * @deprecated Use getUrl() instead
+ */
+ public function url($identifier, $options = array())
+ {
+ return $this->getUrl($identifier, $options);
+ }
+
+ /**
+ * Composes a URL for the identifier and options passed in
+ *
+ * Compose a full URL as specified by the Libravatar API, based on the
+ * email address or openid URL passed in, and the options specified.
+ *
+ * @param string $identifier a string of either an email address
+ * or an openid url
+ * @param array $options an array of (bool) https, (string) algorithm
+ * (string) size, (string) default.
+ * See the set* methods.
+ *
+ * @return string A string of a full URL for an avatar image
+ *
+ * @since Method available since Release 0.2.0
+ * @throws InvalidArgumentException When an invalid option is passed
+ */
+ public function getUrl($identifier, $options = array())
+ {
+ // If no identifier has been passed, set it to a null.
+ // This way, there'll always be something returned.
+ if (!$identifier) {
+ $identifier = null;
+ } else {
+ $identifier = $this->normalizeIdentifier($identifier);
+ }
+
+ // Load all options
+ $options = $this->checkOptionsArray($options);
+ $https = $this->https;
+ if (isset($options['https'])) {
+ $https = (bool)$options['https'];
+ }
+
+ $algorithm = $this->algorithm;
+ if (isset($options['algorithm'])) {
+ $algorithm = $this->processAlgorithm($options['algorithm']);
+ }
+
+ $default = $this->default;
+ if (isset($options['default'])) {
+ $default = $this->processDefault($options['default']);
+ }
+ $size = $this->size;
+ if (isset($options['size'])) {
+ $size = $this->processSize($options['size']);
+ }
+
+
+ $identifierHash = $this->identifierHash($identifier, $algorithm);
+
+ // Get the domain so we can determine the SRV stuff for federation
+ $domain = $this->domainGet($identifier);
+
+ // If https has been specified in $options, make sure we make the
+ // correct SRV lookup
+ $service = $this->srvGet($domain, $https);
+ $protocol = $https ? 'https' : 'http';
+
+ $params = array();
+ if ($size !== null) {
+ $params['size'] = $size;
+ }
+ if ($default !== null) {
+ $params['default'] = $default;
+ }
+ $paramString = '';
+ if (count($params) > 0) {
+ $paramString = '?' . http_build_query($params);
+ }
+
+ // Compose the URL from the pieces we generated
+ $url = $protocol . '://' . $service . '/avatar/' . $identifierHash
+ . $paramString;
+
+ // Return the URL string
+ return $url;
+ }
+
+ /**
+ * Checks the options array and verify that only allowed options are in it.
+ *
+ * @param array $options Array of options for getUrl()
+ *
+ * @return void
+ * @throws Exception When an invalid option is used
+ */
+ protected function checkOptionsArray($options)
+ {
+ //this short options are deprecated!
+ if (isset($options['s'])) {
+ $options['size'] = $options['s'];
+ unset($options['s']);
+ }
+ if (isset($options['d'])) {
+ $options['default'] = $options['d'];
+ unset($options['d']);
+ }
+
+ $allowedOptions = array(
+ 'algorithm' => true,
+ 'default' => true,
+ 'https' => true,
+ 'size' => true,
+ );
+ foreach ($options as $key => $value) {
+ if (!isset($allowedOptions[$key])) {
+ throw new InvalidArgumentException(
+ 'Invalid option in array: ' . $key
+ );
+ }
+ }
+
+ return $options;
+ }
+
+ /**
+ * Normalizes the identifier (E-mail address or OpenID)
+ *
+ * @param string $identifier E-Mail address or OpenID
+ *
+ * @return string Normalized identifier
+ */
+ protected function normalizeIdentifier($identifier)
+ {
+ if (filter_var($identifier, FILTER_VALIDATE_EMAIL)) {
+ return strtolower($identifier);
+ } else {
+ return self::normalizeOpenId($identifier);
+ }
+ }
+
+ /**
+ * Create a hash of the identifier.
+ *
+ * Create a hash of the email address or openid passed in. Algorithm
+ * used for email address ONLY can be varied. Either md5 or sha256
+ * are supported by the Libravatar API. Will be ignored for openid.
+ *
+ * @param string $identifier A string of the email address or openid URL
+ * @param string $hash A string of the hash algorithm type to make
+ * Uses the php implementation of hash()
+ * MD5 preferred for Gravatar fallback
+ *
+ * @return string A string hash of the identifier.
+ *
+ * @since Method available since Release 0.1.0
+ */
+ protected function identifierHash($identifier, $hash = 'md5')
+ {
+ if (filter_var($identifier, FILTER_VALIDATE_EMAIL) || $identifier === null) {
+ // If email, we can select our algorithm. Default to md5 for
+ // gravatar fallback.
+ return hash($hash, $identifier);
+ }
+
+ //no email, so the identifier has to be an OpenID
+ return hash('sha256', $identifier);
+ }
+
+ /**
+ * Normalizes an identifier (URI or XRI)
+ *
+ * @param mixed $identifier URI or XRI to be normalized
+ *
+ * @return string Normalized Identifier.
+ * Empty string when the OpenID is invalid.
+ *
+ * @internal Adapted from OpenID::normalizeIdentifier()
+ */
+ public static function normalizeOpenId($identifier)
+ {
+ // XRI
+ if (preg_match('@^xri://@i', $identifier)) {
+ return preg_replace('@^xri://@i', '', $identifier);
+ }
+
+ if (in_array($identifier[0], array('=', '@', '+', '$', '!'))) {
+ return $identifier;
+ }
+
+ // URL
+ if (!preg_match('@^http[s]?://@i', $identifier)) {
+ $identifier = 'http://' . $identifier;
+ }
+ if (strpos($identifier, '/', 8) === false) {
+ $identifier .= '/';
+ }
+ if (!filter_var($identifier, FILTER_VALIDATE_URL)) {
+ return '';
+ }
+
+ $parts = parse_url($identifier);
+ $parts['scheme'] = strtolower($parts['scheme']);
+ $parts['host'] = strtolower($parts['host']);
+
+ //http://openid.net/specs/openid-authentication-2_0.html#normalization
+ return $parts['scheme'] . '://'
+ . (isset($parts['user']) ? $parts['user'] : '')
+ . (isset($parts['pass']) ? ':' . $parts['pass'] : '')
+ . (isset($parts['user']) || isset($parts['pass']) ? '@' : '')
+ . $parts['host']
+ . (
+ (isset($parts['port'])
+ && $parts['scheme'] === 'http' && $parts['port'] != 80)
+ || (isset($parts['port'])
+ && $parts['scheme'] === 'https' && $parts['port'] != 443)
+ ? ':' . $parts['port'] : ''
+ )
+ . $parts['path']
+ . (isset($parts['query']) ? '?' . $parts['query'] : '');
+ //leave out fragment as requested by the spec
+ }
+
+ /**
+ * Grab the domain from the identifier.
+ *
+ * Extract the domain from the Email or OpenID.
+ *
+ * @param string $identifier A string of the email address or openid URL
+ *
+ * @return string A string of the domain to use
+ *
+ * @since Method available since Release 0.1.0
+ */
+ protected function domainGet($identifier)
+ {
+ if ($identifier === null) {
+ return null;
+ }
+
+ // What are we, email or openid? Split ourself up and get the
+ // important bit out.
+ if (filter_var($identifier, FILTER_VALIDATE_EMAIL)) {
+ $email = explode('@', $identifier);
+ return $email[1];
+ }
+
+ //OpenID
+ $url = parse_url($identifier);
+ $domain = $url['host'];
+ if (isset($url['port']) && $url['scheme'] === 'http'
+ && $url['port'] != 80
+ || isset($url['port']) && $url['scheme'] === 'https'
+ && $url['port'] != 443
+ ) {
+ $domain .= ':' . $url['port'];
+ }
+
+ return $domain;
+ }
+
+ /**
+ * Get the target to use.
+ *
+ * Get the SRV record, filtered by priority and weight. If our domain
+ * has no SRV records, fall back to Libravatar.org
+ *
+ * @param string $domain A string of the domain we extracted from the
+ * provided identifier with domainGet()
+ * @param boolean $https Whether or not to look for https records
+ *
+ * @return string The target URL.
+ *
+ * @since Method available since Release 0.1.0
+ */
+ protected function srvGet($domain, $https = false)
+ {
+
+ // Are we going secure? Set up a fallback too.
+ if (isset($https) && $https === true) {
+ $subdomain = '_avatars-sec._tcp.';
+ $fallback = 'seccdn.';
+ } else {
+ $subdomain = '_avatars._tcp.';
+ $fallback = 'cdn.';
+ }
+
+ // Lets try get us some records based on the choice of subdomain
+ // and the domain we had passed in.
+ $srv = dns_get_record($subdomain . $domain, DNS_SRV);
+
+ // Did we get anything? No?
+ if (count($srv) == 0) {
+ // Then let's try Libravatar.org.
+ return $fallback . 'libravatar.org';
+ }
+
+ // Sort by the priority. We must get the lowest.
+ usort($srv, array($this, 'comparePriority'));
+
+ $top = $srv[0];
+ $sum = 0;
+
+ // Try to adhere to RFC2782's weighting algorithm, page 3
+ // "arrange all SRV RRs (that have not been ordered yet) in any order,
+ // except that all those with weight 0 are placed at the beginning of
+ // the list."
+ shuffle($srv);
+ $srvs = array();
+ foreach ($srv as $s) {
+ if ($s['weight'] == 0) {
+ array_unshift($srvs, $s);
+ } else {
+ array_push($srvs, $s);
+ }
+ }
+
+ foreach ($srvs as $s) {
+ if ($s['pri'] == $top['pri']) {
+ // "Compute the sum of the weights of those RRs"
+ $sum += (int) $s['weight'];
+ // "and with each RR associate the running sum in the selected
+ // order."
+ $pri[$sum] = $s;
+ }
+ }
+
+ // "Then choose a uniform random number between 0 and the sum computed
+ // (inclusive)"
+ $random = rand(0, $sum);
+
+ // "and select the RR whose running sum value is the first in the selected
+ // order which is greater than or equal to the random number selected"
+ foreach ($pri as $k => $v) {
+ if ($k >= $random) {
+ return $v['target'];
+ }
+ }
+ }
+
+ /**
+ * Sorting function for record priorities.
+ *
+ * @param mixed $a A mixed value passed by usort()
+ * @param mixed $b A mixed value passed by usort()
+ *
+ * @return mixed The result of the comparison
+ *
+ * @since Method available since Release 0.1.0
+ */
+ protected function comparePriority($a, $b)
+ {
+ return $a['pri'] - $b['pri'];
+ }
+
+ /**
+ * Automatically set the https option depending on the current connection
+ * value.
+ *
+ * If the current connection is HTTPS, the https options is activated.
+ * If it is not HTTPS, the https option is deactivated.
+ *
+ * @return self
+ */
+ public function detectHttps()
+ {
+ $this->setHttps(
+ isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']
+ );
+
+ return $this;
+ }
+
+ /**
+ * Verify and cast the email address hashing algorithm to use.
+ *
+ * @param string $algorithm Algorithm to use, "sha256" or "md5".
+ *
+ * @return string Algorithm
+ *
+ * @throws InvalidArgumentException When an unsupported algorithm is given
+ */
+ protected function processAlgorithm($algorithm)
+ {
+ $algorithm = (string)$algorithm;
+ if ($algorithm !== 'md5' && $algorithm !== 'sha256') {
+ throw new InvalidArgumentException(
+ 'Only md5 and sha256 hashing supported'
+ );
+ }
+
+ return $algorithm;
+ }
+
+ /**
+ * Verify and cast the default URL to use when no avatar image can be found.
+ * If none is set, the libravatar logo is returned.
+ *
+ * @param string $url Full URL to use OR one of the following:
+ * - "404" - give a "404 File not found" instead of an image
+ * - "mm"
+ * - "identicon"
+ * - "monsterid"
+ * - "wavatar"
+ * - "retro"
+ *
+ * @return string Default URL
+ *
+ * @throws InvalidArgumentException When an invalid URL is given
+ */
+ protected function processDefault($url)
+ {
+ if ($url === null) {
+ return $url;
+ }
+
+ $url = (string)$url;
+
+ switch ($url) {
+ case '404':
+ case 'mm':
+ case 'identicon':
+ case 'monsterid':
+ case 'wavatar':
+ case 'retro':
+ break;
+ default:
+ $valid = filter_var($url, FILTER_VALIDATE_URL);
+ if (!$valid) {
+ throw new InvalidArgumentException('Invalid default avatar URL');
+ }
+ break;
+ }
+
+ return $url;
+ }
+
+ /**
+ * Verify and cast the required size of the images.
+ *
+ * @param integer $size Size (width and height in pixels) of the image.
+ * NULL for the default width.
+ *
+ * @return integer Size
+ *
+ * @throws InvalidArgumentException When a size <= 0 is given
+ */
+ protected function processSize($size)
+ {
+ if ($size === null) {
+ return $size;
+ }
+
+ $size = (int)$size;
+ if ($size <= 0) {
+ throw new InvalidArgumentException('Size has to be larger than 0');
+ }
+
+ return (int)$size;
+ }
+
+
+ /**
+ * Set the email address hashing algorithm to use.
+ * To keep gravatar compatibility, use "md5".
+ *
+ * @param string $algorithm Algorithm to use, "sha256" or "md5".
+ *
+ * @return self
+ * @throws InvalidArgumentException When an unsupported algorithm is given
+ */
+ public function setAlgorithm($algorithm)
+ {
+ $this->algorithm = $this->processAlgorithm($algorithm);
+
+ return $this;
+ }
+
+ /**
+ * Set the default URL to use when no avatar image can be found.
+ * If none is set, the gravatar logo is returned.
+ *
+ * @param string $url Full URL to use OR one of the following:
+ * - "404" - give a "404 File not found" instead of an image
+ * - "mm"
+ * - "identicon"
+ * - "monsterid"
+ * - "wavatar"
+ * - "retro"
+ *
+ * @return self
+ * @throws InvalidArgumentException When an invalid URL is given
+ */
+ public function setDefault($url)
+ {
+ $this->default = $this->processDefault($url);
+
+ return $this;
+ }
+
+ /**
+ * Set if HTTPS URLs shall be returned.
+ *
+ * @param boolean $useHttps If HTTPS url shall be returned
+ *
+ * @return self
+ *
+ * @see detectHttps()
+ */
+ public function setHttps($useHttps)
+ {
+ $this->https = (bool)$useHttps;
+
+ return $this;
+ }
+
+ /**
+ * Set the required size of the images.
+ * Every avatar image is square sized, which means you need to set only number.
+ *
+ * @param integer $size Size (width and height) of the image
+ *
+ * @return self
+ * @throws InvalidArgumentException When a size <= 0 is given
+ */
+ public function setSize($size)
+ {
+ $this->size = $this->processSize($size);
+
+ return $this;
+ }
+
+}
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * c-hanging-comment-ender-p: nil
+ * End:
+ */
+
+?>
diff --git a/libravatar/admin.tpl b/libravatar/admin.tpl
new file mode 100644
index 000000000..814f4a44a
--- /dev/null
+++ b/libravatar/admin.tpl
@@ -0,0 +1,2 @@
+{{ inc field_select.tpl with $field=$default_avatar}}{{ endinc }}
+
diff --git a/libravatar/libravatar.php b/libravatar/libravatar.php
new file mode 100644
index 000000000..08ed6d00b
--- /dev/null
+++ b/libravatar/libravatar.php
@@ -0,0 +1,114 @@
+= 5.3)
+ * Version: 1.1
+ * Author: Klaus Weidenbach
+ */
+
+/**
+ * Installs the plugin hook
+ */
+function libravatar_install() {
+ if (! version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ info(t('Could NOT install Libravatar successfully. It requires PHP >= 5.3') .EOL);
+ // avoid registering the hook
+ return false;
+ }
+ register_hook('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup');
+
+ logger("registered libravatar in avatar_lookup hook");
+}
+
+/**
+ * Removes the plugin hook
+ */
+function libravatar_uninstall() {
+ unregister_hook('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup');
+
+ logger("unregistered libravatar in avatar_lookup hook");
+}
+
+/**
+ * Looks up the avatar at Libravatar and returns the URL.
+ *
+ * @param $a array
+ * @param &$b array
+ */
+function libravatar_lookup($a, &$b) {
+ $default_avatar = get_config('libravatar', 'default_img');
+
+ if (! $default_avatar) {
+ // if not set, look up if there was one from the gravatar addon
+ $default_avatar = get_config('gravatar', 'default_img');
+ // setting default avatar if nothing configured
+ if (! $default_avatar)
+ $default_avatar = 'identicon'; // default image will be a random pattern
+ }
+
+ require_once 'Services/Libravatar.php';
+ $libravatar = new Services_Libravatar();
+ $libravatar->setSize($b['size']);
+ $libravatar->setDefault($default_avatar);
+ $avatar_url = $libravatar->getUrl($b['email']);
+
+ $b['url'] = $avatar_url;
+ $b['success'] = true;
+}
+
+/**
+ * Display admin settings for this addon
+ */
+function libravatar_plugin_admin (&$a, &$o) {
+ $t = file_get_contents( dirname(__file__)."/admin.tpl");
+
+ $default_avatar = get_config('libravatar', 'default_img');
+
+ // set default values for first configuration
+ if(! $default_avatar)
+ $default_avatar = 'identicon'; // pseudo-random geometric pattern based on email hash
+
+ // Available options for the select boxes
+ $default_avatars = array(
+ 'mm' => t('generic profile image'),
+ 'identicon' => t('random geometric pattern'),
+ 'monsterid' => t('monster face'),
+ 'wavatar' => t('computer generated face'),
+ 'retro' => t('retro arcade style face'),
+ );
+
+ // Show warning if PHP version is too old
+ if (! version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ $o = '
' .t('Warning') .'
';
+ $o .= sprintf(t('Your PHP version %s is lower than the required PHP >= 5.3.'), PHP_VERSION);
+ $o .= ' ' .t('This addon is not functional on your server.') .'
';
+ return;
+ }
+
+ // Libravatar falls back to gravatar, so show warning about gravatar addon if enabled
+ $r = q("SELECT * FROM `addon` WHERE `name` = '%s' and `installed` = 1",
+ dbesc('gravatar')
+ );
+ if (count($r)) {
+ $o = '
' .t('Information') .'
' .t('Gravatar addon is installed. Please disable the Gravatar addon. The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'
";
+ else
+ $params['caption'] = bbcode($body);
+ } else if (($link != '') and !$video) {
+ $params['type'] = "link";
+ $params['name'] = $title;
+ $params['url'] = $link;
+ //$params['description'] = bbcode($body);
+ $params['description'] = bbcode($b["body"]);
+ } else {
+ $params['type'] = "regular";
+ $params['title'] = $title;
+ $params['body'] = bbcode($b['body']);
+ }
$x = post_url($tmbl_blog,$params);
$ret_code = $a->get_curl_code();
@@ -187,7 +226,7 @@ function tumblr_send(&$a,&$b) {
elseif($ret_code == 403)
logger('tumblr_send: authentication failure');
else
- logger('tumblr_send: general error: ' . print_r($x,true));
+ logger('tumblr_send: general error: ' . print_r($x,true));
}
}
diff --git a/twitter.tgz b/twitter.tgz
index e011308e2..192d6f85d 100755
Binary files a/twitter.tgz and b/twitter.tgz differ
diff --git a/twitter/twitter.php b/twitter/twitter.php
index 0ac9396df..9984f3695 100755
--- a/twitter/twitter.php
+++ b/twitter/twitter.php
@@ -290,7 +290,7 @@ function twitter_post_hook(&$a,&$b) {
logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG);
require_once('library/twitteroauth.php');
- require_once('include/bbcode.php');
+ require_once('include/bbcode.php');
$tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
// in theory max char is 140 but T. uses t.co to make links
// longer so we give them 10 characters extra
@@ -316,18 +316,24 @@ function twitter_post_hook(&$a,&$b) {
$tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp);
$linksenabled = get_pconfig($b['uid'],'twitter','post_taglinks');
// if a #tag is linked, don't send the [url] over to SN
- // that is, don't send if the option is not set in the
+ // that is, don't send if the option is not set in the
// connector settings
if ($linksenabled=='0') {
- // #-tags
- $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
- // @-mentions
- $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+ // #-tags
+ $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
+ // @-mentions
+ $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+ // recycle 1
+ $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+ // recycle 2
+ //$recycle = html_entity_decode("♻ ", ENT_QUOTES, 'UTF-8');
+ //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp);
}
$tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
$tmp = preg_replace( '/\[bookmark\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/bookmark\]/i', '$2 $1', $tmp);
- // find all http or https links in the body of the entry and
- // apply the shortener if the link is longer then 20 characters
+ // find all http or https links in the body of the entry and
+ // apply the shortener if the link is longer then 20 characters
if (( strlen($tmp)>$max_char ) && ( $max_char > 0 )) {
preg_match_all ( '/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', $tmp, $allurls );
foreach ($allurls as $url) {
@@ -341,7 +347,7 @@ function twitter_post_hook(&$a,&$b) {
}
// ok, all the links we want to send out are save, now strip
// away the remaining bbcode
- $msg = strip_tags(bbcode($tmp));
+ $msg = strip_tags(bbcode($tmp, false, false));
// quotes not working - let's try this
$msg = html_entity_decode($msg);
if (( strlen($msg) > $max_char) && $max_char > 0) {
diff --git a/wppost.tgz b/wppost.tgz
index 21546b375..dc4338ac7 100755
Binary files a/wppost.tgz and b/wppost.tgz differ
diff --git a/wppost/wppost.php b/wppost/wppost.php
index ee9acb0d4..e8b6fc6d5 100755
--- a/wppost/wppost.php
+++ b/wppost/wppost.php
@@ -179,24 +179,26 @@ function wppost_send(&$a,&$b) {
require_once('include/bbcode.php');
require_once('include/html2plain.php');
+ $wptitle = trim($b['title']);
+
// If the title is empty then try to guess
- if ($b['title'] == '') {
+ if ($wptitle == '') {
// Take the description from the bookmark
if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches))
- $b['title'] = $matches[2];
+ $wptitle = $matches[2];
// If no bookmark is found then take the first line
- if ($b['title'] == '') {
+ if ($wptitle == '') {
$title = html2plain(bbcode($b['body']), 0, true);
$pos = strpos($title, "\n");
if (($pos == 0) or ($pos > 60))
$pos = 60;
- $b['title'] = substr($title, 0, $pos);
+ $wptitle = substr($title, 0, $pos);
}
}
- $title = '' . (($b['title']) ? $b['title'] : t('Post from Friendica')) . '';
+ $title = '' . (($wptitle) ? $wptitle : t('Post from Friendica')) . '';
$post = $title . bbcode($b['body']);
$wp_backlink = intval(get_pconfig($b['uid'],'wppost','backlink'));