From 9c0d2c31e87a73f157b360c518eb059e9a2507de Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 7 Jun 2017 22:00:59 -0400 Subject: [PATCH 1/4] Replace AND and OR in PHP conditions by && and || --- boot.php | 20 ++-- include/Contact.php | 26 ++--- include/Photo.php | 12 +-- include/acl_selectors.php | 4 +- include/api.php | 60 +++++------ include/auth.php | 2 +- include/bbcode.php | 36 +++---- include/cache.php | 10 +- include/contact_selectors.php | 2 +- include/contact_widgets.php | 2 +- include/conversation.php | 6 +- include/cron.php | 6 +- include/cronhooks.php | 4 +- include/dba.php | 22 ++-- include/dba_pdo.php | 4 +- include/dbclean.php | 4 +- include/dbm.php | 2 +- include/dbstructure.php | 10 +- include/delivery.php | 6 +- include/dfrn.php | 36 +++---- include/diaspora.php | 60 +++++------ include/discover_poco.php | 10 +- include/enotify.php | 12 +-- include/follow.php | 4 +- include/gprobe.php | 2 +- include/group.php | 4 +- include/html2plain.php | 2 +- include/identity.php | 12 +-- include/items.php | 58 +++++------ include/nav.php | 2 +- include/network.php | 14 +-- include/notifier.php | 10 +- include/oembed.php | 4 +- include/onepoll.php | 4 +- include/ostatus.php | 78 +++++++------- include/photos.php | 2 +- include/pidfile.php | 2 +- include/plaintext.php | 30 +++--- include/plugin.php | 2 +- include/poller.php | 12 +-- include/post_update.php | 6 +- include/queue.php | 4 +- include/session.php | 2 +- include/socgraph.php | 108 ++++++++++---------- include/spool_post.php | 6 +- include/tags.php | 4 +- include/text.php | 10 +- include/threads.php | 8 +- include/update_gcontact.php | 8 +- include/xml.php | 12 +-- index.php | 14 +-- mod/admin.php | 12 +-- mod/community.php | 4 +- mod/contacts.php | 12 +-- mod/dfrn_request.php | 8 +- mod/dirfind.php | 4 +- mod/display.php | 8 +- mod/events.php | 2 +- mod/fetch.php | 2 +- mod/follow.php | 4 +- mod/item.php | 26 ++--- mod/network.php | 4 +- mod/nodeinfo.php | 16 +-- mod/noscrape.php | 4 +- mod/photo.php | 2 +- mod/ping.php | 12 +-- mod/poco.php | 16 +-- mod/proxy.php | 26 ++--- mod/register.php | 2 +- mod/search.php | 6 +- mod/settings.php | 10 +- mod/update_network.php | 2 +- object/Item.php | 18 ++-- src/App.php | 10 +- src/Core/Config.php | 4 +- src/Core/PConfig.php | 4 +- src/Network/Probe.php | 164 +++++++++++++++--------------- src/Util/Lock.php | 10 +- update.php | 2 +- util/maintenance.php | 2 +- view/theme/frio/php/frio_boot.php | 4 +- view/theme/vier/style.php | 2 +- view/theme/vier/theme.php | 10 +- 83 files changed, 596 insertions(+), 596 deletions(-) diff --git a/boot.php b/boot.php index 15341c0fed..6fd7c30372 100644 --- a/boot.php +++ b/boot.php @@ -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); } diff --git a/include/Contact.php b/include/Contact.php index bb6d8c1981..0aeabc9725 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -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 .= ', '; diff --git a/include/Photo.php b/include/Photo.php index 5920f80b38..5c3a52ffd5 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -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; diff --git a/include/acl_selectors.php b/include/acl_selectors.php index c7c6bb206a..665ed17bdf 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -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 .= "\r\n"; - if ($privmail AND $preselected) { + if ($privmail && $preselected) { $o .= implode(", ", $receiverlist); } diff --git a/include/api.php b/include/api.php index 5d962ecd03..bc40e420b0 100644 --- a/include/api.php +++ b/include/api.php @@ -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 = "

" . bbcode($item['title']) . "

\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"])) diff --git a/include/auth.php b/include/auth.php index 5dfe9d3e06..d301f87055 100644 --- a/include/auth.php +++ b/include/auth.php @@ -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')) diff --git a/include/bbcode.php b/include/bbcode.php index 9a43cdb305..2b2d7fc937 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -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('%s
', $data["url"], $data["title"]); } else { $text = sprintf('', $data["type"]); @@ -71,13 +71,13 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { if (strstr(strtolower($oembed), "