'."\n"; foreach ($parameter As $key=>$val) { $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); // counter used inside loop for($i=0; $i < count($keys); $i++) { if(!in_array($keys[$i], $key_sorta)) { $nkeys[$n] = $keys[$i]; $n += "1"; } } for($u=0;$u oder rsort=absteigend return $output; } function FillMultiDBArrays() { global $config,$databases; $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;$i0) { $s1=$s2=0; for ($i = 0; $i < $databases['Detailinfo']['tables']; $i++) { $row = mysql_fetch_array($res); $s1+=$row['Rows']; $s2+=$row['Data_length']+$row['Index_length']; } $databases['Detailinfo']['records']=$s1; $databases['Detailinfo']['size']=$s2; } } //Globale Funktionen function br($m=1) { //gibt m Zeilenumbrüche zurück return str_repeat("\n",$m); } 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['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] : 'Bytes'; 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; default: $suffix = (isset($names[$level])) ? $names[$level] : ''; break; } return round($bytes, $precision) . ' ' . $suffix; } function ExtractDBname($s) { if(strpos(strtolower($s),"_structure_file")>0){ return substr($s,0,strpos(strtolower($s),"_structure_file")); break; } $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($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').' '.$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['logfilenotwritable'].' ('.$logfile.')

'; } else { $fp = @fopen($logfile, "ab"); if($fp) { @fwrite ($fp,$log); @fclose ($fp); } else echo '

'.$lang['logfilenotwritable'].' ('.$logfile.')

'; } } function WritePageParams($aktion) { global $config,$restore,$dump,$nl; $pars=" $val){ if(is_array($val)) { foreach($val as $var2 => $val2){ if ($config['magic_quotes_gpc']==0) { $pars.='$dump[\''.$var.'\']['.((is_int($var2)) ? $var2 : "'".$var2."'").'\'] = "'.addslashes($val2)."\";$nl"; } else { $pars.='$dump[\''.$var.'\']['.((is_int($var2)) ? $var2 : "'".$var2."'").'\'] = "'.$val2."\";$nl"; } } } else { if ($config['magic_quotes_gpc']==0) { $pars.='$dump[\''.$var.'\'] = "'.addslashes($val)."\";$nl"; } else { $pars.='$dump[\''.$var.'\'] = "'.$val."\";$nl"; } } } } elseif($aktion=="restore") { $datei="restore.tmp"; foreach($restore as $var => $val){ if(is_array($val)) { foreach($val as $var2 => $val2){ if ($config['magic_quotes_gpc']==0) { $pars.='$restore[\''.$var.'\']['.((is_int($var2)) ? $var2 : "'".$var2."'").'\'] = "'.addslashes($val2)."\";$nl"; } else { $pars.='$restore[\''.$var.'\']['.((is_int($var2)) ? $var2 : "'".$var2."'").'] = "'.$val2."\";$nl"; } } } else { if ($config['magic_quotes_gpc']==0) { $pars.='$restore[\''.$var.'\'] = "'.addslashes($val)."\";$nl"; } else { $pars.='$restore[\''.$var.'\'] = "'.$val."\";$nl"; } } } } $pars.="$nl?>"; $fp = @fopen($config['paths']['log'].$datei, "w"); if($fp) { @fwrite ($fp,$pars."\n"); @fclose ($fp); } } 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.'|:|'; } $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; $warn=""; if($path=="" || $path=="config") if(!is_writable($config['paths']['config'])) $warn.='Configpath is not writable!   
'; if($path=="" || $path=="backup") if(!is_writable($config['paths']['backup'])) $warn.='Backuppath is not writable!   
'; if($path=="" || $path=="structure") if(!is_writable($config['paths']['structure'])) $warn.='Structurepath is not writable!   
'; if($path=="" || $path=="log") if(!is_writable($config['paths']['log'])) $warn.='Logpath is not writable!   
'; if($warn!="") $warn='ERROR !
'.$warn.'
'; return $warn; } function TestWorkDir() { global $config; //echo "work_chmod: $config['paths']['work']_chmod
"; SetFileRechte($config['paths']['work']); SetFileRechte($config['paths']['backup']); SetFileRechte($config['paths']['structure']); SetFileRechte($config['paths']['log']); SetFileRechte($config['paths']['config']); if(!file_exists($config['files']['parameter'])) SetDefault(true); if(!file_exists($config['files']['log'])) DeleteLog(); } function SetFileRechte($file,$perm="0777") { global $lang; if(substr($file,-1)!="/") $file.="/"; if(strlen($perm)!=4 || intval($perm)==0 || intval($perm)>777) $perm="0777"; if( (ini_get('safe_mode')==1) && (!(is_dir($file))) ) { echo $lang['critical_safemode']; return 0; } else { clearstatcache(); if (!@is_dir($file)) @mkdir($file, $perm); clearstatcache(); $a=@substr(decoct(fileperms($file)),-4); $ret=1; if($a!=$perm && (ini_get('safe_mode')!=1)) { $ret=@chmod($file,$perm); } return $ret; } } function SelectDB($index) { global $databases; $databases['db_actual'] = $databases['Name'][$index]; $databases['praefix'][$databases['db_selected_index']] = $databases['praefix'][$index]; $databases['db_selected_index']=$index; } function EmptyDB($dbn) { global $config; //$res=mysql_query("DROP DATABASE `$dbn`") or die(mysql_error().""); //$res=mysql_query("CREATE DATABASE `$dbn`") or die(mysql_error().""); $t_sql=Array(); $tabellen = mysql_list_tables($dbn,$config['dbconnection']); $num_tables = mysql_num_rows($tabellen); for($i=0;$i<$num_tables;$i++) { $t=mysql_tablename($tabellen,$i); $t_sql[]="DROP TABLE `$t`;"; } for($i=0;$i0) { $nowtime=strtotime("-".($config['del_files_after_days']+1)." day"); for($i=0; $i 0) { if (sizeof($files) > $config['max_backup_files']) { if($config['max_backup_files_each']==1) { //gilt es nur für jede Datenbank for($i=sizeof($files)-1; $i>=0; $i--) { $delfile=explode("|",$files[$i]); if($dbbackups[$delfile[1]] > $config['max_backup_files']) { $out.=DeleteFile($files[$i],"max"); unset($files[$i]); $dbbackups[$delfile[1]]--; } } } else { //oder gilt es für alle Backups for($i=sizeof($files)-1; $i>=$config['max_backup_files']; $i--) { $delfile=implode("|",$files); $out.=DeleteFile($files[$i],"max"); unset($files[$i]); } } } } return $out; } function DeleteFile($files,$function) { global $config,$lang; $delfile=explode("|",$files); $ll=($function=="max") ? $lang['fm_autodel1']:$lang['fm_autodel2']; $r="

