funktionierende Seite, bereit fürs Testing
This commit is contained in:
parent
08d5f3c68f
commit
9dfe5d8a5e
1000
MOCK_DATA.json
1000
MOCK_DATA.json
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,9 @@
|
|||
{
|
||||
"require": {
|
||||
"phpmailer/phpmailer": "^6.4",
|
||||
"phpmailer/phpmailer": "^6.4.1",
|
||||
"rakit/validation": "v1.4.0",
|
||||
"ext-pdo": "*"
|
||||
}
|
||||
},
|
||||
"name": "digihelfer/alumni",
|
||||
"description": ""
|
||||
}
|
||||
|
|
|
@ -4,20 +4,84 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "59230ec995edc426fe883cde9a32b541",
|
||||
"content-hash": "727d168ee56a61f6a6c16e13977daac8",
|
||||
"packages": [
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v6.4.0",
|
||||
"name": "parsecsv/php-parsecsv",
|
||||
"version": "1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||
"reference": "050d430203105c27c30efd1dce7aa421ad882d01"
|
||||
"url": "https://github.com/parsecsv/parsecsv-for-php.git",
|
||||
"reference": "b444afae2f407537ae713f98a7a0c94e296918e6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/050d430203105c27c30efd1dce7aa421ad882d01",
|
||||
"reference": "050d430203105c27c30efd1dce7aa421ad882d01",
|
||||
"url": "https://api.github.com/repos/parsecsv/parsecsv-for-php/zipball/b444afae2f407537ae713f98a7a0c94e296918e6",
|
||||
"reference": "b444afae2f407537ae713f98a7a0c94e296918e6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/support": "Fluent array interface for map functions"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ParseCsv\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jim Myhrberg",
|
||||
"email": "contact@jimeh.me"
|
||||
},
|
||||
{
|
||||
"name": "William Knauss",
|
||||
"email": "will.knauss@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Susann Sgorzaly",
|
||||
"homepage": "https://github.com/susgo"
|
||||
},
|
||||
{
|
||||
"name": "Christian Bläul",
|
||||
"homepage": "https://github.com/Fonata"
|
||||
}
|
||||
],
|
||||
"description": "CSV data parser for PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/parsecsv/parsecsv-for-php/issues",
|
||||
"source": "https://github.com/parsecsv/parsecsv-for-php"
|
||||
},
|
||||
"time": "2021-04-14T18:14:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v6.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||
"reference": "9256f12d8fb0cd0500f93b19e18c356906cbed3d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/9256f12d8fb0cd0500f93b19e18c356906cbed3d",
|
||||
"reference": "9256f12d8fb0cd0500f93b19e18c356906cbed3d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -72,7 +136,7 @@
|
|||
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
|
||||
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.4.0"
|
||||
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.4.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -80,7 +144,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-31T20:06:42+00:00"
|
||||
"time": "2021-04-29T12:25:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "rakit/validation",
|
||||
|
@ -135,7 +199,9 @@
|
|||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform": {
|
||||
"ext-pdo": "*"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.0.0"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
create table entries(id bigint auto_increment primary key, name varchar(255), mail varchar(255) unique,
|
||||
year int(4), birthday date, verify bool, vocation varchar(255)
|
||||
create table entries(id bigint auto_increment primary key, name varchar(255), mail varchar(255),
|
||||
year int(4), birthday date, verify bool, vocation varchar(255), creation DATE
|
||||
);
|
||||
|
||||
create table verify(id bigint primary key, uuid VARCHAR(36),foreign key verify(id) REFERENCES entries(id));
|
||||
|
|
12
login.php
12
login.php
|
@ -1,23 +1,25 @@
|
|||
<?php
|
||||
require_once 'general.php';
|
||||
|
||||
returnHeader();
|
||||
session_start();
|
||||
$config = getConfig();
|
||||
|
||||
if (isset($_POST['user']) && !empty($_POST['user'])
|
||||
&& !empty($_POST['password'])) {
|
||||
if (isset($_POST['user']) && !empty($_POST['user']) && !empty($_POST['password'])) {
|
||||
|
||||
if ($_POST['user'] == $config['user'] && $_POST['password'] == $config['password']) {
|
||||
$_SESSION['user'] = "Hello World";
|
||||
?>
|
||||
Solltest du nicht weitergeleitet werden, klicke
|
||||
<a href="overview.php">hier</a>
|
||||
<?php
|
||||
header('Location: ' . $config['url'] . '/overview.php');
|
||||
die();//https://thedailywtf.com/articles/WellIntentioned-Destruction
|
||||
}
|
||||
else {
|
||||
echo "passwort nicht akzeptiert";
|
||||
echo "Passwort nicht akzeptiert";
|
||||
}
|
||||
}
|
||||
|
||||
returnHeader();
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
|
|
43
overview.php
43
overview.php
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
|
||||
|
||||
require_once 'general.php';
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
session_start();
|
||||
if(!isset($_SESSION['user'])) {
|
||||
|
@ -8,8 +11,6 @@ if(!isset($_SESSION['user'])) {
|
|||
exit;
|
||||
}
|
||||
|
||||
returnHeader();
|
||||
|
||||
$statement = getDatabase()->prepare("SELECT * from entries WHERE verify = 1");
|
||||
|
||||
if(!$statement->execute()) {
|
||||
|
@ -18,6 +19,39 @@ if(!$statement->execute()) {
|
|||
|
||||
$entries = $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if($_GET['export'] != null) {
|
||||
if($statement->rowCount() > 0){
|
||||
$delimiter = ";";
|
||||
$filename = "ehemalige_" . date('Y-m-d') . ".csv";
|
||||
|
||||
//create a file pointer
|
||||
$f = fopen('php://memory', 'w');
|
||||
|
||||
//set column headers
|
||||
$fields = array("ID", "Name", "E-Mail", "Abschlussjahrgang", "Geburtstag", "Email validiert", "Tätigkeit", "Eintragungsdatum");
|
||||
fputcsv($f, $fields, $delimiter);
|
||||
|
||||
//output each row of the data, format line as csv and write to file pointer
|
||||
foreach ($entries as $entry) {
|
||||
$lineData = array($entry['id'], $entry['name'], $entry['mail'], $entry['year'], $entry['birthday'], $entry['verify'], $entry['vocation'], $entry['creation']);
|
||||
fputcsv($f, $lineData, $delimiter);
|
||||
}
|
||||
|
||||
//move back to beginning of file
|
||||
fseek($f, 0);
|
||||
|
||||
//set headers to download file rather than displayed
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '";');
|
||||
|
||||
//output all remaining data on a file pointer
|
||||
fpassthru($f);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
returnHeader();
|
||||
|
||||
?>
|
||||
|
||||
<div class="flex flex-col">
|
||||
|
@ -26,7 +60,7 @@ $entries = $statement->fetchAll(PDO::FETCH_ASSOC);
|
|||
<div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg relative space-y-32">
|
||||
|
||||
<div class="md:mt-6 top-0 right-0 absolute">
|
||||
<button class="bg-blue-500 px-2 py-2 text-lg font-semibold tracking-wider text-white rounded hover:bg-blue-600">als CSV exportieren</button>
|
||||
<a href="overview.php?export=true" class="bg-blue-500 px-2 py-2 text-lg font-semibold tracking-wider text-white rounded hover:bg-blue-600">als CSV exportieren</a>
|
||||
<a href="logout.php" class="bg-blue-500 px-4 py-2 text-lg font-semibold tracking-wider text-white rounded hover:bg-blue-600">ausloggen</a>
|
||||
</div>
|
||||
|
||||
|
@ -38,6 +72,7 @@ $entries = $statement->fetchAll(PDO::FETCH_ASSOC);
|
|||
<th>E-Mail Adresse</th>
|
||||
<th>Jahrgang</th>
|
||||
<th>Alter</th>
|
||||
<th>Eintragung</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -47,6 +82,7 @@ $entries = $statement->fetchAll(PDO::FETCH_ASSOC);
|
|||
|
||||
foreach ($entries as $entry) {
|
||||
$age = date_diff(date_create($entry['birthday']), date_create('now'))->y;
|
||||
$creationDate = date_create($entry["creation"]);
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $entry["name"] ?></td>
|
||||
|
@ -54,6 +90,7 @@ $entries = $statement->fetchAll(PDO::FETCH_ASSOC);
|
|||
<td><?php echo $entry["mail"] ?></td>
|
||||
<td><?php echo $entry["year"] ?></td>
|
||||
<td><?php echo $age ?></td>
|
||||
<td><?php echo date_format($creationDate, "d.m.Y") ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != "POST") {
|
||||
die();
|
||||
}
|
||||
* */
|
||||
|
||||
require_once 'general.php';
|
||||
require_once 'vendor/autoload.php';
|
||||
|
@ -48,7 +47,7 @@ $validData['verify'] = 0;
|
|||
unset($validData['privacy']);
|
||||
|
||||
$db = getDatabase();
|
||||
$statement = $db->prepare("INSERT INTO entries(name, mail, year, birthday, verify, vocation) VALUES (:name, :email, :year, :birthday, :verify, :vocation)");
|
||||
$statement = $db->prepare("INSERT INTO entries(name, mail, year, birthday, verify, vocation, creation) VALUES (:name, :email, :year, :birthday, :verify, :vocation, CURDATE())");
|
||||
|
||||
if(!$statement->execute($validData)) {
|
||||
echo "Datenbank Fehler";
|
||||
|
@ -75,6 +74,7 @@ $mail = new PHPMailer(true);
|
|||
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$mail->Host = $config['mail_server'];
|
||||
$mail->Port = $config['mail_port'];
|
||||
$mail->Username = $config['mail_user'];
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
require_once 'general.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != "GET") {
|
||||
die();
|
||||
}
|
||||
|
||||
$uuid = $_GET['id'];
|
||||
if($uuid == null) {
|
||||
die();
|
||||
}
|
||||
|
||||
$db = getDatabase();
|
||||
$statement = $db->prepare("SELECT id from verify WHERE uuid = :uuid");
|
||||
if(!$statement->execute(['uuid' => $uuid])) {
|
||||
echo "Database Error";
|
||||
die();
|
||||
}
|
||||
|
||||
if($statement->rowCount() != 1) {
|
||||
echo "Kein Eintrag mit dieser ID gefunden";
|
||||
die();
|
||||
}
|
||||
|
||||
$id = $statement->fetch(PDO::FETCH_ASSOC)['id'];
|
||||
if($id == null) {
|
||||
die();
|
||||
}
|
||||
|
||||
$statement = $db->prepare("UPDATE entries SET verify = 1 WHERE id = :id");
|
||||
if(!$statement->execute(['id' => $id])) {
|
||||
echo "Database Error";
|
||||
die();
|
||||
}
|
||||
|
||||
$statement = $db->prepare("DELETE FROM verify WHERE id = :id");
|
||||
if(!$statement->execute(['id' => $id])) {
|
||||
echo "Database Error";
|
||||
die();
|
||||
}
|
||||
|
||||
echo "Danke für die Bestätigung";
|
Loading…
Reference in New Issue