homepage/index.php
2023-02-20 23:23:04 +01:00

198 lines
4.4 KiB
PHP

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$domaines = array(
array(
'name' => 'Local Transfer',
'url' => '/transfer/',
'img' => 'favicon_transfer.png'
),
array(
'name' => 'Emby',
'url' => 'https://emby.netdldata.net/',
'real' => 'emby.lan',
'port' => 8096,
'img' => 'favicon_emby.png'
),
array(
'name' => 'Nextcloud',
'url' => 'https://cloud.netdldata.net/',
'real' => 'nextcloud.lan',
'port' => 443,
'img' => 'favicon_Nextcloud.svg'
),
array(
'name' => 'Orion',
'url' => 'https://orion.netdldata.net/',
'real' => 'orion.lan',
'port' => 80,
'img' => 'favicon_omv.png'
),
array(
'name' => 'Gitea',
'url' => 'https://git.netdldata.net',
'real' => 'git.lan',
'port' => 3000,
'img' => 'favicon-gitea.png'
),
array(
'name' => 'qBittorrent',
'url' => 'https://torrent.netdldata.net',
'real' => 'torrent.lan',
'port' => 8080,
'img' => 'qbittorrent-tray.svg'
),
array(
'name' => 'Webmin',
'url' => 'https://webmin.netdldata.net',
'real' => '192.168.110.74',
'port' => 10000,
'img' => 'favicon_webmin.png'
),
array(
'name' => 'Proxmox',
'url' => 'https://proxmox.netdldata.net',
'real' => 'proxmox.lan',
'port' => 8006,
'img' => 'favicon_proxmox.png'
),
array(
'name' => 'Guacamole',
'url' => 'https://guacamole.netdldata.net',
'real' => 'guacamole.lan',
'port' => 8080,
'img' => 'favicon_guacamole.png'
),
array(
'name' => 'Mail',
'url' => 'https://mail.netdldata.net',
'real' => 'mail.lan',
'port' => 80,
'img' => 'favicon_roundcube.svg'
),
);
if (isset($_COOKIE['socket'])) {
$domaines = unserialize($_COOKIE['socket']);
}
else {
for ($i = 0; $i < sizeof($domaines); $i ++) {
if(array_key_exists('real', $domaines[$i])){
#$domaines[$i]['host'] = gethostbyname($domaines[$i]['real']);
$fp = @fsockopen($domaines[$i]['real'], $domaines[$i]['port'], $errno, $errstr, 0.1);
if ($fp) {
$domaines[$i]['running'] = true;
}
else {
$domaines[$i]['running'] = false;
}
}
}
}
$cookie = serialize($domaines);
$temps = 60*60*2; //2 heures
setcookie ("socket", $cookie, time() + $temps);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<link rel="stylesheet" type="text/css" href="styles/Style.css">
<link rel="icon" href="images/majalis.png" />
<script src="js/jquery-3.4.1.js"></script>
<head>
<title>NetDLData</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
</head>
<body>
<div class="titre">
<h2>Sites NetDLData</h2>
<button class="reload" id="reload" type="button" onclick="cookies()"><img src="images/cloud-reload.png"></button>
</div>
<div id="buttons"></div>
<?php
echo "<br><br>".$_SERVER['HTTP_USER_AGENT'];
#$browser = get_browser(null, true);
#echo "<br><br>You use navigator ".$browser["browser"];
#echo "<br>By ".$browser["browser_maker"];
#echo "<br>In Version ".$browser["version"];
#echo "<br>On system ".$browser["platform"];
#echo "<br>Your IP is ".$_SERVER['REMOTE_ADDR'];
?>
<script type="text/javascript">
var servers = <?php echo json_encode($domaines); ?>;
console.log(servers);
var orientation_etat = true;
for (var key in servers) {
orientation_etat = !orientation_etat;
var server = servers[key];
var div = $('<div />', {
class: 'button ' + orientation(orientation_etat)
});
var button = $('<button />', {
class: 'server',
type: 'button',
onclick: 'site("' + server.url + '")',
html: '<img class="favicon" src="images/' + server.img + '"><div class="description">' + server.name + '</div>'
});
div.append(button);
$("#buttons").append(div);
if (server.hasOwnProperty('running')){
if (server.running) {
button.addClass('allumer');
}
else
button.prop("disabled",true);
}
else
button.addClass('allumer');
}
function cookies() {
document.getElementById("reload").style.cursor = "wait";
document.body.style.cursor = "wait";
var path = document.location.pathname;
document.cookie = "socket=; expires=Thu, 01 Jan 1970 00:00:00 UTC;";
window.location.href = path;
}
function site(url) {
console.log(url);
document.location.href=url;
}
function orientation (status) {
if (status == false)
return "left";
else
return "right";
};
</script>
</body>
</html>