add
This commit is contained in:
1 parent
2062d64ad9
commit
ab8f36b17a
1 file changed
+123
-77
@@ -1,8 +1,14 @@
|
||||
<?php
|
||||
|
||||
class getSpecificData {
|
||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
public function getWeather() {
|
||||
use MaxMind\Db\Reader;
|
||||
|
||||
class getSpecificData
|
||||
{
|
||||
|
||||
public function getWeather()
|
||||
{
|
||||
$url = "https://api.openweathermap.org/data/2.5/weather?q=Jena,DE&APPID=5bc3e1a438c58fca444c4370ac0517b2&units=metric";
|
||||
|
||||
$ch = curl_init();
|
||||
@@ -12,7 +18,7 @@ class getSpecificData {
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if(curl_errno($ch)) {
|
||||
if (curl_errno($ch)) {
|
||||
echo "cURL Fehler: " . curl_error($ch);
|
||||
exit;
|
||||
}
|
||||
@@ -34,60 +40,74 @@ class getSpecificData {
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserAgent(): string {
|
||||
public function getUserAgent(): string
|
||||
{
|
||||
return $_SERVER['HTTP_USER_AGENT'] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getRequestURL(): string {
|
||||
public function getRequestURL(): string
|
||||
{
|
||||
return $_SERVER['REQUEST_URI'] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getCookie(string $name): ?string {
|
||||
public function getCookie(string $name): ?string
|
||||
{
|
||||
return $_COOKIE[$name] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getSessionID(): string {
|
||||
public function getSessionID(): string
|
||||
{
|
||||
return $session_id ?? 'Unbekannt ';
|
||||
}
|
||||
|
||||
public function getServerPort(): string {
|
||||
public function getServerPort(): string
|
||||
{
|
||||
return $_SERVER['SERVER_PORT'] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getClientPort(): string {
|
||||
public function getClientPort(): string
|
||||
{
|
||||
return $_SERVER['REMOTE_PORT'] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getDocumentRoot(): string {
|
||||
public function getDocumentRoot(): string
|
||||
{
|
||||
return $_SERVER['DOCUMENT_ROOT'] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getQuery(): string {
|
||||
|
||||
public function getQuery(): string
|
||||
{
|
||||
return $_SERVER['QUERY_STRING'] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getRequestMethod(): string {
|
||||
|
||||
public function getRequestMethod(): string
|
||||
{
|
||||
return $_SERVER['REQUEST_METHOD'] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getCurrentDir(): string {
|
||||
return __DIR__ ;
|
||||
public function getCurrentDir(): string
|
||||
{
|
||||
return __DIR__;
|
||||
}
|
||||
|
||||
public function getReferer(): string {
|
||||
public function getReferer(): string
|
||||
{
|
||||
return $_SERVER['HTTP_REFERER'] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getWebsite(): string {
|
||||
public function getWebsite(): string
|
||||
{
|
||||
return $_SERVER['HTTP_HOST'] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
public function getDatabase(): string {
|
||||
public function getDatabase(): string
|
||||
{
|
||||
$conn = db_connect();
|
||||
return $conn->host_info;
|
||||
}
|
||||
|
||||
public function getLoggingStatus($variable) {
|
||||
public function getLoggingStatus($variable)
|
||||
{
|
||||
$status = DatabaseShow(
|
||||
"Variablen",
|
||||
"WERT",
|
||||
@@ -96,8 +116,9 @@ class getSpecificData {
|
||||
);
|
||||
return $status;
|
||||
}
|
||||
|
||||
public function getServerName(): string {
|
||||
|
||||
public function getServerName(): string
|
||||
{
|
||||
$Servername = $_SERVER['SERVER_NAME'] ?? 'Unbekannt';
|
||||
|
||||
if (in_array($Servername, ['Unbekannt', '0.0.0.0', '127.0.0.1'])) {
|
||||
@@ -107,7 +128,8 @@ class getSpecificData {
|
||||
}
|
||||
}
|
||||
|
||||
public function getServerIP(): string {
|
||||
public function getServerIP(): string
|
||||
{
|
||||
$ServerIP = $_SERVER['SERVER_ADDR'] ?? 'Unbekannt';
|
||||
|
||||
if (in_array($ServerIP, ['Unbekannt', '0.0.0.0', '127.0.0.1'])) {
|
||||
@@ -116,7 +138,7 @@ class getSpecificData {
|
||||
return $ServerIP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getClientIP(): string
|
||||
{
|
||||
if (PHP_SAPI === 'cli') {
|
||||
@@ -133,13 +155,15 @@ class getSpecificData {
|
||||
return $_SERVER['REMOTE_ADDR'] ?? 'UNKNOWN';
|
||||
}
|
||||
|
||||
public function getRequestTime(): string {
|
||||
public function getRequestTime(): string
|
||||
{
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
$timestamp = $_SERVER['REQUEST_TIME'] ?? time();
|
||||
return date('Y-m-d H:i:s', $timestamp);
|
||||
}
|
||||
|
||||
function getGeoIP($ClientIP) {
|
||||
function getGeoIPOLD($ClientIP)
|
||||
{
|
||||
if (in_array($ClientIP, ['0.0.0.0', '127.0.0.1', '172.30.0.1'])) {
|
||||
return "Lokal";
|
||||
} elseif (in_array($ClientIP, ['Unbekannt', '0.0.0.0', '127.0.0.1'])) {
|
||||
@@ -147,11 +171,26 @@ class getSpecificData {
|
||||
} else {
|
||||
$response = file_get_contents("http://ip-api.com/json/{$ClientIP}?fields=country,countryCode");
|
||||
$data = json_decode($response);
|
||||
return $data->country;
|
||||
return $data->country;
|
||||
}
|
||||
}
|
||||
|
||||
function getWhitelistedIPs() {
|
||||
function getGeoIP($ClientIP)
|
||||
{
|
||||
|
||||
try {
|
||||
$reader = new Reader(__DIR__ . '/../static/GEOIP/GeoLite2-Country.mmdb');
|
||||
$record = $reader->get($ClientIP);
|
||||
$countryNameDe = $record['country']['names']['de'] ?? 'Unbekannt';
|
||||
$reader->close();
|
||||
return $countryNameDe;
|
||||
} catch (\Exception $e) {
|
||||
echo "Fehler: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
function getWhitelistedIPs()
|
||||
{
|
||||
include_once 'DatabaseController.php';
|
||||
$data = DatabaseShow(
|
||||
"Whitelisted",
|
||||
@@ -160,22 +199,23 @@ class getSpecificData {
|
||||
|
||||
$results = [];
|
||||
foreach ($data as $row) {
|
||||
$results[] =$row['IP-ADDRESSE'];
|
||||
$results[] = $row['IP-ADDRESSE'];
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
function getServerNode($ServerIP) {
|
||||
function getServerNode($ServerIP)
|
||||
{
|
||||
$nodes = [
|
||||
'node1' => '172.30.0.11',
|
||||
'node1' => '172.30.0.21',
|
||||
|
||||
'node2' => '172.30.0.12',
|
||||
'node2' => '172.30.0.22',
|
||||
|
||||
|
||||
'node3' => '172.30.0.13',
|
||||
'node3' => '172.30.0.23',
|
||||
|
||||
|
||||
'node4' => '172.30.0.14',
|
||||
'node4' => '172.30.0.24',
|
||||
'Lokal' => 'Lokal',
|
||||
@@ -186,72 +226,78 @@ class getSpecificData {
|
||||
return $node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getClientStatus($ClientIP) {
|
||||
function getClientStatus($ClientIP)
|
||||
{
|
||||
if (in_array($ClientIP, $this->getWhitelistedIPs())) {
|
||||
return "Trusted";
|
||||
}
|
||||
}
|
||||
return "Untrusted";
|
||||
}
|
||||
|
||||
function getIsAdmin(){
|
||||
function getIsAdmin()
|
||||
{
|
||||
return $_SESSION['is_admin'] ?? false;
|
||||
}
|
||||
|
||||
function getIsSuperuser(){
|
||||
|
||||
function getIsSuperuser()
|
||||
{
|
||||
return $_SESSION['is_superuser'] ?? false;
|
||||
}
|
||||
|
||||
function getUsername(){
|
||||
|
||||
function getUsername()
|
||||
{
|
||||
return $_SESSION['username'] ?? 'Gast';
|
||||
}
|
||||
|
||||
public function getAllData(): array {
|
||||
return [
|
||||
'Server - Document Root' => $this->getDocumentRoot(),
|
||||
'Server - Current Dir' => $this->getCurrentDir(),
|
||||
'Server - Name' => $this->getServerName(),
|
||||
'Server - IP' => $this->getServerIP(),
|
||||
'Server - Port' => $this->getServerPort(),
|
||||
'Server - Node' => $this->getServerNode($this->getServerIP()),
|
||||
'Server - Database' => $this->getDatabase(),
|
||||
public function getAllData(): array
|
||||
{
|
||||
return [
|
||||
'Server - Document Root' => $this->getDocumentRoot(),
|
||||
'Server - Current Dir' => $this->getCurrentDir(),
|
||||
'Server - Name' => $this->getServerName(),
|
||||
'Server - IP' => $this->getServerIP(),
|
||||
'Server - Port' => $this->getServerPort(),
|
||||
'Server - Node' => $this->getServerNode($this->getServerIP()),
|
||||
'Server - Database' => $this->getDatabase(),
|
||||
|
||||
|
||||
'Request - URL' => $this->getRequestURL(),
|
||||
'Request - Method' => $this->getRequestMethod(),
|
||||
'Request - Query' => $this->getQuery(),
|
||||
'Request - Referer' => $this->getReferer(),
|
||||
'Request - Time' => $this->getRequestTime(),
|
||||
'Request - URL' => $this->getRequestURL(),
|
||||
'Request - Method' => $this->getRequestMethod(),
|
||||
'Request - Query' => $this->getQuery(),
|
||||
'Request - Referer' => $this->getReferer(),
|
||||
'Request - Time' => $this->getRequestTime(),
|
||||
|
||||
|
||||
'Client - IP' => $this->getClientIP(),
|
||||
'Client - Port' => $this->getClientPort(),
|
||||
'Client - Country' => $this->getGeoIP($this->getClientIP()),
|
||||
'Client - User Agent' => $this->getUserAgent(),
|
||||
'Client - Cookie USER' => $this->getCookie('USER'),
|
||||
'Client - Cookie SESSSRV' => $this->getCookie('SESSSRV'),
|
||||
'Client - Session ID' => $this->getSessionID(),
|
||||
'Client - IP' => $this->getClientIP(),
|
||||
'Client - Port' => $this->getClientPort(),
|
||||
'Client - Country' => $this->getGeoIP($this->getClientIP()),
|
||||
'Client - User Agent' => $this->getUserAgent(),
|
||||
'Client - Cookie USER' => $this->getCookie('USER'),
|
||||
'Client - Cookie SESSSRV' => $this->getCookie('SESSSRV'),
|
||||
'Client - Session ID' => $this->getSessionID(),
|
||||
|
||||
|
||||
'Access - Whitelisted' => $this->getClientStatus($this->getClientIP()),
|
||||
'Access - Whitelisted IPs' => $this->getWhitelistedIPs(),
|
||||
'Access - Whitelisted' => $this->getClientStatus($this->getClientIP()),
|
||||
'Access - Whitelisted IPs' => $this->getWhitelistedIPs(),
|
||||
|
||||
|
||||
'User - Username' => $this->getUsername(),
|
||||
'User - Is Admin' => $this->getIsAdmin(),
|
||||
'User - Is Superuser' => $this->getIsSuperuser(),
|
||||
'User - Username' => $this->getUsername(),
|
||||
'User - Is Admin' => $this->getIsAdmin(),
|
||||
'User - Is Superuser' => $this->getIsSuperuser(),
|
||||
|
||||
'System - Website' => $this->getWebsite(),
|
||||
'Logging - Public' => $this->getLoggingStatus('GENERAL_PUBLIC_LOGGING')[0]['WERT'],
|
||||
'Logging - Public DEV' => $this->getLoggingStatus('DEV_PUBLIC_LOGGING')[0]['WERT'],
|
||||
'Logging - Backend' => $this->getLoggingStatus('GENERAL_BACKEND_LOGGING')[0]['WERT'],
|
||||
'Logging - Backend DEV' => $this->getLoggingStatus('DEV_BACKEND_LOGGING')[0]['WERT'],
|
||||
];
|
||||
}
|
||||
'System - Website' => $this->getWebsite(),
|
||||
'Logging - Public' => $this->getLoggingStatus('GENERAL_PUBLIC_LOGGING')[0]['WERT'],
|
||||
'Logging - Public DEV' => $this->getLoggingStatus('DEV_PUBLIC_LOGGING')[0]['WERT'],
|
||||
'Logging - Backend' => $this->getLoggingStatus('GENERAL_BACKEND_LOGGING')[0]['WERT'],
|
||||
'Logging - Backend DEV' => $this->getLoggingStatus('DEV_BACKEND_LOGGING')[0]['WERT'],
|
||||
];
|
||||
}
|
||||
|
||||
public function ShowAllData(): void {
|
||||
public function ShowAllData(): void
|
||||
{
|
||||
$SpecificData = (new getSpecificData())->getAllData();
|
||||
|
||||
echo "<pre>";
|
||||
@@ -259,8 +305,8 @@ public function getAllData(): array {
|
||||
if (is_array($value)) {
|
||||
$value = implode(', ', $value);
|
||||
}
|
||||
printf("%-22s : %s\n", $key, $value);
|
||||
printf("%-22s : %s\n", $key, $value);
|
||||
}
|
||||
echo "</pre>";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user