Merge remote-tracking branch 'upstream/develop' into unify-link

This commit is contained in:
Michael 2023-05-17 20:03:57 +00:00
commit 7c266be206
39 changed files with 537 additions and 315 deletions

View file

@ -54,11 +54,10 @@ function message_init(App $a)
'$tabs' => $tabs, '$tabs' => $tabs,
'$new' => $new, '$new' => $new,
]); ]);
$base = DI::baseUrl();
$head_tpl = Renderer::getMarkupTemplate('message-head.tpl'); $head_tpl = Renderer::getMarkupTemplate('message-head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [ DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [
'$base' => $base '$base' => (string)DI::baseUrl()
]); ]);
} }

View file

@ -106,7 +106,7 @@ class Smilies
]; ];
$baseUrl = DI::baseUrl(); $baseUrl = (string)DI::baseUrl();
$icons = [ $icons = [
'<img class="smiley" src="' . $baseUrl . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />', '<img class="smiley" src="' . $baseUrl . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />',

View file

@ -1403,12 +1403,32 @@ class BBCode
} }
// Check for headers // Check for headers
$text = preg_replace("(\[h1\](.*?)\[\/h1\])ism", '</p><h1>$1</h1><p>', $text);
$text = preg_replace("(\[h2\](.*?)\[\/h2\])ism", '</p><h2>$1</h2><p>', $text); if ($simple_html == self::INTERNAL) {
$text = preg_replace("(\[h3\](.*?)\[\/h3\])ism", '</p><h3>$1</h3><p>', $text); //Ensure to always start with <h4> if possible
$text = preg_replace("(\[h4\](.*?)\[\/h4\])ism", '</p><h4>$1</h4><p>', $text); $heading_count = 0;
$text = preg_replace("(\[h5\](.*?)\[\/h5\])ism", '</p><h5>$1</h5><p>', $text); for ($level = 6; $level > 0; $level--) {
$text = preg_replace("(\[h6\](.*?)\[\/h6\])ism", '</p><h6>$1</h6><p>', $text); if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) {
$heading_count++;
}
}
if ($heading_count > 0) {
$heading = min($heading_count + 3, 6);
for ($level = 6; $level > 0; $level--) {
if (preg_match("(\[h$level\].*?\[\/h$level\])ism", $text)) {
$text = preg_replace("(\[h$level\](.*?)\[\/h$level\])ism", "</p><h$heading>$1</h$heading><p>", $text);
$heading--;
}
}
}
} else {
$text = preg_replace("(\[h1\](.*?)\[\/h1\])ism", '</p><h1>$1</h1><p>', $text);
$text = preg_replace("(\[h2\](.*?)\[\/h2\])ism", '</p><h2>$1</h2><p>', $text);
$text = preg_replace("(\[h3\](.*?)\[\/h3\])ism", '</p><h3>$1</h3><p>', $text);
$text = preg_replace("(\[h4\](.*?)\[\/h4\])ism", '</p><h4>$1</h4><p>', $text);
$text = preg_replace("(\[h5\](.*?)\[\/h5\])ism", '</p><h5>$1</h5><p>', $text);
$text = preg_replace("(\[h6\](.*?)\[\/h6\])ism", '</p><h6>$1</h6><p>', $text);
}
// Check for paragraph // Check for paragraph
$text = preg_replace("(\[p\](.*?)\[\/p\])ism", '<p>$1</p>', $text); $text = preg_replace("(\[p\](.*?)\[\/p\])ism", '<p>$1</p>', $text);

View file

