1
|
#!/usr/local/bin/php-cgi -f
|
2
|
<?php
|
3
|
/*
|
4
|
* rc.expireaccounts
|
5
|
*
|
6
|
* part of pfSense (https://www.pfsense.org)
|
7
|
* Copyright (c) 2009 Shrew Soft Inc.
|
8
|
* Copyright (c) 2016 Rubicon Communications, LLC (Netgate)
|
9
|
* All rights reserved.
|
10
|
*
|
11
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
* you may not use this file except in compliance with the License.
|
13
|
* You may obtain a copy of the License at
|
14
|
*
|
15
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
*
|
17
|
* Unless required by applicable law or agreed to in writing, software
|
18
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
* See the License for the specific language governing permissions and
|
21
|
* limitations under the License.
|
22
|
*/
|
23
|
|
24
|
require_once("config.inc");
|
25
|
require_once("functions.inc");
|
26
|
|
27
|
$removed = 0;
|
28
|
if (!is_array($config['system']['user'])) {
|
29
|
return;
|
30
|
}
|
31
|
|
32
|
$count = count($config['system']['user']);
|
33
|
$index = 0;
|
34
|
for (; $index < $count; $index++) {
|
35
|
$user =& $config['system']['user'][$index];
|
36
|
if ($user['scope'] == "system") {
|
37
|
continue;
|
38
|
}
|
39
|
echo "1\n";
|
40
|
echo "User {$user['name']} expires {$user['expires']}\n";
|
41
|
if (!$user['expires'] || isset($user['disabled'])) {
|
42
|
continue;
|
43
|
}
|
44
|
echo "1\n";
|
45
|
if (strtotime("-1 day") > strtotime($user['expires'])) {
|
46
|
echo "Disabling user {$user['name']} at index #{$index}\n";
|
47
|
//unset($config['system']['user'][$index]);
|
48
|
$user['disabled'] = true;
|
49
|
$removed++;
|
50
|
$count--;
|
51
|
$index--;
|
52
|
}
|
53
|
}
|
54
|
|
55
|
if ($removed > 0) {
|
56
|
write_config("Expired {$removed} user accounts");
|
57
|
}
|
58
|
|
59
|
//print_r($config);
|
60
|
|
61
|
?>
|