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;
}
}