diff options
author | Warren Baker <warren@decoy.co.za> | 2011-05-16 16:25:32 +0200 |
---|---|---|
committer | Warren Baker <warren@decoy.co.za> | 2011-05-16 16:25:32 +0200 |
commit | 9cd7285680eee801ce8b4cc26621c0cf0e0d4505 (patch) | |
tree | d15dcad8bfbb55cfc0628322e73b54fc82e8a1ac /usr/local/bin | |
parent | 24fa000b3803abe22e2234d3e04d59cd64eb5546 (diff) | |
download | pfsense-9cd7285680eee801ce8b4cc26621c0cf0e0d4505.zip pfsense-9cd7285680eee801ce8b4cc26621c0cf0e0d4505.tar.gz |
Ensure that $timestamp is only ever written out if it contains a value and let file be retained through reboots.
Diffstat (limited to 'usr/local/bin')
-rw-r--r-- | usr/local/bin/captiveportal_gather_stats.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/usr/local/bin/captiveportal_gather_stats.php b/usr/local/bin/captiveportal_gather_stats.php index 5fe1c6b..823b28f 100644 --- a/usr/local/bin/captiveportal_gather_stats.php +++ b/usr/local/bin/captiveportal_gather_stats.php @@ -43,7 +43,7 @@ $concurrent_users = $no_users; $current_user_count = 0; /* tmp file to use to store old data (per interface)*/ -$tmpfile = "{$g['tmp_path']}/captiveportal_online_users"; +$tmpfile = "{$g['vardb_path']}/captiveportal_online_users"; $type = $argv[1]; @@ -82,12 +82,14 @@ if ($type == "loggedin") { $current_user_count = $current_user_count + 1; } - // Write out the latest timestamp - $fd = @fopen($tmpfile, "w"); - if ($fd) { - fwrite($fd, $timestamp); + // Write out the latest timestamp but not if it is empty + if (!empty($timestamp)) { + $fd = @fopen($tmpfile, "w"); + if ($fd) { + fwrite($fd, $timestamp); + } + @fclose($fd); } - @fclose($fd); /* If $timestamp is less than or equal to previous_user_timestamp return 0, * as we only want the 'X' number of users logged in since last RRD poll. |