Browse Source

Replace and/AND and or/OR by && and ||

pull/415/head
Hypolite Petovan 5 years ago
parent
commit
8fa3f2415a
  1. 54
      appnet/appnet.php
  2. 10
      buffer/buffer.php
  3. 2
      buffer/bufferapp.php
  4. 2
      diaspora/diaspora.php
  5. 142
      facebook/facebook.php
  6. 56
      fbpost/fbpost.php
  7. 36
      fbsync/fbsync.php
  8. 16
      fromgplus/fromgplus.php
  9. 2
      geocoordinates/geocoordinates.php
  10. 8
      gpluspost/gpluspost.php
  11. 9
      ifttt/ifttt.php
  12. 4
      jappixmini/jappixmini.php
  13. 2
      leistungsschutzrecht/leistungsschutzrecht.php
  14. 44
      pumpio/pumpio.php
  15. 2
      pumpio/pumpio_sync.php
  16. 2
      rendertime/rendertime.php
  17. 4
      statistics_json/statistics_json.php
  18. 52
      statusnet/statusnet.php
  19. 8
      tumblr/tumblr.php
  20. 74
      twitter/twitter.php
  21. 2
      twitter/twitter_sync.php
  22. 2
      wppost/wppost.php
  23. 4
      xmpp/xmpp.php

54
appnet/appnet.php

