Kaynağa Gözat

提高全平台兼容性

oott123 11 yıl önce
ebeveyn
işleme
fa4cfac46a
6 değiştirilmiş dosya ile 64 ekleme ve 16 silme
  1. 6 8
      .htaccess
  2. 2 2
      app.conf
  3. 0 3
      bae.php
  4. 1 1
      config.yaml
  5. 1 1
      include/start.php
  6. 54 1
      index.php

+ 6 - 8
.htaccess

@@ -1,8 +1,6 @@
-RewriteEngine on
-RewriteBase /LayerBAE/
-RewriteCond $1 ^(index\.php)?$ [OR]
-RewriteCond %{REQUEST_FILENAME} -f [OR]
-RewriteCond %{REQUEST_FILENAME} -d
-
-RewriteRule ^(.*)$ - [S=1]
-RewriteRule ^(.*)$ index.php/$1 [L]
+RewriteEngine On
+RewriteBase /
+RewriteRule ^index\.php$ - [L]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule . /index.php [L]

+ 2 - 2
app.conf

@@ -1,3 +1,3 @@
 handlers:
-  - regex_url: ^(.*)$
-    script: /index.php/$1
+  - check_exist: not_exist
+    script: /index.php

+ 0 - 3
bae.php

@@ -1,3 +0,0 @@
-<?php
-	$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
-	include('./index.php');

+ 1 - 1
config.yaml

@@ -6,4 +6,4 @@ handle:
 - compress: if ( out_header["Content-type"]=="text/css" ) compress
 - compress: if ( out_header["Content-type"]=="image/jpeg" ) compress
 - compress: if ( out_header["Content-type"]=="image/png" ) compress
-- rewrite: if ( !is_dir() && !is_file() && path ~ "^(.*)$" ) goto "index.php/$1"
+- rewrite: if ( !is_dir() && !is_file() && path ~ "^(.*)$" ) goto "index.php"

+ 1 - 1
include/start.php

@@ -12,7 +12,7 @@ function includeloader($class){
 
 spl_autoload_register('includeloader');
 //die($_SERVER['QUERY_STRING']);
-new controller(isset($_SERVER['PATH_INFO'])?$_SERVER['PATH_INFO']:'');
+new controller(isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:'');
 //print_r($_SERVER);die();
 //$url = $_SERVER['DOCUMENT_ROOT'].(isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:'');
 //$url = str_ireplace('\\','/',$url);

+ 54 - 1
index.php

@@ -49,5 +49,58 @@ if(!defined('RUN_ENV')){
 	}
 }
 
-require_once BASE_PATH.'include/start.php';
 
+	global $PHP_SELF;
+
+	$default_server_values = array(
+		'SERVER_SOFTWARE' => '',
+		'REQUEST_URI' => '',
+	);
+
+	$_SERVER = array_merge( $default_server_values, $_SERVER );
+
+	// Fix for IIS when running with PHP ISAPI
+	if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
+
+		// IIS Mod-Rewrite
+		if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
+			$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
+		}
+		// IIS Isapi_Rewrite
+		else if ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
+			$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
+		} else {
+			// Use ORIG_PATH_INFO if there is no PATH_INFO
+			if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
+				$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
+
+			// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
+			if ( isset( $_SERVER['PATH_INFO'] ) ) {
+				if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
+					$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
+				else
+					$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
+			}
+
+			// Append the query string if it exists and isn't null
+			if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
+				$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
+			}
+		}
+	}
+
+	// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
+	if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) )
+		$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
+
+	// Fix for Dreamhost and other PHP as CGI hosts
+	if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false )
+		unset( $_SERVER['PATH_INFO'] );
+
+	// Fix empty PHP_SELF
+	$PHP_SELF = $_SERVER['PHP_SELF'];
+	if ( empty( $PHP_SELF ) )
+		$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] );
+
+
+require_once BASE_PATH.'include/start.php';