Clean up outdated scripts

See #16
This commit is contained in:
Joshua Ramon Enslin 2022-11-07 00:31:57 +01:00
parent 82f01a0961
commit 85ea427242
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
13 changed files with 52 additions and 1165 deletions

17
TODO.md
View File

@ -1,17 +0,0 @@
# Project: Rewrite CSVXML with Rust
## Step 1: Rewriting classes/CsvxmlAvailableFields.php
- New class for fieldentries
- use tlloader: $eventname[1] -> $tlLoader->tl("eventtype-name", "eventname", "1")
- __toArray(){}
## Step 2: Rewrite Validationprocess in index3.php
### FFI with Rust
- https://www.php.net/manual/en/class.ffi.php
- https://www.php.net/manual/en/ffi.examples-basic.php
- https://platform.sh/blog/2020/php-fun-with-ffi-getting-rust-ic/
## Step 3: Remove fnam Parameter

View File

@ -1,54 +0,0 @@
<?PHP
/**
* Contains a helper class for validation errors.
*
* @author Nathan Eikermann <nathan@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Class holding the information about various errors
* that can occur during validation
*/
final class CSVXMLValidator {
public array $error_msgs;
public array $inv_errors;
public array $depcon_errors;
public function addError(String $error)
{
$this->error_msgs[] = $error;
}
public function addInvError(String $error)
{
$this->inv_errors[] = $error;
}
public function addDepconError(String $error)
{
$this->depcon_errors[] = $error;
}
public function overallErrorCount(): int
{
return count($this->error_msgs)
+ count($this->inv_errors)
+ count($this->depcon_errors);
}
/**
* Constructor
*/
public function __construct()
{
$this->error_msgs = [];
$this->inv_errors = [];
$this->depcon_errors = [];
}
}

View File

@ -9,11 +9,11 @@
declare(strict_types = 1); declare(strict_types = 1);
// Set autoloader // Set autoloader
# \error_reporting(E_ALL); \error_reporting(E_ALL);
# \ini_set('display_errors', "1"); \ini_set('display_errors', "1");
\spl_autoload_register("mdCsvxmlAutoloader"); \spl_autoload_register("mdCsvxmlAutoloader");
\set_exception_handler("mdExceptionHandler"); # \set_exception_handler("mdExceptionHandler");
\set_error_handler("mdErrorHandler", E_ALL); # \set_error_handler("mdErrorHandler", E_ALL);
require_once __DIR__ . '/../inc/constants.php'; require_once __DIR__ . '/../inc/constants.php';
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../vendor/autoload.php';
@ -177,165 +177,3 @@ function mdExceptionHandler(Throwable $exception):void {
} }
} }
/**
* Function for generating the HTML head.
*
* @param string $injected Additional code to inject into the head, e.g. a
* reference to JS files.
*
* @return string
*/
function printHTMLHead(string $injected = ""):string {
$output = '<!DOCTYPE HTML>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Validate import CSV files for museum-digital" />
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css" />
<meta name="theme-color" content="#aa4400" />
<link rel="shortcut icon" sizes="128x128" href="assets/img/mdlogo-csvxml.svg" />
<script src="assets/js/csvxml-overview.min.js" type="text/javascript" defer></script>
<meta name="robots" content="noindex" />
<title>CSVXML :: museum-digital</title>
<meta name="keywords" content="Imports, museum-digital" />
';
$output .= $injected;
$output .= '
</head>
<body>
<h1>
<img src="assets/img/mdlogo-csvxml.svg" alt="" />
<span>museum-digital:csvxml</span>
</h1>
';
return $output;
}
/**
* Function generateHelpTooltip returns a tooltip for hovering over using the common settings.
*
* @param string $identifier ID attribute of the tooltip.
* @param string $title Title of the tooltip.
* @param string $explica More in-depth explanation: body of the tooltip.
* @param boolean $setParagraph If set to true (default), the content of the tooltip will be put into a <p> element. Optional.
*
* @return array
*/
function generateHelpTooltip(string $identifier, string $title, string $explica, bool $setParagraph = true):array {
$outputTag = '<a class="newToolTipTag icons iconsHelp" data-for="' . $identifier . '" title="Help"></a>';
$output = '<span class="newToolTip" id="tooltip_' . $identifier . '" data-title="' . $title . '">';
if ($setParagraph) $output .= '<p class="toolTipCont">';
$output .= $explica;
if ($setParagraph) $output .= '</p>';
$output .= '</span>';
return [$output, $outputTag];
}
/**
* Outputs a DOMDocument with correct header and then aborts.
* Used mainly for debugging.
*
* @param DOMDocument $xmlDoc XML object.
*
* @return string
*/
function printDOMDocToXML(DOMDocument $xmlDoc):string {
return '<?xml version="1.0" encoding="UTF-8"?>' . $xmlDoc->saveXML($xmlDoc->documentElement);
}
/**
* Function for creating a DOMElement with a text node inside.
*
* @param DOMDocument $xmlDoc XML document.
* @param string $tag Tag.
* @param string $content Text content.
*
* @return DOMElement
*/
function createTextDomElement(DOMDocument $xmlDoc, string $tag, string $content):DOMElement {
try {
$element = $xmlDoc->createElement($tag);
}
catch (DOMException $e) {
echo "Error at " . __FILE__ . ", line #" . __LINE__ . PHP_EOL . "<br/>";
echo "Cannot create DOM element for $tag / $content";
exit;
}
$element->appendChild($xmlDoc->createTextNode($content));
return $element;
}
/**
* Function for creating a DOMDocument record channel.
*
* @return array
*/
function getBlankRecordChannel():array {
$xmlDoc = new DOMDocument("1.0", "UTF-8");
$xmlMainElem = $xmlDoc->createElement("record");
$record_node = $xmlDoc->appendChild($xmlMainElem); //add RSS element to XML node
return [$xmlDoc, $record_node];
}
/**
* Function for removing a directory with all its contents.
*
* @param string $dir File path of the directory to remove.
*
* @return void
*/
function rrmdir(string $dir):void {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir . "/" . $object) == "dir") rrmdir($dir . "/" . $object);
else unlink($dir . "/" . $object);
}
}
reset($objects);
rmdir($dir);
}
}
/**
* Function for checking if two arrays have identical values / contents.
*
* @param array $arrayA First array to compare.
* @param array $arrayB Second array to compare.
*
* @return boolean
*/
function identical_values(array $arrayA, array $arrayB):bool {
sort($arrayA);
sort($arrayB);
return $arrayA == $arrayB;
}

View File

@ -1,6 +0,0 @@
(function() {
let csvBySelectionButton = document.getElementById("csvBySelection");
let unsetSelectionButton = document.getElementById("unsetSelection");
})();

View File

@ -1,5 +0,0 @@
(function(){let csvBySelectionButton=document.getElementById("csvBySelection");let unsetSelectionButton=document.getElementById("unsetSelection");function checkCSVBySelectionAccessibility(){let selected=document.getElementsByClassName("humanTLToggled");if(selected.length===0){csvBySelectionButton.classList.add("invisible");unsetSelection.classList.add("invisible")}else{csvBySelectionButton.classList.remove("invisible");unsetSelection.classList.remove("invisible")}}
function doForFieldList(callback){let fieldLists=document.getElementsByClassName("fieldList");for(let i=0,max=fieldLists.length;i<max;i++){let fields=fieldLists[i].getElementsByTagName("li");for(let j=0,maxj=fields.length;j<maxj;j++){callback(fields[j])}}}
function toggleListFieldSelectionState(field){let newValue=field.getAttribute("data-alt");field.setAttribute("data-alt",field.textContent);field.textContent=newValue;field.classList.toggle("humanTLToggled");if(field.classList.contains("humanTLToggled")===!1)return;let dependencies=field.getAttribute("data-dependencies");if(dependencies!==undefined&&dependencies!==null){let linkedFields=dependencies.split(";");for(let i=0,max=linkedFields.length;i<max;i++){let linkedField=document.getElementById(linkedFields[i]);if(linkedField.classList.contains("humanTLToggled")===!0)continue;toggleListFieldSelectionState(linkedField)}}}
doForFieldList(function(field){field.addEventListener('click',function(e){toggleListFieldSelectionState(field);checkCSVBySelectionAccessibility()})});csvBySelectionButton.addEventListener('click',function(e){let selectionForm=document.createElement("form");selectionForm.method="POST";selectionForm.action="csv.php";let hiddenInput=document.createElement("input");hiddenInput.type="hidden";hiddenInput.name="selectedFields";hiddenInput.value="";let selected=document.getElementsByClassName("humanTLToggled");for(let i=0,max=selected.length;i<max;i++){hiddenInput.value+=selected[i].getAttribute("data-value")+","}
selectionForm.appendChild(hiddenInput);document.documentElement.appendChild(selectionForm);selectionForm.submit()});let selectRequired=document.getElementById("selectRequired");selectRequired.addEventListener('click',function(e){doForFieldList(function(field){if(field.classList.contains("requiredField")===!1)return;if(field.classList.contains("humanTLToggled")===!0)return;toggleListFieldSelectionState(field);checkCSVBySelectionAccessibility()})});let selectAll=document.getElementById("selectAll");selectAll.addEventListener('click',function(e){doForFieldList(function(field){if(field.classList.contains("humanTLToggled")===!0)return;toggleListFieldSelectionState(field);checkCSVBySelectionAccessibility()})});unsetSelectionButton.addEventListener('click',function(e){doForFieldList(function(field){if(field.classList.contains("humanTLToggled")===!1)return;toggleListFieldSelectionState(field);checkCSVBySelectionAccessibility()})})})()

View File

@ -1,73 +0,0 @@
/**
* A simple implementation of a tooltip.
*
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
*/
function generateToolTips() {
/**
* Function for setting the alignment of an element.
*
* @param {Event} e Event triggering the execution of this function.
* @param {DOMElement} elem Dom element to position.
*
* @return {void}
*/
function getDirection(e, elem) {
if (window.innerHeight < e.clientY + elem.clientHeight) {
elem.style.top = "";
elem.style.bottom = (window.innerHeight - e.clientY) + "px";
}
else {
elem.style.bottom = "";
elem.style.top = (e.clientY + 2) + "px";
}
if (window.innerWidth < e.clientX + elem.clientWidth) {
elem.style.left = "";
elem.style.right = (window.innerWidth - e.clientX) + "px";
} else {
elem.style.right = "";
elem.style.left = (e.clientX + 2) + "px";
}
}
let triggers = document.getElementsByClassName("newToolTipTag");
for (let i = 0, max = triggers.length; i < max; i++) {
let trigger = triggers[i];
let dataTarget = trigger.getAttribute("data-for");
let target = document.getElementById("tooltip_" + dataTarget);
trigger.addEventListener("mouseover", function(e) {
let newMain = document.getElementById("newToolTipMain");
if (newMain !== null) return;
newMain = target.cloneNode(true);
newMain.id = "newToolTipMain";
document.getElementsByTagName("body")[0].appendChild(newMain);
newMain.classList.add("visible");
getDirection(e, newMain);
});
trigger.addEventListener("mousemove", function(e) {
let newMain = document.getElementById("newToolTipMain");
getDirection(e, newMain);
});
trigger.addEventListener("mouseout", function(e) {
let newMain = document.getElementById("newToolTipMain");
if (newMain.classList.contains("sticked")) return;
newMain.classList.remove("visible");
document.getElementsByTagName("body")[0].removeChild(newMain);
});
/*
trigger.addEventListener("click", function(e) {
document.getElementById("newToolTipMain").classList.toggle("sticked");
});
*/
}
}
generateToolTips();

View File

@ -1,83 +0,0 @@
<?PHP
/**
* Generates a CSV template based on the field list provided for CSVXML.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
require_once __DIR__ . "/../functions/functions.php";
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}
// This array contains all available languages
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl', 'pt'];
// Some languages are in translation. They will only be available for logged in users.
if (isset($_GET['navlang'])) {
$_SESSION['lang'] = $_GET['navlang'];
if (!in_array($_SESSION['lang'], $allowed_langs)) $_SESSION['lang'] = 'de';
}
else if (!isset($_SESSION['lang'])) {
$_SESSION['lang'] = MD_STD::lang_getfrombrowser($allowed_langs, 'en', "", false);
}
$lang = $_SESSION['lang'];
if (!empty($_POST) and !empty($_POST['selectedFields'])) {
$selectionActive = true;
$selectedFields = explode(",", trim($_POST['selectedFields'], ","));
}
else {
$selectionActive = false;
$selectedFields = [];
}
$fieldsGetter = new CsvxmlAvailableFields($lang);
$availableFields = $fieldsGetter->getFields();
$line1 = $line2 = $line3 = $line4 = [];
foreach ($availableFields as $headline => $fields) {
$i = 0;
$tLine1 = $tLine2 = $tLine3 = $tLine4 = [];
$tLine1[] = $headline;
foreach($fields as $fieldName => $field) {
if ($selectionActive === true and !in_array($fieldName, $selectedFields)) {
continue;
}
if ($i !== 0) $tLine1[] = "";
$tLine2[] = $fieldName;
$tLine3[] = $field->name_human_readable;
# $tLine4[] = $field->remark;
if (!empty($field->allowedValues)) $tLine4[] = end($field->allowedValues);
else $tLine4[] = $field->name_human_readable;
$i++;
}
if (empty($tLine2) or count($tLine2) === 0) continue;
for ($i = 1; $i <= 4; $i++) {
${"line$i"} = array_merge(${"line$i"}, ${"tLine$i"});
}
}
header('Content-Type: text/csv; charset=utf-8');
if ($selectionActive === true) {
header("Content-Disposition: attachment; filename=csvxml_museum-digital_template-{$lang}_selection.csv");
}
else {
header("Content-Disposition: attachment; filename=csvxml_museum-digital_template-{$lang}.csv");
}
for ($i = 2; $i <= 4; $i++) {
echo '"' . implode("\";\"", ${"line$i"}) . '"' . PHP_EOL;
# echo mb_convert_encoding('"' . implode("\";\"", ${"line$i"}) . '"' . PHP_EOL, 'utf-16', 'utf-8');
}

View File

@ -9,32 +9,17 @@
declare(strict_types = 1); declare(strict_types = 1);
require_once __DIR__ . "/../functions/functions.php"; require_once __DIR__ . "/../functions/functions.php";
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}
// 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'];
$lang = MD_STD::get_user_lang($allowed_langs, "en");
// Some languages are in translation. They will only be available for logged in users. $tlLoader = new MDTlLoader("csxml_start_v2", $lang);
if (isset($_GET['navlang'])) {
$_SESSION['lang'] = $_GET['navlang'];
if (!in_array($_SESSION['lang'], $allowed_langs)) $_SESSION['lang'] = 'de';
}
else if (!isset($_SESSION['lang'])) {
$_SESSION['lang'] = MD_STD::lang_getfrombrowser($allowed_langs, 'en', "", false);
}
$lang = $_SESSION['lang'];
$outFormat = MD_STD_IN::get_http_input_text("output", "html", ['html', 'json']); $outFormat = MD_STD_IN::get_http_input_text("output", "html", ['html', 'json']);
$tlLoader = new MDTlLoader("csxml_start", $lang); if ($outFormat === 'json') {
$fieldsGetter = new CsvxmlAvailableFields($lang); $fieldsGetter = new CsvxmlAvailableFields($lang);
$availableFields = $fieldsGetter->getFields(); $availableFields = $fieldsGetter->getFields();
if ($outFormat === 'json') {
header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); // HTTP/1.1 header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0 header('Pragma: no-cache'); // HTTP/1.0
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *");
@ -46,78 +31,57 @@ if ($outFormat === 'json') {
return; return;
} }
$toInject = '
<script src="assets/js/newToolTip.js" type="text/javascript" defer></script>
';
echo printHTMLHead($toInject);
echo ' echo '
<!DOCTYPE HTML>
<html lang="en">
<head>
<div class="uploader"> <meta name="viewport" content="width=device-width, initial-scale=1" />
<form enctype="multipart/form-data" action="upload.php" method="POST"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<input type="hidden" id="csrf-token" name="csrf-token" aria-label="Anti-CSRF Token" value="' . htmlspecialchars(MD_STD_SEC::getAntiCsrfToken()) . '" /> <meta name="description" content="Validate import CSV files for museum-digital" />
<label for="fileToUpload">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_csv_file_for_upload') . '</label> <script src="assets/js/jszip/dist/jszip.min.js" type="text/javascript" async defer></script>
<input name="uploaded" type="file" accept=".csv" id="fileToUpload" required />
<button type="submit">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'upload') . '</button>
</form>
</div>
<div> <link rel="stylesheet" type="text/css" href="assets/css/csvxml.css" />
<h2>' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'currently_approved_tags') . '</h2> <meta name="theme-color" content="#aa4400" />
<div class="options"> <link rel="shortcut icon" sizes="128x128" href="assets/img/mdlogo-csvxml.svg" />
<a href="csv.php" class="buttonLike">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_all') . '</a> <meta name="robots" content="noindex" />
<a class="buttonLike invisible" id="csvBySelection">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_by_selection') . '</a>
<br />
<a class="buttonLike" id="selectRequired">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_required_fields') . '</a>
<a class="buttonLike" id="selectAll">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_all_fields') . '</a>
<a class="buttonLike invisible" id="unsetSelection">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'unset_selection') . '</a>
</div>
';
$tooltips = []; <title>CSVXML :: museum-digital</title>
foreach ($availableFields as $headline => $fields) {
echo " <meta name="keywords" content="Imports, museum-digital" />
<h3>{$headline}</h3>
<ul class='fieldList'>
";
foreach($fields as $fieldName => $field) {
if (!empty($field->remark) or !empty($field->explica)) $hasTooltip = true; </head>
else $hasTooltip = false; <body class="loading" data-tls="' . htmlspecialchars(MD_STD::json_encode([
'remarks' => $tlLoader->tl('basis', 'basis', 'remarks'),
'download' => $tlLoader->tl('export', 'export', 'download'),
'upload' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'upload'),
'select_csv_file_for_upload' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_csv_file_for_upload'),
'currently_approved_tags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'currently_approved_tags'),
'download_csv_all' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_all'),
'download_csv_by_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_by_selection'),
'select_required_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_required_fields'),
'select_all_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_all_fields'),
'unset_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'unset_selection'),
'file_format' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'file_format'),
'validation_errors' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'validation_errors'),
'errors_parsing' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_parsing'),
'errors_mandatoryTags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mandatoryTags'),
'errors_duplicateInvNos' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_duplicateInvNos'),
'errors_dependentColumns' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_dependentColumns'),
'errors_controlledLists' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_controlledLists'),
'errors_mainImageResource' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mainImageResource'),
'allowed_values' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'allowed_values'),
])) . '">
echo " <h1>
<li id='{$fieldName}' data-alt='{$field->name_human_readable}' data-value='{$fieldName}' data-for='{$fieldName}' class='"; <img src="assets/img/mdlogo-csvxml.svg" alt="" />
if ($hasTooltip === true) echo " newToolTipTag"; <span>museum-digital:csvxml</span>
if (!empty($field->required) and $field->required === true) echo " requiredField"; </h1>
echo "'";
if (!empty($field->dependsOn)) {
echo " data-dependencies='" . htmlspecialchars(implode(";", $field->dependsOn)) . "'";
}
echo ">{$fieldName}";
if (!empty($field->explica)) $toolTipExplica = "</p><h5>General</h5><p>" . $field->explica; <script src="assets/js/csvxmlV2.js" type="text/javascript" async></script>
else $toolTipExplica = "";
$toolTip = generateHelpTooltip($fieldName, "{$field->name_human_readable}", "{$field->remark}{$toolTipExplica}");
if ($hasTooltip) $tooltips[] = $toolTip[0];
echo "</li>";
}
echo '
</ul>
';
}
echo '
</div>
';
echo implode($tooltips);
echo '
</body> </body>
</html> </html>';
';

View File

@ -1,420 +0,0 @@
<?PHP
declare(strict_types = 1);
require_once __DIR__ . "/../functions/functions.php";
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}
// This array contains all available languages
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl','pt'];
// Some languages are in translation. They will only be available for logged in users.
if (isset($_GET['navlang'])) {
$_SESSION['lang'] = $_GET['navlang'];
if (!in_array($_SESSION['lang'], $allowed_langs)) $_SESSION['lang'] = 'de';
} else if (!isset($_SESSION['lang'])) {
$_SESSION['lang'] = MD_STD::lang_getfrombrowser($allowed_langs, 'en', "", false);
}
$lang = $_SESSION['lang'];
$tlLoader = new MDTlLoader("csxml_evaluate", $lang);
$filename = $_GET['fnam'];
$csv_datei = MD_STD::realpath(__DIR__ . '/../csv/' . $filename);
// Get allowed values * $fieldNoMultiplicator
$fieldNoMultiplicator = 10;
$fieldsGetter = new CsvxmlAvailableFields($lang);
$availableFields = $fieldsGetter->getFields();
$validator = new CSVXMLValidator();
$allowed = $eventpart = $eventpartsure = $fieldsWithDependency = $fieldsWithAllowedValueSet = [];
foreach ($availableFields as $categoryName => $fieldCategory) {
$allowed = array_merge($allowed, array_keys($fieldCategory));
// Extended operations for events
if (strpos($categoryName, $tlLoader->tl("basis", "basis", 'event')) !== false) {
foreach ($fieldCategory as $key => $value) {
if (strpos($key, "_annotation") !== false or strpos($key, "_gnd") !== false) continue;
if (strpos($key, "_sure") !== false) $eventpartsure[] = $key;
else $eventpart[] = $key;
}
}
foreach ($fieldCategory as $key => $value) {
if (!empty($value->dependsOn)) {
$fieldsWithDependency[$key] = $value->dependsOn;
}
if (!empty($value->allowedValues)) {
$fieldsWithAllowedValueSet[$key] = $value->allowedValues;
}
}
}
$allowed_inclusion_kind_of = ['inclusion_kind_of', 'Schenkung', 'Kauf', 'Grabung', 'Notbergung', 'Erbschaft', 'Stiftung', 'Enteignung', 'Ursprungsbestand', 'Ajándékozás','Vétel','Feltárás','Hivatalos átadás','Csere','Gyűjtés','Saját előállítás','Törzsanyag','Letét', 'endowment', 'dispossession', 'old stock', ''];
echo printHTMLHead();
echo '<div class="maincontent">';
echo 'Please wait ... (checking validity)';
echo '<form action="index.php" style="margin:0px;padding:0px;">';
echo '<input type="submit" value="Reload" />';
echo '</form>';
///// Check #1
//echo '<pre>';print_r($allowed);echo '</pre>';
echo '1: Only allowed tags (column names) used?';
$fp = fopen($csv_datei, 'r');
$y = 0;
while ($zeile = fgetcsv($fp, 100000, ';')) {
$y++;
$maxLoopLen = count($zeile);
for ($x = 0; $x < $maxLoopLen; $x++) {
$inhalt[$y][$x] = str_replace("'", "\'", $zeile[$x]);
if ($y == 1) {
// remove byte order mark
$inhalt[$y][$x] = str_replace("\xEF\xBB\xBF", "", $inhalt[$y][$x]);
if (!in_array($inhalt[$y][$x], $allowed)) {
$validator->addError(
'<br><i style="font-style:normal;color:#990000;">ERROR in column ' . $x
. ' created by value: ' . $inhalt[$y][$x] . '</i>'
);
}
}
}
}
fclose($fp);
$erstezeile = $inhalt[1];
if (count($validator->error_msgs) != 0) {
echo '<br><b style="color:#990000;">Not allowed tags found !</b>';
} else {
echo '<br><i style="font-style:normal;color:#009900;">Only allowed tags used !</i>';
}
//// Check #2
echo '<br><br>2: Not allowed multiple use of tags (column names)?';
$compare = array_unique($erstezeile);
if (count($erstezeile) != count($compare)) {
$validator->addError(
'<br><b style="color:#990000;">There are duplicate column names !</b>'
);
} else {
echo '<br><i style="font-style:normal;color:#009900;">No duplicate column names !</i>';
}
///// Check #3
echo '<br><br>3: Mandatory tags available and always filled in?';
unset($inv_array);
/**
* Function for finding duplicates?.
*
* @param array $array Input array.
*
* @return array
*/
function Get_duplicates(array $array):array
{
return array_unique(array_diff_assoc($array, array_unique($array)));
}
$mandatory = ['inventory_number','object_type','object_title','object_description'];
foreach ($mandatory as $tMandatoryField) {
if (!in_array($tMandatoryField, $erstezeile)) {
$validator->addInvError(
'<br><i style="font-style:normal;color:#990000;">Mandatory: Column <b>'
. $tMandatoryField . '</b> missing</i>'
);
} else {
$spaltenr = array_search($tMandatoryField, $erstezeile);
for ($j = 0; $j < $y; $j++) {
if ($inhalt[$j + 1][$spaltenr] == '') {
$validator->addInvError(
'<br><i style="font-style:normal;color:#990000;">Missing value for <b>'
. $tMandatoryField . '</b> in row ' . ($j + 1) . '</i>'
);
}
if ($tMandatoryField == 'inventory_number') {
$inv_array[] = $inhalt[$j + 1][$spaltenr];
}
}
}
}
if (count($validator->inv_errors) == 0) {
echo '<br><i style="font-style:normal;color:#009900;">All mandatory tags available and with values !</i>';
}
///// Check #4
echo '<br><br>4: Inventory_number unique ?';
if (in_array('inventory_number', $erstezeile)) {
$doppelte_inv = Get_duplicates($inv_array);
$doppelte_inv = array_values($doppelte_inv);
if (!empty($doppelte_inv)) {
foreach ($doppelte_inv as $tDublicateInvNo) {
$validator->addError(
'<br><i style="font-style:normal;color:#990000;">Multiple use of inventory_number <b>'
. $tDublicateInvNo . '</b></i>'
);
}
} else {
echo '<br><i style="font-style:normal;color:#009900;">All inventory_numbers are unique !</i>';
}
} else {
$validator->addError(
'<br><b style="font-style:normal;color:#990000;">Aborted, column inventory_number is missing</b>'
);
}
///// Check #5
echo '<br><br>5: Dependent colums observed ?<br>';
// Check for correct handling of dependent fields
foreach ($fieldsWithDependency as $tField => $tDependentFields) {
if (array_search($tField, $erstezeile) !== false) {
foreach ($tDependentFields as $tDependentField) {
if (array_search($tDependentField, $erstezeile) === false) {
$depencymessage[] = "Dependency issue at column $tField: Corresponding column $tDependentField is missing";
}
}
}
}
if (!empty($depencymessage)) {
echo '<b style="color:#990000;">Dependent columns were not observed !</b>';
foreach ($depencymessage as $tDepMsg) {
$validator->addError('<br>' . $tDepMsg);
}
} else {
echo '<i style="font-style:normal;color:#009900;">Dependent columns were observed !</i>';
}
///// Check #6
echo '<br><br>6: Dependency of content observed?';
//TODO: get the values for these arrays dynamically?
// JRE: Maybe we can merge them into availablefields
$crosscheck1 = ['object_other_title','detailed_description','detailed_description','inscription','inscription','dimensions_separate_length_value', 'dimensions_separate_width_value', 'dimensions_separate_height_value', 'dimensions_separate_diameter_value', 'dimensions_separate_wall_thickness_value', 'dimensions_separate_weight_value','closer_location','bought_for','worth_value','worth_insurance_value'];
$crosscheck2 = ['object_other_title_kind_of','detailed_description_md','detailed_description_extern','inscription_md','inscription_extern','dimensions_separate_length_unit', 'dimensions_separate_width_unit', 'dimensions_separate_height_unit', 'dimensions_separate_diameter_unit', 'dimensions_separate_wall_thickness_unit', 'dimensions_separate_weight_unit','closer_location_as','bought_for_currency','worth_unit','worth_insurance_unit'];
foreach ($crosscheck1 as $l => $tCrossCheck) {
if (in_array($tCrossCheck, $erstezeile)) {
for ($j = 1; $j < ($y + 1); $j++) {
if ($inhalt[$j][array_search($crosscheck2[$l], $erstezeile)] !== '' and $inhalt[$j][array_search($tCrossCheck, $erstezeile)] == '') {
$validator->addDepconError(
'<br>Tag <b>' . $crosscheck2[$l] . '</b> given but no entry for <b>'
. $tCrossCheck . '</b> (row ' . $j . ')'
);
}
}
}
}
foreach ($eventpart as $l => $tEventPart) {
if (in_array($tEventPart, $erstezeile)) {
for ($j = 1; $j < ($y + 1); $j++) {
if ($inhalt[$j][array_search($eventpartsure[$l], $erstezeile)] !== '' and $inhalt[$j][array_search($tEventPart, $erstezeile)] == '') {
$validator->addDepconError(
'<br>Tag <b>' . $eventpartsure[$l] . '</b> given but no entry for <b>'
. $tEventPart . '</b> (row ' . $j . ')'
);
}
}
}
}
if (in_array('dimensions_separate_show_md', $erstezeile)) {
for ($j = 1; $j < ($y + 1); $j++) {
if ($inhalt[$j][array_search('dimensions_separate_show_md', $erstezeile)] !== '' and ($inhalt[$j][array_search('dimensions_separate_length_value', $erstezeile)] == '') and $inhalt[$j][array_search('dimensions_separate_width_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_heigt_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_weight_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_diameter_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_wall_thickness_value', $erstezeile)] == '') {
$validator->addDepconError(
'<br>Tag <b>dimensions_separate_show_md</b> given but no separate values available (row '
. $j . ')'
);
}
}
}
if (in_array('dimensions_separate_show_extern', $erstezeile)) {
for ($j = 1; $j < ($y + 1); $j++) {
if ($inhalt[$j][array_search('dimensions_separate_show_extern', $erstezeile)] !== '' and ($inhalt[$j][array_search('dimensions_separate_length_value', $erstezeile)] == '') and $inhalt[$j][array_search('dimensions_separate_width_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_heigt_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_weight_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_diameter_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_wall_thickness_value', $erstezeile)] == '') {
$validator->addDepconError(
'<br>Tag <b>dimensions_separate_show_extern</b> given but no separate values available (row '
. $j . ')'
);
}
}
}
/*
for ($im=1;$im<11;$im++)
{
if (in_array('image_name'.$im,$erstezeile))
{
for ($j=1;$j<($y+1);$j++)
{
if ($inhalt[$j][array_search('image_rights'.$im,$erstezeile)]!=='')
{
echo '<br>TAG <b>image_name'.$im.'</b> given but no value available for image_rights'.$im.' (row '.$j.')';
$depcon_error=$depcon_error+1;
}
if ($inhalt[$j][array_search('image_visible'.$im,$erstezeile)]!=='')
{
echo '<br>TAG <b>image_name'.$im.'</b> given but no value available for image_visible'.$im.' (row '.$j.')';
$depcon_error=$depcon_error+1;
}
}
}
}
*/
if (count($validator->depcon_errors) == 0) {
echo '<br><i style="font-style:normal;color:#009900;">Dependency of content was observed !</i>';
}
///// Check #7
echo '<br><br>7: Not allowed values in controlled lists?<br>';
for ($i = 2; $i <= $y; $i++) {
foreach ($inhalt[$i] as $key => $value) {
$columnName = $inhalt[1][$key];
// Only do the check if the field is not restricted
if (isset($fieldsWithAllowedValueSet[$columnName])) {
// For others: check if the value is from the list of allowed values.
if (!in_array($value, $fieldsWithAllowedValueSet[$columnName])) {
// It may be that the value is empty together with all dependent fields,
// because it's in a repeat field that was needed earlier.
if (empty($value) && !empty($fieldsWithDependency[$columnName])) {
$allDependentsEmpty = true;
foreach ($fieldsWithDependency[$columnName] as $depField) {
// Find keys of dependent field
$depFieldKey = array_search($depField, $inhalt[1]);
if (!empty($inhalt[$i][$depFieldKey])) {
$allDependentsEmpty = false;
break;
}
}
if ($allDependentsEmpty !== true) {
$errormessage[] = "Disallowed value in column <code>{$columnName}</code> on row <code>{$i}</code>: <em>"
. $value . "</em> (allowed values: <small>"
. implode(", ", $fieldsWithAllowedValueSet[$columnName])
. "</small>)";
}
}
}
}
}
}
if (!empty($errormessage)) {
echo '<b style="color:#990000;">Columns with controlled values contain invalid values !</b>';
foreach ($errormessage as $tMsg) {
$validator->addError('<br>' . $tMsg);
}
} else {
echo '<i style="font-style:normal;color:#009900;">Values in controlled fields are all valid !</i>';
}
///// Check #8
unset($errormessage);
echo '<br><br>8: Main image or main resource given?<br>';
$hasanyimage = 0;
for ($im = 1; $im < 29; $im++) {
if (array_search('image_name' . $im, $erstezeile) != '') {
$imagemain[$im]['name'] = array_search('image_name' . $im, $erstezeile);$hasanyimage++;
}
if (array_search('image_visible' . $im, $erstezeile) != '') {
$imagemain[$im]['visible'] = array_search('image_visible' . $im, $erstezeile);
}
if (array_search('image_main' . $im, $erstezeile) != '') {
$imagemain[$im]['main'] = array_search('image_main' . $im, $erstezeile);
}
}
if ($hasanyimage > 0) {
$imagemain = array_values($imagemain);
for ($i = 1; $i <= $y; $i++) {
if ($i > 1) {
//check if in a row any image_name is given
$maimg = $hatimg = 0;
foreach ($imagemain as $im => $tMainImage) {
if ($inhalt[$i][$tMainImage["name"]] != '') $hatimg++;
}
if ($hatimg > 0) {
// first check: how many main-images?
foreach ($imagemain as $im => $tMainImage) {
if ($inhalt[$i][$imagemain[$im]['main']] == 'y') {
$maimg++;
$merk = $im;
}
}
// if there is exacly one main-image, is it visible?
if ($maimg == 1) {
if ($inhalt[$i][$imagemain[$merk]['visible']] == 'n') {
$errormessage[] = '<b style="font-weight:normal;color:#990000">Main image in row ' . $i . ' is not visible</b>';
}
}
}
if ($maimg == 0 and $hatimg > 0) {
$errormessage[] = '<b style="font-weight:normal;color:#990000">There is no visible main image given in row ' . $i . '</b>';
}
if ($maimg > 1 and $hatimg > 0) {
$errormessage[] = '<b style="font-weight:normal;color:#990000">There are ' . $maimg . ' main images given in row ' . $i . '</b>';
}
}
}
if (!empty($errormessage)) {
echo '<b style="color:#990000;">There is not one main image for each object !</b>';
foreach ($errormessage as $tMsg) {
$validator->addError('<br>' . $tMsg);
}
} else {
echo '<i style="font-style:normal;color:#009900;">For each object that has images attached exactly one main image is given !</i>';
}
} else {
echo '<i style="font-style:normal;color:#009900;">No images to be imported !</i>';
}
echo '<hr>';
if ($validator->overallErrorCount() > 0) {
echo '
<p>Error(s) found: ' . $validator->overallErrorCount() . '</p>';
foreach ($validator->error_msgs as $msg) {
echo $msg;
}
foreach ($validator->inv_errors as $msg) {
echo $msg;
}
foreach ($validator->depcon_errors as $msg) {
echo $msg;
}
echo '<a href="index6.php?fnam=' . htmlspecialchars($_GET['fnam']) . '" class="buttonLike">Create XML for md:import (utf8)</a><br>';
} else {
echo '<a href="index6.php?fnam=' . htmlspecialchars($_GET['fnam']) . '" class="buttonLike">Create XML for md:import (utf8)</a><br>';
}
echo '</div>';
echo '
</body>
</html>
';

