From: b Date: Fri, 12 May 2023 18:54:35 +0000 (+0000) Subject: Leave just the library. X-Git-Tag: v1.0.0 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=refs%2Ftags%2Fv1.0.0;p=botm%2Fcommon-perl Leave just the library. --- diff --git a/agpl.txt b/agpl.txt deleted file mode 100644 index 70eec1e..0000000 --- a/agpl.txt +++ /dev/null @@ -1,661 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 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 Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are 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. - - 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. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - 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 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 work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - 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 AGPL, see -. diff --git a/bb2html.awk b/bb2html.awk deleted file mode 100644 index b051bcc..0000000 --- a/bb2html.awk +++ /dev/null @@ -1,688 +0,0 @@ -#// bb2html.awk -#// converts bbcode to html. -#// 30.03.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="=" - debug="debug=bb2html.awk:" - automome="/eizm/pro/ong1/mome.pl" - memepath="/eizm/mem/ong1/mome.txt" - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i) - dec=sprintf("%u",i) - ch2hex[ch]=hex - ch2dec[ch]=dec - } -}; -{ - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -}; -END{ - if(argtab["disable_bbcode"]!="") - { - debug=debug"###nl;BBcode disabled" - print debug>>outfile - exit 0 - } - text=argtab["BB"] - html=bb2html(text) - print "HTML="html>>outfile - print debug>>outfile - - # if(tempfile!="") - # { - # text=argtab["message"] - # gsub(/%5Bbr%5D/,"\n",text) - # while(sub(/%5Bong%5D/,ong(),text)>0){print text} - # while(sub(/%5Bung%5D/,ung(),text)>0){print text} - # while(sub(/%5Bong%3Ddecree%5D/,ong("decree"),text)>0){print text} - # while(sub(/%5Bung%3Ddecree%5D/,ung("decree"),text)>0){print text} - # if(text!=argtab["message"]) - # print "message="text >> outfile - # } -}; - -function bb2html(text, depth,count,bbtree,html,tag,tagstart,taglength,elm,tagv,tagname,tagvalue,matchname) -{ - depth=0 - count[0]=1 - bbtree["0"]="" - bbtree["0.n"]=0 - bbtree["0.t"]="post" - bbtree["0.v"]=argtab["subject"] - html="" - gsub(/=/,"=",text) - debug = debug "###nl;###nl;Build BBcode tree:" - while(length(text)!=0) - { - tag=match(text, /\[\/?[a-z0-9\*]+(=(([^\[<>\"\]]*)|(\"[^\"<>]*\")))?\]/) - #"#\"" - # debug = debug "###nl;" RSTART " " RLENGTH - if (tag==0) - { - debug = debug "###nl;text: " text - bbtree[ind(count,depth)]=text - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - text="" - break; - } - tagstart=RSTART - taglength=RLENGTH - if(tagstart>1) - { - elm=substr(text,1,tagstart-1) - debug = debug "###nl;text: " elm - bbtree[ind(count,depth)]=elm - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - } - tag=substr(text,tagstart,taglength) - text=substr(text,tagstart+taglength) - debug = debug "###nl;tag: " tag - if(tag!~/^\[\//) - { - tagv=index(tag,"=") - if(tagv<2) - { - tagname=substr(tag,2,length(tag)-2) - tagvalue="" - } - else - { - tagname=substr(tag,2,tagv-2) - tagvalue=substr(tag,tagv+1,length(tag)-tagv-1) - } - if(tagname !~ /^((quote)|b|i|u|(code)|(img)|(url)|(size)|(color)|(center)|(right)|(sub)|(sup)|(s)|(spoiler)|(list)|(\*))$/) - { - debug = debug "###nl;unknown tag" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||bbtree[indt(count,depth)".t"] == "img"||(bbtree[indt(count,depth)".t"] == "spoiler" && tagname=="spoiler")||(bbtree[indt(count,depth)".t"] == "size" && tagname=="size")) - { - debug = debug "###nl;this tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname=="*") - { - if(bbtree[indt(count,depth)".t"]==tagname) - { - debug = debug "###nl;implied tag: [/"tagname"]" - debug = debug "###nl;matched" - bbtree[ind(count,depth)]="[/"tagname"]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - else if(bbtree[indt(count,depth)".t"]!="list") - { - debug = debug "###nl;this tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - } - debug = debug "###nl;name: " tagname " value: " tagvalue - bbtree[ind(count,depth)]=tagname" "tagvalue - bbtree[ind(count,depth)".k"]="s" - bbtree[indt(count,depth)".n"]=count[depth] - ++depth - count[depth]=1 - bbtree[indt(count,depth)]=tag - bbtree[indt(count,depth)".n"]=0 - bbtree[indt(count,depth)".t"]=tagname - bbtree[indt(count,depth)".v"]=tagvalue - } - else - { - if(depth<=0) - { - debug = debug "###nl;""unmatched" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - tagname=substr(tag,3,length(tag)-3) - if(tagname=="list"&&bbtree[indt(count,depth)".t"]=="*") - { - debug = debug "###nl;implied tag: [/*]" - debug = debug "###nl;matched" - bbtree[ind(count,depth)]="[/*]" - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]="*" - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - debug = debug "###nl;name: " tagname - matchname=bbtree[indt(count,depth)".t"] - if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||(bbtree[indt(count,depth)".t"] == "img" && tagname != "img")) - { - debug = debug "###nl;this tag forbidden here" - bbtree[ind(count,depth)]=tag - bbtree[indt(count,depth)".n"]=count[depth] - ++count[depth] - continue - } - if(tagname!=matchname) - { - debug = debug "###nl;mismatched: " matchname - # bbtree[ind(count,depth)]=tag - # bbtree[indt(count,depth)".n"]=count[depth] - # ++count[depth] - # continue - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".t"]=bbtree[indt(count,depth)".t"] - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - count[depth]="" - --depth - ++count[depth] - continue - } - debug = debug "###nl;matched" - bbtree[ind(count,depth)]=tag - bbtree[ind(count,depth)".k"]="e" - bbtree[ind(count,depth)".m"]=1 - bbtree[ind(count,depth)".t"]=tagname - bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"] - bbtree[indt(count,depth)".n"]=count[depth] - bbtree[indt(count,depth)".m"]=1 - count[depth]="" - --depth - ++count[depth] - } - } - if(depth>0) - debug = debug "###nl;unclosed tags: " depth - - debug = debug "###nl;###nl;""generate HTML:" - depth=0 - count[0]=0 - while(count[0]<=bbtree["0.n"]&&depth>=0) - { - if(count[depth]==0) - { - tag=bbtree[indt(count,depth)] - tagname=bbtree[indt(count,depth)".t"] - tagvalue=bbtree[indt(count,depth)".v"] - debug = debug "###nl;name: "tagname" value: "tagvalue" elements: "bbtree[indt(count,depth)".n"] - if(tagname == "post") - { - } - else if(bbtree[indt(count,depth)".m"]=="") - { - debug = debug "###nl;unmatched" - html = html tag - } - else if(tagname == "quote") - { - if (tagvalue=="") - { - html = html "
" - } - else - { - if(tagvalue !~ /^\".*\"$/) - #"#\"" - tagvalue="You forgot about the quote marks, "tagvalue - else - tagvalue=bb2html(substr(tagvalue,2,length(tagvalue)-2)) - html = html "
"tagvalue" wrote:
" - } - } - else if (tagname == "b") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "i") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "u") - { - html = html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html tag - debug = debug "###nl;not a tag, actually" - } - else - { - html=html"
Code: Select all
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - } - else if (tagname == "img") - html=html"" - } - else if (tagname == "size") - { - if (tagvalue==""||(tagvalue !~ /^[0-9]+$/)||(tagvalue+0)>200) - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname == "color") - { - if (tagvalue==""||tagvalue !~ /^#[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/) #for some reason /^([0-9A-F]{6})$/ doesn't work. - html=html" This tag should have a correct value. " - else - html=html"" - } - else if (tagname ~ /^((center)|(right))$/) - { - html=html"
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="s") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sub") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname =="sup") - { - html=html"" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="spoiler") - { - html=html"
Spoiler:
" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if (tagname=="list") - { - if(tagvalue=="") - html=html"
    " - else - { - if (tagvalue=="1") - tagvalue="decimal" - else if (tagvalue=="i") - tagvalue="lower-roman" - else if (tagvalue=="I") - tagvalue="upper-roman" - else if (tagvalue=="a") - tagvalue="lower-alpha" - else if (tagvalue=="A") - tagvalue="upper-alpha" - else - { - html=html"This tag should have a correct value. " - tagvalue="decimal" - } - html=html"
      " - } - } - else if (tagname=="*") - { - html=html"
    1. " - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else - { - debug = debug "###nl;unknown tag" - html = html tag - } - ++count[depth] - } - else if(bbtree[ind(count,depth)".k"]=="s") - { - debug = debug "###nl;entering tag:" - ++depth - count[depth]=0 - } - else if(bbtree[ind(count,depth)".k"]=="e") - { - debug = debug "###nl;leaving tag:" - tag=bbtree[ind(count,depth)] - tagname=bbtree[ind(count,depth)".t"] - tagvalue=bbtree[ind(count,depth)".v"] - debug = debug "###nl;name: "tagname" value: "tagvalue - if (tagname == "post") - { - } - else if(bbtree[ind(count,depth)".m"]=="") - { - debug = debug "###nl;unmatched" - html = html tag - } - else if(tagname == "quote") - html = html "
" - else if (tagname ~/^(b|i|u|(size)|(color))$/) - html = html"" - else if (tagname == "code") - { - if(bbtree[indtu(count,depth)".t"] == "code") - { - html=html tag - debug = debug "###nl;not a tag, actually" - } - else - html = html"" - } - else if (tagname == "img") - { - html = html"\" alt=\"Image\" />" - if(tagvalue!="") - html=html"This tag shouldn't have any value. " - } - else if(tagname=="url") - html=html"" - else if (tagname ~ /^((center)|(right))$/) - html=html"
" - else if (tagname =="s") - html=html"" - else if (tagname =="sub") - html=html"" - else if (tagname =="sup") - html=html"" - else if (tagname=="spoiler") - html=html"" - else if (tagname=="list") - { - if (tagvalue=="") - html=html"" - else - html=html"" - } - else if (tagname=="*") - html=html"" - else - { - debug = debug "###nl;unknown tag" - html = html tag - } - count[depth]="" - --depth - ++count[depth] - } - else if(count[depth]>bbtree[indt(count,depth)".n"]) - { - debug = debug "###nl;run out of elements in this tag; leaving" - count[depth]="" - --depth - ++count[depth] - } - else - { - tag=bbtree[ind(count,depth)] - debug = debug "###nl;text: "tag - if(bbtree[indt(count,depth)".t"] == "code") - { - # gsub(/ ?
?/,"
",tag) - gsub(/ /,"\\ ",tag) - gsub(/\t/,"\\ \\ ",tag) - } - if(argtab["disable_magic_url"]==""&& bbtree[indt(count,depth)".t"] !~ /^((code)|(img)|(url))$/) - gsub(/https?:\/\/[^\n\r\t<> ]+/,"&",tag) - if(argtab["disable_smilies"]=="" && bbtree[indt(count,depth)".t"] !~ /^((code)|(img))$/) - { - gsub(/(^|[\n\r\t ]):D($|[\n\r\t ])/," \":D\" ",tag) - gsub(/(^|[\n\r\t ]):\)($|[\n\r\t ])/," \":)\" ",tag) - gsub(/(^|[\n\r\t ]):\(($|[\n\r\t ])/," \":(\" ",tag) - gsub(/(^|[\n\r\t ]):o($|[\n\r\t ])/," \":o\" ",tag) - gsub(/(^|[\n\r\t ]):shock:($|[\n\r\t ])/," \":shock:\" ",tag) - gsub(/(^|[\n\r\t ]):\?($|[\n\r\t ])/," \":?\" ",tag) - gsub(/(^|[\n\r\t ])8-\)($|[\n\r\t ])/," \"8-)\" ",tag) - gsub(/(^|[\n\r\t ]):lol:($|[\n\r\t ])/," \":lol:\" ",tag) - gsub(/(^|[\n\r\t ]):x($|[\n\r\t ])/," \":x\" ",tag) - gsub(/(^|[\n\r\t ]):P($|[\n\r\t ])/," \":P\" ",tag) - gsub(/(^|[\n\r\t ]):oops:($|[\n\r\t ])/," \":oops:\" ",tag) - gsub(/(^|[\n\r\t ]):cry:($|[\n\r\t ])/," \":cry:\" ",tag) - gsub(/(^|[\n\r\t ]):evil:($|[\n\r\t ])/," \":evil:\" ",tag) - gsub(/(^|[\n\r\t ]):twisted:($|[\n\r\t ])/," \":twisted:\" ",tag) - gsub(/(^|[\n\r\t ]):roll:($|[\n\r\t ])/," \":roll:\" ",tag) - gsub(/(^|[\n\r\t ]):wink:($|[\n\r\t ])/," \":wink:\" ",tag) - gsub(/(^|[\n\r\t ]);\)($|[\n\r\t ])/," \":wink:\" ",tag) - gsub(/(^|[\n\r\t ]):!:($|[\n\r\t ])/," \":!:\" ",tag) - gsub(/(^|[\n\r\t ]):\?:($|[\n\r\t ])/," \":?:\" ",tag) - gsub(/(^|[\n\r\t ]):idea:($|[\n\r\t ])/," \":idea:\" ",tag) - gsub(/(^|[\n\r\t ]):arrow:($|[\n\r\t ])/," \":arrow:\" ",tag) - gsub(/(^|[\n\r\t ]):\|($|[\n\r\t ])/," \":|\" ",tag) - gsub(/(^|[\n\r\t ]):mrgreen:($|[\n\r\t ])/," \":mrgreen:\" ",tag) - } - - html = html tag - ++count[depth] - } - } - debug = debug "###nl;done" - return html -} - -function ind(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii<=depth;++ii) - { - if(ii!=0) - iindex = iindex "." - iindex = iindex count[ii] - } - # debug = debug "###nl;" iindex - return iindex -} -function indt(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "###nl;" iindex - return iindex -} -function indtu(count,depth, ii,iindex) -{ - iindex = "" - for(ii=0;ii0) - iindex=iindex"." - iindex = iindex "0" - # debug = debug "###nl;" iindex - return iindex -} -function ong(decree, line) -{ - system (automome" -lc 256 -n 67 -d "memepath(decree!=""?" -t \"[decr]\"":"")" > "tempfile) - - while((getline line < tempfile)>0) - { - gsub(/[\r\n]/,"",line) - if(sub(/[AEIOUY]-N-G/,"#O-N-G#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/O+N+G+/,"#&#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/DON'T/,"D#ON'G#T",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/[AEIOUY]NG/,"#ONG#",line)>0) - { - if($0!~/TH\[b\]ONG/) - return preparebb(line) - } - if(sub(/ON /,"#ONG# ",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/O\.?$/,"#ONG# ",$0)>0) - { - close(tempfile) - return preparebb(line) - } - } - close(tempfile) - return "Ong" -} - -function ung(decree, line) -{ - system (automome" -lc 256 -n 67 -d "memepath(decree!=""?" -t \"[decr]\"":"")" > "tempfile) - - while((getline line < tempfile)>0) - { - gsub(/[\r\n]/,"",line) - if(sub(/[AEIOUY]-N-G/,"#U-N-G#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/U+N+G+/,"#&#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/[AEIOUY]NG/,"#UNG#",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/UN /,"#UNG# ",line)>0) - { - close(tempfile) - return preparebb(line) - } - if(sub(/U\.?$/,"#UNG# ",$0)>0) - { - close(tempfile) - return preparebb(line) - } - } - close(tempfile) - return "Ung" -} - -function preparebb(rh) -{ - if(nobb=="") - { - gsub(/\*\*/,"¤",rh) - gsub(/\*[^\*]+\*/,"±&±",rh) - gsub(/±\*/,"[i]",rh) - gsub(/\*±/,"[/i]",rh) - gsub(/¤/,"*",rh) - - gsub(/__/,"¤",rh) - gsub(/_[^_]+_/,"±&±",rh) - gsub(/±_/,"[u]",rh) - gsub(/_±/,"[/u]",rh) - gsub(/¤/,"_",rh) - - gsub(/##/,"¤",rh) - gsub(/#[^#]+#/,"±&±",rh) - gsub(/±#/,"[b]",rh) - gsub(/#±/,"[/b]",rh) - gsub(/¤/,"#",rh) - - gsub(/\$\$/,"¤",rh) - gsub(/\$[^\$]+\$/,"±&±",rh) - gsub(/±\$/,"[size=80]",rh) - gsub(/\$±/,"[/size]",rh) - gsub(/¤/,"$",rh) - } - - return rh (nobb==""?" -- [url=http://mrob.com/time/automome]automome[/url]":" -- automome") -} -function urlencode(name,all, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - escaped = escaped ch - else - escaped = escaped "%" ch2hex[ch] - } - return escaped -} diff --git a/bot5.c b/bot5.c deleted file mode 100644 index c0cfa5d..0000000 --- a/bot5.c +++ /dev/null @@ -1,399 +0,0 @@ -// bot5.c -// SilentBot -// 24.03.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include -#include -#include -#include -#include -#include - -#define TEMP_PATH "/eizm/tmp/t1i/bot5." -#define LOG_PATH "/eizm/log/t1i/bot5.log" -#define WAIT_PATH "/eizm/mem/t1i/mpost/" -#define SENT_PATH "/eizm/mem/t1i/mpost/sent/" -#define TEMPFILE_PATH "/eizm/tmp/t1i/bot5temp" -#define POSTDATA_PATH "/eizm/tmp/t1i/bot5post" -#define COOKIE_PATH "/eizm/tmp/t1i/bot5cook" -#define STOP_PATH "/eizm/tmp/t1i/bot5stop" -#define LS_PATH "/bin/ls" -#define MV_PATH "/bin/mv" -#define RM_PATH "/bin/rm" -#define MAWK_PATH "/usr/bin/mawk" -#define WGET_PATH "/usr/bin/wget" -#define AWK_POST "/eizm/pro/t1i/post.awk" -#define AWK_MPOST "/eizm/pro/t1i/mpost.awk" -#define AWK_LASTPOST "/eizm/pro/t1i/lastpost.awk" -#define PWAIT 15 -#define LASTPOST_ADDRESS "http://forums.xkcd.com/viewtopic.php?f=7&t=101043&sd=d" -#define USERAGENT "SilentBot (http://1190.bicyclesonthemoon.info/silentbot/; the Silent Chronotransponder bot)" - -pid_t sub; -int r; - -int main(int argc, char **argv) -{ - time_t t; - struct tm *nowS; - int yarg; - unsigned char text=0; - unsigned char newlog=0; - FILE *list; - FILE *post; - FILE *stopfile; - char temppath[256]; - unsigned char logopen=0; - unsigned char i; - char line[256]; - char value[256]; - char inpath[256]; - char outpath[256]; - char argp1[256]; - char argp2[256]; - char argp3[256]; - char argp4[256]; - char argp5[256]; - unsigned char d,m,h; - unsigned short y; - unsigned char another=0; - unsigned char edit; - - t=time(NULL); - sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - - while((yarg = getopt(argc,argv,"tn")) != -1) - { - switch(yarg) - { - case 't': - text=1; - break; - case 'n': - newlog=1; - break; - default: - - break; - } - } - if(!text) - { - if(freopen(LOG_PATH,newlog?"wt":"at",stdout)!=NULL) - logopen=1; - } - setvbuf(stdout, NULL, _IONBF, 0); - dup2(fileno(stdout),fileno(stderr)); - printf("\n%s",ctime(&t)); - - stopfile=fopen(STOP_PATH,"wt"); - if (stopfile==NULL) - { - printf("FULL STOPFULL STOP\n"); - return 1; - } - if (lockf(fileno(stopfile),F_TLOCK,0)!=0) - { - printf("FULL STOPFULL STOP\n"); - return 1; - } - fprintf(stopfile,"%hu.FULL STOPFULL STOP\n",0); - - - sub=fork(); - if(sub==0) - { - if(freopen(temppath,"wt",stdout)==NULL) - exit(255); - r=execl(LS_PATH,LS_PATH,"-1","--color=never",WAIT_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("ls fail.\n"); - else - { - list=fopen(temppath,"rt"); - if(list==NULL) - printf("list fail.\n"); - else - { - for(i=0; fgets(line,255,list)!=NULL; ++i) - { - sscanf(line,"%s",value); - if(value[0]>'9'||value[0]<'0') - { - --i; - continue; - } - printf("%s",value); - sprintf(inpath,"%s%s",WAIT_PATH,value); - post=fopen(inpath,"rt"); - if(post==NULL) - { - printf(" fail.\n"); - continue; - } - for(h=0xff,d=0xff,m=0xff,y=0xffff;fgets(line,31,post)!=NULL;) - { - if(line[strlen(line)-1]!='\n') - continue; - if(line[0]=='h'&&line[1]=='=') - { - sscanf(line+2,"%hhu",&h); - //printf("\n h%hhu d%hhu %s",h,d,line); - } - else if(line[0]=='d'&&line[1]=='=') - { - sscanf(line+2,"%hhu",&d); - //printf("\n d%hhu d%hhu %s",d,d,line); - } - else if(line[0]=='m'&&line[1]=='=') - { - sscanf(line+2,"%hhu",&m); - //printf("\n m%hhu d%hhu %s",m,d,line); - } - else if(line[0]=='y'&&line[1]=='=') - { - sscanf(line+2,"%hu",&y); - //printf("\n y%hu d%hhu %s",y,d,line); - } - } - fclose(post); - printf(" %02hhu.%02hhu.%04hu %02hhu:00",d,m,y,h); - nowS=gmtime(&t); - - if((1900+nowS->tm_year-y)>=2) - { - printf(" timer mustard"); - continue; - } - - if(y>1900+nowS->tm_year) - { - printf(" wait\n"); - continue; - } - else if(y==1900+nowS->tm_year) - { - if(m>1+nowS->tm_mon) - { - printf(" wait\n"); - continue; - } - else if(m==1+nowS->tm_mon) - { - if(d>nowS->tm_mday) - { - printf(" wait\n"); - continue; - } - else if(d==nowS->tm_mday) - { - if(h>nowS->tm_hour) - { - printf(" wait\n"); - continue; - } - } - - } - } - - printf(" deliver"); - - do - {//test latest post - edit=0; - sub=fork(); - if(sub==0) - { - r=execl(WGET_PATH,WGET_PATH, "-q","-t", "3","-U", USERAGENT, "-O", TEMPFILE_PATH,LASTPOST_ADDRESS, (char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - break; - - sub=fork(); - if(sub==0) - { - if(freopen(temppath,"wt",stdout)==NULL) - exit(255); - r=execl(MAWK_PATH,MAWK_PATH, "-f",AWK_LASTPOST, TEMPFILE_PATH, (char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - break; - - post=fopen(temppath,"rt"); - if(post==NULL) - break; - - if(fgets(argp1,255,post)!=NULL) - { - sscanf(argp1,"%s",argp2); - sprintf(argp4,"edit=%s",argp2); - } - else - { - fclose(post); - break; - } - if(fgets(argp1,255,post)!=NULL) - { - sscanf(argp1,"%s",argp2); - sprintf(argp5,"user=%s",argp2); - } - else - { - fclose(post); - break; - } - fclose(post); - edit=1; - }while(0); - - sprintf(argp1 ,"postfile=%s",POSTDATA_PATH); - sprintf(argp2,"cookiefile=%s",COOKIE_PATH); - sprintf(argp3,"tempfile=%s",TEMPFILE_PATH); - // sprintf(argp4,"name=%s",name); - // sprintf(argp5,"pass=%s",pass); - - //no longer necessary - bot can now edit - //ETA: not true, still have to wait but only 15s - so that phpBB doesn't - if(another) - sleep(PWAIT); - - sprintf(outpath,"%s%s",SENT_PATH,value); - - sub=fork(); - if(sub==0) - { - r=execl(MV_PATH,MV_PATH,inpath,outpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf(" mv fail.\n"); - - sub=fork(); - if(!sub) - { - if(edit) - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POST,"-v",argp1,"-v",argp2,"-v",argp3,"-v",argp4,"-v",argp5,outpath,(char *)0); - else - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POST,"-v",argp1,"-v",argp2,"-v",argp3,outpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - { - sub=fork(); - if(!sub) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_MPOST,"-v",argp1,"-v",argp2,"-v",argp3,outpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - { - another=0; - continue; - } - } - else - { - post=fopen(POSTDATA_PATH,"rt"); - if(post!=NULL) - { - if(fgets(line,255,post)!=NULL) - { - sscanf(line,"%s",value); - fclose(post); - - post=fopen(outpath,"at"); - if(post!=NULL) - { - fprintf(post,"ID=%s\n",value); - fclose (post); - } - } - else - fclose(post); - } - - } - printf(" ok\n"); - another=1; - - } - - if(i==0) - printf("Nothing.\n"); - fclose(list); - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("rm fail.\n"); - - - sub=fork(); - if(!sub) - { - r=execl(RM_PATH,RM_PATH,"-f",COOKIE_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - sub=fork(); - if(!sub) - { - r=execl(RM_PATH,RM_PATH,"-f",POSTDATA_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - sub=fork(); - if(!sub) - { - r=execl(RM_PATH,RM_PATH,"-f",TEMPFILE_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - lockf(fileno(stopfile),F_ULOCK,0); - fclose(stopfile); - - sub=fork(); - if(!sub) - { - r=execl(RM_PATH,RM_PATH,"-f",STOP_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - } - } - if(logopen) - fclose(stdout); - return 0; -} diff --git a/lastpost.awk b/lastpost.awk deleted file mode 100644 index 9b93751..0000000 --- a/lastpost.awk +++ /dev/null @@ -1,46 +0,0 @@ -#// lastpost.awk -#// what was the last post? -#// 20.03.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="" -} -{ - if ((i=match($0, /id=\"p[0-9]+\"/))!=0) #" - { - temp=substr($0, i+5) - postid=substr(temp, 1, index(temp,"\"")-1) - } - - if ($0 ~ /class=\"postprofile\"/) #" - postprofile = "1" - - else if (postprofile=="") - next - - if($0 ~ /memberlist\.php.*mode=viewprofile[^<>]*>[^<>]+<\/a/) - { - temp=substr($0, index($0, ">")+1) - username=substr(temp, 1, index(temp,"<")-1) - exit - } -} -END{ - print postid - print username -} \ No newline at end of file diff --git a/makefile b/makefile deleted file mode 100644 index e54680c..0000000 --- a/makefile +++ /dev/null @@ -1,138 +0,0 @@ -# "makefile" is automatically generated from "makefile.1.mak" -# -# Copyright (C) 2023 Balthasar Szczepański -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -ifndef TARGET -TARGET = debug -# when want to change target run this first: -# make -B TARGET=target_name makefile -endif - -CHMOD=/usr/bin/chmod -CP =/usr/bin/cp -MKDIR=/usr/bin/mkdir -RM =/usr/bin/rm - -BIN_PATH = /botm/bin/test-post -LIB_PATH = /botm/lib/test-post - - -CONFIGFILE = settings-$(TARGET).txt settings.txt - -# The configuration tool -# http://bicyclesonthemoon.info/git/botm-config -CONFIGURE = /botm/bin/config/configure.pl -CONFIGURE_CMD = $(PERL) $(CONFIGURE) $(CONFIGFILE) - -# keep these 2 lists in the same order!: -GENERATE_FROM=\ -sendpost.1.pl - -TO_GENERATE=\ -sendpost - -DIR=\ -$(BIN_PATH)\ -$(LIB_PATH) - -SETUID= - -EXEC=\ -sendpost - -BIN=\ -$(EXEC) - -LIB=\ -botm_common.pm - -all: $(BIN) - -makefile: makefile.1.mak $(CONFIGFILE) - $(CONFIGURE_CMD) < makefile.1.mak > makefile - - -$(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE) - $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE) - - -exec: $(EXEC) - $(CHMOD) +x $(EXEC) - -setuid: $(SETUID) -# $(CHMOD) u+s,g+s $(SETUID) - - -mktree: - $(MKDIR) -p $(DIR) -# $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR) - -ifdef BIN_PATH -cp_bin: $(BIN) setuid exec | mktree - $(RM) -f $(BIN_PATH)/* - $(CP) -p $(BIN) $(BIN_PATH) -endif - -ifdef LIB_PATH -cp_lib: $(LIB) | mktree - $(RM) -f $(LIB_PATH)/* - $(CP) -p $(LIB) $(LIB_PATH) -endif - -install: all cp_bin cp_lib - -clean: - $(RM) -f $(TO_GENERATE) - -PHONY: all clean install cp_bin cp_lib - - - -e: -# CC=gcc -# CC2=g++ -# CF=-g -Wall -# # LF=-lIL -# LF2=-lcgi - -# all: posted mpview remove post bot5 upload viewer enable - -# bot5: bot5.c post.awk mpost.awk makefile - # $(CC) $(CF) -o bot5 bot5.c - -# # deliver: deliver.c -# # $(CC) $(CF) -o deliver deliver.c - -# remove: remove.c verify.awk - # $(CC) $(CF) -o remove remove.c $(LF2) - -# mpview: mpview.c mview.awk verify.awk makefile - # $(CC) $(CF) -o mpview mpview.c $(LF2) - -# posted: posted.c posted.awk makefile - # $(CC) $(CF) -o posted posted.c $(LF2) - -# post: post.cpp preview.awk bb2html.awk verify.awk makefile - # $(CC2) $(CF) -o post post.cpp $(LF2) - -# upload: upload.c upload.awk makefile - # $(CC) $(CF) -o upload upload.c $(LF2) - -# viewer: viewer.c makefile - # $(CC) $(CF) -o viewer viewer.c $(LF2) - -# enable: posted mpview remove post upload viewer - # chmod u+s posted mpview remove post upload viewer diff --git a/makefile.1.mak b/makefile.1.mak deleted file mode 100644 index 71d5d7d..0000000 --- a/makefile.1.mak +++ /dev/null @@ -1,138 +0,0 @@ -# "makefile" is automatically generated from "makefile.1.mak" -# -# Copyright (C) 2023 Balthasar Szczepański -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -ifndef TARGET -TARGET = debug ###MAKE_TARGET: -# when want to change target run this first: -# make -B TARGET=target_name makefile -endif - -###MAKE_CHMOD: CHMOD = chmod -###MAKE_CP: CP = cp -###MAKE_MKDIR: MKDIR = mkdir -###MAKE_RM: RM = rm - -###MAKE_BIN_PATH: BIN_PATH = /botm/bin/post -###MAKE_LIB_PATH: LIB_PATH = /botm/lib/post - - -CONFIGFILE = settings-$(TARGET).txt settings.txt - -# The configuration tool -# http://bicyclesonthemoon.info/git/botm-config -CONFIGURE = /botm/bin/config/configure.pl ###MAKE_CONFIGURE: -CONFIGURE_CMD = $(PERL) $(CONFIGURE) $(CONFIGFILE) - -# keep these 2 lists in the same order!: -GENERATE_FROM=\ -sendpost.1.pl - -TO_GENERATE=\ -sendpost - -DIR=\ -$(BIN_PATH)\ -$(LIB_PATH) - -SETUID= - -EXEC=\ -sendpost - -BIN=\ -$(EXEC) - -LIB=\ -botm_common.pm - -all: $(BIN) - -makefile: makefile.1.mak $(CONFIGFILE) - $(CONFIGURE_CMD) < makefile.1.mak > makefile - - -$(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE) - $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE) - - -exec: $(EXEC) - $(CHMOD) +x $(EXEC) - -setuid: $(SETUID) -# $(CHMOD) u+s,g+s $(SETUID) - - -mktree: - $(MKDIR) -p $(DIR) -# $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR) - -ifdef BIN_PATH -cp_bin: $(BIN) setuid exec | mktree - $(RM) -f $(BIN_PATH)/* - $(CP) -p $(BIN) $(BIN_PATH) -endif - -ifdef LIB_PATH -cp_lib: $(LIB) | mktree - $(RM) -f $(LIB_PATH)/* - $(CP) -p $(LIB) $(LIB_PATH) -endif - -install: all cp_bin cp_lib - -clean: - $(RM) -f $(TO_GENERATE) - -PHONY: all clean install cp_bin cp_lib - - - -e: -# CC=gcc -# CC2=g++ -# CF=-g -Wall -# # LF=-lIL -# LF2=-lcgi - -# all: posted mpview remove post bot5 upload viewer enable - -# bot5: bot5.c post.awk mpost.awk makefile - # $(CC) $(CF) -o bot5 bot5.c - -# # deliver: deliver.c -# # $(CC) $(CF) -o deliver deliver.c - -# remove: remove.c verify.awk - # $(CC) $(CF) -o remove remove.c $(LF2) - -# mpview: mpview.c mview.awk verify.awk makefile - # $(CC) $(CF) -o mpview mpview.c $(LF2) - -# posted: posted.c posted.awk makefile - # $(CC) $(CF) -o posted posted.c $(LF2) - -# post: post.cpp preview.awk bb2html.awk verify.awk makefile - # $(CC2) $(CF) -o post post.cpp $(LF2) - -# upload: upload.c upload.awk makefile - # $(CC) $(CF) -o upload upload.c $(LF2) - -# viewer: viewer.c makefile - # $(CC) $(CF) -o viewer viewer.c $(LF2) - -# enable: posted mpview remove post upload viewer - # chmod u+s posted mpview remove post upload viewer diff --git a/mpost.awk b/mpost.awk deleted file mode 100644 index 7f90979..0000000 --- a/mpost.awk +++ /dev/null @@ -1,77 +0,0 @@ -#// mpost.awk -#// The tool to post to the mirror -#// 23.11.2014 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="=" - fora="http://1190.bicyclesonthemoon.info/ott" - useragent="\"SilentBot (http://1190.bicyclesonthemoon.info/silentbot/; Time thread post bot)\"" -}; -{ - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -}; -END{ - printf ("username=%s",argtab["username"])>postfile - printf ("&password=%s",argtab["password"])>>postfile - printf ("&subject=%s",argtab["subject"])>>postfile - if("&addbbcode20" in argtab) - printf ("&addbbcode20=%s",argtab["addbbcode20"])>>postfile - printf ("&message=%s",argtab["message"])>>postfile - printf ("&post=%s","Submit")>>postfile - if("disable_bbcode" in argtab) - printf ("&disable_bbcode=%s",argtab["disable_bbcode"])>>postfile - if("disable_smilies" in argtab) - printf ("&disable_smilies=%s",argtab["disable_smilies"])>>postfile - if("disable_magic_url" in argtab) - printf ("&disable_magic_url=%s",argtab["disable_magic_url"])>>postfile - if("attach_sig" in argtab) - printf ("&attach_sig=%s",argtab["attach_sig"])>>postfile - if("notify" in argtab) - printf ("¬ify=%s",argtab["notify"])>>postfile - printf ("&creation_time=%s",argtab["creation_time"])>>postfile - printf ("&form_token=%s",argtab["form_token"])>>postfile - close(postfile) - - if(system("wget -q -t 3 --connect-timeout=60 --post-file=" postfile " -U " useragent " -O " tempfile " \""fora "/post\"")) - { - print "Submit fail." - exit 1 - } - - while((getline temp < tempfile)>0) - { - if (temp ~ /

information/) - { - success=1 - } - } - close(tempfile) - - if (success!=1) - { - print "Sent back to preview!" - exit INDELIVERABLE - } -} diff --git a/mpview.c b/mpview.c deleted file mode 100644 index 6995887..0000000 --- a/mpview.c +++ /dev/null @@ -1,127 +0,0 @@ -// mpview.c (1190.bicyclesonthemoon.info/silentbot/view) -// Display one post -// 25.04.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include -#include -#include -#include -#include - -#define RM_PATH "/bin/rm" -#define CAT_PATH "/bin/cat" -#define MAWK_PATH "/usr/bin/mawk" - -#define SENT_PATH "/eizm/mem/t1i/mpost/sent/" -#define WAIT_PATH "/eizm/mem/t1i/mpost/" - -#define AWK_MVIEW "/eizm/pro/t1i/mview.awk" -#define TEMP_PATH "/eizm/tmp/t1i/mpview." - -int main() -{ - s_cgi *cgi; - pid_t sub; - int r; - - char line[32]; - char filename[32]; - char postpath[256]; - char cat[8]; - - char *arg; - char key[64]; - - char path2[256]; - - cgi=cgiInit(); - - dup2(fileno(stdout),fileno(stderr)); - - printf("Content-type: text/html\n\n"); - - arg=cgiGetValue(cgi,"v"); - sprintf(line,"%s",arg?arg:"???"); - - arg=cgiGetValue(cgi,"key"); - sprintf(key,"key=%s",arg?arg:"???"); - - if(line[0]=='s' && line[1]=='t') - { - sprintf(filename,"%s",line+2); - sprintf(cat,"cat=%s","st"); - sprintf(postpath,"%s%s",SENT_PATH,filename); - } - else if(line[0]=='w' && line[1]=='t') - { - sprintf(filename,"%s",line+2); - sprintf(cat,"cat=%s","wt"); - sprintf(postpath,"%s%s",WAIT_PATH,filename); - } - else - { - sprintf(filename,"%s","???"); - sprintf(postpath,"%s","???"); - sprintf(cat,"cat=%s","???"); - } - - sprintf(path2,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - - printf("\n"); - printf("\n"); - printf("the Silent Chronotransponder • Bicycles on the Moon\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\"1190.bicyclesonthemoon.info\"\n"); - printf("

