<?php

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

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

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

// +----------------------------------------------------------------------+
// | MPN 188 Admin Administration                                         |
// +----------------------------------------------------------------------+
// | VERSION: 0.1 Alpha                                                   |
// +----------------------------------------------------------------------+
// | LICENSE: GPL 2.0 (see docs/LICENSE_GPL)                              |
// |                                                                      |
// | This file is part of MPN 188_8 Administration.                       |
// |                                                                      |
// | MPN 188_8 Administration 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 188_8 Administration 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 188_8 Administration; 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 188_8 Administration.                   |
// | 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 users
 * @category administrators
 * @version $Id: manageAdmins.php,v 1.1.2.9 2004/08/15 12:58:18 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/
 * @todo finish CSS & XHTML conversion
 * @todo reformat old style formatted code to new coding style
 * @todo finish and check function comments
 *
 * @tutorial
 * @filesource
 */

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


/**
 *
 *
 *
 */

function displayAdmins()
{
    global $mpnTables;

    $sql = 'SELECT aid, name, email, url, counter, radminsuper, uid
            FROM ' . $mpnTables['authors'];

    if ( ! @( $result = mysql_query( $sql ) ) && ! @mysql_data_seek( $result, 0 ) )
    {
        goBack( 'Query Failed' . '**' . __FILE__ . '***' .  __LINE__ );
    }

    for ( $i = 1; $i <= mysql_num_rows( $result ); $i++ )
    {
        $curr_list[ $i ] = mysql_fetch_row( $result );

        if ( $curr_list[ $i ][6] != 0 )
        {
            $sql = 'SELECT uname FROM ' . $mpnTables['users'] . ' WHERE uid = ' . $curr_list[ $i ][6];

            if ( ! @( $result1 = mysql_query( $sql ) ) && ! @mysql_data_seek( $result1, 0 ) )
            {
                goBack( 'Query Failed' . '**' . __FILE__ . '***' .  __LINE__ );
            }

            $tmp = mysql_fetch_row( $result1 );
            $curr_list[ $i ][6] = $tmp[0];
        }
    }

    echo "<div id='manageadmins'>\n";

	echo "<h1>" . translate( 'MPN Administrators' ) . "<br />" . translate( 'For Version' ) . " " . _MPN_VERSION_ . "</h1>\n";

   	echo "<br />\n";

   	echo '<h2><a href="./admin.php?fct=manageAdmins&amp;op=editadmin&amp;action=1" title="' . translate( 'Add A New Administrator' ) . '">' . translate( 'Add A New Administrator' ) . '</a></h2>';

    echo "<hr class='w80' />\n";

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

	echo "<table class='simpleborders' summary=''>\n";

		echo "<tr>\n";

			echo '<th>' . translate ( 'Login Name' ) . '</th>' . "\n";
			echo '<th>' . translate ( 'Assoc. User' ) . '</th>' . "\n";
			echo '<th>' . translate ( 'Super' ) . '</th>' . "\n";
			echo '<th>' . translate ( 'Real Name' ) . '</th>' . "\n";
			echo '<th>' . translate ( 'Contact' ) . '</th>' . "\n";
			echo '<th>' . translate ( 'Article Posts' ) . '</th>' . "\n";
			echo '<th>' . translate ( 'Functions' ) . '</th>' . "\n";

		echo "</tr>\n";

		foreach ( $curr_list as $v )
		{
			echo "<tr>\n";

			echo "<td class='center'><b>$v[0]</b></td>\n";
			echo "<td class='center'><b>$v[6]</b></td>\n";
			echo "<td class='center'>\n";
                echo ( $v[5] == 1 ) ? ( translate( 'Yes' ) ) : ( translate( 'No' ) );
            echo "</td>\n";
			echo "<td class='center'>$v[1]</td>\n";
			echo "<td class='center'>\n";

			if ( isset( $v[2] ) && $v[2] != '' )
            {
                echo '&nbsp;&nbsp;<a href="mailto:' . $v[2] . '"><img src="' . _MPN_ROOT_URI . 'images/forum/icons/email.gif" alt="' . translate( 'Send Email To' ) . ' ' . $v[0] . '" ' . _T_NN4_BORDER . ' /></a>' . "\n";
            }

            if ( isset( $v[3] ) && $v[3] != '' )
            {
                if ( strstr( 'http://', $v[3] ) )
                {
                    $v[3] = 'http://' . $v[3];
                }

                echo '&nbsp;&nbsp;<a href="' . $v[3] . '" target="_blank"><img src="' . _MPN_ROOT_URI . 'images/forum/icons/homepage.gif" alt="' . translate( 'Go To' ) . ' ' . $v[0] . '\'s ' . translate( 'Website' ) . '" ' . _T_NN4_BORDER . ' /></a>' . "\n";
            }

			echo "</td><td class='center'>$v[4]</td><td class='center' colspan='2'>\n";

    			echo "<a href='admin.php?fct=manageAdmins&amp;op=editadmin&amp;admin_id=$v[0]&amp;action=2' title='" . translate( "Edit Administrator" ) . "'>" . translate( "Edit" ) . "</a>\n";

    			echo "&nbsp;|&nbsp;<a href='admin.php?fct=manageAdmins&amp;op=saveadmin&amp;admin_id=$v[0]&amp;action=3' title='" . translate( "Delete Administrator" ) . "' onClick='confirmAction()'>" . translate( "Delete" ) . "</a>\n";

			echo "</td></tr>\n";
       }

    echo "</table>\n";

	echo "<br />\n";

	//CloseTable();

	echo "</div>\n";

}  // End Function

