1
|
#!/usr/local/bin/php -f
|
2
|
<?php
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
rc.prunecaptiveportal
|
6
|
part of m0n0wall (http://m0n0.ch/wall)
|
7
|
|
8
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
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
|
/* parse the configuration and include all functions used below */
|
34
|
/* config.inc retrives the util.inc and globals.inc */
|
35
|
require_once("config.inc");
|
36
|
require_once("functions.inc");
|
37
|
require_once("filter.inc");
|
38
|
require_once("shaper.inc");
|
39
|
require_once("captiveportal.inc");
|
40
|
|
41
|
global $g;
|
42
|
global $cpzone;
|
43
|
global $cpzoneid;
|
44
|
|
45
|
$cpzone = str_replace("\n", "", $argv[1]);
|
46
|
if (!is_array($config['captiveportal'][$cpzone])) {
|
47
|
log_error("{$cpzone} is not a valid zone in the configuration!");
|
48
|
return;
|
49
|
}
|
50
|
$cpzoneid = $config['captiveportal'][$cpzone]['zoneid'];
|
51
|
|
52
|
if (file_exists("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running")) {
|
53
|
$stat = stat("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running");
|
54
|
if (time() - $stat['mtime'] >= 120)
|
55
|
@unlink("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running");
|
56
|
else {
|
57
|
log_error("Skipping CP prunning process because previous/another instance is already running");
|
58
|
return;
|
59
|
}
|
60
|
}
|
61
|
|
62
|
@file_put_contents("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running", "");
|
63
|
captiveportal_prune_old();
|
64
|
@unlink("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running");
|
65
|
|
66
|
?>
|