include("inc/header.php");
require_once("inc/functions_restore.php");
echo MSDHeader();
if($config["magic_quotes_gpc"]) {
foreach($_POST as $postvar => $postval){ ${$postvar} = stripslashes($postval); }
foreach($_GET as $getvar => $getval){ ${$getvar} = stripslashes($getval); }
} else {
foreach($_POST as $postvar => $postval){ ${$postvar} = $postval; }
foreach($_GET as $getvar => $getval){ ${$getvar} = $getval; }
}
if((isset($rows) && $rows<5) || !isset($rows)) $rows=5;
if((isset($fontsize) && $fontsize<9) || !isset($fontsize)) $fontsize=9;
if(!isset($destfile)) $destfile="";
if(!isset($selectfile)) $selectfile="";
if(!isset($compressed)) $compressed=0;
if(!isset($debugoutput)) $debugoutput=0;
if(!isset($insert)) $insert="";
if(!isset($create)) $create="";
if(!isset($exp)) $exp=0;
echo headline("Entwicklung - Tests, Konverter, ...");
// Konverter
echo '
Konverter
';
echo '
';
if(isset($startconvert)) {
$destfile.=($compressed==1) ? ".sql.gz" : ".sql";
echo "Konvertierung $selectfile ==> $destfile
";
if(file_exists($config["paths"]["backup"].$selectfile) && strlen($destfile)>7) {
Converter($selectfile,$destfile,$compressed);
}
else echo "falsche Parameter ! Konvertierung ist nicht möglich.";
}
// Parser-Test
echo 'Parser-Test
';
echo '
';
if(isset($startparse)) {
$restore["erweiterte_inserts"]=0;
echo '';
if($debugoutput==1) echo 'DEBUG-Ausgabe "Create"-parsing
';
$AnzahlFelder=AnzahlTabellenfelder($create,$debugoutput);
if($debugoutput==1) echo 'DEBUG-Ausgabe "Insert"-parsing
';
$AnzahlParser=SQL_Is_Complete($insert,$exp,$debugoutput);
echo "
Create-Anweisung: $AnzahlFelder Felder, Insert-Anweisung: $AnzahlParser Felder
";
}
// Testwiese
echo 'Testwiese
';
include("inc/functions_restore.php");
MSD_mysql_connect();
$c="CREATE TABLE `changelog` ( `id` int(11) NOT NULL auto_increment, `datum` date NOT NULL default '0000-00-00', `beschreibung` text collate latin1_general_ci NOT NULL, `autor` varchar(50) collate latin1_general_ci NOT NULL default '', `version` varchar(8) collate latin1_general_ci default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci";
echo "CREATE:
$c
";
echo "
UMWANDLUNG:
".ConvertCreate($c)."
";
echo '
';
include("inc/footer.php");
////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////// Funktionen ////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
function FilelisteCombo($fpath,$selected) {
$r='';
return $r;
}
function Converter1($filesource,$filedestination,$cp)
{
global $config;
$insert= substr($f[0],0,strpos($f[0],"("));
for($i=0;$iDatei '$filesource' wird eingelesen.....";
if(file_exists($config["paths"]["backup"].$filedestination)) unlink($config["paths"]["backup"].$filedestination);
$f = ($cps==1) ? gzopen($config["paths"]["backup"].$filesource,"r") : fopen($config["paths"]["backup"].$filesource,"r");
$z= ($cps==1) ? gzopen($config["paths"]["backup"].$filedestination,"w") : fopen($config["paths"]["backup"].$filedestination,"w");
$insert=$mode="";
$n=0;
$eof= ($cps==1) ? gzeof($f) : feof($f);
WHILE (!$eof)
{
$eof= ($cps==1) ? gzeof($f) : feof($f);
$zeile= ($cps==1) ? gzgets($f,8192) : fgets($f,8192);
if (substr($zeile,0,2)=="--") $zeile="";
//$zeile=rtrim($zeile);
$t=strtolower(substr($zeile,0,10));
if ($t>"")
{
switch ($t)
{
case "insert int":
{
// eine neue Insert Anweisung beginnt
$insert= substr($zeile,0,strpos($zeile,"("));
if(substr(strtoupper($insert),-7)!="VALUES ") $insert.="VALUES ";
$mode="insert";
};
break;
case "create tab":
{
$mode="create";
WHILE (substr(rtrim($zeile),-1)!=";")
{
$zeile.=fgets($f,8192);
}
break;
}
case "drop table":
{
$mode="drop";
$zeile.="\n";
break;
}
}
if ($mode=="insert")
{
// Komma loeschen
$zeile=str_replace("),(",");\n$insert (",$zeile);
if(substr(rtrim($zeile),0,2)==",(" && $insert !="") {
$zeile=";\n".$insert.substr($zeile,1);
}
if(substr(rtrim($zeile),-2)==")," && $insert !="") {
$zeile=substr(rtrim($zeile),0,strlen(rtrim($zeile))-1).";\n$insert";
}
}
$n++;
if ($n>1000) { $n=0;echo "
"; }
echo ".";
if($cps==1) gzwrite($z,$zeile); else fwrite($z,$zeile);
}
flush();
$n++;
}
if($cps==1) gzclose($z); else fclose($z);
if($cps==1) gzclose($f); else fclose($f);
echo "Konvertierung abgeschlossen, '$filedestination' wurde erzeugt.
";
}
function ReadStatus($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);
}
return $s;
}
?>