phpcs-errors:0 phpunit-status:successful phpstan-errors:1
This commit is contained in:
Joshua Ramon Enslin 2020-11-15 05:55:22 +01:00
commit f3e2809c8f
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
6 changed files with 21 additions and 17 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ commonservices
/vendor/ /vendor/
/xml /xml
.phpunit.result.cache .phpunit.result.cache
/.gnupg/

View File

@ -9,8 +9,8 @@
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);
@ -103,17 +103,11 @@ function mdExceptionHandler(Throwable $exception):void {
$output = '<!DOCTYPE html> $output = '<!DOCTYPE html>
<html id="errorPage"> <html id="errorPage">
<head> <head>
<script src="js/loadCaches.min.js?2020013517" type="text/javascript" async></script>
<script src="js/applyCaches.min.js?2020013517" type="text/javascript"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="manifest" href="./manifest.webmanifest" /> <link rel="manifest" href="./manifest.webmanifest" />
<link rel="shortcut icon" sizes="16x16 32x32" href="./db_images_gestaltung/mdlogo-32px.png" /> <link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css" />
<link rel="shortcut icon" sizes="64x64" href="./db_images_gestaltung/mdlogo-64px.png" /> <link rel="shortcut icon" sizes="128x128" href="assets/img/mdlogo-csvxml.svg" />';
<link rel="stylesheet" type="text/css" href="css/main.min.css?2020013517" />
<link rel="stylesheet" type="text/css" href="css/errorPage.css" />';
if (!empty($_SESSION['dark-theme'])) $output .= '
<link rel="stylesheet" type="text/css" href="css/dark-theme.css?2020013517" />';
$output .= ' $output .= '
<title>Error :: '; <title>Error :: ';
$output .= $versionName; $output .= $versionName;
@ -122,7 +116,7 @@ function mdExceptionHandler(Throwable $exception):void {
<body> <body>
<main> <main>
<img src="./db_images_gestaltung/mdlogo-256px.png" /> <img src="/assets/img/mdlogo-csvxml.svg" />
<p>' . $errorMsg . '</p> <p>' . $errorMsg . '</p>
<nav> <nav>

View File

@ -8,6 +8,8 @@
*/ */
declare(strict_types = 1); declare(strict_types = 1);
const CACHE_DIR_PERMS = 0775;
const TL_FILE_DIRS = [ const TL_FILE_DIRS = [
__DIR__ . "/../l10n/musdb/", __DIR__ . "/../l10n/musdb/",
__DIR__ . "/../l10n/importer/", __DIR__ . "/../l10n/importer/",

View File

@ -19,6 +19,7 @@ else if (!isset($_SESSION['lang'])) {
$_SESSION['lang'] = MD_STD::lang_getfrombrowser($allowed_langs, 'en', "", false); $_SESSION['lang'] = MD_STD::lang_getfrombrowser($allowed_langs, 'en', "", false);
} }
$lang = $_SESSION['lang']; $lang = $_SESSION['lang'];
$tlLoader = new MDTlLoader("csxml_evaluate", $lang);
$filename = $_GET['fnam']; $filename = $_GET['fnam'];
$csv_datei = MD_STD::realpath(__DIR__ . '/../csv/' . $filename); $csv_datei = MD_STD::realpath(__DIR__ . '/../csv/' . $filename);
@ -34,7 +35,7 @@ foreach ($availableFields as $categoryName => $fieldCategory) {
$allowed = array_merge($allowed, array_keys($fieldCategory)); $allowed = array_merge($allowed, array_keys($fieldCategory));
// Extended operations for events // Extended operations for events
if (strpos($categoryName, $basis['event']) !== false) { if (strpos($categoryName, $tlLoader->tl("basis", "basis", 'event')) !== false) {
foreach ($fieldCategory as $key => $value) { foreach ($fieldCategory as $key => $value) {
if (strpos($key, "_annotation") !== false or strpos($key, "_gnd") !== false) continue; if (strpos($key, "_annotation") !== false or strpos($key, "_gnd") !== false) continue;
if (strpos($key, "_sure") !== false) $eventpartsure[] = $key; if (strpos($key, "_sure") !== false) $eventpartsure[] = $key;
@ -339,7 +340,7 @@ if ($hasanyimage > 0) {
//check if in a row any image_name is given //check if in a row any image_name is given
$maimg = $hatimg = 0; $maimg = $hatimg = 0;
foreach ($imagemain as $im => $tMainImage) { foreach ($imagemain as $im => $tMainImage) {
if ($inhalt[$i][$tMainImage] != '') $hatimg++; if ($inhalt[$i][$tMainImage["name"]] != '') $hatimg++;
} }
if ($hatimg > 0) { if ($hatimg > 0) {
// first check: how many main-images? // first check: how many main-images?

View File

@ -27,7 +27,7 @@ if (empty($filename = trim($_GET['fnam'], " ,./"))) {
$csv_datei = MD_STD::realpath(__DIR__ . '/../csv/' . $filename); $csv_datei = MD_STD::realpath(__DIR__ . '/../csv/' . $filename);
if (is_dir(__DIR__ . "/../xml")) rrmdir(__DIR__ . '/../xml'); if (is_dir(__DIR__ . "/../xml")) rrmdir(__DIR__ . '/../xml');
mkdir(__DIR__ . "/../xml", 0755); mkdir(__DIR__ . "/../xml", CACHE_DIR_PERMS);
if (!($fp = fopen($csv_datei, 'r'))) { if (!($fp = fopen($csv_datei, 'r'))) {
throw new MDmainEntityNotExistentException("Failed opening file"); throw new MDmainEntityNotExistentException("Failed opening file");
@ -39,7 +39,7 @@ while ($zeile = fgetcsv($fp, 100000, ';')) {
$y++; $y++;
$zieldatei = 'xml/' . $y . '.xml'; $zieldatei = __DIR__ . '/../xml/' . $y . '.xml';
if (!$handle = fopen($zieldatei, 'w')) { if (!$handle = fopen($zieldatei, 'w')) {
echo "Cannot open file ($zieldatei)";exit; echo "Cannot open file ($zieldatei)";exit;
} }

View File

@ -2,8 +2,14 @@
declare(strict_types = 1); declare(strict_types = 1);
require_once __DIR__ . "/../functions/functions.php"; require_once __DIR__ . "/../functions/functions.php";
$target = __DIR__ . "/../csv/" . basename($_FILES['uploaded']['name']); if (empty($_FILES)) {
throw new MDFileDoesNotExist("No file uploaded");
}
$targetpart = basename($_FILES['uploaded']['name']); $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) { if (session_status() != PHP_SESSION_ACTIVE) {
session_start(); session_start();
@ -14,7 +20,7 @@ if (validateAntiCsrfToken() === false) {
} }
//This is our size condition //This is our size condition
if ($uploaded_size > 40000000) { if ($_FILES['uploaded']['size'] > 40000000) {
echo "Your file is too large.<br>"; echo "Your file is too large.<br>";
return; return;
} }