@ -107,7 +107,7 @@ function appnet_connect(&$a) {
$clientId = get_config('appnet','clientid');
$clientSecret = get_config('appnet','clientsecret');
if (($clientId == "") OR ($clientSecret == "")) {
if (($clientId == "") || ($clientSecret == "")) {
$clientId = get_pconfig(local_user(),'appnet','clientid');
$clientSecret = get_pconfig(local_user(),'appnet','clientsecret');
}
@ -154,7 +154,7 @@ function appnet_settings(&$a,&$s) {
$app_clientId = get_config('appnet','clientid');
$app_clientSecret = get_config('appnet','clientsecret');
if (($app_clientId == "") OR ($app_clientSecret == "")) {
if (($app_clientId == "") || ($app_clientSecret == "")) {
$app_clientId = get_pconfig(local_user(),'appnet','clientid');
$app_clientSecret = get_pconfig(local_user(),'appnet','clientsecret');
}
@ -213,7 +213,7 @@ function appnet_settings(&$a,&$s) {
$s .= t("<p>Error fetching user profile. Please clear the configuration and try again.</p>");
}
} elseif (($app_clientId == '') OR ($app_clientSecret == '')) {
} elseif (($app_clientId == '') || ($app_clientSecret == '')) {
$s .= t("<p>You have two ways to connect to App.net.</p>");
$s .= "<hr />";
$s .= t('<p>First way: Register an application at <a href="https://account.app.net/developer/apps/">https://account.app.net/developer/apps/</a> and enter Client ID and Client Secret. ');
@ -245,7 +245,7 @@ function appnet_settings(&$a,&$s) {
$s .= '<a href="'.$url.'">'.t("Sign in using App.net").'</a>';
}
if (($app_clientId != '') OR ($app_clientSecret != '') OR ($token !='')) {
if (($app_clientId != '') || ($app_clientSecret != '') || ($token !='')) {
$s .= '<div id="appnet-disconnect-wrapper">';
$s .= '<label id="appnet-disconnect-label" for="appnet-disconnect">'. t('Clear OAuth configuration') .'</label>';
@ -278,7 +278,7 @@ function appnet_settings_post(&$a,&$b) {
if (isset($_POST["clientid"]))
set_pconfig(local_user(),'appnet','clientid', $_POST['clientid']);
if (isset($_POST["token"]) AND ($_POST["token"] != ""))
if (isset($_POST["token"]) && ($_POST["token"] != ""))
set_pconfig(local_user(),'appnet','token', $_POST['token']);
set_pconfig(local_user(), 'appnet', 'post', intval($_POST['appnet']));
@ -375,12 +375,12 @@ function appnet_create_entities($a, $b, $postdata) {
$start = $pos + 1;
}
if (isset($postdata["url"]) AND isset($postdata["title"]) AND ($postdata["type"] != "photo")) {
if (isset($postdata["url"]) && isset($postdata["title"]) && ($postdata["type"] != "photo")) {
$postdata["title"] = shortenmsg($postdata["title"], 90);
$max = 256 - strlen($postdata["title"]);
$text = shortenmsg($text, $max);
$text .= "\n[".$postdata["title"]."](".$postdata["url"].")";
} elseif (isset($postdata["url"]) AND ($postdata["type"] != "photo")) {
} elseif (isset($postdata["url"]) && ($postdata["type"] != "photo")) {
$postdata["url"] = short_link($postdata["url"]);
$max = 240;
$text = shortenmsg($text, $max);
@ -421,7 +421,7 @@ function appnet_send(&$a,&$b) {
logger("appnet_send: parameter ".print_r($b, true), LOGGER_DATA);
// Looking if its a reply to an app.net post
if ((substr($b["parent-uri"], 0, 5) != "adn::") AND (substr($b["extid"], 0, 5) != "adn::") AND (substr($b["thr-parent"], 0, 5) != "adn::")) {
if ((substr($b["parent-uri"], 0, 5) != "adn::") && (substr($b["extid"], 0, 5) != "adn::") && (substr($b["thr-parent"], 0, 5) != "adn::")) {
logger("appnet_send: no app.net post ".$b["parent"]);
return;
}
@ -443,18 +443,18 @@ function appnet_send(&$a,&$b) {
$nicknameplain = "@".$nicknameplain;
logger("appnet_send: comparing ".$nickname." and ".$nicknameplain." with ".$b["body"], LOGGER_DEBUG);
if ((strpos($b["body"], $nickname) === false) AND (strpos($b["body"], $nicknameplain) === false))
if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false))
$b["body"] = $nickname." ".$b["body"];
logger("appnet_send: parent found ".print_r($orig_post, true), LOGGER_DATA);
} else {
$iscomment = false;
if($b['private'] OR !strstr($b['postopts'],'appnet'))
if($b['private'] || !strstr($b['postopts'],'appnet'))
return;
}
if (($b['verb'] == ACTIVITY_POST) AND $b['deleted'])
if (($b['verb'] == ACTIVITY_POST) && $b['deleted'])
appnet_action($a, $b["uid"], substr($orig_post["uri"], 5), "delete");
if($b['verb'] == ACTIVITY_LIKE) {
@ -542,7 +542,7 @@ function appnet_send(&$a,&$b) {
"value" => $attached_data
);
if (isset($post["url"]) AND !isset($post["title"]) AND ($post["type"] != "photo")) {
if (isset($post["url"]) && !isset($post["title"]) && ($post["type"] != "photo")) {
$display_url = str_replace(array("http://www.", "https://www."), array("", ""), $post["url"]);
$display_url = str_replace(array("http://", "https://"), array("", ""), $display_url);
@ -725,7 +725,7 @@ function appnet_fetchstream($a, $uid) {
$lastid = $post["id"];
if (($item != 0) AND ($postarray['contact-id'] != $me["id"]) AND !function_exists("check_item_notification")) {
if (($item != 0) && ($postarray['contact-id'] != $me["id"]) && !function_exists("check_item_notification")) {
$r = q("SELECT `thread`.`iid` AS `parent` FROM `thread`
INNER JOIN `item` ON `thread`.`iid` = `item`.`parent` AND `thread`.`uid` = `item`.`uid`
WHERE `item`.`id` = %d AND `thread`.`mention` LIMIT 1", dbesc($item));
@ -788,7 +788,7 @@ function appnet_fetchstream($a, $uid) {
$parent_id = 0;
logger('appnet_fetchstream: User '.$uid.' posted mention item '.$item);
if ($item AND function_exists("check_item_notification"))
if ($item && function_exists("check_item_notification"))
check_item_notification($item, $uid, NOTIFY_TAGSELF);
} else {
@ -797,7 +797,7 @@ function appnet_fetchstream($a, $uid) {
}
// Fetch the parent and id
if (($parent_id == 0) AND ($postarray['uri'] != "")) {
if (($parent_id == 0) && ($postarray['uri'] != "")) {
$r = q("SELECT `id`, `parent` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($postarray['uri']),
intval($uid)
@ -811,8 +811,8 @@ function appnet_fetchstream($a, $uid) {
$lastid = $post["id"];
//if (($item != 0) AND ($postarray['contact-id'] != $me["id"])) {
if (($item != 0) AND !function_exists("check_item_notification")) {
//if (($item != 0) && ($postarray['contact-id'] != $me["id"])) {
if (($item != 0) && !function_exists("check_item_notification")) {
require_once('include/enotify.php');
notification(array(
'type' => NOTIFY_TAGSELF,
@ -886,7 +886,7 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
return($r[0]);
}
if (isset($post["reply_to"]) AND ($post["reply_to"] != "")) {
if (isset($post["reply_to"]) && ($post["reply_to"] != "")) {
$postarray['thr-parent'] = "adn::".$post["reply_to"];
// Complete the thread (if the parent doesn't exists)
@ -937,7 +937,7 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
$postarray['object-type'] = ACTIVITY_OBJ_NOTE;
}
if (($post["user"]["id"] != $ownid) OR ($postarray['thr-parent'] == $postarray['uri'])) {
if (($post["user"]["id"] != $ownid) || ($postarray['thr-parent'] == $postarray['uri'])) {
$postarray['owner-name'] = $post["user"]["name"];
$postarray['owner-link'] = $post["user"]["canonical_url"];
$postarray['owner-avatar'] = $post["user"]["avatar_image"]["url"];
@ -1015,7 +1015,7 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
if (is_array($content["annotations"])) {
$photo = appnet_expand_annotations($a, $content["annotations"]);
if (($photo["large"] != "") AND ($photo["url"] != ""))
if (($photo["large"] != "") && ($photo["url"] != ""))
$page_info = "\n[url=".$photo["url"]."][img]".$photo["large"]."[/img][/url]";
elseif ($photo["url"] != "")
$page_info = "\n[img]".$photo["url"]."[/img]";
@ -1034,7 +1034,7 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
if (trim($page_info) != "") {
$removedlink = preg_replace("/\[url\=".$url."\](.*?)\[\/url\]/ism", '', $postarray['body']);
if (($removedlink == "") OR strstr($postarray['body'], $removedlink))
if (($removedlink == "") || strstr($postarray['body'], $removedlink))
$postarray['body'] = $removedlink;
}
}
@ -1075,7 +1075,7 @@ function appnet_expand_entities($a, $body, $entities) {
foreach ($entities["links"] AS $links) {
$url = "[url=".$links["url"]."]".$links["text"]."[/url]";
if (isset($links["amended_len"]) AND ($links["amended_len"] > $links["len"]))
if (isset($links["amended_len"]) && ($links["amended_len"] > $links["len"]))
$replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["amended_len"], "replace"=> $url);
else
$replace[$links["pos"]] = array("pos"=> $links["pos"], "len"=> $links["len"], "replace"=> $url);
@ -1100,7 +1100,7 @@ function appnet_expand_entities($a, $body, $entities) {
function appnet_expand_annotations($a, $annotations) {
$photo = array("url" => "", "large" => "");
foreach ($annotations AS $annotation) {
if (($annotation[type] == "net.app.core.oembed") AND
if (($annotation[type] == "net.app.core.oembed") &&
($annotation["value"]["type"] == "photo")) {
if ($annotation["value"]["url"] != "")
$photo["url"] = $annotation["value"]["url"];
@ -1108,7 +1108,7 @@ function appnet_expand_annotations($a, $annotations) {
if ($annotation["value"]["thumbnail_large_url"] != "")
$photo["large"] = $annotation["value"]["thumbnail_large_url"];
//if (($annotation["value"]["thumbnail_large_url"] != "") AND ($annotation["value"]["url"] != ""))
//if (($annotation["value"]["thumbnail_large_url"] != "") && ($annotation["value"]["url"] != ""))
// $embedded = "\n[url=".$annotation["value"]["url"]."][img]".$annotation["value"]["thumbnail_large_url"]."[/img][/url]";
//elseif ($annotation["value"]["url"] != "")
// $embedded = "\n[img]".$annotation["value"]["url"]."[/img]";
@ -1128,13 +1128,13 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
intval($uid), dbesc("adn::".$contact["id"]));
if(!count($r) AND !$create_user)
if(!count($r) && !$create_user)
return($me["id"]);
if ($contact["canonical_url"] == "")
return($me["id"]);
if (count($r) AND ($r[0]["readonly"] OR $r[0]["blocked"])) {
if (count($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
logger("appnet_fetchcontact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
return(-1);
}
@ -1278,7 +1278,7 @@ function appnet_prepare_body(&$a,&$b) {
$nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
$nicknameplain = "@".$nicknameplain;
if ((strpos($item["body"], $nickname) === false) AND (strpos($item["body"], $nicknameplain) === false))
if ((strpos($item["body"], $nickname) === false) && (strpos($item["body"], $nicknameplain) === false))
$item["body"] = $nickname." ".$item["body"];
}

10
buffer/buffer.php

@ -339,14 +339,14 @@ function buffer_send(&$a,&$b) {
// Seems like a bug to me
// Buffer doesn't add links to Twitter and App.net (but pictures)
//if ($includedlinks AND isset($post["url"]))
if (($profile->service == "twitter") AND isset($post["url"]) AND ($post["type"] != "photo"))
//if ($includedlinks && isset($post["url"]))
if (($profile->service == "twitter") && isset($post["url"]) && ($post["type"] != "photo"))
$post["text"] .= " ".$post["url"];
elseif (($profile->service == "appdotnet") AND isset($post["url"]) AND isset($post["title"]) AND ($post["type"] != "photo")) {
elseif (($profile->service == "appdotnet") && isset($post["url"]) && isset($post["title"]) && ($post["type"] != "photo")) {
$post["title"] = shortenmsg($post["title"], 90);
$post["text"] = shortenmsg($post["text"], $limit - (24 + strlen($post["title"])));
$post["text"] .= "\n[".$post["title"]."](".$post["url"].")";
} elseif (($profile->service == "appdotnet") AND isset($post["url"]) AND ($post["type"] != "photo"))
} elseif (($profile->service == "appdotnet") && isset($post["url"]) && ($post["type"] != "photo"))
$post["text"] .= " ".$post["url"];
elseif ($profile->service == "google")
$post["text"] .= html_entity_decode("&#x00A0;", ENT_QUOTES, 'UTF-8'); // Send a special blank to identify the post through the "fromgplus" addon
@ -363,7 +363,7 @@ function buffer_send(&$a,&$b) {
if (isset($post["description"]))
$message["media[description]"] = $post["description"];
if (isset($post["url"]) AND ($post["type"] != "photo"))
if (isset($post["url"]) && ($post["type"] != "photo"))
$message["media[link]"] = $post["url"];
if (isset($post["image"])) {

2
buffer/bufferapp.php

@ -85,7 +85,7 @@
if ($callback_url) $this->set_callback_url($callback_url);
if ($access_token) $this->access_token = $access_token;
if (isset($_GET['code']) AND $_GET['code']) {
if (isset($_GET['code']) && $_GET['code']) {
$this->code = $_GET['code'];
$this->create_access_token_url();
}

2
diaspora/diaspora.php

@ -142,7 +142,7 @@ function diaspora_settings(&$a,&$s) {
$aspects = false;
if ($handle AND $password) {
if ($handle && $password) {
$conn = new Diaspora_Connection($handle, $password);
$conn->logIn();
$aspects = $conn->getAspects();

142
facebook/facebook.php

@ -13,15 +13,15 @@
* Detailed instructions how to use this plugin can be found at
* https://github.com/friendica/friendica/wiki/How-to:-Friendica%E2%80%99s-Facebook-connector
*
* Vidoes and embeds will not be posted if there is no other content. Links
* and images will be converted to a format suitable for the Facebook API and
* long posts truncated - with a link to view the full post.
* Vidoes and embeds will not be posted if there is no other content. Links
* and images will be converted to a format suitable for the Facebook API and
* long posts truncated - with a link to view the full post.
*
* Facebook contacts will not be able to view private photos, as they are not able to
* authenticate to your site to establish identity. We will address this
* authenticate to your site to establish identity. We will address this
* in a future release.
*/
/** TODO
* - Implement a method for the administrator to delete all configuration data the plugin has created,
* e.g. the app_access_token
@ -260,7 +260,7 @@ function fb_get_friends_sync_parsecontact($uid, $contact) {
$contact->link = 'http://facebook.com/profile.php?id=' . $contact->id;
// If its a page then set the first name from the username
if (!$contact->first_name and $contact->username)
if (!$contact->first_name && $contact->username)
$contact->first_name = $contact->username;
// check if we already have a contact
@ -495,9 +495,9 @@ function facebook_post(&$a) {
}
info( t('Settings updated.') . EOL);
}
}
return;
return;
}
// Facebook settings form
@ -534,7 +534,7 @@ function facebook_content(&$a) {
$fb_limited = get_config('facebook','restrict');
$o = '';
$fb_installed = false;
if (get_pconfig(local_user(),'facebook','post')) {
$access_token = get_pconfig(local_user(),'facebook','access_token');
@ -546,7 +546,7 @@ function facebook_content(&$a) {
}
}
}
$appid = get_config('facebook','appid');
if(! $appid) {
@ -559,10 +559,10 @@ function facebook_content(&$a) {
$o .= '<h3>' . t('Facebook Connect') . '</h3>';
if(! $fb_installed) {
if(! $fb_installed) {
$o .= '<div id="facebook-enable-wrapper">';
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
. $a->get_baseurl() . '/facebook/' . $a->user['nickname'] . '&scope=publish_stream,read_stream,offline_access">' . t('Install Facebook connector for this account.') . '</a>';
$o .= '</div>';
}
@ -574,10 +574,10 @@ function facebook_content(&$a) {
$o .= '<div id="facebook-enable-wrapper">';
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
. $a->get_baseurl() . '/facebook/' . $a->user['nickname'] . '&scope=publish_stream,read_stream,offline_access">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '</a>';
$o .= '</div>';
$o .= '<div id="facebook-post-default-form">';
$o .= '<form action="facebook" method="post" >';
$post_by_default = get_pconfig(local_user(),'facebook','post_by_default');
@ -633,14 +633,14 @@ function facebook_content(&$a) {
function facebook_cron($a,$b) {
$last = get_config('facebook','last_poll');
$poll_interval = intval(get_config('facebook','poll_interval'));
if(! $poll_interval)
$poll_interval = FACEBOOK_DEFAULT_POLL_INTERVAL;
if($last) {
$next = $last + ($poll_interval * 60);
if($next > time())
if($next > time())
return;
}
@ -649,7 +649,7 @@ function facebook_cron($a,$b) {
// Find the FB users on this site and randomize in case one of them
// uses an obscene amount of memory. It may kill this queue run
// but hopefully we'll get a few others through on each run.
// but hopefully we'll get a few others through on each run.
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'facebook' AND `k` = 'post' AND `v` = '1' ORDER BY RAND() ");
if(count($r)) {
@ -668,7 +668,7 @@ function facebook_cron($a,$b) {
// check for new friends once a day
$last_friend_check = get_pconfig($rr['uid'],'facebook','friend_check');
if($last_friend_check)
if($last_friend_check)
$next_friend_check = $last_friend_check + 86400;
else
$next_friend_check = 0;
@ -679,14 +679,14 @@ function facebook_cron($a,$b) {
fb_consume_all($rr['uid']);
}
}
if (get_config('facebook', 'realtime_active') == 1) {
if (!facebook_check_realtime_active()) {
logger('facebook_cron: Facebook is not sending Real-Time Updates any more, although it is supposed to. Trying to fix it...', LOGGER_NORMAL);
facebook_subscription_add_users();
if (facebook_check_realtime_active())
if (facebook_check_realtime_active())
logger('facebook_cron: Successful', LOGGER_NORMAL);
else {
logger('facebook_cron: Failed', LOGGER_NORMAL);
@ -705,7 +705,7 @@ function facebook_cron($a,$b) {
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit'
);
set_config('facebook', 'realtime_err_mailsent', 1);
}
}
@ -714,7 +714,7 @@ function facebook_cron($a,$b) {
del_config('facebook', 'realtime_first_err');
}
}
set_config('facebook','last_poll', time());
}
@ -770,10 +770,10 @@ function facebook_plugin_admin(&$a, &$o){
$o .= '<label for="fb_poll_interval">' . sprintf(t('Polling Interval in minutes (minimum %1$s minutes)'), FACEBOOK_MIN_POLL_INTERVAL) . '</label><input name="poll_interval" id="fb_poll_interval" type="number" min="' . FACEBOOK_MIN_POLL_INTERVAL . '" value="' . $poll_interval . '"><br style="clear: both;">';
$o .= '<label for="fb_sync_comments">' . t('Synchronize comments (no comments on Facebook are missed, at the cost of increased system load)') . '</label><input name="sync_comments" id="fb_sync_comments" type="checkbox" ' . ($sync_comments ? 'checked' : '') . '><br style="clear: both;">';
$o .= '<input type="submit" name="fb_save_keys" value="' . t('Save') . '">';
if ($working_connection) {
$o .= '<h4>' . t('Real-Time Updates') . '</h4>';
$activated = facebook_check_realtime_active();
if ($activated) {
$o .= t('Real-Time Updates are activated.') . '<br><br>';
@ -790,7 +790,7 @@ function facebook_plugin_admin(&$a, &$o){
function facebook_plugin_admin_post(&$a){
check_form_security_token_redirectOnErr('/admin/plugins/facebook', 'fbsave');
if (x($_REQUEST,'fb_save_keys')) {
set_config('facebook', 'appid', $_REQUEST['appid']);
set_config('facebook', 'appsecret', $_REQUEST['appsecret']);
@ -821,8 +821,8 @@ function facebook_jot_nets(&$a,&$b) {
if(intval($fb_post) == 1) {
$fb_defpost = get_pconfig(local_user(),'facebook','post_by_default');
$selected = ((intval($fb_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="facebook_enable"' . $selected . ' value="1" /> '
. t('Post to Facebook') . '</div>';
$b .= '<div class="profile-jot-net"><input type="checkbox" name="facebook_enable"' . $selected . ' value="1" /> '
. t('Post to Facebook') . '</div>';
}
}
@ -877,10 +877,10 @@ function facebook_post_hook(&$a,&$b) {
return;
// only accept comments from the item owner. Other contacts are unknown to FB.
if(! link_compare($b['author-link'], $a->get_baseurl() . '/profile/' . $u[0]['nickname']))
return;
logger('facebook reply id=' . $reply);
}
@ -898,7 +898,7 @@ function facebook_post_hook(&$a,&$b) {
$allow_str = dbesc(implode(', ',$recipients));
if($allow_str) {
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $allow_str ) AND `network` = 'face'");
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $allow_str ) AND `network` = 'face'");
if(count($r))
foreach($r as $rr)
$allow_arr[] = $rr['notify'];
@ -906,7 +906,7 @@ function facebook_post_hook(&$a,&$b) {
$deny_str = dbesc(implode(', ',$deny));
if($deny_str) {
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $deny_str ) AND `network` = 'face'");
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $deny_str ) AND `network` = 'face'");
if(count($r))
foreach($r as $rr)
$deny_arr[] = $rr['notify'];
@ -916,8 +916,8 @@ function facebook_post_hook(&$a,&$b) {
// One or more FB folks were denied access but nobody on FB was specifically allowed access.
// This might cause the post to be open to public on Facebook, but only to selected members
// on another network. Since this could potentially leak a post to somebody who was denied,
// we will skip posting it to Facebook with a slightly vague but relevant message that will
// on another network. Since this could potentially leak a post to somebody who was denied,
// we will skip posting it to Facebook with a slightly vague but relevant message that will
// hopefully lead somebody to this code comment for a better explanation of what went wrong.
notice( t('Post to Facebook cancelled because of multi-network access permission conflict.') . EOL);
@ -932,7 +932,7 @@ function facebook_post_hook(&$a,&$b) {
}
if($b['verb'] == ACTIVITY_LIKE)
$likes = true;
$likes = true;
$appid = get_config('facebook', 'appid' );
@ -945,9 +945,9 @@ function facebook_post_hook(&$a,&$b) {
$fb_token = get_pconfig($b['uid'],'facebook','access_token');
// post to facebook if it's a public post and we've ticked the 'post to Facebook' box,
// post to facebook if it's a public post and we've ticked the 'post to Facebook' box,
// or it's a private message with facebook participants
// or it's a reply or likes action to an existing facebook post
// or it's a reply or likes action to an existing facebook post
if($fb_token && ($toplevel || $b['private'] || $reply)) {
logger('facebook: able to post');
@ -979,7 +979,7 @@ function facebook_post_hook(&$a,&$b) {
}
}
// strip tag links to avoid link clutter, this really should be
// strip tag links to avoid link clutter, this really should be
// configurable because we're losing information
$msg = preg_replace("/\#\[url=(.*?)\](.*?)\[\/url\]/is",'#$2',$msg);
@ -1145,7 +1145,7 @@ function facebook_post_hook(&$a,&$b) {
if($reply) {
$url = 'https://graph.facebook.com/' . $reply . '/' . (($likes) ? 'likes' : 'comments');
} else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) {
} else if (($link != "") || ($image != "") || ($b['title'] == '') || (strlen($msg) < 500)) {
$url = 'https://graph.facebook.com/me/feed';
if($b['plink'])
$postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' . $b['plink'] . '"}';
@ -1281,7 +1281,7 @@ function fb_queue_hook(&$a,&$b) {
logger('facebook_queue: run');
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
intval($x['cid'])
);
@ -1379,7 +1379,7 @@ function fb_consume_all($uid) {
$access_token = get_pconfig($uid,'facebook','access_token');
if(! $access_token)
return;
if(! get_pconfig($uid,'facebook','no_wall')) {
$private_wall = intval(get_pconfig($uid,'facebook','private_wall'));
$s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
@ -1745,7 +1745,7 @@ function fb_consume_stream($uid,$j,$wall = false) {
}
}
}
if($found_blocked) {
logger('facebook: blocking application: ' . $datarray['app']);
continue;
@ -1760,19 +1760,19 @@ function fb_consume_stream($uid,$j,$wall = false) {
$datarray['body'] = (isset($entry->message) ? escape_tags($entry->message) : '');
if(isset($entry->name) and isset($entry->link))
if(isset($entry->name) && isset($entry->link))
$datarray['body'] .= "\n\n[bookmark=".$entry->link."]".$entry->name."[/bookmark]";
elseif (isset($entry->name))
$datarray['body'] .= "\n\n[b]" . $entry->name."[/b]";
if(isset($entry->caption)) {
if(!isset($entry->name) and isset($entry->link))
if(!isset($entry->name) && isset($entry->link))
$datarray['body'] .= "\n\n[bookmark=".$entry->link."]".$entry->caption."[/bookmark]";
else
$datarray['body'] .= "[i]" . $entry->caption."[/i]\n";
}
if(!isset($entry->caption) and !isset($entry->name)) {
if(!isset($entry->caption) && !isset($entry->name)) {
if (isset($entry->link))
$datarray['body'] .= "\n[url]".$entry->link."[/url]\n";
else
@ -1791,7 +1791,7 @@ function fb_consume_stream($uid,$j,$wall = false) {
$datarray['body'] .= "\n[quote]".$quote."[/quote]";
// Only import the picture when the message is no video
// oembed display a picture of the video as well
// oembed display a picture of the video as well
if ($entry->type != "video") {
if(isset($entry->picture) && isset($entry->link)) {
$datarray['body'] .= "\n" . '[url=' . $entry->link . '][img]'.$entry->picture.'[/img][/url]';
@ -1805,7 +1805,7 @@ function fb_consume_stream($uid,$j,$wall = false) {
}
}
if (($datarray['app'] == "Events") and isset($entry->actions))
if (($datarray['app'] == "Events") && isset($entry->actions))
foreach ($entry->actions as $action)
if ($action->name == "View")
$datarray['body'] .= " [url=".$action->link."]".$entry->story."[/url]";
@ -1815,7 +1815,7 @@ function fb_consume_stream($uid,$j,$wall = false) {
// $datarray['body'] = $entry->story;
// Adding the "story" text to see if there are useful data in it (testing)
//if (($datarray['app'] != "Events") and $entry->story)
//if (($datarray['app'] != "Events") && $entry->story)
// $datarray['body'] .= "\n".$entry->story;
if(trim($datarray['body']) == '') {
@ -1830,17 +1830,17 @@ function fb_consume_stream($uid,$j,$wall = false) {
if (isset($entry->actions))
foreach ($entry->actions as $action)
if (($action->name != "Comment") and ($action->name != "Like"))
if (($action->name != "Comment") && ($action->name != "Like"))
$datarray['body'] .= "[url=".$action->link."]".$action->name."[/url] &nbsp; ";
$datarray['body'] = trim($datarray['body']);
//if(($datarray['body'] != '') and ($uid == 1))
//if(($datarray['body'] != '') && ($uid == 1))
// $datarray['body'] .= "[noparse]".print_r($entry, true)."[/noparse]";
if (isset($entry->place)) {
if ($entry->place->name or $entry->place->location->street or
$entry->place->location->city or $entry->place->location->Denmark) {
if ($entry->place->name || $entry->place->location->street ||
$entry->place->location->city || $entry->place->location->Denmark) {
$datarray['coord'] = '';
if ($entry->place->name)
$datarray['coord'] .= $entry->place->name;
@ -1850,7 +1850,7 @@ function fb_consume_stream($uid,$j,$wall = false) {
$datarray['coord'] .= " ".$entry->place->location->city;
if ($entry->place->location->country)
$datarray['coord'] .= " ".$entry->place->location->country;
} else if ($entry->place->location->latitude and $entry->place->location->longitude)
} else if ($entry->place->location->latitude && $entry->place->location->longitude)
$datarray['coord'] = substr($entry->place->location->latitude, 0, 8)
.' '.substr($entry->place->location->longitude, 0, 8);
}
@ -1931,28 +1931,28 @@ function fb_consume_stream($uid,$j,$wall = false) {
* @return bool|string
*/
function fb_get_app_access_token() {
$acc_token = get_config('facebook','app_access_token');
if ($acc_token !== false) return $acc_token;
$appid = get_config('facebook','appid');
$appsecret = get_config('facebook', 'appsecret');
if ($appid === false || $appsecret === false) {
logger('fb_get_app_access_token: appid and/or appsecret not set', LOGGER_DEBUG);
return false;
}
logger('https://graph.facebook.com/oauth/access_token?client_id=' . $appid . '&client_secret=' . $appsecret . '&grant_type=client_credentials', LOGGER_DATA);
$x = fetch_url('https://graph.facebook.com/oauth/access_token?client_id=' . $appid . '&client_secret=' . $appsecret . '&grant_type=client_credentials');
if(strpos($x,'access_token=') !== false) {
logger('fb_get_app_access_token: returned access token: ' . $x, LOGGER_DATA);
$token = str_replace('access_token=', '', $x);
if(strpos($token,'&') !== false)
$token = substr($token,0,strpos($token,'&'));
if ($token == "") {
logger('fb_get_app_access_token: empty token: ' . $x, LOGGER_DEBUG);
return false;
@ -1968,10 +1968,10 @@ function fb_get_app_access_token() {
function facebook_subscription_del_users() {
$a = get_app();
$access_token = fb_get_app_access_token();
$url = "https://graph.facebook.com/" . get_config('facebook', 'appid' ) . "/subscriptions?access_token=" . $access_token;
facebook_delete_url($url);
if (!facebook_check_realtime_active()) del_config('facebook', 'realtime_active');
}
@ -1981,15 +1981,15 @@ function facebook_subscription_del_users() {
function facebook_subscription_add_users($second_try = false) {
$a = get_app();
$access_token = fb_get_app_access_token();
$url = "https://graph.facebook.com/" . get_config('facebook', 'appid' ) . "/subscriptions?access_token=" . $access_token;
list($usec, $sec) = explode(" ", microtime());
$verify_token = sha1($usec . $sec . rand(0, 999999999));
set_config('facebook', 'cb_verify_token', $verify_token);
$cb = $a->get_baseurl() . '/facebook/?realtime_cb=1';
$j = post_url($url,array(
"object" => "user",
"fields" => "feed,friends",
@ -1997,7 +1997,7 @@ function facebook_subscription_add_users($second_try = false) {
"verify_token" => $verify_token,
));
del_config('facebook', 'cb_verify_token');
if ($j) {
$x = json_decode($j);
logger("Facebook reponse: " . $j, LOGGER_DATA);
@ -2018,10 +2018,10 @@ function facebook_subscription_add_users($second_try = false) {
* @return null|array
*/
function facebook_subscriptions_get() {
$access_token = fb_get_app_access_token();
if (!$access_token) return null;
$url = "https://graph.facebook.com/" . get_config('facebook', 'appid' ) . "/subscriptions?access_token=" . $access_token;
$j = fetch_url($url);
$ret = null;
@ -2059,7 +2059,7 @@ if(! function_exists('facebook_delete_url')) {
function facebook_delete_url($url,$headers = null, &$redirects = 0, $timeout = 0) {
$a = get_app();
$ch = curl_init($url);
if(($redirects > 8) || (! $ch))
if(($redirects > 8) || (! $ch))
return false;
curl_setopt($ch, CURLOPT_HEADER, true);

56
fbpost/fbpost.php

@ -412,7 +412,7 @@ function fbpost_jot_nets(&$a,&$b) {
if(intval($fb_post) == 1) {
$fb_defpost = get_pconfig(local_user(),'facebook','post_by_default');
$selected = ((intval($fb_defpost) == 1) ? ' checked="checked" ' : '');
$b .= '<div class="profile-jot-net"><input type="checkbox" name="facebook_enable"' . $selected . ' value="1" /> '
$b .= '<div class="profile-jot-net"><input type="checkbox" name="facebook_enable"' . $selected . ' value="1" /> '
. t('Post to Facebook') . '</div>';
}
}
@ -435,7 +435,7 @@ function fbpost_post_hook(&$a,&$b) {
if($b['extid'] == NETWORK_FACEBOOK)
return;
if(($b['app'] == "Facebook") AND ($b['verb'] != ACTIVITY_LIKE))
if(($b['app'] == "Facebook") && ($b['verb'] != ACTIVITY_LIKE))
return;
logger('fbpost_post_hook: Facebook post accepted', LOGGER_DEBUG);
@ -473,7 +473,7 @@ function fbpost_post_hook(&$a,&$b) {
// A reply to a toplevel post is only allowed for "real" facebook posts
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::') AND ($r[0]['id'] != $r[0]['parent']))
elseif(count($r) && (substr($r[0]['extid'],0,4) === 'fb::') && ($r[0]['id'] != $r[0]['parent']))
$reply = substr($r[0]['extid'],4);
else
return;
@ -525,8 +525,8 @@ function fbpost_post_hook(&$a,&$b) {
// One or more FB folks were denied access but nobody on FB was specifically allowed access.
// This might cause the post to be open to public on Facebook, but only to selected members
// on another network. Since this could potentially leak a post to somebody who was denied,
// we will skip posting it to Facebook with a slightly vague but relevant message that will
// on another network. Since this could potentially leak a post to somebody who was denied,
// we will skip posting it to Facebook with a slightly vague but relevant message that will
// hopefully lead somebody to this code comment for a better explanation of what went wrong.
notice( t('Post to Facebook cancelled because of multi-network access permission conflict.') . EOL);
@ -647,14 +647,14 @@ function fbpost_post_hook(&$a,&$b) {
$post_to_page = get_pconfig($b['uid'],'facebook','post_to_page');
$page_access_token = get_pconfig($b['uid'],'facebook','page_access_token');
if ((intval($post_to_page) != 0) and ($page_access_token != ""))
if ((intval($post_to_page) != 0) && ($page_access_token != ""))
$target = $post_to_page;
else
$target = "me";
if($reply) {
$url = 'https://graph.facebook.com/' . $reply . '/' . (($likes) ? 'likes' : 'comments');
} else if (($video != "") or (($image == "") and ($link != ""))) {
} else if (($video != "") || (($image == "") && ($link != ""))) {
// If it is a link to a video or a link without a preview picture then post it as a link
if ($video != "")
$link = $video;
@ -667,7 +667,7 @@ function fbpost_post_hook(&$a,&$b) {
$postvars['message'] = $msg;
$url = 'https://graph.facebook.com/'.$target.'/links';
} else if (($link == "") and ($image != "")) {
} else if (($link == "") && ($image != "")) {
// If it is only an image without a page link then post this image as a photo
$postvars = array(
'access_token' => $fb_token,
@ -677,10 +677,10 @@ function fbpost_post_hook(&$a,&$b) {
$postvars['message'] = $msg;
$url = 'https://graph.facebook.com/'.$target.'/photos';
//} else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) {
//} else if (($link != "") || ($image != "") || ($b['title'] == '') || (strlen($msg) < 500)) {
} else {
$url = 'https://graph.facebook.com/'.$target.'/feed';
if (!get_pconfig($b['uid'],'facebook','suppress_view_on_friendica') and $b['plink'])
if (!get_pconfig($b['uid'],'facebook','suppress_view_on_friendica') && $b['plink'])
$postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' . $b['plink'] . '"}';
}
/* } else {
@ -694,7 +694,7 @@ function fbpost_post_hook(&$a,&$b) {
} */
// Post to page?
if (!$reply and ($target != "me") and $page_access_token)
if (!$reply && ($target != "me") && $page_access_token)
$postvars['access_token'] = $page_access_token;
logger('fbpost_post_hook: post to ' . $url);
@ -721,7 +721,7 @@ function fbpost_post_hook(&$a,&$b) {
// If it is a special kind of failure the post was receiced
// Although facebook said it wasn't received ...
if (!$likes AND (($retj->error->type != "OAuthException") OR ($retj->error->code != 2)) AND ($x <> "")) {
if (!$likes && (($retj->error->type != "OAuthException") || ($retj->error->code != 2)) && ($x <> "")) {
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid']));
if (count($r))
$a->contact = $r[0]["id"];
@ -830,7 +830,7 @@ function fbpost_queue_hook(&$a,&$b) {
logger('fbpost_queue_hook: run');
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
intval($x['cid'])
);
@ -873,7 +873,7 @@ function fbpost_queue_hook(&$a,&$b) {
// If it is a special kind of failure the post was receiced
// Although facebook said it wasn't received ...
$ret = json_decode($j);
if (($ret->error->type != "OAuthException") OR ($ret->error->code != 2) AND ($j <> ""))
if (($ret->error->type != "OAuthException") || ($ret->error->code != 2) && ($j <> ""))
update_queue_time($x['id']);
else
logger('fbpost_queue_hook: Not requeued, since it seems to be received');
@ -980,7 +980,7 @@ function fbpost_cleanpicture($url) {
$urldata = parse_url($url);
if (isset($urldata["query"])) {
parse_str($urldata["query"], $querydata);
if (isset($querydata["url"]) AND (get_photo_info($querydata["url"])))
if (isset($querydata["url"]) && (get_photo_info($querydata["url"])))
return($querydata["url"]);
}
return($url);
@ -1036,10 +1036,10 @@ function fbpost_fetchwall($a, $uid) {
elseif(!isset($item->privacy))
continue;
if (($post_to_page != $item->from->id) AND ((int)$post_to_page != 0))
if (($post_to_page != $item->from->id) && ((int)$post_to_page != 0))
continue;
if (!strstr($item->id, $item->from->id."_") AND isset($item->to) AND ((int)$post_to_page == 0))
if (!strstr($item->id, $item->from->id."_") && isset($item->to) && ((int)$post_to_page == 0))
continue;
$_SESSION["authenticated"] = true;
@ -1061,7 +1061,7 @@ function fbpost_fetchwall($a, $uid) {
$content = "";
$pagedata["type"] = "";
if(isset($item->name) and isset($item->link)) {
if(isset($item->name) && isset($item->link)) {
$item->link = original_url($item->link);
$oembed_data = oembed_fetch_url($item->link);
$pagedata["type"] = $oembed_data->type;
@ -1072,31 +1072,31 @@ function fbpost_fetchwall($a, $uid) {
// If a link is not only attached but also added in the body, look if it can be removed in the body.
$removedlink = trim(str_replace($item->link, "", $_REQUEST["body"]));
if (($removedlink == "") OR strstr($_REQUEST["body"], $removedlink))
if (($removedlink == "") || strstr($_REQUEST["body"], $removedlink))
$_REQUEST["body"] = $removedlink;
} elseif (isset($item->name))
$content .= "[b]".$item->name."[/b]";
$pagedata["text"] = "";
if(isset($item->description) and ($item->type != "photo"))
if(isset($item->description) && ($item->type != "photo"))
$pagedata["text"] = $item->description;
if(isset($item->caption) and ($item->type == "photo"))
if(isset($item->caption) && ($item->type == "photo"))
$pagedata["text"] = $item->caption;
// Only import the picture when the message is no video
// oembed display a picture of the video as well
//if ($item->type != "video") {
//if (($item->type != "video") and ($item->type != "photo")) {
if (($pagedata["type"] == "") OR ($pagedata["type"] == "link")) {
//if (($item->type != "video") && ($item->type != "photo")) {
if (($pagedata["type"] == "") || ($pagedata["type"] == "link")) {
$pagedata["type"] = $item->type;
if (isset($item->picture))
$pagedata["images"][0]["src"] = $item->picture;
if (($pagedata["type"] == "photo") AND isset($item->object_id)) {
if (($pagedata["type"] == "photo") && isset($item->object_id)) {
logger('fbpost_fetchwall: fetching fbid '.$item->object_id, LOGGER_DEBUG);
$url = "https://graph.facebook.com/".$item->object_id."?access_token=".$access_token;
$feed = fetch_url($url);
@ -1151,8 +1151,8 @@ function fbpost_fetchwall($a, $uid) {
}
if (isset($item->place)) {
if ($item->place->name or $item->place->location->street or
$item->place->location->city or $item->place->location->country) {
if ($item->place->name || $item->place->location->street ||
$item->place->location->city || $item->place->location->country) {
$_REQUEST["location"] = '';
if ($item->place->name)
$_REQUEST["location"] .= $item->place->name;
@ -1165,7 +1165,7 @@ function fbpost_fetchwall($a, $uid) {
$_REQUEST["location"] = trim($_REQUEST["location"]);
}
if ($item->place->location->latitude and $item->place->location->longitude)
if ($item->place->location->latitude && $item->place->location->longitude)
$_REQUEST["coord"] = substr($item->place->location->latitude, 0, 8)
.' '.substr($item->place->location->longitude, 0, 8);
}
@ -1210,7 +1210,7 @@ function fbpost_get_photo($uid,$link) {
function fpost_cleanpicture($image) {
if ((strpos($image, ".fbcdn.net/") OR strpos($image, "/fbcdn-photos-")) and (substr($image, -6) == "_s.jpg"))
if ((strpos($image, ".fbcdn.net/") || strpos($image, "/fbcdn-photos-")) && (substr($image, -6) == "_s.jpg"))
$image = substr($image, 0, -6)."_n.jpg";
$queryvar = fbpost_parse_query($image);

36
fbsync/fbsync.php

@ -42,7 +42,7 @@ function fbsync_follow($a, &$contact) {
logger("fbsync_follow: Check if contact is facebook contact. ".$contact["url"], LOGGER_DEBUG);
if (!strstr($contact["url"], "://www.facebook.com") AND !strstr($contact["url"], "://facebook.com") AND !strstr($contact["url"], "@facebook.com"))
if (!strstr($contact["url"], "://www.facebook.com") && !strstr($contact["url"], "://facebook.com") && !strstr($contact["url"], "@facebook.com"))
return;
// contact seems to be a facebook contact, so continue
@ -267,7 +267,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
$contact_id = 0;
if (($post->parent_post_id != "") AND ($post->actor_id == $post->source_id)) {
if (($post->parent_post_id != "") && ($post->actor_id == $post->source_id)) {
$pos = strpos($post->parent_post_id, "_");
if ($pos != 0) {
@ -279,7 +279,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
$postarray['contact-id'] = $contact_id;
if (array_key_exists("name", $userdata) AND ($userdata["name"] != "") AND !link_compare($userdata["link"], $postarray['author-link'])) {
if (array_key_exists("name", $userdata) && ($userdata["name"] != "") && !link_compare($userdata["link"], $postarray['author-link'])) {
$postarray['owner-name'] = $userdata["name"];
$postarray['owner-link'] = $userdata["link"];
$postarray['owner-avatar'] = $userdata["avatar"];
@ -303,7 +303,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
// Testing if we know the source or the actor
$contact_id = fbsync_fetch_contact($uid, $contacts[$post->source_id], false);
if (($contact_id == 0) and array_key_exists($post->actor_id, $contacts))
if (($contact_id == 0) && array_key_exists($post->actor_id, $contacts))
$contact_id = fbsync_fetch_contact($uid, $contacts[$post->actor_id], false);
// If we don't know anyone, we guess we should know the source. Could be the wrong decision
@ -316,7 +316,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
if ($contact_id == -1) {
logger('fbsync_createpost: Contact is blocked. Post not imported '.print_r($post, true), LOGGER_DEBUG);
return;
} elseif (($contact_id <= 0) AND !$create_user) {
} elseif (($contact_id <= 0) && !$create_user) {
logger('fbsync_createpost: No matching contact found. Post not imported '.print_r($post, true), LOGGER_DEBUG);
return;
} elseif ($contact_id == 0) {
@ -357,7 +357,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
$content = "";
$pagedata["type"] = "";
if (isset($post->attachment->name) and isset($post->attachment->href)) {
if (isset($post->attachment->name) && isset($post->attachment->href)) {
$post->attachment->href = original_url($post->attachment->href);
$oembed_data = oembed_fetch_url($post->attachment->href);
$pagedata["type"] = $oembed_data->type;
@ -371,23 +371,23 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
// If a link is not only attached but also added in the body, look if it can be removed in the body.
$removedlink = trim(str_replace($post->attachment->href, "", $postarray["body"]));
if (($removedlink == "") OR strstr($postarray["body"], $removedlink))
if (($removedlink == "") || strstr($postarray["body"], $removedlink))
$postarray["body"] = $removedlink;
} elseif (isset($post->attachment->name) AND ($post->attachment->name != ""))
} elseif (isset($post->attachment->name) && ($post->attachment->name != ""))
$content = "[b]" . $post->attachment->name."[/b]";
$pagedata["text"] = "";
if (isset($post->attachment->description) and ($post->attachment->fb_object_type != "photo"))
if (isset($post->attachment->description) && ($post->attachment->fb_object_type != "photo"))
$pagedata["text"] = $post->attachment->description;
if (isset($post->attachment->caption) and ($post->attachment->fb_object_type == "photo"))
if (isset($post->attachment->caption) && ($post->attachment->fb_object_type == "photo"))
$pagedata["text"] = $post->attachment->caption;
if ($pagedata["text"].$post->attachment->href.$content.$postarray["body"] == "")
return;
if (isset($post->attachment->media) AND (($pagedata["type"] == "") OR ($pagedata["type"] == "link"))) {
if (isset($post->attachment->media) && (($pagedata["type"] == "") || ($pagedata["type"] == "link"))) {
foreach ($post->attachment->media AS $media) {
if (isset($media->type))
@ -397,7 +397,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
$pagedata["images"][0]["src"] = $media->src;
if (isset($media->photo)) {
if (isset($media->photo->images) AND (count($media->photo->images) > 1))
if (isset($media->photo->images) && (count($media->photo->images) > 1))
$pagedata["images"][0]["src"] = $media->photo->images[1]->src;
if (isset($media->photo->fbid)) {
@ -415,7 +415,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
$pagedata["images"][0]["src"] = fbpost_cleanpicture($pagedata["images"][0]["src"]);
if (isset($media->href) AND ($pagedata["images"][0]["src"] != "") AND ($media->href != "")) {
if (isset($media->href) && ($pagedata["images"][0]["src"] != "") && ($media->href != "")) {
$media->href = original_url($media->href);
$pagedata["url"] = $media->href;
$content .= "\n".'[url='.$media->href.'][img]'.$pagedata["images"][0]["src"].'[/img][/url]';
@ -538,7 +538,7 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
}
// Is blocked? Then return
if ($r[0]["readonly"] OR $r[0]["blocked"]) {
if ($r[0]["readonly"] || $r[0]["blocked"]) {
logger("fbsync_createcomment: UID ".$uid." - Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
return;
}
@ -640,7 +640,7 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
foreach($myconv as $conv) {
// now if we find a match, it means we're in this conversation
if(!link_compare($conv['author-link'],$importer_url) AND !link_compare($conv['author-link'],$own_contact[0]["url"]))
if(!link_compare($conv['author-link'],$importer_url) && !link_compare($conv['author-link'],$own_contact[0]["url"]))
continue;
require_once('include/enotify.php');
@ -785,10 +785,10 @@ function fbsync_fetch_contact($uid, $contact, $create_user) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
intval($uid), dbesc("facebook::".$contact->id));
if(!count($r) AND !$create_user)
if(!count($r) && !$create_user)
return(0);
if (count($r) AND ($r[0]["readonly"] OR $r[0]["blocked"])) {
if (count($r) && ($r[0]["readonly"] || $r[0]["blocked"])) {
logger("fbsync_fetch_contact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
return(-1);
}
@ -970,7 +970,7 @@ function fbsync_fetchuser($a, $uid, $id) {
intval($uid), dbesc("facebook::".$id));
if (count($contact)) {
if (($contact[0]["readonly"] OR $contact[0]["blocked"])) {
if (($contact[0]["readonly"] || $contact[0]["blocked"])) {
logger("fbsync_fetchuser: Contact '".$contact[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
$user["contact-id"] = -1;
} else

16
fromgplus/fromgplus.php

@ -63,7 +63,7 @@ function fromgplus_addon_settings(&$a,&$s) {
$s .= '<input id="fromgplus-keywords" type="checkbox" name="fromgplus-keywords" value="1"'.$keywords_checked.' />';
$s .= '<div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="fromgplus-submit" name="fromgplus-submit"
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="fromgplus-submit" name="fromgplus-submit"
class="settings-submit" value="' . t('Save Settings') . '" /></div>';
$s .= '</div>';
@ -178,7 +178,7 @@ function fromgplus_post($a, $uid, $source, $body, $location, $coord, $id) {
$_REQUEST['location'] = $location;
$_REQUEST['coord'] = $coord;
if (($_REQUEST['title'] == "") AND ($_REQUEST['body'] == "")) {
if (($_REQUEST['title'] == "") && ($_REQUEST['body'] == "")) {
logger('fromgplus: empty post for user '.$uid." ".print_r($_REQUEST, true));
return;
}
@ -269,13 +269,13 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
else
$infoFull = array("0" => 0, "1" => 0);
if (($infoPreview[0] >= $infoFull[0]) AND ($infoPreview[1] >= $infoFull[1])) {
if (($infoPreview[0] >= $infoFull[0]) && ($infoPreview[1] >= $infoFull[1])) {
$temp = $cleaned["full"];
$cleaned["full"] = $cleaned["preview"];
$cleaned["preview"] = $temp;
}
if (($cleaned["full"] == $cleaned["preview"]) OR (($infoPreview[0] == $infoFull[0]) AND ($infoPreview[1] == $infoFull[1])))
if (($cleaned["full"] == $cleaned["preview"]) || (($infoPreview[0] == $infoFull[0]) && ($infoPreview[1] == $infoFull[1])))
$cleaned["preview"] = "";
if ($cleaned["full"] == "")
@ -338,7 +338,7 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
// Add Keywords to page link
$data = parseurl_getsiteinfo_cached($pagedata["url"], true);
if (isset($data["keywords"]) AND get_pconfig($uid, 'fromgplus', 'keywords')) {
if (isset($data["keywords"]) && get_pconfig($uid, 'fromgplus', 'keywords')) {
$pagedata["keywords"] = $data["keywords"];
}
break;
@ -366,7 +366,7 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
$pagedata["images"][1]["src"] = $images["preview"];
}
if (($attachment->displayName != "") AND (fromgplus_cleantext($attachment->displayName) != fromgplus_cleantext($displaytext))) {
if (($attachment->displayName != "") && (fromgplus_cleantext($attachment->displayName) != fromgplus_cleantext($displaytext))) {
$post .= fromgplus_html2bbcode($attachment->displayName)."\n";
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
}
@ -491,7 +491,7 @@ function fromgplus_fetch($a, $uid) {
if (isset($item->location->displayName))
$location = $item->location->displayName;
if (isset($item->location->position->latitude) AND
if (isset($item->location->position->latitude) &&
isset($item->location->position->longitude))
$coord = $item->location->position->latitude." ".$item->location->position->longitude;
@ -542,7 +542,7 @@ function fromgplus_fetch($a, $uid) {
if (isset($item->location->displayName))
$location = $item->location->displayName;
if (isset($item->location->position->latitude) AND
if (isset($item->location->position->latitude) &&
isset($item->location->position->longitude))
$coord = $item->location->position->latitude." ".$item->location->position->longitude;

2
geocoordinates/geocoordinates.php

@ -57,7 +57,7 @@ function geocoordinates_resolve_item(&$item) {
return;
}
if (($data->total_results == 0) OR (count($data->results) == 0)) {
if (($data->total_results == 0) || (count($data->results) == 0)) {
logger("No results found for coordinates ".$item["coord"], LOGGER_DEBUG);
return;
}

8
gpluspost/gpluspost.php

@ -98,7 +98,7 @@ function gpluspost_settings(&$a,&$s) {
if (gpluspost_nextscripts()) {
/*
// To-Do: Option to check the credentials if requested
if (($username != "") AND ($password != "")) {
if (($username != "") && ($password != "")) {
require_once("addon/gpluspost/postToGooglePlus.php");
$loginError = doConnectToGooglePlus2($username, $password);
if ($loginError)
@ -231,7 +231,7 @@ function gpluspost_send(&$a,&$b) {
return;
// if post comes from Google+ don't send it back
if (!get_pconfig($b["uid"],'gpluspost','no_loop_prevention') and (($b['app'] == "Google+") OR ($b["extid"] == NETWORK_GPLUS)))
if (!get_pconfig($b["uid"],'gpluspost','no_loop_prevention') && (($b['app'] == "Google+") || ($b["extid"] == NETWORK_GPLUS)))
return;
if (!gpluspost_nextscripts()) {
@ -331,7 +331,7 @@ function gpluspost_queue_hook(&$a,&$b) {
logger('gpluspost_queue: run');
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
intval($x['cid'])
);
@ -527,7 +527,7 @@ function gpluspost_feeditem($pid, $uid) {
else if ($image != "")
$msglink = $image;
if (($msglink == "") AND $skipwithoutlink)
if (($msglink == "") && $skipwithoutlink)
continue;
else if ($msglink == "")
$msglink = $item["plink"];

9
ifttt/ifttt.php

@ -132,7 +132,7 @@ function ifttt_post(&$a) {
if (isset($_REQUEST["url"]))
$item["url"] = trim($_REQUEST["url"]);
if ((substr($item["msg"], 0, 3) == "<<<") AND (substr($item["msg"], -3, 3) == ">>>"))
if ((substr($item["msg"], 0, 3) == "<<<") && (substr($item["msg"], -3, 3) == ">>>"))
$item["msg"] = substr($item["msg"], 3, -3);
ifttt_message($uid, $item);
@ -164,17 +164,16 @@ function ifttt_message($uid, $item) {
if ($item["type"] == "link") {
$data = query_page_info($item["link"]);
if (isset($item["title"]) AND (trim($item["title"]) != ""))
if (isset($item["title"]) && (trim($item["title"]) != ""))
$data["title"] = $item["title"];
if (isset($item["description"]) AND (trim($item["description"]) != ""))
if (isset($item["description"]) && (trim($item["description"]) != ""))
$data["text"] = $item["description"];
$_REQUEST["body"] .= add_page_info_data($data);
} elseif (($item["type"] == "photo") AND ($item["image"] != ""))
} elseif (($item["type"] == "photo") && ($item["image"] != ""))
$_REQUEST["body"] .= "\n\n[img]".$item["image"]."[/img]\n";
//print_r($_REQUEST);
item_post($a);
}
?>

4
jappixmini/jappixmini.php