Skip to content

Instantly share code, notes, and snippets.

@superjojo140
Created February 11, 2021 10:18
Show Gist options
  • Save superjojo140/b44ca3a9ed27c7bf5c4fd94369f0c87a to your computer and use it in GitHub Desktop.
Save superjojo140/b44ca3a9ed27c7bf5c4fd94369f0c87a to your computer and use it in GitHub Desktop.
Controlled data access with PHP
<?php
$default_info =
"<br><b>Persönliche Daten</b><br>"
."<b>Name:</b> Detlef Dummy<br>";
$TOKEN = "superSecretToken";
$code = $_GET["code"];
$name = $_GET["name"];
$client_ip = $_SERVER['REMOTE_ADDR'];
$time = date("d.m.Y - h:i:sa");
if(!isset($code) || $code != $TOKEN){
echo "Kein Zugriff!";
mail("admin@example.com","Personal Data Info","Blockierter Zugriff von $name (ip: $client_ip) um $time.");
exit;
}
else{
//Access allowed
echo $default_info;
echo "<br><br><i><small>Der Eigentümer dieser Website wird per Mail über den Abruf der Daten durch $name (IP: $client_ip) informiert!</small></i>";
mail("admin@example.com","Personal Data Info","Erfolgreicher Zugriff von $name (ip: $client_ip) um $time.");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment