🔀 merge pull request 'v1.1.0' (#63) from dev into main

Reviewed-on: #63
This commit is contained in:
DrMaxNix 2024-02-20 21:55:58 +01:00
commit 38df57e2ac
45 changed files with 11455 additions and 56 deletions

2
.dat/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

41
.env.template.php Normal file
View File

@ -0,0 +1,41 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
class Env {
/**
* Configuration for sending mail.
*/
const MAIL = [
// SMTP SERVER //
// smtp server address
"host" => "smtp.example.com",
// smtp port
"port" => 587,
// smtp username
"username" => "noreply@example.com",
// smtp password
"password" => "topsecret123",
// whether starttls should be used
// (ssl/tls will be used otherwise)
"starttls" => true
];
/**
* Configuration for admin area.
*/
const ADMIN_AREA = [
// AUTHENTICATION //
// hashed auth token used for login
// generate using `php -r 'echo(password_hash("yourtokenhere", PASSWORD_DEFAULT));'`
// token should have at least 32 characters
"auth_token_hash" => '<hashed token>'
];
}
?>

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
meta.local.php
init.local.php
/.env.php

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Kim Endisch
Copyright (c) 2024 Kim Endisch
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@ -1,2 +1,9 @@
# SBGG.jetzt
Website documenting the progress of the German Selbstbestimmungsgesetz.
Everything about the German Self-Determination Law in one place
## Attribution / Credits
- Tabler Icons (MIT): https://github.com/tabler/tabler-icons
- Ubuntu font (Ubuntu font licence 1.0): https://design.ubuntu.com/font
- PHPMailer ([LGPL-2.1](lib/phpmailer/LICENSE)): https://github.com/PHPMailer/PHPMailer

View File

@ -0,0 +1,84 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Excuse;
use Flake\Id64;
// CHECK CSRF PROTECTION //
$x_cookieless_csrf_protection = getallheaders()["x-cookieless-csrf-protection"] ?? null;
if($x_cookieless_csrf_protection !== "42"){
// show an excuse page
Excuse::show("invalid_csrf_token");
}
// DECODE REQUEST //
// get json string
$json_body = file_get_contents("php://input");
if(strlen($json_body) <= 0){
http_response_code(400);
echo("malformed request body");
die();
}
// try decoding json
$request = json_decode($json_body, true);
if(json_last_error() != JSON_ERROR_NONE){
http_response_code(400);
echo("malformed request body");
die();
}
// VALIDATE VALUES //
// mail address
$mail_address = $request["mail_address"] ?? "";
if(!is_string($mail_address)){
http_response_code(400);
echo("invalid mail address");
die();
}
if(!preg_match("/^[a-zA-Z0-9\.\-\_\+]+@([a-z0-9\-]+\.)+[a-z0-9\-]{2,}$/", $mail_address)){
http_response_code(400);
echo("invalid mail address");
die();
}
// verify key
$verify_key = $request["verify_key"] ?? null;
if(!Id64::is_valid($verify_key)){
http_response_code(400);
echo("invalid verify key");
die();
}
// TRY SUBSCRIBING //
// make sure session isn't locked
if(extension_loaded("session")) session_write_close();
// acquire runlock
ignore_user_abort(true);
// subscribe
if(Newsletter::subscribe(mail_address: $mail_address, verify_key: $verify_key)){
http_response_code(200);
echo(json_encode([
"success" => true
]));
} else {
http_response_code(200);
echo(json_encode([
"success" => false
]));
}
// EXECUTE WORK //
// close connection
Newsletter::api_helper_http_close_connection();
// execute queued work
Newsletter::queue_work();
?>

View File

@ -0,0 +1,81 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Excuse;
use Flake\Id64;
// CHECK CSRF PROTECTION //
$x_cookieless_csrf_protection = getallheaders()["x-cookieless-csrf-protection"] ?? null;
if($x_cookieless_csrf_protection !== "42"){
// show an excuse page
Excuse::show("invalid_csrf_token");
}
// DECODE REQUEST //
// get json string
$json_body = file_get_contents("php://input");
if(strlen($json_body) <= 0){
http_response_code(400);
echo("malformed request body");
die();
}
// try decoding json
$request = json_decode($json_body, true);
if(json_last_error() != JSON_ERROR_NONE){
http_response_code(400);
echo("malformed request body");
die();
}
// VALIDATE VALUES //
// mail address
$mail_address = $request["mail_address"] ?? "";
if(!is_string($mail_address)){
http_response_code(400);
echo("invalid mail address");
die();
}
if(!preg_match("/^[a-zA-Z0-9\.\-\_\+]+@([a-z0-9\-]+\.)+[a-z0-9\-]{2,}$/", $mail_address)){
http_response_code(400);
echo("invalid mail address");
die();
}
// unsubscribe key
$unsubscribe_key = $request["unsubscribe_key"] ?? null;
if(!Id64::is_valid($unsubscribe_key)){
http_response_code(400);
echo("invalid unsubscribe key");
die();
}
// REMOVE FROM MAILING LIST //
// make sure session isn't locked
if(extension_loaded("session")) session_write_close();
// unsubscribe
if(Newsletter::unsubscribe(mail_address: $mail_address, unsubscribe_key: $unsubscribe_key)){
http_response_code(200);
echo(json_encode([
"success" => true
]));
} else {
http_response_code(200);
echo(json_encode([
"success" => false
]));
}
// EXECUTE WORK //
// close connection
Newsletter::api_helper_http_close_connection();
// execute queued work
Newsletter::queue_work();
?>

78
api/newsletter/verify.php Normal file
View File

@ -0,0 +1,78 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Excuse;
// CHECK CSRF PROTECTION //
$x_cookieless_csrf_protection = getallheaders()["x-cookieless-csrf-protection"] ?? null;
if($x_cookieless_csrf_protection !== "42"){
// show an excuse page
Excuse::show("invalid_csrf_token");
}
// DECODE REQUEST //
// get json string
$json_body = file_get_contents("php://input");
if(strlen($json_body) <= 0){
http_response_code(400);
echo("malformed request body");
die();
}
// try decoding json
$request = json_decode($json_body, true);
if(json_last_error() != JSON_ERROR_NONE){
http_response_code(400);
echo("malformed request body");
die();
}
// VALIDATE VALUES //
// mail address
$mail_address = $request["mail_address"] ?? "";
if(!is_string($mail_address)){
http_response_code(400);
echo("invalid mail address");
die();
}
if(!preg_match("/^[a-zA-Z0-9\.\-\_\+]+@([a-z0-9\-]+\.)+[a-z0-9\-]{2,}$/", $mail_address)){
http_response_code(400);
echo("invalid mail address");
die();
}
// language
$language = $request["language"] ?? "";
if(!in_array($language, ["de", "en"])){
http_response_code(400);
echo("invalid language");
die();
}
// VERIFY //
// make sure session isn't locked
if(extension_loaded("session")) session_write_close();
// acquire runlock
ignore_user_abort(true);
// add verify job to queue
Newsletter::verify(mail_address: $mail_address, language: $language);
// positive response
http_response_code(200);
echo(json_encode([
"success" => true
]));
// EXECUTE WORK //
// close connection
Newsletter::api_helper_http_close_connection();
// execute queued work
Newsletter::queue_work();
?>

46
api/static/index.php Normal file
View File

@ -0,0 +1,46 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Project;
use Flake\Excuse;
// GET REQUESTED FILENAME //
// get from url parameter
$filename = Project::param("filename");
// resolve to storage path
$__file_path = ([
"logo-1024.png" => "./asset/logo-1024.png",
"logo-2048.png" => "./asset/logo-2048.png",
"logo-256.png" => "./asset/logo-256.png",
"logo-512.png" => "./asset/logo-512.png",
"logo-bg-1024.png" => "./asset/logo-bg-1024.png",
"logo-bg-2048.png" => "./asset/logo-bg-2048.png",
"logo-bg-256.png" => "./asset/logo-bg-256.png",
"logo-bg-512.png" => "./asset/logo-bg-512.png",
"logo.svg" => "./asset/logo.svg"
])[$filename] ?? null;
// validate lookup
if($__file_path === null){
Excuse::show("not_found");
}
// SERVE FILE //
// make sure session isn't locked
if(extension_loaded("session")) session_write_close();
// general headers
header("Access-Control-Allow-Origin: *");
// content length
header("Content-Length: " . filesize($__file_path));
// mimetype
$mime_content_type = mime_content_type($__file_path);
header("Content-type: " . $mime_content_type);
// file
readfile($__file_path);
?>

7
init.php Normal file
View File

@ -0,0 +1,7 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
// LOAD ENV CONFIG //
require_once("./.env.php");
?>

502
lib/phpmailer/LICENSE Normal file
View File

@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -0,0 +1,40 @@
<?php
/**
* PHPMailer Exception class.
* PHP Version 5.5.
*
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2020 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace PHPMailer\PHPMailer;
/**
* PHPMailer exception handler.
*
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
*/
class Exception extends \Exception
{
/**
* Prettify error message output.
*
* @return string
*/
public function errorMessage()
{
return '<strong>' . htmlspecialchars($this->getMessage(), ENT_COMPAT | ENT_HTML401) . "</strong><br />\n";
}
}

File diff suppressed because it is too large Load Diff

1497
lib/phpmailer/src/SMTP.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,23 @@
<?php
// VERSION //
static::$version = "1.0.43";
static::$version = "1.1.0";
// DEPENDENCIES //
// used extensions
static::$ext[] = "dat";
static::$ext[] = "request";
static::$ext[] = "lang";
static::$ext[] = "page";
static::$ext[] = "file";
static::$ext[] = "hidden";
static::$ext[] = "project";
static::$ext[] = "excuse";
static::$ext[] = "error";
static::$ext[] = "url";
static::$ext[] = "id64";
static::$ext[] = "cookieaccept";
static::$ext[] = "csrf";
// ROUTES //
@ -24,7 +31,23 @@
// pages
static::$route["sbgg.jetzt"] = [
["path" => "", "target" => "page/start"],
["path" => ":lang", "target" => "page/start"]
["path" => "", "target" => "page/start"],
["path" => ":lang", "target" => "page/start"],
["path" => "newsletter/subscribe", "target" => "page/newsletter/subscribe"],
["path" => "newsletter/unsubscribe", "target" => "page/newsletter/unsubscribe"],
["path" => "static/:filename", "target" => "api/static"],
["path" => "api/newsletter/verify", "target" => "api/newsletter/verify.php"],
["path" => "api/newsletter/subscribe", "target" => "api/newsletter/subscribe.php"],
["path" => "api/newsletter/unsubscribe", "target" => "api/newsletter/unsubscribe.php"],
["path" => "admin", "target" => "page/admin/start"],
["path" => "admin/login", "target" => "page/admin/login"],
["path" => "admin/newsletter", "target" => "page/admin/newsletter/overview.php"],
["path" => "admin/newsletter/:content", "target" => "page/admin/newsletter/content.php"],
["path" => "admin/newsletter/api/send-one", "target" => "page/admin/newsletter/api/send_one.php"],
["path" => "admin/newsletter/api/send-all", "target" => "page/admin/newsletter/api/send_all.php"],
];
?>

View File

@ -0,0 +1,25 @@
<?php
return [
"subject" => [
"de" => "SBGG.jetzt: Anmeldung Newsletter",
"en" => "SBGG.jetzt: Newsletter Subscription"
],
"main" => [
"de" => <<<HTML
<h2>Anmeldung Bestätigen</h2>
<p>Du hast soeben die Anmeldung zum SBGG.jetzt Newsletter beantragt. Aus Datenschutz-Gründen musst Du deine E-Mail Adresse verifizieren.</p>
<p>Um Dich für den Newsletter anzumelden, klicke bitte auf den <i>Verifizieren</i> Link unten.</p>
HTML,
"en" => <<<HTML
<h2>Confirm Subscription</h2>
<p>You have just requested to subscribe to the SBGG.jetzt newsletter. For privacy reasons, you have to verify your mail address.</p>
<p>In order to subscribe to the newsletter, please click the <i>Verify</i> link below.</p>
HTML
]
];
?>

View File

@ -0,0 +1,35 @@
<?php
return [
"subject" => [
"de" => "SBGG.jetzt: Willkommen im Newsletter!",
"en" => "SBGG.jetzt: Welcome to the newsletter!"
],
"main" => [
"de" => <<<HTML
<h2>Willkommen im Newsletter!</h2>
<p>Hey! Du wurdest soeben für den SBGG.jetzt Newsletter angemeldet. Falls Du dich nicht selbst angemeldet hast, kannst Du dich über den <i>Abbestellen</i> Link wieder abmelden.</p>
<p>Du wirst ab sofort per Mail über alle Neuigkeiten zum Selbstbestimmungsgesetz informiert.</p>
<p>Solltest Du Fragen oder Anregungen zum Newsletter haben, bin ich gerne unter <a href="mailto:mail@sbgg.jetzt">mail@sbgg.jetzt</a> erreichbar.</p>
<p>Cheers,<br />
Kim</p>
HTML,
"en" => <<<HTML
<h2>Welcome to the Newsletter!</h2>
<p>Hey! You have just been subscribed to the SBGG.jetzt newsletter. If you have not registered yourself, you can unsubscribe using the <i>Unsubscribe</i> link.</p>
<p>From now on, you will be informed about all the news related to the Self-Determination Law by email.</p>
<p>If you have any questions or suggestions regarding the newsletter, feel free to contact me via <a href="mailto:mail@sbgg.jetzt">mail@sbgg.jetzt</a>.</p>
<p>Cheers,<br />
Kim</p>
HTML
]
];
?>

View File

@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="{{dataset:language}}" dir="ltr" data-content-name="{{name}}">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<style media="screen">
* {
box-sizing: border-box;
}
body {
margin: 8px;
background-color: #21252b;
color: #c5cad3;
font-family: "Helvetica Neue", "Segoe UI", Helvetica, sans-serif;
}
table {
border-collapse: collapse;
}
hr {
margin: 24px 0;
border-color: #5c6370;
}
a {
text-decoration: none;
color: #98c379;
}
a:hover {
text-decoration: underline;
}
br.gone {
display: none;
}
.gray {
color: #828997;
}
.page-container {
max-width: 512px;
margin: 128px auto;
}
.page {
padding: 32px;
margin-bottom: 48px;
border-radius: 32px;
background-color: #2c313a;
color: #c5cad3;
}
.footer {
color: #828997;
}
.footer a {
color: #618349;
}
.footer .gray {
color: #454b54;
}
.footer center {
margin-top: 8px;
}
</style>
</head>
<body>
<div class="page-container">
<div class="page">
<center>
<table>
<tbody>
<tr>
<td><img src="{{const:url_prefix}}/static/logo-256.png" alt="" style="height: 64px;" /></td>
<td><h1>SBGG.jetzt</h1></td>
</tr>
</tbody>
</table>
</center>
<hr />
{{main}}
<hr />
{{template-if-isset-dataset:unsubscribe_key,unsubscribe_link}}
{{template-if-isset-dataset:verify_key,verify_link}}
</div>
<div class="footer">
<center>SBGG.jetzt&ensp;<a href="https://git.tjdev.de/kimendisch/sbgg.jetzt">{{text_sourcecode}}</a>&ensp;<span class="gray">v{{const:version}}</span></center><br class="gone" />
<center>&copy; 2024 Kim Endisch&ensp;<span class="gray">|</span>&ensp;<a href="{{link_imprint}}">{{text_imprint}}</a>&ensp;<span class="gray">|</span>&ensp;<a href="{{link_privacy_policy}}">{{text_privacy_policy}}</a></center>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1 @@
<center><a href="{{const:url_prefix}}/newsletter/unsubscribe?mail_address={{dataset:mail_address_urlencoded}}&key={{dataset:unsubscribe_key}}&slang={{dataset:language}}">{{text_unsubscribe}}</a></center>

View File

@ -0,0 +1 @@
<center><a href="{{const:url_prefix}}/newsletter/subscribe?mail_address={{dataset:mail_address_urlencoded}}&key={{dataset:verify_key}}&slang={{dataset:language}}">{{text_verify}}</a></center>

View File

@ -0,0 +1,25 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Url_Redirect;
use Flake\Request;
// CHECK AUTHENTICATION //
// redirect to login page when not logged in
$login = $_SESSION[__NAMESPACE__]["admin"]["login"] ?? null;
if($login !== true){
Url_Redirect::location("http" . (Request::has_ssl() ? "s" : "") . "://" . Request::domain_raw_full() . "/admin/login");
die();
}
// MAYBE DO LOGOUT //
if(isset($_GET["logout"])){
// unset session flag
$_SESSION[__NAMESPACE__]["admin"]["login"] = false;
// redirect to login page
Url_Redirect::location("http" . (Request::has_ssl() ? "s" : "") . "://" . Request::domain_raw_full() . "/admin/login");
die();
}
?>

34
page/admin/footer.php Normal file
View File

@ -0,0 +1,34 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Project;
use Flake\File;
use Flake\Cookieaccept;
?>
<div class="footer">
<div class="brand">
<img src="<?= File::file("./asset/logo-256.png") ?>" alt="logo" />
<span>SBGG.jetzt</span>
<a href="https://git.tjdev.de/kimendisch/sbgg.jetzt" target="_blank"><?= $dict->get("text_sourcecode") ?> <i class="ti ti-external-link"></i></a>
<span class="version">v<?= Project::version() ?></span>
</div>
<?php if(Cookieaccept::is_accepted()){ ?>
<div class="cookierevoke">
<a href="?cookieaccept=0">Revoke Cookie Permission</a>
</div>
<?php } ?>
<div class="legal">
<span>&copy; 2024 Kim Endisch</span>
<span class="delimiter">|</span>
<a href="<?= $dict->get("link_imprint") ?>" target="_blank"><?= $dict->get("text_imprint") ?> <i class="ti ti-external-link"></i></a>
<span class="delimiter">|</span>
<a href="<?= $dict->get("link_privacy_policy") ?>" target="_blank"><?= $dict->get("text_privacy_policy") ?> <i class="ti ti-external-link"></i></a>
</div>
</div>

120
page/admin/login/index.php Normal file
View File

@ -0,0 +1,120 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Url_Redirect;
use Flake\Request;
use Flake\Lang;
use Flake\Lang_Dict;
use Flake\Page;
use Flake\Cookieaccept;
use Flake\Csrf;
// CHECK AUTHENTICATION //
// redirect to start page when logged in
$login = $_SESSION[__NAMESPACE__]["admin"]["login"] ?? null;
if($login === true){
Url_Redirect::location("http" . (Request::has_ssl() ? "s" : "") . "://" . Request::domain_raw_full() . "/admin");
die();
}
// HANDLE LOGIN //
require(__DIR__ . "/login_handler.php");
// LANGUAGE MANAGER //
// hack: fake get param from constant
$_GET["lang"] = "en";
// initialize
$lang = new Lang(list: ["de", "en"], default: "en");
// load dict
$dict = new Lang_Dict($lang);
require("./page/strings.php");
// PAGE INIT //
Page::start();
Page::title("SBGG.jetzt - Admin Area");
Page::icon("./asset/logo-256.png");
Page::lang($lang->get());
Page::viewport(scale: 1, zoom: true);
Page::robots(index: false, follow: false);
Page::author("Kim Endisch");
Page::$head["analytics"] = '<script defer data-domain="sbgg.jetzt" src="https://analytics.tjdev.de/js/script.js"></script>';
Page::css("./page/start/style.css");
Page::css(__DIR__ . "/style.css");
Page::font("ubuntu");
Page::font("tabler");
?>
<?php if(!Cookieaccept::is_accepted()){ ?>
<div class="cookie-notice-required">
<div class="box important">
<span class="title"><i class="ti ti-cookie"></i>Cookies</span>
<div class="description">
<span>This page needs cookies to function correctly.</span>
<span>Cookies are only used for required purposes.</span>
<span>You can read more about this in our <a href="<?= $dict->get("link_privacy_policy") ?>" target="_blank"><?= $dict->get("text_privacy_policy") ?> <i class="ti ti-external-link"></i></a>.</span>
</div>
<div class="button-list">
<a class="button" href="?cookieaccept=1">
<span class="icon ti ti-check"></span>
<span class="text">Accept</span>
</a>
</div>
</div>
</div>
<?php } ?>
<div class="page-container">
<div class="page">
<div class="section">
<div class="content rows">
<div id="login" class="box">
<span class="title">Admin Area</span>
<form id="login-form" class="form" method="post" action="">
<div class="key-value-pair">
<div class="key">
<span class="ti ti-key"></span>
</div>
<div class="value-list">
<input id="login-form-token" class="value" type="password" name="token" placeholder="Authentication Token" autocomplete="off" required />
</div>
</div>
<input type="hidden" name="csrf_token" value="<?= Csrf::token() ?>" />
<button id="login-form-submit" class="button primary">
<span class="text">Login</span>
<span class="icon ti ti-chevron-right"></span>
</button>
</form>
<?php if(isset($_GET["login_failure"])){ ?>
<span id="login-feedback-negative">Login failed</span>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
<?php require(dirname(__DIR__) . "/footer.php"); ?>

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Url_Redirect;
use Flake\Csrf;
if(isset($_POST["token"])){
// VERIFY CSRF TOKEN //
Csrf::check();
// CHECK TOKEN //
// collect token from form submit
$token = $_POST["token"];
// load token hash from env
$auth_token_hash = Env::ADMIN_AREA["auth_token_hash"];
// check
$token_valid = password_verify($token, $auth_token_hash);
// MAYBE DO LOGIN //
if($token_valid){
// set session flag
$_SESSION[__NAMESPACE__]["admin"]["login"] = true;
// reload page
Url_Redirect::query_modify(remove: ["login_failure"]);
}
// LOGIN FAILED //
// display feedback after reload
Url_Redirect::query_modify(remove: ["login_failure"], add: ["login_failure"]);
}
?>

View File

@ -0,0 +1,43 @@
/* SECTION: LOGIN */
.section > .content.rows > #login {
align-items: flex-start;
flex-basis: 32rem;
flex-grow: 64;
}
#login-form-token {
min-width: 22rem;
}
#login-feedback-negative {
color: var(--color-red);
}
/* COOKIE NOTICE */
.cookie-notice-required {
position: fixed;
bottom: 6rem;
right: 2rem;
margin-left: 2rem;
z-index: 999;
}
@media only screen and (max-width: 1000px) {
.cookie-notice-required {
bottom: 8rem;
}
}
.cookie-notice-required .box.important {
border: 0.5rem solid var(--theme);
}
.cookie-notice-required .box a:not(.button) {
font-size: 1rem;
color: var(--theme);
}
.cookie-notice-required .box a:not(.button):hover {
text-decoration: underline;
}

