Dieser Commit ist enthalten in:
Commit
ab3487195f
65 geänderte Dateien mit 10725 neuen und 0 gelöschten Zeilen
14
inc/footer.php
Normale Datei
14
inc/footer.php
Normale Datei
|
|
@ -0,0 +1,14 @@
|
|||
<p align="center" class="small">
|
||||
Autoren:
|
||||
<a class="small" href="http://www.daniel-schlichtholz.de" target="_new">
|
||||
Daniel Schlichtholz & Steffen Kamper</a> - Infoboard:
|
||||
<a class="small" href="<?php echo $config["homepage"]; ?>" target="_new">
|
||||
<?php echo $config["homepage"].'</a></p>';
|
||||
$svice=(isset($_GET["svice"])) ? $_GET["svice"] : 0;
|
||||
$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>" : "";
|
||||
if($svice==1) echo '<table width="100%"><tr bgcolor="#808080"><td>'.$config_array.'</td></tr><tr bgcolor="#808080"><td>'.$database_array.'</td></tr><tr bgcolor="#808080"><td>'.$dump_array.'</td></tr><tr bgcolor="#808080"><td>'.$restore_array.'</td></tr></table>';
|
||||
echo '</BODY></HTML>';
|
||||
?>
|
||||
323
inc/functions.php
Normale Datei
323
inc/functions.php
Normale Datei
|
|
@ -0,0 +1,323 @@
|
|||
<?php
|
||||
|
||||
include_once("inc/functions_global.php");
|
||||
include_once("inc/mysql.php");
|
||||
|
||||
function Help($ToolTip,$Anker,$imgsize=16)
|
||||
{
|
||||
global $config;
|
||||
if($Anker!=""){
|
||||
return '<a href="language/help_'.$config["language"].'.php#'.$Anker.'" titel="'.$ToolTip.'"><img src="images/help16.gif" width="'.$imgsize.'" height="'.$imgsize.'" hspace="'.($imgsize/4).'" vspace="0"></a>';
|
||||
} else {
|
||||
return '<img src="images/help16.gif" width="'.$imgsize.'" height="'.$imgsize.'" alt="'.$ToolTip.'" 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"];
|
||||
@unlink($config["files"]["parameter"]);
|
||||
if($load_default==false){
|
||||
include("./config.php");
|
||||
$config["language"]=$old_lang;
|
||||
}
|
||||
|
||||
//DB-Liste holen
|
||||
MSD_mysql_connect();
|
||||
$databases["db_selected_index"]=-1;
|
||||
if($config["dbonly"]!="") {
|
||||
$databases["db_actual"]=$config["dbonly"];
|
||||
$databases["Name"][0]=$config["dbonly"];
|
||||
$databases["db_selected_index"]=0;
|
||||
$databases["praefix"][0]="";
|
||||
$databases["command_before_dump"][0] = "";
|
||||
$databases["command_after_dump"][0] = "";
|
||||
} else {
|
||||
|
||||
$res = mysql_query("SHOW DATABASES ;",$config["dbconnection"]);
|
||||
$numrows=mysql_numrows($res);
|
||||
for($i=0;$i<$numrows;$i++) {
|
||||
$row = mysql_fetch_row($res);
|
||||
$found_db=$row[0];
|
||||
//echo "found `$found_db`<br>";
|
||||
if($found_db==$old_db) $databases["db_selected_index"]=$i;
|
||||
$databases["Name"][$i]=$found_db;
|
||||
$databases["praefix"][$i]="";
|
||||
$databases["command_before_dump"][$i] = "";
|
||||
$databases["command_after_dump"][$i] = "";
|
||||
|
||||
$out.=$lang["saving_db_form"]." ".$found_db." ".$lang["added"]."$nl";
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
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)
|
||||
{
|
||||
$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($var != "dbconnection" && $var != "version") $pars_all.='$config["'."$var\"] = \"".addslashes($val)."\";$nl";
|
||||
} else {
|
||||
if($var != "dbconnection" && $var != "version") $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;
|
||||
|
||||
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;
|
||||
|
||||
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($cron_save_all_dbs>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"]);
|
||||
$p1=$r.$config["paths"]["backup"];
|
||||
$p2=$r.$config["files"]["perllog"];
|
||||
$p3=$r.$config["files"]["perllogcomplete"];
|
||||
$pcp=str_replace("\\\\","/",$config["cron_perlpath"]);
|
||||
|
||||
|
||||
|
||||
$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=qw('.$p1.');'.$nl;
|
||||
$cronscript.='$logdatei=qw('.$p2.');'.$nl;
|
||||
$cronscript.='$completelogdatei=qw('.$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=qw('.$config["email_recipient"].');'.$nl;
|
||||
$cronscript.='$cronmailfrom=qw('.$config["email_sender"].');'.$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="'.$config["ftp_pass"][$config["ftp_connectionindex"]].'";'.$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.='1;';
|
||||
|
||||
//Datei öffnen und schreiben
|
||||
$ret=true;
|
||||
|
||||
|
||||
|
||||
$ext=($config["cron_extender"]==0) ? "pl" : "cgi";
|
||||
|
||||
$sfile=$config["paths"]["config"].$config["cron_configurationfile"];
|
||||
if ($fp=fopen($sfile, "wb"))
|
||||
{
|
||||
if (!fwrite($fp,$cronscript)) $ret=false;
|
||||
if (!fclose($fp)) $ret=false;
|
||||
//chmod("$sfile",0755);
|
||||
}
|
||||
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 DeleteLog()
|
||||
{
|
||||
global $config;
|
||||
//Datei öffnen und schreiben
|
||||
$log=date("d.m.Y h:i:s").": Log created.\n";
|
||||
$fp = @fopen($config["files"]["log"], "wb");
|
||||
@fwrite ($fp,$log);
|
||||
@fclose ($fp);
|
||||
@chmod($config["files"]["log"],0755);
|
||||
}
|
||||
|
||||
function SYS_editor($dir=0,$fname="")
|
||||
{
|
||||
global $dirs;
|
||||
$f=$text="";$i=0;
|
||||
$ref='filemanagement.php?action=files&svice=1&sysfedit=1';
|
||||
|
||||
if($dir>0 && $fname=="") {
|
||||
$dirname=$dirs[$dir];
|
||||
$dh = opendir($dirname);
|
||||
while (false !== ($filename = readdir($dh)))
|
||||
{
|
||||
if ($filename != "." && $filename != ".." && !is_dir($dirname.$filename))
|
||||
$f.='<a '.((is_writable($filename)) ? '' : 'class="swarnung"').' href="'.$ref.'&dir='.$dir.'&filename='.$filename.'">'.$filename.'</a> ';
|
||||
$i++;if(($i % 4)==1) $f.='<br>';
|
||||
}
|
||||
} elseif($dir>0 && $fname!="") {
|
||||
$dirname=$dirs[$dir];
|
||||
$text=implode("",file($dirname.$fname));
|
||||
}
|
||||
|
||||
|
||||
$r='<form action="'.$ref.'" method="post"><table border="1" rules="rows"><tr><td class="hd" colspan="2">Files in ';
|
||||
$r.='<a href="'.$ref.'&dir=1">./</a> ';
|
||||
$r.='<a href="'.$ref.'&dir=2">inc</a> ';
|
||||
$r.='<a href="'.$ref.'&dir=3">msd_cron</a> ';
|
||||
$r.='<a href="'.$ref.'&dir=4">language</a> ';
|
||||
$r.='<a href="'.$ref.'&dir=5">config</a> ';
|
||||
$r.='</td></tr>'.((!empty($f)) ? '<tr><td colspan="2">'.$f.'</td></tr>' : '');
|
||||
if($fname!="") $r.='<tr><td colspan="2" class="hd" align="center"><strong>File `'.$fname.'`</strong></td></tr>';
|
||||
$r.='<tr><td><input type="reset" name="rest" value=" reset "></td><td><input type="submit" name="fedit_save" value=" save "></tr>';
|
||||
$r.='<tr><td colspan="2" align="center"><input type="hidden" name="edit_filename" value="'.$fname.'"><input type="hidden" name="dir" value="'.$dir.'">';
|
||||
|
||||
$r.='<textarea name="editor" style="width:740px;height:500px;overflow:auto;">'.$text.'</textarea></td></tr></table></form>';
|
||||
|
||||
return $r;
|
||||
}
|
||||
?>
|
||||
442
inc/functions_dump.php
Normale Datei
442
inc/functions_dump.php
Normale Datei
|
|
@ -0,0 +1,442 @@
|
|||
<?php
|
||||
include_once("inc/functions_global.php");
|
||||
|
||||
function new_file($last_groesse=0)
|
||||
{
|
||||
global $dump,$databases,$config,$out,$lang,$nl;
|
||||
|
||||
|
||||
// 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."# Dump by MySQLDump ".$config["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.'# Dump created on '.$cur_time.$nl.$nl;
|
||||
$dump["structure"]="# Status:0:0::".$databases["Name"][$dump["dbindex"]];
|
||||
$dump["structure"].=":php:".$config["version"].$nl;
|
||||
$dump["structure"].="# Dump by MySQLDump ".$config["version"]." (".$config["homepage"].")".$nl;
|
||||
$dump["structure"].='# Dump created on '.$cur_time.$nl."# This file is only the structure of the database without data \r\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.'# This is part '.($dump["part"]-$dump["part_offset"]).' of the backup.'.$nl.$nl.$dump["data"];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
WriteToDumpFile();
|
||||
$dump["part"]++;
|
||||
}
|
||||
|
||||
function GetStatusLine($kind="php")
|
||||
{
|
||||
global $databases,$config, $dump;
|
||||
|
||||
$t_array=explode("|",$databases["db_actual_tableselected"]);
|
||||
$t=0;
|
||||
$r=0;
|
||||
$mp="";$t_zeile="";
|
||||
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)))) {
|
||||
$t++;$r+=$erg["Rows"];
|
||||
$t_zeile.="# TABLE|".$erg["Name"]."|".$erg["Rows"]."|".($erg["Data_length"]+$erg["Index_length"])."|".$erg["Update_time"]."\n";
|
||||
}
|
||||
}
|
||||
if($config["multi_part"]==1) $mp="MP_".($dump["part"]-$dump["part_offset"]);
|
||||
return "# Status:$t:$r:$mp:".$databases["Name"][$dump["dbindex"]].":$kind:".$config["version"].":".$dump["kommentar"].":EXTINFO\n".$t_zeile;
|
||||
}
|
||||
|
||||
// Liest die Eigenschaften der Tabelle aus der DB und baut die CREATE-Anweisung zusammen
|
||||
function get_def($db, $table)
|
||||
{
|
||||
global $config,$nl;
|
||||
|
||||
$def = "DROP TABLE IF EXISTS `$table`;".$nl;
|
||||
mysql_select_db($db);
|
||||
$result = mysql_query("SHOW CREATE TABLE `$table`",$config["dbconnection"]);
|
||||
$row=mysql_fetch_row($result);
|
||||
$def .=$row[1].";".$nl;
|
||||
return $def;
|
||||
}
|
||||
|
||||
|
||||
// Liest die Daten aus der DB aus und baut die INSERT-Anweisung zusammen
|
||||
function get_content($db, $table)
|
||||
{
|
||||
global $config,$nl,$dump;
|
||||
|
||||
$content="";
|
||||
|
||||
$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);
|
||||
//$dump["countdata"]+=$ergebnisse;
|
||||
if ($ergebnisse>$dump["restzeilen"])
|
||||
{
|
||||
$dump["zeilen_offset"]+=$dump["restzeilen"];
|
||||
$ergebnisse--;
|
||||
//$dump["countdata"]--;
|
||||
$dump["restzeilen"]=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dump["table_offset"]++;
|
||||
$dump["zeilen_offset"]=0;
|
||||
$dump["restzeilen"]=$dump["restzeilen"]-$ergebnisse;
|
||||
}
|
||||
for ($x=0;$x<$ergebnisse;$x++)
|
||||
{
|
||||
$row=mysql_fetch_row($result);
|
||||
{
|
||||
|
||||
$insert = "INSERT INTO `$table` VALUES (";
|
||||
$num_felder=mysql_num_fields($result);
|
||||
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);
|
||||
$insert .= ");";
|
||||
$dump["data"] .= $insert.$nl;
|
||||
$dump["countdata"]++;
|
||||
if(strlen($content)>$config["memory_limit"] || ($config["multi_part"]==1 && strlen($content)>$config["multipart_groesse"]) ) {
|
||||
WriteToDumpFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql_free_result($result);
|
||||
}
|
||||
|
||||
function WriteToDumpFile()
|
||||
{
|
||||
global $config,$dump;
|
||||
|
||||
$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"]++;
|
||||
|
||||
$dump["filesize"]=filesize($df);
|
||||
if ($config["multi_part"]==1 && $dump["filesize"]>$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=smallwarnung>ERROR executing Query '.$cap.'</span><br>';
|
||||
} else {
|
||||
WriteLog("executing Query $cap ($cd) was successful");
|
||||
$out.=$lf.'<span class=smallblue>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=smallwarnung>ERROR executing System Command '.$cap.'</span><br>';
|
||||
} else {
|
||||
WriteLog("executing System Command $cap was successful. [$returnval]");
|
||||
$out.=$lf.'<span class=smallblue>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 .= "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 = $lang["emailbody_tb1"].byte_output($config["email_maxsize"]). $lang["emailbody_tb2"];
|
||||
} else {
|
||||
$msg_body = $lang["emailbody_na"];
|
||||
}
|
||||
$msg_body.="`".$databases["Name"][$dump["dbindex"]]."` ".$lang["emailbody_tb3"];
|
||||
$msg_body.="$file (".byte_output(filesize($config["paths"]["backup"].$file)).")<br>";
|
||||
$msg_body=str_replace("\\n\\r","<br>",$msg_body);
|
||||
$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 = $lang["emailbody_n1"].'`'.$databases["Name"][$dump["dbindex"]].'` ('.byte_output(filesize($config["paths"]["backup"].$file)).') '.$lang["emailbody_n2"];
|
||||
$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/plain; charset=US-ASCII\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());
|
||||
$msg_body = (($config["send_mail_dump"]==1) ? $lang["emailbody_mp1an"] : $lang["emailbody_mp1"]).$databases["Name"][$dump["dbindex"]].$lang['emailbody_mp1a'];
|
||||
$subject = $mp_sub;
|
||||
$header.= "FROM:".$config["email_sender"]."\n";
|
||||
$header .= "X-Mailer: PHP/" . phpversion(). "\n";
|
||||
$header .= "X-Sender-IP: $REMOTE_ADDR\n";
|
||||
$header .= "Content-Type: text/html";
|
||||
$body_top = "";
|
||||
$msg_body = $body_top . $msg_body;
|
||||
//$msg_body.=$lang["emailbody2"];
|
||||
$dateistamm=substr($dump["backupdatei"],0,strrpos($dump["backupdatei"],"part_"))."part_";
|
||||
$dateiendung=($config["compression"]==1)?".sql.gz":".sql";
|
||||
$mpdatei=Array();
|
||||
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]));
|
||||
$msg_body.=$mpdatei[$i-1]." (".$sz.")<br>";
|
||||
}
|
||||
$msg_body .=$lang["emailbody_mp2"];
|
||||
$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="smallbrown">'.$email_out.'</span>';
|
||||
WriteLog("$email_log");
|
||||
} else {
|
||||
$out.='<span class="smallwarnung">'.$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.$lang['only_attachment'].$lang['emailbody_mp2'];
|
||||
$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="smallbrown">'.$email_out.'</span>';
|
||||
WriteLog("$email_log");
|
||||
} else {
|
||||
$out.='<span class="smallwarnung">'.$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="smallgreen">'."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="smallgreen" style="padding-left:20px;">'.$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="smallwarnung" style="padding-left:20px;">'.$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="smallgreen" style="padding-left:20px;">'.$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="smallwarnung">'.$lang['ftpconnerror3']."<br>($source -> $dest)</span><br>";
|
||||
} else {
|
||||
$out.= '<span class="smallgreen" style="padding-left:20px;">'.$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);
|
||||
}
|
||||
?>
|
||||
684
inc/functions_global.php
Normale Datei
684
inc/functions_global.php
Normale Datei
|
|
@ -0,0 +1,684 @@
|
|||
<?php
|
||||
include_once("inc/runtime.php");
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
return str_repeat("0",$count-strlen($s)).$s;
|
||||
}
|
||||
function getmicrotime()
|
||||
{
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
function MD_FreeDiskSpace()
|
||||
{
|
||||
global $lang;
|
||||
$dfs=@diskfreespace("../");
|
||||
return ($dfs) ? byte_output($dfs) : $lang['notavail'];
|
||||
}
|
||||
|
||||
function WriteDynamicText($txt,$object)
|
||||
{
|
||||
return '<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;
|
||||
//Zeile zusammensetzen
|
||||
$log=date("d.m.Y h:i:s").': '.$aktion."\n";
|
||||
//Datei öffnen und schreiben
|
||||
$fp = @fopen($config["files"]["log"], "a+");
|
||||
|
||||
if($fp) {
|
||||
@fwrite ($fp,($log));
|
||||
@fclose ($fp);
|
||||
} else echo '<p class="warnung">Log-File kann nicht geschrieben werden!</p>';
|
||||
}
|
||||
function WriteTempOut($aktion)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$fp = @fopen($config["paths"]["log"]."out.tmp", "w");
|
||||
|
||||
if($fp) {
|
||||
@fwrite ($fp,$aktion);
|
||||
@fclose ($fp);
|
||||
}
|
||||
}
|
||||
function WritePageParams($aktion)
|
||||
{
|
||||
global $config,$restore,$dump,$nl;
|
||||
|
||||
$pars="<?$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)
|
||||
{
|
||||
global $config;
|
||||
//Error-Zeile generieren
|
||||
$errormsg=date("d.m.Y h:i:s").': ';
|
||||
$errormsg.=($dest=="RESTORE") ? " Restore of db `$db`\n" : " Dump of db `$db`\n";
|
||||
$errormsg.="Error-Message: $error\n";
|
||||
$errormsg.="SQL : ".$sql."\n\n";
|
||||
//Datei öffnen und schreiben
|
||||
$fp = @fopen($config["paths"]["log"]."error.log", "a+");
|
||||
|
||||
if($fp) {
|
||||
@fwrite ($fp,($errormsg));
|
||||
@fclose ($fp);
|
||||
}
|
||||
}
|
||||
function DirectoryWarnings($path="")
|
||||
{
|
||||
global $config;
|
||||
$warn="";
|
||||
if($path=="" || $path=="config") if(!is_writable($config["paths"]["config"])) $warn.='Configpath is not writable! <a href="main.php?help=1&thema=path&dir=config"><img src="images/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="images/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="images/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="images/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();
|
||||
if(!file_exists($config["files"]["log"])) DeleteLog();
|
||||
}
|
||||
|
||||
|
||||
function SetFileRechte($file,$perm="0777")
|
||||
{
|
||||
global $lang;
|
||||
if(substr($file,-1)!="/") $file.="/";
|
||||
if(strlen($perm)!=4 || intval($perm)==0 || intval($perm)>777) $perm="0777";
|
||||
if( (ini_get('safe_mode')==1) && (!(is_dir($file))) )
|
||||
{
|
||||
echo $lang['critical_safemode'];
|
||||
return 0;
|
||||
} else {
|
||||
clearstatcache();
|
||||
if (!@is_dir($file)) @mkdir($file, $perm);
|
||||
clearstatcache();
|
||||
$a=@substr(decoct(fileperms($file)),-4);
|
||||
$ret=1;
|
||||
if($a!=$perm && (ini_get('safe_mode')!=1)) {
|
||||
$ret=@chmod($file,$perm);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function SelectDB($index)
|
||||
{
|
||||
global $databases;
|
||||
$databases["db_actual"] = $databases["Name"][$index];
|
||||
$databases["praefix"][$databases["db_selected_index"]] = $databases["praefix"][$index];
|
||||
$databases["db_selected_index"]=$index;
|
||||
}
|
||||
|
||||
function EmptyDB($dbn)
|
||||
{
|
||||
$res=mysql_query("DROP DATABASE `$dbn`") or die(mysql_error()."");
|
||||
$res=mysql_query("CREATE DATABASE `$dbn`") or die(mysql_error()."");
|
||||
|
||||
}
|
||||
|
||||
function AutoDelete()
|
||||
{
|
||||
global $del_files, $config, $lang,$out;
|
||||
|
||||
//Files einlesen
|
||||
$dh = opendir($config["paths"]["backup"]);
|
||||
$dbbackups=Array();
|
||||
while (false !== ($filename = readdir($dh)))
|
||||
{
|
||||
|
||||
|
||||
if ($filename != "." && $filename != ".." && !is_dir($config["paths"]["backup"].$filename)) {
|
||||
//statuszeile auslesen
|
||||
if(substr($filename,-2)=="gz"){
|
||||
$fp = gzopen ($config["paths"]["backup"].$filename, "r");
|
||||
$statusline=gzgets($fp,40960);
|
||||
gzclose ($fp);
|
||||
}else{
|
||||
$fp = fopen ($config["paths"]["backup"].$filename, "r");
|
||||
$statusline=fgets($fp,500);
|
||||
fclose ($fp);
|
||||
}
|
||||
$sline=ReadStatusline($statusline);
|
||||
if($sline[0]=="9999") {
|
||||
$tabellenanzahl="";
|
||||
$eintraege="";
|
||||
} else {
|
||||
$tabellenanzahl=$sline[0];
|
||||
$eintraege=$sline[1];
|
||||
}
|
||||
$part=($sline[2]=="") ? 0 : substr($sline[2],3);
|
||||
$databases["db_actual"]=$sline[3];
|
||||
$datum=substr($filename,strlen($databases["db_actual"])+1);
|
||||
$datum=substr($datum,0,16);
|
||||
if(isset($dbbackups[$databases["db_actual"]])) $dbbackups[$databases["db_actual"]]++; else $dbbackups[$databases["db_actual"]]=1;
|
||||
$files[] = "$datum|".$databases["db_actual"]."|$part|$filename";
|
||||
}
|
||||
}
|
||||
|
||||
@rsort($files);
|
||||
// Mehr Dateien vorhanden, als es laut config.php sein dürften? Dann weg damit :-)
|
||||
|
||||
if($config["del_files_after_days"]>0) {
|
||||
$nowtime=strtotime("-".($config["del_files_after_days"]+1)." day");
|
||||
for($i=0; $i<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="<font color=\"red\">".$ll."<br>";
|
||||
$r.= $delfile[3]."<br>";
|
||||
WriteLog("autodeleted ($function) '$delfile[3]'.");
|
||||
unlink($config["paths"]["backup"].$delfile[3]);
|
||||
$r.= "</font>";
|
||||
return $r;
|
||||
}
|
||||
|
||||
function ReadStatusline($line)
|
||||
{
|
||||
//Format # Status:Tabellen:Datensätze:Multipart:DBname
|
||||
if(substr($line,0,8)!="# Status") {
|
||||
$s=Array("-1","-1","","","","","","");
|
||||
} else {
|
||||
$s=explode(":",$line);
|
||||
array_shift($s);
|
||||
if(count($s)<7) {
|
||||
for($i=count($s);$i<8;$i++) {$s[]="";}
|
||||
}
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
function NextPart($s,$first=0) {
|
||||
|
||||
$nf=explode("_",$s);
|
||||
$i=array_search("part",$nf)+1;
|
||||
$p=substr($nf[$i],0,strpos($nf[$i],"."));
|
||||
$ext=substr($nf[$i],strlen($p));
|
||||
if($first==1) {
|
||||
$nf[$i]="1".$ext;
|
||||
} else {
|
||||
$nf[$i]=++$p.$ext;
|
||||
}
|
||||
return implode("_",$nf);
|
||||
}
|
||||
|
||||
function zeit_format($t)
|
||||
{
|
||||
$tt_m=floor($t/60);
|
||||
$tt_s=$t-($tt_m*60);
|
||||
return $tt_m.' min. '.floor($tt_s).' sec';
|
||||
}
|
||||
|
||||
function ErrorReport()
|
||||
{
|
||||
global $config,$PHP_SELF,$PATH,$PATH_TRANSLATED,$SCRIPT_FILENAME,$SCRIPT_NAME,$email,$_SERVER;
|
||||
|
||||
$error_kind=$error_aus="";
|
||||
if(isset($_POST["p"]) && $_POST["p"]==1) {
|
||||
//von Programmfehler geposted
|
||||
$error_kind=$_POST["error_kind"];
|
||||
$error_aus=$_POST["error_aus"];
|
||||
}
|
||||
if(isset($_POST["create_sql"])) {
|
||||
//vom Parser
|
||||
$error_kind="Parser-Fehler";
|
||||
$error_aus=stripslashes(trim($_POST["create_sql"]))."\n\n\n".stripslashes(trim($_POST["insert_sql"]));
|
||||
}
|
||||
$subject = "Fehlerbericht vom ".date("d.m.Y H:s");
|
||||
|
||||
|
||||
$r= '<form action="main.php?action=senderror" method="post">';
|
||||
$r.='<div class="small"><table><tr><td align="center" colspan="2"><h4>'.$subject.'</h4></td></tr>';
|
||||
$r.='<tr><td>Absender</td><td><input type="text" name="error_absender" size="40" value="'.$config["email_recipient"].'"></td></tr>';
|
||||
$r.='<tr><td>Name</td><td><input type="text" name="error_name" size="40"></td></tr>';
|
||||
$r.='<tr><td>Art des Fehlers</td><td><input type="text" name="error_kind" value="'.$error_kind.'" size="40"></td></tr>';
|
||||
$r.='<tr><td valign="top">Anzeige des Fehlers</td><td><textarea name="error_aus" cols="30" rows="6">'.$error_aus.'</textarea></td></tr>';
|
||||
$r.='<tr><td valign="top">zusätzliche Bemerkungen</td><td><textarea name="error_zusatz" cols="30" rows="6"></textarea></td></tr>';
|
||||
|
||||
$vi= '<tr><td>MySQLDump-Version</td><td><b>'.$config["version"].'</b></td></tr>';
|
||||
$vi.= '<tr><td>MySQL-Version</td><td><b>'.MSD_MYSQL_VERSION.'</b></td></tr>';
|
||||
$vi.= '<tr><td>PHP-Version</td><td><b>'.phpversion().'</b></td></tr>';
|
||||
//$vi.= '<tr><td>PHP-Extensions</td><td width="600"><b>'.implode(" ",get_loaded_extensions()).'</b></td></tr>';
|
||||
$vi.= '<tr><td>safe_mode</td><td width="600"><b>'.(($config["safe_mode"]==1) ? "on" : "off").'</b></td></tr>';
|
||||
$vi.= '<tr><td>magic_quotes</td><td width="600"><b>'.(($config["magic_quotes_gpc"]==1) ? "on" : "off").'</b></td></tr>';
|
||||
$vi.= '<tr><td>Variable rootdir</td><td width="600"><b>'.addslashes($config["paths"]["root"]).'</b></td></tr>';
|
||||
$vi.= '<tr><td>Server PHP_SELF</td><td width="600"><b>'.$_SERVER["PHP_SELF"].'</b></td></tr>';
|
||||
$vi.= '<tr><td>Server Path</td><td width="600"><b>'. addslashes($_SERVER["PATH"]).'</b></td></tr>';
|
||||
$vi.= '<tr><td>Server Script-Filename</td><td width="600"><b>'.$_SERVER["SCRIPT_FILENAME"].'</b></td></tr>';
|
||||
$vi.= '<tr><td>Server Script-Name</td><td width="600"><b>'.$_SERVER["SCRIPT_NAME"].'</b></td></tr>';
|
||||
$vi.= '<tr><td>Global PHP_SELF</td><td width="600"><b>'.$PHP_SELF.'</b></td></tr>';
|
||||
$vi.= '<tr><td>Global Path</td><td width="600"><b>'. addslashes($PATH).'</b></td></tr>';
|
||||
$vi.= '<tr><td>Global Path-Translated</td><td width="600"><b>'. addslashes($PATH_TRANSLATED).'</b></td></tr>';
|
||||
$vi.= '<tr><td>Global Script-Filename</td><td width="600"><b>'.addslashes($SCRIPT_FILENAME).'</b></td></tr>';
|
||||
$vi.= '<tr><td>Global Script-Name</td><td width="600"><b>'.addslashes($SCRIPT_NAME).'</b></td></tr>';
|
||||
|
||||
$evars=str_replace("<td>","",$vi);
|
||||
$evars=str_replace('<td width="600">',"",$evars);
|
||||
$evars=str_replace('<tr>',"",$evars);
|
||||
$evars=str_replace('</td>',"",$evars);
|
||||
$evars=str_replace('</tr>',"\n",$evars);
|
||||
|
||||
|
||||
|
||||
//Form-vars
|
||||
$r.=$vi.'<input type="hidden" name="error_vars" value="'.$evars.'">';
|
||||
$r.='<input type="hidden" name="error_subject" value="'.$subject.'">';
|
||||
$r.='<input type="hidden" name="error_mailfrom" value="'.$config["email_sender"].'">';
|
||||
|
||||
$r.= '<tr><td colspan="2" align="center"><input class="Formbutton3" type="submit" name="error_submit" value="Fehlerbericht absenden"></td></tr>';
|
||||
|
||||
|
||||
$r.= "<tr><td><a href='main.php' class='ul'>Home</a></td></tr></table></div></form></body></html>";
|
||||
return $r;
|
||||
}
|
||||
|
||||
function DynOutput($s,$fertig=0) {
|
||||
|
||||
global $config;
|
||||
|
||||
$out="out.html";
|
||||
$tempDatei=$config["paths"]["log"].$out;
|
||||
$tempURL="work/log/".$out;
|
||||
|
||||
|
||||
if($fertig==0) {
|
||||
//$meta='<meta http-equiv="Refresh" content="1">'."\n";
|
||||
$meta.='<meta http-equiv="Pragma" content="no-cache">'."\n";
|
||||
$meta.='<script language="JavaScript">
|
||||
function doReload() {
|
||||
document.loaction.href="";
|
||||
}
|
||||
setTimeout("doReload()", 400);
|
||||
</script>';
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
//Header für HTML
|
||||
$h="<html>\n<head>\n".$meta."\n<title>MySqlDumper</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../styles.css\">";
|
||||
$h.="\n</head>\n<body bgcolor=\"#F5F5F5\">\n";
|
||||
//Footer
|
||||
$f='</body></html>';
|
||||
$page=$h.$s.$f;
|
||||
|
||||
$f=fopen($tempDatei,"w");
|
||||
fwrite($f,$page);
|
||||
fclose($f);
|
||||
echo '<script type="text/javascript">parent.dump_visible.location.href='.$tempURL.';</script>';
|
||||
|
||||
/*echo "<pre>$page</pre>";
|
||||
die;*/
|
||||
}
|
||||
|
||||
function TesteFTP($ftp_server,$ftp_port,$ftp_user_name,$ftp_user_pass,$ftp_dir)
|
||||
{
|
||||
global $lang,$config;
|
||||
if($ftp_port=="" || $ftp_port==0) $ftp_port=21;
|
||||
$pass=-1;
|
||||
if(!extension_loaded("ftp")) {
|
||||
$s='<span class="smallwarnung">'.$lang['noftppossible'].'</span>';
|
||||
} else $pass=0;
|
||||
|
||||
if($pass==0) {
|
||||
if($ftp_server=="" || $ftp_user_name=="" || $ftp_user_pass=="") {
|
||||
$s='<span class="smallwarnung">'.$lang['wrongconnectionpars'].'</span>';
|
||||
} else $pass=1;
|
||||
}
|
||||
|
||||
|
||||
if($pass==1) {
|
||||
$s=$lang['connect_to'].' `'.$ftp_server.'` Port '.$ftp_port.' ... ';
|
||||
|
||||
if($config["ftp_useSSL"]==0)
|
||||
$conn_id = @ftp_connect($ftp_server,$ftp_port,$config["ftp_timeout"]);
|
||||
else
|
||||
$conn_id = @ftp_ssl_connect($ftp_server,$ftp_port,$config["ftp_timeout"]);
|
||||
|
||||
$login_result = @ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
|
||||
if(!$conn_id || (!$login_result)) {
|
||||
$s.='<span class="smallwarnung">'.$lang['conn_not_possible'].'</span>';
|
||||
} else $pass=2;
|
||||
}
|
||||
|
||||
if($pass==2) {
|
||||
$s.='<strong>ok, logged in</strong><br>'.$lang['changedir'].' `'.$ftp_dir.'` ... ';
|
||||
$dirc=@ftp_chdir($conn_id,$ftp_dir);
|
||||
if(!$dirc) {
|
||||
$s.='<br><span class="smallwarnung">'.$lang['changedirerror'].'</span>';
|
||||
} else $pass=3;
|
||||
@ftp_close($conn_id);
|
||||
}
|
||||
if($pass==3) $s.='<br><br><strong>'.$lang['ftp_ok'].'</strong>';
|
||||
return $s;
|
||||
}
|
||||
|
||||
function headline() {
|
||||
global $config;
|
||||
if($config["interface_server_caption"]==1) return '<div style="background-color:'.$config["interface_server_captioncolor"].';width:100%;text-align:center;font-size:11px;"><a href="http://'.$_SERVER["SERVER_NAME"].'" target="_blank" title="'.$_SERVER["SERVER_NAME"].'" style="color:'.buildComplement($config["interface_server_captioncolor"]).'">'.$_SERVER["SERVER_NAME"].'</a></div>';
|
||||
}
|
||||
|
||||
function buildComplement ($color) {
|
||||
|
||||
$komp = -1;
|
||||
|
||||
if (preg_match('/^#[0-9A-F]{1,6}$/i', $color)) {
|
||||
|
||||
$red_str = substr($color, 1, 2);
|
||||
$green_str = substr($color, 3, 2);
|
||||
$blue_str = substr($color, 5, 2);
|
||||
|
||||
$red_int = 255 - base_convert($red_str, 16, 10);
|
||||
$green_int = 255 - base_convert($green_str, 16, 10);
|
||||
$blue_int = 255 - base_convert($blue_str, 16, 10);
|
||||
|
||||
$red_str = base_convert($red_int, 10, 16);
|
||||
$green_str = base_convert($green_int, 10, 16);
|
||||
$blue_str = base_convert($blue_int, 10, 16);
|
||||
|
||||
if (strlen($red_str) == 1) $red_str = '0' . $red_str;
|
||||
if (strlen($green_str) == 1) $green_str = '0' . $green_str;
|
||||
if (strlen($blue_str) == 1) $blue_str = '0' . $blue_str;
|
||||
|
||||
$komp = '#' . strtoupper($red_str) . strtoupper($green_str) . strtoupper($blue_str);
|
||||
|
||||
} else return $komp;
|
||||
|
||||
return $komp;
|
||||
|
||||
}
|
||||
|
||||
function dump($v)
|
||||
{
|
||||
// Ausgabe von var_dump über Output-Buffer in Variable einlesen
|
||||
|
||||
ob_start ();
|
||||
var_dump ($v);
|
||||
$content = ob_get_contents ();
|
||||
ob_end_clean ();
|
||||
|
||||
// maximale Einrückung ermitteln
|
||||
$m = 0;
|
||||
#1
|
||||
preg_match_all ('#^(.*)=>#mU', $content, $stack);
|
||||
$lines = $stack[1];
|
||||
$indents = array_map ('strlen', $lines);
|
||||
if ($indents) {
|
||||
$m = max ($indents) + 1;
|
||||
}
|
||||
#2
|
||||
// Ausgabe von var_dump() an maximaler Einrückung ausrichten
|
||||
$content = preg_replace ('#^(.*)=>\\n\s+(\S)#eUm', '"\\1" .str_repeat(" ", $m - strlen("\\1")>1 ? $m - strlen("\\1") : 1). "\\2"',$content);
|
||||
// bei Array-Strukturen öffnende Klammer { in neue Zeile
|
||||
$content = preg_replace ( '#^((\s*).*){$#m', "\\1\n\\2{", $content);
|
||||
|
||||
echo '<pre>'. htmlentities($content). '</pre>';
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
?>
|
||||
262
inc/functions_restore.php
Normale Datei
262
inc/functions_restore.php
Normale Datei
|
|
@ -0,0 +1,262 @@
|
|||
<?php
|
||||
include_once("inc/functions_global.php");
|
||||
|
||||
function get_sqlbefehl()
|
||||
{
|
||||
global $restore,$config,$databases;
|
||||
|
||||
//Init
|
||||
$restore["fileEOF"]=false;
|
||||
$complete_sql="";
|
||||
$sqlparser_status=0;
|
||||
if(!isset($restore["eintraege_ready"])) $restore["eintraege_ready"]=0;
|
||||
//Parsen
|
||||
WHILE ($sqlparser_status!=100 && (!$restore["fileEOF"]))
|
||||
{
|
||||
//Zeile lesen
|
||||
$zeile= ($restore["compressed"]) ? gzgets($restore["filehandle"],40960) : fgets($restore["filehandle"],40960);
|
||||
if($sqlparser_status==0)
|
||||
{
|
||||
//hier folgt der Anfang eines SQL-Befehls
|
||||
if(substr($zeile,0,1)=="#" or substr($zeile,0,2)=="--")
|
||||
{
|
||||
//Kommentar
|
||||
$zeile="";
|
||||
}
|
||||
else
|
||||
{
|
||||
// was beginnt hier ?
|
||||
if(strtoupper(substr($zeile,0,10))=="DROP TABLE")
|
||||
{
|
||||
$sqlparser_status=1; //Löschaktion
|
||||
//Neue Tabelle beginnt - überprüfen, obs gewünscht ist
|
||||
$restore["do_it"]=false;
|
||||
//prüfen ob gewünscht
|
||||
if(isset($tbl_sel))
|
||||
{
|
||||
if(in_array($tbl_name,$tblArray)) $restore["do_it"]=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$restore["do_it"]=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(strtoupper(substr($zeile,0,12))=="CREATE TABLE") $sqlparser_status=2; //Createaktion
|
||||
if(strtoupper(substr($zeile,0,12))=="CREATE INDEX") $sqlparser_status=4; //Createaktion
|
||||
if(strtoupper(substr($zeile,0,11))=="INSERT INTO")
|
||||
{
|
||||
$sqlparser_status=3; //Datensatzaktion
|
||||
$restore["eintraege_ready"]++;
|
||||
$restore["actual_table"]=strtolower(get_tablename_aus_insert($zeile)); // aktuellen Tabellennamen aus der INSERT-Anweisung extrahieren
|
||||
if(!isset($restore["num_table_fields"][$restore["actual_table"]])) {
|
||||
$restore["num_table_fields"][$restore["actual_table"]]=$restore["actual_fieldcount"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$last_char=substr(rtrim($zeile),-1);
|
||||
$complete_sql.=$zeile;
|
||||
|
||||
if($sqlparser_status==1)
|
||||
{ //Löschaktion
|
||||
if($last_char==";" ) $sqlparser_status=100; //Befehl komplett
|
||||
}
|
||||
|
||||
if($sqlparser_status==2)
|
||||
{ //Createaktion
|
||||
if($last_char==";" )
|
||||
{
|
||||
if($config["minspeed"]>0) {$restore["anzahl_zeilen"]=$config["minspeed"];}
|
||||
$restore["actual_table"]=strtolower(get_tablename($complete_sql));
|
||||
//Tabellenfelderanzahl ermitteln
|
||||
$restore["actual_fieldcount"]=AnzahlTabellenfelder($complete_sql);
|
||||
$restore["num_table_fields"][$restore["actual_table"]]=$restore["actual_fieldcount"];
|
||||
//DEFAULT CHARSET HACK
|
||||
if((GetMySQLVersion()-4.1)<0) {
|
||||
$ll=strpos(strtoupper($complete_sql)," DEFAULT CHARSET");
|
||||
if($ll) {
|
||||
$ll2=strpos($complete_sql," ",$ll+12);
|
||||
if($ll2)
|
||||
$complete_sql=substr($complete_sql,0,$ll).substr($complete_sql,$ll2);
|
||||
else
|
||||
$complete_sql=substr($complete_sql,0,$ll).';';
|
||||
}
|
||||
}
|
||||
$restore["table_create"][$restore["actual_table"]]=$complete_sql;
|
||||
$sqlparser_status=100; //Befehl komplett
|
||||
}
|
||||
}
|
||||
if($sqlparser_status==4)
|
||||
{ //Createindex
|
||||
if($last_char==";" )
|
||||
{
|
||||
if($config["minspeed"]>0) {$restore["anzahl_zeilen"]=$config["minspeed"];}
|
||||
$sqlparser_status=100; //Befehl komplett
|
||||
}
|
||||
}
|
||||
if($sqlparser_status==3)
|
||||
{ //Datensatzaktion
|
||||
if(substr(rtrim($zeile),-2)==");")
|
||||
{
|
||||
//scheinbar ein Ende erreicht
|
||||
$AnzahlFelder=SQL_Is_Complete($complete_sql);
|
||||
|
||||
if($AnzahlFelder==$restore["num_table_fields"][$restore["actual_table"]])
|
||||
{
|
||||
$sqlparser_status=100;
|
||||
}
|
||||
if($AnzahlFelder>$restore["num_table_fields"][$restore["actual_table"]])
|
||||
{
|
||||
if(!isset($restore["table_create"][$restore["actual_table"]])) {
|
||||
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 '<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>';
|
||||
|
||||
/*echo "<pre>";
|
||||
print_r($restore);
|
||||
echo "</pre>";*/
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ($restore["compressed"]) && (gzeof($restore["filehandle"])) ) $restore["fileEOF"]=true;
|
||||
if ( (!$restore["compressed"]) && (feof($restore["filehandle"])) ) $restore["fileEOF"]=true;
|
||||
}
|
||||
return trim($complete_sql) ;
|
||||
}
|
||||
|
||||
// extrahiert auf einfache Art den Tabellennamen aus dem "Create"-Befehl
|
||||
function get_tablename($t)
|
||||
{
|
||||
global $restore;
|
||||
$t=trim(str_replace("CREATE TABLE","",strtoupper($t)));
|
||||
$w=explode(" ",$t);
|
||||
$tn=$w[0];
|
||||
$restore["table_ready"]++;
|
||||
if(substr($tn,0,1)=="`") $tn=substr($tn,1,strlen($tn)-2);
|
||||
return $tn;
|
||||
}
|
||||
|
||||
// extrahiert auf einfache Art den Tabellennamen aus dem "Create"-Befehl
|
||||
function get_tablename_aus_insert($t)
|
||||
{
|
||||
$t=str_replace("insert into ","",strtolower($t));
|
||||
$w=explode(" ",$t);
|
||||
$tn=$w[0];
|
||||
if(substr($tn,0,1)=="`") $tn=substr($tn,1,strlen($tn)-2);
|
||||
return $tn;
|
||||
}
|
||||
|
||||
function AnzahlTabellenfelder($s,$debug=0)
|
||||
{
|
||||
// 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 SQL_Is_Complete($s,$debug=0)
|
||||
{
|
||||
$anz=$f_begin=$f_end=0;
|
||||
$Backslash=chr(92);
|
||||
$s=trim(strtoupper(($s)));
|
||||
$s=substr($s,0,strlen($s)-2);
|
||||
|
||||
$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($tb[$i]);
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
return $anz;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
788
inc/functions_sql.php
Normale Datei
788
inc/functions_sql.php
Normale Datei
|
|
@ -0,0 +1,788 @@
|
|||
<?php
|
||||
|
||||
if(!isset($config["sql_limit"])) $config["sql_limit"]=30;
|
||||
if(!isset($config["bb_width"])) $config["bb_width"]=300;
|
||||
if(!isset($config["bb_textcolor"])) $config["bb_textcolor"]="#990033";
|
||||
|
||||
|
||||
function ReadSQL()
|
||||
{
|
||||
global $SQL_ARRAY,$config;
|
||||
$sf=$config["paths"]["config"].'sql_statements';
|
||||
if(!is_file($sf)){
|
||||
$fp=fopen($sf,"w+");
|
||||
fclose($fp);
|
||||
@chmod($sf,0775);
|
||||
}
|
||||
if(count($SQL_ARRAY)==0 && filesize($sf)>0) {
|
||||
$SQL_ARRAY=file($sf);
|
||||
}
|
||||
}
|
||||
function WriteSQL()
|
||||
{
|
||||
global $SQL_ARRAY,$config;
|
||||
$sf=$config["paths"]["config"].'sql_statements';
|
||||
$str="";
|
||||
for($i=0;$i<count($SQL_ARRAY);$i++) {
|
||||
$str.=$SQL_ARRAY[$i];
|
||||
if(substr($str,-1)!="\n" && $i!=(count($SQL_ARRAY)-1)) $str.="\n";
|
||||
|
||||
}
|
||||
$fp=fopen($sf,"wb");
|
||||
fwrite($fp,$str);
|
||||
fclose($fp);
|
||||
|
||||
}
|
||||
function SQL_Name($index)
|
||||
{
|
||||
global $SQL_ARRAY;
|
||||
$s=explode("|",$SQL_ARRAY[$index]);
|
||||
return $s[0];
|
||||
}
|
||||
function SQL_String($index)
|
||||
{
|
||||
global $SQL_ARRAY;
|
||||
if(isset($SQL_ARRAY[$index]) && !empty($SQL_ARRAY[$index])) {
|
||||
$s=explode("|",$SQL_ARRAY[$index]);
|
||||
return (isset($s[1])) ? $s[1] : "";
|
||||
}
|
||||
}
|
||||
function SQL_ComboBox()
|
||||
{
|
||||
global $SQL_ARRAY,$tablename,$nl;
|
||||
$s=$nl.$nl.'<select class="SQLCombo" name="sqlcombo" onchange="this.form.tb_sql.value=this.options[this.selectedIndex].value;">'.$nl;
|
||||
$s.='<option value="" selected> </option>'.$nl;
|
||||
if(count($SQL_ARRAY)>0) {
|
||||
for($i=0;$i<count($SQL_ARRAY);$i++) {
|
||||
$s.='<option value=\''.stripslashes(SQL_String($i)).'\'>'.SQL_Name($i).'</option>'.$nl;
|
||||
}
|
||||
}
|
||||
$s.='</select>'.$nl.$nl;
|
||||
return $s;
|
||||
}
|
||||
|
||||
function Table_ComboBox()
|
||||
{
|
||||
global $db,$config,$lang,$nl;
|
||||
$tabellen = mysql_list_tables($db,$config["dbconnection"]);
|
||||
$num_tables = mysql_num_rows($tabellen);
|
||||
$s=$nl.$nl.'<select class="SQLCombo" name="tablecombo" onchange="this.form.tb_sql.value=this.options[this.selectedIndex].value;">'.$nl.'<option value="" selected> </option>'.$nl;
|
||||
for($i=0;$i<$num_tables;$i++) {
|
||||
$t=mysql_tablename($tabellen,$i);
|
||||
$s.='<option value="SELECT * FROM `'.$t.'`">'.$lang['table'].' `'.$t.'`</option>'.$nl;
|
||||
}
|
||||
$s.='</select>'.$nl.$nl;
|
||||
return $s;
|
||||
}
|
||||
|
||||
function DB_Exists($db)
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config["dbconnection"])) MSD_mysql_connect();
|
||||
$erg=false;
|
||||
$dbs=mysql_list_dbs($config["dbconnection"]);
|
||||
while ($row = mysql_fetch_object($dbs)) {
|
||||
if(strtolower($row->Database)==strtolower($db)) {
|
||||
$erg=true;break;
|
||||
}
|
||||
}
|
||||
return $erg;
|
||||
}
|
||||
function Table_Exists($db,$table)
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config["dbconnection"])) MSD_mysql_connect();
|
||||
$erg=false;
|
||||
$sqlt="SHOW TABLES FROM `$db`";
|
||||
$res=MSD_query($sqlt) or die(SQLError($sqlt,mysql_error()));
|
||||
|
||||
if($res) {
|
||||
$row = mysql_fetch_row($res);
|
||||
if(strtolower($row[0])==strtolower($table)) {
|
||||
$erg=true;
|
||||
}
|
||||
} else die("ERROR");
|
||||
return $erg;
|
||||
}
|
||||
|
||||
function DB_Empty($dbn)
|
||||
{
|
||||
$r="DROP DATABASE `$dbn`;\nCREATE DATABASE `$dbn`;";
|
||||
MSD_DoSQL($r);
|
||||
|
||||
}
|
||||
|
||||
function DB_Copy($source,$destination,$drop_source=0,$insert_data=1)
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config["dbconnection"])) MSD_mysql_connect();
|
||||
$SQL_Array=$t="";
|
||||
if(!DB_Exists($destination)) $SQL_Array.="CREATE DATABASE `$destination` ;\n";
|
||||
$SQL_Array.="USE `$destination` ;\n";
|
||||
$tabellen = mysql_list_tables($source,$config["dbconnection"]);
|
||||
$num_tables = mysql_num_rows($tabellen);
|
||||
for($i=0;$i<$num_tables;$i++) {
|
||||
$table=mysql_tablename($tabellen,$i);
|
||||
$sqlt="SHOW CREATE TABLE `$source`.`$table`";
|
||||
$res=MSD_query($sqlt) or die(SQLError($sqlt,mysql_error()));
|
||||
$row=mysql_fetch_row($res);
|
||||
$c=$row[1]; if(substr($c,-1)==";") $c=substr($c,0,strlen($c)-1);
|
||||
$SQL_Array.=($insert_data==1) ? "$c SELECT * FROM `$source`.`$table` ;\n" : "$c ;\n";
|
||||
}
|
||||
if($drop_source==1) $SQL_Array.="DROP DATABASE `$source` ;";
|
||||
|
||||
mysql_select_db($destination);
|
||||
MSD_DoSQL($SQL_Array);
|
||||
|
||||
}
|
||||
function Table_Copy($source,$destination,$insert_data,$destinationdb="")
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config["dbconnection"])) MSD_mysql_connect();
|
||||
$SQL_Array=$t="";
|
||||
$sqlc="SHOW CREATE TABLE $source";
|
||||
$res=MSD_query($sqlc) or die(SQLError($sqlc,mysql_error()));
|
||||
$row=mysql_fetch_row($res);
|
||||
$c=$row[1];
|
||||
$a1=strpos($c,"`");
|
||||
$a2=strpos($c,"`",$a1+1);
|
||||
$c=substr($c,0,$a1+1).$destination.substr($c,$a2);
|
||||
if(substr($c,-1)==";") $c=substr($c,0,strlen($c)-1);
|
||||
$SQL_Array.=($insert_data==1) ? "$c SELECT * FROM $source ;\n" : "$c ;\n";
|
||||
//echo "<h5>$SQL_Array</h5>";
|
||||
MSD_DoSQL($SQL_Array);
|
||||
|
||||
}
|
||||
function MSD_DoSQL($sqlcommands,$limit="")
|
||||
{
|
||||
|
||||
global $config,$out,$numrowsabs,$numrows,$num_befehle,$time_used,$sql;
|
||||
|
||||
if(!isset($sql["parser"]["sql_commands"])) $sql["parser"]["sql_commands"]=0;
|
||||
if(!isset($sql["parser"]["sql_errors"])) $sql["parser"]["sql_errors"]=0;
|
||||
|
||||
$sql["parser"]["time_used"]=getmicrotime();
|
||||
if(!isset($config["dbconnection"])) MSD_mysql_connect();
|
||||
$out=$sqlcommand="";
|
||||
$allSQL=explode("\n",$sqlcommands);
|
||||
$sql_queries=count($allSQL);
|
||||
if(!isset($allSQL[$sql_queries-1])) $sql_queries--;
|
||||
if($sql_queries==1) {
|
||||
SQLParser($allSQL[0]);
|
||||
$sql["parser"]["sql_commands"]++;
|
||||
$out.=Stringformat(($sql["parser"]["sql_commands"]),4).": ". $allSQL[0]."\n";
|
||||
$result =MSD_query($allSQL[0]) or die(SQLError($allSQL[0],mysql_error()));
|
||||
|
||||
} else {
|
||||
|
||||
for($i=0;$i<$sql_queries; $i++) {
|
||||
$allSQL[$i]=trim(rtrim($allSQL[$i]));
|
||||
if($allSQL[$i]!="") {
|
||||
$sqlcommand.=$allSQL[$i];
|
||||
SQLParser($sqlcommand);
|
||||
if($sql["parser"]["start"]==0 && $sql["parser"]["end"]==0) {
|
||||
//sql complete
|
||||
$sql["parser"]["sql_commands"]++;
|
||||
$out.=Stringformat(($sql["parser"]["sql_commands"]),4).": ". $sqlcommand."\n";
|
||||
$result =MSD_query($sqlcommand) or die(SQLError($sqlcommand,mysql_error()));
|
||||
$sqlcommand="";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql["parser"]["time_used"]=getmicrotime()-$sql["parser"]["time_used"];
|
||||
}
|
||||
|
||||
function SQLParser($s,$debug=0)
|
||||
{
|
||||
global $sql;
|
||||
$sql["parser"]["start"]=$sql["parser"]["end"]=0;
|
||||
$sql["parser"]["sqlparts"]=0;
|
||||
if(!isset($sql["parser"]["drop"])) $sql["parser"]["drop"]=0;
|
||||
if(!isset($sql["parser"]["create"])) $sql["parser"]["create"]=0;
|
||||
if(!isset($sql["parser"]["insert"])) $sql["parser"]["insert"]=0;
|
||||
if(!isset($sql["parser"]["update"])) $sql["parser"]["update"]=0;
|
||||
if(!isset($sql["parser"]["comment"])) $sql["parser"]["comment"]=0;
|
||||
$Backslash=chr(92);
|
||||
$s=rtrim(trim(strtoupper(($s))));
|
||||
|
||||
//Was ist das für eine Anfrage ?
|
||||
if(substr($s,0,1)=="#" || substr($s,0,2)=="--") {
|
||||
$sql["parser"]["comment"]++;
|
||||
} elseif(substr($s,0,5)=="DROP ") {
|
||||
$sql["parser"]["drop"]++;
|
||||
} elseif(substr($s,0,7)=="CREATE ") {
|
||||
//Hier nur die Anzahl der Klammern zählen
|
||||
$sql["parser"]["start"]=1;
|
||||
$kl1=substr_count($s,"(");
|
||||
$kl2=substr_count($s,")");
|
||||
if($kl2-$kl1==0) {
|
||||
$sql["parser"]["start"]=0;
|
||||
$sql["parser"]["create"]++;
|
||||
}
|
||||
} elseif(substr($s,0,7)=="INSERT " || substr($s,0,7)=="UPDATE ") {
|
||||
|
||||
if(substr($s,0,7)=="INSERT ") $sql["parser"]["insert"]++; else $sql["parser"]["update"]++;
|
||||
$i=strpos($s," VALUES")+7;
|
||||
$s=substr($s,$i);
|
||||
$i=strpos($s,"(")+1;
|
||||
$s=substr($s,$i);
|
||||
$s=substr($s,0,strlen($s)-2);
|
||||
|
||||
$tb=explode(",",$s);
|
||||
for ($i=0;$i<count($tb);$i++){
|
||||
$first=$B_Esc=$B_Ticks=$B_Dashes=0;
|
||||
$v=trim($tb[$i]);
|
||||
//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" && $sql["parser"]["start"]==0){$sql["parser"]["start"]=1;$sql["parser"]["end"]=1;}
|
||||
if($sql["parser"]["start"]==0 && is_numeric($v)){$sql["parser"]["start"]=1;$sql["parser"]["end"]=1;}
|
||||
if($sql["parser"]["start"]==0 && substr($v,0,2)=="0X" && strpos($v," ")==false){$sql["parser"]["start"]=1;$sql["parser"]["end"]=1;}
|
||||
if($sql["parser"]["start"]==0 && is_object($v)){$sql["parser"]["start"]=1;$sql["parser"]["end"]=1;}
|
||||
|
||||
if(substr($v,0,1)=="'" && $sql["parser"]["start"]==0) {$sql["parser"]["start"]=1;if(strlen($v)==1)$first=1;$DELIMITER="'";}
|
||||
if(substr($v,0,1)=='"' && $sql["parser"]["start"]==0) {$sql["parser"]["start"]=1;if(strlen($v)==1)$first=1;$DELIMITER='"';}
|
||||
if($sql["parser"]["start"]==1 && $sql["parser"]["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) {
|
||||
|
||||
$sql["parser"]["end"]=1;
|
||||
} elseif (($B_Delimiter % 2)==1 && strlen($v)>2) {
|
||||
//ist mit `'` maskiert
|
||||
$sql["parser"]["end"]=0;
|
||||
} elseif(($B_Esc % 2)==1) {
|
||||
//ist mit Backslash maskiert
|
||||
$sql["parser"]["end"]=0;
|
||||
} else {
|
||||
|
||||
$sql["parser"]["end"]=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($debug==1) echo "<font color='#0000FF'>".$sql["parser"]["start"]."/".$sql["parser"]["end"]."</font> Feld $i: ".htmlspecialchars($tb[$i])."<font color=#008000>- ".$sql["parser"]["sqlparts"]." ($B_Ticks / $B_Esc)</font><br>";
|
||||
if($sql["parser"]["start"]==1 && $sql["parser"]["end"]==1) {
|
||||
$sql["parser"]["sqlparts"]++;
|
||||
|
||||
$sql["parser"]["start"]=$sql["parser"]["end"]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SQLOutput($sqlcommand,$meldung="")
|
||||
{
|
||||
global $sql,$lang;
|
||||
$s= '<div align="left" class="sqloutbox" style="font-size: 11px;width:90%;padding=6px;">';
|
||||
if($meldung!="") $s.='<p class="success" align="left">'.$meldung.'</p>';
|
||||
$s.='<h5 align="center">'.$lang['sql_output'].'</h5>';
|
||||
$s.='<strong>'.$sql["parser"]["sql_commands"].'</strong>'.$lang['sql_commands_in'].round($sql["parser"]["time_used"],4).$lang['sql_commands_in2'].'<br><br>';
|
||||
$s.=$lang['sql_out1'].'<strong>'.$sql["parser"]["drop"].'</strong> <span style="color:#990099;font-weight:bold;">DROP</span>-, ';
|
||||
$s.='<strong>'.$sql["parser"]["create"].'</strong> <span style="color:#990099;font-weight:bold;">CREATE</span>-, ';
|
||||
$s.='<strong>'.$sql["parser"]["insert"].'</strong> <span style="color:#990099;font-weight:bold;">INSERT</span>-, ';
|
||||
$s.='<strong>'.$sql["parser"]["update"].'</strong> <span style="color:#990099;font-weight:bold;">UPDATE</span>-'.$lang['sql_out2'].'<br>';
|
||||
$s.=$lang['sql_out3'].'<strong>'.$sql["parser"]["comment"].'</strong> '.$lang['sql_out4'].'<br>';
|
||||
if($sql["parser"]["sql_commands"]<5000)
|
||||
$s.='<pre style="line-height: 60%;">'.highlight_sql($sqlcommand).'</pre></div>';
|
||||
else $s.=$lang['sql_out5']."</div>";
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function GetCreateTable($db,$tabelle)
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config["dbconnection"])) MSD_mysql_connect();
|
||||
$res=mysql_query("SHOW CREATE TABLE `$db`.`$tabelle`");
|
||||
if($res) {
|
||||
$row=mysql_fetch_array($res);
|
||||
return $row["Create Table"];
|
||||
} else return mysql_error();
|
||||
|
||||
}
|
||||
|
||||
function KindSQL($sql)
|
||||
{
|
||||
if (preg_match('@^((-- |#)[^\n]*\n|/\*.*?\*/)*(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@im', $sql)) {
|
||||
return 2;
|
||||
} elseif (preg_match('@^((-- |#)[^\n]*\n|/\*.*?\*/)*(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@im', $sql)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function GetPostParams()
|
||||
{
|
||||
global $db,$dbid,$tablename,$context,$limitstart,$order,$orderdir,$sql;
|
||||
$db=$_POST["db"];
|
||||
$dbid=$_POST["dbid"];
|
||||
$tablename=$_POST["tablename"];
|
||||
$context=$_POST["context"];
|
||||
$limitstart=$_POST["limitstart"];
|
||||
$order=$_POST["order"];
|
||||
$orderdir=$_POST["orderdir"];
|
||||
$sql["sql_statement"]=(isset($_POST["sql"])) ? stripslashes(urldecode($_POST["sql"])) : "SELECT * FROM `$tablename`";
|
||||
|
||||
}
|
||||
|
||||
function ComboCommandDump($when,$index)
|
||||
{
|
||||
global $SQL_ARRAY,$nl,$databases;
|
||||
|
||||
if($when==0) {
|
||||
$r='<select class="SQLCombo" name="command_before_'.$index.'">';
|
||||
$csql=$databases["command_before_dump"][$index];
|
||||
} else {
|
||||
$r='<select class="SQLCombo" name="command_after_'.$index.'">';
|
||||
$csql=$databases["command_after_dump"][$index];
|
||||
}
|
||||
|
||||
$r.='<option value="" '.(($csql=="") ? "selected" : "").'> </option>';
|
||||
if(count($SQL_ARRAY)>0) {
|
||||
for($i=0;$i<count($SQL_ARRAY);$i++) {
|
||||
$s=SQL_String($i);
|
||||
$r.='<option value=\''.stripslashes($s).'\' '.(($csql==stripslashes($s)) ? "selected" : "").'>'.SQL_Name($i).'</option>'.$nl;
|
||||
}
|
||||
}
|
||||
|
||||
$r.='</select>';
|
||||
return $r;
|
||||
}
|
||||
|
||||
function EngineCombo($default="")
|
||||
{
|
||||
global $config;
|
||||
if(!$config["dbconnection"]) MSD_mysql_connect();
|
||||
|
||||
$r='<option value="" '.(($default=="") ? "selected" : "").'></option>';
|
||||
if(!MSD_NEW_VERSION) {
|
||||
//BDB | HEAP | ISAM | InnoDB | MERGE | MRG_MYISAM | MYISAM
|
||||
$r.='<option value="BDB" '.(("BDB"==$default) ? "selected" : "").'>BDB</option>';
|
||||
$r.='<option value="HEAP" '.(("HEAP"==$default) ? "selected" : "").'>HEAP</option>';
|
||||
$r.='<option value="ISAM" '.(("ISAM"==$default) ? "selected" : "").'>ISAM</option>';
|
||||
$r.='<option value="InnoDB" '.(("InnoDB"==$default) ? "selected" : "").'>InnoDB</option>';
|
||||
$r.='<option value="MERGE" '.(("MERGE"==$default) ? "selected" : "").'>MERGE</option>';
|
||||
$r.='<option value="MRG_MYISAM" '.(("MRG_MYISAM"==$default) ? "selected" : "").'>MRG_MYISAM</option>';
|
||||
$r.='<option value="MYISAM" '.(("MyISAM"==$default) ? "selected" : "").'>MyISAM</option>';
|
||||
} else {
|
||||
$res=mysql_query("SHOW ENGINES");
|
||||
$num = mysql_num_rows($res);
|
||||
for($i=0;$i<$num;$i++) {
|
||||
$row=mysql_fetch_array($res);
|
||||
$r.='<option value="'.$row["Engine"].'" '.(($row["Engine"]==$default) ? "selected" : "").'>'.$row["Engine"].'</option>';
|
||||
}
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function CharsetCombo($default="")
|
||||
{
|
||||
global $config;
|
||||
if(!MSD_NEW_VERSION) { return "";
|
||||
} else {
|
||||
if(!isset($config["dbconnection"])) MSD_mysql_connect();
|
||||
$res=mysql_query("SHOW Charset");
|
||||
$num = mysql_num_rows($res);
|
||||
$r='<option value="" '.(($default=="") ? "selected" : "").'></option>';
|
||||
for($i=0;$i<$num;$i++) {
|
||||
$row=mysql_fetch_array($res);
|
||||
$r.='<option value="'.$row["Charset"].'" '.(($row["Charset"]==$default) ? "selected" : "").'>'.$row["Charset"].'</option>';
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
||||
function GetCollationArray()
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config["dbconnection"])) MSD_mysql_connect();
|
||||
|
||||
$res=mysql_query("SHOW Collation");
|
||||
$num = mysql_num_rows($res);
|
||||
$r=Array();
|
||||
for($i=0;$i<$num;$i++) {
|
||||
$row=mysql_fetch_array($res);
|
||||
$r[$i]["Collation"]=$row["Collation"];
|
||||
$r[$i]["Charset"]=$row["Charset"];
|
||||
$r[$i]["Id"]=$row["Id"];
|
||||
$r[$i]["Default"]=$row["Default"];
|
||||
$r[$i]["Compiled"]=$row["Compiled"];
|
||||
$r[$i]["Sortlen"]=$row["Sortlen"];
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function CollationCombo($default="")
|
||||
{
|
||||
|
||||
|
||||
if(!MSD_NEW_VERSION) {
|
||||
return "";
|
||||
} else {
|
||||
$r=GetCollationArray();
|
||||
sort($r);
|
||||
$s="";
|
||||
$s='<option value="" '.(($default=="") ? "selected" : "").'></option>';
|
||||
$group="";
|
||||
for($i=0;$i<count($r);$i++) {
|
||||
$gc=$r[$i]["Charset"];
|
||||
if($gc!=$group) {
|
||||
$group=$gc;
|
||||
$s.='<optgroup label="'.$group.'">';
|
||||
}
|
||||
$s.='<option value="'.$r[$i]["Collation"].'" '.(($r[$i]["Collation"]==$default) ? "selected" : "").'>'.$r[$i]["Collation"].'</option>';
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
|
||||
function simple_bbcode_conversion($a)
|
||||
{
|
||||
global $config;
|
||||
$tag_start='<div style="color:'.$config["bb_textcolor"].';width:'.$config["bb_width"].'px;">';
|
||||
$tag_end='</div>';
|
||||
|
||||
//replacements
|
||||
$a=nl2br($a);
|
||||
|
||||
$a=preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/si","<a class=\"small\" href=\"$1\" target=\"blank\">$2</a>",$a);
|
||||
$a=preg_replace("/\[urltargetself=(.*?)\](.*?)\[\/urltargetself\]/si","<a class=\"small\" href=\"$1\" target=\"blank\">$2</a>",$a);
|
||||
$a=preg_replace("/\[url\](.*?)\[\/url\]/si","<a class=\"small\" href=\"$1\" target=\"blank\">$1</a>",$a);
|
||||
$a=preg_replace("/\[ed2k=\+(.*?)\](.*?)\[\/ed2k\]/si","<a class=\"small\" href=\"$1\" target=\"blank\">$2</a>",$a);
|
||||
$a=preg_replace("/\[ed2k=(.*?)\](.*?)\[\/ed2k\]/si","<a class=\"small\" href=\"$1\" target=\"blank\">$2</a>",$a);
|
||||
|
||||
$a=preg_replace("/\[center\](.*?)\[\/center\]/si", "<div align=\"center\">$1</div>", $a);
|
||||
$a=preg_replace("/\[size=([1-2]?[0-9])\](.*?)\[\/size\]/si", "<span style=\"font-size=$1px;\">$2</span>", $a);
|
||||
$a=preg_replace("/\[size=([1-2]?[0-9]):(.*?)\](.*?)\[\/size(.*?)\]/si", "<span style=\"font-size=$1px;\">$3</span>", $a);
|
||||
$a=preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/si", "<span style=\"font-family:$1;\">$2</span>", $a);
|
||||
$a=preg_replace("/\[color=(.*?)\](.*?)\[\/color\]/si", "<span style=\"color=$1;\">$2</span>", $a);
|
||||
$a=preg_replace("/\[color=(.*?):(.*?)\](.*?)\[\/color(.*?)\]/si", "<span style=\"color=$1;\">$3</span>", $a);
|
||||
$a=preg_replace("/\[img\](.*?)\[\/img\]/si", "<img src=\"$1\" vspace=4 hspace=4>", $a);
|
||||
$a=preg_replace("/\[b\](.*?)\[\/b\]/si", "<strong>$1</strong>", $a);
|
||||
$a=preg_replace("/\[b(.*?)\](.*?)\[\/b(.*?)\]/si", "<strong>$2</strong>", $a);
|
||||
$a=preg_replace("/\[u\](.*?)\[\/u\]/si", "<u>$1</u>", $a);
|
||||
$a=preg_replace("/\[u(.*?)\](.*?)\[\/u(.*?)\]/si", "<u>$2</u>", $a);
|
||||
$a=preg_replace("/\[i\](.*?)\[\/i\]/si", "<em>$1</em>", $a);
|
||||
$a=preg_replace("/\[i(.*?)\](.*?)\[\/i(.*?)\]/si", "<em>$2</em>", $a);
|
||||
$a=preg_replace("/\[quote\](.*?)\[\/quote\]/si", "<p align=\"left\" style=\"border: 2px solid silver;padding:4px;\">$1</p>", $a);
|
||||
$a=preg_replace("/\[quote:(.*?)\](.*?)\[\/quote(.*?)\]/si", "<p align=\"left\" style=\"border: 2px solid silver;padding:4px;\">$2</p>", $a);
|
||||
$a=preg_replace("/\[code:(.*?)\](.*?)\[\/code(.*?)\]/si", "<p align=\"left\" style=\"border: 2px solid red;color:green;padding:4px;\">$2</p>", $a);
|
||||
$a=preg_replace("/\[hide\](.*?)\[\/hide\]/si", "<div style=\"background-color:#ccffcc;\">$1</div>", $a);
|
||||
|
||||
$a=preg_replace("/[[:space:]]http:\/\/(.*?)[[:space:]]/si","<a class=\"small\" href=\"http://$1\" target=\"blank\">$1</a>",$a);
|
||||
|
||||
|
||||
|
||||
|
||||
return $tag_start.$a.$tag_end;
|
||||
|
||||
}
|
||||
|
||||
function ExtractTablename($q)
|
||||
{
|
||||
$offset=0;
|
||||
$p=strtoupper($q);
|
||||
$i=strpos($p,"FROM")+5;
|
||||
$p=substr($p,$i);
|
||||
if(substr($p,0,1)=="("){
|
||||
$offset=2;
|
||||
echo "$offset<br>";
|
||||
}
|
||||
if(strpos($p," ",$offset)) {
|
||||
$j=strpos($p," ",$offset);
|
||||
$p=substr($p,$offset,$j);
|
||||
}
|
||||
$t=substr($q,$i+$offset,strlen($p)-$offset);
|
||||
if(substr($t,-1)==",") {
|
||||
//Achtung, keine eindeutige Tabelle
|
||||
$t='';
|
||||
}
|
||||
if(substr($t,0,1)=="`" && substr($t,-1)=="`") $t=substr($t,1,strlen($t)-2);
|
||||
return $t;
|
||||
}
|
||||
|
||||
function GetOptionsCombo($arr,$default)
|
||||
{
|
||||
global $feldtypen,$feldattribute,$feldnull,$feldextras,$feldkeys,$feldrowformat;
|
||||
$r="";
|
||||
foreach ($arr as $s) {
|
||||
$r.='<option value="'.$s.'" '.((strtoupper($default)==strtoupper($s)) ? "selected" : "" ).'>'.$s.'</option>'."\n";
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function DefaultFieldVals()
|
||||
{
|
||||
$dfv=Array();
|
||||
$dfv["VARCHAR"]["defaultsize"]=255;
|
||||
$dfv["VARCHAR"]["maxsize"]=255;
|
||||
|
||||
$dfv["TINYINT"]["defaultsize"]=255;
|
||||
$dfv["TINYINT"]["maxsize"]=255;
|
||||
|
||||
$dfv["TEXT"]["defaultsize"]="";
|
||||
$dfv["TEXT"]["maxsize"]=65535;
|
||||
|
||||
|
||||
$dfv["DATE"]["defaultsize"]=255;
|
||||
$dfv["DATE"]["maxsize"]=255;
|
||||
|
||||
$dfv["SMALLINT"]["defaultsize"]=255;
|
||||
$dfv["SMALLINT"]["maxsize"]=255;
|
||||
|
||||
$dfv["MEDIUMINT"]["defaultsize"]=255;
|
||||
$dfv["MEDIUMINT"]["maxsize"]=255;
|
||||
|
||||
$dfv["INT"]["defaultsize"]=11;
|
||||
$dfv["INT"]["maxsize"]=16;
|
||||
|
||||
$dfv["BIGINT"]["defaultsize"]=255;
|
||||
$dfv["BIGINT"]["maxsize"]=255;
|
||||
|
||||
$dfv["FLOAT"]["defaultsize"]=255;
|
||||
$dfv["FLOAT"]["maxsize"]=255;
|
||||
|
||||
$dfv["DOUBLE"]["defaultsize"]=255;
|
||||
$dfv["DOUBLE"]["maxsize"]=255;
|
||||
|
||||
$dfv["DECIMAL"]["defaultsize"]=255;
|
||||
$dfv["DECIMAL"]["maxsize"]=255;
|
||||
|
||||
$dfv["DATETIME"]["defaultsize"]=255;
|
||||
$dfv["DATETIME"]["maxsize"]=255;
|
||||
|
||||
$dfv["TIMESTAMP"]["defaultsize"]=255;
|
||||
$dfv["TIMESTAMP"]["maxsize"]=255;
|
||||
|
||||
$dfv["TIME"]["defaultsize"]=255;
|
||||
$dfv["TIME"]["maxsize"]=255;
|
||||
|
||||
$dfv["YEAR"]["defaultsize"]=255;
|
||||
$dfv["YEAR"]["maxsize"]=255;
|
||||
|
||||
$dfv["CHAR"]["defaultsize"]=255;
|
||||
$dfv["CHAR"]["maxsize"]=255;
|
||||
|
||||
$dfv["TINYBLOB"]["defaultsize"]=255;
|
||||
$dfv["TINYBLOB"]["maxsize"]=255;
|
||||
|
||||
$dfv["TINYTEXT"]["defaultsize"]=255;
|
||||
$dfv["TINYTEXT"]["maxsize"]=255;
|
||||
|
||||
$dfv["BLOB"]["defaultsize"]=255;
|
||||
$dfv["BLOB"]["maxsize"]=255;
|
||||
|
||||
$dfv["MEDIUMBLOB"]["defaultsize"]=255;
|
||||
$dfv["MEDIUMBLOB"]["maxsize"]=255;
|
||||
|
||||
$dfv["MEDIUMTEXT"]["defaultsize"]=255;
|
||||
$dfv["MEDIUMTEXT"]["maxsize"]=255;
|
||||
|
||||
$dfv["LONGBLOB"]["defaultsize"]=255;
|
||||
$dfv["LONGBLOB"]["maxsize"]=255;
|
||||
|
||||
$dfv["LONGTEXT"]["defaultsize"]=255;
|
||||
$dfv["LONGTEXT"]["maxsize"]=255;
|
||||
|
||||
$dfv["ENUM"]["defaultsize"]=255;
|
||||
$dfv["ENUM"]["maxsize"]=255;
|
||||
|
||||
$dfv["SET"]["defaultsize"]=255;
|
||||
$dfv["SET"]["maxsize"]=255;
|
||||
|
||||
return $dfv;
|
||||
}
|
||||
function FillFieldinfos($db,$tabelle)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$t=GetCreateTable($db,$tabelle);
|
||||
$fields_infos=Array();
|
||||
$fields_infos["_primarykey_"]="";
|
||||
$flds=$keys=$ukeys=$fkeys=0;
|
||||
$fields_infos["_createtable_"]=$t;
|
||||
$tmp=explode("\n",$t);
|
||||
for($i=1;$i<count($tmp)-1;$i++) {
|
||||
$t=trim($tmp[$i]);
|
||||
if(substr($t,-1)==",") $t=substr($t,0,strlen($t)-1);
|
||||
//echo $t."<br>";
|
||||
|
||||
if(substr($t,0,12)=="PRIMARY KEY ") {
|
||||
$t=str_replace("`","",$t);
|
||||
$fields_infos["_primarykey_"]=substr($t,strpos($t,"(")+1,strpos($t,")")-strpos($t,"(")-1);
|
||||
} elseif (substr($t,0,4)=="KEY ") {
|
||||
$t=str_replace("`","",$t);
|
||||
$att=explode(" ",$t);
|
||||
$fields_infos["_key_"][$keys]["name"]=$att[1];
|
||||
$att[2]=str_replace("(","",$att[2]);
|
||||
$att[2]=str_replace(")","",$att[2]);
|
||||
$fields_infos["_key_"][$keys]["columns"]=$att[2];
|
||||
$keys++;
|
||||
} elseif (substr($t,0,11)=="UNIQUE KEY ") {
|
||||
$t=str_replace("`","",$t);
|
||||
$att=explode(" ",$t);
|
||||
$fields_infos["_uniquekey_"][$ukeys]["name"]=$att[2];
|
||||
$att[3]=str_replace("(","",$att[3]);
|
||||
$att[3]=str_replace(")","",$att[3]);
|
||||
$fields_infos["_uniquekey_"][$ukeys]["columns"]=$att[3];
|
||||
$ukeys++;
|
||||
} elseif (substr($t,0,13)=="FULLTEXT KEY ") {
|
||||
$t=str_replace("`","",$t);
|
||||
$att=explode(" ",$t);
|
||||
$fields_infos["_fulltextkey_"][$fkeys]["name"]=$att[2];
|
||||
$att[3]=str_replace("(","",$att[3]);
|
||||
$att[3]=str_replace(")","",$att[3]);
|
||||
$fields_infos["_fulltextkey_"][$fkeys]["columns"]=$att[3];
|
||||
$fkeys++;
|
||||
} else {
|
||||
|
||||
$att=explode(" ",$t);
|
||||
|
||||
if(substr($att[0],0,1)=="`" && substr($att[0],-1)=="`") {
|
||||
$fields_infos[$flds]["name"]=str_replace("`","",$att[0]);
|
||||
$s=1;
|
||||
} else {
|
||||
$fields_infos[$flds]["name"]=str_replace("`","",$att[0])." ";
|
||||
for($ii=1;$i<count($att);$i++) {
|
||||
if(substr($att[$ii],-1)!="`") {
|
||||
$fields_infos[$flds]["name"].=$att[$ii];
|
||||
} else {
|
||||
$fields_infos[$flds]["name"].=str_replace("`","",$att[$ii]);
|
||||
$s=$ii+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fields_infos[$flds]["type"]=(strpos($att[$s],"(")) ? substr($att[$s],0,strpos($att[$s],"(")) : $att[$s];
|
||||
$fields_infos[$flds]["size"]=(strpos($att[$s],"(")) ? substr($att[$s],strpos($att[$s],"(")+1,strpos($att[$s],")")-strpos($att[$s],"(")-1) : "";
|
||||
$fields_infos[$flds]["default"]="";
|
||||
$fields_infos[$flds]["null"]="";
|
||||
$fields_infos[$flds]["extra"]="";
|
||||
$fields_infos[$flds]["atrribut"]="";
|
||||
$fields_infos[$flds]["collate"]="";
|
||||
$s++;
|
||||
while($s<count($att)) {
|
||||
if(isset($att[$s+1]) && strtolower($att[$s].$att[$s+1])=="unsignedzerofill") {
|
||||
$fields_infos[$flds]["extra"]="unsigned zerofill";
|
||||
$s+=2;
|
||||
} elseif(strtolower($att[$s])=="unsigned") {
|
||||
$fields_infos[$flds]["atrribut"]="unsigned";
|
||||
$s++;
|
||||
} elseif(isset($att[$s+1]) && strtolower($att[$s].$att[$s+1])=="notnull") {
|
||||
$fields_infos[$flds]["null"]="NOT NULL";
|
||||
$s+=2;
|
||||
} elseif(strtolower($att[$s])=="null") {
|
||||
$fields_infos[$flds]["null"]="NULL";
|
||||
$s++;
|
||||
} elseif(strtolower($att[$s])=="auto_increment") {
|
||||
$fields_infos[$flds]["extra"]="auto_increment";
|
||||
$s++;
|
||||
} elseif(strtolower($att[$s])=="collate") {
|
||||
$fields_infos[$flds]["collate"]=$att[$s+1];
|
||||
$s+=2;
|
||||
} elseif(strtolower($att[$s])=="character") {
|
||||
$fields_infos[$flds]["character set"]=$att[$s+2];
|
||||
$s+=3;
|
||||
} elseif(strtolower($att[$s])=="default") {
|
||||
//if(strpos(strtolower($fields_infos[$flds]["type"]),"text")===false && strtolower($fields_infos[$flds]["type"])!="varchar")
|
||||
$d="";$ii=$s+1;
|
||||
if(substr($att[$ii],0,1)=="'" && substr($att[$ii],-1)=="'") {
|
||||
$fields_infos[$flds]["default"]=$att[$ii];
|
||||
$s+=2;
|
||||
} else {
|
||||
if(substr($att[$ii],0,1)=="'") {
|
||||
$fields_infos[$flds]["default"]=$att[$ii]." ".$att[$ii+1];
|
||||
$s+=3;
|
||||
} else {
|
||||
$fields_infos[$flds]["default"]=$att[$ii];
|
||||
$s+=2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "not identified: $att[$s]<br>";
|
||||
$s++;
|
||||
}
|
||||
}
|
||||
|
||||
$flds++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
//echo substr($tmp[count($tmp)-1],2)."<br>";
|
||||
$ext=explode(" ",substr($tmp[count($tmp)-1],2));
|
||||
$s="";$haltchar="=";
|
||||
for($i=0;$i<count($ext);$i++) {
|
||||
if(!strpos($ext[$i],$haltchar)) {
|
||||
$s.=$ext[$i]." ";
|
||||
} else {
|
||||
if($haltchar=="'") {
|
||||
$fields_infos["_tableinfo_"]["COMMENT"]=$s.$ext[$i];
|
||||
$s="";$haltchar="=";
|
||||
} else {
|
||||
$s.=substr($ext[$i],0,strpos($ext[$i],$haltchar));
|
||||
if(strtoupper($s)=="COMMENT") {
|
||||
$s=substr($ext[$i],strpos($ext[$i],$haltchar)+1);
|
||||
if(substr($s,-1)=="'") {
|
||||
$fields_infos["_tableinfo_"]["COMMENT"]=$s;
|
||||
$s="";
|
||||
} else {
|
||||
$s.=" ";
|
||||
$haltchar="'";
|
||||
}
|
||||
} else {
|
||||
$fields_infos["_tableinfo_"][strtoupper($s)]=substr($ext[$i],strpos($ext[$i],$haltchar)+1);
|
||||
$s="";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fields_infos;
|
||||
}
|
||||
|
||||
function ChangeKeys($ok,$nk,$fld,$size)
|
||||
{
|
||||
if($ok[0]==$nk[0] && $ok[1]==$nk[1] && $ok[2]==$nk[2] && $ok[3]==$nk[3])
|
||||
return "";
|
||||
else {
|
||||
$s=""; //"$ok[0] | $ok[1] | $ok[2] | $ok[3] *** $nk[0] | $nk[1] |$nk[2] | $nk[3]<br>";
|
||||
|
||||
if($ok[0]==0 && $nk[0]==1) {
|
||||
$s.="ADD PRIMARY KEY (`$fld`), ";
|
||||
} elseif ($ok[0]==1 && $nk[0]==0) {
|
||||
$s.="DROP PRIMARY KEY, ";
|
||||
}
|
||||
if($ok[1]==0 && $nk[1]==1) {
|
||||
$s.="ADD UNIQUE INDEX `$fld` (`$fld`), ";
|
||||
} elseif ($ok[1]==1 && $nk[1]==0) {
|
||||
$s.="DROP INDEX `$fld`, ";
|
||||
}
|
||||
if($ok[2]==0 && $nk[2]==1) {
|
||||
$s.="ADD INDEX `$fld` (`$fld`), ";
|
||||
} elseif ($ok[2]==1 && $nk[2]==0) {
|
||||
$s.="DROP INDEX `$fld`, ";
|
||||
}
|
||||
if($ok[3]==0 && $nk[3]==1) {
|
||||
$s.="ADD FULLTEXT INDEX `$fld` (`$fld`($size)), ";
|
||||
} elseif ($ok[3]==1 && $nk[3]==0) {
|
||||
$s.="DROP FULLTEXT INDEX `$fld`, ";
|
||||
}
|
||||
}
|
||||
if($s!="") $s=substr($s,0,strlen($s)-2);
|
||||
return $s;
|
||||
}
|
||||
?>
|
||||
23
inc/header.php
Normale Datei
23
inc/header.php
Normale Datei
|
|
@ -0,0 +1,23 @@
|
|||
<html>
|
||||
<head>
|
||||
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
|
||||
<meta name="robots" content="none">
|
||||
<meta name="robots" content="noindex">
|
||||
<title>MySqlDumper</title>
|
||||
<link rel="stylesheet" type="text/css" href="styles.css">
|
||||
<script language="JavaScript" src="script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
include_once("inc/functions.php");
|
||||
include_once("inc/mysql.php");
|
||||
|
||||
if(!file_exists($config["files"]["parameter"])) TestWorkDir();
|
||||
include($config["files"]["parameter"]);
|
||||
if(!isset($config["language"]) && ($config["language"]!="de" && $config["language"] !="en")) $config["language"]="de";
|
||||
include_once("language/lang_".$config["language"].".php");
|
||||
SelectDB($databases["db_selected_index"]);
|
||||
|
||||
|
||||
?>
|
||||
83
inc/mysql.php
Normale Datei
83
inc/mysql.php
Normale Datei
|
|
@ -0,0 +1,83 @@
|
|||
<?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();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
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></td></tr>
|
||||
<tr><td style="width:80%;overflow: auto;">'.$lang['sql_error1'].'<br><br><pre>'.highlight_sql($sql).'</pre></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;
|
||||
$tmp="/".implode("/ /",$sql_keywords)."/";
|
||||
$tmp_array=explode(" ",$tmp);
|
||||
$tmp="<span style=\"color:#990099;font-weight:bold;\">".implode("</span>###<span style=\"color:#990099;font-weight:bold;\">",$sql_keywords)."</span>";
|
||||
$tmp_replace=explode("###",$tmp);
|
||||
|
||||
$sql=nl2br(htmlentities($sql));
|
||||
$sql=preg_replace("/`(.*?)`/si", "<span style=\"color:red;\">`$1`</span>", $sql);
|
||||
str_replace("{","{<ul>",$sql);
|
||||
str_replace("}","}</ul>",$sql);
|
||||
str_replace("*","<span style=\"color:red;\">*</span>",$sql);
|
||||
$sql=preg_replace($tmp_array, $tmp_replace, $sql);
|
||||
|
||||
return $sql;
|
||||
}
|
||||
?>
|
||||
65
inc/runtime.php
Normale Datei
65
inc/runtime.php
Normale Datei
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
|
||||
//error_reporting(E_ALL);
|
||||
error_reporting(E_ERROR);
|
||||
|
||||
|
||||
//feste Variabeln
|
||||
$config["version"]="1.14 Beta 3";
|
||||
|
||||
|
||||
|
||||
//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["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());
|
||||
|
||||
//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]<4);
|
||||
$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)));
|
||||
//echo '<pre>'.print_r($p3,true).'</pre>';
|
||||
//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/";
|
||||
$nl="\n";
|
||||
|
||||
//Initialisierungen
|
||||
|
||||
|
||||
//SQL-Library
|
||||
$sqllib["board_deacticate"]="UPDATE `phpbb_config` set config_value=1 where config_name=\"board_disable\"";
|
||||
$sqllib["board_acticate"]="UPDATE `phpbb_config` set config_value=0 where config_name=\"board_disable\"";
|
||||
|
||||
|
||||
|
||||
?>
|
||||
71
inc/tabellenabfrage.php
Normale Datei
71
inc/tabellenabfrage.php
Normale Datei
|
|
@ -0,0 +1,71 @@
|
|||
<?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);
|
||||
|
||||
$tbl_zeile.='<tr><td class="sm"><input type="checkbox" name="chk_tbl" value="'.$row["Name"].'">'.$row["Name"].'</td>';
|
||||
$tbl_zeile.='<td class="sm"><strong>'.$row["Rows"].'</strong> '.$lang['datawith'].' <strong>'.byte_output($row["Data_length"]+$row["Index_length"]).'</strong>, '.$lang['lastbufrom'].' <span class="Blau">'.$row["Update_time"].'</span></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><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><td class="sm"><input type="checkbox" name="chk_tbl" value="'.$s[1].'">'.$s[1].'</td>';
|
||||
$tbl_zeile.='<td class="sm"><strong>'.$s[2].'</strong> '.$lang['datawith'].' <strong>'.byte_output($s[3]).'</strong>, '.$lang['lastbufrom'].' <span class="Blau">'.$s[4].'</span></td></tr>';
|
||||
}
|
||||
if($gz) gzclose ($fp); else fclose ($fp);
|
||||
}
|
||||
}
|
||||
echo '<h3>'.$tblr.' - '.$lang['tableselection'].'</h3><h6>'.$lang['db'].': '.$databases["db_actual"].'</h6><div align="center">';
|
||||
echo '<form name="frm_tbl" action="filemanagement.php" method="post" onSubmit="return chkFormular()"><table width="90%" border="1">';
|
||||
echo '<tr><td colspan="2" class="hd"> <input type="Button" class="Formbutton2" onclick="Sel(true);" value="'.$lang['deselectall'].'"> <input type="Button" class="Formbutton2" onclick="Sel(false);" value="'.$lang['selectall'].'">';
|
||||
echo '<img src="images/blank.gif" alt="" width="80" height="1" border="0"><input type="submit" class="Formbutton" style="width:180px;" name="'.$button_name.'" value="'.$button_caption.'"></td></tr>';
|
||||
echo $tbl_zeile;
|
||||
echo '</table><input type="hidden" name="tbl_array" value=""><input type="hidden" name="filename" value="'.$filename.'"></form></div>';
|
||||
|
||||
|
||||
?>
|
||||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren