Changes:
- reformatted some array - added missing documentation - added type-hints - changed double-quotes to single
This commit is contained in:
parent
c6c936a80f
commit
b8353a6eb7
10 changed files with 106 additions and 84 deletions
|
@ -36,7 +36,7 @@ class Group
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getById(int $gid)
|
public static function getById(int $gid): array
|
||||||
{
|
{
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ class Relation
|
||||||
* @param array $rel
|
* @param array $rel
|
||||||
* @return array contact list
|
* @return array contact list
|
||||||
*/
|
*/
|
||||||
private static function getContacts(int $uid, array $rel)
|
private static function getContacts(int $uid, array $rel): array
|
||||||
{
|
{
|
||||||
$list = [];
|
$list = [];
|
||||||
$profile = Profile::getByUID($uid);
|
$profile = Profile::getByUID($uid);
|
||||||
|
@ -182,8 +182,15 @@ class Relation
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = ['rel' => $rel, 'uid' => $uid, 'self' => false, 'deleted' => false,
|
$condition = [
|
||||||
'hidden' => false, 'archive' => false, 'pending' => false];
|
'rel' => $rel,
|
||||||
|
'uid' => $uid,
|
||||||
|
'self' => false,
|
||||||
|
'deleted' => false,
|
||||||
|
'hidden' => false,
|
||||||
|
'archive' => false,
|
||||||
|
'pending' => false,
|
||||||
|
];
|
||||||
$condition = DBA::mergeConditions($condition, ["`url` IN (SELECT `url` FROM `apcontact`)"]);
|
$condition = DBA::mergeConditions($condition, ["`url` IN (SELECT `url` FROM `apcontact`)"]);
|
||||||
$contacts = DBA::select('contact', ['url'], $condition);
|
$contacts = DBA::select('contact', ['url'], $condition);
|
||||||
while ($contact = DBA::fetch($contacts)) {
|
while ($contact = DBA::fetch($contacts)) {
|
||||||
|
@ -201,7 +208,7 @@ class Relation
|
||||||
* @param array $contact Contact array
|
* @param array $contact Contact array
|
||||||
* @return boolean True if contact is discoverable
|
* @return boolean True if contact is discoverable
|
||||||
*/
|
*/
|
||||||
public static function isDiscoverable(string $url, array $contact = [])
|
public static function isDiscoverable(string $url, array $contact = []): bool
|
||||||
{
|
{
|
||||||
$contact_discovery = DI::config()->get('system', 'contact_discovery');
|
$contact_discovery = DI::config()->get('system', 'contact_discovery');
|
||||||
|
|
||||||
|
@ -254,12 +261,14 @@ class Relation
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $uid user
|
* Returns an array of sugguested contacts for given user id
|
||||||
|
*
|
||||||
|
* @param int $uid User id
|
||||||
* @param int $start optional, default 0
|
* @param int $start optional, default 0
|
||||||
* @param int $limit optional, default 80
|
* @param int $limit optional, default 80
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
static public function getSuggestions(int $uid, int $start = 0, int $limit = 80)
|
static public function getSuggestions(int $uid, int $start = 0, int $limit = 80): array
|
||||||
{
|
{
|
||||||
$cid = Contact::getPublicIdByUserId($uid);
|
$cid = Contact::getPublicIdByUserId($uid);
|
||||||
$totallimit = $start + $limit;
|
$totallimit = $start + $limit;
|
||||||
|
@ -272,20 +281,30 @@ class Relation
|
||||||
|
|
||||||
// The query returns contacts where contacts interacted with whom the given user follows.
|
// The query returns contacts where contacts interacted with whom the given user follows.
|
||||||
// Contacts who already are in the user's contact table are ignored.
|
// Contacts who already are in the user's contact table are ignored.
|
||||||
$results = DBA::select('contact', [],
|
$results = DBA::select('contact', [], ["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` IN
|
||||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` IN
|
|
||||||
(SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ?)
|
(SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ?)
|
||||||
AND NOT `cid` IN (SELECT `id` FROM `contact` WHERE `uid` = ? AND `nurl` IN
|
AND NOT `cid` IN (SELECT `id` FROM `contact` WHERE `uid` = ? AND `nurl` IN
|
||||||
(SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` IN (?, ?))))
|
(SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` IN (?, ?))))
|
||||||
AND NOT `hidden` AND `network` IN (?, ?, ?, ?)",
|
AND NOT `hidden` AND `network` IN (?, ?, ?, ?)",
|
||||||
$cid, 0, $uid, Contact::FRIEND, Contact::SHARING,
|
$cid,
|
||||||
Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $ostatus],
|
0,
|
||||||
['order' => ['last-item' => true], 'limit' => $totallimit]
|
$uid,
|
||||||
|
Contact::FRIEND,
|
||||||
|
Contact::SHARING,
|
||||||
|
Protocol::ACTIVITYPUB,
|
||||||
|
Protocol::DFRN,
|
||||||
|
$diaspora,
|
||||||
|
$ostatus,
|
||||||
|
], [
|
||||||
|
'order' => ['last-item' => true],
|
||||||
|
'limit' => $totallimit,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($contact = DBA::fetch($results)) {
|
while ($contact = DBA::fetch($results)) {
|
||||||
$contacts[$contact['id']] = $contact;
|
$contacts[$contact['id']] = $contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBA::close($results);
|
DBA::close($results);
|
||||||
|
|
||||||
Logger::info('Contacts of contacts who are followed by the given user', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
Logger::info('Contacts of contacts who are followed by the given user', ['uid' => $uid, 'cid' => $cid, 'count' => count($contacts)]);
|
||||||
|
@ -365,12 +384,12 @@ class Relation
|
||||||
* @return int
|
* @return int
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function countFollows(int $cid, array $condition = [])
|
public static function countFollows(int $cid, array $condition = []): int
|
||||||
{
|
{
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition, [
|
||||||
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
|
'`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
|
||||||
$cid]
|
$cid,
|
||||||
);
|
]);
|
||||||
|
|
||||||
return DI::dba()->count('contact', $condition);
|
return DI::dba()->count('contact', $condition);
|
||||||
}
|
}
|
||||||
|
@ -556,7 +575,7 @@ class Relation
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @param bool $shuffle
|
* @param bool $shuffle
|
||||||
* @return array
|
* @return array|bool Array on success, false on failure
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function listCommon(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
public static function listCommon(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||||
|
@ -581,7 +600,7 @@ class Relation
|
||||||
* @return int
|
* @return int
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function countCommonFollows(int $sourceId, int $targetId, array $condition = [])
|
public static function countCommonFollows(int $sourceId, int $targetId, array $condition = []): int
|
||||||
{
|
{
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||||
|
@ -601,7 +620,7 @@ class Relation
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @param bool $shuffle
|
* @param bool $shuffle
|
||||||
* @return array
|
* @return array|bool Array on success, false on failure
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function listCommonFollows(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
public static function listCommonFollows(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||||
|
@ -626,7 +645,7 @@ class Relation
|
||||||
* @return int
|
* @return int
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function countCommonFollowers(int $sourceId, int $targetId, array $condition = [])
|
public static function countCommonFollowers(int $sourceId, int $targetId, array $condition = []): int
|
||||||
{
|
{
|
||||||
$condition = DBA::mergeConditions($condition,
|
$condition = DBA::mergeConditions($condition,
|
||||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
|
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
|
||||||
|
@ -646,7 +665,7 @@ class Relation
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @param bool $shuffle
|
* @param bool $shuffle
|
||||||
* @return array
|
* @return array|bool Array on success, false on failure
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function listCommonFollowers(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
public static function listCommonFollowers(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||||
|
|
|
@ -82,8 +82,8 @@ class User
|
||||||
/**
|
/**
|
||||||
* Apply changes from contact update data to user-contact table
|
* Apply changes from contact update data to user-contact table
|
||||||
*
|
*
|
||||||
* @param array $fields
|
* @param array $fields Fields
|
||||||
* @param array $condition
|
* @param array $condition Conditions
|
||||||
* @return void
|
* @return void
|
||||||
* @throws PDOException
|
* @throws PDOException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -138,9 +138,10 @@ class User
|
||||||
* @param int $cid Either public contact id or user's contact id
|
* @param int $cid Either public contact id or user's contact id
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
* @param boolean $blocked Is the contact blocked or unblocked?
|
* @param boolean $blocked Is the contact blocked or unblocked?
|
||||||
|
* @return void
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function setBlocked($cid, $uid, $blocked)
|
public static function setBlocked(int $cid, int $uid, bool $blocked)
|
||||||
{
|
{
|
||||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||||
if (empty($cdata)) {
|
if (empty($cdata)) {
|
||||||
|
@ -170,7 +171,7 @@ class User
|
||||||
* @return boolean is the contact id blocked for the given user?
|
* @return boolean is the contact id blocked for the given user?
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function isBlocked($cid, $uid)
|
public static function isBlocked(int $cid, int $uid): bool
|
||||||
{
|
{
|
||||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||||
if (empty($cdata)) {
|
if (empty($cdata)) {
|
||||||
|
@ -208,9 +209,10 @@ class User
|
||||||
* @param int $cid Either public contact id or user's contact id
|
* @param int $cid Either public contact id or user's contact id
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
* @param boolean $ignored Is the contact ignored or unignored?
|
* @param boolean $ignored Is the contact ignored or unignored?
|
||||||
|
* @return void
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function setIgnored($cid, $uid, $ignored)
|
public static function setIgnored(int $cid, int $uid, bool $ignored)
|
||||||
{
|
{
|
||||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||||
if (empty($cdata)) {
|
if (empty($cdata)) {
|
||||||
|
@ -229,11 +231,10 @@ class User
|
||||||
*
|
*
|
||||||
* @param int $cid Either public contact id or user's contact id
|
* @param int $cid Either public contact id or user's contact id
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
*
|
|
||||||
* @return boolean is the contact id ignored for the given user?
|
* @return boolean is the contact id ignored for the given user?
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function isIgnored($cid, $uid)
|
public static function isIgnored(int $cid, int $uid): bool
|
||||||
{
|
{
|
||||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||||
if (empty($cdata)) {
|
if (empty($cdata)) {
|
||||||
|
@ -271,9 +272,10 @@ class User
|
||||||
* @param int $cid Either public contact id or user's contact id
|
* @param int $cid Either public contact id or user's contact id
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
* @param boolean $collapsed are the contact's posts collapsed or uncollapsed?
|
* @param boolean $collapsed are the contact's posts collapsed or uncollapsed?
|
||||||
|
* @return void
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function setCollapsed($cid, $uid, $collapsed)
|
public static function setCollapsed(int $cid, int $uid, bool $collapsed)
|
||||||
{
|
{
|
||||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||||
if (empty($cdata)) {
|
if (empty($cdata)) {
|
||||||
|
@ -288,16 +290,15 @@ class User
|
||||||
*
|
*
|
||||||
* @param int $cid Either public contact id or user's contact id
|
* @param int $cid Either public contact id or user's contact id
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
*
|
|
||||||
* @return boolean is the contact id blocked for the given user?
|
* @return boolean is the contact id blocked for the given user?
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
public static function isCollapsed($cid, $uid)
|
public static function isCollapsed(int $cid, int $uid): bool
|
||||||
{
|
{
|
||||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||||
if (empty($cdata)) {
|
if (empty($cdata)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$collapsed = false;
|
$collapsed = false;
|
||||||
|
@ -318,9 +319,10 @@ class User
|
||||||
* @param int $cid Either public contact id or user's contact id
|
* @param int $cid Either public contact id or user's contact id
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
* @param boolean $blocked Is the user blocked or unblocked by the contact?
|
* @param boolean $blocked Is the user blocked or unblocked by the contact?
|
||||||
|
* @return void
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function setIsBlocked($cid, $uid, $blocked)
|
public static function setIsBlocked(int $cid, int $uid, bool $blocked)
|
||||||
{
|
{
|
||||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||||
if (empty($cdata)) {
|
if (empty($cdata)) {
|
||||||
|
@ -335,11 +337,10 @@ class User
|
||||||
*
|
*
|
||||||
* @param int $cid Either public contact id or user's contact id
|
* @param int $cid Either public contact id or user's contact id
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
*
|
|
||||||
* @return boolean Is the user blocked or unblocked by the contact?
|
* @return boolean Is the user blocked or unblocked by the contact?
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function isIsBlocked($cid, $uid)
|
public static function isIsBlocked(int $cid, int $uid): bool
|
||||||
{
|
{
|
||||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||||
if (empty($cdata)) {
|
if (empty($cdata)) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ParsedLogIterator implements \Iterator
|
||||||
private $filters = [];
|
private $filters = [];
|
||||||
|
|
||||||
/** @var string search term */
|
/** @var string search term */
|
||||||
private $search = "";
|
private $search = '';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,10 +108,11 @@ class ParsedLogIterator implements \Iterator
|
||||||
$match = true;
|
$match = true;
|
||||||
foreach ($this->filters as $filter => $filtervalue) {
|
foreach ($this->filters as $filter => $filtervalue) {
|
||||||
switch ($filter) {
|
switch ($filter) {
|
||||||
case "level":
|
case 'level':
|
||||||
$match = $match && ($parsedlogline->level == strtoupper($filtervalue));
|
$match = $match && ($parsedlogline->level == strtoupper($filtervalue));
|
||||||
break;
|
break;
|
||||||
case "context":
|
|
||||||
|
case 'context':
|
||||||
$match = $match && ($parsedlogline->context == $filtervalue);
|
$match = $match && ($parsedlogline->context == $filtervalue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +129,7 @@ class ParsedLogIterator implements \Iterator
|
||||||
*/
|
*/
|
||||||
private function search(ParsedLogLine $parsedlogline): bool
|
private function search(ParsedLogLine $parsedlogline): bool
|
||||||
{
|
{
|
||||||
if ($this->search != "") {
|
if ($this->search != '') {
|
||||||
return strstr($parsedlogline->logline, $this->search) !== false;
|
return strstr($parsedlogline->logline, $this->search) !== false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -138,7 +139,6 @@ class ParsedLogIterator implements \Iterator
|
||||||
* Read a line from reader and parse.
|
* Read a line from reader and parse.
|
||||||
* Returns null if limit is reached or the reader is invalid.
|
* Returns null if limit is reached or the reader is invalid.
|
||||||
*
|
*
|
||||||
* @param ParsedLogLine $parsedlogline
|
|
||||||
* @return ?ParsedLogLine
|
* @return ?ParsedLogLine
|
||||||
*/
|
*/
|
||||||
private function read()
|
private function read()
|
||||||
|
@ -191,7 +191,7 @@ class ParsedLogIterator implements \Iterator
|
||||||
* @see ReversedFileReader::key()
|
* @see ReversedFileReader::key()
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function key()
|
public function key(): int
|
||||||
{
|
{
|
||||||
return $this->reader->key();
|
return $this->reader->key();
|
||||||
}
|
}
|
||||||
|
@ -213,8 +213,8 @@ class ParsedLogIterator implements \Iterator
|
||||||
* @see Iterator::valid()
|
* @see Iterator::valid()
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function valid()
|
public function valid(): bool
|
||||||
{
|
{
|
||||||
return ! is_null($this->value);
|
return !is_null($this->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,7 @@ class Install extends BaseModule
|
||||||
* @return string The text for the next steps
|
* @return string The text for the next steps
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
private function whatNext()
|
private function whatNext(): string
|
||||||
{
|
{
|
||||||
$baseurl = $this->baseUrl->get();
|
$baseurl = $this->baseUrl->get();
|
||||||
return
|
return
|
||||||
|
@ -383,6 +383,7 @@ class Install extends BaseModule
|
||||||
* @param string $cat The category of the setting
|
* @param string $cat The category of the setting
|
||||||
* @param string $key The key of the setting
|
* @param string $key The key of the setting
|
||||||
* @param null|string $default The default value
|
* @param null|string $default The default value
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function checkSetting(Cache $configCache, array $post, string $cat, string $key, ?string $default = null)
|
private function checkSetting(Cache $configCache, array $post, string $cat, string $key, ?string $default = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Maintenance extends BaseModule
|
||||||
|
|
||||||
$exception = new HTTPException\ServiceUnavailableException($reason);
|
$exception = new HTTPException\ServiceUnavailableException($reason);
|
||||||
|
|
||||||
header($_SERVER["SERVER_PROTOCOL"] . ' ' . $exception->getCode() . ' ' . DI::l10n()->t('System down for maintenance'));
|
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $exception->getCode() . ' ' . DI::l10n()->t('System down for maintenance'));
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('exception.tpl');
|
$tpl = Renderer::getMarkupTemplate('exception.tpl');
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ class NoScrape extends BaseModule
|
||||||
$profile_fields = ['about', 'locality', 'region', 'postal-code', 'country-name', 'xmpp', 'matrix'];
|
$profile_fields = ['about', 'locality', 'region', 'postal-code', 'country-name', 'xmpp', 'matrix'];
|
||||||
foreach ($profile_fields as $field) {
|
foreach ($profile_fields as $field) {
|
||||||
if (!empty($owner[$field])) {
|
if (!empty($owner[$field])) {
|
||||||
$json_info["$field"] = $owner[$field];
|
$json_info[$field] = $owner[$field];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ class PermissionTooltip extends \Friendica\BaseModule
|
||||||
* @param int $uriId
|
* @param int $uriId
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function fetchReceivers(int $uriId):string
|
private function fetchReceivers(int $uriId): string
|
||||||
{
|
{
|
||||||
$own_url = '';
|
$own_url = '';
|
||||||
$uid = local_user();
|
$uid = local_user();
|
||||||
|
|
|
@ -60,17 +60,17 @@ class Photo extends BaseModule
|
||||||
{
|
{
|
||||||
$totalstamp = microtime(true);
|
$totalstamp = microtime(true);
|
||||||
|
|
||||||
if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
|
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
|
||||||
if (!empty($_SERVER["HTTP_IF_NONE_MATCH"])) {
|
if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
||||||
header("Etag: " . $_SERVER["HTTP_IF_NONE_MATCH"]);
|
header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']);
|
||||||
}
|
}
|
||||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
|
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
|
||||||
header("Cache-Control: max-age=31536000");
|
header('Cache-Control: max-age=31536000');
|
||||||
if (function_exists("header_remove")) {
|
if (function_exists('header_remove')) {
|
||||||
header_remove("Last-Modified");
|
header_remove('Last-Modified');
|
||||||
header_remove("Expires");
|
header_remove('Expires');
|
||||||
header_remove("Cache-Control");
|
header_remove('Cache-Control');
|
||||||
}
|
}
|
||||||
throw new NotModifiedException();
|
throw new NotModifiedException();
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ class Photo extends BaseModule
|
||||||
} else {
|
} else {
|
||||||
$photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME);
|
$photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME);
|
||||||
$scale = 0;
|
$scale = 0;
|
||||||
if (substr($photoid, -2, 1) == "-") {
|
if (substr($photoid, -2, 1) == '-') {
|
||||||
$scale = intval(substr($photoid, -1, 1));
|
$scale = intval(substr($photoid, -1, 1));
|
||||||
$photoid = substr($photoid, 0, -2);
|
$photoid = substr($photoid, 0, -2);
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ class Photo extends BaseModule
|
||||||
throw new HTTPException\NotFoundException();
|
throw new HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$cacheable = ($photo["allow_cid"] . $photo["allow_gid"] . $photo["deny_cid"] . $photo["deny_gid"] === "") && (isset($photo["cacheable"]) ? $photo["cacheable"] : true);
|
$cacheable = ($photo['allow_cid'] . $photo['allow_gid'] . $photo['deny_cid'] . $photo['deny_gid'] === '') && (isset($photo['cacheable']) ? $photo['cacheable'] : true);
|
||||||
|
|
||||||
$stamp = microtime(true);
|
$stamp = microtime(true);
|
||||||
|
|
||||||
|
@ -179,35 +179,35 @@ class Photo extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
// if customsize is set and image is not a gif, resize it
|
// if customsize is set and image is not a gif, resize it
|
||||||
if ($photo['type'] !== "image/gif" && $customsize > 0 && $customsize <= Proxy::PIXEL_THUMB && $square_resize) {
|
if ($photo['type'] !== 'image/gif' && $customsize > 0 && $customsize <= Proxy::PIXEL_THUMB && $square_resize) {
|
||||||
$img = new Image($imgdata, $photo['type']);
|
$img = new Image($imgdata, $photo['type']);
|
||||||
$img->scaleToSquare($customsize);
|
$img->scaleToSquare($customsize);
|
||||||
$imgdata = $img->asString();
|
$imgdata = $img->asString();
|
||||||
} elseif ($photo['type'] !== "image/gif" && $customsize > 0) {
|
} elseif ($photo['type'] !== 'image/gif' && $customsize > 0) {
|
||||||
$img = new Image($imgdata, $photo['type']);
|
$img = new Image($imgdata, $photo['type']);
|
||||||
$img->scaleDown($customsize);
|
$img->scaleDown($customsize);
|
||||||
$imgdata = $img->asString();
|
$imgdata = $img->asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists("header_remove")) {
|
if (function_exists('header_remove')) {
|
||||||
header_remove("Pragma");
|
header_remove('Pragma');
|
||||||
header_remove("pragma");
|
header_remove('pragma');
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-type: " . $photo['type']);
|
header('Content-type: ' . $photo['type']);
|
||||||
|
|
||||||
$stamp = microtime(true);
|
$stamp = microtime(true);
|
||||||
if (!$cacheable) {
|
if (!$cacheable) {
|
||||||
// it is a private photo that they have no permission to view.
|
// it is a private photo that they have no permission to view.
|
||||||
// tell the browser not to cache it, in case they authenticate
|
// tell the browser not to cache it, in case they authenticate
|
||||||
// and subsequently have permission to see it
|
// and subsequently have permission to see it
|
||||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||||
} else {
|
} else {
|
||||||
$md5 = $photo['hash'] ?: md5($imgdata);
|
$md5 = $photo['hash'] ?: md5($imgdata);
|
||||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
|
||||||
header("Etag: \"{$md5}\"");
|
header("Etag: \"{$md5}\"");
|
||||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
|
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
|
||||||
header("Cache-Control: max-age=31536000");
|
header('Cache-Control: max-age=31536000');
|
||||||
}
|
}
|
||||||
$checksum = microtime(true) - $stamp;
|
$checksum = microtime(true) - $stamp;
|
||||||
|
|
||||||
|
|
|
@ -55,17 +55,17 @@ class Proxy extends BaseModule
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException();
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
|
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
|
||||||
if (!empty($_SERVER["HTTP_IF_NONE_MATCH"])) {
|
if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
||||||
header("Etag: " . $_SERVER["HTTP_IF_NONE_MATCH"]);
|
header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']);
|
||||||
}
|
}
|
||||||
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
|
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (31536000)) . ' GMT');
|
||||||
header("Cache-Control: max-age=31536000");
|
header('Cache-Control: max-age=31536000');
|
||||||
if (function_exists("header_remove")) {
|
if (function_exists('header_remove')) {
|
||||||
header_remove("Last-Modified");
|
header_remove('Last-Modified');
|
||||||
header_remove("Expires");
|
header_remove('Expires');
|
||||||
header_remove("Cache-Control");
|
header_remove('Cache-Control');
|
||||||
}
|
}
|
||||||
throw new NotModifiedException();
|
throw new NotModifiedException();
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ class Proxy extends BaseModule
|
||||||
* ]
|
* ]
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private function getRequestInfo()
|
private function getRequestInfo(): array
|
||||||
{
|
{
|
||||||
$size = ProxyUtils::PIXEL_LARGE;
|
$size = ProxyUtils::PIXEL_LARGE;
|
||||||
$sizetype = '';
|
$sizetype = '';
|
||||||
|
@ -187,6 +187,7 @@ class Proxy extends BaseModule
|
||||||
* Output the image with cache headers
|
* Output the image with cache headers
|
||||||
*
|
*
|
||||||
* @param Image $img
|
* @param Image $img
|
||||||
|
* @return void
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
private static function responseImageHttpCache(Image $img)
|
private static function responseImageHttpCache(Image $img)
|
||||||
|
|
Loading…
Reference in a new issue