mirror of
https://github.com/friendica/friendica
synced 2025-04-25 22:30:10 +00:00
Add new purge contacts option to admin server blocklist
- Move adding a server domain pattern to the blocklist in a separate module to allow reviewing the list of known servers that would be affected
This commit is contained in:
parent
068c567b3d
commit
41062eb7e4
7 changed files with 311 additions and 131 deletions
|
@ -117,6 +117,33 @@ class GServer
|
|||
return self::getID($url, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all the servers which base domain are matching the provided domain pattern
|
||||
*
|
||||
* The pattern is a simple fnmatch() pattern with ? for single wildcard and * for multiple wildcard
|
||||
*
|
||||
* @param string $pattern
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function listByDomainPattern(string $pattern): array
|
||||
{
|
||||
$likePattern = 'http://' . strtr($pattern, ['_' => '\_', '%' => '\%', '?' => '_', '*' => '%']);
|
||||
|
||||
// The SUBSTRING_INDEX returns everything before the eventual third /, which effectively trims an
|
||||
// eventual server path and keep only the server domain which we're matching against the pattern.
|
||||
$sql = "SELECT `gserver`.*, COUNT(*) AS `contacts`
|
||||
FROM `gserver`
|
||||
LEFT JOIN `contact` ON `gserver`.`id` = `contact`.`gsid`
|
||||
WHERE SUBSTRING_INDEX(`gserver`.`nurl`, '/', 3) LIKE ?
|
||||
AND NOT `gserver`.`failed`
|
||||
GROUP BY `gserver`.`id`";
|
||||
|
||||
$stmt = DI::dba()->p($sql, $likePattern);
|
||||
|
||||
return DI::dba()->toArray($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given server is reachable
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue