mirror of
https://github.com/pgmr3/synologySsoClientExamplePage.git
synced 2025-12-13 13:35:49 +01:00
first commit
This commit is contained in:
155
client/UserInfo.php
Normal file
155
client/UserInfo.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
class UserInfo{
|
||||
|
||||
private static function get_user_agent() {
|
||||
return $_SERVER['HTTP_USER_AGENT'];
|
||||
}
|
||||
|
||||
public static function get_ip() {
|
||||
$mainIp = '';
|
||||
if (getenv('HTTP_CLIENT_IP'))
|
||||
$mainIp = getenv('HTTP_CLIENT_IP');
|
||||
else if(getenv('HTTP_X_FORWARDED_FOR'))
|
||||
$mainIp = getenv('HTTP_X_FORWARDED_FOR');
|
||||
else if(getenv('HTTP_X_FORWARDED'))
|
||||
$mainIp = getenv('HTTP_X_FORWARDED');
|
||||
else if(getenv('HTTP_FORWARDED_FOR'))
|
||||
$mainIp = getenv('HTTP_FORWARDED_FOR');
|
||||
else if(getenv('HTTP_FORWARDED'))
|
||||
$mainIp = getenv('HTTP_FORWARDED');
|
||||
else if(getenv('REMOTE_ADDR'))
|
||||
$mainIp = getenv('REMOTE_ADDR');
|
||||
else
|
||||
$mainIp = 'UNKNOWN';
|
||||
return $mainIp;
|
||||
}
|
||||
|
||||
public static function get_os() {
|
||||
|
||||
$user_agent = self::get_user_agent();
|
||||
$os_platform = "Unknown OS Platform";
|
||||
$os_array = array(
|
||||
'/windows nt 11/i' => 'Windows 11',
|
||||
'/windows nt 10/i' => 'Windows 10',
|
||||
'/windows nt 6.3/i' => 'Windows 8.1',
|
||||
'/windows nt 6.2/i' => 'Windows 8',
|
||||
'/windows nt 6.1/i' => 'Windows 7',
|
||||
'/windows nt 6.0/i' => 'Windows Vista',
|
||||
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
|
||||
'/windows nt 5.1/i' => 'Windows XP',
|
||||
'/windows xp/i' => 'Windows XP',
|
||||
'/windows nt 5.0/i' => 'Windows 2000',
|
||||
'/windows me/i' => 'Windows ME',
|
||||
'/win98/i' => 'Windows 98',
|
||||
'/win95/i' => 'Windows 95',
|
||||
'/win16/i' => 'Windows 3.11',
|
||||
'/macintosh|mac os x/i' => 'Mac OS X',
|
||||
'/mac_powerpc/i' => 'Mac OS 9',
|
||||
'/linux/i' => 'Linux',
|
||||
'/ubuntu/i' => 'Ubuntu',
|
||||
'/iphone/i' => 'iPhone',
|
||||
'/ipod/i' => 'iPod',
|
||||
'/ipad/i' => 'iPad',
|
||||
'/android/i' => 'Android',
|
||||
'/blackberry/i' => 'BlackBerry',
|
||||
'/webos/i' => 'Mobile'
|
||||
);
|
||||
|
||||
foreach ($os_array as $regex => $value) {
|
||||
if (preg_match($regex, $user_agent)) {
|
||||
$os_platform = $value;
|
||||
}
|
||||
}
|
||||
return $os_platform;
|
||||
}
|
||||
|
||||
public static function get_browser() {
|
||||
|
||||
$user_agent= self::get_user_agent();
|
||||
|
||||
$browser = "Unknown Browser";
|
||||
|
||||
$browser_array = array(
|
||||
'/msie/i' => 'Internet Explorer',
|
||||
'/Trident/i' => 'Internet Explorer',
|
||||
'/firefox/i' => 'Firefox',
|
||||
'/safari/i' => 'Safari',
|
||||
'/chrome/i' => 'Chrome',
|
||||
'/edge/i' => 'Edge',
|
||||
'/opera/i' => 'Opera',
|
||||
'/netscape/i' => 'Netscape',
|
||||
'/maxthon/i' => 'Maxthon',
|
||||
'/konqueror/i' => 'Konqueror',
|
||||
'/ubrowser/i' => 'UC Browser',
|
||||
'/mobile/i' => 'Handheld Browser'
|
||||
);
|
||||
|
||||
foreach ($browser_array as $regex => $value) {
|
||||
|
||||
if (preg_match($regex, $user_agent)) {
|
||||
$browser = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $browser;
|
||||
|
||||
}
|
||||
|
||||
public static function get_device(){
|
||||
|
||||
$tablet_browser = 0;
|
||||
$mobile_browser = 0;
|
||||
|
||||
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
|
||||
$tablet_browser++;
|
||||
}
|
||||
|
||||
if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|iemobile)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
|
||||
$mobile_browser++;
|
||||
}
|
||||
|
||||
if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
|
||||
$mobile_browser++;
|
||||
}
|
||||
|
||||
$mobile_ua = strtolower(substr(self::get_user_agent(), 0, 4));
|
||||
$mobile_agents = array(
|
||||
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
|
||||
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
|
||||
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
|
||||
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
|
||||
'newt','noki','palm','pana','pant','phil','play','port','prox',
|
||||
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
|
||||
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
|
||||
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
|
||||
'wapr','webc','winw','winw','xda ','xda-');
|
||||
|
||||
if (in_array($mobile_ua,$mobile_agents)) {
|
||||
$mobile_browser++;
|
||||
}
|
||||
|
||||
if (strpos(strtolower(self::get_user_agent()),'opera mini') > 0) {
|
||||
$mobile_browser++;
|
||||
//Check for tablets on opera mini alternative headers
|
||||
$stock_ua = strtolower(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])?$_SERVER['HTTP_X_OPERAMINI_PHONE_UA']:(isset($_SERVER['HTTP_DEVICE_STOCK_UA'])?$_SERVER['HTTP_DEVICE_STOCK_UA']:''));
|
||||
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*mobile))/i', $stock_ua)) {
|
||||
$tablet_browser++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($tablet_browser > 0) {
|
||||
// do something for tablet devices
|
||||
return 'Tablet';
|
||||
}
|
||||
else if ($mobile_browser > 0) {
|
||||
// do something for mobile devices
|
||||
return 'Mobile';
|
||||
}
|
||||
else {
|
||||
// do something for everything else
|
||||
return 'Computer';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
77
client/client.php
Normal file
77
client/client.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// © Copyright (с) 2023 License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// Author: https://github.com/pgmr3
|
||||
// ------------------------------------------------------------------------------
|
||||
//zusätzlicher Code für authorisierungs Prüfung/automatischer logout
|
||||
include_once('../check_accesstoken.php');
|
||||
if(session_status() !== PHP_SESSION_ACTIVE) $name_vorher = session_name (SESSION_NAME); //"ServerTools");
|
||||
session_start();
|
||||
if (!CheckAccesstoken() === "true") { //oder Folgezeile
|
||||
//if(!isset($_SESSION['sso_accesstoken'])) {
|
||||
echo "Verboten / Forbidden";
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<body>
|
||||
<div id="session-lifetime" >undefined</div>
|
||||
</body>
|
||||
<script src="../js/myLoginScript.js" type="text/javascript"></script>
|
||||
<script>
|
||||
window.setInterval(function () { fetchAccess(); },
|
||||
1000); //mili seconds
|
||||
</script>
|
||||
|
||||
|
||||
<?php
|
||||
//ursprünglicher code
|
||||
require('UserInfo.php');
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>UserInfo</title>
|
||||
<style>
|
||||
table {
|
||||
margin-top: 20px;
|
||||
font-family: arial, sans-serif;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td, th {
|
||||
border: 1px solid #dddddd;
|
||||
text-align: center;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
tr:nth-child(even) {
|
||||
background-color: #dddddd;
|
||||
}
|
||||
h2{font-family: sans-serif,'Helvetica';}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<center><h2>UserInfo</h2></center>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Ip</th>
|
||||
<th>Device</th>
|
||||
<th>Os</th>
|
||||
<th>Browser</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= UserInfo::get_ip();?></td>
|
||||
<td><?= UserInfo::get_device();?></td>
|
||||
<td><?= UserInfo::get_os();?></td>
|
||||
<td><?= UserInfo::get_browser();?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
50
client/index.php
Normal file
50
client/index.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// © Copyright (с) 2023 License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// Author: https://github.com/pgmr3
|
||||
// ------------------------------------------------------------------------------
|
||||
//zusätzlicher Code für authorisierungs Prüfung/automatischer logout
|
||||
include_once('../check_accesstoken.php');
|
||||
if(session_status() !== PHP_SESSION_ACTIVE) $name_vorher = session_name (SESSION_NAME); //"ServerTools");
|
||||
session_start();
|
||||
if (!CheckAccesstoken() === "true") { //oder Folgezeile
|
||||
//if(!isset($_SESSION['sso_accesstoken'])) {
|
||||
echo "Verboten / Forbidden";
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<body>
|
||||
<div id="session-lifetime" ></div>
|
||||
</body>
|
||||
<script src="../js/myLoginScript.js" type="text/javascript"></script>
|
||||
<script>
|
||||
window.setInterval(function () { fetchAccess(); },
|
||||
1000); //milliseconds
|
||||
</script>
|
||||
|
||||
|
||||
<!-- urspünglicher Code -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>phpsysinfo</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="https://github.com/pgmr3">
|
||||
<meta name="copyright" content="https://www.gnu.org/licenses/gpl-3.0.html" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="form-client">
|
||||
<h1 class="form-client-heading">Client tools</h1>
|
||||
<h2 class="form-client-heading">Please choose info 1 / info 2 / menu</h2>
|
||||
<button id="info1-button" onclick="window.location.href = '/client/client.php'">Info 1</button>
|
||||
<button id="info2-button" onclick="window.location.href = '/client/info2.php'">Info 2</button>
|
||||
<button id="menu-button" onclick="window.location.href = '/my/'" >menu</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
57
client/info2.php
Normal file
57
client/info2.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// © Copyright (с) 2023 License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
// Author: https://github.com/pgmr3
|
||||
// ------------------------------------------------------------------------------
|
||||
//zusätzlicher Code für authorisierungs Prüfung/automatischer logout
|
||||
include_once('../check_accesstoken.php');
|
||||
if(session_status() !== PHP_SESSION_ACTIVE) $name_vorher = session_name (SESSION_NAME); //"ServerTools");
|
||||
session_start();
|
||||
if (!CheckAccesstoken() === "true") { //oder Folgezeile
|
||||
//if(!isset($_SESSION['sso_accesstoken'])) {
|
||||
echo "Verboten / Forbidden";
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<body>
|
||||
<div id="session-lifetime" ></div>
|
||||
</body>
|
||||
<script src="../js/myLoginScript.js" type="text/javascript"></script>
|
||||
<script>
|
||||
window.setInterval(function () { fetchAccess(); },
|
||||
1000); //mili seconds
|
||||
</script>
|
||||
|
||||
|
||||
<?php
|
||||
//ursprünglicher code
|
||||
header("Cache-Control: no-cache, no-store");
|
||||
//OK <tr><td>X-Forwarded-For IP Address(es)</td><td>".$_SERVER['HTTP_X_FORWARDED_FOR']." </td></tr>
|
||||
if (isset( $_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$xForwarded = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
else $xForwarded = "";
|
||||
print "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">
|
||||
<tr><td align=\"center\"><strong>Attribute</strong></td><td align=\"center\"><strong>Value</strong></td></tr>
|
||||
<tr><td>IP Address (either v4 of v6)</td><td>".$_SERVER['REMOTE_ADDR']."</td></tr>
|
||||
<tr><td>Hostname</td><td>".gethostbyaddr($_SERVER['REMOTE_ADDR'])."</td></tr>
|
||||
|
||||
<tr><td>X-Forwarded-For IP Address(es)</td><td>".
|
||||
$xForwarded
|
||||
." </td></tr>
|
||||
|
||||
<tr><td>Port</td><td>".$_SERVER['REMOTE_PORT']."</td></tr>
|
||||
<tr><td>REQUEST_METHOD</td><td>".$_SERVER['REQUEST_METHOD']."</td></tr>
|
||||
<tr><td>CONTENT_TYPE</td><td>".$_SERVER['CONTENT_TYPE']."</td></tr>
|
||||
<tr><td>GATEWAY_INTERFACE</td><td>".$_SERVER['GATEWAY_INTERFACE']."</td></tr>
|
||||
|
||||
<tr><td>Browser (User Agent)</td><td>".$_SERVER['HTTP_USER_AGENT']."</td></tr>
|
||||
<tr><td>Request Time (Unixtime)</td><td>" .$_SERVER['REQUEST_TIME'] ."</td></tr>
|
||||
<tr><td>Request Time</td><td>" .date("d.m.Y H:i:s",$_SERVER['REQUEST_TIME']) ."</td></tr>
|
||||
<!--
|
||||
<tr><td>Copyright</td><td><a href=\"https://weberblog.net/small-what-is-my-ip-script-at-ip-webernetz-net/\">https://weberblog.net/small-what-is-my-ip-script-at-ip-webernetz-net/</a></td></tr>
|
||||
-->
|
||||
</table>";
|
||||
?>
|
||||
Reference in New Issue
Block a user