don't send header() on CLI environment

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-02-25 15:16:59 +01:00
parent 1faa9f17ab
commit d933549646
3 changed files with 96 additions and 98 deletions

View File

@@ -19,13 +19,13 @@ if (! defined('AREA')) {
*
*/
use Froxlor\Api\Commands\DomainZones as DomainZones;
use Froxlor\Api\Commands\DomainZones;
use Froxlor\UI\Request;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php
$domain_id = (int) Request::get(['domain_id']);
$domain_id = (int) Request::get('domain_id');
$record = isset($_POST['record']['record']) ? trim($_POST['record']['record']) : null;
$type = isset($_POST['record']['type']) ? $_POST['record']['type'] : 'A';

View File

@@ -3,7 +3,6 @@
namespace Froxlor\Api;
use Exception;
use voku\helper\AntiXSS;
/**
* This file is part of the Froxlor project.
@@ -34,7 +33,9 @@ class FroxlorRPC
{
// make basic authentication
if (!isset($_SERVER['PHP_AUTH_USER']) || !self::validateAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
if (@php_sapi_name() !== 'cli') {
header('WWW-Authenticate: Basic realm="API"');
}
throw new Exception('Unauthenticated. Please provide api user credentials.', 401);
}
@@ -77,8 +78,7 @@ class FroxlorRPC
'as' => $secret
), true, true);
if ($result) {
if ($result['apikey'] == $key && $result['secret'] == $secret && ($result['valid_until'] == -1 || $result['valid_until'] >= time(
)) && (($result['customerid'] == 0 && $result['admin_api_allowed'] == 1) || ($result['customerid'] > 0 && $result['cust_api_allowed'] == 1 && $result['deactivated'] == 0))) {
if ($result['apikey'] == $key && $result['secret'] == $secret && ($result['valid_until'] == -1 || $result['valid_until'] >= time()) && (($result['customerid'] == 0 && $result['admin_api_allowed'] == 1) || ($result['customerid'] > 0 && $result['cust_api_allowed'] == 1 && $result['deactivated'] == 0))) {
// get user to check whether api call is allowed
if (!empty($result['allowed_from'])) {
// @todo allow specification and validating of whole subnets later

View File

@@ -19,15 +19,13 @@ if (! defined('AREA')) {
*
*/
use Froxlor\Api\Commands\SubDomains as SubDomains;
use Froxlor\Api\Commands\SubDomains;
use Froxlor\Settings;
use Froxlor\UI\Request;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php
// TODO get domain related settings for logfile (speciallogfile)
$domain_id = (int) Request::get('domain_id');
$last_n = (int) Request::get('number_of_lines', 100);