Subversion Repositories ALCASAR

Rev

Rev 2377 | Rev 2413 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log

Rev 2377 Rev 2394
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: status.php 2377 2017-08-16 18:51:18Z tom.houdayer $
2
# $Id: status.php 2394 2017-08-27 13:28:59Z tom.houdayer $
3
#
3
#
4
# status.php for ALCASAR captive portal
4
# status.php for ALCASAR captive portal
5
# by steweb57 & Rexy
5
# by steweb57 & Rexy
6
# 
6
# 
7
/****************************************************************
7
/****************************************************************
Line 309... Line 309...
309
			if ($res) {
309
			if ($res) {
310
				$row = @da_sql_fetch_array($res,$config);
310
				$row = @da_sql_fetch_array($res,$config);
311
				$cn = (!empty($row['name'])) ? $row['name'] : $user[5];
311
				$cn = (!empty($row['name'])) ? $row['name'] : $user[5];
312
			}
312
			}
313
		}
313
		}
314
 
-
 
315
		// Store the user @IP in a file (to test if he is still active).
-
 
316
		$filename = '/var/tmp/havp/current_users.txt';
-
 
317
		if (file_exists($filename)) {
-
 
318
			$current_users_file = fopen($filename, 'r');
-
 
319
			$content = file($filename);
-
 
320
			fclose($current_users_file);
-
 
321
			if (empty($content)) {
-
 
322
				file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL);
-
 
323
			} else {
-
 
324
				$change_me = 1; // avoid duplicate user @IP
-
 
325
				// if we found duplicate IP, we will not write user @IP (just set change_me = 0)
-
 
326
				foreach ($content as $line) {
-
 
327
				        $line = preg_replace('/\s+/', '', $line);
-
 
328
				        if ($line === $_SERVER['REMOTE_ADDR']) {
-
 
329
				                $change_me = 0;
-
 
330
				        }
-
 
331
				}
-
 
332
				// if user @IP does not exist, we write it
-
 
333
				if ($change_me) {
-
 
334
				        file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL, FILE_APPEND);
-
 
335
				}
-
 
336
			}
-
 
337
		} else {
-
 
338
			// we create filename and we write user @IP.
-
 
339
			file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL);
-
 
340
		}
-
 
341
	}
314
	}
342
}
315
}
343
 
316
 
344
// Cleaning the cache
317
// Cleaning the cache
345
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
318
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');