From 5a2ba9c2e7605bb788bc406184547d22c6436867 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 23 Dec 2024 11:13:27 -0500 Subject: v2.1.0, refactor w/ crimson --- .env | 44 +++ .gitignore | 6 +- .gitmodules | 3 + LICENSE | 674 ++++++++++++++++++++++++++++++++- Makefile | 24 +- README.md | 31 +- build/init/Dockerfile | 21 - build/init/init | 148 -------- build/nginx/Dockerfile | 21 - build/php/Dockerfile | 17 - build/postgres/Dockerfile | 21 - build/postgrest/Dockerfile | 30 -- build/postgrest/entrypoint.sh | 21 - build/postgrest/postgrest.tar.xz | Bin 3648348 -> 0 bytes build/shim/Dockerfile | 9 - build/stamp.sh | 14 - conf/nginx/nginx.conf | 72 ---- conf/postgres/database.env | 17 - docker-compose.yml | 66 ---- shim/README.md | 9 + shim/shim.php | 298 +++++++++++++++ site | 1 + src/db/ext.sql | 7 - src/db/migrations/0000.sql | 24 -- src/db/migrations/0001.sql | 3 - src/db/rev.sql | 21 - src/public/font/Facebook.woff2 | Bin 46298 -> 0 bytes src/public/font/Helvetica Neue.woff2 | Bin 43230 -> 0 bytes src/public/font/Material Icons.woff2 | Bin 389031 -> 0 bytes src/public/font/SF Pro.woff2 | Bin 2719451 -> 0 bytes src/public/js/lib.js | 11 +- src/public/js/post.js | 6 +- src/public/js/thirdparty/jquery.min.js | 4 +- src/scss/_mixins.scss | 3 +- src/scss/_variables.scss | 19 +- src/scss/common.scss | 17 + src/scss/people.scss | 15 +- src/scss/post.scss | 11 + src/scss/settings.scss | 7 +- src/shim/shim.php | 298 --------------- src/web/_controller/_index.php | 23 -- src/web/_controller/_meta.php | 12 +- src/web/_controller/_modal.php | 28 ++ src/web/_controller/_post.php | 201 ++++++++++ src/web/_controller/_template.php | 21 + src/web/_controller/_util/post.php | 212 ----------- src/web/_controller/apps/auth.php | 56 --- src/web/_controller/apps/error.php | 21 - src/web/_controller/apps/home.php | 26 -- src/web/_controller/apps/people.php | 48 --- src/web/_controller/apps/profile.php | 44 --- src/web/_controller/apps/settings.php | 41 -- src/web/_controller/auth.php | 45 +++ src/web/_controller/error.php | 36 ++ src/web/_controller/home.php | 27 ++ src/web/_controller/index.php | 16 + src/web/_controller/modal.php | 38 -- src/web/_controller/people.php | 45 +++ src/web/_controller/profile.php | 44 +++ src/web/_controller/settings.php | 34 ++ src/web/_controller/template.php | 23 -- src/web/_model/apps/auth.php | 13 - src/web/_model/apps/error.php | 31 -- src/web/_model/apps/home.php | 22 -- src/web/_model/apps/people.php | 90 ----- src/web/_model/apps/profile.php | 65 ---- src/web/_model/apps/settings.php | 16 - src/web/_model/auth.php | 42 ++ src/web/_model/cache.php | 37 -- src/web/_model/error.php | 3 + src/web/_model/format.php | 36 -- src/web/_model/home.php | 17 + src/web/_model/main.php | 119 ------ src/web/_model/people.php | 72 ++++ src/web/_model/profile.php | 70 ++++ src/web/_model/request.php | 40 -- src/web/_model/settings.php | 3 + src/web/_views/_modal/about.php | 9 + src/web/_views/_modal/new_post.php | 56 +++ src/web/_views/_modal/register.php | 178 +++++++++ src/web/_views/_template/comment.php | 12 + src/web/_views/_template/error.php | 12 + src/web/_views/_template/modal.php | 14 + src/web/_views/_template/post.php | 86 +++++ src/web/_views/_template/posts.php | 32 ++ src/web/_views/_template/toast.php | 22 ++ src/web/_views/apps/auth/login.php | 87 ----- src/web/_views/apps/error/main.php | 6 - src/web/_views/apps/home/main.php | 27 -- src/web/_views/apps/people/card.php | 15 - src/web/_views/apps/people/footer.php | 3 - src/web/_views/apps/people/header.php | 6 - src/web/_views/apps/people/main.php | 72 ---- src/web/_views/apps/people/people.php | 7 - src/web/_views/apps/profile/main.php | 269 ------------- src/web/_views/apps/settings/main.php | 200 ---------- src/web/_views/auth/main.php | 87 +++++ src/web/_views/error/main.php | 6 + src/web/_views/head.php | 15 +- src/web/_views/header.php | 38 +- src/web/_views/home/main.php | 27 ++ src/web/_views/modal/about.php | 9 - src/web/_views/modal/new_post.php | 59 --- src/web/_views/modal/register.php | 178 --------- src/web/_views/people/card.php | 15 + src/web/_views/people/footer.php | 3 + src/web/_views/people/header.php | 6 + src/web/_views/people/main.php | 76 ++++ src/web/_views/people/people.php | 5 + src/web/_views/profile/main.php | 269 +++++++++++++ src/web/_views/settings/main.php | 197 ++++++++++ src/web/_views/template/comment.php | 15 - src/web/_views/template/error.php | 12 - src/web/_views/template/modal.php | 14 - src/web/_views/template/post.php | 87 ----- src/web/_views/template/posts.php | 25 -- src/web/_views/template/toast.php | 26 -- src/web/config.php | 56 +++ src/web/config/aesthetic.php | 83 ---- src/web/config/routes.php | 12 - src/web/core/_controller.php | 69 ---- src/web/core/_model.php | 44 --- src/web/core/database.php | 282 -------------- src/web/core/loader.php | 101 ----- src/web/core/router.php | 159 -------- src/web/helper/error.php | 9 - src/web/helper/image.php | 77 ---- src/web/helper/lang.php | 81 ---- src/web/index.php | 46 --- src/web/lang/api.php | 31 ++ src/web/lang/auth.php | 32 ++ src/web/lang/common.php | 61 +++ src/web/lang/en_US/api_lang.php | 33 -- src/web/lang/en_US/apps/auth.php | 34 -- src/web/lang/en_US/apps/home.php | 9 - src/web/lang/en_US/apps/people.php | 17 - src/web/lang/en_US/apps/profile.php | 46 --- src/web/lang/en_US/apps/settings.php | 25 -- src/web/lang/en_US/common_lang.php | 74 ---- src/web/lang/en_US/error_lang.php | 8 - src/web/lang/home.php | 7 + src/web/lang/people.php | 17 + src/web/lang/post.php | 35 ++ src/web/lang/profile.php | 43 +++ src/web/lang/settings.php | 25 ++ src/web/lib/_base.php | 61 +++ src/web/lib/_controller.php | 49 +++ src/web/lib/_model.php | 61 +++ src/web/lib/hooks.php | 31 ++ src/web/lib/image.php | 77 ++++ src/web/lib/utils.php | 6 + src/web/stamp.php | 46 +++ 152 files changed, 3607 insertions(+), 4232 deletions(-) create mode 100644 .env create mode 100644 .gitmodules delete mode 100644 build/init/Dockerfile delete mode 100755 build/init/init delete mode 100644 build/nginx/Dockerfile delete mode 100644 build/php/Dockerfile delete mode 100644 build/postgres/Dockerfile delete mode 100644 build/postgrest/Dockerfile delete mode 100755 build/postgrest/entrypoint.sh delete mode 100644 build/postgrest/postgrest.tar.xz delete mode 100644 build/shim/Dockerfile delete mode 100644 build/stamp.sh delete mode 100644 conf/nginx/nginx.conf delete mode 100644 conf/postgres/database.env delete mode 100644 docker-compose.yml create mode 100644 shim/README.md create mode 100755 shim/shim.php create mode 160000 site delete mode 100644 src/db/ext.sql delete mode 100644 src/db/rev.sql delete mode 100644 src/public/font/Facebook.woff2 delete mode 100644 src/public/font/Helvetica Neue.woff2 delete mode 100644 src/public/font/Material Icons.woff2 delete mode 100644 src/public/font/SF Pro.woff2 delete mode 100755 src/shim/shim.php delete mode 100644 src/web/_controller/_index.php create mode 100644 src/web/_controller/_modal.php create mode 100644 src/web/_controller/_post.php create mode 100644 src/web/_controller/_template.php delete mode 100644 src/web/_controller/_util/post.php delete mode 100644 src/web/_controller/apps/auth.php delete mode 100644 src/web/_controller/apps/error.php delete mode 100644 src/web/_controller/apps/home.php delete mode 100644 src/web/_controller/apps/people.php delete mode 100644 src/web/_controller/apps/profile.php delete mode 100644 src/web/_controller/apps/settings.php create mode 100644 src/web/_controller/auth.php create mode 100644 src/web/_controller/error.php create mode 100644 src/web/_controller/home.php create mode 100644 src/web/_controller/index.php delete mode 100644 src/web/_controller/modal.php create mode 100644 src/web/_controller/people.php create mode 100644 src/web/_controller/profile.php create mode 100644 src/web/_controller/settings.php delete mode 100644 src/web/_controller/template.php delete mode 100644 src/web/_model/apps/auth.php delete mode 100644 src/web/_model/apps/error.php delete mode 100644 src/web/_model/apps/home.php delete mode 100644 src/web/_model/apps/people.php delete mode 100644 src/web/_model/apps/profile.php delete mode 100644 src/web/_model/apps/settings.php create mode 100644 src/web/_model/auth.php delete mode 100644 src/web/_model/cache.php create mode 100644 src/web/_model/error.php delete mode 100644 src/web/_model/format.php create mode 100644 src/web/_model/home.php delete mode 100644 src/web/_model/main.php create mode 100644 src/web/_model/people.php create mode 100644 src/web/_model/profile.php delete mode 100644 src/web/_model/request.php create mode 100644 src/web/_model/settings.php create mode 100644 src/web/_views/_modal/about.php create mode 100644 src/web/_views/_modal/new_post.php create mode 100644 src/web/_views/_modal/register.php create mode 100644 src/web/_views/_template/comment.php create mode 100644 src/web/_views/_template/error.php create mode 100644 src/web/_views/_template/modal.php create mode 100644 src/web/_views/_template/post.php create mode 100644 src/web/_views/_template/posts.php create mode 100644 src/web/_views/_template/toast.php delete mode 100644 src/web/_views/apps/auth/login.php delete mode 100644 src/web/_views/apps/error/main.php delete mode 100644 src/web/_views/apps/home/main.php delete mode 100644 src/web/_views/apps/people/card.php delete mode 100644 src/web/_views/apps/people/footer.php delete mode 100644 src/web/_views/apps/people/header.php delete mode 100644 src/web/_views/apps/people/main.php delete mode 100644 src/web/_views/apps/people/people.php delete mode 100644 src/web/_views/apps/profile/main.php delete mode 100644 src/web/_views/apps/settings/main.php create mode 100644 src/web/_views/auth/main.php create mode 100644 src/web/_views/error/main.php create mode 100644 src/web/_views/home/main.php delete mode 100644 src/web/_views/modal/about.php delete mode 100644 src/web/_views/modal/new_post.php delete mode 100644 src/web/_views/modal/register.php create mode 100644 src/web/_views/people/card.php create mode 100644 src/web/_views/people/footer.php create mode 100644 src/web/_views/people/header.php create mode 100644 src/web/_views/people/main.php create mode 100644 src/web/_views/people/people.php create mode 100644 src/web/_views/profile/main.php create mode 100644 src/web/_views/settings/main.php delete mode 100644 src/web/_views/template/comment.php delete mode 100644 src/web/_views/template/error.php delete mode 100644 src/web/_views/template/modal.php delete mode 100644 src/web/_views/template/post.php delete mode 100644 src/web/_views/template/posts.php delete mode 100644 src/web/_views/template/toast.php create mode 100644 src/web/config.php delete mode 100644 src/web/config/aesthetic.php delete mode 100644 src/web/config/routes.php delete mode 100644 src/web/core/_controller.php delete mode 100644 src/web/core/_model.php delete mode 100644 src/web/core/database.php delete mode 100644 src/web/core/loader.php delete mode 100644 src/web/core/router.php delete mode 100644 src/web/helper/error.php delete mode 100644 src/web/helper/image.php delete mode 100644 src/web/helper/lang.php delete mode 100644 src/web/index.php create mode 100644 src/web/lang/api.php create mode 100644 src/web/lang/auth.php create mode 100644 src/web/lang/common.php delete mode 100644 src/web/lang/en_US/api_lang.php delete mode 100644 src/web/lang/en_US/apps/auth.php delete mode 100644 src/web/lang/en_US/apps/home.php delete mode 100644 src/web/lang/en_US/apps/people.php delete mode 100644 src/web/lang/en_US/apps/profile.php delete mode 100644 src/web/lang/en_US/apps/settings.php delete mode 100644 src/web/lang/en_US/common_lang.php delete mode 100644 src/web/lang/en_US/error_lang.php create mode 100644 src/web/lang/home.php create mode 100644 src/web/lang/people.php create mode 100644 src/web/lang/post.php create mode 100644 src/web/lang/profile.php create mode 100644 src/web/lang/settings.php create mode 100644 src/web/lib/_base.php create mode 100644 src/web/lib/_controller.php create mode 100644 src/web/lib/_model.php create mode 100644 src/web/lib/hooks.php create mode 100644 src/web/lib/image.php create mode 100644 src/web/lib/utils.php create mode 100644 src/web/stamp.php diff --git a/.env b/.env new file mode 100644 index 0000000..5c21f53 --- /dev/null +++ b/.env @@ -0,0 +1,44 @@ +# ============================= GENERAL == + +# project directory (absolute path) +# WARNING: CHANGE ME!!! +PROJECT_DIR="" + +# project name +PROJECT_NAME="xssbook" +SOURCE="$PROJECT_DIR/src" +DATA="$PROJECT_DIR/data" + +# production or devlopment +ENVIRONMENT="production" + +# ================================= WEB == + +# What port to listen on +HTTP_PORT=80 +HTTP_BIND=127.0.0.1 + +# ============================ DATABASE == + +# Do we want the postgres database enabled +POSTGRES_ENABLED=true + +# Database authentication +POSTGRES_DB=xssbook +POSTGRES_USER=xssbook +POSTGRES_PASSWORD=xssbook + +# ================================= API == + +# Do we want the postgrest api enabled +API_ENABLED=true + +# API Jwt Secret +# WARNING: CHANGE ME!!! +API_SECRET="809d5fca7979a5fbe184fae76fc53c5c587fd521bf06eb34585fd5d6a3fcbc10573aaf88a2a52fa5457223f78e3a6df4cd3135e0d0b60e84d49b28f634cb19c5ca29c9da88bd46b8f1b639bfde4b9515829031503debce3e85cf07bb224a9a3efa29b26adfeec42abf345eaf2fe828648a14b9e6b7e9a48a9bdc8607b8172251d3bdfa2dcf0c7f4368350e00a7b4bc3c975d37e5f8db031d32ec329c869f562c39358748926a9e26efd28bb15085c14de8b064ea2f8f8c58606c7dfe19721a1a0ad7deb2d5f5cc6f96fa0bdaf624cdfa196fcb802fc508b9e0328207897a7071857f87f89147d065d5c712fc7c7cc4dd1743a55a42dade16e3e86f905cf2ca28" + +# API Anonymous role +API_ROLE="rest_anon" + +# API schema +API_SCHEMA="api" diff --git a/.gitignore b/.gitignore index d1fa58e..ee70994 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -/data -/src/web/lang/en_CAT -/src/public/css/* +data +src/public/css/* +src/scss/_variables.scss diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..4ed3d5d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "site"] + path = site + url = https://g.freya.cat/freya/crimson diff --git a/LICENSE b/LICENSE index b915b7b..f288702 100644 --- a/LICENSE +++ b/LICENSE @@ -1,10 +1,674 @@ - The MIT License (MIT) + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 -Copyright © 2023 Freya Murphy + 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. -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + Preamble -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + The GNU General Public License is a free, copyleft license for +software and other kinds of works. -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + 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/Makefile b/Makefile index 1e30e2c..7e4e94e 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,26 @@ -MIXINS = $(shell find src/scss -name "_*.scss") +.PHONY: all clean build +.PHONY: FORCE + +all: clean build +build: build-css +clean: clean-css + +# =============================================== COMPILE SCSS == + +MIXINS = $(shell find src/scss -name "*.scss" -name "_*") SCSS = $(shell find src/scss -name "*.scss" -not -name "_*") CSS = $(patsubst src/scss/%.scss,src/public/css/%.css,$(SCSS)) -.PHONY: all clean css +.PHONY: build-css clean-css -all: clean css - -clean: - @# clean scss +clean-css: @printf "\033[31m RM \033[0m%s\n" src/public/css @rm -fr src/public/css/* -# =============================================== COMPILE SCSS == - -css: $(CSS) +build-css: $(CSS) -$(CSS): src/public/css/%.css : src/scss/%.scss $(MIXINS) +$(CSS) : src/public/css/%.css: src/scss/%.scss @printf "\033[33m SCSS \033[0m%s\n" $< @mkdir -p $(@D) @sassc --style compressed $< $@ diff --git a/README.md b/README.md index c78fedc..f291e21 100644 --- a/README.md +++ b/README.md @@ -8,32 +8,35 @@ now with xssbook you can run as much stallman disapprovement as you want - all inputs on the site are unfiltered - api calls dont care what you send them as long as they are valid strings - upload anyfiles to be your profile avatar and banner (even adobe flash!!!) -- /apidocs for api documentation ### installation -XXSBook v2 is a multi docker image setup. To run, download the repoistory, build the docker images, and then start the stack. +To get the checkout run: -``` -# download the images +```sh git clone https://g.freya.cat/freya/xssbook2 xssbook2 cd xssbook2 -# build and run the stack -docker compose pull -docker compose build -docker compose up -d ``` -The only configuration that you many want to change is the http port listed in the docker compose file. By default this is set to port 80, but it can be changed to whatever you want. +XSSBook v2 runs in docker compose. To run, you MUST do ALL of the following: -### migrating from xssbook v1 + - Update PROJECT_DIR in .env to be an absolute path to your current directory + - Build all css source from sass by running `make` + - Use `site/compose` instead of docker compose + +Finally, to build the images and start, run: -If you are runing a xssbook v1 setup, the database is fully incompatible with xssbook v2. Luckily there is a migration that exists to port over your data. XSSBook v1 has a single sqlite database file and a custom assets directory likly called `custom`. You will know you have the right directory if there are two sub directories called `avatar` and `banner`. Place the sqlite db file (called `xssbook.db`) and the `custom` directory in the `data/shim` folder of the xssbook v2 directory. If this doesnt exist please do a full setup of v2 first. Then run `docker compose up -d shim`, and you should be all set. +```sh +./site/compose build --pull +./site/compose up -d +``` + +> NOTE: You many want to change is HTTP_PORT and HTTP_BIND in .env. -> WARNING: This will delete ALL data in the database if you specify xssbook v1 files in the data path. Make sure yo only run this once and remove the files once completed. +### migrating from xssbook v1 -> NOTE: the migration will never run if the database files are not supplied. +See `shim/README.md` ### license -This project is licensed under the MIT license +This project is licensed under the GNU GPLv3. diff --git a/build/init/Dockerfile b/build/init/Dockerfile deleted file mode 100644 index 98eb285..0000000 --- a/build/init/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM alpine:3.19 - -# install packages -RUN apk add --no-cache postgresql16-client tini shadow -RUN rm -fr /var/cache/apk/* - -# setup main user -RUN adduser -D init -RUN groupmod --gid 1000 init -RUN usermod --uid 1000 init - -# copy scripts -COPY ./init /usr/local/bin/init - -# remove build packages -RUN apk del shadow - -# do the -USER init -ENTRYPOINT ["/sbin/tini", "--"] -CMD ["/usr/local/bin/init"] diff --git a/build/init/init b/build/init/init deleted file mode 100755 index c8dd3f0..0000000 --- a/build/init/init +++ /dev/null @@ -1,148 +0,0 @@ -#!/bin/sh - -errors=$(mktemp) - -step() { - printf '\x1b[34;1m>> %s\x1b[0m\n' "$*" -} - -error() { - { - printf '\x1b[31;1merror: \x1b[0m%s\n' "$*"; - grep -v 'current transaction is aborted' < "$errors"; - printf "\x1b[31m;1error: \x1b[0mAborting migrations, fix file(s) then restart process."; - } 1>&2; -} - -try() { - "$@" 2> "$errors"; - count=$(grep -c 'ERROR' < "$errors") - if [ "$count" -eq 0 ]; then - return 0; - else - return 1; - fi -} - -export PGPASSWORD="$POSTGRES_PASSWORD" - -psql() { - /usr/bin/psql \ - -h db \ - -p 5432 \ - -d "$POSTGRES_DB" \ - -U "$POSTGRES_USER" \ - "$@" -} - -pg_isready() { - /usr/bin/pg_isready \ - -h db \ - -p 5432 \ - -d "$POSTGRES_DB" \ - -U "$POSTGRES_USER" -} - -curr_revision() { - psql -qtAX -f /db/rev.sql; -} - -wait_until_ready() { - step 'Checking if the database is ready...'; - while true; do - pg_isready; - code=$?; - if [ $code -eq 0 ]; then - break; - fi - sleep 3; - done -} - -run_migrations() { - i="$1" - while true; do - name=$(printf "%04d" "$i"); - file="/db/migrations/$name.sql" - if [ -f "$file" ]; then - if try psql -f "$file"; then - i=$((i+1)); - continue; - else - error "An error occoured during a migration (rev $name)" - return 1; - fi - else - return 0; - fi - done -} - -init_api() { - if try psql -f /db/rest/rest.sql; then - return 0; - else - error "An error occoured during api initialization" - return 1; - fi -} - -update_jwt() { - if try psql -c "UPDATE sys.database_info SET jwt_secret = '$JWT_SECRET' WHERE name = current_database();"; then - return 0; - else - error "Could not update JWT" - return 1; - fi -} - -load_ext() { - psql -qtAX -f /db/ext.sql; -} - -init () { - # reomve ready status - # so php ignores requests - rm -f /status/ready - - step 'Waiting for database'; - # make sure the database is running - # before we run any requests - wait_until_ready; - step 'Database ready'; - - step 'Loading extensions'; - # Make sure extensions are loaded - load_ext; - - step 'Peforming migrations'; - # get the current revision - REV=$(curr_revision); - step "Database at revision: $REV" - # run each migration that is - # higher than our current revision - if ! run_migrations "$REV"; then - return 1; - fi - - step 'Initalizing the api'; - # reinit the api schema for - # postgrest - if ! init_api; then - return 1; - fi - - step 'Updating JWT secret'; - # make sure postgres has the corrent - # jwt secret - if ! update_jwt; then - return 1; - fi - - step 'Database is initialized' - # database is ready - touch /status/ready -} - -init -rm "$errors" diff --git a/build/nginx/Dockerfile b/build/nginx/Dockerfile deleted file mode 100644 index 6aa4e00..0000000 --- a/build/nginx/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM alpine:3.19 - -# install packages -RUN apk add --no-cache nginx shadow tini -RUN rm -fr /var/cache/apk/* - -# update nginx user -RUN groupmod --gid 1000 nginx -RUN usermod --uid 1000 nginx - -# remove build packages -RUN apk del shadow - -# make log syms -RUN ln -sf /dev/stdout /var/log/nginx/access.log && \ - ln -sf /dev/stderr /var/log/nginx/error.log - -# do the -USER nginx -ENTRYPOINT ["/sbin/tini", "--"] -CMD ["/usr/sbin/nginx", "-c", "/etc/nginx/nginx.conf"] diff --git a/build/php/Dockerfile b/build/php/Dockerfile deleted file mode 100644 index 5f4bdd5..0000000 --- a/build/php/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM php:fpm-alpine - -# install packages -RUN apk add --no-cache postgresql-dev runuser shadow -RUN rm -fr /var/cache/apk/* - -# update php user -RUN groupmod --gid 1000 www-data -RUN usermod --uid 1000 www-data - -# install php packages -RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql -RUN docker-php-ext-install pdo pdo_pgsql - -# remove build packages -RUN apk del shadow -USER www-data diff --git a/build/postgres/Dockerfile b/build/postgres/Dockerfile deleted file mode 100644 index 32bca6e..0000000 --- a/build/postgres/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM postgres:16-alpine - -# install packages -RUN apk add --no-cache make git shadow -RUN rm -fr /var/cache/apk/* - -# install pgjwt -RUN git clone https://github.com/michelp/pgjwt.git /tmp/pgjwt -WORKDIR /tmp/pgjwt -RUN make install - -# update postgres user -RUN groupmod --gid 1000 postgres -RUN usermod --uid 1000 postgres - -# remove build packages -RUN apk del make git shadow - -# fix workdir -WORKDIR / -USER postgres diff --git a/build/postgrest/Dockerfile b/build/postgrest/Dockerfile deleted file mode 100644 index bf1a573..0000000 --- a/build/postgrest/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM alpine:3.19 - -# install packages -RUN apk add --no-cache tini shadow -RUN rm -fr /var/cache/apk/* - -# setup main user -RUN adduser -D postgrest -RUN groupmod --gid 1000 postgrest -RUN usermod --uid 1000 postgrest - -# install postgrest -COPY ./postgrest.tar.xz /tmp/postgrest.tar.xz -RUN tar xJf /tmp/postgrest.tar.xz -C /usr/local/bin -RUN rm /tmp/postgrest.tar.xz - -# copy scripts -COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh - -# remove build packages -RUN apk del shadow - -# make the dirs -RUN mkdir -p /etc/postgrest.d && \ - chown postgrest:postgrest /etc/postgrest.d - -# do the -USER postgrest -ENTRYPOINT ["/sbin/tini", "--"] -CMD ["/usr/local/bin/entrypoint.sh"] diff --git a/build/postgrest/entrypoint.sh b/build/postgrest/entrypoint.sh deleted file mode 100755 index 71b433d..0000000 --- a/build/postgrest/entrypoint.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -config=/etc/postgrest.d/postgrest.conf - -PGRST_DB_URI="postgres://authenticator:postgrest@db:5432/$POSTGRES_DB" -PGRST_ROLE="rest_anon" -PGRST_SCHEMA="api" - -rm -fr "$config" -touch "$config" -{ - printf 'db-uri = "%s"\n' "$PGRST_DB_URI"; - printf 'db-anon-role = "%s"\n' "$PGRST_ROLE"; - printf 'db-schemas = "%s"\n' "$PGRST_SCHEMA"; - printf 'jwt-secret = "%s"\n' "$JWT_SECRET"; - printf 'jwt-secret-is-base64 = false\n'; - printf 'server-host = "*"\n'; - printf 'server-port = 3000\n'; -} >> $config - -exec /usr/local/bin/postgrest "$config" diff --git a/build/postgrest/postgrest.tar.xz b/build/postgrest/postgrest.tar.xz deleted file mode 100644 index 33c2b2d..0000000 Binary files a/build/postgrest/postgrest.tar.xz and /dev/null differ diff --git a/build/shim/Dockerfile b/build/shim/Dockerfile deleted file mode 100644 index 82cc9a7..0000000 --- a/build/shim/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM alpine:3.19 -RUN apk add --no-cache \ - php83 \ - php83-pdo \ - php83-pdo_sqlite \ - php83-pdo_pgsql \ - tini -ENTRYPOINT ["/sbin/tini", "--"] -CMD ["/usr/bin/php83", "/opt/shim/shim.php"] diff --git a/build/stamp.sh b/build/stamp.sh deleted file mode 100644 index 3b19b04..0000000 --- a/build/stamp.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -out="./src/web/stamp.php" -public="./src/public" -files=$(find "$public" -type f -printf %P\\n) - -printf " "$out" -for file in $files; do - stamp=$(date +%s -r "$public/$file") - echo "\$__stamps['public/$file'] = $stamp;" >> "$out"; -done -echo "define('FILE_TIMES', \$__stamps);" >> "$out" -echo "unset(\$__stamps);" >> "$out" - diff --git a/conf/nginx/nginx.conf b/conf/nginx/nginx.conf deleted file mode 100644 index 64f1b1d..0000000 --- a/conf/nginx/nginx.conf +++ /dev/null @@ -1,72 +0,0 @@ -worker_processes 4; -daemon off; -pid /tmp/nginx.pid; -error_log /var/log/nginx/error.log; - -events { - worker_connections 1024; -} - -http { - include mime.types; - default_type application/octet-stream; - sendfile on; - keepalive_timeout 70; - server_tokens off; - client_max_body_size 2m; - - access_log /var/log/nginx/access.log; - - upstream postgrest { - server rest:3000; - } - - server { - listen 8080; - root /opt/xssbook; - - gzip on; - gzip_vary on; - gzip_proxied any; - gzip_comp_level 6; - gzip_buffers 16 8k; - gzip_http_version 1.1; - gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml image/x-icon; - - location /api/ { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_set_header Accept-Encoding ""; - proxy_redirect off; - - default_type application/json; - add_header 'Access-Control-Allow-Origin' '*'; - add_header Content-Location /api/$upstream_http_content_location; - proxy_set_header Connection ""; - proxy_http_version 1.1; - - proxy_pass http://postgrest/; - } - - location /favicon.ico { - add_header 'Access-Control-Allow-Origin' '*'; - root /opt/xssbook/public; - add_header Cache-Control "public, max-age=108000"; - } - - location /public { - add_header 'Access-Control-Allow-Origin' '*'; - try_files $uri =404; - add_header Cache-Control "public, max-age=108000"; - } - - location / { - add_header 'Access-Control-Allow-Origin' '*'; - root /opt/xssbook/web; - include fastcgi_params; - fastcgi_pass php:9000; - fastcgi_param SCRIPT_FILENAME $document_root/index.php; - } - - } -} diff --git a/conf/postgres/database.env b/conf/postgres/database.env deleted file mode 100644 index 0361637..0000000 --- a/conf/postgres/database.env +++ /dev/null @@ -1,17 +0,0 @@ -# -# Dynamic env vars -# Can be changed -# -POSTGRES_PASSWORD=xssbook - -# CHANGE THIS -# do not use the default provided jwt secret key -JWT_SECRET="809d5fca7979a5fbe184fae76fc53c5c587fd521bf06eb34585fd5d6a3fcbc10573aaf88a2a52fa5457223f78e3a6df4cd3135e0d0b60e84d49b28f634cb19c5ca29c9da88bd46b8f1b639bfde4b9515829031503debce3e85cf07bb224a9a3efa29b26adfeec42abf345eaf2fe828648a14b9e6b7e9a48a9bdc8607b8172251d3bdfa2dcf0c7f4368350e00a7b4bc3c975d37e5f8db031d32ec329c869f562c39358748926a9e26efd28bb15085c14de8b064ea2f8f8c58606c7dfe19721a1a0ad7deb2d5f5cc6f96fa0bdaf624cdfa196fcb802fc508b9e0328207897a7071857f87f89147d065d5c712fc7c7cc4dd1743a55a42dade16e3e86f905cf2ca28" - -# -# Static env vars -# do not change unless you -# know what you are doign -# -POSTGRES_USER=xssbook -POSTGRES_DB=xssbook diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 10a37a3..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -services: - web: - build: ./build/nginx - restart: unless-stopped - ports: - - '80:8080' - volumes: - - ./src:/opt/xssbook:ro - - ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro - depends_on: - - rest - - php - - php: - build: ./build/php - restart: unless-stopped - env_file: - - ./conf/postgres/database.env - volumes: - - ./src:/opt/xssbook:ro - - ./data/status:/status:ro - - ./data/session:/var/lib/php/session - depends_on: - - db - - db: - build: ./build/postgres - restart: unless-stopped - env_file: - - ./conf/postgres/database.env - environment: - - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C - volumes: - - './data/schemas:/var/lib/postgresql/data' - - ./src/db:/db:ro - - rest: - build: ./build/postgrest - restart: unless-stopped - env_file: - - ./conf/postgres/database.env - depends_on: - - db - - init: - build: ./build/init - restart: no - env_file: - - ./conf/postgres/database.env - volumes: - - ./src/db:/db:ro - - ./data/status:/status - depends_on: - - db - - shim: - build: ./build/shim - restart: no - env_file: - - ./conf/postgres/database.env - volumes: - - ./src/shim:/opt/shim:ro - - ./data/status:/status:ro - - ./data/shim/:/data:ro - depends_on: - - db diff --git a/shim/README.md b/shim/README.md new file mode 100644 index 0000000..80dfb3a --- /dev/null +++ b/shim/README.md @@ -0,0 +1,9 @@ +## shim + +TODO: update beacuse this is now invalid :( + +If you are runing a xssbook v1 setup, the database is fully incompatible with xssbook v2. Luckily there is a migration that exists to port over your data. XSSBook v1 has a single sqlite database file and a custom assets directory likly called `custom`. You will know you have the right directory if there are two sub directories called `avatar` and `banner`. Place the sqlite db file (called `xssbook.db`) and the `custom` directory in the `data/shim` folder of the xssbook v2 directory. If this doesnt exist please do a full setup of v2 first. Then run `docker compose up -d shim`, and you should be all set. + +> WARNING: This will delete ALL data in the database if you specify xssbook v1 files in the data path. Make sure yo only run this once and remove the files once completed. + +> NOTE: the migration will never run if the database files are not supplied. diff --git a/shim/shim.php b/shim/shim.php new file mode 100755 index 0000000..eb84412 --- /dev/null +++ b/shim/shim.php @@ -0,0 +1,298 @@ +#!/usr/bin/env php +setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + + return $conn; +} + +function connect_sqlite() { + $conn_str = sprintf("sqlite:/data/xssbook.db"); + $conn = new \PDO($conn_str); + $conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + + return $conn; +} + +$psql = connect_psql(); +$sqlite = connect_sqlite(); + +function error() { + $psql->rollBack(); + die(); +} + +function get_date( + $day, $month, $year +) { + if (checkdate($month, $day, $year)) { + $date = "{$year}-{$month}-{$day}"; + return $date; + } else { + return "1970-01-01"; + } +} + +function clear_all() { + echo "clearing database\n"; + extract($GLOBALS); + $psql->beginTransaction(); + $psql->exec( + 'DELETE FROM xssbook.user; + DELETE FROM xssbook.post; + DELETE FROM xssbook.comment; + DELETE FROM xssbook.like; + DELETE FROM xssbook.follow; + DELETE FROM xssbook.user_media;' + ); +} + +function migrate_users() { + echo "migrating users\n"; + extract($GLOBALS); + + // load queries + $query = $sqlite->prepare( + 'SELECT user_id, firstname, lastname, email, password, gender, date, day, month, year FROM users;' + ); + $submit = $psql->prepare( + 'INSERT INTO xssbook.user + (id, username, password, first_name, last_name, email, gender, birth_date, created) + VALUES + (?, ?, ?, ?, ?, ?, ?, ?, to_timestamp(?));' + ); + + // load users + $query->execute(); + $rows = $query->fetchAll(); + foreach ($rows as $user) { + // submit each user + $date = get_date( + $user['day'], $user['month'], $user['year'] + ); + $joined = $user['date'] / 1000; + $submit->execute(array( + $user['user_id'], + $user['email'], + $user['password'], + $user['firstname'], + $user['lastname'], + $user['email'], + $user['gender'], + $date, + $joined + )); + } +} + +function migrate_posts() { + echo "migrating posts\n"; + extract($GLOBALS); + + // load queries + $query = $sqlite->prepare( + 'SELECT post_id, user_id, content, date FROM posts;' + ); + $submit = $psql->prepare( + 'INSERT INTO xssbook.post + (id, user_id, content, created) + VALUES + (?, ?, ?, to_timestamp(?));' + ); + + // load posts + $query->execute(); + $rows = $query->fetchall(); + foreach ($rows as $post) { + $created = $post['date'] / 1000; + $submit->execute(array( + $post['post_id'], + $post['user_id'], + $post['content'], + $created + )); + } +} + +function migrate_comments() { + echo "migrating comments\n"; + extract($GLOBALS); + + // load queries + $query = $sqlite->prepare( + 'SELECT comment_id, user_id, post_id, content, date FROM comments;' + ); + $submit = $psql->prepare( + 'INSERT INTO xssbook.comment + (id, user_id, post_id, content, created) + VALUES + (?, ?, ?, ?, to_timestamp(?));' + ); + + // load comments + $query->execute(); + $rows = $query->fetchall(); + foreach ($rows as $comment) { + $created = $comment['date'] / 1000; + $submit->execute(array( + $comment['comment_id'], + $comment['user_id'], + $comment['post_id'], + $comment['content'], + $created + )); + } +} + +function migrate_likes() { + echo "migrating likes\n"; + extract($GLOBALS); + + // load queries + $query = $sqlite->prepare( + 'SELECT user_id, post_id FROM likes;' + ); + $submit = $psql->prepare( + 'INSERT INTO xssbook.like + (user_id, post_id) + VALUES + (?, ?);' + ); + + // load likes + $query->execute(); + $rows = $query->fetchall(); + foreach ($rows as $like) { + $submit->execute(array( + $like['user_id'], + $like['post_id'] + )); + } +} + +function migrate_follow() { + echo "migrating follow\n"; + extract($GLOBALS); + + // load queries + $query = $sqlite->prepare( + 'SELECT follower_id, followee_id FROM friends;' + ); + $submit = $psql->prepare( + 'INSERT INTO xssbook.follow + (follower_id, followee_id) + VALUES + (?, ?);' + ); + + // load follows + $query->execute(); + $rows = $query->fetchall(); + foreach ($rows as $follow) { + $submit->execute(array( + $follow['follower_id'], + $follow['followee_id'] + )); + } +} + +function migrate_user_media($type) { + echo "migrating user media ($type)\n"; + extract($GLOBALS); + + // load queries + $submit = $psql->prepare( + 'INSERT INTO xssbook.user_media + (user_id, content, mime, type) + VALUES + (?, decode(?, \'base64\'), ?, ?);' + ); + + // get dir + $dir = "/data/custom/{$type}"; + if (!is_dir($dir)) { + return; + } + + // load user media + if ($handle = opendir($dir)) { + while (FALSE !== ($file = readdir($handle))) { + if ('.' === $file) continue; + if ('..' === $file) continue; + $n = strpos($file, ".png"); + $uid = substr($file, 0, $n); + $path = "{$dir}/{$file}"; + $data = base64_encode(file_get_contents($path)); + + $submit->execute(array( + $uid, + $data, + 'image/png', + $type + )); + } + closedir($handle); + } +} + +function migrate_seq() { + echo "migrating sequences\n"; + extract($GLOBALS); + + $tables = array('user', 'post', 'like', 'comment', 'follow', 'user_media'); + + foreach ($tables as $table) { + $sql = "SELECT setval('sys.{$table}_id_seq', (SELECT MAX(id) FROM xssbook.{$table}), true);"; + $psql->exec($sql); + } +} + +try { + wait_until_ready(); + clear_all(); + migrate_users(); + migrate_posts(); + migrate_comments(); + migrate_likes(); + migrate_follow(); + migrate_user_media('avatar'); + migrate_user_media('banner'); + migrate_seq(); +} catch (Exception $ex) { + echo "$ex\n"; + $psql->rollBack(); + die(); +} + +$psql->commit(); diff --git a/site b/site new file mode 160000 index 0000000..acfd477 --- /dev/null +++ b/site @@ -0,0 +1 @@ +Subproject commit acfd47748d1da62ac976fba8450277c88b402110 diff --git a/src/db/ext.sql b/src/db/ext.sql deleted file mode 100644 index 2f3376f..0000000 --- a/src/db/ext.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN TRANSACTION; -SET search_path = public; - -CREATE EXTENSION IF NOT EXISTS pgcrypto; -CREATE EXTENSION IF NOT EXISTS pgjwt; - -COMMIT TRANSACTION; diff --git a/src/db/migrations/0000.sql b/src/db/migrations/0000.sql index aa20d2f..e921578 100644 --- a/src/db/migrations/0000.sql +++ b/src/db/migrations/0000.sql @@ -3,30 +3,6 @@ SET search_path = public; -- Migration Start -CREATE SCHEMA sys; - -ALTER SCHEMA sys OWNER TO xssbook; - -CREATE DOMAIN sys."*/*" AS BYTEA; - -CREATE TABLE sys.database_info ( - name TEXT DEFAULT ''::text NOT NULL, - jwt_secret TEXT DEFAULT ''::text NOT NULL, - curr_revision INTEGER DEFAULT 0 NOT NULL -); - -ALTER TABLE sys.database_info - ADD CONSTRAINT database_info_pkey PRIMARY KEY (name); - -ALTER TABLE sys.database_info OWNER TO xssbook; - -INSERT INTO sys.database_info - (name, curr_revision) VALUES (current_database(), 0); - -CREATE TYPE sys.JWT AS ( - token TEXT -); - CREATE SCHEMA admin; ALTER SCHEMA admin OWNER TO xssbook; diff --git a/src/db/migrations/0001.sql b/src/db/migrations/0001.sql index d20d895..9f6f312 100644 --- a/src/db/migrations/0001.sql +++ b/src/db/migrations/0001.sql @@ -2,9 +2,6 @@ BEGIN TRANSACTION; SET search_path = public; -- Migration Start -CREATE ROLE authenticator LOGIN NOINHERIT NOCREATEDB NOCREATEROLE NOSUPERUSER; --- scary, make sure the db is not public!!! -ALTER ROLE authenticator WITH PASSWORD 'postgrest'; CREATE ROLE rest_anon NOLOGIN; CREATE ROLE rest_user NOLOGIN; GRANT rest_anon TO authenticator; diff --git a/src/db/rev.sql b/src/db/rev.sql deleted file mode 100644 index dff1cfe..0000000 --- a/src/db/rev.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE OR REPLACE FUNCTION curr_revision() -RETURNS INTEGER -LANGUAGE plpgsql VOLATILE -AS $BODY$ -DECLARE - _revision INTEGER; -BEGIN - BEGIN - SELECT curr_revision INTO _revision - FROM sys.database_info - WHERE name = current_database(); - RETURN _revision; - EXCEPTION WHEN OTHERS THEN - RETURN 0; - END; -END -$BODY$; - -GRANT EXECUTE ON FUNCTION curr_revision() TO xssbook; - -SELECT curr_revision(); diff --git a/src/public/font/Facebook.woff2 b/src/public/font/Facebook.woff2 deleted file mode 100644 index fcfea6c..0000000 Binary files a/src/public/font/Facebook.woff2 and /dev/null differ diff --git a/src/public/font/Helvetica Neue.woff2 b/src/public/font/Helvetica Neue.woff2 deleted file mode 100644 index c02d45d..0000000 Binary files a/src/public/font/Helvetica Neue.woff2 and /dev/null differ diff --git a/src/public/font/Material Icons.woff2 b/src/public/font/Material Icons.woff2 deleted file mode 100644 index 4b3b9d4..0000000 Binary files a/src/public/font/Material Icons.woff2 and /dev/null differ diff --git a/src/public/font/SF Pro.woff2 b/src/public/font/SF Pro.woff2 deleted file mode 100644 index 5f7f7fb..0000000 Binary files a/src/public/font/SF Pro.woff2 and /dev/null differ diff --git a/src/public/js/lib.js b/src/public/js/lib.js index e19f6c6..e7dba8a 100644 --- a/src/public/js/lib.js +++ b/src/public/js/lib.js @@ -45,8 +45,8 @@ var $$ = (selector) => { }); let config = { childList: true, subtree: true }; - let MutationObserver = window.MutationObserver; - let observer = new MutationObserver(onMutate); + let MutationObserver = window.MutationObserver; + let observer = new MutationObserver(onMutate); observer.observe(document.body, config); }); @@ -61,6 +61,7 @@ var $$ = (selector) => { /// var errorToastAjax = (xhr) => { + console.log(xhr) let data = xhr.responseJSON; let msg, detail, hint; @@ -81,21 +82,21 @@ var errorToastAjax = (xhr) => { if (hint) { query += '&hint=' + hint; } - let url = '/template/toast' + query; + let url = '/_template/toast' + query; $.get(url, function (data) { $('#toast-container').prepend(data); }) } var errorToast = (msg) => { - let url = '/template/toast?msg=' + msg; + let url = '/_template/toast?msg=' + msg; $.get(url, function (data) { $('#toast-container').prepend(data); }) } var successToast = (msg) => { - let url = '/template/toast?type=success&msg=' + msg; + let url = '/_template/toast?type=success&msg=' + msg; $.get(url, function (data) { $('#toast-container').prepend(data); }) diff --git a/src/public/js/post.js b/src/public/js/post.js index a7b05c6..4ede5b5 100644 --- a/src/public/js/post.js +++ b/src/public/js/post.js @@ -14,7 +14,7 @@ $$('.action-load-comments').on('click', function() { let commmentCount = Number(me.attr('commentCount')); let commentMax = Number(me.attr('commentMax')); - let url = '/_util/post/comments?page=' + page + '&id=' + postId + '&max' + commentMax; + let url = '/_post/comments?page=' + page + '&id=' + postId + '&max' + commentMax; $.get(url, function (data) { if (data === '') { me.remove(); @@ -47,7 +47,7 @@ $$('#action-load-posts').on('click', function() { let postMax = Number(me.attr('postMax')); let filterUid = me.attr('userId'); - let url = '/_util/post/posts?page=' + page + '&max=' + postMax; + let url = '/_post/posts?page=' + page + '&max=' + postMax; if (!isNaN(filterUid)) { console.log(filterUid); @@ -89,7 +89,7 @@ $$('.action-new-comment-form').on('submit', function(e) { const onComment = function(data) { let id = data[0].id; $.get({ - url: '/_util/post/comment?id=' + id, + url: '/_post/comment?id=' + id, success: getComment }); } diff --git a/src/public/js/thirdparty/jquery.min.js b/src/public/js/thirdparty/jquery.min.js index 7f37b5d..874a70c 100644 --- a/src/public/js/thirdparty/jquery.min.js +++ b/src/public/js/thirdparty/jquery.min.js @@ -1,2 +1,2 @@ -/*! jQuery v3.7.1 | (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(ie,e){"use strict";var oe=[],r=Object.getPrototypeOf,ae=oe.slice,g=oe.flat?function(e){return oe.flat.call(e)}:function(e){return oe.concat.apply([],e)},s=oe.push,se=oe.indexOf,n={},i=n.toString,ue=n.hasOwnProperty,o=ue.toString,a=o.call(Object),le={},v=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},y=function(e){return null!=e&&e===e.window},C=ie.document,u={type:!0,src:!0,nonce:!0,noModule:!0};function m(e,t,n){var r,i,o=(n=n||C).createElement("script");if(o.text=e,t)for(r in u)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e}var t="3.7.1",l=/HTML$/i,ce=function(e,t){return new ce.fn.init(e,t)};function c(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!v(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&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 00&&t-1 in e)}var y=e.document,m={type:!0,src:!0,nonce:!0,noModule:!0};function x(e,t,n){var r,i=(n=n||y).createElement("script");for(r in i.text=e,m)t&&t[r]&&(i[r]=t[r]);n.head.appendChild(i).parentNode&&i.parentNode.removeChild(i)}var b="4.0.0-beta.2",w=/HTML$/i,T=function(e,t){return new T.fn.init(e,t)};function C(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}T.fn=T.prototype={jquery:b,constructor:T,length:0,toArray:function(){return i.call(this)},get:function(e){return null==e?i.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=T.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return T.each(this,e)},map:function(e){return this.pushStack(T.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(i.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(T.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(T.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n+~]|"+E+")"+E+"*"),N=RegExp(E+"|>"),O=/[+~]/,H=y.documentElement,L=H.matches||H.msMatchesSelector;function P(){var e=[];return function t(n,r){return e.push(n+" ")>T.expr.cacheLength&&delete t[e.shift()],t[n+" "]=r}}function R(e){return e&&void 0!==e.getElementsByTagName&&e}var M="\\["+E+"*("+A+")(?:"+E+"*([*^$|!~]?=)"+E+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+A+"))|)"+E+"*\\]",W=":("+A+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+M+")*)|.*)\\)|)",$={ID:RegExp("^#("+A+")"),CLASS:RegExp("^\\.("+A+")"),TAG:RegExp("^("+A+"|[*])"),ATTR:RegExp("^"+M),PSEUDO:RegExp("^"+W),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+E+"*(even|odd|(([+-]|)(\\d*)n|)"+E+"*(?:([+-]|)"+E+"*(\\d+)|))"+E+"*\\)|)","i")},I=new RegExp(W),F=RegExp("\\\\[\\da-fA-F]{1,6}"+E+"?|\\\\([^\\r\\n\\f])","g"),B=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))};function _(e){return e.replace(F,B)}function U(e){T.error("Syntax error, unrecognized expression: "+e)}var X=RegExp("^"+E+"*,"+E+"*"),z=P();function V(e,t){var n,r,i,o,a,s,u,l=z[e+" "];if(l)return t?0:l.slice(0);a=e,s=[],u=T.expr.preFilter;while(a){for(o in(!n||(r=X.exec(a)))&&(r&&(a=a.slice(r[0].length)||a),s.push(i=[])),n=!1,(r=q.exec(a))&&(n=r.shift(),i.push({value:n,type:r[0].replace(D," ")}),a=a.slice(n.length)),$)(r=T.expr.match[o].exec(a))&&(!u[o]||(r=u[o](r)))&&(n=r.shift(),i.push({value:n,type:o,matches:r}),a=a.slice(n.length));if(!n)break}return t?a.length:a?U(e):z(e,s).slice(0)}function Y(e){for(var t=0,n=e.length,r="";t1)},removeAttr:function(e){return this.each(function(){T.removeAttr(this,e)})}}),T.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o){if(void 0===e.getAttribute)return T.prop(e,t,n);if(1===o&&T.isXMLDoc(e)||(i=T.attrHooks[t.toLowerCase()]),void 0!==n){if(null===n||!1===n&&0!==t.toLowerCase().indexOf("aria-")){T.removeAttr(e,t);return}return i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n),n)}return i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=e.getAttribute(t))?void 0:r}},attrHooks:{},removeAttr:function(e,t){var n,r=0,i=t&&t.match(Q);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),k&&(T.attrHooks.type={set:function(e,t){if("radio"===t&&C(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}});var J=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function K(e,t){return t?"\0"===e?"\uFFFD":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e}T.escapeSelector=function(e){return(e+"").replace(J,K)};var Z=n.sort,ee=n.splice;function et(e,t){if(e===t)return en=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)?e==y||e.ownerDocument==y&&T.contains(y,e)?-1:t==y||t.ownerDocument==y&&T.contains(y,t)?1:0:4&n?-1:1)}T.uniqueSort=function(e){var t,n=[],r=0,i=0;if(en=!1,Z.call(e,et),en){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)ee.call(e,n[r],1)}return e},T.fn.uniqueSort=function(){return this.pushStack(T.uniqueSort(i.apply(this)))};var en,er,ei,eo,ea,es,eu=0,el=0,ec=P(),ef=P(),ep=P(),ed=RegExp(E+"+","g"),eh=RegExp("^"+A+"$"),eg=T.extend({needsContext:RegExp("^"+E+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+E+"*((?:-\\d)?\\d*)"+E+"*\\)|)(?=[^-]|$)","i")},$),ev=/^(?:input|select|textarea|button)$/i,ey=/^h\d$/i,em=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ex=function(){eE()},eb=eS(function(e){return!0===e.disabled&&C(e,"fieldset")},{dir:"parentNode",next:"legend"});function ew(e,t,n,r){var i,o,s,u,l,c,f,p=t&&t.ownerDocument,d=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==d&&9!==d&&11!==d)return n;if(!r&&(eE(t),t=t||eo,es)){if(11!==d&&(l=em.exec(e))){if(i=l[1]){if(9===d)return(s=t.getElementById(i))&&a.call(n,s),n;if(p&&(s=p.getElementById(i))&&T.contains(t,s))return a.call(n,s),n}else if(l[2])return a.apply(n,t.getElementsByTagName(e)),n;else if((i=l[3])&&t.getElementsByClassName)return a.apply(n,t.getElementsByClassName(i)),n}if(!ep[e+" "]&&(!S||!S.test(e))){if(f=e,p=t,1===d&&(N.test(e)||q.test(e))){((p=O.test(e)&&R(t.parentNode)||t)!=t||k)&&((u=t.getAttribute("id"))?u=T.escapeSelector(u):t.setAttribute("id",u=T.expando)),o=(c=V(e)).length;while(o--)c[o]=(u?"#"+u:":scope")+" "+Y(c[o]);f=c.join(",")}try{return a.apply(n,p.querySelectorAll(f)),n}catch(t){ep(e,!0)}finally{u===T.expando&&t.removeAttribute("id")}}}return eN(e.replace(D,"$1"),t,n,r)}function eT(e){return e[T.expando]=!0,e}function eC(e){return function(t){if("form"in t)return t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||!e!==t.isDisabled&&eb(t)===e:t.disabled===e;return"label"in t&&t.disabled===e}}function ej(e){return eT(function(t){return t=+t,eT(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function eE(e){var t,n=e?e.ownerDocument||e:y;n!=eo&&9===n.nodeType&&(ea=(eo=n).documentElement,es=!T.isXMLDoc(eo),k&&y!=eo&&(t=eo.defaultView)&&t.top!==t&&t.addEventListener("unload",ex))}for(er in ew.matches=function(e,t){return ew(e,null,null,t)},ew.matchesSelector=function(e,t){if(eE(e),es&&!ep[t+" "]&&(!S||!S.test(t)))try{return L.call(e,t)}catch(e){ep(t,!0)}return ew(t,eo,null,[e]).length>0},T.expr={cacheLength:50,createPseudo:eT,match:eg,find:{ID:function(e,t){if(void 0!==t.getElementById&&es){var n=t.getElementById(e);return n?[n]:[]}},TAG:function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):t.querySelectorAll(e)},CLASS:function(e,t){if(void 0!==t.getElementsByClassName&&es)return t.getElementsByClassName(e)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=_(e[1]),e[3]=_(e[3]||e[4]||e[5]||""),"~="===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]||U(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]&&U(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return $.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&I.test(n)&&(t=V(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:{ID:function(e){var t=_(e);return function(e){return e.getAttribute("id")===t}},TAG:function(e){var t=_(e).toLowerCase();return"*"===e?function(){return!0}:function(e){return C(e,t)}},CLASS:function(e){var t=ec[e+" "];return t||(t=RegExp("(^|"+E+")"+e+"("+E+"|$)"),ec(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")}))},ATTR:function(e,t,n){return function(r){var i=T.attr(r,e);return null==i?"!="===t:!t||((i+="","="===t)?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace(ed," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h=o!==a?"nextSibling":"previousSibling",g=t.parentNode,v=s&&t.nodeName.toLowerCase(),y=!u&&!s,m=!1;if(g){if(o){while(h){f=t;while(f=f[h])if(s?C(f,v):1===f.nodeType)return!1;d=h="only"===e&&!d&&"nextSibling"}return!0}if(d=[a?g.firstChild:g.lastChild],a&&y){m=(p=(l=(c=g[T.expando]||(g[T.expando]={}))[e]||[])[0]===eu&&l[1])&&l[2],f=p&&g.childNodes[p];while(f=++p&&f&&f[h]||(m=p=0)||d.pop())if(1===f.nodeType&&++m&&f===t){c[e]=[eu,p,m];break}}else if(y&&(m=p=(l=(c=t[T.expando]||(t[T.expando]={}))[e]||[])[0]===eu&&l[1]),!1===m){while(f=++p&&f&&f[h]||(m=p=0)||d.pop())if((s?C(f,v):1===f.nodeType)&&++m&&(y&&((c=f[T.expando]||(f[T.expando]={}))[e]=[eu,m]),f===t))break}return(m-=i)===r||m%r==0&&m/r>=0}}},PSEUDO:function(e,t){var n=T.expr.pseudos[e]||T.expr.setFilters[e.toLowerCase()]||U("unsupported pseudo: "+e);return n[T.expando]?n(t):n}},pseudos:{not:eT(function(e){var t=[],n=[],r=eq(e.replace(D,"$1"));return r[T.expando]?eT(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:eT(function(e){return function(t){return ew(e,t).length>0}}),contains:eT(function(e){return e=_(e),function(t){return(t.textContent||T.text(t)).indexOf(e)>-1}}),lang:eT(function(e){return eh.test(e||"")||U("unsupported lang: "+e),e=_(e).toLowerCase(),function(t){var n;do if(n=es?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===ea},focus:function(e){return e===eo.activeElement&&eo.hasFocus()&&!!(e.type||e.href||~e.tabIndex)},enabled:eC(!1),disabled:eC(!0),checked:function(e){return C(e,"input")&&!!e.checked||C(e,"option")&&!!e.selected},selected:function(e){return k&&e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!T.expr.pseudos.empty(e)},header:function(e){return ey.test(e.nodeName)},input:function(e){return ev.test(e.nodeName)},button:function(e){return C(e,"input")&&"button"===e.type||C(e,"button")},text:function(e){return C(e,"input")&&"text"===e.type},first:ej(function(){return[0]}),last:ej(function(e,t){return[t-1]}),eq:ej(function(e,t,n){return[n<0?n+t:n]}),even:ej(function(e,t){for(var n=0;nt?t:n;--r>=0;)e.push(r);return e}),gt:ej(function(e,t,n){for(var r=n<0?n+t:n;++r1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function eA(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s-1},l,!0),d=[function(e,t,r){var i=!u&&(r||t!=ei)||((n=t).nodeType?f(e,t,r):p(e,t,r));return n=null,i}];c-1&&(e[f]=!(u[f]=d))}}else h=eA(h===u?h.splice(y,h.length):h),o?o(null,u,h,c):a.apply(u,h)})}(c>1&&eD(d),c>1&&Y(t.slice(0,c-1).concat({value:" "===t[c-2].type?"*":""})).replace(D,"$1"),r,c0,r=l.length>0,i=function(e,t,i,o,s){var c,f,p,d=0,h="0",g=e&&[],v=[],y=ei,m=e||r&&T.expr.find.TAG("*",s),x=eu+=null==y?1:Math.random()||.1;for(s&&(ei=t==eo||t||s);null!=(c=m[h]);h++){if(r&&c){f=0,t||c.ownerDocument==eo||(eE(c),i=!es);while(p=l[f++])if(p(c,t||eo,i)){a.call(o,c);break}s&&(eu=x)}n&&((c=!p&&c)&&d--,e&&g.push(c))}if(d+=h,n&&h!==d){f=0;while(p=u[f++])p(g,v,t,i);if(e){if(d>0)while(h--)g[h]||v[h]||(v[h]=j.call(o));v=eA(v)}a.apply(o,v),s&&!e&&v.length>0&&d+u.length>1&&T.uniqueSort(o)}return s&&(eu=x,ei=y),g},n?eT(i):i))).selector=e}return c}function eN(e,t,n,r){var i,o,s,u,l,c="function"==typeof e&&e,f=!r&&V(e=c.selector||e);if(n=n||[],1===f.length){if((o=f[0]=f[0].slice(0)).length>2&&"ID"===(s=o[0]).type&&9===t.nodeType&&es&&T.expr.relative[o[1].type]){if(!(t=(T.expr.find.ID(_(s.matches[0]),t)||[])[0]))return n;c&&(t=t.parentNode),e=e.slice(o.shift().value.length)}i=eg.needsContext.test(e)?0:o.length;while(i--){if(s=o[i],T.expr.relative[u=s.type])break;if((l=T.expr.find[u])&&(r=l(_(s.matches[0]),O.test(o[0].type)&&R(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&Y(o)))return a.apply(n,r),n;break}}}return(c||eq(e,f))(r,t,!es,n,!t||O.test(e)&&R(t.parentNode)||t),n}function eO(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&T(e).is(n))break;r.push(e)}return r}function eH(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}ek.prototype=T.expr.filters=T.expr.pseudos,T.expr.setFilters=new ek,eE(),T.find=ew,ew.compile=eq,ew.select=eN,ew.setDocument=eE,ew.tokenize=V;var eL=T.expr.match.needsContext,eP=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function eR(e){return"<"===e[0]&&">"===e[e.length-1]&&e.length>=3}function eM(e,t,n){return"function"==typeof t?T.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?T.grep(e,function(e){return e===t!==n}):"string"!=typeof t?T.grep(e,function(e){return s.call(t,e)>-1!==n}):T.filter(t,e,n)}T.filter=function(e,t,n){var r=t[0];return(n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType)?T.find.matchesSelector(r,e)?[r]:[]:T.find.matches(e,T.grep(t,function(e){return 1===e.nodeType}))},T.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(T(e).filter(function(){for(t=0;t1?T.uniqueSort(n):n},filter:function(e){return this.pushStack(eM(this,e||[],!1))},not:function(e){return this.pushStack(eM(this,e||[],!0))},is:function(e){return!!eM(this,"string"==typeof e&&eL.test(e)?T(e):e||[],!1).length}});var eW,e$=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(T.fn.init=function(e,t){var n,r;if(!e)return this;if(e.nodeType)return this[0]=e,this.length=1,this;if("function"==typeof e)return void 0!==eW.ready?eW.ready(e):e(T);if(eR(n=e+""))n=[null,e,null];else{if("string"!=typeof e)return T.makeArray(e,this);n=e$.exec(e)}if(n&&(n[1]||!t)){if(!n[1])return(r=y.getElementById(n[2]))&&(this[0]=r,this.length=1),this;if(t=t instanceof T?t[0]:t,T.merge(this,T.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:y,!0)),eP.test(n[1])&&T.isPlainObject(t))for(n in t)"function"==typeof this[n]?this[n](t[n]):this.attr(n,t[n]);return this}return!t||t.jquery?(t||eW).find(e):this.constructor(t).find(e)}).prototype=T.fn,eW=T(y);var eI=/^(?:parents|prev(?:Until|All))/,eF={children:!0,contents:!0,next:!0,prev:!0};function eB(e,t){while((e=e[t])&&1!==e.nodeType);return e}function e_(e){return e}function eU(e){throw e}function eX(e,t,n,r){var i;try{e&&"function"==typeof(i=e.promise)?i.call(e).done(t).fail(n):e&&"function"==typeof(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n(e)}}T.fn.extend({has:function(e){var t=T(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&T.find.matchesSelector(n,e))){o.push(n);break}}return this.pushStack(o.length>1?T.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?s.call(T(e),this[0]):s.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(T.uniqueSort(T.merge(this.get(),T(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),T.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return eO(e,"parentNode")},parentsUntil:function(e,t,n){return eO(e,"parentNode",n)},next:function(e){return eB(e,"nextSibling")},prev:function(e){return eB(e,"previousSibling")},nextAll:function(e){return eO(e,"nextSibling")},prevAll:function(e){return eO(e,"previousSibling")},nextUntil:function(e,t,n){return eO(e,"nextSibling",n)},prevUntil:function(e,t,n){return eO(e,"previousSibling",n)},siblings:function(e){return eH((e.parentNode||{}).firstChild,e)},children:function(e){return eH(e.firstChild)},contents:function(e){return null!=e.contentDocument&&r(e.contentDocument)?e.contentDocument:(C(e,"template")&&(e=e.content||e),T.merge([],e.childNodes))}},function(e,t){T.fn[e]=function(n,r){var i=T.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=T.filter(r,i)),this.length>1&&(eF[e]||T.uniqueSort(i),eI.test(e)&&i.reverse()),this.pushStack(i)}}),T.Callbacks=function(e){e="string"==typeof e?(t=e,n={},T.each(t.match(Q)||[],function(e,t){n[t]=!0}),n):T.extend({},e);var t,n,r,i,o,a,s=[],u=[],l=-1,c=function(){for(a=a||e.once,o=r=!0;u.length;l=-1){i=u.shift();while(++l-1)s.splice(n,1),n<=l&&l--}),this},has:function(e){return e?T.inArray(e,s)>-1:s.length>0},empty:function(){return s&&(s=[]),this},disable:function(){return a=u=[],s=i="",this},disabled:function(){return!s},lock:function(){return a=u=[],i||r||(s=i=""),this},locked:function(){return!!a},fireWith:function(e,t){return a||(t=[e,(t=t||[]).slice?t.slice():t],u.push(t),r||c()),this},fire:function(){return f.fireWith(this,arguments),this},fired:function(){return!!o}};return f},T.extend({Deferred:function(t){var n=[["notify","progress",T.Callbacks("memory"),T.Callbacks("memory"),2],["resolve","done",T.Callbacks("once memory"),T.Callbacks("once memory"),0,"resolved"],["reject","fail",T.Callbacks("once memory"),T.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},catch:function(e){return i.then(null,e)},pipe:function(){var e=arguments;return T.Deferred(function(t){T.each(n,function(n,r){var i="function"==typeof e[r[4]]&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&"function"==typeof e.promise?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t=o&&(r!==eU&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(T.Deferred.getErrorHook&&(c.error=T.Deferred.getErrorHook()),e.setTimeout(c))}}return T.Deferred(function(e){n[0][3].add(a(0,e,"function"==typeof i?i:e_,e.notifyWith)),n[1][3].add(a(0,e,"function"==typeof t?t:e_)),n[2][3].add(a(0,e,"function"==typeof r?r:eU))}).promise()},promise:function(e){return null!=e?T.extend(e,i):i}},o={};return T.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),o=i.call(arguments),a=T.Deferred(),s=function(e){return function(n){r[e]=this,o[e]=arguments.length>1?i.call(arguments):n,--t||a.resolveWith(r,o)}};if(t<=1&&(eX(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||"function"==typeof(o[n]&&o[n].then)))return a.then();while(n--)eX(o[n],s(n),a.reject);return a.promise()}});var ez=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;T.Deferred.exceptionHook=function(t,n){t&&ez.test(t.name)&&e.console.warn("jQuery.Deferred exception",t,n)},T.readyException=function(t){e.setTimeout(function(){throw t})};var eV=T.Deferred();function eY(){y.removeEventListener("DOMContentLoaded",eY),e.removeEventListener("load",eY),T.ready()}T.fn.ready=function(e){return eV.then(e).catch(function(e){T.readyException(e)}),this},T.extend({isReady:!1,readyWait:1,ready:function(e){!(!0===e?--T.readyWait:T.isReady)&&(T.isReady=!0,!0!==e&&--T.readyWait>0||eV.resolveWith(y,[T]))}}),T.ready.then=eV.then,"loading"!==y.readyState?e.setTimeout(T.ready):(y.addEventListener("DOMContentLoaded",eY),e.addEventListener("load",eY));var eG=/-([a-z])/g;function eQ(e,t){return t.toUpperCase()}function eJ(e){return e.replace(eG,eQ)}function eK(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType}function eZ(){this.expando=T.expando+eZ.uid++}eZ.uid=1,eZ.prototype={cache:function(e){var t=e[this.expando];return!t&&(t=Object.create(null),eK(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[eJ(t)]=n;else for(r in t)i[eJ(r)]=t[r];return n},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][eJ(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(eJ):(t=eJ(t))in r?[t]:t.match(Q)||[]).length;while(n--)delete r[t[n]]}(void 0===t||T.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!T.isEmptyObject(t)}};var e0=new eZ,e1=new eZ,e2=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,e3=/[A-Z]/g;function e4(e,t,n){var r,i;if(void 0===n&&1===e.nodeType){if(r="data-"+t.replace(e3,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{i=n,n="true"===i||"false"!==i&&("null"===i?null:i===+i+""?+i:e2.test(i)?JSON.parse(i):i)}catch(e){}e1.set(e,t,n)}else n=void 0}return n}T.extend({hasData:function(e){return e1.hasData(e)||e0.hasData(e)},data:function(e,t,n){return e1.access(e,t,n)},removeData:function(e,t){e1.remove(e,t)},_data:function(e,t,n){return e0.access(e,t,n)},_removeData:function(e,t){e0.remove(e,t)}}),T.fn.extend({data:function(e,t){var n,r,i,o=this[0],a=o&&o.attributes;if(void 0===e){if(this.length&&(i=e1.get(o),1===o.nodeType&&!e0.get(o,"hasDataAttrs"))){n=a.length;while(n--)a[n]&&0===(r=a[n].name).indexOf("data-")&&e4(o,r=eJ(r.slice(5)),i[r]);e0.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof e?this.each(function(){e1.set(this,e)}):G(this,function(t){var n;if(o&&void 0===t)return void 0!==(n=e1.get(o,e))||void 0!==(n=e4(o,e))?n:void 0;this.each(function(){e1.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){e1.remove(this,e)})}}),T.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=e0.get(e,t),n&&(!r||Array.isArray(n)?r=e0.set(e,t,T.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=T.queue(e,t),r=n.length,i=n.shift(),o=T._queueHooks(e,t);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,function(){T.dequeue(e,t)},o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return e0.get(e,n)||e0.set(e,n,{empty:T.Callbacks("once memory").add(function(){e0.remove(e,[t+"queue",n])})})}}),T.fn.extend({queue:function(e,t){var n=2;return("string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]*)/i,tc={thead:["table"],col:["colgroup","table"],tr:["tbody","table"],td:["tr","tbody","table"]};function tf(e,t){var n;return(n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&C(e,t))?T.merge([e],n):n}tc.tbody=tc.tfoot=tc.colgroup=tc.caption=tc.thead,tc.th=tc.td;var tp=/^$|^module$|\/(?:java|ecma)script/i;function td(e,t){for(var n=0,r=e.length;n-1)s=s.appendChild(t.createElement(u[c]));s.innerHTML=T.htmlPrefilter(a),T.merge(p,s.childNodes),(s=f.firstChild).textContent=""}else p.push(t.createTextNode(a))}f.textContent="",d=0;while(a=p[d++]){if(i&&T.inArray(a,i)>-1){o&&o.push(a);continue}if(l=ts(a),s=tf(f.appendChild(a),"script"),l&&td(s),r){c=0;while(a=s[c++])tp.test(a.type||"")&&r.push(a)}}return f}function tv(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function ty(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function tm(e,t,n,r){t=o(t);var i,a,s,u,l,c,f=0,p=e.length,d=p-1,h=t[0];if("function"==typeof h)return e.each(function(i){var o=e.eq(i);t[0]=h.call(this,i,o.html()),tm(o,t,n,r)});if(p&&(a=(i=tg(t,e[0].ownerDocument,!1,e,r)).firstChild,1===i.childNodes.length&&(i=a),a||r)){for(u=(s=T.map(tf(i,"script"),tv)).length;f=1)){for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&!("click"===e.type&&!0===l.disabled)){for(n=0,o=[],a={};n-1:T.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}}return l=this,u0&&td(a,!u&&tf(e,"script")),s},cleanData:function(e){for(var t,n,r,i=T.event.special,o=0;void 0!==(n=e[o]);o++)if(eK(n)){if(t=n[e0.expando]){if(t.events)for(r in t.events)i[r]?T.event.remove(n,r):T.removeEvent(n,r,t.handle);n[e0.expando]=void 0}n[e1.expando]&&(n[e1.expando]=void 0)}}}),T.fn.extend({detach:function(e){return tD(this,e,!0)},remove:function(e){return tD(this,e)},text:function(e){return G(this,function(e){return void 0===e?T.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=e)})},null,e,arguments.length)},append:function(){return tm(this,arguments,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&tk(this,e).appendChild(e)})},prepend:function(){return tm(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=tk(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return tm(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return tm(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(T.cleanData(tf(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return T.clone(this,e,t)})},html:function(e){return G(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!tE.test(e)&&!tc[(tl.exec(e)||["",""])[1].toLowerCase()]){e=T.htmlPrefilter(e);try{for(;nT.inArray(this,e)&&(T.cleanData(tf(this)),n&&n.replaceChild(t,this))},e)}}),T.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){T.fn[e]=function(e){for(var n,r=[],i=T(e),o=i.length-1,s=0;s<=o;s++)n=s===o?this:this.clone(!0),T(i[s])[t](n),a.apply(r,n);return this.pushStack(r)}});var tA=RegExp("^("+e5+")(?!px)[a-z%]+$","i"),tq=/^--/;function tN(t){var n=t.ownerDocument.defaultView;return n||(n=e),n.getComputedStyle(t)}function tO(e,t,n){var r,i=tq.test(t);return(n=n||tN(e))&&(r=n.getPropertyValue(t)||n[t],i&&r&&(r=r.replace(D,"$1")||void 0),""!==r||ts(e)||(r=T.style(e,t))),void 0!==r?r+"":r}var tH=["Webkit","Moz","ms"],tL=y.createElement("div").style,tP={};function tR(e){return tP[e]||(e in tL?e:tP[e]=function(e){var t=e[0].toUpperCase()+e.slice(1),n=tH.length;while(n--)if((e=tH[n]+t)in tL)return e}(e)||e)}(tX=y.createElement("div")).style&&(d.reliableTrDimensions=function(){var t,n,r;if(null==tU){if(t=y.createElement("table"),n=y.createElement("tr"),t.style.cssText="position:absolute;left:-11111px;border-collapse:separate",n.style.cssText="box-sizing:content-box;border:1px solid",n.style.height="1px",tX.style.height="9px",tX.style.display="block",H.appendChild(t).appendChild(n).appendChild(tX),0===t.offsetWidth){H.removeChild(t);return}tU=Math.round(parseFloat((r=e.getComputedStyle(n)).height))+Math.round(parseFloat(r.borderTopWidth))+Math.round(parseFloat(r.borderBottomWidth))===n.offsetHeight,H.removeChild(t)}return tU});var tM=/^(none|table(?!-c[ea]).+)/,tW={position:"absolute",visibility:"hidden",display:"block"},t$={letterSpacing:"0",fontWeight:"400"};function tI(e,t,n){var r=e9.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function tF(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0,l=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(l+=T.css(e,n+e6[a],!0,i)),r?("content"===n&&(u-=T.css(e,"padding"+e6[a],!0,i)),"margin"!==n&&(u-=T.css(e,"border"+e6[a]+"Width",!0,i))):(u+=T.css(e,"padding"+e6[a],!0,i),"padding"!==n?u+=T.css(e,"border"+e6[a]+"Width",!0,i):s+=T.css(e,"border"+e6[a]+"Width",!0,i));return!r&&o>=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))||0),u+l}function tB(e,t,n){var r=tN(e),i=(k||n)&&"border-box"===T.css(e,"boxSizing",!1,r),o=i,a=tO(e,t,r),s="offset"+t[0].toUpperCase()+t.slice(1);if(tA.test(a)){if(!n)return a;a="auto"}return("auto"===a||k&&i||!d.reliableTrDimensions()&&C(e,"tr"))&&e.getClientRects().length&&(i="border-box"===T.css(e,"boxSizing",!1,r),(o=s in e)&&(a=e[s])),(a=parseFloat(a)||0)+tF(e,t,n||(i?"border":"content"),o,r,a)+"px"}function t_(e,t,n,r,i){return new t_.prototype.init(e,t,n,r,i)}T.extend({cssHooks:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=ti(t),u=tq.test(t),l=e.style;if(u||(t=tR(s)),a=T.cssHooks[t]||T.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=e9.exec(n))&&i[1]&&(n=tn(e,t,i),o="number"),null!=n&&n==n&&("number"===o&&(n+=i&&i[3]||(tt(s)?"px":"")),k&&""===n&&0===t.indexOf("background")&&(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=ti(t);return(tq.test(t)||(t=tR(s)),(a=T.cssHooks[t]||T.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=tO(e,t,r)),"normal"===i&&t in t$&&(i=t$[t]),""===n||n)?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),T.each(["height","width"],function(e,t){T.cssHooks[t]={get:function(e,n,r){if(n)return!tM.test(T.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?tB(e,t,r):function(e,t,n){var r,i,o={};for(i in t)o[i]=e.style[i],e.style[i]=t[i];for(i in r=n.call(e),t)e.style[i]=o[i];return r}(e,tW,function(){return tB(e,t,r)})},set:function(e,n,r){var i,o=tN(e),a=r&&"border-box"===T.css(e,"boxSizing",!1,o),s=r?tF(e,t,r,a,o):0;return s&&(i=e9.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=T.css(e,t)),tI(e,n,s)}}}),T.each({margin:"",padding:"",border:"Width"},function(e,t){T.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+e6[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(T.cssHooks[e+t].set=tI)}),T.fn.extend({css:function(e,t){return G(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=tN(e),i=t.length;a1)}}),T.Tween=t_,t_.prototype={constructor:t_,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||T.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(tt(n)?"px":"")},cur:function(){var e=t_.propHooks[this.prop];return e&&e.get?e.get(this):t_.propHooks._default.get(this)},run:function(e){var t,n=t_.propHooks[this.prop];return this.options.duration?this.pos=t=T.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):t_.propHooks._default.set(this),this}},t_.prototype.init.prototype=t_.prototype,t_.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=T.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){T.fx.step[e.prop]?T.fx.step[e.prop](e):1===e.elem.nodeType&&(T.cssHooks[e.prop]||null!=e.elem.style[tR(e.prop)])?T.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},T.easing={linear:function(e){return e},swing:function(e){return .5-Math.cos(e*Math.PI)/2},_default:"swing"},T.fx=t_.prototype.init,T.fx.step={};var tU,tX,tz,tV,tY=/^(?:toggle|show|hide)$/,tG=/queueHooks$/;function tQ(){return e.setTimeout(function(){tz=void 0}),tz=Date.now()}function tJ(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=e6[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function tK(e,t,n){for(var r,i=(tZ.tweeners[t]||[]).concat(tZ.tweeners["*"]),o=0,a=i.length;o1)},removeProp:function(e){return this.each(function(){delete this[T.propFix[e]||e]})}}),T.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return(1===o&&T.isXMLDoc(e)||(t=T.propFix[t]||t,i=T.propHooks[t]),void 0!==n)?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=e.getAttribute("tabindex");return t?parseInt(t,10):t0.test(e.nodeName)||t1.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),k&&(T.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),T.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){T.propFix[this.toLowerCase()]=this}),T.fn.extend({addClass:function(e){var t,n,r,i,o,a;return"function"==typeof e?this.each(function(t){T(this).addClass(e.call(this,t,t3(this)))}):(t=t4(e)).length?this.each(function(){if(r=t3(this),n=1===this.nodeType&&" "+t2(r)+" "){for(o=0;on.indexOf(" "+i+" ")&&(n+=i+" ");r!==(a=t2(n))&&this.setAttribute("class",a)}}):this},removeClass:function(e){var t,n,r,i,o,a;return"function"==typeof e?this.each(function(t){T(this).removeClass(e.call(this,t,t3(this)))}):arguments.length?(t=t4(e)).length?this.each(function(){if(r=t3(this),n=1===this.nodeType&&" "+t2(r)+" "){for(o=0;o-1)n=n.replace(" "+i+" "," ")}r!==(a=t2(n))&&this.setAttribute("class",a)}}):this:this.attr("class","")},toggleClass:function(e,t){var n,r,i,o;return"function"==typeof e?this.each(function(n){T(this).toggleClass(e.call(this,n,t3(this),t),t)}):"boolean"==typeof t?t?this.addClass(e):this.removeClass(e):(n=t4(e)).length?this.each(function(){for(i=0,o=T(this);i-1)return!0;return!1}}),T.fn.extend({val:function(e){var t,n,r,i=this[0];return arguments.length?(r="function"==typeof e,this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,T(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=T.map(i,function(e){return null==e?"":e+""})),(t=T.valHooks[this.type]||T.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))})):i?(t=T.valHooks[i.type]||T.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:null==(n=i.value)?"":n:void 0}}),T.extend({valHooks:{select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),k&&(T.valHooks.option={get:function(e){var t=e.getAttribute("value");return null!=t?t:t2(T.text(e))}}),T.each(["radio","checkbox"],function(){T.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=T.inArray(T(e).val(),t)>-1}}});var t5=/^(?:focusinfocus|focusoutblur)$/,t9=function(e){e.stopPropagation()};T.extend(T.event,{trigger:function(t,n,r,i){var o,a,s,u,l,f,p,d,h=[r||y],v=c.call(t,"type")?t.type:t,m=c.call(t,"namespace")?t.namespace.split("."):[];if(a=d=s=r=r||y,!(3===r.nodeType||8===r.nodeType||t5.test(v+T.event.triggered))&&(v.indexOf(".")>-1&&(v=(m=v.split(".")).shift(),m.sort()),l=0>v.indexOf(":")&&"on"+v,(t=t[T.expando]?t:new T.Event(v,"object"==typeof t&&t)).isTrigger=i?2:3,t.namespace=m.join("."),t.rnamespace=t.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=r),n=null==n?[t]:T.makeArray(n,[t]),p=T.event.special[v]||{},i||!p.trigger||!1!==p.trigger.apply(r,n))){if(!i&&!p.noBubble&&!g(r)){for(u=p.delegateType||v,t5.test(u+v)||(a=a.parentNode);a;a=a.parentNode)h.push(a),s=a;s===(r.ownerDocument||y)&&h.push(s.defaultView||s.parentWindow||e)}o=0;while((a=h[o++])&&!t.isPropagationStopped())d=a,t.type=o>1?u:p.bindType||v,(f=(e0.get(a,"events")||Object.create(null))[t.type]&&e0.get(a,"handle"))&&f.apply(a,n),(f=l&&a[l])&&f.apply&&eK(a)&&(t.result=f.apply(a,n),!1===t.result&&t.preventDefault());return t.type=v,!i&&!t.isDefaultPrevented()&&(!p._default||!1===p._default.apply(h.pop(),n))&&eK(r)&&l&&"function"==typeof r[v]&&!g(r)&&((s=r[l])&&(r[l]=null),T.event.triggered=v,t.isPropagationStopped()&&d.addEventListener(v,t9),r[v](),t.isPropagationStopped()&&d.removeEventListener(v,t9),T.event.triggered=void 0,s&&(r[l]=s)),t.result}},simulate:function(e,t,n){var r=T.extend(new T.Event,n,{type:e,isSimulated:!0});T.event.trigger(r,null,t)}}),T.fn.extend({trigger:function(e,t){return this.each(function(){T.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return T.event.trigger(e,t,n,!0)}});var t6=e.location,t8={guid:Date.now()},t7=/\?/;T.parseXML=function(t){var n,r;if(!t||"string"!=typeof t)return null;try{n=new e.DOMParser().parseFromString(t,"text/xml")}catch(e){}return r=n&&n.getElementsByTagName("parsererror")[0],(!n||r)&&T.error("Invalid XML: "+(r?T.map(r.childNodes,function(e){return e.textContent}).join("\n"):t)),n};var ne=/\[\]$/,nt=/\r?\n/g,nn=/^(?:submit|button|image|reset|file)$/i,nr=/^(?:input|select|textarea|keygen)/i;T.param=function(e,t){var n,r=[],i=function(e,t){var n="function"==typeof t?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!T.isPlainObject(e))T.each(e,function(){i(this.name,this.value)});else for(n in e)!function e(t,n,r,i){var o;if(Array.isArray(n))T.each(n,function(n,o){r||ne.test(t)?i(t,o):e(t+"["+("object"==typeof o&&null!=o?n:"")+"]",o,r,i)});else if(r||"object"!==h(n))i(t,n);else for(o in n)e(t+"["+o+"]",n[o],r,i)}(n,e[n],t,i);return r.join("&")},T.fn.extend({serialize:function(){return T.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=T.prop(this,"elements");return e?T.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!T(this).is(":disabled")&&nr.test(this.nodeName)&&!nn.test(e)&&(this.checked||!tx.test(e))}).map(function(e,t){var n=T(this).val();return null==n?null:Array.isArray(n)?T.map(n,function(e){return{name:t.name,value:e.replace(nt,"\r\n")}}):{name:t.name,value:n.replace(nt,"\r\n")}}).get()}});var ni=/%20/g,no=/#.*$/,na=/([?&])_=[^&]*/,ns=/^(.*?):[ \t]*([^\r\n]*)$/mg,nu=/^(?:GET|HEAD)$/,nl=/^\/\//,nc={},nf={},np="*/".concat("*"),nd=y.createElement("a");function nh(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(Q)||[];if("function"==typeof n)while(r=o[i++])"+"===r[0]?(e[r=r.slice(1)||"*"]=e[r]||[]).unshift(n):(e[r]=e[r]||[]).push(n)}}function ng(e,t,n,r){var i={},o=e===nf;function a(s){var u;return i[s]=!0,T.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function nv(e,t){var n,r,i=T.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&T.extend(!0,e,r),e}nd.href=t6.href,T.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:t6.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(t6.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":np,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":T.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?nv(nv(e,T.ajaxSettings),t):nv(T.ajaxSettings,e)},ajaxPrefilter:nh(nc),ajaxTransport:nh(nf),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var r,i,o,a,s,u,l,c,f,p,d=T.ajaxSetup({},n),h=d.context||d,g=d.context&&(h.nodeType||h.jquery)?T(h):T.event,v=T.Deferred(),m=T.Callbacks("once memory"),x=d.statusCode||{},b={},w={},C="canceled",j={readyState:0,getResponseHeader:function(e){var t;if(l){if(!a){a={};while(t=ns.exec(o))a[t[1].toLowerCase()+" "]=(a[t[1].toLowerCase()+" "]||[]).concat(t[2])}t=a[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return l?o:null},setRequestHeader:function(e,t){return null==l&&(b[e=w[e.toLowerCase()]=w[e.toLowerCase()]||e]=t),this},overrideMimeType:function(e){return null==l&&(d.mimeType=e),this},statusCode:function(e){var t;if(e){if(l)j.always(e[j.status]);else for(t in e)x[t]=[x[t],e[t]]}return this},abort:function(e){var t=e||C;return r&&r.abort(t),E(0,t),this}};if(v.promise(j),d.url=((t||d.url||t6.href)+"").replace(nl,t6.protocol+"//"),d.type=n.method||n.type||d.method||d.type,d.dataTypes=(d.dataType||"*").toLowerCase().match(Q)||[""],null==d.crossDomain){u=y.createElement("a");try{u.href=d.url,u.href=u.href,d.crossDomain=nd.protocol+"//"+nd.host!=u.protocol+"//"+u.host}catch(e){d.crossDomain=!0}}if(ng(nc,d,n,j),d.data&&d.processData&&"string"!=typeof d.data&&(d.data=T.param(d.data,d.traditional)),l)return j;for(f in(c=T.event&&d.global)&&0==T.active++&&T.event.trigger("ajaxStart"),d.type=d.type.toUpperCase(),d.hasContent=!nu.test(d.type),i=d.url.replace(no,""),d.hasContent?d.data&&d.processData&&0===(d.contentType||"").indexOf("application/x-www-form-urlencoded")&&(d.data=d.data.replace(ni,"+")):(p=d.url.slice(i.length),d.data&&(d.processData||"string"==typeof d.data)&&(i+=(t7.test(i)?"&":"?")+d.data,delete d.data),!1===d.cache&&(i=i.replace(na,"$1"),p=(t7.test(i)?"&":"?")+"_="+t8.guid+++p),d.url=i+p),d.ifModified&&(T.lastModified[i]&&j.setRequestHeader("If-Modified-Since",T.lastModified[i]),T.etag[i]&&j.setRequestHeader("If-None-Match",T.etag[i])),(d.data&&d.hasContent&&!1!==d.contentType||n.contentType)&&j.setRequestHeader("Content-Type",d.contentType),j.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+("*"!==d.dataTypes[0]?", "+np+"; q=0.01":""):d.accepts["*"]),d.headers)j.setRequestHeader(f,d.headers[f]);if(d.beforeSend&&(!1===d.beforeSend.call(h,j,d)||l))return j.abort();if(C="abort",m.add(d.complete),j.done(d.success),j.fail(d.error),r=ng(nf,d,n,j)){if(j.readyState=1,c&&g.trigger("ajaxSend",[j,d]),l)return j;d.async&&d.timeout>0&&(s=e.setTimeout(function(){j.abort("timeout")},d.timeout));try{l=!1,r.send(b,E)}catch(e){if(l)throw e;E(-1,e)}}else E(-1,"No Transport");function E(t,n,a,u){var f,p,y,b,w,C=n;!l&&(l=!0,s&&e.clearTimeout(s),r=void 0,o=u||"",j.readyState=t>0?4:0,f=t>=200&&t<300||304===t,a&&(b=function(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r){for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}(d,j,a)),!f&&T.inArray("script",d.dataTypes)>-1&&0>T.inArray("json",d.dataTypes)&&(d.converters["text script"]=function(){}),b=function(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift()){if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o])){for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}}if(!0!==a){if(a&&e.throws)t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}}}return{state:"success",data:t}}(d,b,j,f),f?(d.ifModified&&((w=j.getResponseHeader("Last-Modified"))&&(T.lastModified[i]=w),(w=j.getResponseHeader("etag"))&&(T.etag[i]=w)),204===t||"HEAD"===d.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,f=!(y=b.error))):(y=C,(t||!C)&&(C="error",t<0&&(t=0))),j.status=t,j.statusText=(n||C)+"",f?v.resolveWith(h,[p,C,j]):v.rejectWith(h,[j,C,y]),j.statusCode(x),x=void 0,c&&g.trigger(f?"ajaxSuccess":"ajaxError",[j,d,f?p:y]),m.fireWith(h,[j,C]),!c||(g.trigger("ajaxComplete",[j,d]),--T.active||T.event.trigger("ajaxStop")))}return j},getJSON:function(e,t,n){return T.get(e,t,n,"json")},getScript:function(e,t){return T.get(e,void 0,t,"script")}}),T.each(["get","post"],function(e,t){T[t]=function(e,n,r,i){return("function"==typeof n||null===n)&&(i=i||r,r=n,n=void 0),T.ajax(T.extend({url:e,type:t,dataType:i,data:n,success:r},T.isPlainObject(e)&&e))}}),T.ajaxPrefilter(function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")}),T._evalUrl=function(e,t,n){return T.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,scriptAttrs:t.crossOrigin?{crossOrigin:t.crossOrigin}:void 0,converters:{"text script":function(){}},dataFilter:function(e){T.globalEval(e,t,n)}})},T.fn.extend({wrapAll:function(e){var t;return this[0]&&("function"==typeof e&&(e=e.call(this[0])),t=T(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return"function"==typeof e?this.each(function(t){T(this).wrapInner(e.call(this,t))}):this.each(function(){var t=T(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t="function"==typeof e;return this.each(function(n){T(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){T(this).replaceWith(this.childNodes)}),this}}),T.expr.pseudos.hidden=function(e){return!T.expr.pseudos.visible(e)},T.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},T.ajaxSettings.xhr=function(){return new e.XMLHttpRequest};var ny={0:200};function nm(e){return e.scriptAttrs||!e.headers&&(e.crossDomain||e.async&&0>T.inArray("json",e.dataTypes))}T.ajaxTransport(function(e){var t;return{send:function(n,r){var i,o=e.xhr();if(o.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(i in e.xhrFields)o[i]=e.xhrFields[i];for(i in e.mimeType&&o.overrideMimeType&&o.overrideMimeType(e.mimeType),e.crossDomain||n["X-Requested-With"]||(n["X-Requested-With"]="XMLHttpRequest"),n)o.setRequestHeader(i,n[i]);t=function(e){return function(){t&&(t=o.onload=o.onerror=o.onabort=o.ontimeout=null,"abort"===e?o.abort():"error"===e?r(o.status,o.statusText):r(ny[o.status]||o.status,o.statusText,"text"===(o.responseType||"text")?{text:o.responseText}:{binary:o.response},o.getAllResponseHeaders()))}},o.onload=t(),o.onabort=o.onerror=o.ontimeout=t("error"),t=t("abort");try{o.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}}),T.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},converters:{"text script":function(e){return T.globalEval(e),e}}}),T.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),nm(e)&&(e.type="GET")}),T.ajaxTransport("script",function(e){if(nm(e)){var t,n;return{send:function(r,i){t=T("'; - } - - /** - * Gets the current user - */ - public function user() { - if ($this->user) { - return $this->user; - } - if ($this->session) { - $this->user = $this->db - ->select('*') - ->from('api.user') - ->where('id') - ->eq($this->session['id']) - ->row(); - return $this->user; - } - return NULL; - } - - /** - * Formats a date - * @param string $date - the data in RFC3999 format - * @returns the formatted date - */ - public function date($date) { - $date=date_create($date); - return date_format($date, "Y-m-d D H:m"); - } - -} - -?> diff --git a/src/web/_model/people.php b/src/web/_model/people.php new file mode 100644 index 0000000..bf540cf --- /dev/null +++ b/src/web/_model/people.php @@ -0,0 +1,72 @@ +get_string('filter'); + $filter_uid = $this->get_int('uid'); + $max = $this->get_int('max'); + $query = $this->db() + ->select($select) + ->from('api.user u'); + + if ($filter_type && $filter_uid) { + switch ($filter_type) { + // only show followers + case 'follower': + $query = $query + ->join('xssbook.follow f', 'f.follower_id = u.id AND f.followee_id', 'INNER') + ->eq($filter_uid) + ->where('f.value = TRUE'); + break; + // only show followees + case 'followee': + $query = $query + ->join('xssbook.follow f', 'f.followee_id = u.id AND f.follower_id', 'INNER') + ->eq($filter_uid) + ->where('f.value = TRUE'); + break; + } + } + + if ($max) { + $query = $query + ->where('u.id') + ->le($max); + } + + return $query; + } + + public function get_people(): array { + $filter_type = $this->get_string('filter'); + $filter_uid = $this->get_int('uid'); + $page = $this->get_int('page', 0); + + $page_size = PEOPLE_PAGE_SIZE; + $offset = $page_size * $page; + + $users = $this->get_filted_query('u.*') + ->order_by('u.id', 'DESC') + ->offset($offset) + ->limit($page_size) + ->rows(); + + $count = $this->get_filted_query('COUNT(u.id) AS count') + ->row()['count']; + + $max = 0; + + foreach ($users as $user) + $max = max($max, $user['id']); + + return array( + 'users' => $users, + 'count' => $count, + 'page_size' => $page_size, + 'max_id' => $max, + 'filter_type' => $filter_type, + 'filter_uid' => $filter_uid, + ); + } +} diff --git a/src/web/_model/profile.php b/src/web/_model/profile.php new file mode 100644 index 0000000..d35cc46 --- /dev/null +++ b/src/web/_model/profile.php @@ -0,0 +1,70 @@ +auth_model = $this->load_model('auth'); + } + + public function get_data(): ?array { + $uid = $this->get_int('id'); + $session = $this->auth_model->session(); + + if (!$uid && $session) + $uid = $session['id']; + if (!$uid) + return NULL; + + $user = $this->db() + ->select('*') + ->from('api.user u') + ->where('u.id') + ->eq($uid) + ->row(); + + if (!$user) + return NULL; + + // am i following $uid? + $following = FALSE; + $following_id = NULL; + // is $uid following me? + $followed = FALSE; + + if ($session) { + $sid = $session['id']; + // am i following $uid? + $res = $this->db() + ->select('f.value, f.id') + ->from('xssbook.follow f') + ->where('f.follower_id') + ->eq($sid) + ->where('f.followee_id') + ->eq($uid) + ->row(); + $following = $res ? $res['value'] : FALSE; + $following_id = $res ? $res['id'] : NULL; + // is $uid following me? + $res = $this->db() + ->select('f.value') + ->from('xssbook.follow f') + ->where('f.follower_id') + ->eq($uid) + ->where('f.followee_id') + ->eq($sid) + ->row(); + $followed = $res ? $res['value'] : FALSE; + } + + $data = parent::get_data(); + $data['user'] = $user; + $data['following'] = $following; + $data['following_id'] = $following_id; + $data['followed'] = $followed; + + $name = $this->format_name($user); + $data['title'] .= " - $name"; + return $data; + } +} diff --git a/src/web/_model/request.php b/src/web/_model/request.php deleted file mode 100644 index 4cce07a..0000000 --- a/src/web/_model/request.php +++ /dev/null @@ -1,40 +0,0 @@ - + + diff --git a/src/web/_views/_modal/new_post.php b/src/web/_views/_modal/new_post.php new file mode 100644 index 0000000..aff19a5 --- /dev/null +++ b/src/web/_views/_modal/new_post.php @@ -0,0 +1,56 @@ + + +
+
+
+ +
+ + +
+
+ +
+ +
+ diff --git a/src/web/_views/_modal/register.php b/src/web/_views/_modal/register.php new file mode 100644 index 0000000..2126d0d --- /dev/null +++ b/src/web/_views/_modal/register.php @@ -0,0 +1,178 @@ + + + +
+ + +
+ diff --git a/src/web/_views/_template/comment.php b/src/web/_views/_template/comment.php new file mode 100644 index 0000000..b947ff6 --- /dev/null +++ b/src/web/_views/_template/comment.php @@ -0,0 +1,12 @@ + + +
+ +
+
+ format_name($user)?> + format_date($comment['created'])?> +
+ +
+
diff --git a/src/web/_views/_template/error.php b/src/web/_views/_template/error.php new file mode 100644 index 0000000..2e02cb1 --- /dev/null +++ b/src/web/_views/_template/error.php @@ -0,0 +1,12 @@ + + + + <?=$code . ' - ' . $msg?> + + +
+

