Location: PHPKode > projects > top serious project > bco/functions/functions.menus.php
<?php

function bco_index_menu($headerText)
{

    global $user_array, $logged_in, $is_admin;

    if ($logged_in == 1) {
        $myuserid = $user_array['myuserid'];
        $username = $user_array['username'];
        $display = "<a href=\"logout.php\" class=\"menu\">logout $username</a>";
        
        echo "\n<div align=\"left\">";
        echo "\n    <span class=\"title\">$headerText</span>";
        echo "<br />" . number_format($GLOBALS['number_of_threads']) . " topics"; // | " . bco_get_active_users($numbers_only = TRUE);
        echo "</div>";
        echo "<br />";
        echo "\n<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" class=\"replytable\">";
        echo "\n    <tr>";
        echo "\n        <td class=\"menu\" colspan=\"2\">";

        // Query to count the number of watched threads.
        $watched_query = "select user_id from threads_watched where user_id=$user_array[myuserid]";
        if (!$watched_result = pg_query($watched_query)) {
            exit("Sorry. :(");
        }

        $watched_amount = pg_num_rows($watched_result);

        if (preg_match("/admin\//", $GLOBALS['base_url'])) {
            $base_url = ereg_replace("admin\/", "", $GLOBALS['base_url']);
        } else {
            $base_url = $GLOBALS['base_url'];
        }

        echo "\n            <a href=\"index.php\" class=\"menu\">index</a> | ";
        // Private message check
        $check_for_messages_query = "select users.id, private_messages.viewed from private_messages, users where to_userid=$myuserid and users.id=$myuserid and private_messages.viewed=0 and type=1 and users.password='" . md5($user_array['password']) . "'";
        if (!$result = pg_query($check_for_messages_query)) {
            exit("ERROR: MySQL said: " . pg_last_error(). "$check_for_messages_query");
        }
        $value = pg_num_rows($result);
        if ($value == 1) {
            echo "\n            <a href=\"messages.php?folder=inbox\" class=\"menu\"><strong style=\"text-decoration: blink;\">$value new message</strong></a> | ";
        } elseif ($value > 1) {
            echo "\n            <a href=\"messages.php?folder=inbox\" class=\"menu\"><strong style=\"text-decoration: blink;\">$value new messages</strong></a> | ";
        } else {
            echo "\n            <a href=\"messages.php?folder=inbox\" class=\"menu\">$value new messages</a> | ";
        }

        echo "\n        <a href=\"view_profile.php?id=$myuserid&amp;action=edit\" class=\"menu\">profile</a> | ";
        echo "\n        <a href=\"view_userlist.php\" class=\"menu\">userlist</a> | ";
        echo "\n        <a href=\"view_watched_topics.php\" class=\"menu\">$watched_amount on watch</a> | ";
        echo "\n        <a href=\"change_colors.php\" class=\"menu\">options</a> | ";
        echo "\n        <a href=\"search.php\" class=\"menu\">search</a> | ";
        echo "\n        <a href=\"http://crewcial.org/stats.html\" class=\"menu\">stats</a>";
        echo "\n        </td>";
        echo "\n        <td align=\"right\" class=\"menu\"><a href=\"logout.php\">logout $username</td>";
        echo "\n    </tr>";
        echo "\n    <tr>";
        echo "\n        <td align=\"left\" class=\"menu\" colspan=\"2\">";
        $current_location = basename($_SERVER['PHP_SELF']);
        switch ($current_location) {
        case ("view_topic.php"):
            echo "\n            <a href=\"new_topic.php\" class=\"menu\">new&nbsp;thread</a> ";
            if ($GLOBALS['logged_in'] == 1) {
                // We want to see if this person is already watching this thread.
                $watch_query  = "select user_id from threads_watched where user_id=$user_array[myuserid]";
                $watch_query .= " and thread_id=$_GET[id]";
                if (pg_num_rows(pg_query($watch_query)) == 0) {
                    echo " | <a href=\"view_topic.php?id=$_GET[id]&amp;action=watch\">add thread to watch list</a>";
                } else {
                    echo " | <a href=\"view_topic.php?id=$_GET[id]&amp;action=unwatch\">remove thread from watch list</a>";
                    echo " | <a href=\"view_topic.php?id=$_GET[id]&amp;action=update\">update this thread</a>";
                }
            }
            break;
        case ("index.php"):
        case ("new_topic.php"):
        case ("view_profile.php"):
        case ("view_post_history.php"):
        case ("view_watched_topics.php"):
        case ("active_users.php"):
            echo "\n            <a href=\"new_topic.php\" class=\"menu\">new&nbsp;thread</a> ";
            break;
        case ("messages.php"):
        case ("send_pmsg.php"):
        case ("view_pmsg.php"):
        case ("manage_messages.php"):
            echo "\n            <a href=\"send_pmsg.php\" class=\"menu\">new&nbsp;message</a> ";
            echo "\n            &#149; <a href=\"manage_messages.php\" class=\"menu\">manage&nbsp;messages</a> ";
            echo "\n            &#149; <a href=\"messages.php?folder=inbox\" class=\"menu\">inbox</a> ";
            echo "\n            &#149; <a href=\"messages.php?folder=outbox\" class=\"menu\">outbox</a>";
            break;
        case ("change_colors.php"):
        case ("change_password.php"):
        case ("options.php"):
            echo "\n            <a href=\"change_colors.php\" class=\"menu\">change&nbsp;colors</a> ";
            echo "\n            &#149; <a href=\"change_password.php\" class=\"menu\">change&nbsp;password</a> ";
            echo "\n            &#149; <a href=\"options.php\" class=\"menu\">account&nbsp;options</a>";
            break;
        }
        echo "\n        </td>";
/*        echo "\n        <td align=\"right\" class=\"menu\">";
        echo "\n            <form method=\"get\" action=\"/search.php\">";
        echo "\n                <input type=\"text\" name=\"q\" size=\"15\" maxlength=\"20\" class=\"textfield\" />";
        echo "\n                <input type=\"submit\" name=\"submit\" value=\"search\" class=\"button\" />";
        echo "\n            </form>";
        echo "\n        </td>";*/
        echo "\n    </tr>";
        echo "\n</table>";
        // Display an admin menu.
        if ($is_admin) {
        	bco_admin_menu($current_location);
		} else {
            echo "\n<br />";
        }
    } else {
        echo "\n<div align=\"center\"><a href=\"http://www.1and1.com/?k_id=7709211\" target=\"_blank\"><img src=\"http://1and1.org/banners/isyours2.gif\" width=\"468\" height=\"60\"  border=\"0\" alt=\"1&1 banner ad\" /></a></div>";
        echo "\n<div align=\"left\"><span class=\"title\">$headerText</span></div>";
        echo "\n<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" class=\"replytable\">";
        echo "\n    <tr>";
        echo "\n        <td class=\"menu\" colspan=\"2\">";
        echo "\n            <a href=\"login.php\" class=\"menu\">Login</a> | ";
        echo "\n            <a href=\"signup.php\" class=\"menu\">New account</a>";
        echo "\n        </td>";
        echo "\n    </tr>";
        echo "\n</table>";
        echo "\n<br />";
    }
}

function bco_admin_menu($current_location)
{
    // Display an admin menu.
    echo "\n<br />\n<div align=\"center\">";
    echo "\n<table width=\"80%\" cellpadding=\"2\" cellspacing=\"0\" class=\"dashed\">";
    echo "\n    <tr>";
    echo "\n        <td><span class=\"warning\"><strong>Administration menu. PLEASE USE CAUTION!</strong></span></td>";
    echo "\n    </tr>";
    echo "\n    <tr>";
    echo "\n        <td>";
    switch ($current_location) {
        case ("view_topic.php"):
        // Set sticky or not sticky.
        if ($GLOBALS['sticky'] == 't') {
            echo "\n&#149; <a href=\"admin/admin.php?mode=sticky&amp;action=unset&amp;id=$_GET[id]\">Remove sticky option</a>";
            } else {
            echo "\n&#149; <a href=\"admin/admin.php?mode=sticky&amp;action=set&amp;id=$_GET[id]\">Set sticky option</a>";
            }
        // Set lock or unlock
        if ($GLOBALS['locked'] == 1) {
            echo "\n&#149; <a href=\"admin/admin.php?mode=lock&amp;action=unlock&amp;id=$_GET[id]\">Unlock thread</a>";
            } else {
            echo "\n&#149; <a href=\"admin/admin.php?mode=lock&amp;action=lock&amp;id=$_GET[id]\">Lock thread</a>";
        }
        break;

    case ("view_profile.php");
        if ($GLOBALS['banned'] == 1) {
            echo "\n&#149; <a href=\"admin/admin.php?mode=ban&amp;action=unban&amp;id=$_GET[id]\">Unban user</a>";
        } else {
            echo "\n&#149; <a href=\"admin/admin.php?mode=ban&amp;action=ban&amp;id=$_GET[id]\">Ban user</a>";
            }
        break;

	case ("change_colors.php");
		echo "\n&#149; <a href=\"admin/admin.php?mode=change_colors&amp;color_string=$GLOBALS[color_string]\">Set default colors to current scheme</a>";
		break;

    default:
        echo "No options for this page.";
        break;
    }
    echo "\n        </td>";
    echo "\n    </tr>";
    echo "\n</table>";
    echo "\n</div>";
    echo "\n<br />";
}


?>
Return current item: top serious project