function patcf_is_active($all_users, $user)
{
    if (!in_array($user, $all_users)) {
        return FALSE;
    }
    if (startsWith($user, "active")) {
        return TRUE;
    }
    if (startsWith($user, "yes")) {
        return TRUE;
    }
    if (startsWith($user, "longjson")) {
        return TRUE;
    }
    if (startsWith($user, "credserror")) {
        return TRUE;
    }
    if (startsWith($user, "flip")) {
        return patcf_flip_is_active($seconds);
    }
    if (startsWith($user, "200")) {
        return TRUE;
    }
    if (startsWith($user, "zzz")) {
        return TRUE;
    }
    return FALSE;
}
if ($token == $longtoken) {
    $user = "******";
} else {
    $token = preg_replace('/X/', '', $token);
    // Remove the X
    $user = strrev($token);
}
$state = "";
$comments = array();
$message = '';
$issues = null;
$secret = $pugpigCredsSecret;
if (patcf_is_status_coder($user)) {
    $user = patcf_return_status_code($user, 2);
}
$flip_active = patcf_flip_is_active($seconds);
$deny_issue_based = false;
if ($token == "") {
    $state = "stale";
    $message = "No token!";
    $comments[] = "No token supplied";
} elseif (empty($product_id)) {
    $state = "inactive";
    $message = "No product requested!";
    $comments[] = "No product_id supplied";
} elseif (in_array(strrev($token), array("expiredtoken", "blockedtoken", "alwaysstaletoken"))) {
    $state = "stale";
    $message = "You need to log in again!";
    $comments[] = "Your token is no longer valid";
} elseif (patcf_is_active($all_users, $user)) {
    $state = "active";