".$ll."
"; $r.= $delfile[3]."
"; WriteLog("autodeleted ($function) '$delfile[3]'."); unlink($config['paths']['backup'].$delfile[3]); $r.= "

"; return $r; } function ReadStatusline($line) { /*AUFBAU der Statuszeile: -- Status:tabellenzahl:datensätze:Multipart:Datenbankname:script:scriptversion:Kommentar:MySQLVersion:Backupflags:SQLBefore:SQLAfter:EXTINFO Aufbau Backupflags (1 Zeichen pro Flag, 0 oder 1, 2=unbekannt) (complete inserts)(extended inserts)(ignore inserts)(delayed inserts)(downgrade)(lock tables)(optimize tables) */ $statusline=Array(); if(substr($line,0,8)!="# Status" && substr($line,0,9)!="-- Status") { //Fremdfile $statusline["tables"]=-1; $statusline["records"]=-1; $statusline["part"]="MP_0"; $statusline["dbname"]="unknown"; $statusline["script"]=""; $statusline["scriptversion"]=""; $statusline["comment"]=""; $statusline["mysqlversion"]="unknown"; $statusline["flags"]="2222222"; $statusline["sqlbefore"]=""; $statusline["sqlafter"]=""; } else { // MySQLDumper-File - Informationen extrahieren $s=explode(":",$line); if(count($s)<12) { //fehlenden Elemente auffüllen $c=count($s); array_pop($s); for($i=$c-1;$i<12;$i++) {$s[]="";} } $statusline["tables"]=$s[1]; $statusline["records"]=$s[2]; $statusline["part"]=$s[3]; $statusline["dbname"]=$s[4]; $statusline["script"]=$s[5]; $statusline["scriptversion"]=$s[6]; $statusline["comment"]=$s[7]; $statusline["mysqlversion"]=$s[8]; $statusline["flags"]=$s[9]; $statusline["sqlbefore"]=$s[10]; $statusline["sqlafter"]=$s[11]; } //flags zerlegen if(strlen($statusline["flags"])<6) $statusline["flags"]="2222222"; $statusline["complete_inserts"]=substr($statusline["flags"],0,1); $statusline["extended_inserts"]=substr($statusline["flags"],1,1); $statusline["ignore_inserts"]=substr($statusline["flags"],2,1); $statusline["delayed_inserts"]=substr($statusline["flags"],3,1); $statusline["downgrade"]=substr($statusline["flags"],4,1); $statusline["lock_tables"]=substr($statusline["flags"],5,1); $statusline["optimize_tables"]=substr($statusline["flags"],6,1); return $statusline; } function NextPart($s,$first=0) { global $restore; $nf=explode('_',$s); $i=array_search('part',$nf)+1; $p=substr($nf[$i],0,strpos($nf[$i],'.')); $ext=substr($nf[$i],strlen($p)); if($first==1) { $nf[$i]='1'.$ext; } else { $nf[$i]=++$p.$ext; } $restore['part']=$p; return implode('_',$nf); } function zeit_format($t) { $tt_m=floor($t/60); $tt_s=$t-($tt_m*60); return $tt_m.' min. '.floor($tt_s).' sec'; } function ErrorReport() { global $config,$PHP_SELF,$PATH,$PATH_TRANSLATED,$SCRIPT_FILENAME,$SCRIPT_NAME,$email,$_SERVER; $error_kind=$error_aus=""; if(isset($_POST['p']) && $_POST['p']==1) { //von Programmfehler geposted $error_kind=$_POST['error_kind']; $error_aus=$_POST['error_aus']; } if(isset($_POST['create_sql'])) { //vom Parser $error_kind="Parser-Fehler"; $error_aus=stripslashes(trim($_POST['create_sql']))."\n\n\n".stripslashes(trim($_POST['insert_sql'])); } $subject = "Fehlerbericht vom ".date("d.m.Y H:s"); $i=0; $r= '
'; $r.='
'."\n"; $r.=''."\n"; $r.=''."\n"; $r.=''."\n"; $r.=''."\n"; $r.=''."\n"; $vi= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $vi.= ''."\n"; $formvi=str_replace("<","<",$vi); $formvi=str_replace(">",">",$formvi); //Form-vars $r.=$vi.''; $r.=''; $r.=''; $r.= ''; $r.= "

'.$subject.'

Absender
Name
Art des Fehlers
Anzeige des Fehlers
zusätzliche Bemerkungen
MySQLDump-Version'.MSD_VERSION.'
MySQL-Version'.MSD_MYSQL_VERSION.'
PHP-Version'.phpversion().'
PHP-Extensions'.implode(" ",get_loaded_extensions()).'
safe_mode'.(($config['safe_mode']==1) ? "on" : "off").'
magic_quotes'.(($config['magic_quotes_gpc']==1) ? "on" : "off").'
Variable rootdir'.addslashes($config['paths']['root']).'
Server PHP_SELF'.$_SERVER['PHP_SELF'].'
Server Path'. addslashes(str_replace(';',";
",str_replace('\\','/',$_SERVER['PATH']))).'
Server Script-Filename'.$_SERVER['SCRIPT_FILENAME'].'
Server Script-Name'.$_SERVER['SCRIPT_NAME'].'
Global PHP_SELF'.$PHP_SELF.'
Global Path'. addslashes($PATH).'
Global Path-Translated'. addslashes($PATH_TRANSLATED).'
Global Script-Filename'.addslashes($SCRIPT_FILENAME).'
Global Script-Name'.addslashes($SCRIPT_NAME).'


Home".MSDFooter(); return $r; } function TesteFTP($ftp_server,$ftp_port,$ftp_user_name,$ftp_user_pass,$ftp_dir) { global $lang,$config; if(!isset($config['ftp_timeout'])) $config['ftp_timeout']=60; if($ftp_port=="" || $ftp_port==0) $ftp_port=21; $pass=-1; if(!extension_loaded("ftp")) { $s=''.$lang['noftppossible'].'+++'; } else $pass=0; if($pass==0) { if($ftp_server=="" || $ftp_user_name=="" || $ftp_user_pass=="") { $s=''.$lang['wrongconnectionpars'].''; } else $pass=1; } if($pass==1) { $s=$lang['connect_to'].' `'.$ftp_server.'` Port '.$ftp_port.'
'; if($config['ftp_useSSL']==0) { $conn_id = @ftp_connect($ftp_server,$ftp_port,$config['ftp_timeout']); } else { $conn_id = @ftp_ssl_connect($ftp_server,$ftp_port,$config['ftp_timeout']); } if ($conn_id) $login_result = @ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if(!$conn_id || (!$login_result)) { $s.=''.$lang['conn_not_possible'].''; } else $pass=2; } if($pass==2) { $s.='
Login ok
'.$lang['changedir'].' `'.$ftp_dir.'` ... '; $dirc=@ftp_chdir($conn_id,$ftp_dir); if(!$dirc) { $s.='
'.$lang['changedirerror'].''; } else $pass=3; @ftp_close($conn_id); } if($pass==3) $s.='

'.$lang['ftp_ok'].''; return $s; } function Realpfad($p) { global $config; if(!isset($config['disabled'])) $config['disabled']=ini_get("disable_functions"); if(strpos($config['disabled'],"realpath")) $s=getcwd(); else $s=realpath($p); $s=str_replace("\\","/",$s); if(substr($s,-1)!="/") $s.="/"; return $s; } function GetPerlConfigs() { global $config; $default=$config['cron_configurationfile']; $dh = opendir($config['paths']['config']); $r=""; while (false !== ($filename = readdir($dh))) { if ($filename != "." && $filename != ".." && !is_dir($config['paths']['config'].$filename) && substr($filename,-5)==".conf") { $f=substr($filename,0,strlen($filename)-5); $r.=''.$end."\n"; } elseif($k=="radio") { $r.=$start.'   '.$lang[$filename].$end."\n"; } } } return $r; } function headline($title,$mainframe=1) { global $config,$lang; $s=""; if($config['interface_server_caption']==1) { if($config['interface_server_caption_position']==$mainframe) { $s.='
'.$lang['server'].': '.$_SERVER['SERVER_NAME'].'
'; } } if ($mainframe==1) { $s.='
'.$title.'
'; $s.='
'; } return $s; } function PicCache($rpath="./") { global $BrowserIcon,$config; $t='
'; $dh=opendir($config['files']['iconpath']); while (false !== ($filename = readdir($dh))) { if ($filename != "." && $filename != ".." && !is_dir($config['files']['iconpath'].$filename)) { $t.=''; } } $t.='
'; return $t; } function MSDHeader($kind=0,$onloadFunction="") { global $config, $databases,$lang,$frameset_restore; //kind 0=main 1=menu 2=help $d=($kind==2) ? "../../" : "./"; $r=''."\n\n\n"; if ($kind==0) { //Main without caching $r.=''; } else { $r.=''; } $r.=''."\n"; $r.=''."\n"; $r.='MySqlDumper'."\n"; $r.=''."\n"; $r.=''."\n"; if($frameset_restore==1) $r.=''; $r.="\n'; return $r; } function MSDFooter($rfoot="",$enddiv=1) { global $config, $databases,$dump,$restore,$lang; $f= ''; if($enddiv==1) $f.= '
'; $f.=$rfoot.''; return $f; } function save_bracket($str) { // Wenn Klammer zu am Ende steht, diese behalten $str=trim($str); if (substr($str,-1)==')') $str=')'; else $str=''; return $str; } function DownGrade($s,$show=true) { // if (MSD_NEW_VERSION && strpos(strtolower($s),"collate ") && ($show) ) { // return $s; // } else { $tmp=explode(",",$s); //echo "
";print_r($tmp);echo "
"; for($i=0;$i"; if(substr(strtoupper($tmp2[$j]),0,7)=="ENGINE=") $tmp2[$j]="TYPE=".substr($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]); if (isset($tmp2[$j+1])) $tmp2[$j+1]=save_bracket($tmp2[$j+1]); $tmp2[$j-1]=""; } } $tmp[$i]=implode(" ",$tmp2); } // collate entfernen if(strpos($t,"collate")) { $tmp2=explode(" ",$tmp[$i]); $end=false; for($j=0;$j".$t.""); return $t; // } } function MySQL_Ticks($s) { $klammerstart=$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