don't send header() on CLI environment
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -19,13 +19,13 @@ if (! defined('AREA')) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Froxlor\Api\Commands\DomainZones as DomainZones;
|
use Froxlor\Api\Commands\DomainZones;
|
||||||
use Froxlor\UI\Request;
|
use Froxlor\UI\Request;
|
||||||
|
|
||||||
// This file is being included in admin_domains and customer_domains
|
// This file is being included in admin_domains and customer_domains
|
||||||
// and therefore does not need to require lib/init.php
|
// 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;
|
$record = isset($_POST['record']['record']) ? trim($_POST['record']['record']) : null;
|
||||||
$type = isset($_POST['record']['type']) ? $_POST['record']['type'] : 'A';
|
$type = isset($_POST['record']['type']) ? $_POST['record']['type'] : 'A';
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace Froxlor\Api;
|
namespace Froxlor\Api;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use voku\helper\AntiXSS;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of the Froxlor project.
|
* This file is part of the Froxlor project.
|
||||||
@@ -34,7 +33,9 @@ class FroxlorRPC
|
|||||||
{
|
{
|
||||||
// make basic authentication
|
// make basic authentication
|
||||||
if (!isset($_SERVER['PHP_AUTH_USER']) || !self::validateAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
|
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"');
|
header('WWW-Authenticate: Basic realm="API"');
|
||||||
|
}
|
||||||
throw new Exception('Unauthenticated. Please provide api user credentials.', 401);
|
throw new Exception('Unauthenticated. Please provide api user credentials.', 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +78,7 @@ class FroxlorRPC
|
|||||||
'as' => $secret
|
'as' => $secret
|
||||||
), true, true);
|
), true, true);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
if ($result['apikey'] == $key && $result['secret'] == $secret && ($result['valid_until'] == -1 || $result['valid_until'] >= time(
|
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))) {
|
||||||
)) && (($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
|
// get user to check whether api call is allowed
|
||||||
if (!empty($result['allowed_from'])) {
|
if (!empty($result['allowed_from'])) {
|
||||||
// @todo allow specification and validating of whole subnets later
|
// @todo allow specification and validating of whole subnets later
|
||||||
|
|||||||
@@ -19,15 +19,13 @@ if (! defined('AREA')) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Froxlor\Api\Commands\SubDomains as SubDomains;
|
use Froxlor\Api\Commands\SubDomains;
|
||||||
use Froxlor\Settings;
|
use Froxlor\Settings;
|
||||||
use Froxlor\UI\Request;
|
use Froxlor\UI\Request;
|
||||||
|
|
||||||
// This file is being included in admin_domains and customer_domains
|
// This file is being included in admin_domains and customer_domains
|
||||||
// and therefore does not need to require lib/init.php
|
// 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');
|
$domain_id = (int) Request::get('domain_id');
|
||||||
$last_n = (int) Request::get('number_of_lines', 100);
|
$last_n = (int) Request::get('number_of_lines', 100);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user