Merge branch '2018.12-rc' into task/move-config-to-php-array

This commit is contained in:
Hypolite Petovan
2018-12-27 01:47:53 -05:00
committed by GitHub
420 changed files with 3127 additions and 2911 deletions
+5 -5
View File
@@ -523,7 +523,7 @@ class App
if (!empty($relative_script_path)) {
// Module
if (!empty($_SERVER['QUERY_STRING'])) {
$path = trim(dirname($relative_script_path, substr_count(trim($_SERVER['QUERY_STRING'], '/'), '/') + 1), '/');
$path = trim(rdirname($relative_script_path, substr_count(trim($_SERVER['QUERY_STRING'], '/'), '/') + 1), '/');
} else {
// Root page
$path = trim($relative_script_path, '/');
@@ -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() : '' );
}
/**
@@ -1880,7 +1880,7 @@ class App
*/
public function internalRedirect($toUrl = '', $ssl = false)
{
if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
throw new InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo");
}
@@ -1897,7 +1897,7 @@ class App
*/
public function redirect($toUrl)
{
if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
Core\System::externalRedirect($toUrl);
} else {
$this->internalRedirect($toUrl);
+3 -3
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()))) {
@@ -234,7 +234,7 @@ class Nav
// The following nav links are only show to logged in users
if (local_user()) {
$nav['network'] = ['network', L10n::t('Network'), '', L10n::t('Conversations from your friends')];
$nav['net_reset'] = ['network/0?f=&order=comment&nets=all', L10n::t('Network Reset'), '', L10n::t('Load Network page with no filters')];
$nav['net_reset'] = ['network/?f=', L10n::t('Network Reset'), '', L10n::t('Load Network page with no filters')];
$nav['home'] = ['profile/' . $a->user['nickname'], L10n::t('Home'), '', L10n::t('Your posts and conversations')];
+3 -3
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;
}
+13 -13
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.
@@ -626,7 +626,7 @@ class BBCode extends BaseObject
$data["title"] = $data["url"];
}
if (($data["text"] == "") && ($data["title"] != "") && ($data["url"] == "")) {
if (empty($data["text"]) && !empty($data["title"]) && empty($data["url"])) {
return $data["title"] . $data["after"];
}
@@ -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);
+3 -3
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 = '';
}
@@ -961,7 +961,7 @@ class HTML
$save_label = $mode === 'text' ? L10n::t('Save') : L10n::t('Follow');
$values = [
'$s' => htmlspecialchars($s),
'$s' => $s,
'$id' => $id,
'$action_url' => $url,
'$search_label' => L10n::t('Search'),
+1 -1
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'];
+6 -6
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,
+7
View File
@@ -440,6 +440,13 @@ class Installer
);
$returnVal = $returnVal ? $status : false;
$status = $this->checkFunction('json_encode',
L10n::t('JSON PHP module'),
L10n::t('Error: JSON PHP module required but not installed.'),
true
);
$returnVal = $returnVal ? $status : false;
return $returnVal;
}
+2 -2
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),
+13 -13
View File
@@ -48,29 +48,29 @@ class Renderer extends BaseObject
'internal' => '',
'smarty3' => '}}'
];
/**
* @brief This is our template processor
*
* @param string|FriendicaSmarty $s The string requiring macro substitution or an instance of FriendicaSmarty
* @param array $r key value pairs (search => replace)
*
* @return string substituted string
*/
public static function replaceMacros($s, $r)
/**
* @brief This is our template processor
*
* @param string|FriendicaSmarty $s The string requiring macro substitution or an instance of FriendicaSmarty
* @param array $vars key value pairs (search => replace)
*
* @return string substituted string
*/
public static function replaceMacros($s, $vars)
{
$stamp1 = microtime(true);
$a = self::getApp();
// pass $baseurl to all templates
$r['$baseurl'] = System::baseUrl();
$vars['$baseurl'] = System::baseUrl();
$t = self::getTemplateEngine();
try {
$output = $t->replaceMacros($s, $r);
$output = $t->replaceMacros($s, $vars);
} catch (Exception $e) {
echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
killme();
exit();
}
$a->saveTimestamp($stamp1, "rendering");
+1 -1
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 '';
}
+28 -4
View File
@@ -126,9 +126,33 @@ class System extends BaseObject
{
$err = '';
if ($val >= 400) {
$err = 'Error';
if (!isset($description["title"])) {
$description["title"] = $err." ".$val;
if (!empty($description['title'])) {
$err = $description['title'];
} else {
$title = [
'400' => L10n::t('Error 400 - Bad Request'),
'401' => L10n::t('Error 401 - Unauthorized'),
'403' => L10n::t('Error 403 - Forbidden'),
'404' => L10n::t('Error 404 - Not Found'),
'500' => L10n::t('Error 500 - Internal Server Error'),
'503' => L10n::t('Error 503 - Service Unavailable'),
];
$err = defaults($title, $val, 'Error ' . $val);
$description['title'] = $err;
}
if (empty($description['description'])) {
// Explanations are taken from https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
$explanation = [
'400' => L10n::t('The server cannot or will not process the request due to an apparent client error.'),
'401' => L10n::t('Authentication is required and has failed or has not yet been provided.'),
'403' => L10n::t('The request was valid, but the server is refusing action. The user might not have the necessary permissions for a resource, or may need an account.'),
'404' => L10n::t('The requested resource could not be found but may be available in the future.'),
'500' => L10n::t('An unexpected condition was encountered and no more specific message is suitable.'),
'503' => L10n::t('The server is currently unavailable (because it is overloaded or down for maintenance). Please try again later.'),
];
if (!empty($explanation[$val])) {
$description['description'] = $explanation[$val];
}
}
}
@@ -248,7 +272,7 @@ class System extends BaseObject
*/
public static function externalRedirect($url)
{
if (!filter_var($url, FILTER_VALIDATE_URL)) {
if (empty(parse_url($url, PHP_URL_SCHEME))) {
throw new InternalServerErrorException("'$url' is not a fully qualified URL, please use App->internalRedirect() instead");
}
+6
View File
@@ -18,6 +18,10 @@ class Update
*/
public static function check($via_worker)
{
if (!DBA::connected()) {
return;
}
$build = Config::get('system', 'build');
if (empty($build)) {
@@ -118,6 +122,8 @@ class Update
Lock::release('dbupdate');
}
}
} elseif ($force) {
DBStructure::update($verbose, true);
}
return '';
+1 -1
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;
}
+56 -65
View File
@@ -1044,12 +1044,11 @@ class DBA
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
* @param boolean $in_process Internal use: Only do a commit after the last delete
* @param array $callstack Internal use: prevent endless loops
*
* @return boolean|array was the delete successful? When $in_process is set: deletion data
* @return boolean was the delete successful?
*/
public static function delete($table, array $conditions, array $options = [], $in_process = false, array &$callstack = [])
public static function delete($table, array $conditions, array $options = [], array &$callstack = [])
{
if (empty($table) || empty($conditions)) {
Logger::log('Table and conditions have to be set');
@@ -1098,22 +1097,18 @@ class DBA
if ((count($conditions) == 1) && ($field == array_keys($conditions)[0])) {
foreach ($rel_def AS $rel_table => $rel_fields) {
foreach ($rel_fields AS $rel_field) {
$retval = self::delete($rel_table, [$rel_field => array_values($conditions)[0]], $options, true, $callstack);
$commands = array_merge($commands, $retval);
$retval = self::delete($rel_table, [$rel_field => array_values($conditions)[0]], $options, $callstack);
}
}
// We quit when this key already exists in the callstack.
} elseif (!isset($callstack[$qkey])) {
$callstack[$qkey] = true;
// Fetch all rows that are to be deleted
$data = self::select($table, [$field], $conditions);
while ($row = self::fetch($data)) {
// Now we accumulate the delete commands
$retval = self::delete($table, [$field => $row[$field]], $options, true, $callstack);
$commands = array_merge($commands, $retval);
self::delete($table, [$field => $row[$field]], $options, $callstack);
}
self::close($data);
@@ -1123,74 +1118,70 @@ class DBA
}
}
if (!$in_process) {
// Now we finalize the process
$do_transaction = !self::$in_transaction;
// Now we finalize the process
$do_transaction = !self::$in_transaction;
if ($do_transaction) {
self::transaction();
if ($do_transaction) {
self::transaction();
}
$compacted = [];
$counter = [];
foreach ($commands AS $command) {
$conditions = $command['conditions'];
reset($conditions);
$first_key = key($conditions);
$condition_string = self::buildCondition($conditions);
if ((count($command['conditions']) > 1) || is_int($first_key)) {
$sql = "DELETE FROM `" . $command['table'] . "`" . $condition_string;
Logger::log(self::replaceParameters($sql, $conditions), Logger::DATA);
if (!self::e($sql, $conditions)) {
if ($do_transaction) {
self::rollback();
}
return false;
}
} else {
$key_table = $command['table'];
$key_condition = array_keys($command['conditions'])[0];
$value = array_values($command['conditions'])[0];
// Split the SQL queries in chunks of 100 values
// We do the $i stuff here to make the code better readable
$i = isset($counter[$key_table][$key_condition]) ? $counter[$key_table][$key_condition] : 0;
if (isset($compacted[$key_table][$key_condition][$i]) && count($compacted[$key_table][$key_condition][$i]) > 100) {
++$i;
}
$compacted[$key_table][$key_condition][$i][$value] = $value;
$counter[$key_table][$key_condition] = $i;
}
}
foreach ($compacted AS $table => $values) {
foreach ($values AS $field => $field_value_list) {
foreach ($field_value_list AS $field_values) {
$sql = "DELETE FROM `" . $table . "` WHERE `" . $field . "` IN (" .
substr(str_repeat("?, ", count($field_values)), 0, -2) . ");";
$compacted = [];
$counter = [];
Logger::log(self::replaceParameters($sql, $field_values), Logger::DATA);
foreach ($commands AS $command) {
$conditions = $command['conditions'];
reset($conditions);
$first_key = key($conditions);
$condition_string = self::buildCondition($conditions);
if ((count($command['conditions']) > 1) || is_int($first_key)) {
$sql = "DELETE FROM `" . $command['table'] . "`" . $condition_string;
Logger::log(self::replaceParameters($sql, $conditions), Logger::DATA);
if (!self::e($sql, $conditions)) {
if (!self::e($sql, $field_values)) {
if ($do_transaction) {
self::rollback();
}
return false;
}
} else {
$key_table = $command['table'];
$key_condition = array_keys($command['conditions'])[0];
$value = array_values($command['conditions'])[0];
// Split the SQL queries in chunks of 100 values
// We do the $i stuff here to make the code better readable
$i = isset($counter[$key_table][$key_condition]) ? $counter[$key_table][$key_condition] : 0;
if (isset($compacted[$key_table][$key_condition][$i]) && count($compacted[$key_table][$key_condition][$i]) > 100) {
++$i;
}
$compacted[$key_table][$key_condition][$i][$value] = $value;
$counter[$key_table][$key_condition] = $i;
}
}
foreach ($compacted AS $table => $values) {
foreach ($values AS $field => $field_value_list) {
foreach ($field_value_list AS $field_values) {
$sql = "DELETE FROM `" . $table . "` WHERE `" . $field . "` IN (" .
substr(str_repeat("?, ", count($field_values)), 0, -2) . ");";
Logger::log(self::replaceParameters($sql, $field_values), Logger::DATA);
if (!self::e($sql, $field_values)) {
if ($do_transaction) {
self::rollback();
}
return false;
}
}
}
}
if ($do_transaction) {
self::commit();
}
return true;
}
return $commands;
if ($do_transaction) {
self::commit();
}
return true;
}
/**
+1 -1
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;
}
}
+71 -20
View File
@@ -98,6 +98,48 @@ class Contact extends BaseObject
* @}
*/
/**
* @brief Tests if the given contact is a follower
*
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
*
* @return boolean is the contact id a follower?
*/
public static function isFollower($cid, $uid)
{
if (self::isBlockedByUser($cid, $uid)) {
return false;
}
$cdata = self::getPublicAndUserContacID($cid, $uid);
if (empty($cdata['user'])) {
return false;
}
$condition = ['id' => $cdata['user'], 'rel' => [self::FOLLOWER, self::FRIEND]];
return DBA::exists('contact', $condition);
}
/**
* @brief Get the basepath for a given contact link
* @todo Add functionality to store this value in the contact table
*
* @param string $url The contact link
*
* @return string basepath
*/
public static function getBasepath($url)
{
$data = Probe::uri($url);
if (!empty($data['baseurl'])) {
return $data['baseurl'];
}
// When we can't probe the server, we use some ugly function that does some pattern matching
return PortableContact::detectServer($url);
}
/**
* @brief Returns the contact id for the user and the public contact id for a given contact id
*
@@ -106,7 +148,7 @@ class Contact extends BaseObject
*
* @return array with public and user's contact id
*/
private static function getPublicAndUserContacID($cid, $uid)
public static function getPublicAndUserContacID($cid, $uid)
{
if (empty($uid) || empty($cid)) {
return [];
@@ -418,7 +460,8 @@ class Contact extends BaseObject
public static function updateSelfFromUserID($uid, $update_avatar = false)
{
$fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'gender', 'avatar',
'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'nurl'];
'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl',
'photo', 'thumb', 'micro', 'addr', 'request', 'notify', 'poll', 'confirm', 'poco'];
$self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
if (!DBA::isResult($self)) {
return;
@@ -481,15 +524,15 @@ class Contact extends BaseObject
$fields['nurl'] = Strings::normaliseLink($fields['url']);
$fields['addr'] = $user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
$fields['request'] = System::baseUrl() . '/dfrn_request/' . $user['nickname'];
$fields['notify'] = System::baseUrl() . '/dfrn_notify/' . $user['nickname'];
$fields['poll'] = System::baseUrl() . '/dfrn_poll/' . $user['nickname'];
$fields['notify'] = System::baseUrl() . '/dfrn_notify/' . $user['nickname'];
$fields['poll'] = System::baseUrl() . '/dfrn_poll/'. $user['nickname'];
$fields['confirm'] = System::baseUrl() . '/dfrn_confirm/' . $user['nickname'];
$fields['poco'] = System::baseUrl() . '/poco/' . $user['nickname'];
$fields['poco'] = System::baseUrl() . '/poco/' . $user['nickname'];
$update = false;
foreach ($fields as $field => $content) {
if (isset($self[$field]) && $self[$field] != $content) {
if ($self[$field] != $content) {
$update = true;
}
}
@@ -1061,7 +1104,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) {
@@ -1147,7 +1190,7 @@ class Contact extends BaseObject
$url = $data["url"];
if (!$contact_id) {
DBA::insert('contact', [
$fields = [
'uid' => $uid,
'created' => DateTimeFormat::utcNow(),
'url' => $data["url"],
@@ -1176,10 +1219,13 @@ class Contact extends BaseObject
'writable' => 1,
'blocked' => 0,
'readonly' => 0,
'pending' => 0]
);
'pending' => 0];
$s = DBA::select('contact', ['id'], ['nurl' => Strings::normaliseLink($data["url"]), 'uid' => $uid], ['order' => ['id'], 'limit' => 2]);
$condition = ['nurl' => Strings::normaliseLink($data["url"]), 'uid' => $uid, 'deleted' => false];
DBA::update('contact', $fields, $condition, true);
$s = DBA::select('contact', ['id'], $condition, ['order' => ['id'], 'limit' => 2]);
$contacts = DBA::toArray($s);
if (!DBA::isResult($contacts)) {
return 0;
@@ -1204,8 +1250,10 @@ class Contact extends BaseObject
}
if (count($contacts) > 1 && $uid == 0 && $contact_id != 0 && $data["url"] != "") {
DBA::delete('contact', ["`nurl` = ? AND `uid` = 0 AND `id` != ? AND NOT `self`",
Strings::normaliseLink($data["url"]), $contact_id]);
$condition = ["`nurl` = ? AND `uid` = ? AND `id` != ? AND NOT `self`",
Strings::normaliseLink($data["url"]), 0, $contact_id];
Logger::log('Deleting duplicate contact ' . json_encode($condition), Logger::DEBUG);
DBA::delete('contact', $condition);
}
}
@@ -1618,7 +1666,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 +1712,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) {
@@ -2031,6 +2078,10 @@ class Contact extends BaseObject
*/
public static function magicLink($contact_url, $url = '')
{
if (!local_user()) {
return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url;
}
$cid = self::getIdForURL($contact_url, 0, true);
if (empty($cid)) {
return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url;
@@ -2064,7 +2115,7 @@ class Contact extends BaseObject
*/
public static function magicLinkbyContact($contact, $url = '')
{
if ($contact['network'] != Protocol::DFRN) {
if (!local_user() || ($contact['network'] != Protocol::DFRN)) {
return $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
}
+12 -12
View File
@@ -14,9 +14,9 @@ use Friendica\Core\PConfig;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
use Friendica\Util\Strings;
use Friendica\Util\XML;
require_once 'boot.php';
@@ -53,11 +53,11 @@ class Event extends BaseObject
if ($simple) {
if (!empty($event['summary'])) {
$o = "<h3>" . BBCode::convert($event['summary'], false, $simple) . "</h3>";
$o = "<h3>" . BBCode::convert(Strings::escapeHtml($event['summary']), false, $simple) . "</h3>";
}
if (!empty($event['desc'])) {
$o .= "<div>" . BBCode::convert($event['desc'], false, $simple) . "</div>";
$o .= "<div>" . BBCode::convert(Strings::escapeHtml($event['desc']), false, $simple) . "</div>";
}
$o .= "<h4>" . L10n::t('Starts:') . "</h4><p>" . $event_start . "</p>";
@@ -67,7 +67,7 @@ class Event extends BaseObject
}
if (!empty($event['location'])) {
$o .= "<h4>" . L10n::t('Location:') . "</h4><p>" . BBCode::convert($event['location'], false, $simple) . "</p>";
$o .= "<h4>" . L10n::t('Location:') . "</h4><p>" . BBCode::convert(Strings::escapeHtml($event['location']), false, $simple) . "</p>";
}
return $o;
@@ -75,7 +75,7 @@ class Event extends BaseObject
$o = '<div class="vevent">' . "\r\n";
$o .= '<div class="summary event-summary">' . BBCode::convert($event['summary'], false, $simple) . '</div>' . "\r\n";
$o .= '<div class="summary event-summary">' . BBCode::convert(Strings::escapeHtml($event['summary']), false, $simple) . '</div>' . "\r\n";
$o .= '<div class="event-start"><span class="event-label">' . L10n::t('Starts:') . '</span>&nbsp;<span class="dtstart" title="'
. DateTimeFormat::utc($event['start'], (!empty($event['adjust']) ? DateTimeFormat::ATOM : 'Y-m-d\TH:i:s'))
@@ -90,12 +90,12 @@ class Event extends BaseObject
}
if (!empty($event['desc'])) {
$o .= '<div class="description event-description">' . BBCode::convert($event['desc'], false, $simple) . '</div>' . "\r\n";
$o .= '<div class="description event-description">' . BBCode::convert(Strings::escapeHtml($event['desc']), false, $simple) . '</div>' . "\r\n";
}
if (!empty($event['location'])) {
$o .= '<div class="event-location"><span class="event-label">' . L10n::t('Location:') . '</span>&nbsp;<span class="location">'
. BBCode::convert($event['location'], false, $simple)
. BBCode::convert(Strings::escapeHtml($event['location']), false, $simple)
. '</span></div>' . "\r\n";
// Include a map of the location if the [map] BBCode is used.
@@ -592,10 +592,9 @@ class Event extends BaseObject
$drop = [System::baseUrl() . '/events/drop/' . $event['id'] , L10n::t('Delete event') , '', ''];
}
$title = strip_tags(html_entity_decode(BBCode::convert($event['summary']), ENT_QUOTES, 'UTF-8'));
$title = BBCode::convert(Strings::escapeHtml($event['summary']));
if (!$title) {
list($title, $_trash) = explode("<br", BBCode::convert($event['desc']), 2);
$title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
list($title, $_trash) = explode("<br", BBCode::convert(Strings::escapeHtml($event['desc'])), 2);
}
$author_link = $event['author-link'];
@@ -605,8 +604,9 @@ class Event extends BaseObject
$event['plink'] = Contact::magicLink($author_link, $plink);
$html = self::getHTML($event);
$event['desc'] = BBCode::convert($event['desc']);
$event['location'] = BBCode::convert($event['location']);
$event['summary'] = BBCode::convert(Strings::escapeHtml($event['summary']));
$event['desc'] = BBCode::convert(Strings::escapeHtml($event['desc']));
$event['location'] = BBCode::convert(Strings::escapeHtml($event['location']));
$event_list[] = [
'id' => $event['id'],
'start' => $start,
+2 -2
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;
}
+4 -4
View File
@@ -966,8 +966,8 @@ class GContact
$statistics = json_decode($curlResult->getBody());
if (!empty($statistics->config)) {
if ($statistics->config->instance_with_ssl) {
if (!empty($statistics->config->instance_address)) {
if (!empty($statistics->config->instance_with_ssl)) {
$server = "https://";
} else {
$server = "http://";
@@ -976,8 +976,8 @@ class GContact
$server .= $statistics->config->instance_address;
$hostname = $statistics->config->instance_address;
} elseif (!empty($statistics)) {
if ($statistics->instance_with_ssl) {
} elseif (!empty($statistics->instance_address)) {
if (!empty($statistics->instance_with_ssl)) {
$server = "https://";
} else {
$server = "http://";
+4 -4
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);
@@ -400,8 +400,8 @@ class Group extends BaseObject
];
}
// Don't show the groups when there is only one
if (count($display_groups) <= 2) {
// Don't show the groups on the network page when there is only one
if ((count($display_groups) <= 2) && ($each == 'network')) {
return '';
}
+11 -11
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;
}
@@ -3214,7 +3214,7 @@ class Item extends BaseObject
}
}
public static function getPermissionsSQLByUserId($owner_id, $remote_verified = false, $groups = null)
public static function getPermissionsSQLByUserId($owner_id, $remote_verified = false, $groups = null, $remote_cid = null)
{
$local_user = local_user();
$remote_user = remote_user();
@@ -3237,7 +3237,7 @@ class Item extends BaseObject
* If pre-verified, the caller is expected to have already
* done this and passed the groups into this function.
*/
$set = PermissionSet::get($owner_id, $remote_user, $groups);
$set = PermissionSet::get($owner_id, $remote_cid, $groups);
if (!empty($set)) {
$sql_set = " OR (`item`.`private` IN (1,2) AND `item`.`wall` AND `item`.`psid` IN (" . implode(',', $set) . "))";
@@ -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);
+8 -2
View File
@@ -22,11 +22,14 @@ class ItemURI extends BaseObject
*/
public static function insert($fields)
{
if (!DBA::exists('item-uri', ['uri' => $fields['uri']])) {
// If the URI gets too long we only take the first parts and hope for best
$uri = substr($fields['uri'], 0, 255);
if (!DBA::exists('item-uri', ['uri' => $uri])) {
DBA::insert('item-uri', $fields, true);
}
$itemuri = DBA::selectFirst('item-uri', ['id'], ['uri' => $fields['uri']]);
$itemuri = DBA::selectFirst('item-uri', ['id'], ['uri' => $uri]);
if (!DBA::isResult($itemuri)) {
// This shouldn't happen
@@ -45,6 +48,9 @@ class ItemURI extends BaseObject
*/
public static function getIdByURI($uri)
{
// If the URI gets too long we only take the first parts and hope for best
$uri = substr($uri, 0, 255);
$itemuri = DBA::selectFirst('item-uri', ['id'], ['uri' => $uri]);
if (!DBA::isResult($itemuri)) {
+1 -1
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();
+39 -25
View File
@@ -99,7 +99,7 @@ class Profile
* load a lot of theme-specific content
*
* @brief Loads a profile into the page sidebar.
* @param object $a App
* @param App $a
* @param string $nickname string
* @param int $profile int
* @param array $profiledata array
@@ -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;
@@ -297,9 +297,9 @@ class Profile
$profile['picdate'] = urlencode(defaults($profile, 'picdate', ''));
if (($profile['network'] != '') && ($profile['network'] != Protocol::DFRN)) {
$profile['network_name'] = Strings::formatNetworkName($profile['network'], $profile['url']);
$profile['network_link'] = Strings::formatNetworkName($profile['network'], $profile['url']);
} else {
$profile['network_name'] = '';
$profile['network_link'] = '';
}
Addon::callHooks('profile_sidebar_enter', $profile);
@@ -337,6 +337,11 @@ class Profile
}
}
// Is the remote user already connected to that user?
if ($connect && Contact::isFollower(remote_user(), $profile['uid'])) {
$connect = false;
}
if ($connect && ($profile['network'] != Protocol::DFRN) && !isset($profile['remoteconnect'])) {
$connect = false;
}
@@ -357,7 +362,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 +429,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 +453,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(),
@@ -507,10 +512,8 @@ class Profile
$p['about'] = BBCode::convert($p['about']);
}
if (isset($p['address'])) {
$p['address'] = BBCode::convert($p['address']);
} elseif (isset($p['location'])) {
$p['address'] = BBCode::convert($p['location']);
if (empty($p['address']) && !empty($p['location'])) {
$p['address'] = $p['location'];
}
if (isset($p['photo'])) {
@@ -890,7 +893,7 @@ class Profile
}
$tab = false;
if (x($_GET, 'tab')) {
if (!empty($_GET['tab'])) {
$tab = Strings::escapeTags(trim($_GET['tab']));
}
@@ -1001,7 +1004,7 @@ class Profile
*/
public static function getMyURL()
{
if (x($_SESSION, 'my_url')) {
if (!empty($_SESSION['my_url'])) {
return $_SESSION['my_url'];
}
return null;
@@ -1118,6 +1121,17 @@ class Profile
$_SESSION['visitor_home'] = $visitor['url'];
$_SESSION['my_url'] = $visitor['url'];
/// @todo replace this and the query for this variable with some cleaner functionality
$_SESSION['remote'] = [];
$remote_contacts = DBA::select('contact', ['id', 'uid'], ['nurl' => $visitor['nurl'], 'rel' => [Contact::FOLLOWER, Contact::FRIEND]]);
while ($contact = DBA::fetch($remote_contacts)) {
if (($contact['uid'] == 0) || Contact::isBlockedByUser($visitor['id'], $contact['uid'])) {
continue;
}
$_SESSION['remote'][] = ['cid' => $contact['id'], 'uid' => $contact['uid'], 'url' => $visitor['url']];
}
$arr = [
'visitor' => $visitor,
'url' => $a->query_string
@@ -1173,7 +1187,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();
}
+1 -1
View File
@@ -156,7 +156,7 @@ class Term
$link = '';
}
if (DBA::exists('term', ['uid' => $message['uid'], 'otype' => TERM_OBJ_POST, 'oid' => $itemid, 'url' => $link])) {
if (DBA::exists('term', ['uid' => $message['uid'], 'otype' => TERM_OBJ_POST, 'oid' => $itemid, 'term' => $term])) {
continue;
}
+17 -4
View File
@@ -98,6 +98,19 @@ class User
if (!DBA::isResult($r)) {
return false;
}
if (empty($r['nickname'])) {
return false;
}
// Check if the returned data is valid, otherwise fix it. See issue #6122
$url = System::baseUrl() . '/profile/' . $r['nickname'];
$addr = $r['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
if (($addr != $r['addr']) || ($r['url'] != $url) || ($r['nurl'] != Strings::normaliseLink($r['url']))) {
Contact::updateSelfFromUserID($uid);
}
return $r;
}
@@ -412,12 +425,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.'));
+6 -10
View File
@@ -40,11 +40,8 @@ class Contact extends BaseModule
}
$nets = defaults($_GET, 'nets', '');
if ($nets == 'all') {
$nets = '';
}
if (!x($a->page, 'aside')) {
if (empty($a->page['aside'])) {
$a->page['aside'] = '';
}
@@ -78,18 +75,17 @@ class Contact extends BaseModule
$a->data['contact'] = $contact;
if (($contact['network'] != '') && ($contact['network'] != Protocol::DFRN)) {
$networkname = Strings::formatNetworkName($contact['network'], $contact['url']);
$network_link = Strings::formatNetworkName($contact['network'], $contact['url']);
} else {
$networkname = '';
$network_link = '';
}
/// @TODO Add nice spaces
$vcard_widget = Renderer::replaceMacros(Renderer::getMarkupTemplate('vcard-widget.tpl'), [
'$name' => $contact['name'],
'$photo' => $contact['photo'],
'$url' => Model\Contact::MagicLink($contact['url']),
'$addr' => defaults($contact, 'addr', ''),
'$network_name' => $networkname,
'$network_link' => $network_link,
'$network' => L10n::t('Network:'),
'$account_type' => Model\Contact::getAccountType($contact)
]);
@@ -514,7 +510,7 @@ class Contact extends BaseModule
$relation_text = '';
}
$relation_text = sprintf($relation_text, htmlentities($contact['name']));
$relation_text = sprintf($relation_text, $contact['name']);
$url = Model\Contact::magicLink($contact['url']);
if (strpos($url, 'redir/') === 0) {
@@ -646,7 +642,7 @@ class Contact extends BaseModule
'$profileurllabel'=> L10n::t('Profile URL'),
'$profileurl' => $contact['url'],
'$account_type' => Model\Contact::getAccountType($contact),
'$location' => BBCode::convert($contact['location']),
'$location' => $contact['location'],
'$location_label' => L10n::t('Location:'),
'$xmpp' => BBCode::convert($contact['xmpp']),
'$xmpp_label' => L10n::t('XMPP:'),
+5 -4
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);
@@ -44,6 +44,7 @@ class Feed extends BaseModule
case 'posts':
case 'comments':
case 'activity':
// Correct type names, no change needed
break;
case 'replies':
$type = 'comments';
@@ -53,8 +54,8 @@ class Feed extends BaseModule
}
$nickname = $a->argv[1];
header("Content-type: application/atom+xml");
header("Content-type: application/atom+xml; charset=utf-8");
echo OStatus::feed($nickname, $last_update, 10, $type, $nocache, true);
killme();
exit();
}
}
+1
View File
@@ -9,6 +9,7 @@ use Friendica\Protocol\ActivityPub;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Util\HTTPSignature;
use Friendica\Core\Logger;
/**
* ActivityPub Inbox
+2 -2
View File
@@ -25,12 +25,12 @@ class Itemsource extends \Friendica\BaseModule
$conversation = Model\Conversation::getByItemUri($item['uri']);
$item_uri = $item['uri'];
$source = htmlspecialchars($conversation['source']);
$source = $conversation['source'];
}
$tpl = Renderer::getMarkupTemplate('debug/itemsource.tpl');
$o = Renderer::replaceMacros($tpl, [
'$guid' => ['guid', L10n::t('Item Guid'), htmlentities(defaults($_REQUEST, 'guid', '')), ''],
'$guid' => ['guid', L10n::t('Item Guid'), defaults($_REQUEST, 'guid', ''), ''],
'$source' => $source,
'$item_uri' => $item_uri
]);
+7 -7
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
+5 -5
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
@@ -43,7 +43,7 @@ class Magic extends BaseModule
}
if (!$cid) {
Logger::log('No contact record found: ' . print_r($_REQUEST, true), Logger::DEBUG);
Logger::log('No contact record found: ' . json_encode($_REQUEST), Logger::DEBUG);
// @TODO Finding a more elegant possibility to redirect to either internal or external URL
$a->redirect($dest);
}
+12 -2
View File
@@ -161,11 +161,21 @@ class CurlResult
if ($this->returnCode == 301 || $this->returnCode == 302 || $this->returnCode == 303 || $this->returnCode== 307) {
$redirect_parts = parse_url(defaults($this->info, 'redirect_url', ''));
if (empty($redirect_parts)) {
$redirect_parts = [];
}
if (preg_match('/(Location:|URI:)(.*?)\n/i', $this->header, $matches)) {
$redirect_parts = array_merge($redirect_parts, parse_url(trim(array_pop($matches))));
$redirect_parts2 = parse_url(trim(array_pop($matches)));
if (!empty($redirect_parts2)) {
$redirect_parts = array_merge($redirect_parts, $redirect_parts2);
}
}
$parts = parse_url(defaults($this->info, 'url', ''));
if (empty($parts)) {
$parts = [];
}
/// @todo Checking the corresponding RFC which parts of a redirect can be ommitted.
$components = ['scheme', 'host', 'path', 'query', 'fragment'];
@@ -177,7 +187,7 @@ class CurlResult
$this->redirectUrl = Network::unparseURL($redirect_parts);
$this->isRedirectUrl = filter_var($this->redirectUrl, FILTER_VALIDATE_URL) !== false;
$this->isRedirectUrl = true;
} else {
$this->isRedirectUrl = false;
}
+4 -4
View File
@@ -164,7 +164,7 @@ class Probe
}
}
self::$baseurl = "http://".$host;
self::$baseurl = $host_url;
Logger::log("Probing successful for ".$host, Logger::DEBUG);
@@ -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'];
}
}
@@ -1317,7 +1317,7 @@ class Probe
if ($curlResult->isTimeout()) {
return false;
}
$pubkey = $curlResult['body'];
$pubkey = $curlResult->getBody();
}
$key = explode(".", $pubkey);
+2
View File
@@ -45,6 +45,8 @@ class OEmbed
if (in_array($key, ['thumbnail_width', 'thumbnail_height', 'width', 'height'])) {
// These values should be numbers, so ensure that they really are numbers.
$value = (int)$value;
} elseif (is_array($value)) {
// Ignoring arrays.
} elseif ($key != 'html') {
// Avoid being able to inject some ugly stuff through these fields.
$value = htmlentities($value);
+3 -3
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;
}
+12 -12
View File
@@ -209,20 +209,20 @@ class Processor
*/
public static function createEvent($activity, $item)
{
$event['summary'] = $activity['name'];
$event['desc'] = $activity['content'];
$event['start'] = $activity['start-time'];
$event['finish'] = $activity['end-time'];
$event['summary'] = HTML::toBBCode($activity['name']);
$event['desc'] = HTML::toBBCode($activity['content']);
$event['start'] = $activity['start-time'];
$event['finish'] = $activity['end-time'];
$event['nofinish'] = empty($event['finish']);
$event['location'] = $activity['location'];
$event['adjust'] = true;
$event['cid'] = $item['contact-id'];
$event['uid'] = $item['uid'];
$event['uri'] = $item['uri'];
$event['edited'] = $item['edited'];
$event['private'] = $item['private'];
$event['guid'] = $item['guid'];
$event['plink'] = $item['plink'];
$event['adjust'] = true;
$event['cid'] = $item['contact-id'];
$event['uid'] = $item['uid'];
$event['uri'] = $item['uri'];
$event['edited'] = $item['edited'];
$event['private'] = $item['private'];
$event['guid'] = $item['guid'];
$event['plink'] = $item['plink'];
$condition = ['uri' => $item['uri'], 'uid' => $item['uid']];
$ev = DBA::selectFirst('event', ['id'], $condition);
+1
View File
@@ -599,6 +599,7 @@ class Receiver
$photo = defaults($profile, 'photo', null);
unset($profile['photo']);
unset($profile['baseurl']);
unset($profile['guid']);
$profile['nurl'] = Strings::normaliseLink($profile['url']);
DBA::update('contact', $profile, ['id' => $cid]);
+1 -1
View File
@@ -643,7 +643,7 @@ class Transmitter
$data['object'] = $item['thr-parent'];
}
$owner = User::getOwnerDataById($item['uid']);
$owner = User::getOwnerDataById($item['contact-uid']);
if (!$object_mode) {
return LDSignature::sign($data, $owner);
+4 -4
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;
}
+2 -2
View File
@@ -3727,12 +3727,12 @@ class Diaspora
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
$message = self::constructLike($item, $owner);
$type = "like";
} else {
} elseif (!in_array($item["verb"], [ACTIVITY_FOLLOW])) {
$message = self::constructComment($item, $owner);
$type = "comment";
}
if (!$message) {
if (empty($message)) {
return false;
}
+5 -7
View File
@@ -117,7 +117,7 @@ class Email
return $ret;
}
if (!$struc->parts) {
if (empty($struc->parts)) {
$ret['body'] = self::messageGetPart($mbox, $uid, $struc, 0, 'html');
$html = $ret['body'];
@@ -482,13 +482,11 @@ class Email
'[\r\n]\s*-----BEGIN PGP SIGNATURE-----\s*[\r\n].*'.
'[\r\n]\s*-----END PGP SIGNATURE-----(.*)/is';
preg_match($pattern, $message, $result);
if (preg_match($pattern, $message, $result)) {
$cleaned = trim($result[1].$result[2].$result[3]);
$cleaned = trim($result[1].$result[2].$result[3]);
$cleaned = str_replace(["\n- --\n", "\n- -"], ["\n-- \n", "\n-"], $cleaned);
if ($cleaned == '') {
$cleaned = str_replace(["\n- --\n", "\n- -"], ["\n-- \n", "\n-"], $cleaned);
} else {
$cleaned = $message;
}
+3 -1
View File
@@ -1543,8 +1543,10 @@ class OStatus
*/
private static function constructObjecttype(array $item)
{
if (in_array($item['object-type'], [ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT]))
if (!empty($item['object-type']) && in_array($item['object-type'], [ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT])) {
return $item['object-type'];
}
return ACTIVITY_OBJ_NOTE;
}
+7 -7
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);
@@ -734,7 +734,7 @@ class PortableContact
}
}
if (is_array($nodeinfo['metadata']) && isset($nodeinfo['metadata']['nodeName'])) {
if (isset($nodeinfo['metadata']['nodeName'])) {
$server['site_name'] = $nodeinfo['metadata']['nodeName'];
}
@@ -817,7 +817,7 @@ class PortableContact
}
}
if (is_array($nodeinfo['metadata']) && isset($nodeinfo['metadata']['nodeName'])) {
if (isset($nodeinfo['metadata']['nodeName'])) {
$server['site_name'] = $nodeinfo['metadata']['nodeName'];
}
@@ -1375,15 +1375,15 @@ class PortableContact
$site_name = $data['site_name'];
}
$info = $data['info'];
$info = defaults($data, 'info', '');
$register_policy = defaults($data, 'register_policy', REGISTER_CLOSED);
if (in_array($register_policy, ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'])) {
$register_policy = constant($data['register_policy']);
$register_policy = constant($register_policy);
} else {
Logger::log("Register policy '$register_policy' from $server_url is invalid.");
$register_policy = REGISTER_CLOSED; // set a default value
}
$platform = $data['platform'];
$platform = defaults($data, 'platform', '');
}
}
}
@@ -1778,7 +1778,7 @@ class PortableContact
$curlResult = Network::curl($url);
if ($curlResult->isSuccess()) {
$data = json_decode($curlResult["body"], true);
$data = json_decode($curlResult->getBody(), true);
if (!empty($data)) {
self::discoverServer($data, 3);
+3 -1
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 . "/"];
}
@@ -42,6 +42,8 @@ class FriendicaSmarty extends Smarty
$this->left_delimiter = Renderer::getTemplateLeftDelimiter('smarty3');
$this->right_delimiter = Renderer::getTemplateRightDelimiter('smarty3');
$this->escape_html = true;
// Don't report errors so verbosely
$this->error_reporting = E_ALL & ~E_NOTICE;
}
+1 -1
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";
+1 -1
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");
}
+2
View File
@@ -204,6 +204,8 @@ class HTTPSignature
if (preg_match('/algorithm="(.*?)"/ism', $header, $matches)) {
$ret['algorithm'] = $matches[1];
} else {
$ret['algorithm'] = 'rsa-sha256';
}
if (preg_match('/headers="(.*?)"/ism', $header, $matches)) {
+13 -2
View File
@@ -93,8 +93,13 @@ class JsonLD
'dc' => (object)['@id' => 'http://purl.org/dc/terms/', '@type' => '@id'],
'toot' => (object)['@id' => 'http://joinmastodon.org/ns#', '@type' => '@id']];
$jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
// Trying to avoid memory problems with large content fields
if (!empty($json['object']['source']['content'])) {
$content = $json['object']['source']['content'];
$json['object']['source']['content'] = '';
}
$jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
try {
$compacted = jsonld_compact($jsonobj, $context);
@@ -104,7 +109,13 @@ class JsonLD
Logger::log('compacting error:' . print_r($e, true), Logger::DEBUG);
}
return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true);
$json = json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true);
if (isset($json['as:object']['as:source']['as:content']) && !empty($content)) {
$json['as:object']['as:source']['as:content'] = $content;
}
return $json;
}
/**
+1 -1
View File
@@ -27,7 +27,7 @@ class LDSignature
}
$actor = JsonLD::fetchElement($data, 'actor', 'id');
if (empty($actor)) {
if (empty($actor) || !is_string($actor)) {
return false;
}
+7 -7
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);
@@ -362,7 +362,7 @@ class Network
/// @TODO Really suppress function outcomes? Why not find them + debug them?
$h = @parse_url($url);
if ((is_array($h)) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
if (!empty($h['host']) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
return $url;
}
@@ -489,7 +489,7 @@ class Network
}
$str_allowed = Config::get('system', 'allowed_email', '');
if (!x($str_allowed)) {
if (empty($str_allowed)) {
return true;
}
+9 -9
View File
@@ -140,18 +140,18 @@ class Strings
}
/**
* @brief translate and format the networkname of a contact
* @brief Translate and format the network name of a contact
*
* @param string $network Networkname of the contact (e.g. dfrn, rss and so on)
* @param string $url The contact url
* @param string $network Network name of the contact (e.g. dfrn, rss and so on)
* @param string $url The contact url
*
* @return string Formatted network name
* @return string Formatted network name
*/
public static function formatNetworkName($network, $url = 0)
public static function formatNetworkName($network, $url = '')
{
if ($network != "") {
if ($url != "") {
$network_name = '<a href="' . $url .'">' . ContactSelector::networkToName($network, $url) . "</a>";
if ($network != '') {
if ($url != '') {
$network_name = '<a href="' . $url .'">' . ContactSelector::networkToName($network, $url) . '</a>';
} else {
$network_name = ContactSelector::networkToName($network);
}
@@ -161,7 +161,7 @@ class Strings
}
/**
* @brief Remove intentation from a text
* @brief Remove indentation from a text
*
* @param string $text String to be transformed.
* @param string $chr Optional. Indentation tag. Default tab (\t).
+1 -1
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;
+1 -1
View File
@@ -119,7 +119,7 @@ class CronJobs
}
// delete user records for recently removed accounts
$users = DBA::select('user', ['uid'], ["`account_removed` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY"]);
$users = DBA::select('user', ['uid'], ["`account_removed` AND `account_expires_on` < UTC_TIMESTAMP() "]);
while ($user = DBA::fetch($users)) {
// Delete the contacts of this user
$self = DBA::selectFirst('contact', ['nurl'], ['self' => true, 'uid' => $user['uid']]);
+1 -1
View File
@@ -35,7 +35,7 @@ class GProbe {
$result = Cache::get("gprobe:".$urlparts["host"]);
if (!is_null($result)) {
if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) {
Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), Logger::DEBUG);
Logger::log("DDoS attempt detected for ".$urlparts["host"]." by ".defaults($_SERVER, "REMOTE_ADDR", '').". server data: ".print_r($_SERVER, true), Logger::DEBUG);
return;
}
}
+1 -1
View File
@@ -106,7 +106,7 @@ class Notifier
$inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser(0);
foreach ($inboxes as $inbox) {
Logger::log('Account removal for user ' . $item_id . ' to ' . $inbox .' via ActivityPub', Logger::DEBUG);
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
Worker::add(['priority' => PRIORITY_NEGLIGIBLE, 'created' => $a->queue['created'], 'dont_fork' => true],
'APDelivery', Delivery::REMOVAL, '', $inbox, $item_id);
}
+1 -1
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);