311,33 → 311,6 |
$cn = (!empty($row['name'])) ? $row['name'] : $user[5]; |
} |
} |
|
// Store the user @IP in a file (to test if he is still active). |
$filename = '/var/tmp/havp/current_users.txt'; |
if (file_exists($filename)) { |
$current_users_file = fopen($filename, 'r'); |
$content = file($filename); |
fclose($current_users_file); |
if (empty($content)) { |
file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL); |
} else { |
$change_me = 1; // avoid duplicate user @IP |
// if we found duplicate IP, we will not write user @IP (just set change_me = 0) |
foreach ($content as $line) { |
$line = preg_replace('/\s+/', '', $line); |
if ($line === $_SERVER['REMOTE_ADDR']) { |
$change_me = 0; |
} |
} |
// if user @IP does not exist, we write it |
if ($change_me) { |
file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL, FILE_APPEND); |
} |
} |
} else { |
// we create filename and we write user @IP. |
file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL); |
} |
} |
} |
|