Projet

Général

Profil

Télécharger (5,32 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / status_captiveportal_vouchers.php @ 0cb60645

1
<?php
2
/*
3
    Copyright (C) 2007 Marcel Wiget <mwiget@mac.com>.
4
    All rights reserved.
5

    
6
    Redistribution and use in source and binary forms, with or without
7
    modification, are permitted provided that the following conditions are met:
8

    
9
    1. Redistributions of source code must retain the above copyright notice,
10
       this list of conditions and the following disclaimer.
11

    
12
    2. Redistributions in binary form must reproduce the above copyright
13
       notice, this list of conditions and the following disclaimer in the
14
       documentation and/or other materials provided with the distribution.
15

    
16
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
17
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
20
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
    POSSIBILITY OF SUCH DAMAGE.
26
*/
27
/*
28
	pfSense_MODULE:	captiveportal
29
*/
30

    
31
##|+PRIV
32
##|*IDENT=page-status-captiveportal-vouchers
33
##|*NAME=Status: Captive portal Vouchers page
34
##|*DESCR=Allow access to the 'Status: Captive portal Vouchers' page.
35
##|*MATCH=status_captiveportal_vouchers.php*
36
##|-PRIV
37

    
38
require("guiconfig.inc");
39
require("functions.inc");
40
require_once("filter.inc");
41
require("shaper.inc");
42
require("captiveportal.inc");
43
require_once("voucher.inc");
44

    
45
$cpzone = $_GET['zone'];
46
if (isset($_POST['zone']))
47
	$cpzone = $_POST['zone'];
48

    
49
if (empty($cpzone)) {
50
	header("Location: services_captiveportal_zones.php");
51
	exit;
52
}
53

    
54
if (!is_array($config['captiveportal']))
55
	$config['captiveportal'] = array();
56
$a_cp =& $config['captiveportal'];
57
$pgtitle = array(gettext("Status"), gettext("Captive portal"), gettext("Vouchers"), $a_cp[$cpzone]['zone']);
58
$shortcut_section = "captiveportal-vouchers";
59

    
60
function clientcmp($a, $b) {
61
	global $order;
62
	return strcmp($a[$order], $b[$order]);
63
}
64

    
65
if (!is_array($config['voucher'][$cpzone]['roll'])) {
66
	$config['voucher'][$cpzone]['roll'] = array();
67
}
68
$a_roll = $config['voucher'][$cpzone]['roll'];
69

    
70
$db = array();
71

    
72
foreach($a_roll as $rollent) {
73
	$roll = $rollent['number'];
74
	$minutes = $rollent['minutes'];
75

    
76
	if (!file_exists("{$g['vardb_path']}/voucher_{$cpzone}_active_$roll.db"))
77
		continue;
78

    
79
	$active_vouchers = file("{$g['vardb_path']}/voucher_{$cpzone}_active_$roll.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
80
	foreach($active_vouchers as $voucher => $line) {
81
		list($voucher,$timestamp, $minutes) = explode(",", $line);
82
		$remaining = (($timestamp + 60*$minutes) - time());
83
		if ($remaining > 0) {
84
			$dbent[0] = $voucher;
85
			$dbent[1] = $roll;
86
			$dbent[2] = $timestamp;
87
			$dbent[3] = intval($remaining/60);
88
			$dbent[4] = $timestamp + 60*$minutes; // expires at
89
			$db[] = $dbent;
90
		}
91
	}
92
}
93

    
94
if ($_GET['order']) {
95
	$order = $_GET['order'];
96
	usort($db, "clientcmp");
97
}
98

    
99
include("head.inc");
100
?>
101
<body>
102
<?php include("fbegin.inc"); ?>
103

    
104
<form action="status_captiveportal_vouchers.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
105
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
106
<tr><td class="tabnavtbl">
107
<?php
108
	$tab_array = array();
109
	$tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}");
110
	$tab_array[] = array(gettext("Active Vouchers"), true, "status_captiveportal_vouchers.php?zone={$cpzone}");
111
	$tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}");
112
	$tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone={$cpzone}");
113
	$tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}");
114
	display_top_tabs($tab_array);
115
?>
116
</td></tr>
117
<tr>
118
<td class="tabcont">
119

    
120
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="content pane">
121
  <tr>
122
    <td class="listhdrr"><a href="?order=0&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Voucher"); ?></a></td>
123
    <td class="listhdrr"><a href="?order=1&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Roll"); ?></a></td>
124
    <td class="listhdrr"><a href="?order=2&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Activated at"); ?></a></td>
125
    <td class="listhdrr"><a href="?order=3&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Expires in"); ?></a></td>
126
    <td class="listhdr"><a href="?order=4&amp;showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Expires at"); ?></a></td>
127
    <td class="list"></td>
128
  </tr>
129
<?php foreach ($db as $dbent): ?>
130
  <tr>
131
    <td class="listlr"><?=$dbent[0];?></td>
132
    <td class="listr"><?=$dbent[1];?></td>
133
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[2]));?></td>
134
    <td class="listr"><?=$dbent[3];?> <?=gettext("min"); ?></td>
135
    <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[4]));?></td>
136
    <td class="list"></td>
137
  </tr>
138
<?php endforeach; ?>
139
</table>
140
</td>
141
</tr>
142
</table>
143
</form>
144
<?php include("fend.inc"); ?>
145
</body>
146
</html>
(182-182/254)