pnopaste-1.6/0000755000175000017500000000000013002470345010773 5ustar memepnopaste-1.6/ChangeLog0000644000175000017500000000545213002470345012553 0ustar memeVersion 1.6: - Add update SQL to migrate the code field from text to mediumtext and per default install new databases with mediumtext to avoid truncation. Closes Debian Bug #827803 - Set default paste URL to 'https://nopaste.linux-dev.org/' (HTTPS enabled now). - Add the current working directory to @INC. With Debian Stretch it is removed from the default include path because of security reasons. - Do not set storage engine in sql script, so new databases are created with the default storage engine (e.g. InnoDB instead of the deprecated MyISAM). Version 1.5: - Fix potential Perl warning: Use of uninitialized value within %Syntax_Languages::Langs - Fix Perl warning if GeoIP does not return any country flag. - Bump version to 1.5. - Return english language instead of german one if GeoIP does not find any country. - Add patch from Harri Porten, to use the correct & in lib/HTML. - nopaste-it: some small cleanups. make use of STDERR, $/, corrected spacings and use of die - added a quite mode for nopaste-it which only prints url. can for example be used in shell scripts. - Expire: existance of hash elements is checked using exists() not defined() - Remove LIMITs at the end of UPDATE querys. It is not supported by Postgres. - nopaste-it: Rename script with extension. - Fix Perl warning "Use of uninitialized" in lib/Highlighting. - Add patch from Debian packaging to add Apache 2.4 compatibility. Version 1.4: - Fix typo in french translation. - Remove MySQL'ish "`" from Querys. - Change default user for running the cronjob from nobody to www-data. - Change my email address and adjust the copyright years. - Minor code cleanups. - Dont print warnings if the remote address or the URL base could not be initialized. This happens e.g. if you execute index.pl about your shell. Version 1.3: - Fix warning from Perl if the code view parameter does not only contain integers, triggered by int(). - Implemented a translation system, which will translate the application to the users language. The users language is automatic detected by Geo::IP. - Add german translation. - Add francaise translation from Denis Briand. Version 1.2: - Fix error in MySQL scheme. - Update copyrights. - Some code cleanups. - Use "use"-statements instead of the unsafe require. Version 1.1: - Skin support. - Switch to XHTML. - Fix security issue where a attacker may include input to the "language" field in the nopaste table. - Display "Download" and "New" on a nopaste output page. - Some Perl warnings fixes. - Split out the highlighting css to highlight/. - Workaround a line ending bug in Syntax::HL::Kate. - Add cli tool bin/nopaste-it for nopasting things from the shell. - And also his manpage. - Add settings table. - Increase $CGI::POST_MAX by *= 8. - Some code cleanups. - Fix some typos. Version 1.0: - Initial release. pnopaste-1.6/COPYING0000644000175000017500000004313113002470345012030 0ustar meme GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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. 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 convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. pnopaste-1.6/templates/0000755000175000017500000000000013002470345012771 5ustar memepnopaste-1.6/templates/.htaccess0000644000175000017500000000016413002470345014570 0ustar meme= 2.3> Require all denied Order deny,allow deny from all pnopaste-1.6/templates/header.tmpl0000644000175000017500000000053313002470345015120 0ustar meme #TITLE#
Perl Nopaste Service
pnopaste-1.6/templates/list_table_author.tmpl0000644000175000017500000000047413002470345017400 0ustar meme

#LANG23# #DOWNLOAD# #LANG24# #ADD_NEW#

#LANG25# #TIME#

#LANG26# #EXPIRES#

#LANG27# #AUTHOR#

#LANG28# #LANGUAGE#

pnopaste-1.6/templates/list_confirm.tmpl0000644000175000017500000000050613002470345016360 0ustar meme

#LANG15#
#LANG16# #LINKCODE#.

#LANG17# #LINKCODE##lineX #LANG18# X #LANG19#
#LANG20# #LINKCODE#&download.

#LANG21# #LANG22#.

pnopaste-1.6/templates/list_addform.tmpl0000644000175000017500000000157713002470345016350 0ustar meme

pnopaste-1.6/templates/list_table_desc.tmpl0000644000175000017500000000031613002470345017007 0ustar meme

#LANG12# #DESCRIPTION#

#LANG13#

#LINENUMBERS#
pnopaste-1.6/templates/list_table_code.tmpl0000644000175000017500000000012313002470345016777 0ustar meme
#CODETEXT#
pnopaste-1.6/templates/footer.tmpl0000644000175000017500000000035113002470345015164 0ustar meme pnopaste-1.6/skins/0000755000175000017500000000000013002470345012122 5ustar memepnopaste-1.6/skins/highlight/0000755000175000017500000000000013002470345014071 5ustar memepnopaste-1.6/skins/highlight/engine.css0000644000175000017500000000137713002470345016060 0ustar meme.hl_Alert { color: #00f; } .hl_BaseN { color: #007f00; } .hl_BString { color: #c9a7ff; } .hl_Char { color: #f0f; } .hl_Comment { color: #7f7f7f; font-style: italic; } .hl_DataType { color: #00f; } .hl_DecVal { color: #00007f; } .hl_Error { color: #f00; font-weight: bold; font-style: italic; } .hl_Float { color: #00007f; } .hl_Function { color: #007f00; } .hl_IString { color: #f00; } .hl_Keyword { font-weight: bold; } .hl_Operator { color: #ffa500; } .hl_Others { color: #b03060; } .hl_RegionMarker { color: #96b9ff; font-style: italic; } .hl_Reserved { color: #9b30ff; font-weight: bold; } .hl_String { color: #f00; } .hl_Variable { color: #00f; font-weight: bold; } .hl_Warning { color: #00f; font-weight: bold; font-style: italic; } pnopaste-1.6/skins/default.css0000644000175000017500000000360113002470345014260 0ustar meme@import url(highlight/engine.css); /*** Common ***/ #heading, #footer { text-align: center; } #heading { font-weight: bold; font-size: 1.5em; margin-bottom: 1em; } #footer { margin-top: 2em; } #footer p#rendertime, #footer p#copyright { margin: 0; padding: 0; } #footer p#rendertime { font-style: italic; } /* Border stuff */ #display_paste #options, #display_paste #time, #display_paste #expires, #display_paste #from, #display_paste #language, #display_paste #description, #add_paste .settings, #add_paste .description, #add_paste .code, #add_paste .submit { border: 1px solid black; border-bottom: none; margin: 0; padding: 0.3em 0.5em; } #display_paste #expires { border-top: none; } #display_paste #description, #add_paste .submit { border-bottom: 1px solid black; } /*** Add a paste page ***/ label { display: block; } textarea { width: 100%; } textarea#description { height: 3.5em; } textarea#code { height: 20.5em; } .submit input { width: 100%; } /*** Confirmation page ***/ #confirmation { border: 1px solid black; } #confirmation p { margin: 1em; } /*** Display a paste page ***/ /* The description itself should go to a new line */ #display_paste .description { display: block; } #display_paste #code { margin-bottom: 0; } #display_paste table#codetable { border-collapse: collapse; } #display_paste table#codetable td { border: 1px solid black; } #display_paste td#linenumbers pre, #display_paste td#codetext pre { margin: 0; padding: 0; } #display_paste td#linenumbers { text-align: right; padding: 0 0.5em 0 0.1em; } #display_paste td#codetext { background: white; /* Don't ask me why this works */ width: 999999em; } /* Crap */ body, p#code, p#copyright, p#rendertime { background-color: #c0c0c0; } td#linenumbers, p, div#confirmation { background-color: #c0c0c0; } /* a:link, a:visited, a:active { color: #000000; text-decoration: underline; } */ pnopaste-1.6/skins/lightblue.css0000644000175000017500000000357613002470345014626 0ustar meme@import url(highlight/engine.css); /*** Common ***/ #heading, #footer { text-align: center; } #heading { font-weight: bold; font-size: 1.5em; margin-bottom: 1em; } #footer { margin-top: 2em; } #footer p#rendertime, #footer p#copyright { margin: 0; padding: 0; } #footer p#rendertime { font-style: italic; } /* Border stuff */ #display_paste #options, #display_paste #time, #display_paste #expires, #display_paste #from, #display_paste #language, #display_paste #description, #add_paste .settings, #add_paste .description, #add_paste .code, #add_paste .submit { border: 1px solid black; border-bottom: none; margin: 0; padding: 0.3em 0.5em; } #display_paste #expires { border-top: none; } #display_paste #description, #add_paste .submit { border-bottom: 1px solid black; } /*** Add a paste page ***/ label { display: block; } textarea { width: 100%; } textarea#description { height: 3.5em; } textarea#code { height: 20.5em; } .submit input { width: 100%; } /*** Confirmation page ***/ #confirmation { border: 1px solid black; } #confirmation p { margin: 1em; } /*** Display a paste page ***/ /* The description itself should go to a new line */ #display_paste .description { display: block; } #display_paste #code { margin-bottom: 0; } #display_paste table#codetable { border-collapse: collapse; } #display_paste table#codetable td { border: 1px solid black; } #display_paste td#linenumbers pre, #display_paste td#codetext pre { margin: 0; padding: 0; } #display_paste td#linenumbers { text-align: right; padding: 0 0.5em 0 0.1em; } #display_paste td#codetext { background: white; /* Don't ask me why this works */ width: 999999em; } /* Crap */ body, p#code, p#copyright, p#rendertime { background-color: #aad4ff; } td#linenumbers, p, div#confirmation { background-color: #def; } /* a:link, a:visited, a:active { color: #000000; text-decoration: underline; } */ pnopaste-1.6/TODO0000644000175000017500000000013513002470345011462 0ustar memeTODO List ========= 1.5: - Add a configuration file for nopaste-it with predefined values. pnopaste-1.6/conf/0000755000175000017500000000000013002470345011720 5ustar memepnopaste-1.6/conf/SQL_Access.pm0000644000175000017500000000041313002470345014174 0ustar memepackage SQL_Access; use warnings; use strict; # DBI driver (we only support officaly mysql at the moment!). our $Driver = 'mysql'; # SQL Access. our $Hostname = 'localhost'; our $Database = 'pnopaste'; our $Username = 'pnopaste'; our $Password = 'INSERT_PW'; 1; pnopaste-1.6/conf/.htaccess0000644000175000017500000000016413002470345013517 0ustar meme= 2.3> Require all denied Order deny,allow deny from all pnopaste-1.6/conf/Syntax_Languages.pm0000644000175000017500000000525513002470345015541 0ustar memepackage Syntax_Languages; use warnings; use strict; # Standard selected language. our $Selected = 'Plain'; ### Hash of all available languages. our %Langs = ( # Language name # (De)activated? '.desktop' => 0, '4GL' => 0, '4GL-PER' => 0, 'ABC' => 0, 'AHDL' => 0, 'ANSI C89' => 0, 'ASP' => 1, 'AVR Assembler' => 0, 'AWK' => 1, 'Ada' => 0, 'Ansys' => 0, 'Apache Configuration' => 0, 'Asm6502' => 0, 'Bash' => 1, 'BibTeX' => 0, 'C' => 1, 'C#' => 1, 'C++' => 1, 'CGiS' => 0, 'CMake' => 0, 'CSS' => 1, 'CUE Sheet' => 0, 'Cg' => 0, 'ChangeLog' => 0, 'Cisco' => 0, 'Clipper' => 0, 'ColdFusion' => 0, 'Common Lisp' => 0, 'Component-Pascal' => 0, 'D' => 1, 'Debian Changelog' => 0, 'Debian Control' => 0, 'Diff' => 1, 'Doxygen' => 1, 'E Language' => 0, 'Eiffel' => 0, 'Email' => 0, 'Euphoria' => 0, 'Fortran' => 0, 'FreeBASIC' => 0, 'GDL' => 0, 'GLSL' => 0, 'GNU Assembler' => 0, 'GNU Gettext' => 0, 'HTML' => 1, 'Haskell' => 0, 'IDL' => 0, 'ILERPG' => 0, 'INI Files' => 1, 'Inform' => 0, 'Intel x86 (NASM)' => 0, 'JSP' => 1, 'Java' => 1, 'JavaScript' => 1, 'Javadoc' => 0, 'KBasic' => 0, 'Kate File Template' => 0, 'LDIF' => 0, 'LPC' => 0, 'LaTeX' => 1, 'Lex/Flex' => 0, 'LilyPond' => 0, 'Literate Haskell' => 0, 'Lua' => 1, 'M3U' => 0, 'MAB-DB' => 0, 'MIPS Assembler' => 0, 'Makefile' => 1, 'Mason' => 0, 'Matlab' => 0, 'Modula-2' => 0, 'Music Publisher' => 0, 'Octave' => 0, 'Plain' => 1, 'PHP (HTML)' => 1, 'POV-Ray' => 0, 'Pascal' => 0, 'Perl' => 1, 'PicAsm' => 0, 'Pike' => 0, 'PostScript' => 0, 'Prolog' => 0, 'PureBasic' => 0, 'Python' => 1, 'Quake Script' => 0, 'R Script' => 0, 'REXX' => 0, 'RPM Spec' => 0, 'RSI IDL' => 0, 'RenderMan RIB' => 0, 'Ruby' => 1, 'SGML' => 0, 'SML' => 0, 'SQL' => 1, 'SQL (MySQL)' => 1, 'SQL (PostgreSQL)' => 1, 'Sather' => 0, 'Scheme' => 0, 'Sieve' => 0, 'Spice' => 0, 'Stata' => 0, 'TI Basic' => 0, 'TaskJuggler' => 0, 'Tcl/Tk' => 1, 'UnrealScript' => 0, 'VHDL' => 0, 'VRML' => 0, 'Velocity' => 0, 'Verilog' => 0, 'WINE Config' => 0, 'Wikimedia' => 0, 'XML' => 1, 'XML (Debug)' => 0, 'Yacc/Bison' => 0, 'de_DE' => 0, 'en_EN' => 0, 'ferite' => 0, 'nl' => 0, 'progress' => 0, 'scilab' => 0, 'txt2tags' => 0, 'x.org Configuration' => 0, 'xHarbour' => 0, 'xslt' => 0, 'yacas' => 0 ); 1; pnopaste-1.6/bin/0000755000175000017500000000000013002470345011543 5ustar memepnopaste-1.6/bin/expired_delete.pl0000755000175000017500000000114013002470345015061 0ustar meme#!/usr/bin/perl # This file is part of the pnopaste program # Copyright (C) 2008-2016 Patrick Matthäi # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. use warnings; use strict; # Distribution mode. Just uncomment the following lines # if you are a packager! #use FindBin qw($Bin); #BEGIN { # push(@INC, $Bin . '/../'); #} use lib::Expire; Expire::Delete_Old_Entrys(); exit(0); pnopaste-1.6/bin/cronjob.example0000644000175000017500000000022413002470345014552 0ustar meme*/30 * * * * www-data if [ -f /var/www/pnopaste/bin/expired_delete.pl ]; then /usr/bin/perl /var/www/pnopaste/bin/expired_delete.pl > /dev/null; fi pnopaste-1.6/bin/nopaste-it0000755000175000017500000001022013002470345013547 0ustar meme#!/usr/bin/perl # This file is part of the pnopaste program # Copyright (C) 2008-2016 Patrick Matthäi # Copyright (C) 2010 Philipp Schafft # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. use warnings; use strict; use Getopt::Long; use LWP::Simple; use LWP::UserAgent; use HTTP::Request::Common qw(POST); my $Build = '1.6'; my $NoPaste = 'https://nopaste.linux-dev.org/'; my $Lang = 'Plain'; my $Name = $ENV{'USER'} || undef; my $Expires = '1w'; my $Version = undef; my $File = undef; my $Help = undef; my $List = undef; my $Input = ''; my $Quite = undef; # Get our params. Getopt::Long::Configure('bundling'); GetOptions ( 's|list' => \$List, 'h|help' => \$Help, 'u|url=s' => \$NoPaste, 'n|name=s' => \$Name, 'l|language=s' => \$Lang, 'e|expires=s' => \$Expires, 'f|file=s' => \$File, 'v|version' => \$Version, 'q|quite' => \$Quite, ); # Show the version. if($Version){ print <: Use a different nopaste URL than $NoPaste. -n / --name: Use a different author name than your UNIX username (if it is set). -l / --language : Set the given code language. Popular ones are for example: "C", "C++", "Diff", "Perl", "Ruby", etc. You can get the list of supported languages by using the "-s/--list" option of this program. It will be plain unless nothing different is set. Note: This is case sensitive. -e / --expires : Set the expire option. At the moment it only accepts: "1d", "1w" and "never". The default value is "1w". -f / --file : Add the content of the given file to your paste instead of reading from STDIN. -s / --list: Gets supported code languages from remote pnopaste and prints them. This option could also be mixed with "url". EOF exit(0); } # Check the given expire time. if($Expires ne '1d' and $Expires ne '1w' and $Expires ne 'never'){ print STDERR "Invalid expiration code given.\n"; exit(1); } ### Gets languages and exit. if($List){ my $Site = get($NoPaste); die 'Did not found any output.', "\n" if !$Site; my($Select) = ($Site =~ m!]+name="language"[^>]*>(.*?)!s); my $Values = ''; while($Select =~ s!]*>(.*?)!!s){ $Values .= "\t" . $1 . "\n"; } print 'Supported languages by remote pnopaste:', "\n", $Values; exit(0); } # Read from STDIN or file? if(!$File){ # We just get our stuff from STDIN. local $/ = undef; $Input = ; } else { if(!-e $File){ # Epic fail! This file does not exist! print STDERR 'Error. File ', $File, ' does not exist.', "\n"; exit(1); } # Open the file and try to read from it. open(READ,'<',$File) or die 'Can not read input file: ', $!, "\n"; while(){ $Input .= $_; } close(READ); } my $Agent = LWP::UserAgent->new; # Our name ;) $Agent->agent('Perl Nopaste Agent ' . $Build); # Our HTTP request with POST params. my $Request = POST $NoPaste, [ 'code' => $Input, 'expires' => $Expires, 'name' => $Name, 'language' => $Lang ]; my $Result = $Agent->request($Request); if($Result->is_success){ # The query itself was successful. my $Content = $Result->content; $Content =~ m//; my $ID = $1; if($ID and $ID =~ /\d+/){ # $ID is an integer, so on it has to be right. if ( !$Quite ) { print 'You can find your result on: ', "\n"; print "\t", $ID, "\n"; print "\t", $ID, '&download', "\n"; } else { print $ID, "\n"; } } else { # Where the fuck is the fucking integer? print STDERR 'Seems like there was an error on the server side. The full server output is:', "\n"; print STDERR $Result->content; } } else { # Epic fail at the query, just fuck up.. print STDERR 'Error: ', $Result->status_line, "\n"; exit(1); } pnopaste-1.6/man/0000755000175000017500000000000013002470345011546 5ustar memepnopaste-1.6/man/nopaste-it.10000644000175000017500000000327713002470345013724 0ustar meme.TH "NOPASTE-IT" "1" .SH "NAME" nopaste\-it \- Nopaste software written in Perl (cli tool). .SH "SYNOPSIS" \fBnopaste\-it\fR .SH "DESCRIPTION" This manual page describes briefly the \fBnopaste\-it\fR commandline parameters. .SH "BINARY PARAMETERS" This program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. .TP .B \-h, \-\-help Display this help and exit. .TP .B \-v, \-\-version Display version and exit. .TP .B \-q, \-\-quite Be more quite. Only print URL of post. .TP .B \-u, \-\-url Use a different nopaste URL than http://nopaste.linux\-dev.org/. .TP .B \-n, \-\-name Use a different author name than your UNIX username (if it is set). .TP .B \-l, \-\-language Set the given code language. Popular ones are for example: "C", "C++", "Diff", "Perl", "Ruby", etc. You can get the list of supported languages by using the "\-s / \-\-list" option of this program. It will be plain unless nothing different is set. Note: This is case sensitive. .TP .B \-e, \-\-expires Set the expire option. At the moment it only accepts: "1d", "1w" and "never". The default value is "1w". .TP .B \-f, \-\-file Add the content of the given file to your paste instead of reading from STDIN. .TP .B \-s, \-\-list Gets supported code languages from remote pnopaste and prints them. This option could also be mixed with "url". .SH "AUTHOR" This manual page was written by Patrick Matth\[:a]i for nopaste\-it. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation pnopaste-1.6/INSTALL0000644000175000017500000000331613002470345012027 0ustar memeINSTALL ======= Copy the whole project to your webserver DocumentRoot. MODULES ======= You need the DBD driver for DBI - this is available in every distribution as package. On Debian just type: # apt-get install libdbi-perl But you also need a rarely packaged module for syntax highlighting. In most cases you have to install it about CPAN. # perl -MCPAN -e shell % install Syntax::Highlight::Engine::Kate or if you are on an after Debian Lenny release: # apt-get install libsyntax-highlight-engine-kate-perl libwww-perl libgeo-ip-perl After that you should have everything for pnopaste! DATABASE ======== Create a new user and database for pnopaste at your MySQL server. Now import the "sql/mysql_5.sql" to the new database. CONFIGURATION ============= Now go to the "conf/" directory and insert your newly created user, password and databasename (maybe also host) into the SQL_Access.pm. WEBSERVER ========= I recommend (for example for Apache2) the following VirtualHost: ServerName nopaste.yourhost.com ServerAdmin im-the@serveradmin.com DocumentRoot /var/www/pnopaste AllowOverride all DirectoryIndex index.pl AddHandler cgi-script .pl Options Indexes ExecCGI Surely you could also use mod_perl instead of cgi. But you should make sure, that your webserver allows you to overwrite settings, if you don't allow it, evil users may read out your lib/Database.pm for example and damage you! That is the reason why I delivered some .htaccess files. :-) END === Now everything should be done and hopefully working fine! pnopaste-1.6/index.pl0000755000175000017500000000372013002470345012444 0ustar meme#!/usr/bin/perl # This file is part of the pnopaste program # Copyright (C) 2008-2016 Patrick Matthäi # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. use warnings; no warnings 'once'; use strict; use Cwd; use lib cwd; use CGI qw/:standard/; use lib::Code; use lib::HTML; use lib::Security; use lib::Highlighting; use lib::Expire; # CGI class. my $CGI = new CGI; # Security settings for the cgi module. $CGI::DISABLE_UPLOADS = 1; $CGI::POST_MAX = 83886080; # Start the application. Main(); ### Main function - it decides where we go. sub Main { my $Full_URL = $CGI->url(-full => 1); my $Remote_Addr = $CGI->remote_host(); if(!defined $Full_URL){ $Full_URL = 'none'; } if(!defined $Remote_Addr){ $Remote_Addr = 'none'; } # Block all banned IPs directly. if(Security::Blacklist_Host($Remote_Addr) == 1){ HTML::Error(2); } #Clean up database from expired entries. if(Expire::Get_Cleanup()){ Expire::Delete_Old_Entrys(); } # Get all GET parameters. my $Params = $CGI->url_param('keywords'); # Seems like someone wants a code. if($Params and $Params =~ /^\d/){ my $Download = 0; if($Params =~ /download$/){ $Download = 1; } $Params =~ s/^\D*?(\d+).*$/$1/; $Params = int($Params); HTML::Code($Params, $Download, $Full_URL); } # New code comes in. elsif($CGI->param('code')){ # Get POST parameters. my $Code = $CGI->param('code') || ''; my $Desc = $CGI->param('description') || ''; my $Name = $CGI->param('name') || ''; my $Expi = $CGI->param('expires') || $Expire::Standard; my $Synt = $CGI->param('language') || 'Plain'; Code::Add($Code, $Desc, $Name, $Expi, $Synt, $Remote_Addr, $Full_URL); } else { # Else just show the add page. HTML::Add($Full_URL); } } 1; pnopaste-1.6/sql/0000755000175000017500000000000013002470345011572 5ustar memepnopaste-1.6/sql/1.6.sql0000644000175000017500000000005413002470345012616 0ustar memeALTER TABLE nopaste MODIFY code MEDIUMTEXT; pnopaste-1.6/sql/mysql_5.sql0000644000175000017500000000216413002470345013707 0ustar memeCREATE TABLE `blacklist_ip` ( `id` int(11) NOT NULL auto_increment, `ip` varchar(15) NOT NULL, `hits` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `ip` (`ip`) ) ; CREATE TABLE `blacklist_word` ( `id` int(11) NOT NULL auto_increment, `word` varchar(250) NOT NULL, `hits` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `word` (`word`) ) ; CREATE TABLE `nopaste` ( `id` int(11) NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', `description` text NOT NULL, `code` mediumtext, `language` text NOT NULL, `time` int(15) NOT NULL default '0', `ip` varchar(20) NOT NULL, `expires` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `time` (`time`), KEY `expires` (`expires`) ) ; CREATE TABLE `settings` ( `username` VARCHAR(100) NOT NULL default 'admin', `password` VARCHAR(100) NOT NULL, `session` VARCHAR(100) NOT NULL, `expires` int(15) NOT NULL default '0', `cleanup` int(1) NOT NULL default '1', `title` VARCHAR(150) NOT NULL default 'Perl NoPaste Service', `style` VARCHAR(20) NOT NULL default 'default', `language` VARCHAR(2) NOT NULL default 'en' ) ; pnopaste-1.6/lib/0000755000175000017500000000000013002470345011541 5ustar memepnopaste-1.6/lib/.htaccess0000644000175000017500000000016413002470345013340 0ustar meme= 2.3> Require all denied Order deny,allow deny from all pnopaste-1.6/lib/Security.pm0000644000175000017500000000341413002470345013710 0ustar memepackage Security; # This file is part of the pnopaste program # Copyright (C) 2008-2016 Patrick Matthäi # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. use warnings; use strict; use lib::Database; use lib::Hits; ### Check if the IP is blacklisted. sub Blacklist_Host { my($IP) = @_; my $Query = 'SELECT id FROM blacklist_ip WHERE ip = ? LIMIT 1'; $Query = $Database::dbh->prepare($Query); $Query->execute($IP); my $List = $Query->fetchrow_hashref(); if($List->{'id'}){ Hits::Inc_Badhost($List->{'id'}); return 1; } # Not blacklisted. return 0; } ### Returns the bad Hosts as array. sub Get_Blacklist_Hosts { my $Query = 'SELECT ip FROM blacklist_ip ORDER by id'; $Query = $Database::dbh->prepare($Query); $Query->execute(); my @Result; while(my $List = $Query->fetchrow_hashref()){ push(@Result, $List->{'ip'}); } return @Result } ### Check codes for badwords. sub Blacklist_Words { my($Code) = @_; my $Query = 'SELECT id,word FROM blacklist_word'; $Query = $Database::dbh->prepare($Query); $Query->execute(); while(my $List = $Query->fetchrow_hashref()){ my $Match = $List->{'word'}; if($Code =~ /$Match/i){ Hits::Inc_Badword($List->{'id'}); # Blacklisted. return 1; } } # Nothing evil found. return 0; } ### Returns the badwords as array. sub Get_Blacklist_Words { my $Query = 'SELECT word FROM blacklist_word ORDER by id'; $Query = $Database::dbh->prepare($Query); $Query->execute(); my @Result; while(my $List = $Query->fetchrow_hashref()){ push(@Result, $List->{'word'}); } return @Result; } 1; pnopaste-1.6/lib/Highlighting.pm0000644000175000017500000000627613002470345014517 0ustar memepackage Highlighting; # This file is part of the pnopaste program # Copyright (C) 2008-2016 Patrick Matthäi # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. use warnings; no warnings 'once'; use strict; use Syntax::Highlight::Engine::Kate; use conf::Syntax_Languages; # Language object. my $Language = ''; ### Sets the language object. sub Language { my($Lang) = @_; if(Is_Valid($Lang)){ $Language = $Lang; return 1; } return 0; } ### Checks if the given language is available. sub Is_Valid { my($Check) = @_; if(!$Check){ # No value given, invalid. return 0; } elsif($Syntax_Languages::Langs{$Check} == 1){ # Valid. return 1; } return 0; } ### Gets the available languages. sub Get_Languages { my @List; while(my($Code_Lang, $Code_Enable) = each(%Syntax_Languages::Langs)){ if($Code_Enable){ # Just add activated languages. push(@List, $Code_Lang); } } return @List; } ### Creates the highlighting using the Kate module. sub Highlight { my($Code) = @_; if(!$Language){ return 'No language defined.'; } my $hl = new Syntax::Highlight::Engine::Kate( language => $Language, substitutions => { "<" => "<", ">" => ">", "&" => "&", "\t" => " ", # All hail to
! (ToDo: Does this work with trailing spaces?)
			# " "		=> " ",
			# "\t"		=> "    ",
			"\r"		=> "",
			"\n"		=> "\n",
		},
		format_table => {
			Alert			=> ["", ""],
			BaseN			=> ["", ""],
			BString			=> ["", ""],
			Char			=> ["", ""],
			Comment			=> ["", ""],
			DataType		=> ["", ""],
			DecVal			=> ["", ""],
			Error			=> ["", ""],
			Float			=> ["", ""],
			Function		=> ["", ""],
			IString			=> ["", ""],
			Keyword			=> ["", ""],
			Normal			=> ["", ""],
			Operator		=> ["", ""],
			Others			=> ["", ""],
			RegionMarker	=> ["", ""],
			Reserved		=> ["", ""],
			String			=> ["", ""],
			Variable		=> ["", ""],
			Warning			=> ["", ""],
		},
	);

	$Code = $hl->highlightText($Code);
	return $Code;
}


### Creates the time list with option tags for HTML.
sub Build_Syntax_List_HTML {
	my @List = Get_Languages();

	my $String = '';

	@List = sort(@List);

	foreach my $Tmp (@List){
		if($Tmp eq $Syntax_Languages::Selected){
			$String .= '' . "\n";
		} else {
			$String .= '' . "\n";
		}
	}

	return $String;
}


1;
pnopaste-1.6/lib/Format.pm0000644000175000017500000000266213002470345013335 0ustar  memepackage Format;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;
use lib::Highlighting;


### Build line numbers in html.
sub Build_Line_Numbers {
	my($Count) = @_;

	my $String = '';

	# Build $Count anker elements and return them.
	for(my $x = 1; $x <= $Count; $x++){
		$String .= '' . $x . ':' . "\n";
	}

	$String =~ s/\n$//;

	return $String;
}


### Reformat the text for html.
sub To_HTML {
	my($Input, $Language, $Syntax_HL) = @_;

	my $Return = '';


	if($Language eq 'Plain'){
		$Syntax_HL = 0;
	}
	elsif($Syntax_HL == 1){
		Highlighting::Language($Language);
	}

	# We need the numbers of lines.
	my @Walk;
	push(@Walk, $_) for split m!\n! => $Input;


	if($Syntax_HL){
		# Use the highlighting engine.
		$Return = Highlighting::Highlight($Input);
	}
	else {

		foreach my $Line (@Walk){
			$Line =~ s/\r//g;
			$Line =~ s/&/&/g;
			# Do some html enties.
			$Line =~ s//>/g;
			$Line =~ s/"/"/g;

			# Add to string.
			if(defined $Line){
				$Return .= $Line . "\n";
			}
		}
	}


	$Return =~ s/\n$//;

	return(scalar(@Walk), $Return);
}