@ -315,7 +315,12 @@ class Protocol
*/ */
public static function supportsProbe($protocol): bool public static function supportsProbe($protocol): bool
{ {
if (in_array($protocol, self::NATIVE_SUPPORT)) { // "Mail" can only be probed for a specific user in a specific condition, so we are ignoring it here.
if ($protocol == self::MAIL) {
return false;
}
if (in_array($protocol, array_merge(self::NATIVE_SUPPORT, [self::ZOT, self::PHANTOM]))) {
return true; return true;
} }

View file

@ -55,40 +55,42 @@ class Search
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getContactsFromProbe(string $user): ResultList public static function getContactsFromProbe(string $user, $only_forum = false): ResultList
{ {
$emptyResultList = new ResultList(1, 0, 1); $emptyResultList = new ResultList();
if ((filter_var($user, FILTER_VALIDATE_EMAIL) && Network::isEmailDomainValid($user)) || if (empty(parse_url($user, PHP_URL_SCHEME)) && !(filter_var($user, FILTER_VALIDATE_EMAIL) || Network::isEmailDomainValid($user))) {
(substr(Strings::normaliseLink($user), 0, 7) == 'http://')) {
$user_data = Contact::getByURL($user);
if (empty($user_data)) {
return $emptyResultList;
}
if (!in_array($user_data['network'], Protocol::FEDERATED)) {
return $emptyResultList;
}
$contactDetails = Contact::getByURLForUser($user_data['url'] ?? '', DI::userSession()->getLocalUserId());
$result = new ContactResult(
$user_data['name'] ?? '',
$user_data['addr'] ?? '',
($contactDetails['addr'] ?? '') ?: ($user_data['url'] ?? ''),
new Uri($user_data['url'] ?? ''),
$user_data['photo'] ?? '',
$user_data['network'] ?? '',
$contactDetails['cid'] ?? 0,
$user_data['id'] ?? 0,
$user_data['tags'] ?? ''
);
return new ResultList(1, 1, 1, [$result]);
} else {
return $emptyResultList; return $emptyResultList;
} }
$user_data = Contact::getByURL($user);
if (empty($user_data)) {
return $emptyResultList;
}
if ($only_forum && ($user_data['contact-type'] != Contact::TYPE_COMMUNITY)) {
return $emptyResultList;
}
if (!Protocol::supportsProbe($user_data['network'])) {
return $emptyResultList;
}
$contactDetails = Contact::getByURLForUser($user_data['url'], DI::userSession()->getLocalUserId());
$result = new ContactResult(
$user_data['name'],
$user_data['addr'],
$user_data['addr'] ?: $user_data['url'],
new Uri($user_data['url']),
$user_data['photo'],
$user_data['network'],
$contactDetails['cid'] ?? 0,
$user_data['id'],
$user_data['tags']
);
return new ResultList(1, 1, 1, [$result]);
} }
/** /**
@ -129,7 +131,7 @@ class Search
$resultList = new ResultList( $resultList = new ResultList(
($results['page'] ?? 0) ?: 1, ($results['page'] ?? 0) ?: 1,
$results['count'] ?? 0, $results['count'] ?? 0,
($results['itemsperpage'] ?? 0) ?: 30 ($results['itemsperpage'] ?? 0) ?: 30
); );
@ -174,7 +176,7 @@ class Search
$contacts = Contact::searchByName($search, $type == self::TYPE_FORUM ? 'community' : '', true); $contacts = Contact::searchByName($search, $type == self::TYPE_FORUM ? 'community' : '', true);
$resultList = new ResultList($start, $itemPage, count($contacts)); $resultList = new ResultList($start, count($contacts), $itemPage);
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
$result = new ContactResult( $result = new ContactResult(
@ -284,4 +286,4 @@ class Search
return 'search?q=' . urlencode($search); return 'search?q=' . urlencode($search);
} }
} }
} }

View file

@ -129,20 +129,6 @@ class Update
DI::lock()->release('dbupdate', true); DI::lock()->release('dbupdate', true);
} }
if (!DBStructure::existsTable('config')) {
DBA::e(<<<EOF
CREATE TABLE IF NOT EXISTS `config` (
`id` int unsigned NOT NULL auto_increment COMMENT '',
`cat` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The category of the entry',
`k` varbinary(50) NOT NULL DEFAULT '' COMMENT 'The key of the entry',
`v` mediumtext COMMENT '',
PRIMARY KEY(`id`),
UNIQUE INDEX `cat_k` (`cat`,`k`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='main configuration storage';
EOF
);
}
$build = DI::config()->get('system', 'build'); $build = DI::config()->get('system', 'build');
if (empty($build)) { if (empty($build)) {

View file

@ -151,8 +151,8 @@ class Cron
// We are acquiring the two locks from the worker to avoid locking problems // We are acquiring the two locks from the worker to avoid locking problems
if (DI::lock()->acquire(Worker::LOCK_PROCESS, 10)) { if (DI::lock()->acquire(Worker::LOCK_PROCESS, 10)) {
if (DI::lock()->acquire(Worker::LOCK_WORKER, 10)) { if (DI::lock()->acquire(Worker::LOCK_WORKER, 10)) {
DBA::e("OPTIMIZE TABLE `workerqueue`"); DBA::optimizeTable('workerqueue');
DBA::e("OPTIMIZE TABLE `process`"); DBA::optimizeTable('process');
DI::lock()->release(Worker::LOCK_WORKER); DI::lock()->release(Worker::LOCK_WORKER);
} }
DI::lock()->release(Worker::LOCK_PROCESS); DI::lock()->release(Worker::LOCK_PROCESS);
@ -197,7 +197,7 @@ class Cron
// Optimizing this table only last seconds // Optimizing this table only last seconds
if (DI::config()->get('system', 'optimize_tables')) { if (DI::config()->get('system', 'optimize_tables')) {
Logger::info('Optimize start'); Logger::info('Optimize start');
DBA::e("OPTIMIZE TABLE `post-delivery`"); DBA::optimizeTable('post-delivery');
Logger::info('Optimize end'); Logger::info('Optimize end');
} }
} }

View file

@ -821,6 +821,27 @@ class DBA
return DI::dba()->processlist(); return DI::dba()->processlist();
} }
/**
* Optimizes tables
*
* @param string $table a given table
*
* @return bool True, if successfully optimized, otherwise false
* @throws \Exception
*/
public static function optimizeTable(string $table): bool
{
return DI::dba()->optimizeTable($table);
}
/**
* Kill sleeping database processes
*/
public static function deleteSleepingProcesses()
{
DI::dba()->deleteSleepingProcesses();
}
/** /**
* Fetch a database variable * Fetch a database variable
* *

View file

@ -57,6 +57,18 @@ class DBStructure
echo DI::l10n()->t('The database version had been set to %s.', $version); echo DI::l10n()->t('The database version had been set to %s.', $version);
} }
/**
* Drops a specific table
*
* @param string $table the table name
*
* @return bool true if possible, otherwise false
*/
public static function dropTable(string $table): bool
{
return DBA::isResult(DBA::e('DROP TABLE ' . DBA::quoteIdentifier($table) . ';'));
}
/** /**
* Drop unused tables * Drop unused tables
* *
@ -94,8 +106,7 @@ class DBStructure
$sql = 'DROP TABLE ' . DBA::quoteIdentifier($table) . ';'; $sql = 'DROP TABLE ' . DBA::quoteIdentifier($table) . ';';
echo $sql . "\n"; echo $sql . "\n";
$result = DBA::e($sql); if (!static::dropTable($table)) {
if (!DBA::isResult($result)) {
self::printUpdateError($sql); self::printUpdateError($sql);
} }
} else { } else {

View file

@ -1357,6 +1357,15 @@ class Database
} }
$fields = $this->castFields($table, $fields); $fields = $this->castFields($table, $fields);
$direct_fields = [];
foreach ($fields as $key => $value) {
if (is_numeric($key)) {
$direct_fields[] = $value;
unset($fields[$key]);
}
}
$table_string = DBA::buildTableString([$table]); $table_string = DBA::buildTableString([$table]);
@ -1369,7 +1378,8 @@ class Database
} }
$sql = "UPDATE " . $ignore . $table_string . " SET " $sql = "UPDATE " . $ignore . $table_string . " SET "
. implode(" = ?, ", array_map([DBA::class, 'quoteIdentifier'], array_keys($fields))) . " = ?" . ((count($fields) > 0) ? implode(" = ?, ", array_map([DBA::class, 'quoteIdentifier'], array_keys($fields))) . " = ?" : "")
. ((count($direct_fields) > 0) ? ((count($fields) > 0) ? " , " : "") . implode(" , ", $direct_fields) : "")
. $condition_string; . $condition_string;
// Combines the updated fields parameter values with the condition parameter values // Combines the updated fields parameter values with the condition parameter values
@ -1758,6 +1768,37 @@ class Database
return (['list' => $statelist, 'amount' => $processes]); return (['list' => $statelist, 'amount' => $processes]);
} }
/**
* Optimizes tables
*
* @param string $table a given table
*
* @return bool True, if successfully optimized, otherwise false
* @throws \Exception
*/
public function optimizeTable(string $table): bool
{
return $this->e("OPTIMIZE TABLE " . DBA::buildTableString([$table])) !== false;
}
/**
* Kill sleeping database processes
*
* @return void
*/
public function deleteSleepingProcesses()
{
$processes = $this->p("SHOW FULL PROCESSLIST");
while ($process = $this->fetch($processes)) {
if (($process['Command'] != 'Sleep') || ($process['Time'] < 300) || ($process['db'] != $this->databaseName())) {
continue;
}
$this->e("KILL ?", $process['Id']);
}
$this->close($processes);
}
/** /**
* Fetch a database variable * Fetch a database variable
* *

View file

@ -38,22 +38,24 @@ class DatabaseException extends Exception
* *
* @link https://php.net/manual/en/exception.construct.php * @link https://php.net/manual/en/exception.construct.php
* *
* @param string $message The Database error message. * @param string $message The Database error message.
* @param int $code The Database error code. * @param int $code The Database error code.
* @param string $query The Database error query. * @param string $query The Database error query.
* @param Throwable $previous [optional] The previous throwable used for the exception chaining. * @param Throwable|null $previous [optional] The previous throwable used for the exception chaining.
*/ */
public function __construct(string $message, int $code, string $query, Throwable $previous = null) public function __construct(string $message, int $code, string $query, Throwable $previous = null)
{ {
parent::__construct($message, $code, $previous); parent::__construct(sprintf('"%s" at "%s"', $message, $query) , $code, $previous);
$this->query = $query; $this->query = $query;
} }
/** /**
* {@inheritDoc} * Returns the query, which caused the exception
*
* @return string
*/ */
public function __toString() public function getQuery(): string
{ {
return sprintf('Database error %d "%s" at "%s"', $this->message, $this->code, $this->query); return $this->query;
} }
} }

View file

@ -88,7 +88,10 @@ final class DeliveryQueueItem extends \Friendica\BaseRepository
public function remove(Entity\DeliveryQueueItem $deliveryQueueItem): bool public function remove(Entity\DeliveryQueueItem $deliveryQueueItem): bool
{ {
return $this->db->delete(self::$table_name, ['uri-id' => $deliveryQueueItem->postUriId, 'gsid' => $deliveryQueueItem->targetServerId]); return $this->db->delete(self::$table_name, [
'uri-id' => $deliveryQueueItem->postUriId,
'gsid' => $deliveryQueueItem->targetServerId
]);
} }
public function removeFailedByServerId(int $gsid, int $failedThreshold): bool public function removeFailedByServerId(int $gsid, int $failedThreshold): bool
@ -98,16 +101,17 @@ final class DeliveryQueueItem extends \Friendica\BaseRepository
public function incrementFailed(Entity\DeliveryQueueItem $deliveryQueueItem): bool public function incrementFailed(Entity\DeliveryQueueItem $deliveryQueueItem): bool
{ {
return $this->db->e(" return $this->db->update(self::$table_name, [
UPDATE " . DBA::buildTableString([self::$table_name]) . " "`failed` = `failed` + 1"
SET `failed` = `failed` + 1 ], [
WHERE `uri-id` = ? AND `gsid` = ?", "`uri-id` = ? AND `gsid` = ?",
$deliveryQueueItem->postUriId, $deliveryQueueItem->targetServerId $deliveryQueueItem->postUriId,
); $deliveryQueueItem->targetServerId
]);
} }
public function optimizeStorage(): bool public function optimizeStorage(): bool
{ {
return $this->db->e("OPTIMIZE TABLE " . DBA::buildTableString([self::$table_name])); return $this->db->optimizeTable(self::$table_name);
} }
} }

View file

