Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2111 → Rev 2112

/web/js/statusControler.js
236,26 → 236,3
setTimeout('chilliController.refresh()', 1500);
}
 
// The event window.onbeforeunload doesn't work with some browsers like 'opera' or 'Safari'.
// In the next version of alcasar, 30' without the status window do an automatic logout.
/*
var alcasarOnbeforeUnload = window.onbeforeunload;
 
window.onbeforeunload = function(){
if (alcasarOnbeforeUnload)
alcasarOnbeforeUnload();
alcasarLogoff();
}
*/
 
// The event window.onbeforeunload doesn't work with some browsers like 'opera' or 'Safari'.
window.onbeforeunload = function(){
alcasarLogoff();
//on annule la fonction alcasarLogoff pour ne pas avoir une deuxième requette sur onunload
alcasarLogoff = function(){}
}
// Opera doesn't fire the unload event when you navigate Back and Forward or close the window. It does when you click on a link.
window.onunload = function(){
//la fonction quelque chose uniquement si onbeforeunload n'est pas executée
alcasarLogoff();
}
/web/still_connected.php
1,23 → 1,22
<?php
 
//store in a file user @IP who can join this page.
//store user @IP who can join this page (still have their status.php tab open) in a file.
$filename='/var/tmp/havp/current_users.txt';
//change me avoid duplicate user @IP
$change_me = 1;
 
//check if filename exists
//check if file exists
if(file_exists($filename)){
$fichier = fopen($filename, "r");
$content = file($filename);
 
//if file is empty, we put user @IP in it.
$current_users_file = fopen($filename, "r");
$content = file($filename);
fclose($current_users_file);
// if file is empty, we put user @IP in it.
if(empty($content))
{
file_put_contents($filename, $_SERVER['REMOTE_ADDR']);
file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL);
}
else
{
//if we found duplicate IP, it will not write user @IP in filename (set change_me = 0)
// if we found duplicate user IP, it will not be writen again
foreach($content as $line){
$line = preg_replace('/\s+/', '', $line);
if($line == $_SERVER['REMOTE_ADDR'])
24,21 → 23,17
{
$change_me = 0;
}
 
}
 
//if user @IP does not exist, we will write it in filename
// else we write user IP in the file
if($change_me)
{
file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL , FILE_APPEND);
}
}
 
}
else
{
//we create filename and we put user @IP in it.
//The file doesn't exist. We create it and write user @IP.
file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL);
}
 
?>