1;
pnopaste-1.6/lib/HTML.pm0000644000175000017500000001233313002470345012645 0ustar  memepackage HTML;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
no warnings 'once';
use strict;
use lib::Benchmark;
use lib::Database;
use lib::Expire;
use lib::Format;
use lib::Skin;
use lib::Language;
use lib::Highlighting;
use lib::Version;


# Shows the confirm page with the ID link.
sub Confirm {
	my($ID, $Self_URL) = @_;

	Header();

	List_Confirm($ID, $Self_URL);

	Footer();
}


### Shows errors and exits.
sub Error {
	my($Error_ID) = @_;

	# ErrorID List.
	my %Errors = (
		1	=> Language::Get(1),
		2	=> Language::Get(2),
		3	=> Language::Get(3),
		4	=> Language::Get(4)
	);

	Header();

	print $Errors{$Error_ID}, "\n";

	Footer();
}


### Adds html header and stylesheet.
sub Header {

	# The content type. This is the reason, why Header()
	# is only allowed to be called once in an session.
	print "Content-type: text/html; charset=UTF-8\n\n";

	my $Style = Skin::Get_Skin();
	my $Title = Skin::Get_Title();

	open(HEAD,'<','./templates/header.tmpl') or return;
	while(){
		$_ =~ s/#STYLE#/$Style/g;
		$_ =~ s/#TITLE#/$Title/g;
		$_ = Language_Replace($_);
		print;
	}
	close(HEAD);
}


### Replaces #LANGint()# to translated messages.
sub Language_Replace {
	my($String) = @_;
	
	$String =~ s/#LANG([^#]+)#/Language::Get($1)/eg;
	
	return $String;
}


### Adds html footer.
sub Footer {
	open(FOOT,'<','./templates/footer.tmpl') or return;

	my $Version	= $Version::Build;
	my $Needed	= Benchmark::Calculate();

	while(){
		$_ =~ s/#RENDERTIME#/$Needed/g;
		$_ =~ s/#VERSION#/$Version/g;
		$_ = Language_Replace($_);
		print;
	}
	close(FOOT);

	exit(0);
}


### Adds add form page.
sub Add_Form {
	my($FullURL) = @_;

	my $Timeoptions = Expire::Build_Time_List_HTML();
	my $Langoptions = Highlighting::Build_Syntax_List_HTML();


	open(ADD,'<','./templates/list_addform.tmpl') or return;

	while(){
		# Replace the template url with the real one for POST.
		$_ =~ s/#SCRIPTNAME#/$FullURL/g;
		# Insert timesheet lists.
		$_ =~ s/#TIMELISTOPTIONS#/$Timeoptions/g;
		# Insert Syntax HL options.
		$_ =~ s/#LANGUAGEOPTIONS#/$Langoptions/g;
		
		$_ = Language_Replace($_);

		print;
	}

	close(ADD);
}


### Creates the confirm page from the template.
sub List_Confirm {
	my($ID, $FullURL) = @_;

	# Add the '?' to the Full URL.
	my $FullURL_ID = $FullURL . '?' . $ID;

	open(CONFIRM,'<','./templates/list_confirm.tmpl') or return;

	while(){
		# Replace the template url with the real one for POST.
		$_ =~ s/#LINKCODE#/$FullURL_ID/g;
		$_ =~ s/#URLCODE#/$FullURL/g;
		$_ = Language_Replace($_);
		print;
	}

	close(CONFIRM);
}


### Display the html main add page.
sub Add {
	my($URL) = @_;

	Header();
	Add_Form($URL);
	Footer();
}


### Displays a code.
sub Code {
	my($ID, $Download, $BaseURL) = @_;

	my $Query = 'SELECT name,description,code,time,ip,language FROM nopaste WHERE id = ? LIMIT 1';
	$Query = $Database::dbh->prepare($Query);
	$Query->execute($ID);

	my $List = $Query->fetchrow_hashref();
	if(!$List){
		Add($BaseURL);
	}

	# Declarations and some failovers.
	my $Time		= localtime($List->{'time'});
	my $Author		= $List->{'name'}			|| 'Anonymous';
	my $Description	= $List->{'description'}	|| Language::Get(5);
	my $Code		= $List->{'code'}			|| '';
	my $IP			= $List->{'ip'};
	my $Syntax_HL	= $List->{'language'}		|| 'Plain';
	my $Expires		= Expire::Get_Expire($ID);


	# We have to change the content-type for downloads.
	if($Download){
		print "Content-type: text/plain\n\n";
		print $Code;
		exit(0);
	}


	$Author .= ' (' . $IP . ')';

	my($Code_Lines, $Code_Text) = Format::To_HTML($Code, $Syntax_HL, 1);
	my($Desc_Lines, $Desc_Text) = Format::To_HTML($Description, $Syntax_HL, 0);

	my $Line_Numbers = Format::Build_Line_Numbers($Code_Lines);

	my $Get_Link = '' . Language::Get(6) . '';
	my $New_Link = '' . Language::Get(6) . '';

	Header();

	# Write authors part.
	my $Tmpl_Authors = '';

	open(AUTHORS,'<','./templates/list_table_author.tmpl') or return;
	while(){
		$Tmpl_Authors .= $_;
	}
	close(AUTHORS);

	$Tmpl_Authors =~ s/#TIME#/$Time/g;
	$Tmpl_Authors =~ s/#LANGUAGE#/$Syntax_HL/g;
	$Tmpl_Authors =~ s/#EXPIRES#/$Expires/g;
	$Tmpl_Authors =~ s/#LINENUMBERS#/$Line_Numbers/g;
	$Tmpl_Authors =~ s/#DOWNLOAD#/$Get_Link/g;
	$Tmpl_Authors =~ s/#ADD_NEW#/$New_Link/g;
	$Tmpl_Authors = Language_Replace($Tmpl_Authors);
	$Tmpl_Authors =~ s/#AUTHOR#/$Author/g;


	# Write desc part.
	my $Tmpl_Desc = '';

	open(DESC,'<','./templates/list_table_desc.tmpl') or return;
	while(){
		$Tmpl_Desc .= $_;
	}
	close(DESC);

	$Tmpl_Desc =~ s/#LINENUMBERS#/$Line_Numbers/g;
	$Tmpl_Desc = Language_Replace($Tmpl_Desc);
	$Tmpl_Desc =~ s/#DESCRIPTION#/$Desc_Text/g;


	# Write code part.
	my $Tmpl_Code = '';

	open(CODE,'<','./templates/list_table_code.tmpl') or return;
	while(){
		$Tmpl_Code .= $_;
	}
	close(CODE);

	$Tmpl_Code =~ s/#CODETEXT#/$Code_Text/g;

	print $Tmpl_Authors, $Tmpl_Desc, $Tmpl_Code;

	# Print footer.
	Footer();

}


1;
pnopaste-1.6/lib/Benchmark.pm0000644000175000017500000000141613002470345013773 0ustar  memepackage Benchmark;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;
use Time::HiRes qw(gettimeofday);


my($Start_Sec, $Start_USec) = gettimeofday();
my $Bench_Start = $Start_Sec . '.' . $Start_USec;


sub Calculate {

	my($End_Sec, $End_USec) = gettimeofday();
	my $Bench_End = $End_Sec . '.' . $End_USec;

	my $Diff = $Bench_End - $Bench_Start;
	$Diff = sprintf("%.4f", $Diff);

	if($Diff < 0){
		$Diff = '0.0000';
	}

	return $Diff;
}


1;
pnopaste-1.6/lib/Database.pm0000644000175000017500000000124113002470345013601 0ustar  memepackage Database;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
no warnings 'once';
use strict;
use DBI;
use conf::SQL_Access;

### Database handle.
our $dbh = DBI->connect_cached(
	"dbi:$SQL_Access::Driver:$SQL_Access::Database:$SQL_Access::Hostname",
	$SQL_Access::Username,
	$SQL_Access::Password
) or die 'SQL error: ', $DBI::errstr;


1;
pnopaste-1.6/lib/Code.pm0000644000175000017500000000270613002470345012756 0ustar  memepackage Code;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;
use lib::Database;
use lib::Expire;
use lib::HTML;
use lib::Security;
use lib::Highlighting;


### Adds a new code to the database.
sub Add {
		my($Code, $Desc, $Name, $Expi, $Synt, $Remote_Addr, $Full_URL) = @_;


        # Now some security checks, if all given values are valid.
        if(Expire::Valid_Time($Expi) == 0){
                HTML::Error(1);
        }
        elsif(Security::Blacklist_Words($Code) == 1){
                HTML::Error(3);
        }
        elsif(Highlighting::Is_Valid($Synt) == 0){
                HTML::Error(4);
        }

        # Create query with all needed data.
        my $Query = 'INSERT INTO nopaste (name, description, code, time, ip, expires, language) VALUES (?, ?, ?, ?, ?, ?, ?)';
        $Query = $Database::dbh->prepare($Query);
        $Query->execute($Name, $Desc, $Code, time(), $Remote_Addr, $Expire::Time_List{$Expi}, $Synt);

        # Get the last MySQL auto_increment ID.
        my $Last_ID = $Database::dbh->{'mysql_insertid'};

        # Show us the confirm page.
        HTML::Confirm($Last_ID, $Full_URL);
}

1;
pnopaste-1.6/lib/Version.pm0000644000175000017500000000065613002470345013533 0ustar  memepackage Version;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;

our $Build = '1.6';

1;
pnopaste-1.6/lib/Expire.pm0000644000175000017500000000426013002470345013335 0ustar  memepackage Expire;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;
use lib::Database;


our %Time_List = (
	'6h'	=> 21600,
	'1d'	=> 86400,
	'1w'	=> 604800,
	'1m'	=> 2419200,
	'never'	=> 0
);

# Standard choice.
our $Standard = '1w';


### Builds an array of the times.
sub Time_List {
	my @List = sort {
		$Time_List{$b} <=> $Time_List{$a}
	} keys %Time_List;

	return @List;
}


### Creates the time list with option tags for HTML.
sub Build_Time_List_HTML {
	my @List = Time_List();

	my $String = '';

	foreach my $Tmp (@List){
		if($Tmp eq $Standard){
			$String .= '' . "\n";
		} else {
			$String .= '' . "\n";
		}
	}

	return $String;
}


### Checks if the expire time is valid.
sub Valid_Time {
	my($Time) = @_;

	if(!exists $Time_List{$Time}){
		return 0;
	}

	return 1;
}


### Get the expire date of a code.
sub Get_Expire {
	my($ID) = @_;

	my $Query = 'SELECT time,expires FROM nopaste WHERE id = ? LIMIT 1';
	$Query = $Database::dbh->prepare($Query);
	$Query->execute($ID);

	my $Result = $Query->fetchrow_hashref();

	my $Expiretime = $Result->{'expires'};
	my $Createtime = $Result->{'time'};

	# It will never expires.
	if(!$Expiretime){
		return 'never';
	}

	$Expiretime += $Createtime;
	$Expiretime = localtime($Expiretime);

	return $Expiretime;
}


### Deletes expired entrys.
sub Delete_Old_Entrys {

	my $Query = 'DELETE FROM nopaste WHERE expires != 0 AND time + expires < ?';
	$Query = $Database::dbh->prepare($Query);
	$Query->execute(time());

}


### Gets default setting for cleanup option.
sub Get_Cleanup {
	my $Default = 1;

	my $Query = 'SELECT cleanup FROM settings LIMIT 1';
	$Query = $Database::dbh->prepare($Query);
	$Query->execute();

	my $List = $Query->fetchrow_hashref();
	if(defined $List->{'cleanup'}){
		$Default = $List->{'cleanup'};
	}

	return $Default;
}

1;
pnopaste-1.6/lib/Language.pm0000644000175000017500000000372113002470345013625 0ustar  memepackage Language;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;
use Geo::IP;
use CGI qw/:standard/;


# Default language.
my $Language = 'EN';
my $Lang_Dir = 'lang/';

# Start the language detection.
Initialiaze();


### Initialize the remote client.
sub Initialiaze {
	# Our CGI object.
	my $CGI = new CGI;
	my $Remote_Addr = $CGI->remote_host();

	if(!defined $Remote_Addr or $Remote_Addr eq 'localhost'){
		# Could not get the IP address, we set the default and return.
		Set_Language($Language);
		return;
	}

	# Our GeoIP object with the standard country database.
	my $GeoIP = Geo::IP->new(GEOIP_STANDARD);

	# Get country code of the remote client.
	my $Country = $GeoIP->country_code_by_addr($Remote_Addr);

	Set_Language($Country);
}


### Sets the language based on the result of geoip country code.
sub Set_Language {
	my($Lang) = @_;

	$Lang = Mapping($Lang);

	my $Lang_File = $Lang_Dir . $Lang . '.pm';

	if(-e $Lang_File){
		# We have got a translation for this client.
		$Language = $Lang;
	}

}


### Do some static language country code mappings.
sub Mapping {
	my($Lang) = @_;

	if(!defined $Lang){
		$Lang = 'EN';
	}
	elsif($Lang eq 'AT'){
		$Lang = 'DE';
	}

	return $Lang;
}


### Get all available translations.
sub Get_Languages {
	my @Languages = ();

	opendir(R, $Lang_Dir) or return undef;

	while(my $File = readdir(R)){
		if($File =~ /^.*\.pm$/){
			$File =~ s/\.pm//;

			push(@Languages, $File);
		}
	}

	closedir(R);

	return @Languages;
}


### Get the translation for the translateable ID.
sub Get {
	my($ID) = @_;

	# Load language module.
	require $Lang_Dir . $Language . '.pm';

	return $Translation::Strings{$ID};
}


1;
pnopaste-1.6/lib/Skin.pm0000644000175000017500000000323413002470345013005 0ustar  memepackage Skin;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;
use lib::Database;

# Default (fallback) settings.
my $CSS_Default		= 'default';
my $Title_Default	= 'Perl Nopaste';


### Returns available skins in an array.
sub Get_Available_Skins {
	my @Skins;

	opendir(R,'./skins/');

	while(my $File = readdir(R)){
		if(-e './skins/' . $File and $File =~ /^.*\.css$/){
			$File =~ s/\.css$//;
			push(@Skins, $File);
		}
	}

	closedir(R);

	return @Skins;
}


### Returns the HTML title.
sub Get_Title {
	my $Query = 'SELECT title FROM settings LIMIT 1';
	$Query = $Database::dbh->prepare($Query);
	$Query->execute();

	my $Result = $Query->fetchrow_hashref();
	my $Title = $Result->{'title'};

	if(!defined $Title){
		return $Title_Default;
	} else {
		return $Title;
	}
}


### Checks if a skin is valid.
sub Is_Valid {
	my($Check) = @_;

	return 0 if !$Check;

	my @Skinlist = Get_Available_Skins();

	foreach my $Tmp (@Skinlist){
		if($Tmp eq $Check){
			# Valid.
			return 1;
		}
	}

	# Invalid.
	return 0;
}


### Gets the saved skin from the database.
sub Get_Skin {
	my $Query = 'SELECT style FROM settings LIMIT 1';
	$Query = $Database::dbh->prepare($Query);
	$Query->execute();

	my $Result = $Query->fetchrow_hashref();
	my $Skin = $Result->{'style'};

	if(Is_Valid($Skin) == 0){
		return $CSS_Default;
	} else {
		return $Skin;
	}
}

1;

pnopaste-1.6/lib/Hits.pm0000644000175000017500000000147013002470345013010 0ustar  memepackage Hits;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;
use lib::Database;


### Inc the Badword hit.
sub Inc_Badword {
	my($ID) = @_;

	my $Query = 'UPDATE blacklist_word SET hits = hits + 1 WHERE id = ?';
	$Query = $Database::dbh->prepare($Query);
	$Query->execute($ID);
}


### Inc the Badhost hit.
sub Inc_Badhost {
	my($ID) = @_;

	my $Query = 'UPDATE blacklist_ip SET hits = hits + 1 WHERE id = ?';
	$Query = $Database::dbh->prepare($Query);
	$Query->execute($ID);
}


1;
pnopaste-1.6/lang/0000755000175000017500000000000013002470345011714 5ustar  memepnopaste-1.6/lang/EN.pm0000644000175000017500000000244113002470345012555 0ustar  memepackage Translation;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;


our %Strings = (
	1	=> 'Invalid expire time.',
	2	=> 'Your Hostname is blacklisted.',
	3	=> 'You used one or more badwords in the code fields.',
	4	=> 'The given code language is not present.',
	5	=> 'The user has not left a description.',
	6	=> 'Here',
	7	=> 'Rendertime:',
	8	=> 'sec',
	9	=> 'Your name:',
	10	=> 'Expires in:',
	11	=> 'Syntax Highlighting:',
	12	=> 'Description:',
	13	=> 'Code:',
	14	=> 'Insert',
	15	=> 'Hello. Your code has been successfull added.',
	16	=> 'You can access your paste now on',
	17	=> 'You can also link directly against a specific line, for example with',
	18	=> 'where',
	19	=> 'is the line number.',
	20	=> 'If you wish to download the code as plain/text, then go to',
	21	=> 'If you wish to add another entry,',
	22	=> 'click here',
	23	=> 'Download:',
	24	=> 'New:',
	25	=> 'Nopaste from:',
	26	=> 'Expires on:',
	27	=> 'From:',
	28	=> 'Code language:'
);

1;
pnopaste-1.6/lang/DK.pm0000644000175000017500000000241013002470345012545 0ustar  memepackage Translation;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;


our %Strings = (
	1	=> 'Ugyldig udløbstid.',
	2	=> 'Din Host er ikke tilladt.',
	3	=> 'Du har brugt en eller flere ikke tilladte ord i kodefelterne .',
	4	=> 'Den angivene sprogkode er ikke tilladt.',
	5	=> 'Brugeren har ikke efterladt en beskrivelse.',
	6	=> 'Her',
	7	=> 'Rendertid:',
	8	=> 'sek',
	9	=> 'Dit navn:',
	10	=> 'Udløber:',
	11	=> 'Syntax Highlighting:',
	12	=> 'Beskrivelse:',
	13	=> 'Kode:',
	14	=> 'Tilføj',
	15	=> 'Hej.Din kode er tilføjet.',
	16	=> 'Du finder din paste på',
	17	=> 'Du kann også henvise på en speciel linie, for eksempel med',
	18	=> 'hvor',
	19	=> 'er liniens nummer.',
	20	=> 'Hvis du ønsker at downloade coden som plain/text, gå til',
	21	=> 'Hvis du ønsker at tilføje en hvidere paste,',
	22	=> 'klik her',
	23	=> 'Download:',
	24	=> 'Ny:',
	25	=> 'Nopaste fra:',
	26	=> 'Udløber:',
	27	=> 'Fra:',
	28	=> 'Sprogkode:'
);

1;
pnopaste-1.6/lang/DE.pm0000644000175000017500000000263213002470345012545 0ustar  memepackage Translation;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;


our %Strings = (
	1	=> 'Ungültige Expire Zeit.',
	2	=> 'Dein Host ist gesperrt.',
	3	=> 'Du hast einen oder mehrere gesperrte Wörter verwendet.',
	4	=> 'Die angegebene Syntax Sprache ist ungültig.',
	5	=> 'Der Benutzer hat keine Beschreibung hinterlassen.',
	6	=> 'Hier',
	7	=> 'Renderzeit:',
	8	=> 'sek',
	9	=> 'Dein Name:',
	10	=> 'Läuft ab in:',
	11	=> 'Syntax Highlighting:',
	12	=> 'Beschreibung:',
	13	=> 'Code:',
	14	=> 'Hinzufügen',
	15	=> 'Hallo. Dein Code wurde erfolgreich hinzugefügt.',
	16	=> 'Du kannst deinen Paste erreichen auf',
	17	=> 'Du kannst ebenso direkt auf eine spezielle Zeilennummer verweisen, zum Beispiel mit',
	18	=> 'wo',
	19	=> 'die Zeilennummer ist.',
	20	=> 'Wenn du deinen Code als plain/text downloaden möchtest, dann geh auf',
	21	=> 'Wenn du einen weiteren Eintrag hinzufügen möchtest,',
	22	=> 'Klick hier',
	23	=> 'Download:',
	24	=> 'Neu:',
	25	=> 'Nopaste von:',
	26	=> 'Läuft ab am:',
	27	=> 'Von:',
	28	=> 'Code Sprache:'
);

1;
pnopaste-1.6/lang/FR.pm0000644000175000017500000000263313002470345012565 0ustar  memepackage Translation;

# This file is part of the pnopaste program
# Copyright (C) 2008-2016 Patrick Matthäi 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

use warnings;
use strict;


our %Strings = (
	1	=> 'Temps d\'expiration invalide.',
	2	=> 'Votre Nom d\'hôte est blacklisté.',
	3	=> 'Vous utilisez un ou plusieurs mots incorrect dans le champ de code.',
	4	=> 'Le code du langage fourni n\'est pas présent.',
	5	=> 'L\'utilisateur n\'a pas laissé de description.',
	6	=> 'Ici',
	7	=> 'Temps de calcul:',
	8	=> 'sec',
	9	=> 'Votre nom:',
	10	=> 'Expire dans:',
	11	=> 'Coloration syntaxique:',
	12	=> 'Description:',
	13	=> 'Code:',
	14	=> 'Insérer:',
	15	=> 'Bonjour, Votre code a été ajouté avec succès.',
	16	=> 'Vous pouvez, maintenant, acceder à votre paste sur',
	17	=> 'Vous pouvez également obtenir un lien vers une ligne spécifique, par exemple:',
	18	=> 'où',
	19	=> 'est le numéro de ligne.',
	20	=> 'Si vous souhaitez télécharger le code en plain/text, aller sur',
	21	=> 'Si vous souhaitez ajouter une nouvelle entrée,',
	22	=> 'cliquez ici',
	23	=> 'Telecharger:',
	24	=> 'Nouveau:',
	25	=> 'Pas de past pour:',
	26	=> 'Expire le:',
	27	=> 'De:',
	28	=> 'Langage:'
);

1;
pnopaste-1.6/AUTHORS0000644000175000017500000000021713002470345012043 0ustar  memeProgrammers:
	Patrick Matthäi 
	Philipp Schafft 

Templates:
	Uli Schlachter