+
+
+ + diff --git a/src/web/_views/_template/modal.php b/src/web/_views/_template/modal.php new file mode 100644 index 0000000..8e4545d --- /dev/null +++ b/src/web/_views/_template/modal.php @@ -0,0 +1,14 @@ + + + diff --git a/src/web/_views/_template/post.php b/src/web/_views/_template/post.php new file mode 100644 index 0000000..f7f5de2 --- /dev/null +++ b/src/web/_views/_template/post.php @@ -0,0 +1,86 @@ + + +
+
+ +
+ + format_date($post['created'])?> +
+
+

+ +

+ $post['id'] + ); + if ($post['like_id'] !== NULL) { + $post_attrs['likeId'] = $post['like_id']; + } +?> + + +
+
+ + +
+
+ +
+ $post['id']); + $cdata = $this->comments(); + + $loaded = $cdata['loaded']; + $max = $cdata['max']; + $page_size = $cdata['page_size']; + $total = $post['comment_count']; + + if ($loaded >= $page_size && $page_size < $total) { + echo ilang('action_load_comments', + class: 'action-load-comments btn btn-blend mt', + attrs: array( + 'postId' => $post['id'], + 'loaded' => $loaded, + 'pageSize' => $page_size, + 'commentCount' => $total, + 'commentMax' => $max, + ) + ); + } + + ?> +
+ +
+ +
+ + +
+
+ +
+ + diff --git a/src/web/_views/_template/posts.php b/src/web/_views/_template/posts.php new file mode 100644 index 0000000..4202e67 --- /dev/null +++ b/src/web/_views/_template/posts.php @@ -0,0 +1,32 @@ +
+posts(); + + $loaded = $pdata['loaded']; + $page_size = $pdata['page_size']; + $total = $pdata['total']; + $max = $pdata['max']; + $filterUid = $pdata['filter_uid']; +?> + +
+ + +
+ += $page_size && $page_size < $total) { + echo ilang('action_load_posts', + id: 'action-load-posts', + class: 'btn btn-blend grow mb mt', + attrs: array( + 'loaded' => $loaded, + 'pageSize' => $page_size, + 'postCount' => $total, + 'postMax' => $max, + 'userId' => $filterUid ? json_encode($filterUid) : '' + ) + ); + } +?> +
diff --git a/src/web/_views/_template/toast.php b/src/web/_views/_template/toast.php new file mode 100644 index 0000000..902955c --- /dev/null +++ b/src/web/_views/_template/toast.php @@ -0,0 +1,22 @@ + + + +
+ + +
diff --git a/src/web/_views/apps/auth/login.php b/src/web/_views/apps/auth/login.php deleted file mode 100644 index ac4cd02..0000000 --- a/src/web/_views/apps/auth/login.php +++ /dev/null @@ -1,87 +0,0 @@ - - -
-
-

