Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Secure webmap fix #109

Merged
merged 1 commit into from
Apr 29, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions PHP/proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,15 @@ public function isUnauthorized()

}

if (strpos($this->proxyBody,'"code":403') !== false) {

$isUnauthorized = true;

}

$errorCode = $jsonData->{'error'}->{'code'};

if($errorCode == 499 || $errorCode == 498)
if($errorCode == 499 || $errorCode == 498 || $errorCode == 403)
{
$isUnauthorized = true;

Expand Down Expand Up @@ -801,8 +807,34 @@ public function initCurl()
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);

}



public function curlError()
{
// see full of cURL error codes at http://curl.haxx.se/libcurl/c/libcurl-errors.html

$message = "cURL error (" . curl_errno($this->ch) . "): "
. curl_error($this->ch) . ".";

$this->proxyLog->log($message);

header('Status: 502', true, 502); // 502 Bad Gateway - The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.

header('Content-Type: application/json');

$configError = array(
"error" => array("code" => 502,
"details" => array($message),
"message" => "Proxy failed due to curl error."
));

echo json_encode($configError);

curl_close($this->ch);

$this->ch = null;

exit();
}

public function proxyGet() {

Expand All @@ -822,7 +854,7 @@ public function proxyGet() {

if(curl_errno($this->ch) > 0 || empty($this->response))
{
$this->proxyLog->log("Curl error or no response: " . curl_error($this->ch));
$this->curlError();

}else{

Expand Down Expand Up @@ -887,7 +919,7 @@ public function proxyPost($url, $params)

if(curl_errno($this->ch) > 0 || empty($this->response))
{
$this->proxyLog->log("Curl error or no response: " . curl_error($this->ch));
$this->curlError();

}else{

Expand Down Expand Up @@ -947,7 +979,7 @@ public function proxyFiles()

if(curl_errno($this->ch) > 0 || empty($this->response))
{
$this->proxyLog->log("Curl error or no response: " . curl_error($this->ch));
$this->curlError();
}else{

$this->setProxyHeaders();
Expand Down