if (!strstr($referer, $page)) {
if (empty($_REQUEST["url"])) {
- System::httpExit(400, ["title" => L10n::t('Bad Request')]);
+ throw new \Friendica\Network\HTTPException\BadRequestException(L10n::t('This page is missing a url parameter.'));
}
$content = add_page_info($_REQUEST["url"]);
}
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
- System::httpExit(403, ['title' => L10n::t('Access denied.')]);
+ throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
}
if ($a->argc < 2) {
- System::httpExit(403, ['title' => L10n::t('Access denied.')]);
+ throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
}
Nav::setSelected('events');
$nick = $a->argv[1];
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) {
- System::httpExit(404, ['title' => L10n::t('Page not found.')]);
+ throw new \Slim\Exception\NotFoundException();
}
$a->data['user'] = $user;
$user = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBA::isResult($user)) {
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
dfrn_dispatch_private($user, $postdata);
} elseif (!dfrn_dispatch_public($postdata)) {
if (($dfrn_id === '') && empty($_POST['dfrn_id'])) {
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
- System::httpExit(403);
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
$user = '';
DBA::escape($a->argv[1])
);
if (!$r) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$hidewall = ($r[0]['hidewall'] && !local_user());
// heluecht: I don't know why we don't fail immediately when the user or contact hadn't been found.
// Since it doesn't make sense to continue from this point on, we now fail here. This should be safe.
if (!DBA::isResult($r)) {
- System::httpExit(404, ["title" => L10n::t('Page not found.')]);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
// URL reply
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Module\Objects;
+use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\DFRN;
use Friendica\Util\Strings;
}
if (!DBA::isResult($item)) {
- System::httpExit(404);
+ return;
}
if ($a->argc >= 3 && $nick == 'feed-item') {
function display_content(App $a, $update = false, $update_uid = 0)
{
if (Config::get('system','block_public') && !local_user() && !remote_user()) {
- notice(L10n::t('Public access denied.') . EOL);
- return;
+ throw new HTTPException\ForbiddenException(L10n::t('Public access denied.'));
}
$o = '';
}
if (!$item_id) {
- System::httpExit(404);
+ throw new HTTPException\NotFoundException(L10n::t('The requested item doesn\'t exist or has been deleted.'));
}
// We are displaying an "alternate" link if that post was public. See issue 2864
$is_owner = (local_user() && (in_array($a->profile['profile_uid'], [local_user(), 0])) ? true : false);
if (!empty($a->profile['hidewall']) && !$is_owner && !$is_remote_contact) {
- notice(L10n::t('Access to this profile has been restricted.') . EOL);
- return;
+ throw new HTTPException\ForbiddenException(L10n::t('Access to this profile has been restricted.'));
}
// We need the editor here to be able to reshare an item.
$item = Item::selectFirstForUser(local_user(), $fields, $condition);
if (!DBA::isResult($item)) {
- System::httpExit(404);
+ throw new HTTPException\NotFoundException(L10n::t('The requested item doesn\'t exist or has been deleted.'));
}
$item['uri'] = $item['parent-uri'];
{
$xml = DFRN::itemFeed($item_id, $conversation);
if ($xml == '') {
- System::httpExit(500);
+ throw new HTTPException\InternalServerErrorException(L10n::t('The feed for this item is unavailable.'));
}
header("Content-type: application/atom+xml");
echo $xml;
function fetch_init(App $a)
{
-
if (($a->argc != 3) || (!in_array($a->argv[1], ["post", "status_message", "reshare"]))) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$guid = $a->argv[2];
}
}
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
// Fetch some data from the author (We could combine both queries - but I think this is more readable)
$user = User::getOwnerDataById($item["uid"]);
if (!$user) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$status = Diaspora::buildStatus($item, $user);
function follow_post(App $a)
{
if (!local_user()) {
- System::httpExit(403, ['title' => L10n::t('Access denied.')]);
+ throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
}
if (isset($_REQUEST['cancel'])) {
if ($a->argc > 1) {
$which = $a->argv[1];
} else {
- notice(L10n::t('No profile') . EOL);
- return;
+ throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('No profile'));
}
$profile = 0;
}
if (!strlen($text)) {
- header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . L10n::t('Not Found'));
- $tpl = Renderer::getMarkupTemplate("404.tpl");
- return Renderer::replaceMacros($tpl, [
- '$message' => L10n::t('Page not found.')
- ]);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$html = Markdown::convert($text, false);
// Get out if the system doesn't have public access allowed
if (intval(Config::get('system', 'block_public'))) {
- System::httpExit(401);
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
// Return the raw content of the template. We use this to make templates usable for js functions.
$nick = $r[0]['nickname'];
$a->internalRedirect('display/' . $nick . '/' . $id);
} else {
- notice(L10n::t('Item not found.') . EOL);
+ throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('Item not found.'));
}
return;
$system_mode = false;
if (intval(Config::get('system', 'block_public')) || (Config::get('system', 'block_local_dir'))) {
- System::httpExit(401);
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
if ($a->argc > 1) {
if (empty($nickname)) {
$c = q("SELECT * FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1");
if (!DBA::isResult($c)) {
- System::httpExit(401);
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
$system_mode = true;
}
DBA::escape($nickname)
);
if (! DBA::isResult($users) || $users[0]['hidewall'] || $users[0]['hide-friends']) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$user = $users[0];
$ret['entry'][] = [];
}
} else {
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
+
Logger::log("End of poco", Logger::DEBUG);
if ($format === 'xml') {
echo json_encode($ret);
exit();
} else {
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
}
function probe_content(App $a)
{
if (!local_user()) {
- System::httpExit(403, ["title" => L10n::t("Public access denied."),
- "description" => L10n::t("Only logged in users are permitted to perform a probing.")]);
- exit();
+ $e = new \Friendica\Network\HTTPException\ForbiddenException(L10n::t("Only logged in users are permitted to perform a probing."));
+ $e->httpdesc = L10n::t("Public access denied.");
+ throw $e;
}
$o = '<div class="generic-page-wrapper">';
function hub_return($valid, $body)
{
if ($valid) {
- header($_SERVER["SERVER_PROTOCOL"] . ' 200 OK');
echo $body;
} else {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
exit();
}
function hub_post_return()
{
- System::httpExit(200);
+ throw new \Friendica\Network\HTTPException\OKException();
}
function pubsub_init(App $a)
// PuSH subscription must be considered "public" so just block it
// if public access isn't enabled.
if (Config::get('system', 'block_public')) {
- System::httpExit(403);
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
// Subscription request from subscriber
$subscribe = 0;
} else {
Logger::log("Invalid hub_mode=$hub_mode, ignoring.");
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
Logger::log("$hub_mode request from " . $_SERVER['REMOTE_ADDR']);
if (!$nick) {
Logger::log('Bad hub_topic=$hub_topic, ignoring.');
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
// fetch user from database given the nickname
$owner = DBA::selectFirst('user', ['uid', 'hidewall', 'nickname'], $condition);
if (!DBA::isResult($owner)) {
Logger::log('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback);
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
// abort if user's wall is supposed to be private
if ($owner['hidewall']) {
Logger::log('Local user ' . $nick . 'has chosen to hide wall, ignoring.');
- System::httpExit(403);
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
// get corresponding row from contact table
$contact = DBA::selectFirst('contact', ['poll'], $condition);
if (!DBA::isResult($contact)) {
Logger::log('Self contact for user ' . $owner['uid'] . ' not found.');
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
// sanity check that topic URLs are the same
if (!Strings::compareLink($hub_topic, $contact['poll']) && !Strings::compareLink($hub_topic2, $contact['poll']) && !Strings::compareLink($hub_topic, $self)) {
Logger::log('Hub topic ' . $hub_topic . ' != ' . $contact['poll']);
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
// do subscriber verification according to the PuSH protocol
// give up if the HTTP return code wasn't a success (2xx)
if ($ret < 200 || $ret > 299) {
Logger::log("Subscriber verification for $hub_topic at $hub_callback returned $ret, ignoring.");
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
// check that the correct hub_challenge code was echoed back
if (trim($body) !== $hub_challenge) {
Logger::log("Subscriber did not echo back hub.challenge, ignoring.");
Logger::log("\"$hub_challenge\" != \"".trim($body)."\"");
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
PushSubscriber::renew($owner['uid'], $nick, $subscribe, $hub_callback, $hub_topic, $hub_secret);
- System::httpExit(202);
+ throw new \Friendica\Network\HTTPException\AcceptedException();
}
exit();
}
$enabled = intval(Config::get('system', 'diaspora_enabled'));
if (!$enabled) {
Logger::log('mod-diaspora: disabled');
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
if (($a->argc == 2) && ($a->argv[1] === 'public')) {
$public = false;
if ($a->argc != 3 || $a->argv[1] !== 'users') {
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
$guid = $a->argv[2];
$importer = DBA::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
if (!DBA::isResult($importer)) {
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
}
if (empty($_POST['xml'])) {
$postdata = file_get_contents("php://input");
if ($postdata == '') {
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
Logger::log('mod-diaspora: message is in the new format', Logger::DEBUG);
Logger::log('mod-diaspora: decoded msg: ' . print_r($msg, true), Logger::DATA);
if (!is_array($msg)) {
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
Logger::log('mod-diaspora: dispatching', Logger::DEBUG);
$ret = Diaspora::dispatch($importer, $msg);
}
- System::httpExit(($ret) ? 200 : 500);
- // NOTREACHED
+ if ($ret) {
+ throw new \Friendica\Network\HTTPException\OKException();
+ } else {
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
+ }
}
DBA::escape($nick)
);
if (! DBA::isResult($r)) {
- System::httpExit(500);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
$importer = $r[0];
if (empty($base)) {
Logger::log('unable to locate salmon data in xml ');
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
// Stash the signature away for now. We have to find their key or it won't be good for anything.
if(! $author_link) {
Logger::log('Could not retrieve author URI.');
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
// Once we have the author URI, go to the web and try to find their public key
if(! $key) {
Logger::log('Could not retrieve author key.');
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
$key_info = explode('.',$key);
if (! $verify) {
Logger::log('Message did not verify. Discarding.');
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
Logger::log('Message verified with mode '.$mode);
//if((DBA::isResult($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == Contact::FOLLOWER) || ($r[0]['blocked']))) {
if (DBA::isResult($r) && $r[0]['blocked']) {
Logger::log('Ignoring this author.');
- System::httpExit(202);
- // NOTREACHED
+ throw new \Friendica\Network\HTTPException\AcceptedException();
}
// Placeholder for hub discovery.
OStatus::import($data, $importer, $contact_rec, $hub);
- System::httpExit(200);
+ throw new \Friendica\Network\HTTPException\OKException();
}
}
if (Config::get('system','local_search') && !local_user() && !remote_user()) {
- System::httpExit(403,
- ["title" => L10n::t("Public access denied."),
- "description" => L10n::t("Only logged in users are permitted to perform a search.")]);
- exit();
- //notice(L10n::t('Public access denied.').EOL);
- //return;
+ $e = new \Friendica\Network\HTTPException\ForbiddenException(L10n::t("Only logged in users are permitted to perform a search."));
+ $e->httpdesc = L10n::t("Public access denied.");
+ throw $e;
}
if (Config::get('system','permit_crawling') && !local_user() && !remote_user()) {
if (!is_null($result)) {
$resultdata = json_decode($result);
if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
- System::httpExit(429,
- ["title" => L10n::t("Too Many Requests"),
- "description" => L10n::t("Only one search per minute is permitted for not logged in users.")]);
- exit();
+ throw new \Friendica\Network\HTTPException\TooManyRequestsException(L10n::t("Only one search per minute is permitted for not logged in users."));
}
Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => $resultdata->accesses + 1]), Cache::HOUR);
} else
function viewcontacts_init(App $a)
{
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
- System::httpExit(403, ["title" => L10n::t('Access denied.')]);
+ throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
}
if ($a->argc < 2) {
- System::httpExit(403, ["title" => L10n::t('Access denied.')]);
+ throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
}
Nav::setSelected('home');
$user = DBA::selectFirst('user', [], ['nickname' => $a->argv[1], 'blocked' => false]);
if (!DBA::isResult($user)) {
- System::httpExit(404, ["title" => L10n::t('Page not found.')]);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$a->data['user'] = $user;
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if (!$item_id) {
- notice(L10n::t('Item not found.') . EOL);
- return;
+ throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('Item not found.'));
}
$item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $item_id]);
Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA);
- System::httpExit(403);
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
}
}
if (!DBA::isResult($user) && empty($profiledata)) {
Logger::log('profile error: ' . $a->query_string, Logger::DEBUG);
- notice(L10n::t('Requested account is not available.') . EOL);
return;
}
if (empty($pdata) && empty($profiledata)) {
Logger::log('profile error: ' . $a->query_string, Logger::DEBUG);
- notice(L10n::t('Requested profile is not available.') . EOL);
return;
}
{
$a = self::getApp();
if ($a->argc != 2) {
- System::httpExit(400); // Bad Request.
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
// @TODO: Replace with parameter from router
// Check for existence
$item = MAttach::exists(['id' => $item_id]);
if ($item === false) {
- System::httpExit(404, ['description' => L10n::t('Item was not found.')]);
+ throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('Item was not found.'));
}
// Now we'll fetch the item, if we have enough permisson
$item = MAttach::getByIdWithPermission($item_id);
if ($item === false) {
- System::httpExit(403, ['description' => L10n::t('Permission denied.')]);
+ throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Permission denied.'));
}
$data = MAttach::getData($item);
if (is_null($data)) {
Logger::log('NULL data for attachment with id ' . $item['id']);
- System::httpExit(404, ['description' => L10n::t('Item was not found.')]);
+ throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('Item was not found.'));
}
// Use quotes around the filename to prevent a "multiple Content-Disposition"
// @TODO: Replace with parameter from router
if ($a->argc < 2) {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
$type = null;
// @TODO: Replace with parameter from router
if (empty($a->argv[1])) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
// @TODO: Replace with parameter from router
$owner = User::getOwnerDataByNick($a->argv[1]);
if (empty($owner)) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$page = defaults($_REQUEST, 'page', null);
// @TODO: Replace with parameter from router
if (empty($a->argv[1])) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
// @TODO: Replace with parameter from router
$owner = User::getOwnerDataByNick($a->argv[1]);
if (empty($owner)) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$page = defaults($_REQUEST, 'page', null);
$change = false;
if (!local_user()) {
- System::httpExit(403);
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
$a = self::getApp();
}
if (!isset($group)) {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
$groupeditor = [
$postdata = file_get_contents('php://input');
if (empty($postdata)) {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
if (Config::get('debug', 'ap_inbox_log')) {
if (!empty($a->argv[1])) {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
if (!DBA::isResult($user)) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$uid = $user['uid'];
} else {
ActivityPub\Receiver::processInbox($postdata, $_SERVER, $uid);
- System::httpExit(202);
+ throw new \Friendica\Network\HTTPException\AcceptedException();
}
}
$a = self::getApp();
if (!$a->getMode()->isInstall()) {
- Core\System::httpExit(403);
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
// route: install/testrwrite
// @TODO: Replace with parameter from router
if ($a->getArgumentValue(1, '') == 'testrewrite') {
// Status Code 204 means that it worked without content
- Core\System::httpExit(204);
+ throw new \Friendica\Network\HTTPException\NoContentException();
}
self::$installer = new Core\Installer();
$config = self::getApp()->getConfig();
if (!$config->get('system', 'nodeinfo')) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
}
*
* @param App $app
*
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \Friendica\Network\HTTPException\NotFoundException
*/
private static function printWellKnown(App $app)
{
$config = $app->getConfig();
if (!$config->get('system', 'nodeinfo')) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$nodeinfo = [
$a = self::getApp();
if (empty($a->argv[1])) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
if (!ActivityPub::isRequest()) {
// @TODO: Replace with parameter from router
$item = Item::selectFirst(['id', 'author-link'], ['guid' => $a->argv[1], 'private' => false]);
if (!DBA::isResult($item) || !strstr($item['author-link'], System::baseUrl())) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
}
// @TODO: Replace with parameter from router
if (empty($a->argv[1])) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$owner = User::getOwnerDataByNick($a->argv[1]);
if (empty($owner)) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$page = defaults($_REQUEST, 'page', null);
namespace Friendica\Module;
use Friendica\BaseModule;
+use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Model\Photo as MPhoto;
$a = self::getApp();
// @TODO: Replace with parameter from router
if ($a->argc <= 1 || $a->argc > 4) {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
}
if ($photo === false) {
- // not using System::httpExit() because we don't want html here.
- header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found" , true, 404);
- exit();
+ System::httpExit('404', 'Not Found');
}
$cacheable = ($photo["allow_cid"] . $photo["allow_gid"] . $photo["deny_cid"] . $photo["deny_gid"] === "") && (isset($photo["cacheable"]) ? $photo["cacheable"] : true);
if (is_null($img) || !$img->isValid()) {
Logger::log("Invalid photo with id {$photo["id"]}.");
- System::httpExit(500, ["description" => "Invalid photo with id {$photo["id"]}."]);
+ throw new \Friendica\Network\HTTPException\InternalServerErrorException(L10n::t('Invalid photo with id %s.', $photo["id"]));
}
// if customsize is set and image is not a gif, resize it
// @TODO: Replace with parameter from router
if ($a->argc < 2) {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
self::$which = filter_var($a->argv[1], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK);
$request = self::getRequestInfo();
if (empty($request['url'])) {
- System::httpExit(400, ['title' => L10n::t('Bad Request.')]);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
// Webserver already tried direct cache...
$config = self::getApp()->getConfig();
if (!$config->get("system", "nodeinfo")) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
}
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\System;
use Friendica\Network\Probe;
/**
*/
class WebFinger extends BaseModule
{
- public static function init()
+ public static function content()
{
if (!local_user()) {
- System::httpExit(
- 403,
- [
- 'title' => L10n::t('Public access denied.'),
- 'description' => L10n::t('Only logged in users are permitted to perform a probing.'),
- ],
- );
- exit();
+ $e = new \Friendica\Network\HTTPException\ForbiddenException(L10n::t("Only logged in users are permitted to perform a probing."));
+ $e->httpdesc = L10n::t("Public access denied.");
+ throw $e;
}
- }
- public static function content()
- {
$app = self::getApp();
$addr = defaults($_GET, 'addr', '');
$user = User::getByNickname($name);
if (empty($user)) {
- System::httpExit(404);
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$profileURL = $app->getBaseURL() . '/profile/' . $user['nickname'];
if ($no_exit) {
return false;
} else {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
}
if ($no_exit) {
return false;
} else {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
}
if ($no_exit) {
return false;
} else {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
}
if ($no_exit) {
return false;
} else {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
}
if ($no_exit) {
return false;
} else {
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
}
if (!$base) {
Logger::log('unable to locate salmon data in xml');
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
if (!$author_link) {
Logger::log('Could not retrieve author URI.');
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
// Once we have the author URI, go to the web and try to find their public key
// (first this will look it up locally if it is in the fcontact cache)
if (!$key) {
Logger::log('Could not retrieve author key.');
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
$verify = Crypto::rsaVerify($signed_data, $signature, $key);
if (!$verify) {
Logger::log('Message did not verify. Discarding.');
- System::httpExit(400);
+ throw new \Friendica\Network\HTTPException\BadRequestException();
}
Logger::log('Message verified.');