Replaced online check

This commit is contained in:
Matteo Gheza 2020-11-14 15:25:24 +01:00
parent 2e3cb18560
commit 51df554065
9 changed files with 16 additions and 57 deletions

View File

@ -657,6 +657,16 @@ class user
$this->log("User removed", null, $removed_by, date("d/m/Y"), date("H:i.s"));
$this->tools->profiler_stop();
}
public function online_time_update($id=null){
$this->tools->profiler_start("Update online timestamp");
if(is_null($id)) $id = $this->auth->getUserId();
$time = time();
$sql = "UPDATE `%PREFIX%_profiles` SET online_time = '$time' WHERE id = '" . $id ."'";
$this->database->exec($sql, true);
bdump(["id" => $id, "time" => $time]);
$this->tools->profiler_stop();
}
}
class translations

View File

@ -2,6 +2,7 @@
include_once '../../core.php';
init_class();
$user->requirelogin(false);
$user->online_time_update();
if(isset($_POST["change_id"]) && $_POST["dispo"] == 1 && $_POST["token_list"] == $_SESSION['token_list']){
$risultato = $database->exec("UPDATE `%PREFIX%_profiles` SET `available` = '1' WHERE `%PREFIX%_profiles`.`id` = :id;", false, [":id" => $_POST["change_id"]]);
$user->log("Attivazione disponibilita'", $_POST["change_id"], $user->auth->getUserId(), date("d/m/Y"), date("H:i.s"));

View File

@ -1,36 +0,0 @@
<?php
$start = true;
$minutes = 5;
include_once "../../core.php";
init_class();
$user->requirelogin(false);
function arraynum(){
global $database;
$risultato = $database->exec("SELECT * FROM `%PREFIX%_profiles` ORDER BY available DESC, chief DESC, services ASC, name ASC", true);
$incremento = array();
$availability_minutes_old = array();
foreach($risultato as $row){
if($row['available'] == "1"){
$incremento[] = $row['name'];
$availability_minutes_old[] = $row['availability_minutes'];
}
}
return $incremento;
}
if(!isset($_GET['name'])){
print_r(arraynum());
} else {
if(isset($_GET['name'])){
$arr = arraynum();
$name = str_replace("_", " ", $_GET['name']);
if(in_array($name, $arr)){
echo "si";
} else {
echo "no";
}
}
}
?>

View File

@ -2,6 +2,7 @@
include_once("../../core.php");
init_class();
$user->requirelogin(false);
$user->online_time_update();
$risultato = $database->exec("SELECT * FROM `%PREFIX%_profiles` ORDER BY available DESC, chief DESC, services ASC, availability_minutes ASC, name ASC;", true);

View File

@ -2,6 +2,7 @@
include_once("../../core.php");
init_class();
$user->requirelogin(false);
$user->online_time_update();
$risultato = $database->exec("SELECT * FROM `%PREFIX%_log` ORDER BY `date` DESC, `time` DESC", true);

View File

@ -2,6 +2,7 @@
include_once("../../core.php");
init_class();
$user->requirelogin(false);
$user->online_time_update();
$risultato = $database->exec("SELECT * FROM `%PREFIX%_services` ORDER BY data DESC, uscita DESC", true);

View File

@ -2,6 +2,7 @@
include_once("../../core.php");
init_class();
$user->requirelogin(false);
$user->online_time_update();
$risultato = $database->exec("SELECT * FROM `%PREFIX%_trainings` ORDER BY data DESC, inizio desc", true);

View File

@ -3,6 +3,7 @@
include_once("../../core.php");
init_class();
$user->requirelogin(false);
$user->online_time_update();
$risultato = $database->exec('SELECT * FROM `%PREFIX%_profiles` WHERE id = :id', true, array(":id" => $_GET['user'])); // Pesco i dati della table

View File

@ -313,27 +313,6 @@
I agree
</button>
</div>
{% if user.autenticated %}
<script>
function check() {
var xhr = new XMLHttpRequest();
xhr.open('GET', '{{ urlsoftware }}online_check.php');
xhr.onload = function () {
if (xhr.status === 200) {
console.log('Text ' + xhr.responseText);
} else {
console.log('Request failed. Returned status of ' + xhr.status);
}
};
xhr.send();
}
//check();
/* setInterval(function() {
check();
}, 30000); */
</script>
{% endif %}
{% block menu %}
<!-- Menu -->
<div class="topnav" id="myTopnav">