Merge pull request #3528 from Hypolite/task/replace-explicit-php-logical-operators

Replace explicit php logical operators
This commit is contained in:
Tobias Diekershoff 2017-06-09 07:44:19 +02:00 committed by GitHub
commit 1838024f6d
93 changed files with 677 additions and 676 deletions

View file

@ -770,7 +770,7 @@ function admin_page_site_post(App $a) {
$worker_frontend = ((x($_POST,'worker_frontend')) ? True : False);
// Has the directory url changed? If yes, then resubmit the existing profiles there
if ($global_directory != Config::get('system', 'directory') AND ($global_directory != '')) {
if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
Config::set('system', 'directory', $global_directory);
proc_run(PRIORITY_LOW, 'include/directory.php');
}
@ -936,7 +936,7 @@ function admin_page_site(App $a) {
/* Installed langs */
$lang_choices = get_available_languages();
if (strlen(get_config('system','directory_submit_url')) AND
if (strlen(get_config('system','directory_submit_url')) &&
!strlen(get_config('system','directory'))) {
set_config('system','directory', dirname(get_config('system','directory_submit_url')));
del_config('system','directory_submit_url');
@ -958,7 +958,7 @@ function admin_page_site(App $a) {
$f = basename($file);
// Only show allowed themes here
if (($allowed_theme_list != '') AND !strstr($allowed_theme_list, $f)) {
if (($allowed_theme_list != '') && !strstr($allowed_theme_list, $f)) {
continue;
}
@ -1183,7 +1183,7 @@ function admin_page_dbsync(App $a) {
goaway('admin/dbsync');
}
if (($a->argc > 2) AND (intval($a->argv[2]) OR ($a->argv[2] === 'check'))) {
if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) {
require_once("include/dbstructure.php");
$retval = update_structure(false, true);
if (!$retval) {
@ -1663,7 +1663,7 @@ function admin_page_plugins(App $a) {
$show_plugin = true;
// If the addon is unsupported, then only show it, when it is enabled
if ((strtolower($info["status"]) == "unsupported") AND !in_array($id, $a->plugins)) {
if ((strtolower($info["status"]) == "unsupported") && !in_array($id, $a->plugins)) {
$show_plugin = false;
}
@ -1801,7 +1801,7 @@ function admin_page_themes(App $a) {
$is_supported = 1-(intval(file_exists($file.'/unsupported')));
$is_allowed = intval(in_array($f,$allowed_themes));
if ($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes")) {
if ($is_allowed || $is_supported || get_config("system", "show_unsupported_themes")) {
$themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
}
}

View file

@ -68,14 +68,14 @@ function community_content(App $a, $update = 0) {
}
$previousauthor = $item["author-link"];
if (($numposts < $maxpostperauthor) AND (sizeof($s) < $a->pager['itemspage'])) {
if (($numposts < $maxpostperauthor) && (sizeof($s) < $a->pager['itemspage'])) {
$s[] = $item;
}
}
if ((sizeof($s) < $a->pager['itemspage'])) {
$r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
}
} while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
} while ((sizeof($s) < $a->pager['itemspage']) && (++$count < 50) && (sizeof($r) > 0));
} else {
$s = $r;
}

View file

@ -17,7 +17,7 @@ function contacts_init(App $a) {
$contact_id = 0;
if((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
if((($a->argc == 2) && intval($a->argv[1])) || (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()),
@ -42,7 +42,7 @@ function contacts_init(App $a) {
if ($contact_id) {
$a->data['contact'] = $r[0];
if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) {
if (($a->data['contact']['network'] != "") && ($a->data['contact']['network'] != NETWORK_DFRN)) {
$networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']);
} else {
$networkname = '';
@ -266,7 +266,7 @@ function _contact_update_profile($contact_id) {
$data = Probe::uri($r[0]["url"], "", 0, false);
// "Feed" or "Unknown" is mostly a sign of communication problems
if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"]))
if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) && ($data["network"] != $r[0]["network"]))
return;
$updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm",
@ -281,14 +281,14 @@ function _contact_update_profile($contact_id) {
}
foreach($updatefields AS $field)
if (isset($data[$field]) AND ($data[$field] != ""))
if (isset($data[$field]) && ($data[$field] != ""))
$update[$field] = $data[$field];
$update["nurl"] = normalise_link($data["url"]);
$query = "";
if (isset($data["priority"]) AND ($data["priority"] != 0))
if (isset($data["priority"]) && ($data["priority"] != 0))
$query = "`priority` = ".intval($data["priority"]);
foreach($update AS $key => $value) {
@ -573,7 +573,7 @@ function contacts_content(App $a) {
if ($contact['network'] == NETWORK_DFRN)
$profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false));
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) &&
($contact['rel'] == CONTACT_IS_FOLLOWER))
$follow = App::get_baseurl(true)."/follow?url=".urlencode($contact["url"]);

View file

@ -626,7 +626,7 @@ function dfrn_request_post(App $a) {
);
// NOTREACHED
// END $network === NETWORK_DFRN
} elseif (($network != NETWORK_PHANTOM) AND ($url != "")) {
} elseif (($network != NETWORK_PHANTOM) && ($url != "")) {
/*
*
@ -693,7 +693,7 @@ function dfrn_request_content(App $a) {
$confirm_key = (x($_GET,'confirm_key') ? $_GET['confirm_key'] : "");
// Checking fastlane for validity
if (x($_SESSION, "fastlane") AND (normalise_link($_SESSION["fastlane"]) == normalise_link($dfrn_url))) {
if (x($_SESSION, "fastlane") && (normalise_link($_SESSION["fastlane"]) == normalise_link($dfrn_url))) {
$_POST["dfrn_url"] = $dfrn_url;
$_POST["confirm_key"] = $confirm_key;
$_POST["localconfirm"] = 1;
@ -813,9 +813,9 @@ function dfrn_request_content(App $a) {
// At first look if an address was provided
// Otherwise take the local address
if (x($_GET,'addr') AND ($_GET['addr'] != "")) {
if (x($_GET,'addr') && ($_GET['addr'] != "")) {
$myaddr = hex2bin($_GET['addr']);
} elseif (x($_GET,'address') AND ($_GET['address'] != "")) {
} elseif (x($_GET,'address') && ($_GET['address'] != "")) {
$myaddr = $_GET['address'];
} elseif (local_user()) {
if (strlen($a->path)) {

View file

@ -37,7 +37,7 @@ function dirfind_content(App $a, $prefix = "") {
if (strpos($search,'@') === 0) {
$search = substr($search,1);
$header = sprintf( t('People Search - %s'), $search);
if ((valid_email($search) AND validate_email($search)) OR
if ((valid_email($search) && validate_email($search)) ||
(substr(normalise_link($search), 0, 7) == "http://")) {
$user_data = probe_url($search);
$discover_user = (in_array($user_data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)));
@ -75,7 +75,7 @@ function dirfind_content(App $a, $prefix = "") {
$j->results[] = $objresult;
// Add the contact to the global contacts if it isn't already in our system
if (($contact["cid"] == 0) AND ($contact["zid"] == 0) AND ($contact["gid"] == 0)) {
if (($contact["cid"] == 0) && ($contact["zid"] == 0) && ($contact["gid"] == 0)) {
update_gcontact($user_data);
}
} elseif ($local) {

View file

@ -71,7 +71,7 @@ function display_init(App $a) {
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `id` = %d", $r[0]["parent"]);
}
if (($itemuid != local_user()) AND local_user()) {
if (($itemuid != local_user()) && local_user()) {
// Do we know this contact but we haven't got this item?
// Copy the wohle thread to our local storage so that we can interact.
// We really should change this need for the future since it scales very bad.
@ -141,11 +141,11 @@ function display_fetchauthor($a, $item) {
// Skip if it isn't a pure repeated messages
// Does it start with a share?
if (!$skip AND strpos($body, "[share") > 0) {
if (!$skip && strpos($body, "[share") > 0) {
$skip = true;
}
// Does it end with a share?
if (!$skip AND (strlen($body) > (strrpos($body, "[/share]") + 8))) {
if (!$skip && (strlen($body) > (strrpos($body, "[/share]") + 8))) {
$skip = true;
}
if (!$skip) {
@ -274,7 +274,7 @@ function display_content(App $a, $update = 0) {
}
}
if ($item_id AND !is_numeric($item_id)) {
if ($item_id && !is_numeric($item_id)) {
$r = qu("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), intval($a->profile['uid']));
if (dbm::is_result($r)) {

View file

@ -436,7 +436,7 @@ function events_content(App $a) {
$sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ');
}
if ($cid OR ($mode !== 'new')) {
if ($cid || ($mode !== 'new')) {
$sh_checked .= ' disabled="disabled" ';
}

View file

@ -11,7 +11,7 @@ require_once("include/xml.php");
function fetch_init(App $a) {
if (($a->argc != 3) OR (!in_array($a->argv[1], array("post", "status_message", "reshare")))) {
if (($a->argc != 3) || (!in_array($a->argv[1], array("post", "status_message", "reshare")))) {
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
killme();
}

View file

@ -37,14 +37,14 @@ function follow_content(App $a) {
$ret = probe_url($url);
if (($ret["network"] == NETWORK_DIASPORA) AND !get_config('system','diaspora_enabled')) {
if (($ret["network"] == NETWORK_DIASPORA) && !get_config('system','diaspora_enabled')) {
notice( t("Diaspora support isn't enabled. Contact can't be added.") . EOL);
$submit = "";
//goaway($_SESSION['return_url']);
// NOTREACHED
}
if (($ret["network"] == NETWORK_OSTATUS) AND get_config('system','ostatus_disabled')) {
if (($ret["network"] == NETWORK_OSTATUS) && get_config('system','ostatus_disabled')) {
notice( t("OStatus support is disabled. Contact can't be added.") . EOL);
$submit = "";
//goaway($_SESSION['return_url']);

View file

@ -139,8 +139,8 @@ function item_post(App $a) {
// If the contact id doesn't fit with the contact, then set the contact to null
$thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent));
if (dbm::is_result($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS)
AND (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) {
if (dbm::is_result($thrparent) && ($thrparent[0]["network"] === NETWORK_OSTATUS)
&& (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) {
$parent_contact = get_contact_details_by_url($thrparent[0]["author-link"]);
if (!isset($parent_contact["nick"])) {
@ -175,7 +175,7 @@ function item_post(App $a) {
$object = ((x($_REQUEST, 'object')) ? $_REQUEST['object'] : '');
// Check for multiple posts with the same message id (when the post was created via API)
if (($message_id != '') AND ($profile_uid != 0)) {
if (($message_id != '') && ($profile_uid != 0)) {
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($message_id),
intval($profile_uid)
@ -309,8 +309,8 @@ function item_post(App $a) {
// for non native networks use the network of the original post as network of the item
if (($parent_item['network'] != NETWORK_DIASPORA)
AND ($parent_item['network'] != NETWORK_OSTATUS)
AND ($network == "")) {
&& ($parent_item['network'] != NETWORK_OSTATUS)
&& ($network == "")) {
$network = $parent_item['network'];
}
@ -504,7 +504,7 @@ function item_post(App $a) {
$bookmark = 0;
$data = get_attachment_data($body);
if (preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) OR isset($data["type"])) {
if (preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"])) {
$objecttype = ACTIVITY_OBJ_BOOKMARK;
$bookmark = 1;
}
@ -543,7 +543,7 @@ function item_post(App $a) {
* add a statusnet style reply tag if the original post was from there
* and we are replying, and there isn't one already
*/
if ($parent AND ($parent_contact['network'] == NETWORK_OSTATUS)) {
if ($parent && ($parent_contact['network'] == NETWORK_OSTATUS)) {
$contact = '@[url=' . $parent_contact['url'] . ']' . $parent_contact['nick'] . '[/url]';
if (!in_array($contact, $tags)) {
@ -1226,7 +1226,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
}
// select someone by attag or nick and the name passed in the current network
if(!dbm::is_result($r) AND ($network != ""))
if(!dbm::is_result($r) && ($network != ""))
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
dbesc($name),
dbesc($name),
@ -1235,7 +1235,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
);
//select someone from this user's contacts by name in the current network
if (!dbm::is_result($r) AND ($network != "")) {
if (!dbm::is_result($r) && ($network != "")) {
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
dbesc($name),
dbesc($network),
@ -1262,7 +1262,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
}
if (dbm::is_result($r)) {
if (strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"]))) {
if (strlen($inform) && (isset($r[0]["notify"]) || isset($r[0]["id"]))) {
$inform .= ',';
}
@ -1275,14 +1275,14 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
$profile = $r[0]["url"];
$alias = $r[0]["alias"];
$newname = $r[0]["nick"];
if (($newname == "") OR (($r[0]["network"] != NETWORK_OSTATUS) AND ($r[0]["network"] != NETWORK_TWITTER)
AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET))) {
if (($newname == "") || (($r[0]["network"] != NETWORK_OSTATUS) && ($r[0]["network"] != NETWORK_TWITTER)
&& ($r[0]["network"] != NETWORK_STATUSNET) && ($r[0]["network"] != NETWORK_APPNET))) {
$newname = $r[0]["name"];
}
}
//if there is an url for this persons profile
if (isset($profile) AND ($newname != "")) {
if (isset($profile) && ($newname != "")) {
$replaced = true;
// create profile link

View file

@ -398,7 +398,7 @@ function network_content(App $a, $update = 0) {
}
set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
if(!$update AND !$rawmode) {
if(!$update && !$rawmode) {
$tabs = network_tabs($a);
$o .= $tabs;
@ -459,7 +459,7 @@ function network_content(App $a, $update = 0) {
$sql_table = "`thread`";
$sql_parent = "`iid`";
if ($nouveau OR strlen($file) OR $update) {
if ($nouveau || strlen($file) || $update) {
$sql_table = "`item`";
$sql_parent = "`parent`";
$sql_post_table = " INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`";

View file

@ -25,12 +25,12 @@ function nodeinfo_init(App $a) {
killme();
}
if (($a->argc != 2) OR ($a->argv[1] != '1.0')) {
if (($a->argc != 2) || ($a->argv[1] != '1.0')) {
http_status_exit(404);
killme();
}
$smtp = (function_exists('imap_open') AND !Config::get('system', 'imap_disabled') AND !Config::get('system', 'dfrn_only'));
$smtp = (function_exists('imap_open') && !Config::get('system', 'imap_disabled') && !Config::get('system', 'dfrn_only'));
$nodeinfo = array();
$nodeinfo['version'] = '1.0';
@ -74,7 +74,7 @@ function nodeinfo_init(App $a) {
if (plugin_enabled('appnet')) {
$nodeinfo['services']['inbound'][] = 'appnet';
}
if (plugin_enabled('appnet') OR plugin_enabled('buffer')) {
if (plugin_enabled('appnet') || plugin_enabled('buffer')) {
$nodeinfo['services']['outbound'][] = 'appnet';
}
if (plugin_enabled('blogger')) {
@ -83,7 +83,7 @@ function nodeinfo_init(App $a) {
if (plugin_enabled('dwpost')) {
$nodeinfo['services']['outbound'][] = 'dreamwidth';
}
if (plugin_enabled('fbpost') OR plugin_enabled('buffer')) {
if (plugin_enabled('fbpost') || plugin_enabled('buffer')) {
$nodeinfo['services']['outbound'][] = 'facebook';
}
if (plugin_enabled('statusnet')) {
@ -91,7 +91,7 @@ function nodeinfo_init(App $a) {
$nodeinfo['services']['outbound'][] = 'gnusocial';
}
if (plugin_enabled('gpluspost') OR plugin_enabled('buffer')) {
if (plugin_enabled('gpluspost') || plugin_enabled('buffer')) {
$nodeinfo['services']['outbound'][] = 'google';
}
if (plugin_enabled('ijpost')) {
@ -123,7 +123,7 @@ function nodeinfo_init(App $a) {
if (plugin_enabled('tumblr')) {
$nodeinfo['services']['outbound'][] = 'tumblr';
}
if (plugin_enabled('twitter') OR plugin_enabled('buffer')) {
if (plugin_enabled('twitter') || plugin_enabled('buffer')) {
$nodeinfo['services']['outbound'][] = 'twitter';
}
if (plugin_enabled('wppost')) {
@ -203,11 +203,11 @@ function nodeinfo_cron() {
$month = time() - (30 * 24 * 60 * 60);
foreach ($users AS $user) {
if ((strtotime($user['login_date']) > $halfyear) OR
if ((strtotime($user['login_date']) > $halfyear) ||
(strtotime($user['last-item']) > $halfyear)) {
++$active_users_halfyear;
}
if ((strtotime($user['login_date']) > $month) OR
if ((strtotime($user['login_date']) > $month) ||
(strtotime($user['last-item']) > $month)) {
++$active_users_monthly;
}

View file

@ -17,7 +17,7 @@ function noscrape_init(App $a) {
profile_load($a,$which,$profile);
if (!$a->profile['net-publish'] OR $a->profile['hidewall']) {
if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
header('Content-type: application/json; charset=utf-8');
$json_info = array("hide" => true);
echo json_encode($json_info);
@ -42,7 +42,7 @@ function noscrape_init(App $a) {
'tags' => $keywords
);
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)) {

View file

@ -119,7 +119,7 @@ function photo_init(App $a) {
intval($resolution)
);
$public = (dbm::is_result($r)) AND ($r[0]['allow_cid'] == '') AND ($r[0]['allow_gid'] == '') AND ($r[0]['deny_cid'] == '') AND ($r[0]['deny_gid'] == '');
$public = (dbm::is_result($r)) && ($r[0]['allow_cid'] == '') && ($r[0]['allow_gid'] == '') && ($r[0]['deny_cid'] == '') && ($r[0]['deny_gid'] == '');
if (dbm::is_result($r)) {
$resolution = $r[0]['scale'];

View file

@ -330,10 +330,10 @@ function ping_init(App $a)
if (dbm::is_result($notifs)) {
// Are the nofications called from the regular process or via the friendica app?
$regularnotifications = (intval($_GET['uid']) AND intval($_GET['_']));
$regularnotifications = (intval($_GET['uid']) && intval($_GET['_']));
foreach ($notifs as $notif) {
if ($a->is_friendica_app() OR !$regularnotifications) {
if ($a->is_friendica_app() || !$regularnotifications) {
$notif['message'] = str_replace("{0}", $notif['name'], $notif['message']);
}
@ -434,7 +434,7 @@ function ping_get_notifications($uid)
intval($offset)
);
if (!$r AND !$seen) {
if (!$r && !$seen) {
$seen = true;
$seensql = "";
$order = "DESC";
@ -474,12 +474,12 @@ function ping_get_notifications($uid)
$notification["href"] = App::get_baseurl() . "/notify/view/" . $notification["id"];
if ($notification["visible"] AND !$notification["spam"] AND
!$notification["deleted"] AND !is_array($result[$notification["parent"]])) {
if ($notification["visible"] && !$notification["spam"] &&
!$notification["deleted"] && !is_array($result[$notification["parent"]])) {
$result[$notification["parent"]] = $notification;
}
}
} while ((count($result) < 50) AND !$quit);
} while ((count($result) < 50) && !$quit);
return($result);
}

View file

@ -55,7 +55,7 @@ function poco_init(App $a) {
$cid = intval($a->argv[4]);
}
if (! $system_mode AND ! $global) {
if (! $system_mode && ! $global) {
$users = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid`
where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1",
dbesc($user)
@ -157,7 +157,7 @@ function poco_init(App $a) {
if (x($_GET, 'filtered')) {
$ret['filtered'] = false;
}
if (x($_GET, 'updatedSince') AND ! $global) {
if (x($_GET, 'updatedSince') && ! $global) {
$ret['updatedSince'] = false;
}
$ret['startIndex'] = (int) $startIndex;
@ -207,21 +207,21 @@ function poco_init(App $a) {
}
}
if (($contact['about'] == "") AND isset($contact['pabout'])) {
if (($contact['about'] == "") && isset($contact['pabout'])) {
$contact['about'] = $contact['pabout'];
}
if ($contact['location'] == "") {
if (isset($contact['plocation'])) {
$contact['location'] = $contact['plocation'];
}
if (isset($contact['pregion']) AND ( $contact['pregion'] != "")) {
if (isset($contact['pregion']) && ( $contact['pregion'] != "")) {
if ($contact['location'] != "") {
$contact['location'] .= ", ";
}
$contact['location'] .= $contact['pregion'];
}
if (isset($contact['pcountry']) AND ( $contact['pcountry'] != "")) {
if (isset($contact['pcountry']) && ( $contact['pcountry'] != "")) {
if ($contact['location'] != "") {
$contact['location'] .= ", ";
}
@ -229,10 +229,10 @@ function poco_init(App $a) {
}
}
if (($contact['gender'] == "") AND isset($contact['pgender'])) {
if (($contact['gender'] == "") && isset($contact['pgender'])) {
$contact['gender'] = $contact['pgender'];
}
if (($contact['keywords'] == "") AND isset($contact['pub_keywords'])) {
if (($contact['keywords'] == "") && isset($contact['pub_keywords'])) {
$contact['keywords'] = $contact['pub_keywords'];
}
if (isset($contact['account-type'])) {
@ -306,7 +306,7 @@ function poco_init(App $a) {
if ($entry['network'] == NETWORK_STATUSNET) {
$entry['network'] = NETWORK_OSTATUS;
}
if (($entry['network'] == "") AND ($contact['self'])) {
if (($entry['network'] == "") && ($contact['self'])) {
$entry['network'] = NETWORK_DFRN;
}
}

View file

@ -48,15 +48,15 @@ function proxy_init(App $a) {
$basepath = $a->get_basepath();
// If the cache path isn't there, try to create it
if (!is_dir($basepath . '/proxy') AND is_writable($basepath)) {
if (!is_dir($basepath . '/proxy') && is_writable($basepath)) {
mkdir($basepath . '/proxy');
}
// Checking if caching into a folder in the webroot is activated and working
$direct_cache = (is_dir($basepath . '/proxy') AND is_writable($basepath . '/proxy'));
$direct_cache = (is_dir($basepath . '/proxy') && is_writable($basepath . '/proxy'));
// Look for filename in the arguments
if ((isset($a->argv[1]) OR isset($a->argv[2]) OR isset($a->argv[3])) AND !isset($_REQUEST['url'])) {
if ((isset($a->argv[1]) || isset($a->argv[2]) || isset($a->argv[3])) && !isset($_REQUEST['url'])) {
if (isset($a->argv[3])) {
$url = $a->argv[3];
} elseif (isset($a->argv[2])) {
@ -65,7 +65,7 @@ function proxy_init(App $a) {
$url = $a->argv[1];
}
if (isset($a->argv[3]) AND ($a->argv[3] == 'thumb')) {
if (isset($a->argv[3]) && ($a->argv[3] == 'thumb')) {
$size = 200;
}
@ -112,7 +112,7 @@ function proxy_init(App $a) {
$urlhash = 'pic:' . sha1($_REQUEST['url']);
$cachefile = get_cachefile(hash('md5', $_REQUEST['url']));
if ($cachefile != '' AND file_exists($cachefile)) {
if ($cachefile != '' && file_exists($cachefile)) {
$img_str = file_get_contents($cachefile);
$mime = image_type_to_mime_type(exif_imagetype($cachefile));
@ -140,7 +140,7 @@ function proxy_init(App $a) {
$valid = true;
$r = array();
if (!$direct_cache AND ($cachefile == '')) {
if (!$direct_cache && ($cachefile == '')) {
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
if (dbm::is_result($r)) {
$img_str = $r[0]['data'];
@ -163,7 +163,7 @@ function proxy_init(App $a) {
unlink($tempfile);
// If there is an error then return a blank image
if ((substr($a->get_curl_code(), 0, 1) == '4') OR (!$img_str)) {
if ((substr($a->get_curl_code(), 0, 1) == '4') || (!$img_str)) {
$img_str = file_get_contents('images/blank.png');
$mime = 'image/png';
$cachefile = ''; // Clear the cachefile so that the dummy isn't stored
@ -173,7 +173,7 @@ function proxy_init(App $a) {
$img->scaleImage(10);
$img_str = $img->imageString();
}
} elseif ($mime != 'image/jpeg' AND !$direct_cache AND $cachefile == '') {
} elseif ($mime != 'image/jpeg' && !$direct_cache && $cachefile == '') {
$image = @imagecreatefromstring($img_str);
if ($image === FALSE) {
@ -199,7 +199,7 @@ function proxy_init(App $a) {
} else {
$img = new Photo($img_str, $mime);
if ($img->is_valid() AND !$direct_cache AND ($cachefile == '')) {
if ($img->is_valid() && !$direct_cache && ($cachefile == '')) {
$img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
}
}
@ -219,7 +219,7 @@ function proxy_init(App $a) {
// If there is a real existing directory then put the cache file there
// advantage: real file access is really fast
// Otherwise write in cachefile
if ($valid AND $direct_cache) {
if ($valid && $direct_cache) {
file_put_contents($basepath . '/proxy/' . proxy_url($_REQUEST['url'], true), $img_str_orig);
if ($sizetype != '') {
file_put_contents($basepath . '/proxy/' . proxy_url($_REQUEST['url'], true) . $sizetype, $img_str);
@ -282,7 +282,7 @@ function proxy_url($url, $writemode = false, $size = '') {
$shortpath = hash('md5', $url);
$longpath = substr($shortpath, 0, 2);
if (is_dir($basepath) AND $writemode AND !is_dir($basepath . '/' . $longpath)) {
if (is_dir($basepath) && $writemode && !is_dir($basepath . '/' . $longpath)) {
mkdir($basepath . '/' . $longpath);
chmod($basepath . '/' . $longpath, 0777);
}
@ -306,7 +306,7 @@ function proxy_url($url, $writemode = false, $size = '') {
// Too long files aren't supported by Apache
// Writemode in combination with long files shouldn't be possible
if ((strlen($proxypath) > 250) AND $writemode) {
if ((strlen($proxypath) > 250) && $writemode) {
return $shortpath;
} elseif (strlen($proxypath) > 250) {
return App::get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url);
@ -360,7 +360,7 @@ function proxy_parse_query($url) {
function proxy_img_cb($matches) {
// if the picture seems to be from another picture cache then take the original source
$queryvar = proxy_parse_query($matches[2]);
if (($queryvar['url'] != '') AND (substr($queryvar['url'], 0, 4) == 'http')) {
if (($queryvar['url'] != '') && (substr($queryvar['url'], 0, 4) == 'http')) {
$matches[2] = urldecode($queryvar['url']);
}

View file

@ -83,7 +83,7 @@ function register_post(App $a) {
}
// Only send a password mail when the password wasn't manually provided
if (!x($_POST,'password1') OR !x($_POST,'confirm')) {
if (!x($_POST,'password1') || !x($_POST,'confirm')) {
$res = send_register_open_eml(
$user['email'],
$a->config['sitename'],

View file

@ -97,7 +97,7 @@ function search_content(App $a) {
return;
}
if(get_config('system','local_search') AND !local_user()) {
if(get_config('system','local_search') && !local_user()) {
http_status_exit(403,
array("title" => t("Public access denied."),
"description" => t("Only logged in users are permitted to perform a search.")));
@ -106,7 +106,7 @@ function search_content(App $a) {
//return;
}
if (get_config('system','permit_crawling') AND !local_user()) {
if (get_config('system','permit_crawling') && !local_user()) {
// Default values:
// 10 requests are "free", after the 11th only a call per minute is allowed
@ -122,7 +122,7 @@ function search_content(App $a) {
$result = Cache::get("remote_search:".$remote);
if (!is_null($result)) {
$resultdata = json_decode($result);
if (($resultdata->time > (time() - $crawl_permit_period)) AND ($resultdata->accesses > $free_crawls)) {
if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
http_status_exit(429,
array("title" => t("Too Many Requests"),
"description" => t("Only one search per minute is permitted for not logged in users.")));

View file

@ -462,13 +462,13 @@ function settings_post(App $a) {
$notify += intval($_POST['notify8']);
// Adjust the page flag if the account type doesn't fit to the page flag.
if (($account_type == ACCOUNT_TYPE_PERSON) AND !in_array($page_flags, array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE)))
if (($account_type == ACCOUNT_TYPE_PERSON) && !in_array($page_flags, array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE)))
$page_flags = PAGE_NORMAL;
elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) AND !in_array($page_flags, array(PAGE_SOAPBOX)))
elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) && !in_array($page_flags, array(PAGE_SOAPBOX)))
$page_flags = PAGE_SOAPBOX;
elseif (($account_type == ACCOUNT_TYPE_NEWS) AND !in_array($page_flags, array(PAGE_SOAPBOX)))
elseif (($account_type == ACCOUNT_TYPE_NEWS) && !in_array($page_flags, array(PAGE_SOAPBOX)))
$page_flags = PAGE_SOAPBOX;
elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) AND !in_array($page_flags, array(PAGE_COMMUNITY, PAGE_PRVGROUP)))
elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) && !in_array($page_flags, array(PAGE_COMMUNITY, PAGE_PRVGROUP)))
$page_flags = PAGE_COMMUNITY;
$email_changed = false;
@ -949,7 +949,7 @@ function settings_content(App $a) {
$is_experimental = file_exists('view/theme/' . $th . '/experimental');
$unsupported = file_exists('view/theme/' . $th . '/unsupported');
$is_mobile = file_exists('view/theme/' . $th . '/mobile');
if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){
if (!$is_experimental || ($is_experimental && (get_config('experimentals','exp_themes')==1 || get_config('experimentals','exp_themes')===false))){
$theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
if ($is_mobile) {
$mobile_themes[$f]=$theme_name;
@ -1101,7 +1101,7 @@ function settings_content(App $a) {
// Set the account type to "Community" when the page is a community page but the account type doesn't fit
// This is only happening on the first visit after the update
if (in_array($a->user['page-flags'], array(PAGE_COMMUNITY, PAGE_PRVGROUP)) AND
if (in_array($a->user['page-flags'], array(PAGE_COMMUNITY, PAGE_PRVGROUP)) &&
($a->user['account-type'] != ACCOUNT_TYPE_COMMUNITY))
$a->user['account-type'] = ACCOUNT_TYPE_COMMUNITY;

View file

@ -15,7 +15,7 @@ function update_network_content(App $a) {
echo "<!DOCTYPE html><html><body>\r\n";
echo "<section>";
if (!get_pconfig($profile_uid, "system", "no_auto_update") OR ($_GET["force"] == 1)) {
if (!get_pconfig($profile_uid, "system", "no_auto_update") || ($_GET["force"] == 1)) {
$text = network_content($a, $profile_uid);
} else {
$text = "";