/**
 *
 *
 *
 */

function editAdmin()
{
    global $mpnTables;

    $action =(int)$_REQUEST['action'];
    $aid = $GLOBALS['ainf']['uname'];
    $labelcss = 'style="width: 20%;"';
    $formcss = '';
    $note = '<em class="warn">&#042;&nbsp;</em>' . translate( 'Indicates Required Field' );

    echo "<div id='manageadmins'>\n";

    switch ( $action )
    {
        case 1: // Add Admin

            $title = translate( 'Adding New Administrator' );
            $subtitle = NULL;

            $data1 = NULL;

            $data2 = array ( 1, 0, 0, 0, 0, 0, 0, 0, 0 );

            $data3 = array ( 0, 0, 0, 0, 0, 0, 0, 0, 0 );

            $admin_tmp['radminsuper'] = 0;

        break;

        case 2: // Edit Admin

            $sql = 'SELECT *
                    FROM ' . $mpnTables['authors'] . '
                    WHERE aid = "' . $_REQUEST['admin_id'] . '"';

            if ( ! @( $result = mysql_query( $sql ) ) && ! @mysql_data_seek( $result, 0 ) )
            {
                goBack( 'Query Failed' . '**' . __FILE__ . '***' .  __LINE__ );
            }

            $admin_tmp = mysql_fetch_assoc( $result );

            $data1 = array( $admin_tmp['aid'], $admin_tmp['email'], $admin_tmp['name'], $admin_tmp['url'] );

            $data2 = array( $admin_tmp['radminarticle'], $admin_tmp['radmintopic'], $admin_tmp['radminright'], $admin_tmp['radminmain'], $admin_tmp['radminleft'], $admin_tmp['radminhead'], $admin_tmp['radminephem'], $admin_tmp['radminpartner'], $admin_tmp['radminsurvey'] );

            $data3 = array( $admin_tmp['radminforum'], $admin_tmp['radminguestbook'], $admin_tmp['radminuser'], $admin_tmp['radminsection'], $admin_tmp['radminlink'], $admin_tmp['radminfaq'], $admin_tmp['radmindownload'], $admin_tmp['radminreviews'], $admin_tmp['radminmpn'] );

            $title = translate( 'Editing Administrator' ) . '&nbsp;<i>' . $admin_tmp['aid'] . '</i>';
            $subtitle = "<a class='subtitle1' href='./admin.php?fct=manageAdmins&op=setpass&aid=" . $admin_tmp['aid'] . "' title='" . translate( "Change Pass" ) . "'>" . translate( "Change" ) . "&nbsp;<i>" . $admin_tmp['aid'] . "'s</i>&nbsp;" . translate( "Password" ) . "</a>\n";

        break;

    } // End Switch

    echo '<h1>' . $title . '</h1><br />';
    echo $note;

    if ( ! empty( $subtitle ) )
    {
        echo '<br /><br />' . "\n";
        echo $subtitle;
    }

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

    echo "<form action='admin.php?fct=manageAdmins' method='post'>\n";

        echo "<input type='hidden' name='op' value='saveadmin'></input>\n";

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

        OpenTable();

        echo "<br /><p class='tabletitles'>" . translate( "Personal Information" ) . "</p><br />\n";

        $labelcss = 'style="width: 20%;"';
        $formcss = '';

        $opts = array ( 'aid', 'email', 'name', 'url' );

    	$label = array ( '<em class="warn">&#042;</em>&nbsp;' . translate( 'Nick Name' ), '<em class="warn">&#042;</em>&nbsp;' . translate( 'E-Mail' ), translate( 'Real Name' ), translate( 'Web Site' ) );
    	$val_text = NULL;
    	$para = array( 'size="35" maxlength="30"', 'size="55" maxlength="50"', 'size="65" maxlength="60"', 'size="65" maxlength="60"' );

    	// Output

    	echo $_SERVER['F_LIB'] -> formTextbox( $data1 , $opts , $val_text , $label , $para, $labelcss, $formcss ) . "\n";
    	unset ( $data1 , $opts , $val_text , $label , $para );

        $auid = ( $admin_tmp['uid'] == 0 && isset( $_COOKIE['user'] ) ) ? ( $GLOBALS['uinf']['uid'] ) : ( $admin_tmp['uid'] );

        $sql = 'SELECT uid, uname
                FROM ' . $mpnTables['users'] . '
                WHERE uid > 1
                ORDER BY uname ASC';

        $result = mysql_query( $sql );

        echo '<label>' . translate( 'Associate Admin With User' ) . '?</label>' . "\n";

        echo '<select class="formdata" name="uid">' . "\n";

            echo '<option value="0">' . translate( 'Select A User' ) . '</option>' . "\n";

            if ( (bool)FALSE != $result )
            {
                for ( $i = 0; $i < @mysql_num_rows( $result ); $i++ )
                {
                    if (    ! @mysql_data_seek( $result, $i )
                         || ! @( $tmp = mysql_fetch_row( $result ) ) )
                    {
                        continue;
                    }

                    $sel = ( $tmp[0] == $auid ) ? ( 'selected="yes"' ) : ( NULL );

                    echo '<option ' . $sel . ' value="' . $tmp[0] . '">' . $tmp[1] . '</option>' . "\n";
                }

                @mysql_free_result ( $result );
            }

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

        CloseTable();

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

        echo "<p class='subtitle1'>" . translate( "Administrative Section Permissions" ) . "</p>\n";

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

    	$labelcss = 'style="width: 50%;"';

        OpenTable();

        echo "<br /><p class='tabletitles'>" . translate( "Select Sections Or Choose SuperUser To Allow Access To All Sections" ) . "</p><br />\n";

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

        	echo "<span class='subtitle1'>" . translate( "Super User" ) . ":</span>&nbsp;&nbsp;\n";

        	$sel = ( isset( $admin_tmp ) && $admin_tmp['radminsuper'] == 1 ) ? ( 'checked="yes"' ) : ( '' );

            echo "<input type='checkbox' name='radminsuper' value='1' $sel />\n";

        echo "</div>\n";

        echo "<br /><hr class='w80' /><br />\n";

        echo "<table summary=''><tr><td>\n";

        $opts = array( 'radminarticle', 'radmintopic', 'radminright', 'radminmain', 'radminleft', 'radminhead', 'radminephem', 'radminpartner', 'radminsurvey' );

		$label = array( translate( 'Articles &amp; Topics' ), translate( 'Topics Only' ), translate( 'Auto Articles Only' ), translate( 'Center Blocks' ), translate( 'Side Blocks' ), translate( 'Headlines' ), translate( 'Ephemerids' ), translate( 'Partners' ), translate( 'Polls &amp; Surveys' ) );
		$val_text = array( 'Yes' , 'No' );
		$val = array( 1 , 0 );

		// OUTPUT

		echo $_SERVER['F_LIB'] -> formOption( $data2, $opts, $val_text, $val, $label, $type='radio', $labelcss, $formcss ) . "\n";
		unset ( $data2 , $opts , $val_text , $val , $label , $type );

		echo "</td><td>\n";

		$opts = array( 'radminforum', 'radminguestbook', 'radminuser', 'radminsection', 'radminlink', 'radminfaq', 'radmindownload', 'radminreviews', 'radminmpn' );

		$label = array( translate( 'Forums' ), translate( 'Guest Book' ), translate( 'eGallery' ), translate( 'Sections' ), translate( 'Links' ), translate( 'FAQs'), translate( 'Downloads' ), translate( 'Reviews' ), translate( 'My Yellow Pages' ) );
		$val_text = array( 'Yes' , 'No' );
		$val = array( 1 , 0 );

		// OUTPUT

		echo $_SERVER['F_LIB'] -> formOption( $data3, $opts, $val_text, $val, $label, $type='radio', $labelcss, $formcss ) . "\n";
		unset ( $data3 , $opts , $val_text , $val , $label , $type );

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

		echo "<br />\n";

		CloseTable();

	    if ( $action != 1 )
	    {
	        echo "<input type='hidden' name='aid' value='" . $admin_tmp['aid'] . "'></input>\n";
	        echo "<input type='hidden' name='action' value='2'></input>\n";
	    }
	    else
	    {
	        echo "<input type='hidden' name='action' value='1'></input>\n";
	    }

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

        echo "<div class='submit'>\n";

	   	    echo "<input class='button' type='submit' value='" . translate ( "Save Changes" ) ."'>\n";

        echo "</div>\n";

	   	echo "</p>\n";

	echo "</form>\n";

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

    permHints();

}  // End Function

