format
This commit is contained in:
parent
476808db4b
commit
e97198aa10
3 changed files with 21 additions and 20 deletions
|
@ -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
|
||||
]);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,7 +192,7 @@ function get_real_ip() {
|
|||
function get_session_ip(Config $config): string
|
||||
{
|
||||
$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));
|
||||
return $addr;
|
||||
}
|
||||
|
@ -822,4 +824,3 @@ function generate_key(int $length = 20): string
|
|||
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
@ -20,7 +20,7 @@ class VarnishPurger extends Extension
|
|||
}
|
||||
|
||||
global $config;
|
||||
$host = $config->get_string('varnish_host');
|
||||
$host = $config->get_string('varnish_host');
|
||||
$port = $config->get_int('varnish_port');
|
||||
$protocol = $config->get_string('varnish_protocol');
|
||||
$url = $protocol . '://'. $host . '/' . $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));
|
||||
|
|
Reference in a new issue