function ExportHTML() { global $sql, $config, $lang; $header = implode("", file($config['paths']['config'] . 'html_template')); $header = str_replace("{TITLE}", 'MSD HTML-Export', $header); $footer = "\n\n</body>\n</html>"; $content = ""; $content .= '<h1>Datenbank ' . $sql['export']['db'] . '</h1>'; $time_start = time(); if (!isset($config['dbconnection'])) { MSD_mysql_connect(); } for ($table = 0; $table < count($sql['export']['tables']); $table++) { $content .= '<h2>Tabelle ' . $sql['export']['tables'][$table] . '</h2>' . "\n"; $fsql = "show fields from `" . $sql['export']['tables'][$table] . "`"; $dsql = "select * from `" . $sql['export']['tables'][$table] . "`"; //Struktur $res = MSD_query($fsql) or die(SQLError($fsql, mysql_error())); if ($res) { $field = $fieldname = $fieldtyp = array(); $structure = "<table class=\"Table\">\n"; $numfields = mysql_numrows($res); for ($feld = 0; $feld < $numfields; $feld++) { $row = mysql_fetch_row($res); $field[$feld] = $row[0]; if ($feld == 0) { $structure .= "<tr class=\"Header\">\n"; for ($i = 0; $i < count($row); $i++) { $str = mysql_fetch_field($res, $i); $fieldname[$i] = $str->name; $fieldtyp[$i] = $str->type; $structure .= "<th>" . $str->name . "</th>\n"; } $structure .= "</tr>\n<tr>\n"; } for ($i = 0; $i < count($row); $i++) { $structure .= "<td class=\"Object\">" . ($row[$i] != "" ? $row[$i] : " ") . "</td>\n"; } $structure .= "</tr>\n"; } $structure .= "</table>\n"; } if ($sql['export']['htmlstructure'] == 1) { $content .= "<h3>Struktur</h3>\n" . $structure; } //Daten $res = MSD_query($dsql) or die(SQLError($dsql, mysql_error())); if ($res) { $anz = mysql_num_rows($res); $content .= "<h3>Daten ({$anz} Datensätze)</h3>\n"; $content .= "<table class=\"Table\">\n"; for ($feld = 0; $feld < count($field); $feld++) { if ($feld == 0) { $content .= "<tr class=\"Header\">\n"; for ($i = 0; $i < count($field); $i++) { $content .= "<th>" . $field[$i] . "</th>\n"; } $content .= "</tr>\n"; } } for ($d = 0; $d < $anz; $d++) { $row = mysql_fetch_row($res); $content .= "<tr>\n"; for ($i = 0; $i < count($row); $i++) { $content .= '<td class="Object">' . ($row[$i] != "" ? $row[$i] : " ") . "</td>\n"; } $content .= "</tr>\n"; } } $content .= "</table>"; } CSVOutput($header . $content . $footer); }
function ExportHTML() { global $sql, $config, $lang; $header = '<html><head><title>MSD Export</title></head>'; $footer = "\n\n</body>\n</html>"; $content = ""; $content .= '<h1>' . $lang['L_DB'] . ' ' . $sql['export']['db'] . '</h1>'; $time_start = time(); if (!isset($config['dbconnection'])) { MSD_mysql_connect(); } for ($table = 0; $table < count($sql['export']['tables']); $table++) { $content .= '<h2>Tabelle ' . $sql['export']['tables'][$table] . '</h2>' . "\n"; $fsql = "show fields from `" . $sql['export']['tables'][$table] . "`"; $dsql = "select * from `" . $sql['export']['tables'][$table] . "`"; //Struktur $res = MSD_query($fsql); if ($res) { $field = $fieldname = $fieldtyp = array(); $structure = "<table class=\"Table\">\n"; $numfields = mysqli_num_rows($res); for ($feld = 0; $feld < $numfields; $feld++) { $row = mysqli_fetch_row($res); $field[$feld] = $row[0]; if ($feld == 0) { $structure .= "<tr class=\"Header\">\n"; for ($i = 0; $i < count($row); $i++) { $str = ($___mysqli_tmp = mysqli_fetch_field_direct($res, 0)) && is_object($___mysqli_tmp) ? !is_null($___mysqli_tmp->primary_key = $___mysqli_tmp->flags & MYSQLI_PRI_KEY_FLAG ? 1 : 0) && !is_null($___mysqli_tmp->multiple_key = $___mysqli_tmp->flags & MYSQLI_MULTIPLE_KEY_FLAG ? 1 : 0) && !is_null($___mysqli_tmp->unique_key = $___mysqli_tmp->flags & MYSQLI_UNIQUE_KEY_FLAG ? 1 : 0) && !is_null($___mysqli_tmp->numeric = (int) ($___mysqli_tmp->type <= MYSQLI_TYPE_INT24 || $___mysqli_tmp->type == MYSQLI_TYPE_YEAR || (defined("MYSQLI_TYPE_NEWDECIMAL") ? $___mysqli_tmp->type == MYSQLI_TYPE_NEWDECIMAL : 0))) && !is_null($___mysqli_tmp->blob = (int) in_array($___mysqli_tmp->type, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB))) && !is_null($___mysqli_tmp->unsigned = $___mysqli_tmp->flags & MYSQLI_UNSIGNED_FLAG ? 1 : 0) && !is_null($___mysqli_tmp->zerofill = $___mysqli_tmp->flags & MYSQLI_ZEROFILL_FLAG ? 1 : 0) && !is_null($___mysqli_type = $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = $___mysqli_type == MYSQLI_TYPE_STRING || $___mysqli_type == MYSQLI_TYPE_VAR_STRING ? "type" : "") && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && in_array($___mysqli_type, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24)) ? "int" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && in_array($___mysqli_type, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, defined("MYSQLI_TYPE_NEWDECIMAL") ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)) ? "real" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && $___mysqli_type == MYSQLI_TYPE_TIMESTAMP ? "timestamp" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && $___mysqli_type == MYSQLI_TYPE_YEAR ? "year" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && ($___mysqli_type == MYSQLI_TYPE_DATE || $___mysqli_type == MYSQLI_TYPE_NEWDATE) ? "date " : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && $___mysqli_type == MYSQLI_TYPE_TIME ? "time" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && $___mysqli_type == MYSQLI_TYPE_SET ? "set" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && $___mysqli_type == MYSQLI_TYPE_ENUM ? "enum" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && $___mysqli_type == MYSQLI_TYPE_GEOMETRY ? "geometry" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && $___mysqli_type == MYSQLI_TYPE_DATETIME ? "datetime" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && in_array($___mysqli_type, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB)) ? "blob" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type && $___mysqli_type == MYSQLI_TYPE_NULL ? "null" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->type = "" == $___mysqli_tmp->type ? "unknown" : $___mysqli_tmp->type) && !is_null($___mysqli_tmp->not_null = $___mysqli_tmp->flags & MYSQLI_NOT_NULL_FLAG ? 1 : 0) : false ? $___mysqli_tmp : false; $fieldname[$i] = $str->name; $fieldtyp[$i] = $str->type; $structure .= "<th>" . $str->name . "</th>\n"; } $structure .= "</tr>\n<tr>\n"; } for ($i = 0; $i < count($row); $i++) { $structure .= "<td class=\"Object\">" . ($row[$i] != "" ? $row[$i] : " ") . "</td>\n"; } $structure .= "</tr>\n"; } $structure .= "</table>\n"; } if ($sql['export']['htmlstructure'] == 1) { $content .= "<h3>Struktur</h3>\n" . $structure; } //Daten $res = MSD_query($dsql); if ($res) { $anz = mysqli_num_rows($res); $content .= "<h3>Daten ({$anz} Datensätze)</h3>\n"; $content .= "<table class=\"Table\">\n"; for ($feld = 0; $feld < count($field); $feld++) { if ($feld == 0) { $content .= "<tr class=\"Header\">\n"; for ($i = 0; $i < count($field); $i++) { $content .= "<th>" . $field[$i] . "</th>\n"; } $content .= "</tr>\n"; } } for ($d = 0; $d < $anz; $d++) { $row = mysqli_fetch_row($res); $content .= "<tr>\n"; for ($i = 0; $i < count($row); $i++) { $content .= '<td class="Object">' . ($row[$i] != "" ? $row[$i] : " ") . "</td>\n"; } $content .= "</tr>\n"; } } $content .= "</table>"; } CSVOutput($header . $content . $footer); }