Dateien nach "public" hochladen
This commit is contained in:
parent
e5accf1ea6
commit
b193d1c5ce
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
// Benutzername und Passwort für den Zugriff auf die Adminseite
|
||||
$admin_username = 'admin';
|
||||
$admin_password = 'Lena0308+'; // Sie sollten ein starkes Passwort verwenden
|
||||
|
||||
// Überprüfen, ob das Formular abgesendet wurde und die Benutzername-Passwort-Kombination korrekt ist
|
||||
if (isset($_POST['username']) && isset($_POST['password'])) {
|
||||
$entered_username = $_POST['username'];
|
||||
$entered_password = $_POST['password'];
|
||||
|
||||
// Überprüfen, ob Benutzername und Passwort korrekt sind
|
||||
if ($entered_username === $admin_username && $entered_password === $admin_password) {
|
||||
// Benutzername und Passwort korrekt, setze eine Session-Variable um den Zugriff zu markieren
|
||||
session_start();
|
||||
$_SESSION['admin_logged_in'] = true;
|
||||
} else {
|
||||
// Benutzername oder Passwort falsch
|
||||
echo "Falscher Benutzername oder Passwort.";
|
||||
}
|
||||
}
|
||||
|
||||
// Überprüfen, ob der Administrator eingeloggt ist
|
||||
session_start();
|
||||
if (!isset($_SESSION['admin_logged_in']) || !$_SESSION['admin_logged_in']) {
|
||||
// Der Administrator ist nicht eingeloggt, zeige das Login-Formular
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/png" href="../img/logo.png">
|
||||
<link rel="stylesheet" href="../css/admin.css">
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<h2>Login</h2>
|
||||
<form class="login-form" method="post" action="">
|
||||
<label for="username">Benutzername:</label>
|
||||
<input type="text" id="username" name="username" required><br>
|
||||
<label for="password">Passwort:</label>
|
||||
<input type="password" id="password" name="password" required><br>
|
||||
<input type="submit" value="Login">
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit; // Stoppe die Ausführung des restlichen Codes, da der Benutzer nicht eingeloggt ist
|
||||
}
|
||||
|
||||
// Überprüfen, ob die letzte Aktivitätszeit vorhanden ist und mehr als 15 Minuten vergangen sind
|
||||
if (isset($_SESSION['last_activity'])) {
|
||||
$inactive_time = 15 * 60; // 15 Minuten in Sekunden
|
||||
$current_time = time();
|
||||
$elapsed_time = $current_time - $_SESSION['last_activity'];
|
||||
|
||||
if ($elapsed_time > $inactive_time) {
|
||||
// Abmeldung des Benutzers aufgrund von Inaktivität
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header("Location: logout.php"); // Leite den Benutzer zur Logout-Seite weiter
|
||||
exit;
|
||||
} else {
|
||||
// Aktualisiere die letzte Aktivitätszeit
|
||||
$_SESSION['last_activity'] = time();
|
||||
}
|
||||
}
|
||||
|
||||
require_once '../vendor/autoload.php'; // Include barcode library
|
||||
|
||||
// Funktion zum Generieren des Barcodes
|
||||
function generateBarcode($ean)
|
||||
{
|
||||
// Überprüfen, ob die EAN gültig ist (nur Zahlen und Länge 13)
|
||||
if (ctype_digit($ean) && strlen($ean) == 13) {
|
||||
$generator = new Picqer\Barcode\BarcodeGeneratorHTML();
|
||||
return $generator->getBarcode($ean, $generator::TYPE_EAN_13);
|
||||
} else {
|
||||
return "Ungültige EAN";
|
||||
}
|
||||
}
|
||||
|
||||
// Datenbankverbindung herstellen und Daten abrufen
|
||||
$config = include '../config/config.php';
|
||||
$conn = new mysqli($config['servername'], $config['username'], $config['password'], $config['database']);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM articles";
|
||||
$result = $conn->query($sql);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/png" href="../img/logo.png">
|
||||
<title>Admin</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../css/admin.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2 class="table-title">Herdset Übersicht</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Hersteller</th>
|
||||
<th>Set Name</th>
|
||||
<th>Article Number</th>
|
||||
<th>EAN Barcode</th>
|
||||
<th>Backofen</th>
|
||||
<th>Backofen EAN</th>
|
||||
<th>Kochfeld</th>
|
||||
<th>Kochfeld EAN</th>
|
||||
<th>Auszug</th>
|
||||
<th>Auszug EAN</th>
|
||||
<th>Backblech</th>
|
||||
<th>Backblech EAN</th>
|
||||
<th>Pakete</th>
|
||||
</tr>
|
||||
<?php
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
echo "<tr>";
|
||||
echo "<td>" . $row["id"] . "</td>";
|
||||
echo "<td>" . $row["manufacturer"] . "</td>";
|
||||
echo "<td>" . $row["set_name"] . "</td>";
|
||||
echo "<td>" . $row["article_number"] . "</td>";
|
||||
echo "<td>" . generateBarcode($row["ean_barcode"]) . "</td>";
|
||||
echo "<td>" . $row["part1"] . "</td>";
|
||||
echo "<td>" . generateBarcode($row["part1_ean"]) . "</td>";
|
||||
echo "<td>" . $row["part2"] . "</td>";
|
||||
echo "<td>" . generateBarcode($row["part2_ean"]) . "</td>";
|
||||
echo "<td>" . $row["part3"] . "</td>";
|
||||
echo "<td>" . generateBarcode($row["part3_ean"]) . "</td>";
|
||||
echo "<td>" . $row["part4"] . "</td>";
|
||||
echo "<td>" . generateBarcode($row["part4_ean"]) . "</td>";
|
||||
echo "<td>" . $row["quantity"] . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
} else {
|
||||
echo "0 results";
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
</table>
|
||||
<a href="../includes/add_article_form.php" class="add-article-button">Hinzufügen</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
session_start();
|
||||
|
||||
// Überprüfen, ob der Benutzer bereits angemeldet ist
|
||||
if (isset($_SESSION['authenticated']) && $_SESSION['authenticated'] === true) {
|
||||
if ($_SESSION['access_level'] === 'all') {
|
||||
header('Location: /admin.php');
|
||||
exit;
|
||||
} elseif ($_SESSION['access_level'] === 'limited') {
|
||||
header('Location: /search.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
include 'auth.php';
|
||||
|
||||
// Überprüfen, ob ein POST-Request gesendet wurde
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
|
||||
// Authentifizierung des Benutzers
|
||||
if (authenticate($username, $password)) {
|
||||
// Benutzer ist erfolgreich angemeldet
|
||||
if ($_SESSION['access_level'] === 'all') {
|
||||
header('Location: admin.php');
|
||||
exit;
|
||||
} elseif ($_SESSION['access_level'] === 'limited') {
|
||||
header('Location: search.php');
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
// Falsche Anmeldeinformationen
|
||||
$error = "Falscher Benutzername oder Passwort.";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">Login</div>
|
||||
<div class="card-body">
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label for="username">Benutzername:</label>
|
||||
<input type="text" class="form-control" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Passwort:</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Login</button>
|
||||
</form>
|
||||
<?php if (isset($error)) : ?>
|
||||
<div class="alert alert-danger mt-3" role="alert"><?= $error ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header("Location: login.php"); // Leiten Sie den Benutzer zur Login-Seite weiter
|
||||
exit;
|
||||
?>
|
|
@ -0,0 +1,196 @@
|
|||
<?php
|
||||
include '../includes/database.php';
|
||||
require_once('../vendor/tecnickcom/tcpdf/tcpdf.php');
|
||||
require_once('../vendor/autoload.php');
|
||||
|
||||
$articleData = [];
|
||||
$error = "";
|
||||
|
||||
function createPdfFolder($folder)
|
||||
{
|
||||
if (!file_exists($folder)) {
|
||||
if (!mkdir($folder, 0755, true)) {
|
||||
die('Fehler beim Erstellen des Verzeichnisses für PDFs.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pdfDirectory = dirname(__DIR__) . '/pdf';
|
||||
createPdfFolder($pdfDirectory);
|
||||
|
||||
function generateEANBarcode($eanNumber, $pdf)
|
||||
{
|
||||
$style = array(
|
||||
'border' => 0,
|
||||
'padding' => 0,
|
||||
'fgcolor' => array(0, 0, 0),
|
||||
'bgcolor' => false,
|
||||
'module_width' => 0.5,
|
||||
'module_height' => 10
|
||||
);
|
||||
return $pdf->write1DBarcode($eanNumber, 'EAN13', '', '', '', 20, 1, $style, 'N');
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$articleNumber = $_POST['article_number'];
|
||||
$setName = $_POST['set_name'];
|
||||
$sql = "SELECT * FROM articles WHERE article_number = ? OR set_name LIKE ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("ss", $articleNumber, $setName);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result) {
|
||||
if ($result->num_rows > 0) {
|
||||
$articleData = $result->fetch_assoc();
|
||||
} else {
|
||||
$error = "Artikel nicht gefunden.";
|
||||
}
|
||||
} else {
|
||||
$error = "Fehler beim Ausführen der Abfrage: " . $conn->error;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['download_pdf'])) {
|
||||
if (!empty($articleData)) {
|
||||
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||
$pdf->SetCreator(PDF_CREATOR);
|
||||
$pdf->SetAuthor('M_Viper');
|
||||
$pdf->SetTitle('Article Information');
|
||||
$pdf->SetSubject('Article Details');
|
||||
$pdf->SetKeywords('Article, Details, PDF');
|
||||
$pdf->AddPage();
|
||||
$pdf->SetFont('helvetica', '', 13);
|
||||
|
||||
$html = '
|
||||
<h3> </h3>
|
||||
<table style="border-collapse: collapse; width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
|
||||
<td style="width: 35%;">
|
||||
<h1 style="margin-left: 40px;"><strong>Hersteller: ' . $articleData['manufacturer'] . '</strong></h1>
|
||||
<p style="margin-left: 40px;"><strong>Bezeichnung: ' . $articleData['set_name'] . '</strong></p>
|
||||
<p style="margin-left: 40px;"><strong>Artikelnummer: ' . $articleData['article_number'] . '</strong></p>
|
||||
<p style="margin-left: 40px;"><strong>EAN: ' . $articleData['ean_barcode'] . '</strong></p>
|
||||
</td>
|
||||
<td style="width: 35%;">
|
||||
<h1 style="margin-left: 20px;"><img style="font-size: 14px; font-weight: 400; text-align: right;" src="https://m-viper.de/Logistik/img/ofen.png" alt="" width="120" height="120" /><strong><br /></strong></h1>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
||||
|
||||
// Adding additional tables for parts
|
||||
$parts = array(
|
||||
array("Bezeichnung" => "Backofen", "Teil" => $articleData['part1'], "EAN" => $articleData['part1_ean'], "Barcode" => $articleData['ean_barcode'], "Pakete" => $articleData['quantity']),
|
||||
array("Bezeichnung" => "Kochfeld", "Teil" => $articleData['part2'], "EAN" => $articleData['part2_ean'], "Barcode" => '', "Pakete" => ''),
|
||||
array("Bezeichnung" => "Auszug", "Teil" => $articleData['part3'], "EAN" => $articleData['part3_ean'], "Barcode" => '', "Pakete" => ''),
|
||||
array("Bezeichnung" => "Backblech", "Teil" => $articleData['part4'], "EAN" => $articleData['part4_ean'], "Barcode" => '', "Pakete" => '')
|
||||
);
|
||||
|
||||
foreach ($parts as $key => $part) {
|
||||
$barcode = ($part["Barcode"] && $key === 0) ? generateEANBarcode($part["Barcode"], $pdf) : '';
|
||||
$html .= '
|
||||
<table style="border-collapse: collapse; width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 70%; padding-left: 20px; border-bottom: 1px solid #000;">
|
||||
<p><strong>' . $part["Bezeichnung"] . ': ' . $part["Teil"] . '</strong></p>
|
||||
<p><strong>EAN: ' . $part["EAN"] . '</strong></p>
|
||||
</td>
|
||||
<td style="width: 30%; text-align: center; border-bottom: 1px solid #000;"><strong>' . ($barcode ? $barcode : '') . '</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3> </h3>';
|
||||
}
|
||||
|
||||
$html .= '
|
||||
<table style="border-collapse: collapse; width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 100%; text-align: center; border: 1px solid #000; font-size: 18px;"><strong>Pakete: ' . $articleData['quantity'] . '</strong></td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
$pdf->writeHTML($html);
|
||||
$pdf->Output($pdfDirectory . '/article_details.pdf', 'F');
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Disposition: attachment; filename="article_details.pdf"');
|
||||
readfile($pdfDirectory . '/article_details.pdf');
|
||||
exit;
|
||||
} else {
|
||||
$error = "Keine Artikelinformationen gefunden.";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="../css/search.css">
|
||||
<link rel="icon" type="image/png" href="../img/logo.png">
|
||||
<title>Einbauherdset Suche</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="title-image">
|
||||
<h1>Einbauherdset Suche</h1>
|
||||
<img src="../img/ofen.png" alt="Title Image">
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="search-box">
|
||||
<h2>Artikel Suche </h2>
|
||||
<form method="post">
|
||||
<label>Artikelnummer:</label>
|
||||
<input type="text" name="article_number" >
|
||||
<label>Setbezeichnung:</label>
|
||||
<input type="text" name="set_name">
|
||||
<input type="submit" value="Search">
|
||||
</form>
|
||||
</div>
|
||||
<div class="result-box">
|
||||
<h2>Artikel Details</h2>
|
||||
<?php if (!empty($articleData)) : ?>
|
||||
<div class="box">
|
||||
<h3>Hersteller: <?php echo $articleData['manufacturer']; ?></h3>
|
||||
</div>
|
||||
<div class="box">
|
||||
<p>Artikelnummer: <?php echo $articleData['article_number']; ?></p>
|
||||
<p>Bezeichnung: <?php echo $articleData['set_name']; ?></p>
|
||||
<p>EAN Barcode: <?php echo $articleData['ean_barcode']; ?></p>
|
||||
</div>
|
||||
<?php $partNames = array('Backofen', 'Kochfeld', 'Auszug', 'Backblech'); ?>
|
||||
<?php for ($i = 1; $i <= 4; $i++) : ?>
|
||||
<?php $partKey = "part{$i}"; ?>
|
||||
<?php $eanKey = "{$partKey}_ean"; ?>
|
||||
<?php if (!empty($articleData[$partKey])) : ?>
|
||||
<div class="box">
|
||||
<h3><?php echo $partNames[$i-1]; ?>:</h3>
|
||||
<p>Bezeichnung: <?php echo $articleData[$partKey]; ?></p>
|
||||
<p>EAN Barcode: <?php echo $articleData[$eanKey]; ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endfor; ?>
|
||||
<div class="box">
|
||||
<h3>Pakete:</h3>
|
||||
<p><?php echo $articleData['quantity']; ?></p>
|
||||
</div>
|
||||
<form method="post">
|
||||
<input type="hidden" name="article_number" value="<?php echo $articleData['article_number']; ?>">
|
||||
<input type="submit" name="download_pdf" value="Download PDF">
|
||||
</form>
|
||||
<?php elseif ($error) : ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<a href="admin.php" class="watermark">Copyright 2024 M_Viper</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue