Projet

Général

Profil

Télécharger (2,1 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / etc / rc.expireaccounts @ e7eeb5ce

1
#!/usr/local/bin/php -f
2
<?php
3
/* $Id$ */
4
/*
5
	rc.exireaccounts
6
	part of pfSense
7
	
8
	Copyright (C) 2009 Shrew Soft Inc.
9
	All rights reserved.
10
	
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13
	
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16
	
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20
	
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32

    
33
	require_once("config.inc");
34
	require_once("functions.inc");
35

    
36
	$removed = 0;
37
	if (!is_array($config['system']['user']))
38
		return;
39

    
40
	$count = count($config['system']['user']);
41
	$index = 0;
42
	for(; $index < $count; $index++) {
43
		$user =& $config['system']['user'][$index];
44
		if($user['scope'] == "system")
45
			continue;
46
		echo "1\n";
47
		echo "User {$user['name']} expires {$user['expires']}\n";
48
		if(!$user['expires'] || isset($user['disabled']))
49
			continue;
50
		echo "1\n";
51
		if(strtotime("-1 day") > strtotime($user['expires'])) {
52
			echo "Disabling user {$user['name']} at index #{$index}\n";
53
			//unset($config['system']['user'][$index]);
54
			$user['disabled'] = true;
55
			$removed++;
56
			$count--;
57
			$index--;
58
		}
59
	}
60

    
61
	if($removed > 0)
62
		write_config("Expired {$removed} user accounts");
63

    
64
	//print_r($config);
65

    
66
?>
(52-52/110)