function clientcmp($a, $b)
{
    global $order;
    return strcmp($a[$order], $b[$order]);
}
if (!is_array($config['captiveportal'])) {
    $config['captiveportal'] = array();
}
$a_cp =& $config['captiveportal'];
$cpdb_all = array();
foreach ($a_cp as $cpzone => $cp) {
    $cpdb = captiveportal_read_db();
    foreach ($cpdb as $cpent) {
        $cpent[10] = $cpzone;
        if ($_GET['showact']) {
            $cpent[11] = captiveportal_get_last_activity($cpent[2], $cpentry[3]);
        }
        $cpdb_all[] = $cpent;
    }
}
if ($_GET['order']) {
    if ($_GET['order'] == "ip") {
        $order = 2;
    } else {
        if ($_GET['order'] == "mac") {
            $order = 3;
        } else {
            if ($_GET['order'] == "user") {
                $order = 4;
            } else {
                if ($_GET['order'] == "lastact") {
            if (isset($mac_man[$mac_hi])) {
                print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>";
            }
        }
        ?>
	&nbsp;
				</td>
				<td>
					<?php 
        echo htmlspecialchars($cpent[4]);
        ?>
&nbsp;
				</td>
<?php 
        if ($_GET['showact']) {
            $last_act = captiveportal_get_last_activity($cpent[2], $cpent[3]);
            ?>
				<td>
					<?php 
            echo htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));
            ?>
				</td>
				<td>
<?php 
            if ($last_act != 0) {
                echo htmlspecialchars(date("m/d/Y H:i:s", $last_act));
            }
            ?>

				</td>
<?php 
    return strcmp($a[$order], $b[$order]);
}
$cpdb = array();
if (file_exists("{$g['vardb_path']}/captiveportal.db")) {
    $captiveportallck = lock('captiveportaldb');
    $cpcontents = file("{$g['vardb_path']}/captiveportal.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    unlock($captiveportallck);
} else {
    $cpcontents = array();
}
$concurrent = count($cpcontents);
foreach ($cpcontents as $cpcontent) {
    $cpent = explode(",", $cpcontent);
    $sessionid = $cpent[5];
    if ($_GET['showact']) {
        $cpent[5] = captiveportal_get_last_activity($cpent[2]);
    }
    $cpdb[$sessionid] = $cpent;
}
if ($_GET['order']) {
    if ($_GET['order'] == "ip") {
        $order = 2;
    } else {
        if ($_GET['order'] == "mac") {
            $order = 3;
        } else {
            if ($_GET['order'] == "user") {
                $order = 4;
            } else {
                if ($_GET['order'] == "lastact") {
                    $order = 5;