View File

@ -0,0 +1,66 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Csrf;
// HANDLE AUTHENTICATION //
require("./page/admin/auth_handler.php");
// DECODE REQUEST //
// get json string
$json_body = file_get_contents("php://input");
if(strlen($json_body) <= 0){
http_response_code(400);
echo("malformed request body");
die();
}
// try decoding json
$request = json_decode($json_body, true);
if(json_last_error() != JSON_ERROR_NONE){
http_response_code(400);
echo("malformed request body");
die();
}
// VALIDATE VALUES //
// csrf token
Csrf::check(token: $request["csrf_token"] ?? "");
// content name
$content_name = $request["content_name"] ?? "";
if(!is_string($content_name)){
http_response_code(400);
echo("invalid content name");
die();
}
if(!preg_match("/^\d{4}-\d{2}-\d{2}(-[a-z0-9]+)+$/", $content_name)){
http_response_code(400);
echo("invalid content name");
die();
}
// TRY SENDING //
// make sure session isn't locked
if(extension_loaded("session")) session_write_close();
// add jobs to queue
Newsletter::send_all(content_name: $content_name);
// positive response
http_response_code(200);
echo(json_encode([
"success" => true
]));
// EXECUTE WORK //
// close connection
Newsletter::api_helper_http_close_connection();
// execute queued work
Newsletter::queue_work();
?>

View File

@ -0,0 +1,90 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Csrf;
// HANDLE AUTHENTICATION //
require("./page/admin/auth_handler.php");
// DECODE REQUEST //
// get json string
$json_body = file_get_contents("php://input");
if(strlen($json_body) <= 0){
http_response_code(400);
echo("malformed request body");
die();
}
// try decoding json
$request = json_decode($json_body, true);
if(json_last_error() != JSON_ERROR_NONE){
http_response_code(400);
echo("malformed request body");
die();
}
// VALIDATE VALUES //
// csrf token
Csrf::check(token: $request["csrf_token"] ?? "");
// mail address
$mail_address = $request["mail_address"] ?? "";
if(!is_string($mail_address)){
http_response_code(400);
echo("invalid mail address");
die();
}
if(!preg_match("/^[a-zA-Z0-9\.\-\_\+]+@([a-z0-9\-]+\.)+[a-z0-9\-]{2,}$/", $mail_address)){
http_response_code(400);
echo("invalid mail address");
die();
}
// content name
$content_name = $request["content_name"] ?? "";
if(!is_string($content_name)){
http_response_code(400);
echo("invalid content name");
die();
}
if(!preg_match("/^\d{4}-\d{2}-\d{2}(-[a-z0-9]+)+$/", $content_name)){
http_response_code(400);
echo("invalid content name");
die();
}
// CHECK WHETHER THIS ADDRESS IS A MEMBER //
if(!Newsletter::is_member(mail_address: $mail_address)){
http_response_code(200);
echo(json_encode([
"success" => false,
"reason" => "no_member"
]));
die();
}
// TRY SENDING //
// make sure session isn't locked
if(extension_loaded("session")) session_write_close();
// add job to queue
Newsletter::send_one(mail_address: $mail_address, content_name: $content_name);
// positive response
http_response_code(200);
echo(json_encode([
"success" => true
]));
// EXECUTE WORK //
// close connection
Newsletter::api_helper_http_close_connection();
// execute queued work
Newsletter::queue_work();
?>

View File

@ -0,0 +1,225 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Lang;
use Flake\Lang_Dict;
use Flake\Page;
use Flake\Project;
use Flake\Excuse;
use Flake\Csrf;
// HANDLE AUTHENTICATION //
require("./page/admin/auth_handler.php");
// LOAD CONTENT //
// get content name from url param
$content_name = Project::param("content");
// check whether this content exists
if(!in_array($content_name, Newsletter::content_list())){
Excuse::show("not_found");
}
// load content data
$content = Newsletter::content_file_read(name: $content_name);
// MAYBE PROVIDE PREVIEW HTML //
if(isset($_GET["preview"])){
// validate language
$language = $_GET["preview"];
if(!in_array($language, ["de", "en"])){
http_response_code(400);
echo("invalid preview language requested");
die();
}
// render preview
$preview = Newsletter::content_render_preview(content: $content, language: $language);
// output preview
echo($preview);
die();
}
// LANGUAGE MANAGER //
// hack: fake get param from constant
$_GET["lang"] = "en";
// initialize
$lang = new Lang(list: ["de", "en"], default: "en");
// load dict
$dict = new Lang_Dict($lang);
require("./page/strings.php");
// PAGE INIT //
Page::start();
Page::title("SBGG.jetzt - Admin Area");
Page::icon("./asset/logo-256.png");
Page::lang($lang->get());
Page::viewport(scale: 1, zoom: true);
Page::robots(index: false, follow: false);
Page::author("Kim Endisch");
Page::$head["analytics"] = '<script defer data-domain="sbgg.jetzt" src="https://analytics.tjdev.de/js/script.js"></script>';
Page::css("./page/start/style.css");
Page::js(__DIR__ . "/iframe_magic.js");
Page::js(__DIR__ . "/send_one.js");
Page::js(__DIR__ . "/send_all.js");
Page::font("ubuntu");
Page::font("tabler");
?>
<div class="page-container full-page">
<div class="page">
<div class="section">
<div class="content">
<div class="button-list align-left">
<a href="/admin/newsletter" class="button on-bg">
<span class="icon ti ti-arrow-left"></span>
<span class="text">Go Back</span>
</a>
<a href="/admin" class="button on-bg">
<span class="icon ti ti-home"></span>
<span class="text">Go Home</span>
</a>
</div>
</div>
</div>
<div class="section">
<div class="header">
<span class="icon ti ti-news"></span>
<span class="text">Preview</span>
</div>
<div class="content full-page rows">
<div class="box">
<span class="extra"><i class="ti ti-world"></i> Language: <span class="white">DE</span></span>
<div class="preview-container">
<iframe src="?preview=de" width="576" scrolling="no" onload="iframe_resize(this)"></iframe>
</div>
</div>
<div class="box">
<span class="extra"><i class="ti ti-world"></i> Language: <span class="white">EN</span></span>
<div class="preview-container">
<iframe src="?preview=en" width="576" scrolling="no" onload="iframe_resize(this)"></iframe>
</div>
</div>
</div>
</div>
<div class="section">
<div class="header">
<span class="icon ti ti-mail-fast"></span>
<span class="text">Delivery</span>
</div>
<div class="content rows">
<div class="box">
<span class="title">Send to One</span>
<div id="newsletter-send-one-form-container" class="form-container">
<div id="newsletter-send-one-form" class="form">
<div class="key-value-pair">
<div class="key">
<span class="ti ti-at"></span>
</div>
<div class="value-list">
<div class="inputwrapper">
<input id="newsletter-send-one-form-mail-address" class="value" type="text" placeholder="Member Mail Address" autocomplete="off" />
</div>
</div>
</div>
<input id="newsletter-send-one-form-content-name" type="hidden" value="<?= $content_name ?>" />
<input id="newsletter-send-one-form-csrf-token" type="hidden" value="<?= Csrf::token() ?>" />
<button id="newsletter-send-one-form-submit" class="button primary">
<span class="text">Send to One</span>
<span class="icon ti ti-chevron-right"></span>
</button>
</div>
<div id="newsletter-send-one-form-feedback" class="form-feedback gone">
<div id="newsletter-send-one-form-feedback-wait" class="form-feedback-wait centertext gone">
<span class="icon spinning ti ti-loader-2"></span>
<span class="text">Adding job to queue</span>
</div>
<div id="newsletter-send-one-form-feedback-success" class="form-feedback-success centertext gone">
<span class="icon ti ti-check"></span>
<span class="text">Job successfully queued</span>
</div>
<div id="newsletter-send-one-form-feedback-failure" class="form-feedback-failure centertext gone">
<span class="icon ti ti-x"></span>
<span class="text">Queueing job failed</span>
</div>
<div id="newsletter-send-one-form-feedback-failure-no-member" class="form-feedback-failure centertext gone">
<span class="icon ti ti-x"></span>
<span class="text">Not a newsletter member</span>
</div>
</div>
</div>
</div>
<div class="box danger">
<span class="title">Send to All (<?= Newsletter::member_count() ?>)</span>
<div id="newsletter-send-all-form-container" class="form-container">
<div id="newsletter-send-all-form" class="form">
<div class="key-value-pair">
<div class="key">
<span class="ti ti-shield"></span>
</div>
<div class="value-list">
<span id="newsletter-send-all-form-safe-code" class="value select-none">&nbsp;</span>
<div class="inputwrapper">
<input id="newsletter-send-all-form-safe-code-repeat" class="value" type="text" placeholder="Safe Code" autocomplete="off" />
</div>
</div>
</div>
<input id="newsletter-send-all-form-content-name" type="hidden" value="<?= $content_name ?>" />
<input id="newsletter-send-all-form-csrf-token" type="hidden" value="<?= Csrf::token() ?>" />
<button id="newsletter-send-all-form-submit" class="button primary">
<span class="text">Send to All</span>
<span class="icon ti ti-chevron-right"></span>
</button>
</div>
<div id="newsletter-send-all-form-feedback" class="form-feedback gone">
<div id="newsletter-send-all-form-feedback-wait" class="form-feedback-wait centertext gone">
<span class="icon spinning ti ti-loader-2"></span>
<span class="text">Adding jobs to queue</span>
</div>
<div id="newsletter-send-all-form-feedback-success" class="form-feedback-success centertext gone">
<span class="icon ti ti-check"></span>
<span class="text">Jobs successfully queued</span>
</div>
<div id="newsletter-send-all-form-feedback-failure" class="form-feedback-failure centertext gone">
<span class="icon ti ti-x"></span>
<span class="text">Queueing jobs failed</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require(dirname(__DIR__) . "/footer.php"); ?>

View File

@ -0,0 +1,5 @@
"use strict";
function iframe_resize(self){
self.style.height = self.contentWindow.document.documentElement.scrollHeight + "px";
}

View File

@ -0,0 +1,95 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use DateTimeImmutable;
use Flake\Lang;
use Flake\Lang_Dict;
use Flake\Page;
// HANDLE AUTHENTICATION //
require("./page/admin/auth_handler.php");
// LANGUAGE MANAGER //
// hack: fake get param from constant
$_GET["lang"] = "en";
// initialize
$lang = new Lang(list: ["de", "en"], default: "en");
// load dict
$dict = new Lang_Dict($lang);
require("./page/strings.php");
// PAGE INIT //
Page::start();
Page::title("SBGG.jetzt - Admin Area");
Page::icon("./asset/logo-256.png");
Page::lang($lang->get());
Page::viewport(scale: 1, zoom: true);
Page::robots(index: false, follow: false);
Page::author("Kim Endisch");
Page::$head["analytics"] = '<script defer data-domain="sbgg.jetzt" src="https://analytics.tjdev.de/js/script.js"></script>';
Page::css("./page/start/style.css");
Page::font("ubuntu");
Page::font("tabler");
?>
<div class="page-container">
<div class="page">
<div class="section">
<div class="content">
<div class="button-list align-left">
<a href="/admin" class="button on-bg">
<span class="icon ti ti-arrow-left"></span>
<span class="text">Go Back</span>
</a>
</div>
</div>
</div>
<div class="section">
<div class="header">
<span class="icon ti ti-news"></span>
<span class="text">Content</span>
</div>
<div class="content">
<?php
$content_list = Newsletter::content_list();
rsort($content_list);
foreach($content_list as $one_content_name){
$date_raw = substr($one_content_name, 0, 10);
if($date_raw === "0000-00-00"){
$date_formatted = "System Message";
} else {
$date = new DateTimeImmutable($date_raw);
$date_formatted = $date->format('d M Y');
}
$name_raw = substr($one_content_name, 11);
$name_formatted = ucwords(str_replace("-", " ", basename($name_raw)));
?>
<a href="/admin/newsletter/<?= urlencode($one_content_name) ?>" class="box align-left">
<span class="extra"><i class="ti ti-calendar"></i><?= $date_formatted ?></span>
<span class="title"><?= $name_formatted ?></span>
</a>
<?php } ?>
</div>
</div>
</div>
</div>
<?php require(dirname(__DIR__) . "/footer.php"); ?>

View File

