NobGit
public nobgit read

NobMail

Based on mailcow: dockerized

Languages

Repository composition by tracked source files.

PHP
PHP 49% JavaScript 35% HTML 9% CSS 4% Shell 2% Python 1% Lua 0% Perl 0% Ruby 0% SCSS 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git

Commit

Revert "[Web] Fix broken autoconfig ports, fixes #4221 (#4223)" (#4226)

This reverts commit 9afea99189d5fd888aefb1f3552f2f56118a0d7d.

639e7516
AndrĂ© Peters <[email protected]> 4 years, 11 months ago
data/web/inc/functions.inc.php     | 12 +-----------
 data/web/inc/prerequisites.inc.php | 14 +++++++++++---
 data/web/inc/vars.inc.php          | 12 ++++++------
 3 files changed, 18 insertions(+), 20 deletions(-)

Diff

diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php
index 4b2d8c2f..c6642418 100644
--- a/data/web/inc/functions.inc.php
+++ b/data/web/inc/functions.inc.php
@@ -2219,14 +2219,4 @@ function cleanupCSS($ignore = '', $folder = '/tmp/*.css') {
   }
 }
 
-function get_remote_ip() {
-  $remote = $_SERVER['REMOTE_ADDR'];
-  if (filter_var($remote, FILTER_VALIDATE_IP) === false) {
-    return '0.0.0.0';
-  }
-  return $remote;
-}
-
-function getEnvPort(string $name): int {
-	return (int)filter_var(substr(getenv($name), strrpos(getenv($name), ':')), FILTER_SANITIZE_NUMBER_INT);
-}
\ No newline at end of file
+?>
diff --git a/data/web/inc/prerequisites.inc.php b/data/web/inc/prerequisites.inc.php
index 86aeb200..0cbd05a0 100644
--- a/data/web/inc/prerequisites.inc.php
+++ b/data/web/inc/prerequisites.inc.php
@@ -5,8 +5,6 @@
   header('Location: /SOGo', true, 307);
   exit;
 }*/
-// Load core functions first
-require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.inc.php';
 
 require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/vars.inc.php';
 $default_autodiscover_config = $autodiscover_config;
@@ -173,7 +171,17 @@ function exception_handler($e) {
 }
 set_exception_handler('exception_handler');
 
-// Load session
+// TODO: Move function
+function get_remote_ip() {
+  $remote = $_SERVER['REMOTE_ADDR'];
+  if (filter_var($remote, FILTER_VALIDATE_IP) === false) {
+    return '0.0.0.0';
+  }
+  return $remote;
+}
+
+// Load core functions first
+require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/functions.inc.php';
 require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/sessions.inc.php';
 
 // IMAP lib
diff --git a/data/web/inc/vars.inc.php b/data/web/inc/vars.inc.php
index 0951a9de..eb3b4b0c 100644
--- a/data/web/inc/vars.inc.php
+++ b/data/web/inc/vars.inc.php
@@ -45,18 +45,18 @@ $autodiscover_config = array(
   // The autoconfig service will additionally announce the STARTTLS-enabled ports, specified in the "tlsport" variable.
   'imap' => array(
     'server' => $mailcow_hostname,
-    'port' => getEnvPort('IMAPS_PORT'),
-    'tlsport' => getEnvPort('IMAP_PORT')
+    'port' => (int)filter_var(substr(getenv('IMAPS_PORT'), strrpos(getenv('IMAPS_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT),
+    'tlsport' => (int)filter_var(substr(getenv('POP_PORT'), strrpos(getenv('IMAP_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT)
   ),
   'pop3' => array(
     'server' => $mailcow_hostname,
-    'port' => getEnvPort('POPS_PORT'),
-    'tlsport' => getEnvPort('POP_PORT')
+    'port' => (int)filter_var(substr(getenv('POPS_PORT'), strrpos(getenv('POPS_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT),
+    'tlsport' => (int)filter_var(substr(getenv('POP_PORT'), strrpos(getenv('POP_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT)
   ),
   'smtp' => array(
     'server' => $mailcow_hostname,
-    'port' => getEnvPort('SMTPS_PORT'),
-    'tlsport' => getEnvPort('SUBMISSION_PORT')
+    'port' => (int)filter_var(substr(getenv('SMTPS_PORT'), strrpos(getenv('SMTPS_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT),
+    'tlsport' => (int)filter_var(substr(getenv('SUBMISSION_PORT'), strrpos(getenv('SUBMISSION_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT)
   ),
   'activesync' => array(
     'url' => 'https://' . $mailcow_hostname . ($https_port == 443 ? '' : ':' . $https_port) . '/Microsoft-Server-ActiveSync',