friendica-github/src/Module/Acctlink.php

35 lines
807 B
PHP
Raw Normal View History

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;
use Friendica\Core\System;
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
{
protected function rawContent(array $request = [])
2018-10-13 18:32:14 +02: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
}
}