Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring deleted fixes #1083

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/RestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ public function __construct($config = 'rest')
// when output is displayed for not damaging data accidentally
$this->output->parse_exec_vars = false;

// Load the rest.php configuration file
$this->get_local_config($config);

// Log the loading time to the log table
if ($this->config->item('rest_enable_logging') === true) {
// Start the timer for how long the request takes
$this->_start_rtime = microtime(true);
}

// Load the rest.php configuration file
$this->get_local_config($config);

// Determine supported output formats from configuration
$supported_formats = $this->config->item('rest_supported_formats');

Expand Down Expand Up @@ -544,7 +544,7 @@ public function _remap($object_called, $arguments = [])
$this->response([
$this->config->item('rest_status_field_name') => false,
$this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unknown_method'),
], $this->http_status['METHOD_NOT_ALLOWED']);
], self::HTTP_METHOD_NOT_ALLOWED);
}

// Doing key related stuff? Can only do it if they have a key right?
Expand Down Expand Up @@ -623,7 +623,7 @@ public function response($data = null, $http_code = null, $continue = false)

// If data is NULL and no HTTP status code provided, then display, error and exit
if ($data === null && $http_code === null) {
$http_code = HTTP_NOT_FOUND;
$http_code = self::HTTP_NOT_FOUND;
}

// If data is not NULL and a HTTP status code provided, then continue
Expand Down Expand Up @@ -661,7 +661,7 @@ public function response($data = null, $http_code = null, $continue = false)
// If not greater than zero, then set the HTTP status code as 200 by default
// Though perhaps 500 should be set instead, for the developer not passing a
// correct HTTP status code
$http_code > 0 || $http_code = HTTP_OK;
$http_code > 0 || $http_code = self::HTTP_OK;

$this->output->set_status_header($http_code);

Expand Down Expand Up @@ -1541,7 +1541,7 @@ protected function _perform_ldap_auth($username = '', $password = null)
'basedn' => $this->config->item('basedn', 'ldap'),
];

log_message('debug', 'LDAP Auth: Connect to '.(isset($ldaphost) ? $ldaphost : '[ldap not configured]'));
log_message('debug', 'LDAP Auth: Connect to '.(isset($ldap['host']) ? $ldap['host'] : '[ldap not configured]'));

// Connect to the ldap server
$ldapconn = ldap_connect($ldap['host'], $ldap['port']);
Expand Down Expand Up @@ -1715,7 +1715,7 @@ protected function _check_php_session()
$this->response([
$this->config->item('rest_status_field_name') => false,
$this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unauthorized'),
], $this->http_status['UNAUTHORIZED']);
], self::HTTP_UNAUTHORIZED);
}
}

Expand Down Expand Up @@ -1800,7 +1800,7 @@ protected function _prepare_digest_auth()
$this->response([
$this->config->item('rest_status_field_name') => false,
$this->config->item('rest_message_field_name') => $this->lang->line('text_rest_invalid_credentials'),
], $this->http_status['UNAUTHORIZED']);
], self::HTTP_UNAUTHORIZED);
}
}

Expand All @@ -1820,7 +1820,7 @@ protected function _check_blacklist_auth()
$this->response([
$this->config->item('rest_status_field_name') => false,
$this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ip_denied'),
], $this->http_status['UNAUTHORIZED']);
], self::HTTP_UNAUTHORIZED);
}
}

Expand All @@ -1845,7 +1845,7 @@ protected function _check_whitelist_auth()
$this->response([
$this->config->item('rest_status_field_name') => false,
$this->config->item('rest_message_field_name') => $this->lang->line('text_rest_ip_unauthorized'),
], $this->http_status['UNAUTHORIZED']);
], self::HTTP_UNAUTHORIZED);
}
}

Expand Down Expand Up @@ -1880,7 +1880,7 @@ protected function _force_login($nonce = '')
$this->response([
$this->config->item('rest_status_field_name') => false,
$this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unauthorized'),
], $this->http_status['UNAUTHORIZED']);
], self::HTTP_UNAUTHORIZED);
}

/**
Expand Down