Dieser Commit ist enthalten in:
Commit
9764c1b424
119 geänderte Dateien mit 13927 neuen und 0 gelöschten Zeilen
15
mysqldumper/inc/footer.php
Normale Datei
15
mysqldumper/inc/footer.php
Normale Datei
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
$config_array=(isset($config)) ? "<strong>CONFIG</strong><pre>".@print_r($config,true)."</pre>": "";
|
||||
$database_array=(isset($database)) ? "<strong>DATABASE</strong><pre>".@print_r($database,true)."</pre>": "";
|
||||
$dump_array=(isset($dump)) ? "<strong>DUMP</strong><pre>".@print_r($dump,true)."</pre>": "";
|
||||
$restore_array=(isset($restore)) ? "<strong>RESTORE</strong><pre>".@print_r($restore,true)."</pre>" : "";
|
||||
|
||||
echo '<p align="center" class="small">'.$lang['authors'].':
|
||||
<a class="small" href="http://www.daniel-schlichtholz.de" target="_blank">
|
||||
Daniel Schlichtholz & Steffen Kamper</a> - Infoboard:
|
||||
<a class="small" href="'.$config['homepage'].'" target="_blank">'.
|
||||
$config['homepage'].'</a></p>';
|
||||
|
||||
echo '</div></body></html>';
|
||||
|
||||
?>
|
||||
439
mysqldumper/inc/functions.php
Normale Datei
439
mysqldumper/inc/functions.php
Normale Datei
|
|
@ -0,0 +1,439 @@
|
|||
<?php
|
||||
include_once('./inc/functions_global.php');
|
||||
include_once('./inc/mysql.php');
|
||||
|
||||
function Help($ToolTip,$Anker,$imgsize=12)
|
||||
{
|
||||
global $config;
|
||||
if($Anker!=""){
|
||||
return '<a href="language/'.$config['language'].'/help.php#'.$Anker.'" title="'.$ToolTip.'"><img src="'.$config['files']['iconpath'].'help16.gif" width="'.$imgsize.'" height="'.$imgsize.'" hspace="'.($imgsize/4).'" vspace="0" border="0" alt="Help"></a>';
|
||||
} else {
|
||||
return '<img src="'.$config['files']['iconpath'].'help16.gif" width="'.$imgsize.'" height="'.$imgsize.'" alt="Help" title="'.$ToolTip.'" border="0" hspace="'.($imgsize/4).'" vspace="0" >';
|
||||
}
|
||||
}
|
||||
|
||||
function DeleteFilesM($dir, $pattern = "*.*")
|
||||
{
|
||||
$deleted = false;
|
||||
$pattern = str_replace(array("\*","\?"), array(".*","."), preg_quote($pattern));
|
||||
if (substr($dir,-1) != "/") $dir.= "/";
|
||||
if (is_dir($dir))
|
||||
{ $d = opendir($dir);
|
||||
while ($file = readdir($d))
|
||||
{ if (is_file($dir.$file) && ereg("^".$pattern."$", $file))
|
||||
{
|
||||
if (unlink($dir.$file)) $deleted[] = $file;
|
||||
}
|
||||
}
|
||||
closedir($d);
|
||||
return $deleted;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
function SetDefault($load_default=false)
|
||||
{
|
||||
global $config,$databases,$nl,$out,$lang;
|
||||
|
||||
//Arrays löschen
|
||||
$i=0;
|
||||
$old_db=$databases['db_actual'];
|
||||
//unset($databases);
|
||||
$databases['Name']=Array();
|
||||
|
||||
$old_lang=$config['language'];
|
||||
|
||||
if($load_default==true){
|
||||
@unlink($config['files']['parameter']);
|
||||
include("./config.php");
|
||||
$config['language']=$old_lang;
|
||||
include("language/".$config['language']."/lang.php");
|
||||
}
|
||||
|
||||
//DB-Liste holen
|
||||
MSD_mysql_connect();
|
||||
|
||||
$databases['db_selected_index']=-1;
|
||||
|
||||
$res = mysql_query("SHOW DATABASES ;",$config['dbconnection']);
|
||||
$numrows=mysql_numrows($res);
|
||||
$a=0;
|
||||
for($i=0;$i<$numrows;$i++)
|
||||
{
|
||||
$row = mysql_fetch_row($res);
|
||||
$found_db=$row[0];
|
||||
|
||||
// Testverbindung aufbauen
|
||||
$res2=mysql_query("SHOW TABLES FROM `$found_db`",$config['dbconnection']);
|
||||
if (!$res2===false)
|
||||
{
|
||||
if($found_db==$old_db) $databases['db_selected_index']=$a;
|
||||
$databases['Name'][$a]=$found_db;
|
||||
$databases['praefix'][$a]="";
|
||||
$databases['command_before_dump'][$a] = "";
|
||||
$databases['command_after_dump'][$a] = "";
|
||||
$out.=$lang['saving_db_form']." ".$found_db." ".$lang['added']."$nl";
|
||||
$a++;
|
||||
}
|
||||
}
|
||||
if($databases['db_selected_index']==-1) {
|
||||
$databases['db_selected_index']=0;
|
||||
$databases['db_actual']=$databases['Name'][$databases['db_selected_index']];
|
||||
} else $databases['db_actual']=$databases['Name'][$databases['db_selected_index']];
|
||||
$databases['db_actual_cronpraefix']="";
|
||||
$databases['db_actual_cronindex']=$databases['db_selected_index'];
|
||||
|
||||
WriteParams(1,$config,$databases);
|
||||
if($load_default==false) WriteLog("default settings loaded.");
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
function WriteParams($as=0,$config,$databases)
|
||||
{
|
||||
global $config_dontsave;
|
||||
$nl="\n";
|
||||
FillMultiDBArrays();
|
||||
//Parameter zusammensetzen
|
||||
$config['multipart_groesse']=$config['multipartgroesse1']*(($config['multipartgroesse2']==1) ? 1024 : 1024*1024);
|
||||
$param=$pars_all='<?php '.$nl;
|
||||
if(!isset($config['email_maxsize'])) $config['email_maxsize']=$config['email_maxsize1']*(($config['email_maxsize2']==1) ? 1024 : 1024*1024);
|
||||
if(!isset($config['cron_execution_path'])) $config['cron_execution_path']="msd_cron/";
|
||||
if($as==0) $config['paths']['root']=addslashes(Realpfad("./"));
|
||||
foreach($config as $var => $val){
|
||||
if(is_array($val)) {
|
||||
foreach($val as $var2 => $val2){
|
||||
if ($config['magic_quotes_gpc']==0 || $as==1) {
|
||||
$pars_all.='$config[\''.$var.'\']['.((is_int($var2)) ? $var2 : "'".$var2."'").'] = \''.addslashes($val2)."';$nl";
|
||||
} else {
|
||||
$pars_all.='$config[\''.$var.'\']['.((is_int($var2)) ? $var2 : "'".$var2."'").'] = \''.$val2."';$nl";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($config['magic_quotes_gpc']==0 || $as==1) {
|
||||
if(!in_array($var,$config_dontsave)) $pars_all.='$config[\''.$var.'\'] = \''.addslashes($val)."';$nl";
|
||||
} else {
|
||||
if(!in_array($var,$config_dontsave)) $pars_all.='$config[\''.$var.'\'] = \''.$val."';$nl";
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($databases as $var => $val){
|
||||
if(is_array($val)) {
|
||||
foreach($val as $var2 => $val2){
|
||||
if ($config['magic_quotes_gpc']==0 || $as==1) {
|
||||
$pars_all.='$databases[\''.$var.'\']['.((is_int($var2)) ? $var2 : "'".$var2."'").'] = \''.addslashes($val2)."';$nl";
|
||||
} else {
|
||||
$pars_all.='$databases[\''.$var.'\']['.((is_int($var2)) ? $var2 : "'".$var2."'").'] = \''.$val2."';$nl";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($config['magic_quotes_gpc']==0 || $as==1) {
|
||||
$pars_all.='$databases[\''.$var.'\'] = \''.addslashes($val)."';$nl";
|
||||
} else {
|
||||
$pars_all.='$databases[\''.$var.'\'] = \''.$val."';$nl";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$param.='?>'; $pars_all.='?>';
|
||||
|
||||
//Datei öffnen und schreiben
|
||||
$ret=true;
|
||||
@chmod($config['files']['parameter'], 0777);
|
||||
if ($fp=fopen($config['files']['parameter'], "wb"))
|
||||
{
|
||||
if (!fwrite($fp,$pars_all)) $ret=false;
|
||||
if (!fclose($fp)) $ret=false;
|
||||
}
|
||||
else $ret=false;
|
||||
|
||||
$ret=WriteCronScript($config,$databases);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function WriteCronScript($config,$databases)
|
||||
{
|
||||
|
||||
global $nl, $cron_save_all_dbs,
|
||||
$cron_db_array,$cron_dbpraefix_array,$cron_db_cbd_array,$cron_db_cad_array;
|
||||
|
||||
$tomask=Array('@'=>'\@','$'=>'\$','\\'=>'\\\\');
|
||||
|
||||
if(!isset($databases['praefix'][$databases['db_selected_index']])) $databases['praefix'][$databases['db_selected_index']]="";
|
||||
if(!isset($databases['db_actual_cronindex'])) $databases['db_actual_cronindex']=$databases['db_selected_index'];
|
||||
if(!isset($config['email_maxsize'])) $config['email_maxsize']=$config['email_maxsize1']*(($config['email_maxsize2']==1) ? 1024 : 1024*1024);
|
||||
|
||||
if($config['cron_samedb']==0) {
|
||||
$cron_dbname=$databases['db_actual'];
|
||||
$cron_dbpraefix = $databases['praefix'][$databases['db_selected_index']];
|
||||
}else {
|
||||
if($databases['db_actual_cronindex']>=0) {
|
||||
$cron_dbname=$databases['Name'][$databases['db_actual_cronindex']];
|
||||
$cron_dbpraefix = $databases['db_actual_cronpraefix'];
|
||||
|
||||
} else {
|
||||
$cron_dbname=$databases['db_actual'];
|
||||
$cron_dbpraefix = $databases['praefix'][$databases['db_selected_index']];
|
||||
}
|
||||
}
|
||||
|
||||
if($databases['db_actual_cronindex']<0) {
|
||||
$csadb='$cron_save_all_dbs=1;'.$nl;
|
||||
$csadb.='$cron_db_array=qw('.$cron_db_array.');'.$nl;
|
||||
$csadb.='$cron_dbpraefix_array=qw('.$cron_dbpraefix_array.');'.$nl;
|
||||
$csadb.='$dbpraefix="";'.$nl;
|
||||
$csadb.='$command_beforedump_array="'.$cron_db_cbd_array.'";'.$nl;
|
||||
$csadb.='$command_afterdump_array="'.$cron_db_cad_array.'";'.$nl;
|
||||
} else {
|
||||
$csadb='$cron_save_all_dbs=0;'.$nl;
|
||||
$csadb.='$cron_db_array="";'.$nl;
|
||||
$csadb.='$cron_dbpraefix_array="";'.$nl;
|
||||
$csadb.='$dbpraefix="'.$cron_dbpraefix.'";'.$nl;
|
||||
$csadb.='$command_beforedump_array="'.$databases['command_before_dump'][$databases['db_selected_index']].'";'.$nl;
|
||||
$csadb.='$command_afterdump_array="'.$databases['command_after_dump'][$databases['db_selected_index']].'";'.$nl;
|
||||
}
|
||||
|
||||
|
||||
$r=str_replace("\\\\","/",$config['paths']['root']);
|
||||
$r=str_replace("@","\@",$r);
|
||||
$p1=$r.$config['paths']['backup'];
|
||||
$p2=$r.$config['files']['perllog'].(($config['logcompression']==1) ? '.gz':'');
|
||||
$p3=$r.$config['files']['perllogcomplete'].(($config['logcompression']==1) ? '.gz':'');
|
||||
|
||||
$cronscript="#Vars - written at ".date("Y-m-d").$nl;
|
||||
$cronscript.='$dbhost="'.$config['dbhost'].'";'.$nl;
|
||||
$cronscript.='$dbname="'.$cron_dbname.'";'.$nl;
|
||||
$cronscript.='$dbuser="'.$config['dbuser'].'";'.$nl;
|
||||
$cronscript.='$dbpass="'.$config['dbpass'].'";'.$nl;
|
||||
$cronscript.=$csadb;
|
||||
$cronscript.='$compression='.$config['cron_compression'].';'.$nl;
|
||||
$cronscript.='$backup_path="'.$p1.'";'.$nl;
|
||||
$cronscript.='$logdatei="'.$p2.'";'.$nl;
|
||||
$cronscript.='$completelogdatei="'.$p3.'";'.$nl;
|
||||
$cronscript.='$nl="\n";'.$nl;
|
||||
$cronscript.='$cron_printout='.$config['cron_printout'].';'.$nl;
|
||||
$cronscript.='$cronmail='.$config['cron_mail'].';'.$nl;
|
||||
$cronscript.='$cronmail_dump='.$config['cron_mail_dump'].';'.$nl;
|
||||
$cronscript.='$cronmailto="'.strtr($config['email_recipient'],$tomask).'";'.$nl;
|
||||
$cronscript.='$cronmailfrom="'.strtr($config['email_sender'],$tomask).'";'.$nl;
|
||||
$cronscript.='$cronftp='.$config['cron_ftp'].';'.$nl;
|
||||
$cronscript.='$ftp_server="'.$config['ftp_server'][$config['ftp_connectionindex']].'";'.$nl;
|
||||
$cronscript.='$ftp_port='.$config['ftp_port'][$config['ftp_connectionindex']].';'.$nl;
|
||||
$cronscript.='$ftp_user="'.$config['ftp_user'][$config['ftp_connectionindex']].'";'.$nl;
|
||||
$cronscript.='$ftp_pass="'.strtr($config['ftp_pass'][$config['ftp_connectionindex']],$tomask).'";'.$nl;
|
||||
$cronscript.='$ftp_dir="'.$config['ftp_dir'][$config['ftp_connectionindex']].'";'.$nl;
|
||||
$cronscript.='$mp='.$config['multi_part'].';'.$nl;
|
||||
$cronscript.='$multipart_groesse='.$config['multipart_groesse'].';'.$nl;
|
||||
$cronscript.='$email_maxsize='.$config['email_maxsize'].';'.$nl;
|
||||
$cronscript.='$auto_delete='.$config['auto_delete'].';'.$nl;
|
||||
$cronscript.='$cron_del_files_after_days='.$config['del_files_after_days'].';'.$nl;
|
||||
$cronscript.='$max_backup_files='.$config['max_backup_files'].';'.$nl;
|
||||
$cronscript.='$max_backup_files_each='.$config['max_backup_files_each'].';'.$nl;
|
||||
$cronscript.='$perlspeed='.$config['perlspeed'].';'.$nl;
|
||||
$cronscript.='$optimize_tables_beforedump='.$config['optimize_tables_beforedump'].';'.$nl;
|
||||
$cronscript.='$logcompression='.$config['logcompression'].';'.$nl;
|
||||
$cronscript.='$log_maxsize='.$config['log_maxsize'].';'.$nl;
|
||||
$cronscript.='$backup_complete_inserts='.$config['backup_complete_inserts'].';'.$nl;
|
||||
$cronscript.='$backup_extended_inserts='.$config['backup_extended_inserts'].';'.$nl;
|
||||
$cronscript.='$backup_delayed_inserts='.$config['backup_delayed_inserts'].';'.$nl;
|
||||
$cronscript.='$backup_ignore_inserts='.$config['backup_ignore_inserts'].';'.$nl;
|
||||
$cronscript.='$backup_lock_tables='.$config['backup_lock_tables'].';'.$nl;
|
||||
$cronscript.='$complete_log='.$config['cron_completelog'].';'.$nl;
|
||||
$cronscript.='$my_comment="";'.$nl;
|
||||
$cronscript.='1;';
|
||||
|
||||
|
||||
//Datei öffnen und schreiben
|
||||
$ret=true;
|
||||
|
||||
|
||||
|
||||
$ext=($config['cron_extender']==0) ? "pl" : "cgi";
|
||||
|
||||
$sfile=$config['paths']['config'].$config['cron_configurationfile'];
|
||||
|
||||
@chmod("$sfile",0777);
|
||||
if ($fp=fopen($sfile, "wb"))
|
||||
{
|
||||
if (!fwrite($fp,$cronscript)) $ret=false;
|
||||
if (!fclose($fp)) $ret=false;
|
||||
}
|
||||
else $ret=false;
|
||||
|
||||
if(!file_exists($config['paths']['config']."mysqldumper.conf")) {
|
||||
$sfile=$config['paths']['config']."mysqldumper.conf";
|
||||
if ($fp=fopen($sfile, "wb"))
|
||||
{
|
||||
if (!fwrite($fp,$cronscript)) $ret=false;
|
||||
if (!fclose($fp)) $ret=false;
|
||||
//chmod("$sfile",0755);
|
||||
}
|
||||
else $ret=false;
|
||||
}
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
function LogFileInfo($logcompression) {
|
||||
global $config;
|
||||
|
||||
$l=Array();$sum=$s=$l['log_size']=$l['perllog_size']=$l['perllogcomplete_size']=$l['errorlog_size']=$l['log_totalsize']=0;
|
||||
if($logcompression==1) {
|
||||
$l['log']=$config['files']['log'].".gz";
|
||||
$l['perllog']=$config['files']['perllog'].".gz";
|
||||
$l['perllogcomplete']=$config['files']['perllogcomplete'].".gz";
|
||||
$l['errorlog']=$config['paths']['log']."error.log.gz";
|
||||
} else {
|
||||
$l['log']=$config['files']['log'];
|
||||
$l['perllog']=$config['files']['perllog'];
|
||||
$l['perllogcomplete']=$config['files']['perllogcomplete'];
|
||||
$l['errorlog']=$config['paths']['log']."error.log";
|
||||
}
|
||||
$l['log_size']+=@filesize($l['log']);$sum+=$l['log_size'];
|
||||
$l['perllog_size']+=@filesize($l['perllog']);$sum+=$l['perllog_size'];
|
||||
$l['perllogcomplete_size']+=@filesize($l['perllogcomplete']);$sum+=$l['perllogcomplete_size'];
|
||||
$l['errorlog_size']+=@filesize($l['errorlog']);$sum+=$l['errorlog_size'];
|
||||
$l['log_totalsize']+=$sum;
|
||||
|
||||
|
||||
return $l;
|
||||
}
|
||||
|
||||
function DeleteLog()
|
||||
{
|
||||
global $config;
|
||||
//Datei öffnen und schreiben
|
||||
$log=date('d.m.Y H:i:s')." Log created.\n";
|
||||
if($config['logcompression']==1) {
|
||||
$fp = @gzopen($config['files']['log'].'.gz', "wb");
|
||||
@gzwrite ($fp,$log);
|
||||
@gzclose ($fp);
|
||||
@chmod($config['files']['log'].'.gz',0755);
|
||||
} else {
|
||||
$fp = @fopen($config['files']['log'], "wb");
|
||||
@fwrite ($fp,$log);
|
||||
@fclose ($fp);
|
||||
@chmod($config['files']['log'],0755);
|
||||
}
|
||||
}
|
||||
|
||||
function SwitchLogfileFormat()
|
||||
{
|
||||
global $config;
|
||||
$del=DeleteFilesM($config['paths']['log'],"*");
|
||||
DeleteLog();
|
||||
}
|
||||
|
||||
|
||||
function CreateDirsFTP() {
|
||||
|
||||
global $lang,$install_ftp_server,$install_ftp_port,$install_ftp_user_name,$install_ftp_user_pass,$install_ftp_path;
|
||||
// Herstellen der Basis-Verbindung
|
||||
echo '<hr>'.$lang['connect_to'].' `'.$install_ftp_server.'` Port '.$install_ftp_port.' ...<br>';
|
||||
$conn_id = ftp_connect($install_ftp_server);
|
||||
// Einloggen mit Benutzername und Kennwort
|
||||
$login_result = ftp_login($conn_id, $install_ftp_user_name, $install_ftp_user_pass);
|
||||
// Verbindung überprüfen
|
||||
if ((!$conn_id) || (!$login_result)) {
|
||||
echo $lang['ftp_notconnected'];
|
||||
echo $lang['connwith']." $tinstall_ftp_server ".$lang['asuser']." $install_ftp_user_name ".$lang['notpossible'];
|
||||
return 0;
|
||||
} else {
|
||||
|
||||
//Wechsel in betroffenes Verzeichnis
|
||||
echo $lang['changedir'].' `'.$install_ftp_path.'` ...<br>';
|
||||
ftp_chdir($conn_id,$install_ftp_path);
|
||||
// Erstellen der Verzeichnisse
|
||||
echo $lang['dircr1'].' ...<br>';
|
||||
ftp_mkdir($conn_id,"work");
|
||||
ftp_site($conn_id, "CHMOD 0777 work");
|
||||
echo $lang['changedir'].' `work` ...<br>';
|
||||
ftp_chdir($conn_id,"work");
|
||||
echo $lang['indir'].' `'.ftp_pwd($conn_id).'`<br>';
|
||||
echo $lang['dircr5'].' ...<br>';
|
||||
ftp_mkdir($conn_id,"config");
|
||||
ftp_site($conn_id, "CHMOD 0777 config");
|
||||
echo $lang['dircr2'].' ...<br>';
|
||||
ftp_mkdir($conn_id,"backup");
|
||||
ftp_site($conn_id, "CHMOD 0777 backup");
|
||||
echo $lang['dircr3'].' ...<br>';
|
||||
ftp_mkdir($conn_id,"structure");
|
||||
ftp_site($conn_id, "CHMOD 0777 structure");
|
||||
echo $lang['dircr4'].' ...<br>';
|
||||
ftp_mkdir($conn_id,"log");
|
||||
ftp_site($conn_id, "CHMOD 0777 log");
|
||||
|
||||
// Schließen des FTP-Streams
|
||||
ftp_quit($conn_id);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function ftp_mkdirs($config,$dirname)
|
||||
{
|
||||
$dir=split("/", $dirname);
|
||||
for ($i=0;$i<count($dir)-1;$i++)
|
||||
{
|
||||
$path.=$dir[$i]."/";
|
||||
@ftp_mkdir($config['dbconnection'],$path);
|
||||
}
|
||||
if (@ftp_mkdir($config['dbconnection'],$dirname))
|
||||
return 1;
|
||||
}
|
||||
|
||||
function IsWritable($dir)
|
||||
{
|
||||
$testfile=$dir . "/.writetest";
|
||||
if ($writable = @fopen ($testfile, 'w')) {
|
||||
@fclose ($writable);
|
||||
@unlink ($testfile);
|
||||
}
|
||||
return $writable;
|
||||
}
|
||||
|
||||
function SearchDatabases($printout)
|
||||
{
|
||||
global $databases,$config,$lang;
|
||||
|
||||
if(!isset($config['dbconnection'])) MSD_mysql_connect();
|
||||
if(isset($config['dbonly']) && $config['dbonly']!='') {
|
||||
$success=@mysql_select_db($config['dbonly'],$config['dbconnection']);
|
||||
if($success) {
|
||||
$databases['db_actual']=$config['dbonly'];
|
||||
$databases['Name'][0]=$config['dbonly'];
|
||||
$databases['praefix'][0] = "";
|
||||
$databases['command_before_dump'][0] = "";
|
||||
$databases['command_after_dump'][0] = "";
|
||||
$databases['db_selected_index']=0;
|
||||
if($printout==1) echo "... ".$lang['found_db']." `".$config['dbonly']."`<br />";
|
||||
} else echo '<div style="color:red;">'.$lang['found_no_db'].' `'.$config['dbonly']."` !</div>";
|
||||
} else {
|
||||
$db_list = @mysql_list_dbs($config['dbconnection']);
|
||||
$i=0;
|
||||
if($db_list && @mysql_num_rows($db_list)>0) {
|
||||
$databases['db_selected_index'] = 0;
|
||||
while ($row = @mysql_fetch_row($db_list))
|
||||
{
|
||||
// Test-Select um zu sehen, ob Berechtigungen existieren
|
||||
if(mysql_query("SHOW TABLES FROM `".$row[0]."`",$config['dbconnection']))
|
||||
{
|
||||
$databases['Name'][$i]=$row[0];
|
||||
$databases['praefix'][$i] = "";
|
||||
$databases['command_before_dump'][$i] = "";
|
||||
$databases['command_after_dump'][$i] = "";
|
||||
|
||||
if($printout==1) echo $lang['found_db'].' `'.$row[0].'`<br />';
|
||||
}
|
||||
}
|
||||
$databases['db_actual']=$databases['Name'][0];
|
||||
$databases['db_selected_index']=0;
|
||||
} else {
|
||||
if($printout==1) echo $lang['dbonlyneed'].'<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
475
mysqldumper/inc/functions_dump.php
Normale Datei
475
mysqldumper/inc/functions_dump.php
Normale Datei
|
|
@ -0,0 +1,475 @@
|
|||
<?php
|
||||
include_once('./inc/functions_global.php');
|
||||
|
||||
//Buffer für Multipart-Filesizeprüfung
|
||||
$buffer=10*1024;
|
||||
|
||||
function new_file($last_groesse=0)
|
||||
{
|
||||
global $dump,$databases,$config,$out,$lang,$nl,$mysql_commentstring;
|
||||
|
||||
// Dateiname aus Datum und Uhrzeit bilden
|
||||
if ($dump['part']-$dump['part_offset']==1) $dump['filename_stamp']=date("Y_m_d_H_i",time());
|
||||
if ($config['multi_part']==1)
|
||||
{
|
||||
$dateiname=$databases['Name'][$dump['dbindex']].'_'.$dump['filename_stamp'].'_part_'.($dump['part']-$dump['part_offset']);
|
||||
}
|
||||
else $dateiname=$databases['Name'][$dump['dbindex']].'_'.date("Y_m_d_H_i",time());
|
||||
$structurefilename=$databases['Name'][$dump['dbindex']].'_structure_file';
|
||||
$endung= ($config['compression']) ? '.sql.gz' : '.sql';
|
||||
$dump['backupdatei']=$dateiname.$endung;
|
||||
$dump['backupdatei_structure']=$structurefilename.$endung;
|
||||
|
||||
if (file_exists($config['paths']['backup'].$dump['backupdatei'])) unlink($config['paths']['backup'].$dump['backupdatei']);
|
||||
if($config['multi_part']==0 || ($config['multi_part']==1 && ($dump['part']-$dump['part_offset'])==1))
|
||||
{
|
||||
if (file_exists($config['paths']['structure'].$dump['backupdatei_structure'])) unlink($config['paths']['structure'].$dump['backupdatei_structure']);
|
||||
}
|
||||
$cur_time=date("Y-m-d H:i");
|
||||
$statuszeile=GetStatusLine().$nl.$mysql_commentstring.' Dump by MySQLDumper '.MSD_VERSION.' ('.$config['homepage'].')'.$nl;
|
||||
|
||||
if ($dump['part']-$dump['part_offset']==1)
|
||||
{
|
||||
if($config['multi_part']==0)
|
||||
{
|
||||
if($config['multi_dump']==1) WriteLog('starting Multidump with '.count($databases['multi']).' Datenbases.');
|
||||
WriteLog('Start Dump \''.$dump['backupdatei'].'\'');
|
||||
}
|
||||
else WriteLog('Start Multipart-Dump \''.$dateiname.'\'');
|
||||
|
||||
$out.='<strong>'.$lang['startdump'].'`'.$databases['Name'][$dump['dbindex']].'`</strong>'.(($databases['praefix'][$dump['dbindex']]!="") ?' ('.$lang['withpraefix'].' <span style="color:blue">'.$databases['praefix'][$dump['dbindex']].'</span>)' : '').'... ';
|
||||
ExecuteCommand('b');
|
||||
if($dump['part']==1)
|
||||
{
|
||||
$dump['table_offset']=0;
|
||||
$dump['countdata']=0;
|
||||
}
|
||||
// Seitenerstaufruf -> Backupdatei anlegen
|
||||
|
||||
$dump['data']=$statuszeile.$mysql_commentstring.' Dump created at '.$cur_time.$nl.$nl;
|
||||
$dump['structure']=$mysql_commentstring.' Status:0:0::'.$databases['Name'][$dump['dbindex']];
|
||||
$dump['structure'].=":php:".MSD_VERSION.$nl;
|
||||
$dump['structure'].=$mysql_commentstring.' Dump by MySQLDumper '.MSD_VERSION.' ('.$config['homepage'].')'.$nl;
|
||||
$dump['structure'].=$mysql_commentstring.' Dump created on '.$cur_time.$nl.$mysql_commentstring.' This file only contains the structure of the database without data \n\n';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if($config['multi_part']!=0) {
|
||||
WriteLog('Continue Multipart-Dump with File '.($dump['part']-$dump['part_offset']).' (last file was '.$last_groesse.' Bytes)');
|
||||
$dump['data']=$statuszeile.$mysql_commentstring.' This is part '.($dump['part']-$dump['part_offset']).' of the backup.'.$nl.$nl.$dump['data'];
|
||||
|
||||
}
|
||||
}
|
||||
WriteToDumpFile();
|
||||
$dump['part']++;
|
||||
}
|
||||
|
||||
function GetStatusLine($kind="php")
|
||||
{
|
||||
/*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)
|
||||
*/
|
||||
|
||||
global $databases,$config, $dump,$mysql_commentstring;
|
||||
|
||||
$t_array=explode("|",$databases['db_actual_tableselected']);
|
||||
$t=0;
|
||||
$r=0;
|
||||
$t_zeile="$mysql_commentstring\n$mysql_commentstring TABLE-INFO\n";
|
||||
MSD_mysql_connect();
|
||||
$res=mysql_query("SHOW TABLE STATUS FROM `".$databases['Name'][$dump['dbindex']]."`");
|
||||
$numrows=mysql_num_rows($res);
|
||||
for($i=0;$i<$numrows;$i++) {
|
||||
$erg=mysql_fetch_array($res);
|
||||
if(($databases['db_actual_tableselected']=="" || ($databases['db_actual_tableselected']!="" && (in_array($erg[0],$t_array)))) && (substr($erg[0],0,strlen($databases['praefix'][$dump['dbindex']]))==$databases['praefix'][$dump['dbindex']])) {
|
||||
$t++;$r+=$erg['Rows'];
|
||||
$t_zeile.="$mysql_commentstring TABLE|".$erg['Name']."|".$erg['Rows']."|".($erg['Data_length']+$erg['Index_length'])."|".$erg['Update_time']."\n";
|
||||
}
|
||||
}
|
||||
//$dump['totalrecords']=$r;
|
||||
$flags=$config['backup_complete_inserts'].$config['backup_extended_inserts'].$config['backup_ignore_inserts'].$config['backup_delayed_inserts'].$config['backup_downgrade'].$config['backup_lock_tables'].$config['optimize_tables_beforedump'];
|
||||
|
||||
$mp=($config['multi_part']==1) ? $mp="MP_".($dump['part']-$dump['part_offset']) : "MP_0";
|
||||
$statusline="$mysql_commentstring Status:$t:$r:$mp:".$databases['Name'][$dump['dbindex']].":$kind:".MSD_VERSION.":".$dump['kommentar'].":";
|
||||
$statusline.=MSD_MYSQL_VERSION.":$flags:::EXTINFO\n".$t_zeile."$mysql_commentstring"." EOF TABLE-INFO\n$mysql_commentstring\n\n";
|
||||
return $statusline;
|
||||
}
|
||||
|
||||
// Liest die Eigenschaften der Tabelle aus der DB und baut die CREATE-Anweisung zusammen
|
||||
function get_def($db, $table,$withdata=1)
|
||||
{
|
||||
global $config,$nl,$mysql_commentstring;
|
||||
|
||||
$def = "\n\n$mysql_commentstring\n$mysql_commentstring Create Table `$table`\n$mysql_commentstring\n\nDROP TABLE IF EXISTS `$table`;\n";
|
||||
mysql_select_db($db);
|
||||
$result = mysql_query('SHOW CREATE TABLE `'.$table.'`',$config['dbconnection']);
|
||||
$row=mysql_fetch_row($result);
|
||||
$def .= (($config['backup_downgrade']==1) ? DownGrade($row[1],false) : $row[1].';')."\n\n";
|
||||
|
||||
if($withdata==1) {
|
||||
$def.="$mysql_commentstring\n$mysql_commentstring Data for Table `$table`\n$mysql_commentstring\n\n";
|
||||
if($config['backup_delayed_inserts']==0) $def.="/*!40000 ALTER TABLE `$table` DISABLE KEYS */;".$nl;
|
||||
if($config['backup_lock_tables']==1 && $config['backup_delayed_inserts']==0) $def.="LOCK TABLES `$table` WRITE;\n\n";
|
||||
}
|
||||
return $def;
|
||||
}
|
||||
|
||||
|
||||
// Liest die Daten aus der DB aus und baut die INSERT-Anweisung zusammen
|
||||
function get_content($db, $table)
|
||||
{
|
||||
global $config,$nl,$dump,$buffer;
|
||||
|
||||
$content='';
|
||||
$delayed=(isset($config['backup_delayed_inserts']) && $config['backup_delayed_inserts']==1) ? 'DELAYED ' : '';
|
||||
$complete=(isset($config['backup_complete_inserts']) && $config['backup_complete_inserts']==1) ? Fieldlist($db,$table).' ':'';
|
||||
$ignore=(isset($config['backup_ignore_inserts']) && $config['backup_ignore_inserts']==1) ? 'IGNORE ':'';
|
||||
|
||||
$table_ready=0;
|
||||
$query='SELECT * FROM `'.$table.'` LIMIT '.$dump['zeilen_offset'].','.($dump['restzeilen']+1);
|
||||
mysql_select_db($db);
|
||||
$result = mysql_query($query,$config['dbconnection']);
|
||||
$ergebnisse=mysql_num_rows($result);
|
||||
$num_felder=mysql_num_fields($result);
|
||||
$first=1;
|
||||
|
||||
if ($ergebnisse>$dump['restzeilen'])
|
||||
{
|
||||
$dump['zeilen_offset']+=$dump['restzeilen'];
|
||||
$ergebnisse--;
|
||||
$dump['restzeilen']=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dump['table_offset']++;
|
||||
$dump['zeilen_offset']=0;
|
||||
$dump['restzeilen']=$dump['restzeilen']-$ergebnisse;
|
||||
$table_ready=1;
|
||||
}
|
||||
$ax=0;
|
||||
for ($x=0;$x<$ergebnisse;$x++)
|
||||
{
|
||||
$row=mysql_fetch_row($result);
|
||||
$ax++;
|
||||
|
||||
if($config['backup_extended_inserts']==0 || ($config['backup_extended_inserts']==1 && $first==1 && $ax==1) ) {
|
||||
$insert = 'INSERT '.$delayed.$ignore.'INTO `'.$table.'` '.$complete.'VALUES (';
|
||||
$first=0;
|
||||
} else $insert='(';
|
||||
|
||||
|
||||
for($j=0; $j<$num_felder;$j++)
|
||||
{
|
||||
if(!isset($row[$j])) $insert .= 'NULL,';
|
||||
else if($row[$j] != '') $insert.= '\''.mysql_escape_string($row[$j]).'\',';
|
||||
else $insert .= '\'\',';
|
||||
}
|
||||
$insert = ereg_replace(',$','',$insert);
|
||||
if(strlen($dump['data'])>400000 || $x==($ergebnisse-1)) {
|
||||
$ax=0;$first=1;
|
||||
}
|
||||
$insert .= ($config['backup_extended_inserts']==0 || $x==($ergebnisse-1) || $ax==0) ? ");\n" : '),';
|
||||
$dump['data'] .= $insert;
|
||||
$dump['countdata']++;
|
||||
if(strlen($dump['data'])>$config['memory_limit'] || ($config['multi_part']==1 && strlen($dump['data'])+$buffer>$config['multipart_groesse']) ) {
|
||||
WriteToDumpFile();
|
||||
}
|
||||
}
|
||||
|
||||
if($table_ready==1 && $config['backup_lock_tables']==1 && $config['backup_delayed_inserts']==0) $dump['data'].="\nUNLOCK TABLES;";
|
||||
if($table_ready==1 && $config['backup_delayed_inserts']==0) $dump['data'].="\n/*!40000 ALTER TABLE `$table` ENABLE KEYS */;\n\n";
|
||||
mysql_free_result($result);
|
||||
}
|
||||
|
||||
function WriteToDumpFile()
|
||||
{
|
||||
global $config,$dump,$buffer;
|
||||
$dump['filesize']=0;
|
||||
|
||||
$df=$config['paths']['backup'].$dump['backupdatei'];
|
||||
$sf=$config['paths']['structure'].$dump['backupdatei_structure'];
|
||||
|
||||
if ($config['compression']==1)
|
||||
{
|
||||
if($dump['data']!='') {
|
||||
$fp = gzopen ($df,'ab');
|
||||
gzwrite ($fp,$dump['data']); gzclose ($fp);
|
||||
}
|
||||
if($dump['structure']!='') {
|
||||
$fp = gzopen ($sf,'ab');
|
||||
gzwrite ($fp,$dump['structure']); gzclose ($fp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($dump['data']!='') {
|
||||
$fp = fopen ($df,'ab');
|
||||
fwrite ($fp,$dump['data']);fclose ($fp);
|
||||
}
|
||||
if($dump['structure']!='') {
|
||||
$fp = fopen ($sf,'ab');
|
||||
fwrite ($fp,$dump['structure']); fclose ($fp);
|
||||
}
|
||||
}
|
||||
$dump['data']=$dump['structure']='';
|
||||
if(!isset($dump['fileoperations'])) $dump['fileoperations']=0;
|
||||
$dump['fileoperations']++;
|
||||
|
||||
if ($config['multi_part']==1) clearstatcache();
|
||||
$dump['filesize']=filesize($df);
|
||||
if ($config['multi_part']==1 && $dump['filesize']+$buffer>$config['multipart_groesse'])
|
||||
new_file($dump['filesize']); // Wenn maximale Dateigroesse erreicht -> neues File starten
|
||||
}
|
||||
|
||||
function ExecuteCommand($when)
|
||||
{
|
||||
global $config,$databases,$dump,$out,$lang;
|
||||
|
||||
if($when=='b') { // before dump
|
||||
$cd=$databases['command_before_dump'][$dump['dbindex']];
|
||||
$cap='before Dump'; $lf='<br>';
|
||||
} else {
|
||||
$cd=$databases['command_after_dump'][$dump['dbindex']];
|
||||
$cap='after Dump'; $lf='';
|
||||
}
|
||||
|
||||
if($cd!='') {
|
||||
//jetzt ausführen
|
||||
if(substr(strtolower($cd),0,7)!='system:') {
|
||||
@mysql_select_db($databases['Name'][$dump['dbindex']]);
|
||||
if(strpos($cd,';')) {
|
||||
$cad=explode(';',$cd);
|
||||
for($i=0;$i<count($cad);$i++) {
|
||||
if($cad[$i]) $result .= @mysql_query($cad[$i],$config['dbconnection']);
|
||||
}
|
||||
} else {
|
||||
$result = @mysql_query($cd,$config['dbconnection']);
|
||||
}
|
||||
if(!$result) {
|
||||
WriteLog("Error while executing Query $cap ($cd) : ".mysql_error());
|
||||
ErrorLog("Command ".$cap,$databases['Name'][$dump['dbindex']],$cd,mysql_error());
|
||||
$dump['errors']++;
|
||||
$out.=$lf.'<span class="error">ERROR executing Query '.$cap.'</span><br>';
|
||||
} else {
|
||||
WriteLog("executing Query $cap ($cd) was successful");
|
||||
$out.=$lf.'<span class="success">executing Query '.$cap.' was successful</span><br>';
|
||||
}
|
||||
} elseif(substr(strtolower($cd),0,7)=="system:") {
|
||||
//$result=@system(substr($cd,7),$returnval);
|
||||
$cap=substr($cd,7);
|
||||
$result=1;
|
||||
if(!$result) {
|
||||
WriteLog("Error while executing System Command $cap");
|
||||
$dump['errors']++;
|
||||
$out.=$lf.'<span class="error">ERROR executing System Command '.$cap.'</span><br>';
|
||||
} else {
|
||||
WriteLog("executing System Command $cap was successful. [$returnval]");
|
||||
$out.=$lf.'<span class="success">executing System Command '.$cap.' was successful</span><br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function DoEmail()
|
||||
{
|
||||
global $config,$dump,$databases,$email,$lang,$out,$REMOTE_ADDR;
|
||||
|
||||
$header="";
|
||||
if($config['cron_use_sendmail']==1) {
|
||||
//sendmail
|
||||
if(ini_get("sendmail_path")!=$config['cron_sendmail']) @ini_set("SMTP",$config['cron_sendmail']);
|
||||
if(ini_get("sendmail_from")!=$config['email_sender']) @ini_set("SMTP",$config['email_sender']);
|
||||
} else {
|
||||
//SMTP
|
||||
}
|
||||
if(ini_get("SMTP")!=$config['cron_smtp']) @ini_set("SMTP",$config['cron_smtp']);
|
||||
if(ini_get("smtp_port")!=25) @ini_set("smtp_port",25);
|
||||
|
||||
|
||||
if($config['multi_part']==0) {
|
||||
$file = $dump['backupdatei'];
|
||||
$file_name=(strpos("/",$file)) ? substr($file,strrpos("/",$file)) : $file;
|
||||
$file_type = filetype($config['paths']['backup'].$file);
|
||||
$file_size = filesize($config['paths']['backup'].$file);
|
||||
if(($config['email_maxsize']>0 && $file_size>$config['email_maxsize']) || $config['send_mail_dump']==0) {
|
||||
//anhang zu gross
|
||||
$subject = "Backup '".$databases['Name'][$dump['dbindex']]."' - ".date("d\.m\.Y H:i",time());
|
||||
$header.= "FROM:".$config['email_sender']."\n";
|
||||
$header.= "MIME-version: 1.0\n";
|
||||
$header .= "X-Mailer: PHP/" . phpversion(). "\n";
|
||||
$header .= "X-Sender-IP: $REMOTE_ADDR\n";
|
||||
$header .= "Content-Type: text/html";
|
||||
if($config['send_mail_dump']!=0) {
|
||||
$msg_body = sprintf(addslashes($lang['emailbody_toobig']),byte_output($config['email_maxsize']),$databases['Name'][$dump['dbindex']],"$file (".byte_output(filesize($config['paths']['backup'].$file)).")<br>");
|
||||
} else {
|
||||
$msg_body = sprintf(addslashes($lang['emailbody_noattach']),$databases['Name'][$dump['dbindex']],"$file (".byte_output(filesize($config['paths']['backup'].$file)).")");
|
||||
}
|
||||
$msg_body.='<a href="http://'.$_SERVER['HTTP_HOST'].substr($_SERVER["PHP_SELF"],0,strrpos($_SERVER["PHP_SELF"],"/")).'/'.$config['paths']['backup'].$file.'">'.$file.'</a>';
|
||||
$email_log="Email sent to '".$config['email_recipient']."'";
|
||||
$email_out=$lang['email_was_send']."`".$config['email_recipient']."`<br>";
|
||||
} else {
|
||||
//alles ok, anhang generieren
|
||||
$msg_body = sprintf(addslashes($lang['emailbody_attach']),$databases['Name'][$dump['dbindex']],"$file (".byte_output(filesize($config['paths']['backup'].$file)).")");
|
||||
$subject = "Backup '".$databases['Name'][$dump['dbindex']]."' - ".date("d\.m\.Y",time());
|
||||
$fp = fopen($config['paths']['backup'].$file, "r");
|
||||
$contents = fread($fp, $file_size);
|
||||
$encoded_file = chunk_split(base64_encode($contents));
|
||||
fclose($fp);
|
||||
$header.= "FROM:".$config['email_sender']."\n";
|
||||
$header.= "MIME-version: 1.0\n";
|
||||
$header.= "Content-type: multipart/mixed; ";
|
||||
$header.= "boundary=\"Message-Boundary\"\n";
|
||||
$header.= "Content-transfer-encoding: 7BIT\n";
|
||||
$header.= "X-attachments: $file_name";
|
||||
$body_top = "--Message-Boundary\n";
|
||||
$body_top.= "Content-type: text/html\n";
|
||||
$body_top.= "Content-transfer-encoding: 7BIT\n";
|
||||
$body_top.= "Content-description: Mail message body\n\n";
|
||||
$msg_body = $body_top . $msg_body;
|
||||
$msg_body.= "\n\n--Message-Boundary\n";
|
||||
$msg_body.= "Content-type: $file_type; name=\"$file\"\n";
|
||||
$msg_body.= "Content-Transfer-Encoding: BASE64\n";
|
||||
$msg_body.= "Content-disposition: attachment; filename=\"$file\"\n\n";
|
||||
$msg_body.= "$encoded_file\n";
|
||||
$msg_body.= "--Message-Boundary--\n";
|
||||
$email_log="Email was sent to '".$config['email_recipient']."' with '".$dump['backupdatei']."'.";
|
||||
$email_out=$lang['email_was_send']."`".$config['email_recipient']."`".$lang['with']."`".$dump['backupdatei']."`.<br>";
|
||||
}
|
||||
} else {
|
||||
//Multipart
|
||||
$mp_sub="Backup '".$databases['Name'][$dump['dbindex']]."' - ".date("d\.m\.Y",time());
|
||||
$subject = $mp_sub;
|
||||
$header.= "FROM:".$config['email_sender']."\n";
|
||||
$header.= "MIME-version: 1.0\n";
|
||||
$header .= "X-Mailer: PHP/" . phpversion(). "\n";
|
||||
$header .= "X-Sender-IP: $REMOTE_ADDR\n";
|
||||
$header .= "Content-Type: text/html";
|
||||
$dateistamm=substr($dump['backupdatei'],0,strrpos($dump['backupdatei'],"part_"))."part_";
|
||||
$dateiendung=($config['compression']==1)?".sql.gz":".sql";
|
||||
$mpdatei=Array();
|
||||
$mpfiles="";
|
||||
for ($i=1;$i<($dump['part']-$dump['part_offset']);$i++) {
|
||||
$mpdatei[$i-1]=$dateistamm.$i.$dateiendung;
|
||||
$sz=byte_output(@filesize($config['paths']['backup'].$mpdatei[$i-1]));
|
||||
$mpfiles.=$mpdatei[$i-1]." (".$sz.")<br>";
|
||||
}
|
||||
$msg_body = ($config['send_mail_dump']==1) ? sprintf(addslashes($lang['emailbody_mp_attach']),$databases['Name'][$dump['dbindex']],$mpfiles) : sprintf(addslashes($lang['emailbody_mp_noattach']),$databases['Name'][$dump['dbindex']],$mpfiles);
|
||||
$email_log="Email was sent to '".$config['email_recipient']."'";
|
||||
$email_out=$lang['email_was_send']."`".$config['email_recipient']."`<br>";
|
||||
}
|
||||
if (@mail($config['email_recipient'], stripslashes($subject), $msg_body, $header)) {
|
||||
$out.= '<span class="success">'.$email_out.'</span>';
|
||||
WriteLog("$email_log");
|
||||
} else {
|
||||
$out.='<span class="error">'.$lang['mailerror'].'</span><br>';
|
||||
WriteLog("Email to '".$config['email_recipient']."' failed !");
|
||||
ErrorLog("Email ",$databases['Name'][$dump['dbindex']],'Subject: '.stripslashes($subject),$lang['mailerror']);
|
||||
$dump['errors']++;
|
||||
}
|
||||
|
||||
if(isset($mpdatei) && $config['send_mail_dump']==1) { // && ($config['email_maxsize']==0 || ($config['email_maxsize']>0 && $config['multipartgroesse2']<=$config['email_maxsize']))) {
|
||||
for($i=0;$i<count($mpdatei);$i++) {
|
||||
$file_name=$mpdatei[$i];
|
||||
$file_type = filetype($config['paths']['backup'].$mpdatei[$i]);
|
||||
$file_size = filesize($config['paths']['backup'].$mpdatei[$i]);
|
||||
$fp = fopen($config['paths']['backup'].$mpdatei[$i], "r");
|
||||
$contents = fread($fp, $file_size);
|
||||
$encoded_file = chunk_split(base64_encode($contents));
|
||||
fclose($fp);
|
||||
$subject =$mp_sub. " [Part ".($i+1)." / ".count($mpdatei)."]";
|
||||
$header= "FROM:".$config['email_sender']."\n";
|
||||
$header.= "MIME-version: 1.0\n";
|
||||
$header.= "Content-type: multipart/mixed; ";
|
||||
$header.= "boundary=\"Message-Boundary\"\n";
|
||||
$header.= "Content-transfer-encoding: 7BIT\n";
|
||||
$header.= "X-attachments: $file_name";
|
||||
$body_top = "--Message-Boundary\n";
|
||||
$body_top.= "Content-type: text/html\n";
|
||||
$body_top.= "Content-transfer-encoding: 7BIT\n";
|
||||
$body_top.= "Content-description: Mail message body\n\n";
|
||||
$msg_body = $body_top.addslashes($lang['email_only_attachment'].$lang['emailbody_footer']);
|
||||
$msg_body.= "\n\n--Message-Boundary\n";
|
||||
$msg_body.= "Content-type: $file_type; name=\"".$mpdatei[$i]."\"\n";
|
||||
$msg_body.= "Content-Transfer-Encoding: BASE64\n";
|
||||
$msg_body.= "Content-disposition: attachment; filename=\"".$mpdatei[$i]."\"\n\n";
|
||||
$msg_body.= "$encoded_file\n";
|
||||
$msg_body.= "--Message-Boundary--\n";
|
||||
$email_log="Email with $mpdatei[$i] was sent to '".$config['email_recipient']."'";
|
||||
$email_out=$lang['email_was_send']."`".$config['email_recipient']."`".$lang['with']."`".$mpdatei[$i]."`.<br>";
|
||||
|
||||
if (@mail($config['email_recipient'], stripslashes($subject), $msg_body, $header)) {
|
||||
$out.= '<span class="success">'.$email_out.'</span>';
|
||||
WriteLog("$email_log");
|
||||
} else {
|
||||
$out.='<span class="error">'.$lang['mailerror'].'</span><br>';
|
||||
WriteLog("Email to '".$config['email_recipient']."' failed !");
|
||||
ErrorLog("Email ",$databases['Name'][$dump['dbindex']],'Subject: '.stripslashes($subject),$lang['mailerror']);
|
||||
$dump['errors']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function DoFTP()
|
||||
{
|
||||
global $config,$dump,$out;
|
||||
|
||||
if($config['multi_part']==0) {
|
||||
SendViaFTP($dump['backupdatei'],1);
|
||||
} else {
|
||||
$dateistamm=substr($dump['backupdatei'],0,strrpos($dump['backupdatei'],"part_"))."part_";
|
||||
$dateiendung=($config['compression']==1)?".sql.gz":".sql";
|
||||
for ($i=1;$i<($dump['part']-$dump['part_offset']);$i++) {
|
||||
$mpdatei=$dateistamm.$i.$dateiendung;
|
||||
SendViaFTP($mpdatei,$i);
|
||||
}
|
||||
}
|
||||
$out.='<span class="success">'."file sent via FTP (".$dump['backupdatei']." => ".$config['ftp_server'][$config['ftp_connectionindex']].")</span><br><br>";
|
||||
}
|
||||
|
||||
function SendViaFTP($source_file,$conn_msg=1)
|
||||
{
|
||||
global $config,$out,$lang;
|
||||
flush();
|
||||
if($conn_msg==1) $out.='<span class="success">'.$lang['filesendftp']."(".$config['ftp_server'][$config['ftp_connectionindex']]." - ".$config['ftp_user'][$config['ftp_connectionindex']].")</span><br>";
|
||||
|
||||
|
||||
// Herstellen der Basis-Verbindung
|
||||
if($config['ftp_useSSL']==0)
|
||||
$conn_id = ftp_connect($config['ftp_server'][$config['ftp_connectionindex']], $config['ftp_port'][$config['ftp_connectionindex']],$config['ftp_timeout']);
|
||||
else
|
||||
$conn_id = ftp_ssl_connect($config['ftp_server'][$config['ftp_connectionindex']], $config['ftp_port'][$config['ftp_connectionindex']],$config['ftp_timeout']);
|
||||
// Einloggen mit Benutzername und Kennwort
|
||||
$login_result = ftp_login($conn_id, $config['ftp_user'][$config['ftp_connectionindex']], $config['ftp_pass'][$config['ftp_connectionindex']]);
|
||||
|
||||
// Verbindung überprüfen
|
||||
if ((!$conn_id) || (!$login_result)) {
|
||||
$out.= '<span class="error">'.$lang['ftpconnerror'].$config['ftp_server'][$config['ftp_connectionindex']].$lang['ftpconnerror1'].$config['ftp_user'][$config['ftp_connectionindex']].$lang['ftpconnerror2'].'</span><br>';
|
||||
exit;
|
||||
} else {
|
||||
if($conn_msg==1) $out.= '<span class="success">'.$lang['ftpconnected1'].$config['ftp_server'][$config['ftp_connectionindex']].$lang['ftpconnerror1'].$config['ftp_user'][$config['ftp_connectionindex']].'</span><br>';
|
||||
}
|
||||
|
||||
// Upload der Datei
|
||||
$dest=$config['ftp_dir'][$config['ftp_connectionindex']].$source_file;
|
||||
$source=$config['paths']['backup'].$source_file;
|
||||
$upload = @ftp_put($conn_id, $dest,$source , FTP_BINARY);
|
||||
|
||||
// Upload-Status überprüfen
|
||||
if (!$upload) {
|
||||
$out.= '<span class="error">'.$lang['ftpconnerror3']."<br>($source -> $dest)</span><br>";
|
||||
} else {
|
||||
$out.= '<span class="success">'.$lang['file'].' <a href="'.$config['paths']['backup'].$source_file.'" class="smallblack">'.$source_file.'</a>'.$lang['ftpconnected2'].$config['ftp_server'][$config['ftp_connectionindex']].$lang['ftpconnected3'].'</span><br>';
|
||||
WriteLog("'$source_file' sent via FTP.");
|
||||
}
|
||||
|
||||
// Schließen des FTP-Streams
|
||||
@ftp_quit($conn_id);
|
||||
}
|
||||
?>
|
||||
350
mysqldumper/inc/functions_files.php
Normale Datei
350
mysqldumper/inc/functions_files.php
Normale Datei
|
|
@ -0,0 +1,350 @@
|
|||
<?php
|
||||
function FilelisteCombo($fpath,$selected) {
|
||||
$r='<select name="selectfile">';
|
||||
$r.='<option value="" '.(($selected=="") ? "SELECTED" : "").'></option>';
|
||||
|
||||
$dh = opendir($fpath);
|
||||
while (false !== ($filename = readdir($dh)))
|
||||
{
|
||||
if ($filename != "." && $filename != ".." && !is_dir($fpath.$filename)) {
|
||||
$r.='<option value="'.$filename.'" ';
|
||||
if($filename==$selected) $r.=' SELECTED';
|
||||
$r.='>'.$filename.'</option>'."\n";
|
||||
}
|
||||
}
|
||||
$r.='</select>';
|
||||
return $r;
|
||||
}
|
||||
|
||||
function sortierdatum($datum)
|
||||
{
|
||||
$p=explode(' ',$datum);
|
||||
$uhrzeit=$p[1];
|
||||
$p2=explode('.',$p[0]);
|
||||
$day=$p2[0];
|
||||
$month=$p2[1];
|
||||
$year=$p2[2];
|
||||
return $year.'.'.$month.'.'.$day.' '.$uhrzeit;
|
||||
}
|
||||
|
||||
function FileList($multi=0)
|
||||
{
|
||||
global $config,$kind,$fpath,$lang,$databases,$href,$dbactiv,$action,$expand;
|
||||
|
||||
$files=Array();
|
||||
if($kind==0){
|
||||
//Backup-Dateien
|
||||
$Theader=$lang['fm_files1'].' '.$lang['of'].' "'.$dbactiv.'"';
|
||||
$Wheader=$lang['fm_files2'];
|
||||
$akind=1;
|
||||
} else {
|
||||
//Struktur-Dateien
|
||||
$Theader=$lang['fm_files2'];
|
||||
$Wheader=$lang['fm_files1'];
|
||||
$akind=0;
|
||||
}
|
||||
$Sum_Files=0;
|
||||
$dh = opendir($fpath);
|
||||
$fl="";
|
||||
$i=0;
|
||||
while (false !== ($filename = readdir($dh)))
|
||||
{
|
||||
if ($filename != "." && $filename != ".." && !is_dir($fpath.$filename))
|
||||
{
|
||||
$files[$i]['name'] = $filename;
|
||||
$Sum_Files++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$fl.='<div align="center">'.br().$lang['fm_choose_file'].br();
|
||||
$fl.='<span id="gd"> </span>'.br().'<br><br>';
|
||||
|
||||
$fl.='<table class="border">'.br();
|
||||
$fl.='<tr>'.br().'<td colspan="8" align="left"><strong>'.$Theader.'</strong></td>'.br().'<td colspan="3" align="right"><a href="filemanagement.php?action='.$action.'&kind='.$akind.'" class="small">'.$Wheader.'</a></td>'.br().'</tr>'.br();
|
||||
|
||||
//Tableheader
|
||||
$fl.='<tr class="thead">'.br().'<th colspan="2">'.$lang['db'].'</th>'.br().'
|
||||
<th>gz</th>'.br().'
|
||||
<th>Script</th>'.br().'
|
||||
<th colspan="2">'.$lang['comment'].'</th>'.br().'
|
||||
|
||||
<th>'.$lang['fm_filedate'].'</th>'.br().'
|
||||
<th>Multipart</th>'.br().'
|
||||
<th>'.$lang['fm_tables'].' / '.$lang['fm_records'].'</th>'.br().'
|
||||
<th align="right" colspan="2">'.$lang['fm_filesize'].'</th>'.br().'</tr>'.br();
|
||||
|
||||
$checkindex=$arrayindex=$gesamt=0;
|
||||
$db_summary_anzahl=Array();
|
||||
if(count($files)>0)
|
||||
{
|
||||
for ($i=0; $i<sizeof($files); $i++)
|
||||
{
|
||||
// Dateigröße
|
||||
$size = filesize($fpath.$files[$i]['name']);
|
||||
$file_datum=date("d\.m\.Y H:i", filemtime($fpath.$files[$i]['name']));
|
||||
|
||||
//statuszeile auslesen
|
||||
$sline='';
|
||||
|
||||
if(substr($files[$i]['name'],-2)=="gz"){
|
||||
if($config['zlib']) {
|
||||
$fp = gzopen ($fpath.$files[$i]['name'], "r");
|
||||
$sline=gzgets($fp,40960);
|
||||
gzclose ($fp);
|
||||
}
|
||||
}else{
|
||||
$fp = fopen ($fpath.$files[$i]['name'], "r");
|
||||
$sline=fgets($fp,5000);
|
||||
fclose ($fp);
|
||||
}
|
||||
$statusline=ReadStatusline($sline);
|
||||
|
||||
$but=ExtractBUT($files[$i]['name']);
|
||||
if ($but=="") $but=$file_datum;
|
||||
$dbn=$statusline['dbname'];
|
||||
|
||||
//jetzt alle in ein Array packen
|
||||
if($statusline['part']=="MP_0" || $statusline['part']=="")
|
||||
{
|
||||
$db_backups[$arrayindex]['name']=$files[$i]['name'];
|
||||
$db_backups[$arrayindex]['db']=$dbn;
|
||||
$db_backups[$arrayindex]['size']=$size;
|
||||
$db_backups[$arrayindex]['date']=$but;
|
||||
$db_backups[$arrayindex]['sort']=sortierdatum($but);
|
||||
$db_backups[$arrayindex]['tabellen']=$statusline['tables'];
|
||||
$db_backups[$arrayindex]['eintraege']=$statusline['records'];
|
||||
$db_backups[$arrayindex]['multipart']=0;
|
||||
$db_backups[$arrayindex]['kommentar']=$statusline['comment'];
|
||||
$db_backups[$arrayindex]['script']=($statusline['script']!="") ? $statusline['script']."(".$statusline['scriptversion'].")" : "";
|
||||
|
||||
if(!isset($db_summary_last[$dbn])) $db_summary_last[$dbn]=$but;
|
||||
$db_summary_anzahl[$dbn]=(isset($db_summary_anzahl[$dbn])) ? $db_summary_anzahl[$dbn]+1 : 1;
|
||||
$db_summary_size[$dbn]=(isset($db_summary_size[$dbn])) ? $db_summary_size[$dbn]+$size : $size;
|
||||
if($but>$db_summary_last[$dbn])$db_summary_last[$dbn]=$but;
|
||||
}
|
||||
else
|
||||
{
|
||||
//multipart nur einmal
|
||||
$done=0;
|
||||
if(!isset($db_summary_size[$dbn])) $db_summary_size[$dbn]=0;
|
||||
for($j=0;$j<$arrayindex;$j++)
|
||||
{
|
||||
if(isset($db_backups[$j]))
|
||||
{
|
||||
if ( ($db_backups[$j]['date']==$but) && ($db_backups[$j]['db']==$dbn) )
|
||||
{
|
||||
$db_backups[$j]['multipart']++;
|
||||
$db_backups[$j]['size']+=$size;
|
||||
$db_summary_size[$dbn]+=$size;
|
||||
$done=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($done==1) $arrayindex--;
|
||||
|
||||
if($done==0)
|
||||
{
|
||||
//Eintrag war noch nicht vorhanden
|
||||
$db_backups[$arrayindex]['name']=$files[$i]['name'];
|
||||
$db_backups[$arrayindex]['db']=$dbn;
|
||||
$db_backups[$arrayindex]['size']=$size;
|
||||
$db_backups[$arrayindex]['date']=$but;
|
||||
$db_backups[$arrayindex]['sort']=sortierdatum($but);
|
||||
$db_backups[$arrayindex]['tabellen']=$statusline['tables'];
|
||||
$db_backups[$arrayindex]['eintraege']=$statusline['records'];
|
||||
$db_backups[$arrayindex]['multipart']=1;
|
||||
$db_backups[$arrayindex]['kommentar']=$statusline['comment'];
|
||||
$db_backups[$arrayindex]['script']=($statusline['script']!="") ? $statusline['script']."(".$statusline['scriptversion'].")" : "";
|
||||
|
||||
if(!isset($db_summary_last[$dbn])) $db_summary_last[$dbn]=$but;
|
||||
$db_summary_anzahl[$dbn]=(isset($db_summary_anzahl[$dbn])) ? $db_summary_anzahl[$dbn]+1 : 1;
|
||||
$db_summary_size[$dbn]=(isset($db_summary_size[$dbn])) ? $db_summary_size[$dbn]+$size : $size;
|
||||
if( $but>$db_summary_last[$dbn])$db_summary_last[$dbn]=$but;
|
||||
|
||||
}
|
||||
}
|
||||
// Gesamtgröße aller Backupfiles
|
||||
$arrayindex++;
|
||||
$gesamt = $gesamt + $size;
|
||||
}
|
||||
}
|
||||
//Schleife fertig - jetzt Ausgabe
|
||||
if ( (isset($db_backups)) && (is_array($db_backups)) ) $db_backups=mu_sort($db_backups,'sort,name');
|
||||
|
||||
// Hier werden die Dateinamen ausgegeben
|
||||
if($arrayindex>0) {
|
||||
for($i=$arrayindex;$i>=0;$i--) {
|
||||
$cl= ($i % 2) ? "dbrow" : "dbrow1";
|
||||
if(isset($db_backups[$i]['db']) && $db_backups[$i]['db']==$dbactiv)
|
||||
{
|
||||
$multi=($db_summary_anzahl[$dbactiv]>1 && $action=="files") ? 1 : 0;
|
||||
|
||||
$fl.='<input type="hidden" name="multi" value="'.$multi.'">';
|
||||
if($db_backups[$i]['multipart']>0) {$dbn=NextPart($db_backups[$i]['name'],1);}else{$dbn=$db_backups[$i]['name'];}
|
||||
$fl.='<tr '.(($dbactiv==$databases['db_actual']) ? 'class="dbrowsel"' : 'class="'.$cl.'"').'>'.br();
|
||||
$fl.='<td align="left" colspan="2" nowrap>'.br();
|
||||
if($multi==0)
|
||||
{
|
||||
$fl.='<input type="hidden" name="multipart[]" value="'.$db_backups[$i]['multipart'].'"><input name="file[]" type="radio" class="radio" value="'.$dbn.'" onClick="Check('.$checkindex++.',0);">';
|
||||
}
|
||||
else
|
||||
{
|
||||
$fl.='<input type="hidden" name="multipart[]" value="'.$db_backups[$i]['multipart'].'"><input name="file[]" type="checkbox" class="checkbox" value="'.$dbn.'" onClick="Check('.$checkindex++.',1);">';
|
||||
}
|
||||
$fl.=($db_backups[$i]['multipart']==0) ? ' <a href="'.$fpath.$dbn.'" title="Backupfile: '.$dbn.'" style="font-size:8pt;">'.(($db_backups[$i]['db']=='unknown') ? $dbn : $db_backups[$i]['db']).'</a></td>'.br() : ' <span style="font-size:8pt;">'.$db_backups[$i]['db'].'</span></td>'.br();
|
||||
|
||||
$fl.='<td class="sm" nowrap align="center">'.((substr($dbn,-3)==".gz") ? '<img src="'.$config['files']['iconpath'].'gz.gif" alt="'.$lang['compressed'].'" width="16" height="16" border="0">' : " ").'</td>';
|
||||
$fl.='<td class="sm" nowrap align="center">'.$db_backups[$i]['script'].'</td>';
|
||||
$fl.='<td class="sm" nowrap align="right">'.(($db_backups[$i]['kommentar']!="") ? '<img src="'.$config['files']['iconpath'].'rename.gif" alt="'.$db_backups[$i]['kommentar'].'" title="'.$db_backups[$i]['kommentar'].'" width="16" height="16" border="0">' : " ").'</td>';
|
||||
$fl.='<td class="sm" nowrap align="left">'.(($db_backups[$i]['kommentar']!="") ? nl2br(wordwrap($db_backups[$i]['kommentar'],50)) : " ").'</td>';
|
||||
|
||||
$fl.='<td class="sm" nowrap>'.$db_backups[$i]['date'].'</td>'.br();
|
||||
$fl.='<td style="text-align:center">';
|
||||
$fl.=($db_backups[$i]['multipart']==0) ? $lang['no'] : '<a style="font-size:11px;" href="filemanagement.php?action=files&kind=0&dbactiv='.$dbactiv.'&expand='.$i.'">'.$db_backups[$i]['multipart'].' Files</a>'; //
|
||||
$fl.='</td>'.br().'<td style="text-align:right;padding-right:12px;" nowrap>';
|
||||
$fl.=($db_backups[$i]['eintraege']!=-1) ? $db_backups[$i]['tabellen'].' / '.number_format($db_backups[$i]['eintraege'],0,",",".") :$lang['fm_oldbackup'];
|
||||
$fl.='</td>'.br();
|
||||
$fl.='<td align="right" colspan="2" style="font-size:8pt;">'.byte_output($db_backups[$i]['size']).'</td>'.br();
|
||||
$fl.='</tr>'.br();
|
||||
|
||||
if($expand==$i) {
|
||||
$fl.='<tr '.(($dbactiv==$databases['db_actual']) ? 'class="dbrowsel"' : 'class="'.$cl.'"').'>'.br();
|
||||
$fl.='<td class="sm" valign="top">All Parts:</td><td class="sm" colspan="11" align="left">'.PartListe($db_backups[$i]['name'],$db_backups[$i]['multipart']).'</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fl.='<tr>'.br().'<td colspan="11" align="left"><br><strong>'.$lang['fm_all_bu'].'</strong></td>'.br().'</tr>'.br();
|
||||
//Tableheader
|
||||
$fl.='<tr class="thead">'.br().'<th colspan="5" align="left">'.$lang['fm_dbname'].'</th>'.br().'
|
||||
<th align="left">'.$lang['fm_anz_bu'].'</th>'.br().'
|
||||
<th>'.$lang['fm_last_bu'].'</th>'.br().'
|
||||
<th colspan="4" style="text-align:right;">'.$lang['fm_totalsize'].'</th></tr>'.br();
|
||||
//die anderen Backups
|
||||
if(count($db_summary_anzahl)>0)
|
||||
{
|
||||
$i=0;
|
||||
while(list($key, $val) = each($db_summary_anzahl))
|
||||
{
|
||||
$cl= ($i++ % 2) ? "dbrow" : "dbrow1";
|
||||
$keyaus=($key=="unknown") ? '<em>'.$lang['no_msd_backupfile'].'</em>' : $key;
|
||||
$fl.='<tr class="'.$cl.'">'.br().'<td colspan="5" align="left"><a href="'.$href.'&dbactiv='.$key.'">'.$keyaus.'</a></td>'.br();
|
||||
$fl.='<td style="text-align:right">'.$val.' </td>'.br();
|
||||
$fl.='<td class="sm" nowrap>'.((isset($db_summary_last[$key])) ? $db_summary_last[$key] : "").'</td>'.br();
|
||||
$fl.='<td style="text-align:right;font-size:8pt;" colspan="4">'.byte_output($db_summary_size[$key]).' </td>'.br();
|
||||
$fl.='</tr>'.br(3);
|
||||
}
|
||||
}
|
||||
if (!is_array($files)) $fl.='<tr><td colspan="11">'.$lang['fm_nofilesfound'].'</td></tr>'.br();
|
||||
|
||||
//--------------------------------------------------------
|
||||
//*** Ausgabe der Gesamtgröße aller Backupfiles ***
|
||||
//--------------------------------------------------------
|
||||
$space = MD_FreeDiskSpace();
|
||||
$fl.= '<tr>'.br();
|
||||
$fl.= '<td align="left" colspan="8"><b>'.$lang['fm_totalsize'].' ('.$Sum_Files.' files): </b> </td>'.br();
|
||||
$fl.= '<td style="text-align:right" colspan="3"><b>'.byte_output($gesamt).'</b></td>'.br();
|
||||
$fl.= '</tr>'.br();
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
//*** Ausgabe des freien Speicher auf dem Rechner ***
|
||||
//--------------------------------------------------------
|
||||
$fl.= '<tr>'.br();
|
||||
$fl.= '<td colspan="8" align="left">'.$lang['fm_freespace'].': </td>'.br();
|
||||
$fl.= '<td colspan="3" style="text-align:right"><b>'.$space.'</b></td>'.br();
|
||||
$fl.= '</tr>'.br();
|
||||
$fl.= '</table></div>'.br();
|
||||
|
||||
return $fl;
|
||||
}
|
||||
|
||||
function PartListe($f,$nr)
|
||||
{
|
||||
global $config;
|
||||
$dateistamm=substr($f,0,strrpos($f,"part_"))."part_";
|
||||
$dateiendung=(substr(strtolower($f),-2)=="gz")?".sql.gz":".sql";
|
||||
$s="";
|
||||
for($i=1;$i<=$nr;$i++) {
|
||||
if($i>1) $s.="<br>";
|
||||
$s.='<a href="'.$config['paths']['backup'].$dateistamm.$i.$dateiendung.'">'.$dateistamm.$i.$dateiendung.'</a> '.byte_output(@filesize($config['paths']['backup'].$dateistamm.$i.$dateiendung));
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
function Converter($filesource,$filedestination,$cp) {
|
||||
global $config,$lang;
|
||||
|
||||
$cps=(substr(strtolower($filesource),-2)=="gz") ? 1 : 0;
|
||||
echo "<h5>".sprintf($lang['convert_fileread'],$filesource).".....</h5><span style=\"font-size:10px;\">";
|
||||
if(file_exists($config['paths']['backup'].$filedestination)) unlink($config['paths']['backup'].$filedestination);
|
||||
$f = ($cps==1) ? gzopen($config['paths']['backup'].$filesource,"r") : fopen($config['paths']['backup'].$filesource,"r");
|
||||
$z= ($cps==1) ? gzopen($config['paths']['backup'].$filedestination,"w") : fopen($config['paths']['backup'].$filedestination,"w");
|
||||
$insert=$mode="";
|
||||
$n=0;
|
||||
$eof= ($cps==1) ? gzeof($f) : feof($f);
|
||||
WHILE (!$eof)
|
||||
{
|
||||
$eof= ($cps==1) ? gzeof($f) : feof($f);
|
||||
$zeile= ($cps==1) ? gzgets($f,8192) : fgets($f,8192);
|
||||
if (substr($zeile,0,2)=="--") $zeile="";
|
||||
//$zeile=rtrim($zeile);
|
||||
$t=strtolower(substr($zeile,0,10));
|
||||
if ($t>"")
|
||||
{
|
||||
switch ($t)
|
||||
{
|
||||
case "insert int":
|
||||
{
|
||||
// eine neue Insert Anweisung beginnt
|
||||
$insert= substr($zeile,0,strpos($zeile,"("));
|
||||
if(substr(strtoupper($insert),-7)!="VALUES ") $insert.="VALUES ";
|
||||
$mode="insert";
|
||||
|
||||
};
|
||||
break;
|
||||
case "create tab":
|
||||
{
|
||||
$mode="create";
|
||||
WHILE (substr(rtrim($zeile),-1)!=";")
|
||||
{
|
||||
$zeile.=fgets($f,8192);
|
||||
}
|
||||
$zeile="\n\r".MySQL_Ticks($zeile)."\n\r";
|
||||
break;
|
||||
}
|
||||
case "drop table":
|
||||
{
|
||||
$mode="drop";
|
||||
$zeile.="\n\r";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($mode=="insert")
|
||||
{
|
||||
// Komma loeschen
|
||||
$zeile=str_replace("),(",");\n$insert (",$zeile);
|
||||
if(substr(rtrim($zeile),0,2)==",(" && $insert !="") {
|
||||
$zeile=";\n".$insert.substr($zeile,1);
|
||||
}
|
||||
if(substr(rtrim($zeile),-2)==")," && $insert !="") {
|
||||
$zeile=substr(rtrim($zeile),0,strlen(rtrim($zeile))-1).";\n$insert";
|
||||
}
|
||||
}
|
||||
$n++;
|
||||
if ($n>1000) { $n=0;echo "<br>"; }
|
||||
echo ".";
|
||||
if($cps==1) gzwrite($z,$zeile); else fwrite($z,$zeile);
|
||||
}
|
||||
flush();
|
||||
$n++;
|
||||
}
|
||||
if($cps==1) gzclose($z); else fclose($z);
|
||||
if($cps==1) gzclose($f); else fclose($f);
|
||||
echo "</span><h5>".sprintf($lang['convert_finished'],$filedestination)."</h5>";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
954
mysqldumper/inc/functions_global.php
Normale Datei
954
mysqldumper/inc/functions_global.php
Normale Datei
|
|
@ -0,0 +1,954 @@
|
|||
<?php
|
||||
include_once('./inc/runtime.php');
|
||||
|
||||
function get_page_parameter($parameter,$ziel='dump')
|
||||
{
|
||||
$page_parameter='<form action="'.$ziel.'.php" method="POST" name="'.$ziel.'">'."\n";
|
||||
foreach ($parameter As $key=>$val)
|
||||
{
|
||||
$page_parameter.='<input type="hidden" name="'.$key.'" value="'.$val.'">'."\n";
|
||||
}
|
||||
$page_parameter.='</form>';
|
||||
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<count($array); $u++)
|
||||
{
|
||||
$arr = $array[$u];
|
||||
for ($s=0; $s<count($nkeys); $s++)
|
||||
{
|
||||
$k = $nkeys[$s];
|
||||
$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;
|
||||
|
||||
$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++)
|
||||
{
|
||||
$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();
|
||||
mysql_select_db($databases['Name'][$index]);
|
||||
$databases['Detailinfo']['Name']=$databases['Name'][$index];
|
||||
$res=@mysql_query('SHOW TABLE STATUS FROM `'.$databases['Name'][$index].'`');
|
||||
if($res) $databases['Detailinfo']['tables']=mysql_num_rows($res);
|
||||
if($databases['Detailinfo']['tables']>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)
|
||||
{
|
||||
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 '<script language="JavaScript">WP("'.addslashes($txt).','.$object.'");</script>';
|
||||
}
|
||||
|
||||
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) .'<br>';
|
||||
@gzclose ($fp);
|
||||
} else echo '<p class="warnung">'.$lang['logfilenotwritable'].' ('.$logfile.')</p>';
|
||||
} else {
|
||||
$fp = @fopen($logfile, "ab");
|
||||
if($fp) {
|
||||
@fwrite ($fp,$log);
|
||||
@fclose ($fp);
|
||||
} else echo '<p class="warnung">'.$lang['logfilenotwritable'].' ('.$logfile.')</p>';
|
||||
}
|
||||
}
|
||||
|
||||
function WritePageParams($aktion)
|
||||
{
|
||||
global $config,$restore,$dump,$nl;
|
||||
|
||||
$pars="<?$nl";
|
||||
if($aktion=="dump") {
|
||||
$datei="dump.tmp";
|
||||
foreach($dump as $var => $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.='<font color="red">Error-Message: '.$error.'</font>|:|';
|
||||
}
|
||||
else
|
||||
{
|
||||
$errormsg.='<font color="green">Notice: '.$error.'</font>|:|';
|
||||
}
|
||||
|
||||
$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! <a href="main.php?help=1&thema=path&dir=config"><img src="'.$config['files']['iconpath'].'help16.gif" alt="" width="16" height="16" border="0"></a><br>';
|
||||
if($path=="" || $path=="backup") if(!is_writable($config['paths']['backup'])) $warn.='Backuppath is not writable! <a href="main.php?help=1&thema=path&dir=backup"><img src="'.$config['files']['iconpath'].'help16.gif" alt="" width="16" height="16" border="0"></a><br>';
|
||||
if($path=="" || $path=="structure") if(!is_writable($config['paths']['structure'])) $warn.='Structurepath is not writable! <a href="main.php?help=1&thema=path&dir=structure"><img src="'.$config['files']['iconpath'].'help16.gif" alt="" width="16" height="16" border="0"></a><br>';
|
||||
if($path=="" || $path=="log") if(!is_writable($config['paths']['log'])) $warn.='Logpath is not writable! <a href="main.php?help=1&thema=path&dir=log"><img src="'.$config['files']['iconpath'].'help16.gif" alt="" width="16" height="16" border="0"></a><br>';
|
||||
if($warn!="") $warn='<span class="warnung"><strong>ERROR !</strong><br>'.$warn.'</span>';
|
||||
return $warn;
|
||||
}
|
||||
|
||||
function TestWorkDir()
|
||||
{
|
||||
global $config;
|
||||
|
||||
//echo "work_chmod: $config['paths']['work']_chmod<br>";
|
||||
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;$i<count($t_sql);$i++) {
|
||||
$res=mysql_query($t_sql[$i]) 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");
|
||||
$sline=gzgets($fp,40960);
|
||||
gzclose ($fp);
|
||||
}else{
|
||||
$fp = fopen ($config['paths']['backup'].$filename, "r");
|
||||
$sline=fgets($fp,500);
|
||||
fclose ($fp);
|
||||
}
|
||||
$statusline=ReadStatusline($sline);
|
||||
$tabellenanzahl=($statusline["tables"]==-1) ? "" : $statusline["tables"];
|
||||
$eintraege=($statusline["records"]==-1) ? "" : $statusline["records"];
|
||||
$part=($statusline["part"]=="MP_0") ? 0 : substr($statusline["part"],3);
|
||||
$databases['db_actual']=$statusline["dbname"];
|
||||
$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<sizeof($files); $i++)
|
||||
{
|
||||
$delfile=explode("|",$files[$i]);
|
||||
$ts=substr($delfile[0],0,4)."-".substr($delfile[0],5,2)."-".substr($delfile[0],8,2);
|
||||
if(strtotime($ts)<$nowtime){
|
||||
$out.=DeleteFile($files[$i],"days");
|
||||
unset($files[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@rsort($files);
|
||||
if($config['max_backup_files'] > 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="<p class=\"error\">".$ll."<br>";
|
||||
$r.= $delfile[3]."<br>";
|
||||
WriteLog("autodeleted ($function) '$delfile[3]'.");
|
||||
unlink($config['paths']['backup'].$delfile[3]);
|
||||
$r.= "</p>";
|
||||
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= '<form action="main.php?action=senderror" method="post">';
|
||||
$r.='<div id="content"><table class="bordersmall"><tr class="thead"><th align="center" colspan="2"><h4>'.$subject.'</h4></th></tr>'."\n";
|
||||
$r.='<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Absender</td><td><input type="text" name="error_absender" size="40" value="'.$config['email_recipient'].'"></td></tr>'."\n";
|
||||
$r.='<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Name</td><td><input type="text" name="error_name" size="40"></td></tr>'."\n";
|
||||
$r.='<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Art des Fehlers</td><td><input type="text" name="error_kind" value="'.$error_kind.'" size="40"></td></tr>'."\n";
|
||||
$r.='<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td valign="top">Anzeige des Fehlers</td><td><textarea name="error_aus" cols="30" rows="6">'.$error_aus.'</textarea></td></tr>'."\n";
|
||||
$r.='<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td valign="top">zusätzliche Bemerkungen</td><td><textarea name="error_zusatz" cols="30" rows="6"></textarea></td></tr>'."\n";
|
||||
|
||||
$vi= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>MySQLDump-Version</td><td><b>'.MSD_VERSION.'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>MySQL-Version</td><td><b>'.MSD_MYSQL_VERSION.'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>PHP-Version</td><td><b>'.phpversion().'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>PHP-Extensions</td><td width="600"><b>'.implode(" ",get_loaded_extensions()).'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>safe_mode</td><td width="600"><b>'.(($config['safe_mode']==1) ? "on" : "off").'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>magic_quotes</td><td width="600"><b>'.(($config['magic_quotes_gpc']==1) ? "on" : "off").'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Variable rootdir</td><td width="600"><b>'.addslashes($config['paths']['root']).'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Server PHP_SELF</td><td width="600"><b>'.$_SERVER['PHP_SELF'].'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Server Path</td><td width="600"><b>'. addslashes(str_replace(';',";<br>",str_replace('\\','/',$_SERVER['PATH']))).'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Server Script-Filename</td><td width="600"><b>'.$_SERVER['SCRIPT_FILENAME'].'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Server Script-Name</td><td width="600"><b>'.$_SERVER['SCRIPT_NAME'].'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Global PHP_SELF</td><td width="600"><b>'.$PHP_SELF.'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Global Path</td><td width="600"><b>'. addslashes($PATH).'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Global Path-Translated</td><td width="600"><b>'. addslashes($PATH_TRANSLATED).'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Global Script-Filename</td><td width="600"><b>'.addslashes($SCRIPT_FILENAME).'</b></td></tr>'."\n";
|
||||
$vi.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td>Global Script-Name</td><td width="600"><b>'.addslashes($SCRIPT_NAME).'</b></td></tr>'."\n";
|
||||
|
||||
$formvi=str_replace("<","<",$vi);
|
||||
$formvi=str_replace(">",">",$formvi);
|
||||
|
||||
//Form-vars
|
||||
$r.=$vi.'<input type="hidden" name="error_vars" value="'.$formvi.'">';
|
||||
$r.='<input type="hidden" name="error_subject" value="'.$subject.'">';
|
||||
$r.='<input type="hidden" name="error_mailfrom" value="'.$config['email_sender'].'">';
|
||||
|
||||
$r.= '<tr class="'.(($i++ % 2) ? 'dbrow' : 'dbrow1').'"><td colspan="2" align="center"><input class="Formbutton" type="submit" name="error_submit" value="Fehlerbericht absenden"></td></tr>';
|
||||
|
||||
|
||||
$r.= "</table><br><br><a href='main.php'>Home</a>".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='<span class="error">'.$lang['noftppossible'].'+++</span>';
|
||||
} else $pass=0;
|
||||
|
||||
if($pass==0) {
|
||||
if($ftp_server=="" || $ftp_user_name=="" || $ftp_user_pass=="") {
|
||||
$s='<span class="error">'.$lang['wrongconnectionpars'].'</span>';
|
||||
} else $pass=1;
|
||||
}
|
||||
|
||||
|
||||
if($pass==1) {
|
||||
$s=$lang['connect_to'].' `'.$ftp_server.'` Port '.$ftp_port.'<br>';
|
||||
|
||||
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.='<span class="error">'.$lang['conn_not_possible'].'</span>';
|
||||
} else $pass=2;
|
||||
}
|
||||
|
||||
if($pass==2) {
|
||||
$s.='<br><strong>Login ok</strong><br>'.$lang['changedir'].' `'.$ftp_dir.'` ... ';
|
||||
$dirc=@ftp_chdir($conn_id,$ftp_dir);
|
||||
if(!$dirc) {
|
||||
$s.='<br><span class="error">'.$lang['changedirerror'].'</span>';
|
||||
} else $pass=3;
|
||||
@ftp_close($conn_id);
|
||||
}
|
||||
if($pass==3) $s.='<br><br><strong>'.$lang['ftp_ok'].'</strong>';
|
||||
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.='<option value="'.$f.'" ';
|
||||
if($filename==$default) $r.=' SELECTED';
|
||||
$r.='> '.$f.' </option>'."\n";
|
||||
}
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
function GetThemes() {
|
||||
global $config;
|
||||
$default=$config['theme'];
|
||||
$dh = opendir($config['paths']['root']."css/");
|
||||
$r="";
|
||||
while (false !== ($filename = readdir($dh)))
|
||||
{
|
||||
if ($filename != "." && $filename != ".." && is_dir($config['paths']['root']."css/".$filename)) {
|
||||
|
||||
$r.='<option value="'.$filename.'" ';
|
||||
if($filename==$default) $r.=' SELECTED';
|
||||
$r.='> '.$filename.' </option>'."\n";
|
||||
}
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
function GetLanguageCombo($k="op",$class="",$name="",$start="",$end="") {
|
||||
global $config,$lang;
|
||||
$default=$config['language'];
|
||||
$dh = opendir($config['paths']['root']."language/");
|
||||
$r="";
|
||||
while (false !== ($filename = readdir($dh)))
|
||||
{
|
||||
if ($filename != "." && $filename != ".." && $filename != "flags" && is_dir($config['paths']['root']."language/".$filename)) {
|
||||
//echo $config['paths']['root']."language/".$filename."<br>";
|
||||
if($k=="op") {
|
||||
$r.=$start.'<option value="'.$filename.'" ';
|
||||
if($filename==$default) $r.=' SELECTED';
|
||||
$r.=' class="'.$class.'"> '.$lang[$filename].' </option>'.$end."\n";
|
||||
} elseif($k=="radio") {
|
||||
$r.=$start.'<input type="radio" class="'.$class.'" name="'.$name.'" value="'.$filename.'" '.(($filename==$default) ? "checked" : "").' onclick="show_tooldivs(\''.$filename.'\');"><img src="language/flags/'.$filename.'.gif" alt="" width="25" height="15" border="0"> '.$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.='<div id="server'.$mainframe.'">'.$lang['server'].': <a class="server" href="http://'.$_SERVER['SERVER_NAME'].'" target="_blank" title="'.$_SERVER['SERVER_NAME'].'">'.$_SERVER['SERVER_NAME'].'</a></div>';
|
||||
}
|
||||
}
|
||||
if ($mainframe==1) {
|
||||
$s.='<div id="pagetitle">'.$title.'</div>';
|
||||
$s.='<div id="content">';
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
function PicCache($rpath="./") {
|
||||
global $BrowserIcon,$config;
|
||||
|
||||
$t='<div style="display:none">';
|
||||
|
||||
$dh=opendir($config['files']['iconpath']);
|
||||
while (false !== ($filename = readdir($dh)))
|
||||
{
|
||||
if ($filename != "." && $filename != ".." && !is_dir($config['files']['iconpath'].$filename)) {
|
||||
$t.='<img src="'.$config['files']['iconpath'].$filename.'" width="16" height="16" alt="">';
|
||||
}
|
||||
}
|
||||
$t.='</div>';
|
||||
return $t;
|
||||
}
|
||||
|
||||
function MSDHeader($kind=0,$onloadFunction="")
|
||||
{
|
||||
global $config, $databases,$lang,$frameset_restore;
|
||||
//kind 0=main 1=menu 2=help
|
||||
$d=($kind==2) ? "../../" : "./";
|
||||
$r='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'."\n<html>\n<head>\n";
|
||||
|
||||
if ($kind==0) {
|
||||
//Main without caching
|
||||
$r.='<META HTTP-EQUIV="Pragma" CONTENT="no-cache">';
|
||||
} else {
|
||||
$r.='<META HTTP-EQUIV="cache-control" CONTENT="public">';
|
||||
}
|
||||
$r.='<META NAME="robots" CONTENT="none">'."\n";
|
||||
$r.='<META NAME="robots" CONTENT="noindex">'."\n";
|
||||
$r.='<title>MySqlDumper</title>'."\n";
|
||||
$r.='<link rel="stylesheet" type="text/css" href="'.$d.'css/'.$config['theme'].'/style.css">'."\n";
|
||||
$r.='<script language="JavaScript" src="'.$d.'js/script.js" type="text/javascript"></script>'."\n";
|
||||
|
||||
|
||||
if($frameset_restore==1) $r.='<script language="JavaScript">
|
||||
//restore the frameset
|
||||
var params="";
|
||||
if(document.URL.indexOf("/") != -1)
|
||||
{
|
||||
var stringArray = document.URL.split("/");
|
||||
params = stringArray.pop();
|
||||
}
|
||||
if (parent.frames.length == 0) { parent.location.href="index.php?page="+params; }
|
||||
</script>';
|
||||
|
||||
|
||||
$r.="</head>\n<body ".(($kind==1) ? 'class="menu"' : '').(($onloadFunction!="") ? ' onload="'.$onloadFunction.'();"' : '').'>';
|
||||
|
||||
return $r;
|
||||
}
|
||||
function MSDFooter($rfoot="",$enddiv=1)
|
||||
{
|
||||
global $config, $databases,$dump,$restore,$lang;
|
||||
$f= '<div id="footer">'.$lang['authors'].':
|
||||
<a class="small" href="http://dislabs.de" target="_new">
|
||||
Daniel Schlichtholz & Steffen Kamper</a> - Infoboard:
|
||||
<a class="small" href="'.$config['homepage'].'" target="_blanc">'.
|
||||
$config['homepage'].'</a></div>';
|
||||
|
||||
if($enddiv==1) $f.= '</div>';
|
||||
|
||||
$f.=$rfoot.'</body></html>';
|
||||
|
||||
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 "<pre>";print_r($tmp);echo "</pre>";
|
||||
|
||||
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++) {
|
||||
//echo $j.": ".$tmp2[$j]."<br>";
|
||||
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<count($tmp2);$j++) {
|
||||
if(strtolower($tmp2[$j])=="collate"){
|
||||
$tmp2[$j]=save_bracket($tmp2[$j]);
|
||||
$tmp2[$j+1]=save_bracket($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).";";
|
||||
// if (strpos($t,'en_rules')) die ("<hr>".$t."</hr>");
|
||||
|
||||
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<count($pieces);$i++) {
|
||||
$r=trim(rtrim($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) {
|
||||
$pos=strpos($r," ");
|
||||
$r="`".substr($r,0,$pos)."`".substr($r,$pos);
|
||||
}
|
||||
}
|
||||
$pieces[$i]=$r;
|
||||
}
|
||||
$back=substr($s,0,$inner_s_start+1).implode(",",$pieces).");";
|
||||
return $back;
|
||||
}
|
||||
|
||||
?>
|
||||
497
mysqldumper/inc/functions_restore.php
Normale Datei
497
mysqldumper/inc/functions_restore.php
Normale Datei
|
|
@ -0,0 +1,497 @@
|
|||
<?php
|
||||
include_once('./inc/functions_global.php');
|
||||
include_once('./inc/runtime.php');
|
||||
define('DEBUG',0);
|
||||
|
||||
function AnzahlTabellenfelder($s,$debug=0)
|
||||
{
|
||||
/******* Diese Funktion wird nur in der develop.php gebraucht *******/
|
||||
// ermittelt die Anzahl der Spalten einer Tabelle aus einer CREATE-Anweisung
|
||||
$anz=$anz_delimter=$rit=$klammerstart=$klammerauf=$klammerzu=0;
|
||||
$s=strtoupper($s);
|
||||
$i=strpos($s,"(")+1;
|
||||
$s=substr($s,$i);
|
||||
$tb=explode(',',$s);
|
||||
|
||||
$defaultstart=false;
|
||||
for ($i=0;$i<count($tb);$i++){
|
||||
$tb[$i]=trim($tb[$i]);
|
||||
$klammerstart+=substr_count($tb[$i], "(")-substr_count($tb[$i], ")");
|
||||
if($i==count($tb)-1) $klammerstart+=1;
|
||||
$anz_delimter+=substr_count($tb[$i], "'");
|
||||
if($anz_delimter % 2 ==0) $anz_delimter=0;
|
||||
//kommt ein Index???
|
||||
if(substr($tb[$i],0,4)=='KEY ' ||
|
||||
substr($tb[$i],0,7)=='UNIQUE ' ||
|
||||
substr($tb[$i],0,12)=='PRIMARY KEY ' ||
|
||||
substr($tb[$i],0,13)=='FULLTEXT KEY '
|
||||
) {
|
||||
$rit=1;
|
||||
} else {
|
||||
if($klammerstart==0 && $anz_delimter==0) {
|
||||
if($rit==0) $anz++;
|
||||
$rit=0;
|
||||
}
|
||||
}
|
||||
if($debug==1) echo "$i: $tb[$i]".' <font color="#0000FF">'.$anz."</font> [offene Klammern: $klammerstart] --$rit<br>";
|
||||
|
||||
}
|
||||
return $anz;
|
||||
}
|
||||
|
||||
function get_sqlbefehl()
|
||||
{
|
||||
global $restore,$config,$databases,$lang;
|
||||
|
||||
//Init
|
||||
$restore['fileEOF']=false;
|
||||
$restore['EOB']=false;
|
||||
$complete_sql='';
|
||||
$sqlparser_status=0;
|
||||
if(!isset($restore['eintraege_ready'])) $restore['eintraege_ready']=0;
|
||||
|
||||
//Parsen
|
||||
WHILE ($sqlparser_status!=100 && !$restore['fileEOF'] && !$restore['EOB'] )
|
||||
{
|
||||
//nächste Zeile lesen
|
||||
$zeile= ($restore['compressed']) ? gzgets($restore['filehandle']) : fgets($restore['filehandle']);
|
||||
|
||||
/******************* Setzen des Parserstatus *******************/
|
||||
// herausfinden um was für einen Befehl es sich handelt
|
||||
IF ($sqlparser_status==0)
|
||||
{
|
||||
|
||||
//Vergleichszeile, um nicht bei jedem Vergleich strtoupper ausführen zu müssen
|
||||
$zeile2=strtoupper(trim($zeile));
|
||||
|
||||
// Am Ende eines MySQLDumper-Backups angelangt?
|
||||
if(substr($zeile2,0,6)=='-- EOB' || substr($zeile2,0,5)=='# EOB')
|
||||
{
|
||||
$restore['EOB']=true;
|
||||
$zeile='--';$zeile2='--';
|
||||
$sqlparser_status=100;
|
||||
}
|
||||
|
||||
// Kommenatr?
|
||||
if ( (substr($zeile2,0,2)=='--') || (substr($zeile2,0,1)=='#') )
|
||||
{
|
||||
$zeile='';$zeile2=''; $sqlparser_status=0;
|
||||
}
|
||||
|
||||
//Einfache Anweisung finden die mit Semikolon beendet werden
|
||||
if(substr($zeile2,0,11)=='LOCK TABLES') $sqlparser_status=5;
|
||||
if(substr($zeile2,0,6)=='COMMIT') $sqlparser_status=5;
|
||||
if(substr($zeile2,0,5)=='BEGIN') $sqlparser_status=5;
|
||||
if(substr($zeile2,0,13)=='UNLOCK TABLES') $sqlparser_status=5;
|
||||
if(substr($zeile2,0,4)=='SET ') $sqlparser_status=5;
|
||||
if(substr($zeile2,0,6)=='START ') $sqlparser_status=5;
|
||||
if(substr($zeile2,0,3)=='/*!') $sqlparser_status=5; //MySQL-Condition oder Kommentar
|
||||
|
||||
if(substr($zeile2,0,12)=='CREATE TABLE') $sqlparser_status=2; //Createaktion
|
||||
if(substr($zeile2,0,12)=='CREATE INDEX') $sqlparser_status=4; //Indexaktion
|
||||
|
||||
//Kommentar
|
||||
if ( ($sqlparser_status!=5) && (substr($zeile2,0,2)=='/*')) $sqlparser_status=6;
|
||||
|
||||
// Befehle, die nicht ausgeführt werden sollen
|
||||
if (substr($zeile2,0,4)=='USE ') $sqlparser_status=7;
|
||||
if (substr($zeile2,0,14)=='DROP DATABASE ') $sqlparser_status=7;
|
||||
if(substr($zeile2,0,10)=='DROP TABLE') $sqlparser_status=1; //Löschaktion
|
||||
|
||||
if (substr($zeile2,0,7)=='INSERT ')
|
||||
{
|
||||
$sqlparser_status=3; //Datensatzaktion
|
||||
$restore['actual_table']=strtolower(get_tablename_aus_insert($zeile));
|
||||
|
||||
// Pruefen ob die Spaltenanzahl bekannt ist und wenn nicht setzen
|
||||
if(!isset($restore['num_table_fields'][$restore['actual_table']]))
|
||||
{
|
||||
$restore['num_table_fields'][$restore['actual_table']]=get_num_rows($restore['actual_table']);
|
||||
}
|
||||
}
|
||||
// Fortsetzung von erweiterten Inserts
|
||||
if ($restore['flag']==1) $sqlparser_status=3;
|
||||
|
||||
if ( ($sqlparser_status==0) && (trim($complete_sql)>'') && ($restore['flag']==-1) )
|
||||
{
|
||||
// Unbekannten Befehl entdeckt
|
||||
v($restore);
|
||||
echo "<br>Sql: ".$complete_sql;
|
||||
echo "<br>Erweiterte Inserts: ".$restore['erweiterte_inserts'];
|
||||
die('<br>'.$lang['unknown_sqlcommand'].': '.$zeile);
|
||||
}
|
||||
/******************* Ende von Setzen des Parserstatus *******************/
|
||||
}
|
||||
|
||||
$last_char=substr(rtrim($zeile),-1);
|
||||
// Zeilenumbrüche erhalten - sonst werden Schlüsselwörter zusammengefügt
|
||||
// z.B. 'null' und in der nächsten Zeile 'check' wird zu 'nullcheck'
|
||||
$complete_sql.=$zeile."\n";
|
||||
|
||||
if($sqlparser_status==1)
|
||||
{ //Löschaktion
|
||||
if($last_char==';') $sqlparser_status=100; //Befehl komplett
|
||||
}
|
||||
|
||||
if($sqlparser_status==2)
|
||||
{
|
||||
// Createanweisung ist beim Finden eines ; beendet
|
||||
if($last_char==';' )
|
||||
{
|
||||
if($config['minspeed']>0) $restore['anzahl_zeilen']=$config['minspeed'];
|
||||
|
||||
//Spaltenanzahl fuer diese Tabelle merken
|
||||
$restore['actual_table']=get_tablename($complete_sql);
|
||||
|
||||
$complete_sql=del_inline_comments($complete_sql); //Inline-Kommentare entfernen
|
||||
|
||||
//Create ausfuehren und Anzahl der Spalten speichern
|
||||
$restore['actual_fieldcount']=submit_create_action($complete_sql);
|
||||
$restore['num_table_fields'][$restore['actual_table']]=$restore['actual_fieldcount'];
|
||||
|
||||
// Zeile verwerfen und naechsten Befehl suchen
|
||||
$complete_sql='';
|
||||
$sqlparser_status=0;
|
||||
}
|
||||
}
|
||||
|
||||
if($sqlparser_status==3)
|
||||
{
|
||||
//INSERT
|
||||
// Anzahl der Felder ermitteln wenn unbekannt
|
||||
if(!isset($restore['num_table_fields'][$restore['actual_table']]))
|
||||
{
|
||||
$restore['num_table_fields'][$restore['actual_table']]=get_num_rows($restore['actual_table']);
|
||||
}
|
||||
|
||||
|
||||
$AnzahlFelder=SQL_Is_Complete($complete_sql,$restore['num_table_fields'][$restore['actual_table']],DEBUG);
|
||||
|
||||
// einen vollständigen Insert ermittelt
|
||||
if($AnzahlFelder==$restore['num_table_fields'][$restore['actual_table']])
|
||||
{
|
||||
$sqlparser_status=100;
|
||||
$complete_sql=trim($complete_sql);
|
||||
|
||||
// letzter Ausdruck des erweiterten Inserts erreicht?
|
||||
if(substr($complete_sql,-2)==');')
|
||||
{
|
||||
$restore['flag']=-1;
|
||||
}
|
||||
|
||||
// Wenn am Ende der Zeile ein Klammer Komma -> erweiterter Insert-Modus -> Steuerflag setzen
|
||||
if(substr($complete_sql,-2)=='),')
|
||||
{
|
||||
// letztes Komme gegen Semikolon tauschen
|
||||
$complete_sql=substr($complete_sql,0,-1).';';
|
||||
$restore['erweiterte_inserts']=1;
|
||||
$restore['flag']=1;
|
||||
}
|
||||
|
||||
if (substr($complete_sql,0,7)!='INSERT ')
|
||||
{
|
||||
$complete_sql=$restore['insert_syntax'].' VALUES '.$complete_sql.';';
|
||||
}
|
||||
else
|
||||
{
|
||||
// INSERT Syntax ermitteln und merken
|
||||
$ipos=strpos(strtoupper($complete_sql),'VALUES');
|
||||
if (!$ipos===false) $restore['insert_syntax']=substr($complete_sql,0,$ipos);
|
||||
else $restore['insert_syntax']='INSERT INTO `'.$restore['actual_table'].'`';
|
||||
}
|
||||
|
||||
if($AnzahlFelder>$restore['num_table_fields'][$restore['actual_table']] && $restore['erweiterte_inserts']==0)
|
||||
{
|
||||
if(!isset($restore['table_create'][$restore['actual_table']]))
|
||||
{
|
||||
global $lang;
|
||||
include('./inc/functions_sql.php');
|
||||
$restore['table_create'][$restore['actual_table']]=GetCreateTable($databases['db_actual'],$restore['actual_table']);
|
||||
}
|
||||
|
||||
echo '<form action="main.php?action=extinfo" method="post">';
|
||||
echo '<p class="warnung">Parser-Fehler : zuviele gezählt in Tabelle '.$restore["actual_table"].' ('.$AnzahlFelder.' statt '.$restore["num_table_fields"][$restore["actual_table"]].')';
|
||||
echo '<br>Aktuelle Tabelle: '.$restore['actual_table'];
|
||||
echo '<h4>CREATE-Anweisung</h4><textarea name="create_sql" style="width:90%;height:200px;">'.$restore["table_create"][$restore["actual_table"]].'</textarea>';
|
||||
echo '<h4>INSERT-Anweisung</h4><textarea name="insert_sql" style="width:90%;height:200px;">'.$complete_sql.'</textarea></p><br>';
|
||||
echo '<br><br><input type="submit" name="tell_error" value="Fehlerbericht"></form>'.$zeile;
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Index
|
||||
if($sqlparser_status==4)
|
||||
{ //Createindex
|
||||
if($last_char==';' )
|
||||
{
|
||||
if($config['minspeed']>0) {$restore['anzahl_zeilen']=$config['minspeed'];}
|
||||
$complete_sql=del_inline_comments($complete_sql);
|
||||
$sqlparser_status=100; //Befehl komplett
|
||||
}
|
||||
}
|
||||
|
||||
// Kommentar oder Condition
|
||||
if($sqlparser_status==5)
|
||||
{ //Anweisung
|
||||
if($last_char==';' )
|
||||
{
|
||||
if($config['minspeed']>0) {$restore['anzahl_zeilen']=$config['minspeed'];}
|
||||
$complete_sql=del_inline_comments($complete_sql);
|
||||
$sqlparser_status=100; //Befehl komplett
|
||||
}
|
||||
}
|
||||
|
||||
// Mehrzeiliger oder Inline-Kommentar
|
||||
if($sqlparser_status==6)
|
||||
{
|
||||
if(!strrpos($zeile,'*/')===false)
|
||||
{
|
||||
$complete_sql=trim(del_inline_comments($complete_sql));
|
||||
$sqlparser_status=0;
|
||||
}
|
||||
}
|
||||
|
||||
// Befehle, die verworfen werden sollen
|
||||
if($sqlparser_status==7)
|
||||
{ //Anweisung
|
||||
if($last_char==';' )
|
||||
{
|
||||
if($config["minspeed"]>0) {$restore["anzahl_zeilen"]=$config["minspeed"];}
|
||||
$complete_sql='';
|
||||
$sqlparser_status=0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ($restore['compressed']) && (gzeof($restore['filehandle'])) ) $restore['fileEOF']=true;
|
||||
if ( (!$restore['compressed']) && (feof($restore['filehandle'])) ) $restore['fileEOF']=true;
|
||||
|
||||
}
|
||||
return trim($complete_sql);
|
||||
}
|
||||
|
||||
function submit_create_action($sql)
|
||||
{
|
||||
//Führt eine Create-Anweisung durch und ermittelt danach die Anzahl der aktuellen Spalten
|
||||
// und legt diese im Array ab
|
||||
global $restore;
|
||||
$tablename=get_tablename($sql);
|
||||
if (DEBUG)
|
||||
{
|
||||
echo "<br>Tabellenname: ".$tablename;
|
||||
echo "<br>Create: ".$sql;
|
||||
}
|
||||
$res=mysql_query($sql);
|
||||
if (!$res===false)
|
||||
{
|
||||
if (DEBUG) echo "<br>Create-Anweisung erfolgreich ausgeführt.";
|
||||
$restore['actual_table']=$tablename;
|
||||
$restore['table_ready']++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//erster Versuch die Tabelle anzulegen hat nicht geklappt
|
||||
// versuchen wir es mal mit der alten Syntax
|
||||
$res=mysql_query(downgrade($sql));
|
||||
if (!$res===false)
|
||||
{
|
||||
if (DEBUG) echo "<br>Create-Anweisung nach Downgrade erfolgreich ausgeführt.";
|
||||
$restore['actual_table']=$tablename;
|
||||
$restore['table_ready']++;
|
||||
}
|
||||
else
|
||||
{
|
||||
SQLError($sql,'Couldn\'t create table: '.$tablename);
|
||||
die();
|
||||
}
|
||||
}
|
||||
return get_num_rows($tablename);
|
||||
}
|
||||
|
||||
function get_num_rows($tablename)
|
||||
{
|
||||
//Anzahl der Tabellenspalten ermitteln
|
||||
$sql='SHOW COLUMNS FROM `'.$tablename.'`';
|
||||
$res=mysql_query($sql);
|
||||
if ($res)
|
||||
{
|
||||
$num_rows=mysql_num_rows($res);
|
||||
}
|
||||
else
|
||||
{
|
||||
v($restore);
|
||||
die('Couldn\'t read rowcount for table '.$tablename.'!<br>Restore:'.$restore['actual_table']);
|
||||
}
|
||||
return $num_rows;
|
||||
}
|
||||
|
||||
function del_inline_comments($sql)
|
||||
{
|
||||
$sql=str_replace("\n",'<br>',$sql);
|
||||
|
||||
//Inline-Kommentare entfernen
|
||||
preg_match_all("/(\/\*(.+)\*\/)/U",$sql,$array);
|
||||
if (is_array($array[0]))
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
v($array);
|
||||
echo"<br><hr>vorher:<br>".$sql."<br><hr>";
|
||||
}
|
||||
$sql=str_replace($array[0],'',$sql);
|
||||
if (DEBUG) echo"Nachher: :<br>".$sql."<br><hr>";
|
||||
}
|
||||
$sql=trim(str_replace('<br>',"\n",$sql));
|
||||
//Wenn nach dem Entfernen nur noch ein ; übrigbleibt -> entfernen
|
||||
if ($sql==';') $sql='';
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function lock_table()
|
||||
{
|
||||
global $config,$restore;
|
||||
if ($config["lock_tables"]==1 && (isset($restore["actual_table"])) && ($restore["actual_table"]<>"unbekannt") )
|
||||
{
|
||||
$sql="LOCK TABLES `".$restore["actual_table"]."` WRITE";
|
||||
$res=MSD_query($sql) || die(SQLError("Kein Lock ausgeführt!",mysql_error()));
|
||||
}
|
||||
}
|
||||
|
||||
function stri_replace($original,$patterns)
|
||||
{
|
||||
$finalremove=$original;
|
||||
$piece_front='';
|
||||
$piece_back='';
|
||||
$piece_replace='';
|
||||
|
||||
for ($x=0; $x < count($patterns); $x++)
|
||||
{
|
||||
$safety=0;
|
||||
while(strstr(strtolower($finalremove),strtolower($patterns[$x])))
|
||||
{
|
||||
$safety=$safety+1;
|
||||
if ($safety >= 100000) { break; }
|
||||
|
||||
$occ=strpos(strtolower($finalremove),strtolower($patterns[$x]));
|
||||
$piece_front=substr($finalremove,0,$occ);
|
||||
$piece_back=substr($finalremove,($occ+strlen($patterns[$x])));
|
||||
$finalremove=$piece_front . $piece_replace . $piece_back;
|
||||
}
|
||||
}
|
||||
return $finalremove;
|
||||
}
|
||||
|
||||
|
||||
// extrahiert auf einfache Art den Tabellennamen aus dem "Create"-Befehl
|
||||
function get_tablename($t)
|
||||
{
|
||||
global $restore;
|
||||
$ersetzen=array('CREATE TABLE','IF NOT EXISTS');
|
||||
$t=trim(stri_replace($t,$ersetzen));
|
||||
$t=trim(str_replace('(',' ',$t));
|
||||
$w=explode(' ',$t);
|
||||
$tn=$w[0];
|
||||
if(substr($tn,0,1)=='`') $tn=substr($tn,1,strlen($tn)-2);
|
||||
return $tn;
|
||||
}
|
||||
|
||||
// extrahiert auf einfache Art den Tabellennamen aus dem "Insert"-Befehl
|
||||
function get_tablename_aus_insert($t)
|
||||
{
|
||||
$t=substr(strtolower($t),strpos(strtolower($t), 'into ')+5);
|
||||
$w=explode(' ',$t);
|
||||
$tn=$w[0];
|
||||
if(substr($tn,0,1)=='`') $tn=substr($tn,1,strlen($tn)-2);
|
||||
return $tn;
|
||||
}
|
||||
|
||||
function SQL_Is_Complete($s,$expected=0,$debug=0)
|
||||
{
|
||||
global $restore;
|
||||
if ($debug) echo "<br>Zu analysieren:".$s."<br>";
|
||||
$anz=$f_begin=$f_end=$restore["erw_anz"]=0;
|
||||
$Backslash=chr(92);
|
||||
$s=trim(strtoupper(($s)));
|
||||
if(substr($s,-2)==");" || substr($s,-2)=="),") $s=substr($s,0,strlen($s)-2);
|
||||
if(substr($s,-1)==")") $s=substr($s,0,strlen($s)-1);
|
||||
if(strpos($s," VALUES")) {
|
||||
$i=strpos($s," VALUES")+7;
|
||||
$s=substr($s,$i);
|
||||
}
|
||||
$i=strpos($s,"(")+1;
|
||||
$s=substr($s,$i);
|
||||
|
||||
$tb=explode(",",$s);
|
||||
for ($i=0;$i<count($tb);$i++){
|
||||
$first=$B_Esc=$B_Ticks=$B_Dashes=0;
|
||||
$v=trim(rtrim($tb[$i]));
|
||||
|
||||
//erweitert ?
|
||||
if($anz==0 && $restore["erweiterte_inserts"]==1 && substr($v,0,1)=="(") $v=substr($v,1);
|
||||
if($expected>0 && $anz==$expected-1 && substr($v,-1)==")") {
|
||||
$v=substr($v,0,strlen($v)-1); // ) entfernen
|
||||
//if($i+1<count($tb)) $tb[$i+1]=substr(trim(rtrim($tb[$i+1])),1);
|
||||
if($restore["erweiterte_inserts"]==0) {
|
||||
$restore["erweiterte_inserts"]=1;
|
||||
$restore["flag"]=1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Ticks + Dashes zählen
|
||||
for($cpos=2;$cpos<=strlen($v);$cpos++)
|
||||
{if(substr($v,(-1*$cpos),1)=="'") {$B_Ticks++;} else {break;}}
|
||||
for($cpos=2;$cpos<=strlen($v);$cpos++)
|
||||
{if(substr($v,(-1*$cpos),1)=='"') {$B_Dashes++;} else {break;}}
|
||||
|
||||
//Backslashes zählen
|
||||
for($cpos=2+$B_Ticks;$cpos<=strlen($v);$cpos++)
|
||||
{if(substr($v,(-1*$cpos),1)=="\\") {$B_Esc++;} else {break;}}
|
||||
|
||||
|
||||
|
||||
if($v=="NULL" && $f_begin==0){$f_begin=1;$f_end=1;}
|
||||
if($f_begin==0 && is_numeric($v)){$f_begin=1;$f_end=1;}
|
||||
//blob fix von PHPMyAdmin Dump
|
||||
if($f_begin==0 && substr($v,0,2)=="0X" && strpos($v," ")==false){$f_begin=1;$f_end=1;}
|
||||
if($f_begin==0 && is_object($v)){$f_begin=1;$f_end=1;}
|
||||
|
||||
if(substr($v,0,1)=="'" && $f_begin==0) {$f_begin=1;if(strlen($v)==1)$first=1;$DELIMITER="'";}
|
||||
if(substr($v,0,1)=='"' && $f_begin==0) {$f_begin=1;if(strlen($v)==1)$first=1;$DELIMITER='"';}
|
||||
if($f_begin==1 && $f_end!=1 && $first==0){
|
||||
if (substr($v,-1)==$DELIMITER){
|
||||
$B_Delimiter=($DELIMITER=="'") ? $B_Ticks : $B_Dashes;
|
||||
//ist Delimiter maskiert?
|
||||
if (($B_Esc % 2)==1 && ($B_Delimiter % 2)==1 && strlen($v)>2) {
|
||||
|
||||
$f_end=1;
|
||||
} elseif (($B_Delimiter % 2)==1 && strlen($v)>2) {
|
||||
//ist mit `'` maskiert
|
||||
$f_end=0;
|
||||
} elseif(($B_Esc % 2)==1) {
|
||||
//ist mit Backslash maskiert
|
||||
$f_end=0;
|
||||
} else {
|
||||
|
||||
$f_end=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($debug==1) echo "<font color='#0000FF'>$f_begin/$f_end</font> Feld $i: ".htmlspecialchars($tb[$i])."<font color=#008000>- $anz ($B_Ticks / $B_Esc)</font><br>";
|
||||
if($f_begin==1 && $f_end==1) {
|
||||
$anz++;
|
||||
$f_begin=$f_end=0;
|
||||
if($anz==$expected) {
|
||||
$restore["erw_anz"]++;
|
||||
if($debug==1) echo "<h5>".$restore["erw_anz"].".Insert - (".$anz." Felder)</h5>";
|
||||
$anz=0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if($anz==0 && $expected>0 && $restore["erw_anz"]>0) $anz=$expected;
|
||||
|
||||
return $anz;
|
||||
}
|
||||
|
||||
?>
|
||||
1124
mysqldumper/inc/functions_sql.php
Normale Datei
1124
mysqldumper/inc/functions_sql.php
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
11
mysqldumper/inc/header.php
Normale Datei
11
mysqldumper/inc/header.php
Normale Datei
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
include_once('./inc/functions.php');
|
||||
include_once('./inc/mysql.php');
|
||||
|
||||
if(!file_exists($config['files']['parameter'])) TestWorkDir();
|
||||
include('./'.$config['files']['parameter']);
|
||||
include('./language/lang_list.php');
|
||||
SelectDB($databases['db_selected_index']);
|
||||
$config['files']['iconpath']='css/'.$config['theme'].'/icons/';
|
||||
|
||||
?>
|
||||
120
mysqldumper/inc/mysql.php
Normale Datei
120
mysqldumper/inc/mysql.php
Normale Datei
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
//Feldspezifikationen
|
||||
$feldtypen=Array("VARCHAR","TINYINT","TEXT","DATE","SMALLINT","MEDIUMINT","INT","BIGINT","FLOAT","DOUBLE","DECIMAL","DATETIME","TIMESTAMP","TIME","YEAR","CHAR","TINYBLOB","TINYTEXT","BLOB","MEDIUMBLOB","MEDIUMTEXT","LONGBLOB","LONGTEXT","ENUM","SET");
|
||||
$feldattribute=ARRAY("","BINARY","UNSIGNED","UNSIGNED ZEROFILL");
|
||||
$feldnulls=Array("NOT NULL","NULL");
|
||||
$feldextras=Array("","AUTO_INCREMENT");
|
||||
$feldkeys=Array("","PRIMARY KEY","UNIQUE KEY", "FULLTEXT");
|
||||
$feldrowformat=Array("","FIXED","DYNAMIC","COMPRESSED");
|
||||
|
||||
$rechte_daten=Array("SELECT","INSERT","UPDATE","DELETE","FILE");
|
||||
$rechte_struktur=Array("CREATE","ALTER","INDEX","DROP","CREATE TEMPORARY TABLES");
|
||||
$rechte_admin=Array("GRANT","SUPER","PROCESS","RELOAD","SHUTDOWN","SHOW DATABASES","LOCK TABLES","REFERENCES","EXECUTE","REPLICATION CLIENT","REPLICATION SLAVE");
|
||||
$rechte_resourcen=Array("MAX QUERIES PER HOUR","MAX UPDATES PER HOUR","MAX CONNECTIONS PER HOUR");
|
||||
|
||||
$sql_keywords=array( 'ALTER', 'AND', 'ADD', 'AUTO_INCREMENT','BETWEEN', 'BINARY', 'BOTH', 'BY', 'BOOLEAN','CHANGE', 'CHARSET','CHECK','COLLATE', 'COLUMNS', 'COLUMN', 'CROSS','CREATE', 'DATABASES', 'DATABASE', 'DATA', 'DELAYED', 'DESCRIBE', 'DESC', 'DISTINCT', 'DELETE', 'DROP', 'DEFAULT','ENCLOSED', 'ENGINE','ESCAPED', 'EXISTS', 'EXPLAIN','FIELDS', 'FIELD', 'FLUSH', 'FOR', 'FOREIGN', 'FUNCTION', 'FROM','GROUP', 'GRANT','HAVING','IGNORE', 'INDEX', 'INFILE', 'INSERT', 'INNER', 'INTO', 'IDENTIFIED','JOIN','KEYS', 'KILL','KEY','LEADING', 'LIKE', 'LIMIT', 'LINES', 'LOAD', 'LOCAL', 'LOCK', 'LOW_PRIORITY', 'LEFT', 'LANGUAGE', 'MEDIUMINT', 'MODIFY','MyISAM','NATURAL', 'NOT', 'NULL', 'NEXTVAL','OPTIMIZE', 'OPTION', 'OPTIONALLY', 'ORDER', 'OUTFILE', 'OR', 'OUTER', 'ON','PROCEEDURE','PROCEDURAL', 'PRIMARY','READ', 'REFERENCES', 'REGEXP', 'RENAME', 'REPLACE', 'RETURN', 'REVOKE', 'RLIKE', 'RIGHT','SHOW', 'SONAME', 'STATUS', 'STRAIGHT_JOIN', 'SELECT', 'SETVAL', 'TABLES', 'TEMINATED', 'TO', 'TRAILING','TRUNCATE', 'TABLE', 'TEMPORARY', 'TRIGGER', 'TRUSTED','UNIQUE', 'UNLOCK', 'USE', 'USING', 'UPDATE', 'UNSIGNED','VALUES', 'VARIABLES', 'VIEW','WITH', 'WRITE', 'WHERE','ZEROFILL','XOR','ALL', 'ASC', 'AS','SET','IN', 'IS', 'IF');
|
||||
$mysql_doc=Array("Feldtypen" => "http://dev.mysql.com/doc/mysql/de/Column_types.html");
|
||||
|
||||
function MSD_mysql_connect()
|
||||
{
|
||||
global $config,$databases;
|
||||
|
||||
$port=(isset($config['dbport']) && !empty($config['dbport'])) ? ":".$config['dbport'] : "";
|
||||
$socket=(isset($config['dbsocket']) && !empty($config['dbsocket'])) ? ":".$config['dbsocket'] : "";
|
||||
$config['dbconnection'] = @mysql_connect($config['dbhost'].$port.$socket,$config['dbuser'],$config['dbpass']) or die(SQLError("Datenbankverbindung",mysql_error()));
|
||||
if(!defined('MSD_MYSQL_VERSION')) GetMySQLVersion();
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetMySQLVersion()
|
||||
{
|
||||
$res=MSD_query("select version()");
|
||||
$row = mysql_fetch_array($res);
|
||||
$version=$row[0];
|
||||
$new=(substr($version,0,3)>=4.1);
|
||||
if(!defined('MSD_MYSQL_VERSION')) define('MSD_MYSQL_VERSION', $version);
|
||||
if(!defined('MSD_NEW_VERSION')) define('MSD_NEW_VERSION',$new);
|
||||
return $version;
|
||||
}
|
||||
|
||||
function MSD_query($query)
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config['dbconnection'])) MSD_mysql_connect();
|
||||
return @mysql_query($query, $config['dbconnection']);
|
||||
|
||||
}
|
||||
|
||||
function MSD_mysql_error()
|
||||
{
|
||||
global $config,$databases;
|
||||
|
||||
}
|
||||
|
||||
function SQLError($sql,$error)
|
||||
{
|
||||
global $lang,$mysql_errorhelp_ref,$config;
|
||||
echo '<div align="center"><table border="1" bordercolor="#ff0000" cellspacing="0">
|
||||
<tr bgcolor="#ff0000"><td style="color:white;font-size:16px;"><strong>MySQL-ERROR</strong> <a href="'.$mysql_errorhelp_ref.'" target="_blank">
|
||||
<img src="'.$config['files']['iconpath'].'help16.gif" alt="'.$lang['MySQLErrorDoc'].'" title="'.$lang['MySQLErrorDoc'].'" width="16" height="16" border="0"></a></td></tr>
|
||||
<tr><td style="width:80%;overflow: auto;">'.$lang['sql_error1'].'<br><br>'.Highlight_SQL($sql).'</td></tr>
|
||||
<tr><td width="600">'.$lang['sql_error2'].'<br><br><span style="color:red;">'.$error.'</span></td></tr>
|
||||
</table>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
function Highlight_SQL($sql)
|
||||
{
|
||||
global $sql_keywords;
|
||||
|
||||
$end="";
|
||||
$tickstart=false;
|
||||
$a=@token_get_all("<?$sql?>");
|
||||
foreach($a as $token) {
|
||||
if(!is_array($token)) {
|
||||
if($token=="`") $tickstart=!$tickstart;
|
||||
$end.=$token;
|
||||
} else {
|
||||
if($tickstart) $end.=$token[1]; else {
|
||||
switch(token_name($token[0])) {
|
||||
case "T_STRING":
|
||||
case "T_AS":
|
||||
case "T_FOR":
|
||||
|
||||
$end.=(in_array(strtoupper($token[1]),$sql_keywords)) ? "<span style=\"color:#990099;font-weight:bold;\">".$token[1]."</span>": $token[1];
|
||||
break;
|
||||
case "T_IF":
|
||||
case "T_LOGICAL_AND":
|
||||
case "T_LOGICAL_OR":
|
||||
case "T_LOGICAL_XOR":
|
||||
$end.=(in_array(strtoupper($token[1]),$sql_keywords)) ? "<span style=\"color:#0000ff;font-weight:bold;\">".$token[1]."</span>": $token[1];
|
||||
break;
|
||||
case "T_CLOSE_TAG":
|
||||
case "T_OPEN_TAG":
|
||||
break;
|
||||
default:
|
||||
$end.=$token[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$end=preg_replace("/`(.*?)`/si", "<span style=\"color:red;\">`$1`</span>", $end);
|
||||
return $end;
|
||||
}
|
||||
|
||||
function Fieldlist($db,$tbl)
|
||||
{
|
||||
$fl='';
|
||||
$res=MSD_query("SHOW FIELDS FROM `$db`.`$tbl`;");
|
||||
if($res) {
|
||||
$fl='(';
|
||||
for($i=0;$i<mysql_num_rows($res);$i++) {
|
||||
$row=mysql_fetch_row($res);
|
||||
$fl.='`'.$row[0].'`,';
|
||||
}
|
||||
$fl=substr($fl,0,strlen($fl)-1).')';
|
||||
}
|
||||
return $fl;
|
||||
}
|
||||
?>
|
||||
149
mysqldumper/inc/runtime.php
Normale Datei
149
mysqldumper/inc/runtime.php
Normale Datei
|
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
//Konstanten
|
||||
if (!defined('MSD_VERSION')) define('MSD_VERSION', '1.21');
|
||||
if (!defined('MSD_VERSION_ADD')) define('MSD_VERSION_ADD', '');
|
||||
|
||||
if (!defined('MSD_OS')) define('MSD_OS', PHP_OS);
|
||||
if (!defined('MSD_OS_EXT')) define('MSD_OS_EXT',@php_uname());
|
||||
if (!defined('MSD_IS_WINDOWS')) {
|
||||
if (stristr(PHP_OS, 'win')) {
|
||||
define('MSD_IS_WINDOWS', 1);
|
||||
} else {
|
||||
define('MSD_IS_WINDOWS', 0);
|
||||
}
|
||||
}
|
||||
if (!defined('MSD_USER_OS')) {
|
||||
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
|
||||
} else if (!isset($HTTP_USER_AGENT)) {
|
||||
$HTTP_USER_AGENT = '';
|
||||
}
|
||||
|
||||
// 1. Platform
|
||||
if (strstr($HTTP_USER_AGENT, 'Win')) {
|
||||
define('MSD_USER_OS', 'Win');
|
||||
} else if (strstr($HTTP_USER_AGENT, 'Mac')) {
|
||||
define('MSD_USER_OS', 'Mac');
|
||||
} else if (strstr($HTTP_USER_AGENT, 'Linux')) {
|
||||
define('MSD_USER_OS', 'Linux');
|
||||
} else if (strstr($HTTP_USER_AGENT, 'Unix')) {
|
||||
define('MSD_USER_OS', 'Unix');
|
||||
} else if (strstr($HTTP_USER_AGENT, 'OS/2')) {
|
||||
define('MSD_USER_OS', 'OS/2');
|
||||
} else {
|
||||
define('MSD_USER_OS', 'Other');
|
||||
}
|
||||
|
||||
// 2. browser and version
|
||||
// (must check everything else before Mozilla)
|
||||
|
||||
if (preg_match('@Opera(/| )([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
|
||||
define('MSD_BROWSER_VERSION', $log_version[2]);
|
||||
define('MSD_BROWSER_AGENT', 'OPERA');
|
||||
$BrowserIcon='opera.png';
|
||||
} else if (preg_match('@MSIE ([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
|
||||
define('MSD_BROWSER_VERSION', $log_version[1]);
|
||||
define('MSD_BROWSER_AGENT', 'IE');
|
||||
$BrowserIcon='msie.png';
|
||||
} else if (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
|
||||
define('MSD_BROWSER_VERSION', $log_version[1]);
|
||||
define('MSD_BROWSER_AGENT', 'OMNIWEB');
|
||||
$BrowserIcon='omniweb.png';
|
||||
} else if (preg_match('@(Konqueror/)(.*)(;)@', $HTTP_USER_AGENT, $log_version)) {
|
||||
define('MSD_BROWSER_VERSION', $log_version[2]);
|
||||
define('MSD_BROWSER_AGENT', 'KONQUEROR');
|
||||
$BrowserIcon='konqueror.png';
|
||||
} else if (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)
|
||||
&& preg_match('@Safari/([0-9]*)@', $HTTP_USER_AGENT, $log_version2)) {
|
||||
define('MSD_BROWSER_VERSION', $log_version[1] . '.' . $log_version2[1]);
|
||||
define('MSD_BROWSER_AGENT', 'SAFARI');
|
||||
$BrowserIcon='safari.png';
|
||||
} else if (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
|
||||
define('MSD_BROWSER_VERSION', $log_version[1]);
|
||||
define('MSD_BROWSER_AGENT', 'MOZILLA');
|
||||
$BrowserIcon='mozilla.png';
|
||||
} else {
|
||||
define('MSD_BROWSER_VERSION', 0);
|
||||
define('MSD_BROWSER_AGENT', 'OTHER');
|
||||
$BrowserIcon='blank.gif';
|
||||
}
|
||||
}
|
||||
|
||||
//feste Variabeln
|
||||
$config['lock_tables']=0;
|
||||
|
||||
//Pfade und Files
|
||||
$config['paths']['root']=Realpfad('./');
|
||||
$config['paths']['work']='work/';
|
||||
$config['paths']['backup']=$config['paths']['work'].'backup/';
|
||||
$config['paths']['structure']=$config['paths']['work'].'structure/';
|
||||
$config['paths']['log']=$config['paths']['work'].'log/';
|
||||
$config['paths']['config']=$config['paths']['work'].'config/';
|
||||
$config['paths']['perlexec']='msd_cron/';
|
||||
$config['cron_configurationfile']='mysqldumper.conf';
|
||||
$config['files']['log']=$config['paths']['log'].'mysqldump.log';
|
||||
$config['files']['perllog']=$config['paths']['log'].'mysqldump_perl.log';
|
||||
$config['files']['perllogcomplete']=$config['paths']['log'].'mysqldump_perl.complete.log';
|
||||
$config['files']['parameter']=$config['paths']['config'].'parameter.php';
|
||||
|
||||
//Ini-Parameter
|
||||
$config['max_execution_time']=ini_get('max_execution_time');
|
||||
$config['max_execution_time']=($config['max_execution_time']<=0) ? 30:$config['max_execution_time'];
|
||||
if ($config['max_execution_time']>30) $config['max_execution_time']=30;;
|
||||
$config['upload_max_filesize']=ini_get('upload_max_filesize');
|
||||
$config['safe_mode']=ini_get('safe_mode');
|
||||
$config['magic_quotes_gpc']=ini_get('magic_quotes_gpc');
|
||||
$config['disabled']=ini_get('disable_functions');
|
||||
$config['phpextensions']=implode(', ',get_loaded_extensions());
|
||||
$m=str_replace('M','',get_cfg_var('memory_limit'));
|
||||
$config['ram']=(empty($m)) ? 0 : $m;
|
||||
|
||||
//Ist zlib möglich?
|
||||
$p1=explode(', ',$config['phpextensions']);
|
||||
$p2=explode(',',str_replace(' ','',$config['disabled']));
|
||||
//Buggy PHP-Version ?
|
||||
$p3=explode('.',PHP_VERSION);
|
||||
$buggy=($p3[0]==4 && $p3[1]==3 && $p3[2]<3);
|
||||
$config['zlib']=(!$buggy) && (in_array('zlib',$p1) && (!in_array('gzopen',$p2) || !in_array('gzwrite',$p2) || !in_array('gzgets',$p2) || !in_array('gzseek',$p2) || !in_array('gztell',$p2)));
|
||||
|
||||
//Tuning-Ecke
|
||||
$config['tuning_add']=1.1;
|
||||
$config['tuning_sub']=0.9;
|
||||
$config['time_buffer']=0.75; //max_zeit=$config['max_execution_time']*$config['time_buffer']
|
||||
$config['perlspeed']=10000; //Anzahl der Datensätze, die in einem Rutsch gelesen werden
|
||||
|
||||
|
||||
//Bausteine
|
||||
$meta=br().br().'<meta http-equiv="expires" content="3600"> '.br().'<META HTTP-EQUIV="Pragma" CONTENT="no-cache">'.br(2);
|
||||
//$preload_restore='<script language="JavaScript">Preload(2)</script>';
|
||||
//$preload_dump='<script language="JavaScript">Preload(1)</script>';
|
||||
$config['homepage']='http://www.mysqldumper.de/board/';
|
||||
$languagepacks_ref='http://www.mysqldumper.de/board/viewforum.php?f=24';
|
||||
$stylepacks_ref='http://www.mysqldumper.de/board/viewforum.php?f=25';
|
||||
|
||||
$nl="\n";
|
||||
$mysql_commentstring='--';
|
||||
|
||||
//config-Variablen, die nicht gesichert werden sollen
|
||||
$config_dontsave=Array('max_execution_time','safe_mode','magic_quotes_gpc','disabled',
|
||||
'phpextensions','ram','zlib','tuning_add','tuning_sub','time_buffer','perlspeed',
|
||||
'dbconnection','version');
|
||||
|
||||
//Initialisierungen
|
||||
//0 schaltet frameset-restore aus
|
||||
$frameset_restore=0;
|
||||
|
||||
function v($t)
|
||||
{
|
||||
echo '<br>';
|
||||
if (is_array($t))
|
||||
{
|
||||
echo '<pre>';
|
||||
print_r($t);
|
||||
echo '</pre>';
|
||||
}
|
||||
else echo $t;
|
||||
}
|
||||
?>
|
||||
55
mysqldumper/inc/sqllib.php
Normale Datei
55
mysqldumper/inc/sqllib.php
Normale Datei
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
//SQL-Library
|
||||
include_once('./language/'.$config['language'].'/lang_sql.php');
|
||||
|
||||
/*
|
||||
Template
|
||||
if $sqllib[$i]['sql']=trenn, Then it is a Heading
|
||||
$sqllib[$i]['name']="";
|
||||
$sqllib[$i]['sql']="";
|
||||
$i++;
|
||||
*/
|
||||
$i=0;
|
||||
$sqllib=ARRAY();
|
||||
|
||||
$sqllib[$i]['name']=$lang['sqllib_generalfunctions'];
|
||||
$sqllib[$i]['sql']="trenn";
|
||||
$i++;
|
||||
|
||||
|
||||
$sqllib[$i]['name']=$lang['sqllib_resetauto'];
|
||||
$sqllib[$i]['sql']="ALTER TABLE `table` AUTO_INCREMENT=1;";
|
||||
$i++;
|
||||
|
||||
/********* phpBB-Boards *********************************/
|
||||
$sqllib[$i]['name']="phpBB-".$lang['sqllib_boards'];
|
||||
$sqllib[$i]['sql']="trenn";
|
||||
$i++;
|
||||
|
||||
// Bord de-/aktivieren
|
||||
$sqllib[$i]['name']=$lang['sqllib_deactivateboard'].' [phpBB]';
|
||||
$sqllib[$i]['sql']="UPDATE `phpbb_config` set config_value=1 where config_name='board_disable'";
|
||||
$i++;
|
||||
|
||||
$sqllib[$i]['name']=$lang['sqllib_activateboard'].' [phpBB]';
|
||||
$sqllib[$i]['sql']="UPDATE `phpbb_config` set config_value=0 where config_name='board_disable'";
|
||||
$i++;
|
||||
|
||||
// Bord de-/aktivieren
|
||||
|
||||
$sqllib[$i]['name']="vBulletin-".$lang['sqllib_boards'];
|
||||
$sqllib[$i]['sql']="trenn";
|
||||
$i++;
|
||||
|
||||
// Bord de-/aktivieren
|
||||
$sqllib[$i]['name']=$lang['sqllib_deactivateboard'].' [vBulletin]';
|
||||
$sqllib[$i]['sql']="UPDATE forum SET options = options - 1 WHERE options & 1";
|
||||
$i++;
|
||||
|
||||
$sqllib[$i]['name']=$lang['sqllib_activateboard'].' [vBulletin]';
|
||||
$sqllib[$i]['sql']="UPDATE forum SET options = options + 1 WHERE NOT (options & 1)";
|
||||
$i++;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
86
mysqldumper/inc/tabellenabfrage.php
Normale Datei
86
mysqldumper/inc/tabellenabfrage.php
Normale Datei
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
include_once('./language/'.$config['language'].'/lang.php');
|
||||
include_once('./language/'.$config['language'].'/lang_dump.php');
|
||||
|
||||
$tblr=($tblfrage_refer=='dump') ? 'Backup' : $tblr='Restore';
|
||||
$filename=(isset($_GET['filename'])) ? $_GET['filename'] : '';
|
||||
|
||||
//Informationen zusammenstellen
|
||||
if($tblr=='Backup')
|
||||
{
|
||||
//Info aus der Datenbank lesen
|
||||
MSD_mysql_connect();
|
||||
$res=mysql_query('SHOW TABLE STATUS FROM `'.$databases['db_actual'].'`');
|
||||
$numrows=mysql_num_rows($res);
|
||||
$button_name='dump_tbl';
|
||||
$button_caption=$lang['startdump'];
|
||||
$tbl_zeile='';
|
||||
for($i=0;$i<$numrows;$i++) {
|
||||
$row=mysql_fetch_array($res);
|
||||
$klasse=($i % 2) ? 1:'';
|
||||
$tbl_zeile.='<tr class="dbrow'.$klasse.'"><td class="sm" align="left"><input type="checkbox" class="checkbox" name="chk_tbl" value="'.$row['Name'].'">'.$row['Name'].'</td>';
|
||||
$tbl_zeile.='<td class="sm" align="left"><strong>'.$row['Rows'].'</strong> '.$lang['datawith'].' <strong>'.byte_output($row['Data_length']+$row['Index_length']).'</strong>, '.$lang['lastbufrom'].' '.$row['Update_time'].'</td></tr>';
|
||||
}
|
||||
} else {
|
||||
//Restore - Header aus Backupfile lesen
|
||||
$button_name='restore_tbl';
|
||||
$button_caption="";
|
||||
$gz = (substr($filename,-3))=='.gz' ? 1 : 0;
|
||||
if ($gz)
|
||||
{
|
||||
$fp = gzopen ($fpath.$filename, "r");
|
||||
$statusline=gzgets($fp,40960);
|
||||
$offset= gztell($fp);
|
||||
} else {
|
||||
$fp = fopen ($fpath.$filename, "r");
|
||||
$statusline=fgets($fp,5000);
|
||||
$offset= ftell($fp);
|
||||
}
|
||||
//Header auslesen
|
||||
$sline=ReadStatusline($statusline);
|
||||
$anzahl_tabellen=$sline[0];
|
||||
$anzahl_eintraege=$sline[1];
|
||||
$part=($sline[2]=="") ? 0 : substr($sline[2],3);
|
||||
$EXTINFO= $sline[6];
|
||||
if($EXTINFO=="") {
|
||||
$tbl_zeile.='<tr calss="dbrow"><td class="sm" colspan="2">'.$lang['not_supported'].'</td>';
|
||||
} else {
|
||||
for($i=0;$i<$anzahl_tabellen;$i++) {
|
||||
if ($gz)
|
||||
{
|
||||
gzseek($fp,$offset);
|
||||
$statusline=gzgets($fp,40960);
|
||||
$offset= gztell($fp);
|
||||
} else {
|
||||
fseek($fp,$offset);
|
||||
$statusline=fgets($fp,5000);
|
||||
$offset= ftell($fp);
|
||||
}
|
||||
$s=explode("|",$statusline);
|
||||
$tbl_zeile.='<tr class="dbrow"><td align="left"><input type="checkbox" class="checkbox" name="chk_tbl" value="'.$s[1].'">'.$s[1].'</td>';
|
||||
$tbl_zeile.='<td align="left"><strong>'.$s[2].'</strong> '.$lang['datawith'].' <strong>'.byte_output($s[3]).'</strong>, '.$lang['lastbufrom'].' '.$s[4].'</td></tr>';
|
||||
}
|
||||
if($gz) gzclose ($fp); else fclose ($fp);
|
||||
}
|
||||
}
|
||||
|
||||
$buttons='<tr><td colspan="2"><table width="100%" border="0"><tr>'
|
||||
.'<td><input type="button" class="Formbutton" onclick="Sel(true);" value="'.$lang['deselectall'].'"></td>'
|
||||
.'<td><input type="button" onclick="Sel(false);" value="'.$lang['selectall'].'" class="Formbutton"></td>'
|
||||
.'<td><input type="submit" class="Formbutton" style="width:180px;" name="'.$button_name.'" value="'.$button_caption.'"></td>'
|
||||
.'</tr></table></td></tr>';
|
||||
|
||||
echo '<div id="pagetitle">'.$tblr.' - '.$lang['tableselection'].'</div><h6>'.$lang['db'].': '.$databases['db_actual'].'</h6>';
|
||||
echo '<div id="content">';
|
||||
echo '<form name="frm_tbl" action="filemanagement.php" method="post" onSubmit="return chkFormular()">';
|
||||
echo '<table class="bordersmall">';
|
||||
|
||||
echo $buttons;
|
||||
echo $tbl_zeile;
|
||||
echo $buttons;
|
||||
|
||||
echo '</table><input type="hidden" name="dumpKommentar" value="'.$dk.'"><input type="hidden" name="tbl_array" value=""><input type="hidden" name="filename" value="'.$filename.'"></form>';
|
||||
//echo '</div><br><br><br><br>';
|
||||
echo '</div><br><br><br>';
|
||||
|
||||
?>
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren