1 |
cb7d18d5
|
Renato Botelho
|
#!/usr/local/bin/php-cgi -f
|
2 |
0092b3bd
|
mgrooms
|
<?php
|
3 |
|
|
/*
|
4 |
ac24dc24
|
Renato Botelho
|
* rc.expireaccounts
|
5 |
|
|
*
|
6 |
|
|
* part of pfSense (https://www.pfsense.org)
|
7 |
c5d81585
|
Renato Botelho
|
* Copyright (c) 2009 Shrew Soft Inc.
|
8 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2016 Electric Sheep Fencing
|
9 |
0284d79e
|
jim-p
|
* Copyright (c) 2016-2020 Rubicon Communications, LLC (Netgate)
|
10 |
ac24dc24
|
Renato Botelho
|
* All rights reserved.
|
11 |
|
|
*
|
12 |
b12ea3fb
|
Renato Botelho
|
* 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 |
ac24dc24
|
Renato Botelho
|
*
|
16 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
17 |
ac24dc24
|
Renato Botelho
|
*
|
18 |
b12ea3fb
|
Renato Botelho
|
* 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 |
ac24dc24
|
Renato Botelho
|
*/
|
24 |
0092b3bd
|
mgrooms
|
|
25 |
5f2d078e
|
Scott Ullrich
|
require_once("config.inc");
|
26 |
|
|
require_once("functions.inc");
|
27 |
0092b3bd
|
mgrooms
|
|
28 |
|
|
$removed = 0;
|
29 |
086cf944
|
Phil Davis
|
if (!is_array($config['system']['user'])) {
|
30 |
0092b3bd
|
mgrooms
|
return;
|
31 |
086cf944
|
Phil Davis
|
}
|
32 |
0092b3bd
|
mgrooms
|
|
33 |
|
|
$count = count($config['system']['user']);
|
34 |
|
|
$index = 0;
|
35 |
e173dd74
|
Phil Davis
|
for (; $index < $count; $index++) {
|
36 |
41fb483a
|
Ermal
|
$user =& $config['system']['user'][$index];
|
37 |
086cf944
|
Phil Davis
|
if ($user['scope'] == "system") {
|
38 |
0092b3bd
|
mgrooms
|
continue;
|
39 |
086cf944
|
Phil Davis
|
}
|
40 |
0092b3bd
|
mgrooms
|
echo "1\n";
|
41 |
|
|
echo "User {$user['name']} expires {$user['expires']}\n";
|
42 |
086cf944
|
Phil Davis
|
if (!$user['expires'] || isset($user['disabled'])) {
|
43 |
0092b3bd
|
mgrooms
|
continue;
|
44 |
086cf944
|
Phil Davis
|
}
|
45 |
0092b3bd
|
mgrooms
|
echo "1\n";
|
46 |
e173dd74
|
Phil Davis
|
if (strtotime("-1 day") > strtotime($user['expires'])) {
|
47 |
41fb483a
|
Ermal
|
echo "Disabling user {$user['name']} at index #{$index}\n";
|
48 |
|
|
//unset($config['system']['user'][$index]);
|
49 |
|
|
$user['disabled'] = true;
|
50 |
0092b3bd
|
mgrooms
|
$removed++;
|
51 |
|
|
$count--;
|
52 |
|
|
$index--;
|
53 |
|
|
}
|
54 |
|
|
}
|
55 |
|
|
|
56 |
e173dd74
|
Phil Davis
|
if ($removed > 0) {
|
57 |
0092b3bd
|
mgrooms
|
write_config("Expired {$removed} user accounts");
|
58 |
e173dd74
|
Phil Davis
|
}
|
59 |
0092b3bd
|
mgrooms
|
|
60 |
6c8a7393
|
Ermal Lu?i
|
//print_r($config);
|
61 |
0092b3bd
|
mgrooms
|
|
62 |
|
|
?>
|