$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');
}
$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');
}
$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. ');
$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>';
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']));
$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);
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;
}
$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) {
"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);
$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));
$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 {
}
// 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)
$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,
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)
$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"];
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]";
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;
}
}
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);
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"];
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]";
$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);
}
$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"];
}
// 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(" ", ENT_QUOTES, 'UTF-8'); // Send a special blank to identify the post through the "fromgplus" addon
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"])) {
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();
}
$aspects = false;
- if ($handle AND $password) {
+ if ($handle && $password) {
$conn = new Diaspora_Connection($handle, $password);
$conn->logIn();
$aspects = $conn->getAspects();
* 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
$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
}
info( t('Settings updated.') . EOL);
- }
+ }
- return;
+ return;
}
// Facebook settings form
$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');
}
}
}
-
+
$appid = get_config('facebook','appid');
if(! $appid) {
$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>';
}
$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');
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;
}
// 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)) {
// 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;
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);
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit'
);
-
+
set_config('facebook', 'realtime_err_mailsent', 1);
}
}
del_config('facebook', 'realtime_first_err');
}
}
-
+
set_config('facebook','last_poll', time());
}
$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>';
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']);
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>';
}
}
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);
}
$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'];
$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'];
// 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);
}
if($b['verb'] == ACTIVITY_LIKE)
- $likes = true;
+ $likes = true;
$appid = get_config('facebook', 'appid' );
$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');
}
}
- // 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);
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'] . '"}';
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'])
);
$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);
}
}
}
-
+
if($found_blocked) {
logger('facebook: blocking application: ' . $datarray['app']);
continue;
$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
$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]';
}
}
- 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]";
// $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']) == '') {
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] ";
$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;
$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);
}
* @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;
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');
}
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",
"verify_token" => $verify_token,
));
del_config('facebook', 'cb_verify_token');
-
+
if ($j) {
$x = json_decode($j);
logger("Facebook reponse: " . $j, LOGGER_DATA);
* @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;
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);
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>';
}
}
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);
// 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;
// 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);
$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;
$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,
$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 {
} */
// 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);
// 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"];
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'])
);
// 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');
$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);
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;
$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;
// 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);
}
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;
$_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);
}
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);
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
$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) {
$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"];
// 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
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) {
$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;
// 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))
$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)) {
$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]';
}
// 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;
}
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');
$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);
}
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
$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>';
$_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;
}
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"] == "")
// 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;
$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);
}
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;
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;
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;
}
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)
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()) {
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'])
);
else if ($image != "")
$msglink = $image;
- if (($msglink == "") AND $skipwithoutlink)
+ if (($msglink == "") && $skipwithoutlink)
continue;
else if ($msglink == "")
$msglink = $item["plink"];
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);
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);
}
-?>
if ($server == "")
$server = get_config("jappixmini", "default_server");
- if (($username == "") and get_config("jappixmini", "default_user"))
+ if (($username == "") && get_config("jappixmini", "default_user"))
$username = $a->user["nickname"];
$info_text = get_config("jappixmini", "infotext");
$activate = get_pconfig(local_user(),'jappixmini','activate');
$dontinsertchat = get_pconfig(local_user(), 'jappixmini','dontinsertchat');
- if (!$activate or $dontinsertchat) return;
+ if (!$activate || $dontinsertchat) return;
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/jappixmini/jappix/php/get.php?t=js&g=mini.xml"></script>'."\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/jappixmini/jappix/php/get.php?t=js&f=presence.js~caps.js~name.js~roster.js"></script>'."\r\n";
if (isset($attr["href"])) {
$urldata = parse_url($attr["href"]);
- if (isset($urldata["host"]) AND !isset($urldata["path"])) {
+ if (isset($urldata["host"]) && !isset($urldata["path"])) {
$cleanedurlpart = explode("%", $urldata["host"]);
$hostname = explode(".", $cleanedurlpart[0]);
$consumer_secret = get_pconfig(local_user(), 'pumpio','consumer_secret');
$hostname = get_pconfig(local_user(), 'pumpio','host');
- if ((($consumer_key == "") OR ($consumer_secret == "")) AND ($hostname != "")) {
+ if ((($consumer_key == "") || ($consumer_secret == "")) && ($hostname != "")) {
logger("pumpio_connect: register client");
$clientdata = pumpio_registerclient($a, $hostname);
set_pconfig(local_user(), 'pumpio','consumer_key', $clientdata->client_id);
logger("pumpio_connect: ckey: ".$consumer_key." csecrect: ".$consumer_secret, LOGGER_DEBUG);
}
- if (($consumer_key == "") OR ($consumer_secret == "")) {
+ if (($consumer_key == "") || ($consumer_secret == "")) {
logger("pumpio_connect: ".sprintf("Unable to register the client at the pump.io server '%s'.", $hostname));
$o .= sprintf(t("Unable to register the client at the pump.io server '%s'."), $hostname);
$s .= '<input id="pumpio-servername" type="text" name="pumpio_host" value="'.$servername.'" />';
$s .= '</div><div class="clear"></div>';
- if (($username != '') AND ($servername != '')) {
+ if (($username != '') && ($servername != '')) {
$oauth_token = get_pconfig(local_user(), "pumpio", "oauth_token");
$oauth_token_secret = get_pconfig(local_user(), "pumpio", "oauth_token_secret");
$s .= '<div id="pumpio-password-wrapper">';
- if (($oauth_token == "") OR ($oauth_token_secret == "")) {
+ if (($oauth_token == "") || ($oauth_token_secret == "")) {
$s .= '<div id="pumpio-authenticate-wrapper">';
$s .= '<a href="'.$a->get_baseurl().'/pumpio/connect">'.t("Authenticate your pump.io connection").'</a>';
$s .= '</div><div class="clear"></div>';
logger("pumpio_send: receiver ".print_r($receiver, true));
- if (!count($receiver) AND ($b['private'] OR !strstr($b['postopts'],'pumpio')))
+ if (!count($receiver) && ($b['private'] || !strstr($b['postopts'],'pumpio')))
return;
}
if($b['verb'] == ACTIVITY_DISLIKE)
return;
- if (($b['verb'] == ACTIVITY_POST) AND ($b['created'] !== $b['edited']) AND !$b['deleted'])
+ if (($b['verb'] == ACTIVITY_POST) && ($b['created'] !== $b['edited']) && !$b['deleted'])
pumpio_action($a, $b["uid"], $b["uri"], "update", $b["body"]);
- if (($b['verb'] == ACTIVITY_POST) AND $b['deleted'])
+ if (($b['verb'] == ACTIVITY_POST) && $b['deleted'])
pumpio_action($a, $b["uid"], $b["uri"], "delete");
if($b['deleted'] || ($b['created'] !== $b['edited']))
$inReplyTo = array("id" => $orig_post["uri"],
"objectType" => "note");
- if (($orig_post["object-type"] != "") AND (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA)))
+ if (($orig_post["object-type"] != "") && (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA)))
$inReplyTo["objectType"] = str_replace(NAMESPACE_ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
$params["object"] = array(
$post_id = $user->object->id;
logger('pumpio_send '.$username.': success '.$post_id);
- if($post_id AND $iscomment) {
+ if($post_id && $iscomment) {
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']);
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
dbesc($post_id),
$orig_post = $r[0];
- if ($orig_post["extid"] AND !strstr($orig_post["extid"], "/proxy/"))
+ if ($orig_post["extid"] && !strstr($orig_post["extid"], "/proxy/"))
$uri = $orig_post["extid"];
else
$uri = $orig_post["uri"];
- if (($orig_post["object-type"] != "") AND (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA)))
+ if (($orig_post["object-type"] != "") && (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA)))
$objectType = str_replace(NAMESPACE_ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
elseif (strstr($uri, "/api/comment/"))
$objectType = "comment";
if ($receiver->id == "http://activityschema.org/collection/public")
$public = true;
- if ($public AND !stristr($post->generator->displayName, $application_name)) {
+ if ($public && !stristr($post->generator->displayName, $application_name)) {
require_once('include/html2bbcode.php');
$_SESSION["authenticated"] = true;
require_once('include/items.php');
require_once('include/html2bbcode.php');
- if (($post->verb == "like") OR ($post->verb == "favorite"))
+ if (($post->verb == "like") || ($post->verb == "favorite"))
return pumpio_dolike($a, $uid, $self, $post, $own_id);
- if (($post->verb == "unlike") OR ($post->verb == "unfavorite"))
+ if (($post->verb == "unlike") || ($post->verb == "unfavorite"))
return pumpio_dounlike($a, $uid, $self, $post, $own_id);
if ($post->verb == "delete")
if ($post->verb == "share") {
if (!intval(get_config('system','wall-to-wall_share'))) {
- if (isset($post->object->author->displayName) AND ($post->object->author->displayName != ""))
+ if (isset($post->object->author->displayName) && ($post->object->author->displayName != ""))
$share_author = $post->object->author->displayName;
- elseif (isset($post->object->author->preferredUsername) AND ($post->object->author->preferredUsername != ""))
+ elseif (isset($post->object->author->preferredUsername) && ($post->object->author->preferredUsername != ""))
$share_author = $post->object->author->preferredUsername;
else
$share_author = $post->object->author->url;
$top_item = item_store($postarray);
$postarray["id"] = $top_item;
- if (($top_item == 0) AND ($post->verb == "update")) {
+ if (($top_item == 0) && ($post->verb == "update")) {
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s' , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
dbesc($postarray["title"]),
dbesc($postarray["body"]),
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_id))
+ if(!link_compare($conv['author-link'],$importer_url) && !link_compare($conv['author-link'],$own_id))
continue;
require_once('include/enotify.php');
logger('pumpio_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'])
);
$success = false;
- if ($oauth_token AND $oauth_token_secret AND
- $consumer_key AND $consumer_secret) {
+ if ($oauth_token && $oauth_token_secret &&
+ $consumer_key && $consumer_secret) {
$username = $user.'@'.$host;
logger('pumpio_queue: able to post for user '.$username);
if($success) {
$post_id = $user->object->id;
logger('pumpio_queue: send '.$username.': success '.$post_id);
- if($post_id AND $iscomment) {
+ if($post_id && $iscomment) {
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']);
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
dbesc($post_id),
use Friendica\App;
-if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
+if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
$directory = dirname($_SERVER["argv"][0]);
if (substr($directory, 0, 1) != "/")
$ignored_modules = array("fbrowser");
$ignored = in_array($a->module, $ignored_modules);
- if (is_site_admin() AND ($_GET["mode"] != "minimal") AND !$a->is_mobile AND !$a->is_tablet AND !$ignored) {
+ if (is_site_admin() && ($_GET["mode"] != "minimal") && !$a->is_mobile && !$a->is_tablet && !$ignored) {
$o = $o.'<div class="renderinfo">'.sprintf(t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s"),
round($a->performance["database"] - $a->performance["database_write"], 3),
round($a->performance["database_write"], 3),
$month = time() - (30 * 24 * 60 * 60);
foreach ($users AS $user) {
- if ((strtotime($user['login_date']) > $halfyear) OR
+ if ((strtotime($user['login_date']) > $halfyear) ||
(strtotime($user['lastitem_date']) > $halfyear))
++$active_users_halfyear;
- if ((strtotime($user['login_date']) > $month) OR
+ if ((strtotime($user['login_date']) > $month) ||
(strtotime($user['lastitem_date']) > $month))
++$active_users_monthly;
if(intval($statusnet_post) == 1) {
$statusnet_defpost = get_pconfig(local_user(),'statusnet','post_by_default');
$selected = ((intval($statusnet_defpost) == 1) ? ' checked="checked" ' : '');
- $b .= '<div class="profile-jot-net"><input type="checkbox" name="statusnet_enable"' . $selected . ' value="1" /> '
+ $b .= '<div class="profile-jot-net"><input type="checkbox" name="statusnet_enable"' . $selected . ' value="1" /> '
. t('Post to GNU Social') . '</div>';
}
}
$s .= '<label id="statusnet-disconnect-label" for="statusnet-disconnect">'. t('Clear OAuth configuration') .'</label>';
$s .= '<input id="statusnet-disconnect" type="checkbox" name="statusnet-disconnect" value="1" />';
$s .= '</div><div class="clear"></div>';
- $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
+ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
}
}
$s .= '</div><div class="clear"></div>';
// Looking if its a reply to a GNU Social post
$hostlength = strlen($hostname) + 2;
- if ((substr($b["parent-uri"], 0, $hostlength) != $hostname."::") AND (substr($b["extid"], 0, $hostlength) != $hostname."::")
- AND (substr($b["thr-parent"], 0, $hostlength) != $hostname."::")) {
+ if ((substr($b["parent-uri"], 0, $hostlength) != $hostname."::") && (substr($b["extid"], 0, $hostlength) != $hostname."::")
+ && (substr($b["thr-parent"], 0, $hostlength) != $hostname."::")) {
logger("statusnet_post_hook: no GNU Social post ".$b["parent"]);
return;
}
$nicknameplain = "@".$nick;
logger("statusnet_post_hook: 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("statusnet_post_hook: parent found ".print_r($orig_post, true), LOGGER_DEBUG);
} else {
$iscomment = false;
- if($b['private'] OR !strstr($b['postopts'],'statusnet'))
+ if($b['private'] || !strstr($b['postopts'],'statusnet'))
return;
}
- if (($b['verb'] == ACTIVITY_POST) AND $b['deleted'])
+ if (($b['verb'] == ACTIVITY_POST) && $b['deleted'])
statusnet_action($a, $b["uid"], substr($orig_post["uri"], $hostlength), "delete");
if($b['verb'] == ACTIVITY_LIKE) {
$msgarr = plaintext($a, $b, $max_char, true, 7);
$msg = $msgarr["text"];
- if (($msg == "") AND isset($msgarr["title"]))
+ if (($msg == "") && isset($msgarr["title"]))
$msg = shortenmsg($msgarr["title"], $max_char - 50);
$image = "";
- if (isset($msgarr["url"]) AND ($msgarr["type"] != "photo")) {
- if ((strlen($msgarr["url"]) > 20) AND
+ if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
+ if ((strlen($msgarr["url"]) > 20) &&
((strlen($msg." \n".$msgarr["url"]) > $max_char)))
$msg .= " \n".short_link($msgarr["url"]);
else
$msg .= " \n".$msgarr["url"];
- } elseif (isset($msgarr["image"]) AND ($msgarr["type"] != "video"))
+ } elseif (isset($msgarr["image"]) && ($msgarr["type"] != "video"))
$image = $msgarr["image"];
if ($image != "") {
$nickname = "@[url=".$orig_post["author-link"]."]".$nick."[/url]";
$nicknameplain = "@".$nick;
- 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"];
}
$msgarr = plaintext($a, $item, $max_char, true, 7);
$msg = $msgarr["text"];
- if (isset($msgarr["url"]) AND ($msgarr["type"] != "photo"))
+ if (isset($msgarr["url"]) && ($msgarr["type"] != "photo"))
$msg .= " ".$msgarr["url"];
if (isset($msgarr["image"]))
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1",
intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET));
- 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("statusnet_fetch_contact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
return(-1);
}
$postarray['owner-link'] = $post->user->statusnet_profile_url;
$postarray['owner-avatar'] = $post->user->profile_image_url;
}
- if(($contactid == 0) AND !$only_existing_contact)
+ if(($contactid == 0) && !$only_existing_contact)
$contactid = $self['id'];
elseif ($contactid <= 0)
return(array());
foreach($myconv as $conv) {
// now if we find a match, it means we're in this conversation
- if(!link_compare($conv['author-link'],$user[0]["url"]) AND !link_compare($conv['author-link'],$own_user[0]["url"]))
+ if(!link_compare($conv['author-link'],$user[0]["url"]) && !link_compare($conv['author-link'],$own_user[0]["url"]))
continue;
require_once('include/enotify.php');
$items = $connection->get('statuses/home_timeline', $parameters);
if (!is_array($items)) {
- if (is_object($items) AND isset($items->error))
+ if (is_object($items) && isset($items->error))
$errormsg = $items->error;
elseif (is_object($items))
$errormsg = print_r($items, true);
- elseif (is_string($items) OR is_float($items) OR is_int($items))
+ elseif (is_string($items) || is_float($items) || is_int($items))
$errormsg = $items;
else
$errormsg = "Unknown error";
logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted home timeline item '.$item);
- if ($item AND !function_exists("check_item_notification"))
+ if ($item && !function_exists("check_item_notification"))
statusnet_checknotification($a, $uid, $nick, $item, $postarray);
}
logger('statusnet_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item);
- if ($item AND function_exists("check_item_notification"))
+ if ($item && function_exists("check_item_notification"))
check_item_notification($item, $uid, NOTIFY_TAGSELF);
}
}
$parent_id = $r[0]['parent'];
}
- if (($item != 0) AND !function_exists("check_item_notification")) {
+ if (($item != 0) && !function_exists("check_item_notification")) {
require_once('include/enotify.php');
notification(array(
'type' => NOTIFY_TAGSELF,
logger('statusnet_complete_conversation: User '.$self["nick"].' posted home timeline item '.$item);
- if ($item AND !function_exists("check_item_notification"))
+ if ($item && !function_exists("check_item_notification"))
statusnet_checknotification($a, $uid, $nick, $item, $postarray);
}
}
$footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
$body = str_replace($search, $footerlink, $body);
- } elseif (($oembed_data->type == "photo") AND isset($oembed_data->url) AND !$dontincludemedia)
+ } elseif (($oembed_data->type == "photo") && isset($oembed_data->url) && !$dontincludemedia)
$body = str_replace($search, "[url=".$expanded_url."][img]".$oembed_data->url."[/img][/url]", $body);
elseif ($oembed_data->type != "link")
$body = str_replace($search, "[url=".$expanded_url."]".$expanded_url."[/url]", $body);
if ($footerurl != "")
$footer = add_page_info($footerurl);
- if (($footerlink != "") AND (trim($footer) != "")) {
+ if (($footerlink != "") && (trim($footer) != "")) {
$removedlink = trim(str_replace($footerlink, "", $body));
- if (($removedlink == "") OR strstr($body, $removedlink))
+ if (($removedlink == "") || strstr($body, $removedlink))
$body = $removedlink;
$body .= $footer;
// It'll need our Consumer Key and Secret as well as our Request Token and Secret
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $_SESSION['request_token'], $_SESSION['request_token_secret']);
- // Ok, let's get an Access Token. We'll need to pass along our oauth_verifier which was given to us in the URL.
+ // Ok, let's get an Access Token. We'll need to pass along our oauth_verifier which was given to us in the URL.
$access_token = $tum_oauth->getAccessToken($_REQUEST['oauth_verifier']);
// We're done with the Request Token and Secret so let's remove those.
$oauth_token_secret = get_pconfig(local_user(), "tumblr", "oauth_token_secret");
$s .= '<div id="tumblr-page-wrapper">';
- if (($oauth_token != "") and ($oauth_token_secret != "")) {
+ if (($oauth_token != "") && ($oauth_token_secret != "")) {
$page = get_pconfig(local_user(),'tumblr','page');
$consumer_key = get_config('tumblr','consumer_key');
if (!isset($siteinfo["type"]))
$siteinfo["type"] = "";
- if (($title == "") AND isset($siteinfo["title"]))
+ if (($title == "") && isset($siteinfo["title"]))
$title = $siteinfo["title"];
if (isset($siteinfo["text"]))
break;
}
- if (isset($params['caption']) AND (trim($title) != ""))
+ if (isset($params['caption']) && (trim($title) != ""))
$params['caption'] = '<h1>'.$title."</h1>".
"<p>".$params['caption']."</p>";
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-
+
/* Twitter Plugin for Friendica
*
* Author: Tobias Diekershoff
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"))
+ if (!strstr($contact["url"], "://twitter.com") && !strstr($contact["url"], "@twitter.com"))
return;
// contact seems to be a twitter contact, so continue
if(intval($tw_post) == 1) {
$tw_defpost = get_pconfig(local_user(),'twitter','post_by_default');
$selected = ((intval($tw_defpost) == 1) ? ' checked="checked" ' : '');
- $b .= '<div class="profile-jot-net"><input type="checkbox" name="twitter_enable"' . $selected . ' value="1" /> '
+ $b .= '<div class="profile-jot-net"><input type="checkbox" name="twitter_enable"' . $selected . ' value="1" /> '
. t('Post to Twitter') . '</div>';
}
}
$s .= '<label id="twitter-disconnect-label" for="twitter-disconnect">'. t('Clear OAuth configuration') .'</label>';
$s .= '<input id="twitter-disconnect" type="checkbox" name="twitter-disconnect" value="1" />';
$s .= '</div><div class="clear"></div>';
- $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
+ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
}
}
$s .= '</div><div class="clear"></div>';
logger("twitter_post_hook: parameter ".print_r($b, true), LOGGER_DATA);
// Looking if its a reply to a twitter post
- if ((substr($b["parent-uri"], 0, 9) != "twitter::") AND (substr($b["extid"], 0, 9) != "twitter::") AND (substr($b["thr-parent"], 0, 9) != "twitter::")) {
+ if ((substr($b["parent-uri"], 0, 9) != "twitter::") && (substr($b["extid"], 0, 9) != "twitter::") && (substr($b["thr-parent"], 0, 9) != "twitter::")) {
logger("twitter_post_hook: no twitter post ".$b["parent"]);
return;
}
$nicknameplain = "@".$nicknameplain;
logger("twitter_post_hook: 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("twitter_post_hook: parent found ".print_r($orig_post, true), LOGGER_DATA);
} else {
$iscomment = false;
- if($b['private'] OR !strstr($b['postopts'],'twitter'))
+ if($b['private'] || !strstr($b['postopts'],'twitter'))
return;
}
- if (($b['verb'] == ACTIVITY_POST) AND $b['deleted'])
+ if (($b['verb'] == ACTIVITY_POST) && $b['deleted'])
twitter_action($a, $b["uid"], substr($orig_post["uri"], 9), "delete");
if($b['verb'] == ACTIVITY_LIKE) {
$msgarr = plaintext($a, $b, $max_char, true, 8);
$msg = $msgarr["text"];
- if (($msg == "") AND isset($msgarr["title"]))
+ if (($msg == "") && isset($msgarr["title"]))
$msg = shortenmsg($msgarr["title"], $max_char - 50);
$image = "";
- if (isset($msgarr["url"]) AND ($msgarr["type"] != "photo"))
+ if (isset($msgarr["url"]) && ($msgarr["type"] != "photo"))
$msg .= "\n".$msgarr["url"];
- if (isset($msgarr["image"]) AND ($msgarr["type"] != "video"))
+ if (isset($msgarr["image"]) && ($msgarr["type"] != "video"))
$image = $msgarr["image"];
// and now tweet it :-)
- if(strlen($msg) and ($image != "")) {
+ if(strlen($msg) && ($image != "")) {
$img_str = fetch_url($image);
$tempfile = tempnam(get_temppath(), "cache");
if ($result->source)
set_config("twitter", "application_name", strip_tags($result->source));
- if ($result->errors OR $result->error) {
+ if ($result->errors || $result->error) {
logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
// Workaround: Remove the picture link so that the post can be reposted without it
}
}
- if(strlen($msg) and ($image == "")) {
+ if(strlen($msg) && ($image == "")) {
$url = 'statuses/update';
$post = array('status' => $msg);
$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"];
}
$msgarr = plaintext($a, $item, $max_char, true, 8);
$msg = $msgarr["text"];
- if (isset($msgarr["url"]) AND ($msgarr["type"] != "photo"))
+ if (isset($msgarr["url"]) && ($msgarr["type"] != "photo"))
$msg .= " ".$msgarr["url"];
if (isset($msgarr["image"]))
logger('twitter_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'])
);
$success = false;
- if ($ckey AND $csecret AND $otoken AND $osecret) {
+ if ($ckey && $csecret && $otoken && $osecret) {
logger('twitter_queue: able to post');
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
intval($uid), dbesc("twitter::".$contact->id_str));
- 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("twitter_fetch_contact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
return(-1);
}
$plain = str_replace($url->url, '', $plain);
- if ($url->url AND $url->expanded_url AND $url->display_url) {
+ if ($url->url && $url->expanded_url && $url->display_url) {
$expanded_url = original_url($url->expanded_url);
$oembed_data = oembed_fetch_url($expanded_url);
// Quickfix: Workaround for URL with "[" and "]" in it
- if (strpos($expanded_url, "[") OR strpos($expanded_url, "]"))
+ if (strpos($expanded_url, "[") || strpos($expanded_url, "]"))
$expanded_url = $url->url;
if ($type == "")
$body = str_replace($url->url, $footerlink, $body);
//} elseif (($oembed_data->type == "photo") AND isset($oembed_data->url) AND !$dontincludemedia) {
- } elseif (($oembed_data->type == "photo") AND isset($oembed_data->url)) {
+ } elseif (($oembed_data->type == "photo") && isset($oembed_data->url)) {
$body = str_replace($url->url,
"[url=".$expanded_url."][img]".$oembed_data->url."[/img][/url]",
$body);
if ($footerurl != "")
$footer = add_page_info($footerurl, false, $picture);
- if (($footerlink != "") AND (trim($footer) != "")) {
+ if (($footerlink != "") && (trim($footer) != "")) {
$removedlink = trim(str_replace($footerlink, "", $body));
- if (($removedlink == "") OR strstr($body, $removedlink))
+ if (($removedlink == "") || strstr($body, $removedlink))
$body = $removedlink;
$body .= $footer;
}
- if (($footer == "") AND ($picture != ""))
+ if (($footer == "") && ($picture != ""))
$body .= "\n\n[img]".$picture."[/img]\n";
- elseif (($footer == "") AND ($picture == ""))
+ elseif (($footer == "") && ($picture == ""))
$body = add_page_info_to_body($body);
if ($no_tags)
// When the post links to an external page, we only take one picture.
// We only do this when there is exactly one media.
- if ((count($post->entities->urls) > 0) AND (count($post->extended_entities->media) == 1)) {
+ if ((count($post->entities->urls) > 0) && (count($post->extended_entities->media) == 1)) {
$picture = "";
foreach($post->extended_entities->media AS $medium) {
if (isset($medium->media_url_https)) {
$bitrate = 0;
// We take the video with the highest bitrate
foreach ($medium->video_info->variants AS $variant) {
- if (($variant->content_type == "video/mp4") AND ($variant->bitrate >= $bitrate)) {
+ if (($variant->content_type == "video/mp4") && ($variant->bitrate >= $bitrate)) {
$media[$medium->url] = "\n[video]".$variant->url."[/video]";
$bitrate = $variant->bitrate;
}
$postarray['owner-avatar'] = twitter_fix_avatar($post->user->profile_image_url_https);
}
- if(($contactid == 0) AND !$only_existing_contact) {
+ if(($contactid == 0) && !$only_existing_contact) {
$contactid = $self['id'];
} elseif ($contactid <= 0) {
logger("Contact ID is zero or less than zero.", LOGGER_DEBUG);
$postarray = $retweet;
}
- if (is_object($post->quoted_status) AND !$noquote) {
+ if (is_object($post->quoted_status) && !$noquote) {
$quoted = twitter_createpost($a, $uid, $post->quoted_status, $self, false, false, true);
$postarray['body'] = $statustext;
foreach($myconv as $conv) {
// now if we find a match, it means we're in this conversation
- if(!link_compare($conv['author-link'],$user[0]["url"]) AND !link_compare($conv['author-link'],$own_user[0]["url"]))
+ if(!link_compare($conv['author-link'],$user[0]["url"]) && !link_compare($conv['author-link'],$own_user[0]["url"]))
continue;
require_once('include/enotify.php');
logger('twitter_fetchparentpost: User '.$self["nick"].' posted parent timeline item '.$item);
- if ($item AND !function_exists("check_item_notification"))
+ if ($item && !function_exists("check_item_notification"))
twitter_checknotification($a, $uid, $own_id, $item, $postarray);
}
}
logger('twitter_fetchhometimeline: User '.$self["nick"].' posted home timeline item '.$item);
- if ($item AND !function_exists("check_item_notification"))
+ if ($item && !function_exists("check_item_notification"))
twitter_checknotification($a, $uid, $own_id, $item, $postarray);
}
$item = item_store($postarray);
$postarray["id"] = $item;
- if ($item AND function_exists("check_item_notification"))
+ if ($item && function_exists("check_item_notification"))
check_item_notification($item, $uid, NOTIFY_TAGSELF);
- if (!isset($postarray["parent"]) OR ($postarray["parent"] == 0))
+ if (!isset($postarray["parent"]) || ($postarray["parent"] == 0))
$postarray["parent"] = $item;
logger('twitter_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item);
} else
$parent_id = $postarray['parent'];
- if (($item != 0) AND !function_exists("check_item_notification")) {
+ if (($item != 0) && !function_exists("check_item_notification")) {
require_once('include/enotify.php');
notification(array(
'type' => NOTIFY_TAGSELF,
use Friendica\App;
-if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
+if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
$directory = dirname($_SERVER["argv"][0]);
if (substr($directory, 0, 1) != "/")
$title = html2plain(bbcode($title, false, false), 0, true)."\n";
$pos = strpos($title, "\n");
$trailer = "";
- if (($pos == 0) or ($pos > 100)) {
+ if (($pos == 0) || ($pos > 100)) {
$pos = 100;
$trailer = "...";
}
$s .= '<div class="clear"></div>';
}
- if (!get_config("xmpp", "central_userbase") OR get_pconfig(local_user(),"xmpp","individual")) {
+ if (!get_config("xmpp", "central_userbase") || get_pconfig(local_user(),"xmpp","individual")) {
$s .= '<label id="xmpp-bosh-proxy-label" for="xmpp-bosh-proxy">'.t('Jabber BOSH host').'</label>';
$s .= ' <input id="xmpp-bosh-proxy" type="text" name="xmpp_bosh_proxy" value="'.$bosh_proxy.'" />';
$s .= '<div class="clear"></div>';
$a->page['htmlhead'] .= '<link type="text/css" rel="stylesheet" media="screen" href="addon/xmpp/converse/css/converse.css" />'."\n";
$a->page['htmlhead'] .= '<script src="addon/xmpp/converse/builds/converse.min.js"></script>'."\n";
- if (get_config("xmpp", "central_userbase") AND !get_pconfig(local_user(),"xmpp","individual")) {
+ if (get_config("xmpp", "central_userbase") && !get_pconfig(local_user(),"xmpp","individual")) {
$bosh_proxy = get_config("xmpp", "bosh_proxy");
$password = get_pconfig(local_user(), "xmpp", "password");