}
$OnlineUserArray = _APCMS_GetUserOnline('indexstats');
if (!($lastbackup = _APCMS_GetLastBackup())) {
    $LASTBACKUPTIME = "<span style=\"color:red\"><b><blink>Noch kein Backup!</blink></b></span>";
    $LASTBACKUPFILE = "<span style=\"color:red\"><b>--</b></span>";
} elseif ($lastbackup['time'] <= $akt_time - 604800) {
    $LASTBACKUPTIME = "<span style=\"color:red\"><blink>" . _APCMS_FormattedDateTime($lastbackup['time']) . "</blink></span>";
    $LASTBACKUPFILE = "<span style=\"color:red\">" . _APCMS_SpecialChars($lastbackup['file']) . "</span>";
} else {
    $LASTBACKUPTIME = _APCMS_FormattedDateTime($lastbackup['time']);
    $LASTBACKUPFILE = _APCMS_SpecialChars($lastbackup['file']);
}
require_once $_SESSION['APCMS']['CLASS_DIR'] . "/apcms_admintable.class." . $_SESSION['APCMS']['SUFFIX'];
$ADMINTABLE1 = new APCMS_ADMINTABLE($_SESSION['APCMS']['TABLE']['BGCOLOR'], $_SESSION['APCMS']['HELPSYSTEM']['BGCOLOR'], $_SESSION['APCMS']['HELPSYSTEM']['FGCOLOR']);
$ADMINTABLE1->AddRow('<strong>Versions-Information</strong>', '', 2);
$ADMINTABLE1->AddRow('<strong>APCMS-Version</stron>', ($NEWVERSION != "" ? $NEWVERSION . "&nbsp; &nbsp;" : "") . ' <strong>' . _APCMS_version() . '</stron>');
$ADMINTABLE1->AddRow('PHP-Version', phpversion());
$ADMINTABLE1->AddRow('MySQL-Version', $db->mysqlversion());
$ADMINTABLE1->AddRow('GDLib-Version', _APCMS_getGDVersion());
$CONTENTINHALT .= $ADMINTABLE1->GetTable() . "<br />";
$ADMINTABLE2 = new APCMS_ADMINTABLE($_SESSION['APCMS']['TABLE']['BGCOLOR'], $_SESSION['APCMS']['HELPSYSTEM']['BGCOLOR'], $_SESSION['APCMS']['HELPSYSTEM']['FGCOLOR']);
$ADMINTABLE2->AddRow('<strong>System-Information</strong>', '', 2);
$ADMINTABLE2->AddRow('Date', $ACTUALTIME_FORMATTED);
$ADMINTABLE2->AddRow('Install-Date', _APCMS_FormattedDateTime($akt_installdate));
$ADMINTABLE2->AddRow('Letztes Backup vom', $LASTBACKUPTIME);
$ADMINTABLE2->AddRow('Letztes Backup', $LASTBACKUPFILE);
$ADMINTABLE2->AddRow('reg. User', _APCMS_RegUsersNum());
$ADMINTABLE2->AddRow('User Online', $OnlineUserArray['useronline_onlinenum']);
$CONTENTINHALT .= $ADMINTABLE2->GetTable() . "<br />";
$ADMINTABLE3 = new APCMS_ADMINTABLE($_SESSION['APCMS']['TABLE']['BGCOLOR'], $_SESSION['APCMS']['HELPSYSTEM']['BGCOLOR'], $_SESSION['APCMS']['HELPSYSTEM']['FGCOLOR']);
$ADMINTABLE3->AddRow('<strong>Support-Information</strong>', '', 2);
/** 
 * Macht Backups von den Tabellen oder der ganzen Datenbank, Backups werden getrennt in Text-Dateien gespeichert 
 * 
 * @param          int $complete Soll die gesamte Datenbank gebackuppt werden? (1/0) 
 * @param          int $tables Array mit Tabellen, die gebackuppt werden sollen, wenn $complete == 0 
 * @param          int $what Was soll gebackuppt werden? (data/structure/dataonly) 
 * @param          int $drop Soll "DROP TABLE" hinzugefügt werden? (1/0) 
 * @since          0.0.1 
 * @version        0.0.1 
 * @access         private 
 * @return         void 
 * @author         Alexander Mieland 
 * @copyright      2000-2004 by APP - Another PHP Program 
 */
