WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • Modules »
  • Geolocation of Users
  • Print
Pages: [1]   Go Down

Author Topic: Geolocation of Users  (Read 5481 times)

Offline markherrmann

  • Posts: 141
Geolocation of Users
« on: October 08, 2021, 06:45:08 PM »
Hi, im Rahmen einer Benutzerkontrolle habe ich in meinem Webprojekt mittels Droplet unter anderem eine geografische Zuordnung der User auf Basis deren IP-Adresse eingebaut. Ich lasse Länder, aus denen nur Spam ins Kontaktformular geschrieben wird gar nicht mehr auf meine Inhalte.
PS. Die Möglichkeiten Honeypot's oder weiterer Kontrollen (Laufzeit der UI-Eingaben) nutze ich zusätzlich im Formular.

Hier ein einfacher Code unter Nutzung eines Dienstleisters.
Da dieser gratis ist frage ich nicht jeden Request ab sondern speichere jeden Request mit Verfalldatum in Tabelle (now_online) ist er neu Frage ich ab, ist er bekannt oder verfallen dann nicht.

Das hat den Vorteil das der Fremde Dienst nicht bei jedem Seitenaufbau benutzt werden muss (Seitenladezeiten liegen so zwischen ca. 0,003 ms und 0,480 ms bei Nutzern aus Chicago US)

Anbei der rauskopierte Code (nicht elegant, aber als Anregung für andere gedacht):
Code: [Select]
function droplet_loadWebPage($url, $postdata="") {
$agent = WEBSITE_TITLE."_myAgent_1.0.0";
        $header[] = "Accept: text/vnd.wap.wml,*.*";
        $ch = curl_init($url);
        if ($ch) {
curl_setopt($ch,    CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,    CURLOPT_USERAGENT, $agent);
curl_setopt($ch,    CURLOPT_HTTPHEADER, $header);
curl_setopt($ch,    CURLOPT_FOLLOWLOCATION, 1);
if (isset($postdata) && $postdata != "") {
curl_setopt($ch,    CURLOPT_POST, 1);
curl_setopt($ch,    CURLOPT_POSTFIELDS, $postdata);
} // end if isset
$tmp = curl_exec ($ch);
curl_close ($ch);
} // end if $ch
return $tmp;
unset ($tmp);
} // droplet_loadWebPage

// Benutzung eines OnlineDienstes... IP->LOCAL (db-ip.com)
$temp_local["inspect_ip"] = 'http://api.db-ip.com/v2/free/'.$out["ip"];
$temp_local["ip2local_info"] = droplet_loadWebPage($temp_local["inspect_ip"]);
$temp_local["json_object"] = json_decode($temp_local["ip2local_info"]);
if (!isset($temp_local["json_object"]->{'continentCode'})) {
$out["kontinent_id"] = '';
$out["kontinent_name"] = '';
$out["land_id"] = '';
$out["land_name"] = '';
$out["bundesland"] = '';
$out["stadt"] = '';
} else {
$out["kontinent_id"] = $temp_local["json_object"]->{'continentCode'};
$out["kontinent_name"] = $temp_local["json_object"]->{'continentName'};
$out["land_id"] = $temp_local["json_object"]->{'countryCode'};
$out["land_name"] = droplet_german_code2land($out["land_id"]);
// $out["land_name"] = $temp_local["json_object"]->{'countryName'};
$out["bundesland"] = $temp_local["json_object"]->{'stateProv'};
$out["stadt"] = $temp_local["json_object"]->{'city'};
} // end if isset
return $out;
} // droplet_getUserinformation

Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • Modules »
  • Geolocation of Users
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2