*/
/**
- * Installing the Friendika/Facebook connector
+ * Installing the Friendica/Facebook connector
*
* 1. register an API key for your site from developer.facebook.com
- * a. We'd be very happy if you include "Friendika" in the application name
- * to increase name recognition. The Friendika icons are also present
+ * a. We'd be very happy if you include "Friendica" in the application name
+ * to increase name recognition. The Friendica icons are also present
* in the images directory and may be uploaded as a Facebook app icon.
- * Use images/friendika-16.jpg for the Icon and images/friendika-128.jpg for the Logo.
+ * Use images/friendica-16.jpg for the Icon and images/friendica-128.jpg for the Logo.
* b. The url should be your site URL with a trailing slash.
- * You may use http://portal.friendika.com/privacy as the privacy policy
- * URL unless your site has different requirements, and
- * http://portal.friendika.com as the Terms of Service URL unless
- * you have different requirements. (Friendika is a software application
- * and does not require Terms of Service, though your installation of it might).
+ * Friendica is a software application and does not require a Privacy Policy
+ * or Terms of Service, though your installation of it might. Facebook may require
+ * that you provide a Privacy Policy, which we find ironic.
* c. Set the following values in your .htconfig.php file
* $a->config['facebook']['appid'] = 'xxxxxxxxxxx';
* $a->config['facebook']['appsecret'] = 'xxxxxxxxxxxxxxx';
function fb_get_friends($uid) {
- $r = q("SELECT `id` FROM `user` WHERE `uid` = %d AND `account_expired` = 0 LIMIT 1",
+ $r = q("SELECT `uid` FROM `user` WHERE `uid` = %d AND `account_expired` = 0 LIMIT 1",
intval($uid)
);
if(! count($r))
else {
// create contact record
- $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `notify`, `poll`,
+ $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
`writable`, `blocked`, `readonly`, `pending` )
- VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
+ VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
intval($uid),
dbesc(datetime_convert()),
dbesc($jp->link),
+ dbesc(normalise_link($jp->link)),
dbesc(''),
dbesc(''),
dbesc($jp->id),
set_pconfig($uid,'facebook','private_wall',$private_wall);
+ set_pconfig($uid,'facebook','blocked_apps',escape_tags(trim($_POST['blocked_apps'])));
+
$linkvalue = ((x($_POST,'facebook_linking')) ? intval($_POST['facebook_linking']) : 0);
set_pconfig($uid,'facebook','no_linking', (($linkvalue) ? 0 : 1));
$o .= '<p>' . t('If you choose to link conversations and leave both of these boxes unchecked, your Facebook profile wall will be merged with your profile wall on this website and your privacy settings on this website will be used to determine who may see the conversations.') . '</p>';
+
+ $blocked_apps = get_pconfig(local_user(),'facebook','blocked_apps');
+
+ $o .= '<div><label id="blocked-apps-label" for="blocked-apps">' . t('Comma separated applications to ignore') . ' </label></div>';
+ $o .= '<div><textarea id="blocked-apps" name="blocked_apps" >' . htmlspecialchars($blocked_apps) . '</textarea></div>';
+
$o .= '<input type="submit" name="submit" value="' . t('Submit') . '" /></form></div>';
}
$toplevel = (($b['id'] == $b['parent']) ? true : false);
- if(strstr($b['postopts'],'facebook')) {
- $linking = ((get_pconfig($b['uid'],'facebook','no_linking')) ? 0 : 1);
+ $linking = ((get_pconfig($b['uid'],'facebook','no_linking')) ? 0 : 1);
- if((! $toplevel) && ($linking)) {
- $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($b['parent']),
- intval($b['uid'])
- );
- if(count($r) && substr($r[0]['uri'],0,4) === 'fb::')
- $reply = substr($r[0]['uri'],4);
- elseif(count($r) && substr($r[0]['extid'],0,4) === 'fb::')
- $reply = substr($r[0]['extid'],4);
- else
- return;
- logger('facebook reply id=' . $reply);
- }
+ if((! $toplevel) && ($linking)) {
+ $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($b['parent']),
+ intval($b['uid'])
+ );
+ if(count($r) && substr($r[0]['uri'],0,4) === 'fb::')
+ $reply = substr($r[0]['uri'],4);
+ elseif(count($r) && substr($r[0]['extid'],0,4) === 'fb::')
+ $reply = substr($r[0]['extid'],4);
+ else
+ return;
+ logger('facebook reply id=' . $reply);
+ }
+
+ if(strstr($b['postopts'],'facebook') || ($b['private']) || ($reply)) {
if($b['private'] && $reply === false) {
$allow_people = expand_acl($b['allow_cid']);
$msg = preg_replace("/\[img\](.*?)\[\/img\]/is", t('Image: ') . '$1', $msg);
if((strpos($link,z_root()) !== false) && (! $image))
- $image = $a->get_baseurl() . '/images/friendika-64.jpg';
+ $image = $a->get_baseurl() . '/images/friendica-64.jpg';
$msg = trim(strip_tags(bbcode($msg)));
$msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
else {
$url = 'https://graph.facebook.com/me/feed';
if($b['plink'])
- $postvars['actions'] = '{"name": "' . t('View on Friendika') . '", "link": "' . $b['plink'] . '"}';
+ $postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' . $b['plink'] . '"}';
}
logger('facebook: post to ' . $url);
else {
if(! $likes) {
$s = serialize(array('url' => $url, 'item' => $b['id'], 'post' => $postvars));
- q("INSERT INTO `queue` ( `network`, `cid`, `created`, `last`, `content`)
- VALUES ( '%s', %d, '%s', '%s', '%s') ",
- dbesc(NETWORK_FACEBOOK),
- intval($a->contact),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- dbesc($s)
- );
-
+ require_once('include/queue_fn.php');
+ add_to_queue($a->contact,NETWORK_FACEBOOK,$s);
notice( t('Facebook post failed. Queued for retry.') . EOL);
}
}
if((local_user()) && (local_user() == $b['uid'])) {
$fb_post = intval(get_pconfig(local_user(),'facebook','post'));
- $fb_enable = (($fb_post && x($_POST,'facebook_enable')) ? intval($_POST['facebook_enable']) : 0);
+ $fb_enable = (($fb_post && x($_REQUEST,'facebook_enable')) ? intval($_REQUEST['facebook_enable']) : 0);
// if API is used, default to the chosen settings
- if($_POST['api_source'] && intval(get_pconfig(local_user(),'facebook','post_by_default')))
+ if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'facebook','post_by_default')))
$fb_enable = 1;
if(! $fb_enable)
intval($uid)
);
+ $blocked_apps = get_pconfig($uid,'facebook','blocked_apps');
+ $blocked_apps_arr = explode(',',$blocked_apps);
$self_id = get_pconfig($uid,'facebook','self_id');
if(! count($j->data) || (! strlen($self_id)))
$datarray['app'] = strip_tags($entry->application->name);
else
$datarray['app'] = 'facebook';
+
+ $found_blocked = false;
+
+ if(count($blocked_apps_arr)) {
+ foreach($blocked_apps_arr as $bad_appl) {
+ if(strlen(trim($bad_appl)) && (stristr($datarray['app'],trim($bad_appl)))) {
+ $found_blocked = true;
+ }
+ }
+ }
+
+ if($found_blocked) {
+ logger('facebook: blocking application: ' . $datarray['app']);
+ continue;
+ }
+
$datarray['author-name'] = $from->name;
$datarray['author-link'] = 'http://facebook.com/profile.php?id=' . $from->id;
$datarray['author-avatar'] = 'https://graph.facebook.com/' . $from->id . '/picture';
$datarray['plink'] = $datarray['author-link'] . '&v=wall&story_fbid=' . substr($entry->id,strpos($entry->id,'_') + 1);
- $datarray['body'] = $entry->message;
- if($entry->picture)
- $datarray['body'] .= "\n\n" . '[img]' . $entry->picture . '[/img]';
- if($entry->link)
- $datarray['body'] .= "\n" . linkify($entry->link);
+ $datarray['body'] = escape_tags($entry->message);
+
+ if($entry->picture && $entry->link) {
+ $datarray['body'] .= "\n\n" . '[url=' . $entry->link . '][img]' . $entry->picture . '[/img][/url]';
+ }
+ else {
+ if($entry->picture)
+ $datarray['body'] .= "\n\n" . '[img]' . $entry->picture . '[/img]';
+ if($entry->link)
+ $datarray['body'] .= "\n" . '[url=' . $entry->link . ']' . t('link') . '[/url]';
+ }
if($entry->name)
$datarray['body'] .= "\n" . $entry->name;
if($entry->caption)