This commit is contained in:
Shish 2022-07-09 23:37:43 +01:00
parent 476808db4b
commit e97198aa10
3 changed files with 21 additions and 20 deletions

View file

@ -89,7 +89,7 @@ new UserClass("user", "base", [
Permissions::SEND_PM => true,
Permissions::READ_PM => true,
Permissions::SET_PRIVATE_IMAGE => true,
Permissions::PERFORM_BULK_ACTIONS => true,
Permissions::PERFORM_BULK_ACTIONS => true,
Permissions::BULK_DOWNLOAD => true,
Permissions::CHANGE_USER_SETTING => true
]);

View file

@ -164,23 +164,25 @@ function check_im_version(): int
* Get request IP
*/
function get_remote_addr() {
return $_SERVER['REMOTE_ADDR'];
function get_remote_addr()
{
return $_SERVER['REMOTE_ADDR'];
}
/**
* Get real IP if behind a reverse proxy
*/
function get_real_ip() {
$ip = get_remote_addr();
if (REVERSE_PROXY_X_HEADERS && isset($_SERVER['HTTP_X_REAL_IP'])) {
$ip = $_SERVER['HTTP_X_REAL_IP'];
if(!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
$ip = "0.0.0.0";
function get_real_ip()
{
$ip = get_remote_addr();
if (REVERSE_PROXY_X_HEADERS && isset($_SERVER['HTTP_X_REAL_IP'])) {
$ip = $_SERVER['HTTP_X_REAL_IP'];
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
$ip = "0.0.0.0";
}
}
}
return $ip;
return $ip;
}
/**
@ -822,4 +824,3 @@ function generate_key(int $length = 20): string
return $randomString;
}

View file

@ -6,10 +6,10 @@ class VarnishPurger extends Extension
{
public function onInitExt(InitExtEvent $event)
{
global $config;
$config->set_default_string('varnish_host', '127.0.0.1');
$config->set_default_int('varnish_port', 80);
$config->set_default_string('varnish_protocol', 'http');
global $config;
$config->set_default_string('varnish_host', '127.0.0.1');
$config->set_default_int('varnish_port', 80);
$config->set_default_string('varnish_protocol', 'http');
}
private function curl_purge($path)
@ -32,7 +32,7 @@ class VarnishPurger extends Extension
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode != 200) {
throw new SCoreException('PURGE ' . $url . ' unsuccessful (HTTP '. $httpCode . ')');
throw new SCoreException('PURGE ' . $url . ' unsuccessful (HTTP '. $httpCode . ')');
}
curl_close($ch);
assert(!is_null($result) && !is_null($httpCode));