@ -0,0 +1,189 @@
"use strict";
let newsletter_send_all_form;
let newsletter_send_all_safe_code;
let newsletter_send_all_input_safe_code_repeat;
let newsletter_send_all_input_content_name;
let newsletter_send_all_input_csrf_token;
let newsletter_send_all_input_submit;
let newsletter_send_all_feedback;
let newsletter_send_all_feedback_wait;
let newsletter_send_all_feedback_success;
let newsletter_send_all_feedback_failure;
let newsletter_send_all_valid_safe_code = false;
window.addEventListener("load", function(){
// STORE ELEMENTS //
newsletter_send_all_form = document.getElementById("newsletter-send-all-form");
newsletter_send_all_safe_code = document.getElementById("newsletter-send-all-form-safe-code");
newsletter_send_all_input_safe_code_repeat = document.getElementById("newsletter-send-all-form-safe-code-repeat");
newsletter_send_all_input_content_name = document.getElementById("newsletter-send-all-form-content-name");
newsletter_send_all_input_csrf_token = document.getElementById("newsletter-send-all-form-csrf-token");
newsletter_send_all_input_submit = document.getElementById("newsletter-send-all-form-submit");
newsletter_send_all_feedback = document.getElementById("newsletter-send-all-form-feedback");
newsletter_send_all_feedback_wait = document.getElementById("newsletter-send-all-form-feedback-wait");
newsletter_send_all_feedback_success = document.getElementById("newsletter-send-all-form-feedback-success");
newsletter_send_all_feedback_failure = document.getElementById("newsletter-send-all-form-feedback-failure");
// INITIALIZE INPUTS //
newsletter_send_all_init_safe_code();
newsletter_send_all_init_safe_code_repeat();
newsletter_send_all_init_submit();
});
/**
* HELPER: Initialize safe code text.
*/
async function newsletter_send_all_init_safe_code(){
// POPULATE WITH RANDOM NUMBER //
newsletter_send_all_safe_code.textContent = Math.random().toString().slice(2, 6);
}
/**
* HELPER: Initialize safe code repeat input.
*/
async function newsletter_send_all_init_safe_code_repeat(){
// REGISTER INPUT HANDLER //
newsletter_send_all_input_safe_code_repeat.addEventListener("input", newsletter_send_all_update_safe_code_repeat);
}
/**
* HELPER: Initialize submit button input.
*/
async function newsletter_send_all_init_submit(){
// REGISTER CLICK HANDLER //
newsletter_send_all_input_submit.addEventListener("click", newsletter_send_all_submit);
// UPDATE STATE //
newsletter_send_all_update_submit();
}
/**
* CALLBACK: Update safe code repeat state.
*/
async function newsletter_send_all_update_safe_code_repeat(){
// VALIDATE INPUT //
// load values
let should = newsletter_send_all_safe_code.textContent;
let is = newsletter_send_all_input_safe_code_repeat.value;
// compare
newsletter_send_all_valid_safe_code = (is === should);
// UPDATE VALIDITY INDICATOR //
// get element
let validity_indicator = newsletter_send_all_input_safe_code_repeat.parentElement;
// reset state
validity_indicator.classList.remove("valid", "invalid");
// set state
if(newsletter_send_all_valid_safe_code){
validity_indicator.classList.add("valid");
} else {
validity_indicator.classList.add("invalid");
}
// UPDATE SUBMIT BUTTON //
newsletter_send_all_update_submit();
}
/**
* HELPER: Update submit button state.
*/
async function newsletter_send_all_update_submit(){
// DISABLE //
newsletter_send_all_input_submit.classList.add("disabled");
// MAYBE ENABLE //
if(newsletter_send_all_valid_safe_code){
newsletter_send_all_input_submit.classList.remove("disabled");
}
}
/**
* CALLBACK: Maybe submit the form.
*/
async function newsletter_send_all_submit(){
// MAKE SURE ALL INPUTS ARE VALID //
if(!newsletter_send_all_valid_safe_code) return;
// SHOW WAIT FEEDBACK //
newsletter_send_all_feedback.classList.remove("hidden", "gone");
newsletter_send_all_form.classList.add("hidden");
newsletter_send_all_feedback_wait.classList.remove("hidden", "gone");
// COLLECT VALUES //
// content name
let content_name = newsletter_send_all_input_content_name.value;
// csrf token
let csrf_token = newsletter_send_all_input_csrf_token.value;
// SEND API REQUEST //
var xhr = new XMLHttpRequest();
xhr.open("POST", "/admin/newsletter/api/send-all", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify({
content_name: content_name,
csrf_token: csrf_token
}));
xhr.onload = function(){
let success = true;
// validate http status code
if(xhr.status !== 200) success = false;
// check response
let response = null;
if(success){
try {
response = JSON.parse(xhr.response);
} catch(e){}
if(typeof response !== "object") success = false;
if(success && response === null) success = false;
if(success && response.success !== true) success = false;
}
// positive feedback
if(success){
newsletter_send_all_feedback_wait.classList.add("gone");
newsletter_send_all_feedback_success.classList.remove("hidden", "gone");
return;
}
// negative feedback: no member
if(response !== null && (response.reason ?? "") === "no_member"){
newsletter_send_all_feedback_wait.classList.add("gone");
newsletter_send_all_feedback_failure_no_member.classList.remove("hidden", "gone");
return;
}
// negative feedback: default
newsletter_send_all_feedback_wait.classList.add("gone");
newsletter_send_all_feedback_failure.classList.remove("hidden", "gone");
}
}

View File

@ -0,0 +1,181 @@
"use strict";
let newsletter_send_one_form;
let newsletter_send_one_input_mail_address;
let newsletter_send_one_input_content_name;
let newsletter_send_one_input_csrf_token;
let newsletter_send_one_input_submit;
let newsletter_send_one_feedback;
let newsletter_send_one_feedback_wait;
let newsletter_send_one_feedback_success;
let newsletter_send_one_feedback_failure;
let newsletter_send_one_feedback_failure_no_member;
let newsletter_send_one_valid_mail_address = false;
window.addEventListener("load", function(){
// STORE ELEMENTS //
newsletter_send_one_form = document.getElementById("newsletter-send-one-form");
newsletter_send_one_input_mail_address = document.getElementById("newsletter-send-one-form-mail-address");
newsletter_send_one_input_content_name = document.getElementById("newsletter-send-one-form-content-name");
newsletter_send_one_input_csrf_token = document.getElementById("newsletter-send-one-form-csrf-token");
newsletter_send_one_input_submit = document.getElementById("newsletter-send-one-form-submit");
newsletter_send_one_feedback = document.getElementById("newsletter-send-one-form-feedback");
newsletter_send_one_feedback_wait = document.getElementById("newsletter-send-one-form-feedback-wait");
newsletter_send_one_feedback_success = document.getElementById("newsletter-send-one-form-feedback-success");
newsletter_send_one_feedback_failure = document.getElementById("newsletter-send-one-form-feedback-failure");
newsletter_send_one_feedback_failure_no_member = document.getElementById("newsletter-send-one-form-feedback-failure-no-member");
// INITIALIZE INPUTS //
newsletter_send_one_init_mail_address();
newsletter_send_one_init_submit();
});
/**
* HELPER: Initialize mail address input.
*/
async function newsletter_send_one_init_mail_address(){
// REGISTER INPUT HANDLER //
newsletter_send_one_input_mail_address.addEventListener("input", newsletter_send_one_update_mail_address);
}
/**
* HELPER: Initialize submit button input.
*/
async function newsletter_send_one_init_submit(){
// REGISTER CLICK HANDLER //
newsletter_send_one_input_submit.addEventListener("click", newsletter_send_one_submit);
// UPDATE STATE //
newsletter_send_one_update_submit();
}
/**
* CALLBACK: Update mail address state.
*/
async function newsletter_send_one_update_mail_address(){
// VALIDATE INPUT //
// load value
let value = newsletter_send_one_input_mail_address.value;
// check against regex
newsletter_send_one_valid_mail_address = (value.match(/^[a-zA-Z0-9\.\-\_\+]+@([a-z0-9\-]+\.)+[a-z0-9\-]{2,}$/) !== null);
// UPDATE VALIDITY INDICATOR //
// get element
let validity_indicator = newsletter_send_one_input_mail_address.parentElement;
// reset state
validity_indicator.classList.remove("valid", "invalid");
// set state
if(newsletter_send_one_valid_mail_address){
validity_indicator.classList.add("valid");
} else {
validity_indicator.classList.add("invalid");
}
// UPDATE SUBMIT BUTTON //
newsletter_send_one_update_submit();
}
/**
* HELPER: Update submit button state.
*/
async function newsletter_send_one_update_submit(){
// DISABLE //
newsletter_send_one_input_submit.classList.add("disabled");
// MAYBE ENABLE //
if(newsletter_send_one_valid_mail_address){
newsletter_send_one_input_submit.classList.remove("disabled");
}
}
/**
* CALLBACK: Maybe submit the form.
*/
async function newsletter_send_one_submit(){
// MAKE SURE ALL INPUTS ARE VALID //
if(!newsletter_send_one_valid_mail_address) return;
// SHOW WAIT FEEDBACK //
newsletter_send_one_feedback.classList.remove("hidden", "gone");
newsletter_send_one_form.classList.add("hidden");
newsletter_send_one_feedback_wait.classList.remove("hidden", "gone");
// COLLECT VALUES //
// mail address
let mail_address = newsletter_send_one_input_mail_address.value;
// content name
let content_name = newsletter_send_one_input_content_name.value;
// csrf token
let csrf_token = newsletter_send_one_input_csrf_token.value;
// SEND API REQUEST //
var xhr = new XMLHttpRequest();
xhr.open("POST", "/admin/newsletter/api/send-one", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify({
mail_address: mail_address,
content_name: content_name,
csrf_token: csrf_token
}));
xhr.onload = function(){
let success = true;
// validate http status code
if(xhr.status !== 200) success = false;
// check response
let response = null;
if(success){
try {
response = JSON.parse(xhr.response);
} catch(e){}
if(typeof response !== "object") success = false;
if(success && response === null) success = false;
if(success && response.success !== true) success = false;
}
// positive feedback
if(success){
newsletter_send_one_feedback_wait.classList.add("gone");
newsletter_send_one_feedback_success.classList.remove("hidden", "gone");
return;
}
// negative feedback: no member
if(response !== null && (response.reason ?? "") === "no_member"){
newsletter_send_one_feedback_wait.classList.add("gone");
newsletter_send_one_feedback_failure_no_member.classList.remove("hidden", "gone");
return;
}
// negative feedback: default
newsletter_send_one_feedback_wait.classList.add("gone");
newsletter_send_one_feedback_failure.classList.remove("hidden", "gone");
}
}

View File

@ -0,0 +1,88 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Lang;
use Flake\Lang_Dict;
use Flake\Page;
// HANDLE AUTHENTICATION //
require("./page/admin/auth_handler.php");
// LANGUAGE MANAGER //
// hack: fake get param from constant
$_GET["lang"] = "en";
// initialize
$lang = new Lang(list: ["de", "en"], default: "en");
// load dict
$dict = new Lang_Dict($lang);
require("./page/strings.php");
// PAGE INIT //
Page::start();
Page::title("SBGG.jetzt - Admin Area");
Page::icon("./asset/logo-256.png");
Page::lang($lang->get());
Page::viewport(scale: 1, zoom: true);
Page::robots(index: false, follow: false);
Page::author("Kim Endisch");
Page::$head["analytics"] = '<script defer data-domain="sbgg.jetzt" src="https://analytics.tjdev.de/js/script.js"></script>';
Page::css("./page/start/style.css");
Page::font("ubuntu");
Page::font("tabler");
?>
<div class="page-container">
<div class="page">
<div class="title">
<h1><?= $dict->get("page_title_h1") ?></h1>
<h2>Admin Area</h2>
</div>
<div class="section">
<div class="header">
<span class="icon ti ti-direction-sign"></span>
<span class="text">Actions</span>
</div>
<div class="content rows">
<div class="box">
<span class="title">Newsletter</span>
<div class="button-list">
<a href="/admin/newsletter" class="button">
<span class="icon ti ti-news"></span>
<span class="text">Manage Content</span>
</a>
</div>
</div>
<div class="box">
<span class="title">Admin Session</span>
<div class="button-list">
<a href="?logout" class="button">
<span class="icon ti ti-logout"></span>
<span class="text">Logout</span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php require(dirname(__DIR__) . "/footer.php"); ?>

View File

