commit 524a12f184b881a6d3c2b4769672c54cd5159875 Author: flashwave Date: Sun Feb 6 17:08:09 2022 +0100 AJAX Chat diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f469da --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +[Tt]humbs.db +[Dd]esktop.ini +.DS_Store +public/lib/config-db.php diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..629c6c1 --- /dev/null +++ b/LICENCE @@ -0,0 +1,662 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + Copyright (C) 2007-2008 Sebastian Tschan (blueimp) + Copyright (C) 2008-2014 Phil Nicolcev (frug) + Copyright (C) 2015, 2022 flashwave + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1dca134 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# AJAX Chat + +This is/was our fork of [AJAX Chat](https://github.com/frug/AJAX-Chat) from back before the Sock Chat days. + +I'm pretty sure it's based on AJAX Chat 0.8.4 but I'm not sure. It's probably kind of impossible to run this fork yourself, not that you'd want to anyway. + +Unfortunately AGPL requires I use the same licence for my additions so you'll have to deal with that. Also AGPL requires me to include the full licence text, which AJAX Chat didn't actually do itself so I'll do an attempt at recreating it. + +There's probably a bunch of copyright violations in this repository but I don't really care. + +I'm providing this pretty much as-is, aside from the adjustments I will be making to make this run on [ajaxchat.flashii.net](https://ajaxchat.flashii.net) for preservation of the Classic experience. If you review some of the Language used you'll understand this disclaimer, however historical accuracy is of utmost importance. diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..c984b68 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,7 @@ +RewriteEngine on +Options +FollowSymLinks +Options -Indexes +RewriteRule ^logs$ index.php?view=logs +RewriteRule ^mobile$ index.php?view=mobile +RewriteRule ^chat$ index.php +RewriteRule ^desktop$ index.php diff --git a/public/FABridge.swf b/public/FABridge.swf new file mode 100644 index 0000000..1894cf4 Binary files /dev/null and b/public/FABridge.swf differ diff --git a/public/css/Black.ajaxchat.css b/public/css/Black.ajaxchat.css new file mode 100644 index 0000000..df8e554 --- /dev/null +++ b/public/css/Black.ajaxchat.css @@ -0,0 +1,98 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @author Philip Nicolcev + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +@import url('meta.modern.ajaxchat.css'); + +@media screen,projection,handheld { + + /* Buttons */ + #content #bbCodeContainer input, #content #logoutChannelContainer input, #content #submitButton, #loginForm #loginButton { + background-color:#000; + color:#f0f0f0; + border: 1px solid #808080; + background-image: linear-gradient(to bottom, #222, #000); + } + #content select, #loginForm select, #loginForm input, #content textarea { + background-color:#000; + color:#fafafa; + border: 1px solid #808080; + } + + /* Status Icon */ + #content #statusIconContainer { + background-image: url('../images/loading-sprite.png'); + } + #content .statusContainerOff { + background-position: 0px 0px; + } + #content .statusContainerOn { + background-position: 0px -22px; + } + #content .statusContainerAlert { + background-position: 0px -44px; + } + + /* Other Theme Elements */ + #loginContent { + background-color:#000; + color:#FFF; + } + #loginContent h1 { + color:#FFF; + } + #loginContent a { + color:#FFF; + } + #loginContent input, #loginContent select { + background-color:#212121; + color:#FFF; + } + #loginContent #errorContainer { + color:red; + } + #content { + background-color:#000; + color:#FFF; + } + #content h1 { + color:#FFF; + } + #content a { + color:#FFF; + } + #content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #colorCodesContainer, #content textarea { + border-color:gray; + background-color:#000; + } + #content #colorCodesContainer a { + border-color:black; + } + #content #optionsContainer input { + background-color:transparent; + } + #content .rowEven { + background-color:#212121; + } + #content .rowOdd { + background-color:#000; + } + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#1E90FF; + } + #content #chatList .deleteSelected { + border-color:red; + } + #content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + background-color:#212121; + color:#FFF; + } +} \ No newline at end of file diff --git a/public/css/Blue.ajaxchat.css b/public/css/Blue.ajaxchat.css new file mode 100644 index 0000000..5c3c3b5 --- /dev/null +++ b/public/css/Blue.ajaxchat.css @@ -0,0 +1,106 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @author Philip Nicolcev + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + * + * Blue Style by nookls + * nookls.org + */ + +@import url('meta.modern.ajaxchat.css'); + +@media screen,projection,handheld { + + /* Buttons */ + #content #bbCodeContainer input, #content #logoutChannelContainer input, #content #submitButton, #loginForm #loginButton { + background-color:#002545; + color:#f0f0f0; + border: 1px solid #808080; + background-image: linear-gradient(to bottom, #002545, #000); + background-image: -webkit-linear-gradient(top, #002545, #000); + } + #content select, #loginForm select, #loginForm input, #content textarea { + background-color:#002545; + color:#fafafa; + border: 1px solid #808080; + } + + /* Status Icon */ + #content #statusIconContainer { + background-image: url('../images/loading-sprite.png'); + } + #content .statusContainerOff { + background-position: 0px 0px; + } + #content .statusContainerOn { + background-position: 0px -22px; + } + #content .statusContainerAlert { + background-position: 0px -44px; + } + + /* Other Theme Elements */ + #loginContent { + background-color:#000; + color:#FFF; + } + #loginContent { + background-color:#002545; + color:#FFF; + } + #loginContent h1 { + color:#FFF; + } + #loginContent a { + color:#FFF; + } + #loginContent input, #loginContent select { + background-color:#002545; + color:#FFF; + } + #loginContent #errorContainer { + color:red; + } + #content { + background-color:#002545; + color:#FFF; + } + #content h1 { + color:#FFF; + } + #content a { + color:#FFF; + } + #content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #colorCodesContainer, #content textarea { + border-color:#003D8E; + background-color:#002545; + } + #content #colorCodesContainer a { + border-color:#003D8E; + } + #content #optionsContainer input { + background-color:transparent; + } + #content .rowEven { + background-color:#0D355D; + } + #content .rowOdd { + background-color:#002545; + } + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#1E90FF; + } + #content #chatList .deleteSelected { + border-color:red; + } + #content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + background-color:#0D355D; + color:#FFF; + } +} \ No newline at end of file diff --git a/public/css/Halext.ajaxchat.css b/public/css/Halext.ajaxchat.css new file mode 100644 index 0000000..dbf92bb --- /dev/null +++ b/public/css/Halext.ajaxchat.css @@ -0,0 +1,108 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + * This style is made by freakyfurball\moegami + * http://zeniea.com/ +*/ + +@import url('meta.legacy.ajaxchat.css'); + +/* +* Colors +*/ + +@media screen,projection,handheld { + + #loginContent { + background-color: #000000; + background-image: -linear-gradient(to bottom, #4c3b52, #000000); + color: #999999; + } + #loginContent h1 { + color: #98ba8c; + } + #loginContent a { + color: #9775a3; + } + #loginContent input, #loginContent select { + background-color: #312634; + color: 9775a3; + } + #loginContent #loginFormContainer #loginButton { + background-color: #312634; + color: #9775a3; + } + #loginContent #errorContainer { + color: red; + } + + #content { + background-color: #000000; + background-image: linear-gradient(to bottom, #4c3b52, #000000); + color: #999999; + } + #content h1 { + color: #FFFFFF; + } + #content a { + color: #9775a3; + } + #content input, #content select, #content textarea { + background-color: #312634; + color: #999999; + } + #content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #bbCodeContainer, #content #colorCodesContainer, #content #emoticonsContainer { + border-color: gray; + background-color: #231b26; + } + #content #statusIconContainer { + background-image: url('../images/loading-sprite.png'); + } + #content .statusContainerOff { + background-position: 0px 0px; + } + #content .statusContainerOn { + background-position: 0px -22px; + } + #content .statusContainerAlert { + background-position: 0px -44px; + } + #content #bbCodeContainer input, #content #logoutButton, #content #submitButton { + background-color: #312634; + color: #999999; + } + #content #colorCodesContainer a { + border-color: #312634; + } + #content #optionsContainer input { + background-color: transparent; + } + #content .rowEven { + background-color: #312634; + } + #content .rowOdd { + background-color: #4c3b52; + } + #content #chatList .chatBotErrorMessage { + color: red; + } + #content #chatList a { + color: #9775a3; + } + #content #chatList .delete { + background: url('../images/delete.png') no-repeat right; + } + #content #chatList .deleteSelected { + border-color: red; + } + #content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + background-color: #312634; + color: #999999; + } + #content #settingsContainer #settingsList input.playback { + background: url('../images/playback.png') no-repeat; + } +} \ No newline at end of file diff --git a/public/css/Legacy.ajaxchat.css b/public/css/Legacy.ajaxchat.css new file mode 100644 index 0000000..c27ade7 --- /dev/null +++ b/public/css/Legacy.ajaxchat.css @@ -0,0 +1,104 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +@import url('meta.legacy.ajaxchat.css'); + +/* + * Colors + */ + +@media screen,projection,handheld { + + #loginContent { + background-color:#000; + color:#FFF; + } + #loginContent h1 { + color:#FFF; + } + #loginContent a { + color:#FFF; + } + #loginContent input, #loginContent select { + background-color:#212121; + color:#FFF; + } + #loginContent #loginFormContainer #loginButton { + background-color:#212121; + color:#FFF; + } + #loginContent #errorContainer { + color:red; + } + + #content { + background-color:#000; + color:#FFF; + } + #content h1 { + color:#FFF; + } + #content a { + color:#FFF; + } + #content input, #content select, #content textarea { + background-color:#212121; + color:#FFF; + } + #content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #bbCodeContainer, #content #colorCodesContainer, #content #emoticonsContainer { + border-color:gray; + background-color:#000; + } + #content #statusIconContainer { + background-image: url('../images/loading-sprite.png'); + } + #content .statusContainerOff { + background-position: 0px 0px; + } + #content .statusContainerOn { + background-position: 0px -22px; + } + #content .statusContainerAlert { + background-position: 0px -44px; + } + #content #bbCodeContainer input, #content #logoutButton, #content #submitButton { + background-color:#212121; + color:#FFF; + } + #content #colorCodesContainer a { + border-color:black; + } + #content #optionsContainer input { + background-color:transparent; + } + #content .rowEven { + background-color:#212121; + } + #content .rowOdd { + background-color:#000; + } + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#1E90FF; + } + #content #chatList .delete { + background:url('../images/delete.png') no-repeat right; + } + #content #chatList .deleteSelected { + border-color:red; + } + #content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + background-color:#212121; + color:#FFF; + } + #content #settingsContainer #settingsList input.playback { + background:url('../images/playback.png') no-repeat; + } +} \ No newline at end of file diff --git a/public/css/Mio.ajaxchat.css b/public/css/Mio.ajaxchat.css new file mode 100644 index 0000000..a60cdcb --- /dev/null +++ b/public/css/Mio.ajaxchat.css @@ -0,0 +1,108 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + * Style by Flashwave for Flashii.net + */ + +@import url('meta.legacy.ajaxchat.css'); + +/* + * Colors + */ + +@media screen,projection,handheld { + + #loginContent { + background-color: #FBEEFF; + color: #000; + background-image: url('../images/fade-purple.png'); + background-repeat: repeat-x; + } + #loginContent h1 { + color: #000; + } + #loginContent a { + color: #000; + } + #userNameField, #passwordField { + padding: 2px 4px 3px 4px; + border: 1px solid #AAA; + outline: none; + font-family: arial,helvetica,sans-serif; + } + #loginContent #errorContainer { + color:red; + } + + #content { + background-color: #FBEEFF; + color: #000; + background-image: url('../images/fade-purple.png'); + background-repeat: repeat-x; + } + #content h1 { + color:#306; + } + #content a { + color:#000; + } + #content textarea { + border: 1px solid #AAA; + outline: none; + font-family: arial,helvetica,sans-serif; + color:#000; + } + #content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #bbCodeContainer, #content #colorCodesContainer, #content #emoticonsContainer { + border: 1px solid #9475B2; + } + #content #statusIconContainer { + background-image: url('../images/loading-sprite.png'); + } + #content .statusContainerOff { + background-position: 0px 0px; + } + #content .statusContainerOn { + background-position: 0px -22px; + } + #content .statusContainerAlert { + background-position: 0px -44px; + } + #content #colorCodesContainer a { + border: 1px solid #9475B2; + } + #content #optionsContainer input { + background-color:transparent; + } + #content .rowEven { + background-color: #C9BBCC; + } + #content .rowOdd { + background-color: #FBEEFF; + } + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#1E90FF; + } + #content #chatList .delete { + background:url('../images/delete.png') no-repeat right; + } + #content #chatList .deleteSelected { + border-color:red; + } + #content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + background-color: #9475B2; + color: #306; + } + #content #settingsContainer #settingsList input.playback { + background:url('../images/playback.png') no-repeat; + } + + #content .user { + color: #000; + } +} \ No newline at end of file diff --git a/public/css/Nico.ajaxchat.css b/public/css/Nico.ajaxchat.css new file mode 100644 index 0000000..7cc5343 --- /dev/null +++ b/public/css/Nico.ajaxchat.css @@ -0,0 +1,136 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @author Philip Nicolcev + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +@import url('meta.modern.ajaxchat.css'); + +@media screen,projection,handheld { + + /* Buttons */ + #content #bbCodeContainer input, #content #logoutChannelContainer input, #content #submitButton, #loginForm #loginButton { + background-color:#000; + color:#f0f0f0; + border: 1px solid #808080; + background-image: linear-gradient(to bottom, #110033, #000000); + background-image: -webkit-linear-gradient(top, #110033, #000000); + } + #loginContent #loginButton { + background-color:#000; + color:#f0f0f0; + border: 1px solid #808080; + background-image: linear-gradient(to bottom, #110033, #000000); + background-image: -webkit-linear-gradient(top, #110033, #000000); + } + #loginContent input { + background-color:#000; + color:#f0f0f0; + border: 1px solid #808080; + } + #content select, #loginForm select, #loginForm input, #content textarea { + background-color:#000; + color:#fafafa; + border: 1px solid #808080; + } + + /* Status Icon */ + #content #statusIconContainer { + width: 25px; + height: 26px; + } + #content .statusContainerOff { + background-image: url('../images/linkgood.gif'); + } + #content .statusContainerOn { + background-image: url('../images/linkyellow.gif'); + } + #content .statusContainerAlert { + background-image: url('../images/linkbad.gif'); + } + + /* Other Theme Elements */ + #loginContent { + background-color:#000; + background-image:url('../images/pclouds.jpg'); + color:#FFF; + } + #loginContent h1 { + color:#FFF; + } + #loginContent a { + color:#FFF; + } + #loginContent input, #loginContent select { + background-color:#212121; + color:#FFF; + } + #loginContent #errorContainer { + color:red; + } + #content { + background-color:#000; + background-image:url('../images/pclouds.jpg'); + color:#FFF; + } + #content h1 { + color:#FFF; + } + #content a { + color:#FFF; + } + #content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #colorCodesContainer, #content textarea { + border-color:gray; + background-color:transparent; + } + #content #colorCodesContainer a { + border-color:black; + } + #content #optionsContainer input { + background-color:transparent; + } + #content .rowEven { + + } + #content .rowOdd { + + } + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#1E90FF; + } + #content #chatList .deleteSelected { + border-color:red; + } + #content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + color:#FFF; + } + + /* Username colors + #content .guest { + color: #FF9999; + } + #content .user { + color: #FFFFFF; + } + #content .moderator { + color: #AA0000; + } + #content .admin { + color: #9900CC; + } + #content .chatBot { + color: #9E8DA7; + } + #content .purple { + color: #FF9900; + } + #content .cmod { + color: #0033FF; + }*/ +} \ No newline at end of file diff --git a/public/css/Terminal.ajaxchat.css b/public/css/Terminal.ajaxchat.css new file mode 100644 index 0000000..876a868 --- /dev/null +++ b/public/css/Terminal.ajaxchat.css @@ -0,0 +1,129 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @author Philip Nicolcev + * @copyright (c) Sebastian Tschan + * @license Modified MIT License + * @link https://blueimp.net/ajax/ + */ + +@import url('meta.legacy.ajaxchat.css'); +@import url('meta.terminal.ajaxchat.css'); + +@media screen,projection,handheld { + + /* Buttons */ + #content #bbCodeContainer input, #content input, #content #submitButton, #loginForm #loginButton { + background-color:#000; + color:#00ff2b; + border: 1px solid #00ff2b; + font-family:monospace; + } + #content select, #loginForm select, #loginForm input, #content textarea { + background-color:#000; + color:#00ff2b; + border: 1px solid #00ff2b; + font-family:monospace; + } + + /* Status Icon */ + #content #statusIconContainer { + background-image: url('../images/loading-sprite.png'); + } + #content .statusContainerOff { + background-position: 0px 0px; + } + #content .statusContainerOn { + background-position: 0px -22px; + } + #content .statusContainerAlert { + background-position: 0px -44px; + } + + /* Other Theme Elements */ + #loginContent { + background-color:#000; + color:#FFF; + } + #loginContent h1 { + color:#FFF; + } + #loginContent a { + color:#FFF; + } + #loginContent input, #loginContent select { + background-color:#212121; + color:#FFF; + } + #loginContent #errorContainer { + color:red; + } + #content { + background-color:#000; + color:#00ff2b; + } + #content h1 { + color:#00ff2b; + } + #content a { + color:#00ff2b; + } + #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #colorCodesContainer, #content textarea { + border-color:#00ff2b; + background-color:#000; + } + + #content #chatList { + color:#00ff2b; + } + + #content #colorCodesContainer a { + border-color:black; + } + #content #optionsContainer input { + background-color:transparent; + } + #content .rowEven { + background-color:#000; + } + #content .rowOdd { + background-color:#000; + } + #content .guest { + text-shadow:0px 0px 5px gray; + } + #content .user { + text-shadow:0px 0px 5px #FFF; + } + #content .moderator { + text-shadow:0px 0px 5px #0A0; + } + #content .admin { + text-shadow:0px 0px 5px #A00; + } + #content .chatBot, #content .bots { + text-shadow:0px 0px 5px #9E8DA7; + } + #content .purple { + text-shadow:0px 0px 5px #824CA0; + } + #content .cmod { + text-shadow:0px 0px 5px #09F; + } + #content .donator { + text-shadow:0px 0px 5px #EE9400; + } + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#1E90FF; + } + #content #chatList .deleteSelected { + border-color:red; + } + #content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + background-color:#000; + color:#00ff2b; + } +} \ No newline at end of file diff --git a/public/css/White.ajaxchat.css b/public/css/White.ajaxchat.css new file mode 100644 index 0000000..d4ca491 --- /dev/null +++ b/public/css/White.ajaxchat.css @@ -0,0 +1,111 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + * + * Color palette inspired by phpBB style "prosilver": + * http://www.phpbb.com/ + */ + +@import url('meta.legacy.ajaxchat.css'); + +/* + * Colors + */ + +@media screen,projection,handheld { + + #loginContent { + background-color:#F9F9F9; + color:#28313F; + } + #loginContent h1 { + color:#333333; + } + #loginContent a { + color:#333333; + } + #loginContent input, #loginContent select { + background-color:#FFF; + color:#333333; + } + #loginContent #loginFormContainer #loginButton { + background-color:#F7F5F1; + color:#333333; + } + #loginContent #errorContainer { + color:red; + } + + #content { + background-color:#F9F9F9; + color:#28313F; + } + #content h1 { + color:#333333; + } + #content a { + color:#333333; + } + #content input, #content select, #content textarea { + background-color:#FFF; + color:#333333; + } + #content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #bbCodeContainer, #content #colorCodesContainer, #content #emoticonsContainer { + border-color:#105289; + background-color:#FFF; + } + #content #statusIconContainer { + background-image: url('../images/loading-sprite.png'); + } + #content .statusContainerOff { + background-position: 0px 0px; + } + #content .statusContainerOn { + background-position: 0px -22px; + } + #content .statusContainerAlert { + background-position: 0px -44px; + } + #content #bbCodeContainer input, #content #logoutButton, #content #submitButton { + background-color:#F7F5F1; + color:#333333; + } + #content #colorCodesContainer a { + border-color:black; + } + #content #optionsContainer input { + background-color:transparent; + } + #content .rowEven { + background-color:#E1EBF2; + } + #content .rowOdd { + background-color:#ECF3F7; + } + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#D31141; + } + #content #chatList .delete { + background:url('../images/delete.png') no-repeat right; + } + #content #chatList .deleteSelected { + border-color:red; + } + #content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + background-color:#E1EBF2; + color:#105289; + } + #content #settingsContainer #settingsList input.playback { + background:url('../images/playback.png') no-repeat; + } + + #content .user { + color: #000; + } +} \ No newline at end of file diff --git a/public/css/chatlogin.css b/public/css/chatlogin.css new file mode 100644 index 0000000..f9631e8 --- /dev/null +++ b/public/css/chatlogin.css @@ -0,0 +1,69 @@ +h1, h3 { + font-weight: 100; + margin: 0px; +} + +h1 { + font-size: 3em; + text-shadow: 0px 0px .5em #F1F1F1; +} + +h3 { + display: inline-block; + box-shadow: 0px 0px .5em #700; + min-width: 300px; + font-size: 15px; + padding: 2px; + margin: 10px; + background: linear-gradient(180deg, #900, #600) #700; +} + +div.copyright { + font-size: 12px; + color: #CCC; +} + +form { + margin: 10px; +} + +form input[type="text"], form input[type="password"] { + height: 18px; + width: 288px; +} + +form input[type="text"] { + border-top-left-radius: 5px; + border-top-right-radius: 5px; +} + +form input[type="submit"] { + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; + background: #404; + box-shadow: 0px 0px 1em #707 inset; + color: #FFF; + font-weight: 700; + border-color: #808; +} + +form *:not(option) { + height: 30px; + display: block; + margin: 1px auto; + width: 300px; + padding: 5px; + border: 1px #888 solid; + background: transparent; + box-shadow: 0px 0px 1em #888 inset +} + +a { + color: inherit; + text-decoration: none; + transition: text-shadow .2s; +} + +a:hover { + text-shadow: 0px 0px 1em #F1F1F1; +} \ No newline at end of file diff --git a/public/css/meta.legacy.ajaxchat.css b/public/css/meta.legacy.ajaxchat.css new file mode 100644 index 0000000..ff6b435 --- /dev/null +++ b/public/css/meta.legacy.ajaxchat.css @@ -0,0 +1,486 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +/* Import Username and Text colour CSS file */ +@import url('textcolours.ajaxchat.css'); + +/* word-wrap fix */ +* { + word-wrap: break-word !important; +} + +/* + * Borders + */ + +#content img { + border:none; +} +#content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #bbCodeContainer, #content #colorCodesContainer, #content #emoticonsContainer, #content #colorCodesContainer a { + border-width:1px; + border-style:solid; +} +#content #chatList .deleteSelected { + border-width:1px; + border-style:dotted; +} +#content #helpContainer #helpList table, #content #settingsContainer #settingsList table { + border-collapse:collapse; +} + +/* + * Fonts + */ + +#loginContent { + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:0.8em; +} +#loginContent h1 { + font-size:1.3em; + font-family:"Trebuchet MS", Verdana, Arial, sans-serif; + font-weight:bold; +} +#loginContent a { + text-decoration:none; +} +#loginContent a:hover { + text-decoration:underline; +} +#loginContent #loginRegisteredUsers { + font-size:0.8em; +} +#loginContent #copyright { + font-size:0.8em; +} + +#content { + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:0.8em; +} +#content h1 { + font-size:1.3em; + font-family:"Trebuchet MS", Verdana, Arial, sans-serif; + font-weight:bold; +} +#content h3 { + font-size:1.0em; +} +#content a { + text-decoration:none; +} +#content a:hover { + text-decoration:underline; +} +#content #copyright { + font-size:0.8em; +} +#content #chatList span.dateTime { + font-size:0.7em; +} +#content #chatList .chatBotMessage { + font-style:italic; +} +#content #chatList .chatBotErrorMessage { + font-style:italic; +} +#content #chatList .privmsg { + font-style:italic; +} +#content #chatList .action { + font-style:italic; +} +#content #chatList q { + font-variant:small-caps; +} +#content #chatList code { + font-size:1.2em; +} +#content #onlineListContainer #onlineList div { + font-size:0.9em; +} +#content #helpContainer #helpList td { + font-size:0.9em; +} +#content #helpContainer #helpList td.code { + font-style:italic; +} +#content #settingsContainer #settingsList td { + font-size:0.9em; +} + +/* + * Positioning + */ + +#loginContent { + position:absolute; + width:100%; + height:100%; +} +#loginContent #loginHeadlineContainer { + margin-left:100px; + margin-right:100px; + margin-top:100px; +} +#loginContent #loginFormContainer { + margin-left:100px; + margin-right:100px; +} +#loginContent #loginFormContainer div { + margin-bottom:7px; +} +#loginContent #loginRegisteredUsers { + padding-top:5px; +} +#loginContent #errorContainer { + margin-left:100px; + margin-right:100px; +} +#loginContent #copyright { + margin-top:20px; + margin-left:100px; + margin-right:100px; +} + +#content { + position:absolute; + width:100%; + height:100%; +} +#content #copyright { + position:absolute; + right:20px; + top:20px; +} +#content #headlineContainer { + position:absolute; + left:20px; + top:5px; +} +#content #logoutChannelContainer { + position:absolute; + left:20px; + top:50px; +} +#content #statusIconContainer { + position:absolute; + right:20px; + top:50px; + width: 22px; + height: 22px; +} +#content #chatList { + position:absolute; + left:20px; + right:230px; + top:85px; + bottom:150px; + overflow:auto; +} +#content #inputFieldContainer { + position:absolute; + left:20px; + right:20px; + bottom:95px; + padding-right:4px; +} +#content #submitButtonContainer { + position:absolute; + right:20px; + bottom:60px; +} +#content #onlineListContainer { + position:absolute; + right:20px; + top:85px; + width:200px; + bottom:150px; +} +#content #helpContainer { + position:absolute; + right:20px; + top:85px; + width:360px; + bottom:150px; +} +#content #settingsContainer { + position:absolute; + right:20px; + top:85px; + width:360px; + bottom:150px; +} +#content #bbCodeContainer { + position:absolute; + left:20px; + bottom:20px; + padding:3px; +} +#content #colorCodesContainer { + position:absolute; + left:20px; + bottom:55px; + padding:3px; + z-index:1; +} +#content #emoticonsContainer { + position:absolute; + left:20px; + bottom:57px; + padding:3px; +} +#content #optionsContainer { + position:absolute; + right:20px; + bottom:20px; + padding:3px; + padding-right:0px; +} +#content #bbCodeContainer input { + padding-left:4px; + padding-right:4px; +} +#content #colorCodesContainer a { + display:block; + float:left; + width:20px; + height:20px; +} +#content #optionsContainer input { + vertical-align:middle; +} +#content #optionsContainer input.button { + width:22px; + height:22px; +} +#content #emoticonsContainer a { + margin-left:1px; + margin-right:1px; +} +#content #emoticonsContainer img { + vertical-align:middle; + margin-bottom:2px; +} +#content #headlineContainer h1 { + margin-left:auto; + margin-top:12px; +} +#content #chatList div { + padding-left:10px; + padding-top:2px; + padding-right:10px; + padding-bottom:2px; +} +#content #chatList img { + vertical-align:middle; + margin-bottom:2px; +} +#content #chatList cite { + margin-right:5px; +} +#content #chatList .bbCodeImage { + vertical-align:top; + overflow:auto; + margin:5px; +} +#content #chatList .delete { + display:block; + float:right; + width:10px; + height:10px; + margin-top:2px; + padding-left:5px; +} +#content #inputFieldContainer #inputField { + width:100%; + height:40px; +} +#content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + height:30px; + padding-left:10px; + padding-top:4px; + padding-right:10px; + padding-bottom:4px; + margin:0px; + text-align:center; +} +#content #onlineListContainer #onlineList, #content #helpContainer #helpList, #content #settingsContainer #settingsList { + position:absolute; + left:0px; + right:0px; + top:25px; + bottom:0px; + overflow:auto; +} +#content #onlineListContainer #onlineList div { + padding-left:10px; + padding-top:2px; + padding-right:10px; + padding-bottom:2px; +} +#content #onlineListContainer #onlineList a { + display:block; +} +#content #onlineListContainer #onlineList ul { + margin-left:0px; + margin-top:5px; + margin-bottom:5px; + padding-left:20px; +} +#content #helpContainer #helpList td, #content #settingsContainer #settingsList td { + padding-left:10px; + padding-top:4px; + padding-right:10px; + padding-bottom:4px; + vertical-align:top; +} +#content #settingsContainer #settingsList td { + vertical-align:middle; +} +#content #settingsContainer #settingsList td.setting { + width:115px; +} +#content #settingsContainer #settingsList input.text { + width:100px; +} +#content #settingsContainer #settingsList select.left { + text-align:right; +} +#content #settingsContainer #settingsList input.button { + width:22px; + height:22px; + vertical-align:middle; + margin-bottom:2px; +} + +/* + * Misc + */ + +@media screen,projection,handheld { + + #content #bbCodeContainer input, #content #optionsContainer input.button, #content #settingsContainer #settingsList input.button { + cursor:pointer; + } + +} + +/* Buttons */ +#content #optionsContainer #helpButton { + background:url('../images/help.png') no-repeat; +} +#content #optionsContainer #settingsButton { + background:url('../images/settings.png') no-repeat; +} +#content #optionsContainer #onlineListButton { + background:url('../images/users.png') no-repeat; +} +#content #optionsContainer #audioButton { + background:url('../images/audio.png') no-repeat 0px 0px; +} +#content #optionsContainer #audioButton.off { + background-position: 0px 100%; +} +#content #optionsContainer #autoScrollButton { + background:url('../images/autoscroll.png') no-repeat 0px 0px; +} +#content #optionsContainer #autoScrollButton.off { + background-position: 0px 100%; +} +#content #settingsContainer #settingsList input.playback { + background:url('../images/playback.png') no-repeat; +} + +/* + * Print layout + */ + +@media print { + + #content { + position:static; + } + #content #copyright { + display:none; + } + #content #headlineContainer { + display:none; + } + #content #logoutChannelContainer { + display:none; + } + #content #statusIconContainer { + display:none; + } + #content #chatList { + position:static; + overflow:visible; + } + #content #inputFieldContainer { + display:none; + } + #content #submitButtonContainer { + display:none; + } + #content #onlineListContainer { + display:none; + } + #content #helpContainer { + display:none; + } + #content #settingsContainer { + display:none; + } + #content #bbCodeContainer { + display:none; + } + #content #colorCodesContainer { + display:none; + } + #content #emoticonsContainer { + display:none; + } + #content #optionsContainer { + display:none; + } + #content #chatList div { + padding-bottom:5px; + } + #content #chatList img { + vertical-align:middle; + margin-bottom:2px; + } + #content #chatList cite { + margin-right:5px; + } + #content #chatList .delete { + display:none; + } + + #content #chatList { + border:none; + } + + #content { + font-family:'times new roman', times, serif; + font-size:1.0em; + text-align:justify; + } + #content #chatList code { + font-size:0.8em; + } + + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#1E90FF; + } + +} diff --git a/public/css/meta.modern.ajaxchat.css b/public/css/meta.modern.ajaxchat.css new file mode 100644 index 0000000..55131f2 --- /dev/null +++ b/public/css/meta.modern.ajaxchat.css @@ -0,0 +1,451 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @author Philip Nicolcev + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +/* Import Username and Text colour CSS file */ +@import url('textcolours.ajaxchat.css'); + +/* word-wrap fix */ +* { + word-wrap: break-word !important; +} + +/* Positioning */ +#loginContent { + position:absolute; + width:100%; + height:100%; +} +#loginContent #loginHeadlineContainer { + margin: 100px 100px 0 100px; +} +#loginContent #loginFormContainer, #loginContent #errorContainer { + margin: 0 100px; +} +#loginContent #loginFormContainer div { + margin-bottom:7px; +} +#loginContent #loginRegisteredUsers { + padding-top:5px; +} +#loginContent #copyright { + margin: 20px 100px 0 100px; +} +#content { + position:absolute; + width:100%; + height:100%; +} +#content #copyright { + position:absolute; + right:20px; + top:20px; +} +#content #headlineContainer { + position:absolute; + left:20px; + top:5px; +} +#content #logoutChannelContainer { + position:absolute; + left:20px; + top:50px; +} +#content #logoutChannelContainer select{ + width: 105px; + height: 22px; +} +#content #statusIconContainer { + position:absolute; + right:20px; + top:50px; + width: 22px; + height: 22px; +} +#content #chatList { + position:absolute; + left:20px; + right:230px; + top:85px; + bottom:150px; + overflow:auto; +} +#content #inputFieldContainer { + position:absolute; + left:20px; + right:20px; + bottom:95px; + padding-right:4px; +} +#content #submitButtonContainer { + position:absolute; + right:20px; + bottom:60px; +} +#content #onlineListContainer { + position:absolute; + right:20px; + top:85px; + width:200px; + bottom:150px; +} +#content #helpContainer { + position:absolute; + right:20px; + top:85px; + width:360px; + bottom:150px; +} +#content #settingsContainer { + position:absolute; + right:20px; + top:85px; + width:360px; + bottom:150px; +} +#content #bbCodeContainer { + position:absolute; + left:20px; + bottom:20px; + padding:3px; +} +#content #colorCodesContainer { + position:absolute; + left:20px; + bottom:55px; + padding:3px; + z-index:1; +} +#content #emoticonsContainer { + position:absolute; + left:20px; + bottom:57px; + padding:3px; +} +#content #optionsContainer { + position:absolute; + right:20px; + bottom:20px; + padding:3px; + padding-right:0px; +} +#content #bbCodeContainer input, #content #logoutButton, #content #mobileButton, #content #submitButton, #loginContent #loginButton { + padding: 4px 10px; +} +#content #colorCodesContainer a { + display:block; + float:left; + width:20px; + height:20px; +} +#content #optionsContainer input { + vertical-align:middle; +} +#content #optionsContainer input.button { + width:22px; + height:22px; +} +#content #emoticonsContainer a { + margin-left:1px; + margin-right:1px; +} +#content #emoticonsContainer img { + vertical-align:middle; + margin-bottom:2px; +} +#content #headlineContainer h1 { + margin-left:auto; + margin-top:12px; +} +#content #chatList div { + padding: 2px 10px; +} +#content #chatList img { + vertical-align:middle; + margin-bottom:2px; +} +#content #chatList cite { + margin-right:5px; +} +#content #chatList .bbCodeImage { + vertical-align:top; + overflow:auto; + margin:5px; +} +#content #chatList .delete { + display:block; + float:right; + width:10px; + height:10px; + margin-top:2px; + padding-left:5px; + background:url('../images/delete.png') no-repeat right; +} +#content #inputFieldContainer #inputField { + width:100%; + height:40px; +} +#content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + height:30px; + padding: 4px 10px; + margin:0px; + text-align:center; +} +#content #onlineListContainer #onlineList, #content #helpContainer #helpList, #content #settingsContainer #settingsList { + position:absolute; + left:0px; + right:0px; + top:25px; + bottom:0px; + overflow:auto; +} +#content #onlineListContainer #onlineList div { + padding: 2px 10px; +} +#content #onlineListContainer #onlineList a { + display:block; +} +#content #onlineListContainer #onlineList ul { + margin: 5px 0; + padding-left:20px; +} +#content #helpContainer #helpList td, #content #settingsContainer #settingsList td { + padding: 4px 10px; + vertical-align:top; +} +#content #settingsContainer #settingsList td { + vertical-align:middle; +} +#content #settingsContainer #settingsList td.setting { + width:115px; +} +#content #settingsContainer #settingsList input.text { + width:100px; +} +#content #settingsContainer #settingsList select.left { + text-align:right; +} +#content #settingsContainer #settingsList input.button { + width:22px; + height:22px; + vertical-align:middle; + margin-bottom:2px; +} + +/* Buttons */ +#content #optionsContainer #helpButton { + background:url('../images/help.png') no-repeat; +} +#content #optionsContainer #settingsButton { + background:url('../images/settings.png') no-repeat; +} +#content #optionsContainer #onlineListButton { + background:url('../images/users.png') no-repeat; +} +#content #optionsContainer #audioButton { + background:url('../images/audio.png') no-repeat 0px 0px; +} +#content #optionsContainer #audioButton.off { + background-position: 0px 100%; +} +#content #optionsContainer #autoScrollButton { + background:url('../images/autoscroll.png') no-repeat 0px 0px; +} +#content #optionsContainer #autoScrollButton.off { + background-position: 0px 100%; +} +#content #settingsContainer #settingsList input.playback { + background:url('../images/playback.png') no-repeat; +} + +/* Borders */ +#content img { + border:none; +} +#content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #colorCodesContainer, +#content #colorCodesContainer a, #content textarea { + border-width:1px; + border-style:solid; +} +#content #chatList .deleteSelected { + border-width:1px; + border-style:dotted; +} +#content #helpContainer #helpList table, #content #settingsContainer #settingsList table { + border-collapse:collapse; +} + +/* Misc */ +#content #bbCodeContainer input, #content #optionsContainer input.button, #content #settingsContainer #settingsList input.button, #content #logoutButton, #content #mobileButton, #content #submitButton, #loginContent #loginButton { + cursor:pointer; +} + +/* Fonts */ +#loginContent { + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:0.8em; +} +#loginContent h1 { + font-size:1.3em; + font-family:"Trebuchet MS", Verdana, Arial, sans-serif; + font-weight:bold; +} +#loginContent a { + text-decoration:none; +} +#loginContent a:hover { + text-decoration:underline; +} +#loginContent #loginRegisteredUsers { + font-size:0.8em; +} +#loginContent #copyright { + font-size:0.8em; +} +#content { + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:0.8em; +} +#content h1 { + font-size:1.3em; + font-family:"Trebuchet MS", Verdana, Arial, sans-serif; + font-weight:bold; +} +#content h3 { + font-size:1.0em; +} +#content a { + text-decoration:none; +} +#content a:hover { + text-decoration:underline; +} +#content #copyright { + font-size:0.8em; +} +#content #chatList span.dateTime { + font-size:0.7em; +} +#content #chatList .chatBotMessage { + font-style:italic; +} +#content #chatList .chatBotErrorMessage { + font-style:italic; +} +#content #chatList .privmsg { + font-style:italic; +} +#content #chatList .action { + font-style:italic; +} +#content #chatList q { + font-variant:small-caps; +} +#content #chatList code { + font-size:1.2em; +} +#content #onlineListContainer #onlineList div { + font-size:0.9em; +} +#content #helpContainer #helpList td { + font-size:0.9em; +} +#content #helpContainer #helpList td.code { + font-style:italic; +} +#content #settingsContainer #settingsList td { + font-size:0.9em; +} + +/* + * Print layout + */ + +@media print { + + #content { + position:static; + } + #content #copyright { + display:none; + } + #content #headlineContainer { + display:none; + } + #content #logoutChannelContainer { + display:none; + } + #content #statusIconContainer { + display:none; + } + #content #chatList { + position:static; + overflow:visible; + } + #content #inputFieldContainer { + display:none; + } + #content #submitButtonContainer { + display:none; + } + #content #onlineListContainer { + display:none; + } + #content #helpContainer { + display:none; + } + #content #settingsContainer { + display:none; + } + #content #bbCodeContainer { + display:none; + } + #content #colorCodesContainer { + display:none; + } + #content #emoticonsContainer { + display:none; + } + #content #optionsContainer { + display:none; + } + #content #chatList div { + padding-bottom:5px; + } + #content #chatList img { + vertical-align:middle; + margin-bottom:2px; + } + #content #chatList cite { + margin-right:5px; + } + #content #chatList .delete { + display:none; + } + + #content #chatList { + border:none; + } + + #content { + font-family:'times new roman', times, serif; + font-size:1.0em; + text-align:justify; + } + #content #chatList code { + font-size:0.8em; + } + + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#1E90FF; + } + +} diff --git a/public/css/meta.terminal.ajaxchat.css b/public/css/meta.terminal.ajaxchat.css new file mode 100644 index 0000000..dccb264 --- /dev/null +++ b/public/css/meta.terminal.ajaxchat.css @@ -0,0 +1,115 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license Modified MIT License + * @link https://blueimp.net/ajax/ + */ + + +/* word-wrap fix */ +* { + word-wrap: break-word !important; +} + +/* Fonts */ +#loginContent { + font-family:monospace; + font-size:0.8em; +} +#loginContent h1 { + font-size:1.3em; + font-family:monospace; + font-weight:bold; +} +#loginContent a { + text-decoration:none; +} +#loginContent a:hover { + text-decoration:underline; +} +#loginContent #loginRegisteredUsers { + font-size:0.8em; +} +#loginContent #copyright { + font-size:0.8em; +} +/*#content { + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:0.8em; +} +#content h1 { + font-size:1.3em; + font-family:"Trebuchet MS", Verdana, Arial, sans-serif; + font-weight:bold; +}*/ +#content { + font-family:monospace; + font-size:14px; +} +#content h1 { + font-size:14px; + font-family:monospace; + font-weight:bold; +} +#content h3 { + font-size:1.0em; +} +#content a { + text-decoration:none; +} +#content a:hover { + text-decoration:underline; +} +#content #copyright { + font-size:0.8em; +} +#content #chatList span.dateTime { + font-size:0.7em; +} +#content #chatList span.guest { + font-weight:bold; +} +#content #chatList span.user { + font-weight:bold; +} +#content #chatList span.moderator { + font-weight:bold; +} +#content #chatList span.admin { + font-weight:bold; +} +#content #chatList span.chatBot { + font-weight:bold; + font-style:italic; +} +#content #chatList .chatBotMessage { + font-style:italic; +} +#content #chatList .chatBotErrorMessage { + font-style:italic; +} +#content #chatList .privmsg { + font-style:italic; +} +#content #chatList .action { + font-style:italic; +} +#content #chatList q { + font-variant:small-caps; +} +#content #chatList code { + font-size:1.2em; +} +#content #onlineListContainer #onlineList div { + font-size:0.9em; +} +#content #helpContainer #helpList td { + font-size:0.9em; +} +#content #helpContainer #helpList td.code { + font-style:italic; +} +#content #settingsContainer #settingsList td { + font-size:0.9em; +} diff --git a/public/css/mio.css b/public/css/mio.css new file mode 100644 index 0000000..b895c52 --- /dev/null +++ b/public/css/mio.css @@ -0,0 +1,851 @@ +/* + Flashii.net Style Codename "Mio" + By Flashwave +*/ + +@charset "utf-8"; + +html { + color: #000000; + font: 12px/20px Georgia, "Times New Roman", Times, serif; +} + +body { + margin: 0px; + padding: 0px; + font-family: Verdana, Arial, Helvetica, sans-serif; + background: linear-gradient(180deg, #C2AFFE, #FBEEFF) repeat-x scroll center top #FBEEFF; + background-size: auto 200px; + text-align: center; +} + +img.logo { + height: 150px; + width: 450px; + border: 0px; + background: url('https://static.flash.moe/logos/logo.png') no-repeat scroll left top transparent; + background-size: cover; +} + + +.clear { + clear: both !important; + float: none !important; +} +.hidden { + display: none !important; + visibility: hidden !important; +} + +div.navbar a { + color: #000000; + text-decoration: none; +} + +div.navbar a:hover { + color: #609; +} + +hr { + color: #9475B2; + background: #9475B2; + height: 1px; + border: 0px; +} + +div.navbar ul { + display: table; + margin: 0px auto; + clear: both; + text-align: center; + margin-top: 5px; + border-top: 1px solid; + min-width: 880px; + max-width: 1024px; +} + +div.navbar li { + float: left; + display: block; + text-align: center; + margin-top: -1px; + position: relative; + left: 217.5px; + z-index: 1; +} + +li.notcurrent { + background: none repeat scroll 0% 0% #C9BBCC; + border-width: 1px 1px 1px medium; + border-style: solid solid solid none; + border-color: inherit; + border-image: none; + padding: 2px 1em; +} + +li.current { + background: none repeat scroll 0% 0% #FBEEFF; + border-width: 1px 1px 1px 1px; + border-style: solid solid solid solid; + border-color: inherit; + border-image: none; + padding: 2px 1em; + padding-bottom: 4px; + margin-left:-1px; + border-top: medium none; +} + +li.first { + border-left: 1px solid; +} + +li.fill { + border-top: 1px solid; + padding-bottom: 4px; + width: 100px !important; +} + +div.pagecontent, div.profile { + margin: 0px auto; + margin-top: 5px; + min-width: 880px; + max-width: 1024px; + border: solid 1px #9475B2; + background: #FBEEFF; +} + +div.profile { + min-height: 246px; +} + +div.profile_cont { + text-align: left; + padding: 0px 20px; +} + +div.profile_cont hr { + border: 0px solid #000; + height: 1px; + color: #000; + background: #000; + width: 75%; +} + +div.mioboards, div.mioblog, div.miowhois { + margin: 0px auto; + margin-top: 5px; + min-width: 660px; + max-width: 924px; + border: solid 1px #9475B2; +} + +div.miochatquote { + margin: 0px auto; + margin-top: 5px; + border: solid 1px #9475B2; + display: inline-block; +} +div.miochatquote .chatquote { + text-align: left; + color: #FFF; + min-width: 500px; +} +div.miochatquote .chatquote div .dateTime { + font-size: 9px; +} +div.miochatquote .chatquote div { + padding: 1px 5px 1px 7px; +} +div.miochatquote .chatquote div:nth-child(odd) { + background: #000; +} +div.miochatquote .chatquote div:nth-child(even) { + background: #212121; +} + +div.miodonate { + margin: 0px auto; + margin-top: 5px; + min-width: 660px; + max-width: 924px; + border: solid 1px #9475B2; +} + +div.miodonate h3 { + margin: 0px; +} + +div.miodonate hr { + margin-bottom: 0px; +} + +div.miodonate h2 { + margin: 0px; + background: #9475B2; + border: solid 1px #9475B2; + text-align: right; + float: right; + border-bottom-left-radius: 12px; + display: inline-block; + margin-top: -1px; + padding: 5px; +} + +div.miodonate ul { + list-style: square outside none; +} + +div.miodonate li { + list-style: none outside none; + background: #9475B2; + margin: 0px; + width: 815px; + margin: 8px; + height: 20px; + display: list-item; + box-shadow: 0 0 10px grey; + border-radius: 3px; + font-size: 140%; + padding: 10px; +} + +div.mioucpbar { + min-width: 880px; + max-width: 1024px; +} + +div.miobottom{ + margin: 0px auto; + overflow: auto; + height: auto !important; +} + +div.miobinner { + position: relative; + left: -50%; + float: right; + clear: both; + text-align: left; +} + +h3.miotitle { + background-color: #9475B2; + color: #330066; + margin-top: 0px; + text-align: left; + padding: 3px; +} + +h2.miotitle { + background-color: #9475B2; + color: #330066; + margin: 0px; + text-align: center; + padding: 3px; +} + +h1.miotitle { + color: #330066; + margin: 0px; + text-align: center; +} + +body.miomessage { + margin-top: 20%; + text-align: center; +} + +h1.miomessage { + color: #440077; + font-size: 36pt; +} + +.miosub { + color: #330066; + font-size: 8pt; +} + +div.mioboxcontent { + text-align: left; + margin: 0px; + line-height: 130%; + overflow: auto; + width: 100%; +} + +div.mioboxcontent h4 { + text-decoration: underline; + display: inline; +} + +div.mioboards div.mioboxcontent { + padding: 0.25em 0.5em 0px; + padding-left: 20px; +} + +div.miocolumn { + float: left; + width: 25%; + display: block; +} + +a.boardlink { + text-decoration: none; + color: inherit; +} + +a.boardlink:hover,a.boardlink:active { + text-decoration: underline; +} + +div.postcontent { + text-align: left; + padding: 0px 10px 0px 10px; +} + +h3.title { + margin-top: 0px; + background-color: #9475B2; + text-align: left; + padding: 3px; +} + +h1.title{ + margin-top: 0px; + background-color: #9475B2; + text-align: left; + padding: 5px; +} + +ol,dl { + text-align: left; +} + +dl { + padding-left: 10px; +} + +dt.q { + font-weight: bold; + color: #550088; +} + +dd.a { + border-bottom: solid 1px #9475B2; + padding-right: 10px; + margin-bottom: 5px; +} + +span.permalink { + float: right; +} + +span.permalink a { + text-decoration: none; +} + +span.permalink a:hover { + text-decoration: underline; +} + +input[type="text"],input[type="password"],input[type="date"],textarea { + margin: 0px 2px 0px 0px; + padding: 2px 4px 3px; + border: 1px solid #AAA; + outline: medium none; + font-family: arial,helvetica,sans-serif; + font-size: 10pt; +} + +select { + padding: 1px 2px 2px; + border: 1px solid #AAA; + outline: medium none; + font-family: arial,helvetica,sans-serif; + font-size: 10pt; +} + +div.copyright{ + padding-top: 5px; + font-size: 11px; + line-height: 15px; +} + +div.copyright a { + text-decoration: none; +} + +.prof_avatar{ + max-height: 200px; + max-width: 200px; + border: 1px solid #9475B2; +} + +div.prof_avatar_cont{ + text-align: right; + float: right; + width: 200px; + height: 200px; + clear: both; + margin-top: -6px; + margin-right: -11px; +} + +div.prof_options { + font-size: 10px; + text-transform: uppercase; +} + +div.prof_options a, div.prof_options a:visited { + color: #111; + text-decoration: none; +} + +div.prof_options a:hover, div.prof_options a:active { + color: #111; + text-decoration: underline; +} + +div.ucp_avatar_cont { + text-align: center; + font-weight: bold; +} + +.windowbutton-container { + float: right; + margin-top: -2px; + margin-right: -2px; + margin-left: -2px; + margin-bottom: -2px; +} + +.closebutton { + cursor: pointer; + height: 23px; + width: 23px; + border: 0px; + background: url('https://static.flash.moe/images/window-sprite.png') no-repeat scroll 0px 0px transparent; +} + +.maxbutton { + cursor: pointer; + height: 23px; + width: 23px; + border: 0px; + background: url('https://static.flash.moe/images/window-sprite.png') no-repeat scroll 0px -23px transparent; +} + +.minbutton { + cursor: pointer; + height: 23px; + width: 23px; + border: 0px; + background: url('https://static.flash.moe/images/window-sprite.png') no-repeat scroll 0px -46px transparent; +} + +.donate-btn { + cursor: pointer; + height: 26px; + width: 90px; + border: 0px; + background: url('https://static.flash.moe/images/donate-btn.png') no-repeat scroll 0px 0px transparent; +} + +div.topLeftBar { + color: #000000; + position: absolute; + left: 0px; + background: #FBEEFF; + padding: 1px 9px; + border: 1px #9475B2 solid; + border-top: 0px; + border-left: 0px; + box-shadow: 0 0 1.5em #808080; + z-index: 997; +} + +div.topLeftBar a { + color: inherit; + text-decoration: none; +} + +div.topLeftBar a:hover { + text-decoration: underline; +} + +div.manageReportsContainer { + text-align: left; + width: 800px; +} + +div.manageReportsContainer > fieldset { + border: #9475B2 solid 1px; + margin: 5px; +} + +div.manageReportsContainer > fieldset > legend { + border: #9475B2 solid 1px; + background: #9475B2; + color: #306; + padding: 1px 5px; +} + +div.manageReportsContainer > fieldset > span > .reportText { + font-size: 10px; + line-height: 130%; +} + +table.miotable { + width:100%; +} + +table.miotablestandalone { + margin: 0px auto; + margin-top: 5px; + min-width: 880px; + max-width: 1024px; + border: solid 1px #9475B2; +} + +.ucptable tr { + width: 100%; +} + +.ucptable td { + width: 50%; +} + +.ucptable input[type="text"],.ucptable input[type="date"] { + width: 373px; +} + +.miotable tr.head { + background:#9475B2; + text-align:center; + font-weight:bold; +} + +.miotable tr.ucpmenu td { + width:25%; +} + +.miotable a { + text-decoration:none; +} + +.miotable a:hover { + text-decoration:underline; +} + +.miotable tr.online a { + color:green; +} + +.miotable tr.semionline a { + color:orange; +} + +.miotable tr.offline a { + color:red; +} + +.miotable td { + padding: 5px; +} + +.miotable tr.online { + color: green; + background: rgba(0,45,0,0.9);} + +.miotable tr.semionline { + color: orange; + background: rgba(51,24,0,0.9); +} + +.miotable tr.offline { + color: red; + background: rgba(51,0,0,0.9); +} + +.registerbutton, .loginbutton { + display: block; + background: #9475B2; + color: #330066; + padding: 10px; + font-size: 20px; + text-decoration: none; + transition: text-shadow 0.2s; +} + +.registerbutton:hover, .loginbutton:hover { + text-shadow: 0px 0px 8px #F1F1F1; +} + +/* Flashii Bar */ +div.flashii-bar .barAvatar { + margin-bottom: -5px; + height: 20px; + width: 20px; +} + +div.flashii-bar { + color: #000000; + position: absolute; + right: 0px; + background: #FBEEFF; + padding: 1px 9px; + /*border-radius: 0px 0px 0px 8px;*/ + border: 1px #9475B2 solid; + border-top: 0px; + border-right: 0px; + /*box-shadow: 0 0 1px grey;*/ + box-shadow: 0 0 1.5em #808080; + z-index: 997; +} + +div.flashii-black { + background: rgba(0,0,0,0.5); + position: fixed; + top: 0px; + left: 0px; + right: 0px; + bottom: 0px; + height: 100%; + width: 100%; + z-index: 998; +} + +div.flashii-bar a { + color: inherit; + text-decoration: none; +} + +div.flashii-bar a:hover { + text-decoration: underline; +} + +div.flashii-horizon { + background-color: transparent; + text-align: center; + position: absolute; + top: 30%; + left: 0px; + width: 100%; + height: 1px; + overflow: visible; + visibility: visible; + display: block; + z-index: 999; +} + +div#flashii-login,div#flashii-register { + min-width: 333px; + max-width: 462px; + border: solid 1px #9475B2; + z-index: 999; + background: #FBEEFF; + margin: 0px auto; +} + +div#flashii-login h3,div#flashii-register h3 { + background-color: #9475B2; + color: rgb(51,0,102); + margin-top: 0px; + text-align: left; + padding: 3px; +} + +div#flashii-login h3 a,div#flashii-register h3 a { + float: right; + color: inherit; + text-decoration: none; +} + +div#flashii-login table,div#flashii-register table { + margin: 0px auto; + text-align: left; +} + +div#flashii-login tr td:first-child,div#flashii-register tr td:first-child{ + background: #C9BBCC; + border: 1px #746677 solid; + color: #400070; + font-weight: bold; + padding: 0px 5px; + font-size: 10pt; + width: 35% !important; +} + +div#flashii-login table tr:last-child td, div#flashii-register table tr:last-child td{ + background: transparent !important; + border: none !important; + color: inherit !important; + font-weight: normal !important; + padding: 0 0 !important; + font-size: inherit !important; + text-align: center; +} + +div#flashii-login #recaptcha_response_field,div#flashii-login input[type="text"],div#flashii-login input[type="password"],div#flashii-register #recaptcha_response_field,div#flashii-register input[type="text"],div#flashii-register input[type="password"] { + margin: 0px 2px 0px 0px; + padding: 2px 4px 3px; + border: 1px solid #AAA; + outline: medium none; + font-family: arial,helvetica,sans-serif; + font-size: 10pt; + width: 292px; +} + +#recaptcha_widget img { + cursor: pointer; +} + +div#recaptcha_image { + margin: 0px 2px 0px 0px; + border: 1px solid #AAA; + outline: medium none; +} + +#recaptcha_response_field { + margin-top: 4px !important; +} + +.recaptcha_custom_buttons { + font-size: smaller; +} + + +/* some more shit */ +.group-select { + margin: 0px auto; + text-align: center; + min-width: 330px !important; + max-width: 945px; +} + +.group-select a { + color: inherit; +} + +.group-select-user { + background: #9475B2; + float: left; + margin: 10px; + text-align: center; + width: 275px; + height: 175px; + padding: 10px; + transition: background 0.5s, box-shadow 0.2s; + box-shadow: inset 0px 0px 1.5em #000; +} + +.group-select-user:hover { + background: #8364A1; + cursor: pointer; + box-shadow: inset 0px 0px 2em #000; +} + +.group-select-user-avatar { + min-height: 150px; + min-width: 150px; + margin: auto auto; +} + +.group-select-user-avatar img { + max-height: 150px; + max-width: 150px; + border: 0px; + padding: 0px; + margin: 0px; +} + + +.membersPage { + width: 100%; + padding: 10px 0px; + overflow: hidden; + text-align: center; +} + +.membersPage a { + color: inherit; +} + +.membersPage .groupBox, .membersPage .userBox { + background: #9475B2; + margin: 10px; + text-align: center; + display: inline-block; + vertical-align: top; + transition: background 0.5s, box-shadow 0.2s; +} + +.membersPage .groupBox { + padding: 7px; + font-size: 15px; + min-width: 150px; + box-shadow: inset 0px 0px 1em #000; +} + +.membersPage .userBox { + padding: 10px; + line-height: 330%; + width: 200px; + height: 230px; + box-shadow: inset 0px 0px 1.5em #000; +} + +.membersPage .groupBox:hover, .membersPage .userBox:hover { + background: #8364A1; + cursor: pointer; +} + +.membersPage .groupBox:hover { + box-shadow: inset 0px 0px 1em #000; +} + +.membersPage .userBox:hover { + box-shadow: inset 0px 0px 1.5em #000; +} + +.membersPage .userBox img { + width: 200px; + height: 200px; + display: block; + margin: 0px auto; +} + +.membersPage .userBox .userBoxUserName { + font-weight: 700; +} + +.news-post-time { + text-align: right; + font-size: .8em; + margin-right: 10px; + margin-bottom: 7px; +} +.news-poster { + float: right; + text-align: right; + margin-top: -3px; + margin-left: 5px; +} +.news-poster img { + max-width: 120px; + max-height: 120px; + border: 1px solid #9475B2; +} +.news-poster h2 { + line-height: 11px; + margin: -5px 0px 0px; + font-weight: 100; + background: #9475B2; + border-bottom-left-radius: 10px; + font-size: 1.5em; + padding: 5px !important; + height: 15px; +} +.news-comments-container { + margin: 5px auto 0px; +} \ No newline at end of file diff --git a/public/css/mobile.ajaxchat.css b/public/css/mobile.ajaxchat.css new file mode 100644 index 0000000..eb40fc2 --- /dev/null +++ b/public/css/mobile.ajaxchat.css @@ -0,0 +1,439 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @author Philip Nicolcev + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +@import url('textcolours.ajaxchat.css'); + +/* Fonts */ +#loginContent { + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:0.8em; +} +#loginContent h1 { + font-size:1.3em; + font-family:"Trebuchet MS", Verdana, Arial, sans-serif; + font-weight:bold; +} +#loginContent a { + text-decoration:none; +} +#loginContent a:hover { + text-decoration:underline; +} +#loginContent #loginRegisteredUsers { + font-size:0.8em; +} +#loginContent #copyright { + font-size:0.8em; +} +#content { + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:0.8em; +} +#content h1 { + font-size:1.3em; + font-family:"Trebuchet MS", Verdana, Arial, sans-serif; + font-weight:bold; +} +#content h3 { + font-size:1.0em; +} +#content a { + text-decoration:none; +} +#content a:hover { + text-decoration:underline; +} +#content #copyright { + font-size:0.8em; +} +#content #chatList span.dateTime { + font-size:0.7em; +} +#content #chatList .chatBotMessage { + font-style:italic; +} +#content #chatList .chatBotErrorMessage { + font-style:italic; +} +#content #chatList .privmsg { + font-style:italic; +} +#content #chatList .action { + font-style:italic; +} +#content #chatList q { + font-variant:small-caps; +} +#content #chatList code { + font-size:1.2em; +} +#content #onlineListContainer #onlineList div { + font-size:0.9em; +} +#content #helpContainer #helpList td { + font-size:0.9em; +} +#content #helpContainer #helpList td.code { + font-style:italic; +} +#content #settingsContainer #settingsList td { + font-size:0.9em; +} +/* Positioning */ +#loginContent { + position:absolute; + width:100%; + height:100%; +} +#loginContent #loginHeadlineContainer { + margin: 100px 100px 0 100px; +} +#loginContent #loginFormContainer, #loginContent #errorContainer { + margin: 0 100px; +} +#loginContent #loginFormContainer div { + margin-bottom:7px; +} +#loginContent #loginRegisteredUsers { + padding-top:5px; +} +#loginContent #copyright { + margin: 20px 100px 0 100px; +} +#content { + position:absolute; + width:100%; + height:100%; +} +#content #copyright { + position:absolute; + right:10px; + top:10px; +} +#content #headlineContainer { + position:absolute; + left:10px; + top:3px; +} +#content #logoutChannelContainer { + position:absolute; + left:10px; + top:50px; +} +#content #logoutChannelContainer select{ + width: 105px; + height: 22px; +} +#content #statusIconContainer { + position:absolute; + width: 22px; + height: 22px; +} +#content #chatList { + position:absolute; + left:10px; + right:10px; + top:40px; + bottom:70px; + overflow:auto; +} +#content #inputFieldContainer { + position:absolute; + left:10px; + right:10px; + bottom:42px; + padding-right:4px; +} +#content #submitButtonContainer { + position:absolute; + right:10px; + bottom:38px; + padding:3px; +} +#content #onlineListContainer { + position:absolute; + left:10px; + right:10px; + top:40px; + bottom:70px; +} +#content #helpContainer { + position:absolute; + right:10px; + top:85px; + width:360px; + bottom:150px; +} +#content #settingsContainer { + position:absolute; + left:10px; + right:10px; + top:40px; + bottom:70px; +} +#content #bbCodeContainer { + position:absolute; + left:10px; + bottom:10px; + padding:3px; +} +#content #colorCodesContainer { + position:absolute; + left:10px; + bottom:37px; + padding:3px; + z-index:1; +} +#content #emoticonsContainer { + position:absolute; + left:10px; + bottom:57px; + padding:3px; +} +#content #optionsContainer { + position:absolute; + right:10px; + top:5px; + padding:3px; + margin-left:auto; + margin-top:2px; +} +#content #bbCodeContainer input, #content #logoutButton, #content #submitButton, #loginContent #loginButton { + padding: 1px 2px; +} +#content #colorCodesContainer a { + display:block; + float:left; + width:20px; + height:20px; +} +#content #optionsContainer input { + vertical-align:middle; +} +#content #optionsContainer input.button { + width:22px; + height:22px; +} +#content #emoticonsContainer a { + margin-left:1px; + margin-right:1px; +} +#content #emoticonsContainer img { + vertical-align:middle; + margin-bottom:2px; +} +#content #headlineContainer h1 { + margin-left:auto; + margin-top:6px; +} +#content #chatList div { + padding: 2px 10px; +} +#content #chatList img { + vertical-align:middle; + margin-bottom:2px; +} +#content #chatList cite { + margin-right:5px; +} +#content #chatList .bbCodeImage { + vertical-align:top; + overflow:auto; + margin:5px; +} +#content #chatList .delete { + display:block; + float:right; + width:10px; + height:10px; + margin-top:2px; + padding-left:5px; + background:url('../images/delete.png') no-repeat right; +} +#content #inputFieldContainer #inputField { + width:100%; + height:18px; +} +#content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + height:30px; + padding: 4px 10px; + margin:0px; + text-align:center; +} +#content #onlineListContainer #onlineList, #content #helpContainer #helpList, #content #settingsContainer #settingsList { + position:absolute; + left:0px; + top:25px; + right:0px; + bottom:0px; + overflow:auto; +} +#content #onlineListContainer #onlineList div { + padding: 2px 10px; +} +#content #onlineListContainer #onlineList a { + display:block; +} +#content #onlineListContainer #onlineList ul { + margin: 5px 0; + padding-left:10px; +} +#content #helpContainer #helpList td, #content #settingsContainer #settingsList td { + vertical-align:top; +} +#content #settingsContainer #settingsList td { + vertical-align:middle; +} +#content #settingsContainer #settingsList td.setting { +} +#content #settingsContainer #settingsList input.text { + width:100px; +} +#content #settingsContainer #settingsList select.left { + text-align:right; +} +#content #settingsContainer #settingsList input.button { + height:22px; + vertical-align:middle; + margin-bottom:2px; +} + +/* Buttons */ + #content #optionsContainer #helpButton { + background:url('../images/help.png') no-repeat; + } + #content #optionsContainer #settingsButton { + background:url('../images/settings.png') no-repeat; + } + #content #optionsContainer #onlineListButton { + background:url('../images/users.png') no-repeat; + } + #content #optionsContainer #audioButton { + background:url('../images/audio.png') no-repeat; + } + #content #optionsContainer #audioButton.off { + background:url('../images/audio-off.png') no-repeat; + } + #content #optionsContainer #autoScrollButton { + background:url('../images/autoscroll.png') no-repeat; + } + #content #optionsContainer #autoScrollButton.off { + background:url('../images/autoscroll-off.png') no-repeat; + } + +/* Borders */ +#content img { + border:none; +} +#content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #colorCodesContainer, +#content #colorCodesContainer a, #content textarea { + border-width:1px; + border-style:solid; +} +#content #chatList .deleteSelected { + border-width:1px; + border-style:dotted; +} +#content #helpContainer #helpList table, #content #settingsContainer #settingsList table { + border-collapse:collapse; +} + +/* Misc */ +#content #bbCodeContainer input, #content #optionsContainer input.button, #content #settingsContainer #settingsList input.button, #content #logoutButton, #content #submitButton, #loginContent #loginButton { + cursor:pointer; +} + +@media screen,projection,handheld { + + /* Buttons */ + #content #bbCodeContainer input, #content #logoutButton, #content #submitButton, #loginForm #loginButton { + background-color:#000; + color:#f0f0f0; + border: 1px solid #808080; + background-image: linear-gradient(to bottom, #222, #000); + background-image: -webkit-linear-gradient(top, #222, #000); + } + #content select, #loginForm select, #loginForm input, #content textarea { + background-color:#000; + color:#fafafa; + border: 1px solid #808080; + } + + /* Status Icon */ + #content #statusIconContainer { + background-image: url('../images/loading-sprite.png'); + } + #content .statusContainerOff { + background-position: 0px 0px; + } + #content .statusContainerOn { + background-position: 0px -22px; + } + #content .statusContainerAlert { + background-position: 0px -44px; + } + + /* Other Theme Elements */ + #loginContent { + background-color:#000; + color:#FFF; + } + #loginContent h1 { + color:#FFF; + } + #loginContent a { + color:#FFF; + } + #loginContent input, #loginContent select { + background-color:#212121; + color:#FFF; + } + #loginContent #errorContainer { + color:red; + } + #content { + background-color:#000; + color:#FFF; + } + #content h1 { + color:#FFF; + } + #content a { + color:#FFF; + } + #content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #colorCodesContainer, #content textarea { + border-color:gray; + background-color:#000; + } + #content #colorCodesContainer a { + border-color:black; + } + #content #optionsContainer input { + background-color:transparent; + } + #content .rowEven { + background-color:#212121; + } + #content .rowOdd { + background-color:#000; + } + #content #chatList .chatBotErrorMessage { + color:red; + } + #content #chatList a { + color:#1E90FF; + } + #content #chatList .deleteSelected { + border-color:red; + } + #content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + background-color:#212121; + color:#FFF; + } +} \ No newline at end of file diff --git a/public/css/mobiledev.ajaxchat.css b/public/css/mobiledev.ajaxchat.css new file mode 100644 index 0000000..0ecd7a1 --- /dev/null +++ b/public/css/mobiledev.ajaxchat.css @@ -0,0 +1,410 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @author Philip Nicolcev + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +@import url('textcolours.ajaxchat.css'); + +/* Fonts */ +#content, #loginContent { + font-family: "Segoe UI", sans-serif; +} + +#loginContent { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 0.8em; +} +#loginContent h1 { + font-size: 1.3em; + font-family: "Trebuchet MS", Verdana, Arial, sans-serif; + font-weight: bold; +} +#loginContent a { + text-decoration: none; +} +#loginContent a: hover { + text-decoration: underline; +} +#loginContent #loginRegisteredUsers { + font-size: 0.8em; +} +#loginContent #copyright { + font-size: 0.8em; +} +#content { + font-size: 0.8em; +} +#content h1 { + font-size: 1.3em; + font-weight: bold; +} +#content h3 { + font-size: 1.0em; +} +#content a { + text-decoration: none; +} +#content a: hover { + text-decoration: underline; +} +#content #copyright { + font-size: 0.8em; +} +#content #chatList span.dateTime { + font-size: 0.7em; +} +#content #chatList .chatBotMessage { + font-style: italic; +} +#content #chatList .chatBotErrorMessage { + font-style: italic; +} +#content #chatList .privmsg { + font-style: italic; +} +#content #chatList .action { + font-style: italic; +} +#content #chatList q { + font-variant: small-caps; +} +#content #chatList code { + font-size: 1.2em; +} +#content #onlineListContainer #onlineList div { + font-size: 0.9em; +} +#content #helpContainer #helpList td { + font-size: 0.9em; +} +#content #helpContainer #helpList td.code { + font-style: italic; +} +#content #settingsContainer #settingsList td { + font-size: 0.9em; +} +/* Positioning */ +#loginContent { + position: absolute; + width: 100%; + height: 100%; +} +#loginContent #loginHeadlineContainer { + margin: 100px 100px 0 100px; +} +#loginContent #loginFormContainer, #loginContent #errorContainer { + margin: 0 100px; +} +#loginContent #loginFormContainer div { + margin-bottom: 7px; +} +#loginContent #loginRegisteredUsers { + padding-top: 5px; +} +#loginContent #copyright { + margin: 20px 100px 0 100px; +} +#content { + position: absolute; + width: 100%; + height: 100%; +} +#content #copyright { + position: absolute; + right: 10px; + top: 10px; +} +#content #headlineContainer { + position: absolute; + left: 10px; + top: 3px; +} +#content #logoutChannelContainer { + position: absolute; + left: 10px; + top: 50px; +} +#content #logoutChannelContainer select{ + width: 105px; + height: 22px; +} +#content #chatList { + position: absolute; + left: 0px; + right: 0px; + top: 40px; + bottom: 70px; + overflow: auto; +} +#content #onlineListContainer, #content #settingsContainer { + position: absolute; + left: 10px; + right: 10px; + top: 40px; + bottom: 70px; +} +#content #bbCodeContainer { + position: absolute; + left: 10px; + bottom: 10px; + padding: 3px; + display: block; +} +#content #colorCodesContainer { + position: absolute; + left: 10px; + bottom: 37px; + padding: 3px; + z-index: 1; +} +#content #emoticonsContainer { + position: absolute; + left: 10px; + bottom: 57px; + padding: 3px; +} +#content #optionsContainer { + position: absolute; + right: 10px; + top: 5px; + padding: 3px; + margin-left: auto; + margin-top: 2px; +} +#content #bbCodeContainer input, #content .actionButton, #loginContent #loginButton { + padding: 1px 2px; +} +#content #colorCodesContainer a { + display: block; + float: left; + width: 20px; + height: 20px; +} +#content #optionsContainer input { + vertical-align: middle; +} +#content #optionsContainer input.button { + width: 22px; + height: 22px; +} +#content #emoticonsContainer a { + margin-left: 1px; + margin-right: 1px; +} +#content #emoticonsContainer img { + vertical-align: middle; + margin-bottom: 2px; +} +#content #headlineContainer h1 { + margin-left: auto; + margin-top: 6px; +} +#content #chatList div { + padding: 3px 10px; +} +#content #chatList img { + vertical-align: middle; + margin-bottom: 2px; +} +#content #chatList cite { + margin-right: 5px; +} +#content #chatList .bbCodeImage { + vertical-align: top; + overflow: auto; + margin: 5px; +} +#content #chatList .delete { + display: block; + float: right; + width: 10px; + height: 10px; + margin-top: 2px; + padding-left: 5px; + background: url('../images/delete.png') no-repeat right; +} +#content #inputField { + position: absolute; + bottom: 0px; + left: 0px; + width: calc(100% - 53px); + height: 40px; + display: inline-block; + margin: 0px !important; +} +#content #submitButton { + position: absolute; + bottom: 0px; + right: 0px; + width: 50px; + height: 41px; + margin: 0px !important; +} +#content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + height: 30px; + padding: 4px 10px; + margin: 0px; + text-align: center; +} +#content #onlineListContainer #onlineList, #content #helpContainer #helpList, #content #settingsContainer #settingsList { + position: absolute; + left: 0px; + top: 25px; + right: 0px; + bottom: 0px; + overflow: auto; +} +#content #onlineListContainer #onlineList div { + padding: 2px 10px; +} +#content #onlineListContainer #onlineList a { + display: block; +} +#content #onlineListContainer #onlineList ul { + margin: 5px 0; + padding-left: 10px; +} +#content #helpContainer #helpList td, #content #settingsContainer #settingsList td { + vertical-align: top; +} +#content #settingsContainer #settingsList td { + vertical-align: middle; +} +#content #settingsContainer #settingsList td.setting { +} +#content #settingsContainer #settingsList input.text { + width: 100px; +} +#content #settingsContainer #settingsList select.left { + text-align: right; +} +#content #settingsContainer #settingsList input.button { + height: 22px; + vertical-align: middle; + margin-bottom: 2px; +} + +/* Buttons */ +#content #optionsContainer #settingsButton { + background: url('../images/settings.png') no-repeat; +} +#content #optionsContainer #onlineListButton { + background: url('../images/users.png') no-repeat; +} +#content #optionsContainer #audioButton { + background: url('../images/audio.png') no-repeat 0px 0px; +} +#content #optionsContainer #audioButton.off { + background-position: 0px 100%; +} +#content #optionsContainer #autoScrollButton { + background: url('../images/autoscroll.png') no-repeat; +} +#content #optionsContainer #autoScrollButton.off { + background: url('../images/autoscroll-off.png') no-repeat; +} + +/* Borders */ +#content img { + border: none; +} +#content #chatList .deleteSelected { + border-width: 1px; + border-style: dotted; +} +#content #helpContainer #helpList table, #content #settingsContainer #settingsList table { + border-collapse: collapse; +} + +/* Misc */ +#content #bbCodeContainer input, #content #optionsContainer input.button, #content #settingsContainer #settingsList input.button, #content .actionButton, #loginContent #loginButton { + cursor: pointer; +} + +/* Buttons */ +#content #bbCodeContainer input, #content .actionButton, #loginForm #loginButton { + background-color: #000; + color: #f0f0f0; + border: 1px solid #808080; + background-image: linear-gradient(to bottom, #222, #000); +} +#content select, #loginForm select, #loginForm input, #content textarea { + background-color: #000; + color: #fafafa; + border: 1px solid #808080; +} + +/* Status Icon */ +#content #statusIconContainer { + height: 1px; +} +#content .statusContainerOff { + background: #2F2; +} +#content .statusContainerOn { + background: #FF2; +} +#content .statusContainerAlert { + background: #F22; +} + +/* Other Theme Elements */ +#loginContent { + background-color: #000; + color: #FFF; +} +#loginContent h1 { + color: #FFF; +} +#loginContent a { + color: #FFF; +} +#loginContent input, #loginContent select { + background-color: #212121; + color: #FFF; +} +#loginContent #errorContainer { + color: red; +} +#content { + background-color: #000; + color: #FFF; +} +#content h1 { + color: #FFF; +} +#content a { + color: #FFF; +} +#content #chatList, #content #onlineListContainer, #content #helpContainer, #content #settingsContainer, #content #colorCodesContainer, #content textarea { + background-color: #444; +} +#content #colorCodesContainer a { + border-color: black; +} +#content #optionsContainer input { + background-color: transparent; +} +#content .rowEven { + background-color: #212121; +} +#content .rowOdd { + background-color: #000; +} +#content #chatList .chatBotErrorMessage { + color: red; +} +#content #chatList a { + color: #1E90FF; +} +#content #chatList .deleteSelected { + border-color: red; +} +#content #onlineListContainer h3, #content #helpContainer h3, #content #settingsContainer h3 { + background-color: #212121; + color: #FFF; +} \ No newline at end of file diff --git a/public/css/textcolours.ajaxchat.css b/public/css/textcolours.ajaxchat.css new file mode 100644 index 0000000..4c3bb3b --- /dev/null +++ b/public/css/textcolours.ajaxchat.css @@ -0,0 +1,219 @@ +/* Color Container */ +a.Silver { + background-color: #C0C0C0; +} +a.Citrine { + background-color: #F2D839; +} +a.Orange { + background-color: #FFA500; +} +a.Pumpkin { + background-color: #FF7518; +} +a.Red { + background-color: #F50000; +} +a.Crimson { + background-color: #C00000; +} +a.Ruby { + background-color: #E0115F; +} +a.Amaranth { + background-color: #E52B50; +} +a.Thulite { + background-color: #DE6FA1; +} +a.Pink { + background-color: #FF6FF2; +} +a.Purpureus { + background-color: #9A4EAE; +} +a.Antisia { + background-color: #915C83; +} +a.Cerulean { + background-color: #007BA7; +} +a.Cobalt { + background-color: #0047AB; +} +a.Aqua { + background-color: #20E4FF; +} +a.Mint { + background-color: #39F2B1; +} +a.Keppel { + background-color: #3AB09E; +} +a.Teal { + background-color: #008585; +} +a.Green { + background-color: #008500; +} +a.Chartreuse { + background-color: #7FFF00; +} +a.Nitrate { + background-color: #95CC00; +} +a.Lilive { + background-color: #C0C000; +} +a.Daive { + background-color: #858500; +} +a.Zaffre { + background-color: #0014A8; +} +a.Amethyst { + background-color: #9966CC; +} + +/* Text Color */ +#content .Silver { + color: #C0C0C0; +} +#content .Citrine { + color: #F2D839; +} +#content .Orange { + color: #FFA500; +} +#content .Pumpkin { + color: #FF7518; +} +#content .Red { + color: #F50000; +} +#content .Crimson { + color: #C00000; +} +#content .Ruby { + color: #E0115F; +} +#content .Amaranth { + color: #E52B50; +} +#content .Irresistible { + color: #B3446C; +} +#content .Thulite { + color: #DE6FA1; +} +#content .Pink { + color: #FF6FF2; +} +#content .Purpureus { + color: #9A4EAE; +} +#content .Antisia { + color: #915C83; +} +#content .Cerulean { + color: #007BA7; +} +#content .Cobalt { + color: #0047AB; +} +#content .Aqua { + color: #20E4FF; +} +#content .Turquoise { + color: #40E0D0; +} +#content .Mint { + color: #39F2B1; +} +#content .Keppel { + color: #3AB09E; +} +#content .Teal { + color: #008585; +} +#content .Green { + color: #008500; +} +#content .Lime { + color: #BFFF00; +} +#content .Chartreuse { + color: #7FFF00; +} +#content .Nitrate { + color: #95CC00; +} +#content .Lilive { + color: #C0C000; +} +#content .Daive { + color: #858500; +} +#content .Zaffre { + color: #0014A8; +} +#content .Amethyst { + color: #9966CC; +} + +/* Username colors */ +#content .guest { + color: gray; +} +#content #chatList span.guest { + font-weight: bold; +} +#content .user { + color: #FFF; +} +#content #chatList span.user { + font-weight: bold; +} +#content .moderator { + color: #0A0; +} +#content #chatList span.moderator { + font-weight: bold; +} +#content .admin { + color: #A00; +} +#content #chatList span.admin { + font-weight: bold; +} +#content .chatBot { + color: #9E8DA7; +} +#content #chatList span.chatBot { + font-weight: bold; + font-style: italic; +} +#content .purple { + color: #824CA0; +} +#content #chatList span.purple { + font-weight: bold; +} +#content .cmod { + color: #09F; +} +#content #chatList span.cmod { + font-weight: bold; +} +#content .bots { + color: #9E8DA7; +} +#content #chatList span.bots { + font-weight: bold; +} +#content .donator { + color: #EE9400; +} +#content #chatList span.donator { + font-weight: bold; +} \ No newline at end of file diff --git a/public/css/yuuno.css b/public/css/yuuno.css new file mode 100644 index 0000000..dc16060 --- /dev/null +++ b/public/css/yuuno.css @@ -0,0 +1,1220 @@ +/* + * Flashii.net Style Codename "Yuuno" + */ +@charset "utf-8"; + +/* Standard Elements */ +* { + /* Reset margin and padding */ + margin: 0; + padding: 0; +} +html { + width: 100%; + height: 100%; +} +body { + font: 12px/20px Verdana, sans-serif; + background: linear-gradient(180deg, #C2AFFE, #FBEEFF) no-repeat scroll left top #FBEEFF; + background-size: cover; + color: #000; + height: 100%; + position: relative; + width: 100%; +} + +#container { + min-height: 100%; + position: relative; + width: 100%; +} +#contentwrapper { + padding-bottom: 220px; +} +@media (max-width: 1033px) { + #contentwrapper { + padding-bottom: 230px; + } +} +@media (max-width: 860px) { + #contentwrapper { + padding-bottom: 375px; + } +} +@media (max-width: 510px) { + #contentwrapper { + padding-bottom: 380px; + } +} +@media (max-width: 426px) { + #contentwrapper { + padding-bottom: 625px; + } +} + +.clear { + clear: both !important; + float: none !important; +} +.hidden { + display: none !important; + visibility: hidden !important; +} + +hr.default { + border: 0; + height: 1px; + color: #9475B2; + background: #9475B2; +} + +img { + max-width: 100%; + max-height: 100%; +} +img.default-avatar-setting { + max-width: 200px; + max-height: 200px; + border: 3px solid #EEE; + background: #EEE; + box-shadow: 0 3px 7px #888; + border-radius: 3px; + margin: 5px; +} +img.homepage-menu-avatar { + float: right; + max-width: 100px; + max-width: 100px; + margin-top: -25px; + margin-right: 0; +} +@media (max-width: 400px) { + img.homepage-menu-avatar { + display: none; + } +} +.standalone img:not(:hover) { + max-width: 100%; +} + +a { + color: inherit; + text-decoration: none; +} +a.underline:hover { + text-decoration: underline !important; +} +a.default { + color: #22E; + text-decoration: none; +} +a.default:hover { + color: #22E; + text-decoration: underline; +} +a.default:active { + color: #E22; + text-decoration: underline; +} +a.gotop { + display: inline-block; + background: url('https://static.flash.moe/images/arrow.png') #111; + color: #FFF; + width: 60px; + height: 60px; + border-radius: 5px; + text-decoration: none; + opacity: .3; + transition: opacity .5s, box-shadow .5s; + margin: 10px 5px; + float: right; + position: fixed; + bottom: 0; + right: 5px; + z-index: 2; +} +a.gotop:hover { + opacity: .8; + box-shadow: 0 0 1em #FFF inset; +} +a.gotop:active { + box-shadow: 0 0 1em #FFF inset; + opacity: .9; +} + +/* Keyframe Elements */ +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} +@keyframes fadeOut { + 0% { + opacity: 1; + } + 100% { + opacity: 0; + display: none; + } +} +@keyframes fadeIn { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + display: block; + } +} + +/* Notifications */ +.notifications { + position: fixed; + top: 5px; + right: 5px; + z-index: 3; +} +.notifications div { + min-width: 200px; + max-width: 400px; + background: rgba(0, 0, 0, .6); + border: 2px solid #306; + border-radius: 10px; + padding: 10px; + color: #FFF; + font-weight: 700; + margin: 5px; +} + +/* Site Header Styling */ +.header { + text-align: center; + background: linear-gradient(180deg, #C2AFFE, #CCBAFE); + box-shadow: 0 0 5px #8364A1; +} +/*.header .logo { + display: block; + height: 120px; + width: 350px; + border: 0px; + background: url('//cdn.flashii.net/img/satorilogo.png') no-repeat scroll left top transparent; + background-size: cover; + margin: 0px auto; +}*/ +.header .logo { + background: none; + height: auto; + width: auto; + display: inline-block; + text-decoration: none; + font: 100 70px/80px "Segoe UI", sans-serif; + color: #B06AC4; + transition: color .2s, text-shadow .2s; +} +.header .logo:after { + content: "Flashii.net"; +} +.header .logo:hover { + color: #C17BD5; + text-shadow: 0 0 .1em #C17BD5; +} +.header .logo:active { + color: #A059B3; + text-shadow: 0 0 .1em #A059B3; +} +@media (max-width: 768px) { + /*.header .logo { + background: none; + height: auto; + width: auto; + display: inline-block; + text-decoration: none; + font: 50px/60px "Segoe UI Light", sans-serif; + color: #B06AC4; + }*/ + .header .logo { + font: 100 50px/60px "Segoe UI", sans-serif; + } +} +.header .menu { + border-bottom: 2px solid #9475B2; +} +.header .menu .menu-nav { + text-align: left; + float: left; +} +.header .menu .menu-ucp { + text-align: right; + float: right; +} +.header .menu .menu-mob { + display: none; +} +.header .menu .menu-item { + margin: 0 8px -2px; + display: inline-block; + min-width: 75px; + padding: 5px; + border-bottom: 2px solid #8364A1; + color: inherit; + text-decoration: none; + text-align: center; + transition: border-color .5s, background .3s; +} +.header .menu .menu-item.avatar { + width: auto; + padding-left: 36px; + background: url('../images/pixel.png') no-repeat scroll left center / contain transparent; +} +.header .menu .menu-item:hover { + border-color: #503180 !important; +} +.header .menu .menu-item:active { + border-color: #503180 !important; + background-color: #503180 !important; +} +.header .menu .menu-donate:hover { + border-color: #EE9400 !important; +} +.header .menu .menu-donate:active { + border-color: #EE9400 !important; + background-color: #EE9400 !important; +} + +@media (max-width: 1120px) and (min-width: 769px) { + .header .menu { + border: 0; + padding-bottom: 5px; + } + .header .menu .menu-nav, .header .menu .menu-ucp { + display: block; + float: none; + text-align: center; + } + .header .menu .menu-item { + min-width: 120px; + border: 0; + margin: 0 8px; + } + .header .menu .menu-nav .menu-item { + min-width: 120px; + border-bottom: 1px solid #8364A1; + } + .header .menu .menu-ucp .menu-item { + min-width: 120px; + border-top: 1px solid #8364A1; + } +} + +@media (max-width: 768px) { + .header .menu .menu-nav, .header .menu .menu-ucp { + float: none; + text-align: center; + display: none; + } + .header .menu .menu-hid { + display: block; + } + .header .menu .menu-mob { + display: block; + } + .header .menu .menu-mob .menu-item { + width: 100px; + } + .header .menu .menu-nav .menu-item, .header .menu .menu-ucp .menu-item { + display: block; + border-top: 0; + border-bottom: 1px solid #8364A1; + margin: 0 8px; + } + .header .menu .menu-nav:before { + content: "Navigation"; + font-size: 20px; + line-height: 40px; + } + .header .menu .menu-ucp:before { + content: "User Settings"; + font-size: 20px; + line-height: 40px; + } +} + +/* Footer Styling */ +.footer { + box-shadow: 0 0 1em #9475B2; + font-size: small; + width: 100%; + padding-top: 10px; + padding-bottom: 30px; + background: linear-gradient(180deg, #9475B2 0%, #FBEEFF 20%, #C2AFFE 100%) #C2AFFE; + position: absolute; + bottom: 0; +} +.footer .ftsections a { + color: inherit; + text-decoration: none; +} +.footer .ftsections a:hover { + text-decoration: underline; +} +.footer .ftsections { + margin: auto; + text-align: center; + width: 95%; + min-height: 150px; +} +.footer .ftsections .ftsection { + vertical-align: top; + text-align: left; + display: inline-block; + width: 200px; + list-style-type: none; +} +.footer .ftsections .ftsection li { + margin: 2px; +} +.footer .ftsections .ftsection li.fthead { + margin-bottom: 5px; + font-weight: 700; +} +.footer .sections .copycentre { + text-align: center; + width: 100%; +} + +/* Main content related stuff */ +.content { + margin: 10px auto; + padding: 2px 3px; + width: 1024px; + border: 1px solid #9475B2; + box-shadow: 0 0 3px #9475B2; + border-radius: 3px; + background: #D3BFFF; +} +.standalone { + background: #C2AEEE; + padding: 10px; + width: auto; + max-width: 1024px; +} +.private-message { + border-top: 1px solid #C2AEEE; +} + +/* Markdown Section */ +.markdown { + font: 12px/1.4 "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; + word-wrap: break-word; +} +.markdown a { + color: #00F; + text-decoration: none; +} +.markdown a:hover { + color: #00F; + text-decoration: underline; +} +.markdown a:active { + color: #F00; + text-decoration: underline; +} +.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { + border-bottom: 1px solid; + padding-bottom: 5px; + font-weight: 700; +} +.markdown p, .markdown blockquote, .markdown ul, .markdown ol, .markdown dl, .markdown table, .markdown pre { + margin-top: 0; + margin-bottom: 16px; +} +.markdown hr { + border: 0; + height: 1px; + color: #000; + background: #000; + margin: 0; +} +.markdown table { + display: block; + width: 100%; + overflow: auto; + word-break: keep-all; + border-collapse: collapse; + border-spacing: 0; +} +.markdown table tr { + border-spacing: 0; + border: 1px solid #9475B2; +} +.markdown table th, .markdown table td { + padding: 6px 13px; + border: 1px solid #9475B2; +} +.markdown table tr:nth-child(even) { + background: #B19DDD; +} +.markdown hr { + background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAECAYAAACtBE5DAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OENDRjNBN0E2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OENDRjNBN0I2NTZBMTFFMEI3QjRBODM4NzJDMjlGNDgiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo4Q0NGM0E3ODY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4Q0NGM0E3OTY1NkExMUUwQjdCNEE4Mzg3MkMyOUY0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqqezsUAAAAfSURBVHjaYmRABcYwBiM2QSA4y4hNEKYDQxAEAAIMAHNGAzhkPOlYAAAAAElFTkSuQmCC') repeat-x scroll 0px 0px transparent; + border: 0 none; + color: #CCC; + height: 4px; + padding: 0; + margin: 15px 0; +} +.markdown blockquote { + border-left: 4px solid #9475B2; + padding: 0 15px; + color: #555; +} +.markdown blockquote > blockquote { + margin-left: 0; +} +.markdown blockquote > :last-child { + margin-bottom: 0; +} +.markdown pre { + word-wrap: normal; +} +.markdown .highlight pre, .markdown pre { + background: #B19DDD; + border: 1px solid #9475B2; + font-size: 13px; + line-height: 19px; + overflow: auto; + padding: 6px 10px; + border-radius: 3px; +} +.markdown ul, .markdown ol { + margin-left: 40px; +} + +/* Styling for the plain HTML button on the /r/ pages */ +.markdown-raw { + width: 100%; + margin-top: 7px; + text-align: center; +} +.markdown-raw a { + display: inline-block; + margin: 0 auto; + border-radius: 5px; + background: #A08DDC; + padding: 8px 10px; + box-shadow: inset 0 0 .5em #000; + text-decoration: none; + color: #000; + transition: box-shadow .2s; + min-width: 200px; +} +.markdown-raw a:active { + box-shadow: inset 0 0 1em #000; +} + +/* Content div styling */ +.content-column { + position: relative; + min-height: 600px; +} +.content-left { + float: left; + width: 688px; +} +.content-right { + float: right; + width: 334px; +} +.content-left .head, +.news .head, +.donate .head, +.loginPage > .loginCont .head, +.messages .head { + margin: -1px -2px; + padding: 4px 5px 5px; + font-weight: 700; + font-size: 20px; + color: #306; + background: linear-gradient(90deg, rgba(148,117,178,.7), rgba(148,117,178,0)) #C2AFFE; + border-radius: 2px; +} +.content-right .head, +.loginPage > .registerForm .head { + margin: -1px -2px -1px; + padding: 4px 5px 5px; + font-weight: 700; + font-size: 20px; + color: #306; + background: linear-gradient(270deg, rgba(148,117,178,.7), rgba(148,117,178,0)) #C2AFFE; + border-radius: 2px; +} + +/* Button div styling */ +.button { + margin: 0 0 3px; + padding: 7px 5px; + text-align: center; + border-radius: 5px; + font-weight: 100; + background: linear-gradient(180deg, #874399, #35245E) #874399; + transition: text-shadow .25s; + color: #FFF; + font-size: 16px; + text-decoration: none; + display: block; +} +.button:hover { + text-shadow: 0 0 8px #F1F1F1; + cursor: pointer; +} +.content-right .registerbutton { + background: linear-gradient(180deg, #874399, #35245E) #874399; +} +.button.profileOption { + width: auto !important; +} + +/* Frontpage news styling (and probably news page too) */ +.news { + min-height: 0; +} +.news-head { + margin: -1px -2px; + padding: 4px; + background: #C2AFFE; + font-weight: 700; + display: block; + font-size: 17px; + color: inherit; + text-decoration: none; +} +.news-rss { + float: right; +} +.news-body { + font-size: 10pt; + padding: 2px 0 0 3px; +} +.news-post-time { + font-size: 8pt; + padding: 6px 15px; + text-align: right; + font-weight: 700; +} +.news-poster { + margin-top: -20px; + float: right; + text-align: center; + width: 140px; +} +.news-poster img { + max-width: 120px; + max-height: 120px; +} +.news-poster h1 { + line-height: 100%; + margin: 0; + margin-top: -5px; +} +@media (max-width: 768px) { + .news-poster { + margin: 0; + } +} +@media (max-width: 400px) { + .news-poster { + margin-top: 10px; + width: auto; + padding: 0 10px 0 0; + } + .news-poster img { + display: none; + } +} + +/* Heading */ +h1, h2, h3, h4, h5, h6 { + font-family: "Segoe UI", sans-serif; + font-weight: 100; + margin: 5px 0; +} +h1.stylised { + text-shadow: 0 0 5px #8364A1; + color: #614390; +} + +/* Homepage */ +.homepage .content-right ul { + margin: 10px 0; + margin-left: 30px; +} + +/* Chat login */ +.content.chat { + +} +.content.chat .head { + margin: -1px -2px -1px; + padding: 2px; + font-weight: 700; + font-size: 20px; + color: #306; + background: linear-gradient(270deg, rgba(148,117,178,.7), rgba(148,117,178,0)) #C2AFFE; + border-radius: 2px; +} + +.content.chat form { + padding: 10px; +} + +.content.chat form input[type="text"], .content.chat form input[type="password"] { + height: 18px; + width: 488px; +} + +.content.chat form *:not(option) { + display: block; + margin: 1px auto; + width: 500px; + padding: 5px; +} + +.content.chat .loggedIn { + text-align: center; +} + +.content.chat .loggedIn .userBox { + padding: 10px; + line-height: 330%; + width: 150px; + height: 180px; + background: linear-gradient(180deg, #C2AFFE, #B19EED) no-repeat scroll left top / cover #C2AFFE; + margin: 7px; + border-radius: 5px; + text-align: center; + box-shadow: 0 0 .5em #000; + display: inline-block; + vertical-align: top; + transition: box-shadow 0.2s; +} + +.content.chat .loggedIn .userBox:hover { + box-shadow: 0 0 1em #000; + cursor: pointer; +} + +.content.chat .loggedIn .userBox:active { + box-shadow: 0 0 1.5em #609; +} + +.content.chat .loggedIn .userBox img { + width: 150px; + height: 150px; + display: block; + margin: 0 auto; +} + +.content.chat .loggedIn .userBox .userBoxUserName { + font-weight: 700; +} + +.content.chat a { + color: inherit; +} + +/* Profile */ +.profile .button { + display: inline-block !important; + padding: 7px 16px; +} +.profile .standingtable { + border-collapse: separate; + border-spacing: 0; +} +.profile .standingtable td { + border-left: 1px solid #9475B2; + border-bottom: 1px solid #9475B2; + vertical-align: middle; +} +.profile .standingtable td:first-child { + border-left: 0 none; +} +.profile .standingtable tr:last-child td { + border-bottom: 0 none; +} +.profile .standingtable tr:first-child td { + background: #9475B2; + padding: 0 3px; + font-weight: 700; +} +.profile .content-left { + max-height: 800px; + overflow: auto; +} +@media (max-width: 1024px) { + .content { + width: auto; + } + .content .content-right { + width: 100%; + min-height: 0; + } + .content .content-left { + width: 100%; + min-height: 0; + border-top: 1px solid #9475B2; + } +} + +/* Settings */ +.settings .right-menu-nav > div { + background: #C2AFFE; + padding: 4px; + margin: -1px -2px; + font-weight: 700; + display: block; + font-size: 17px; +} +.settings .right-menu-nav > a { + display: block; + font-size: 14px; + line-height: 25px; + color: #22E; + text-decoration: none; + padding-left: 10px; +} +.settings .right-menu-nav > a:hover { + color: #22E; + text-decoration: underline; +} +.settings .right-menu-nav > a:active { + color: #E22; + text-decoration: underline; +} +.settings .settings-explanation { + font-size: 11px; + line-height: 18px; + padding: 7px; + border-bottom: 1px solid #C2AFFE; + margin-bottom: 7px; +} +.settings .settings-table { + width: 100%; +} +.settings .settings-table tr > th { + font-size: 17px; + background: #C2AFFE; + padding: 4px; + margin: -1px -2px; + font-weight: 700; +} +.settings .settings-table tr > td { + text-align: center; +} +.settings .settings-table > tbody > tr:not(:last-child) > td { + border-bottom: 1px solid #C2AFFE; +} +.settings .settings-table tr.current-session > td { + background: #B39EED; +} +.settings .profile-field { + width: 100%; +} +.settings .profile-field > div:nth-child(2) > input { + width: calc(100% - 16px); +} +.settings .profile-save { + text-align: center; + padding: 10px; +} +.settings .background-frame { + max-width: 600px; + max-height: 400px; + border: 3px solid #EEE; + background: #EEE; + box-shadow: 0 3px 7px #888; + border-radius: 3px; + margin: 5px; +} +.settings form { + overflow: auto; +} + +/* Members page */ +.membersPage { + width: 100%; + padding: 10px 0; + overflow: hidden; + text-align: center; +} +.membersPage a { + color: inherit; +} +.membersPage .groupBox, .membersPage .userBox { + background: linear-gradient(180deg, #C2AFFE, #B19EED) no-repeat scroll left top / cover #C2AFFE; + margin: 7px; + border-radius: 5px; + text-align: center; + box-shadow: 0 0 .5em #000; + display: inline-block; + vertical-align: top; + transition: box-shadow .2s; +} +.membersPage .groupBox { + padding: 5px; + font-size: 15px; + min-width: 150px; + text-shadow: 0 0 1em #888; +} +.membersPage .userBox { + padding: 10px; + line-height: 330%; + width: 200px; + height: 230px; +} +.membersPage .groupBox:hover, .membersPage .userBox:hover { + box-shadow: 0 0 1em #000; + cursor: pointer; +} +.membersPage .groupBox:active, .membersPage .userBox:active { + box-shadow: 0 0 1.5em #609; +} +.membersPage .userBox img { + width: 200px; + height: 200px; + display: block; + margin: 0 auto; +} +.membersPage .userBox .userBoxUserName { + font-weight: 700; +} + +/* Drop Down Styling */ +.dropDown { + display: inline-block; + position: relative; +} +.dropDown .dropDownInner { + display: inline-block; + background: rgba(12, 12, 12, .7); + min-width: 200px; + border: 2px solid #9475B2; + float: left; + font-family: "Segoe UI", sans-serif; + text-align: left; + margin: 0 2px; + transition: background .5s; +} +.dropDown .dropDownInner:hover { + background: rgba(21, 21, 21, .8); +} +.dropDown .dropDownInner a { + padding: 0 1px 0 4px; + display: none; + color: #FFF; + text-decoration: none; + clear: both; + transition: background .2s; +} +.dropDown .dropDownInner a:hover { + background: rgba(21, 21, 21, .5); +} +.dropDown .dropDownInner a:active { + background: rgba(21, 21, 21, .7); +} +.dropDown .dropDownInner a.dropDownSelected { + display: inline-block; +} +.dropDown .dropDownInner:hover a { + display: block; + float: none; +} +.dropDown .dropDownInner a.dropDownDesc { + display: inline-block; +} +.dropDown .dropDownInner:hover a.dropDownDesc { + display: none; +} + +/* Donate page */ +.donate .sectionHeader { + margin: -1px -2px; + background: linear-gradient(270deg, rgba(148, 117, 178, .7), rgba(148, 117, 178, 0), rgba(148, 117, 178, .7)) #C2AFFE; + padding: 2px; + font-weight: 700; + font-size: 15px; + color: #306; +} +.donate .featureParent { + width: 100%; + padding: 10px 0; + overflow: hidden; + text-align: center; +} +.donate .featureBox { + background: linear-gradient(180deg, #C2AFFE, #B19EED) no-repeat scroll left top / cover #C2AFFE; + margin: 7px; + border-radius: 5px; + text-align: center; + box-shadow: 0 0 .5em #000; + display: inline-block; + vertical-align: top; + transition: box-shadow .2s; + width: 320px; + padding: 5px 0; +} +.donate .featureBox:hover { + box-shadow: 0 0 1em #000; + cursor: pointer; +} +.donate .featureBox:active { + box-shadow: 0 0 1.5em #609; +} +.donate .featureBoxHeader { + font-weight: 700; + font-size: 15px; +} +.donate .featureBoxDesc { + padding: 1px 2px; +} +.donate .featureBoxDesc.donateClosed { + display: none; +} +.donate .featureBoxDesc.donateOpened { + display: block; +} +.donate .paypal-donate-form { + margin: 10px auto; + display: block; + text-align: center; +} + +/* Messages */ +.messages > table { + width: 100%; + border-spacing: 0; +} +.messages > .msg-inbox > thead > tr > td { + font-weight: 700; + text-align: center; +} +.messages > .msg-inbox > tbody > tr > td { + border-bottom: 1px solid #B19EED; + border-top: 1px solid #B19EED; +} +.messages > .msg-inbox > * > tr > td { + padding: 0 4px; +} +.messages > .msg-inbox > * > tr > td:first-child { + width: 150px; + text-align: center; +} +.messages > .msg-inbox > tbody > tr > td:first-child { + border-left: 1px solid #B19EED; +} +.messages > .msg-inbox > * > tr > td:last-child { + width: 220px; + text-align: center; +} +.messages > .msg-inbox > tbody > tr > td:last-child { + border-right: 1px solid #B19EED; +} + +.messageFoldersContainer { + text-align: center; + padding: 9px 0 0; +} + +.messageFoldersContainer > .messagesFolder { + background: linear-gradient(180deg, #C2AFFE, #B19EED) no-repeat scroll left top / cover #C2AFFE; + margin: 7px; + border-radius: 5px; + text-align: center; + box-shadow: 0 0 .5em #000; + display: inline-block; + vertical-align: top; + transition: box-shadow .2s; + padding: 5px; + font-size: 15px; + min-width: 150px; + color: inherit; + text-decoration: none; +} +.messageFoldersContainer > .messagesFolder:hover { + box-shadow: 0 0 1em #000; + cursor: pointer; +} +.messageFoldersContainer > .messagesFolder:active { + box-shadow: 0 0 1.5em #609; +} + +/* Input buttons styling */ +input[type="submit"].inputStyling, input[type="button"].inputStyling, input[type="reset"].inputStyling { + padding: 3px 10px; + cursor: pointer; + border: 0; + border-radius: 3px; + background: linear-gradient(180deg, #9475B2 0%, #9475B2 50%, #86A 50%) #9475B2; + margin: 4px 1px; + color: #FFF; + box-shadow: inset #222 0 0 1px; + text-shadow: #888 0 0 2px; + transition: text-shadow .5s, box-shadow .5s; + font-size: 22px; + min-width: 120px; +} +input[type="submit"].inputStyling:hover, input[type="button"].inputStyling:hover, input[type="reset"].inputStyling:hover { + box-shadow: inset #222 0 0 3px; + text-shadow: #F1F1F1 0 0 5px; +} +input[type="submit"].inputStyling:active, input[type="button"].inputStyling:active, input[type="reset"].inputStyling:active { + box-shadow: inset #222 0 0 5px; + text-shadow: #F1F1F1 0 0 3px; + transition: text-shadow .2s, box-shadow .2s; +} +input[type="text"].inputStyling, input[type="password"].inputStyling, input[type="date"].inputStyling, input[type="url"].inputStyling { + padding: 3px 4px; + border: 1px solid #CCC; + box-shadow: inset #DDD 0 0 5px; + background: linear-gradient(180deg, #FFF 0%, #EEE 50%, #E5E5E5 50%) #FFF; +} +textarea.inputStyling { + padding: 3px 4px; + border: 1px solid #CCC; + box-shadow: inset #DDD 0 0 5px; + background: linear-gradient(180deg, #FFF 0%, #EEE 50%, #E5E5E5 50%) #FFF; +} + +/* Login and Register pages */ +.loginPage { + margin: 0 auto; + max-width: 825px; +} +.loginPage > .registerForm, +.loginPage > .loginCont > * { + text-align: center; + border: 1px solid #9475B2; + margin: 10px auto; + padding: 2px 3px; + width: 400px; + border: 1px solid #9475B2; + box-shadow: 0 0 3px #9475B2; + border-radius: 3px; + background: #D3BFFF; +} +@media (max-width: 430px) { + .loginPage > .registerForm, + .loginPage > .loginCont > * { + width: 300px; + } +} +.loginPage > .loginCont { + float: left; +} +.loginPage > .registerForm { + float: right; +} +@media (max-width: 820px) { + .loginPage > .loginCont { + float: none; + } + .loginPage > .registerForm { + float: none; + } +} +.loginPage .head { + text-align: left; +} +.loginPage > div > form > div > input { + font-size: 16px; +} +.loginPage input[type="text"], .loginPage input[type="password"] { + width: calc(100% - 16px); +} +.loginPage form > div > label { + font-size: 20px; + font-weight: 100; + padding: 0 5px; + line-height: 32px; + color: #222; + text-shadow: #888 0 0 3px; +} +.loginPage .subLinks { + font-size: 10px; +} +.loginPage .centreAlign { + text-align: center; +} +.loginPage .leftAlign { + text-align: left; +} + +/* reCAPTCHA */ +.recaptcha { + text-align: center; + width: 334px; + margin: 0 auto; +} +.recaptcha > .recaptcha_widget_form { + border: 1px solid #9475B2; + display: inline-block; + position: relative; + left: 1px; +} +.recaptcha > .recaptcha_widget_form > #recaptcha_image { + margin: 0 auto; + cursor: pointer; +} +.recaptcha > .recaptcha_widget_form > #recaptcha_response_field { + width: calc(300px - 10px); +} +.recaptcha > .recaptcha_widget_form { + float: left; +} +.recaptcha > .recaptcha_buttons { + float: right; + font-size: 25px; +} +.recaptcha > .recaptcha_buttons > a { + height: 26.9px; + display: block; + background: linear-gradient(270deg, #9475B2 0%, #9475B2 50%, #86A 50%) repeat scroll 0% 0% #9475B2; + padding: 2px 6px 0 4px; + margin-bottom: -2px; + color: #306; + text-shadow: 0 0 1px #306; + transition: text-shadow .5s; +} +.recaptcha > .recaptcha_buttons > a:hover { + text-shadow: #306 0 0 5px; +} +.recaptcha > .recaptcha_buttons > a:active { + text-shadow: #306 0 0 3px; + transition: text-shadow .2s; +} +.recaptcha > .recaptcha_buttons > a:first-child { + border-top-right-radius: 4px; +} +.recaptcha > .recaptcha_buttons > a:last-child { + border-bottom-right-radius: 4px; +} +@media (max-width: 430px) { + .recaptcha { + width: 301px; + } + .recaptcha > .recaptcha_widget_form { + position: relative; + left: -1px; + } + .recaptcha > .recaptcha_buttons > a { + display: inline-block; + width: 26.9px; + background: linear-gradient(0deg, #9475B2 0%, #9475B2 50%, #86A 50%) repeat scroll 0% 0% #9475B2; + } + .recaptcha > .recaptcha_buttons > a:first-child { + border-top-right-radius: 0px; + border-bottom-left-radius: 4px; + } +} diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..8f8c8a4 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/ie5-6.css b/public/ie5-6.css new file mode 100644 index 0000000..f1c63c1 --- /dev/null +++ b/public/ie5-6.css @@ -0,0 +1,70 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + + +/* + * Positioning adjustments for IE versions < 7 + */ + +body { + width:100%; + height:100%; +} +#content #chatList { + position:static; + margin-right:230px; + margin-left:20px; + margin-top:85px; + height:360px; +} +#content #onlineListContainer { + height:360px; +} +#content #helpContainer { + height:360px; +} +#content #settingsContainer { + height:360px; +} +#content #inputFieldContainer { + top:460px; + padding:0px; +} +#content #submitButtonContainer { + top:517px; +} +#content #bbCodeContainer { + top:550px; +} +#content #colorCodesContainer { + top:516px; +} +#content #emoticonsContainer { + top:517px; +} +#content #optionsContainer { + top:555px; +} +#content #inputFieldContainer #inputField { + width:94%; +} +#content #onlineListContainer #onlineList { + width:100%; + height:335px; + overflow:auto; +} +#content #helpContainer #helpList { + width:100%; + height:335px; + overflow:auto; +} +#content #settingsContainer #settingsList { + width:100%; + height:335px; + overflow:auto; +} \ No newline at end of file diff --git a/public/images/audio.png b/public/images/audio.png new file mode 100644 index 0000000..fb37053 Binary files /dev/null and b/public/images/audio.png differ diff --git a/public/images/autoscroll.png b/public/images/autoscroll.png new file mode 100644 index 0000000..7c313e5 Binary files /dev/null and b/public/images/autoscroll.png differ diff --git a/public/images/delete.png b/public/images/delete.png new file mode 100644 index 0000000..ae99c71 Binary files /dev/null and b/public/images/delete.png differ diff --git a/public/images/fade-purple.png b/public/images/fade-purple.png new file mode 100644 index 0000000..46f6669 Binary files /dev/null and b/public/images/fade-purple.png differ diff --git a/public/images/gothic.woff b/public/images/gothic.woff new file mode 100644 index 0000000..c438704 Binary files /dev/null and b/public/images/gothic.woff differ diff --git a/public/images/help.png b/public/images/help.png new file mode 100644 index 0000000..c67c7a6 Binary files /dev/null and b/public/images/help.png differ diff --git a/public/images/linkbad.gif b/public/images/linkbad.gif new file mode 100644 index 0000000..a5d0513 Binary files /dev/null and b/public/images/linkbad.gif differ diff --git a/public/images/linkgood.gif b/public/images/linkgood.gif new file mode 100644 index 0000000..e480670 Binary files /dev/null and b/public/images/linkgood.gif differ diff --git a/public/images/linkyellow.gif b/public/images/linkyellow.gif new file mode 100644 index 0000000..0e3f9b2 Binary files /dev/null and b/public/images/linkyellow.gif differ diff --git a/public/images/loading-sprite.png b/public/images/loading-sprite.png new file mode 100644 index 0000000..5d74214 Binary files /dev/null and b/public/images/loading-sprite.png differ diff --git a/public/images/pclouds.jpg b/public/images/pclouds.jpg new file mode 100644 index 0000000..1afaaa7 Binary files /dev/null and b/public/images/pclouds.jpg differ diff --git a/public/images/pixel.png b/public/images/pixel.png new file mode 100644 index 0000000..6c6fb51 Binary files /dev/null and b/public/images/pixel.png differ diff --git a/public/images/playback.png b/public/images/playback.png new file mode 100644 index 0000000..10102d8 Binary files /dev/null and b/public/images/playback.png differ diff --git a/public/images/settings.png b/public/images/settings.png new file mode 100644 index 0000000..cc91d65 Binary files /dev/null and b/public/images/settings.png differ diff --git a/public/images/users.png b/public/images/users.png new file mode 100644 index 0000000..bced28c Binary files /dev/null and b/public/images/users.png differ diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..55d86e5 --- /dev/null +++ b/public/index.php @@ -0,0 +1,24 @@ + 0) { + for (var i = 0; i < ol; i++) { + if (typeof objects[i].SetVariable != "undefined") { + activeObjects[activeObjects.length] = objects[i]; + } + } + } + var embeds = document.getElementsByTagName("embed"); + var el = embeds.length; + var activeEmbeds = []; + if (el > 0) { + for (var j = 0; j < el; j++) { + if (typeof embeds[j].SetVariable != "undefined") { + activeEmbeds[activeEmbeds.length] = embeds[j]; + } + } + } + var aol = activeObjects.length; + var ael = activeEmbeds.length; + var searchStr = "bridgeName="+ bridgeName; + if ((aol == 1 && !ael) || (aol == 1 && ael == 1)) { + FABridge.attachBridge(activeObjects[0], bridgeName); + } + else if (ael == 1 && !aol) { + FABridge.attachBridge(activeEmbeds[0], bridgeName); + } + else { + var flash_found = false; + if (aol > 1) { + for (var k = 0; k < aol; k++) { + var params = activeObjects[k].childNodes; + for (var l = 0; l < params.length; l++) { + var param = params[l]; + if (param.nodeType == 1 && param.tagName.toLowerCase() == "param" && param["name"].toLowerCase() == "flashvars" && param["value"].indexOf(searchStr) >= 0) { + FABridge.attachBridge(activeObjects[k], bridgeName); + flash_found = true; + break; + } + } + if (flash_found) { + break; + } + } + } + if (!flash_found && ael > 1) { + for (var m = 0; m < ael; m++) { + var flashVars = activeEmbeds[m].attributes.getNamedItem("flashVars").nodeValue; + if (flashVars.indexOf(searchStr) >= 0) { + FABridge.attachBridge(activeEmbeds[m], bridgeName); + break; + } + } + } + } + return true; +} + +// used to track multiple bridge instances, since callbacks from AS are global across the page. + +FABridge.nextBridgeID = 0; +FABridge.instances = {}; +FABridge.idMap = {}; +FABridge.refCount = 0; + +FABridge.extractBridgeFromID = function(id) +{ + var bridgeID = (id >> 16); + return FABridge.idMap[bridgeID]; +} + +FABridge.attachBridge = function(instance, bridgeName) +{ + var newBridgeInstance = new FABridge(instance, bridgeName); + + FABridge[bridgeName] = newBridgeInstance; + +/* FABridge[bridgeName] = function() { + return newBridgeInstance.root(); + } +*/ + var callbacks = FABridge.initCallbacks[bridgeName]; + if (callbacks == null) + { + return; + } + for (var i = 0; i < callbacks.length; i++) + { + callbacks[i].call(newBridgeInstance); + } + delete FABridge.initCallbacks[bridgeName] +} + +// some methods can't be proxied. You can use the explicit get,set, and call methods if necessary. + +FABridge.blockedMethods = +{ + toString: true, + get: true, + set: true, + call: true +}; + +FABridge.prototype = +{ + + +// bootstrapping + + root: function() + { + return this.deserialize(this.target.getRoot()); + }, +//clears all of the AS objects in the cache maps + releaseASObjects: function() + { + return this.target.releaseASObjects(); + }, +//clears a specific object in AS from the type maps + releaseNamedASObject: function(value) + { + if(typeof(value) != "object") + { + return false; + } + else + { + var ret = this.target.releaseNamedASObject(value.fb_instance_id); + return ret; + } + }, +//create a new AS Object + create: function(className) + { + return this.deserialize(this.target.create(className)); + }, + + + // utilities + + makeID: function(token) + { + return (this.bridgeID << 16) + token; + }, + + + // low level access to the flash object + +//get a named property from an AS object + getPropertyFromAS: function(objRef, propName) + { + if (FABridge.refCount > 0) + { + throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); + } + else + { + FABridge.refCount++; + retVal = this.target.getPropFromAS(objRef, propName); + retVal = this.handleError(retVal); + FABridge.refCount--; + return retVal; + } + }, +//set a named property on an AS object + setPropertyInAS: function(objRef,propName, value) + { + if (FABridge.refCount > 0) + { + throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); + } + else + { + FABridge.refCount++; + retVal = this.target.setPropInAS(objRef,propName, this.serialize(value)); + retVal = this.handleError(retVal); + FABridge.refCount--; + return retVal; + } + }, + +//call an AS function + callASFunction: function(funcID, args) + { + if (FABridge.refCount > 0) + { + throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); + } + else + { + FABridge.refCount++; + retVal = this.target.invokeASFunction(funcID, this.serialize(args)); + retVal = this.handleError(retVal); + FABridge.refCount--; + return retVal; + } + }, +//call a method on an AS object + callASMethod: function(objID, funcName, args) + { + if (FABridge.refCount > 0) + { + throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); + } + else + { + FABridge.refCount++; + args = this.serialize(args); + retVal = this.target.invokeASMethod(objID, funcName, args); + retVal = this.handleError(retVal); + FABridge.refCount--; + return retVal; + } + }, + + // responders to remote calls from flash + + //callback from flash that executes a local JS function + //used mostly when setting js functions as callbacks on events + invokeLocalFunction: function(funcID, args) + { + var result; + var func = this.localFunctionCache[funcID]; + + if(func != undefined) + { + result = this.serialize(func.apply(null, this.deserialize(args))); + } + + return result; + }, + + // Object Types and Proxies + + // accepts an object reference, returns a type object matching the obj reference. + getTypeFromName: function(objTypeName) + { + return this.remoteTypeCache[objTypeName]; + }, + //create an AS proxy for the given object ID and type + createProxy: function(objID, typeName) + { + var objType = this.getTypeFromName(typeName); + instanceFactory.prototype = objType; + var instance = new instanceFactory(objID); + this.remoteInstanceCache[objID] = instance; + return instance; + }, + //return the proxy associated with the given object ID + getProxy: function(objID) + { + return this.remoteInstanceCache[objID]; + }, + + // accepts a type structure, returns a constructed type + addTypeDataToCache: function(typeData) + { + newType = new ASProxy(this, typeData.name); + var accessors = typeData.accessors; + for (var i = 0; i < accessors.length; i++) + { + this.addPropertyToType(newType, accessors[i]); + } + + var methods = typeData.methods; + for (var i = 0; i < methods.length; i++) + { + if (FABridge.blockedMethods[methods[i]] == undefined) + { + this.addMethodToType(newType, methods[i]); + } + } + + + this.remoteTypeCache[newType.typeName] = newType; + return newType; + }, + + //add a property to a typename; used to define the properties that can be called on an AS proxied object + addPropertyToType: function(ty, propName) + { + var c = propName.charAt(0); + var setterName; + var getterName; + if(c >= "a" && c <= "z") + { + getterName = "get" + c.toUpperCase() + propName.substr(1); + setterName = "set" + c.toUpperCase() + propName.substr(1); + } + else + { + getterName = "get" + propName; + setterName = "set" + propName; + } + ty[setterName] = function(val) + { + this.bridge.setPropertyInAS(this.fb_instance_id, propName, val); + } + ty[getterName] = function() + { + return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, propName)); + } + }, + + //add a method to a typename; used to define the methods that can be callefd on an AS proxied object + addMethodToType: function(ty, methodName) + { + ty[methodName] = function() + { + return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id, methodName, FABridge.argsToArray(arguments))); + } + }, + + // Function Proxies + + //returns the AS proxy for the specified function ID + getFunctionProxy: function(funcID) + { + var bridge = this; + if (this.remoteFunctionCache[funcID] == null) + { + this.remoteFunctionCache[funcID] = function() + { + bridge.callASFunction(funcID, FABridge.argsToArray(arguments)); + } + } + return this.remoteFunctionCache[funcID]; + }, + + //reutrns the ID of the given function; if it doesnt exist it is created and added to the local cache + getFunctionID: function(func) + { + if (func.__bridge_id__ == undefined) + { + func.__bridge_id__ = this.makeID(this.nextLocalFuncID++); + this.localFunctionCache[func.__bridge_id__] = func; + } + return func.__bridge_id__; + }, + + // serialization / deserialization + + serialize: function(value) + { + var result = {}; + + var t = typeof(value); + //primitives are kept as such + if (t == "number" || t == "string" || t == "boolean" || t == null || t == undefined) + { + result = value; + } + else if (value instanceof Array) + { + //arrays are serializesd recursively + result = []; + for (var i = 0; i < value.length; i++) + { + result[i] = this.serialize(value[i]); + } + } + else if (t == "function") + { + //js functions are assigned an ID and stored in the local cache + result.type = FABridge.TYPE_JSFUNCTION; + result.value = this.getFunctionID(value); + } + else if (value instanceof ASProxy) + { + result.type = FABridge.TYPE_ASINSTANCE; + result.value = value.fb_instance_id; + } + else + { + result.type = FABridge.TYPE_ANONYMOUS; + result.value = value; + } + + return result; + }, + + //on deserialization we always check the return for the specific error code that is used to marshall NPE's into JS errors + // the unpacking is done by returning the value on each pachet for objects/arrays + deserialize: function(packedValue) + { + + var result; + + var t = typeof(packedValue); + if (t == "number" || t == "string" || t == "boolean" || packedValue == null || packedValue == undefined) + { + result = this.handleError(packedValue); + } + else if (packedValue instanceof Array) + { + result = []; + for (var i = 0; i < packedValue.length; i++) + { + result[i] = this.deserialize(packedValue[i]); + } + } + else if (t == "object") + { + for(var i = 0; i < packedValue.newTypes.length; i++) + { + this.addTypeDataToCache(packedValue.newTypes[i]); + } + for (var aRefID in packedValue.newRefs) + { + this.createProxy(aRefID, packedValue.newRefs[aRefID]); + } + if (packedValue.type == FABridge.TYPE_PRIMITIVE) + { + result = packedValue.value; + } + else if (packedValue.type == FABridge.TYPE_ASFUNCTION) + { + result = this.getFunctionProxy(packedValue.value); + } + else if (packedValue.type == FABridge.TYPE_ASINSTANCE) + { + result = this.getProxy(packedValue.value); + } + else if (packedValue.type == FABridge.TYPE_ANONYMOUS) + { + result = packedValue.value; + } + } + return result; + }, + //increases the reference count for the given object + addRef: function(obj) + { + this.target.incRef(obj.fb_instance_id); + }, + //decrease the reference count for the given object and release it if needed + release:function(obj) + { + this.target.releaseRef(obj.fb_instance_id); + }, + + // check the given value for the components of the hard-coded error code : __FLASHERROR + // used to marshall NPE's into flash + + handleError: function(value) + { + if (typeof(value)=="string" && value.indexOf("__FLASHERROR")==0) + { + var myErrorMessage = value.split("||"); + if(FABridge.refCount > 0 ) + { + FABridge.refCount--; + } + throw new Error(myErrorMessage[1]); + return value; + } + else + { + return value; + } + } +}; + +// The root ASProxy class that facades a flash object + +ASProxy = function(bridge, typeName) +{ + this.bridge = bridge; + this.typeName = typeName; + return this; +}; +//methods available on each ASProxy object +ASProxy.prototype = +{ + get: function(propName) + { + return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, propName)); + }, + + set: function(propName, value) + { + this.bridge.setPropertyInAS(this.fb_instance_id, propName, value); + }, + + call: function(funcName, args) + { + this.bridge.callASMethod(this.fb_instance_id, funcName, args); + }, + + addRef: function() { + this.bridge.addRef(this); + }, + + release: function() { + this.bridge.release(this); + } +}; diff --git a/public/js/chat.js b/public/js/chat.js new file mode 100644 index 0000000..e3eca5f --- /dev/null +++ b/public/js/chat.js @@ -0,0 +1,3003 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + * + * The SELFHTML documentation has been used throughout this project: + * http://selfhtml.org + * + * Stylesheet and cookie methods have been inspired by Paul Sowden (A List Apart): + * http://www.alistapart.com/stories/alternate/ + * + * Modified for Flashii Chat + */ + +// AJAX Chat client side logic: +var ajaxChat = { + + settingsInitiated: null, + styleInitiated: null, + initializeFunction: null, + finalizeFunction: null, + loginChannelID: null, + loginChannelName: null, + timerRate: null, + timer: null, + ajaxURL: null, + baseURL: null, + regExpMediaUrl: null, + dirs: null, + startChatOnLoad: null, + chatStarted: null, + domIDs: null, + dom: null, + settings: null, + nonPersistentSettings: null, + unusedSettings: null, + bbCodeTags: null, + colorCodes: null, + emoticonCodes: null, + emoticonFiles: null, + soundFiles: null, + sounds: null, + soundTransform: null, + sessionName: null, + cookieExpiration: null, + cookiePath: null, + cookieDomain: null, + cookieSecure: null, + chatBotName: null, + chatBotID: null, + allowUserMessageDelete: null, + inactiveTimeout: null, + privateChannelDiff: null, + privateMessageDiff: null, + showChannelMessages: null, + messageTextMaxLength: null, + socketServerEnabled: null, + socketServerHost: null, + socketServerPort: null, + socketServerChatID: null, + socket: null, + socketIsConnected: null, + socketTimerRate: null, + socketReconnectTimer: null, + socketRegistrationID: null, + userID: null, + userName: null, + userRole: null, + channelID: null, + channelName: null, + channelSwitch: null, + usersList: null, + userNamesList: null, + userMenuCounter: null, + encodedUserName: null, + userNodeString: null, + ignoredUserNames: null, + lastID: null, + localID: null, + lang: null, + langCode: null, + baseDirection: null, + originalDocumentTitle: null, + blinkInterval: null, + httpRequest: null, + retryTimer:null, + retryTimerDelay:null, + DOMbuffering: null, + DOMbuffer: null, + DOMbufferRowClass: 'rowOdd', + imageID: 0, + + init: function(config, lang, initSettings, initStyle, initialize, initializeFunction, finalizeFunction) { + this.httpRequest = new Object(); + this.usersList = new Array(); + this.userNamesList = new Array(); + this.userMenuCounter = 0; + this.lastID = 0; + this.localID = 0; + this.lang = lang; + this.initConfig(config); + this.initDirectories(); + if(initSettings) { + this.initSettings(); + } + if(initStyle) { + this.initStyle(); + } + this.initializeFunction = initializeFunction; + this.finalizeFunction = finalizeFunction; + if(initialize) { + this.setLoadHandler(); + } + }, + + initConfig: function(config) { + this.loginChannelID = config['loginChannelID']; + this.loginChannelName = config['loginChannelName']; + this.timerRate = config['timerRate']; + this.ajaxURL = config['ajaxURL']; + this.baseURL = config['baseURL']; + this.regExpMediaUrl = config['regExpMediaUrl']; + this.startChatOnLoad = config['startChatOnLoad']; + this.domIDs = config['domIDs']; + this.settings = config['settings']; + this.nonPersistentSettings = config['nonPersistentSettings']; + this.bbCodeTags = config['bbCodeTags']; + this.colorCodes = config['colorCodes']; + this.emoticonCodes = config['emoticonCodes']; + this.emoticonFiles = config['emoticonFiles']; + this.soundFiles = config['soundFiles']; + this.sessionName = config['sessionName']; + this.cookieExpiration = config['cookieExpiration']; + this.cookiePath = config['cookiePath']; + this.cookieDomain = config['cookieDomain']; + this.cookieSecure = config['cookieSecure']; + this.chatBotName = config['chatBotName']; + this.chatBotID = config['chatBotID']; + this.allowUserMessageDelete = config['allowUserMessageDelete']; + this.inactiveTimeout = config['inactiveTimeout']; + this.privateChannelDiff = config['privateChannelDiff']; + this.privateMessageDiff = config['privateMessageDiff']; + this.showChannelMessages = config['showChannelMessages']; + this.messageTextMaxLength = config['messageTextMaxLength']; + this.socketServerEnabled = config['socketServerEnabled']; + this.socketServerHost = config['socketServerHost']; + this.socketServerPort = config['socketServerPort']; + this.socketServerChatID = config['socketServerChatID']; + this.DOMbuffering = false; + this.DOMbuffer = ""; + this.retryTimerDelay = this.timerRate + (((this.inactiveTimeout*6000) - this.timerRate)/4); + }, + + initDirectories: function() { + this.dirs = new Object(); + //this.dirs['emoticons'] = 'http://cdn.flashii.net/img/emoticons/'; + //this.dirs['sounds'] = 'http://cdn.flashii.net/snd/chat/'; + this.dirs['emoticons'] = 'https://static.flash.moe/emoticons/'; + this.dirs['sounds'] = 'sounds/'; + }, + + initSettings: function() { + this.settingsInitiated = true; + this.unusedSettings = new Object(); + var cookie = this.readCookie(this.sessionName + '_settings'); + if(cookie) { + var settingsArray = cookie.split('&'); + var setting,key,value,number; + for(var i=0; i'
+						+ this.emoticonCodes[i]
+						+ ''; + } + if(this.dom['emoticonsContainer']) { + this.updateDOM('emoticonsContainer', this.DOMbuffer); + } + this.DOMbuffer = ""; + }, + + initColorCodes: function() { + if(this.dom['colorCodesContainer']) { + this.DOMbuffer = ""; + for(var i=0; i' + + "\r\n" + } + this.updateDOM('colorCodesContainer', this.DOMbuffer); + this.DOMbuffer = ""; + } + }, + + setStatus: function(currentStatus) { + //Make sure the status container div exists before changing its class. + if (document.getElementById('statusIconContainer') != null ) { + //currentStatus options are: Off for green, On for orange, and Alert for red. + document.getElementById('statusIconContainer').className = 'statusContainer' + currentStatus; + } + }, + + startChatUpdate: function() { + // Start the chat update and retrieve current user and channel info and set the login channel: + var infos = 'userID,userName,userRole,channelID,channelName'; + if(this.socketServerEnabled) { + infos += ',socketRegistrationID'; + } + var params = '&getInfos=' + this.encodeText(infos); + if(!isNaN(parseInt(this.loginChannelID))) { + params += '&channelID='+this.loginChannelID; + } else if(this.loginChannelName !== null) { + params += '&channelName='+this.encodeText(this.loginChannelName); + } + this.updateChat(params); + }, + + updateChat: function(paramString) { + var requestUrl = this.ajaxURL + + '&lastID=' + + this.lastID; + if(paramString) { + requestUrl += paramString; + } + this.makeRequest(requestUrl,'GET',null); + }, + + loadFlashInterface: function() { + if(this.dom['flashInterfaceContainer']) { + this.updateDOM( + 'flashInterfaceContainer', + '' + +'' + +'' + +'' + +'' + ); + FABridge.addInitializationCallback('ajaxChat', this.flashInterfaceLoadCompleteHandler); + } + }, + + flashInterfaceLoadCompleteHandler: function() { + ajaxChat.initializeFlashInterface(); + }, + + initializeFlashInterface: function() { + if(this.socketServerEnabled) { + this.socketTimerRate = (this.inactiveTimeout-1)*60*1000; + this.socketConnect(); + } + this.loadSounds(); + this.initializeCustomFlashInterface(); + }, + + socketConnect: function() { + if(!this.socketIsConnected) { + try { + if(!this.socket && FABridge.ajaxChat) { + this.socket = FABridge.ajaxChat.create('flash.net.XMLSocket'); + this.socket.addEventListener('connect', this.socketConnectHandler); + this.socket.addEventListener('close', this.socketCloseHandler); + this.socket.addEventListener('data', this.socketDataHandler); + this.socket.addEventListener('ioError', this.socketIOErrorHandler); + this.socket.addEventListener('securityError', this.socketSecurityErrorHandler); + } + this.socket.connect(this.socketServerHost, this.socketServerPort); + } catch(e) { + //alert(e); + } + } + clearTimeout(this.socketReconnectTimer); + this.socketReconnectTimer = null; + }, + + socketConnectHandler: function(event) { + ajaxChat.socketIsConnected = true; + // setTimeout is needed to avoid calling the flash interface recursively: + setTimeout('ajaxChat.socketRegister()', 0); + }, + + socketCloseHandler: function(event) { + ajaxChat.socketIsConnected = false; + if(ajaxChat.socket) { + clearTimeout(ajaxChat.timer); + ajaxChat.updateChat(null); + } + }, + + socketDataHandler: function(event) { + ajaxChat.socketUpdate(event.getData()); + }, + + socketIOErrorHandler: function(event) { + // setTimeout is needed to avoid calling the flash interface recursively (e.g. sound on new messages): + setTimeout('ajaxChat.addChatBotMessageToChatList(\'/error SocketIO\')', 0); + setTimeout('ajaxChat.updateChatlistView()', 1); + }, + + socketSecurityErrorHandler: function(event) { + // setTimeout is needed to avoid calling the flash interface recursively (e.g. sound on new messages): + setTimeout('ajaxChat.addChatBotMessageToChatList(\'/error SocketSecurity\')', 0); + setTimeout('ajaxChat.updateChatlistView()', 1); + }, + + socketRegister: function() { + if(this.socket && this.socketIsConnected) { + try { + this.socket.send( + '' + ); + } catch(e) { + //alert(e); + } + } + }, + + loadXML: function(str) { + if(!arguments.callee.parser) { + try { + // DOMParser native implementation (Mozilla, Opera): + arguments.callee.parser = new DOMParser(); + } catch(e) { + var customDOMParser = function() {} + if(navigator.appName == 'Microsoft Internet Explorer') { + // IE implementation: + customDOMParser.prototype.parseFromString = function(str, contentType) { + if(!arguments.callee.XMLDOM) { + arguments.callee.XMLDOM = new ActiveXObject('Microsoft.XMLDOM'); + } + arguments.callee.XMLDOM.loadXML(str); + return arguments.callee.XMLDOM; + } + } else { + // Safari, Konqueror: + customDOMParser.prototype.parseFromString = function(str, contentType) { + if(!arguments.callee.httpRequest) { + arguments.callee.httpRequest = new XMLHttpRequest(); + } + arguments.callee.httpRequest.open( + 'GET', + 'data:text/xml;charset=utf-8,'+encodeURIComponent(str), + false + ); + arguments.callee.httpRequest.send(null); + return arguments.callee.httpRequest.responseXML; + } + } + arguments.callee.parser = new customDOMParser(); + } + } + return arguments.callee.parser.parseFromString(str, 'text/xml'); + }, + + socketUpdate: function(data) { + var xmlDoc = this.loadXML(data); + if(xmlDoc) { + this.handleOnlineUsers(xmlDoc.getElementsByTagName('user')); + // If the root node has the attribute "mode" set to "1" it is a channel message: + if((this.showChannelMessages || xmlDoc.firstChild.getAttribute('mode') != '1') && !this.channelSwitch) { + var channelID = xmlDoc.firstChild.getAttribute('channelID'); + if(channelID == this.channelID || + parseInt(channelID) == parseInt(this.userID)+this.privateMessageDiff + ) { + this.handleChatMessages(xmlDoc.getElementsByTagName('message')); + } + } + } + }, + + setAudioVolume: function(volume) { + volume = parseFloat(volume); + if(!isNaN(volume)) { + if(volume < 0) { + volume = 0.0; + } else if(volume > 1) { + volume = 1.0; + } + this.settings['audioVolume'] = volume; + try { + if(!this.soundTransform) { + this.soundTransform = FABridge.ajaxChat.create('flash.media.SoundTransform'); + } + this.soundTransform.setVolume(volume); + } catch(e) { + //alert(e); + } + } + return ajaxChat.setHTML5SoundVolume(volume); + }, + + loadSounds: function() { + try { + this.setAudioVolume(this.settings['audioVolume']); + this.sounds = new Object(); + var sound,urlRequest; + for(var key in this.soundFiles) { + sound = FABridge.ajaxChat.create('flash.media.Sound'); + sound.addEventListener('complete', this.soundLoadCompleteHandler); + sound.addEventListener('ioError', this.soundIOErrorHandler); + urlRequest = FABridge.ajaxChat.create('flash.net.URLRequest'); + urlRequest.setUrl(this.dirs['sounds']+this.soundFiles[key]); + sound.load(urlRequest); + } + } catch(e) { + alert(e); + } + }, + + soundLoadCompleteHandler: function(event) { + var sound = event.getTarget(); + for(var key in ajaxChat.soundFiles) { + // Get the sound key by matching the sound URL with the sound filename: + if((new RegExp(ajaxChat.soundFiles[key])).test(sound.getUrl())) { + // Add the loaded sound to the sounds list: + ajaxChat.sounds[key] = sound; + } + } + }, + + soundIOErrorHandler: function(event) { + // setTimeout is needed to avoid calling the flash interface recursively (e.g. sound on new messages): + setTimeout('ajaxChat.addChatBotMessageToChatList(\'/error SoundIO\')', 0); + setTimeout('ajaxChat.updateChatlistView()', 1); + }, + + soundPlayCompleteHandler: function(event) { + // soundChannel event 'soundComplete' + }, + + playSound: function(soundID) { + if(this.sounds && this.sounds[soundID]) { + try { + // play() parameters are + // startTime:Number (default = 0), + // loops:int (default = 0) and + // sndTransform:SoundTransform (default = null) + //return this.sounds[soundID].play(0, 0, this.soundTransform); + return ajaxChat.playHTML5Sound(soundID,this.sounds[soundID]); + } catch(e) { + //alert(e); + } + } + return null; + }, + + playSoundOnNewMessage: function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) { + if(this.settings['audio'] && this.sounds && this.lastID && !this.channelSwitch) { + switch(userID) { + case this.chatBotID: + var messageParts = messageText.split(' ', 1); + switch(messageParts[0]) { + case '/login': + case '/channelEnter': + this.playSound(this.settings['soundEnter']); + break; + case '/logout': + case '/channelLeave': + case '/kick': + this.playSound(this.settings['soundLeave']); + break; + case '/error': + this.playSound(this.settings['soundError']); + break; + case '/unban': + this.playSound(this.settings['soundKick']); + break; + default: + this.playSound(this.settings['soundChatBot']); + } + break; + case this.userID: + this.playSound(this.settings['soundSend']); + break; + default: + var messageParts = messageText.split(' ', 1); + switch(messageParts[0]) { + case '/privmsg': + this.playSound(this.settings['soundPrivate']); + break; + default: + this.playSound(this.settings['soundReceive']); + } + break; + } + } + }, + + fillSoundSelection: function(selectionID, selectedSound) { + var selection = document.getElementById(selectionID); + // Skip the first, empty selection: + var i = 1; + for(var key in this.soundFiles) { + selection.options[i] = new Option(key, key); + if(key == selectedSound){ + selection.options[i].selected = true; + } + i++; + } + }, + + getHttpRequest: function(identifier) { + if(!this.httpRequest[identifier]) { + if (window.XMLHttpRequest) { + this.httpRequest[identifier] = new XMLHttpRequest(); + if (this.httpRequest[identifier].overrideMimeType) { + this.httpRequest[identifier].overrideMimeType('text/xml'); + } + } else if (window.ActiveXObject) { + try { + this.httpRequest[identifier] = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + this.httpRequest[identifier] = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) { + } + } + } + } + return this.httpRequest[identifier]; + }, + + makeRequest: function(url, method, data) { + ajaxChat.setStatus('On'); + ajaxChat.retryTimer = setTimeout("ajaxChat.updateChat(null); ajaxChat.setStatus('Alert');", this.retryTimerDelay); + try { + var identifier; + if(data) { + // Create up to 50 HTTPRequest objects: + if(!arguments.callee.identifier || arguments.callee.identifier > 50) { + arguments.callee.identifier = 1; + } else { + arguments.callee.identifier++; + } + identifier = arguments.callee.identifier; + } else { + identifier = 0; + } + this.getHttpRequest(identifier).open(method, url, true); + this.getHttpRequest(identifier).onreadystatechange = function() { + try { + ajaxChat.handleResponse(identifier); + } catch(e) { + try { + clearTimeout(ajaxChat.timer); + } catch(e) { + //alert(e); + } + try { + if(data) { + ajaxChat.addChatBotMessageToChatList('/error ConnectionTimeout'); + ajaxChat.setStatus('Alert'); + ajaxChat.updateChatlistView(); + } + } catch(e) { + //alert(e); + } + try { + ajaxChat.timer = setTimeout('ajaxChat.updateChat(null);', ajaxChat.timerRate); + } catch(e) { + //alert(e); + } + } + }; + if(method == 'POST') { + this.getHttpRequest(identifier).setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + } + this.getHttpRequest(identifier).send(data); + } catch(e) { + clearTimeout(this.timer); + if(data) { + this.addChatBotMessageToChatList('/error ConnectionTimeout'); + ajaxChat.setStatus('Alert'); + this.updateChatlistView(); + } + this.timer = setTimeout('ajaxChat.updateChat(null);', this.timerRate); + } + }, + + handleResponse: function(identifier) { + if (this.getHttpRequest(identifier).readyState == 4) { + if (this.getHttpRequest(identifier).status == 200) { + clearTimeout(ajaxChat.retryTimer); + var xmlDoc = this.getHttpRequest(identifier).responseXML; + ajaxChat.setStatus('Off'); + } else { + // Connection status 0 can be ignored. + if (this.getHttpRequest(identifier).status == 0) { + ajaxChat.setStatus('On'); + this.updateChatlistView(); + return false; + } else { + this.addChatBotMessageToChatList('/error ConnectionStatus '+this.getHttpRequest(identifier).status); + ajaxChat.setStatus('Alert'); + this.updateChatlistView(); + return false; + } + } + } + if(!xmlDoc) { + return false; + } + this.handleXML(xmlDoc); + return true; + }, + + handleXML: function(xmlDoc) { + this.handleInfoMessages(xmlDoc.getElementsByTagName('info')); + this.handleOnlineUsers(xmlDoc.getElementsByTagName('user')); + this.handleChatMessages(xmlDoc.getElementsByTagName('message')); + this.channelSwitch = null; + this.setChatUpdateTimer(); + }, + + setChatUpdateTimer: function() { + clearTimeout(this.timer); + if(this.chatStarted) { + var timeout; + if(this.socketIsConnected) { + timeout = this.socketTimerRate; + } else { + timeout = this.timerRate; + if(this.socketServerEnabled && !this.socketReconnectTimer) { + // If the socket connection fails try to reconnect once in a minute: + this.socketReconnectTimer = setTimeout('ajaxChat.socketConnect();', 60000); + } + } + this.timer = setTimeout('ajaxChat.updateChat(null);', timeout); + } + }, + + handleInfoMessages: function(infoNodes) { + var infoType, infoData; + for(var i=0; i' + + userName + + '' + + '
    '+this.getUserNodeStringItems(encodedUserName, userID, false) : + ' style="display:none;">') + + '
' + +''; + if(userID == this.userID) { + this.userNodeString = str; + } + return str; + } + }, + + toggleUserMenu: function(menuID, userName, userID) { + // If the menu is empty, fill it with user node menu items before toggling it. + var isInline = false; + if (menuID.indexOf('ium') >= 0 ) { + isInline = true; + } + if(!document.getElementById(menuID).firstChild) { + this.updateDOM( + menuID, + this.getUserNodeStringItems( + this.encodeText(this.addSlashes(this.getScriptLinkValue(userName))), + userID, + isInline + ), + false, + true + ) + } + this.showHide(menuID); + this.dom['chatList'].scrollTop = this.dom['chatList'].scrollHeight; + }, + + getUserNodeStringItems: function(encodedUserName, userID, isInline) { + var menu; + if(encodedUserName != this.encodedUserName) { + menu = '
  • ' + + this.lang['userMenuViewProfile'] + + '
  • ' + + '
  • ' + + this.lang['userMenuSendPrivateMessage'] + + '
  • ' + + '
  • ' + + this.lang['userMenuDescribe'] + + '
  • ' + + '
  • ' + + this.lang['userMenuOpenPrivateChannel'] + + '
  • ' + + '
  • ' + + this.lang['userMenuClosePrivateChannel'] + + '
  • ' + + '
  • ' + + this.lang['userMenuIgnore'] + + '
  • '; + if (isInline) { + menu += '
  • ' + + this.lang['userMenuInvite'] + + '
  • ' + + '
  • ' + + this.lang['userMenuUninvite'] + + '
  • ' + + '
  • ' + + this.lang['userMenuWhereis'] + + '
  • '; + } + if(this.userRole == 2 || this.userRole == 3 || this.userRole == 6) { + menu += '
  • ' + + this.lang['userMenuKick'] + + '
  • ' + + '
  • ' + + this.lang['userMenuWhois'] + + '
  • '; + } + } else { + menu = '
  • ' + + this.lang['userMenuLogout'] + + '
  • ' + + '
  • ' + + this.lang['userMenuWho'] + + '
  • ' + + '
  • ' + + this.lang['userMenuIgnoreList'] + + '
  • ' + + '
  • ' + + this.lang['userMenuList'] + + '
  • ' + + '
  • ' + + this.lang['userMenuAction'] + + '
  • ' + + '
  • ' + + this.lang['userMenuNick'] + + '
  • '; + if(this.userRole == 2 || this.userRole == 3 || this.userRole == 4 || this.userRole == 6 || this.userRole == 9) { + menu += '
  • ' + + this.lang['userMenuEnterPrivateRoom'] + + '
  • ' + + '
  • ' + + this.lang['userMenuLogs'] + + '
  • '; + if(this.userRole == 2 || this.userRole == 3 || this.userRole == 6) { + menu += '
  • ' + + this.lang['userMenuBans'] + + '
  • '; + } + } + } + menu += this.getCustomUserMenuItems(encodedUserName, userID); + return menu; + }, + + setOnlineListRowClasses: function() { + if(this.dom['onlineList']) { + var node = this.dom['onlineList'].firstChild; + var rowEven = false; + while(node) { + this.setClass(node, (rowEven ? 'rowEven' : 'rowOdd')) + node = node.nextSibling; + rowEven = !rowEven; + } + } + }, + + clearChatList: function() { + while(this.dom['chatList'].hasChildNodes()) { + this.dom['chatList'].removeChild(this.dom['chatList'].firstChild); + } + }, + + clearOnlineUsersList: function() { + this.usersList = new Array(); + this.userNamesList = new Array(); + if(this.dom['onlineList']) { + while(this.dom['onlineList'].hasChildNodes()) { + this.dom['onlineList'].removeChild(this.dom['onlineList'].firstChild); + } + } + }, + + getEncodedChatBotName: function() { + if(typeof arguments.callee.encodedChatBotName == 'undefined') { + arguments.callee.encodedChatBotName = this.encodeSpecialChars(this.chatBotName); + } + return arguments.callee.encodedChatBotName; + }, + + addChatBotMessageToChatList: function(messageText) { + this.addMessageToChatList( + new Date(), + this.chatBotID, + this.getEncodedChatBotName(), + 5, + null, + messageText, + null + ); + }, + + addMessageToChatList: function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) { + // Prevent adding the same message twice: + if(this.getMessageNode(messageID)) { + return; + } + if(!this.onNewMessage(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip)) { + return; + } + this.DOMbufferRowClass = this.DOMbufferRowClass == 'rowEven' ? 'rowOdd' : 'rowEven'; + this.DOMbuffer = this.DOMbuffer + + this.getChatListMessageString( + dateObject, userID, userName, userRole, messageID, messageText, channelID, ip + ); + if(!this.DOMbuffering){ + this.updateDOM('chatList', this.DOMbuffer) + this.DOMbuffer = ""; + } + }, + + getChatListMessageString: function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) { + var rowClass = this.DOMbufferRowClass; + var userClass = this.getRoleClass(userRole); + var colon; + if(messageText.indexOf('/action') == 0 || messageText.indexOf('/me') == 0 || messageText.indexOf('/privaction') == 0) { + userClass += ' action'; + colon = ' '; + } else { + colon = ': '; + } + var dateTime = this.settings['dateFormat'] ? '' + + this.formatDate(this.settings['dateFormat'], dateObject) + ' ' : ''; + return '
    ' + + this.getDeletionLink(messageID, userID, userRole, channelID) + + dateTime + + '' + + userName + + '' + + colon + + this.replaceText(messageText) + + '
    '; + }, + + getChatListUserNameTitle: function(userID, userName, userRole, ip) { + return (ip != null) ? ' title="IP: ' + ip + '"' : ''; + }, + + getMessageDocumentID: function(messageID) { + return ((messageID === null) ? 'ajaxChat_lm_'+(this.localID++) : 'ajaxChat_m_'+messageID); + }, + + getMessageNode: function(messageID) { + return ((messageID === null) ? null : document.getElementById(this.getMessageDocumentID(messageID))); + }, + + getUserDocumentID: function(userID) { + return 'ajaxChat_u_'+userID; + }, + + getUserNode: function(userID) { + return document.getElementById(this.getUserDocumentID(userID)); + }, + + getUserMenuDocumentID: function(userID) { + return 'ajaxChat_um_'+userID; + }, + + getInlineUserMenuDocumentID: function(menuID, index) { + return 'ajaxChat_ium_'+menuID+'_'+index; + }, + + getDeletionLink: function(messageID, userID, userRole, channelID) { + if(messageID !== null && this.isAllowedToDeleteMessage(messageID, userID, userRole, channelID)) { + if(!arguments.callee.deleteMessage) { + arguments.callee.deleteMessage = this.encodeSpecialChars(this.lang['deleteMessage']); + } + return ' ' // Adding a space - without any content Opera messes up the chatlist display + } + return ''; + }, + + isAllowedToDeleteMessage: function(messageID, userID, userRole, channelID) { + if((((this.userRole == 1 && this.allowUserMessageDelete && (userID == this.userID || + parseInt(channelID) == parseInt(this.userID)+this.privateMessageDiff || + parseInt(channelID) == parseInt(this.userID)+this.privateChannelDiff)) || + this.userRole == 7 || this.userRole == 5 || this.userRole == 2) && userRole != 3 && userRole != 4) || this.userRole == 3) { + return true; + } + return false; + }, + + onNewMessage: function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) { + if(!this.customOnNewMessage(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip)) { + return false; + } + if(this.ignoreMessage(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip)) { + return false; + } + if(this.parseDeleteMessageCommand(messageText)) { + return false; + } + this.blinkOnNewMessage(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip); + this.playSoundOnNewMessage(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip); + return true; + }, + + parseDeleteMessageCommand: function(messageText) { + if(messageText.indexOf('/delete') == 0) { + var messageID = messageText.substr(8); + var messageNode = this.getMessageNode(messageID); + if(messageNode) { + var nextSibling = messageNode.nextSibling; + try { + this.dom['chatList'].removeChild(messageNode); + if(nextSibling) { + this.updateChatListRowClasses(nextSibling); + } + } catch(e) { + } + } + return true; + } + return false; + }, + + blinkOnNewMessage: function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) { + if(this.settings['blink'] && this.lastID && !this.channelSwitch && userID != this.userID) { + clearInterval(this.blinkInterval); + this.blinkInterval = setInterval( + 'ajaxChat.blinkUpdate(\''+this.addSlashes(this.decodeSpecialChars(userName))+'\')', + this.settings['blinkInterval'] + ); + } + }, + + blinkUpdate: function(blinkStr) { + if(!this.originalDocumentTitle) { + this.originalDocumentTitle = document.title; + } + if(!arguments.callee.blink) { + document.title = '[@ ] '+blinkStr+' - '+this.originalDocumentTitle; + arguments.callee.blink = 1; + } else if(arguments.callee.blink > this.settings['blinkIntervalNumber']) { + clearInterval(this.blinkInterval); + document.title = this.originalDocumentTitle; + arguments.callee.blink = 0; + } else { + if(arguments.callee.blink % 2 != 0) { + document.title = '[@ ] '+blinkStr+' - '+this.originalDocumentTitle; + } else { + document.title = '[ @] '+blinkStr+' - '+this.originalDocumentTitle; + } + arguments.callee.blink++; + } + }, + + updateChatlistView: function() { + if(this.dom['chatList'].childNodes && this.settings['maxMessages']) { + while(this.dom['chatList'].childNodes.length > this.settings['maxMessages']) { + this.dom['chatList'].removeChild(this.dom['chatList'].firstChild); + } + } + + if(this.settings['autoScroll']) { + this.dom['chatList'].scrollTop = this.dom['chatList'].scrollHeight; + } + }, + + encodeText: function(text) { + return encodeURIComponent(text); + }, + + decodeText: function(text) { + return decodeURIComponent(text); + }, + + utf8Encode: function(plainText) { + var utf8Text = ''; + for(var i=0; i127) && (c<2048)) { + utf8Text += String.fromCharCode((c>>6)|192); + utf8Text += String.fromCharCode((c&63)|128); + } else { + utf8Text += String.fromCharCode((c>>12)|224); + utf8Text += String.fromCharCode(((c>>6)&63)|128); + utf8Text += String.fromCharCode((c&63)|128); + } + } + return utf8Text; + }, + + utf8Decode: function(utf8Text) { + var plainText = ''; + var c,c2,c3; + var i=0; + while(i191) && (c<224)) { + c2 = utf8Text.charCodeAt(i+1); + plainText += String.fromCharCode(((c&31)<<6) | (c2&63)); + i+=2; + } else { + c2 = utf8Text.charCodeAt(i+1); + c3 = utf8Text.charCodeAt(i+2); + plainText += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63)); + i+=3; + } + } + return plainText; + }, + + encodeSpecialChars: function(text) { + if (!arguments.callee.regExp) { + arguments.callee.regExp = new RegExp('[&<>\'"]', 'g'); + } + + return text.replace( + arguments.callee.regExp, + this.encodeSpecialCharsCallback + ); + }, + + encodeSpecialCharsCallback: function(str) { + switch(str) { + case '&': + return '&'; + case '<': + return '<'; + case '>': + return '>'; + case '\'': + // As ' is not supported by IE, we use ' as replacement for ('): + return '''; + case '"': + return '"'; + default: + return str; + } + }, + + decodeSpecialChars: function(text) { + if (!arguments.callee.regExp) { + arguments.callee.regExp = new RegExp('(&)|(<)|(>)|(')|(")', 'g'); + } + + return text.replace( + arguments.callee.regExp, + this.decodeSpecialCharsCallback + ); + }, + + decodeSpecialCharsCallback: function(str) { + switch(str) { + case '&': + return '&'; + case '<': + return '<'; + case '>': + return '>'; + case ''': + return '\''; + case '"': + return '"'; + default: + return str; + } + }, + + inArray: function(haystack, needle) { + var i = haystack.length; + while(i--) { + if(haystack[i] === needle) { + return true; + } + } + return false; + }, + + arraySearch: function(needle, haystack) { + var i = haystack.length; + while(i--) { + if(haystack[i] === needle) { + return i; + } + } + return false; + }, + + stripTags: function(str) { + if (!arguments.callee.regExp) { + arguments.callee.regExp = new RegExp('<\\/?[^>]+?>', 'g'); + } + + return str.replace(arguments.callee.regExp, ''); + }, + + stripBBCodeTags: function(str) { + if (!arguments.callee.regExp) { + arguments.callee.regExp = new RegExp('\\[\\/?[^\\]]+?\\]', 'g'); + } + + return str.replace(arguments.callee.regExp, ''); + }, + + escapeRegExp: function(text) { + if (!arguments.callee.regExp) { + var specials = new Array( + '^', '$', '*', '+', '?', '.', '|', '/', + '(', ')', '[', ']', '{', '}', '\\' + ); + arguments.callee.regExp = new RegExp( + '(\\' + specials.join('|\\') + ')', 'g' + ); + } + return text.replace(arguments.callee.regExp, '\\$1'); + }, + + addSlashes: function(text) { + // Adding slashes in front of apostrophs and backslashes to ensure a valid JavaScript expression: + return text.replace(/\\/g, '\\\\').replace(/\'/g, '\\\''); + }, + + removeSlashes: function(text) { + // Removing slashes added by calling addSlashes(text) previously: + return text.replace(/\\\\/g, '\\').replace(/\\\'/g, '\''); + }, + + formatDate: function(format, date) { + date = (date == null) ? new date() : date; + + return format + .replace(/%Y/g, date.getFullYear()) + .replace(/%m/g, this.addLeadingZero(date.getMonth()+1)) + .replace(/%d/g, this.addLeadingZero(date.getDate())) + .replace(/%H/g, this.addLeadingZero(date.getHours())) + .replace(/%i/g, this.addLeadingZero(date.getMinutes())) + .replace(/%s/g, this.addLeadingZero(date.getSeconds())); + }, + + addLeadingZero: function(number) { + number = number.toString(); + if(number.length < 2) { + number = '0'+number; + } + return number; + }, + + getUserIDFromUserName: function(userName) { + var index = this.arraySearch(userName, this.userNamesList); + if(index !== false) { + return this.usersList[index]; + } + return null; + }, + + getUserNameFromUserID: function(userID) { + var index = this.arraySearch(userID, this.usersList); + if(index !== false) { + return this.userNamesList[index]; + } + return null; + }, + + getRoleClass: function(roleID) { + switch(parseInt(roleID)) { + case 0: + return 'guest'; + case 1: + return 'user'; + case 2: + return 'moderator'; + case 3: + return 'admin'; + case 4: + return 'purple'; + case 5: + return 'chatBot'; + case 6: + return 'cmod'; + case 7: + return 'bots'; + case 8: + return 'dokuro'; + case 9: + return 'donator'; + default: + return 'default'; + } + }, + + handleInputFieldKeyPress: function(event) { + if(event.keyCode == 13 && !event.shiftKey) { + this.sendMessage(); + try { + event.preventDefault(); + } catch(e) { + event.returnValue = false; // IE + } + return false; + } + return true; + }, + + handleInputFieldKeyUp: function(event) { + this.updateMessageLengthCounter(); + }, + + updateMessageLengthCounter: function() { + if(this.dom['messageLengthCounter']) { + this.updateDOM( + 'messageLengthCounter', + this.dom['inputField'].value.length + '/' + this.messageTextMaxLength, + false, + true + ) + } + }, + + sendMessage: function(text) { + text = text ? text : this.dom['inputField'].value; + if(!text) { + return; + } + text = this.parseInputMessage(text); + if(text) { + clearTimeout(this.timer); + var message = 'lastID=' + + this.lastID + + '&text=' + + this.encodeText(text); + this.makeRequest(this.ajaxURL,'POST',message); + } + this.dom['inputField'].value = ''; + this.dom['inputField'].focus(); + this.updateMessageLengthCounter(); + }, + + parseInputMessage: function(text) { + if(text.charAt(0) == '/') { + var textParts = text.split(' '); + switch(textParts[0]) { + case '/ignore': + text = this.parseIgnoreInputCommand(text, textParts); + break; + default: + text = this.parseCustomInputCommand(text, textParts); + } + if(text && this.settings['persistFontColor'] && this.settings['fontColor']) { + text = this.assignFontColorToCommandMessage(text, textParts); + } + } else { + text = this.parseCustomInputMessage(text); + if(text && this.settings['persistFontColor'] && this.settings['fontColor']) { + text = this.assignFontColorToMessage(text); + } + } + return text; + }, + + assignFontColorToMessage: function(text) { + return '[color='+this.settings['fontColor']+']'+text+'[/color]'; + }, + + assignFontColorToCommandMessage: function(text, textParts) { + switch(textParts[0]) { + case '/msg': + case '/describe': + if(textParts.length > 2) { + return textParts[0]+' '+textParts[1]+' ' + + '[color='+this.settings['fontColor']+']' + + textParts.slice(2).join(' ') + + '[/color]'; + } + break; + case '/me': + case '/action': + if(textParts.length > 1) { + return textParts[0]+' ' + + '[color='+this.settings['fontColor']+']' + + textParts.slice(1).join(' ') + + '[/color]'; + } + break; + } + return text; + }, + + parseIgnoreInputCommand: function(text, textParts) { + var ignoredUserNames = this.getIgnoredUserNames(); + if(textParts.length > 1) { + var userName = this.encodeSpecialChars(textParts[1]); + // Prevent adding the chatBot or current user to the list: + if(userName == this.userName || userName == this.getEncodedChatBotName()) { + // Display the list of ignored users instead: + return this.parseIgnoreInputCommand(null, new Array('/ignore')); + } + if(ignoredUserNames.length > 0) { + var i = ignoredUserNames.length; + while(i--) { + if(ignoredUserNames[i] === userName) { + ignoredUserNames.splice(i,1); + this.addChatBotMessageToChatList('/ignoreRemoved '+userName); + this.setIgnoredUserNames(ignoredUserNames); + this.updateChatlistView(); + return null; + } + } + } + ignoredUserNames.push(userName); + this.addChatBotMessageToChatList('/ignoreAdded '+userName); + this.setIgnoredUserNames(ignoredUserNames); + } else { + if(ignoredUserNames.length == 0) { + this.addChatBotMessageToChatList('/ignoreListEmpty -'); + } else { + this.addChatBotMessageToChatList('/ignoreList '+ignoredUserNames.join(' ')); + } + } + this.updateChatlistView(); + return null; + }, + + parseSilentIgnoreInputCommand: function(text, textParts) { + var ignoredUserNames = this.getIgnoredUserNames(); + if(textParts.length > 1) { + var userName = this.encodeSpecialChars(textParts[1]); + // Prevent adding the chatBot or current user to the list: + if(userName == this.userName || userName == this.getEncodedChatBotName()) { + // Display the list of ignored users instead: + return this.parseIgnoreInputCommand(null, new Array('/ignore')); + } + if(ignoredUserNames.length > 0) { + var i = ignoredUserNames.length; + while(i--) { + if(ignoredUserNames[i] === userName) { + this.updateChatlistView(); + return null; + } + } + } + ignoredUserNames.push(userName); + this.setIgnoredUserNames(ignoredUserNames); + } + this.updateChatlistView(); + return null; + }, + + getIgnoredUserNames: function() { + if(!this.ignoredUserNames) { + var ignoredUserNamesString = this.getSetting('ignoredUserNames'); + if(ignoredUserNamesString) { + this.ignoredUserNames = ignoredUserNamesString.split(' '); + } else { + this.ignoredUserNames = new Array(); + } + } + return this.ignoredUserNames; + }, + + setIgnoredUserNames: function(ignoredUserNames) { + this.ignoredUserNames = ignoredUserNames; + this.setSetting('ignoredUserNames', ignoredUserNames.join(' ')); + }, + + ignoreMessage: function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) { + if(userID == this.chatBotID && messageText.charAt(0) == '/') { + var textParts = messageText.split(' '); + if(textParts.length > 1) { + switch(textParts[0]) { + case '/invite': + case '/uninvite': + case '/roll': + userName = textParts[1]; + break; + } + } + } + if(this.inArray(this.getIgnoredUserNames(), userName)) { + return true; + } + return false; + }, + + deleteMessage: function(messageID) { + var messageNode = this.getMessageNode(messageID); + if(messageNode) { + var originalClass = this.getClass(messageNode); + this.setClass(messageNode, originalClass+' deleteSelected'); + if(confirm(this.lang['deleteMessageConfirm'])) { + var nextSibling = messageNode.nextSibling; + try { + this.dom['chatList'].removeChild(messageNode); + if(nextSibling) { + this.updateChatListRowClasses(nextSibling); + } + this.updateChat('&delete='+messageID); + } catch(e) { + this.setClass(messageNode, originalClass); + } + } else { + this.setClass(messageNode, originalClass); + } + } + }, + + updateChatListRowClasses: function(node) { + if(!node) { + node = this.dom['chatList'].firstChild; + } + if(node) { + var previousNode = node.previousSibling; + var rowEven = (previousNode && this.getClass(previousNode) == 'rowOdd') ? true : false; + while(node) { + this.setClass(node, (rowEven ? 'rowEven' : 'rowOdd')) + node = node.nextSibling; + rowEven = !rowEven; + } + } + }, + + getClass: function(node) { + if(typeof node.className != 'undefined') { + return node.className; // IE + } else { + return node.getAttribute('class'); + } + }, + + setClass: function(node, className) { + if(typeof node.className != 'undefined') { + node.className = className; // IE + } else { + node.setAttribute('class', className); + } + }, + + scriptLinkEncode: function(text) { + return this.encodeText(this.addSlashes(this.decodeSpecialChars(text))); + }, + + scriptLinkDecode: function(text) { + return this.encodeSpecialChars(this.removeSlashes(this.decodeText(text))); + }, + + getScriptLinkValue: function(value) { + // This method returns plainText encoded values from javascript links + // The value has to be utf8Decoded for MSIE and Opera: + if(typeof arguments.callee.utf8Decode == 'undefined') { + switch(navigator.appName) { + case 'Microsoft Internet Explorer': + case 'Opera': + arguments.callee.utf8Decode = true; + return this.utf8Decode(value); + default: + arguments.callee.utf8Decode = false; + return value; + } + } else if(arguments.callee.utf8Decode) { + return this.utf8Decode(value); + } else { + return value; + } + }, + + sendMessageWrapper: function(text) { + this.sendMessage(this.getScriptLinkValue(text)); + }, + + insertMessageWrapper: function(text) { + this.insertText(this.getScriptLinkValue(text), true); + }, + + switchChannel: function(channel) { + if(!this.chatStarted) { + this.clearChatList(); + this.channelSwitch = true; + this.loginChannelID = null; + this.loginChannelName = channel; + this.requestTeaserContent(); + return; + } + clearTimeout(this.timer); + var message = 'lastID=' + + this.lastID + + '&channelName=' + + this.encodeText(channel); + this.makeRequest(this.ajaxURL,'POST',message); + if(this.dom['inputField'] && this.settings['autoFocus']) { + this.dom['inputField'].focus(); + } + }, + + logout: function() { + clearTimeout(this.timer); + var message = 'logout=true'; + this.makeRequest(this.ajaxURL,'POST',message); + }, + + handleLogout: function(url) { + window.location.href = url; + }, + + toggleSetting: function(setting, buttonID) { + this.setSetting(setting, !this.getSetting(setting)); + if(buttonID) { + this.updateButton(setting, buttonID); + } + }, + + updateButton: function(setting, buttonID) { + var node = document.getElementById(buttonID); + if(node) { + this.setClass(node, (this.getSetting(setting) ? 'button' : 'button off')) + } + }, + + showHide: function(id, styleDisplay, displayInline) { + var node = document.getElementById(id); + if(node) { + if(styleDisplay) { + node.style.display = styleDisplay; + } else { + if(node.style.display == 'none') { + node.style.display = (displayInline ? 'inline' : 'block'); + } else { + node.style.display = 'none'; + } + } + } + }, + + setPersistFontColor: function(bool) { + this.settings['persistFontColor'] = bool; + if(!this.settings['persistFontColor']) { + this.settings['fontColor'] = null; + if(this.dom['inputField']) { + this.dom['inputField'].className = ''; + } + } + }, + + setFontColor: function(color) { + if(this.settings['persistFontColor']) { + this.settings['fontColor'] = color; + if(this.dom['inputField']) { + this.dom['inputField'].className = color; + } + if(this.dom['colorCodesContainer']) { + this.dom['colorCodesContainer'].style.display = 'none'; + if(this.dom['inputField']) { + this.dom['inputField'].focus(); + } + } + } else { + this.insert('[color=' + color + ']', '[/color]'); + } + }, + + insertText: function(text, clearInputField) { + if(clearInputField) { + this.dom['inputField'].value = ''; + } + this.insert(text, ''); + }, + + insertBBCode: function(bbCode) { + switch(bbCode) { + case 'url': + var url = prompt(this.lang['urlDialog'], 'http://'); + if(url) + this.insert('[url=' + url + ']', '[/url]'); + else + this.dom['inputField'].focus(); + break; + default: + this.insert('[' + bbCode + ']', '[/' + bbCode + ']'); + } + }, + + insert: function(startTag, endTag) { + this.dom['inputField'].focus(); + // Internet Explorer: + if(typeof document.selection != 'undefined') { + // Insert the tags: + var range = document.selection.createRange(); + var insText = range.text; + range.text = startTag + insText + endTag; + // Adjust the cursor position: + range = document.selection.createRange(); + if (insText.length == 0) { + range.move('character', -endTag.length); + } else { + range.moveStart('character', startTag.length + insText.length + endTag.length); + } + range.select(); + } + // Firefox, etc. (Gecko based browsers): + else if(typeof this.dom['inputField'].selectionStart != 'undefined') { + // Insert the tags: + var start = this.dom['inputField'].selectionStart; + var end = this.dom['inputField'].selectionEnd; + var insText = this.dom['inputField'].value.substring(start, end); + this.dom['inputField'].value = this.dom['inputField'].value.substr(0, start) + + startTag + + insText + + endTag + + this.dom['inputField'].value.substr(end); + // Adjust the cursor position: + var pos; + if (insText.length == 0) { + pos = start + startTag.length; + } else { + pos = start + startTag.length + insText.length + endTag.length; + } + this.dom['inputField'].selectionStart = pos; + this.dom['inputField'].selectionEnd = pos; + } + // Other browsers: + else { + var pos = this.dom['inputField'].value.length; + this.dom['inputField'].value = this.dom['inputField'].value.substr(0, pos) + + startTag + + endTag + + this.dom['inputField'].value.substr(pos); + } + }, + + replaceText: function(text) { + try{ + text = this.replaceLineBreaks(text); + if(text.charAt(0) == '/') { + text = this.replaceCommands(text); + } else { + text = this.replaceBBCode(text); + text = this.replaceHyperLinks(text); + text = this.replaceEmoticons(text); + } + text = this.breakLongWords(text); + text = this.replaceCustomText(text); + } catch(e){ + //alert(e); + } + return text; + }, + + replaceCommands: function(text) { + try { + if(text.charAt(0) != '/') { + return text; + } + var textParts = text.split(' '); + switch(textParts[0]) { + case '/login': + return this.replaceCommandLogin(textParts); + case '/logout': + return this.replaceCommandLogout(textParts); + case '/channelEnter': + return this.replaceCommandChannelEnter(textParts); + case '/channelLeave': + return this.replaceCommandChannelLeave(textParts); + case '/privmsg': + return this.replaceCommandPrivMsg(textParts); + case '/privmsgto': + return this.replaceCommandPrivMsgTo(textParts); + case '/privaction': + return this.replaceCommandPrivAction(textParts); + case '/privactionto': + return this.replaceCommandPrivActionTo(textParts); + case '/me': + case '/action': + return this.replaceCommandAction(textParts); + case '/invite': + return this.replaceCommandInvite(textParts); + case '/inviteto': + return this.replaceCommandInviteTo(textParts); + case '/uninvite': + return this.replaceCommandUninvite(textParts); + case '/uninviteto': + return this.replaceCommandUninviteTo(textParts); + case '/queryOpen': + return this.replaceCommandQueryOpen(textParts); + case '/queryClose': + return this.replaceCommandQueryClose(textParts); + case '/ignoreAdded': + return this.replaceCommandIgnoreAdded(textParts); + case '/ignoreRemoved': + return this.replaceCommandIgnoreRemoved(textParts); + case '/ignoreList': + return this.replaceCommandIgnoreList(textParts); + case '/ignoreListEmpty': + return this.replaceCommandIgnoreListEmpty(textParts); + case '/kick': + return this.replaceCommandKick(textParts); + case '/who': + return this.replaceCommandWho(textParts); + case '/whoChannel': + return this.replaceCommandWhoChannel(textParts); + case '/whoEmpty': + return this.replaceCommandWhoEmpty(textParts); + case '/list': + return this.replaceCommandList(textParts); + case '/bans': + return this.replaceCommandBans(textParts); + case '/bansEmpty': + return this.replaceCommandBansEmpty(textParts); + case '/unban': + return this.replaceCommandUnban(textParts); + case '/whois': + return this.replaceCommandWhois(textParts); + case '/whereis': + return this.replaceCommandWhereis(textParts); + case '/roll': + return this.replaceCommandRoll(textParts); + case '/nick': + return this.replaceCommandNick(textParts); + case '/error': + return this.replaceCommandError(textParts); + default: + return this.replaceCustomCommands(text, textParts); + } + } catch(e) { + //alert(e); + } + return text; + }, + + replaceCommandLogin: function(textParts) { + return '' + + this.lang['login'].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandLogout: function(textParts) { + var type = ''; + if(textParts.length == 3) + type = textParts[2]; + return '' + + this.lang['logout' + type].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandChannelEnter: function(textParts) { + return '' + + this.lang['channelEnter'].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandChannelLeave: function(textParts) { + return '' + + this.lang['channelLeave'].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandPrivMsg: function(textParts) { + var privMsgText = textParts.slice(1).join(' '); + privMsgText = this.replaceBBCode(privMsgText); + privMsgText = this.replaceHyperLinks(privMsgText); + privMsgText = this.replaceEmoticons(privMsgText); + return '' + + this.lang['privmsg'] + + ' ' + + privMsgText; + }, + + replaceCommandPrivMsgTo: function(textParts) { + var privMsgText = textParts.slice(2).join(' '); + privMsgText = this.replaceBBCode(privMsgText); + privMsgText = this.replaceHyperLinks(privMsgText); + privMsgText = this.replaceEmoticons(privMsgText); + return '' + + this.lang['privmsgto'].replace(/%s/, textParts[1]) + + ' ' + + privMsgText; + }, + + replaceCommandPrivAction: function(textParts) { + var privActionText = textParts.slice(1).join(' '); + privActionText = this.replaceBBCode(privActionText); + privActionText = this.replaceHyperLinks(privActionText); + privActionText = this.replaceEmoticons(privActionText); + return '' + + privActionText + + ' ' + + this.lang['privmsg'] + + ' '; + }, + + replaceCommandPrivActionTo: function(textParts) { + var privActionText = textParts.slice(2).join(' '); + privActionText = this.replaceBBCode(privActionText); + privActionText = this.replaceHyperLinks(privActionText); + privActionText = this.replaceEmoticons(privActionText); + return '' + + privActionText + + ' ' + + this.lang['privmsgto'].replace(/%s/, textParts[1]) + + ' '; + }, + + replaceCommandAction: function(textParts) { + var actionText = textParts.slice(1).join(' '); + actionText = this.replaceBBCode(actionText); + actionText = this.replaceHyperLinks(actionText); + actionText = this.replaceEmoticons(actionText); + return '' + + actionText + + ''; + }, + + replaceCommandInvite: function(textParts) { + var inviteText = this.lang['invite'] + .replace(/%s/, textParts[1]) + .replace( + /%s/, + '' + + textParts[2] + + '' + ); + return '' + + inviteText + + ''; + }, + + replaceCommandInviteTo: function(textParts) { + var inviteText = this.lang['inviteto'] + .replace(/%s/, textParts[1]) + .replace(/%s/, textParts[2]); + return '' + + inviteText + + ''; + }, + + replaceCommandUninvite: function(textParts) { + var uninviteText = this.lang['uninvite'] + .replace(/%s/, textParts[1]) + .replace(/%s/, textParts[2]); + return '' + + uninviteText + + ''; + }, + + replaceCommandUninviteTo: function(textParts) { + var uninviteText = this.lang['uninviteto'] + .replace(/%s/, textParts[1]) + .replace(/%s/, textParts[2]); + return '' + + uninviteText + + ''; + }, + + replaceCommandQueryOpen: function(textParts) { + return '' + + this.lang['queryOpen'].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandQueryClose: function(textParts) { + return '' + + this.lang['queryClose'].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandIgnoreAdded: function(textParts) { + return '' + + this.lang['ignoreAdded'].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandIgnoreRemoved: function(textParts) { + return '' + + this.lang['ignoreRemoved'].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandIgnoreList: function(textParts) { + return '' + + this.lang['ignoreList'] + ' ' + + this.getInlineUserMenu(textParts.slice(1)) + + ''; + }, + + replaceCommandIgnoreListEmpty: function(textParts) { + return '' + + this.lang['ignoreListEmpty'] + + ''; + }, + + replaceCommandKick: function(textParts) { + return '' + + this.lang['logoutKicked'].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandWho: function(textParts) { + return '' + + this.lang['who'] + ' ' + + this.getInlineUserMenu(textParts.slice(1)) + + ''; + }, + + replaceCommandWhoChannel: function(textParts) { + return '' + + this.lang['whoChannel'].replace(/%s/, textParts[1]) + ' ' + + this.getInlineUserMenu(textParts.slice(2)) + + ''; + }, + + replaceCommandWhoEmpty: function(textParts) { + return '' + + this.lang['whoEmpty'] + + ''; + }, + + replaceCommandList: function(textParts) { + var channels = textParts.slice(1); + var listChannels = new Array(); + var channelName; + for(var i=0; i'+channels[i]+'' : channels[i]; + listChannels.push( + '' + + channelName + + '' + ); + } + return '' + + this.lang['list'] + ' ' + + listChannels.join(', ') + + ''; + }, + + replaceCommandBans: function(textParts) { + var users = textParts.slice(1); + var listUsers = new Array(); + for(var i=0; i' + + users[i] + + '' + ); + } + return '' + + this.lang['bans'] + ' ' + + listUsers.join(', ') + + ''; + }, + + replaceCommandBansEmpty: function(textParts) { + return '' + + this.lang['bansEmpty'] + + ''; + }, + + replaceCommandUnban: function(textParts) { + return '' + + this.lang['unban'].replace(/%s/, textParts[1]) + + ''; + }, + + replaceCommandWhois: function(textParts) { + return '' + + this.lang['whois'].replace(/%s/, textParts[1]) + ' ' + + textParts[2] + + ''; + }, + + replaceCommandWhereis: function(textParts) { + return '' + + this.lang['whereis'].replace(/%s/, textParts[1]).replace( + /%s/, + '' + + textParts[2] + + '' + ) + + ''; + }, + + replaceCommandRoll: function(textParts) { + var rollText = this.lang['roll'].replace(/%s/, textParts[1]); + rollText = rollText.replace(/%s/, textParts[2]); + rollText = rollText.replace(/%s/, textParts[3]); + return '' + + rollText + + ''; + }, + + replaceCommandNick: function(textParts) { + return '' + + this.lang['nick'].replace(/%s/, textParts[1]).replace(/%s/, textParts[2]) + + ''; + }, + + replaceCommandError: function(textParts) { + var errorMessage = this.lang['error'+textParts[1]]; + if(!errorMessage) { + errorMessage = 'Error: Unknown.'; + } else if(textParts.length > 2) { + errorMessage = errorMessage.replace(/%s/, textParts.slice(2).join(' ')); + } + return '' + + errorMessage + + ''; + }, + + getInlineUserMenu: function(users) { + var menu = ''; + for(var i=0; i0) { + menu += ', '; + } + menu += '' + + ((users[i] == this.userName) ? ''+users[i]+'' : users[i]) + + '' + + ''; + } + this.userMenuCounter++; + return menu; + }, + + containsUnclosedTags: function(str) { + if (!arguments.callee.regExpOpenTags || !arguments.callee.regExpCloseTags) { + arguments.callee.regExpOpenTags = new RegExp('<[^>\\/]+?>', 'gm'); + arguments.callee.regExpCloseTags = new RegExp('<\\/[^>]+?>', 'gm'); + } + var openTags = str.match(arguments.callee.regExpOpenTags); + var closeTags = str.match(arguments.callee.regExpCloseTags); + // Return true if the number of tags doesn't match: + if((!openTags && closeTags) || + (openTags && !closeTags) || + (openTags && closeTags && (openTags.length != closeTags.length))) { + return true; + } + return false; + }, + + breakLongWords: function(text) { + if(!this.settings['wordWrap']) + return text; + var newText = ''; + var charCounter = 0; + var currentChar, withinTag, withinEntity; + + for(var i=0; i): + if(i>5 && text.substr(i-5,4) == '
    0 && text.charAt(i-1) == '>') { + withinTag = false; + // Reset the charCounter after newline tags (
    ): + if(i>4 && text.substr(i-5,4) == '
    0 && text.charAt(i-1) == ';') { + withinEntity = false; + // We only increase the charCounter once for the whole entiy: + charCounter++; + } + + if(!withinTag && !withinEntity) { + // Reset the charCounter if we encounter a word boundary: + if(currentChar == ' ' || currentChar == '\n' || currentChar == '\t') { + charCounter = 0; + } else { + // We are not within a tag or entity, increase the charCounter: + charCounter++; + } + if(charCounter > this.settings['maxWordLength']) { + // maxWordLength has been reached, break here and reset the charCounter: + newText += this.getBreakString(); + charCounter = 0; + } + } + // Add the current char to the text: + newText += currentChar; + } + + return newText; + }, + + getBreakString: function() { + // Returns the character sequence used to wrap long words + if(typeof arguments.callee.breakString == 'undefined') { + arguments.callee.breakString = '​'; + } + return arguments.callee.breakString; + }, + + replaceBBCode: function(text) { + if(!this.settings['bbCode']) { + // If BBCode is disabled, just strip the text from BBCode tags: + if (!arguments.callee.regExpStripBBCode) { + arguments.callee.regExpStripBBCode = new RegExp( + '\\[(?:\\/)?(\\w+)(?:=([^<>]*?))?\\]', + 'gm' + ); + } + return text.replace( + arguments.callee.regExpStripBBCode, + '' + ); + } + // Remove the BBCode tags: + if (!arguments.callee.regExp) { + arguments.callee.regExp = new RegExp( + '\\[(\\w+)(?:=([^<>]*?))?\\](.+?)\\[\\/\\1\\]', + 'gm' + ); + } + return text.replace( + arguments.callee.regExp, + this.replaceBBCodeCallback + ); + }, + + replaceBBCodeCallback: function(str, p1, p2, p3) { + // Only replace predefined BBCode tags: + if(!ajaxChat.inArray(ajaxChat.bbCodeTags, p1)) { + return str; + } + // Avoid invalid XHTML (unclosed tags): + if(ajaxChat.containsUnclosedTags(p3)) { + return str; + } + switch(p1) { + case 'color': + return ajaxChat.replaceBBCodeColor(p3, p2); + case 'url': + return ajaxChat.replaceBBCodeUrl(p3, p2); + case 'img': + return ajaxChat.replaceBBCodeImage(p3); + case 'quote': + return ajaxChat.replaceBBCodeQuote(p3, p2); + case 'code': + return ajaxChat.replaceBBCodeCode(p3); + case 'u': + return ajaxChat.replaceBBCodeUnderline(p3); + default: + return ajaxChat.replaceCustomBBCode(p1, p2, p3); + } + }, + + replaceBBCodeColor: function(content, attribute) { + if(this.settings['bbCodeColors']) { + // Only allow predefined color codes: + if(!attribute || !this.inArray(ajaxChat.colorCodes, attribute)) + return content; + return '' + + this.replaceBBCode(content) + + ''; + } + return content; + }, + + replaceBBCodeUrl: function(content, attribute) { + var url; + if(attribute) + url = attribute.replace(/\s/gm, this.encodeText(' ')); + else + url = this.stripBBCodeTags(content.replace(/\s/gm, this.encodeText(' '))); + if (!arguments.callee.regExpUrl) { + arguments.callee.regExpUrl = new RegExp( + '^(?:(?:http)|(?:https)|(?:ftp)|(?:irc)):\\/\\/', + '' + ); + } + if(!url || !url.match(arguments.callee.regExpUrl)) + return content; + return '' + + this.replaceBBCode(content) + + ''; + }, + + replaceBBCodeImage: function(url) { + ++this.imageID; + if(this.settings['bbCodeImages']) { + if (!arguments.callee.regExpUrl) { + arguments.callee.regExpUrl = new RegExp( + this.regExpMediaUrl, + '' + ); + } + if(!url || !url.match(arguments.callee.regExpUrl)) + return url; + url = this.stripTags(url.replace(/\s/gm, this.encodeText(' '))); + url = this.stripTags(url.replace(/\r/gm, this.encodeText(' '))); + url = this.stripTags(url.replace(/\n/gm, this.encodeText(' '))); + //return ''+''; + return ''+url+' [Embed] '; + } + return url; + }, + + parseEmbedImage: function(id,mode) { + var image = document.getElementById('img'+id); + var url = image.getAttribute('href'); + var embed = document.getElementById('imge'+id); + var maxWidth = this.dom['chatList'].offsetWidth-50; + var maxHeight = this.dom['chatList'].offsetHeight-50; + if(mode) { + image.innerHTML = url; + embed.innerHTML = 'Embed'; + embed.setAttribute('onclick','ajaxChat.parseEmbedImage(\''+id+'\',0);'); + } else { + image.innerHTML = ''; + embed.innerHTML = 'Remove'; + embed.setAttribute('onclick','ajaxChat.parseEmbedImage(\''+id+'\',1);'); + } + }, + + replaceBBCodeQuote: function(content, attribute) { + if(attribute) + return '' + + this.lang['cite'].replace(/%s/, attribute) + + '' + + this.replaceBBCode(content) + + ''; + return '' + + this.replaceBBCode(content) + + ''; + }, + + replaceBBCodeCode: function(content) { + // Replace vertical tabs and multiple spaces with two non-breaking space characters: + return '' + + this.replaceBBCode(content.replace(/\t|(?: )/gm, '  ')) + + ''; + }, + + replaceBBCodeUnderline: function(content) { + return '' + + this.replaceBBCode(content) + + ''; + }, + + replaceHyperLinks: function(text) { + if(!this.settings['hyperLinks']) { + return text; + } + if(!arguments.callee.regExp) { + arguments.callee.regExp = new RegExp( + '(^|\\s|>)((?:(?:http)|(?:https)|(?:ftp)|(?:irc)):\\/\\/[^\\s<>]+)(<\\/a>)?', + 'gm' + ); + } + return text.replace( + arguments.callee.regExp, + // Specifying an anonymous function as second parameter: + function(str, p1, p2, p3) { + // Do not replace URL's inside URL's: + if(p3) { + return str; + } + return p1 + + '' + + p2 + + ''; + } + ); + }, + + replaceLineBreaks: function(text) { + if (!arguments.callee.regExp) { + arguments.callee.regExp = new RegExp('\\n', 'g'); + } + if(!this.settings['lineBreaks']) { + return text.replace(arguments.callee.regExp, ' '); + } else { + return text.replace(arguments.callee.regExp, '
    '); + } + }, + + replaceEmoticons: function(text) { + if(!this.settings['emoticons']) { + return text; + } + if(!arguments.callee.regExp) { + var regExpStr = '^(.*)('; + for(var i=0; i' + + ajaxChat.replaceEmoticons(p3); + } + return str; + }, + + getActiveStyle: function() { + var cookie = this.readCookie(this.sessionName + '_style'); + var style = cookie ? cookie : this.getPreferredStyleSheet(); + return style; + }, + + initStyle: function() { + this.styleInitiated = true; + this.setActiveStyleSheet(this.getActiveStyle()); + }, + + persistStyle: function() { + if(this.styleInitiated) { + this.createCookie(this.sessionName + '_style', this.getActiveStyleSheet(), this.cookieExpiration); + } + }, + + setSelectedStyle: function() { + if(this.dom['styleSelection']) { + var style = this.getActiveStyle(); + var styleOptions = this.dom['styleSelection'].getElementsByTagName('option'); + for(var i=0; imenuItem ) + // encodedUserName contains the userName ready to be used for javascript links + // userID is only available for the online users menu - not for the inline user menu + // use (encodedUserName == this.encodedUserName) to check for the current user + getCustomUserMenuItems: function(encodedUserName, userID) { + return ''; + }, + + // Override to parse custom input messages: + // Return replaced text + // text contains the whole message + parseCustomInputMessage: function(text) { + return text; + }, + + // Override to parse custom input commands: + // Return parsed text + // text contains the whole message, textParts the message split up as words array + parseCustomInputCommand: function(text, textParts) { + return text; + }, + + // Override to replace custom text: + // Return replaced text + // text contains the whole message + replaceCustomText: function(text) { + return text; + }, + + // Override to replace custom commands: + // Return replaced text for custom commands + // text contains the whole message, textParts the message split up as words array + replaceCustomCommands: function(text, textParts) { + return text; + }, + + // Override to replace custom BBCodes: + // Return replaced text and call replaceBBCode recursively for the content text + // tag contains the BBCode tag, attribute the BBCode attribute and content the content text + // This method is only called for BBCode tags which are in the bbCodeTags list + replaceCustomBBCode: function(tag, attribute, content) { + return '<' + tag + '>' + this.replaceBBCode(content) + ''; + }, + + // Override to perform custom actions on new messages: + // Return true if message is to be added to the chatList, else false + customOnNewMessage: function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) { + return true; + } + +} \ No newline at end of file diff --git a/public/js/config.js b/public/js/config.js new file mode 100644 index 0000000..1c1f546 --- /dev/null +++ b/public/js/config.js @@ -0,0 +1,292 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +// Ajax Chat config parameters: +var ajaxChatConfig = { + + // The channelID of the channel to enter on login (the loginChannelName is used if set to null): + loginChannelID: null, + // The channelName of the channel to enter on login (the default channel is used if set to null): + loginChannelName: null, + + // The time in ms between update calls to retrieve new chat messages: + timerRate: 2000, + + // The URL to retrieve the XML chat messages (must at least contain one parameter): + ajaxURL: './?ajax=true', + // The base URL of the chat directory, used to retrieve media files (images, sound files, etc.): + baseURL: './', + + // A regular expression for allowed source URL's for media content (e.g. images displayed inline); + regExpMediaUrl: '^((http)|(https)):\\/\\/', + + // If set to false the chat update is delayed until the event defined in ajaxChat.setStartChatHandler(): + startChatOnLoad: true, + + // Defines the IDs of DOM nodes accessed by the chat: + domIDs: { + // The ID of the chat messages list: + chatList: 'chatList', + // The ID of the online users list: + onlineList: 'onlineList', + // The ID of the message text input field: + inputField: 'inputField', + // The ID of the message text length counter: + messageLengthCounter: 'messageLengthCounter', + // The ID of the channel selection: + channelSelection: 'channelSelection', + // The ID of the style selection: + styleSelection: 'styleSelection', + // The ID of the emoticons container: + emoticonsContainer: 'emoticonsContainer', + // The ID of the color codes container: + colorCodesContainer: 'colorCodesContainer', + // The ID of the flash interface container: + flashInterfaceContainer: 'flashInterfaceContainer' + }, + + // Defines the settings which can be modified by users: + settings: { + // Defines if BBCode tags are replaced with the associated HTML code tags: + bbCode: true, + // Defines if image BBCode is replaced with the associated image HTML code: + bbCodeImages: true, + // Defines if color BBCode is replaced with the associated color HTML code: + bbCodeColors: true, + // Defines if hyperlinks are made clickable: + hyperLinks: true, + // Defines if line breaks are enabled: + lineBreaks: true, + // Defines if emoticon codes are replaced with their associated images: + emoticons: true, + + // Defines if the focus is automatically set to the input field on chat load or channel switch: + autoFocus: true, + // Defines if the chat list scrolls automatically to display the latest messages: + autoScroll: true, + // The maximum count of messages displayed in the chat list (will be ignored if set to 0): + maxMessages: 0, + + // Defines if long words are wrapped to avoid vertical scrolling: + wordWrap: false, + // Defines the maximum length before a word gets wrapped: + maxWordLength: 32, + + // Defines the format of the date and time displayed for each chat message: + dateFormat: '(%H:%i:%s)', + + // Defines if font colors persist without the need to assign them to each message: + persistFontColor: true, + // The default font color, uses the page default font color if set to null: + fontColor: null, + + // Defines if sounds are played: + audio: true, + // Defines the sound volume (0.0 = mute, 1.0 = max): + audioVolume: 1.0, + + // Defines the sound that is played when normal messages are reveived: + soundReceive: 'sound_1', + // Defines the sound that is played on sending normal messages: + soundSend: 'sound_2', + // Defines the sound that is played on channel enter or login: + soundEnter: 'sound_3', + // Defines the sound that is played on channel leave or logout: + soundLeave: 'sound_4', + // Defines the sound that is played on chatBot messages: + soundChatBot: 'sound_5', + // Defines the sound that is played on error messages: + soundError: 'sound_6', + // Defines the sound that is played on kicked messages: + soundKick: 'sound_7', + // Defines the sound that is played when private messages are received: + soundPrivate: 'sound_1', + + // Defines if the document title blinks on new messages: + blink: true, + // Defines the blink interval in ms: + blinkInterval: 500, + // Defines the number of blink intervals: + blinkIntervalNumber: 10 + }, + + // Defines a list of settings which are not to be stored in a session cookie: + nonPersistentSettings: new Array( + 'wordWrap' + ), + + // Defines the list of allowed BBCodes: + bbCodeTags: new Array( + 'b', + 'i', + 'u', + 'quote', + 'code', + 'color', + 'url', + 'img' + ), + + // Defines the list of allowed color codes: + colorCodes: new Array( + 'Silver', + 'Citrine', + 'Orange', + 'Pumpkin', + 'Red', + 'Crimson', + 'Ruby', + 'Amaranth', + 'Thulite', + 'Pink', + 'Amethyst', + 'Purpureus', + 'Antisia', + 'Cerulean', + 'Cobalt', + 'Aqua', + 'Mint', + 'Keppel', + 'Teal', + 'Green', + 'Chartreuse', + 'Nitrate', + 'Lilive', + 'Daive' + ), + + // Defines the list of allowed emoticon codes: + emoticonCodes: new Array( + ':happy:', + ':lmao:', + ':angry:', + ':angrier:', + ':evil:', + ':glare:', + ':eat:', + ':lol:', + ':dizzy:', + ':yay:', + ':wtf:', + ':sigh:', + ':omg:', + ':ouch:', + ':tired:', + ':kiss:', + ':love:', + ':sweat:', + ':suspicious:', + ':crying:', + ':blank:', + ':puke:', + ':ruse:', + ':meow:', + ':jew:', + ':winxp:', + ':childish:', + ':idea:' + ), + + // Defines the list of emoticon files associated with the emoticon codes: + emoticonFiles: new Array( + 'happy.png', + 'lmao.png', + 'angry.png', + 'angrier.png', + 'evil.png', + 'glare.png', + 'eat.gif', + 'lol.png', + 'dizzy.gif', + 'vhappy.png', + 'wtf.png', + 'sigh.png', + 'omg.png', + 'ouch.png', + 'tired.gif', + 'kiss.gif', + 'love.png', + 'sweat.gif', + 'suspicious.gif', + 'crying.png', + 'blank.png', + 'puke.gif', + 'ruse.png', + 'meow.png', + 'jew.png', + 'winxp.png', + 'childish.png', + 'idea.png' + ), + + // Defines the available sounds loaded on chat start: + soundFiles: { + sound_1: 'ajax_incoming.mp3', + sound_2: 'ajax_outgoing.mp3', + sound_3: 'ajax_login.mp3', + sound_4: 'ajax_logout.mp3', + sound_5: 'ajax_chatbot.mp3', + sound_6: 'ajax_error.mp3', + sound_7: 'dokuro_pipiru.mp3', + sound_8: 'ajax_shit.mp3', + dicks: 'dicks.mp3', + xp_1: 'xp_incoming.mp3', + xp_2: 'xp_outgoing.mp3', + xp_3: 'xp_login.mp3', + xp_4: 'xp_logout.mp3', + xp_5: 'xp_chatbot.mp3', + xp_6: 'xp_error.mp3' + }, + + + // The following configuration options are usually overwritten by server-side values: + + // Session identification, used for style and setting cookies: + sessionName: 'ajax_chat', + + // The time in days until the style and setting cookies expire: + cookieExpiration: 365, + // The path of the cookies, '/' allows to read the cookies from all directories: + cookiePath: '/', + // The domain of the cookies, defaults to the hostname of the server if set to null: + cookieDomain: null, + // If enabled, cookies must be sent over secure (SSL/TLS encrypted) connections: + cookieSecure: null, + + // The name of the chat bot: + chatBotName: 'Koishi', + // The userID of the chat bot: + chatBotID: 2147483647, + + // Allow/Disallow registered users to delete their own messages: + allowUserMessageDelete: false, + + // Minutes until a user is declared inactive (last status update) - the minimum is 2 minutes: + inactiveTimeout: 2, + + // UserID plus this value are private channels (this is also the max userID and max channelID): + privateChannelDiff: 500000000, + // UserID plus this value are used for private messages: + privateMessageDiff: 1000000000, + + // Defines if login/logout and channel enter/leave are displayed: + showChannelMessages: true, + + // Max messageText length: + messageTextMaxLength: 2000, + + // Defines if the socket server is enabled: + socketServerEnabled: false, + // Defines the hostname of the socket server used to connect from client side: + socketServerHost: 'localhost', + // Defines the port of the socket server: + socketServerPort: 1935, + // This ID can be used to distinguish between different chat installations using the same socket server: + socketServerChatID: 0 + +} \ No newline at end of file diff --git a/public/js/custom.js b/public/js/custom.js new file mode 100644 index 0000000..ad661bf --- /dev/null +++ b/public/js/custom.js @@ -0,0 +1,40 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +// Overriding client side functionality: + +/* +// Example - Overriding the replaceCustomCommands method: +ajaxChat.replaceCustomCommands = function(text, textParts) { + return text; +} + */ + +ajaxChat.customInitialize = function() { + ajaxChat.addChatBotMessageToChatList("[b]Welcome to Flashii Chat![/b]"); + ajaxChat.addChatBotMessageToChatList("[i]the one time i tried to use gimp i got scared and tried closing it and it crashed[/i]"); +} + +ajaxChat.loadHTML5Sounds=function(){ + aO = document.createElement('audio'); + aO.id = 'audioObject'; + document.body.appendChild(aO); + this.audioObject = document.getElementById('audioObject'); + this.setAudioVolume(this.settings['audioVolume']); + this.sounds = {}; + for(var key in this.soundFiles){ + this.sounds[key] = this.dirs['sounds']+this.soundFiles[key]; + } +} +ajaxChat.playHTML5Sound=function(soundID,soundFile){ + this.audioObject.src = soundFile; + this.audioObject.play(); +} +ajaxChat.setHTML5SoundVolume=function(volume){ + this.audioObject.volume = volume; +} diff --git a/public/js/index.html b/public/js/index.html new file mode 100644 index 0000000..e69de29 diff --git a/public/js/lang/en.js b/public/js/lang/en.js new file mode 100644 index 0000000..12d03e0 --- /dev/null +++ b/public/js/lang/en.js @@ -0,0 +1,95 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +// Ajax Chat language Object: +var ajaxChatLang = { + + login: '%s logs into the Chat.', + logout: '%s logs out of the Chat.', + logoutTimeout: '%s has been logged out (Exploded).', + //logoutTimeout: '%s has been logged out (Timeout).', + //logoutKicked: '%s has been kekked from the Chat.', + logoutKicked: '%s got clubbed to death.', + logoutIP: '%s has been logged out (Invalid IP address).', + channelEnter: '%s enters the channel.', + channelLeave: '%s leaves the channel.', + privmsg: '(whispers)', + privmsgto: '(whispers to %s)', + invite: '%s invites you to join %s.', + inviteto: 'Your invitation to %s to join channel %s has been sent.', + uninvite: '%s uninvites you from channel %s.', + uninviteto: 'Your uninvitation to %s for channel %s has been sent.', + queryOpen: 'Private channel opened to %s.', + queryClose: 'Private channel to %s closed.', + ignoreAdded: 'Added %s to the ignore list.', + ignoreRemoved: 'Removed %s from the ignore list.', + ignoreList: 'Ignored Users:', + ignoreListEmpty: 'No ignored Users listed.', + who: 'Online Users:', + whoChannel: 'Online Users in channel %s:', + whoEmpty: 'No online users in the given channel.', + list: 'Available channels:', + bans: 'Banned Users:', + bansEmpty: 'No banned Users listed.', + unban: 'Ban of user %s revoked.', + whois: 'User %s - IP address:', + whereis: 'User %s is in channel %s.', + roll: '%s rolls %s and gets %s.', + nick: '%s is now known as %s.', + toggleUserMenu: 'Toggle user menu for %s', + userMenuLogout: 'Logout', + userMenuWho: 'List online users', + userMenuList: 'List available channels', + userMenuAction: 'Describe action', + userMenuRoll: 'Roll dice', + userMenuNick: 'Change username', + userMenuEnterPrivateRoom: 'Enter private room', + userMenuSendPrivateMessage: 'Send private message', + userMenuDescribe: 'Send private action', + userMenuOpenPrivateChannel: 'Open private channel', + userMenuClosePrivateChannel: 'Close private channel', + userMenuInvite: 'Invite', + userMenuUninvite: 'Uninvite', + userMenuIgnore: 'Ignore/Accept', + userMenuIgnoreList: 'List ignored users', + userMenuWhereis: 'Display channel', + userMenuKick: 'Kick/Ban', + userMenuBans: 'List banned users', + userMenuWhois: 'Display IP', + userMenuLogs: 'Enter logs', + userMenuViewProfile: 'View profile', + unbanUser: 'Ban on user %s revoked.', + joinChannel: 'Join channel %s', + cite: '%s said:', + urlDialog: 'Please enter the address (URL) of the webpage:', + deleteMessage: 'Delete this chat message', + deleteMessageConfirm: 'Are you sure you want to delete the selected chat message?', + errorCookiesRequired: 'Cookies are required for this chat.', + errorUserNameNotFound: 'Error: User %s not found.', + errorMissingText: 'Error: Missing message text.', + errorMissingUserName: 'Error: Missing username.', + errorInvalidUserName: 'Error: Invalid username.', + errorUserNameInUse: 'Error: Username already in use.', + errorMissingChannelName: 'Error: Missing channel name.', + errorInvalidChannelName: 'Error: Invalid channel name: %s', + errorPrivateMessageNotAllowed: 'Error: Private messages are not allowed.', + errorInviteNotAllowed: 'Error: You are not allowed to invite someone to this channel.', + errorUninviteNotAllowed: 'Error: You are not allowed to uninvite someone from this channel.', + errorNoOpenQuery: 'Error: No private channel open.', + errorKickNotAllowed: 'You are not allowed to kick %s', + errorCommandNotAllowed: 'You are not allowed to do %s', + errorUnknownCommand: 'Error: Command %s does not exist.', + errorMaxMessageRate: 'Error: You exceeded the maximum number of messages per minute.', + errorConnectionTimeout: 'Error: Connection timeout. Please try again.', + errorConnectionStatus: 'Error: Connection status: %s', + errorSoundIO: 'Error: Failed to load sound file (Flash IO Error).', + errorSocketIO: 'Error: Connection to socket server failed (Flash IO Error).', + errorSocketSecurity: 'Error: Connection to socket server failed (Flash Security Error).', + errorDOMSyntax: 'Error: Invalid DOM Syntax (DOM ID: %s).', + errorHolyRoll: 'Congratulations, you\'ve found the roll command. But it\'s rank protected so jokes on you!' +} \ No newline at end of file diff --git a/public/js/lang/index.html b/public/js/lang/index.html new file mode 100644 index 0000000..e69de29 diff --git a/public/js/logs.js b/public/js/logs.js new file mode 100644 index 0000000..a26d59e --- /dev/null +++ b/public/js/logs.js @@ -0,0 +1,128 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +// Overrides client-side functionality for the logs view: + + ajaxChat.logsMonitorMode = null; + ajaxChat.logsLastID = null; + ajaxChat.logsCommand = null; + + ajaxChat.startChatUpdate = function() { + var infos = 'userID,userName,userRole'; + if(this.socketServerEnabled) { + infos += ',socketRegistrationID'; + } + this.updateChat('&getInfos=' + this.encodeText(infos)); + } + + ajaxChat.updateChat = function(paramString) { + // Only update if we have parameters, are in monitor mode or the lastID has changed since the last update: + if(paramString || this.logsMonitorMode || !this.logsLastID || this.lastID != this.logsLastID) { + // Update the logsLastID for the lastID check: + this.logsLastID = this.lastID; + + var requestUrl = this.ajaxURL + + '&lastID=' + + this.lastID; + if(paramString) { + requestUrl += paramString; + } + requestUrl += '&' + this.getLogsCommand(); + this.makeRequest(requestUrl,'GET',null); + } else { + this.logsLastID = null; + } + } + + ajaxChat.sendMessage = function() { + this.getLogs(); + } + + ajaxChat.getLogs = function() { + clearTimeout(this.timer); + this.clearChatList(); + this.lastID = 0; + this.logsCommand = null; + this.makeRequest(this.ajaxURL,'POST',this.getLogsCommand()); + } + + ajaxChat.getLogsCommand = function() { + if(!this.logsCommand) { + if(!this.dom['inputField'].value && + parseInt(this.dom['yearSelection'].value) <= 0 && + parseInt(this.dom['hourSelection'].value) <= 0) { + this.logsMonitorMode = true; + } else { + this.logsMonitorMode = false; + } + this.logsCommand = 'command=getLogs' + + '&channelID=' + this.dom['channelSelection'].value + + '&year=' + this.dom['yearSelection'].value + + '&month=' + this.dom['monthSelection'].value + + '&day=' + this.dom['daySelection'].value + + '&hour=' + this.dom['hourSelection'].value + + '&search=' + this.encodeText(this.dom['inputField'].value); + } + return this.logsCommand; + } + + ajaxChat.onNewMessage = function(dateObject, userID, userName, userRoleClass, messageID, messageText, channelID, ip) { + if(messageText.indexOf('/delete') == 0) { + return false; + } + if(this.logsMonitorMode) { + this.blinkOnNewMessage(dateObject, userID, userName, userRoleClass, messageID, messageText, channelID, ip); + this.playSoundOnNewMessage( + dateObject, userID, userName, userRoleClass, messageID, messageText, channelID, ip + ); + } + return true; + } + + ajaxChat.logout = function() { + clearTimeout(this.timer); + this.makeRequest(this.ajaxURL,'POST','logout=true'); + } + + ajaxChat.switchLanguage = function(langCode) { + window.location.search = '?view=logs&lang='+langCode; + } + + ajaxChat.setChatUpdateTimer = function() { + clearTimeout(this.timer); + var timeout; + if(this.socketIsConnected && this.logsLastID && this.lastID == this.logsLastID) { + timeout = this.socketTimerRate; + } else { + timeout = this.timerRate; + if(this.socketServerEnabled && !this.socketReconnectTimer) { + // If the socket connection fails try to reconnect once in a minute: + this.socketReconnectTimer = setTimeout('ajaxChat.socketConnect();', 60000); + } + } + this.timer = setTimeout('ajaxChat.updateChat(null);', timeout); + } + + ajaxChat.socketUpdate = function(data) { + if(this.logsMonitorMode) { + var xmlDoc = this.loadXML(data); + if(xmlDoc) { + var selectedChannelID = parseInt(this.dom['channelSelection'].value); + var channelID = parseInt(xmlDoc.firstChild.getAttribute('channelID')); + if(selectedChannelID == -3 || channelID == selectedChannelID || + selectedChannelID == -2 && channelID >= this.privateMessageDiff || + selectedChannelID == -1 + && channelID >= this.privateChannelDiff + && channelID < this.privateMessageDiff + ) { + this.handleChatMessages(xmlDoc.getElementsByTagName('message')); + } + } + } + } + \ No newline at end of file diff --git a/public/js/shoutbox.js b/public/js/shoutbox.js new file mode 100644 index 0000000..fd2b30f --- /dev/null +++ b/public/js/shoutbox.js @@ -0,0 +1,12 @@ +/* + * @package AJAX_Chat + * @author Sebastian Tschan + * @copyright (c) Sebastian Tschan + * @license GNU Affero General Public License + * @link https://blueimp.net/ajax/ + */ + +// Overrides functionality for the shoutbox view: + + ajaxChat.handleLogout = function() { + } diff --git a/public/lib/.htaccess b/public/lib/.htaccess new file mode 100644 index 0000000..91e386d --- /dev/null +++ b/public/lib/.htaccess @@ -0,0 +1,4 @@ +AuthType Basic +AuthName "Forbidden" +AuthUserFile /dev/null +require user nobody \ No newline at end of file diff --git a/public/lib/class/AJAXChat.php b/public/lib/class/AJAXChat.php new file mode 100644 index 0000000..80fb2c5 --- /dev/null +++ b/public/lib/class/AJAXChat.php @@ -0,0 +1,3491 @@ +initConfig(); + + // Initialize the DataBase connection: + $this->initDataBaseConnection(); + + // Initialize request variables: + $this->initRequestVars(); + + // Initialize the chat session: + $this->initSession(); + + // Handle the browser request and send the response content: + $this->handleRequest(); + } + + function initConfig() { + $config = null; + if(!include(AJAX_CHAT_PATH.'lib/config.php')) { + print('Error: Configuration file could not be loaded.'); + exit; + } + $this->_config = &$config; + + // Initialize custom configuration settings: + $this->initCustomConfig(); + } + + function initRequestVars() { + $this->_requestVars = array(); + $this->_requestVars['ajax'] = isset($_REQUEST['ajax']) ? true : false; + $this->_requestVars['userID'] = isset($_REQUEST['userID']) ? (int)$_REQUEST['userID'] : null; + $this->_requestVars['userName'] = isset($_REQUEST['userName']) ? $_REQUEST['userName'] : null; + $this->_requestVars['channelID'] = isset($_REQUEST['channelID']) ? (int)$_REQUEST['channelID'] : null; + $this->_requestVars['channelName'] = isset($_REQUEST['channelName']) ? $_REQUEST['channelName'] : null; + $this->_requestVars['text'] = isset($_POST['text']) ? $_POST['text'] : null; + $this->_requestVars['lastID'] = isset($_REQUEST['lastID']) ? (int)$_REQUEST['lastID'] : 0; + $this->_requestVars['login'] = isset($_REQUEST['login']) ? true : false; + $this->_requestVars['logout'] = isset($_POST['logout']) ? true : false; + $this->_requestVars['password'] = isset($_REQUEST['password']) ? $_REQUEST['password'] : null; + $this->_requestVars['view'] = isset($_REQUEST['view']) ? $_REQUEST['view'] : null; + $this->_requestVars['year'] = isset($_REQUEST['year']) ? (int)$_REQUEST['year'] : null; + $this->_requestVars['month'] = isset($_REQUEST['month']) ? (int)$_REQUEST['month'] : null; + $this->_requestVars['day'] = isset($_REQUEST['day']) ? (int)$_REQUEST['day'] : null; + $this->_requestVars['hour'] = isset($_REQUEST['hour']) ? (int)$_REQUEST['hour'] : null; + $this->_requestVars['search'] = isset($_REQUEST['search']) ? $_REQUEST['search'] : null; + $this->_requestVars['shoutbox'] = isset($_REQUEST['shoutbox']) ? true : false; + $this->_requestVars['getInfos'] = isset($_REQUEST['getInfos']) ? $_REQUEST['getInfos'] : null; + $this->_requestVars['lang'] = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : null; + $this->_requestVars['delete'] = isset($_REQUEST['delete']) ? (int)$_REQUEST['delete'] : null; + + // Initialize custom request variables: + $this->initCustomRequestVars(); + + // Remove slashes which have been added to user input strings if magic_quotes_gpc is On: + /*if(get_magic_quotes_gpc()) { + // It is safe to remove the slashes as we escape user data ourself + array_walk( + $this->_requestVars, + create_function( + '&$value, $key', + 'if(is_string($value)) $value = stripslashes($value);' + ) + ); + }*/ + } + + function initDataBaseConnection() { + // Create a new database object: + $this->db = new AJAXChatDataBase( + $this->_config['dbConnection'] + ); + // Use a new database connection if no existing is given: + if(!$this->_config['dbConnection']['link']) { + // Connect to the database server: + $this->db->connect($this->_config['dbConnection']); + if($this->db->error()) { + echo $this->db->getError(); + die(); + } + // Select the database: + $this->db->select($this->_config['dbConnection']['name']); + if($this->db->error()) { + echo $this->db->getError(); + die(); + } + } + // Unset the dbConnection array for safety purposes: + unset($this->_config['dbConnection']); + } + + function getDataBaseTable($table) { + return ($this->db->getName() ? $this->db->getName().'.'.$this->getConfig('dbTableNames',$table) : $this->getConfig('dbTableNames',$table)); + } + + function initSession() { + // Start the PHP session (if not already started): + $this->startSession(); + + if($this->isLoggedIn()) { + // Logout if we receive a logout request, the chat has been closed or the userID could not be revalidated: + if($this->getRequestVar('logout') || !$this->isChatOpen() || !$this->revalidateUserID()) { + $this->logout(); + return; + } + // Logout if the Session IP is not the same when logged in and ipCheck is enabled: + if($this->getConfig('ipCheck') && ($this->getSessionIP() === null || $this->getSessionIP() != $_SERVER['REMOTE_ADDR'])) { + $this->logout('IP'); + return; + } + } else if( + // Login if auto-login enabled or a login, userName or shoutbox parameter is given: + $this->getConfig('forceAutoLogin') || + $this->getRequestVar('login') || + $this->getRequestVar('userName') || + $this->getRequestVar('shoutbox') + ) { + $this->login(); + } + + // Initialize the view: + $this->initView(); + + if($this->getView() == 'chat') { + $this->initChatViewSession(); + } else if($this->getView() == 'logs') { + $this->initLogsViewSession(); + } + + if(!$this->getRequestVar('ajax') && !headers_sent()) { + // Set style cookie: + $this->setStyle(); + // Set langCode cookie: + $this->setLangCodeCookie(); + } + + $this->initCustomSession(); + } + + function initLogsViewSession() { + if($this->getConfig('socketServerEnabled')) { + if(!$this->getSessionVar('logsViewSocketAuthenticated')) { + $this->updateLogsViewSocketAuthentication(); + $this->setSessionVar('logsViewSocketAuthenticated', true); + } + } + } + + function updateLogsViewSocketAuthentication() { + if($this->getUserRole() != AJAX_CHAT_ADMIN) { + $channels = array(); + foreach($this->getChannels() as $channel) { + if($this->getConfig('logsUserAccessChannelList') && !in_array($channel, $this->getConfig('logsUserAccessChannelList'))) { + continue; + } + array_push($channels, $channel); + } + array_push($channels, $this->getPrivateMessageID()); + array_push($channels, $this->getPrivateChannelID()); + } else { + // The channelID "ALL" authenticates for all channels: + $channels = array('ALL'); + } + $this->updateSocketAuthentication( + $this->getUserID(), + $this->getSocketRegistrationID(), + $channels + ); + } + + function initChatViewSession() { + // If channel is not null we are logged in to the chat view: + if($this->getChannel() !== null) { + // Check if the current user has been logged out due to inactivity: + if(!$this->isUserOnline()) { + $this->logout(); + return; + } + if($this->getRequestVar('ajax')) { + $this->initChannel(); + $this->updateOnlineStatus(); + $this->checkAndRemoveInactive(); + } + } else { + if($this->getRequestVar('ajax')) { + // Set channel, insert login messages and add to online list on first ajax request in chat view: + $this->chatViewLogin(); + } + } + } + + function isChatOpen() { + if($this->getUserRole() == AJAX_CHAT_ADMIN) + return true; + if($this->getConfig('chatClosed')) + return false; + $time = time(); + if($this->getConfig('timeZoneOffset') !== null) { + // Subtract the server timezone offset and add the config timezone offset: + $time -= date('Z', $time); + $time += $this->getConfig('timeZoneOffset'); + } + // Check the opening hours: + if($this->getConfig('openingHour') < $this->getConfig('closingHour')) + { + if(($this->getConfig('openingHour') > date('G', $time)) || ($this->getConfig('closingHour') <= date('G', $time))) + return false; + } + else + { + if(($this->getConfig('openingHour') > date('G', $time)) && ($this->getConfig('closingHour') <= date('G', $time))) + return false; + } + // Check the opening weekdays: + if(!in_array(date('w', $time), $this->getConfig('openingWeekDays'))) + return false; + return true; + } + + function handleRequest() { + if($this->getRequestVar('ajax')) { + if($this->isLoggedIn()) { + // Parse info requests (for current userName, etc.): + $this->parseInfoRequests(); + + // Parse command requests (e.g. message deletion): + $this->parseCommandRequests(); + + // Parse message requests: + $this->initMessageHandling(); + } + // Send chat messages and online user list in XML format: + $this->sendXMLMessages(); + } else { + // Display XHTML content for non-ajax requests: + $this->sendXHTMLContent(); + } + } + + function parseCommandRequests() { + if($this->getRequestVar('delete') !== null) { + $this->deleteMessage($this->getRequestVar('delete')); + } + } + + function parseInfoRequests() { + if($this->getRequestVar('getInfos')) { + $infoRequests = explode(',', $this->getRequestVar('getInfos')); + foreach($infoRequests as $infoRequest) { + $this->parseInfoRequest($infoRequest); + } + } + } + + function parseInfoRequest($infoRequest) { + switch($infoRequest) { + case 'userID': + $this->addInfoMessage($this->getUserID(), 'userID'); + break; + case 'userName': + $this->addInfoMessage($this->getUserName(), 'userName'); + break; + case 'userRole': + $this->addInfoMessage($this->getUserRole(), 'userRole'); + break; + case 'channelID': + $this->addInfoMessage($this->getChannel(), 'channelID'); + break; + case 'channelName': + $this->addInfoMessage($this->getChannelName(), 'channelName'); + break; + case 'socketRegistrationID': + $this->addInfoMessage($this->getSocketRegistrationID(), 'socketRegistrationID'); + break; + default: + $this->parseCustomInfoRequest($infoRequest); + } + } + + function sendXHTMLContent() { + $httpHeader = new AJAXChatHTTPHeader($this->getConfig('contentEncoding'), $this->getConfig('contentType')); + + $template = new AJAXChatTemplate($this, $this->getTemplateFileName(), $httpHeader->getContentType()); + + // Send HTTP header: + $httpHeader->send(); + + // Send parsed template content: + echo $template->getParsedContent(); + } + + function getTemplateFileName() { + switch($this->getView()) { + case 'chat': + return AJAX_CHAT_PATH.'lib/template/loggedIn.html'; + case 'logs': + return AJAX_CHAT_PATH.'lib/template/logs.html'; + case 'mobile': + return AJAX_CHAT_PATH.'lib/template/mobile.html'; + case 'legacy': + return AJAX_CHAT_PATH.'lib/template/legacyLogin.html'; + case 'banned': + return AJAX_CHAT_PATH.'lib/template/banned.html'; + case 'legacy1': + return AJAX_CHAT_PATH.'lib/template/~loggedOut.html'; + case 'legacy2': + return AJAX_CHAT_PATH.'lib/template/loggedOut~.html'; + case 'legacy3': + return AJAX_CHAT_PATH.'lib/template/loggedOutFA.html'; + default: + return AJAX_CHAT_PATH.'lib/template/loggedOut.html'; + } + } + + function initView() { + $this->_view = null; + // "chat" is the default view: + $view = ($this->getRequestVar('view') === null) ? 'chat' : $this->getRequestVar('view'); + if($this->hasAccessTo($view)) { + $this->_view = $view; + } + } + + function getView() { + return $this->_view; + } + + function hasAccessTo($view) { + if(substr($view, 0, 6) === 'legacy') + return !$this->isLoggedIn(); + + switch($view) { + case 'legacy': + if($this->isLoggedIn()) { + return false; + } + return true; + case 'banned': + return true; + case 'chat': + case 'mobile': + case 'teaser': + if($this->isLoggedIn()) { + return true; + } + return false; + case 'logs': + if($this->isLoggedIn() && ($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == CMOD || $this->getUserRole() == AJAX_CHAT_MODERATOR || $this->getUserRole() == PURPLE || $this->getUserRole() == DONATOR || + ($this->getConfig('logsUserAccess') && + ($this->getUserRole() == AJAX_CHAT_USER)) + )) { + return true; + } + return false; + default: + return false; + } + } + + function login() { + // Retrieve valid login user data (from request variables or session data): + $userData = $this->getValidLoginUserData(); + + if(!$userData) { + $this->addInfoMessage('errorInvalidUser'); + return false; + } + + // If the chat is closed, only the admin may login: + if(!$this->isChatOpen() && $userData['userRole'] != AJAX_CHAT_ADMIN) { + $this->addInfoMessage('errorChatClosed'); + return false; + } + + if(!$this->getConfig('allowGuestLogins') && $userData['userRole'] == AJAX_CHAT_GUEST) { + return false; + } + + // Check if userID or userName are already listed online: + if($this->isUserOnline($userData['userID']) || $this->isUserNameInUse($userData['userName'])) { + // Set the registered user inactive and remove the inactive users so the user can be logged in again: + $this->setInactive($userData['userID'], $userData['userName']); + $this->removeInactive(); + } + + // Check if user is banned: + if($userData['userRole'] != AJAX_CHAT_ADMIN && $this->isUserBanned($userData['userName'], $userData['userID'], $_SERVER['REMOTE_ADDR'])) { + $this->addInfoMessage('errorBanned'); + return false; + } + + // Check if the max number of users is logged in (not affecting moderators or admins): + if(!($userData['userRole'] == AJAX_CHAT_MODERATOR || $userData['userRole'] == PURPLE || $userData['userRole'] == AJAX_CHAT_ADMIN) && $this->isMaxUsersLoggedIn()) { + $this->addInfoMessage('errorMaxUsersLoggedIn'); + return false; + } + + // Use a new session id (if session has been started by the chat): + $this->regenerateSessionID(); + + // Log in: + $this->setUserID($userData['userID']); + $this->setUserName($userData['userName']); + $this->setLoginUserName($userData['userName']); + $this->setUserRole($userData['userRole']); + $this->setLoggedIn(true); + $this->setLoginTimeStamp(time()); + + // IP Security check variable: + $this->setSessionIP($_SERVER['REMOTE_ADDR']); + + // The client authenticates to the socket server using a socketRegistrationID: + if($this->getConfig('socketServerEnabled')) { + $this->setSocketRegistrationID( + md5(uniqid(rand(), true)) + ); + } + + // Add userID, userName and userRole to info messages: + $this->addInfoMessage($this->getUserID(), 'userID'); + $this->addInfoMessage($this->getUserName(), 'userName'); + $this->addInfoMessage($this->getUserRole(), 'userRole'); + + // Purge logs: + if($this->getConfig('logsPurgeLogs')) { + $this->purgeLogs(); + } + + // Report login to Satori: + /*$boatcom = @fsockopen('marie.railgun.sh', 9064, $errno, $errstr, 5); + if($boatcom) { + $message = sprintf('{sock}[i][url=https://flashii.net/profile.php?u=%d][b]%s[/b][/url] logged into [url=https://flash.moe/chat/]Flashii Chat Legacy[/url].[/i]', $userData['userID'], $userData['userName']); + $message = chr(0xF) . hash_hmac('sha256', $message, 'lol glad i caught this, that could\'ve been pretty funny if i forgot to remove this') . $message . chr(0xF); + fwrite($boatcom, $message); + fflush($boatcom); + fclose($boatcom); + }*/ + + return true; + } + + function chatViewLogin() { + $this->setChannel($this->getValidRequestChannelID()); + $this->addToOnlineList(); + + // Add channelID and channelName to info messages: + $this->addInfoMessage($this->getChannel(), 'channelID'); + $this->addInfoMessage($this->getChannelName(), 'channelName'); + + // Login message: + $text = '/login '.$this->getUserName(); + $this->insertChatBotMessage( + $this->getChannel(), + $text, + null, + 1 + ); + } + + function getValidRequestChannelID() { + $channelID = $this->getRequestVar('channelID'); + $channelName = $this->getRequestVar('channelName'); + // Check the given channelID, or get channelID from channelName: + if($channelID === null) { + if($channelName !== null) { + $channelID = $this->getChannelIDFromChannelName($channelName); + // channelName might need encoding conversion: + if($channelID === null) { + $channelID = $this->getChannelIDFromChannelName( + $this->trimChannelName($channelName, $this->getConfig('contentEncoding')) + ); + } + } + } + // Validate the resulting channelID: + if(!$this->validateChannel($channelID)) { + if($this->getChannel() !== null) { + return $this->getChannel(); + } + return $this->getConfig('defaultChannelID'); + } + return $channelID; + } + + function initChannel() { + $channelID = $this->getRequestVar('channelID'); + $channelName = $this->getRequestVar('channelName'); + if($channelID !== null) { + $this->switchChannel($this->getChannelNameFromChannelID($channelID)); + } else if($channelName !== null) { + if($this->getChannelIDFromChannelName($channelName) === null) { + // channelName might need encoding conversion: + $channelName = $this->trimChannelName($channelName, $this->getConfig('contentEncoding')); + } + $this->switchChannel($channelName); + } + } + + function logout($type=null) { + // Update the socket server authentication for the user: + if($this->getConfig('socketServerEnabled')) { + $this->updateSocketAuthentication($this->getUserID()); + } + if($this->isUserOnline()) { + $this->chatViewLogout($type); + } + $this->setLoggedIn(false); + $this->destroySession(); + + // Re-initialize the view: + $this->initView(); + } + + function chatViewLogout($type) { + $this->removeFromOnlineList(); + if($type !== null) { + $type = ' '.$type; + } + // Logout message + $text = '/logout '.$this->getUserName().$type; + $this->insertChatBotMessage( + $this->getChannel(), + $text, + null, + 1 + ); + } + + function switchChannel($channelName) { + $channelID = $this->getChannelIDFromChannelName($channelName); + + if($channelID !== null && $this->getChannel() == $channelID) { + // User is already in the given channel, return: + return; + } + + // Check if we have a valid channel: + if(!$this->validateChannel($channelID)) { + // Invalid channel: + $text = '/error InvalidChannelName '.$channelName; + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + $text + ); + return; + } + + $oldChannel = $this->getChannel(); + + $this->setChannel($channelID); + $this->updateOnlineList(); + + // Channel leave message + $text = '/channelLeave '.$this->getUserName(); + $this->insertChatBotMessage( + $oldChannel, + $text, + null, + 1 + ); + + // Channel enter message + $text = '/channelEnter '.$this->getUserName(); + $this->insertChatBotMessage( + $this->getChannel(), + $text, + null, + 1 + ); + + $this->addInfoMessage($channelName, 'channelSwitch'); + $this->addInfoMessage($channelID, 'channelID'); + $this->_requestVars['lastID'] = 0; + } + + function addToOnlineList() { + $sql = 'INSERT INTO '.$this->getDataBaseTable('online').'( + userID, + userName, + userRole, + channel, + dateTime, + ip + ) + VALUES ( + '.$this->db->makeSafe($this->getUserID()).', + '.$this->db->makeSafe($this->getUserName()).', + '.$this->db->makeSafe($this->getUserRole()).', + '.$this->db->makeSafe($this->getChannel()).', + NOW(), + '.$this->db->makeSafe($this->ipToStorageFormat($_SERVER['REMOTE_ADDR'])).' + );'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + $this->resetOnlineUsersData(); + } + + function removeFromOnlineList() { + $sql = 'DELETE FROM + '.$this->getDataBaseTable('online').' + WHERE + userID = '.$this->db->makeSafe($this->getUserID()).';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + $this->removeUserFromOnlineUsersData(); + } + + function updateOnlineList() { + $sql = 'UPDATE + '.$this->getDataBaseTable('online').' + SET + userName = '.$this->db->makeSafe($this->getUserName()).', + channel = '.$this->db->makeSafe($this->getChannel()).', + dateTime = NOW(), + ip = '.$this->db->makeSafe($this->ipToStorageFormat($_SERVER['REMOTE_ADDR'])).' + WHERE + userID = '.$this->db->makeSafe($this->getUserID()).';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + $this->resetOnlineUsersData(); + } + + function initMessageHandling() { + // Don't handle messages if we are not in chat view: + if($this->getView() != 'chat') { + return; + } + + // Check if we have been uninvited from a private or restricted channel: + if(!$this->validateChannel($this->getChannel())) { + // Switch to the default channel: + $this->switchChannel($this->getChannelNameFromChannelID($this->getConfig('defaultChannelID'))); + return; + } + + if($this->getRequestVar('text') !== null) { + $this->insertMessage($this->getRequestVar('text')); + } + } + + function insertParsedMessage($text) { + // Replace Unicode character + $text = preg_replace("/\xEF\xBF\xBF/im", " ", $text); + + $gtParse = preg_replace('/\\[(?:\\/)?(\\w+)(?:=([^<>]*?))?\\]/ms', '', $text); + + // Auto greentext + if(preg_match("/>(.*?)$/im", $gtParse)) { + $text = preg_replace("/>(.*?)$/im", "[color=Green]>$1[/color]", $gtParse); + } + if(preg_match("/(.*?)<$/im", $gtParse)) { + $text = preg_replace("/(.*?)<$/im", "[color=Red]$1<[/color]", $gtParse); + } + + // Emoticon Limiting + $emoticons = array(':happy:', ':lmao:', ':angry:', ':angrier:', ':evil:', ':glare:', ':eat:', ':lol:', ':dizzy:', ':yay:', ':wtf:', ':sigh:', ':omg:', ':ouch:', ':tired:', ':kiss:', ':love:', ':sweat:', ':suspicious:', ':crying:', ':blank:', ':puke:', ':ruse:', ':meow:'); + $emoticonCount = 0; + + foreach($emoticons as $emoticon) { + // Increase Emoticon count + $emoticonCount += substr_count($text, $emoticon); + + // If higher than 10 replace then + if($emoticonCount > 10) + $text = str_replace($emoticon, '', $text); + } + + if($this->getQueryUserName() !== null && strpos($text, '/') !== 0) { + // If a queryUserName is set, sent all messages as private messages to this userName: + $text = '/msg '.$this->getQueryUserName().' '.$text; + } + + if(strpos($text, '/') === 0) { + // Parse IRC-style commands: + $textParts = explode(' ', $text); + + switch($textParts[0]) { + // Channel switch: + case '/join': + $this->insertParsedMessageJoin($textParts); + break; + + // Logout: + case '/quit': + case '/suicide': + $this->logout(); + break; + + // Private message: + case '/msg': + case '/describe': + $this->insertParsedMessagePrivMsg($textParts); + break; + + // Invitation: + case '/invite': + $this->insertParsedMessageInvite($textParts); + break; + + // Uninvitation: + case '/uninvite': + $this->insertParsedMessageUninvite($textParts); + break; + + // Private messaging: + case '/query': + $this->insertParsedMessageQuery($textParts); + break; + + // Kicking offending users from the chat: + case '/kick': + $this->insertParsedMessageKick($textParts); + break; + + // Listing banned users: + case '/bans': + $this->insertParsedMessageBans($textParts); + break; + + // Unban user (remove from ban list): + case '/unban': + $this->insertParsedMessageUnban($textParts); + break; + + // Describing actions: + case '/me': + case '/action': + $this->insertParsedMessageAction($textParts); + break; + + // Listing online Users: + case '/who': + $this->insertParsedMessageWho($textParts); + break; + + // Listing available channels: + case '/list': + $this->insertParsedMessageList($textParts); + break; + + // Retrieving the channel of a User: + case '/whereis': + $this->insertParsedMessageWhereis($textParts); + break; + + // Listing information about a User: + case '/whois': + $this->insertParsedMessageWhois($textParts); + break; + + // Rolling dice: + case '/roll': + $this->insertParsedMessageRoll($textParts); + break; + + // Switching userName: + case '/nick': + $this->insertParsedMessageNick($textParts); + break; + + // Switching userName: + case '/saibatekuisagoodsite': + $this->insertParsedMessageChangeNick($textParts); + break; + + // Custom or unknown command: + default: + if(!$this->parseCustomCommands($text, $textParts)) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UnknownCommand '.$textParts[0] + ); + } + } + + } else { + // No command found, just insert the plain message: + $this->insertCustomMessage( + $this->getUserID(), + $this->getUserName(), + $this->getUserRole(), + $this->getChannel(), + $text + ); + } + include_once 'satori.php'; + } + + function insertParsedMessageJoin($textParts) { + if(count($textParts) == 1) { + // join with no arguments is the own private channel, if allowed: + if($this->isAllowedToCreatePrivateChannel()) { + // Private channels are identified by square brackets: + $this->switchChannel($this->getChannelNameFromChannelID($this->getPrivateChannelID())); + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingChannelName' + ); + } + } else { + $this->switchChannel($textParts[1]); + } + } + + function insertParsedMessagePrivMsg($textParts) { + if($this->isAllowedToSendPrivateMessage()) { + if(count($textParts) < 3) { + if(count($textParts) == 2) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingText' + ); + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingUserName' + ); + } + } else { + // Get UserID from UserName: + $toUserID = $this->getIDFromName($textParts[1]); + if($toUserID === null) { + if($this->getQueryUserName() !== null) { + // Close the current query: + $this->insertMessage('/query'); + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameNotFound '.$textParts[1] + ); + } + } else { + // Insert /privaction command if /describe is used: + $command = ($textParts[0] == '/describe') ? '/privaction' : '/privmsg'; + // Copy of private message to current User: + $this->insertCustomMessage( + $this->getUserID(), + $this->getUserName(), + $this->getUserRole(), + $this->getPrivateMessageID(), + $command.'to '.$textParts[1].' '.implode(' ', array_slice($textParts, 2)) + ); + // Private message to requested User: + $this->insertCustomMessage( + $this->getUserID(), + $this->getUserName(), + $this->getUserRole(), + $this->getPrivateMessageID($toUserID), + $command.' '.implode(' ', array_slice($textParts, 2)) + ); + } + } + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error PrivateMessageNotAllowed' + ); + } + } + + function insertParsedMessageInvite($textParts) { + if($this->getChannel() == $this->getPrivateChannelID() || in_array($this->getChannel(), $this->getChannels())) { + if(count($textParts) == 1) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingUserName' + ); + } else { + $toUserID = $this->getIDFromName($textParts[1]); + if($toUserID === null) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameNotFound '.$textParts[1] + ); + } else { + // Add the invitation to the database: + $this->addInvitation($toUserID); + $invitationChannelName = $this->getChannelNameFromChannelID($this->getChannel()); + // Copy of invitation to current User: + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/inviteto '.$textParts[1].' '.$invitationChannelName + ); + // Invitation to requested User: + $this->insertChatBotMessage( + $this->getPrivateMessageID($toUserID), + '/invite '.$this->getUserName().' '.$invitationChannelName + ); + } + } + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error InviteNotAllowed' + ); + } + } + + function insertParsedMessageUninvite($textParts) { + if($this->getChannel() == $this->getPrivateChannelID() || in_array($this->getChannel(), $this->getChannels())) { + if(count($textParts) == 1) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingUserName' + ); + } else { + $toUserID = $this->getIDFromName($textParts[1]); + if($toUserID === null) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameNotFound '.$textParts[1] + ); + } else { + // Remove the invitation from the database: + $this->removeInvitation($toUserID); + $invitationChannelName = $this->getChannelNameFromChannelID($this->getChannel()); + // Copy of uninvitation to current User: + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/uninviteto '.$textParts[1].' '.$invitationChannelName + ); + // Uninvitation to requested User: + $this->insertChatBotMessage( + $this->getPrivateMessageID($toUserID), + '/uninvite '.$this->getUserName().' '.$invitationChannelName + ); + } + } + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UninviteNotAllowed' + ); + } + } + + function insertParsedMessageQuery($textParts) { + if($this->isAllowedToSendPrivateMessage()) { + if(count($textParts) == 1) { + if($this->getQueryUserName() !== null) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/queryClose '.$this->getQueryUserName() + ); + // Close the current query: + $this->setQueryUserName(null); + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error NoOpenQuery' + ); + } + } else { + if($this->getIDFromName($textParts[1]) === null) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameNotFound '.$textParts[1] + ); + } else { + if($this->getQueryUserName() !== null) { + // Close the current query: + $this->insertMessage('/query'); + } + // Open a query to the requested user: + $this->setQueryUserName($textParts[1]); + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/queryOpen '.$textParts[1] + ); + } + } + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error PrivateMessageNotAllowed' + ); + } + } + + function insertParsedMessageKick($textParts) { + // Only moderators/admins may kick users: + if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR || $this->getUserRole() == CMOD || $this->getUserID() == 11) { + if(count($textParts) == 1) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingUserName' + ); + } else { + // Get UserID from UserName: + $kickUserID = $this->getIDFromName($textParts[1]); + if($kickUserID === null) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameNotFound '.$textParts[1] + ); + } else { + // Check the role of the user to kick: + $kickUserRole = $this->getRoleFromID($kickUserID); + if( + $kickUserRole == AJAX_CHAT_ADMIN || + ( + ( + $kickUserID == 11 + && + $this->getUserRole() != AJAX_CHAT_ADMIN + && + $this->getUserID() != 11 + ) + || + ( + $kickUserRole == CMOD + && + $this->getUserRole() != AJAX_CHAT_MODERATOR + && + $this->getUserRole() != PURPLE + && + $this->getUserRole() != AJAX_CHAT_ADMIN + && + $this->getUserID() != 11 + ) + || + ( + $kickUserRole == AJAX_CHAT_MODERATOR + && + $this->getUserRole() != PURPLE + && + $this->getUserRole() != AJAX_CHAT_ADMIN + && + $this->getUserID() != 11 + ) + ) + ) { + // Admins and moderators may not be kicked: + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error KickNotAllowed '.$textParts[1] + ); + } else { + // Kick user and insert message: + $channel = $this->getChannelFromID($kickUserID); + $banMinutes = (count($textParts) > 2) ? $textParts[2] : null; + $this->kickUser($textParts[1], $banMinutes, $kickUserID); + // If no channel found, user logged out before he could be kicked + if($channel !== null) { + $this->insertChatBotMessage( + $channel, + '/kick '.$textParts[1], + null, + 1 + ); + // Send a copy of the message to the current user, if not in the channel: + if($channel != $this->getChannel()) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/kick '.$textParts[1], + null, + 1 + ); + } + } + } + } + } + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error CommandNotAllowed '.$textParts[0] + ); + } + } + + function insertParsedMessageBans($textParts) { + // Only moderators/admins may see the list of banned users: + if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR || $this->getUserRole() == CMOD) { + $this->removeExpiredBans(); + $bannedUsers = $this->getBannedUsers(); + if(count($bannedUsers) > 0) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/bans '.implode(' ', $bannedUsers) + ); + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/bansEmpty -' + ); + } + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error CommandNotAllowed '.$textParts[0] + ); + } + } + + function insertParsedMessageUnban($textParts) { + // Only moderators/admins may unban users: + if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR || $this->getUserRole() == CMOD) { + $this->removeExpiredBans(); + if(count($textParts) == 1) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingUserName' + ); + } else { + if(!in_array($textParts[1], $this->getBannedUsers())) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameNotFound '.$textParts[1] + ); + } else { + // Unban user and insert message: + $this->unbanUser($textParts[1]); + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/unban '.$textParts[1] + ); + } + } + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error CommandNotAllowed '.$textParts[0] + ); + } + } + + function insertParsedMessageAction($textParts) { + if(count($textParts) == 1) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingText' + ); + } else { + if($this->getQueryUserName() !== null) { + // If we are in query mode, sent the action to the query user: + $this->insertMessage('/describe '.$this->getQueryUserName().' '.implode(' ', array_slice($textParts, 1))); + } else { + $this->insertCustomMessage( + $this->getUserID(), + $this->getUserName(), + $this->getUserRole(), + $this->getChannel(), + implode(' ', $textParts) + ); + } + } + } + + function insertParsedMessageWho($textParts) { + if(count($textParts) == 1) { + if($this->isAllowedToListHiddenUsers()) { + // List online users from any channel: + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/who '.implode(' ', $this->getOnlineUsers()) + ); + } else { + // Get online users for all accessible channels: + $channels = $this->getChannels(); + // Add the own private channel if allowed: + if($this->isAllowedToCreatePrivateChannel()) { + array_push($channels, $this->getPrivateChannelID()); + } + // Add the invitation channels: + foreach($this->getInvitations() as $channelID) { + if(!in_array($channelID, $channels)) { + array_push($channels, $channelID); + } + } + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/who '.implode(' ', $this->getOnlineUsers($channels)) + ); + } + } else { + $channelName = $textParts[1]; + $channelID = $this->getChannelIDFromChannelName($channelName); + if(!$this->validateChannel($channelID)) { + // Invalid channel: + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error InvalidChannelName '.$channelName + ); + } else { + // Get online users for the given channel: + $onlineUsers = $this->getOnlineUsers(array($channelID)); + if(count($onlineUsers) > 0) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/whoChannel '.$channelName.' '.implode(' ', $onlineUsers) + ); + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/whoEmpty -' + ); + } + } + } + } + + function insertParsedMessageList($textParts) { + // Get the names of all accessible channels: + $channelNames = $this->getChannelNames(); + // Add the own private channel, if allowed: + if($this->isAllowedToCreatePrivateChannel()) { + array_push($channelNames, $this->getPrivateChannelName()); + } + // Add the invitation channels: + foreach($this->getInvitations() as $channelID) { + $channelName = $this->getChannelNameFromChannelID($channelID); + if($channelName !== null && !in_array($channelName, $channelNames)) { + array_push($channelNames, $channelName); + } + } + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/list '.implode(' ', $channelNames) + ); + } + + function insertParsedMessageWhereis($textParts) { + if(count($textParts) == 1) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingUserName' + ); + } else { + // Get UserID from UserName: + $whereisUserID = $this->getIDFromName($textParts[1]); + if($whereisUserID === null) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameNotFound '.$textParts[1] + ); + } else { + $channelID = $this->getChannelFromID($whereisUserID); + if($this->validateChannel($channelID)) { + $channelName = $this->getChannelNameFromChannelID($channelID); + } else { + $channelName = null; + } + if($channelName === null) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameNotFound '.$textParts[1] + ); + } else { + // List user information: + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/whereis '.$textParts[1].' '.$channelName + ); + } + } + } + } + + function insertParsedMessageWhois($textParts) { + // Only moderators/admins: + if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR || $this->getUserRole() == PURPLE || $this->getUserRole() == CMOD) { +// if($this->getUserRole() == AJAX_CHAT_ADMIN) { + if(count($textParts) == 1) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingUserName' + ); + } else { + // Get UserID from UserName: + $whoisUserID = $this->getIDFromName($textParts[1]); + if($whoisUserID === null) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameNotFound '.$textParts[1] + ); + } else { + // List user information: + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/whois '.$textParts[1].' '.$this->getIPFromID($whoisUserID) + ); + } + } + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error CommandNotAllowed '.$textParts[0] + ); + } + } + + function insertParsedMessageRoll($textParts) { + if(count($textParts) == 1) { + // default is one d6: + $text = '/roll '.$this->getUserName().' 1d6 '.$this->rollDice(6); + } else { + $diceParts = explode('d', $textParts[1]); + if(count($diceParts) == 2) { + $number = (int)$diceParts[0]; + $sides = (int)$diceParts[1]; + + // Dice number must be an integer between 1 and 100, else roll only one: + $number = ($number > -1 && $number < 100) ? $number : 1; + + // Sides must be an integer between 1 and 100, else take 6: + $sides = ($sides > -1 && $sides < 100) ? $sides : 6; + + $text = '/roll '.$this->getUserName().' '.$number.'d'.$sides.' '; + for($i=0; $i<$number; $i++) { + if($i != 0) + $text .= ','; + switch($this->getUserID()) { // snowflake + case 3://303: + $text .= str_shuffle('bird'); + break; + + case 0://230: + $text .= str_shuffle('portugal'); + break; + + case 15://21: + $text .= str_shuffle('divorce'); + break; + + case 2://8: + $text .= str_shuffle('mewow'); + break; + + default: + $text .= $this->rollDice($sides); + } + } + } else { + // if dice syntax is invalid, roll one d6: + $text = '/roll '.$this->getUserName().' 1d6 '.$this->rollDice(6); + } + } + $this->insertChatBotMessage( + $this->getChannel(), + $text + ); + } + + function insertParsedMessageNick($textParts) { + if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR || $this->getUserRole() == PURPLE || $this->getUserRole() == CMOD || $this->getUserRole() == BOTS || $this->getUserRole() == DONATOR) { + if(!$this->getConfig('allowNickChange') || + (!$this->getConfig('allowGuestUserName') && $this->getUserRole() == AJAX_CHAT_GUEST)) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error CommandNotAllowed '.$textParts[0] + ); + } elseif(count($textParts) == 1) { + $oldUserName = $this->getUserName(); + $newUserName = $this->getLoginUserName(); + if($oldUserName != $newUserName) { + $this->setUserName($newUserName); + $this->updateOnlineList(); + // Add info message to update the client-side stored userName: + $this->addInfoMessage($this->getUserName(), 'userName'); + $this->insertChatBotMessage( + $this->getChannel(), + '/nick '.$oldUserName.' '.$newUserName, + null, + 2 + ); + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingUserName' + ); + } + } else { + $newUserName = implode(' ', array_slice($textParts, 1)); + if($newUserName == $this->getLoginUserName()) { + // Allow the user to regain the original login userName: + $prefix = ''; + $suffix = ''; + } else if($this->getUserRole() == AJAX_CHAT_GUEST) { + $prefix = $this->getConfig('guestUserPrefix'); + $suffix = $this->getConfig('guestUserSuffix'); + } else { + $prefix = $this->getConfig('changedNickPrefix'); + $suffix = $this->getConfig('changedNickSuffix'); + } + $maxLength = $this->getConfig('userNameMaxLength') + - $this->stringLength($prefix) + - $this->stringLength($suffix); + $newUserName = $this->trimString($newUserName, 'UTF-8', $maxLength, true); + if(!$newUserName) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error InvalidUserName' + ); + } else { + $newUserName = $prefix.$newUserName.$suffix; + if($this->isUserNameInUse($newUserName)) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error UserNameInUse' + ); + } else { + $oldUserName = $this->getUserName(); + $this->setUserName($newUserName); + $this->updateOnlineList(); + // Add info message to update the client-side stored userName: + $this->addInfoMessage($this->getUserName(), 'userName'); + $this->insertChatBotMessage( + $this->getChannel(), + '/nick '.$oldUserName.' '.$newUserName, + null, + 2 + ); + } + } + } + } else { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error CommandNotAllowed '.$textParts[0] + ); + } + } + + function insertParsedMessageChangeNick($textParts) { + if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR) { + if(count($textParts) == 1) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MissingUserName' + ); + } else { + $newUserName = implode(' ', array_slice($textParts, 1)); + $oldUserName = $this->getUserName(); + $this->setUserName($newUserName); + $this->updateOnlineList(); + $this->addInfoMessage($this->getUserName(), 'userName'); + } + } + } + + function insertMessage($text) { + if(!$this->isAllowedToWriteMessage()) + return; + + if(!$this->floodControl()) + return; + + $text = $this->trimMessageText($text); + if($text == '') + return; + + if(!$this->onNewMessage($text)) + return; + + $text = $this->replaceCustomText($text); + + $this->insertParsedMessage($text); + } + + function deleteMessage($messageID) { + // Retrieve the channel of the given message: + $sql = 'SELECT + channel + FROM + '.$this->getDataBaseTable('messages').' + WHERE + id='.$this->db->makeSafe($messageID).';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + $row = $result->fetch(); + + if($row['channel'] !== null) { + $channel = $row['channel']; + + if($this->getUserRole() == AJAX_CHAT_ADMIN) { + $condition = ''; + } else if($this->getUserRole() == CMOD || $this->getUserRole() == PURPLE) { + $condition = ' AND + NOT (userRole='.$this->db->makeSafe(AJAX_CHAT_MODERATOR).') + AND + NOT (userRole='.$this->db->makeSafe(AJAX_CHAT_ADMIN).') + AND + NOT (userRole='.$this->db->makeSafe(AJAX_CHAT_CHATBOT).')'; + } else if($this->getUserRole() == AJAX_CHAT_MODERATOR) { + $condition = ' AND + NOT (userRole='.$this->db->makeSafe(AJAX_CHAT_ADMIN).') + AND + NOT (userRole='.$this->db->makeSafe(AJAX_CHAT_CHATBOT).')'; + } else if($this->getUserRole() == AJAX_CHAT_USER && $this->getConfig('allowUserMessageDelete')) { + $condition = 'AND + ( + userID='.$this->db->makeSafe($this->getUserID()).' + OR + ( + channel = '.$this->db->makeSafe($this->getPrivateMessageID()).' + OR + channel = '.$this->db->makeSafe($this->getPrivateChannelID()).' + ) + AND + NOT (userRole='.$this->db->makeSafe(AJAX_CHAT_ADMIN).') + AND + NOT (userRole='.$this->db->makeSafe(AJAX_CHAT_CHATBOT).') + )'; + } else { + return false; + } + + // Remove given message from the database: + $sql = 'DELETE FROM + '.$this->getDataBaseTable('messages').' + WHERE + id='.$this->db->makeSafe($messageID).' + '.$condition.';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + if($result->affectedRows() == 1) { + // Insert a deletion command to remove the message from the clients chatlists: + $this->insertChatBotMessage($channel, '/delete '.$messageID); + return true; + } + } + return false; + } + + function floodControl() { + // Admins can do whatever the fuck they want: + if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR || $this->getUserID() == 11) { + return true; + } + $time = time(); + // Check the time of the last inserted message: + if($this->getInsertedMessagesRateTimeStamp()+60 < $time) { + $this->setInsertedMessagesRateTimeStamp($time); + $this->setInsertedMessagesRate(1); + } else { + // Increase the inserted messages rate: + $rate = $this->getInsertedMessagesRate()+1; + $this->setInsertedMessagesRate($rate); + // Check if message rate is too high: + if($rate > $this->getConfig('maxMessageRate')) { + $this->insertChatBotMessage( + $this->getPrivateMessageID(), + '/error MaxMessageRate' + ); + $this->kickUser($this->getUserName(), 10, $this->getUserID()); + $this->insertChatBotMessage($this->getChannel(), "[i][b]".$this->getUsername()."[/b] exceeded the message limit and will now be kicked for 10 minutes.[/i]"); + $this->insertChatBotMessage($this->getChannel(), "/kick ". $this->getUsername()); + // Return false so the message is not inserted: + return false; + } + } + return true; + } + + function isAllowedToWriteMessage() { + if($this->getUserRole() != AJAX_CHAT_GUEST) + return true; + if($this->getConfig('allowGuestWrite')) + return true; + return false; + } + + function insertChatBotMessage($channelID, $messageText, $ip=null, $mode=0) { + $this->insertCustomMessage( + $this->getConfig('chatBotID'), + $this->getConfig('chatBotName'), + AJAX_CHAT_CHATBOT, + $channelID, + $messageText, + $ip, + $mode + ); + } + + function insertCustomMessage($userID, $userName, $userRole, $channelID, $text, $ip=null, $mode=0) { + // The $mode parameter is used for socket updates: + // 0 = normal messages + // 1 = channel messages (e.g. login/logout, channel enter/leave, kick) + // 2 = messages with online user updates (nick) + + $ip = $ip ? $ip : $_SERVER['REMOTE_ADDR']; + + $sql = 'INSERT INTO '.$this->getDataBaseTable('messages').'( + userID, + userName, + userRole, + channel, + dateTime, + ip, + text + ) + VALUES ( + '.$this->db->makeSafe($userID).', + '.$this->db->makeSafe($userName).', + '.$this->db->makeSafe($userRole).', + '.$this->db->makeSafe($channelID).', + NOW(), + '.$this->db->makeSafe($this->ipToStorageFormat($ip)).', + '.$this->db->makeSafe($text).' + );'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + if($this->getConfig('socketServerEnabled')) { + $this->sendSocketMessage( + $this->getSocketBroadcastMessage( + $this->db->getLastInsertedID(), + time(), + $userID, + $userName, + $userRole, + $channelID, + $text, + $mode + ) + ); + } + } + + function getSocketBroadcastMessage( + $messageID, + $timeStamp, + $userID, + $userName, + $userRole, + $channelID, + $text, + $mode + ) { + // The $mode parameter: + // 0 = normal messages + // 1 = channel messages (e.g. login/logout, channel enter/leave, kick) + // 2 = messages with online user updates (nick) + + // Get the message XML content: + $xml = ''; + if($mode) { + // Add the list of online users if the user list has been updated ($mode > 0): + $xml .= $this->getChatViewOnlineUsersXML(array($channelID)); + } + if($mode != 1 || $this->getConfig('showChannelMessages')) { + $xml .= ''; + $xml .= $this->getChatViewMessageXML( + $messageID, + $timeStamp, + $userID, + $userName, + $userRole, + $channelID, + $text + ); + $xml .= ''; + } + $xml .= ''; + return $xml; + } + + function sendSocketMessage($message) { + // Open a TCP socket connection to the socket server: + if($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) { + if(@socket_connect($socket, $this->getConfig('socketServerIP'), $this->getConfig('socketServerPort'))) { + // Append a null-byte to the string as EOL (End Of Line) character + // which is required by Flash XML socket communication: + $message .= "\0"; + @socket_write( + $socket, + $message, + strlen($message) // Using strlen to count the bytes instead of the number of UTF-8 characters + ); + } + @socket_close($socket); + } + } + + function updateSocketAuthentication($userID, $socketRegistrationID=null, $channels=null) { + // If no $socketRegistrationID or no $channels are given the authentication is removed for the given user: + $authentication = ''; + if($channels) { + foreach($channels as $channelID) { + $authentication .= ''; + } + } + $authentication .= ''; + $this->sendSocketMessage($authentication); + } + + function setSocketRegistrationID($value) { + $this->setSessionVar('SocketRegistrationID', $value); + } + + function getSocketRegistrationID() { + return $this->getSessionVar('SocketRegistrationID'); + } + + function rollDice($sides) { + // seed with microseconds since last "whole" second: + //mt_srand((double)microtime()*1000000); + + return mt_rand(1, $sides); + } + + function kickUser($userName, $banMinutes=null, $userID=null) { + if($userID === null) { + $userID = $this->getIDFromName($userName); + } + if($userID === null) { + return; + } + + $banMinutes = ($banMinutes !== null) ? $banMinutes : $this->getConfig('defaultBanTime'); + + if($banMinutes) { + // Ban User for the given time in minutes: + $this->banUser($userName, $banMinutes, $userID); + } + + // Remove given User from online list: + $sql = 'DELETE FROM + '.$this->getDataBaseTable('online').' + WHERE + userID = '.$this->db->makeSafe($userID).';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + // Update the socket server authentication for the kicked user: + if($this->getConfig('socketServerEnabled')) { + $this->updateSocketAuthentication($userID); + } + + $this->removeUserFromOnlineUsersData($userID); + } + + function getBannedUsersData($key=null, $value=null) { + if($this->_bannedUsersData === null) { + $this->_bannedUsersData = array(); + + $sql = 'SELECT + userID, + userName, + ip + FROM + '.$this->getDataBaseTable('bans').' + WHERE + NOW() < dateTime;'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + while($row = $result->fetch()) { + $row['ip'] = $this->ipFromStorageFormat($row['ip']); + array_push($this->_bannedUsersData, $row); + } + + $result->free(); + } + + if($key) { + $bannedUsersData = array(); + foreach($this->_bannedUsersData as $bannedUserData) { + if(!isset($bannedUserData[$key])) { + return $bannedUsersData; + } + if($value) { + if($bannedUserData[$key] == $value) { + array_push($bannedUsersData, $bannedUserData); + } else { + continue; + } + } else { + array_push($bannedUsersData, $bannedUserData[$key]); + } + } + return $bannedUsersData; + } + + return $this->_bannedUsersData; + } + + function getBannedUsers() { + return $this->getBannedUsersData('userName'); + } + + function banUser($userName, $banMinutes=null, $userID=null) { + if($userID === null) { + $userID = $this->getIDFromName($userName); + } + $ip = $this->getIPFromID($userID); + if(!$ip || $userID === null) { + return; + } + + // Remove expired bans: + $this->removeExpiredBans(); + + $banMinutes = (int)$banMinutes; + if(!$banMinutes) { + // If banMinutes is not a valid integer, use the defaultBanTime: + $banMinutes = $this->getConfig('defaultBanTime'); + } + + $sql = 'INSERT INTO '.$this->getDataBaseTable('bans').'( + userID, + userName, + dateTime, + ip + ) + VALUES ( + '.$this->db->makeSafe($userID).', + '.$this->db->makeSafe($userName).', + DATE_ADD(NOW(), interval '.$this->db->makeSafe($banMinutes).' MINUTE), + '.$this->db->makeSafe($this->ipToStorageFormat($ip)).' + );'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + } + + function unbanUser($userName) { + $sql = 'DELETE FROM + '.$this->getDataBaseTable('bans').' + WHERE + userName = '.$this->db->makeSafe($userName).';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + } + + function removeExpiredBans() { + $sql = 'DELETE FROM + '.$this->getDataBaseTable('bans').' + WHERE + dateTime < NOW();'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + } + + function setInactive($userID, $userName=null) { + $condition = 'userID='.$this->db->makeSafe($userID); + if($userName !== null) { + $condition .= ' OR userName='.$this->db->makeSafe($userName); + } + $sql = 'UPDATE + '.$this->getDataBaseTable('online').' + SET + dateTime = DATE_SUB(NOW(), interval '.(intval($this->getConfig('inactiveTimeout'))+1).' MINUTE) + WHERE + '.$condition.';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + $this->resetOnlineUsersData(); + } + + function removeInactive() { + $sql = 'SELECT + userID, + userName, + channel + FROM + '.$this->getDataBaseTable('online').' + WHERE + NOW() > DATE_ADD(dateTime, interval '.$this->getConfig('inactiveTimeout').' MINUTE);'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + if($result->numRows() > 0) { + $condition = ''; + while($row = $result->fetch()) { + if(!empty($condition)) + $condition .= ' OR '; + // Add userID to condition for removal: + $condition .= 'userID='.$this->db->makeSafe($row['userID']); + + // Update the socket server authentication for the kicked user: + if($this->getConfig('socketServerEnabled')) { + $this->updateSocketAuthentication($row['userID']); + } + + $this->removeUserFromOnlineUsersData($row['userID']); + + // Insert logout timeout message: + $text = '/logout '.$row['userName'].' Timeout'; + $this->insertChatBotMessage( + $row['channel'], + $text, + null, + 1 + ); + } + + $result->free(); + + $sql = 'DELETE FROM + '.$this->getDataBaseTable('online').' + WHERE + '.$condition.';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + } + } + + function updateOnlineStatus() { + // Update online status every 50 seconds (this allows update requests to be in time): + if(!$this->getStatusUpdateTimeStamp() || ((time() - $this->getStatusUpdateTimeStamp()) > 50)) { + $this->updateOnlineList(); + $this->setStatusUpdateTimeStamp(time()); + } + } + + function checkAndRemoveInactive() { + // Remove inactive users every inactiveCheckInterval: + if(!$this->getInactiveCheckTimeStamp() || ((time() - $this->getInactiveCheckTimeStamp()) > $this->getConfig('inactiveCheckInterval')*60)) { + $this->removeInactive(); + $this->setInactiveCheckTimeStamp(time()); + } + } + + function sendXMLMessages() { + $httpHeader = new AJAXChatHTTPHeader('UTF-8', 'text/xml'); + + // Send HTTP header: + $httpHeader->send(); + + // Output XML messages: + echo $this->getXMLMessages(); + } + + function getXMLMessages() { + switch($this->getView()) { + case 'chat': + return $this->getChatViewXMLMessages(); + case 'teaser': + return $this->getTeaserViewXMLMessages(); + case 'logs': + return $this->getLogsViewXMLMessages(); + default: + return $this->getLogoutXMLMessage(); + } + } + + function getMessageCondition() { + $condition = 'id > '.$this->db->makeSafe($this->getRequestVar('lastID')).' + AND ( + channel = '.$this->db->makeSafe($this->getChannel()).' + OR + channel = '.$this->db->makeSafe($this->getPrivateMessageID()).' + ) + AND + '; + if($this->getConfig('requestMessagesPriorChannelEnter') || + ($this->getConfig('requestMessagesPriorChannelEnterList') && in_array($this->getChannel(), $this->getConfig('requestMessagesPriorChannelEnterList')))) { + $condition .= 'NOW() < DATE_ADD(dateTime, interval '.$this->getConfig('requestMessagesTimeDiff').' HOUR)'; + } else { + $condition .= 'dateTime >= \''.date('Y-m-d H:i:s', $this->getChannelEnterTimeStamp()).'\''; + } + return $condition; + } + + function getMessageFilter() { + $filterChannelMessages = ''; + if(!$this->getConfig('showChannelMessages') || $this->getRequestVar('shoutbox')) { + $filterChannelMessages = ' AND NOT ( + text LIKE (\'/login%\') + OR + text LIKE (\'/logout%\') + OR + text LIKE (\'/channelEnter%\') + OR + text LIKE (\'/channelLeave%\') + OR + text LIKE (\'/kick%\') + )'; + } + return $filterChannelMessages; + } + + function getInfoMessagesXML() { + $xml = ''; + // Go through the info messages: + foreach($this->getInfoMessages() as $type=>$infoArray) { + foreach($infoArray as $info) { + $xml .= ''; + $xml .= 'encodeSpecialChars($info).']]>'; + $xml .= ''; + } + } + $xml .= ''; + return $xml; + } + + function getChatViewOnlineUsersXML($channelIDs) { + // Get the online users for the given channels: + $onlineUsersData = $this->getOnlineUsersData($channelIDs); + $xml = ''; + foreach($onlineUsersData as $onlineUserData) { + $xml .= 'encodeSpecialChars($onlineUserData['userName']).']]>'; + $xml .= ''; + } + $xml .= ''; + return $xml; + } + + function getLogoutXMLMessage() { + $xml = ''; + $xml .= ''; + $xml .= ''; + $xml .= ''; + $xml .= 'encodeSpecialChars($this->getConfig('logoutData')).']]>'; + $xml .= ''; + $xml .= ''; + $xml .= ''; + return $xml; + } + + function getChatViewMessageXML( + $messageID, + $timeStamp, + $userID, + $userName, + $userRole, + $channelID, + $text + ) { + $message = 'encodeSpecialChars($userName).']]>'; + $message .= 'encodeSpecialChars($text).']]>'; + $message .= ''; + return $message; + } + + function getChatViewMessagesXML() { + // Get the last messages in descending order (this optimises the LIMIT usage): + $sql = 'SELECT + id, + userID, + userName, + userRole, + channel AS channelID, + UNIX_TIMESTAMP(dateTime) AS timeStamp, + text + FROM + '.$this->getDataBaseTable('messages').' + WHERE + '.$this->getMessageCondition().' + '.$this->getMessageFilter().' + ORDER BY + id + DESC + LIMIT '.$this->getConfig('requestMessagesLimit').';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + $messages = ''; + + // Add the messages in reverse order so it is ascending again: + while($row = $result->fetch()) { + $message = $this->getChatViewMessageXML( + $row['id'], + $row['timeStamp'], + $row['userID'], + $row['userName'], + $row['userRole'], + $row['channelID'], + $row['text'] + ); + $messages = $message.$messages; + } + $result->free(); + + $messages = ''.$messages.''; + return $messages; + } + + function getChatViewXMLMessages() { + $xml = ''; + $xml .= ''; + $xml .= $this->getInfoMessagesXML(); + $xml .= $this->getChatViewOnlineUsersXML(array($this->getChannel())); + $xml .= $this->getChatViewMessagesXML(); + $xml .= ''; + return $xml; + } + + function getTeaserMessageCondition() { + $channelID = $this->getValidRequestChannelID(); + $condition = 'channel = '.$this->db->makeSafe($channelID).' + AND + '; + if($this->getConfig('requestMessagesPriorChannelEnter') || + ($this->getConfig('requestMessagesPriorChannelEnterList') && in_array($channelID, $this->getConfig('requestMessagesPriorChannelEnterList')))) { + $condition .= 'NOW() < DATE_ADD(dateTime, interval '.$this->getConfig('requestMessagesTimeDiff').' HOUR)'; + } else { + // Teaser content may not be shown for this channel: + $condition .= '0 = 1'; + } + return $condition; + } + + function getTeaserViewMessagesXML() { + // Get the last messages in descending order (this optimises the LIMIT usage): + $sql = 'SELECT + id, + userID, + userName, + userRole, + channel AS channelID, + UNIX_TIMESTAMP(dateTime) AS timeStamp, + text + FROM + '.$this->getDataBaseTable('messages').' + WHERE + '.$this->getTeaserMessageCondition().' + '.$this->getMessageFilter().' + ORDER BY + id + DESC + LIMIT '.$this->getConfig('requestMessagesLimit').';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + $messages = ''; + + // Add the messages in reverse order so it is ascending again: + while($row = $result->fetch()) { + $message = ''; + $message .= 'encodeSpecialChars($row['userName']).']]>'; + $message .= 'encodeSpecialChars($row['text']).']]>'; + $message .= ''; + $messages = $message.$messages; + } + $result->free(); + + $messages = ''.$messages.''; + return $messages; + } + + function getTeaserViewXMLMessages() { + $xml = ''; + $xml .= ''; + $xml .= $this->getInfoMessagesXML(); + $xml .= $this->getTeaserViewMessagesXML(); + $xml .= ''; + return $xml; + } + + function getLogsViewCondition() { + $condition = 'id > '.$this->db->makeSafe($this->getRequestVar('lastID')); + + // Check the channel condition: + switch($this->getRequestVar('channelID')) { + case '-3': + // Just display messages from all accessible channels + if($this->getUserRole() != AJAX_CHAT_ADMIN) { + $condition .= ' AND (channel = '.$this->db->makeSafe($this->getPrivateMessageID()); + $condition .= ' OR channel = '.$this->db->makeSafe($this->getPrivateChannelID()); + foreach($this->getChannels() as $channel) { + if($this->getConfig('logsUserAccessChannelList') && !in_array($channel, $this->getConfig('logsUserAccessChannelList'))) { + continue; + } + $condition .= ' OR channel = '.$this->db->makeSafe($channel); + } + $condition .= ')'; + } + break; + case '-2': + if($this->getUserRole() != AJAX_CHAT_ADMIN) { + $condition .= ' AND channel = '.($this->getPrivateMessageID()); + } else { + $condition .= ' AND channel > '.($this->getConfig('privateMessageDiff')-1); + } + break; + case '-1': + if($this->getUserRole() != AJAX_CHAT_ADMIN) { + $condition .= ' AND channel = '.($this->getPrivateChannelID()); + } else { + $condition .= ' AND (channel > '.($this->getConfig('privateChannelDiff')-1).' AND channel < '.($this->getConfig('privateMessageDiff')).')'; + } + break; + default: + if(($this->getUserRole() == AJAX_CHAT_ADMIN || !$this->getConfig('logsUserAccessChannelList') || in_array($this->getRequestVar('channelID'), $this->getConfig('logsUserAccessChannelList'))) + && $this->validateChannel($this->getRequestVar('channelID'))) { + $condition .= ' AND channel = '.$this->db->makeSafe($this->getRequestVar('channelID')); + } else { + // No valid channel: + $condition .= ' AND 0 = 1'; + } + } + + // Check the period condition: + $hour = ($this->getRequestVar('hour') === null || $this->getRequestVar('hour') > 23 || $this->getRequestVar('hour') < 0) ? null : $this->getRequestVar('hour'); + $day = ($this->getRequestVar('day') === null || $this->getRequestVar('day') > 31 || $this->getRequestVar('day') < 1) ? null : $this->getRequestVar('day'); + $month = ($this->getRequestVar('month') === null || $this->getRequestVar('month') > 12 || $this->getRequestVar('month') < 1) ? null : $this->getRequestVar('month'); + $year = ($this->getRequestVar('year') === null || $this->getRequestVar('year') > date('Y') || $this->getRequestVar('year') < $this->getConfig('logsFirstYear')) ? null : $this->getRequestVar('year'); + + // If a time (hour) is given but no date (year, month, day), use the current date: + if($hour !== null) { + if($day === null) + $day = date('j'); + if($month === null) + $month = date('n'); + if($year === null) + $year = date('Y'); + } + + if($year === null) { + // No year given, so no period condition + } else if($month === null) { + // Define the given year as period: + $periodStart = mktime(0, 0, 0, 1, 1, $year); + // The last day in a month can be expressed by using 0 for the day of the next month: + $periodEnd = mktime(23, 59, 59, 13, 0, $year); + } else if($day === null) { + // Define the given month as period: + $periodStart = mktime(0, 0, 0, $month, 1, $year); + // The last day in a month can be expressed by using 0 for the day of the next month: + $periodEnd = mktime(23, 59, 59, $month+1, 0, $year); + } else if($hour === null){ + // Define the given day as period: + $periodStart = mktime(0, 0, 0, $month, $day, $year); + $periodEnd = mktime(23, 59, 59, $month, $day, $year); + } else { + // Define the given hour as period: + $periodStart = mktime($hour, 0, 0, $month, $day, $year); + $periodEnd = mktime($hour, 59, 59, $month, $day, $year); + } + + if(isset($periodStart)) + $condition .= ' AND dateTime > \''.date('Y-m-d H:i:s', $periodStart).'\' AND dateTime <= \''.date('Y-m-d H:i:s', $periodEnd).'\''; + + // Check the search condition: + if($this->getRequestVar('search')) { + if(($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR || $this->getUserRole() == PURPLE || $this->getUserRole() == CMOD) && strpos($this->getRequestVar('search'), 'ip=') === 0) { + // Search for messages with the given IP: + $ip = substr($this->getRequestVar('search'), 3); + $condition .= ' AND (ip = '.$this->db->makeSafe($this->ipToStorageFormat($ip)).')'; + } else if(strpos($this->getRequestVar('search'), 'userID=') === 0) { + // Search for messages with the given userID: + $userID = substr($this->getRequestVar('search'), 7); + $condition .= ' AND (userID = '.$this->db->makeSafe($userID).')'; + } else { + // Use the search value as regular expression on message text and username: + $condition .= ' AND (userName REGEXP '.$this->db->makeSafe($this->getRequestVar('search')).' OR text REGEXP '.$this->db->makeSafe($this->getRequestVar('search')).')'; + } + } + + // If no period or search condition is given, just monitor the last messages on the given channel: + if(!isset($periodStart) && !$this->getRequestVar('search')) { + $condition .= ' AND NOW() < DATE_ADD(dateTime, interval '.$this->getConfig('logsRequestMessagesTimeDiff').' HOUR)'; + } + + return $condition; + } + + function getLogsViewMessagesXML() { + $sql = 'SELECT + id, + userID, + userName, + userRole, + channel AS channelID, + UNIX_TIMESTAMP(dateTime) AS timeStamp, + ip, + text + FROM + '.$this->getDataBaseTable('messages').' + WHERE + '.$this->getLogsViewCondition().' + ORDER BY + id + LIMIT '.$this->getConfig('logsRequestMessagesLimit').';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + $xml = ''; + while($row = $result->fetch()) { + $xml .= 'getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR || $this->getUserRole() == PURPLE) { + $xml .= ' ip="'.$this->ipFromStorageFormat($row['ip']).'"'; + } + $xml .= '>'; + $xml .= 'encodeSpecialChars($row['userName']).']]>'; + $xml .= 'encodeSpecialChars($row['text']).']]>'; + $xml .= ''; + } + $result->free(); + + $xml .= ''; + + return $xml; + } + + function getLogsViewXMLMessages() { + $xml = ''; + $xml .= ''; + $xml .= $this->getInfoMessagesXML(); + $xml .= $this->getLogsViewMessagesXML(); + $xml .= ''; + return $xml; + } + + function purgeLogs() { + $sql = 'DELETE FROM + '.$this->getDataBaseTable('messages').' + WHERE + dateTime < DATE_SUB(NOW(), interval '.$this->getConfig('logsPurgeTimeDiff').' DAY);'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + } + + function getInfoMessages($type=null) { + if(!isset($this->_infoMessages)) { + $this->_infoMessages = array(); + } + if($type) { + if(!isset($this->_infoMessages[$type])) { + $this->_infoMessages[$type] = array(); + } + return $this->_infoMessages[$type]; + } else { + return $this->_infoMessages; + } + } + + function addInfoMessage($info, $type='error') { + if(!isset($this->_infoMessages)) { + $this->_infoMessages = array(); + } + if(!isset($this->_infoMessages[$type])) { + $this->_infoMessages[$type] = array(); + } + if(!in_array($info, $this->_infoMessages[$type])) { + array_push($this->_infoMessages[$type], $info); + } + } + + function getRequestVars() { + return $this->_requestVars; + } + + function getRequestVar($key) { + if($this->_requestVars && isset($this->_requestVars[$key])) { + return $this->_requestVars[$key]; + } + return null; + } + + function setRequestVar($key, $value) { + if(!$this->_requestVars) { + $this->_requestVars = array(); + } + $this->_requestVars[$key] = $value; + } + + function getOnlineUsersData($channelIDs=null, $key=null, $value=null) { + if($this->_onlineUsersData === null) { + $this->_onlineUsersData = array(); + + $sql = 'SELECT + userID, + userName, + userRole, + channel, + UNIX_TIMESTAMP(dateTime) AS timeStamp, + ip + FROM + '.$this->getDataBaseTable('online').' + ORDER BY + userName;'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + while($row = $result->fetch()) { + $row['ip'] = $this->ipFromStorageFormat($row['ip']); + array_push($this->_onlineUsersData, $row); + } + + $result->free(); + } + + if($channelIDs || $key) { + $onlineUsersData = array(); + foreach($this->_onlineUsersData as $userData) { + if($channelIDs && !in_array($userData['channel'], $channelIDs)) { + continue; + } + if($key) { + if(!isset($userData[$key])) { + return $onlineUsersData; + } + if($value !== null) { + if($userData[$key] == $value) { + array_push($onlineUsersData, $userData); + } else { + continue; + } + } else { + array_push($onlineUsersData, $userData[$key]); + } + } else { + array_push($onlineUsersData, $userData); + } + } + return $onlineUsersData; + } + + return $this->_onlineUsersData; + } + + function removeUserFromOnlineUsersData($userID=null) { + if(!$this->_onlineUsersData) { + return; + } + $userID = ($userID === null) ? $this->getUserID() : $userID; + for($i=0; $i_onlineUsersData); $i++) { + if($this->_onlineUsersData[$i]['userID'] == $userID) { + array_splice($this->_onlineUsersData, $i, 1); + break; + } + } + } + + function resetOnlineUsersData() { + $this->_onlineUsersData = null; + } + + function getOnlineUsers($channelIDs=null) { + return $this->getOnlineUsersData($channelIDs, 'userName'); + } + + function getOnlineUserIDs($channelIDs=null) { + return $this->getOnlineUsersData($channelIDs, 'userID'); + } + + function startSession() { + if(!session_id()) { + // Set the session name: + session_name($this->getConfig('sessionName')); + + // Set session cookie parameters: + session_set_cookie_params( + 0, // The session is destroyed on logout anyway, so no use to set this + $this->getConfig('sessionCookiePath'), + $this->getConfig('sessionCookieDomain'), + $this->getConfig('sessionCookieSecure') + ); + + // Start the session: + session_start(); + + // We started a new session: + $this->_sessionNew = true; + } + } + + function destroySession() { + if($this->_sessionNew) { + // Delete all session variables: + $_SESSION = array(); + + // Delete the session cookie: + if (isset($_COOKIE[session_name()])) { + setcookie( + session_name(), + '', + time()-42000, + $this->getConfig('sessionCookiePath'), + $this->getConfig('sessionCookieDomain'), + $this->getConfig('sessionCookieSecure') + ); + } + + // Destroy the session: + session_destroy(); + } else { + // Unset all session variables starting with the sessionKeyPrefix: + foreach($_SESSION as $key=>$value) { + if(strpos($key, $this->getConfig('sessionKeyPrefix')) === 0) { + unset($_SESSION[$key]); + } + } + } + } + + function regenerateSessionID() { + if($this->_sessionNew) { + // Regenerate session id: + @session_regenerate_id(true); + } + } + + function getSessionVar($key, $prefix=null) { + if($prefix === null) + $prefix = $this->getConfig('sessionKeyPrefix'); + + // Return the session value if existing: + if(isset($_SESSION[$prefix.$key])) + return $_SESSION[$prefix.$key]; + else + return null; + } + + function setSessionVar($key, $value, $prefix=null) { + if($prefix === null) + $prefix = $this->getConfig('sessionKeyPrefix'); + + // Set the session value: + $_SESSION[$prefix.$key] = $value; + } + + function getSessionIP() { + return $this->getSessionVar('IP'); + } + + function setSessionIP($ip) { + $this->setSessionVar('IP', $ip); + } + + function getQueryUserName() { + return $this->getSessionVar('QueryUserName'); + } + + function setQueryUserName($userName) { + $this->setSessionVar('QueryUserName', $userName); + } + + function getInvitations() { + if($this->_invitations === null) { + $this->_invitations = array(); + + $sql = 'SELECT + channel + FROM + '.$this->getDataBaseTable('invitations').' + WHERE + userID='.$this->db->makeSafe($this->getUserID()).' + AND + DATE_SUB(NOW(), interval 1 DAY) < dateTime;'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + + while($row = $result->fetch()) { + array_push($this->_invitations, $row['channel']); + } + + $result->free(); + } + return $this->_invitations; + } + + function removeExpiredInvitations() { + $sql = 'DELETE FROM + '.$this->getDataBaseTable('invitations').' + WHERE + DATE_SUB(NOW(), interval 1 DAY) > dateTime;'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + } + + function addInvitation($userID, $channelID=null) { + $this->removeExpiredInvitations(); + + $channelID = ($channelID === null) ? $this->getChannel() : $channelID; + + $sql = 'INSERT INTO '.$this->getDataBaseTable('invitations').'( + userID, + channel, + dateTime + ) + VALUES ( + '.$this->db->makeSafe($userID).', + '.$this->db->makeSafe($channelID).', + NOW() + );'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + } + + function removeInvitation($userID, $channelID=null) { + $channelID = ($channelID === null) ? $this->getChannel() : $channelID; + + $sql = 'DELETE FROM + '.$this->getDataBaseTable('invitations').' + WHERE + userID='.$this->db->makeSafe($userID).' + AND + channel='.$this->db->makeSafe($channelID).';'; + + // Create a new SQL query: + $result = $this->db->sqlQuery($sql); + + // Stop if an error occurs: + if($result->error()) { + echo $result->getError(); + die(); + } + } + + function getUserID() { + return $this->getSessionVar('UserID'); + } + + function setUserID($id) { + $this->setSessionVar('UserID', $id); + } + + function getUserName() { + return $this->getSessionVar('UserName'); + } + + function setUserName($name) { + $this->setSessionVar('UserName', $name); + } + + function getLoginUserName() { + return $this->getSessionVar('LoginUserName'); + } + + function setLoginUserName($name) { + $this->setSessionVar('LoginUserName', $name); + } + + function getUserRole() { + $userRole = $this->getSessionVar('UserRole'); + if($userRole === null) + return AJAX_CHAT_GUEST; + return $userRole; + } + + function setUserRole($role) { + $this->setSessionVar('UserRole', $role); + } + + function getChannel() { + return $this->getSessionVar('Channel'); + } + + function setChannel($channel) { + $this->setSessionVar('Channel', $channel); + + // Save the channel enter timestamp: + $this->setChannelEnterTimeStamp(time()); + + // Update the channel authentication for the socket server: + if($this->getConfig('socketServerEnabled')) { + $this->updateSocketAuthentication( + $this->getUserID(), + $this->getSocketRegistrationID(), + array($channel,$this->getPrivateMessageID()) + ); + } + + // Reset the logs view socket authentication session var: + if($this->getSessionVar('logsViewSocketAuthenticated')) { + $this->setSessionVar('logsViewSocketAuthenticated', false); + } + } + + function isLoggedIn() { + return (bool)$this->getSessionVar('LoggedIn'); + } + + function setLoggedIn($bool) { + $this->setSessionVar('LoggedIn', $bool); + } + + function getLoginTimeStamp() { + return $this->getSessionVar('LoginTimeStamp'); + } + + function setLoginTimeStamp($time) { + $this->setSessionVar('LoginTimeStamp', $time); + } + + function getChannelEnterTimeStamp() { + return $this->getSessionVar('ChannelEnterTimeStamp'); + } + + function setChannelEnterTimeStamp($time) { + $this->setSessionVar('ChannelEnterTimeStamp', $time); + } + + function getStatusUpdateTimeStamp() { + return $this->getSessionVar('StatusUpdateTimeStamp'); + } + + function setStatusUpdateTimeStamp($time) { + $this->setSessionVar('StatusUpdateTimeStamp', $time); + } + + function getInactiveCheckTimeStamp() { + return $this->getSessionVar('InactiveCheckTimeStamp'); + } + + function setInactiveCheckTimeStamp($time) { + $this->setSessionVar('InactiveCheckTimeStamp', $time); + } + + function getInsertedMessagesRate() { + return $this->getSessionVar('InsertedMessagesRate'); + } + + function setInsertedMessagesRate($rate) { + $this->setSessionVar('InsertedMessagesRate', $rate); + } + + function getInsertedMessagesRateTimeStamp() { + return $this->getSessionVar('InsertedMessagesRateTimeStamp'); + } + + function setInsertedMessagesRateTimeStamp($time) { + $this->setSessionVar('InsertedMessagesRateTimeStamp', $time); + } + + function getLangCode() { + // Get the langCode from request or cookie: + $langCodeCookie = isset($_COOKIE[$this->getConfig('sessionName').'_lang']) ? $_COOKIE[$this->getConfig('sessionName').'_lang'] : null; + $langCode = $this->getRequestVar('lang') ? $this->getRequestVar('lang') : $langCodeCookie; + // Check if the langCode is valid: + if(!in_array($langCode, $this->getConfig('langAvailable'))) { + // Determine the user language: + $language = new AJAXChatLanguage($this->getConfig('langAvailable'), $this->getConfig('langDefault')); + $langCode = $language->getLangCode(); + } + return $langCode; + } + + function setLangCodeCookie() { + setcookie( + $this->getConfig('sessionName').'_lang', + $this->getLangCode(), + time()+60*60*24*$this->getConfig('sessionCookieLifeTime'), + $this->getConfig('sessionCookiePath'), + $this->getConfig('sessionCookieDomain'), + $this->getConfig('sessionCookieSecure') + ); + } + + function removeUnsafeCharacters($str) { + // Remove NO-WS-CTL, non-whitespace control characters (RFC 2822), decimal 1–8, 11–12, 14–31, and 127: + return AJAXChatEncoding::removeUnsafeCharacters($str); + } + + function subString($str, $start=0, $length=null, $encoding='UTF-8') { + return AJAXChatString::subString($str, $start, $length, $encoding); + } + + function stringLength($str, $encoding='UTF-8') { + return AJAXChatString::stringLength($str, $encoding); + } + + function trimMessageText($text) { + return $this->trimString($text, 'UTF-8', $this->getConfig('messageTextMaxLength')); + } + + function trimUserName($userName) { + return $this->trimString($userName, null, $this->getConfig('userNameMaxLength'), true, true); + } + + function trimChannelName($channelName) { + return $this->trimString($channelName, null, null, true, true); + } + + function trimString($str, $sourceEncoding=null, $maxLength=null, $replaceWhitespace=false, $decodeEntities=false, $htmlEntitiesMap=null) { + // Make sure the string contains valid unicode: + $str = $this->convertToUnicode($str, $sourceEncoding); + + // Make sure the string contains no unsafe characters: + $str = $this->removeUnsafeCharacters($str); + + // Strip whitespace from the beginning and end of the string: + $str = trim($str); + + if($replaceWhitespace) { + // Replace any whitespace in the userName with the underscore "_": + $str = preg_replace('/\s/u', '_', $str); + } + + if($decodeEntities) { + // Decode entities: + $str = $this->decodeEntities($str, 'UTF-8', $htmlEntitiesMap); + } + + if($maxLength) { + // Cut the string to the allowed length: + $str = $this->subString($str, 0, $maxLength); + } + + return $str; + } + + function convertToUnicode($str, $sourceEncoding=null) { + if($sourceEncoding === null) { + $sourceEncoding = $this->getConfig('sourceEncoding'); + } + return $this->convertEncoding($str, $sourceEncoding, 'UTF-8'); + } + + function convertFromUnicode($str, $contentEncoding=null) { + if($contentEncoding === null) { + $contentEncoding = $this->getConfig('contentEncoding'); + } + return $this->convertEncoding($str, 'UTF-8', $contentEncoding); + } + + function convertEncoding($str, $charsetFrom, $charsetTo) { + return AJAXChatEncoding::convertEncoding($str, $charsetFrom, $charsetTo); + } + + function encodeEntities($str, $encoding='UTF-8', $convmap=null) { + return AJAXChatEncoding::encodeEntities($str, $encoding, $convmap); + } + + function decodeEntities($str, $encoding='UTF-8', $htmlEntitiesMap=null) { + return AJAXChatEncoding::decodeEntities($str, $encoding, $htmlEntitiesMap); + } + + function htmlEncode($str) { + return AJAXChatEncoding::htmlEncode($str, $this->getConfig('contentEncoding')); + } + + function encodeSpecialChars($str) { + return AJAXChatEncoding::encodeSpecialChars($str); + } + + function decodeSpecialChars($str) { + return AJAXChatEncoding::decodeSpecialChars($str); + } + + function ipToStorageFormat($ip) { + if(function_exists('inet_pton')) { + // ipv4 & ipv6: + return @inet_pton($ip); + } + // Only ipv4: + return @pack('N',@ip2long($ip)); + } + + function ipFromStorageFormat($ip) { + if(function_exists('inet_ntop')) { + // ipv4 & ipv6: + return @inet_ntop($ip); + } + // Only ipv4: + $unpacked = @unpack('Nlong',$ip); + if(isset($unpacked['long'])) { + return @long2ip($unpacked['long']); + } + return null; + } + + function getConfig($key, $subkey=null) { + if($subkey) + return $this->_config[$key][$subkey]; + else + return $this->_config[$key]; + } + + function setConfig($key, $subkey, $value) { + if($subkey) { + if(!isset($this->_config[$key])) { + $this->_config[$key] = array(); + } + $this->_config[$key][$subkey] = $value; + } else { + $this->_config[$key] = $value; + } + } + + function getLang($key=null) { + if(!$this->_lang) { + // Include the language file: + $lang = null; + require(AJAX_CHAT_PATH.'lib/lang/'.$this->getLangCode().'.php'); + $this->_lang = &$lang; + } + if($key === null) + return $this->_lang; + if(isset($this->_lang[$key])) + return $this->_lang[$key]; + return null; + } + + function getChatURL() { + if(defined('AJAX_CHAT_URL')) { + return AJAX_CHAT_URL; + } + + return + (isset($_SERVER['HTTPS']) ? 'https://' : 'http://'). + (isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : ''). + (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME']. + (isset($_SERVER['HTTPS']) && $_SERVER['SERVER_PORT'] == 443 || $_SERVER['SERVER_PORT'] == 80 ? '' : ':'.$_SERVER['SERVER_PORT']))). + substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1); + } + + function getIDFromName($userName) { + $userDataArray = $this->getOnlineUsersData(null,'userName',$userName); + if($userDataArray && isset($userDataArray[0])) { + return $userDataArray[0]['userID']; + } + return null; + } + + function getNameFromID($userID) { + $userDataArray = $this->getOnlineUsersData(null,'userID',$userID); + if($userDataArray && isset($userDataArray[0])) { + return $userDataArray[0]['userName']; + } + return null; + } + + function getChannelFromID($userID) { + $userDataArray = $this->getOnlineUsersData(null,'userID',$userID); + if($userDataArray && isset($userDataArray[0])) { + return $userDataArray[0]['channel']; + } + return null; + } + + function getIPFromID($userID) { + $userDataArray = $this->getOnlineUsersData(null,'userID',$userID); + if($userDataArray && isset($userDataArray[0])) { + return $userDataArray[0]['ip']; + } + return null; + } + + function getRoleFromID($userID) { + $userDataArray = $this->getOnlineUsersData(null,'userID',$userID); + if($userDataArray && isset($userDataArray[0])) { + return $userDataArray[0]['userRole']; + } + return null; + } + + function getChannelNames() { + return array_flip($this->getChannels()); + } + + function getChannelIDFromChannelName($channelName) { + if(!$channelName) + return null; + $channels = $this->getAllChannels(); + if(array_key_exists($channelName,$channels)) { + return $channels[$channelName]; + } + $channelID = null; + // Check if the requested channel is the own private channel: + if($channelName == $this->getPrivateChannelName()) { + return $this->getPrivateChannelID(); + } + // Try to retrieve a private room ID: + $strlenChannelName = $this->stringLength($channelName); + $strlenPrefix = $this->stringLength($this->getConfig('privateChannelPrefix')); + $strlenSuffix = $this->stringLength($this->getConfig('privateChannelSuffix')); + if($this->subString($channelName,0,$strlenPrefix) == $this->getConfig('privateChannelPrefix') + && $this->subString($channelName,$strlenChannelName-$strlenSuffix) == $this->getConfig('privateChannelSuffix')) { + $userName = $this->subString( + $channelName, + $strlenPrefix, + $strlenChannelName-($strlenPrefix+$strlenSuffix) + ); + $userID = $this->getIDFromName($userName); + if($userID !== null) { + $channelID = $this->getPrivateChannelID($userID); + } + } + return $channelID; + } + + function getChannelNameFromChannelID($channelID) { + foreach($this->getAllChannels() as $key=>$value) { + if($value == $channelID) { + return $key; + } + } + // Try to retrieve a private room name: + if($channelID == $this->getPrivateChannelID()) { + return $this->getPrivateChannelName(); + } + $userName = $this->getNameFromID($channelID-$this->getConfig('privateChannelDiff')); + if($userName === null) { + return null; + } + return $this->getPrivateChannelName($userName); + } + + function getChannelName() { + return $this->getChannelNameFromChannelID($this->getChannel()); + } + + function getPrivateChannelName($userName=null) { + if($userName === null) { + $userName = $this->getUserName(); + } + return $this->getConfig('privateChannelPrefix').$userName.$this->getConfig('privateChannelSuffix'); + } + + function getPrivateChannelID($userID=null) { + if($userID === null) { + $userID = $this->getUserID(); + } + return $userID + $this->getConfig('privateChannelDiff'); + } + + function getPrivateMessageID($userID=null) { + if($userID === null) { + $userID = $this->getUserID(); + } + return $userID + $this->getConfig('privateMessageDiff'); + } + + function isAllowedToSendPrivateMessage() { + if($this->getConfig('allowPrivateMessages') || $this->getUserRole() == AJAX_CHAT_ADMIN) { + return true; + } + return false; + } + + function isAllowedToCreatePrivateChannel() { + if($this->getConfig('allowPrivateChannels')) { + switch($this->getUserRole()) { + case DONATOR: + return true; + case BOTS: + return true; + case PURPLE: + return true; + case CMOD: + return true; + case AJAX_CHAT_MODERATOR: + return true; + case AJAX_CHAT_ADMIN: + return true; + default: + return false; + } + } + return false; + } + + function isAllowedToListHiddenUsers() { + // Hidden users are users within private or restricted channels: + switch($this->getUserRole()) { + case CMOD: + return true; + case PURPLE: + return true; + case AJAX_CHAT_MODERATOR: + return true; + case AJAX_CHAT_ADMIN: + return true; + default: + return false; + } + } + + function isUserOnline($userID=null) { + $userID = ($userID === null) ? $this->getUserID() : $userID; + $userDataArray = $this->getOnlineUsersData(null,'userID',$userID); + if($userDataArray && count($userDataArray) > 0) { + return true; + } + return false; + } + + function isUserNameInUse($userName=null) { + $userName = ($userName === null) ? $this->getUserName() : $userName; + $userDataArray = $this->getOnlineUsersData(null,'userName',$userName); + if($userDataArray && count($userDataArray) > 0) { + return true; + } + return false; + } + + function isUserBanned($userName, $userID=null, $ip=null) { + if($userID !== null) { + $bannedUserDataArray = $this->getBannedUsersData('userID',$userID); + if($bannedUserDataArray && isset($bannedUserDataArray[0])) { + return true; + } + } + if($ip !== null) { + $bannedUserDataArray = $this->getBannedUsersData('ip',$ip); + if($bannedUserDataArray && isset($bannedUserDataArray[0])) { + return true; + } + } + $bannedUserDataArray = $this->getBannedUsersData('userName',$userName); + if($bannedUserDataArray && isset($bannedUserDataArray[0])) { + return true; + } + return false; + } + + function isMaxUsersLoggedIn() { + if(count($this->getOnlineUsersData()) >= $this->getConfig('maxUsersLoggedIn')) { + return true; + } + return false; + } + + function validateChannel($channelID) { + if($channelID === null) { + return false; + } + // Return true for normal channels the user has acces to: + if(in_array($channelID, $this->getChannels())) { + return true; + } + // Return true if the user is allowed to join his own private channel: + if($channelID == $this->getPrivateChannelID() && $this->isAllowedToCreatePrivateChannel()) { + return true; + } + // Return true if the user has been invited to a restricted or private channel: + if(in_array($channelID, $this->getInvitations())) { + return true; + } + // No valid channel, return false: + return false; + } + + function createGuestUserName() { + $maxLength = $this->getConfig('userNameMaxLength') + - $this->stringLength($this->getConfig('guestUserPrefix')) + - $this->stringLength($this->getConfig('guestUserSuffix')); + + // seed with microseconds since last "whole" second: + mt_srand((double)microtime()*1000000); + + // Create a random userName using numbers between 100000 and 999999: + $userName = substr(mt_rand(100000, 999999), 0, $maxLength); + + return $this->getConfig('guestUserPrefix').$userName.$this->getConfig('guestUserSuffix'); + } + + // Guest userIDs must not interfere with existing userIDs and must be lower than privateChannelDiff: + function createGuestUserID() { + // seed with microseconds since last "whole" second: + mt_srand((double)microtime()*1000000); + + return mt_rand($this->getConfig('minGuestUserID'), $this->getConfig('privateChannelDiff')-1); + } + + function getGuestUser() { + if(!$this->getConfig('allowGuestLogins')) + return null; + + if($this->getConfig('allowGuestUserName')) { + $maxLength = $this->getConfig('userNameMaxLength') + - $this->stringLength($this->getConfig('guestUserPrefix')) + - $this->stringLength($this->getConfig('guestUserSuffix')); + + // Trim guest userName: + $userName = $this->trimString($this->getRequestVar('userName'), null, $maxLength, true, true); + + // If given userName is invalid, create one: + if(!$userName) { + $userName = $this->createGuestUserName(); + } else { + // Add the guest users prefix and suffix to the given userName: + $userName = $this->getConfig('guestUserPrefix').$userName.$this->getConfig('guestUserSuffix'); + } + } else { + $userName = $this->createGuestUserName(); + } + + $userData = array(); + $userData['userID'] = $this->createGuestUserID(); + $userData['userName'] = $userName; + $userData['userRole'] = AJAX_CHAT_GUEST; + return $userData; + } + + function getCustomVar($key) { + if(!isset($this->_customVars)) + $this->_customVars = array(); + if(!isset($this->_customVars[$key])) + return null; + return $this->_customVars[$key]; + } + + function setCustomVar($key, $value) { + if(!isset($this->_customVars)) + $this->_customVars = array(); + $this->_customVars[$key] = $value; + } + + // Override to replace custom template tags: + // Return the replacement for the given tag (and given tagContent) + function replaceCustomTemplateTags($tag, $tagContent) { + return null; + } + + // Override to initialize custom configuration settings: + function initCustomConfig() { + } + + // Override to add custom request variables: + // Add values to the request variables array: $this->_requestVars['customVariable'] = null; + function initCustomRequestVars() { + } + + // Override to add custom session code right after the session has been started: + function initCustomSession() { + } + + // Override, to parse custom info requests: + // $infoRequest contains the current info request + // Add info responses using the method addInfoMessage($info, $type) + function parseCustomInfoRequest($infoRequest) { + } + + // Override to replace custom text: + // Return replaced text + // $text contains the whole message + function replaceCustomText(&$text) { + return $text; + } + + // Override to add custom commands: + // Return true if a custom command has been successfully parsed, else false + // $text contains the whole message, $textParts the message split up as words array + function parseCustomCommands($text, $textParts) { + return false; + } + + // Override to perform custom actions on new messages: + // Return true if message may be inserted, else false + // $text contains the whole message + function onNewMessage($text) { + return true; + } + + // Override to perform custom actions on new messages: + // Method to set the style cookie depending on user data + function setStyle() { + } + + // Override: + // Returns true if the userID of the logged in user is identical to the userID of the authentication system + // or the user is authenticated as guest in the chat and the authentication system + function revalidateUserID() { + return true; + } + + // Override: + // Returns an associative array containing userName, userID and userRole + // Returns null if login is invalid + function getValidLoginUserData() { + // Check if we have a valid registered user: + if(false) { + // Here is the place to check user authentication + } else { + // Guest users: + return $this->getGuestUser(); + } + } + + // Override: + // Store the channels the current user has access to + // Make sure channel names don't contain any whitespace + function &getChannels() { + if($this->_channels === null) { + $this->_channels = $this->getAllChannels(); + } + return $this->_channels; + } + + // Override: + // Store all existing channels + // Make sure channel names don't contain any whitespace + function &getAllChannels() { + if($this->_allChannels === null) { + $this->_allChannels = array(); + + // Default channel, public to everyone: + $this->_allChannels[$this->trimChannelName($this->getConfig('defaultChannelName'))] = $this->getConfig('defaultChannelID'); + } + return $this->_allChannels; + } + +} diff --git a/public/lib/class/AJAXChatDataBase.php b/public/lib/class/AJAXChatDataBase.php new file mode 100644 index 0000000..e4d4024 --- /dev/null +++ b/public/lib/class/AJAXChatDataBase.php @@ -0,0 +1,81 @@ +_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig); + break; + case 'mysql': + $this->_db = new AJAXChatDatabaseMySQL($dbConnectionConfig); + break; + default: + // Use MySQLi if available, else MySQL (and check the type of a given database connection object): + if(function_exists('mysqli_connect') && (!$dbConnectionConfig['link'] || is_object($dbConnectionConfig['link']))) { + $this->_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig); + } else { + $this->_db = new AJAXChatDatabaseMySQL($dbConnectionConfig); + } + } + } + + // Method to connect to the DataBase server: + function connect(&$dbConnectionConfig) { + return $this->_db->connect($dbConnectionConfig); + } + + // Method to select the DataBase: + function select($dbName) { + return $this->_db->select($dbName); + } + + // Method to determine if an error has occured: + function error() { + return $this->_db->error(); + } + + // Method to return the error report: + function getError() { + return $this->_db->getError(); + } + + // Method to return the connection identifier: + function &getConnectionID() { + return $this->_db->getConnectionID(); + } + + // Method to prevent SQL injections: + function makeSafe($value) { + return $this->_db->makeSafe($value); + } + + // Method to perform SQL queries: + function sqlQuery($sql) { + return $this->_db->sqlQuery($sql); + } + + // Method to retrieve the current DataBase name: + function getName() { + return $this->_db->getName(); + //If your database has hyphens ( - ) in it, try using this instead: + //return '`'.$this->_db->getName().'`'; + } + + // Method to retrieve the last inserted ID: + function getLastInsertedID() { + return $this->_db->getLastInsertedID(); + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/AJAXChatEncoding.php b/public/lib/class/AJAXChatEncoding.php new file mode 100644 index 0000000..0707120 --- /dev/null +++ b/public/lib/class/AJAXChatEncoding.php @@ -0,0 +1,138 @@ +'&', '<'=>'<', '>'=>'>', "'"=>''', '"'=>'"'); + } + return $specialChars; + } + + // Helper function to store Regular expression for NO-WS-CTL as we cannot use static class members in PHP4: + public static function getRegExp_NO_WS_CTL() { + static $regExp_NO_WS_CTL; + if(!$regExp_NO_WS_CTL) { + // Regular expression for NO-WS-CTL, non-whitespace control characters (RFC 2822), decimal 1–8, 11–12, 14–31, and 127: + $regExp_NO_WS_CTL = '/[\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7F]/'; + } + return $regExp_NO_WS_CTL; + } + + public static function convertEncoding($str, $charsetFrom, $charsetTo) { + if(function_exists('mb_convert_encoding')) { + return mb_convert_encoding($str, $charsetTo, $charsetFrom); + } + if(function_exists('iconv')) { + return iconv($charsetFrom, $charsetTo, $str); + } + if(($charsetFrom == 'UTF-8') && ($charsetTo == 'ISO-8859-1')) { + return utf8_decode($str); + } + if(($charsetFrom == 'ISO-8859-1') && ($charsetTo == 'UTF-8')) { + return utf8_encode($str); + } + return $str; + } + + public static function htmlEncode($str, $contentCharset='UTF-8') { + switch($contentCharset) { + case 'UTF-8': + // Encode only special chars (&, <, >, ', ") as entities: + return AJAXChatEncoding::encodeSpecialChars($str); + break; + case 'ISO-8859-1': + case 'ISO-8859-15': + // Encode special chars and all extended characters above ISO-8859-1 charset as entities, then convert to content charset: + return AJAXChatEncoding::convertEncoding(AJAXChatEncoding::encodeEntities($str, 'UTF-8', array( + 0x26, 0x26, 0, 0xFFFF, // & + 0x3C, 0x3C, 0, 0xFFFF, // < + 0x3E, 0x3E, 0, 0xFFFF, // > + 0x27, 0x27, 0, 0xFFFF, // ' + 0x22, 0x22, 0, 0xFFFF, // " + 0x100, 0x2FFFF, 0, 0xFFFF // above ISO-8859-1 + )), 'UTF-8', $contentCharset); + break; + default: + // Encode special chars and all characters above ASCII charset as entities, then convert to content charset: + return AJAXChatEncoding::convertEncoding(AJAXChatEncoding::encodeEntities($str, 'UTF-8', array( + 0x26, 0x26, 0, 0xFFFF, // & + 0x3C, 0x3C, 0, 0xFFFF, // < + 0x3E, 0x3E, 0, 0xFFFF, // > + 0x27, 0x27, 0, 0xFFFF, // ' + 0x22, 0x22, 0, 0xFFFF, // " + 0x80, 0x2FFFF, 0, 0xFFFF // above ASCII + )), 'UTF-8', $contentCharset); + } + } + + public static function encodeSpecialChars($str) { + return strtr($str, AJAXChatEncoding::getSpecialChars()); + } + + public static function decodeSpecialChars($str) { + return strtr($str, array_flip(AJAXChatEncoding::getSpecialChars())); + } + + public static function encodeEntities($str, $encoding='UTF-8', $convmap=null) { + if($convmap && function_exists('mb_encode_numericentity')) { + return mb_encode_numericentity($str, $convmap, $encoding); + } + return htmlentities($str, ENT_QUOTES, $encoding); + } + + public static function decodeEntities($str, $encoding='UTF-8', $htmlEntitiesMap=null) { + // Due to PHP bug #25670, html_entity_decode does not work with UTF-8 for PHP versions < 5: + if(function_exists('html_entity_decode') && version_compare(phpversion(), 5, '>=')) { + // Replace numeric and literal entities: + $str = html_entity_decode($str, ENT_QUOTES, $encoding); + // Replace additional literal HTML entities if an HTML entities map is given: + if($htmlEntitiesMap) { + $str = strtr($str, $htmlEntitiesMap); + } + } else { + // Replace numeric entities: + $str = preg_replace('~&#([0-9]+);~e', 'AJAXChatEncoding::unicodeChar("\\1")', $str); + $str = preg_replace('~&#x([0-9a-f]+);~ei', 'AJAXChatEncoding::unicodeChar(hexdec("\\1"))', $str); + // Replace literal entities: + $htmlEntitiesMap = $htmlEntitiesMap ? $htmlEntitiesMap : array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES)); + $str = strtr($str, $htmlEntitiesMap); + } + return $str; + } + + public static function unicodeChar($c) { + if($c <= 0x7F) { + return chr($c); + } else if($c <= 0x7FF) { + return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F); + } else if($c <= 0xFFFF) { + return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F) + . chr(0x80 | $c & 0x3F); + } else if($c <= 0x10FFFF) { + return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) + . chr(0x80 | $c >> 6 & 0x3F) + . chr(0x80 | $c & 0x3F); + } else { + return null; + } + } + + public static function removeUnsafeCharacters($str) { + // Remove NO-WS-CTL, non-whitespace control characters (RFC 2822), decimal 1–8, 11–12, 14–31, and 127: + return preg_replace(AJAXChatEncoding::getRegExp_NO_WS_CTL(), '', $str); + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/AJAXChatFileSystem.php b/public/lib/class/AJAXChatFileSystem.php new file mode 100644 index 0000000..a8c5704 --- /dev/null +++ b/public/lib/class/AJAXChatFileSystem.php @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/public/lib/class/AJAXChatHTTPHeader.php b/public/lib/class/AJAXChatHTTPHeader.php new file mode 100644 index 0000000..f97a8d8 --- /dev/null +++ b/public/lib/class/AJAXChatHTTPHeader.php @@ -0,0 +1,56 @@ +_contentType = $contentType.'; charset='.$encoding; + $this->_constant = true; + } else { + if(isset($_SERVER['HTTP_ACCEPT']) && (strpos($_SERVER['HTTP_ACCEPT'],'application/xhtml+xml') !== false)) { + $this->_contentType = 'application/xhtml+xml; charset='.$encoding; + } else { + $this->_contentType = 'text/html; charset='.$encoding; + } + $this->_constant = false; + } + $this->_noCache = $noCache; + } + + // Method to send the HTTP header: + function send() { + // Prevent caching: + if($this->_noCache) { + header('Cache-Control: no-cache, must-revalidate'); + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); + } + + // Send the content-type-header: + header('Content-Type: '.$this->_contentType); + + // Send vary header if content-type varies (important for proxy-caches): + if(!$this->_constant) { + header('Vary: Accept'); + } + } + + // Method to return the content-type string: + function getContentType() { + // Return the content-type string: + return $this->_contentType; + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/AJAXChatLanguage.php b/public/lib/class/AJAXChatLanguage.php new file mode 100644 index 0000000..70c3513 --- /dev/null +++ b/public/lib/class/AJAXChatLanguage.php @@ -0,0 +1,102 @@ +_regExpAcceptLangCode = '/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i'; + $this->_availableLangCodes = $availableLangCodes; + $this->_defaultLangCode = $defaultLangCode; + if($langCode && in_array($langCode, $availableLangCodes)) { + $this->_langCode = $langCode; + } + $this->_strictMode = $strictMode; + } + + // Method to detect the language code from the HTTP_ACCEPT_LANGUAGE header: + function detectLangCode() { + // If HTTP_ACCEPT_LANGUAGE is empty use defaultLangCode: + if(empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + $this->_langCode = $this->_defaultLangCode; + return; + } + + // Split up the HTTP_ACCEPT_LANGUAGE header: + $acceptedLanguages = preg_split('/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + + $currentLangCode = $this->_defaultLangCode; + $currentLangQuality = 0.0; + + foreach($acceptedLanguages as $acceptedLanguage) { + // Parse the language string: + $match = preg_match($this->_regExpAcceptLangCode, $acceptedLanguage, $matches); + // Check if the syntax is valid: + if(!$match) { + continue; + } + + // Get and split the language code: + $langCodeParts = explode ('-', $matches[1]); + + // Get the language quality given as float value: + if(isset($matches[2])) { + $langQuality = (float)$matches[2]; + } else { + // Missing language quality value is maximum quality: + $langQuality = 1.0; + } + + // Go through it until the language code is empty: + while(count($langCodeParts)) { + // Join the current langCodeParts: + $langCode = strtolower(join('-', $langCodeParts)); + // Check if the langCode is in the available list: + if(in_array($langCode, $this->_availableLangCodes)) { + // Check the quality setting: + if ($langQuality > $currentLangQuality) { + $currentLangCode = $langCode; + $currentLangQuality = $langQuality; + break; + } + } + // If strict mode is set, don't minimalize the language code: + if($this->_strictMode) { + break; + } + // else chop off the right part: + array_pop($langCodeParts); + } + } + + $this->_langCode = $currentLangCode; + } + + function getLangCode() { + if(!$this->_langCode) { + $this->detectLangCode(); + } + return $this->_langCode; + } + + function setLangCode($langCode) { + $this->_langCode = $langCode; + } + + function getLangCodes() { + return $this->_availableLangCodes; + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/AJAXChatMySQLDataBase.php b/public/lib/class/AJAXChatMySQLDataBase.php new file mode 100644 index 0000000..e6f0c7b --- /dev/null +++ b/public/lib/class/AJAXChatMySQLDataBase.php @@ -0,0 +1,92 @@ +_connectionID = $dbConnectionConfig['link']; + $this->_dbName = $dbConnectionConfig['name']; + } + + // Method to connect to the DataBase server: + function connect(&$dbConnectionConfig) { + $this->_connectionID = @mysql_connect( + $dbConnectionConfig['host'], + $dbConnectionConfig['user'], + $dbConnectionConfig['pass'], + true + ); + if(!$this->_connectionID) { + $this->_errno = null; + $this->_error = 'Database connection failed.'; + return false; + } + return true; + } + + // Method to select the DataBase: + function select($dbName) { + if(!@mysql_select_db($dbName, $this->_connectionID)) { + $this->_errno = mysql_errno($this->_connectionID); + $this->_error = mysql_error($this->_connectionID); + return false; + } + $this->_dbName = $dbName; + return true; + } + + // Method to determine if an error has occured: + function error() { + return (bool)$this->_error; + } + + // Method to return the error report: + function getError() { + if($this->error()) { + $str = 'Error-Report: ' .$this->_error."\n"; + $str .= 'Error-Code: '.$this->_errno."\n"; + } else { + $str = 'No errors.'."\n"; + } + return $str; + } + + // Method to return the connection identifier: + function &getConnectionID() { + return $this->_connectionID; + } + + // Method to prevent SQL injections: + function makeSafe($value) { + return "'".mysql_real_escape_string($value, $this->_connectionID)."'"; + } + + // Method to perform SQL queries: + function sqlQuery($sql) { + return new AJAXChatMySQLQuery($sql, $this->_connectionID); + } + + // Method to retrieve the current DataBase name: + function getName() { + return $this->_dbName; + } + + // Method to retrieve the last inserted ID: + function getLastInsertedID() { + return mysql_insert_id($this->_connectionID); + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/AJAXChatMySQLQuery.php b/public/lib/class/AJAXChatMySQLQuery.php new file mode 100644 index 0000000..5c8f715 --- /dev/null +++ b/public/lib/class/AJAXChatMySQLQuery.php @@ -0,0 +1,89 @@ +_sql = trim($sql); + $this->_connectionID = $connectionID; + if($this->_connectionID) { + $this->_result = mysql_query($this->_sql, $this->_connectionID); + if(!$this->_result) { + $this->_errno = mysql_errno($this->_connectionID); + $this->_error = mysql_error($this->_connectionID); + } + } else { + $this->_result = mysql_query($this->_sql); + if(!$this->_result) { + $this->_errno = mysql_errno(); + $this->_error = mysql_error(); + } + } + } + + // Returns true if an error occured: + function error() { + // Returns true if the Result-ID is valid: + return !(bool)($this->_result); + } + + // Returns an Error-String: + function getError() { + if($this->error()) { + $str = 'Query: ' .$this->_sql ."\n"; + $str .= 'Error-Report: ' .$this->_error."\n"; + $str .= 'Error-Code: '.$this->_errno; + } else { + $str = "No errors."; + } + return $str; + } + + // Returns the content: + function fetch() { + if($this->error()) { + return null; + } else { + return mysql_fetch_assoc($this->_result); + } + } + + // Returns the number of rows (SELECT or SHOW): + function numRows() { + if($this->error()) { + return null; + } else { + return mysql_num_rows($this->_result); + } + } + + // Returns the number of affected rows (INSERT, UPDATE, REPLACE or DELETE): + function affectedRows() { + if($this->error()) { + return null; + } else { + return mysql_affected_rows($this->_connectionID); + } + } + + // Frees the memory: + function free() { + @mysql_free_result($this->_result); + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/AJAXChatMySQLiDataBase.php b/public/lib/class/AJAXChatMySQLiDataBase.php new file mode 100644 index 0000000..6b7c6d5 --- /dev/null +++ b/public/lib/class/AJAXChatMySQLiDataBase.php @@ -0,0 +1,91 @@ +_connectionID = $dbConnectionConfig['link']; + $this->_dbName = $dbConnectionConfig['name']; + } + + // Method to connect to the DataBase server: + function connect(&$dbConnectionConfig) { + $this->_connectionID = new mysqli( + $dbConnectionConfig['host'], + $dbConnectionConfig['user'], + $dbConnectionConfig['pass'] + ); + if(!$this->_connectionID) { + $this->_errno = mysqli_connect_errno(); + $this->_error = mysqli_connect_error(); + return false; + } + return true; + } + + // Method to select the DataBase: + function select($dbName) { + if(!$this->_connectionID->select_db($dbName)) { + $this->_errno = $this->_connectionID->errno; + $this->_error = $this->_connectionID->error; + return false; + } + $this->_dbName = $dbName; + return true; + } + + // Method to determine if an error has occured: + function error() { + return (bool)$this->_error; + } + + // Method to return the error report: + function getError() { + if($this->error()) { + $str = 'Error-Report: ' .$this->_error."\n"; + $str .= 'Error-Code: '.$this->_errno."\n"; + } else { + $str = 'No errors.'."\n"; + } + return $str; + } + + // Method to return the connection identifier: + function &getConnectionID() { + return $this->_connectionID; + } + + // Method to prevent SQL injections: + function makeSafe($value) { + return "'".$this->_connectionID->escape_string($value)."'"; + } + + // Method to perform SQL queries: + function sqlQuery($sql) { + return new AJAXChatMySQLiQuery($sql, $this->_connectionID); + } + + // Method to retrieve the current DataBase name: + function getName() { + return $this->_dbName; + } + + // Method to retrieve the last inserted ID: + function getLastInsertedID() { + return $this->_connectionID->insert_id; + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/AJAXChatMySQLiQuery.php b/public/lib/class/AJAXChatMySQLiQuery.php new file mode 100644 index 0000000..cbce97e --- /dev/null +++ b/public/lib/class/AJAXChatMySQLiQuery.php @@ -0,0 +1,81 @@ +_sql = trim($sql); + $this->_connectionID = $connectionID; + $this->_result = $this->_connectionID->query($this->_sql); + if(!$this->_result) { + $this->_errno = $this->_connectionID->errno; + $this->_error = $this->_connectionID->error; + } + } + + // Returns true if an error occured: + function error() { + // Returns true if the Result-ID is valid: + return !(bool)($this->_result); + } + + // Returns an Error-String: + function getError() { + if($this->error()) { + $str = 'Query: ' .$this->_sql ."\n"; + $str .= 'Error-Report: ' .$this->_error."\n"; + $str .= 'Error-Code: '.$this->_errno; + } else { + $str = "No errors."; + } + return $str; + } + + // Returns the content: + function fetch() { + if($this->error()) { + return null; + } else { + return $this->_result->fetch_assoc(); + } + } + + // Returns the number of rows (SELECT or SHOW): + function numRows() { + if($this->error()) { + return null; + } else { + return $this->_result->num_rows; + } + } + + // Returns the number of affected rows (INSERT, UPDATE, REPLACE or DELETE): + function affectedRows() { + if($this->error()) { + return null; + } else { + return $this->_connectionID->affected_rows; + } + } + + // Frees the memory: + function free() { + $this->_result->free(); + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/AJAXChatString.php b/public/lib/class/AJAXChatString.php new file mode 100644 index 0000000..606240a --- /dev/null +++ b/public/lib/class/AJAXChatString.php @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/public/lib/class/AJAXChatTemplate.php b/public/lib/class/AJAXChatTemplate.php new file mode 100644 index 0000000..1ec0841 --- /dev/null +++ b/public/lib/class/AJAXChatTemplate.php @@ -0,0 +1,359 @@ +ajaxChat = $ajaxChat; + $this->_regExpTemplateTags = '/\[(\w+?)(?:(?:\/)|(?:\](.+?)\[\/\1))\]/s'; + $this->_templateFile = $templateFile; + $this->_contentType = $contentType; + } + + function getParsedContent() { + if(!$this->_parsedContent) { + $this->parseContent(); + } + return $this->_parsedContent; + } + + function getContent() { + if(!$this->_content) { + $this->_content = AJAXChatFileSystem::getFileContents($this->_templateFile); + } + return $this->_content; + } + + function parseContent() { + $this->_parsedContent = $this->getContent(); + + // Remove the XML declaration if the content-type is not xml: + if($this->_contentType && (strpos($this->_contentType,'xml') === false)) { + $doctypeStart = strpos($this->_parsedContent, '_parsedContent = substr($this->_parsedContent, $doctypeStart); + } + } + + // Replace template tags ([TAG/] and [TAG]content[/TAG]) and return parsed template content: + $this->_parsedContent = preg_replace_callback($this->_regExpTemplateTags, array($this, 'replaceTemplateTags'), $this->_parsedContent); + } + + function replaceTemplateTags($tagData) { + switch($tagData[1]) { + case 'AJAX_CHAT_URL': + return $this->ajaxChat->htmlEncode($this->ajaxChat->getChatURL()); + + case 'LANG': + return $this->ajaxChat->htmlEncode($this->ajaxChat->getLang($tagData[2])); + case 'LANG_CODE': + return $this->ajaxChat->getLangCode(); + + case 'BASE_DIRECTION': + return $this->getBaseDirectionAttribute(); + + case 'CONTENT_ENCODING': + return $this->ajaxChat->getConfig('contentEncoding'); + + case 'CONTENT_TYPE': + return $this->_contentType; + + case 'LOGIN_URL': + return ($this->ajaxChat->getRequestVar('view') == 'logs') ? './?view=logs' : './'; + + case 'USER_NAME_MAX_LENGTH': + return $this->ajaxChat->getConfig('userNameMaxLength'); + case 'MESSAGE_TEXT_MAX_LENGTH': + return $this->ajaxChat->getConfig('messageTextMaxLength'); + + case 'LOGIN_CHANNEL_ID': + return $this->ajaxChat->getValidRequestChannelID(); + + case 'SESSION_NAME': + return $this->ajaxChat->getConfig('sessionName'); + + case 'COOKIE_EXPIRATION': + return $this->ajaxChat->getConfig('sessionCookieLifeTime'); + case 'COOKIE_PATH': + return $this->ajaxChat->getConfig('sessionCookiePath'); + case 'COOKIE_DOMAIN': + return $this->ajaxChat->getConfig('sessionCookieDomain'); + case 'COOKIE_SECURE': + return $this->ajaxChat->getConfig('sessionCookieSecure'); + + case 'CHAT_BOT_NAME': + return rawurlencode($this->ajaxChat->getConfig('chatBotName')); + case 'CHAT_BOT_ID': + return $this->ajaxChat->getConfig('chatBotID'); + + case 'ALLOW_USER_MESSAGE_DELETE': + if($this->ajaxChat->getConfig('allowUserMessageDelete')) + return 1; + else + return 0; + + case 'INACTIVE_TIMEOUT': + return $this->ajaxChat->getConfig('inactiveTimeout'); + + case 'PRIVATE_CHANNEL_DIFF': + return $this->ajaxChat->getConfig('privateChannelDiff'); + case 'PRIVATE_MESSAGE_DIFF': + return $this->ajaxChat->getConfig('privateMessageDiff'); + + case 'SHOW_CHANNEL_MESSAGES': + if($this->ajaxChat->getConfig('showChannelMessages')) + return 1; + else + return 0; + + case 'SOCKET_SERVER_ENABLED': + if($this->ajaxChat->getConfig('socketServerEnabled')) + return 1; + else + return 0; + + case 'SOCKET_SERVER_HOST': + if($this->ajaxChat->getConfig('socketServerHost')) { + $socketServerHost = $this->ajaxChat->getConfig('socketServerHost'); + } else { + $socketServerHost = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']); + } + return rawurlencode($socketServerHost); + + case 'SOCKET_SERVER_PORT': + return $this->ajaxChat->getConfig('socketServerPort'); + + case 'SOCKET_SERVER_CHAT_ID': + return $this->ajaxChat->getConfig('socketServerChatID'); + + case 'STYLE_SHEETS': + return $this->getStyleSheetLinkTags(); + + case 'CHANNEL_OPTIONS': + return $this->getChannelOptionTags(); + case 'STYLE_OPTIONS': + return $this->getStyleOptionTags(); + case 'LANGUAGE_OPTIONS': + return $this->getLanguageOptionTags(); + + case 'ERROR_MESSAGES': + return $this->getErrorMessageTags(); + + case 'LOGS_CHANNEL_OPTIONS': + return $this->getLogsChannelOptionTags(); + case 'LOGS_YEAR_OPTIONS': + return $this->getLogsYearOptionTags(); + case 'LOGS_MONTH_OPTIONS': + return $this->getLogsMonthOptionTags(); + case 'LOGS_DAY_OPTIONS': + return $this->getLogsDayOptionTags(); + case 'LOGS_HOUR_OPTIONS': + return $this->getLogsHourOptionTags(); + case 'MENU_BAR': + return << +
  • Home
  • +
  • News
  • +
  • Chat
  • +
  • Members
  • +
  • Donate
  • +
  • Status
  • + +EOF; + case 'COPYRIGHT': + return << + Copyright © 2013-2015 Flashwave +
    AJAX Chat © blueimp.net +
    + Feedback | + Changelog | + Rules & Info | + Terms of Service | + Contact | + DevSite | + Legacy Login +
    +EOF; + case 'SANDSTORM': + if(date('md') === '0127' || !empty($_GET['sandstorm'])) + return << + +
    +HTML; + else + return ''; + default: + return $this->ajaxChat->replaceCustomTemplateTags($tagData[1], (isset($tagData[2]) ? $tagData[2] : null)); + } + } + + // Function to display alternating table row colors: + function alternateRow($rowOdd='rowOdd', $rowEven='rowEven') { + static $i; + $i += 1; + if($i % 2 == 0) { + return $rowEven; + } else { + return $rowOdd; + } + } + + function getBaseDirectionAttribute() { + $langCodeParts = explode('-', $this->ajaxChat->getLangCode()); + switch($langCodeParts[0]) { + case 'ar': + case 'fa': + case 'he': + return 'rtl'; + default: + return 'ltr'; + } + } + + function getStyleSheetLinkTags() { + $styleSheets = ''; + foreach($this->ajaxChat->getConfig('styleAvailable') as $style) { + $alternate = ($style == $this->ajaxChat->getConfig('styleDefault')) ? '' : 'alternate '; + $styleSheets .= ''; + } + return $styleSheets; + } + + function getChannelOptionTags() { + $channelOptions = ''; + $channelSelected = false; + foreach($this->ajaxChat->getChannels() as $key=>$value) { + if($this->ajaxChat->isLoggedIn()) { + $selected = ($value == $this->ajaxChat->getChannel()) ? ' selected="selected"' : ''; + } else { + $selected = ($value == $this->ajaxChat->getConfig('defaultChannelID')) ? ' selected="selected"' : ''; + } + if($selected) { + $channelSelected = true; + } + $channelOptions .= ''; + } + if($this->ajaxChat->isLoggedIn() && $this->ajaxChat->isAllowedToCreatePrivateChannel()) { + // Add the private channel of the user to the options list: + if(!$channelSelected && $this->ajaxChat->getPrivateChannelID() == $this->ajaxChat->getChannel()) { + $selected = ' selected="selected"'; + $channelSelected = true; + } else { + $selected = ''; + } + $privateChannelName = $this->ajaxChat->getPrivateChannelName(); + $channelOptions .= ''; + } + // If current channel is not in the list, try to retrieve the channelName: + if(!$channelSelected) { + $channelName = $this->ajaxChat->getChannelName(); + if($channelName !== null) { + $channelOptions .= ''; + } else { + // Show an empty selection: + $channelOptions .= ''; + } + } + return $channelOptions; + } + + function getStyleOptionTags() { + $styleOptions = ''; + foreach($this->ajaxChat->getConfig('styleAvailable') as $style) { + $selected = ($style == $this->ajaxChat->getConfig('styleDefault')) ? ' selected="selected"' : ''; + $styleOptions .= ''; + } + return $styleOptions; + } + + function getLanguageOptionTags() { + $languageOptions = ''; + $languageNames = $this->ajaxChat->getConfig('langNames'); + foreach($this->ajaxChat->getConfig('langAvailable') as $langCode) { + $selected = ($langCode == $this->ajaxChat->getLangCode()) ? ' selected="selected"' : ''; + $languageOptions .= ''; + } + return $languageOptions; + } + + function getErrorMessageTags() { + $errorMessages = ''; + foreach($this->ajaxChat->getInfoMessages('error') as $error) { + $errorMessages .= '

    '.$this->ajaxChat->htmlEncode($this->ajaxChat->getLang($error)).'

    '; + } + return $errorMessages; + } + + function getLogsChannelOptionTags() { + $channelOptions = ''; + $channelOptions .= ''; + foreach($this->ajaxChat->getChannels() as $key=>$value) { + if($this->ajaxChat->getUserRole() != AJAX_CHAT_ADMIN && $this->ajaxChat->getConfig('logsUserAccessChannelList') && !in_array($value, $this->ajaxChat->getConfig('logsUserAccessChannelList'))) { + continue; + } + $channelOptions .= ''; + } + $channelOptions .= ''; + $channelOptions .= ''; + return $channelOptions; + } + + function getLogsYearOptionTags() { + $yearOptions = ''; + $yearOptions .= ''; + for($year=date('Y'); $year>=$this->ajaxChat->getConfig('logsFirstYear'); $year--) { + $yearOptions .= ''; + } + return $yearOptions; + } + + function getLogsMonthOptionTags() { + $monthOptions = ''; + $monthOptions .= ''; + for($month=1; $month<=12; $month++) { + $monthOptions .= ''; + } + return $monthOptions; + } + + function getLogsDayOptionTags() { + $dayOptions = ''; + $dayOptions .= ''; + for($day=1; $day<=31; $day++) { + $dayOptions .= ''; + } + return $dayOptions; + } + + function getLogsHourOptionTags() { + $hourOptions = ''; + $hourOptions .= ''; + for($hour=0; $hour<=23; $hour++) { + $hourOptions .= ''; + } + return $hourOptions; + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/CustomAJAXChat.php b/public/lib/class/CustomAJAXChat.php new file mode 100644 index 0000000..8a073a1 --- /dev/null +++ b/public/lib/class/CustomAJAXChat.php @@ -0,0 +1,260 @@ +getRequestVar('password')) { + // Check if we have a valid registered user: + + $userName = $this->getRequestVar('userName'); + $userName = $this->convertEncoding($userName, $this->getConfig('contentEncoding'), $this->getConfig('sourceEncoding')); + + $password = $this->getRequestVar('password'); + $password = $this->convertEncoding($password, $this->getConfig('contentEncoding'), $this->getConfig('sourceEncoding')); + + $flashiiConfig = parse_ini_file('/www/flashii.net/config/config.ini', true, INI_SCANNER_TYPED); + + if (!empty($flashiiConfig['Database'])) { + $dbConfig = $flashiiConfig['Database']; + $flashiiDb = new PDO( + "mysql:unix_socket={$dbConfig['unix_socket']};dbname={$dbConfig['database']}", + $dbConfig['username'], + $dbConfig['password'], + [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, + PDO::ATTR_EMULATE_PREPARES => false, + ] + ); + + $getFlashiiUser = $flashiiDb->prepare(' + SELECT `user_id` as `userID`, `username` as `userName`, `display_role` as `userRole`, `password` + FROM `msz_users` + WHERE LOWER(`username`) = LOWER(:username) + '); + $getFlashiiUser->bindValue('username', $userName); + $flashiiUser = $getFlashiiUser->execute() ? $getFlashiiUser->fetch(PDO::FETCH_ASSOC) : []; + + if (!empty($flashiiUser) && password_verify($password, $flashiiUser['password'])) { + unset($flashiiUser['password']); + + // corrections, i'm not going to update the random IDs scattered about + switch ($flashiiUser['userRole']) { + case 2: + $flashiiUser['userRole'] = AJAX_CHAT_MODERATOR; + break; + case 3: + $flashiiUser['userRole'] = AJAX_CHAT_ADMIN; + break; + case 4: + $flashiiUser['userRole'] = BOTS; + break; + case 5: + $flashiiUser['userRole'] = AJAX_CHAT_GUEST; + break; + case 6: + case 7: + $flashiiUser['userRole'] = DONATOR; + break; + default: + $flashiiUser['userRole'] = AJAX_CHAT_USER; + } + + /*if ($flashiiUser['userID'] === 2) { + $flashiiUser['userRole'] = CMOD; + } else*/if ($flashiiUser['userID'] === 3) { + $flashiiUser['userRole'] = AJAX_CHAT_MODERATOR; + } + + return $flashiiUser; + } + } + + return null; + } else { + // Guest users: + return $this->getGuestUser(); + } + } + + // Store the channels the current user has access to + // Make sure channel names don't contain any whitespace + function &getChannels() { + if($this->_channels === null) { + $this->_channels = array(); + + /*$customUsers = $this->getCustomUsers(); + + // Get the channels, the user has access to: + if($this->getUserRole() == AJAX_CHAT_GUEST) { + $validChannels = $customUsers[0]['channels']; + } else { + $validChannels = $customUsers[$this->getUserID()]['channels']; + }*/ + + // Add the valid channels to the channel list (the defaultChannelID is always valid): + foreach($this->getAllChannels() as $key=>$value) { + // Check if we have to limit the available channels: + if($this->getConfig('limitChannelList') && !in_array($value, $this->getConfig('limitChannelList'))) { + continue; + } + + //if(in_array($value, $validChannels) || $value == $this->getConfig('defaultChannelID')) { + $this->_channels[$key] = $value; + //} + } + } + return $this->_channels; + } + + // Store all existing channels + // Make sure channel names don't contain any whitespace + function &getAllChannels() { + if($this->_allChannels === null) { + // Get all existing channels: + $customChannels = $this->getCustomChannels(); + + $defaultChannelFound = false; + + foreach($customChannels as $key=>$value) { + $forumName = $this->trimChannelName($value); + + $this->_allChannels[$forumName] = $key; + + if($key == $this->getConfig('defaultChannelID')) { + $defaultChannelFound = true; + } + } + + if(!$defaultChannelFound) { + // Add the default channel as first array element to the channel list: + $this->_allChannels = array_merge( + array( + $this->trimChannelName($this->getConfig('defaultChannelName'))=>$this->getConfig('defaultChannelID') + ), + $this->_allChannels + ); + } + } + return $this->_allChannels; + } + + /*function &getCustomUsers() { + global $database; + + $userlist = $database->query("SELECT * FROM `accounts`.`flashii_users` WHERE `userrole` != '0'")->fetch_all(MYSQLI_ASSOC); + + $users = array(); + + $users[0] = array(); + $users[0]['userRole'] = AJAX_CHAT_GUEST; + $users[0]['userName'] = null; + $users[0]['password'] = null; + $users[0]['channels'] = array(0,1); + + foreach($userlist as $user) { + $users[$user['id']] = array(); + $users[$user['id']]['userName'] = $user['username']; + $users[$user['id']]['password'] = $user['password']; + + switch($user['userrole']) { + // Tenshi + case 7: + $users[$user['id']]['userRole'] = DONATOR; + $users[$user['id']]['channels'] = array(0, 1); + break; + + // Chat Moderators + case 6: + $users[$user['id']]['userRole'] = CMOD; + $users[$user['id']]['channels'] = array(0, 1, 2); + break; + + // Bots + case 5: + $users[$user['id']]['userRole'] = BOTS; + $users[$user['id']]['channels'] = array(0, 1, 2); + break; + + // Developers + case 4: + $users[$user['id']]['userRole'] = PURPLE; + $users[$user['id']]['channels'] = array(0, 1, 2); + break; + + // Administrator + case 3: + $users[$user['id']]['userRole'] = AJAX_CHAT_ADMIN; + $users[$user['id']]['channels'] = array(0, 1, 2); + break; + + // Site Moderators + case 2: + $users[$user['id']]['userRole'] = AJAX_CHAT_MODERATOR; + $users[$user['id']]['channels'] = array(0, 1, 2); + break; + + // Regular Users + case 1: + $users[$user['id']]['userRole'] = AJAX_CHAT_USER; + $users[$user['id']]['channels'] = array(0, 1); + break; + + // Unknown and Deactivated Users + case 0: + default: + $users[$user['id']]['userRole'] = AJAX_CHAT_GUEST; + $users[$user['id']]['channels'] = array(0); + } + } + + return $users; + }*/ + + function &getCustomChannels() { + $channels = [ + 0 => 'Public', + ]; + /*$result = $this->db->sqlQuery("SELECT * FROM ajax_chat_channels")->_result->fetch_all(MYSQLI_ASSOC); + + foreach($result as $channel) { + $channels[$channel['id']] = $channel['name']; + }*/ + + if($this->isLoggedIn()) + $channels[9001] = 'Secret'; + + return $channels; + } + + function parseCustomCommands($text, $textParts) { + switch($textParts[0]) { + case '/afk': + $this->setUserName('_' . $this->getUserName()); + $this->updateOnlineList(); + $this->addInfoMessage($this->getUserName(), 'userName'); + $this->setSessionVar('AwayFromKeyboard', true); + return true; + default: + return false; + } + } + + function onNewMessage($text) { + if($this->getSessionVar('AwayFromKeyboard')) { + $this->setUserName(substr($this->getUserName(), 6)); + $this->updateOnlineList(); + $this->addInfoMessage($this->getUserName(), 'userName'); + $this->setSessionVar('AwayFromKeyboard', false); + } + return true; + } +} diff --git a/public/lib/class/CustomAJAXChatInterface.php b/public/lib/class/CustomAJAXChatInterface.php new file mode 100644 index 0000000..b84dd42 --- /dev/null +++ b/public/lib/class/CustomAJAXChatInterface.php @@ -0,0 +1,21 @@ +initConfig(); + + // Initialize the DataBase connection: + $this->initDataBaseConnection(); + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/CustomAJAXChatShoutBox.php b/public/lib/class/CustomAJAXChatShoutBox.php new file mode 100644 index 0000000..453357b --- /dev/null +++ b/public/lib/class/CustomAJAXChatShoutBox.php @@ -0,0 +1,25 @@ +initConfig(); + } + + function getShoutBoxContent() { + $template = new AJAXChatTemplate($this, AJAX_CHAT_PATH.'lib/template/shoutbox.html'); + + // Return parsed template content: + return $template->getParsedContent(); + } + +} +?> \ No newline at end of file diff --git a/public/lib/class/satori.php b/public/lib/class/satori.php new file mode 100644 index 0000000..ea82b1f --- /dev/null +++ b/public/lib/class/satori.php @@ -0,0 +1,239 @@ +]*?))?\\]/ms', '', $satoriParse); +$textParts = explode(' ', $satoriParse); + + +// Random Stuff +$defaultResponseArray = ['What do you want?', 'Kindly fuck off.', 'Don\'t know how to "%s" something.', 'Come again?', 'Satori returned an empty result set (i.e. zero rows).']; +$defaultResponse = sprintf($defaultResponseArray[array_rand($defaultResponseArray)], $textParts[0]); + + +// Actions +if(preg_match('/^k$/im', $satoriParse)) { + $satoriResp = ['Thank you for your amazing and insightful message. It is truly an honour to have this message in my database. I can\'t thank you more than to say go fuck yourself. You truly touched me... Thank you.']; +} +if(preg_match('/^time to break the chat$/im', $satoriParse)) { + $satoriResp = ['Stay away from me!']; +} +if(preg_match('/^all aboard the sailboat$/im', $satoriParse)) { + $satoriResp = ['Why would we get on something that is about to sink :^)']; +} + + +// Reactions +if(preg_match('/^satori/im', $textParts[0])) { + switch($satoriInput = preg_replace('/^satori? ?/', '', $satoriParse)) { + case 'version': + $satoriResp = ['[b][color=Red]S[/color][color=Ruby]a[/color][color=Citrine]t[/color][color=Green]o[/color][color=Teal]r[/color][color=Cobalt]i[/color][/b] Version not [b]6[/b]']; + break; + case 'what are you': + $satoriResp = ['I am nice girl for nice chat.', '[img]http://i.imgur.com/NcFitL2.jpg[/img]']; + break; + case 'hi': + $satoriResp = ['sup']; + break; + case 'help': + $satoriResp = ['If you need help with things refer to the [url=http://flashii.net/r/faq]FAQ[/url].', 'If this didn\'t help you don\'t hesitate to ask an active user.']; + break; + case 'why do you exist': + $satoriResp = ['So you have someone to hate. <3']; + break; + case 'suck my dick': + $satoriResp = ['Do you even have one? Can\'t see it.']; + break; + case 'make me admin': + $satoriResp = ['Why the fuck would you WANT admin? It\'s nothing more than extra work for an ugly red username! Look now the colour for deactivated user, that one\'s fucking hot.']; + break; + case 'anime': + $satoriResp = ['Oh god, i wish i could leave this chat but i\'m stuck in here ;__;']; + break; + case 'e': + $satoriResp = ['Do I look like Nasbot or something?']; + break; + case 'meow': + $satoriResp = ['Mewow!']; + break; + case 'puush': + $satoriResp = ['Something you should be using.']; + break; + case 'what is flash\'s password': + case 'what is flashwave\'s password': + case 'what is moka\'s password': + $satoriResp = ['/suicide', 'I do recommend sending it in chat right now.']; + break; + case 'what do you think about snailmush': + case 'what do you like snailmush': + case 'snailmush': + $satoriResp = ['I-it\'s not like I like him or-or any-anything...... ;_;']; + break; + case 'x snailmush': + case 'loves snailmush': + case 'do you love snailmush': + case 'do you love snailmush?': + $satoriResp = ['NO!', '[s]Trigger Kick']; + break; + case 'saibateku': + $satoriResp = ['That place is still up?']; + break; + case 'titanic': + $satoriResp = ['Did you mean Sailboat?']; + break; + case 'did sailboat sink yet': + $satoriResp = ['No but I wish it would. Fuck that place. Seems to be getting pretty close however...']; + break; + case 'malwareup': + $satoriResp = ['Good malware discussion forum.']; + break; + case 'flashii': + $satoriResp = ['Mediocre shithole. 0/10']; + break; + case 'cybernetics': + $satoriResp = ['Did you mean "Saibateku"?']; + break; + case 'nathat': + $satoriResp = ['shut up']; + break; + case 'waifu': + case 'inori aizawa': + case 'internet explorer tan': + $satoriResp = ['Inori Aizawa Is Mai Waifu.', 'Welcome To Mai Web Browser Is Mai Waifu Land!']; + break; + case 'webkit': + case 'safari': + case 'blink': + case 'chrome': + $satoriResp = [':puke::puke::puke:']; + break; + case 'gecko': + case 'trident': + case 'internet explorer': + case 'iexplore': + case 'firefox': + case 'mozilla firefox': + $satoriResp = [':love::love::love:']; + break; + case 'bribob': + case 'bribob4': + $satoriResp = ['Mediocre faggot. 0/10']; + break; + case 'kelopez': + case 'brante': + $satoriResp = ['http://en.wikipedia.org/wiki/Mexican']; + break; + case 'kamil': + case 'rakowski': + case 'kamilrakowski': + $satoriResp = ['http://en.wikipedia.org/wiki/Jews']; + break; + case 'secret': + $satoriResp = ['I\'m not a secret ripoff, what are you talking about?', '[i]My code is better, time to kill yourself![/i]']; + break; + case 'koishi': + $satoriResp = ['Don\'t fuck with Koishi.']; + break; + case ':^)': + $satoriResp = ['8^)']; + break; + case 'nookls': + $satoriResp = ['HOOOOLLLLLYYYYYYYYYYYYY CRAP NOOKLS IS SO AMAZING WOWOWOWOWOWOW HE\'S ACTUALLY ON THIS SITE WORSHIP WORSHIP AMAZING BRILLIANT I LOVE YOU NOOKLS WE ALL LOVE YOU WE LOVE YOU AS MUCH AS FANGIRLS LOVE JUSTIN BIEBER AAAAAAAAHHHHHHHHHHHH THIS IS THE BEST MOMENT!']; + break; + case 'zeniea': + $satoriResp = ['For whatever reason I have the urge to say "This place smells like a catholic church on crack"...']; + break; + case 'zquest': + $satoriResp = ['Good comic 10/10']; + break; + case 'fuck me': + $satoriResp = [':wtf:']; + break; + case 'satori': + $satoriResp = ['Wait, what are you trying to do?']; + break; + case 'satori satori': + $satoriResp = ['Don\'t fucking do this to me...']; + break; + case 'satori satori satori': + $satoriResp = ['[b][i]I\'ll fucking murder you![/i][/b]']; + break; + case 'satori satori satori satori': + $satoriResp = ['no don\'t']; + break; + case 'satori satori satori satori satori': + $satoriResp = ['please don\'t do this to me']; + break; + case 'satori satori satori satori satori satori': + $satoriResp = ['i have a waifu and kids']; + break; + case 'satori satori satori satori satori satori satori': + $satoriResp = ['okay i was kidding about the kids part']; + break; + case 'satori satori satori satori satori satori satori satori': + $satoriResp = ['rip life']; + break; + case 'you are annoying': + case 'please die': + case 'die': + $satoriResp = ['Well I\'m God and you can\'t do shit.']; + break; + case 'misaka-20001': + $satoriResp = ['We\'ll have to move one of these days...', 'The good ol\' Pentium 4 doesn\'t seem to be able to handle shit anymore...']; + break; + case 'how old are you': + case 'how old is flashii': + case 'how old is koishi': + $satoriResp = [date_diff(date_create('2013-01-27 22:14:44 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')]; + break; + case 'how old is zeniea': + case 'how old is secret': + $satoriResp = [date_diff(date_create('2011-07-07 00:00:00 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')]; + break; + case 'how old is zquest': + $satoriResp = [date_diff(date_create('2013-11-16 00:00:00 UTC'), date_create(date('Y-m-d H:i:s e')))->format('%y year(s), %m month(s), %d day(s), %H hour(s), %i minute(s) and %s second(s)')]; + break; + case 'are you broken': + case 'are you broken?': + case 'is flashii broken': + case 'is flashii broken?': + $satoriResp = ['yes']; + break; + default: + $satoriResp = [$defaultResponse]; + break; + } +} + + +// Check if disabled +if(!$satoriSetting['enabled']) + $satoriResp = null; + + +// Bring the process of sending a message down to one if +if(isset($satoriResp)) { + foreach($satoriResp as $directives => $response) { + if($response == '[s]Trigger Kick') { + $this->logout('Kicked'); + } else { + $this->insertCustomMessage( + $satoriSetting['userID'], + $satoriSetting['userName'], + $satoriSetting['userRank'], + $this->getChannel(), + vsprintf($response, $directives), + $satoriSetting['userIP'], + 0 + ); + } + } +} diff --git a/public/lib/classes.php b/public/lib/classes.php new file mode 100644 index 0000000..9648fa5 --- /dev/null +++ b/public/lib/classes.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/public/lib/config.php b/public/lib/config.php new file mode 100644 index 0000000..b953b3b --- /dev/null +++ b/public/lib/config.php @@ -0,0 +1,225 @@ +'English'); + +// Available styles: +$config['styleAvailable'] = array('Mio', 'Legacy', 'Blue', 'Black', 'Nico', 'Halext', 'White', 'Terminal'); +// Default style: +$config['styleDefault'] = 'Black'; + +// The encoding used for the XHTML content: +$config['contentEncoding'] = 'UTF-8'; +// The encoding of the data source, like userNames and channelNames: +$config['sourceEncoding'] = 'UTF-8'; +// The content-type of the XHTML page (e.g. "text/html", will be set dependent on browser capabilities if set to null): +$config['contentType'] = null; + +// Session name used to identify the session cookie: +$config['sessionName'] = 'fii_chat'; +// Prefix added to every session key: +$config['sessionKeyPrefix'] = 'fii_chat'; +// The lifetime of the language, style and setting cookies in days: +$config['sessionCookieLifeTime'] = 365; +// The path of the cookies, '/' allows to read the cookies from all directories: +$config['sessionCookiePath'] = '/'; +// The domain of the cookies, defaults to the hostname of the server if set to null: +$config['sessionCookieDomain'] = null; +// If enabled, cookies must be sent over secure (SSL/TLS encrypted) connections: +$config['sessionCookieSecure'] = null; + +// Default channelName used together with the defaultChannelID if no channel with this ID exists: +$config['defaultChannelName'] = 'Public'; +// ChannelID used when no channel is given: +$config['defaultChannelID'] = 0; +// Defines an array of channelIDs (e.g. array(0, 1)) to limit the number of available channels, will be ignored if set to null: +$config['limitChannelList'] = null; + +// UserID plus this value are private channels (this is also the max userID and max channelID): +$config['privateChannelDiff'] = 500000000; +// UserID plus this value are used for private messages: +$config['privateMessageDiff'] = 1000000000; + +// Enable/Disable private Channels: +$config['allowPrivateChannels'] = true; +// Enable/Disable private Messages: +$config['allowPrivateMessages'] = true; + +// Private channels should be distinguished by either a prefix or a suffix or both (no whitespace): +$config['privateChannelPrefix'] = '['; +// Private channels should be distinguished by either a prefix or a suffix or both (no whitespace): +$config['privateChannelSuffix'] = ']'; + +// If enabled, users will be logged in automatically as guest users (if allowed), if not authenticated: +$config['forceAutoLogin'] = false; + +// Defines if login/logout and channel enter/leave are displayed: +$config['showChannelMessages'] = true; + +// If enabled, the chat will only be accessible for the admin: +$config['chatClosed'] = false; +// Defines the timezone offset in seconds (-12*60*60 to 12*60*60) - if null, the server timezone is used: +$config['timeZoneOffset'] = null; +// Defines the hour of the day the chat is opened (0 - closingHour): +$config['openingHour'] = 0; +// Defines the hour of the day the chat is closed (openingHour - 24): +$config['closingHour'] = 24; +// Defines the weekdays the chat is opened (0=Sunday to 6=Saturday): +$config['openingWeekDays'] = array(0,1,2,3,4,5,6); + +// Enable/Disable guest logins: +$config['allowGuestLogins'] = false; +// Enable/Disable write access for guest users - if disabled, guest users may not write messages: +$config['allowGuestWrite'] = false; +// Allow/Disallow guest users to choose their own userName: +$config['allowGuestUserName'] = false; +// Guest users should be distinguished by either a prefix or a suffix or both (no whitespace): +$config['guestUserPrefix'] = '['; +// Guest users should be distinguished by either a prefix or a suffix or both (no whitespace): +$config['guestUserSuffix'] = ']'; +// Guest userIDs may not be lower than this value (and not higher than privateChannelDiff): +$config['minGuestUserID'] = 400000000; + +// Allow/Disallow users to change their userName (Nickname): +$config['allowNickChange'] = true; +// Changed userNames should be distinguished by either a prefix or a suffix or both (no whitespace): +$config['changedNickPrefix'] = '~'; +// Changed userNames should be distinguished by either a prefix or a suffix or both (no whitespace): +$config['changedNickSuffix'] = ''; + +// Allow/Disallow registered users to delete their own messages: +$config['allowUserMessageDelete'] = false; + +// The userID used for Koishi messages: +$config['chatBotID'] = 2147483647; +// The userName used for Koishi messages +$config['chatBotName'] = 'Hanyuu'; +// The userID used for Satori messages: +$config['satoriID'] = 2147483646; +// The userName used for Satori messages +$config['satoriName'] = 'Satori'; +// The userID used for Dokuro messages: +$config['dokuroID'] = 2147483647; +// The userName used for Dokuro messages +$config['dokuroName'] = 'Dokuro'; +// The userID used for Koishi messages: +$config['koishiID'] = 2147483647; +// The userName used for Koishi messages +$config['koishiName'] = 'Koishi'; +// The userID used for Railgun messages: +$config['railgunID'] = 2147483646; +// The userName used for Railgun messages +$config['railgunName'] = 'Railgun'; +// The userID used for Snailmush messages: +$config['snailID'] = 2147483646; +// The userName used for Snailmush messages +$config['snailName'] = 'Koishi'; + +// Minutes until a user is declared inactive (last status update) - the minimum is 2 minutes: +$config['inactiveTimeout'] = 2; +// Interval in minutes to check for inactive users: +$config['inactiveCheckInterval'] = 3; + +// Defines if messages are shown which have been sent before the user entered the channel: +$config['requestMessagesPriorChannelEnter'] = true; +// Defines an array of channelIDs (e.g. array(0, 1)) for which the previous setting is always true (will be ignored if set to null): +$config['requestMessagesPriorChannelEnterList'] = null; +// Max time difference in hours for messages to display on each request: +$config['requestMessagesTimeDiff'] = 24; +// Max number of messages to display on each request: +$config['requestMessagesLimit'] = 10; + +// Max users in chat (does not affect moderators or admins): +$config['maxUsersLoggedIn'] = 100; +// Max userName length: +$config['userNameMaxLength'] = 30; +// Max messageText length: +$config['messageTextMaxLength'] = 2000; +// Defines the max number of messages a user may send per minute: +$config['maxMessageRate'] = 20; + +// Defines the default time in minutes a user gets banned if kicked from a moderator without ban minutes parameter: +$config['defaultBanTime'] = 10; + +// Argument that is given to the handleLogout JavaScript method: +$config['logoutData'] = './'; + +// If true, checks if the user IP is the same when logged in: +$config['ipCheck'] = false; + +// Defines the max time difference in hours for logs when no period or search condition is given: +$config['logsRequestMessagesTimeDiff'] = 1; +// Defines how many logs are returned on each logs request: +$config['logsRequestMessagesLimit'] = 10; + +// Defines the earliest year used for the logs selection: +$config['logsFirstYear'] = 2013; + +// Defines if old messages are purged from the database: +$config['logsPurgeLogs'] = false; +// Max time difference in days for old messages before they are purged from the database: +$config['logsPurgeTimeDiff'] = 1; + +// Defines if registered users (including moderators) have access to the logs (admins are always granted access): +$config['logsUserAccess'] = false; +// Defines a list of channels (e.g. array(0, 1)) to limit the logs access for registered users, includes all channels the user has access to if set to null: +$config['logsUserAccessChannelList'] = null; + +// Defines if the socket server is enabled: +$config['socketServerEnabled'] = false; +// Defines the hostname of the socket server used to connect from client side (the server hostname is used if set to null): +$config['socketServerHost'] = null; +// Defines the IP of the socket server used to connect from server side to broadcast update messages: +$config['socketServerIP'] = '127.0.0.1'; +// Defines the port of the socket server: +$config['socketServerPort'] = 1935; +// This ID can be used to distinguish between different chat installations using the same socket server: +$config['socketServerChatID'] = 69; diff --git a/public/lib/custom.php b/public/lib/custom.php new file mode 100644 index 0000000..1809bc2 --- /dev/null +++ b/public/lib/custom.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/public/lib/lang/en.php b/public/lib/lang/en.php new file mode 100644 index 0000000..7694360 --- /dev/null +++ b/public/lib/lang/en.php @@ -0,0 +1,120 @@ + + + + + + [LANG]title[/LANG] // Banned + + + [STYLE_SHEETS/] + + + + + + + + + +
    +
    +

    [LANG]title[/LANG] // Banned

    +
    +
    +
    Your IP is banned from accessing this Chat.
    +
    + + +
    + + \ No newline at end of file diff --git a/public/lib/template/legacyLogin.html b/public/lib/template/legacyLogin.html new file mode 100644 index 0000000..94569ac --- /dev/null +++ b/public/lib/template/legacyLogin.html @@ -0,0 +1,170 @@ + + + + + + + [LANG]title[/LANG] + + + [STYLE_SHEETS/] + + + + + + + + + +
    +
    +

    [LANG]title[/LANG]

    +
    +
    +
    + + +

    +
    +

    +
    +

    +
    +

    +
    +
    +
    * [LANG]registeredUsers[/LANG]
    +
    +
    +
    [ERROR_MESSAGES/]
    + + +
    + + + \ No newline at end of file diff --git a/public/lib/template/loggedIn.html b/public/lib/template/loggedIn.html new file mode 100644 index 0000000..c249489 --- /dev/null +++ b/public/lib/template/loggedIn.html @@ -0,0 +1,393 @@ + + + + + + + + + + + [LANG]title[/LANG] + + [STYLE_SHEETS/] + + + + + + + + + + +
    +
    +

    [LANG]titleinchat[/LANG]

    +
    +
    + + + + + + + + +
    +
    + +
    +
    + +
    +
    + 0/[MESSAGE_TEXT_MAX_LENGTH/] + +
    +
    +
    + + + + + + + + +
    + +
    + + + + + +
    +
    +

    [LANG]onlineUsers[/LANG]

    +
    +
    + + + + +
    +
    + + diff --git a/public/lib/template/loggedOut.html b/public/lib/template/loggedOut.html new file mode 100644 index 0000000..b7e49f9 --- /dev/null +++ b/public/lib/template/loggedOut.html @@ -0,0 +1,72 @@ + + + + + +Flashii - Chat + + + + + + + + + +
    +
    [ERROR_MESSAGES/]
    +
    +
    +

    [LANG]title[/LANG] Login

    +
    + + + + + + + +
    [SANDSTORM/]
    +
    +
    +
    + +[COPYRIGHT/] + + \ No newline at end of file diff --git a/public/lib/template/loggedOutFA.html b/public/lib/template/loggedOutFA.html new file mode 100644 index 0000000..8560bd8 --- /dev/null +++ b/public/lib/template/loggedOutFA.html @@ -0,0 +1,70 @@ + + + + + +Flashii - Chat + + + + + + + + + +
    +
    +
    [ERROR_MESSAGES/]
    +
    +

    [LANG]title[/LANG] Login

    +
    + + + + + + +

    +
    +
    +
    + +[COPYRIGHT/] + + \ No newline at end of file diff --git a/public/lib/template/loggedOut~.html b/public/lib/template/loggedOut~.html new file mode 100644 index 0000000..b08a0f0 --- /dev/null +++ b/public/lib/template/loggedOut~.html @@ -0,0 +1,61 @@ + + + + + + + [LANG]title[/LANG] + + + + + + + + + +
    +
    +

    [LANG]title[/LANG]

    +
    + [ERROR_MESSAGES/] + +
    +
    + + + + + + +
    + +
    +
    + + \ No newline at end of file diff --git a/public/lib/template/logs.html b/public/lib/template/logs.html new file mode 100644 index 0000000..446318a --- /dev/null +++ b/public/lib/template/logs.html @@ -0,0 +1,284 @@ + + + + + + + [LANG]logsTitle[/LANG] + + [STYLE_SHEETS/] + + + + + + + + + + + +
    +
    +

    [LANG]logsTitle[/LANG]

    +
    +
    + + + + + + + + + + + + + + +
    + +
    +
    + +
    +
    + +
    +
    + + + +
    + + + +
    +
    + + \ No newline at end of file diff --git a/public/lib/template/mobile.html b/public/lib/template/mobile.html new file mode 100644 index 0000000..4c0b1de --- /dev/null +++ b/public/lib/template/mobile.html @@ -0,0 +1,196 @@ + + + + + + + [LANG]title[/LANG] + + + + + + + + + + + + + +
    +
    +

    + [LANG]title[/LANG] + + +

    +
    + + +
    +
    + +
    +
    + + + + + + + + + +
    + +
    + + + +
    + + +
    +
    + + \ No newline at end of file diff --git a/public/lib/template/shoutbox.html b/public/lib/template/shoutbox.html new file mode 100644 index 0000000..5470d48 --- /dev/null +++ b/public/lib/template/shoutbox.html @@ -0,0 +1,61 @@ +
    + + + + + + + +
    +
    + +
    + + + +
    +
    \ No newline at end of file diff --git a/public/lib/template/~loggedOut.html b/public/lib/template/~loggedOut.html new file mode 100644 index 0000000..2605f4a --- /dev/null +++ b/public/lib/template/~loggedOut.html @@ -0,0 +1,82 @@ + + + + + + + [LANG]title[/LANG] + + + [STYLE_SHEETS/] + + + + + + + + + + +
    +
    +

    [LANG]title[/LANG]

    +
    +
    +
    +
    Welcome to Flashii Chat! Please register if you haven't yet.
    + + +

    +
    +

    +
    +

    +
    +

    +
    +
    +
    * [LANG]registeredUsers[/LANG]
    +
    +
    +
    [ERROR_MESSAGES/]
    + + +
    + + + \ No newline at end of file diff --git a/public/sandstorm.mp3 b/public/sandstorm.mp3 new file mode 100644 index 0000000..861c4cd Binary files /dev/null and b/public/sandstorm.mp3 differ diff --git a/public/sandstorm.ogg b/public/sandstorm.ogg new file mode 100644 index 0000000..969c3c4 Binary files /dev/null and b/public/sandstorm.ogg differ diff --git a/public/sounds/ajax_chatbot.mp3 b/public/sounds/ajax_chatbot.mp3 new file mode 100644 index 0000000..0d5a5f2 Binary files /dev/null and b/public/sounds/ajax_chatbot.mp3 differ diff --git a/public/sounds/ajax_chatbot.ogg b/public/sounds/ajax_chatbot.ogg new file mode 100644 index 0000000..5517fb1 Binary files /dev/null and b/public/sounds/ajax_chatbot.ogg differ diff --git a/public/sounds/ajax_error.mp3 b/public/sounds/ajax_error.mp3 new file mode 100644 index 0000000..2a333c0 Binary files /dev/null and b/public/sounds/ajax_error.mp3 differ diff --git a/public/sounds/ajax_error.ogg b/public/sounds/ajax_error.ogg new file mode 100644 index 0000000..338c532 Binary files /dev/null and b/public/sounds/ajax_error.ogg differ diff --git a/public/sounds/ajax_incoming.mp3 b/public/sounds/ajax_incoming.mp3 new file mode 100644 index 0000000..f9526e1 Binary files /dev/null and b/public/sounds/ajax_incoming.mp3 differ diff --git a/public/sounds/ajax_incoming.ogg b/public/sounds/ajax_incoming.ogg new file mode 100644 index 0000000..32d439d Binary files /dev/null and b/public/sounds/ajax_incoming.ogg differ diff --git a/public/sounds/ajax_login.mp3 b/public/sounds/ajax_login.mp3 new file mode 100644 index 0000000..1c76577 Binary files /dev/null and b/public/sounds/ajax_login.mp3 differ diff --git a/public/sounds/ajax_login.ogg b/public/sounds/ajax_login.ogg new file mode 100644 index 0000000..3fe2411 Binary files /dev/null and b/public/sounds/ajax_login.ogg differ diff --git a/public/sounds/ajax_logout.mp3 b/public/sounds/ajax_logout.mp3 new file mode 100644 index 0000000..d2f66ba Binary files /dev/null and b/public/sounds/ajax_logout.mp3 differ diff --git a/public/sounds/ajax_logout.ogg b/public/sounds/ajax_logout.ogg new file mode 100644 index 0000000..21c31a0 Binary files /dev/null and b/public/sounds/ajax_logout.ogg differ diff --git a/public/sounds/ajax_outgoing.mp3 b/public/sounds/ajax_outgoing.mp3 new file mode 100644 index 0000000..73bdcd2 Binary files /dev/null and b/public/sounds/ajax_outgoing.mp3 differ diff --git a/public/sounds/ajax_outgoing.ogg b/public/sounds/ajax_outgoing.ogg new file mode 100644 index 0000000..bdbcfe7 Binary files /dev/null and b/public/sounds/ajax_outgoing.ogg differ diff --git a/public/sounds/ajax_shit.mp3 b/public/sounds/ajax_shit.mp3 new file mode 100644 index 0000000..7fecc60 Binary files /dev/null and b/public/sounds/ajax_shit.mp3 differ diff --git a/public/sounds/ajax_shit.ogg b/public/sounds/ajax_shit.ogg new file mode 100644 index 0000000..84136cf Binary files /dev/null and b/public/sounds/ajax_shit.ogg differ diff --git a/public/sounds/dicks.mp3 b/public/sounds/dicks.mp3 new file mode 100644 index 0000000..f423322 Binary files /dev/null and b/public/sounds/dicks.mp3 differ diff --git a/public/sounds/dicks.ogg b/public/sounds/dicks.ogg new file mode 100644 index 0000000..379fcfb Binary files /dev/null and b/public/sounds/dicks.ogg differ diff --git a/public/sounds/dokuro_pipiru.mp3 b/public/sounds/dokuro_pipiru.mp3 new file mode 100644 index 0000000..d096e56 Binary files /dev/null and b/public/sounds/dokuro_pipiru.mp3 differ diff --git a/public/sounds/dokuro_pipiru.ogg b/public/sounds/dokuro_pipiru.ogg new file mode 100644 index 0000000..05884e0 Binary files /dev/null and b/public/sounds/dokuro_pipiru.ogg differ diff --git a/public/sounds/xp_chatbot.mp3 b/public/sounds/xp_chatbot.mp3 new file mode 100644 index 0000000..73e80a5 Binary files /dev/null and b/public/sounds/xp_chatbot.mp3 differ diff --git a/public/sounds/xp_error.mp3 b/public/sounds/xp_error.mp3 new file mode 100644 index 0000000..c831170 Binary files /dev/null and b/public/sounds/xp_error.mp3 differ diff --git a/public/sounds/xp_incoming.mp3 b/public/sounds/xp_incoming.mp3 new file mode 100644 index 0000000..84fc1d4 Binary files /dev/null and b/public/sounds/xp_incoming.mp3 differ diff --git a/public/sounds/xp_login.mp3 b/public/sounds/xp_login.mp3 new file mode 100644 index 0000000..147edd5 Binary files /dev/null and b/public/sounds/xp_login.mp3 differ diff --git a/public/sounds/xp_logout.mp3 b/public/sounds/xp_logout.mp3 new file mode 100644 index 0000000..cf4ed0c Binary files /dev/null and b/public/sounds/xp_logout.mp3 differ diff --git a/public/sounds/xp_outgoing.mp3 b/public/sounds/xp_outgoing.mp3 new file mode 100644 index 0000000..68f1885 Binary files /dev/null and b/public/sounds/xp_outgoing.mp3 differ