/**
 *
 *
 *
 */

function setPass()
{
    global $minpass;

    $labelcss = 'style="width: 40%;"';
    $formcss = '';

    if ( isset( $_REQUEST['new'] ) )
    {
        echo "<h1>" . translate ( 'Set The Password For' ) . "&nbsp<i>" . $_REQUEST['aid'] . "</i></h1><br />\n";
    }
    else
    {
        echo "<h1>" . translate ( 'Change Password For' ) . "&nbsp<i>" . $_REQUEST['aid'] . "</i></h1><br />\n";
    }

	echo "<span class='label'>" . translate ( "NOTE:  Clicking on the <i>Change Pass</i> Button Will ONLY Change The Password" ) . "<br /><br />" . translate( "Passwords MUST be set separately" ) . "</span>\n";

	echo "<hr class='w80' /><br />\n";

	OpenTable();

	echo "<br />\n";

	echo "<h2>" . translate ( 'Enter YOUR Password And New Password For' ) . "&nbsp;" . $_REQUEST['aid'] . "\n";

	echo "<br />\n";

	echo "<span class='label'>(&nbsp;" . translate ( 'Minimum Password Length' ) . ": $minpass&nbsp;)</span></h2>\n";

	echo "<br />\n";

	echo "<form name='cPass'  action='admin.php?fct=manageAdmins' method='post'>\n";

	echo "<input type='hidden' name='op' value='saveadmin'></input>\n";

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

   			echo "<table summary=''><tr><td class='formlabel' $labelcss>\n";

   				echo "" . translate ( "Your Password For Confirmation" ) . ":&nbsp;\n";

   			echo "</td><td class='formoption' $formcss>\n";

   				echo "<input type='password' name='pass' size='10' maxlength='20'></input>\n";

   			echo "</td></tr><tr><td class='formlabel' $labelcss>\n";

				echo "" . translate ( "New Password For" ) . "&nbsp;" . $_REQUEST['aid'] . ":&nbsp;\n";

			echo "</td><td class='formoption' $formcss>\n";

   				echo "<input type='password' name='vpass' size='10' maxlength='20'></input>\n";

   			echo "</td></tr><tr><td class='formlabel'>\n";

				echo "" . translate ( "Confirm New Password" ) . ":&nbsp;\n";

   			echo "</td><td class='formoption' $formcss>\n";

   				echo "<input type='password' name='cvpass' size='10' maxlength='20'></input>\n";

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

		    echo "<input type='hidden' name='action' value='4'></input>\n";
		    echo "<input type='hidden' name='aid' value='" . $_REQUEST['aid'] . "'></input>\n";

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

		   	    echo "<input class='button' type='submit' value='" . translate ( "Change Pass" ) . "'>\n";

            echo "</div>\n";

   		echo "</p>\n";

	echo "</form>\n";

	echo "<br />\n";

	CloseTable();

    echo "</div>\n";

}  // End Function

