Project

General

Profile

Download (2.45 KB) Statistics
| Branch: | Tag: | Revision:
1 cb7d18d5 Renato Botelho
#!/usr/local/bin/php-cgi -f
2 5b237745 Scott Ullrich
<?php
3
/*
4
	rc.prunecaptiveportal
5
	part of m0n0wall (http://m0n0.ch/wall)
6 e173dd74 Phil Davis
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 e173dd74 Phil Davis
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 e173dd74 Phil Davis
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 e173dd74 Phil Davis
16 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19 e173dd74 Phil Davis
20 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32 483e6de8 Scott Ullrich
/* parse the configuration and include all functions used below */
33 e173dd74 Phil Davis
/* config.inc retrieves the util.inc and globals.inc */
34 483e6de8 Scott Ullrich
require_once("config.inc");
35
require_once("functions.inc");
36 5f2d078e Scott Ullrich
require_once("filter.inc");
37
require_once("shaper.inc");
38 483e6de8 Scott Ullrich
require_once("captiveportal.inc");
39
40 64053339 Ermal
global $g;
41 baec2b00 Ermal
global $cpzone;
42
global $cpzoneid;
43 64053339 Ermal
44 b4792bf8 Ermal
$cpzone = str_replace("\n", "", $argv[1]);
45 baec2b00 Ermal
if (!is_array($config['captiveportal'][$cpzone])) {
46
	log_error("{$cpzone} is not a valid zone in the configuration!");
47
	return;
48
}
49
$cpzoneid = $config['captiveportal'][$cpzone]['zoneid'];
50 64053339 Ermal
51
if (file_exists("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running")) {
52 8135f01f Ermal
	$stat = stat("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running");
53 e173dd74 Phil Davis
	if (time() - $stat['mtime'] >= 120) {
54 8135f01f Ermal
		@unlink("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running");
55 e173dd74 Phil Davis
	} else {
56
		log_error("Skipping CP pruning process because previous/another instance is already running");
57 8135f01f Ermal
		return;
58
	}
59 64053339 Ermal
}
60
61
@file_put_contents("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running", "");
62 483e6de8 Scott Ullrich
captiveportal_prune_old();
63 64053339 Ermal
@unlink("{$g['tmp_path']}/.rc.prunecaptiveportal.{$cpzone}.running");
64 483e6de8 Scott Ullrich
65 5b237745 Scott Ullrich
?>