Jump to content

GeekInAsia

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

GeekInAsia's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am trying to create a simple function that I can call from the start of each page. It is simply checking where a users is in the UK or trying to access whilst overseas. I have the detection working fine, however it alerts me every time they reload or change a page. What i want is just to be alerted once. My code it below if someone can point out my mistakes I would appreciate it. <?php if (getenv(@HTTP_X_FORWARDED_FOR)) { $tmp_SurferIP = @getenv(HTTP_X_FORWARDED_FOR); } else { $tmp_SurferIP = @getenv(REMOTE_ADDR); } $tmp_SurferCountry = geoip_country_code_by_addr($gi, $tmp_SurferIP); if ($tmp_SurferCountry != "GB") { if (@$_SESSION['SurferCountryDenied'] != TRUE) { $tmp_SentToEmail = "ehostmanager@gmail.com"; $tmp_MessageSubject = "Site Access Denied Notice - ".$tmp_SurferCountry." - ".$tmp_SurferIP; SendEmail ($tmp_SentToEmail,$tmp_MessageSubject,$tmp_MessageBody); @$_SESSION['SurferCountryDenied'] = TRUE; } echo "Sorry you are not in the UK, so access to this site has been denied"; exit; } else { if (@$_SESSION['SurferCountryGranted'] != TRUE) { $tmp_SentToEmail = "ehostmanager@gmail.com"; $tmp_MessageSubject = "Site Access Granted Notice - ".$tmp_SurferCountry." - ".$tmp_SurferIP; $tmp_MessageBody = "The IP address <strong>".$tmp_SurferIP."</strong> has been granted access to the site due to being detected within the United Kingdom"; @$_SESSION['SurferCountryGranted'] = TRUE; SendEmail ($tmp_SentToEmail,$tmp_MessageSubject,$tmp_MessageBody); } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.