the Silent Chronotransponder

\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_MVIEW,"-v","bg=1","-v",cat,"-v","s=1","-v",key,postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - // if(r) - // { - // printf("
\n",line); - // printf("
\n"); - // printf("%s %s POST NOT FOUND.\n",AWK_MVIEW,postpath); - // printf("\n
\n"); - // printf("
\n"); - // } - - printf("
back to the Silent Chronotransponder
\n"); - printf("
1190.bicyclesonthemoon.info\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",path2,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("

Ch*rpin* M*stard! file not deleted!

"); - - return 0; -} diff --git a/mview.awk b/mview.awk deleted file mode 100644 index f122227..0000000 --- a/mview.awk +++ /dev/null @@ -1,38 +0,0 @@ -#// mview.awk -#// Display one post -#// 25.04.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="=" -}; -{ - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -}; -END{ - if(key!=argtab["key"]&&cat=="wt"&&argtab["key"]!="") - { - print"Invalid key.

" - exit - } - print "
" - print "
"argtab["subject_h"]"
" - print "
"argtab["username_h"]" • "argtab["y"]"-"argtab["m"]"-"argtab["d"]" "argtab["h"]":00
quote "((cat=="wt")?("edit "):"")"remove "(argtab["ID"]!=""?" OTT":"")"
" - print "
"((argtab["HTML"]!="")?argtab["HTML"]:argtab["BBHTML"])"
" - print "
" -} diff --git a/notice.awk b/notice.awk deleted file mode 100644 index 56e6355..0000000 --- a/notice.awk +++ /dev/null @@ -1,50 +0,0 @@ -#// notice.awk -#// Display "Did you notice..." post in viewer -#// 31.03.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - timecmd="date -u +\"%Y%m%d%H\"" -} -{ - real=1 - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -} -END{ - if(real=="") - exit 1 - - posttime=argtab["y"]argtab["m"]argtab["d"]argtab["h"] - timecmd | getline thistime - close(timecmd) - - if (thistime"argtab["subject_h"]" "(argtab["ID"]!=""?"        (OTT time travel)":"")"" - print""((argtab["HTML"]!="")?argtab["HTML"]:argtab["BBHTML"])"" - } - else if (int(argtab["round"])==int(round)+1) - { - print ""argtab["subject_h"]"" - } - -} \ No newline at end of file diff --git a/post.awk b/post.awk deleted file mode 100644 index 32542e3..0000000 --- a/post.awk +++ /dev/null @@ -1,311 +0,0 @@ -#// post.awk -#// The tool to post to the OTT -#// 25.04.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="=" - fora="http://forums.xkcd.com" - useragent="\"SilentBot (http://1190.bicyclesonthemoon.info/silentbot/; the Silent Chronotransponder bot)\"" - timecmd="date -u +\"%d %b %Y, %k:%M UTC\"" - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i); - ch2hex[ch]=hex - hex2ch[hex]=ch - } -}; -{ - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -}; -END{ - if(entitydecode(user)!=urldecode(argtab["username"])) - edit="" - - if(system("wget -q -t 3 --connect-timeout=60 --save-cookies=" cookiefile " -U " useragent " -O " tempfile " " fora "/ucp.php?mode=login")) - { - print "Pre-login fail." - exit 1 - } - while((getline cookie < cookiefile)>0) - { - if(cookie ~ /_sid/) - { - split(cookie,arr,"_sid[ \t]*") - SID=arr[2] - } - } - close(cookiefile) - print "username=" argtab["username"] "&password=" argtab["password"] "&sid=" SID "&login=Login" > postfile - close(postfile) - if(system("wget -q -t 3 --connect-timeout=60 --save-cookies=" cookiefile " --post-file=" postfile " -U " useragent " -O " tempfile " \"" fora "/ucp.php?mode=login\"")) - { - print "Login fail." - exit 1 - } - - while((getline temp < tempfile)>0) - { - if (temp ~ /
0) - { - if (tolower(line) ~ /

information/) - { - print "Unexpected h2: information\n" - getline line < tempfile - print line - exit 1 - } - - while (line!="") - { - i=match(line, //) - if(i!=0) - { - tag=substr(line,1,i) - line=substr(line,i+1) - } - else #oh no tag doesn't end on this line - whatever, I don't care. - { - tag=line - line="" - } - - - if(tag ~ /^postfile - if("&addbbcode20" in argtab) - printf ("&addbbcode20=%s",argtab["addbbcode20"])>>postfile - if(edit!="") - printf ("&message=%s",argtab["old_message"] "%0A%5Bsize%3D110%5D%5Bb%5D" argtab["subject"] "%5B%2Fb%5D%5B%2Fsize%5D%0A%5Bsize%3D80%5D" urlencode(posttime) "%5B%2Fsize%5D%0A" argtab["message"])>>postfile - else - printf ("&message=%s",argtab["message"])>>postfile - printf ("&post=%s","Submit")>>postfile - if("disable_bbcode" in argtab) - printf ("&disable_bbcode=%s",argtab["disable_bbcode"])>>postfile - if("disable_smilies" in argtab) - printf ("&disable_smilies=%s",argtab["disable_smilies"])>>postfile - if("disable_magic_url" in argtab) - printf ("&disable_magic_url=%s",argtab["disable_magic_url"])>>postfile - if("attach_sig" in argtab) - printf ("&attach_sig=%s",argtab["attach_sig"])>>postfile - if("notify" in argtab) - printf ("¬ify=%s",argtab["notify"])>>postfile - printf ("&creation_time=%s",argtab["creation_time"])>>postfile - printf ("&form_token=%s",argtab["form_token"])>>postfile - for(i=0; i>postfile - - close(postfile) - - system("sleep 1") - if(system("wget -q -t 3 --connect-timeout=60 --load-cookies=" cookiefile " --save-cookies=" cookiefile " --post-file=" postfile " -U " useragent " -O " tempfile " \"" fora "/posting.php?mode="((edit!="")?"edit&f=7&p="edit:"reply&f=7&t=101043")"\"")) - { - print "Submit fail." - exit 1 - } - - while((getline temp < tempfile)>0) - { - if (temp ~ /

information/) - { - success=1 - } - if ((temp ~ /]*p=/) && (postid=="")) - { - postid = substr (temp , index(temp, "#p")+2) - postid = substr (postid, 1, index(postid, "\"") - 1) - } - } - close(tempfile) - - print postid > postfile - close(postfile) - - if (success!=1) - { - print "Sent back to preview!" - exit INDELIVERABLE - } - - while((getline cookie < cookiefile)>0) - { - if(cookie ~ /_sid/) - { - split(cookie,arr,"_sid[ \t]*") - SID=arr[2] - break - } - } - close(cookiefile) - if(system("wget -q -t 3 --connect-timeout=60 -U " useragent " -O " tempfile " \"" fora "/ucp.php?mode=logout&sid=" SID"\"")) - { - print "Logout fail." - } - - -} -function urlencode(name,all, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - escaped = escaped ch - else - escaped = escaped "%" ch2hex[ch] - } - return escaped -} -function entitydecode(ht ,i,j,un,num) -# quot, amp, lt, gt, nbsp, and decimal numbered. -{ - while ((i=match(ht, /&((#[0-9]+)|([a-zA-Z]+));/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - j=index(ht, ";") - - if(ht~/^&#/) - { - num=int(substr(ht, 3, j-3)) - un=un sprintf("%c",num) - } - else - { - num=tolower(substr(ht, 2, j-2)) - if(num == "quot") - un=un "\"" - else if(num == "amp") - un=un "&" - else if(num == "lt") - un=un "<" - else if(num == "gt") - un=un ">" - else if(num == "nbsp") - un=un "\xA0" - else - un = un ht - } - ht=substr(ht, j+1) - } - un=un ht - return un -} -function urldecode(ht ,i,j,un,num) -{ - while ((i=match(ht, /%[0-9a-fA-F][0-9a-fA-F]/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - num=toupper(substr(ht, 2, 2)) - un=un hex2ch[num] - ht=substr(ht, 4) - } - un=un ht - return un -} diff --git a/post.cpp b/post.cpp deleted file mode 100644 index 89fb04a..0000000 --- a/post.cpp +++ /dev/null @@ -1,612 +0,0 @@ -// post.cpp (1190.bicyclesonthemoon.info/aftertime/post) -// The post edit interface -// 25.04.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include -#include -#include -#include -#include -#include -#include - -#define RM_PATH "/bin/rm" -#define MV_PATH "/bin/mv" -#define CAT_PATH "/bin/cat" -#define MAWK_PATH "/usr/bin/mawk" - -#define POST_PATH "/eizm/www/time/silentbot/post.htm" -#define INFO_PATH "/eizm/www/time/silentbot/info.htm" -#define MPOST_PATH "/eizm/mem/t1i/mpost/" - -#define AWK_PREVIEW "/eizm/pro/t1i/preview.awk" -#define AWK_VIEW "/eizm/pro/t1i/view.awk" -#define TEMP_PATH "/eizm/tmp/t1i/preview." -#define AWK_B2H "/eizm/pro/t1i/bb2html.awk" -#define AWK_VERIFY "/eizm/pro/t1i/verify.awk" - -s_cgi *cgi; -pid_t sub; -int r; -FILE *tempfile; -FILE *postfile; -bool tf=false; -bool pf=false; -char temppath[256]=""; -char temppath2[256]=""; -char postpath[512]=""; - -char zero='\0'; -char *username = &zero; -char *password = &zero; -char *subject = &zero; -char *message = &zero; -char *y = &zero; -char *m = &zero; -char *d = &zero; -char *h = &zero; -char *disable_bbcode = &zero; -char *disable_smilies = &zero; -char *disable_magic_url = &zero; -char *attach_sig = &zero; -char *notify = &zero; -char *Preview = &zero; -char *post =&zero; -char *addquote =&zero; -char *edit =&zero; -char *forceID =&zero; -char *silent =&zero; -char *key =&zero; -char *forcekey =&zero; - -char wrong[256]; - -void submit(); -void preview (const char *text); -void writeArg(FILE *file,const char *name,const char *value, bool all); -void writeArg(FILE *file,const char *name,const char *value, const char *insert); -void writeArgH(FILE *file,const char *name,const char *value, unsigned char br); -void writeArgH(FILE *file,const char *value); -void end(int m); -void id(char *timenumber,unsigned short y, unsigned char m, unsigned short d, unsigned char h, char *name); - -void end(int m) -{ - if(tf) - fclose(tempfile); - if(pf) - fclose(postfile); - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath2,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(pf) - { - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - } - exit(m); -} - -void writeArg(FILE *file,const char *name,const char *value, bool all=false) -{ - unsigned short length, i, v; - fprintf(file,"%s=",name); - for(i=0, length=strlen(value);i='0'&&value[i]<='9')||(value[i]>='A'&&value[i]<='Z')||(value[i]>='a'&&value[i]<='z') - ||value[i]=='.'||value[i]=='~'||value[i]=='-'||value[i]=='_')&&(!all)) - fputc(v,file); - else - fprintf(file,"%%%02X",v); - } - fputc('\n',file); -} - -void writeArg(FILE *file,const char *name,const char *value, const char *insert) -{ - unsigned short length, i, v; - fprintf(file,"%s=",name); - for(i=0, length=strlen(value);i='0'&&value[i]<='9')||(value[i]>='A'&&value[i]<='Z')||(value[i]>='a'&&value[i]<='z') - ||value[i]=='.'||value[i]=='~'||value[i]=='-'||value[i]=='_') - fputc(v,file); - else - fprintf(file,"%%%02X",v); - } - for(i=0, length=strlen(insert);i='0'&&insert[i]<='9')||(insert[i]>='A'&&insert[i]<='Z')||(insert[i]>='a'&&insert[i]<='z') - ||insert[i]=='.'||insert[i]=='~'||insert[i]=='-'||insert[i]=='_') - fputc(v,file); - else - fprintf(file,"%%%02X",v); - } - fputc('\n',file); -} - -void writeArgH(FILE *file,const char *name,const char *value, unsigned char br=0) -{ - unsigned short length, i, v; - fprintf(file,"%s=",name); - for(i=0, length=strlen(value);i"); - case '\r': - if(br&0x01) - break; - case '=': - case '<': - case '>': - case '&': - fprintf(file,"&#%hu;",v); - break; - default: - fputc(v,file); - } - } - fputc('\n',file); -} - -void writeArgH(FILE *file,const char *value) -{ - unsigned short length, i, v; - for(i=0, length=strlen(value);i': - case ' ': - case '\r': - case '\n': - case '=': - fprintf(file,"&#%hu;",v); - break; - default: - fputc(v,file); - } - } -} - -void submit() -{ - time_t posttime; - struct tm *nowS; - char timenumber[256]; - char forcepath[512]; - char yy[8]; - char mm[4]; - char dd[4]; - char hh[4]; - char arg1[256]; - char arg2[256]; - char newkey[33]; - unsigned char tm, td, th; - unsigned short ty; - - posttime=time(NULL); - nowS=gmtime(&posttime); - - if(forcekey[0]=='\0') - sprintf(newkey,"%04X%04X%04X%04X%04X%04X%04X%04X", - (unsigned short)rand(),(unsigned short)rand(),(unsigned short)rand(),(unsigned short)rand(), - (unsigned short)rand(),(unsigned short)rand(),(unsigned short)rand(),(unsigned short)rand()); - else - sprintf(newkey,"%s",forcekey); - - if(y[0]!='\0'){sscanf(y,"%hu",&ty); sprintf(yy,"%04hu",ty); } - if(m[0]!='\0'){sscanf(m,"%hhu",&tm);sprintf(mm,"%02hhu",tm);} - if(d[0]!='\0'){sscanf(d,"%hhu",&td);sprintf(dd,"%02hhu",td);} - if(h[0]!='\0'){sscanf(h,"%hhu",&th);sprintf(hh,"%02hhu",th);} - - if((ty>0x0fff)||(tm>0x0f)||(td>0x1f)||(th>0x1f)) - preview("Time too long"); - // I accept invalid time as long as it's not too long - - - if(ty<1900+nowS->tm_year) - preview("Can't send this post to the past."); - else if(ty==1900+nowS->tm_year) - { - if(tm<1+nowS->tm_mon) - preview("Can't send this post to the past."); - else if(tm==1+nowS->tm_mon) - { - if(tdtm_mday) - preview("Can't send this post to the past."); - else if (td==nowS->tm_mday) - { - if (th<1+nowS->tm_hour) - preview("Can't send this post to the past."); - } - } - } - - - // sprintf(timenumber,"%04hu%02hhu%02hhu%02hhu_%llu",ty,tm,td,th,(unsigned long long)posttime); - id(timenumber,ty,tm,td,th,username); - sprintf(postpath,"%s%s",MPOST_PATH,timenumber); - if(forceID[0]!='\0') - sprintf(forcepath,"%s%s",MPOST_PATH,forceID); - - tempfile=fopen(temppath,"wt"); - if(tempfile==NULL) - preview("Couldn't create file."); - tf=true; - writeArgH(tempfile,"timenumber",timenumber); - writeArgH(tempfile,"key",newkey); - writeArgH(tempfile,"BBHTML",message,1); - writeArgH(tempfile,"BB",message,3); - writeArgH(tempfile,"username_h",username); - writeArgH(tempfile,"subject_h",subject); - if(h[0]!='\0')writeArgH(tempfile,"h",hh); - if(d[0]!='\0')writeArgH(tempfile,"d",dd); - if(m[0]!='\0')writeArgH(tempfile,"m",mm); - if(y[0]!='\0')writeArgH(tempfile,"y",yy); - writeArg (tempfile,"username",username); - writeArg (tempfile,"password",password,1); - writeArg (tempfile,"subject",subject); - writeArg (tempfile,"message",message,(silent[0]!='\0')?"":((disable_bbcode[0]!='\0')?"\n\n-- posted by SilentBot":"[right][size=80]-- posted by SilentBot [img]http://forums.xkcd.com/download/file.php?id=47884[/img][/size][/right]")); - if(disable_bbcode[0]!='\0') - writeArg(tempfile,"disable_bbcode",disable_bbcode); - if(disable_smilies[0]!='\0') - writeArg(tempfile,"disable_smilies",disable_smilies); - if(disable_magic_url[0]!='\0') - writeArg(tempfile,"disable_magic_url",disable_magic_url); - if(attach_sig[0]!='\0') - writeArg(tempfile,"attach_sig",attach_sig); - if(notify[0]!='\0') - writeArg(tempfile,"notify",notify); - if(silent[0]!='\0') - writeArgH(tempfile,"silent",silent); - fclose(tempfile); - tf=false; - - sprintf(arg1,"outfile=%s",temppath); - sprintf(arg2,"tempfile=%s",temppath2); - fflush(stdout); - sub=fork(); - if(sub==0) - { - setvbuf(stdout, NULL, _IONBF, 0); - dup2(fileno(stdout),fileno(stderr)); - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_B2H,"-v",arg1,"-v",arg2,temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - sprintf(arg1,"name=%s",username); - sprintf(arg2,"pass=%s",password); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_VERIFY,"-v",arg1,"-v",arg2,"-v","reversed=1",(forceID[0]!='\0')?forcepath:postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(!r) - preview("Can't replace this post. Not yours or wrong password?"); - - if(forceID[0]!='\0') - { - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,forcepath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - } - - sub=fork(); - if(sub==0) - { - r=execl(MV_PATH,MV_PATH,temppath,postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - // preview("Couldn't add post to queue."); - preview(postpath); - - printf("Content-type: text/html\n\n"); - sprintf(arg1,"info=

This message has been sent successfully.

View your submitted message

Return to the Silent Chronotransponder

",timenumber,newkey); - // printf("Content-type: text/html\n\n"); - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_VIEW,"-v",arg1,INFO_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("%s",arg1); - end(0); -} -void preview (const char *text) -{ - char arg1[256]; - char arg2[256]; - char yy[8]; - char mm[4]; - char dd[4]; - char hh[4]; - unsigned short ty; - unsigned char tm,td,th; - if(y[0]!='\0'){sscanf(y,"%hu",&ty); ty&=0x0fff;sprintf(yy,"%04hu",ty); } - if(m[0]!='\0'){sscanf(m,"%hhu",&tm);tm&= 0x0f;sprintf(mm,"%02hhu",tm);} - if(d[0]!='\0'){sscanf(d,"%hhu",&td);td&= 0x1f;sprintf(dd,"%02hhu",td);} - if(h[0]!='\0'){sscanf(h,"%hhu",&th);th&= 0x1f;sprintf(hh,"%02hhu",th);} - - tempfile=fopen(temppath,"wt"); - if(tempfile==NULL) - end(1); - tf=true; - - writeArgH(tempfile,"HTML",message,1); - writeArgH(tempfile,"BB",message,3); - writeArgH(tempfile,"wrong",text); - writeArgH(tempfile,"username",username); - writeArgH(tempfile,"subject",subject); - writeArgH(tempfile,"message",message); - if(h[0]!='\0')writeArgH(tempfile,"h",hh); - if(d[0]!='\0')writeArgH(tempfile,"d",dd); - if(m[0]!='\0')writeArgH(tempfile,"m",mm); - if(y[0]!='\0')writeArgH(tempfile,"y",yy); - writeArgH(tempfile,"disable_bbcode",disable_bbcode); - writeArgH(tempfile,"disable_smilies",disable_smilies); - writeArgH(tempfile,"disable_magic_url",disable_magic_url); - writeArgH(tempfile,"attach_sig",attach_sig); - writeArgH(tempfile,"notify",notify); - writeArgH(tempfile,"silent",silent); - writeArgH(tempfile,"addquote",addquote); - writeArgH(tempfile,"edit",edit); - writeArgH(tempfile,"forceID",forceID); - writeArgH(tempfile,"key",forcekey); - fclose(tempfile); - tf=false; - - printf("Content-type: text/html\n\n"); - - sprintf(arg1,"outfile=%s",temppath); - sprintf(arg2,"tempfile=%s",temppath2); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - setvbuf(stdout, NULL, _IONBF, 0); - dup2(fileno(stdout),fileno(stderr)); - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_B2H,"-v",arg1,"-v",arg2,temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - // printf("Content-type: text/html\n\n"); - sprintf(arg1,"argfile=%s",temppath); - sprintf(arg2,"key=%s",key[0]?key:"???"); - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_PREVIEW,"-v",arg1,"-v",arg2,POST_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("

