diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d574c04..0000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/uploads -/__pycache__ -/dataBase.db -/.env -/out -/Telegram_provider/dataBase.db -/Telegram_provider/.env \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c456616..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "FileUploaderBot"] - path = FileUploaderBot - url = https://github.com/kwixie1/FileUploaderBot.git diff --git a/404.html b/404.html deleted file mode 100644 index e4db7a9..0000000 --- a/404.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - File uploader - - - - - - - -
-

File uploader

- -
-

by AndcoolSystems

-
-
-
-                    .:
-                    !&J
-                    ~GP:
-                    !#?
-            :^:. .!J7.
-           .JB&@@B~?57.                     ..:^~!7JY?
-       .~?:G@@@@B?#@@@&7       ..:^~!7?JJYYY5PG&@#PJ77~
-     .J#B^!@@@@@&&@@@@@&.!JYYYY55YYJ?!~^~!?Y55J7~!?5B@#
-     ^@@! ^@@@@@@@@@@@@B.^J&#G!     .~?Y5Y?!~!JP#@@@@@B
-⠀⠀^JYY57!#G  ?B@@@@@@@@#5: .7^.~7Y55J!^~7YG&@@@@@@@@@B
-Y@#7:  .?^ 7G?7?JYY?^.  ~55?7J55J7^^~?P#@@@@@@@@@@@#P?^
-Y#!5PY7~:.  !GPY5Y7.  :!J55Y7~:^!JG&@@@@@@@@@@&BY!:  :~
-Y#  .~7JY555YYGBPYJJY55J!::^75B&@@@@@@@@@@#PJ~. .^?P#@#
-Y#        ..:::^^^^^^.:~?P#@@@@@@@@@@&B57^  :!JG&@@@@@B
-Y#                   P&@@@@@@@@@@&GY!:  ^75B&@@@@@@@@@B
-Y#                  .&@@@@@@@#P?~. .~JP#@@@@@@@@@@&B57:
-Y#                  .&@@&B57:  :!YG&@@@@@@@@@@&GJ!::~?J
-Y#                  .5J~. .^?5#@@@@@@@@@@@#P?~:^!YG&@@#
-Y#       404          .~JG#@@@@@@@@@@&BY7^:^75B@@@@@@@#
-Y#                  .P&@@@@@@@@@@#GJ~::~JP#@@@@@@@@@@@P
-Y#                  .&@@@@@@@B5?^:^!YB&@@@@@@@@@@&GY!:
-Y#                  .&@@&GY!^:~?P#@@@@@@@@@@@#P?~.
-Y#                  .5J~::!JG&@@@@@@@@@@&B57^.
-Y#                   :75B&@@@@@@@@@@#GJ!:
-!&!                 .#@@@@@@@@@@B5?^.
-~GP!:              .&@@@@@&GY!:
-    ~J55YJ?7!~~^^^^^~!@@#PJ~.
-    .^~!7??JJJJJJJJ7^.
-                    
-
-

The file is a lie.

