<?php function check_permissions($user, $allowed = array()) {
    # Use this function if you want to handle success and failure 
    # yourself gracefully.

    $prog='/u/isg/bin/util/get_classlist_info';

    $type=exec("$prog userid $user type");

    return in_array($type, $allowed);
}

function ensure_permissions($user, $allowed = array()) {
# Abort abruptly with a terse message if the user should not view this
# page.
# Otherwise, continue loading the page.

    if (!check_permissions($user, $allowed)) {
        echo "<p>You ($user) do not have permission to view this page.</p>";
        exit(5);
    }
}
?>