xssbook

- -
-
-
-
- - -
-
- - -
- 'submit') - )?> - -
-
- 'submit') - )?> -
- -
diff --git a/src/web/_views/apps/error/main.php b/src/web/_views/apps/error/main.php deleted file mode 100644 index bcc6f90..0000000 --- a/src/web/_views/apps/error/main.php +++ /dev/null @@ -1,6 +0,0 @@ - - -
-

- -
diff --git a/src/web/_views/apps/home/main.php b/src/web/_views/apps/home/main.php deleted file mode 100644 index 864034a..0000000 --- a/src/web/_views/apps/home/main.php +++ /dev/null @@ -1,27 +0,0 @@ - - -
- -
-
- - - - -
- -
- - post_controller->index(); ?> -
diff --git a/src/web/_views/apps/people/card.php b/src/web/_views/apps/people/card.php deleted file mode 100644 index 93b1350..0000000 --- a/src/web/_views/apps/people/card.php +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- -
- format_model->name($user)?> - -
-
-
- - - diff --git a/src/web/_views/apps/people/header.php b/src/web/_views/apps/people/header.php deleted file mode 100644 index b1099ec..0000000 --- a/src/web/_views/apps/people/header.php +++ /dev/null @@ -1,6 +0,0 @@ - - -
-

