0) { $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) { return str_repeat("0",$count-strlen($s)).$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; //Zeile zusammensetzen $log=date("d.m.Y h:i:s").': '.$aktion."\n"; //Datei öffnen und schreiben $fp = @fopen($config["files"]["log"], "a+"); if($fp) { @fwrite ($fp,($log)); @fclose ($fp); } else echo '

Log-File kann nicht geschrieben werden!

'; } function WriteTempOut($aktion) { global $config; $fp = @fopen($config["paths"]["log"]."out.tmp", "w"); if($fp) { @fwrite ($fp,$aktion); @fclose ($fp); } } 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) { global $config; //Error-Zeile generieren $errormsg=date("d.m.Y h:i:s").': '; $errormsg.=($dest=="RESTORE") ? " Restore of db `$db`\n" : " Dump of db `$db`\n"; $errormsg.="Error-Message: $error\n"; $errormsg.="SQL : ".$sql."\n\n"; //Datei öffnen und schreiben $fp = @fopen($config["paths"]["log"]."error.log", "a+"); 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(); 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) { $res=mysql_query("DROP DATABASE `$dbn`") or die(mysql_error().""); $res=mysql_query("CREATE DATABASE `$dbn`") or die(mysql_error().""); } function AutoDelete() { global $del_files, $config, $lang,$out; //Files einlesen $dh = opendir($config["paths"]["backup"]); $dbbackups=Array(); 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"); $statusline=gzgets($fp,40960); gzclose ($fp); }else{ $fp = fopen ($config["paths"]["backup"].$filename, "r"); $statusline=fgets($fp,500); fclose ($fp); } $sline=ReadStatusline($statusline); if($sline[0]=="9999") { $tabellenanzahl=""; $eintraege=""; } else { $tabellenanzahl=$sline[0]; $eintraege=$sline[1]; } $part=($sline[2]=="") ? 0 : substr($sline[2],3); $databases["db_actual"]=$sline[3]; $datum=substr($filename,strlen($databases["db_actual"])+1); $datum=substr($datum,0,16); if(isset($dbbackups[$databases["db_actual"]])) $dbbackups[$databases["db_actual"]]++; else $dbbackups[$databases["db_actual"]]=1; $files[] = "$datum|".$databases["db_actual"]."|$part|$filename"; } } @rsort($files); // Mehr Dateien vorhanden, als es laut config.php sein dürften? Dann weg damit :-) if($config["del_files_after_days"]>0) { $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) { //Format # Status:Tabellen:Datensätze:Multipart:DBname if(substr($line,0,8)!="# Status") { $s=Array("-1","-1","","","","","",""); } else { $s=explode(":",$line); array_shift($s); if(count($s)<7) { for($i=count($s);$i<8;$i++) {$s[]="";} } } return $s; } function NextPart($s,$first=0) { $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; } 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"); $r= '
'; $r.='
'; $r.=''; $r.=''; $r.=''; $r.=''; $r.=''; $vi= ''; $vi.= ''; $vi.= ''; //$vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $vi.= ''; $evars=str_replace("',"",$evars); $evars=str_replace('',"",$evars); $evars=str_replace('',"\n",$evars); //Form-vars $r.=$vi.''; $r.=''; $r.=''; $r.= ''; $r.= "

'.$subject.'

Absender
Name
Art des Fehlers
Anzeige des Fehlers
zusätzliche Bemerkungen
MySQLDump-Version'.$config["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($_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).'
","",$vi); $evars=str_replace('',"",$evars); $evars=str_replace('
Home
"; return $r; } function DynOutput($s,$fertig=0) { global $config; $out="out.html"; $tempDatei=$config["paths"]["log"].$out; $tempURL="work/log/".$out; if($fertig==0) { //$meta=''."\n"; $meta.=''."\n"; $meta.=''; } else { } //Header für HTML $h="\n\n".$meta."\nMySqlDumper\n"; $h.="\n\n\n"; //Footer $f=''; $page=$h.$s.$f; $f=fopen($tempDatei,"w"); fwrite($f,$page); fclose($f); echo ''; /*echo "
$page
"; die;*/ } function TesteFTP($ftp_server,$ftp_port,$ftp_user_name,$ftp_user_pass,$ftp_dir) { global $lang,$config; 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"]); $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.='ok, logged in
'.$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 headline() { global $config; if($config["interface_server_caption"]==1) return '
'.$_SERVER["SERVER_NAME"].'
'; } function buildComplement ($color) { $komp = -1; if (preg_match('/^#[0-9A-F]{1,6}$/i', $color)) { $red_str = substr($color, 1, 2); $green_str = substr($color, 3, 2); $blue_str = substr($color, 5, 2); $red_int = 255 - base_convert($red_str, 16, 10); $green_int = 255 - base_convert($green_str, 16, 10); $blue_int = 255 - base_convert($blue_str, 16, 10); $red_str = base_convert($red_int, 10, 16); $green_str = base_convert($green_int, 10, 16); $blue_str = base_convert($blue_int, 10, 16); if (strlen($red_str) == 1) $red_str = '0' . $red_str; if (strlen($green_str) == 1) $green_str = '0' . $green_str; if (strlen($blue_str) == 1) $blue_str = '0' . $blue_str; $komp = '#' . strtoupper($red_str) . strtoupper($green_str) . strtoupper($blue_str); } else return $komp; return $komp; } function dump($v) { // Ausgabe von var_dump über Output-Buffer in Variable einlesen ob_start (); var_dump ($v); $content = ob_get_contents (); ob_end_clean (); // maximale Einrückung ermitteln $m = 0; #1 preg_match_all ('#^(.*)=>#mU', $content, $stack); $lines = $stack[1]; $indents = array_map ('strlen', $lines); if ($indents) { $m = max ($indents) + 1; } #2 // Ausgabe von var_dump() an maximaler Einrückung ausrichten $content = preg_replace ('#^(.*)=>\\n\s+(\S)#eUm', '"\\1" .str_repeat(" ", $m - strlen("\\1")>1 ? $m - strlen("\\1") : 1). "\\2"',$content); // bei Array-Strukturen öffnende Klammer { in neue Zeile $content = preg_replace ( '#^((\s*).*){$#m', "\\1\n\\2{", $content); echo '
'. htmlentities($content). '
'; } 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.='