Week 4: Moved week 3 CMS into week 4

This commit is contained in:
Llewellyn van der Merwe 2022-04-17 23:04:21 +02:00
parent 3aad2bfca4
commit 5c42fc815d
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
104 changed files with 14204 additions and 0 deletions

39
week-04/README.md Normal file
View File

@ -0,0 +1,39 @@
# Homework: PDO and CRUD
Create a database named "sportstars". Inside that database, create a table also named "sportstars". Inside that table, the following column names would be required to complete the assignment:
| id | int(11) | primary key, not null, auto increment |
| --- | --- | --- |
| name | varchar(100) | not null |
| age | int(3) | not null |
| sport | varchar(100) | not null |
Create a PHP Web Application using the lesson plans taught during this week regarding PHP Data Objects (PDO), as well as the skills being used in the CMS project regarding CRUD (Create, Read, Update, and Delete) to create a fully-functional, dynamic, database-driven web application that will allow the user to enter the name, age, and sport of the sport star. The following criteria would be required when completing this:
- The Homepage (first page to access) MUST include a blank table. This table will display column headings "Name", "Age", "Sport", and "Update". There should be a link to allow the user to add a new sport star above or below the table. The last column in the table should be two separate links, one of which states "Edit" and another that states "Delete".
- When a user adds a new sport star, it'll take them to a form where the user will fill out the proper fields. Proper error handling must be displayed for a form with invalid characters, as well as empty form fields. When the user submits the newly created sport star, they should be told that the star has been added successfully with a link to go back to the Homepage to view the newly created star.
- When a user edits an existing sport star, it'll take them to an auto-filled form that has the information currently existing for the sport star in the form field. The user can change the information. Upon updating the existing sport star, the user should be redirected to the Homepage and be able to view their changes. The previously existing information should now display the updated information.
- When a user deletes an existing sport star, it should first give them a warning (either a new page or an alert box) asking the user to confirm the deletion or cancel it. Once confirmed, the sport star should be removed from both the database and the table on the Homepage.
Keep in mind that this is being done in PDO. The use of mysqli in PHP is FORBIDDEN and will result in a loss of points. Make sure upon completion to zip up your project files (with all pages created for this assignment) and then submit in this assignment.
Include a dump of your test database using the mysqldump program or phpmyAdmin and upload the exported file with your submission. Here are some sites with tutorials that show you how to use mysqldump and phpMyAdmin:
[How to export a database with mysqldump](http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html)
[How to export a database using phpMyAdmin](http://fragments.turtlemeat.com/mysql-database-backup-restore-phpmyadmin.php)
> See [homework](https://git.vdm.dev/champlain/WEBD-325-45/src/branch/master/week-04/homework)...
# Project: Content Management of Subjects
Complete the scripts to manage content for multiple subjects on the public site for your CMS projects. Your functionality should include all necessary CRUD (Create, Read, Update, Delete) tasks required to maintain subject categories on the public site. Remember that a logged in administrator (that was created in week 3) should have the ability to create, update, and delete the subjects appropriately. When an admin is updating a subject, the form field should be auto-filled with the information that is currently displaying for the subject. The admin and all users should have the ability to read the subjects. After you complete this part of your project, zip up your entire project and submit in this assignment.
There will be 2 points of extra credit awarded if PDO is used to complete the database programming with MySQL and PHP. There will be an additional 3 points extra credit awarded if you incorporate the Composer Library into your project. Make sure to send me a submission comment about your use of PDO and/or the Composer Library and what exactly you did with Composer so the extra credit can be awarded appropriately.
Also, make sure to include a dump of your test database using the mysqldump program or phpMyAdmin and upload the exported file with your submission. Here are some sites with tutorials that show how to use mysqldump and phpMyAdmin:
[How to export a database with mysqldump](http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html)
[How to export a database using phpMyAdmin](http://fragments.turtlemeat.com/mysql-database-backup-restore-phpmyadmin.php)
> See [project proposal](https://git.vdm.dev/champlain/WEBD-325-45/src/branch/master/week-04/project)...

28
week-04/project/.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
# IDE & System Related Files
.buildpath
.project
.settings
.DS_Store
.idea
.vscode
.docker
/docker-compose.yml
/nbproject
# Local System File
/octoconfig.php
/.htaccess
/web.config
/php.ini
# Vendor directory handling
/libraries/vendor
# OSX
._*
.Spotlight-V100
.Trashes
# Windows
Thumbs.db
Desktop.ini

674
week-04/project/LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 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 General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is 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. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
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.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
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 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. Use with the GNU Affero General Public License.
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 Affero 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 special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 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 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 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 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 General Public License for more details.
You should have received a copy of the GNU 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 the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
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 GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

28
week-04/project/README.md Normal file
View File

@ -0,0 +1,28 @@
# Login To Admin Area or Create an Account
This is the basic basic dependency injection CMS
## To install this CMS
1. Import the SQL tables into your database found in /sql/install.sql
2. Copy the /octoconfig.php.example file to /octoconfig.php
3. Update the /octoconfig.php to reflect your CMS details
4. Remove the installation folder from you root directory
## To install all composer libraries
0. Make sure you have [composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos) installed on your system.
1. In your terminal go to the root folder of your Octoleo website where you will find the composer.json file.
2. Run the following command composer install to install all PHP packages.
## To create an Account
1. Open [hostname:]/administrator
2. Click on link that says create Account
3. Fill in your details [done]
## To login to admin/staff area
1. Open [hostname:]/administrator
2. Add you username and password
3. Click login [done]

View File

@ -0,0 +1,97 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// Option to override defines from root folder
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L15
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
include_once dirname(__DIR__) . '/defines.php';
}
// Load the default defines
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L20
if (!defined('_LDEFINES'))
{
define('LPATH_BASE', dirname(__DIR__));
require_once LPATH_BASE . '/includes/defines.php';
}
// Check for presence of vendor dependencies not included in the git repository
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L26
if (!file_exists(LPATH_LIBRARIES . '/vendor/autoload.php'))
{
echo file_get_contents(LPATH_ROOT . '/templates/system/build_incomplete.html');
exit;
}
// Load configuration (or install)
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L34
require_once LPATH_BASE . '/includes/framework.php';
// Wrap in a try/catch so we can display an error if need be
try
{
$container = (new Joomla\DI\Container)
->registerServiceProvider(new Octoleo\CMS\Service\ConfigurationProvider(LPATH_CONFIGURATION . '/octoconfig.php'))
->registerServiceProvider(new Octoleo\CMS\Service\SessionProvider)
->registerServiceProvider(new Octoleo\CMS\Service\UserProvider)
->registerServiceProvider(new Octoleo\CMS\Service\AdminApplicationProvider)
->registerServiceProvider(new Joomla\Database\Service\DatabaseProvider)
->registerServiceProvider(new Octoleo\CMS\Service\EventProvider)
->registerServiceProvider(new Octoleo\CMS\Service\HttpProvider)
->registerServiceProvider(new Octoleo\CMS\Service\LoggingProvider)
->registerServiceProvider(new Joomla\Preload\Service\PreloadProvider)
->registerServiceProvider(new Octoleo\CMS\Service\TemplatingProvider);
// Alias the web application to Octoleo's base application class as this is the primary application for the environment
$container->alias(Joomla\Application\AbstractApplication::class, Joomla\Application\AbstractWebApplication::class);
// Alias the web logger to the PSR-3 interface as this is the primary logger for the environment
$container->alias(Monolog\Logger::class, 'monolog.logger.application.web')
->alias(Psr\Log\LoggerInterface::class, 'monolog.logger.application.web');
}
catch (\Throwable $e)
{
error_log($e);
header('HTTP/1.1 500 Internal Server Error', null, 500);
echo '<html><head><title>Container Initialization Error</title></head><body><h1>Container Initialization Error</h1><p>An error occurred while creating the DI container: ' . $e->getMessage() . '</p></body></html>';
exit(1);
}
// Execute the application
// source: https://github.com/joomla/framework.joomla.org/blob/master/www/index.php#L85
try
{
$app = $container->get(Joomla\Application\AbstractApplication::class);
// Set the application as global app
\Octoleo\CMS\Factory::$application = $app;
// Execute the application.
$app->execute();
}
catch (\Throwable $e)
{
error_log($e);
if (!headers_sent())
{
header('HTTP/1.1 500 Internal Server Error', null, 500);
header('Content-Type: text/html; charset=utf-8');
}
echo '<html><head><title>Application Error</title></head><body><h1>Application Error</h1><p>An error occurred while executing the application: ' . $e->getMessage() . '</p></body></html>';
exit(1);
}
// I am just playing around... ((ewɘ))yn purring

View File

@ -0,0 +1,24 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// Global definitions
$parts = explode(DIRECTORY_SEPARATOR, LPATH_BASE);
array_pop($parts);
// Defines.
define('LPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
define('LPATH_SITE', LPATH_ROOT);
define('LPATH_CONFIGURATION', LPATH_ROOT);
define('LPATH_ADMINISTRATOR', LPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
define('LPATH_LIBRARIES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
define('LPATH_INSTALLATION', LPATH_ROOT . DIRECTORY_SEPARATOR . 'installation');
define('LPATH_TEMPLATES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'templates/admin');

View File

@ -0,0 +1,35 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// System includes
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/framework.php#L14
require_once LPATH_LIBRARIES . '/bootstrap.php';
// Installation check, and check on removal of the installation directory.
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/framework.php#L17
if (!file_exists(LPATH_CONFIGURATION . '/octoconfig.php')
|| (filesize(LPATH_CONFIGURATION . '/octoconfig.php') < 10)
|| (file_exists(LPATH_INSTALLATION . '/index.php')))
{
if (file_exists(LPATH_INSTALLATION . '/index.php'))
{
header('Location: ../installation/index.php');
exit;
}
else
{
echo 'No configuration file found and no installation code available. Exiting...';
exit;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,35 @@
<?php
/**
* @package Octoleo CMS
*
* @created 3rd April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// NOTE: This file should remain compatible with PHP 5.2 to allow us to run our PHP minimum check and show a friendly error message
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/index.php#L9
// Define the application's minimum supported PHP version as a constant, so it can be referenced within the application.
define('OCTOLEO_MINIMUM_PHP', '7.2.5');
if (version_compare(PHP_VERSION, OCTOLEO_MINIMUM_PHP, '<'))
{
die(
str_replace(
'{{phpversion}}',
OCTOLEO_MINIMUM_PHP,
file_get_contents(dirname(__FILE__) . '/../templates/system/incompatible.html')
)
);
}
/**
* Constant that is checked in included files to prevent direct access.
*/
define('_LEXEC', 1);
// We must setup some house rules, since we can't have all
// this code just doing what it wants can we.... <<eWɘ>>yn growling
require_once dirname(__FILE__) . '/includes/app.php';

View File

@ -0,0 +1,71 @@
{
"name": "octoleo/cms",
"type": "project",
"description": "Octoleo CMS",
"keywords": [
"octoleo",
"cms"
],
"homepage": "https://github.com/mychamplain",
"license": "GPL-2.0-or-later",
"config": {
"optimize-autoloader": true,
"platform": {
"php": "7.2.5"
},
"vendor-dir": "libraries/vendor",
"github-protocols": ["https"],
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"autoload": {
"psr-4": {
"Octoleo\\CMS\\": "libraries/src/"
}
},
"require": {
"php": "^7.2.5",
"joomla/application": "~2.0",
"joomla/archive": "~2.0",
"joomla/authentication": "~2.0",
"joomla/console": "~2.0",
"joomla/controller": "~2.0",
"joomla/crypt": "~2.0",
"joomla/data": "~2.0",
"joomla/database": "~2.0",
"joomla/di": "~2.0",
"joomla/event": "~2.0",
"joomla/filter": "~2.0",
"joomla/filesystem": "~2.0",
"joomla/http": "~2.0",
"joomla/input": "~2.0",
"joomla/model": "~2.0",
"joomla/preload": "~2.0",
"joomla/ldap": "~2.0",
"joomla/oauth1": "~2.0",
"joomla/oauth2": "~2.0",
"joomla/registry": "~2.0",
"joomla/renderer": "~2.0",
"joomla/router": "~2.0",
"joomla/session": "~2.0",
"joomla/string": "~2.0",
"joomla/uri": "~2.0",
"joomla/utilities": "~2.0",
"algo26-matthias/idna-convert": "~3.0",
"joomla/view": "~2.0",
"laminas/laminas-diactoros": "^2.3",
"monolog/monolog": "^2.1",
"psr/link": "^1.0",
"ramsey/uuid": "^4.0.1",
"robmorgan/phinx": "^0.12.3",
"defuse/php-encryption": "^2.0",
"symfony/asset": "^5.1.2",
"symfony/process": "^5.1.2",
"symfony/web-link": "^5.1.2",
"symfony/yaml": "^5.1.2",
"theiconic/php-ga-measurement-protocol": "^2.7.2",
"twig/twig": "^2.13",
"phpmailer/phpmailer": "~6.0"
}
}

5392
week-04/project/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,196 @@
##
# @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
# @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
##
###########################################
# ======= Set basic Security header =======
# Just enable the rules on the live site and exclude the dev sites
<If "req('Host') == 'cms.builder.vdm'">
<IfModule mod_headers.c>
# X-XSS-Protection
Header always set X-XSS-Protection "1; mode=block"
# X-Frame-Options
Header always set X-Frame-Options DENY
# X-Content-Type nosniff
Header always set X-Content-Type-Options nosniff
# Referrer Policy
Header always set Referrer-Policy "no-referrer-when-downgrade"
# Strict-Transport-Security
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
# Cross-Origin-Opener-Policy
Header always set Cross-Origin-Opener-Policy "same-origin"
# Content-Security-Policy
Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'sha256-IxJ2MRv31XGmZD5ovlgSBrPmMjftYTJ3OM9/kLh6nBo=' 'sha256-QIsD5w9F5MPp3vlmsPHmbv0GZjN9ja3BuhcwpaWZuUw=' https://*.google-analytics.com https://www.googletagmanager.com https://*.pingdom.net; style-src 'self' 'sha256-4Su6mBWzEIFnH4pAGMOuaeBrstwJN4Z3pq/s1Kn4/KQ=' https://*.joomla.org https://fonts.googleapis.com; connect-src 'self' https://*.pingdom.net https://*.doubleclick.net https://*.google-analytics.com; frame-src 'self' https://*.googletagmanager.com; font-src 'self' https://fonts.gstatic.com https://*.joomla.org; img-src 'self' https://*.google-analytics.com https://*.googletagmanager.com https://*.joomla.org https://*.pingdom.net https://*.doubleclick.net https://*.githubusercontent.com https://*.travis-ci.org https://travis-ci.org; frame-ancestors 'self'; report-uri https://joomla.report-uri.com/r/t/csp/enforce"
</IfModule>
</If>
###########################################
###########################################
# ======= Enable the Rewrite Engine =======
RewriteEngine On
###########################################
###########################################
# ======= No directory listings =======
IndexIgnore *
Options +FollowSymLinks
Options -Indexes
###########################################
###########################################
# === Optimal default expiration time ===
<IfModule mod_expires.c>
# Enable expiration control
ExpiresActive On
# Default expiration: 1 hour after request
ExpiresDefault "now plus 1 hour"
# CSS and JS expiration: 1 week after request
ExpiresByType text/css "now plus 1 week"
ExpiresByType application/javascript "now plus 1 week"
ExpiresByType application/x-javascript "now plus 1 week"
# Image files expiration: 1 month after request
ExpiresByType image/bmp "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"
ExpiresByType image/jp2 "now plus 1 month"
ExpiresByType image/pipeg "now plus 1 month"
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/svg+xml "now plus 1 month"
ExpiresByType image/tiff "now plus 1 month"
ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
ExpiresByType image/x-icon "now plus 1 month"
ExpiresByType image/ico "now plus 1 month"
ExpiresByType image/icon "now plus 1 month"
ExpiresByType text/ico "now plus 1 month"
ExpiresByType application/ico "now plus 1 month"
ExpiresByType image/vnd.wap.wbmp "now plus 1 month"
ExpiresByType application/vnd.wap.wbxml "now plus 1 month"
ExpiresByType application/smil "now plus 1 month"
# Audio files expiration: 1 month after request
ExpiresByType audio/basic "now plus 1 month"
ExpiresByType audio/mid "now plus 1 month"
ExpiresByType audio/midi "now plus 1 month"
ExpiresByType audio/mpeg "now plus 1 month"
ExpiresByType audio/x-aiff "now plus 1 month"
ExpiresByType audio/x-mpegurl "now plus 1 month"
ExpiresByType audio/x-pn-realaudio "now plus 1 month"
ExpiresByType audio/x-wav "now plus 1 month"
# Movie files expiration: 1 month after request
ExpiresByType application/x-shockwave-flash "now plus 1 month"
ExpiresByType x-world/x-vrml "now plus 1 month"
ExpiresByType video/x-msvideo "now plus 1 month"
ExpiresByType video/mpeg "now plus 1 month"
ExpiresByType video/mp4 "now plus 1 month"
ExpiresByType video/quicktime "now plus 1 month"
ExpiresByType video/x-la-asf "now plus 1 month"
ExpiresByType video/x-ms-asf "now plus 1 month"
</IfModule>
###########################################
###########################################
# == Automatic compression of resources ==
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
</IfModule>
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_keep_workfiles No
mod_gzip_can_negotiate Yes
mod_gzip_add_header_count Yes
mod_gzip_send_vary Yes
mod_gzip_min_http 1000
mod_gzip_minimum_file_size 300
mod_gzip_maximum_file_size 512000
mod_gzip_maximum_inmem_size 60000
mod_gzip_handle_methods GET
mod_gzip_item_include file \.(html?|txt|css|js|php|pl|xml|rb|py)$
mod_gzip_item_include mime ^text/plain$
mod_gzip_item_include mime ^text/html$
mod_gzip_item_include mime ^text/xml$
mod_gzip_item_include mime ^text/css$
mod_gzip_item_include mime ^application/xml$
mod_gzip_item_include mime ^application/xhtml+xml$
mod_gzip_item_include mime ^application/rss+xml$
mod_gzip_item_include mime ^application/javascript$
mod_gzip_item_include mime ^application/x-javascript$
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include handler ^server-status$
mod_gzip_item_include handler ^server-info$
mod_gzip_item_include handler ^application/x-httpd-php
mod_gzip_item_exclude mime ^image/.*
</IfModule>
###########################################
###########################################
# ======== Remove multiple slashes ========
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]
###########################################
###########################################
# ======== Remove trailing slashes ========
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]
###########################################
###########################################
# ======== Redirect HTTP to HTTPS =========
#RewriteCond %{HTTPS} off
#RewriteCond %{HTTP_HOST} ^framework.joomla.org$ [NC]
#RewriteRule ^(.*)$ https://framework.joomla.org/$1 [R=301,L,QSA]
###########################################
###########################################
# ======== Redirect removed pages =========
#RewriteCond %{REQUEST_URI} ^/about
#RewriteRule ^(.*)$ /contributors [R=301,L,QSA]
###########################################
###########################################
# ======== SEF URL Routing ========
# If the request is not for a static asset
RewriteCond %{REQUEST_URI} !^/media/
# Or for a file that exists in the web directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite the request to run the application
RewriteRule (.*) index.php
###########################################

View File

@ -0,0 +1,95 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// Option to override defines from root folder
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L15
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
include_once dirname(__DIR__) . '/defines.php';
}
// Load the default defines
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L20
if (!defined('_LDEFINES'))
{
define('LPATH_BASE', dirname(__DIR__));
require_once LPATH_BASE . '/includes/defines.php';
}
// Check for presence of vendor dependencies not included in the git repository
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L26
if (!file_exists(LPATH_LIBRARIES . '/vendor/autoload.php'))
{
echo file_get_contents(LPATH_ROOT . '/templates/system/build_incomplete.html');
exit;
}
// Load configuration (or install)
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L34
require_once LPATH_BASE . '/includes/framework.php';
// Wrap in a try/catch so we can display an error if need be
try
{
$container = (new Joomla\DI\Container)
->registerServiceProvider(new Octoleo\CMS\Service\SiteApplicationProvider)
->registerServiceProvider(new Octoleo\CMS\Service\ConfigurationProvider(LPATH_CONFIGURATION . '/octoconfig.php'))
->registerServiceProvider(new Joomla\Database\Service\DatabaseProvider)
->registerServiceProvider(new Octoleo\CMS\Service\EventProvider)
->registerServiceProvider(new Octoleo\CMS\Service\HttpProvider)
->registerServiceProvider(new Octoleo\CMS\Service\LoggingProvider)
->registerServiceProvider(new Joomla\Preload\Service\PreloadProvider)
->registerServiceProvider(new Octoleo\CMS\Service\TemplatingProvider);
// Alias the web application to Octoleo's base application class as this is the primary application for the environment
$container->alias(Joomla\Application\AbstractApplication::class, Joomla\Application\AbstractWebApplication::class);
// Alias the web logger to the PSR-3 interface as this is the primary logger for the environment
$container->alias(Monolog\Logger::class, 'monolog.logger.application.web')
->alias(Psr\Log\LoggerInterface::class, 'monolog.logger.application.web');
}
catch (\Throwable $e)
{
error_log($e);
header('HTTP/1.1 500 Internal Server Error', null, 500);
echo '<html><head><title>Container Initialization Error</title></head><body><h1>Container Initialization Error</h1><p>An error occurred while creating the DI container: ' . $e->getMessage() . '</p></body></html>';
exit(1);
}
// Execute the application
// source: https://github.com/joomla/framework.joomla.org/blob/master/www/index.php#L85
try
{
$app = $container->get(Joomla\Application\AbstractApplication::class);
// Set the application as global app
\Octoleo\CMS\Factory::$application = $app;
// Execute the application.
$app->execute();
}
catch (\Throwable $e)
{
error_log($e);
if (!headers_sent())
{
header('HTTP/1.1 500 Internal Server Error', null, 500);
header('Content-Type: text/html; charset=utf-8');
}
echo '<html><head><title>Application Error</title></head><body><h1>Application Error</h1><p>An error occurred while executing the application: ' . $e->getMessage() . '</p></body></html>';
exit(1);
}
// I am just playing around... ((ewɘ))yn purring

View File

@ -0,0 +1,23 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// Global definitions
$parts = explode(DIRECTORY_SEPARATOR, LPATH_BASE);
// Defines.
define('LPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
define('LPATH_SITE', LPATH_ROOT);
define('LPATH_CONFIGURATION', LPATH_ROOT);
define('LPATH_ADMINISTRATOR', LPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
define('LPATH_LIBRARIES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
define('LPATH_INSTALLATION', LPATH_ROOT . DIRECTORY_SEPARATOR . 'installation');
define('LPATH_TEMPLATES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'templates/site');

View File

@ -0,0 +1,35 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// System includes
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/framework.php#L14
require_once LPATH_LIBRARIES . '/bootstrap.php';
// Installation check, and check on removal of the installation directory.
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/framework.php#L17
if (!file_exists(LPATH_CONFIGURATION . '/octoconfig.php')
|| (filesize(LPATH_CONFIGURATION . '/octoconfig.php') < 10)
|| (file_exists(LPATH_INSTALLATION . '/index.php')))
{
if (file_exists(LPATH_INSTALLATION . '/index.php'))
{
header('Location: ' . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php')) . 'installation/index.php');
exit;
}
else
{
echo 'No configuration file found and no installation code available. Exiting...';
exit;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

35
week-04/project/index.php Normal file
View File

@ -0,0 +1,35 @@
<?php
/**
* @package Octoleo CMS
*
* @created 3rd April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// NOTE: This file should remain compatible with PHP 5.2 to allow us to run our PHP minimum check and show a friendly error message
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/index.php#L9
// Define the application's minimum supported PHP version as a constant, so it can be referenced within the application.
define('OCTOLEO_MINIMUM_PHP', '7.2.5');
if (version_compare(PHP_VERSION, OCTOLEO_MINIMUM_PHP, '<'))
{
die(
str_replace(
'{{phpversion}}',
OCTOLEO_MINIMUM_PHP,
file_get_contents(dirname(__FILE__) . '/templates/system/incompatible.html')
)
);
}
/**
* Constant that is checked in included files to prevent direct access.
*/
define('_LEXEC', 1);
// We must setup some house rules, since we can't have all
// this code just doing what it wants can we?... <<eWɘ>>yn growling
require_once dirname(__FILE__) . '/includes/app.php';

View File

@ -0,0 +1,31 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// Option to override defines from root folder
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L15
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
include_once dirname(__DIR__) . '/defines.php';
}
// Load the default defines
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/includes/app.php#L20
if (!defined('_LDEFINES'))
{
define('LPATH_BASE', dirname(__DIR__));
require_once LPATH_BASE . '/includes/defines.php';
}
// I have not yet had time to finish this part of the application (CMS)
echo file_get_contents(LPATH_ROOT . '/templates/system/install_notice.html');
exit;

View File

@ -0,0 +1,23 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// Global definitions
$parts = explode(DIRECTORY_SEPARATOR, LPATH_BASE);
array_pop($parts);
// Defines.
define('LPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
define('LPATH_SITE', LPATH_ROOT);
define('LPATH_CONFIGURATION', LPATH_ROOT);
define('LPATH_ADMINISTRATOR', LPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
define('LPATH_LIBRARIES', LPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');
define('LPATH_INSTALLATION', LPATH_ROOT . DIRECTORY_SEPARATOR . 'installation');

View File

@ -0,0 +1,41 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// System includes
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/administrator/includes/framework.php#L14
require_once LPATH_LIBRARIES . '/bootstrap.php';
// Installation check, and check on removal of the installation directory.
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/administrator/includes/framework.php#L17
if (!file_exists(LPATH_CONFIGURATION . '/octoconfig.php')
|| (filesize(LPATH_CONFIGURATION . '/octoconfig.php') < 10)
|| (file_exists(LPATH_INSTALLATION . '/index.php')))
{
if (file_exists(LPATH_INSTALLATION . '/index.php'))
{
header('Location: ../installation/index.php');
exit;
}
else
{
echo 'No configuration file found and no installation code available. Exiting...';
exit;
}
}
// Pre-Load configuration. Don't remove the Output Buffering due to BOM issues.
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/administrator/includes/framework.php#L36
ob_start();
require_once LPATH_CONFIGURATION . '/octoconfig.php';
ob_end_clean();

View File

@ -0,0 +1,35 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// NOTE: This file should remain compatible with PHP 5.2 to allow us to run our PHP minimum check and show a friendly error message
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/index.php#L9
// Define the application's minimum supported PHP version as a constant, so it can be referenced within the application.
define('OCTOLEO_MINIMUM_PHP', '7.2.5');
if (version_compare(PHP_VERSION, OCTOLEO_MINIMUM_PHP, '<'))
{
die(
str_replace(
'{{phpversion}}',
OCTOLEO_MINIMUM_PHP,
file_get_contents(dirname(__FILE__) . '/../templates/system/incompatible.html')
)
);
}
/**
* Constant that is checked in included files to prevent direct access.
*/
define('_LEXEC', 1);
// We must setup some house rules, since we can't have all
// this code just doing what it wants can we.... <<eWɘ>>yn growling
require_once dirname(__FILE__) . '/includes/app.php';

View File

@ -0,0 +1,9 @@
# Apache 2.4+
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Apache 2.0-2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>

View File

@ -0,0 +1,48 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_LEXEC') or die;
// Set the platform root path as a constant if necessary.
// source: https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/bootstrap.php#L12
defined('LPATH_PLATFORM') or define('LPATH_PLATFORM', __DIR__);
// Detect the native operating system type.
$os = strtoupper(substr(PHP_OS, 0, 3));
defined('IS_WIN') or define('IS_WIN', ($os === 'WIN'));
defined('IS_UNIX') or define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')));
// Import the library loader if necessary.
if (!class_exists('LLoader'))
{
require_once LPATH_PLATFORM . '/loader.php';
// If JLoader still does not exist panic.
if (!class_exists('LLoader'))
{
throw new RuntimeException('Octoleo Platform not loaded.');
}
}
// Setup the autoloaders.
LLoader::setup();
// Create the Composer autoloader
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require LPATH_LIBRARIES . '/vendor/autoload.php';
// We need to pull our decorated class loader into memory before unregistering Composer's loader
class_exists('\\Octoleo\\CMS\\Autoload\\ClassLoader');
$loader->unregister();
// Decorate Composer autoloader
spl_autoload_register([new \Octoleo\CMS\Autoload\ClassLoader($loader), 'loadClass'], true, true);

View File

@ -0,0 +1,599 @@
<?php
/**
* @package Octoleo CMS
*
* Joomla! Content Management System
*
* @source https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/loader.php
* @adapted Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
*
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
**/
defined('LPATH_PLATFORM') or die;
/**
* Static class to handle loading of libraries.
*
* @since 1.0.0
*/
abstract class LLoader
{
/**
* Container for already imported library paths.
*
* @var array
* @since 1.7.0
*/
protected static $classes = array();
/**
* Container for already imported library paths.
*
* @var array
* @since 1.7.0
*/
protected static $imported = array();
/**
* Container for registered library class prefixes and path lookups.
*
* @var array
* @since 3.0.0
*/
protected static $prefixes = array();
/**
* Holds proxy classes and the class names the proxy.
*
* @var array
* @since 3.2
*/
protected static $classAliases = array();
/**
* Holds the inverse lookup for proxy classes and the class names the proxy.
*
* @var array
* @since 3.4
*/
protected static $classAliasesInverse = array();
/**
* Container for namespace => path map.
*
* @var array
* @since 3.1.4
*/
protected static $namespaces = array();
/**
* Holds a reference for all deprecated aliases (mainly for use by a logging platform).
*
* @var array
* @since 3.6.3
*/
protected static $deprecatedAliases = array();
/**
* The root folders where extensions can be found.
*
* @var array
* @since 4.0.0
*/
protected static $extensionRootFolders = array();
/**
* Method to get the list of registered classes and their respective file paths for the autoloader.
*
* @return array The array of class => path values for the autoloader.
*
* @since 1.7.0
*/
public static function getClassList()
{
return self::$classes;
}
/**
* Method to get the list of deprecated class aliases.
*
* @return array An associative array with deprecated class alias data.
*
* @since 3.6.3
*/
public static function getDeprecatedAliases()
{
return self::$deprecatedAliases;
}
/**
* Method to get the list of registered namespaces.
*
* @return array The array of namespace => path values for the autoloader.
*
* @since 3.1.4
*/
public static function getNamespaces()
{
return self::$namespaces;
}
/**
* Load the file for a class.
*
* @param string $class The class to be loaded.
*
* @return boolean True on success
*
* @since 1.7.0
*/
public static function load($class)
{
// Sanitize class name.
$key = strtolower($class);
// If the class already exists do nothing.
if (class_exists($class, false))
{
return true;
}
// If the class is registered include the file.
if (isset(self::$classes[$key]))
{
$found = (bool) include_once self::$classes[$key];
if ($found)
{
self::loadAliasFor($class);
}
// If the class doesn't exists, we probably have a class alias available
if (!class_exists($class, false))
{
// Search the alias class, first none namespaced and then namespaced
$original = array_search($class, self::$classAliases) ? : array_search('\\' . $class, self::$classAliases);
// When we have an original and the class exists an alias should be created
if ($original && class_exists($original, false))
{
class_alias($original, $class);
}
}
return true;
}
return false;
}
/**
* Register a class prefix with lookup path. This will allow developers to register library
* packages with different class prefixes to the system autoloader. More than one lookup path
* may be registered for the same class prefix, but if this method is called with the reset flag
* set to true then any registered lookups for the given prefix will be overwritten with the current
* lookup path. When loaded, prefix paths are searched in a "last in, first out" order.
*
* @param string $prefix The class prefix to register.
* @param string $path Absolute file path to the library root where classes with the given prefix can be found.
* @param boolean $reset True to reset the prefix with only the given lookup path.
* @param boolean $prepend If true, push the path to the beginning of the prefix lookup paths array.
*
* @return void
*
* @throws RuntimeException
*
* @since 3.0.0
*/
public static function registerPrefix($prefix, $path, $reset = false, $prepend = false)
{
// Verify the library path exists.
if (!is_dir($path))
{
$path = (str_replace(LPATH_ROOT, '', $path) == $path) ? basename($path) : str_replace(LPATH_ROOT, '', $path);
throw new RuntimeException('Library path ' . $path . ' cannot be found.', 500);
}
// If the prefix is not yet registered or we have an explicit reset flag then set set the path.
if ($reset || !isset(self::$prefixes[$prefix]))
{
self::$prefixes[$prefix] = array($path);
}
// Otherwise we want to simply add the path to the prefix.
else
{
if ($prepend)
{
array_unshift(self::$prefixes[$prefix], $path);
}
else
{
self::$prefixes[$prefix][] = $path;
}
}
}
/**
* Offers the ability for "just in time" usage of `class_alias()`.
* You cannot overwrite an existing alias.
*
* @param string $alias The alias name to register.
* @param string $original The original class to alias.
* @param string|boolean $version The version in which the alias will no longer be present.
*
* @return boolean True if registration was successful. False if the alias already exists.
*
* @since 3.2
*/
public static function registerAlias($alias, $original, $version = false)
{
// PHP is case insensitive so support all kind of alias combination
$lowercasedAlias = strtolower($alias);
if (!isset(self::$classAliases[$lowercasedAlias]))
{
self::$classAliases[$lowercasedAlias] = $original;
$original = self::stripFirstBackslash($original);
if (!isset(self::$classAliasesInverse[$original]))
{
self::$classAliasesInverse[$original] = array($lowercasedAlias);
}
else
{
self::$classAliasesInverse[$original][] = $lowercasedAlias;
}
// If given a version, log this alias as deprecated
if ($version)
{
self::$deprecatedAliases[] = array('old' => $alias, 'new' => $original, 'version' => $version);
}
return true;
}
return false;
}
/**
* Register a namespace to the autoloader. When loaded, namespace paths are searched in a "last in, first out" order.
*
* @param string $namespace A case sensitive Namespace to register.
* @param string $path A case sensitive absolute file path to the library root where classes of the given namespace can be found.
* @param boolean $reset True to reset the namespace with only the given lookup path.
* @param boolean $prepend If true, push the path to the beginning of the namespace lookup paths array.
*
* @return void
*
* @throws RuntimeException
*
* @since 3.1.4
*/
public static function registerNamespace($namespace, $path, $reset = false, $prepend = false)
{
// Verify the library path exists.
if (!is_dir($path))
{
$path = (str_replace(LPATH_ROOT, '', $path) == $path) ? basename($path) : str_replace(LPATH_ROOT, '', $path);
throw new RuntimeException('Library path ' . $path . ' cannot be found.', 500);
}
// Trim leading and trailing backslashes from namespace, allowing "\Parent\Child", "Parent\Child\" and "\Parent\Child\" to be treated the same way.
$namespace = trim($namespace, '\\');
// If the namespace is not yet registered or we have an explicit reset flag then set the path.
if ($reset || !isset(self::$namespaces[$namespace]))
{
self::$namespaces[$namespace] = array($path);
}
// Otherwise we want to simply add the path to the namespace.
else
{
if ($prepend)
{
array_unshift(self::$namespaces[$namespace], $path);
}
else
{
self::$namespaces[$namespace][] = $path;
}
}
}
/**
* Method to setup the autoloaders for the Octoleo Platform.
* Since the SPL autoloaders are called in a queue we will add our explicit
* class-registration based loader first, then fall back on the autoloader based on conventions.
* This will allow people to register a class in a specific location and override platform libraries
* as was previously possible.
*
* @param boolean $enablePsr True to enable autoloading based on PSR-0.
* @param boolean $enablePrefixes True to enable prefix based class loading (needed to auto load the Octoleo core).
* @param boolean $enableClasses True to enable class map based class loading (needed to auto load the Octoleo core).
*
* @return void
*
* @since 3.1.4
*/
public static function setup($enablePsr = true, $enablePrefixes = true, $enableClasses = true)
{
if ($enableClasses)
{
// Register the class map based autoloader.
spl_autoload_register(array('LLoader', 'load'));
}
if ($enablePrefixes)
{
// Register the prefix autoloader.
spl_autoload_register(array('LLoader', '_autoload'));
}
if ($enablePsr)
{
// Register the PSR based autoloader.
spl_autoload_register(array('LLoader', 'loadByPsr'));
spl_autoload_register(array('LLoader', 'loadByAlias'));
}
}
/**
* Method to autoload classes that are namespaced to the PSR-4 standard.
*
* @param string $class The fully qualified class name to autoload.
*
* @return boolean True on success, false otherwise.
*
* @since 3.7.0
* @deprecated 5.0 Use LLoader::loadByPsr instead
*/
public static function loadByPsr4($class)
{
return self::loadByPsr($class);
}
/**
* Method to autoload classes that are namespaced to the PSR-4 standard.
*
* @param string $class The fully qualified class name to autoload.
*
* @return boolean True on success, false otherwise.
*
* @since 4.0.0
*/
public static function loadByPsr($class)
{
$class = self::stripFirstBackslash($class);
// Find the location of the last NS separator.
$pos = strrpos($class, '\\');
// If one is found, we're dealing with a NS'd class.
if ($pos !== false)
{
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
$className = substr($class, $pos + 1);
}
// If not, no need to parse path.
else
{
$classPath = null;
$className = $class;
}
$classPath .= $className . '.php';
// Loop through registered namespaces until we find a match.
foreach (self::$namespaces as $ns => $paths)
{
if (strpos($class, "{$ns}\\") === 0)
{
$nsPath = trim(str_replace('\\', DIRECTORY_SEPARATOR, $ns), DIRECTORY_SEPARATOR);
// Loop through paths registered to this namespace until we find a match.
foreach ($paths as $path)
{
$classFilePath = realpath($path . DIRECTORY_SEPARATOR . substr_replace($classPath, '', 0, strlen($nsPath) + 1));
// We do not allow files outside the namespace root to be loaded
if (strpos($classFilePath, realpath($path)) !== 0)
{
continue;
}
// We check for class_exists to handle case-sensitive file systems
if (is_file($classFilePath) && !class_exists($class, false))
{
$found = (bool) include_once $classFilePath;
if ($found)
{
self::loadAliasFor($class);
}
return $found;
}
}
}
}
return false;
}
/**
* Method to autoload classes that have been aliased using the registerAlias method.
*
* @param string $class The fully qualified class name to autoload.
*
* @return boolean True on success, false otherwise.
*
* @since 3.2
*/
public static function loadByAlias($class)
{
$class = strtolower(self::stripFirstBackslash($class));
if (isset(self::$classAliases[$class]))
{
// Force auto-load of the regular class
class_exists(self::$classAliases[$class], true);
// Normally this shouldn't execute as the autoloader will execute applyAliasFor when the regular class is
// auto-loaded above.
if (!class_exists($class, false) && !interface_exists($class, false))
{
class_alias(self::$classAliases[$class], $class);
}
}
}
/**
* Applies a class alias for an already loaded class, if a class alias was created for it.
*
* @param string $class We'll look for and register aliases for this (real) class name
*
* @return void
*
* @since 3.4
*/
public static function applyAliasFor($class)
{
$class = self::stripFirstBackslash($class);
if (isset(self::$classAliasesInverse[$class]))
{
foreach (self::$classAliasesInverse[$class] as $alias)
{
class_alias($class, $alias);
}
}
}
/**
* Autoload a class based on name.
*
* @param string $class The class to be loaded.
*
* @return boolean True if the class was loaded, false otherwise.
*
* @since 1.7.3
*/
public static function _autoload($class)
{
foreach (self::$prefixes as $prefix => $lookup)
{
$chr = strlen($prefix) < strlen($class) ? $class[strlen($prefix)] : 0;
if (strpos($class, $prefix) === 0 && ($chr === strtoupper($chr)))
{
return self::_load(substr($class, strlen($prefix)), $lookup);
}
}
return false;
}
/**
* Load a class based on name and lookup array.
*
* @param string $class The class to be loaded (without prefix).
* @param array $lookup The array of base paths to use for finding the class file.
*
* @return boolean True if the class was loaded, false otherwise.
*
* @since 3.0.0
*/
private static function _load($class, $lookup)
{
// Split the class name into parts separated by camelCase.
$parts = preg_split('/(?<=[a-z0-9])(?=[A-Z])/x', $class);
$partsCount = count($parts);
foreach ($lookup as $base)
{
// Generate the path based on the class name parts.
$path = realpath($base . '/' . implode('/', array_map('strtolower', $parts)) . '.php');
// Load the file if it exists and is in the lookup path.
if (strpos($path, realpath($base)) === 0 && is_file($path))
{
$found = (bool) include_once $path;
if ($found)
{
self::loadAliasFor($class);
}
return $found;
}
// Backwards compatibility patch
// If there is only one part we want to duplicate that part for generating the path.
if ($partsCount === 1)
{
// Generate the path based on the class name parts.
$path = realpath($base . '/' . implode('/', array_map('strtolower', array($parts[0], $parts[0]))) . '.php');
// Load the file if it exists and is in the lookup path.
if (strpos($path, realpath($base)) === 0 && is_file($path))
{
$found = (bool) include_once $path;
if ($found)
{
self::loadAliasFor($class);
}
return $found;
}
}
}
return false;
}
/**
* Loads the aliases for the given class.
*
* @param string $class The class.
*
* @return void
*
* @since 3.8.0
*/
private static function loadAliasFor($class)
{
if (!array_key_exists($class, self::$classAliasesInverse))
{
return;
}
foreach (self::$classAliasesInverse[$class] as $alias)
{
// Force auto-load of the alias class
class_exists($alias, true);
}
}
/**
* Strips the first backslash from the given class if present.
*
* @param string $class The class to strip the first prefix from.
*
* @return string The striped class name.
*
* @since 3.8.0
*/
private static function stripFirstBackslash($class)
{
return $class && $class[0] === '\\' ? substr($class, 1) : $class;
}
}

View File

@ -0,0 +1,90 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Application;
use Joomla\Application\AbstractWebApplication;
use Joomla\Application\Controller\ControllerResolverInterface;
use Joomla\Application\SessionAwareWebApplicationInterface;
use Joomla\Application\SessionAwareWebApplicationTrait;
use Joomla\Application\Web\WebClient;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
use Joomla\Router\RouterInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Site application class
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/WebApplication.php
*/
class AdminApplication extends AbstractWebApplication implements SessionAwareWebApplicationInterface, SessionMessageAwareInterface, IdentityAwareInterface
{
use IdentityAwareTrait, SessionMessageAwareTrait, SessionAwareWebApplicationTrait;
/**
* The application's controller resolver.
*
* @var ControllerResolverInterface
*/
protected $controllerResolver;
/**
* The application's router.
*
* @var RouterInterface
*/
protected $router;
/**
* Class constructor.
*
* @param ControllerResolverInterface $controllerResolver The application's controller resolver
* @param RouterInterface $router The application's router
* @param Input $input An optional argument to provide dependency injection for the application's
* input object.
* @param Registry $config An optional argument to provide dependency injection for the application's
* config object.
* @param WebClient $client An optional argument to provide dependency injection for the application's
* client object.
* @param ResponseInterface $response An optional argument to provide dependency injection for the application's
* response object.
*/
public function __construct(
ControllerResolverInterface $controllerResolver,
RouterInterface $router,
Input $input = null,
Registry $config = null,
WebClient $client = null,
ResponseInterface $response = null
)
{
$this->controllerResolver = $controllerResolver;
$this->router = $router;
// Call the constructor as late as possible (it runs `initialise`).
parent::__construct($input, $config, $client, $response);
}
/**
* Method to run the application routines.
*
* @return void
*/
protected function doExecute(): void
{
$route = $this->router->parseRoute($this->get('uri.route'), $this->input->getMethod());
// Add variables to the input if not already set
foreach ($route->getRouteVariables() as $key => $value)
{
$this->input->def($key, $value);
}
\call_user_func($this->controllerResolver->resolve($route));
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Application;
use Octoleo\CMS\User\User;
use Octoleo\CMS\User\UserFactoryInterface;
interface IdentityAwareInterface
{
/**
* Get the application identity.
*
* @return User
*
* @since 1.0.0
*/
public function getIdentity(): User;
/**
* Allows the application to load a custom or default identity.
*
* @param User $identity An optional identity object. If omitted, a null user object is created.
*
* @return $this
*
* @since 1.0.0
*/
public function loadIdentity(User $identity = null): IdentityAwareInterface;
/**
* Set the user factory to use.
*
* @param UserFactoryInterface $userFactory The user factory to use
*
* @return void
*
* @since 1.0.0
*/
public function setUserFactory(UserFactoryInterface $userFactory);
/**
* Get the user factory to use.
*
* @return UserFactoryInterface
*
* @since 1.0.0
*/
public function getUserFactory(): UserFactoryInterface;
}

View File

@ -0,0 +1,91 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Octoleo\CMS\Application;
use Octoleo\CMS\User\User;
use Octoleo\CMS\User\UserFactoryInterface;
/**
* Trait for application classes which are identity (user) aware
*
* @since 1.0.0
*/
trait IdentityAwareTrait
{
/**
* The application identity object.
*
* @var User
* @since 1.0.0
*/
protected $identity;
/**
* UserFactoryInterface
*
* @var UserFactoryInterface
* @since 1.0.0
*/
private $userFactory;
/**
* Get the application identity.
*
* @return User
*
* @since 1.0.0
*/
public function getIdentity(): User
{
return $this->identity;
}
/**
* Allows the application to load a custom or default identity.
*
* @param User $identity An optional identity object. If omitted, a null user object is created.
*
* @return IdentityAwareInterface
*
* @since 1.0.0
*/
public function loadIdentity(User $identity = null): IdentityAwareInterface
{
$this->identity = $identity ?: $this->userFactory->loadUserById(0);
return $this;
}
/**
* Set the user factory to use.
*
* @param UserFactoryInterface $userFactory The user factory to use
*
* @return void
*
* @since 1.0.0
*/
public function setUserFactory(UserFactoryInterface $userFactory)
{
$this->userFactory = $userFactory;
}
/**
* Get the user factory to use.
*
* @return UserFactoryInterface
*
* @since 1.0.0
*/
public function getUserFactory(): UserFactoryInterface
{
return $this->userFactory;
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Application;
/**
* Application Session Message Aware Interface
*
* @since 1.0.0
*/
interface SessionMessageAwareInterface
{
const MSG_INFO = 'info';
/**
* Enqueue a system message.
*
* @param string $msg The message to enqueue.
* @param string $type The message type. Default is message.
*
* @return void
*
* @since 3.2
*/
public function enqueueMessage(string $msg, string $type = self::MSG_INFO);
/**
* Get the system message queue.
*
* @param boolean $clear Clear the messages currently attached to the application object
*
* @return array The system message queue.
*
* @since 3.2
*/
public function getMessageQueue(bool $clear = false): array;
}

View File

@ -0,0 +1,88 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Application;
use Joomla\Filter\InputFilter as InputFilterAlias;
use Octoleo\CMS\Filter\InputFilter;
/**
* Trait for application classes which are identity (user) aware
*
* @since 1.0.0
*/
trait SessionMessageAwareTrait
{
/**
* Enqueue a system message.
*
* @param string $msg The message to enqueue.
* @param string $type The message type. Default is message.
*
* @return void
*
* @since 1.0.0
*/
public function enqueueMessage(string $msg, string $type = self::MSG_INFO)
{
// Don't add empty messages.
if ($msg === null || trim($msg) === '')
{
return;
}
$inputFilter = InputFilter::getInstance(
[],
[],
InputFilterAlias::ONLY_BLOCK_DEFINED_TAGS,
InputFilterAlias::ONLY_BLOCK_DEFINED_ATTRIBUTES
);
// Build the message array and apply the HTML InputFilter with the default blacklist to the message
$message = array(
'message' => $inputFilter->clean($msg, 'html'),
'type' => $inputFilter->clean(strtolower($type), 'cmd'),
);
// For empty queue, if messages exists in the session, enqueue them first.
$messages = $this->getMessageQueue();
if (!\in_array($message, $messages))
{
// Enqueue the message.
$messages[] = $message;
// update the session
$this->getSession()->set('application.queue', $messages);
}
}
/**
* Get the system message queue.
*
* @param boolean $clear Clear the messages currently attached to the application object
*
* @return array The system message queue.
*
* @since 1.0.0
*/
public function getMessageQueue(bool $clear = false): array
{
// Get messages from Session
$sessionQueue = $this->getSession()->get('application.queue', []);
if ($clear)
{
$this->getSession()->set('application.queue', []);
}
return $sessionQueue;
}
}

View File

@ -0,0 +1,86 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Application;
use Joomla\Application\AbstractWebApplication;
use Joomla\Application\Controller\ControllerResolverInterface;
use Joomla\Application\Web\WebClient;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
use Joomla\Router\RouterInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Site application class
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/WebApplication.php
*/
class SiteApplication extends AbstractWebApplication
{
/**
* The application's controller resolver.
*
* @var ControllerResolverInterface
*/
protected $controllerResolver;
/**
* The application's router.
*
* @var RouterInterface
*/
protected $router;
/**
* Class constructor.
*
* @param ControllerResolverInterface $controllerResolver The application's controller resolver
* @param RouterInterface $router The application's router
* @param Input $input An optional argument to provide dependency injection for the application's
* input object.
* @param Registry $config An optional argument to provide dependency injection for the application's
* config object.
* @param WebClient $client An optional argument to provide dependency injection for the application's
* client object.
* @param ResponseInterface $response An optional argument to provide dependency injection for the application's
* response object.
*/
public function __construct(
ControllerResolverInterface $controllerResolver,
RouterInterface $router,
Input $input = null,
Registry $config = null,
WebClient $client = null,
ResponseInterface $response = null
)
{
$this->controllerResolver = $controllerResolver;
$this->router = $router;
// Call the constructor as late as possible (it runs `initialise`).
parent::__construct($input, $config, $client, $response);
}
/**
* Method to run the application routines.
*
* @return void
*/
protected function doExecute(): void
{
$route = $this->router->parseRoute($this->get('uri.route'), $this->input->getMethod());
// Add variables to the input if not already set
foreach ($route->getRouteVariables() as $key => $value)
{
$this->input->def($key, $value);
}
\call_user_func($this->controllerResolver->resolve($route));
}
}

View File

@ -0,0 +1,71 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Asset;
use Symfony\Component\Asset\Context\ContextInterface;
use Symfony\Component\Asset\Package;
use Symfony\Component\Asset\PathPackage;
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
/**
* Extended path package for resolving assets from a Laravel Mix manifest
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Asset/MixPathPackage.php
*/
class MixPathPackage extends PathPackage
{
/**
* Decorated Package instance
*
* @var Package
*/
private $decoratedPackage;
/**
* Constructor
*
* @param Package $decoratedPackage Decorated Package instance
* @param string $basePath The base path to be prepended to relative paths
* @param VersionStrategyInterface $versionStrategy The version strategy
* @param ContextInterface $context The context
*/
public function __construct(
Package $decoratedPackage,
string $basePath,
VersionStrategyInterface $versionStrategy,
ContextInterface $context = null
) {
parent::__construct($basePath, $versionStrategy, $context);
$this->decoratedPackage = $decoratedPackage;
}
/**
* Returns an absolute or root-relative public path.
*
* @param string $path A path
*
* @return string The public path
*/
public function getUrl($path)
{
if ($this->isAbsoluteUrl($path))
{
return $path;
}
$versionedPath = $this->getVersionStrategy()->applyVersion("/$path");
if ($versionedPath === $path)
{
return $this->decoratedPackage->getUrl($path);
}
return $this->getBasePath() . ltrim($versionedPath, '/');
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Autoload;
\defined('_LEXEC') or die;
use Composer\Autoload\ClassLoader as ComposerClassLoader;
/**
* Decorate Composer ClassLoader for Octoleo!
*
* For backward compatibility due to class aliasing in the CMS, the loadClass() method was modified to call
* the LLoader::applyAliasFor() method.
*
* @since 3.4
*/
class ClassLoader
{
/**
* The Composer class loader
*
* @var ComposerClassLoader
* @since 3.4
*/
private $loader;
/**
* Constructor
*
* @param ComposerClassLoader $loader Composer autoloader
*
* @since 3.4
*/
public function __construct(ComposerClassLoader $loader)
{
$this->loader = $loader;
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
*
* @return boolean|null True if loaded, null otherwise
*
* @since 3.4
*/
public function loadClass($class)
{
if ($result = $this->loader->loadClass($class))
{
\LLoader::applyAliasFor($class);
}
return $result;
}
}

View File

@ -0,0 +1,113 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Controller;
use Joomla\Application\AbstractApplication;
use Joomla\Controller\AbstractController;
use Joomla\Input\Input;
use Joomla\Uri\Uri;
use Laminas\Diactoros\Response\RedirectResponse;
use Octoleo\CMS\View\Admin\DashboardHtmlView;
use Laminas\Diactoros\Response\HtmlResponse;
/**
* Controller handling the site's homepage
*
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
*/
class DashboardController extends AbstractController
{
/**
* The view object.
*
* @var DashboardHtmlView
*/
private $view;
/**
* Constructor.
*
* @param DashboardHtmlView $view The view object.
* @param Input $user The user object.
* @param Input $input The input object.
* @param AbstractApplication $app The application object.
*/
public function __construct(DashboardHtmlView $view, Input $input = null, AbstractApplication $app = null)
{
parent::__construct($input, $app);
$this->view = $view;
}
/**
* Execute the controller.
*
* @return boolean
* @throws \Exception
*/
public function execute(): bool
{
// our little access controller TODO: we can do better
$has_access = false;
// Enable browser caching
$this->getApplication()->allowCache(true);
$dashboard = $this->getInput()->getString('dashboard', '');
$id = $this->getInput()->getInt('id', 0);
$this->view->setActiveDashboard($dashboard);
$this->view->setActiveId($id);
/** @var \Octoleo\CMS\User\UserFactory $userFactory */
$userFactory = $this->getApplication()->getUserFactory();
// user actions [access, signup]
if ('access' === $dashboard || 'signup' === $dashboard || 'logout' === $dashboard)
{
if ('access' === $dashboard && $userFactory->login())
{
$has_access = true;
}
elseif ('signup' === $dashboard && $userFactory->create())
{
$has_access = true;
}
elseif ('logout' === $dashboard && $userFactory->logout())
{
$has_access = false;
}
// we by default always load the dashboard
$this->view->setActiveDashboard('dashboard');
}
elseif ($userFactory->active())
{
$has_access = true;
}
if ($has_access)
{
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
}
else
{
// get uri request to get host
$uri = new Uri($this->getApplication()->get('uri.request'));
// Redirect to the administrator area
$this->getApplication()->redirect($uri->getScheme() . '://' . $uri->getHost() . '/administrator/');
}
return true;
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Controller;
use Joomla\Application\AbstractApplication;
use Joomla\Controller\AbstractController;
use Joomla\Input\Input;
use Joomla\Renderer\RendererInterface;
use Laminas\Diactoros\Response\HtmlResponse;
/**
* Controller handling the site's homepage
*
* @method \Octoleo\CMS\Application\SiteApplication getApplication() Get the application object.
* @property-read \Octoleo\CMS\Application\SiteApplication $app Application object
*/
class HomepageController extends AbstractController
{
/**
* The template renderer.
*
* @var RendererInterface
*/
private $renderer;
/**
* Constructor.
*
* @param RendererInterface $renderer The template renderer.
* @param Input $input The input object.
* @param AbstractApplication $app The application object.
*/
public function __construct(RendererInterface $renderer, Input $input = null, AbstractApplication $app = null)
{
parent::__construct($input, $app);
$this->renderer = $renderer;
}
/**
* Execute the controller.
*
* @return boolean
*/
public function execute(): bool
{
// Enable browser caching
$this->getApplication()->allowCache(true);
$this->getApplication()->setResponse(new HtmlResponse($this->renderer->render('homepage.twig')));
return true;
}
}

View File

@ -0,0 +1,71 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Controller;
use Joomla\Application\AbstractApplication;
use Joomla\Controller\AbstractController;
use Joomla\Input\Input;
use Joomla\Renderer\RendererInterface;
use Laminas\Diactoros\Response\HtmlResponse;
/**
* Controller handling the site's homepage
*
* @method \Octoleo\CMS\Application\SiteApplication getApplication() Get the application object.
* @property-read \Octoleo\CMS\Application\SiteApplication $app Application object
*/
class LoginController extends AbstractController
{
/**
* The template renderer.
*
* @var RendererInterface
*/
private $renderer;
/**
* Constructor.
*
* @param RendererInterface $renderer The template renderer.
* @param Input $input The input object.
* @param AbstractApplication $app The application object.
*/
public function __construct(RendererInterface $renderer, Input $input = null, AbstractApplication $app = null)
{
parent::__construct($input, $app);
$this->renderer = $renderer;
}
/**
* Execute the controller.
*
* @return boolean
*/
public function execute(): bool
{
// Enable browser caching
$this->getApplication()->allowCache(true);
$task = $this->getInput()->getString('account', null);
if ('signup' === $task)
{
$this->getApplication()->setResponse(new HtmlResponse($this->renderer->render('signup.twig')));
}
else
{
$this->getApplication()->setResponse(new HtmlResponse($this->renderer->render('login.twig')));
}
return true;
}
}

View File

@ -0,0 +1,82 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Controller;
use Joomla\Application\AbstractApplication;
use Joomla\Controller\AbstractController;
use Joomla\Input\Input;
use Joomla\Uri\Uri;
use Octoleo\CMS\View\Page\PageHtmlView;
use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\RedirectResponse;
/**
* Controller handling the site's simple text pages
*
* @method \Octoleo\CMS\Application\SiteApplication getApplication() Get the application object.
* @property-read \Octoleo\CMS\Application\SiteApplication $app Application object
*/
class PageController extends AbstractController
{
/**
* The view object.
*
* @var PageHtmlView
*/
private $view;
/**
* Constructor.
*
* @param PageHtmlView $view The view object.
* @param Input $input The input object.
* @param AbstractApplication $app The application object.
*/
public function __construct(PageHtmlView $view, Input $input = null, AbstractApplication $app = null)
{
parent::__construct($input, $app);
$this->view = $view;
}
/**
* Execute the controller.
*
* @return boolean
*/
public function execute(): bool
{
// Enable browser caching
$this->getApplication()->allowCache(true);
$page = $this->getInput()->getString('view', '');
$details = $this->getInput()->getString('details', '');
// if for some reason the view value is administrator
if ('administrator' === $page)
{
// get uri request to get host
$uri = new Uri($this->getApplication()->get('uri.request'));
// Redirect to the administrator area
$this->getApplication()->setResponse(new RedirectResponse($uri->getScheme() . '://' . $uri->getHost() . '/administrator/', 301));
}
else
{
$this->view->setPage($page);
$this->view->setDetails($details);
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
}
return true;
}
}

View File

@ -0,0 +1,40 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Controller;
use Joomla\Controller\AbstractController;
use Laminas\Diactoros\Response\TextResponse;
/**
* Controller class to display a message to individuals looking for the wrong CMS
*
* @method \Octoleo\CMS\Application\SiteApplication getApplication() Get the application object.
* @property-read \Octoleo\CMS\Application\SiteApplication $app Application object
*/
class WrongCmsController extends AbstractController
{
/**
* Execute the controller.
*
* @return boolean
*/
public function execute(): bool
{
// Enable browser caching
$this->getApplication()->allowCache(true);
$response = new TextResponse("This isn't the CMS you're looking for.", 404);
$this->getApplication()->setResponse($response);
return true;
}
}

View File

@ -0,0 +1,484 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Date;
use Joomla\Database\DatabaseInterface;
use Octoleo\CMS\Factory;
/**
* Date is a class that stores a date and provides logic to manipulate
* and render that date in a variety of formats.
*
* @method Date|bool add(\DateInterval $interval) Adds an amount of days, months, years, hours, minutes and seconds to a Date object.
* @method Date|bool sub(\DateInterval $interval) Subtracts an amount of days, months, years, hours, minutes and seconds from a Date object.
* @method Date|bool modify(string $modify) Alter the timestamp of this object by incre/decre-menting in a format accepted by strtotime().
*
* @property-read string $daysinmonth t - Number of days in the given month.
* @property-read string $dayofweek N - ISO-8601 numeric representation of the day of the week.
* @property-read string $dayofyear z - The day of the year (starting from 0).
* @property-read boolean $isleapyear L - Whether it's a leap year.
* @property-read string $day d - Day of the month, 2 digits with leading zeros.
* @property-read string $hour H - 24-hour format of an hour with leading zeros.
* @property-read string $minute i - Minutes with leading zeros.
* @property-read string $second s - Seconds with leading zeros.
* @property-read string $microsecond u - Microseconds with leading zeros.
* @property-read string $month m - Numeric representation of a month, with leading zeros.
* @property-read string $ordinal S - English ordinal suffix for the day of the month, 2 characters.
* @property-read string $week W - ISO-8601 week number of year, weeks starting on Monday.
* @property-read string $year Y - A full numeric representation of a year, 4 digits.
*
* @since 1.7.0
*/
class Date extends \DateTime
{
const DAY_ABBR = "\x021\x03";
const DAY_NAME = "\x022\x03";
const MONTH_ABBR = "\x023\x03";
const MONTH_NAME = "\x024\x03";
/**
* The format string to be applied when using the __toString() magic method.
*
* @var string
* @since 1.7.0
*/
public static $format = 'Y-m-d H:i:s';
/**
* Placeholder for a \DateTimeZone object with GMT as the time zone.
*
* @var object
* @since 1.7.0
*
* @deprecated 5.0 Without replacement
*/
protected static $gmt;
/**
* Placeholder for a \DateTimeZone object with the default server
* time zone as the time zone.
*
* @var object
* @since 1.7.0
*
* @deprecated 5.0 Without replacement
*/
protected static $stz;
/**
* The \DateTimeZone object for usage in rending dates as strings.
*
* @var \DateTimeZone
* @since 3.0.0
*/
protected $tz;
/**
* Constructor.
*
* @param string $date String in a format accepted by strtotime(), defaults to "now".
* @param mixed $tz Time zone to be used for the date. Might be a string or a DateTimeZone object.
*
* @since 1.7.0
*/
public function __construct($date = 'now', $tz = null)
{
// Create the base GMT and server time zone objects.
if (empty(self::$gmt) || empty(self::$stz))
{
// @TODO: This code block stays here only for B/C, can be removed in 5.0
self::$gmt = new \DateTimeZone('GMT');
self::$stz = new \DateTimeZone(@date_default_timezone_get());
}
// If the time zone object is not set, attempt to build it.
if (!($tz instanceof \DateTimeZone))
{
if (\is_string($tz))
{
$tz = new \DateTimeZone($tz);
}
else
{
$tz = new \DateTimeZone('UTC');
}
}
// Backup active time zone
$activeTZ = date_default_timezone_get();
// Force UTC timezone for correct time handling
date_default_timezone_set('UTC');
// If the date is numeric assume a unix timestamp and convert it.
$date = is_numeric($date) ? date('c', $date) : $date;
// Call the DateTime constructor.
parent::__construct($date, $tz);
// Restore previously active timezone
date_default_timezone_set($activeTZ);
// Set the timezone object for access later.
$this->tz = $tz;
}
/**
* Magic method to access properties of the date given by class to the format method.
*
* @param string $name The name of the property.
*
* @return mixed A value if the property name is valid, null otherwise.
*
* @since 1.7.0
*/
public function __get($name)
{
$value = null;
switch ($name)
{
case 'daysinmonth':
$value = $this->format('t', true);
break;
case 'dayofweek':
$value = $this->format('N', true);
break;
case 'dayofyear':
$value = $this->format('z', true);
break;
case 'isleapyear':
$value = (boolean) $this->format('L', true);
break;
case 'day':
$value = $this->format('d', true);
break;
case 'hour':
$value = $this->format('H', true);
break;
case 'minute':
$value = $this->format('i', true);
break;
case 'second':
$value = $this->format('s', true);
break;
case 'month':
$value = $this->format('m', true);
break;
case 'ordinal':
$value = $this->format('S', true);
break;
case 'week':
$value = $this->format('W', true);
break;
case 'year':
$value = $this->format('Y', true);
break;
default:
$trace = debug_backtrace();
trigger_error(
'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'],
E_USER_NOTICE
);
}
return $value;
}
/**
* Magic method to render the date object in the format specified in the public
* static member Date::$format.
*
* @return string The date as a formatted string.
*
* @since 1.7.0
*/
public function __toString()
{
return (string) parent::format(self::$format);
}
/**
* Proxy for new Date().
*
* @param string $date String in a format accepted by strtotime(), defaults to "now".
* @param mixed $tz Time zone to be used for the date.
*
* @return Date
*
* @since 1.7.3
*/
public static function getInstance($date = 'now', $tz = null)
{
return new static($date, $tz);
}
/**
* Translates day of week number to a string.
*
* @param integer $day The numeric day of the week.
* @param boolean $abbr Return the abbreviated day string?
*
* @return string The day of the week.
*
* @since 1.7.0
*/
public function dayToString($day, $abbr = false)
{
switch ($day)
{
case 0:
return $abbr ? 'Sun' : 'Sunday';
case 1:
return $abbr ? 'Mon' : 'Monday';
case 2:
return $abbr ? 'Tue' : 'Tuesday';
case 3:
return $abbr ? 'Wed' : 'Wednesday';
case 4:
return $abbr ? 'Thu' : 'Thursday';
case 5:
return $abbr ? 'Fri' : 'Friday';
case 6:
return $abbr ? 'Sat' : 'Saturday';
}
}
/**
* Gets the date as a formatted string in a local calendar.
*
* @param string $format The date format specification string (see {@link PHP_MANUAL#date})
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
* @param boolean $translate True to translate localised strings
*
* @return string The date string in the specified format format.
*
* @since 1.7.0
*/
public function calendar($format, $local = false, $translate = true)
{
return $this->format($format, $local, $translate);
}
/**
* Gets the date as a formatted string.
*
* @param string $format The date format specification string (see {@link PHP_MANUAL#date})
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
* @param boolean $translate True to translate localised strings
*
* @return string The date string in the specified format format.
*
* @since 1.7.0
*/
#[\ReturnTypeWillChange]
public function format($format, $local = false, $translate = true)
{
if ($translate)
{
// Do string replacements for date format options that can be translated.
$format = preg_replace('/(^|[^\\\])D/', "\\1" . self::DAY_ABBR, $format);
$format = preg_replace('/(^|[^\\\])l/', "\\1" . self::DAY_NAME, $format);
$format = preg_replace('/(^|[^\\\])M/', "\\1" . self::MONTH_ABBR, $format);
$format = preg_replace('/(^|[^\\\])F/', "\\1" . self::MONTH_NAME, $format);
}
// If the returned time should not be local use UTC.
if ($local == false)
{
parent::setTimezone(new \DateTimeZone('UTC'));
}
// Format the date.
$return = parent::format($format);
if ($translate)
{
// Manually modify the month and day strings in the formatted time.
if (strpos($return, self::DAY_ABBR) !== false)
{
$return = str_replace(self::DAY_ABBR, $this->dayToString(parent::format('w'), true), $return);
}
if (strpos($return, self::DAY_NAME) !== false)
{
$return = str_replace(self::DAY_NAME, $this->dayToString(parent::format('w')), $return);
}
if (strpos($return, self::MONTH_ABBR) !== false)
{
$return = str_replace(self::MONTH_ABBR, $this->monthToString(parent::format('n'), true), $return);
}
if (strpos($return, self::MONTH_NAME) !== false)
{
$return = str_replace(self::MONTH_NAME, $this->monthToString(parent::format('n')), $return);
}
}
if ($local == false && $this->tz !== null)
{
parent::setTimezone($this->tz);
}
return $return;
}
/**
* Get the time offset from GMT in hours or seconds.
*
* @param boolean $hours True to return the value in hours.
*
* @return float The time offset from GMT either in hours or in seconds.
*
* @since 1.7.0
*/
public function getOffsetFromGmt($hours = false)
{
return (float) $hours ? ($this->tz->getOffset($this) / 3600) : $this->tz->getOffset($this);
}
/**
* Translates month number to a string.
*
* @param integer $month The numeric month of the year.
* @param boolean $abbr If true, return the abbreviated month string
*
* @return string The month of the year.
*
* @since 1.7.0
*/
public function monthToString($month, $abbr = false)
{
switch ($month)
{
case 1:
return $abbr ? 'Jan' : 'January'; //
case 2:
return $abbr ? 'Feb' : 'February';
case 3:
return $abbr ? 'Mar' : 'March';
case 4:
return $abbr ? 'Apr' : 'April';
case 5:
return 'May';
case 6:
return $abbr ? 'Jun' : 'June';
case 7:
return $abbr ? 'Jul' : 'July';
case 8:
return $abbr ? 'Aug' : 'August';
case 9:
return $abbr ? 'Sep' : 'September';
case 10:
return $abbr ? 'Oct' : 'October';
case 11:
return $abbr ? 'Nov' : 'November';
case 12:
return $abbr ? 'Dec' : 'December';
}
}
/**
* Method to wrap the setTimezone() function and set the internal time zone object.
*
* @param \DateTimeZone $tz The new \DateTimeZone object.
*
* @return Date
*
* @since 1.7.0
* @note This method can't be type hinted due to a PHP bug: https://bugs.php.net/bug.php?id=61483
*/
#[\ReturnTypeWillChange]
public function setTimezone($tz)
{
$this->tz = $tz;
return parent::setTimezone($tz);
}
/**
* Gets the date as an ISO 8601 string. IETF RFC 3339 defines the ISO 8601 format
* and it can be found at the IETF Web site.
*
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
*
* @return string The date string in ISO 8601 format.
*
* @link http://www.ietf.org/rfc/rfc3339.txt
* @since 1.7.0
*/
public function toISO8601($local = false)
{
return $this->format(\DateTimeInterface::RFC3339, $local, false);
}
/**
* Gets the date as an SQL datetime string.
*
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
* @param DatabaseInterface $db The database driver or null to use Factory::getDbo()
*
* @return string The date string in SQL datetime format.
*
* @throws \Exception
* @since 2.5.0
* @link http://dev.mysql.com/doc/refman/5.0/en/datetime.html
*/
public function toSql($local = false, DatabaseInterface $db = null)
{
if ($db === null)
{
/** @var \Joomla\Database\DatabaseInterface $db */
$db = Factory::getContainer()->get(DatabaseInterface::class);
}
return $this->format($db->getDateFormat(), $local, false);
}
/**
* Gets the date as an RFC 822 string. IETF RFC 2822 supercedes RFC 822 and its definition
* can be found at the IETF Web site.
*
* @param boolean $local True to return the date string in the local time zone, false to return it in GMT.
*
* @return string The date string in RFC 822 format.
*
* @link http://www.ietf.org/rfc/rfc2822.txt
* @since 1.7.0
*/
public function toRFC822($local = false)
{
return $this->format(\DateTimeInterface::RFC2822, $local, false);
}
/**
* Gets the date as UNIX time stamp.
*
* @return integer The date as a UNIX timestamp.
*
* @since 1.7.0
*/
public function toUnix()
{
return (int) parent::format('U');
}
}

View File

@ -0,0 +1,195 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\EventListener;
use Joomla\Application\ApplicationEvents;
use Joomla\Application\Event\ApplicationErrorEvent;
use Joomla\Console\ConsoleEvents;
use Joomla\Console\Event\ApplicationErrorEvent as ConsoleApplicationErrorEvent;
use Joomla\Event\SubscriberInterface;
use Octoleo\CMS\Application\SiteApplication;
use Joomla\Renderer\RendererInterface;
use Joomla\Router\Exception\MethodNotAllowedException;
use Joomla\Router\Exception\RouteNotFoundException;
use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
/**
* Error handling event subscriber
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/EventListener/ErrorSubscriber.php
*/
class ErrorSubscriber implements SubscriberInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* Layout renderer
*
* @var RendererInterface
*/
private $renderer;
/**
* Event subscriber constructor.
*
* @param RendererInterface $renderer Layout renderer
*/
public function __construct(RendererInterface $renderer)
{
$this->renderer = $renderer;
}
/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
ApplicationEvents::ERROR => 'handleWebError',
ConsoleEvents::APPLICATION_ERROR => 'handleConsoleError',
];
}
/**
* Handle console application errors.
*
* @param ConsoleApplicationErrorEvent $event Event object
*
* @return void
*/
public function handleConsoleError(ConsoleApplicationErrorEvent $event): void
{
$this->logError($event->getError());
}
/**
* Handle web application errors.
*
* @param ApplicationErrorEvent $event Event object
*
* @return void
*/
public function handleWebError(ApplicationErrorEvent $event): void
{
/** @var SiteApplication $app */
$app = $event->getApplication();
switch (true)
{
case $event->getError() instanceof MethodNotAllowedException :
// Log the error for reference
$this->logger->error(
sprintf('Route `%s` not supported by method `%s`', $app->get('uri.route'), $app->input->getMethod()),
['exception' => $event->getError()]
);
$this->prepareResponse($event);
$app->setHeader('Allow', implode(', ', $event->getError()->getAllowedMethods()));
break;
case $event->getError() instanceof RouteNotFoundException :
// Log the error for reference
$this->logger->error(
sprintf('Route `%s` not found', $app->get('uri.route')),
['exception' => $event->getError()]
);
$this->prepareResponse($event);
break;
default:
$this->logError($event->getError());
$this->prepareResponse($event);
break;
}
}
/**
* Log the error.
*
* @param \Throwable $throwable The error being processed
*
* @return void
*/
private function logError(\Throwable $throwable): void
{
$this->logger->error(
sprintf('Uncaught Throwable of type %s caught.', \get_class($throwable)),
['exception' => $throwable]
);
}
/**
* Prepare the response for the event
*
* @param ApplicationErrorEvent $event Event object
*
* @return void
*/
private function prepareResponse(ApplicationErrorEvent $event): void
{
/** @var SiteApplication $app */
$app = $event->getApplication();
$app->allowCache(false);
switch (true)
{
case $app->input->getString('_format', 'html') === 'json' :
case $app->mimeType === 'application/json' :
case $app->getResponse() instanceof JsonResponse :
$data = [
'code' => $event->getError()->getCode(),
'message' => $event->getError()->getMessage(),
'error' => true,
];
$response = new JsonResponse($data);
break;
default :
$response = new HtmlResponse(
$this->renderer->render('exception.twig', ['exception' => $event->getError()])
);
break;
}
switch ($event->getError()->getCode())
{
case 404 :
$response = $response->withStatus(404);
break;
case 405 :
$response = $response->withStatus(405);
break;
case 500 :
default :
$response = $response->withStatus(500);
break;
}
$app->setResponse($response);
}
}

View File

@ -0,0 +1,300 @@
<?php
/**
* @package Octoleo CMS
*
* @created 3rd April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS;
\defined('LPATH_PLATFORM') or die;
use Joomla\Application\WebApplicationInterface;
use Joomla\Database\Service\DatabaseProvider;
use Joomla\DI\Container;
use Joomla\Registry\Registry;
use PHPMailer\PHPMailer\Exception as phpmailerException;
/**
* Octoleo Platform Factory class.
*
* @since 1.0.0
*
* SOURCE: https://github.com/joomla/joomla-cms/blob/4.1-dev/libraries/src/Factory.php#L39
*/
abstract class Factory
{
/**
* Global application object
*
* @var WebApplicationInterface
* @since 1.0.0
*/
public static $application = null;
/**
* Global configuration object
*
* @var \LConfig
* @since 1.0.0
*/
public static $config = null;
/**
* Global container object
*
* @var Container
* @since 1.0.0
*/
public static $container = null;
/**
* Global mailer object
*
* @var Mail
* @since 1.0.0
*/
public static $mailer = null;
/**
* Get the global application object. When the global application doesn't exist, an exception is thrown.
*
* @return WebApplicationInterface object
*
* @since 1.0.0
* @throws \Exception
*/
public static function getApplication() : WebApplicationInterface
{
if (!self::$application)
{
throw new \Exception('Failed to start application', 500);
}
return self::$application;
}
/**
* Get a container object
*
* Returns the global service container object, only creating it if it doesn't already exist.
*
* This method is only suggested for use in code whose responsibility is to create new services
* and needs to be able to resolve the dependencies, and should therefore only be used when the
* container is not accessible by other means. Valid uses of this method include:
*
* - A static `getInstance()` method calling a factory service from the container,
* see `Joomla\CMS\Toolbar\Toolbar::getInstance()` as an example
* - An application front controller loading and executing the Joomla application class,
* see the `cli/joomla.php` file as an example
* - Retrieving optional constructor dependencies when not injected into a class during a transitional
* period to retain backward compatibility, in this case a deprecation notice should also be emitted to
* notify developers of changes needed in their code
*
* This method is not suggested for use as a one-for-one replacement of static calls, such as
* replacing calls to `Factory::getDbo()` with calls to `Factory::getContainer()->get('db')`, code
* should be refactored to support dependency injection instead of making this change.
*
* @return Container
*
* @since 4.0.0
*/
public static function getContainer(): Container
{
if (!self::$container)
{
self::$container = self::createContainer();
}
return self::$container;
}
/**
* Get a mailer object.
*
* Returns the global {@link Mail} object, only creating it if it doesn't already exist.
*
* @return Mail object
*
* @see Mail
* @since 1.7.0
*/
public static function getMailer()
{
if (!self::$mailer)
{
self::$mailer = self::createMailer();
}
$copy = clone self::$mailer;
return $copy;
}
/**
* Create a container object
*
* @return Container
*
* @since 4.0.0
*/
protected static function createContainer(): Container
{
return (new Container)
->registerServiceProvider(new Service\ConfigurationProvider(LPATH_CONFIGURATION . '/octoconfig.php'))
->registerServiceProvider(new Service\SessionProvider)
->registerServiceProvider(new Service\UserProvider)
->registerServiceProvider(new DatabaseProvider)
->registerServiceProvider(new Service\EventProvider)
->registerServiceProvider(new Service\HttpProvider)
->registerServiceProvider(new Service\LoggingProvider);
}
/**
* Get a configuration object
*
* Returns the global {@link \JConfig} object, only creating it if it doesn't already exist.
*
* @param string $file The path to the configuration file
* @param string $type The type of the configuration file
* @param string $namespace The namespace of the configuration file
*
* @return Registry
*
* @see Registry
* @since 1.1.1
*/
public static function getConfig($file = null, $type = 'PHP', $namespace = '')
{
/**
* If there is an application object, fetch the configuration from there.
* Check it's not null because LanguagesModel can make it null and if it's null
* we would want to re-init it from configuration.php.
*/
if (self::$application && self::$application->getConfig() !== null)
{
return self::$application->getConfig();
}
if (!self::$config)
{
if ($file === null)
{
$file = JPATH_CONFIGURATION . '/octoconfig.php';
}
self::$config = self::createConfig($file, $type, $namespace);
}
return self::$config;
}
/**
* Create a configuration object
*
* @param string $file The path to the configuration file.
* @param string $type The type of the configuration file.
* @param string $namespace The namespace of the configuration file.
*
* @return Registry
*
* @see Registry
* @since 1.0.0
*/
protected static function createConfig($file, $type = 'PHP', $namespace = '')
{
if (is_file($file))
{
include_once $file;
}
// Create the registry with a default namespace of config
$registry = new Registry;
// Sanitize the namespace.
$namespace = ucfirst((string) preg_replace('/[^A-Z_]/i', '', $namespace));
// Build the config name.
$name = 'LConfig' . $namespace;
// Handle the PHP configuration type.
if ($type === 'PHP' && class_exists($name))
{
// Create the LConfig object
$config = new $name;
// Load the configuration values into the registry
$registry->loadObject($config);
}
return $registry;
}
/**
* Create a mailer object
*
* @return Mail object
*
* @see Mail
* @since 1.0.0
*/
protected static function createMailer()
{
// $conf = self::getConfig();
//
// $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1;
// $smtpuser = $conf->get('smtpuser');
// $smtppass = $conf->get('smtppass');
// $smtphost = $conf->get('smtphost');
// $smtpsecure = $conf->get('smtpsecure');
// $smtpport = $conf->get('smtpport');
// $mailfrom = $conf->get('mailfrom');
// $fromname = $conf->get('fromname');
// $mailer = $conf->get('mailer');
//
// // Create a Mail object
// $mail = Mail::getInstance();
//
// // Clean the email address
// $mailfrom = MailHelper::cleanLine($mailfrom);
//
// // Set default sender without Reply-to if the mailfrom is a valid address
// if (MailHelper::isEmailAddress($mailfrom))
// {
// // Wrap in try/catch to catch phpmailerExceptions if it is throwing them
// try
// {
// // Check for a false return value if exception throwing is disabled
// if ($mail->setFrom($mailfrom, MailHelper::cleanLine($fromname), false) === false)
// {
// Log::add(__METHOD__ . '() could not set the sender data.', Log::WARNING, 'mail');
// }
// }
// catch (phpmailerException $e)
// {
// Log::add(__METHOD__ . '() could not set the sender data.', Log::WARNING, 'mail');
// }
// }
//
// // Default mailer is to use PHP's mail function
// switch ($mailer)
// {
// case 'smtp':
// $mail->useSmtp($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
// break;
//
// case 'sendmail':
// $mail->isSendmail();
// break;
//
// default:
// $mail->isMail();
// break;
// }
//
// return $mail;
}
}

View File

@ -0,0 +1,527 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Filter;
use Octoleo\CMS\String\PunycodeHelper;
use Joomla\Filter\InputFilter as BaseInputFilter;
/**
* InputFilter is a class for filtering input from any data source
*
* Forked from the php input filter library by: Daniel Morris <dan@rootcube.com>
* Original Contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie.
*
* @since 1.7.0
*/
class InputFilter extends BaseInputFilter
{
/**
* An array containing a list of extensions for files that are typically
* executable directly in the webserver context, potentially resulting in code executions
*
* @since 4.0.0
*/
public const FORBIDDEN_FILE_EXTENSIONS = [
'php', 'phps', 'pht', 'phtml', 'php3', 'php4', 'php5', 'php6', 'php7', 'asp',
'php8', 'phar', 'inc', 'pl', 'cgi', 'fcgi', 'java', 'jar', 'py', 'aspx'
];
/**
* A flag for Unicode Supplementary Characters (4-byte Unicode character) stripping.
*
* @var integer
* @since 3.5
*/
private $stripUSC = 0;
/**
* A container for InputFilter instances.
*
* @var InputFilter[]
* @since 4.0.0
*/
protected static $instances = array();
/**
* Constructor for inputFilter class. Only first parameter is required.
*
* @param array $tagsArray List of user-defined tags
* @param array $attrArray List of user-defined attributes
* @param integer $tagsMethod The constant static::ONLY_ALLOW_DEFINED_TAGS or static::BLOCK_DEFINED_TAGS
* @param integer $attrMethod The constant static::ONLY_ALLOW_DEFINED_ATTRIBUTES or static::BLOCK_DEFINED_ATTRIBUTES
* @param integer $xssAuto Only auto clean essentials = 0, Allow clean blocked tags/attributes = 1
* @param integer $stripUSC Strip 4-byte unicode characters = 1, no strip = 0
*
* @since 1.7.0
*/
public function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1, $stripUSC = 0)
{
parent::__construct($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto);
// Assign member variables
$this->stripUSC = $stripUSC;
}
/**
* Returns an input filter object, only creating it if it doesn't already exist.
*
* @param array $tagsArray List of user-defined tags
* @param array $attrArray List of user-defined attributes
* @param integer $tagsMethod The constant static::ONLY_ALLOW_DEFINED_TAGS or static::BLOCK_DEFINED_TAGS
* @param integer $attrMethod The constant static::ONLY_ALLOW_DEFINED_ATTRIBUTES or static::BLOCK_DEFINED_ATTRIBUTES
* @param integer $xssAuto Only auto clean essentials = 0, Allow clean blocked tags/attributes = 1
* @param integer $stripUSC Strip 4-byte unicode characters = 1, no strip = 0
*
* @return InputFilter The InputFilter object.
*
* @since 1.7.0
*/
public static function getInstance($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1, $stripUSC = 0)
{
$sig = md5(serialize(array($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto)));
if (empty(self::$instances[$sig]))
{
self::$instances[$sig] = new InputFilter($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto, $stripUSC);
}
return self::$instances[$sig];
}
/**
* Method to be called by another php script. Processes for XSS and
* specified bad code.
*
* @param mixed $source Input string/array-of-string to be 'cleaned'
* @param string $type The return type for the variable:
* INT: An integer, or an array of integers,
* UINT: An unsigned integer, or an array of unsigned integers,
* FLOAT: A floating point number, or an array of floating point numbers,
* BOOLEAN: A boolean value,
* WORD: A string containing A-Z or underscores only (not case sensitive),
* ALNUM: A string containing A-Z or 0-9 only (not case sensitive),
* CMD: A string containing A-Z, 0-9, underscores, periods or hyphens (not case sensitive),
* BASE64: A string containing A-Z, 0-9, forward slashes, plus or equals (not case sensitive),
* STRING: A fully decoded and sanitised string (default),
* HTML: A sanitised string,
* ARRAY: An array,
* PATH: A sanitised file path, or an array of sanitised file paths,
* TRIM: A string trimmed from normal, non-breaking and multibyte spaces
* USERNAME: Do not use (use an application specific filter),
* RAW: The raw string is returned with no filtering,
* unknown: An unknown filter will act like STRING. If the input is an array it will return an
* array of fully decoded and sanitised strings.
*
* @return mixed 'Cleaned' version of input parameter
*
* @since 1.7.0
*/
public function clean($source, $type = 'string')
{
// Strip Unicode Supplementary Characters when requested to do so
if ($this->stripUSC)
{
// Alternatively: preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xE2\xAF\x91", $source) but it'd be slower.
$source = $this->stripUSC($source);
}
return parent::clean($source, $type);
}
/**
* Function to punyencode utf8 mail when saving content
*
* @param string $text The strings to encode
*
* @return string The punyencoded mail
*
* @since 3.5
*/
public function emailToPunycode($text)
{
$pattern = '/(("mailto:)+[\w\.\-\+]+\@[^"?]+\.+[^."?]+("|\?))/';
if (preg_match_all($pattern, $text, $matches))
{
foreach ($matches[0] as $match)
{
$match = (string) str_replace(array('?', '"'), '', $match);
$text = (string) str_replace($match, PunycodeHelper::emailToPunycode($match), $text);
}
}
return $text;
}
/**
* Checks an uploaded for suspicious naming and potential PHP contents which could indicate a hacking attempt.
*
* The options you can define are:
* null_byte Prevent files with a null byte in their name (buffer overflow attack)
* forbidden_extensions Do not allow these strings anywhere in the file's extension
* php_tag_in_content Do not allow `<?php` tag in content
* phar_stub_in_content Do not allow the `__HALT_COMPILER()` phar stub in content
* shorttag_in_content Do not allow short tag `<?` in content
* shorttag_extensions Which file extensions to scan for short tags in content
* fobidden_ext_in_content Do not allow forbidden_extensions anywhere in content
* php_ext_content_extensions Which file extensions to scan for .php in content
*
* This code is an adaptation and improvement of Admin Tools' UploadShield feature,
* relicensed and contributed by its author.
*
* @param array $file An uploaded file descriptor
* @param array $options The scanner options (see the code for details)
*
* @return boolean True of the file is safe
*
* @since 3.4
*/
public static function isSafeFile($file, $options = array())
{
$defaultOptions = array(
// Null byte in file name
'null_byte' => true,
// Forbidden string in extension (e.g. php matched .php, .xxx.php, .php.xxx and so on)
'forbidden_extensions' => self::FORBIDDEN_FILE_EXTENSIONS,
// <?php tag in file contents
'php_tag_in_content' => true,
// <? tag in file contents
'shorttag_in_content' => true,
// __HALT_COMPILER()
'phar_stub_in_content' => true,
// Which file extensions to scan for short tags
'shorttag_extensions' => array(
'inc', 'phps', 'class', 'php3', 'php4', 'php5', 'php6', 'php7', 'php8', 'txt', 'dat', 'tpl', 'tmpl',
),
// Forbidden extensions anywhere in the content
'fobidden_ext_in_content' => true,
// Which file extensions to scan for .php in the content
'php_ext_content_extensions' => array('zip', 'rar', 'tar', 'gz', 'tgz', 'bz2', 'tbz', 'jpa'),
);
$options = array_merge($defaultOptions, $options);
// Make sure we can scan nested file descriptors
$descriptors = $file;
if (isset($file['name']) && isset($file['tmp_name']))
{
$descriptors = static::decodeFileData(
array(
$file['name'],
$file['type'],
$file['tmp_name'],
$file['error'],
$file['size'],
)
);
}
// Handle non-nested descriptors (single files)
if (isset($descriptors['name']))
{
$descriptors = array($descriptors);
}
// Scan all descriptors detected
foreach ($descriptors as $fileDescriptor)
{
if (!isset($fileDescriptor['name']))
{
// This is a nested descriptor. We have to recurse.
if (!static::isSafeFile($fileDescriptor, $options))
{
return false;
}
continue;
}
$tempNames = $fileDescriptor['tmp_name'];
$intendedNames = $fileDescriptor['name'];
if (!\is_array($tempNames))
{
$tempNames = array($tempNames);
}
if (!\is_array($intendedNames))
{
$intendedNames = array($intendedNames);
}
$len = \count($tempNames);
for ($i = 0; $i < $len; $i++)
{
$tempName = array_shift($tempNames);
$intendedName = array_shift($intendedNames);
// 1. Null byte check
if ($options['null_byte'])
{
if (strstr($intendedName, "\x00"))
{
return false;
}
}
// 2. PHP-in-extension check (.php, .php.xxx[.yyy[.zzz[...]]], .xxx[.yyy[.zzz[...]]].php)
if (!empty($options['forbidden_extensions']))
{
$explodedName = explode('.', $intendedName);
$explodedName = array_reverse($explodedName);
array_pop($explodedName);
$explodedName = array_map('strtolower', $explodedName);
/*
* DO NOT USE array_intersect HERE! array_intersect expects the two arrays to
* be set, i.e. they should have unique values.
*/
foreach ($options['forbidden_extensions'] as $ext)
{
if (\in_array($ext, $explodedName))
{
return false;
}
}
}
// 3. File contents scanner (PHP tag in file contents)
if ($options['php_tag_in_content']
|| $options['shorttag_in_content'] || $options['phar_stub_in_content']
|| ($options['fobidden_ext_in_content'] && !empty($options['forbidden_extensions'])))
{
$fp = strlen($tempName) ? @fopen($tempName, 'r') : false;
if ($fp !== false)
{
$data = '';
while (!feof($fp))
{
$data .= @fread($fp, 131072);
if ($options['php_tag_in_content'] && stripos($data, '<?php') !== false)
{
return false;
}
if ($options['phar_stub_in_content'] && stripos($data, '__HALT_COMPILER()') !== false)
{
return false;
}
if ($options['shorttag_in_content'])
{
$suspiciousExtensions = $options['shorttag_extensions'];
if (empty($suspiciousExtensions))
{
$suspiciousExtensions = array(
'inc', 'phps', 'class', 'php3', 'php4', 'txt', 'dat', 'tpl', 'tmpl',
);
}
/*
* DO NOT USE array_intersect HERE! array_intersect expects the two arrays to
* be set, i.e. they should have unique values.
*/
$collide = false;
foreach ($suspiciousExtensions as $ext)
{
if (\in_array($ext, $explodedName))
{
$collide = true;
break;
}
}
if ($collide)
{
// These are suspicious text files which may have the short tag (<?) in them
if (strstr($data, '<?'))
{
return false;
}
}
}
if ($options['fobidden_ext_in_content'] && !empty($options['forbidden_extensions']))
{
$suspiciousExtensions = $options['php_ext_content_extensions'];
if (empty($suspiciousExtensions))
{
$suspiciousExtensions = array(
'zip', 'rar', 'tar', 'gz', 'tgz', 'bz2', 'tbz', 'jpa',
);
}
/*
* DO NOT USE array_intersect HERE! array_intersect expects the two arrays to
* be set, i.e. they should have unique values.
*/
$collide = false;
foreach ($suspiciousExtensions as $ext)
{
if (\in_array($ext, $explodedName))
{
$collide = true;
break;
}
}
if ($collide)
{
/*
* These are suspicious text files which may have an executable
* file extension in them
*/
foreach ($options['forbidden_extensions'] as $ext)
{
if (strstr($data, '.' . $ext))
{
return false;
}
}
}
}
/*
* This makes sure that we don't accidentally skip a <?php tag if it's across
* a read boundary, even on multibyte strings
*/
$data = substr($data, -10);
}
fclose($fp);
}
}
}
}
return true;
}
/**
* Method to decode a file data array.
*
* @param array $data The data array to decode.
*
* @return array
*
* @since 3.4
*/
protected static function decodeFileData(array $data)
{
$result = array();
if (\is_array($data[0]))
{
foreach ($data[0] as $k => $v)
{
$result[$k] = static::decodeFileData(array($data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k]));
}
return $result;
}
return array('name' => $data[0], 'type' => $data[1], 'tmp_name' => $data[2], 'error' => $data[3], 'size' => $data[4]);
}
/**
* Try to convert to plaintext
*
* @param string $source The source string.
*
* @return string Plaintext string
*
* @since 3.5
*/
protected function decode($source)
{
static $ttr;
if (!\is_array($ttr))
{
// Entity decode
$trans_tbl = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT, 'ISO-8859-1');
foreach ($trans_tbl as $k => $v)
{
$ttr[$v] = utf8_encode($k);
}
}
$source = strtr($source, $ttr);
// Convert decimal
$source = preg_replace_callback(
'/&#(\d+);/m',
function ($m) {
return utf8_encode(\chr($m[1]));
},
$source
);
// Convert hex
$source = preg_replace_callback(
'/&#x([a-f0-9]+);/mi',
function ($m) {
return utf8_encode(\chr('0x' . $m[1]));
},
$source
);
return $source;
}
/**
* Recursively strip Unicode Supplementary Characters from the source. Not: objects cannot be filtered.
*
* @param mixed $source The data to filter
*
* @return mixed The filtered result
*
* @since 3.5
*/
protected function stripUSC($source)
{
if (\is_object($source))
{
return $source;
}
if (\is_array($source))
{
$filteredArray = array();
foreach ($source as $k => $v)
{
$filteredArray[$k] = $this->stripUSC($v);
}
return $filteredArray;
}
return preg_replace('/[\xF0-\xF7].../s', "\xE2\xAF\x91", $source);
}
}

View File

@ -0,0 +1,67 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Model;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\ParameterType;
use Joomla\Model\DatabaseModelInterface;
use Joomla\Model\DatabaseModelTrait;
/**
* Model class for pages
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Model/PackageModel.php
*/
class DashboardModel implements DatabaseModelInterface
{
use DatabaseModelTrait;
/**
* Array of legal dashboards
*
* @var array
*/
private $legalDashboards = [
'items' => 'items.twig',
'item' => 'edit.twig',
'menus' => 'menus.twig',
'menu' => 'edit.twig',
'users' => 'users.twig',
'user' => 'edit.twig'
];
/**
* Instantiate the model.
*
* @param DatabaseDriver $db The database adapter.
*/
public function __construct(DatabaseDriver $db)
{
$this->setDb($db);
}
/**
* Get a active dashboard template name
*
* @param string $dashboardName The dashboard to lookup
*
* @return string
*
*/
public function getDashboard(string $dashboardName): string
{
if (!isset($this->legalDashboards[$dashboardName]))
{
return 'dashboard.twig';
}
return $this->legalDashboards[$dashboardName];
}
}

View File

@ -0,0 +1,87 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Model;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\ParameterType;
use Joomla\Model\DatabaseModelInterface;
use Joomla\Model\DatabaseModelTrait;
/**
* Model class for pages
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Model/PackageModel.php
*/
class PageModel implements DatabaseModelInterface
{
use DatabaseModelTrait;
/**
* Array of legal pages
*
* @var array
*/
private $legalPages = ['products', 'blog', 'about-us', 'location', 'contact-us'];
/**
* Array of legal details pages
*
* @var array
*/
private $legalDetailsPages = ['yachts', 'ski-boats', 'drones'];
/**
* Instantiate the model.
*
* @param DatabaseDriver $db The database adapter.
*/
public function __construct(DatabaseDriver $db)
{
$this->setDb($db);
}
/**
* Get a page's data
*
* @param string $pageName The page to lookup
*
* @return string
*
* @throws \RuntimeException
*/
public function getPage(string $pageName): string
{
if (!in_array($pageName, $this->legalPages))
{
throw new \RuntimeException(sprintf('Unable to find page data for the `%s`', $pageName), 404);
}
return $pageName;
}
/**
* Get a page's details data
*
* @param string $detailsName The page details to lookup
*
* @return string
*
* @throws \RuntimeException
*/
public function getDetails(string $detailsName): string
{
if (strlen($detailsName) && !in_array($detailsName, $this->legalDetailsPages))
{
throw new \RuntimeException(sprintf('Unable to find page details data for the `%s`', $detailsName), 404);
}
return $detailsName;
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Renderer;
use Joomla\Application\AbstractApplication;
use Joomla\Application\AbstractWebApplication;
use Symfony\Component\Asset\Context\ContextInterface;
/**
* Joomla! application aware context
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Renderer/ApplicationContext.php
*/
class ApplicationContext implements ContextInterface
{
/**
* Application object
*
* @var AbstractApplication
*/
private $app;
/**
* Constructor
*
* @param AbstractApplication $app The application object
*/
public function __construct(AbstractApplication $app)
{
$this->app = $app;
}
/**
* Gets the base path.
*
* @return string The base path
*/
public function getBasePath()
{
return rtrim($this->app->get('uri.base.path'), '/');
}
/**
* Checks whether the request is secure or not.
*
* @return boolean
*/
public function isSecure()
{
if ($this->app instanceof AbstractWebApplication)
{
return $this->app->isSslConnection();
}
return false;
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Renderer;
use Symfony\Component\Asset\Packages;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
/**
* Framework site's Twig extension class
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Renderer/FrameworkExtension.php
*/
class FrameworkExtension extends AbstractExtension
{
/**
* Returns a list of filters to add to the existing list
*
* @return TwigFilter[] An array of TwigFilter instances
*/
public function getFilters()
{
return [
new TwigFilter('get_class', 'get_class'),
new TwigFilter('strip_root_path', [$this, 'stripRootPath']),
];
}
/**
* Returns a list of functions to add to the existing list.
*
* @return TwigFunction[] An array of TwigFunction instances
*/
public function getFunctions()
{
return [
new TwigFunction('asset', [Packages::class, 'getUrl']),
new TwigFunction('preload', [FrameworkTwigRuntime::class, 'preloadAsset']),
new TwigFunction('request_uri', [FrameworkTwigRuntime::class, 'getRequestUri']),
new TwigFunction('route', [FrameworkTwigRuntime::class, 'getRouteUri']),
new TwigFunction('sri', [FrameworkTwigRuntime::class, 'getSriAttributes'], ['is_safe' => ['html']]),
new TwigFunction('url', [FrameworkTwigRuntime::class, 'getRouteUrl']),
];
}
/**
* Removes the application root path defined by the constant "JPATH_ROOT"
*
* @param string $string The string to process
*
* @return string
*/
public function stripRootPath(string $string): string
{
return str_replace(JPATH_ROOT . DIRECTORY_SEPARATOR, '', $string);
}
}

View File

@ -0,0 +1,161 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Renderer;
use Joomla\Application\AbstractApplication;
use Joomla\Preload\PreloadManager;
/**
* Twig runtime class
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Renderer/FrameworkTwigRuntime.php
*/
class FrameworkTwigRuntime
{
/**
* Application object
*
* @var AbstractApplication
*/
private $app;
/**
* The HTTP/2 preload manager
*
* @var PreloadManager
*/
private $preloadManager;
/**
* The SRI manifest data
*
* @var array|null
*/
private $sriManifestData;
/**
* The path to the SRI manifest data
*
* @var string
*/
private $sriManifestPath;
/**
* Constructor
*
* @param AbstractApplication $app The application object
* @param PreloadManager $preloadManager The HTTP/2 preload manager
* @param string $sriManifestPath The path to the SRI manifest data
*/
public function __construct(AbstractApplication $app, PreloadManager $preloadManager, string $sriManifestPath)
{
$this->app = $app;
$this->preloadManager = $preloadManager;
$this->sriManifestPath = $sriManifestPath;
}
/**
* Retrieves the current URI
*
* @return string
*/
public function getRequestUri(): string
{
return $this->app->get('uri.request');
}
/**
* Get the URI for a route
*
* @param string $route Route to get the path for
*
* @return string
*/
public function getRouteUri(string $route = ''): string
{
return $this->app->get('uri.base.path') . $route;
}
/**
* Get the full URL for a route
*
* @param string $route Route to get the URL for
*
* @return string
*/
public function getRouteUrl(string $route = ''): string
{
return $this->app->get('uri.base.host') . $this->getRouteUri($route);
}
/**
* Get the SRI attributes for an asset
*
* @param string $path A public path
*
* @return string
*/
public function getSriAttributes(string $path): string
{
if ($this->sriManifestData === null)
{
if (!file_exists($this->sriManifestPath))
{
throw new \RuntimeException(sprintf('SRI manifest file "%s" does not exist.', $this->sriManifestPath));
}
$sriManifestContents = file_get_contents($this->sriManifestPath);
if ($sriManifestContents === false)
{
throw new \RuntimeException(sprintf('Could not read SRI manifest file "%s".', $this->sriManifestPath));
}
$this->sriManifestData = json_decode($sriManifestContents, true);
if (0 < json_last_error())
{
throw new \RuntimeException(sprintf('Error parsing JSON from SRI manifest file "%s" - %s', $this->sriManifestPath, json_last_error_msg()));
}
}
$assetKey = "/$path";
if (!isset($this->sriManifestData[$assetKey]))
{
return '';
}
$attributes = '';
foreach ($this->sriManifestData[$assetKey] as $key => $value)
{
$attributes .= ' ' . $key . '="' . $value . '"';
}
return $attributes;
}
/**
* Preload a resource
*
* @param string $uri The URI for the resource to preload
* @param string $linkType The preload method to apply
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
*
* @return string
*
* @throws \InvalidArgumentException
*/
public function preloadAsset(string $uri, string $linkType = 'preload', array $attributes = []): string
{
$this->preloadManager->link($uri, $linkType, $attributes);
return $uri;
}
}

View File

@ -0,0 +1,270 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Service;
use Joomla\Application\AbstractWebApplication;
use Joomla\Application\Controller\ContainerControllerResolver;
use Joomla\Application\Controller\ControllerResolverInterface;
use Joomla\Application\Web\WebClient;
use Joomla\Database\DatabaseInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Session\SessionInterface;
use Octoleo\CMS\Controller\DashboardController;
use Octoleo\CMS\Controller\LoginController;
use Octoleo\CMS\Controller\WrongCmsController;
use Octoleo\CMS\Model\DashboardModel;
use Octoleo\CMS\User\UserFactoryInterface;
use Octoleo\CMS\View\Admin\DashboardHtmlView;
use Octoleo\CMS\Application\AdminApplication;
use Joomla\Input\Input;
use Joomla\Renderer\RendererInterface;
use Joomla\Router\Router;
use Joomla\Router\RouterInterface;
use Psr\Log\LoggerInterface;
/**
* Application service provider
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Service/ApplicationProvider.php
*/
class AdminApplicationProvider implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*/
public function register(Container $container): void
{
/*
* Application Classes
*/
// This service cannot be protected as it is decorated when the debug bar is available
$container->alias(AdminApplication::class, AbstractWebApplication::class)
->share(AbstractWebApplication::class, [$this, 'getAdminApplicationClassService']);
/*
* Application Helpers and Dependencies
*/
// This service cannot be protected as it is decorated when the debug bar is available
$container->alias(ContainerControllerResolver::class, ControllerResolverInterface::class)
->share(ControllerResolverInterface::class, [$this, 'getControllerResolverService']);
$container->share(WebClient::class, [$this, 'getWebClientService'], true);
// This service cannot be protected as it is decorated when the debug bar is available
$container->alias(RouterInterface::class, 'application.router')
->alias(Router::class, 'application.router')
->share('application.router', [$this, 'getApplicationRouterService']);
$container->share(Input::class, [$this, 'getInputClassService'], true);
/*
* MVC Layer
*/
// Controllers
$container->alias(DashboardController::class, 'controller.dashboard')
->share('controller.dashboard', [$this, 'getControllerDashboardService'], true);
$container->alias(LoginController::class, 'controller.login')
->share('controller.login', [$this, 'getControllerLoginService'], true);
$container->alias(WrongCmsController::class, 'controller.wrong.cms')
->share('controller.wrong.cms', [$this, 'getControllerWrongCmsService'], true);
// Models
$container->alias(DashboardModel::class, 'model.dashboard')
->share('model.dashboard', [$this, 'getModelDashboardService'], true);
// Views
$container->alias(DashboardHtmlView::class, 'view.dashboard.html')
->share('view.dashboard.html', [$this, 'getViewDashboardHtmlService'], true);
}
/**
* Get the `application.router` service
*
* @param Container $container The DI container.
*
* @return RouterInterface
*/
public function getApplicationRouterService(Container $container): RouterInterface
{
$router = new Router;
/*
* CMS Admin Panels
*/
$router->all(
'/index.php?dashboard=*',
DashboardController::class
);
$router->get(
'/*',
LoginController::class
);
return $router;
}
/**
* Get the `controller.login` service
*
* @param Container $container The DI container.
*
* @return LoginController
*/
public function getControllerLoginService(Container $container): LoginController
{
return new LoginController(
$container->get(RendererInterface::class),
$container->get(Input::class),
$container->get(AdminApplication::class)
);
}
/**
* Get the `controller.dashboard` service
*
* @param Container $container The DI container.
*
* @return DashboardController
*/
public function getControllerDashboardService(Container $container): DashboardController
{
return new DashboardController(
$container->get(DashboardHtmlView::class),
$container->get(Input::class),
$container->get(AdminApplication::class)
);
}
/**
* Get the `controller.wrong.cms` service
*
* @param Container $container The DI container.
*
* @return WrongCmsController
*/
public function getControllerWrongCmsService(Container $container): WrongCmsController
{
return new WrongCmsController(
$container->get(Input::class),
$container->get(AdminApplication::class)
);
}
/**
* Get the Input class service
*
* @param Container $container The DI container.
*
* @return Input
*/
public function getInputClassService(Container $container): Input
{
return new Input($_REQUEST);
}
/**
* Get the `model.dashboard` service
*
* @param Container $container The DI container.
*
* @return DashboardModel
*/
public function getModelDashboardService(Container $container): DashboardModel
{
return new DashboardModel($container->get(DatabaseInterface::class));
}
/**
* Get the WebApplication class service
*
* @param Container $container The DI container.
*
* @return AdminApplication
*/
public function getAdminApplicationClassService(Container $container): AdminApplication
{
/** @var \Octoleo\CMS\Application\AdminApplication $application */
$application = new AdminApplication(
$container->get(ControllerResolverInterface::class),
$container->get(RouterInterface::class),
$container->get(Input::class),
$container->get('config'),
$container->get(WebClient::class)
);
$application->httpVersion = '2';
// Inject extra services
$application->setDispatcher($container->get(DispatcherInterface::class));
$application->setLogger($container->get(LoggerInterface::class));
$application->setSession($container->get(SessionInterface::class));
$application->setUserFactory($container->get(UserFactoryInterface::class));
return $application;
}
/**
* Get the controller resolver service
*
* @param Container $container The DI container.
*
* @return ControllerResolverInterface
*/
public function getControllerResolverService(Container $container): ControllerResolverInterface
{
return new ContainerControllerResolver($container);
}
/**
* Get the `view.page.html` service
*
* @param Container $container The DI container.
*
* @return DashboardHtmlView
*/
public function getViewDashboardHtmlService(Container $container): DashboardHtmlView
{
return new DashboardHtmlView(
$container->get('model.dashboard'),
$container->get('renderer')
);
}
/**
* Get the web client service
*
* @param Container $container The DI container.
*
* @return WebClient
*/
public function getWebClientService(Container $container): WebClient
{
/** @var Input $input */
$input = $container->get(Input::class);
$userAgent = $input->server->getString('HTTP_USER_AGENT', '');
$acceptEncoding = $input->server->getString('HTTP_ACCEPT_ENCODING', '');
$acceptLanguage = $input->server->getString('HTTP_ACCEPT_LANGUAGE', '');
return new WebClient($userAgent, $acceptEncoding, $acceptLanguage);
}
}

View File

@ -0,0 +1,76 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Registry\Registry;
class ConfigurationProvider implements ServiceProviderInterface
{
/**
* Configuration instance
*
* @var Registry
*/
private $config;
/**
* Constructor.
*
* @param string $file Path to the config file.
*
* @throws \RuntimeException
*/
public function __construct(string $file)
{
// Verify the configuration exists and is readable.
if (!is_readable($file))
{
throw new \RuntimeException('Configuration file does not exist or is unreadable.');
}
// load the class
include_once $file;
$this->config = new Registry(new \LConfig());
// Set database values based on config values
$this->config->loadObject( (object) ['database' => [
'driver' => 'mysql',
'host' => $this->config->get('host'),
'port' => $this->config->get('port', ''),
'user' => $this->config->get('user'),
'password' => $this->config->get('password'),
'database' => $this->config->get('db'),
'prefix' => $this->config->get('dbprefix')
]
]);
}
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*/
public function register(Container $container): void
{
$container->share(
'config',
function (): Registry
{
return $this->config;
},
true
);
}
}

View File

@ -0,0 +1,75 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\Dispatcher;
use Joomla\Event\DispatcherInterface;
use Octoleo\CMS\EventListener\ErrorSubscriber;
use Joomla\Renderer\RendererInterface;
use Psr\Log\LoggerInterface;
/**
* Event service provider
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Service/EventProvider.php
*/
class EventProvider implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*/
public function register(Container $container): void
{
// This service cannot be protected as it is decorated when the debug bar is available
$container->alias(Dispatcher::class, DispatcherInterface::class)
->share(DispatcherInterface::class, [$this, 'getDispatcherService']);
$container->share(ErrorSubscriber::class, [$this, 'getErrorSubscriber'], true)
->tag('event.subscriber', [ErrorSubscriber::class]);
}
/**
* Get the DispatcherInterface service
*
* @param Container $container The DI container.
*
* @return DispatcherInterface
*/
public function getDispatcherService(Container $container): DispatcherInterface
{
$dispatcher = new Dispatcher;
foreach ($container->getTagged('event.subscriber') as $subscriber)
{
$dispatcher->addSubscriber($subscriber);
}
return $dispatcher;
}
/**
* Get the ErrorSubscriber service
*
* @param Container $container The DI container.
*
* @return ErrorSubscriber
*/
public function getErrorSubscriber(Container $container): ErrorSubscriber
{
$subscriber = new ErrorSubscriber($container->get(RendererInterface::class));
$subscriber->setLogger($container->get(LoggerInterface::class));
return $subscriber;
}
}

View File

@ -0,0 +1,64 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Http\Http;
use Joomla\Http\HttpFactory;
/**
* HTTP service provider
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Service/HttpProvider.php
*/
class HttpProvider implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*/
public function register(Container $container): void
{
$container->alias(Http::class, 'http')
->share('http', [$this, 'getHttpService'], true);
$container->alias(HttpFactory::class, 'http.factory')
->share('http.factory', [$this, 'getHttpFactoryService'], true);
}
/**
* Get the `http` service
*
* @param Container $container The DI container.
*
* @return Http
*/
public function getHttpService(Container $container): Http
{
/** @var HttpFactory $factory */
$factory = $container->get('http.factory');
return $factory->getHttp();
}
/**
* Get the `http.factory` service
*
* @param Container $container The DI container.
*
* @return HttpFactory
*/
public function getHttpFactoryService(Container $container): HttpFactory
{
return new HttpFactory;
}
}

View File

@ -0,0 +1,132 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor\PsrLogMessageProcessor;
use Monolog\Processor\WebProcessor;
/**
* Logging service provider
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Service/LoggingProvider.php
*/
class LoggingProvider implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*/
public function register(Container $container): void
{
/*
* Monolog Handlers
*/
$container->share('monolog.handler.application', [$this, 'getMonologHandlerApplicationService'], true);
/*
* Monolog Processors
*/
$container->share('monolog.processor.psr3', [$this, 'getMonologProcessorPsr3Service'], true);
$container->share('monolog.processor.web', [$this, 'getMonologProcessorWebService'], true);
/*
* Application Loggers
*/
$container->share('monolog.logger.application.cli', [$this, 'getMonologLoggerApplicationCliService'], true);
$container->share('monolog.logger.application.web', [$this, 'getMonologLoggerApplicationWebService'], true);
}
/**
* Get the `monolog.handler.application` service
*
* @param Container $container The DI container.
*
* @return StreamHandler
*/
public function getMonologHandlerApplicationService(Container $container): StreamHandler
{
/** @var \Joomla\Registry\Registry $config */
$config = $container->get('config');
$level = strtoupper($config->get('log.application', $config->get('log.level', 'error')));
return new StreamHandler(LPATH_ROOT . '/logs/framework.log', \constant('\\Monolog\\Logger::' . $level));
}
/**
* Get the `monolog.logger.application.cli` service
*
* @param Container $container The DI container.
*
* @return Logger
*/
public function getMonologLoggerApplicationCliService(Container $container): Logger
{
return new Logger(
'Framework',
[
$container->get('monolog.handler.application'),
],
[
$container->get('monolog.processor.psr3'),
]
);
}
/**
* Get the `monolog.logger.application.web` service
*
* @param Container $container The DI container.
*
* @return Logger
*/
public function getMonologLoggerApplicationWebService(Container $container): Logger
{
return new Logger(
'Framework',
[
$container->get('monolog.handler.application'),
],
[
$container->get('monolog.processor.psr3'),
$container->get('monolog.processor.web'),
]
);
}
/**
* Get the `monolog.processor.psr3` service
*
* @param Container $container The DI container.
*
* @return PsrLogMessageProcessor
*/
public function getMonologProcessorPsr3Service(Container $container): PsrLogMessageProcessor
{
return new PsrLogMessageProcessor;
}
/**
* Get the `monolog.processor.web` service
*
* @param Container $container The DI container.
*
* @return WebProcessor
*/
public function getMonologProcessorWebService(Container $container): WebProcessor
{
return new WebProcessor;
}
}

View File

@ -0,0 +1,128 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Service;
use Joomla\Application\AbstractWebApplication;
use Joomla\Database\DatabaseInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\Dispatcher;
use Joomla\Session\Session;
use Joomla\Session\SessionInterface;
use Joomla\Session\Storage\NativeStorage as SessionNativeStorage;
use Joomla\Session\StorageInterface;
use Joomla\Session\Handler\DatabaseHandler as SessionDatabaseHandler;
use Joomla\Session\HandlerInterface;
use Octoleo\CMS\Session\MetadataManager;
/**
* Session service provider
*/
class SessionProvider implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*/
public function register(Container $container): void
{
$container->alias(SessionDatabaseHandler::class, HandlerInterface::class)
->share(HandlerInterface::class, [$this, 'getSessionDatabaseHandlerClassService'], true);
$container->alias(SessionNativeStorage::class, StorageInterface::class)
->share(StorageInterface::class, [$this, 'getSessionNativeStorageClassService'], true);
$container->alias(Session::class, SessionInterface::class)
->share(SessionInterface::class, [$this, 'getSessionClassService'], true);
$container->alias(MetadataManager::class, MetadataManager::class)
->share(MetadataManager::class, [$this, 'getMetadataManagerClassService'], true);
}
/**
* Get the session metadata manager service
*
* @param Container $container The DI container.
*
* @return MetadataManager
*/
public function getMetadataManagerClassService(Container $container): MetadataManager
{
return new MetadataManager(
$container->get(DatabaseInterface::class)
);
}
/**
* Get the `admin.session` service
*
* @param Container $container The DI container.
*
* @return SessionInterface
* @throws \Exception
*/
public function getSessionClassService(Container $container): SessionInterface
{
/** @var \Joomla\Session\Session; $session */
$session = new Session($container->get(SessionNativeStorage::class), $container->get(Dispatcher::class));
// Start session if not already started
if (empty($session->getId()))
{
$session->start();
}
return $session;
}
/**
* Get the Session Database Handler service
*
* @param Container $container The DI container.
*
* @return HandlerInterface
*/
public function getSessionDatabaseHandlerClassService(Container $container): HandlerInterface
{
return new SessionDatabaseHandler($container->get(DatabaseInterface::class));
}
/**
* Get the `admin.session` service
*
* @param Container $container The DI container.
*
* @return StorageInterface
*/
public function getSessionNativeStorageClassService(Container $container): StorageInterface
{
/** @var \Joomla\Registry\Registry $config */
$config = $container->get('config');
// Generate a session name. (not secure enough)
$name = md5('octoleoAdmin');
// Calculate the session lifetime.
$lifetime = $config->get('lifetime') ? $config->get('lifetime') * 60 : 900;
// Initialize the options for the Session object.
$options = [
'name' => $name,
'expire' => $lifetime
];
return new SessionNativeStorage($container->get(SessionDatabaseHandler::class), $options);
}
}

View File

@ -0,0 +1,296 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Service;
use Joomla\Application\AbstractWebApplication;
use Joomla\Application\Controller\ContainerControllerResolver;
use Joomla\Application\Controller\ControllerResolverInterface;
use Joomla\Application\Web\WebClient;
use Joomla\Database\DatabaseInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Octoleo\CMS\Controller\HomepageController;
use Octoleo\CMS\Controller\WrongCmsController;
use Octoleo\CMS\Controller\PageController;
use Octoleo\CMS\Model\PageModel;
use Octoleo\CMS\View\Page\PageHtmlView;
use Octoleo\CMS\Application\SiteApplication;
use Joomla\Input\Input;
use Joomla\Renderer\RendererInterface;
use Joomla\Router\Route;
use Joomla\Router\Router;
use Joomla\Router\RouterInterface;
use Psr\Log\LoggerInterface;
/**
* Application service provider
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Service/ApplicationProvider.php
*/
class SiteApplicationProvider implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*/
public function register(Container $container): void
{
/*
* Application Classes
*/
// This service cannot be protected as it is decorated when the debug bar is available
$container->alias(SiteApplication::class, AbstractWebApplication::class)
->share(AbstractWebApplication::class, [$this, 'getSiteApplicationClassService']);
/*
* Application Helpers and Dependencies
*/
// This service cannot be protected as it is decorated when the debug bar is available
$container->alias(ContainerControllerResolver::class, ControllerResolverInterface::class)
->share(ControllerResolverInterface::class, [$this, 'getControllerResolverService']);
$container->share(WebClient::class, [$this, 'getWebClientService'], true);
// This service cannot be protected as it is decorated when the debug bar is available
$container->alias(RouterInterface::class, 'application.router')
->alias(Router::class, 'application.router')
->share('application.router', [$this, 'getApplicationRouterService']);
$container->share(Input::class, [$this, 'getInputClassService'], true);
/*
* MVC Layer
*/
// Controllers
$container->alias(HomepageController::class, 'controller.homepage')
->share('controller.homepage', [$this, 'getControllerHomepageService'], true);
$container->alias(PageController::class, 'controller.page')
->share('controller.page', [$this, 'getControllerPageService'], true);
$container->alias(WrongCmsController::class, 'controller.wrong.cms')
->share('controller.wrong.cms', [$this, 'getControllerWrongCmsService'], true);
// Models
$container->alias(PageModel::class, 'model.page')
->share('model.page', [$this, 'getModelPageService'], true);
// Views
$container->alias(PageHtmlView::class, 'view.page.html')
->share('view.page.html', [$this, 'getViewPageHtmlService'], true);
}
/**
* Get the `application.router` service
*
* @param Container $container The DI container.
*
* @return RouterInterface
*/
public function getApplicationRouterService(Container $container): RouterInterface
{
$router = new Router;
/*
* CMS Admin Panels
*/
$router->get(
'/wp-admin',
WrongCmsController::class
);
$router->get(
'/wp-admin/*',
WrongCmsController::class
);
$router->get(
'wp-login.php',
WrongCmsController::class
);
/*
* Web routes
*/
$router->addRoute(new Route(['GET', 'HEAD'], '/', HomepageController::class));
$router->get(
'/:view',
PageController::class
);
$router->get(
'/:view',
PageController::class
);
$router->get(
'/:view/:details',
PageController::class
);
return $router;
}
/**
* Get the `controller.homepage` service
*
* @param Container $container The DI container.
*
* @return HomepageController
*/
public function getControllerHomepageService(Container $container): HomepageController
{
return new HomepageController(
$container->get(RendererInterface::class),
$container->get(Input::class),
$container->get(SiteApplication::class)
);
}
/**
* Get the `controller.page` service
*
* @param Container $container The DI container.
*
* @return PageController
*/
public function getControllerPageService(Container $container): PageController
{
return new PageController(
$container->get(PageHtmlView::class),
$container->get(Input::class),
$container->get(SiteApplication::class)
);
}
/**
* Get the `controller.wrong.cms` service
*
* @param Container $container The DI container.
*
* @return WrongCmsController
*/
public function getControllerWrongCmsService(Container $container): WrongCmsController
{
return new WrongCmsController(
$container->get(Input::class),
$container->get(SiteApplication::class)
);
}
/**
* Get the Input class service
*
* @param Container $container The DI container.
*
* @return Input
*/
public function getInputClassService(Container $container): Input
{
return new Input($_REQUEST);
}
/**
* Get the `model.page` service
*
* @param Container $container The DI container.
*
* @return PageModel
*/
public function getModelPageService(Container $container): PageModel
{
return new PageModel($container->get(DatabaseInterface::class));
}
/**
* Get the WebApplication class service
*
* @param Container $container The DI container.
*
* @return SiteApplication
*/
public function getSiteApplicationClassService(Container $container): SiteApplication
{
$application = new SiteApplication(
$container->get(ControllerResolverInterface::class),
$container->get(RouterInterface::class),
$container->get(Input::class),
$container->get('config'),
$container->get(WebClient::class)
);
$application->httpVersion = '2';
// Inject extra services
$application->setDispatcher($container->get(DispatcherInterface::class));
$application->setLogger($container->get(LoggerInterface::class));
return $application;
}
/**
* Get the controller resolver service
*
* @param Container $container The DI container.
*
* @return ControllerResolverInterface
*/
public function getControllerResolverService(Container $container): ControllerResolverInterface
{
return new ContainerControllerResolver($container);
}
/**
* Get the `view.page.html` service
*
* @param Container $container The DI container.
*
* @return PageHtmlView
*/
public function getViewPageHtmlService(Container $container): PageHtmlView
{
$view = new PageHtmlView(
$container->get('model.page'),
$container->get('renderer')
);
$view->setLayout('page.twig');
return $view;
}
/**
* Get the web client service
*
* @param Container $container The DI container.
*
* @return WebClient
*/
public function getWebClientService(Container $container): WebClient
{
/** @var Input $input */
$input = $container->get(Input::class);
$userAgent = $input->server->getString('HTTP_USER_AGENT', '');
$acceptEncoding = $input->server->getString('HTTP_ACCEPT_ENCODING', '');
$acceptLanguage = $input->server->getString('HTTP_ACCEPT_LANGUAGE', '');
return new WebClient($userAgent, $acceptEncoding, $acceptLanguage);
}
}

View File

@ -0,0 +1,312 @@
<?php
/**
* Joomla! Framework Website
*
* @copyright Copyright (C) 2014 - 2017 Open Source Matters, Inc. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later
*/
namespace Octoleo\CMS\Service;
use Joomla\Application\AbstractApplication;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Octoleo\CMS\Asset\MixPathPackage;
use Octoleo\CMS\Renderer\ApplicationContext;
use Octoleo\CMS\Renderer\FrameworkExtension;
use Octoleo\CMS\Renderer\FrameworkTwigRuntime;
use Joomla\Preload\PreloadManager;
use Joomla\Renderer\RendererInterface;
use Joomla\Renderer\TwigRenderer;
use Symfony\Component\Asset\Packages;
use Symfony\Component\Asset\PathPackage;
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy;
use Twig\Cache\CacheInterface;
use Twig\Cache\FilesystemCache;
use Twig\Cache\NullCache;
use Twig\Environment;
use Twig\Extension\DebugExtension;
use Twig\Extension\ProfilerExtension;
use Twig\Loader\FilesystemLoader;
use Twig\Loader\LoaderInterface;
use Twig\Profiler\Profile;
use Twig\RuntimeLoader\ContainerRuntimeLoader;
/**
* Templating service provider
* source: https://github.com/joomla/framework.joomla.org/blob/master/src/Service/TemplatingProvider.php
*/
class TemplatingProvider implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*/
public function register(Container $container): void
{
$container->alias(Packages::class, 'asset.packages')
->share('asset.packages', [$this, 'getAssetPackagesService'], true);
$container->alias(RendererInterface::class, 'renderer')
->alias(TwigRenderer::class, 'renderer')
->share('renderer', [$this, 'getRendererService'], true);
$container->alias(CacheInterface::class, 'twig.cache')
->alias(\Twig_CacheInterface::class, 'twig.cache')
->share('twig.cache', [$this, 'getTwigCacheService'], true);
$container->alias(Environment::class, 'twig.environment')
->alias(\Twig_Environment::class, 'twig.environment')
->share('twig.environment', [$this, 'getTwigEnvironmentService'], true);
$container->alias(DebugExtension::class, 'twig.extension.debug')
->alias(\Twig_Extension_Debug::class, 'twig.extension.debug')
->share('twig.extension.debug', [$this, 'getTwigExtensionDebugService'], true);
$container->alias(FrameworkExtension::class, 'twig.extension.framework')
->share('twig.extension.framework', [$this, 'getTwigExtensionFrameworkService'], true);
// This service cannot be protected as it is decorated when the debug bar is available
$container->alias(ProfilerExtension::class, 'twig.extension.profiler')
->alias(\Twig_Extension_Profiler::class, 'twig.extension.profiler')
->share('twig.extension.profiler', [$this, 'getTwigExtensionProfilerService']);
$container->alias(LoaderInterface::class, 'twig.loader')
->alias(\Twig_LoaderInterface::class, 'twig.loader')
->share('twig.loader', [$this, 'getTwigLoaderService'], true);
$container->alias(Profile::class, 'twig.profiler.profile')
->alias(\Twig_Profiler_Profile::class, 'twig.profiler.profile')
->share('twig.profiler.profile', [$this, 'getTwigProfilerProfileService'], true);
$container->alias(FrameworkTwigRuntime::class, 'twig.runtime.framework')
->share('twig.runtime.framework', [$this, 'getTwigRuntimeFrameworkService'], true);
$container->alias(ContainerRuntimeLoader::class, 'twig.runtime.loader')
->alias(\Twig_ContainerRuntimeLoader::class, 'twig.runtime.loader')
->share('twig.runtime.loader', [$this, 'getTwigRuntimeLoaderService'], true);
$this->tagTwigExtensions($container);
}
/**
* Get the `asset.packages` service
*
* @param Container $container The DI container.
*
* @return Packages
*/
public function getAssetPackagesService(Container $container): Packages
{
/** @var AbstractApplication $app */
$app = $container->get(AbstractApplication::class);
$context = new ApplicationContext($app);
$mediaPath = $app->get('uri.media.path', '/media/');
$defaultPackage = new PathPackage($mediaPath, new EmptyVersionStrategy, $context);
$mixStrategy = new MixPathPackage(
$defaultPackage,
$mediaPath,
new JsonManifestVersionStrategy(LPATH_ROOT . '/media/mix-manifest.json'),
$context
);
return new Packages(
$defaultPackage,
[
'mix' => $mixStrategy,
]
);
}
/**
* Get the `renderer` service
*
* @param Container $container The DI container.
*
* @return RendererInterface
*/
public function getRendererService(Container $container): RendererInterface
{
return new TwigRenderer($container->get('twig.environment'));
}
/**
* Get the `twig.cache` service
*
* @param Container $container The DI container.
*
* @return \Twig_CacheInterface
*/
public function getTwigCacheService(Container $container): \Twig_CacheInterface
{
/** @var \Joomla\Registry\Registry $config */
$config = $container->get('config');
// Pull down the renderer config
$cacheEnabled = $config->get('template.cache.enabled', false);
$cachePath = $config->get('template.cache.path', 'cache/twig');
$debug = $config->get('template.debug', false);
if ($debug === false && $cacheEnabled !== false)
{
return new FilesystemCache(LPATH_ROOT . '/' . $cachePath);
}
return new NullCache;
}
/**
* Get the `twig.environment` service
*
* @param Container $container The DI container.
*
* @return Environment
*/
public function getTwigEnvironmentService(Container $container): Environment
{
/** @var \Joomla\Registry\Registry $config */
$config = $container->get('config');
$debug = $config->get('template.debug', false);
$environment = new Environment(
$container->get('twig.loader'),
['debug' => $debug]
);
// Add the runtime loader
$environment->addRuntimeLoader($container->get('twig.runtime.loader'));
// Set up the environment's caching service
$environment->setCache($container->get('twig.cache'));
// Add the Twig extensions
$environment->setExtensions($container->getTagged('twig.extension'));
// Add a global tracking the debug states
$environment->addGlobal('appDebug', $config->get('debug', false));
$environment->addGlobal('fwDebug', $debug);
return $environment;
}
/**
* Get the `twig.extension.debug` service
*
* @param Container $container The DI container.
*
* @return DebugExtension
*/
public function getTwigExtensionDebugService(Container $container): DebugExtension
{
return new DebugExtension;
}
/**
* Get the `twig.extension.framework` service
*
* @param Container $container The DI container.
*
* @return FrameworkExtension
*/
public function getTwigExtensionFrameworkService(Container $container): FrameworkExtension
{
return new FrameworkExtension;
}
/**
* Get the `twig.extension.profiler` service
*
* @param Container $container The DI container.
*
* @return ProfilerExtension
*/
public function getTwigExtensionProfilerService(Container $container): ProfilerExtension
{
return new ProfilerExtension($container->get('twig.profiler.profile'));
}
/**
* Get the `twig.loader` service
*
* @param Container $container The DI container.
*
* @return \Twig_LoaderInterface
*/
public function getTwigLoaderService(Container $container): \Twig_LoaderInterface
{
return new FilesystemLoader([LPATH_TEMPLATES]);
}
/**
* Get the `twig.profiler.profile` service
*
* @param Container $container The DI container.
*
* @return Profile
*/
public function getTwigProfilerProfileService(Container $container): Profile
{
return new Profile;
}
/**
* Get the `twig.runtime.framework` service
*
* @param Container $container The DI container.
*
* @return FrameworkTwigRuntime
*/
public function getTwigRuntimeFrameworkService(Container $container): FrameworkTwigRuntime
{
return new FrameworkTwigRuntime(
$container->get(AbstractApplication::class),
$container->get(PreloadManager::class),
LPATH_ROOT . '/media/sri-manifest.json'
);
}
/**
* Get the `twig.runtime.loader` service
*
* @param Container $container The DI container.
*
* @return ContainerRuntimeLoader
*/
public function getTwigRuntimeLoaderService(Container $container): ContainerRuntimeLoader
{
return new ContainerRuntimeLoader($container);
}
/**
* Tag services which are Twig extensions
*
* @param Container $container The DI container.
*
* @return void
*/
private function tagTwigExtensions(Container $container): void
{
/** @var \Joomla\Registry\Registry $config */
$config = $container->get('config');
$debug = $config->get('template.debug', false);
$twigExtensions = ['twig.extension.framework'];
if ($debug)
{
$twigExtensions[] = 'twig.extension.debug';
}
$container->tag('twig.extension', $twigExtensions);
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Service;
use Joomla\Authentication\AuthenticationStrategyInterface;
use Joomla\Authentication\Strategies\DatabaseStrategy;
use Joomla\Input\Input;
use Octoleo\CMS\User\UserFactory;
use Octoleo\CMS\User\UserFactoryInterface;
use Joomla\Database\DatabaseInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
/**
* Service provider for the user dependency
*
* @since 1.0.0
* source: https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Service/Provider/User.php
*/
class UserProvider implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.0.0
*/
public function register(Container $container)
{
$container->alias('user.factory', UserFactoryInterface::class)
->alias(UserFactory::class, UserFactoryInterface::class)
->share(UserFactoryInterface::class, [$this, 'getUserFactoryService'], true);
$container->alias(DatabaseStrategy::class, AuthenticationStrategyInterface::class)
->share(AuthenticationStrategyInterface::class, [$this, 'getAuthenticationStrategyService'], true);
}
/**
* Get the UserFactoryInterface class service
*
* @param Container $container The DI container.
*
* @return UserFactoryInterface
* @throws \Exception
*/
public function getUserFactoryService(Container $container): UserFactoryInterface
{
return new UserFactory(
$container->get(DatabaseInterface::class),
$container->get(AuthenticationStrategyInterface::class)
);
}
/**
* Get the AuthenticationStrategyInterface class service
*
* @param Container $container The DI container.
*
* @return AuthenticationStrategyInterface
*/
public function getAuthenticationStrategyService(Container $container): AuthenticationStrategyInterface
{
return new DatabaseStrategy(
$container->get(Input::class),
$container->get(DatabaseInterface::class)
);
}
}

View File

@ -0,0 +1,326 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\Session;
use Octoleo\CMS\User\User;
use Joomla\Database\DatabaseInterface;
use Joomla\Database\Exception\ExecutionFailureException;
use Joomla\Database\ParameterType;
use Joomla\Session\SessionInterface;
/**
* Manager for optional session metadata.
*
* @since 3.8.6
* @internal
*/
final class MetadataManager
{
/**
* Internal variable indicating a session record exists.
*
* @var integer
* @since 4.0.0
* @note Once PHP 7.1 is the minimum supported version this should become a private constant
*/
private static $sessionRecordExists = 1;
/**
* Internal variable indicating a session record does not exist.
*
* @var integer
* @since 4.0.0
* @note Once PHP 7.1 is the minimum supported version this should become a private constant
*/
private static $sessionRecordDoesNotExist = 0;
/**
* Internal variable indicating an unknown session record statue.
*
* @var integer
* @since 4.0.0
* @note Once PHP 7.1 is the minimum supported version this should become a private constant
*/
private static $sessionRecordUnknown = -1;
/**
* Database driver.
*
* @var DatabaseInterface
* @since 3.8.6
*/
private $db;
/**
* MetadataManager constructor.
*
* @param DatabaseInterface $db Database driver.
*
* @since 3.8.6
*/
public function __construct(DatabaseInterface $db)
{
$this->db = $db;
}
/**
* Create the metadata record if it does not exist.
*
* @param SessionInterface $session The session to create the metadata record for.
* @param User $user The user to associate with the record.
*
* @return void
*
* @since 3.8.6
* @throws \RuntimeException
*/
public function createRecordIfNonExisting(SessionInterface $session, User $user)
{
$exists = $this->checkSessionRecordExists($session->getId());
// Only touch the database if the record does not already exist
if ($exists !== self::$sessionRecordExists)
{
return;
}
$this->createSessionRecord($session, $user);
}
/**
* Create the metadata record if it does not exist.
*
* @param SessionInterface $session The session to create or update the metadata record for.
* @param User $user The user to associate with the record.
*
* @return void
*
* @since 4.0.0
* @throws \RuntimeException
*/
public function createOrUpdateRecord(SessionInterface $session, User $user)
{
$exists = $this->checkSessionRecordExists($session->getId());
// Do not try to touch the database if we can't determine the record state
if ($exists === self::$sessionRecordUnknown)
{
return;
}
if ($exists === self::$sessionRecordDoesNotExist)
{
$this->createSessionRecord($session, $user);
return;
}
$this->updateSessionRecord($session, $user);
}
/**
* Delete records with a timestamp prior to the given time.
*
* @param integer $time The time records should be deleted if expired before.
*
* @return void
*
* @since 3.8.6
*/
public function deletePriorTo($time)
{
$query = $this->db->getQuery(true)
->delete($this->db->quoteName('#__session'))
->where($this->db->quoteName('time') . ' < :time')
->bind(':time', $time, ParameterType::INTEGER);
$this->db->setQuery($query);
try
{
$this->db->execute();
}
catch (ExecutionFailureException $exception)
{
// Since garbage collection does not result in a fatal error when run in the session API, we don't allow it here either.
}
}
/**
* Get session record exists
*
* @param string $sessionId The session ID to check
*
* @return mixed on success value for record presence
*
* @since 1.0.0
*/
public function getSessionRecord(string $sessionId)
{
$query = $this->db->getQuery(true)
->select('*')
->from($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = :session_id')
->bind(':session_id', $sessionId)
->setLimit(1);
$this->db->setQuery($query);
return $this->db->loadObject();
}
/**
* Check if the session record exists
*
* @param string $sessionId The session ID to check
*
* @return integer Status value for record presence
*
* @since 4.0.0
*/
private function checkSessionRecordExists(string $sessionId): int
{
$query = $this->db->getQuery(true)
->select($this->db->quoteName('session_id'))
->from($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = :session_id')
->bind(':session_id', $sessionId)
->setLimit(1);
$this->db->setQuery($query);
try
{
$exists = $this->db->loadResult();
}
catch (ExecutionFailureException $e)
{
return self::$sessionRecordUnknown;
}
if ($exists)
{
return self::$sessionRecordExists;
}
return self::$sessionRecordDoesNotExist;
}
/**
* Create the session record
*
* @param SessionInterface $session The session to create the metadata record for.
* @param User $user The user to associate with the record.
*
* @return void
*
* @since 4.0.0
*/
private function createSessionRecord(SessionInterface $session, User $user)
{
$query = $this->db->getQuery(true);
$time = $session->isNew() ? time() : $session->get('session.timer.start');
$columns = [
$this->db->quoteName('session_id'),
$this->db->quoteName('guest'),
$this->db->quoteName('time'),
$this->db->quoteName('userid'),
$this->db->quoteName('username'),
];
// Add query placeholders
$values = [
':session_id',
':guest',
':time',
':user_id',
':username',
];
// Bind query values
$sessionId = $session->getId();
$userIsGuest = $user->get('guest', 0);
$userId = $user->get('id', 0);
$username = $user->get('username', '');
$query->bind(':session_id', $sessionId)
->bind(':guest', $userIsGuest, ParameterType::INTEGER)
->bind(':time', $time)
->bind(':user_id', $userId, ParameterType::INTEGER)
->bind(':username', $username);
$query->insert($this->db->quoteName('#__session'))
->columns($columns)
->values(implode(', ', $values));
$this->db->setQuery($query);
try
{
$this->db->execute();
}
catch (ExecutionFailureException $e)
{
// This failure isn't critical, we can go on without the metadata
}
}
/**
* Update the session record
*
* @param SessionInterface $session The session to update the metadata record for.
* @param User $user The user to associate with the record.
*
* @return void
*
* @since 4.0.0
*/
private function updateSessionRecord(SessionInterface $session, User $user)
{
$query = $this->db->getQuery(true);
$time = time();
$setValues = [
$this->db->quoteName('guest') . ' = :guest',
$this->db->quoteName('time') . ' = :time',
$this->db->quoteName('userid') . ' = :user_id',
$this->db->quoteName('username') . ' = :username',
];
// Bind query values
$sessionId = $session->getId();
$userIsGuest = $user->get('guest', 0);
$userId = $user->get('id', 0);
$username = $user->get('username', '');
$query->bind(':session_id', $sessionId)
->bind(':guest', $userIsGuest, ParameterType::INTEGER)
->bind(':time', $time)
->bind(':user_id', $userId, ParameterType::INTEGER)
->bind(':username', $username);
$query->update($this->db->quoteName('#__session'))
->set($setValues)
->where($this->db->quoteName('session_id') . ' = :session_id');
$this->db->setQuery($query);
try
{
$this->db->execute();
}
catch (ExecutionFailureException $e)
{
// This failure isn't critical, we can go on without the metadata
}
}
}

View File

@ -0,0 +1,260 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\String;
use Algo26\IdnaConvert\ToIdn;
use Algo26\IdnaConvert\ToUnicode;
use Joomla\Uri\UriHelper;
/**
* Joomla Platform String Punycode Class
*
* Class for handling UTF-8 URLs
* Wraps the Punycode library
* All functions assume the validity of utf-8 URLs.
*
* @since 3.1.2
*/
abstract class PunycodeHelper
{
/**
* Transforms a UTF-8 string to a Punycode string
*
* @param string $utfString The UTF-8 string to transform
*
* @return string The punycode string
*
* @since 3.1.2
*/
public static function toPunycode($utfString)
{
return (new ToIdn)->convert($utfString);
}
/**
* Transforms a Punycode string to a UTF-8 string
*
* @param string $punycodeString The Punycode string to transform
*
* @return string The UF-8 URL
*
* @since 3.1.2
*/
public static function fromPunycode($punycodeString)
{
return (new ToUnicode)->convert($punycodeString);
}
/**
* Transforms a UTF-8 URL to a Punycode URL
*
* @param string $uri The UTF-8 URL to transform
*
* @return string The punycode URL
*
* @since 3.1.2
*/
public static function urlToPunycode($uri)
{
$parsed = UriHelper::parse_url($uri);
if (!isset($parsed['host']) || $parsed['host'] == '')
{
// If there is no host we do not need to convert it.
return $uri;
}
$host = $parsed['host'];
$hostExploded = explode('.', $host);
$newhost = '';
foreach ($hostExploded as $hostex)
{
$hostex = static::toPunycode($hostex);
$newhost .= $hostex . '.';
}
$newhost = substr($newhost, 0, -1);
$newuri = '';
if (!empty($parsed['scheme']))
{
// Assume :// is required although it is not always.
$newuri .= $parsed['scheme'] . '://';
}
if (!empty($newhost))
{
$newuri .= $newhost;
}
if (!empty($parsed['port']))
{
$newuri .= ':' . $parsed['port'];
}
if (!empty($parsed['path']))
{
$newuri .= $parsed['path'];
}
if (!empty($parsed['query']))
{
$newuri .= '?' . $parsed['query'];
}
if (!empty($parsed['fragment']))
{
$newuri .= '#' . $parsed['fragment'];
}
return $newuri;
}
/**
* Transforms a Punycode URL to a UTF-8 URL
*
* @param string $uri The Punycode URL to transform
*
* @return string The UTF-8 URL
*
* @since 3.1.2
*/
public static function urlToUTF8($uri)
{
if (empty($uri))
{
return '';
}
$parsed = UriHelper::parse_url($uri);
if (!isset($parsed['host']) || $parsed['host'] == '')
{
// If there is no host we do not need to convert it.
return $uri;
}
$host = $parsed['host'];
$hostExploded = explode('.', $host);
$newhost = '';
foreach ($hostExploded as $hostex)
{
$hostex = self::fromPunycode($hostex);
$newhost .= $hostex . '.';
}
$newhost = substr($newhost, 0, -1);
$newuri = '';
if (!empty($parsed['scheme']))
{
// Assume :// is required although it is not always.
$newuri .= $parsed['scheme'] . '://';
}
if (!empty($newhost))
{
$newuri .= $newhost;
}
if (!empty($parsed['port']))
{
$newuri .= ':' . $parsed['port'];
}
if (!empty($parsed['path']))
{
$newuri .= $parsed['path'];
}
if (!empty($parsed['query']))
{
$newuri .= '?' . $parsed['query'];
}
if (!empty($parsed['fragment']))
{
$newuri .= '#' . $parsed['fragment'];
}
return $newuri;
}
/**
* Transforms a UTF-8 email to a Punycode email
* This assumes a valid email address
*
* @param string $email The UTF-8 email to transform
*
* @return string The punycode email
*
* @since 3.1.2
*/
public static function emailToPunycode($email)
{
$explodedAddress = explode('@', $email);
// Not addressing UTF-8 user names
$newEmail = $explodedAddress[0];
if (!empty($explodedAddress[1]))
{
$domainExploded = explode('.', $explodedAddress[1]);
$newdomain = '';
foreach ($domainExploded as $domainex)
{
$domainex = static::toPunycode($domainex);
$newdomain .= $domainex . '.';
}
$newdomain = substr($newdomain, 0, -1);
$newEmail = $newEmail . '@' . $newdomain;
}
return $newEmail;
}
/**
* Transforms a Punycode email to a UTF-8 email
* This assumes a valid email address
*
* @param string $email The punycode email to transform
*
* @return string The punycode email
*
* @since 3.1.2
*/
public static function emailToUTF8($email)
{
$explodedAddress = explode('@', $email);
// Not addressing UTF-8 user names
$newEmail = $explodedAddress[0];
if (!empty($explodedAddress[1]))
{
$domainExploded = explode('.', $explodedAddress[1]);
$newdomain = '';
foreach ($domainExploded as $domainex)
{
$domainex = static::fromPunycode($domainex);
$newdomain .= $domainex . '.';
}
$newdomain = substr($newdomain, 0, -1);
$newEmail = $newEmail . '@' . $newdomain;
}
return $newEmail;
}
}

View File

@ -0,0 +1,76 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\User;
use Joomla\Registry\Registry;
use Joomla\Database\DatabaseInterface;
use Octoleo\CMS\Factory;
/**
* User class. Handles all application interaction with a user
*
* @since 1.0.0
*/
class User extends Registry
{
/**
* Constructor activating the default information of the language
*
* @param integer $identifier The primary key of the user to load (optional).
*
* @throws \Exception
* @since 1.1.0
*/
public function __construct($identifier = 0)
{
// Load the user if it exists
if (!empty($identifier))
{
$data = $this->load($identifier);
// not a guest
$data->guest = 0;
}
else
{
// Initialise guest
$data = (object) ['id' => 0, 'sendEmail' => 0, 'aid' => 0, 'guest' => 1];
}
// set the data
parent::__construct($data);
}
/**
* Method to load a User object by user id number
*
* @param int $id The user id of the user to load
*
* @return Object on success
*
* @throws \Exception
* @since 1.0.0
*/
protected function load( int $id): object
{
// Get the database
$db = Factory::getContainer()->get(DatabaseInterface::class);
// Initialise some variables
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__users'))
->where($db->quoteName('id') . ' = :id')
->bind(':id', $id)
->setLimit(1);
$db->setQuery($query);
return $db->loadObject();
}
}

View File

@ -0,0 +1,481 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\User;
use Joomla\Authentication\AuthenticationStrategyInterface;
use Joomla\Database\DatabaseInterface;
use Joomla\Authentication\Password\BCryptHandler;
use Joomla\Filter\InputFilter as InputFilterAlias;
use Joomla\String\StringHelper;
use Octoleo\CMS\Application\AdminApplication;
use Octoleo\CMS\Date\Date;
use Octoleo\CMS\Factory;
use Octoleo\CMS\Filter\InputFilter;
use Octoleo\CMS\Session\MetadataManager;
/**
* Default factory for creating User objects
*
* @since 1.0.0
* source: https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/User/UserFactory.php
*/
class UserFactory implements UserFactoryInterface
{
/**
* The database.
*
* @var DatabaseInterface
*/
private $db;
/**
* @var AuthenticationStrategyInterface
*/
private $authentication;
/**
* @var InputFilter
*/
private $inputFilter;
/**
* @var string[]
*/
private $userFilter = [
'name' => 'STRING',
'username' => 'USERNAME',
'email' => 'STRING',
'password' => 'RAW',
'password2' => 'RAW'
];
/**
* @var BCryptHandler
*/
private $secure;
/**
* UserFactory constructor.
*
* @param DatabaseInterface|null $db The database
* @param AuthenticationStrategyInterface|null $authentication
*
* @throws \Exception
*/
public function __construct(
DatabaseInterface $db = null,
AuthenticationStrategyInterface $authentication = null,
BCryptHandler $secure = null)
{
$this->db = ($db) ?: Factory::getApplication()->get(DatabaseInterface::class);
$this->authentication = ($authentication) ?: Factory::getApplication()->get(AuthenticationStrategyInterface::class);
$this->secure = ($secure) ?: new BCryptHandler();
}
/**
* Method to get an instance of a user for the given id.
*
* @param int $id The id
*
* @return User
*
* @throws \Exception
* @since 1.0.0
*/
public function loadUserById(int $id): User
{
return new User($id);
}
/**
* Method to get an instance of a user for the given username.
*
* @param string $username The username
*
* @return User
*
* @throws \Exception
* @since 1.0.0
*/
public function loadUserByUsername(string $username): User
{
// Initialise some variables
$query = $this->db->getQuery(true)
->select($this->db->quoteName('id'))
->from($this->db->quoteName('#__users'))
->where($this->db->quoteName('username') . ' = :username')
->bind(':username', $username)
->setLimit(1);
$this->db->setQuery($query);
return $this->loadUserById((int) $this->db->loadResult());
}
/**
* Check if user is active
*
* @return bool
* @throws \Exception
*/
public function active(): bool
{
/** @var \Octoleo\CMS\Application\AdminApplication $application */
$application = Factory::getApplication();
$session = $application->getSession();
// Grab the current session ID
$sessionId = $session->getId();
/** @var \Octoleo\CMS\Session\MetadataManager $manager */
$manager = Factory::getContainer()->get(MetadataManager::class);
$active = $manager->getSessionRecord($sessionId);
// if no active session is found...
if (!$active)
{
return false;
}
// if user above 0 the active
if ($active->guest == 0 && $active->userid > 0)
{
return true;
}
// Purge the session
$query = $this->db->getQuery(true)
->delete($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = :sessionid')
->bind(':sessionid', $sessionId);
try
{
$this->db->setQuery($query)->execute();
}
catch (\RuntimeException $e)
{
// The old session is already invalidated, don't let this block logging in
}
// destroy session
$session->destroy();
// very basic for now....
return false;
}
/**
* Check if a user exist based on give key value pair
*
* @param string $value
* @param string $key
*
* @return false|mixed on success return user ID
*/
public function exist(string $value, string $key = 'username')
{
try
{
$id = $this->db->setQuery(
$this->db->getQuery(true)
->select($this->db->quoteName('id'))
->from($this->db->quoteName('#__users'))
->where($this->db->quoteName($key) . ' = ?')
->bind(1, $value)
)->loadResult();
}
catch (\RuntimeException $exception)
{
return false;
}
if ($id > 0)
{
return $id;
}
return false;
}
/**
* Attempt to authenticate the username and password pair.
*
* @return string|boolean A string containing a username if authentication is successful, false otherwise.
*
* @since 1.1.0
*/
public function authenticate()
{
return $this->authentication->authenticate();
}
/**
* Attempt to login user
*
* @return boolean true on success
*
* @throws \Exception
* @since 1.0.0
*/
public function login(): bool
{
/** @var \Octoleo\CMS\Application\AdminApplication $application */
$application = Factory::getApplication();
if (($username = $this->authenticate()) !== false)
{
$user = $this->loadUserByUsername($username);
// If loadUserByUsername returned an error, then pass it back.
if ($user instanceof \Exception)
{
$application->enqueueMessage('Login failure', 'Error');
return false;
}
// If loadUserByUsername returned an error, then pass it back.
if ($user->get('block', true))
{
$application->enqueueMessage('Login failure, user is blocked.', 'Warning');
return false;
}
return $this->setUserSession($application, $user->toArray());
}
// set authentication failure message
$application->enqueueMessage('Login failure, please try again.', 'Warning');
return false;
}
/**
* Logout user
*
* @return bool
* @throws \Exception
*/
public function logout(): bool
{
/** @var \Octoleo\CMS\Application\AdminApplication $application */
$application = Factory::getApplication();
$session = $application->getSession();
// Grab the current session ID
$sessionId = $session->getId();
// Purge the session
$query = $this->db->getQuery(true)
->delete($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = :sessionid')
->bind(':sessionid', $sessionId);
try
{
$this->db->setQuery($query)->execute();
}
catch (\RuntimeException $e)
{
// The old session is already invalidated, don't let this block logging in
}
// destroy session
$session->destroy();
// very basic for now....
return true;
}
/**
* Attempt to great user
*
* @param string|null $name
* @param string|null $username
* @param string|null $email
* @param string|null $password
* @param string|null $password2
*
* @return boolean true on success
*
* @throws \Exception
* @since 1.0.0
*/
public function create(
string $name = null,
string $username = null,
string $email = null,
string $password = null,
string $password2 = null): bool
{
/** @var \Octoleo\CMS\Application\AdminApplication $application */
$application = Factory::getApplication();
/** @var \Joomla\Input\Input $input */
$input = $application->getInput();
$user = [];
$user['name'] = ($name) ?: $input->getString('name', '');
$user['username'] = ($username) ?: $input->getString('username', '');
$user['email'] = ($email) ?: $input->getString('email', '');
$user['password'] = ($password) ?: $input->getString('password', '');
$user['password2'] = ($password2) ?: $input->getString('password2', '');
// check if username exist
if (!empty($user['username']) && $this->exist($user['username']))
{
$application->enqueueMessage('Username already exist, try another username.', 'Warning');
return false;
}
// check if email exist
if (!empty($user['email']) && $this->exist($user['email'], 'email'))
{
$application->enqueueMessage('Email already exist, try another email.', 'Warning');
return false;
}
// load our filter
$this->inputFilter = InputFilter::getInstance(
[],
[],
InputFilterAlias::ONLY_BLOCK_DEFINED_TAGS,
InputFilterAlias::ONLY_BLOCK_DEFINED_ATTRIBUTES
);
// check that we have all the values set
$valid = true;
foreach ($user as $key => $detail)
{
// check if its empty
if (empty($detail))
{
$valid = false;
$application->enqueueMessage($key . ' is required', 'error');
}
// check if its valid
if (!$this->valid($key, $detail))
{
$valid = false;
$application->enqueueMessage($key . ' is not valid', 'error');
}
}
// check passwords TODO: check that we have a valid email
if (isset($user['password2']) && $user['password'] != $user['password2'])
{
$valid = false;
$application->enqueueMessage('Passwords do not match', 'error');
}
unset ($user['password2']);
// continue only if valid
if ($valid)
{
// hash the password
$user['password'] = $this->secure->hashPassword($user['password']);
// set the registration date
$user['registerDate'] = (new Date())->toSql();
// set other defaults for now
$user['sendEmail'] = 1;
$user['block'] = 0;
$user['params'] = '';
$insert = (object) $user;
try
{
// Insert the user
$result = $this->db->insertObject('#__users', $insert, 'id');
}
catch (\RuntimeException $exception)
{
throw new \RuntimeException($exception->getMessage(), 404);
return false;
}
// only set session if success
if ($result)
{
$user['id'] = $this->db->insertid();
return $this->setUserSession($application, $user);
}
}
return false;
}
/**
* Attempt validate user input (BASIC)
*
* @param string $key
* @param string $detail
*
* @return bool
*/
private function valid(string $key, string $detail): bool
{
if (isset($this->userFilter[$key]))
{
$valid = $this->inputFilter->clean($detail, $this->userFilter[$key]);
if (StringHelper::strcmp($valid, $detail) == 0)
{
return true;
}
}
return false;
}
/**
* @param AdminApplication $application
* @param array $user
*
* @return bool
* @throws \Exception
*/
private function setUserSession(AdminApplication $application, array $user): bool
{
$session = $application->getSession();
// Grab the current session ID
$oldSessionId = $session->getId();
// Fork the session
$session->fork();
// Register the needed session variables
$session->set('user', $user);
// Purge the old session
$query = $this->db->getQuery(true)
->delete($this->db->quoteName('#__session'))
->where($this->db->quoteName('session_id') . ' = :sessionid')
->bind(':sessionid', $oldSessionId);
try
{
$this->db->setQuery($query)->execute();
}
catch (\RuntimeException $e)
{
// The old session is already invalidated, don't let this block logging in
}
/** @var \Octoleo\CMS\Session\MetadataManager $manager */
$manager = Factory::getContainer()->get(MetadataManager::class);
$manager->createOrUpdateRecord($session, $this->loadUserById($user['id']));
return true;
}
}

View File

@ -0,0 +1,48 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\User;
/**
* Interface defining a factory which can create User objects
*
* @since 1.0.0
*/
interface UserFactoryInterface
{
/**
* Method to get an instance of a user for the given id.
*
* @param int $id The id
*
* @return User
*
* @since 1.0.0
*/
public function loadUserById(int $id): User;
/**
* Method to get an instance of a user for the given username.
*
* @param string $username The username
*
* @return User
*
* @since 1.0.0
*/
public function loadUserByUsername(string $username): User;
/**
* Attempt to authenticate the username and password pair.
*
* @return string|boolean A string containing a username if authentication is successful, false otherwise.
*
* @since 1.1.0
*/
public function authenticate();
}

View File

@ -0,0 +1,83 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\View\Admin;
use Octoleo\CMS\Model\DashboardModel;
use Joomla\Renderer\RendererInterface;
use Joomla\View\HtmlView;
/**
* Dashboard HTML view class for the application
*/
class DashboardHtmlView extends HtmlView
{
/**
* The id of item/user/menu
*
* @var int
*/
private $id;
/**
* The page model object.
*
* @var DashboardModel
*/
private $dashboardModel;
/**
* Instantiate the view.
*
* @param DashboardModel $dashboardModel The page model object.
* @param RendererInterface $renderer The renderer object.
*/
public function __construct(DashboardModel $dashboardModel, RendererInterface $renderer)
{
parent::__construct($renderer);
$this->dashboardModel = $dashboardModel;
}
/**
* Method to render the view
*
* @return string The rendered view
*/
public function render()
{
$this->setData(['page' => $this->id]);
return parent::render();
}
/**
* Set the active dashboard
*
* @param string $name The active page name
*
* @return void
*/
public function setActiveDashboard(string $name): void
{
$this->setLayout($this->dashboardModel->getDashboard($name));
}
/**
* Set the active page details
*
* @param int $id The selected item/user/menu
*
* @return void
*/
public function setActiveId(int $id): void
{
$this->id = $id;
}
}

View File

@ -0,0 +1,96 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Octoleo\CMS\View\Page;
use Octoleo\CMS\Model\PageModel;
use Joomla\Renderer\RendererInterface;
use Joomla\View\HtmlView;
/**
* Page HTML view class for the application
*/
class PageHtmlView extends HtmlView
{
/**
* The active page
*
* @var string
*/
private $page = '';
/**
* The active page details
*
* @var string
*/
private $details;
/**
* The page model object.
*
* @var PageModel
*/
private $pageModel;
/**
* Instantiate the view.
*
* @param PageModel $pageModel The page model object.
* @param RendererInterface $renderer The renderer object.
*/
public function __construct(PageModel $pageModel, RendererInterface $renderer)
{
parent::__construct($renderer);
$this->pageModel = $pageModel;
}
/**
* Method to render the view
*
* @return string The rendered view
*/
public function render()
{
$this->setData(
[
'page' => $this->pageModel->getPage($this->page),
'details' => $this->pageModel->getDetails($this->details)
]
);
return parent::render();
}
/**
* Set the active page
*
* @param string $page The active page name
*
* @return void
*/
public function setPage(string $page): void
{
$this->page = $page;
}
/**
* Set the active page details
*
* @param string $page The active page name
*
* @return void
*/
public function setDetails(string $details): void
{
$this->details = $details;
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</configuration>

View File

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,95 @@
<?php
/**
* @package Octoleo CMS
*
* @created 9th April 2022
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
* @license GNU General Public License version 2 or later; see LICENSE.txt
* -------------------------------------------------------------------------
* THIS SHOULD ONLY BE USED AS A LAST RESORT WHEN THE WEB INSTALLER FAILS
*
* If you are installing Octoleo! manually ie not using the web browser installer
* then rename this file to octoconfig.php eg
*
* UNIX -> mv octoconfig.php.example octoconfig.php
* Windows -> rename octoconfig.php.example octoconfig.php
*
* Now edit this file and configure the parameters for your site and
* database.
*
* Finally move this file to the root folder of your Octoleo installation eg
*
* UNIX -> mv octoconfig.php ../
* Windows -> copy octoconfig.php ../
*
* SOURCE: https://github.com/joomla/joomla-cms/blob/4.1-dev/installation/configuration.php-dist
*
*/
class LConfig
{
public $sitename = 'Octoleo!'; // Name of Octoleo site
/* Database Settings */
public $dbtype = 'mysqli'; // Normally mysqli
public $host = 'localhost'; // This is normally set to localhost
public $user = ''; // Database username
public $password = ''; // Database password
public $db = ''; // Database name
public $dbprefix = 'llewellyn_'; // LEAVE THIS UNCHANGED FOR NOW
public $dbencryption = 0;
public $dbsslverifyservercert = false;
public $dbsslkey = '';
public $dbsslcert = '';
public $dbsslca = '';
public $dbsslcipher = '';
/* Server Settings */
public $secret = 'EiT9pmiqMycmQ6xx'; // Use something very secure. For example on linux the following command `cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-16} | head -n 1`
public $helpurl = 'https://help.octoleo.org/proxy?keyref=Help{major}{minor}:{keyref}&lang={langcode}';
public $tmp_path = '/tmp'; // This path needs to be writable by Octoleo!
/* Locale Settings */
public $offset = 'UTC';
/* Session settings */
public $lifetime = 15; // Session time
public $session_handler = 'database';
public $session_filesystem_path = '';
public $session_memcached_server_host = 'localhost';
public $session_memcached_server_port = 11211;
public $session_metadata = true;
public $session_redis_persist = 1;
public $session_redis_server_auth = '';
public $session_redis_server_db = 0;
public $session_redis_server_host = 'localhost';
public $session_redis_server_port = 6379;
/* Mail Settings */
public $mailonline = true;
public $mailer = 'mail';
public $mailfrom = '';
public $fromname = '';
public $massmailoff = false;
public $replyto = '';
public $replytoname = '';
public $sendmail = '/usr/sbin/sendmail';
public $smtpauth = false;
public $smtpuser = '';
public $smtppass = '';
public $smtphost = 'localhost';
public $smtpsecure = 'none';
public $smtpport = 25;
/* Meta Settings */
public $MetaDesc = 'Octoleo! - the dynamic portal engine and content management system';
public $MetaAuthor = true;
public $MetaVersion = false;
public $MetaRights = '';
public $robots = '';
public $sitename_pagetitles = 0;
/* Cookie Settings */
public $cookie_domain = '';
public $cookie_path = '';
}

View File

@ -0,0 +1,28 @@
# If the Joomla site is installed within a folder
# eg www.example.com/joomla/ then the robots.txt file
# MUST be moved to the site root
# eg www.example.com/robots.txt
# AND the joomla folder name MUST be prefixed to all of the
# paths.
# eg the Disallow rule for the /administrator/ folder MUST
# be changed to read
# Disallow: /joomla/administrator/
#
# For more information about the robots.txt standard, see:
# https://www.robotstxt.org/orig.html
User-agent: *
Disallow: /administrator/
Disallow: /bin/
Disallow: /cache/
Disallow: /cli/
Disallow: /components/
Disallow: /includes/
Disallow: /installation/
Disallow: /language/
Disallow: /layouts/
Disallow: /libraries/
Disallow: /logs/
Disallow: /modules/
Disallow: /plugins/
Disallow: /tmp/

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,141 @@
--
-- DATABASE STRUCTURE FOR GENERIC CMS (Adapted from Joomla!)
-- -- subject to change --
--
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Table structure for table `llewellyn_menu`
--
CREATE TABLE IF NOT EXISTS `llewellyn_menu` (
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL COMMENT 'The display title of the menu item.',
`alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'The SEF alias of the menu item.',
`path` varchar(1024) NOT NULL COMMENT 'The computed path of the menu item based on the alias field.',
`published` tinyint NOT NULL DEFAULT 0 COMMENT 'The published state of the menu link.',
`parent_id` int unsigned NOT NULL DEFAULT 1 COMMENT 'The parent menu item in the menu tree.',
`level` int unsigned NOT NULL DEFAULT 0 COMMENT 'The relative level in the tree.',
`item_id` int unsigned NOT NULL DEFAULT 0 COMMENT 'FK to llewellyn_item.id',
`checked_out` int unsigned COMMENT 'FK to llewellyn_users.id',
`checked_out_time` datetime COMMENT 'The time the menu item was checked out.',
`params` text NOT NULL COMMENT 'JSON encoded data for the menu item.',
`lft` int NOT NULL DEFAULT 0 COMMENT 'Nested set lft.',
`rgt` int NOT NULL DEFAULT 0 COMMENT 'Nested set rgt.',
`home` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Indicates if this menu item is the home or default page.',
`publish_up` datetime,
`publish_down` datetime,
PRIMARY KEY (`id`),
KEY `idx_item` (`item_id`),
KEY `idx_left_right` (`lft`,`rgt`),
KEY `idx_alias` (`alias`(100)),
KEY `idx_path` (`path`(100))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=102;
--
-- Table structure for table `llewellyn_session`
--
CREATE TABLE IF NOT EXISTS `llewellyn_session` (
`session_id` varbinary(192) NOT NULL,
`guest` tinyint unsigned DEFAULT 1,
`time` int NOT NULL DEFAULT 0,
`data` mediumtext,
`userid` int DEFAULT 0,
`username` varchar(150) DEFAULT '',
PRIMARY KEY (`session_id`),
KEY `userid` (`userid`),
KEY `time` (`time`),
KEY `guest` (`guest`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table `llewellyn_users`
--
CREATE TABLE IF NOT EXISTS `llewellyn_users` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(400) NOT NULL DEFAULT '',
`username` varchar(150) NOT NULL DEFAULT '',
`email` varchar(100) NOT NULL DEFAULT '',
`password` varchar(100) NOT NULL DEFAULT '',
`block` tinyint NOT NULL DEFAULT 0,
`sendEmail` tinyint DEFAULT 0,
`registerDate` datetime NOT NULL,
`lastvisitDate` datetime,
`activation` varchar(100) NOT NULL DEFAULT '',
`params` text NOT NULL,
`lastResetTime` datetime COMMENT 'Date of last password reset',
`resetCount` int NOT NULL DEFAULT 0 COMMENT 'Count of password resets since lastResetTime',
`requireReset` tinyint NOT NULL DEFAULT 0 COMMENT 'Require user to reset password on next login',
PRIMARY KEY (`id`),
KEY `idx_name` (`name`(100)),
KEY `idx_block` (`block`),
UNIQUE KEY `idx_username` (`username`),
KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table `llewellyn_usergroups`
--
CREATE TABLE IF NOT EXISTS `llewellyn_usergroups` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
`parent_id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Adjacency List Reference Id',
`lft` int NOT NULL DEFAULT 0 COMMENT 'Nested set lft.',
`rgt` int NOT NULL DEFAULT 0 COMMENT 'Nested set rgt.',
`title` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_usergroup_parent_title_lookup` (`parent_id`,`title`),
KEY `idx_usergroup_title_lookup` (`title`),
KEY `idx_usergroup_adjacency_lookup` (`parent_id`),
KEY `idx_usergroup_nested_set_lookup` (`lft`,`rgt`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table `llewellyn_user_usergroup_map`
--
CREATE TABLE IF NOT EXISTS `llewellyn_user_usergroup_map` (
`user_id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Foreign Key to llewellyn_users.id',
`group_id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Foreign Key to llewellyn_usergroups.id',
PRIMARY KEY (`user_id`,`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table `llewellyn_item`
--
CREATE TABLE IF NOT EXISTS `llewellyn_item` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL DEFAULT '',
`alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
`introtext` mediumtext NOT NULL,
`fulltext` mediumtext NOT NULL,
`state` tinyint NOT NULL DEFAULT 0,
`created` datetime NOT NULL,
`created_by` int unsigned NOT NULL DEFAULT 0,
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
`modified` datetime NOT NULL,
`modified_by` int unsigned NOT NULL DEFAULT 0,
`checked_out` int unsigned,
`checked_out_time` datetime NULL DEFAULT NULL,
`publish_up` datetime NULL DEFAULT NULL,
`publish_down` datetime NULL DEFAULT NULL,
`version` int unsigned NOT NULL DEFAULT 1,
`ordering` int NOT NULL DEFAULT 0,
`metakey` text,
`metadesc` text NOT NULL,
`hits` int unsigned NOT NULL DEFAULT 0,
`metadata` text NOT NULL,
`featured` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Set if article is featured.',
PRIMARY KEY (`id`),
KEY `idx_checkout` (`checked_out`),
KEY `idx_state` (`state`),
KEY `idx_createdby` (`created_by`),
KEY `idx_alias` (`alias`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

View File

@ -0,0 +1,20 @@
{% extends "index.twig" %}
{% block title %}Octoleo Dashboard{% endblock %}
{% block content %}
<div class="uk-container uk-margin">
<h1 class="uk-article-title">Octoleo CMS Dashboard</h1>
<div class="uk-grid-small uk-child-width-expand@s uk-text-center" uk-grid>
<div>
<div class="uk-card uk-card-default uk-card-body"><a href="{{ url() }}index.php?dashboard=users">Users</a></div>
</div>
<div>
<div class="uk-card uk-card-default uk-card-body"><a href="{{ url() }}index.php?dashboard=menus">Menus</a></div>
</div>
<div>
<div class="uk-card uk-card-default uk-card-body"><a href="{{ url() }}index.php?dashboard=items">Items</a></div>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,37 @@
{% extends "index.twig" %}
{% block title %}Edit{% endblock %}
{% block content %}
<div class="uk-container">
<form>
<fieldset class="uk-fieldset">
<legend class="uk-legend">Legend</legend>
<div class="uk-margin">
<input class="uk-input" type="text" placeholder="Input">
</div>
<div class="uk-margin">
<select class="uk-select">
<option>Option 01</option>
<option>Option 02</option>
</select>
</div>
<div class="uk-margin">
<textarea class="uk-textarea" rows="5" placeholder="Textarea"></textarea>
</div>
<div class="uk-margin uk-grid-small uk-child-width-auto uk-grid">
<label><input class="uk-radio" type="radio" name="radio2" checked> A</label>
<label><input class="uk-radio" type="radio" name="radio2"> B</label>
</div>
<div class="uk-margin uk-grid-small uk-child-width-auto uk-grid">
<label><input class="uk-checkbox" type="checkbox" checked> A</label>
<label><input class="uk-checkbox" type="checkbox"> B</label>
</div>
<div class="uk-margin">
<input class="uk-range" type="range" value="2" min="0" max="10" step="0.1">
</div>
</fieldset>
</form>
</div>
<!-- Source: https://getuikit.com/docs/form -->
{% endblock %}

View File

@ -0,0 +1,29 @@
{% extends 'index.twig' %}
{% block bodyNavigation %}{% endblock %}
{% block title %}Octoleo Error{% endblock %}
{% block content %}
<div class="uk-container uk-margin">
{% if exception.code in [404, 405] %}
<h2>We Couldn't Find It</h2>
<p class="lead">Sorry, we couldn't find the page matching your request. Try using the navigation to find what you were looking for?</p>
{% else %}
<h2>Ouch, That's an Error</h2>
<p class="lead">Well this is embarrassing, seems there was an error processing this request. Perhaps try again? Or <a href="https://github.com/octoleo/crm/issues/new?title=[FW Site]&body=Please state the nature of your development emergency">file an issue</a> so we can address it.</p>
{% endif %}
{% if appDebug %}
<h3><span class="badge badge-danger">{{ exception.code|default(0) }}</span> {{ exception|get_class }}</h3>
<p>{{ exception.message|strip_root_path }}</p>
{% if exception.previous %}
{% set _previous = exception.previous %}
<h3>Previous Exception</h3>
<h4><span class="badge badge-danger">{{ exception.code|default(0) }}</span> {{ exception|get_class }}</h4>
<p>{{ exception.message|strip_root_path }}</p>
{% endif %}
{% endif %}
</div>
{% endblock %}

View File

@ -0,0 +1,9 @@
{% macro load_footer() %}
<div class="uk-section uk-section-primary">
<div class="uk-container uk-container-small">
<div class="uk-text-center uk-card-body">
<small>Copyright © Generic Company. All Rights Reserved. | Octoleo CMS</small>
</div>
</div>
</div>
{% endmacro %}

View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<!-- For Responsive -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
<!-- UIkit CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.13.7/dist/css/uikit.min.css" />
<!-- UIkit JS -->
<script src="https://cdn.jsdelivr.net/npm/uikit@3.13.7/dist/js/uikit.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/uikit@3.13.7/dist/js/uikit-icons.min.js"></script>
<!-- End for Responsive -->
<!-- For SEO -->
<title>{% block title %}Octoleo! Framework, a framework for developing PHP applications{% endblock %}</title>
<meta charset="utf-8">
<meta name="description" content="{% block metaDescription %}The Octoleo! Framework provides a structurally sound foundation on which to build applications in PHP, which is easy to adapt and extend. Let's find out more!{% endblock %}">
<meta name="generator" content="Octoleo! Framework" />
<meta property="og:description" content="{{ block('metaDescription') }}" />
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="Octoleo! Framework" />
<meta property="og:title" content="{{ block('title') }}" />
<meta property="og:type" content="{% block metaOgType %}website{% endblock %}" />
<meta property="og:url" content="{{ request_uri() }}" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@Octoleo" />
<meta name="twitter:description" content="{{ block('metaDescription') }}" />
<meta name="twitter:title" content="{{ block('title') }}" />
{% block metadata %}{% endblock %}
<!-- End for SEO -->
<!-- For Misc -->
<link href="favicon.ico" rel="shortcut icon" />
<!-- End for misc -->
{% block headCSS %}{% endblock %}
{% block headJavaScript %}{% endblock %}
</head>
{% block body %}{% endblock %}
</html>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,13 @@
{% extends "header.twig" %}
{% block body %}
<body id="go">
{% block bodyNavigation %}{% import 'nav.twig' as macros %}{{ macros.load_admin_navbar() }}{% endblock %}
<main>
{% block content %}{% endblock %}
</main>
{% block footerContent %}{% import 'footer.twig' as macros %}{{ macros.load_footer() }}{% endblock %}
{% block bodyJavaScript %}{% endblock %}
{{ url }}
</body>
{% endblock %}

View File

@ -0,0 +1,52 @@
{% extends "index.twig" %}
{% block title %}Items{% endblock %}
{% block content %}
<div class="uk-container uk-margin">
<h1 class="uk-article-title">Items</h1>
<a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=item">Create</a>
<table class="uk-table uk-table-justify uk-table-divider">
<thead>
<tr>
<th class="uk-width-small">Table Heading</th>
<th>Table Heading</th>
<th>Table Heading</th>
</tr>
</thead>
<tbody>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=item&id=1">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=item&id=2">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=item&id=3">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=item&id=4">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=item&id=5">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=item&id=6">Edit</a></td>
</tr>
</tbody>
</table>
</div>
<!-- Source: https://getuikit.com/docs/table -->
{% endblock %}

View File

@ -0,0 +1,18 @@
{% extends "index.twig" %}
{% block bodyNavigation %}{% endblock %}
{% block content %}
<div class="uk-height-1-1 uk-background-cover uk-overflow-hidden uk-flex"
style="background-color: #fff; background-image: url('https://source.unsplash.com/random/1920x800/?yachts'); min-height: 500px; height: 100%">
<div class="uk-width-1-2@m uk-text-center uk-margin-auto uk-margin-auto-vertical uk-overlay uk-overlay-default">
<h1>Login Here</h1>
<form action="{{ url() }}index.php?dashboard=access" method="post">
<input name="username" class="uk-input uk-width-1-2" type="text" placeholder="Username">
<input name="password" class="uk-input uk-width-1-2" type="password" placeholder="*************">
<input type="submit" class="uk-button uk-button-primary uk-width-1-2" value="Login"/>
<a class="uk-button uk-width-1-2" href="{{ url() }}?account=signup">Create Account</a>
</form>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,50 @@
{% extends "index.twig" %}
{% block content %}
<div class="uk-container uk-margin">
<h1 class="uk-article-title">Menus</h1>
<a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=menu">Create</a>
<table class="uk-table uk-table-justify uk-table-divider">
<thead>
<tr>
<th class="uk-width-small">Table Heading</th>
<th>Table Heading</th>
<th>Table Heading</th>
</tr>
</thead>
<tbody>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=menu&id=1">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=menu&id=2">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=menu&id=3">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=menu&id=4">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=menu&id=5">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=menu&id=6">Edit</a></td>
</tr>
</tbody>
</table>
</div>
<!-- Source: https://getuikit.com/docs/table -->
{% endblock %}

View File

@ -0,0 +1,19 @@
{% macro load_admin_navbar() %}
<nav class="uk-navbar-container" uk-navbar>
<div class="uk-navbar-left">
<ul class="uk-navbar-nav">
<li><a href="{{ url() }}index.php?dashboard">Dashboard</a></li>
<li><a href="{{ url() }}index.php?dashboard=users">Users</a></li>
<li><a href="{{ url() }}index.php?dashboard=menus">Menus</a></li>
<li><a href="{{ url() }}index.php?dashboard=items">Items</a></li>
</ul>
</div>
<div class="uk-navbar-right">
<ul class="uk-navbar-nav">
<li class="uk-active"><a href="{{ url() }}index.php?dashboard=logout">Logout</a></li>
<li class="uk-active"><a href="/">Site</a></li>
</ul>
</div>
</nav>
{% endmacro %}
<!-- Source: https://getuikit.com/docs/navbar -->

View File

@ -0,0 +1,21 @@
{% extends "index.twig" %}
{% block bodyNavigation %}{% endblock %}
{% block content %}
<div class="uk-height-1-1 uk-background-cover uk-overflow-hidden uk-flex"
style="min-height: 500px; height: 100%">
<div class="uk-width-1-2@m uk-text-center uk-margin-auto uk-margin-auto-vertical uk-overlay uk-overlay-default">
<h1>Create Account</h1>
<form action="{{ url() }}index.php?dashboard=signup" method="post">
<input name="name" class="uk-input uk-width-1-2" type="text" placeholder="Name">
<input name="username" class="uk-input uk-width-1-2" type="text" placeholder="Username">
<input name="email" class="uk-input uk-width-1-2" type="text" placeholder="Email">
<input name="password" class="uk-input uk-width-1-2" type="password" placeholder="password">
<input name="password2" class="uk-input uk-width-1-2" type="password" placeholder="confirm password">
<input type="submit" class="uk-button uk-button-primary uk-width-1-2" value="Create Account"/>
<a class="uk-button uk-width-1-2" href="{{ url() }}">Login</a>
</form>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,32 @@
{% extends "index.twig" %}
{% block title %}Users{% endblock %}
{% block content %}
<div class="uk-container uk-margin">
<h1 class="uk-article-title">Users</h1>
<a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=user">Create</a>
<table class="uk-table uk-table-justify uk-table-divider">
<thead>
<tr>
<th class="uk-width-small">Table Heading</th>
<th>Table Heading</th>
<th>Table Heading</th>
</tr>
</thead>
<tbody>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=user&id=1">Edit</a></td>
</tr>
<tr>
<td>Table Data</td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</td>
<td><a class="uk-button uk-button-default" href="{{ url() }}index.php?dashboard=user&id=2">Edit</a></td>
</tr>
</tbody>
</table>
</div>
<!-- Source: https://getuikit.com/docs/table -->
{% endblock %}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,27 @@
{% extends 'index.twig' %}
{% block title %}Octoleo Error{% endblock %}
{% block content %}
<div class="uk-container uk-margin">
{% if exception.code in [404, 405] %}
<h2>We Couldn't Find It</h2>
<p class="lead">Sorry, we couldn't find the page matching your request. Try using the navigation to find what you were looking for?</p>
{% else %}
<h2>Ouch, That's an Error</h2>
<p class="lead">Well this is embarrassing, seems there was an error processing this request. Perhaps try again? Or <a href="https://github.com/octoleo/crm/issues/new?title=[FW Site]&body=Please state the nature of your development emergency">file an issue</a> so we can address it.</p>
{% endif %}
{% if appDebug %}
<h3><span class="badge badge-danger">{{ exception.code|default(0) }}</span> {{ exception|get_class }}</h3>
<p>{{ exception.message|strip_root_path }}</p>
{% if exception.previous %}
{% set _previous = exception.previous %}
<h3>Previous Exception</h3>
<h4><span class="badge badge-danger">{{ exception.code|default(0) }}</span> {{ exception|get_class }}</h4>
<p>{{ exception.message|strip_root_path }}</p>
{% endif %}
{% endif %}
</div>
{% endblock %}

View File

@ -0,0 +1,9 @@
{% macro load_footer() %}
<div class="uk-section uk-section-primary">
<div class="uk-container uk-container-small">
<div class="uk-text-center uk-card-body">
<small>Copyright © Generic Company. All Rights Reserved. | Octoleo CMS</small>
</div>
</div>
</div>
{% endmacro %}

View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<!-- For Responsive -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
<!-- UIkit CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.13.7/dist/css/uikit.min.css" />
<!-- UIkit JS -->
<script src="https://cdn.jsdelivr.net/npm/uikit@3.13.7/dist/js/uikit.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/uikit@3.13.7/dist/js/uikit-icons.min.js"></script>
<!-- End for Responsive -->
<!-- For SEO -->
<title>{% block title %}Octoleo! Framework, a framework for developing PHP applications{% endblock %}</title>
<meta charset="utf-8">
<meta name="description" content="{% block metaDescription %}The Octoleo! Framework provides a structurally sound foundation on which to build applications in PHP, which is easy to adapt and extend. Let's find out more!{% endblock %}">
<meta name="generator" content="Octoleo! Framework" />
<meta property="og:description" content="{{ block('metaDescription') }}" />
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="Octoleo! Framework" />
<meta property="og:title" content="{{ block('title') }}" />
<meta property="og:type" content="{% block metaOgType %}website{% endblock %}" />
<meta property="og:url" content="{{ request_uri() }}" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@Octoleo" />
<meta name="twitter:description" content="{{ block('metaDescription') }}" />
<meta name="twitter:title" content="{{ block('title') }}" />
{% block metadata %}{% endblock %}
<!-- End for SEO -->
<!-- For Misc -->
<link href="favicon.ico" rel="shortcut icon" />
<!-- End for misc -->
{% block headCSS %}{% endblock %}
{% block headJavaScript %}{% endblock %}
</head>
{% block body %}{% endblock %}
</html>

View File

@ -0,0 +1,10 @@
{% extends "index.twig" %}
{% block content %}
<div class="uk-margin-remove-top uk-height-large uk-background-cover uk-overflow-hidden uk-flex" style="background-image: url('https://source.unsplash.com/random/1920x500/?yachts');">
<div class="uk-width-1-2@m uk-text-center uk-margin-auto uk-margin-auto-vertical uk-overlay uk-overlay-default">
<h1>Welcome</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,12 @@
{% extends "header.twig" %}
{% block body %}
<body id="go">
{% block bodyNavigation %}{% import 'nav.twig' as macros %}{{ macros.load_site_navbar() }}{% endblock %}
<main>
{% block content %}{% endblock %}
</main>
{% block footerContent %}{% import 'footer.twig' as macros %}{{ macros.load_footer() }}{% endblock %}
{% block bodyJavaScript %}{% endblock %}
</body>
{% endblock %}

View File

@ -0,0 +1,28 @@
{% macro load_site_navbar() %}
<nav class="uk-navbar-container" uk-navbar>
<div class="uk-navbar-center">
<ul class="uk-navbar-nav">
<li class="uk-active"><a href="{{ url() }}">Home</a></li>
<li>
<a href="{{ url() }}products">Products</a>
<div class="uk-navbar-dropdown">
<ul class="uk-nav uk-navbar-dropdown-nav">
<li class="uk-active"><a href="{{ url() }}products/yachts">Yachts</a></li>
<li><a href="{{ url() }}products/ski-boats">Ski Boats</a></li>
<li><a href="{{ url() }}products/drones">Drones</a></li>
</ul>
</div>
</li>
<li><a href="{{ url() }}blog">Blog</a></li>
<li><a href="{{ url() }}about-us">About Us</a></li>
</ul>
</div>
<div class="uk-navbar-right">
<ul class="uk-navbar-nav">
<li><a href="{{ url() }}location">Location</a></li>
<li><a href="{{ url() }}contact-us">Contact Us</a></li>
</ul>
</div>
</nav>
{% endmacro %}
<!-- Source: https://getuikit.com/docs/navbar -->

View File

@ -0,0 +1,14 @@
{% extends "index.twig" %}
{% block content %}
<div class="uk-margin-remove-top uk-height-large uk-background-cover uk-overflow-hidden uk-flex" style="background-image: url('https://source.unsplash.com/random/1920x500/?yachts');">
<div class="uk-width-1-2@m uk-text-center uk-margin-auto uk-margin-auto-vertical uk-overlay uk-overlay-default">
<h1>{{ page }}</h1>
{% if details == '' %}
<p>YOU ARE IN PAGES</p>
{% else %}
<p>You are into {{ details }}</p>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,34 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Language" content="en-GB">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Octoleo: Environment Setup Incomplete</title><!-- Sets the page title, IMPORTANT DO NOT REMOVE -->
<style>html{background:#ee2a00;background:radial-gradient(ellipse at center,#f1f1f1 0,#ee2a00 100%);background-attachment:fixed;background-repeat:no-repeat}body{background-color:transparent;color:#555;font:14px/18px sans-serif}body,ol,ul{margin:0;padding:0}ol,ul{list-style:none}a{color:#0084b4;text-decoration:none}a:focus,a:hover{text-decoration:underline}p a{line-height:inherit}.container{align-items:center;display:flex;flex-direction:column;height:100vh;justify-content:center;margin:0 auto;overflow:hidden;position:relative;width:100%}.alert-main{background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:5px;box-shadow:0 0 10px rgba(0,0,0,.05);display:block;margin:0 20px;padding:20px 60px;position:relative}svg{bottom:-120px;position:absolute;right:-70px;-webkit-transform:rotate(10deg);transform:rotate(10deg);width:400px;z-index:-1}h1,p{text-rendering:optimizeLegibility;position:relative;text-align:center;z-index:10}h1{font-size:40px;font-weight:200;line-height:1;margin:18px 0 0;text-shadow:0 1px 2px rgba(0,0,0,.2)}label,p{color:#777;font-size:18px;font-weight:300;line-height:25px;margin:10px 0 20px}p a{color:#1c3d5c;font-weight:700}.link-help{background-color:#f5f5f5;border:1px solid rgba(0,0,0,.1);border-radius:.25rem;font-size:1rem;font-weight:400;padding:.4rem .85rem;text-decoration:none}.link-help:hover{background-color:#eee;text-decoration:none}.footer{font-size:11px;margin:8px 20px;text-align:left}.footer ul{margin-bottom:5px}.footer li{display:inline;line-height:20px;margin:0 5px}.footer a,.footer li{color:#1c3d5c}.footer a:hover{color:#59b0ff}.links{display:block;font-size:1rem;margin-left:auto;margin-right:auto;margin-top:4rem;text-align:center}.links li{display:inline-block;margin-top:20px}@media screen and (max-width:480px){.container{height:auto;padding-bottom:20px;padding-top:20px}h1{font-size:30px}.link-help{white-space:nowrap}}</style><!-- Sets the page styling, IMPORTANT DO NOT REMOVE -->
</head>
<body>
<div class="container">
<div class="container-main">
<div class="alert-main">
<h1 id="headerText">Environment Setup Incomplete</h1>
<p><span id="descText1">It looks like you are trying to run Octoleo! from our git repository. To do so requires you complete a couple of extra steps first.</span></p>
<p style="text-align: left;">
0. Make sure you have <a href="https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos">composer</a> installed on your system.
<br />
1. In your terminal go to the root folder of your Octoleo website where you will find the <u>composer.json</u> file.
<br />
2. Run the following command <code>composer install</code> to install all PHP packages.
</p>
</div>
<div class="footer">
<ul class="links">
<li><a href="https://www.octoleo.org/">Octoleo</a></li> -
<li><a href="https://git.vdm.dev/octoleo/">Help</a></li>
</ul>
</div>
</div>
</div>
<!-- source: https://github.com/joomla/joomla-cms/blob/4.1-dev/templates/system/build_incomplete.html -->
</body>
</html>

View File

@ -0,0 +1,27 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Language" content="en-GB">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Octoleo: unsupported PHP version</title><!-- Sets the page title, IMPORTANT DO NOT REMOVE -->
<style>html{background:#ee2a00;background:radial-gradient(ellipse at center,#f1f1f1 0,#ee2a00 100%);background-attachment:fixed;background-repeat:no-repeat}body{background-color:transparent;color:#555;font:14px/18px sans-serif}body,ol,ul{margin:0;padding:0}ol,ul{list-style:none}a{color:#0084b4;text-decoration:none}a:focus,a:hover{text-decoration:underline}p a{line-height:inherit}.container{align-items:center;display:flex;flex-direction:column;height:100vh;justify-content:center;margin:0 auto;overflow:hidden;position:relative;width:100%}.alert-main{background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:5px;box-shadow:0 0 10px rgba(0,0,0,.05);display:block;margin:0 20px;padding:20px 60px;position:relative}svg{bottom:-120px;position:absolute;right:-70px;-webkit-transform:rotate(10deg);transform:rotate(10deg);width:400px;z-index:-1}h1,p{text-rendering:optimizeLegibility;position:relative;text-align:center;z-index:10}h1{font-size:40px;font-weight:200;line-height:1;margin:18px 0 0;text-shadow:0 1px 2px rgba(0,0,0,.2)}label,p{color:#777;font-size:18px;font-weight:300;line-height:25px;margin:10px 0 20px}p a{color:#1c3d5c;font-weight:700}.link-help{background-color:#f5f5f5;border:1px solid rgba(0,0,0,.1);border-radius:.25rem;font-size:1rem;font-weight:400;padding:.4rem .85rem;text-decoration:none}.link-help:hover{background-color:#eee;text-decoration:none}.footer{font-size:11px;margin:8px 20px;text-align:left}.footer ul{margin-bottom:5px}.footer li{display:inline;line-height:20px;margin:0 5px}.footer a,.footer li{color:#1c3d5c}.footer a:hover{color:#59b0ff}.links{display:block;font-size:1rem;margin-left:auto;margin-right:auto;margin-top:4rem;text-align:center}.links li{display:inline-block;margin-top:20px}@media screen and (max-width:480px){.container{height:auto;padding-bottom:20px;padding-top:20px}h1{font-size:30px}.link-help{white-space:nowrap}}</style><!-- Sets the page styling, IMPORTANT DO NOT REMOVE -->
</head>
<body>
<div class="container">
<div class="container-main">
<div class="alert-main">
<h1 id="headerText">Sorry, your PHP version is not supported</h1>
<p><span id="descText1">Your host needs to use PHP version {{phpversion}} or newer to run this version of Octoleo!</span></p>
</div>
<div class="footer">
<ul class="links">
<li><a href="https://www.octoleo.org/">Octoleo</a></li> -
<li><a href="https://git.vdm.dev/octoleo/">Help</a></li>
</ul>
</div>
</div>
</div>
<!-- source: https://github.com/joomla/joomla-cms/blob/4.1-dev/templates/system/incompatible.html -->
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More