Projet

Général

Profil

Télécharger (4,76 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / status_captiveportal_test.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-test
33
##|*NAME=Status: Captive portal test Vouchers page
34
##|*DESCR=Allow access to the 'Status: Captive portal Test Vouchers' page.
35
##|*MATCH=status_captiveportal_test.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

    
58
$pgtitle = array(gettext("Status"), gettext("Captive portal"), gettext("Test Vouchers"), $a_cp[$cpzone]['zone']);
59
$shortcut_section = "captiveportal-vouchers";
60

    
61
include("head.inc");
62
?>
63
<body>
64
<?php include("fbegin.inc"); ?>
65

    
66
<form action="status_captiveportal_test.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
67
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
68
<tr><td class="tabnavtbl">
69
<?php 
70
	$tab_array = array();
71
        $tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}");
72
        $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}");
73
        $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}");
74
        $tab_array[] = array(gettext("Test Vouchers"), true, "status_captiveportal_test.php?zone={$cpzone}");
75
	$tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}");
76
        display_top_tabs($tab_array);
77
?> 
78
</td></tr>
79
<tr>
80
<td class="tabcont">
81

    
82
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="content pane">
83
  <tr>
84
    <td valign="top" class="vncellreq"><?=gettext("Voucher(s)"); ?></td>
85
    <td class="vtable">
86
    <textarea name="vouchers" cols="65" rows="3" id="vouchers" class="formpre"><?=htmlspecialchars($_POST['vouchers']);?></textarea>
87
    <br />
88
<?=gettext("Enter multiple vouchers separated by space or newline. The remaining time, if valid, will be shown for each voucher"); ?>.</td>      
89
  </tr>      
90
  <tr>
91
    <td width="22%" valign="top">&nbsp;</td>
92
    <td width="78%">
93
    <input name="zone" type="hidden" value="<?=htmlspecialchars($cpzone);?>" />
94
    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Submit"); ?>" />
95
    </td>
96
  </tr>
97
</table>
98
</td></tr></table>
99
</form>
100
<br/>
101
<?php
102
if ($_POST) {
103
    if ($_POST['vouchers']) {
104
        $test_results = voucher_auth($_POST['vouchers'], 1);
105
        echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\" summary=\"results\">\n";
106
        foreach ($test_results as $result) {
107
            if (strpos($result, " good ") || strpos($result, " granted ")) {
108
                echo "<tr><td bgcolor=\"#D9DEE8\"><img src=\"/themes/{$g['theme']}/images/icons/icon_pass.gif\" alt=\"pass\" /></td>";
109
                echo "<td bgcolor=\"#D9DEE8\">$result</td></tr>";
110
            } else {
111
                echo "<tr><td bgcolor=\"#FFD9D1\"><img src=\"/themes/{$g['theme']}/images/icons/icon_block.gif\" alt=\"block\" /></td>";
112
                echo "<td bgcolor=\"#FFD9D1\">$result</td></tr>";
113
            }
114
        }
115
        echo "</table>";
116
    }
117
}
118

    
119
include("fend.inc");
120
?>
121
</body>
122
</html>
(180-180/254)