mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-10-05 18:34:20 +02:00
Merge branch 'master' of https://github.com/stevenandres/PrivateBin into stevenandres-master
This commit is contained in:
commit
d764c03759
3 changed files with 24 additions and 0 deletions
|
@ -195,6 +195,24 @@ class Controller
|
|||
*/
|
||||
private function _create()
|
||||
{
|
||||
// Check if whitelist feature is enabled
|
||||
if (($option = $this->_conf->getKey('whitelist_paste_creation', 'traffic')) !== null) {
|
||||
// Parse whitelist into array
|
||||
$whitelist = explode(',', $option);
|
||||
// Check for source IP in HTTP header
|
||||
if (($option = $this->_conf->getKey('header', 'traffic')) !== null) {
|
||||
$httpHeader = 'HTTP_' . $option;
|
||||
// Grab source IP from HTTP header (if it exists)
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure last paste from visitors IP address was more than configured amount of seconds ago.
|
||||
ServerSalt::setStore($this->_model->getStore());
|
||||
TrafficLimiter::setConfiguration($this->_conf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue