Compare commits
30 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d951ac852e | |||
| ebf029e7dd | |||
| 2226e91faf | |||
| e3775e1045 | |||
| 2df08a0e7d | |||
| b37316ce64 | |||
| b4f758f0b5 | |||
| 7ac0f6c850 | |||
| 9f21c3a87e | |||
| 6b20d046d1 | |||
| 17b6df73ff | |||
| 47c7003e3b | |||
| 0b21909a78 | |||
|
|
90aefd81c9 | ||
| e5f42a129e | |||
|
|
261f61b33c | ||
| 40c9f8cc39 | |||
| 1096ecdf54 | |||
| da0a8e03b2 | |||
| 0a27ec5ac7 | |||
| e63812141f | |||
| a2db88ee38 | |||
| db97d829b8 | |||
| 87edea507b | |||
| be2968143a | |||
| ba301238d4 | |||
| 1cb0e161bf | |||
| 65dc1dd8a5 | |||
| 9ec2c248b2 | |||
| 4b1dbb054c |
34 changed files with 3560 additions and 2891 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -5,6 +5,8 @@ vendor/*
|
|||
modules/*
|
||||
!modules/welcome
|
||||
!modules/admin
|
||||
!modules/phatemplates
|
||||
!modules/phangoapp
|
||||
settings/config.php
|
||||
setting/config_test.php
|
||||
|
||||
|
|
|
|||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "modules/admin/media/js/jsutils"]
|
||||
path = modules/admin/media/js/jsutils
|
||||
url = https://git.cuchulu.com/paramecio/jsutils
|
||||
675
LICENSE.txt
Normal file
675
LICENSE.txt
Normal file
|
|
@ -0,0 +1,675 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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
|
||||
<http://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
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
87
index.php
87
index.php
|
|
@ -2,37 +2,90 @@
|
|||
|
||||
use PhangoApp\PhaUtils\Utils;
|
||||
|
||||
include('libraries/Utils.php');
|
||||
include('libraries/Routes.php');
|
||||
ob_start();
|
||||
|
||||
//include('libraries/Utils.php');
|
||||
//include('libraries/Routes.php');
|
||||
|
||||
if(is_file(__DIR__.'/vendor/autoload.php')) {
|
||||
|
||||
include(__DIR__.'/vendor/autoload.php');
|
||||
|
||||
}
|
||||
|
||||
//ob_start();
|
||||
|
||||
spl_autoload_register(function($class_name) {
|
||||
|
||||
//include($nombre_clase . '.php';
|
||||
//echo $class_name;
|
||||
switch($class_name) {
|
||||
//Simple autoload for modules, first element is module, second element is the file to load.
|
||||
|
||||
case 'PhangoApp\PDO\MySQL':
|
||||
$arr_library=explode('\\', $class_name);
|
||||
|
||||
include('./libraries/PDO.php');
|
||||
if(count($arr_library)>1) {
|
||||
|
||||
break;
|
||||
$module=strtolower($arr_library[0]);
|
||||
|
||||
$last_path=implode('/', array_slice($arr_library, 1, count($arr_library)));
|
||||
|
||||
$library=strtolower($last_path);
|
||||
|
||||
if(is_file('modules/'.$module.'/libraries/'.$library.'.php')) {
|
||||
|
||||
include('modules/'.$module.'/libraries/'.$library.'.php');
|
||||
|
||||
}
|
||||
else if(is_file('modules/'.$module.'/libraries/'.strtolower($arr_library[1]).'.php')) {
|
||||
|
||||
include_once('modules/'.$module.'/libraries/'.strtolower($arr_library[1]).'.php');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
if(is_file('vendor/autoload.php')) {
|
||||
|
||||
include('vendor/autoload.php');
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
Utils::load_config('config');
|
||||
|
||||
if(!PhangoApp\PhaRouter\Config::$on_other) {
|
||||
|
||||
if(!PhangoApp\PhaRouter\Config::$get_path_info) {
|
||||
|
||||
$path_info=isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$path_info=str_replace(PhangoApp\PhaRouter\Config::$base_url.'index.php', '', $_SERVER['REQUEST_URI']);
|
||||
|
||||
if($path_info===PhangoApp\PhaRouter\Config::$base_url) {
|
||||
|
||||
$path_info='';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if(!isset($_GET['path_info'])) {
|
||||
|
||||
$path_info='';
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$path_info=$_GET['path_info'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo \PhangoApp\PhaRouter\get_route($path_info);
|
||||
|
||||
ob_end_flush();
|
||||
//ob_end_flush();
|
||||
$final_content=ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
echo $final_content;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,20 @@ class Config {
|
|||
|
||||
static public $modules_allowed=['welcome' => 'modules/welcome'];
|
||||
|
||||
static public $libraries_allowed=[];
|
||||
|
||||
static public $base_url='';
|
||||
|
||||
static public $data=[];
|
||||
|
||||
static public $index_file='index.php/';
|
||||
|
||||
static public $get_path_info=false;
|
||||
|
||||
static public $on_other=false;
|
||||
|
||||
static public $on_proxy=false;
|
||||
|
||||
}
|
||||
|
||||
/*Examples
|
||||
|
|
@ -20,7 +32,9 @@ class Config {
|
|||
* Url: http://domain.com/index.php/{module}/index/{arg1}/{arg2} -> modules/module/controller_index.php AppController->App($args);
|
||||
*/
|
||||
|
||||
function get_controller($controller, $args=[]) {
|
||||
function get_controller($path_info, $controller, $args=[]) {
|
||||
|
||||
$controller=__DIR__.'/../'.$controller;
|
||||
|
||||
if(is_file($controller)) {
|
||||
|
||||
|
|
@ -30,6 +44,8 @@ function get_controller($controller, $args=[]) {
|
|||
|
||||
$controller=new \AppController();
|
||||
|
||||
$controller->path_info=$path_info;
|
||||
|
||||
//return $controller->App($args);
|
||||
return call_user_func_array(array($controller, 'App'), $args);
|
||||
|
||||
|
|
@ -44,8 +60,12 @@ function get_controller($controller, $args=[]) {
|
|||
|
||||
echo 'Page not found';
|
||||
|
||||
if(!\PhangoApp\PhaRouter\Config::$on_other) {
|
||||
|
||||
http_response_code(404);
|
||||
|
||||
}
|
||||
|
||||
exit(1);
|
||||
|
||||
}
|
||||
|
|
@ -68,7 +88,7 @@ function get_route($path_info) {
|
|||
|
||||
$controller=\PhangoApp\PhaRouter\Config::$modules_allowed[\PhangoApp\PhaRouter\Config::$home_module].'/controllers/app.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($controller, []);
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, []);
|
||||
|
||||
break;
|
||||
|
||||
|
|
@ -80,7 +100,7 @@ function get_route($path_info) {
|
|||
|
||||
$controller=$module_path.'/controllers/app.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($controller, []);
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, []);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +114,7 @@ function get_route($path_info) {
|
|||
|
||||
$controller=$module_path.'/controllers/'.$arr_path[2].'.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($controller, []);
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, []);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +130,7 @@ function get_route($path_info) {
|
|||
|
||||
$args=array_slice($arr_path, 2, count($arr_path));
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($controller, $args);
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, $args);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +143,7 @@ function get_route($path_info) {
|
|||
|
||||
$controller=\PhangoApp\PhaRouter\Config::$modules_allowed[\PhangoApp\PhaRouter\Config::$home_module].'/controllers/app.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($controller, []);
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, []);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -131,8 +151,12 @@ function get_route($path_info) {
|
|||
|
||||
echo 'Page not found';
|
||||
|
||||
if(!\PhangoApp\PhaRouter\Config::$on_other) {
|
||||
|
||||
http_response_code(404);
|
||||
|
||||
}
|
||||
|
||||
exit(1);
|
||||
|
||||
|
||||
|
|
@ -173,9 +197,9 @@ function filter_path($path_info) {
|
|||
|
||||
class Url {
|
||||
|
||||
static public function make_url($module, $script='', $file='', $args=[]) {
|
||||
static public function make_url($module, $script='', $args=[]) {
|
||||
|
||||
$url='/'.$module;
|
||||
$url=$module;
|
||||
|
||||
if($script!='') {
|
||||
|
||||
|
|
@ -183,25 +207,19 @@ class Url {
|
|||
|
||||
}
|
||||
|
||||
if($file!='') {
|
||||
|
||||
$url.='/'.$file;
|
||||
|
||||
}
|
||||
|
||||
if(count($args)>0) {
|
||||
|
||||
$url.='/'.implode('/', $args);
|
||||
|
||||
}
|
||||
|
||||
return Config::$base_url.'/index.php'.$url;
|
||||
return Config::$base_url.Config::$index_file.$url;
|
||||
|
||||
}
|
||||
|
||||
static public function make_media_url($file) {
|
||||
|
||||
return Config::$base_url.'/'.$file;
|
||||
return Config::$base_url.$file;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -209,6 +227,16 @@ class Url {
|
|||
|
||||
class Controller {
|
||||
|
||||
public $path_info='';
|
||||
|
||||
public function json($arr_return) {
|
||||
|
||||
$final_return=json_encode($arr_return);
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
return $final_return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -395,13 +395,13 @@ class Utils {
|
|||
|
||||
//Get randomly elements from the randomly generated array.
|
||||
|
||||
$c=count($disorder_abc);
|
||||
$c=count($disorder_abc)-1;
|
||||
|
||||
$password_final='';
|
||||
|
||||
for($x=0;$x<$length_pass;$x++) {
|
||||
|
||||
$num_element_pass=random_int(0, $c-1);
|
||||
$num_element_pass=random_int(0, $c);
|
||||
|
||||
$password_final.=$disorder_abc[$num_element_pass];
|
||||
|
||||
|
|
@ -591,12 +591,12 @@ class Utils {
|
|||
* @param $path Path where search the config.
|
||||
*/
|
||||
|
||||
static public function load_config($name_config, $path="./settings")
|
||||
static public function load_config($name_config, $path="settings")
|
||||
{
|
||||
|
||||
//load_libraries(array($name_config), PhangoVar::$base_path.'/modules/'.$module.'/config/');
|
||||
|
||||
$file=$path.'/'.$name_config.'.php';
|
||||
$file=__DIR__.'/../'.$path.'/'.$name_config.'.php';
|
||||
|
||||
if(is_file($file) && !isset(Utils::$cache_config[$file]))
|
||||
{
|
||||
|
|
|
|||
15
libraries/composer-first.json
Normal file
15
libraries/composer-first.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"repositories": [
|
||||
{
|
||||
|
||||
"type": "vcs",
|
||||
"url": "https://git.cuchulu.com/phangoapp/wpdo"
|
||||
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"phangoapp/wpdo": "dev-master"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +1,35 @@
|
|||
<?php
|
||||
|
||||
use PhangoApp\PhaView\View;
|
||||
use PhangoApp\PDO\MySQL;
|
||||
//use PhangoApp\PhaView\View;
|
||||
use PhangoApp\WPDO\WPDO;
|
||||
use PhangoApp\PhaRouter\Url;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
//use PhangoApp\PhaModels\Webmodel;
|
||||
|
||||
include('./modules/admin/libraries/login.php');
|
||||
//include('./modules/admin/libraries/login.php');
|
||||
|
||||
function controller($switch='') {
|
||||
//include('modules/admin/libraries/tplcontroller.php');
|
||||
|
||||
session_start();
|
||||
class AppController extends Admin\TplController\TplController {
|
||||
|
||||
switch($switch) {
|
||||
public function app($op='') {
|
||||
|
||||
switch($op) {
|
||||
|
||||
default:
|
||||
|
||||
if(PhangoModule\Admin\login()) {
|
||||
if($this->check_login()) {
|
||||
|
||||
if($switch=='') {
|
||||
//Default admin page.
|
||||
|
||||
echo View::load_view(['title' => 'Admin', 'content' => ''], 'dashboard');
|
||||
echo $this->tpl->load_template('layout', ['title' => 'Admin', 'path_module' => 'admin.home']);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
//Include module admin.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
header('Location: '.PhangoApp\PhaRouter\Url::make_url('admin', 'app', 'login'));
|
||||
header('Location: '.PhangoApp\PhaRouter\Url::make_url('admin', 'app', ['login']));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -38,77 +37,164 @@ function controller($switch='') {
|
|||
|
||||
case 'login':
|
||||
|
||||
$conn=MySQL::get_pdo_connection();
|
||||
$this->db->connect();
|
||||
|
||||
$sth=$conn->query('SELECT count(*) as num_items from useradmin');
|
||||
$c_user=$this->db->select_count('useradmin', '', []);
|
||||
|
||||
$count=$sth->fetch()[0];
|
||||
$error=1;
|
||||
|
||||
if($count==0) {
|
||||
$error_form=['username_error' => ''];
|
||||
|
||||
header('Location: '.PhangoApp\PhaRouter\Url::make_url('admin', 'app', 'register'));
|
||||
if(!$c_user) {
|
||||
|
||||
header('Location: '.Url::make_url('admin', 'app', ['signup']));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if($_SERVER['REQUEST_METHOD']=='POST') {
|
||||
|
||||
//Check csrf token first.
|
||||
|
||||
if(PhangoApp\PhaRouter\Config::$on_proxy) {
|
||||
|
||||
$ip=$_SERVER['HTTP_CLIENT_IP'] ?? $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? '';
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$ip=$_SERVER['REMOTE_ADDR'] ?? '';
|
||||
|
||||
}
|
||||
|
||||
echo View::load_view(['login' => 1], 'login');
|
||||
if($ip!='') {
|
||||
|
||||
break;
|
||||
$arr_tries=$this->db->select_a_row('login_tries', [], 'WHERE ip=?', [$ip]);
|
||||
|
||||
case 'login_check':
|
||||
$now=date("Y-m-d H:i:s");
|
||||
|
||||
$conn=MySQL::get_pdo_connection();
|
||||
if($arr_tries) {
|
||||
|
||||
$data=['error' => 1];
|
||||
$timestamp_5_min=strtotime($now)-300;
|
||||
$timestamp_last_login=strtotime($arr_tries['date']);
|
||||
|
||||
$username=$_POST['username'];
|
||||
if($timestamp_5_min>$timestamp_last_login) {
|
||||
|
||||
$password=$_POST['password'];
|
||||
|
||||
$sth=$conn->prepare('SELECT id, password from useradmin where username=?');
|
||||
|
||||
$sth->execute([$username]);
|
||||
|
||||
$rows=$sth->fetchAll();
|
||||
|
||||
if(count($rows)>0) {
|
||||
|
||||
$password_hash=$rows[0]['password'];
|
||||
|
||||
if(password_verify($password, $password_hash)) {
|
||||
|
||||
$data['error']=0;
|
||||
|
||||
$_SESSION['phango_login']=1;
|
||||
$this->db->delete('login_tries', 'WHERE ip=?', [$ip]);
|
||||
$arr_tries=false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
$num_tries=$arr_tries['num_tries'] ?? 0;
|
||||
|
||||
return json_encode($data);
|
||||
if($num_tries<5) {
|
||||
|
||||
break;
|
||||
$username=trim($_POST['username'] ?? '');
|
||||
$password=trim($_POST['password'] ?? '');
|
||||
|
||||
case 'register':
|
||||
if($username=='') {
|
||||
|
||||
$conn=MySQL::get_pdo_connection();
|
||||
$error_form['username_error']=_('Username empty');
|
||||
|
||||
$sth=$conn->query('SELECT count(*) as num_items from useradmin');
|
||||
}
|
||||
|
||||
$count=$sth->fetch()[0];
|
||||
$arr_user=$this->db->select_a_row('useradmin', [], 'WHERE username=?', [$username]);
|
||||
|
||||
if($count==0) {
|
||||
if($arr_user) {
|
||||
|
||||
echo View::load_view(['login' => 0], 'login');
|
||||
if(password_verify($password, $arr_user['password'])) {
|
||||
|
||||
$error=0;
|
||||
|
||||
$_SESSION['admin_login']=$arr_user['id'];
|
||||
$_SESSION['date_login']=date("Y-m-d H:i:s");
|
||||
$_SESSION['theme']=$arr_user['theme'];
|
||||
|
||||
if($arr_user['double_auth']) {
|
||||
|
||||
$_SESSION['double_auth']=1;
|
||||
|
||||
$auth_code=PhangoApp\PhaUtils\Utils::get_token(12);
|
||||
|
||||
$this->db->update('useradmin', ['auth_token' => password_hash($auth_code, PASSWORD_DEFAULT)], 'where id=?', [$arr_user['id']]);
|
||||
|
||||
// Send email
|
||||
|
||||
$this->send_mail_auth(PhangoApp\PhaRouter\Config::$email_site, PhangoApp\PhaRouter\Config::$portal_name, $arr_user['email'], $arr_user['username'], $auth_code);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$error_form['username_error']=_('Wrong user or password');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$error_form['username_error']=_('Wrong user or password');
|
||||
|
||||
}
|
||||
|
||||
if($error) {
|
||||
|
||||
if(!$arr_tries) {
|
||||
|
||||
$this->db->insert('login_tries', ['num_tries' => 0, 'ip' => $ip]);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$this->db->update('login_tries', ['num_tries' => $arr_tries['num_tries']+1, 'date' => date("Y-m-d H:i:s")], 'WHERE ip=?', [$ip]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$error_form['username_error']=_('Sorry, you need wait 5 minutes for retry login.');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$error_form['username_error']=_('Unknown error');
|
||||
|
||||
}
|
||||
|
||||
echo $this->json(['error' => $error, 'error_form' => $error_form, 'message' => '']);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
echo $this->tpl->load_template('login', ['title' => 'Login']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'signup_check':
|
||||
case 'signup':
|
||||
|
||||
$data=['error' => 0];
|
||||
$this->db->connect();
|
||||
|
||||
$c_user=$this->db->select_count('useradmin', '', []);
|
||||
|
||||
if(!$c_user) {
|
||||
|
||||
if($_SERVER['REQUEST_METHOD']=='POST') {
|
||||
|
||||
$error=0;
|
||||
|
||||
$error_form=[];
|
||||
|
||||
$arr_data=['username', 'email', 'password', 'repeat_password'];
|
||||
|
||||
|
|
@ -118,15 +204,12 @@ function controller($switch='') {
|
|||
|
||||
}
|
||||
|
||||
//$username=$_POST['username'];
|
||||
//^[A-Za-z0-9_-]+$
|
||||
|
||||
$username=trim($_POST['username']);
|
||||
|
||||
if(!preg_match('/^[A-Za-z0-9_-]+$/', $username)) {
|
||||
if(!preg_match('/^[A-Za-z0-9_-]+$/', $username) || $username=='') {
|
||||
|
||||
$data['error']=1;
|
||||
$data['username']=_("Error: empty value");
|
||||
$error=1;
|
||||
$error_form['username_error']=_("Error: empty value");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -134,8 +217,8 @@ function controller($switch='') {
|
|||
|
||||
if(!$email) {
|
||||
|
||||
$data['error']=1;
|
||||
$data['email']=_("Error: email is not valid");
|
||||
$error=1;
|
||||
$error_form['email_error']=_("Error: email is not valid");
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -145,44 +228,175 @@ function controller($switch='') {
|
|||
|
||||
if($password=='') {
|
||||
|
||||
$data['error']=1;
|
||||
$data['password']=_("Error: password empty");
|
||||
$error=1;
|
||||
$error_form['password_error']=_("Error: password empty");
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if($password!=$repeat_password) {
|
||||
|
||||
$data['error']=1;
|
||||
$data['password']=_("Error: password not equal");
|
||||
$error=1;
|
||||
$error_form['password_error']=_("Error: password not equal");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($data['error']==0) {
|
||||
if(!$error) {
|
||||
|
||||
$password=password_hash($password, PASSWORD_DEFAULT);
|
||||
if(!$this->db->insert('useradmin', ['username' => $username, 'password' => password_hash($password, PASSWORD_DEFAULT), 'email' => $email])) {
|
||||
|
||||
$conn=MySQL::get_pdo_connection();
|
||||
$error=1;
|
||||
|
||||
if(!$conn->prepare('INSERT into useradmin (`username`, `password`, `email`) VALUES (?, ?, ?)')->execute([$username, $password, $email])) {
|
||||
|
||||
$data['error']=1;
|
||||
$data['username']=_("Error: cannot insert the new user in database, check your database connection");
|
||||
$error_form['username_error']=_("Error: cannot create the user, please contact with the administrator");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//$sth->execute([$username, $password, $email]);
|
||||
echo $this->json(['error' => $error, 'error_form' => $error_form, 'message' => '']);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
echo $this->tpl->load_template('signup', ['title' => 'Signup']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'check_auth':
|
||||
|
||||
//Session expired.
|
||||
|
||||
if($this->check_login()) {
|
||||
|
||||
if($_SERVER['REQUEST_METHOD']=='POST') {
|
||||
|
||||
$this->db->connect();
|
||||
|
||||
$error=1;
|
||||
|
||||
$error_form['auth_code_error']='';
|
||||
|
||||
$auth_code=$_POST['auth_code'] ?? '';
|
||||
//($table, $fields, $where_sql='', $values=[])
|
||||
//$arr_tries=$this->db->select_a_row('login_tries', [], 'WHERE ip=?', [$ip]);
|
||||
$arr_user=$this->db->select_a_row('useradmin', [], 'WHERE id=?', [$_SESSION['admin_login']]);
|
||||
|
||||
if(password_verify($auth_code, $arr_user['auth_token'])) {
|
||||
|
||||
unset($_SESSION['double_auth']);
|
||||
|
||||
$_SESSION['theme']=$arr_user['theme'];
|
||||
|
||||
$error=0;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$error_form['auth_code_error']='Sorry, auth code wrong';
|
||||
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo $this->json(['error' => $error, 'error_form' => $error_form]);
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
else {
|
||||
|
||||
echo $this->tpl->load_template('check_auth', ['title' => 'Double auth']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
header('Location: '.PhangoApp\PhaRouter\Url::make_url('admin', 'app', ['login']));
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'logout':
|
||||
|
||||
$_SESSION=[];
|
||||
|
||||
header('Location: '.PhangoApp\PhaRouter\Url::make_url('admin'));
|
||||
|
||||
break;
|
||||
|
||||
case 'change_theme':
|
||||
|
||||
if($this->check_login()) {
|
||||
|
||||
settype($_GET['theme'], 'integer');
|
||||
|
||||
if($_GET['theme']>1 || $_GET['theme']<0) {
|
||||
|
||||
$_GET['theme']=0;
|
||||
|
||||
}
|
||||
|
||||
$error=0;
|
||||
|
||||
$message='';
|
||||
|
||||
$this->db->connect();
|
||||
|
||||
if(!$this->db->update('useradmin', ['theme' => $_GET['theme']], 'WHERE id=?', [$_SESSION['admin_login']])) {
|
||||
|
||||
$error=1;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$_SESSION['theme']=$_GET['theme'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo $this->json(['error' => $error, 'message' => $message]);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function send_mail_auth($email_from, $portal_name, $email_to, $name, $auth_code) {
|
||||
|
||||
$mail=new PHPMailer(true);
|
||||
|
||||
|
||||
try {
|
||||
|
||||
//$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
|
||||
$mail->isSMTP(); //Send using SMTP
|
||||
$mail->Host=\PhangoApp\PhaRouter\Config::$data['smtp_host']; //Set the SMTP server to send through
|
||||
$mail->SMTPAuth=true; //Enable SMTP authentication
|
||||
$mail->Username=PhangoApp\PhaRouter\Config::$data['smtp_username']; //SMTP username
|
||||
$mail->Password=PhangoApp\PhaRouter\Config::$data['smtp_password']; //SMTP password
|
||||
$mail->SMTPSecure=PHPMailer::ENCRYPTION_STARTTLS; //Enable implicit TLS encryption
|
||||
$mail->Port=PhangoApp\PhaRouter\Config::$data['smtp_port'] ?? 587; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
|
||||
$mail->CharSet='UTF-8';
|
||||
|
||||
$mail->setFrom($email_from, $portal_name);
|
||||
$mail->addAddress($email_to, $name);
|
||||
|
||||
$mail->Subject = 'Code for complete login';
|
||||
$mail->Body = 'We send to you a code for activate your account using double authentication: '.$auth_code;
|
||||
|
||||
$mail->send();
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
//echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
221
modules/admin/controllers/users.php
Normal file
221
modules/admin/controllers/users.php
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
<?php
|
||||
|
||||
//include('modules/admin/libraries/tplcontroller.php');
|
||||
|
||||
class GenerateAdminClass {
|
||||
|
||||
public $fields_edit;
|
||||
public $fields_list;
|
||||
public $db;
|
||||
public $table;
|
||||
public $url;
|
||||
public $tpl;
|
||||
public $json=false;
|
||||
|
||||
public function __construct($db, $table, $fields_edit, $fields_list, $url, $tpl) {
|
||||
|
||||
$this->db=$db;
|
||||
$this->table=$table;
|
||||
$this->fields_edit=$fields_edit;
|
||||
$this->fields_list=$fields_list;
|
||||
$this->url=$url;
|
||||
$this->tpl=$tpl;
|
||||
|
||||
}
|
||||
|
||||
public function show() {
|
||||
|
||||
$op=$_GET['op'] ?? '';
|
||||
|
||||
switch($op) {
|
||||
|
||||
default:
|
||||
|
||||
$this->json=false;
|
||||
|
||||
return $this->list();
|
||||
|
||||
break;
|
||||
|
||||
case 'get_list':
|
||||
|
||||
//$arr_model=$model->select_to_array();
|
||||
return $this->get_list();
|
||||
|
||||
break;
|
||||
|
||||
case 'edit':
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function get_list() {
|
||||
|
||||
|
||||
$error=1;
|
||||
|
||||
$message='';
|
||||
|
||||
$this->json=true;
|
||||
|
||||
#return {'items': items, 'error': 0, 'total_num_items': total_num_items}
|
||||
$items=[];
|
||||
|
||||
$total_num_items=0;
|
||||
|
||||
$this->db->connect();
|
||||
|
||||
$total_num_items=$this->db->select_count($this->table, '', []);
|
||||
|
||||
//select($table, $fields, $where_sql, $values)
|
||||
/*
|
||||
* begin_page=request.args.get('begin_page', 0)
|
||||
|
||||
try:
|
||||
begin_page=int(begin_page)
|
||||
except:
|
||||
begin_page=0
|
||||
|
||||
num_elements=request.args.get('num_elements', 0)
|
||||
|
||||
try:
|
||||
num_elements=int(num_elements)
|
||||
except:
|
||||
num_elements=20
|
||||
|
||||
order_field=request.args.get('order_field', 'date_reserved')
|
||||
|
||||
if not order_field in reservas.fields:
|
||||
order_field='date_reserved'
|
||||
|
||||
arr_order=['ASC', 'DESC']
|
||||
|
||||
try:
|
||||
|
||||
order=int(request.args.get('order', '0'))
|
||||
|
||||
if order<0 or order>1:
|
||||
order=0
|
||||
|
||||
except:
|
||||
|
||||
order=0*/
|
||||
|
||||
settype($_GET['begin_page'], 'integer');
|
||||
settype($_GET['num_elements'], 'integer');
|
||||
|
||||
$begin_page=$_GET['begin_page'];
|
||||
$num_elements=$_GET['num_elements'];
|
||||
|
||||
if($num_elements<=0) {
|
||||
|
||||
$num_elements=20;
|
||||
|
||||
}
|
||||
|
||||
$arr_order=['ASC', 'DESC'];
|
||||
|
||||
settype($_GET['order'], 'integer');
|
||||
|
||||
$order=$_GET['order'];
|
||||
|
||||
$order_field=array_key_first($this->fields_list);
|
||||
|
||||
$get_order_field=trim($_GET['order_field'] ?? '');
|
||||
|
||||
if(in_array($get_order_field, array_keys($this->fields_list), true) && $get_order_field!='') {
|
||||
|
||||
$order_field=$get_order_field;
|
||||
|
||||
}
|
||||
|
||||
$search_values=[$order_field, $arr_order[$order]];
|
||||
|
||||
$sql_search_text='WHERE 1=1';
|
||||
|
||||
settype($_GET['search_all_text'], 'string');
|
||||
|
||||
$search_all_text=trim($_GET['search_all_text']);
|
||||
|
||||
if($search_all_text!='') {
|
||||
|
||||
$arr_fields=[];
|
||||
$arr_values=[];
|
||||
|
||||
//$arr_values_sql=array_fill(0, count($this->fields_list), '?');
|
||||
foreach(array_keys($this->fields_list) as $field) {
|
||||
|
||||
$arr_fields[]='`'.$field.'` LIKE ?';
|
||||
$arr_values[]=$search_all_text.'%';
|
||||
}
|
||||
|
||||
$search_values=array_merge($arr_values, $search_values);
|
||||
$sql_search_text=$sql_search_text.' AND ('.implode(' OR ', $arr_fields).')';
|
||||
//$search_all_text='WHERE ';
|
||||
|
||||
}
|
||||
|
||||
$this->db->select($this->table, array_keys($this->fields_list), $sql_search_text.' order by ? ? limit '.$begin_page.','.$num_elements, $search_values);
|
||||
|
||||
//fwrite(STDERR, $sql_search_text.' order by ? ? limit '.$begin_page.','.$num_elements);
|
||||
//file_put_contents('php://stderr', var_export($search_values, true)." ".$sql_search_text.' order by ? ? limit '.$begin_page.','.$num_elements."\n");
|
||||
|
||||
foreach($this->db->get_result() as $v) {
|
||||
|
||||
$items[]=$v;
|
||||
|
||||
$items[count($items)-1]['options']='<a href="">'._('Edit').'</a><br /><a href="">'._('Delete').'</a>';
|
||||
|
||||
}
|
||||
|
||||
if($items) {
|
||||
|
||||
$error=0;
|
||||
|
||||
}
|
||||
|
||||
return ['items' =>$items, 'total_num_items' => $total_num_items, 'error' => $error, 'message' => $message];
|
||||
|
||||
}
|
||||
|
||||
public function list() {
|
||||
|
||||
return $this->tpl->load_template('list', ['fields_list' => $this->fields_list, 'table' => $this->db->tables[$this->table]->name, 'url' => $this->url]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class AppController extends Admin\AdminController\AdminController {
|
||||
|
||||
public function app($op='') {
|
||||
|
||||
$domain_url=\PhangoApp\PhaRouter\Config::$domain_url;
|
||||
|
||||
$admin=new GenerateAdminClass($this->db, 'useradmin', ['username', 'password', 'email', 'double_auth', 'theme'], ['username' => _('Username'), 'email' => _('Email')], $domain_url.\PhangoApp\PhaRouter\Url::make_url('admin', 'users'), $this->tpl);
|
||||
|
||||
$admin_html=$admin->show();
|
||||
|
||||
if(!$admin->json) {
|
||||
|
||||
echo $this->tpl->load_template('users', ['title' => _('Edit users'), 'path_module' => 'admin.users', 'content' => $admin_html]);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
echo $this->json($admin_html);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
25
modules/admin/libraries/admincontroller.php
Normal file
25
modules/admin/libraries/admincontroller.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Admin\AdminController;
|
||||
|
||||
use PhangoApp\WPDO;
|
||||
use PhaTemplates\Templates;
|
||||
|
||||
//include('modules/admin/libraries/tplcontroller.php');
|
||||
|
||||
class AdminController extends \Admin\TplController\TplController {
|
||||
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
if(!$this->check_login()) {
|
||||
|
||||
header('Location: '.\PhangoApp\PhaRouter\Url::make_url('admin', 'app', ['login']));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
9
modules/admin/libraries/settings.php
Normal file
9
modules/admin/libraries/settings.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Admin\Settings;
|
||||
|
||||
class Config {
|
||||
|
||||
static public $config_admin=[];
|
||||
|
||||
}
|
||||
65
modules/admin/libraries/tplcontroller.php
Normal file
65
modules/admin/libraries/tplcontroller.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace Admin\TplController;
|
||||
|
||||
use PhangoApp\WPDO;
|
||||
use PhaTemplates\Templates;
|
||||
|
||||
class TplController extends \PhangoApp\PhaRouter\Controller {
|
||||
|
||||
public $tpl;
|
||||
public $db;
|
||||
|
||||
public function __construct() {
|
||||
|
||||
session_start();
|
||||
|
||||
$useradmin=new WPDO\WTable('useradmin', ['id', 'username', 'password', 'email', 'double_auth', 'auth_token', 'theme']);
|
||||
|
||||
$login_tries=new WPDO\WTable('login_tries', ['ip', 'num_tries', 'date']);
|
||||
|
||||
$this->db=new WPDO\WPDO(['useradmin' => $useradmin, 'login_tries' => $login_tries]);
|
||||
|
||||
$this->tpl=new Templates(['theme/admin/templates', 'modules/admin/templates']);
|
||||
|
||||
}
|
||||
|
||||
public function check_login() {
|
||||
|
||||
if(isset($_SESSION['admin_login'])) {
|
||||
|
||||
if(isset($_SESSION['double_auth']) && $this->path_info!='/admin/app/check_auth') {
|
||||
|
||||
$now=date("Y-m-d H:i:s");
|
||||
|
||||
$timestamp_5_min=strtotime($now)-300;
|
||||
$timestamp_last_login=strtotime($_SESSION['date_login']);
|
||||
|
||||
if($timestamp_5_min>$timestamp_last_login) {
|
||||
|
||||
header('Location: '.\PhangoApp\PhaRouter\Url::make_url('admin', 'app', ['logout']));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
header('Location: '.\PhangoApp\PhaRouter\Url::make_url('admin', 'app', ['check_auth']));
|
||||
|
||||
}
|
||||
|
||||
die;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,28 +1,54 @@
|
|||
|
||||
/** {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}*/
|
||||
|
||||
body
|
||||
{
|
||||
|
||||
margin:0px;
|
||||
background-color:#f4f6f9;
|
||||
font-family: "Roboto", sans, sans-serif, serif;
|
||||
font-family: sans, sans-serif, serif;
|
||||
font-size: 16px;
|
||||
/*-webkit-transition: all 0.5s ease-in-out;
|
||||
transition: all 0.5s ease-in-out;
|
||||
-webkit-transition-property: background-color, color;
|
||||
transition-property: background-color, color;*/
|
||||
|
||||
}
|
||||
|
||||
a
|
||||
{
|
||||
body.dark {
|
||||
background-color: #232834;
|
||||
|
||||
color: #fbfbfb;
|
||||
/*-webkit-transition: all 0.5s ease-in-out;
|
||||
transition: all 0.5s ease-in-out;
|
||||
-webkit-transition-property: background-color, color;
|
||||
transition-property: background-color, color;*/
|
||||
|
||||
}
|
||||
|
||||
a {
|
||||
|
||||
color: #1c6280;
|
||||
|
||||
}
|
||||
|
||||
a:hover
|
||||
{
|
||||
a:hover {
|
||||
|
||||
color: #d54e21;
|
||||
|
||||
}
|
||||
|
||||
.dark a {
|
||||
|
||||
color: #5fa6c4;
|
||||
|
||||
}
|
||||
|
||||
#header
|
||||
{
|
||||
|
||||
|
|
@ -39,6 +65,14 @@ a:hover
|
|||
|
||||
}
|
||||
|
||||
.dark #header {
|
||||
|
||||
|
||||
|
||||
background-color:#1e1412;
|
||||
|
||||
}
|
||||
|
||||
#title_phango
|
||||
{
|
||||
font-size:28px;
|
||||
|
|
@ -99,6 +133,20 @@ h1 {
|
|||
|
||||
}
|
||||
|
||||
.dark h1 {
|
||||
|
||||
background-color:#000a22;
|
||||
color: #fbfbfb;
|
||||
border-color: #000;
|
||||
|
||||
}
|
||||
|
||||
.dark h2 {
|
||||
|
||||
color: #fbfbfb;
|
||||
|
||||
}
|
||||
|
||||
p {
|
||||
|
||||
border: solid #cbcbcb;
|
||||
|
|
@ -142,6 +190,16 @@ p {
|
|||
box-sizing: border-box;
|
||||
/* padding-bottom: 100px;*/
|
||||
overflow:hidden;
|
||||
height:100%;
|
||||
-webkit-box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75);
|
||||
-moz-box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75);
|
||||
box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75);
|
||||
}
|
||||
|
||||
.dark #menu {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#menu a
|
||||
|
|
@ -257,8 +315,23 @@ p {
|
|||
border: solid #cbcbcb;
|
||||
border-width: 0px 0px 1px 0px;
|
||||
min-height: 90vh;
|
||||
/*-webkit-transition: all 0.5s ease-in-out;
|
||||
transition: all 0.5s ease-in-out;*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
.dark .content_admin {
|
||||
|
||||
background-color: #1e202a;
|
||||
/*-webkit-transition: all 0.5s ease-in-out;
|
||||
transition: all 0.5s ease-in-out;*/
|
||||
border: solid #323232;
|
||||
border-width: 0px 0px 1px 0px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.content_admin i {
|
||||
|
||||
margin-right: 10px;
|
||||
|
|
@ -271,8 +344,10 @@ p {
|
|||
width:82%;
|
||||
padding:0px 0px 0px 0px;
|
||||
box-sizing: border-box;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.content
|
||||
{
|
||||
padding:0px 10px 5px 10px;
|
||||
|
|
@ -320,6 +395,13 @@ p {
|
|||
|
||||
}
|
||||
|
||||
.dark .form {
|
||||
|
||||
background-color: #1e202a;
|
||||
border-color: #323232;
|
||||
|
||||
}
|
||||
|
||||
.form textarea {
|
||||
|
||||
width:100%;
|
||||
|
|
@ -327,6 +409,13 @@ p {
|
|||
|
||||
}
|
||||
|
||||
.dark .form textarea {
|
||||
|
||||
background-color: #1e202a;
|
||||
color: #fbfbfb;
|
||||
|
||||
}
|
||||
|
||||
.form label {
|
||||
display: block;
|
||||
/*width: 150px;*/
|
||||
|
|
@ -408,6 +497,12 @@ table {
|
|||
|
||||
}
|
||||
|
||||
.dark .table_list {
|
||||
|
||||
border: solid #323232 1px;
|
||||
|
||||
}
|
||||
|
||||
.title_list td, .fields_span_title {
|
||||
|
||||
margin:0px;
|
||||
|
|
@ -423,6 +518,13 @@ table {
|
|||
|
||||
}
|
||||
|
||||
.dark .title_list td {
|
||||
|
||||
background-color:#000a22;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.fields_span_title, div.options_td , div.fields_span_table_data {
|
||||
|
||||
box-sizing: border-box;
|
||||
|
|
@ -449,6 +551,13 @@ table {
|
|||
|
||||
}
|
||||
|
||||
.dark .row_list td {
|
||||
|
||||
background-color: #2d313b;
|
||||
color: #fbfbfb;
|
||||
|
||||
}
|
||||
|
||||
div.fields_span_table_data {
|
||||
|
||||
box-sizing: border-box;
|
||||
|
|
@ -472,6 +581,13 @@ div.fields_span_table_data {
|
|||
|
||||
}
|
||||
|
||||
.dark .cont_text, .dark .cont {
|
||||
|
||||
background-color: #2d313b;
|
||||
border-color: #343434;
|
||||
|
||||
}
|
||||
|
||||
.cont_top {
|
||||
|
||||
border-width: 1px 1px 1px 1px;
|
||||
|
|
@ -518,6 +634,12 @@ div.fields_span_table_data {
|
|||
|
||||
}
|
||||
|
||||
.dark .error {
|
||||
|
||||
color: #ff3232;
|
||||
|
||||
}
|
||||
|
||||
.hidden_form
|
||||
{
|
||||
|
||||
|
|
@ -577,9 +699,11 @@ a:hover.no_choose_flag
|
|||
#center_body input {
|
||||
|
||||
border: solid #bcbcbc;
|
||||
border-width:1px;
|
||||
border-width:2px;
|
||||
border-radius:5px;
|
||||
background: #eeeeee;
|
||||
padding: 2px 4px;
|
||||
font-size:16px;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -589,6 +713,13 @@ a:hover.no_choose_flag
|
|||
|
||||
}
|
||||
|
||||
.dark #center_body input {
|
||||
|
||||
background-color: #2d313b;
|
||||
color: #fbfbfb;
|
||||
|
||||
}
|
||||
|
||||
#center_body input[type="submit"], #center_body input[type="button"], #center_body input[type="button"].button_blue
|
||||
{
|
||||
|
||||
|
|
@ -611,6 +742,12 @@ a:hover.no_choose_flag
|
|||
|
||||
}
|
||||
|
||||
.dark #center_body input[type="button"] {
|
||||
|
||||
background: #d08b2c;
|
||||
|
||||
}
|
||||
|
||||
#center_body input:hover[type="submit"], #center_body input[type="button"].button_blue
|
||||
{
|
||||
|
||||
|
|
@ -627,6 +764,15 @@ a:hover.no_choose_flag
|
|||
|
||||
}
|
||||
|
||||
#center_body input:hover[type="button"].button_blue
|
||||
{
|
||||
|
||||
background: #215181;
|
||||
cursor: pointer;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#center_body input[type="text"], #center_body input[type="password"]
|
||||
{
|
||||
|
||||
|
|
@ -647,6 +793,16 @@ a:hover.no_choose_flag
|
|||
border: solid #bcbcbc;
|
||||
border-width:1px;
|
||||
border-radius:5px;
|
||||
padding: 2px 5px;
|
||||
border: solid #cbcbcb 2px;
|
||||
font-size: 16px;
|
||||
|
||||
}
|
||||
|
||||
.dark #center_body select {
|
||||
|
||||
background-color: #2d313b;
|
||||
color: #fbfbfb;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -846,7 +1002,7 @@ a.form_button_tab:hover
|
|||
|
||||
#layer_loading {
|
||||
|
||||
z-index:50000;
|
||||
z-index:99999;
|
||||
/*background-color:rgba(0,0,0,0.4);*/
|
||||
/*opacity:0.5;*/
|
||||
position:absolute;
|
||||
|
|
@ -880,6 +1036,7 @@ a.form_button_tab:hover
|
|||
box-sizing: border-box;
|
||||
/* border: solid #fff 1px;*/
|
||||
float:left;
|
||||
overflow:hidden;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -889,6 +1046,7 @@ a.form_button_tab:hover
|
|||
box-sizing: border-box;
|
||||
/* border: solid #fff 1px;*/
|
||||
float:left;
|
||||
overflow:hidden;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -899,6 +1057,7 @@ a.form_button_tab:hover
|
|||
box-sizing: border-box;
|
||||
/*border: solid #f00 1px;*/
|
||||
float:left;
|
||||
overflow:hidden;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -908,6 +1067,7 @@ a.form_button_tab:hover
|
|||
box-sizing: border-box;
|
||||
/*border: solid #f00 1px;*/
|
||||
float:left;
|
||||
overflow:hidden;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -969,6 +1129,14 @@ h2.title_container {
|
|||
|
||||
}
|
||||
|
||||
.dark h2.title_container {
|
||||
|
||||
background-color: #2d313b;
|
||||
border-color: #343434;
|
||||
color: #fbfbfb;
|
||||
|
||||
}
|
||||
|
||||
.container_warning h2.title_container {
|
||||
|
||||
background:#dc3545;
|
||||
|
|
@ -1001,6 +1169,144 @@ h2.title_container {
|
|||
|
||||
}
|
||||
|
||||
.dark .container_content {
|
||||
|
||||
background-color: #2d313b;
|
||||
border-color: #343434;
|
||||
color: #fbfbfb;
|
||||
|
||||
}
|
||||
|
||||
/* Switch for dark mode */
|
||||
|
||||
/* switches css */
|
||||
|
||||
/* The switch - the box around the slider */
|
||||
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 40px;
|
||||
height: 16px;
|
||||
|
||||
}
|
||||
|
||||
/* Hide default HTML checkbox */
|
||||
.switch input {display:none;}
|
||||
|
||||
/* The slider */
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
height: 16px;
|
||||
width:38px;
|
||||
box-sizing: border-box;
|
||||
-webkit-box-sizing:border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* before is the checkbox */
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 22px;
|
||||
width: 22px;
|
||||
left: -1px;
|
||||
top: -3px;
|
||||
background-color: #fbfbfb;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #447211;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #447211;
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
-webkit-transform: translateX(21px);
|
||||
-ms-transform: translateX(21px);
|
||||
transform: translateX(21px);
|
||||
background-color: #7ed321;
|
||||
}
|
||||
|
||||
input:checked + .slider_grey {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
input:focus + .slider_grey {
|
||||
box-shadow: 0 0 1px #ccc;
|
||||
}
|
||||
|
||||
input:checked + .slider_grey:before {
|
||||
-webkit-transform: translateX(21px);
|
||||
-ms-transform: translateX(21px);
|
||||
transform: translateX(21px);
|
||||
background-color: #fbfbfb;
|
||||
}
|
||||
|
||||
|
||||
/* Rounded sliders */
|
||||
.slider.round {
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.container_switch {
|
||||
|
||||
margin-top:6px;
|
||||
display:inline-block;
|
||||
float:right;
|
||||
|
||||
}
|
||||
|
||||
.switch-btn {
|
||||
|
||||
position:absolute;
|
||||
/*border: solid #f00 1px;*/
|
||||
right:4px;
|
||||
top:8px;
|
||||
z-index:9999;
|
||||
|
||||
}
|
||||
|
||||
.switch-slider {
|
||||
|
||||
text-align:center;
|
||||
display: inline-block;
|
||||
|
||||
}
|
||||
|
||||
.switch-text {
|
||||
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
position:relative;
|
||||
top: -4px;
|
||||
left:-2px;
|
||||
color: #000;
|
||||
|
||||
}
|
||||
|
||||
.dark .switch-text {
|
||||
|
||||
color: #fbfbfb;
|
||||
|
||||
}
|
||||
|
||||
/* Media queries */
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
Before Width: | Height: | Size: 434 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
4
modules/admin/media/js/jquery.min.js
vendored
4
modules/admin/media/js/jquery.min.js
vendored
File diff suppressed because one or more lines are too long
1
modules/admin/media/js/jsutils
Submodule
1
modules/admin/media/js/jsutils
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit a915e7be5a47709ad98c38b298893e254876a166
|
||||
9
modules/admin/settings/config_admin.php
Normal file
9
modules/admin/settings/config_admin.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
use Admin\Settings\Config;
|
||||
|
||||
Config::$config_admin[]=[_('Users Admin')];
|
||||
|
||||
Config::$config_admin[]=[_('Edit users'), $this->make_url('admin', 'users'), 'admin.users', '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" width="24" style="fill: currentColor;display: inline-block;vertical-align: -.130em;position:relative;left:-6px;top:2px;"><!--!Font Awesome Free v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 312C386.3 312 440 258.3 440 192C440 125.7 386.3 72 320 72C253.7 72 200 125.7 200 192C200 258.3 253.7 312 320 312zM290.3 368C191.8 368 112 447.8 112 546.3C112 562.7 125.3 576 141.7 576L498.3 576C514.7 576 528 562.7 528 546.3C528 447.8 448.2 368 349.7 368L290.3 368z"/></svg>'];
|
||||
|
||||
//config_admin.append([users_edit, 'paramecio2.modules.admin.admin.ausers', 'admin_app.ausers', '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" width="24" style="fill: currentColor;display: inline-block;vertical-align: -.130em;position:relative;left:-6px;top:2px;"><!--!Font Awesome Free v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 312C386.3 312 440 258.3 440 192C440 125.7 386.3 72 320 72C253.7 72 200 125.7 200 192C200 258.3 253.7 312 320 312zM290.3 368C191.8 368 112 447.8 112 546.3C112 562.7 125.3 576 141.7 576L498.3 576C514.7 576 528 562.7 528 546.3C528 447.8 448.2 368 349.7 368L290.3 368z"/></svg>'])
|
||||
68
modules/admin/templates/check_auth.php
Normal file
68
modules/admin/templates/check_auth.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?=$this->layout('login_tpl', ['title' => $title])?>
|
||||
<?=$this->start('content')?>
|
||||
<form method="post" name="auth_submit" id="auth_submit">
|
||||
<p align="center" style="padding: 0px 10px;"><?=_('Check your email for get instructions for complete login with double auth or')?> <a href="<?=$this->make_url('admin', 'app', ['logout'])?>">logout</a> and login again with other user</p>
|
||||
<p><label for="auth_code"></label><input type="text" name="auth_code" id="auth_code_form" placeholder="<?=_('Code')?>"/></p>
|
||||
<p class="error" id="auth_code_error"></p>
|
||||
<?=PhangoApp\PhaUtils\Utils::set_csrf_key($name_token='csrf_token', $length_token=80)?>
|
||||
<p>
|
||||
<input type="submit" id="button_submit" class="button" value="<?=_('Send auth code')?>" />
|
||||
</p>
|
||||
</form>
|
||||
<?=$this->end('content')?>
|
||||
<?=$this->start('footer_js')?>
|
||||
<script language="Javascript">
|
||||
$(document).ready( function () {
|
||||
|
||||
$("#auth_submit").submit( function () {
|
||||
|
||||
$('.error').html('');
|
||||
|
||||
$('#loader-wrapper').show();
|
||||
|
||||
$.ajax({
|
||||
url: "<?=$this->make_url('admin', 'app', ['check_auth'])?>",
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
data: {'auth_code': $('#auth_code_form').val()},
|
||||
success: function (data) {
|
||||
|
||||
if(data.error==0)
|
||||
{
|
||||
console.log('Success');
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
location.href="<?=$this->make_url('admin')?>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
$('#csrf_token').attr('value', data.csrf_token);
|
||||
|
||||
$('#auth_code_error').html(data.error_form.auth_code_error);
|
||||
}
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
alert('Error');
|
||||
|
||||
console.log(data);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<?=$this->end('footer_js')?>
|
||||
218
modules/admin/templates/layout.php
Normal file
218
modules/admin/templates/layout.php
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
<?php
|
||||
|
||||
|
||||
//use
|
||||
|
||||
$theme=$_SESSION['theme'] ?? 0;
|
||||
|
||||
$dark_checked='';
|
||||
$dark_css='';
|
||||
|
||||
if($theme=='1') {
|
||||
|
||||
$dark_checked='checked';
|
||||
$dark_css='dark';
|
||||
|
||||
}
|
||||
|
||||
foreach(PhangoApp\PhaRouter\Config::$modules_allowed as $module) {
|
||||
|
||||
//echo $module;
|
||||
|
||||
if(is_file($module.'/settings/config_admin.php')) {
|
||||
|
||||
include($module.'/settings/config_admin.php');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
<title><?=$title?></title>
|
||||
<link href="<?=$this->make_media_url('modules/admin/media/css/admin.css')?>" rel="stylesheet" />
|
||||
<link href="<?=$this->make_media_url('modules/admin/media/css/responsive-nav.css')?>" rel="stylesheet" />
|
||||
<link href="<?=$this->make_media_url('modules/admin/media/css/tooltipster.bundle.min.css')?>" rel="stylesheet" />
|
||||
<?=$this->section('extra_css')?>
|
||||
<script language="Javascript" src="<?=$this->make_media_url('modules/admin/media/js/jquery.min.js')?>"></script>
|
||||
<script language="Javascript" src="<?=$this->make_media_url('modules/admin/media/js/responsive-nav.min.js')?>"></script>
|
||||
<script language="Javascript" src="<?=$this->make_media_url('modules/admin/media/js/tooltipster.bundle.min.js')?>"></script>
|
||||
<?=$this->section('extra_js')?>
|
||||
<?=$this->section('extra_header')?>
|
||||
</head>
|
||||
<body class="<?=$dark_css?>">
|
||||
<div id="layer_loading"><div id="container_loading"><div class="lds-dual-ring"></div></div></div>
|
||||
<div id="languages_general">
|
||||
</div>
|
||||
<div id="logout">
|
||||
<a href="<?=$this->make_url('admin', 'app', ['logout'])?>"><i class="fa fa-power-off" aria-hidden="true"></i> <?=_('Logout')?></a>
|
||||
</div>
|
||||
|
||||
<div id="center_body">
|
||||
<div id="header">
|
||||
<a href="#nav" id="toggle"><i class="fa fa-bars" aria-hidden="true"></i><span>Menu</span></a>
|
||||
<span id="title_phango"><?=PhangoApp\PhaRouter\Config::$portal_name?></span>
|
||||
</div>
|
||||
<div class="content_admin">
|
||||
|
||||
<nav id="menu" class="nav-collapse">
|
||||
<ul>
|
||||
<li class="menu_title">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" width="22" style="fill: currentColor;display: inline-block;vertical-align: -.130em;position:relative;left:-3px;top:2px;">
|
||||
<!--!Font Awesome Free v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.-->
|
||||
<path d="M259.1 73.5C262.1 58.7 275.2 48 290.4 48L350.2 48C365.4 48 378.5 58.7 381.5 73.5L396 143.5C410.1 149.5 423.3 157.2 435.3 166.3L503.1 143.8C517.5 139 533.3 145 540.9 158.2L570.8 210C578.4 223.2 575.7 239.8 564.3 249.9L511 297.3C511.9 304.7 512.3 312.3 512.3 320C512.3 327.7 511.8 335.3 511 342.7L564.4 390.2C575.8 400.3 578.4 417 570.9 430.1L541 481.9C533.4 495 517.6 501.1 503.2 496.3L435.4 473.8C423.3 482.9 410.1 490.5 396.1 496.6L381.7 566.5C378.6 581.4 365.5 592 350.4 592L290.6 592C275.4 592 262.3 581.3 259.3 566.5L244.9 496.6C230.8 490.6 217.7 482.9 205.6 473.8L137.5 496.3C123.1 501.1 107.3 495.1 99.7 481.9L69.8 430.1C62.2 416.9 64.9 400.3 76.3 390.2L129.7 342.7C128.8 335.3 128.4 327.7 128.4 320C128.4 312.3 128.9 304.7 129.7 297.3L76.3 249.8C64.9 239.7 62.3 223 69.8 209.9L99.7 158.1C107.3 144.9 123.1 138.9 137.5 143.7L205.3 166.2C217.4 157.1 230.6 149.5 244.6 143.4L259.1 73.5zM320.3 400C364.5 399.8 400.2 363.9 400 319.7C399.8 275.5 363.9 239.8 319.7 240C275.5 240.2 239.8 276.1 240 320.3C240.2 364.5 276.1 400.2 320.3 400z"/></svg><?=_('Applications')?></li>
|
||||
<?php
|
||||
|
||||
foreach(Admin\Settings\Config::$config_admin as $admin) {
|
||||
|
||||
$class_selected='';
|
||||
$link_text='';
|
||||
|
||||
if(count($admin)>=3) {
|
||||
|
||||
if($admin[2]==$path_module) {
|
||||
|
||||
$class_selected='selected_menu';
|
||||
|
||||
}
|
||||
|
||||
$icon_module='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" width="22" style="fill: currentColor;display: inline-block;vertical-align: -.130em;position:relative;left:-3px;top:2px;"><!--!Font Awesome Free v7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M528 320C528 205.1 434.9 112 320 112C205.1 112 112 205.1 112 320C112 434.9 205.1 528 320 528C434.9 528 528 434.9 528 320zM64 320C64 178.6 178.6 64 320 64C461.4 64 576 178.6 576 320C576 461.4 461.4 576 320 576C178.6 576 64 461.4 64 320z"/></svg>';
|
||||
|
||||
if(count($admin)>3) {
|
||||
|
||||
$icon_module=$admin[3];
|
||||
|
||||
}
|
||||
|
||||
$link_text=$admin[0];
|
||||
|
||||
?>
|
||||
<li><a href="<?=$admin[1]?>" class="<?=$class_selected?>">
|
||||
<?=$icon_module?>
|
||||
<?=$link_text?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
|
||||
}
|
||||
else if(count($admin)==1) {
|
||||
|
||||
$link_text=$admin[0];
|
||||
?>
|
||||
<li><div class="father_admin"><?=$link_text?></div></li>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="contents">
|
||||
<h1><?=$title?></h1>
|
||||
<div class="switch-btn">
|
||||
<div class="switch-text">
|
||||
<?=_('Dark theme')?>
|
||||
</div>
|
||||
<div class="switch-slider">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="theme" value="1" id="theme" <?=$dark_checked?>/>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_SESSION['flash'])) {
|
||||
?>
|
||||
<div class="flash"><?=$_SESSION['flash']?></div>
|
||||
<?php
|
||||
unset($_SESSION['flash']);
|
||||
}
|
||||
?>
|
||||
<script>setTimeout(function () { $(".flash").fadeOut(); }, 3000);</script>
|
||||
<?=$this->section('content')?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="loading_ajax">
|
||||
</div>
|
||||
<script>
|
||||
var navigation = responsiveNav(".nav-collapse", {customToggle: "#toggle"});
|
||||
|
||||
$('.tooltip').tooltipster({
|
||||
animation: 'fade',
|
||||
delay: 100,
|
||||
trigger: 'click'
|
||||
});
|
||||
|
||||
const slider = document.querySelector('input[name="theme"]');
|
||||
|
||||
slider.addEventListener("change", function () {
|
||||
|
||||
//Block button while send to ajax.
|
||||
|
||||
$(this).prop("disabled",true);
|
||||
|
||||
var dark='';
|
||||
|
||||
if (this.checked) {
|
||||
document.body.classList.add("dark");
|
||||
|
||||
dark='1';
|
||||
|
||||
} else {
|
||||
document.body.classList.remove("dark");
|
||||
|
||||
dark='0';
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "<?=$this->make_url('admin', 'app', ['change_theme'])?>?theme="+dark,
|
||||
type: 'GET',
|
||||
data: {},
|
||||
success: function (data) {
|
||||
|
||||
if(!data.error) {
|
||||
|
||||
console.log('Changed to dark in all pages');
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
console.log('Cannot set dark theme in all pages!');
|
||||
|
||||
}
|
||||
|
||||
$(slider).prop("disabled",false);
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
|
||||
alert('Error: '+data.status+' '+data.statusText);
|
||||
|
||||
$(slider).prop("disabled", false);
|
||||
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#layer_loading').hide();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<?=$this->section('footer_js')?>
|
||||
</body>
|
||||
</html>
|
||||
34
modules/admin/templates/list.php
Normal file
34
modules/admin/templates/list.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<table id="<?=$table?>_table" class="table_list">
|
||||
<tr class="title_list"><td><?=_('Username')?></td><td><?=_('Email')?><td><?=('Opciones')?></td></tr>
|
||||
</table>
|
||||
<?=$this->start('footer_js')?>
|
||||
<script src="<?=$this->make_media_url('modules/admin/media/js/jsutils/ajax_list.js')?>"></script>
|
||||
<script src="<?=$this->make_media_url('modules/admin/media/js/jsutils/popup.js', 'lasala')?>"></script>
|
||||
<script>
|
||||
|
||||
options_list={'url': '<?=$url?>/?op=get_list', 'order_fields': [
|
||||
|
||||
<?php
|
||||
foreach($fields_list as $key => $val) {
|
||||
echo "'".$key."',\n";
|
||||
}
|
||||
?>
|
||||
'<?=_('Options')?>'
|
||||
|
||||
], 'num_elements': 20, 'search_all': true};
|
||||
|
||||
fields=[
|
||||
|
||||
<?php
|
||||
foreach($fields_list as $key => $val) {
|
||||
echo "'".$key."',\n";
|
||||
}
|
||||
?>
|
||||
'<?=_('options')?>'
|
||||
|
||||
];
|
||||
|
||||
<?=$table?>_table=$('#<?=$table?>_table').ajaxListSimple(fields, options_list);
|
||||
|
||||
</script>
|
||||
<?=$this->end('footer_js')?>
|
||||
69
modules/admin/templates/login.php
Normal file
69
modules/admin/templates/login.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?=$this->layout('login_tpl', ['title' => $title])?>
|
||||
<?=$this->start('content')?>
|
||||
<form method="post" name="login_submit" id="login_submit">
|
||||
<p><label for="username"></label><input type="text" name="username" id="username_form" placeholder="<?=_('Username')?>"/></p>
|
||||
<p class="error" id="username_error"></p>
|
||||
<p><input type="password" name="password" id="password_form" placeholder="<?=_('Password')?>"/></p>
|
||||
<p class="error" id="password_error"></p>
|
||||
<?=PhangoApp\PhaUtils\Utils::set_csrf_key($name_token='csrf_token', $length_token=80)?>
|
||||
<p>
|
||||
<input type="submit" id="button_submit" class="button" value="<?=_('Login')?>" />
|
||||
</p>
|
||||
</form>
|
||||
<?=$this->end('content')?>
|
||||
<?=$this->start('footer_js')?>
|
||||
<script language="Javascript">
|
||||
$(document).ready( function () {
|
||||
|
||||
$("#login_submit").submit( function () {
|
||||
|
||||
$('.error').html('');
|
||||
|
||||
$('#loader-wrapper').show();
|
||||
|
||||
$.ajax({
|
||||
url: "<?=$this->make_url('admin', 'app', ['login'])?>",
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
data: {'username': $('#username_form').val(), 'password': $('#password_form').val(), 'csrf_token': $('#csrf_token').val()},
|
||||
success: function (data) {
|
||||
|
||||
if(data.error==0)
|
||||
{
|
||||
console.log('Success');
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
location.href="<?=$this->make_url('admin')?>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
$('#csrf_token').attr('value', data.csrf_token);
|
||||
|
||||
$('#username_error').html(data.error_form.username_error);
|
||||
}
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
alert('Error');
|
||||
|
||||
console.log(data);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<?=$this->end('footer_js')?>
|
||||
140
modules/admin/templates/login_tpl.php
Normal file
140
modules/admin/templates/login_tpl.php
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?=$title?></title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
|
||||
margin:0px;
|
||||
background-color: #060502;
|
||||
|
||||
font-family: sans-serif;
|
||||
color: #fbfbfb;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
|
||||
}
|
||||
|
||||
#container {
|
||||
|
||||
/*margin-right:auto;
|
||||
margin-left:auto;*/
|
||||
min-width: 400px;
|
||||
background-color: #000;
|
||||
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
||||
margin-top: 40px;
|
||||
border-radius: 0.75rem;
|
||||
border-top: 4px solid #4f46e5;
|
||||
text-align:center;
|
||||
padding: 15px 5px;
|
||||
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin: 0 auto 0 auto;
|
||||
height: 4rem;
|
||||
width: 4rem;
|
||||
color: #fbfbfb; /* Índigo 600 */
|
||||
}
|
||||
|
||||
input {
|
||||
|
||||
width: 300px;
|
||||
border: solid #454545 2px;
|
||||
border-radius: 6px;
|
||||
font-size: 28px;
|
||||
|
||||
}
|
||||
|
||||
.button {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 18px;
|
||||
transition: background-color 0.3s ease;
|
||||
border: solid #454545 2px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: #0056b3; /* Un azul más oscuro */
|
||||
}
|
||||
|
||||
.error {
|
||||
|
||||
color: #ee0000;
|
||||
|
||||
}
|
||||
|
||||
/*Loader layer*/
|
||||
|
||||
#loader-wrapper {
|
||||
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
background-color: transparent;
|
||||
|
||||
z-index: 99999;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
opacity: 1;
|
||||
transition: opacity 0.5s ease-out;
|
||||
/*display: none;*/
|
||||
}
|
||||
|
||||
|
||||
.loader-hidden {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
|
||||
.spinner {
|
||||
border: 8px solid #f3f3f3;
|
||||
border-top: 8px solid #007bff;
|
||||
border-radius: 50%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
</style>
|
||||
<?=$this->section('header_js')?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="loader-wrapper" style="display:none;">
|
||||
<div class="spinner"></div>
|
||||
</div>
|
||||
<div id="container">
|
||||
<h1><?=$title?></h1>
|
||||
<p align="center">
|
||||
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" stroke="currentColor" stroke-width="2" style="fill: currentColor;"><!--!Font Awesome Free v7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M470.5 463.6C451.4 416.9 405.5 384 352 384L288 384C234.5 384 188.6 416.9 169.5 463.6C133.9 426.3 112 375.7 112 320C112 205.1 205.1 112 320 112C434.9 112 528 205.1 528 320C528 375.7 506.1 426.2 470.5 463.6zM430.4 496.3C398.4 516.4 360.6 528 320 528C279.4 528 241.6 516.4 209.5 496.3C216.8 459.6 249.2 432 288 432L352 432C390.8 432 423.2 459.6 430.5 496.3zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM320 304C297.9 304 280 286.1 280 264C280 241.9 297.9 224 320 224C342.1 224 360 241.9 360 264C360 286.1 342.1 304 320 304zM232 264C232 312.6 271.4 352 320 352C368.6 352 408 312.6 408 264C408 215.4 368.6 176 320 176C271.4 176 232 215.4 232 264z"/></svg>
|
||||
</p>
|
||||
<?=$this->section('content')?>
|
||||
</div>
|
||||
<script src="<?=$this->make_media_url('modules/admin/media/js/jquery.min.js')?>"></script>
|
||||
<?=$this->section('footer_js')?>
|
||||
</body>
|
||||
</html>
|
||||
67
modules/admin/templates/signup.php
Normal file
67
modules/admin/templates/signup.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?=$this->layout('login_tpl', ['title' => 'Signup'])?>
|
||||
<?=$this->start('content')?>
|
||||
<form method="post" name="register_submit" id="register_submit">
|
||||
<p><label for="username"></label><input type="text" name="username" id="username_form" placeholder="<?=_('Username')?>"/></p>
|
||||
<p class="error" id="username_error"></p>
|
||||
<p><input type="password" name="password" id="password_form" placeholder="<?=_('Password')?>"/></p>
|
||||
<p class="error" id="password_error"></p>
|
||||
<p><input type="password" name="repeat_password" id="repeat_password_form" placeholder="<?=_('Repeat Password')?>"/></p>
|
||||
<p class="error" id="repeat_password_error"></p>
|
||||
<p><input type="text" name="email" id="email_form" placeholder="<?=_('Email')?>"/></p>
|
||||
<?=PhangoApp\PhaUtils\Utils::set_csrf_key($name_token='csrf_token', $length_token=80)?>
|
||||
<p class="error" id="email_error"></p>
|
||||
<p>
|
||||
<input type="submit" id="button_submit" class="button" value="<?=_('Create user')?>" />
|
||||
</p>
|
||||
</form>
|
||||
<?=$this->end('content')?>
|
||||
<?=$this->start('footer_js')?>
|
||||
<script language="Javascript">
|
||||
$(document).ready( function () {
|
||||
|
||||
$("#register_submit").submit( function () {
|
||||
|
||||
$('.error').html('');
|
||||
|
||||
$('#loader-wrapper').show();
|
||||
|
||||
$.ajax({
|
||||
url: "<?=$this->make_url('admin', 'app', ['signup'])?>",
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
data: {'username': $('#username_form').val(), 'email': $('#email_form').val(), 'password': $('#password_form').val(), 'repeat_password': $('#repeat_password_form').val(), 'csrf_token': $('#csrf_token').val()},
|
||||
success: function (data) {
|
||||
|
||||
if(data.error==0)
|
||||
{
|
||||
console.log('Success');
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
location.href="<?=$this->make_url('admin', 'app', ['login'])?>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$('#loader-wrapper').hide();
|
||||
|
||||
$('#csrf_token').attr('value', data.csrf_token);
|
||||
|
||||
$('#username_error').html(data.error_form.username_error);
|
||||
$('#email_error').html(data.error_form.email_error);
|
||||
$('#password_error').html(data.error_form.password_error);
|
||||
|
||||
$('#repeat_password_error').html(data.error_form.password_repeat_error);
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<?=$this->end('footer_js')?>
|
||||
4
modules/admin/templates/users.php
Normal file
4
modules/admin/templates/users.php
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?=$this->layout('layout', ['title' => $title, 'path_module' => 'admin.home'])?>
|
||||
<?=$this->start('content')?>
|
||||
<?=$content?>
|
||||
<?=$this->end('content')?>
|
||||
260
modules/phangoapp/libraries/pharouter.php
Normal file
260
modules/phangoapp/libraries/pharouter.php
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
<?php
|
||||
|
||||
namespace PhangoApp\PhaRouter;
|
||||
use PhangoApp\PhaUtils\Utils;
|
||||
|
||||
class Config {
|
||||
|
||||
static public $home_module='welcome';
|
||||
|
||||
static public $modules_allowed=['welcome' => 'modules/welcome'];
|
||||
|
||||
static public $libraries_allowed=[];
|
||||
|
||||
static public $base_url='';
|
||||
|
||||
static public $domain_url='http://localhost';
|
||||
|
||||
static public $data=[];
|
||||
|
||||
static public $index_file='index.php/';
|
||||
|
||||
static public $get_path_info=false;
|
||||
|
||||
static public $on_other=false;
|
||||
|
||||
static public $on_proxy=false;
|
||||
|
||||
static public $portal_name='Website name';
|
||||
|
||||
static public $email_site='';
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*Examples
|
||||
* Url: http://domain.com/
|
||||
* Url: http://domain.com/index.php/{module}
|
||||
* Url: http://domain.com/index.php/{module}/app/{arg1}/{arg2} -> modules/module/controller_app.php controller($args);
|
||||
* Url: http://domain.com/index.php/{module}/index/{arg1}/{arg2} -> modules/module/controller_index.php AppController->App($args);
|
||||
*/
|
||||
|
||||
function get_controller($path_info, $controller, $args=[]) {
|
||||
|
||||
$controller=__DIR__.'/../../../'.$controller;
|
||||
|
||||
if(is_file($controller)) {
|
||||
|
||||
include_once($controller);
|
||||
|
||||
if(class_exists('AppController')) {
|
||||
|
||||
$controller=new \AppController();
|
||||
|
||||
$controller->path_info=$path_info;
|
||||
|
||||
//return $controller->App($args);
|
||||
return call_user_func_array(array($controller, 'App'), $args);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
return call_user_func_array('controller', $args);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
echo 'Page not found';
|
||||
|
||||
if(!\PhangoApp\PhaRouter\Config::$on_other) {
|
||||
|
||||
http_response_code(404);
|
||||
|
||||
}
|
||||
|
||||
exit(1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Route is: /module/switch/
|
||||
//Route is: /module/file/switch/
|
||||
//Route is: /module/file/switch/parameter1/parameter2
|
||||
|
||||
function get_route($path_info) {
|
||||
|
||||
if($path_info!='') {
|
||||
|
||||
$arr_path=filter_path($path_info);
|
||||
|
||||
switch (count($arr_path)) {
|
||||
|
||||
case 0:
|
||||
|
||||
$controller=\PhangoApp\PhaRouter\Config::$modules_allowed[\PhangoApp\PhaRouter\Config::$home_module].'/controllers/app.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, []);
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
if(isset(Config::$modules_allowed[$arr_path[1]])) {
|
||||
|
||||
$module_path=Config::$modules_allowed[$arr_path[1]];
|
||||
|
||||
$controller=$module_path.'/controllers/app.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, []);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
if(isset(Config::$modules_allowed[$arr_path[1]])) {
|
||||
|
||||
$module_path=Config::$modules_allowed[$arr_path[1]];
|
||||
|
||||
$controller=$module_path.'/controllers/'.$arr_path[2].'.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, []);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if(isset(Config::$modules_allowed[$arr_path[1]])) {
|
||||
|
||||
$module_path=Config::$modules_allowed[$arr_path[1]];
|
||||
|
||||
$controller=$module_path.'/controllers/'.$arr_path[2].'.php';
|
||||
|
||||
$args=array_slice($arr_path, 2, count($arr_path));
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, $args);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$controller=\PhangoApp\PhaRouter\Config::$modules_allowed[\PhangoApp\PhaRouter\Config::$home_module].'/controllers/app.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($path_info, $controller, []);
|
||||
|
||||
}
|
||||
|
||||
//If not return, page not found.
|
||||
|
||||
echo 'Page not found';
|
||||
|
||||
if(!\PhangoApp\PhaRouter\Config::$on_other) {
|
||||
|
||||
http_response_code(404);
|
||||
|
||||
}
|
||||
|
||||
exit(1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function filter_path($path_info) {
|
||||
|
||||
$final_path=[];
|
||||
|
||||
$arr_path=explode('/', $path_info);
|
||||
|
||||
if($arr_path[count($arr_path)-1]=='') {
|
||||
|
||||
unset($arr_path[count($arr_path)-1]);
|
||||
|
||||
}
|
||||
|
||||
$z=1;
|
||||
|
||||
unset($arr_path[0]);
|
||||
|
||||
foreach($arr_path as $k => $info) {
|
||||
|
||||
$v=Utils::slugify($info);
|
||||
|
||||
if($v!='') {
|
||||
|
||||
$final_path[$z]=$v;
|
||||
|
||||
$z++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $final_path;
|
||||
|
||||
}
|
||||
|
||||
class Url {
|
||||
|
||||
static public function make_url($module, $script='', $args=[]) {
|
||||
|
||||
$url=$module;
|
||||
|
||||
if($script!='') {
|
||||
|
||||
$url.='/'.$script;
|
||||
|
||||
}
|
||||
|
||||
if(count($args)>0) {
|
||||
|
||||
$url.='/'.implode('/', $args);
|
||||
|
||||
}
|
||||
|
||||
return Config::$base_url.Config::$index_file.$url;
|
||||
|
||||
}
|
||||
|
||||
static public function make_media_url($file) {
|
||||
|
||||
return Config::$base_url.$file;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Controller {
|
||||
|
||||
public $path_info='';
|
||||
|
||||
public function json($arr_return) {
|
||||
|
||||
$final_return=json_encode($arr_return);
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
return $final_return;
|
||||
|
||||
}
|
||||
|
||||
public function send_error($str) {
|
||||
|
||||
|
||||
if(!fwrite(STDERR, $str)) {
|
||||
|
||||
throw new Exception('Cannot write to stderr!! '.$str);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
698
modules/phangoapp/libraries/phautils/utils.php
Normal file
698
modules/phangoapp/libraries/phautils/utils.php
Normal file
|
|
@ -0,0 +1,698 @@
|
|||
<?php
|
||||
|
||||
namespace PhangoApp\PhaUtils;
|
||||
|
||||
use PhangoApp\PhaRouter\Routes;
|
||||
|
||||
/**
|
||||
* Class with text utilities and more
|
||||
*/
|
||||
|
||||
class Utils {
|
||||
|
||||
/**
|
||||
* An array for cache loaded libraries
|
||||
*/
|
||||
|
||||
static public $cache_libraries=array();
|
||||
|
||||
static public $cache_config=array();
|
||||
|
||||
static public $textbb_type='';
|
||||
|
||||
/**
|
||||
* Function for normalize texts for use on urls or other things...
|
||||
*
|
||||
* This function is used for convert text in a format useful for cleaning and beauty urls or cleaning text
|
||||
*
|
||||
* @param string $text String for normalize
|
||||
* @param boolean $respect_upper If true or 1 respect uppercase, if false or 0 convert to lowercase the $text
|
||||
* @param string $replace Character used for replace text spaces.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static public function slugify($text, $respect_upper=0, $replace_space='-', $replace_dot=0, $replace_barr=0)
|
||||
{
|
||||
|
||||
$from=iconv('utf-8', 'us-ascii//TRANSLIT', '¿?{}@~=^:´[]#*·');
|
||||
$to= iconv('utf-8', 'us-ascii//TRANSLIT', '---------------');
|
||||
|
||||
if($replace_dot==1)
|
||||
{
|
||||
|
||||
$from.='.';
|
||||
$to.='-';
|
||||
|
||||
}
|
||||
|
||||
if($replace_barr==1)
|
||||
{
|
||||
|
||||
$from.="/";
|
||||
$to.="-";
|
||||
|
||||
}
|
||||
|
||||
//utf8_decode(urldecode($text));
|
||||
|
||||
$text=trim(str_replace(" ", $replace_space, $text));
|
||||
|
||||
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
|
||||
|
||||
$text=preg_replace('~[^-\w]+~', '', $text);
|
||||
|
||||
//$text = strtr($text, $from, $to);
|
||||
|
||||
//Used for pass base64 via GET that use upper, for example.
|
||||
|
||||
if($respect_upper==0)
|
||||
{
|
||||
|
||||
$text = strtolower($text);
|
||||
|
||||
}
|
||||
|
||||
return $text; //iconv('us-ascii//TRANSLIT', 'utf-8', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to clean up the text of undesirable elements
|
||||
* @param string $text Text to clean
|
||||
* @param string $br Boolean variable used for control if you want br tags or \n symbon on input text
|
||||
*/
|
||||
|
||||
static public function form_text( $text ,$br=1)
|
||||
{
|
||||
|
||||
settype( $text, "string" );
|
||||
|
||||
$text = trim( $text );
|
||||
|
||||
$arr_tags=array('/</', '/>/', '/"/', '/\'/', "/ /");
|
||||
$arr_entities=array('<', '>', '"', ''', ' ');
|
||||
|
||||
if($br==1)
|
||||
{
|
||||
|
||||
$text = preg_replace($arr_tags, $arr_entities, $text);
|
||||
|
||||
$arr_text = explode("\n\r\n", $text);
|
||||
|
||||
$c=count($arr_text);
|
||||
|
||||
if($c>1)
|
||||
{
|
||||
for($x=0;$x<$c;$x++)
|
||||
{
|
||||
|
||||
$arr_text[$x]='<p>'.trim($arr_text[$x]).' </p>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$text=implode('', $arr_text);
|
||||
|
||||
$arr_text = explode("\n", $text);
|
||||
|
||||
$c=count($arr_text);
|
||||
|
||||
if($c>1)
|
||||
{
|
||||
for($x=0;$x<$c;$x++)
|
||||
{
|
||||
|
||||
$arr_text[$x]=trim($arr_text[$x]).'<br />';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$text=implode('', $arr_text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$text = Utils::make_slashes( $text );
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used for add slashes from _POST and _GET variables.
|
||||
*
|
||||
*
|
||||
* @param string $string String for add slashes
|
||||
*/
|
||||
|
||||
static public function make_slashes( $string )
|
||||
{
|
||||
return addslashes( $string );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used for strip slashes from _POST and _GET variables.
|
||||
*
|
||||
*
|
||||
* @param string $string String for strip slashes
|
||||
*/
|
||||
|
||||
static public function unmake_slashes( $string )
|
||||
{
|
||||
return stripslashes( $string );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to clean up the text of undesirable html tags
|
||||
*
|
||||
* @param string $text Input text for clean undesirable html tags
|
||||
* @param array $allowedtags An array with allow tags on the text.
|
||||
*/
|
||||
|
||||
static public function form_text_html( $text , $allowedtags=array())
|
||||
{
|
||||
|
||||
settype( $text, "string" );
|
||||
|
||||
//If no html editor \r\n=<p>
|
||||
|
||||
/*$text=preg_replace("/<br.*?>/", "\n", $text);*/
|
||||
|
||||
/*if(Utils::$textbb_type!='')
|
||||
{
|
||||
|
||||
$text=str_replace("\r", '', $text);
|
||||
$text=str_replace("\n", '', $text);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//Make <p>
|
||||
|
||||
$arr_text = explode("\n\r\n", $text);
|
||||
|
||||
$c=count($arr_text);
|
||||
|
||||
if($c>1)
|
||||
{
|
||||
for($x=0;$x<$c;$x++)
|
||||
{
|
||||
|
||||
$arr_text[$x]='<p>'.trim($arr_text[$x]).' </p>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$text=implode('', $arr_text);
|
||||
|
||||
$arr_text = explode("\n", $text);
|
||||
|
||||
$c=count($arr_text);
|
||||
|
||||
if($c>1)
|
||||
{
|
||||
for($x=0;$x<$c;$x++)
|
||||
{
|
||||
|
||||
$arr_text[$x]=trim($arr_text[$x]).'<br />';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$text=implode('', $arr_text);
|
||||
|
||||
}*/
|
||||
/*echo htmlentities($text);
|
||||
die;*/
|
||||
|
||||
//Check tags
|
||||
|
||||
//Bug : tags deleted ocuppied space.
|
||||
|
||||
//First strip_tags
|
||||
|
||||
$text = trim( $text );
|
||||
|
||||
//Trim html
|
||||
|
||||
/*$text=str_replace(' ', ' ', $text);
|
||||
|
||||
while(preg_match('/<p>\s+<\/p>$/s', $text))
|
||||
{
|
||||
|
||||
$text=preg_replace('/<p>\s+<\/p>$/s', '', $text);
|
||||
|
||||
}*/
|
||||
|
||||
//Now clean undesirable html tags
|
||||
|
||||
if(count($allowedtags)>0)
|
||||
{
|
||||
|
||||
$text=strip_tags($text, '<'.implode('><', array_keys($allowedtags)).'>' );
|
||||
|
||||
$arr_tags=array('/</', '/>/', '/"/', '/\'/', "/ /");
|
||||
$arr_entities=array('<', '>', '"', ''', ' ');
|
||||
|
||||
$text=preg_replace($arr_tags, $arr_entities, $text);
|
||||
|
||||
$text=str_replace(' ', ' ', $text);
|
||||
|
||||
$arr_tags_clean=array();
|
||||
$arr_tags_empty_clean=array();
|
||||
|
||||
//Close tags.
|
||||
|
||||
//Filter tags
|
||||
|
||||
$final_allowedtags=array();
|
||||
|
||||
foreach($allowedtags as $tag => $parameters)
|
||||
{
|
||||
//If mark how recursive, make a loop
|
||||
|
||||
settype($parameters['recursive'], 'integer');
|
||||
|
||||
$c_count=0;
|
||||
$x=0;
|
||||
|
||||
if($parameters['recursive']==1)
|
||||
{
|
||||
|
||||
$c_count = substr_count( $text, '<'.$tag.'>');
|
||||
|
||||
}
|
||||
|
||||
for($x=0;$x<=$c_count;$x++)
|
||||
{
|
||||
|
||||
$text=preg_replace($parameters['pattern'], $parameters['replace'], $text);
|
||||
|
||||
}
|
||||
|
||||
$pos_=strpos($tag, '_');
|
||||
|
||||
if($pos_!==false)
|
||||
{
|
||||
|
||||
$tag=substr($tag, 0, $pos_);
|
||||
|
||||
}
|
||||
|
||||
$final_allowedtags[]=$tag.'_tmp';
|
||||
|
||||
//Destroy open tags.
|
||||
|
||||
$arr_tags_clean[]='/<(.*?)'.$tag.'(.*?)>/';
|
||||
|
||||
$arr_tags_empty_clean[]='';
|
||||
$arr_tags_empty_clean[]='';
|
||||
|
||||
}
|
||||
|
||||
$text=preg_replace($arr_tags_clean, $arr_tags_empty_clean, $text);
|
||||
}
|
||||
|
||||
//With clean code, modify <tag_tmp
|
||||
|
||||
$text=str_replace('_tmp', '', $text);
|
||||
|
||||
//Close tags
|
||||
|
||||
$text = Utils::unmake_slashes( $text );
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* function for clean newlines
|
||||
*
|
||||
* @param string $text Text to clean.
|
||||
*/
|
||||
|
||||
static public function unform_text( $text )
|
||||
{
|
||||
|
||||
$text = preg_replace( "/<p>(.*?)<\/p>/s", "$1\n\r\n", $text );
|
||||
$text = str_replace( "<br />", "", $text );
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A function for generate a rand token used on sessions.
|
||||
*
|
||||
* @param string $length_token A variable used for set the character's length the password. More length, password more secure
|
||||
*/
|
||||
|
||||
static public function get_token($length_token=24)
|
||||
{
|
||||
|
||||
$rand_prefix=Utils::generate_random_password($length_token);
|
||||
|
||||
return $rand_prefix;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used for generate a simple random password. Use random_int php function for get the characters of the password
|
||||
*
|
||||
* @param string $length_pass A variable used for set the character's length the password. More length, password more secure
|
||||
*
|
||||
*/
|
||||
|
||||
static public function generate_random_password($length_pass=32)
|
||||
{
|
||||
|
||||
$x=0;
|
||||
$z=0;
|
||||
|
||||
$abc=array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '*', '+', '!', '-', '_', '@', '#', '$');
|
||||
|
||||
$disorder_abc=[];
|
||||
|
||||
//Simple disorder using random_int
|
||||
|
||||
while(count($abc)>0) {
|
||||
|
||||
$c_abc=count($abc);
|
||||
|
||||
$num_element_move=random_int(0, $c_abc-1);
|
||||
|
||||
$disorder_abc[]=$abc[$num_element_move];
|
||||
|
||||
unset($abc[$num_element_move]);
|
||||
|
||||
$abc=array_values($abc);
|
||||
|
||||
}
|
||||
|
||||
//Get randomly elements from the randomly generated array.
|
||||
|
||||
$c=count($disorder_abc)-1;
|
||||
|
||||
$password_final='';
|
||||
|
||||
for($x=0;$x<$length_pass;$x++) {
|
||||
|
||||
$num_element_pass=random_int(0, $c);
|
||||
|
||||
$password_final.=$disorder_abc[$num_element_pass];
|
||||
|
||||
}
|
||||
|
||||
//Add strange characters
|
||||
|
||||
return $password_final;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load libraries, well, simply an alternative include
|
||||
*
|
||||
* Very important function used for load the functions and method necessaries on your projects. Is simple, you create a file php and put in a libraries folder. Use the name without php used in file and magically the file is loaded. You can use this function in many places, phango use a little cache for know who file is loaded.
|
||||
*
|
||||
* @param string $names The name of php file without .php extension. If you want specific many libraries you can use an array
|
||||
* @param string $path The base path where search the library if is not in standard path. By default the path is on Utils::$base_path/libraries/ or Utils::$base_path/modules/$module/libraries/
|
||||
* @deprecated Use namespaces and composer instead.
|
||||
*/
|
||||
|
||||
static public function load_libraries($names, $path='')
|
||||
{
|
||||
|
||||
if(gettype($names)!='array')
|
||||
{
|
||||
|
||||
$arr_names[]=$names;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$arr_names=&$names;
|
||||
|
||||
}
|
||||
|
||||
if($path=='')
|
||||
{
|
||||
|
||||
$path=Routes::$base_path.'/vendor/'.Routes::$app.'/libraries/';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$path=Routes::$base_path.'/'.$path.'/';
|
||||
|
||||
}
|
||||
|
||||
|
||||
foreach($arr_names as $library)
|
||||
{
|
||||
|
||||
|
||||
if(!isset(Utils::$cache_libraries[$library]))
|
||||
{
|
||||
|
||||
$old_path=$path;
|
||||
|
||||
if(is_file($path.'/'.$library.'.php'))
|
||||
{
|
||||
include($path.$library.'.php');
|
||||
|
||||
Utils::$cache_libraries[$library]=1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Libraries path
|
||||
|
||||
$path=Routes::$base_path.'/libraries/';
|
||||
|
||||
if(!include($path.$library.'.php'))
|
||||
{
|
||||
|
||||
|
||||
die();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Utils::$cache_libraries[$library]=1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple function for replate real quotes for quote html entities.
|
||||
*
|
||||
* @param string $text Text to clean.
|
||||
*/
|
||||
|
||||
static public function replace_quote_text( $text )
|
||||
{
|
||||
|
||||
$text = str_replace( "\"", """, $text );
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function for set array values without keys inside $array_strip
|
||||
*
|
||||
* @param array $array_strip The array with key values for set
|
||||
* @param array $array_source The array that i want fill with default values
|
||||
*
|
||||
*/
|
||||
|
||||
static public function filter_fields_array($array_strip, $array_source)
|
||||
{
|
||||
|
||||
$array_final=array();
|
||||
|
||||
if(count($array_strip)>0)
|
||||
{
|
||||
foreach($array_strip as $field_strip)
|
||||
{
|
||||
|
||||
$array_final[$field_strip]=@$array_source[$field_strip];
|
||||
|
||||
}
|
||||
|
||||
return $array_final;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return $array_source;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used for show on stdout a csrf_token used by POST phango controllers for check if is a real POST from phango.
|
||||
*
|
||||
* @param string $name_token The name of the token key in session
|
||||
* @param int $length_token The length of
|
||||
*/
|
||||
|
||||
static public function set_csrf_key($name_token='csrf_token', $length_token=80)
|
||||
{
|
||||
|
||||
/*if(!isset($_SESSION['csrf_token']))
|
||||
{*/
|
||||
|
||||
$_SESSION['csrf_token']=Utils::get_token($length_token);
|
||||
|
||||
//}
|
||||
|
||||
return "\n<input type=\"hidden\" name=\"".$name_token."\" value=\"".$_SESSION['csrf_token']."\"/>\n";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used for show on stdout a csrf_token used by POST phango controllers for check if is a real POST from phango.
|
||||
*
|
||||
*/
|
||||
|
||||
static public function generate_csrf_key($length_token=80)
|
||||
{
|
||||
|
||||
$_SESSION['csrf_token']=Utils::get_token($length_token);
|
||||
|
||||
return $_SESSION['csrf_token'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for load config for modules.
|
||||
*
|
||||
*
|
||||
* @param $name_config Name of the config file, optional. Normally load config.php file on folder config.
|
||||
* @param $path Path where search the config.
|
||||
*/
|
||||
|
||||
static public function load_config($name_config, $path="settings")
|
||||
{
|
||||
|
||||
//load_libraries(array($name_config), PhangoVar::$base_path.'/modules/'.$module.'/config/');
|
||||
|
||||
$file='./'.$path.'/'.$name_config.'.php';
|
||||
|
||||
if(is_file($file) && !isset(Utils::$cache_config[$file]))
|
||||
{
|
||||
include($file);
|
||||
|
||||
Utils::$cache_config[$file]=1;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for reload config.
|
||||
*
|
||||
* @warning WARNING, use this method only if you don't have any alternative
|
||||
*
|
||||
* @param $module Name of the module
|
||||
* @param $name_config Name of the config file, optional. Normally load config.php file on folder config.
|
||||
*/
|
||||
|
||||
static public function reload_config($name_config, $path="./settings")
|
||||
{
|
||||
|
||||
//load_libraries(array($name_config), PhangoVar::$base_path.'/modules/'.$module.'/config/');
|
||||
|
||||
$file=$path.'/'.$name_config.'.php';
|
||||
|
||||
if(is_file($file))
|
||||
{
|
||||
|
||||
$cont_file_config=file_get_contents($file);
|
||||
|
||||
$cont_file_config=str_replace('<?php', '', $cont_file_config);
|
||||
|
||||
$cont_file_config=str_replace('?>', '', $cont_file_config);
|
||||
|
||||
if(eval($cont_file_config)===FALSE)
|
||||
{
|
||||
|
||||
throw new \Exception('Error: cannot reload the config file: '.$file);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for wrap words of a string
|
||||
*
|
||||
* @param string $text The text to wrap
|
||||
* @param integer $num_words The number of words of returned text
|
||||
* @param string $text_explain The string used for show that the texts is more longer
|
||||
* @param boolean $yes_more_ever Boolean used for activate or disable $text_explain if the size of real string is the same of the new string
|
||||
*/
|
||||
|
||||
static public function wrap_words($text, $num_words, $text_explain='...', $yes_more_ever=0)
|
||||
{
|
||||
|
||||
$arr_text=explode(' ', $text);
|
||||
|
||||
$final_text='';
|
||||
|
||||
$total_num_text=count($arr_text);
|
||||
|
||||
if($total_num_text<$num_words)
|
||||
{
|
||||
|
||||
$num_words=$total_num_text;
|
||||
|
||||
if($yes_more_ever==0)
|
||||
{
|
||||
$text_explain='';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for($x=0;$x<$num_words;$x++)
|
||||
{
|
||||
|
||||
$arr_final_text[]=$arr_text[$x];
|
||||
|
||||
}
|
||||
|
||||
return implode(' ', $arr_final_text).' '.$text_explain;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
2
modules/phatemplates/.gitignore
vendored
Normal file
2
modules/phatemplates/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*~
|
||||
vendor/*
|
||||
157
modules/phatemplates/libraries/templates.php
Normal file
157
modules/phatemplates/libraries/templates.php
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
namespace PhaTemplates;
|
||||
|
||||
class Templates {
|
||||
|
||||
public $search_dir;
|
||||
|
||||
public $template='';
|
||||
|
||||
public $section='';
|
||||
|
||||
public $section_content=[];
|
||||
|
||||
public $yes_layout=false;
|
||||
|
||||
public $layout='';
|
||||
|
||||
public function __construct($search_dir) {
|
||||
|
||||
$this->search_dir=$search_dir;
|
||||
|
||||
}
|
||||
|
||||
public function load_template($name_template, $args=[]) {
|
||||
|
||||
$name_template=basename($name_template);
|
||||
|
||||
$template='';
|
||||
|
||||
$this->yes_layout=false;
|
||||
|
||||
$z=0;
|
||||
|
||||
foreach($this->search_dir as $dir) {
|
||||
|
||||
$file_template=$dir.'/'.$name_template.'.php';
|
||||
|
||||
if(is_file($file_template)) {
|
||||
|
||||
extract($args);
|
||||
|
||||
ob_start();
|
||||
|
||||
include($file_template);
|
||||
|
||||
if($this->yes_layout) {
|
||||
|
||||
$final_template=$this->load_template($this->layout, $args);
|
||||
|
||||
echo $final_template;
|
||||
}
|
||||
|
||||
$this->template=ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if($z==count($this->search_dir)) {
|
||||
|
||||
throw new \Exception("Error: view {$file_template} not found: ".implode(' and ', $this->search_dir));
|
||||
die;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$z++;
|
||||
|
||||
}
|
||||
|
||||
return $this->template;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for set a layout in the template
|
||||
*
|
||||
*/
|
||||
|
||||
public function layout($tpl_name, $args) {
|
||||
|
||||
//echo implode("\n", $this->section_content);
|
||||
|
||||
$this->yes_layout=true;
|
||||
|
||||
$this->layout=$tpl_name;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for set a section in a layout
|
||||
*
|
||||
*/
|
||||
|
||||
public function section($section_name) {
|
||||
|
||||
|
||||
//First execute start and end
|
||||
if(isset($this->section_content[$section_name])) {
|
||||
|
||||
echo $this->section_content[$section_name];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for create a section in a template with a layout
|
||||
*
|
||||
*/
|
||||
|
||||
public function start($section_name) {
|
||||
|
||||
ob_start();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for finish section in a template with a layout
|
||||
*
|
||||
*/
|
||||
|
||||
public function end($section_name) {
|
||||
|
||||
$this->section_content[$section_name]=$this->section_content[$section_name] ?? '';
|
||||
|
||||
$this->section_content[$section_name].=ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function e($str) {
|
||||
|
||||
return html_entities($str);
|
||||
|
||||
}
|
||||
|
||||
public function make_url($module, $script='', $args=[]) {
|
||||
|
||||
return \PhangoApp\PhaRouter\Url::make_url($module, $script, $args);
|
||||
|
||||
}
|
||||
|
||||
public function make_media_url($file) {
|
||||
|
||||
return \PhangoApp\PhaRouter\Url::make_media_url($file);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
use PhangoApp\PhaView\View;
|
||||
use PhangoApp\PhaI18n\I18n;
|
||||
|
||||
PhangoApp\PhaRouter\Config::$modules_allowed=['welcome' => 'modules/welcome'];
|
||||
|
||||
PhangoApp\PhaRouter\Config::$home_module='welcome';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue