Pārlūkot izejas kodu

Added feature to support sub-directories as multi-url identifiers. Still unsafe (cookies) but working. This links to task 6510 but it actually fixes an issue in refs #6314

Yannick Warnier 11 gadi atpakaļ
vecāks
revīzija
3e373a87ff
1 mainītis faili ar 18 papildinājumiem un 5 dzēšanām
  1. 18 5
      main/inc/global.inc.php

+ 18 - 5
main/inc/global.inc.php

@@ -143,13 +143,26 @@ if (!empty($_configuration['multiple_access_urls'])) {
     $pos = strpos($root_rel,'/');
     $root_rel = substr($root_rel,0,$pos);
     $protocol = ((!empty($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) != 'OFF') ? 'https' : 'http').'://';
-    $request_url1 = $protocol.$_SERVER['SERVER_NAME'].'/'.$root_rel.'/';
-    $request_url2 = $protocol.$_SERVER['HTTP_HOST'].'/'.$root_rel.'/';
-    
-    
+    //urls with subdomains
+    $request_url_root_1 = $protocol.$_SERVER['SERVER_NAME'].'/';
+    $request_url_root_2 = $protocol.$_SERVER['HTTP_HOST'].'/';
+    //urls with subdirs
+    $request_url_sub_1 = $request_url_root_1.$root_rel.'/';
+    $request_url_sub_2 = $request_url_root_2.$root_rel.'/';
+
+    // You can use subdirs as multi-urls, but in this case none of them can be
+    // the root dir. The admin portal should be something like https://host/adm/
+    // At this time, subdirs will still hold a share cookie, so not ideal yet
+    // see #6510
     foreach ($access_urls as $details) {
-        if ($request_url1 == $details['url'] or $request_url2 == $details['url']) {
+        if ($request_url_sub_1 == $details['url'] or $request_url_sub_2 == $details['url']) {
+            $_configuration['access_url'] = $details['id'];
+            break; //found one match with subdir, get out of foreach
+        }
+        // Didn't find any? Now try without subdirs
+        if ($request_url_root_1 == $details['url'] or $request_url_root_2 == $details['url']) {
             $_configuration['access_url'] = $details['id'];
+            break; //found one match, get out of foreach
         }
     }
 } else {