Add checks for accessibility of queried file names
This commit is contained in:
34
index4.php
34
index4.php
@ -24,13 +24,20 @@ else if (!isset($_SESSION['lang'])) {
|
||||
$lang = $_SESSION['lang'];
|
||||
|
||||
require __DIR__ . "/translation-importer/$lang/csvxml-overview.php";
|
||||
require __DIR__ . '/inc/zeichen.php';
|
||||
|
||||
require 'inc/zeichen.php';
|
||||
$filename = $_GET['fnam'];
|
||||
$csv_datei = 'csv/' . $filename;
|
||||
if (empty($filename = trim($_GET['fnam'], " ,./"))) {
|
||||
echo "Error: Invalid file name";
|
||||
exit;
|
||||
}
|
||||
$csv_datei = __DIR__ . '/csv/' . $filename;
|
||||
if (!file_exists($csv_datei)) {
|
||||
echo "Error: The CSV file does not exist.";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (is_dir(__DIR__ . "/xml")) rrmdir(__DIR__ . '/xml');
|
||||
mkdir("xml", 0755);
|
||||
mkdir(__DIR__ . "/xml", 0755);
|
||||
|
||||
$fp = fopen ($csv_datei, 'r');
|
||||
$y = 0;
|
||||
@ -42,18 +49,20 @@ while ($zeile = fgetcsv($fp, 100000, ';')) {
|
||||
echo "Cannot open file ($zieldatei)";exit;
|
||||
}
|
||||
$somecontent = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; // für Ungarn ///////////////////////////////////
|
||||
$somecontent = $somecontent . '<record>' . "\n";
|
||||
$somecontent .= '<record>' . "\n";
|
||||
|
||||
$lineCount = count($zeile);
|
||||
for ($x = 0; $x < $lineCount; $x++) {
|
||||
|
||||
for ($x = 0; $x < count ( $zeile ); $x++)
|
||||
{
|
||||
$inhalt[$y][$x] = $zeile[$x];
|
||||
$inhalt[$y][$x] = preg_replace('/[\x00-\x1F\x7F]/u', '', $inhalt[$y][$x]);
|
||||
$inhalt[$y][$x] = str_replace('>', ']', str_replace('<', '[', $inhalt[$y][$x]));
|
||||
if (empty($inhalt[$y][$x])) continue;
|
||||
//if ($y!=1) $inhalt[$y][$x] = '<![CDATA['.$inhalt[$y][$x].']]>';
|
||||
$somecontent = $somecontent . '<' . tagify(transform($inhalt[1][$x])) . '>' . (($inhalt[$y][$x])) . '</' . tagify(transform($inhalt[1][$x])) . '>' . "\n"; //für ungarn sonst weg }
|
||||
|
||||
}
|
||||
$somecontent = $somecontent . '</record>';
|
||||
$somecontent .= '</record>';
|
||||
if (fwrite($handle, $somecontent) === FALSE) {
|
||||
echo "Cannot write to file ($filename)";exit;
|
||||
}
|
||||
@ -66,13 +75,10 @@ echo printHTMLHead();
|
||||
|
||||
echo '
|
||||
<div>
|
||||
Please wait ... (transforming)
|
||||
<hr />
|
||||
|
||||
' . ($y - 1) . ' files created
|
||||
<br/>
|
||||
<a href="zipit.php"><img src="img/go.gif"> Download as zip</a>
|
||||
|
||||
<hr/>
|
||||
<a href="zipit.php" class="buttonLike">Download as zip</a>
|
||||
|
||||
</div>';
|
||||
|
||||
echo '
|
||||
|
Reference in New Issue
Block a user