Project

General

Profile

Download (1.64 KB) Statistics
| Branch: | Tag: | Revision:
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 Electric Sheep Fencing
9
 * Copyright (c) 2016-2020 Rubicon Communications, LLC (Netgate)
10
 * All rights reserved.
11
 *
12
 * Licensed under the Apache License, Version 2.0 (the "License");
13
 * you may not use this file except in compliance with the License.
14
 * You may obtain a copy of the License at
15
 *
16
 * http://www.apache.org/licenses/LICENSE-2.0
17
 *
18
 * Unless required by applicable law or agreed to in writing, software
19
 * distributed under the License is distributed on an "AS IS" BASIS,
20
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
 * See the License for the specific language governing permissions and
22
 * limitations under the License.
23
 */
24

    
25
	require_once("config.inc");
26
	require_once("functions.inc");
27

    
28
	$removed = 0;
29
	if (!is_array($config['system']['user'])) {
30
		return;
31
	}
32

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

    
56
	if ($removed > 0) {
57
		write_config("Expired {$removed} user accounts");
58
	}
59

    
60
	//print_r($config);
61

    
62
?>
(31-31/82)