$shortcut_section = "captiveportal-vouchers";
include "head.inc";
$tab_array = array();
$tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}");
$tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}");
$tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}");
$tab_array[] = array(gettext("Test Vouchers"), true, "status_captiveportal_test.php?zone={$cpzone}");
$tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}");
display_top_tabs($tab_array);
require_once 'classes/Form.class.php';
$form = new Form();
$section = new Form_Section('Test Vouchers');
$section->addInput(new Form_Textarea('vouchers', 'Vouchers', $_POST['vouchers']))->setHelp('Enter multiple vouchers separated by space or newline. The remaining time, if valid, will be shown for each voucher.');
$section->addInput(new Form_Input('zone', null, 'hidden', $cpzone));
$form->add($section);
print $form;
if ($_POST) {
    if ($_POST['vouchers']) {
        $test_results = voucher_auth($_POST['vouchers'], 1);
        $output = "";
        foreach ($test_results as $result) {
            if (strpos($result, " good ") || strpos($result, " granted ")) {
                $output .= '<font color="green">' . htmlspecialchars($result) . '</font>' . '<br />';
            } else {
                $output .= '<font color="red">' . htmlspecialchars($result) . '</font>' . '<br />';
            }
        }
        print_info_box($output);
    }
}
include "foot.inc";
Example #2
0
         portal_reply_page($cpcfg['blockedmacsurl'], "redir");
     } else {
         portal_reply_page($redirurl, "error", "This MAC address has been blocked");
     }
 } else {
     if ($clientmac && $radmac_enable && portal_mac_radius($clientmac, $clientip, $radiusctx)) {
         /* radius functions handle everything so we exit here since we're done */
     } else {
         if (portal_consume_passthrough_credit($clientmac)) {
             /* allow the client through if it had a pass-through credit for its MAC */
             captiveportal_logportalauth("unauthenticated", $clientmac, $clientip, "ACCEPT");
             portal_allow($clientip, $clientmac, "unauthenticated");
         } else {
             if (isset($config['voucher'][$cpzone]['enable']) && $_POST['accept'] && $_POST['auth_voucher']) {
                 $voucher = trim($_POST['auth_voucher']);
                 $timecredit = voucher_auth($voucher);
                 // $timecredit contains either a credit in minutes or an error message
                 if ($timecredit > 0) {
                     // voucher is valid. Remaining minutes returned
                     // if multiple vouchers given, use the first as username
                     $a_vouchers = preg_split("/[\t\n\r ]+/s", $voucher);
                     $voucher = $a_vouchers[0];
                     $attr = array('voucher' => 1, 'session_timeout' => $timecredit * 60, 'session_terminate_time' => 0);
                     if (portal_allow($clientip, $clientmac, $voucher, null, $attr)) {
                         // YES: user is good for $timecredit minutes.
                         captiveportal_logportalauth($voucher, $clientmac, $clientip, "Voucher login good for {$timecredit} min.");
                     } else {
                         portal_reply_page($redirurl, "error", $config['voucher'][$cpzone]['descrmsgexpired'] ? $config['voucher'][$cpzone]['descrmsgexpired'] : $errormsg);
                     }
                 } else {
                     if (-1 == $timecredit) {