Subversion Repositories ALCASAR

Rev

Rev 2008 | Rev 2064 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2008 Rev 2013
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: status.php 2008 2016-07-25 09:00:46Z raphael.pion $
2
# $Id: status.php 2013 2016-07-28 15:51:12Z raphael.pion $
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 250... Line 250...
250
				$connection_history.="</ul>";
250
				$connection_history.="</ul>";
251
				if ($a_connected > 1){
251
				if ($a_connected > 1){
252
					$a_connection = $l_a_connection." ".$a_connected." ".$l_a_connection_time; }
252
					$a_connection = $l_a_connection." ".$a_connected." ".$l_a_connection_time; }
253
			}
253
			}
254
		}
254
		}
-
 
255
		
-
 
256
		//store in a file user @IP who can join this page.
-
 
257
		$filename='/tmp/current_users.txt';
-
 
258
		//change me avoid duplicate user @IP
-
 
259
		$change_me = 1;
-
 
260
 
-
 
261
		//check if filename exists
-
 
262
		if(file_exists($filename)){
-
 
263
			$fichier = fopen($filename, "r");
-
 
264
			$content = file($filename);
-
 
265
 
-
 
266
			//if file is empty, we put user @IP in it.
-
 
267
			if(empty($content))
-
 
268
			{
-
 
269
				file_put_contents($filename, $_SERVER['REMOTE_ADDR']);
-
 
270
			}
-
 
271
			else
-
 
272
			{
-
 
273
				//if we found duplicate IP, it will not write user @IP in filename (set change_me = 0)
-
 
274
				foreach($content as $line){
-
 
275
				        $line = preg_replace('/\s+/', '', $line);
-
 
276
				        if($line == $_SERVER['REMOTE_ADDR'])
-
 
277
				        {
-
 
278
				                $change_me = 0;
-
 
279
				        }
-
 
280
 
-
 
281
				}
-
 
282
 
-
 
283
				//if user @IP does not exist, we will write it in filename
-
 
284
				if($change_me)
-
 
285
				{
-
 
286
				        file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL , FILE_APPEND);
-
 
287
				}
-
 
288
			}
-
 
289
 
-
 
290
		}
-
 
291
		else
-
 
292
		{
-
 
293
			//we create filename and we put user @IP in it.
-
 
294
			file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL);
-
 
295
		}
-
 
296
		
-
 
297
		
255
	}
298
	}
256
}
299
}
257
?>
300
?>
258
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
301
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
259
<html lang="fr">
302
<html lang="fr">