Online check
This commit is contained in:
parent
668c33856b
commit
0c2b20ab91
|
@ -271,7 +271,6 @@ CREATE TABLE IF NOT EXISTS `".$prefix."_profiles` (
|
||||||
`telefono` varchar(25) DEFAULT NULL,
|
`telefono` varchar(25) DEFAULT NULL,
|
||||||
`services` int(11) NOT NULL DEFAULT 0,
|
`services` int(11) NOT NULL DEFAULT 0,
|
||||||
`trainings` int(11) NOT NULL DEFAULT 0,
|
`trainings` int(11) NOT NULL DEFAULT 0,
|
||||||
`online` tinyint(1) NOT NULL DEFAULT 0,
|
|
||||||
`online_time` int(11) NOT NULL DEFAULT 0,
|
`online_time` int(11) NOT NULL DEFAULT 0,
|
||||||
`minuti_dispo` int(11) NOT NULL DEFAULT 0,
|
`minuti_dispo` int(11) NOT NULL DEFAULT 0,
|
||||||
`immagine` varchar(1000) DEFAULT NULL,
|
`immagine` varchar(1000) DEFAULT NULL,
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
<?php
|
|
||||||
include_once 'core.php';
|
|
||||||
init_class();
|
|
||||||
if(isset($_SESSION)){
|
|
||||||
$user = $user->name();
|
|
||||||
} else {
|
|
||||||
$user = "test";
|
|
||||||
}
|
|
||||||
$string = <<<EOT
|
|
||||||
<script>
|
|
||||||
ciao = 0;
|
|
||||||
function onLine() {
|
|
||||||
ciao = ciao + 1;
|
|
||||||
console.log(ciao);
|
|
||||||
console.log("onLine");
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
xhr.open('GET', 'http://62.171.139.86/allerta/online_check.php?user=$user');
|
|
||||||
xhr.onload = function () {
|
|
||||||
if (xhr.status === 200) {
|
|
||||||
console.log('Text ' + xhr.responseText);
|
|
||||||
} else {
|
|
||||||
console.log('Request failed. Returned status of ' + xhr.status);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function offLine() {
|
|
||||||
console.log("offLine");
|
|
||||||
}
|
|
||||||
|
|
||||||
function check() {
|
|
||||||
console.log("dfcghfhdt");
|
|
||||||
var i = new Image();
|
|
||||||
i.onload = onLine;
|
|
||||||
i.onerror = offLine;
|
|
||||||
i.src = 'https://www.google-analytics.com/__utm.gif';
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
EOT;
|
|
||||||
echo($string);
|
|
|
@ -1,22 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
error_reporting(1);
|
require 'core.php';
|
||||||
$start = true;
|
|
||||||
$minuti = date('i');
|
|
||||||
|
|
||||||
include_once 'core.php';
|
|
||||||
|
|
||||||
init_class();
|
init_class();
|
||||||
|
$user->requirelogin();
|
||||||
|
$id = $user->auth->getUserId();
|
||||||
|
$time = time();
|
||||||
|
|
||||||
$sql = "SELECT name, online, online_time FROM `%PREFIX%_profiles`";
|
if(!is_null($id)){
|
||||||
$risultato = $database->exec($sql, true);
|
$sql = "UPDATE `%PREFIX%_profiles` SET online_time = '$time' WHERE id = '" . $id ."'";
|
||||||
var_dump($risultato);
|
|
||||||
foreach($risultato as $row){
|
|
||||||
print("<pre>" . print_r($row, true) . "</pre>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($_GET) && !is_null($_GET['user'])){
|
|
||||||
$sql = "UPDATE `%PREFIX%_profiles` SET online = '1', online_time = '$minuti' WHERE name = '" . urldecode($_GET['user']) . "'";
|
|
||||||
$risultato = $database->exec($sql, true);
|
$risultato = $database->exec($sql, true);
|
||||||
var_dump($risultato);
|
echo(json_encode(["id" => $id, "time" => $time, "sql" => $sql]));
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
error_reporting(1);
|
|
||||||
$start = true;
|
|
||||||
$minuti = date('i');
|
|
||||||
include_once 'core.php';
|
|
||||||
|
|
||||||
init_class();
|
|
||||||
|
|
||||||
$minuti = date('i');
|
|
||||||
$sql = "UPDATE `%PREFIX%_users` SET online='0', online_time='0' WHERE online_time < '$minuti';";
|
|
||||||
$risultato = $database->exec($sql);
|
|
||||||
echo $sql;
|
|
||||||
?>
|
|
|
@ -47,7 +47,7 @@ th, td {
|
||||||
if(!in_array($row['name'], $hidden) && ($row['hidden'] == 0 && $row['disabled'] == 0)){
|
if(!in_array($row['name'], $hidden) && ($row['hidden'] == 0 && $row['disabled'] == 0)){
|
||||||
echo "<tr><td>";
|
echo "<tr><td>";
|
||||||
if ($row['caposquadra'] == 1) {echo "<img src='./risorse/images/cascoRosso.png' width='20px'> ";} else{echo "<img src='./risorse/images/cascoNero.png' width='20px'> ";}
|
if ($row['caposquadra'] == 1) {echo "<img src='./risorse/images/cascoRosso.png' width='20px'> ";} else{echo "<img src='./risorse/images/cascoNero.png' width='20px'> ";}
|
||||||
if($row['online'] == 1){
|
if((time()-$row["online_time"])<=30){
|
||||||
echo "<u>".$user->nameById($row["id"])."</u></td><td>";
|
echo "<u>".$user->nameById($row["id"])."</u></td><td>";
|
||||||
} else {
|
} else {
|
||||||
echo "".$user->nameById($row["id"])."</td><td>";
|
echo "".$user->nameById($row["id"])."</td><td>";
|
||||||
|
|
|
@ -59,7 +59,7 @@ th, td {
|
||||||
} else {
|
} else {
|
||||||
echo "<a onclick='Attivo(".$row["id"].");'><img src='./risorse/images/cascoNero.png' width='20px'> ";
|
echo "<a onclick='Attivo(".$row["id"].");'><img src='./risorse/images/cascoNero.png' width='20px'> ";
|
||||||
}
|
}
|
||||||
if($row['online'] == 1){
|
if((time()-$row["online_time"])<=30){
|
||||||
echo "<u>".$name."</u></a></td><td><a onclick='$callFunction(".$row["id"].");'>";
|
echo "<u>".$name."</u></a></td><td><a onclick='$callFunction(".$row["id"].");'>";
|
||||||
} else {
|
} else {
|
||||||
echo $name."</a></td><td><a onclick='$callFunction(".$row["id"].");'>";
|
echo $name."</a></td><td><a onclick='$callFunction(".$row["id"].");'>";
|
||||||
|
|
|
@ -261,7 +261,7 @@
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
/* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */
|
/* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */
|
||||||
function myFunction() {
|
function menu() {
|
||||||
var x = document.getElementById("myTopnav");
|
var x = document.getElementById("myTopnav");
|
||||||
//var z = document.getElementById("logout");
|
//var z = document.getElementById("logout");
|
||||||
if (x.className === "topnav") {
|
if (x.className === "topnav") {
|
||||||
|
@ -301,13 +301,9 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
ciao = 0;
|
function check() {
|
||||||
function onLine() {
|
|
||||||
ciao = ciao + 1;
|
|
||||||
console.log(ciao);
|
|
||||||
console.log("onLine");
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', '{{ urlsoftware }}online_check.php?user={{ user.name }}');
|
xhr.open('GET', '{{ urlsoftware }}online_check.php');
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
if (xhr.status === 200) {
|
if (xhr.status === 200) {
|
||||||
console.log('Text ' + xhr.responseText);
|
console.log('Text ' + xhr.responseText);
|
||||||
|
@ -318,21 +314,10 @@
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function offLine() {
|
|
||||||
console.log("offLine");
|
|
||||||
}
|
|
||||||
|
|
||||||
function check() {
|
|
||||||
var i = new Image();
|
|
||||||
i.onload = onLine;
|
|
||||||
i.onerror = offLine;
|
|
||||||
i.src = 'https://www.google-analytics.com/__utm.gif';
|
|
||||||
}
|
|
||||||
|
|
||||||
check();
|
check();
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
check();
|
check();
|
||||||
}, 10000);
|
}, 30000);
|
||||||
</script>
|
</script>
|
||||||
{% block menu %}
|
{% block menu %}
|
||||||
<!-- Menu -->
|
<!-- Menu -->
|
||||||
|
@ -344,7 +329,7 @@
|
||||||
<a {# href="{{ urlsoftware }}grafici.php" #}>{{ 'Graphics'|t }}</a>
|
<a {# href="{{ urlsoftware }}grafici.php" #}>{{ 'Graphics'|t }}</a>
|
||||||
{% if enable_technical_support %}<a href="javascript:void(0);" onclick="chat()">{{ 'Technical Support' }}</a>{% endif %}
|
{% if enable_technical_support %}<a href="javascript:void(0);" onclick="chat()">{{ 'Technical Support' }}</a>{% endif %}
|
||||||
<a style="float: right;" id="logout">{{ 'Hi, %s.'|t|format(user.name) }} <b onclick="location.href='{{ urlsoftware }}logout.php';">{{ 'Logout'|t }}</b></a>
|
<a style="float: right;" id="logout">{{ 'Hi, %s.'|t|format(user.name) }} <b onclick="location.href='{{ urlsoftware }}logout.php';">{{ 'Logout'|t }}</b></a>
|
||||||
<a href="javascript:void(0);" class="icon" onclick="myFunction()">☰</a>
|
<a href="javascript:void(0);" class="icon" onclick="menu()">☰</a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /Menu -->
|
<!-- /Menu -->
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue