commit dd574d60120672fc0b79e10f938f4558d601a7f9
parent 196c482954301a7a515c82048f301ba3a540ce1b
Author: MTRNord <mtrnord1@gmail.com>
Date: Tue, 3 Feb 2015 14:50:32 +0100
I analized it
Diffstat:
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/api.php b/api.php
@@ -21,8 +21,24 @@ if (!file_exists('core/config/connect.db.inc.php')) {
}else{
//$request = $_SERVER['REQUEST_URI'];
//$Api = substr($request, strrpos($request, 'v1/') + 3);
- $Api = $_SERVER['PATH_INFO'];
+
+ $scriptName = $_SERVER['SCRIPT_NAME'];
+ $queryString = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
+
+ // Physical path
+ if (strpos($requestUri, $scriptName) !== false) {
+ $physicalPath = $scriptName; // <-- Without rewriting
+ } else {
+ $physicalPath = str_replace('\\', '', dirname($scriptName)); // <-- With rewriting
+ }
+
+ $requestUri = $_SERVER['REQUEST_URI'];
+ $Api['PATH_INFO'] = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path
+ $Api['PATH_INFO'] = str_replace('?' . $queryString, '', $Api['PATH_INFO']); // <-- Remove query string
+ $Api['PATH_INFO'] = '/' . ltrim($Api['PATH_INFO'], '/'); // <-- Ensure leading slash
print_r($Api);
+
+
//header("HTTP/1.1 301 Moved Permanently");
//header("Location:api/v1/api.php/$Api");
}