<?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 Database Administration                                      |
// |                                                                      |
// | -> Entry Point To Database Administration                            |
// +----------------------------------------------------------------------+
// | 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 database
 * @version $Id: dbMaint.php,v 1.1.2.6 2004/08/15 12:58:16 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 ) *****

$return_link = "<a class='subtitle1' href='./admin.php?fct=dbutil' title='" . translate( "Return To Database Utilities" ) . "'>" . translate( "Return To Database Utilities" ) . "</a>\n";

/**
 *
 *
 *
 */

function dbMaint()
{
    echo "<div class='center'>\n";

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

        echo "<label class='subtitle1'>" . translate( "Optimize Your Database Tables Now" ) . "</label>\n";

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

        echo "<input type='hidden' name='op' value='optimizeDB'></input>\n";
        echo "<input class='button' type='submit' value='" . translate( "Optimize DB" ) . "'></input>\n";

        echo "</form>\n";

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

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

        echo "<label class='subtitle1'>" . translate( "Repair Your Database Tables Now" ) . "</label>\n";

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

        echo "<input type='hidden' name='op' value='repairDB'></input>\n";
        echo "<input class='button' type='submit' value='" . translate( "Repair DB" ) . "'></input>\n";

        echo "</form>\n";

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

        echo "<h2>NOTE:</h2>\n";

        echo "<p>" . translate( "It Is Only Necessary To Perform Table Repairs If You Are Having Problems With Your Database Tables" ) . ".<br />" . translate( "For Example, Like Sudden Unexplained Database Errors" ) . ".</p><br />\n";

        echo "</div>\n";

}  // End Function

/**
 *
 *
 *
 */

function optimizeDB()
{
    global $mpnTables, $return_link;

    foreach( $mpnTables as $v )
    {
        mysql_query( 'OPTIMIZE TABLE ' . $v );
    }

    echo "<h1>" . translate( "Database Optimization Is Complete" ) . "</h1>\n";

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

    echo $return_link;

}  // End Function

/**
 *
 *
 *
 */

function repairDB()
{
    global $mpnTables, $return_link;

    foreach( $mpnTables as $v )
    {
        mysql_query( 'REPAIR TABLE ' . $v );
    }

    echo "<h1>" . translate( "Database Repair Is Complete" ) . "</h1>\n";

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

    echo $return_link;

}  // End Function

?>