<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* Copyright (c) 2001 by Thomas Rudant (thomas.rudant@grunk.net)        */
/* http://www.grunk.net                                                 */
/* http://www.securite-internet.org                                     */
/*                                                                      */
/* This program 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.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}

global $admin_file;
$aid = substr("$aid", 0,25);
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `radminsuper` FROM `".TABLE_AUTHORS."` WHERE `aid`='$aid'"));
$acces = $GLOBALS['db']->XMFbin($row['radminsuper']);
if (!$acces == 1) { die ("Acces denied"); }
if($admintest && $adminsecu)  {

define('DATABASE_MAX', true);
get_adminlang("database");

function menu() {
global $admin_file;
if (is_file('kernel/popup.php')) {
include_once('kernel/popup.php');}
if (is_file('kernel/addons/convert_size.php')) {
include_once('kernel/addons/convert_size.php');}
        Max_OpenTable();
        echo "<center><a href=\"".$admin_file.".php?op=database\"><font class='title'><b>"._DB_DATADASE_TITLE."</b></font></a></center>"
            ."<center><a href=\"".$admin_file.".php?op=BackupDBgz_file\">"._DB_SAVEDBFILE."</a> - "
            ."<a href=\"".$admin_file.".php?op=BackupFilegz_file\">"._DB_SAVEWEBSITEFILE."</a><br />"
	    ."<a href=\"".$admin_file.".php?op=OptimizeDB\">"._DB_OPTIMIZEDB."</a> - <a href=\"".$admin_file.".php?op=Backup_Instant\">"._DB_BACKUPINSTANT."</a><br / ><a href=\"".$admin_file.".php?op=mysqltap\">"._DB_MYSQLTAP."</a></center>";
        br('1');
        Max_CloseTable();
}

function status() {
global $cache, $admin_file;
br('1');
Max_OpenTable();
echo "<center><b>"._DB_GESTIONDATABASE."</b></center><br />"
    ."<table width=\"100%\" border=\"1\">"
    ."<tr><td></td><TD bgcolor=\"$bgcolor1\"><b>"._NAME."</b></td><td bgcolor=\"$bgcolor1\"><b>"._SIZE."</b></td><td bgcolor=\"$bgcolor1\"><b>"._DATE."</b></td></tr>";
$dir = dir(''.$cache.'/Backups/Database');
while ( $namefile = $dir->read() ) {

if ($namefile === '.' OR $namefile === '..' OR $namefile === '.htaccess' OR $namefile === 'index.html' OR $namefile === 'index.php') continue;

$filesizenamefile = filesize(''.$cache.'/Backups/Database/'.$namefile.'');
$datenamefile = filemtime(''.$cache.'/Backups/Database/'.$namefile.'');
$datenamefile = date('d.m.Y H:m:s', $datenamefile);
echo "<tr><td><a href=\"".$admin_file.".php?op=DeleteBackupDB&amp;filename=$namefile\"><img src=\"images/no.png\" alt=\""._DELETE."\" title=\""._DELETE."\" border=\"0\" /></a>";
br('1');

echo "<a href=\"".$cache."/Backups/Database/".$namefile."\"><img src=\"images/view.gif\" alt=\""._SHOW."\" title=\""._SHOW."\" border=\"0\" width=\"17\" height=\"17\" /></a>"
    ."</td><td>  $namefile</td><td>".convert_size($filesizenamefile)."</td><td> $datenamefile</td></tr>";
}
$dir->close() ;
clearstatcache();
echo "</table>";
Max_CloseTable();
br('1');
Max_OpenTable();
echo "<center><b>"._DB_GESTIONPHPFILES."</b></center><br />"
    ."<table width=\"100%\" border=\"1\">"
	."<tr><td></td><TD bgcolor=\"$bgcolor1\"><b>"._NAME."</b></td><TD bgcolor=\"$bgcolor1\"><b>"._SIZE."</b></td><td bgcolor=\"$bgcolor1\"><b>"._DATE."</b></td></tr>";
$dir = dir(''.$cache.'/Backups/Files');
while ( $namefile = $dir->read() ) {

if ($namefile === '.' OR $namefile === '..' OR $namefile === '.htaccess' OR $namefile === 'index.html' OR $namefile === 'index.php') continue;

$filesizenamefile = filesize(''.$cache.'/Backups/Files/'.$namefile.'');
$datenamefile = filemtime(''.$cache.'/Backups/Files/'.$namefile.'');
$datenamefile = date('d.m.Y H:m:s', $datenamefile);
echo "<tr><td><a href=\"".$admin_file.".php?op=DeleteBackupFiles&amp;filename=$namefile\"><img src=\"images/no.png\" alt=\""._DELETE."\" title=\""._DELETE."\" border=\"0\" /></a>";
br('1');

echo "<a href=\"".$cache."/Backups/Files/".$namefile."\"><img src=\"images/view.gif\" alt=\""._SHOW."\" title=\""._SHOW."\" border=\"0\" width=\"17\" height=\"17\" /></a>"
    ."</td><td>  $namefile</td><td>".convert_size($filesizenamefile)."</td><td> $datenamefile</td></tr>";
}
$dir->close() ;
clearstatcache();
echo "</table>";
Max_CloseTable();
br('1');
}

switch($op) {
case 'ListingDB':include_once('admin/modules/database/ListingDB.php');break;
case 'BackupDBgz_file':include_once('admin/modules/database/BackupDBgz_file.php'); break;
case 'BackupFilegz_file':include_once('admin/modules/database/BackupFilegz_file.php'); break;
case 'BackupDBgz':include_once('admin/modules/database/BackupDBgz.php'); break;
case 'BackupDB':include_once('admin/modules/database/BackupDB.php');break;
case 'database':include_once('admin/modules/database/homedatabase.php');break;
case 'OptimizeDB':
case 'CheckDB':
case 'AnalyzeDB':
case 'RepairDB':
case 'StatusDB':
include_once('admin/modules/database/operations_database.php');
break;
case 'RestoreDB':include_once('admin/modules/database/RestoreDB.php');break;
case 'DeleteBackupDB':include_once('admin/modules/database/DeleteBackupDB.php');break;
case 'DeleteBackupFiles':include_once('admin/modules/database/DeleteBackupFiles.php');break;
case 'OptimizeDB':include_once('admin/modules/database/OptimizeDB.php');break;
case 'Backup_Instant':include_once('admin/modules/database/Backup_Instant.php');break;
case 'mysqltap':
case 'mtshowtable':
case 'mtbrowse':
case 'mtoptimize':
case 'mtrepair':
case 'SubmitSQL':
case 'mtsqlimport':
case 'editor_table':
case 'SaveTable':
include_once('admin/modules/database/mysqltap.php');
break;
}
}else {
	echo "Access Denied";
}