Alex Trofimov 4 лет назад
Родитель
Сommit
c2ce025456
3 измененных файлов с 30 добавлено и 4 удалено
  1. 1 1
      inc/classes/BxDolPage.php
  2. 3 3
      inc/classes/BxDolPermalinks.php
  3. 26 0
      inc/utils.inc.php

+ 1 - 1
inc/classes/BxDolPage.php

@@ -339,7 +339,7 @@ class BxDolPage extends BxDolFactory implements iBxDolFactoryObject, iBxDolRepla
         if (false === $sQuery)
             return false;
 
-        parse_str($sQuery, $aQueryParams);
+        $aQueryParams = bx_parse_str($sQuery);
 
         $sPageUri = !empty($aQueryParams['i']) ? $aQueryParams['i'] : false;
         unset($aQueryParams['i']);

+ 3 - 3
inc/classes/BxDolPermalinks.php

@@ -185,15 +185,15 @@ class BxDolPermalinks extends BxDolDb implements iBxDolSingleton
             $sPage = $this->getPageNameFromLink($sLink, $iLength);
 
             if (!$this->_isEnabled($sKey))
-                return bx_append_url_params($sLink, $aParams, false);
+                return bx_append_url_params($sLink, $aParams);
 
             $sUrl = $this->_fixUrlAmpersand($this->aLinksStandard[$sKey]['permalink'] . $sPage);
 
-            return $sPrefix . bx_append_url_params($sUrl, $aParams, false);
+            return $sPrefix . bx_append_url_params($sUrl, $aParams);
 
         }
 
-        return $sPrefix . bx_append_url_params($this->_isEnabled($sLink) ? $this->aLinksStandard[$sLink]['permalink'] : $sLink, $aParams, false);
+        return $sPrefix . bx_append_url_params($this->_isEnabled($sLink) ? $this->aLinksStandard[$sLink]['permalink'] : $sLink, $aParams);
     }
 
     /**

+ 26 - 0
inc/utils.inc.php

@@ -1406,6 +1406,32 @@ function bx_encode_url_params ($a, $aExcludeKeys = array (), $aOnlyKeys = false)
     return $s;
 }
 
+/**
+ * It works similar to `parse_str` php function, but it doesn't decode URL params
+ */
+function bx_parse_str($s) 
+{
+    $a = [];
+    $aPairs = explode('&', $s);
+
+    foreach ($aPairs as $i) {
+        list($sName, $mixedValue) = explode('=', $i, 2);
+        $sName = rtrim($sName, '[]');
+
+        if (isset($a[$sName])) {
+            if (is_array($a[$sName]))
+                $a[$sName][] = $mixedValue;
+            else 
+                $a[$sName] = [$a[$sName], $mixedValue];
+        }
+        else {
+            $a[$sName] = $mixedValue;
+        }
+    }
+
+    return $a;
+}
+
 function bx_append_url_params ($sUrl, $mixedParams, $bEncodeParams = true, $aIgnoreParams = [])
 {
     if (!$mixedParams)