Ver código fonte

Added option to forward to local instance if detected

CauseFX 6 anos atrás
pai
commit
b19fe1701a
3 arquivos alterados com 53 adições e 1 exclusões
  1. 4 1
      api/config/default.php
  2. 26 0
      api/functions/organizr-functions.php
  3. 23 0
      js/functions.js

+ 4 - 1
api/config/default.php

@@ -255,5 +255,8 @@ return array(
 	'homepageUnifiEnabled' => 'false',
 	'homepageUnifiAuth' => '1',
 	'homepageUnifiRefresh' => '600000',
-	'youtubeAPI' => ''
+	'youtubeAPI' => '',
+	'wanDomain' => '',
+	'localAddress' => '',
+	'enableLocalAddressForward' => false
 );

+ 26 - 0
api/functions/organizr-functions.php

@@ -107,6 +107,9 @@ function organizrSpecialSettings()
 		'login' => array(
 			'rememberMe' => $GLOBALS['rememberMe'],
 			'rememberMeDays' => $GLOBALS['rememberMeDays'],
+			'wanDomain' => $GLOBALS['wanDomain'],
+			'localAddress' => $GLOBALS['localAddress'],
+			'enableLocalAddressForward' => $GLOBALS['enableLocalAddressForward'],
 		),
 		'misc' => array(
 			'installedPlugins' => qualifyRequest(1) ? $GLOBALS['installedPlugins'] : '',
@@ -869,6 +872,29 @@ function getSettingsMain()
 				'placeholder' => 'i.e. 123.123.123.123',
 				'help' => 'IPv4 only at the moment - This will set your login as local if your IP falls within the From and To'
 			),
+			array(
+				'type' => 'input',
+				'name' => 'wanDomain',
+				'label' => 'WAN Domain',
+				'value' => $GLOBALS['wanDomain'],
+				'placeholder' => 'only domain and tld - i.e. domain.com',
+				'help' => 'Enter domain if you wish to be forwarded to a local address - Local Address filled out on next item'
+			),
+			array(
+				'type' => 'input',
+				'name' => 'localAddress',
+				'label' => 'Local Address',
+				'value' => $GLOBALS['localAddress'],
+				'placeholder' => 'http://home.local',
+				'help' => 'Full local address of organizr install - i.e. http://home.local or http://192.168.0.100'
+			),
+			array(
+				'type' => 'switch',
+				'name' => 'enableLocalAddressForward',
+				'label' => 'Enable Local Address Forward',
+				'help' => 'Enables the local address forward if on local address and accessed from WAN Domain',
+				'value' => $GLOBALS['enableLocalAddressForward'],
+			),
 		),
 		'Auth Proxy' => array(
 			array(

+ 23 - 0
js/functions.js

@@ -6592,6 +6592,28 @@ function organizrSpecialSettings(array){
 		$(searchBoxResults).appendTo($('.organizr-area'));
 	}
 }
+function checkLocalForwardStatus(array){
+    if(array.settings.login.enableLocalAddressForward == true && typeof array.settings.login.enableLocalAddressForward !== 'undefined'){
+        if(array.setting.login.wanDomain !== '' && array.setting.login.localAddress !== ''){
+            console.log('Local Login Enabled');
+            console.log('Local Login Testing...');
+            let remoteSite = array.setting.login.wanDomain;
+            let localSite = array.setting.login.localAddress;
+            try {
+                let currentURL = decodeURI(window.location.href)
+                let currentSite = window.location.host;
+                if(activeInfo.settings.user.local && currentSite.indexOf(remoteSite) !== -1 && currentURL.indexOf('override') === -1){
+                    console.log('Local Login Status: Local | Forwarding Now');
+                    window.location = localSite;
+                }
+            } catch(e) {
+                console.error(e);
+            }
+            console.log('Local Login Status: Not Local');
+
+        }
+    }
+}
 function forceSearch(term){
     $.magnificPopup.close();
     var tabName = $("li[data-url^='api/?v1/homepage/page']").find('span').html();
@@ -7422,6 +7444,7 @@ function launch(){
                     accountManager(json);
                     organizrSpecialSettings(json);
                     getPingList(json);
+                    checkLocalForwardStatus(json);
                 }
                 loadCustomJava(json.appearance);
                 if(getCookie('lockout')){