Ch*rpin* M*stard

"); - end(0); -} - -int main() -{ - bool missing=false; - - char *arg; - - cgi=cgiInit(); - srand (time (NULL) + getpid()); - - sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - sprintf(temppath2,"%s_%lu",TEMP_PATH,(unsigned long)getpid()); - - arg=cgiGetValue(cgi,"password"); - if(arg!=NULL) - password=arg; - else - { - missing=true; - strcpy(wrong,"Password is missing."); - } - - arg=cgiGetValue(cgi,"username"); - if(arg!=NULL) - username=arg; - else - { - missing=true; - strcpy(wrong,"Name is missing."); - } - - arg=cgiGetValue(cgi,"subject"); - if(arg!=NULL) - subject=arg; - else - { - missing=true; - strcpy(wrong,"Subject was missing. Replaced with default value."); - } - - arg=cgiGetValue(cgi,"message"); - if(arg!=NULL) - message=arg; - else - { - missing=true; - strcpy(wrong,"Post is empty."); - } - - arg=cgiGetValue(cgi,"y"); - if(arg!=NULL) - y=arg; - else - { - missing=true; - strcpy(wrong,"Time not specified."); - } - - arg=cgiGetValue(cgi,"m"); - if(arg!=NULL) - m=arg; - else - { - missing=true; - strcpy(wrong,"Time not specified."); - } - - arg=cgiGetValue(cgi,"d"); - if(arg!=NULL) - d=arg; - else - { - missing=true; - strcpy(wrong,"Time not specified."); - } - - arg=cgiGetValue(cgi,"h"); - if(arg!=NULL) - h=arg; - else - { - missing=true; - strcpy(wrong,"Time not specified."); - } - - arg=cgiGetValue(cgi,"disable_bbcode"); - if(arg!=NULL) - disable_bbcode=arg; - - arg=cgiGetValue(cgi,"disable_smilies"); - if(arg!=NULL) - disable_smilies=arg; - - arg=cgiGetValue(cgi,"disable_magic_url"); - if(arg!=NULL) - disable_magic_url=arg; - - arg=cgiGetValue(cgi,"attach_sig"); - if(arg!=NULL) - attach_sig=arg; - - arg=cgiGetValue(cgi,"notify"); - if(arg!=NULL) - notify=arg; - - arg=cgiGetValue(cgi,"silent"); - if(arg!=NULL) - silent=arg; - - arg=cgiGetValue(cgi,"Preview"); - if(arg!=NULL) - Preview=arg; - - arg=cgiGetValue(cgi,"post"); - if(arg!=NULL) - post=arg; - - arg=cgiGetValue(cgi,"q"); - if(arg!=NULL) - addquote=arg; - - arg=cgiGetValue(cgi,"e"); - if(arg!=NULL) - edit=arg; - - arg=cgiGetValue(cgi,"forceID"); - if(arg!=NULL) - forceID=arg; - - arg=cgiGetValue(cgi,"key"); - if(arg!=NULL) - key=arg; - - arg=cgiGetValue(cgi,"forcekey"); - if(arg!=NULL) - forcekey=arg; - - if(strcmp(post,"Submit")==0) - { - if(missing) - preview(wrong); - else - submit(); - } - else - preview(""); - - return 0; - -} - -void id(char *timenumber,unsigned short y, unsigned char m, unsigned short d, unsigned char h, char *name) -{ - sprintf(timenumber,"%04hu%02hhu%02hhu%02hhu_",y,m,d,h); - for(unsigned short j=0, k=strlen(name);j. - - -BEGIN{ - FS="=" - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i); - hexl=sprintf("%02x",i); - ch2hex[ch]=hex - hex2ch[hex]=ch - hex2ch[hexl]=ch - } -}; -{ - gsub(/[\r\n]/,"",$0) - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -}; -END{ - if(((pass!=urldecode(argtab["password"]))||(name!=urldecode(argtab["username"])))&&cat!="st") - exit 1; - if (r2==0) - class="plw" - else - class="plv" - print ""argtab["y"]"-"argtab["m"]"-"argtab["d"]" "argtab["h"]":00"argtab["username_h"]""argtab["subject_h"]"view quote "(cat=="wt"?"edit ":"")"remove"(argtab["ID"]!=""?" OTT":"")"" -} -# function urlencode(name,all, len,iii,escaped,ch) -# { - # len=length(name) - # escaped="" - # for(iii=1;iii<=len;++iii) - # { - # ch=substr(name,iii,1); - # if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - # escaped = escaped ch - # else - # escaped = escaped "%" ch2hex[ch] - # } - # return escaped -# } -function urldecode(ht ,i,j,un,num) -{ - while ((i=match(ht, /%[0-9a-fA-F][0-9a-fA-F]/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - num=toupper(substr(ht, 2, 2)) - un=un hex2ch[num] - ht=substr(ht, 4) - } - un=un ht - return un -} \ No newline at end of file diff --git a/posted.c b/posted.c deleted file mode 100644 index 8ead0e0..0000000 --- a/posted.c +++ /dev/null @@ -1,190 +0,0 @@ -// posted.c (1190.bicyclesonthemoon.info/silentbot/list) -// Display the post list -// 26.04.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include -#include -#include -#include -#include - -#define TEMP_PATH "/eizm/tmp/t1i/posted." -#define SENT_PATH "/eizm/mem/t1i/mpost/sent/" -#define WAIT_PATH "/eizm/mem/t1i/mpost/" -#define LS_PATH "/bin/ls" -#define RM_PATH "/bin/rm" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_POSTED "/eizm/pro/t1i/posted.awk" - -s_cgi *cgi; -pid_t sub; -int r; - -int main(int argc, char **argv) -{ - char temppath[256]=""; - char line[512]; - char filename[512]; - char postpath[512]; - char argp1[256]; - char argp2[256]; - FILE *tempfile; - // FILE *postfile; - unsigned char i; - unsigned char sent; - char zero='\0'; - char *value; - char *username; - char *password; - // dup2(fileno(stdout),fileno(stderr)); - cgi=cgiInit(); - - username=((value=cgiGetValue(cgi,"username"))?value:&zero); - password=((value=cgiGetValue(cgi,"password"))?value:&zero); - sent=cgiGetValue(cgi,"sent"); - sprintf(argp1,"name=%s",username); - sprintf(argp2,"pass=%s",password); - - - sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - - printf("Content-type: text/html\n\n"); - printf("\n"); - printf("\n"); - printf("the Silent Chronotransponder • Bicycles on the Moon\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\"1190.bicyclesonthemoon.info\"\n"); - printf("

the Silent Chronotransponder

\n"); - printf("(some explanation)
\n"); - printf("
\n"); - printf("\n",username); - printf("\n"); - printf("\n",sent?" checked":""); - printf("
Username:
Password:
Sent posts:
\n"); - printf("Write a post

\n"); - printf("
\n"); - printf("
(file format - 23.03.2015)


\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - if(freopen(temppath,"wt",stdout)==NULL) - exit(255); - r=execl(LS_PATH,LS_PATH,"-1","--color=never",WAIT_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("No messages.
\n"); - else - { - printf("\n"); - printf("\n"); - - tempfile=fopen(temppath,"rt"); - if(tempfile!=NULL) - { - for(i=0; fgets(line,511,tempfile)!=NULL; ++i) - { - sscanf(line,"%s",filename); - //printf("+$%s\n",line); - sprintf(postpath,"%s%s",WAIT_PATH,filename); - - fflush(stdout); - sub=fork(); - if(!sub) - { - //dup2(fileno(stdout),fileno(stderr)); - - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POSTED,"-v",i&0x1?"r2=1":"r2=0","-v","cat=wt","-v",argp1,"-v",argp2,postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - --i; - - } - fclose(tempfile); - } - printf("
Waiting
post timeauthorsubjectaction

\n"); - - } - - if(sent) - { - fflush(stdout); - sub=fork(); - if(sub==0) - { - if(freopen(temppath,"wt",stdout)==NULL) - exit(255); - r=execl(LS_PATH,LS_PATH,"-1","--color=never",SENT_PATH,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - printf("No messages.
\n"); - else - { - printf("
\n"); - printf("\n"); - - tempfile=fopen(temppath,"rt"); - if(tempfile!=NULL) - { - for(i=0; fgets(line,511,tempfile)!=NULL; ++i) - { - sscanf(line,"%s",filename); - sprintf(postpath,"%s%s",SENT_PATH,filename); - - fflush(stdout); - sub=fork(); - if(!sub) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POSTED,"-v",i&0x1?"r2=1":"r2=0","-v","cat=st","-v",argp1,"-v",argp2,postpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - --i; - - } - fclose(tempfile); - } - - printf("
Sent
post timeauthorsubjectaction
\n"); - } - } - - printf("
Aftertime ONGsystem

1190.bicyclesonthemoon.info\n"); - - fflush(stdout); - sub=fork(); - if(sub==0) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - return 0; -} diff --git a/postid.awk b/postid.awk deleted file mode 100644 index c5b4946..0000000 --- a/postid.awk +++ /dev/null @@ -1,31 +0,0 @@ -#postid.awk -#24.04.2015 -#replaced by notice4.awk - -BEGIN{ - postpath="/eizm/mem/t1i/mpost/sent/" - noticepath="/eizm/mem/t1i/notice/" - tab_len=0 -} -{ - ID=$1 - frame =$NF - - if(frame !~ /t1i-[0-9][0-9][0-9][0-9]/) - next - - frame=substr(frame, 5, 4) - - notice=noticepath frame - - getline OTT < notice - close (notice) - - if(OTT=="") - next - - post=postpath ID - - print "ID="OTT >> post - close(post) -} \ No newline at end of file diff --git a/preview.awk b/preview.awk deleted file mode 100644 index 677418e..0000000 --- a/preview.awk +++ /dev/null @@ -1,204 +0,0 @@ -#// preview.awk -#// Preview a post in the post edit interface -#// 25.04.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - sentpath="/eizm/mem/t1i/mpost/sent/" - waitpath="/eizm/mem/t1i/mpost/" - - HTML="
Preview: %s
%s

" - wrong="
%s
\n" - subject="\n" - username="\n" - time="Y: M: D: H: \n" - message="\n" - # forcetime1="\n" - # forcetime2="fTime: day: month: year: \n" - # img="" - back="back to the Silent Chronotransponder" - - disable_bbcode=" Disable BBcode
\n" - disable_smilies=" Disable smilies
\n" - disable_magic_url=" Do not automatically parse URLs
\n" - attach_sig=" Attach a signature
\n" - notify=" Notify me when a reply is posted
\n" - silent=" Very silent
\n" - - forceID="\n" - forcekey="\n" - - addquote="" - - # print "" - close(argfile) - if(argtab["edit"] ~ /^wt[0-9]+_[0-9a-fA-F]+$/) - { - argtab["forceID"]=substr(argtab["edit"],3) - argfile= waitpath argtab["forceID"] - - while((getline argline < argfile)>0) - { - gsub(/[\r\n]/,"",argline) - eq=index(argline,"=") - if(argline ~ /^key=/) - { - if(substr(argline,eq+1)!=key && argtab["addquote"]~/^wt/) - { - argtab["wrong"]="Invalid key." - break; - } - argtab["key"]=substr(argline,eq+1) - } - else if(argline ~ /^((username)|(subject))_h=/) - argtab[substr(argline,1,eq-3)]=substr(argline,eq+1) - else if(argline ~ /^BBHTML=/) - { - argtab["message"]=substr(argline,eq+1) - gsub(/
/,"\n",argtab["message"]) - } - else if(argline ~ /^((BB)|(username)|(subject)|(message)|(HTML)|(debug))=/) - {} - else - argtab[substr(argline,1,eq-1)]=substr(argline,eq+1) - } - close(argfile) - } - else if(argtab["addquote"] ~ /^[sw]t[0-9]+_[0-9a-fA-F]+$/) - { - if(argtab["addquote"] ~ /^st[0-9]+_[0-9a-fA-F]+$/) - argfile= sentpath substr(argtab["addquote"],3) - if(argtab["addquote"] ~ /^wt[0-9]+_[0-9a-fA-F]+$/) - argfile= waitpath substr(argtab["addquote"],3) - #else - #argfile is not changed = quote self? - while((getline argline < argfile)>0) - { - gsub(/[\r\n]/,"",argline) - eq=index(argline,"=") - if(argline ~ /^key=/) - { - if(substr(argline,eq+1)!=key && argtab["addquote"]~/^wt/) - { - argtab["wrong"]="Invalid key." - break; - } - } - if(argline ~ /^BBHTML=/) - { - addquotehtml=substr(argline,eq+1) - gsub(/
/,"\n",addquotehtml) - } - if(argline ~ /^username_h=/) - addquotename=substr(argline,eq+1) - if(argline ~ /^subject_h/) - { - addquotesub=substr(argline,eq+1) - if(addquotesub ~ /^Re:/) - argtab["subject"]=addquotesub - else - argtab["subject"]="Re: "addquotesub - } - if(argline ~ /^y=/) - { - argtab["y"]=substr(argline,eq+1) - } - if(argline ~ /^d=/) - { - argtab["d"]=substr(argline,eq+1) - } - if(argline ~ /^m=/) - { - argtab["m"]=substr(argline,eq+1) - } - if(argline ~ /^h=/) - { - argtab["h"]=substr(argline,eq+1) - } - } - close(argfile) - if(addquotehtml!="") - addquote="[quote=""addquotename""]"addquotehtml"[/quote]" - } -}; -{ - if ($0 ~ /^###HTML/) - { - if((argtab["HTML"]!="")&&(argtab["wrong"]=="")) - printf(HTML,argtab["subject"],argtab["HTML"]) - } - else if ($0 ~ /^###wrong/) - { - if(argtab["wrong"]!="") - printf(wrong,argtab["wrong"]) - } - else if ($0 ~ /^###subject/) - printf(subject,((argtab["subject"]=="")?"Wait for it.":argtab["subject"])) - else if ($0 ~ /^###username/) - printf(username,argtab["username"]) - else if ($0 ~ /^###message/) - printf(message,argtab["message"],addquote) - else if ($0 ~ /^###time/) - printf(time,argtab["y"],argtab["m"],argtab["d"],argtab["h"]) - - else if ($0 ~ /^###future/) - { - ###no longer supported - } - else if ($0 ~ /^###forceID/) - { - if(argtab["forceID"]!="") - printf(forceID,argtab["forceID"]) - } - else if ($0 ~ /^###forcekey/) - { - if(argtab["key"]!="") - printf(forcekey,argtab["key"]) - } - else if ($0 ~ /^###back/) - { - print back - } - else if ($0 ~ /^###debug/) - { - gsub(/###nl;/,"\n",argtab["debug"]) - gsub(/-/," - ",argtab["debug"]) - print "" - } - else if ($0 ~ /^###disable_bbcode/) - printf(disable_bbcode,(argtab["disable_bbcode"]=="on")?"checked=\"checked\"":"") - else if ($0 ~ /^###disable_smilies/) - printf(disable_smilies,(argtab["disable_smilies"]=="on")?"checked=\"checked\"":"") - else if ($0 ~ /^###disable_magic_url/) - printf(disable_magic_url,(argtab["disable_magic_url"]=="on")?"checked=\"checked\"":"") - else if ($0 ~ /^###attach_sig/) - printf(attach_sig,(argtab["attach_sig"]=="on")?"checked=\"checked\"":"") - else if ($0 ~ /^###notify/) - printf(notify,(argtab["notify"]=="on")?"checked=\"checked\"":"") - else if ($0 ~ /^###silent/) - printf(silent,(argtab["silent"]=="on")?"checked=\"checked\"":"") - else - print $0 -}; diff --git a/remove.c b/remove.c deleted file mode 100644 index 4b5a10b..0000000 --- a/remove.c +++ /dev/null @@ -1,115 +0,0 @@ -// remove.c (1190.bicyclesonthemoon.info/silentbot/remove) -// remove a post -// 25.04.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include -#include -#include -#include -#include - -#define SENT_PATH "/eizm/mem/t1i/mpost/sent/" -#define WAIT_PATH "/eizm/mem/t1i/mpost/" -#define RMOV_PATH "/eizm/mem/t1i/mpost/rm/" -#define MV_PATH "/bin/mv" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_VERIFY "/eizm/pro/t1i/verify.awk" - -int main(int argc, char **argv) -{ - s_cgi *cgi; - pid_t sub; - int r; - - char zero='\0'; - char *rmov = &zero; - char *arg; - char *username; - char *password; - char inpath[256]; - char outpath[256]; - char argp1[256]; - char argp2[256]; - - cgi=cgiInit(); - - rmov=((arg=cgiGetValue(cgi,"r"))?arg:&zero); - - username=((arg=cgiGetValue(cgi,"username"))?arg:&zero); - password=((arg=cgiGetValue(cgi,"password"))?arg:&zero); - if(username[0]=='\0'||password[0]=='\0') - { - arg=cgiGetValue(cgi,"r"); - if(arg!=NULL) - rmov=arg; - printf("Content-type: text/html\n\n"); - printf("\n"); - printf("\n"); - printf("the Silent Chronotransponder • Bicycles on the Moon\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\n"); - printf("\"1190.bicyclesonthemoon.info\"\n"); - printf("

the Silent Chronotransponder interface

\n"); - printf("
\n"); - printf("Remove post %s?\n",rmov); - printf("\n",username); - printf("\n"); - printf("
Username:
Password:
\n",rmov); - printf("
1190.bicyclesonthemoon.info\n"); - return 0; - } - - if(rmov[0]=='s'&&rmov[1]=='t') - sprintf(inpath,"%s%s",SENT_PATH,rmov+2); - else if(rmov[0]=='w'&&rmov[1]=='t') - sprintf(inpath,"%s%s",WAIT_PATH,rmov+2); - else - { - cgiRedirect("/silentbot/list"); - return(0); - } - - sprintf(argp1,"name=%s",username); - sprintf(argp2,"pass=%s",password); - - sub=fork(); - if(sub==0) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_VERIFY,"-v",argp1,"-v",argp2,inpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - if(r) - { - cgiRedirect("/silentbot/list"); - return(0); - } - sprintf(outpath,"%s%s",RMOV_PATH,rmov+2); - - sub=fork(); - if(sub==0) - { - r=execl(MV_PATH,MV_PATH,inpath,outpath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - cgiRedirect("/silentbot/list"); - return 0; -} \ No newline at end of file diff --git a/sendpost.1.pl b/sendpost.1.pl deleted file mode 100644 index e5cb857..0000000 --- a/sendpost.1.pl +++ /dev/null @@ -1,117 +0,0 @@ -###RUN_PERL: - -# Copyright (C) 2023 Balthasar Szczepański -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -use strict; -use utf8; -use Getopt::Long; -use Encode qw(encode decode); - -###PERL_LIB: use lib '/botm/lib/post'; -use botm_common qw(readdatafile); - -###PERL_ENCODING_FILE_IN: use constant ENCODING_FILE_IN => 'UTF-8' -###PERL_ENCODING_FILE_OUT: use constant ENCODING_FILE_OUT => 'utf8' -###PERL_ENCODING_STD_IN: use constant ENCODING_STD_IN => 'UTF-8' -###PERL_ENCODING_STD_OUT: use constant ENCODING_STD_OUT => 'utf8' - -binmode STDIN, ':encoding('.ENCODING_STD_IN.')'; -# binmode ARGV, ':encoding('.ENCODING_STD_IN.')'; # not working -binmode STDOUT, ':encoding('.ENCODING_STD_OUT.')'; -binmode STDERR, ':encoding('.ENCODING_STD_OUT.')'; - -my $helptext = - "sendpost [options] [file(s)]\n". - " -s, --username=USERNAME\n". - " -p, --password=PASSWORD\n". - " -t, --subject=POST_SUBJECT\n". - " -c, --content=POST_CONTENT\n". - "\n". - " -d, --data-only\n". - "\n". - " -B, --bbcode\n". - " -b, --no-bbcode\n". - " -S, --smilies\n". - " -s, --no-smilies\n". - " -U, --urls\n". - " -u, --no-urls\n". - " -G, --signature\n". - " -g, --no-signature\n". - " -N, --notify\n". - " -n, --no-notify\n". - "\n". - " -M, --mirror\n". - " -m, --no-mirror\n". - "\n". - " -h, --help\n"; - -my %options = {}; - -foreach my $arg (@ARGV) { - $arg = decode(ENCODING_STD_IN, $arg); -} - -Getopt::Long::Configure('bundling'); -GetOptions ( - 'username|l=s' => \$options{'username'}, - 'password|p=s' => \$options{'password'}, - 'subject|t=s' => \$options{'subject'}, - 'content|c=s' => \$options{'content'}, - - 'data-only|d' => \$options{'data-only'}, - - 'bbcode|B' => \$options{ 'bbcode'}, - 'no-bbcode|b' => \$options{'no-bbcode'}, - 'smilies|S' => \$options{ 'smilies'}, - 'no-smilies|s' => \$options{'no-smilies'}, - 'urls|U' => \$options{ 'urls'}, - 'no-urls|u' => \$options{'no-urls'}, - 'signature|G' => \$options{ 'signature'}, - 'no-signature|g' => \$options{'no-signature'}, - 'notify|N' => \$options{ 'notify'}, - 'no-notify|n' => \$options{'no-notify'}, - - 'mirror|M' => \$options{ 'mirror'}, - 'no-mirror|m' => \$options{'no-mirror'}, - 'help|h' => \$options{ 'help'} -); - -if ($options{'help'} ne '') { - print $helptext; - exit 0; -} - -print "options\n"; -foreach my $ind (keys %options) { - print $ind.'='.$options{$ind}."\n"; -} -print; -foreach my $arg (@ARGV) { - print "\nFILE $arg\n"; - my %data = readdatafile($arg, 'utf8', 1); - foreach my $ind (keys %data) { - print $ind.'='.$data{$ind}."\n"; - } -} -if ((scalar @ARGV) == 0) { - print "\nSTDIN\n"; - my $fh; - my %data = readdatafile(\*STDIN, 'utf8', 1); - foreach my $ind (keys %data) { - print $ind.'='.$data{$ind}."\n"; - } -} - diff --git a/settings-debug.txt b/settings-debug.txt deleted file mode 100644 index df2ea3d..0000000 --- a/settings-debug.txt +++ /dev/null @@ -1,22 +0,0 @@ -# target name. settings file (THIS FILE) is "settings-TARGET_NAME.txt" -# where TARGET_NAME is the value -target: debug - -# The configuration tool -# http://bicyclesonthemoon.info/git/botm-config -# alternatively, copy configure.pl to source directory. -configure: /botm/bin/config/configure.pl - -bin_path: /botm/bin/test-post -lib_path: /botm/lib/test-post - -encoding_file_in: UTF-8 -encoding_file_out: utf8 -encoding_std_in: UTF-8 -encoding_std_out: utf8 - -cp: /usr/bin/cp -chmod: /usr/bin/chmod -mkdir: /usr/bin/mkdir -perl: /usr/bin/perl -rm: /usr/bin/rm diff --git a/settings-release.txt b/settings-release.txt deleted file mode 100644 index f4c4783..0000000 --- a/settings-release.txt +++ /dev/null @@ -1,22 +0,0 @@ -# target name. settings file (THIS FILE) is "settings-TARGET_NAME.txt" -# where TARGET_NAME is the value -target: release - -# The configuration tool -# http://bicyclesonthemoon.info/git/botm-config -# alternatively, copy configure.pl to source directory. -configure: /botm/bin/config/configure.pl - -bin_path: /botm/bin/post -lib_path: /botm/lib/post - -encoding_file_in: UTF-8 -encoding_file_out: utf8 -encoding_std_in: UTF-8 -encoding_std_out: utf8 - -cp: /usr/bin/cp -chmod: /usr/bin/chmod -mkdir: /usr/bin/mkdir -perl: /usr/bin/perl -rm: /usr/bin/rm diff --git a/settings.txt b/settings.txt deleted file mode 100644 index 7f34c9a..0000000 --- a/settings.txt +++ /dev/null @@ -1,42 +0,0 @@ -# settings.txt -# 08.15.2023 -# -# Copyright (C) 2023 Balthasar Szczepański -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -_SHEBANG: #!$0 -_PERL_USE_2: use $0 $1; -_PERL_CONSTANT: use constant $0 => $1; - -MAKE_CONFIGURE = CONFIGURE = $configure -MAKE_TARGET = TARGET = $target - -MAKE_CHMOD = CHMOD=$chmod -MAKE_CP = CP =$cp -MAKE_MKDIR = MKDIR=$mkdir -MAKE_RM = RM =$rm - -MAKE_BIN_PATH = BIN_PATH = $bin_path -MAKE_LIB_PATH = LIB_PATH = $lib_path - - -PERL_ENCODING_FILE_IN = @_PERL_CONSTANT(ENCODING_FILE_IN , '$encoding_file_in') -PERL_ENCODING_FILE_OUT = @_PERL_CONSTANT(ENCODING_FILE_OUT, '$encoding_file_out') -PERL_ENCODING_STD_IN = @_PERL_CONSTANT(ENCODING_STD_IN , '$encoding_std_in') -PERL_ENCODING_STD_OUT = @_PERL_CONSTANT(ENCODING_STD_OUT , '$encoding_std_out') -PERL_LIB = @_PERL_USE_2(lib, '$lib_path') - - -RUN_PERL = @_SHEBANG($perl) \ No newline at end of file diff --git a/upload.awk b/upload.awk deleted file mode 100644 index 4e9dc44..0000000 --- a/upload.awk +++ /dev/null @@ -1,894 +0,0 @@ -#// upload.awk -#// The post upload interface -#// 05.06.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - postpath="/eizm/mem/t1i/mpost/" - stpath="/eizm/mem/t1i/mpost/sent/" - rmpath="/eizm/mem/t1i/mpost/rm/" - bb2html="/eizm/pro/t1i/bb2html.awk" - automome="/eizm/pro/ong1/mome.pl" - memepath="/eizm/mem/ong1/mome.txt" - timecmd="date -u +\"%s\"" - - timecmd | getline thistime - close(timecmd) - - srand(int(thistime) + int( PROCINFO["pid"])) - - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i) - hexl=sprintf("%02x",i) - dec=sprintf("%u",i) - ch2hex[ch]=hex - hex2ch[hex]=ch - ch2hexl[ch]=hexl - ch2dec[ch]=dec - } - - year=substr(timetext,1,4) - month=substr(timetext,5,2) - day=substr(timetext,7,2) - hour=substr(timetext,9,2) - - yyy=year+0 - mmm=month+0 - ddd=day+0 - hhh=hour+0 - - ln=0 - memenumber=8 -} -{ - gsub(/[\r\n]/,"",$0) - if (FNR==1) - { - name=$0 - # print "username: "name - next - } - if (FNR==2) - { - pass=$0 - gsub(/./,"*", $0) - # print "password: "$0 - next - } - - if($0=="") - { - if(ln!=0) - { - post() - ln=0 - nobb="" - nosmil="" - nourl="" - sig="" - notify="" - silent="" - quot="" - rmov="" - lst="" - flst="" - h="" - d="" - m="" - y="" - subject="" - content="" - options="" - # replace="" - } - next - } - - ++ln - if(ln==1) - { - y=substr($0,1,4) - m=substr($0,6,2) - d=substr($0,9,2) - h=substr($0,12,2) - # #xxxx-xx-xx xx xxxx-xx-xx xx - # if(length($0)>=27) - # replace=substr($0,15,4)substr($0,20,2)substr($0,23,2)substr($0,26,2) - } - else if(ln==2) - { - options=tolower($0) - if(options ~ /b/) - nobb=1 - if(options ~ /s/) - nosmil=1 - if(options ~ /u/) - nourl=1 - if(options ~ /a/) - sig=1 - if(options ~ /n/) - notify=1 - if(options ~ /v/) - silent=1 - if(options ~ /r/) - rmov=1 - if(options ~ /q/) - quot=1 - if(options ~ /l/) - lst=1 - if(options ~ /f/) - flst=1 - } - else if(ln==3) - { - subject=$0 - } - else - { - if(ln!=4) - content=content "\n" $0 - else - content=$0 - } - -} -END{ - if(ln!=0) - post() -} -function remove( postid,postfile,rmfile,stfile,temp,f,tn,eq,tv) -{ - postid=sprintf("%04d%02d%02d%02d_%s",y,m,d,h,hexencode(name)) - postfile=postpath postid - rmfile=rmpath postid - stfile=stpath postid - printf("%s",postid" ") - - while((getline temp < postfile)>0) - { - f=1 - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - if(tn=="username") - { - if(urldecode(tv)!=name) - { - # print "Can't remove, post belongs to "substr(temp,eq+1)"." - print "not removed."substr(temp,eq+1)"." - close(postfile) - return - } - } - else if(tn=="password") - { - if(urldecode(tv)!=pass) - { - # print "Can't remove, wrong password." - print "not removed" - #I shouldn't tell why - the user can't be able to determine if post exists. - close(postfile) - return - } - } - } - - if(f!="") - { - close(postfile) - if(system("mv -f "postfile" "rmfile)==0) - { - print "removed." - return - } - } - f="" - while((getline temp < stfile)>0) - { - f=1 - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - if(tn=="username") - { - if(urldecode(tv)!=name) - { - print "Can't remove, post belongs to "substr(temp,eq+1)"." - close(stfile) - return - } - } - else if(tn=="password") - { - if(urldecode(tv)!=pass) - { - print "Can't remove, wrong password." - close(stfile) - return - } - } - } - if(f!="") - { - close(stfile) - if(system("mv -f "stfile" "rmfile)==0) - { - print "removed." - return - } - } - print "not removed." -} - -function quote( postid,postfile,stfile,temp,f,opt,cont,ongt,subj,eq,tn,tv,id) -{ - postid=sprintf("%04d%02d%02d%02d_%s",y,m,d,h,hexencode(name)) - postfile=postpath postid - stfile=stpath postid - - while((getline temp < postfile)>0) - { - f=1 - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - if(tn=="username") - { - if(urldecode(tv)!=name) - { - #print "Can't quote, post belongs to "substr(temp,eq+1)"." - print " can't. quote." #I shouldn't tell why - close(postfile) - return - } - } - else if(tn=="password") - { - if(urldecode(tv)!=pass) - { - #print "Can't quote, wrong password." - print " can't quote." #I shouldn't tell why - close(postfile) - return - } - } - else if(tn=="BB") - cont=unhtml(tv) - else if(tn=="brtext") - ongt=tv - else if(tn=="subject_h") - subj=unhtml(tv) - else if(tn=="disable_bbcode") - { - if(tv=="on") - opt=opt"B" - } - else if(tn=="disable_smilies") - { - if(tv=="on") - opt=opt"S" - } - else if(tn=="disable_magic_url") - { - if(tv=="on") - opt=opt"U" - } - else if(tn=="attach_sig") - { - if(tv=="on") - opt=opt"A" - } - else if(tn=="notify") - { - if(tv=="on") - opt=opt"N" - } - else if(tn=="silent") - { - if(tv=="on") - opt=opt"V" - } - } - if(f!="") - { - close(postfile) - if (opt=="") - opt="_" - print postid" subject "subj - print postid" options "opt - print postid" content "((ongt!="")?ongt:cont) - return - } - - while((getline temp < stfile)>0) - { - f=1 - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - if(tn=="BB") - cont=unhtml(tv) - else if(tn=="brtext") - ongt=tv - else if(tn=="subject_h") - subj=unhtml(tv) - else if(tn=="ID") - id=tv - else if(tn=="disable_bbcode") - { - if(tv=="on") - opt=opt"B" - } - else if(tn=="disable_smilies") - { - if(tv=="on") - opt=opt"S" - } - else if(tn=="disable_magic_url") - { - if(tv=="on") - opt=opt"U" - } - else if(tn=="attach_sig") - { - if(tv=="on") - opt=opt"A" - } - else if(tn=="notify") - { - if(tv=="on") - opt=opt"N" - } - else if(tn=="silent") - { - if(tv=="on") - opt=opt"V" - } - } - if(f!="") - { - close(stfile) - if (opt=="") - opt="_" - print postid" subject "subj - print postid" options "opt - print postid" content "((ongt!="")?ongt:cont) - if(id!="") - print postid" ID "id - return - } - - else - print postid " can't quote." #I shouldn't tell why -} - -function list( cmd,id,postfile,temp,mt,f,eq,tn,tv) -{ - - if (flst!="") - { - cmd="/bin/ls -1 --color=never "stpath - while ((cmd | getline id)>0) - { - f="" - mt="[0-9]*_"hexencode(name) - if(id !~ mt) - continue - stfile = stpath id - #print id - - while((getline temp < stfile)>0) - { - f=1 - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - if(tn=="subject_h") - subj=unhtml(tv) - } - if(f!="") - { - close(stfile) - print id" subject "subj - } - } - close (cmd) - } - - cmd="/bin/ls -1 --color=never "postpath - while ((cmd | getline id)>0) - { - f="" - mt="[0-9]*_"hexencode(name) - if(id !~ mt) - continue - postfile = postpath id - #print id - - while((getline temp < postfile)>0) - { - f=1 - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - if(tn=="username") - { - if(urldecode(tv)!=name) - { - close(postfile) - f="" - break - } - } - else if(tn=="password") - { - if(urldecode(tv)!=pass) - { - close(postfile) - f="" - break - } - } - else if(tn=="subject_h") - subj=unhtml(tv) - } - if(f!="") - { - close(postfile) - print id" subject "subj - } - - - - ########33 - } - close (cmd) -} - -function post( postid,replaceid,postfile,replacefile,temp,i,eq,tn,tv) -{ - if(lst!="") - return list() - if(quot!="") - return quote() - if(rmov!="") - return remove() - postid=sprintf("%04d%02d%02d%02d_%s",y,m,d,h,hexencode(name)) - printf("%s",postid" ") - postfile=postpath postid - - if(options=="") - { - print "No options defined." - return - } - - # if(replace!="") - # { - # replaceid=replace"_"hexencode(name) - # replacefile=postpath replaceid - # } - - if (name=="") - { - print "Username missing." - return - } - if (pass=="") - { - print "Password missing." - return - } - if (subject=="") - { - print "Subject missing." - return - } - if (content=="") - { - print "Post is empty." - return - } - - yy=y+0 - mm=m+0 - dd=d+0 - hh=h+0 - - if(yy0) - { - gsub(/[\r\n]/,"",temp) - eq=index(temp,"=") - tn=substr(temp,1,eq-1) - tv=substr(temp,eq+1) - if(tn=="username") - { - if(urldecode(tv)!=name) - { - print "Can't replace, post belongs to "substr(temp,eq+1) - close(postfile) - return - } - } - else if(tn=="password") - { - if(urldecode(tv)!=pass) - { - print "Can't replace, wrong password" - close(postfile) - return - } - } - else if(tn ~ /^[ou]ngd?-[0-9]+$/) - { - ongtable[tn]=brunescape(tv) - } - else if(tn == "key") - key=tv - } - close(postfile) - - # if(replace!="") - # { - # #print "Repalce post "replaceid - # while((getline temp < replacefile)>0) - # { - # gsub(/[\r\n]/,"",temp) - # eq=index(temp,"=") - # if(substr(temp,1,eq-1)=="username") - # { - # if(substr(temp,eq+1)!=urlencode(name)) - # { - # print "Can't replace, post belongs to "substr(temp,eq+1) - # close(replacefile) - # return - # } - # } - # else if(substr(temp,1,eq-1)=="password") - # { - # if(substr(temp,eq+1)!=urlencode(pass,"all")) - # { - # print "Can't replace, wrong password" - # close(replacefile) - # return - # } - # } - # } - # close(replacefile) - # system("rm -f " replacefile) - - # } - printf("")>postfile - - print "timenumber="htmlescape(postid) >> postfile - print "key="(key==""?newkey():key) >> postfile - print "username="urlencode(name) >> postfile - print "password="urlencode(pass,"all") >> postfile - print "username_h="htmlescape(name) >> postfile - - # print("Post time:\n"d"."m"."y" "h":00") - print "h="htmlescape(h) >> postfile - print "d="htmlescape(d) >> postfile - print "m="htmlescape(m) >> postfile - print "y="htmlescape(y) >> postfile - - if(nobb!="") - print "disable_bbcode=on" >> postfile - if(nosmil!="") - print "disable_smilies=on" >> postfile - if(nourl!="") - print "disable_magic_url=on" >> postfile - if(sig!="") - print "attach_sig=on" >> postfile - if(notify!="") - print "notify=on" >> postfile - if(silent!="") - print "silent=on" >> postfile - - print "subject="urlencode(subject) >> postfile - print "subject_h="htmlescape(subject) >> postfile - - print "brtext="brescape(content) >> postfile - - gsub(/\[br\]/,"\n",content) - - for(i=0; content~/\[ong\]/; ++i) - { - tn=sprintf("ong-%u",i) - ongtext = ongtable[tn] - if (ongtext == "") - ongtext=ong() - print(tn"="brescape(ongtext)) >> postfile - sub(/\[ong\]/,subescape(ongtext),content) - } - for(i=0; content~/\[ung\]/; ++i) - { - tn=sprintf("ung-%u",i) - ongtext = ongtable[tn] - if (ongtext == "") - ongtext=ung() - print(tn"="brescape(ongtext)) >> postfile - sub(/\[ung\]/,subescape(ongtext),content) - } - for(i=0; content~/\[ong=decree\]/; ++i) - { - tn=sprintf("ongd-%u",i) - ongtext = ongtable[tn] - if (ongtext == "") - ongtext=ong("decree") - print(tn"="brescape(ongtext)) >> postfile - sub(/\[ong=decree\]/,subescape(ongtext),content) - } - for(i=0; content~/\[ung=decree\]/; ++i) - { - tn=sprintf("ungd-%u",i) - ongtext = ongtable[tn] - if (ongtext == "") - ongtext=ung("decree") - print(tn"="brescape(ongtext)) >> postfile - sub(/\[ung=decree\]/,subescape(ongtext),content) - } - - # print "content:\n"content - print "BBHTML="htmlescape(content,"","br") >> postfile - print "BB="htmlescape(content,"less","br") >> postfile - print "message="urlencode(content ((silent=="")?(nobb==""?"[right][size=80]-- posted by SilentBot [img]http://forums.xkcd.com/download/file.php?id=47884[/img][/size][/right]":"\n\n-- posted by SilentBot"):"")) >> postfile - - print "posted." - system ("mawk -f "bb2html" -v outfile=\""postfile"\" \""postfile"\"") - system ("wait 1") - close (postfile) -} - -function urlencode(name,all, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - escaped = escaped ch - else - escaped = escaped "%" ch2hex[ch] - } - return escaped -} -function hexencode(name, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1) - escaped = escaped ch2hex[ch] - } - return escaped -} -function subescape(subtext) -{ - gsub(/&/,"\\\\\\&",subtext) - return subtext -} - -function htmlescape(name,less,br, len,iii,escaped,ch) -{ - len=length(name) - escaped="" - for(iii=1;iii<=len;++iii) - { - ch=substr(name,iii,1); - if(ch == "\n") - escaped = escaped ((br!="")?"
":"&#"ch2dec[ch]";") - else if(ch =="\r") - escaped = escaped ((br!="")?"":"&#"ch2dec[ch]";") - else if(ch ~ /[\" ]/ && less=="")#"#"\"" - escaped = escaped "&#"ch2dec[ch]";" - else if(ch ~ /[=<>&]/) - escaped = escaped "&#"ch2dec[ch]";" - else - escaped = escaped ch - } - return escaped -} - -function getmeme(decree ,meme,i) -{ - if(decree!="" && lastdecr=="") - { - close(tempfile) - system (automome" -lc 256 -n "memenumber" -d "memepath" -t \"[decr]\" > "tempfile) - } - else if(decree=="" && lastdecr!="") - { - close(tempfile) - system (automome" -lc 256 -n "memenumber" -d "memepath" > "tempfile) - } - for(i=0; ((getline meme < tempfile)<=0) && (i<3); ++i) - { - memenumber=memenumber*2 - close(tempfile) - if(decree!="") - system (automome" -lc 256 -n "memenumber" -d "memepath" -t \"[decr]\" > "tempfile) - else - system (automome" -lc 256 -n "memenumber" -d "memepath" > "tempfile) - } - lastdecr=decree - return meme -} - -function ong(decree, line) -{ - # system (automome" -lc 256 -n 67 -d "memepath(decree!=""?" -t \"[decr]\"":"")" > "tempfile) - - while((line=getmeme(decree))!="") - { - gsub(/[\r\n]/,"",line) - if(sub(/[AEIOUY]-N-G/,"#O-N-G#",line)>0) - return preparebb(line) - if(sub(/O+N+G+/,"#&#",line)>0) - return preparebb(line) - if(sub(/DON'T/,"D#ON'G#T",line)>0) - return preparebb(line) - if(sub(/[AEIOUY]NG/,"#ONG#",line)>0) - { - if($0!~/TH\[b\]ONG/) - return preparebb(line) - } - if(sub(/ON /,"#ONG# ",line)>0) - return preparebb(line) - if(sub(/O\.?$/,"#ONG# ",$0)>0) - return preparebb(line) - } - return "Ong" -} - -function ung(decree, line) -{ - # system (automome" -lc 256 -n 67 -d "memepath(decree!=""?" -t \"[decr]\"":"")" > "tempfile) - - while((line=getmeme(decree))!="")#((getline line < tempfile)>0) - { - gsub(/[\r\n]/,"",line) - if(sub(/[AEIOUY]-N-G/,"#U-N-G#",line)>0) - return preparebb(line) - if(sub(/U+N+G+/,"#&#",line)>0) - return preparebb(line) - if(sub(/[AEIOUY]NG/,"#UNG#",line)>0) - return preparebb(line) - if(sub(/UN /,"#UNG# ",line)>0) - return preparebb(line) - if(sub(/U\.?$/,"#UNG# ",$0)>0) - return preparebb(line) - } - return "Ung" -} -function preparebb(rh) -{ - if(nobb=="") - { - gsub(/\*\*/,"¤",rh) - gsub(/\*[^\*]+\*/,"±&±",rh) - gsub(/±\*/,"[i]",rh) - gsub(/\*±/,"[/i]",rh) - gsub(/¤/,"*",rh) - - gsub(/&&/,"¤",rh) - gsub(/&[^&]+&/,"±&±",rh) - gsub(/±&/,"[center][b]",rh) - gsub(/&±/,"[/b][/center]",rh) - gsub(/¤/,"\\&",rh) - - gsub(/__/,"¤",rh) - gsub(/_[^_]+_/,"±&±",rh) - gsub(/±_/,"[u]",rh) - gsub(/_±/,"[/u]",rh) - gsub(/¤/,"_",rh) - - gsub(/##/,"¤",rh) - gsub(/#[^#]+#/,"±&±",rh) - gsub(/±#/,"[b]",rh) - gsub(/#±/,"[/b]",rh) - gsub(/¤/,"#",rh) - - gsub(/\$\$/,"¤",rh) - gsub(/\$[^\$]+\$/,"±&±",rh) - gsub(/±\$/,"[size=80]",rh) - gsub(/\$±/,"[/size]",rh) - gsub(/¤/,"$",rh) - } - - return rh (nobb==""?" -- [url=http://1190.bicyclesonthemoon.info/ongtext?b=on][b]ong[/b]o[/url][url=http://mrob.com/time/automome/]mome[/url]":" -- ongomome") -} -function unhtml(ht ,i,j,un,num) -{ - gsub(//,"[br]",ht) - while ((i=match(ht, /&#[0-9]+;/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - j=index(ht, ";") - num=int(substr(ht, 3, j-3)) - un=un sprintf("%c",num) - ht=substr(ht, j+1) - } - un=un ht - return un -} -function brescape(text) #there will be more -{ - gsub(/\r/,"",text) - gsub(/\n/,"[br]",text) - return text -} -function brunescape(text) #there will be more -{ - gsub(/\[br\]/,"\n",text) - return text -} -function urldecode(ht ,i,j,un,num) -{ - while ((i=match(ht, /%[0-9a-fA-F][0-9a-fA-F]/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - num=toupper(substr(ht, 2, 2)) - un=un hex2ch[num] - ht=substr(ht, 4) - } - un=un ht - return un -} -function newkey( key,i,rn) -{ - for(i=0; i<8; ++i) - { - rn=int(rand()*65536) - key = key sprintf("%04X",rn) - } - return key -} \ No newline at end of file diff --git a/upload.c b/upload.c deleted file mode 100644 index 24c5d09..0000000 --- a/upload.c +++ /dev/null @@ -1,97 +0,0 @@ -// upload.c (1190.bicyclesonthemoon.info/silentbot/upload) -// The post upload interface -// 28.03.2015 -// -// Copyright (C) 2015 Balthasar Szczepański -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include -#include -#include -#include -#include -#include - -#define RM_PATH "/bin/rm" -#define MAWK_PATH "/usr/bin/mawk" -#define AWK_UPLOAD "/eizm/pro/t1i/upload.awk" -#define TEMP_PATH "/eizm/tmp/t1i/upload." -#define RM_PATH "/bin/rm" - -s_cgi *cgi; -pid_t sub; -int r; - -int main(int argc, char **argv) -{ - char *temppath; - char **up; - time_t posttime; - struct tm *nowS; - char timetext[64]; - char timenumber[64]; - char temppath2[247]; - char temppath3[256]; - - setvbuf(stdout, NULL, _IONBF, 0); - dup2(fileno(stdout),fileno(stderr)); - - cgi=cgiInit(); - - sprintf(temppath2,"%s%lu",TEMP_PATH,(unsigned long)getpid()); - sprintf(temppath3,"tempfile=%s",temppath2); - - printf("Content-type: text\n\n"); - up=cgiGetFiles(cgi); - if (up) - { - temppath=cgiGetFile(cgi,up[0])->tmpfile; - - posttime=time(NULL); - nowS=gmtime(&posttime); - - sprintf(timenumber,"timenumber=%lu",(unsigned long)posttime); - sprintf(timetext,"timetext=%04d%02d%02d%02d",nowS->tm_year+1900,nowS->tm_mon+1,nowS->tm_mday,nowS->tm_hour); - - // printf("%s\n%s\n%s\n",timenumber,timetext,temppath); - - sub=fork(); - if(!sub) - { - r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_UPLOAD,"-v",timetext,"-v",timenumber,"-v",temppath3,temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - sub=fork(); - if(!sub) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - sub=fork(); - if(!sub) - { - r=execl(RM_PATH,RM_PATH,"-f",temppath2,(char *)0); - exit(r); - } - waitpid(sub,&r,0); - - return 0; - } - printf("File missing\n"); - return 0; -} diff --git a/verify.awk b/verify.awk deleted file mode 100644 index a0ffc4e..0000000 --- a/verify.awk +++ /dev/null @@ -1,77 +0,0 @@ -#// verify.awk -#// Check if post belongs to user -#// 25.04.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepański -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - -BEGIN{ - FS="=" - for(i=0;i<256;++i) - { - ch=sprintf("%c",i) - hex=sprintf("%02X",i); - ch2hex[ch]=hex - hex2ch[hex]=ch - } - if(reversed!="") - { - ok=1 - fail=0 - } - else - { - ok=0 - fail=1 - } -} -{ - gsub(/[\r\n]/,"",$0) - eq=index($0,"=") - argtab[substr($0,1,eq-1)]=substr($0,eq+1) -} -END{ - if(argtab["username"]==""||argtab["password"]==""||(urldecode(argtab["username"])==name&&urldecode(argtab["password"])==pass)) - exit ok - else - exit fail -} -# function urlencode(name,all, len,iii,escaped,ch) -# { - # len=length(name) - # escaped="" - # for(iii=1;iii<=len;++iii) - # { - # ch=substr(name,iii,1); - # if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all=="")) - # escaped = escaped ch - # else - # escaped = escaped "%" ch2hex[ch] - # } - # return escaped -# } -function urldecode(ht ,i,j,un,num) -{ - while ((i=match(ht, /%[0-9a-fA-F][0-9a-fA-F]/))!=0)# - { - un=un substr(ht, 1, i-1) - ht=substr(ht, i) - num=toupper(substr(ht, 2, 2)) - un=un hex2ch[num] - ht=substr(ht, 4) - } - un=un ht - return un -} diff --git a/view.awk b/view.awk deleted file mode 100644 index fcccc6d..0000000 --- a/view.awk +++ /dev/null @@ -1,59 +0,0 @@ -#// view.awk -#// insert text -#// 27.03.2015 -#// -#// Copyright (C) 2015 Balthasar Szczepañski -#// -#// This program is free software: you can redistribute it and/or modify -#// it under the terms of the GNU Affero 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 Affero General Public License for more details. -#// -#// You should have received a copy of the GNU Affero General Public License -#// along with this program. If not, see . - - -###reusedfrommirror; - -{ - # if ($0 ~ /^###sig&/) - # { - # split ($0 ,arr,"&") - # system("cat " sig arr[2]) - # } - # else if ($0 ~ /^###inf&/) - # { - # split ($0 ,arr,"&") - # system("cat " otterinf arr[2]) - # } - # else if ($0 ~ /^###prev/) - # { - # print left - # } - # else if ($0 ~ /^###next/) - # { - # print right - # } - # else if ($0 ~ /^###links/) - # { - # system ("cat " links); - # } - # else - if ($0 ~ /^###info/) - { - print info; - } - else if ($0 ~ /^###title/) - { - print title; - } - else - { - print $0 - } -};