/**
* Retrieve GeoIP data
*/
-$geo = $info->getGeoIPCity();
-if (empty($geo[1])) {
- $geo = False;
+if (function_exists("geoip_record_by_name")) {
+ $geo = $info->getGeoIPCity();
+ if (empty($geo[1])) {
+ $geo = False;
+ }
+} else {
+ $geo = False;
}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Deine IP — ip.malte70.de</title>
+ <title>Deine IP (powered by Windows 98) <?=$AppInfo["TitleSeparator"]?> <?=$AppInfo["Name"]?></title>
<meta name="author" content="Malte Bublitz">
+ <meta name="robots" content="noindex">
<?php foreach ($Data["Stylesheet"] as $css): ?>
<link rel="stylesheet" type="text/css" href="<?=$css?>">
<?php endforeach; ?>
--- /dev/null
+<?php
+/**
+ * API Documentation
+ *
+ * Parse Markdown from `API.md` to HTML and
+ * embed it in a small page layout.
+ */
+
+//ini_set("error_reporting", True);
+//error_reporting(E_ALL & ~E_DEPRECATED);
+
+require_once("config.inc.php");
+require_once("../lib/Markdown2HTML.php");
+
+$md2html = new Markdown2HTML();
+$md2html->setFilename("API.md");
+if (!$md2html->getFileExists()) {
+ header("HTTP/1.0 404 Not Found");
+} elseif (!$md2html->getFileReadable()) {
+ header("HTTP/1.0 403 Forbidden");
+}
+$md2html->getMarkdown();
+$md2html->parseMarkdown();
+
+/**
+ * DEBUG: Only show parsed Markdown
+ * served as text/plain
+ */
+if ((is_bool(@$_GET["debug"]) && @$_GET["debug"]) || in_array(strtolower(@$_GET["debug"]), array("true","yes","1"))) {
+ header("Content-Type:text/plain; charset=UTF-8");
+ die($md2html->getHTML());
+}
+
+$css = "markdown.css";
+
+$title = "API " . $AppInfo["TitleSeparator"] . " " . $AppInfo["Name"];
+
+// store locale
+$originalLocales = explode(";", setlocale(LC_ALL, 0));
+//setlocale(LC_ALL, "de_DE.utf8");
+
+$mtime = filemtime($md2html->getFilename());
+// date is always English, but strftime is localized.
+// Note: Using RFC 2822 format
+//$mtime = date("r", $mtime);
+$mtime = strftime("%a, %d %b %Y %T %z", $mtime);
+
+// restore locale
+/*
+foreach ($originalLocales as $localeSetting) {
+ if (strpos($localeSetting, "=") !== false) {
+ list ($category, $locale) = explode("=", $localeSetting);
+ }
+ else {
+ $category = LC_ALL;
+ $locale = $localeSetting;
+ }
+ setlocale($category, $locale);
+}*/
+
+
+$Data = Array(
+ "Filename" => $filename,
+ "Title" => $title,
+ "Headline" => '<a href="' . $filename . '" download>' . $md2html->getHeadline() . '</a>',
+ "ParsedMarkdown" => $md2html->getHTML(),
+ "Stylesheet" => "//xyz.malte70.de/css/".$css,
+ "Favicon" => "https://xyz.malte70.de/img/icons_tango/floppy-512.png",
+ "FaviconSize" => "512x512",
+ "Footer" => "<a href=\"$filename\" download>$filename</a> · Last modified: $mtime",
+);
+
+?><!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
+ <title><?=$Data["Title"]?></title>
+
+ <link rel="icon" type="image/png" sizes="128x128" href="/assets/img/favicon.png">
+ <link rel="stylesheet" href="<?=$Data["Stylesheet"]?>">
+ </head>
+ <body>
+ <header>
+ <h1>
+ <?=$Data["Headline"]?>
+ </h1>
+ </header>
+
+ <main>
+ <section id="markdown">
+<?=$Data["ParsedMarkdown"]?>
+ </section>
+ </main>
+<?php if (!empty($Data["Footer"])): ?>
+
+ <footer>
+ <p>
+ <?=$Data["Footer"]?>
+ </p>
+ </footer>
+<?php endif; ?>
+ </body>
+</html>
break;
case "country":
- print $info->getGeoIPCountry();
+ print function_exists("geoip_record_by_name") ? $info->getGeoIPCountry() : "Error: API method not available!";
break;
case "region_code":
+ if (!function_exists("geoip_record_by_name")) {
+ print "Error: API method not available!";
+ http_response_code(405);
+ break;
+ }
$region = $info->getGeoIPRegion();
if (is_array($region))
print $region[0];
break;
case "region":
+ if (!function_exists("geoip_record_by_name")) {
+ print "Error: API method not available!";
+ http_response_code(405);
+ break;
+ }
$region = $info->getGeoIPRegion();
if (is_array($region))
print $region[1];
break;
case "city":
+ if (!function_exists("geoip_record_by_name")) {
+ print "Error: API method not available!";
+ http_response_code(405);
+ break;
+ }
$city = $info->getGeoIPCity();
if ($city)
print $city[0];
case "zip":
case "postal_code":
+ if (!function_exists("geoip_record_by_name")) {
+ print "Error: API method not available!";
+ http_response_code(405);
+ break;
+ }
$city = $info->getGeoIPCity();
if ($city)
print $city[1];
case "coordinates":
case "gps":
+ if (!function_exists("geoip_record_by_name")) {
+ print "Error: API method not available!";
+ http_response_code(405);
+ break;
+ }
$city = $info->getGeoIPCity();
if ($city)
print $city[2][0] . " " . $city[2][1];
break;
case "latitude":
+ if (!function_exists("geoip_record_by_name")) {
+ print "Error: API method not available!";
+ http_response_code(405);
+ break;
+ }
$city = $info->getGeoIPCity();
if ($city)
print $city[2][0];
break;
case "longitude":
+ if (!function_exists("geoip_record_by_name")) {
+ print "Error: API method not available!";
+ http_response_code(405);
+ break;
+ }
$city = $info->getGeoIPCity();
if ($city)
print $city[2][1];
}
-?>
\ No newline at end of file
+?>
)
);
- $this->OS .= " " . implode($version, ".");
+ $this->OS .= " " . implode(".", $version);
} elseif (stripos($ua, "iPhone") !== false) {
$this->OS = "iOS";
)
);
- $this->OS .= " " . implode($version, ".");
+ $this->OS .= " " . implode(".", $version);
} elseif (stripos($ua, "Macintosh") !== false) {
$this->OS = "Apple OS X";
)
);
- $this->OS .= " " . implode($version, ".");
+ $this->OS .= " " . implode(".", $version);
+
} else {
$this->OS = $fallback;
*/
$AppInfo = Array(
"Name" => "ip.malte70.de",
+ //"TitleSeparator" => "::",
+ "TitleSeparator" => "|",
+ //"TitleSeparator" => "-",
"URL" => "https://github.com/projekt-ancistrus/ipinfo",
"Copyright" => Array(
"Year" => "2016-".date("Y"),
),
);
+
+/**
+ * Enable debugging mode if "debug" GET parameter is
+ * set.
+ */
@$debug = in_array(
strtolower($_GET["debug"]),
Array(
ini_set("display_errors", "On");
}
-?>
\ No newline at end of file
+
+/**
+ * Autoloading for composer packages
+ */
+require __DIR__ . '/vendor/autoload.php';
+
+?>
$footerData = Array(
"© " . $AppInfo["Copyright"]["Year"] . ' <a href="' . $AppInfo["Copyright"]["AuthorLink"] . '" rel="me nofollow">' . $AppInfo["Copyright"]["AuthorName"] . '</a>',
'Powered by <a href="' . $AppInfo["URL"] . '">' . $AppInfo["Name"] . '</a>',
- '<a href="API.md">API</a>'
+ '<a href="api-doc.php">API</a>'
);
$lang = substr(
2
);
if ($lang == "de") {
- $msg_your_ip = "Deine IP–Adresse";
+ $msg_your_ip = "Deine IP-Adresse";
} else {
- $msg_your_ip = "Your IP";
+ $msg_your_ip = "Your IP Address";
}
$Data = Array(
"Meta" => Array(
"Lang" => $lang,
"Charset" => "UTF-8",
- "Title" => $msg_your_ip . " :: " . $AppInfo["Name"],
+ "Title" => $msg_your_ip." ".$AppInfo["TitleSeparator"]." ".$AppInfo["Name"],
"Author" => "Malte Bublitz",
"HumansTXT" => false,
"Stylesheet" => "assets/css/style.css"
require_once("template.inc.php");
}
-?>
\ No newline at end of file
+?>
$is_ipv6 = $info->isIPv6();
$Translations = Array(
"de" => Array(
- "Title" => "Deine IP",
+ "Title" => "Deine IP/Browserkennung",
"IP" => "IP-Adresse" . ($is_ipv6 ? " (IPv6)" : " (IPv4)"),
"IPv4" => "IP-Adresse (IPv4)",
"IPv6" => "IP-Adresse (IPv6)",
"Loc" => "Ort"
),
"en" => Array(
- "Title" => "Your IP",
+ "Title" => "Your IP and User-agent",
"IP" => "IP Address" . ($is_ipv6 ? " (IPv6)" : " (IPv4)"),
"IPv4" => "IP Address (IPv4)",
"IPv6" => "IP Address (IPv6)",
<?=$info->getOS()?> (<?=getMsg($lang, "Lang")?>: <?=$info->getLanguage()?>)
</p>
<?php
-if ($debug) {
- print '<pre>';
- print "\$info->getGeoIPCountry() = " . $info->getGeoIPCountry() . "\n";
- print "\n\$info->getGeoIPCity() = ";
- print_r($info->getGeoIPCity());
- print '</pre>';
-}
-if (!empty($info->getGeoIPCity()[0])) {
- $coord = Array(
- number_format($info->getGeoIPCity()[2][0], 4, ".", ""),
- number_format($info->getGeoIPCity()[2][1], 4, ".", "")
- );
+/**
+ * Verify that GeoIP is available, which is not the case
+ * after I updated the server from Ubuntu 20.04 to 22.04 !!!
+ */
+if (function_exists("geoip_record_by_name")) {
+
+ if ($debug) {
+ print '<pre>';
+ print "\$info->getGeoIPCountry() = " . $info->getGeoIPCountry() . "\n";
+
+ print "\n\$info->getGeoIPCity() = ";
+ print_r($info->getGeoIPCity());
+ print '</pre>';
+ }
+ if (!empty($info->getGeoIPCity()[0])) {
+ $coord = Array(
+ number_format($info->getGeoIPCity()[2][0], 4, ".", ""),
+ number_format($info->getGeoIPCity()[2][1], 4, ".", "")
+ );
?>
<h3><?=getMsg($lang, "Loc")?></h3>
<p class="info" id="location">
<?=$info->getGeoIPCity()[0]?>, <?=$info->getGeoIPCountry()?>
</p>
-<?php } ?>
+<?php
+ }
+
+} // GeoIP functions available
+?>
<h3><?=getMsg($lang, "UA")?></h3>
<p class="info" id="user-agent">
<?=$info->getUserAgent()?>
$footerData = Array(
"© " . $AppInfo["Copyright"]["Year"] . ' <a href="' . $AppInfo["Copyright"]["AuthorLink"] . '" rel="me nofollow">' . $AppInfo["Copyright"]["AuthorName"] . '</a>',
'Powered by <a href="' . $AppInfo["URL"] . '">' . $AppInfo["Name"] . '</a>',
- '<a href="API.md">API</a>'
+ '<a href="api-doc.php">API</a>'
);
$Data = Array(
"Meta" => Array(
"Lang" => $lang,
"Charset" => "UTF-8",
- "Title" => getMsg($lang, "Title") . " :: " . $AppInfo["Name"],
+ "Title" => getMsg($lang, "Title")." ".$AppInfo["TitleSeparator"]." ".$AppInfo["Name"],
"Author" => "Malte Bublitz",
"HumansTXT" => false,
"Stylesheet" => "assets/css/style.css"
--- /dev/null
+# robotstxt.org/
+
+User-agent: *
+Disallow: /98.php
+
+User-agent: *
+Disallow: /api-doc.php
+
+User-agent: *
+Disallow: /api.php
+
+User-agent: *
+Disallow: /assets
+
+User-agent: *
+Disallow: /widget.php
$text_color,
$WidgetConfig["FontFamily"],
$info->getIP()
+ //$info->getIP()=="188.136.91.26" ? "203.0.113.42" : $info->getIP()
);