@ -0,0 +1,139 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Lang;
use Flake\Lang_Dict;
use Flake\Page;
use Flake\Project;
use Flake\Url;
use Flake\Url_Redirect;
use Flake\Request;
use Flake\File;
// COLLECT REQUEST DATA //
// mail address
$mail_address = $_GET["mail_address"] ?? null;
if(!is_string($mail_address)){
Url_Redirect::location("http" . (Request::has_ssl() ? "s" : "") . "://" . Request::domain_raw_full());
}
// LANGUAGE MANAGER //
// hack: fake get param from url path
$param_lang = $_GET["slang"] ?? "de";
$_GET["lang"] = $param_lang;
// initialize
$lang = new Lang(list: ["de", "en"], default: "de");
// load dict
$dict = new Lang_Dict($lang);
require("./page/strings.php");
// PAGE INIT //
Page::start();
Page::title($dict->get("newsletter_subscribe_page_title"));
Page::icon("./asset/logo-256.png");
Page::lang($lang->get());
Page::viewport(scale: 1, zoom: true);
Page::robots(index: false, follow: false);
Page::author("Kim Endisch");
Page::$head["analytics"] = '<script defer data-domain="sbgg.jetzt" src="https://analytics.tjdev.de/js/script.js"></script>';
Page::css("./page/start/style.css");
Page::js(__DIR__ . "/main.js");
Page::font("ubuntu");
Page::font("tabler");
?>
<div class="page-container">
<div class="page">
<div id="news" class="section">
<div class="content rows">
<div id="newsletter" class="box">
<span class="title"><?= $dict->get("newsletter_subscribe_title") ?></span>
<div id="newsletter-signup-form-container" class="form-container">
<div id="newsletter-signup-form" class="form">
<div class="key-value-pair">
<div class="key">
<span class="ti ti-at"></span>
</div>
<div class="value-list">
<div class="inputwrapper">
<input id="newsletter-signup-form-mail-address" class="value" type="text" value="<?= htmlspecialchars($mail_address) ?>" disabled />
</div>
</div>
</div>
<button id="newsletter-signup-form-submit" class="button primary">
<span class="text"><?= $dict->get("newsletter_subscribe_submit") ?></span>
<span class="icon ti ti-chevron-right"></span>
</button>
</div>
<div id="newsletter-signup-form-feedback" class="form-feedback gone">
<div id="newsletter-signup-form-feedback-wait" class="form-feedback-wait centertext gone">
<span class="icon spinning ti ti-loader-2"></span>
<span class="text"><?= $dict->get("newsletter_subscribe_feedback_wait") ?></span>
</div>
<div id="newsletter-signup-form-feedback-success" class="form-feedback-success centertext gone">
<span class="icon ti ti-check"></span>
<span class="text"><?= $dict->get("newsletter_subscribe_feedback_success") ?></span>
</div>
<div id="newsletter-signup-form-feedback-failure" class="form-feedback-failure centertext gone">
<span class="icon ti ti-x"></span>
<span class="text"><?= $dict->get("newsletter_subscribe_feedback_failure") ?></span>
</div>
</div>
</div>
</div>
<div class="box align-left">
<?php
$newsletter_subscribe_privacy_note = $dict->get("newsletter_subscribe_privacy_note");
foreach($newsletter_subscribe_privacy_note as $one_newsletter_subscribe_privacy_note_line){
echo("<span class=\"align-left\">" . $one_newsletter_subscribe_privacy_note_line . "</span>");
}
?>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<div class="brand">
<img src="<?= File::file("./asset/logo-256.png") ?>" alt="logo" />
<span>SBGG.jetzt</span>
<a href="https://git.tjdev.de/kimendisch/sbgg.jetzt" target="_blank"><?= $dict->get("text_sourcecode") ?> <i class="ti ti-external-link"></i></a>
<span class="version">v<?= Project::version() ?></span>
</div>
<div class="lang">
<span><i class="ti ti-world"></i></span>
<a <?= ($lang->get() === "de" ? "class=\"selected\"" : "") ?> href="<?= Url::query_modify(remove: ["slang"], add: ["slang=de"]) ?>">DE</a>
<span class="delimiter">|</span>
<a <?= ($lang->get() === "en" ? "class=\"selected\"" : "") ?> href="<?= Url::query_modify(remove: ["slang"], add: ["slang=en"]) ?>">EN</a>
</div>
<div class="legal">
<span>&copy; 2024 Kim Endisch</span>
<span class="delimiter">|</span>
<a href="<?= $dict->get("link_imprint") ?>" target="_blank"><?= $dict->get("text_imprint") ?> <i class="ti ti-external-link"></i></a>
<span class="delimiter">|</span>
<a href="<?= $dict->get("link_privacy_policy") ?>" target="_blank"><?= $dict->get("text_privacy_policy") ?> <i class="ti ti-external-link"></i></a>
</div>
</div>

View File

