2018-10-13 18:32:14 +02:00
|
|
|
<?php
|
2024-08-24 15:27:00 +02:00
|
|
|
|
|
|
|
// Copyright (C) 2010-2024, the Friendica project
|
|
|
|
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-10-13 18:32:14 +02:00
|
|
|
|
|
|
|
namespace Friendica\Module;
|
|
|
|
|
|
|
|
use Friendica\BaseModule;
|
2018-10-19 20:11:27 +02:00
|
|
|
use Friendica\Core\System;
|
2020-07-16 10:22:14 +00:00
|
|
|
use Friendica\Model\Contact;
|
2021-11-16 22:39:23 +01:00
|
|
|
use Friendica\Network\HTTPException\NotFoundException;
|
2018-10-13 18:32:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Redirects to another URL based on the parameter 'addr'
|
|
|
|
*/
|
2018-10-13 19:00:44 +02:00
|
|
|
class Acctlink extends BaseModule
|
2018-10-13 18:32:14 +02:00
|
|
|
{
|
2021-11-20 15:38:03 +01:00
|
|
|
protected function rawContent(array $request = [])
|
2018-10-13 18:32:14 +02:00
|
|
|
{
|
2019-10-15 09:20:32 -04:00
|
|
|
$addr = trim($_GET['addr'] ?? '');
|
2021-11-17 08:16:33 +01:00
|
|
|
if (!$addr) {
|
|
|
|
throw new NotFoundException('Parameter "addr" is missing or empty');
|
|
|
|
}
|
2018-10-13 18:32:14 +02:00
|
|
|
|
2021-11-17 08:16:33 +01:00
|
|
|
$contact = Contact::getByURL($addr, null, ['url']) ?? '';
|
|
|
|
if (!$contact) {
|
|
|
|
throw new NotFoundException('Contact not found');
|
2018-10-13 18:32:14 +02:00
|
|
|
}
|
2021-11-14 23:13:47 +01:00
|
|
|
|
2021-11-17 08:16:33 +01:00
|
|
|
System::externalRedirect($contact['url']);
|
2018-10-13 18:32:14 +02:00
|
|
|
}
|
|
|
|
}
|