Browse Source

Replace AND and OR in PHP conditions by && and ||

tags/3.5.3
Hypolite Petovan 3 years ago
parent
commit
9c0d2c31e8
83 changed files with 596 additions and 596 deletions
  1. +10
    -10
      boot.php
  2. +13
    -13
      include/Contact.php
  3. +6
    -6
      include/Photo.php
  4. +2
    -2
      include/acl_selectors.php
  5. +30
    -30
      include/api.php
  6. +1
    -1
      include/auth.php
  7. +18
    -18
      include/bbcode.php
  8. +5
    -5
      include/cache.php
  9. +1
    -1
      include/contact_selectors.php
  10. +1
    -1
      include/contact_widgets.php
  11. +3
    -3
      include/conversation.php
  12. +3
    -3
      include/cron.php
  13. +2
    -2
      include/cronhooks.php
  14. +11
    -11
      include/dba.php
  15. +2
    -2
      include/dba_pdo.php
  16. +2
    -2
      include/dbclean.php
  17. +1
    -1
      include/dbm.php
  18. +5
    -5
      include/dbstructure.php
  19. +3
    -3
      include/delivery.php
  20. +18
    -18
      include/dfrn.php
  21. +30
    -30
      include/diaspora.php
  22. +5
    -5
      include/discover_poco.php
  23. +6
    -6
      include/enotify.php
  24. +2
    -2
      include/follow.php
  25. +1
    -1
      include/gprobe.php
  26. +2
    -2
      include/group.php
  27. +1
    -1
      include/html2plain.php
  28. +6
    -6
      include/identity.php
  29. +29
    -29
      include/items.php
  30. +1
    -1
      include/nav.php
  31. +7
    -7
      include/network.php
  32. +5
    -5
      include/notifier.php
  33. +2
    -2
      include/oembed.php
  34. +2
    -2
      include/onepoll.php
  35. +39
    -39
      include/ostatus.php
  36. +1
    -1
      include/photos.php
  37. +1
    -1
      include/pidfile.php
  38. +15
    -15
      include/plaintext.php
  39. +1
    -1
      include/plugin.php
  40. +6
    -6
      include/poller.php
  41. +3
    -3
      include/post_update.php
  42. +2
    -2
      include/queue.php
  43. +1
    -1
      include/session.php
  44. +54
    -54
      include/socgraph.php
  45. +3
    -3
      include/spool_post.php
  46. +2
    -2
      include/tags.php
  47. +5
    -5
      include/text.php
  48. +4
    -4
      include/threads.php
  49. +4
    -4
      include/update_gcontact.php
  50. +6
    -6
      include/xml.php
  51. +7
    -7
      index.php
  52. +6
    -6
      mod/admin.php
  53. +2
    -2
      mod/community.php
  54. +6
    -6
      mod/contacts.php
  55. +4
    -4
      mod/dfrn_request.php
  56. +2
    -2
      mod/dirfind.php
  57. +4
    -4
      mod/display.php
  58. +1
    -1
      mod/events.php
  59. +1
    -1
      mod/fetch.php
  60. +2
    -2
      mod/follow.php
  61. +13
    -13
      mod/item.php
  62. +2
    -2
      mod/network.php
  63. +8
    -8
      mod/nodeinfo.php
  64. +2
    -2
      mod/noscrape.php
  65. +1
    -1
      mod/photo.php
  66. +6
    -6
      mod/ping.php
  67. +8
    -8
      mod/poco.php
  68. +13
    -13
      mod/proxy.php
  69. +1
    -1
      mod/register.php
  70. +3
    -3
      mod/search.php
  71. +5
    -5
      mod/settings.php
  72. +1
    -1
      mod/update_network.php
  73. +9
    -9
      object/Item.php
  74. +5
    -5
      src/App.php
  75. +2
    -2
      src/Core/Config.php
  76. +2
    -2
      src/Core/PConfig.php
  77. +82
    -82
      src/Network/Probe.php
  78. +5
    -5
      src/Util/Lock.php
  79. +1
    -1
      update.php
  80. +1
    -1
      util/maintenance.php
  81. +2
    -2
      view/theme/frio/php/frio_boot.php
  82. +1
    -1
      view/theme/vier/style.php
  83. +5
    -5
      view/theme/vier/theme.php

+ 10
- 10
boot.php View File

@@ -993,7 +993,7 @@ function notice($s) {
function info($s) {
$a = get_app();

if (local_user() AND get_pconfig(local_user(), 'system', 'ignore_info')) {
if (local_user() && get_pconfig(local_user(), 'system', 'ignore_info')) {
return;
}

@@ -1063,7 +1063,7 @@ function proc_run($cmd) {
$arr = array('args' => $args, 'run_cmd' => true);

call_hooks("proc_run", $arr);
if (!$arr['run_cmd'] OR ! count($args)) {
if (!$arr['run_cmd'] || ! count($args)) {
return;
}

@@ -1407,7 +1407,7 @@ function clear_cache($basepath = "", $path = "") {
$path = $basepath;
}

if (($path == "") OR (!is_dir($path))) {
if (($path == "") || (!is_dir($path))) {
return;
}

@@ -1444,7 +1444,7 @@ function get_itemcachepath() {
}

$itemcache = get_config('system', 'itemcache');
if (($itemcache != "") AND App::directory_usable($itemcache)) {
if (($itemcache != "") && App::directory_usable($itemcache)) {
return $itemcache;
}

@@ -1471,7 +1471,7 @@ function get_itemcachepath() {
*/
function get_spoolpath() {
$spoolpath = get_config('system', 'spoolpath');
if (($spoolpath != "") AND App::directory_usable($spoolpath)) {
if (($spoolpath != "") && App::directory_usable($spoolpath)) {
// We have a spool path and it is usable
return $spoolpath;
}
@@ -1506,7 +1506,7 @@ function get_temppath() {

$temppath = get_config("system", "temppath");

if (($temppath != "") AND App::directory_usable($temppath)) {
if (($temppath != "") && App::directory_usable($temppath)) {
// We have a temp path and it is usable
return $temppath;
}
@@ -1515,7 +1515,7 @@ function get_temppath() {
$temppath = sys_get_temp_dir();

// Check if it is usable
if (($temppath != "") AND App::directory_usable($temppath)) {
if (($temppath != "") && App::directory_usable($temppath)) {
// To avoid any interferences with other systems we create our own directory
$new_temppath = $temppath . "/" . $a->get_hostname();
if (!is_dir($new_temppath)) {
@@ -1638,7 +1638,7 @@ function argv($x) {
function infinite_scroll_data($module) {

if (get_pconfig(local_user(), 'system', 'infinite_scroll')
AND ($module == "network") AND ($_GET["mode"] != "minimal")) {
&& ($module == "network") && ($_GET["mode"] != "minimal")) {

// get the page number
if (is_string($_GET["page"])) {
@@ -1651,12 +1651,12 @@ function infinite_scroll_data($module) {

// try to get the uri from which we load the content
foreach ($_GET AS $param => $value) {
if (($param != "page") AND ($param != "q")) {
if (($param != "page") && ($param != "q")) {
$reload_uri .= "&" . $param . "=" . urlencode($value);
}
}

if (($a->page_offset != "") AND ! strstr($reload_uri, "&offset=")) {
if (($a->page_offset != "") && ! strstr($reload_uri, "&offset=")) {
$reload_uri .= "&offset=" . urlencode($a->page_offset);
}



+ 13
- 13
include/Contact.php View File

@@ -262,33 +262,33 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
$profile = $default;
}

if (($profile["photo"] == "") AND isset($default["photo"])) {
if (($profile["photo"] == "") && isset($default["photo"])) {
$profile["photo"] = $default["photo"];
}

if (($profile["name"] == "") AND isset($default["name"])) {
if (($profile["name"] == "") && isset($default["name"])) {
$profile["name"] = $default["name"];
}

if (($profile["network"] == "") AND isset($default["network"])) {
if (($profile["network"] == "") && isset($default["network"])) {
$profile["network"] = $default["network"];
}

if (($profile["thumb"] == "") AND isset($profile["photo"])) {
if (($profile["thumb"] == "") && isset($profile["photo"])) {
$profile["thumb"] = $profile["photo"];
}

if (($profile["micro"] == "") AND isset($profile["thumb"])) {
if (($profile["micro"] == "") && isset($profile["thumb"])) {
$profile["micro"] = $profile["thumb"];
}

if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND
if ((($profile["addr"] == "") || ($profile["name"] == "")) && ($profile["gid"] != 0) &&
in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
proc_run(PRIORITY_LOW, "include/update_gcontact.php", $profile["gid"]);
}

// Show contact details of Diaspora contacts only if connected
if (($profile["cid"] == 0) AND ($profile["network"] == NETWORK_DIASPORA)) {
if (($profile["cid"] == 0) && ($profile["network"] == NETWORK_DIASPORA)) {
$profile["location"] = "";
$profile["about"] = "";
$profile["gender"] = "";
@@ -559,7 +559,7 @@ function get_contact($url, $uid = 0, $no_update = false) {
// Update the contact every 7 days
$update_photo = ($contacts[0]['avatar-date'] < datetime_convert('','','now -7 days'));

if (!$update_photo OR $no_update) {
if (!$update_photo || $no_update) {
return $contact_id;
}
} elseif ($uid != 0) {
@@ -636,7 +636,7 @@ function get_contact($url, $uid = 0, $no_update = false) {
}
}

if (count($contacts) > 1 AND $uid == 0 AND $contact_id != 0 AND $url != "") {
if (count($contacts) > 1 && $uid == 0 && $contact_id != 0 && $url != "") {
q("DELETE FROM `contact` WHERE `nurl` = '%s' AND `id` != %d AND NOT `self`",
dbesc(normalise_link($url)),
intval($contact_id));
@@ -654,9 +654,9 @@ function get_contact($url, $uid = 0, $no_update = false) {
}

// Only update if there had something been changed
if ($data["addr"] != $contacts[0]["addr"] OR
$data["alias"] != $contacts[0]["alias"] OR
$data["name"] != $contacts[0]["name"] OR
if ($data["addr"] != $contacts[0]["addr"] ||
$data["alias"] != $contacts[0]["alias"] ||
$data["name"] != $contacts[0]["name"] ||
$data["nick"] != $contacts[0]["nick"]) {
q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s',
`name-date` = '%s', `uri-date` = '%s' WHERE `id` = %d",
@@ -769,7 +769,7 @@ function formatted_location($profile) {
if($profile['locality'])
$location .= $profile['locality'];

if($profile['region'] AND ($profile['locality'] != $profile['region'])) {
if($profile['region'] && ($profile['locality'] != $profile['region'])) {
if($location)
$location .= ', ';



+ 6
- 6
include/Photo.php View File

@@ -785,7 +785,7 @@ function update_contact_avatar($avatar, $uid, $cid, $force = false) {
$data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]);
}

if (($r[0]["avatar"] != $avatar) OR $force) {
if (($r[0]["avatar"] != $avatar) || $force) {
$photos = import_profile_photo($avatar, $uid, $cid, true);

if ($photos) {
@@ -825,7 +825,7 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
$filename = basename($photo);
$img_str = fetch_url($photo, true);

if ($quit_on_error AND ($img_str == "")) {
if ($quit_on_error && ($img_str == "")) {
return false;
}

@@ -883,7 +883,7 @@ function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
$photo_failure = true;
}

if ($photo_failure AND $quit_on_error) {
if ($photo_failure && $quit_on_error) {
return false;
}

@@ -902,7 +902,7 @@ function get_photo_info($url) {

$data = Cache::get($url);

if (is_null($data) OR !$data OR !is_array($data)) {
if (is_null($data) || !$data || !is_array($data)) {
$img_str = fetch_url($url, true, $redirects, 4);
$filesize = strlen($img_str);

@@ -996,7 +996,7 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") {
/// $default_cid = $r[0]['id'];
/// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);

if ((strlen($imagedata) == 0) AND ($url == "")) {
if ((strlen($imagedata) == 0) && ($url == "")) {
logger("No image data and no url provided", LOGGER_DEBUG);
return(array());
} elseif (strlen($imagedata) == 0) {
@@ -1102,7 +1102,7 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") {
}
}

if ($width > 160 AND $height > 160) {
if ($width > 160 && $height > 160) {
$x = 0;
$y = 0;



+ 2
- 2
include/acl_selectors.php View File

@@ -209,7 +209,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p

$tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : "");

if ($privmail AND $preselected) {
if ($privmail && $preselected) {
$sql_extra .= " AND `id` IN (".implode(",", $preselected).")";
$hidepreselected = ' style="display: none;"';
} else {
@@ -261,7 +261,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p

$o .= "</select>\r\n";

if ($privmail AND $preselected) {
if ($privmail && $preselected) {
$o .= implode(", ", $receiverlist);
}



+ 30
- 30
include/api.php View File

@@ -483,7 +483,7 @@ $called_api = null;
logger("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG);

// Searching for contact URL
if (!is_null($contact_id) AND (intval($contact_id) == 0)) {
if (!is_null($contact_id) && (intval($contact_id) == 0)) {
$user = dbesc(normalise_link($contact_id));
$url = $user;
$extra_query = "AND `contact`.`nurl` = '%s' ";
@@ -493,7 +493,7 @@ $called_api = null;
}

// Searching for contact id with uid = 0
if (!is_null($contact_id) AND (intval($contact_id) != 0)) {
if (!is_null($contact_id) && (intval($contact_id) != 0)) {
$user = dbesc(api_unique_id_to_url($contact_id));

if ($user == "") {
@@ -538,7 +538,7 @@ $called_api = null;
}
}

if (is_null($user) AND ($a->argc > (count($called_api) - 1)) AND (count($called_api) > 0)) {
if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api);
list($user, $null) = explode(".", $a->argv[$argid]);
if (is_numeric($user)) {
@@ -600,7 +600,7 @@ $called_api = null;
$network_name = network_to_name($r[0]['network'], $r[0]['url']);

// If no nick where given, extract it from the address
if (($r[0]['nick'] == "") OR ($r[0]['name'] == $r[0]['nick'])) {
if (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) {
$r[0]['nick'] = api_get_nick($r[0]["url"]);
}

@@ -716,7 +716,7 @@ $called_api = null;
$starred = 0;

// Add a nick if it isn't present there
if (($uinfo[0]['nick'] == "") OR ($uinfo[0]['name'] == $uinfo[0]['nick'])) {
if (($uinfo[0]['nick'] == "") || ($uinfo[0]['name'] == $uinfo[0]['nick'])) {
$uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]);
}

@@ -749,7 +749,7 @@ $called_api = null;
'contributors_enabled' => false,
'is_translator' => false,
'is_translation_enabled' => false,
'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) OR ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)),
'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) || ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)),
'follow_request_sent' => false,
'statusnet_blocking' => false,
'notifications' => false,
@@ -777,10 +777,10 @@ $called_api = null;

$status_user = api_get_user($a, $item["author-link"]);

$status_user["protected"] = (($item["allow_cid"] != "") OR
($item["allow_gid"] != "") OR
($item["deny_cid"] != "") OR
($item["deny_gid"] != "") OR
$status_user["protected"] = (($item["allow_cid"] != "") ||
($item["allow_gid"] != "") ||
($item["deny_cid"] != "") ||
($item["deny_gid"] != "") ||
$item["private"]);

if ($item['thr-parent'] == $item['uri']) {
@@ -1305,9 +1305,9 @@ $called_api = null;
$status_info["entities"] = $converted["entities"];
}

if (($lastwall['item_network'] != "") AND ($status["source"] == 'web')) {
if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) {
$status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
} elseif (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
} elseif (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
$status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')');
}

@@ -1393,11 +1393,11 @@ $called_api = null;
$user_info["status"]["entities"] = $converted["entities"];
}

if (($lastwall['item_network'] != "") AND ($user_info["status"]["source"] == 'web')) {
if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) {
$user_info["status"]["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
}

if (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
if (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
$user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . network_to_name($lastwall['item_network'], $user_info['url']) . ')');
}

@@ -2289,11 +2289,11 @@ $called_api = null;
$statushtml = "<h4>" . bbcode($item['title']) . "</h4>\n" . $statushtml;
}

// feeds without body should contain the link
if (($item['network'] == NETWORK_FEED) && (strlen($item['body']) == 0)) {
$statushtml .= bbcode($item['plink']);
}
// feeds without body should contain the link
if (($item['network'] == NETWORK_FEED) && (strlen($item['body']) == 0)) {
$statushtml .= bbcode($item['plink']);
}
$entities = api_get_entitities($statustext, $body);

return array(
@@ -2402,8 +2402,8 @@ $called_api = null;
$offset = 0;
//foreach ($urls[1] AS $id=>$url) {
foreach ($ordered_urls AS $url) {
if ((substr($url["title"], 0, 7) != "http://") AND (substr($url["title"], 0, 8) != "https://") AND
!strpos($url["title"], "http://") AND !strpos($url["title"], "https://"))
if ((substr($url["title"], 0, 7) != "http://") && (substr($url["title"], 0, 8) != "https://") &&
!strpos($url["title"], "http://") && !strpos($url["title"], "https://"))
$display_url = $url["title"];
else {
$display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url["url"]);
@@ -2455,7 +2455,7 @@ $called_api = null;
$scale = scale_image($image[0], $image[1], 150);
$sizes["thumb"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");

if (($image[0] > 150) OR ($image[1] > 150)) {
if (($image[0] > 150) || ($image[1] > 150)) {
$scale = scale_image($image[0], $image[1], 340);
$sizes["small"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
}
@@ -2463,7 +2463,7 @@ $called_api = null;
$scale = scale_image($image[0], $image[1], 600);
$sizes["medium"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");

if (($image[0] > 600) OR ($image[1] > 600)) {
if (($image[0] > 600) || ($image[1] > 600)) {
$scale = scale_image($image[0], $image[1], 1024);
$sizes["large"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
}
@@ -2668,7 +2668,7 @@ $called_api = null;
list($status_user, $owner_user) = api_item_get_user($a, $item);

// Look if the posts are matching if they should be filtered by user id
if ($filter_user AND ($status_user["id"] != $user_info["id"])) {
if ($filter_user && ($status_user["id"] != $user_info["id"])) {
continue;
}

@@ -2712,9 +2712,9 @@ $called_api = null;
$status["entities"] = $converted["entities"];
}

if (($item['item_network'] != "") AND ($status["source"] == 'web')) {
if (($item['item_network'] != "") && ($status["source"] == 'web')) {
$status["source"] = network_to_name($item['item_network'], $user_info['url']);
} elseif (($item['item_network'] != "") AND (network_to_name($item['item_network'], $user_info['url']) != $status["source"])) {
} elseif (($item['item_network'] != "") && (network_to_name($item['item_network'], $user_info['url']) != $status["source"])) {
$status["source"] = trim($status["source"].' ('.network_to_name($item['item_network'], $user_info['url']).')');
}

@@ -2723,7 +2723,7 @@ $called_api = null;
// It doesn't work reliable with the link if its a feed
//$IsRetweet = ($item['owner-link'] != $item['author-link']);
//if ($IsRetweet)
// $IsRetweet = (($item['owner-name'] != $item['author-name']) OR ($item['owner-avatar'] != $item['author-avatar']));
// $IsRetweet = (($item['owner-name'] != $item['author-name']) || ($item['owner-avatar'] != $item['author-avatar']));


if ($item["id"] == $item["parent"]) {
@@ -3022,7 +3022,7 @@ $called_api = null;

if (api_user() === false) throw new ForbiddenException();

if (!x($_POST, "text") OR (!x($_POST,"screen_name") AND !x($_POST,"user_id"))) return;
if (!x($_POST, "text") || (!x($_POST,"screen_name") && !x($_POST,"user_id"))) return;

$sender = api_get_user($a);

@@ -4334,7 +4334,7 @@ $called_api = null;
$in_reply_to['user_id_str'] = NULL;
$in_reply_to['screen_name'] = NULL;

if (($item['thr-parent'] != $item['uri']) AND (intval($item['parent']) != intval($item['id']))) {
if (($item['thr-parent'] != $item['uri']) && (intval($item['parent']) != intval($item['id']))) {
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
intval($item['uid']),
dbesc($item['thr-parent']));
@@ -4415,7 +4415,7 @@ $called_api = null;
if (isset($data["text"]))
$body = $data["text"];

if (($body == "") AND (isset($data["title"])))
if (($body == "") && (isset($data["title"])))
$body = $data["title"];

if (isset($data["url"]))


+ 1
- 1
include/auth.php View File

@@ -29,7 +29,7 @@ if (isset($_COOKIE["Friendica"])) {
new_cookie($authcookiedays*24*60*60, $r[0]);

// Do the authentification if not done by now
if (!isset($_SESSION) OR !isset($_SESSION['authenticated'])) {
if (!isset($_SESSION) || !isset($_SESSION['authenticated'])) {
authenticate_success($r[0]);

if (get_config('system','paranoia'))


+ 18
- 18
include/bbcode.php View File

@@ -49,14 +49,14 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
$data["title"] = str_replace(array("http://", "https://"), "", $data["title"]);
}

if (((strpos($data["text"], "[img=") !== false) OR (strpos($data["text"], "[img]") !== false)) AND ($data["image"] != "")) {
if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false)) && ($data["image"] != "")) {
$data["preview"] = $data["image"];
$data["image"] = "";
}

if ($simplehtml == 7) {
$text = style_url_for_mastodon($data["url"]);
} elseif (($simplehtml != 4) AND ($simplehtml != 0)) {
} elseif (($simplehtml != 4) && ($simplehtml != 0)) {
$text = sprintf('<a href="%s" target="_blank">%s</a><br>', $data["url"], $data["title"]);
} else {
$text = sprintf('<span class="type-%s">', $data["type"]);
@@ -71,13 +71,13 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
if (strstr(strtolower($oembed), "<iframe ")) {
$text = $oembed;
} else {
if (($data["image"] != "") AND !strstr(strtolower($oembed), "<img ")) {
if (($data["image"] != "") && !strstr(strtolower($oembed), "<img ")) {
$text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], proxy_url($data["image"]), $data["title"]);
} elseif (($data["preview"] != "") AND !strstr(strtolower($oembed), "<img ")) {
} elseif (($data["preview"] != "") && !strstr(strtolower($oembed), "<img ")) {
$text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], proxy_url($data["preview"]), $data["title"]);
}

if (($data["type"] == "photo") AND ($data["url"] != "") AND ($data["image"] != "")) {
if (($data["type"] == "photo") && ($data["url"] != "") && ($data["image"] != "")) {
$text .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data["url"], proxy_url($data["image"]), $data["title"]);
} else {
$text .= $oembed;
@@ -103,25 +103,25 @@ function bb_remove_share_information($Text, $plaintext = false, $nolink = false)

$title = htmlentities($data["title"], ENT_QUOTES, 'UTF-8', false);
$text = htmlentities($data["text"], ENT_QUOTES, 'UTF-8', false);
if ($plaintext OR (($title != "") AND strstr($text, $title))) {
if ($plaintext || (($title != "") && strstr($text, $title))) {
$data["title"] = $data["url"];
} elseif (($text != "") AND strstr($title, $text)) {
} elseif (($text != "") && strstr($title, $text)) {
$data["text"] = $data["title"];
$data["title"] = $data["url"];
}

if (($data["text"] == "") AND ($data["title"] != "") AND ($data["url"] == "")) {
if (($data["text"] == "") && ($data["title"] != "") && ($data["url"] == "")) {
return $data["title"] . $data["after"];
}

// If the link already is included in the post, don't add it again
if (($data["url"] != "") AND strpos($data["text"], $data["url"])) {
if (($data["url"] != "") && strpos($data["text"], $data["url"])) {
return $data["text"] . $data["after"];
}

$text = $data["text"];

if (($data["url"] != "") AND ($data["title"] != "")) {
if (($data["url"] != "") && ($data["title"] != "")) {
$text .= "\n[url=" . $data["url"] . "]" . $data["title"] . "[/url]";
} elseif (($data["url"] != "")) {
$text .= "\n" . $data["url"];
@@ -167,7 +167,7 @@ function cleancss($input) {
function bb_style_url($match) {
$url = $match[1];

if (isset($match[2]) AND ($match[1] != $match[2])) {
if (isset($match[2]) && ($match[1] != $match[2])) {
return $match[0];
}

@@ -485,20 +485,20 @@ function bb_ShareAttributes($share, $simplehtml) {

$data = get_contact_details_by_url($profile);

if (isset($data["name"]) AND ($data["name"] != "") AND isset($data["addr"]) AND ($data["addr"] != ""))
if (isset($data["name"]) && ($data["name"] != "") && isset($data["addr"]) && ($data["addr"] != ""))
$userid_compact = $data["name"]." (".$data["addr"].")";
else
$userid_compact = GetProfileUsername($profile,$author, true);

if (isset($data["addr"]) AND ($data["addr"] != ""))
if (isset($data["addr"]) && ($data["addr"] != ""))
$userid = $data["addr"];
else
$userid = GetProfileUsername($profile,$author, false);

if (isset($data["name"]) AND ($data["name"] != ""))
if (isset($data["name"]) && ($data["name"] != ""))
$author = $data["name"];

if (isset($data["micro"]) AND ($data["micro"] != ""))
if (isset($data["micro"]) && ($data["micro"] != ""))
$avatar = $data["micro"];

$preshare = trim($share[1]);
@@ -744,7 +744,7 @@ function bb_RemovePictureLinks($match) {
}

function bb_expand_links($match) {
if (($match[3] == "") OR ($match[2] == $match[3]) OR stristr($match[2], $match[3])) {
if (($match[3] == "") || ($match[2] == $match[3]) || stristr($match[2], $match[3])) {
return ($match[1] . "[url]" . $match[2] . "[/url]");
} else {
return ($match[1] . $match[3] . " [url]" . $match[2] . "[/url]");
@@ -930,7 +930,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
$MAILSearchString = $URLSearchString;

// Remove all hashtag addresses
if ((!$tryoembed OR $simplehtml) AND !in_array($simplehtml, array(3, 7))) {
if ((!$tryoembed || $simplehtml) && !in_array($simplehtml, array(3, 7))) {
$Text = preg_replace("/([#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
} elseif ($simplehtml == 3) {
$Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
@@ -1319,7 +1319,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// Clean up the HTML by loading and saving the HTML with the DOM.
// Bad structured html can break a whole page.
// For performance reasons do it only with ativated item cache or at export.
if (!$tryoembed OR (get_itemcachepath() != "")) {
if (!$tryoembed || (get_itemcachepath() != "")) {
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;



+ 5
- 5
include/cache.php View File

@@ -172,35 +172,35 @@ class Cache {
set_config("system", "cache_cleared_day", time());
}

if (($max_level <= CACHE_HOUR) AND (get_config("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) {
if (($max_level <= CACHE_HOUR) && (get_config("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) {
q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d",
dbesc(datetime_convert('UTC','UTC',"now - 1 hours")), intval(CACHE_HOUR));

set_config("system", "cache_cleared_hour", time());
}

if (($max_level <= CACHE_HALF_HOUR) AND (get_config("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) {
if (($max_level <= CACHE_HALF_HOUR) && (get_config("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) {
q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d",
dbesc(datetime_convert('UTC','UTC',"now - 30 minutes")), intval(CACHE_HALF_HOUR));

set_config("system", "cache_cleared_half_hour", time());
}

if (($max_level <= CACHE_QUARTER_HOUR) AND (get_config("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) {
if (($max_level <= CACHE_QUARTER_HOUR) && (get_config("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) {
q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d",
dbesc(datetime_convert('UTC','UTC',"now - 15 minutes")), intval(CACHE_QUARTER_HOUR));

set_config("system", "cache_cleared_quarter_hour", time());
}

if (($max_level <= CACHE_FIVE_MINUTES) AND (get_config("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) {
if (($max_level <= CACHE_FIVE_MINUTES) && (get_config("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) {
q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d",
dbesc(datetime_convert('UTC','UTC',"now - 5 minutes")), intval(CACHE_FIVE_MINUTES));

set_config("system", "cache_cleared_five_minute", time());
}

if (($max_level <= CACHE_MINUTE) AND (get_config("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) {
if (($max_level <= CACHE_MINUTE) && (get_config("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) {
q("DELETE FROM `cache` WHERE `updated` < '%s' AND `expire_mode` = %d",
dbesc(datetime_convert('UTC','UTC',"now - 1 minutes")), intval(CACHE_MINUTE));



+ 1
- 1
include/contact_selectors.php View File

@@ -100,7 +100,7 @@ function network_to_name($s, $profile = "") {

$networkname = str_replace($search, $replace, $s);

if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) AND ($profile != "")) {
if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
$r = q("SELECT `gserver`.`platform` FROM `gcontact`
INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
WHERE `gcontact`.`nurl` = '%s' AND `platform` != ''",


+ 1
- 1
include/contact_widgets.php View File

@@ -51,7 +51,7 @@ function unavailable_networks() {
$networks[] = NETWORK_APPNET;
}

if (!plugin_enabled("fbpost") AND !plugin_enabled("facebook")) {
if (!plugin_enabled("fbpost") && !plugin_enabled("facebook")) {
$networks[] = NETWORK_FACEBOOK;
}



+ 3
- 3
include/conversation.php View File

@@ -712,7 +712,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$profile_link = zrl($profile_link);
}

if (!x($item, 'author-thumb') OR ($item['author-thumb'] == "")) {
if (!x($item, 'author-thumb') || ($item['author-thumb'] == "")) {
$author_contact = get_contact_details_by_url($item['author-link'], $profile_owner);
if ($author_contact["thumb"]) {
$item['author-thumb'] = $author_contact["thumb"];
@@ -721,7 +721,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
}
}

if (!isset($item['owner-thumb']) OR ($item['owner-thumb'] == "")) {
if (!isset($item['owner-thumb']) || ($item['owner-thumb'] == "")) {
$owner_contact = get_contact_details_by_url($item['owner-link'], $profile_owner);
if ($owner_contact["thumb"]) {
$item['owner-thumb'] = $owner_contact["thumb"];
@@ -1013,7 +1013,7 @@ function item_photo_menu($item) {
$menu[t("Poke")] = $poke_link;
}

if ((($cid == 0) OR ($rel == CONTACT_IS_FOLLOWER)) AND
if ((($cid == 0) || ($rel == CONTACT_IS_FOLLOWER)) &&
in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
$menu[t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
}


+ 3
- 3
include/cron.php View File

@@ -186,7 +186,7 @@ function cron_poll_contacts($argc, $argv) {
$contact['priority'] = 2;
}

if ($contact['subhub'] AND in_array($contact['network'], array(NETWORK_DFRN, NETWORK_ZOT, NETWORK_OSTATUS))) {
if ($contact['subhub'] && in_array($contact['network'], array(NETWORK_DFRN, NETWORK_ZOT, NETWORK_OSTATUS))) {
/*
* We should be getting everything via a hub. But just to be sure, let's check once a day.
* (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
@@ -197,7 +197,7 @@ function cron_poll_contacts($argc, $argv) {
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
}

if (($contact['priority'] >= 0) AND !$force) {
if (($contact['priority'] >= 0) && !$force) {
$update = false;

$t = $contact['last-update'];
@@ -245,7 +245,7 @@ function cron_poll_contacts($argc, $argv) {

logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact["nick"] . " " . $contact["name"]);

if (($contact['network'] == NETWORK_FEED) AND ($contact['priority'] <= 3)) {
if (($contact['network'] == NETWORK_FEED) && ($contact['priority'] <= 3)) {
$priority = PRIORITY_MEDIUM;
} else {
$priority = PRIORITY_LOW;


+ 2
- 2
include/cronhooks.php View File

@@ -7,7 +7,7 @@ function cronhooks_run(&$argv, &$argc) {

require_once 'include/datetime.php';

if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
if (($argc == 2) && is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
foreach ($a->hooks["cron"] as $hook) {
if ($hook[1] == $argv[1]) {
logger("Calling cron hook '" . $hook[1] . "'", LOGGER_DEBUG);
@@ -38,7 +38,7 @@ function cronhooks_run(&$argv, &$argc) {

$d = datetime_convert();

if (is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
foreach ($a->hooks["cron"] as $hook) {
logger("Calling cronhooks for '" . $hook[1] . "'", LOGGER_DEBUG);
proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);


+ 11
- 11
include/dba.php View File

@@ -117,7 +117,7 @@ class dba {

/**
* @brief Returns the MySQL server version string
*
*
* This function discriminate between the deprecated mysql API and the current
* object-oriented mysqli API. Example of returned string: 5.5.46-0+deb8u1
*
@@ -183,17 +183,17 @@ class dba {

foreach ($r AS $row) {
if ((intval($a->config["system"]["db_loglimit_index"]) > 0)) {
$log = (in_array($row['key'], $watchlist) AND
$log = (in_array($row['key'], $watchlist) &&
($row['rows'] >= intval($a->config["system"]["db_loglimit_index"])));
} else {
$log = false;
}

if ((intval($a->config["system"]["db_loglimit_index_high"]) > 0) AND ($row['rows'] >= intval($a->config["system"]["db_loglimit_index_high"]))) {
if ((intval($a->config["system"]["db_loglimit_index_high"]) > 0) && ($row['rows'] >= intval($a->config["system"]["db_loglimit_index_high"]))) {
$log = true;
}

if (in_array($row['key'], $blacklist) OR ($row['key'] == "")) {
if (in_array($row['key'], $blacklist) || ($row['key'] == "")) {
$log = false;
}

@@ -363,7 +363,7 @@ class dba {
// PDO doesn't return "true" on successful operations - like mysqli does
// Emulate this behaviour by checking if the query returned data and had columns
// This should be reliable enough
if (($this->driver == 'pdo') AND (count($r) == 0) AND ($columns == 0)) {
if (($this->driver == 'pdo') && (count($r) == 0) && ($columns == 0)) {
return true;
}

@@ -490,7 +490,7 @@ class dba {
static private function replace_parameters($sql, $args) {
$offset = 0;
foreach ($args AS $param => $value) {
if (is_int($args[$param]) OR is_float($args[$param])) {
if (is_int($args[$param]) || is_float($args[$param])) {
$replace = intval($args[$param]);
} else {
$replace = "'".self::$dbo->escape($args[$param])."'";
@@ -520,7 +520,7 @@ class dba {
unset($args[0]);

// When the second function parameter is an array then use this as the parameter array
if ((count($args) > 0) AND (is_array($args[1]))) {
if ((count($args) > 0) && (is_array($args[1]))) {
$params = $args[1];
} else {
$params = $args;
@@ -533,7 +533,7 @@ class dba {
$args[++$i] = $param;
}

if (!self::$dbo OR !self::$dbo->connected) {
if (!self::$dbo || !self::$dbo->connected) {
return false;
}

@@ -948,7 +948,7 @@ class dba {

// When the search field is the relation field, we don't need to fetch the rows
// This is useful when the leading record is already deleted in the frontend but the rest is done in the backend
if ((count($param) == 1) AND ($field == array_keys($param)[0])) {
if ((count($param) == 1) && ($field == array_keys($param)[0])) {
foreach ($rel_def AS $rel_table => $rel_fields) {
foreach ($rel_fields AS $rel_field) {
$retval = self::delete($rel_table, array($rel_field => array_values($param)[0]), true, $callstack);
@@ -1110,7 +1110,7 @@ class dba {
}
}

if (!$do_update OR (count($fields) == 0)) {
if (!$do_update || (count($fields) == 0)) {
return true;
}

@@ -1190,7 +1190,7 @@ class dba {

$result = self::p($sql, $condition);

if (is_bool($result) OR !$single_row) {
if (is_bool($result) || !$single_row) {
return $result;
} else {
$row = self::fetch($result);


+ 2
- 2
include/dba_pdo.php View File

@@ -190,14 +190,14 @@ class dba {
* regardless of any logging that may or may nor be in effect.
* These usually indicate SQL syntax errors that need to be resolved.
*/
if (isset($result) AND ($result === false)) {
if (isset($result) && ($result === false)) {
logger('dba: ' . printable($sql) . ' returned false.' . "\n" . $this->error);
if (file_exists('dbfail.out')) {
file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND);
}
}

if (isset($result) AND (($result === true) || ($result === false))) {
if (isset($result) && (($result === true) || ($result === false))) {
return $result;
}



+ 2
- 2
include/dbclean.php View File

@@ -24,7 +24,7 @@ function dbclean_run(&$argv, &$argc) {
for ($i = 1; $i <= 9; $i++) {
// Execute the background script for a step when it isn't finished.
// Execute step 8 and 9 only when $days is defined.
if (!Config::get('system', 'finished-dbclean-'.$i, false) AND (($i < 8) OR ($days > 0))) {
if (!Config::get('system', 'finished-dbclean-'.$i, false) && (($i < 8) || ($days > 0))) {
proc_run(PRIORITY_LOW, 'include/dbclean.php', $i);
}
}
@@ -296,7 +296,7 @@ function remove_orphans($stage = 0) {
}

// Call it again if not all entries were purged
if (($stage != 0) AND ($count > 0)) {
if (($stage != 0) && ($count > 0)) {
proc_run(PRIORITY_MEDIUM, 'include/dbclean.php');
}
}

+ 1
- 1
include/dbm.php View File

@@ -76,7 +76,7 @@ class dbm {

if (is_bool($value)) {
$value = ($value ? 'true' : 'false');
} elseif (is_float($value) OR is_integer($value)) {
} elseif (is_float($value) || is_integer($value)) {
$value = (string)$value;
} else {
$value = "'".dbesc($value)."'";


+ 5
- 5
include/dbstructure.php View File

@@ -133,7 +133,7 @@ function table_structure($table) {
// On utf8mb4 a varchar index can only have a length of 191
// The "show index" command sometimes returns this value although this value wasn't added manually.
// Because we don't want to add this number to every index, we ignore bigger numbers
if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 191) OR ($index["Key_name"] == "PRIMARY"))) {
if (($index["Sub_part"] != "") && (($index["Sub_part"] < 191) || ($index["Key_name"] == "PRIMARY"))) {
$column .= "(".$index["Sub_part"].")";
}

@@ -232,7 +232,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
}

// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
if ((version_compare($db->server_info(), '5.7.4') >= 0) &&
!(strpos($db->server_info(), 'MariaDB') !== false)) {
$ignore = '';
} else {
@@ -381,7 +381,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
$field_definition = $database[$name]["fields"][$fieldname];

// Define the default collation if not given
if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
if (!isset($parameters['Collation']) && !is_null($field_definition['Collation'])) {
$parameters['Collation'] = 'utf8mb4_general_ci';
} else {
$parameters['Collation'] = null;
@@ -389,7 +389,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {

if ($field_definition['Collation'] != $parameters['Collation']) {
$sql2 = db_modify_table_field($fieldname, $parameters);
if (($sql3 == "") OR (substr($sql3, -2, 2) == "; ")) {
if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
$sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
} else {
$sql3 .= ", ".$sql2;
@@ -513,7 +513,7 @@ function db_field_command($parameters, $create = true) {
if ($parameters["extra"] != "")
$fieldstruct .= " ".$parameters["extra"];

/*if (($parameters["primary"] != "") AND $create)
/*if (($parameters["primary"] != "") && $create)
$fieldstruct .= " PRIMARY KEY";*/

return($fieldstruct);


+ 3
- 3
include/delivery.php View File

@@ -339,7 +339,7 @@ function delivery_run(&$argv, &$argc){

// If we are setup as a soapbox we aren't accepting top level posts from this person

if (($x[0]['page-flags'] == PAGE_SOAPBOX) AND $top_level) {
if (($x[0]['page-flags'] == PAGE_SOAPBOX) && $top_level) {
break;
}
logger('mod-delivery: local delivery');
@@ -462,14 +462,14 @@ function delivery_run(&$argv, &$argc){
dbesc($it['parent-uri']),
intval($uid));

if (dbm::is_result($r) AND ($r[0]['title'] != '')) {
if (dbm::is_result($r) && ($r[0]['title'] != '')) {
$subject = $r[0]['title'];
} else {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']),
intval($uid));

if (dbm::is_result($r) AND ($r[0]['title'] != ''))
if (dbm::is_result($r) && ($r[0]['title'] != ''))
$subject = $r[0]['title'];
}
}


+ 18
- 18
include/dfrn.php View File

@@ -245,7 +245,7 @@ class dfrn {
/// @TODO This hook can't work anymore
// call_hooks('atom_feed', $atom);

if (!dbm::is_result($items) OR $onlyheader) {
if (!dbm::is_result($items) || $onlyheader) {
$atom = trim($doc->saveXML());

call_hooks('atom_feed_end', $atom);
@@ -508,7 +508,7 @@ class dfrn {

$attributes = array();

if (!$public OR !$hidewall) {
if (!$public || !$hidewall) {
$attributes = array("dfrn:updated" => $namdate);
}

@@ -519,7 +519,7 @@ class dfrn {
$attributes = array("rel" => "photo", "type" => "image/jpeg",
"media:width" => 175, "media:height" => 175, "href" => $owner['photo']);

if (!$public OR !$hidewall) {
if (!$public || !$hidewall) {
$attributes["dfrn:updated"] = $picdate;
}

@@ -921,7 +921,7 @@ class dfrn {

if (count($tags)) {
foreach ($tags as $t) {
if (($type != 'html') OR ($t[0] != "@")) {
if (($type != 'html') || ($t[0] != "@")) {
xml::add_element($doc, $entry, "category", "", array("scheme" => "X-DFRN:".$t[0].":".$t[1], "term" => $t[2]));
}
}
@@ -940,7 +940,7 @@ class dfrn {
intval($owner["uid"]),
dbesc(normalise_link($mention)));

if (dbm::is_result($r) AND ($r[0]["forum"] OR $r[0]["prv"])) {
if (dbm::is_result($r) && ($r[0]["forum"] || $r[0]["prv"])) {
xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
"href" => $mention));
@@ -1323,7 +1323,7 @@ class dfrn {
$contact["avatar-date"] = $attributes->textContent;
}
}
if (($width > 0) AND ($href != "")) {
if (($width > 0) && ($href != "")) {
$avatarlist[$width] = $href;
}
}
@@ -1332,7 +1332,7 @@ class dfrn {
$author["avatar"] = current($avatarlist);
}

if (dbm::is_result($r) AND !$onlyfetch) {
if (dbm::is_result($r) && !$onlyfetch) {
logger("Check if contact details for contact " . $r[0]["id"] . " (" . $r[0]["nick"] . ") have to be updated.", LOGGER_DEBUG);

$poco = array("url" => $contact["url"]);
@@ -1774,7 +1774,7 @@ class dfrn {
$relocate["poll"] = $xpath->query("dfrn:poll/text()", $relocation)->item(0)->nodeValue;
$relocate["sitepubkey"] = $xpath->query("dfrn:sitepubkey/text()", $relocation)->item(0)->nodeValue;

if (($relocate["avatar"] == "") AND ($relocate["photo"] != "")) {
if (($relocate["avatar"] == "") && ($relocate["photo"] != "")) {
$relocate["avatar"] = $relocate["photo"];
}

@@ -1922,7 +1922,7 @@ class dfrn {
}

// update last-child if it changes
if ($item["last-child"] AND ($item["last-child"] != $current["last-child"])) {
if ($item["last-child"] && ($item["last-child"] != $current["last-child"])) {
$r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(datetime_convert()),
dbesc($item["parent-uri"]),
@@ -2206,7 +2206,7 @@ class dfrn {
$title = $attributes->textContent;
}
}
if (($rel != "") AND ($href != "")) {
if (($rel != "") && ($href != "")) {
switch ($rel) {
case "alternate":
$item["plink"] = $href;
@@ -2254,7 +2254,7 @@ class dfrn {
);

// Is there an existing item?
if (dbm::is_result($current) AND edited_timestamp_is_newer($current[0], $item) AND
if (dbm::is_result($current) && edited_timestamp_is_newer($current[0], $item) &&
(datetime_convert("UTC","UTC",$item["edited"]) < $current[0]["edited"])) {
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
return;
@@ -2328,7 +2328,7 @@ class dfrn {
}

$notice_info = $xpath->query("statusnet:notice_info", $entry);
if ($notice_info AND ($notice_info->length > 0)) {
if ($notice_info && ($notice_info->length > 0)) {
foreach ($notice_info->item(0)->attributes AS $attributes) {
if ($attributes->name == "source") {
$item["app"] = strip_tags($attributes->textContent);
@@ -2378,9 +2378,9 @@ class dfrn {
}
}

if (($term != "") AND ($scheme != "")) {
if (($term != "") && ($scheme != "")) {
$parts = explode(":", $scheme);
if ((count($parts) >= 4) AND (array_shift($parts) == "X-DFRN")) {
if ((count($parts) >= 4) && (array_shift($parts) == "X-DFRN")) {
$termhash = array_shift($parts);
$termurl = implode(":", $parts);

@@ -2440,7 +2440,7 @@ class dfrn {
$item["contact-id"] = $owner["contact-id"];
}

if (($item["network"] != $owner["network"]) AND ($owner["network"] != "")) {
if (($item["network"] != $owner["network"]) && ($owner["network"] != "")) {
$item["network"] = $owner["network"];
}

@@ -2448,7 +2448,7 @@ class dfrn {
$item["contact-id"] = $author["contact-id"];
}

if (($item["network"] != $author["network"]) AND ($author["network"] != "")) {
if (($item["network"] != $author["network"]) && ($author["network"] != "")) {
$item["network"] = $author["network"];
}

@@ -2548,7 +2548,7 @@ class dfrn {
);
}

if ($posted_id AND $parent AND ($entrytype == DFRN_REPLY_RC)) {
if ($posted_id && $parent && ($entrytype == DFRN_REPLY_RC)) {
logger("Notifying followers about comment ".$posted_id, LOGGER_DEBUG);
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $posted_id);
}
@@ -2613,7 +2613,7 @@ class dfrn {
$when = datetime_convert("UTC", "UTC", "now", "Y-m-d H:i:s");
}

if (!$uri OR !$importer["id"]) {
if (!$uri || !$importer["id"]) {
return false;
}



+ 30
- 30
include/diaspora.php View File

@@ -416,7 +416,7 @@ class Diaspora {
$fields = $postdata['fields'];

// Is it a an action (comment, like, ...) for our own post?
if (isset($fields->parent_guid) AND !$postdata["relayed"]) {
if (isset($fields->parent_guid) && !$postdata["relayed"]) {
$guid = notags(unxmlify($fields->parent_guid));
$importer = self::importer_for_guid($guid);
if (is_array($importer)) {
@@ -612,9 +612,9 @@ class Diaspora {
}
}

if (($fieldname == "author_signature") AND ($entry != ""))
if (($fieldname == "author_signature") && ($entry != ""))
$author_signature = base64_decode($entry);
elseif (($fieldname == "parent_author_signature") AND ($entry != ""))
elseif (($fieldname == "parent_author_signature") && ($entry != ""))
$parent_author_signature = base64_decode($entry);
elseif (!in_array($fieldname, array("author_signature", "parent_author_signature", "target_author_signature"))) {
if ($signed_data != "") {
@@ -624,7 +624,7 @@ class Diaspora {

$signed_data .= $entry;
}
if (!in_array($fieldname, array("parent_author_signature", "target_author_signature")) OR
if (!in_array($fieldname, array("parent_author_signature", "target_author_signature")) ||
($orig_type == "relayable_retraction"))
xml::copy($entry, $fields, $fieldname);
}
@@ -714,13 +714,13 @@ class Diaspora {
$update = true;
}

if (!$person OR $update) {
if (!$person || $update) {
logger("create or refresh", LOGGER_DEBUG);
$r = probe_url($handle, PROBE_DIASPORA);

// Note that Friendica contacts will return a "Diaspora person"
// if Diaspora connectivity is enabled on their server
if ($r AND ($r["network"] === NETWORK_DIASPORA)) {
if ($r && ($r["network"] === NETWORK_DIASPORA)) {
self::add_fcontact($r, $update);
$person = $r;
}
@@ -1143,7 +1143,7 @@ class Diaspora {
// Fetch the author - for the old and the new Diaspora version
if ($source_xml->post->status_message->diaspora_handle)
$author = (string)$source_xml->post->status_message->diaspora_handle;
elseif ($source_xml->author AND ($source_xml->getName() == "status_message"))
elseif ($source_xml->author && ($source_xml->getName() == "status_message"))
$author = (string)$source_xml->author;

// If this isn't a "status_message" then quit
@@ -1463,7 +1463,7 @@ class Diaspora {
}

// If we are the origin of the parent we store the original data and notify our followers
if ($message_id AND $parent_item["origin"]) {
if ($message_id && $parent_item["origin"]) {

// Formerly we stored the signed text, the signature and the author in different fields.
// We now store the raw data so that we are more flexible.
@@ -1767,7 +1767,7 @@ class Diaspora {
}

// If we are the origin of the parent we store the original data and notify our followers
if ($message_id AND $parent_item["origin"]) {
if ($message_id && $parent_item["origin"]) {

// Formerly we stored the signed text, the signature and the author in different fields.
// We now store the raw data so that we are more flexible.
@@ -2116,7 +2116,7 @@ class Diaspora {
// perhaps we were already sharing with this person. Now they're sharing with us.
// That makes us friends.
if ($contact) {
if ($following AND $sharing) {
if ($following && $sharing) {
logger("Author ".$author." (Contact ".$contact["id"].") wants to have a bidirectional conection.", LOGGER_DEBUG);
self::receive_request_make_friend($importer, $contact);

@@ -2139,17 +2139,17 @@ class Diaspora {
}
}

if (!$following AND $sharing AND in_array($importer["page-flags"], array(PAGE_SOAPBOX, PAGE_NORMAL))) {
if (!$following && $sharing && in_array($importer["page-flags"], array(PAGE_SOAPBOX, PAGE_NORMAL))) {
logger("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", LOGGER_DEBUG);
return false;
} elseif (!$following AND !$sharing) {
} elseif (!$following && !$sharing) {
logger("Author ".$author." doesn't want anything - and we don't know the author. Request is ignored.", LOGGER_DEBUG);
return false;
} elseif (!$following AND $sharing) {
} elseif (!$following && $sharing) {
logger("Author ".$author." wants to share with us.", LOGGER_DEBUG);
} elseif ($following AND $sharing) {
} elseif ($following && $sharing) {
logger("Author ".$author." wants to have a bidirectional conection.", LOGGER_DEBUG);
} elseif ($following AND !$sharing) {
} elseif ($following && !$sharing) {
logger("Author ".$author." wants to listen to us.", LOGGER_DEBUG);
}

@@ -2227,9 +2227,9 @@ class Diaspora {
// but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
// we are going to change the relationship and make them a follower.

if (($importer["page-flags"] == PAGE_FREELOVE) AND $sharing AND $following)
if (($importer["page-flags"] == PAGE_FREELOVE) && $sharing && $following)
$new_relation = CONTACT_IS_FRIEND;
elseif (($importer["page-flags"] == PAGE_FREELOVE) AND $sharing)
elseif (($importer["page-flags"] == PAGE_FREELOVE) && $sharing)
$new_relation = CONTACT_IS_SHARING;
else
$new_relation = CONTACT_IS_FOLLOWER;
@@ -2452,7 +2452,7 @@ class Diaspora {
intval($r[0]["parent"]));

// Only delete it if the parent author really fits
if (!link_compare($p[0]["author-link"], $contact["url"]) AND !link_compare($r[0]["author-link"], $contact["url"])) {
if (!link_compare($p[0]["author-link"], $contact["url"]) && !link_compare($r[0]["author-link"], $contact["url"])) {
logger("Thread author ".$p[0]["author-link"]." and item author ".$r[0]["author-link"]." don't fit to expected contact ".$contact["url"], LOGGER_DEBUG);
return false;
}
@@ -2489,7 +2489,7 @@ class Diaspora {
$target_type = notags(unxmlify($data->target_type));

$contact = self::contact_by_handle($importer["uid"], $sender);
if (!$contact AND (in_array($target_type, array("Contact", "Person")))) {
if (!$contact && (in_array($target_type, array("Contact", "Person")))) {
logger("cannot find contact for sender: ".$sender." and user ".$importer["uid"]);
return false;
}
@@ -2617,7 +2617,7 @@ class Diaspora {
$datarray["location"] = $address["address"];
}

if (isset($address["lat"]) AND isset($address["lng"])) {
if (isset($address["lat"]) && isset($address["lng"])) {
$datarray["coord"] = $address["lat"]." ".$address["lng"];
}

@@ -2930,7 +2930,7 @@ class Diaspora {
// The message could not be delivered. We mark the contact as "dead"
mark_for_death($contact);
}
} elseif (($return_code >= 200) AND ($return_code <= 299)) {
} elseif (($return_code >= 200) && ($return_code <= 299)) {
// We successfully delivered a message, the contact is alive
unmark_for_death($contact);
}
@@ -3040,7 +3040,7 @@ class Diaspora {

// Skip if it isn't a pure repeated messages
// Does it start with a share?
if ((strpos($body, "[share") > 0) AND $complete)
if ((strpos($body, "[share") > 0) && $complete)
return(false);

// Does it end with a share?
@@ -3088,7 +3088,7 @@ class Diaspora {
$ret= array();

$ret["root_handle"] = preg_replace("=https?://(.*)/u/(.*)=ism", "$2@$1", $profile);
if (($ret["root_handle"] == $profile) OR ($ret["root_handle"] == ""))
if (($ret["root_handle"] == $profile) || ($ret["root_handle"] == ""))
return(false);

$link = "";
@@ -3101,7 +3101,7 @@ class Diaspora {
$link = $matches[1];

$ret["root_guid"] = preg_replace("=https?://(.*)/posts/(.*)=ism", "$2", $link);
if (($ret["root_guid"] == $link) OR (trim($ret["root_guid"]) == ""))
if (($ret["root_guid"] == $link) || (trim($ret["root_guid"]) == ""))
return(false);

return($ret);
@@ -3161,7 +3161,7 @@ class Diaspora {
if ($event['start']) {
$eventdata['start'] = datetime_convert($eventdata['timezone'], "UTC", $event['start'], $mask);
}
if ($event['finish'] AND !$event['nofinish']) {
if ($event['finish'] && !$event['nofinish']) {
$eventdata['end'] = datetime_convert($eventdata['timezone'], "UTC", $event['finish'], $mask);
}
if ($event['summary']) {
@@ -3207,7 +3207,7 @@ class Diaspora {
$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');

// Detect a share element and do a reshare
if (!$item['private'] AND ($ret = self::is_reshare($item["body"]))) {
if (!$item['private'] && ($ret = self::is_reshare($item["body"]))) {
$message = array("root_diaspora_id" => $ret["root_handle"],
"root_guid" => $ret["root_guid"],
"guid" => $item["guid"],
@@ -3257,7 +3257,7 @@ class Diaspora {
"provider_display_name" => $item["app"]);

// Diaspora rejects messages when they contain a location without "lat" or "lng"
if (!isset($location["lat"]) OR !isset($location["lng"])) {
if (!isset($location["lat"]) || !isset($location["lng"])) {
unset($message["location"]);
}

@@ -3532,7 +3532,7 @@ class Diaspora {

// Old way - is used by the internal Friendica functions
/// @todo Change all signatur storing functions to the new format
if ($signature['signed_text'] AND $signature['signature'] AND $signature['signer'])
if ($signature['signed_text'] && $signature['signature'] && $signature['signer'])
$message = self::message_from_signature($item, $signature);
else {// New way
$msg = json_decode($signature['signed_text'], true);
@@ -3584,7 +3584,7 @@ class Diaspora {
$target_type = "StatusMessage";
}

if ($relay AND ($item["uri"] !== $item["parent-uri"]))
if ($relay && ($item["uri"] !== $item["parent-uri"]))
$signature = "parent_author_signature";
else
$signature = "target_author_signature";
@@ -3764,7 +3764,7 @@ class Diaspora {
public static function store_like_signature($contact, $post_id) {

// Is the contact the owner? Then fetch the private key
if (!$contact['self'] OR ($contact['uid'] == 0)) {
if (!$contact['self'] || ($contact['uid'] == 0)) {
logger("No owner post, so not storing signature", LOGGER_DEBUG);
return false;
}


+ 5
- 5
include/discover_poco.php View File

@@ -81,12 +81,12 @@ function discover_poco_run(&$argv, &$argc) {
logger($result, LOGGER_DEBUG);
} elseif ($mode == 3) {
update_suggestions();
} elseif (($mode == 2) AND get_config('system','poco_completion')) {
} elseif (($mode == 2) && get_config('system','poco_completion')) {
discover_users();
} elseif (($mode == 1) AND ($search != "") and get_config('system','poco_local_search')) {
} elseif (($mode == 1) && ($search != "") and get_config('system','poco_local_search')) {
discover_directory($search);
gs_search_user($search);
} elseif (($mode == 0) AND ($search == "") and (get_config('system','poco_discovery') > 0)) {
} elseif (($mode == 0) && ($search == "") and (get_config('system','poco_discovery') > 0)) {
// Query Friendica and Hubzilla servers for their users
poco_discover();

@@ -176,7 +176,7 @@ function discover_users() {
$server_url = $user["server_url"];
}

if ((($server_url == "") AND ($user["network"] == NETWORK_FEED)) OR $force_update OR poco_check_server($server_url, $user["network"])) {
if ((($server_url == "") && ($user["network"] == NETWORK_FEED)) || $force_update || poco_check_server($server_url, $user["network"])) {
logger('Check profile '.$user["url"]);
proc_run(PRIORITY_LOW, "include/discover_poco.php", "check_profile", base64_encode($user["url"]));

@@ -216,7 +216,7 @@ function discover_directory($search) {
if (dbm::is_result($exists)) {
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);

if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) &&
($exists[0]["updated"] < $exists[0]["last_failure"])) {
continue;
}


+ 6
- 6
include/enotify.php View File

@@ -99,7 +99,7 @@ function notification($params) {
intval($parent_id),
intval($params['uid'])
);
if ($p AND count($p) AND ($p[0]["ignored"])) {
if ($p && count($p) && ($p[0]["ignored"])) {
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
return;
}
@@ -515,7 +515,7 @@ function notification($params) {

logger('sending notification email');

if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
if (isset($params['parent']) && (intval($params['parent']) != 0)) {
$id_for_parent = $params['parent']."@".$hostname;

// Is this the first email notification for this parent item and user?
@@ -676,7 +676,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
// Check for invalid profile urls. 13 should be the shortest possible profile length:
// http://a.bc/d
// Additionally check for invalid urls that would return the normalised value "http:"
if ((strlen($profile) >= 13) AND (normalise_link($profile) != "http:")) {
if ((strlen($profile) >= 13) && (normalise_link($profile) != "http:")) {
if (!in_array($profile, $profiles2))
$profiles2[] = $profile;

@@ -760,11 +760,11 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$tagged = false;

foreach ($profiles AS $profile) {
if (strpos($item[0]["tag"], "=".$profile."]") OR strpos($item[0]["body"], "=".$profile."]"))
if (strpos($item[0]["tag"], "=".$profile."]") || strpos($item[0]["body"], "=".$profile."]"))
$tagged = true;
}

if ($item[0]["mention"] OR $tagged OR ($defaulttype == NOTIFY_TAGSELF)) {
if ($item[0]["mention"] || $tagged || ($defaulttype == NOTIFY_TAGSELF)) {
$params["type"] = NOTIFY_TAGSELF;
$params["verb"] = ACTIVITY_TAG;
}
@@ -776,7 +776,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
LIMIT 1",
intval($item[0]["parent"]), intval($uid));

if ($parent AND !isset($params["type"])) {
if ($parent && !isset($params["type"])) {
$params["type"] = NOTIFY_COMMENT;
$params["verb"] = ACTIVITY_POST;
}


+ 2
- 2
include/follow.php View File

@@ -30,10 +30,10 @@ function update_contact($id) {

// make sure to not overwrite existing values with blank entries
foreach ($ret AS $key => $val) {
if (isset($r[0][$key]) AND ($r[0][$key] != "") AND ($val == ""))
if (isset($r[0][$key]) && ($r[0][$key] != "") && ($val == ""))
$ret[$key] = $r[0][$key];

if (isset($r[0][$key]) AND ($ret[$key] != $r[0][$key]))
if (isset($r[0][$key]) && ($ret[$key] != $r[0][$key]))
$update = true;
}



+ 1
- 1
include/gprobe.php View File

@@ -47,7 +47,7 @@ function gprobe_run(&$argv, &$argc){
}
if (dbm::is_result($r)) {
// Check for accessibility and do a poco discovery
if (poco_last_updated($r[0]['url'], true) AND ($r[0]["network"] == NETWORK_DFRN))
if (poco_last_updated($r[0]['url'], true) && ($r[0]["network"] == NETWORK_DFRN))
poco_load(0,0,$r[0]['id'], str_replace('/profile/','/poco/',$r[0]['url']));
}



+ 2
- 2
include/group.php View File

@@ -22,7 +22,7 @@ function group_add($uid,$name) {
intval($uid),
dbesc($name)
);
notice( t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
notice( t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
}
return true;
}
@@ -320,7 +320,7 @@ function expand_groups($a,$check_dead = false, $use_gcontact = false) {
if (dbm::is_result($r))
foreach ($r as $rr)
$ret[] = $rr['contact-id'];
if ($check_dead AND !$use_gcontact) {
if ($check_dead && !$use_gcontact) {
require_once('include/acl_selectors.php');
$ret = prune_deadguys($ret);
}


+ 1
- 1
include/html2plain.php View File

@@ -212,7 +212,7 @@ function html2plain($html, $wraplength = 75, $compact = false)

$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');

if (!$compact AND ($message != "")) {
if (!$compact && ($message != "")) {
$counter = 1;
foreach ($urls as $id=>$url)
if ($url != "")


+ 6
- 6
include/identity.php View File

@@ -217,7 +217,7 @@ function profile_sidebar($profile, $block = 0) {

$profile['picdate'] = urlencode($profile['picdate']);

if (($profile['network'] != "") AND ($profile['network'] != NETWORK_DFRN)) {
if (($profile['network'] != "") && ($profile['network'] != NETWORK_DFRN)) {
$profile['network_name'] = format_network_name($profile['network'], $profile['url']);
} else {
$profile['network_name'] = "";
@@ -240,7 +240,7 @@ function profile_sidebar($profile, $block = 0) {
}

// Is the local user already connected to that user?
if ($connect AND local_user()) {
if ($connect && local_user()) {
if (isset($profile["url"])) {
$profile_url = normalise_link($profile["url"]);
} else {
@@ -254,19 +254,19 @@ function profile_sidebar($profile, $block = 0) {
$connect = false;
}

if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect']))
if ($connect && ($profile['network'] != NETWORK_DFRN) && !isset($profile['remoteconnect']))
$connect = false;

$remoteconnect = NULL;
if (isset($profile['remoteconnect']))
$remoteconnect = $profile['remoteconnect'];

if ($connect AND ($profile['network'] == NETWORK_DFRN) AND !isset($remoteconnect))
if ($connect && ($profile['network'] == NETWORK_DFRN) && !isset($remoteconnect))
$subscribe_feed = t("Atom feed");
else
$subscribe_feed = false;

if (remote_user() OR (get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user()))) {
if (remote_user() || (get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user()))) {
$wallmessage = t('Message');
$wallmessage_link = "wallmessage/".$profile["nickname"];

@@ -379,7 +379,7 @@ function profile_sidebar($profile, $block = 0) {
if (!$block) {
$contact_block = contact_block();

if (is_array($a->profile) AND !$a->profile['hide-friends']) {
if (is_array($a->profile) && !$a->profile['hide-friends']) {
$r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
intval($a->profile['uid']));
if (dbm::is_result($r))


+ 29
- 29
include/items.php View File

@@ -159,16 +159,16 @@ function add_page_info_data($data) {

// It maybe is a rich content, but if it does have everything that a link has,
// then treat it that way
if (($data["type"] == "rich") AND is_string($data["title"]) AND
is_string($data["text"]) AND (sizeof($data["images"]) > 0)) {
if (($data["type"] == "rich") && is_string($data["title"]) &&
is_string($data["text"]) && (sizeof($data["images"]) > 0)) {
$data["type"] = "link";
}

if ((($data["type"] != "link") AND ($data["type"] != "video") AND ($data["type"] != "photo")) OR ($data["title"] == $data["url"])) {
if ((($data["type"] != "link") && ($data["type"] != "video") && ($data["type"] != "photo")) || ($data["title"] == $data["url"])) {
return "";
}

if ($no_photos AND ($data["type"] == "photo")) {
if ($no_photos && ($data["type"] == "photo")) {
return "";
}

@@ -204,7 +204,7 @@ function add_page_info_data($data) {
$preview = str_replace(array("[", "]"), array("&#91;", "&#93;"), htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false));
// if the preview picture is larger than 500 pixels then show it in a larger mode
// But only, if the picture isn't higher than large (To prevent huge posts)
if (($data["images"][0]["width"] >= 500) AND ($data["images"][0]["width"] >= $data["images"][0]["height"])) {
if (($data["images"][0]["width"] >= 500) && ($data["images"][0]["width"] >= $data["images"][0]["height"])) {
$text .= " image='".$preview."'";
} else {
$text .= " preview='".$preview."'";
@@ -214,7 +214,7 @@ function add_page_info_data($data) {
$text .= "]".$data["text"]."[/attachment]";

$hashtags = "";
if (isset($data["keywords"]) AND count($data["keywords"])) {
if (isset($data["keywords"]) && count($data["keywords"])) {
$hashtags = "\n";
foreach ($data["keywords"] AS $keyword) {
/// @todo make a positive list of allowed characters
@@ -237,11 +237,11 @@ function query_page_info($url, $no_photos = false, $photo = "", $keywords = fals

logger('fetch page info for ' . $url . ' ' . print_r($data, true), LOGGER_DEBUG);

if (!$keywords AND isset($data["keywords"])) {
if (!$keywords && isset($data["keywords"])) {
unset($data["keywords"]);
}

if (($keyword_blacklist != "") AND isset($data["keywords"])) {
if (($keyword_blacklist != "") && isset($data["keywords"])) {
$list = explode(", ", $keyword_blacklist);
foreach ($list AS $keyword) {
$keyword = trim($keyword);
@@ -259,7 +259,7 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
$data = query_page_info($url, $no_photos, $photo, $keywords, $keyword_blacklist);

$tags = "";
if (isset($data["keywords"]) AND count($data["keywords"])) {
if (isset($data["keywords"]) && count($data["keywords"])) {
foreach ($data["keywords"] AS $keyword) {
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"),
array("", "", "", "", "", ""), $keyword);
@@ -301,7 +301,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
}

// Convert urls without bbcode elements
if (!$matches AND $texturl) {
if (!$matches && $texturl) {
preg_match("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", " ".$body, $matches);

// Yeah, a hack. I really hate regular expressions :)
@@ -315,21 +315,21 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
}

// Remove the link from the body if the link is attached at the end of the post
if (isset($footer) AND (trim($footer) != "") AND (strpos($footer, $matches[1]))) {
if (isset($footer) && (trim($footer) != "") && (strpos($footer, $matches[1]))) {
$removedlink = trim(str_replace($matches[1], "", $body));
if (($removedlink == "") OR strstr($body, $removedlink)) {
if (($removedlink == "") || strstr($body, $removedlink)) {
$body = $removedlink;
}

$url = str_replace(array('/', '.'), array('\/', '\.'), $matches[1]);
$removedlink = preg_replace("/\[url\=" . $url . "\](.*?)\[\/url\]/ism", '', $body);
if (($removedlink == "") OR strstr($body, $removedlink)) {
if (($removedlink == "") || strstr($body, $removedlink)) {
$body = $removedlink;
}
}

// Add the page information to the bottom
if (isset($footer) AND (trim($footer) != "")) {
if (isset($footer) && (trim($footer) != "")) {
$body .= $footer;
}

@@ -421,10 +421,10 @@ function store_conversation($arr) {
if (in_array($arr['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
$conversation = array('item-uri' => $arr['uri'], 'received' => dbm::date());

if (isset($arr['parent-uri']) AND ($arr['parent-uri'] != $arr['uri'])) {
if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) {
$conversation['reply-to-uri'] = $arr['parent-uri'];
}
if (isset($arr['thr-parent']) AND ($arr['thr-parent'] != $arr['uri'])) {
if (isset($arr['thr-parent']) && ($arr['thr-parent'] != $arr['uri'])) {
$conversation['reply-to-uri'] = $arr['thr-parent'];
}

@@ -453,7 +453,7 @@ function store_conversation($arr) {
unset($old_conv['source']);
}
// Update structure data all the time but the source only when its from a better protocol.
if (($old_conv['protocol'] < $conversation['protocol']) AND ($old_conv['protocol'] != 0)) {
if (($old_conv['protocol'] < $conversation['protocol']) && ($old_conv['protocol'] != 0)) {
unset($conversation['protocol']);
unset($conversation['source']);
}
@@ -503,9 +503,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f

if ($notify) {
$guid_prefix = "";
} elseif ((trim($arr['guid']) == "") AND (trim($arr['plink']) != "")) {
} elseif ((trim($arr['guid']) == "") && (trim($arr['plink']) != "")) {
$arr['guid'] = uri_to_guid($arr['plink']);
} elseif ((trim($arr['guid']) == "") AND (trim($arr['uri']) != "")) {
} elseif ((trim($arr['guid']) == "") && (trim($arr['uri']) != "")) {
$arr['guid'] = uri_to_guid($arr['uri']);
} else {
$parsed = parse_url($arr["author-link"]);
@@ -653,7 +653,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
$arr['edited'] = datetime_convert();
}

if (($arr['author-link'] == "") AND ($arr['owner-link'] == "")) {
if (($arr['author-link'] == "") && ($arr['owner-link'] == "")) {
logger("Both author-link and owner-link are empty. Called by: " . App::callstack(), LOGGER_DEBUG);
}

@@ -832,7 +832,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
$a = get_app();
$self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
if ((normalise_link($arr['author-link']) == $self) OR (normalise_link($arr['owner-link']) == $self)) {
if ((normalise_link($arr['author-link']) == $self) || (normalise_link($arr['owner-link']) == $self)) {
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id));
logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
}
@@ -1051,7 +1051,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f

// update the commented timestamp on the parent
// Only update "commented" if it is really a comment