Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
HTTP_USER_AGENT might not be set
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs committed Oct 11, 2011
1 parent a850784 commit 52528df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function remote_ip() {
return $this->_remote_ip;

$remote_addr_list = array();
if (isset($this->headers["REMOTE_ADDR"]))
if (!empty($this->headers["REMOTE_ADDR"]))
$remote_addr_list = explode(",", $this->headers["REMOTE_ADDR"]);

foreach ($remote_addr_list as $addr)
Expand All @@ -235,11 +235,11 @@ public function remote_ip() {

$forwarded_for = array();

if (isset($this->headers["HTTP_X_FORWARDED_FOR"]))
if (!empty($this->headers["HTTP_X_FORWARDED_FOR"]))
$forwarded_for = explode(",",
$this->headers["HTTP_X_FORWARDED_FOR"]);

if (isset($this->headers["HTTP_CLIENT_IP"])) {
if (!empty($this->headers["HTTP_CLIENT_IP"])) {
if (!in_array($this->headers["HTTP_CLIENT_IP"], $forwarded_for))
throw new HalfMoonException("IP spoofing attack? "
. "HTTP_CLIENT_IP="
Expand Down Expand Up @@ -284,7 +284,7 @@ public function request_method() {

/* the user's browser as reported by the server */
public function user_agent() {
return $this->headers["HTTP_USER_AGENT"];
return @$this->headers["HTTP_USER_AGENT"];
}

private function etag_matches_inm() {
Expand Down

0 comments on commit 52528df

Please sign in to comment.