| ... | ... |
@@ -14,6 +14,8 @@ class Request{
|
| 14 | 14 |
public function __construct(){
|
| 15 | 15 |
if(isset($_SERVER['L3_PATH'])) |
| 16 | 16 |
$this->path = $_SERVER['L3_PATH']; |
| 17 |
+ else if(isset($_SERVER['REDIRECT_L3_PATH'])) |
|
| 18 |
+ $this->path = $_SERVER['REDIRECT_L3_PATH']; |
|
| 17 | 19 |
$this->method = $_SERVER['REQUEST_METHOD']; |
| 18 | 20 |
$this->accept = isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:""; |
| 19 | 21 |
$this->acceptTypes = $this->parseAccept($this->accept); |
| ... | ... |
@@ -12,8 +12,8 @@ class Request{
|
| 12 | 12 |
public $headers; |
| 13 | 13 |
public $body; |
| 14 | 14 |
public function __construct(){
|
| 15 |
- if(isset($_GET['path'])) |
|
| 16 |
- $this->path = $_GET['path']; |
|
| 15 |
+ if(isset($_SERVER['L3_PATH'])) |
|
| 16 |
+ $this->path = $_SERVER['L3_PATH']; |
|
| 17 | 17 |
$this->method = $_SERVER['REQUEST_METHOD']; |
| 18 | 18 |
$this->accept = isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:""; |
| 19 | 19 |
$this->acceptTypes = $this->parseAccept($this->accept); |
| ... | ... |
@@ -15,10 +15,10 @@ class Request{
|
| 15 | 15 |
if(isset($_GET['path'])) |
| 16 | 16 |
$this->path = $_GET['path']; |
| 17 | 17 |
$this->method = $_SERVER['REQUEST_METHOD']; |
| 18 |
- $this->accept = $_SERVER['HTTP_ACCEPT']; |
|
| 18 |
+ $this->accept = isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:""; |
|
| 19 | 19 |
$this->acceptTypes = $this->parseAccept($this->accept); |
| 20 | 20 |
$this->acceptLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])?$_SERVER['HTTP_ACCEPT_LANGUAGE']:""; |
| 21 |
- $this->userAgent = $_SERVER['HTTP_USER_AGENT']; |
|
| 21 |
+ $this->userAgent = isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; |
|
| 22 | 22 |
if(function_exists('apache_request_headers')){
|
| 23 | 23 |
$this->headers = apache_request_headers(); |
| 24 | 24 |
} |
| ... | ... |
@@ -49,10 +49,10 @@ class Request{
|
| 49 | 49 |
$type = explode(";", $acceptParts);
|
| 50 | 50 |
$result[] = $type[0]; |
| 51 | 51 |
if(count($type)>1){
|
| 52 |
- if($type[1][0].$type[1][1] == "q="){
|
|
| 52 |
+ if(isset($type[1]) && $type[1][0].$type[1][1] == "q="){
|
|
| 53 | 53 |
$quality_factors[] = substr($type[1],2); |
| 54 | 54 |
} |
| 55 |
- else if($type[2][0].$type[2][1] == "q="){
|
|
| 55 |
+ else if(isset($type[2]) && $type[2][0].$type[2][1] == "q="){
|
|
| 56 | 56 |
$quality_factors[] = substr($type[2],2); |
| 57 | 57 |
} |
| 58 | 58 |
else{
|
| ... | ... |
@@ -3,41 +3,41 @@ |
| 3 | 3 |
namespace elanpl\L3; |
| 4 | 4 |
|
| 5 | 5 |
class Request{
|
| 6 |
- public $Path; |
|
| 7 |
- public $Method; |
|
| 8 |
- public $Accept; |
|
| 9 |
- public $AcceptTypes; |
|
| 10 |
- public $AcceptLanguage; |
|
| 11 |
- public $UserAgent; |
|
| 12 |
- public $Headers; |
|
| 13 |
- public $Body; |
|
| 6 |
+ public $path; |
|
| 7 |
+ public $method; |
|
| 8 |
+ public $accept; |
|
| 9 |
+ public $acceptTypes; |
|
| 10 |
+ public $acceptLanguage; |
|
| 11 |
+ public $userAgent; |
|
| 12 |
+ public $headers; |
|
| 13 |
+ public $body; |
|
| 14 | 14 |
public function __construct(){
|
| 15 | 15 |
if(isset($_GET['path'])) |
| 16 |
- $this->Path = $_GET['path']; |
|
| 17 |
- $this->Method = $_SERVER['REQUEST_METHOD']; |
|
| 18 |
- $this->Accept = $_SERVER['HTTP_ACCEPT']; |
|
| 19 |
- $this->AcceptTypes = $this->ParseAccept($this->Accept); |
|
| 20 |
- $this->AcceptLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])?$_SERVER['HTTP_ACCEPT_LANGUAGE']:""; |
|
| 21 |
- $this->UserAgent = $_SERVER['HTTP_USER_AGENT']; |
|
| 16 |
+ $this->path = $_GET['path']; |
|
| 17 |
+ $this->method = $_SERVER['REQUEST_METHOD']; |
|
| 18 |
+ $this->accept = $_SERVER['HTTP_ACCEPT']; |
|
| 19 |
+ $this->acceptTypes = $this->parseAccept($this->accept); |
|
| 20 |
+ $this->acceptLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])?$_SERVER['HTTP_ACCEPT_LANGUAGE']:""; |
|
| 21 |
+ $this->userAgent = $_SERVER['HTTP_USER_AGENT']; |
|
| 22 | 22 |
if(function_exists('apache_request_headers')){
|
| 23 |
- $this->Headers = apache_request_headers(); |
|
| 23 |
+ $this->headers = apache_request_headers(); |
|
| 24 | 24 |
} |
| 25 | 25 |
else{
|
| 26 |
- $this->Headers = array(); |
|
| 26 |
+ $this->headers = array(); |
|
| 27 | 27 |
foreach($_SERVER as $key => $value) {
|
| 28 | 28 |
if (substr($key, 0, 5) <> 'HTTP_') {
|
| 29 | 29 |
continue; |
| 30 | 30 |
} |
| 31 | 31 |
$header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
|
| 32 |
- $this->Headers[$header] = $value; |
|
| 32 |
+ $this->headers[$header] = $value; |
|
| 33 | 33 |
} |
| 34 | 34 |
} |
| 35 | 35 |
if (php_sapi_name() != "cli") {
|
| 36 |
- $this->Body = file_get_contents('php://input');
|
|
| 36 |
+ $this->body = file_get_contents('php://input');
|
|
| 37 | 37 |
} |
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 |
- public function ParseAccept($accept){
|
|
| 40 |
+ public function parseAccept($accept){
|
|
| 41 | 41 |
//cut out the spaces |
| 42 | 42 |
$accept = str_replace(" ", "", $accept);
|
| 43 | 43 |
|
| ... | ... |
@@ -45,8 +45,8 @@ class Request{
|
| 45 | 45 |
$quality_factors = array(); |
| 46 | 46 |
|
| 47 | 47 |
// find content type and corresponding quality factor value |
| 48 |
- foreach(explode(",", $accept) as $AcceptParts){
|
|
| 49 |
- $type = explode(";", $AcceptParts);
|
|
| 48 |
+ foreach(explode(",", $accept) as $acceptParts){
|
|
| 49 |
+ $type = explode(";", $acceptParts);
|
|
| 50 | 50 |
$result[] = $type[0]; |
| 51 | 51 |
if(count($type)>1){
|
| 52 | 52 |
if($type[1][0].$type[1][1] == "q="){
|
| ... | ... |
@@ -10,6 +10,7 @@ class Request{
|
| 10 | 10 |
public $AcceptLanguage; |
| 11 | 11 |
public $UserAgent; |
| 12 | 12 |
public $Headers; |
| 13 |
+ public $Body; |
|
| 13 | 14 |
public function __construct(){
|
| 14 | 15 |
if(isset($_GET['path'])) |
| 15 | 16 |
$this->Path = $_GET['path']; |
| ... | ... |
@@ -31,6 +32,9 @@ class Request{
|
| 31 | 32 |
$this->Headers[$header] = $value; |
| 32 | 33 |
} |
| 33 | 34 |
} |
| 35 |
+ if (php_sapi_name() != "cli") {
|
|
| 36 |
+ $this->Body = file_get_contents('php://input');
|
|
| 37 |
+ } |
|
| 34 | 38 |
} |
| 35 | 39 |
|
| 36 | 40 |
public function ParseAccept($accept){
|
| ... | ... |
@@ -1,4 +1,4 @@ |
| 1 |
-<? |
|
| 1 |
+<?php |
|
| 2 | 2 |
|
| 3 | 3 |
namespace elanpl\L3; |
| 4 | 4 |
|
| ... | ... |
@@ -16,8 +16,8 @@ class Request{
|
| 16 | 16 |
$this->Method = $_SERVER['REQUEST_METHOD']; |
| 17 | 17 |
$this->Accept = $_SERVER['HTTP_ACCEPT']; |
| 18 | 18 |
$this->AcceptTypes = $this->ParseAccept($this->Accept); |
| 19 |
- $this->AcceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE']; |
|
| 20 |
- $this->UserAgent = $_SERVER['HTTP_USERAGENT']; |
|
| 19 |
+ $this->AcceptLanguage = isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])?$_SERVER['HTTP_ACCEPT_LANGUAGE']:""; |
|
| 20 |
+ $this->UserAgent = $_SERVER['HTTP_USER_AGENT']; |
|
| 21 | 21 |
if(function_exists('apache_request_headers')){
|
| 22 | 22 |
$this->Headers = apache_request_headers(); |
| 23 | 23 |
} |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,69 @@ |
| 1 |
+<? |
|
| 2 |
+ |
|
| 3 |
+namespace elanpl\L3; |
|
| 4 |
+ |
|
| 5 |
+class Request{
|
|
| 6 |
+ public $Path; |
|
| 7 |
+ public $Method; |
|
| 8 |
+ public $Accept; |
|
| 9 |
+ public $AcceptTypes; |
|
| 10 |
+ public $AcceptLanguage; |
|
| 11 |
+ public $UserAgent; |
|
| 12 |
+ public $Headers; |
|
| 13 |
+ public function __construct(){
|
|
| 14 |
+ if(isset($_GET['path'])) |
|
| 15 |
+ $this->Path = $_GET['path']; |
|
| 16 |
+ $this->Method = $_SERVER['REQUEST_METHOD']; |
|
| 17 |
+ $this->Accept = $_SERVER['HTTP_ACCEPT']; |
|
| 18 |
+ $this->AcceptTypes = $this->ParseAccept($this->Accept); |
|
| 19 |
+ $this->AcceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE']; |
|
| 20 |
+ $this->UserAgent = $_SERVER['HTTP_USERAGENT']; |
|
| 21 |
+ if(function_exists('apache_request_headers')){
|
|
| 22 |
+ $this->Headers = apache_request_headers(); |
|
| 23 |
+ } |
|
| 24 |
+ else{
|
|
| 25 |
+ $this->Headers = array(); |
|
| 26 |
+ foreach($_SERVER as $key => $value) {
|
|
| 27 |
+ if (substr($key, 0, 5) <> 'HTTP_') {
|
|
| 28 |
+ continue; |
|
| 29 |
+ } |
|
| 30 |
+ $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
|
|
| 31 |
+ $this->Headers[$header] = $value; |
|
| 32 |
+ } |
|
| 33 |
+ } |
|
| 34 |
+ } |
|
| 35 |
+ |
|
| 36 |
+ public function ParseAccept($accept){
|
|
| 37 |
+ //cut out the spaces |
|
| 38 |
+ $accept = str_replace(" ", "", $accept);
|
|
| 39 |
+ |
|
| 40 |
+ $result = array(); |
|
| 41 |
+ $quality_factors = array(); |
|
| 42 |
+ |
|
| 43 |
+ // find content type and corresponding quality factor value |
|
| 44 |
+ foreach(explode(",", $accept) as $AcceptParts){
|
|
| 45 |
+ $type = explode(";", $AcceptParts);
|
|
| 46 |
+ $result[] = $type[0]; |
|
| 47 |
+ if(count($type)>1){
|
|
| 48 |
+ if($type[1][0].$type[1][1] == "q="){
|
|
| 49 |
+ $quality_factors[] = substr($type[1],2); |
|
| 50 |
+ } |
|
| 51 |
+ else if($type[2][0].$type[2][1] == "q="){
|
|
| 52 |
+ $quality_factors[] = substr($type[2],2); |
|
| 53 |
+ } |
|
| 54 |
+ else{
|
|
| 55 |
+ $quality_factors[] = 1; |
|
| 56 |
+ } |
|
| 57 |
+ } |
|
| 58 |
+ else{
|
|
| 59 |
+ $quality_factors[] = 1; |
|
| 60 |
+ } |
|
| 61 |
+ } |
|
| 62 |
+ |
|
| 63 |
+ // sort the types according to quality factors |
|
| 64 |
+ array_multisort($quality_factors, SORT_DESC, SORT_NUMERIC, $result); |
|
| 65 |
+ |
|
| 66 |
+ return $result; |
|
| 67 |
+ } |
|
| 68 |
+ |
|
| 69 |
+} |
|
| 0 | 70 |
\ No newline at end of file |