Chore: Verschiebe Git-Repository in das Hauptverzeichnis und richte .gitignore ein

This commit is contained in:
salam committed 2026-10-19 10:11:04 +02:00
commit 96d0545193
502 files changed
+176027

No files matched your search

@@ -0,0 +1,148 @@
<?php
namespace HermannTelser\Gutachten\Uploads;
use ForceUTF8\Encoding;
use HermannTelser\Gutachten\DB\DbFunction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class UploadAllgemein
{
/**
* @return false
*/
public static function upload()
{
// DbFunction::$debug = 1;
$phpFileUploadErrors = [
0 => 'There is no error, the file uploaded with success',
1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini',
2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
3 => 'The uploaded file was only partially uploaded',
4 => 'No file was uploaded',
6 => 'Missing a temporary folder',
7 => 'Failed to write file to disk.',
8 => 'A PHP extension stopped the file upload.',
];
$userid = $GLOBALS['TSFE']->fe_user->user['uid'];
$projektid = GeneralUtility::_GP('pid');
\define('SITE_ROOT', realpath(__DIR__));
$files = glob(SITE_ROOT.'/uploaded_files/*'); // get all file names
foreach ($files as $file) { // iterate files
if (is_file($file)) {
unlink($file);
} // delete file
}
$response = [];
$response['message'] = '<h3>Allgemeinflächen</h3>';
// $response['message'] = '<i class="fa fa-exclamation-triangle rot"></i> <b>Falscher Dokumenteninhalt für Allgemeinflächen.</b>';
// return $response;
if (isset($_FILES['uploadedfile']) && UPLOAD_ERR_OK == $_FILES['uploadedfile']['error']) {
$fileTmpPath = $_FILES['uploadedfile']['tmp_name'];
$fileName = $_FILES['uploadedfile']['name'];
$fileSize = $_FILES['uploadedfile']['size'];
$fileType = $_FILES['uploadedfile']['type'];
$fileNameCmps = explode('.', $fileName);
$fileExtension = strtolower(end($fileNameCmps));
// sanitize file-name
$newFileName = md5(time().$fileName).'.'.$fileExtension;
// check if file has one of the following extensions
//$allowedfileExtensions = array('jpg', 'gif', 'png', 'zip', 'txt', 'xls', 'doc','rtf','csv');
$allowedfileExtensions = ['csv', 'txt'];
if (\in_array($fileExtension, $allowedfileExtensions)) {
// directory in which the uploaded file will be moved
$uploadFileDir = SITE_ROOT.'/uploaded_files/';
$dest_path = $uploadFileDir.$newFileName;
if (move_uploaded_file($fileTmpPath, $dest_path)) {
if (DbFunction::$debug) {
echo "Die Datei wurde erfolgreich hochgeladen.\n";
}
$sum_raume_all_vorher = DbFunction::count('tx_gutachten_allgemein', ['pid' => $projektid]);
DbFunction::delete('tx_gutachten_allgemein', ['pid' => $projektid]);
$file = file_get_contents($dest_path);
$file = Encoding::toUTF8($file, Encoding::ICONV_TRANSLIT);
$arr = preg_split('/\r\n|\r|\n/', $file);
$sum_raume_all_nachher=0;
foreach ($arr as $key => $value) {
$row = explode('|', $value);
$result = array_map('trim', $row);
if (\count($result) > 4) {
$response['message'] .= 'Mehr als Vier Spalten im Dokument.';
$response['class'] = 'error';
return $response;
} elseif (\count($result) < 4) {
$response['message'] .= 'Weniger als Vier Spalten im Dokument.';
$response['class'] = 'error';
return $response;
// } elseif (!\in_array($result[0], ['Allg.', 'Allgemein'])) {
// $response['message'] = 'Falsches Dokument.';
// $response['class'] = 'error';
//
// return $response;
}
$insert_array = [];
$insert_array['pid'] = $projektid;
$insert_array['uid'] = $userid;
$insert_array['geschoss'] = $result[1];
$insert_array['typ'] = $result[2];
$insert_array['qm'] = str_replace(',', '.', $result[3]);
DbFunction::secureInsert('tx_gutachten_allgemein', $insert_array);
$sum_raume_all_nachher++;
}
$response['message'] .= "<b>Die Datei wurde erfolgreich hochgeladen.</b>";
$response['message'] .= "<br>Summe Objekte vorher: $sum_raume_all_vorher";
$response['message'] .= "; nachher: $sum_raume_all_nachher";
$diff = abs($sum_raume_all_vorher - $sum_raume_all_nachher);
$response['message'] .= "; <b>Differenz: $diff </b>";
$response['class'] = 'ok';
} else {
$response['message'] .= $phpFileUploadErrors[$_FILES['uploadedfile']['error']];
$response['file'] = $uploadfile;
$response['class'] = 'error';
$response['dir'] = __DIR__;
$response['tmp'] = sys_get_temp_dir();
return $response;
}
} else {
$response['message'] .= 'Dokument muss txt oder csv sein';
$response['class'] = 'error';
return $response;
}
} else {
$response['message'] .= $phpFileUploadErrors[$_FILES['uploadedfile']['error']];
$response['file'] = $_FILES['uploadedfile']['name'];
$response['class'] = 'error';
$response['dir'] = __DIR__;
$response['tmp'] = sys_get_temp_dir();
$response['time'] = time();
return $response;
}
// UPLOAD_ERR_INI_SIZE = Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
// UPLOAD_ERR_FORM_SIZE = Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
// UPLOAD_ERR_PARTIAL = Value: 3; The uploaded file was only partially uploaded.
// UPLOAD_ERR_NO_FILE = Value: 4; No file was uploaded.
// UPLOAD_ERR_NO_TMP_DIR = Value: 6; Missing a temporary folder. Introduced in PHP 5.0.3.
// UPLOAD_ERR_CANT_WRITE = Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.
// UPLOAD_ERR_EXTENSION = Value: 8; A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help.
return $response;
}
}
@@ -0,0 +1,200 @@
<?php
namespace HermannTelser\Gutachten\Uploads;
use ForceUTF8\Encoding;
use HermannTelser\Gutachten\DB\DbFunction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class UploadNutzflaechen
{
/**
* @return false
*/
public static function upload()
{
// DbFunction::$debug = 1;
$phpFileUploadErrors = [
0 => 'There is no error, the file uploaded with success',
1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini',
2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
3 => 'The uploaded file was only partially uploaded',
4 => 'No file was uploaded',
6 => 'Missing a temporary folder',
7 => 'Failed to write file to disk.',
8 => 'A PHP extension stopped the file upload.',
];
$userid = $GLOBALS['TSFE']->fe_user->user['uid'];
$projektid = GeneralUtility::_GP('pid');
\define('SITE_ROOT', realpath(__DIR__));
$files = glob(SITE_ROOT.'/uploaded_files/*'); // get all file names
foreach ($files as $file) { // iterate files
if (is_file($file)) {
unlink($file);
} // delete file
}
$response = [];
$response['message'] = '<h3>Nutzflächen</h3>';
// $response['message'] = '<i class="fa fa-exclamation-triangle rot"></i> <b>Falscher Dokumenteninhalt für Nutzflächen .</b>';
// return $response;
if (isset($_FILES['uploadedfile']) && UPLOAD_ERR_OK == $_FILES['uploadedfile']['error']) {
$fileTmpPath = $_FILES['uploadedfile']['tmp_name'];
$fileName = $_FILES['uploadedfile']['name'];
$fileSize = $_FILES['uploadedfile']['size'];
$fileType = $_FILES['uploadedfile']['type'];
$fileNameCmps = explode('.', $fileName);
$fileExtension = strtolower(end($fileNameCmps));
// sanitize file-name
$newFileName = md5(time().$fileName).'.'.$fileExtension;
// check if file has one of the following extensions
//$allowedfileExtensions = array('jpg', 'gif', 'png', 'zip', 'txt', 'xls', 'doc','rtf','csv');
$allowedfileExtensions = ['csv', 'txt'];
if (\in_array($fileExtension, $allowedfileExtensions)) {
// directory in which the uploaded file will be moved
$uploadFileDir = SITE_ROOT.'/uploaded_files/';
$dest_path = $uploadFileDir.$newFileName;
if (move_uploaded_file($fileTmpPath, $dest_path)) {
if (DbFunction::$debug) {
echo "Die Datei wurde erfolgreich hochgeladen.\n";
}
// DbFunction::delete('tx_gutachten_allgemein', ['pid' => $projektid]);
$file = file_get_contents($dest_path);
// echo $file; exit;
$file = Encoding::toUTF8($file, Encoding::ICONV_TRANSLIT);
$arr = preg_split('/\r\n|\r|\n/', $file);
// Order by topNr
$_ordered = [];
foreach ($arr as $key => $value) {
$row = explode('|', $value);
$result = array_map('trim', $row);
if (\count($result) > 4) {
$response['message'] = 'Mehr als Vier Spalten im Dokument.';
$response['class'] = 'error';
return $response;
} elseif (\count($result) < 4) {
$response['message'] = 'Weniger als Vier Spalten im Dokument.';
$response['class'] = 'error';
return $response;
}
if ('' != $value) {
$topNr = $result[0];
if ('' != $topNr) {
$_ordered[$topNr][] = $result;
}
}
}
$sum_raume_all_vorher = DbFunction::count('tx_gutachten_raume_all', ['pid' => $projektid]);
$_raeume = [];
foreach ($_ordered as $topNr => $daten) {
$tt_raume_basis_id = DbFunction::get('tx_gutachten_raume_basis', 'id', ['AND' => ['pid' => $projektid, 'topNr' => $topNr]]);
if (!$tt_raume_basis_id) {
$insert_array = [];
$insert_array['pid'] = $projektid;
$insert_array['uid'] = $userid;
$insert_array['topNr'] = $topNr;
$tt_raume_basis_id = DbFunction::secureInsert('tx_gutachten_raume_basis', $insert_array);
}
// tx_gutachten_raume_all
foreach ($daten as $key => $value) {
$geschoss = $value[1];
$raum = $value[2];
$flaeche = $value[3];
$flaeche = str_replace(',', '.', $flaeche);
$_raeume[] = $raum;
$tmp = DbFunction::select('tx_gutachten_raume_all', 'id', ['AND' => ['pid' => $projektid, 'raum' => $raum, 'tt_raume_basis_id' => $tt_raume_basis_id]]);
if (!\count($tmp)) {
$insert_array = [];
$insert_array['tt_raume_basis_id'] = $tt_raume_basis_id;
$insert_array['uid'] = $userid;
$insert_array['pid'] = $projektid;
$insert_array['geschoss'] = $geschoss;
$insert_array['raum'] = $raum;
$insert_array['qm'] = $flaeche;
DbFunction::secureInsert('tx_gutachten_raume_all', $insert_array);
} else {
$update_array = [];
$update_array['qm'] = $flaeche;
$update_array['geschoss'] = $geschoss;
DbFunction::secureUpdate('tx_gutachten_raume_all', $update_array, ['id' => $tmp[0]]);
}
}
}
$_raeume = array_unique($_raeume);
$_obsolet = [];
$tmp = DbFunction::select('tx_gutachten_raume_generell', 'raum', ['pid' => $projektid]);
foreach ($tmp as $key => $raum) {
if (!\in_array($raum, $_raeume)) {
$_obsolet[] = $raum;
}
}
foreach ($_obsolet as $key => $raum) {
DbFunction::delete('tx_gutachten_raume_generell', ['AND' => ['pid' => $projektid, 'raum' => $raum]]);
}
foreach ($_raeume as $key => $raum) {
$tmp = DbFunction::select('tx_gutachten_raume_generell', ['id', 'raum'], ['AND' => ['pid' => $projektid, 'raum' => $raum], 'ORDER' => 'id']);
if (0 == \count($tmp)) {
$insert_array = [];
$insert_array['pid'] = $projektid;
$insert_array['uid'] = $userid;
$insert_array['raum'] = $raum;
DbFunction::secureInsert('tx_gutachten_raume_generell', $insert_array);
} elseif (\count($tmp) > 1) {
foreach ($tmp as $k => $v) {
if ($k > 0) {
DbFunction::delete('tx_gutachten_raume_generell', ['id' => $v['id']]);
}
}
}
}
$sum_raume_all_nachher = DbFunction::count('tx_gutachten_raume_all', ['pid' => $projektid]);
$response['message'] .= "<b>Die Datei wurde erfolgreich hochgeladen.</b>";
$response['message'] .= "<br>Summe Objekte vorher: $sum_raume_all_vorher";
$response['message'] .= "; nachher: $sum_raume_all_nachher";
$diff = abs($sum_raume_all_vorher - $sum_raume_all_nachher);
$response['message'] .= "; <b>Differenz: $diff </b>";
$response['class'] = 'ok';
return $response;
}
$response['message'] = $phpFileUploadErrors[$_FILES['uploadedfile']['error']];
$response['file'] = $uploadfile;
$response['class'] = 'error';
$response['dir'] = __DIR__;
$response['tmp'] = sys_get_temp_dir();
return $response;
}
$response['message'] = 'Dokument muss txt oder csv sein';
$response['class'] = 'error';
return $response;
}
$response['message'] = $phpFileUploadErrors[$_FILES['uploadedfile']['error']];
$response['file'] = $_FILES['uploadedfile']['name'];
$response['class'] = 'error';
$response['dir'] = __DIR__;
$response['tmp'] = sys_get_temp_dir();
$response['time'] = time();
return $response;
}
}
@@ -0,0 +1,44 @@
<?php
namespace HermannTelser\Gutachten\Uploads;
use HermannTelser\Gutachten\Utility\Message;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/***
*
* This file is part of the "NuhOdds Comparatore" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2019 Hermann Telser <hermann.telser@gmail.com>
*
***/
class _UploadsController
{
public function __construct()
{
$arr = [];
switch (GeneralUtility::_GP('action')) {
// DOWNLOADS
case 'allgemein':
$arr = UploadAllgemein::upload();
break;
case 'nutzflaechen':
$arr = UploadNutzflaechen::upload();
break;
default:
Message::error(
__FILE__,
__LINE__,
'no controller switch defined'
);
}
header('Content-Type: application/json');
echo json_encode($arr);
exit();
}
}
@@ -0,0 +1 @@
Allgemein | EG | Fahrräder | 7,20␍Allgemein | EG | Freifläche 1 | 45,42␍Allgemein | EG | Freifläche 2 | 19,85␍Allgemein | EG | Grünfläche | 118,22␍Allgemein | EG | Quartiersplatz | 267,15␍Allgemein | EG | Stiege EG | 15,66␍Allgemein | EG | Trafor. 1 | 2,81␍Allgemein | EG | Trafor. 2 | 2,81␍Allgemein | EG | Trafor. 3 | 11,98␍Allgemein | EG | Zugang | 286,74␍Allgemein | OG1 | Gang | 17,00␍Allgemein | OG1 | Stgh. OG1 | 14,74␍Allgemein | OG2 | Gang | 17,00␍Allgemein | OG2 | Stgh. OG2 | 16,07␍Allgemein | OG3 | Dachfläche bekiest | 317,29␍Allgemein | OG3 | Stgh. OG3 | 13,72␍Allgemein | UG | Abluft B | 1,90␍Allgemein | UG | einspurige EB01 | 2,81␍Allgemein | UG | einspurige EB02 | 2,50␍Allgemein | UG | einspurige EB03 | 2,50␍Allgemein | UG | Elektro B | 5,33␍Allgemein | UG | Fahrräder B | 41,71␍Allgemein | UG | Gang B | 18,45␍Allgemein | UG | Garage B | 495,63␍Allgemein | UG | KIWA/Sport B | 6,97␍Allgemein | UG | Müllraum B | 16,53␍Allgemein | UG | Schleuse B | 4,09␍Allgemein | UG | Stellplatz B01 | 13,27␍Allgemein | UG | Stellplatz B02 | 13,39␍Allgemein | UG | Stellplatz B03 | 13,39␍Allgemein | UG | Stellplatz B04 | 15,00␍Allgemein | UG | Stellplatz B05 | 15,30␍Allgemein | UG | Stgh. UG | 4,66␍Allgemein | UG | Technik B | 11,93