diff --git a/.gitignore b/.gitignore index 6a01bf7..7664bcb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ vendor/* modules/* !modules/welcome !modules/admin +!modules/phatemplates +!modules/phangoapp settings/config.php setting/config_test.php diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..6edb248 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "modules/admin/media/js/jsutils"] + path = modules/admin/media/js/jsutils + url = https://git.cuchulu.com/paramecio/jsutils diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..10926e8 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,675 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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. + + + Copyright (C) + + 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 . + +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: + + Copyright (C) + 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 +. + + 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 +. + diff --git a/index.php b/index.php index 3942b8a..5ce8af3 100644 --- a/index.php +++ b/index.php @@ -2,37 +2,90 @@ use PhangoApp\PhaUtils\Utils; -include('libraries/Utils.php'); -include('libraries/Routes.php'); +ob_start(); -spl_autoload_register(function ($class_name) { - - //include($nombre_clase . '.php'; - //echo $class_name; - switch($class_name) { - - case 'PhangoApp\PDO\MySQL': - - include('./libraries/PDO.php'); - - break; - - } - -}); +//include('libraries/Utils.php'); +//include('libraries/Routes.php'); -if(is_file('vendor/autoload.php')) { +if(is_file(__DIR__.'/vendor/autoload.php')) { - include('vendor/autoload.php'); + include(__DIR__.'/vendor/autoload.php'); } -ob_start(); +//ob_start(); + +spl_autoload_register(function($class_name) { + + //Simple autoload for modules, first element is module, second element is the file to load. + + $arr_library=explode('\\', $class_name); + + if(count($arr_library)>1) { + + $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'); + + } + } + + +}); Utils::load_config('config'); -$path_info=isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; +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; diff --git a/libraries/Routes.php b/libraries/Routes.php index 585274e..ba4cbb5 100644 --- a/libraries/Routes.php +++ b/libraries/Routes.php @@ -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,8 +32,10 @@ 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)) { include_once($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,7 +60,11 @@ function get_controller($controller, $args=[]) { echo 'Page not found'; - http_response_code(404); + if(!\PhangoApp\PhaRouter\Config::$on_other) { + + http_response_code(404); + + } exit(1); @@ -57,7 +77,7 @@ function get_controller($controller, $args=[]) { //Route is: /module/file/switch/parameter1/parameter2 function get_route($path_info) { - + if($path_info!='') { $arr_path=filter_path($path_info); @@ -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,15 +143,19 @@ 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, []); } //If not return, page not found. echo 'Page not found'; - - http_response_code(404); + + 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=[]) { - - $url='/'.$module; + static public function make_url($module, $script='', $args=[]) { + + $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; + + } } diff --git a/libraries/Utils.php b/libraries/Utils.php index 6287c34..5d959fd 100644 --- a/libraries/Utils.php +++ b/libraries/Utils.php @@ -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])) { diff --git a/libraries/composer-first.json b/libraries/composer-first.json new file mode 100644 index 0000000..1e10071 --- /dev/null +++ b/libraries/composer-first.json @@ -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" + } +} diff --git a/modules/admin/controllers/app.php b/modules/admin/controllers/app.php index 3848097..7859b26 100644 --- a/modules/admin/controllers/app.php +++ b/modules/admin/controllers/app.php @@ -1,188 +1,402 @@ 'Admin', 'content' => ''], 'dashboard'); + switch($op) { + + default: + + if($this->check_login()) { + + //Default admin page. + + echo $this->tpl->load_template('layout', ['title' => 'Admin', 'path_module' => 'admin.home']); } else { - //Include module admin. + header('Location: '.PhangoApp\PhaRouter\Url::make_url('admin', 'app', ['login'])); } - - } - else { - - header('Location: '.PhangoApp\PhaRouter\Url::make_url('admin', 'app', 'login')); - - } - - break; - - case 'login': - - $conn=MySQL::get_pdo_connection(); - - $sth=$conn->query('SELECT count(*) as num_items from useradmin'); - - $count=$sth->fetch()[0]; - - if($count==0) { + + break; + + case 'login': + + $this->db->connect(); + + $c_user=$this->db->select_count('useradmin', '', []); - header('Location: '.PhangoApp\PhaRouter\Url::make_url('admin', 'app', 'register')); + $error=1; + + $error_form=['username_error' => '']; - } - - echo View::load_view(['login' => 1], 'login'); - - break; - - case 'login_check': - - $conn=MySQL::get_pdo_connection(); - - $data=['error' => 1]; - - $username=$_POST['username']; - - $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)) { + if(!$c_user) { - $data['error']=0; - - $_SESSION['phango_login']=1; + 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'] ?? ''; + + } + + if($ip!='') { + + $arr_tries=$this->db->select_a_row('login_tries', [], 'WHERE ip=?', [$ip]); + + $now=date("Y-m-d H:i:s"); + + if($arr_tries) { + + $timestamp_5_min=strtotime($now)-300; + $timestamp_last_login=strtotime($arr_tries['date']); + + if($timestamp_5_min>$timestamp_last_login) { + + $this->db->delete('login_tries', 'WHERE ip=?', [$ip]); + $arr_tries=false; + + } + + } + + $num_tries=$arr_tries['num_tries'] ?? 0; + + if($num_tries<5) { + + $username=trim($_POST['username'] ?? ''); + $password=trim($_POST['password'] ?? ''); + + if($username=='') { + + $error_form['username_error']=_('Username empty'); + + } + + $arr_user=$this->db->select_a_row('useradmin', [], 'WHERE username=?', [$username]); + + if($arr_user) { + + 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' => '']); - } - - header('Content-Type: application/json; charset=utf-8'); - - return json_encode($data); - - break; - - case 'register': - - $conn=MySQL::get_pdo_connection(); - - $sth=$conn->query('SELECT count(*) as num_items from useradmin'); + } + else { + + echo $this->tpl->load_template('login', ['title' => 'Login']); + + } + + } + + break; + + case 'signup': + + $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']; + + foreach($arr_data as $v) { + + settype($_POST[$v], 'string'); + + } + + $username=trim($_POST['username']); + + if(!preg_match('/^[A-Za-z0-9_-]+$/', $username) || $username=='') { + + $error=1; + $error_form['username_error']=_("Error: empty value"); + + } + + $email=filter_var($_POST['email'], FILTER_VALIDATE_EMAIL); + + if(!$email) { + + $error=1; + $error_form['email_error']=_("Error: email is not valid"); + + + } + + $password=trim($_POST['password']); + $repeat_password=trim($_POST['repeat_password']); + + if($password=='') { + + $error=1; + $error_form['password_error']=_("Error: password empty"); + + } + else { + + if($password!=$repeat_password) { + + $error=1; + $error_form['password_error']=_("Error: password not equal"); + + } + + } + + if(!$error) { + + if(!$this->db->insert('useradmin', ['username' => $username, 'password' => password_hash($password, PASSWORD_DEFAULT), 'email' => $email])) { + + $error=1; + + $error_form['username_error']=_("Error: cannot create the user, please contact with the administrator"); + } + + } + + 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'; + + } + + echo $this->json(['error' => $error, 'error_form' => $error_form]); - $count=$sth->fetch()[0]; - - if($count==0) { - - echo View::load_view(['login' => 0], 'login'); - - } - - break; - - case 'signup_check': - - $data=['error' => 0]; - - $arr_data=['username', 'email', 'password', 'repeat_password']; - - foreach($arr_data as $v) { - - settype($_POST[$v], 'string'); - - } - - //$username=$_POST['username']; - //^[A-Za-z0-9_-]+$ - - $username=trim($_POST['username']); - - if(!preg_match('/^[A-Za-z0-9_-]+$/', $username)) { - - $data['error']=1; - $data['username']=_("Error: empty value"); - - } - - $email=filter_var($_POST['email'], FILTER_VALIDATE_EMAIL); - - if(!$email) { - - $data['error']=1; - $data['email']=_("Error: email is not valid"); - - - } - - $password=trim($_POST['password']); - $repeat_password=trim($_POST['repeat_password']); - - if($password=='') { - - $data['error']=1; - $data['password']=_("Error: password empty"); - - } - else { - - if($password!=$repeat_password) { - - $data['error']=1; - $data['password']=_("Error: password not equal"); - + } + else { + + echo $this->tpl->load_template('check_auth', ['title' => 'Double auth']); + + } + } - - } - - if($data['error']==0) { + else { + + header('Location: '.PhangoApp\PhaRouter\Url::make_url('admin', 'app', ['login'])); + + } + + break; + + case 'logout': + + $_SESSION=[]; - $password=password_hash($password, PASSWORD_DEFAULT); - - $conn=MySQL::get_pdo_connection(); + 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']; + + } - 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"); - } - //$sth->execute([$username, $password, $email]); - - } - - header('Content-Type: application/json; charset=utf-8'); - - return json_encode($data); - - break; + + 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; + } + + + } } diff --git a/modules/admin/controllers/users.php b/modules/admin/controllers/users.php new file mode 100644 index 0000000..3269655 --- /dev/null +++ b/modules/admin/controllers/users.php @@ -0,0 +1,221 @@ +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']=''._('Edit').'
'._('Delete').''; + + } + + 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); + + } + + } + +} + diff --git a/modules/admin/libraries/admincontroller.php b/modules/admin/libraries/admincontroller.php new file mode 100644 index 0000000..ac70158 --- /dev/null +++ b/modules/admin/libraries/admincontroller.php @@ -0,0 +1,25 @@ +check_login()) { + + header('Location: '.\PhangoApp\PhaRouter\Url::make_url('admin', 'app', ['login'])); + + } + + } + + +} diff --git a/modules/admin/libraries/settings.php b/modules/admin/libraries/settings.php new file mode 100644 index 0000000..48f5449 --- /dev/null +++ b/modules/admin/libraries/settings.php @@ -0,0 +1,9 @@ +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; + + } + + } + +} diff --git a/modules/admin/media/css/admin.css b/modules/admin/media/css/admin.css index 8b610f4..e411a60 100644 --- a/modules/admin/media/css/admin.css +++ b/modules/admin/media/css/admin.css @@ -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 */ diff --git a/modules/admin/media/fonts/FontAwesome.otf b/modules/admin/media/fonts/FontAwesome.otf deleted file mode 100644 index 401ec0f..0000000 Binary files a/modules/admin/media/fonts/FontAwesome.otf and /dev/null differ diff --git a/modules/admin/media/fonts/fontawesome-webfont.eot b/modules/admin/media/fonts/fontawesome-webfont.eot deleted file mode 100644 index e9f60ca..0000000 Binary files a/modules/admin/media/fonts/fontawesome-webfont.eot and /dev/null differ diff --git a/modules/admin/media/fonts/fontawesome-webfont.svg b/modules/admin/media/fonts/fontawesome-webfont.svg deleted file mode 100644 index 855c845..0000000 --- a/modules/admin/media/fonts/fontawesome-webfont.svg +++ /dev/null @@ -1,2671 +0,0 @@ - - - - -Created by FontForge 20120731 at Mon Oct 24 17:37:40 2016 - By ,,, -Copyright Dave Gandy 2016. All rights reserved. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/admin/media/fonts/fontawesome-webfont.ttf b/modules/admin/media/fonts/fontawesome-webfont.ttf deleted file mode 100644 index 35acda2..0000000 Binary files a/modules/admin/media/fonts/fontawesome-webfont.ttf and /dev/null differ diff --git a/modules/admin/media/fonts/fontawesome-webfont.woff b/modules/admin/media/fonts/fontawesome-webfont.woff deleted file mode 100644 index 400014a..0000000 Binary files a/modules/admin/media/fonts/fontawesome-webfont.woff and /dev/null differ diff --git a/modules/admin/media/fonts/fontawesome-webfont.woff2 b/modules/admin/media/fonts/fontawesome-webfont.woff2 deleted file mode 100644 index 4d13fc6..0000000 Binary files a/modules/admin/media/fonts/fontawesome-webfont.woff2 and /dev/null differ diff --git a/modules/admin/media/js/jquery.min.js b/modules/admin/media/js/jquery.min.js index 0de648e..7f37b5d 100644 --- a/modules/admin/media/js/jquery.min.js +++ b/modules/admin/media/js/jquery.min.js @@ -1,2 +1,2 @@ -/*! jQuery v3.6.4 | (c) OpenJS Foundation and other contributors | jquery.org/license */ -!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,y=n.hasOwnProperty,a=y.toString,l=a.call(Object),v={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.4",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&v(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!y||!y.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ve(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ye(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ve(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.cssHas=ce(function(){try{return C.querySelector(":has(*,:jqfake)"),!1}catch(e){return!0}}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],y=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||y.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||y.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||y.push(".#.+[+~]"),e.querySelectorAll("\\\f"),y.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),d.cssHas||y.push(":has"),y=y.length&&new RegExp(y.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),v=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType&&e.documentElement||e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&v(p,e)?-1:t==C||t.ownerDocument==p&&v(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!y||!y.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),v.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",v.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",v.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Ut,Xt=[],Vt=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xt.pop()||S.expando+"_"+Ct.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Vt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Vt,"$1"+r):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Xt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),v.createHTMLDocument=((Ut=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Ut.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(v.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return B(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=_e(v.pixelPosition,function(e,t){if(t)return t=Be(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return B(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0+~]|"+ge+")"+ge+"*"),x=new RegExp(ge+"|>"),j=new RegExp(g),A=new RegExp("^"+t+"$"),D={ID:new RegExp("^#("+t+")"),CLASS:new RegExp("^\\.("+t+")"),TAG:new RegExp("^("+t+"|[*])"),ATTR:new RegExp("^"+p),PSEUDO:new RegExp("^"+g),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ge+"*(even|odd|(([+-]|)(\\d*)n|)"+ge+"*(?:([+-]|)"+ge+"*(\\d+)|))"+ge+"*\\)|)","i"),bool:new RegExp("^(?:"+f+")$","i"),needsContext:new RegExp("^"+ge+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ge+"*((?:-\\d)?\\d*)"+ge+"*\\)|)(?=[^-]|$)","i")},N=/^(?:input|select|textarea|button)$/i,q=/^h\d$/i,L=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,H=/[+~]/,O=new RegExp("\\\\[\\da-fA-F]{1,6}"+ge+"?|\\\\([^\\r\\n\\f])","g"),P=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},M=function(){V()},R=J(function(e){return!0===e.disabled&&fe(e,"fieldset")},{dir:"parentNode",next:"legend"});try{k.apply(oe=ae.call(ye.childNodes),ye.childNodes),oe[ye.childNodes.length].nodeType}catch(e){k={apply:function(e,t){me.apply(e,ae.call(t))},call:function(e){me.apply(e,ae.call(arguments,1))}}}function I(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(V(e),e=e||T,C)){if(11!==p&&(u=L.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return k.call(n,a),n}else if(f&&(a=f.getElementById(i))&&I.contains(e,a)&&a.id===i)return k.call(n,a),n}else{if(u[2])return k.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&e.getElementsByClassName)return k.apply(n,e.getElementsByClassName(i)),n}if(!(h[t+" "]||d&&d.test(t))){if(c=t,f=e,1===p&&(x.test(t)||m.test(t))){(f=H.test(t)&&U(e.parentNode)||e)==e&&le.scope||((s=e.getAttribute("id"))?s=ce.escapeSelector(s):e.setAttribute("id",s=S)),o=(l=Y(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+Q(l[o]);c=l.join(",")}try{return k.apply(n,f.querySelectorAll(c)),n}catch(e){h(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return re(t.replace(ve,"$1"),e,n,r)}function W(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function F(e){return e[S]=!0,e}function $(e){var t=T.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function B(t){return function(e){return fe(e,"input")&&e.type===t}}function _(t){return function(e){return(fe(e,"input")||fe(e,"button"))&&e.type===t}}function z(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&R(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function X(a){return F(function(o){return o=+o,F(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function U(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function V(e){var t,n=e?e.ownerDocument||e:ye;return n!=T&&9===n.nodeType&&n.documentElement&&(r=(T=n).documentElement,C=!ce.isXMLDoc(T),i=r.matches||r.webkitMatchesSelector||r.msMatchesSelector,r.msMatchesSelector&&ye!=T&&(t=T.defaultView)&&t.top!==t&&t.addEventListener("unload",M),le.getById=$(function(e){return r.appendChild(e).id=ce.expando,!T.getElementsByName||!T.getElementsByName(ce.expando).length}),le.disconnectedMatch=$(function(e){return i.call(e,"*")}),le.scope=$(function(){return T.querySelectorAll(":scope")}),le.cssHas=$(function(){try{return T.querySelector(":has(*,:jqfake)"),!1}catch(e){return!0}}),le.getById?(b.filter.ID=function(e){var t=e.replace(O,P);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(O,P);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):t.querySelectorAll(e)},b.find.CLASS=function(e,t){if("undefined"!=typeof t.getElementsByClassName&&C)return t.getElementsByClassName(e)},d=[],$(function(e){var t;r.appendChild(e).innerHTML="",e.querySelectorAll("[selected]").length||d.push("\\["+ge+"*(?:value|"+f+")"),e.querySelectorAll("[id~="+S+"-]").length||d.push("~="),e.querySelectorAll("a#"+S+"+*").length||d.push(".#.+[+~]"),e.querySelectorAll(":checked").length||d.push(":checked"),(t=T.createElement("input")).setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),r.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&d.push(":enabled",":disabled"),(t=T.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||d.push("\\["+ge+"*name"+ge+"*="+ge+"*(?:''|\"\")")}),le.cssHas||d.push(":has"),d=d.length&&new RegExp(d.join("|")),l=function(e,t){if(e===t)return a=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!le.sortDetached&&t.compareDocumentPosition(e)===n?e===T||e.ownerDocument==ye&&I.contains(ye,e)?-1:t===T||t.ownerDocument==ye&&I.contains(ye,t)?1:o?se.call(o,e)-se.call(o,t):0:4&n?-1:1)}),T}for(e in I.matches=function(e,t){return I(e,null,null,t)},I.matchesSelector=function(e,t){if(V(e),C&&!h[t+" "]&&(!d||!d.test(t)))try{var n=i.call(e,t);if(n||le.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){h(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(O,P),e[3]=(e[3]||e[4]||e[5]||"").replace(O,P),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||I.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&I.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return D.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&j.test(n)&&(t=Y(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(O,P).toLowerCase();return"*"===e?function(){return!0}:function(e){return fe(e,t)}},CLASS:function(e){var t=s[e+" "];return t||(t=new RegExp("(^|"+ge+")"+e+"("+ge+"|$)"))&&s(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=I.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function T(e,n,r){return v(n)?ce.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?ce.grep(e,function(e){return e===n!==r}):"string"!=typeof n?ce.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(ce.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||k,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:S.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof ce?t[0]:t,ce.merge(this,ce.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:C,!0)),w.test(r[1])&&ce.isPlainObject(t))for(r in t)v(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=C.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):v(e)?void 0!==n.ready?n.ready(e):e(ce):ce.makeArray(e,this)}).prototype=ce.fn,k=ce(C);var E=/^(?:parents|prev(?:Until|All))/,j={children:!0,contents:!0,next:!0,prev:!0};function A(e,t){while((e=e[t])&&1!==e.nodeType);return e}ce.fn.extend({has:function(e){var t=ce(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,Ce=/^$|^module$|\/(?:java|ecma)script/i;xe=C.createDocumentFragment().appendChild(C.createElement("div")),(be=C.createElement("input")).setAttribute("type","radio"),be.setAttribute("checked","checked"),be.setAttribute("name","t"),xe.appendChild(be),le.checkClone=xe.cloneNode(!0).cloneNode(!0).lastChild.checked,xe.innerHTML="",le.noCloneChecked=!!xe.cloneNode(!0).lastChild.defaultValue,xe.innerHTML="",le.option=!!xe.lastChild;var ke={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function Se(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&fe(e,t)?ce.merge([e],n):n}function Ee(e,t){for(var n=0,r=e.length;n",""]);var je=/<|&#?\w+;/;function Ae(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function Re(e,t){return fe(e,"table")&&fe(11!==t.nodeType?t:t.firstChild,"tr")&&ce(e).children("tbody")[0]||e}function Ie(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function We(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Fe(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(_.hasData(e)&&(s=_.get(e).events))for(i in _.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),C.head.appendChild(r[0])},abort:function(){i&&i()}}});var Jt,Kt=[],Zt=/(=)\?(?=&|$)|\?\?/;ce.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Kt.pop()||ce.expando+"_"+jt.guid++;return this[e]=!0,e}}),ce.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Zt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Zt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=v(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Zt,"$1"+r):!1!==e.jsonp&&(e.url+=(At.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||ce.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=ie[r],ie[r]=function(){o=arguments},n.always(function(){void 0===i?ce(ie).removeProp(r):ie[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Kt.push(r)),o&&v(i)&&i(o[0]),o=i=void 0}),"script"}),le.createHTMLDocument=((Jt=C.implementation.createHTMLDocument("").body).innerHTML="
",2===Jt.childNodes.length),ce.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(le.createHTMLDocument?((r=(t=C.implementation.createHTMLDocument("")).createElement("base")).href=C.location.href,t.head.appendChild(r)):t=C),o=!n&&[],(i=w.exec(e))?[t.createElement(i[1])]:(i=Ae([e],t,o),o&&o.length&&ce(o).remove(),ce.merge([],i.childNodes)));var r,i,o},ce.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(ce.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},ce.expr.pseudos.animated=function(t){return ce.grep(ce.timers,function(e){return t===e.elem}).length},ce.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=ce.css(e,"position"),c=ce(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=ce.css(e,"top"),u=ce.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),v(t)&&(t=t.call(e,n,ce.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},ce.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){ce.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===ce.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===ce.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=ce(e).offset()).top+=ce.css(e,"borderTopWidth",!0),i.left+=ce.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-ce.css(r,"marginTop",!0),left:t.left-i.left-ce.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===ce.css(e,"position"))e=e.offsetParent;return e||J})}}),ce.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;ce.fn[t]=function(e){return M(this,function(e,t,n){var r;if(y(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),ce.each(["top","left"],function(e,n){ce.cssHooks[n]=Ye(le.pixelPosition,function(e,t){if(t)return t=Ge(e,n),_e.test(t)?ce(e).position()[n]+"px":t})}),ce.each({Height:"height",Width:"width"},function(a,s){ce.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){ce.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return M(this,function(e,t,n){var r;return y(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?ce.css(e,t,i):ce.style(e,t,n,i)},s,n?e:void 0,n)}})}),ce.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){ce.fn[t]=function(e){return this.on(t,e)}}),ce.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.on("mouseenter",e).on("mouseleave",t||e)}}),ce.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){ce.fn[n]=function(e,t){return 0make_url('admin', 'users'), 'admin.users', '']; + +//config_admin.append([users_edit, 'paramecio2.modules.admin.admin.ausers', 'admin_app.ausers', '']) diff --git a/modules/admin/templates/check_auth.php b/modules/admin/templates/check_auth.php new file mode 100644 index 0000000..40a49af --- /dev/null +++ b/modules/admin/templates/check_auth.php @@ -0,0 +1,68 @@ +layout('login_tpl', ['title' => $title])?> +start('content')?> +
+

logout and login again with other user

+

+

+ +

+ +

+
+end('content')?> +start('footer_js')?> + +end('footer_js')?> diff --git a/modules/admin/templates/layout.php b/modules/admin/templates/layout.php new file mode 100644 index 0000000..ea1172d --- /dev/null +++ b/modules/admin/templates/layout.php @@ -0,0 +1,218 @@ + + + + + + +<?=$title?> + + + +section('extra_css')?> + + + +section('extra_js')?> +section('extra_header')?> + + +
+
+
+
+ +
+ +
+ +
+ + +
+

+
+
+ +
+
+ +
+
+
+ + +
+ + + section('content')?> +
+
+
+
+
+ +section('footer_js')?> + + diff --git a/modules/admin/templates/list.php b/modules/admin/templates/list.php new file mode 100644 index 0000000..2fe78c2 --- /dev/null +++ b/modules/admin/templates/list.php @@ -0,0 +1,34 @@ + + +
+start('footer_js')?> + + + +end('footer_js')?> diff --git a/modules/admin/templates/login.php b/modules/admin/templates/login.php new file mode 100644 index 0000000..5cd768f --- /dev/null +++ b/modules/admin/templates/login.php @@ -0,0 +1,69 @@ +layout('login_tpl', ['title' => $title])?> +start('content')?> +
+

+

+

+

+ +

+ +

+
+end('content')?> +start('footer_js')?> + +end('footer_js')?> diff --git a/modules/admin/templates/login_tpl.php b/modules/admin/templates/login_tpl.php new file mode 100644 index 0000000..9c9ffc4 --- /dev/null +++ b/modules/admin/templates/login_tpl.php @@ -0,0 +1,140 @@ + + + + + + + <?=$title?> + + + section('header_js')?> + + + +
+

+

+ +

+ section('content')?> +
+ +section('footer_js')?> + + diff --git a/modules/admin/templates/signup.php b/modules/admin/templates/signup.php new file mode 100644 index 0000000..4196085 --- /dev/null +++ b/modules/admin/templates/signup.php @@ -0,0 +1,67 @@ +layout('login_tpl', ['title' => 'Signup'])?> +start('content')?> +
+

+

+

+

+

+

+

+ +

+

+ +

+
+end('content')?> +start('footer_js')?> + +end('footer_js')?> diff --git a/modules/admin/templates/users.php b/modules/admin/templates/users.php new file mode 100644 index 0000000..ba24a47 --- /dev/null +++ b/modules/admin/templates/users.php @@ -0,0 +1,4 @@ +layout('layout', ['title' => $title, 'path_module' => 'admin.home'])?> +start('content')?> + +end('content')?> diff --git a/modules/phangoapp/libraries/pharouter.php b/modules/phangoapp/libraries/pharouter.php new file mode 100644 index 0000000..5867af9 --- /dev/null +++ b/modules/phangoapp/libraries/pharouter.php @@ -0,0 +1,260 @@ + '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); + + } + + } + +} diff --git a/modules/phangoapp/libraries/phautils/utils.php b/modules/phangoapp/libraries/phautils/utils.php new file mode 100644 index 0000000..575ddf5 --- /dev/null +++ b/modules/phangoapp/libraries/phautils/utils.php @@ -0,0 +1,698 @@ +/', '/"/', '/\'/', "/ /"); + $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]='

'.trim($arr_text[$x]).' 

'; + + } + } + + + $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]).'
'; + + } + } + + $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=

+ + /*$text=preg_replace("//", "\n", $text);*/ + + /*if(Utils::$textbb_type!='') + { + + $text=str_replace("\r", '', $text); + $text=str_replace("\n", '', $text); + + } + else + { + + //Make

+ + $arr_text = explode("\n\r\n", $text); + + $c=count($arr_text); + + if($c>1) + { + for($x=0;$x<$c;$x++) + { + + $arr_text[$x]='

'.trim($arr_text[$x]).' 

'; + + } + } + + + $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]).'
'; + + } + } + + $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('/

\s+<\/p>$/s', $text)) + { + + $text=preg_replace('/

\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 (.*?)<\/p>/s", "$1\n\r\n", $text ); + $text = str_replace( "
", "", $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\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('', '', $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; + + } + + +} + +?> diff --git a/modules/phatemplates/.gitignore b/modules/phatemplates/.gitignore new file mode 100644 index 0000000..9300fb5 --- /dev/null +++ b/modules/phatemplates/.gitignore @@ -0,0 +1,2 @@ +*~ +vendor/* diff --git a/modules/phatemplates/libraries/templates.php b/modules/phatemplates/libraries/templates.php new file mode 100644 index 0000000..032cf9f --- /dev/null +++ b/modules/phatemplates/libraries/templates.php @@ -0,0 +1,157 @@ +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); + + } + +} diff --git a/settings/config.sample.php b/settings/config.sample.php index 9c94fcb..853af28 100644 --- a/settings/config.sample.php +++ b/settings/config.sample.php @@ -1,8 +1,5 @@ 'modules/welcome']; PhangoApp\PhaRouter\Config::$home_module='welcome';