' . "\n";
foreach ($parameter as $key => $val) {
if (is_array($val)) {
foreach ($val as $key2 => $val2) {
$page_parameter .= ''
. "\n";
}
} else {
$page_parameter .= '' . "\n";
}
}
$page_parameter .= '';
return $page_parameter;
}
function mu_sort($array, $key_sort)
{
$key_sorta = explode(',', $key_sort);
$keys = array_keys($array[0]);
$n = 0;
for ($m = 0; $m < count($key_sorta); $m++) {
$nkeys[$m] = trim($key_sorta[$m]);
}
$n += count($key_sorta);
for ($i = 0; $i < count($keys); $i++) {
if (!in_array($keys[$i], $key_sorta)) {
$nkeys[$n] = $keys[$i];
$n += "1";
}
}
for ($u = 0; $u < count($array); $u++) {
$arr = $array[$u];
for ($s = 0; $s < count($nkeys); $s++) {
$k = $nkeys[$s];
if (isset($array[$u][$k])) {
$output[$u][$k] = $array[$u][$k];
}
}
}
// wenn die Sortierung nicht ab- sondern aufsteigend sein soll, muss sort() benutzt werden
sort($output); // Sort=Aufsteigend -> oder rsort=absteigend
return $output;
}
function FillMultiDBArrays()
{
global $config, $databases;
// Nur füllen wenn überhaupt Datenbanken gefunden wurden
if ((isset($databases['Name'])) && (count($databases['Name']) > 0)) {
$databases['multi'] = Array();
$databases['multi_praefix'] = Array();
if (!isset($databases['db_selected_index'])) {
$databases['db_selected_index'] = 0;
}
if (!isset($databases['db_actual']) && isset($databases['Name'])) {
$databases['db_actual'] = $databases['Name'][$databases['db_selected_index']];
}
if (!isset($databases['multisetting'])) {
$databases['multisetting'] = '';
}
// if($config['multi_dump']==1)
// {
if ($databases['multisetting'] == '') {
//$databases['multi'][0]=$databases['db_actual'];
//$databases['multi_praefix'][0]=(isset($databases['praefix'][0])) ? $databases['praefix'][0] : '';
} else {
$databases['multi'] = explode(';', $databases['multisetting']);
$flipped = array_flip($databases['Name']);
for ($i = 0; $i < count($databases['multi']); $i++) {
if (isset($flipped[$databases['multi'][$i]])) {
$ind = $flipped[$databases['multi'][$i]];
$databases['multi_praefix'][$i] = (isset($databases['praefix'][$ind])) ? $databases['praefix'][$ind]
: '';
}
}
}
// }
/*
else
{
$databases['multi'][0]=(isset($databases['db_actual'])) ? $databases['db_actual'] : '';
$databases['multi_praefix'][0]=(isset($databases['praefix'])) ? $databases['praefix'][$databases['db_selected_index']] : '';
}
*/
}
}
function DBDetailInfo($index)
{
global $databases, $config;
$databases['Detailinfo']['tables'] = $databases['Detailinfo']['records'] = $databases['Detailinfo']['size'] = 0;
MSD_mysql_connect();
if (isset($databases['Name'][$index])) {
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $databases['Name'][$index]));
$databases['Detailinfo']['Name'] = $databases['Name'][$index];
$res = @mysqli_query(
$GLOBALS["___mysqli_ston"],
'SHOW TABLE STATUS FROM `' . $databases['Name'][$index] . '`'
);
if ($res) {
$databases['Detailinfo']['tables'] = mysqli_num_rows($res);
}
if ($databases['Detailinfo']['tables'] > 0) {
$s1 = $s2 = 0;
while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$s1 += $row['Rows'];
$s2 += $row['Data_length'] + $row['Index_length'];
}
$databases['Detailinfo']['records'] = $s1;
$databases['Detailinfo']['size'] = $s2;
}
}
}
function Stringformat($s, $count)
{
if ($count >= strlen($s)) {
return str_repeat("0", $count - strlen($s)) . $s;
} else {
return $s;
}
}
function getmicrotime()
{
list ($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function MD_FreeDiskSpace()
{
global $lang;
$dfs = @diskfreespace("../");
return ($dfs) ? byte_output($dfs) : $lang['L_NOTAVAIL'];
}
function WriteDynamicText($txt, $object)
{
return '';
}
function byte_output($bytes, $precision = 2, $names = Array())
{
if (!is_numeric($bytes) || $bytes < 0) {
return false;
}
for ($level = 0; $bytes >= 1024; $level++) {
$bytes /= 1024;
}
switch ($level) {
case 0:
$suffix = (isset($names[0])) ? $names[0] : 'B';
break;
case 1:
$suffix = (isset($names[1])) ? $names[1] : 'KB';
break;
case 2:
$suffix = (isset($names[2])) ? $names[2] : 'MB';
break;
case 3:
$suffix = (isset($names[3])) ? $names[3] : 'GB';
break;
case 4:
$suffix = (isset($names[4])) ? $names[4] : 'TB';
break;
case 5:
$suffix = (isset($names[4])) ? $names[4] : 'PB';
break;
case 6:
$suffix = (isset($names[4])) ? $names[4] : 'EB';
break;
case 7:
$suffix = (isset($names[4])) ? $names[4] : 'ZB';
break;
default:
$suffix = (isset($names[$level])) ? $names[$level] : '';
break;
}
return sprintf("%01." . $precision . "f", round($bytes, $precision)) . ' ' . $suffix;
}
function ExtractDBname($s)
{
$sp = explode('_', $s);
$anz = count($sp) - 1;
$r = 0;
if ($anz > 4) {
$df = 5; //Datumsfelder
if ($sp[$anz - 1] == 'part') {
$df += 2;
}
if ($sp[$anz - 3] == 'crondump' || $sp[$anz - 1] == 'crondump') {
$df += 2;
}
$anz = $anz - $df; //Datum weg
for ($i = 0; $i <= $anz; $i++) {
$r += strlen($sp[$i]) + 1;
}
return substr($s, 0, $r - 1);
} else {
//Fremdformat
return substr($s, 0, strpos($s, '.'));
}
}
function ExtractBUT($s)
{
$i = strpos(strtolower($s), "part");
if ($i > 0) {
$s = substr($s, 0, $i - 1);
}
$i = strpos(strtolower($s), "crondump");
if ($i > 0) {
$s = substr($s, 0, $i - 1);
}
$i = strpos(strtolower($s), ".sql");
if ($i > 0) {
$s = substr($s, 0, $i);
}
$sp = explode("_", $s);
$anz = count($sp) - 1;
if (strtolower($sp[$anz]) == 'perl') {
$anz--;
}
if ($anz > 4) {
return $sp[$anz - 2] . "." . $sp[$anz - 3] . "." . $sp[$anz - 4] . " " . $sp[$anz - 1] . ":" . $sp[$anz];
} else {
//Fremdformat
return "";
}
}
function WriteLog($aktion)
{
global $config, $lang;
$log = date('d.m.Y H:i:s') . ' ' . htmlspecialchars($aktion) . "\n";
$logfile = ($config['logcompression'] == 1) ? $config['files']['log'] . '.gz' : $config['files']['log'];
if (@filesize($logfile) + strlen($log) > $config['log_maxsize']) {
@unlink($logfile);
}
//Datei öffnen und schreiben
if ($config['logcompression'] == 1) {
$fp = @gzopen($logfile, 'a');
if ($fp) {
@gzwrite($fp, $log) . '
';
@gzclose($fp);
} else {
echo '
' . $lang['L_LOGFILENOTWRITABLE'] . ' (' . $logfile . ')
'; } } else { $fp = @fopen($logfile, "ab"); if ($fp) { @fwrite($fp, $log); @fclose($fp); } else { echo '' . $lang['L_LOGFILENOTWRITABLE'] . ' (' . $logfile . ')
'; } } } function ErrorLog($dest, $db, $sql, $error, $art = 1) { //$art=0 -> Fehlermeldung //$art=1 -> Hinweis global $config; if (strlen($sql) > 100) { $sql = substr($sql, 0, 100) . " ... (snip)"; } //Error-Zeile generieren $errormsg = date('d.m.Y H:i:s') . ': '; $errormsg .= ($dest == 'RESTORE') ? ' Restore of db `' . $db . '`|:|' : ' Dump of db `' . $db . '`|:|'; if ($art == 0) { $errormsg .= 'Error-Message: ' . $error . '|:|'; } else { $errormsg .= 'Notice: ' . $error . '|:|'; } if ($sql > '') { $errormsg .= 'SQL: ' . $sql . "\n"; } //Datei öffnen und schreiben if ($config['logcompression'] == 1) { $fp = @gzopen($config['paths']['log'] . 'error.log.gz', 'ab'); if ($fp) { @gzwrite($fp, ($errormsg)); @gzclose($fp); } } else { $fp = @fopen($config['paths']['log'] . 'error.log', 'ab'); if ($fp) { @fwrite($fp, ($errormsg)); @fclose($fp); } } } function DirectoryWarnings($path = "") { global $config, $lang; $warn = ''; if (!is_writable($config['paths']['work'])) { $warn .= sprintf($lang['L_WRONG_RIGHTS'], $config['paths']['work'], '0777'); } if (!is_writable($config['paths']['config'])) { $warn .= sprintf($lang['L_WRONG_RIGHTS'], $config['paths']['config'], '0777'); } if (!is_writable($config['paths']['backup'])) { $warn .= sprintf($lang['L_WRONG_RIGHTS'], $config['paths']['backup'], '0777'); } if (!is_writable($config['paths']['log'])) { $warn .= sprintf($lang['L_WRONG_RIGHTS'], $config['paths']['log'], '0777'); } if ($warn != '') { $warn = '' . $warn . ''; } return $warn; } function TestWorkDir() { global $config; $ret = SetFileRechte($config['paths']['work']); if ($ret === true) { $ret = SetFileRechte($config['paths']['backup']); } if ($ret === true) { $ret = SetFileRechte($config['paths']['log']); } if ($ret === true) { $ret = SetFileRechte($config['paths']['config']); } if ($ret === true) { if (!file_exists($config['files']['parameter'])) { SetDefault(true); } if (!file_exists($config['files']['log'])) { DeleteLog(); } } return $ret; } function SetFileRechte($file, $is_dir = 1, $perm = 0777) { global $lang; $ret = true; if ($is_dir == 1) { if (substr($file, -1) != "/") { $file .= "/"; } } clearstatcache(); // erst pruefen, ob Datei oder Verzeichnis existiert if (!file_exists($file)) { // Wenn es sich um ein Verzeichnis handelt -> anlegen if ($is_dir == 1) { $ret = @mkdir($file, $perm); if (!$ret === true) { // Hat nicht geklappt -> Rueckmeldung $ret = sprintf($lang['L_CANT_CREATE_DIR'], $file); } } } // wenn bisher alles ok ist -> Rechte setzen - egal ob Datei oder Verzeichnis if ($ret === true) { $ret = @chmod($file, $perm); if (!$ret === true) { $ret = sprintf($lang['L_WRONG_RIGHTS'], $file, decoct($perm)); } } return $ret; } function SelectDB($index) { global $databases; if (is_string($index)) { // name given $dbNames = array_flip($databases['Name']); if (array_key_exists($index, $dbNames)) { $index = $dbNames[$index]; } } if (isset($databases['Name'][$index])) { $databases['db_actual'] = $databases['Name'][$index]; if (isset($databases['praefix'][$index])) { $databases['praefix'][$databases['db_selected_index']] = $databases['praefix'][$index]; } else { $databases['praefix'][$databases['db_selected_index']] = ''; } if (isset($databases['db_selected_index'])) { $databases['db_selected_index'] = $index; } else { $databases['db_selected_index'] = 0; } } else { // keine DB vorhanden $databases['praefix'][$databases['db_selected_index']] = ''; $databases['db_selected_index'] = 0; $databases['db_actual'] = ''; } } function EmptyDB($dbn) { global $config; $t_sql = array(); @mysqli_query($GLOBALS["___mysqli_ston"], 'SET FOREIGN_KEY_CHECKS=0'); $res = mysqli_query($config['dbconnection'], 'SHOW TABLE STATUS FROM `' . $dbn . '`') or die('EmptyDB: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); WHILE ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) { if (substr(strtoupper($row['Comment']), 0, 4) == 'VIEW') { $t_sql[] = 'DROP VIEW `' . $dbn . '`.`' . $row['Name'] . '`'; } else { $t_sql[] = 'DROP TABLE `' . $dbn . '`.`' . $row['Name'] . '`'; } } if (sizeof($t_sql) > 0) { for ($i = 0; $i < count($t_sql); $i++) { $res = mysqli_query($GLOBALS["___mysqli_ston"], $t_sql[$i]) or die('EmptyDB-Error: ' . ((is_object( $GLOBALS["___mysqli_ston"] )) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false))); } } @mysqli_query($GLOBALS["___mysqli_ston"], 'SET FOREIGN_KEY_CHECKS=1'); } function AutoDelete() { global $del_files, $config, $lang, $out; $out = ''; if ($config['max_backup_files'] > 0) { //Files einlesen $dh = opendir($config['paths']['backup']); $dbbackups = array(); $files = array(); // Build assoc Array $db=>$timestamp=>$filenames while (false !== ($filename = readdir($dh))) { if ($filename != '.' && $filename != '..' && !is_dir($config['paths']['backup'] . $filename)) { //statuszeile auslesen if (substr($filename, -2) == 'gz') { $fp = gzopen($config['paths']['backup'] . $filename, 'r'); $sline = gzgets($fp, 40960); gzclose($fp); } else { $fp = fopen($config['paths']['backup'] . $filename, 'r'); $sline = fgets($fp, 500); fclose($fp); } $statusline = ReadStatusline($sline); if ($statusline['dbname'] != 'unknown') { $tabellenanzahl = ($statusline['tables'] == -1) ? '' : $statusline['tables']; $eintraege = ($statusline['records'] == -1) ? '' : $statusline['records']; $part = ($statusline['part'] == 'MP_0' || $statusline['part'] = '') ? 0 : substr( $statusline['part'], 3 ); $db_name = $statusline['dbname']; $datum = substr($filename, strlen($db_name) + 1); $timestamp = substr($datum, 0, 16); if (!isset($files[$db_name])) { $files[$db_name] = array(); } if (!isset($files[$db_name][$timestamp])) { $files[$db_name][$timestamp] = array(); } $files[$db_name][$timestamp][] = $filename; } } } $out = ''; // stores output messages // Backups pro DB und Timestamp ermitteln foreach ($files as $db => $val) { //echo "' . $lang['L_FM_AUTODEL1'] . '
';
$r .= $delfile[3] . "
";
$part = $delfile[2];
if ($part > 0) {
for ($i = $part; $i > 0; $i--) {
$delete = @unlink($config['paths']['backup'] . $delfile[3]);
if ($delete) {
WriteLog("autodeleted ($function) '$delfile[3]'.");
}
}
} else {
WriteLog("autodeleted ($function) '$delfile[3]'.");
unlink($config['paths']['backup'] . $delfile[3]);
}
$r .= '
";print_r($tmp);echo ""; for ($i = 0; $i < count($tmp); $i++) { $t = strtolower($tmp[$i]); if (strpos($t, "collate ")) { $tmp2 = explode(" ", $tmp[$i]); for ($j = 0; $j < count($tmp2); $j++) { if (strtolower($tmp2[$j]) == "collate") { $tmp2[$j] = ""; $tmp2[$j + 1] = save_bracket($tmp2[$j + 1]); $j++; } } $tmp[$i] = implode(" ", $tmp2); } if (strpos($t, "engine=")) { $tmp2 = explode(" ", $tmp[$i]); for ($j = 0; $j < count($tmp2); $j++) { if (substr(strtoupper($tmp2[$j]), 0, 7) == "ENGINE=") { $tmp2[$j] = "TYPE=" . substr($tmp2[$j], 7, strlen($tmp2[$j]) - 7); } if (substr(strtoupper($tmp2[$j]), 0, 8) == "CHARSET=") { $tmp2[$j] = ""; $tmp2[$j - 1] = save_bracket($tmp2[$j - 1]); } if (substr(strtoupper($tmp2[$j]), 0, 8) == "COLLATE=") { $tmp2[$j] = save_bracket($tmp2[$j]); $tmp2[$j - 1] = ""; } } $tmp[$i] = implode(" ", $tmp2); } // character Set sprache entfernen if (strpos($t, "character set")) { $tmp2 = explode(" ", $tmp[$i]); $end = false; for ($j = 0; $j < count($tmp2); $j++) { if (strtolower($tmp2[$j]) == "character") { $tmp2[$j] = ''; $tmp2[$j + 1] = save_bracket($tmp2[$j + 1]); $tmp2[$j + 2] = save_bracket($tmp2[$j + 2]); } } $tmp[$i] = implode(" ", $tmp2); } if (strpos($t, "timestamp")) { $tmp2 = explode(" ", $tmp[$i]); $end = false; for ($j = 0; $j < count($tmp2); $j++) { if ($end) { $tmp2[$j] = ""; } if (strtolower($tmp2[$j]) == "timestamp") { $tmp2[$j] = "TIMESTAMP(14)"; $end = true; } } $tmp[$i] = implode(" ", $tmp2); } } $t = implode(",", $tmp); if (substr(rtrim($t), -1) != ";") { $t = rtrim($t) . ";"; } return $t; } function MySQL_Ticks($s) { $klammerstart = $lastklammerstart = $end = 0; $inner_s_start = strpos($s, '('); $inner_s_end = strrpos($s, ')'); $inner_s = substr($s, $inner_s_start + 1, $inner_s_end - (1 + $inner_s_start)); $pieces = explode(',', $inner_s); for ($i = 0; $i < count($pieces); $i++) { $r = trim($pieces[$i]); $klammerstart += substr_count($r, "(") - substr_count($r, ")"); if ($i == count($pieces) - 1) { $klammerstart += 1; } if (substr(strtoupper($r), 0, 4) == "KEY " || substr(strtoupper($r), 0, 7) == "UNIQUE " || substr( strtoupper($r), 0, 12 ) == "PRIMARY KEY " || substr(strtoupper($r), 0, 13) == "FULLTEXT KEY " ) { //nur ein Key $end = 1; } else { if (substr($r, 0, 1) != '`' && substr($r, 0, 1) != '\'' && $klammerstart == 0 && $end == 0 && $lastklammerstart == 0 ) { $pos = strpos($r, ' '); $r = '`' . substr($r, 0, $pos) . '`' . substr($r, $pos); } } $pieces[$i] = $r; $lastklammerstart = $klammerstart; } $back = substr($s, 0, $inner_s_start + 1) . implode(',', $pieces) . ');'; return $back; } /** * Convert all array elements to UTF-8 * * @param $array * * @return array */ function convert_to_utf8($obj) { global $config; $ret = $obj; // wenn die Verbindung zur Datenbank nicht auf utf8 steht, dann muessen die Rückgaben in utf8 gewandelt werden, // da die Webseite utf8-kodiert ist if (!isset($config['mysql_can_change_encoding'])) { get_sql_encodings(); } if ($config['mysql_can_change_encoding'] == false && $config['mysql_standard_character_set'] != 'utf8') { if (is_array($obj)) { foreach ($obj as $key => $val) { //echo "