-

-
diff --git a/src/web/_views/apps/people/main.php b/src/web/_views/apps/people/main.php deleted file mode 100644 index ec84ab9..0000000 --- a/src/web/_views/apps/people/main.php +++ /dev/null @@ -1,72 +0,0 @@ - - -
-people(); -?> -
- -= $page_size && $page_size < $total): ?> - $loaded, - 'pageSize' => $page_size, - 'userCount' => $total, - 'userMax' => $max, - 'filterUid' => $filter_uid, - 'filterType' => $filer_type - ) - )?> - - diff --git a/src/web/_views/apps/people/people.php b/src/web/_views/apps/people/people.php deleted file mode 100644 index 5fc0d17..0000000 --- a/src/web/_views/apps/people/people.php +++ /dev/null @@ -1,7 +0,0 @@ - - -view('apps/people/card', array('user' => $user)); - } -?> diff --git a/src/web/_views/apps/profile/main.php b/src/web/_views/apps/profile/main.php deleted file mode 100644 index b2ad496..0000000 --- a/src/web/_views/apps/profile/main.php +++ /dev/null @@ -1,269 +0,0 @@ - - -
-
-
- -
-
- -
-
-
-
- format_model->name($user)?> - -
- main->session && - (!isset($self) || $self['id'] != $user['id']) - ): ?> - - - -
- 0): ?> -
- - - -
-
-
-
- - - - -
-
-
-
-
- post_controller->index(); - ?> -
-
-

- - - - - - - - - - - - - - - - - - - - - -
main->date($user['birth_date'])?>
-

- - - - - - - - - - - - - - - - - - - - - - - - - -
main->date($user['created'])?>
main->date($user['seen'])?>
-
-
- people_controller->content(); - ?> -
-
- people_controller->content(); - ?> -
-
- -
diff --git a/src/web/_views/apps/settings/main.php b/src/web/_views/apps/settings/main.php deleted file mode 100644 index 2033acc..0000000 --- a/src/web/_views/apps/settings/main.php +++ /dev/null @@ -1,200 +0,0 @@ - - - -main->user(); - -function __create_form($user, $col) { - $ph = ucfirst(lang('ph_' . $col)); - $val = $user[$col]; - return "
-
- - -
- - - -
"; -} - -?> - - - -
-
-

-
-

- - - - - - - -
-

- -
-
- - -
-
- - -
- -
-
-

- -

-
- -
- - -
-
-

-
- -
- - -
-
-
-
diff --git a/src/web/_views/auth/main.php b/src/web/_views/auth/main.php new file mode 100644 index 0000000..9604770 --- /dev/null +++ b/src/web/_views/auth/main.php @@ -0,0 +1,87 @@ + + +
+
+

xssbook

+ +
+
+
+
+ + +
+
+ + +
+ 'submit') + )?> + +
+
+ 'submit') + )?> +
+ +
diff --git a/src/web/_views/error/main.php b/src/web/_views/error/main.php new file mode 100644 index 0000000..bcc6f90 --- /dev/null +++ b/src/web/_views/error/main.php @@ -0,0 +1,6 @@ + + +
+

