Using the standard function to return http errors

This commit is contained in:
Michael 2018-12-02 19:33:01 +00:00
parent e88781164a
commit 83489b36c4
2 changed files with 5 additions and 7 deletions

View File

@ -18,8 +18,7 @@ function fetch_init(App $a)
{
if (($a->argc != 3) || (!in_array($a->argv[1], ["post", "status_message", "reshare"]))) {
header($_SERVER["SERVER_PROTOCOL"].' 404 '.L10n::t('Not Found'));
killme();
System::httpExit(404, ['title' => L10n::t('Not found.')]);
}
$guid = $a->argv[2];
@ -45,15 +44,13 @@ function fetch_init(App $a)
}
}
header($_SERVER["SERVER_PROTOCOL"].' 404 '.L10n::t('Not Found'));
killme();
System::httpExit(404, ['title' => L10n::t('Not found.')]);
}
// 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) {
header($_SERVER["SERVER_PROTOCOL"].' 404 '.L10n::t('Not Found'));
killme();
System::httpExit(404, ['title' => L10n::t('Not found.')]);
}
$status = Diaspora::buildStatus($item, $user);

View File

@ -7,6 +7,7 @@ use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Protocol\OStatus;
use Friendica\Util\Strings;
use Friendica\Core\System;
require_once 'include/items.php';
@ -16,7 +17,7 @@ function hub_return($valid, $body)
header($_SERVER["SERVER_PROTOCOL"] . ' 200 OK');
echo $body;
} else {
header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
System::httpExit(404, ['title' => L10n::t('Not found.')]);
}
killme();
}