Replace x() by isset(), !empty() or defaults()

- Remove extraneous parentheses around empty() calls
- Remove duplicate calls to intval(), count() or strlen() after empty()
- Replace ternary operators outputting binary value with empty() return value
- Rewrite defaults() without x()
This commit is contained in:
Hypolite Petovan 2018-11-30 09:06:22 -05:00
parent ea4e772b1e
commit 458981f75c
101 changed files with 896 additions and 914 deletions

View file

@ -549,7 +549,7 @@ class App
// Use environment variables for mysql if they are set beforehand
if (!empty(getenv('MYSQL_HOST'))
&& (!empty(getenv('MYSQL_USERNAME')) || !empty(getenv('MYSQL_USER')))
&& !empty(getenv('MYSQL_USERNAME') || !empty(getenv('MYSQL_USER')))
&& getenv('MYSQL_PASSWORD') !== false
&& !empty(getenv('MYSQL_DATABASE')))
{
@ -668,7 +668,7 @@ class App
$this->hostname = Core\Config::get('config', 'hostname');
}
return $scheme . '://' . $this->hostname . (!empty($this->getURLPath()) ? '/' . $this->getURLPath() : '' );
return $scheme . '://' . $this->hostname . !empty($this->getURLPath() ? '/' . $this->getURLPath() : '' );
}
/**

View file

@ -58,7 +58,7 @@ class Nav
public static function build(App $a)
{
// Placeholder div for popup panel
$nav = '<div id="panel" style="display: none;"></div>' ;
$nav = '<div id="panel" style="display: none;"></div>';
$nav_info = self::getInfo($a);
@ -170,7 +170,7 @@ class Nav
// "Home" should also take you home from an authenticated remote profile connection
$homelink = Profile::getMyURL();
if (! $homelink) {
$homelink = ((x($_SESSION, 'visitor_home')) ? $_SESSION['visitor_home'] : '');
$homelink = defaults($_SESSION, 'visitor_home', '');
}
if (($a->module != 'home') && (! (local_user()))) {

View file

@ -308,12 +308,12 @@ class OEmbed
}
$domain = parse_url($url, PHP_URL_HOST);
if (!x($domain)) {
if (empty($domain)) {
return false;
}
$str_allowed = Config::get('system', 'allowed_oembed', '');
if (!x($str_allowed)) {
if (empty($str_allowed)) {
return false;
}
@ -334,7 +334,7 @@ class OEmbed
throw new Exception('OEmbed failed for URL: ' . $url);
}
if (x($title)) {
if (!empty($title)) {
$o->title = $title;
}

View file

@ -130,12 +130,12 @@ class BBCode extends BaseObject
$type = "";
preg_match("/type='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$type = strtolower($matches[1]);
}
preg_match('/type="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$type = strtolower($matches[1]);
}
@ -153,12 +153,12 @@ class BBCode extends BaseObject
$url = "";
preg_match("/url='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$url = $matches[1];
}
preg_match('/url="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$url = $matches[1];
}
@ -168,12 +168,12 @@ class BBCode extends BaseObject
$title = "";
preg_match("/title='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$title = $matches[1];
}
preg_match('/title="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$title = $matches[1];
}
@ -186,12 +186,12 @@ class BBCode extends BaseObject
$image = "";
preg_match("/image='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$image = $matches[1];
}
preg_match('/image="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$image = $matches[1];
}
@ -201,12 +201,12 @@ class BBCode extends BaseObject
$preview = "";
preg_match("/preview='(.*?)'/ism", $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$preview = $matches[1];
}
preg_match('/preview="(.*?)"/ism', $attributes, $matches);
if (x($matches, 1)) {
if (!empty($matches[1])) {
$preview = $matches[1];
}
@ -234,7 +234,7 @@ class BBCode extends BaseObject
*/
$has_title = !empty($item['title']);
$plink = (!empty($item['plink']) ? $item['plink'] : '');
$plink = defaults($item, 'plink', '');
$post = self::getAttachmentData($body);
// if nothing is found, it maybe having an image.
@ -1662,7 +1662,7 @@ class BBCode extends BaseObject
// Summary (e.g. title) is required, earlier revisions only required description (in addition to
// start which is always required). Allow desc with a missing summary for compatibility.
if ((x($ev, 'desc') || x($ev, 'summary')) && x($ev, 'start')) {
if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
$sub = Event::getHTML($ev, $simple_html);
$text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism", '', $text);

View file

@ -908,7 +908,7 @@ class HTML
public static function micropro($contact, $redirect = false, $class = '', $textmode = false)
{
// Use the contact URL if no address is available
if (!x($contact, "addr")) {
if (empty($contact['addr'])) {
$contact["addr"] = $contact["url"];
}
@ -924,7 +924,7 @@ class HTML
}
// If there is some js available we don't need the url
if (x($contact, 'click')) {
if (!empty($contact['click'])) {
$url = '';
}

View file

@ -106,7 +106,7 @@ class Authentication extends BaseObject
$masterUid = $user_record['uid'];
if ((x($_SESSION, 'submanage')) && intval($_SESSION['submanage'])) {
if (!empty($_SESSION['submanage'])) {
$user = DBA::selectFirst('user', ['uid'], ['uid' => $_SESSION['submanage']]);
if (DBA::isResult($user)) {
$masterUid = $user['uid'];

View file

@ -119,11 +119,11 @@ HELP;
$db_data = $this->getOption(['d', 'dbdata'], ($save_db) ? getenv('MYSQL_DATABASE') : '');
$db_user = $this->getOption(['U', 'dbuser'], ($save_db) ? getenv('MYSQL_USER') . getenv('MYSQL_USERNAME') : '');
$db_pass = $this->getOption(['P', 'dbpass'], ($save_db) ? getenv('MYSQL_PASSWORD') : '');
$url_path = $this->getOption(['u', 'urlpath'], (!empty('FRIENDICA_URL_PATH')) ? getenv('FRIENDICA_URL_PATH') : null);
$php_path = $this->getOption(['b', 'phppath'], (!empty('FRIENDICA_PHP_PATH')) ? getenv('FRIENDICA_PHP_PATH') : null);
$admin_mail = $this->getOption(['A', 'admin'], (!empty('FRIENDICA_ADMIN_MAIL')) ? getenv('FRIENDICA_ADMIN_MAIL') : '');
$tz = $this->getOption(['T', 'tz'], (!empty('FRIENDICA_TZ')) ? getenv('FRIENDICA_TZ') : '');
$lang = $this->getOption(['L', 'lang'], (!empty('FRIENDICA_LANG')) ? getenv('FRIENDICA_LANG') : '');
$url_path = $this->getOption(['u', 'urlpath'], !empty('FRIENDICA_URL_PATH') ? getenv('FRIENDICA_URL_PATH') : null);
$php_path = $this->getOption(['b', 'phppath'], !empty('FRIENDICA_PHP_PATH') ? getenv('FRIENDICA_PHP_PATH') : null);
$admin_mail = $this->getOption(['A', 'admin'], !empty('FRIENDICA_ADMIN_MAIL') ? getenv('FRIENDICA_ADMIN_MAIL') : '');
$tz = $this->getOption(['T', 'tz'], !empty('FRIENDICA_TZ') ? getenv('FRIENDICA_TZ') : '');
$lang = $this->getOption(['L', 'lang'], !empty('FRIENDICA_LANG') ? getenv('FRIENDICA_LANG') : '');
if (empty($php_path)) {
$php_path = $installer->getPHPPath();
@ -132,7 +132,7 @@ HELP;
$installer->createConfig(
$php_path,
$url_path,
((!empty($db_port)) ? $db_host . ':' . $db_port : $db_host),
(!empty($db_port) ? $db_host . ':' . $db_port : $db_host),
$db_user,
$db_pass,
$db_data,

View file

@ -643,7 +643,7 @@ class NotificationsManager extends BaseObject
'madeby_zrl' => Contact::magicLink($it['url']),
'madeby_addr' => $it['addr'],
'contact_id' => $it['contact-id'],
'photo' => ((x($it, 'fphoto')) ? ProxyUtils::proxifyUrl($it['fphoto'], false, ProxyUtils::SIZE_SMALL) : "images/person-300.jpg"),
'photo' => (!empty($it['fphoto']) ? ProxyUtils::proxifyUrl($it['fphoto'], false, ProxyUtils::SIZE_SMALL) : "images/person-300.jpg"),
'name' => $it['fname'],
'url' => $it['furl'],
'zrl' => Contact::magicLink($it['furl']),
@ -675,7 +675,7 @@ class NotificationsManager extends BaseObject
'uid' => $_SESSION['uid'],
'intro_id' => $it['intro_id'],
'contact_id' => $it['contact-id'],
'photo' => ((x($it, 'photo')) ? ProxyUtils::proxifyUrl($it['photo'], false, ProxyUtils::SIZE_SMALL) : "images/person-300.jpg"),
'photo' => (!empty($it['photo']) ? ProxyUtils::proxifyUrl($it['photo'], false, ProxyUtils::SIZE_SMALL) : "images/person-300.jpg"),
'name' => $it['name'],
'location' => BBCode::convert($it['glocation'], false),
'about' => BBCode::convert($it['gabout'], false),

View file

@ -26,7 +26,7 @@ class DatabaseSessionHandler extends BaseObject implements SessionHandlerInterfa
public function read($session_id)
{
if (!x($session_id)) {
if (empty($session_id)) {
return '';
}

View file

@ -105,7 +105,7 @@ class UserImport
}
if (!x($account, 'version')) {
if (empty($account['version'])) {
notice(L10n::t("Error! No version data in file! This is not a Friendica account file?"));
return;
}

View file

@ -538,7 +538,7 @@ class DBStructure
$primary_keys = [];
foreach ($structure["fields"] AS $fieldname => $field) {
$sql_rows[] = "`".DBA::escape($fieldname)."` ".self::FieldCommand($field);
if (x($field,'primary') && $field['primary']!='') {
if (!empty($field['primary'])) {
$primary_keys[] = $fieldname;
}
}

View file

@ -1061,7 +1061,7 @@ class Contact extends BaseObject
$update_contact = ($contact['avatar-date'] < DateTimeFormat::utc('now -7 days'));
// We force the update if the avatar is empty
if (!x($contact, 'avatar')) {
if (empty($contact['avatar'])) {
$update_contact = true;
}
if (!$update_contact || $no_update) {
@ -1618,7 +1618,7 @@ class Contact extends BaseObject
return $result;
}
if (x($arr['contact'], 'name')) {
if (!empty($arr['contact']['name'])) {
$ret = $arr['contact'];
} else {
$ret = Probe::uri($url, $network, $uid, false);
@ -1664,16 +1664,15 @@ class Contact extends BaseObject
}
// do we have enough information?
if (!((x($ret, 'name')) && (x($ret, 'poll')) && ((x($ret, 'url')) || (x($ret, 'addr'))))) {
if (empty($ret['name']) || empty($ret['poll']) || (empty($ret['url']) && empty($ret['addr']))) {
$result['message'] .= L10n::t('The profile address specified does not provide adequate information.') . EOL;
if (!x($ret, 'poll')) {
if (empty($ret['poll'])) {
$result['message'] .= L10n::t('No compatible communication protocols or feeds were discovered.') . EOL;
}
if (!x($ret, 'name')) {
if (empty($ret['name'])) {
$result['message'] .= L10n::t('An author or name was not found.') . EOL;
}
if (!x($ret, 'url')) {
if (empty($ret['url'])) {
$result['message'] .= L10n::t('No browser URL could be matched to this address.') . EOL;
}
if (strpos($url, '@') !== false) {

View file

@ -276,10 +276,10 @@ class FileTag
}
if ($cat == true) {
$pattern = '<' . self::encode($file) . '>' ;
$pattern = '<' . self::encode($file) . '>';
$termtype = TERM_CATEGORY;
} else {
$pattern = '[' . self::encode($file) . ']' ;
$pattern = '[' . self::encode($file) . ']';
$termtype = TERM_FILE;
}

View file

@ -33,7 +33,7 @@ class Group extends BaseObject
public static function create($uid, $name)
{
$return = false;
if (x($uid) && x($name)) {
if (!empty($uid) && !empty($name)) {
$gid = self::getIdByName($uid, $name); // check for dupes
if ($gid !== false) {
// This could be a problem.
@ -202,7 +202,7 @@ class Group extends BaseObject
*/
public static function removeByName($uid, $name) {
$return = false;
if (x($uid) && x($name)) {
if (!empty($uid) && !empty($name)) {
$gid = self::getIdByName($uid, $name);
$return = self::remove($gid);

View file

@ -1359,15 +1359,15 @@ class Item extends BaseObject
$item['owner-name'] = trim(defaults($item, 'owner-name', ''));
$item['owner-link'] = trim(defaults($item, 'owner-link', ''));
$item['owner-avatar'] = trim(defaults($item, 'owner-avatar', ''));
$item['received'] = ((x($item, 'received') !== false) ? DateTimeFormat::utc($item['received']) : DateTimeFormat::utcNow());
$item['created'] = ((x($item, 'created') !== false) ? DateTimeFormat::utc($item['created']) : $item['received']);
$item['edited'] = ((x($item, 'edited') !== false) ? DateTimeFormat::utc($item['edited']) : $item['created']);
$item['changed'] = ((x($item, 'changed') !== false) ? DateTimeFormat::utc($item['changed']) : $item['created']);
$item['commented'] = ((x($item, 'commented') !== false) ? DateTimeFormat::utc($item['commented']) : $item['created']);
$item['received'] = (isset($item['received']) ? DateTimeFormat::utc($item['received']) : DateTimeFormat::utcNow());
$item['created'] = (isset($item['created']) ? DateTimeFormat::utc($item['created']) : $item['received']);
$item['edited'] = (isset($item['edited']) ? DateTimeFormat::utc($item['edited']) : $item['created']);
$item['changed'] = (isset($item['changed']) ? DateTimeFormat::utc($item['changed']) : $item['created']);
$item['commented'] = (isset($item['commented']) ? DateTimeFormat::utc($item['commented']) : $item['created']);
$item['title'] = trim(defaults($item, 'title', ''));
$item['location'] = trim(defaults($item, 'location', ''));
$item['coord'] = trim(defaults($item, 'coord', ''));
$item['visible'] = ((x($item, 'visible') !== false) ? intval($item['visible']) : 1);
$item['visible'] = (isset($item['visible']) ? intval($item['visible']) : 1);
$item['deleted'] = 0;
$item['parent-uri'] = trim(defaults($item, 'parent-uri', $item['uri']));
$item['post-type'] = defaults($item, 'post-type', self::PT_ARTICLE);
@ -1626,7 +1626,7 @@ class Item extends BaseObject
// It is mainly used in the "post_local" hook.
unset($item['api_source']);
if (x($item, 'cancel')) {
if (!empty($item['cancel'])) {
Logger::log('post cancelled by addon.');
return 0;
}
@ -3443,7 +3443,7 @@ class Item extends BaseObject
$filesubtype = 'unkn';
}
$title = Strings::escapeHtml(trim(!empty($mtch[4]) ? $mtch[4] : $mtch[1]));
$title = Strings::escapeHtml(trim(defaults($mtch, 4, $mtch[1])));
$title .= ' ' . $mtch[2] . ' ' . L10n::t('bytes');
$icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>';
@ -3455,7 +3455,7 @@ class Item extends BaseObject
}
// Map.
if (strpos($s, '<div class="map">') !== false && x($item, 'coord')) {
if (strpos($s, '<div class="map">') !== false && !empty($item['coord'])) {
$x = Map::byCoordinates(trim($item['coord']));
if ($x) {
$s = preg_replace('/\<div class\=\"map\"\>/', '$0' . $x, $s);

View file

@ -97,7 +97,7 @@ class Photo
$photo = DBA::selectFirst(
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
);
if (x($photo['resource-id'])) {
if (!empty($photo['resource-id'])) {
$hash = $photo['resource-id'];
} else {
$hash = self::newResource();

View file

@ -288,7 +288,7 @@ class Profile
$location = false;
// This function can also use contact information in $profile
$is_contact = x($profile, 'cid');
$is_contact = !empty($profile['cid']);
if (!is_array($profile) && !count($profile)) {
return $o;
@ -357,7 +357,7 @@ class Profile
// See issue https://github.com/friendica/friendica/issues/3838
// Either we remove the message link for remote users or we enable creating messages from remote users
if (remote_user() || (self::getMyURL() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) {
if (remote_user() || (self::getMyURL() && !empty($profile['unkmail']) && ($profile['uid'] != local_user()))) {
$wallmessage = L10n::t('Message');
if (remote_user()) {
@ -424,23 +424,23 @@ class Profile
// Fetch the account type
$account_type = Contact::getAccountType($profile);
if (x($profile, 'address')
|| x($profile, 'location')
|| x($profile, 'locality')
|| x($profile, 'region')
|| x($profile, 'postal-code')
|| x($profile, 'country-name')
if (!empty($profile['address'])
|| !empty($profile['location'])
|| !empty($profile['locality'])
|| !empty($profile['region'])
|| !empty($profile['postal-code'])
|| !empty($profile['country-name'])
) {
$location = L10n::t('Location:');
}
$gender = x($profile, 'gender') ? L10n::t('Gender:') : false;
$marital = x($profile, 'marital') ? L10n::t('Status:') : false;
$homepage = x($profile, 'homepage') ? L10n::t('Homepage:') : false;
$about = x($profile, 'about') ? L10n::t('About:') : false;
$xmpp = x($profile, 'xmpp') ? L10n::t('XMPP:') : false;
$gender = !empty($profile['gender']) ? L10n::t('Gender:') : false;
$marital = !empty($profile['marital']) ? L10n::t('Status:') : false;
$homepage = !empty($profile['homepage']) ? L10n::t('Homepage:') : false;
$about = !empty($profile['about']) ? L10n::t('About:') : false;
$xmpp = !empty($profile['xmpp']) ? L10n::t('XMPP:') : false;
if ((x($profile, 'hidewall') || $block) && !local_user() && !remote_user()) {
if ((!empty($profile['hidewall']) || $block) && !local_user() && !remote_user()) {
$location = $gender = $marital = $homepage = $about = false;
}
@ -448,7 +448,7 @@ class Profile
$firstname = $split_name['first'];
$lastname = $split_name['last'];
if (x($profile, 'guid')) {
if (!empty($profile['guid'])) {
$diaspora = [
'guid' => $profile['guid'],
'podloc' => System::baseUrl(),
@ -890,7 +890,7 @@ class Profile
}
$tab = false;
if (x($_GET, 'tab')) {
if (!empty($_GET['tab'])) {
$tab = Strings::escapeTags(trim($_GET['tab']));
}
@ -1001,7 +1001,7 @@ class Profile
*/
public static function getMyURL()
{
if (x($_SESSION, 'my_url')) {
if (!empty($_SESSION['my_url'])) {
return $_SESSION['my_url'];
}
return null;
@ -1173,7 +1173,7 @@ class Profile
*/
public static function getThemeUid()
{
$uid = ((!empty($_REQUEST['puid'])) ? intval($_REQUEST['puid']) : 0);
$uid = (!empty($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
if ((local_user()) && ((PConfig::get(local_user(), 'system', 'always_my_theme')) || (!$uid))) {
return local_user();
}

View file

@ -412,12 +412,12 @@ class User
$password = !empty($data['password']) ? trim($data['password']) : '';
$password1 = !empty($data['password1']) ? trim($data['password1']) : '';
$confirm = !empty($data['confirm']) ? trim($data['confirm']) : '';
$blocked = !empty($data['blocked']) ? intval($data['blocked']) : 0;
$verified = !empty($data['verified']) ? intval($data['verified']) : 0;
$blocked = !empty($data['blocked']);
$verified = !empty($data['verified']);
$language = !empty($data['language']) ? Strings::escapeTags(trim($data['language'])) : 'en';
$publish = !empty($data['profile_publish_reg']) && intval($data['profile_publish_reg']) ? 1 : 0;
$netpublish = strlen(Config::get('system', 'directory')) ? $publish : 0;
$publish = !empty($data['profile_publish_reg']);
$netpublish = $publish && Config::get('system', 'directory');
if ($password1 != $confirm) {
throw new Exception(L10n::t('Passwords do not match. Password unchanged.'));

View file

@ -44,7 +44,7 @@ class Contact extends BaseModule
$nets = '';
}
if (!x($a->page, 'aside')) {
if (empty($a->page['aside'])) {
$a->page['aside'] = '';
}

View file

@ -28,8 +28,8 @@ class Feed extends BaseModule
{
$a = self::getApp();
$last_update = x($_GET, 'last_update') ? $_GET['last_update'] : '';
$nocache = x($_GET, 'nocache') && local_user();
$last_update = defaults($_GET, 'last_update', '');
$nocache = !empty($_GET['nocache']) && local_user();
if ($a->argc < 2) {
System::httpExit(400);

View file

@ -34,11 +34,11 @@ class Login extends BaseModule
{
$a = self::getApp();
if (x($_SESSION, 'theme')) {
if (!empty($_SESSION['theme'])) {
unset($_SESSION['theme']);
}
if (x($_SESSION, 'mobile-theme')) {
if (!empty($_SESSION['mobile-theme'])) {
unset($_SESSION['mobile-theme']);
}
@ -68,7 +68,7 @@ class Login extends BaseModule
self::openIdAuthentication($openid_url, !empty($_POST['remember']));
}
if (x($_POST, 'auth-params') && $_POST['auth-params'] === 'login') {
if (!empty($_POST['auth-params']) && $_POST['auth-params'] === 'login') {
self::passwordAuthentication(
trim($_POST['username']),
trim($_POST['password']),
@ -163,7 +163,7 @@ class Login extends BaseModule
$_SESSION['last_login_date'] = DateTimeFormat::utcNow();
Authentication::setAuthenticatedSessionForUser($record, true, true);
if (x($_SESSION, 'return_path')) {
if (!empty($_SESSION['return_path'])) {
$return_path = $_SESSION['return_path'];
unset($_SESSION['return_path']);
} else {
@ -221,15 +221,15 @@ class Login extends BaseModule
}
}
if (isset($_SESSION) && x($_SESSION, 'authenticated')) {
if (x($_SESSION, 'visitor_id') && !x($_SESSION, 'uid')) {
if (!empty($_SESSION['authenticated'])) {
if (!empty($_SESSION['visitor_id']) && empty($_SESSION['uid'])) {
$contact = DBA::selectFirst('contact', [], ['id' => $_SESSION['visitor_id']]);
if (DBA::isResult($contact)) {
self::getApp()->contact = $contact;
}
}
if (x($_SESSION, 'uid')) {
if (!empty($_SESSION['uid'])) {
// already logged in user returning
$check = Config::get('system', 'paranoia');
// extra paranoia - if the IP changed, log them out

View file

@ -28,10 +28,10 @@ class Magic extends BaseModule
Logger::log('args: ' . print_r($_REQUEST, true), Logger::DATA);
$addr = ((x($_REQUEST, 'addr')) ? $_REQUEST['addr'] : '');
$dest = ((x($_REQUEST, 'dest')) ? $_REQUEST['dest'] : '');
$test = ((x($_REQUEST, 'test')) ? intval($_REQUEST['test']) : 0);
$owa = ((x($_REQUEST, 'owa')) ? intval($_REQUEST['owa']) : 0);
$addr = defaults($_REQUEST, 'addr', '');
$dest = defaults($_REQUEST, 'dest', '');
$test = (!empty($_REQUEST['test']) ? intval($_REQUEST['test']) : 0);
$owa = (!empty($_REQUEST['owa']) ? intval($_REQUEST['owa']) : 0);
// NOTE: I guess $dest isn't just the profile url (could be also
// other profile pages e.g. photo). We need to find a solution

View file

@ -347,7 +347,7 @@ class Probe
$data['url'] = $uri;
}
if (x($data, 'photo')) {
if (!empty($data['photo'])) {
$data['baseurl'] = Network::getUrlMatch(Strings::normaliseLink(defaults($data, 'baseurl', '')), Strings::normaliseLink($data['photo']));
} else {
$data['photo'] = System::baseUrl() . '/images/person-300.jpg';
@ -358,7 +358,7 @@ class Probe
$data['name'] = $data['nick'];
}
if (!x($data, 'name')) {
if (empty($data['name'])) {
$data['name'] = $data['url'];
}
}

View file

@ -67,7 +67,7 @@ class Post extends BaseObject
$this->setTemplate('wall');
$this->toplevel = $this->getId() == $this->getDataValue('parent');
if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
if (!empty($_SESSION['remote']) && is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $visitor) {
if ($visitor['cid'] == $this->getDataValue('contact-id')) {
$this->visiting = true;
@ -253,7 +253,7 @@ class Post extends BaseObject
$responses = get_responses($conv_responses, $response_verbs, $this, $item);
foreach ($response_verbs as $value => $verbs) {
$responses[$verbs]['output'] = x($conv_responses[$verbs], $item['uri']) ? format_like($conv_responses[$verbs][$item['uri']], $conv_responses[$verbs][$item['uri'] . '-l'], $verbs, $item['uri']) : '';
$responses[$verbs]['output'] = !empty($conv_responses[$verbs][$item['uri']]) ? format_like($conv_responses[$verbs][$item['uri']], $conv_responses[$verbs][$item['uri'] . '-l'], $verbs, $item['uri']) : '';
}
/*
@ -678,7 +678,7 @@ class Post extends BaseObject
*/
private function setTemplate($name)
{
if (!x($this->available_templates, $name)) {
if (empty($this->available_templates[$name])) {
Logger::log('[ERROR] Item::setTemplate : Template not available ("' . $name . '").', Logger::DEBUG);
return false;
}

View file

@ -2637,7 +2637,7 @@ class DFRN
if (($item["object-type"] == ACTIVITY_OBJ_EVENT) && !$owner_unknown) {
Logger::log("Item ".$item["uri"]." seems to contain an event.", Logger::DEBUG);
$ev = Event::fromBBCode($item["body"]);
if ((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) {
if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
Logger::log("Event in item ".$item["uri"]." was found.", Logger::DEBUG);
$ev["cid"] = $importer["id"];
$ev["uid"] = $importer["importer_uid"];
@ -2925,7 +2925,7 @@ class DFRN
public static function autoRedir(App $a, $contact_nick)
{
// prevent looping
if (x($_REQUEST, 'redir') && intval($_REQUEST['redir'])) {
if (!empty($_REQUEST['redir'])) {
return;
}
@ -3077,10 +3077,10 @@ class DFRN
*/
private static function isEditedTimestampNewer($existing, $update)
{
if (!x($existing, 'edited') || !$existing['edited']) {
if (empty($existing['edited'])) {
return true;
}
if (!x($update, 'edited') || !$update['edited']) {
if (empty($update['edited'])) {
return false;
}

View file

@ -84,7 +84,7 @@ class PortableContact
return;
}
$url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation' : '?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation') ;
$url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation' : '?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation');
Logger::log('load: ' . $url, Logger::DEBUG);

View file

@ -28,7 +28,7 @@ class FriendicaSmarty extends Smarty
// setTemplateDir can be set to an array, which Smarty will parse in order.
// The order is thus very important here
$template_dirs = ['theme' => "view/theme/$theme/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
if (x($a->theme_info, "extends")) {
if (!empty($a->theme_info['extends'])) {
$template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . self::SMARTY3_TEMPLATE_FOLDER . "/"];
}

View file

@ -67,7 +67,7 @@ class FriendicaSmartyEngine implements ITemplateEngine
if (file_exists("{$root}view/theme/$theme/$filename")) {
$template_file = "{$root}view/theme/$theme/$filename";
} elseif (x($a->theme_info, 'extends') && file_exists(sprintf('%sview/theme/%s}/%s', $root, $a->theme_info['extends'], $filename))) {
} elseif (!empty($a->theme_info['extends']) && file_exists(sprintf('%sview/theme/%s}/%s', $root, $a->theme_info['extends'], $filename))) {
$template_file = sprintf('%sview/theme/%s}/%s', $root, $a->theme_info['extends'], $filename);
} elseif (file_exists("{$root}/$filename")) {
$template_file = "{$root}/$filename";

View file

@ -36,7 +36,7 @@ class Emailer
Addon::callHooks('emailer_send_prepare', $params);
$email_textonly = false;
if (x($params, "uid")) {
if (!empty($params['uid'])) {
$email_textonly = PConfig::get($params['uid'], "system", "email_textonly");
}

View file

@ -121,7 +121,7 @@ class Network
@curl_setopt($ch, CURLOPT_HEADER, true);
if (x($opts, "cookiejar")) {
if (!empty($opts['cookiejar'])) {
curl_setopt($ch, CURLOPT_COOKIEJAR, $opts["cookiejar"]);
curl_setopt($ch, CURLOPT_COOKIEFILE, $opts["cookiejar"]);
}
@ -130,7 +130,7 @@ class Network
// @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// @curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
if (x($opts, 'accept_content')) {
if (!empty($opts['accept_content'])) {
curl_setopt(
$ch,
CURLOPT_HTTPHEADER,
@ -156,15 +156,15 @@ class Network
/// @todo We could possibly set this value to "gzip" or something similar
curl_setopt($ch, CURLOPT_ENCODING, '');
if (x($opts, 'headers')) {
if (!empty($opts['headers'])) {
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
}
if (x($opts, 'nobody')) {
if (!empty($opts['nobody'])) {
@curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']);
}
if (x($opts, 'timeout')) {
if (!empty($opts['timeout'])) {
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
} else {
$curl_time = Config::get('system', 'curl_timeout', 60);
@ -489,7 +489,7 @@ class Network
}
$str_allowed = Config::get('system', 'allowed_email', '');
if (!x($str_allowed)) {
if (empty($str_allowed)) {
return true;
}

View file

@ -481,7 +481,7 @@ class Temporal
$o .= "<td $today>";
$day = str_replace(' ', '&nbsp;', sprintf('%2.2d', $d));
if ($started) {
if (x($links, $d) !== false) {
if (isset($links[$d])) {
$o .= "<a href=\"{$links[$d]}\">$day</a>";
} else {
$o .= $day;

View file

@ -201,7 +201,7 @@ class OnePoll
$url = $contact['poll'] . '?dfrn_id=' . $idtosend
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
. '&type=data&last_update=' . $last_update
. '&perm=' . $perm ;
. '&perm=' . $perm;
$curlResult = Network::curl($url);