forked from Cavemanon/cavepaintings
format
This commit is contained in:
parent
476808db4b
commit
e97198aa10
|
@ -89,7 +89,7 @@ new UserClass("user", "base", [
|
||||||
Permissions::SEND_PM => true,
|
Permissions::SEND_PM => true,
|
||||||
Permissions::READ_PM => true,
|
Permissions::READ_PM => true,
|
||||||
Permissions::SET_PRIVATE_IMAGE => true,
|
Permissions::SET_PRIVATE_IMAGE => true,
|
||||||
Permissions::PERFORM_BULK_ACTIONS => true,
|
Permissions::PERFORM_BULK_ACTIONS => true,
|
||||||
Permissions::BULK_DOWNLOAD => true,
|
Permissions::BULK_DOWNLOAD => true,
|
||||||
Permissions::CHANGE_USER_SETTING => true
|
Permissions::CHANGE_USER_SETTING => true
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -164,23 +164,25 @@ function check_im_version(): int
|
||||||
* Get request IP
|
* Get request IP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function get_remote_addr() {
|
function get_remote_addr()
|
||||||
return $_SERVER['REMOTE_ADDR'];
|
{
|
||||||
|
return $_SERVER['REMOTE_ADDR'];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get real IP if behind a reverse proxy
|
* Get real IP if behind a reverse proxy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function get_real_ip() {
|
function get_real_ip()
|
||||||
$ip = get_remote_addr();
|
{
|
||||||
if (REVERSE_PROXY_X_HEADERS && isset($_SERVER['HTTP_X_REAL_IP'])) {
|
$ip = get_remote_addr();
|
||||||
$ip = $_SERVER['HTTP_X_REAL_IP'];
|
if (REVERSE_PROXY_X_HEADERS && isset($_SERVER['HTTP_X_REAL_IP'])) {
|
||||||
if(!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
|
$ip = $_SERVER['HTTP_X_REAL_IP'];
|
||||||
$ip = "0.0.0.0";
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,7 +192,7 @@ function get_real_ip() {
|
||||||
function get_session_ip(Config $config): string
|
function get_session_ip(Config $config): string
|
||||||
{
|
{
|
||||||
$mask = $config->get_string("session_hash_mask", "255.255.0.0");
|
$mask = $config->get_string("session_hash_mask", "255.255.0.0");
|
||||||
$addr = get_real_ip();
|
$addr = get_real_ip();
|
||||||
$addr = inet_ntop(inet_pton($addr) & inet_pton($mask));
|
$addr = inet_ntop(inet_pton($addr) & inet_pton($mask));
|
||||||
return $addr;
|
return $addr;
|
||||||
}
|
}
|
||||||
|
@ -822,4 +824,3 @@ function generate_key(int $length = 20): string
|
||||||
|
|
||||||
return $randomString;
|
return $randomString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ class VarnishPurger extends Extension
|
||||||
{
|
{
|
||||||
public function onInitExt(InitExtEvent $event)
|
public function onInitExt(InitExtEvent $event)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_string('varnish_host', '127.0.0.1');
|
$config->set_default_string('varnish_host', '127.0.0.1');
|
||||||
$config->set_default_int('varnish_port', 80);
|
$config->set_default_int('varnish_port', 80);
|
||||||
$config->set_default_string('varnish_protocol', 'http');
|
$config->set_default_string('varnish_protocol', 'http');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function curl_purge($path)
|
private function curl_purge($path)
|
||||||
|
@ -20,7 +20,7 @@ class VarnishPurger extends Extension
|
||||||
}
|
}
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
$host = $config->get_string('varnish_host');
|
$host = $config->get_string('varnish_host');
|
||||||
$port = $config->get_int('varnish_port');
|
$port = $config->get_int('varnish_port');
|
||||||
$protocol = $config->get_string('varnish_protocol');
|
$protocol = $config->get_string('varnish_protocol');
|
||||||
$url = $protocol . '://'. $host . '/' . $path;
|
$url = $protocol . '://'. $host . '/' . $path;
|
||||||
|
@ -32,7 +32,7 @@ class VarnishPurger extends Extension
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
if ($httpCode != 200) {
|
if ($httpCode != 200) {
|
||||||
throw new SCoreException('PURGE ' . $url . ' unsuccessful (HTTP '. $httpCode . ')');
|
throw new SCoreException('PURGE ' . $url . ' unsuccessful (HTTP '. $httpCode . ')');
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
assert(!is_null($result) && !is_null($httpCode));
|
assert(!is_null($result) && !is_null($httpCode));
|
||||||
|
|
Loading…
Reference in New Issue