function _APCMS_MakeSQLBackup($complete = 1, $tables = "", $what = "data", $drop = 1)
{
    global $db, $_LANGUAGE, $akt_time;
    $filetime = date("Y-m-d-H-i", $akt_time);
    $success = 0;
    $old = @ignore_user_abort(1);
    if ($complete == 1) {
        unset($tables);
        $QUERY = $db->unbuffered_query("SHOW TABLES");
        while ($THISTABLE = $db->fetch_row($QUERY)) {
            $tables[] = $THISTABLE[0];
        }
    }
    for ($q = 0; $q < count($tables); $q++) {
        $table = $tables[$q];
        $dateidir = $_SESSION['APCMS']['TMP_DIR'] . "/last_backup/";
        $dateiname = $table . ".sql";
        $sqltext = "#########################################################\n";
        $sqltext .= "## Created by APCMS v" . _APCMS_version() . "\n";
        $sqltext .= "## Copyright © 2000- by Alexander Mieland\n";
        $sqltext .= "## APP - Another PHP Program\n";
        $sqltext .= "## http://www.php-programs.de\n";
        $sqltext .= "## Kontakt: dma147@mieland-programming.de\n";
        $sqltext .= "#########################################################\n";
        $sqltext .= "##\n";
        $sqltext .= "##\n";
        $create_text = "";
        $insert_text = "";
        if ($what == "structure" or $what == "data") {
            if ($drop == 1) {
                $create_text .= "##\n";
                $create_text .= "##\t\tDROP-data von Tabelle `" . $table . "`\n";
                $create_text .= "##\n";
                $create_text .= "DROP TABLE IF EXISTS `" . $table . "`;\n\n";
            }
            $create_text .= "##\n";
            $create_text .= "##\t\tCREATE-data von Tabelle `" . $table . "`\n";
            $create_text .= "##\n";
            $sql = "SHOW CREATE TABLE `" . $_SESSION['MYSQLDATA']['DB'] . "`.`" . $table . "`";
            $result = $db->unbuffered_query($sql);
            if (!isset($result)) {
                $sql = "DESCRIBE `" . $_SESSION['MYSQLDATA']['DB'] . "`.`" . $table . "`";
                $result = $db->unbuffered_query($sql);
                if (isset($result)) {
                    $fieldnum = 0;
                    while ($row = $db->fetch_row($result)) {
                        $fieldnum++;
                    }
                    $result = $db->unbuffered_query($sql);
                    $create_text .= "CREATE TABLE `" . $_SESSION['MYSQLDATA']['DB'] . "`.`" . $table . "`";
                    $tz = 0;
                    $sqlende = "";
                    while ($row = $db->fetch_row($result)) {
                        $name = $row[0];
                        $type = " " . $row[1];
                        if ($row[2] == "") {
                            $null = " NOT NULL";
                        } else {
                            $null = " NULL";
                        }
                        if ($row[4] == "") {
                            $default = "";
                        } else {
                            $default = " DEFAULT '" . $row[4] . "'";
                        }
                        if ($row[5] == "") {
                            $extra = "";
                        } else {
                            $extra = " " . $row[5];
                        }
                        $create_text .= "\t`" . $name . "`" . $type . $null . $default . $extra;
                        $tz++;
                        if ($tz < $fieldnum) {
                            $create_text .= ", \n";
                        }
                    }
                    unset($pri_key);
                    unset($mul_key);
                    unset($mul_index_key);
                    unset($uni_key);
                    unset($uni_index_key);
                    unset($full_key);
                    unset($full_index_key);
                    $sql = "SHOW KEYS FROM `" . $_SESSION['MYSQLDATA']['DB'] . "`.`" . $table . "`";
                    $key_result = $db->unbuffered_query($sql);
                    while ($row = $db->fetch_row($key_result)) {
                        $non_unique = $row[1];
                        $key_name = $row[2];
                        $column_name = $row[4];
                        $fulltext = $row[9];
                        if (ereg("PRIMARY", $key_name)) {
                            $pri_key[] = $column_name;
                            $pri_index_key[] = $key_name;
                        } elseif ($non_unique) {
                            if ($fulltext == "FULLTEXT") {
                                $full_key[] = $column_name;
                                $full_index_key[] = $key_name;
                            } else {
                                $mul_key[] = $column_name;
                                $mul_index_key[] = $key_name;
                            }
                        } elseif (!$non_unique and !ereg("PRIMARY", $key_name)) {
                            $uni_key[] = $column_name;
                            $uni_index_key[] = $key_name;
                        }
                    }
                    if (count($pri_key) > 0) {
                        $pri_text = " PRIMARY KEY (";
                        for ($tr = 0; $tr < count($pri_key); $tr++) {
                            $pri_text .= $pri_key[$tr];
                            if ($tr + 1 < count($pri_key)) {
                                $pri_text .= ", ";
                            }
                        }
                        $pri_text .= ")";
                        $create_text .= ", \n\t" . trim($pri_text);
                    }
                    if (count($mul_key) > 0) {
                        $mul_text = " KEY (";
                        for ($tr = 0; $tr < count($mul_key); $tr++) {
                            $mul_text .= $mul_key[$tr];
                            if ($tr + 1 < count($mul_key)) {
                                $mul_text .= ", ";
                            }
                        }
                        $mul_text .= ")";
                        $create_text .= ", \n\t" . trim($mul_text);
                    }
                    if (count($full_key) > 0) {
                        $full_text = " FULLTEXT KEY (";
                        for ($tr = 0; $tr < count($full_key); $tr++) {
                            $full_text .= $full_key[$tr];
                            if ($tr + 1 < count($full_key)) {
                                $full_text .= ", ";
                            }
                        }
                        $full_text .= ")";
                        $create_text .= ", \n\t" . trim($full_text);
                    }
                    if (count($uni_key) > 0) {
                        $uni_text = " UNIQUE KEY (";
                        for ($tr = 0; $tr < count($uni_key); $tr++) {
                            $uni_text .= $uni_key[$tr];
                            if ($tr + 1 < count($uni_key)) {
                                $uni_text .= ", ";
                            }
                        }
                        $uni_text .= ")";
                        $create_text .= ", \n\t" . trim($uni_text);
                    }
                    $create_text .= "\n);\n\n";
                }
            } else {
                $row = $db->fetch_row($result);
                $create_text .= $row[1] . ";\n\n";
            }
        }
        if ($what == "dataonly" or $what == "data") {
            $insert_text .= "##\n";
            $insert_text .= "##\t\tINSERT-data von Tabelle `" . $table . "`\n";
            $insert_text .= "##\n";
            $R2 = $db->unbuffered_query("SELECT * FROM `" . $table . "`");
            unset($THIS);
            while ($THIS = $db->fetch_array($R2)) {
                $insert_text .= "INSERT INTO `" . $table . "` (";
                @reset($THIS);
                unset($key);
                unset($val);
                $insert_text1 = '';
                $insert_text2 = '';
                foreach ($THIS as $key => $val) {
                    if (!intval($key) and $key != "0") {
                        $insert_text1 .= "`" . $key . "`,";
                        $insert_text2 .= "'" . addslashes($val) . "',";
                    }
                }
                $insert_text1 = substr($insert_text1, 0, strlen($insert_text1) - 1);
                $insert_text2 = substr($insert_text2, 0, strlen($insert_text2) - 1);
                $insert_text .= $insert_text1 . ") VALUES (" . $insert_text2 . ");\n";
            }
        }
        if ($create_text != "") {
            $create_text = $sqltext . $create_text;
            if ($TXT = fopen($dateidir . $filetime . "_CREATE_" . $dateiname, "w")) {
                fputs($TXT, $create_text);
                fclose($TXT);
                chmod($dateidir . $filetime . "_CREATE_" . $dateiname, 0666);
            }
        }
        if ($insert_text != "") {
            $insert_text = $sqltext . $insert_text;
            if ($TXT = fopen($dateidir . $filetime . "_INSERT_" . $dateiname, "w")) {
                fputs($TXT, $insert_text);
                fclose($TXT);
                chmod($dateidir . $filetime . "_INSERT_" . $dateiname, 0666);
            }
        }
    }
}