Project

General

Profile

Download (2.46 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php -f
2
<?php
3 1b8df11b Bill Marquette
/* $Id$ */
4 5b237745 Scott Ullrich
/*
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 483e6de8 Scott Ullrich
/* 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 5f2d078e Scott Ullrich
require_once("filter.inc");
38
require_once("shaper.inc");
39 483e6de8 Scott Ullrich
require_once("captiveportal.inc");
40
41 64053339 Ermal
global $g;
42 baec2b00 Ermal
global $cpzone;
43
global $cpzoneid;
44 64053339 Ermal
45 b4792bf8 Ermal
$cpzone = str_replace("\n", "", $argv[1]);
46 baec2b00 Ermal
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 64053339 Ermal
52
if (file_exists("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running")) {
53 8135f01f Ermal
	$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 64053339 Ermal
}
61
62
@file_put_contents("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running", "");
63 483e6de8 Scott Ullrich
captiveportal_prune_old();
64 64053339 Ermal
@unlink("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running");
65 483e6de8 Scott Ullrich
66 5b237745 Scott Ullrich
?>