}
if (!is_array($config['captiveportal'])) {
    $config['captiveportal'] = array();
}
$a_cp =& $config['captiveportal'];
$pgtitle = array(gettext("Status"), gettext("Captive portal"), gettext("Expire Vouchers"), $a_cp[$cpzone]['zone']);
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"), false, "status_captiveportal_test.php?zone={$cpzone}");
$tab_array[] = array(gettext("Expire Vouchers"), true, "status_captiveportal_expire.php?zone={$cpzone}");
display_top_tabs($tab_array);
require_once 'classes/Form.class.php';
$form = new Form();
$section = new Form_Section('Expire Vouchers');
$section->addInput(new Form_Textarea('vouchers', 'Vouchers', $_POST['vouchers']))->setHelp('Enter multiple vouchers separated by space or newline. All valid vouchers will be marked as expired.');
$section->addInput(new Form_Input('zone', null, 'hidden', $cpzone));
$form->add($section);
print $form;
if ($_POST) {
    if ($_POST['vouchers']) {
        if (voucher_expire($_POST['vouchers'])) {
            print_info_box(gettext('Voucher successfully marked'), 'success');
        } else {
            print_info_box(gettext('Error: Voucher could not be processed'), 'danger');
        }
    }
}
include "foot.inc";
$pconfig['ticketbits'] = $config['voucher'][$cpzone]['ticketbits'];
$pconfig['checksumbits'] = $config['voucher'][$cpzone]['checksumbits'];
$pconfig['magic'] = $config['voucher'][$cpzone]['magic'];
$pconfig['exponent'] = $config['voucher'][$cpzone]['exponent'];
$pconfig['publickey'] = base64_decode($config['voucher'][$cpzone]['publickey']);
$pconfig['privatekey'] = base64_decode($config['voucher'][$cpzone]['privatekey']);
$pconfig['msgnoaccess'] = $config['voucher'][$cpzone]['descrmsgnoaccess'];
$pconfig['msgexpired'] = $config['voucher'][$cpzone]['descrmsgexpired'];
$pconfig['vouchersyncdbip'] = $config['voucher'][$cpzone]['vouchersyncdbip'];
$pconfig['vouchersyncport'] = $config['voucher'][$cpzone]['vouchersyncport'];
$pconfig['vouchersyncpass'] = $config['voucher'][$cpzone]['vouchersyncpass'];
$pconfig['vouchersyncusername'] = $config['voucher'][$cpzone]['vouchersyncusername'];
if ($_POST) {
    unset($input_errors);
    if ($_POST['postafterlogin']) {
        voucher_expire($_POST['voucher_expire']);
        exit;
    }
    $pconfig = $_POST;
    /* input validation */
    if ($_POST['enable'] == "yes") {
        if (!$_POST['vouchersyncusername']) {
            $reqdfields = explode(" ", "charset rollbits ticketbits checksumbits publickey magic");
            $reqdfieldsn = array(gettext("charset"), gettext("rollbits"), gettext("ticketbits"), gettext("checksumbits"), gettext("publickey"), gettext("magic"));
        } else {
            $reqdfields = explode(" ", "vouchersyncdbip vouchersyncport vouchersyncpass vouchersyncusername");
            $reqdfieldsn = array(gettext("Synchronize Voucher Database IP"), gettext("Sync port"), gettext("Sync password"), gettext("Sync username"));
        }
        do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
    }
    if (!$_POST['vouchersyncusername']) {
?>
" />
    <input name="Submit" type="submit" class="formbtn" value="<?php 
echo gettext("Submit");
?>
" />
    </td>
  </tr>
</table>
</td></tr></table>
</form>
<br/>
<?php 
if ($_POST) {
    if ($_POST['vouchers']) {
        $result = voucher_expire($_POST['vouchers']);
        echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\" summary=\"results\">\n";
        if ($result) {
            echo "<tr><td bgcolor=\"#D9DEE8\"><img src=\"/themes/{$g['theme']}/images/icons/icon_pass.gif\" alt=\"pass\" /></td>";
            echo "<td bgcolor=\"#D9DEE8\">Success</td></tr>";
        } else {
            echo "<tr><td bgcolor=\"#FFD9D1\"><img src=\"/themes/{$g['theme']}/images/icons/icon_block.gif\" alt=\"block\" /></td>";
            echo "<td bgcolor=\"#FFD9D1\">Error</td></tr>";
        }
        echo "</table>";
    }
}
include "fend.inc";
?>
</body>
</html>