+ +
diff --git a/src/web/_views/head.php b/src/web/_views/head.php index cca43a1..809ab36 100644 --- a/src/web/_views/head.php +++ b/src/web/_views/head.php @@ -4,23 +4,14 @@ - main->link_js($js); - } - foreach ($css_files as $css) { - echo $this->main->link_css($css); - } - ?> + <?=$title?> - -
diff --git a/src/web/_views/header.php b/src/web/_views/header.php index 7315afb..4ba15ed 100644 --- a/src/web/_views/header.php +++ b/src/web/_views/header.php @@ -1,7 +1,6 @@ main->user(); $this->view('head', $data); ?>
diff --git a/src/web/_views/modal/about.php b/src/web/_views/modal/about.php deleted file mode 100644 index 4bc7a4f..0000000 --- a/src/web/_views/modal/about.php +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/src/web/_views/modal/new_post.php b/src/web/_views/modal/new_post.php deleted file mode 100644 index 66e6561..0000000 --- a/src/web/_views/modal/new_post.php +++ /dev/null @@ -1,59 +0,0 @@ - - -main->user(); -?> -
-
-
- -
- - -
-
- -
- -
- diff --git a/src/web/_views/modal/register.php b/src/web/_views/modal/register.php deleted file mode 100644 index 5c76fe9..0000000 --- a/src/web/_views/modal/register.php +++ /dev/null @@ -1,178 +0,0 @@ - - - -
- - -
- diff --git a/src/web/_views/people/card.php b/src/web/_views/people/card.php new file mode 100644 index 0000000..7e040ba --- /dev/null +++ b/src/web/_views/people/card.php @@ -0,0 +1,15 @@ + + + +
+ +
+ format_name($user)?> + +
+
+
+ + + diff --git a/src/web/_views/people/header.php b/src/web/_views/people/header.php new file mode 100644 index 0000000..b1099ec --- /dev/null +++ b/src/web/_views/people/header.php @@ -0,0 +1,6 @@ + + +
+

+

+
diff --git a/src/web/_views/people/main.php b/src/web/_views/people/main.php new file mode 100644 index 0000000..c602b2c --- /dev/null +++ b/src/web/_views/people/main.php @@ -0,0 +1,76 @@ + +
+ people(); ?> +
+ + +
+ +
+ += $page_size && $page_size < $total): ?> + $loaded, + 'pageSize' => $page_size, + 'userCount' => $total, + 'userMax' => $max, + 'filterUid' => $filter_uid, + 'filterType' => $filer_type + ) + )?> + + diff --git a/src/web/_views/people/people.php b/src/web/_views/people/people.php new file mode 100644 index 0000000..8726f1d --- /dev/null +++ b/src/web/_views/people/people.php @@ -0,0 +1,5 @@ +view('people/card', array('user' => $user)); +} +?> diff --git a/src/web/_views/profile/main.php b/src/web/_views/profile/main.php new file mode 100644 index 0000000..3e7129c --- /dev/null +++ b/src/web/_views/profile/main.php @@ -0,0 +1,269 @@ + + +
+
+
+ +
+
+ +
+
+
+
+ format_name($user)?> + +
+ + + + +
+ 0): ?> +
+ + + +
+
+
+
+ + + + +
+
+
+
+
+ post_controller->index(); + ?> +
+
+

+ + + + + + + + + + + + + + + + + + + + + +
format_date($user['birth_date'])?>
+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
format_date($user['created'])?>
format_date($user['seen'])?>
+
+
+ people_controller->content(); + ?> +
+
+ people_controller->content(); + ?> +
+
+ +
diff --git a/src/web/_views/settings/main.php b/src/web/_views/settings/main.php new file mode 100644 index 0000000..4401fe1 --- /dev/null +++ b/src/web/_views/settings/main.php @@ -0,0 +1,197 @@ + +
+ + +
+ + + + "; +} + +?> + + + +
+
+

+
+

+ + + + + + + +
+

+ +
+
+ + +
+
+ + +
+ +
+
+

+ +

+
+ +
+ + +
+
+

+
+ +
+ + +
+
+
+
diff --git a/src/web/_views/template/comment.php b/src/web/_views/template/comment.php deleted file mode 100644 index ceac588..0000000 --- a/src/web/_views/template/comment.php +++ /dev/null @@ -1,15 +0,0 @@ - - -load->model('format'); -?> -
- -
-
- name($user)?> - main->date($comment['created'])?> -
- -
-
diff --git a/src/web/_views/template/error.php b/src/web/_views/template/error.php deleted file mode 100644 index 2e02cb1..0000000 --- a/src/web/_views/template/error.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - <?=$code . ' - ' . $msg?> - - -
-

-
-
- - diff --git a/src/web/_views/template/modal.php b/src/web/_views/template/modal.php deleted file mode 100644 index 2a041a7..0000000 --- a/src/web/_views/template/modal.php +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/src/web/_views/template/post.php b/src/web/_views/template/post.php deleted file mode 100644 index 48f8bb6..0000000 --- a/src/web/_views/template/post.php +++ /dev/null @@ -1,87 +0,0 @@ - - -
-
- -
- - main->date($post['created'])?> -
-
-

- -

