Kaynağa Gözat

#2498 Rewrite engine

Alex Trofimov 6 yıl önce
ebeveyn
işleme
260ce8cb20
5 değiştirilmiş dosya ile 61 ekleme ve 1 silme
  1. 5 0
      .htaccess
  2. 23 0
      inc/classes/BxDolRewriteRulesQuery.php
  3. 1 1
      inc/utils.inc.php
  4. 0 0
      install/sql/system.sql
  5. 32 0
      r.php

+ 5 - 0
.htaccess

@@ -11,6 +11,11 @@ Options -MultiViews -Indexes
     RewriteRule ^m/(.*)$  modules/index.php?r=$1 [QSA,L]
     RewriteRule ^page/(.*)$  page.php?i=$1 [QSA,L]
     RewriteRule ^s/([a-zA-Z0-9_]+)/([a-zA-Z0-9\.]+)  storage.php?o=$1&f=$2   [QSA,L]
+
+    RewriteCond %{REQUEST_FILENAME} -f [OR]
+    RewriteCond %{REQUEST_FILENAME} -d
+    RewriteRule .+ - [L]
+    RewriteRule ^(.+)$ r.php?_q=$1 [QSA,L]
 </IfModule>
 
 AddType image/svg+xml svg

+ 23 - 0
inc/classes/BxDolRewriteRulesQuery.php

@@ -0,0 +1,23 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+class BxDolRewriteRulesQuery extends BxDolDb
+{
+    public function __construct()
+    {
+    	parent::__construct();
+    }
+
+    static public function getActiveRules()
+    {        
+        return BxDolDb::getInstance()->fromCache("sys_wiki_rewrite_rules", "getAll", "SELECT * FROM `sys_rewrite_rules` WHERE `active` = 1");
+    }
+}
+
+/** @} */

+ 1 - 1
inc/utils.inc.php

@@ -544,7 +544,7 @@ function dbgTiming($sStartMicrotime)
     $i1 = explode(' ', microtime ());
     $i2 = explode(' ', $sStartMicrotime);
     $iTime = ($i1[0]+$i1[1]) - ($i2[0]+$i2[1]);
-    return round($iTime, 3) . ' sec';
+    return round($iTime, 6) . ' sec';
 }
 
 function echoJson($a)

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
install/sql/system.sql


+ 32 - 0
r.php

@@ -0,0 +1,32 @@
+<?php
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+require_once('./inc/header.inc.php');
+require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
+
+bx_import('BxDolLanguages');
+
+check_logged();
+
+$sRequest = ltrim($_GET['_q'], '/');
+$sPath = parse_url(BX_DOL_URL_ROOT, PHP_URL_PATH);
+if ($sPath && '/' != $sPath)
+    $sRequest = bx_ltrim_str($sRequest, rtrim($sPath, '/'));
+
+$aRewriteRules = BxDolRewriteRulesQuery::getActiveRules();
+foreach ($aRewriteRules as $a) {
+    if (preg_match('#'.$a['preg'].'#i', $sRequest, $aMatches)) {
+        BxDolService::callSerialized($a['service'], $aMatches);
+        exit;
+    }
+}
+
+BxDolTemplate::getInstance()->displayPageNotFound();
+
+/** @} */

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor