<?php

@( (bool)FALSE === strpos( $_SERVER['REQUEST_URI'], basename( __FILE__ ) ) ) OR exit( '!! ACCESS DENIED !!' );

/* vim: set expandtab tabstop=4 shiftwidth=4: */

// ***** BEGIN LICENSE BLOCK ( DO NOT REMOVE ) *****

// +----------------------------------------------------------------------+
// | MPN Admin Menu For 188_8                                             |
// |                                                                      |
// | -> MPN Administration Menu                                           |
// +----------------------------------------------------------------------+
// | VERSION: 0.1 Alpha                                                   |
// +----------------------------------------------------------------------+
// | LICENSE: GPL 2.0 (see docs/LICENSE_GPL)                              |
// |                                                                      |
// | This file is part of MPN Admin Entry For MPN 188_8.                  |
// |                                                                      |
// | MPN Admin Entry For MPN 188_8 is free software; you can              |
// | redistribute it and/or modify it under the terms of the GNU          |
// | General Public License as published by the Free Software Foundation; |
// | either version 2 of the License, or (at your option) any             |
// | later version.                                                       |
// |                                                                      |
// | MPN Admin Entry For MPN 188_8 is distributed in the hope that it     |
// | will be useful, but WITHOUT ANY WARRANTY; without even the implied   |
// | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     |
// | See the GNU General Public License for more details.                 |
// |                                                                      |
// | You should have received a copy of the GNU General Public License    |
// | along with MPN Admin Entry For MPN 188_8; if not, write to the       |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 59 Temple Place, Suite 330                                           |
// | Boston, MA 02111-1307  USA                                           |
// +----------------------------------------------------------------------+
// | AUTHOR(s):                                                           |
// |                                                                      |
// | The Original Code is the MPN Admin Entry For MPN 188_8.              |
// | The Initial Developer of the Original Code is Eric Haddix.           |
// |                                                                      |
// | Portions created by Eric Haddix or Kiril Threndor                    |
// | <support@mpn.illearth.net> are                                       |
// | Copyright (C) 2003 Eric Haddix.  All Rights Reserved.                |
// +----------------------------------------------------------------------+
// | CONTRIBUTOR(s):                                                      |
// |                                                                      |
// |                                                                      |
// +----------------------------------------------------------------------+
// | MODIFICATIONS:                                                       |
// |                                                                      |
// |                                                                      |
// +----------------------------------------------------------------------+
// | NOTES:                                                               |
// +----------------------------------------------------------------------+
// | SUPPORT:                                                             |
// |   WEB:   http://myphpnuke.com/                                       |
// |   EMAIL: support@mpn.illearth.net                                    |
// +----------------------------------------------------------------------+

/**
 * MPN_188_8_Modules
 *
 * @package MPN_188_8_Administration
 * @subpackage interface
 * @version $Id: adminMenu.php,v 1.1.2.9 2004/09/16 15:16:24 kirilt Exp $
 *
 * @author Kiril Threndor <support@mpn.illearth.net>
 * @copyright Copyright (C) 2003 Eric Haddix
 * @license http://www.gnu.org/licenses/gpl.html GPL 2.0
 * @support http://myphpnuke.com/
 *
 * @tutorial
 * @filesource
 */

// ***** END LICENSE BLOCK ( DO NOT REMOVE ) *****

// ADMIN MENU USING HTML FORMS ( Admin Menu Type 1 )

if ( ! _MPN_ADMIN ) { adminLoginForm(); }

$menustyle1 = 'style="background-color:' . $bgcolor2 . '; border:2px inset #000000; width:33%;"';
$menustyle2 = 'style="background-color:' . $bgcolor3 . '; border:2px inset #000000; width:33%;"';

echo '<div class="adminmenu">' . "\n";

    echo '<h1>' . translate( 'myPHPNuke' ) . ' ' . _MPN_VERSION_ . ' ' . translate( 'Administration' ) . '</h1><br />' . "\n";

    //OpenTable();

    echo '<table class="wauto" summary="Admin Menu"><tr>' . "\n";

        echo '<td class="center" ' . $menustyle1 . '>' . "\n";

            modNav();

        if ( _ADMIN_TRUSTED )
        {
            echo '</td><td class="center" ' . $menustyle2 . '>' . "\n";

            configNav();
        }

    echo '</td></tr></table>' . "\n";

    echo '<br />' . "\n";

    echo '<div class="center">' . "\n";

        echo '<p class="subtitle1">' . "\n";

            echo '<a href="./admin.php" title="' . translate( 'Administrative Home Page' ) . '">' . translate( 'Admin Home' ) . '</a>' . "\n";

           echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . "\n";

            echo '<a href="./admin.php?op=logout" title="' . translate( 'Log Off' ) . '">' . translate( 'Log Out' ) . '</a>' . "\n";

            if ( _ADMIN_TRUSTED )
            {
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . "\n";

                echo '<a href="./admin.php?op=sysinfo" title="' . translate( 'System Information' ) . '" target="_blank">' . translate( 'System Information' ) . '</a>' . "\n";
            }

            echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . "\n";

            echo '<a href="http://www.myphpnuke.com/manual188/" title="' . _MPN_VERSION_ . ' ' . translate( 'Administrative Manual' ) . '" target="_blank">!&nbsp;' . translate( 'HELP' ) . '&nbsp;!</a>' . "\n";

            echo '<br />' . "\n";

        echo '</p>' . "\n";

    echo '</div>' . "\n";

   // CloseTable();

   // echo '<br /><br />' . "\n";

echo '</div>' . "\n";

// ##### SUBMENU LOADER #####

/**
 *
 *
 *
 */

function getSubMenu( $menu_items, $title )
{
    $content = '<hr class="w80" />' . "\n";

    $content .= '<h2>' . $title . '</h2>' . "\n";

    $content .= '<div class="form">' . "\n";

        $content .= '<form action="admin.php" method="get">' . "\n";

            $content .= '<p>' . "\n";

                $content .= '<label class="middle"><span class="subtitle2">' . translate( 'Available Utilities' ) . ':</span></label>&nbsp;' . "\n";

               $content .= '<select name="alk" onchange="submit()">' . "\n";

                    foreach ( $menu_items AS $key => $v )
                    {
                        $fctchk = ( ! empty( $_REQUEST['fct'] ) ) ? ( (bool)FALSE !== strpos( $key, $_REQUEST['fct'] ) ) : ( (bool)FALSE );
                        $opchk = ( ! empty( $_REQUEST['op'] ) ) ? ( (bool)FALSE !== strpos( $key, $_REQUEST['op'] ) ) : ( (bool)FALSE );

                        $sel = ( $_SERVER['QUERY_STRING'] == $key || ( $fctchk || $opchk ) )
                             ? ( 'selected="yes"' )
                             : ( NULL );

                        $content .= '<option value="' . base64_encode( $key ) . '" ' . $sel . '>' . $v . '</option>' . "\n";
                    }

                $content .= '</select>' . "\n";

                $content .= '<input class="button" type="submit" value="' . translate( 'G O' ) . '"></input>' . "\n";

            $content .= '</p>' . "\n";

        $content .= '</form>' . "\n";

    $content .= '</div>' . "\n";

    $content .= '<hr class="w80" /><br />' . "\n";

    return $content;

} // End Function

/**
 *
 *
 *
 */

function configNav()
{
    @( $cfg_menu = include _DP_ADMIN_ . 'menu' . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'menu_config.array.php' )
      OR goBack( translate( 'Include Error' ) );

    echo '<form action="admin.php" method="get">' . "\n";

        echo '<p class="forms">' . "\n";

            echo '<h3>' . translate( 'Site Configuration' ) . '</h3>' . "\n";

            echo '<select name="alk" onchange="submit()">' . "\n";

                foreach ( $cfg_menu AS $key => $v )
                {
                    $fctchk = ( isset( $_REQUEST['fct'] ) && (bool)FALSE !== @strpos( $key, $_REQUEST['fct'] ) );
                    $opchk = ( isset( $_REQUEST['op'] ) && (bool)FALSE !== @strpos( $key, $_REQUEST['op'] ) );

                    $sel = ( $_SERVER['QUERY_STRING'] == $key || ( $fctchk || $opchk ) )
                         ? ( 'selected="yes"' )
                         : ( NULL );

                    echo '<option value="' . base64_encode( $key ) . '" ' . $sel . '>' . $v . '</option>' . "\n";
                }

            echo '</select>' . "\n";

            echo '<input class="button" type="submit" value="' . translate ( 'G O' ) . '"></input>' . "\n";

        echo '</p>' . "\n";

    echo '</form>' . "\n";

}  // End Function

/**
 *
 *
 *
 */

function modNav()
{
    @( $mod_menu = include _DP_ADMIN_ . 'menu' . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'menu_mod.array.php' )
      OR goBack( translate( 'Include Error' ) );

    if ( ! _ADMIN_TRUSTED )
    {
        unset( $mod_menu['op=mod_users'], $mod_menu['fct=dbutil'] );

        $admin_ary = array
        (
            'op=submissions' => array( 'article', 'topic', 'right' )
          , 'op=ForumAdmin' => array( 'forum', 'guestbook' )
          , 'fct=blocks' => array( 'left', 'main', 'partner', 'survey', 'ephem', 'head' )
          , 'op=links' => array( 'link', 'section', 'faq', 'download', 'reviews', 'mpn', 'user' )
        );

        foreach ( $admin_ary as $key => $v )
        {
            $access = (bool)FALSE;

            foreach( $v AS $sec )
            {
                if ( $GLOBALS['ainf'][ $sec ] )
                {
                    $access = (bool)TRUE;
                    break;
                }
            }

            if ( ! $access ) { unset( $mod_menu[ $key ] ); }
        }
    }

    if ( empty( $mod_menu ) ) { goBack( translate( 'Insufficient Rights' ) ); }

    echo '<form action="admin.php" method="get">' . "\n";

       echo '<p class="forms">' . "\n";

            echo '<h3>' . translate( 'Module Configuration' ) . '</h3>' . "\n";

            echo '<select name="alk" onchange="submit()">' . "\n";

                foreach ( $mod_menu AS $key => $v )
                {
                    $fctchk = ( isset( $_REQUEST['fct'] ) && (bool)FALSE !== @strpos( $key, $_REQUEST['fct'] ) );
                    $opchk = ( isset( $_REQUEST['op'] ) && (bool)FALSE !== @strpos( $key, $_REQUEST['op'] ) );

                    $sel = ( $_SERVER['QUERY_STRING'] == $key || ( $fctchk || $opchk ) )
                         ? ( 'selected="yes"' )
                         : ( NULL );

                     echo '<option value="' . base64_encode( $key ) . '" ' . $sel . '>' . $v . '</option>' . "\n";
                }

            echo '</select>' . "\n";

            echo '<input class="button" type="submit" value="' . translate ( 'G O' ) . '"></input>' . "\n";

        echo '</p>' . "\n";

    echo '</form>' . "\n";

}  // End Function

?>