-main->user(); - $liked = $post['like_id'] ? 'btn-primary' : ''; - $post_attrs = array( - 'postId' => $post['id'] - ); - if ($post['like_id'] !== NULL) { - $post_attrs['likeId'] = $post['like_id']; - } -?> - - -
-
- - -
-
- -
- $post['id']); - $cdata = $this->comments(); - - $loaded = $cdata['loaded']; - $max = $cdata['max']; - $page_size = $cdata['page_size']; - $total = $post['comment_count']; - - if ($loaded >= $page_size && $page_size < $total) { - ilang('action_load_comments', - class: 'action-load-comments btn btn-blend mt', - attrs: array( - 'postId' => $post['id'], - 'loaded' => $loaded, - 'pageSize' => $page_size, - 'commentCount' => $total, - 'commentMax' => $max, - ) - ); - } - - ?> -
- -
- -
- - -
-
- -
- - diff --git a/src/web/_views/template/posts.php b/src/web/_views/template/posts.php deleted file mode 100644 index ed79688..0000000 --- a/src/web/_views/template/posts.php +++ /dev/null @@ -1,25 +0,0 @@ -
-posts(); - - $loaded = $pdata['loaded']; - $page_size = $pdata['page_size']; - $total = $pdata['total']; - $max = $pdata['max']; - $filterUid = $pdata['filter_uid']; - - if ($loaded >= $page_size && $page_size < $total) { - ilang('action_load_posts', - id: 'action-load-posts', - class: 'btn btn-blend grow mb mt', - attrs: array( - 'loaded' => $loaded, - 'pageSize' => $page_size, - 'postCount' => $total, - 'postMax' => $max, - 'userId' => $filterUid ? json_encode($filterUid) : '' - ) - ); - } -?> -
diff --git a/src/web/_views/template/toast.php b/src/web/_views/template/toast.php deleted file mode 100644 index 0a6a82f..0000000 --- a/src/web/_views/template/toast.php +++ /dev/null @@ -1,26 +0,0 @@ - - - -
- - -
diff --git a/src/web/config.php b/src/web/config.php new file mode 100644 index 0000000..3ca2bbd --- /dev/null +++ b/src/web/config.php @@ -0,0 +1,56 @@ + 'home' sends / to /home +// +// style - single or list of css styles to load on specific routes +// +// js - single or list of js script to load on specific routes +// +// autoload - list of directories to autoload all PHP files in them +// +define('SITE_CONFIG', array( + /* core settings */ + 'domain' => 'xssbook.com', + 'allowed_hosts' => ['xssbook.com'], + 'base_path' => '/', + 'theme_color' => '#1778f2', + /* route overides */ + 'routes' => array( + 'manifest.json' => '_meta/manifest', + ), + /* css to load on each route */ + 'style' => array( + '' => 'css/common.css', + 'home' => ['css/home.css', 'css/post.css'], + 'auth' => 'css/auth.css', + 'people' => 'css/people.css', + 'profile' => ['css/profile.css', 'css/people.css', 'css/post.css'], + 'settings' => 'css/settings.css', + 'error' => 'css/error.css', + ), + /* js to load on each route */ + 'js' => array( + '' => ['js/thirdparty/jquery.min.js', 'js/lib.js', 'js/modal.js'], + 'home' => 'js/post.js', + 'profile' => 'js/post.js', + ), + /* directories to autoload php code */ + 'autoload' => array('/lib'), +)); + +define('POST_PAGE_SIZE', 10); +define('COMMENT_PAGE_SIZE', 5); +define('PEOPLE_PAGE_SIZE', 24); diff --git a/src/web/config/aesthetic.php b/src/web/config/aesthetic.php deleted file mode 100644 index 5a66660..0000000 --- a/src/web/config/aesthetic.php +++ /dev/null @@ -1,83 +0,0 @@ -config = array( - '_common' => array( - 'js' => [ - 'js/thirdparty/jquery.min.js', - 'js/lib.js', - 'js/modal.js', - ], - 'css' => [ - 'css/common.css' - ], - ), - 'error' => array( - 'css' => [ - 'css/error.css' - ], - ), - 'home' => array( - 'js' => [ - 'js/post.js', - ], - 'css' => [ - 'css/home.css', - 'css/post.css' - ], - ), - 'auth' => array( - 'css' => [ - 'css/auth.css' - ], - ), - 'people' => array( - 'css' => [ - 'css/people.css' - ], - ), - 'profile' => array( - 'js' => [ - 'js/post.js', - ], - 'css' => [ - 'css/profile.css', - 'css/people.css', - 'css/post.css' - ], - ), - 'settings' => array( - 'css' => [ - 'css/settings.css' - ] - ), - ); - } - /** - * @param mixed $route - * @return array - */ - function get_files($route): array { - $js_files = $this->config['_common']['js']; - $css_files = $this->config['_common']['css']; - - if (array_key_exists($route, $this->config)) { - $config = $this->config[$route]; - if (array_key_exists('js', $config)) { - $js_files = array_merge($js_files, $config['js']); - } - if (array_key_exists('css', $config)) { - $css_files = array_merge($css_files, $config['css']); - } - } - - return array( - 'js_files' => $js_files, - 'css_files' => $css_files, - ); - } - -} diff --git a/src/web/config/routes.php b/src/web/config/routes.php deleted file mode 100644 index 20b499a..0000000 --- a/src/web/config/routes.php +++ /dev/null @@ -1,12 +0,0 @@ -load = $load; - $this->main = $this->load->model('main'); - $this->db = $this->main->db; - - $info = $this->main->info; - $lang = $info['lang']; - $this->load->lang($lang); - $app = $info['app']; - if ($app) { - $this->load->app_lang($lang, $app); - } - - $this->format_model = $this->load->model('format'); - } - - public function index() {} - - public function redirect($link) { - header('Location: '. $link, true, 301); - die(); - } - - protected function view($__name, $data = array()) { - $__root = $GLOBALS['webroot']; - $__path = $__root . '/_views/' . $__name . '.php'; - if (is_file($__path)) { - extract($data); - require($__path); - return; - } - } - - protected function is_ajax(): bool { - $_POST = json_decode( - file_get_contents("php://input"), true - ); - return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'; - } - - protected function error($code): void { - $_GET['code'] = $code; - $this->main->info['app'] = 'error'; - $error_controller = $this->load->controller('apps/error'); - $error_controller->index(); - die(); - } - -} -?> diff --git a/src/web/core/_model.php b/src/web/core/_model.php deleted file mode 100644 index dfc7163..0000000 --- a/src/web/core/_model.php +++ /dev/null @@ -1,44 +0,0 @@ -load = $load; - $this->main = $this->load->model('main'); - $this->db = $this->main->db; - $this->config = new Aesthetic(); - } - - /** - * @returns the base model data - */ - public function get_data(): ?array { - $data = array(); - $data['self'] = $this->main->user(); - - $info = $this->main->info; - $app = $info['app']; - - if ($app) { - $files = $this->config->get_files($app); - $data = array_merge($data, $files); - } else { - $files = $this->config->get_files(); - $data = array_merge($data, $files); - } - - return $data; - } -} diff --git a/src/web/core/database.php b/src/web/core/database.php deleted file mode 100644 index 25cb5ba..0000000 --- a/src/web/core/database.php +++ /dev/null @@ -1,282 +0,0 @@ -conn = $conn; - $this->query = ''; - - $this->set = FALSE; - $this->where = FALSE; - $this->param = array(); - } - - /// - /// ARBITRARY QUERY - /// - - public function query($query) { - $this->query .= $query; - return $this; - } - - /// - /// SELECT - /// - - public function select($select) { - $this->query .= "SELECT $select\n"; - return $this; - } - - public function from($from) { - $this->query .= "FROM $from\n"; - return $this; - } - - /// - /// INSERT - /// - - public function insert_into($insert, ...$columns) { - $this->query .= "INSERT INTO $insert\n ("; - foreach ($columns as $idx => $column) { - if ($idx !== 0) { - $this->query .= ","; - } - $this->query .= $column; - } - $this->query .= ")\n"; - return $this; - } - - public function values(...$values) { - $this->query .= "VALUES ("; - foreach ($values as $idx => $value) { - if ($idx !== 0) { - $this->query .= ","; - } - $this->query .= "?"; - array_push($this->param, $value); - } - $this->query .= ")\n"; - return $this; - } - - /// - /// WHERE - /// - - public function where($cond) { - if (!$this->where) { - $this->where = TRUE; - $this->query .= "WHERE "; - } else { - $this->query .= "AND "; - } - $this->query .= "$cond "; - return $this; - } - - public function where_in($column, $array) { - if (!$this->where) { - $this->where = TRUE; - $this->query .= "WHERE "; - } else { - $this->query .= "AND "; - } - if (empty($array)) { - $this->query .= "FALSE\n"; - return $this; - } - $in = $this->in($array); - $this->query .= "$column $in\n"; - return $this; - } - - private function in($array) { - $in = 'IN ('; - foreach ($array as $idx => $item) { - if ($idx != 0) { - $in .= ","; - } - $in .= "?"; - array_push($this->param, $item); - } - $in .= ")"; - return $in; - } - - /// - /// OPERATORS - /// - - public function like($item) { - $this->query .= "LIKE ?\n"; - array_push($this->param, $item); - return $this; - } - - public function eq($item) { - $this->query .= "= ?\n"; - array_push($this->param, $item); - return $this; - } - - public function ne($item) { - $this->query .= "<> ?\n"; - array_push($this->param, $item); - return $this; - } - - public function lt($item) { - $this->query .= "< ?\n"; - array_push($this->param, $item); - return $this; - } - - public function le($item) { - $this->query .= "<= ?\n"; - array_push($this->param, $item); - return $this; - } - - /// - /// JOINS - /// - - public function join($table, $on, $type = 'LEFT') { - $this->query .= "$type JOIN $table ON $on\n"; - return $this; - } - - /// - /// LIMIT, OFFSET, ORDER - /// - - public function limit($limit) { - $this->query .= "LIMIT ?\n"; - array_push($this->param, $limit); - return $this; - } - - public function offset($offset) { - $this->query .= "OFFSET ?\n"; - array_push($this->param, $offset); - return $this; - } - - public function order_by($column, $order = 'ASC') { - $this->query .= "ORDER BY " . $column . ' ' . $order . ' '; - return $this; - } - - /// - /// COLLECT - /// - - public function rows(...$params) { - $args = $this->param; - foreach ($params as $param) { - array_push($args, $param); - } - $stmt = $this->conn->prepare($this->query); - try { - $stmt->execute($args); - } catch (Exception $ex) { - echo $ex; - echo '
>> caused by <<
'; - echo str_replace("\n", "
", $this->query); - } - return $stmt->fetchAll(PDO::FETCH_ASSOC); - } - - public function row(...$params) { - $args = $this->param; - foreach ($params as $param) { - array_push($args, $param); - } - $stmt = $this->conn->prepare($this->query); - $stmt->execute($args); - return $stmt->fetch(PDO::FETCH_ASSOC); - } - - public function execute(...$params) { - $args = $this->param; - foreach ($params as $param) { - array_push($args, $param); - } - $stmt = $this->conn->prepare($this->query); - try { - $stmt->execute($args); - return TRUE; - } catch (Exception $_e) { - echo $_e; - echo '
>> caused by <<
'; - echo str_replace("\n", "
", $this->query); - return FALSE; - } - } -} - -/** - * DatabaseHelper - * allows queries on the - * postgres database - */ -class DatabaseHelper { - - private $conn; - - function __construct() { - $this->conn = NULL; - } - - private function connect() { - if ($this->conn === NULL) { - $user = getenv("POSTGRES_USER"); - $pass = getenv("POSTGRES_PASSWORD"); - $db = getenv("POSTGRES_DB"); - $host = 'db'; - $port = '5432'; - - $conn_str = sprintf("pgsql:host=%s;port=%d;dbname=%s;user=%s;password=%s", - $host, - $port, - $db, - $user, - $pass - ); - $this->conn = new \PDO($conn_str); - $this->conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - } - return $this->conn; - } - - public function select($select) { - $conn = $this->connect(); - $query = new DatabaseQuery($conn); - return $query->select($select); - } - - public function insert_into($insert, ...$columns) { - $conn = $this->connect(); - $query = new DatabaseQuery($conn); - return $query->insert_into($insert, ...$columns); - } - - public function query($query_str) { - $conn = $this->connect(); - $query = new DatabaseQuery($conn); - return $query->query($query_str); - } -} - diff --git a/src/web/core/loader.php b/src/web/core/loader.php deleted file mode 100644 index 2091533..0000000 --- a/src/web/core/loader.php +++ /dev/null @@ -1,101 +0,0 @@ -loaded = array(); - } - - /** - * Loads a $type of object from a $dir with a given $name - * @param string $name - the name of the object to load - * @param string $dir - the directory theese objects are stored in - * @param string $type - the type of the object - */ - private function load_type($name, $dir, $type): object|NULL { - $path = $dir . '/' . $name . '.php'; - if (array_key_exists($path, $this->loaded)) { - return $this->loaded[$path]; - } - - if (!file_exists($path)) { - return NULL; - } - - $parts = explode('/', $name); - $part = end($parts); - $class = ucfirst($part) . '_' . $type; - require($path); - - $ref = NULL; - try { - $ref = new ReflectionClass($class); - } catch (Exception $_e) {} - - if ($ref === NULL) { - return NULL; - } - - $obj = $ref->newInstance($this); - $this->loaded[$path] = $obj; - - return $obj; - } - - /** - * Loads a model - * @param string $name - the name of the model to load - */ - public function model($name): object|NULL { - $root = $GLOBALS['webroot']; - $dir = $root . '/_model'; - return $this->load_type($name, $dir, 'model'); - } - - /** - * Loads a controller - * @param string $name - the name of the controller to load - */ - public function controller($name): Controller|NULL { - $root = $GLOBALS['webroot']; - $dir = $root . '/_controller'; - return $this->load_type($name, $dir, 'controller'); - } - - /** - * Loads the given common lang - * @param string $lang_code 0 the language code - */ - public function lang($lang_code): void { - $dir = $GLOBALS['webroot'] . '/lang/' . $lang_code . '/'; - $lang = $GLOBALS['lang']; - if ($handle = opendir($dir)) { - while (false !== ($entry = readdir($handle))) { - if ($entry === '.' || $entry === '..' || $entry === 'apps') { - continue; - } - $path = $dir . $entry; - require($path); - } - } - $GLOBALS['lang'] = $lang; - } - - /** - * Loads a given app specific lang - * @param string $lang_code - the language code - * @param string $name - the name of the app - */ - public function app_lang($lang_code, $name): void { - $dir = $GLOBALS['webroot'] . '/lang/' . $lang_code . '/apps/'; - $file = $dir . $name . '.php'; - if (file_exists($file)) { - $lang = $GLOBALS['lang']; - require($dir . $name . '.php'); - $GLOBALS['lang'] = $lang; - } - } - -} diff --git a/src/web/core/router.php b/src/web/core/router.php deleted file mode 100644 index 557665b..0000000 --- a/src/web/core/router.php +++ /dev/null @@ -1,159 +0,0 @@ -load = $load; - $this->main = $this->load->model('main'); - } - - /** - * @param string $path - the current request path - * Gets the current route - * @return array - */ - private function get_req_route($path): array { - // trim the path - $path = trim($path); - // remove first '/' - $path = substr($path, 1); - // get path parts - $parts = explode('/', $path); - - $len = count($parts); - - // get route info - $route = array(); - // e.g. / - if ($path === '') { - $route = array( - 'route' => '', - 'slug' => 'index', - ); - // e.g. /home /login - } else if ($len === 1) { - $route = array( - 'route' => $parts[0], - 'slug' => 'index', - ); - // e.g. /home/posts - } else { - $route = array ( - 'route' => implode('/', array_slice($parts, 0, -1)), - 'slug' => end($parts) - ); - }; - - $route['app'] = $route['route']; - $routes = $GLOBALS['routes']; - if (array_key_exists($route['route'], $routes)) { - $route['route'] = $routes[$route['route']]; - } - - return $route; - } - - /** - * Gets the curret request info - * @return array - */ - private function get_req(): array|bool { - $method = $_SERVER['REQUEST_METHOD']; - - $uri = parse_url($_SERVER['REQUEST_URI']); - if (!$uri) { - return FALSE; - } - - $path = $uri['path']; - - return array_merge( - array( - 'uri' => $uri, - 'method' => $method, - 'lang' => $this->get_lang(), - ), - $this->get_req_route($path), - ); - } - - /** - * Gets the current language - * @return string - */ - private function get_lang(): string { - return 'en_US'; - } - - /** - * Handles a router error code - * @param int $code - the http error code - * @param bool $recursed - */ - private function handle_error($code, $recursed): void { - if ($recursed) { - die($code . ' (recursed)'); - } - - $this->main->info = array(); - $this->main->info['slug'] = 'index'; - $this->main->info['app'] = 'error'; - $this->main->info['route'] = 'apps/error'; - $this->main->info['lang'] = $this->get_lang(); - $req = $this->main->info; - $_GET['code'] = $code; - - $this->handle_req($req, TRUE); - } - - /** - * @param array $req - * @param bool $recursed - */ - private function handle_req($req, $recursed = FALSE): void { - - if ($req === FALSE) { - $this->handle_error(500, $recursed); - return; - } - - $controller = $this->load->controller($req['route']); - - if ($controller === NULL) { - $this->handle_error(404, $recursed); - return; - } - - $ref = NULL; - try { - $ref = new ReflectionMethod($controller, $req['slug']); - } catch (Exception $_e) {} - - if ($ref === NULL || !$ref->isPublic()) { - $this->handle_error(404, $recursed); - return; - - } - - $ref->invoke($controller); - } - - /** - * Handels the incomming reuqest - */ - public function handle_request(): void { - $req = $this->get_req(); - $this->main->info = $req; - $this->handle_req($req); - } - -} diff --git a/src/web/helper/error.php b/src/web/helper/error.php deleted file mode 100644 index 2b6959e..0000000 --- a/src/web/helper/error.php +++ /dev/null @@ -1,9 +0,0 @@ -'; - } else if ($click) { - $content .= '