/**
 *
 *
 *
 */

function saveAdmin()
{
	global $mpnTables;

	if ( ! isset( $_POST['radminsuper'] ) ) { $_POST['radminsuper'] = '0'; }
	if ( $_POST['radminleft'] == 1 ) { $_POST['radminright'] = '1'; }

    $remove_keys = array( 'op', 'action' );
    $action = (int)$_REQUEST['action'];

	switch ( $action )
	{
	    case 1: // New Admin

    	    $allow = 26;

            if ( ! is_array( ( $admin_tmp = $_SERVER['F_LIB'] -> checkPostVars( $remove_keys, $allow ) ) ) )
            {
                goBack( $admin_tmp . '**' . __FILE__ . '***' .  __LINE__ );
                exit;
            }

    	    // Check Submitted Data

    	    checkNewAdmin( $admin_tmp );

            @mysql_query( 'LOCK TABLES ' . $mpnTables['authors'] . ' WRITE' );

            if ( ! @mysql_query( "INSERT INTO " . $mpnTables['authors'] . " SET aid = '" . $admin_tmp['aid'] . "'" ) )
            {
                 @mysql_query( 'UNLOCK TABLES' );
                 goBack( translate( 'Insert Query Failed' ) . '**' . __FILE__ . '***' .  __LINE__ );
                 exit;
            }

            foreach ( $admin_tmp AS $key => $v )
            {
                if ( $key != 'aid' && isset( $v ) && $v != '' )

                if ( ! @mysql_query( "UPDATE " . $mpnTables['authors'] . " SET $key = '" . $v . "' WHERE aid = '" . $admin_tmp['aid'] . "'" ) )
                {
                    @mysql_query( 'UNLOCK TABLES' );
                    goBack( 'Update Query Failed' . '**' . __FILE__ . '***' .  __LINE__ );
                    exit;
                }
        	}

        	mysql_query( 'UNLOCK TABLES' );

        	$_SERVER['F_LIB'] -> redirectRequest( "admin.php?fct=manageAdmins&op=setpass&aid=" . $admin_tmp['aid'] . "&new=1" );
        	exit;

        break;


	    case 2: // Save Edited Admin

            $allow = 26;

            if ( ! is_array( ( $admin_tmp = $_SERVER['F_LIB'] -> checkPostVars( $remove_keys, $allow ) ) ) )
            {
                goBack( $admin_tmp );
                exit;
            }

            if ( ! $_SERVER['F_LIB'] -> checkDBField( 'authors', 'aid', $admin_tmp['aid'] ) )
            {
                goBack( translate( 'Cannot Find Admin In Database' ) );
                exit;
            }

            @mysql_query( 'LOCK TABLES ' . $mpnTables['authors'] . ' WRITE' );

            foreach ( $admin_tmp AS $key => $v )
            {
                if ( isset( $v ) && $v != '' )
                {
                    if ( ! @mysql_query( "UPDATE " . $mpnTables['authors'] . " SET $key = '$v' WHERE aid = '" . $admin_tmp['aid'] . "'" ) )
                    {
                        @mysql_query( 'UNLOCK TABLES' );
                        goBack( 'Update Query Failed' . '**' . __FILE__ . '***' .  __LINE__ );
                        exit;
                    }
               }
            }

            @mysql_query( 'UNLOCK TABLES' );

        break;


        case 3: // Delete Admin

            $allow = 3;

            if ( ! is_array( $admin_tmp = $_SERVER['F_LIB'] -> checkPostVars( $remove_keys, $allow ) ) )
            {
                goBack( $admin_tmp );
                exit;
            }

            $sql = "DELETE
                    FROM " . $mpnTables['authors'] . "
                    WHERE aid = '" . $_REQUEST['admin_id'] . "'";

            @mysql_query( 'LOCK TABLES ' . $mpnTables['authors'] . ' WRITE' );

            if ( ! @mysql_query( $sql ) )
            {
                @mysql_query( 'UNLOCK TABLES' );
                goBack( 'Delete Query Failed' . '**' . __FILE__ . '***' .  __LINE__ );
                exit;
            }

            @mysql_query( 'UNLOCK TABLES' );

        break;


        case 4: // Save Password

            $allow = 7;

            if ( ! is_array( ( $admin_tmp = $_SERVER['F_LIB'] -> checkPostVars( $remove_keys, $allow ) ) ) )
            {
                goBack( $admin_tmp );
                exit;
            }

            $check_ary = array( $admin_tmp['pass'], $admin_tmp['vpass'], $admin_tmp['cvpass'] );

            $verify_check_ary = $_SERVER['SAN'] -> verifyContent( $check_ary, 3 );

            if ( in_array( (bool)FALSE, $verify_check_ary ) )
            {
                goBack( translate( 'You Failed To Include Required Information' ) );
                exit;
            }

            if ( $admin_tmp['vpass'] !== $admin_tmp['cvpass'] )
            {
                goBack( translate( "New Password Mis-Match" ) );
                exit;
            }

            $sql = "SELECT (pwd = '" . md5( $admin_tmp['pass'] ) . "')
                    FROM " . $mpnTables['authors'] . "
                    WHERE aid = '" . $GLOBALS['ainf']['uname'] . "'";

            if ( ! @( $result = mysql_query( $sql ) ) && ! @mysql_data_seek( $result, 0 ) )
            {
                goBack( translate( 'ACCESS DENIED!! Cannot Verify Your Identity' ) . '**' . __FILE__ . '***' .  __LINE__ );
            }

            $sql = "SELECT aid FROM " . $mpnTables['authors'] . " WHERE aid = '" . $admin_tmp['aid'] . "'";

            if ( ! @( $result = mysql_query( $sql ) ) && ! @mysql_data_seek( $result, 0 ) )
            {
                goBack( translate( 'Cannot Find Admin In Database' ) . '**' . __FILE__ . '***' .  __LINE__ );
            }

            $save_admin = mysql_fetch_row( $result );

            @mysql_query( 'LOCK TABLES ' . $mpnTables['authors'] . ' WRITE' );

            $sql = 'UPDATE ' . $mpnTables['authors'] . '
                    SET pwd = "' . md5( $admin_tmp['vpass'] ) . '"
                    WHERE aid = "' . $save_admin[0] . '" LIMIT 1';

            if ( ! @mysql_query( $sql ) )
            {
                mysql_query( 'UNLOCK TABLES' );
                goBack( translate( 'Update Query Failed' ) . '**' . __FILE__ . '***' .  __LINE__ );
            }

            @mysql_query( 'UNLOCK TABLES' );

        break;

    } // End Switch

    $_SERVER['F_LIB'] -> redirectRequest( 'admin.php?fct=manageAdmins&op=mod_authors' );

}  // End Function

