added check for null whitelist
This commit is contained in:
parent
b8594c174a
commit
8fbdb69d8a
|
@ -196,15 +196,20 @@ class Controller
|
||||||
*/
|
*/
|
||||||
private function _create()
|
private function _create()
|
||||||
{
|
{
|
||||||
// Check whitelist if allowed to create
|
// Check if whitelist feature is enabled
|
||||||
$whitelist = explode(',', $this->_conf->getKey('whitelist_paste_creation', 'traffic'));
|
if (($option = $this->_conf->getKey('whitelist', 'traffic')) !== null) {
|
||||||
if (($option = $this->_conf->getKey('header', 'traffic')) !== null) {
|
// Parse whitelist into array
|
||||||
$httpHeader = 'HTTP_' . $option;
|
$whitelist = explode(',', $this->_conf->getKey('whitelist_paste_creation', 'traffic'));
|
||||||
if (array_key_exists($httpHeader, $_SERVER) && !empty($_SERVER[$httpHeader])) {
|
// Check for source IP in HTTP header
|
||||||
// compare source IP from web server with whitelist
|
if (($option = $this->_conf->getKey('header', 'traffic')) !== null) {
|
||||||
if(!in_array($_SERVER[$httpHeader], $whitelist)) {
|
$httpHeader = 'HTTP_' . $option;
|
||||||
$this->_return_message(1, I18n::_('Your IP is not authorized to create pastes.'));
|
// Grab source IP from HTTP header (if it exists)
|
||||||
return;
|
if (array_key_exists($httpHeader, $_SERVER) && !empty($_SERVER[$httpHeader])) {
|
||||||
|
// Check if source IP reported from HTTP header is in whitelist array
|
||||||
|
if (!in_array($_SERVER[$httpHeader], $whitelist)) {
|
||||||
|
$this->_return_message(1, I18n::_('Your IP is not authorized to create pastes.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue