]> bicyclesonthemoon.info Git - ott/enhance/commitdiff
Initial state as of 20.09.2015
authorb <rowerynaksiezycu@gmail.com>
Sun, 20 Sep 2015 12:00:00 +0000 (12:00 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sun, 20 Sep 2015 12:00:00 +0000 (12:00 +0000)
41 files changed:
agpl.txt [new file with mode: 0644]
bb2html.awk [new file with mode: 0644]
bot4.c [new file with mode: 0644]
click.c [new file with mode: 0644]
deliver.c [new file with mode: 0644]
findlatest.awk [new file with mode: 0644]
force.c [new file with mode: 0644]
generator.c [new file with mode: 0644]
lastpost.awk [new file with mode: 0644]
makefile [new file with mode: 0644]
mem/mome.txt [new file with mode: 0644]
mem/npb.png [new file with mode: 0644]
mome.awk [new file with mode: 0644]
mome.pl [new file with mode: 0755]
mpost.awk [new file with mode: 0644]
mpview.c [new file with mode: 0644]
mview.awk [new file with mode: 0644]
npb.cpp [new file with mode: 0644]
npbd.cpp [new file with mode: 0644]
ogdfparse.awk [new file with mode: 0644]
ong.c [new file with mode: 0644]
ongoing.awk [new file with mode: 0755]
ongtext.awk [new file with mode: 0644]
ongtext.c [new file with mode: 0644]
pleaseong.c [new file with mode: 0644]
post.awk [new file with mode: 0644]
post.cpp [new file with mode: 0644]
posted.awk [new file with mode: 0644]
posted.c [new file with mode: 0644]
preview.awk [new file with mode: 0644]
related.awk [new file with mode: 0644]
relink.c [new file with mode: 0644]
remove.c [new file with mode: 0644]
spoiler.c [new file with mode: 0644]
update.c [new file with mode: 0644]
view.awk [new file with mode: 0644]
view.c [new file with mode: 0644]
viewpage.c [new file with mode: 0644]
www/info.htm [new file with mode: 0644]
www/npb.htm [new file with mode: 0644]
www/post.htm [new file with mode: 0644]

diff --git a/agpl.txt b/agpl.txt
new file mode 100644 (file)
index 0000000..70eec1e
--- /dev/null
+++ b/agpl.txt
@@ -0,0 +1,661 @@
+                    GNU AFFERO GENERAL PUBLIC LICENSE\r
+                       Version 3, 19 November 2007\r
+\r
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\r
+ Everyone is permitted to copy and distribute verbatim copies\r
+ of this license document, but changing it is not allowed.\r
+\r
+                            Preamble\r
+\r
+  The GNU Affero General Public License is a free, copyleft license for\r
+software and other kinds of works, specifically designed to ensure\r
+cooperation with the community in the case of network server software.\r
+\r
+  The licenses for most software and other practical works are designed\r
+to take away your freedom to share and change the works.  By contrast,\r
+our General Public Licenses are intended to guarantee your freedom to\r
+share and change all versions of a program--to make sure it remains free\r
+software for all its users.\r
+\r
+  When we speak of free software, we are referring to freedom, not\r
+price.  Our General Public Licenses are designed to make sure that you\r
+have the freedom to distribute copies of free software (and charge for\r
+them if you wish), that you receive source code or can get it if you\r
+want it, that you can change the software or use pieces of it in new\r
+free programs, and that you know you can do these things.\r
+\r
+  Developers that use our General Public Licenses protect your rights\r
+with two steps: (1) assert copyright on the software, and (2) offer\r
+you this License which gives you legal permission to copy, distribute\r
+and/or modify the software.\r
+\r
+  A secondary benefit of defending all users' freedom is that\r
+improvements made in alternate versions of the program, if they\r
+receive widespread use, become available for other developers to\r
+incorporate.  Many developers of free software are heartened and\r
+encouraged by the resulting cooperation.  However, in the case of\r
+software used on network servers, this result may fail to come about.\r
+The GNU General Public License permits making a modified version and\r
+letting the public access it on a server without ever releasing its\r
+source code to the public.\r
+\r
+  The GNU Affero General Public License is designed specifically to\r
+ensure that, in such cases, the modified source code becomes available\r
+to the community.  It requires the operator of a network server to\r
+provide the source code of the modified version running there to the\r
+users of that server.  Therefore, public use of a modified version, on\r
+a publicly accessible server, gives the public access to the source\r
+code of the modified version.\r
+\r
+  An older license, called the Affero General Public License and\r
+published by Affero, was designed to accomplish similar goals.  This is\r
+a different license, not a version of the Affero GPL, but Affero has\r
+released a new version of the Affero GPL which permits relicensing under\r
+this license.\r
+\r
+  The precise terms and conditions for copying, distribution and\r
+modification follow.\r
+\r
+                       TERMS AND CONDITIONS\r
+\r
+  0. Definitions.\r
+\r
+  "This License" refers to version 3 of the GNU Affero General Public License.\r
+\r
+  "Copyright" also means copyright-like laws that apply to other kinds of\r
+works, such as semiconductor masks.\r
+\r
+  "The Program" refers to any copyrightable work licensed under this\r
+License.  Each licensee is addressed as "you".  "Licensees" and\r
+"recipients" may be individuals or organizations.\r
+\r
+  To "modify" a work means to copy from or adapt all or part of the work\r
+in a fashion requiring copyright permission, other than the making of an\r
+exact copy.  The resulting work is called a "modified version" of the\r
+earlier work or a work "based on" the earlier work.\r
+\r
+  A "covered work" means either the unmodified Program or a work based\r
+on the Program.\r
+\r
+  To "propagate" a work means to do anything with it that, without\r
+permission, would make you directly or secondarily liable for\r
+infringement under applicable copyright law, except executing it on a\r
+computer or modifying a private copy.  Propagation includes copying,\r
+distribution (with or without modification), making available to the\r
+public, and in some countries other activities as well.\r
+\r
+  To "convey" a work means any kind of propagation that enables other\r
+parties to make or receive copies.  Mere interaction with a user through\r
+a computer network, with no transfer of a copy, is not conveying.\r
+\r
+  An interactive user interface displays "Appropriate Legal Notices"\r
+to the extent that it includes a convenient and prominently visible\r
+feature that (1) displays an appropriate copyright notice, and (2)\r
+tells the user that there is no warranty for the work (except to the\r
+extent that warranties are provided), that licensees may convey the\r
+work under this License, and how to view a copy of this License.  If\r
+the interface presents a list of user commands or options, such as a\r
+menu, a prominent item in the list meets this criterion.\r
+\r
+  1. Source Code.\r
+\r
+  The "source code" for a work means the preferred form of the work\r
+for making modifications to it.  "Object code" means any non-source\r
+form of a work.\r
+\r
+  A "Standard Interface" means an interface that either is an official\r
+standard defined by a recognized standards body, or, in the case of\r
+interfaces specified for a particular programming language, one that\r
+is widely used among developers working in that language.\r
+\r
+  The "System Libraries" of an executable work include anything, other\r
+than the work as a whole, that (a) is included in the normal form of\r
+packaging a Major Component, but which is not part of that Major\r
+Component, and (b) serves only to enable use of the work with that\r
+Major Component, or to implement a Standard Interface for which an\r
+implementation is available to the public in source code form.  A\r
+"Major Component", in this context, means a major essential component\r
+(kernel, window system, and so on) of the specific operating system\r
+(if any) on which the executable work runs, or a compiler used to\r
+produce the work, or an object code interpreter used to run it.\r
+\r
+  The "Corresponding Source" for a work in object code form means all\r
+the source code needed to generate, install, and (for an executable\r
+work) run the object code and to modify the work, including scripts to\r
+control those activities.  However, it does not include the work's\r
+System Libraries, or general-purpose tools or generally available free\r
+programs which are used unmodified in performing those activities but\r
+which are not part of the work.  For example, Corresponding Source\r
+includes interface definition files associated with source files for\r
+the work, and the source code for shared libraries and dynamically\r
+linked subprograms that the work is specifically designed to require,\r
+such as by intimate data communication or control flow between those\r
+subprograms and other parts of the work.\r
+\r
+  The Corresponding Source need not include anything that users\r
+can regenerate automatically from other parts of the Corresponding\r
+Source.\r
+\r
+  The Corresponding Source for a work in source code form is that\r
+same work.\r
+\r
+  2. Basic Permissions.\r
+\r
+  All rights granted under this License are granted for the term of\r
+copyright on the Program, and are irrevocable provided the stated\r
+conditions are met.  This License explicitly affirms your unlimited\r
+permission to run the unmodified Program.  The output from running a\r
+covered work is covered by this License only if the output, given its\r
+content, constitutes a covered work.  This License acknowledges your\r
+rights of fair use or other equivalent, as provided by copyright law.\r
+\r
+  You may make, run and propagate covered works that you do not\r
+convey, without conditions so long as your license otherwise remains\r
+in force.  You may convey covered works to others for the sole purpose\r
+of having them make modifications exclusively for you, or provide you\r
+with facilities for running those works, provided that you comply with\r
+the terms of this License in conveying all material for which you do\r
+not control copyright.  Those thus making or running the covered works\r
+for you must do so exclusively on your behalf, under your direction\r
+and control, on terms that prohibit them from making any copies of\r
+your copyrighted material outside their relationship with you.\r
+\r
+  Conveying under any other circumstances is permitted solely under\r
+the conditions stated below.  Sublicensing is not allowed; section 10\r
+makes it unnecessary.\r
+\r
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\r
+\r
+  No covered work shall be deemed part of an effective technological\r
+measure under any applicable law fulfilling obligations under article\r
+11 of the WIPO copyright treaty adopted on 20 December 1996, or\r
+similar laws prohibiting or restricting circumvention of such\r
+measures.\r
+\r
+  When you convey a covered work, you waive any legal power to forbid\r
+circumvention of technological measures to the extent such circumvention\r
+is effected by exercising rights under this License with respect to\r
+the covered work, and you disclaim any intention to limit operation or\r
+modification of the work as a means of enforcing, against the work's\r
+users, your or third parties' legal rights to forbid circumvention of\r
+technological measures.\r
+\r
+  4. Conveying Verbatim Copies.\r
+\r
+  You may convey verbatim copies of the Program's source code as you\r
+receive it, in any medium, provided that you conspicuously and\r
+appropriately publish on each copy an appropriate copyright notice;\r
+keep intact all notices stating that this License and any\r
+non-permissive terms added in accord with section 7 apply to the code;\r
+keep intact all notices of the absence of any warranty; and give all\r
+recipients a copy of this License along with the Program.\r
+\r
+  You may charge any price or no price for each copy that you convey,\r
+and you may offer support or warranty protection for a fee.\r
+\r
+  5. Conveying Modified Source Versions.\r
+\r
+  You may convey a work based on the Program, or the modifications to\r
+produce it from the Program, in the form of source code under the\r
+terms of section 4, provided that you also meet all of these conditions:\r
+\r
+    a) The work must carry prominent notices stating that you modified\r
+    it, and giving a relevant date.\r
+\r
+    b) The work must carry prominent notices stating that it is\r
+    released under this License and any conditions added under section\r
+    7.  This requirement modifies the requirement in section 4 to\r
+    "keep intact all notices".\r
+\r
+    c) You must license the entire work, as a whole, under this\r
+    License to anyone who comes into possession of a copy.  This\r
+    License will therefore apply, along with any applicable section 7\r
+    additional terms, to the whole of the work, and all its parts,\r
+    regardless of how they are packaged.  This License gives no\r
+    permission to license the work in any other way, but it does not\r
+    invalidate such permission if you have separately received it.\r
+\r
+    d) If the work has interactive user interfaces, each must display\r
+    Appropriate Legal Notices; however, if the Program has interactive\r
+    interfaces that do not display Appropriate Legal Notices, your\r
+    work need not make them do so.\r
+\r
+  A compilation of a covered work with other separate and independent\r
+works, which are not by their nature extensions of the covered work,\r
+and which are not combined with it such as to form a larger program,\r
+in or on a volume of a storage or distribution medium, is called an\r
+"aggregate" if the compilation and its resulting copyright are not\r
+used to limit the access or legal rights of the compilation's users\r
+beyond what the individual works permit.  Inclusion of a covered work\r
+in an aggregate does not cause this License to apply to the other\r
+parts of the aggregate.\r
+\r
+  6. Conveying Non-Source Forms.\r
+\r
+  You may convey a covered work in object code form under the terms\r
+of sections 4 and 5, provided that you also convey the\r
+machine-readable Corresponding Source under the terms of this License,\r
+in one of these ways:\r
+\r
+    a) Convey the object code in, or embodied in, a physical product\r
+    (including a physical distribution medium), accompanied by the\r
+    Corresponding Source fixed on a durable physical medium\r
+    customarily used for software interchange.\r
+\r
+    b) Convey the object code in, or embodied in, a physical product\r
+    (including a physical distribution medium), accompanied by a\r
+    written offer, valid for at least three years and valid for as\r
+    long as you offer spare parts or customer support for that product\r
+    model, to give anyone who possesses the object code either (1) a\r
+    copy of the Corresponding Source for all the software in the\r
+    product that is covered by this License, on a durable physical\r
+    medium customarily used for software interchange, for a price no\r
+    more than your reasonable cost of physically performing this\r
+    conveying of source, or (2) access to copy the\r
+    Corresponding Source from a network server at no charge.\r
+\r
+    c) Convey individual copies of the object code with a copy of the\r
+    written offer to provide the Corresponding Source.  This\r
+    alternative is allowed only occasionally and noncommercially, and\r
+    only if you received the object code with such an offer, in accord\r
+    with subsection 6b.\r
+\r
+    d) Convey the object code by offering access from a designated\r
+    place (gratis or for a charge), and offer equivalent access to the\r
+    Corresponding Source in the same way through the same place at no\r
+    further charge.  You need not require recipients to copy the\r
+    Corresponding Source along with the object code.  If the place to\r
+    copy the object code is a network server, the Corresponding Source\r
+    may be on a different server (operated by you or a third party)\r
+    that supports equivalent copying facilities, provided you maintain\r
+    clear directions next to the object code saying where to find the\r
+    Corresponding Source.  Regardless of what server hosts the\r
+    Corresponding Source, you remain obligated to ensure that it is\r
+    available for as long as needed to satisfy these requirements.\r
+\r
+    e) Convey the object code using peer-to-peer transmission, provided\r
+    you inform other peers where the object code and Corresponding\r
+    Source of the work are being offered to the general public at no\r
+    charge under subsection 6d.\r
+\r
+  A separable portion of the object code, whose source code is excluded\r
+from the Corresponding Source as a System Library, need not be\r
+included in conveying the object code work.\r
+\r
+  A "User Product" is either (1) a "consumer product", which means any\r
+tangible personal property which is normally used for personal, family,\r
+or household purposes, or (2) anything designed or sold for incorporation\r
+into a dwelling.  In determining whether a product is a consumer product,\r
+doubtful cases shall be resolved in favor of coverage.  For a particular\r
+product received by a particular user, "normally used" refers to a\r
+typical or common use of that class of product, regardless of the status\r
+of the particular user or of the way in which the particular user\r
+actually uses, or expects or is expected to use, the product.  A product\r
+is a consumer product regardless of whether the product has substantial\r
+commercial, industrial or non-consumer uses, unless such uses represent\r
+the only significant mode of use of the product.\r
+\r
+  "Installation Information" for a User Product means any methods,\r
+procedures, authorization keys, or other information required to install\r
+and execute modified versions of a covered work in that User Product from\r
+a modified version of its Corresponding Source.  The information must\r
+suffice to ensure that the continued functioning of the modified object\r
+code is in no case prevented or interfered with solely because\r
+modification has been made.\r
+\r
+  If you convey an object code work under this section in, or with, or\r
+specifically for use in, a User Product, and the conveying occurs as\r
+part of a transaction in which the right of possession and use of the\r
+User Product is transferred to the recipient in perpetuity or for a\r
+fixed term (regardless of how the transaction is characterized), the\r
+Corresponding Source conveyed under this section must be accompanied\r
+by the Installation Information.  But this requirement does not apply\r
+if neither you nor any third party retains the ability to install\r
+modified object code on the User Product (for example, the work has\r
+been installed in ROM).\r
+\r
+  The requirement to provide Installation Information does not include a\r
+requirement to continue to provide support service, warranty, or updates\r
+for a work that has been modified or installed by the recipient, or for\r
+the User Product in which it has been modified or installed.  Access to a\r
+network may be denied when the modification itself materially and\r
+adversely affects the operation of the network or violates the rules and\r
+protocols for communication across the network.\r
+\r
+  Corresponding Source conveyed, and Installation Information provided,\r
+in accord with this section must be in a format that is publicly\r
+documented (and with an implementation available to the public in\r
+source code form), and must require no special password or key for\r
+unpacking, reading or copying.\r
+\r
+  7. Additional Terms.\r
+\r
+  "Additional permissions" are terms that supplement the terms of this\r
+License by making exceptions from one or more of its conditions.\r
+Additional permissions that are applicable to the entire Program shall\r
+be treated as though they were included in this License, to the extent\r
+that they are valid under applicable law.  If additional permissions\r
+apply only to part of the Program, that part may be used separately\r
+under those permissions, but the entire Program remains governed by\r
+this License without regard to the additional permissions.\r
+\r
+  When you convey a copy of a covered work, you may at your option\r
+remove any additional permissions from that copy, or from any part of\r
+it.  (Additional permissions may be written to require their own\r
+removal in certain cases when you modify the work.)  You may place\r
+additional permissions on material, added by you to a covered work,\r
+for which you have or can give appropriate copyright permission.\r
+\r
+  Notwithstanding any other provision of this License, for material you\r
+add to a covered work, you may (if authorized by the copyright holders of\r
+that material) supplement the terms of this License with terms:\r
+\r
+    a) Disclaiming warranty or limiting liability differently from the\r
+    terms of sections 15 and 16 of this License; or\r
+\r
+    b) Requiring preservation of specified reasonable legal notices or\r
+    author attributions in that material or in the Appropriate Legal\r
+    Notices displayed by works containing it; or\r
+\r
+    c) Prohibiting misrepresentation of the origin of that material, or\r
+    requiring that modified versions of such material be marked in\r
+    reasonable ways as different from the original version; or\r
+\r
+    d) Limiting the use for publicity purposes of names of licensors or\r
+    authors of the material; or\r
+\r
+    e) Declining to grant rights under trademark law for use of some\r
+    trade names, trademarks, or service marks; or\r
+\r
+    f) Requiring indemnification of licensors and authors of that\r
+    material by anyone who conveys the material (or modified versions of\r
+    it) with contractual assumptions of liability to the recipient, for\r
+    any liability that these contractual assumptions directly impose on\r
+    those licensors and authors.\r
+\r
+  All other non-permissive additional terms are considered "further\r
+restrictions" within the meaning of section 10.  If the Program as you\r
+received it, or any part of it, contains a notice stating that it is\r
+governed by this License along with a term that is a further\r
+restriction, you may remove that term.  If a license document contains\r
+a further restriction but permits relicensing or conveying under this\r
+License, you may add to a covered work material governed by the terms\r
+of that license document, provided that the further restriction does\r
+not survive such relicensing or conveying.\r
+\r
+  If you add terms to a covered work in accord with this section, you\r
+must place, in the relevant source files, a statement of the\r
+additional terms that apply to those files, or a notice indicating\r
+where to find the applicable terms.\r
+\r
+  Additional terms, permissive or non-permissive, may be stated in the\r
+form of a separately written license, or stated as exceptions;\r
+the above requirements apply either way.\r
+\r
+  8. Termination.\r
+\r
+  You may not propagate or modify a covered work except as expressly\r
+provided under this License.  Any attempt otherwise to propagate or\r
+modify it is void, and will automatically terminate your rights under\r
+this License (including any patent licenses granted under the third\r
+paragraph of section 11).\r
+\r
+  However, if you cease all violation of this License, then your\r
+license from a particular copyright holder is reinstated (a)\r
+provisionally, unless and until the copyright holder explicitly and\r
+finally terminates your license, and (b) permanently, if the copyright\r
+holder fails to notify you of the violation by some reasonable means\r
+prior to 60 days after the cessation.\r
+\r
+  Moreover, your license from a particular copyright holder is\r
+reinstated permanently if the copyright holder notifies you of the\r
+violation by some reasonable means, this is the first time you have\r
+received notice of violation of this License (for any work) from that\r
+copyright holder, and you cure the violation prior to 30 days after\r
+your receipt of the notice.\r
+\r
+  Termination of your rights under this section does not terminate the\r
+licenses of parties who have received copies or rights from you under\r
+this License.  If your rights have been terminated and not permanently\r
+reinstated, you do not qualify to receive new licenses for the same\r
+material under section 10.\r
+\r
+  9. Acceptance Not Required for Having Copies.\r
+\r
+  You are not required to accept this License in order to receive or\r
+run a copy of the Program.  Ancillary propagation of a covered work\r
+occurring solely as a consequence of using peer-to-peer transmission\r
+to receive a copy likewise does not require acceptance.  However,\r
+nothing other than this License grants you permission to propagate or\r
+modify any covered work.  These actions infringe copyright if you do\r
+not accept this License.  Therefore, by modifying or propagating a\r
+covered work, you indicate your acceptance of this License to do so.\r
+\r
+  10. Automatic Licensing of Downstream Recipients.\r
+\r
+  Each time you convey a covered work, the recipient automatically\r
+receives a license from the original licensors, to run, modify and\r
+propagate that work, subject to this License.  You are not responsible\r
+for enforcing compliance by third parties with this License.\r
+\r
+  An "entity transaction" is a transaction transferring control of an\r
+organization, or substantially all assets of one, or subdividing an\r
+organization, or merging organizations.  If propagation of a covered\r
+work results from an entity transaction, each party to that\r
+transaction who receives a copy of the work also receives whatever\r
+licenses to the work the party's predecessor in interest had or could\r
+give under the previous paragraph, plus a right to possession of the\r
+Corresponding Source of the work from the predecessor in interest, if\r
+the predecessor has it or can get it with reasonable efforts.\r
+\r
+  You may not impose any further restrictions on the exercise of the\r
+rights granted or affirmed under this License.  For example, you may\r
+not impose a license fee, royalty, or other charge for exercise of\r
+rights granted under this License, and you may not initiate litigation\r
+(including a cross-claim or counterclaim in a lawsuit) alleging that\r
+any patent claim is infringed by making, using, selling, offering for\r
+sale, or importing the Program or any portion of it.\r
+\r
+  11. Patents.\r
+\r
+  A "contributor" is a copyright holder who authorizes use under this\r
+License of the Program or a work on which the Program is based.  The\r
+work thus licensed is called the contributor's "contributor version".\r
+\r
+  A contributor's "essential patent claims" are all patent claims\r
+owned or controlled by the contributor, whether already acquired or\r
+hereafter acquired, that would be infringed by some manner, permitted\r
+by this License, of making, using, or selling its contributor version,\r
+but do not include claims that would be infringed only as a\r
+consequence of further modification of the contributor version.  For\r
+purposes of this definition, "control" includes the right to grant\r
+patent sublicenses in a manner consistent with the requirements of\r
+this License.\r
+\r
+  Each contributor grants you a non-exclusive, worldwide, royalty-free\r
+patent license under the contributor's essential patent claims, to\r
+make, use, sell, offer for sale, import and otherwise run, modify and\r
+propagate the contents of its contributor version.\r
+\r
+  In the following three paragraphs, a "patent license" is any express\r
+agreement or commitment, however denominated, not to enforce a patent\r
+(such as an express permission to practice a patent or covenant not to\r
+sue for patent infringement).  To "grant" such a patent license to a\r
+party means to make such an agreement or commitment not to enforce a\r
+patent against the party.\r
+\r
+  If you convey a covered work, knowingly relying on a patent license,\r
+and the Corresponding Source of the work is not available for anyone\r
+to copy, free of charge and under the terms of this License, through a\r
+publicly available network server or other readily accessible means,\r
+then you must either (1) cause the Corresponding Source to be so\r
+available, or (2) arrange to deprive yourself of the benefit of the\r
+patent license for this particular work, or (3) arrange, in a manner\r
+consistent with the requirements of this License, to extend the patent\r
+license to downstream recipients.  "Knowingly relying" means you have\r
+actual knowledge that, but for the patent license, your conveying the\r
+covered work in a country, or your recipient's use of the covered work\r
+in a country, would infringe one or more identifiable patents in that\r
+country that you have reason to believe are valid.\r
+\r
+  If, pursuant to or in connection with a single transaction or\r
+arrangement, you convey, or propagate by procuring conveyance of, a\r
+covered work, and grant a patent license to some of the parties\r
+receiving the covered work authorizing them to use, propagate, modify\r
+or convey a specific copy of the covered work, then the patent license\r
+you grant is automatically extended to all recipients of the covered\r
+work and works based on it.\r
+\r
+  A patent license is "discriminatory" if it does not include within\r
+the scope of its coverage, prohibits the exercise of, or is\r
+conditioned on the non-exercise of one or more of the rights that are\r
+specifically granted under this License.  You may not convey a covered\r
+work if you are a party to an arrangement with a third party that is\r
+in the business of distributing software, under which you make payment\r
+to the third party based on the extent of your activity of conveying\r
+the work, and under which the third party grants, to any of the\r
+parties who would receive the covered work from you, a discriminatory\r
+patent license (a) in connection with copies of the covered work\r
+conveyed by you (or copies made from those copies), or (b) primarily\r
+for and in connection with specific products or compilations that\r
+contain the covered work, unless you entered into that arrangement,\r
+or that patent license was granted, prior to 28 March 2007.\r
+\r
+  Nothing in this License shall be construed as excluding or limiting\r
+any implied license or other defenses to infringement that may\r
+otherwise be available to you under applicable patent law.\r
+\r
+  12. No Surrender of Others' Freedom.\r
+\r
+  If conditions are imposed on you (whether by court order, agreement or\r
+otherwise) that contradict the conditions of this License, they do not\r
+excuse you from the conditions of this License.  If you cannot convey a\r
+covered work so as to satisfy simultaneously your obligations under this\r
+License and any other pertinent obligations, then as a consequence you may\r
+not convey it at all.  For example, if you agree to terms that obligate you\r
+to collect a royalty for further conveying from those to whom you convey\r
+the Program, the only way you could satisfy both those terms and this\r
+License would be to refrain entirely from conveying the Program.\r
+\r
+  13. Remote Network Interaction; Use with the GNU General Public License.\r
+\r
+  Notwithstanding any other provision of this License, if you modify the\r
+Program, your modified version must prominently offer all users\r
+interacting with it remotely through a computer network (if your version\r
+supports such interaction) an opportunity to receive the Corresponding\r
+Source of your version by providing access to the Corresponding Source\r
+from a network server at no charge, through some standard or customary\r
+means of facilitating copying of software.  This Corresponding Source\r
+shall include the Corresponding Source for any work covered by version 3\r
+of the GNU General Public License that is incorporated pursuant to the\r
+following paragraph.\r
+\r
+  Notwithstanding any other provision of this License, you have\r
+permission to link or combine any covered work with a work licensed\r
+under version 3 of the GNU General Public License into a single\r
+combined work, and to convey the resulting work.  The terms of this\r
+License will continue to apply to the part which is the covered work,\r
+but the work with which it is combined will remain governed by version\r
+3 of the GNU General Public License.\r
+\r
+  14. Revised Versions of this License.\r
+\r
+  The Free Software Foundation may publish revised and/or new versions of\r
+the GNU Affero General Public License from time to time.  Such new versions\r
+will be similar in spirit to the present version, but may differ in detail to\r
+address new problems or concerns.\r
+\r
+  Each version is given a distinguishing version number.  If the\r
+Program specifies that a certain numbered version of the GNU Affero General\r
+Public License "or any later version" applies to it, you have the\r
+option of following the terms and conditions either of that numbered\r
+version or of any later version published by the Free Software\r
+Foundation.  If the Program does not specify a version number of the\r
+GNU Affero General Public License, you may choose any version ever published\r
+by the Free Software Foundation.\r
+\r
+  If the Program specifies that a proxy can decide which future\r
+versions of the GNU Affero General Public License can be used, that proxy's\r
+public statement of acceptance of a version permanently authorizes you\r
+to choose that version for the Program.\r
+\r
+  Later license versions may give you additional or different\r
+permissions.  However, no additional obligations are imposed on any\r
+author or copyright holder as a result of your choosing to follow a\r
+later version.\r
+\r
+  15. Disclaimer of Warranty.\r
+\r
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\r
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\r
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\r
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\r
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\r
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\r
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\r
+\r
+  16. Limitation of Liability.\r
+\r
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\r
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\r
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\r
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\r
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\r
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\r
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\r
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\r
+SUCH DAMAGES.\r
+\r
+  17. Interpretation of Sections 15 and 16.\r
+\r
+  If the disclaimer of warranty and limitation of liability provided\r
+above cannot be given local legal effect according to their terms,\r
+reviewing courts shall apply local law that most closely approximates\r
+an absolute waiver of all civil liability in connection with the\r
+Program, unless a warranty or assumption of liability accompanies a\r
+copy of the Program in return for a fee.\r
+\r
+                     END OF TERMS AND CONDITIONS\r
+\r
+            How to Apply These Terms to Your New Programs\r
+\r
+  If you develop a new program, and you want it to be of the greatest\r
+possible use to the public, the best way to achieve this is to make it\r
+free software which everyone can redistribute and change under these terms.\r
+\r
+  To do so, attach the following notices to the program.  It is safest\r
+to attach them to the start of each source file to most effectively\r
+state the exclusion of warranty; and each file should have at least\r
+the "copyright" line and a pointer to where the full notice is found.\r
+\r
+    <one line to give the program's name and a brief idea of what it does.>\r
+    Copyright (C) <year>  <name of author>\r
+\r
+    This program is free software: you can redistribute it and/or modify\r
+    it under the terms of the GNU Affero General Public License as published by\r
+    the Free Software Foundation, either version 3 of the License, or\r
+    (at your option) any later version.\r
+\r
+    This program is distributed in the hope that it will be useful,\r
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+    GNU Affero General Public License for more details.\r
+\r
+    You should have received a copy of the GNU Affero General Public License\r
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+Also add information on how to contact you by electronic and paper mail.\r
+\r
+  If your software can interact with users remotely through a computer\r
+network, you should also make sure that it provides a way for users to\r
+get its source.  For example, if your program is a web application, its\r
+interface could display a "Source" link that leads users to an archive\r
+of the code.  There are many ways you could offer source, and different\r
+solutions will be better for different programs; see section 13 for the\r
+specific requirements.\r
+\r
+  You should also get your employer (if you work as a programmer) or school,\r
+if any, to sign a "copyright disclaimer" for the program, if necessary.\r
+For more information on this, and how to apply and follow the GNU AGPL, see\r
+<http://www.gnu.org/licenses/>.\r
diff --git a/bb2html.awk b/bb2html.awk
new file mode 100644 (file)
index 0000000..f7faa35
--- /dev/null
@@ -0,0 +1,541 @@
+#// bb2html.awk\r
+#// converts bbcode to html.\r
+#// 30.03.2015\r
+#// \r
+#// Copyright (C) 2015  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       FS="="\r
+       debug="debug=bb2html.awk:"\r
+};\r
+{\r
+       eq=index($0,"=")\r
+       argtab[substr($0,1,eq-1)]=substr($0,eq+1)\r
+};\r
+END{\r
+       if(argtab["disable_bbcode"]!="")\r
+       {\r
+               debug=debug"###nl;BBcode disabled"\r
+               print debug>>outfile\r
+               exit 0\r
+       }\r
+       text=argtab["BB"]\r
+       html=bb2html(text)\r
+       print "HTML="html>>outfile\r
+       print debug>>outfile\r
+};\r
+\r
+function bb2html(text,   depth,count,bbtree,html,tag,tagstart,taglength,elm,tagv,tagname,tagvalue,matchname)\r
+{\r
+       depth=0\r
+       count[0]=1\r
+       bbtree["0"]=""\r
+       bbtree["0.n"]=0\r
+       bbtree["0.t"]="post"\r
+       bbtree["0.v"]=argtab["subject"]\r
+       html=""\r
+       gsub(/&#61;/,"=",text)\r
+       debug = debug "###nl;###nl;Build BBcode tree:"\r
+       while(length(text)!=0)\r
+       {\r
+               tag=match(text, /\[\/?[a-z0-9\*]+(=(([^\[<>\"\]]*)|(\"[^\"<>]*\")))?\]/)\r
+               #"#\""\r
+               # debug = debug "###nl;" RSTART " " RLENGTH\r
+               if (tag==0)\r
+               {\r
+                       debug = debug "###nl;text: " text\r
+                       bbtree[ind(count,depth)]=text\r
+                       bbtree[indt(count,depth)".n"]=count[depth]\r
+                       ++count[depth]\r
+                       text=""\r
+                       break;\r
+               }\r
+               tagstart=RSTART\r
+               taglength=RLENGTH\r
+               if(tagstart>1)\r
+               {\r
+                       elm=substr(text,1,tagstart-1)\r
+                       debug = debug "###nl;text: " elm\r
+                       bbtree[ind(count,depth)]=elm\r
+                       bbtree[indt(count,depth)".n"]=count[depth]\r
+                       ++count[depth]\r
+               }\r
+               tag=substr(text,tagstart,taglength)\r
+               text=substr(text,tagstart+taglength)\r
+               debug = debug "###nl;tag: " tag\r
+               if(tag!~/^\[\//)\r
+               {\r
+                       tagv=index(tag,"=")\r
+                       if(tagv<2)\r
+                       {\r
+                               tagname=substr(tag,2,length(tag)-2)\r
+                               tagvalue=""\r
+                       }\r
+                       else\r
+                       {\r
+                               tagname=substr(tag,2,tagv-2)\r
+                               tagvalue=substr(tag,tagv+1,length(tag)-tagv-1)\r
+                       }\r
+                       if(tagname !~ /^((quote)|b|i|u|(code)|(img)|(url)|(size)|(color)|(center)|(right)|(sub)|(sup)|(s)|(spoiler)|(list)|(\*))$/)\r
+                       {\r
+                               debug = debug "###nl;unknown tag"\r
+                               bbtree[ind(count,depth)]=tag\r
+                               bbtree[indt(count,depth)".n"]=count[depth]\r
+                               ++count[depth]\r
+                               continue\r
+                       }\r
+                       if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||bbtree[indt(count,depth)".t"] == "img"||(bbtree[indt(count,depth)".t"] == "size" && tagname=="size"))\r
+                       {\r
+                               debug = debug "###nl;this tag forbidden here"\r
+                               bbtree[ind(count,depth)]=tag\r
+                               bbtree[indt(count,depth)".n"]=count[depth]\r
+                               ++count[depth]\r
+                               continue\r
+                       }\r
+                       if(tagname=="*")\r
+                       {\r
+                               if(bbtree[indt(count,depth)".t"]==tagname)\r
+                               {\r
+                                       debug = debug "###nl;implied tag: [/"tagname"]"\r
+                                       debug = debug "###nl;matched"\r
+                                       bbtree[ind(count,depth)]="[/"tagname"]"\r
+                                       bbtree[ind(count,depth)".k"]="e"\r
+                                       bbtree[ind(count,depth)".m"]=1\r
+                                       bbtree[ind(count,depth)".t"]=tagname\r
+                                       bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"]\r
+                                       bbtree[indt(count,depth)".n"]=count[depth]\r
+                                       bbtree[indt(count,depth)".m"]=1\r
+                                       count[depth]=""\r
+                                       --depth\r
+                                       ++count[depth]\r
+                               }\r
+                               else if(bbtree[indt(count,depth)".t"]!="list")\r
+                               {\r
+                                       debug = debug "###nl;this tag forbidden here"\r
+                                       bbtree[ind(count,depth)]=tag\r
+                                       bbtree[indt(count,depth)".n"]=count[depth]\r
+                                       ++count[depth]\r
+                                       continue\r
+                               }\r
+                       }\r
+                       debug = debug "###nl;name: " tagname " value: " tagvalue\r
+                       bbtree[ind(count,depth)]=tagname" "tagvalue\r
+                       bbtree[ind(count,depth)".k"]="s"\r
+                       bbtree[indt(count,depth)".n"]=count[depth]\r
+                       ++depth\r
+                       count[depth]=1\r
+                       bbtree[indt(count,depth)]=tag\r
+                       bbtree[indt(count,depth)".n"]=0\r
+                       bbtree[indt(count,depth)".t"]=tagname\r
+                       bbtree[indt(count,depth)".v"]=tagvalue\r
+               }\r
+               else\r
+               {\r
+                       if(depth<=0)\r
+                       {\r
+                               debug = debug "###nl;""unmatched"\r
+                               bbtree[ind(count,depth)]=tag\r
+                               bbtree[indt(count,depth)".n"]=count[depth]\r
+                               ++count[depth]\r
+                               continue\r
+                       }\r
+                       tagname=substr(tag,3,length(tag)-3)\r
+                       if(tagname=="list"&&bbtree[indt(count,depth)".t"]=="*")\r
+                       {\r
+                               debug = debug "###nl;implied tag: [/*]"\r
+                               debug = debug "###nl;matched"\r
+                               bbtree[ind(count,depth)]="[/*]"\r
+                               bbtree[ind(count,depth)".k"]="e"\r
+                               bbtree[ind(count,depth)".m"]=1\r
+                               bbtree[ind(count,depth)".t"]="*"\r
+                               bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"]\r
+                               bbtree[indt(count,depth)".n"]=count[depth]\r
+                               bbtree[indt(count,depth)".m"]=1\r
+                               count[depth]=""\r
+                               --depth\r
+                               ++count[depth]\r
+                       }\r
+                       debug = debug "###nl;name: " tagname\r
+                       matchname=bbtree[indt(count,depth)".t"]\r
+                       if((bbtree[indt(count,depth)".t"] == "code" && tagname!="code")||(bbtree[indt(count,depth)".t"] == "img" && tagname != "img"))\r
+                       {\r
+                               debug = debug "###nl;this tag forbidden here"\r
+                               bbtree[ind(count,depth)]=tag\r
+                               bbtree[indt(count,depth)".n"]=count[depth]\r
+                               ++count[depth]\r
+                               continue\r
+                       }\r
+                       if(tagname!=matchname)\r
+                       {\r
+                               debug = debug "###nl;mismatched: " matchname\r
+                               # bbtree[ind(count,depth)]=tag\r
+                               # bbtree[indt(count,depth)".n"]=count[depth]\r
+                               # ++count[depth]\r
+                               # continue\r
+                               bbtree[ind(count,depth)]=tag\r
+                               bbtree[ind(count,depth)".k"]="e"\r
+                               bbtree[ind(count,depth)".t"]=bbtree[indt(count,depth)".t"]\r
+                               bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"]\r
+                               bbtree[indt(count,depth)".n"]=count[depth]\r
+                               count[depth]=""\r
+                               --depth\r
+                               ++count[depth]\r
+                               continue\r
+                       }\r
+                       debug = debug "###nl;matched"\r
+                       bbtree[ind(count,depth)]=tag\r
+                       bbtree[ind(count,depth)".k"]="e"\r
+                       bbtree[ind(count,depth)".m"]=1\r
+                       bbtree[ind(count,depth)".t"]=tagname\r
+                       bbtree[ind(count,depth)".v"]=bbtree[indt(count,depth)".v"]\r
+                       bbtree[indt(count,depth)".n"]=count[depth]\r
+                       bbtree[indt(count,depth)".m"]=1\r
+                       count[depth]=""\r
+                       --depth\r
+                       ++count[depth]\r
+               }\r
+       }\r
+       if(depth>0)\r
+               debug = debug "###nl;unclosed tags: " depth\r
+       \r
+       debug = debug "###nl;###nl;""generate HTML:"\r
+       depth=0\r
+       count[0]=0\r
+       while(count[0]<=bbtree["0.n"]&&depth>=0)\r
+       {\r
+               if(count[depth]==0)\r
+               {\r
+                       tag=bbtree[indt(count,depth)]\r
+                       tagname=bbtree[indt(count,depth)".t"]\r
+                       tagvalue=bbtree[indt(count,depth)".v"]\r
+                       debug = debug "###nl;name: "tagname" value: "tagvalue" elements: "bbtree[indt(count,depth)".n"]\r
+                       if(tagname == "post")\r
+                       {\r
+                       }\r
+                       else if(bbtree[indt(count,depth)".m"]=="")\r
+                       {\r
+                               debug = debug "###nl;unmatched"\r
+                               html = html tag\r
+                       }\r
+                       else if(tagname == "quote")\r
+                       {\r
+                               if (tagvalue=="")\r
+                               {\r
+                                       html = html "<blockquote class=\"pq\"><div>"\r
+                               }\r
+                               else\r
+                               {\r
+                                       if(tagvalue !~ /^\".*\"$/)\r
+                                       #"#\""\r
+                                               tagvalue="You forgot about the quote marks, "tagvalue\r
+                                       else\r
+                                               tagvalue=bb2html(substr(tagvalue,2,length(tagvalue)-2))\r
+                                       html = html "<blockquote class=\"pq\"><div><cite class=\"pq\"><b class=\"br\">"tagvalue"</b> wrote:</cite><br>"\r
+                               }\r
+                       }\r
+                       else if (tagname == "b")\r
+                       {\r
+                               html = html"<span style=\"font-weight: bold\">"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. " \r
+                       }\r
+                       else if (tagname == "i")\r
+                       {\r
+                               html = html"<span style=\"font-style: italic\">"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. " \r
+                       }\r
+                       else if (tagname == "u")\r
+                       {\r
+                               html = html"<span style=\"text-decoration: underline\">"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. " \r
+                       }\r
+                       else if (tagname == "code")\r
+                       {\r
+                               if(bbtree[indtu(count,depth)".t"] == "code")\r
+                               {\r
+                                       html=html tag\r
+                                       debug = debug "###nl;not a tag, actually"\r
+                               }\r
+                               else\r
+                               {\r
+                                       html=html"<dl class=\"pq\"><dt class=\"pq\">Code: <a href=\"#\" onclick=\"selectCode(this); return false;\">Select all</a></dt><dd><code class=\"pq\">"\r
+                                       if(tagvalue!="")\r
+                                               html=html"This tag shouldn't have any value. "\r
+                               }\r
+                       }\r
+                       else if (tagname == "img")\r
+                               html=html"<img src=\""\r
+                       else if (tagname == "url")\r
+                       {\r
+                               if(tagvalue=="")\r
+                               {\r
+                                       ++count[depth]\r
+                                       tagvalue=bbtree[ind(count,depth)]\r
+                                       --count[depth]\r
+                                       debug = debug "###nl;implied value: " tagvalue\r
+                               }\r
+                               html=html"<a href=\""tagvalue"\" class=\"postlink\">"\r
+                       }\r
+                       else if (tagname == "size")\r
+                       {\r
+                               if (tagvalue==""||(tagvalue !~ /^[0-9]+$/)||(tagvalue+0)>200)\r
+                                       html=html"<span style=\"font-size: 130%; line-height: 116%;\"> This tag should have a correct value. "\r
+                               else\r
+                                       html=html"<span style=\"font-size: "tagvalue"%; line-height: 116%;\">"\r
+                       }\r
+                       else if (tagname == "color")\r
+                       {\r
+                               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.\r
+                                       html=html"<span style=\"color: #EE0000\"> This tag should have a correct value. "\r
+                               else\r
+                                       html=html"<span style=\"color: "tagvalue"\">"\r
+                       }\r
+                       else if (tagname ~ /^((center)|(right))$/)\r
+                       {\r
+                               html=html"<div align=\""tagname"\">"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. "\r
+                       }\r
+                       else if (tagname =="s")\r
+                       {\r
+                               html=html"<strike>"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. "\r
+                       }\r
+                       else if (tagname =="sub")\r
+                       {\r
+                               html=html"<sub>"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. "\r
+                       }\r
+                       else if (tagname =="sup")\r
+                       {\r
+                               html=html"<sup>"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. "\r
+                       }\r
+                       else if (tagname=="spoiler")\r
+                       {\r
+                               html=html"<div style=\"margin:20px; margin-top:5px\"><div class=\"quotetitle\"><b>Spoiler:</b> <input type=\"button\" class=\"pk\" value=\"Show\" style=\"width:45px;font-size:10px;margin:0px;padding:0px;\" onclick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';        this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }\" /></div><div class=\"quotecontent\"><div style=\"display: none;\">"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. "\r
+                       }\r
+                       else if (tagname=="list")\r
+                       {\r
+                               if(tagvalue=="")\r
+                                       html=html"<ul>"\r
+                               else\r
+                               {\r
+                                       if (tagvalue=="1")\r
+                                               tagvalue="decimal"\r
+                                       else if (tagvalue=="i")\r
+                                               tagvalue="lower-roman"\r
+                                       else if (tagvalue=="I")\r
+                                               tagvalue="upper-roman"\r
+                                       else if (tagvalue=="a")\r
+                                               tagvalue="lower-alpha"\r
+                                       else if (tagvalue=="A")\r
+                                               tagvalue="upper-alpha"\r
+                                       else\r
+                                       {\r
+                                               html=html"This tag should have a correct value. "\r
+                                               tagvalue="decimal"\r
+                                       }\r
+                                       html=html"<ol style=\"list-style-type: "tagvalue"\">"\r
+                               }\r
+                       }\r
+                       else if (tagname=="*")\r
+                       {\r
+                               html=html"<li>"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. "\r
+                       }\r
+                       else\r
+                       {\r
+                               debug = debug "###nl;unknown tag"\r
+                               html = html tag\r
+                       }\r
+                       ++count[depth]\r
+               }\r
+               else if(bbtree[ind(count,depth)".k"]=="s")\r
+               {\r
+                       debug = debug "###nl;entering tag:"\r
+                       ++depth\r
+                       count[depth]=0\r
+               }\r
+               else if(bbtree[ind(count,depth)".k"]=="e")\r
+               {\r
+                       debug = debug "###nl;leaving tag:"\r
+                       tag=bbtree[ind(count,depth)]\r
+                       tagname=bbtree[ind(count,depth)".t"]\r
+                       tagvalue=bbtree[ind(count,depth)".v"]\r
+                       debug = debug "###nl;name: "tagname" value: "tagvalue\r
+                       if (tagname == "post")\r
+                       {\r
+                       }\r
+                       else if(bbtree[ind(count,depth)".m"]=="")\r
+                       {\r
+                               debug = debug "###nl;unmatched"\r
+                               html = html tag\r
+                       }\r
+                       else if(tagname == "quote")\r
+                               html = html "</div></blockquote>"\r
+                       else if (tagname ~/^(b|i|u|(size)|(color))$/)\r
+                               html = html"</span>"\r
+                       else if (tagname == "code")\r
+                       {\r
+                               if(bbtree[indtu(count,depth)".t"] == "code")\r
+                               {\r
+                                       html=html tag\r
+                                       debug = debug "###nl;not a tag, actually"\r
+                               }\r
+                               else\r
+                                       html = html"</code></dd></dl>"\r
+                       }\r
+                       else if (tagname == "img")\r
+                       {\r
+                               html = html"\" alt=\"Image\" />"\r
+                               if(tagvalue!="")\r
+                                       html=html"This tag shouldn't have any value. "\r
+                       }\r
+                       else if(tagname=="url")\r
+                               html=html"</a>"\r
+                       else if (tagname ~ /^((center)|(right))$/)\r
+                               html=html"</div>"\r
+                       else if (tagname =="s")\r
+                               html=html"</strike>"\r
+                       else if (tagname =="sub")\r
+                               html=html"</sub>"\r
+                       else if (tagname =="sup")\r
+                               html=html"</sup>"\r
+                       else if (tagname=="spoiler")\r
+                               html=html"</div></div></div>"\r
+                       else if (tagname=="list")\r
+                       {\r
+                               if (tagvalue=="")\r
+                                       html=html"</ul>"\r
+                               else\r
+                                       html=html"</ol>"\r
+                       }\r
+                       else if (tagname=="*")\r
+                               html=html"</li>"\r
+                       else\r
+                       {\r
+                               debug = debug "###nl;unknown tag"\r
+                               html = html tag\r
+                       }\r
+                       count[depth]=""\r
+                       --depth\r
+                       ++count[depth]\r
+               }\r
+               else if(count[depth]>bbtree[indt(count,depth)".n"])\r
+               {\r
+                       debug = debug "###nl;run out of elements in this tag; leaving"\r
+                       count[depth]=""\r
+                       --depth\r
+                       ++count[depth]\r
+               }\r
+               else\r
+               {\r
+                       tag=bbtree[ind(count,depth)]\r
+                       debug = debug "###nl;text: "tag\r
+                       if(bbtree[indt(count,depth)".t"] == "code")\r
+                       {\r
+                               # gsub(/ ?<br> ?/,"<br>",tag)\r
+                               gsub(/ /,"\\&nbsp;",tag)\r
+                               gsub(/\t/,"\\&nbsp;\\&nbsp;",tag)\r
+                       }\r
+                       if(argtab["disable_magic_url"]==""&& bbtree[indt(count,depth)".t"] !~ /^((code)|(img)|(url))$/)\r
+                               gsub(/https?:\/\/[^\n\r\t<> ]+/,"<a href=\"&\" class=\"postlink\">&</a>",tag)\r
+                       if(argtab["disable_smilies"]=="" && bbtree[indt(count,depth)".t"] !~ /^((code)|(img))$/)\r
+                       {\r
+                               gsub(/(^|[\n\r\t ]):D($|[\n\r\t ])/," <img title=\"Very Happy\" alt=\":D\" src=\"/ott/prosilver/smilies/icon_biggrin.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):\)($|[\n\r\t ])/," <img title=\"Smile\" alt=\":)\" src=\"/ott/prosilver/smilies/icon_smile.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):\(($|[\n\r\t ])/," <img title=\"Sad\" alt=\":(\" src=\"/ott/prosilver/smilies/icon_sad.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):o($|[\n\r\t ])/," <img title=\"Surprised\" alt=\":o\" src=\"/ott/prosilver/smilies/icon_surprised.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):shock:($|[\n\r\t ])/," <img title=\"Shocked\" alt=\":shock:\" src=\"/ott/prosilver/smilies/icon_eek.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):\?($|[\n\r\t ])/," <img title=\"Confused\" alt=\":?\" src=\"/ott/prosilver/smilies/icon_confused.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ])8-\)($|[\n\r\t ])/," <img title=\"Cool\" alt=\"8-)\" src=\"/ott/prosilver/smilies/icon_cool.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):lol:($|[\n\r\t ])/," <img title=\"Laughing\" alt=\":lol:\" src=\"/ott/prosilver/smilies/icon_lol.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):x($|[\n\r\t ])/," <img title=\"Mad\" alt=\":x\" src=\"/ott/prosilver/smilies/icon_mad.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):P($|[\n\r\t ])/," <img title=\"Razz\" alt=\":P\" src=\"/ott/prosilver/smilies/icon_razz.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):oops:($|[\n\r\t ])/," <img title=\"Embarassed\" alt=\":oops:\" src=\"/ott/prosilver/smilies/icon_redface.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):cry:($|[\n\r\t ])/," <img title=\"Crying or Very Sad\" alt=\":cry:\" src=\"/ott/prosilver/smilies/icon_cry.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):evil:($|[\n\r\t ])/," <img title=\"Evil or Very Mad\" alt=\":evil:\" src=\"/ott/prosilver/smilies/icon_evil.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):twisted:($|[\n\r\t ])/," <img title=\"Twisted Evil\" alt=\":twisted:\" src=\"/ott/prosilver/smilies/icon_twisted.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):roll:($|[\n\r\t ])/," <img title=\"Rolling Eyes\" alt=\":roll:\" src=\"/ott/prosilver/smilies/icon_rolleyes.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):wink:($|[\n\r\t ])/," <img title=\"Wink\" alt=\":wink:\" src=\"/ott/prosilver/smilies/icon_wink.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]);\)($|[\n\r\t ])/," <img title=\"Wink\" alt=\":wink:\" src=\"/ott/prosilver/smilies/icon_wink.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):!:($|[\n\r\t ])/," <img title=\"Exclamation\" alt=\":!:\" src=\"/ott/prosilver/smilies/icon_exclaim.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):\?:($|[\n\r\t ])/," <img title=\"Question\" alt=\":?:\" src=\"/ott/prosilver/smilies/icon_question.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):idea:($|[\n\r\t ])/," <img title=\"Idea\" alt=\":idea:\" src=\"/ott/prosilver/smilies/icon_idea.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):arrow:($|[\n\r\t ])/," <img title=\"Arrow\" alt=\":arrow:\" src=\"/ott/prosilver/smilies/icon_arrow.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):\|($|[\n\r\t ])/," <img title=\"Neutral\" alt=\":|\" src=\"/ott/prosilver/smilies/icon_neutral.gif\" /> ",tag)\r
+                               gsub(/(^|[\n\r\t ]):mrgreen:($|[\n\r\t ])/," <img title=\"Mr. Green\" alt=\":mrgreen:\" src=\"/ott/prosilver/smilies/icon_mrgreen.gif\" /> ",tag)\r
+                       }\r
+                       \r
+                       html = html tag\r
+                       ++count[depth]\r
+               }\r
+       }\r
+       debug = debug "###nl;done"\r
+       return html\r
+}\r
+\r
+function ind(count,depth,   ii,iindex)\r
+{\r
+       iindex = ""\r
+       for(ii=0;ii<=depth;++ii)\r
+       {\r
+               if(ii!=0)\r
+                       iindex = iindex "."\r
+               iindex = iindex count[ii]\r
+       }\r
+       # debug = debug "###nl;" iindex\r
+       return iindex\r
+}\r
+function indt(count,depth,   ii,iindex)\r
+{\r
+       iindex = ""\r
+       for(ii=0;ii<depth;++ii)\r
+       {\r
+               if(ii!=0)\r
+                       iindex = iindex "."\r
+               iindex = iindex count[ii]\r
+       }\r
+       if(depth>0)\r
+               iindex=iindex"."\r
+       iindex = iindex "0"\r
+       # debug = debug "###nl;" iindex\r
+       return iindex\r
+}\r
+function indtu(count,depth,   ii,iindex)\r
+{\r
+       iindex = ""\r
+       for(ii=0;ii<depth-1;++ii)\r
+       {\r
+               if(ii!=0)\r
+                       iindex = iindex "."\r
+               iindex = iindex count[ii]\r
+       }\r
+       if(depth>0)\r
+               iindex=iindex"."\r
+       iindex = iindex "0"\r
+       # debug = debug "###nl;" iindex\r
+       return iindex\r
+}
\ No newline at end of file
diff --git a/bot4.c b/bot4.c
new file mode 100644 (file)
index 0000000..a8cc27c
--- /dev/null
+++ b/bot4.c
@@ -0,0 +1,699 @@
+// bot4.c\r
+// The bot to post frames to the OTT\r
+// 08.04.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#include <unistd.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <time.h>\r
+#include <string.h>\r
+#include <sys/wait.h>\r
+\r
+#define OK              0\r
+#define POST_MSTD     256\r
+#define INDELIVERABLE 512\r
+#define NOPOSTS         3\r
+#define STOP_MSTD       4\r
+#define NAME_MSTD       5\r
+#define DOWN_MSTD       6\r
+#define PREP_MSTD       7\r
+#define LAST_MSTD       8\r
+#define ONGD_MSTD       9\r
+\r
+#define LINE_LIMIT 16000\r
+\r
+#define USERAGENT "bothasar_p (http://1190.bicyclesonthemoon.info/ongoing.htm; BFTF post bot)"\r
+\r
+#define OTT_ADDRESS "http://forums.xkcd.com/viewtopic.php?f=7&t=101043&start="\r
+#define TTO_ADDRESS "http://1190.bicyclesonthemoon.info/ott/view?start="\r
+#define MSTD_ADDRESS "http://1190.bicyclesonthemoon.info/ott/mview?start="\r
+#define LASTPOST_ADDRESS "http://forums.xkcd.com/viewtopic.php?f=7&t=101043&sd=d"\r
+\r
+#define LAST_PATH "/eizm/mem/ong1/lasttime"\r
+#define LOG_PATH "/eizm/log/ong1/bot4.log"\r
+#define STOP_PATH "/eizm/tmp/ong1/bot4stop"\r
+#define NAME_PATH "/eizm/mem/ong1/name"\r
+#define REDUNDANT_NAME_PATH "/eizm/mem/ottmirror/name"\r
+#define TEMPFILE_PATH "/eizm/tmp/ong1/bot3temp"\r
+#define TEMPFILE2_PATH "/eizm/tmp/ong1/bot3temp2"\r
+#define POSTDATA_PATH "/eizm/tmp/ong1/bot3post"\r
+#define COOKIE_PATH "/eizm/tmp/ong1/bot3cook"\r
+#define ONG_STATE_PATH "/eizm/data/aftertime/bftf/ongstate"\r
+#define FORCEMEME_PATH "/eizm/mem/ong1/forcememe"\r
+#define MEME_PATH "/eizm/mem/ong1/mome.txt"\r
+\r
+#define WGET_PATH "/usr/bin/wget"\r
+#define MAWK_PATH "/usr/bin/mawk"\r
+#define RM_PATH "/bin/rm"\r
+#define PERL_PATH "/usr/bin/perl"\r
+#define AWK_LATEST "/eizm/pro/ong1/findlatest.awk"\r
+#define AWK_RELATED "/eizm/pro/ong1/related.awk"\r
+#define AWK_POST "/eizm/pro/ong1/post.awk"\r
+#define AWK_MPOST "/eizm/pro/ong1/mpost.awk"\r
+#define AWK_MOME "/eizm/pro/ong1/mome.awk"\r
+#define PERL_MOME "/eizm/pro/ong1/mome.pl"\r
+#define AWK_LASTPOST "/eizm/pro/ong1/lastpost.awk"\r
+\r
+int main(int argc,char *argv[]);\r
+int longline(const char *in,const char *out, unsigned long limit);\r
+void end(int m);\r
+\r
+unsigned char logopen=0;\r
+FILE *file;\r
+FILE *stopfile;\r
+pid_t sub;\r
+int r;\r
+\r
+int main(int argc,char *argv[])\r
+{\r
+       time_t t;\r
+       \r
+       int yarg;\r
+       unsigned char text=0;\r
+       unsigned char otherbot=0;\r
+       unsigned char force=0;\r
+       unsigned char newlog=0;\r
+       unsigned char nopost=0;\r
+       unsigned char mpost=0;\r
+       unsigned long start=0x06666666; // this is a coincidence. It's the largest number that won't overflow the 32bit integer.\r
+       unsigned long last=0xffffffff;\r
+       unsigned long page;\r
+       unsigned long posts;\r
+       \r
+       unsigned short frame=65523;\r
+       unsigned short lastframe=0;\r
+       unsigned char ongstate=0;\r
+       unsigned char pope=0;\r
+       unsigned char selectong=0;\r
+       unsigned char edit;\r
+       \r
+       char name [256];\r
+       char mome[1024];\r
+       char pass [256];\r
+       char bot  [256];\r
+       char argp1[256];\r
+       char argp2[256];\r
+       char argp3[256];\r
+       char argp4[256];\r
+       char argp5[256];\r
+       char URL  [256];\r
+       \r
+       time(&t);\r
+       srand(getpid());\r
+       opterr=0;\r
+       \r
+       while((yarg = getopt(argc,argv,"tnfpmro:")) != -1)\r
+       {\r
+               switch(yarg)\r
+               {\r
+               case 't':\r
+                       text=1;\r
+                       break;\r
+               case 'n':\r
+                       newlog=1;\r
+                       break;\r
+               case 'f':\r
+                       force=1;\r
+                       break;\r
+               case 'p':\r
+                       nopost=1;\r
+                       break;\r
+               case 'm':\r
+                       mpost=1;\r
+                       break;\r
+               case 'r':\r
+                       otherbot=1;\r
+                       break;\r
+               case 'o':\r
+                       selectong=1;\r
+                       sscanf(optarg,"%hu",&frame);\r
+                       ongstate=2;\r
+                       break;\r
+               default:\r
+                       \r
+                       break;\r
+               }\r
+       }\r
+       \r
+       if(!text)\r
+       {\r
+               if(freopen(LOG_PATH,newlog?"wt":"at",stdout)!=NULL)\r
+                       logopen=1;\r
+       }\r
+       setvbuf(stdout, NULL, _IONBF, 0);\r
+       dup2(fileno(stdout),fileno(stderr));\r
+       printf("\n%s",ctime(&t));\r
+       \r
+       stopfile=fopen(STOP_PATH,"wt");\r
+       if (stopfile==NULL)\r
+               end(STOP_MSTD);\r
+       if (lockf(fileno(stopfile),F_TLOCK,0)!=0)\r
+               end(STOP_MSTD); \r
+       fprintf(stopfile,"%hu.FULL STOPFULL STOP\n",0);\r
+               \r
+       if((file=fopen(LAST_PATH,"rt"))!=NULL)\r
+       {\r
+               fscanf(file,"%lu %hu",&start,&lastframe);\r
+               fclose(file);\r
+       }\r
+       printf("start with page %lu, last frame was %hu",start,lastframe);\r
+       \r
+       if(!selectong)\r
+       {\r
+               file=fopen(ONG_STATE_PATH,"rt");\r
+               if(file!=NULL)\r
+               {\r
+                       fscanf(file,"%hhu %hu",&ongstate,&frame);\r
+                       fclose(file);\r
+               }\r
+               else\r
+                       end(LAST_MSTD);\r
+       }\r
+       \r
+       printf(", current frame is %hu",frame);\r
+       \r
+       file=fopen(otherbot?REDUNDANT_NAME_PATH:NAME_PATH,"rt");\r
+       if(file==NULL)\r
+               end(NAME_MSTD);\r
+       if(fgets(argp1,255,file)!=NULL)\r
+               sscanf(argp1,"%s",name);\r
+       else\r
+               end(NAME_MSTD);\r
+       if(fgets(argp1,255,file)!=NULL)\r
+               sscanf(argp1,"%s",pass);\r
+       else\r
+               end(NAME_MSTD);\r
+       if(fgets(argp1,255,file)!=NULL)\r
+               sscanf(argp1,"%s",bot);\r
+       else\r
+               sprintf(bot,"%s","bothasar_p");\r
+       fclose(file);\r
+       printf("\n%s",bot);\r
+       \r
+       if(force==0)\r
+       {\r
+               if(ongstate!=2)\r
+                       end(INDELIVERABLE);\r
+               if(frame<=lastframe)\r
+                       end(ONGD_MSTD);         \r
+               for(page=start;page<=last;++page)\r
+               {\r
+                       if(page!=start)\r
+                               sleep(3);\r
+                       printf("\n%lu",page);\r
+                       sprintf(URL,"%s%lu",OTT_ADDRESS,(page-1)*40);\r
+               \r
+                       // download the newpage\r
+                       printf(" download");\r
+                       sub=fork();\r
+                       if(!sub)\r
+                       {\r
+                               r=execl(WGET_PATH,WGET_PATH, "-q","-t", "3","--connect-timeout=60","-U", USERAGENT, "-O", TEMPFILE_PATH,URL, (char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+                       if(r)\r
+                       { \r
+                               sprintf(URL,"%s%lu",TTO_ADDRESS,(page-1)*40);\r
+                               printf(" redundant %s",URL);\r
+                               sub=fork();\r
+                               if(!sub)\r
+                               {\r
+                                       r=execl(WGET_PATH,WGET_PATH, "-q","-t", "3","-U", USERAGENT, "-O", TEMPFILE_PATH,URL, (char *)0);\r
+                                       exit(r);\r
+                               }\r
+                               waitpid(sub,&r,0);\r
+                               if(r)\r
+                               {\r
+                                       printf(" %d ",r);\r
+                                       end(DOWN_MSTD);\r
+                               }\r
+                       }\r
+                       printf(" OK, prepare");\r
+                       r=longline(TEMPFILE_PATH,TEMPFILE2_PATH,LINE_LIMIT);\r
+                       if(r)\r
+                               end(PREP_MSTD);\r
+                       printf(".");\r
+                       \r
+                       // what's the last page and how many posts are there?\r
+                       sprintf(argp1,"outfile=%s",TEMPFILE_PATH);\r
+                       sub=fork();\r
+                       if(!sub)\r
+                       {\r
+                               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_LATEST,"-v",argp1,TEMPFILE2_PATH,(char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+                       if(r)\r
+                               end(LAST_MSTD);\r
+                       printf(".");\r
+                       \r
+                       if((file=fopen(TEMPFILE_PATH,"rt"))!=NULL)\r
+                       {\r
+                               fscanf(file,"%lu %lu",&last,&posts);\r
+                               if(posts%40==0)\r
+                                       pope=1;\r
+                               else\r
+                                       pope=0;\r
+                               fclose(file);\r
+                       }\r
+                       else\r
+                               end(LAST_MSTD);\r
+                       if(page>last)\r
+                               page=last;\r
+                       printf(".OK match");\r
+                       \r
+                       sprintf(argp1,"frame=%hu",frame);\r
+                       sub=fork();\r
+                       if(!sub)\r
+                       {\r
+                               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_RELATED,"-v",argp1,TEMPFILE2_PATH,(char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+                       if(r)\r
+                       {\r
+                               if((file=fopen(LAST_PATH,"wt"))!=NULL)\r
+                               {\r
+                                       fprintf(file,"%lu %hu",last,frame);\r
+                                       fclose(file);\r
+                               }\r
+                               else\r
+                                       end(STOP_MSTD);\r
+                               end(ONGD_MSTD);\r
+                       }\r
+                       else\r
+                       {\r
+                               if((file=fopen(LAST_PATH,"wt"))!=NULL)\r
+                               {\r
+                                       fprintf(file,"%lu %hu",page,frame);\r
+                                       fclose(file);\r
+                               }\r
+                               else\r
+                                       end(STOP_MSTD);\r
+                       }\r
+                       printf(" nothing found.");\r
+               }\r
+               \r
+               for(page=1,last=0xffffffff;page<=last;++page)\r
+               {\r
+                       if(page!=start)\r
+                               sleep(3);\r
+                       printf("\nm%lu",page);\r
+                       sprintf(URL,"%s%lu",MSTD_ADDRESS,(page-1)*40);\r
+               \r
+                       // download the newpage\r
+                       printf(" download");\r
+                       sub=fork();\r
+                       if(!sub)\r
+                       {\r
+                               r=execl(WGET_PATH,WGET_PATH, "-q","-t", "3","--connect-timeout=60","-U", USERAGENT, "-O", TEMPFILE_PATH,URL, (char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+                       if(r)\r
+                       {\r
+                               printf(" not here.");\r
+                               break;\r
+                       }\r
+                       printf(" OK, prepare");\r
+                       r=longline(TEMPFILE_PATH,TEMPFILE2_PATH,LINE_LIMIT);\r
+                       if(r)\r
+                               break;\r
+                       printf(".");\r
+                       \r
+                       // what's the last page and how many posts are there?\r
+                       sprintf(argp1,"outfile=%s",TEMPFILE_PATH);\r
+                       sub=fork();\r
+                       if(!sub)\r
+                       {\r
+                               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_LATEST,"-v",argp1,TEMPFILE2_PATH,(char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+                       if(r)\r
+                               break;\r
+                       printf(".");\r
+                       \r
+                       if((file=fopen(TEMPFILE_PATH,"rt"))!=NULL)\r
+                       {\r
+                               fscanf(file,"%lu %lu",&last,&posts);\r
+                               if(posts%40==0)\r
+                                       pope=1;\r
+                               else\r
+                                       pope=0;\r
+                               fclose(file);\r
+                       }\r
+                       else\r
+                               break;\r
+                       if(page>last)\r
+                               page=last;\r
+                       printf(".OK match");\r
+                       \r
+                       sprintf(argp1,"frame=%hu",frame);\r
+                       sub=fork();\r
+                       if(!sub)\r
+                       {\r
+                               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_RELATED,"-v",argp1,TEMPFILE2_PATH,(char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+                       if(r)\r
+                               end(ONGD_MSTD);\r
+                       printf(" nothing found.");\r
+               }\r
+       }       \r
+       \r
+       printf("\nGet meme.");\r
+       \r
+       file=fopen(FORCEMEME_PATH,"rt");\r
+       if(file==NULL)\r
+       {\r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       freopen(TEMPFILE_PATH,"wt",stdout);\r
+                       r=execl(PERL_PATH,PERL_PATH,PERL_MOME,"-lc","150","-n","67","-d",MEME_PATH,"-t",pope?"[decrall]":"",(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               if(r==0)\r
+               {\r
+                       sprintf(argp1,"outfile=%s",TEMPFILE2_PATH);\r
+                       sub=fork();\r
+                       if(!sub)\r
+                       {\r
+                               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_MOME,"-v",argp1,TEMPFILE_PATH,(char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+                       if(r==0)\r
+                       {\r
+                               file=fopen(TEMPFILE2_PATH,"rt");\r
+                               if(file!=NULL)\r
+                               {\r
+                                       fscanf(file,"%s",mome);\r
+                                       fclose(file);\r
+                               }\r
+                               else\r
+                                       sprintf(mome,"%s","Ong.");\r
+                       }\r
+                       else\r
+                               sprintf(mome,"%s","Ong.");\r
+               }\r
+               else\r
+                       sprintf(mome,"%s","Ong.");\r
+       }\r
+       else\r
+       {\r
+               fscanf(file,"%s",mome);\r
+               fclose(file);\r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(RM_PATH,RM_PATH,"-f",FORCEMEME_PATH,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               if(r)\r
+                       sprintf(mome,"%s","Ong.");\r
+       }\r
+\r
+       printf(" %s OK.\ncreate post file",mome);\r
+       \r
+       file=fopen(POSTDATA_PATH,"wt");\r
+       if(file != NULL)\r
+       {\r
+               fprintf(file,"username=%s\n",name);\r
+               fprintf(file,"password=%s\n",pass);\r
+               fprintf(file,"subject=bftf-%04hu\n",frame);\r
+               fprintf(file,"addbbcode20=%s\n","100");\r
+               fprintf(file,"message=%s%s%hu%s%04hu%s%s%s%s%s",\r
+                       mome,\r
+                       "%0A%5Burl%3Dhttp%3A%2F%2F1190.bicyclesonthemoon.info%2Fongoing.htm%3Ff%3D",\r
+                       frame,\r
+                       ((rand()&0x7)?"%5D%5Bimg%5Dhttp%3A%2F%2F1190.bicyclesonthemoon.info%2Fongoing%2Fbftf-":"%5D%5Bimg%5Dhttp%3A%2F%2F1190.bicyclesonthemoon.info%2Fongoing%2Fnpbftf-"),\r
+                       frame,\r
+                       (frame>=564)?\r
+                               ".png%5B%2Fimg%5D%5B%2Furl%5D%5Bspoiler%5DI%27d%20highly%20recommend%20following%20the%20first%20commandment%20...again.%5B%2Fspoiler%5D":\r
+                               ".png%5B%2Fimg%5D%5B%2Furl%5D%5Bspoiler%5D...%5B%2Fspoiler%5D",\r
+                       pope?"":"",\r
+                       "%5Bsize%3D85%5D%5Bright%5D--%20posted%20by%20",\r
+                       bot,\r
+                       "%5B%2Fright%5D%5B%2Fsize%5D"\r
+               );\r
+               fclose(file);\r
+       }\r
+       else\r
+               end(POST_MSTD);\r
+       printf(" OK\nsend post");\r
+       \r
+       do\r
+       {//test latest post\r
+               edit=0;\r
+               sub=fork();\r
+               if(sub==0)\r
+               {\r
+                       r=execl(WGET_PATH,WGET_PATH, "-q","-t", "3","-U", USERAGENT, "-O", TEMPFILE_PATH,LASTPOST_ADDRESS, (char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               if(r)\r
+                       break;\r
+               \r
+               sub=fork();\r
+               if(sub==0)\r
+               {\r
+                       if(freopen(TEMPFILE2_PATH,"wt",stdout)==NULL)\r
+                               exit(255);\r
+                       r=execl(MAWK_PATH,MAWK_PATH, "-f",AWK_LASTPOST, TEMPFILE_PATH, (char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               if(r)\r
+                       break;\r
+               \r
+               file=fopen(TEMPFILE2_PATH,"rt");\r
+               if(file==NULL)\r
+                       break;\r
+                       \r
+               if(fgets(argp1,255,file)!=NULL)\r
+               {\r
+                       sscanf(argp1,"%s",argp2);\r
+                       sprintf(argp4,"edit=%s",argp2);\r
+               }\r
+               else\r
+               {\r
+                       fclose(file);\r
+                       break;\r
+               }\r
+               if(fgets(argp1,255,file)!=NULL)\r
+               {\r
+                       sscanf(argp1,"%s",argp2);\r
+                       sprintf(argp5,"user=%s",argp2);\r
+               }\r
+               else\r
+               {\r
+                       fclose(file);\r
+                       break;\r
+               }\r
+               fclose(file);\r
+               edit=1;\r
+       }while(0);\r
+       \r
+       sprintf(argp1 ,"postfile=%s",TEMPFILE2_PATH);\r
+       sprintf(argp2,"cookiefile=%s",COOKIE_PATH);\r
+       sprintf(argp3,"tempfile=%s",TEMPFILE_PATH);\r
+       //sprintf(argp4,"name=%s",name);\r
+       //sprintf(argp5,"pass=%s",pass);\r
+       \r
+       if(!nopost)\r
+       {\r
+               if(mpost)\r
+                       r=mpost;\r
+               else\r
+               {\r
+                       sub=fork();\r
+                       if(!sub)\r
+                       {\r
+                               if(edit)\r
+                                       r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POST,"-v",argp1,"-v",argp2,"-v",argp3,"-v",argp4,"-v",argp5,POSTDATA_PATH,(char *)0);\r
+                               else\r
+                                       r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POST,"-v",argp1,"-v",argp2,"-v",argp3,POSTDATA_PATH,(char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+               }\r
+               if(r)\r
+               {\r
+                       sub=fork();\r
+                       if(!sub)\r
+                       {\r
+                               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_MPOST,"-v",argp1,"-v",argp2,"-v",argp3,POSTDATA_PATH,(char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+                       if(r)\r
+                               end(r);\r
+               }\r
+       }\r
+       printf(" OK");\r
+       end(OK);\r
+       return 0;\r
+}\r
+\r
+int longline(const char *in,const char *out, unsigned long limit)\r
+{\r
+       FILE *infile;\r
+       FILE *outfile;\r
+       unsigned char tag;\r
+       unsigned long counter=0;\r
+       char ch;\r
+       \r
+       outfile=fopen(out,"wt");\r
+       if(outfile==NULL)\r
+               return 1;\r
+       infile=fopen(in,"rt");\r
+       if(infile==NULL)\r
+       {\r
+               fclose(outfile);\r
+               return 1;\r
+       }\r
+       \r
+       while(!feof(infile))\r
+       {\r
+               ch=(char)(fgetc(infile));\r
+               fputc(ch,outfile);\r
+               ++counter;\r
+               switch(ch)\r
+               {\r
+               case '<':\r
+                       tag=1;\r
+                       break;\r
+               case '>':\r
+                       tag=0;\r
+                       if(counter>=limit)\r
+                       {\r
+                               fputc('\n',outfile);\r
+                               counter=0;\r
+                       }\r
+                       break;\r
+               case ' ':\r
+                       if((!tag) && (counter>= limit))\r
+                       if(counter>=limit)\r
+                       {\r
+                               fputc('\n',outfile);\r
+                               counter=0;\r
+                       }\r
+                       break;\r
+               case '\r':\r
+               case '\n':\r
+                       counter=0;\r
+                       break;\r
+               default:\r
+                       break;\r
+               }\r
+               \r
+       }\r
+       return 0;\r
+}\r
+\r
+\r
+void end(int m)\r
+{\r
+       switch(m)\r
+       {\r
+       case INDELIVERABLE:\r
+               printf("\nCan't ONG this yet.\n");\r
+               break;\r
+       case NAME_MSTD:\r
+               printf("\nName and password fail.\n");\r
+               break;\r
+       case DOWN_MSTD:\r
+               printf("\nDownload fail.\n");\r
+               break;\r
+       case PREP_MSTD:\r
+               printf("\nNewpage prepare fail.\n");\r
+               break;\r
+       case LAST_MSTD:\r
+               printf("\nRemember last time fail.\n");\r
+               break;\r
+       case ONGD_MSTD:\r
+               printf("\nAlready ONGed\n");\r
+               break;\r
+       case POST_MSTD:\r
+               printf("\nPost fail.\n");\r
+               break;\r
+       case STOP_MSTD:\r
+               printf("\nFULL STOPFULL STOP\n");\r
+               break;\r
+       \r
+       \r
+       case OK:\r
+               printf("\nONGED\n");\r
+               break;\r
+       default:\r
+               printf("\nCh*rping m*stard!\n");\r
+       }\r
+       if(logopen)\r
+               fclose(stdout);\r
+       if(m != STOP_MSTD)\r
+       {\r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(RM_PATH,RM_PATH,"-f",COOKIE_PATH,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(RM_PATH,RM_PATH,"-f",POSTDATA_PATH,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(RM_PATH,RM_PATH,"-f",TEMPFILE_PATH,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(RM_PATH,RM_PATH,"-f",TEMPFILE2_PATH,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               \r
+               lockf(fileno(stopfile),F_ULOCK,0);\r
+               fclose(stopfile);\r
+               \r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(RM_PATH,RM_PATH,"-f",STOP_PATH,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               \r
+       }\r
+       exit(m);\r
+}\r
diff --git a/click.c b/click.c
new file mode 100644 (file)
index 0000000..3a8a273
--- /dev/null
+++ b/click.c
@@ -0,0 +1,164 @@
+// click.c (1190.bicyclesonthemoon.info/click)\r
+// The button that could activate BFTF\r
+// 06.04.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define ONG_STATE_PATH "/eizm/data/aftertime/bftf/ongstate"\r
+#define LOG_PATH        "/eizm/log/ong1/click.log"\r
+#define TIMEFRAME       4\r
+#define INDEX_PATH      "/eizm/www/time/index.htm"\r
+#define NEWINDEX_PATH   "/eizm/www/time/ongdex.htm"\r
+#define CP_PATH         "/bin/cp"\r
+\r
+\r
+#include <cgi.h>\r
+#include <time.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <unistd.h>\r
+#include <stdlib.h>\r
+#include <sys/wait.h>\r
+\r
+s_cgi *cgi;\r
+pid_t sub;\r
+int r;\r
+\r
+void writeHTML(FILE *file,const char *text);\r
+int main (int argc, char *argv[]);\r
+\r
+void writeHTML(FILE *file,const char *text)\r
+{\r
+       unsigned short length, i, v;\r
+       for(i=0, length=strlen(text);i<length;++i)\r
+       {\r
+               v=((unsigned short)text[i])&0x00ff;\r
+               switch (text[i])\r
+               {\r
+               case '\n':\r
+               case '\"':\r
+               case '&':\r
+               case '<':\r
+               case '>':\r
+               case ' ':\r
+               case '\r':\r
+               case '=':\r
+                       fprintf(file,"&#%hu;",v);\r
+                       break;\r
+               default:\r
+                       fputc(v,file);\r
+               }\r
+       }\r
+}\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+       FILE *file;\r
+       char *value;\r
+       unsigned short ongFrame;\r
+       unsigned char ongState, safeword;\r
+       time_t now;\r
+       struct tm *nowS;\r
+       unsigned char h,m,s;\r
+       unsigned long d;\r
+       \r
+       cgi=cgiInit();\r
+       \r
+       now=time(NULL);\r
+       nowS=localtime(&now);\r
+       d=TIMEFRAME*3600-(nowS->tm_sec+60*nowS->tm_min+3600*(nowS->tm_hour%TIMEFRAME));\r
+       s=(unsigned char)(d%60);\r
+       m=(unsigned char)((d/60)%60);\r
+       h=(unsigned char)(d/3600);\r
+       \r
+       value=cgiGetValue(cgi,"n");\r
+       safeword=((value!=NULL)?((strcmp(value,"NI")==0)?1:0):0);\r
+       \r
+       if(safeword)\r
+       {\r
+               file=fopen(ONG_STATE_PATH,"rt");\r
+               if(file!=NULL)\r
+               {\r
+                       fscanf(file,"%hhu %hu",&ongState,&ongFrame);\r
+                       fclose(file);\r
+                       if(ongState==0)\r
+                       {\r
+                               file=fopen(ONG_STATE_PATH,"wt");\r
+                               if(file!=NULL)\r
+                               {\r
+                                       fprintf(file,"1 0");\r
+                                       fclose(file);\r
+                               }\r
+                               sub=fork();\r
+                               if(!sub)\r
+                               {\r
+                                       r=execl(CP_PATH,CP_PATH, "-f", NEWINDEX_PATH, INDEX_PATH, (char *)0);\r
+                                       exit(r);\r
+                               }\r
+                               waitpid(sub,&r,0);\r
+                       }\r
+                       if(ongFrame>0)\r
+                               cgiRedirect("/ongoing.htm");\r
+               }\r
+               \r
+       }\r
+       \r
+       file=fopen(LOG_PATH,"at");\r
+       if(file!=NULL)\r
+       {\r
+               fprintf(file,"%s\n",(value!=NULL)?value:"");\r
+               fclose(file);\r
+       }\r
+       \r
+       fputs("Content-type: text/html\n\n",stdout);\r
+       \r
+       fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n",stdout);\r
+       fputs("<html lang=\"en\"><head>\n",stdout);\r
+       fputs("<title>N = ",stdout);\r
+       writeHTML(stdout,safeword?"2":((value!=NULL)?value:"???"));\r
+       fputs("&bull; Bicycles on the Moon</title>\n",stdout);\r
+       fputs("<meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-2\">\n",stdout);\r
+       fputs("<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n",stdout);\r
+       fputs("</head><body><center>\n",stdout);\r
+       fputs("<a href=\"/\"><img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\"></a><br>\n",stdout);\r
+       fputs("<H1>N = ",stdout);\r
+       writeHTML(stdout,safeword?"2":((value!=NULL)?value:"???"));\r
+       fputs("</H1>\n",stdout);\r
+       if(safeword)\r
+       {\r
+               fputs("<table><tr><td>\n",stdout);\r
+               fputs("<a href=\"/ongoing.htm\"><img src=\"/ongoing.png\" alt=\"the frame, a png file\" title=\"I'd highly recommend following the first commandment.\" border=\"2\"></a><br>\n",stdout);\r
+               fputs("</td><tr align=\"right\"><td>\n",stdout);\r
+               printf("%2hhu:%02hhu:%02hhu\n",h,m,s);\r
+               fputs("</td><tr align=\"left\"><td>",stdout);\r
+               fputs("You started something.<br>\n",stdout);\r
+               fputs("You made a change that can't be reversed.<br>\n",stdout);\r
+               fputs("Soon, you will notice a change.<br>\n",stdout);\r
+               fputs("And then another one.<br>\n",stdout);\r
+               fputs("And another one.<br>\n",stdout);\r
+               fputs("<br>\n",stdout);\r
+               fputs("Wait for it.<br>\n",stdout);\r
+               fputs("</td></tr></table>\n",stdout);\r
+       }\r
+       else\r
+       {\r
+               fputs("<img src=\"/img/722.png\" alt=\"xkcd722\3\" border=\"0\"><br>\n",stdout);\r
+       }\r
+       fputs("<a href=\"/\">1190.bicyclesonthemoon.info</a>\n",stdout);\r
+       fputs("</center></body></html>\n",stdout);\r
+       \r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/deliver.c b/deliver.c
new file mode 100644 (file)
index 0000000..0794e8d
--- /dev/null
+++ b/deliver.c
@@ -0,0 +1,180 @@
+// deliver.c\r
+// The ct-if bot\r
+// 08.09.2014\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#include <unistd.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <time.h>\r
+#include <sys/wait.h>\r
+\r
+#define TEMP_PATH "/eizm/tmp/ong1/deliver."\r
+#define LOG_PATH "/eizm/log/ong1/deliver.log"\r
+#define POST_PATH "/eizm/mem/ong1/mpost/"\r
+#define WAIT_PATH "/eizm/mem/ong1/mpost/wait/"\r
+#define LS_PATH "/bin/ls"\r
+#define MV_PATH "/bin/mv"\r
+#define RM_PATH "/bin/rm"\r
+\r
+pid_t sub;\r
+int r;\r
+\r
+int main(int argc, char **argv)\r
+{\r
+       time_t t;\r
+       struct tm *nowS;\r
+       int yarg;\r
+       unsigned char text=0;\r
+       unsigned char newlog=0;\r
+       FILE *list;\r
+       FILE *post;\r
+       char temppath[256];\r
+       unsigned char logopen=0;\r
+       unsigned char i;\r
+       char line[32];\r
+       char value[32];\r
+       char inpath[256];\r
+       char outpath[256];\r
+       unsigned char d;\r
+       unsigned char m;\r
+       unsigned short y;\r
+       \r
+       t=time(NULL);\r
+       sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid());\r
+       \r
+       while((yarg = getopt(argc,argv,"tn")) != -1)\r
+       {\r
+               switch(yarg)\r
+               {\r
+               case 't':\r
+                       text=1;\r
+                       break;\r
+               case 'n':\r
+                       newlog=1;\r
+                       break;\r
+               default:\r
+                       \r
+                       break;\r
+               }\r
+       }\r
+       if(!text)\r
+       {\r
+               if(freopen(LOG_PATH,newlog?"wt":"at",stdout)!=NULL)\r
+                       logopen=1;\r
+       }\r
+       setvbuf(stdout, NULL, _IONBF, 0);\r
+       dup2(fileno(stdout),fileno(stderr));\r
+       printf("\n%s",ctime(&t));\r
+       \r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               if(freopen(temppath,"wt",stdout)==NULL)\r
+                       exit(255);\r
+               r=execl(LS_PATH,LS_PATH,"-1","--color=never",WAIT_PATH,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       if(r)\r
+               printf("ls fail.\n");\r
+       else\r
+       {\r
+               list=fopen(temppath,"rt");\r
+               if(list==NULL)\r
+                       printf("list fail.\n");\r
+               else\r
+               {\r
+                       for(i=0; fgets(line,31,list)!=NULL; ++i)\r
+                       {\r
+                               sscanf(line,"%s",value);\r
+                               printf("%s",value);\r
+                               sprintf(inpath,"%s%s",WAIT_PATH,value);\r
+                               post=fopen(inpath,"rt");\r
+                               if(post==NULL)\r
+                               {\r
+                                       printf(" fail.;");\r
+                                       continue;\r
+                               }\r
+                               for(d=0xff,m=0xff,y=0xffff;fgets(line,31,post)!=NULL;)\r
+                               {\r
+                                       if(line[0]=='d'&&line[1]=='=')\r
+                                               sscanf(line+2,"%hhu",&d);\r
+                                       else if(line[0]=='m'&&line[1]=='=')\r
+                                               sscanf(line+2,"%hhu",&m);\r
+                                       else if(line[0]=='y'&&line[1]=='=')\r
+                                               sscanf(line+2,"%hu",&y);\r
+                               }\r
+                               fclose(post);\r
+                               printf(" %hhu.%hhu.%hu",d,m,y);\r
+                               nowS=localtime(&t);\r
+                               \r
+                               if(y>1900+nowS->tm_year)\r
+                               {\r
+                                       printf(" wait\n");\r
+                                       continue;\r
+                               }\r
+                               else if(y==1900+nowS->tm_year)\r
+                               {\r
+                                       if(m>1+nowS->tm_mon)\r
+                                       {\r
+                                               printf(" wait\n");\r
+                                               continue;\r
+                                       }\r
+                                       else if(m==1+nowS->tm_mon)\r
+                                       {\r
+                                               if(d>nowS->tm_mday)\r
+                                               {\r
+                                                       printf(" wait\n");\r
+                                                       continue;\r
+                                               }\r
+                                       }\r
+                               }\r
+                               \r
+                               printf(" deliver");\r
+                               sprintf(outpath,"%s%s",POST_PATH,value);\r
+                               \r
+                               sub=fork();\r
+                               if(sub==0)\r
+                               {\r
+                                       r=execl(MV_PATH,MV_PATH,inpath,outpath,(char *)0);\r
+                                       exit(r);\r
+                               }\r
+                               waitpid(sub,&r,0);\r
+                               if(r)\r
+                                       printf(" mv fail.\n");\r
+                               else\r
+                                       printf(" ok\n");\r
+                       }\r
+                       if(i==0)\r
+                               printf("Nothing.\n");\r
+                       fclose(list);\r
+                       sub=fork();\r
+                       if(sub==0)\r
+                       {\r
+                               r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0);\r
+                               exit(r);\r
+                       }\r
+                       waitpid(sub,&r,0);\r
+                       if(r)\r
+                               printf("rm fail.\n");\r
+               }\r
+       }\r
+       if(logopen)\r
+               fclose(stdout);\r
+       return 0;\r
+}\r
diff --git a/findlatest.awk b/findlatest.awk
new file mode 100644 (file)
index 0000000..5701c47
--- /dev/null
@@ -0,0 +1,49 @@
+#// findlatest.awk
+#// find the latest page and number of posts.
+#// 14.08.2014
+#// 
+#// Copyright (C) 2014  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 <http://www.gnu.org/licenses/>.
+
+
+BEGIN {
+       a=1;
+};
+{
+       if (posts== "")
+       {
+               for(i=1;i<=NF;i++)
+               {
+                       if(tolower($i) ~ /posts/)
+                               posts=$(i-1)
+               }
+       }
+       else    if (tolower($0) ~ /page/)
+       {
+               gsub(/<[^>]*>/," ",$0)
+               for(i=1;i<=NF;i++)
+               {
+                       if((tolower($i) ~ /page/) && (tolower($(i+2)) ~ /of/))
+                       {
+                               print $(i+3) " " posts >outfile
+                               a=0;
+                               exit a;
+                       }
+               }
+       }
+};
+END {
+       exit a
+}
diff --git a/force.c b/force.c
new file mode 100644 (file)
index 0000000..5f6a077
--- /dev/null
+++ b/force.c
@@ -0,0 +1,47 @@
+// force.c (1190.bicyclesonthemoon.info/ct-if-f)\r
+// Force the ct-if bot\r
+// 11.11.2014\r
+// \r
+// Copyright (C) 2014  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define BOT_PATH "/eizm/pro/ong1/deliver"\r
+\r
+#include <cgi.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <sys/wait.h>\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+       s_cgi *cgi;\r
+       pid_t sub;\r
+       int r;\r
+       \r
+       cgi=cgiInit();\r
+       printf("Content-type: text\n\n");\r
+       \r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               r=execl(BOT_PATH,BOT_PATH,"-t","-r",(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       \r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/generator.c b/generator.c
new file mode 100644 (file)
index 0000000..db950ac
--- /dev/null
@@ -0,0 +1,163 @@
+// generator.c (1190.bicyclesonthemoon.info/og-if-2)\r
+// The object generator online interface\r
+// 20.09.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define LOG_PATH "/eizm/log/ong1/generator.log"\r
+#define FILE_PATH "/eizm/mem/ong1/generator/"\r
+#define LOGIN0 "kxa"\r
+#define PASSWORD0 "CFRTdsn'tapproV"\r
+#define LOGIN1 "b"\r
+#define LOGIN2 "fth"\r
+#define MV_PATH "/bin/mv"\r
+#define MAWK_PATH "/usr/bin/mawk"\r
+#define AWK_OGDF "/eizm/pro/ong1/ogdfparse.awk"\r
+\r
+#include <cgi.h>\r
+#include <time.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <string.h>\r
+#include <sys/wait.h>\r
+\r
+\r
+void response(char *text);\r
+int main(int argc,char **argv);\r
+\r
+time_t posttime;\r
+s_cgi *cgi;\r
+int t;\r
+pid_t sub;\r
+\r
+// void response(char *text)\r
+// {\r
+       // printf("%s%s%s%s%s%s%s%s%s%s%s%s%s",\r
+               // "Content-type: text/html\n\n",\r
+               // "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n",\r
+               // "<html lang=\"en\"><head>\n",\r
+               // "<title>Object Generator online &bull; Bicycles on the Moon</title>\n",\r
+               // "<meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-2\">\n",\r
+               // "<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n",\r
+               // "<link rel=\"stylesheet\" href=\"/css/botm.css\">\n",\r
+               // "</head><body>\n",\r
+               // "<a href=\"/\"><img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\"></a>\n",\r
+               // "<h1>Object generator online</h1><p>\n",\r
+               // text,\r
+               // "<br><a href=\"generator.htm\">Object generator interface</a></p>\n",\r
+               // "<a href=\"/\">1190.bicyclesonthemoon.info</a></body></html>\n"\r
+       // );\r
+       // exit(0);\r
+// }\r
+\r
+int main(int argc, char **argv)\r
+{\r
+       char *login;\r
+       char *password;\r
+       char *n;\r
+       char **up;\r
+       char *filename;\r
+       char filepath[256];\r
+       char argp1[256];\r
+       char argp2[256];\r
+       char argp3[256];\r
+       FILE *logfile;\r
+       \r
+       posttime=time(NULL);\r
+       cgi=cgiInit();\r
+       \r
+       setvbuf(stdout, NULL, _IONBF, 0);\r
+       dup2(fileno(stdout),fileno(stderr));\r
+       \r
+       login=cgiGetValue(cgi,"login");\r
+       password=cgiGetValue(cgi,"password");\r
+       n=cgiGetValue(cgi,"n");\r
+       \r
+       up=cgiGetFiles(cgi);\r
+       if (up)\r
+       {\r
+               filename=cgiGetFile(cgi,up[0])->filename;\r
+               sprintf(filepath,"%s%llu_%s",FILE_PATH,(unsigned long long)posttime,filename);\r
+               sub=fork();\r
+               if(sub==0)\r
+               {\r
+                       t=execl(MV_PATH,MV_PATH,cgiGetFile(cgi,up[0])->tmpfile,filepath,(char *)0);\r
+                       exit(t);\r
+               }\r
+               waitpid(sub,&t,0);\r
+       }\r
+       else\r
+               sprintf(filepath,"%s","---");\r
+       \r
+       // if(login==NULL || password==NULL || n==NULL || !up)\r
+               // cgiRedirect("/generator.htm");\r
+       \r
+       logfile=fopen(LOG_PATH,"at");\r
+       if(logfile!=NULL)\r
+       {\r
+               fprintf(logfile,"l=%s p=%s n=%s f=%s\n",(login!=NULL)?login:"---",(password!=NULL)?password:"---",(n!=NULL)?n:"---",filepath);\r
+               fclose(logfile);\r
+       }\r
+       // else\r
+               // response(LOG_PATH);\r
+       printf("%s%s%s%s%s%s%s%s%s%s",\r
+               "Content-type: text/html\n\n",\r
+               "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n",\r
+               "<html lang=\"en\"><head>\n",\r
+               "<title>Object Generator online &bull; Bicycles on the Moon</title>\n",\r
+               "<meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-2\">\n",\r
+               "<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n",\r
+               "<link rel=\"stylesheet\" href=\"/css/botm.css\">\n",\r
+               "</head><body>\n",\r
+               "<a href=\"/\"><img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\"></a>\n",\r
+               "<h1>Object generator online</h1><p><code>\n"\r
+       );\r
+       if(login==NULL)\r
+               printf("No login.\n");\r
+       else if(password==NULL)\r
+               printf("No password.\n");\r
+       else if(strcmp(login,LOGIN0)==0 && strcmp(password,PASSWORD0)==0)\r
+       {\r
+               if(!up)\r
+                       printf("No definition file.\n");\r
+               else if(n==NULL)\r
+                       printf("Quantity unspecified.\n");\r
+               else\r
+               {\r
+                       sprintf(argp1,"ogdf_name=%s",filename);\r
+                       sprintf(argp2,"q=%s",n);\r
+                       sprintf(argp3,"logf=%s",LOG_PATH);\r
+                       \r
+                       sub=fork();\r
+                       if(sub==0)\r
+                       {\r
+                               t=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_OGDF,"-v",argp1,"-v",argp2,"-v",argp3,filepath,(char *)0);\r
+                               exit(t);\r
+                       }\r
+                       waitpid(sub,&t,0);\r
+               }\r
+       }\r
+       else if((strcmp(login,LOGIN0)==0 || strcmp(login,LOGIN1)==0 || strcmp(login,LOGIN2)==0))\r
+               printf("Password incorrect.\n");\r
+       else\r
+               printf("Login incorrect.\n");\r
+       printf("%s%s",\r
+               "</code><br><br><a href=\"generator.htm\">Object generator interface</a></p>\n",\r
+               "<a href=\"/\">1190.bicyclesonthemoon.info</a></body></html>\n"\r
+       );\r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/lastpost.awk b/lastpost.awk
new file mode 100644 (file)
index 0000000..9b93751
--- /dev/null
@@ -0,0 +1,46 @@
+#// lastpost.awk\r
+#// what was the last post?\r
+#// 20.03.2015\r
+#// \r
+#// Copyright (C) 2015  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       FS=""\r
+}\r
+{\r
+       if ((i=match($0, /id=\"p[0-9]+\"/))!=0) #"\r
+       {\r
+               temp=substr($0, i+5)\r
+               postid=substr(temp, 1, index(temp,"\"")-1)\r
+       }\r
+       \r
+       if ($0 ~ /class=\"postprofile\"/) #"\r
+               postprofile = "1"\r
+       \r
+       else if (postprofile=="")\r
+               next\r
+       \r
+       if($0 ~ /memberlist\.php.*mode=viewprofile[^<>]*>[^<>]+<\/a/)\r
+       {\r
+               temp=substr($0, index($0, ">")+1)\r
+               username=substr(temp, 1, index(temp,"<")-1)\r
+               exit\r
+       }\r
+}\r
+END{\r
+       print postid\r
+       print username\r
+}
\ No newline at end of file
diff --git a/makefile b/makefile
new file mode 100644 (file)
index 0000000..9f4ff62
--- /dev/null
+++ b/makefile
@@ -0,0 +1,68 @@
+CC=gcc\r
+CC2=g++\r
+CF=-g -Wall\r
+LF=-lIL\r
+LF2=-lcgi\r
+\r
+all: bot4 deliver remove view mpview viewpage relink ong pleaseong update spoiler click generator post posted force enable npb npbd\r
+\r
+npb: npb.cpp makefile\r
+       $(CC2) $(CF) $(LF) -o npb npb.cpp\r
+\r
+npbd: npbd.cpp makefile\r
+       $(CC2) $(CF) -o npbd npbd.cpp $(LF2)\r
+\r
+bot4: bot4.c findlatest.awk related.awk post.awk mpost.awk mome.pl mome.awk makefile\r
+       $(CC) $(CF) -o bot4 bot4.c\r
+\r
+deliver: deliver.c\r
+       $(CC) $(CF) -o deliver deliver.c\r
+\r
+remove: remove.c\r
+       $(CC) $(CF) -o remove remove.c $(LF2)\r
+\r
+pleaseong: pleaseong.c\r
+       $(CC) $(CF) -o pleaseong pleaseong.c $(LF2)\r
+\r
+view: view.c makefile\r
+       $(CC) $(CF) -o view view.c $(LF2)\r
+\r
+mpview: mpview.c mview.awk view.awk makefile\r
+       $(CC) $(CF) -o mpview mpview.c $(LF2)\r
+\r
+viewpage: viewpage.c makefile\r
+       $(CC) $(CF) -o viewpage viewpage.c $(LF2)\r
+\r
+relink: relink.c makefile\r
+       $(CC) $(CF) -o relink relink.c $(LF2)\r
+\r
+ong: ong.c makefile\r
+       $(CC) $(CF) -o ong ong.c\r
+\r
+update: update.c makefile\r
+       $(CC) $(CF) -o update update.c\r
+\r
+spoiler: spoiler.c makefile\r
+       $(CC) $(CF) -o spoiler spoiler.c $(LF2)\r
+\r
+click: click.c makefile\r
+       $(CC) $(CF) -o click click.c $(LF2)\r
+\r
+generator: generator.c ogdfparse.awk makefile\r
+       $(CC) $(CF) -o generator generator.c $(LF2)\r
+\r
+posted: posted.c posted.awk makefile\r
+       $(CC) $(CF) -o posted posted.c $(LF2)\r
+\r
+post: post.cpp preview.awk bb2html.awk makefile\r
+       $(CC2) $(CF) -o post post.cpp $(LF2)\r
+\r
+ongtext: ongtext.c ongtext.awk makefile\r
+       $(CC) $(CF) -o ongtext ongtext.c $(LF2)\r
+\r
+force: force.c\r
+       $(CC) $(CF) -o force force.c $(LF2)\r
+\r
+\r
+enable: relink view click generator posted post remove ongtext pleaseong force\r
+       chmod u+s relink view click generator posted post remove ongtext pleaseong force\r
diff --git a/mem/mome.txt b/mem/mome.txt
new file mode 100644 (file)
index 0000000..2e18542
--- /dev/null
@@ -0,0 +1,3367 @@
+#THE MEME TEMPLATE FILE. I'S A COPY OF MROB'S FILE WITH SOME MODIFICATIONS.
+#(almost)NONE OF THESE COMMENTS BELOW ARE MINE
+#http://mrob.com/time/automome
+# OTTified memes for #automeme#
+#
+#                               LICENSE
+#
+# This memes file, and the software to process it (which is at
+# http://mrob.com/time/automome/automeme-pl.txt ) are made available under
+# a Creative Commons Attribution-NonCommercial 4.0 International License.
+# License details are at http://mrob.com/cc-license.html
+#
+# EXAMPLES
+#
+# To get lots of What-If memes, use:
+#
+#    automeme -v -n 143 | \
+#                 egrep '(COULD|HOW..*WOULD|IF.EVERY|IF..*[CW]OULD|WHAT.IF)'
+#
+# REVISION HISTORY
+#  20140406 First version by mrob27
+#  20140407:
+#     add 'CASSINI-MADAGASCAR' to noun-place
+#     add classes verb-intr-perfect and verb-tr-perfect. They are mostly
+# the same as verb-xx-past, except for irregular verbs. The only
+# difference right now is "HIDE FROM CORINNE" vs. "HIDDEN FROM CORINNE"
+#     add verb-tr-perfect to "THIS IS [@PHOTOSHOPPED@0.67, adjective..."
+# template. In my mind, transitive perfect-tense verbs metch the
+# snowclone a little bit better than adjectives. The original AUTOMEME
+# has ('~photoshopped', 'adj') but I added 'verb3 there as well.
+#  20140408:
+#    change 'SHIT' to 'M**STARD' in the 'SHIT WAS SO CASH' meme
+#    add AMTOO, BEANETTE and ROSETTA; add another of CUEBALL, MEGAN,
+# CUEGAN and MEGBALL because those characters are more 'popular'
+# 20140408, continued
+#    add THE BEACH to [noun-place]
+#    add MYSTERYONG to all 3 noun types
+#    add ONG (5 tenses) to verb-tr-xxx (for usage examples, see
+# [OTT:381:11|#p3334595], [OTT:475:17|#p3343415], and [OTT:1282:16|#p3423689]
+#    add CUPCAKE (a big deal with @Valarya) to the [noun]s
+# 20140409:
+#    The JavaScript now has a function scan_cvt() with 5 arguments that
+# performs mappings like '_foo_' -> '<em>foo</em>'. scan_cvt is used 4 times:
+#      s = scan_cvt(s, '**', '*', '*');
+#      s = scan_cvt(s, '*', '<em>', '</em>');
+#      s = scan_cvt(s, '$', '<span style="font-size:smaller">', '</span>');
+#      s = scan_cvt(s, '*', '*', '*');
+# The effect of the first and last part is to make ** be the way to
+# represent a literal '*'. The middle two calls turn '*' into the <em>
+# style and '$' into small-caps. Thus CH**RP becomes CH*RP and *CHIRP*
+# becomes <em>CHIRP</em>.
+#    Add $ER$OTT$IC$ to [adjective]
+#    Add the ability to filter and transform (using regular expressions)
+# members of a class to define another class.
+#
+# 20140410:
+#   Add char-1word, containing 1-word characters, and use it in the BLESS
+# and THANK templates.
+#   Break [noun-singular] up into two categories [noun-unique] and
+# [noun-commodity], then define [noun-singular] as the union of those
+# two, and define [noun-article] using only the members of [noun-commodity]
+#   Add VOLDEFRAME and WHISTLE OF TEMPORAL HARMONY to noun-unique
+#
+# 20140411:
+#   BLESS... and THANK YOU... memes once again include multi-word things.
+#   Re-do te nouns again; there is now a list of nouns with articles and
+# [noun-commodity] is derived from it. This allows us to handle initial
+# consonants properly ("AN HONOR") and foreign scripts ("A ᓭᘖᔭᓄᐨ" or
+# "AN ᓭᘖᔭᓄᐨ") should we ever want to.
+#   There may now be two random literals at the beginning of a replaceable,
+# enabling the following modifications:
+#     I ACCIDENTALLY ... IS THIS [BAD@0.33, DANGEROUS@0.5, ENDISH]?
+#     I LIKE MY [MEN@0.25, WOMEN@0.33, noun-plural, noun-mass] ...
+# (and maybe a few others (I forgot to keep track))
+#   Add this variation on the Dos Equis meme:
+#     I DON'T ALWAYS [verb-tr-inf] [noun-plural, noun-mass], BUT WHEN I DO,
+#     I [PREFER@0.2, verb-tr-inf] [noun-plural, noun-mass]
+#   Add snowclone templates:
+#     THE [noun-singular] IS TOO CH**RPING [HIGH@0.3, adjective]
+#     KEEP CALM AND [MOLPY@0.2, verb-inf-1word] ON
+#     REMAIN [CALM@0.2, adjective] AND [verb-inf-1word] [noun-mass, noun-plural]
+#   (Previously I had these slightly worse versions of those two:
+#     KEEP [CALM@0.2, adjective] AND [MOLPY@0.2, verb-tr-inf, verb-intr-inf] ON
+#     KEEP [CALM@0.2, adjective] AND [verb-tr-inf, verb-intr-inf] [noun-mass, noun-plural]
+#   )
+#     [verb-tr-cont, verb-intr-cont] [$0/ING/ERS/] GONNA [$0/ING//]
+#       (e.g. "CH*RPING CH*IRPERS GONNA CH*RP")
+#       (needs an operator that links the verb tenses by table lookup.)
+#     A WILD [noun-singular] [APPEARED@0.5, APPEARS]!
+#
+#   Add category [nounz] and use in the "IS IT CAN BE... TIEM NAO PLEES?"
+#   Vocabulary additions:
+#     adjectives: ZANCLEAN, (AWEFULSOME, but we already have AWESOMEFUL),
+#       MUSTARDY, CH*RPING, BEANISH, OTCOLORED
+#     characters: BEARDO (early name for Rosetta), EXPANDO, OLDPIXBOT
+#     place names: "THE AFOREWHEN", "THE AFTERWHEN", "THE FUTURE"
+#     commodity noun with irregular plural: A NEWPIX / NEWPICES
+#     normal nouns: A PASTPOST, A MANIP, A FIRSTPOST, A BLINDPOST, A XIP,
+#       A WIP, A WIPEND, A MOLPYSNAKE, A WOWTREE, A FLUTTERBEE,
+#       AN OTTIFICATION, A RAPTORCAT, A CUEGANITE, A PUNSAW, A SILENTONG
+#     intransitive verbs: COMA
+#     transitive verbs: SPOILER
+#
+# 20140412:
+#   Use non-greedy patterns in the BLESS and THANKS memes
+#   Vocabulary additions:
+#     verb: POST/POSTED/POSTING/POSTS
+#     character: MS. FRIZZLE, GOATEE
+#     noun-unique: (THE) JAVASCRIPT, (THE) ZANCLEAN FLOOD
+#     noun-comm-art: A RAPTOR, A RIBBIT, AN EQUIMOLPY, A SPARROW-RAPTOR,
+#       A CHUPAMOLPY, A QUACKMOLPY, A FACEBUG, A MOOLPY, A RHINOCEROLPY,
+#       A PASTPAGE (there are a lot more molpy species on NP1543)
+#
+# 20140414:
+#    Add the cut operator, an empty replaceable '[]', which is a
+#    signal to delete everything up to that point. This is used in the
+#    DIAL X FOR Xxxx template, where the full word Xxxx needs to be
+#    generated first.
+#    Add several memes from @Link
+#
+# 20140415:
+#   Many additions that I did not bother to document.
+#   place: CHRONOCORP
+# 20140418:
+#   noun-plural: HOTDOGS ("A HOTDOG" was already in noun-comm-art)
+# 20140421:
+#   Add Doge meme (WOW - SO [noun] - etc.)
+# 20140425:
+#   character: AZULE
+#   verb-transitive: to WAIT FOR
+#   Add a bunch of templates tagged 'azule' and originating in OtherComics
+# 20140427:
+#   Break commodity (non-unique) nouns into positive and negative
+#   categories (used in XKCD #51 meme).
+#
+# 20140511:
+#   Add noun Q04B
+#   Add snowclone: "PLEASE READ: A PERSONAL APPEAL ..."
+# 20140512:
+#   Add noun-unique QUESTIONABLE CARCASS
+#   Add CITATION NEEDED meme
+# 20140518:
+#   Add a few more XKCD-based memes from @azule.
+#   Add [adjective-article] and derive [adjective] from it. Add [adverb].
+#   Add more vocabulary from Link's versions 2.1 and earlier (e.g.
+# PINKLYMOLP and CUEGANZZLE, to GO CAVE) and memes from his v. 2.0
+#
+# 20140522:
+#   Change MOOLPY to MOOPY
+# 20140523:
+#   Add a lot of origin notes.
+#   Add BAOBABBY
+#
+# 20140612:
+#   Add origin of "THANK YOU [character], BUT OUR...
+#
+# 20140621 Add verb to AZULE
+# 20140622:
+#   Add VITSSÅGAR (plural of VITSSÅGEN)
+# 20140624:
+#   adjectives SANDISH, CAVEISH
+# 20140625:
+#   noun-plural OVARIES (see OTT:1997:28#p3611339) and verb AZULING
+# (see OTT:1998:24#p3611715)
+#   Add sexual double-entendre meme
+#
+# 20140709:
+#   Add AN OVARY
+# 20140711:
+#   Add 408 and 503 memes
+#
+# 20140724:
+#   Add MOROBU.
+#   Begin scanning through all edits of @Link's version
+#   (automome.penguindevelopment.org) to bring mine up to date. I
+#   had fallen behind since his version 2.0, which added the MultiWord
+#   class. Today I start by adding my own multiclass syntax, and use
+#   it to define the verbs.
+#
+# 20140725:
+#   add a bunch of origin comments; multiclass the nouns (still in
+#   animal and mineral categories); rename "noun-place" to simply
+#   "place"; add several memes from @Link; improve alphabetization of
+#   the templates.
+#
+# 20140726:
+#   add the rest of Link's memes, so this file now has all from his
+#   version 2.4
+#      Add meme: NOW IS THE TIME...
+# 20140727:
+#   add meme "EVERY TIME YOU [verb-inf], ..."
+# 20140728:
+#   add two versions of the "Billy Madison" meme, and "you can't have
+#   your X and Y it too".
+#   Lengthen the "this is your brain on drugs" template.
+#   Add PELRIGG, ETERNAL DENSITY and BLITZGIRL
+#   Add [character] to the ONLY TWO THINGS COME FROM template
+#   Lengthen the Ramirez meme by adding [character]
+# 20140729:
+#   Add ERGMAN, YAPPO, TAIXZO
+# 20140730:
+#   Improvements from Link's v. 2.5:
+#     Add A HERETICAL and HERETICALLY; character SIR VINNIE LONGDONG;
+#     verb SACRIFICING; nouns COLPIX, LOOPIST, OTHERCOMIC, and VIRGIN;
+#     minor corrections (e.g. use [verb-tr-present] instead of
+#     [verb-present] in "think of the kittens"); Add "Hast seen the
+#     white whale", "I'm sorry, Dave...", "Maybe X is a metaphor for..."
+#   Make [place] a multiclass to define appropriate prepositions for
+#   each (used in the two templates marked '**' below)
+#   Add meme templates:
+#     "he wasn't the most X Y in the Z"  **
+#     "don't hate me because I'm adjective"
+#     "molpies gone wild"
+#     "there is no crying in [place]" **
+#     Isaiah 48:22 ("there is no peace for the wicked")
+#     "got milk?"
+#     "I'm going to X like I've never X'd before" (two forms)
+#   Add the paradoxical "noun-unique-article" class so that I can
+#   add the "Yes Virginia, there is a..." template.
+# 20140731:
+#   Break adjectives up into positive and negative
+#   Add recent change from azule to xkcd #194, and add xkcd #1025 template
+#   (there are still a lot of xkcd-based templates from azule that I could add later)
+#   Add TREBUCHAT to noun-mass-negative (see OTT:2050:16#p3632176)
+# 20140801:
+#   Add THE CASTRAFTLE to [place]
+# 20140802:
+#   Add characters THE 1ST CLERIC, THE 2ND SCRIBE, UCIM, and noun BLITZROCKET
+#   Add corrections and improvements made evident by Link's recent version 3.0:
+#     Merge 404/408/503 into one template
+#     Change some literal probabilities
+#     Add [verb-cont][noun] form of "I don't want to be right" template
+#     Use intransitive verb in Billy Madison template
+#     Use perfect tense in "...like I've never [verbed] before"
+#     in Arthur Baer meme use appropriate "out of" preposition according to place, e.g. "AWAY FROM THE BEACH" rather than "OUT OF THE BEACH"
+#     Add initial "THIS" to "this is the cancer that..." and "... why we can't have nice things"
+#   Add noun-mass-the and verb-cont-1word
+#   Add -pr-out column to multiclass [place], used in the Arthur Baer meme
+#   Add templates:
+#     "it's super effective!"
+#     "I am Ozymandius... look on my works" (two forms)
+#   Add class [adjective=most]
+#   Add a few more xkcd templates from azule
+#   Add "best part of waking up..." meme
+# 20140803:
+#   Small tweak to Boys' Life meme
+# 20140804:
+#   Add named regexes for the class-building operations.
+#   Add place THE PAST
+# 20140805:
+#   Use named regexes in all of the templates.
+#   Add changes from Link's 3.2:
+#     Add multiclass adjec (only used in a couple of places, until we get
+#     multiclass unions so we can retain the positive/negative distinction)
+#     Improve grammar of some templates
+#     Add memes "So long ... all the fish"; "friends don't let friends..." ;
+#       "one ring to rule..."; "nuke it from orbit..."; "demons run..."
+#     Add regex /s-ending-invert/ to support new meme "He's the hero Gotham..."
+#     Add place THE MOONBASE
+# 20140807:
+#   Add memes "You live by the sword..."; "the buck stops here"
+# 20140808:
+#   Add DUNEJUMPISHLY, break adverbs up into positive ane negative
+#   Add a few Japanese memes (@@Link and @@azule, please ignore ^_^ )
+#   Add "A few X short of a Y"; "give me your poor, your tired..."; "math
+#     is hard, let's go shopping"; "my X Y-eth over"; "X is the Y of Z" and
+#     its "then why are we..." variant
+# 20140809:
+#   Change spelling of :AZULE: isomorphs
+#   Expand "consider the lilies..." and "I'm a doctor, not..."
+#   Add several more memes: "have X will travel"; "I'm going to X ... and
+#     by X I mean..."; "... but I played one on TV"; "in X nobody can hear...";
+#     "save an X, shoot a Y"; "shit happens"; "take this X and shove it";
+#     "we don't need no stinking X"; "X is so last week"
+#
+# 20140830:
+#   Add some Azule memes, and change some others to add ideas from @azule (some of which might have also come from @Link)
+# 20140902:
+#   Add some memes from Link's version 3.2
+# 20140903:
+#   Add changes from Link's 3.3
+# 20140904: Add a bunch of memes based on chapter titles in the What-If book.
+# 20140905: Bug-fixes and clean up new regexes. Add more What-If titles.
+# 20140907:
+#   Add -art field to the verbs, use it for t-verb-actor-article and a couple memes
+#   Add Azule's dawgify and dawgchar
+#   Add Eternal Density's random name generator
+# 20140908:
+#   Add multiclass noun-interval
+#   Add vocabulary from Eternal Density's list at OTT:2094:23#p3648331
+#   Add vocabulary from Azule; add some more xkcd memes from azule.
+#   Add ЯOЯЯIM TTO ИA.
+# 20140910:
+#   Add some more vocabulary from balthasar_s
+#   Use a new fancy regex remove-the: /(^THE )|( ƎHT$)|($)//i
+#   Add several more What-If titles
+# 20140912: Add OTHERRIVERWADINGISH, GOOMHR; tweak a couple of the azule memes
+@ 20140914: Hyphenate modifier in HOW X IS IT.. IN A Y-STORM
+# 20140917: "ЯОЯЯІМ ТТО" (all Cyrillic) looks better than "ЯOЯЯIM TTO"
+# 20140919:
+#   Add lots fo changes from azule: vocabulary including several animals, ASPCA meme
+# 20141127: Add Roko's Basilisk meme (alt-text of xkcd 1450)
+# 20150102: Add Sustainabilizer meme ("If we have asked you for some data...")
+# 20150108: Add SILENTBOT
+# 20150109:
+#   Changes from Link's version 3.4:
+#     Add THE GLR (in addition to, not replacing, plain "GLR")
+#     Add interjection BAOBABS
+#     Add nouns CHRONOTRANSPONDER, LIZARD, RIDONDAKITI, RONG, TRANSLATEOUNG
+#     Add class [char-noart]
+#     Add [adjec-noun] to most replaceables that already had [noun-mass]
+#     7 new memes from @Link:
+#       Vega Strike "Hulls pop like vibrant seeds..."
+#       Mario "It's-a-me, Luigi"
+#       Firefly "Man walks down the street..."
+#       Firefly "My food is problematic"
+#       "¡This NOUN is VERBing me!"
+#       Doctor Who "No, not the mind probe!"
+#       Legend of Zelda Tingle "... These are the magic words..."
+# 20150110: Add more bits of edtitle template
+# 20150112: Add NUMBERWONGGH meme; add a few animals like TRILOMEG
+# 20150113: Add PENGOAT and other goat-like vocab; there is now an adjective-neutral category. Fix Colossal Caves "maze" meme to handle placenams that have a hyphen.
+ 20150115: Add "Stick it in your..." and "99 problems" memes
+# 20150119: Add a little "utility templates" section with (for now) only the [sentence-imperative] template.
+# 20150123: Add [decree] template definitions by #balthasar_s#. Add several movie name templates.
+# 20150131: Add CASTRAFTLE in several places.
+# 20150213: Add "I went to see the fight..."
+# 20150215: Add *AUFGEMOLPEN*
+# 20150224: Add BALTHACARIUS and JAVASCRIPT
+# Named regex transformations for class lists and classlike templates.
+
+# The 'add-foo' regexes simply add something to the beginning
+regex add-that: /^/THAT /
+regex add-the: /^/THE /
+regex add-most: /^/MOST /
+
+# /has-no-spaces/ matches a string only if it contains no spaces,
+# and if used in a grep context, leaves the string unchanged.
+regex has-no-spaces: /^([^ ]+)$/$1/
+
+# oneword-est only matches things that end in EST and contain no punctuation
+# or spaces.
+regex oneword-est: /^({A-Z}+EST)$/$1/
+
+# /remove-article/ only matches things that start with an article 'A '
+# or 'AN ', and removes the article.
+regex remove-article: /^ *AN? +//i
+
+# Match anything, and if it starts with "THE ", remove the THE. It is of
+# critical importance that the clauses of this OR-grouping are ordered
+# with the ^-forms first and the $-forms after.
+regex remove-the: /(^THE )|( ƎНТ$)|($)//i
+
+class adjective-positive-article:
+AN AWEFULSOME
+AN AWESOMEFUL
+A BAOBABISH
+A BEANISH
+A BUFFYHATTED
+A DUNEISH
+A DUNEJUMPISH
+AN $ER$OTT$IC$
+A FLUTTERBEEWINGISH
+A MOUNTAINISH
+A MOLPISH
+A NEAT
+AN OTCOLORED
+AN OTTERRIFIC
+AN OTTISH
+A PRICKLY
+A RAPTORISH
+A $RELATED$
+A SANDISH
+A SEAISH
+A STEAKISH
+A TOQUISH
+A TREEISH
+A WINGISH
+A WINGGHISH
+A WOWTERFALLISH
+A WOWTERFUL
+A ZANCLEAN
+A SILENTTIMERISH
+A SUSTAINABILIZED
+A KEYBOARD-SMASHING
+
+class adjective-neutral-article:
+A PENGOATIMATE
+A RECENT
+
+class adjective-negative-article:
+A CAVEISH
+A CH**RPING
+AN ENDISH
+AN EPSILONISH
+A HERETICAL
+A HILLISH
+A MUSTARDY
+AN OTHERRIVERWADINGISH
+A RAPTORCATTISH
+A REDUNDANT
+A RIVERISH
+A STEAMBOTTLISH
+A WEIRD
+A YAPPOCISED
+
+class adjective-article:
+[adjective-positive-article]
+[adjective-neutral-article]
+[adjective-negative-article]
+
+class adjective-positive:
+[adjective-positive-article] ms/remove-article/
+
+class adjective-negative:
+[adjective-negative-article] ms/remove-article/
+
+class adjective:
+[adjective-article] ms/remove-article/
+
+# Some of the -noun forms are deliberately humorous. See Jargon File, e.g. "ferrous => ferrosity"
+multiclass adjec [-desc-art, -comp-art, -super, -noun]:
+AN AWEFULSOME       | AN AWEFULSOMER        | AWEFULSOMEST         | AWEFULSOMENESS
+AN AWESOMEFUL       | AN AWESOMEFULLER      | AWESOMEFULLEST       | AWESOMEFULNESS
+A BAOBABISH         | A BAOBABISHER         | BAOBABISHEST         | BAOBABISHNESS
+A BEANISH           | A BEANISHER           | BEANISHEST           | BEANISHNESS
+A BUFFYHATTED       | A MORE BUFFYHATTED    | MOST BUFFYHATTED     | BUFFYHABERDASHERY
+A CAVEISH           | A CAVEISHER           | CAVEISHEST           | CAVEISHNESS
+A CH*RPING          | A MORE CH*RPING       | MOST CH*RPING        | CH*RPITUDE
+A DUNEISH           | A DUNEISHER           | DUNEISHEST           | DUNEISHNESS
+A DUNEJUMPISH       | A DUNEJUMPISHER       | DUNEJUMPISHEST       | DUNEJUMPTION
+AN ENDISH           | AN ENDISHER           | ENDISHEST            | ENDISHNESS
+AN EPSILONISH       | AN EPSILONISHER       | EPSILONISHEST        | EPSILONITY
+A FLUTTERBEEWINGISH | A FLUTTERBEEWINGISHER | FLUTTERBEEWINGISHEST | FLUTTERBEEWINGISHNESSITUDE
+A HATTED            | A MORE HATTED         | MOST HATTED          | HABERDASHERY
+A HERETICAL         | A MORE HERETICAL      | MOST HERETICAL       | HERESY
+A HILLISH           | A HILLISHER           | HILLISHEST           | HILLISHNESS
+A MOUNTAINISH       | A MORE MOUNTAINISH    | MOST MOUNTAINISH     | MOUNTAINOSITY
+A MOLPISH           | A MOLPIER             | MOLPIEST             | MOLPISHNESS
+A MUSTARDY          | A MUSTARDIER          | MUSTARDIEST          | MUSTARDINESS
+AN OTCOLORED        | A MORE OTCOLORED      | MOST OTCOLORED       | OTCOLORISATION
+A PENGOATIMATE      | A MORE PENGOATIMATE   | MOST PENGOATIMATE    | PENGOATITUDE
+A RAPTORISH         | A MORE RAPTORISH      | MOST RAPTORISH       | RAPTORISHNESS
+A RAPTORCATTISH     | A RAPTORCATTISHER     | RAPTORCATTISHEST     | RAPTORFELINITY
+A RECENT            | A MORE RECENT         | A RECENTMOST         | RECENTNESS
+A REDUNDANT         | A MORE REDUNDANT      | MOST REDUNDANT       | REDUNDANCY
+A RELATED           | A MORE RELATED        | MOST RELATED         | RELATEDNESS
+A RIVERISH          | A MORE RIVERISH       | MOST RIVERISH        | RIVERISHNESS
+A SANDISH           | A SANDISHER           | SANDISHEST           | SANDISHNESS
+A SEAISH            | A MORE SEAISH         | MOST SEAISH          | SEAISHNESS
+A STEAKISH          | A STEAKISHER          | STEAKISHEST          | STEAKISHNESS
+A STEAMBOTTLISH     | A MORE STEAMBOTTLISH  | MOST STEAMBOTTLISH   | STEAMBOTTLISHNESS
+A TEMPORAL          | A MORE TEMPORAL       | MOST TEMPORAL        | TEMPORALITY
+A TREEISH           | A TREEISHER           | TREEISHEST           | TREEISHNESS
+AN UNGLISH          | AN UNGLISHER          | MOST UNGLISH         | UNGLISHNESS
+A WEIRD             | A WEIRDER             | WEIRDEST             | WEIRDNESS
+A WINGISH           | A WINGISHER           | WINGISHEST           | WINGISHNESS
+A WOWTERFALLISH     | A MORE WOWTERFALLISH  | MOST WOWTERFALLISH   | WOWTERFALLISHNESS
+A WOWTERFUL         | A MORE WOWTERFUL      | MOST WOWTERFUL       | WOWTERFULNESS
+A YAPPOCISED        | A MORE YAPPOCISED     | MOST YAPPOCISED      | YAPPOCISION
+A ZANCLEAN          | A MORE ZANCLEAN       | MOST ZANCLEAN        | ZANCLEANLINESS
+A SUSTAINABLE       | A MORE SUSTAINABLE    | MOST SUSTAINABLE     | SUSTAINABILITY
+
+class adjec-est:
+[adjec-super] ms/oneword-est/
+
+class adjec-comp:
+[adjec-comp-art] ms/remove-article/
+
+class adverb-positive:
+AWEFULSOMELY
+AWESOMEFULLY
+BAOBABISHLY
+BEANISHLY
+DUNEJUMPISHLY
+$ER$OTT$ICALLY$
+FLUTTERBEEWINGISHLY
+MOLPISHLY
+OTCOLOREDLY
+RAPTORISHLY
+RELATEDLY
+SEAISHLY
+TREEISHLY
+WINGISHLY
+WOWTERFULLY
+ZANCLEANLY
+
+class adverb-negative:
+CAVEISHLY
+CH**RPINGLY
+ENDISHLY
+EPSILONISHLY
+HERETICALLY
+MUSTARDILY
+RAPTORCATTISHLY
+REDUNDANTLY
+RIVERISHLY
+STEAMBOTTLISHLY
+WEIRDLY
+YAPPOCISEDLY
+
+class adverb:
+[adverb-positive]
+[adverb-negative]
+
+class character_no_s:
+# OTC characters
+AFRO
+AMTOO
+BALDO
+BEANETTE
+BEARDO
+BIGGEST BANGS BROTHER
+BLACK BUN
+BOB
+BRAVEBEAN
+BRICK
+BROKENBEAN
+BUNNY
+BUZZ
+CUEBALL
+ CUEBALL
+CUEGAN
+ CUEGAN
+CUEGANZZLE
+CURLY
+CURLY BUN
+EXPANDO
+FORELOCK
+GOATEE
+GLR
+GRAY BUN
+HAT-HAIR
+HEADBAND
+HES
+LAPETITE
+LITTLEST BANGS BROTHER
+LOOPSY
+LOPSIDE
+LUCKY
+MEG-A-LIKE
+MEGAN
+ MEGAN
+MEGBALL
+ MEGBALL
+MIDDLE BANGS BROTHER
+MINI-BUNNY
+MINI-SHORTDO
+MINI-TWO-TONE
+MS. FRIZZLE
+NEWEST BANGS BROTHER
+PART
+PONY
+PULLED BACK
+ROSE
+ROSETTA
+ ROSETTA
+ROUNDHAIR
+SANDY
+SHE-BANGS
+SHORTDO
+SHORTY
+SPARSE
+SPIKE
+THE FORTY
+THE GLR
+THE TIMEGHOST
+TWO-TONE
+WHITE BUNNY
+ZOMBEANIE
+#
+# OTTers and their fictional creations
+THE 1ST CLERIC
+THE 2ND SCRIBE
+AUTOMOME
+AZULE
+BALTHACARIUS
+BLITZGIRL
+CZULE
+ETERNAL DENSITY
+ERGMAN
+FFOXY
+GEORGE THE MALEVOLENT GALLSTONE
+HES
+IMAGEBOT
+LMJB1964
+LMJBOT
+MOROBU
+MROB27
+MRORL
+NEWPIXBOT
+OLDPIXBOT
+PELRIGG
+RANDOMPIXBOT
+SILENTBOT
+SIR VINNIE LONGDONG
+STORMANGEL
+TAIXZO
+THE FIRST CLERIC
+THE MOPEY MOLPY MOME
+THE PINKLYMOLP
+THE SECOND SCRIBE
+TIMBORME
+UCIM
+YAPPO
+BOTHASAR__S
+BOTHASAR__P
+BOTHASAR__T
+KXA
+# Non-OTC and non-Otter
+HODOR
+
+# A temporary "gift" to balthasar_s
+class character:
+[character_no_s]
+[character_no_s]
+[character_no_s]
+[character_no_s]
+[character_no_s] ms/$/__S/
+
+# All the characters that are just one word (used in Ramirez meme)
+class char-1word:
+[character] ms/has-no-spaces/
+
+class char-noart:
+[character] ms/remove-the/
+# He made a connection in the other direction and the fans all shouted out...
+class interjection:
+BAOBABS
+BOOM-DE-YADA
+CH**RP
+CH**RPING MUSTARD
+GOOMHR
+LWPAII
+OMR
+RANDAMMIT
+STEAMBOTTLE
+
+class noun-mass-pos-article:
+A BLUEHANCEMENT
+A BUTTER
+A <COMPUTERY STUFF>
+A CUSTARD
+AN EPSILON
+A KETCHUP
+AN OINTMENT
+AN ORGANIZED SAND
+A PANTHER SALVE
+A Q04B
+A REDUNDANCY
+A SIGCOURAGEMENT
+A SKITCHERTS
+A TIME
+A ᓭᘖᔭᓄᐨ
+A T1I
+A BFTF
+A LEML
+
+class noun-mass-positive:
+[noun-mass-pos-article] ms/remove-article/
+
+class noun-mass-neg-article:
+AN ****DISHNESS
+A HERESY
+A JAVASCRIPT
+A LEGO
+A MMONS
+A MUSTARD
+AN ONGST
+AN OUTSIDE
+A SEMENCOFFEECANCERSTARSANDBACONBABIESONICE
+A TREBUCHAT
+
+class noun-mass-negative:
+[noun-mass-neg-article] ms/remove-article/
+
+class noun-mass:
+[noun-mass-positive]
+[noun-mass-negative]
+
+class noun-mass-the:
+[noun-mass] ms/add-the/
+
+# NOTE: I include 'GOAT', 'PENGOAT', etc. as [animal] even though they refer to poats, because it's just too confusing.
+multiclass noun-animal[-art, -plural]:
+AN AMOEBLPY      | AMOEBLPIES
+AN ANTELOPEY     | ANTELOPIES
+AN ANTEPENGOAT   | ANTEPENGOATS
+A BADGERMOLP     | BADGERMOLPS
+A BAOBABBY       | BAOBABBIES
+A BEANIE         | BEANIES
+A BEARAPTOR      | BEARAPTORS
+A BEESNAKE       | BEESNAKES
+A BRAINSLUG      | BRAINSLUGS
+A CENTIMOLPY     | CENTIMOLPIES
+A CHIRPY         | CHIRPIES
+A CHUPAMOLPY     | CHUPAMOLPIES
+A CUEGANITE      | CUEGANITES
+AN EQUIMOLPY     | EQUIMOLPIES
+A FACEBUG        | FACEBUGS
+A FLUTTERBEE     | FLUTTERBEES
+A FREQUENTLY     | FREQUENTLIES
+A GATORRAPTOR    | GATORRAPTORS
+A GECKOLPY       | GECKOLPIES
+A GHOLPY         | GHOLPIES
+A GOAT           | GOATS
+A GOATPY         | GOATPIES
+A GUINEAMOLP     | GUINEAMOLPS
+A HAMPLY         | HAMPLIES
+A KANGAMOLP      | KANGAMOLPIES
+A KEYBOARD       | KEYBOARDS
+A LOOPIST        | LOOPISTS
+A MEOWLPY        | MEOWLPIES
+A MOLPACA        | MOLPACAS
+A MOLPANZEE      | MOLPANZEES
+A MOLPHIN        | MOLPHINS
+A MOLPICOOT      | MOLPICOOTS
+A MOLPIDILLO     | MOLPIDILLOES
+A MOLPOSSUM      | MOLPOSSUM
+A MOLPY          | MOLPIES
+A MOLPYBARA      | MOLPYBARAS
+A MOLPYDILE      | MOLPYDILES
+A MOLPYSNAKE     | MOLPYSNAKES
+A MOME           | MOMES
+A MOOPY          | MOOPIES
+A MURTLE         | MURTLES
+A NINJA          | NINJAS
+AN ORCARAPTOR    | ORCARAPTORS
+AN ORANGUMOLP    | ORANGUMOLPS
+AN OTTER         | OTTERS
+AN OTTERMOLPY    | OTTERMOLPIES
+A PAGEPOPE       | PAGEPOPES
+A PENGOAT        | PENGOATS
+A POPE           | POPES
+A POPERAPTOR     | POPERAPTORS
+A PRICKLYMOLP    | PRICKLYMOLPS
+A QUACKMOLPY     | QUACKMOLPIES
+A RABTOR         | RABTORS
+A RAPTOR         | RAPTORS
+A RAPTORCAT      | RAPTORCATS
+A RAPTORCUDA     | RAPTORCUDAS
+A RAPTORSHARK    | RAPTORSHARKS
+A RATPY          | RATPIES
+A REDUNDAKITTY   | REDUNDAKITTIES
+A RHINOCEROLPY   | RHINOCEROLPIES
+A RIBBIT         | RIBBITS
+A ROOMMOLPY      | ROOMMOLPIES
+A SEAWOLPY       | SEAWOLPIES
+A SLITHERMOLP    | SLITHERMOLPS
+A SPARROW-RAPTOR | SPARROW-RAPTORS
+A SPOILERAPTOR   | SPOILERAPTORS
+A SQUIRPY        | SQUIRPIES
+A TIMEWAITER     | TIMEWAITERS
+A TRICEROCUE     | TRICEROCUES
+A TRILOBOLPY     | TRILOBOLPIES
+A TRILOMEG       | TRILOMEGGS
+A TURTLEMOLPY    | TURTLEMOLPIES
+A VIPERRAPTOR    | VIPERRAPTORS
+A VIRGIN         | VIRGINS
+A WALLAPY        | WALLAPIES
+A WOLPY          | WOLPIES
+A WOOLPY         | WOOLPIES
+A WOTTERMOLPY    | WOTTERMOLPIES
+
+class noun-animal:
+[noun-animal-art] ms/remove-article/
+
+class noun-animal-1word:
+[noun-animal] ms/has-no-spaces/
+
+class noun-animal-singular:
+[noun-animal]
+
+multiclass noun-interval [-art, -plural]:
+A HECTONEWPIX         | HECTONEWPICES
+A LONGPIX             | LONGPICES
+A MINIP               | MINIPS
+A NOPIX               | NOPICES
+A NEWPIX              | NEWPICES
+A XIP                 | XIPS
+A DIP                 | DIPS
+A WIP                 | WIPS
+A YIP                 | YIPS
+
+class noun-interval:
+[noun-interval-art] ms/remove-article/
+multiclass noun-mineral [-art, -plural]:
+A BAG                 | BAGS
+A BAGPUN              | BAGPUNS
+A BAOBAB              | BAOBABS
+A BLINDPOST           | BLINDPOSTS
+A BLITZROCKET         | BLITZROCKETS
+A BOTCASTLE           | BOTCASTLES
+A BUFFYHAT            | BUFFYHATS
+A BUNGALOW            | BUNGALOWS
+A CAKE                | CAKES
+A CASBOTTLE           | CASBOTTLES
+A CASTRAFTLE          | CASTRAFTLES
+A CHRONOTRANSPONDER   | CHRONOTRANSPONDERS
+A COMA                | COMAS
+A C****KIE            | C****KIES
+A COLPIX              | COLPICES
+A CREDENZA            | CREDENZAS
+A CUPCAKE             | CUPCAKES
+A DECREE              | DECREES
+A DILGUNNERANG        | DILGUNNERANGS
+A DOOM BANANA         | DOOM BANANAS
+A FIRSTPOST           | FIRSTPOSTS
+A GAZEBO              | GAZEBOES
+A GRAPEVINE           | GRAPEVINES
+A HARPSICHORD         | HARPSICHORDS
+A HOTDOG              | HOTDOGS
+A HUGO                | HUGOS
+A LAPLEOPARD          | LAPLEOPARDS
+AN M&&M               | M&&MS
+A MANIP               | MANIPS
+A MIP                 | MIPS
+A MUSTARDIS           | MUSTARDISAR
+A MYSTERYONG          | MYSTERYONGS
+A NEEDLE-PULLED THING | NEEDLE-PULLED THINGS
+A NEWPIXBOTTIFICATION | NEWPIXBOTTIFICATIONS
+AN OLDPIX             | OLDPICES
+AN ONG                | ONGS
+AN OTHERCOMIC         | OTHERCOMICS
+AN OTTERCOMIC         | OTTERCOMICS
+AN OTTERONG           | OTTERONGS
+AN OTTIFICATION       | OTTIFICATIONS
+AN OVARY              | OVARIES
+A PASTPAGE            | PASTPAGES
+A PASTPOST            | PASTPOSTS
+A PHONESAW            | PHONESAWS
+A PLAN(C)K            | PLAN(C)KS
+A PUN                 | PUNS
+A PUNSAW              | PUNSAWS
+A PUZZLE              | PUZZLES
+A RAFTCASTLE          | RAFTCASTLES
+A REVEALER THE RECENT | REVEALERS THE RECENT
+A BLITZYCLE           | BLITZYCLES
+A REDUNDABIKE         | REDUNDABIKES
+A RIDONDAKITI         | RIDONDAKITI
+A RONG                | RONGS
+AN S&&M               | S&&MS
+A SCRUMPTIOUS DONUT   | SCRUMPTIOUS DONUTS
+A SILENTONG           | SILENTONGS
+AN ONGTHEMOON         | ONGTHEMOONS
+A SHIPCASTLE          | SHIPCASTLES
+A %5bSPOILER%5d       | %5bSPOILERS%5d
+A SPOILERCAKE         | SPOILERCAKES
+A SPURLER             | SPURLERS
+A STARRYONG           | STARRYONGS
+A STEAMBOTTLE         | STEAMBOTTLES
+A TARDIS              | TARDISES
+A THREAD              | THREADS
+A THWAPSTICK          | THWAPSTICKS
+A TIMEFRAME           | TIMEFRAMES
+A TIMEODY             | TIMEODIES
+A TREBUCHAT           | TREBUCHATS
+A TREBUCHET           | TREBUCHETS
+AN UNG                | UNGS
+A VITSSÅGEN           | VITSSÅGAR
+A WHEELSTICK          | WHEELSTICKS
+A WIPEND              | WIPENDS
+A WOWTERFALL          | WOWTERFALLS
+A WOWTREE             | WOWTREES
+
+class noun-mineral:
+[noun-mineral-art] ms/remove-article/
+
+class noun-plural:
+[noun-animal-plural]
+[noun-mineral-plural]
+[noun-interval-plural]
+
+class nounz:
+[noun-plural] ms/S$/Z/
+
+# 'unique' noun is one for which the article A or AN does not make sense:
+# There is only one OTC, so we do not say 'AN OTC' (but THE OTC is okay)
+# Ironically the noun-uniqie-article form is needed, to satisfy the
+# "Yes Virginia, there is a Santa Claus" template.
+class noun-unique-article:
+A COMFY CHAIR
+AN EPILOGUE
+A JAVASCRIPT
+A MROBDEX
+AN OTC
+AN OTT
+AN OTTSCARS
+AN OTW
+A QUESTIONABLE CARCASTLE
+A RECKONING
+A SKYCIRCLE
+A TYMIVERSARY
+A VATICAN MILLINER'S PERFECT CUSTOMER
+A VOLDEFRAME
+A WHISTLE OF TEMPORAL HARMONY
+A ZANCLEAN FLOOD
+ЯОЯЯІМ ТТО ИА
+
+class noun-unique:
+[noun-unique-article] ms/remove-article/
+[noun-unique-article] ms/ ИА$//
+
+#regex ra-balt: /(^ *AN? +)|( +ИА *$)//i
+#class nu-balt:
+#[noun-unique-article] ms/ra-balt/
+
+# In azule's version this is called "noun-definite"
+class noun-unique-the:
+[noun-unique] ms/add-the/
+
+# A 'commodity' noun is one for which the article A or AN makes sense
+# (and THE would also be all right). First we define these with their article
+# and then we make the commodity list by removing the articles from this list.
+class noun-comm-art:
+[noun-animal-art]
+[noun-mineral-art]
+[noun-interval-art]
+
+class noun-article:
+[noun-unique-article]
+[noun-comm-art]
+
+class noun-commodity:
+[noun-comm-art] ms/remove-article/
+
+class noun-singular:
+[noun-unique]
+[noun-commodity]
+
+class noun-pl-1word:
+[noun-plural] ms/has-no-spaces/
+
+class noun-singular-article:
+[noun-comm-art]
+
+class noun-singular-the:
+[noun-singular] ms/add-the/
+
+# Note that this defines "place-name" and "place-prep", but doesn't
+# define "place", but we immediately define that later.
+multiclass place [-name, -pr-in, -pr-out, -art]:
+CASSINI-MADAGASCAR | IN | OUT OF       | A
+THE CASTRAFTLE     | ON | OFF OF       | A
+CHATEAU D'IF       | IN | OUT OF       | A
+CHRONOCORP         | AT | OUT OF       | A
+GIBRALTAR          | IN | OUT OF       | A
+NEWPIXIA           | IN | OUT OF       | A
+OTTERCON           | AT | OUT OF       | AN
+R.A.Z.O.R.         | AT | OUT OF       | A
+SPAAACE            | IN | BACK FROM    | SOME
+THE AFOREWHEN      | IN | OUT OF       | AN
+THE AFTERWHEN      | IN | OUT OF       | AN
+THE BASEMENT       | IN | OUT OF       | A
+THE BEACH          | ON | AWAY FROM    | A
+THE BLUECAVE       | IN | OUT OF       | A
+THE BOTCASTLE      | IN | OUT OF       | A
+THE DUNES          | IN | OUT OF       | SOME
+THE FUTURE         | IN | BACK FROM    | A
+THE HILLS          | IN | OUT OF       | SOME
+THE MR*BDEX        | IN | OUT OF       | A
+THE MOONBASE       | ON | OFF OF       | A
+THE MOUNTAINS      | IN | OUT OF       | SOME
+THE MUSTARDIS      | IN | OUT OF       | A
+THE OTC            | IN | OUT OF       | AN
+THE OTT            | IN | OUT OF       | AN
+THE OUTSIDE        | IN | BACK FROM    | AN
+THE PAST           | IN | FORWARD FROM | A
+THE PRESENT TIME   | IN | OUT OF       | A
+THE RAFTCASTLE     | ON | OFF OF       | A
+THE RIVER          | ON | FROM         | A
+THE SANDCASTLE     | IN | OUT OF       | A
+THE SEA            | ON | FROM         | A
+THE TARDIS         | IN | OUT OF       | A
+THE TOWER          | ON | OUT OF       | A
+XKPLAINXKCD        | ON | FROM         | SOME
+ᘝᓄᘈᖉᐣ              | IN | OUT OF       | A
+ЯОЯЯІМ ТТО ƎНТ     | ON | OUT OF       | AN
+
+# Use this regex to transform IN/ON/AT to INTO/ONTO/INTO
+regex in-to-into: /IN/INTO/, /ON/ONTO/, /AT/INTO/
+
+# Use this regex to transform SOME/A/AN to THEM/IT/IT
+regex some-to-them: /SOME/THEM/, /AN?/IT/
+
+# This one is a little more elaborate; it is used when a [place] is
+# modified by another word (typically an adjective) and we want to
+# retain SOME when appropriate but otherwise use A or AN according to the
+# adjective that was added. For example, starting with:
+#     ... A RIVER ...
+#     ... SOME MOUNTAINS ...
+# we add adjectives to get:
+#     ... A AN ENDISH RIVER ...
+#     ... SOME AN ENDISH MOUNTAINS ...
+# then postprocess to remove the unwanted article:
+#     ... AN ENDISH RIVER ...
+#     ... SOME ENDISH MOUNTAINS ...
+regex postproc-some: / SOME AN? / SOME /, / AN? (AN?) / $1 /
+
+class place:
+[place-name]
+
+class place-noart:
+[place-name] ms/remove-the/
+
+# Test of fancy regex. To see results, uncomment the code and use the command:
+#
+#    automeme -v -n 30 -t '[test2]' | sort
+#
+#regex test3: /(^THE )|( ƎHT$)|($)//i
+#
+#class test1:
+#THE BAR
+#FOO ƎHT
+#QUX
+#
+#class test2:
+#[test1]  ms/test3/
+
+# Only used in the Russian Reversal meme (%%% we really need multiclass unions)
+multiclass place-russia [-name, -pr-in, -pr-out]:
+RUSSIA | IN | OUT OF
+RUSSIA | IN | OUT OF
+RUSSIA | IN | OUT OF
+RUSSIA | IN | OUT OF
+RUSSIA | IN | OUT OF
+
+class noun-singular-1word:
+[noun-singular] ms/has-no-spaces/
+
+class noun:
+[noun-singular]
+[noun-mass]
+
+class noun-the:
+[noun-singular-the]
+[noun-mass-the]
+
+class noun-1word:
+[noun] ms/has-no-spaces/
+
+class noun-plural-the:
+[noun-mass] ms/add-the/
+[noun-plural] ms/add-the/
+
+class noun-singular-that:
+[noun-singular] ms/add-that/
+[noun-unique] ms/add-that/
+
+# %%% This is a placeholder for a full negative-positive distinction system
+# to be added after I permit multiclass unions. For now it's okay because
+# it is only being used in one place and there aren't many negative nouns
+# to redundantly list twice and be redundant.
+#    Since the nouns are already multiclassed and already have one distinction (animal vs mineral), I'd want to define a way for two multiclasses to be union-ed together forming a new multiclass. That would also simplify existing memes where I use the isomorph syntax and I have to use "[verb-tr-xxx verb-intr-xxx]" instead of just "verb-xxx" so that the isomorph works.
+class noun-singular-neg-art:
+A BAGPUN
+A BRAINSLUG
+A C****KIE
+A DILGUNNERANG
+A DOOM BANANA
+A FACEBUG
+A KEYBOARD
+A LOOPIST
+A PUNSAW
+A RAPTORCAT
+A RAPTORSHARK
+A SPURLER
+A STEAMBOTTLE
+A THWAPSTICK
+A VOLDEFRAME
+
+class noun-singular-negative:
+[noun-singular-neg-art] ms/remove-article/
+
+# This probably won't be too useful. Some preps not listed (like BETWEEN) would be nice to add if I could make a prep-ref-plural for prepositions referencing a plural indirect object; or others (like INSTEAD OF) that require that the precedent phrae is [verb-tr] [object].
+class preposition:
+ABOVE
+ACROSS
+AMONGST
+ATOP
+BEFORE
+BELOW
+BESIDE
+CLOSE TO
+FOR
+FROM
+IN
+INSTEAD OF
+LIKE
+NEAR
+ON
+ONTO
+OUT OF
+OVER
+PAST
+'ROUND
+THROUGH
+TOWARDS
+UNDER
+UPON
+WITH
+
+class prep-1word:
+[preposition] ms/has-no-spaces/
+
+# ------------------------ INTRANSITIVE VERBS ------------------------
+
+# Column
+#   1   intransitive present continuous, as in "I am hiding", or "while hiding"
+#   2   intransitive 1st/2nd person present and infinitive, as in "I hide", "you hide", or "to hide" (3rd-person present is "verb-intr-present")
+#   3    intransitive past, as in "I hid"
+#   4    intransitive perfect, as in "I had hidden"
+#   5    intransitive third-person present, as in "he hides"
+
+multiclass verb-intr[-cont, -inf, -past, -perfect, -present, -art]:
+:AZULING:           | :AZULE:           | :AZULED:          | :AZULED:            | :AZULES:           | AN
+BASEMENTING         | BASEMENT          | BASEMENTED        | BASEMENTED          | BASEMENTS          | A
+BLINDPOSTING        | BLINDPOST         | BLINDPOSTED       | BLINDPOSTED         | BLINDPOSTS         | A
+CHEWING BEESNAKES   | CHEW BEESNAKES    | CHEWED BEESNAKES  | CHEWED BEESNAKES    | CHEWS BEESNAKES    | A
+CH**RPING           | CH**RP            | CH**RPED          | CH**RPED            | CH**RPS            | A
+COMAING             | COMA              | COMA'D            | COMA'D              | COMAS              | A
+DELURKING           | DELURK            | DELURKED          | DELURKED            | DELURKS            | A
+DOODLING FURIOUSLY  | DOODLE FURIOUSLY  | DOODLED FURIOUSLY | DOODLED FURIOUSLY   | DOODLES FURIOUSLY  | A
+GOING CAVE          | GO CAVE           | WENT CAVE         | GONE CAVE           | GOES CAVE          | A
+HIDING FROM CORINNE | HIDE FROM CORINNE | HID FROM CORINNE  | HIDDEN FROM CORINNE | HIDES FROM CORINNE | A
+KETCHUPPING         | KETCHUP           | UPKETCHED         | UPKETCHED           | KETCHUPS           | A
+MOLPYING ABOUT      | MOLPY ABOUT       | MOLPIED ABOUT     | MOLPIED ABOUT       | MOLPIES ABOUT      | A
+MOLPYING DOWN       | MOLPY DOWN        | MOLPIED DOWN      | MOLPIED DOWN        | MOLPIES DOWN       | A
+MOLPYING UP         | MOLPY UP          | MOLPIED UP        | MOLPIED UP          | MOLPIES UP         | A
+POSTING             | POST              | POSTED            | POSTED              | POSTS              | A
+UNBASEMENTING       | UNBASEMENT        | UNBASEMENTED      | UNBASEMENTED        | UNBASEMENTS        | AN
+WAITING             | WAIT              | WAITED            | WAITED              | WAITS              | A
+WAITING FOR IT      | WAIT FOR IT       | WAITED FOR IT     | WAITED FOR IT       | WAITS FOR IT       | A
+*AUFMOLP*ING        | *MOLP* *AUF*      | *MOLP*ED *AUF*    | *AUFGEMOLPT*        | *MOLP*S *AUF*      | AN
+E:E:EING            | E:E:E             | E:E:E'D           | E:E:E'D             | E:E:ES
+# For testing
+#SINGING             | SING              | SANG              | SUNG                | SINGS             | A
+
+# ------------------------ TRANSITIVE VERBS ------------------------
+
+ #Column
+#   1    transitive present continuous, as in "I am drinking milk" or "while drinking milk"
+#   2    transitive 1st/2nd person present, and infinitive, as in "I drink milk" or "to drink milk" (3rd-person present is "verb-tr-present"); used with "will" for future tense
+#   3    transitive past tense, as in "I drank milk"
+#   4    transitive active-perfect or passive-perfect, as in "he had drunk milk" or "the milk had been drunk"; used with "will have" for future-perfect
+#   5    transitive 3rd person present, as in "he drinks milk"
+#   6    article for use in compound phrases, e.g. "A" for "a drinking party"
+multiclass verb-tr[-cont, -inf, -past, -perfect, -present, -art]:
+BLITZING       | BLITZ       | BLITZED       | BLITZED       | BLITZES       | A
+BLITZNAPPING   | BLITZNAP    | BLITZNAPPED   | BLITZNAPPED   | BLITZNAPS     | A
+BLUENHANCING   | BLUENHANCE  | BLUENHANCED   | BLUENHANCED   | BLUENHANCES   | A
+CH**RPING      | CH**RP      | CH**RPED      | CH**RPED      | CH**RPS       | A
+CORINNING      | CORINNE     | CORINNED      | CORINNED      | CORINNES      | A
+CRENELLATING   | CRENELLATE  | CRENELLATED   | CRENELLATED   | CRENELLATES   | A
+DEMUSTARDING   | DEMUSTARD   | DEMUSTARDED   | DEMUSTARDED   | DEMUSTARDS    | A
+****DING       | ****D       | ****DED       | ****DED       | ****DS        | AN
+ENHANCING      | ENHANCE     | ENHANCED      | ENHANCED      | ENHANCES      | AN
+GOATING        | GOAT        | GOATED        | GOATED        | GOATS         | A
+HOTDOGGING     | HOTDOG      | HOTDOGGED     | HOTDOGGED     | HOTDOGS       | A
+KETCHUPPING    | KETCHUP     | UPKETCHED     | UPKETCHED     | KETCHUPS      | A
+MEMEIFYING     | MEMEIFY     | MEMEIFIED     | MEMEIFIED     | MEMEIFIES     | A
+MUSTARDING     | MUSTARD     | MUSTARDED     | MUSTARDED     | MUSTARDS      | A
+NINJAING       | NINJA       | NINJA'D       | NINJA'D       | NINJAS        | A
+ONGING         | ONG         | ONG'D         | ONG'D         | ONGS          | AN
+OTTCOLORISING  | OTTCOLORISE | OTTCOLORISED  | OTTCOLORISED  | OTTCOLORISES  | AN
+OTTIFYING      | OTTIFY      | OTTIFIED      | OTTIFIED      | OTTIFIES      | AN
+POSTING        | POST        | POSTED        | POSTED        | POSTS         | A
+PUNSAWING      | PUNSAW      | PUNSAWED      | PUNSAWED      | PUNSAWS       | A
+SACRIFICING    | SACRIFICE   | SACRIFICED    | SACRIFICED    | SACRIFICES    | A
+SCHIZOBLITZING | SCHIZOBLITZ | SCHIZOBLITZED | SCHIZOBLITZED | SCHIZOBLITZES | A
+SPOILERING     | SPOILER     | SPOILERED     | SPOILERED     | SPOILERS      | A
+SUSTAINABILIZING | SUSTAINABILIZE | SUSTAINABILIZED | SUSTAINABILIZED | SUSTAINABILIZES | A
+THWAPPING      | THWAP       | THWAPPED      | THWAPPED      | THWAPS        | A
+WAITING FOR    | WAIT FOR    | WAITED FOR    | WAITED FOR    | WAITS FOR     | A
+
+class verb-inf:
+[verb-intr-inf]
+[verb-tr-inf]
+
+class verb-inf-1word:
+[verb-inf] ms/has-no-spaces/
+
+class verb-cont:
+[verb-intr-cont]
+[verb-tr-cont]
+
+template verb-cont-article: [verb-tr-cont, verb-intr-cont][][$0/-art] [$0/hyphenate/][]
+
+class verb-cont-1word:
+[verb-cont] ms/has-no-spaces/
+
+class verb-present:
+[verb-intr-present]
+[verb-tr-present]
+
+class verb-present-1word:
+[verb-present] ms/has-no-spaces/
+
+class verb-tr-perfect-1word:
+[verb-tr-perfect] ms/has-no-spaces/
+# Convert a verb-present to archaic "-eth" ending. The conversions are meant to be a bit humorous.
+regex present-to-eth: /$/:/, /ES:/ETH:/, /([AIOU])S:/$1ETH:/, /TS:/TETH:/, /(.)S:/$1$1ETH:/, /:$//
+regex prepend-re:  /^/:/, /(:*)/$1RE-/, /^://
+class verb-past:
+[verb-intr-past]
+[verb-tr-past]
+
+class verb-perfect:
+[verb-intr-perfect]
+[verb-tr-perfect]
+
+# Used only to test/demonstrate the non-redundancy algorithm.
+class avoid:
+FOO
+BAR
+BAZ
+QUX
+
+# [all-vocab] attempts to include every word exactly once. It cannot be perfect.
+class all-vocab:
+[adjective]
+[adverb]
+[character-1word]
+[interjection]
+[noun-mass]
+[noun-animal]
+[noun-mineral]
+[noun-interval]
+[noun-unique]
+[place-noart]
+[prep-1word]
+[verb-inf-1word]
+
+class all-vocab-f:
+[all-vocab] ms/^(F)/$1/
+
+class all-vocab-i:
+[all-vocab] ms/^(I)/$1/
+
+class all-vocab-h:
+[all-vocab] ms/^(H)/$1/
+
+class all-vocab-p:
+[all-vocab] ms/^(P)/$1/
+
+class all-vocab-t:
+[all-vocab] ms/^(T)/$1/
+# ---------------------- CLASSLIKE TEMPLATES -----------------------
+
+# Get out of recentmost class definition
+templates:
+
+# Generate a character name that has been transformed for use in a
+# SUP DAWG, ... meme. For example,
+regex dawgify: /O\b/OH/gi, /\bA|A\b/UH/gi, /EA/EE/gi, /X/KS/gi, /CK/KK/gi, /C|CH/K/gi, /UR/R/gi, /IR/UR/gi, /ER/A/gi, /TH/D/gi, /EW/U/gi, /CU/KYU/gi, /EST/IST/gi, /({^AEIOU})\1/$1/gi, /Y\b/EE/gi, /WH/W/gi, /I([^AEIOU])E\b/IE$1/gi, /O([^AEIOU])E\b/OA$1/gi, /U([^AEIOU])E\b/YOO$1/gi
+template dawgchar: [character][][$0/dawgify/][]
+# For testing:
+# [character][][$0] -> [$0/dawgify/]
+
+# -------------------- REGEXes FOR REPLACEABLES --------------------
+
+# Abbreviate a trailing "ING" to "IN'" (meant for verbs)
+regex abbrev-ing: /:$/ :/, /$/ /, /ING /IN' /, / $//, / :$/:/
+
+# Add an article A or AN
+regex add-article: /^/A /, /^A ({AEIOU})/AN $1/
+
+# Transform a continuous verb, such as "RUNNING", into the plural
+# of the actor ("RUNNERS"). Also turns "MOLPYING DOWN" into "MOLPIERS DOWN",
+# and avoids turning "SINGING" into "SERSERS" or "SERSING": it does
+# this by first adding a blank space to the end, then transforming -YING
+# or -ING only if it is followed by a space, then removing the extra space
+# at the end.
+regex cont-to-actors: /:$/ :/, /$/ /, /YING /IERS /, /ING /ERS /, /EERS /ERS /, / $//, / :$/:/
+regex cont-to-actor: /:$/ :/, /$/ /, /YING /IER /, /ING /ER /, /EER /ER /, / $//, / :$/:/
+
+# Return the first letter of the string: given "MORDOR", returns "M".
+regex first-letter: /^(.).*/$1/
+
+# Return the first "word" (any group of characters except a space) of a string, or the whole string if it has no spaces.
+regex first-word: /^({^ }+) .*$/$1/
+regex second-word: /^{^ }+ //, /^({^ }+) .*$/$1/
+# Return the last "word"
+regex last-word: /^.* ({^ }+)$/$1/
+
+# Remove a '-' and everything after it, leaving only the former part.
+# For example if the string is "404-NOT FOUND", this returns just the "404".
+regex former-part: /{`}.*$//
+#
+regex middle-part: /^{^`}*{`}//, /{`}{^`}*$//
+# Remove any initial text up to a '`' (with greedy matching), leaving
+# only the latter part. For example if the string is "404-NOT FOUND",
+# this returns just the "NOT FOUND".
+regex latter-part: /^.*{`}//
+
+# Turn all 'R' and 'L' into 'W'
+regex fudd: /{RL}/W/g
+
+# Turn spaces to hyphens '-'
+regex hyphenate: / /-/g
+
+# Return the initial letters of all words in the string: given "REVEALER THE RECENT", returns "RTR".
+regex initial-letters: /-/ /g, /^/ /, / (.){^ }*/$1/g, /^ //
+
+# From azule: tries to turn a noun into the comparative adjective form. Examples: THREAD -> THREADIER ; OVARY -> OVARIER ; MOLPHIN -> MOLPHINNIER
+regex intensify: /(?:I?{EY}?|(?:ED)?|({AEIOU}?({GTN}?)))$/$1$2/, /$/IER/
+
+# Letter multipliers. These are named based on the sample words AGILE
+# (representing a words that starts with a vowel) or DEFILE (representing
+# one that starts with a consonant
+
+# ...vC -> ...vCC : AGILE->AGGILE, DEFILE->DEFFILE
+# Double first post-vowel consonant
+regex lm-aggile: /({AEIOU})({^AEIOU})/$1$2$2/
+
+# ...V -> ...VVVV : AGILE->AGIIIILE, DEFILE->DEEEEFILE
+# Increase first vowel to 4x
+regex lm-aaaagile: /({AEIOU})/$1$1$1$1/
+
+# AGILE->AGGIIIILE, DEFILE->DEFFIIIILE
+regex lm-aggiiiile: /({AEIOU})({^AEIOU})({^AEIOU}*)({AEIOU})/$1$2$2$3$4$4$4$4/
+
+# Negate a (positive, bare) adjective by adding "AN UN" to the beginning
+regex negate-adjective: /^/AN UN/
+
+# Remove a first word, if any
+regex remove-first-word: /^{^ }+ //
+
+# Remove everything up to the first vowel (Used in the "Bless you, ants. Blants." template)
+regex remove-leading-consonants: /^.*?({AEIOU})/$1/
+
+# If the input ends in 'S' return a null string, else return an 'S'
+regex s-ending-invert: /TARDIS$/TARDI/, /$/S/, /^.*?({S}+)$/$1/, /SS//
+
+# Add 'SOVIET' to the beginning of something (which should probably be a
+# [place]), then switch if it started with 'THE', move the article to
+# the beginning. Thus, "ENGLAND" would become "SOVIET ENGLAND" and
+# "THE BEACH" would become "THE SOVIET BEACH".
+regex sovietize: /^/SOVIET /, /SOVIET THE/THE SOVIET/
+
+# Spell out a word, for example "WORD" becomes "W-O-R-D"
+regex spell-out: /({A-Z})/$1-/g, /- / /g, /-$//
+
+# Change an initial article 'THE' to 'THIS'
+regex the-to-this: /^THE /THIS /
+
+template random-digit: [0@0.1, 1@0.111111, 2@0.125, 3@0.142857, 4@0.166667, 5@0.2, 6@0.25, 7@0.333333, 8@0.5, 9][]
+template random_12: [@0.333, 1@0.5, 2][]
+
+
+
+template imper1: [verb-tr-inf] THE [noun-plural, noun-mass, adjec-noun][]
+template imper2: [verb-tr-inf] [noun-plural] [preposition] THE [noun-singular, noun-mass, adjec-noun][]
+template imper3: [verb-intr-inf] [preposition] THE [noun-singular, noun-mass, adjec-noun][]
+template imper4: [place-name][$0/remove-the/][][verb-intr-inf] [$0/-pr-out] [$0/-art] [$1][]
+template sentence-imperative: [imper1, imper2, imper3, imper4][]
+
+# -----------------------------  MEMES -----------------------------
+
+
+# From South Park episode "Gnomes" (1998) "1. Collect Underpants. / 2. ? / 3. Profit"
+#-1. COLLECT UNDERPANTS. 2. ? 3. PROFIT
+PHASE 1. [sentence-imperative] / / PHASE 2. [sentence-imperative] / / PHASE 3. [sentence-imperative] / / PHASE 4. ??? / / PHASE 5. [PROFIT@0.5, verb-inf]!!!
+# "404 Not Found", A common error when browsing the World Wide Web
+# "408 Request Timeout", errors happened on the OTT for a while (see OTT:1916:19#p3579895, OTT:1970:9#p3599612, OTT:1981:0|#p3604672, OTT:1993:36|#p3609728, etc.)
+# "503 Service Unavailable", errors have affected the OTT several times due to spambot attacks
+# We select one of three literal strings, cut [], and invoke the string twice using regexps to extract the two parts.
+#-404 - NOT FOUND
+[404-NOT FOUND@0.33, 408-REQUEST TIMEOUT@0.5, 503-UNAVAILABLE][][$0/former-part/] -- [noun-singular] [$0/latter-part/]
+
+# azule: xkcd #647
+#-9/11 HEPPENED BEFORE...
+THE [ZANCLEAN@0.5, adjective-negative] [FLOOD@0.5, noun] HAPPENED BEFORE I WAS BORN, YET I'M OLD ENOUGH TO HAVE THIS CONVERSATION WITH YOU.
+
+# From "That's Why I assault Ren" (a manga about pedophilia, 2007), original phrase is "A cat is fine too" ; http://knowyourmeme.com/memes/a-cat-is-fine-too
+#-A CAT IS FINE TOO
+[noun-singular-article] IS [adjective] TOO
+
+# xkcd #1318, memeified by mrob27.
+# First we define a template for each of the six sentences in the comic.
+template xkcd1318a: [noun-plural] SUGGEST IT'S [adjective].[]
+template xkcd1318b: IT'S [noun-singular-article].[]
+template xkcd1318c: IT'S [adjective-article] [noun-singular].[]
+template xkcd1318d: IT'S [noun-singular-article] [verb-tr-perfect] BY THE [noun-singular, adjective] [noun-plural].[]
+template xkcd1318e: IT'S THAT PLUS [adjective] [noun-singular].[]
+template xkcd1318f: IT'S [verb-tr-perfect] IN [noun-singular-article, noun-unique-article] THAT'S [verb-tr-perfect].[]
+#
+# Next, define a template that chooses at random one of the above six forms.
+template xkcd1318-part: [xkcd1318a, xkcd1318b, xkcd1318c, xkcd1318d, xkcd1318e, xkcd1318f][]
+#
+# Then, make a random xkcd 1318 by doing [xkcd1318-part] six times, with an *ACTUALLY* in between each one.
+#-ACTUALLY, MEASUREMENTS SUGGEST...
+... *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, ...
+# "A few cards short of a full deck", etc. and probably rather old ; http://snowclones.org/2007/10/03/a-few-x-short-of-a-y/
+#-A FEW X SHORT OF A Y
+... XE'S [JUST @0.5,]A FEW [noun-plural] [SHY@0.5, SHORT] OF [noun-singular-article]
+
+# Added by mrob27
+# Shakespeare (Richard III, 1591) "A horse, a horse! My kingdom for a horse" ; http://snowclones.org/2008/06/04/my-kingdom-for-an-x/
+#   and noting that "my kingdom for an" now yields results from Google, thus we need not ensure the noun starts with a consonant
+#-A HORSE, A HORSE! MY...
+[noun-singular-article], [$0], MY KINGDOM FOR [$0]
+
+# Japanese meme: Image of a baby Manga-captioned with a two-part contrary zinger (example: "That's a lovely sweater ... / for me to puke on!!!") followed by the tag-line まさに外道!!! (masanigedou, "downright heresy") indicating that the baby is a demon for being so impolite ; http://knowyourmeme.com/memes/aka-san-gedo-beibi-%E5%A4%96%E9%81%93%E3%83%99%E3%82%A4%E3%83%93%E3%83%BC
+#-AKA-SAN / GEDOU BEIBII
+#[THAT@0.5, YOUR] [noun] WAS [PRETTY@0.25, MOLPISHLY@0.33,, adverb-positive] [adjective-positive] ... FOR A [noun-singular-negative]. *まさに外道!!!*
+
+# Zero Wing animation (2000); http://snowclones.org/2011/01/10/all-your-x-are-belong-to-us/
+#-ALL YOUR BASE ARE BELONG TO US
+ALL YOUR [noun-singular] ARE BELONG TO [noun-singular, noun-plural, noun-mass, character]
+
+# Firefly TV series ("Trash" episode, 2003); the original quote was "Also, I can kill you with my brain."
+#-ALSO, I CAN KILL ...
+ALSO, I CAN [verb-tr-inf] YOU WITH MY [noun-singular].
+
+# Added by @Link, not in AUTOMEME
+# deviantART comic by Angela Dunn (2009) with words "Angie grab my boobs"; http://knowyourmeme.com/memes/x-grab-my-y
+#-ANGIE GRAB MY...
+[character] GRAB MY [noun-singular, noun-plural]
+
+# azule: xkcd #859
+#-AN UNMATCHED LEFT PARENTHESIS
+[adjective][][$0/negate-adjective/] [noun-singular] CREATES AN UNRESOLVED TENSION THAT WILL STAY WITH YOU ALL [noun-interval]
+
+# Videogame "Genji: Days of the Blade" (2006), used as a live demo during Sony's unveiling of the PS3 console, showed the "Giant Enemy Crab" character; original game's text is "you attack its weak point for massive damage" ; http://knowyourmeme.com/memes/e3-sony-2006-giant-enemy-crab
+#-ATTACK ITS WEAK POINT...
+template decr1: ATTACK ITS WEAK POINT FOR [adjective] [noun-singular, noun-plural, noun-mass][]
+[decr1]
+
+# Pokemon "Wild X Appeared!" (with X being any Pokemon Red + Blue character, e.g. EKANS or ZUBAT), later changed to "A wild X appeared!", present tense form also seen on Internet; http://knowyourmeme.com/memes/a-wild-x-appears-wild-x-appeared
+#-A WILD PIKACHU APPEARS
+A WILD [noun-singular] [APPEARED@0.5, APPEARS]!
+
+# "The Dark Knight" (Batman film, 2008) "Because he's the hero Gotham deserves, but not the one it needs right now"
+#-BECAUSE HE'S THE HERO...
+[place][$0/s-ending-invert/][][character] IS THE [HERO@0.3, noun, noun-unique] [$0] DESERVE[$1], BUT NOT THE ONE IT NEEDS RIGHT NOW.
+
+# Fanfictoon "Halflife: Full Life Consequences" (2006) "Because you are headcrab zombie"
+#-BECAUSE YOU ARE HEADCRAB...
+BECAUSE YOU ARE *[HEADCRAB@0.33, adjective] [noun-singular, noun-mass]*
+
+# 4chan meme "Become an hero", referring to suicide ; http://en.wiktionary.org/wiki/an_hero , http://www.nytimes.com/2008/08/03/magazine/03trolls-t.html
+#-BECOME AN HERO
+template decr2: BECOME AN [noun-singular, noun-plural, noun-mass][]
+[decr2]
+
+# Bear Grylls, "Better Drink My Own [urine]", on the UK TV programme "Born Survivor", via reddit
+#-BETTER DRINK MY OWN...
+BETTER [verb-tr-inf] MY OWN [noun-singular, noun-mass, adjec-noun]
+
+# By Link; Elmer Fudd (character in Chuck Jones cartoons, ca. 1951 and later) "Be vewy vewy quiet, I'm hunting wabbits"
+#-BE VEWY VEWY QUIET...
+template decr3: [adjective][HUNTING@0.5, verb-tr-cont][noun-plural][]BE VEWY VEWY [$0/fudd/], I'M [$1/fudd/] [$2/fudd/][]
+[decr3]
+
+# captioned image (2008) "Bitches dont know about my popsicle"; http://knowyourmeme.com/memes/bitches-dont-know-about-my-popsicle
+#-BITCHES DON'T KNOW ABOUT...
+[noun-plural] DON'T KNOW ABOUT MY [noun-singular, noun-plural, noun-mass]
+
+# In both of the originals (AUTOMEME and Link's AUTOMOME) this meme includes
+# multi-word NOUNs.
+# "Look Around You" mock educational programme (2002-2005), "Bless you ants. Blants."; At end of video: https://www.youtube.com/watch?v=gaI6kBVyu00
+#-BLESS YOU, ANTS. BLANTS.
+BLESS YOU, [noun-plural, noun-mass, character, adjec-noun]. BL[$0/remove-leading-consonants/].
+
+# From xkcd #442
+#-BOOM DE YADA
+# We make an effort to form the desired number of syllables
+#
+# Replace a word or phrase with a number of I's for every syllable in it. This
+# actually just counts the number of vowel-clusters, which almost always works.
+# Some examples:
+#    MOLPY -> I     TARDIS -> II     ZANCLEAN FLOOD -> III     HAMPLY -> II
+# and note that "ZANCLEAN" might be wrong depending on how you pronounce it.
+regex count-syllables: /{^AEIOUY}*{AEIOUY}+{^AEIOUY}*/i/g, /{^i}//g, /i/I/g
+#
+# Pick a noun, then count its syllables, and then turn the syllable-count into
+# "THE" only if it is less than 3. The key here is the two-step regex: First
+# it matches /III+/ and replaces with //, which makes the string null if it
+# had three I's or more; then it does /I+/THE/ which turns the string
+# into "THE" but only if there were I's present.
+template noun2s: [noun][$0/count-syllables/][$1/III+//, /I+/THE /][][$2][$0][]
+#
+# $1: syllable count: PLANCK->I, WOWTREE->II, RAPTORSHARK->III
+# $2: "THE " if $0 is II or less, else ""
+# $3: " IS" if $0 is I or less, else "'S"
+#   so we get "THE PLANCK IS", "THE WOWTREE'S", "THE RAPTORSHARK'S"
+template nounis: [noun, noun-mass, adjec-noun][$0/count-syllables/][$1/III+//, /I+/THE /][$1/II+//, /$/'S/, /I'S/ IS/][][$2][$0][$3][]
+# Pick a noun-plural, and if it has 4 or syllables be happy, but if it has only 3 or fewer add 'THE'
+template noun3s: [noun-plural][$0/count-syllables/][$1/IIII+//, /I+/THE /][][$2][$0][]
+#
+# Similar to noun3s except starting with an -ING verb
+template verb3s: [verb-cont][$0/ING$/NGI/][$1/count-syllables/][$2/IIII+//, /I+/THE /][][$3][$0][]
+#
+template boomdeyada: [BOT-TER-IADA@0.1, BOOM-DE-YADA][]
+#
+# Put it all together. Note that in order to get the *same* [boomdeyada] twice, we need to involve the macro once and then copy it with the "[$0], [$0]" syntax.
+[boomdeyada][]I LOVE [verb3s]. [I LOVE@0.5, AND ALL] [noun3s]. [nounis] PRETTY COOL. [$0], [$0].
+
+# Eddard Stark (Game of Thrones character); original quote is "Brace yourselves; winter is coming".
+#-BRACE YOURSELVES; WINTER...
+BRACE [YOURSELF@0.5, YOURSELVES], [noun-singular, noun-mass, adjec-noun] IS COMING
+
+# Added by mrob27
+# Breakin' 2: Electric Boogaloo (1984); http://snowclones.org/2008/05/15/x-2-electric-boogaloo/
+#   The replaceable is a movie title, so it could be anything though a single word seems most suitable. For the 'bag' reference, see [OTT:467:23|#p3342973]
+#-BREAKIN' 2: ELECTRIC...
+*[noun-singular, noun-mass, noun-plural, verb-tr-cont, verb-tr-inf] 2: ELECTRIC BAGALOO*
+
+# A valid, though extremely unlikely or absurd, sentence made from repeating the same word several times. See OTT:280:12#p3322793, OTT:280:20#p3322806 ; http://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo
+#-BUFFALO BUFFALO BUFFALO...
+template buffalow: [noun-1word, verb-inf-1word, verb-inf-1word, interjection][]
+template buffalo1: [buffalow][][$0], [$0] [$0] [$0], [$0] [$0][]
+template buffalo2: [buffalow][][$0] [$0], [$0] [$0] [$0], [$0] [$0][]
+template buffalo3: [buffalow][][$0] [$0] [$0], [$0] [$0], [$0] [$0][]
+[buffalo1, buffalo2, buffalo3].
+# azule: xkcd #598
+#-CAN YOU TRY TO LOOK... BLOCKIER?
+template xkcd598a: [noun-singular-negative][]CAN YOU TRY TO LOOK... [$0/intensify/]?[]
+template xkcd598b: CAN YOU TRY TO LOOK... [adjec-comp]?[]
+template decr4: [xkcd598a, xkcd598b][]
+[decr4]
+
+# By Link
+# An example is in the M*A*S*H film (1970) "Captain Pierce went to Japan and all he got me was this lousy T-shirt"
+#-CAPTAIN PIERCE WENT...
+template went1: WENT TO [place][]
+template went2: [verb-tr-past] THE [noun-plural][]
+[I@0.2, character] [went1, went2], AND ALL I GOT WAS THIS LOUSY [HAT@0.17, T-SHIRT@0.2, FLIP-BOOK@0.25, noun-singular, noun-unique]
+
+# Photo of a cat peeking down from a hole in the ceiling (2003), later captioned with "Ceiling cat is watching you masturbate" (2006); http://knowyourmeme.com/memes/ceiling-cat
+#-CEILING CAT IS WATCHING...
+CEILING [noun-singular, character] IS WATCHING YOU [verb-tr-inf, verb-intr-inf]
+
+
+
+
+
+# azule: xkcd #285 "[Citation needed]", commonly seen on Wikipedia
+#-CITATION NEEDED
+%5b_[CITATION@0.3, noun-singular, noun-mass] [NEEDED@0.3, verb-tr-past]_%5d
+
+# webcomic/blog "Hyperbole and a Half", strip titled "Why I'll Never be an Adult" (2010) featuring the line "Clean *ALL* the things!" (cartoon image of person holding a broom with hand-written caption) ; http://knowyourmeme.com/memes/x-all-the-y
+#-CLEAN ALL THE THINGS
+template decr5: [verb-tr-inf] *ALL* THE [noun-plural, noun-mass, adjec-noun][]
+[decr5]
+I [verb-tr-past] *ALL* THE [noun-plural, noun-mass, adjec-noun]
+
+# Image macro of a surprised parson/face captioned with "Cock goes where?" or "Penis goes where?" ; http://knowyourmeme.com/memes/penis-goes-wherecock-goes-where
+#-COCK GOES WHERE
+[noun] GOES *WHERE?*
+
+# Added by mrob27. Matthew 6:28 (part of the Sermon on the Mount) "Consider the lilies of the field, how they grow; they toil not, neither do they spin",  or Luke 12:24 "Consider the ravens: for they neither sow nor reap; which neither have storehouse nor barn; and God feedeth them..." ; http://snowclones.org/2011/01/06/consider-the-x/
+# The [consider3] template is based on Monty Python "Life of Brian" (1979), "I haven't got anything against the birds. Consider the lilies."
+#-CONSIDER THE LILIES OF THE FIELD
+template consider1: CONSIDER THE [noun-plural, adjec-noun][]
+template consider1a: [consider1] OF [place][]
+template consider2: AND WHY DO YOU WORRY ABOUT [noun-plural]? [consider1, consider1a], HOW THEY [verb-tr-inf]: THEY NEITHER [verb-tr-inf] NOR [verb-tr-inf].[]
+template consider3: I HAVEN'T GOT *ANYTHING* AGAINST THE [noun-plural]! [consider1].[]
+[consider1a, consider2, consider3]
+template decr6: [consider1a][]
+
+# azule: xkcd #401
+#-COOL! I JUST GAVE A HELICOPTER...
+[TREEISH@0.2, MOLPISH@0.25, NEAT@0.3, adjective-positive]!  I JUST GAVE [noun-article, place] CANCER.
+
+# azule: xkcd #936
+#-CORRECT HORSE BATTERY STAPLE
+[character][]EASY-TO-REMEMBER PASSWORD: [CORRECT@0.2, adjective] [$0/remove-the/] [noun] [noun]
+
+# Randall Munroe What-If book, p. 187
+#-COULD A (SMALL) ROCKET...
+[place-name][adjective-article][]COULD [$1/^(AN? )/$1%28/]) [noun] (WITH [noun]) BE [verb-tr-perfect] TO [adjective-article] POINT [$0/-pr-in] [$0] WHERE IT WOULD ONLY NEED [adjective-article] [noun-mineral] TO GET TO [adjective] [adjec-noun]?
+
+# Friends TV show (1996) "Could I *be* wearing any more clothes?", snowclone associated with Chandler though it was Joey who said that line; http://friends.wikia.com/wiki/Running_Gags#Could_I_BE_any_more....3F
+#-COULD I BE WEARING ANY MORE...
+COULD [noun-plural, noun-mass, character, adjec-noun] *BE* ANY MORE [adjective]?
+
+# Randall Munroe What-If book, p. 199
+#-COULD YOU SURVIVE...
+[place-name][]COULD YOU [verb-tr-inf] [noun-singular-article] BY [verb-tr-cont] YOURSELF [$0/-pr-in] [adjective-article] [$0/remove-the/]?
+
+# Film "Crouching Tiger, Hidden Dragon" (2000)
+#-CROUCHING TIGER, HIDDEN...
+[CROUCHING@0.7, verb-cont-1word] [RAPTORCAT@0.1, noun-singular], [HIDDEN@0.7, adjective, verb-tr-perfect-1word] [DRAGON@0.1, noun-singular]
+
+# From Link; Doctor Who (1988) "Crush the lesser races! Conquer the galaxy! Unimaginable power! Unlimited rice pudding! Et cetera! Et cetera!"
+#-CRUSH THE LESSER...
+[verb-tr-inf] THE [LESSER@0.67, adjective] [noun-plural]! [verb-tr-inf] THE [noun, adjec-noun]! UNIMAGINABLE [noun-mass, adjec-noun]! UNLIMITED [RICE PUDDING@0.5, noun-mass, noun-plural, adjec-noun]! ET CETERA, ET CETERA!
+
+# Star Trek (original TV series, 1966); http://snowclones.org/2007/08/06/dammit-jim-im-an-x-not-a-y/
+#   notable for having been a snowclone from the very start
+# DAMMIT JIM, I'M A DOCTOR...
+template t-verb-actor-article: [verb-tr-cont, verb-intr-cont][][$0/-art] [$0/cont-to-actor/][]
+template t-noun-singular-article: [noun-singular-article][]
+template noun-or-actor: [t-verb-actor-article, t-noun-singular-article][]
+DAMNIT [JIM@0.5, char-noart], I'M [noun-or-actor], NOT [noun-or-actor]!
+
+# Doctor Who "A Good Man Goes to War" (2011) "Demons run when..."
+#-DEMONS RUN WHEN A GOOD MAN GOES TO WAR
+[noun-plural] RUN WHEN [A GOOD@0.25, A MOLPISH@0.33, adjective-article] [noun] GOES TO [WAR@0.33, place]
+
+# By Azule: xkcd #1046
+#-DESTROY TOTALLY JUST STOPPED...
+template unrealpre: [RAPTOR@0.1, ][]
+template unrealsuf: [SOME@0.111, FUL@0.125, NESS@0.167, ITUDE@0.2, ED@0.25, ISH@0.333, MOLP@0.5, ][]
+regex eed-ed: /({^AEIOU})EED/$1ED/g
+template unrealword: [unrealpre][noun, adjective, place-noart, verb-cont][unrealsuf][]
+[unrealword][]"[$0/eed-ed/]" TOTALLY JUST STOPPED SEEMING LIKE A REAL WORD.
+
+# Dial M for Murder (1954 film)
+#-DIAL M FOR MURDER
+template decr7: [noun-singular, noun-plural, noun-mass, character, adjec-noun] []DIAL [$0/first-letter/] FOR [$0][]
+[decr7]
+
+# From Azule: an OTT running gag
+#-DID ANYONE NOTICE...
+DID ANYONE NOTICE THE [JAVASCRIPT@0.2, noun, adjec-noun]?
+
+# Official poster for film "Die Hard 2" (1990) featured the words "DIE HARDER", leading to the movie being called "Die Hard 2: Die Harder" which became a snowclone meme.
+#-DIE HARD 2: ...
+[verb-inf-1word] HARD 2: [$0] HARDER
+
+# A trolling phrase, from an unknown IRC channel in 2002, via 4chan ("HAHAHA DISREGARD THAT, I SUCK COCKS”) ; http://knowyourmeme.com/memes/disregard-that-i-suck-cocks
+#-DISREGARD THAT, I...
+DISREGARD THAT, I [verb-tr-inf] [noun-plural, noun-mass, adjec-noun]
+
+# Pantene shampoo commercial, "Don't hate me because I'm beautiful" ; http://snowclones.org/2007/09/11/dont-hate-me-because-im-y/
+#-DON'T HATE ME BECAUSE..
+DON'T [HATE@0.3, verb-tr-inf] ME BECAUSE I'M [FLUTTERBEEWINGISH@0.2, WINGISH@0.25, adjective]
+
+# Movie title (Doctor Strangelove)
+#-DR. STRANGELOVE, OR HOW...
+DR. [noun-singular, noun-mass, character], OR HOW I LEARNED TO STOP [WORRYING@0.1, verb-intr-cont] AND LOVE THE [noun-singular]
+
+# From balthasar_s ; the mother of all snowclones: Franz Boas (1911) "Another example of the same kind, the words for SNOW in Eskimo, may be given. ..." ; popularized by Benjamin Whorf "Science and Linguistics" (1949) "We [English speakers] have the same word for falling snow, snow on the ground, ... To an Eskimo, this all-inclusive word would be almost unthinkable....", see Geoffrey Pullum "The Great Eskimo Vocabulary Hoax" (1991) ISBN 0-226-68534-9 ; http://snowclones.org/2007/05/31/if-eskimos-have-n-words-for-snow-x-have-y-words-for-z/
+#
+# An eloquent modern example is Douglas Adams, "So Long, and Thanks for All the Fish" (1984) :
+#   "He had read somewhere that the Eskimos had over two hundred different
+#   words for snow, without which their conversation would probably have
+#   got very monotonous. So they would distinguish between thin snow and
+#   thick snow, light snow and heavy snow, sludgy snow, brittle snow, snow
+#   that came in flurries, snow that came in drifts, snow that came in on
+#   the bottom of your neighbour's boots all over your nice clean igloo
+#   floor, the snows of winter, the snows of spring, the snows you
+#   remember from your childhood that were so much better than any of your
+#   modern snow, fine snow, feathery snow, hill snow, valley snow, snow
+#   that falls in the morning, snow that falls at night, snow that falls
+#   all of a sudden just when you were going out fishing, and snow that
+#   despite all your efforts to train them, the huskies have pissed on."
+#
+#-ESKIMOS HAVE 100 WORDS...
+[noun-animal-plural] HAVE [OVER 27@0.33, 52@0.5, ABOUT A HUNDRED] WORDS FOR [noun-plural, verb-cont, noun-mass], BUT NONE FOR [noun-plural, verb-cont, noun-mass]
+# From Link; Shakespeare "Julius Caesar" (1599) "Et tu, brute?"
+#-ET TU, BRUTE
+[character][]ET TU, [$0/remove-the/]?
+
+# azule: xkcd #208
+#-EVERYBODY STAND BACK. I KNOW REGULAR EXPRESSIONS.
+template xkcd208a: [EVERYBODY@0.5, EVERYMOLPY], STAND BACK. I KNOW [adjective] [noun-plural].[]
+template xkcd208b: [EVERYBODY@0.5, EVERYMOLPY], STAND BACK. I KNOW [verb-cont].[]
+[xkcd208a, xkcd208b]
+
+# A parody of Catholic school scare tactics (e.g. threatening that a boy would lose his vision, etc.) rendered as a photo of a kitten captioned "every time you masturbate, God kills a kitten" in BarFly magazine (1999). The snowclone goes back at least as far as "It's A Wonderful Life" (1946) "Every time a bell rings an angel gets his wings." ; popularized in 2002 via a photo of Domo-Kuns chasing a kitten through a meadow and posted to FARK.com ; http://knowyourmeme.com/memes/every-time-you-masturbate-god-kills-a-kitten ; http://nancyfriedman.typepad.com/away_with_words/2010/12/snowclones-happen.html
+#-EVERY TIME YOU... THINK OF THE KITTENS
+EVERY TIME YOU [MAKE A PUN@0.2, verb-intr-inf], [RANDALL@0.3, THE GLR@0.4, character] [verb-tr-present] [noun-animal-art]. PLEASE, THINK OF THE [$3/-plural].
+
+# A captioned "demotivational poster" featuring a seagull and an eagle with the line, "Excuse me sir, Can you spare a moment for Jesus Christ?" (2011), imitating a familiar opening pitch by Christian door-to-door evangelists; http://knowyourmeme.com/memes/excuse-me-sir-do-you-have-a-moment-to-talk-about-jesus-christ
+#-EXCUSE ME SIR, CAN...
+EXCUSE ME [SIR@0.5, MA'AM], DO YOU HAVE A MOMENT TO TALK ABOUT [character, noun-plural, noun-unique-the, noun-mass, adjec-noun]?
+
+# Cassius Clay (later known as Muhammad Ali) in 1963 "Float like a butterfly, sting like a bee"
+#-FLOAT LIKE A...
+template decr8: [verb-inf-1word] LIKE [A FLUTTERBEE@0.2, noun-singular-article], [verb-inf-1word] LIKE [A BEESNAKE@0.2, noun-singular-article][]
+[decr8]
+
+#-FRIENDS DON'T LET FRIENDS DO DRUGS
+[FRIENDS@0.5, noun-plural] DON'T LET [$0] [verb-tr-inf] [noun-plural, noun-mass, adjec-noun]
+
+# Randall Munroe What-If book, p. 107
+#-FROM WHAT HEIGHT...
+FROM WHAT [DEPTH@0.33, DISTANCE@0.5, HEIGHT] WOULD YOU NEED TO [verb-tr-inf] [noun-article] FOR IT TO BE [verb-tr-perfect] WHEN IT [verb-tr-past] THE [noun]?
+
+# Song "Miracles" by Insane Clown Posse (2009) lyric "Fucking Magnets, How Do They Work?"; http://knowyourmeme.com/memes/fucking-magnets-how-do-they-work
+#-FUCKING MAGNETS, HOW...
+CH**RPING [noun-plural], HOW DO THEY WORK?
+
+# Azule: xkcd #137
+#-FUCK. THAT. SHIT.
+# @Link chose the base words: CHIRP. THAT. MUSTARD. (which could be construed to be based on CHIRPING MUSTARD.)
+[CHIRP@0.5, verb-tr-inf][MUSTARD@0.5, noun-singular][]*[$0/ /. /g]. THAT. [$1/ /. /g].*
+
+# Hugo acceptance speech by Randall Munroe (delivered by Cory Doctorow) (1024) "Gazebo. Ointment. Harpsichord. Credenza. Bungalow"
+# Link OTTified this in a slightly different way
+#-GAZEBO. OINTMENT. HARPSICHORD. CREDENZA. BUNGALOW.
+template gazebo1: [GAZEBO@0.1, OINTMENT@0.12, HARPSICHORD@0.14, CREDENZA@0.16, BUNGALOW@0.18, noun, adjec-noun][]
+[gazebo1]. [gazebo1]. [gazebo1]. [gazebo1]. [gazebo1].
+
+# From the "Girls gone wild" videos, advertised heavily on late-night television starting in 1997
+#-GIRLS GONE WILD
+IT'S [noun-animal-plural] GONE WILD[@0.3, %20II@0.3, %20III@0.3, %204@0.3, %205@0.3, %206@0.4, %207]!
+
+# Emma Lazarus "The New Colossus" (1883), a poem associated with the Statue of Liberty, "Give me your tired, your poor, / Your huddled masses yearning to breathe free" ; http://snowclones.org/2008/04/03/givebring-me-your-poor-your-tired-your-x/
+#-GIVE ME YOUR POOR, YOUR TIRED...
+template laz-end-1: [verb-tr-inf] [noun-plural, noun-mass][]
+template laz-end-2: [verb-intr-inf] [FREE@0.5, MOLPISHLY][]
+template decr9: [BRING@0.5, GIVE] ME YOUR [adjective-negative], YOUR [adjective-negative], YOUR [adjective] [noun-plural] YEARNING TO [laz-end-1, laz-end-2][]
+[decr9]
+
+# Randall Munroe What-If book, p. 77
+#-GIVEN HUMANITY'S CURRENT...
+GIVEN [THE OTT'S@0.33, NEWPIXIA'S@0.5, OUR] CURRENT [noun-mass-positive] AND [noun-plural], IS IT POSSIBLE TO [verb-tr-inf] [adjective-article] [noun-singular]?
+
+# Califormia Milk Board advertisement tagline "Got Milk?" (1993) ; http://snowclones.org/2007/11/08/got-x/
+#-GOT MILK?
+GOT [noun-mass, noun-mass, noun-plural, adjec-noun]?
+
+# various fashion journalism statements e.g. "the new neutrals", "the new black" ; http://snowclones.org/2007/07/01/x-is-the-new-y/
+#-GRAY IS THE NEW BLACK
+template newblack1: [noun-singular, noun-mass, adjec-noun] IS THE NEW [noun-singular, noun-mass, adjec-noun][]
+template newblack2: [noun-plural] ARE THE NEW [noun-plural][]
+[newblack1, newblack2]
+
+# From Moby Dick (chapter 100), "Ship, ahoy! Hast seen the White Whale?"
+#-HAST SEEN THE WHITE WHALE?
+[CASTRAFTLE AHOY! @0.15, RAFTCASTLE AHOY! @0.05, ]HAST [SEEN@0.5, verb-tr-past] THE [adjective] [WHALPY@0.33, noun-singular]?
+
+# Bob Hope biography "Have tux, will travel" (1954), then "Have Gun -- Will Travel" (1950's), thence to Robert Heinlein "Have Spcaesuit..." ; http://snowclones.org/2007/07/20/have-x-will-travel/
+#-HAVE GUN WILL TRAVEL
+HAVE [noun, adjec-noun], WILL [TIME-TRAVEL@0.1, TRAVEL@0.4, verb-inf]
+
+# "Haters gonna hate", possibly from 3LW song "Playas gon' play" (2000) which has a few other lines matching the snowclone; http://knowyourmeme.com/memes/haters-gonna-hate
+#    I lengthened it to "hating haters gonna hate" because it's funnier.
+# %%% I've had to special-case the MOLPYING->MOLPIERS case, which I
+# can do because the vocabulary is defined right here in this file.
+# A better way would be to add the actor form ("HIDERS FROM CORINNE")
+# as a 6th form of the verb multiclasses, then use the multiclass isomorph
+# syntax [$0/-actor] to transform the words.
+# To test, use 'automeme -n 100235 | grep GONNA | grep -v NEED | sort | uniq'
+#-HATING HATERS GONNA HATE
+[verb-tr-cont, verb-intr-cont] [$0/cont-to-actors/] GONNA [$0/-inf]
+
+# Doctor Who "The Eleventh Hour" (2010) original dialogue is "Hello. I'm the Doctor. Basically...run."
+#-HELLO, I'M THE DOCTOR....
+HELLO, I'M [character]. BASICALLY, [RUN@0.4, verb-intr-inf]!
+
+# The Princess Bride (1987), Inigo Montoya's line "My name is Inigo Montoya. You killed my father. Prepare to die."
+#-HELLO, MY NAME IS INIGO...
+HELLO. MY NAME IS [character]. YOU [verb-tr-past] MY [noun-singular, noun-plural, noun-mass, adjec-noun]. PREPARE TO [DIE@0.4, verb-intr-inf].
+
+# "Hello Yes, this is dog", a LOLcat image of a black lab with a telephone receiver; http://knowyourmeme.com/memes/yes-this-is-dog
+#-HELLO? YES, THIS IS DOG
+HELLO? YES, THIS IS [noun-singular, noun-mass, character, adjec-noun]
+
+# From Link; Carly Rae Jepsen song "Call me Maybe" (2012), "Hey, I just met you, and this is crazy, But here's my number, so call me maybe"
+#-HEY, I JUST MET YOU...
+HEY, I JUST [verb-tr-past] YOU, AND THIS IS CRAZY / BUT HERE'S MY [noun], SO [verb-tr-inf] ME MAYBE
+
+# HES, OTT:2090:15|#p3646617, "'Hide the OTTer' sounds like a fun game.
+#-HIDE THE OTTER SOUNDS...
+"[verb-tr-inf] THE [noun]" SOUNDS LIKE [A FUN@0.6, A MOLPISH@0.4, adjective-article] [HOTDOG@0.4, GAME@0.6, noun].
+
+# Randall Munroe What-If book, p. 174
+#-HOW CLOSE WOULD YOU HAVE TO BE...
+HOW CLOSE WOULD YOU HAVE TO BE TO A SUPER[noun] TO GET [adjective-article] DOSE OF [noun-animal] [noun-mass]?
+
+# Randall Munroe What-If book, p. 91
+#-HOW DANGEROUS IS IT...
+regex remove-space-hyphen: /{- }//gi
+[place-name][noun-mass][$1/remove-space-hyphen/][]HOW [adjective] IS IT, REALLY, TO [BE@0.5, verb-inf] [$0/-pr-in] [$0/-art] [$0/remove-the/] DURING [$2/add-article/][STORM@0.5, FLOOD]?
+
+# "How do I shot web?" on a picture of Spider-Man, probably originating on Something Awful forums; derivatives often deliberately lack prepositions; http://knowyourmeme.com/memes/how-do-i-shot-web
+#-HOW DO I SHOT WEB?
+HOW DO I [verb-tr-past] [noun-singular, noun-plural, noun-mass, character, adjec-noun]?
+
+# Randall Munroe What-If book, p. 179
+#-HOW FAST CAN YOU HIT...
+HOW [adverb] CAN YOU [verb-tr-inf] A [noun-singular] WHILE [verb-cont] AND [verb-inf]?
+
+# Randall Munroe What-If book, p. 86
+#-HOW FAST WOULD I HAVE TO BIKE...
+HOW [adverb] WOULD I HAVE TO [verb-inf] FOR MY [noun] TO [verb-inf] THE WAY [noun-singular-article] [verb-present] WHILE [verb-cont]?
+
+# Randall Munroe What-If book, p. 112
+#-HOW HARD WOULD A PUCK...
+[place-name][$0/-pr-in][]HOW [adverb] WOULD [noun-article] HAVE TO BE [verb-tr-perfect] TO BE ABLE TO [verb-tr-inf] THE [noun-animal] [IMMEDIATELY@0.33, STRAIGHT@0.5, BACKWARD] [$1/in-to-into/] [$0]?
+
+# Randall Munroe What-If book, p. 168
+#-HOW HIGH CAN A HUMAN...
+HOW [FAST@0.25, FAR@0.33, HIGH@0.5, LONG] CAN A [noun-animal] [verb-tr-inf] SOMETHING?
+
+# Yahoo answers "How is babby formed? How girl get pragnent"; http://knowyourmeme.com/memes/how-is-babby-formed
+#-HOW IS BABBY FORMED?
+HOW IS [noun-singular, noun-mass, adjec-noun] FORMED? HOW [noun-singular, noun-mass, character, adjec-noun] GET [PRAGNENT@0.33, adjective]?
+
+# Randall Munroe What-If book, p. 78
+#-HOW LONG COULD A NUCLEAR...
+[place-name][]HOW [LONG@0.5, FAR] COULD [adjective-article] [noun] [verb-inf] [$0/-pr-in] [$0]?
+
+# Randall Munroe What-If book, p. 143
+#-HOW MUCH FORCE POWER...
+template yoda1: HOW MUCH [adjective, noun-animal] [noun-mass] CAN [character] [verb-tr-inf]?[]
+template yoda2: HOW MANY [adjective, noun-animal] [noun-plural] CAN [character] [verb-tr-inf]?[]
+[yoda1, yoda2]
+
+# Randall Munroe What-If book, p. 204
+#-HOW QUICKLY WOULD THE OCEANS...
+HOW [adverb] WOULD THE [SEA@0.25, OCEANS@0.3, noun-plural] [verb-tr-inf] IF [adjective-article] [noun-mineral] 3 Q IN [LENGTH@0.33, SIZE@0.5, RADIUS] WERE CREATED IN THE MIDDLE OF [place-name], THE [adjec-super] PART OF THE [$1]? HOW WOULD [place-name] CHANGE AS THE [noun-mass] WAS BEING [$2/-perfect]?
+
+# Video game "Vega Strike", a line attributed to the Rlaan: "Hulls pop like vibrant seeds. Splashing photons in a void. I am sticky."
+#-HULLS POP LIKE VIBRANT SEEDS...
+# %%% right now if it chooses "A VOID" it gets what ever -pr-in belongs to the (unused) [place-name]. For now I don't really care.
+[place-name][][noun-plural] POP LIKE [VIBRANT@0.15, adjective] [SEEDS@0.25, noun-plural]. SPLASHING [noun-plural] [$0/-pr-in] [A VOID@0.5, $0]. I AM [STICKY@0.25, adjective].
+# 4chan /b/ (2008) "I accidentally 93MB of .rar files", derivatives omit the verb; http://knowyourmeme.com/memes/i-accidentally
+#-I ACCIDENTALLY 93MB OF...
+I ACCIDENTALLY [noun-singular-article], IS THIS [BAD@0.33, DANGEROUS@0.5, ENDISH]?
+
+# from Link, v 2.3 (unknown origin)
+#-I AM BEST...
+I AM *[BEST@0.3, MOLPIEST@0.3, adjec-est] [noun-singular, noun-mass, adjec-noun]*, THE [$0] [$1] EVER!
+
+# Jordan Sparks (1971) lyric "I am woman, hear me roar"; http://en.wikipedia.org/wiki/I_Am_Woman
+#-I AM WOMAN
+I AM [character], HEAR ME [ROAR@0.5, verb-intr-inf]
+
+# Tupac Shakur, interview on KMEL (1996), "I didn't choose the thug life, the thug life chose me."
+#-I DIDN'T CHOOSE...
+I DIDN'T CHOOSE THE [noun-singular, noun-mass] LIFE; THE [$0] LIFE CHOSE ME
+
+# "Most interesting man" campaign for Dos Equis beer "I don't always drink beer, but when I do, I prefer Dos Equis -- Stay thirsty, my friends."; http://knowyourmeme.com/memes/the-most-interesting-man-in-the-world
+#-I DON'T ALWAYS DRINK...
+template doseq1: [verb-intr-inf][]
+template doseq2: [verb-tr-inf] [noun-mass, noun-plural, adjec-noun][]
+I DON'T ALWAYS [doseq1, doseq2], BUT WHEN I DO, I [PREFER@0.2, verb-tr-inf] [noun-plural, noun-mass, adjec-noun]
+
+# azule: xkcd #595
+#-I DON'T THINK ARC-WELDING...
+I DON'T THINK [verb-tr-cont] [noun-singular-article] COUNTS AS [SEXY@0.3, adjective-positive].
+
+# azule: xkcd #616
+#-I DON'T KNOW WHAT YOU...
+I DON'T KNOW WHAT YOU JUST SAID BECAUSE I WAS THINKING ABOUT [verb-intr-cont, noun-mass, place-name, noun-unique, noun-plural].
+
+# Randall Munroe What-If book, p. 102
+#-IF AN ASTEROID...
+[place-name][$0/-art][]IF [$1] [$0/remove-the/] WERE VERY [adjective] BUT SUPER[adjective], COULD YOU REALLY [verb-inf] [$0/-pr-in] [$1/some-to-them/] LIKE [character]?
+
+# azule: xkcd #1317
+#-I FEEL PARALYZED BY OVER...
+I FEEL PARALYZED BY [OVERWHELMING EXISTENTIAL DREAD@0.33, THE SADNESS@0.5, T**** ****D].  ...AND YET FOR SOME REASON I'M ~*REALLY*~ EXCITED ABOUT [verb-intr-cont, noun-plural, verb-tr-cont, noun-mass]?
+
+# Randall Munroe What-If book, p. 61
+#-IF EVERY HUMAN SOMEHOW SIMPLY...
+[place-name][]IF EVERY [MOLPY@0.33, OTTER@0.5, HUMAN] SOMEHOW SIMPLY [verb-past] COMPLETELY [$0/-pr-out] [$0], HOW LONG WOULD IT BE BEFORE THE LAST [adjective] [noun] WOULD [verb-inf]?
+
+# Randall Munroe What-If book, p. 114
+#-IF EVERYONE ON THE PLANET STAYED...
+[place-name][]IF [EVERYONE@0.5, EVERYMOLPY] [$0/-pr-in] [$0] [verb-past] AWAY FROM EACH [OTHER@0.5, OTTER] FOR A [FEW@0.5, COUPLE OF] [noun-interval-plural], WOULDN'T THE COMMON [noun] BE [verb-tr-perfect]?
+
+# Randall Munroe What-If book, p. 84
+#-IF EVERYONE PUT LITTLE TURBINE...
+IF [EVERYONE@0.5, EVERYMOLPY] PUT LITTLE [noun-mass] [noun-plural] ON THE [noun-plural] OF THEIR [noun-plural] AND [noun-plural], HOW MUCH [noun-mass] WOULD WE [verb-tr-inf]? WOULD WE EVER [$7] ENOUGH [$6] TO [verb-tr-inf] THE [adjec-noun] OF THE [$2]?
+
+# Randall Munroe What-If book, p. 27
+#-IF EVERY PERSON ON EARTH...
+[place-name][]IF EVERY [PERSON@0.2, MOLPY@0.5, OTTER] [$0/-pr-in] [$0] [AIMED@0.3, verb-tr-past] A [noun] AT [noun-the] AT THE SAME TIME, WOULD IT CHANGE [adjec-noun]?
+
+# Star Wars IV: A New Hope (1977) Darth Vader's line "I find your lack of faith disturbing"
+#-I FIND YOUR LACK OF FAITH...
+I FIND YOUR LACK OF [noun-plural, noun-mass, adjec-noun] DISTURBING
+
+# Motown song "If loving you is wrong, I don't want to be right" (1972); http://snowclones.org/2007/10/31/if-x-is-wrong-i-dont-want-to-be-right/
+#-IF LOVING YOU...
+IF [verb-cont, verb-cont, verb-cont, verb-cont, character, noun-mass, noun-singular-the] IS WRONG, I DON'T WANT TO BE RIGHT
+IF [verb-tr-cont] [YOU@0.3, character, noun-mass, noun-plural, noun-singular-article, adjec-noun] IS WRONG, I DON'T WANT TO BE RIGHT
+
+# Randall Munroe What-If book, p. 83
+#-IF MY PRINTER COULD...
+IF MY [noun] COULD LITERALLY [verb-tr-inf] [noun-mass, noun-plural], WOULD IT HAVE [A SEAISH@0.5, THAT BIG AN] EFFECT ON [place-name]?
+
+# 1977 film based on H.G.Wells "Empire of the Ants"; original quote is "I, for one, welcome our new insect overlords", which the oft-cited Simpsons episode was referencing; http://knowyourmeme.com/memes/i-for-one-welcome-our-new-insect-overlords
+#-I, FOR ONE, WELCOME OUR...
+I, FOR ONE, WELCOME OUR NEW [noun-singular] OVERLORDS
+
+# "Billy Madison" (1995) "If peeing in your pants is cool, consider me Miles Davis."
+#-IF PEEING IN YOUR PANTS...
+IF [verb-intr-cont] IN [YOUR PANTS@0.3, place] IS [adjective], [THEN I'M@0.5, CONSIDER ME] [character, adjective, verb-tr-perfect].
+IF [verb-tr-cont] YOUR [noun-plural] IS [adjective], [THEN I'M@0.5, CONSIDER ME] [character, adjective, verb-tr-perfect].
+
+# Randall Munroe What-If book, p. 77
+#-IF PEOPLE HAD WHEELS...
+IF [noun-animal-plural] HAD [noun-mineral-plural], AND COULD [verb-inf], HOW WOULD WE DIFFERENTIATE THEM FROM [noun-plural]?
+
+#ZoomanSP [OTT:2220:8|#p3731295], "If square-glasses guy is the bftf representation of balthasar_s, who is the OTT equivalent of kxa?"
+#-IF SQUARE-GLASSES GUY IS THE BFTF....
+IF [character] IS THE [BFTF@0.2, place-noart, noun-mass] REPRESENTATION OF [character], WHO IS THE [OTT@0.2, place-noart, noun-mass] EQUIVALENT OF [character]?
+
+# Randall Munroe What-If book, p. 183
+#-IF TWO IMMORTAL PEOPLE...
+template whatif183: [place-name][][adjective-article] [noun]LIKE [$0/remove-the/][]
+[whatif183][]IF TWO [adjective] [noun-plural] WERE [PLACED@0.3, verb-tr-perfect] [ON@0.5, BY] [RIVAL@0.33, OPPOSITE@0.5, OPPOSING] [noun-plural] OF [$0/postproc-some/], HOW LONG WOULD IT TAKE THEM TO [verb-tr-inf] EACH OTHER? A KILO[noun-interval]? A MEGA[noun-interval]? TWENTY-SEVEN UMPTY[noun-interval]?
+
+# OTT-specific meme by @Link
+# Captioned photo of a bear (with snow on its face) and caption "I fucking love cocaine" (2009); http://knowyourmeme.com/memes/cocaine-bear
+#-I FUCKING LOVE...
+I CH**RPING LOVE [noun-plural, noun-mass, adjec-noun]
+
+# azule, An OTT running gag starting at OTT:49:39#p3305676
+#-I WAITED A HALF HOUR... (not "I WAITED HALF AN HOUR...)
+*I [WAITED@0.6, verb-tr-past] HALF [AN HOUR@0.1, noun-interval-art] FOR ONE [DARKENING@0.5, adjective, verb-tr-cont] [PIXEL@0.5, noun-singular].*
+
+# azule: xkcd #349
+#-IF WE MAKE IT BACK...
+IF WE MAKE IT BACK ALIVE, YOU'RE NEVER [verb-tr-cont] ANYTHING AGAIN.
+
+# azule: xkcd #180
+#-IF YOU DIE IN CANADA, ...
+IF YOU [DIE@0.3, verb-intr-inf] IN [place], YOU [$0] IN *REAL LIFE*!
+
+# Randall Munroe What-If book, p. 73
+#-IF YOU SUDDENLY BEGAN...
+IF YOU SUDDENLY BEGAN [verb-cont] STEADILY AT 1 [CUEBALL@0.5, NEWPAGE] PER [noun-interval], HOW EXACTLY WOULD YOU [verb-inf]? WOULD YOU [verb-inf] OR [verb-inf] FIRST?
+
+# Azule: xkcd #1171
+# Jay-Z song "99 Problems" (2004) lyric "If you're havin' girl problems I feeb bad for you son, I've got 99 problems but a b*tch ain't one"
+#-I GOT 99 PROBLEMS BUT...
+I GOT 99 [PROBLEMS@0.7, noun-animal-plural], SO I USED [noun-plural]. NOW I HAVE 100 [$0].
+
+# @mrob27: The regexp here removes the article A or AN from the noun-singular-article
+# "I can has X; you can has my X" has countless examples, many in captioned photos in the style of the original "I can has cheezburger" genre, linked to the creation of the website by that name ( icanhas.cheezburger.com ) in reference to a captioned cat (2007); the lolcat style had already been popular on 4chan; http://en.wikipedia.org/wiki/I_Can_Has_Cheezburger%3F
+#-I HAS X; YOU CAN HAS MY X
+I HAS [noun-singular-article]. YOU CAN HAS MY [$0/remove-article/]
+
+# "I have reported you to AOL for stealing pictures, as it is a crime." goes back to at least 2005 ( http://www.neowin.net/forum/topic/360276-put-a-pic-on-my-msn-dis-pic-illigal/ ) and is linked to the "AOL Police" meme, an old running gag. ; http://wiki.unmod.org/index.php?title=4chan#AOL_Police ; http://www.lurkmore.com/wiki/AOL_Police
+#-I HAVE REPORTED YOU...
+I HAVE REPORTED YOU TO [character] FOR [STEALING@0.5, verb-tr-cont] [noun-plural, noun-mass] AS IT IS A CRIME
+
+#-I HATE THIS F*CK*NG PLACE, #commented, because I don't understand, why this,
+#[all-vocab-i] [all-vocab-h] [all-vocab-t] [all-vocab-f] [all-vocab-p]
+
+# azule: xkcd #821
+#-I KNOW IT'S NATURAL AND ALL...
+[place-name][]I KNOW IT'S NATURAL AND ALL, BUT I REALLY WISH [noun-plural] [$0/-pr-in] [$0] WOULDN'T TRY TO [verb-tr-inf] ME.
+
+# Azule: xkcd #405
+#-I *LIKE* MY HAT
+I *LIKE* MY [HAT@0.25, noun].
+
+# Eddie Izzard "Glorious" stand-up act (1997) "I like my women like I like my coffee... covered in beeees!", but clearly originating much earlier ; http://en.wikiquote.org/wiki/Eddie_Izzard
+#-I LIKE MY WOMEN...
+I LIKE MY [MEN@0.25, WOMEN@0.33, noun-plural, noun-mass, adjec-noun] LIKE I LIKE MY [noun-plural, noun-mass]: COVERED IN [noun-plural, noun-mass, adjec-noun]
+
+# LOLcat caption "I made you a cookie, but I eated it"; http://knowyourmeme.com/memes/i-made-you-a-cookie-but-i-eated-it
+#-I MADE YOU A COOKIE...
+I MADE YOU [noun-singular-article], BUT I [verb-tr-past] IT
+
+# azule: xkcd #481
+#-I'M A MORON.
+I'M [noun-singular-article].  I... I DIDN'T KNOW.
+
+# Azule: xkcd #974
+#-I'M DEVELOPING A SYSTEM...
+I'M DEVELOPING A SYSTEM TO [PASS YOU@0.3, verb-tr-inf] ARBITRARY [CONDIMENTS@0.2, noun-mineral-plural].
+
+# A variant of "when I say X I really mean Y" ;  http://snowclones.org/2007/03/30/when-i-say-x-what-i-really-mean-is-y/
+#-I'M GOING TO ...
+I'M GOING TO [verb-tr-inf] [MY@0.5, THIS] [noun-singular], AND BY '[$0]' I MEAN '[verb-tr-inf]', AND BY '[$1] [$2]' I MEAN '[noun-mass, noun-plural, adjec-noun]'.
+
+# Image of Dragonball Z character "Cell" with caption "IMMA CHARGIN MAH LAZER"; http://knowyourmeme.com/memes/shoop-da-whoop-im-a-firin-mah-lazer
+#-IMMA CHARGIN MAH LAZER
+IMMA CHARGIN MAH [noun-singular, noun-plural, noun-mass, adjec-noun]
+
+# Starcraft screenshot (2003) with words "im in ur base killing all ur d00dz"; also "I'm in your base killing your dudes" or similar; http://knowyourmeme.com/memes/in-ur-base ; http://snowclones.org/2007/10/19/im-in-ur-x-ying-ur-z/
+#-I'M IN UR BASE...
+I'M IN [YOUR@0.3, UR@0.5, YR] [noun-singular, noun-mass, adjec-noun], [verb-tr-cont] [$0] [noun-plural, noun-mass, adjec-noun]
+
+# Robert Young in an aspirin advertisement (1970s), or Peter Bergman in a Vicks Formula 44 advertisement (1986) "I'm not a doctor, but I play one on TV" ; http://snowclones.org/2007/08/17/im-not-an-x-but-i-play-one-on-tv/
+#-I'M NOT A DOCTOR, BUT...
+[place-name][]I'M NOT [noun-or-actor], BUT I [PLAY@0.33, verb-tr-inf] ONE [$0/-pr-in] [$0].
+
+# azule: xkcd #178
+#-I'M NOT REALLY INTO...
+I'M NOT REALLY INTO [noun-plural, noun-mass].
+
+# 2001: A Space Odyssey (1968) "I'm sorry, Dave. I'm afraid I can't do that."
+#-I'M SORRY DAVE, I'M...
+I'M SORRY, [character]. I'M AFRAID I CAN'T [DO@0.15, verb-tr-inf] THAT.
+
+# Superbowl XLIV (2015) halftime show Katy Parry backup dancer in shark costume flubbed moves and became a meme; "I'm such a Left Shark when it comes to dancing."; http://knowyourmeme.com/memes/super-bowl-xlix-halftime-shark
+#-I'M SUCH A LEFT SHARK WHEN IT...
+#I'M SUCH A LEFT [RAPTORSHARK@0.5, noun-animal-1word] WHEN IT COMES TO [verb-cont-1word]
+
+# alt-text of xkcd 1450
+#-I'M WORKING TO BRING ABOUT
+I'M WORKING TO [CREATE@0.25, BRING ABOUT@0.33, verb-tr-inf] [adjective-article] [noun] THAT WILL ETERNALLY [verb-tr-inf] [EVERY@0.5, ANY][ONE@0.5, MOLPY] WHO [FAILS@0.5, FAILED] TO [verb-tr-inf] THE [char-1word]'S [noun-animal] PEOPLE.
+
+# From Link, v 2.3
+# LOLspeak used in forum discussions when the speaker has succeeded in doing something (typically making the post) before some anticipated event, such as the thread being locked or removed by a moderator; in the latter case "in b4 404" is common. ; http://knowyourmeme.com/memes/in-b4
+#-IN B4 404
+IN B4 [503@0.2, 408@0.25, adjective] [MUSTARD@0.2, SADNESS@0.25, noun-singular, noun-plural, noun-mass, adjec-noun]
+
+# azule: xkcd #714
+#-IN MY PORN, PEOPLE F***
+IN MY [PORN@0.3, SLASH-FICTION@0.2, noun], PEOPLE *[verb-inf]*.
+
+# Russian reversal jokes (http://en.wikipedia.org/wiki/Russian_reversal) from the 1960's; later associated with Yakov Smirnoff, e.g. Miller Lite ad (1985) "In Russia, Party always finds you."; http://knowyourmeme.com/memes/in-soviet-russia
+#-IN SOVIET RUSSIA...
+[place-russia-name, place-russia-name, place-russia-name, place-name][][$0/-pr-in] [$0/sovietize/], [noun-singular, noun-mass, character, adjec-noun] [verb-tr-present] *YOU*
+
+# "Alien" (1979) "In space, no one can hear you scream." ; http://snowclones.org/2007/07/05/in-space-no-one-can-hear-you-x/
+#-IN SPACE, NO ONE CAN HEAR...
+[place-name][][$0/-pr-in] [$0], [NO-ONE@0.5, NOMOLPY] CAN [SEE@0.5, HEAR] YOU [verb-inf].
+
+# Beginning in the 1950's, if not earlier, products were marketed by an appeal to convenience. This meme came from ad copy for products that are dehydrated, and prepared by adding the water, e.g. "Instant coffee -- just add water".
+#-INSTANT COFFEE -- JUST...
+INSTANT [noun-singular, noun-plural, noun-mass, adjec-noun], JUST ADD [noun-plural, noun-mass, adjec-noun]
+
+# azule: xkcd #325
+#  %%% The 'noun-singular-negative' is currently orphaned from the rest of the noun system; this is the only meme that attempts to use it.
+#-INSTEAD OF OFFICE...
+template xkcd325a: INSTEAD OF [noun-mass, noun-singular], [PACKAGE@0.5, noun-singular] CONTAINED [noun-mass-negative, noun-singular-negative]. WOULD NOT [BUY@0.5, verb-intr-inf] AGAIN.[]
+template xkcd325b: [PACKAGE@0.5, noun-singular] CONTAINED [noun-mass-positive, noun-singular]. WOULD [BUY@0.5, verb-intr-inf] AGAIN[]
+[xkcd325a, xkcd325b]
+
+# Randall Munroe What-If book, p. 200
+#-IN THE MOVIE 300 THEY...
+template moviename1: [noun, verb-cont][]
+template moviename2: [noun, verb-cont] [2@0.2, III@0.25, 4@0.33, 5@0.5, VI][]
+template moviename3: [adjective-article] [noun, verb-cont-1word][]
+template moviename4: THE [adjective, verb-cont-1word] [noun, adjec-noun][]
+template moviename5: [verb-cont] [preposition] [noun-plural, noun-mass][]
+template moviename6: [noun-article] [OF@0.4, preposition] [place, noun-plural, noun-mass][]
+template moviename: [moviename1, moviename2, moviename3, moviename4, moviename5, moviename6][]
+IN THE [OTHERCOMIC@0.33, MOVIE@0.5, HOTDOG] *"[moviename]"* THEY [verb-tr-inf] [noun-plural] INTO [place-name] AND THEY SEEMINGLY [verb-tr-inf] [noun-unique-the]. IS THIS POSSIBLE, AND HOW MANY [$3] WOULD IT TAKE?
+# Based on Neil_Boekend, OTT:2094:27#p3648403
+#-IN YOUR MIND, REPLACE...
+IN YOUR MIND, REPLACE [noun] WITH [noun].
+
+# From Link; Doctor Who episode "The Deadly Assassain" (1976) Tom Baker "I reject your reality and substitute my own" ; later requoted by 1984 film "The Dungeonmaster" and TV serires "Mythbusters"
+#-I REJECT YOUR REALITY...
+I REJECT YOUR [noun, noun-plural, adjec-noun] AND SUBSTITUTE MY OWN
+
+# Friends (1996) character Phoebe "I see what you did there"; http://knowyourmeme.com/memes/i-see-what-you-did-there
+# also seen as a caption on the same Futurama image of Fry described in the "Not sure if..." snowclone.
+#-I SEE WHAT YOU DID THERE
+I SEE WHAT [YOU@0.5, character] [verb-tr-past] THERE
+
+# LOLcat caption "Is it can be hugs tiem now plees?"; http://knowyourmeme.com/memes/is-it-can-be-hugs-tiem-now-plees
+#-IS IT CAN BE HUGS...
+IS IT CAN BE [noun-singular, nounz] TIEM NAO PLEES?
+
+# Randall Munroe What-If book, p. 68
+#-IS IT POSSIBLE TO BUILD A JETPACK...
+[verb-cont][]IS IT POSSIBLE TO [verb-tr-inf] [noun-article] USING [DOWNWARD@0.5, UPWARD]-[$0/hyphenate/] [noun-plural]?
+
+# Randall Munroe What-If book, p. 153
+#-IS THERE ENOUGH ENERGY...
+[place-name][]IS THERE ENOUGH [noun-mass] TO [verb-tr-inf] THE ENTIRE CURRENT [noun-animal] POPULATION [$0/-pr-out] [$0]?
+
+# from azule, based on xkcd #1190 frame 833
+#-IT CAN DO WHATEVER IT WANTS...
+IT CAN DO WHATEVER IT WANTS.  IT'S [THE SEA@0.5, noun-singular-the, noun-mass].
+
+# 4chan /b/ user (2007) "I think halo is a pretty cool guy. Eh kills aleins and doesnt afraid of anything."; http://knowyourmeme.com/memes/pretty-cool-guy
+#-I THINK HALO IS A PRETTY...
+I THINK [character] IS A PRETTY [TREEISH@0.2, MOLPISH@0.3, adjective] [XUY@0.1, noun-singular]. 'XEH [verb-tr-present] [noun-plural, noun-mass, character, adjec-noun] AND DOESN'T [ENDISH@0.3, AFRAID OF] ANYTHING
+
+# From @Link, in vers. 3.4
+# Probably from Mario videogames, there are several examples, such as "It's a-me, Luigi, and you-a gonna die!"
+# %%% would like to add random short phrases here, perhaps similarly to in the boom-de-yada meme
+#-IT'S-A-ME, LUIGI
+#IT'S-A-ME, [character]!
+
+# The Adventures of Superman (TV series, 1952) "Look! Up in the sky! It's a bird. / It's a plane. / It's Superman!"
+#-IT'S A PLANE
+IT'S [noun-singular-article]. IT'S [noun-singular-article]. IT'S *SUPER[noun-singular-1word]!*
+
+# Pokemon videogames (1996) ; http://knowyourmeme.com/memes/its-super-effective
+#-IT'S SUPER EFFECTIVE
+template pokemon1: [PIKACHU@0.2, character] USED [noun-mass, verb-inf]! [IT'S SUPER EFFECTIVE!@0.5, IT'S NOT VERY EFFECTIVE...@0.7, ...BUT IT FAILED!][]
+template pokemon2: [LINK@0.2, character] USED EMERGENCY [KITTEN@0.2, LINK@0.25, noun]! IT'S A SUPER [$1]![]
+[pokemon1, pokemon2]
+
+# Joseph Barker (1854) "there are tortoises all the way down"; Stephen Hawking (1988) attributing to Bertrand Russell "But it's tortoises all the way down!"; and many others; http://snowclones.org/2011/01/26/its-x-all-the-way-down/ ; http://en.wikipedia.org/wiki/Turtles_all_the_way_down
+# "except that every 13th and 14th..." from @mrob27 at OTTercon
+#-IT'S TURTLES ALL...
+template turtle1: IT'S [noun-plural, noun-mass, adjec-noun] ALL THE WAY DOWN[]
+template turtle2: IT'S [noun-plural] ALL THE WAY DOWN, EXCEPT THAT EVERY 13TH AND 14TH ONE IS [noun-singular-article][]
+[turtle1@0.7, turtle2].
+# "It's over. <product/company> is finished" possibly imitates Frodo's "It's Over" line after the climax of his quest in The Lord of the Rings.
+#-IT'S OVER.
+IT'S OVER. [noun-singular, noun-mass, character, adjec-noun] IS FINISHED.
+
+# Descartes (1637); http://snowclones.org/2011/01/05/i-x-therefore-i-am/
+#-I THINK, THEREFORE I AM
+I [THINK@0.5, verb-intr-inf], THEREFORE I [verb-intr-inf]
+
+# Elder Scrolls V: Skyrim (2011) "I used to be an adventurer like you, then I took an arrow in the knee."; http://knowyourmeme.com/memes/i-took-an-arrow-in-the-knee
+#-I USED TO BE AN...
+I USED TO BE [noun-singular-article] LIKE YOU, THEN I TOOK [noun-singular-article] IN THE KNEE
+
+# Pirates of the Caribbean: Dead Man's Chest (2008) line "I got a jar of dirt! I got a jar of dirt! and guess what's inside it!" ; http://knowyourmeme.com/memes/ive-got-a-jar-of-dirt
+#-I'VE GOT A JAR OF DIRT...
+I'VE GOT A JAR OF [noun-plural, noun-mass, noun-mass]! I'VE GOT A JAR OF [$0]! AND GUESS WHAT'S INSIDE IT!
+
+# "A Few Good Men" (1992 film) original lines are "I want the truth! / You can't handle the truth." ; http://knowyourmeme.com/memes/you-cant-handle-the-truth
+#-I WANT THE TRUTH...
+"I WANT THE [noun-singular, noun-mass, adjec-noun]!" / "YOU CAN'T HANDLE THE [$0]!"
+
+# Doctor Who (reboot) episode "The Eleventh Hour" (2010) original dialogue is "Yeah, it's cool. Bow ties are cool." ; http://knowyourmeme.com/memes/bow-ties-are-cool
+#-I WEAR A BOWTIE..
+I WEAR [noun-animal-art, noun-mineral-art] NOW. [$0/-plural] ARE [COOL@0.5, TREEISH@0.5, MOLPISH].
+
+# "I went to a fight and a hockey game broke out"
+#-I WENT TO A FIGHT AND A HOCKEY GAME BROKE OUT.
+template hgevent1: [place-name][][$0/-art] [$0/remove-the/][]
+template hgevent2: [noun-article]-[verb-cont-1word][]
+I WENT [TO SEE@0.5, TO] [hgevent1@0.5, hgevent2] AND [noun-article] [ALMOST @0.5, ]BROKE OUT.
+
+# Monty Python "Hungarian Phrasebook" sketch, John Cleese: "I will not buy this record, it is scratched."
+#-I WILL NOT BUY THIS...
+I WILL NOT [verb-tr-inf] THIS [noun-singular, noun-mass, adjec-noun] -- IT IS [noun-singular-article, noun-mass, adjective, character, adjec-noun]
+
+# Azule: An OTT running gag started around NP49
+#-I WAITED HALF AN HOUR...
+*I [WAITED@0.6, verb-tr-past] HALF [AN HOUR@0.1, noun-interval-art] FOR ONE [DARKENING@0.7, verb-tr-cont] [PIXEL@0.5, noun-singular].*
+
+# azule: xkcd #1
+#-I WONDER WHERE I'LL FLOAT NEXT
+I WONDER WHERE I'LL [verb-intr-inf, verb-tr-inf] NEXT?
+
+# from webcomic "Toothpaste For Dinner" via 4chan (2006); original quote was "JESUS CHRIST IT'S A LION! GET IN THE CAR!"
+#-JESUS CHRIST IT'S A LION...
+GREAT LORD RANDALL IT'S [noun-singular-article] GET IN THE [CAR@0.33, CASTRAFTLE@0.15, RAFTCASTLE@0.05, noun-singular, noun-mass]
+
+
+# "Keep calm and carry on", British WWII public safety poster by the Ministry of Information; http://knowyourmeme.com/memes/keep-calm-and-carry-on
+#-KEEP CALM AND CARRY ON
+template decr10: KEEP CALM AND [MOLPY@0.2, verb-inf-1word] ON[]
+template decr11: REMAIN [CALM@0.2, adjective] AND [verb-inf-1word] [noun-mass, noun-plural][]
+[decr10]
+[decr11]
+# Invented by mrob27, just as an excuse to use the [moviename] template more often
+#-LEADING AT THE BOX OFFICE
+LEADING AT THE OFFICE BOX THIS WIP: 1. *[moviename]* , 2. *[moviename]* , 3. *[moviename]* , 4. *[moviename]* , 5. *[moviename]*
+
+# Randall Munroe What-If book, p. 126
+#-LET'S ASSUME THERE'S LIFE ON...
+[place-name][]LET'S ASSUME THERE'S [LIFE@0.3, noun-animal-art] [$0/-pr-in] THE NEAREST [adjective] [$0/remove-the/] AND THAT XEY HAVE [noun-mass] COMPARABLE TO OURS. IF THEY LOOKED AT OUR [$4] RIGHT NOW, WHAT WOULD THEY SEE?
+
+# Wizard of Oz (1939); http://snowclones.org/2007/05/22/x-y-and-z-oh-my/
+#   A lot of the substitutions don't fit the original meter and thus make for a poor snowclone; so you might want to disable this one.
+#-LIONS AND TIGERS AND...
+[noun-plural] AND [noun-plural] AND [noun-plural, noun-mass, adjec-noun], OH MY!
+
+# azule: xkcd #703
+#-LISTEN UP! THE FIRST RULE...
+*LISTEN UP!*  THE FIRST RULE OF [REDUNDANCY@0.2, noun, adjec-noun] CLUB IS THE FIRST RULE OF [$0] CLUB.
+
+# "LOLI HAET PIZZA" (presumed a typo of "LOL I haet pizza"), later "LOEV" also became common, sometimes appears as an image caption showing an anime girl and the thing they LOEV (or HAET), or a boy with the word SHOTA instead of LOLI ; https://encyclopediadramatica.es/Loli_Haet_Pizza
+#-LOLI HAET PIZZA
+[LOLI@0.3, SHOTA@0.2, character] [LOEV@0.8, HAET] [noun-singular, noun-plural, noun-mass, character, adjec-noun]
+
+# Poem "Ozymandias" by Percy Bysshe Shelley (1818), "My name is Ozymandias, king of kings: Look on my works, ye Mighty, and despair!"
+#-LOOK ON MY WORKS, YE...
+[noun-animal-art, noun-mineral-art][]MY NAME IS [character], [$0/remove-article/] OF [$0/-plural]: LOOK ON MY [noun-plural, noun-mass], YE [adjective, verb-cont-1word], AND [DESPAIR@0.25, verb-intr-inf]!
+template decr12: LOOK ON MY [noun-plural, noun-mass], YE [adjective, verb-cont-1word], AND [DESPAIR@0.25, verb-intr-inf]![]
+[decr12]
+
+# TV Show "Firefly" episode "The Message" (2003) character Hoban 'Wash' Washburne quote "Man walks down the street in that hat, people know he's not afraid of anything."
+#-MAN WALKS DOWN THE STREET...
+[place-name][][OTTER@0.5, MOLPY] [WALKS@0.3, verb-present] DOWN [$0/-art] [$0/remove-the/] IN THAT [BRAINSLUG@0.2, SAFETY HAT@0.25, HAT@0.33, noun], PEOPLE KNOW XE'S NOT AFRAID OF ANYTHING.
+
+# Mattell Teen Talk Barbie (1992), a talking doll that says "Math class is tough." and "Want to go shopping? Okay, meet me at the mall." ; http://snowclones.org/2008/02/19/x-is-hard-let’s-go-shopping/
+#-MATH IS HARD, LET'S GO SHOPPING
+template decr13: [verb-cont] IS HARD, LET'S GO [verb-cont].[]
+[decr13]
+
+# By Link, a running joke in the OTT originating with early theories explaining xkcd 1190 "Time"
+# %%% azule: Yes, I meant to say "running joke in the OTT", not "OTC" :)
+#-MAYBE MEGAN IS PREGNANT...
+MAYBE [character] [IS PREGNANT@0.2, HAS CANCER@0.25, HAD AN ABORTION@0.33, GOT MARRIED@0.5, GOT DIVORCED]! MAYBE [THE OTC@0.2, noun-singular-the, noun-mass, place] IS A METAPHOR FOR [THIS@0.1, THAT@0.1, noun-plural, noun-mass]!
+
+# Possibly "maximum volume yields maximum results"
+#-MAXIMUM VOLUME YIELDS...
+MAXIMUM [noun-plural, noun-mass, adjec-noun] YIELDS MAXIMUM [noun-plural, noun-mass, adjec-noun]
+
+# From japanese.stackexchange.com/questions/8125/are-snowclones-common-in-japanese
+# 見ろ! 人がゴミのようだ!   Look! People, seems like waste/garbage!
+# 見ろ! X が Y  のようだ!   Look! X seems like Y!
+#-MIRO! HITOGAGOMINOYOUDA!
+
+# Angelastic, OTT:753:4|#p3370725 "Molpy molpy molpy molpy molpy molpy molpy molpy grapevine grapevine" imitating Jonto Picking's "Badgers" (see http://en.wikipedia.org/wiki/Badgers_(animation) ); it was soon lengthened to 12 "molpy"s to fit the song, now usually referencing @yappobiscuit's parody at OTT:757:14#p3371215
+#-MOLPY MOLPY MOLPY... GRAPEVINE
+[MOLPY@0.2, noun-1word] [$0] [$0] [$0] [$0] [$0] [$0] [$0] [$0] [$0] [$0] [$0] [GRAPEVINE@0.2, noun-1word] [$1]
+
+# from azule
+#-MONEY DOESN'T GROW ON TREES.
+[noun-plural] DON'T [GROW@0.5, verb-intr-inf] ON [TREES@0.25, BAOBABS@0.33, noun-plural].
+
+# xkcd #1190 "Time", frame 2119
+#-MORE WORLD. MAYBE DIFFERENT.
+MORE [noun-mass, noun-singular]. MAYBE [DIFFERENT@0.5, adjective].
+
+# From Psalms 23:5 ("The Lord is my shepherd"), KJV has "... thou anointest my head with oil; my cup runneth over. ; http://snowclones.org/2007/11/13/my-x-runneth-over/
+#-MY CUP RUNNETH OVER
+[verb-present-1word][]MY [noun] [$0/present-to-eth/] OVER
+
+# Added by @Link
+# song "Milkshake" by Kelis (2003), lyric is "My Milkshake Brings All the Boys to the Yard", parodied on Family Guy, then on YouTube; http://knowyourmeme.com/memes/my-milkshake-brings-all-the-boys-to-the-yard
+#-MY MILKSHAKE BRINGS...
+MY [noun-singular] BRINGS ALL THE [noun-plural] TO [THE YARD@0.5, place]
+
+# "Firefly" TV show episode "The Message", character River Tam, "My food is problematic"
+#-MY FOOD IS PROBLEMATIC
+MY [noun, adjec-noun] IS PROBLEMATIC.
+
+# Possibly Monty Python "Dirty Hungarian Phrasebook" (1970) "My hovercraft is full of eels"
+#-MY HOVERCRAFT IS FULL...
+MY [noun-singular, noun-mass] IS FULL OF [noun-plural, noun-mass, adjec-noun]
+
+# 4chan (2007) "My [girlfriend] just [censored] me; Shit was SO cash"; http://knowyourmeme.com/memes/shit-was-so-cash-copypasta
+#-MY GIRLFRIEND JUST...
+MY [noun-commodity, noun-mass] JUST [verb-tr-past] ME; M**STARD WAS SO [CASH@0.5, adjective]
+
+# A common LOLcat caption snowclone
+#-MY X, LET ME SHOW...
+MY [noun-singular, noun-mass], LET ME SHOW YOU IT
+
+# Hemingway (For Whom the Bell Tolls, 1940)
+#-NEVER SEND TO KNOW FOR...
+NEVER SEND TO KNOW FOR WHOM THE [noun-singular] [verb-intr-present, verb-tr-present]; IT [$1] FOR THEE
+
+# @Kieryn, OTT:723:24#p3367381 ""ni ni ni ni ni chupacabra ping pong ball"
+#    Meme added by @Link (mrob27 added more NI's and the fixed-probability literals)
+#-NI NI NI NI NI...
+NI NI [NI@0.33, NI NI@0.5, NI NI NI] [CHUPACABRA@0.2, noun-singular, noun-mass] [PING-PONG BALL@0.2, noun-singular, noun-mass, adjec-noun]
+
+# From azule; Statement (often seen in film credits) from the American Humane Association or ASPCA "No animals were harmed in the making of this film"
+#-NO ANIMALS WERE HARMED
+NO [MOLPIES@0.1, noun-animal-plural] WERE [HARMED@0.5, verb-tr-perfect] IN THE MAKING OF THIS [MEME@0.3, noun].
+
+# Probably "No, John. You are the demons" from fanfiction "DOOM: Repercussions of Evil" (2002) ; http://knowyourmeme.com/memes/doom-repercussions-of-evil
+#-NO JOHN YOU ARE THE DEMONS
+NO, [noun-singular, noun-mass, character], YOU ARE THE [noun-singular, noun-mass, adjec-noun]
+
+# azule: xkcd #11
+#-NONE OF THE PLACES...
+NONE OF THE PLACES I [FLOATED@0.5, verb-intr-past] HAD [noun-plural].
+
+# Captioned image of an elephant seal with a blue bucket, captioned "Noooo they be stealin' my Bucket" ; http://knowyourmeme.com/memes/lolrus
+#-NOOOO THEY BE STEALIN'...
+NOOOO THEY BE [verb-tr-cont] MY [noun-singular, noun-plural, noun-mass, adjec-noun]
+
+# From japanese.stackexchange.com/questions/8125/are-snowclones-common-in-japanese
+# 能登かわいいよ能登  Noto am cute noto
+#  X  かわいいよ X    X is a cute X
+#-NOTO KAWAIYONOTO
+#[character, noun] IS A CUTE [$0]
+
+# Futurama episode "The Lesser of Two Evils" (2000) image of Fry squinting his eyes, captioned by this snowclone; an early example seems to be "Not sure if trolling / or just stupid" ; http://knowyourmeme.com/memes/futurama-fry-not-sure-if
+#-NOT SURE IF TROLLING...
+NOT SURE IF [verb-intr-cont] OR JUST [verb-intr-cont, adjective]
+
+# Probably very old, a way to describe someone as being "stupid", e.g. "He wasn't the sharpest knife in the drawer" ; http://snowclones.org/2007/10/03/not-the-xest-y-in-the-z/
+#-NOT THE MOST X Y IN THE Z
+[place-name][]... XE WASN'T THE [adjec-super] [noun-singular] [$0/-pr-in] [$0]
+
+# azule: Wikipedia template found at the top of articles, "Not to be confused with [[other-thing]]"
+#-NOT TO BE CONFUSED WITH...
+template azconf1: [noun].  *NOT TO BE CONFUSED WITH _[noun]_.*[]
+template azconf2: [verb-cont].  *NOT TO BE CONFUSED WITH _[verb-cont]_.*[]
+[azconf1, azconf2]
+
+# A line from the Bhagavad Gita, "Now I am become Death, the destroyer of worlds.", popularized after J. Robert Oppenheimer cited it in reference to the atomic bomb
+#-NOW I AM BECOME...
+[verb-cont][$0/cont-to-actor/][]NOW I AM BECOME [ENDISHNESS@0.25, character, noun-singular, noun-mass, adjec-noun], THE [$1/hyphenate/] OF [noun-plural, noun-mass, adjec-noun]
+
+# A common quote template, found in Seinfeld and some movies
+#-NOW IF YOU'LL EXCUSE...
+NOW IF YOU'LL EXCUSE ME, I HAVE [noun-singular-article, noun-plural, noun-mass, adjec-noun] TO [verb-tr-inf]
+
+# A drill for touch-typing practice (1889) "Now is the time for all good men to come to the aid of the party" , later versions substitute "their country" for "the party"
+#-NOW IS THE TIME FOR ALL...
+NOW IS THE TIME FOR ALL [TREEISH@0.33, MOLPISH@0.5, GOOD] [noun-animal-plural] TO COME TO THE AID OF [noun-singular-the, place]
+
+# "Aliens" (1986) Hicks (or Ripley) "[I say we take off and] nuke the [entire] site from orbit. It's the only way to be sure."
+#-NUKE 'EM FROM ORBIT. IT'S...
+template decr14: [verb-tr-inf] ['EM@0.5, IT] FROM [THE MOON@0.3, ORBIT@0.5, place]. IT'S THE ONLY WAY TO BE [SURE@0.7, adjective].[]
+[decr14]
+
+# Captioned image of Happy Cat ( http://knowyourmeme.com/memes/happy-cat ), badly cropped, with words "Oh God How Did This Get Here I Am Not Good With Computer" (2005) ; http://knowyourmeme.com/memes/oh-god-how-did-this-get-here-i-am-not-good-with-computer
+#-OH GOD HOW DID THIS GET...
+OH GLR HOW DID [THIS@0.5, noun-plural, noun-mass, character, adjec-noun] GET HERE I AM NOT GOOD WITH [noun-plural, noun-mass]
+
+# This is LOLspeak and a little too generic to identify an origin.
+#-OH HAI, I XED YOUR Y
+OH HAI, I [verb-tr-past] YOUR [noun-singular, noun-plural, noun-mass, adjec-noun]
+
+# Lord of the Rings "One does not simply walk into Mordor"; http://knowyourmeme.com/memes/one-does-not-simply-walk-into-mordor
+#-ONE DOES NOT SIMPLY WALK...
+ONE DOES NOT SIMPLY [verb-intr-inf] INTO [MORDOR@0.3, place].
+
+# J.R.R. Tolkien, "Lord of the Rings" (1954) "One ring to rule them all, one rind to find them / one ring to bring them all and in the darkness bind them"
+#-ONE RING TO RULE THEM ALL...
+[place-name][]ONE [noun-singular] TO [RULE@0.75, verb-tr-inf] THEM ALL, ONE [$1] TO FIND THEM / ONE [$1] TO [BRING@0.7, verb-tr-inf] THEM ALL AND [$0/-pr-in] [$0] BIND THEM.
+
+# Aristotle (4th century BCE), "One swallow does not a summer make, nor one fine day; similarly one day or brief time of happiness does not make a person entirely happy."; http://en.wiktionary.org/wiki/one_swallow_does_not_a_summer_make
+#-ONE SWALLOW DOES...
+ONE [noun-singular] DOES NOT [noun-singular-article] MAKE
+
+# "An Officer and a Gentleman" (1982) "The only two things from Oklahoma are steers and queers, and I don't see any horns on you boy" ; also known from "Full Metal Jacket" (1997) where the line is "Holy Dogshit! Only two things come from Texas, steers and queers. You don't look much like a steer, so that kind of narrows down doesn't it."
+#-ONLY TWO THINGS COME...
+ONLY TWO THINGS COME FROM [place]: [noun-plural, noun-mass, character, adjec-noun] AND [noun-plural, noun-mass, character, adjec-noun]
+
+# From azule: xkcd #1393 (Timeghost)
+#-OOOOOOOOOOOOO... TIIIME IS PASSIIIING!
+[noun, place-name][$0/\bTHE\b/Þ/g][$1/lm-aaaagile/][verb-cont][]...@$OO$@OO@$OOO$@O@$O$@...  [$2/Þ/THE/g] IS [$3/lm-aggiiiile/]!
+
+# From Link; Shakespeare "Romeo and Juliet" (1597) "O Romeo, Romeo! wherefore art thou Romeo?"
+#-O ROMEO, ROMEO! WHEREFORE..
+[character][]O [$0/remove-the/], [$1]! WHEREFORE ART THOU [$1]?
+
+# From azule
+#-OTC: ONE TRUE COMIC
+[noun][]OT[$0/initial-letters/]: ONE TRUE [$0]
+
+# Azule: xkcd 414
+#-OUR COPY OF THE KAMA...
+OUR COPY OF THE [noun-unique, noun-mineral] HAS A COUPLE MISTRANSLATIONS.  WHICH WE REFUSE TO FIX.
+
+# from japanese.stackexchange.com/questions/8125/are-snowclones-common-in-japanese
+# パンが無いならお菓子を食べればいいじゃない It's not good if you eat sweets, if there is no bread
+#  X  が Y  なら    Z     すればいいじゃない It's not good if Z X is there is a Y
+#-PAN GA NAINARA OKASHI O TABEREBA II JANAI
+
+# azule: xkcd #194
+#-PENISES: THEY ARE ABOUT ...
+[noun-plural]:  THEY ARE ABOUT THIS [BIG@0.25, SEAISH@0.33, adjective-positive].  NOW CAN WE *PLEASE*, AS [A CULTURE@0.25, THE OTT@0.33, A THREAD@0.5, A NEEDLE-PULLED THING], MOVE ON?
+
+# H. P. Lovecraft short story "The Call of Cthulhu" (1928), original phrase is "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn" (meaning "In his house at R'lyeh, dead Cthulhu waits dreaming.")
+#-PH'NGLUI MGLW'NAFH ...
+[character][place][]PH'NGLUI MGLW'NAFH [$0/remove-the/] [$1/remove-the/] WGAH'NAGL FHTAGN
+
+# Muppets sketch "Pigs in space"
+#-PIGS ... IN SPACE!
+[noun-plural, noun-mass, character] ... IN SPAAAACE!
+
+# Very old, e.g. "Boys' Life" magazine (Aug 1929) "You fellows go out there and play like you've never played before!" ; http://snowclones.org/2007/12/21/going-to-x-like-ive-never-xed-before/
+#-PLAY LIKE YOU'VE NEVER...
+template neverbefore1: I'M GOING TO [verb-tr-inf verb-intr-inf] LIKE I'VE NEVER [$0/-perfect] BEFORE.[]
+template neverbefore2: I'M GOING TO [verb-tr-inf] [noun-plural] LIKE I'VE NEVER [$0/-perfect] [$1] BEFORE.[]
+[neverbefore1, neverbefore2]
+
+# Wikipadia funds campaign (2010) "Please Read: A Personal Appeal From Wikipedia Founder Jimmy Wales"; http://knowyourmeme.com/memes/events/2010-wikipedia-fundraising-campaign
+#-PLEASE READ: A PERSONAL...
+PLEASE READ: A PERSONAL APPEAL FROM [noun-singular] FOUNDER [character].
+
+# NetNanny ad with words "Pornography? On *my* computer?"; http://knowyourmeme.com/memes/x-in-my-y
+#-PORNOGRAPHY? ON...
+[noun-plural, noun-mass, adjec-noun]? [IN@0.5, ON] *MY* [noun-singular, noun-mass]?
+
+# From a games magazine article with a DOOM (1993) screenshot and the caption "PROTIP on DOOM: To defeat the Cyberdemon, shoot at it until it dies."; this may have started the "Protip" running gag ( http://knowyourmeme.com/memes/protip )
+#-PROTIP: TO DEFEAT THE...
+PROTIP: TO [DEFEAT@0.15, verb-tr-inf] THE [noun-singular, noun-mass], [verb-tr-inf] IT UNTIL IT [verb-intr-present]
+
+# @mrob27: This replaces two memes in the original:
+#   PUSH BUTAN, RECEIVE [noun-singular, noun-plural, noun-mass]
+#   PUSH BUTTON, RECEIVE [noun-singular, noun-plural, noun-mass]
+# thus making the overall likelihood half as much
+# Prank caption (appearing as graffiti) written under the pictorial instructions for an electric hand dryer: "Push Button" (under the picture of a hand/finger pushing the dryer's button) / "Receive Bacon" (under a picture of the jet of hot air, depicted as a set of red wavy lines, above the hands) ; earliest known Internet reference is from 2004 ; http://knowyourmeme.com/memes/push-button-receive-bacon
+#-PUSH BUTTON, RECEIVE BACON
+template decr15: PUSH [BUTAN@0.5, BUTTON], RECEIVE [noun-singular, noun-plural, noun-mass][]
+[decr15]
+
+# photo upload prank fad on YTMND and 4chan /b/ (2006) "Put Shoe on Head" ; http://knowyourmeme.com/memes/put-shoe-on-head
+#-PUT SHOE ON HEAD
+template decr16: PUT [noun-singular, noun-mass] ON [HEAD@0.5, noun-singular, noun-mass][]
+[decr16]
+
+# azule: xkcd #1025
+#-RACCOON SEX DUNGEON  .. DOT TUMBLR DOT COM
+[noun-animal-singular] [verb-tr-cont] [DUNGEON@0.3, noun-unique-the]  ... DOT CHIRPING MUSTARD DOT COM.
+
+# Possibly from the "Ramirez, Do Everything!" meme: inspired by "Call of Duty: Modern Warfare 2" (2009), typical examples are "Ramirez, rip that tank apart with your hands!" and "Remirez, take down that chopper with your throwing knife" ; http://knowyourmeme.com/memes/ramirez-do-everything
+#-RAMIREZ, X THAT Y WITH YOUR Z!
+[RAMIREZ@0.2, char-1word], [verb-tr-inf] [noun-singular-that, noun-plural-the]... WITH YOUR [noun-singular, noun-plural, noun-mass, adjec-noun]!
+
+# azule: xkcd #378
+# %%% This needs the Xzibit treatment to handle the noun-plural case differently so I can always have a singular form for the C-X M-C part
+#-REAL PROGRAMMERS USE ...
+template xkcd378a: _REAL_ [noun-plural] USE [noun-article, noun-mass, noun-plural].[]
+template xkcd378b: EXCUSE ME, BUT _REAL_ [noun-plural] USE [noun-article, noun-mass, noun-plural].  OH YEAH! GOOD OL' C-X M-C M-[$1/remove-article/]...[]
+[xkcd378a, xkcd378b]
+
+# From Azule: an OTT meme started around NP1602
+template redun-subj-1: [noun-mass] IS[]
+template redun-subj-2: [noun-plural] ARE[]
+#-REDUNDANCY IS MOLPISH
+[REDUNDANCY IS@0.2, REDUNDAKITTY IS@0.1, redun-subj-1, redun-subj-2] [MOLPISH@0.5, MOLPFISH@0.1, adjective-positive].
+
+# azule, from OTT starting at OTT:871:20#p3384779
+#-REDUNDANT SPOILER IS REDUNDANT.
+REDUNDANT [noun] IS REDUNDANT.
+
+# At least as old as humor book "Save an alligator, shoot a preppie" (1981); also recently "eat" and "ride" are commonly-seen verbs.
+#-SAVE AN ALLIGATOR...
+template decr17: SAVE [noun-singular-article], [EAT@0.12, RIDE@0.15, verb-tr-inf] [noun-singular-article][]
+[decr17]
+
+# Known from Heroes (2006) "Save the Cheerleader, Save the World" but undoubtedly much older.
+#-SAVE THE CHEERLEADER...
+template decr18: [SAVE@0.5, verb-tr-inf] THE [noun-singular, noun-plural, noun-mass], [$0] THE WORLD[]
+[decr18]
+
+# azule: xkcd #54
+#-SCIENCE. IT WORKS, BITCHES.
+[noun-mass, noun-singular-the, verb-cont]. IT WORKS, CH**RPIES.
+
+# azule: xkcd #1037
+#-SCIENTISTS CREATE LIFE IN LAB
+[character] AND [character] CREATE [LIFE@0.2, noun-singular, noun-mass] IN LAB:  "THE TRICK WAS [CH*RPING@0.2, verb-intr-cont]!"
+
+# From the original AUTOMEME, origin unknown
+#-SCREAMING...
+SCREAMING [noun-singular, character]: [character] DOESN'T LIKE IT
+
+# azule: xkcd #10
+#-SEMENCOFFEE...
+SEMENCOFFEECANCERHELPIMTRAPPEDINA[noun-1word]FACTORYSTARSANDBACONBABIESONICE...
+
+# UNC-CH slang "shit happens" (1983), documented in "Yale Book of Quotations" ; http://nancyfriedman.typepad.com/away_with_words/2010/12/snowclones-happen.html
+#-SHIT HAPPENS
+template shithappens1: [adjective] [noun, adjec-noun] HAPPENS.[]
+template shithappens2: [noun, adjec-noun] HAPPENS.[]
+[shithappens1, shithappens2]
+
+# Simpsons character Montgomery Burns, "Smithers, release the hounds"
+#-SMITHERS, RELEASE THE HOUNDS!
+[SMITHERS@0.3, character][][$0/remove-the/], RELEASE THE [RAPTORCATS@0.1, RAPTORSHARKS@0.1, noun-plural]!
+
+# deviantArt group MudKipClub (2003), "so i herd you like mudkips", in reference to the Pokemon character, with spelling changed later; http://knowyourmeme.com/memes/i-herd-u-like-mudkips
+#-SO I HERD U LIEK...
+SO I HERD U [LIEK@0.25, verb-tr-inf] [noun-plural, noun-mass, adjec-noun]
+
+# From "Hitchhiker's Guide to the Galaxy" (Fit the Third, 1978), later used as a title for the 3rd novel
+#-SO LONG AND THANKS...
+SO LONG AND THANKS FOR ALL THE [noun-plural, noun-mass, adjec-noun]
+
+# "The Big Lebowski" (1998) "Sometimes you eat the bear, and sometimes, well, he eats you."
+#-SOMETIMES YOU EAT THE BEAR...
+SOMETIMES YOU [verb-tr-inf] THE [noun-singular], SOMETIMES THE [$1] [$0/-present] YOU
+
+# From Link; "Star Trek" TV series (1966) opening titles
+#-SPACE: THE FINAL FRONTIER...
+template sttos_dur: FIVE-[noun-interval][]
+template sttng_dur: [CONTINUING@0.5, CONTINUONG][]
+[place-name][][$0/remove-the/]: THE FINAL FRONTIER. THESE ARE THE VOYAGES OF THE STARCASTRAFTLE _[noun, adjec-noun]_. ITS [sttos_dur, sttng_dur] MISSION: TO EXPLORE [adjective] NEW [WORLDS@0.3, TIMES@0.5, AFTERWHENS], TO SEEK OUT NEW [noun-mass, adjec-noun] AND NEW [noun-plural, adjec-noun], TO [adverb] [verb-tr-inf, verb-intr-inf] WHERE NO [MOLPY@0.5, noun] HAS [$9/-perfect] BEFORE.
+# A phrase attributed to Theodore Roosevelt (United State president, 1901-1909), specifcally with respect to foreign policy: "Speak softly and carry a big stick; you will go far."; http://en.wikipedia.org/wiki/Big_Stick_ideology
+#-SPEAK SOFTLY AND...
+template decr19: SPEAK [SOFTLY@0.4, adverb] AND CARRY [A SEAISH@0.4, adjective-article] [THWAPSTICK@0.2, noun-singular][]
+[decr19]
+
+# "Spiderman, Spiderman, does whatever a spider can"
+#-SPIDERMAN, SPIDERMAN, ...
+[noun-singular-article][][$0/remove-first-word/]MAN, [$1]MAN, DOES WHATEVER [$0] CAN
+
+# azule: xkcd #109
+#-SPOILER ALERT...
+SPOILER ALERT!  [character] [KILLS@0.5, verb-tr-present] [character] WITH [place, noun-singular-article]!
+
+#-STICK IT IN YOUR TREBUCHET" SOUNDS LIKE...
+"[verb-tr-inf] IT IN YOUR [noun]" SOUNDS LIKE SLANG FOR TELLING SOMEONE TO [GTCO@0.2, CH**RP OFF@0.25, verb-inf].
+
+# GameFAQ's Random Insanity message board (original was “Ninjas! Thousands of them!”); knowyourmeme.com/memes/suddenly-bananas-thousands-of-them
+#-SUDDENLY, NINJAS!...
+SUDDENLY, [noun-plural]. THOUSANDS OF THEM!
+
+# azule: xkcd #149
+#-SUDO MAKE ME A...
+template decr20: [MOLPY@0.1, SUDO] MAKE ME [noun-singular-article].[]
+[decr20]
+
+# azule: xkcd #550
+#-SUP DAWG, I HERD U DIDN'T...
+SUP [dawgchar], I HERD U DIDN'T LIEK [verb-tr-cont], BUT I ACCIDENTALLY IN YOUR [noun-singular].
+
+# song "Take this job and shove it" (1978) ; http://snowclones.org/2007/05/22/take-this-x-and-shove-it/
+#-TAKE THIS JOB...
+template decr21: TAKE THIS [noun] AND [verb-tr-inf] IT[]
+[decr21]
+
+# "Coffee Talk with Paul Baldwin / Linda Richman", a serial sketch featuring Mike Myers on Saturday Night Live (1991-1994), a typical example was "I'm a little verklempt. ... Talk amongst yourselves ... I'll give you a topic ... The Progressive Era was neither progressive nor an era. Discuss.", or (a three-word form) "The Holy Roman Empire was neither holy nor Roman nor an empire."
+#-TAWK AMONGST YOURSELVES...
+template bawldwin2: THE [adjective] [noun-plural] WERE NEITHER [$0] NOR [$1]. DISCUSS.[]
+template bawldwin3: [noun-singular-article][]THE [adjective] [adjective] [$0/remove-article/] WAS NEITHER [$1] NOR [$2] NOR [$0]. DISCUSS.[]
+template decr22: [TAWK AMONGST YOA-XELVES. @0.5, ][I'LL GIVE YOO A TOAPIC... @0.5, ][bawldwin2, bawldwin3][]
+[decr22]
+
+# "Look Around You" mock educational programme (2002-2005), "In the meantime, Thanks ants. Thants." ; https://www.youtube.com/watch?v=gaI6kBVyu00
+#-THANKS, ANTS. THANTS.
+THANKS, [noun-plural, noun-mass, character, adjec-noun]. TH[$0/remove-leading-consonants/].
+
+# Super Mario Bros. videogame (1985) "Thank you Mario! But our princess is in another castle"; http://knowyourmeme.com/memes/but-our-princess-is-in-another-castle
+#-THANK YOU MARIO...
+THANK YOU [character], BUT OUR [noun-singular, noun-mass] IS IN ANOTHER [noun-singular]
+
+# azule: xkcd #37
+#-THAT'S A SWEET ASS-CAR
+THAT'S [A SWEET#0.5, adjective-article] ASS-[noun-singular].
+
+# "Snakes on a Plane" (2006 film), "That's it! I have had it with these m**herf**king snakes on this m**herf**king plane!"
+#-THAT'S IT! I HAVE HAD...
+THAT'S IT! I HAVE HAD IT WITH THESE MOLPYCH**RPING [noun-plural] ON THIS MOLPYCH**RPING [CASTRAFTLE@0.11, RAFTCASTLE@0.04 noun-singular]!
+
+# Crocodile Dundee (1986) "That's not a knife. ... Now *that's* a knife!" ; http://snowclones.org/2007/09/21/thats-not-an-x-this-is-an-x/
+#-THAT'S NOT A KNIFE....
+THAT'S NOT [noun-singular-article] ... *THIS* IS [$0]
+
+# Neil Armstrong (1969), upon stepping on the Moon, "That's one small step for [a] man, one giant leap for Mankind."
+#-THAT'S ONE SMALL STEP...
+THAT'S ONE RIVERISH [noun-singular] FOR [noun-singular-article], ONE SEAISH [$0] FOR [$1/remove-article/]KIND
+
+# by @azule, based on the ALT text of xkcd #1401 and "trebuchat" OTTifications on NP2048
+#-THE NICE THING ABOUT HEADCANNONS...
+[noun-animal-plural, TREBUCHET, TREBUCHAT][]THE NICE THING ABOUT HEAD[$0/lm-aggile/] IS THAT IT'S REALLY EASY TO GET [OTHER PEOPLE@0.5, OTTERS] TO BELIEVE IN THEM.
+
+# Advertisement "The best part of waking up is Folgers in your cup"
+#-THE BEST PART OF WAKING...
+THE [MOLPIEST@0.25, adjec-super] PART OF [MOLPYING UP@0.2, verb-cont] IS [noun-mass, noun-plural, adjec-noun] IN YOUR [noun]
+
+# Harry Truman (U.S. predident) "The buck stops here" sign (1945), referring to the political practice of "passing the buck"
+# From balthasar_s and BlitzGirl via Link
+#...THE BUCK STOPS HERE
+THE [noun] [STOPS@0.7, ****DS@0.3, verb-intr-present] HERE
+
+# Portal videogame (2007), "The cake is a lie" ; http://knowyourmeme.com/memes/the-cake-is-a-lie
+#...THE CAKE IS A LIE
+THE [noun-singular, adjec-noun] IS A LIE
+
+# Fight Club (1999); http://snowclones.org/2011/01/04/the-first-rule-of-x-is-you-dont-talk-about-x/
+#-THE FIRST RULE OF...
+THE FIRST RULE OF [noun-mass, adjec-noun] IS, YOU DON'T TALK ABOUT [$0]
+THE FIRST RULE OF [noun-singular, adjec-noun] CLUB IS, YOU DON'T TALK ABOUT [$0] CLUB
+
+# captioned image (2003) "The internet is serious business"; http://knowyourmeme.com/memes/the-internet-is-serious-business
+#-THE INTERNET IS SERIOUS BUSINESS
+[noun-singular, character] IS SERIOUS [noun-singular]
+
+# "The rent is too damn high", (2010) slogan of a NYC resident and 3rd-party politician; http://knowyourmeme.com/memes/the-rent-is-too-damn-high-jimmy-mcmillan
+#-THE RENT IS TOO...
+[THE@0.5, THIS] [noun-singular] IS TOO CH**RPING [HIGH@0.3, adjective]
+
+# "There is a windmill in my beard. Your argument is invalid." http://captionsearch.com/image.php?id=254
+#   which is a derivative of the older and less-specific "Your argument is invalid"; http://knowyourmeme.com/memes/your-argument-is-invalid
+#-THERE IS A WINDMILL...
+THERE IS [noun-singular-article] IN MY [BEARD@0.33, noun-singular, noun-mass], YOUR ARGUMENT IS INVALID
+
+# Tom Hanks in "A League of Their Own" (1992); http://snowclones.org/2008/04/22/theres-no-crying-in-x/
+#-THERE'S NO CRYING IN BASEBALL
+[place-name][]THERE'S NO [E****ISHNESS@0.33, SADNESS@0.5, CRYING] [$0/-pr-in] [$0]
+
+# Isaiah 48:22 (or 57:20-21) "There is no peace, says The Lord, for the wicked."
+#-THERE IS NO PEACE...
+THERE IS NO [noun-mass, noun-singular, adjec-noun][, SAID THE GLR,@0.25, , SAID RANDALL,@0.33, ] FOR THE [adjective].
+
+# Star Wars Ep. IV (1977); http://snowclones.org/2008/03/04/these-are-not-the-x-youre-looking-for/
+#   and note that "AREN'T" is true to the original, rather than the now-popular "ARE NOT"
+#-THESE AREN'T THE DROIDS...
+THESE AREN'T THE [noun-plural] YOU'RE [verb-cont] FOR
+
+# Rap "Ridin'" by Chamillionaire (2006) lyric "They see me rollin', they hatin" ; http://knowyourmeme.com/memes/they-see-me-rollin
+# To test use 'automeme -n 100235 | grep 'THEY SEE ME' | sort | uniq'
+#-THEY SEE ME ROLLIN'...
+[verb-cont][verb-cont][]THEY SEE ME [$0/abbrev-ing/], THEY [HATIN'@0.33, $1/abbrev-ing/]
+
+# YTMND page with words "They're taking the hobbits to Isengard!", originally from Lord of the Rings (The Two Towers) words spoken by Legolas, OTTified by BlitzGirl at OTT:1483:11#p3462281 ; http://knowyourmeme.com/memes/theyre-taking-the-hobbits-to-isengard
+#-THEY'RE TAKING THE HOBBITS...
+THEY'RE TAKING THE [MOLPIES@0.2, noun-plural] TO [ISENGARD@0.33, ᘝᓄᘈᖉᐣ@0.45, place]!
+
+# "Dr. Tran" web animated cartoon series, episode "Roybertito's" (2008) quote "This cheese is burning me!"
+# thence to xkcd forums wordfilter mapping "lol" to "¡This cheese is burning me!"; later reprised as a "mod madness" wordfilter in 2009 and 2011
+# thence to the "CueMegAll" chat site for OTTers by @Eternal Density, which included automatic wordfiltering of *everything* typed, turning most words into similarly-spelled words that appear in the "Time" comic dialogue, plus some special mappings that reference OTT inside jokes or other xkcd references including old Madness filters
+# From @Link, version 3.4
+#-THIS CHEESE IS BURNING ME
+#¡THIS [noun, noun-mass, adjec-noun] IS [verb-tr-cont] ME!
+
+# Parody of a Chick Publications tract featuring a man saying "Look at this lousy peanut butter sandwich!", parodied by Something Awful forums with caption "This is an ass sandwich. It is made of ass and poo" ; http://knowyourmeme.com/memes/sandwich-chef
+#-THIS IS AN ASS...
+THIS IS [adjective-article] [noun-singular]. IT IS MADE OF [noun-singular, noun-plural, noun-mass, adjective, adjec-noun] AND [noun-singular, noun-plural, noun-mass, adjective, adjec-noun].
+
+# Another xkcd 137 adaptation from Azule
+#-THIS IS VERY IMPORTANT...
+#[t:ott-darkening, t:ott-metaphor, t:xkcd11, t:xkcd51, t:xkcd180, t:xkcd821c2, t:xkcd859]  THIS IS VERY IMPORTANT, SO I WANT TO SAY IT AS CLEARLY AS I CAN:  *[CHIRP, verb_tr-inf--negative/ /. /g]. THAT. [MUSTARD, noun-singular--negative/ /. /g].*
+
+# From Link v. 2.3 (origin unknown)
+#-THIS IS X Y. I MUST...
+THIS IS [adjective] [noun-singular], I MUST [verb-tr-inf] IT
+
+# From the original AUTOMEME (origin unknown)
+# A highly-retweeted tweet from user Horse_ebooks (2012), "'This is not acceptable!'' I screamed as Kathy drowned"
+#-THIS IS NOT ACCEPTABLE...
+"[THIS IS NOT ACCEPTABLE@0.2, interjection]!" I SCREAMED AS [character] [verb-intr-past]
+
+# xkcd 1190 "Time" frame 1006 character "Megan" quote "Yeah. / But that's what the first part of not ending looks like."; and frames 1072-3 character "Cueball" quote "Yeah. / But that's what the first part of understanding everything looks like."
+#-THIS IS WHAT THE FIRST PART...
+[YEAH. BUT @0.5, ][THAT'S@0.5, THIS IS] WHAT THE FIRST PART OF [verb-tr-cont] [noun-plural, noun-mass, adjec-noun] LOOKS LIKE.
+
+# "This is why we can't have nice things" (an admonition by a parent to a child who has damaged something) predates the internet, and appeared in e.g. Paula Poundstone HBO special "Cats, Cops and Stuff" (1990) ; image macros of an angry cat began to appear in 2008 in response to off-topic posts or threadjacking ; http://knowyourmeme.com/memes/this-is-why-we-cant-have-nice-things
+#-THIS IS WHY WE CAN'T HAVE NICE THINGS
+[character, noun-mass-the, noun-singular-the][][$0/the-to-this/] IS WHY WE CAN'T HAVE [MOLPISH@0.2, NICE@0.25, adjective] THINGS.
+
+# Partnership for a Drug-Free America (1987) "This is your brain. This is your brain on drugs. Any questions?" ; http://snowclones.org/2009/06/24/this-is-your-brain-on-x/
+#-THIS IS YOUR BRAIN...
+THIS IS YOUR [BRAIN@0.35, noun-singular]. AND THIS IS YOUR [$0] ON [noun-plural, noun-mass, adjec-noun]. ANY QUESTIONS?
+
+# A popular image macro from 2003 or earlier, originally "This looks shopped / I can tell from some of the pixels and from seeing quite a few shops in my time." ; http://knowyourmeme.com/memes/this-looks-shopped
+#-THIS LOOKS SHOPPED...
+THIS [LOOKS@0.5, IS] [PHOTOSHOPPED@0.2, SHOOPED@0.1, OTTIFIED@0.25, OTCOLORISED@0.33, adjective, verb-tr-perfect]. I CAN TELL BY THE [noun-singular, noun-plural, noun-mass, adjec-noun] AND FROM HAVING SEEN A LOT OF [noun-plural, noun-mass, adjec-noun] IN MY DIP
+
+# Randall Munroe What-If book, p. 131
+#-THIS MAY BE A BIT...
+THIS MAY BE A BIT [adjective-negative], BUT... IF SOME[ONE@0.33, OTTER@0.5, MOLPY]'S [noun] SUDDENLY [VANISHED@0.3, verb-past], HOW LONG WOULD THEY [verb-inf]?
+
+# A threadjacking attempt on the Team Xbox forums (2002), original quote is "This thread is now about duckies and bunnies. Discuss." ; http://knowyourmeme.com/memes/threadjacking
+#-THIS THREAD IS NOW...
+template threadjack1: THIS [NEEDLE-PULLED THING@0.5, noun-singular] IS NOW ABOUT [adjective] [noun-plural, character, adjec-noun][.@0.5, . DISCUSS.][]
+template threadjack2: THIS [NEEDLE-PULLED THING@0.5, noun-singular] IS NOW ABOUT [noun-plural, character, adjec-noun] AND [noun-plural, character, adjec-noun][.@0.5, . DISCUSS.][]
+[threadjack1, threadjack2]
+
+# From Azule, currently commented out because I would need to add several templates and make others into named templates.
+#-THUS ENDS TIME
+# [t:xkcd51, t:xkcd109-sub, t:xkcd208, t:xkcd414, t:xkcd550, t:xkcd859, t:xkcd1013, t:xkcd1017, t:xkcd1110a, t:xkcd1171, t:xkcd1190f1018, t:xkcd1278, t:xkcd1393, t:xkcd1401]  ...THUS ENDS TIME.
+
+# Shakespeare "Hamlet" (1600) "To be or not to be, that is the question"
+#-TO BE OR NOT TO BE ...
+TO [verb-tr-inf, verb-intr-inf] OR NOT TO [$0], THAT IS THE QUESTION
+
+# azule: xkcd #1131
+template x1131s1: [NUMBERS@0.5, noun-plural] CONTINUE[]
+template x1131s2: [noun-article] CONTINUES[]
+# %%% @Azule had "noun-compar" here, but it is undefined.
+#-TO SURPRISE OF PUNDITS
+TO THE SURPRISE OF [PUNDITS@0.3, noun-animal-plural, character], [x1131s1, x1131s2] TO BE THE BEST SYSTEM FOR DETERMINING WHICH OF TWO THINGS IS [LARGER@0.3, adjec-comp].
+
+# From Link; The Wizard of Oz (1939) "I've got a feeling we're not in Kansas anymore"
+#-TOTO, I'VE GOT A FEELING WE'RE...
+[place-name][][character], I'VE GOT A FEELING WE'RE NOT [$0/-pr-in] [$0] ANYMORE
+
+# Probably "Trolling is a art", a phrase which describes itself inasmuch as posting the phrase might be considered trolling (for responses correcting 'a' to 'an')
+#-TROLLING IS A ART
+[verb-cont] IS A [ART@0.5, noun-1word]
+
+# Salon magazine Twitter account (2010) "Very important for Obama to do him job" ; http://gawker.com/5910716/very-important-for-obama-to-do-him-job-explaining-salons-greatest-moment
+#-VERY IMPORTANT FOR OBAMA...
+VERY IMPORTANT FOR [character] TO [DO@0.4, verb-tr-inf] XIM [JOB@0.5, noun-singular, noun-mass, adjec-noun]
+
+# by azule, based on an OTT meme that started around NP1549
+#-VITAL HOTDOG FUNCTION
+*[adjective] [noun-singular, noun-plural, noun-mass, adjec-noun, verb-tr-cont]* IS [A HIDDEN TRACK ON@0.25, THE NAME OF@0.33, THE LATEST SINGLE OFF OF] THE [LATEST@0.3, NEWEST] [VHF@0.5, VITAL HOTDOG FUNCTION] ALBUM.
+
+# "The Treasure of the Sierra Madre" (book 1935, film 1948) "Badges? [...] We don't need badges. I don't have to show you any stinking badges." , made famous by "Blazing Saddles" (1974) "Badges? We don't need no stinking badges." ; http://snowclones.org/2007/07/27/x-we-dont-need-no-stinkin-x/
+#-WE DON'T NEED NO STINKIN'...
+[CH**RPING@0.33, STINKING@0.5, verb-cont-1word][][noun-plural, noun-mass, adjec-noun]? WE DON'T NEED NO [$0/abbrev-ing/] [$1].
+
+# azule: xkcd #51
+#-WE HAD A MALARIA PARTY...
+WE HAD [noun-mass-neg-article] PARTY, BUT IT TURNED OUT NOT TO BE VERY [MOLPISH@0.5, adjective-positive].
+
+# Frank Herbert "Dune" (1965) "Usul, we have wormsign the likes of which even God has never seen!"
+# Added by @Link (not in AUTOMEME)
+#-USUL, WE HAVE WORMSIGN...
+[character], WE HAVE [noun-1word]SIGN THE LIKES OF WHICH EVEN [RANDALL@0.33, THE GLR@0.5, THE OTA] HAS NEVER SEEN!
+
+# Legend of Zelda character Tingle, "Tingle, Tingle! Kooloo-Limpah! ...These are the magic words that Tingle created himself. Don't steal them!"
+#-TINGLE, TINGLE! KOOLOO-LIMPAH...
+#    ---> This meme is near the end because I am using EDnames
+
+# Azule, OTT:2062:19#p3636039 "Well, anything *could* be a meme, including this sentence I just wrote."
+#-WELL, ANYTHING COULD BE...
+WELL, ANYTHING *COULD* BE [A MEME@0.2, noun-singular-article], INCLUDING THIS [SENTENCE@0.1, noun] I JUST [verb-tr-past].
+
+# This is probably from Heather Chandler in "Heathers" (1988), "Well, f*** me gently with a chainsaw."
+#-WELL, FUCK ME...
+WELL CH**RP ME [adverb] WITH [noun-singular-article]
+
+# azule: xkcd #528
+#-WELL, IT'S BETTER THAN VISTA
+WELL, IT'S MOLPIER THAN [noun-singular-neg-art, noun-mass-negative].
+
+# Jaws (1975) "We're gonna need a bigger boat"; http://snowclones.org/2008/02/06/were-gonna-need-a-bigger-x/
+#-WE'RE GONNA NEED...
+WE'RE GONNA NEED A MORE [SEAISH@0.3, adjective] [noun-singular]
+
+# Folgers instant coffee advertising campaign (late 1970's) "We are here at <restaurant> where we've secretly replaced the fine coffee they usually serve with Folgers Crystals. Let's see if anyone can tell the difference!"
+#-WE'VE SECRETLY REPLACED...
+WE'VE SECRETLY REPLACED [character]'S [noun-singular, noun-mass] WITH [noun-singular-article, noun-mass]. LET'S SEE IF XE NOTICES...
+
+# BBC educational programme "Look Around You" (2002-2005), full line was "But what is water? It's a difficult question, because water is impossible to describe. One might ask the same about birds. What are birds? We just don't know."; https://www.youtube.com/watch?v=Kh0Y2hVe_bw
+#-WHAT ARE BIRDS? WE...
+WHAT *ARE* [noun-plural]? WE JUST DON'T KNOW.
+
+# possibly "Whatever floats your boat", though not confirmed; http://snowclones.org/2007/12/10/whatever-xs-your-y/
+#-WHATEVER FLOATS YOUR BOAT
+WHATEVER [verb-tr-present] YOUR [CASTRAFTLE@0.19, RAFTCASTLE@0.06, SHIPCASTLE@0.33, noun-singular, noun-plural, noun-mass]
+
+# "What happens on tour, stays on tour", an unspoken pact originating in rugby union teams whilst on an overseas trip, later adapted to "What happens on the road,..." by rock bands and crews, then to "What happens here, stays here" in reference to Las Vegas, more popularly repeated as "What happens in Vegas, stays in Vegas."
+#-WHAT HAPPENS ON TOUR...
+WHAT HAPPENS IN [place], STAYS IN [$0].
+
+# Randall Munroe What-If book, p. 119
+#-WHAT IF A GLASS OF WATER WAS...
+WHAT IF [noun-mineral-art] OF [noun-mass] WERE, ALL OF A SUDDEN, LITERALLY HALF [noun-mass, adjective, verb-perfect]?
+
+# Randall Munroe What-If book, p. 187
+#-WHAT IF A SPACECRAFT SLOWED...
+WHAT IF A [noun-animal] [verb-past] [WITH@0.5, BY] [adjec-noun] TO JUST A FEW [noun-plural] USING [noun-plural] LIKE [adjective-article] [noun]? WOULD THAT [ENHANCE@0.33, E****@0.5, NEGATE] THE NEED FOR [adjective-article] [noun]?
+
+# Randall Munroe What-If book, p. 23
+#-WHAT IF EVERYONE ACTUALLY...
+[place-name][]WHAT IF [EVERYONE@0.5, EVERYMOLPY] ACTUALLY HAD ONLY ONE [noun], A RANDOM [noun] SOMEWHERE [$0/-pr-in] [$0]?
+
+# Randall Munroe What-If book, p. 10
+# Note two-step process to handle "SOME A"/ "AN A" treatment as in Colossal Caves meme
+#-WHAT IF I TOOK A SWIM IN A TYPICAL SPENT...
+template spentfuelpool: [place-name][]WHAT IF I TOOK A [WALK@0.33, HIKE@0.5, SWIM] [$0/-pr-in] [$0/-art] A TYPICAL [adjective] [noun] [$0/remove-the/]? WOULD I NEED TO [verb-inf] TO ACTUALLY [verb-tr-inf] [adjective-article] AMOUNT OF [noun-plural, noun-mass]?[]
+[spentfuelpool][][$0/postproc-some/]
+
+# Randall Munroe What-If book, p. 88
+#-WHAT IF YOU STRAPPED C4 TO...
+WHAT IF YOU [verb-tr-past] [noun-mass] ON [noun-article]? COULD THIS BE [adjective-article] [noun], OR WOULD IT BE AS [adjective-negative] AS IT SOUNDS?
+
+# Doctor Who episode "The Five Doctors", The Castellan's line "No, not the mind probe!"
+#-WHAT? NO, NOT THE MIND _PROBE_!
+WHAT! NO, NOT THE [MIND@0.3, noun-singular, noun-mass] _[PROBE@0.3, noun-singular, noun-mass]_!
+
+# Randall Munroe "What-If" book, p.195
+#-WHAT PLACE ON EARTH WOULD ALLOW YOU...
+[place-name][$0/-art][]WHAT [$0/remove-the/] [ON EARTH@0.33, IN NEWPIXIA@0.5, IN TIME] WOULD ALLOW YOU TO [verb-inf] THE LONGEST BY [verb-cont] [$0/-pr-out] [$1/some-to-them/]? WHAT ABOUT USING [A SQUIRPY@0.3, adjective-article] [noun-mineral]?
+
+# Randall Munroe What-If book, p. 77
+#-WHAT SORT OF LOGISTIC...
+WHAT SORT OF [adjective] [noun-plural, noun-mass] WOULD YOU ENCOUNTER IN TRYING TO [verb-tr-inf] AN ARMY OF [noun-animal-plural]?
+
+# By Link, v. 0.3.1 (origin unknown)
+#-WHAT THE FUCK? YOU ARE...
+WHAT THE CH**RP? YOU ARE [noun-singular, noun-mass, character]. AND [adjective]
+
+# Randall Munroe What-If book, p. 52
+#-WHAT WOULD HAPPEN IF A HAIR DRYER
+template hairdryer: [place-name][]WHAT WOULD HAPPEN IF A [noun] WITH [CONTINUOUS@0.3, adjective] [POWER@0.3, noun-mass, adjec-noun] WERE [verb-tr-perfect] AND PUT [$0/-pr-in] [$0/-art] [A MUSTARDPROOF@0.2, AN AIRTIGHT@0.25, A WATERTIGHT@0.33, adjective-article] 1$X$1$X$1-CUEBALL [$0/remove-the/]?[]
+[hairdryer][][$0/postproc-some/]
+
+# Randall Munroe What-If book, p. 1
+#-WHAT WOULD HAPPEN IF EARTH AND ALL...
+WHAT WOULD HAPPEN IF [place-name] AND ALL [TEMPORAL@0.2, adjective] OBJECTS SUDDENLY STOPPED [verb-cont], BUT THE [noun] RETAINED ITS [adjec-noun]?
+
+# Randall Munroe What-If book, p. 43
+#-WHAT WOULD HAPPEN IF EVERYONE ON EARTH STOOD...
+[place-name][]WHAT WOULD HAPPEN IF [EVERYONE@0.5, EVERYMOLPY] [$0/-pr-in] [$0] [verb-past] AS CLOSE TO EACH OTHER AS THEY COULD AND [verb-past], EVERYONE [verb-cont] AT THE SAME INSTANT?
+
+# Randall Munroe What-If book, p. 35
+#-WHAT WOULD HAPPEN IF YOU MADE A PERIODIC...
+[noun-animal-plural, noun-mineral-plural][$0/-art][]WHAT WOULD HAPPEN IF [YOU@0.5, character] [verb-tr-past] [adjective-article] [noun] [WITH@0.5, OUT OF] [noun]-SHAPED [$0], WHERE EACH [$1/remove-article/] WAS [MADE@0.3, verb-tr-perfect] [WITH@0.5, BY] [verb-cont-article] [noun]?
+
+# Randall Munroe What-If book, p. 131
+#-WHAT WOULD HAPPEN IF YOU TRIED TO FLY A...
+WHAT WOULD HAPPEN IF YOU TRIED TO [verb-tr-inf] A NORMAL [adjective] [noun] [ABOVE@0.33, THROUGH@0.5, UNDER] DIFFERENT [adjective] [noun-plural]?
+
+# Randall Munroe What-If book, p. 7
+#-WHAT WOULD HAPPEN IF YOU TRIED TO HIT...
+WHAT WOULD HAPPEN IF YOU TRIED TO [verb-tr-inf] A [noun] [verb-tr-perfect] AT 90 PERCENT THE [SPEED@0.2, MOLPISHNESS@0.25, adjec-noun] OF [noun-mass]?
+
+# Randall Munroe What-If book, p. 192
+#-WHEN -- IF EVER -- WILL...
+WHEN -- IF EVER -- WILL THE [noun-mass, adjec-noun] OF THE [noun] SURPASS THAT OF [character, place-name, place-name, place-name]?
+
+# Randall Munroe What-If book, p. 146
+#-WHICH US STATE...
+WHICH [adjective] [noun] IS ACTUALLY [verb-tr-perfect] THE MOST?
+
+# from azule, based on xkcd #1340
+#-WHOA, IT'S 2014-03-10!
+WHOA, IT'S [FRAME@0.33, NP@0.5, NEWPIX] [random_12][random-digit][random-digit][random-digit]!  UNDER [GLR@0.25, MSCHA@0.33, GEEKWAGON@0.5, AUBRONWOOD]'S SYSTEM, THAT [$0] WILL ~NEVER HAPPEN AGAIN!!~
+
+# azule: xkcd #979
+#-WHO WERE YOU, DENVERCODER9? WHAT DID YOU SEE?
+[character][]WHO WERE YOU, [$0/remove-the/]?  ~*WHAT DID YOU SEE?!*~
+
+# "With friends like {you/that/these}, who needs enemies?", also seen in other languages (e.g. Spanish "Con amigos así ¿quién necesita enemigos?"; German "Behüte mich Gott vor meinen Freunden, mit den Feinden will ich schon fertig werden.")
+#-WITH FRIENDS LIKE...
+WITH [noun-plural] LIKE [THIS@0.5, THESE], WHO NEEDS [noun-plural, noun-mass, adjec-noun]?
+
+# Doge (2012) a photo of a Shiba Inu dog (named Kabosu) with "interior monologue" captions in Comic Sans and various colours; http://knowyourmeme.com/memes/doge
+#-WOW - SO SCARE - ...
+[WOW@0.5, NEAT] - SO [noun-singular] - MANY [adjective] - SUCH [verb-cont] - VERY [noun-singular] - MUCH [adjective] - [SEA IS BIG@0.33, RIVER IS SMALL@0.5, HAIL RANDALL]
+
+# http://nancyfriedman.typepad.com/away_with_words/2010/12/snowclones-happen.html
+#-X IS SO LAST-Y
+[verb-cont] IS [JUST @0.5,]SO *LAST [noun-interval]*.
+
+# Photo of "Chappelle's Show" character Tyrone Biggums with caption "YA'LL GOT ANY STEAM DEALS" (2010) , "any more" added in subsequent image macros on Reddit ; http://knowyourmeme.com/memes/yall-got-anymore-of
+#-Y'ALL GOT ANY MORE...
+Y'ALL GOT ANY MORE OF THEM [noun-plural]?
+
+# editorial in the New York Sun (1897), "Yes Virginia, there is a Santa Claus" ; http://snowclones.org/2007/10/12/yes-virginia-there-is-an-x/
+#-YES VIRGINIA, THERE IS...
+[VIRGINIA@0.2, character][]YES [$0/remove-the/], THERE *IS* [noun-unique-article, noun-unique-article, noun-singular-article].
+
+# Very common snowclone, going back at least to Arthur Baer (1938) "You can take a boy out of the country but you can't take the country out of a boy."
+#-YOU CAN TAKE A BOY OUT OF...
+[place-name][]YOU CAN TAKE [character, noun-singular-the] [$0/-pr-out] [$0], BUT YOU CAN'T TAKE [$0] OUT OF [$1]
+
+# "You can't have your cake and eat it too"
+#-YOU CAN'T HAVE YOUR CAKE...
+YOU CAN'T [verb-tr-inf] YOUR [noun-mass, noun-singular] AND [verb-tr-inf] IT TOO
+
+# Infocom "Hitchhiker's Guide to the Galaxy" text adventure game (1984), "You have destroyed most of a small galaxy. Please pick your words with greater care."; http://www.imdb.com/title/tt0436395/quotes
+#-YOU HAVE DESTROYED MOST OF...
+YOU HAVE [verb-tr-past] MOST OF A RIVERISH [noun-commodity]. PLEASE PICK YOUR [noun-plural, noun-mass] WITH GREATER CARE.
+
+# Matthew 26:52 (KJV has "for all they that take the sword shall perish with the sword."
+#-YOU LIVE BY THE SWORD, YOU DIE BY THE SWORD
+YOU [LIVE@0.3, verb-inf] BY THE [PUNSAW@0.25, THWAPSTICK@0.3, noun], YOU [DIE@0.3, verb-inf] BY THE [$1]
+
+# azule: xkcd #231
+#-YOU'RE A KITTY!
+YOU'RE [noun-singular-article]!
+
+# Reddit demotivator "You wouldn't download a car" (captioned "F*ck you / I would if I could"), a parody of “Piracy Parody Ad” (2007) by roboslobproductions on YouTube, itself a parody of the MPAA "You Wouldn't steal a car / You wouldn't steal a handbag / ..." ad campaign; http://knowyourmeme.com/memes/piracy-its-a-crime
+#-YOU WOULDN'T DOWNLOAD A CAR
+YOU WOULDN'T [DOWNLOAD@0.5, verb-tr-inf] [A CASTRAFTLE@0.21, A RAFTCASTLE@0.08, noun-singular-article]
+
+# Photo of Xzibit (Alvin Nathaniel Joiner) captioned with "Yo dawg I herd you like cars so we put a car in yo car so you can drive while u drive" (2008), a parody of the show "Pimp My Ride" wherein Xzibit often put absurd things (like a badminton net or an aquarium) into the car being customized for a person who presumably liked badminton or fish; http://knowyourmeme.com/memes/xzibit-yo-dawg
+# The original starts with a plural noun ("cars") and changes to singular "... put a car in your car"; but could also me memeified with all plurals e.g. "... out some cars in your cars"; this latter form works with mass nouns:
+# HERD U LIEK   ...  SO WE PUT    ...     IN YR
+#              MEMES            A MEME           MEME
+#             HOTDOGS         SOME HOTDOGS      HOTDOG
+#             MUSTARD         SOME MUSTARD     MUSTARD
+template wawlpy1: [noun-animal-art, noun-mineral-art, noun-interval-art][][$0/-plural] SO WE PUT [$0] IN YOUR [$0/remove-article/][]
+template wawlpy2: [noun-animal-art, noun-mineral-art, noun-interval-art][][$0/-plural] SO WE PUT SOME [$1] IN YOUR [$0/remove-article/][]
+template wawlpy3: [noun-mass] SO WE PUT SOME [$0] IN YOUR [$0][]
+#-YO DAWG, I HEARD YOU LIKE...
+YO WAWLPY, I HEARD YOU LIKE [wawlpy1, wawlpy2, wawlpy3] SO YOU CAN [verb-intr-inf] WHILE YOU [$1]
+
+# 2009 MTV VIdeo Music Awards, Kanye West "Yo Taylor, I'm really happy for you, Imma let you finish but Beyonce had one of the best videos of all time..."
+#-YO TAYLOR, I'M REALLY HAPPY...
+YO [character], I'M REALLY HAPPY FOR YOU, IMMA LET YOU FINISH, BUT [character] HAD ONE OF THE [MOST TREEISH@0.33, MOLPIEST@0.5, MOST WOWTERFUL] [noun-plural] OF ALL TIME
+
+# A very old metaphor template, used to describe the significance of something by alluding to a well-known and analagous thing in another domain: e.g. "pink is the navy blue of India", "Stanford is the Harvard of the West", "mrob27 is the the Leonardo DiCaprio of the OTTscars". Probably very old, and hard to track to an origin; http://snowclones.org/2007/12/18/x-is-the-y-of-z/
+#-X IS THE DARK MATTER OF Y
+template darkmatter1: [noun-singular-the, character] IS THE [noun-singular, noun-mass, adjec-noun] OF [noun-the][]
+template darkmatter2: [noun-plural] ARE THE [noun-plural, noun-mass, adjec-noun] OF [noun-the][]
+[darkmatter1, darkmatter2]
+
+# mrob27's variant
+IF [noun-plural] ARE THE [noun-plural] OF [noun-the], AND [$1] ARE THE [noun-plural] OF [noun-the], WHY ARE WE STILL [verb-tr-cont] [$0]?
+
+# Habbo hotel (2006) organized protests in response to mods' suspected racial bias "Pool's closed due to AIDS"; http://knowyourmeme.com/memes/pools-closed
+[POOL@0.5, noun-singular, noun-mass]'S CLOSED DUE TO [noun-plural, noun-mass, character, adjec-noun]
+
+# 4chan "Tits or GTFO" (2006); http://knowyourmeme.com/memes/tits-or-gtfo
+#   and noting 'GTFO' changed to 'GTCO' (that is, changing F****K to CH**RP)
+[noun-plural, noun-mass, adjec-noun] OR GTCO
+
+# From the original AUTOMEME (origin unknown)
+[adjective] [noun-plural] ARE *SUPERIOR*
+
+# Here we replace any initial THE with THIS
+# %%% Link's version randomly uses 'THIS' or 'THAT' at the beginning
+# "This, guys, is the cancer that is killing /b/"
+[noun-singular-the, noun-mass-the, character][][$0/the-to-this/] IS THE [BACONSEMENCOFFEEBABYCANCER@0.2, noun-singular, noun-mass, adjec-noun] THAT IS [E****ING@0.33, KILLING@0.5, CH**RPING] [noun-plural, noun-mass, character]
+
+# Generic euphemism for sexual double-entendre (e.g. Monty Python's Flying Circus season 1 episode 3, Eric Idle, "Is your wife a...goer...eh? Know what I mean? Know what I mean? Nudge nudge. Nudge nudge. Know what I mean? Say no more..."), as an Internet meme more commonly associated with Mr. Bean (Rowan Atkinson), see also OTT:1992:37 ; http://knowyourmeme.com/memes/if-you-know-what-i-mean
+[character] IS "[verb-tr-cont] [noun-singular-article, noun-singular-the, place, character]"... IF YOU KNOW WHAT I MEAN
+
+# From the original AUTOMEME (origin unknown) Possibly "Open your f***ng eyes. Open them"
+[verb-tr-inf] YOUR CH**RPING [noun-plural]. [$0] THEM.
+
+# A common LOLcat caption, "Xcat is X" where X is an adjective (e.g. "Happycat is happy") or a noun ("Lampcat is a lamp"), original unknown but probably 2007 ; http://english.turkcebilgi.com/Lolcat
+# If it's a noun we want the article ("a lamp") only in the second substitution at the end, for adjectives we do not want the article at all. We accomplish this [noun-singular-article, adjective] followed by a cut [], then use a regexp that removes an initial word, if any, in the first substitution.
+[noun-singular-article, adjective][][$0/remove-first-word/]MEOWLPY IS [$0]
+
+# from Link, v. 2.4 (unknown origin) "{} THE {}"
+[verb-tr-inf] THE [noun-plural, noun-mass, adjec-noun]!
+
+# A children's rhyme, "Lenny and Lisa, sitting in a tree, K-I-S-S-I-N-G"
+[verb-cont][][character] AND [character], SITTING IN A [NEAT @0.33, WOW@0.5,]TREE, [$0/spell-out/]
+
+# From the "Warhammer" games, the battle-cry of the followers of Khorne: "Blood for the Blood God! Skulls for the Throne of Khorne!"
+# The awkward construction at the beginning is to make a noun into an adjective:
+#   [noun-plural]            # Select a noun, e.g. "SWORDS"
+#   [$0/-art]                # Get the singular article form: "A SWORD"
+#   [$1/remove-first-word/]  # Remove the article: "SWORD"
+# We then use the artcle-less singular noun as an adjective, "SWORD GOD". And we do it all over again with another noun for the THRONE part.
+# %%% This could be made a lot clearer if we could auto-generate a third column in a multiclass using a template and/or regexp based on one of the other columns.
+[noun-animal-plural, noun-mineral-plural, noun-interval-art][$0/-art][$1/remove-first-word/][noun-animal-plural, noun-mineral-plural, noun-interval-art][$3/-art][$4/remove-first-word/][][$0] FOR THE [$2] GOD! [$3] FOR THE [$5] THRONE!
+
+# A game loosely based on the "wild mass guess" page ( http://tvtropes.org/pmwiki/pmwiki.php/WMG/TimeLord ), wherein the rules consist merely of naming a person or character, and a place or object they are associated with. ; http://www.telltalegames.com/community/discussion/16916/name-here-is-a-time-lord-game
+[character] IS A TIME LORD AND [noun-singular-the, place] IS XIS TARDIS
+
+# Borat "In my country, they would go crazy for these two. ... This one... not so much... ", later memified to "X is Y. Z? ... not so much."
+[noun-singular-article, noun-mass, character, adjec-noun] IS [adjective]. [noun-singular-article, noun-mass, character, adjec-noun]? NOT SO MUCH.
+
+#trzymam kredens
+I CAN'T [SLEEP@0.2, verb-inf] BECAUSE I HAVE TO [HOLD@0.1, verb-tr-inf] MY [CREDENZA@0.2, noun-mineral].
+
+#
+template decr: DECREE: [decr1, decr2, decr4, decr5, decr6, decr7, decr8, decr9, decr10, decr11, decr12, decr13, decr14, decr15, decr16, decr17, decr18, decr19, decr20, decr21, decr22][]
+template decrimp: DECREE: [imper1, imper2, imper3, imper4][]
+template decrall: [decr@0.6, decrimp][]
+
+# ----------------------- GEEK-OUT TEMPLATES -----------------------
+
+# Demonstrating the avoidance algorithm. To test, un-comment this meme and do:
+#     automeme -n 9111 -v | grep '[a-z]' | sort | uniq
+# [avoid] [avoid] [avoid] [avoid]
+
+# "Story" templates used to evaluate and test the recursion mechanism.
+# "equine verbs: they're what you roasting roast", based on "Verb: It's what you do."
+# VERB: IT'S WHAT YOU DO
+template verbmeme: [verb-tr-cont][$0/-inf][][adjective] [VERBS@0.3, noun-plural]: THEY'RE WHAT YOU [$0/hyphenate/] [$1/hyphenate/][]
+# This regex takes the second word *except* for its colon
+regex verbmeme-word2: /^.* ({^ }+):.*$/$1/
+[character][character][][$0] AND [$1] WERE STANDING BY A [noun] THAT HAD SOMETHING WRITTEN ON IT IN BEANISH. I ASKED [$1] WHAT IT SAYS. [$1] TURNED TO LOOK AT [$0]. I ASKED [$0], AND XE ANSWERED, *"[verbmeme]."*. "REALLY, [$0]?" I REPLIED, "[$3/last-word/]? WHY NOT [verb-tr-inf] THEM?" [$1] LOOKED BACK AT ME AND REPLIED, "BECAUSE [$5/-cont] [$3/verbmeme-word2/] IS [****DISH@0.5, adjective-negative]."
+
+# xkcd #1318, memeified by mrob27.
+# First we define a template for each of the six sentences in the comic.
+template xkcd1318a: [noun-plural] SUGGEST IT'S [adjective].[]
+template xkcd1318b: IT'S [noun-singular-article].[]
+template xkcd1318c: IT'S [adjective-article] [noun-singular].[]
+template xkcd1318d: IT'S [noun-singular-article] [verb-tr-perfect] BY THE [noun-singular, adjective] [noun-plural].[]
+template xkcd1318e: IT'S THAT PLUS [adjective] [noun-singular].[]
+template xkcd1318f: IT'S [verb-tr-perfect] IN A [noun-singular] THAT'S [verb-tr-perfect].[]
+#
+# Next, define a template that chooses at random one of the above six forms.
+template xkcd1318-part: [xkcd1318a, xkcd1318b, xkcd1318c, xkcd1318d, xkcd1318e, xkcd1318f][]
+#
+# Then, make a random xkcd 1318 by doing [xkcd1318-part] six times, with an *ACTUALLY* in between each one.
+#... *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, [xkcd1318-part] *ACTUALLY*, ...
+# TV series "That Mitchell and Webb Look", recurring sketch "Numberwang" (2006)
+#-THAT'S NUMBERWANG
+template wang1: [random-digit][]
+template wang2: [random_12][random-digit][]
+template wang3: [random-digit][random-digit][]
+template wang4: [random_12][random-digit][random-digit][]
+template wangnt: [wang1, wang2, wang3, wang4][]
+template wangnum: [wangnt][][$0/^0+//, /^$/0/][]
+# template 'wangshow' takes elements from the xkcd 1318 meme and adapts them into a show tagline.
+#    the maths quiz that simply everyone is talking about
+#    the maths quiz that's simply everyone
+#    the numbers show that simply everyone, is talking about? yes.
+#    the maths quiz for everyone from 8 to 8 hundred and eighty eight.
+# examples:
+#   IT'S A DILGUNNERANG
+#       -> THE SHOW THAT'S A DILGUNNERANG
+#   IT'S THAT PLUS EPSILONISH XIP
+#       -> THE SHOW THAT'S THAT PLUS EPSILONISH XIP
+#   MOLPYBARAS SUGGEST IT'S OTTERRIFIC
+#       -> THE SHOW MOLPYBARAS SUGGEST IS OTTERRIFIC
+template wangshow: [xkcd1318-part][]THE [MATHS@0.5, NUMBERS] [QUIZ@0.5, SHOW] [$0/^IT'/THAT'/, /SUGGEST IT'/SUGGEST I/][]
+[IT'S@0.3, WELCOME TO@0.5, THIS IS] NUMBERWONGGH, [wangshow] HERE WITH US TODIP FOR THE FIRST TIME ARE [char-1word] WHO IS FROM [place-name], AND [char-1word] WHO IS ALSO FROM [place-name]. RIGHT, [LET'S BEGIN@0.5, WE START THIS ROUND] WITH [$2]. / [wangnum]? / THAT'S NUMBERWONGGH! [$4]? / [wangnum]. / YES, [$8] IS NUMBERWONGGH. [$2]? / [wangnum]. / [interjection], NO, [$9] IS ACTUALLY [noun-mass-negative], SORRY!
+
+# Descriptions of the "Complex maze" from "Colossal Caves" adventure (1976) ; http://en.wikipedia.org/wiki/Colossal_Cave_Adventure#Maze_of_twisty_little_passages
+# There are exactly twelve phrases in the original, fitting this template:
+#
+#   YOU ARE IN A [foo] [foo] [foo] PASSAGES, ALL DIFFERENT.
+#
+# where the three "[foo]"s comprise a permutation of "LITTLE", "TWISTY", and
+# "MAZE OF", or with "TWISTING instead of "TWISTY" to get 12 combinations
+# instead of just six.
+#    To make this meme we need to exploit the automatic duplication-avoidance
+# feature of automeme. First, here is the implementation of the
+# straight (un-memeified) Colossal Cave phrases:
+#
+template maze-adj: [LITTLE@0.33, TWISTING@0.5, MAZE OF][]
+template maze-ing: [maze-adj] [maze-adj] [maze-adj][]
+template maze-y: [maze-ing][][$0/TWISTING/TWISTY/][]
+#YOU ARE IN A [maze-ing, maze-y] PASSAGES, ALL DIFFERENT.
+#
+# To memeify it, we want to substitute "MAZE" with a randomly-chosen
+# [place]. Since a regex cannot refer to another replaceable, we instead
+# change the "MAZE" to a backquote "`" (which does not occur anywhere in
+# the lexicon), then use the /former-part/ and /latter-part/ regexes to
+# separate it into two phrases so we can interpose the [place-name]
+# where "MAZE" was. We also OTTify LITTLE while we're at it. As usual in
+# complex cases like this, all but the last step is performed before a cut [].
+# (If we also wanted to change LITTLE to a random adjective, we could repeat
+# the process we used for MAZE.)
+#
+template maze-permut: [place-name][$0/remove-the/][maze-ing, maze-y][$2/MAZE/`/, /LITTLE/RIVERISH/][][$0/-pr-in] `[$0/-art] `[$3/former-part/][$1][$3/latter-part/][]
+# Examples of [maze-permut] :
+#   IN `AN `RIVERISH OTC OF TWISTING
+#   ON `A `TWISTING RIVERISH TOWER OF
+#   IN `SOME `RIVERISH TWISTY DUNES OF
+# The preposition and article (1st and 2nd parts) match the place not the adjective: in the first example "AN" is matched to "OTC".
+# I use '`' as the separator to handle hyphenated places, e.g. "YOU ARE IN A RIVERISH TWISTY CASSINI-MADAGASCAR OF HAMPLIES, ALL RELATED."
+#
+# Extract the three parts and add an article to the 3rd
+template maze-some: [maze-permut][$0/former-part/][$0/middle-part/][$0/latter-part/][$3/add-article/][]YOU ARE [$1][$2][$4] [noun-plural], ALL [adjective].[]
+# Examples of [maze-some] :
+#   YOU ARE ON A A RIVERISH RIVER OF TWISTY PASTPOSTS, ALL SEAISH.
+#   YOU ARE IN AN A TWISTING AFTERWHEN OF RIVERISH DECREES, ALL AWESOMEFUL.
+#   YOU ARE IN SOME A TWISTING RIVERISH MOUNTAINS OF KEYBOARDS, ALL WOWTERFUL.
+# The first article will be SOME if needed to match the place; the second article (e.g. "A" in the "YOU ARE IN AN A TWISTING..." example) matches the following word, be it an adjective or placename.
+#
+# Finally we postprocess to remove the duplicate article: If the first article is A or AN, remove it, else we remove the 2nd article after the SOME.
+[maze-some][][$0/postproc-some/]
+
+# My "nerd-sniping monstrosity" from NP2058. Purely as a demonstration of
+# the capabilities of regular expressions to do cool things in totally
+# incomprehensible ways, this templace selects two [character] names,
+# multiplies the number of letters together and shows the answer in decimal
+# and binary.
+#
+# Count the number of letters in a word (up to 999)
+regex count-letters: /{A-Z}/I/gi, /{^A-Z}//g, /IIIII/V/g, /VV/X/g, /X$/X0/, /XXXXX/L/g, /LL/C/g, /C0/C00/, /CV/C0V/, /CI/C0I/, /CCCCC/D/, /DCCCC/9/, /DCCC/8/, /DCC/7/, /DC/6/, /D/5/, /CCCC/4/, /CCC/3/, /CC/2/, /C/1/, /LXXXX/9/, /LXXX/8/, /LXX/7/, /LX/6/, /L/5/, /XXXX/4/, /XXX/3/, /XX/2/, /X/1/, /VIIII/9/, /VIII/8/, /VII/7/, /VI/6/, /V/5/, /IIII/4/, /III/3/, /II/2/, /I/1/
+HELLO, I AM [character], AND MY NAME HAS [$0/count-letters/] LETTERS!
+#
+# Count letters in Roman Numerals (999 max)
+regex count-ltrs-roman: /{A-Z}/I/gi, /{^A-Z}//g, /IIIII/V/g, /VV/X/g, /XXXXX/L/g, /LL/C/g, /CCCCC/D/
+
+# Count letters and give the answer in "BinaRo", which is "Binary Roman Numerals": A=1, B=2, C=4, D=8 and so on, up to 63
+regex count-binaro: /{A-Z}/A/gi, /{^A-Z}//g, /AA/B/g, /BB/C/g, /CC/D/g, /DD/E/g, /EE/F/
+#
+# Multiply a binary-Roman number by 2 (up to 255*2)
+regex binaro-x2: /H/I/g, /G/H/g, /F/G/g, /E/F/g, /D/E/g, /C/D/g, /B/C/g, /A/Bg/
+#
+# Given two binaro numbers demarcated like "DA_CB_", return a single (non-reduced) binaro string equal to their product. (There are better ways to do this)
+regex multiply: /({B-E}*)A_({A-F}*)_({A-K}*)/$1_$2_$3$2/, /({CDE}*)B_({A-F}*)_({A-K}*)/$1_$2_$3$2$2/, /({DE}*)C_({A-F}*)_({A-K}*)/$1_$2_$3$2$2$2$2/, /({E}*)D_({A-F}*)_({A-K}*)/$1_$2_$3$2$2$2$2$2$2$2$2/, /E_({A-F}*)_({A-K}*)/$2$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1/, /_{A-F}*_({A-K}*)/$1/
+#
+# Turn a binaro number into a equal string of A's
+regex binaro-expand: /G/FF/g, /F/EE/g, /E/DD/g, /D/CC/g, /C/BB/g, /B/AA/g
+#
+# Count letters, answer in (normal) binary.
+regex count-binary: /{A-Z}/A/gi, /{^A-Z}//g, /$/ /, /AA/B/g, /B /B0/, /BB/C/g, /C0/C00/, /CA/C0A/, /CC/D/g, /D0/D00/, /DB/D0B/, /DD/E/g, /E0/E00/, /EC/E0C/, /EE/F/g, /F0/F00/, /FD/F0D/, /FF/G/g, /G0/G00/, /GE/G0E/, /GG/H/g, /H0/H00/, /HF/H0F/, /HH/I/g, /I0/I00/, /IG/I0G/, /[A-K]/1/g, / //
+#
+template zombie-character: ZOMBIE-[character][]
+#
+# Pick two words, return them along with a data field comprising their letter-counts in binaro
+template twoform: [zombie-character][zombie-character][][$0/hyphenate/] [$1/hyphenate/] [$2/count-binaro/]_[$3/count-binaro/]_[]
+#
+# Demonstrate multiplication and binary numeric output.
+[twoform][$0/first-word/][$0/second-word/][$0/last-word/][$3/multiply/][$4/binaro-expand/][]I'M [$1], AND I'VE BEEN LEARNING MATHS FROM LMJB1964. THIS IS MY FRIEND [$2], AND THE NUMBER OF LETTERS IN MY NAME MULTIPLIED BY THAT IN XES NAME IS [$5/count-letters/], [$5/count-ltrs-roman/] IN ROMAN NUMERALS, OR [$5/count-binary/] IN BASE 2.
+
+# Japanese news interview (2014) young man who says "being in the snow with my lover like this immerses me in a special feeling. I like it." (originally "恋人といる時の雪って特別な気分に浸れて僕は好きです") next to girlfriend who appears embarrassed ; http://knowyourmeme.com/memes/special-feeling-%E7%89%B9%E5%88%A5%E3%81%AA%E6%B0%97%E5%88%86
+#BEING IN THE SNOW WITH MY LOVER...
+# @@Link and @@azule: ignore this!
+#[verb-cont] WITH MY [noun] GIVES ME A [SPECIAL@0.25, MOLPISH@0.33, adjective-positive] FEELING.
+
+# Scene from "Death Note" manga Ch. 53 (2005), or episode 24 of the anime series (2007), showing character Light Yagami (Kira) with caption "JUST AS PLANNED!", became a popular image macro from 2005, seen on 4chan starting 2007 ; http://knowyourmeme.com/memes/just-as-planned
+template event1: THE [noun-plural, noun-mass] [verb-tr-past] THE [noun][]
+template event2: [noun-singular-article] IS [verb-cont][]
+template keikaku1: 計画[通り@0.7, されていないと][]
+template keikaku2: [JUST@0.7, NOT] AS PLANNED[]
+[event1, event2] ... [keikaku1, keikaku2]
+
+# (More Japanese memes are at: knowyourmeme.com/search?page=2&q=japanese
+
+# A big example I created for azule, which will probably go in the
+# documentation someday
+# 
+# regex remove-leading-the: /^THE //
+# 
+# # Some names with THE, some without, some have multiple words
+# class oznames:
+# DOROTHY GALE
+# GLINDA (THE GOOD WITCH OF THE NORTH)
+# THE SCARECROW
+# TOTO
+# THE WICKED WITCH OF THE WEST
+# 
+# class names-no-the:
+# # Take anything starting with THE but remove the THE
+# [oznames] ms/remove-leading-the/
+# # Take most of the rest (ugly)
+# [oznames] ms/^({A-SU-Z})/$1/
+# [oznames] ms/^(T{A-GI-Z})/$1/
+# # We would still miss THEODORE
+# 
+# templates:
+# # Do it one way
+# 'SUP [names-no-the]? (template1)
+# 
+# # Do it the other way
+# [oznames][]'SUP [$0/remove-leading-the/]? (template2)
+
+# An approximation of Eternal Density's random title generator. The original
+# is online at mustardriver.webfactional.com/hyperwaitforce/randomname/
+#
+# Names consist of one or more syllables drawn from a list, with
+# apparently no elision or modification of adjacent letters. Also
+# with low probability 'rach' or 'ette' is added to the beginning or
+# end... or possibly syllable frequency varies by syllable -- for
+# example, "zor" might be less common than "tor" -- but I haven't
+# done a thorough analysis.
+class ednamsyl:
+AN
+AX
+BALL
+BIN
+BOB
+BUN
+CAN
+CHA
+COM
+CUE
+DAN
+DOM
+DRAG
+EL
+ETTE
+FREE
+GAN
+GON
+HAT
+HUD
+IQUE
+JER
+JON
+KIT
+LAR
+LEE
+LEET
+LIP
+LOR
+MAN
+MAR
+MEG
+MEL
+MIN
+NA
+NAR
+NAS
+ON
+OOZ
+PLUG
+RA
+RACH
+RAG
+RAP
+ROS
+RY
+SAL
+SKIT
+SNAG
+TAD
+TAL
+TAN
+TAP
+TAX
+TAY
+TER
+THAT
+TOR
+UK
+VAN
+WHAL
+WO
+YUB
+ZOORT
+ZOR
+
+# The distribution of names by syllable-count seems to suggest this type of
+# generation function: Start with one syllable. Then flip a coin 4 times; for
+# each "heads" add another syllable, but for 'tails' do nothing. With low
+# probability, add an ending ('rach' or 'ette') to the beginning and/or end.
+template edname: [ednamsyl][ednamsyl@0.5, ][ednamsyl@0.5, ][ednamsyl@0.5, ][ednamsyl@0.5, ][]
+
+# Simple two-syllable EDname
+template ednam2syl: [ednamsyl][ednamsyl][]
+
+class edactype:
+ANTI
+BIO
+BLITZ
+BUG
+CARBO
+CLAP
+COUNTER
+CUSTARD
+DANGER
+DINO
+DISCO
+DOOM
+ELECTRO
+FAIRY
+FAN
+FUTURO
+FUZZY
+HEXA
+HEXADECI
+HIGH
+MAGNETO
+MAL
+MAXI
+MEGA
+MIME
+MINI
+MOLP
+MOON
+NECRO
+NEGA
+POP
+PRIMO
+PROTO
+QUACK
+RAPTOR
+SPIDER
+SQUISHY
+SUPER
+TECHNO
+TEMPORO
+ULTRA
+VICE
+XENO
+ZERO
+
+class edactor:
+ADMIRAL
+BAKER
+CAPTAIN
+COLONEL
+DEFEATER
+DESTROYER
+DIRECTOR
+DISCOVERER
+EMPEROR
+EMPRESS
+EXECUTIONER
+EXECUTOR
+EXPERT
+FOUNDER
+GENERAL
+GRADUATE
+HELPER
+HERO
+KING
+KNIGHT
+LADY
+LIBRARIAN
+LORD
+MAKER
+MOME
+OCCUPANT
+POPE
+PREEMPTOR
+PRESIDENT
+QUEEN
+REVEALER
+RULER
+SAVER
+SINGER
+VENDOR
+VIPER
+WIZARD
+
+# Special places (unique domains)
+class edplspec:
+%5bCLASSIFIED INFORMATION%5d
+ACCIDENTAL DYNAMITE
+ACCIDENTAL TNT
+ALL MUD
+CAT KIND
+DISCO
+DOWN UNDER
+ENCOM
+HUMANITY
+# Original had "Humens"
+HUMANS
+MAILBOXES
+NOWHERE
+OLD EARTH
+SOME BACKWATER PLANET
+SPACE
+SUFFICIENT VELOCITY
+THE ARENA
+THE BLACK
+THE CONTINUUM
+THE CORE
+THE FUTURE
+THE IMPERIUM
+THE OTHER SIDE
+THE OVERFLOW
+THE PAST
+THE RING
+THE SPOT
+THE THUNDERDOME
+THE UTTER EAST
+TIME
+YESTERDAY'S LEFTOVERS
+# The original had "Zombie Goasts"
+ZOMBIE GHOSTS
+
+class edplace:
+CASTLE
+CAVE
+CITY
+CLOUD
+DOME
+FOREST
+GLADE
+HILL
+ISLAND
+LAND
+MOUNTAIN
+OCEAN
+PALACE
+POOL
+PORT
+REGION
+RIVER
+ROAD
+ROCK
+SEA
+STAR
+STREET
+VILLAGE
+VOLCANO
+WATERFALL
+WORLD
+
+# A 'domain' is a named place, like "ANYUBTAN CASTLE" or "RALOR VILLAGE"
+template edomain: [edname] [edplace][]
+
+template edthing: [edplspec@0.5, edomain][]
+
+# edtitle
+templates:
+[edname], [edactype]-[edactor] OF [edthing]
+
+
+# Legend of Zelda character Tingle, "Tingle, Tingle! Kooloo-Limpah! ...These are the magic words that Tingle created himself. Don't steal them!"
+#-TINGLE, TINGLE! KOOLOO-LIMPAH... : this meme is near the end because I am using EDnames
+[character], [$0]! [ednam2syl]-[ednam2syl]! ...THESE ARE THE [MAGIC@0.6, adjective] WORDS THAT [$0] CREATED XIMSELF. DON'T [STEAL@0.25, verb-tr-inf] THEM!
+
+# The following templates are a translation ot the "Vilani Random Word Generator" at http://eaglestone.pocketempires.com/lang/vilani/vilanigen4.html
+
+# 0  39  78  99  120  141  162  180  190  200 204 208 212 216
+#  39  39  21  21   21   21   18   10   10   4   4   4   4
+#  K   G   M   D    L    SH   KH   N    S    P   B   Z   R
+#  216 177 138 117  96   75   54   36   26   16  12  8   4
+template vilani_i_cons: [K@0.18, G@0.22, M@0.15, D@0.18, L@0.22, SH@0.28, KH@0.185, N@0.28, S@0.38, P@0.25, B@0.33, Z@0.5, R][]
+
+# 0  67  84  143  184 192  208 216
+#  67  17  59   41   8   16   8
+#  A   E   I    U    AA  II   UU
+#  216 149 132  73   32  24   8
+template vilani_vow: [A@0.31, E@0.11, I@0.44, U@0.56, AA@0.25, II@0.67, UU][]
+
+#  0  76  101  139  165  180  191  216
+#   76  25   38   26   15   11   25
+#   R   N    M    SH   G    S    K
+#   216 140  115  77   51   36   25
+template vilani_f_cons: [R@0.35, N@0.18, M@0.33, SH@0.34, G@0.29, S@0.31, K][]
+
+template vilani_v: [vilani_vow][]
+template vilani_cv: [vilani_i_cons][vilani_vow][]
+template vilani_vc: [vilani_vow][vilani_f_cons][]
+template vilani_cvc: [vilani_i_cons][vilani_vow][vilani_f_cons][]
+
+template vilani_bas: [vilani_v, vilani_cv, vilani_cv, vilani_vc, vilani_cvc][]
+template vilani_alt: [vilani_cv, vilani_cv, vilani_cv, vilani_cvc, vilani_cvc][]
+
+template vilani: [vilani_bas][vilani_alt@0.5, ][vilani_alt@0.5, ][vilani_alt@0.5, ][vilani_alt@0.5, ][]
+
+# [vilani] [vilani] [vilani] [vilani] [vilani]
\ No newline at end of file
diff --git a/mem/npb.png b/mem/npb.png
new file mode 100644 (file)
index 0000000..36db7c7
Binary files /dev/null and b/mem/npb.png differ
diff --git a/mome.awk b/mome.awk
new file mode 100644 (file)
index 0000000..52e8cf0
--- /dev/null
+++ b/mome.awk
@@ -0,0 +1,99 @@
+#// mome.awk\r
+#// automome ONGification\r
+#// 16.01.2015\r
+#// \r
+#// Copyright (C) 2015  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       printf("")>outfile\r
+       for(i=0;i<256;++i)\r
+       {\r
+               ch=sprintf("%c",i)\r
+               hex=sprintf("%02X",i);\r
+               ch2hex[ch]=hex\r
+       }\r
+}\r
+{\r
+       if(sub(/[AEIOUY]-N-G/,"[b]O-N-G[/b]",$0)>0)\r
+       {\r
+               print prepare($0) > outfile\r
+               exit\r
+       }\r
+       if(sub(/O+N+G+/,"[b]&[/b]",$0)>0)\r
+       {\r
+               print prepare($0) > outfile\r
+               exit\r
+       }\r
+       if(sub(/DON'T/,"D[b]ON'G[/b]T",$0)>0)\r
+       {\r
+               print prepare($0) > outfile\r
+               exit\r
+       }\r
+       if(sub(/[AEIOUY]NG/,"[b]ONG[/b]",$0)>0)\r
+       {\r
+               if($0!~/TH\[b\]ONG/)\r
+               {\r
+               print prepare($0) > outfile\r
+                       exit\r
+               }\r
+       }\r
+       if(sub(/ON /,"[b]ONG[/b] ",$0)>0)\r
+       {\r
+               print prepare($0) > outfile\r
+               exit\r
+       }\r
+       if(sub(/O\.?$/,"[b]ONG[/b] ",$0)>0)\r
+       {\r
+               print prepare($0) > outfile\r
+               exit\r
+       }\r
+};\r
+function urlencode(name,   len,iii,escaped,ch)\r
+{\r
+       len=length(name)\r
+       escaped=""\r
+       for(iii=1;iii<=len;++iii)\r
+       {\r
+               ch=substr(name,iii,1);\r
+               if (ch ~ /[a-z]|[A-Z]|[0-9]/)\r
+                       escaped = escaped ch\r
+               else\r
+                       escaped = escaped "%" ch2hex[ch]\r
+       }\r
+       return escaped\r
+};\r
+function prepare(rh)\r
+{\r
+       gsub(/\*\*/,"¤",rh)\r
+       gsub(/\*[^\*]+\*/,"±&±",rh)\r
+       gsub(/±\*/,"[i]",rh)\r
+       gsub(/\*±/,"[/i]",rh)\r
+       gsub(/¤/,"*",rh)\r
+       \r
+       gsub(/__/,"¤",rh)\r
+       gsub(/_[^_]+_/,"±&±",rh)\r
+       gsub(/±_/,"[u]",rh)\r
+       gsub(/_±/,"[/u]",rh)\r
+       gsub(/¤/,"_",rh)\r
+       \r
+       gsub(/\$\$/,"¤",rh)\r
+       gsub(/\$[^\$]+\$/,"±&±",rh)\r
+       gsub(/±\$/,"[size=80]",rh)\r
+       gsub(/\$±/,"[/size]",rh)\r
+       gsub(/¤/,"$",rh)\r
+       \r
+       return urlencode(rh  " -- [url=http://1190.bicyclesonthemoon.info/ongtext?b=on][b]ong[/b]o[/url][url=http://mrob.com/time/automome/]mome[/url]")\r
+}\r
diff --git a/mome.pl b/mome.pl
new file mode 100755 (executable)
index 0000000..d0eabd5
--- /dev/null
+++ b/mome.pl
@@ -0,0 +1,974 @@
+#!/usr/bin/perl
+#
+# mome.pl
+# automome
+# 09.09.2014
+#
+# mome.pl is actually mrob27's automome.
+# (http://mrob.com/time/automome)
+# which he released on the following license:
+# #                               LICENSE
+# #
+# # This software, and the sample memes file that goes with it (which is at
+# # http://mrob.com/time/automome/automeme-pl.txt ) are made available under
+# # a Creative Commons Attribution-NonCommercial 4.0 International License.
+# # License details are at http://mrob.com/cc-license.html
+
+use strict;
+
+# These are required for UTF-8 parsing, which is exemplified by:
+#
+#   class foreign-words:
+#     π
+#   regex initial-letter: /^(.).*$/$1/
+#   [foreign-words] starts with '[$0/initial-letter/]
+#
+# however on older OS's, like MacOS 10.4, using these 'use' statements
+# sometimes causes false errors from Perl.
+use utf8;
+use open ':std', ':encoding(UTF-8)';
+
+my $bapropos = q@
+automeme(1r)   -- generate random bits of text using templates that match
+                  popular internet 'memes'
+@;
+
+my $g_memefile = "ott-snowclones.txt";
+
+my $help = qq`
+NAME
+
+  automeme     -- generate random bits of text using templates that match
+                  popular internet 'memes'
+
+DESCRIPTION
+
+Given no argument, this script just prints out a string of text that
+is generated using a randomly-selected template and filling in, after
+the style of "Mad Libs".
+
+The meme definitions are in a file called "$g_memefile" in the
+current directory or in ~/data/memes ; this can be changed with the -o
+and -d options.
+
+OPTIONS
+
+  -d foo/bar.txt  - Read the meme definitions from "foo/bar.txt". You can
+                    give any pathname; if nothing is found it prints an error
+                    and exits. You can also give just a filename, in which
+                    case it will look first in the current directory, then
+                    in ~/data/memes
+  -lc 60          - Limit number of characters of any output lines to 60
+  -n 27           - Make 27 lines of random memey goodness
+  -o              - Use the original AUTOMEME snowclone database,
+                    "automeme.txt", either in the current directory or in
+                    ~/data/memes
+  -t '[noun]'     - Instead of selecting templates from those provided
+                    in the file, expand the given string as if it were a
+                    template.
+  -v              - Verbose: Print some debugging messages.
+
+FILE FORMAT
+
+A meme data file can include blank lines or comments starting with
+'#', which will be ignored. A line starting with 'class', such as
+'class adjective:', starts a list of words/phrases of a particular
+category. A line starting with 'templates:' begins the meme templates
+(snowclone definitions). The format of meme templates is demonstrated
+by the examples in &examples(), which are executed if you pass the
+arguments "-n 0".
+
+DEBUGGING
+
+To detect errors in the memes template file, use the command
+
+  automeme -n 10000 -v | grep Error
+
+This tells it to generate a lot of memes and print error messages (-v),
+the #grep# will filter out just the error messages.
+
+SEE ALSO
+
+  fortune       - The classic adage generator
+  magic-8-ball  - Prognosticator
+
+`;
+
+my $unused_block_header = q`
+
+REVISION HISTORY
+
+ 20140406 First version (cloned from #skel#). Get engine working.
+Convert @Link's OTT meme database into this grammar.
+ 20140407 Fix a bug in rep2 index calculation; allow random selection between
+two words with [FOO@0.27, BAR]
+ 20140408 Add -o option.
+ 20140409 Allow multiple regexps in history substitution; add
+'[foo]ms/bar/baz/' generator for defining classes based on other classes.
+ 20140411 Fix a regexp bug; allow two fixed-probability literals
+ 20140415 Add cut operator '[]'
+ 20140427 UTF8 compliance.
+ 20140505 Add -lc option.
+ 20140723 Add multiclass syntax.
+ 20140725 In &rep3, check for the 'LITERAL@0.12, ' parts first, and
+allow three such parts. Add more syntax examples to &examples()
+  Implement isomorph syntax. $1/foo/bar regexp syntax now allows
+'g' modifier.
+ 20140730 &rep3 now accepts arbitrarily many random literal parts.
+Add an explanatory block comment on multiclass.
+ 20140731 -v option shows an error message if an empty class
+is used in a replaceable context.
+ 20140803 Add some more error detection.
+ 20140804 Template-expansion code (functions memeify, rep1, rep2 and rep3)
+can now call itself recursively.
+ 20140804 Add named regex syntax (but only for the ms// selector when
+building derived classes)
+ 20140805 Support named regexes in replaceables; add more error
+detection. &rep3 now tries to make sure each string acquired from a
+call to rep2 is different from any previous ones (within this
+particular call to memeify).
+ 20140806 Add named templates and recursion. Add more error-checking.
+ 20140807 More error detection
+ 20140813 More restrictive test for 'class has no members' error
+ 20140830 Do not need the UTF-8 "use" statements.
+ 20140907 You can now give fixed probabilities to templates and/or
+classes in a rep3 replaceable.
+ 20140908 Add -t option.
+
+BUGS and TO-DO
+
+A template can be given a name via label, allowing it to be invoked
+the same way a class is named (as an option within a replaceable).
+Labels must contain no spaces or other odd punctuation; if you want a
+literal colon you can use %3a. If you want the template *only* for use
+within another template, end its definition with a cut [].
+  Invoke a set of labeled templates with "[foo, bar, baz]" which will
+cause one to be picked and a recursive call to rep3
+  Use a labeled template as a macro/substring of a longer template
+with just one label inside brackets e.g. "foo bar [baz]"
+  We'll want to be able to do "foo: [bar, baz][]" and invoke [foo] two
+or more times in e.g. the Doge meme. This means at least 2 or 3
+recursive levels should be allowed.
+  Provide a way to indicate that a replaceable should *not* duplicate
+an earlier one (or perhaps this should always be true by default for
+certain classes of replaceables).
+  Use this construct to improve the Doge meme and deal with xkcd #1318
+
+MULTICLASS and ISOMORPHS
+
+A *multiclass* is a set of classes whose members have a one-to-one
+correspondence with each other. Here is an example of a multiclass
+defining singular and plural nouns:
+
+   multiclass noun[-singular, -plural]:
+   CAT     | CATS
+   FISH    | FISH
+   GOOSE   | GEESE
+
+This defines classes "noun-singular" and "noun-plural". Each noun has
+singular and plural forms, called "declensions". It is also useful to
+define a multiclass for verbs, in which case we have "conjugations":
+
+   multiclass verb-transitive[-present, -past]:
+   CARRY    | CARRIED
+   SEE      | SAW
+   THROW    | THREW
+
+The general term for declension and conjugation is "inflection", so
+each item in a line is a different inflection of the words next to it:
+"CATS" is the plural inflection of "CAT" and "SAW" is the past
+inflection of "SEE".
+    However, a multiclass is useful for things that are not inflections.
+Consider the following examples:
+
+   multiclass animal[-singular, -plural, -collective]:
+   CAT     | CATS   | CLOWDER
+   COW     | HERD   | CATTLE
+   FISH    | FISH   | SCHOOL
+   GOOSE   | GEESE  | FLOCK
+
+   multiclass vehicle[-singular, -operator]:
+   BICYCLE | RIDER
+   CAR     | DRIVER
+   SHIP    | CAPTAIN
+   TRAIN   | ENGINEER
+
+Here we use the multiclass to define *isomorphisms*, such as "FISH is
+to SCHOOL as CAT is to _______" (what is the collecive noun for cats?)
+and "CAR is to DRIVER as TRAIN is to _______" (what do you call the
+driver of a train?). The different words in a row cannot be called
+"inflections" so intead I call them "isomorphs".
+    To use a multiclass, first invoke a class member using its normal
+class name, then get an isomorph using the history variable, a slash,
+and the ending of the class name for the isomorph. For example,
+the template:
+
+    I SAW A [animal-collective] OF [$0/-plural].
+
+which might generate the sentence "I SAW A SCHOOL OF FISH."
+
+`;
+
+my $hd = $ENV{"HOME"};
+
+my $p_classname = "[-_a-z0-9]+";
+my $p_mul_names = "[-, _a-z0-9]+";
+
+my $g_iterations = 1;
+my $g_limit_characters = 9999;
+my $g_verbose = 0;
+
+my %error_seen;
+sub reg_error
+{
+  my($msg) = @_;
+  if ($error_seen{$msg}) {
+  } else {
+    print "*** Error: $msg\n" if ($g_verbose);
+    $error_seen{$msg} = 1;
+  }
+}
+
+# Check a regexp pattern to determine if it is a valid Perl regexp.
+sub validate_regexp
+{
+  my($pat, $nonfatal) = @_;
+  my($evstr);
+
+  if (" $pat)" =~ m/[^\\][\$\@\%][^)]/) {
+    # Allow no variables
+    return 0;
+  }
+
+  if (($pat =~ m/\|/) && ($pat =~ m|/|)) {
+    # Cannot handle, fail
+    &reg_error("Pattern cannot use both '|' and '/'");
+    return 0;
+  } elsif ($pat =~ m|/|) {
+    $evstr = "'foo' =~ m|$pat|";
+  } else {
+    $evstr = "'foo' =~ m/$pat/";
+  }
+  eval $evstr;
+  if ($@) {
+    # Failage
+    # die "val fail /$pat/\n";
+    return 0;
+  }
+  # It must have succeeded
+  return 1;
+}
+
+sub eval_repl
+{
+  my($l, $from, $to, $mod) = @_;
+  my($rv, $evstr);
+
+  $rv = $l;
+  $evstr = '$rv =~ ';
+  if (($from =~ m/\|/) && ($from =~ m|/|)) {
+    # Cannot handle, just return original string
+    return $l;
+  } elsif ($from =~ m|/|) {
+    $evstr .= "s|$from|$to|$mod;";
+  } else {
+    $evstr .= "s/$from/$to/$mod;";
+  }
+  eval $evstr;
+  if ($@) {
+    # Failage
+    # die "repl fail /$from/$to/\n";
+    return $l;
+  }
+  # It must have succeeded
+  return $rv;
+}
+
+sub eval_match
+{
+  my($l, $pat, $mod) = @_;
+  my($rv, $evstr);
+
+  $rv = 0;
+  $evstr = '$rv = ($l =~';
+  if ($pat =~ m|/|) {
+    $evstr .= "m|$pat|$mod)";
+  } else {
+    $evstr .= "m/$pat/$mod)";
+  }
+  eval $evstr;
+  if ($@) {
+    # Failage
+    # die "match fail '$pat'\n";
+    return 0;
+  }
+  # It must have succeeded
+  return $rv;
+}
+
+my %class_pop;
+my %class_member;
+
+my %named_regex;
+my %named_template;
+
+# Add line of text to current class
+sub add1
+{
+  my($class, $l) = @_;
+  my($key);
+
+  $class_pop{$class} += 0; # Make sure this is not the null string
+                           # when defining the first element
+  $key = "$class $class_pop{$class}";
+  $class_member{$key} = $l;
+  # print "class_member{$key} = $class_member{$key}\n";
+  $class_pop{$class}++;
+}
+
+my $g_mc_width;
+my @mc_names;
+my @mc_vars;
+my %is_multiclass;
+my %mc_isomorphs;
+my %multiclass_basenames;
+
+# Define the names of each of the classes in a multiclass.
+sub mc_setup
+{
+  my($base, $vars) = @_;
+  my($name, $b2, $var);
+
+  $g_mc_width = 0;
+  foreach $var (split(/,/, $vars)) {
+    $var =~ s/ //g;
+    # print "mcs $g_mc_width $var\n";
+    $name = $base . $var;
+    $mc_names[$g_mc_width] = $name;
+    $is_multiclass{$name} = 1;
+    $mc_vars[$g_mc_width] = $var;
+    $g_mc_width++;
+  }
+
+  # Create the isomorph mappings
+  for $b2 (@mc_names) {
+    for $var (@mc_vars) {
+      $mc_isomorphs{"$b2/$var"} = $base . $var;
+      # print "mc_isomorphs{'$b2/$var'} = '$base$var'\n";
+    }
+  }
+
+  $multiclass_basenames{$base} = 1;
+}
+
+# Add a list of items to all the classes in the current multiclass. The input
+# is a line like "FOO | BAR |    | BAZ" where the items are separated by
+# '|'. Any blank items will cause empty strings to be put into the corresponding
+# 
+sub mc_add
+{
+  my($l) = @_;
+  my($i, $class, $key, $var);
+
+  $i = 0;
+  foreach $var (split(/\|/, $l)) {
+    if ($i < $g_mc_width) {
+      $var =~ s/^ +//;
+      $var =~ s/ +$//;
+      # print "mcs $i $var\n";
+      $class = $mc_names[$i];
+      $class_pop{$class} += 0;
+      $key = "$class $class_pop{$class}";
+      $class_member{$key} = $var;
+      # print "class_member{'$key'} = '$var'\n";
+      $class_pop{$class}++;
+      $i++;
+    }
+  }
+  # Make sure blanks are put in any columns that were left out
+  while ($i < $g_mc_width) {
+    $class = $mc_names[$i];
+    $key = "$class $class_pop{$class}";
+    $class_member{$key} = '';
+    $class_pop{$class}++;
+    $i++;
+  }
+}
+
+# Load data for vocabulary and snowclone templates
+sub load_data
+{
+  my($dir, $fn, $fp, $l, $class, $key);
+  my($vocab, $mclass, $mdim, $p1, $p2);
+
+  # %%% In future the meme database could be selected by an environment
+  # variable, command-line option and/or rc file.
+  $fn = "$g_memefile";
+
+  # Look for database in curdir or in ~/data/memes
+  if ($fn =~ m|^/|) {
+    # User gave absolute path
+    $fp = $fn;
+  } else {
+    # Relative path: look in . or in ~/data/memes
+    $dir = ".";
+    if (!(-f "$dir/$fn")) { $dir = "$hd/data/memes"; }
+    $fp = "$dir/$fn";
+  }
+  die "No file '$fp'\n" if (!(-f $fp));
+
+  print "Reading meme definitions from $fp\n" if ($g_verbose);
+  open(my $IN, $fp);
+  while($l = <$IN>) {
+    chomp $l;
+    $l =~ s/[\t]/ /g;
+    $l =~ s/^ +//;
+    $l =~ s/ +$//;
+    $l =~ s/ +/ /g;
+    if ($l eq '') {
+      # Blank line -- ignore
+    } elsif ($l =~ m/^#/) {
+      # Comment delimiter -- ignore
+    } elsif ($l =~ m/^class +($p_classname):$/i) {
+      $class = $1;
+      $vocab = 1; $mclass = '';
+    } elsif ($l =~ m/^multiclass +($p_classname) *\[($p_mul_names)\]:$/i) {
+      $mclass = $1; $mdim = $2;
+      # print "mc_setup($mclass, $mdim)\n";
+      &mc_setup($mclass, $mdim);
+      $vocab = 1; $class = ''; # Suppress adding to simple class
+    } elsif ($l =~ m|^regex +($p_classname): *(/.+/.*/[gi]*) *$|i) {
+      $p1 = $1; $p2 = $2;
+      $named_regex{$p1} = $p2;
+    } elsif ($l =~ m|^regex +($p_classname)|i) {
+      &reg_error ("Malformed regex definition '$1'");
+    } elsif ($l =~ m|^regex +|i) {
+      &reg_error ("Malformed regex declaration");
+    } elsif ($l =~ m|^template +($p_classname): +(.*)\[\] *$|i) {
+      $p1 = $1; $p2 = $2;
+      $named_template{$p1} = $p2;
+      # print "named_template{$p1} = $p2\n";
+    } elsif ($l =~ m|^template |i) {
+      &reg_error("'template' keyword without classname, ':' or ending '[]'");
+    } elsif ($l =~ m/^templates:$/) {
+      $class = 't:';
+      $vocab = 0; $mclass = '';
+    } elsif ($class ne '') {
+      my($fcl, $from, $to, $i, $key, $mod);
+      if ($vocab
+         && ($l =~ m|^\[($p_classname)\] *ms/([^/]+)/(.*)$|))
+      {
+        $fcl = $1; $p1 = $2; $p2 = $3;
+        if ($named_regex{$p1} ne '') {
+          $p1 = $named_regex{$p1};
+        } else {
+          $p1 = "/$p1/$p2";
+        }
+        $p1 =~ tr/{}/[]/;
+        if ($p1 =~ m|/([^/]+)/([^/]*)/(i?)|) {
+          $from = $1; $to = $2; $mod = $3;
+          # print "foo1 |$fcl|$from|$to|\n";
+          if ($class_pop{$fcl} <= 0) {
+            &reg_error("No elements in [$fcl]");
+          } elsif (&validate_regexp($from)) {
+            for($i=0; $i<$class_pop{$fcl}; $i++) {
+              $key = "$fcl $i";
+              $l = $class_member{$key};
+              if (&eval_match($l, $from, $mod)) {
+                # print "foo1 '$l' s/$from/$to/$mod";
+                $l = &eval_repl($l, $from, $to, $mod);
+                # print "-> '$l'\n";
+                &add1($class, $l);
+              } else {
+                # print "foo4 '$l' does not match /$from/\n";
+              }
+            }
+          } else {
+            &reg_error("Could not validate regex /$from/");
+          }
+        } else {
+          &reg_error("Could not parse regex $p1");
+        }
+      } elsif ($vocab && ($l =~ m|^\[($p_classname)\] *$|))
+      {
+        $fcl = $1;
+        if (($fcl ne $class) && ($class_pop{$fcl} > 0)) {
+          for($i=0; $i<$class_pop{$fcl}; $i++) {
+            $key = "$fcl $i";
+            $l = $class_member{$key};
+            &add1($class, $l);
+          }
+        } elsif ($class_pop{$fcl} <= 0) {
+          # print "foo2 no elements in [$fcl]\n";
+        } else {
+          # print "foo3 could not validate /$from/\n";
+        }
+      } else {
+        &add1($class, $l);
+      }
+    } elsif ($mclass ne '') {
+      &mc_add($l);
+    }
+  }
+  close $IN;
+} # End of load_data
+
+# variables used within memeify, and re-instantiated by memeify when
+# it calls itself recursively. See www.perlmonks.org/?node_id=66677
+our $g_rep2_index;
+our $g_rep2_class;
+
+our @g_subst_history;
+our $n_meme_substitutions;
+our @g_sh_index;
+our @g_sh_class;
+our @g_sh_oa;
+our %rep2_results;
+
+my $complexity;
+my $base_template;
+
+# memeify takes a full meme template and expands it. Templates can invoke labeled sub-templates. The final result is returned as a string.
+# memeify does not perform the final step of un-escaping %% literals.
+sub memeify
+{
+  my($meme) = @_;
+
+  local $g_rep2_index;
+  local $g_rep2_class;
+
+  local @g_subst_history;
+  local $n_meme_substitutions;
+  local @g_sh_index;
+  local @g_sh_class;
+  local @g_sh_oa;
+  local %rep2_results;
+
+  # print "memeify '$meme', n_meme_substitutions == $n_meme_substitutions\n";
+  # print "foo1 gsh[0] == $g_subst_history[0]\n";
+
+  # Return a single substitution from a given class, chosen at random
+  sub rep1
+  {
+    my($class) = @_;
+    my($i, $t);
+
+    $i = int($class_pop{$class} * rand);
+    $t = $class_member{"$class $i"};
+    return $t;
+  }
+
+  # rep2 takes a list of classes OR a list of named templates, and either
+  # selects a class member or selects and executes a template.
+  #
+  # In the first form, it returns a substitution chosen from one or more
+  # classes given a list of those classes' names. The distribution
+  # will be even by individual class-member, not by class. For
+  # example, if you give the classes "fruits, vegetables" and if there
+  # are 14 vegetables and 11 fruits, then this function will return a
+  # vegetable 14/(14+11) = 56% of the time.
+  #
+  # In the second form, it chooses a named template given a list of template
+  # names, then executes the selected template by making a single recursive
+  # call to memeify. In this instance, each named template has an equal
+  # probability of being chosen.
+  sub rep2
+  {
+    my($classes) = @_;
+    my($cls, $tpop, $ncls, $i, $na, $nr, $recurse);
+    my(@bases);
+    my(@cnames);
+
+    $classes =~ s/,/ /g;
+    $classes = " $classes ";
+    $ncls = 0; $tpop = 0; $recurse = 0;
+    foreach $cls (split / /, $classes) {
+      if ($cls =~ m/^$p_classname$/) {
+        if ($class_pop{$cls}) {
+          if ($recurse) {
+            &reg_error("Cannot mix named templates and literal-classes in a pick-list.");
+          } else {
+            $cnames[$ncls] = $cls;
+            $bases[$ncls] = $tpop;
+            $tpop += $class_pop{$cls};
+            $ncls++;
+          }
+        } elsif ($multiclass_basenames{$cls}) {
+          &reg_error("'$cls' is a multiclass basename, variant missing.");
+        } elsif ($named_template{$cls} ne '') {
+          if ($tpop > 0) {
+            &reg_error("Cannot mix literal-classes and named templates in a pick-list.");
+          } else {
+            $recurse = 1;
+            $cnames[$ncls] = $cls;
+# print "cnames[$ncls] = '$cls'\n";
+            $ncls++;
+          }
+        } elsif (($cls =~ m/[a-z]/) && ($cls eq lc($cls))) {
+          &reg_error("Class '$cls' has no members.");
+        }
+      }
+    }
+
+    if ($recurse) {
+      # Pick one at random
+      $na = int($ncls * rand);
+      # Retrieve the template and memeify it!
+      $cls = &memeify($named_template{$cnames[$na]});
+      return $cls;
+    }
+
+    if ($ncls == 0) {
+      # We found none, so we'll just return the string
+      $classes =~ s/^ *//;
+      $classes =~ s/ *$//;
+      return $classes;
+    }
+
+    $na = int($tpop * rand);
+
+    # Find out what class we selected
+    $i=0; while (($na>=$bases[$i+1]) && ($i+1 < $ncls)) { $i++; }
+
+    # Convert the absolute index into an index relative to the selected class
+    $nr = $na - $bases[$i];
+    $cls = $cnames[$i];
+
+    # If we're drawing from a member of a multiclass, it makes sense to
+    # remember the class name and index for use in later isomorph
+    # substitution
+    if ($is_multiclass{$cls}) {
+      $g_rep2_index = $nr;
+      $g_rep2_class = $cls;
+    } else {
+      $g_rep2_index = -1;
+      $g_rep2_class = '';
+    }
+
+    # print "foo1 $cls: ncls $ncls tpop $tpop na $na nr $nr\n";
+
+    # We're done!
+    return $class_member{"$cls $nr"};
+  } # End of rep2
+
+  # Call rep2 with a repetition-avoidance loop. Results are considered
+  # 'duplicate' if the result (output of rep2) is identical to a
+  # previous rep2 result, regardless of whether the argument (input to
+  # rep2) is the same or different.
+  sub avoid_rep2
+  {
+    my($arg) = @_;
+
+    # We iteratively call &rep2 until it manages to return a result that
+    # is distinct from any other &rep2 calls within this instance of
+    # &memeify. To avoid infinite looping, we try at most 27 times.
+    my($avoid_count) = 27;
+    my($rv);
+
+    while ($avoid_count > 0) {
+      $rv = &rep2($arg);
+      if (($rep2_results{$rv}+0) == 0) {
+        # We found a new one!
+        $avoid_count = 0;
+      } else {
+        $avoid_count--;
+      }
+    }
+    $rep2_results{$rv} = 1;
+
+    return $rv;
+  }
+
+  # Return a replacement for one of the types of substitutions defined by the
+  # automeme grammar (see FILE FORMAT section in block comment above, and
+  # examples in &examples() routine below)
+  sub rep3
+  {
+    my($arg) = @_;
+    my ($i, $rv, $from, $to, $rs, $mod, $gh_index, $gh_class, $oa, $t);
+
+    # print "foo2 gsh[0] == $g_subst_history[0]\n";
+
+    $rv = ''; $oa = $arg;
+    $gh_index = -1; $gh_class = '';
+    if ($arg eq '') {
+      # Cut: send cut signal back to caller
+      return '[]';
+    }
+
+    $i = 0;
+    while ($arg =~ s/^([^\$\@]*)\@([.0-9]+), *//) {
+      if ((rand() < $2) && ($i == 0)) {
+        # Return initial string (a template, class, or literal)
+        # with a fixed probability
+        $rv = $1;
+        if (($class_pop{$rv} > 0) || ($named_template{$rv} ne '')) {
+          $rv = &avoid_rep2($rv);
+        }
+        $i = 1;
+      }
+    }
+
+    if ($i) {
+      # We got one of the randoms
+    } elsif ($arg =~ m|^\$([0-9]+) *(/.*/.*) *$|) {
+      # numbered 'variable' with (one or more) regexp replacement(s)
+      # demarcated by at least two slash characters '/'
+      $rv = $1; $rs = $2;
+      # Check for named regex
+      if ($rs =~ m|^/($p_classname)/$|) {
+        # With just two slashes, we expect a named regex.
+        $t = $1;
+        if ($named_regex{$t} ne '') {
+          $rs = $named_regex{$t};
+        } elsif ($g_sh_class[$i] ne '') {
+          # Perhaps they're trying to do an isomorph
+          &reg_error("I got '/$t/', but isomorph syntax has no trailing slash.");
+        } else {
+          &reg_error("No named regex '$t'");
+        }
+      } else {
+        # This is okay, it's probably a literal regex.
+        # &reg_error("'$rs' is not of the named-regex form");
+      }
+      if ($rv >= $n_meme_substitutions) {
+        &reg_error("There is no '\$$rv' in history.");
+      }
+      $rv = $g_subst_history[$rv];
+      $rs .= ', ';
+      # print "rep3 |$arg|$rv|$rs|\n";
+      # Bite off the grep-forms one at a time. Each is expected to
+      # be of the form /foo/bar/x where the match 'foo' must be non-null,
+      # and the trailing modifiers 'x' can include 'g' or 'i' but nothing
+      # else.
+      while ($rs =~ m|^/([^/]+)/([^/]*)/([gi]*), *(.*)$|) {
+        $from = $1; $to = $2; $mod = $3; $rs = $4;
+        $from =~ tr/{}/[]/;
+        # print "rep3 '$rv' /$from/$to/";
+        if (&validate_regexp($from)) {
+          $rv = &eval_repl($rv, $from, $to, $mod);
+        } else {
+          &reg_error("Could not validate regex /$from/");
+        }
+        # print " -> '$rv'\n";
+      }
+      # See if we are left with anything; this is a syntax error.
+      if ($rs ne '') {
+        &reg_error("Malformed or partial regex '$rs'");
+      }
+    } elsif ($arg =~ m|^\$([0-9]+) */([^/]+)$|) {
+      # numbered 'variable' with isomorph substitution
+      $i = $1; $rs = $2;
+      # print "foo $i $g_sh_class[$i]\n";
+      if ($g_sh_class[$i] eq '') {
+        # We cannot isomorph, just return the original
+        $rv = $g_subst_history[$i];
+        if ($named_regex{$rs} ne '') {
+          &reg_error("In '[\$$i/$rs]', the named regex needs a trailing slash.");
+        } else {
+          &reg_error("'$g_sh_oa[$i]' is not a multiclass member.");
+        }
+      } else {
+        # Get isomorph class
+        $rv = $mc_isomorphs{"$g_sh_class[$i]/$rs"};
+        # print "mc_isomorphs{'$g_sh_class[$i]/$rs' == $rv\n";
+        if ($rv eq '') {
+          # They asked for a nonexistent isomorph
+          $rv = $g_subst_history[$i];
+          # print "foo-err2\n";
+          if ($named_regex{$rs} ne '') {
+            &reg_error("Named regex '$rs' needs a trailing slash.");
+          } else {
+            &reg_error("'$g_sh_class[$i]' has no isomorph '$rs'.");
+          }
+        } else {
+          $rv = $class_member{"$rv $g_sh_index[$i]"};
+        }
+      }
+    } elsif ($arg =~ m|^\$([0-9]+) *$|) {
+      # numbered 'variable': return the Nth substitution from those we have
+      # generated so far for this meme. We return directly so as not to
+      # define another history item, which would be redundant.
+      return $g_subst_history[$1];
+    } elsif ($arg =~ m|^\$([0-9]+)(.*)$|) {
+      &reg_error("Unknown modifier '$2' on history variable");
+    } else {
+      # default case: $arg contains one or more word classes
+      # implementation differs depending on whether equal weight is given per
+      # class or per class-member.
+      # %%% recursion passes through here; callers checked in rep2
+
+      $rv = &avoid_rep2($arg);
+
+      $gh_index = $g_rep2_index;
+      $gh_class = $g_rep2_class;
+    }
+
+    $g_subst_history[$n_meme_substitutions] = $rv;
+    $g_sh_index[$n_meme_substitutions] = $gh_index;
+    $g_sh_class[$n_meme_substitutions] = $gh_class;
+    $g_sh_oa[$n_meme_substitutions] = $oa;
+    $n_meme_substitutions++;
+
+    return $rv;
+  } # End of rep3
+
+  $complexity++;
+  if ($complexity > 27) {
+    &reg_error("Recursive template too complex: $base_template");
+    return "";
+  }
+
+  # Do it!
+  $meme =~ s/\[([^]]+)\]/&rep3($1)/ge;
+
+  # Detect a cut signal if any
+  $meme =~ s/^.*\[\]//;
+
+  return $meme;
+} # End of memeify
+
+sub mfy2
+{
+  my($template) = @_;
+  my($rv);
+
+  $complexity = 0;
+  $base_template = $template;
+
+  $rv = &memeify($template);
+
+  # De-escape any special literals
+  $rv =~ s/\%([0-9a-fA-F]{2})/chr(hex($1))/ge;
+
+  return $rv;
+}
+
+sub examples
+{
+  # Pass "-n 0" as arguments to see these demonstration test cases
+
+  # Return an adjective
+  print (&mfy2("[adjective]") . "\n");
+
+  # Return a present-continuous (aka present progressive) or past-tense verb
+  print (&mfy2("[verb-tr-cont, verb-tr-past]") . "\n");
+
+  # Return a random noun, but half the time it's HODOR. In Perl
+  # @ inside "" is special so we use ''
+  print (&mfy2('[HODOR@0.5, noun-singular]') . "\n");
+
+  # Return NORTH 1/4 of the time, EAST 1/3 of the remaining time,
+  # SOUTH 1/2 of the remaining time, and WEST the rest of the time.
+  print (&mfy2('[NORTH@0.25, EAST@0.3333, SOUTH@0.5, WEST]') . "\n");
+
+  # Example of a full expansion
+  print (&mfy2('I CAN [verb-tr-inf] [HOTDOG@0.3, noun-singular] PLEEZ?') . "\n");
+
+  # This one uses the % escape character to include literal brackets [] in the result
+  print (&mfy2('%5b[CITATION@0.3, noun-singular, noun-mass] [NEEDED@0.3, verb-tr-past]%5d') . "\n");
+
+  # A few examples that use history substitition
+  print (&mfy2('I PUT [noun-mass] IN YOUR [$0]...') . "\n");
+
+  # This snowclone performs a sort of Pig Latin transformation. The prototype
+  # is "Bless you, ants. Blants." but we want it to work on plural nouns
+  # that start with a consonant. We use a regexp to remove any string of zero
+  # or more non-vowels from the beginning of $0. Note the use of braces {}
+  # to represent a character-class within the regexp.
+  print (&mfy2('BLESS YOU, [noun-plural, noun-mass, character]. BL[$0/^{^AEIUO}+//].') . "\n");
+
+  # Here we use a regexp to remove the article (or any initial word) from a
+  # noun-singular-article
+  print (&mfy2('I HAZ [noun-singular-article]. U CAN HAS MY [$0/^{^ }+ //].') . "\n");
+
+  # For the "Dial M for murder" template we need to choose the full word
+  # 'murder' before being able to extract its first letter. To achieve this
+  # we use the cut operation '[]', which causes the parser to evaluate
+  # the preceding portion and then discard it.
+  print (&mfy2('[noun-singular, noun-plural, noun-mass, character] []DIAL [$0/^(.).*/$1/] FOR [$0]') . "\n");
+
+  # Another example, where we select a [place] and then remove any initial 'THE'
+  print (&mfy2('[place][]PH\'NGLUI MGLW\'NAFH [character] [$0/^THE //] WGAH\'NAGL FHTAGN') . "\n");
+
+  # A sometimes flawed attempt at verb conjugation. The prototype is
+  # "Hating haters gonna hate", and we attempt to transform the continuous
+  # verb form ("hating") into the plural actor form ("haters") by matching the
+  # ING and changing it to ERS. We than attempt to form the infinitive ("hate")
+  # by simply removing ING, but that doesn't always work. Here we show a few
+  # exceptions
+  print (&mfy2('[verb-tr-cont, verb-intr-cont] [$0/YING/IERS/, /ING/ERS/] GONNA [$0/ING//, /LLAT$/LLATE/, /DOODL /DOODLE /, /HOTDOGG/HOTDOG/]') . "\n");
+
+  # Another attempt at verb transformation
+  print (&mfy2('[verb-intr-cont][verb-intr-cont][]THEY SEE ME [$0/ING/IN\'/], THEY [HATIN\'@0.67, $1/ING/IN\'/]') . "\n");
+
+  print (&mfy2('I WEAR [noun-mineral-art] NOW. [$0/-plural] ARE COOL.') . "\n");
+
+  print (&mfy2('[noun-animal-plural, noun-mineral-plural][$0/-art][$1/^{^ }+ //][][$0] FOR THE [$2] GOD!') . "\n");
+
+  # Demonstrating use of a meme subroutine ('[verbmeme]'), buth the main meme and the subroutine use $0, and the main meme extracts parts of the subroutine.
+  print (&mfy2('[character][character][][$1] TURNED TO LOOK AT [$0]. I ASKED [$0], AND XE ANSWERED, "[verbmeme]". "REALLY, [$0]?" I REPLIED, "[$2/^.* ({^ }+)$/$1/]? WHY NOT [verb-tr-inf] THEM?" [$1] LOOKED BACK AT ME AND REPLIED, "BECAUSE [$4/-cont] [$2/^.* ({^ }+):.*$/$1/] IS [****DISH@0.5, adjective-negative]."') . "\n");
+
+  # Demonstrating the avoidance algorithm.
+  print (&mfy2("[avoid] [avoid] [avoid] [avoid]") . "\n");
+}
+
+$| = 1;
+
+# Set defaults and parse arguments
+my ($arg, $i, $g_literal_template);
+while($arg = shift) {
+  if ($arg =~ m/^-[-]?h(elp)?$/) {
+    print $help;
+    exit(0);
+  } elsif ($arg eq '-d') {
+    # Use user-specified memebase
+    $g_memefile = shift;
+  } elsif ($arg eq '-lc') {
+    # Limit characters: max length for memes
+    $g_limit_characters = shift;
+  } elsif ($arg eq '-n') {
+    # Produce N memes
+    $g_iterations = shift;
+  } elsif ($arg eq '-o') {
+    # Use original memebase
+    $g_memefile = "automeme.txt";
+  } elsif ($arg eq '-t') {
+    $g_literal_template = shift;
+  } elsif ($arg eq '-v') {
+    $g_verbose = 1;
+  } else {
+    print STDERR "Unrecognized argument '$arg'\n";
+    exit(-1);
+  }
+}
+
+# Read in the memes database
+&load_data();
+
+if ($g_iterations <= 0) {
+  &examples();
+}
+
+# Produce N memes
+my ($m, $gg);
+for($i=0; $i<$g_iterations; $i++) {
+  # Get memes until we have one that's short enough
+  $gg = 1;
+  while($gg) {
+    if ($g_literal_template ne '') {
+      $m = &mfy2($g_literal_template);
+    } else {
+      $m = &mfy2(&rep1('t:'));
+    }
+    $gg++;
+    if ($gg > 10000) {
+      print STDERR "I have tried 10000 times without finding a short enough result.\n";
+      exit(-1);
+    }
+    if (length($m) < $g_limit_characters) {
+      $gg = 0;
+    }
+  }
+  print ("$m\n");
+}
diff --git a/mpost.awk b/mpost.awk
new file mode 100644 (file)
index 0000000..f312876
--- /dev/null
+++ b/mpost.awk
@@ -0,0 +1,76 @@
+#// mpost.awk\r
+#// The tool to post to the mirror\r
+#// 08.04.2015\r
+#// \r
+#// Copyright (C) 2015  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       FS="="\r
+       fora="http://1190.bicyclesonthemoon.info/ott"\r
+       useragent="\"bothasar_p (http://1190.bicyclesonthemoon.info/ott/; Time thread post bot)\""\r
+};\r
+{\r
+       argtab[$1]=$2\r
+};\r
+END{\r
+       printf ("username=%s",argtab["username"])>postfile\r
+       printf ("&password=%s",argtab["password"])>>postfile\r
+       printf ("&subject=%s",argtab["subject"])>>postfile\r
+       if("&addbbcode20" in argtab)\r
+               printf ("&addbbcode20=%s",argtab["addbbcode20"])>>postfile\r
+       printf ("&message=%s",argtab["message"])>>postfile\r
+       printf ("&post=%s","Submit")>>postfile\r
+       if("disable_bbcode" in argtab)\r
+               printf ("&disable_bbcode=%s",argtab["disable_bbcode"])>>postfile\r
+       if("disable_smilies" in argtab)\r
+               printf ("&disable_smilies=%s",argtab["disable_smilies"])>>postfile\r
+       if("disable_magic_url" in argtab)\r
+               printf ("&disable_magic_url=%s",argtab["disable_magic_url"])>>postfile\r
+       if("attach_sig" in argtab)\r
+               printf ("&attach_sig=%s",argtab["attach_sig"])>>postfile\r
+       if("notify" in argtab)\r
+               printf ("&notify=%s",argtab["notify"])>>postfile\r
+       printf ("&creation_time=%s",argtab["creation_time"])>>postfile\r
+       printf ("&form_token=%s",argtab["form_token"])>>postfile\r
+       close(postfile)\r
+       \r
+       if(system("wget -q -t 3 --connect-timeout=60 --post-file=" postfile " -U " useragent " -O " tempfile " \""fora "/post\""))\r
+       {\r
+               print "Submit fail."\r
+               exit 1\r
+       }\r
+       \r
+       while((getline temp < tempfile)>0)\r
+       {\r
+               if (temp ~ /<p class=.error/)\r
+               {\r
+                       print temp\r
+                       print "POST IMPOSSIBLE!"\r
+                       exit 2\r
+               }\r
+               if (tolower(temp) ~ /<h2>information/)\r
+               {\r
+                       success=1\r
+               }\r
+       }\r
+       close(tempfile)\r
+       \r
+       if (success!=1)\r
+       {\r
+               print "Sent back to preview!"\r
+               exit INDELIVERABLE\r
+       }\r
+}\r
diff --git a/mpview.c b/mpview.c
new file mode 100644 (file)
index 0000000..45c2cba
--- /dev/null
+++ b/mpview.c
@@ -0,0 +1,137 @@
+// mpview.c (1190.bicyclesonthemoon.info/ct-if-v)\r
+// Display one post\r
+// 17.04.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#include <cgi.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <sys/wait.h>\r
+\r
+// #define RM_PATH "/bin/rm"\r
+#define CAT_PATH "/bin/cat"\r
+#define MAWK_PATH "/usr/bin/mawk"\r
+\r
+#define NP_TOP_PATH "/eizm/www/time/aftertime/bftf/top"\r
+#define NP_END_PATH "/eizm/www/time/aftertime/bftf/end"\r
+#define INFO_PATH "/eizm/www/time/aftertime/bftf/info.htm"\r
+#define POST_PATH "/eizm/mem/ong1/mpost/"\r
+#define WAIT_PATH "/eizm/mem/ong1/mpost/wait/"\r
+\r
+#define AWK_MVIEW "/eizm/pro/ong1/mview.awk"\r
+#define TEMP_PATH "/eizm/tmp/ong1/mpview."\r
+\r
+int main()\r
+{\r
+       s_cgi *cgi;\r
+       pid_t sub;\r
+       int r;\r
+       \r
+       char line[32];\r
+       char filename[32];\r
+       char postpath[256];\r
+       char otherpath[256];\r
+       char cat[8];\r
+       char othercat[8];\r
+       \r
+       char *arg;\r
+       \r
+       FILE *file;\r
+       \r
+       unsigned char fff;\r
+       \r
+       cgi=cgiInit();\r
+       fff=(cgiGetValue(cgi,"fff")!=NULL);\r
+       \r
+       arg=cgiGetValue(cgi,"v");\r
+       sprintf(line,"%s",arg?arg:"???");\r
+       if(line[0]=='c' && line[1]=='t')\r
+       {\r
+               sprintf(filename,"%s",line+2);\r
+               sprintf(cat,"cat=%s","ct");\r
+               sprintf(othercat,"%s","wt");\r
+               sprintf(postpath,"%s%s",POST_PATH,filename);\r
+               sprintf(otherpath,"%s%s",WAIT_PATH,filename);\r
+       }\r
+       else if(line[0]=='w' && line[1]=='t')\r
+       {\r
+               sprintf(filename,"%s",line+2);\r
+               sprintf(cat,"cat=%s","wt");\r
+               sprintf(othercat,"%s","ct");\r
+               sprintf(postpath,"%s%s",WAIT_PATH,filename);\r
+               sprintf(otherpath,"%s%s",POST_PATH,filename);\r
+       }\r
+       else \r
+       {\r
+               printf("Status: 404 - Not found.\n\nNot this.\n");\r
+               return 0;\r
+               // sprintf(filename,"%s","???");\r
+               // sprintf(postpath,"%s","???");\r
+               // sprintf(cat,"cat=%s","???");\r
+       }\r
+       \r
+       file=fopen(postpath,"rt");\r
+       if(file==NULL)\r
+       {\r
+               file=fopen(otherpath,"rt");\r
+               if(file==NULL)\r
+               {\r
+                       printf("Status: 404 - Not found.\n\nNot this.\n");\r
+                       return 0;\r
+               }\r
+               fclose(file);\r
+               sprintf(postpath,"/ct-if-v?v=%s%s%s",othercat,line+2,fff?"&fff=fff":"");\r
+               cgiRedirect(postpath);\r
+               return 0;\r
+       }\r
+       \r
+       fclose(file);\r
+       \r
+       printf("Content-type: text/html\n\n");\r
+       printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n");\r
+       printf("<html lang=\"en\"><head>\n");\r
+       printf("<title>Chronotransponder test interface &bull; Bicycles on the Moon</title>\n");\r
+       printf("<meta http-equiv=\"Content-type\" content=\"text/html; charset=UTF-8\">\n");\r
+       printf("<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n");\r
+       printf("<link rel=\"stylesheet\" href=\"/css/botm.css\">\n");\r
+       printf("<script type=\"text/javascript\" src=\"/ott/prosilver/template/forum_fn.js\"></script>\n");\r
+       printf("</head><body><a href=\"/\"><img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\"></a>\n");\r
+       printf("<h1>Chronotransponder test interface</h1>\n");\r
+       \r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_MVIEW,"-v","bg=1","-v",cat,"-v","s=1",postpath,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       if(r)\r
+       {\r
+               printf("<div id=\"%s\" class=\"post bg1\">\n",line);\r
+               printf("<div class=\"inner\"><span class=\"corners-top\"><span></span></span>\n");\r
+               printf("%s %s POST NOT FOUND.\n",AWK_MVIEW,postpath);\r
+               printf("<span class=\"corners-bottom\"><span></span></span>\n</div></div>\n");\r
+               printf("<hr class=\"divider\"></hr>\n");\r
+       }\r
+       \r
+       printf("<a href=\"/ct-if%s\">back to the chronotrasponder test interface</a><br>\n",fff?"?fff=fff":"");\r
+       printf("<br><a href=\"/\">1190.bicyclesonthemoon.info</a></body></html>\n");\r
+       \r
+       return 0;\r
+}\r
diff --git a/mview.awk b/mview.awk
new file mode 100644 (file)
index 0000000..7f9b713
--- /dev/null
+++ b/mview.awk
@@ -0,0 +1,34 @@
+#// mview.awk\r
+#// Display one post\r
+#// 04.10.2014\r
+#// \r
+#// Copyright (C) 2014  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       FS="="\r
+};\r
+{\r
+       eq=index($0,"=")\r
+       argtab[substr($0,1,eq-1)]=substr($0,eq+1)\r
+};\r
+END{\r
+       \r
+       print "<div id=\""cat argtab["timenumber"]"\" class=\"pl\">"\r
+       print "<div class=\"pls\">"argtab["subject_h"]"</div>"\r
+       print "<div class=\"plt\">author: <b>"argtab["username_h"]"</b> &bull; sent: <b>"argtab["timetext"]"</b> &bull; received: <b>"argtab["d"]"."argtab["m"]"."argtab["y"]"</b> <div class=\"pr\"><a class=\"bi\" href=\"/ct-if-p?q="cat argtab["timenumber"](fff!=""?"&amp;fff=fff":"")"\">quote</a> <a class=\"bi\" href=\"/ct-if-r?r="cat argtab["timenumber"](fff!=""?"&amp;fff=fff":"")"\">remove</a> </div></div>"\r
+       print "<div class=\"plw\">"((argtab["HTML"]!="")?argtab["HTML"]:argtab["BBHTML"])"</div>"\r
+       print "</div>"\r
+}\r
diff --git a/npb.cpp b/npb.cpp
new file mode 100644 (file)
index 0000000..8e9ccd1
--- /dev/null
+++ b/npb.cpp
@@ -0,0 +1,237 @@
+// npb.cpp
+// NewpixbOTTification - The tool to add newpixbots to pictures
+// 16.01.2015
+// 
+// Copyright (C) 2013  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 <http://www.gnu.org/licenses/>.
+// 
+
+// Requires Dev Image Library (libdevil) (http://openil.sourceforge.net/)
+// on Pentium III libdevil must be recompiled with
+// --disable-ssl2 --disable-ssl3
+// (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572954)
+
+#define INPIX_MUSTARD 1
+#define OUTPIX_MUSTARD 2
+#define NPBPIX_MUSTARD 3
+#define ARGUMENT_MUSTARD 4
+#define SEAISH_MUSTARD 5
+#define ANIMATED_MUSTARD 6
+#define FAIL 900
+#define OK 0
+
+#define NPBPIX2 "/eizm/mem/ong1/npb.png"
+#define X2  311
+#define X21 210
+#define Y2  475
+#define Y21 407
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <IL/il.h>
+
+void mustard(int mustard);
+void loadnpb(const char *path);
+void npbottify0(const char *path);
+void npbottify1(const char *path);
+void npbottify2(const char *path);
+int main (int argc, const char *argv[]);
+
+ILuint inPix, outPix, npbPix;
+ILboolean q=true;
+ILboolean inH=false;
+ILboolean outH=false;
+ILboolean npbH=false;
+ILuint inX, inY, outX, outY;
+ILubyte *newdata;
+
+int main (int argc, const char *argv[])
+{
+       if(argc<3)
+               mustard(ARGUMENT_MUSTARD);
+       if (argc>=4)
+       {
+               if (argv[3][0]=='q' || argv[3][0]=='Q')
+                       q=false;
+       }
+       
+       ilInit();
+       if(!ilEnable(IL_ORIGIN_SET))mustard(FAIL);
+       if(!ilEnable(IL_FILE_OVERWRITE))mustard(FAIL);
+       ilClearColour(255,255,0,0);
+       ilGenImages(1, &inPix);
+       inH=true;
+       ilBindImage(inPix);
+       if(!ilLoadImage(argv[1]))mustard(INPIX_MUSTARD);
+       if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(INPIX_MUSTARD);
+       //if(!ilConvertPal(IL_PAL_RGBA32))mustard(FAIL);
+       
+       inX=ilGetInteger(IL_IMAGE_WIDTH);
+       inY=ilGetInteger(IL_IMAGE_HEIGHT);
+       if(ilGetInteger(IL_NUM_IMAGES)>1)
+               mustard(ANIMATED_MUSTARD);
+       
+       // if(inX<=X02&&inY<=Y02)
+               // npbottify0(argv[2]);
+       // else if(inX<=X12&&inY<=Y12)
+               // npbottify1(argv[2]);
+       else
+               npbottify2(argv[2]);    
+       //ok
+       mustard(0);
+}
+
+void loadnpb(const char *path)
+{
+       ilGenImages(1, &npbPix);
+       npbH=true;
+       ilBindImage(npbPix);
+       if(!ilLoadImage(path))mustard(NPBPIX_MUSTARD);
+       if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(NPBPIX_MUSTARD);
+ }
+
+void npbottify2(const char *path)
+{
+       unsigned long i,j;
+       outX=(X21+inX+2>X2)?(X21+inX+2):X2;
+       outY=(Y21+inY+2>Y2)?(Y21+inY+2):Y2;
+       ilGenImages(1, &outPix);
+       outH=true;
+       loadnpb(NPBPIX2);
+       newdata=ilGetData();
+       ilBindImage(outPix);
+       if(!ilTexImage(outX,outY,1,4,IL_RGBA,IL_UNSIGNED_BYTE,NULL))mustard(OUTPIX_MUSTARD);
+       if(!ilClearImage())mustard(FAIL);
+       ilSetPixels(outX-X2,0,0,X2,Y2,1,IL_RGBA,IL_UNSIGNED_BYTE,newdata);
+       newdata=ilGetData();
+       for(i=outX-X21-inX-2;i<outX-X21+2;++i)
+       {
+               //printf("i=%lu\n",i);
+               for(j=Y21-2;j<Y21+inY+2;++j)
+               {
+                       //printf("i=%lu j=%lu\n",i,j);
+                       if((i==outX-X21-inX-2)||(i==outX-X21-inX-1)||
+                          (i==outX-X21    +1)||(i==outX-X21      )||
+                          (j==     Y21    -2)||(j==     Y21    -1)||
+                          (j==     Y21+inY+1)||(j==     Y21+inY  ))
+                       {
+                               newdata[4*(i+outX*j)+0]=0x00;
+                               newdata[4*(i+outX*j)+1]=0x00;
+                               newdata[4*(i+outX*j)+2]=0x00;
+                               newdata[4*(i+outX*j)+3]=0xFF;   
+                       }
+                       else
+                       {
+                               newdata[4*(i+outX*j)+0]=0xFF;
+                               newdata[4*(i+outX*j)+1]=0xFF;
+                               newdata[4*(i+outX*j)+2]=0xFF;
+                               newdata[4*(i+outX*j)+3]=0xFF;
+                       }
+               }
+       }
+       
+       if(!ilOverlayImage(inPix,outX-X21-inX,outY-Y21-inY,0))mustard(FAIL);
+       
+       // i=outX-X21-inX-2;
+       // j=Y21-2;
+       // newdata[4*(i+outX*j)+0]=0x00;
+       // newdata[4*(i+outX*j)+1]=0x00;
+       // newdata[4*(i+outX*j)+2]=0x00;
+       // newdata[4*(i+outX*j)+3]=0x00;   
+       // j=Y21+inY+1;
+       // newdata[4*(i+outX*j)+0]=0x00;
+       // newdata[4*(i+outX*j)+1]=0x00;
+       // newdata[4*(i+outX*j)+2]=0x00;
+       // newdata[4*(i+outX*j)+3]=0x00;   
+       // i=outX-X21+1;
+       // newdata[4*(i+outX*j)+0]=0x00;
+       // newdata[4*(i+outX*j)+1]=0x00;
+       // newdata[4*(i+outX*j)+2]=0x00;
+       // newdata[4*(i+outX*j)+3]=0x00;   
+       // j=Y21-2;
+       // newdata[4*(i+outX*j)+0]=0x00;
+       // newdata[4*(i+outX*j)+1]=0x00;
+       // newdata[4*(i+outX*j)+2]=0x00;
+       // newdata[4*(i+outX*j)+3]=0x00;   
+       
+       // i=outX-X21-inX;
+       // j=Y21;
+       // newdata[4*(i+outX*j)+0]=0x00;
+       // newdata[4*(i+outX*j)+1]=0x00;
+       // newdata[4*(i+outX*j)+2]=0x00;
+       // newdata[4*(i+outX*j)+3]=0xFF;   
+       // j=Y21+inY-1;
+       // newdata[4*(i+outX*j)+0]=0x00;
+       // newdata[4*(i+outX*j)+1]=0x00;
+       // newdata[4*(i+outX*j)+2]=0x00;
+       // newdata[4*(i+outX*j)+3]=0xFF;   
+       // i=outX-X21-1;
+       // newdata[4*(i+outX*j)+0]=0x00;
+       // newdata[4*(i+outX*j)+1]=0x00;
+       // newdata[4*(i+outX*j)+2]=0x00;
+       // newdata[4*(i+outX*j)+3]=0xFF;   
+       // j=Y21;
+       // newdata[4*(i+outX*j)+0]=0x00;
+       // newdata[4*(i+outX*j)+1]=0x00;
+       // newdata[4*(i+outX*j)+2]=0x00;
+       // newdata[4*(i+outX*j)+3]=0xFF;
+       
+       ilGenImages(1, &npbPix);
+       npbH=true;
+       ilBindImage(npbPix);
+       if(!ilLoadImage(NPBPIX2))mustard(NPBPIX_MUSTARD);
+       if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(NPBPIX_MUSTARD);
+       ilBindImage(outPix);
+       if(!ilOverlayImage(npbPix,outX-X2,outY-Y2,0))mustard(FAIL);
+       //ilSetPixels(outX-X2,0,0,X2,Y2,1,IL_RGBA,IL_UNSIGNED_BYTE,newdata);
+       
+       if(!ilSave(IL_PNG,path))mustard(OUTPIX_MUSTARD);
+
+       
+}
+
+void mustard(int mustard)
+{
+       switch(mustard)
+       {
+       case 0:
+               if(q) printf("NewpixbOTTified!\n");break;
+       case ARGUMENT_MUSTARD:
+               if(q) printf("npb inPix outPix [q]\n");break;
+       case INPIX_MUSTARD:
+               if(q) printf("inPIX mustard.\n");break;
+       case OUTPIX_MUSTARD:
+               if(q) printf("outPIX mustard.\n");break;
+       case NPBPIX_MUSTARD:
+               if(q) printf("npbPIX mustard.\n");break;
+       case SEAISH_MUSTARD:
+               if(q) printf("Seaishness is mustard.\n");break;
+       case ANIMATED_MUSTARD:
+               if(q) printf("Animation is mustard.\n");break;
+       default:
+               if (q) printf("Ch*rpin* mustard mustaard!\n");
+       }
+       if(inH)
+               ilDeleteImages(1, &inPix);
+       if(outH)
+       {
+               ilDeleteImages(1, &outPix);
+               //delete[] newdata;
+       }
+       if(npbH)
+               ilDeleteImages(1, &npbPix);
+       exit(mustard);
+}
+       
diff --git a/npbd.cpp b/npbd.cpp
new file mode 100644 (file)
index 0000000..98a1dd8
--- /dev/null
+++ b/npbd.cpp
@@ -0,0 +1,149 @@
+// npbd.cpp - copied from the original NewpixbOTTification but not actually used
+// The online interface for the NewpixbOTTification and 403fication software
+// 16.01.2015
+// 
+// Copyright (C) 2014  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 <http://www.gnu.org/licenses/>.
+// 
+
+// Requires cgilib (http://www.infodrom.org/projects/cgilib/)
+// line 146 of cgi.h must be changed from:
+// extern }
+// to:
+// }
+
+#include <cgi.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+
+#define WGET_PATH  "/usr/bin/wget"
+#define NPB_PATH   "/eizm/pro/ong1/npb"
+#define MEG_PATH   "./403"
+#define RM_PATH    "/bin/rm"
+#define LOG_PATH   "/eizm/log/npb/npb.log"
+#define LOG_PATH2  "/eizm/log/npb/403.log"
+#define USERAGENT  "NewpixbOTTification\x20(1190.bicyclesonthemoon.dnsd.info/npb/npb.htm)"
+#define USERAGENT2 "403fication\x20(1190.bicyclesonthemoon.dnsd.info/npb/403.htm)"
+#define MSTD_PATH  "/pro/npb/mpb.png"
+#define MSTD_PATH2 "/pro/npb/503.png"
+
+int main (int argc, char *argv[]);
+void mustard(int mustard);
+
+FILE *pix;
+unsigned char buf[1024];
+char url[1024];
+char path[256];
+char method[256];
+s_cgi *cgi;
+int t;
+pid_t sub;
+struct stat st;
+unsigned long p;
+unsigned short q;
+char **up;
+bool meg=false;
+
+int main (int argc, char *argv[])
+{
+       cgi=cgiInit();
+       
+       sprintf(path,"%s",(getenv("PATH_INFO")!=NULL)?(getenv("PATH_INFO")):"");
+       if(strcmp(path,"/403")==0)
+       {
+               meg=true;
+               //mustard(0);
+       }
+       
+       up=cgiGetFiles(cgi);
+       if (up)
+       {
+               sprintf(path,"%s",cgiGetFile(cgi,up[0])->tmpfile);
+               sprintf(url,"%s",cgiGetFile(cgi,up[0])->filename);
+       }
+       else
+       {
+               sprintf(url,"%s",(cgiGetValue(cgi,"inpix")!=NULL)?(cgiGetValue(cgi,"inpix")):"");
+               sprintf(path,"/var/tmp/%lu",(unsigned long)getpid());
+               
+               //Why is  there no spawnl() in linux?
+               sub=fork();
+               if(sub==0)
+               {
+                       t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",meg?USERAGENT2:USERAGENT,"-O",path,url,(char *)0);
+                       exit(t);
+               }
+               waitpid(sub,&t,0);
+               if(t)mustard(t);
+       }
+       
+       sub=fork();
+       if(sub==0)
+       {
+               t=execl(meg?MEG_PATH:NPB_PATH,meg?MEG_PATH:NPB_PATH,path,path,"q",(char *)0);
+               exit(t);
+       }
+       waitpid(sub,&t,0);
+       if(t)mustard(t);
+       
+       pix=fopen(path,"rb");
+       if(pix==NULL)
+               mustard(123);
+       fstat(fileno(pix),&st);
+       p=st.st_size/1024;
+       q=st.st_size%1024;
+       
+       printf("Content-Length: %lu\n",(unsigned long)(st.st_size));
+       printf("Content-type: image/png\n\n");
+       for(unsigned long i=0;i<p;++i)
+       {
+               fread(buf,1,1024,pix);
+               fwrite(buf,1,1024,stdout);
+       }
+       if(q!=0)
+       {
+               fread(buf,1,q,pix);
+               fwrite(buf,1,q,stdout);
+       }
+       fclose(pix);
+       fflush(stdout);
+       mustard(0);//no mustard
+}
+
+void mustard(int mustard)
+{
+       if(mustard)
+       {
+               cgiRedirect(meg?MSTD_PATH2:MSTD_PATH);
+       }
+       sub=fork();
+       if(sub==0)
+       {
+               t=execl(RM_PATH,RM_PATH,"-f",path,(char *)0);
+               exit(t);
+       }
+       waitpid(sub,&t,0);
+       // pix=fopen(meg?LOG_PATH2:LOG_PATH,"at");
+       // if(pix!=NULL)
+       // {
+               // fprintf(pix,"%x %s\n",mustard,url);
+               // fclose(pix);
+       // }
+       exit(mustard);
+}
\ No newline at end of file
diff --git a/ogdfparse.awk b/ogdfparse.awk
new file mode 100644 (file)
index 0000000..99290c0
--- /dev/null
@@ -0,0 +1,182 @@
+#// ogdfparse.awk\r
+#// the object generator definition file "parser"\r
+#// 13.03.2015\r
+#// \r
+#// Copyright (C) 2015  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       basepath="/eizm/mem/ong1"\r
+       linenum=0\r
+       depth=0\r
+       nonstandard=0\r
+       external=0\r
+       toplevel=0\r
+       iflevel=0\r
+       limit=65536\r
+       if(int(q)<0)\r
+               fail("fatal error.")\r
+}\r
+{\r
+       ++linenum\r
+       gsub(/[\r\n]/,"",$0)\r
+       gsub(/(^[ \t]+)|([ \t]+$)/,"",$0)\r
+       gsub(/#.*$/,"",$0)\r
+       # print "   "linenum "\t"$0\r
+       \r
+       if($0 == "")\r
+               next\r
+       if($0 == "{")\r
+       {\r
+               ++depth\r
+               next\r
+       }\r
+       if($0 == "}")\r
+       {\r
+               if(depth==0)\r
+                       fail("syntax error.")\r
+               --depth\r
+               next\r
+       }\r
+       if($0 ~ /^!/)\r
+       {\r
+               narg=split($0, aarg, /[ \t]+/)\r
+               if(narg!=2)\r
+                       fail("syntax error.")\r
+               if(aarg[1]=="!ifenabled")\r
+               {\r
+                       ++iflevel\r
+               }\r
+               if(aarg[1]=="!endif")\r
+               {\r
+                       if (iflevel==0)\r
+                               fail("unmatched endif.")\r
+                       --iflevel\r
+               }\r
+               if(aarg[1]=="!enable")\r
+               {\r
+                       if (aarg[2]=="NONSTANDARD_1419")\r
+                       {\r
+                               nonstandard=1\r
+                               limit=256\r
+                               next\r
+                       }\r
+                       if (aarg[2]=="EXTERNAL_DEFINITIONS" && nonstandard!=0)\r
+                       {\r
+                               external=1\r
+                               next\r
+                       }\r
+                       if (aarg[2]=="LIMIT_8BIT" && nonstandard!=0)\r
+                       {\r
+                               limit=256\r
+                               next\r
+                       }\r
+                       fail(aarg[2]" undefined.")\r
+               }\r
+               if(aarg[1]=="!disable")\r
+               {\r
+                       if (aarg[2]=="NONSTANDARD_1419")\r
+                       {\r
+                               nonstandard=0\r
+                               limit=65536\r
+                               external=0\r
+                               next\r
+                       }\r
+                       if (aarg[2]=="EXTERNAL_DEFINITIONS" && nonstandard!=0)\r
+                       {\r
+                               external=0\r
+                               next\r
+                       }\r
+                       if (aarg[2]=="LIMIT_8BIT" && nonstandard!=0)\r
+                       {\r
+                               limit=65536\r
+                               next\r
+                       }\r
+                       fail(aarg[2]" undefined.")\r
+               }\r
+               fail(aarg[1]" undefined.")\r
+       }\r
+       if($0 ~ /^[A-Za-z][A-Za-z0-9_]*\([^\(\)]*\)$/)\r
+       {\r
+               narg=split($0, aarg, /[\(\)]/)\r
+               if(aarg[narg]=="")\r
+                       --narg\r
+               if(depth==0)\r
+                       fail(aarg[1]" not allowed here.")\r
+               if(aarg[1]=="insertRelative"&&external!=0)\r
+                       fail(aarg[1]" not allowed here.")\r
+               if(aarg[1]=="topLevelReplace"&&external!=0)\r
+               {\r
+                       if(depth!=1)\r
+                               fail(aarg[1]" not allowed here.")\r
+                       nbarg=split(aarg[2],barg,/,/)\r
+                       if(nbarg!=2)\r
+                               fail(aarg[1]" wrong number of arguments.")\r
+                       if(barg[1] !~ /^[A-Za-z][A-Za-z0-9_]*$/ || barg[1] ~ /(NONSTANDARD_1419)|(EXTERNAL_DEFINITIONS)|(topLevelReplace)/)\r
+                               fail(barg[1]" wrong type.")\r
+                       if(barg[1] != "E")\r
+                               fail(barg[1]" undefined.")\r
+                       if(barg[2] !~ /^\"[^\"]*\"$/)\r
+                       #\""\r
+                               fail(barg[2]" wrong type.")\r
+                       argpath=substr(barg[2],2,length(barg[2])-2)\r
+                       fullpath=basepath argpath\r
+                       if(getline line < fullpath)\r
+                       {\r
+                               close(fullpath)\r
+                               if(line=="")\r
+                                       fail(argpath" cannot read.")\r
+                               if(line !~/^###generator&/)\r
+                                       fail(argpath" 1: syntax error.")\r
+                               sub(/^###generator&/,"",line)\r
+                               obname=line\r
+                               toplevel=1\r
+                               next\r
+                       }\r
+                       fail(argpath " cannot read.")\r
+               }\r
+               fail(aarg[1]" undefined.")\r
+       }\r
+       fail("syntax error.")\r
+}\r
+END{\r
+       if (ex!="")\r
+               exit\r
+       if(depth!=0)\r
+               fail("syntax error.")\r
+       if(iflevel!=0)\r
+               fail("unmatched endif")\r
+       if(toplevel==0)\r
+               fail("top level undefined.")\r
+       success(obname, int(q))\r
+}\r
+function fail(error)\r
+{\r
+       t=ogdf_name" "linenum": "error\r
+       print t\r
+       print "  "t >> logf\r
+       close(logf)\r
+       ex=1\r
+       exit\r
+}\r
+function success(name, q)\r
+{\r
+       t=q%limit " item(s) of: \""name"\" added to generation queue."\r
+       print t\r
+       print "  "t >> logf\r
+       close(logf)\r
+       ex=1\r
+       exit\r
+}\r
diff --git a/ong.c b/ong.c
new file mode 100644 (file)
index 0000000..f611dc7
--- /dev/null
+++ b/ong.c
@@ -0,0 +1,102 @@
+// ong.c\r
+// The bot to ONG new frames to the viewer.\r
+// 17.04.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define ONG_STATE_PATH "/eizm/data/aftertime/bftf/ongstate"\r
+#define BOT4_PATH      "/eizm/pro/ong1/bot4"\r
+#define MAX_FRAME      786 // na razie tyle\r
+#define FRAME_PRINTF   "/eizm/data/aftertime/bftf/%hu.png"\r
+#define ONGED_PRINTF   "/eizm/www/time/aftertime/bftf/bftf-%04hu.png"\r
+#define NPBFIED_PRINTF "/eizm/www/time/aftertime/bftf/npbftf-%04hu.png"\r
+#define CP_PATH        "/bin/cp"\r
+#define NPB_PATH       "/eizm/pro/ong1/npb"\r
+\r
+#include <stdio.h>\r
+#include <unistd.h>\r
+#include <stdlib.h>\r
+#include <sys/wait.h>\r
+\r
+pid_t sub;\r
+int r;\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+       FILE *file;\r
+       unsigned short ongFrame;\r
+       unsigned char ongState;\r
+       char framePath[64];\r
+       char ongedPath[64];\r
+       char npbfiedPath[64];\r
+       \r
+       file=fopen(ONG_STATE_PATH,"rt");\r
+       if(file!=NULL)\r
+       {\r
+               fscanf(file,"%hhu %hu",&ongState,&ongFrame);\r
+               fclose(file);\r
+       }\r
+       else\r
+       {\r
+               ongState=0;\r
+               ongFrame=0;\r
+       }\r
+       \r
+       if(ongState==2&&ongFrame<MAX_FRAME)\r
+       {\r
+               ++ongFrame;\r
+               sprintf(framePath,FRAME_PRINTF,ongFrame);\r
+               sprintf(ongedPath,ONGED_PRINTF,ongFrame);\r
+               sprintf(npbfiedPath,NPBFIED_PRINTF,ongFrame);\r
+               \r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(NPB_PATH,NPB_PATH,framePath,npbfiedPath,"q",(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               if(r)\r
+                       return r;\r
+               \r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(CP_PATH,CP_PATH,framePath,ongedPath,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               if(r)\r
+                       return r;\r
+               \r
+               file=fopen(ONG_STATE_PATH,"wt");\r
+               if(file!=NULL)\r
+               {\r
+                       fprintf(file,"1 %hu",ongFrame);\r
+                       fclose(file);\r
+               }\r
+               sprintf(framePath,"-o%hu",ongFrame-1);\r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(BOT4_PATH,BOT4_PATH,framePath,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+       }\r
+       \r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/ongoing.awk b/ongoing.awk
new file mode 100755 (executable)
index 0000000..6adb904
--- /dev/null
@@ -0,0 +1,9 @@
+#! /usr/bin/mawk -f
+#ongoing.awk (1190.bicyclesonthemoon.info/ongoing.txt)
+#display ongoing.txt
+#17.04.2015
+BEGIN{
+       print"Content-type: text\n"
+       system ("/bin/cat /eizm/data/aftertime/bftf/ongstate")
+       # system ("/bin/cat /eizm/pro/ong1/makefile")
+}
diff --git a/ongtext.awk b/ongtext.awk
new file mode 100644 (file)
index 0000000..a0d7ffe
--- /dev/null
@@ -0,0 +1,215 @@
+#// ongtext.awk\r
+#// ONGification from the ONGtext generator\r
+#// 13.10.2014\r
+#// \r
+#// Copyright (C) 2015  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       automome="/eizm/pro/ong1/mome.pl"\r
+       memepath="/eizm/mem/ong1/mome.txt"\r
+       \r
+       for(i=0;i<256;++i)\r
+       {\r
+               ch=sprintf("%c",i)\r
+               hex=sprintf("%02X",i)\r
+               dec=sprintf("%u",i)\r
+               ch2hex[ch]=hex\r
+               ch2dec[ch]=dec\r
+       }\r
+       \r
+       if(options ~ /o/)\r
+               format="o"\r
+       else if(options ~ /u/)\r
+               format="u"\r
+       else\r
+       {\r
+               print "Ch*rpin* M*stard!"\r
+               exit\r
+       }\r
+       if(options ~ /d/)\r
+               decree=1\r
+       if(options ~ /h/)\r
+               html=1\r
+       if(options ~ /b/)\r
+               bbcode=1\r
+       if(options ~ /t/)\r
+               textonly=1\r
+       \r
+       system (automome" -lc 256 -n 67 -d "memepath(decree!=""?" -t \"[decr]\"":"")" > "tempfile)\r
+       if (format=="o")\r
+               ongtext=ong(tempfile)\r
+       else\r
+               ongtext=ung(tempfile)\r
+       if(html!="")\r
+               print (textonly==""?"<span class=\"br\">":"")preparehtml(ongtext)(textonly==""?"</span><br>":"")\r
+       if(bbcode!="")\r
+               print (textonly==""?"<code>":"")preparebb(ongtext)(textonly==""?"</code><br>":"")\r
+       \r
+       if(html=="" && bbcode=="")\r
+               print (textonly==""?"<code>"htmlescape(ongtext)"</code><br>":ongtext)\r
+       \r
+}\r
+function ong(tempfile,   line)\r
+{\r
+       while((getline line < tempfile)>0)\r
+       {\r
+               gsub(/[\r\n]/,"",line)\r
+               if(sub(/[AEIOUY]-N-G/,"#O-N-G#",line)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+               if(sub(/O+N+G+/,"#&#",line)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+               if(sub(/DON'T/,"D#ON'G#T",line)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+               if(sub(/[AEIOUY]NG/,"#ONG#",line)>0)\r
+               {\r
+                       if($0!~/TH\[b\]ONG/)\r
+                               return line\r
+               }\r
+               if(sub(/ON /,"#ONG# ",line)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+               if(sub(/O\.?$/,"#ONG# ",$0)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+       }\r
+       close(tempfile)\r
+       return "Ong"\r
+}\r
+\r
+function ung(tempfile,   line)\r
+{\r
+       while((getline line < tempfile)>0)\r
+       {\r
+               gsub(/[\r\n]/,"",line)\r
+               if(sub(/[AEIOUY]-N-G/,"#U-N-G#",line)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+               if(sub(/U+N+G+/,"#&#",line)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+               if(sub(/[AEIOUY]NG/,"#UNG#",line)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+               if(sub(/UN /,"#UNG# ",line)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+               if(sub(/U\.?$/,"#UNG# ",$0)>0)\r
+               {\r
+                       close(tempfile)\r
+                       return line\r
+               }\r
+       }\r
+       close(tempfile)\r
+       return "Ung"\r
+}\r
+\r
+function preparebb(rh)\r
+{\r
+       gsub(/\*\*/,"¤",rh)\r
+       gsub(/\*[^\*]+\*/,"±&±",rh)\r
+       gsub(/±\*/,"[i]",rh)\r
+       gsub(/\*±/,"[/i]",rh)\r
+       gsub(/¤/,"*",rh)\r
+       \r
+       gsub(/__/,"¤",rh)\r
+       gsub(/_[^_]+_/,"±&±",rh)\r
+       gsub(/±_/,"[u]",rh)\r
+       gsub(/_±/,"[/u]",rh)\r
+       gsub(/¤/,"_",rh)\r
+       \r
+       gsub(/##/,"¤",rh)\r
+       gsub(/#[^#]+#/,"±&±",rh)\r
+       gsub(/±#/,"[b]",rh)\r
+       gsub(/#±/,"[/b]",rh)\r
+       gsub(/¤/,"#",rh)\r
+       \r
+       gsub(/\$\$/,"¤",rh)\r
+       gsub(/\$[^\$]+\$/,"±&±",rh)\r
+       gsub(/±\$/,"[size=80]",rh)\r
+       gsub(/\$±/,"[/size]",rh)\r
+       gsub(/¤/,"$",rh)\r
+       \r
+       return (textonly==""?htmlescape(rh):rh)\r
+}\r
+\r
+function preparehtml(rh)\r
+{\r
+       gsub(/\*\*/,"¤",rh)\r
+       gsub(/\*[^\*]+\*/,"±&±",rh)\r
+       gsub(/±\*/,"«i»",rh)\r
+       gsub(/\*±/,"«/i»",rh)\r
+       gsub(/¤/,"*",rh)\r
+       \r
+       gsub(/__/,"¤",rh)\r
+       gsub(/_[^_]+_/,"±&±",rh)\r
+       gsub(/±_/,"«u»",rh)\r
+       gsub(/_±/,"«/u»",rh)\r
+       gsub(/¤/,"_",rh)\r
+       \r
+       gsub(/##/,"¤",rh)\r
+       gsub(/#[^#]+#/,"±&±",rh)\r
+       gsub(/±#/,"«b»",rh)\r
+       gsub(/#±/,"«/b»",rh)\r
+       gsub(/¤/,"#",rh)\r
+       \r
+       gsub(/\$\$/,"¤",rh)\r
+       gsub(/\$[^\$]+\$/,"±&±",rh)\r
+       gsub(/±\$/,"«span style=\"font-size: 80%;\"»",rh)\r
+       gsub(/\$±/,"«/span»",rh)\r
+       gsub(/¤/,"$",rh)\r
+       \r
+       rh = htmlescape(rh)\r
+       gsub(/«/,"<",rh)\r
+       gsub(/»/,">",rh)\r
+       \r
+       return rh\r
+}\r
+\r
+function htmlescape(name,less,br,   len,iii,escaped,ch)\r
+{\r
+       len=length(name)\r
+       escaped=""\r
+       for(iii=1;iii<=len;++iii)\r
+       {\r
+               ch=substr(name,iii,1);\r
+               if(ch ~ /[=<>&#\r\n\"]/)\r
+                       escaped = escaped "&#"ch2dec[ch]";"\r
+               else\r
+                       escaped = escaped ch\r
+       }\r
+       return escaped\r
+}\r
diff --git a/ongtext.c b/ongtext.c
new file mode 100644 (file)
index 0000000..899993e
--- /dev/null
+++ b/ongtext.c
@@ -0,0 +1,136 @@
+// ongtext.c (1190.bicyclesonthemoon.info/ongtext)\r
+// ONGtext generator\r
+// 31.01.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#include <cgi.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <sys/wait.h>\r
+\r
+#define MAWK_PATH "/usr/bin/mawk"\r
+#define AWK_ONGTEXT "/eizm/pro/ong1/ongtext.awk"\r
+#define TEMP_PATH "/eizm/tmp/ong1/ongtext."\r
+#define RM_PATH "/bin/rm"\r
+\r
+int main (int argc, char **argv)\r
+{\r
+       s_cgi *cgi;\r
+       pid_t sub;\r
+       int r;\r
+       \r
+       char *value;\r
+       \r
+       unsigned char format=0;\r
+       unsigned char decree=0;\r
+       unsigned char output=0;\r
+       unsigned char nohtml=0;\r
+       \r
+       char options[16];\r
+       char temppath[247];\r
+       char temppath2[256];\r
+       \r
+       setvbuf(stdout, NULL, _IONBF, 0);\r
+       dup2(fileno(stdout),fileno(stderr));\r
+       \r
+       cgi=cgiInit();\r
+       \r
+       sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid());\r
+       sprintf(temppath2,"tempfile=%s",temppath);\r
+       \r
+       if((value=cgiGetValue(cgi,"f"))!=NULL)\r
+       {\r
+               switch(value[0])\r
+               {\r
+               case 'o':\r
+                       format = 1;\r
+                       break;\r
+               case 'u':\r
+                       format = 2;\r
+                       break;\r
+               }\r
+       }\r
+       \r
+       if(cgiGetValue(cgi,"d")!=NULL)\r
+               decree=1;\r
+       \r
+       if(cgiGetValue(cgi,"b")!=NULL)\r
+               output|=1;\r
+       if(cgiGetValue(cgi,"h")!=NULL)\r
+               output|=2;\r
+       if(cgiGetValue(cgi,"t")!=NULL)\r
+               nohtml=1;\r
+       \r
+       sprintf(options,"options=%s%s%s%s%s",format!=0?(format==1?"o":"u"):"",decree!=0?"d":"",(output&2)!=0?"h":"",(output&1)!=0?"b":"",nohtml!=0?"t":"");\r
+       \r
+       if(nohtml==0)\r
+       {\r
+               fputs("Content-type: text/html\n\n",stdout);\r
+               fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n",stdout);\r
+               fputs("<html lang=\"en\"><head>\n",stdout);\r
+               fputs("<title>ONGtext generator &bull; Bicycles on the Moon</title>\n",stdout);\r
+               fputs("<meta http-equiv=\"Content-type\" content=\"text/html; charset=UTF-8\">\n",stdout);\r
+               fputs("<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n",stdout);\r
+               fputs("<link rel=\"stylesheet\" href=\"/css/botm.css\">\n",stdout);\r
+               fputs("</head><body><a href=\"/\"><img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\"></a>\n",stdout);\r
+               fputs("<h1>ONGtext generator</h1>\n",stdout);\r
+       }\r
+       else\r
+               fputs("Content-type: text\n\n",stdout);\r
+       if(format!=0)\r
+       {\r
+               sub=fork();\r
+               if(sub==0)\r
+               {\r
+                       r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_ONGTEXT,"-v",options,"-v",temppath2,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               \r
+               sub=fork();\r
+               if(sub==0)\r
+               {\r
+                       r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+       }\r
+       \r
+       if(nohtml==0)\r
+       {\r
+               \r
+               fputs("<br>With the help of mrob27's <a href=\"http://mrob.com/time/automome\">automome</a>.<br>",stdout);\r
+               fputs("<form method=\"get\" action=\"/ongtext\">\n",stdout);\r
+               fputs("<br>\n",stdout);\r
+               fprintf(stdout,"<input type=\"radio\" class=\"pt\" name=\"f\" value=\"o\"%s>ONG<br>\n",format!=2?" checked":"");\r
+               fprintf(stdout,"<input type=\"radio\" class=\"pt\" name=\"f\" value=\"u\"%s>UNG<br>\n",format==2?" checked":"");\r
+               fputs("<br>\n",stdout);\r
+               fprintf(stdout,"<input type=\"checkbox\" class=\"pt\" name=\"d\"%s>decree<br>\n",decree!=0?" checked":"");\r
+               fputs("<br>\n",stdout);\r
+               fprintf(stdout,"<input type=\"checkbox\" class=\"pt\" name=\"h\"%s>HTML<br>\n",(output&2)!=0?" checked":"");\r
+               fprintf(stdout,"<input type=\"checkbox\" class=\"pt\" name=\"b\"%s>BBcode<br>\n",(output&1)!=0?" checked":"");\r
+               fputs("<br>\n",stdout);\r
+               fputs("<input type=\"checkbox\" class=\"pt\" name=\"t\">text only<br>\n",stdout);\r
+               fputs("<br>\n",stdout); \r
+               fputs("<input type=\"submit\" class=\"pk\" value=\"Generate\">\n",stdout);\r
+               fputs("</form><br>\n",stdout);\r
+               fputs("<a href=\"/ongtextsrc/\">source</a><br><br>\n",stdout);\r
+               fputs("<a href=\"/\">1190.bicyclesonthemoon.info</a></body></html>\n",stdout);\r
+       }\r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/pleaseong.c b/pleaseong.c
new file mode 100644 (file)
index 0000000..5379e77
--- /dev/null
@@ -0,0 +1,47 @@
+// pleaseong.c (1190.bicyclesonthemoon.info/ongoing/pleaseongthis)\r
+// Ask the bot to post the frame\r
+// 23.01.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define BOT_PATH "/eizm/pro/ong1/bot4"\r
+\r
+#include <cgi.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <sys/wait.h>\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+       s_cgi *cgi;\r
+       pid_t sub;\r
+       int r;\r
+       \r
+       cgi=cgiInit();\r
+       printf("Content-type: text\n\n");\r
+       \r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               r=execl(BOT_PATH,BOT_PATH,"-t"/**/,"-r"/**/,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       \r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/post.awk b/post.awk
new file mode 100644 (file)
index 0000000..2de88e5
--- /dev/null
+++ b/post.awk
@@ -0,0 +1,304 @@
+#// post.awk\r
+#// The tool to post to the OTT\r
+#// 23.03.2015\r
+#// \r
+#// Copyright (C) 2015  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       FS="="\r
+       fora="http://forums.xkcd.com"\r
+       useragent="\"bothasar_p (http://1190.bicyclesonthemoon.info/ongoing.htm; BFTF post bot)\""\r
+       timecmd="date -u +\"%d %b %Y, %k:%M UTC\""\r
+       \r
+       for(i=0;i<256;++i)\r
+       {\r
+               ch=sprintf("%c",i)\r
+               hex=sprintf("%02X",i);\r
+               ch2hex[ch]=hex\r
+               hex2ch[hex]=ch\r
+       }\r
+};\r
+{\r
+       eq=index($0,"=")\r
+       argtab[substr($0,1,eq-1)]=substr($0,eq+1)\r
+};\r
+END{\r
+       if(entitydecode(user)!=urldecode(argtab["username"]))\r
+               edit=""\r
+       \r
+       if(system("wget -q -t 3 --connect-timeout=60 --save-cookies=" cookiefile " -U " useragent " -O " tempfile " " fora "/ucp.php?mode=login"))\r
+       {\r
+               print "Pre-login fail."\r
+               exit 1\r
+       }\r
+       while((getline cookie < cookiefile)>0)\r
+       {\r
+               if(cookie ~ /_sid/)\r
+               {\r
+                       split(cookie,arr,"_sid[ \t]*")\r
+                       SID=arr[2]\r
+               }\r
+       }\r
+       close(cookiefile)\r
+       print "username=" argtab["username"] "&password=" argtab["password"] "&sid=" SID "&login=Login" > postfile\r
+       close(postfile)\r
+       if(system("wget -q -t 3 --connect-timeout=60 --save-cookies=" cookiefile " --post-file=" postfile " -U " useragent " -O " tempfile " \"" fora "/ucp.php?mode=login\""))\r
+       {\r
+               print "Login fail."\r
+               exit 1\r
+       }\r
+       \r
+       while((getline temp < tempfile)>0)\r
+       {\r
+               if (temp ~ /<div class=.error/)\r
+               {\r
+                       print temp\r
+                       print "LOGIN IMPOSSIBLE!"\r
+                       exit 2\r
+               }\r
+       }\r
+       close(tempfile)\r
+       \r
+       if(system("wget -q -t 3 --connect-timeout=60 --load-cookies=" cookiefile " --save-cookies=" cookiefile " -U " useragent " -O " tempfile " \"" fora "/posting.php?mode="((edit!="")?"edit&f=7&p="edit:"reply&f=7&t=101043")"\""))\r
+       {\r
+               print "Postreply fail."\r
+               exit 1\r
+       }\r
+       \r
+       # extract info from form\r
+       att_inp=0\r
+       while((getline line < tempfile)>0)\r
+       {\r
+               if (tolower(line) ~ /<h2>information/)\r
+               {\r
+                       print "Unexpected h2: information\n"\r
+                       getline line < tempfile\r
+                       print line\r
+                       exit 1\r
+               }\r
+               \r
+               while (line!="")\r
+               {\r
+                       i=match(line, /</)\r
+                       if(i!=0)\r
+                       {\r
+                               text=substr(line,1,i-1)\r
+                               line=substr(line,i)\r
+                       }\r
+                       else\r
+                       {\r
+                               text=line\r
+                               line=""\r
+                       }\r
+                       if(textarea!="")\r
+                               argtab["old_message"] = argtab["old_message"] urlencode(entitydecode(text)"\n")\r
+                       \r
+                       i=match(line, />/)\r
+                       if(i!=0)\r
+                       {\r
+                               tag=substr(line,1,i)\r
+                               line=substr(line,i+1)\r
+                       }\r
+                       else #oh no tag doesn't end on this line - whatever, I don't care.\r
+                       {\r
+                               tag=line\r
+                               line=""\r
+                       }\r
+                       \r
+                       \r
+                       if(tag ~ /^<textarea.*id=\"message\"/) #"\r
+                               textarea="1"\r
+                       else if(tag ~ /<\/textarea/)\r
+                               textarea=""\r
+                       \r
+                       else if(tag ~ /name=\"form_token/)\r
+                       #\"#"\r
+                       {\r
+                               value=substr(tag, index(tag, "value=\"")+7)\r
+                               value=substr(value, 1, index(value, "\"")-1)\r
+                               argtab["form_token"]=urlencode(entitydecode(value))\r
+                       }\r
+                       else if(tag ~ /name=\"creation_time/)\r
+                       #\"#"\r
+                       {\r
+                               value=substr(tag, index(tag, "value=\"")+7)\r
+                               value=substr(value, 1, index(value, "\"")-1)\r
+                               argtab["creation_time"]=urlencode(entitydecode(value))\r
+                       }\r
+                       else if(tag ~ /name=\"subject/)\r
+                       #\"#"\r
+                       {\r
+                               value=substr(tag, index(tag, "value=\"")+7)\r
+                               value=substr(value, 1, index(value, "\"")-1)\r
+                               argtab["old_subject"]=urlencode(entitydecode(value))\r
+                       }\r
+                       \r
+                       #may have to extend it to other things. NNot now.\r
+                       else if(tag ~ /^<input.*name="attachment/) #")\r
+                       {\r
+                               value=substr(tag, index(tag, "value=\"")+7)\r
+                               value=substr(value, 1, index(value, "\"")-1)\r
+                               \r
+                               tagname=substr(tag, index(tag, "name=\"")+6)\r
+                               tagname=substr(tagname, 1, index(tagname, "\"")-1)\r
+                               \r
+                               nam_tab[att_inp]=urlencode(entitydecode(tagname))\r
+                               val_tab[att_inp]=urlencode(entitydecode(value))\r
+                               ++att_inp\r
+                       }\r
+               }\r
+       }\r
+       close(tempfile)\r
+       \r
+       if(edit!="")\r
+       {\r
+               timecmd | getline posttime\r
+               close(timecmd)\r
+       }\r
+       \r
+       printf ("subject=%s",argtab[(edit!="")?"old_subject":"subject"])>postfile\r
+       if("&addbbcode20" in argtab)\r
+               printf ("&addbbcode20=%s",argtab["addbbcode20"])>>postfile\r
+       if(edit!="")\r
+               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\r
+       else\r
+               printf ("&message=%s",argtab["message"])>>postfile\r
+       printf ("&post=%s","Submit")>>postfile\r
+       if("disable_bbcode" in argtab)\r
+               printf ("&disable_bbcode=%s",argtab["disable_bbcode"])>>postfile\r
+       if("disable_smilies" in argtab)\r
+               printf ("&disable_smilies=%s",argtab["disable_smilies"])>>postfile\r
+       if("disable_magic_url" in argtab)\r
+               printf ("&disable_magic_url=%s",argtab["disable_magic_url"])>>postfile\r
+       if("attach_sig" in argtab)\r
+               printf ("&attach_sig=%s",argtab["attach_sig"])>>postfile\r
+       if("notify" in argtab)\r
+               printf ("&notify=%s",argtab["notify"])>>postfile\r
+       printf ("&creation_time=%s",argtab["creation_time"])>>postfile\r
+       printf ("&form_token=%s",argtab["form_token"])>>postfile\r
+       for(i=0; i<att_inp; ++i)\r
+               printf("&%s=%s",nam_tab[i],val_tab[i])>>postfile\r
+       \r
+       close(postfile)\r
+       \r
+       system("sleep 1")\r
+       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")"\""))\r
+       {\r
+               print "Submit fail."\r
+               exit 1\r
+       }\r
+       \r
+       while((getline temp < tempfile)>0)\r
+       {\r
+               if (temp ~ /<p class=.error/)\r
+               {\r
+                       print temp\r
+                       print "POST IMPOSSIBLE!"\r
+                       exit 2\r
+               }\r
+               if (tolower(temp) ~ /<h2>information/)\r
+               {\r
+                       success=1\r
+               }\r
+       }\r
+       close(tempfile)\r
+       \r
+       if (success!=1)\r
+       {\r
+               print "Sent back to preview!"\r
+               exit INDELIVERABLE\r
+       }\r
+       \r
+       while((getline cookie < cookiefile)>0)\r
+       {\r
+               if(cookie ~ /_sid/)\r
+               {\r
+                       split(cookie,arr,"_sid[ \t]*")\r
+                       SID=arr[2]\r
+                       break\r
+               }\r
+       }\r
+       close(cookiefile)\r
+       if(system("wget -q -t 3 --connect-timeout=60 -U " useragent " -O " tempfile " \"" fora "/ucp.php?mode=logout&sid=" SID"\""))\r
+       {\r
+               print "Logout fail."\r
+       }\r
+       \r
\r
+}\r
+function urlencode(name,all,   len,iii,escaped,ch)\r
+{\r
+       len=length(name)\r
+       escaped=""\r
+       for(iii=1;iii<=len;++iii)\r
+       {\r
+               ch=substr(name,iii,1);\r
+               if ((ch ~ /[a-zA-Z0-9\.\-_~]/)&&(all==""))\r
+                       escaped = escaped ch\r
+               else\r
+                       escaped = escaped "%" ch2hex[ch]\r
+       }\r
+       return escaped\r
+}\r
+function entitydecode(ht   ,i,j,un,num)\r
+# quot, amp, lt, gt, nbsp, and decimal numbered.\r
+{\r
+       while ((i=match(ht, /&((#[0-9]+)|([a-zA-Z]+));/))!=0)#\r
+       {\r
+               un=un substr(ht, 1, i-1)\r
+               ht=substr(ht, i)\r
+               j=index(ht, ";")\r
+               \r
+               if(ht~/^&#/)\r
+               {\r
+                       num=int(substr(ht, 3, j-3))\r
+                       un=un sprintf("%c",num)\r
+               }\r
+               else\r
+               {\r
+                       num=tolower(substr(ht, 2, j-2))\r
+                       if(num == "quot")\r
+                               un=un "\""\r
+                       else if(num == "amp")\r
+                               un=un "&"\r
+                       else if(num == "lt")\r
+                               un=un "<"\r
+                       else if(num == "gt")\r
+                               un=un ">"\r
+                       else if(num == "nbsp")\r
+                               un=un "\xA0"\r
+                       else\r
+                               un = un ht\r
+               }\r
+               ht=substr(ht, j+1)\r
+       }\r
+       un=un ht\r
+       return un\r
+}\r
+function urldecode(ht   ,i,j,un,num)\r
+# quot, amp, lt, gt, nbsp, and decimal numbered.\r
+{\r
+       while ((i=match(ht, /%[0-9a-fA-F][0-9a-fA-F]/))!=0)#\r
+       {\r
+               un=un substr(ht, 1, i-1)\r
+               ht=substr(ht, i)\r
+               num=toupper(substr(ht, 2, 2))\r
+               un=un hex2ch[num]\r
+               ht=substr(ht, 4)\r
+       }\r
+       un=un ht\r
+       return un\r
+}\r
diff --git a/post.cpp b/post.cpp
new file mode 100644 (file)
index 0000000..72c5974
--- /dev/null
+++ b/post.cpp
@@ -0,0 +1,538 @@
+// post.cpp (1190.bicyclesonthemoon.info/ct-if-p)\r
+// The post edit interface\r
+// 17.04.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#include <cgi.h>\r
+#include <time.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <string.h>\r
+#include <sys/wait.h>\r
+\r
+#define RM_PATH "/bin/rm"\r
+#define MV_PATH "/bin/mv"\r
+#define CAT_PATH "/bin/cat"\r
+#define MAWK_PATH "/usr/bin/mawk"\r
+\r
+#define POST_PATH "/eizm/www/time/aftertime/bftf/post.htm"\r
+#define INFO_PATH "/eizm/www/time/aftertime/bftf/info.htm"\r
+#define MPOST_PATH "/eizm/mem/ong1/mpost/wait/"\r
+// #define MLIST_PATH "/eizm/mem/ott/mlistaaa"\r
+// #define MLAST_PATH "/eizm/mem/ottmirror/mlist/lastaaa"\r
+// #define MFRONT_PATH "/eizm/www/time/ott/mfrontaaa"\r
+\r
+#define AWK_PREVIEW "/eizm/pro/ong1/preview.awk"\r
+#define AWK_VIEW "/eizm/pro/ong1/view.awk"\r
+#define TEMP_PATH "/eizm/tmp/ong1/preview."\r
+#define AWK_B2H "/eizm/pro/ong1/bb2html.awk"\r
+#define DELIVER_PATH "/eizm/pro/ong1/deliver"\r
+\r
+s_cgi *cgi;\r
+pid_t sub;\r
+int r;\r
+FILE *tempfile;\r
+FILE *postfile;\r
+bool tf=false;\r
+bool pf=false;\r
+char temppath[256]="";\r
+char postpath[256]="";\r
+bool fff;\r
+\r
+char zero='\0';\r
+char *username = &zero;\r
+char *subject = &zero;\r
+char *message = &zero;\r
+char *y = &zero;\r
+char *m = &zero;\r
+char *d = &zero;\r
+char *Preview = &zero;\r
+char *post =&zero;\r
+char *addquote =&zero;\r
+char *fy = &zero;\r
+char *fm = &zero;\r
+char *fd = &zero;\r
+char *forcetime = &zero;\r
+char *hidden = &zero;\r
+char wrong[256];\r
+\r
+void submit();\r
+void preview (const char *text);\r
+void writeArg(FILE *file,const char *name,const char *value, bool all);\r
+void writeArg(FILE *file,const char *name,const char *value, char *insert);\r
+void writeArgH(FILE *file,const char *name,const char *value, unsigned char br);\r
+void writeArgH(FILE *file,const char *value);\r
+void end(int m);\r
+\r
+void end(int m)\r
+{\r
+       if(tf)\r
+               fclose(tempfile);\r
+       if(pf)\r
+               fclose(postfile);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       if(pf)\r
+       {\r
+               sub=fork();\r
+               if(sub==0)\r
+               {\r
+                       r=execl(RM_PATH,RM_PATH,"-f",postpath,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+       }\r
+       exit(m);\r
+}\r
+\r
+void writeArg(FILE *file,const char *name,const char *value, bool all=false)\r
+{\r
+       unsigned short length, i, v;\r
+       fprintf(file,"%s=",name);\r
+       for(i=0, length=strlen(value);i<length;++i)\r
+       {\r
+               v=((unsigned short)value[i])&0x00ff;\r
+               if(((value[i]>='0'&&value[i]<='9')||(value[i]>='A'&&value[i]<='Z')||(value[i]>='a'&&value[i]<='z')\r
+               ||value[i]=='.'||value[i]=='~'||value[i]=='-'||value[i]=='_')&&(!all))\r
+                       fputc(v,file);\r
+               else\r
+                       fprintf(file,"%%%02X",v);\r
+       }\r
+       fputc('\n',file);\r
+}\r
+\r
+void writeArg(FILE *file,const char *name,const char *value, char *insert)\r
+{\r
+       unsigned short length, i, v;\r
+       fprintf(file,"%s=",name);\r
+       for(i=0, length=strlen(insert);i<length;++i)\r
+       {\r
+               v=((unsigned short)insert[i])&0x00ff;\r
+               if((insert[i]>='0'&&insert[i]<='9')||(insert[i]>='A'&&insert[i]<='Z')||(insert[i]>='a'&&insert[i]<='z')\r
+               ||insert[i]=='.'||insert[i]=='~'||insert[i]=='-'||insert[i]=='_')\r
+                       fputc(v,file);\r
+               else\r
+                       fprintf(file,"%%%02X",v);\r
+       }\r
+       for(i=0, length=strlen(value);i<length;++i)\r
+       {\r
+               v=((unsigned short)value[i])&0x00ff;\r
+               if((value[i]>='0'&&value[i]<='9')||(value[i]>='A'&&value[i]<='Z')||(value[i]>='a'&&value[i]<='z')\r
+               ||value[i]=='.'||value[i]=='~'||value[i]=='-'||value[i]=='_')\r
+                       fputc(v,file);\r
+               else\r
+                       fprintf(file,"%%%02X",v);\r
+       }\r
+       fputc('\n',file);\r
+}\r
+\r
+void writeArgH(FILE *file,const char *name,const char *value, unsigned char br=0)\r
+{\r
+       unsigned short length, i, v;\r
+       fprintf(file,"%s=",name);\r
+       for(i=0, length=strlen(value);i<length;++i)\r
+       {\r
+               v=((unsigned short)value[i])&0x00ff;\r
+               switch (value[i])\r
+               {\r
+               case '\"':\r
+               case ' ':\r
+                       if(br&0x02)\r
+                       {\r
+                               fputc(v,file);\r
+                               break;\r
+                       }\r
+                       else\r
+                       {\r
+                               fprintf(file,"&#%hu;",v);\r
+                               break;\r
+                       }\r
+               case '\n':\r
+                       if(br&0x01)\r
+                               fprintf(file,"<br>");\r
+               case '\r':\r
+                       if(br&0x01)\r
+                               break;\r
+               case '=':\r
+               case '<':\r
+               case '>':\r
+               case '&':\r
+                       fprintf(file,"&#%hu;",v);\r
+                       break;\r
+               default:\r
+                       fputc(v,file);\r
+               }\r
+       }\r
+       fputc('\n',file);\r
+}\r
+\r
+void writeArgH(FILE *file,const char *value)\r
+{\r
+       unsigned short length, i, v;\r
+       for(i=0, length=strlen(value);i<length;++i)\r
+       {\r
+               v=((unsigned short)value[i])&0x00ff;\r
+               switch (value[i])\r
+               {\r
+               case '\"':\r
+               case '&':\r
+               case '<':\r
+               case '>':\r
+               case ' ':\r
+               case '\r':\r
+               case '\n':\r
+               case '=':\r
+                       fprintf(file,"&#%hu;",v);\r
+                       break;\r
+               default:\r
+                       fputc(v,file);\r
+               }\r
+       }\r
+}\r
+\r
+void submit()\r
+{\r
+       time_t posttime;\r
+       struct tm *nowS;\r
+       char timetext[32];\r
+       char timenumber[32];\r
+       char yy[8];\r
+       char mm[4];\r
+       char dd[4];\r
+       char yyy[8];\r
+       char mmm[4];\r
+       char ddd[4];\r
+       char arg1[256];\r
+       unsigned char tm, td;\r
+       unsigned short ty;\r
+       bool deliver=false;\r
+\r
+       posttime=time(NULL);\r
+       nowS=localtime(&posttime);\r
+       if(y[0]!='\0'){sscanf(y,"%hu",&ty); sprintf(yyy,"%04hu",ty); }\r
+       if(m[0]!='\0'){sscanf(m,"%hhu",&tm);sprintf(mmm,"%02hhu",tm);}\r
+       if(d[0]!='\0'){sscanf(d,"%hhu",&td);sprintf(ddd,"%02hhu",td);}\r
+       \r
+       if(!fff)\r
+       {\r
+               if((ty==1900+nowS->tm_year)&&(tm==1+nowS->tm_mon)&&(td==nowS->tm_mday))\r
+                       preview("Can't send this mesage to the same day it came from.");\r
+               if(ty<1900+nowS->tm_year)\r
+                       preview("Can't send this mesage to the past. It wasn't received in the past.");\r
+               else if(ty==1900+nowS->tm_year)\r
+               {\r
+                       if(tm<1+nowS->tm_mon)\r
+                               preview("Can't send this mesage to the past. It wasn't received in the past.");\r
+                       else if(tm==1+nowS->tm_mon)\r
+                       {\r
+                               if(td<=nowS->tm_mday)\r
+                                       preview("Can't send this mesage to the past. It wasn't received in the past.");\r
+                       }\r
+               }\r
+       }\r
+       else if((ty==1900+nowS->tm_year)&&(tm==1+nowS->tm_mon)&&(td==nowS->tm_mday))\r
+               deliver=true;\r
+               \r
+       sprintf(timenumber,"%llu",(unsigned long long)posttime);\r
+       if(forcetime[0]!='\0')\r
+               sprintf(timetext,"%s",forcetime);\r
+       else\r
+               strftime(timetext,31,"%e.%m.%Y %H:%M",gmtime(&posttime));\r
+       sprintf(postpath,"%s%s",MPOST_PATH,timenumber);\r
+       \r
+       if(fd[0]!='\0'&&fy[0]!='\0'&&fm[0]!='\0')\r
+       {\r
+               sprintf(yy,"%s",fy);\r
+               sprintf(mm,"%s",fm);\r
+               sprintf(dd,"%s",fd);\r
+       }\r
+       else\r
+       {\r
+               posttime+=86400;\r
+               nowS=localtime(&posttime);\r
+               sprintf(yy,"%04d",1900+nowS->tm_year);\r
+               sprintf(mm,"%02d",1+nowS->tm_mon);\r
+               sprintf(dd,"%2d",nowS->tm_mday);\r
+       }\r
+       \r
+       tempfile=fopen(temppath,"wt");\r
+       if(tempfile==NULL)\r
+               preview("Couldn't create file.");\r
+       tf=true;\r
+       writeArgH(tempfile,"timenumber",timenumber);\r
+       writeArgH(tempfile,"timetext",timetext);\r
+       writeArgH(tempfile,"BBHTML",message,1);\r
+       writeArgH(tempfile,"BB",message,3);\r
+       writeArgH(tempfile,"username_h",username);\r
+       writeArgH(tempfile,"subject_h",subject);\r
+       if(d[0]!='\0')writeArgH(tempfile,"d",ddd);\r
+       if(m[0]!='\0')writeArgH(tempfile,"m",mmm);\r
+       if(y[0]!='\0')writeArgH(tempfile,"y",yyy);\r
+       writeArgH(tempfile,"yy",yy,2);\r
+       writeArgH(tempfile,"mm",mm,2);\r
+       writeArgH(tempfile,"dd",dd,2);\r
+       writeArgH(tempfile,"disable_smilies","on");\r
+       fclose(tempfile);\r
+       tf=false;\r
+       \r
+       printf("Content-type: text/html\n\n");\r
+       sprintf(arg1,"outfile=%s",temppath);\r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               setvbuf(stdout, NULL, _IONBF, 0);\r
+               dup2(fileno(stdout),fileno(stderr));\r
+               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_B2H,"-v",arg1,temppath,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       \r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               r=execl(MV_PATH,MV_PATH,temppath,postpath,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       if(r)\r
+               // preview("Couldn't add post to queue.");\r
+               preview(postpath);\r
+       \r
+       sprintf(arg1,"info=<p>This message has been sent successfully.<br><br><a href=\"/ct-if-v?v=wt%s%s\">View your submitted message</a><br><br><a href=\"/ct-if%s/\">Return to the chronotransponder time interface</a></p>",timenumber,(fff?"&amp;fff=fff":""),(fff?"?fff=fff":""));\r
+       // printf("Content-type: text/html\n\n");\r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_VIEW,"-v",arg1,INFO_PATH,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       if(r)\r
+               printf("<HTML><body>%s</body></html>",arg1);\r
+       \r
+       if(deliver)\r
+       {\r
+               fflush(stdout);\r
+               sub=fork();\r
+               if(sub==0)\r
+               {\r
+                       r=execl(DELIVER_PATH,DELIVER_PATH,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+       }\r
+       \r
+       end(0);\r
+}\r
+void preview (const char *text)\r
+{\r
+       char arg1[256];\r
+       time_t posttime;\r
+       struct tm *nowS;\r
+       char yy[8];\r
+       char mm[4];\r
+       char dd[4];\r
+       unsigned short ty;\r
+       unsigned char tm,td;\r
+       \r
+       tempfile=fopen(temppath,"wt");\r
+       if(tempfile==NULL)\r
+               end(1);\r
+       tf=true;\r
+       \r
+       if(d[0]=='\0'&&y[0]=='\0'&&m[0]=='\0')\r
+       {\r
+               posttime=time(NULL);\r
+               posttime+=86400;\r
+               nowS=localtime(&posttime);\r
+               sprintf(yy,"%04d",1900+nowS->tm_year);\r
+               sprintf(mm,"%02d",1+nowS->tm_mon);\r
+               sprintf(dd,"%2d",nowS->tm_mday);\r
+       }\r
+       else\r
+       {\r
+               if(y[0]!='\0'){sscanf(y,"%hu",&ty); sprintf(yy,"%04hu",ty); }\r
+               if(m[0]!='\0'){sscanf(m,"%hhu",&tm);sprintf(mm,"%02hhu",tm);}\r
+               if(d[0]!='\0'){sscanf(d,"%hhu",&td);sprintf(dd,"%02hhu",td);}\r
+       }\r
+       \r
+       writeArgH(tempfile,"HTML",message,1);\r
+       writeArgH(tempfile,"BB",message,3);\r
+       writeArgH(tempfile,"wrong",text);\r
+       writeArgH(tempfile,"username",username);\r
+       writeArgH(tempfile,"subject",subject);\r
+       writeArgH(tempfile,"message",message);\r
+       if(d[0]!='\0')writeArgH(tempfile,"d",dd);\r
+       if(m[0]!='\0')writeArgH(tempfile,"m",mm);\r
+       if(y[0]!='\0')writeArgH(tempfile,"y",yy);\r
+       writeArgH(tempfile,"dd",fd);\r
+       writeArgH(tempfile,"mm",fm);\r
+       writeArgH(tempfile,"yy",fy);\r
+       writeArgH(tempfile,"forcetime",forcetime);\r
+       writeArgH(tempfile,"disable_smilies","on");\r
+       writeArgH(tempfile,"addquote",addquote);\r
+       writeArgH(tempfile,"hidden",hidden);\r
+       fclose(tempfile);\r
+       tf=false;\r
+       \r
+       printf("Content-type: text/html\n\n");\r
+       \r
+       sprintf(arg1,"outfile=%s",temppath);\r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               setvbuf(stdout, NULL, _IONBF, 0);\r
+               dup2(fileno(stdout),fileno(stderr));\r
+               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_B2H,"-v",arg1,temppath,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       \r
+       // printf("Content-type: text/html\n\n");\r
+       sprintf(arg1,"argfile=%s",temppath);\r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_PREVIEW,"-v",arg1,"-v",fff?"fff=fff":"f=f",POST_PATH,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       if(r)\r
+               printf("<HTML><body><p>Ch*rpin* M*stard</p></body></html>");\r
+       end(0);\r
+}\r
+\r
+int main()\r
+{\r
+       bool missing=false;\r
+       \r
+       char *arg;\r
+       \r
+       cgi=cgiInit();\r
+       fff=(cgiGetValue(cgi,"fff")!=NULL);\r
+       \r
+       sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid());\r
+       \r
+       arg=cgiGetValue(cgi,"username");\r
+       if(arg!=NULL)\r
+               username=arg;\r
+       else\r
+       {\r
+               missing=true;\r
+               strcpy(wrong,"Name is missing.");\r
+       }\r
+       \r
+       arg=cgiGetValue(cgi,"subject");\r
+       if(arg!=NULL)\r
+               subject=arg;\r
+       else\r
+       {\r
+               missing=true;\r
+               strcpy(wrong,"Subject was missing. Replaced with default value.");\r
+       }\r
+       \r
+       arg=cgiGetValue(cgi,"message");\r
+       if(arg!=NULL)\r
+               message=arg;\r
+       else\r
+       {\r
+               missing=true;\r
+               strcpy(wrong,"Post is empty.");\r
+       }\r
+       \r
+       arg=cgiGetValue(cgi,"y");\r
+       if(arg!=NULL)\r
+               y=arg;\r
+       else\r
+       {\r
+               missing=true;\r
+               strcpy(wrong,"Time not specified.");\r
+       }\r
+       \r
+       arg=cgiGetValue(cgi,"m");\r
+       if(arg!=NULL)\r
+               m=arg;\r
+       else\r
+       {\r
+               missing=true;\r
+               strcpy(wrong,"Time not specified.");\r
+       }\r
+       \r
+       arg=cgiGetValue(cgi,"d");\r
+       if(arg!=NULL)\r
+               d=arg;\r
+       else\r
+       {\r
+               missing=true;\r
+               strcpy(wrong,"Time not specified.");\r
+       }\r
+       \r
+       arg=cgiGetValue(cgi,"yy");\r
+       if(arg!=NULL)\r
+               fy=arg;\r
+       \r
+       arg=cgiGetValue(cgi,"mm");\r
+       if(arg!=NULL)\r
+               fm=arg;\r
+       \r
+       arg=cgiGetValue(cgi,"dd");\r
+       if(arg!=NULL)\r
+               fd=arg;\r
+       \r
+       arg=cgiGetValue(cgi,"forcetime");\r
+       if(arg!=NULL)\r
+               forcetime=arg;\r
+       \r
+       arg=cgiGetValue(cgi,"Preview");\r
+       if(arg!=NULL)\r
+               Preview=arg;\r
+       \r
+       arg=cgiGetValue(cgi,"post");\r
+       if(arg!=NULL)\r
+               post=arg;\r
+               \r
+       arg=cgiGetValue(cgi,"q");\r
+       if(arg!=NULL)\r
+               addquote=arg;\r
+       \r
+       arg=cgiGetValue(cgi,"hidden");\r
+       if(arg!=NULL)\r
+               hidden=arg;\r
+       \r
+       if(strcmp(post,"Submit")==0)\r
+       {\r
+               if(missing)\r
+                       preview(wrong);\r
+               else\r
+                       submit();\r
+       }\r
+       else\r
+               preview("");\r
+       \r
+       return 0;\r
+       \r
+}\r
diff --git a/posted.awk b/posted.awk
new file mode 100644 (file)
index 0000000..c574256
--- /dev/null
@@ -0,0 +1,38 @@
+#// posted.awk\r
+#// Display one entry in the post list\r
+#// 05.10.2014\r
+#// \r
+#// Copyright (C) 2014  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       FS="="\r
+};\r
+{\r
+       gsub(/[\r\n]/,"",$0)\r
+       eq=index($0,"=")\r
+       argtab[substr($0,1,eq-1)]=substr($0,eq+1)\r
+};\r
+END{\r
+       if(cat=="wt" && argtab["hidden"]!="" && fff=="")\r
+               exit 1\r
+       if (r2==0)\r
+               class="plw"\r
+       else\r
+               class="plv"\r
+       \r
+       # print "<tr class=\""class"\"><td class=\"plk\">"argtab["timetext"]"</td><td class=\"plk\">"argtab["d"]"."argtab["m"]"."argtab["y"]"</td><td class=\"plk\">"argtab["username_h"]"</td><td class=\"plk\">"argtab["subject_h"]"</td><td class=\"plk\"><form method=\"post\" action=\"/ct-if-r\"><a href=\"/ct-if-v?v="cat argtab["timenumber"](fff!=""?"&amp;fff=fff":"")"\">view</a> <a href=\"/ct-if-p?q="cat argtab["timenumber"](fff!=""?"&amp;fff=fff":"")"\">quote</a> <input type=\"hidden\" name=\"r\" value=\""cat argtab["timenumber"]"\"><input type=\"submit\" value=\"remove\" class=\"hl\"></form></td></tr>"\r
+       print "<tr class=\""class"\"><td class=\"plk\">"argtab["timetext"]"</td><td class=\"plk\">"argtab["d"]"."argtab["m"]"."argtab["y"]"</td><td class=\"plk\">"argtab["username_h"]"</td><td class=\"plk\">"argtab["subject_h"]"</td><td class=\"plk\"><a href=\"/ct-if-v?v="cat argtab["timenumber"](fff!=""?"&amp;fff=fff":"")"\">view</a> <a href=\"/ct-if-p?q="cat argtab["timenumber"](fff!=""?"&amp;fff=fff":"")"\">quote</a> <a href=\"/ct-if-r?r="cat argtab["timenumber"](fff!=""?"&amp;fff=fff":"")"\">remove</a></td></tr>"\r
+}
\ No newline at end of file
diff --git a/posted.c b/posted.c
new file mode 100644 (file)
index 0000000..ef4e19f
--- /dev/null
+++ b/posted.c
@@ -0,0 +1,163 @@
+// posted.c (1190.bicyclesonthemoon.info/ct-if)\r
+// Display the post list\r
+// 23.11.2014\r
+// \r
+// Copyright (C) 2014  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#include <cgi.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <sys/wait.h>\r
+\r
+#define TEMP_PATH "/eizm/tmp/ong1/posted."\r
+#define MPOST_PATH "/eizm/mem/ong1/mpost/"\r
+#define WAIT_PATH "/eizm/mem/ong1/mpost/wait/"\r
+#define LS_PATH "/bin/ls"\r
+#define RM_PATH "/bin/rm"\r
+#define MAWK_PATH "/usr/bin/mawk"\r
+#define AWK_POSTED "/eizm/pro/ong1/posted.awk"\r
+\r
+s_cgi *cgi;\r
+pid_t sub;\r
+int r;\r
+\r
+int main(int argc, char **argv)\r
+{\r
+       char temppath[256]="";\r
+       char line[32];\r
+       char filename[32];\r
+       char postpath[256];\r
+       FILE *tempfile;\r
+       // FILE *postfile;\r
+       unsigned char i;\r
+       unsigned char fff;\r
+       // dup2(fileno(stdout),fileno(stderr));\r
+       cgi=cgiInit();\r
+       fff=(cgiGetValue(cgi,"fff")!=NULL);\r
+       \r
+       sprintf(temppath,"%s%lu",TEMP_PATH,(unsigned long)getpid());\r
+       \r
+       printf("Content-type: text/html\n\n");\r
+       printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n");\r
+       printf("<html lang=\"en\"><head>\n");\r
+       printf("<title>Chronotransponder test interface &bull; Bicycles on the Moon</title>\n");\r
+       printf("<meta http-equiv=\"Content-type\" content=\"text/html; charset=UTF-8\">\n");\r
+       printf("<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n");\r
+       printf("<link rel=\"stylesheet\" href=\"/css/botm.css\">\n");\r
+       printf("</head><body><a href=\"/\"><img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\"></a>\n");\r
+       printf("<h1>Chronotransponder test interface</h1>\n");\r
+       \r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               if(freopen(temppath,"wt",stdout)==NULL)\r
+                       exit(255);\r
+               r=execl(LS_PATH,LS_PATH,"-1","--color=never",MPOST_PATH,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       if(r)\r
+               printf("No messages.<br>\n");\r
+       else\r
+       {\r
+               printf("<table class=\"pl\"><tr class=\"pls\"><td colspan=\"5\">CT</td></tr>\n");\r
+               printf("<tr class=\"plt\"><td class=\"plk\">sent</td><td class=\"plk\">received</td><td class=\"plk\">author</td><td class=\"plk\">subject</td><td class=\"plk\">action</td></tr>\n");\r
+               \r
+               tempfile=fopen(temppath,"rt");\r
+               if(tempfile!=NULL)\r
+               {\r
+                       for(i=0; fgets(line,31,tempfile)!=NULL; ++i)\r
+                       {\r
+                               sscanf(line,"%s",filename);\r
+                               sprintf(postpath,"%s%s",MPOST_PATH,filename);\r
+                               \r
+                               fflush(stdout);\r
+                               sub=fork();\r
+                               if(!sub)\r
+                               {\r
+                                       r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POSTED,"-v",i&0x1?"r2=1":"r2=0","-v","cat=ct","-v",fff?"fff=fff":"f=f",postpath,(char *)0);\r
+                                       exit(r);\r
+                               }\r
+                               waitpid(sub,&r,0);\r
+                               \r
+                       }\r
+                       fclose(tempfile);\r
+               }\r
+               printf("</table><br><b><a href=\"/ct-if-p%s\">Send a message</a></b><br>\n",fff?"?fff=fff":"");\r
+\r
+       }\r
+       \r
+       // if(fff)\r
+       // {\r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               if(freopen(temppath,"wt",stdout)==NULL)\r
+                       exit(255);\r
+               r=execl(LS_PATH,LS_PATH,"-1","--color=never",WAIT_PATH,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       if(r)\r
+               printf("No messages.<br>\n");\r
+       else\r
+       {\r
+               printf("<br><table class=\"pl\"><tr class=\"pls\"><td colspan=\"5\">WAIT</td></tr>\n");\r
+               printf("<tr class=\"plt\"><td class=\"plk\">sent</td><td class=\"plk\">to be received</td><td class=\"plk\">author</td><td class=\"plk\">subject</td><td class=\"plk\">action</td></tr>\n");\r
+               \r
+               tempfile=fopen(temppath,"rt");\r
+               if(tempfile!=NULL)\r
+               {\r
+                       for(i=0; fgets(line,31,tempfile)!=NULL; ++i)\r
+                       {\r
+                               sscanf(line,"%s",filename);\r
+                               sprintf(postpath,"%s%s",WAIT_PATH,filename);\r
+                               \r
+                               fflush(stdout);\r
+                               sub=fork();\r
+                               if(!sub)\r
+                               {\r
+                                       r=execl(MAWK_PATH,MAWK_PATH,"-f",AWK_POSTED,"-v",i&0x1?"r2=1":"r2=0","-v","cat=wt","-v",fff?"fff=fff":"f=f",postpath,(char *)0);\r
+                                       exit(r);\r
+                               }\r
+                               waitpid(sub,&r,0);\r
+                               if(r)\r
+                               --i;\r
+                               \r
+                       }\r
+                       fclose(tempfile);\r
+               }\r
+               \r
+               printf("</table>%s\n",fff?"<br><b><a href=\"/ct-if-f\">Force delivery</a></b><br>":"");\r
+       }\r
+// }\r
+       \r
+       printf("<br><a href=\"/\">1190.bicyclesonthemoon.info</a></body></html>\n");\r
+       \r
+       fflush(stdout);\r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               r=execl(RM_PATH,RM_PATH,"-f",temppath,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       \r
+       return 0;\r
+}\r
diff --git a/preview.awk b/preview.awk
new file mode 100644 (file)
index 0000000..800d4d8
--- /dev/null
@@ -0,0 +1,165 @@
+#// preview.awk
+#// Preview a post in the post edit interface
+#// 05.10.2014
+#// 
+#// Copyright (C) 2014  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 <http://www.gnu.org/licenses/>.
+
+BEGIN{
+       postpath="/eizm/mem/ong1/mpost/"
+       waitpath="/eizm/mem/ong1/mpost/wait/"
+       
+       HTML="<div class=\"pl\"><div class=\"pls\">Preview: %s</div><div class=\"plw\">%s</div></div><br>"
+       wrong="<div class=\"plt\"><b>%s</b></div>\n"
+       subject="<input type=\"text\" name=\"subject\" id=\"subject\" size=\"40\" maxlength=\"60\" tabindex=\"1\" value=\"%s\" class=\"pt\">\n"
+       username="<input tabindex=\"2\" name=\"username\" id=\"username\" size=\"40\" value=\"%s\" class=\"pt\" type=\"text\">\n"
+       time="<b>day: </b><input tabindex=\"3\" name=\"d\" id=\"day\" size=\"2\" value=\"%s\" class=\"pt\" type=\"text\"><b> month: </b><input tabindex=\"4\" name=\"m\" id=\"month\" size=\"2\" value=\"%s\" class=\"pt\" type=\"text\"><b> year: </b><input tabindex=\"5\" name=\"y\" id=\"year\" size=\"4\" value=\"%s\" class=\"pt\" type=\"text\">\n"
+       message="<textarea name=\"message\" id=\"message\" rows=\"20\" tabindex=\"6\" class=\"pt\" >%s%s</textarea>\n"
+       forcetime1="<input type=\"text\" name=\"forcetime\" id=\"forcetime\" size=\"16\" maxlength=\"32\" value=\"%s\" class=\"pt\">\n"
+       forcetime2="<tr><td><b>fTime: </b></td><td><b>day: </b><input name=\"dd\" id=\"fday\" size=\"2\" value=\"%s\" class=\"pt\" type=\"text\"><b> month: </b><input name=\"mm\" id=\"fmonth\" size=\"2\" value=\"%s\" class=\"pt\" type=\"text\"><b> year: </b><input name=\"yy\" id=\"fyear\" size=\"4\" value=\"%s\" class=\"pt\" type=\"text\"></tr>\n"
+       future="<input type=\"hidden\" name=\"fff\" value=\"fff\">"
+       img="<input type=\"button\" class=\"pk\" accesskey=\"p\" name=\"addbbcode14\" value=\"Img\" style=\"width: 40px\" onclick=\"bbstyle(14)\" title=\"Insert image: [img]http://image_url[/img]\" >"
+       back="<a href=\"/ct-if%s\">back to the chronotransponder interface</a>\n"
+       hidden="<input type=\"text\" name=\"hidden\" size=\"1\" class=\"pt\" value=\"%s\">\n"
+       addquote=""
+       
+       # print "<!--preview.awk:\nargfile=" argfile
+       while((getline argline < argfile)>0)
+       {
+               gsub(/[\r\n]/,"",argline)
+               eq=index(argline,"=")
+               argtab[substr(argline,1,eq-1)]=substr(argline,eq+1)
+               # print substr(argline,1,eq-1) "=" argtab[substr(argline,1,eq-1)]
+       }
+       # print "-->"
+       close(argfile)
+       if(argtab["addquote"] ~ /^[cw]t[0-9]+$/)
+       {
+               if(argtab["addquote"] ~ /^ct[0-9]+$/)
+                       argfile= postpath substr(argtab["addquote"],3)
+               if(argtab["addquote"] ~ /^wt[0-9]+$/)
+                       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 ~ /^BBHTML=/)
+                       {
+                               addquotehtml=substr(argline,eq+1)
+                               gsub(/<br>/,"\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 ~ /^timetext/)
+                       {
+                               addquotetime=", at "substr(argline,eq+1)
+                       }
+                       if(argline ~ /^yy=/)
+                       {
+                               argtab["y"]=substr(argline,eq+1)
+                       }
+                       if(argline ~ /^dd=/)
+                       {
+                               argtab["d"]=substr(argline,eq+1)
+                       }
+                       if(argline ~ /^mm=/)
+                       {
+                               argtab["m"]=substr(argline,eq+1)
+                       }
+                       if(argline ~ /^y=/)
+                       {
+                               argtab["yy"]=substr(argline,eq+1)
+                       }
+                       if(argline ~ /^d=/)
+                       {
+                               argtab["dd"]=substr(argline,eq+1)
+                       }
+                       if(argline ~ /^m=/)
+                       {
+                               argtab["mm"]=substr(argline,eq+1)
+                       }
+               }
+               close(argfile)
+               if(addquotehtml!="")
+                       addquote="[quote=&quot;"addquotename addquotetime"&quot;]"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"]=="")?"???":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["d"],argtab["m"],argtab["y"])
+       else if ($0 ~ /^###forcetime1/)
+       {
+               if(fff!="")
+                       printf(forcetime1,argtab["forcetime"])
+       }
+       else if ($0 ~ /^###forcetime2/)
+       {
+               if(fff!="")
+                       printf(forcetime2,argtab["dd"],argtab["mm"],argtab["yy"])
+       }
+       else if ($0 ~ /^###future/)
+       {
+               if(fff!="")
+                       print future
+       }
+       else if ($0 ~ /^###hidden/)
+       {
+               if(fff!="")
+                       printf(hidden,argtab["hidden"])
+       }
+       else if ($0 ~ /^###img/)
+       {
+               if(fff!="")
+                       print img
+       }
+       else if ($0 ~ /^###back/)
+       {
+               printf(back,fff!=""?"?fff=fff":"")
+       }
+       else if ($0 ~ /^###debug/)
+       {
+               gsub(/###nl;/,"\n",argtab["debug"])
+               gsub(/-/," - ",argtab["debug"])
+               print "<!-- "argtab["debug"]" -->"
+       }
+       else
+               print $0
+};
diff --git a/related.awk b/related.awk
new file mode 100644 (file)
index 0000000..943493e
--- /dev/null
@@ -0,0 +1,35 @@
+#// related.awk\r
+#// find an ONGed frame\r
+#// 29.10.2014\r
+#// \r
+#// Copyright (C) 2014  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+BEGIN{\r
+       related=0;\r
+       regexp=sprintf("(ongoing\\.((png)|(htm))\\?f=0*%lu)|(bftf-%04lu)",frame,frame)\r
+       printf(" \"" regexp "\"")\r
+};\r
+{\r
+       if ($0 ~ regexp)\r
+       {\r
+               related=1;\r
+               printf(" - already ONGed.");\r
+               exit related;\r
+       }\r
+};\r
+END{\r
+       exit related;\r
+}\r
diff --git a/relink.c b/relink.c
new file mode 100644 (file)
index 0000000..5dceb41
--- /dev/null
+++ b/relink.c
@@ -0,0 +1,63 @@
+// relink.c (1190.bicyclesonthemoon.info/ongoing.png (old))\r
+// redirect to the latest frame\r
+// 06.04.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define ONG_STATE_PATH "/eizm/data/aftertime/bftf/ongstate"\r
+#define RELINK_PATH    "/ongframe.png?f=%hu"\r
+\r
+#include <cgi.h>\r
+#include <stdio.h>\r
+\r
+s_cgi *cgi;\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+       FILE *file;\r
+       char relinkPath[256];\r
+       unsigned short ongFrame;\r
+       unsigned char ongState;\r
+       \r
+       cgi=cgiInit();\r
+       \r
+       file=fopen(ONG_STATE_PATH,"rt");\r
+       if(file!=NULL)\r
+       {\r
+               fscanf(file,"%hhu %hu",&ongState,&ongFrame);\r
+               fclose(file);\r
+       }\r
+       else\r
+       {\r
+               ongState=0;\r
+               ongFrame=0;\r
+       }\r
+       \r
+       if(ongState==1)\r
+       {\r
+               file=fopen(ONG_STATE_PATH,"wt");\r
+               if(file!=NULL)\r
+               {\r
+                       fprintf(file,"2 %hu",ongFrame);\r
+                       fclose(file);\r
+               }\r
+       }\r
+       \r
+       sprintf(relinkPath,RELINK_PATH,(unsigned short)ongFrame);\r
+       cgiRedirect(relinkPath);\r
+       \r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/remove.c b/remove.c
new file mode 100644 (file)
index 0000000..ee1bf66
--- /dev/null
+++ b/remove.c
@@ -0,0 +1,107 @@
+// remove.c (1190.bicyclesonthemoon.info/ct-if-r)\r
+// remove a post\r
+// 23.11.2014\r
+// \r
+// Copyright (C) 2014  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#include <cgi.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <sys/wait.h>\r
+\r
+#define POST_PATH "/eizm/mem/ong1/mpost/"\r
+#define WAIT_PATH "/eizm/mem/ong1/mpost/wait/"\r
+#define RMOV_PATH "/eizm/mem/ong1/mpost/rm/"\r
+#define MV_PATH "/bin/mv"\r
+\r
+int main(int argc, char **argv)\r
+{\r
+       s_cgi *cgi;\r
+       pid_t sub;\r
+       int r;\r
+       unsigned char fff;\r
+       \r
+       char zero='\0';\r
+       char *rmov = &zero;\r
+       char *arg;\r
+       char inpath[256];\r
+       char outpath[256];\r
+       \r
+       cgi=cgiInit();\r
+       \r
+       fff=(cgiGetValue(cgi,"fff")!=NULL);\r
+       if(cgiGetValue(cgi,"no")!=NULL)\r
+       {\r
+               cgiRedirect(fff?"/ct-if?fff=fff":"/ct-if");\r
+               return(0);\r
+       }\r
+       \r
+       if(cgiGetValue(cgi,"yes")==NULL)\r
+       {\r
+               arg=cgiGetValue(cgi,"r");\r
+               if(arg!=NULL)\r
+                       rmov=arg;\r
+               printf("Content-type: text/html\n\n");\r
+               printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n");\r
+               printf("<html lang=\"en\"><head>\n");\r
+               printf("<title>Chronotransponder test interface &bull; Bicycles on the Moon</title>\n");\r
+               printf("<meta http-equiv=\"Content-type\" content=\"text/html; charset=UTF-8\">\n");\r
+               printf("<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n");\r
+               printf("<link rel=\"stylesheet\" href=\"/css/botm.css\">\n");\r
+               printf("</head><body>\n");\r
+               printf("<img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\">\n");\r
+               printf("<h1>Chronotransponder test interface</h1>\n");\r
+               printf("<form action=\"/ct-if-r\" method=\"post\">\n");\r
+               printf("<b>Remove message %s?</b><br>\n",rmov);\r
+               if(fff)\r
+                       printf("<input type=\"hidden\" name=\"fff\" value=\"fff\">\n");\r
+               printf("<input type=\"submit\" class=\"pk\" name=\"yes\" value=\"Yes\">\n");\r
+               printf("<input type=\"submit\" class=\"pk\" name=\"no\"  value=\"No\">\n");\r
+               printf("<input type=\"hidden\" name=\"r\" value=\"%s\">\n",rmov);\r
+               printf("</form><br><a href=\"/\">1190.bicyclesonthemoon.info</a></body></html>\n");\r
+               return 0;\r
+       }\r
+       \r
+       arg=cgiGetValue(cgi,"r");\r
+       if(arg==NULL)\r
+       {\r
+               cgiRedirect(fff?"/ct-if?fff=fff":"/ct-if");\r
+               return(0);\r
+       }\r
+       rmov=arg;\r
+       \r
+       if(rmov[0]=='c'&&rmov[1]=='t')\r
+               sprintf(inpath,"%s%s",POST_PATH,rmov+2);\r
+       else if(rmov[0]=='w'&&rmov[1]=='t')\r
+               sprintf(inpath,"%s%s",WAIT_PATH,rmov+2);\r
+       else\r
+       {\r
+               cgiRedirect(fff?"/ct-if?fff=fff":"/ct-if");\r
+               return(0);\r
+       }\r
+       sprintf(outpath,"%s%s",RMOV_PATH,rmov+2);\r
+       \r
+       sub=fork();\r
+       if(sub==0)\r
+       {\r
+               r=execl(MV_PATH,MV_PATH,inpath,outpath,(char *)0);\r
+               exit(r);\r
+       }\r
+       waitpid(sub,&r,0);\r
+       cgiRedirect(fff?"/ct-if?fff=fff":"/ct-if");\r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/spoiler.c b/spoiler.c
new file mode 100644 (file)
index 0000000..ec1182d
--- /dev/null
+++ b/spoiler.c
@@ -0,0 +1,114 @@
+// spoiler.c (1190.bicyclesonthemoon.info/spoiler)\r
+// main page redundaspoiler\r
+// 16.08.2015\r
+// \r
+// Copyright (C) 2014  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define REDBUTTON 32\r
+\r
+#include <cgi.h>\r
+#include <stdio.h>\r
+\r
+s_cgi *cgi;\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+       char *value;\r
+       unsigned short n;\r
+       unsigned char open;\r
+       unsigned char discovered;\r
+       \r
+       cgi=cgiInit();\r
+       \r
+       value=cgiGetValue(cgi,"n");\r
+       if(value!=NULL) \r
+               sscanf(value,"%hu",&n);\r
+       else\r
+               n=0;\r
+       \r
+       open=((cgiGetValue(cgi,"o")!=NULL)?1:0);\r
+       discovered=((cgiGetValue(cgi,"d")!=NULL)?1:0);\r
+       \r
+       printf("Content-type: text/html\n\n");\r
+       \r
+       fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n",stdout);\r
+       fputs("<html lang=\"en\"><head>\n",stdout);\r
+       fputs("<title>xkcd 1190: \"Time\" &bull; Bicycles on the Moon</title>\n",stdout);\r
+       fputs("<meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-2\">\n",stdout);\r
+       fputs("<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n",stdout);\r
+       fputs("<link rel=\"stylesheet\" href=\"/css/botm.css\">\n",stdout);\r
+       fputs("</head><body>\n",stdout);\r
+       fputs("Hi, I'm balthasar_s and this is<br>\n",stdout);\r
+       fputs("<img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\"><br><br>\n",stdout);\r
+       fputs("Some things related to the <a href=\"http://wiki.chirpingmustard.com\">Time</a> thread on the xkcd Fora are here.\n",stdout);\r
+       fputs("<ul>\n",stdout);\r
+       fputs("<li><a href=\"/ott/\">The OTT mirror</a><ul><li><a href=\"/ottmirror/\">Source and instructions</a></li></ul></li>\n",stdout);\r
+       if(discovered)\r
+               fputs("<li><a href=\"/ongoing.htm\">ONGoing story</a></li>\n<ul><li><a href=\"/ongmeta.htm\">The discovery</a></li><li><a href=\"/generator\">Object generator online</a></li>\n<li><a href=\"/ct-if\">Chronotransponder test interface</a></li></ul>\n",stdout);\r
+       fputs("<li><a href=\"/aftertime\">time after Time</a><ul>\n",stdout);\r
+       fputs("<li><a href=\"/aftertime/viewer?story=t1i\"><span class=\"ni\">The viewer</a></li>\n",stdout);\r
+       fputs("<li><a href=\"/silentbot/list\">The Silent Chronotransponder</a></li></ul></li>\n",stdout);\r
+       fputs("<li>Auto-manip and enhance<ul><li><a href=\"/pro/npb/npb.htm\">NewpixbOTTification</a></li>\n",stdout);\r
+       fputs("<li><a href=\"/pro/npb/403.htm\">403fication</a></li>\n",stdout);\r
+       fputs("<li><a href=\"/pro/bluenh/bluenh.htm\">Bluenhancement</a></li>\n",stdout);\r
+       fputs("<li><a href=\"/pro/nofading/nofading.htm\">Un-fading</a></li>\n",stdout);\r
+       fputs("<li><a href=\"/pro/insertframe/insertframe.htm\">Hidden frames</a></li></ul></li>\n",stdout);\r
+       fputs("<li><a href=\"/script\">Userscripts</a></li>\n",stdout);\r
+       fputs("<li><a href=\"/ongtext?b=on\">ONGtext generator</a></li>\n",stdout);\r
+       fputs("<li>Bots<ul>\n<li><a href=\"/bothasar_s/\">bothasar_s</a></li>\n",stdout);\r
+       fputs("<li><a href=\"/bothasar_t/\">bothasar_t</a></li>\n",stdout);\r
+       fputs("<li><a href=\"/bothasar_p/\">bothasar_p</a></li>\n",stdout);\r
+       fputs("<li>lmjbot</li>\n",stdout);\r
+       fputs("<li><a href=\"/silentbot/\">SilentBot</a></li>\n</ul></li>\n",stdout);\r
+       fputs("<li><a href=\"/staf/\">SilentTimer action figure</a></li>\n",stdout);\r
+       fputs("<li><a href=\"/mrobsniped/\">mr<img src=\"/img/mrob27.gif\" alt=\"o\">bdex decoding</a></li>\n",stdout);\r
+       fputs("</ul>\n",stdout);\r
+       fputs("Redundant:<br>\n",stdout);\r
+       fputs("<div style=\"margin:20px; margin-top:5px\">\n",stdout);\r
+       printf("<form method=\"post\" action=\"/redundant?spoiler=%s\">\n",open?"show":"hide");\r
+       printf("<input type=\"hidden\" name=\"n\" value=\"%hu\">\n",n+1);\r
+       if(discovered)\r
+               fputs("<input type=\"hidden\" name=\"d\" value=\"1\">\n",stdout);\r
+       printf("<b>Spoiler: </b><input class=\"pk\" type=\"submit\" value=\"%s\"><br>\n",open?"Show":"Hide");\r
+       \r
+       if(!open)\r
+       {\r
+               fputs("<input type=\"hidden\" name=\"o\" value=\"1\">\n",stdout);\r
+               \r
+               if(n==REDBUTTON)\r
+               {\r
+                       fputs("</form>\n",stdout);\r
+                       fputs("<form method=\"get\" action=\"/click\"><br>\n",stdout);\r
+                       fputs("N = <input class=\"pt\" type=\"text\" name=\"n\" size=\"3\"><br>\n",stdout);\r
+                       fputs("This button was supposed to be red: <input class=\"pk\" type=\"submit\" value=\"DON'T CLICK!\">\n",stdout);\r
+                       fputs("</form><br>\n",stdout);\r
+                       fputs("<form method=\"get\" action=\"/pro/bluenh/nh.png\"><br>\n",stdout);\r
+                       fputs("Also, enhance: <input class=\"pt\" type=\"text\" name=\"i\" size=\"3\"> <input class=\"pk\" type=\"submit\" value=\"ENHANCE!\">\n",stdout);\r
+               }\r
+               else\r
+               {\r
+                       fputs("<img src=\"/img/redunbot.jpg\" alt=\"I told U was redundant. Y U no believe me?\" border=\"0\"><br><br>\n",stdout);\r
+                       fputs("<img src=\"/img/botmlogo2.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"1\"><br>\n",stdout);\r
+                       printf("botmlogo2.png (1.24 KiB) Viewed %hu times<br>\n",n+1190);\r
+                       fputs("<img src=\"/img/redunbot.jpg\" alt=\"I told U was redundant. Y U no believe me?\" border=\"1\"><br>\n",stdout);\r
+                       printf("redunbot.jpg (83.88 KiB) Viewed %hu times<br>\n",n+1190);\r
+               }\r
+       }\r
+       \r
+       fputs("</form></div></body></html>\n",stdout);\r
+       \r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/update.c b/update.c
new file mode 100644 (file)
index 0000000..04d1afa
--- /dev/null
+++ b/update.c
@@ -0,0 +1,71 @@
+// update.c (1190.bicyclesonthemoon.info/aftertime/remove)\r
+// update demustarded frames to viewer\r
+// 17.04.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define ONG_STATE_PATH "/eizm/data/aftertime/bftf/ongstate"\r
+#define FRAME_PRINTF   "/eizm/data/aftertime/bftf/%hu.png"\r
+#define ONGED_PRINTF   "/eizm/www/time/aftertime/bftf/bftf-%04hu.png"\r
+#define CP_PATH        "/bin/cp"\r
+\r
+#include <stdio.h>\r
+#include <unistd.h>\r
+#include <stdlib.h>\r
+#include <sys/wait.h>\r
+\r
+pid_t sub;\r
+int r;\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+       FILE *file;\r
+       unsigned short i,ongFrame;\r
+       unsigned char ongState;\r
+       char framePath[64];\r
+       char ongedPath[64];\r
+       \r
+       file=fopen(ONG_STATE_PATH,"rt");\r
+       if(file!=NULL)\r
+       {\r
+               fscanf(file,"%hhu %hu",&ongState,&ongFrame);\r
+               fclose(file);\r
+       }\r
+       else\r
+       {\r
+               ongState=0;\r
+               ongFrame=0;\r
+       }\r
+       \r
+       for(i=0;i<=ongFrame;++i)\r
+       {\r
+               \r
+               sprintf(framePath,FRAME_PRINTF,i);\r
+               sprintf(ongedPath,ONGED_PRINTF,i);\r
+               \r
+               sub=fork();\r
+               if(!sub)\r
+               {\r
+                       r=execl(CP_PATH,CP_PATH,framePath,ongedPath,(char *)0);\r
+                       exit(r);\r
+               }\r
+               waitpid(sub,&r,0);\r
+               if(r)\r
+                       return r;\r
+       }\r
+       \r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/view.awk b/view.awk
new file mode 100644 (file)
index 0000000..e14feea
--- /dev/null
+++ b/view.awk
@@ -0,0 +1,57 @@
+#// view.awk\r
+#// insert text\r
+#// 03.09.2014\r
+#// \r
+#// Copyright (C) 2015  Balthasar Szczepański\r
+#// \r
+#// This program is free software: you can redistribute it and/or modify\r
+#// it under the terms of the GNU Affero General Public License as\r
+#// published by the Free Software Foundation, either version 3 of the\r
+#// License, or (at your option) any later version.\r
+#// \r
+#// This program is distributed in the hope that it will be useful,\r
+#// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+#// GNU Affero General Public License for more details.\r
+#// \r
+#// You should have received a copy of the GNU Affero General Public License\r
+#// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+\r
+###reusedfrommirror;\r
+{\r
+       if ($0 ~ /^###sig&/)\r
+       {\r
+               split ($0 ,arr,"&")\r
+               system("cat " sig arr[2])\r
+       }\r
+       else if ($0 ~ /^###inf&/)\r
+       {\r
+               split ($0 ,arr,"&")\r
+               system("cat " otterinf arr[2])\r
+       }\r
+       else if ($0 ~ /^###prev/)\r
+       {\r
+               print left\r
+       }\r
+       else if ($0 ~ /^###next/)\r
+       {\r
+               print right\r
+       }\r
+       else if ($0 ~ /^###links/)\r
+       {\r
+               system ("cat " links);\r
+       }\r
+       else if ($0 ~ /^###info/)\r
+       {\r
+               print info;\r
+       }\r
+       else if ($0 ~ /^###title/)\r
+       {\r
+               print title;\r
+       }\r
+       else\r
+       {\r
+               print $0\r
+       }\r
+};\r
diff --git a/view.c b/view.c
new file mode 100644 (file)
index 0000000..e2f71c4
--- /dev/null
+++ b/view.c
@@ -0,0 +1,110 @@
+// view.c (1190.bicyclesonthemoon.info/ongoing.png(new) 1190.bicyclesonthemoon.info/ongframe.png)\r
+// the frame\r
+// 06.04.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define ONG_STATE_PATH "/eizm/data/aftertime/bftf/ongstate"\r
+#define CFRT_PATH      "/ongoing/cfrt.png"\r
+#define FRAME_PRINTF   "/ongoing/bftf-%04hu.png"\r
+\r
+\r
+#include <cgi.h>\r
+#include <stdio.h>\r
+#include <sys/stat.h>\r
+\r
+s_cgi *cgi;\r
+\r
+int main (int argc, char *argv[]);\r
+// int sendfile(char *path);\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+       FILE *file;\r
+       char *value;\r
+       char framePath[256];\r
+       unsigned short cgiFrame, ongFrame;\r
+       unsigned char ongState;\r
+       \r
+       cgi=cgiInit();\r
+       \r
+       file=fopen(ONG_STATE_PATH,"rt");\r
+       if(file==NULL)\r
+       {\r
+               cgiRedirect(CFRT_PATH);\r
+               return 1;\r
+       }\r
+       fscanf(file,"%hhu %hu",&ongState,&ongFrame);\r
+       fclose(file);\r
+       \r
+       value=cgiGetValue(cgi,"f");\r
+       if(value!=NULL)\r
+               sscanf(value,"%hu",&cgiFrame);\r
+       else\r
+               cgiFrame=ongFrame;\r
+       \r
+       if(ongState==0||cgiFrame>ongFrame)\r
+       {\r
+               cgiRedirect(CFRT_PATH);\r
+               return 0;\r
+       }\r
+       if(cgiFrame==ongFrame&&ongState==1&&cgiGetValue(cgi,"n")==NULL)\r
+       {\r
+               file=fopen(ONG_STATE_PATH,"wt");\r
+               if(file!=NULL)\r
+               {\r
+                       fprintf(file,"2 %hu",ongFrame);\r
+                       fclose(file);\r
+               }\r
+       }\r
+       \r
+       sprintf(framePath,FRAME_PRINTF,cgiFrame);\r
+       cgiRedirect(framePath);\r
+       return 0;\r
+       // return sendfile(framePath);\r
+}\r
+\r
+/*int sendfile(char *path)\r
+{\r
+       unsigned long p,i;\r
+       unsigned short q;\r
+       FILE *file;\r
+       struct stat st;\r
+       unsigned char buf[1024];\r
+       \r
+       file=fopen(path,"rb");\r
+       if(file==NULL)\r
+               return 1;\r
+       fstat(fileno(file),&st);\r
+       p=st.st_size/1024;\r
+       q=st.st_size%1024;\r
+       \r
+       printf("Content-Length: %lu\n",(unsigned long)(st.st_size));\r
+       printf("Content-type: image/png\n\n");\r
+       \r
+       for(i=0;i<p;++i)\r
+       {\r
+               fread(buf,1,1024,file);\r
+               fwrite(buf,1,1024,stdout);\r
+       }\r
+       if(q!=0)\r
+       {\r
+               fread(buf,1,q,file);\r
+               fwrite(buf,1,q,stdout);\r
+       }\r
+       fclose(file);\r
+       return 0;\r
+}*/
\ No newline at end of file
diff --git a/viewpage.c b/viewpage.c
new file mode 100644 (file)
index 0000000..ace6a2a
--- /dev/null
@@ -0,0 +1,182 @@
+// view.c (1190.bicyclesonthemoon.info/ongoing.htm)\r
+// the bftf viewer\r
+// 08.04.2015\r
+// \r
+// Copyright (C) 2015  Balthasar Szczepański\r
+// \r
+// This program is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU Affero General Public License as\r
+// published by the Free Software Foundation, either version 3 of the\r
+// License, or (at your option) any later version.\r
+// \r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU Affero General Public License for more details.\r
+// \r
+// You should have received a copy of the GNU Affero General Public License\r
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+#define TIMEFRAME 12\r
+#define ONG_STATE_PATH "/eizm/data/aftertime/bftf/ongstate"\r
+#define AWK_ENHANCE    "/eizm/pro/ong1/enhance.awk"\r
+#define ENHANCE_PATH   "/eizm/mem/ong1/enh/%04hu"\r
+#define REDIRECT       "/aftertime/viewer?story=bftf"\r
+\r
+#include <cgi.h>\r
+#include <time.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+s_cgi *cgi;\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+       time_t now;\r
+       struct tm *nowS;\r
+       unsigned char h,m,s;\r
+       unsigned long d;\r
+       char *value;\r
+       char *bb;\r
+       char *spoiler;\r
+       char *enhance;\r
+       unsigned short cgiFrame, ongFrame;\r
+       unsigned char ongState;\r
+       char enhancepath [32];\r
+       FILE *file;\r
+       char alttext[256];\r
+       char redirect[256];\r
+       \r
+       cgi=cgiInit();\r
+       \r
+       now=time(NULL);\r
+       nowS=localtime(&now);\r
+       d=(TIMEFRAME*3600-(nowS->tm_sec+60*nowS->tm_min+3600*(nowS->tm_hour%TIMEFRAME)))%(3600*TIMEFRAME);\r
+       s=(unsigned char)(d%60);\r
+       m=(unsigned char)((d/60)%60);\r
+       h=(unsigned char)(d/3600);\r
+       \r
+       file=fopen(ONG_STATE_PATH,"rt");\r
+       if(file!=NULL)\r
+       {\r
+               fscanf(file,"%hhu %hu",&ongState,&ongFrame);\r
+               fclose(file);\r
+       }\r
+       else\r
+               ongFrame=0;\r
+       \r
+       value=cgiGetValue(cgi,"f");\r
+       if(value!=NULL)\r
+               sscanf(value,"%hu",&cgiFrame);\r
+       else\r
+               cgiFrame=ongFrame;\r
+       bb=cgiGetValue(cgi,"b");\r
+       spoiler=cgiGetValue(cgi,"s");\r
+       enhance=cgiGetValue(cgi,"e");\r
+#if defined REDIRECT\r
+       strcpy(redirect,REDIRECT);\r
+       if(value!=NULL)\r
+               sprintf(redirect+strlen(redirect),"&f=%s",value);\r
+       if(bb!=NULL)\r
+               sprintf(redirect+strlen(redirect),"&b=%s",bb);\r
+       if(enhance!=NULL)\r
+               sprintf(redirect+strlen(redirect),"&n=%s",enhance);\r
+       cgiRedirect(redirect);\r
+       return 0;\r
+#endif\r
+       \r
+       if(cgiFrame>ongFrame)\r
+       {\r
+               strcpy(alttext,"You aren't supposed to see this frame now.");\r
+               printf("Status: 404 Not Found (Wait for it.)\n");\r
+       }\r
+       else if(cgiFrame>=564)\r
+               strcpy(alttext,"I'd highly recommend following the first commandment ...again.");\r
+       else if(cgiFrame>549)\r
+               strcpy(alttext,"...");\r
+       else if(cgiFrame==549)\r
+               strcpy(alttext,"I'd highly re");\r
+       else if(cgiFrame>28)\r
+               strcpy(alttext,"I'd highly recommend following the first commandment.");\r
+       else\r
+               strcpy(alttext,"I'd highly recommend following the first commandment. It may not look very related now. BUT IT WILL.");\r
+       \r
+       sprintf(enhancepath,ENHANCE_PATH,cgiFrame);\r
+       \r
+       printf("Content-type: text/html\n\n");\r
+       \r
+       puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\">\n");\r
+       puts("<html lang=\"en\"><head>\n");\r
+       puts("<title>ONGoing &bull; Bicycles on the Moon</title>\n");\r
+       puts("<meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-2\">\n");\r
+       puts("<link rel=\"icon\" type=\"image/png\" href=\"/img/favicon.png\">\n");\r
+       puts("<link rel=\"stylesheet\" href=\"/css/botm.css\">\n");\r
+       puts("</head><body><center>\n");\r
+       puts("<a href=\"/\"><img src=\"/img/botmlogo4.png\" alt=\"1190.bicyclesonthemoon.info\" border=\"0\"></a><br>\n");\r
+       printf("<H1>%hu</H1>\n",cgiFrame);\r
+       puts("<table cellspacing=\"0\" cellpadding=\"0\"><tr><td colspan=\"4\" width=\"414\">\n");\r
+       if(value!=NULL)\r
+               printf("<img src=\"/ongoing.png?f=%hu\" alt=\"the frame, a png file\" title=\"%s\" border=\"2\"><br>\n",cgiFrame,alttext);\r
+       else\r
+               printf("<a href=\"/ongoing.htm?f=%hu\"><img src=\"/ongoing.png\" alt=\"the frame, a png file\" title=\"%s\" border=\"2\"></a><br>\n",ongFrame,alttext);\r
+       puts("</td><tr align=\"right\"><td colspan=\"4\" width=\"414\">");\r
+       \r
+       if(d!=0)\r
+               printf("<tt><b class=\"%s\">%02hhu</b>:<b class=\"%s\">%02hhu</b>:<b class=\"%s\">%02hhu</b></tt>\n",ongState>=2?"br":"ni",h,ongState>=2?"br":"ni",m,ongState>=2?"br":"ni",s);\r
+       else\r
+               printf("<tt><b class=\"%s\">00</b>:<b class=\"%s\">00</b>:<b class=\"%s\">NG</b></tt>\n",ongState>=2?"br":"ni",ongState>=2?"br":"ni",ongState>=2?"br":"ni");\r
+       \r
+       // printf("<tt><b class=\"%s\">E</b>:<b class=\"%s\">E</b>:<b class=\"%s\">E</b></tt>\n",ongState>=2?"br":"ni",ongState>=2?"br":"ni",ongState>=2?"br":"ni");\r
+       \r
+       puts("</td></tr>\n");\r
+       if(value!=NULL)\r
+       {\r
+               puts("<tr align=\"center\"><td width=\"104\"><a href=\"/ongoing.htm?f=0\">| &lt; 0</a></td>\n");\r
+               if(cgiFrame>0)\r
+                       printf("<td width=\"103\"><a href=\"/ongoing.htm?f=%hu\">&lt; %hu</a>\n",cgiFrame-1,cgiFrame-1);\r
+               else\r
+                       puts("<td width=\"103\"></td>\n");\r
+               if(cgiFrame<ongFrame)\r
+                       printf("<td width=\"103\"><a href=\"/ongoing.htm?f=%hu\">%hu &gt;</a>\n",cgiFrame+1,cgiFrame+1);\r
+               else\r
+                       puts("<td  width=\"103\"></td>\n");\r
+               printf("<td width=\"104\"><a href=\"/ongoing.htm?f=%hu\">%hu &gt;|</a></tr>\n",ongFrame,ongFrame);\r
+               if(cgiFrame<=ongFrame)\r
+               {\r
+                       if(bb!=NULL)\r
+                       {\r
+                               printf("<tr><td colspan=\"4\"><code>[url=http://1190.bicyclesonthemoon.info/ongoing.htm?f=%hu][img]http://1190.bicyclesonthemoon.info/ongoing/bftf-%04hu.png[/img][/url]",cgiFrame,cgiFrame);\r
+                               if(spoiler!=NULL)\r
+                                       printf("[spoiler]%s[/spoiler]",alttext);\r
+                               printf("</code></td></tr>\n");\r
+                               if(spoiler!=NULL && ongFrame==cgiFrame)\r
+                                       printf("<tr align=\"center\"><td colspan=\"4\"><form method=\"post\" action=\"/ongoing/pleaseongthis\">[<input type=\"submit\" class=\"hl\" value=\"ONG this for me\">]</form></td></tr>\n");\r
+                               if(spoiler==NULL)\r
+                                       printf("<tr align=\"center\"><td colspan=\"4\">[<a href=\"/ongoing.htm?f=%hu&amp;b=1&amp;s=1\">spoiler</a>]</td></tr>\n",cgiFrame);\r
+                       }\r
+                       else\r
+                               printf("<tr align=\"center\"><td colspan=\"4\">[<a href=\"/ongoing.htm?f=%hu&amp;b=1\">bbcode</a>]</td></tr>\n",cgiFrame);\r
+                       file=fopen(enhancepath,"rt");\r
+                       if(file!=NULL)\r
+                       {\r
+                               if(enhance==NULL)\r
+                                       printf("<tr align=\"center\"><td colspan=\"4\">[<a href=\"/ongoing.htm?f=%hu&amp;e=1\">enhance</a>]</td></tr>\n",cgiFrame);\r
+                               else\r
+                               {\r
+                                       puts("<tr align=\"center\"><td colspan=\"4\">");\r
+                                       while(fgets(alttext,255,file)!=NULL)\r
+                                               puts(alttext);\r
+                                       puts("</td></tr>\n");\r
+                               }\r
+                               fclose(file);\r
+                       }\r
+               }\r
+               puts("<tr align=\"center\"><td colspan=\"4\"><form method=\"get\" action=\"/ongoing.htm\">go to frame:<input class=\"pt\" type=\"text\" name=\"f\" size=\"4\"><input class=\"pk\" type=\"submit\" value=\"GO\"></form></td></tr>\n");\r
+       }\r
+       \r
+       puts("</table>\n");\r
+       puts("<a href=\"/\">1190.bicyclesonthemoon.info</a>\n");\r
+       puts("</center></body></html>\n");\r
+       \r
+       return 0;\r
+}
\ No newline at end of file
diff --git a/www/info.htm b/www/info.htm
new file mode 100644 (file)
index 0000000..ceb348d
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">\r
+<html lang="en"><head>\r
+<title>Chronotransponder test interface &bull; Bicycles on the Moon</title>\r
+<meta http-equiv="Content-type" content="text/html; charset=UTF-8">\r
+<link rel="icon" type="image/png" href="/img/favicon.png">\r
+<link rel="stylesheet" href="/css/botm.css">\r
+<script type="text/javascript" src="/ott/prosilver/template/forum_fn.js"></script>\r
+<!-- <script type="text/javascript" src="/ott/prosilver/template/styleswitcher.js" ></script> -->\r
+\r
+</head><body><a href="/"><img src="/img/botmlogo2.png" alt="1190.bicyclesonthemoon.info" border="0"></a>\r
+<h1>Chronotransponder test interface</h1>\r
+###info\r
+<a href="/">1190.bicyclesonthemoon.info</a></body></html>\r
diff --git a/www/npb.htm b/www/npb.htm
new file mode 100644 (file)
index 0000000..2db3d27
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
+<html lang="pl">
+       <head>
+               <title>It's NewpixbOTTification time! &bull; Bicycles on the Moon</title>
+               <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
+               <link rel="stylesheet" href="/css/botm.css">
+               <link rel="icon" type="image/png" href="/img/favicon.png"/>
+       </head>
+       <body>
+               <a href="/"><img src="/img/botmlogo2.png" alt="1190.bicyclesonthemoon.info" border="0"></a>
+               <h1>It's NewpixbOTTification time!</h1>
+               <form method="post" action="/ongoing/npb">
+                       NewpixbOTTify by URL<br>
+                       URL of image:
+                       <input class="pt" type="text" name="inpix">
+                       <input class="pk" type="submit" value="NewpixbOTTify!">
+               </form>
+               <br>
+               <form method="post" action="/ongoing/npb" enctype="multipart/form-data">
+                       NewpixbOTTify by file upload<br>
+                       Upload the image:
+                       <input class="pt" type="file" name="inpix">
+                       <input class="pk" type="submit" value="NewpixbOTTify!">
+               </form>
+               <br>
+               Source code available at <a href="svn://bicyclesonthemoon.info/npb">svn://bicyclesonthemoon.info/npb</a> (use "e" to login) or <a href="http://1190.bicyclesonthemoon.info/pro/npb">http://1190.bicyclesonthemoon.info/pro/npb</a>.
+               
+       </body>
+</html>
diff --git a/www/post.htm b/www/post.htm
new file mode 100644 (file)
index 0000000..7bd63bb
--- /dev/null
@@ -0,0 +1,160 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">\r
+<html lang="en"><head>\r
+<title>Chronotransponder test interface &bull; Bicycles on the Moon</title>\r
+<meta http-equiv="Content-type" content="text/html; charset=UTF-8">\r
+<link rel="icon" type="image/png" href="/img/favicon.png">\r
+<link rel="stylesheet" href="/css/botm.css">\r
+<!-- Javascript copied from the fora. -->\r
+<script type="text/javascript" src="/ott/prosilver/template/forum_fn.js"></script>\r
+<!-- <script type="text/javascript" src="/ott/prosilver/template/styleswitcher.js" ></script> -->\r
+\r
+</head><body><a href="/"><img src="/img/botmlogo2.png" alt="1190.bicyclesonthemoon.info" border="0"></a>\r
+<h1>Chronotransponder test interface</h1>\r
+<form method="post" action="/ct-if-p" id="postform">\r
+###debug\r
+###future\r
+<script type="text/javascript">\r
+// <![CDATA[\r
+       var form_name = 'postform';\r
+       var text_name = 'message';\r
+       var load_draft = false;\r
+       var upload = false;\r
+\r
+       // Define the bbCode tags\r
+       var bbcode = new Array();\r
+       var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]', '[bibliography]', '[/bibliography]', '[center]', '[/center]', '[cite]', '[/cite]', '[imath]', '[/imath]', '[math]', '[/math]', '[right]', '[/right]', '[s]', '[/s]', '[spoiler]', '[/spoiler]', '[sub]', '[/sub]', '[sup]', '[/sup]');\r
+       var imageTag = false;\r
+\r
+       // Helpline messages\r
+       var help_line = {\r
+               b: 'Bold text: [b]text[/b]',\r
+               i: 'Italic text: [i]text[/i]',\r
+               u: 'Underline text: [u]text[/u]',\r
+               q: 'Quote text: [quote]text[/quote]',\r
+               c: 'Code display: [code]code[/code]',\r
+               l: 'List: [list]text[/list]',\r
+               o: 'Ordered list: [list=]text[/list]',\r
+               p: 'Insert image: [img]http://image_url[/img]',\r
+               w: 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]',\r
+               a: 'Inline uploaded attachment: [attachment=]filename.ext[/attachment]',\r
+               s: 'Font colour: [color=red]text[/color]  Tip: you can also use color=#FF0000',\r
+               f: 'Font size: [size=85]small text[/size]',\r
+               y: 'List: Add list element',\r
+               d: 'Flash: [flash=width,height]http://url[/flash]'\r
+               \r
+                       ,cb_22: ''\r
+               \r
+                       ,cb_24: ''\r
+               \r
+                       ,cb_26: ''\r
+               \r
+                       ,cb_28: 'Inserts an inline block of TeX math.'\r
+               \r
+                       ,cb_30: 'Adds a block of TeX math (not inline)'\r
+               \r
+                       ,cb_32: ''\r
+               \r
+                       ,cb_34: 'strike through'\r
+               \r
+                       ,cb_36: 'hides spoilers'\r
+               \r
+                       ,cb_38: 'subscript'\r
+               \r
+                       ,cb_40: 'superscript'\r
+               \r
+       }\r
+\r
+       var panels = new Array('options-panel', 'attach-panel', 'poll-panel');\r
+       var show_panel = 'options-panel';\r
+\r
+\r
+// ]]>\r
+</script>\r
+\r
+<script type="text/javascript" src="/ongoing/editor.js"></script>\r
+###HTML\r
+<div class="pl">\r
+       <div class="pls">Send a message</div>\r
+###wrong\r
+       <div class="plw">\r
+               <div class="le">\r
+                       <table cellpadding="0" cellspacing="0" border="0">\r
+                       <tr><td><b>Subject: </b></td><td>\r
+###subject\r
+                       </td></tr><tr><td><b>Name: </b></td><td>\r
+###username\r
+                       </td></tr>\r
+###forcetime2\r
+                       <tr><td><b>Time: </b></td><td>\r
+###time\r
+                       </td></tr><tr><td><b>Action: </b></td><td>\r
+                               <input type="submit" tabindex="7" name="Preview" value="Preview" class="pk" >\r
+                               <input type="submit" tabindex="8" name="post" value="Submit" class="pk" >\r
+###forcetime1\r
+                       </td></tr></table>\r
+               </div>\r
+               <div>\r
+                       <input type="button" class="pk" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" title="Bold text: [b]text[/b]" >\r
+                       <input type="button" class="pk" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onclick="bbstyle(2)" title="Italic text: [i]text[/i]" >\r
+                       <input type="button" class="pk" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onclick="bbstyle(4)" title="Underline text: [u]text[/u]" >\r
+                       <input type="button" class="pk" name="addbbcode34" value="s" onclick="bbstyle(34)" title="strike through" >\r
+                       <input type="button" class="pk" name="addbbcode38" value="sub" onclick="bbstyle(38)" title="subscript" >\r
+                       <input type="button" class="pk" name="addbbcode40" value="sup" onclick="bbstyle(40)" title="superscript" >\r
+                       <!-- <br> -->\r
+                       <input type="button" class="pk" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px" onclick="bbstyle(6)" title="Quote text: [quote]text[/quote]" >\r
+                       <input type="button" class="pk" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onclick="bbstyle(8)" title="Code display: [code]code[/code]" >\r
+                       <input type="button" class="pk" accesskey="l" name="addbbcode10" value="List" style="width: 40px" onclick="bbstyle(10)" title="List: [list]text[/list]" >\r
+                       <input type="button" class="pk" accesskey="o" name="addbbcode12" value="List=" style="width: 40px" onclick="bbstyle(12)" title="Ordered list: [list=]text[/list]" >\r
+                       <input type="button" class="pk" accesskey="y" name="addlistitem" value="[*]" style="width: 40px" onclick="bbstyle(-1)" title="List item: [*]text[/*]" >\r
+                       <br>\r
+###img\r
+                       <!-- <input type="button" class="pk" accesskey="p" name="addbbcode14" value="Img" style="width: 40px" onclick="bbstyle(14)" title="Insert image: [img]http://image_url[/img]" > -->\r
+                       <input type="button" class="pk" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onclick="bbstyle(16)" title="Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]" >\r
+                       <input type="button" class="pk" name="addbbcode24" value="center" onclick="bbstyle(24)" title="" >\r
+                       <input type="button" class="pk" name="addbbcode32" value="right" onclick="bbstyle(32)" title="" >\r
+                       <input type="button" class="pk" name="addbbcode36" value="spoiler" onclick="bbstyle(36)" title="hides spoilers" >\r
+                       <!-- <br> -->\r
+                       <b>Font size: </b>\r
+                       <select name="addbbcode20" class="pk" onchange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]');this.form.addbbcode20.selectedIndex = 2;" title="Font size: [size=85]small text[/size]">\r
+                               <option value="50">Tiny</option>\r
+                               <option value="85">Small</option>\r
+                               <option value="100" selected="selected">Normal</option>\r
+                               <option value="150">Large</option>\r
+                               <option value="200">Huge</option>\r
+                       </select>\r
+                       <input type="button" class="pk" name="bbpalette" id="bbpalette" value="Font colour" onclick="change_palette();" title="Font colour: [color=red]text[/color]  Tip: you can also use color=#FF0000">\r
+###hidden\r
+               </div>\r
+               <div id="colour_palette" class="le" style="display: none;">\r
+               <b>Font colour:</b><br>\r
+                       <script type="text/javascript">\r
+                       // <![CDATA[\r
+                               function change_palette()\r
+                               {\r
+                                       <!-- dE('colour_palette'); -->\r
+                                       e = document.getElementById('colour_palette');\r
+                                       \r
+                                       if (e.style.display == 'block')\r
+                                       {\r
+                                               e.style.display = 'none'\r
+                                               document.getElementById('bbpalette').value = 'Font colour';\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               e.style.display = 'block'\r
+                                               document.getElementById('bbpalette').value = 'Hide font colour';\r
+                                       }\r
+                               }\r
+\r
+                               colorPalette('h', 15, 10);\r
+                       // ]]>\r
+                       </script>\r
+               </div>\r
+       </div>\r
+       <div class="plt">Write here:</div>\r
+###message\r
+       \r
+</div>\r
+</form>\r
+###back\r
+<br><br><a href="/">1190.bicyclesonthemoon.info</a></body></html>\r