Project

General

Profile

« Previous | Next » 

Revision f200e233

Added by sbeaver almost 10 years ago

status_captiveportal_test.php Conversion complete

Ready for review

View differences:

usr/local/www/status_captiveportal_test.php
26 26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 27
	POSSIBILITY OF SUCH DAMAGE.
28 28
*/
29
/*	
30
	pfSense_MODULE:	captiveportal
29
/*
30
	pfSense_MODULE: captiveportal
31 31
*/
32 32

  
33 33
##|+PRIV
......
46 46

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

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

  
56 56
if (!is_array($config['captiveportal']))
57
        $config['captiveportal'] = array();
57
	$config['captiveportal'] = array();
58
	
58 59
$a_cp =& $config['captiveportal'];
59 60

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

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

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

  
84
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="content pane">
85
  <tr>
86
    <td valign="top" class="vncellreq"><?=gettext("Voucher(s)"); ?></td>
87
    <td class="vtable">
88
    <textarea name="vouchers" cols="65" rows="3" id="vouchers" class="formpre"><?=htmlspecialchars($_POST['vouchers']);?></textarea>
89
    <br />
90
<?=gettext("Enter multiple vouchers separated by space or newline. The remaining time, if valid, will be shown for each voucher"); ?>.</td>      
91
  </tr>      
92
  <tr>
93
    <td width="22%" valign="top">&nbsp;</td>
94
    <td width="78%">
95
    <input name="zone" type="hidden" value="<?=htmlspecialchars($cpzone);?>" />
96
    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Submit"); ?>" />
97
    </td>
98
  </tr>
99
</table>
100
</td></tr></table>
101
</form>
102
<br/>
103
<?php
65

  
66
$tab_array = array();
67
$tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}");
68
$tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}");
69
$tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}");
70
$tab_array[] = array(gettext("Test Vouchers"), true, "status_captiveportal_test.php?zone={$cpzone}");
71
$tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}");
72
display_top_tabs($tab_array);
73

  
74
require('classes/Form.class.php');
75

  
76
$form = new Form;
77

  
78
$section = new Form_Section('Test Vouchers');
79

  
80
$section->addInput(new Form_Textarea(
81
	'vouchers',
82
	'Vouchers',
83
	$_POST['vouchers']
84
))->setHelp('Enter multiple vouchers separated by space or newline. The remaining time, if valid, will be shown for each voucher.');
85

  
86
$section->addInput(new Form_Input(
87
	'zone',
88
	null,
89
	'hidden',
90
	$cpzone
91
));
92

  
93
$form->add($section);
94
print($form);
95

  
104 96
if ($_POST) {
105
    if ($_POST['vouchers']) {
106
        $test_results = voucher_auth($_POST['vouchers'], 1);
107
        echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\" summary=\"results\">\n";
108
        foreach ($test_results as $result) {
109
            if (strpos($result, " good ") || strpos($result, " granted ")) {
110
                echo "<tr><td bgcolor=\"#D9DEE8\"><img src=\"/themes/{$g['theme']}/images/icons/icon_pass.gif\" alt=\"pass\" /></td>";
111
                echo "<td bgcolor=\"#D9DEE8\">$result</td></tr>";
112
            } else {
113
                echo "<tr><td bgcolor=\"#FFD9D1\"><img src=\"/themes/{$g['theme']}/images/icons/icon_block.gif\" alt=\"block\" /></td>";
114
                echo "<td bgcolor=\"#FFD9D1\">$result</td></tr>";
115
            }
116
        }
117
        echo "</table>";
118
    }
97
	if ($_POST['vouchers']) {
98
		$test_results = voucher_auth($_POST['vouchers'], 1);
99
		$output = "";
100

  
101
		foreach ($test_results as $result) {
102
			if (strpos($result, " good ") || strpos($result, " granted ")) {
103
				$output .= '<font color="green">' . $result . '</font>' . '<br />';
104
			} else {
105
				$output .= '<font color="red">' . $result . '</font>' . '<br />';
106
			}
107
		}
108

  
109
		print_info_box($output);
110
	}
119 111
}
120 112

  
121
include("fend.inc");
122
?>
123
</body>
124
</html>
113
include("foot.inc");

Also available in: Unified diff