/**
 *
 *
 *
 */

function checkNewAdmin( $ary )
{
    // Check For Empty

    $check_ary = array( $ary['aid'], $ary['email'] );

    $verify_check_ary = $_SERVER['SAN'] -> verifyContent( $check_ary, 3 );

    if ( in_array( (bool)FALSE, $verify_check_ary ) )
    {
        goBack( translate( 'You Failed To Include Required Information' ) );
        exit;
    }

    // Check URL

    if ( isset( $ary['url'] ) && $ary['url'] != '' && ! $_SERVER['SAN'] -> verifyContent( $ary['url'], 1 ) )
    {
        goBack( translate( 'Invalid URL' ) );
        exit;
    }

    // Check Nick

    if ( $_SERVER['F_LIB'] -> checkDBField( 'authors', 'aid', $ary['aid'] ) )
    {
        goBack( translate( 'Invalid User Nickname.  Name Already Taken.' ) );
        exit;
    }

    // Check Email

    if ( ! $_SERVER['SAN'] -> verifyContent( $ary['email'], 2 ) || $_SERVER['F_LIB'] -> checkDBField( 'authors', 'email', $ary['email'] ) )
    {
        goBack( translate( 'Invalid Email Or Email Already Taken' ) );
        exit;
    }

    return;

}  // End Function

function permHints()
{
    echo '<h3>' . translate ( 'Administrative Permissions Explained' ) . '</h3>' . "\n";

    echo '<p class="subtitle2">' . translate( 'The following lists show sections each administrator will have access to if enabled' ) . '&#046;<br />' . translate( 'Super Admins have access to all administrative sections' ) . '&#046;</p>' . "\n";

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

    echo '<table summary="Admin Permissions Explained"><tr class="top"><td class="w50">' . "\n";

        echo '<h4 class="indent15">' . translate ( 'Articles &amp; Topics' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Article Management (edit / delete)' );
                echo '<li />' . translate( 'Topic Management (create / edit / delete)' );
                echo '<li />' . translate( 'Manage Article Submissions (approve / deny)' );
                echo '<li />' . translate( 'Create New Administrative Articles' );
                echo '<li />' . translate( 'Create New Administrative Automated Articles' );
                echo '<li />' . translate( 'Article Comments Management (delete)' );

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

        echo '<h4 class="indent15">' . translate ( 'Topics Only' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Topic Management' );

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

        echo '<h4 class="indent15">' . translate ( 'Auto Articles Only' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Create New Administrative Automated Articles' );

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

        echo '<h4 class="indent15">' . translate ( 'Center Blocks' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Center Blocks Configuration' );
                echo '<li />' . translate( 'My Message II' );
                echo '<li />' . translate( 'Header Banners (NOT random banners)' );

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

        echo '<h4 class="indent15">' . translate ( 'Side Blocks' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'All Left and Right Side Blocks' );
                echo '<li />' . translate( 'Random Banners Block' );
                echo '<li />' . translate( 'Quote Of The Day Block' );
                echo '<li />' . translate( 'Headlines Block' );
                echo '<li />' . translate( 'Partners Block' );
                echo '<li />' . translate( 'Ephemerids Block' );
                echo '<li />' . translate( 'Survey / Poll Block' );

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

        echo '<h4 class="indent15">' . translate ( 'Headlines' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Headlines Block Only' );

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

        echo '<h4 class="indent15">' . translate ( 'Ephemerids' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Ephemerids Block Only' );

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

        echo '<h4 class="indent15">' . translate ( 'Partners' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Partners Block Only' );

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

        echo '<h4 class="indent15">' . translate ( 'Polls &amp; Surveys' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Polls & Surveys Block Only' );
                echo '<li />' . translate( 'Survey / Poll Comments Management (delete)' );

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


        echo '</td><td class="w50">' . "\n";


        echo '<h4 class="indent15">' . translate ( 'Forum' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Forum Management' );
                echo '<li />' . translate( 'Forum Configuration' );
                echo '<li />' . translate( 'Forum Access' );
                echo '<li />' . translate( 'Forum Ranks' );
                echo '<li />' . translate( 'Emoticons (smiles)' );
                echo '<li />' . translate( 'Guest Book Configuration' );

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

        echo'<h4 class="indent15">' . translate ( 'Guest Book' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Guest Book Configuration Only' );

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

        echo '<h4 class="indent15">' . translate ( 'eGallery' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'eGallery Management &amp; Configuration' );

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

        echo '<h4 class="indent15">' . translate ( 'Sections' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Special Sections Management' );

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

        echo '<h4 class="indent15">' . translate ( 'Links' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Web Links Management' );

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

        echo '<h4 class="indent15">' . translate ( 'FAQs' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Frequently Asked Question Management' );

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

        echo '<h4 class="indent15">' . translate ( 'Downloads' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Downloads Management &amp; Configuration' );

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

        echo '<h4 class="indent15">' . translate ( 'Reviews' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'Reviews Management' );

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

        echo '<h4 class="indent15">' . translate ( 'My Yellow Pages' ) . '</h4>' . "\n";

            echo '<ul class="indent30">' . "\n";

                echo '<li />' . translate( 'My Yellow Pages Management' );

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

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

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

    echo '<p><b>' . translate( 'Advanced Users Note' ) . '</b>: ';
    echo translate( 'A break down of the database field assignments can be found in ./admin/menu/perms.txt' ) . '</p>' . "\n";

} // End Function


switch ( $_REQUEST['op'] )
{
    case "mod_authors":

        displayAdmins();

    break;

    case "editadmin":

        editAdmin();

    break;

    case "saveadmin":

        saveAdmin();

    break;

    case "setpass":

        setPass();

    break;

    DEFAULT: displayAdmins(); break;

} // End Switch


?>