View File

@ -1,92 +0,0 @@
<?PHP
declare(strict_types = 1);
require_once __DIR__ . "/../functions/functions.php";
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}
// This array contains all available languages
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl', 'pt'];
// Some languages are in translation. They will only be available for logged in users.
if (isset($_GET['navlang'])) {
$_SESSION['lang'] = $_GET['navlang'];
if (!in_array($_SESSION['lang'], $allowed_langs)) $_SESSION['lang'] = 'de';
}
else if (!isset($_SESSION['lang'])) {
$_SESSION['lang'] = MD_STD::lang_getfrombrowser($allowed_langs, 'en', "", false);
}
$lang = $_SESSION['lang'];
if (empty($filename = trim($_GET['fnam'], " ,./"))) {
echo "Error: Invalid file name";
exit;
}
$csv_datei = MD_STD::realpath(__DIR__ . '/../csv/' . $filename);
if (is_dir(__DIR__ . "/../xml")) rrmdir(__DIR__ . '/../xml');
mkdir(__DIR__ . "/../xml", CACHE_DIR_PERMS);
if (!($fp = fopen($csv_datei, 'r'))) {
throw new MDmainEntityNotExistentException("Failed opening file");
}
$y = 0;
while ($zeile = fgetcsv($fp, 100000, ';', "\"")) {
$zeile = str_replace("\xEF\xBB\xBF", '', $zeile);
$y++;
$zieldatei = __DIR__ . '/../xml/' . $y . '.xml';
if (!$handle = fopen($zieldatei, 'w')) {
echo "Cannot open file ($zieldatei)";
exit;
}
$xmlDoc = new DOMDocument("1.0", "UTF-8");
$xmlDoc->preserveWhiteSpace = false;
$xmlDoc->formatOutput = true;
# $xmlDoc->encoding = 'utf-8';
$xmlMainElem = $xmlDoc->createElement("record");
$record_node = $xmlDoc->appendChild($xmlMainElem); //add record element to XML node
# $rss_node->setAttribute("version", "2.0"); //set RSS version
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';
if (!isset($inhalt[1][$x])) {
echo "Error at position $x";
}
$record_node->appendChild(createTextDomElement($xmlDoc, trim($inhalt[1][$x] ?? ""), trim($inhalt[$y][$x] ?? "")));
}
$somecontent = '<?xml version="1.0" encoding="UTF-8"?>' . $xmlDoc->saveXML($xmlDoc->documentElement);
# $somecontent .= '</record>';
//if ($y>1)
//{
if (fwrite($handle, $somecontent) === false) {
echo "Cannot write to file ($filename)";
exit;
}
fclose($handle);
}
fclose($fp);
echo printHTMLHead();
echo '
<div>
' . ($y - 1) . ' files created<br />
<hr/>
<a href="zipit.php" class="buttonLike">Download as ZIP</a>
</div>';

View File

@ -1,87 +0,0 @@
<?PHP
/**
* New start page for CSVXML.
*
* @link https://groupit.museum-digital.de/csvxml/
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
require_once __DIR__ . "/../functions/functions.php";
$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl', 'pt'];
$lang = MD_STD::get_user_lang($allowed_langs, "en");
$tlLoader = new MDTlLoader("csxml_start_v2", $lang);
$outFormat = MD_STD_IN::get_http_input_text("output", "html", ['html', 'json']);
if ($outFormat === 'json') {
$fieldsGetter = new CsvxmlAvailableFields($lang);
$availableFields = $fieldsGetter->getFields();
header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: X-PINGOTHER, Content-Type, Accept-Encoding, cache-control");
header("Access-Control-Max-Age: 86400");
header('content-type: application/json');
echo json_encode($availableFields);
return;
}
echo '
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Validate import CSV files for museum-digital" />
<script src="assets/js/jszip/dist/jszip.min.js" type="text/javascript" async defer></script>
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.css" />
<meta name="theme-color" content="#aa4400" />
<link rel="shortcut icon" sizes="128x128" href="assets/img/mdlogo-csvxml.svg" />
<meta name="robots" content="noindex" />
<title>CSVXML :: museum-digital</title>
<meta name="keywords" content="Imports, museum-digital" />
</head>
<body class="loading" data-tls="' . htmlspecialchars(MD_STD::json_encode([
'remarks' => $tlLoader->tl('basis', 'basis', 'remarks'),
'download' => $tlLoader->tl('export', 'export', 'download'),
'upload' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'upload'),
'select_csv_file_for_upload' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_csv_file_for_upload'),
'currently_approved_tags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'currently_approved_tags'),
'download_csv_all' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_all'),
'download_csv_by_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_by_selection'),
'select_required_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_required_fields'),
'select_all_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_all_fields'),
'unset_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'unset_selection'),
'file_format' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'file_format'),
'validation_errors' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'validation_errors'),
'errors_parsing' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_parsing'),
'errors_mandatoryTags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mandatoryTags'),
'errors_duplicateInvNos' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_duplicateInvNos'),
'errors_dependentColumns' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_dependentColumns'),
'errors_controlledLists' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_controlledLists'),
'errors_mainImageResource' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mainImageResource'),
'allowed_values' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'allowed_values'),
])) . '">
<h1>
<img src="assets/img/mdlogo-csvxml.svg" alt="" />
<span>museum-digital:csvxml</span>
</h1>
<script src="assets/js/csvxmlV2.js" type="text/javascript" async></script>
</body>
</html>';

View File

@ -1,35 +0,0 @@
<?PHP
declare(strict_types = 1);
require_once __DIR__ . "/../functions/functions.php";
if (empty($_FILES)) {
throw new MDFileDoesNotExist("No file uploaded");
}
$targetpart = basename($_FILES['uploaded']['name']);
$target = __DIR__ . "/../csv/" . $targetpart;
// TODO: File name needs to be sanitized, or tmp name used
if (session_status() != PHP_SESSION_ACTIVE) {
session_start();
}
if (MD_STD_SEC::validateAntiCsrfToken() === false) {
throw new MDWrongCsrfTokenException();
}
//This is our size condition
if ($_FILES['uploaded']['size'] > 40000000) {
echo "Your file is too large.<br>";
return;
}
//Here we check that $ok was not set to 0 by an error
//If everything is ok we try to upload it
if(!move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
echo "Sorry, there was a problem uploading your file.";
return;
}
header("Location: index3.php?fnam=" . basename($_FILES['uploaded']['name']));

View File

@ -1,43 +0,0 @@
<?PHP
require_once __DIR__ . "/../inc/zip.php";
require_once __DIR__ . "/../functions/functions.php";
$fileTime = date("D, d M Y H:i:s T");
$fileDir = __DIR__ . '/../xml/';
$zip = new Zip();
//$zip->setComment("Example Zip file.\nCreated on " . date('l jS \of F Y h:i:s A'));
if ($handle = opendir($fileDir)) {
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if (strpos($file, ".xml") !== false) {
$pathData = pathinfo($fileDir . $file);
$fileName = $pathData['filename'];
if ($file != '1.xml')
$zip->addFile(MD_STD::file_get_contents($fileDir . $file), $file, filectime($fileDir . $file));
}
}
}
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
$zip->finalize(); // Not scrictly necessary, the next line will call it anyway.
$zipData = $zip->getZipData();
$length = strlen($zipData);
header('Pragma: public');
header("Last-Modified: " . $fileTime);
header("Expires: 0");
header("Accept-Ranges: bytes");
header("Connection: close");
header("Content-Type: application/zip");
header('Content-Disposition: attachment; filename="csv_xml.zip";' );
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $length);
echo $zipData;
rrmdir(__DIR__ . '/../xml');