From e97198aa106af337eeb1420436a13c913e763f4f Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 9 Jul 2022 23:37:43 +0100 Subject: [PATCH] format --- core/userclass.php | 2 +- core/util.php | 27 ++++++++++++++------------- ext/varnish/main.php | 12 ++++++------ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/core/userclass.php b/core/userclass.php index 827448b2..a15d1767 100644 --- a/core/userclass.php +++ b/core/userclass.php @@ -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 ]); diff --git a/core/util.php b/core/util.php index a2774437..ab60089b 100644 --- a/core/util.php +++ b/core/util.php @@ -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; } - diff --git a/ext/varnish/main.php b/ext/varnish/main.php index 82938d17..3d20cbdb 100644 --- a/ext/varnish/main.php +++ b/ext/varnish/main.php @@ -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));