function phoromatic_webui_header_logged_in()
{
    $sub_links = array();
    $html_links = array();
    if ($_SESSION['AdminLevel'] == -40) {
        $pages = array('Admin', 'Admin_Config', 'Admin_Data');
    } else {
        if ($_SESSION['AdminLevel'] > 0) {
            $pages = array('Main');
            if (phoromatic_account_system_count() > 0) {
                array_push($pages, 'Dashboard');
            }
            array_push($pages, 'Systems', 'Schedules', 'Benchmark', 'Results');
            if (phoromatic_tracker_page_relevant()) {
                array_push($pages, 'Tracker');
            }
            if (isset($_SESSION['AdminLevel']) && $_SESSION['AdminLevel'] < 4) {
                array_push($sub_links, 'Users');
            }
            array_push($sub_links, 'Settings');
        }
    }
    array_push($sub_links, 'Logout');
    foreach ($pages as $page) {
        if (strtolower($page) == PAGE_REQUEST) {
            array_push($html_links, '<a href="?' . strtolower($page) . '"><u>' . str_replace('_', ' ', $page) . '</u></a>');
        } else {
            array_push($html_links, '<a href="?' . strtolower($page) . '">' . str_replace('_', ' ', $page) . '</a>');
        }
    }
    foreach ($sub_links as &$link) {
        $link = '<a href="?' . strtolower($link) . '">' . $link . '</a>';
    }
    return phoromatic_webui_header($html_links, '<form action="/?search" method="post" id="search"><input type="search" name="search" size="16" /> <input type="submit" name="sa" value="Search" /></form> ' . implode('&nbsp; &nbsp; &nbsp; &nbsp;', $sub_links) . ' &nbsp; ');
}
function phoromatic_webui_header_logged_in()
{
    $html_links = array();
    if ($_SESSION['AdminLevel'] == -40) {
        $pages = array('Admin', 'Admin_Config', 'Admin_Data', 'Logout');
    } else {
        if ($_SESSION['AdminLevel'] > 0) {
            $sub_main_menu = array();
            $sub_systems_menu = array();
            $sub_testing_menu = array();
            $sub_results_menu = array();
            if (phoromatic_account_system_count() > 0) {
                array_push($sub_systems_menu, 'Dashboard');
                array_push($sub_systems_menu, 'Maintenance Table');
                array_push($sub_systems_menu, 'Component Table');
            }
            array_push($sub_main_menu, '<a href="?tests">Test Profiles</a>');
            if (isset($_SESSION['AdminLevel']) && $_SESSION['AdminLevel'] < 4) {
                array_push($sub_main_menu, 'Users');
            }
            array_push($sub_main_menu, 'Settings', '<a href="?account_activity">Account Activity</a>', 'Logout');
            array_push($sub_testing_menu, '<a href="?schedules">Test Schedules</a>');
            if (!PHOROMATIC_USER_IS_VIEWER) {
                array_push($sub_testing_menu, '<a href="?sched">Create A Schedule</a>', '<a href="?benchmark">Run A Benchmark</a>');
            }
            if (phoromatic_tracker_page_relevant()) {
                array_push($sub_results_menu, 'Tracker');
            }
            array_push($sub_results_menu, '<a href="/rss.php?user='******'UserID'] . '&amp;v=' . sha1($_SESSION['CreatedOn']) . '">Results Feed <img src="images/rss.png" /></a>');
            $pages = array('Main' => $sub_main_menu, 'Systems' => $sub_systems_menu, '<a href="#">Testing</a>' => $sub_testing_menu, 'Results' => $sub_results_menu, '<form action="/?search" method="post" id="search"><input type="search" name="search" id="seach_input" size="16" /> <input type="submit" name="sa" value="Search" /></form>');
        }
    }
    foreach ($pages as $title => $page) {
        if (is_array($page) || empty($page)) {
            $menu_row = array();
            foreach ($page as $sub_page) {
                array_push($menu_row, menu_item_to_html($sub_page));
            }
            $html_links[menu_item_to_html($title)] = $menu_row;
        } else {
            array_push($html_links, menu_item_to_html($page));
        }
    }
    return phoromatic_webui_header($html_links, null);
}