-
-
- - \ No newline at end of file diff --git a/FileUploaderBot b/FileUploaderBot deleted file mode 160000 index 2c0f5d9..0000000 --- a/FileUploaderBot +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2c0f5d9c7f5660ea101321c52f41197dfa552e91 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f288702..0000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/README.md b/README.md deleted file mode 100644 index 3226c44..0000000 --- a/README.md +++ /dev/null @@ -1,459 +0,0 @@ -# File Uploader - -The file uploader is implemented in the Python programming language using FastAPI. All uploaded files are stored on the server. The API provides the ability to preview and download files based on their file extensions. - -## API Documentation - -The API is currently hosted at [fu.andcool.ru](https://fu.andcool.ru/). -Page redirection is handled through the nginx proxy server. The API consists of 2 pathes: - -- `/file/` – Endpoint where all files are located. -- `/api/` – Main API endpoint - -### 1.1 Authorization Errors - -All requests requiring the `Authorization` header may encounter errors related to authorization issues. -The `Authorization` header should have the format `Authorization: Bearer `. - -#### Response Example - -All errors of this type follow a consistent response format and always return an HTTP code of `401`. -This section will be referred to as `1.1` in the documentation. - -```json -{ - "status": "error", - "message": "Auth error", - "auth_error": { - "message": "error message", - "errorId": - } -} -``` - -**List of errors:** - -| errorId | message | Reasons | -| ------- | ------------------------------------------------------ | -------------------------------------------------- | -| -1 | No Authorization header provided | The request is missing the `Authorization` header | -| -2 | Authorization header must have `Bearer ` format | The `Authorization` header has an incorrect format | -| -3 | Access token expired | The token has expired | -| -4 | Invalid access token | The token cannot be decrypted | -| -5 | Token not found | The token is not found | - -### 1.2 Basic API - -### Retrieve a file based on the URL. -`GET /file/` or `GET /f/` -Successful execution returns a `200` status code and the binary file with the `Content-Type`. -If the file type cannot be determined, the API returns the file in download mode. - -#### Possible Errors - -| Error Code | Description | Possible Reasons | -| ---------- | -------------- | ---------------------------------------------- | -| 404 | File not found | The file referenced by the code does not exist | - -### Upload a file to the server -`POST /api/upload/{group_id}?include_ext=false` -The request body should contain the file to be uploaded. -Only one file is allowed, and its size should not exceed 100MB. -The maximum request frequency is **2 per minute**. - -**Query params:** -> The `group_id` parameter indicates the group to which the file should be uploaded. The parameter can take the value `private`, which means that the file must be linked to a personal account. When passing the `group_id` parameter other than the `private` Authorization header is required. - -**Request body:** -> **The `Content-Type` header of the request must be a `multipart/form-data`** -The file must be have `file` key in request body. -The query parameter `include_ext` can be set to `true/false` to indicate whether the file extension should be included in the file URL. - -**Request headers:** ->The request can also include the `Authorization` header, containing the user's unique token. -If the token is not provided or is not valid, the `synced` field in the response body will be set to `false`. The file will be uploaded to the server regardless of whether the `Authorization` header is included in the request. The `auth_error` field in the response body contains the authentication error (section `1.1`), and if there is no error, the field will be `{}`. - -#### Response Example -On successful execution, the API returns a `200` HTTP code along with a JSON response. - -```json -{ - "status": "success", - "message": "File uploaded successfully", - "file_url": "4yn-8yjhsu", - "file_url_full": "https://fu.andcool.ru/file/4yn-8yjhsu", - "key": "6b9a1c1b-5594-4cb9-8d49-99a4c28782a1", - "ext": ".mp4", - "user_filename": "test.mp4", - "synced": true, - "auth_error": {} -} -``` - -#### Possible Errors -| Error Code | message | Possible Reasons | -| ---------- | ----------------------------------- | ------------------------------------------------------------------------------ | -| 400 | No file uploaded | No file is given in the request body | -| 413 | File size exceeds the limit (100MB) | The file size exceeds 100MB | -| 400 | Invalid group id | `group_id` parameter contains non-numerical value | -| 404 | Group not found | The group wuth provided `group_id` not found | -| 403 | You are not in the group | Group is exists, but you are has not permissions to upload files in this group | - -### Delete a file -`GET /api/delete/?key=` -Successful execution returns a `200` status code, removing the file from the server. - -#### Possible Errors - -| Error Code | Description | Possible Reasons | -| ---------- | ------------------ | ---------------------------------- | -| 404 | File not found | The file for deletion is not found | -| 400 | Invalid unique key | The provided unique key is invalid | - -### 1.2 Authorization API -### Login and register -`POST /api/register` -`POST /api/login` -Request limit per minute: 10 times. -Both requests accept the same request body but have different errors. -> A Boolean value can be passed to the optional query parameter `bot`. When `bot` is true, a token with a lifetime of 6 months will be generated. - -#### Request Example - -```json -{ - "username": "My cool username", - "password": "My cool password" -} -``` - -Successful execution returns a `200` HTTP code, indicating successful registration / login. - -```json -{ - "status": "success", - "accessToken": "", - "username": "My cool username", - "message": "logged in with password" -} -``` - -### Possible Errors - -**Common for both requests:** - -| errorId | HTTP code | message | Reasons | -| ------- | --------- | ----------------------------- | --------------------------------------------------- | -| 2 | 400 | No username/password provided | Username/password fields are missing in the request | - -**Errors for /register:** - -| errorId | HTTP code | message | Reasons | -| ------- | --------- | ----------------------------------------------- | --------------------------------------------- | -| 1 | 400 | An account with this name is already registered | A user with the given username already exists | - -**Errors for /login:** - -| errorId | HTTP code | message | Reasons | -| ------- | --------- | -------------- | ------------------ | -| 3 | 400 | Wrong password | Incorrect password | -| 4 | 404 | User not found | Username not found | - -### Refreshe the token -`POST /api/refresh_token` -Request limit per minute: 10 times. -The request body includes the `accessToken` field containing only the token (without `Bearer`). -Successful execution returns a `200` HTTP code along with the `accessToken` field in the request body, containing the new token. - -#### Possible Errors - -| errorId | HTTP code | message | Reasons | -| ------- | --------- | ------------------------ | ------------------------------------------------- | -| 5 | 400 | No access token provided | The `accessToken` field is missing in the request | - -Errors described in section `1.1` may also occur. - -### Log out of the account -`POST /api/logout` -Request limit per minute: 10 times. -Endpoint takes the `Authorization` header containing the access token. -Successful execution of the request deletes the provided token and returns a `200` HTTP code - -#### Possible Errors - -Errors described in section `1.1` may occur as well. - - -### Get a list of files. -`GET /api/get_files/{group_id}` -It takes the `Authorization` header containing the access token. -Retrieves a list of all files associated with this account. - -> The `group_id` parameter shows which group to get the files from. If the parameter is set to `private`, the files will be taken from a personal account, otherwise Authorization header is required - -#### Response Example - -```json -{ - "status": "success", - "message": "files got successfully", - "username": "My cool username", - "is_group_owner": true, - "data": [ - { - "file_url": "4yn-8yjhsu", - "file_url_full": "https://fu.andcool.ru/file/4yn-8yjhsu", - "key": "6b9a1c1b-5594-4cb9-8d49-99a4c28782a1", - "ext": ".mp4", - "user_filename": "test.mp4", - "creation_date": "1.1.1971", - "synced": true - }, - { - "file_url": "4yn-8yjhsR", - "file_url_full": "https://fu.andcool.ru/file/4yn-8yjhsR", - "key": "6b9a1c1b-5594-4cb9-8d49-99a4c28782a1", - "ext": ".mp4", - "user_filename": "test1.mp4", - "creation_date": "1.1.1971", - "synced": true - } - ] -} -``` - -#### Possible Errors - -Errors described in section `1.1` may occur as well. -| Error Code | message | Possible Reasons | -| ---------- | ------------------------ | ------------------------------------------------------------------------------ | -| 400 | Invalid group id | `group_id` parameter contains non-numerical value | -| 404 | Group not found | The group wuth provided `group_id` not found | -| 403 | You are not in the group | Group is exists, but you are has not permissions to upload files in this group | - - -### Transfer local files to an account. -`POST /api/transfer` -It takes the `Authorization` header containing the access token. - -> The request transfers local files to the account. The endpoint takes files from the `data` field in the request body and sequentially binds each file to an account. If the binding of any file failed, then these files will be returned in the response body in the `unsuccess` field. The file is transferred by their `file_url` and `key` - -#### Request body example -```json -{ - "data":[ - { - "file_url": "4yn-8yjhsu", - "key": "6b9a1c1b-5594-4cb9-8d49-99a4c28782a1" - }, - { - "file_url": "4yn-8yjhsR", - "key": "6b9a1c1b-5594-4cb9-8d49-99a4c28782a1" - } - ] -} -``` - -#### Response example - -```json -{ - "status": "success", - "message": "transfered", - "unsuccess": [ - { - "file_url": "4yn-8yjhsR", - "key": "6b9a1c1b-5594-4cb9-8d49-99a4c28782a1" - } - ] -} - -``` - -#### Possible Errors - -Errors described in section `1.1` may occur as well. -| Error Code | message | Possible Reasons | -| ---------- | ------------------------------- | ---------------------------------------------- | -| 400 | Couldn't parse request body | No request body provided | -| 400 | No `data` field in request body | Couldn't not find `data` field in request body | - -## Groups - -### Create file group -`POST /api/create_group` -It takes the `Authorization` header containing the access token. -> Creates a group with the passed name. The maximum length of a group name is 50 characters. - -#### Request body example -```json -{ - "group_name": "New group" -} -``` - -#### Response example - -```json -{ - "status": "success", - "message": "created", - "name": "New group", - "group_id": 12345678, -} -``` - -#### Possible Errors - -Errors described in section `1.1` may occur as well. -| Error Code | message | Possible Reasons | -| ---------- | ------------------------------------- | ---------------------------------------------------- | -| 400 | No `group_name` provided | Couldn't not find `group_name` field in request body | -| 400 | Group name length exceeded (50 chars) | Too long group name | - -### Delete file group -`DELETE /api/delete_group/{group_id}` -It takes the `Authorization` header containing the access token. -> Deletes a group with the passed `group_id`. - - -#### Response example - -```json -{ - "status": "success", - "message": "deleted" -} -``` - -#### Possible Errors - -Errors described in section `1.1` may occur as well. -| Error Code | message | Possible Reasons | -| ---------- | -------------------------------------------------- | -------------------------------------- | -| 404 | Group not found | Group with passed `group_id` not found | -| 403 | You dont have any permissions to delete this group | You are not owner of this group | - -### Generate a new invite link -`GET /api/generate_invite/{group_id}` -It takes the `Authorization` header containing the access token. -> Generates a invite link for group with the passed `group_id`. - - -#### Response example - -```json -{ - "status": "success", - "message": "created", - "invite_link": "https://fu.andcool.ru/invite/DSAfd4-hpoqFDFj" -} -``` - -#### Possible Errors - -Errors described in section `1.1` may occur as well. -| Error Code | message | Possible Reasons | -| ---------- | ----------------------------- | -------------------------------------- | -| 404 | Group not found | Group with passed `group_id` not found | -| 403 | You dont have any permissions | You are not owner of this group | - -### Join to a group -`POST /api/join/{invite_link}` -It takes the `Authorization` header containing the access token. -> Joins to a group by passed `invite_link`. - - -#### Response example - -```json -{ - "status": "success", - "message": "created", - "name": "New group", - "group_id": 12345678, -} -``` - -#### Possible Errors - -Errors described in section `1.1` may occur as well. -| Error Code | message | Possible Reasons | -| ---------- | ---------------------------- | ----------------------------- | -| 404 | Invite link not found | Could not found a invite link | -| 400 | You are already in the group | You are already in the group | - - -### Leave from group -`POST /api/leave/{group_id}` -It takes the `Authorization` header containing the access token. -> Leaves from group with passed `group_id` - - -#### Response example -```json -{ - "status": "success", - "message": "leaved" -} -``` - -#### Possible Errors - -Errors described in section `1.1` may occur as well. -| Error Code | message | Possible Reasons | -| ---------- | ------------------------ | -------------------------------------- | -| 404 | Group not found | Group with passed `group_id` not found | -| 400 | You are not in the group | You are not in the group | - - -### Get info about invite link -`GET /api/invite_info/{invite_link}` -It takes the `Authorization` header containing the access token. -> Gives an information about group about invite link. - - -#### Response example -```json -{ - "status": "success", - "message": "Info got successfully", - "name": "New group", - "group_id": 12345678, -} -``` - -#### Possible Errors - -Errors described in section `1.1` may occur as well. -| Error Code | message | Possible Reasons | -| ---------- | --------------------- | ----------------------------- | -| 404 | Invite link not found | Could not found a invite link | - - -### Get all group from account -`GET /api/get_groups` -It takes the `Authorization` header containing the access token. -> Get list of groups linked to an account. - - -#### Response example -```json -{ - "status": "success", - "message": "groups got successfully", - "groups": [ - { - "name": "Bim-Bim", - "group_id": 12345679 - }, - { - "name": "Bam-Bam", - "group_id": 12345677 - } - ] -} -``` - -#### Possible Errors - -Errors described in section `1.1` may occur as well. diff --git a/Telegram_provider/.env b/Telegram_provider/.env deleted file mode 100644 index 6ebec57..0000000 --- a/Telegram_provider/.env +++ /dev/null @@ -1 +0,0 @@ -TOKEN=6423586916:AAG2Fi0Su0qoJIC9EZjX-UL23ZVU_WGZoJg \ No newline at end of file diff --git a/Telegram_provider/main.py b/Telegram_provider/main.py deleted file mode 100644 index d998cfe..0000000 --- a/Telegram_provider/main.py +++ /dev/null @@ -1,289 +0,0 @@ -""" -by AndcoolSystems, 2024 -""" - -from aiogram import Bot, Dispatcher, types, F -from aiogram.fsm.context import FSMContext -from aiogram.fsm.state import StatesGroup, State -from aiogram.filters.command import Command -from aiogram.utils.keyboard import InlineKeyboardBuilder -from aiogram.methods import DeleteWebhook -from prisma import Prisma -import os -from dotenv import load_dotenv -import time -import asyncio -import io -import aiohttp - -"""Создание всех нужных объектов""" -load_dotenv() -bot = Bot(token=os.getenv("TOKEN")) -dp = Dispatcher() -db = Prisma() -version = "beta 0.0.1" - -class States(StatesGroup): - """Стейты для aiogram""" - - wait_to_data = State() - login_register = State() - - -async def upload(bytes: bytearray, filename: str, user): - form_data = aiohttp.FormData() - form_data.add_field('file', bytes, filename=filename) - headers = {} - if user: - headers = {"Authorization": "Bearer " + user.token} - - async with aiohttp.ClientSession("https://fu.andcool.ru") as session: - async with session.post(f"/api/upload/private", - data=form_data, headers=headers) as r: - return r, await r.json() - - -async def get_files(token: str): - async with aiohttp.ClientSession("https://fu.andcool.ru") as session: - async with session.get(f"/api/get_files/private", headers={"Authorization": "Bearer " + token}) as r: - return r, await r.json() - - -async def send_login_message(message: types.Message): - builder = InlineKeyboardBuilder() - builder.add(types.InlineKeyboardButton( - text="Log in", - callback_data=f"log_login") - ) - builder.add(types.InlineKeyboardButton( - text="Register", - callback_data=f"log_register") - ) - - await message.answer(f"_To access your files from any device, sign in. " + \ - "The files will be linked to your account and you will have full access to them._", - reply_markup=builder.as_markup(), - parse_mode="Markdown") - - -@dp.message(Command('start')) -async def start(message: types.Message, state: FSMContext): - """Хэндлер для команды /start""" - - await state.clear() - await message.answer("*Attention! This bot is in open beta testing, so there may be significant bugs and errors in operation.\n*" + \ - f"Current version: {version}", parse_mode="Markdown") - await message.answer(f"Hello, {message.from_user.full_name}!\n" + \ - f"I am the Telegram provider of the fu.andcool.ru service. To get started, send me the file that needs to be uploaded.") - - -@dp.message(Command('account')) -async def account(message: types.Message, state: FSMContext): - user = await db.user.find_first(where={"user_id": message.from_user.id}) - if not user: - await send_login_message(message) - return - - else: - response, response_json = await get_files(user.token) - if response.status == 401: - await db.user.delete(where={"id": user.id}) - await send_login_message(message) - return - - if response.status == 429: - await message.answer("Sorry, the servers are overloaded right now") - return - - builder = InlineKeyboardBuilder() - builder.add(types.InlineKeyboardButton( - text="Log out", - callback_data=f"logout") - ) - - await message.answer(f"*Account:*\n*Username:* {user.username}\n" + \ - f"*Files on account:* {len(response_json['data'])}", - reply_markup=builder.as_markup(), - parse_mode="Markdown") - - -@dp.callback_query(F.data.startswith("log_")) -async def log(callback: types.CallbackQuery, state: FSMContext): - await callback.message.delete() - await callback.message.answer(f"OK, now send me the data from your account in the format:\n```\nMy cool username\nMy cool password```", - parse_mode="Markdown") - await state.set_state(States.wait_to_data) - await state.update_data(login_register=callback.data.replace("log_", "")) - - -@dp.message(F.text, States.wait_to_data) -async def log_reg(message: types.Message, state: FSMContext): - login_register = (await state.get_data())["login_register"] - login_and_password = message.text.replace('`', '').split("\n") - - if len(login_and_password) < 2: - await message.answer('The data was sent incorrectly') - return - - async with aiohttp.ClientSession("https://fu.andcool.ru") as session: - async with session.post(f"/api/{'login' if login_register == 'login' else 'register'}?bot=true", - json={"username": login_and_password[0], - "password": login_and_password[1]}) as r: - - await message.delete() - data_resp = await r.json() - if r.status == 400 or r.status == 404: - await message.answer(data_resp['message']) - return - - if r.status == 200: - await db.user.create(data={ - "user_id": message.from_user.id, - "username": data_resp['username'], - 'token': data_resp['accessToken'] - }) - await account(message, state) - await state.clear() - return - - await message.answer("Unhandled error") - return - - -@dp.callback_query(F.data == "logout") -async def log(callback: types.CallbackQuery, state: FSMContext): - user = await db.user.find_first(where={"user_id": callback.from_user.id}) - if not user: - await callback.message.answer("You are not logged in") - return - - async with aiohttp.ClientSession("https://fu.andcool.ru") as session: - async with session.get(f"/api/logout", headers={"Authorization": "Bearer " + user.token}) as response: - if response.status == 401 or response.status == 200: - await db.user.delete(where={"id": user.id}) - await callback.message.answer("Logged out!") - await callback.message.delete() - return - - -@dp.message(F.content_type.in_({'document', 'photo', 'video', 'animation', 'video_note', 'voice', 'text'})) -async def send_file(message: types.Message, state: FSMContext): - """Хэндлер для файлов""" - - match message.content_type: - case "document": - document = message.document - file_id = document.file_id - - bio = io.BytesIO() - filename = document.file_name - file_bytes = await bot.download(file_id, destination=bio) - bio.seek(0) - - case "photo": - photo = message.photo[-1] - file_id = photo.file_id - file = await bot.get_file(file_id) - - bio = io.BytesIO() - filename = file.file_path - file_bytes = await bot.download(file_id, destination=bio) - bio.seek(0) - - case "video": - video = message.video - file_id = video.file_id - file = await bot.get_file(file_id) - - bio = io.BytesIO() - filename = file.file_path - file_bytes = await bot.download(file_id, destination=bio) - bio.seek(0) - - case "animation": - animation = message.animation - file_id = animation.file_id - file = await bot.get_file(file_id) - - bio = io.BytesIO() - filename = file.file_path - file_bytes = await bot.download(file_id, destination=bio) - bio.seek(0) - - case "video_note": - video_note = message.video_note - file_id = video_note.file_id - file = await bot.get_file(file_id) - - bio = io.BytesIO() - filename = file.file_path - file_bytes = await bot.download(file_id, destination=bio) - bio.seek(0) - - case "voice": - voice = message.voice - file_id = voice.file_id - file = await bot.get_file(file_id) - - bio = io.BytesIO() - filename = f"voice.mp3" - file_bytes = await bot.download(file_id, destination=bio) - bio.seek(0) - - case "text": - file_bytes = message.text.encode() - filename = 'text.txt' - - user = await db.user.find_first(where={"user_id": message.from_user.id}) - response, result = await upload(file_bytes, filename, user) - - if response.status != 200: - error = result['error'] if response.status == 429 else result['message'] - await message.reply(error) - return - - builder = InlineKeyboardBuilder() - builder.add(types.InlineKeyboardButton( - text="Delete file", - callback_data=f"delete_{result['file_url']}_{result['key']}") - ) - - await message.reply(f"*Your file has been uploaded.!*\n*Link:* {result['file_url_full']}\n*Size:* {result['size']}", - reply_markup=builder.as_markup(), - parse_mode="Markdown") - - -@dp.callback_query(F.data.startswith("delete_")) -async def delete_file(callback: types.CallbackQuery, state: FSMContext): - """Хэндлер для колбэка кнопок выбора удаления""" - - file_data = callback.data.replace("delete_", "").split("_") - async with aiohttp.ClientSession("https://fu.andcool.ru") as session: - async with session.get(f"/api/delete/{file_data[0]}?key={file_data[1]}") as r: - response = await r.json() - if response['status'] == 'success': - await callback.message.delete() - await callback.message.answer("File has been deleted!") - else: - await callback.message.answer(response['message']) - - -async def start(): - """Асинхронная функция для запуска диспатчера""" - - await db.connect() # Connecting to database - started = True - while started: - try: - await bot(DeleteWebhook(drop_pending_updates=True)) - await dp.start_polling(bot) - started = False - except Exception: - started = True - print("An error has occurred, reboot in 10 seconds") - time.sleep(10) - print("rebooting...") - - -if __name__ == '__main__': - asyncio.run(start()) diff --git a/Telegram_provider/schema.prisma b/Telegram_provider/schema.prisma deleted file mode 100644 index 91ac307..0000000 --- a/Telegram_provider/schema.prisma +++ /dev/null @@ -1,18 +0,0 @@ -datasource db { - // could be postgresql or mysql - provider = "sqlite" - url = "file:dataBase.db" -} - -generator db { - provider = "prisma-client-py" - interface = "asyncio" - recursive_type_depth = 5 -} - -model User { - id Int @id @default(autoincrement()) - user_id BigInt @default(0) - username String @default("") - token String @default("") -} diff --git a/accept_invite.html b/accept_invite.html deleted file mode 100644 index 77c0621..0000000 --- a/accept_invite.html +++ /dev/null @@ -1,213 +0,0 @@ - - - - - File uploader - - - - - - - -
-

