1
|
#!/usr/local/bin/php-cgi -f
|
2
|
<?php
|
3
|
/*
|
4
|
rc.expireaccounts
|
5
|
part of pfSense
|
6
|
|
7
|
Copyright (C) 2009 Shrew Soft Inc.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
|
32
|
require_once("config.inc");
|
33
|
require_once("functions.inc");
|
34
|
|
35
|
$removed = 0;
|
36
|
if (!is_array($config['system']['user'])) {
|
37
|
return;
|
38
|
}
|
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
|
}
|
47
|
echo "1\n";
|
48
|
echo "User {$user['name']} expires {$user['expires']}\n";
|
49
|
if (!$user['expires'] || isset($user['disabled'])) {
|
50
|
continue;
|
51
|
}
|
52
|
echo "1\n";
|
53
|
if (strtotime("-1 day") > strtotime($user['expires'])) {
|
54
|
echo "Disabling user {$user['name']} at index #{$index}\n";
|
55
|
//unset($config['system']['user'][$index]);
|
56
|
$user['disabled'] = true;
|
57
|
$removed++;
|
58
|
$count--;
|
59
|
$index--;
|
60
|
}
|
61
|
}
|
62
|
|
63
|
if ($removed > 0) {
|
64
|
write_config("Expired {$removed} user accounts");
|
65
|
}
|
66
|
|
67
|
//print_r($config);
|
68
|
|
69
|
?>
|