@ -0,0 +1,94 @@
"use strict";
let newsletter_form;
let newsletter_input_submit;
let newsletter_feedback;
let newsletter_feedback_wait;
let newsletter_feedback_success;
let newsletter_feedback_failure;
window.addEventListener("load", function(){
// STORE ELEMENTS //
newsletter_form = document.getElementById("newsletter-signup-form");
newsletter_input_submit = document.getElementById("newsletter-signup-form-submit");
newsletter_feedback = document.getElementById("newsletter-signup-form-feedback");
newsletter_feedback_wait = document.getElementById("newsletter-signup-form-feedback-wait");
newsletter_feedback_success = document.getElementById("newsletter-signup-form-feedback-success");
newsletter_feedback_failure = document.getElementById("newsletter-signup-form-feedback-failure");
// INITIALIZE INPUTS //
newsletter_init_submit();
});
/**
* HELPER: Initialize submit button input.
*/
async function newsletter_init_submit(){
// REGISTER CLICK HANDLER //
newsletter_input_submit.addEventListener("click", newsletter_submit);
}
/**
* CALLBACK: Maybe submit the form.
*/
async function newsletter_submit(){
// SHOW WAIT FEEDBACK //
newsletter_feedback.classList.remove("hidden", "gone");
newsletter_form.classList.add("hidden");
newsletter_feedback_wait.classList.remove("hidden", "gone");
// COLLECT VALUES //
// mail address
const url_params = new URLSearchParams(window.location.search);
let mail_address = url_params.get("mail_address");
// verify_key
let verify_key = url_params.get("key");
// SEND API REQUEST //
var xhr = new XMLHttpRequest();
xhr.open("POST", "/api/newsletter/subscribe", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("x-cookieless-csrf-protection", "42");
xhr.send(JSON.stringify({
mail_address: mail_address,
verify_key: verify_key
}));
xhr.onload = function(){
let success = true;
// validate http status code
if(xhr.status !== 200) success = false;
// check response
if(success){
let response = null;
try {
response = JSON.parse(xhr.response);
} catch(e){}
if(typeof response !== "object") success = false;
if(success && response === null) success = false;
if(success && response.success !== true) success = false;
}
// positive feedback
if(success){
newsletter_feedback_wait.classList.add("gone");
newsletter_feedback_success.classList.remove("hidden", "gone");
return;
}
// negative feedback
newsletter_feedback_wait.classList.add("gone");
newsletter_feedback_failure.classList.remove("hidden", "gone");
}
}

View File

@ -0,0 +1,130 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
use Flake\Lang;
use Flake\Lang_Dict;
use Flake\Page;
use Flake\File;
use Flake\Project;
use Flake\Url;
use Flake\Url_Redirect;
use Flake\Request;
// COLLECT REQUEST DATA //
// mail address
$mail_address = $_GET["mail_address"] ?? null;
if(!is_string($mail_address)){
Url_Redirect::location("http" . (Request::has_ssl() ? "s" : "") . "://" . Request::domain_raw_full());
}
// LANGUAGE MANAGER //
// hack: fake get param from url path
$param_lang = $_GET["slang"] ?? "de";
$_GET["lang"] = $param_lang;
// initialize
$lang = new Lang(list: ["de", "en"], default: "de");
// load dict
$dict = new Lang_Dict($lang);
require("./page/strings.php");
// PAGE INIT //
Page::start();
Page::title($dict->get("newsletter_unsubscribe_page_title"));
Page::icon("./asset/logo-256.png");
Page::lang($lang->get());
Page::viewport(scale: 1, zoom: true);
Page::robots(index: false, follow: false);
Page::author("Kim Endisch");
Page::$head["analytics"] = '<script defer data-domain="sbgg.jetzt" src="https://analytics.tjdev.de/js/script.js"></script>';
Page::css("./page/start/style.css");
Page::js(__DIR__ . "/main.js");
Page::font("ubuntu");
Page::font("tabler");
?>
<div class="page-container">
<div class="page">
<div id="news" class="section">
<div class="content rows">
<div id="newsletter" class="box">
<span class="title"><?= $dict->get("newsletter_unsubscribe_title") ?></span>
<div id="newsletter-signup-form-container" class="form-container">
<div id="newsletter-signup-form" class="form">
<div class="key-value-pair">
<div class="key">
<span class="ti ti-at"></span>
</div>
<div class="value-list">
<div class="inputwrapper">
<input id="newsletter-signup-form-mail-address" class="value" type="text" value="<?= htmlspecialchars($mail_address) ?>" disabled />
</div>
</div>
</div>
<button id="newsletter-signup-form-submit" class="button primary">
<span class="text"><?= $dict->get("newsletter_unsubscribe_submit") ?></span>
<span class="icon ti ti-chevron-right"></span>
</button>
</div>
<div id="newsletter-signup-form-feedback" class="form-feedback gone">
<div id="newsletter-signup-form-feedback-wait" class="form-feedback-wait centertext gone">
<span class="icon spinning ti ti-loader-2"></span>
<span class="text"><?= $dict->get("newsletter_unsubscribe_feedback_wait") ?></span>
</div>
<div id="newsletter-signup-form-feedback-success" class="form-feedback-success centertext gone">
<span class="icon ti ti-check"></span>
<span class="text"><?= $dict->get("newsletter_unsubscribe_feedback_success") ?></span>
</div>
<div id="newsletter-signup-form-feedback-failure" class="form-feedback-failure centertext gone">
<span class="icon ti ti-x"></span>
<span class="text"><?= $dict->get("newsletter_unsubscribe_feedback_failure") ?></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<div class="brand">
<img src="<?= File::file("./asset/logo-256.png") ?>" alt="logo" />
<span>SBGG.jetzt</span>
<a href="https://git.tjdev.de/kimendisch/sbgg.jetzt" target="_blank"><?= $dict->get("text_sourcecode") ?> <i class="ti ti-external-link"></i></a>
<span class="version">v<?= Project::version() ?></span>
</div>
<div class="lang">
<span><i class="ti ti-world"></i></span>
<a <?= ($lang->get() === "de" ? "class=\"selected\"" : "") ?> href="<?= Url::query_modify(remove: ["slang"], add: ["slang=de"]) ?>">DE</a>
<span class="delimiter">|</span>
<a <?= ($lang->get() === "en" ? "class=\"selected\"" : "") ?> href="<?= Url::query_modify(remove: ["slang"], add: ["slang=en"]) ?>">EN</a>
</div>
<div class="legal">
<span>&copy; 2024 Kim Endisch</span>
<span class="delimiter">|</span>
<a href="<?= $dict->get("link_imprint") ?>" target="_blank"><?= $dict->get("text_imprint") ?> <i class="ti ti-external-link"></i></a>
<span class="delimiter">|</span>
<a href="<?= $dict->get("link_privacy_policy") ?>" target="_blank"><?= $dict->get("text_privacy_policy") ?> <i class="ti ti-external-link"></i></a>
</div>
</div>

View File

@ -0,0 +1,94 @@
"use strict";
let newsletter_form;
let newsletter_input_submit;
let newsletter_feedback;
let newsletter_feedback_wait;
let newsletter_feedback_success;
let newsletter_feedback_failure;
window.addEventListener("load", function(){
// STORE ELEMENTS //
newsletter_form = document.getElementById("newsletter-signup-form");
newsletter_input_submit = document.getElementById("newsletter-signup-form-submit");
newsletter_feedback = document.getElementById("newsletter-signup-form-feedback");
newsletter_feedback_wait = document.getElementById("newsletter-signup-form-feedback-wait");
newsletter_feedback_success = document.getElementById("newsletter-signup-form-feedback-success");
newsletter_feedback_failure = document.getElementById("newsletter-signup-form-feedback-failure");
// INITIALIZE INPUTS //
newsletter_init_submit();
});
/**
* HELPER: Initialize submit button input.
*/
async function newsletter_init_submit(){
// REGISTER CLICK HANDLER //
newsletter_input_submit.addEventListener("click", newsletter_submit);
}
/**
* CALLBACK: Maybe submit the form.
*/
async function newsletter_submit(){
// SHOW WAIT FEEDBACK //
newsletter_feedback.classList.remove("hidden", "gone");
newsletter_form.classList.add("hidden");
newsletter_feedback_wait.classList.remove("hidden", "gone");
// COLLECT VALUES //
// mail address
const url_params = new URLSearchParams(window.location.search);
let mail_address = url_params.get("mail_address");
// unsubscribe_key
let unsubscribe_key = url_params.get("key");
// SEND API REQUEST //
var xhr = new XMLHttpRequest();
xhr.open("POST", "/api/newsletter/unsubscribe", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("x-cookieless-csrf-protection", "42");
xhr.send(JSON.stringify({
mail_address: mail_address,
unsubscribe_key: unsubscribe_key
}));
xhr.onload = function(){
let success = true;
// validate http status code
if(xhr.status !== 200) success = false;
// check response
if(success){
let response = null;
try {
response = JSON.parse(xhr.response);
} catch(e){}
if(typeof response !== "object") success = false;
if(success && response === null) success = false;
if(success && response.success !== true) success = false;
}
// positive feedback
if(success){
newsletter_feedback_wait.classList.add("gone");
newsletter_feedback_success.classList.remove("hidden", "gone");
return;
}
// negative feedback
newsletter_feedback_wait.classList.add("gone");
newsletter_feedback_failure.classList.remove("hidden", "gone");
}
}

94
page/start/copylink.js Normal file
View File

@ -0,0 +1,94 @@
"use strict";
window.addEventListener("load", function(event){
// REGISTER ONCLICK HANDLERS //
// iterate over all copylink buttons
let copylink_button_list = document.getElementsByClassName("copylink");
for(let one_copylink_button of copylink_button_list){
// register onclick function
one_copylink_button.onclick = function(){ copylink_click(this) };
// add descriptive title
one_copylink_button.title = copylink_hint_text;
}
});
/**
* CALLBACK: Copylink was clicked.
*
* @param self Copylink button element.
*/
async function copylink_click(self){
let success = true;
// RETRIEVE SECTION ID //
// try to find
let section_id = copylink_section_id(self);
// check whether search was successful
if(section_id === null) success = false;
// SAVE SECTION LINK TO CLIPBOARD //
if(success){
// build url
let section_url = new URL("#" + section_id, window.location.href);
// save to clipboard
try {
await navigator.clipboard.writeText(section_url);
} catch (error){
success = false;
}
}
// FEEDBACK //
if(success){
// positive feedback
self.classList.add("ti-check", "feedback-positive");
self.classList.remove("ti-link");
setTimeout(function(){
self.classList.add("ti-link");
self.classList.remove("ti-check", "feedback-positive");
}, 2500);
return;
}
// negative feedback
self.classList.add("ti-x", "feedback-negative");
self.classList.remove("ti-link");
setTimeout(function(){
self.classList.add("ti-link");
self.classList.remove("ti-x", "feedback-negative");
}, 2500);
}
/**
* HELPER: Find closest section id.
*
* @param self Base element.
*
* @return `null`: Unable to find a section id
* string: Closest section id to copylink button.
*/
function copylink_section_id(self){
// CHECK FOR ID ATTRIBUTE //
if(self.id !== undefined && self.id !== null && self.id.length > 0){
// found an id
return self.id;
}
// STOP SEARCHING //
// check whether element has parent
if(self.parentElement === null || self.parentElement === undefined) return null;
// CONTINUE SEARCHING //
return copylink_section_id(self.parentElement);
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
// MAKE TRANSLATION DICT AVAILABLE VIA JAVASCRIPT //
global $kimendisch_sbgg_jetzt_dict;
// `copylink_hint_text`
echo("let copylink_hint_text = " . json_encode($kimendisch_sbgg_jetzt_dict->get("copylink_hint_text")) . ";");
?>

View File

@ -36,6 +36,10 @@
$dict = new Lang_Dict($lang);
require("./page/strings.php");
// make available to `eval`-ed scripts
global $kimendisch_sbgg_jetzt_dict;
$kimendisch_sbgg_jetzt_dict = $dict;
// PAGE INIT //
Page::start();
@ -46,6 +50,8 @@
Page::lang($lang->get());
Page::viewport(scale: 1, zoom: true);
Page::$head["alternate_de"] = '<link rel="alternate" hreflang="de" href="/" />';
Page::$head["alternate_en"] = '<link rel="alternate" hreflang="en" href="/en" />';
Page::robots(index: true, follow: true);
Page::author("Kim Endisch");
@ -54,6 +60,9 @@
Page::$head["analytics"] = '<script defer data-domain="sbgg.jetzt" src="https://analytics.tjdev.de/js/script.js"></script>';
Page::css(__DIR__ . "/style.css");
Page::js(__DIR__ . "/copylink_dict.js.php", eval: true);
Page::js(__DIR__ . "/copylink.js");
Page::js(__DIR__ . "/newsletter.js");
Page::font("ubuntu");
Page::font("tabler");
@ -66,14 +75,14 @@
<div class="page-container">
<div class="page">
<div class="title">
<span class="abolish"><?= $dict->get("page_title_abolish") ?></span>
<span class="introduce"><?= $dict->get("page_title_introduce") ?></span>
<h1><?= $dict->get("page_title_h1") ?></h1>
<h2><?= $dict->get("page_title_h2") ?></h2>
</div>
<div class="section">
<div id="why" class="content">
<div class="box">
<span class="title"><?= $dict->get("why_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("why_title") ?></span>
<?php
$why_text = $dict->get("why_text");
@ -89,6 +98,7 @@
<div class="header">
<span class="icon ti ti-clock"></span>
<span class="text"><?= $dict->get("timeline_title") ?></span>
<button class="copylink ti ti-link"></button>
</div>
<div class="content">
<div class="timeline">
@ -104,7 +114,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_koalitionsvertrag_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_koalitionsvertrag_title") ?></span>
<?php
$timeline_koalitionsvertrag_text = $dict->get("timeline_koalitionsvertrag_text");
@ -134,7 +144,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_eckpunktepapier_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_eckpunktepapier_title") ?></span>
<?php
$timeline_eckpunktepapier_text = $dict->get("timeline_eckpunktepapier_text");
@ -164,7 +174,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_referentenentwurf_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_referentenentwurf_title") ?></span>
<?php
$timeline_referentenentwurf_text = $dict->get("timeline_referentenentwurf_text");
@ -198,7 +208,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_regierungsentwurf_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_regierungsentwurf_title") ?></span>
<?php
$timeline_regierungsentwurf_text = $dict->get("timeline_regierungsentwurf_text");
@ -228,7 +238,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_bundesrat_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_bundesrat_title") ?></span>
<?php
$timeline_bundesrat_text = $dict->get("timeline_bundesrat_text");
@ -262,7 +272,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_lesung_1_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_lesung_1_title") ?></span>
<?php
$timeline_lesung_1_text = $dict->get("timeline_lesung_1_text");
@ -292,7 +302,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_ausschuss_anhoerung_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_ausschuss_anhoerung_title") ?></span>
<?php
$timeline_ausschuss_anhoerung_text = $dict->get("timeline_ausschuss_anhoerung_text");
@ -322,7 +332,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_lesung_2_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_lesung_2_title") ?></span>
<?php
$timeline_lesung_2_text = $dict->get("timeline_lesung_2_text");
@ -345,7 +355,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_lesung_3_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_lesung_3_title") ?></span>
<?php
$timeline_lesung_3_text = $dict->get("timeline_lesung_3_text");
@ -368,7 +378,7 @@
<span class="extra"><i class="ti ti-calendar"></i><?= $timeline_date ?></span>
<?php } ?>
<span class="title"><?= $dict->get("timeline_inkrafttreten_title") ?></span>
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("timeline_inkrafttreten_title") ?></span>
<?php
$timeline_inkrafttreten_text = $dict->get("timeline_inkrafttreten_text");
@ -382,10 +392,91 @@
</div>
</div>
<div id="news" class="section">
<div class="header">
<span class="icon ti ti-bell"></span>
<span class="text"><?= $dict->get("news_title") ?></span>
<button class="copylink ti ti-link"></button>
</div>
<div class="content rows">
<div id="newsletter" class="box">
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("news_newsletter_title") ?></span>
<div id="newsletter-signup-form-container" class="form-container">
<div id="newsletter-signup-form" class="form">
<div class="key-value-pair">
<div class="key">
<span class="ti ti-at"></span>
</div>
<div class="value-list">
<div class="inputwrapper">
<input id="newsletter-signup-form-mail-address" class="value" type="text" placeholder="<?= $dict->get("news_newsletter_mail_address") ?>" autocomplete="off" />
</div>
</div>
</div>
<div class="key-value-pair">
<div class="key">
<span class="ti ti-world"></span>
</div>
<div class="value-list">
<div id="newsletter-signup-form-language" class="value switch" data-selected="<?= $lang->get() ?>">
<?php foreach(["de", "en"] as $one_lang){ ?>
<button class="option" data-value="<?= $one_lang ?>">
<span class="text"><?= strtoupper($one_lang) ?></span>
</button>
<?php } ?>
</div>
</div>
</div>
<button id="newsletter-signup-form-submit" class="button primary">
<span class="text"><?= $dict->get("news_newsletter_subscribe") ?></span>
<span class="icon ti ti-chevron-right"></span>
</button>
</div>
<div id="newsletter-signup-form-feedback" class="form-feedback gone">
<div id="newsletter-signup-form-feedback-wait" class="form-feedback-wait centertext gone">
<span class="icon spinning ti ti-loader-2"></span>
<span class="text"><?= $dict->get("news_newsletter_feedback_wait") ?></span>
</div>
<div id="newsletter-signup-form-feedback-success" class="form-feedback-success centertext gone">
<span class="icon ti ti-check"></span>
<span class="text"><?= $dict->get("news_newsletter_feedback_success") ?></span>
</div>
<div id="newsletter-signup-form-feedback-failure" class="form-feedback-failure centertext gone">
<span class="icon ti ti-x"></span>
<span class="text"><?= $dict->get("news_newsletter_feedback_failure") ?></span>
</div>
</div>
</div>
<span class="inline gray"><?= $dict->get("news_newsletter_note") ?></span>
</div>
<div id="social-media" class="box">
<span class="title"><button class="copylink ti ti-link"></button><?= $dict->get("news_social_media_title") ?></span>
<div class="button-list">
<a href="https://www.instagram.com/sbgg.jetzt" target="_blank" class="button">
<span class="icon big ti ti-brand-instagram"></span>
<div class="text">
<span>Instagram</span>
<span class="gray">@sbgg.jetzt</span>
</div>
<span class="icon ti ti-external-link"></span>
</a>
</div>
</div>
</div>
</div>
<div id="about" class="section">
<div class="header">
<span class="icon ti ti-heart"></span>
<span class="text"><?= $dict->get("about_title") ?></span>
<button class="copylink ti ti-link"></button>
</div>
<div class="content">
<div class="box">
@ -396,8 +487,6 @@
}
?>
<span class="gray"><?= $dict->get("about_disclaimer") ?></span>
<div class="button-list">
<a <?= Hidden::href("mailto:mail@sb"."gg.jetzt") ?> class="button primary">
<span class="icon ti ti-mail"></span>
@ -419,7 +508,7 @@
<div class="footer">
<div class="brand">
<img src="<?= File::file("./asset/logo-256.png") ?>" alt="logo" />
<span>SBGG Jetzt!</span>
<span>SBGG.jetzt</span>
<a href="https://git.tjdev.de/kimendisch/sbgg.jetzt" target="_blank"><?= $dict->get("text_sourcecode") ?> <i class="ti ti-external-link"></i></a>
<span class="version">v<?= Project::version() ?></span>
</div>

230
page/start/newsletter.js Normal file
View File

@ -0,0 +1,230 @@
"use strict";
let newsletter_form;
let newsletter_input_mail_address;
let newsletter_input_language;
let newsletter_input_language_option_list;
let newsletter_input_submit;
let newsletter_feedback;
let newsletter_feedback_wait;
let newsletter_feedback_success;
let newsletter_feedback_failure;
let newsletter_valid_mail_address = false;
let newsletter_valid_language = false;
window.addEventListener("load", function(){
// STORE ELEMENTS //
newsletter_form = document.getElementById("newsletter-signup-form");
newsletter_input_mail_address = document.getElementById("newsletter-signup-form-mail-address");
newsletter_input_language = document.getElementById("newsletter-signup-form-language");
newsletter_input_language_option_list = newsletter_input_language.getElementsByClassName("option");
newsletter_input_submit = document.getElementById("newsletter-signup-form-submit");
newsletter_feedback = document.getElementById("newsletter-signup-form-feedback");
newsletter_feedback_wait = document.getElementById("newsletter-signup-form-feedback-wait");
newsletter_feedback_success = document.getElementById("newsletter-signup-form-feedback-success");
newsletter_feedback_failure = document.getElementById("newsletter-signup-form-feedback-failure");
// INITIALIZE INPUTS //
newsletter_init_mail_address();
newsletter_init_language();
newsletter_init_submit();
});
/**
* HELPER: Initialize mail address input.
*/
async function newsletter_init_mail_address(){
// REGISTER INPUT HANDLER //
newsletter_input_mail_address.addEventListener("input", newsletter_update_mail_address);
}
/**
* HELPER: Initialize language input.
*/
async function newsletter_init_language(){
// REGISTER CLICK HANDLERS //
for(let one_option of newsletter_input_language_option_list){
one_option.addEventListener("click", newsletter_change_language);
}
// UPDATE STATE //
newsletter_update_language();
}
/**
* HELPER: Initialize submit button input.
*/
async function newsletter_init_submit(){
// REGISTER CLICK HANDLER //
newsletter_input_submit.addEventListener("click", newsletter_submit);
// UPDATE STATE //
newsletter_update_submit();
}
/**
* CALLBACK: Update mail address state.
*/
async function newsletter_update_mail_address(){
// VALIDATE INPUT //
// load value
let value = newsletter_input_mail_address.value;
// check against regex
newsletter_valid_mail_address = (value.match(/^[a-zA-Z0-9\.\-\_\+]+@([a-z0-9\-]+\.)+[a-z0-9\-]{2,}$/) !== null);
// UPDATE VALIDITY INDICATOR //
// get element
let validity_indicator = newsletter_input_mail_address.parentElement;
// reset state
validity_indicator.classList.remove("valid", "invalid");
// set state
if(newsletter_valid_mail_address){
validity_indicator.classList.add("valid");
} else {
validity_indicator.classList.add("invalid");
}
// UPDATE SUBMIT BUTTON //
newsletter_update_submit();
}
/**
* CALLBACK: Change language.
*/
async function newsletter_change_language(){
// DETERMINE NEW VALUE //
// get from attribute
let value = this.dataset.value;
// store to main element
newsletter_input_language.dataset.selected = value;
// UPDATE STATE //
newsletter_update_language();
}
/**
* HELPER: Update language state.
*/
async function newsletter_update_language(){
// HIGHLIGHT SELECTED ELEMENT //
let value = newsletter_input_language.dataset.selected;
newsletter_valid_language = false;
for(let one_option of newsletter_input_language_option_list){
// reset classes
one_option.classList.remove("selected");
// selected
if(one_option.dataset.value === value){
newsletter_valid_language = true;
one_option.classList.add("selected");
}
}
// UPDATE SUBMIT BUTTON //
newsletter_update_submit();
}
/**
* HELPER: Update submit button state.
*/
async function newsletter_update_submit(){
// DISABLE //
newsletter_input_submit.classList.add("disabled");
// MAYBE ENABLE //
if(newsletter_valid_mail_address && newsletter_valid_language){
newsletter_input_submit.classList.remove("disabled");
}
}
/**
* CALLBACK: Maybe submit the form.
*/
async function newsletter_submit(){
// MAKE SURE ALL INPUTS ARE VALID //
if(!newsletter_valid_mail_address || !newsletter_valid_language) return;
// SHOW WAIT FEEDBACK //
newsletter_feedback.classList.remove("hidden", "gone");
newsletter_form.classList.add("hidden");
newsletter_feedback_wait.classList.remove("hidden", "gone");
// COLLECT VALUES //
// mail address
let mail_address = newsletter_input_mail_address.value;
// language
let language = newsletter_input_language.dataset.selected;
// SEND API REQUEST //
var xhr = new XMLHttpRequest();
xhr.open("POST", "/api/newsletter/verify", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("x-cookieless-csrf-protection", "42");
xhr.send(JSON.stringify({
mail_address: mail_address,
language: language
}));
xhr.onload = function(){
let success = true;
// validate http status code
if(xhr.status !== 200) success = false;
// check response
if(success){
let response = null;
try {
response = JSON.parse(xhr.response);
} catch(e){}
if(typeof response !== "object") success = false;
if(success && response === null) success = false;
if(success && response.success !== true) success = false;
}
// positive feedback
if(success){
newsletter_feedback_wait.classList.add("gone");
newsletter_feedback_success.classList.remove("hidden", "gone");
return;
}
// negative feedback
newsletter_feedback_wait.classList.add("gone");
newsletter_feedback_failure.classList.remove("hidden", "gone");
}
}

View File

@ -4,6 +4,7 @@
--color-white: #c5cad3;
--color-gray-light: #acb0b9;
--color-gray: #828997;
--color-gray-dark: #5c6370;
--color-gray-dark-dark: #454b54;
@ -83,6 +84,27 @@ span {
a {
text-decoration: none;
}
span a {
color: var(--theme);
}
span a:hover {
text-decoration: underline;
cursor: pointer;
}
span.gray a {
color: var(--color-gray);
text-decoration: underline;
text-decoration-style: dotted;
}
span.gray a:hover {
text-decoration-style: solid;
}
button {
all: unset;
}
button:focus {
outline: revert;
}
.link {
color: var(--theme);
}
@ -94,12 +116,31 @@ a {
span.inline {
display: inline;
}
span.align-left {
text-align: left;
}
.colored {
color: var(--theme);
}
.gray {
color: var(--color-gray);
}
.white {
color: var(--color-white);
}
.hidden {
visibility: hidden !important;
}
.gone {
display: none !important;
}
.select-none {
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
@ -114,6 +155,9 @@ span.inline {
align-items: center;
justify-content: flex-start;
}
.page-container.full-page {
width: 100%;
}
.page {
max-width: 50vw;
@ -125,6 +169,9 @@ span.inline {
text-align: center;
}
.page-container.full-page .page {
width: 100%;
}
@media only screen and (max-width: 1600px) {
.page {
max-width: 70vw;
@ -148,6 +195,10 @@ span.inline {
/* PAGE TITLE */
.page > .title {
display: flex;
flex-direction: column;
gap: 1rem;
margin: 2rem 0;
}
@media only screen and (max-width: 1000px) {
@ -155,21 +206,21 @@ span.inline {
margin: 0 0;
}
}
.page > .title h1, .page > .title span {
font-size: 2rem;
}
.page > .title .abolish {
margin-bottom: 1rem;
color: var(--color-gray);
}
.page > .title .introduce h1 {
display: inline;
.page > .title h1, .page > .title h2 {
align-self: center;
margin: 0;
}
.page > .title h1 {
font-size: 3rem;
background-image: linear-gradient(to right, var(--color-red), var(--color-orange), var(--color-yellow), var(--color-green), var(--color-blue), var(--color-purple));
-webkit-background-clip: text;
color: transparent;
}
.page > .title h2 {
font-size: 1.5rem;
}
@ -177,11 +228,19 @@ span.inline {
/* SECTIONS */
.section {
display: flex;
flex-direction: column;
width: 100%;
}
.section > .header {
display: flex;
align-self: flex-start;
position: relative;
padding-right: 0.5rem;
display: inline-flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
@ -200,6 +259,20 @@ span.inline {
padding: 1rem 2rem;
}
.section > .content.rows {
flex-direction: row;
flex-wrap: wrap;
align-items: flex-start;
justify-content: center;
}
.section > .content.full-page {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
@ -217,21 +290,39 @@ span.inline {
border-radius: 2rem;
background-color: var(--color-bg-light);
}
.box.align-left {
align-items: flex-start;
}
.box.shrink {
display: inline-flex;
}
.box.important {
border: 0.5rem solid var(--theme);
}
.box.danger {
border: 0.5rem solid var(--color-red);
}
.box.danger * {
--theme: var(--color-red);
--theme-light: var(--color-red-light);
--theme-dark: var(--color-red-dark);
}
a.box:hover {
background-color: var(--color-gray-dark-dark);
}
.box .title, .box .extra {
display: inline-flex;
flex-direction: row;
justify-content: center;
align-items: center;
align-items: baseline;
gap: 0.5rem;
}
.box .title {
position: relative;
left: -0.5rem;
padding-left: 0.5rem;
color: var(--theme);
font-size: 1.5rem;
}
@ -390,8 +481,11 @@ span.inline {
justify-content: center;
gap: 1rem;
}
.button-list.align-left {
justify-content: flex-start;
}
.button {
.button, .button.disabled:hover {
align-items: center;
display: inline-flex;
@ -402,13 +496,31 @@ span.inline {
color: var(--color-white);
border-radius: 1rem;
background-color: var(--color-gray-dark-dark);
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.button.on-bg {
background-color: var(--color-bg-light);
}
.button:hover {
cursor: pointer;
}
.button:hover {
background-color: var(--color-gray-dark);
}
.button.on-bg:hover {
background-color: var(--color-gray-dark-dark);
}
.button.disabled {
opacity: 0.3;
}
.button.disabled:hover {
cursor: not-allowed;
}
.button.primary {
.button.primary, .button.primary.disabled:hover {
color: var(--color-bg);
background-color: var(--theme);
}
@ -416,15 +528,246 @@ span.inline {
background-color: var(--theme-dark);
}
.button .icon.big {
font-size: 2rem;
}
.button .text {
display: inline-flex;
flex-flow: column;
align-items: flex-start;
}
/* SECTION: NEWS */
.section > .content.rows > #newsletter, .section > .content.rows > #social-media {
align-items: flex-start;
}
.section > .content.rows > #newsletter {
flex-basis: 32rem;
flex-grow: 64;
}
.section > .content.rows > #social-media {
flex-basis: 16rem;
flex-grow: 1;
flex-shrink: 1;
}
.form-container {
position: relative;
width: 100%;
}
.form {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
gap: 1rem;
}
#newsletter-signup-form-mail-address {
min-width: 22rem;
}
.form-feedback {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: center;
}
.form-feedback .centertext {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
gap: 0.5rem;
}
.form-feedback-wait {
color: var(--color-blue);
}
.form-feedback-success {
color: var(--color-green);
}
.form-feedback-failure {
color: var(--color-red);
}
/* COPYLINKS */
.copylink {
position: absolute;
padding: 0.5rem;
font-size: 1rem;
color: #0000;
}
.title .copylink {
left: -1.3rem;
padding-right: 0.2rem;
}
.header .copylink {
right: -1.3rem;
padding-left: 0.2rem;
}
*:hover > .copylink {
color: var(--color-gray);
}
.copylink:hover, .copylink:focus-visible {
color: var(--color-white);
cursor: pointer;
}
.copylink.feedback-negative, .copylink.feedback-positive {
opacity: 0;
transition: opacity 1s 1.5s linear;
}
.copylink.feedback-negative {
color: var(--color-red);
}
.copylink.feedback-positive {
color: var(--color-green);
}
/* FORM ELEMENTS */
.key-value-pair {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: stretch;
}
.key-value-pair .key {
display: flex;
align-items: center;
padding: 1rem;
border-top-left-radius: 1rem;
border-bottom-left-radius: 1rem;
background-color: var(--theme);
color: var(--color-bg);
}
.key-value-pair .value-list {
flex-grow: 1;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-items: flex-start;
gap: 0.5rem;
}
.key-value-pair .value {
flex-grow: 1;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-items: flex-start;
gap: 0.5rem;
padding: 1rem;
border-top-right-radius: 1rem;
border-bottom-right-radius: 1rem;
background-color: var(--color-gray-dark-dark);
}
.inputwrapper {
position: relative;
width: 100%;
}
.inputwrapper.valid input, .inputwrapper.invalid input {
padding-right: 2.5rem;
}
.inputwrapper.valid::after, .inputwrapper.invalid::after {
position: absolute;
right: 1rem;
top: 50%;
transform: translateY(-50%);
display: block;
font-size: 1rem;
font-family: "tabler-icons" !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.inputwrapper.valid::after {
content: "\ea5e";
color: var(--color-green);
}
.inputwrapper.invalid::after {
content: "\eb55";
color: var(--color-red);
}
input {
width: 100%;
outline: none;
border: none;
margin: 0;
font-size: 1rem;
color: var(--color-white);
background: none;
}
input::placeholder {
color: var(--color-gray-light);
}
.value.switch {
flex-direction: row;
gap: 0;
padding: 0;
background: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.switch .option {
padding: 1rem;
background-color: var(--color-gray-dark-dark);
}
.switch .option:last-child {
border-top-right-radius: 1rem;
border-bottom-right-radius: 1rem;
}
.switch .option:hover {
background-color: var(--color-gray-dark);
cursor: pointer;
}
.switch .option.selected {
background-color: var(--theme-dark);
color: var(--color-bg);
}
/* FOOTER */
.footer {
@ -489,3 +832,19 @@ span.inline {
font-weight: bold;
color: inherit;
}
/* ANIMATION KIT */
.form-feedback .spinning {
animation-name: spinning;
animation-duration: 0.5s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
@keyframes spinning {
from { transform:rotate(0deg); }
to { transform:rotate(360deg); }
}

View File

@ -4,26 +4,26 @@
$dict->define([
"title" => [
"de" => "Selbstbestimmungsgesetz Jetzt!",
"en" => "Self-Determination Act Now!"
"de" => "SBGG.jetzt - Alle Infos zum Selbstbestimmungsgesetz",
"en" => "SBGG.jetzt - Everything about the German Self-Determination Law"
],
"description" => [
"de" => "Das TSG muss endlich durch ein Selbstbestimmungsgesetz ersetzt werden! Diese Seite verfolgt den Fortschritt der Gesetzgebung.",
"en" => "The TSG must be replaced by a Self-Determination Law! This page is tracking the progress of the legislation."
"de" => "Alle Infos zum Selbstbestimmungsgesetz an einem Ort",
"en" => "Everything about the German Self-Determination Law in one place"
],
"page_title_abolish" => [
"de" => "TSG abschaffen,",
"en" => "Abolish the TSG,"
"page_title_h1" => [
"de" => "SBGG.jetzt",
"en" => "SBGG.jetzt"
],
"page_title_introduce" => [
"de" => "<h1>Selbst&shy;bestim&shy;mungs&shy;gesetz</h1> einführen!",
"en" => "Introduce a <h1>Self-Determination Law</h1>!"
"page_title_h2" => [
"de" => "Alle Infos zum Selbstbestimmungsgesetz",
"en" => "Everything about the German Self-Determination Law"
],
@ -289,11 +289,11 @@
"timeline_lesung_2_text" => [
"de" => [
"Die zweite Lesung im Bundestag diskutiert die Ergebnisse der Ausschüsse. Einzelne Abgeordnete können Änderungen beantragen.",
"<span class=\"inline gray\">Hinweis: In der Tagesordnung des Deutschen Bundestags ist derzeit noch kein Termin für die zweite Lesung angesetzt. Nächste Sitzungswoche: ab 19 Feb 2024 (Stand: 30 Jan 2024)</span>"
"<span class=\"inline gray\">Hinweis: In der Tagesordnung des Deutschen Bundestags ist derzeit noch kein Termin für die zweite Lesung angesetzt. Nächste Sitzungswoche: ab 11 Mär 2024 (Stand: 19 Feb 2024)</span>"
],
"en" => [
"The second reading in the <i>Bundestag</i> (Parliament) discusses the results of the committees. Individual members of the Bundestag can request changes.",
"<span class=\"inline gray\">Note: The agenda of the <i>Bundestag</i> (Parliament) does currently not contain an appointment for the second reading. Next session week: from 19 Feb 2024 (As of 30 Jan 2024)</span>"
"<span class=\"inline gray\">Note: The agenda of the <i>Bundestag</i> (Parliament) does currently not contain an appointment for the second reading. Next session week: from 11 Mar 2024 (As of 19 Feb 2024)</span>"
]
],
"timeline_lesung_2_button" => [
@ -331,8 +331,8 @@
"timeline_inkrafttreten_date" => [
"de" => "01 Nov 2024",
"en" => "01 Nov 2024"
"de" => "01 Nov 2025",
"en" => "01 Nov 2025"
],
"timeline_inkrafttreten_title" => [
"de" => "Inkrafttreten des Gesetzes",
@ -341,11 +341,11 @@
"timeline_inkrafttreten_text" => [
"de" => [
"Insofern der Bundesrat keine Einwände hat, wird das Gesetz veröffentlicht und tritt an einem bestimmten Tag in Kraft.",
"<span class=\"inline gray\">Hinweis: Das Datum <i>01 Nov 2024</i> stammt aus Artikel 13 SBGG des Regierungsentwurfs und kann sich noch ändern.</span>"
"<span class=\"inline gray\">Hinweis: Das Datum <i>01 Nov 2025</i> stammt aus Ziffer 18 der <a href=\"https://web.archive.org/web/20240218225719/https://www.bundesrat.de/SharedDocs/drucksachen/2023/0401-0500/432-1-23.pdf?__blob=publicationFile&v=1\" target=\"_blank\">Empfehlungen der Ausschüsse vom 06 Oct 2023 <i class=\"ti ti-external-link\"></i></a> und kann sich noch ändern.</span>"
],
"en" => [
"If the <i>Bundesrat</i> (Federal Council) has no objections, the law will be published and will come into force on a specific date.",
"<span class=\"inline gray\">Note: The date <i>01 Nov 2024</i> is derived from the government draft and could still change.</span>"
"<span class=\"inline gray\">Note: The date <i>01 Nov 2025</i> is derived from clause 18 of the <a href=\"https://web.archive.org/web/20240218225719/https://www.bundesrat.de/SharedDocs/drucksachen/2023/0401-0500/432-1-23.pdf?__blob=publicationFile&v=1\" target=\"_blank\">recommendations of the committees from 06 Oct 2023 (german) <i class=\"ti ti-external-link\"></i></a> and could still change.</span>"
]
],
"timeline_inkrafttreten_button" => [
@ -357,6 +357,49 @@
"news_title" => [
"de" => "Bleib auf dem Laufenden",
"en" => "Stay up to date"
],
"news_newsletter_title" => [
"de" => "Newsletter",
"en" => "Newsletter"
],
"news_newsletter_mail_address" => [
"de" => "Deine Lieblings-Mail-Adresse",
"en" => "Your favorite mail address"
],
"news_newsletter_subscribe" => [
"de" => "Abonnieren",
"en" => "Subscribe"
],
"news_newsletter_note" => [
"de" => "Hinweis: Der Newsletter kann je nach Mail-Anbieter unter Umständen im Spam-Ordner landen.",
"en" => "Note: Depending on your mail provider, the newsletter may end up in your spam folder."
],
"news_newsletter_feedback_wait" => [
"de" => "Verifizierungs-Mail wird gesendet",
"en" => "Sending verification mail"
],
"news_newsletter_feedback_success" => [
"de" => "Verifizierungs-Mail versendet",
"en" => "Verification mail sent"
],
"news_newsletter_feedback_failure" => [
"de" => "Fehler bei der Versendung der Verifizierungs-Mail",
"en" => "Failed to send verification mail"
],
"news_social_media_title" => [
"de" => "Soziale Medien",
"en" => "Social Media"
],
"about_title" => [
"de" => "Über diese Webseite",
"en" => "About this Website"
@ -376,11 +419,6 @@
]
],
"about_disclaimer" => [
"de" => "Die Inhalte dieser Seite wurden sorgfältig recherchiert und nach bestem Wissen und Gewissen erstellt. Für die Korrektheit der Angaben wird jedoch keine Haftung übernommen.",
"en" => "The contents of this site have been carefully researched and created to the best of my knowledge and belief. However, no liability is assumed for the correctness of the information."
],
"about_button_mail" => [
"de" => "Kontakt",
"en" => "Contact"
@ -415,6 +453,87 @@
"link_privacy_policy" => [
"de" => "https://www.tjdev.de/datenschutz",
"en" => "https://www.tjdev.de/privacy"
]
],
"copylink_hint_text" => [
"de" => "Bereichs-Link kopieren",
"en" => "Copy section link"
],
"newsletter_subscribe_page_title" => [
"de" => "SBGG.jetzt - Newsletter Abonnieren",
"en" => "SBGG.jetzt - Subscribe to Newsletter"
],
"newsletter_subscribe_title" => [
"de" => "Newsletter Abonnieren",
"en" => "Subscribe to Newsletter"
],
"newsletter_subscribe_submit" => [
"de" => "Abonnieren",
"en" => "Subscribe"
],
"newsletter_subscribe_feedback_wait" => [
"de" => "Wird angemeldet",
"en" => "Subscribing"
],
"newsletter_subscribe_feedback_success" => [
"de" => "Erfolgreich angemeldet",
"en" => "Successfully subscribed"
],
"newsletter_subscribe_feedback_failure" => [
"de" => "Fehler bei der Anmeldung",
"en" => "Failed to subscribe"
],
"newsletter_subscribe_privacy_note" => [
"de" => [
"Deine Mail-Adresse wird ausschließlich zum Versenden des Newsletters verwendet und zu keinem Zeitpunkt an Dritte weitergegeben.",
"Du kannst Dich jederzeit über einen Link in den E-Mails wieder abmelden.",
"Mehr zum Thema Datenschutz erfährst Du in unserer <a href=\"https://www.tjdev.de/datenschutz\" target=\"_blank\">Datenschutzerklärung <i class=\"ti ti-external-link\"></i></a>."
],
"en" => [
"Your mail address is exclusively being used for the delivery of the newsletter and never being forwarded to third parties.",
"You can unsubscribe at any time via a link in the newsletter mails.",
"More about data privacy can be found in our <a href=\"https://www.tjdev.de/privacy\" target=\"_blank\">Privacy Policy <i class=\"ti ti-external-link\"></i></a>."
]
],
"newsletter_unsubscribe_page_title" => [
"de" => "SBGG.jetzt - Newsletter Abbestellen",
"en" => "SBGG.jetzt - Unsubscribe from Newsletter"
],
"newsletter_unsubscribe_title" => [
"de" => "Newsletter Abbestellen",
"en" => "Unsubscribe from Newsletter"
],
"newsletter_unsubscribe_submit" => [
"de" => "Abbestellen",
"en" => "Unsubscribe"
],
"newsletter_unsubscribe_feedback_wait" => [
"de" => "Wird abgemeldet",
"en" => "Unsubscribing"
],
"newsletter_unsubscribe_feedback_success" => [
"de" => "Erfolgreich abgemeldet",
"en" => "Successfully unsubscribed"
],
"newsletter_unsubscribe_feedback_failure" => [
"de" => "Fehler bei der Abmeldung",
"en" => "Failed to unsubscribe"
],
]);
?>

9
src/lib_phpmailer.php Normal file
View File

@ -0,0 +1,9 @@
<?php
declare(strict_types = 1);
namespace Kimendisch\Sbgg_Jetzt;
// LOAD PHPMAILER LIBRARY //
require_once("./lib/phpmailer/src/Exception.php");
require_once("./lib/phpmailer/src/SMTP.php");
require_once("./lib/phpmailer/src/PHPMailer.php");
?>

1014
src/newsletter.php Normal file

File diff suppressed because it is too large Load Diff