File uploader

- -
-
-

Loading...

-

- -
-
- - - - \ No newline at end of file diff --git a/config.py b/config.py deleted file mode 100644 index 889e276..0000000 --- a/config.py +++ /dev/null @@ -1,33 +0,0 @@ -filetypes = { - "xml": "application/xml", - "yaml": "application/x-yaml", - - "aac": "audio/aac", - "mp3": "audio/mpeg", - "mpeg": "audio/mpeg", - "ogg": "audio/ogg", - - "gif": "image/gif", - "jpeg": "image/jpeg", - "jpg": "image/jpeg", - "png": "image/png", - "svg": "image/svg+xml", - "tiff": "image/tiff", - "ico": "image/vnd.microsoft.icon", - "wbmp": "image/vnd.wap.wbmp", - "webp": "image/webp", - - "csv": "text/csv", - "html": "text/html", - "md": "text/markdown", - "txt": "text/plain", - - "mpeg": "video/mpeg", - "mp4": "video/mp4", - "webm": "video/webm", - "avi": "video/x-msvideo", -} -default = "application/x-msdownload" - -accesLifeTime = 432_000 -accesLifeTimeBot = 15_552_000 \ No newline at end of file diff --git a/imports.py b/imports.py deleted file mode 100644 index fc02171..0000000 --- a/imports.py +++ /dev/null @@ -1,23 +0,0 @@ -from fastapi import FastAPI, UploadFile, Request, Header -from fastapi.responses import JSONResponse, FileResponse, Response -from typing import Annotated, Union -import uvicorn -from config import * -import aiohttp -import utils -from slowapi.errors import RateLimitExceeded -from slowapi import Limiter, _rate_limit_exceeded_handler -from slowapi.util import get_remote_address -from fastapi.middleware.cors import CORSMiddleware -import time -import aiofiles -from prisma import Prisma -import uuid -import os -from datetime import datetime -from dotenv import load_dotenv -import jwt -import bcrypt -import random - -rate_limit_exceeded_handler = _rate_limit_exceeded_handler diff --git a/main.py b/main.py deleted file mode 100644 index edb95c0..0000000 --- a/main.py +++ /dev/null @@ -1,941 +0,0 @@ -""" -created by AndcoolSystems, 2023-2024 -""" - -from imports import * - - -def custom_key_func(request: Request): - if get_remote_address(request) == os.getenv("SERVER_IP"): - return "bots" - return "user" - - -def dynamic_limit_provider(key: str): - if key == "bots": - return "1000/minute" - return "10/minute" - - -def dynamic_limit_provider_upload(key: str): - if key == "bots": - return "500/minute" - return "2/minute" - - -limiter = Limiter(key_func=custom_key_func) -app = FastAPI() -db = Prisma() -load_dotenv() -app.state.limiter = limiter -app.add_exception_handler(RateLimitExceeded, rate_limit_exceeded_handler) - -app.add_middleware( # Disable CORS - CORSMiddleware, - allow_origins=["*"], - allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], -) - - -@app.on_event("startup") -async def startup_event(): - await db.connect() # Connecting to database - print("Connected to Data Base") - - -@app.get("/api") # root api endpoint -@limiter.limit(dynamic_limit_provider) -async def api(request: Request): - return JSONResponse( - content={ - "status": "success", - "message": "File uploader RESTful API", - "docs": "https://github.com/Andcool-Systems/File-uploader/blob/main/README.md", - }, - status_code=200, - ) - - -async def check_token(Authorization): - if not Authorization: # If token doesn't provided - return None, {"message": "No Authorization header provided", "errorId": -1} - - token_header = Authorization.split(" ") - if len(token_header) != 2: # If token have unsupported format - return None, { - "message": "Authorization header must have `Bearer ` format", - "errorId": -2, - } - - try: - token = jwt.decode( - token_header[1], "accessTokenSecret", algorithms=["HS256"] - ) # Decode token - except jwt.exceptions.DecodeError: - return None, {"message": "Invalid access token", "errorId": -4} - - token_db = await db.token.find_first( - where={"accessToken": token_header[1]}, include={"user": True} - ) # Find token in db - - if not token_db: # If not found - return None, {"message": "Token not found", "errorId": -5} - - if token["ExpiresAt"] < time.time(): # If token expired - await db.token.delete(where={"id": token_db.id}) - return None, {"message": "Access token expired", "errorId": -3} - - return token_db, {} - - -@app.get("/invite/{group_id}") # invite page handler -async def invite(group_id: str, request: Request): - async with aiofiles.open("accept_invite.html", mode="rb") as f: - return Response(await f.read(), media_type="text/html", status_code=200) - - -@app.post("/api/upload/{group_id}") # File upload handler -@limiter.limit(dynamic_limit_provider_upload) -async def upload_file( - group_id: str, - file: UploadFile, - request: Request, - include_ext: bool = False, - max_uses: int = 0, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - if not file: # Check, if the file is uploaded - return JSONResponse( - content={"status": "error", "message": "No file uploaded"}, status_code=400 - ) - - if file.size > 100 * 1024 * 1024: # 100MB limit - return JSONResponse( - content={ - "status": "error", - "message": "File size exceeds the limit (100MB)", - }, - status_code=413, - ) - - if max_uses > 10000: - return JSONResponse( - content={"status": "error", "message": "Invalid max_uses parameter"}, - status_code=400, - ) - - saved_to_account = False - user_id = -1 - - token_db, auth_error = await check_token(Authorization) # Check token - if token_db: # If token is okay - saved_to_account = True - user_id = token_db.user.id - - if group_id != "private": - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - if not group_id.isnumeric(): - return JSONResponse( - content={"status": "error", "message": "Invalid group id"}, - status_code=400, - ) - - group = await db.group.find_first( - where={"group_id": group_id}, include={"members": True} - ) - if not group: - return JSONResponse( - content={"status": "error", "message": "Group not found"}, - status_code=404, - ) - if token_db.user not in group.members: - return JSONResponse( - content={"status": "error", "message": "You are not in the group"}, - status_code=403, - ) - else: - group_id = -1 - - key = str(uuid.uuid4()) # Generate unique delete key - ext = ("." + file.filename.split(".")[-1].lower()) if file.filename.find(".") != -1 else "" # Get file extension - fid = utils.generate_token(10) + (ext if include_ext else "") # Generate file url - fn = str(uuid.uuid4()) + ext # Generate file name - - async with aiofiles.open(f"uploads/{fn}", "wb") as f: # Save file locally - await f.write(file.file.read()) - - now = datetime.now() - created = await db.file.create( - { # Creating a file record - "user_id": user_id, - "group_id": int(group_id), - "created_date": f"{now.day}.{now.month}.{now.year} {now.hour}:{now.minute}:{now.second}", - "url": fid, - "filename": f"uploads/{fn}", - "craeted_at": time.time(), - "last_watched": time.time(), - "key": key, - "type": ( - filetypes.get(ext[1:], default) if ext and ext.lower()[1:] in filetypes else "download" - ), - "ext": ext, - "size": file.size, - "user_filename": file.filename, - "max_uses": max_uses, - } - ) - - user_filename = created.user_filename[:50] + ( - "..." if len(created.user_filename) > 50 else "" - ) - return JSONResponse( - content={ - "status": "success", - "message": "File uploaded successfully", - "file_url": created.url, - "file_url_full": "https://fu.andcool.ru/file/" + created.url, - "key": created.key, - "ext": created.ext, - "size": utils.calculate_size(file.size), - "user_filename": user_filename, - "username": None if not token_db and group_id != "private" else token_db.user.username, - "craeted_at": created.craeted_at, - "synced": saved_to_account, - "auth_error": auth_error, - }, - status_code=200, - ) - - -@app.get("/file/{url}") # Get file handler -@app.get("/f/{url}") -@limiter.limit(dynamic_limit_provider) -async def send_file(url: str, request: Request): - result = await db.file.find_first(where={"url": url}) # Get file by url - if not result: - async with aiofiles.open("404.html", mode="rb") as f: - return Response( - await f.read(), media_type="text/html", status_code=404 - ) # if file does'n exists - - print(request.headers.get("CF-IPCountry")) - - if "sec-fetch-dest" in request.headers: - if request.headers.get("sec-fetch-dest") == "document": - result = await db.file.update( - where={"id": result.id}, - data={ - "last_watched": time.time(), - "uses_number": result.uses_number + 1, - }, - ) # Update last watched record - else: - result = await db.file.update( - where={"id": result.id}, - data={"last_watched": time.time(), "uses_number": result.uses_number + 1}, - ) - - if result.max_uses < result.uses_number and result.max_uses != 0: - await delete_file(result.url, result.key) - return JSONResponse(content="File not found!", status_code=404) - - if result.type != "download": # If File extension recognized - async with aiofiles.open(result.filename, mode="rb") as f: - return Response( - await f.read(), media_type=result.type - ) # Send file with "Content-type" header - else: # If file extension doesn't recognized - return FileResponse( - path=result.filename, filename=result.user_filename, media_type=result.type - ) # Send file as FileResponse - - -@app.get("/api/delete/{url}") # File delete handler -async def delete_file(url: str, key: str = ""): - result = await db.file.find_first(where={"url": url}) # Get file record by url - if not result: - return JSONResponse( - content={"status": "error", "message": "File not found"}, status_code=200 - ) # if file does'n exists - - if result.key == key: # If provided key matched with key from database record - os.remove(result.filename) # Delete file - await db.file.delete( - where={"id": result.id} - ) # Delete file record from database - - async with aiohttp.ClientSession( - "https://api.cloudflare.com" - ) as session: # Clear file cache from CloudFlare - async with session.post( - f"/client/v4/zones/{os.getenv('ZONE_ID')}/purge_cache", - json={"files": ["https://fu.andcool.ru/file/" + result.url]}, - headers={"Authorization": "Bearer " + os.getenv("KEY")}, - ): - pass - - return JSONResponse( - content={"status": "success", "message": "deleted"}, status_code=200 - ) - else: # If provided key doesn't matched with key from database record - return JSONResponse( - content={"status": "error", "message": "invalid unique key"}, - status_code=400, - ) - - -@app.get("/api/getFiles/{group_id}") # get files handler -@app.get("/api/get_files/{group_id}") # get files handler -@limiter.limit(dynamic_limit_provider) -async def getFiles( - group_id: str, - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - user = await db.user.find_first( - where={"id": token_db.user_id} - ) # Get user files from db - - if group_id == "private": - files = await db.file.find_many( - where={"user_id": user.id, "group_id": -1} - ) # Get all user files from db - else: - if not group_id.isnumeric(): - return JSONResponse( - content={"status": "error", "message": "Invalid group id"}, - status_code=400, - ) - - group = await db.group.find_first( - where={"group_id": group_id}, include={"members": True} - ) - if not group: - return JSONResponse( - content={"status": "error", "message": "Group not found"}, - status_code=404, - ) - if user not in group.members: - return JSONResponse( - {"status": "error", "message": "You are not in the group"}, - status_code=400, - ) - - files = await db.file.find_many(where={"group_id": group_id}) - - files_response = [] - for file in files: - user_filename = file.user_filename[:50] + ( - "..." if len(file.user_filename) > 50 else "" - ) - usr = (await db.user.find_first(where={"id": file.user_id})).username if group_id != "private" else None - files_response.append( - { - "file_url": file.url, - "file_url_full": "https://fu.andcool.ru/file/" + file.url, - "key": file.key, - "ext": file.ext, - "user_filename": user_filename, - "creation_date": file.created_date, - "craeted_at": file.craeted_at, - "size": utils.calculate_size(file.size), - "username": usr, - "synced": True, - } - ) - return JSONResponse( - content={ - "status": "success", - "message": "messages got successfully", - "username": user.username, - "is_group_owner": ( - None if group_id == "private" else group.admin_id == token_db.user_id - ), - "data": files_response, - }, - status_code=200, - ) - - -@app.post("/api/register") # Registartion handler -@limiter.limit(dynamic_limit_provider) -async def register(request: Request, bot: bool = False): - body = await request.json() - if ( - "username" not in body or "password" not in body - ): # If request body doesn't have username and password field - return JSONResponse( - { - "status": "error", - "message": "No username/password provided", - "errorId": 2, - }, - status_code=400, - ) - - user = await db.user.find_first( - where={"username": body["username"]} - ) # Find same username in db - - if user: # If iser already exists - return JSONResponse( - { - "status": "error", - "message": "An account with this name is already registered", - "errorId": 1, - }, - status_code=400, - ) - - salt = bcrypt.gensalt() # Encrypt password - hashed = bcrypt.hashpw(bytes(str(body["password"]), "utf-8"), salt) - - user = await db.user.create( # Create user record in db - {"username": str(body["username"]), "password": str(hashed.decode("utf-8"))} - ) - access = jwt.encode( - { - "user_id": int(user.id), - "ExpiresAt": time.time() + (accesLifeTime if not bot else accesLifeTimeBot), - }, - "accessTokenSecret", - algorithm="HS256", - ) # Generate token - - await db.token.create( - { # Create token record in db - "accessToken": access, - "user": { - "connect": { - "id": user.id, - }, - }, - } - ) - return JSONResponse( - { - "status": "success", - "accessToken": access, - "username": body["username"], - "message": "registred", - }, - status_code=200, - ) - - -@app.post("/api/login") # login handler -@limiter.limit(dynamic_limit_provider) -async def login(request: Request, bot: bool = False): - body = await request.json() - if ( - "username" not in body or "password" not in body - ): # If request body doesn't have username and password field - return JSONResponse( - { - "status": "error", - "message": "No username/password provided", - "errorId": 2, - }, - status_code=400, - ) - - user = await db.user.find_first( - where={"username": body["username"]}, include={"tokens": True} - ) # Find same username in db - if not user: # If user doesn't exists - return JSONResponse( - {"status": "error", "message": "User not found", "errorId": 4}, - status_code=404, - ) - - if bcrypt.checkpw( - bytes(body["password"], "utf-8"), bytes(user.password, "utf-8") - ): # If password is correct - access = jwt.encode( - { - "user_id": int(user.id), - "ExpiresAt": time.time() - + (accesLifeTime if not bot else accesLifeTimeBot), - }, - "accessTokenSecret", - algorithm="HS256", - ) - if len(user.tokens) > 10: # If user have more than 10 tokens - await db.token.delete_many(where={"user_id": user.id}) - - await db.token.create( - { # Create token record in db - "accessToken": access, - "user": { - "connect": { - "id": user.id, - } - }, - } - ) - - return { - "status": "success", - "accessToken": access, - "username": user.username, - "message": "logged in with password", - } - else: # If password doesn't match - return JSONResponse( - {"status": "error", "message": "Wrong password", "errorId": 3}, - status_code=400, - ) - - -@app.post("/api/refresh_token") # refresh token handler -@limiter.limit(dynamic_limit_provider) -async def refresh_token(request: Request): - body = await request.json() - if "accessToken" not in body: # If token doesn't provided - return JSONResponse( - {"status": "error", "message": "No access token provided", "errorId": 5}, - status_code=400, - ) - - token_db, auth_error = await check_token( - body["accessToken"] - ) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - access = jwt.encode( - {"user_id": int(token_db.user_id), "ExpiresAt": time.time() + accesLifeTime}, - "accessTokenSecret", - algorithm="HS256", - ) # Generate new token - await db.token.update( - where={"id": token_db.id}, data={"accessToken": access} # Replace old token - ) - - return {"status": "success", "accessToken": access, "message": "token refreshed"} - - -@app.post("/api/logout") # logout handler -@limiter.limit(dynamic_limit_provider) -async def logout( - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - await db.token.delete(where={"id": token_db.id}) # Delete token record from db - - return {"status": "success", "message": "logged out"} - - -@app.post("/api/transfer") # transfer handler -@limiter.limit(dynamic_limit_provider) -async def transfer( - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - try: - body = await request.json() - except: - return JSONResponse( - content={"status": "error", "message": "Couldn't parse request body"}, - status_code=400, - ) - - if "data" not in body: - return JSONResponse( - content={"status": "error", "message": "No `data` field in request body"}, - status_code=400, - ) - - non_success = [] - for requested_file in body["data"]: - try: - file = await db.file.find_first(where={"url": requested_file["file_url"]}) - if not file or file.key != requested_file["key"]: - non_success.append(requested_file) - continue - - await db.file.update( - where={"id": file.id}, data={"user_id": token_db.user_id} - ) - except: - non_success.append(requested_file) - - return {"status": "success", "message": "transfered", "unsuccess": non_success} - - -# --------------------------------------Groups------------------------------------------ - - -@app.post("/api/create_group") # create group handler -@limiter.limit(dynamic_limit_provider) -async def create_group( - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - body = await request.json() - if "group_name" not in body: # If token doesn't provided - return JSONResponse( - {"status": "error", "message": "No `group_name` provided"}, status_code=400 - ) - - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - if len(body["group_name"]) > 50: - return JSONResponse( - content={ - "status": "error", - "message": "Group name length exceeded (50 chars)", - }, - status_code=400, - ) - group = await db.group.create( - data={ - "name": body["group_name"], - "group_id": random.randint(10000000, 99999999), - "admin_id": token_db.user_id, - "members": { - "connect": {"id": token_db.user_id}, - }, - } - ) - return { - "status": "success", - "message": "created", - "name": group.name, - "group_id": group.group_id, - } - - -@app.delete("/api/delete_group/{group_id}") # delete group handler -@limiter.limit(dynamic_limit_provider) -async def delete_group( - group_id: int, - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - group = await db.group.find_first(where={"group_id": group_id}) - if not group: - return JSONResponse( - {"status": "error", "message": "Group not found"}, status_code=404 - ) - - if group.admin_id != token_db.user_id: - return JSONResponse( - { - "status": "error", - "message": "You dont have any permissions to delete this group", - }, - status_code=403, - ) - - await db.group.delete(where={"id": group.id}) - - return {"status": "success", "message": "deleted"} - - -@app.get("/api/generate_invite/{group_id}") # generate invite handler -@limiter.limit(dynamic_limit_provider) -async def generate_invite( - group_id: int, - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - group = await db.group.find_first(where={"group_id": group_id}) - if not group: - return JSONResponse( - {"status": "error", "message": "Group not found"}, status_code=404 - ) - - if group.admin_id != token_db.user_id: - return JSONResponse( - { - "status": "error", - "message": "You dont have any permissions", - }, - status_code=403, - ) - - invite = await db.invitements.create( - data={"data": utils.generate_token(15), "group": {"connect": {"id": group.id}}} - ) - - return { - "status": "success", - "message": "created", - "invite_link": f"https://fu.andcool.ru/invite/{invite.data}", - } - - -@app.post("/api/join/{invite_link}") # join handler -@limiter.limit(dynamic_limit_provider) -async def delete_group( - invite_link: str, - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - invite = await db.invitements.find_first( - where={"data": invite_link}, include={"group": True} - ) - if not invite: - return JSONResponse( - {"status": "error", "message": "Invite link not found"}, status_code=404 - ) - - group = await db.group.find_first( - where={"id": invite.group_id}, include={"members": True} - ) - if token_db.user in group.members: - return JSONResponse( - {"status": "error", "message": "You are already in the group"}, - status_code=400, - ) - - await db.group.update( - data={ - "members": { - "connect": {"id": token_db.user_id}, - } - }, - where={"id": group.id}, - ) - - await db.invitements.delete(where={"id": invite.id}) - - return { - "status": "success", - "message": "Joined", - "name": group.name, - "group_id": group.group_id, - } - - -@app.get("/api/invite_info/{invite_link}") # invite info handler -@limiter.limit(dynamic_limit_provider) -async def delete_group( - invite_link: str, - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - invite = await db.invitements.find_first( - where={"data": invite_link}, include={"group": True} - ) - if not invite: - return JSONResponse( - {"status": "error", "message": "Invite link not found"}, status_code=404 - ) - - return { - "status": "success", - "message": "Info got successfully", - "name": invite.group.name, - "group_id": invite.group.group_id, - } - - -@app.post("/api/leave/{group_id}") # leave handler -@limiter.limit(dynamic_limit_provider) -async def delete_group( - group_id: int, - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - group = await db.group.find_first( - where={"group_id": group_id}, include={"members": True} - ) - if not group: - return JSONResponse( - {"status": "error", "message": "Group not found"}, status_code=404 - ) - - if token_db.user not in group.members: - return JSONResponse( - {"status": "error", "message": "You are not in the group"}, status_code=400 - ) - - await db.group.update( - data={"members": {"disconnect": {"id": token_db.user_id}}}, - where={"id": group.id}, - ) - - return {"status": "success", "message": "leaved"} - - -@app.get("/api/get_groups") # get groups handler -@limiter.limit(dynamic_limit_provider) -async def get_groups( - request: Request, - Authorization: Annotated[ - Union[str, None], Header(convert_underscores=False) - ] = None, -): - - token_db, auth_error = await check_token(Authorization) # Check token validity - if not token_db: # If token is not valid - return JSONResponse( - content={ - "status": "error", - "message": "Auth error", - "auth_error": auth_error, - }, - status_code=401, - ) - - user = await db.user.find_first( - where={"id": token_db.user_id}, include={"groups": True} - ) - groups = [] - for group in user.groups: - groups.append( - { - "name": group.name, - "group_id": group.group_id, - } - ) - return {"status": "success", "message": "groups got successfully", "groups": groups} - - -if __name__ == "__main__": # Start program - uvicorn.run("main:app", reload=True, port=8080) diff --git a/schema.prisma b/schema.prisma deleted file mode 100644 index 9a22ff1..0000000 --- a/schema.prisma +++ /dev/null @@ -1,62 +0,0 @@ -datasource db { - // could be postgresql or mysql - provider = "sqlite" - url = "file:dataBase.db" -} - -generator db { - provider = "prisma-client-py" - interface = "asyncio" - recursive_type_depth = 5 -} - -model file { - id Int @id @default(autoincrement()) - user_id Int @default(-1) - group_id BigInt @default(-1) - created_date String @default("") - url String @default("") - filename String @default("") - craeted_at Float @default(0) - last_watched Float @default(0) - key String @default("") - type String @default("") - ext String @default("") - size Int @default(0) - user_filename String @default("") - uses_number Int @default(0) - max_uses Int @default(0) -} - -model User { - id Int @id @default(autoincrement()) - username String @default("") - password String @default("") - tokens Token[] - groups Group[] -} - -model Token{ - id Int @id @default(autoincrement()) - accessToken String @default("") - user User @relation(fields: [user_id], references: [id]) - user_id Int @default(0) -} - -model Group{ - id Int @id @default(autoincrement()) - name String @default("") - group_id BigInt @default(0) - admin_id Int @default(0) - members User[] - invitements Invitements[] -} - -model Invitements{ - id Int @id @default(autoincrement()) - data String @default("") - group Group @relation(fields: [group_id], references: [id]) - group_id Int @default(0) -} - - diff --git a/utils.py b/utils.py deleted file mode 100644 index 1ea0942..0000000 --- a/utils.py +++ /dev/null @@ -1,18 +0,0 @@ -import random - - -def generate_token(length): - base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789-+=" - return "".join([random.choice(base) for x in range(length)]) - - -def calculate_size(size: int): - units = ["B", "KB", "MB", "GB", "TB"] - unit_iteration = 0 - calculated_size = size - - while calculated_size >= 1024: - calculated_size /= 1024 - unit_iteration += 1 - - return f"{round(calculated_size, 2)}{units[unit_iteration]}" diff --git a/web/favicon.ico b/web/favicon.ico deleted file mode 100644 index 923cf25..0000000 Binary files a/web/favicon.ico and /dev/null differ diff --git a/web/index.html b/web/index.html deleted file mode 100644 index e7b86a6..0000000 --- a/web/index.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - File uploader - - - - - - - - - - - - - - -
-
- - -
-

File uploader

- -
-

by AndcoolSystems

-

- A simple file uploader based on Python FastAPI.
- Insert files to start uploading. Maximum file size: 100MB

- -

To access your files from any device, sign in. - The files will be linked to your account and you will have full access to them.

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

- -
-
- - \ No newline at end of file diff --git a/web/login/index.html b/web/login/index.html deleted file mode 100644 index e7fc368..0000000 --- a/web/login/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - File uploader - - - - - - - - - -
-

File uploader

- -
-

by AndcoolSystems

-

To access your files from any device, sign in. - The files will be linked to your account and you will have full access to them.

-
-

Login

- - -

- - -
- - -
- - \ No newline at end of file diff --git a/web/login/script.js b/web/login/script.js deleted file mode 100644 index e699288..0000000 --- a/web/login/script.js +++ /dev/null @@ -1,73 +0,0 @@ -//let api = "http://127.0.0.1:8080"; -let api = "https://fu.andcool.ru"; - -function moveToPage(page_url){ - const protocol = window.location.protocol; - const host = window.location.host; - window.location.replace(protocol + "//" + host + page_url); -} - -function parseJwt (token) { - var base64Url = token.split('.')[1]; - var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); - var jsonPayload = decodeURIComponent(window.atob(base64).split('').map(function(c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); - }).join('')); - - return JSON.parse(jsonPayload); -} - -function checkAccess(token) { - var secondsSinceEpoch = Date.now() / 1000 - res = parseJwt(token); - - return (parseInt(res["ExpiresAt"]) - 259200) > secondsSinceEpoch; -} - -async function register(){ - let username = document.getElementById('reg_username').value; - let pass = document.getElementById('reg_pass').value; - let error_mess = document.getElementById('reg_error'); - - if (username && pass){ - try{ - let response = await axios.post(api + "/api/register", - {'username': username, "password": pass}, {}) - - if (!response){ return; } - if (response.status == 200){ - console.log(response.data); - localStorage.setItem("accessToken", response.data.accessToken); - setTimeout(moveToPage("/"), 1000); - } - - }catch(err){ - console.log(err.response.data); - error_mess.textContent = err.response.data.message; - } - } -} - -async function login(){ - let username = document.getElementById('log_username').value; - let pass = document.getElementById('log_pass').value; - let error_mess = document.getElementById('log_error'); - - if (username && pass){ - try{ - let response = await axios.post(api + "/api/login", - {'username': username, "password": pass}, {}) - - if (!response){ return; } - if (response.status == 200){ - console.log(response.data); - localStorage.setItem("accessToken", response.data.accessToken); - setTimeout(moveToPage("/"), 1000); - } - - }catch(err){ - console.log(err.response.data); - error_mess.textContent = err.response.data.message; - } - } -} \ No newline at end of file diff --git a/web/login/style.css b/web/login/style.css deleted file mode 100644 index ffb31b3..0000000 --- a/web/login/style.css +++ /dev/null @@ -1,99 +0,0 @@ -body{ - font-family: 'Roboto Mono', monospace; - display: flex; - justify-content: center; - background-color: #222222; - color: #eeeeee; -} - -main{ - width: 70%; - text-align: left; -} - -h1{ - font-family: 'Roboto Mono', monospace; - font-weight: 400; -} -h3{margin-top: 2%;} - -hr{ - border: 1px solid rgb(105, 105, 105); -} -p{margin-left: 2px;} - -input{ - background-color: rgb(105, 105, 105); - border: none; - color: white; - margin-bottom: 1%; - padding: 0.7%; - border-radius: 5px; - font-family: 'Roboto Mono', monospace; -} - -input::placeholder { - color: rgb(201, 200, 200); - } -.log_div{ - display: flex; - flex-direction: column; - align-items: center; - flex-wrap: nowrap; -} - -.error{ - margin: 0; - margin-bottom: 1%; - color:red; - font-family: 'Roboto Mono', monospace; -} - -.reg_btn{ - color:#eeeeee; - background-color: rgb(105, 105, 105); - border: none; - padding: 7px; - border-radius: 5px; - font-size: 100%; - cursor: pointer; - font-family: 'Roboto Mono', monospace; -} -.reg_btn:hover{ - background-color: rgb(78, 78, 78); -} - -.change_page{ - background: none; - color:#eeeeee; - border: none; - cursor: pointer; - margin-top: 3px; - font-family: 'Roboto Mono', monospace; -} - -.change_page:hover{ - color:#b9b9b9; -} - -nav a{ - cursor: pointer; - color: white; - text-decoration: none; -} -nav a:hover{ - font-weight: 600; - text-decoration: underline dashed; -} -.selected{font-weight: 600;} -@media(max-width: 425px){ - main{width: 90%;} - h1{font-size: 130%;} - p{font-size: 90%;} - input{padding: 2%;} - .reg_btn{ - font-size: 95%; - padding-top: 1.5%; - padding-bottom: 1.5%; - } -} \ No newline at end of file diff --git a/web/res/external-link.png b/web/res/external-link.png deleted file mode 100644 index e9e742f..0000000 Binary files a/web/res/external-link.png and /dev/null differ diff --git a/web/res/external-link.svg b/web/res/external-link.svg deleted file mode 100644 index 45f4011..0000000 --- a/web/res/external-link.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/web/res/globe_off.png b/web/res/globe_off.png deleted file mode 100644 index 9040ae1..0000000 Binary files a/web/res/globe_off.png and /dev/null differ diff --git a/web/res/globe_on.png b/web/res/globe_on.png deleted file mode 100644 index 50e9241..0000000 Binary files a/web/res/globe_on.png and /dev/null differ diff --git a/web/res/user_plus.svg b/web/res/user_plus.svg deleted file mode 100644 index d4be380..0000000 --- a/web/res/user_plus.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/web/script.js b/web/script.js deleted file mode 100644 index 69d1fad..0000000 --- a/web/script.js +++ /dev/null @@ -1,574 +0,0 @@ -let api_upload_url = "/api/upload"; -let api_file_url = "/file/"; -let api_url = "https://fu.andcool.ru"; -//let api_url = "http://127.0.0.1:8080"; - -async function delete_file(data, id) { - let confirmed = confirm("Delete it? It will be impossible to restore the file!"); - if (confirmed) { - let response = await axios.get(api + "/api/delete/" + data.file_url + "?key=" + data.key); - if (response.status == 200) { - if (!data.synced) { - let old_data = JSON.parse(localStorage.getItem("file_history") || "[]"); - old_data.splice(id, 1); - localStorage.setItem("file_history", JSON.stringify(old_data)); - } - document.getElementById("row_" + id).remove(); - } - } -} - - -function append_to_files_arr(data, id) { - let table = document.getElementById('files_table'); - - // Insert a row at the start of table - let newRow = table.insertRow(0); - newRow.id = "row_" + id; - newRow.className = "tr"; - - // Insert a cell at the end of the row - let newCell = newRow.insertCell(); - let newCell2 = newRow.insertCell(); - // Append a text node to the cell - let url = document.createElement("p"); - url.innerHTML = data['file_url_full']; - url.id = "url"; - url.onclick = function () { navigator.clipboard.writeText(data['file_url_full']); } - - let filename = document.createElement("p"); - filename.innerHTML = data['user_filename']; - filename.id = "filename"; - - let creation_date_div = document.createElement("div"); - creation_date_div.id = "creation_date_div"; - - let cr_time = document.createElement("p"); - cr_time.innerHTML = data['creation_date'] + " " + (!data['size'] || data['size'] == "0B" ? "" : data['size']); - cr_time.id = "cr_time"; - - const button = document.createElement('button'); - button.innerHTML = 'Delete'; - button.className = "button" - button.onclick = function () { delete_file(data, id); } - - let online = document.createElement("img"); - online.className = "online"; - if (data.synced) { - online.src = "./res/globe_on.png"; - online.title = "Synchronized with the server"; - } else { - online.src = "./res/globe_off.png"; - online.title = "Stored on local browser"; - } - - let a_btn = document.createElement("a"); - a_btn.href = data['file_url_full']; - a_btn.className = "href_btn"; - a_btn.target = "_blank"; - a_btn.title = "Open in new tab"; - - let href_img = document.createElement("img"); - href_img.src = "./res/external-link.svg"; - href_img.id = "external"; - a_btn.appendChild(href_img); - - let username = document.createElement("p"); - username.innerHTML = data['username'] ? data['username'] + "'s file" : ""; - username.id = "username"; - - let urls_div = document.createElement("div"); - let url_link_div = document.createElement("div"); - url_link_div.className = "url_link_div"; - url_link_div.appendChild(a_btn); - url_link_div.appendChild(url); - - urls_div.appendChild(url_link_div); - urls_div.appendChild(filename); - - creation_date_div.appendChild(cr_time); - creation_date_div.appendChild(online); - urls_div.appendChild(creation_date_div); - if (data["username"]) urls_div.appendChild(username); - - newCell.appendChild(urls_div); - newCell2.appendChild(button); -} - - -async function get_new_tokens(accessToken) { - try { - let response = await axios.post(api_url + "/api/refresh_token", { 'accessToken': "Bearer " + accessToken }, {}) - if (!response) return false; - if (response.status != 200) return false; - return response.data.accessToken; - } catch { - return false; - } -} - -async function create_group() { - accessToken = localStorage.getItem("accessToken"); - if (!accessToken) return []; - if (!checkAccess(accessToken)) { - let new_access = await get_new_tokens(accessToken); - if (!new_access) { - localStorage.removeItem("accessToken"); - return []; - } - accessToken = new_access; - localStorage.setItem("accessToken", new_access); - } - try { - let name = document.getElementById('group_name').value; - if(name.length > 0 && name.length < 50){ - let response = await axios.post(api_url + "/api/create_group", { 'group_name': name }, { - headers: { - 'Authorization': 'Bearer ' + accessToken - } - }) - if (!response) return; - if (response.status == 200) { - let groups = document.getElementById('groups'); - groups.value = response.data.group_id; - localStorage.setItem('prev_group', response.data.group_id); - location.reload(); - }else{ - alert(response.data.message); - } - } - - - } catch (e) { - if (e.response && e.response.status == 401) { - localStorage.removeItem("accessToken"); - return []; - } - return []; - } -} - -async function create_invite() { - accessToken = localStorage.getItem("accessToken"); - if (!accessToken) return []; - if (!checkAccess(accessToken)) { - let new_access = await get_new_tokens(accessToken); - if (!new_access) { - localStorage.removeItem("accessToken"); - return []; - } - accessToken = new_access; - localStorage.setItem("accessToken", new_access); - } - try { - let gr_id = document.getElementById('groups').value; - let response = await axios.get(api_url + "/api/generate_invite/" + gr_id, { - headers: { - 'Authorization': 'Bearer ' + accessToken - } - }) - if (!response) return; - if (response.status == 200) { - let invite_link = document.getElementById('invite_link'); - invite_link.innerHTML = response.data.invite_link; - invite_link.onclick = () => {navigator.clipboard.writeText(response.data.invite_link)} - document.getElementById('invite_link_link').style.display = "block"; - }else{ - alert(response.data.message); - } - - - - } catch (e) { - if (e.response && e.response.status == 401) { - localStorage.removeItem("accessToken"); - return []; - } - return []; - } -} - - -async function delete_group() { - accessToken = localStorage.getItem("accessToken"); - if (!accessToken) return []; - if (!checkAccess(accessToken)) { - let new_access = await get_new_tokens(accessToken); - if (!new_access) { - localStorage.removeItem("accessToken"); - return []; - } - accessToken = new_access; - localStorage.setItem("accessToken", new_access); - } - try { - let gr_id = document.getElementById('groups').value; - if(confirm("Delete group? All files would be unlinked from the group! (Not deleted)")){ - let response = await axios.delete(api_url + "/api/delete_group/" + gr_id, { - headers: { - 'Authorization': 'Bearer ' + accessToken - } - }) - if (!response) return; - if (response.status == 200) { - localStorage.setItem('prev_group', "private"); - location.reload(); - }else{ - alert(response.data.message); - } - } - - - } catch (e) { - if (e.response && e.response.status == 401) { - localStorage.removeItem("accessToken"); - return []; - } - return []; - } -} - -async function leave_group() { - accessToken = localStorage.getItem("accessToken"); - if (!accessToken) return []; - if (!checkAccess(accessToken)) { - let new_access = await get_new_tokens(accessToken); - if (!new_access) { - localStorage.removeItem("accessToken"); - return []; - } - accessToken = new_access; - localStorage.setItem("accessToken", new_access); - } - try { - let gr_id = document.getElementById('groups').value; - if(confirm("Leave group?")){ - let response = await axios.post(api_url + "/api/leave/" + gr_id, {}, { - headers: { - 'Authorization': 'Bearer ' + accessToken - } - }) - if (!response) return; - if (response.status == 200) { - localStorage.setItem('prev_group', "private"); - location.reload(); - }else{ - alert(response.data.message); - } - } - - - } catch (e) { - if (e.response && e.response.status == 401) { - localStorage.removeItem("accessToken"); - return []; - } - return []; - } -} - - -async function transfer_func() { - accessToken = localStorage.getItem("accessToken"); - if (!accessToken) return []; - if (!checkAccess(accessToken)) { - let new_access = await get_new_tokens(accessToken); - if (!new_access) { - localStorage.removeItem("accessToken"); - return []; - } - accessToken = new_access; - localStorage.setItem("accessToken", new_access); - } - try { - let response = await axios.post(api_url + "/api/transfer", { 'data': JSON.parse(localStorage.getItem("file_history") || "[]") }, { - headers: { - 'Authorization': 'Bearer ' + accessToken - } - }) - if (!response) return; - if (response.status == 200) { - localStorage.setItem("file_history", JSON.stringify(response.data.unsuccess)); - location.reload(); - } - - - } catch (e) { - if (e.response && e.response.status == 401) { - localStorage.removeItem("accessToken"); - return []; - } - return []; - } -} - -async function fetch_groups() { - let accessToken = localStorage.getItem("accessToken"); - if (!accessToken) return []; - if (!checkAccess(accessToken)) { - let new_access = await get_new_tokens(accessToken); - if (!new_access) { - localStorage.removeItem("accessToken"); - return []; - } - accessToken = new_access; - localStorage.setItem("accessToken", new_access); - } - try { - let response = await axios.get(api_url + "/api/get_groups", { - headers: { - 'Authorization': 'Bearer ' + accessToken - } - }) - if (!response) return; - - document.getElementById('groups_selector').style.display = "block"; - let prev_group = localStorage.getItem("prev_group"); - let groups = document.getElementById('groups'); - let value_finded = false; - for (const group of response.data.groups) { - let groupel = document.createElement("option"); - groupel.innerHTML = group.name; - groupel.value = group.group_id; - groups.appendChild(groupel); - if (group.group_id == prev_group){ - groups.value = prev_group; - value_finded = true; - } - } - if (!value_finded) localStorage.removeItem("prev_group"); - fetch_files(localStorage.getItem("accessToken")); - - } catch (e) { - if (e.response && e.response.status == 401) { - localStorage.removeItem("accessToken"); - return []; - } - return []; - } -} - -async function fetch_files(accessToken) { - if (!accessToken) return []; - if (!checkAccess(accessToken)) { - let new_access = await get_new_tokens(accessToken); - if (!new_access) { - localStorage.removeItem("accessToken"); - return []; - } - accessToken = new_access; - localStorage.setItem("accessToken", new_access); - } - let group = document.getElementById('groups').value; - try { - let response = await axios.get(api_url + "/api/get_files/" + group, { - headers: { - 'Authorization': 'Bearer ' + accessToken - } - }) - if (!response) return; - - let logim_page_btn = document.getElementById('login_page_a'); - logim_page_btn.textContent = "Logout"; - logim_page_btn.href = "/"; - logim_page_btn.onclick = function () { if (confirm("Log out?")) { logout() } }; - document.title = "File uploader · " + response.data.username; - - document.getElementById('login_mess').textContent = "Logged as " + response.data.username; - document.getElementById('invite_users').disabled = !response.data.is_group_owner; - document.getElementById('leave').title = response.data.is_group_owner ? "Delete group" : "Leave group"; - document.getElementById('leave').disabled = (response.data.is_group_owner == null); - document.getElementById('leave').onclick = response.data.is_group_owner ? () => {delete_group()} : () => {leave_group()} - - let len = 0; - let table = document.getElementById('files_table'); - table.innerHTML = ""; - if (group == "private") { - let file_history = JSON.parse(localStorage.getItem("file_history") || "[]"); - if (file_history != []) { - for (const file of file_history) { - append_to_files_arr(file, len); - len++; - } - } - // Insert a row at the start of table - let newRow = table.insertRow(0); - newRow.id = "transfer_row"; - // Insert a cell at the end of the row - let newCell = newRow.insertCell(); - // Append a text node to the cell - let transfer = document.createElement("button"); - transfer.id = "trensfer"; - transfer.innerHTML = "Transfer local files to an account" - transfer.onclick = function () { if (confirm("Transfer local files to an active account?")) transfer_func() } - if (len > 0) newCell.appendChild(transfer); - } - let it = 0; - for (const file of response.data.data) { - append_to_files_arr(file, len + it); - it++; - } - - } catch (e) { - console.log(e); - if (e.response && e.response.status == 401) { - localStorage.removeItem("accessToken"); - return []; - } - return []; - } -} - -async function logout() { - let accessToken = localStorage.getItem("accessToken"); - if (!accessToken) return []; - if (!checkAccess(accessToken)) { - let new_access = await get_new_tokens(accessToken); - if (!new_access) { - localStorage.removeItem("accessToken"); - return []; - } - accessToken = new_access; - localStorage.setItem("accessToken", new_access); - } - try { - let response = await axios.post(api_url + "/api/logout", {}, { - headers: { - 'Authorization': 'Bearer ' + accessToken - } - }) - if (!response) return []; - if (response.status == 401 || response.status == 200) { - localStorage.removeItem("accessToken"); - - let logim_page_btn = document.getElementById('login_page_a'); - logim_page_btn.textContent = "Login"; - logim_page_btn.href = "https://fu.andcool.ru/login/"; - } - } catch { - localStorage.removeItem("accessToken"); - return []; - } -} - -addEventListener("DOMContentLoaded", (event) => { - document.getElementById('groups').addEventListener("change", (event) => { - localStorage.setItem("prev_group", event.target.value); - document.getElementById('invite_link_link').style.display = "none"; - fetch_files(localStorage.getItem("accessToken"), - event.target.value); - }); - document.getElementById('input_file').addEventListener('change', function (e) { - let fileInput = document.getElementById('input_file'); - let load_mess = document.getElementById('load_mess'); - - let file = fileInput.files[0]; - if (file) { - let reader = new FileReader(); - - reader.onprogress = function (e) { - if (e.lengthComputable) { - let percentage = (e.loaded / e.total) * 100; - load_mess.textContent = "Uploading file... " + percentage.toFixed(1) + '%'; - } - }; - - reader.onload = function () { - console.log('File loaded successfully'); - if (file.size > 100 * 1024 * 1024) { - load_mess.textContent = "File size exceeds the limit (100MB)"; - return; - } - upload(file); - }; - - reader.readAsDataURL(file); - } - }); - let len = 0; - let file_history = JSON.parse(localStorage.getItem("file_history") || "[]"); - if (file_history != []) { - for (const file of file_history) { - append_to_files_arr(file, len); - len++; - } - } - fetch_groups(); - - let dropContainer = document.getElementById('dropContainer') - dropContainer.ondragover = dropContainer.ondragenter = function (evt) { - evt.preventDefault(); - }; - - - dropContainer.ondrop = function (evt) { - const dT = new DataTransfer(); - dT.items.add(evt.dataTransfer.files[0]); - document.getElementById('input_file').files = dT.files; - document.getElementById('input_file').dispatchEvent(new Event('change')) - evt.preventDefault(); - }; -}); - - -async function upload(file) { - - let imagefile = document.querySelector('#input_file'); - let load_mess = document.getElementById('load_mess'); - let file_ext = document.getElementById('include_ext'); - let group_id = document.getElementById('groups').value; - load_mess.textContent = "Uploading to the server..."; - - try { - let response = await axios.post(`${api_url}${api_upload_url}/${group_id}?include_ext=${file_ext.checked}`, { 'file': file }, { - headers: { - 'Content-Type': 'multipart/form-data', - 'Authorization': 'Bearer ' + localStorage.getItem("accessToken") - } - }) - - imagefile.value = ""; - if (response) { - if (response.status == 200) { - let response1 = response.data; - var currentdate = new Date(); - var datetime = currentdate.getDate() + "." - + (currentdate.getMonth() + 1) + "." - + currentdate.getFullYear() + " " - + currentdate.getHours() + ":" - + currentdate.getMinutes() + ":" - + currentdate.getSeconds(); - - - response1["creation_date"] = datetime; - load_mess.textContent = "Uploaded!"; - - - let old_data = JSON.parse(localStorage.getItem("file_history") || "[]"); - append_to_files_arr(response1, old_data.length) - - navigator.clipboard.writeText(response1['file_url_full']); - - if (!response1.synced) { - old_data.push(response1); - localStorage.setItem("file_history", JSON.stringify(old_data)); - } - } - } - } catch (err) { - console.log(err); - if(err.response){ - if(err.response.status == 429){ - load_mess.textContent = "Too many requests (2 per minute)"; - return; - }else{ - load_mess.textContent = err.response.data.message; - return - } - } - load_mess.textContent = "Error while uploading file. See console for more information."; - imagefile.value = ""; - } - -} - diff --git a/web/snowflakes.js b/web/snowflakes.js deleted file mode 100644 index 15df132..0000000 --- a/web/snowflakes.js +++ /dev/null @@ -1,95 +0,0 @@ -function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } - -let object_array = []; - -class Circle { - constructor(object) { - this.object = object; - this.cnavas_width = 200; - this.vw = window.innerWidth; - this.vh = window.innerHeight; - - this.posX = getRandomInt(0, this.vw); - this.posY = getRandomInt(-this.vw, -50); - - this.speedX = 5; - this.speedY = 1; - - this.last_time = 0; - this.last_set = 1; - this.random_time = getRandomInt(1000, 5000); - this.random_sin_mod = getRandomInt(1, 3); - this.last_scroll = document.documentElement.scrollTop || document.body.scrollTop; - } - - tick() { - let now_time = Date.now(); - - const circle = this.object; - this.posY += this.speedY; - this.posX += Math.sin(now_time / 1000) * this.random_sin_mod; - - if (this.posY > this.vh) { this.posY = getRandomInt(-this.vw, -50); } - if (this.posX > this.vw) { - this.posX = -10; - } - if (this.posX < -10) { this.posX = this.vw; } - this.posY -= (document.documentElement.scrollTop || document.body.scrollTop) - this.last_scroll; - - if (now_time - this.last_time > this.random_time) { - this.last_time = now_time; - this.random_time = getRandomInt(1000, 5000); - this.random_sin_mod = getRandomInt(1, 3); - } - - circle.style.left = this.posX + 'px'; - circle.style.top = this.posY + 'px'; - this.last_scroll = document.documentElement.scrollTop || document.body.scrollTop; - - } -} -function run_anim() { - let table = document.getElementById('canvas'); - let vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); - let count = 30 - - const date = new Date(); - let day = date.getDate(); - let month = date.getMonth() + 1; - if (!((month == 12 && day > 20) || (month == 1 && day < 5)) || vw < 900) return; - - if (localStorage.getItem("disable_snow")) return; - - let snow_btn = document.getElementById('snow_btn'); - snow_btn.style.display = "block"; - table.style.display = "block"; - - for (let x = 0; x < count; x++) { - var snowflake = document.createElement("p"); - snowflake.innerHTML = "*"; - snowflake.className = "snowflake"; - table.appendChild(snowflake); - object_array.push(new Circle(snowflake)); - - } -} -function tick() { - for (const snowflake of object_array) { - snowflake.tick(); - } -} - -setInterval(tick, 16); - - -function stop_anim() { - object_array = []; - let table = document.getElementById('canvas'); - table.innerHTML = ""; - table.style.display = "none"; -} - - -addEventListener("DOMContentLoaded", (event) => { - run_anim(); -}); \ No newline at end of file diff --git a/web/style.css b/web/style.css deleted file mode 100644 index 10c3db2..0000000 --- a/web/style.css +++ /dev/null @@ -1,362 +0,0 @@ - -body{ - font-family: 'Roboto Mono', monospace; - display: flex; - justify-content: center; - background-color: #222222; - color: #eeeeee; - overflow-x: hidden; - margin: 0; -} - -main{ - width: 70%; - text-align: left; -} - -h1{ - font-family: 'Roboto Mono', monospace; - font-weight: 400; -} - -hr{ - border: 1px solid rgb(105, 105, 105); -} -p{margin-left: 2px;} -.input-file span { - position: relative; - display: inline-block; - cursor: pointer; - outline: none; - font-size: 16px; - vertical-align: middle; - border: 2px rgb(105, 105, 105) solid; - border-radius: 15px; - padding: 10px; - font-weight: 400; - margin-left: 2px; - margin-bottom: 1%; - transition: background-color 0.2s; -} - -.input-file span:hover{ - background-color: rgb(105, 105, 105); - text-decoration: dashed; - transition: background-color 0.2s; -} - -.input-file input[type=file] { - position: absolute; - z-index: -1; - opacity: 0; - display: block; - width: 0; - height: 0; -} - -#load_mess{ - /*display: none*/ - margin: 0; - margin-bottom: 1%; -} - -#files_table{ - display: inline-block; - width: 100%; -} -#files_table tbody{width: 100%;} - - -#files_table .tr{ - display: flex; - position: relative; - outline: none; - text-decoration: none; - font-size: 16px; - vertical-align: middle; - border: 2px rgb(105, 105, 105) solid; - border-radius: 15px; - padding: 5px; - font-weight: 400; - align-items: center; - padding-right: 6px; - margin-bottom: 2%; -} - -#files_table .button{ - cursor: pointer; - background-color: #222222; - color:#eeeeee; - font-family: 'Roboto Mono', monospace; - font-weight: 400; - font-size: 80%; - border: 2px rgb(105, 105, 105) solid; - border-radius: 10px; - padding: 5px; - font-weight: 400; - margin-left: 3%; - transition: background-color 0.2s; -} - -#files_table button:hover{ - background-color: rgb(109, 109, 109); - transition: background-color 0.2s; -} - -#files_table p{ - color:#eeeeee; - font-family: 'Roboto Mono', monospace; - font-weight: 400; - margin: 0; -} - -#files_table #url{ - font-size: 95%; - cursor: pointer; - color: white; - text-decoration: none; - text-wrap: wrap; - display: block; -} - -#files_table #url:hover{ - text-decoration: underline dashed; -} - -#files_table #filename{ - font-size: 70%; - color: rgb(200, 200, 200); -} - -#files_table #cr_time{ - font-size: 70%; - color: rgb(200, 200, 200) -} - -tr { - white-space: normal; - display: flex; - justify-content: space-between; -} - -tbody{ - max-width: 90%; -} - -td div{ - max-width: 90%; -} - -#addit_sett_btn{ - cursor: pointer; - background-color: transparent; - border: none; - color: white; - font-size: 100%; - margin-bottom: 1%; - font-family: 'Roboto Mono', monospace; -} - -#addit_sett_btn:hover{text-decoration: underline dashed;} - -#addit_sett{ - display: none; - padding-left: 1%; - margin-bottom: 1%; -} - -#creation_date_div{ - display: flex; - flex-direction: row; - justify-content: flex-start; - align-items: center; -} -.online{ - display: block; - width: 15px; - height: 15px; - border-radius: 50%; - margin-left: 0.5%; -} - -nav a{ - cursor: pointer; - color: white; - text-decoration: none; -} -nav a:hover{ - font-weight: 600; - text-decoration: underline dashed; -} - -#login_mess{ - font-style: italic; -} - -.selected{font-weight: 600;} - -#dropContainer{ - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: -1; -} - -.snowflake{ - position: absolute; - font-size: 200%; - color: white; - margin: 0; - overflow: hidden; -} - -#canvas{ - overflow: hidden; - position: fixed; - width: 100%; - height: 100%; - pointer-events: none; - z-index: 100; -} - -#snow_btn{ - display: none; - position: absolute; - top: 0px; - left: 0px; - background: none; - border: none; - font-size: 300%; - color: white; - transform:rotate(0deg); - transition: transform 0.3s ease-in-out; - padding: 0; - width: 35px; - height: 35px; - vertical-align: top; -} - -#snow_btn:hover{ - cursor: pointer; - transform:rotate(-180deg); - transition: transform 0.3s ease-in-out; -} - -.url_link_div{ - display: flex; - align-items: center; - flex-direction: row; - text-overflow: ellipsis; -} - -.href_btn{ - display: flex; - align-items: center; - justify-content: center; - margin-right: 1%; -} - -#transfer_row{ - border: none; -} - -#trensfer{ - margin-bottom: 3%; - margin-left: 0; - cursor: pointer; - background-color: #222222; - color:#eeeeee; - font-family: 'Roboto Mono', monospace; - font-weight: 400; - font-size: 80%; - border: 2px rgb(105, 105, 105) solid; - border-radius: 10px; - padding: 5px; - font-weight: 400; - transition: background-color 0.2s; -} - -#groups{ - background-color: #222222; - color: white; - border: 2px rgb(105, 105, 105) solid; - border-radius: 10px; - padding: 5px; - max-width: 100%; -} - -.group_btn{ - background-color: #222222; - color: #eeeeee; - border: 2px rgb(105, 105, 105) solid; - border-radius: 10px; - width: 31px; - height: 31px; - font-family: 'Roboto Mono', monospace; - font-weight: 600; - font-size: 0.9rem; - padding: 0px; - margin-left: 5px; - transition: background-color 0.2s; - cursor: pointer; -} - -.group_btn:hover{ - background-color: rgb(109, 109, 109); - transition: background-color 0.2s; -} - -#username{ - font-size: 70%; - color: rgb(200, 200, 200) -} - -.group_btn:disabled{ - cursor: default; - border: 2px rgb(68, 68, 68) solid; -} -.group_btn:disabled:hover{ - background-color: #222222; -} - -.button_creation_class{ - background-color: #222222; - border: 2px rgb(105, 105, 105) solid; - border-radius: 10px; - padding: 10px; - color: white; - cursor: pointer; - transition: background-color 0.2s; -} - -.button_creation_class:hover{ - background-color: rgb(109, 109, 109); - transition: background-color 0.2s; -} - -#external{ - width: 16px; - height: 16px; - -} - -@media(max-width: 425px){ - main{width: 90%;} - h1{font-size: 130%;} - p{font-size: 90%;} - .input-file span { - font-size: 90%; - padding: 7px; - border-radius: 10px; - } - #files_table .tr{padding: 2%; flex-wrap: wrap;} - #files_table p{font-size: 70%; margin: 0; word-break: break-all;} - #files_table .button{font-size: 70%; padding: 7px; margin: 0} - #files_table #url{font-size: 70%;} - #addit_sett{padding-left: 2%; margin-bottom: 3%;} - #addit_sett_btn{margin-bottom: 3%;} - .add_label{font-size: 80%;} - #files_table .tr {flex-direction: column; align-items: flex-start;} -} \ No newline at end of file diff --git a/web/tos/index.html b/web/tos/index.html deleted file mode 100644 index fd97628..0000000 --- a/web/tos/index.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - File uploader - - - - - - - - - -
-

File uploader

- -
-

by AndcoolSystems

-
-Terms of Service and Privacy Policy
-
-These Terms of Service ("Terms") govern your use of this Service, and our commitment to your privacy.
-
-Terms of Service:
-
-1. User Agreement:
-   1.1. By using the Service, you agree to the terms of the provided user agreement.
-
-2. Responsibility for Uploaded Content:
-   2.1. The Service is not responsible for the content of uploaded materials.
-   2.2. Uploaded content reflects only the author's point of view.
-
-3. Copyright:
-   3.1. Users undertake not to upload, transmit, or exchange files that violate the copyrights of third parties.
-   3.2. The Service has the right to remove any materials violating copyrights without prior notice.
-
-4. Prohibited Materials:
-   4.1. Uploading, transmitting, or exchanging files containing viruses, malware, pornography, calls for violence, or any other materials violating laws and moral standards is prohibited.
-
-5. Privacy:
-   5.1. The Service commits to maintaining the confidentiality of user data.
-   5.2. Users agree to the collection and processing of their personal data in accordance with the privacy policy.
-
-6. Responsibility:
-   6.1. The Service is not responsible for data loss resulting from the use of the Service.
-   6.2. Users are responsible for the security of their data and password for accessing the Service.
-
-7. Modification and Removal of Content:
-   7.1. The Service reserves the right to modify and remove content that violates the Terms of Service.
-
-Privacy Policy:
-
-1. Collection and Use of Information:
-   1.1. The Service collects only necessary information to provide services, such as login and password for registration.
-   1.2. Information will not be shared with third parties without the user's consent.
-
-2. Data Storage:
-   2.1. The Service ensures secure storage of user data.
-   2.2. Users have the right to request the deletion of their data from the system.
-
-3. Cookies:
-   3.1. The Service uses cookies to enhance the user experience.
-   3.2. Users can disable cookies in their browser settings.
-
-4. Security:
-   4.1. The Service takes measures to secure data transmission.
-   4.2. Users undertake not to disclose their password to third parties.
-
-5. Changes in Policy:
-   5.1. The Service reserves the right to make changes to the privacy policy.
-   5.2. Changes will be published on the Service's website.
-
-Last update: 27.01.2024
-            
-
- - \ No newline at end of file diff --git a/web/tos/style.css b/web/tos/style.css deleted file mode 100644 index e000847..0000000 --- a/web/tos/style.css +++ /dev/null @@ -1,64 +0,0 @@ - -body{ - font-family: 'Roboto Mono', monospace; - display: flex; - justify-content: center; - background-color: #222222; - color: #eeeeee; - height: 100%; - overflow-x: hidden; -} - -main{ - width: 70%; - text-align: left; -} - -h1{ - font-family: 'Roboto Mono', monospace; - font-weight: 400; -} - -hr{ - border: 1px solid rgb(105, 105, 105); -} -p{margin-left: 2px;} - - - -nav a{ - cursor: pointer; - color: white; - text-decoration: none; -} -nav a:hover{ - font-weight: 600; - text-decoration: underline dashed; -} - -#login_mess{ - font-style: italic; -} - -.selected{font-weight: 600;} - -pre{ - text-wrap: wrap; -} -#head{ - font-size: 150%; -} -#head2nd{ - font-size: 140%; -} - -b{ - font-size: 120%; -} - -@media(max-width: 425px){ - main{width: 90%;} - h1{font-size: 130%;} - p{font-size: 90%;} - -} \ No newline at end of file diff --git a/web/uploaders/File uploader.sxcu b/web/uploaders/File uploader.sxcu deleted file mode 100644 index d030048..0000000 --- a/web/uploaders/File uploader.sxcu +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Version": "15.0.0", - "Name": "File uploader", - "DestinationType": "ImageUploader, FileUploader", - "RequestMethod": "POST", - "RequestURL": "https://fu.andcool.ru/api/upload", - "Parameters": { - "include_ext": "true" - }, - "Body": "MultipartFormData", - "FileFormName": "file", - "URL": "{json:file_url_full}", - "DeletionURL": "https://fu.andcool.ru/api/delete/{json:file_url}?key={json:key}", - "ErrorMessage": "{json:message}" -} \ No newline at end of file diff --git a/web/uploaders/index.html b/web/uploaders/index.html deleted file mode 100644 index b2f82b0..0000000 --- a/web/uploaders/index.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - File uploader - - - - - - - - - - -
-

File uploader

- -
-

by AndcoolSystems

-

ShareX

-

Click here to download the ShareX config

- -
- - \ No newline at end of file diff --git a/web/uploaders/style.css b/web/uploaders/style.css deleted file mode 100644 index 5e51d23..0000000 --- a/web/uploaders/style.css +++ /dev/null @@ -1,14 +0,0 @@ -h2{ - margin-bottom: 1%; -} - -#sharex{ - margin: 0%; - margin-left: 15px; -} - -#sharex a{ - color:white; - text-decoration: underline; - -}