@ -361,7 +361,7 @@ class Contact
$background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true; $background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true;
// Update the contact in the background if needed // Update the contact in the background if needed
if ($background_update && !self::isLocal($url) && Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) { if ($background_update && !self::isLocal($url) && Protocol::supportsProbe($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
try { try {
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']); UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
@ -1279,7 +1279,7 @@ class Contact
$background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true; $background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true;
if ($background_update && !self::isLocal($url) && Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) { if ($background_update && !self::isLocal($url) && Protocol::supportsProbe($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
try { try {
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']); UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
@ -2682,6 +2682,8 @@ class Contact
return true; return true;
} }
$has_local_data = self::hasLocalData($id, $contact);
$uid = $contact['uid']; $uid = $contact['uid'];
unset($contact['uid']); unset($contact['uid']);
@ -2702,18 +2704,20 @@ class Contact
$updated = DateTimeFormat::utcNow(); $updated = DateTimeFormat::utcNow();
$has_local_data = self::hasLocalData($id, $contact); if (!Protocol::supportsProbe($ret['network']) && !Protocol::supportsProbe($contact['network'])) {
if (!Probe::isProbable($ret['network'])) {
// Periodical checks are only done on federated contacts // Periodical checks are only done on federated contacts
$failed_next_update = null; $failed_next_update = null;
$success_next_update = null; $success_next_update = null;
} elseif ($has_local_data) { } elseif ($has_local_data) {
$failed_next_update = GServer::getNextUpdateDate(false, $created, $last_update, !in_array($contact['network'], Protocol::FEDERATED)); $failed_next_update = GServer::getNextUpdateDate(false, $created, $last_update, !in_array($contact['network'], Protocol::FEDERATED));
$success_next_update = GServer::getNextUpdateDate(true, $created, $last_update, !in_array($contact['network'], Protocol::FEDERATED)); $success_next_update = GServer::getNextUpdateDate(true, $created, $last_update, !in_array($contact['network'], Protocol::FEDERATED));
} else { } elseif (in_array($ret['network'], array_merge(Protocol::NATIVE_SUPPORT, [Protocol::ZOT, Protocol::PHANTOM]))) {
$failed_next_update = DateTimeFormat::utc('now +6 month'); $failed_next_update = DateTimeFormat::utc('now +6 month');
$success_next_update = DateTimeFormat::utc('now +1 month'); $success_next_update = DateTimeFormat::utc('now +1 month');
} else {
// We don't check connector networks very often to not run into API rate limits
$failed_next_update = DateTimeFormat::utc('now +12 month');
$success_next_update = DateTimeFormat::utc('now +12 month');
} }
if (Strings::normaliseLink($contact['url']) != Strings::normaliseLink($ret['url'])) { if (Strings::normaliseLink($contact['url']) != Strings::normaliseLink($ret['url'])) {
@ -3596,7 +3600,7 @@ class Contact
if (empty($contact['id']) && Network::isValidHttpUrl($url)) { if (empty($contact['id']) && Network::isValidHttpUrl($url)) {
Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $url); Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $url);
++$added; ++$added;
} elseif (!empty($contact['network']) && Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) { } elseif (!empty($contact['network']) && Protocol::supportsProbe($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
try { try {
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']); UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
++$updated; ++$updated;

View file

@ -918,9 +918,7 @@ class Photo
*/ */
public static function getResourceData(string $name): array public static function getResourceData(string $name): array
{ {
$base = DI::baseUrl(); $guid = str_replace([Strings::normaliseLink((string)DI::baseUrl()), '/photo/'], '', Strings::normaliseLink($name));
$guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name));
if (parse_url($guid, PHP_URL_SCHEME)) { if (parse_url($guid, PHP_URL_SCHEME)) {
return []; return [];
@ -982,9 +980,7 @@ class Photo
*/ */
public static function isLocalPage(string $name): bool public static function isLocalPage(string $name): bool
{ {
$base = DI::baseUrl(); $guid = str_replace(Strings::normaliseLink((string)DI::baseUrl()), '', Strings::normaliseLink($name));
$guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name));
$guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid); $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);
if (empty($guid)) { if (empty($guid)) {
return false; return false;

View file

@ -78,7 +78,7 @@ class Delivery
*/ */
public static function incrementFailed(int $uri_id, string $inbox) public static function incrementFailed(int $uri_id, string $inbox)
{ {
return DBA::e('UPDATE `post-delivery` SET `failed` = `failed` + 1 WHERE `uri-id` = ? AND `inbox-id` = ?', $uri_id, ItemURI::getIdByURI($inbox)); return DBA::update('post-delivery', ["`failed` = `failed` + 1"], ['uri-id' => $uri_id, 'inbox-id' => ItemURI::getIdByURI($inbox)]);
} }
public static function selectForInbox(string $inbox) public static function selectForInbox(string $inbox)

View file

@ -82,27 +82,27 @@ class DeliveryData
*/ */
public static function incrementQueueDone(int $uri_id, int $protocol = 0) public static function incrementQueueDone(int $uri_id, int $protocol = 0)
{ {
$sql = ''; $increments = ["`queue_done` = `queue_done` + 1"];
switch ($protocol) { switch ($protocol) {
case self::ACTIVITYPUB: case self::ACTIVITYPUB:
$sql = ", `activitypub` = `activitypub` + 1"; $increments[] = "`activitypub` = `activitypub` + 1";
break; break;
case self::DFRN: case self::DFRN:
$sql = ", `dfrn` = `dfrn` + 1"; $increments[] = "`dfrn` = `dfrn` + 1";
break; break;
case self::LEGACY_DFRN: case self::LEGACY_DFRN:
$sql = ", `legacy_dfrn` = `legacy_dfrn` + 1"; $increments[] = "`legacy_dfrn` = `legacy_dfrn` + 1";
break; break;
case self::DIASPORA: case self::DIASPORA:
$sql = ", `diaspora` = `diaspora` + 1"; $increments[] = "`diaspora` = `diaspora` + 1";
break; break;
case self::OSTATUS: case self::OSTATUS:
$sql = ", `ostatus` = `ostatus` + 1"; $increments[] = "`ostatus` = `ostatus` + 1";
break; break;
} }
return DBA::e('UPDATE `post-delivery-data` SET `queue_done` = `queue_done` + 1' . $sql . ' WHERE `uri-id` = ?', $uri_id); return DBA::update('post-delivery-data', $increments, ['uri-id' => $uri_id]);
} }
/** /**
@ -116,7 +116,7 @@ class DeliveryData
*/ */
public static function incrementQueueFailed(int $uri_id) public static function incrementQueueFailed(int $uri_id)
{ {
return DBA::e('UPDATE `post-delivery-data` SET `queue_failed` = `queue_failed` + 1 WHERE `uri-id` = ?', $uri_id); return DBA::update('post-delivery-data', ["`queue_failed` = `queue_failed` + 1"], ['uri-id' => $uri_id]);
} }
/** /**
@ -129,7 +129,7 @@ class DeliveryData
*/ */
public static function incrementQueueCount(int $uri_id, int $increment = 1) public static function incrementQueueCount(int $uri_id, int $increment = 1)
{ {
return DBA::e('UPDATE `post-delivery-data` SET `queue_count` = `queue_count` + ? WHERE `uri-id` = ?', $increment, $uri_id); return DBA::update('post-delivery-data', ["`queue_count` = `queue_count` + $increment"], ['uri-id' => $uri_id]);
} }
/** /**

View file

@ -167,7 +167,7 @@ class User
$system['region'] = ''; $system['region'] = '';
$system['postal-code'] = ''; $system['postal-code'] = '';
$system['country-name'] = ''; $system['country-name'] = '';
$system['homepage'] = DI::baseUrl(); $system['homepage'] = (string)DI::baseUrl();
$system['dob'] = '0000-00-00'; $system['dob'] = '0000-00-00';
// Ensure that the user contains data // Ensure that the user contains data

View file

@ -23,6 +23,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Search; use Friendica\Core\Search;
use Friendica\DI; use Friendica\DI;
@ -62,18 +63,13 @@ class BaseSearch extends BaseModule
} }
$header = ''; $header = '';
$results = new ResultList();
if (strpos($search, '@') === 0) { if (strpos($search, '@') === 0) {
$search = trim(substr($search, 1)); $search = trim(substr($search, 1));
$type = Search::TYPE_PEOPLE; $type = Search::TYPE_PEOPLE;
$header = DI::l10n()->t('People Search - %s', $search); $header = DI::l10n()->t('People Search - %s', $search);
} elseif (strpos($search, '!') === 0) {
if (strrpos($search, '@') > 0) {
$results = Search::getContactsFromProbe(Network::convertToIdn($search));
}
}
if (strpos($search, '!') === 0) {
$search = trim(substr($search, 1)); $search = trim(substr($search, 1));
$type = Search::TYPE_FORUM; $type = Search::TYPE_FORUM;
$header = DI::l10n()->t('Forum Search - %s', $search); $header = DI::l10n()->t('Forum Search - %s', $search);
@ -91,14 +87,18 @@ class BaseSearch extends BaseModule
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage); $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
if ($localSearch && empty($results)) { if (!$results->getTotal() && !$localSearch && Search::getGlobalDirectory()) {
$pager->setItemsPerPage(80);
$results = Search::getContactsFromLocalDirectory($search, $type, $pager->getStart(), $pager->getItemsPerPage());
} elseif (Search::getGlobalDirectory() && empty($results)) {
$results = Search::getContactsFromGlobalDirectory($search, $type, $pager->getPage()); $results = Search::getContactsFromGlobalDirectory($search, $type, $pager->getPage());
$pager->setItemsPerPage($results->getItemsPage()); $pager->setItemsPerPage($results->getItemsPage());
} else { }
$results = new ResultList();
if (!$results->getTotal()) {
$pager->setItemsPerPage(80);
$results = Search::getContactsFromLocalDirectory($search, $type, $pager->getStart(), $pager->getItemsPerPage());
}
if (!$results->getTotal()) {
$results = Search::getContactsFromProbe(Network::convertToIdn($search), $type == Search::TYPE_FORUM);
} }
return self::printResult($results, $pager, $header); return self::printResult($results, $pager, $header);
@ -151,4 +151,4 @@ class BaseSearch extends BaseModule
'$paginate' => $pager->renderFull($results->getTotal()), '$paginate' => $pager->renderFull($results->getTotal()),
]); ]);
} }
} }

View file

@ -64,9 +64,9 @@ class HCard extends BaseModule
$page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n"; $page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
} }
$baseUrl = DI::baseUrl(); $baseUrl = (string)DI::baseUrl();
$uri = urlencode('acct:' . $profile['nickname'] . '@' . $baseUrl->getHost() . ($baseUrl->getPath() ? '/' . $baseUrl->getPath() : '')); $uri = urlencode('acct:' . $profile['nickname'] . '@' . DI::baseUrl()->getHost() . (DI::baseUrl()->getPath() ? '/' . DI::baseUrl()->getPath() : ''));
$page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n"; $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n";
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/dfrn_poll/' . $nickname . '" />' . "\r\n"; $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/dfrn_poll/' . $nickname . '" />' . "\r\n";

View file

@ -21,6 +21,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Exception;
use Friendica\App; use Friendica\App;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -30,7 +31,6 @@ use Friendica\Database\Database;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests; use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Util\HTTPSignature; use Friendica\Util\HTTPSignature;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
@ -65,120 +65,102 @@ class Magic extends BaseModule
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$this->logger->info('magic module: invoked'); if ($_SERVER['REQUEST_METHOD'] == 'HEAD') {
$this->logger->debug('Got a HEAD request');
System::exit();
}
$this->logger->debug('args', ['request' => $_REQUEST]); $this->logger->debug('Invoked', ['request' => $request]);
$addr = $request['addr'] ?? ''; $addr = $request['addr'] ?? '';
$dest = $request['dest'] ?? ''; $dest = $request['dest'] ?? '';
$bdest = $request['bdest'] ?? ''; $bdest = $request['bdest'] ?? '';
$owa = intval($request['owa'] ?? 0); $owa = intval($request['owa'] ?? 0);
$cid = 0;
// bdest is preferred as it is hex-encoded and can survive url rewrite and argument parsing // bdest is preferred as it is hex-encoded and can survive url rewrite and argument parsing
if (!empty($bdest)) { if (!empty($bdest)) {
$dest = hex2bin($bdest); $dest = hex2bin($bdest);
$this->logger->info('bdest detected. ', ['dest' => $dest]); $this->logger->debug('bdest detected', ['dest' => $dest]);
} }
if (!empty($addr)) {
$cid = Contact::getIdForURL($addr);
} elseif (!empty($dest)) {
$cid = Contact::getIdForURL($dest);
}
$this->logger->info('Contact ID: ', ['cid' => $cid]);
$contact = false;
if (!$cid) {
$this->logger->info('No contact record found', $_REQUEST);
if ($addr ?: $dest) {
$contact = Contact::getByURL($addr ?: $dest);
}
if (empty($contact)) {
if (!$owa) { if (!$owa) {
// @TODO Finding a more elegant possibility to redirect to either internal or external URL $this->logger->info('No contact record found, no oWA, redirecting to destination.', ['request' => $request, 'server' => $_SERVER, 'dest' => $dest]);
$this->app->redirect($dest); $this->app->redirect($dest);
} }
} else { } else {
$contact = $this->dba->selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
// Redirect if the contact is already authenticated on this site. // Redirect if the contact is already authenticated on this site.
if ($this->app->getContactId() && strpos($contact['nurl'], Strings::normaliseLink($this->baseUrl)) !== false) { if ($this->app->getContactId() && strpos($contact['nurl'], Strings::normaliseLink($this->baseUrl)) !== false) {
$this->logger->info('Contact is already authenticated'); $this->logger->info('Contact is already authenticated, redirecting to destination.', ['dest' => $dest]);
System::externalRedirect($dest); System::externalRedirect($dest);
} }
$this->logger->info('Contact URL: ', ['url' => $contact['url']]); $this->logger->debug('Contact found', ['url' => $contact['url']]);
}
if (!$this->userSession->getLocalUserId() || !$owa) {
$this->logger->notice('Not logged in or not OWA, redirecting to destination.', ['uid' => $this->userSession->getLocalUserId(), 'owa' => $owa, 'dest' => $dest]);
$this->app->redirect($dest);
} }
// OpenWebAuth // OpenWebAuth
if ($this->userSession->getLocalUserId() && $owa) { $owner = User::getOwnerDataById($this->userSession->getLocalUserId());
$this->logger->info('Checking OWA now');
$user = User::getById($this->userSession->getLocalUserId());
$basepath = false; $gserver = $this->dba->selectFirst('gserver', ['url'], ['id' => $contact['gsid']]);
if (!empty($contact)) { if (empty($gserver)) {
$this->logger->info('Contact found - trying friendica style basepath extraction'); $this->logger->notice('Server not found, redirecting to destination.', ['gsid' => $contact['gsid'], 'dest' => $dest]);
// Extract the basepath
// NOTE: we need another solution because this does only work
// for friendica contacts :-/ . We should have the basepath
// of a contact also in the contact table.
$contact_url = $contact['url'];
if (!(strpos($contact_url, '/profile/') === false)) {
$exp = explode('/profile/', $contact['url']);
$basepath = $exp[0];
$this->logger->info('Basepath: ', ['basepath' => $basepath]);
} else {
$this->logger->info('Not possible to extract basepath in friendica style');
}
}
if (!$basepath) {
// For the rest of the OpenWebAuth-enabled Fediverse
$parsed = parse_url($dest);
$this->logger->info('Parsed URL: ', ['parsed URL' => $parsed]);
if (!$parsed) {
System::externalRedirect($dest);
}
$basepath = $parsed['scheme'] . '://' . $parsed['host'] . (isset($parsed['port']) ? ':' . $parsed['port'] : '');
}
$accept_headers = ['application/x-dfrn+json', 'application/x-zot+json'];
$header = [
'Accept' => $accept_headers,
'X-Open-Web-Auth' => [Strings::getRandomHex()],
];
// Create a header that is signed with the local users private key.
$header = HTTPSignature::createSig(
$header,
$user['prvkey'],
'acct:' . $user['nickname'] . '@' . $this->baseUrl->getHost() . ($this->baseUrl->getPath() ? '/' . $this->baseUrl->getPath() : '')
);
$this->logger->info('Headers: ', ['headers' => $header]);
// Try to get an authentication token from the other instance.
$curlResult = $this->httpClient->get($basepath . '/owa', HttpClientAccept::DEFAULT, [HttpClientOptions::HEADERS => $header, HttpClientOptions::ACCEPT_CONTENT => $accept_headers]);
if ($curlResult->isSuccess()) {
$j = json_decode($curlResult->getBody(), true);
$this->logger->info('Curl result body: ', ['body' => $j]);
if ($j['success']) {
$token = '';
if ($j['encrypted_token']) {
// The token is encrypted. If the local user is really the one the other instance
// thinks he/she is, the token can be decrypted with the local users public key.
openssl_private_decrypt(Strings::base64UrlDecode($j['encrypted_token']), $token, $user['prvkey']);
} else {
$token = $j['token'];
}
$args = (strpbrk($dest, '?&') ? '&' : '?') . 'owt=' . $token;
$this->logger->info('Redirecting', ['path' => $dest . $args]);
System::externalRedirect($dest . $args);
}
}
System::externalRedirect($dest); System::externalRedirect($dest);
} }
// @TODO Finding a more elegant possibility to redirect to either internal or external URL $basepath = $gserver['url'];
$this->app->redirect($dest);
$header = [
'Accept' => ['application/x-dfrn+json', 'application/x-zot+json'],
'X-Open-Web-Auth' => [Strings::getRandomHex()],
];
// Create a header that is signed with the local users private key.
$header = HTTPSignature::createSig(
$header,
$owner['prvkey'],
'acct:' . $owner['addr']
);
$this->logger->info('Fetch from remote system', ['basepath' => $basepath, 'headers' => $header]);
// Try to get an authentication token from the other instance.
try {
$curlResult = $this->httpClient->request('get', $basepath . '/owa', [HttpClientOptions::HEADERS => $header]);
} catch (Exception $exception) {
$this->logger->notice('URL is invalid, redirecting to destination.', ['url' => $basepath, 'error' => $exception, 'dest' => $dest]);
System::externalRedirect($dest);
}
if (!$curlResult->isSuccess()) {
$this->logger->notice('OWA request failed, redirecting to destination.', ['returncode' => $curlResult->getReturnCode(), 'dest' => $dest]);
System::externalRedirect($dest);
}
$j = json_decode($curlResult->getBody(), true);
if (empty($j) || !$j['success']) {
$this->logger->notice('Invalid JSON, redirecting to destination.', ['json' => $j, 'dest' => $dest]);
$this->app->redirect($dest);
}
if ($j['encrypted_token']) {
// The token is encrypted. If the local user is really the one the other instance
// thinks they is, the token can be decrypted with the local users public key.
$token = '';
openssl_private_decrypt(Strings::base64UrlDecode($j['encrypted_token']), $token, $owner['prvkey']);
} else {
$token = $j['token'];
}
$args = (strpbrk($dest, '?&') ? '&' : '?') . 'owt=' . $token;
$this->logger->debug('Redirecting', ['path' => $dest . $args]);
System::externalRedirect($dest . $args);
} }
} }

View file

@ -40,7 +40,7 @@ class OpenSearch extends BaseModule
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$hostname = DI::baseUrl()->getHost(); $hostname = DI::baseUrl()->getHost();
$baseUrl = DI::baseUrl(); $baseUrl = (string)DI::baseUrl();
/** @var DOMDocument $xml */ /** @var DOMDocument $xml */
XML::fromArray([ XML::fromArray([

View file

@ -298,7 +298,7 @@ class Register extends BaseModule
$user = $result['user']; $user = $result['user'];
$base_url = DI::baseUrl(); $base_url = (string)DI::baseUrl();
if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) { if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) {
$url = $base_url . '/profile/' . $user['nickname']; $url = $base_url . '/profile/' . $user['nickname'];

View file

@ -46,7 +46,7 @@ class HostMeta extends BaseModule
$config->set('system', 'site_pubkey', $res['pubkey']); $config->set('system', 'site_pubkey', $res['pubkey']);
} }
$domain = DI::baseUrl(); $domain = (string)DI::baseUrl();
XML::fromArray([ XML::fromArray([
'XRD' => [ 'XRD' => [

View file

@ -134,6 +134,6 @@ class Notify extends BaseEntity
*/ */
public static function formatMessage(string $name, string $message): string public static function formatMessage(string $name, string $message): string
{ {
return str_replace('{0}', '<span class="contactname">' . strip_tags(BBCode::convert($name)) . '</span>', $message); return str_replace('{0}', '<span class="contactname">' . strip_tags(BBCode::convert($name)) . '</span>', htmlspecialchars($message));
} }
} }

View file

@ -312,7 +312,7 @@ class Queue
// Optimizing this table only last seconds // Optimizing this table only last seconds
if (DI::config()->get('system', 'optimize_tables')) { if (DI::config()->get('system', 'optimize_tables')) {
Logger::info('Optimize start'); Logger::info('Optimize start');
DBA::e("OPTIMIZE TABLE `inbox-entry`"); DBA::optimizeTable('inbox-entry');
Logger::info('Optimize end'); Logger::info('Optimize end');
} }
} }

View file

@ -330,7 +330,7 @@ class Transmitter
return [ return [
'type' => 'Service', 'type' => 'Service',
'name' => App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION, 'name' => App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION,
'url' => DI::baseUrl() 'url' => (string)DI::baseUrl()
]; ];
} }

View file

@ -478,7 +478,7 @@ class Feed
$attachments = []; $attachments = [];
$enclosures = $xpath->query("enclosure|' . $atomns . ':link[@rel='enclosure']", $entry); $enclosures = $xpath->query("enclosure|$atomns:link[@rel='enclosure']", $entry);
if (!empty($enclosures)) { if (!empty($enclosures)) {
foreach ($enclosures as $enclosure) { foreach ($enclosures as $enclosure) {
$href = ''; $href = '';

View file

@ -163,15 +163,6 @@ class Cron
{ {
Logger::info('Looking for sleeping processes'); Logger::info('Looking for sleeping processes');
$processes = DBA::p("SHOW FULL PROCESSLIST"); DBA::deleteSleepingProcesses();
while ($process = DBA::fetch($processes)) {
if (($process['Command'] != 'Sleep') || ($process['Time'] < 300) || ($process['db'] != DBA::databaseName())) {
continue;
}
DBA::e("KILL ?", $process['Id']);
Logger::notice('Killed sleeping process', ['id' => $process['Id']]);
}
DBA::close($processes);
} }
} }

View file

@ -40,36 +40,36 @@ class OptimizeTables
Logger::info('Optimize start'); Logger::info('Optimize start');
DBA::e("OPTIMIZE TABLE `cache`"); DBA::optimizeTable('cache');
DBA::e("OPTIMIZE TABLE `locks`"); DBA::optimizeTable('locks');
DBA::e("OPTIMIZE TABLE `oembed`"); DBA::optimizeTable('oembed');
DBA::e("OPTIMIZE TABLE `parsed_url`"); DBA::optimizeTable('parsed_url');
DBA::e("OPTIMIZE TABLE `session`"); DBA::optimizeTable('session');
if (DI::config()->get('system', 'optimize_all_tables')) { if (DI::config()->get('system', 'optimize_all_tables')) {
DBA::e("OPTIMIZE TABLE `apcontact`"); DBA::optimizeTable('apcontact');
DBA::e("OPTIMIZE TABLE `contact`"); DBA::optimizeTable('contact');
DBA::e("OPTIMIZE TABLE `contact-relation`"); DBA::optimizeTable('contact-relation');
DBA::e("OPTIMIZE TABLE `conversation`"); DBA::optimizeTable('conversation');
DBA::e("OPTIMIZE TABLE `diaspora-contact`"); DBA::optimizeTable('diaspora-contact');
DBA::e("OPTIMIZE TABLE `diaspora-interaction`"); DBA::optimizeTable('diaspora-interaction');
DBA::e("OPTIMIZE TABLE `fcontact`"); DBA::optimizeTable('fcontact');
DBA::e("OPTIMIZE TABLE `gserver`"); DBA::optimizeTable('gserver');
DBA::e("OPTIMIZE TABLE `gserver-tag`"); DBA::optimizeTable('gserver-tag');
DBA::e("OPTIMIZE TABLE `inbox-status`"); DBA::optimizeTable('inbox-status');
DBA::e("OPTIMIZE TABLE `item-uri`"); DBA::optimizeTable('item-uri');
DBA::e("OPTIMIZE TABLE `notification`"); DBA::optimizeTable('notification');
DBA::e("OPTIMIZE TABLE `notify`"); DBA::optimizeTable('notify');
DBA::e("OPTIMIZE TABLE `photo`"); DBA::optimizeTable('photo');
DBA::e("OPTIMIZE TABLE `post`"); DBA::optimizeTable('post');
DBA::e("OPTIMIZE TABLE `post-content`"); DBA::optimizeTable('post-content');
DBA::e("OPTIMIZE TABLE `post-delivery-data`"); DBA::optimizeTable('post-delivery-data');
DBA::e("OPTIMIZE TABLE `post-link`"); DBA::optimizeTable('post-link');
DBA::e("OPTIMIZE TABLE `post-thread`"); DBA::optimizeTable('post-thread');
DBA::e("OPTIMIZE TABLE `post-thread-user`"); DBA::optimizeTable('post-thread-user');
DBA::e("OPTIMIZE TABLE `post-user`"); DBA::optimizeTable('post-user');
DBA::e("OPTIMIZE TABLE `storage`"); DBA::optimizeTable('storage');
DBA::e("OPTIMIZE TABLE `tag`"); DBA::optimizeTable('tag');
} }
Logger::info('Optimize end'); Logger::info('Optimize end');

View file

@ -35,6 +35,15 @@ return [
'workerqueue', 'workerqueue',
'mail', 'mail',
'post-delivery-data', 'post-delivery-data',
'gserver' => [
[
'url' => 'https://friendica.local',
'nurl' => 'http://friendica.local',
'register_policy' => 0,
'registered-users' => 0,
'network' => 'unkn',
],
],
// Base test config to avoid notice messages // Base test config to avoid notice messages
'user' => [ 'user' => [
[ [

View file

@ -259,12 +259,12 @@ Karl Marx - Die ursprüngliche Akkumulation
'text' => '[emoji=https://fedi.underscore.world/emoji/custom/custom/heart_nb.png]:heart_nb:[/emoji]', 'text' => '[emoji=https://fedi.underscore.world/emoji/custom/custom/heart_nb.png]:heart_nb:[/emoji]',
], ],
'task-12900-multiple-paragraphs' => [ 'task-12900-multiple-paragraphs' => [
'expectedHTML' => '<h1>Header</h1><ul><li>One</li><li>Two</li></ul><p>This is a paragraph<br>with a line feed.</p><p>Second Chapter</p>', 'expectedHTML' => '<h4>Header</h4><ul><li>One</li><li>Two</li></ul><p>This is a paragraph<br>with a line feed.</p><p>Second Chapter</p>',
'text' => "[h1]Header[/h1][ul][*]One[*]Two[/ul]\n\nThis is a paragraph\nwith a line feed.\n\nSecond Chapter", 'text' => "[h4]Header[/h4][ul][*]One[*]Two[/ul]\n\nThis is a paragraph\nwith a line feed.\n\nSecond Chapter",
], ],
'task-12900-header-with-paragraphs' => [ 'task-12900-header-with-paragraphs' => [
'expectedHTML' => '<h1>Header</h1><p>Some Chapter</p>', 'expectedHTML' => '<h4>Header</h4><p>Some Chapter</p>',
'text' => '[h1]Header[/h1]Some Chapter', 'text' => '[h4]Header[/h4]Some Chapter',
], ],
'bug-12842-ul-newlines' => [ 'bug-12842-ul-newlines' => [
'expectedHTML' => '<p>This is:</p><ul><li>some</li><li>amazing</li><li>list</li></ul>', 'expectedHTML' => '<p>This is:</p><ul><li>some</li><li>amazing</li><li>list</li></ul>',

View file

@ -0,0 +1,103 @@
<?php
/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Test\src\Database;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Test\FixtureTest;
use Friendica\Test\Util\CreateDatabaseTrait;
class DatabaseTest extends FixtureTest
{
use CreateDatabaseTrait;
protected function setUp(): void
{
$this->setUpVfsDir();
parent::setUp();
$this->configCache = new Cache();
$this->configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/');
}
/**
* Test, if directly updating a field is possible
*/
public function testUpdateIncrease()
{
$db = $this->getDbInstance();
self::assertTrue($db->insert('config', ['cat' => 'test', 'k' => 'inc', 'v' => 0]));
self::assertTrue($db->update('config', ["`v` = `v` + 1"], ['cat' => 'test', 'k' => 'inc']));
self::assertEquals(1, $db->selectFirst('config', ['v'], ['cat' => 'test', 'k' => 'inc'])['v']);
}
/**
* Test if combining directly field updates with normal updates is working
*/
public function testUpdateWithField()
{
$db = $this->getDbInstance();
self::assertEquals('https://friendica.local', $db->selectFirst('gserver', ['url'], ['nurl' => 'http://friendica.local'])['url']);
self::assertTrue($db->update('gserver', ['active-week-users' => 0], ['nurl' => 'http://friendica.local']));
self::assertTrue($db->update('gserver', [
'site_name' => 'test', "`registered-users` = `registered-users` + 1",
'info' => 'another test',
"`active-week-users` = `active-week-users` + 2"
], [
'nurl' => 'http://friendica.local'
]));
self::assertEquals(1, $db->selectFirst('gserver', ['registered-users'], ['nurl' => 'http://friendica.local'])['registered-users']);
self::assertEquals(2, $db->selectFirst('gserver', ['active-week-users'], ['nurl' => 'http://friendica.local'])['active-week-users']);
self::assertTrue($db->update('gserver', [
'site_name' => 'test', "`registered-users` = `registered-users` + 1",
'info' => 'another test'
], [
'nurl' => 'http://friendica.local'
]));
self::assertEquals(2, $db->selectFirst('gserver', ['registered-users'], ['nurl' => 'http://friendica.local'])['registered-users']);
self::assertTrue($db->update('gserver', [
'site_name' => 'test', "`registered-users` = `registered-users` - 1",
'info' => 'another test'
], [
'nurl' => 'http://friendica.local'
]));
self::assertEquals(1, $db->selectFirst('gserver', ['registered-users'], ['nurl' => 'http://friendica.local'])['registered-users']);
}
public function testUpdateWithArray()
{
$db = $this->getDbInstance();
self::assertTrue($db->update('gserver', ['active-week-users' => 0, 'registered-users' => 0], ['nurl' => 'http://friendica.local']));
$fields = ["`registered-users` = `registered-users` + 1"];
$fields[] = "`active-week-users` = `active-week-users` + 2";
self::assertTrue($db->update('gserver', $fields, ['nurl' => 'http://friendica.local']));
self::assertEquals(2, $db->selectFirst('gserver', ['active-week-users'], ['nurl' => 'http://friendica.local'])['active-week-users']);
self::assertEquals(1, $db->selectFirst('gserver', ['registered-users'], ['nurl' => 'http://friendica.local'])['registered-users']);
}
}

View file

@ -0,0 +1,47 @@
<?php
/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Test\src\Navigation\Notifications\Entity;
use Friendica\Navigation\Notifications\Entity\Notify;
use Friendica\Test\FixtureTest;
class NotifyTest extends FixtureTest
{
public function dataFormatNotify(): array
{
return [
'xss-notify' => [
'name' => 'Whiskers',
'message' => '{0} commented in the thread "If my username causes a pop up in a piece of software, that softwar…" from <script>alert("Tek");</script>',
'assertion' => '<span class="contactname">Whiskers</span> commented in the thread &quot;If my username causes a pop up in a piece of software, that softwar…&quot; from &lt;script&gt;alert(&quot;Tek&quot;);&lt;/script&gt;',
],
];
}
/**
* @dataProvider dataFormatNotify
*/
public function testFormatNotify(string $name, string $message, string $assertion)
{
self::assertEquals($assertion, Notify::formatMessage($name, $message));
}
}

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2023.06-dev\n" "Project-Id-Version: 2023.06-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-05-09 06:34+0000\n" "POT-Creation-Date: 2023-05-12 07:57+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -44,7 +44,7 @@ msgstr ""
msgid "Item not found." msgid "Item not found."
msgstr "" msgstr ""
#: mod/item.php:435 mod/message.php:68 mod/message.php:114 mod/notes.php:45 #: mod/item.php:435 mod/message.php:67 mod/message.php:113 mod/notes.php:45
#: mod/photos.php:152 mod/photos.php:669 src/Model/Event.php:522 #: mod/photos.php:152 mod/photos.php:669 src/Model/Event.php:522
#: src/Module/Attach.php:55 src/Module/BaseApi.php:99 #: src/Module/Attach.php:55 src/Module/BaseApi.php:99
#: src/Module/BaseNotifications.php:98 src/Module/BaseSettings.php:52 #: src/Module/BaseNotifications.php:98 src/Module/BaseSettings.php:52
@ -219,86 +219,86 @@ msgstr ""
msgid "Your password has been changed at %s" msgid "Your password has been changed at %s"
msgstr "" msgstr ""
#: mod/message.php:46 mod/message.php:129 src/Content/Nav.php:319 #: mod/message.php:46 mod/message.php:128 src/Content/Nav.php:319
msgid "New Message" msgid "New Message"
msgstr "" msgstr ""
#: mod/message.php:83 src/Module/Profile/UnkMail.php:100 #: mod/message.php:82 src/Module/Profile/UnkMail.php:100
msgid "No recipient selected." msgid "No recipient selected."
msgstr "" msgstr ""
#: mod/message.php:88 #: mod/message.php:87
msgid "Unable to locate contact information." msgid "Unable to locate contact information."
msgstr "" msgstr ""
#: mod/message.php:92 src/Module/Profile/UnkMail.php:106 #: mod/message.php:91 src/Module/Profile/UnkMail.php:106
msgid "Message could not be sent." msgid "Message could not be sent."
msgstr "" msgstr ""
#: mod/message.php:96 src/Module/Profile/UnkMail.php:109 #: mod/message.php:95 src/Module/Profile/UnkMail.php:109
msgid "Message collection failure." msgid "Message collection failure."
msgstr "" msgstr ""
#: mod/message.php:123 src/Module/Notifications/Introductions.php:135 #: mod/message.php:122 src/Module/Notifications/Introductions.php:135
#: src/Module/Notifications/Introductions.php:170 #: src/Module/Notifications/Introductions.php:170
#: src/Module/Notifications/Notification.php:85 #: src/Module/Notifications/Notification.php:85
msgid "Discard" msgid "Discard"
msgstr "" msgstr ""
#: mod/message.php:136 src/Content/Nav.php:316 view/theme/frio/theme.php:241 #: mod/message.php:135 src/Content/Nav.php:316 view/theme/frio/theme.php:241
msgid "Messages" msgid "Messages"
msgstr "" msgstr ""
#: mod/message.php:149 #: mod/message.php:148
msgid "Conversation not found." msgid "Conversation not found."
msgstr "" msgstr ""
#: mod/message.php:154 #: mod/message.php:153
msgid "Message was not deleted." msgid "Message was not deleted."
msgstr "" msgstr ""
#: mod/message.php:169 #: mod/message.php:168
msgid "Conversation was not removed." msgid "Conversation was not removed."
msgstr "" msgstr ""
#: mod/message.php:182 mod/message.php:287 src/Module/Profile/UnkMail.php:145 #: mod/message.php:181 mod/message.php:286 src/Module/Profile/UnkMail.php:145
msgid "Please enter a link URL:" msgid "Please enter a link URL:"
msgstr "" msgstr ""
#: mod/message.php:191 src/Module/Profile/UnkMail.php:151 #: mod/message.php:190 src/Module/Profile/UnkMail.php:151
msgid "Send Private Message" msgid "Send Private Message"
msgstr "" msgstr ""
#: mod/message.php:192 mod/message.php:347 #: mod/message.php:191 mod/message.php:346
msgid "To:" msgid "To:"
msgstr "" msgstr ""
#: mod/message.php:193 mod/message.php:348 #: mod/message.php:192 mod/message.php:347
msgid "Subject:" msgid "Subject:"
msgstr "" msgstr ""
#: mod/message.php:197 mod/message.php:351 src/Module/Invite.php:171 #: mod/message.php:196 mod/message.php:350 src/Module/Invite.php:171
msgid "Your message:" msgid "Your message:"
msgstr "" msgstr ""
#: mod/message.php:200 mod/message.php:355 src/Content/Conversation.php:360 #: mod/message.php:199 mod/message.php:354 src/Content/Conversation.php:360
#: src/Module/Post/Edit.php:131 #: src/Module/Post/Edit.php:131
msgid "Upload photo" msgid "Upload photo"
msgstr "" msgstr ""
#: mod/message.php:201 mod/message.php:356 src/Module/Post/Edit.php:135 #: mod/message.php:200 mod/message.php:355 src/Module/Post/Edit.php:135
#: src/Module/Profile/UnkMail.php:153 #: src/Module/Profile/UnkMail.php:153
msgid "Insert web link" msgid "Insert web link"
msgstr "" msgstr ""
#: mod/message.php:202 mod/message.php:358 mod/photos.php:1291 #: mod/message.php:201 mod/message.php:357 mod/photos.php:1291
#: src/Content/Conversation.php:390 src/Content/Conversation.php:734 #: src/Content/Conversation.php:390 src/Content/Conversation.php:734
#: src/Module/Item/Compose.php:205 src/Module/Post/Edit.php:145 #: src/Module/Item/Compose.php:205 src/Module/Post/Edit.php:145
#: src/Module/Profile/UnkMail.php:154 src/Object/Post.php:550 #: src/Module/Profile/UnkMail.php:154 src/Object/Post.php:550
msgid "Please wait" msgid "Please wait"
msgstr "" msgstr ""
#: mod/message.php:203 mod/message.php:357 mod/photos.php:702 #: mod/message.php:202 mod/message.php:356 mod/photos.php:702
#: mod/photos.php:819 mod/photos.php:1097 mod/photos.php:1138 #: mod/photos.php:819 mod/photos.php:1097 mod/photos.php:1138
#: mod/photos.php:1194 mod/photos.php:1268 #: mod/photos.php:1194 mod/photos.php:1268
#: src/Module/Calendar/Event/Form.php:250 src/Module/Contact/Advanced.php:132 #: src/Module/Calendar/Event/Form.php:250 src/Module/Contact/Advanced.php:132
@ -317,52 +317,52 @@ msgstr ""
msgid "Submit" msgid "Submit"
msgstr "" msgstr ""
#: mod/message.php:224 #: mod/message.php:223
msgid "No messages." msgid "No messages."
msgstr "" msgstr ""
#: mod/message.php:280 #: mod/message.php:279
msgid "Message not available." msgid "Message not available."
msgstr "" msgstr ""
#: mod/message.php:324 #: mod/message.php:323
msgid "Delete message" msgid "Delete message"
msgstr "" msgstr ""
#: mod/message.php:326 mod/message.php:457 #: mod/message.php:325 mod/message.php:456
msgid "D, d M Y - g:i A" msgid "D, d M Y - g:i A"
msgstr "" msgstr ""
#: mod/message.php:341 mod/message.php:454 #: mod/message.php:340 mod/message.php:453
msgid "Delete conversation" msgid "Delete conversation"
msgstr "" msgstr ""
#: mod/message.php:343 #: mod/message.php:342
msgid "" msgid ""
"No secure communications available. You <strong>may</strong> be able to " "No secure communications available. You <strong>may</strong> be able to "
"respond from the sender's profile page." "respond from the sender's profile page."
msgstr "" msgstr ""
#: mod/message.php:346 #: mod/message.php:345
msgid "Send Reply" msgid "Send Reply"
msgstr "" msgstr ""
#: mod/message.php:428 #: mod/message.php:427
#, php-format #, php-format
msgid "Unknown sender - %s" msgid "Unknown sender - %s"
msgstr "" msgstr ""
#: mod/message.php:430 #: mod/message.php:429
#, php-format #, php-format
msgid "You and %s" msgid "You and %s"
msgstr "" msgstr ""
#: mod/message.php:432 #: mod/message.php:431
#, php-format #, php-format
msgid "%s and You" msgid "%s and You"
msgstr "" msgstr ""
#: mod/message.php:460 #: mod/message.php:459
#, php-format #, php-format
msgid "%d message" msgid "%d message"
msgid_plural "%d messages" msgid_plural "%d messages"
@ -1683,7 +1683,7 @@ msgstr ""
#: src/Content/Item.php:439 src/Content/Widget.php:80 #: src/Content/Item.php:439 src/Content/Widget.php:80
#: src/Model/Contact.php:1199 src/Model/Contact.php:1210 #: src/Model/Contact.php:1199 src/Model/Contact.php:1210
#: src/Module/Contact/Follow.php:167 view/theme/vier/theme.php:196 #: src/Module/Contact/Follow.php:167 view/theme/vier/theme.php:195
msgid "Connect/Follow" msgid "Connect/Follow"
msgstr "" msgstr ""
@ -1804,7 +1804,7 @@ msgstr ""
#: src/Module/Settings/TwoFactor/AppSpecific.php:129 #: src/Module/Settings/TwoFactor/AppSpecific.php:129
#: src/Module/Settings/TwoFactor/Index.php:118 #: src/Module/Settings/TwoFactor/Index.php:118
#: src/Module/Settings/TwoFactor/Recovery.php:107 #: src/Module/Settings/TwoFactor/Recovery.php:107
#: src/Module/Settings/TwoFactor/Verify.php:146 view/theme/vier/theme.php:241 #: src/Module/Settings/TwoFactor/Verify.php:146 view/theme/vier/theme.php:240
msgid "Help" msgid "Help"
msgstr "" msgstr ""
@ -2081,46 +2081,46 @@ msgid_plural "%d invitations available"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: src/Content/Widget.php:78 view/theme/vier/theme.php:194 #: src/Content/Widget.php:78 view/theme/vier/theme.php:193
msgid "Find People" msgid "Find People"
msgstr "" msgstr ""
#: src/Content/Widget.php:79 view/theme/vier/theme.php:195 #: src/Content/Widget.php:79 view/theme/vier/theme.php:194
msgid "Enter name or interest" msgid "Enter name or interest"
msgstr "" msgstr ""
#: src/Content/Widget.php:81 view/theme/vier/theme.php:197 #: src/Content/Widget.php:81 view/theme/vier/theme.php:196
msgid "Examples: Robert Morgenstein, Fishing" msgid "Examples: Robert Morgenstein, Fishing"
msgstr "" msgstr ""
#: src/Content/Widget.php:82 src/Module/Contact.php:432 #: src/Content/Widget.php:82 src/Module/Contact.php:432
#: src/Module/Directory.php:96 view/theme/vier/theme.php:198 #: src/Module/Directory.php:96 view/theme/vier/theme.php:197
msgid "Find" msgid "Find"
msgstr "" msgstr ""
#: src/Content/Widget.php:83 src/Module/Contact/Suggestions.php:73 #: src/Content/Widget.php:83 src/Module/Contact/Suggestions.php:73
#: view/theme/vier/theme.php:199 #: view/theme/vier/theme.php:198
msgid "Friend Suggestions" msgid "Friend Suggestions"
msgstr "" msgstr ""
#: src/Content/Widget.php:84 view/theme/vier/theme.php:200 #: src/Content/Widget.php:84 view/theme/vier/theme.php:199
msgid "Similar Interests" msgid "Similar Interests"
msgstr "" msgstr ""
#: src/Content/Widget.php:85 view/theme/vier/theme.php:201 #: src/Content/Widget.php:85 view/theme/vier/theme.php:200
msgid "Random Profile" msgid "Random Profile"
msgstr "" msgstr ""
#: src/Content/Widget.php:86 view/theme/vier/theme.php:202 #: src/Content/Widget.php:86 view/theme/vier/theme.php:201
msgid "Invite Friends" msgid "Invite Friends"
msgstr "" msgstr ""
#: src/Content/Widget.php:87 src/Module/Directory.php:88 #: src/Content/Widget.php:87 src/Module/Directory.php:88
#: view/theme/vier/theme.php:203 #: view/theme/vier/theme.php:202
msgid "Global Directory" msgid "Global Directory"
msgstr "" msgstr ""
#: src/Content/Widget.php:89 view/theme/vier/theme.php:205 #: src/Content/Widget.php:89 view/theme/vier/theme.php:204
msgid "Local Directory" msgid "Local Directory"
msgstr "" msgstr ""
@ -3272,7 +3272,7 @@ msgstr ""
msgid "[no subject]" msgid "[no subject]"
msgstr "" msgstr ""
#: src/Model/Photo.php:1188 src/Module/Media/Photo/Upload.php:171 #: src/Model/Photo.php:1184 src/Module/Media/Photo/Upload.php:171
msgid "Wall Photos" msgid "Wall Photos"
msgstr "" msgstr ""
@ -5546,11 +5546,11 @@ msgstr ""
msgid "Forum Search - %s" msgid "Forum Search - %s"
msgstr "" msgstr ""
#: src/Module/BaseSearch.php:121 src/Module/Contact/MatchInterests.php:139 #: src/Module/BaseSearch.php:123 src/Module/Contact/MatchInterests.php:139
msgid "No matches" msgid "No matches"
msgstr "" msgstr ""
#: src/Module/BaseSearch.php:147 #: src/Module/BaseSearch.php:149
#, php-format #, php-format
msgid "" msgid ""
"%d result was filtered out because your node blocks the domain it is " "%d result was filtered out because your node blocks the domain it is "
@ -11876,7 +11876,7 @@ msgstr ""
msgid "Community Pages" msgid "Community Pages"
msgstr "" msgstr ""
#: view/theme/vier/config.php:139 view/theme/vier/theme.php:149 #: view/theme/vier/config.php:139 view/theme/vier/theme.php:148
msgid "Community Profiles" msgid "Community Profiles"
msgstr "" msgstr ""
@ -11884,7 +11884,7 @@ msgstr ""
msgid "Help or @NewHere ?" msgid "Help or @NewHere ?"
msgstr "" msgstr ""
#: view/theme/vier/config.php:141 view/theme/vier/theme.php:320 #: view/theme/vier/config.php:141 view/theme/vier/theme.php:319
msgid "Connect Services" msgid "Connect Services"
msgstr "" msgstr ""
@ -11892,10 +11892,10 @@ msgstr ""
msgid "Find Friends" msgid "Find Friends"
msgstr "" msgstr ""
#: view/theme/vier/config.php:143 view/theme/vier/theme.php:176 #: view/theme/vier/config.php:143 view/theme/vier/theme.php:175
msgid "Last users" msgid "Last users"
msgstr "" msgstr ""
#: view/theme/vier/theme.php:235 #: view/theme/vier/theme.php:234
msgid "Quick Start" msgid "Quick Start"
msgstr "" msgstr ""

View file

@ -1,4 +1,4 @@
<div class="notif-item {{if !$item_seen}}unseen{{/if}}" {{if $item_seen}}aria-hidden="true"{{/if}}> <div class="notif-item {{if !$item_seen}}unseen{{/if}}" {{if $item_seen}}aria-hidden="true"{{/if}}>
<a href="{{$notification.link}}"><img src="{{$notification.image}}" aria-hidden="true" class="notif-image">{{$notification.text nofilter}} <span class="notif-when">{{$notification.ago}}</span></a> <a href="{{$notification.link}}"><img src="{{$notification.image}}" aria-hidden="true" class="notif-image">{{$notification.text}} <span class="notif-when">{{$notification.ago}}</span></a>
</div> </div>

View file

@ -45,7 +45,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
<head> <head>
<title><?php if (!empty($page['title'])) echo $page['title'] ?></title> <title><?php if (!empty($page['title'])) echo $page['title'] ?></title>
<meta request="<?php echo htmlspecialchars($_REQUEST['pagename'] ?? '') ?>"> <meta request="<?php echo htmlspecialchars($_REQUEST['pagename'] ?? '') ?>">
<script type="text/javascript">var baseurl = "<?php echo DI::baseUrl(); ?>";</script> <script type="text/javascript">var baseurl = "<?php echo (string)DI::baseUrl(); ?>";</script>
<script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script> <script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script>
<?php <?php
// Because we use minimal for modals the header and the included js stuff should be only loaded // Because we use minimal for modals the header and the included js stuff should be only loaded

View file

@ -41,7 +41,7 @@
<button type="button" class="navbar-toggle collapsed pull-left visible-sm visible-xs" <button type="button" class="navbar-toggle collapsed pull-left visible-sm visible-xs"
data-toggle="offcanvas" data-target="aside" aria-haspopup="true"> data-toggle="offcanvas" data-target="aside" aria-haspopup="true">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">Toggle navigation</span>
<i class="fa fa-ellipsis-v fa-fw fa-lg" aria-hidden="true"></i> <i class="fa fa-angle-double-right fa-fw fa-lg" aria-hidden="true"></i>
</button> </button>
{{* Left section of the NavBar with navigation shortcuts/icons *}} {{* Left section of the NavBar with navigation shortcuts/icons *}}

View file

@ -45,7 +45,7 @@ function smoothly_init(App $a) {
$cssFile = null; $cssFile = null;
$ssl_state = false; $ssl_state = false;
$baseurl = DI::baseUrl(); $baseurl = (string)DI::baseUrl();
DI::page()['htmlhead'] .= <<< EOT DI::page()['htmlhead'] .= <<< EOT
<script> <script>
@ -112,7 +112,7 @@ if (! function_exists('_js_in_foot')) {
/** @purpose insert stuff in bottom of page /** @purpose insert stuff in bottom of page
*/ */
$ssl_state = false; $ssl_state = false;
$baseurl = DI::baseUrl(); $baseurl = (string)DI::baseUrl();
$bottom['$baseurl'] = $baseurl; $bottom['$baseurl'] = $baseurl;
$tpl = Renderer::getMarkupTemplate('bottom.tpl'); $tpl = Renderer::getMarkupTemplate('bottom.tpl');

View file

@ -137,8 +137,7 @@ function vier_community_info()
$show_lastusers = get_vier_config("show_lastusers", 1); $show_lastusers = get_vier_config("show_lastusers", 1);
// get_baseurl // get_baseurl
$url = DI::baseUrl(); $aside['$url'] = $url = (string)DI::baseUrl();
$aside['$url'] = $url;
// community_profiles // community_profiles
if ($show_profiles) { if ($show_profiles) {