Fix type error

This commit is contained in:
Joshua Ramon Enslin 2022-03-15 10:29:19 +01:00
parent b0bdf698ab
commit 0ba9a3b1ec
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
3 changed files with 15 additions and 9 deletions

View File

@ -12,7 +12,7 @@ if (session_status() != PHP_SESSION_ACTIVE) {
}
// This array contains all available languages
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl','pt'];
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl', 'pt'];
// Some languages are in translation. They will only be available for logged in users.

View File

@ -14,7 +14,7 @@ if (session_status() != PHP_SESSION_ACTIVE) {
}
// This array contains all available languages
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl','pt'];
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl', 'pt'];
// Some languages are in translation. They will only be available for logged in users.

View File

@ -7,7 +7,7 @@ if (session_status() != PHP_SESSION_ACTIVE) {
}
// This array contains all available languages
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl','pt'];
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl', 'pt'];
// Some languages are in translation. They will only be available for logged in users.
@ -33,7 +33,7 @@ if (!($fp = fopen($csv_datei, 'r'))) {
throw new MDmainEntityNotExistentException("Failed opening file");
}
$y = 0;
while ($zeile = fgetcsv($fp, 100000, ';')) {
while ($zeile = fgetcsv($fp, 100000, ';', "\"")) {
$zeile = str_replace("\xEF\xBB\xBF", '', $zeile);
@ -41,7 +41,8 @@ while ($zeile = fgetcsv($fp, 100000, ';')) {
$zieldatei = __DIR__ . '/../xml/' . $y . '.xml';
if (!$handle = fopen($zieldatei, 'w')) {
echo "Cannot open file ($zieldatei)";exit;
echo "Cannot open file ($zieldatei)";
exit;
}
$xmlDoc = new DOMDocument("1.0", "UTF-8");
@ -52,13 +53,17 @@ while ($zeile = fgetcsv($fp, 100000, ';')) {
$record_node = $xmlDoc->appendChild($xmlMainElem); //add record element to XML node
# $rss_node->setAttribute("version", "2.0"); //set RSS version
$lineCount = count($zeile);
if (empty($lineCount)) $lineCount = count($zeile);
for ($x = 0; $x < $lineCount; $x++) {
$inhalt[$y][$x] = $zeile[$x];
if ($inhalt[$y][$x] == '') $inhalt[$y][$x] = 'ERSATZ';
$record_node->appendChild(createTextDomElement($xmlDoc, trim($inhalt[1][$x]), trim($inhalt[$y][$x])));
if (!isset($inhalt[1][$x])) {
echo "Error at position $x";
}
$record_node->appendChild(createTextDomElement($xmlDoc, trim($inhalt[1][$x] ?? ""), trim($inhalt[$y][$x] ?? "")));
}
@ -67,8 +72,9 @@ while ($zeile = fgetcsv($fp, 100000, ';')) {
# $somecontent .= '</record>';
//if ($y>1)
//{
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";exit;
if (fwrite($handle, $somecontent) === false) {
echo "Cannot write to file ($filename)";
exit;
}
fclose($handle);