Files
vokspace/import.php
2026-01-02 21:00:45 +01:00

176 lines
6.3 KiB
PHP

<?php /* session_start();
$Suchbegriff = strip_tags(htmlentities($_GET["q"]));
$_SESSION["redirect"] = 'index';
$folderID = $_SESSION["folderID"];
$dateiname = $_FILES['file']['name'];
$groesse = $_FILES['file']['size'];
$typ = $_FILES['file']['type'];
$tmp_name = $_FILES['file']['tmp_name'];
$page = strip_tags(htmlentities($_POST["page"]));
?>
<!DOCTYPE html>
<html>
<head>
<title>Importieren | Vokabelbox</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="files/style.css" />
<script language="javascript" type="text/javascript" src="files/scripts.js"></script>
<meta name="google-site-verification" content="zP1CNCQcUP1lr3cYAUMljl5D-GqiUphk-1NdrFS5g6g" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<link rel="apple-touch-icon" sizes="57x57" href="https://www.timvandenboom.de/Favicons/VokabelBox/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="https://www.timvandenboom.de/Favicons/VokabelBox/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="https://www.timvandenboom.de/Favicons/VokabelBox/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="https://www.timvandenboom.de/Favicons/VokabelBox/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="https://www.timvandenboom.de/Favicons/VokabelBox/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="https://www.timvandenboom.de/Favicons/VokabelBox/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="https://www.timvandenboom.de/Favicons/VokabelBox/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="https://www.timvandenboom.de/Favicons/VokabelBox/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="https://www.timvandenboom.de/Favicons/VokabelBox/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="https://www.timvandenboom.de/Favicons/VokabelBox/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://www.timvandenboom.de/Favicons/VokabelBox/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="https://www.timvandenboom.de/Favicons/VokabelBox/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="https://www.timvandenboom.de/Favicons/VokabelBox/favicon-16x16.png">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="https://www.timvandenboom.de/Favicons/VokabelBox/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<header>
<p onclick="window.location.href='index'"></p>
<button class="far fa-user-circle" onclick="window.location.href='myaccount'"></button>
<button class="fas fa-user-circle" onclick="window.location.href='myaccount'"></button>
<form id="search-bar" action="search" method="GET">
<input type="text" required autofocus placeholder="Suche..." name="q">
<button type="submit" class="fas fa-search"></button>
</form>
<button type="text" class="fas fa-times" id="search-bar-close" onclick="hideSearch()"></button>
<button class="fas fa-search" id="search-open" onclick="showSearch()"></button>
</header>
<main>
<div class="middle">
<?php
require "files/ezine_db.inc.php";
include "files/loginscript.inc.php";
include "files/errorcodesscript.inc.php";
if($LoggedIn == 'true') {
if($page == '1' || $page == '') {
?>
<form action="import" method="post" enctype="multipart/form-data">
<input type="hidden" name="page" value="2">
<input type="file" name="file"><br>
<button type="submit">Hochladen</button>
</form>
<?php
}
if($page == '2') {
$dateiname = $_FILES['file']['name'];
$groesse = $_FILES['file']['size'];
$typ = $_FILES['file']['type'];
$tmp_name = $_FILES['file']['tmp_name'];
$csv_mimetypes = array(
'text/csv',
'text/plain',
'application/csv',
'text/comma-separated-values',
'application/excel',
'application/vnd.ms-excel',
'application/vnd.msexcel',
'text/anytext',
'application/octet-stream',
'application/txt',
);
if (!in_array($_FILES['file']['type'], $csv_mimetypes)) {
echo "<p>Dies ist keine CSV-Datei! Ein <a href='https://www.convertio.co/de/'>Datei-Converter</a> kann helfen.</p>";
}
else {
if($groesse >= '500000') {
die("Die Datei darf maximal 5 Megabyte gro&szlig; sein! <button onclick=\"window.location.href='import'\">Zur&uuml;ck</button>");
}
$dateiname_tmp = hash('crc32',$dateiname);
move_uploaded_file(
$_FILES['file']['tmp_name'] ,
'temporary/'. $dateiname_tmp);
$pfad = 'temporary/' . $dateiname_tmp;
print("<h4>Stimmt das so?</h4><h2><b>$dateiname</b></h2><table class='vok-table'><tr><td>Muttersprache</td><td>Fremdsprache</td></tr>");
$row = 1;
if (($handle = fopen($pfad, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 4096, ",")) !== FALSE) {
if($row == '1') {
$row++;
$c = '0';
}
else {
if($row == '2') {
print("<tr>");
$row++;
for ($c=0; $c < '2'; $c++) {
echo "<td>" . $data[$c] . "</td>\n";
}
print("</tr>");
}
else {
print("<tr>");
$row++;
for ($c=0; $c < '2'; $c++) {
echo "<td>" . $data[$c] . "</td>\n";
}
print("</tr>");
}
}
}
fclose($handle);
}
?>
</table>
<button onclick=\"window.location.href='actions/add-vokab'\" class='classic-button classic-button-grey'>
<i class='fas fa-download'> </i>
Importieren
</button>
<?php
}
}
}
?>
</div>
<a class="no-formatting impressum" href="https://www.timvandenboom.de/impressum">Impressum</a>
</main>
<a id='back-arrow' class='fas fa-arrow-left back no-formatting' href='index?folderID=<?php print("$folderID") ?>'></a>
</body>
</html>
<?php */ ?>