diff --git a/appnetpost/appnetpost.php b/appnetpost/appnetpost.php index f434f098..ca6d5d27 100644 --- a/appnetpost/appnetpost.php +++ b/appnetpost/appnetpost.php @@ -202,7 +202,7 @@ function appnetpost_original_url($url, $depth=1) { curl_setopt($ch, CURLOPT_NOBODY, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch,CURLOPT_USERAGENT,'Opera/9.64(Windows NT 5.1; U; de) Presto/2.1.1'); + curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'); $header = curl_exec($ch); $curl_info = @curl_getinfo($ch); diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index 9fc13c5e..4c271873 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -304,6 +304,9 @@ function fromgplus_handleattachments($item, $displaytext) { function fromgplus_fetch($a, $uid) { $maxfetch = 20; + // Special blank to identify postings from the googleplus connector + $blank = html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); + $account = get_pconfig($uid,'fromgplus','account'); $key = get_config('fromgplus','key'); @@ -330,6 +333,15 @@ function fromgplus_fetch($a, $uid) { $lastdate = strtotime($item->published); if ($item->access->description == "Public") + + // Loop prevention - ignore postings from HootSuite + if ($item->provider->title == "HootSuite") + continue; + + // Loop prevention through the special blank from the googleplus connector + if (strstr($item->object->content, $blank)) + continue; + switch($item->object->objectType) { case "note": $post = fromgplus_html2bbcode($item->object->content); @@ -343,9 +355,7 @@ function fromgplus_fetch($a, $uid) { else $location = ""; - // Loop prevention - should be made better - if ($item->provider->title != "HootSuite") - fromgplus_post($a, $uid, "Google+", $post, $location); + fromgplus_post($a, $uid, "Google+", $post, $location); //fromgplus_post($a, $uid, $item->provider->title, $post, $location); break; @@ -353,7 +363,7 @@ function fromgplus_fetch($a, $uid) { case "activity": $post = fromgplus_html2bbcode($item->annotation)."\n"; - if (intval(get_config('system','new_share'))) { + if (!intval(get_config('system','old_share'))) { $post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName). "' profile='".$item->object->actor->url. "' avatar='".$item->object->actor->image->url. @@ -379,9 +389,7 @@ function fromgplus_fetch($a, $uid) { else $location = ""; - // Loop prevention - should be made better - if ($item->provider->title != "HootSuite") - fromgplus_post($a, $uid, "Google+", $post, $location); + fromgplus_post($a, $uid, "Google+", $post, $location); //fromgplus_post($a, $uid, $item->provider->title, $post, $location); break; } diff --git a/gpluspost/gpluspost.php b/gpluspost/gpluspost.php index eb35cd33..08bb1423 100644 --- a/gpluspost/gpluspost.php +++ b/gpluspost/gpluspost.php @@ -220,7 +220,7 @@ function gpluspost_original_url($url, $depth=1) { curl_setopt($ch, CURLOPT_NOBODY, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch,CURLOPT_USERAGENT,'Opera/9.64(Windows NT 5.1; U; de) Presto/2.1.1'); + curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0'); $header = curl_exec($ch); $curl_info = @curl_getinfo($ch); diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 63f403c2..1f76c100 100755 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -484,7 +484,7 @@ function pumpio_send(&$a,&$b) { logger('pumpio_send '.$username.': success '.$post_id); if($post_id AND $iscomment) { logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']); - q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d LIMIT 1", + q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d", dbesc($post_id), intval($b['id']) ); @@ -925,7 +925,7 @@ function pumpio_get_contact($uid, $contact) { `name-date` = '%s', `uri-date` = '%s', `avatar-date` = '%s' - WHERE `id` = %d LIMIT 1 + WHERE `id` = %d ", dbesc($photos[0]), dbesc($photos[1]), @@ -952,8 +952,10 @@ function pumpio_get_contact($uid, $contact) { `micro` = '%s', `name-date` = '%s', `uri-date` = '%s', - `avatar-date` = '%s' - WHERE `id` = %d LIMIT 1 + `avatar-date` = '%s', + `name` = '%s', + `nick` = '%s' + WHERE `id` = %d ", dbesc($photos[0]), dbesc($photos[1]), @@ -961,6 +963,8 @@ function pumpio_get_contact($uid, $contact) { dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), + dbesc($contact->displayName), + dbesc($contact->preferredUsername), intval($r[0]['id']) ); } @@ -1129,10 +1133,17 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet } if ($post->verb == "share") { - $postarray['body'] = "[share author='".$post->object->author->displayName. - "' profile='".$post->object->author->url. - "' avatar='".$post->object->author->image->url. - "' link='".$post->links->self->href."']".$postarray['body']."[/share]"; + if (!intval(get_config('system','wall-to-wall_share'))) { + $postarray['body'] = "[share author='".$post->object->author->displayName. + "' profile='".$post->object->author->url. + "' avatar='".$post->object->author->image->url. + "' link='".$post->links->self->href."']".$postarray['body']."[/share]"; + } else { + // Let shares look like wall-to-wall posts + $postarray['author-name'] = $post->object->author->displayName; + $postarray['author-link'] = $post->object->author->url; + $postarray['author-avatar'] = $post->object->author->image->url; + } } if (trim($postarray['body']) == "") @@ -1350,7 +1361,7 @@ function pumpio_queue_hook(&$a,&$b) { logger('pumpio_queue: send '.$username.': success '.$post_id); if($post_id AND $iscomment) { logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']); - q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d LIMIT 1", + q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d", dbesc($post_id), intval($z['item']) ); diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 2c979540..66aa3bd5 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -548,7 +548,7 @@ function statusnet_shortenmsg($b, $max_char) { $msglink = $b["plink"]; // If the message is short enough then don't modify it. (if the link exists in the original message) - if ((strlen(trim($origmsg)) <= $max_char) AND (strpos($origmsg, $msglink) OR ($msglink == ""))) + if ((strlen(trim($origmsg)) <= $max_char) AND (($msglink == "") OR strpos($origmsg, $msglink))) return(array("msg"=>trim($origmsg), "image"=>"")); // If the message is short enough and contains a picture then post the picture as well diff --git a/twitter/twitter.css b/twitter/twitter.css index 3ff37cda..99ee0bef 100755 --- a/twitter/twitter.css +++ b/twitter/twitter.css @@ -24,6 +24,8 @@ #twitter-enable-label, #twitter-shortening-label, #twitter-mirror-label, +#twitter-import-label, +#twitter-create_user-label, #twitter-pin-label { float: left; width: 250px; diff --git a/twitter/twitter.php b/twitter/twitter.php index 1bee1bdf..b7bf77f0 100755 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -71,6 +71,7 @@ function twitter_install() { register_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets'); register_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron'); register_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook'); + register_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow'); logger("installed twitter"); } @@ -91,6 +92,45 @@ function twitter_uninstall() { } +function twitter_follow($a, &$contact) { + + logger("twitter_follow: Check if contact is twitter contact. ".$contact["url"], LOGGER_DEBUG); + + if (!strstr($contact["url"], "://twitter.com") AND !strstr($contact["url"], "@twitter.com")) + return; + + // contact seems to be a twitter contact, so continue + $nickname = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $contact["url"]); + $nickname = str_replace("@twitter.com", "", $nickname); + + $uid = $a->user["uid"]; + + $ckey = get_config('twitter', 'consumerkey'); + $csecret = get_config('twitter', 'consumersecret'); + $otoken = get_pconfig($uid, 'twitter', 'oauthtoken'); + $osecret = get_pconfig($uid, 'twitter', 'oauthsecret'); + + require_once("addon/twitter/codebird.php"); + + $cb = \Codebird\Codebird::getInstance(); + $cb->setConsumerKey($ckey, $csecret); + $cb->setToken($otoken, $osecret); + + $parameters = array(); + $parameters["screen_name"] = $nickname; + + $user = $cb->friendships_create($parameters); + + twitter_fetchuser($a, $uid, $nickname); + + $r = q("SELECT name,nick,url,addr,batch,notify,poll,request,confirm,poco,photo,priority,network,alias,pubkey + FROM `contact` WHERE `uid` = %d AND `nick` = '%s'", + intval($uid), + dbesc($nickname)); + if (count($r)) + $contact["contact"] = $r[0]; +} + function twitter_jot_nets(&$a,&$b) { if(! local_user()) return; @@ -107,9 +147,10 @@ function twitter_jot_nets(&$a,&$b) { function twitter_settings_post ($a,$post) { if(! local_user()) return; - // don't check twitter settings if twitter submit button is not clicked - if (!x($_POST,'twitter-submit')) return; - + // don't check twitter settings if twitter submit button is not clicked + if (!x($_POST,'twitter-submit')) + return; + if (isset($_POST['twitter-disconnect'])) { /*** * if the twitter-disconnect checkbox is set, clear the OAuth key/secret pair @@ -125,6 +166,8 @@ function twitter_settings_post ($a,$post) { del_pconfig(local_user(), 'twitter', 'lastid'); del_pconfig(local_user(), 'twitter', 'mirror_posts'); del_pconfig(local_user(), 'twitter', 'intelligent_shortening'); + del_pconfig(local_user(), 'twitter', 'import'); + del_pconfig(local_user(), 'twitter', 'create_user'); } else { if (isset($_POST['twitter-pin'])) { // if the user supplied us with a PIN from Twitter, let the magic of OAuth happen @@ -152,6 +195,8 @@ function twitter_settings_post ($a,$post) { set_pconfig(local_user(),'twitter','post_taglinks',intval($_POST['twitter-sendtaglinks'])); set_pconfig(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror'])); set_pconfig(local_user(), 'twitter', 'intelligent_shortening', intval($_POST['twitter-shortening'])); + set_pconfig(local_user(), 'twitter', 'import', intval($_POST['twitter-import'])); + set_pconfig(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user'])); info( t('Twitter settings updated.') . EOL); }} } @@ -178,6 +223,10 @@ function twitter_settings(&$a,&$s) { $mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : ''); $shorteningenabled = get_pconfig(local_user(),'twitter','intelligent_shortening'); $shorteningchecked = (($shorteningenabled) ? ' checked="checked" ' : ''); + $importenabled = get_pconfig(local_user(),'twitter','import'); + $importchecked = (($importenabled) ? ' checked="checked" ' : ''); + $create_userenabled = get_pconfig(local_user(),'twitter','create_user'); + $create_userchecked = (($create_userenabled) ? ' checked="checked" ' : ''); $s .= '