initial commit for rvr-nextgen
Some checks failed
rvr-nextgen/pipeline/head There was a failure building this commit
21
.env.example
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
APP_NAME="Travel Organizer and Register"
|
||||||
|
APP_URL=http://rvr.dev/
|
||||||
|
DEV=1
|
||||||
|
DB_HOST=mariadb
|
||||||
|
DB_USER=rvr
|
||||||
|
DB_PASSWORD=rvr
|
||||||
|
DB_NAME=rvr
|
||||||
|
GOOGLE_MAPS_SERVER_API_KEY=your_google_maps_server_api_key
|
||||||
|
GOOGLE_MAPS_JS_API_KEY=your_google_maps_js_api_key
|
||||||
|
LEAFLET_TILESERVER_URL=a_leaflet_compatible_tileserver_url
|
||||||
|
LEAFLET_TILESERVER_SUBDOMAINS=list_of_subdomains_for_the_tileserver_without_separators
|
||||||
|
LEAFLET_TILESERVER_ATTRIBUTION=attribution_to_be_shown_for_tiles
|
||||||
|
STATIC_ROOT=/static
|
||||||
|
MAIL_FROM=rvr@rvr-dev.ch
|
||||||
|
MAIL_HOST=mail
|
||||||
|
MAIL_PORT=2500
|
||||||
|
GOOGLE_OAUTH_CLIENT_ID=your_google_oauth_client_id
|
||||||
|
GOOGLE_OAUTH_CLIENT_SECRET=your_google_oauth_client_secret
|
||||||
|
GOOGLE_ANALITICS_ID=your_google_analytics_id
|
||||||
|
RECAPTCHA_SITEKEY=your_recaptcha_sitekey
|
||||||
|
RECAPTCHA_SECRET=your_recaptcha_secret
|
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.png filter=lfs diff=lfs merge=lfs -text
|
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.env
|
||||||
|
installed
|
||||||
|
vendor
|
||||||
|
node_modules
|
14
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Listen for XDebug in Docker",
|
||||||
|
"type": "php",
|
||||||
|
"request": "launch",
|
||||||
|
"port": 9000,
|
||||||
|
"pathMappings": {
|
||||||
|
"/var/www/rvr": "${workspaceRoot}",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
62
Jenkinsfile
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
node {
|
||||||
|
label 'rvr'
|
||||||
|
customWorkspace 'workspace/rvr'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Install composer') {
|
||||||
|
environment {
|
||||||
|
COMPOSER_HOME="${WORKSPACE}/.composer"
|
||||||
|
}
|
||||||
|
agent {
|
||||||
|
dockerfile {
|
||||||
|
filename 'docker/Dockerfile-test'
|
||||||
|
dir '.'
|
||||||
|
reuseNode true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'composer install'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Unit Testing') {
|
||||||
|
agent {
|
||||||
|
dockerfile {
|
||||||
|
filename 'docker/Dockerfile-test'
|
||||||
|
dir '.'
|
||||||
|
reuseNode true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'vendor/bin/phpunit --log-junit unit_test_results.xml --testdox tests'
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
archiveArtifacts 'unit_test_results.xml'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Static Code Analysis') {
|
||||||
|
agent {
|
||||||
|
dockerfile {
|
||||||
|
filename 'docker/Dockerfile-test'
|
||||||
|
dir '.'
|
||||||
|
reuseNode true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh 'php vendor/bin/phpstan analyse -c phpstan.neon --error-format=prettyJson > static_code_analysis_results.json'
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
archiveArtifacts 'static_code_analysis_results.json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
660
LICENSE.md
Normal file
@ -0,0 +1,660 @@
|
|||||||
|
### GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||||
|
<https://fsf.org/>
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies of this
|
||||||
|
license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
### Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains
|
||||||
|
free software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, 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
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing
|
||||||
|
under this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
### TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
#### 0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public
|
||||||
|
License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds
|
||||||
|
of works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of
|
||||||
|
an exact copy. The resulting work is called a "modified version" of
|
||||||
|
the earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user
|
||||||
|
through a computer network, with no transfer of a copy, is not
|
||||||
|
conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices" to
|
||||||
|
the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
#### 1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. "Object code" means any non-source form of
|
||||||
|
a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users can
|
||||||
|
regenerate automatically from other parts of the Corresponding Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that same
|
||||||
|
work.
|
||||||
|
|
||||||
|
#### 2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not convey,
|
||||||
|
without conditions so long as your license otherwise remains in force.
|
||||||
|
You may convey covered works to others for the sole purpose of having
|
||||||
|
them make modifications exclusively for you, or provide you with
|
||||||
|
facilities for running those works, provided that you comply with the
|
||||||
|
terms of this License in conveying all material for which you do not
|
||||||
|
control copyright. Those thus making or running the covered works for
|
||||||
|
you must do so exclusively on your behalf, under your direction and
|
||||||
|
control, on terms that prohibit them from making any copies of your
|
||||||
|
copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under the
|
||||||
|
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||||
|
it unnecessary.
|
||||||
|
|
||||||
|
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such
|
||||||
|
circumvention is effected by exercising rights under this License with
|
||||||
|
respect to the covered work, and you disclaim any intention to limit
|
||||||
|
operation or modification of the work as a means of enforcing, against
|
||||||
|
the work's users, your or third parties' legal rights to forbid
|
||||||
|
circumvention of technological measures.
|
||||||
|
|
||||||
|
#### 4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
#### 5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
- a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
- b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under
|
||||||
|
section 7. This requirement modifies the requirement in section 4
|
||||||
|
to "keep intact all notices".
|
||||||
|
- c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
- d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
#### 6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms of
|
||||||
|
sections 4 and 5, provided that you also convey the machine-readable
|
||||||
|
Corresponding Source under the terms of this License, in one of these
|
||||||
|
ways:
|
||||||
|
|
||||||
|
- a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
- b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the Corresponding
|
||||||
|
Source from a network server at no charge.
|
||||||
|
- c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
- d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
- e) Convey the object code using peer-to-peer transmission,
|
||||||
|
provided you inform other peers where the object code and
|
||||||
|
Corresponding Source of the work are being offered to the general
|
||||||
|
public at no charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal,
|
||||||
|
family, or household purposes, or (2) anything designed or sold for
|
||||||
|
incorporation into a dwelling. In determining whether a product is a
|
||||||
|
consumer product, doubtful cases shall be resolved in favor of
|
||||||
|
coverage. For a particular product received by a particular user,
|
||||||
|
"normally used" refers to a typical or common use of that class of
|
||||||
|
product, regardless of the status of the particular user or of the way
|
||||||
|
in which the particular user actually uses, or expects or is expected
|
||||||
|
to use, the product. A product is a consumer product regardless of
|
||||||
|
whether the product has substantial commercial, industrial or
|
||||||
|
non-consumer uses, unless such uses represent the only significant
|
||||||
|
mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to
|
||||||
|
install and execute modified versions of a covered work in that User
|
||||||
|
Product from a modified version of its Corresponding Source. The
|
||||||
|
information must suffice to ensure that the continued functioning of
|
||||||
|
the modified object code is in no case prevented or interfered with
|
||||||
|
solely because modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or
|
||||||
|
updates for a work that has been modified or installed by the
|
||||||
|
recipient, or for the User Product in which it has been modified or
|
||||||
|
installed. Access to a network may be denied when the modification
|
||||||
|
itself materially and adversely affects the operation of the network
|
||||||
|
or violates the rules and protocols for communication across the
|
||||||
|
network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
#### 7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders
|
||||||
|
of that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
- a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
- b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
- c) Prohibiting misrepresentation of the origin of that material,
|
||||||
|
or requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
- d) Limiting the use for publicity purposes of names of licensors
|
||||||
|
or authors of the material; or
|
||||||
|
- e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
- f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions
|
||||||
|
of it) with contractual assumptions of liability to the recipient,
|
||||||
|
for any liability that these contractual assumptions directly
|
||||||
|
impose on those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions; the
|
||||||
|
above requirements apply either way.
|
||||||
|
|
||||||
|
#### 8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your license
|
||||||
|
from a particular copyright holder is reinstated (a) provisionally,
|
||||||
|
unless and until the copyright holder explicitly and finally
|
||||||
|
terminates your license, and (b) permanently, if the copyright holder
|
||||||
|
fails to notify you of the violation by some reasonable means prior to
|
||||||
|
60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
#### 9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or run
|
||||||
|
a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
#### 10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
#### 11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims owned
|
||||||
|
or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within the
|
||||||
|
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||||
|
the non-exercise of one or more of the rights that are specifically
|
||||||
|
granted under this License. You may not convey a covered work if you
|
||||||
|
are a party to an arrangement with a third party that is in the
|
||||||
|
business of distributing software, under which you make payment to the
|
||||||
|
third party based on the extent of your activity of conveying the
|
||||||
|
work, and under which the third party grants, to any of the parties
|
||||||
|
who would receive the covered work from you, a discriminatory patent
|
||||||
|
license (a) in connection with copies of the covered work conveyed by
|
||||||
|
you (or copies made from those copies), or (b) primarily for and in
|
||||||
|
connection with specific products or compilations that contain the
|
||||||
|
covered work, unless you entered into that arrangement, or that patent
|
||||||
|
license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
#### 12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If 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 convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under
|
||||||
|
this License and any other pertinent obligations, then as a
|
||||||
|
consequence you may not convey it at all. For example, if you agree to
|
||||||
|
terms that obligate you to collect a royalty for further conveying
|
||||||
|
from those to whom you convey the Program, the only way you could
|
||||||
|
satisfy both those terms and this License would be to refrain entirely
|
||||||
|
from conveying the Program.
|
||||||
|
|
||||||
|
#### 13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your
|
||||||
|
version supports such interaction) an opportunity to receive the
|
||||||
|
Corresponding Source of your version by providing access to the
|
||||||
|
Corresponding Source from a network server at no charge, through some
|
||||||
|
standard or customary means of facilitating copying of software. This
|
||||||
|
Corresponding Source shall include the Corresponding Source for any
|
||||||
|
work covered by version 3 of the GNU General Public License that is
|
||||||
|
incorporated pursuant to the following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
#### 14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Affero 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 Program
|
||||||
|
specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future versions
|
||||||
|
of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
#### 15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||||
|
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||||
|
CORRECTION.
|
||||||
|
|
||||||
|
#### 16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||||
|
CONVEYS THE PROGRAM 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 PROGRAM (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 PROGRAM
|
||||||
|
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||||
|
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
#### 17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
### How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these
|
||||||
|
terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest to
|
||||||
|
attach them to the start of each source file to most effectively state
|
||||||
|
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 program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper
|
||||||
|
mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for
|
||||||
|
the specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. For more information on this, and how to apply and follow
|
||||||
|
the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
83
README.md
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
# RVR
|
||||||
|
|
||||||
|
[![Build Status](https://ci.esoko.eu/job/rvr-nextgen/job/master/badge/icon)](https://ci.esoko.eu/job/rvr-nextgen/job/master/)
|
||||||
|
|
||||||
|
This is the RVR Application project. This is a game about guessing where you are based on a street view panorama - inspired by existing applications.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Clone the Git repository
|
||||||
|
|
||||||
|
The first step is obviously cloning the repository to your machine:
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone https://git.esoko.eu/esoko/rvr-nextgen.git
|
||||||
|
```
|
||||||
|
|
||||||
|
All the commands listed here should be executed from the repository root.
|
||||||
|
|
||||||
|
### Setup Docker stack (recommended)
|
||||||
|
|
||||||
|
The easiest way to build up a fully working application with web server and database is to use Docker Compose with the included `docker-compose.yml`.
|
||||||
|
|
||||||
|
All you have to do is executing the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Attach shell to the container of `rvr-nextgen-app`:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker exec -it rvr-nextgen-app bash
|
||||||
|
```
|
||||||
|
|
||||||
|
All of the following commands should be executed there.
|
||||||
|
|
||||||
|
### Manual setup (alternative)
|
||||||
|
|
||||||
|
If you don't use the Docker stack you need to install your environment manually. Check `docker-compose.yml` and `docker/Dockerfile` to see the system requirements.
|
||||||
|
|
||||||
|
### Initialize project
|
||||||
|
|
||||||
|
This command installes all of the Composer requirements and creates a copy of the example `.env` file.
|
||||||
|
|
||||||
|
```
|
||||||
|
composer create-project
|
||||||
|
```
|
||||||
|
|
||||||
|
### Set environment variables
|
||||||
|
|
||||||
|
The `.env` file contains several environment variables that are needed by the application to work properly. These should be configured for your environment.
|
||||||
|
|
||||||
|
One very important variable is `DEV`. This indicates that the application operates in development (staging) and not in production mode.
|
||||||
|
|
||||||
|
**Hint:** If you install the application in the Docker stack for development (staging) environment, only the variables for external dependencies (API keys, map attribution, etc.) should be adapted. All other variables (for DB connection, static root, mailing, multiplayer, etc.) are fine with the default value.
|
||||||
|
|
||||||
|
### (Production only) Create cron job
|
||||||
|
|
||||||
|
To maintain database (delete inactive users, old sessions etc.), the command `db:maintain` should be regularly executed. It is recommended to create a cron job that runs every hour:
|
||||||
|
|
||||||
|
```
|
||||||
|
0 * * * * /path/to/your/installation/rvr db:maintain >>/var/log/cron-rvr.log 2>&1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Finalize installation
|
||||||
|
|
||||||
|
After you followed the above steps, execute the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
scripts/install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
**And you are done!** The application is ready to use and develop. In development mode an administrative user is also created by the installation script, email is **rvr@rvr.dev**, password is **123456**. In production mode you should create the first administrative user with the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
./rvr user:add EMAIL PASSWORD admin
|
||||||
|
```
|
||||||
|
|
||||||
|
If you installed it in the Docker stack, you can reach it on http://localhost. The mails that are sent by the application can be found on http://localhost:8080/. If needed, the database server can be directly reached on localhost:3306.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*License: **GNU AGPL 3.0**. Full license text can be found in file `LICENSE`.*
|
26
USED_SOFTWARE
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---------------------------------------------------------------
|
||||||
|
Bootstrap Icons
|
||||||
|
https://github.com/twbs/icons
|
||||||
|
---------------------------------------------------------------
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2019 The Bootstrap Authors
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
---------------------------------------------------------------
|
23
app.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
define('SCRIPT_STARTED', hrtime(true));
|
||||||
|
|
||||||
|
require 'vendor/autoload.php';
|
||||||
|
|
||||||
|
const ROOT = __DIR__;
|
||||||
|
const VERSION = '';
|
||||||
|
const REVISION = '';
|
||||||
|
const REVISION_DATE = '';
|
||||||
|
|
||||||
|
$dotenv = Dotenv\Dotenv::createImmutable(ROOT);
|
||||||
|
$dotenv->load();
|
||||||
|
|
||||||
|
class Container
|
||||||
|
{
|
||||||
|
static SokoWeb\Interfaces\Database\IConnection $dbConnection;
|
||||||
|
static SokoWeb\Routing\RouteCollection $routeCollection;
|
||||||
|
static SokoWeb\Interfaces\Session\ISessionHandler $sessionHandler;
|
||||||
|
static SokoWeb\Interfaces\Request\IRequest $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
Container::$dbConnection = new SokoWeb\Database\Mysql\Connection($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']);
|
2
cache/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
29
composer.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "esoko/rvr",
|
||||||
|
"type": "project",
|
||||||
|
"description": "RVR Application",
|
||||||
|
"license": "GNU AGPL 3.0",
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"url": "https://git.esoko.eu/esoko/soko-web.git",
|
||||||
|
"type": "git"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"esoko/soko-web": "0.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^9.6",
|
||||||
|
"phpstan/phpstan": "^1.10"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"RVR\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"post-root-package-install": [
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
3018
composer.lock
generated
Normal file
0
database/migrations/data/.gitkeep
Normal file
0
database/migrations/structure/.gitkeep
Normal file
39
database/rvr.sql
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET foreign_key_checks = 0;
|
||||||
|
|
||||||
|
CREATE TABLE `migrations` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`migration` varchar(255) NOT NULL,
|
||||||
|
`type` enum('structure','data') NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `sessions` (
|
||||||
|
`id` varchar(32) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,
|
||||||
|
`data` text NOT NULL,
|
||||||
|
`updated` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `users` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`email` varchar(100) NOT NULL,
|
||||||
|
`password` varchar(60) DEFAULT NULL,
|
||||||
|
`type` enum('user','admin') NOT NULL,
|
||||||
|
`google_sub` varchar(255) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
|
||||||
|
`created` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `email` (`email`),
|
||||||
|
UNIQUE KEY `google_sub` (`google_sub`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `user_password_resetters` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`user_id` int(10) unsigned NOT NULL,
|
||||||
|
`token` varchar(32) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,
|
||||||
|
`expires` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `user_id` (`user_id`),
|
||||||
|
KEY `token` (`token`),
|
||||||
|
CONSTRAINT `user_password_resetters_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
28
docker-compose.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: ./docker
|
||||||
|
dockerfile: Dockerfile-app
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/rvr
|
||||||
|
mariadb:
|
||||||
|
image: mariadb:10.3
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
volumes:
|
||||||
|
- mysql:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: 'root'
|
||||||
|
MYSQL_DATABASE: 'rvr'
|
||||||
|
MYSQL_USER: 'rvr'
|
||||||
|
MYSQL_PASSWORD: 'rvr'
|
||||||
|
mail:
|
||||||
|
image: marcopas/docker-mailslurper:latest
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
- 8085:8085
|
||||||
|
volumes:
|
||||||
|
mysql:
|
30
docker/Dockerfile-app
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
FROM ubuntu:focal
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
|
||||||
|
# Install Nginx, PHP and further necessary packages
|
||||||
|
RUN apt update --fix-missing
|
||||||
|
RUN apt install -y curl git unzip mariadb-client nginx \
|
||||||
|
php-apcu php-xdebug php7.4-cli php7.4-curl php7.4-fpm php7.4-mbstring php7.4-mysql php7.4-zip php7.4-xml
|
||||||
|
|
||||||
|
# Configure Nginx with PHP
|
||||||
|
RUN mkdir -p /run/php
|
||||||
|
COPY configs/nginx.conf /etc/nginx/sites-available/default
|
||||||
|
RUN echo "xdebug.remote_enable = 1" >> /etc/php/7.4/mods-available/xdebug.ini
|
||||||
|
RUN echo "xdebug.remote_autostart = 1" >> /etc/php/7.4/mods-available/xdebug.ini
|
||||||
|
RUN echo "xdebug.remote_connect_back = 1" >> /etc/php/7.4/mods-available/xdebug.ini
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
COPY scripts/install-composer.sh install-composer.sh
|
||||||
|
RUN ./install-composer.sh
|
||||||
|
|
||||||
|
# Install Node.js and required packages
|
||||||
|
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
|
||||||
|
RUN apt install -y nodejs
|
||||||
|
RUN npm install -g uglify-js clean-css-cli svgo yarn
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
VOLUME /var/www/rvr
|
||||||
|
WORKDIR /var/www/rvr
|
||||||
|
|
||||||
|
ENTRYPOINT /usr/sbin/php-fpm7.4 -F & /usr/sbin/nginx -g 'daemon off;'
|
6
docker/Dockerfile-test
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
FROM ubuntu:focal
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
|
||||||
|
RUN apt update && apt install -y curl git unzip php7.4-cli php7.4-mbstring php7.4-xml
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
23
docker/configs/nginx.conf
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
root /var/www/rvr/public;
|
||||||
|
|
||||||
|
index index.php index.html index.htm index.nginx-debian.html;
|
||||||
|
|
||||||
|
server_name rvr-dev.ch;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$args;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
include snippets/fastcgi-php.conf;
|
||||||
|
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
17
docker/scripts/install-composer.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
EXPECTED_CHECKSUM="$(curl -sL https://composer.github.io/installer.sig)"
|
||||||
|
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
|
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
||||||
|
|
||||||
|
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
|
||||||
|
then
|
||||||
|
>&2 echo 'ERROR: Invalid installer checksum'
|
||||||
|
rm composer-setup.php
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||||
|
RESULT=$?
|
||||||
|
rm composer-setup.php
|
||||||
|
exit $RESULT
|
13
mail/password-reset.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Hi,
|
||||||
|
<br><br>
|
||||||
|
You recently requested password reset on {{APP_NAME}} with this email address ({{EMAIL}}).
|
||||||
|
To reset the password to your account, please click on the following link:<br>
|
||||||
|
<a href="{{RESET_LINK}}" title="Reset password">{{RESET_LINK}}</a>
|
||||||
|
<br><br>
|
||||||
|
You can reset your password with this link util {{EXPIRES}}.
|
||||||
|
<br><br>
|
||||||
|
If you did not requested password reset, no further action is required, your account is not touched.
|
||||||
|
<br><br>
|
||||||
|
Regards,<br>
|
||||||
|
{{APP_NAME}}<br>
|
||||||
|
<a href="{{BASE_URL}}" title="{{APP_NAME}}">{{BASE_URL}}</a>
|
9
mail/signup-noconfirm.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Hi,
|
||||||
|
<br><br>
|
||||||
|
You recently signed up on {{APP_NAME}} with this Google account ({{EMAIL}}).
|
||||||
|
<br><br>
|
||||||
|
Have fun on {{APP_NAME}}!
|
||||||
|
<br><br>
|
||||||
|
Regards,<br>
|
||||||
|
{{APP_NAME}}<br>
|
||||||
|
<a href="{{BASE_URL}}" title="{{APP_NAME}}">{{BASE_URL}}</a>
|
18
mail/signup.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
Hi,
|
||||||
|
<br><br>
|
||||||
|
You recently signed up on {{APP_NAME}} with this email address ({{EMAIL}}).
|
||||||
|
To activate your account, please click on the following link:<br>
|
||||||
|
<a href="{{ACTIVATE_LINK}}" title="Account activation">{{ACTIVATE_LINK}}</a>
|
||||||
|
<br><br>
|
||||||
|
You can activate your account until {{ACTIVATABLE_UNTIL}}.
|
||||||
|
If you don't activate your account, your email address will be permanently deleted after this point of time.
|
||||||
|
<br><br>
|
||||||
|
If you did not sign up on {{APP_NAME}} or changed your mind, no further action is required.
|
||||||
|
However if you want to immediately delete your email address, please click on the following link:<br>
|
||||||
|
<a href="{{CANCEL_LINK}}" title="Sign up cancellation">{{CANCEL_LINK}}</a>
|
||||||
|
<br><br>
|
||||||
|
Have fun on {{APP_NAME}}!
|
||||||
|
<br><br>
|
||||||
|
Regards,<br>
|
||||||
|
{{APP_NAME}}<br>
|
||||||
|
<a href="{{BASE_URL}}" title="{{APP_NAME}}">{{BASE_URL}}</a>
|
9
phpstan.neon
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
parameters:
|
||||||
|
level: 5
|
||||||
|
checkMissingIterableValueType: false
|
||||||
|
paths:
|
||||||
|
- app.php
|
||||||
|
- rvr
|
||||||
|
- web.php
|
||||||
|
- src
|
||||||
|
- tests
|
5
public/.htaccess
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
RewriteEngine On
|
||||||
|
RewriteBase /
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ index.php [L]
|
58
public/index.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use SokoWeb\Interfaces\Response\IRedirect;
|
||||||
|
use SokoWeb\Response\Redirect;
|
||||||
|
|
||||||
|
require '../web.php';
|
||||||
|
|
||||||
|
$method = strtolower($_SERVER['REQUEST_METHOD']);
|
||||||
|
$url = substr($_SERVER['REQUEST_URI'], strlen('/'));
|
||||||
|
if (($pos = strpos($url, '?')) !== false) {
|
||||||
|
$url = substr($url, 0, $pos);
|
||||||
|
}
|
||||||
|
$url = rawurldecode($url);
|
||||||
|
|
||||||
|
$match = Container::$routeCollection->match($method, $url == '' ? [] : explode('/', $url));
|
||||||
|
|
||||||
|
if ($match !== null) {
|
||||||
|
list($route, $params) = $match;
|
||||||
|
|
||||||
|
Container::$request->setParsedRouteParams($params);
|
||||||
|
|
||||||
|
$handler = $route->getHandler();
|
||||||
|
$controller = new $handler[0](Container::$request);
|
||||||
|
|
||||||
|
if ($controller instanceof SokoWeb\Interfaces\Authorization\ISecured) {
|
||||||
|
$authorized = $controller->authorize();
|
||||||
|
} else {
|
||||||
|
$authorized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$authorized) {
|
||||||
|
Container::$request->session()->set('redirect_after_login', $url);
|
||||||
|
$response = new Redirect(Container::$routeCollection->getRoute('login')->generateLink(), IRedirect::TEMPORARY);
|
||||||
|
header('Location: ' . $response->getUrl(), true, $response->getHttpCode());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($method === 'post' && Container::$request->post('anti_csrf_token') !== Container::$request->session()->get('anti_csrf_token')) {
|
||||||
|
$content = new SokoWeb\Response\JsonContent(['error' => 'no_valid_anti_csrf_token']);
|
||||||
|
header('Content-Type: text/html; charset=UTF-8', true, 403);
|
||||||
|
$content->render();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = call_user_func([$controller, $handler[1]]);
|
||||||
|
if ($response instanceof SokoWeb\Interfaces\Response\IContent) {
|
||||||
|
header('Content-Type: ' . $response->getContentType() . '; charset=UTF-8');
|
||||||
|
$response->render();
|
||||||
|
return;
|
||||||
|
} elseif ($response instanceof SokoWeb\Interfaces\Response\IRedirect) {
|
||||||
|
header('Location: ' . $response->getUrl(), true, $response->getHttpCode());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = new SokoWeb\Response\HtmlContent('error/404');
|
||||||
|
header('Content-Type: text/html; charset=UTF-8', true, 404);
|
||||||
|
$content->render();
|
1
public/static/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules
|
573
public/static/css/rvr.css
Normal file
@ -0,0 +1,573 @@
|
|||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
font-size: 100%;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
button::-moz-focus-inner, input::-moz-focus-inner {
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* to be compatible with browsers that don't know <main> */
|
||||||
|
main {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
::selection {
|
||||||
|
background-color: #3b5998;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
p, h1, h2, h3, input, textarea, select, button, a, table, label {
|
||||||
|
font-family: 'Oxygen', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3 {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1>a:link, h1>a:visited {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1>a:hover, h1>a:focus {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p, h2, h3 {
|
||||||
|
line-height: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
sup, sub {
|
||||||
|
position: relative;
|
||||||
|
font-size: smaller;
|
||||||
|
}
|
||||||
|
|
||||||
|
sup {
|
||||||
|
vertical-align: top;
|
||||||
|
top: -0.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub {
|
||||||
|
vertical-align: bottom;
|
||||||
|
bottom: -0.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
border: solid #bbbbbb 1px;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bold {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.small, span.small {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.justify {
|
||||||
|
text-align: justify;
|
||||||
|
}
|
||||||
|
|
||||||
|
.marginTop {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.marginLeft {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.marginBottom {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.marginRight {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg.inline, img.inline {
|
||||||
|
display: inline;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
margin-right: 0.3em;
|
||||||
|
vertical-align: -0.15em;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:link, a:visited {
|
||||||
|
color: #3b5998;
|
||||||
|
font-weight: 700;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover, a:focus {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
button, a.button {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #ffffff;
|
||||||
|
background-color: #5e77aa;
|
||||||
|
padding: 0 15px;
|
||||||
|
height: 35px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 3px;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.small, div.inputWithButton>button {
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 0 12px;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.small {
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.inputWithButton>button {
|
||||||
|
border-radius: 2px;
|
||||||
|
height: 27px;
|
||||||
|
line-height: 27px;
|
||||||
|
width: 75px;
|
||||||
|
margin-left: -79px;
|
||||||
|
vertical-align: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:enabled:hover, button:enabled:focus, a.button:hover, a.button:focus {
|
||||||
|
background-color: #29457f;
|
||||||
|
outline: none;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
color: #dddddd;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.fullWidth, a.button.fullWidth {
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.noLeftRadius, a.button.noLeftRadius {
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.noRightRadius, a.button.noRightRadius {
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.gray, a.button.gray {
|
||||||
|
background-color: #808080;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.gray:enabled:hover, button.gray:enabled:focus, a.button.gray:hover, a.button.gray:focus {
|
||||||
|
background-color: #555555;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.red, a.button.red {
|
||||||
|
background-color: #aa5e5e;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.red:enabled:hover, button.red:enabled:focus, a.button.red:hover, a.button.red:focus {
|
||||||
|
background-color: #7f2929;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.yellow, a.button.yellow {
|
||||||
|
background-color: #e8a349;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.yellow:enabled:hover, button.yellow:enabled:focus, a.button.yellow:hover, a.button.yellow:focus {
|
||||||
|
background-color: #c37713;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.green, a.button.green {
|
||||||
|
background-color: #28a745;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.green:enabled:hover, button.green:enabled:focus, a.button.green:hover, a.button.green:focus {
|
||||||
|
background-color: #1b7d31;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.text, select, textarea {
|
||||||
|
background-color: #f9fafb;
|
||||||
|
border: solid #c8d2e1 1px;
|
||||||
|
border-radius: 2px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.text, select {
|
||||||
|
height: 30px;
|
||||||
|
line-height: 30px;
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=checkbox], input[type=radio] {
|
||||||
|
margin-right: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
padding: 5px;
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.text.big, select.big, textarea.big, div.inputWithButton>input.text {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.text.big, select.big, div.inputWithButton>input.text {
|
||||||
|
height: 35px;
|
||||||
|
line-height: 35px;
|
||||||
|
padding: 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea.big {
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.fullWidth, select.fullWidth, textarea.fullWidth {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.text:disabled, select:disabled, textarea:disabled {
|
||||||
|
background-color: #dfdfdf;
|
||||||
|
border: solid #dfdfdf 1px;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.text:focus, select:focus, textarea:focus {
|
||||||
|
background-color: #ffffff;
|
||||||
|
border: solid #29457f 2px;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.text:focus, select:focus {
|
||||||
|
padding: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea:focus {
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.text.big:focus, select.big:focus {
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.inputWithButton>input.text {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0 83px 0 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.inputWithButton>input.text:focus {
|
||||||
|
padding: 0 82px 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea.big:focus {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.modal {
|
||||||
|
position: fixed;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-radius: 3px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow-y: auto;
|
||||||
|
z-index: 6;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cover {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
background-color: #000000;
|
||||||
|
opacity: 0.5;
|
||||||
|
z-index: 5;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.error, p.formError {
|
||||||
|
color: #7f2929;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.formError {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto auto;
|
||||||
|
background-color: #212f4d;
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
padding: 0 12px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
header>p {
|
||||||
|
line-height: inherit;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
header>p>span {
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
header>p>span>a:link, header>p>span>a:visited {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
header>p>span:not(:last-child) {
|
||||||
|
border-right: solid white 1px;
|
||||||
|
padding-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
background-color: #ffffff;
|
||||||
|
padding: 6px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
main.full {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: calc(100% - 40px);
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
background-color: #869ab9;
|
||||||
|
padding: 3px 6px;
|
||||||
|
color: #181f28;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer>p {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.buttonContainer {
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.buttonContainer>button {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cookiesNotice {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
margin: 20px;
|
||||||
|
background-color: #eeeeee;
|
||||||
|
border: solid #888888 1px;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 10px;
|
||||||
|
text-align: center;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
#loading {
|
||||||
|
position: fixed;
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
margin-top: -32px;
|
||||||
|
margin-left: -32px;
|
||||||
|
z-index: 7;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.box {
|
||||||
|
width: 576px;
|
||||||
|
background-color: #eeeeee;
|
||||||
|
border-radius: 3px;
|
||||||
|
margin: 10px auto;
|
||||||
|
padding: 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.circleControl {
|
||||||
|
position: absolute;
|
||||||
|
width: 60px;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.circleControl .controlItem {
|
||||||
|
position: relative;
|
||||||
|
height: 60px;
|
||||||
|
margin-top: 10px;
|
||||||
|
opacity: 70%;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.circleControl .controlItem:hover {
|
||||||
|
opacity: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.circleControl .controlItem div {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.circleControl .controlBackground {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
opacity: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.circleControl .controlIcon {
|
||||||
|
width: 75%;
|
||||||
|
height: 75%;
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 599px) {
|
||||||
|
header h1 span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
footer>p:not(:first-child) {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
button, a.button {
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
button.marginLeft, a.button.marginLeft {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
button.marginRight, a.button.marginRight {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
div.modal {
|
||||||
|
left: 20px;
|
||||||
|
right: 20px;
|
||||||
|
padding-left: 15px;
|
||||||
|
padding-right: 15px;
|
||||||
|
}
|
||||||
|
div.box {
|
||||||
|
width: initial;
|
||||||
|
}
|
||||||
|
.circleControl {
|
||||||
|
width: 45px;
|
||||||
|
}
|
||||||
|
.circleControl .controlItem {
|
||||||
|
height: 45px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 600px) {
|
||||||
|
footer>p {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
footer>p:not(:first-child) {
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
footer>p:not(:last-child) {
|
||||||
|
border-right: solid #181f28 1px;
|
||||||
|
padding-right: 6px;
|
||||||
|
}
|
||||||
|
div.modal {
|
||||||
|
width: 540px;
|
||||||
|
left: 50%;
|
||||||
|
margin-left: -270px;
|
||||||
|
padding-left: 20px;
|
||||||
|
padding-right: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-height: 399px) {
|
||||||
|
div.modal {
|
||||||
|
top: 20px;
|
||||||
|
max-height: calc(100% - 40px);
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
.circleControl {
|
||||||
|
width: 45px;
|
||||||
|
}
|
||||||
|
.circleControl .controlItem {
|
||||||
|
height: 45px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-height: 400px) and (max-height: 499px) {
|
||||||
|
div.modal {
|
||||||
|
top: 50px;
|
||||||
|
max-height: calc(100% - 100px);
|
||||||
|
padding-top: 15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-height: 500px) {
|
||||||
|
div.modal {
|
||||||
|
top: 75px;
|
||||||
|
max-height: calc(100% - 150px);
|
||||||
|
padding-top: 15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
}
|
BIN
public/static/img/favicon/16x16.png
(Stored with Git LFS)
Normal file
BIN
public/static/img/favicon/192x192.png
(Stored with Git LFS)
Normal file
BIN
public/static/img/favicon/32x32.png
(Stored with Git LFS)
Normal file
BIN
public/static/img/favicon/96x96.png
(Stored with Git LFS)
Normal file
2
public/static/img/favicon/SOURCE
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
The PNGs in this folder are generated from '../icon.svg'.
|
||||||
|
Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'.
|
5
public/static/img/icon.svg
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<!-- Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="#869ab9" viewBox="0 0 16 16">
|
||||||
|
<path d="m8.335 6.982.8 1.386a.25.25 0 0 0 .451-.039l1.06-2.882a.25.25 0 0 0-.192-.333l-3.026-.523a.25.25 0 0 0-.26.371l.667 1.154-.621.373A2.5 2.5 0 0 0 6 8.632V11h1V8.632a1.5 1.5 0 0 1 .728-1.286l.607-.364Z"/>
|
||||||
|
<path fill-rule="evenodd" d="M6.95.435c.58-.58 1.52-.58 2.1 0l6.515 6.516c.58.58.58 1.519 0 2.098L9.05 15.565c-.58.58-1.519.58-2.098 0L.435 9.05a1.482 1.482 0 0 1 0-2.098L6.95.435Zm1.4.7a.495.495 0 0 0-.7 0L1.134 7.65a.495.495 0 0 0 0 .7l6.516 6.516a.495.495 0 0 0 .7 0l6.516-6.516a.495.495 0 0 0 0-.7L8.35 1.134Z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 737 B |
23
public/static/img/loading.svg
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<svg viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g>
|
||||||
|
<linearGradient id="linear-gradient">
|
||||||
|
<stop offset="0%" stop-color="#ffffff" />
|
||||||
|
<stop offset="100%" stop-color="#000000" />
|
||||||
|
</linearGradient>
|
||||||
|
<circle
|
||||||
|
fill="none"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="url(#linear-gradient)"
|
||||||
|
stroke-width="6"
|
||||||
|
cx="25"
|
||||||
|
cy="25"
|
||||||
|
r="22" />
|
||||||
|
<animateTransform
|
||||||
|
attributeName="transform"
|
||||||
|
type="rotate"
|
||||||
|
from="0 25 25"
|
||||||
|
to="360 25 25"
|
||||||
|
dur="1.25"
|
||||||
|
repeatCount="indefinite" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 732 B |
10
public/static/img/markers/marker-blue-empty.svg
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!-- Original image: Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. -->
|
||||||
|
<svg viewBox="0 0 12 16" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path
|
||||||
|
fill="#3183ce"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#19456d"
|
||||||
|
stroke-width="0.3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
d="m 5.9999998,15.849652 c 0,0 5.8511182,-5.579947 5.8511182,-9.8134832 a 5.8511179,5.8880898 0 0 0 -11.7022358,0 c 0,4.2335362 5.8511176,9.8134832 5.8511176,9.8134832" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 529 B |
16
public/static/img/markers/marker-blue.svg
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!-- Original image: Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. -->
|
||||||
|
<svg viewBox="0 0 12 16" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path
|
||||||
|
fill="#3183ce"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#19456d"
|
||||||
|
stroke-width="0.3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
d="m 5.9999998,15.849652 c 0,0 5.8511182,-5.579947 5.8511182,-9.8134832 a 5.8511179,5.8880898 0 0 0 -11.7022358,0 c 0,4.2335362 5.8511176,9.8134832 5.8511176,9.8134832" />
|
||||||
|
<circle
|
||||||
|
fill="#19456d"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
cx="6"
|
||||||
|
cy="6"
|
||||||
|
r="3" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 639 B |
10
public/static/img/markers/marker-gray-empty.svg
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!-- Original image: Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. -->
|
||||||
|
<svg viewBox="0 0 12 16" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path
|
||||||
|
fill="#828282"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#383838"
|
||||||
|
stroke-width="0.3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
d="m 5.9999998,15.849652 c 0,0 5.8511182,-5.579947 5.8511182,-9.8134832 a 5.8511179,5.8880898 0 0 0 -11.7022358,0 c 0,4.2335362 5.8511176,9.8134832 5.8511176,9.8134832" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 529 B |
16
public/static/img/markers/marker-gray.svg
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!-- Original image: Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. -->
|
||||||
|
<svg viewBox="0 0 12 16" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path
|
||||||
|
fill="#828282"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#383838"
|
||||||
|
stroke-width="0.3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
d="m 5.9999998,15.849652 c 0,0 5.8511182,-5.579947 5.8511182,-9.8134832 a 5.8511179,5.8880898 0 0 0 -11.7022358,0 c 0,4.2335362 5.8511176,9.8134832 5.8511176,9.8134832" />
|
||||||
|
<circle
|
||||||
|
fill="#383838"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
cx="6"
|
||||||
|
cy="6"
|
||||||
|
r="3" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 639 B |
10
public/static/img/markers/marker-green-empty.svg
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!-- Original image: Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. -->
|
||||||
|
<svg viewBox="0 0 12 16" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path
|
||||||
|
fill="#28a745"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#285624"
|
||||||
|
stroke-width="0.3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
d="m 5.9999998,15.849652 c 0,0 5.8511182,-5.579947 5.8511182,-9.8134832 a 5.8511179,5.8880898 0 0 0 -11.7022358,0 c 0,4.2335362 5.8511176,9.8134832 5.8511176,9.8134832" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 529 B |
16
public/static/img/markers/marker-green.svg
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!-- Original image: Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. -->
|
||||||
|
<svg viewBox="0 0 12 16" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path
|
||||||
|
fill="#28a745"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#285624"
|
||||||
|
stroke-width="0.3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
d="m 5.9999998,15.849652 c 0,0 5.8511182,-5.579947 5.8511182,-9.8134832 a 5.8511179,5.8880898 0 0 0 -11.7022358,0 c 0,4.2335362 5.8511176,9.8134832 5.8511176,9.8134832" />
|
||||||
|
<circle
|
||||||
|
fill="#285624"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
cx="6"
|
||||||
|
cy="6"
|
||||||
|
r="3" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 639 B |
16
public/static/img/markers/marker-red.svg
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!-- Original image: Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. -->
|
||||||
|
<svg viewBox="0 0 12 16" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path
|
||||||
|
fill="#d24d4d"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#752929"
|
||||||
|
stroke-width="0.3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
d="m 5.9999998,15.849652 c 0,0 5.8511182,-5.579947 5.8511182,-9.8134832 a 5.8511179,5.8880898 0 0 0 -11.7022358,0 c 0,4.2335362 5.8511176,9.8134832 5.8511176,9.8134832" />
|
||||||
|
<circle
|
||||||
|
fill="#752929"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
cx="6"
|
||||||
|
cy="6"
|
||||||
|
r="3" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 639 B |
69
public/static/js/account/account.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
var Account = {
|
||||||
|
original: null,
|
||||||
|
countdown: null,
|
||||||
|
|
||||||
|
openGoogleAuthenticate: function () {
|
||||||
|
window.open('/account/googleAuthenticate', 'googleAuthenticate', 'height=600,width=600')
|
||||||
|
},
|
||||||
|
|
||||||
|
authenticatedWithGoogleCallback: function (authenticatedWithGoogleUntil) {
|
||||||
|
var password = document.getElementsByTagName('form')[0].elements.password;
|
||||||
|
var button = document.getElementById('authenticateWithGoogleButton');
|
||||||
|
|
||||||
|
Account.original = {
|
||||||
|
type: password.type,
|
||||||
|
placeholder: password.placeholder,
|
||||||
|
required: password.required,
|
||||||
|
disabled: password.disabled
|
||||||
|
};
|
||||||
|
|
||||||
|
password.type = 'text';
|
||||||
|
password.placeholder = 'Authenticated!'
|
||||||
|
password.value = '';
|
||||||
|
password.required = false;
|
||||||
|
password.disabled = true;
|
||||||
|
|
||||||
|
button.disabled = true;
|
||||||
|
|
||||||
|
Account.countdown = setInterval(function () {
|
||||||
|
var timeLeft = Math.ceil((authenticatedWithGoogleUntil.getTime() - new Date().getTime()) / 1000);
|
||||||
|
|
||||||
|
if (timeLeft > 30) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeLeft <= 0) {
|
||||||
|
Account.resetGoogleAuthentication();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
password.placeholder = 'Authenticated! ' + timeLeft + ' seconds left...';
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
|
||||||
|
resetGoogleAuthentication: function () {
|
||||||
|
if (Account.countdown !== null) {
|
||||||
|
clearInterval(Account.countdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
var password = document.getElementsByTagName('form')[0].elements.password;
|
||||||
|
var button = document.getElementById('authenticateWithGoogleButton');
|
||||||
|
|
||||||
|
password.type = Account.original.type;
|
||||||
|
password.placeholder = Account.original.placeholder
|
||||||
|
password.required = Account.original.required;
|
||||||
|
password.disabled = Account.original.disabled;
|
||||||
|
|
||||||
|
button.disabled = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
document.getElementById('authenticateWithGoogleButton').onclick = function () {
|
||||||
|
Account.openGoogleAuthenticate();
|
||||||
|
};
|
||||||
|
|
||||||
|
document.getElementsByTagName('form')[0].onreset = function () {
|
||||||
|
Account.resetGoogleAuthentication();
|
||||||
|
};
|
||||||
|
})();
|
10
public/static/js/account/google_authenticate.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
(function () {
|
||||||
|
if (success) {
|
||||||
|
window.opener.Account.authenticatedWithGoogleCallback(authenticatedWithGoogleUntil);
|
||||||
|
window.close();
|
||||||
|
} else {
|
||||||
|
document.getElementById('closeWindowButton').onclick = function () {
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
226
public/static/js/rvr.js
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
var RVR = {
|
||||||
|
isSecure: window.location.protocol === 'https:',
|
||||||
|
cookiesAgreed: false,
|
||||||
|
sessionAvailableHooks: {},
|
||||||
|
|
||||||
|
initGoogleAnalitics: function () {
|
||||||
|
if (typeof GOOGLE_ANALITICS_ID === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Global site tag (gtag.js) - Google Analytics
|
||||||
|
var script = document.createElement('script');
|
||||||
|
script.src = 'https://www.googletagmanager.com/gtag/js?id=' + GOOGLE_ANALITICS_ID;
|
||||||
|
script.async = true;
|
||||||
|
|
||||||
|
document.head.appendChild(script);
|
||||||
|
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag() { dataLayer.push(arguments); }
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', GOOGLE_ANALITICS_ID);
|
||||||
|
},
|
||||||
|
|
||||||
|
httpRequest: function (method, url, callback, data) {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xhr.onload = callback;
|
||||||
|
|
||||||
|
xhr.open(method, url, true);
|
||||||
|
|
||||||
|
xhr.responseType = 'json';
|
||||||
|
|
||||||
|
if (method === 'POST') {
|
||||||
|
if (typeof data === 'undefined') {
|
||||||
|
data = new FormData();
|
||||||
|
}
|
||||||
|
|
||||||
|
data.append('anti_csrf_token', ANTI_CSRF_TOKEN);
|
||||||
|
|
||||||
|
xhr.send(data);
|
||||||
|
} else {
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setOnsubmitForForm: function (form) {
|
||||||
|
form.onsubmit = function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
document.getElementById('loading').style.visibility = 'visible';
|
||||||
|
|
||||||
|
var formData = new FormData(form);
|
||||||
|
var formError = form.getElementsByClassName('formError')[0];
|
||||||
|
var pageLeaveOnSuccess = form.dataset.redirectOnSuccess || form.dataset.reloadOnSuccess;
|
||||||
|
|
||||||
|
RVR.httpRequest('POST', form.action, function () {
|
||||||
|
if (!pageLeaveOnSuccess) {
|
||||||
|
document.getElementById('loading').style.visibility = 'hidden';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.response.error) {
|
||||||
|
if (pageLeaveOnSuccess) {
|
||||||
|
document.getElementById('loading').style.visibility = 'hidden';
|
||||||
|
}
|
||||||
|
|
||||||
|
formError.style.display = 'block';
|
||||||
|
formError.innerHTML = this.response.error.errorText;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.response.redirect) {
|
||||||
|
window.location.replace(this.response.redirect.target);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pageLeaveOnSuccess) {
|
||||||
|
formError.style.display = 'none';
|
||||||
|
form.reset();
|
||||||
|
} else {
|
||||||
|
if (form.dataset.redirectOnSuccess) {
|
||||||
|
window.location.replace(form.dataset.redirectOnSuccess);
|
||||||
|
} else if (form.dataset.reloadOnSuccess) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, formData);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
showModal: function (id) {
|
||||||
|
document.getElementById(id).style.visibility = 'visible';
|
||||||
|
document.getElementById('cover').style.visibility = 'visible';
|
||||||
|
},
|
||||||
|
|
||||||
|
showModalWithContent: function (title, body, extraButtons) {
|
||||||
|
if (typeof extraButtons === 'undefined') {
|
||||||
|
extraButtons = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
RVR.showModal('modal');
|
||||||
|
|
||||||
|
document.getElementById('modalTitle').textContent = title;
|
||||||
|
|
||||||
|
if (typeof body === 'object') {
|
||||||
|
document.getElementById('modalText').appendChild(body);
|
||||||
|
} else {
|
||||||
|
document.getElementById('modalText').textContent = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
var buttons = document.getElementById('modalButtons');
|
||||||
|
buttons.textContent = '';
|
||||||
|
|
||||||
|
for (var i = 0; i < extraButtons.length; i++) {
|
||||||
|
var extraButton = extraButtons[i];
|
||||||
|
var button = document.createElement(extraButton.type);
|
||||||
|
|
||||||
|
if (extraButton.type === 'a') {
|
||||||
|
button.classList.add('button');
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < extraButton.classNames.length; i++) {
|
||||||
|
button.classList.add(extraButton.classNames[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.classList.add('marginTop');
|
||||||
|
button.classList.add('marginRight');
|
||||||
|
button.textContent = extraButton.text;
|
||||||
|
|
||||||
|
if (extraButton.type === 'a') {
|
||||||
|
button.href = extraButton.href;
|
||||||
|
} else if (extraButton.type === 'button') {
|
||||||
|
button.onclick = extraButton.onclick;
|
||||||
|
}
|
||||||
|
|
||||||
|
buttons.appendChild(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
var closeButton = document.createElement('button');
|
||||||
|
|
||||||
|
closeButton.classList.add('gray');
|
||||||
|
closeButton.classList.add('marginTop');
|
||||||
|
closeButton.textContent = 'Close';
|
||||||
|
closeButton.onclick = function () {
|
||||||
|
RVR.hideModal();
|
||||||
|
};
|
||||||
|
|
||||||
|
buttons.appendChild(closeButton);
|
||||||
|
},
|
||||||
|
|
||||||
|
hideModal: function () {
|
||||||
|
var modals = document.getElementsByClassName('modal');
|
||||||
|
|
||||||
|
for (var i = 0; i < modals.length; i++) {
|
||||||
|
modals[i].style.visibility = 'hidden';
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('cover').style.visibility = 'hidden';
|
||||||
|
},
|
||||||
|
|
||||||
|
observeInput: function (input, buttonToToggle) {
|
||||||
|
if (input.defaultValue !== input.value) {
|
||||||
|
buttonToToggle.disabled = false;
|
||||||
|
} else {
|
||||||
|
buttonToToggle.disabled = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
observeInputsInForm: function (form, observedInputs) {
|
||||||
|
for (var i = 0; i < observedInputs.length; i++) {
|
||||||
|
var input = form.elements[observedInputs[i]];
|
||||||
|
|
||||||
|
switch (input.tagName) {
|
||||||
|
case 'INPUT':
|
||||||
|
case 'TEXTAREA':
|
||||||
|
input.oninput = function () {
|
||||||
|
RVR.observeInput(this, form.elements.submit);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'SELECT':
|
||||||
|
input.onchange = function () {
|
||||||
|
RVR.observeInput(this, form.elements.submit);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
form.onreset = function () {
|
||||||
|
form.elements.submit.disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var anchors = document.getElementsByTagName('a');
|
||||||
|
for (var i = 0; i < anchors.length; i++) {
|
||||||
|
var a = anchors[i];
|
||||||
|
if (a.href !== 'javascript:;' && a.target !== '_blank') {
|
||||||
|
a.onclick = function () {
|
||||||
|
document.getElementById('loading').style.visibility = 'visible';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var forms = document.getElementsByTagName('form');
|
||||||
|
for (var i = 0; i < forms.length; i++) {
|
||||||
|
var form = forms[i];
|
||||||
|
|
||||||
|
if (form.dataset.noSubmit) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
RVR.setOnsubmitForForm(form);
|
||||||
|
|
||||||
|
if (form.dataset.observeInputs) {
|
||||||
|
RVR.observeInputsInForm(form, form.dataset.observeInputs.split(','));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('cover').onclick = function () {
|
||||||
|
RVR.hideModal();
|
||||||
|
};
|
||||||
|
|
||||||
|
RVR.initGoogleAnalitics();
|
||||||
|
})();
|
6
public/static/package.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"leaflet": "^1.6.0",
|
||||||
|
"leaflet.markercluster": "^1.4.1"
|
||||||
|
}
|
||||||
|
}
|
13
public/static/yarn.lock
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
leaflet.markercluster@^1.4.1:
|
||||||
|
version "1.4.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/leaflet.markercluster/-/leaflet.markercluster-1.4.1.tgz#b53f2c4f2ca7306ddab1dbb6f1861d5e8aa6c5e5"
|
||||||
|
integrity sha512-ZSEpE/EFApR0bJ1w/dUGwTSUvWlpalKqIzkaYdYB7jaftQA/Y2Jav+eT4CMtEYFj+ZK4mswP13Q2acnPBnhGOw==
|
||||||
|
|
||||||
|
leaflet@^1.6.0:
|
||||||
|
version "1.6.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.6.0.tgz#aecbb044b949ec29469eeb31c77a88e2f448f308"
|
||||||
|
integrity sha512-CPkhyqWUKZKFJ6K8umN5/D2wrJ2+/8UIpXppY7QDnUZW5bZL5+SEI2J7GBpwh4LIupOKqbNSQXgqmrEJopHVNQ==
|
13
rvr
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require 'app.php';
|
||||||
|
|
||||||
|
$app = new Symfony\Component\Console\Application('RVR Console', '');
|
||||||
|
|
||||||
|
$app->add(new RVR\Cli\MigrateDatabaseCommand());
|
||||||
|
$app->add(new RVR\Cli\AddUserCommand());
|
||||||
|
$app->add(new RVR\Cli\LinkViewCommand());
|
||||||
|
$app->add(new RVR\Cli\MaintainDatabaseCommand());
|
||||||
|
|
||||||
|
$app->run();
|
162
scripts/deploy-to-multiple-worktrees.py
Executable file
@ -0,0 +1,162 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
# Usage: ./deploy-to-multiple-worktrees.py REPO_PATH WORKTREE_DEVELOPMENT_PATH WORKTREE_PRODUCTION_PATH
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import re
|
||||||
|
|
||||||
|
WORKTREE_REGEX = r"^worktree (.*)\nHEAD ([a-f0-9]*)\n(?:branch refs\/heads\/(.*)|detached)$"
|
||||||
|
|
||||||
|
if len(sys.argv) < 4:
|
||||||
|
print("Usage: ./deploy-to-multiple-worktrees.py REPO_PATH WORKTREE_DEVELOPMENT_PATH WORKTREE_PRODUCTION_PATH")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
REPO = os.path.abspath(sys.argv[1])
|
||||||
|
WORKTREE_DEVELOPMENT = os.path.abspath(sys.argv[2])
|
||||||
|
WORKTREE_PRODUCTION = os.path.abspath(sys.argv[3])
|
||||||
|
|
||||||
|
class Worktree:
|
||||||
|
def __init__(self, path, branch, revision, version):
|
||||||
|
self.path = path
|
||||||
|
self.branch = branch
|
||||||
|
self.revision = revision
|
||||||
|
self.version = version
|
||||||
|
self.newRevision = None
|
||||||
|
self.newVersion = None
|
||||||
|
|
||||||
|
def getDataForWorktrees():
|
||||||
|
ret = subprocess.check_output(["git", "worktree", "list", "--porcelain"], cwd=REPO).decode().strip()
|
||||||
|
blocks = ret.split("\n\n")
|
||||||
|
|
||||||
|
worktrees = []
|
||||||
|
|
||||||
|
for block in blocks:
|
||||||
|
matches = re.search(WORKTREE_REGEX, block)
|
||||||
|
|
||||||
|
if matches:
|
||||||
|
path = matches.group(1)
|
||||||
|
revision = matches.group(2)
|
||||||
|
branch = matches.group(3)
|
||||||
|
version = getVersion(revision)
|
||||||
|
|
||||||
|
worktrees.append(Worktree(path, branch, revision, version))
|
||||||
|
|
||||||
|
return worktrees
|
||||||
|
|
||||||
|
def findWorktree(path):
|
||||||
|
for worktree in worktrees:
|
||||||
|
if worktree.path == path:
|
||||||
|
return worktree
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def getVersion(branch):
|
||||||
|
return subprocess.check_output(["git", "describe", "--tags", "--always", "--match", "Release_*", branch], cwd=REPO).decode().strip()
|
||||||
|
|
||||||
|
def getRevisionForRef(ref):
|
||||||
|
return subprocess.check_output(["git", "rev-list", "-1", ref], cwd=REPO).decode().strip()
|
||||||
|
|
||||||
|
def getLatestReleaseTag():
|
||||||
|
process = subprocess.Popen(["git", "for-each-ref", "refs/tags/Release*", "--sort=-creatordate", "--format=%(refname:short)"], stdout=subprocess.PIPE, cwd=REPO)
|
||||||
|
|
||||||
|
for line in process.stdout:
|
||||||
|
tag = line.decode().rstrip()
|
||||||
|
|
||||||
|
if isTagVerified(tag):
|
||||||
|
return tag
|
||||||
|
|
||||||
|
print(f"[WARNING] Tag '{tag}' is not verified, skipping.")
|
||||||
|
|
||||||
|
raise Exception("No verified 'Release*' tag found!")
|
||||||
|
|
||||||
|
def isTagVerified(tag):
|
||||||
|
process = subprocess.run(["git", "tag", "--verify", tag], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=REPO)
|
||||||
|
|
||||||
|
return process.returncode == 0
|
||||||
|
|
||||||
|
def updateRepoFromRemote():
|
||||||
|
subprocess.call(["git", "fetch", "origin", "--prune", "--prune-tags"], cwd=REPO)
|
||||||
|
|
||||||
|
def checkoutWorktree(worktreePath, ref):
|
||||||
|
subprocess.call(["git", "checkout", "-f", ref], cwd=worktreePath)
|
||||||
|
|
||||||
|
def cleanWorktree(worktreePath):
|
||||||
|
subprocess.call(["git", "clean", "-f", "-d"], cwd=worktreePath)
|
||||||
|
|
||||||
|
def updateAppInWorktree(worktreePath):
|
||||||
|
subprocess.call([worktreePath + "/scripts/update.sh"], cwd=worktreePath)
|
||||||
|
|
||||||
|
def updateAppVersionInWorktree(worktreePath):
|
||||||
|
subprocess.call([worktreePath + "/scripts/update-version.sh"], cwd=worktreePath)
|
||||||
|
|
||||||
|
worktrees = getDataForWorktrees()
|
||||||
|
|
||||||
|
updateRepoFromRemote()
|
||||||
|
|
||||||
|
print("Repo is updated from origin")
|
||||||
|
|
||||||
|
print("----------------------------------------------")
|
||||||
|
print("----------------------------------------------")
|
||||||
|
|
||||||
|
developmentWorktree = findWorktree(WORKTREE_DEVELOPMENT)
|
||||||
|
|
||||||
|
developmentWorktree.newRevision = getRevisionForRef(developmentWorktree.branch)
|
||||||
|
developmentWorktree.newVersion = getVersion(developmentWorktree.revision)
|
||||||
|
|
||||||
|
print("DEVELOPMENT (" + developmentWorktree.path + ") is on branch " + developmentWorktree.branch)
|
||||||
|
print(developmentWorktree.revision + " = " + developmentWorktree.branch + " (" + developmentWorktree.version + ")")
|
||||||
|
print(developmentWorktree.newRevision + " = origin/" + developmentWorktree.branch + " (" + developmentWorktree.newVersion + ")")
|
||||||
|
|
||||||
|
if developmentWorktree.revision != developmentWorktree.newRevision:
|
||||||
|
print("-> DEVELOPMENT (" + developmentWorktree.path + ") will be UPDATED")
|
||||||
|
print("----------------------------------------------")
|
||||||
|
|
||||||
|
checkoutWorktree(developmentWorktree.path, developmentWorktree.branch)
|
||||||
|
cleanWorktree(developmentWorktree.path)
|
||||||
|
|
||||||
|
print(developmentWorktree.path + " is checked out to " + developmentWorktree.branch + " and cleaned")
|
||||||
|
|
||||||
|
updateAppInWorktree(developmentWorktree.path)
|
||||||
|
updateAppVersionInWorktree(developmentWorktree.path)
|
||||||
|
|
||||||
|
print("RVR is updated in " + developmentWorktree.path)
|
||||||
|
elif developmentWorktree.version != developmentWorktree.newVersion:
|
||||||
|
print("-> DEVELOPMENT " + developmentWorktree.path + "'s version info will be UPDATED")
|
||||||
|
|
||||||
|
updateAppVersionInWorktree(developmentWorktree.path)
|
||||||
|
|
||||||
|
print("RVR version is updated in " + developmentWorktree.path)
|
||||||
|
else:
|
||||||
|
print("-> DEVELOPMENT (" + developmentWorktree.path + ") WON'T be updated")
|
||||||
|
|
||||||
|
print("----------------------------------------------")
|
||||||
|
print("----------------------------------------------")
|
||||||
|
|
||||||
|
productionWorktree = findWorktree(WORKTREE_PRODUCTION)
|
||||||
|
|
||||||
|
productionWorktree.newVersion = getLatestReleaseTag()
|
||||||
|
productionWorktree.newRevision = getRevisionForRef(productionWorktree.newVersion)
|
||||||
|
|
||||||
|
print("PRODUCTION (" + productionWorktree.path + ")")
|
||||||
|
print(productionWorktree.revision + " = " + productionWorktree.version)
|
||||||
|
print(productionWorktree.newRevision + " = " + productionWorktree.newVersion)
|
||||||
|
|
||||||
|
if productionWorktree.revision != productionWorktree.newRevision:
|
||||||
|
print("-> PRODUCTION (" + productionWorktree.path + ") will be UPDATED")
|
||||||
|
|
||||||
|
checkoutWorktree(productionWorktree.path, productionWorktree.newRevision)
|
||||||
|
cleanWorktree(productionWorktree.path)
|
||||||
|
|
||||||
|
print(productionWorktree.path + " is checked out to " + productionWorktree.newRevision + " and cleaned")
|
||||||
|
|
||||||
|
updateAppInWorktree(productionWorktree.path)
|
||||||
|
updateAppVersionInWorktree(productionWorktree.path)
|
||||||
|
|
||||||
|
print("RVR is updated in " + productionWorktree.path)
|
||||||
|
else:
|
||||||
|
print("-> PRODUCTION (" + productionWorktree.path + ") WON'T be updated")
|
||||||
|
|
||||||
|
print("----------------------------------------------")
|
||||||
|
print("----------------------------------------------")
|
15
scripts/gitHooks/prepare-commit-msg
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BRANCH_NAME=$(git symbolic-ref --short HEAD)
|
||||||
|
BRANCH_PATTERN="^(bugfix|feature|hotfix)\/([A-Z]+-[0-9]+).*"
|
||||||
|
|
||||||
|
if [[ "${BRANCH_NAME}" =~ $BRANCH_PATTERN ]]; then
|
||||||
|
TICKET_ID=$(echo $BRANCH_NAME | sed -E "s@$BRANCH_PATTERN@\\2@")
|
||||||
|
|
||||||
|
COMMIT_MESSAGE=$(head -n 1 $1)
|
||||||
|
COMMIT_MESSAGE_REGEX="^$TICKET_ID .*"
|
||||||
|
|
||||||
|
if [[ ! "${COMMIT_MESSAGE}" =~ $COMMIT_MESSAGE_REGEX ]]; then
|
||||||
|
sed -i.bak -e "1s/^/$TICKET_ID /" $1
|
||||||
|
fi
|
||||||
|
fi
|
35
scripts/install.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ROOT_DIR=$(dirname $(readlink -f "$0"))/..
|
||||||
|
|
||||||
|
. ${ROOT_DIR}/.env
|
||||||
|
|
||||||
|
if [ -f ${ROOT_DIR}/installed ]; then
|
||||||
|
echo "RVR is already installed! To force reinstall, delete file 'installed' from the root directory!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing NPM packages..."
|
||||||
|
(cd ${ROOT_DIR}/multi && npm install)
|
||||||
|
|
||||||
|
echo "Installing Yarn packages..."
|
||||||
|
(cd ${ROOT_DIR}/public/static && yarn install)
|
||||||
|
|
||||||
|
echo "Installing RVR DB..."
|
||||||
|
mysql --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD} ${DB_NAME} < ${ROOT_DIR}/database/rvr.sql
|
||||||
|
|
||||||
|
echo "Migrating DB..."
|
||||||
|
(cd ${ROOT_DIR} && ./rvr db:migrate)
|
||||||
|
|
||||||
|
if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then
|
||||||
|
echo "Minifying JS, CSS and SVG files..."
|
||||||
|
${ROOT_DIR}/scripts/minify.sh
|
||||||
|
|
||||||
|
echo "Linking view files..."
|
||||||
|
(cd ${ROOT_DIR} && ./rvr view:link)
|
||||||
|
else
|
||||||
|
echo "Creating the first user..."
|
||||||
|
(cd ${ROOT_DIR} && ./rvr user:add rvr@rvr.dev 123456 admin)
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch ${ROOT_DIR}/installed
|
11
scripts/minify.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ROOT_DIR=$(dirname $(readlink -f "$0"))/..
|
||||||
|
|
||||||
|
. ${ROOT_DIR}/.env
|
||||||
|
|
||||||
|
find ${ROOT_DIR}/public/static/js -type f -iname '*.js' -exec uglifyjs {} -c -m -o {} \;
|
||||||
|
|
||||||
|
find ${ROOT_DIR}/public/static/css -type f -iname '*.css' -exec cleancss {} -o {} \;
|
||||||
|
|
||||||
|
find ${ROOT_DIR}/public/static/img -type f -iname '*.svg' -exec svgo {} -o {} \;
|
20
scripts/run-sql.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$#" -lt 1 ]; then
|
||||||
|
echo "Usage: $0 <sql_file>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SQL_FILE=$1
|
||||||
|
|
||||||
|
ROOT_DIR=$(dirname $(readlink -f "$0"))/..
|
||||||
|
|
||||||
|
. ${ROOT_DIR}/.env
|
||||||
|
|
||||||
|
if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then
|
||||||
|
echo "This script can only be used in DEV mode!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running SQL on DB..."
|
||||||
|
mysql --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD} ${DB_NAME} < ${SQL_FILE}
|
17
scripts/update-version.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ROOT_DIR=$(dirname $(readlink -f "$0"))/..
|
||||||
|
|
||||||
|
. ${ROOT_DIR}/.env
|
||||||
|
|
||||||
|
cd ${ROOT_DIR}
|
||||||
|
|
||||||
|
echo "Updating version info..."
|
||||||
|
|
||||||
|
VERSION=$(git describe --tags --always --match "Release_*" HEAD)
|
||||||
|
REVISION=$(git rev-parse --short HEAD)
|
||||||
|
REVISION_DATE=$(git show -s --format=%aI HEAD)
|
||||||
|
|
||||||
|
sed -i -E "s/const VERSION = '(.*)';/const VERSION = '${VERSION}';/" main.php
|
||||||
|
sed -i -E "s/const REVISION = '(.*)';/const REVISION = '${REVISION}';/" main.php
|
||||||
|
sed -i -E "s/const REVISION_DATE = '(.*)';/const REVISION_DATE = '${REVISION_DATE}';/" main.php
|
29
scripts/update.sh
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ROOT_DIR=$(dirname $(readlink -f "$0"))/..
|
||||||
|
|
||||||
|
. ${ROOT_DIR}/.env
|
||||||
|
|
||||||
|
echo "Installing Composer packages..."
|
||||||
|
if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then
|
||||||
|
(cd ${ROOT_DIR} && composer install --no-dev)
|
||||||
|
else
|
||||||
|
(cd ${ROOT_DIR} && composer install --dev)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing NPM packages..."
|
||||||
|
(cd ${ROOT_DIR}/multi && npm install)
|
||||||
|
|
||||||
|
echo "Installing Yarn packages..."
|
||||||
|
(cd ${ROOT_DIR}/public/static && yarn install)
|
||||||
|
|
||||||
|
echo "Migrating DB..."
|
||||||
|
(cd ${ROOT_DIR} && ./rvr db:migrate)
|
||||||
|
|
||||||
|
if [ -z "${DEV}" ] || [ "${DEV}" -eq "0" ]; then
|
||||||
|
echo "Minifying JS, CSS and SVG files..."
|
||||||
|
${ROOT_DIR}/scripts/minify.sh
|
||||||
|
|
||||||
|
echo "Linking view files..."
|
||||||
|
(cd ${ROOT_DIR} && ./rvr view:link)
|
||||||
|
fi
|
50
src/Cli/AddUserCommand.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php namespace RVR\Cli;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use SokoWeb\PersistentData\PersistentDataManager;
|
||||||
|
use RVR\PersistentData\Model\User;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class AddUserCommand extends Command
|
||||||
|
{
|
||||||
|
public function configure(): void
|
||||||
|
{
|
||||||
|
$this->setName('user:add')
|
||||||
|
->setDescription('Adding of user.')
|
||||||
|
->addArgument('email', InputArgument::REQUIRED, 'Email of user')
|
||||||
|
->addArgument('password', InputArgument::REQUIRED, 'Password of user')
|
||||||
|
->addArgument('type', InputArgument::OPTIONAL, 'Type of user');;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$user = new User();
|
||||||
|
$user->setEmail($input->getArgument('email'));
|
||||||
|
$user->setPlainPassword($input->getArgument('password'));
|
||||||
|
$user->setCreatedDate(new DateTime());
|
||||||
|
|
||||||
|
if ($input->hasArgument('type') && $input->getArgument('type') !== null) {
|
||||||
|
$user->setType($input->getArgument('type'));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdm = new PersistentDataManager();
|
||||||
|
$pdm->saveToDb($user);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$output->writeln('<error>Adding user failed!</error>');
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
$output->writeln((string) $e);
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln('<info>User was successfully added!</info>');
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
69
src/Cli/LinkViewCommand.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php namespace RVR\Cli;
|
||||||
|
|
||||||
|
use FilesystemIterator;
|
||||||
|
use SokoWeb\View\Linker;
|
||||||
|
use RecursiveDirectoryIterator;
|
||||||
|
use RecursiveIteratorIterator;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class LinkViewCommand extends Command
|
||||||
|
{
|
||||||
|
public function configure(): void
|
||||||
|
{
|
||||||
|
$this->setName('view:link')
|
||||||
|
->setDescription('Linking of views.')
|
||||||
|
->addArgument('view', InputArgument::OPTIONAL, 'View file to be linked.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$views = [];
|
||||||
|
|
||||||
|
$view = $input->getArgument('view');
|
||||||
|
|
||||||
|
if ($view !== null) {
|
||||||
|
$views[] = $view;
|
||||||
|
} else {
|
||||||
|
$folder = ROOT . '/views';
|
||||||
|
$folderLength = strlen($folder) + 1;
|
||||||
|
|
||||||
|
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folder, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
|
||||||
|
|
||||||
|
foreach ($iterator as $file) {
|
||||||
|
if ($file->isDir() || $file->getExtension() !== 'php') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$view = substr($file->getPath(), $folderLength) . '/' . $file->getBasename('.php');
|
||||||
|
|
||||||
|
if (strpos($view, 'templates') === 0 || strpos($view, 'tests') === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$views[] = $view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
foreach ($views as $view) {
|
||||||
|
$generator = new Linker($view);
|
||||||
|
$generator->generate();
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$output->writeln('<error>Linking view(s) failed!</error>');
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
$output->writeln((string) $e);
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln('<info>View(s) successfully linked!</info>');
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
76
src/Cli/MaintainDatabaseCommand.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php namespace RVR\Cli;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use SokoWeb\Database\Query\Modify;
|
||||||
|
use SokoWeb\Database\Query\Select;
|
||||||
|
use SokoWeb\Interfaces\Database\IResultSet;
|
||||||
|
use SokoWeb\PersistentData\PersistentDataManager;
|
||||||
|
use RVR\Repository\UserPasswordResetterRepository;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class MaintainDatabaseCommand extends Command
|
||||||
|
{
|
||||||
|
private PersistentDataManager $pdm;
|
||||||
|
|
||||||
|
private UserPasswordResetterRepository $userPasswordResetterRepository;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->pdm = new PersistentDataManager();
|
||||||
|
$this->userPasswordResetterRepository = new UserPasswordResetterRepository();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configure(): void
|
||||||
|
{
|
||||||
|
$this->setName('db:maintain')
|
||||||
|
->setDescription('Maintain database.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->deleteExpiredPasswordResetters();
|
||||||
|
$this->deleteExpiredSessions();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$output->writeln('<error>Maintenance failed!</error>');
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
$output->writeln((string) $e);
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln('<info>Maintenance was successful!</info>');
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function deleteExpiredPasswordResetters(): void
|
||||||
|
{
|
||||||
|
foreach ($this->userPasswordResetterRepository->getAllExpired() as $passwordResetter) {
|
||||||
|
$this->pdm->deleteFromDb($passwordResetter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function deleteExpiredSessions(): void
|
||||||
|
{
|
||||||
|
//TODO: model may be used for sessions too
|
||||||
|
$select = new Select(\Container::$dbConnection, 'sessions');
|
||||||
|
$select->columns(['id']);
|
||||||
|
$select->where('updated', '<', (new DateTime('-7 days'))->format('Y-m-d H:i:s'));
|
||||||
|
|
||||||
|
$result = $select->execute();
|
||||||
|
|
||||||
|
while ($session = $result->fetch(IResultSet::FETCH_ASSOC)) {
|
||||||
|
$modify = new Modify(\Container::$dbConnection, 'sessions');
|
||||||
|
$modify->setId($session['id']);
|
||||||
|
$modify->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
122
src/Cli/MigrateDatabaseCommand.php
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
<?php namespace RVR\Cli;
|
||||||
|
|
||||||
|
use SokoWeb\Database\Query\Modify;
|
||||||
|
use SokoWeb\Database\Query\Select;
|
||||||
|
use SokoWeb\Interfaces\Database\IResultSet;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class MigrateDatabaseCommand extends Command
|
||||||
|
{
|
||||||
|
public function configure(): void
|
||||||
|
{
|
||||||
|
$this->setName('db:migrate')
|
||||||
|
->setDescription('Migration of database changes.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$db = \Container::$dbConnection;
|
||||||
|
|
||||||
|
$db->startTransaction();
|
||||||
|
|
||||||
|
$success = [];
|
||||||
|
try {
|
||||||
|
foreach ($this->readDir('structure') as $file) {
|
||||||
|
$db->multiQuery(file_get_contents($file));
|
||||||
|
|
||||||
|
$success[] = $this->saveToDB($file, 'structure');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->readDir('data') as $file) {
|
||||||
|
require $file;
|
||||||
|
|
||||||
|
$success[] = $this->saveToDB($file, 'data');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$db->rollback();
|
||||||
|
|
||||||
|
$output->writeln('<error>Migration failed!</error>');
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
$output->writeln((string) $e);
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->commit();
|
||||||
|
|
||||||
|
$output->writeln('<info>Migration was successful!</info>');
|
||||||
|
$output->writeln('');
|
||||||
|
|
||||||
|
if (count($success) > 0) {
|
||||||
|
foreach ($success as $migration) {
|
||||||
|
$output->writeln($migration);
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln('');
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function readDir(string $type): array
|
||||||
|
{
|
||||||
|
$done = [];
|
||||||
|
|
||||||
|
$migrationTableExists = \Container::$dbConnection->query('SELECT count(*)
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema = \'' . $_ENV['DB_NAME'] . '\'
|
||||||
|
AND table_name = \'migrations\';')
|
||||||
|
->fetch(IResultSet::FETCH_NUM)[0];
|
||||||
|
|
||||||
|
if ($migrationTableExists != 0) {
|
||||||
|
$select = new Select(\Container::$dbConnection, 'migrations');
|
||||||
|
$select->columns(['migration']);
|
||||||
|
$select->where('type', '=', $type);
|
||||||
|
$select->orderBy('migration');
|
||||||
|
|
||||||
|
$result = $select->execute();
|
||||||
|
|
||||||
|
while ($migration = $result->fetch(IResultSet::FETCH_ASSOC)) {
|
||||||
|
$done[] = $migration['migration'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = ROOT . '/database/migrations/' . $type;
|
||||||
|
$dir = opendir($path);
|
||||||
|
|
||||||
|
if ($dir === false) {
|
||||||
|
throw new \Exception('Cannot open dir: ' . $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = [];
|
||||||
|
while ($file = readdir($dir)) {
|
||||||
|
$filePath = $path . '/' . $file;
|
||||||
|
|
||||||
|
if (!is_file($filePath) || in_array(pathinfo($file, PATHINFO_FILENAME), $done)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$files[] = $filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
natsort($files);
|
||||||
|
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function saveToDB(string $file, string $type): string
|
||||||
|
{
|
||||||
|
$baseName = pathinfo($file, PATHINFO_FILENAME);
|
||||||
|
|
||||||
|
$modify = new Modify(\Container::$dbConnection, 'migrations');
|
||||||
|
$modify->set('migration', $baseName);
|
||||||
|
$modify->set('type', $type);
|
||||||
|
$modify->save();
|
||||||
|
|
||||||
|
return $baseName . ' (' . $type . ')';
|
||||||
|
}
|
||||||
|
}
|
27
src/Controller/HomeController.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php namespace RVR\Controller;
|
||||||
|
|
||||||
|
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||||
|
use SokoWeb\Interfaces\Request\IRequest;
|
||||||
|
use SokoWeb\Interfaces\Response\IContent;
|
||||||
|
use SokoWeb\Response\HtmlContent;
|
||||||
|
use SokoWeb\Response\JsonContent;
|
||||||
|
|
||||||
|
class HomeController implements ISecured
|
||||||
|
{
|
||||||
|
private IRequest $request;
|
||||||
|
|
||||||
|
public function __construct(IRequest $request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return $this->request->user() !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIndex(): IContent
|
||||||
|
{
|
||||||
|
return new HtmlContent('index');
|
||||||
|
}
|
||||||
|
}
|
302
src/Controller/LoginController.php
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
<?php namespace RVR\Controller;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use SokoWeb\Http\Request;
|
||||||
|
use SokoWeb\Interfaces\Request\IRequest;
|
||||||
|
use SokoWeb\Interfaces\Response\IContent;
|
||||||
|
use SokoWeb\Interfaces\Response\IRedirect;
|
||||||
|
use SokoWeb\Mailing\Mail;
|
||||||
|
use SokoWeb\OAuth\GoogleOAuth;
|
||||||
|
use RVR\PersistentData\Model\UserPasswordResetter;
|
||||||
|
use SokoWeb\PersistentData\PersistentDataManager;
|
||||||
|
use RVR\Repository\UserPasswordResetterRepository;
|
||||||
|
use RVR\Repository\UserRepository;
|
||||||
|
use SokoWeb\Response\HtmlContent;
|
||||||
|
use SokoWeb\Response\JsonContent;
|
||||||
|
use SokoWeb\Response\Redirect;
|
||||||
|
use SokoWeb\Util\CaptchaValidator;
|
||||||
|
use SokoWeb\Util\JwtParser;
|
||||||
|
|
||||||
|
class LoginController
|
||||||
|
{
|
||||||
|
private IRequest $request;
|
||||||
|
|
||||||
|
private PersistentDataManager $pdm;
|
||||||
|
|
||||||
|
private UserRepository $userRepository;
|
||||||
|
|
||||||
|
private UserPasswordResetterRepository $userPasswordResetterRepository;
|
||||||
|
|
||||||
|
public function __construct(IRequest $request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
$this->pdm = new PersistentDataManager();
|
||||||
|
$this->userRepository = new UserRepository();
|
||||||
|
$this->userPasswordResetterRepository = new UserPasswordResetterRepository();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLoginForm()
|
||||||
|
{
|
||||||
|
if ($this->request->user() !== null) {
|
||||||
|
return new Redirect(\Container::$routeCollection->getRoute('index')->generateLink(), IRedirect::TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HtmlContent('login/login');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGoogleLoginRedirect(): IRedirect
|
||||||
|
{
|
||||||
|
$state = bin2hex(random_bytes(16));
|
||||||
|
$nonce = bin2hex(random_bytes(16));
|
||||||
|
|
||||||
|
$this->request->session()->set('oauth_state', $state);
|
||||||
|
$this->request->session()->set('oauth_nonce', $nonce);
|
||||||
|
|
||||||
|
$oAuth = new GoogleOAuth(new Request());
|
||||||
|
$url = $oAuth->getDialogUrl(
|
||||||
|
$state,
|
||||||
|
$this->request->getBase() . '/' . \Container::$routeCollection->getRoute('login-google-action')->generateLink(),
|
||||||
|
$nonce
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Redirect($url, IRedirect::TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRequestPasswordResetForm()
|
||||||
|
{
|
||||||
|
if ($this->request->user() !== null) {
|
||||||
|
return new Redirect(\Container::$routeCollection->getRoute('index')->generateLink(), IRedirect::TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HtmlContent('login/password_reset_request', ['email' => $this->request->query('email')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRequestPasswordResetSuccess(): IContent
|
||||||
|
{
|
||||||
|
return new HtmlContent('login/password_reset_request_success');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResetPasswordForm()
|
||||||
|
{
|
||||||
|
if ($this->request->user() !== null) {
|
||||||
|
return new Redirect(\Container::$routeCollection->getRoute('index')->generateLink(), IRedirect::TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = $this->request->query('token');
|
||||||
|
$resetter = $this->userPasswordResetterRepository->getByToken($token);
|
||||||
|
|
||||||
|
if ($resetter === null || $resetter->getExpiresDate() < new DateTime()) {
|
||||||
|
return new HtmlContent('login/reset_password', ['success' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->userRepository->getById($resetter->getUserId());
|
||||||
|
|
||||||
|
return new HtmlContent('login/reset_password', ['success' => true, 'token' => $token, 'email' => $user->getEmail()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(): IContent
|
||||||
|
{
|
||||||
|
if ($this->request->user() !== null) {
|
||||||
|
return new JsonContent(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->userRepository->getByEmail($this->request->post('email'));
|
||||||
|
if ($user === null || !$user->checkPassword($this->request->post('password'))) {
|
||||||
|
return new JsonContent([
|
||||||
|
'error' => [
|
||||||
|
'errorText' => 'No user found with the given email address or the given password is wrong. You can <a href="/password/requestReset?email=' .
|
||||||
|
urlencode($this->request->post('email')) . '" title="Request password reset">request password reset</a>!'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->request->setUser($user);
|
||||||
|
|
||||||
|
return new JsonContent(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loginWithGoogle()
|
||||||
|
{
|
||||||
|
$redirectUrl = $this->request->session()->get('redirect_after_login');
|
||||||
|
if ($redirectUrl === null) {
|
||||||
|
$redirectUrl = \Container::$routeCollection->getRoute('index')->generateLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->request->user() !== null) {
|
||||||
|
$this->request->session()->delete('redirect_after_login');
|
||||||
|
return new Redirect($redirectUrl, IRedirect::TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->request->query('state') !== $this->request->session()->get('oauth_state')) {
|
||||||
|
return new HtmlContent('login/google_login');
|
||||||
|
}
|
||||||
|
|
||||||
|
$oAuth = new GoogleOAuth(new Request());
|
||||||
|
$tokenData = $oAuth->getToken(
|
||||||
|
$this->request->query('code'),
|
||||||
|
$this->request->getBase() . '/' . \Container::$routeCollection->getRoute('login-google-action')->generateLink()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isset($tokenData['id_token'])) {
|
||||||
|
return new HtmlContent('login/google_login');
|
||||||
|
}
|
||||||
|
|
||||||
|
$jwtParser = new JwtParser($tokenData['id_token']);
|
||||||
|
$idToken = $jwtParser->getPayload();
|
||||||
|
|
||||||
|
if ($idToken['nonce'] !== $this->request->session()->get('oauth_nonce')) {
|
||||||
|
return new HtmlContent('login/google_login');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$idToken['email_verified']) {
|
||||||
|
return new HtmlContent('login/google_login');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->userRepository->getByGoogleSub($idToken['sub']);
|
||||||
|
if ($user === null) {
|
||||||
|
return new JsonContent([
|
||||||
|
'error' => [
|
||||||
|
'errorText' => 'No user found for this Google account.'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->request->setUser($user);
|
||||||
|
|
||||||
|
$this->request->session()->delete('redirect_after_login');
|
||||||
|
return new Redirect($redirectUrl, IRedirect::TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout(): IRedirect
|
||||||
|
{
|
||||||
|
$this->request->setUser(null);
|
||||||
|
|
||||||
|
return new Redirect(\Container::$routeCollection->getRoute('index')->generateLink(), IRedirect::TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function requestPasswordReset(): IContent
|
||||||
|
{
|
||||||
|
if ($this->request->user() !== null) {
|
||||||
|
return new JsonContent([
|
||||||
|
'redirect' => [
|
||||||
|
'target' => '/' . \Container::$routeCollection->getRoute('home')->generateLink()
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_ENV['RECAPTCHA_SITEKEY'])) {
|
||||||
|
if (!$this->request->post('g-recaptcha-response')) {
|
||||||
|
return new JsonContent(['error' => ['errorText' => 'Please check "I\'m not a robot" in the reCAPTCHA box!']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$captchaValidator = new CaptchaValidator();
|
||||||
|
$captchaResponse = $captchaValidator->validate($this->request->post('g-recaptcha-response'));
|
||||||
|
if (!$captchaResponse['success']) {
|
||||||
|
return new JsonContent(['error' => ['errorText' => 'reCAPTCHA challenge failed. Please try again!']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->userRepository->getByEmail($this->request->post('email'));
|
||||||
|
if ($user === null) {
|
||||||
|
return new JsonContent([
|
||||||
|
'error' => [
|
||||||
|
'errorText' => 'No user found with the given email address.'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$existingResetter = $this->userPasswordResetterRepository->getByUser($user);
|
||||||
|
if ($existingResetter !== null && $existingResetter->getExpiresDate() > new DateTime()) {
|
||||||
|
return new JsonContent([
|
||||||
|
'error' => [
|
||||||
|
'errorText' => 'Password reset was recently requested for this account. Please check your email, or try again later!'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = bin2hex(random_bytes(16));
|
||||||
|
$expires = new DateTime('+1 hour');
|
||||||
|
|
||||||
|
$passwordResetter = new UserPasswordResetter();
|
||||||
|
$passwordResetter->setUser($user);
|
||||||
|
$passwordResetter->setToken($token);
|
||||||
|
$passwordResetter->setExpiresDate($expires);
|
||||||
|
|
||||||
|
\Container::$dbConnection->startTransaction();
|
||||||
|
|
||||||
|
if ($existingResetter !== null) {
|
||||||
|
$this->pdm->deleteFromDb($existingResetter);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->pdm->saveToDb($passwordResetter);
|
||||||
|
|
||||||
|
\Container::$dbConnection->commit();
|
||||||
|
|
||||||
|
$this->sendPasswordResetEmail($user->getEmail(), $token, $expires);
|
||||||
|
|
||||||
|
return new JsonContent(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetPassword(): IContent
|
||||||
|
{
|
||||||
|
if ($this->request->user() !== null) {
|
||||||
|
return new JsonContent([
|
||||||
|
'redirect' => [
|
||||||
|
'target' => '/' . \Container::$routeCollection->getRoute('home')->generateLink()
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = $this->request->query('token');
|
||||||
|
$resetter = $this->userPasswordResetterRepository->getByToken($token);
|
||||||
|
|
||||||
|
if ($resetter === null || $resetter->getExpiresDate() < new DateTime()) {
|
||||||
|
return new JsonContent([
|
||||||
|
'redirect' => [
|
||||||
|
'target' => '/' . \Container::$routeCollection->getRoute('password-reset')->generateLink(['token' => $token])
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($this->request->post('password')) < 6) {
|
||||||
|
return new JsonContent([
|
||||||
|
'error' => [
|
||||||
|
'errorText' => 'The given password is too short. Please choose a password that is at least 6 characters long!'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->request->post('password') !== $this->request->post('password_confirm')) {
|
||||||
|
return new JsonContent(['error' => ['errorText' => 'The given passwords do not match.']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
\Container::$dbConnection->startTransaction();
|
||||||
|
|
||||||
|
$this->pdm->deleteFromDb($resetter);
|
||||||
|
|
||||||
|
$user = $this->userRepository->getById($resetter->getUserId());
|
||||||
|
$user->setPlainPassword($this->request->post('password'));
|
||||||
|
|
||||||
|
$this->pdm->saveToDb($user);
|
||||||
|
|
||||||
|
\Container::$dbConnection->commit();
|
||||||
|
|
||||||
|
$this->request->setUser($user);
|
||||||
|
|
||||||
|
return new JsonContent(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendPasswordResetEmail(string $email, string $token, DateTime $expires): void
|
||||||
|
{
|
||||||
|
$mail = new Mail();
|
||||||
|
$mail->addRecipient($email);
|
||||||
|
$mail->setSubject($_ENV['APP_NAME'] . ' - Password reset');
|
||||||
|
$mail->setBodyFromTemplate('password-reset', [
|
||||||
|
'EMAIL' => $email,
|
||||||
|
'RESET_LINK' => $this->request->getBase() . '/' .
|
||||||
|
\Container::$routeCollection->getRoute('password-reset')->generateLink(['token' => $token]),
|
||||||
|
'EXPIRES' => $expires->format('Y-m-d H:i T')
|
||||||
|
]);
|
||||||
|
$mail->send();
|
||||||
|
}
|
||||||
|
}
|
174
src/Controller/UserController.php
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
<?php namespace RVR\Controller;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use SokoWeb\Http\Request;
|
||||||
|
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||||
|
use SokoWeb\Interfaces\Request\IRequest;
|
||||||
|
use SokoWeb\Interfaces\Response\IContent;
|
||||||
|
use SokoWeb\Interfaces\Response\IRedirect;
|
||||||
|
use SokoWeb\OAuth\GoogleOAuth;
|
||||||
|
use SokoWeb\PersistentData\PersistentDataManager;
|
||||||
|
use RVR\PersistentData\Model\User;
|
||||||
|
use SokoWeb\Response\HtmlContent;
|
||||||
|
use SokoWeb\Response\JsonContent;
|
||||||
|
use SokoWeb\Response\Redirect;
|
||||||
|
use SokoWeb\Util\JwtParser;
|
||||||
|
|
||||||
|
class UserController implements ISecured
|
||||||
|
{
|
||||||
|
private IRequest $request;
|
||||||
|
|
||||||
|
private PersistentDataManager $pdm;
|
||||||
|
|
||||||
|
public function __construct(IRequest $request)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
$this->pdm = new PersistentDataManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return $this->request->user() !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAccount(): IContent
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var User $user
|
||||||
|
*/
|
||||||
|
$user = $this->request->user();
|
||||||
|
|
||||||
|
return new HtmlContent('account/account', ['user' => $user->toArray()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGoogleAuthenticateRedirect(): IRedirect
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var User $user
|
||||||
|
*/
|
||||||
|
$user = $this->request->user();
|
||||||
|
|
||||||
|
$state = bin2hex(random_bytes(16));
|
||||||
|
$nonce = bin2hex(random_bytes(16));
|
||||||
|
|
||||||
|
$this->request->session()->set('oauth_state', $state);
|
||||||
|
$this->request->session()->set('oauth_nonce', $nonce);
|
||||||
|
|
||||||
|
$oAuth = new GoogleOAuth(new Request());
|
||||||
|
|
||||||
|
$url = $oAuth->getDialogUrl(
|
||||||
|
$state,
|
||||||
|
$this->request->getBase() . '/' . \Container::$routeCollection->getRoute('account.googleAuthenticate-action')->generateLink(),
|
||||||
|
$nonce,
|
||||||
|
$user->getEmail()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Redirect($url, IRedirect::TEMPORARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authenticateWithGoogle(): IContent
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var User $user
|
||||||
|
*/
|
||||||
|
$user = $this->request->user();
|
||||||
|
|
||||||
|
if ($this->request->query('state') !== $this->request->session()->get('oauth_state')) {
|
||||||
|
return new HtmlContent('account/google_authenticate', ['success' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$oAuth = new GoogleOAuth(new Request());
|
||||||
|
$tokenData = $oAuth->getToken(
|
||||||
|
$this->request->query('code'),
|
||||||
|
$this->request->getBase() . '/' . \Container::$routeCollection->getRoute('account.googleAuthenticate-action')->generateLink()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isset($tokenData['id_token'])) {
|
||||||
|
return new HtmlContent('account/google_authenticate', ['success' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$jwtParser = new JwtParser($tokenData['id_token']);
|
||||||
|
$idToken = $jwtParser->getPayload();
|
||||||
|
|
||||||
|
if ($idToken['nonce'] !== $this->request->session()->get('oauth_nonce')) {
|
||||||
|
return new HtmlContent('account/google_authenticate', ['success' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($idToken['sub'] !== $user->getGoogleSub()) {
|
||||||
|
return new HtmlContent('account/google_authenticate', [
|
||||||
|
'success' => false,
|
||||||
|
'errorText' => 'This Google account is not linked to your account.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$authenticatedWithGoogleUntil = new DateTime('+45 seconds');
|
||||||
|
$this->request->session()->set('authenticated_with_google_until', $authenticatedWithGoogleUntil);
|
||||||
|
|
||||||
|
return new HtmlContent('account/google_authenticate', [
|
||||||
|
'success' => true,
|
||||||
|
'authenticatedWithGoogleUntil' => $authenticatedWithGoogleUntil
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveAccount(): IContent
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var User $user
|
||||||
|
*/
|
||||||
|
$user = $this->request->user();
|
||||||
|
|
||||||
|
if (!$this->confirmUserIdentity(
|
||||||
|
$user,
|
||||||
|
$this->request->session()->get('authenticated_with_google_until'),
|
||||||
|
$this->request->post('password'),
|
||||||
|
$error
|
||||||
|
)) {
|
||||||
|
return new JsonContent(['error' => ['errorText' => $error]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($this->request->post('password_new')) > 0) {
|
||||||
|
if (strlen($this->request->post('password_new')) < 6) {
|
||||||
|
return new JsonContent([
|
||||||
|
'error' => [
|
||||||
|
'errorText' => 'The given new password is too short. Please choose a password that is at least 6 characters long!'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->request->post('password_new') !== $this->request->post('password_new_confirm')) {
|
||||||
|
return new JsonContent([
|
||||||
|
'error' => [
|
||||||
|
'errorText' => 'The given new passwords do not match.'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->setPlainPassword($this->request->post('password_new'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->pdm->saveToDb($user);
|
||||||
|
|
||||||
|
$this->request->session()->delete('authenticated_with_google_until');
|
||||||
|
|
||||||
|
return new JsonContent(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function confirmUserIdentity(User $user, ?DateTime $authenticatedWithGoogleUntil, ?string $password, ?string &$error): bool
|
||||||
|
{
|
||||||
|
if ($authenticatedWithGoogleUntil !== null && $authenticatedWithGoogleUntil > new DateTime()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($password !== null) {
|
||||||
|
if ($user->checkPassword($password)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = 'The given current password is wrong.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = 'Could not confirm your identity. Please try again!';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
122
src/PersistentData/Model/User.php
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
<?php namespace RVR\PersistentData\Model;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use SokoWeb\PersistentData\Model\Model;
|
||||||
|
use SokoWeb\Interfaces\Authentication\IUser;
|
||||||
|
|
||||||
|
class User extends Model implements IUser
|
||||||
|
{
|
||||||
|
protected static string $table = 'users';
|
||||||
|
|
||||||
|
protected static array $fields = ['email', 'password', 'type', 'google_sub', 'created'];
|
||||||
|
|
||||||
|
private static array $types = ['user', 'admin'];
|
||||||
|
|
||||||
|
private string $email = '';
|
||||||
|
|
||||||
|
private ?string $password = null;
|
||||||
|
|
||||||
|
private string $type = 'user';
|
||||||
|
|
||||||
|
private ?string $googleSub = null;
|
||||||
|
|
||||||
|
private DateTime $created;
|
||||||
|
|
||||||
|
public function setEmail(string $email): void
|
||||||
|
{
|
||||||
|
$this->email = $email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPassword(?string $hashedPassword): void
|
||||||
|
{
|
||||||
|
$this->password = $hashedPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlainPassword(string $plainPassword): void
|
||||||
|
{
|
||||||
|
$this->password = password_hash($plainPassword, PASSWORD_BCRYPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setType(string $type): void
|
||||||
|
{
|
||||||
|
if (in_array($type, self::$types)) {
|
||||||
|
$this->type = $type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGoogleSub(?string $googleSub): void
|
||||||
|
{
|
||||||
|
$this->googleSub = $googleSub;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCreatedDate(DateTime $created): void
|
||||||
|
{
|
||||||
|
$this->created = $created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCreated(string $created): void
|
||||||
|
{
|
||||||
|
$this->created = new DateTime($created);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail(): string
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPassword(): ?string
|
||||||
|
{
|
||||||
|
return $this->password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType(): string
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGoogleSub(): ?string
|
||||||
|
{
|
||||||
|
return $this->googleSub;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreatedDate(): DateTime
|
||||||
|
{
|
||||||
|
return $this->created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreated(): string
|
||||||
|
{
|
||||||
|
return $this->created->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasPermission(int $permission): bool
|
||||||
|
{
|
||||||
|
switch ($permission) {
|
||||||
|
case IUser::PERMISSION_NORMAL:
|
||||||
|
return true;
|
||||||
|
case IUser::PERMISSION_ADMIN:
|
||||||
|
return $this->type === 'admin';
|
||||||
|
default:
|
||||||
|
throw new \Exception('Permission does not exist: ' . $permission);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUniqueId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDisplayName(): string
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkPassword(string $password): bool
|
||||||
|
{
|
||||||
|
if ($this->password === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return password_verify($password, $this->password);
|
||||||
|
}
|
||||||
|
}
|
71
src/PersistentData/Model/UserPasswordResetter.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?php namespace RVR\PersistentData\Model;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use SokoWeb\PersistentData\Model\Model;
|
||||||
|
|
||||||
|
class UserPasswordResetter extends Model
|
||||||
|
{
|
||||||
|
protected static string $table = 'user_password_resetters';
|
||||||
|
|
||||||
|
protected static array $fields = ['user_id', 'token', 'expires'];
|
||||||
|
|
||||||
|
protected static array $relations = ['user' => User::class];
|
||||||
|
|
||||||
|
private ?User $user = null;
|
||||||
|
|
||||||
|
private ?int $userId = null;
|
||||||
|
|
||||||
|
private string $token = '';
|
||||||
|
|
||||||
|
private DateTime $expires;
|
||||||
|
|
||||||
|
public function setUser(User $user): void
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUserId(int $userId): void
|
||||||
|
{
|
||||||
|
$this->userId = $userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setToken(string $token): void
|
||||||
|
{
|
||||||
|
$this->token = $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setExpiresDate(DateTime $expires): void
|
||||||
|
{
|
||||||
|
$this->expires = $expires;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setExpires(string $expires): void
|
||||||
|
{
|
||||||
|
$this->expires = new DateTime($expires);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUser(): ?User
|
||||||
|
{
|
||||||
|
return $this->user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserId(): ?int
|
||||||
|
{
|
||||||
|
return $this->userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToken(): string
|
||||||
|
{
|
||||||
|
return $this->token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExpiresDate(): DateTime
|
||||||
|
{
|
||||||
|
return $this->expires;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExpires(): string
|
||||||
|
{
|
||||||
|
return $this->expires->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
}
|
47
src/Repository/UserPasswordResetterRepository.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php namespace RVR\Repository;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use Generator;
|
||||||
|
use SokoWeb\Database\Query\Select;
|
||||||
|
use RVR\PersistentData\Model\User;
|
||||||
|
use RVR\PersistentData\Model\UserPasswordResetter;
|
||||||
|
use SokoWeb\PersistentData\PersistentDataManager;
|
||||||
|
|
||||||
|
class UserPasswordResetterRepository
|
||||||
|
{
|
||||||
|
private PersistentDataManager $pdm;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->pdm = new PersistentDataManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getById(int $userConfirmationId): ?UserPasswordResetter
|
||||||
|
{
|
||||||
|
return $this->pdm->selectFromDbById($userConfirmationId, UserPasswordResetter::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByToken(string $token): ?UserPasswordResetter
|
||||||
|
{
|
||||||
|
$select = new Select(\Container::$dbConnection);
|
||||||
|
$select->where('token', '=', $token);
|
||||||
|
|
||||||
|
return $this->pdm->selectFromDb($select, UserPasswordResetter::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByUser(User $user): ?UserPasswordResetter
|
||||||
|
{
|
||||||
|
$select = new Select(\Container::$dbConnection);
|
||||||
|
$select->where('user_id', '=', $user->getId());
|
||||||
|
|
||||||
|
return $this->pdm->selectFromDb($select, UserPasswordResetter::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllExpired(): Generator
|
||||||
|
{
|
||||||
|
$select = new Select(\Container::$dbConnection);
|
||||||
|
$select->where('expires', '<', (new DateTime())->format('Y-m-d H:i:s'));
|
||||||
|
|
||||||
|
yield from $this->pdm->selectMultipleFromDb($select, UserPasswordResetter::class);
|
||||||
|
}
|
||||||
|
}
|
37
src/Repository/UserRepository.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php namespace RVR\Repository;
|
||||||
|
|
||||||
|
use SokoWeb\Interfaces\Repository\IUserRepository;
|
||||||
|
use SokoWeb\Database\Query\Select;
|
||||||
|
use RVR\PersistentData\Model\User;
|
||||||
|
use SokoWeb\PersistentData\PersistentDataManager;
|
||||||
|
|
||||||
|
class UserRepository implements IUserRepository
|
||||||
|
{
|
||||||
|
private PersistentDataManager $pdm;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->pdm = new PersistentDataManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getById(int $userId): ?User
|
||||||
|
{
|
||||||
|
return $this->pdm->selectFromDbById($userId, User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByEmail(string $email): ?User
|
||||||
|
{
|
||||||
|
$select = new Select(\Container::$dbConnection);
|
||||||
|
$select->where('email', '=', $email);
|
||||||
|
|
||||||
|
return $this->pdm->selectFromDb($select, User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByGoogleSub(string $sub): ?User
|
||||||
|
{
|
||||||
|
$select = new Select(\Container::$dbConnection);
|
||||||
|
$select->where('google_sub', '=', $sub);
|
||||||
|
|
||||||
|
return $this->pdm->selectFromDb($select, User::class);
|
||||||
|
}
|
||||||
|
}
|
36
views/account/account.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
@js(js/account/account.js)
|
||||||
|
|
||||||
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
|
@section(main)
|
||||||
|
<h2>Account</h2>
|
||||||
|
<div class="box">
|
||||||
|
<form id="accountForm" action="/account" method="post" data-observe-inputs="password_new,password_new_confirm">
|
||||||
|
<?php if ($user['password'] !== null && $user['google_sub'] !== null): ?>
|
||||||
|
<p class="justify small">Please confirm your identity with your password or with Google to modify your account.</p>
|
||||||
|
<div class="inputWithButton">
|
||||||
|
<input type="password" class="text name="password" placeholder="Current password" required minlength="6" autofocus><!--
|
||||||
|
--><button id="authenticateWithGoogleButton" class="yellow" type="button">Google</button>
|
||||||
|
</div>
|
||||||
|
<?php elseif ($user['password'] !== null): ?>
|
||||||
|
<p class="justify small">Please confirm your identity with your password to modify your account.</p>
|
||||||
|
<input type="password" class="text big fullWidth" name="password" placeholder="Current password" required minlength="6" autofocus>
|
||||||
|
<?php elseif ($user['google_sub'] !== null): ?>
|
||||||
|
<p class="justify small">Please confirm your identity with Google to modify your account.</p>
|
||||||
|
<div class="inputWithButton">
|
||||||
|
<input type="text" class="text" name="password" placeholder="Authenticate with Google..." disabled><!--
|
||||||
|
--><button id="authenticateWithGoogleButton" class="yellow" type="button">Google</button>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<hr>
|
||||||
|
<?php /* TODO: disabled for the time being, email modification should be implemented */ ?>
|
||||||
|
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" value="<?= $user['email'] ?>" disabled>
|
||||||
|
<input type="password" class="text big fullWidth marginTop" name="password_new" placeholder="New password" minlength="6">
|
||||||
|
<input type="password" class="text big fullWidth marginTop" name="password_new_confirm" placeholder="New password confirmation" minlength="6">
|
||||||
|
<p id="accountFormError" class="formError justify marginTop"></p>
|
||||||
|
<div class="right marginTop">
|
||||||
|
<button type="submit" name="submit" disabled>Save</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
28
views/account/google_authenticate.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
@js(js/account/google_authenticate.js)
|
||||||
|
|
||||||
|
@extends(templates/layout_minimal)
|
||||||
|
|
||||||
|
@section(main)
|
||||||
|
<h2>Authenticate with Google</h2>
|
||||||
|
<?php if (!$success): ?>
|
||||||
|
<div class="box">
|
||||||
|
<p class="error justify">
|
||||||
|
<?php if (isset($errorText)): ?>
|
||||||
|
<?= $errorText ?>
|
||||||
|
<?php else: ?>
|
||||||
|
Authentication with Google failed.
|
||||||
|
<?php endif; ?>
|
||||||
|
Please <a id="closeWindowButton" href="javascript:;" title="Close">close this window/tab</a> and try again!
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section(pageScript)
|
||||||
|
<script>
|
||||||
|
var success = <?= $success ? 'true' : 'false' ?>;
|
||||||
|
<?php if (isset($authenticatedWithGoogleUntil)): ?>
|
||||||
|
var authenticatedWithGoogleUntil = new Date('<?= $authenticatedWithGoogleUntil->format('c') ?>');
|
||||||
|
<?php endif; ?>
|
||||||
|
</script>
|
||||||
|
@endsection
|
6
views/error/404.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
|
@section(main)
|
||||||
|
<h2>404 | Page not found</h2>
|
||||||
|
<p>The requested URL was not found on this server. <a href="/" title="<?= $_ENV['APP_NAME'] ?>">Back to start.</a></p>
|
||||||
|
@endsection
|
8
views/index.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
|
@section(main)
|
||||||
|
<h2><?= $_ENV['APP_NAME'] ?></h2>
|
||||||
|
<div class="box">
|
||||||
|
<p>This is the new <?= $_ENV['APP_NAME'] ?>.</p>
|
||||||
|
</div>
|
||||||
|
@endsection
|
8
views/login/google_login.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
|
@section(main)
|
||||||
|
<h2>Login up with Google</h2>
|
||||||
|
<div class="box">
|
||||||
|
<p class="error justify">Authentication with Google failed. Please <a href="/login/google" title="Login with Google">try again</a>!</p>
|
||||||
|
</div>
|
||||||
|
@endsection
|
20
views/login/login.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
|
@section(main)
|
||||||
|
<h2>Login</h2>
|
||||||
|
<div class="box">
|
||||||
|
<form id="loginForm" action="/login" method="post" data-redirect-on-success="/">
|
||||||
|
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" required autofocus>
|
||||||
|
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" required minlength="6">
|
||||||
|
<p id="loginFormError" class="formError justify marginTop"></p>
|
||||||
|
<div class="right marginTop">
|
||||||
|
<button type="submit">Login</button>
|
||||||
|
</div>
|
||||||
|
<p class="center marginTop"><a href="/password/requestReset" title="Request password reset">Forgot your password?</a></p>
|
||||||
|
<hr>
|
||||||
|
<div class="center">
|
||||||
|
<a class="button yellow" href="/login/google" title="Login with Google">Login with Google</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
21
views/login/password_reset_request.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
@js(https://www.google.com/recaptcha/api.js)
|
||||||
|
|
||||||
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
|
@section(main)
|
||||||
|
<h2>Request password reset</h2>
|
||||||
|
<div class="box">
|
||||||
|
<form id="passwordResetForm" action="/password/requestReset" method="post" data-redirect-on-success="/password/requestReset/success">
|
||||||
|
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" value="<?= isset($email) ? $email : '' ?>" required autofocus>
|
||||||
|
<?php if (!empty($_ENV['RECAPTCHA_SITEKEY'])): ?>
|
||||||
|
<div class="marginTop">
|
||||||
|
<div class="g-recaptcha" data-sitekey="<?= $_ENV['RECAPTCHA_SITEKEY'] ?>"></div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<p id="passwordResetFormError" class="formError justify marginTop"></p>
|
||||||
|
<div class="right marginTop">
|
||||||
|
<button type="submit">Continue</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
@endsection
|
8
views/login/password_reset_request_success.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
|
@section(main)
|
||||||
|
<h2>Request password reset</h2>
|
||||||
|
<div class="box">
|
||||||
|
<p class="justify">Password reset was successfully requested. Please check your email and click on the link to reset your password!</p>
|
||||||
|
</div>
|
||||||
|
@endsection
|
20
views/login/reset_password.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
|
@section(main)
|
||||||
|
<h2>Reset password</h2>
|
||||||
|
<div class="box">
|
||||||
|
<?php if ($success) : ?>
|
||||||
|
<form id="resetPasswordForm" action="/password/reset/<?= $token ?>" method="post" data-redirect-on-success="/">
|
||||||
|
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" value="<?= $email ?>" disabled>
|
||||||
|
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" required minlength="6" autofocus>
|
||||||
|
<input type="password" class="text big fullWidth marginTop" name="password_confirm" placeholder="Password confirmation" required minlength="6">
|
||||||
|
<p id="resetPasswordFormError" class="formError justify marginTop"></p>
|
||||||
|
<div class="right">
|
||||||
|
<button class="marginTop" type="submit">Reset password</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<?php else: ?>
|
||||||
|
<p class="error justify">Confirming your identity failed. Please check the link you entered, or retry <a href="/password/requestReset" title="Request password reset">requesting password reset</a>!</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
@endsection
|
13
views/templates/layout_minimal.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
@extends(templates/rvr)
|
||||||
|
|
||||||
|
@section(content)
|
||||||
|
<header>
|
||||||
|
<h1>
|
||||||
|
<img class="inline" width="1em" height="1em" src="<?= $_ENV['STATIC_ROOT'] ?>/img/icon.svg?rev=<?= REVISION ?>" alt="<?= $_ENV['APP_NAME'] ?>"><!--
|
||||||
|
--><?= $_ENV['APP_NAME'] ?>
|
||||||
|
</h1>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
@yields('main')
|
||||||
|
</main>
|
||||||
|
@endsection
|
32
views/templates/layout_normal.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
@extends(templates/rvr)
|
||||||
|
|
||||||
|
@section(content)
|
||||||
|
<header>
|
||||||
|
<h1>
|
||||||
|
<a href="/" title="<?= $_ENV['APP_NAME'] ?>">
|
||||||
|
<img class="inline" width="1em" height="1em" src="<?= $_ENV['STATIC_ROOT'] ?>/img/icon.svg?rev=<?= REVISION ?>" alt="<?= $_ENV['APP_NAME'] ?>"><!--
|
||||||
|
--><span><?= $_ENV['APP_NAME'] ?></span>
|
||||||
|
</a>
|
||||||
|
</h1>
|
||||||
|
<p>
|
||||||
|
<?php if (Container::$request->user()) : ?>
|
||||||
|
<span><a href="/account" title="Account">
|
||||||
|
<?php /* Copyright (c) 2019 The Bootstrap Authors. License can be found in 'USED_SOFTWARE' in section 'Bootstrap Icons'. */ ?>
|
||||||
|
<svg class="inline" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path fill-rule="evenodd" d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
|
||||||
|
</svg><!--
|
||||||
|
--><?= Container::$request->user()->getDisplayName() ?><!--
|
||||||
|
--></a></span><!--
|
||||||
|
--><span><a href="/logout" title="Logout">Logout</a></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
@yields('main')
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<p><?= round($__debug_runtime, 0) ?> ms</p>
|
||||||
|
<p><span class="bold"><?= $_ENV['APP_NAME'] ?></span> <?= str_replace('Release_', '', VERSION) ?></p><!--
|
||||||
|
--><p>© The RVR Contributors <?= (new DateTime(REVISION_DATE))->format('Y') ?></p>
|
||||||
|
</footer>
|
||||||
|
@endsection
|
53
views/templates/rvr.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="description" content="<?= $_ENV['APP_NAME'] ?>">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="theme-color" content="#212f4d">
|
||||||
|
<title><?= $_ENV['APP_NAME'] ?></title>
|
||||||
|
<?php if (preg_match('/^(http(s)?:)?\/\//', $_ENV['STATIC_ROOT']) === 1): ?>
|
||||||
|
<link href="<?= $_ENV['STATIC_ROOT'] ?>" rel="preconnect">
|
||||||
|
<?php endif; ?>
|
||||||
|
<link href="https://fonts.gstatic.com" rel="preconnect">
|
||||||
|
<?php if (!empty($_ENV['GOOGLE_ANALITICS_ID'])): ?>
|
||||||
|
<link href="https://www.googletagmanager.com" rel="preconnect">
|
||||||
|
<link href="https://www.google-analytics.com" rel="preconnect">
|
||||||
|
<?php endif; ?>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Oxygen:wght@400;700&display=swap" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Oxygen+Mono:wght@400&display=swap" rel="stylesheet">
|
||||||
|
<link href="<?= $_ENV['STATIC_ROOT'] ?>/css/rvr.css?rev=<?= REVISION ?>" rel="stylesheet">
|
||||||
|
@yields('externalCss')
|
||||||
|
@yields('inlineCss')
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="<?= $_ENV['STATIC_ROOT'] ?>/img/favicon/192x192.png?rev=<?= REVISION ?>">
|
||||||
|
<link rel="icon" type="image/png" sizes="96x96" href="<?= $_ENV['STATIC_ROOT'] ?>/img/favicon/96x96.png?rev=<?= REVISION ?>">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="<?= $_ENV['STATIC_ROOT'] ?>/img/favicon/32x32.png?rev=<?= REVISION ?>">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="<?= $_ENV['STATIC_ROOT'] ?>/img/favicon/16x16.png?rev=<?= REVISION ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="loading">
|
||||||
|
<img src="<?= $_ENV['STATIC_ROOT'] ?>/img/loading.svg?rev=<?= REVISION ?>" width="64" height="64" alt="Loading">
|
||||||
|
</div>
|
||||||
|
<div id="cover"></div>
|
||||||
|
<div id="modal" class="modal">
|
||||||
|
<h2 id="modalTitle"></h2>
|
||||||
|
<p id="modalText" class="justify marginTop"></p>
|
||||||
|
<div id="modalButtons" class="right"></div>
|
||||||
|
</div>
|
||||||
|
@yields('pagemodal')
|
||||||
|
@yields('content')
|
||||||
|
<script>
|
||||||
|
const STATIC_ROOT = '<?= $_ENV['STATIC_ROOT'] ?>';
|
||||||
|
const REVISION = '<?= REVISION ?>';
|
||||||
|
var ANTI_CSRF_TOKEN = '<?= \Container::$request->session()->get('anti_csrf_token') ?>';
|
||||||
|
const GOOGLE_MAPS_JS_API_KEY = '<?= $_ENV['GOOGLE_MAPS_JS_API_KEY'] ?>';
|
||||||
|
<?php if (!empty($_ENV['GOOGLE_ANALITICS_ID'])): ?>
|
||||||
|
const GOOGLE_ANALITICS_ID = '<?= $_ENV['GOOGLE_ANALITICS_ID'] ?>';
|
||||||
|
<?php endif; ?>
|
||||||
|
</script>
|
||||||
|
@yields('pageScript')
|
||||||
|
<script src="<?= $_ENV['STATIC_ROOT'] ?>/js/rvr.js?rev=<?= REVISION ?>"></script>
|
||||||
|
@yields('externalJs')
|
||||||
|
@yields('inlineJs')
|
||||||
|
</body>
|
||||||
|
</html>
|
22
views/tests/view_complex.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
@css(test1.css)
|
||||||
|
@js(test1.js)
|
||||||
|
@js(test2_<?= $some['expression'] ?>)
|
||||||
|
|
||||||
|
@extra
|
||||||
|
<?php phpinfo() ?>
|
||||||
|
@endextra
|
||||||
|
|
||||||
|
@extends(parent)
|
||||||
|
|
||||||
|
@section(section1)
|
||||||
|
<div>Test HTML with @extends - section 1</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section(section2)
|
||||||
|
<div>Test HTML with @extends - section 2</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@extra
|
||||||
|
<?php $a = 'test_string' ?>
|
||||||
|
EXTRA
|
||||||
|
@endextra
|
5
views/tests/view_invalid_multiple_extends.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
@extends(parent1)
|
||||||
|
|
||||||
|
@extends(parent2)
|
||||||
|
|
||||||
|
<div>Test HTML with multiple @extends</div>
|
6
views/tests/view_invalid_multiple_sections_open.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
@extends(parent)
|
||||||
|
|
||||||
|
@section(section1)
|
||||||
|
@section(section2)
|
||||||
|
|
||||||
|
<div>Test HTML with opening @section before previous closed</div>
|
4
views/tests/view_invalid_section_not_open.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@extends(parent)
|
||||||
|
|
||||||
|
<div>Test HTML with @endsection when no section is open</div>
|
||||||
|
@endsection
|
3
views/tests/view_invalid_section_without_extends.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@section(section1)
|
||||||
|
|
||||||
|
<div>Test HTML with @section but without @extends</div>
|
4
views/tests/view_with_assets.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@css(test.css)
|
||||||
|
@js(test.js)
|
||||||
|
@js(test_<?= $some['expression'] ?>)
|
||||||
|
<div>Test HTML with @css and @js</div>
|
5
views/tests/view_with_extends.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
@extends(parent)
|
||||||
|
|
||||||
|
@section(section1)
|
||||||
|
<div>Test HTML with @extends</div>
|
||||||
|
@endsection
|
1
views/tests/view_without_extends.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<div>Test HTML without @extends</div>
|
74
web.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require 'app.php';
|
||||||
|
|
||||||
|
if (!empty($_ENV['DEV'])) {
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
ini_set('display_errors', '1');
|
||||||
|
} else {
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
Container::$routeCollection = new SokoWeb\Routing\RouteCollection();
|
||||||
|
|
||||||
|
Container::$routeCollection->get('index', '', [RVR\Controller\HomeController::class, 'getIndex']);
|
||||||
|
Container::$routeCollection->get('startSession', 'startSession.json', [RVR\Controller\HomeController::class, 'startSession']);
|
||||||
|
Container::$routeCollection->group('login', function (SokoWeb\Routing\RouteCollection $routeCollection) {
|
||||||
|
$routeCollection->get('login', '', [RVR\Controller\LoginController::class, 'getLoginForm']);
|
||||||
|
$routeCollection->post('login-action', '', [RVR\Controller\LoginController::class, 'login']);
|
||||||
|
$routeCollection->get('login-google', 'google', [RVR\Controller\LoginController::class, 'getGoogleLoginRedirect']);
|
||||||
|
$routeCollection->get('login-google-action', 'google/code', [RVR\Controller\LoginController::class, 'loginWithGoogle']);
|
||||||
|
});
|
||||||
|
Container::$routeCollection->group('password', function (SokoWeb\Routing\RouteCollection $routeCollection) {
|
||||||
|
$routeCollection->get('password-requestReset', 'requestReset', [RVR\Controller\LoginController::class, 'getRequestPasswordResetForm']);
|
||||||
|
$routeCollection->post('password-requestReset-action', 'requestReset', [RVR\Controller\LoginController::class, 'requestPasswordReset']);
|
||||||
|
$routeCollection->get('password-requestReset.success', 'requestReset/success', [RVR\Controller\LoginController::class, 'getRequestPasswordResetSuccess']);
|
||||||
|
$routeCollection->get('password-reset', 'reset/{token}', [RVR\Controller\LoginController::class, 'getResetPasswordForm']);
|
||||||
|
$routeCollection->post('password-reset.action', 'reset/{token}', [RVR\Controller\LoginController::class, 'resetPassword']);
|
||||||
|
});
|
||||||
|
Container::$routeCollection->get('logout', 'logout', [RVR\Controller\LoginController::class, 'logout']);
|
||||||
|
Container::$routeCollection->group('account', function (SokoWeb\Routing\RouteCollection $routeCollection) {
|
||||||
|
$routeCollection->get('account', '', [RVR\Controller\UserController::class, 'getAccount']);
|
||||||
|
$routeCollection->post('account-action', '', [RVR\Controller\UserController::class, 'saveAccount']);
|
||||||
|
$routeCollection->get('account.googleAuthenticate', 'googleAuthenticate', [RVR\Controller\UserController::class, 'getGoogleAuthenticateRedirect']);
|
||||||
|
$routeCollection->get('account.googleAuthenticate-action', 'googleAuthenticate/code', [RVR\Controller\UserController::class, 'authenticateWithGoogle']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Container::$sessionHandler = new SokoWeb\Session\DatabaseSessionHandler();
|
||||||
|
|
||||||
|
session_set_save_handler(Container::$sessionHandler, true);
|
||||||
|
session_start([
|
||||||
|
'gc_probability' => 0, // old sessions are deleted by MaintainDatabaseCommand
|
||||||
|
'cookie_lifetime' => 604800,
|
||||||
|
'cookie_path' => '/',
|
||||||
|
'cookie_httponly' => true,
|
||||||
|
'cookie_samesite' => 'Lax'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (isset($_COOKIE[session_name()])) {
|
||||||
|
// extend session cookie lifetime is cookie already exists
|
||||||
|
setcookie(session_name(), session_id(), [
|
||||||
|
'expires' => time() + 604800,
|
||||||
|
'path' => '/',
|
||||||
|
'httponly' => true,
|
||||||
|
'samesite' => 'Lax'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is needed to handle old type of session IDs
|
||||||
|
if (!Container::$sessionHandler->validateId(session_id())) {
|
||||||
|
session_regenerate_id(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Container::$request = new SokoWeb\Request\Request(
|
||||||
|
$_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'],
|
||||||
|
$_GET,
|
||||||
|
$_POST,
|
||||||
|
$_SESSION,
|
||||||
|
new RVR\Repository\UserRepository()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!Container::$request->session()->has('anti_csrf_token')) {
|
||||||
|
Container::$request->session()->set('anti_csrf_token', bin2hex(random_bytes(16)));
|
||||||
|
}
|