Or you might try changing this block:
Code: Select all
if ($what == "dataonly" OR $what == "data") {
$insert_text .= "##\n";
$insert_text .= "## INSERT-data von Tabelle ".$table."\n";
$insert_text .= "##\n";
$R2 = serendipity_db_query("SELECT * FROM ".$table."");
unset($THIS);
if (is_array($R2) && count($R2) >= 1) {
foreach ($R2 AS $THIS) {
$insert_text .= "INSERT INTO ".$table." (";
@reset ($THIS);
unset($key);
unset($val);
$insert_text1 = '';
$insert_text2 = '';
foreach ($THIS as $key => $val) {
if (!intval($key) AND $key != "0") {
$insert_text1 .= "".$key.",";
$insert_text2 .= "'".addslashes($val)."',";
}
}
$insert_text1 = substr($insert_text1, 0, (strlen($insert_text1)-1));
$insert_text2 = substr($insert_text2, 0, (strlen($insert_text2)-1));
$insert_text .= $insert_text1.") VALUES (".$insert_text2.");\n";
}
}
}
if ($create_text != "") {
$create_text = $sqltext.$create_text;
if ($TXT=fopen($dateidir.$filetime."_CREATE_".$dateiname, "w")) {
fputs($TXT,$create_text);
fclose($TXT);
chmod($dateidir.$filetime."_CREATE_".$dateiname, 0666);
}
}
if ($insert_text != "") {
$insert_text = $sqltext.$insert_text;
if ($TXT=fopen($dateidir.$filetime."_INSERT_".$dateiname, "w")) {
fputs($TXT,$insert_text);
fclose($TXT);
chmod($dateidir.$filetime."_INSERT_".$dateiname, 0666);
}
}
To something like this (which is
entirely untested and may not work at all):
Code: Select all
if ($what == "dataonly" OR $what == "data") {
$insert_text .= "##\n";
$insert_text .= "## INSERT-data von Tabelle ".$table."\n";
$insert_text .= "##\n";
$R2 = serendipity_db_query("SELECT * FROM ".$table."");
unset($THIS);
if (is_array($R2) && count($R2) >= 1) {
if ($TXT=fopen($dateidir.$filetime."_INSERT_".$dateiname, "w")) {
fputs($TXT,$sqltext);
foreach ($R2 AS $THIS) {
$insert_text = "INSERT INTO ".$table." (";
@reset ($THIS);
unset($key);
unset($val);
$insert_text1 = '';
$insert_text2 = '';
foreach ($THIS as $key => $val) {
if (!intval($key) AND $key != "0") {
$insert_text1 .= "".$key.",";
$insert_text2 .= "'".addslashes($val)."',";
}
}
$insert_text1 = substr($insert_text1, 0, (strlen($insert_text1)-1));
$insert_text2 = substr($insert_text2, 0, (strlen($insert_text2)-1));
$insert_text .= $insert_text1.") VALUES (".$insert_text2.");\n";
fputs($TXT,$insert_text);
}
fclose($TXT);
chmod($dateidir.$filetime."_INSERT_".$dateiname, 0666);
}
}
}
if ($create_text != "") {
$create_text = $sqltext.$create_text;
if ($TXT=fopen($dateidir.$filetime."_CREATE_".$dateiname, "w")) {
fputs($TXT,$create_text);
fclose($TXT);
chmod($dateidir.$filetime."_CREATE_".$dateiname, 0666);
}
}
I am assuming that the problem is that the variable $insert_text is growing too large... The new code writes the file as it processes... Mind you, PHP might just keep the whole file in memory, so you would still have the same problem...
Plus, my code may not even be correctly formed, so you might have to troubleshoot missing semicolons and stuff...
EDIT: oh, and I don't have any idea of what the output will look like, so you will need to make sure the files can actually be imported (if it works at all)