--- /dev/null
+Original Author :
+
+ 2003-2004 : David Bachelart < david dot bachelart at polytechnique dot org >
+
+Current Authors :
+
+ since 2005 : Pierre Habouzit < pierre dot habouzit at polytechnique dot org >
+ since 2006 : Florent Bruneau < florent dot bruneau at polytechnique dot org >
--- /dev/null
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, 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.
+\f
+ 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.)
+\f
+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.
+\f
+ 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.
+\f
+ 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.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ 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) 19yy 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.
+
+ <signature of Ty Coon>, 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.
--- /dev/null
+================================================================================
+VERSION 1.3
+
+Sat, 08 Avr 2006 Florent Bruneau <florent.bruneau@m4x.org>
+
+ * PHP5 Compatible
+
+March 2006 Florent Bruneau <florent.bruneau@m4x.org>
+
+ * Add multipart and attachment support
+ * Add HTML and RichText support
+ * Improve url handling
+ * Fix invalid html in submission form
+ * Add quotations handling
+ * Fix cache issue with empty newsgroups
+ * Add x-face placement support
+ * Improve support of some non-standard clients
+ * Fix support of post without subject
+ * Improve wrapping
+
+================================================================================
+VERSION 1.2
+
+Wed, 19 Oct 2005 Pierre Habouzit <pierre.habouzit@m4x.org>
+
+ * Fix a problem wrt responses (Re: in subject).
+ * Fix a problem with empty overviews.
+ * Fix Header encoding problems.
+
+================================================================================
+VERSION 1.1
+
+Tue, 24 May 2005 Pierre Habouzit <pierre.habouzit@m4x.org>
+
+ * Fix one problem with $this->ids beeing empty in Spool.
+ * Fix encoding issues since iconv truncates strings sometimes.
+ * Make the post forms use utf-8.
+
+================================================================================
+VERSION 1.0
+
+Fri, 07 Jan 2005 Pierre Habouzit <pierre.habouzit@m4x.org>
+
+ * Banana is now a real standalone class.
+ * Clean hooks.
+ * Update the script spoolgen.php.
+
+Wed, 05 Jan 2005 Pierre Habouzit <pierre.habouzit@m4x.org>
+
+ * continue the work with post.php.
+
+Tue, 04 Jan 2005 Pierre Habouzit <pierre.habouzit@m4x.org>
+
+ * prepare Banana to be a library :
+ - delete a lot of echo's.
+ - use a lot of string passing.
+ - create more Banana:: functions.
+ => API IS NOT STABLE ATM.
+
+Mon, 03 Jan 2005 Pierre Habouzit <pierre.habouzit@m4x.org>
+
+ * no more $news -> class Banana.
+ * continue include rework.
+ * hooks functions enters.
+ * $banana is now the only global variable we need.
+ * exit format.inc.php.
+
+Sun, 02 Jan 2005 Pierre Habouzit <pierre.habouzit@m4x.org>
+
+ * _(..) -> _b_(..) that performs a dgettext('banana', ...).
+ * use gettext and no more $locales.
+ * rework includes.
+
+Sat, 01 Jan 2005 Pierre Habouzit <pierre.habouzit@m4x.org>
+
+ * rework headerDecode function (biggest bottleneck).
+ * rework includes.
+
+================================================================================
+VERSION 0.7.1
+
+Before Jan 2005 David Bachelart <david.bachelart@m4x.org>
+
+ * first version.
+
+================================================================================
+vim:set ts=4 sw=4:
--- /dev/null
+# definitions
+
+VERSION=$(shell grep VERSION Changelog | head -1 | sed -e "s/VERSION //;s/\t.*//")
+PKG_DIST = banana-$(VERSION)
+
+PKG_FILES = AUTHORS Changelog COPYING README Makefile TODO
+
+PKG_DIRS = banana po css examples img
+
+VCS_FILTER = ! -name .arch-ids ! -name .arch-inventory
+
+# global targets
+
+build: pkg-build
+
+dist: clean pkg-dist
+
+clean:
+ rm -rf locale banana/include/banana.inc.php
+ make -C po clean
+
+%: %.in Makefile
+ sed -e 's,@VERSION@,$(VERSION) The Bearded Release,g' $< > $@
+
+
+# banana package targets
+
+pkg-build: banana/banana.inc.php
+ make -C po
+ make -C po clean
+
+pkg-dist: pkg-build
+ rm -rf $(PKG_DIST) $(PKG_DIST).tar.gz
+ mkdir $(PKG_DIST)
+ cp -a $(PKG_FILES) $(PKG_DIST)
+ for dir in `find $(PKG_DIRS) -type d $(VCS_FILTER)`; \
+ do \
+ mkdir -p $(PKG_DIST)/$$dir; \
+ find $$dir -type f $(VCS_FILTER) -maxdepth 1 -exec cp {} $(PKG_DIST)/$$dir \; ; \
+ done
+ tar czf $(PKG_DIST).tar.gz $(PKG_DIST)
+ rm -rf $(PKG_DIST)
+
+
+
+.PHONY: build dist clean pkg-build pkg-dist lib-build lib-dist
+
--- /dev/null
+banana - a web interface for a NNTP server
+
+DISTRIBUTING
+============
+
+banana is distributed under the terms of the GNU General Public
+License (GPL) (see COPYING)
--- /dev/null
+* MIME support
+* strict NNTP support
--- /dev/null
+<?php
+/********************************************************************************
+* include/NetNNTP.inc.php : NNTP subroutines
+* -------------------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+/** Class NNTP
+ * implements some basic functions for NNTP protocol
+ */
+class nntp
+{
+ /** socket filehandle */
+ var $ns;
+ /** posting allowed */
+ var $posting;
+ /** last NNTP error code */
+ var $lasterrorcode;
+ /** last NNTP error text */
+ var $lasterrortext;
+ /** test validity */
+ var $valid = true;
+
+ /** constructor
+ * @param $_host STRING NNTP host
+ * @param $_timeout INTEGER socket timeout
+ * @param $_reader BOOLEAN sends a "MODE READER" at connection if true
+ */
+
+ function nntp($_url, $_timeout=120, $_reader=true)
+ {
+ $url['port'] = 119;
+ $url = parse_url($_url);
+ $this->ns = fsockopen($url['host'], $url['port'], $errno, $errstr, $_timeout);
+ if (!$this->ns) {
+ $this->valid = false;
+ return null;
+ }
+
+ $result = $this->gline();
+ $this->posting = (substr($result, 0, 3)=="200");
+ if ($_reader && ($result{0}=="2")) {
+ $this->pline("MODE READER\r\n");
+ $result = $this->gline();
+ $this->posting = ($result{0}=="200");
+ }
+ if ($result{0}=="2" && $url['user'] && $url['user']!='anonymous') {
+ return $this->authinfo($url['user'], $url['pass']);
+ }
+ return ($result{0}=="2");
+ }
+
+# Socket functions
+
+ /** get a line from server
+ * @return STRING
+ */
+
+ function gline()
+ {
+ return rtrim(fgets($this->ns, 1200));
+ }
+
+ /** puts a line on server
+ * @param STRING $_line line to put
+ */
+
+ function pline($_line)
+ {
+ return fputs($this->ns, $_line, strlen($_line));
+ }
+
+# strict NNTP Functions [RFC 977]
+# see http://www.faqs.org/rfcs/rfc977.html
+
+ /** authentification
+ * @param $_user STRING login
+ * @param $_pass INTEGER password
+ * @return BOOLEAN true if authentication was successful
+ */
+
+ function authinfo($_user, $_pass)
+ {
+ $user = preg_replace("/(\r|\n)/", "", $_user);
+ $pass = preg_replace("/(\r|\n)/", "", $_pass);
+ $this->pline("AUTHINFO USER $user\r\n");
+ $this->gline();
+ $this->pline("AUTHINFO PASS $pass\r\n");
+ $result=$this->gline();
+ if ($result{0}!="2") {
+ $this->lasterrorcode = substr($result, 0, 3);
+ $this->lasterrortext = substr($result, 4);
+ return false;
+ }
+ return true;
+ }
+
+ /** retrieves an article
+ * MSGID is a numeric ID a shown in article's headers. MSGNUM is a
+ * server-dependent ID (see X-Ref on many servers) and retriving
+ * an article by this way will change the current article pointer.
+ * If an error occur, false is returned.
+ * @param $_msgid STRING MSGID or MSGNUM of article
+ * @return ARRAY lines of the article
+ * @see body
+ * @see head
+ */
+
+ function article($_msgid="")
+ {
+ $msgid = preg_replace("/(\r|\n)/", "", $_msgid);
+ $this->pline("ARTICLE $msgid\r\n");
+ $result = $this->gline();
+ if ($result{0} != '2') {
+ $this->lasterrorcode = substr($result, 0, 3);
+ $this->lasterrortext = substr($result, 4);
+ return false;
+ }
+ $result = $this->gline();
+ while ($result != ".") {
+ $array[] = $result;
+ $result = $this->gline();
+ }
+ return $array;
+ }
+
+ /** post a message
+ * if an error occur, false is returned
+ * @param $_message STRING message to post
+ * @return STRING MSGID of article
+ */
+
+ function post($_message)
+ {
+ if (is_array($_message)) {
+ $message=join("\n", $_message);
+ } else {
+ $message=$_message;
+ }
+ $this->pline("POST \r\n");
+ $result=$this->gline();
+ if ($result{0} != '3') {
+ $this->lasterrorcode = substr($result, 0, 3);
+ $this->lasterrortext = substr($result, 4);
+ return false;
+ }
+ $this->pline($message."\r\n.\r\n");
+ $result = $this->gline();
+ if ($result{0} != '2') {
+ $this->lasterrorcode = substr($result, 0, 3);
+ $this->lasterrortext = substr($result, 4);
+ return false;
+ }
+ if ($result{0} == '2') {
+ if (preg_match("/(<[^@>]+@[^@>]+>)/", $result, $regs)) {
+ return $regs[0];
+ } else {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /** fetches the body of an article
+ * params are the same as article
+ * @param $_msgid STRING MSGID or MSGNUM of article
+ * @return ARRAY lines of the article
+ * @see article
+ * @see head
+ */
+
+ function body($_msgid="")
+ {
+ $msgid = preg_replace("/(\r|\n)/", "", $_msgid);
+ $this->pline("BODY $msgid\r\n");
+ $result = $this->gline();
+ if ($result{0} != '2') {
+ $this->lasterrorcode = substr($result, 0, 3);
+ $this->lasterrortext = substr($result, 4);
+ return false;
+ }
+ $array = Array();
+ while (($result = $this->gline()) != ".") {
+ $array[] = $result;
+ }
+ return $array;
+ }
+
+ /** fetches the headers of an article
+ * params are the same as article
+ * @param $_msgid STRING MSGID or MSGNUM of article
+ * @return ARRAY lines of the article
+ * @see article
+ * @see body
+ */
+
+ function head($_msgid="")
+ {
+ $msgid = preg_replace("/(\r|\n)/", "", $_msgid);
+ $this->pline("HEAD $msgid\r\n");
+ $result = $this->gline();
+ if ($result{0}!="2") {
+ $this->lasterrorcode = substr($result, 0, 3);
+ $this->lasterrortext = substr($result, 4);
+ return false;
+ }
+ $result = $this->gline();
+ while ($result != ".") {
+ $array[] = $result;
+ $result = $this->gline();
+ }
+ return $array;
+ }
+
+ /** set current group
+ * @param $_group STRING
+ * @return ARRAY array : nb of articles in group, MSGNUM of first article, MSGNUM of last article, and group name
+ */
+
+ function group($_group)
+ {
+ $group = preg_replace("/(\r|\n)/", "", $_group);
+ $this->pline("GROUP $group\r\n");
+ $line = $this->gline();
+ if ($line{0}!="2") {
+ $this->lasterrorcode = substr($line, 0, 3);
+ $this->lasterrortext = substr($line, 4);
+ return false;
+ }
+ if (preg_match("/^2\d{2} (\d+) (\d+) (\d+) ([^ ]+)/", $line, $regs)) {
+ return array($regs[1], $regs[2], $regs[3], $regs[4]);
+ }
+ return false;
+ }
+
+ /** set the article pointer to the previous article in current group
+ * @return STRING MSGID of article
+ * @see next
+ */
+
+ function last()
+ {
+ $this->pline("LAST \r\n");
+ $line = $this->gline();
+ if ($line{0}!="2") {
+ $this->lasterrorcode = substr($result, 0, 3);
+ $this->lasterrortext = substr($result, 4);
+ return false;
+ }
+ if (preg_match("/^2\d{2} \d+ <([^>]+)>/", $line, $regs)) {
+ return "<{$regs[1]}>";
+ }
+ return false;
+ }
+
+ /** set the article pointer to the next article in current group
+ * @return STRING MSGID of article
+ * @see last
+ */
+
+ function next()
+ {
+ $this->pline("NEXT \r\n");
+ $line = $this->gline();
+ if ($line{0}!="2") {
+ $this->lasterrorcode = substr($result, 0, 3);
+ $this->lasterrortext = substr($result, 4);
+ return false;
+ }
+ if (preg_match("/^2\d{2} \d+ <([^>]+)>/", $line, $regs)) {
+ return "<{$regs[1]}>";
+ }
+ return false;
+ }
+
+ /** set the current article pointer
+ * @param $_msgid STRING MSGID or MSGNUM of article
+ * @return BOOLEAN true if authentication was successful, error code otherwise
+ * @see article
+ * @see body
+ */
+
+ function nntpstat($_msgid)
+ {
+ $msgid = preg_replace("/(\r|\n)/", "", $_msgid);
+ $this->pline("STAT $msgid\r\n");
+ $line = $this->gline();
+ if ($line{0}!="2") {
+ $this->lasterrorcode = substr($result, 0, 3);
+ $this->lasterrortext = substr($result, 4);
+ return false;
+ }
+ if (preg_match("/^2\d{2} \d+ <([^>]+)>/", $line, $regs)) {
+ return "<{$regs[1]}>";
+ }
+ return false;
+ }
+
+ /** returns true if posting is allowed
+ * @return BOOLEAN true if posting is allowed lines
+ */
+
+ function postok()
+ {
+ return ($this->posting);
+ }
+
+ /** retreive the group list
+ * @return ARRAY group name => (MSGNUM of first article, MSGNUM of last article, NNTP flags)
+ * @see newgroups, liste
+ */
+ function _grouplist()
+ {
+ global $banana;
+
+ if (substr($this->gline(), 0, 1)!="2") {
+ return false;
+ }
+ $result = $this->gline();
+ $array = Array();
+ while ($result != ".") {
+ preg_match("/([^ ]+) (\d+) (\d+) (.)/", $result, $regs);
+ if (!isset($banana->grp_pattern) || preg_match('@'.$banana->grp_pattern.'@', $regs[1])) {
+ $array[$regs[1]] = array(intval($regs[2]), intval($regs[3]), intval($regs[4]));
+ }
+ $result = $this->gline();
+ }
+ return $array;
+ }
+
+ /** gets information about all active newsgroups
+ * @return ARRAY group name => (MSGNUM of first article, MSGNUM of last article, NNTP flags)
+ * @see newgroups
+ */
+
+ function liste()
+ {
+ $this->pline("LIST\r\n");
+ return $this->_grouplist();
+ }
+
+ /** get information about recent newsgroups
+ * same as list, but information are limited to newgroups created after $_since
+ * @param $_since INTEGER unix timestamp
+ * @param $_distributions STRING distributions
+ * @return ARRAY same format as liste
+ * @see liste
+ */
+
+ function newgroups($_since, $_distributions="")
+ {
+#assume $_since is a unix timestamp
+ $distributions = preg_replace("/(\r|\n)/", "", $_distributions);
+ $this->pline("NEWGROUPS ".gmdate("ymd His", $_since)
+ ." GMT $distributions\r\n");
+ return $this->_grouplist();
+ }
+
+ /** gets a list of new articles
+ * @param $_since INTEGER unix timestamp
+ * @parma $_groups STRING pattern of intersting groups
+ * @return ARRAY MSGID of new articles
+ */
+
+ function newnews($_since, $_groups="*", $_distributions="")
+ {
+ $distributions = preg_replace("/(\r|\n)/", "", $_distributions);
+ $groups = preg_replace("/(\r|\n)/", "", $_groups);
+ $array = array();
+#assume $since is a unix timestamp
+ $this->pline("NEWNEWS $_groups ".gmdate("ymd His", $_since)." GMT $distributions\r\n");
+ if (substr($this->gline(), 0, 1)!="2") {
+ return false;
+ }
+ while (($result = $this->gline()) != ".") {
+ $array[] = $result;
+ }
+ return $array;
+ }
+
+ /** Tell the remote server that I am not a user client, but probably another news server
+ * @return BOOLEAN true if sucessful
+ */
+
+ function slave()
+ {
+ $this->pline("SLAVE \r\n");
+ return (substr($this->gline(), 0, 1)=="2");
+ }
+
+ /** implements IHAVE method
+ * @param $_msgid STRING MSGID of article
+ * @param $_message STRING article
+ * @return BOOLEAN
+ */
+
+ function ihave($_msgid, $_message=false)
+ {
+ $msgid = preg_replace("/(\r|\n)/", "", $_msgid);
+ if (is_array($message)) {
+ $message = join("\n", $_message);
+ } else {
+ $message = $_message;
+ }
+ $this->pline("IHAVE $msgid \r\n");
+ $result = $this->gline();
+ if ($message && ($result{0}=="3")) {
+ $this->pline("$message\r\n.\r\n");
+ $result = $this->gline();
+ }
+ return ($result{0}=="2");
+ }
+
+ /** closes connection to server
+ */
+
+ function quit()
+ {
+ $this->pline("QUIT\r\n");
+ $this->gline();
+ fclose($this->ns);
+ }
+
+# NNTP Extensions [RFC 2980]
+
+ /** Returns the date on the remote server
+ * @return INTEGER timestamp
+ */
+
+ function date()
+ {
+ $this->pline("DATE \r\n");
+ $result = $this->gline();
+ if (preg_match("/^111 (\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/", $result, $r)) {
+ return gmmktime($r[4], $r[5], $r[6], $r[2], $r[3], $r[1]);
+ }
+ return false;
+ }
+
+ /** returns group descriptions
+ * @param $_pattern STRING pattern of intersting groups
+ * @return ARRAY group name => description
+ */
+
+ function xgtitle($_pattern="*")
+ {
+ $pattern = preg_replace("/[\r\n]/", "", $_pattern);
+ $this->pline("XGTITLE $pattern \r\n");
+ if (substr($this->gline(), 0, 1)!="2") return false;
+ $result = $this->gline();
+ while ($result != ".") {
+ preg_match("/([^ \t]+)[ \t]+(.+)$/", $result, $regs);
+ $array[$regs[1]] = $regs[2];
+ $result = $this->gline();
+ }
+ return $array;
+ }
+
+ /** obtain the header field $hdr for all the messages specified
+ * @param $_hdr STRING name of the header (eg: 'From')
+ * @param $_range STRING range of articles
+ * @return ARRAY MSGNUM => header value
+ */
+
+ function xhdr($_hdr, $_range="")
+ {
+ $hdr = preg_replace("/(\r|\n)/", "", $_hdr);
+ $range = preg_replace("/(\r|\n)/", "", $_range);
+ $this->pline("XHDR $hdr $range \r\n");
+ if (substr($this->gline(), 0, 1)!="2") {
+ return false;
+ }
+
+ $array = array();
+ while (($result = $this->gline()) != '.') {
+ preg_match("/([^ \t]+) (.*)$/", $result, $regs);
+ $array[$regs[1]] = $regs[2];
+ }
+ return $array;
+ }
+
+ /** obtain the header field $_hdr matching $_pat for all the messages specified
+ * @param $_hdr STRING name of the header (eg: 'From')
+ * @param $_range STRING range of articles
+ * @param $_pat STRING pattern
+ * @return ARRAY MSGNUM => header value
+ */
+
+ function xpat($_hdr, $_range, $_pat)
+ {
+ $hdr = preg_replace("/(\r|\n)/", "", $_hdr);
+ $range = preg_replace("/(\r|\n)/", "", $_range);
+ $pat = preg_replace("/(\r|\n)/", "", $_pat);
+ $this->pline("XPAT $hdr $range $pat\r\n");
+ if (substr($this->gline(), 0, 1)!="2") {
+ return false;
+ }
+ $result = $this->gline();
+ while ($result != ".") {
+ preg_match("/([^ \t]+) (.*)$/", $result, $regs);
+ $array[$regs[1]] = $regs[2];
+ $result = $this->gline();
+ }
+ return $array;
+ }
+}
+
+?>
--- /dev/null
+<?php
+/********************************************************************************
+* install.d/config.inc.php : configuration file
+* --------------------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+class Banana
+{
+ var $maxspool = 3000;
+
+ var $hdecode = array('from','name','organization','subject');
+ var $parse_hdr = array('content-disposition', 'content-transfer-encoding', 'content-type', 'date', 'followup-to', 'from',
+ 'message-id', 'newsgroups', 'organization', 'references', 'subject', 'x-face');
+ var $show_hdr = array('from', 'subject', 'newsgroups', 'followup', 'date', 'organization', 'references', 'x-face');
+
+ /** Favorites MIMEtypes to use, by order for reading multipart messages
+ */
+ var $body_mime = array('text/plain', 'text/html', 'text/richtext');
+ /** Indicate wether posting attachment is allowed
+ */
+ var $can_attach = true;
+ /** Maximum allowed file size for attachment
+ */
+ var $maxfilesize = 100000;
+ /** Indicate wether x-face should be skinned as specials data or not
+ */
+ var $formatxface = true;
+
+ /** Regexp for selecting newsgroups to show (if empty, match all newsgroups)
+ * ex : '^xorg\..*' for xorg.*
+ */
+ var $grp_pattern;
+
+ var $tbefore = 5;
+ var $tafter = 5;
+ var $tmax = 50;
+
+ var $wrap = 74;
+ /** Match an url
+ * Should be included in a regexp delimited using ! (eg: "!$url_regexp!i")
+ * If it matches, return 3 main parts :
+ * \\1 and \\3 are delimiters
+ * \\2 is the url
+ *
+ * eg : preg_match("!$url_regexp!i", "[http://www.polytechnique.org]", $matches);
+ * $matches[1] = "["
+ * $matches[2] = "http://www.polytechnique.org"
+ * $matches[3] = "]"
+ */
+ var $url_regexp = '(["\[])?((?:https?|ftp|news)://(?:&|,?[a-z@0-9.~%$£µ&i#\-+=_/\?])*)(["\]])?';
+
+
+ /** Boundary for multipart messages
+ */
+ var $boundary = 'bananaBoundary42';
+ /** Global headers to use for messages
+ */
+ var $custom = "Mime-Version: 1.0\nUser-Agent: Banana @VERSION@\n";
+ /** Global headers to use from multipart messages
+ */
+ var $custom_mp = "Content-Type: multipart/mixed; boundary=\"bananaBoundary42\"\nContent-Transfer-Encoding: 7bit\n";
+ /** Body type when using plain text
+ */
+ var $custom_plain= "Content-Type: text/plain; charset=utf-8\nContent-Transfert-Encoding: 8bit\n";
+
+ /** News serveur to use
+ */
+ var $host = 'news://localhost:119/';
+
+ /** User profile
+ */
+ var $profile = Array( 'name' => 'Anonymous <anonymouse@example.com>', 'sig' => '', 'org' => '',
+ 'customhdr' =>'', 'display' => 0, 'lastnews' => 0, 'locale' => 'fr_FR', 'subscribe' => array());
+
+ var $state = Array('group' => null, 'artid' => null);
+ var $nntp;
+ var $groups;
+ var $newgroups;
+ var $post;
+ var $spool;
+
+ function Banana()
+ {
+ $this->_require('NetNNTP');
+ setlocale(LC_ALL, $this->profile['locale']);
+ $this->nntp = new nntp($this->host);
+ if (!$this->nntp || !$this->nntp->valid) {
+ $this->nntp = null;
+ }
+ }
+
+ function run($class = 'Banana')
+ {
+ global $banana;
+
+ Banana::_require('misc');
+ $banana = new $class();
+
+ if (!$banana->nntp) {
+ return '<p class="error">'._b_('Impossible de contacter le serveur').'</p>';
+ }
+
+ $group = empty($_GET['group']) ? null : strtolower($_GET['group']);
+ $artid = empty($_GET['artid']) ? null : strtolower($_GET['artid']);
+ $partid = !isset($_GET['part']) ? -1 : $_GET['part'];
+ $banana->state = Array ('group' => $group, 'artid' => $artid);
+
+ if (is_null($group)) {
+ if (isset($_GET['subscribe'])) {
+ return $banana->action_listSubs();
+ } elseif (isset($_POST['subscribe'])) {
+ $banana->action_saveSubs();
+ }
+ return $banana->action_listGroups();
+
+ } elseif (is_null($artid)) {
+ if (isset($_POST['action']) && $_POST['action'] == 'new') {
+ return $banana->action_doFup($group, isset($_POST['artid']) ? intval($_POST['artid']) : -1);
+ } elseif (isset($_GET['action']) && $_GET['action'] == 'new') {
+ return $banana->action_newFup($group);
+ } else {
+ return $banana->action_showThread($group, isset($_GET['first']) ? intval($_GET['first']) : 1);
+ }
+
+ } else {
+ if (isset($_POST['action']) && $_POST['action']=='cancel') {
+ $res = $banana->action_cancelArticle($group, $artid);
+ } else {
+ $res = '';
+ }
+
+ if (isset($_GET['action'])) {
+ switch ($_GET['action']) {
+ case 'cancel':
+ $res .= $banana->action_showArticle($group, $artid, $partid);
+ if ($banana->post->checkcancel()) {
+ $form = '<p class="error">'._b_('Voulez-vous vraiment annuler ce message ?').'</p>'
+ . "<form action=\"?group=$group&artid=$artid\" method='post'><p>"
+ . '<input type="hidden" name="action" value="cancel" />'
+ . '<input type="submit" value="Annuler !" />'
+ . '</p></form>';
+ return $form.$res;
+ }
+ return $res;
+
+ case 'new':
+ return $banana->action_newFup($group, $artid);
+ }
+ }
+
+ if (isset($_GET['pj'])) {
+ $action = false;
+ if (isset($_GET['action']) && $_GET['action'] == 'view') {
+ $action = true;
+ }
+ $att = $banana->action_getAttachment($group, $artid, $_GET['pj'], $action);
+ if ($att != "") {
+ return $res.$att;
+ }
+ return "";
+ }
+
+ return $res . $banana->action_showArticle($group, $artid, $partid);
+ }
+ }
+
+ /**************************************************************************/
+ /* actions */
+ /**************************************************************************/
+
+ function action_saveSubs()
+ {
+ return;
+ }
+
+ function action_listGroups()
+ {
+ $this->_newGroup();
+
+ $cuts = displayshortcuts();
+ $res = '<h1>'._b_('Les forums de Banana').'</h1>'.$cuts.$this->groups->to_html();
+ if (count($this->newgroups->overview)) {
+ $res .= '<p>'._b_('Les forums suivants ont été créés depuis ton dernier passage :').'</p>';
+ $res .= $this->newgroups->to_html();
+ }
+
+ $this->nntp->quit();
+ return $res.$cuts;
+ }
+
+ function action_listSubs()
+ {
+ $this->_require('groups');
+ $this->groups = new BananaGroups(BANANA_GROUP_ALL);
+
+ $cuts = displayshortcuts();
+ $res = '<h1>'._b_('Abonnements').'</h1>'.$cuts.$this->groups->to_html(true).$cuts;
+
+ $this->nntp->quit();
+ return $res;
+ }
+
+ function action_showThread($group, $first)
+ {
+ if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) {
+ return '<p class="error">'._b_('Impossible charger la liste des messages').'</p>';
+ }
+
+ if ($first > count($this->spool->overview)) {
+ $first = count($this->spool->overview);
+ }
+
+ $first = $first - ($first % $this->tmax) + 1;
+
+ $cuts = displayshortcuts($first);
+
+ $res = '<h1>'.$group.'</h1>'.$cuts;
+ $res .= $this->spool->to_html($first, $first+$this->tmax);
+
+ $this->nntp->quit();
+
+ return $res.$cuts;
+ }
+
+ function action_showArticle($group, $id, $part)
+ {
+ if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) {
+ return '<p class="error">'._b_('Impossible charger la liste des messages').'</p>';
+ }
+
+ if (!$this->_newPost($id)) {
+ if ($this->nntp->lasterrorcode == "423") {
+ $this->spool->delid($id);
+ }
+ $this->nntp->quit();
+ return displayshortcuts().'<p class="error">'._b_('Impossible d\'accéder au message. Le message a peut-être été annulé').'</p>';
+ }
+
+ $cuts = displayshortcuts();
+ $res = '<h1>'._b_('Message').'</h1>'.$cuts;
+ $res .= $this->post->to_html($part);
+
+ $this->nntp->quit();
+
+ return $res.$cuts;
+ }
+
+ function action_getAttachment($group, $id, $pjid, $action)
+ {
+ if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) {
+ return '<p class="error">'._b_('Impossible charger la liste des messages').'</p>';
+ }
+
+ if (!$this->_newPost($id)) {
+ if ($this->nntp->lasterrorcode == "423") {
+ $this->spool->delid($id);
+ }
+ $this->nntp->quit();
+ return displayshortcuts().'<p class="error">'._b_('Impossible d\'accéder au message. Le message a peut-être été annulé').'</p>';
+ }
+
+ $this->nntp->quit();
+ if ($this->post->get_attachment($pjid, $action)) {
+ return "";
+ } else {
+ return displayshortcuts().'<p calss="error">'._b_('Impossible d\'accéder à la pièce jointe.').'</p>';
+ }
+ }
+
+ function action_cancelArticle($group, $id)
+ {
+ if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) {
+ return '<p class="error">'._b_('Impossible charger la liste des messages').'</p>';
+ }
+
+ if (!$this->_newPost($id)) {
+ return '<p class="error">'._b_('Impossible de trouver le message à annuler').'</p>';
+ }
+ $mid = array_search($id, $this->spool->ids);
+
+ if (!$this->post->checkcancel()) {
+ return '<p class="error">'._b_('Vous n\'avez pas les permissions pour annuler ce message').'</p>';
+ }
+ $msg = 'From: '.$this->profile['name']."\n"
+ . "Newsgroups: $group\n"
+ . "Subject: cmsg $mid\n"
+ . $this->custom
+ . "Control: cancel $mid\n"
+ . "\n"
+ . "Message canceled with Banana";
+ if ($this->nntp->post($msg)) {
+ $this->spool->delid($id);
+ $this->nntp->quit();
+ header("Location: ?group=$group&first=$id");
+ } else {
+ return '<p class="error">'._b_('Impossible d\'annuler le message').'</p>';
+ }
+ }
+
+ function action_newFup($group, $id = -1)
+ {
+ $subject = $body = '';
+ $target = $group;
+
+ if ($id > 0) {
+ $this->nntp->group($group);
+ if ($this->_newPost($id)) {
+ $subject = preg_replace("/^re\s*:\s*/i", '', 'Re: '.$this->post->headers['subject']);
+ $body = utf8_encode($this->post->name." "._b_("a écrit"))." :\n".wrap($this->post->get_body(), "> ");
+ $target = isset($this->post->headers['followup-to']) ? $this->post->headers['followup-to'] : $this->post->headers['newsgroups'];
+ }
+ }
+
+ $this->nntp->quit();
+
+ $cuts = displayshortcuts();
+ $html = '<h1>'._b_('Nouveau message').'</h1>'.$cuts;
+ $html .= '<form enctype="multipart/form-data" action="?group='.$group.'" method="post" accept-charset="utf-8">';
+ $html .= '<table class="bicol" cellpadding="0" cellspacing="0">';
+ $html .= '<tr><th colspan="2">'._b_('En-têtes').'</th></tr>';
+ $html .= '<tr><td>'._b_('Nom').'</td><td>'.htmlentities($this->profile['name']).'</td></tr>';
+ $html .= '<tr><td>'._b_('Sujet').'</td><td><input type="text" name="subject" value="'.htmlentities($subject).'" size="60" /></td></tr>';
+ $html .= '<tr><td>'._b_('Forums').'</td><td><input type="text" name="newsgroups" value="'.htmlentities($target).'" size="60" /></td></tr>';
+ $html .= '<tr><td>'._b_('Suivi à ').'</td><td><input type="text" name="followup" value="" size="60" /></td></tr>';
+ $html .= '<tr><td>'._b_('Organisation').'</td><td>'.$this->profile['org'].'</td></tr>';
+ $html .= '<tr><th colspan="2">'._b_('Corps').'</th></tr>';
+ $html .= '<tr><td colspan="2"><textarea name="body" cols="74" rows="16">'
+ . to_entities($body).($this->profile['sig'] ? "\n\n-- \n".htmlentities($this->profile['sig']) : '').'</textarea></td></tr>';
+ if ($this->can_attach) {
+ $html .= '<tr><th colspan="2">'._b_('Pièce jointe').'</th></tr>';
+ $html .= '<tr><td colspan="2"><input type="hidden" name="MAX_FILE_SIZE" value="'.$this->maxfilesize.'" />';
+ $html .= '<input type="file" name="newpj" size="40"/></td></tr>';
+ }
+ $html .= '<tr><th colspan="2">';
+ if ($id > 0) {
+ $html .= '<input type="hidden" name="artid" value="'.$id.'" />';
+ }
+ $html .= '<input type="hidden" name="action" value="new" />';
+ $html .= '<input type="submit" value="Envoyer le message" /></th></tr>';
+ $html .= '</table></form>';
+
+ return $html.$cuts;
+ }
+
+ function action_doFup($group, $artid = -1)
+ {
+ if ( ! ( is_utf8($_POST['subject']) && is_utf8($_POST['name'])
+ && is_utf8($_POST['org']) && is_utf8($_POST['body']) )
+ ) {
+ foreach(array('subject', 'name', 'org', 'body') as $key) {
+ $_POST[$key] = utf8_encode($_POST[$key]);
+ }
+ }
+
+ $to = preg_replace('/\s*(,|;)\s*/', ',', $_POST['newsgroups']);
+ if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) {
+ return '<p class="error">'._b_('Impossible charger la liste des messages').'</p>';
+ }
+
+ $body = preg_replace("/\n\.[ \t\r]*\n/m", "\n..\n", $_POST['body']);
+ $msg = 'From: '.$this->profile['name']."\n"
+ . "Newsgroups: ". $to . "\n"
+ . "Subject: ".headerEncode($_POST['subject'], 128)."\n"
+ . (empty($this->profile['org']) ? '' : "Organization: {$this->profile['org']}\n")
+ . (empty($_POST['followup']) ? '' : 'Followup-To: '.$_POST['followup']."\n");
+
+ if ($artid != -1) {
+ $this->_require('post');
+ $post = new BananaPost($artid);
+ if (!$post || !$post->valid) {
+ return '<p class="error">'._b_('Impossible charger le message d\'origine').'</p>';
+ }
+ $refs = ( isset($post->headers['references']) ? $post->headers['references']." " : "" );
+ $msg .= "References: $refs{$post->headers['message-id']}\n";
+ }
+
+ $body_headers = $this->custom_plain;
+ $body = wrap($body, "");
+
+ // include attachment in the body
+ $uploaded = $this->_upload('newpj');
+ switch ($uploaded['error']) {
+ case UPLOAD_ERR_OK:
+ $this->custom = $this->custom_mp.$this->custom;
+ $body = $this->_make_part($body_headers, $body);
+ $file_head = 'Content-Type: '.$uploaded['type'].'; name="'.$uploaded['name']."\"\n"
+ . 'Content-Transfer-Encoding: '.$uploaded['encoding']."\n"
+ . 'Content-Disposition: attachment; filename="'.$uploaded['name']."\"\n";
+ $body .= $this->_make_part($file_head, $uploaded['data']);
+ $body .= "\n--".$this->boundary.'--';
+ break;
+
+ case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE:
+ return '<p class="error">'._b_('Fichier trop gros pour être envoyé : ')
+ .$uploaded['name'].'</p>'.$this->action_showThread($group, $artid);
+
+ case UPLOAD_ERR_PARTIAL:
+ return '<p class="error">'._b_('Erreur lors de l\'upload de ')
+ .$uploaded['name'].'</p>'.$this->action_showThread($group, $artid);
+
+ case UPLOAD_ERR_NO_FILE:
+ return '<p class="error">'._b_('Le fichier spécifié n\'existe pas : ')
+ .$uploaded['name'].'</p>'.$this->action_showThread($group, $artid);
+
+ case UPLOAD_ERR_NO_TMP_DIR:
+ return '<p class="error">'._b_('Une erreur est survenue sur le serveur lors de l\'upload de ')
+ .$uploaded['name'].'</p>'.$this->action_showThread($group, $artid);
+
+ default:
+ $this->custom = $body_headers.$this->custom;
+ }
+
+ // finalise and post the message
+ $msg .= $this->custom.$this->profile['customhdr']."\n".$body;
+
+ if ($this->nntp->post($msg)) {
+ header("Location: ?group=$group".($artid==-1 ? '' : "&first=$artid"));
+ } else {
+ return "<p class=\"error\">"._b_('Impossible de poster le message')."</p>".$this->action_showThread($group, $artid);
+ }
+ }
+
+ /**************************************************************************/
+ /* Private functions */
+ /**************************************************************************/
+
+ function _newSpool($group, $disp=0, $since='') {
+ $this->_require('spool');
+ if (!$this->spool || $this->spool->group != $group) {
+ $this->spool = new BananaSpool($group, $disp, $since);
+ if (!$this->spool || !$this->spool->valid) {
+ $this->spool = null;
+ return false;
+ }
+ }
+ return true;
+ }
+
+ function _newPost($id)
+ {
+ $this->_require('post');
+ $this->post = new BananaPost($id);
+ if (!$this->post || !$this->post->valid) {
+ $this->post = null;
+ return false;
+ }
+ return true;
+ }
+
+ function _newGroup()
+ {
+ $this->_require('groups');
+ $this->groups = new BananaGroups(BANANA_GROUP_SUB);
+ if ($this->groups->type == BANANA_GROUP_SUB) {
+ $this->newgroups = new BananaGroups(BANANA_GROUP_NEW);
+ }
+ }
+
+ function _require($file)
+ {
+ require_once (dirname(__FILE__).'/'.$file.'.inc.php');
+ }
+
+ function _upload($file)
+ {
+ if ($_FILES[$file]['name'] == "") {
+ return Array( 'error' => -1 );
+ }
+
+ // upload
+ $_FILES[$file]['tmp_name'];
+
+ // test if upload is ok
+ $file = $_FILES[$file];
+ if ($file['size'] == 0 || $file['error'] != 0) {
+ if ($file['error'] == 0) {
+ $file['error'] = -1;
+ }
+ return $file;
+ }
+
+ // adding custum data
+ $mime = rtrim(shell_exec('file -bi '.$file['tmp_name'])); //Because mime_content_type don't work :(
+ $encod = 'base64';
+ if (preg_match("@([^ ]+/[^ ]+); (.*)@", $mime, $format)) {
+ $mime = $format[1];
+ $encod = $format[2];
+ }
+ $data = fread(fopen($file['tmp_name'], 'r'), $file['size']);
+ if ($encod == 'base64') {
+ $data = chunk_split(base64_encode($data));
+ }
+ $file['name'] = basename($file['name']);
+ $file['type'] = $mime;
+ $file['encoding'] = $encod;
+ $file['data'] = $data;
+
+ return $file;
+ }
+
+ function _make_part($headers, $body)
+ {
+ return "\n--".$this->boundary."\n".$headers."\n".$body;
+ }
+}
+
+?>
--- /dev/null
+<?php
+/********************************************************************************
+* include/groups.inc.php : class for group lists
+* ------------------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+/** class for group lists
+ */
+
+define ( 'BANANA_GROUP_ALL', 0 );
+define ( 'BANANA_GROUP_SUB', 1 );
+define ( 'BANANA_GROUP_NEW', 2 );
+
+class BananaGroups {
+ /** group list */
+ var $overview = Array();
+ /** last update */
+ var $date;
+
+ var $type;
+
+ /** constructor
+ */
+
+ function BananaGroups($_type = BANANA_GROUP_SUB) {
+ global $banana;
+
+ $this->type = $_type;
+ $desc = $banana->nntp->xgtitle();
+
+ $this->load();
+
+ if (empty($this->overview) && $_type == BANANA_GROUP_SUB) {
+ $this->type = BANANA_GROUP_ALL;
+ $this->load();
+ }
+ }
+
+ /** Load overviews
+ */
+ function load()
+ {
+ global $banana;
+
+ if ($this->type == BANANA_GROUP_NEW) {
+ $list = $banana->nntp->newgroups($banana->profile['lastnews']);
+ } else {
+ $list = $banana->nntp->liste();
+ if ($this->type == BANANA_GROUP_SUB) {
+ $mylist = Array();
+ foreach ($banana->profile['subscribe'] as $g) {
+ if (isset($list[$g])) {
+ $mylist[$g] = $list[$g];
+ }
+ }
+ $list = $mylist;
+ }
+ }
+
+ foreach ($list as $g=>$l) {
+ $this->overview[$g][0] = isset($desc[$g]) ? $desc[$g] : '-';
+ $this->overview[$g][1] = $l[0];
+ }
+ ksort($this->overview);
+ }
+
+ /** updates overview
+ * @param date INTEGER date of last update
+ */
+ function update($_date) {
+ global $banana;
+ $serverdate = $banana->nntp->date();
+ if (!$serverdate) $serverdate=time();
+ $newlist = $banana->nntp->newgroups($_date);
+ if (!$newlist) return false;
+ $this->date = $serverdate;
+ foreach (array_keys($newlist) as $g) {
+ $groupstat = $banana->nntp->group($g);
+ $groupdesc = $banana->nntp->xgtitle($g);
+ $this->overview[$g][0]=($groupdesc?$groupdesc:"-");
+ $this->overview[$g][1]=$groupstat[0];
+ }
+ return true;
+ }
+
+ function to_html($show_form = false)
+ {
+ global $banana;
+ if (empty($this->overview)) {
+ return;
+ }
+
+ $html = '<table class="bicol banana_group" cellspacing="0" cellpadding="2">'."\n";
+ $html .= '<tr><th>'._b_('Total').'</th><th>';
+ if ($show_form) {
+ $html .= _b_('Abo.').'</th><th>';
+ } elseif ($this->type == BANANA_GROUP_SUB) {
+ $html .= _b_('Nouveaux').'</th><th>';
+ }
+ $html .= _b_('Nom').'</th><th>'._b_('Description').'</th></tr>'."\n";
+
+ $b = true;
+ foreach ($this->overview as $g => $d) {
+ $b = !$b;
+ $ginfo = $banana->nntp->group($g);
+ $new = count($banana->nntp->newnews($banana->profile['lastnews'],$g));
+
+ $html .= '<tr class="'.($b ? 'pair' : 'impair').'">'."\n";
+ $html .= "<td class='all'>{$ginfo[0]}</td>";
+ if ($show_form) {
+ $html .= '<td class="new"><input type="checkbox" name="subscribe[]" value="'.$g.'"';
+ if (in_array($g, $banana->profile['subscribe'])) {
+ $html .= ' checked="checked"';
+ }
+ $html .= ' /></td>';
+ } elseif ($this->type == BANANA_GROUP_SUB) {
+ $html .= '<td class="new">'.($new ? $new : '-').'</td>';
+ }
+ $html .= "<td class='grp'><a href='?group=$g'>$g</a></td><td class='dsc'>{$d[0]}</td></tr>";
+ }
+
+ $html .= '</table>';
+
+ if ($show_form) {
+ return '<form method="post" action="?"><div class="center"><input type="submit" value="Valider" /></div>'
+ .$html.'<div class="center"><input type="submit" value="Valider" /></div></form>';
+ }
+
+ return $html;
+ }
+}
+
+?>
--- /dev/null
+<?php
+/********************************************************************************
+ * include/misc.inc.php : Misc functions
+ * -------------------------
+ *
+ * This file is part of the banana distribution
+ * Copyright: See COPYING files that comes with this distribution
+ ********************************************************************************/
+
+/********************************************************************************
+ * MISC
+ */
+
+function _b_($str) { return utf8_decode(dgettext('banana', utf8_encode($str))); }
+
+function to_entities($str) {
+ require_once dirname(__FILE__).'/utf8.php';
+ return utf8entities(htmlentities($str, ENT_NOQUOTES, 'UTF-8'));
+}
+
+function is_utf8($s) { return iconv('utf-8', 'utf-8', $s) == $s; }
+
+function textFormat_translate($format)
+{
+ switch (strtolower($format)) {
+ case 'plain': return _b_('Texte brut');
+ case 'richtext': return _b_('Texte enrichi');
+ case 'html': return _b_('HTML');
+ default: return $format;
+ }
+}
+
+/********************************************************************************
+ * HTML STUFF
+ * Taken from php.net
+ */
+
+/**
+ * @return string
+ * @param string
+ * @desc Strip forbidden tags and delegate tag-source check to removeEvilAttributes()
+ */
+function removeEvilTags($source)
+{
+ $allowedTags = '<h1><b><i><a><ul><li><pre><hr><blockquote><img><br><font><p><small><big><sup><sub><code><em>';
+ $source = preg_replace('|</div>|i', '<br />', $source);
+ $source = strip_tags($source, $allowedTags);
+ return preg_replace('/<(.*?)>/ie', "'<'.removeEvilAttributes('\\1').'>'", $source);
+}
+
+/**
+ * @return string
+ * @param string
+ * @desc Strip forbidden attributes from a tag
+ */
+function removeEvilAttributes($tagSource)
+{
+ $stripAttrib = 'javascript:|onclick|ondblclick|onmousedown|onmouseup|onmouseover|'.
+ 'onmousemove|onmouseout|onkeypress|onkeydown|onkeyup';
+ return stripslashes(preg_replace("/$stripAttrib/i", '', $tagSource));
+}
+
+/** Convert html to plain text
+ */
+function htmlToPlainText($res)
+{
+ $res = trim(html_entity_decode(strip_tags($res, '<div><br><p>')));
+ $res = preg_replace("@</?(br|p|div)[^>]*>@i", "\n", $res);
+ if (!is_utf8($res)) {
+ $res = utf8_encode($res);
+ }
+ return $res;
+}
+
+/********************************************************************************
+ * RICHTEXT STUFF
+ */
+
+/** Convert richtext to html
+ */
+function richtextToHtml($source)
+{
+ $tags = Array('bold' => 'b',
+ 'italic' => 'i',
+ 'smaller' => 'small',
+ 'bigger' => 'big',
+ 'underline' => 'u',
+ 'subscript' => 'sub',
+ 'superscript' => 'sup',
+ 'excerpt' => 'blockquote',
+ 'paragraph' => 'p',
+ 'nl' => 'br'
+ );
+
+ // clean unsupported tags
+ $protectedTags = '<signature><lt><comment><'.join('><', array_keys($tags)).'>';
+ $source = strip_tags($source, $protectedTags);
+
+ // convert richtext tags to html
+ foreach (array_keys($tags) as $tag) {
+ $source = preg_replace('@(</?)'.$tag.'([^>]*>)@i', '\1'.$tags[$tag].'\2', $source);
+ }
+
+ // some special cases
+ $source = preg_replace('@<signature>@i', '<br>-- <br>', $source);
+ $source = preg_replace('@</signature>@i', '', $source);
+ $source = preg_replace('@<lt>@i', '<', $source);
+ $source = preg_replace('@<comment[^>]*>((?:[^<]|<(?!/comment>))*)</comment>@i', '<!-- \1 -->', $source);
+ return removeEvilAttributes($source);
+}
+
+/********************************************************************************
+ * HEADER STUFF
+ */
+
+function _headerdecode($charset, $c, $str) {
+ $s = ($c == 'Q' || $c == 'q') ? quoted_printable_decode($str) : base64_decode($str);
+ $s = iconv($charset, 'iso-8859-15', $s);
+ return str_replace('_', ' ', $s);
+}
+
+function headerDecode($value) {
+ $val = preg_replace('/(=\?[^?]*\?[BQbq]\?[^?]*\?=) (=\?[^?]*\?[BQbq]\?[^?]*\?=)/', '\1\2', $value);
+ return preg_replace('/=\?([^?]*)\?([BQbq])\?([^?]*)\?=/e', '_headerdecode("\1", "\2", "\3")', $val);
+}
+
+function headerEncode($value, $trim = 0) {
+ if ($trim) {
+ if (strlen($value) > $trim) {
+ $value = substr($value, 0, $trim) . "[...]";
+ }
+ }
+ return "=?UTF-8?B?".base64_encode($value)."?=";
+}
+
+function header_translate($hdr) {
+ switch ($hdr) {
+ case 'from': return _b_('De');
+ case 'subject': return _b_('Sujet');
+ case 'newsgroups': return _b_('Forums');
+ case 'followup-to': return _b_('Suivi-Ã ');
+ case 'date': return _b_('Date');
+ case 'organization': return _b_('Organisation');
+ case 'references': return _b_('Références');
+ case 'x-face': return _b_('Image');
+ default:
+ if (function_exists('hook_headerTranslate')
+ && $res = hook_headerTranslate($hdr)) {
+ return $res;
+ }
+ return $hdr;
+ }
+}
+
+function formatDisplayHeader($_header,$_text) {
+ global $banana;
+ switch ($_header) {
+ case "date":
+ return formatDate($_text);
+
+ case "followup-to":
+ case "newsgroups":
+ $res = "";
+ $groups = preg_split("/[\t ]*,[\t ]*/",$_text);
+ foreach ($groups as $g) {
+ $res.="<a href='?group=$g'>$g</a>, ";
+ }
+ return substr($res,0, -2);
+
+ case "from":
+ return formatFrom($_text);
+
+ case "references":
+ $rsl = "";
+ $ndx = 1;
+ $text = str_replace("><","> <",$_text);
+ $text = preg_split("/[ \t]/",strtr($text,$banana->spool->ids));
+ $parents = preg_grep("/^\d+$/",$text);
+ $p = array_pop($parents);
+ $par_ok = Array();
+
+ while ($p) {
+ $par_ok[]=$p;
+ $p = $banana->spool->overview[$p]->parent;
+ }
+ foreach (array_reverse($par_ok) as $p) {
+ $rsl .= "<a href=\"?group={$banana->spool->group}&artid=$p\">$ndx</a> ";
+ $ndx++;
+ }
+ return $rsl;
+
+ case "x-face":
+ return '<img src="xface.php?face='.urlencode(base64_encode($_text)).'" alt="x-face" />';
+
+ default:
+ if (function_exists('hook_formatDisplayHeader')
+ && $res = hook_formatDisplayHeader($_header, $_text))
+ {
+ return $res;
+ }
+ return htmlentities($_text);
+ }
+}
+
+/********************************************************************************
+ * FORMATTING STUFF
+ */
+
+function formatDate($_text) {
+ return strftime("%A %d %B %Y, %H:%M (fuseau serveur)", strtotime($_text));
+}
+
+function fancyDate($stamp) {
+ $today = intval(time() / (24*3600));
+ $dday = intval($stamp / (24*3600));
+
+ if ($today == $dday) {
+ $format = "%H:%M";
+ } elseif ($today == 1 + $dday) {
+ $format = _b_('hier')." %H:%M";
+ } elseif ($today < 7 + $dday) {
+ $format = '%a %H:%M';
+ } else {
+ $format = '%a %e %b';
+ }
+ return strftime($format, $stamp);
+}
+
+function formatFrom($text) {
+# From: mark@cbosgd.ATT.COM
+# From: mark@cbosgd.ATT.COM (Mark Horton)
+# From: Mark Horton <mark@cbosgd.ATT.COM>
+ $mailto = '<a href="mailto:';
+
+ $result = htmlentities($text);
+ if (preg_match("/^([^ ]+)@([^ ]+)$/",$text,$regs)) {
+ $result="$mailto{$regs[1]}@{$regs[2]}\">".htmlentities($regs[1]."@".$regs[2])."</a>";
+ }
+ if (preg_match("/^([^ ]+)@([^ ]+) \((.*)\)$/",$text,$regs)) {
+ $result="$mailto{$regs[1]}@{$regs[2]}\">".htmlentities($regs[3])."</a>";
+ }
+ if (preg_match("/^\"?([^<>\"]+)\"? +<(.+)@(.+)>$/",$text,$regs)) {
+ $result="$mailto{$regs[2]}@{$regs[3]}\">".htmlentities($regs[1])."</a>";
+ }
+ return preg_replace("/\\\(\(|\))/","\\1",$result);
+}
+
+function displayshortcuts($first = -1) {
+ global $banana;
+ extract($banana->state);
+
+ $res = '<div class="banana_scuts">';
+ $res .= '[<a href="?">'._b_('Liste des forums').'</a>] ';
+ if (is_null($group)) {
+ return $res.'[<a href="?subscribe=1">'._b_('Abonnements').'</a>]</div>';
+ }
+
+ $res .= "[<a href=\"?group=$group\">$group</a>] ";
+
+ if (is_null($artid)) {
+ $res .= "[<a href=\"?group=$group&action=new\">"._b_('Nouveau message')."</a>] ";
+ if (sizeof($banana->spool->overview)>$banana->tmax) {
+ $res .= '<br />';
+ $n = intval(log(count($banana->spool->overview), 10))+1;
+ for ($ndx=1; $ndx <= sizeof($banana->spool->overview); $ndx += $banana->tmax) {
+ if ($first==$ndx) {
+ $fmt = "[%0{$n}u-%0{$n}u] ";
+ } else {
+ $fmt = "[<a href=\"?group=$group&first=$ndx\">%0{$n}u-%0{$n}u</a>] ";
+ }
+ $res .= sprintf($fmt, $ndx, min($ndx+$banana->tmax-1,sizeof($banana->spool->overview)));
+ }
+ }
+ } else {
+ $res .= "[<a href=\"?group=$group&artid=$artid&action=new\">"
+ ._b_('Répondre')."</a>] ";
+ if ($banana->post && $banana->post->checkcancel()) {
+ $res .= "[<a href=\"?group=$group&artid=$artid&action=cancel\">"
+ ._b_('Annuler ce message')."</a>] ";
+ }
+ }
+ return $res.'</div>';
+}
+
+/********************************************************************************
+ * FORMATTING STUFF : BODY
+ */
+
+function autoformat($text)
+{
+ global $banana;
+ $length = $banana->wrap;
+
+ $cmd = "echo ".escapeshellarg($text)." | perl -MText::Autoformat -e 'autoformat {left=>1, right=>$length, all=>1 };'";
+ exec($cmd, $result, $ret);
+ if ($ret != 0) {
+ $result = split("\n", $text);
+ }
+ return $result;
+}
+
+function wrap($text, $_prefix="", $_force=false)
+{
+ $parts = preg_split("/\n-- ?\n/", $text);
+ if (count($parts) >1) {
+ $sign = "\n-- \n" . array_pop($parts);
+ $text = join("\n-- \n", $parts);
+ } else {
+ $sign = '';
+ }
+
+ global $banana;
+ $url = $banana->url_regexp;
+ $length = $banana->wrap;
+ $max = $length + ($length/10);
+ $splits = split("\n", $text);
+ $result = array();
+ $next = array();
+ $format = false;
+ foreach ($splits as $line) {
+ if ($_force || strlen($line) > $max) {
+ if (preg_match("!^(.*)($url)(.*)!i", $line, $matches) && strlen($matches[2]) > $length && strlen($matches) < 900) {
+ if (strlen($matches[1]) != 0) {
+ array_push($next, rtrim($matches[1]));
+ if (strlen($matches[1]) > $max) {
+ $format = true;
+ }
+ }
+
+ if ($format) {
+ $result = array_merge($result, autoformat(join("\n", $next)));
+ } else {
+ $result = array_merge($result, $next);
+ }
+ $format = false;
+ $next = array();
+ array_push($result, $matches[2]);
+
+ if (strlen($matches[6]) != 0) {
+ array_push($next, ltrim($matches[6]));
+ if (strlen($matches[6]) > $max) {
+ $format = true;
+ }
+ }
+ } else {
+ $format = true;
+ array_push($next, $line);
+ }
+ } else {
+ array_push($next, $line);
+ }
+ }
+ if ($format) {
+ $result = array_merge($result, autoformat(join("\n", $next)));
+ } else {
+ $result = array_merge($result, $next);
+ }
+
+ return $_prefix.join("\n$_prefix", $result).($_prefix ? '' : $sign);
+}
+
+function cutlink($link)
+{
+ global $banana;
+
+ if (strlen($link) > $banana->wrap) {
+ $link = substr($link, 0, $banana->wrap - 3)."...";
+ }
+ return $link;
+}
+
+function cleanurl($url)
+{
+ $url = str_replace('@', '%40', $url);
+ return '<a href="'.$url.'" title="'.$url.'">'.cutlink($url).'</a>';
+}
+
+function formatbody($_text, $format='plain', $flowed=false)
+{
+ if ($format == 'html') {
+ $res = '<br/>'.html_entity_decode(to_entities(removeEvilTags($_text))).'<br/>';
+ } else if ($format == 'richtext') {
+ $res = '<br/>'.html_entity_decode(to_entities(richtextToHtml($_text))).'<br/>';
+ } else {
+ $res = "\n\n" . to_entities(wrap($_text, "", $flowed))."\n\n";
+ }
+
+ if ($format != 'html') {
+ global $banana;
+ $url = $banana->url_regexp;
+ $res = preg_replace("/(<|>|")/", " \\1 ", $res);
+ $res = preg_replace("!$url!ie", "'\\1'.cleanurl('\\2').'\\3'", $res);
+ $res = preg_replace('/(["\[])?(?:mailto:)?([a-z0-9.\-+_]+@[a-z0-9.\-+_]+)(["\]])?/i', '\1<a href="mailto:\2">\2</a>\3', $res);
+ $res = preg_replace("/ (<|>|") /", "\\1", $res);
+
+ if ($format == 'richtext') {
+ $format = 'html';
+ }
+ }
+
+ if ($format == 'html') {
+ $res = preg_replace("@(</p>)\n?-- ?\n?(<p[^>]*>|<br[^>]*>)@", "\\1<br/>-- \\2", $res);
+ $res = preg_replace("@<br[^>]*>\n?-- ?\n?(<p[^>]*>)@", "<br/>-- <br/>\\2", $res);
+ $res = preg_replace("@(<pre[^>]*>)\n?-- ?\n@", "<br/>-- <br/>\\1", $res);
+ $parts = preg_split("@(:?<p[^>]*>\n?-- ?\n?</p>|<br[^>]*>\n?-- ?\n?<br[^>]*>)@", $res);
+ } else {
+ while (preg_match("@(^|<pre>|\n)>@i", $res)) {
+ $res = preg_replace("@(^|<pre>|\n)((>[^\n]*\n)+)@ie",
+ "'\\1</pre><blockquote><pre>'"
+ .".stripslashes(preg_replace('@(^|<pre>|\n)>[ \\t\\r]*@i', '\\1', '\\2'))"
+ .".'</pre></blockquote><pre>'",
+ $res);
+ }
+ $res = preg_replace("@<pre>-- ?\n@", "<pre>\n-- \n", $res);
+ $parts = preg_split("/\n-- ?\n/", $res);
+ }
+
+ if (count($parts) > 1) {
+ $sign = array_pop($parts);
+ if ($format == 'html') {
+ $res = join('<br/>-- <br/>', $parts);
+ $sign = '<hr style="width: 100%; margin: 1em 0em; " />'.$sign.'<br/>';
+ } else {
+ $res = join('\n-- \n', $parts);
+ $sign = '</pre><hr style="width: 100%; margin: 1em 0em; " /><pre>'.$sign;
+ }
+ return $res.$sign;
+ } else {
+ return $res;
+ }
+}
+
+?>
--- /dev/null
+<?php
+/********************************************************************************
+* include/posts.inc.php : class for posts
+* -----------------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+/** class for posts
+ */
+
+class BananaPost
+{
+ var $id;
+ /** headers */
+ var $headers;
+ /** body */
+ var $body;
+ /** formating */
+ var $messages;
+ /** attachment */
+ var $pj;
+ /** poster name */
+ var $name;
+ /** test validity */
+ var $valid = true;
+
+ /** constructor
+ * @param $_id STRING MSGNUM or MSGID (a group should be selected in this case)
+ */
+ function BananaPost($_id)
+ {
+ global $banana;
+ $this->id = $_id;
+ $this->pj = array();
+ $this->messages = array();
+ if (!$this->_header()) {
+ $this->valid = false;
+ return null;
+ }
+
+
+ if ($body = $banana->nntp->body($_id)) {
+ $this->body = join("\n", $body);
+ } else {
+ $this->valid = false;
+ return null;
+ }
+
+ if (isset($this->headers['content-transfer-encoding'])) {
+ if (preg_match("/base64/", $this->headers['content-transfer-encoding'])) {
+ $this->body = base64_decode($this->body);
+ } elseif (preg_match("/quoted-printable/", $this->headers['content-transfer-encoding'])) {
+ $this->body = quoted_printable_decode($this->body);
+ }
+ }
+
+ if ($this->_split_multipart($this->headers, $this->body)) {
+ $this->set_body_to_part(0);
+ } else {
+ $this->_split_multipart($mpart_type[1], $mpart_boundary[1]);
+ $this->_find_uuencode();
+ if (preg_match('!charset=([^;]*)\s*(;|$)!', $this->headers['content-type'], $matches)) {
+ $this->body = iconv($matches[1], 'utf-8', $this->body);
+ } else {
+ $this->body = utf8_encode($this->body);
+ }
+ }
+ }
+
+ /** find and add uuencoded attachments
+ */
+ function _find_uuencode()
+ {
+ if (preg_match_all('@\n(begin \d+ ([^\r\n]+)\r?(?:\n(?!end)[^\n]*)*\nend)@', $this->body, $matches, PREG_SET_ORDER)) {
+ foreach ($matches as $match) {
+ $mime = trim(exec('echo '.escapeshellarg($match[1]).' | uudecode -o /dev/stdout | file -bi -'));
+ if ($mime != 'application/x-empty') {
+ $this->body = trim(str_replace($match[0], '', $this->body));
+ $body = $match[1];
+ $header['content-type'] = $mime.'; name="'.$match[2].'"';
+ $header['content-transfer-encoding'] = 'x-uuencode';
+ $header['content-disposition'] = 'attachment; filename="'.$match[2].'"';
+ $this->_add_attachment(Array('headers' => $header, 'body' => $body));
+ }
+ }
+ }
+ }
+
+ /** split multipart messages
+ * @param $type STRING multipart type description
+ * @param $boundary STRING multipart boundary identification string
+ */
+ function _split_multipart($headers, $body)
+ {
+ if (!preg_match("@multipart/([^;]+);@", $headers['content-type'], $type)) {
+ return false;
+ }
+
+ preg_match("/boundary=\"?([^ \"]+)\"?/", $headers['content-type'], $boundary);
+ $boundary = $boundary[1];
+ $type = $type[1];
+ $parts = preg_split("@\n--$boundary(--|\n)@", $body);
+ foreach ($parts as $part) {
+ $part = $this->_get_part($part);
+ $local_header = $part['headers'];
+ $local_body = $part['body'];
+ if (!$this->_split_multipart($local_header, $local_body)) {
+ $is_text = isset($local_header['content-type']) && preg_match("@text/([^;]+);@", $local_header['content-type'])
+ && (!isset($local_header['content-disposition']) || !preg_match('@attachment@', $local_header['content-disposition']));
+
+ // alternative ==> multiple formats for messages
+ if ($type == 'alternative' && $is_text) {
+ array_push($this->messages, $part);
+
+ // !alternative ==> une body, others are attachments
+ } else if ($is_text) {
+ if (count($this->messages) == 0) {
+ $this->body = $local_body;
+ foreach (array_keys($local_header) as $key) {
+ $this->header[$key] = $local_header[$key];
+ }
+ array_push($this->messages, $part);
+ } else {
+ $this->_add_attachment($part);
+ }
+ } else {
+ $this->_add_attachment($part);
+ }
+ }
+ }
+ return true;
+ }
+
+ /** extract new headers from the part
+ * @param $part STRING part of a multipart message
+ */
+ function _get_part($part)
+ {
+ global $banana;
+
+ $lines = split("\n", $part);
+ while (count($lines)) {
+ $line = array_shift($lines);
+ if ($line != "") {
+ if (preg_match('@^[\t\r ]+@', $line) && isset($hdr)) {
+ $local_headers[$hdr] .= ' '.trim($line);
+ } else {
+ list($hdr, $val) = split(":[ \t\r]*", $line, 2);
+ $hdr = strtolower($hdr);
+ if (in_array($hdr, $banana->parse_hdr)) {
+ $local_headers[$hdr] = $val;
+ }
+ }
+ } else {
+ break;
+ }
+ }
+ $local_body = join("\n", $lines);
+ if (preg_match("/quoted-printable/", $local_headers['content-transfer-encoding'])) {
+ $local_body = quoted_printable_decode($local_body);
+ }
+ return Array('headers' => $local_headers, 'body' => $local_body);
+ }
+
+ /** add an attachment
+ */
+ function _add_attachment($part)
+ {
+ $local_header = $part['headers'];
+ $local_body = $part['body'];
+
+ if ((isset($local_header['content-disposition']) && preg_match("/filename=\"?([^\"]+)\"?/", $local_header['content-disposition'], $filename))
+ || (isset($local_header['content-type']) && preg_match("/name=\"?([^\"]+)\"?/", $local_header['content-type'], $filename))) {
+ $filename = $filename[1];
+ }
+ if (!isset($filename)) {
+ $filename = "attachment".count($pj);
+ }
+
+ if (isset($local_header['content-type'])) {
+ if (preg_match("/^\\s*([^ ;]+);/", $local_header['content-type'], $mimetype)) {
+ $mimetype = $mimetype[1];
+ }
+ }
+ if (!isset($mimetype)) {
+ return false;
+ }
+
+ array_push($this->pj, Array('MIME' => $mimetype,
+ 'filename' => $filename,
+ 'encoding' => strtolower($local_header['content-transfer-encoding']),
+ 'data' => $local_body));
+ return true;
+ }
+
+ /** return body in plain text (useful for messages without a text/plain part)
+ */
+ function get_body()
+ {
+ preg_match("@text/([^;]+);@", $this->headers['content-type'], $format);
+ if ($format[1] == 'plain') {
+ return $this->body;
+ }
+ if ($format[1] == 'richtext') {
+ return htmlToPlainText(richtextToHtml($this->body));
+ } else {
+ return htmlToPlainText($this->body);
+ }
+ }
+
+ /** decode an attachment
+ * @param pjid INT id of the attachment to decode
+ * @param action BOOL action to execute : true=view, false=download
+ */
+ function get_attachment($pjid, $action = false)
+ {
+ if ($pjid >= count($this->pj)) {
+ return false;
+ } else {
+ $file = $this->pj[$pjid];
+ header('Content-Type: '.$file['MIME'].'; name="'.$file['filename'].'"');
+ if (!$action) {
+ header('Content-Disposition: attachment; filename="'.$file['filename'].'"');
+ } else {
+ header('Content-Disposition: inline; filename="'.$file['filename'].'"');
+ }
+ if ($file['encoding'] == 'base64') {
+ echo base64_decode($file['data']);
+ } else if ($file['encoding'] == 'x-uuencode') {
+ passthru('echo '.escapeshellarg($file['data']).' | uudecode -o /dev/stdout');
+ } else {
+ header('Content-Transfer-Encoding: '.$file['encoding']);
+ echo $file['data'];
+ }
+ return true;
+ }
+ }
+
+ /** set body to represent the given part
+ * @param partid INT index of the part in messages
+ */
+ function set_body_to_part($partid)
+ {
+ global $banana;
+
+ if (count($this->messages) == 0) {
+ return false;
+ }
+
+ $local_header = $this->messages[$partid]['headers'];
+ $this->body = $this->messages[$partid]['body'];
+ foreach ($banana->parse_hdr as $hdr) {
+ if (isset($local_header[$hdr])) {
+ $this->headers[$hdr] = $local_header[$hdr];
+ }
+ }
+
+ if (preg_match('!charset=([^;]*)\s*(;|$)!', $this->headers['content-type'], $matches)) {
+ $this->body = iconv($matches[1], 'utf-8', $this->body);
+ } else {
+ $this->body = utf8_encode($this->body);
+ }
+ return true;
+ }
+
+ function _header()
+ {
+ global $banana;
+ $hdrs = $banana->nntp->head($this->id);
+ if (!$hdrs) {
+ return false;
+ }
+
+ // parse headers
+ foreach ($hdrs as $line) {
+ if (preg_match("/^[\t\r ]+/", $line)) {
+ $line = ($hdr=="X-Face"?"":" ").ltrim($line);
+ if (in_array($hdr, $banana->parse_hdr)) {
+ $this->headers[$hdr] .= $line;
+ }
+ } else {
+ list($hdr, $val) = split(":[ \t\r]*", $line, 2);
+ $hdr = strtolower($hdr);
+ if (in_array($hdr, $banana->parse_hdr)) {
+ $this->headers[$hdr] = $val;
+ }
+ }
+ }
+ // decode headers
+ foreach ($banana->hdecode as $hdr) {
+ if (isset($this->headers[$hdr])) {
+ $this->headers[$hdr] = headerDecode($this->headers[$hdr]);
+ }
+ }
+
+ $this->name = $this->headers['from'];
+ $this->name = preg_replace('/<[^ ]*>/', '', $this->name);
+ $this->name = trim($this->name);
+ return true;
+ }
+
+ function checkcancel()
+ {
+ if (function_exists('hook_checkcancel')) {
+ return hook_checkcancel($this->headers);
+ }
+ return ($this->headers['from'] == $_SESSION['name']." <".$_SESSION['mail'].">");
+ }
+
+ /** convert message to html
+ * @param partid INT id of the multipart message that must be displaid
+ */
+ function to_html($partid = -1)
+ {
+ global $banana;
+
+ if (count($this->messages) > 1) {
+ if ($partid != -1) {
+ $this->set_body_to_part($partid);
+ } else {
+ // Select prefered text-format
+ foreach ($banana->body_mime as $mime) {
+ for ($id = 0 ; $id < count($this->messages) ; $id++) {
+ if (preg_match("@$mime@", $this->messages[$id]['headers']['content-type'])) {
+ $partid = $id;
+ $this->set_body_to_part($partid);
+ break;
+ }
+ }
+ if ($partid != -1) {
+ break;
+ }
+ }
+ if ($partid == -1) {
+ $partid = 0;
+ }
+ }
+ } else {
+ $partid = 0;
+ }
+
+ $res = '<table class="bicol banana_msg" cellpadding="0" cellspacing="0">';
+ $res .= '<tr><th colspan="2">'._b_('En-têtes').'</th></tr>';
+ $res .= '<tr><td class="headers"><table cellpadding="0" cellspacing="0">';
+
+ foreach ($banana->show_hdr as $hdr) {
+ if (isset($this->headers[$hdr])) {
+ $res2 = formatdisplayheader($hdr, $this->headers[$hdr]);
+ if ($res2 && ($hdr != 'x-face' || !$banana->formatxface)) {
+ $res .= '<tr><td class="hdr">'.header_translate($hdr)."</td><td class='val'>$res2</td></tr>\n";
+ } else if ($res2) {
+ $xface = $res2;
+ }
+ }
+ }
+ $res .= '</table></td><td class="xface">';
+
+ if ($xface) {
+ $res .= $xface;
+ }
+ $res .= '</td></tr>';
+
+ $res .= '<tr><th colspan="2">'._b_('Corps');
+ if (count($this->messages) > 1) {
+ for ($i = 0 ; $i < count($this->messages) ; $i++) {
+ if ($i == 0) {
+ $res .= ' : ';
+ } else {
+ $res .= ' . ';
+ }
+ preg_match("@text/([^;]+);@", $this->messages[$i]['headers']['content-type'], $format);
+ $format = textFormat_translate($format[1]);
+ if ($i != $partid) {
+ $res .= '<a href="?group='.$banana->state['group'].'&artid='.$this->id.'&part='.$i.'">'.$format.'</a>';
+ } else {
+ $res .= $format;
+ }
+ }
+ }
+ $res .= '</th></tr>';
+
+ preg_match("@text/([^;]+);@", $this->headers['content-type'], $format);
+ $format = $format[1];
+ $res .= '<tr><td colspan="2"';
+ if ($format == 'html') {
+ if (preg_match('@<body[^>]*bgcolor="?([#0-9a-f]+)"?[^>]*>@i', $this->body, $bgcolor)) {
+ $res .= ' bgcolor="'.$bgcolor[1].'"';
+ }
+ $res .= '>'.formatbody($this->body, $format);
+ } else {
+ $res .= '><pre>'.formatbody($this->body).'</pre>';
+ }
+ $res .= '</td></tr>';
+
+ if (count($this->pj) > 0) {
+ $res .= '<tr><th colspan="2">'._b_('Pièces jointes').'</th></tr>';
+ $res .= '<tr><td colspan="2">';
+ $i = 0;
+ foreach ($this->pj as $file) {
+ $res .= $file['filename'].' ('.$file['MIME'].') : ';
+ $res .= '<a href="?group='.$banana->state['group'].'&artid='.$this->id.'&pj='.$i.'">télécharger</a>';
+ $res .= ' . <a href="?group='.$banana->state['group'].'&artid='.$this->id.'&pj='.$i.'&action=view" target="_blank">aperçu</a>';
+ $res .= '<br/>';
+ $i++;
+ }
+ $res .= '</td></tr>';
+ }
+
+ $res .= '<tr><th colspan="2">'._b_('Apercu').'</th></tr>';
+ $ndx = $banana->spool->getndx($this->id);
+ $res .= '<tr><td class="thrd" colspan="2">'.$banana->spool->to_html($ndx-$banana->tbefore, $ndx+$banana->tafter, $ndx).'</td></tr>';
+
+ return $res.'</table>';
+ }
+}
+
+?>
--- /dev/null
+<?php
+/********************************************************************************
+* include/spool.inc.php : spool subroutines
+* -----------------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+if(!function_exists('file_put_contents')) {
+ function file_put_contents($filename, $data)
+ {
+ $fp = fopen($filename, 'w');
+ if(!$fp) {
+ trigger_error('file_put_contents cannot write in file '.$filename, E_USER_ERROR);
+ return;
+ }
+ fputs($fp, $data);
+ fclose($fp);
+ }
+}
+
+function spoolCompare($a,$b) { return ($b->date>=$a->date); }
+
+/** Class spoolhead
+ * class used in thread overviews
+ */
+class BananaSpoolHead
+{
+ /** date (timestamp) */
+ var $date;
+ /** subject */
+ var $subject;
+ /** author */
+ var $from;
+ /** reference of parent */
+ var $parent;
+ /** paren is direct */
+ var $parent_direct;
+ /** array of children */
+ var $children = Array();
+ /** true if post is read */
+ var $isread;
+ /** number of posts deeper in this branch of tree */
+ var $desc;
+ /** same as desc, but counts only unread posts */
+ var $descunread;
+
+ /** constructor
+ * @param $_date INTEGER timestamp of post
+ * @param $_subject STRING subject of post
+ * @param $_from STRING author of post
+ * @param $_desc INTEGER desc value (1 for a new post)
+ * @param $_read BOOLEAN true if read
+ * @param $_descunread INTEGER descunread value (0 for a new post)
+ */
+
+ function BananaSpoolHead($_date, $_subject, $_from, $_desc=1, $_read=true, $_descunread=0)
+ {
+ $this->date = $_date;
+ $this->subject = $_subject;
+ $this->from = $_from;
+ $this->desc = $_desc;
+ $this->isread = $_read;
+ $this->descunread = $_descunread;
+ }
+}
+
+/** Class spool
+ * builds and updates spool
+ */
+
+define("BANANA_SPOOL_VERSION", '0.2');
+
+class BananaSpool
+{
+ var $version;
+ /** spool */
+ var $overview;
+ /** group name */
+ var $group;
+ /** array msgid => msgnum */
+ var $ids;
+ /** thread starts */
+ var $roots;
+ /** test validity */
+ var $valid = true;
+
+ /** constructor
+ * @param $_group STRING group name
+ * @param $_display INTEGER 1 => all posts, 2 => only threads with new posts
+ * @param $_since INTEGER time stamp (used for read/unread)
+ */
+ function BananaSpool($_group, $_display=0, $_since="")
+ {
+ global $banana;
+ $this->group = $_group;
+ $groupinfo = $banana->nntp->group($_group);
+ if (!$groupinfo) {
+ $this->valid = false;
+ return null;
+ }
+
+ $this->_readFromFile();
+
+ $do_save = false;
+ $first = $banana->maxspool ? max($groupinfo[2]-$banana->maxspool, $groupinfo[1]) : $groupinfo[1];
+ $last = $groupinfo[2];
+ if ($this->version == BANANA_SPOOL_VERSION && is_array($this->overview)) {
+ if (count($this->overview)) {
+ for ($id = min(array_keys($this->overview)); $id<$first; $id++) {
+ $this->delid($id, false);
+ $do_save = true;
+ }
+ }
+ if (!empty($this->overview)) {
+ $first = max(array_keys($this->overview))+1;
+ }
+ } else {
+ unset($this->overview, $this->ids);
+ $this->version = BANANA_SPOOL_VERSION;
+ }
+
+ if ($first<=$last && $groupinfo[0]) {
+ $do_save = true;
+ $this->_updateSpool("$first-$last");
+ }
+
+ if ($do_save) { $this->_saveToFile(); }
+
+ $this->_updateUnread($_since, $_display);
+ }
+
+ function _readFromFile()
+ {
+ $file = $this->_spoolfile();
+ if (file_exists($file)) {
+ $temp = unserialize(file_get_contents($file));
+ foreach (get_object_vars($temp) as $key=>$val) {
+ $this->$key = $val;
+ }
+ }
+ }
+
+ function _saveToFile()
+ {
+ $file = $this->_spoolfile();
+ uasort($this->overview, "spoolcompare");
+
+ $this->roots = Array();
+ foreach($this->overview as $id=>$msg) {
+ if (is_null($msg->parent)) {
+ $this->roots[] = $id;
+ }
+ }
+
+ file_put_contents($file, serialize($this));
+ }
+
+ function _spoolfile()
+ {
+ global $banana;
+ $url = parse_url($banana->host);
+ $file = $url['host'].'_'.$url['port'].'_'.$this->group;
+ return dirname(dirname(__FILE__)).'/spool/'.$file;
+ }
+
+ function _updateSpool($arg)
+ {
+ global $banana;
+ $dates = array_map('strtotime', $banana->nntp->xhdr('Date', $arg));
+ $subjects = array_map('headerdecode', $banana->nntp->xhdr('Subject', $arg));
+ $froms = array_map('headerdecode', $banana->nntp->xhdr('From', $arg));
+ $msgids = $banana->nntp->xhdr('Message-ID', $arg);
+ $refs = $banana->nntp->xhdr('References', $arg);
+
+ if (is_array($this->ids)) {
+ $this->ids = array_merge($this->ids, array_flip($msgids));
+ } else {
+ $this->ids = array_flip($msgids);
+ }
+
+ foreach ($msgids as $id=>$msgid) {
+ $msg = new BananaSpoolHead($dates[$id], $subjects[$id], $froms[$id]);
+ $refs[$id] = str_replace('><', '> <', $refs[$id]);
+ $msgrefs = preg_split("/[ \t]/", strtr($refs[$id], $this->ids));
+ $parents = preg_grep('/^\d+$/', $msgrefs);
+ $msg->parent = array_pop($parents);
+ $msg->parent_direct = preg_match('/^\d+$/', array_pop($msgrefs));
+
+ if (isset($this->overview[$id])) {
+ $msg->desc = $this->overview[$id]->desc;
+ $msg->children = $this->overview[$id]->children;
+ }
+ $this->overview[$id] = $msg;
+
+ if ($p = $msg->parent) {
+ if (empty($this->overview[$p])) {
+ $this->overview[$p] = new BananaSpoolHead($dates[$p], $subjects[$p], $froms[$p], 1);
+ }
+ $this->overview[$p]->children[] = $id;
+
+ while ($p) {
+ $this->overview[$p]->desc += $msg->desc;
+ $p = $this->overview[$p]->parent;
+ }
+ }
+ }
+ }
+
+ function _updateUnread($since, $mode)
+ {
+ global $banana;
+ if (empty($since)) { return; }
+
+ if (is_array($newpostsids = $banana->nntp->newnews($since, $this->group))) {
+ if (!is_array($this->ids)) { $this->ids = array(); }
+ $newpostsids = array_intersect($newpostsids, array_keys($this->ids));
+ foreach ($newpostsids as $mid) {
+ $this->overview[$this->ids[$mid]]->isread = false;
+ $this->overview[$this->ids[$mid]]->descunread = 1;
+ $parentmid = $this->ids[$mid];
+ while (isset($parentmid)) {
+ $this->overview[$parentmid]->descunread ++;
+ $parentmid = $this->overview[$parentmid]->parent;
+ }
+ }
+
+ if (count($newpostsids)) {
+ switch ($mode) {
+ case 1:
+ foreach ($this->roots as $k=>$i) {
+ if ($this->overview[$i]->descunread==0) {
+ $this->killdesc($i);
+ unset($this->roots[$k]);
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ /** kill post and childrens
+ * @param $_id MSGNUM of post
+ */
+
+ function killdesc($_id)
+ {
+ if (sizeof($this->overview[$_id]->children)) {
+ foreach ($this->overview[$_id]->children as $c) {
+ $this->killdesc($c);
+ }
+ }
+ unset($this->overview[$_id]);
+ if (($msgid = array_search($_id, $this->ids)) !== false) {
+ unset($this->ids[$msgid]);
+ }
+ }
+
+ /** delete a post from overview
+ * @param $_id MSGNUM of post
+ */
+
+ function delid($_id, $write=true)
+ {
+ if (isset($this->overview[$_id])) {
+ if (sizeof($this->overview[$_id]->parent)) {
+ $this->overview[$this->overview[$_id]->parent]->children =
+ array_diff($this->overview[$this->overview[$_id]->parent]->children, array($_id));
+ if (sizeof($this->overview[$_id]->children)) {
+ $this->overview[$this->overview[$_id]->parent]->children =
+ array_merge($this->overview[$this->overview[$_id]->parent]->children, $this->overview[$_id]->children);
+ foreach ($this->overview[$_id]->children as $c) {
+ $this->overview[$c]->parent = $this->overview[$_id]->parent;
+ $this->overview[$c]->parent_direct = false;
+ }
+ }
+ $p = $this->overview[$_id]->parent;
+ while ($p) {
+ $this->overview[$p]->desc--;
+ $p = $this->overview[$p]->parent;
+ }
+ } elseif (sizeof($this->overview[$_id]->children)) {
+ foreach ($this->overview[$_id]->children as $c) {
+ $this->overview[$c]->parent = null;
+ }
+ }
+ unset($this->overview[$_id]);
+ $msgid = array_search($_id, $this->ids);
+ if ($msgid) {
+ unset($this->ids[$msgid]);
+ }
+
+ if ($write) { $this->_saveToFile(); }
+ }
+ }
+
+ /** displays children tree of a post
+ * @param $_id INTEGER MSGNUM of post
+ * @param $_index INTEGER linear number of post in the tree
+ * @param $_first INTEGER linear number of first post displayed
+ * @param $_last INTEGER linear number of last post displayed
+ * @param $_ref STRING MSGNUM of current post
+ * @param $_pfx_node STRING prefix used for current node
+ * @param $_pfx_end STRING prefix used for children of current node
+ * @param $_head BOOLEAN true if first post in thread
+ */
+
+ function _to_html($_id, $_index, $_first=0, $_last=0, $_ref="", $_pfx_node="", $_pfx_end="", $_head=true)
+ {
+ $spfx_f = '<img src="img/k1.gif" height="21" width="9" alt="o" />';
+ $spfx_n = '<img src="img/k2.gif" height="21" width="9" alt="*" />';
+ $spfx_Tnd = '<img src="img/T-direct.gif" height="21" width="12" alt="+" />';
+ $spfx_Lnd = '<img src="img/L-direct.gif" height="21" width="12" alt="`" />';
+ $spfx_snd = '<img src="img/s-direct.gif" height="21" width="5" alt="-" />';
+ $spfx_T = '<img src="img/T.gif" height="21" width="12" alt="+" />';
+ $spfx_L = '<img src="img/L.gif" height="21" width="12" alt="`" />';
+ $spfx_s = '<img src="img/s.gif" height="21" width="5" alt="-" />';
+ $spfx_e = '<img src="img/e.gif" height="21" width="12" alt=" " />';
+ $spfx_I = '<img src="img/I.gif" height="21" width="12"alt="|" />';
+
+ if ($_index + $this->overview[$_id]->desc < $_first || $_index > $_last) {
+ return;
+ }
+
+ $res = '';
+
+ if ($_index>=$_first) {
+ $hc = empty($this->overview[$_id]->children);
+
+ $res .= '<tr class="'.($_index%2?'pair':'impair').($this->overview[$_id]->isread?'':' new')."\">\n";
+ $res .= "<td class='date'>".fancyDate($this->overview[$_id]->date)." </td>\n";
+ $res .= "<td class='subj'>"
+ ."<div class='tree'>$_pfx_node".($hc?($_head?$spfx_f:($this->overview[$_id]->parent_direct?$spfx_s:$spfx_snd)):$spfx_n)
+ ."</div>";
+ $subject = $this->overview[$_id]->subject;
+ if (strlen($subject) == 0) {
+ $subject = _b_('(pas de sujet)');
+ }
+ if ($_index == $_ref) {
+ $res .= '<span class="cur">'.htmlentities($subject).'</span>';
+ } else {
+ $res .= "<a href='?group={$this->group}&artid=$_id'>".htmlentities($subject).'</a>';
+ }
+ $res .= "</td>\n<td class='from'>".formatFrom($this->overview[$_id]->from)."</td>\n</tr>";
+
+ if ($hc) { return $res; }
+ }
+
+ $_index ++;
+
+ $children = $this->overview[$_id]->children;
+ while ($child = array_shift($children)) {
+ if ($_index > $_last) { return $res; }
+ if ($_index+$this->overview[$child]->desc >= $_first) {
+ if (sizeof($children)) {
+ $res .= $this->_to_html($child, $_index, $_first, $_last, $_ref,
+ $_pfx_end.($this->overview[$child]->parent_direct?$spfx_T:$spfx_Tnd),
+ $_pfx_end.$spfx_I, false);
+ } else {
+ $res .= $this->_to_html($child, $_index, $_first, $_last, $_ref,
+ $_pfx_end.($this->overview[$child]->parent_direct?$spfx_L:$spfx_Lnd),
+ $_pfx_end.$spfx_e, false);
+ }
+ }
+ $_index += $this->overview[$child]->desc;
+ }
+
+ return $res;
+ }
+
+ /** Displays overview
+ * @param $_first INTEGER MSGNUM of first post
+ * @param $_last INTEGER MSGNUM of last post
+ * @param $_ref STRING MSGNUM of current/selectionned post
+ */
+
+ function to_html($_first=0, $_last=0, $_ref = null)
+ {
+ $res = '<table class="bicol banana_thread" cellpadding="0" cellspacing="0">';
+
+ if (is_null($_ref)) {
+ $res .= '<tr><th>'._b_('Date').'</th>';
+ $res .= '<th>'._b_('Sujet').'</th>';
+ $res .= '<th>'._b_('Auteur').'</th></tr>';
+ }
+
+ $index = 1;
+ if (sizeof($this->overview)) {
+ foreach ($this->roots as $id) {
+ $res .= $this->_to_html($id, $index, $_first, $_last, $_ref);
+ $index += $this->overview[$id]->desc ;
+ if ($index > $_last) { break; }
+ }
+ } else {
+ $res .= '<tr><td colspan="3">'._b_('Aucun message dans ce forum').'</td></tr>';
+ }
+
+ return $res .= '</table>';
+ }
+
+ /** computes linear post index
+ * @param $_id INTEGER MSGNUM of post
+ * @return INTEGER linear index of post
+ */
+
+ function getndx($_id)
+ {
+ $ndx = 1;
+ $id_cur = $_id;
+ while (true) {
+ $id_parent = $this->overview[$id_cur]->parent;
+ if (is_null($id_parent)) break;
+ $pos = array_search($id_cur, $this->overview[$id_parent]->children);
+
+ for ($i = 0; $i < $pos ; $i++) {
+ $ndx += $this->overview[$this->overview[$id_parent]->children[$i]]->desc;
+ }
+ $ndx++; //noeud père
+
+ $id_cur = $id_parent;
+ }
+
+ foreach ($this->roots as $i) {
+ if ($i==$id_cur) {
+ break;
+ }
+ $ndx += $this->overview[$i]->desc;
+ }
+ return $ndx;
+ }
+}
+
+?>
--- /dev/null
+<?php\r
+/********************************************************************************\r
+* banana/utf8.php : utf8 to html entities\r
+* ---------------\r
+*\r
+* This file is part of the banana distribution\r
+* Copyright: See COPYING files that comes with this distribution\r
+********************************************************************************/\r
+\r
+function utf8entities($source)\r
+{\r
+ // array used to figure what number to decrement from character order value \r
+ // according to number of characters used to map unicode to ascii by utf-8\r
+ $decrement[4] = 240;\r
+ $decrement[3] = 224;\r
+ $decrement[2] = 192;\r
+ $decrement[1] = 0;\r
+ \r
+ // the number of bits to shift each charNum by\r
+ $shift[1][0] = 0;\r
+ $shift[2][0] = 6;\r
+ $shift[2][1] = 0;\r
+ $shift[3][0] = 12;\r
+ $shift[3][1] = 6;\r
+ $shift[3][2] = 0;\r
+ $shift[4][0] = 18;\r
+ $shift[4][1] = 12;\r
+ $shift[4][2] = 6;\r
+ $shift[4][3] = 0;\r
+ \r
+ $pos = 0;\r
+ $len = strlen($source);\r
+ $encodedString = '';\r
+ while ($pos < $len)\r
+ {\r
+ $charPos = $source{$pos};\r
+ $asciiPos = ord($charPos);\r
+ if ($asciiPos < 128)\r
+ {\r
+ $encodedString .= $charPos;\r
+ $pos++;\r
+ continue;\r
+ }\r
+ \r
+ $i=1;\r
+ if (($asciiPos >= 240) && ($asciiPos <= 255)) // 4 chars representing one unicode character\r
+ $i=4;\r
+ else if (($asciiPos >= 224) && ($asciiPos <= 239)) // 3 chars representing one unicode character\r
+ $i=3;\r
+ else if (($asciiPos >= 192) && ($asciiPos <= 223)) // 2 chars representing one unicode character\r
+ $i=2;\r
+ else // 1 char (lower ascii)\r
+ $i=1;\r
+ $thisLetter = substr($source, $pos, $i);\r
+ $pos += $i;\r
+ \r
+ // process the string representing the letter to a unicode entity\r
+ $thisLen = strlen($thisLetter);\r
+ $thisPos = 0;\r
+ $decimalCode = 0;\r
+ while ($thisPos < $thisLen)\r
+ {\r
+ $thisCharOrd = ord(substr($thisLetter, $thisPos, 1));\r
+ if ($thisPos == 0)\r
+ {\r
+ $charNum = intval($thisCharOrd - $decrement[$thisLen]);\r
+ $decimalCode += ($charNum << $shift[$thisLen][$thisPos]);\r
+ }\r
+ else\r
+ {\r
+ $charNum = intval($thisCharOrd - 128);\r
+ $decimalCode += ($charNum << $shift[$thisLen][$thisPos]);\r
+ }\r
+ \r
+ $thisPos++;\r
+ }\r
+ \r
+ $encodedLetter = '&#'. str_pad($decimalCode, ($thisLen==1)?3:5, '0', STR_PAD_LEFT).';';\r
+ $encodedString .= $encodedLetter;\r
+ }\r
+ \r
+ return $encodedString;\r
+}\r
+\r
+?>\r
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2003-2004 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * 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 *
+ ***************************************************************************/
+
+body {
+ font-family:"Trebuchet MS",Verdana,Geneva,Arial,Helvetica,sans-serif;
+ margin:2em 1%;
+ padding:0;
+}
+
+div.bloc { width: 800px; margin-left: auto; margin-right: auto; }
+
+div.foot {
+ border-top: 1px solid #a2c2e1;
+ padding-top: 1em;
+ margin-top: 1em;
+}
+
+a:link, a:visited { color: #f60; background: transparent; }
+a:active, a:hover { color: #369; background: transparent; }
+
+hr { border: none; border-top: 1px dotted #a2c2e1; }
+
+h1 {
+ color: #369;
+ background: inherit;
+ font-size: 200%;
+ text-align: center;
+ margin: 0em;
+ border-bottom: 2px solid #369;
+ padding: 4px;
+ margin: 1em 0em;
+}
+
+table.bicol {
+ border-collapse: collapse;
+ border: 1px solid #a2c2e1;
+ width: 100%;
+}
+
+table.bicol tr.impair { }
+table.bicol tr.pair { color: inherit; background: #eee; }
+
+table.bicol th {
+ color: #369;
+ background: #d6e1ec;
+ padding: 0px 4px;
+}
+
+table.bicol td { padding: 0px 4px; }
+
--- /dev/null
+/********************************************************************************
+* css/style.css : Default css
+* ---------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+div.banana_scuts { text-align: left; padding: 0.5em 0em; }
+
+/** GROUP LIST **/
+
+table.banana_group td.new { text-align: center; }
+table.banana_group td.all { text-align: center; }
+table.banana_group td.grp { text-align: left; }
+table.banana_group td.dsc { text-align: left; }
+
+/** THREAD VIEW **/
+
+table.banana_thread td { white-space: nowrap; height: 100%; vertical-align: middle; }
+
+table.banana_thread tr.new { font-weight: bold; }
+
+table.banana_thread td.date { width: 15%; text-align: center; }
+table.banana_thread td.subj { text-align: left; overflow: hidden; }
+table.banana_thread td.from { text-align: left; }
+
+table.banana_thread div.tree { float: left; padding-right: 0.3em; }
+table.banana_thread span.cur { font-style: italic; font-size: 90%; }
+
+/** MESSAGE VIEW **/
+
+table.banana_msg td.headers { width: 100%; }
+table.banana_msg .hdr { width: 15%; text-align: right; font-weight: bold; padding-right: 1em; }
+table.banana_msg td.xface { text-align: right; }
+
+table.banana_msg td.thrd { padding: 0px; }
+table.banana_msg table { border: 0px; padding: 0px; margin: 0px; width: 100%; }
+
+table.banana_msg blockquote {
+ color: blue;
+ font-style: italic;
+ margin-left: 0;
+ padding-left: 1em;
+ border-left: solid 1px;
+ border-color: blue;
+}
+table.banana_msg blockquote blockquote {
+ color: green;
+ border-color: green;
+}
+table.banana_msg blockquote blockquote blockquote {
+ color: #cc0000;
+ border-color: #cc0000;
+}
+
+/** MISC **/
+
+div.center { text-align: center; padding: 1em; }
+p.error { color: red; background: inherit; }
+
--- /dev/null
+banana (1.3-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Pierre Habouzit <madcoder@debian.org> Sun, 18 Jun 2006 17:32:27 +0200
+
+banana (1.2-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Pierre Habouzit <madcoder@debian.org> Wed, 19 Oct 2005 20:00:06 +0200
+
+banana (1.1-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Pierre Habouzit <madcoder@debian.org> Tue, 24 May 2005 09:13:39 +0200
+
+banana (1.0-1) unstable; urgency=low
+
+ * First upstream release.
+
+ -- Pierre Habouzit <pierre.habouzit@m4x.org> Wed, 19 Jan 2005 21:55:41 +0100
+
--- /dev/null
+Source: banana
+Section: web
+Priority: optional
+Maintainer: Pierre Habouzit <madcoder@debian.org>
+Standards-Version: 3.6.1
+Build-Depends-Indep: cdbs, debhelper (>= 4.1.16)
+
+Package: php-banana
+Architecture: all
+Depends: php4-cli
+Recommends: compface, imagemagick
+Description: php library aimed to write NNTP <-> Web gateways
+ .
+ Homepage: http://opensource.polytechnique.org/banana/
+
--- /dev/null
+This package was debianized by Pierre Habouzit <pierre.habouzit@m4x.org> on
+Fri, 07 Jan 2005 22:40:08 +0100
+
+It was downloaded from http://opensource.polytechnique.org/banana/
+
+Upstream Author: David Bachelart
+
+* Banana is licensed under the terms of the GPL version 2
+ or later and is copyright :
+
+ (c) 2003-2004 David Bachelart.
+ (c) 2005 Pierre Habouzit.
+
+On Debian GNU/Linux systems, the complete text of the GNU General Public
+License may be found in `/usr/share/common-licenses/GPL'.
--- /dev/null
+--- /home/x2000habouzit/dev/banana/banana/spool.inc.php 2005-01-07 23:47:41.000000000 +0100
++++ banana/spool.inc.php 2005-01-07 23:46:58.000000000 +0100
+@@ -150,7 +150,7 @@
+ global $banana;
+ $url = parse_url($banana->host);
+ $file = $url['host'].'_'.$url['port'].'_'.$this->group;
+- return dirname(dirname(__FILE__)).'/spool/'.$file;
++ return "/var/spool/banana/$file";
+ }
+
+ function _updateSpool($arg)
--- /dev/null
+banana/ /usr/share/php/
+img/ /usr/share/banana/
+css/ /usr/share/banana/
+locale/ /usr/share/
--- /dev/null
+#! /bin/sh
+
+chown -R www-data /var/spool/banana
+
+#DEBHELPER#
+
+exit 0
+
--- /dev/null
+#!/bin/sh -e
+
+ACTION=$1
+case "$ACTION" in
+ purge)
+ rm -rf /var/spool/banana
+ ;;
+
+ *)
+ ;;
+esac
+
+
+#DEBHELPER#
+
+exit 0
--- /dev/null
+#!/usr/bin/make -f
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
+
+# configure simple-patchsys
+DEB_PATCHDIRS := debian/patches
+
+# documentation
+DEB_INSTALL_DOCS_ALL :=
+DEB_INSTALL_DOCS_php-banana := AUTHORS TODO examples/
+
+# changelogs
+DEB_INSTALL_CHANGELOGS_ALL :=
+DEB_INSTALL_CHANGELOGS_php-banana := Changelog
+
+#directories
+DEB_INSTALL_DIRS_php-banana := var/spool/banana/
+
+install/php-banana::
+ make
+
+clean::
+ rm -f debian/compat
+ make clean
--- /dev/null
+<?php
+/********************************************************************************
+* index.php : main page (newsgroups list)
+* -----------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+require_once("banana/banana.inc.php");
+$res = Banana::run();
+
+if ($res != "") {
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;
+ charset=iso-8859-1">
+ <meta name="description" content="WebForum2/Banana">
+ <link href="css/style.css" type="text/css" rel="stylesheet" media="screen">
+ <link href="css/banana.css" type="text/css" rel="stylesheet" media="screen">
+ <title>
+ Banana, a NNTP<->Web Gateway
+ </title>
+ </head>
+ <body>
+ <div class="bloc">
+<?php echo $res; ?>
+ <div class="foot">
+ <em>Banana</em>, a Web interface for a NNTP Server<br />
+ Developed under GPL License for <a href="http://www.polytechnique.org">Polytechnique.org</a>
+ </div>
+ </div>
+ </body>
+</html>
+<?php
+}
+?>
--- /dev/null
+#! /usr/bin/php4
+<?php
+/********************************************************************************
+ * spoolgen.php : spool generation
+ * --------------
+ *
+ * This file is part of the banana distribution
+ * Copyright: See COPYING files that comes with this distribution
+ ********************************************************************************/
+
+require_once("banana/banana.inc.php");
+
+$opt = getopt('u:p:h');
+
+if(isset($opt['h'])) {
+ echo <<<EOF
+usage: spoolgen.php [ -u user ] [ -p pass ]
+ create all spools, using user user and pass pass
+EOF;
+ exit;
+}
+
+class MyBanana extends Banana
+{
+ function MyBanana()
+ {
+ global $opt;
+ $this->host = "http://{$opt['u']}:{$opt['p']}@localhost:119/";
+ echo $this->host;
+ parent::Banana();
+ }
+
+ function createAllSpool()
+ {
+ $this->_require('groups');
+ $this->_require('spool');
+ $this->_require('misc');
+
+ $groups = new BananaGroups(BANANA_GROUP_ALL);
+
+ foreach (array_keys($groups->overview) as $g) {
+ print "Generating spool for $g : ";
+ $spool = new BananaSpool($g);
+ print "done.\n";
+ unset($spool);
+ }
+ $this->nntp->quit();
+ }
+}
+
+
+$banana = new MyBanana();
+$banana->createAllSpool();
+?>
--- /dev/null
+<?php
+
+header('Content-Type: image/jpeg');
+passthru('echo '.escapeshellarg(base64_decode($_REQUEST['face'])).'|uncompface -X |convert xbm:- jpg:-');
+
+?>
--- /dev/null
+# Horde .mo files makefile
+#
+# $Horde: horde/po/Makefile,v 1.2.2.3 2002/05/20 17:36:22 jan Exp $
+#
+
+LANGS:=$(shell ls *.po|sed -e s/\.po$$//)
+
+all: banana.pot ${LANGS:=.lang}
+
+clean:
+ rm -f *.po~ *.lang
+
+banana.pot: ../banana/*.php
+ @echo Parsing Tree for new messages
+ @echo
+ @xgettext --from-code=iso-8859-15 -j -k_b_ -o banana.pot $<
+
+%.lang: banana.pot ../banana/*.php %.po
+ @echo Generating $(@:.lang=.po)
+ @echo -n ' '
+ @mkdir -p ../locale/$(@:.lang=)/LC_MESSAGES/
+ @msgmerge -U $(@:lang=po) $< 2> /dev/null
+ @msgfmt --statistics -c -v -o ../locale/$(@:.lang=)/LC_MESSAGES/banana.mo $(@:lang=po)
+ @echo
+ @rm -f $(@:lang=po~)
+ @touch $@
+
+
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2005-10-19 19:58+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../banana/banana.inc.php:54
+msgid "Impossible de contacter le serveur"
+msgstr ""
+
+#: ../banana/banana.inc.php:93
+msgid "Voulez-vous vraiment annuler ce message ?"
+msgstr ""
+
+#: ../banana/banana.inc.php:124
+msgid "Les forums de Banana"
+msgstr ""
+
+#: ../banana/banana.inc.php:126
+msgid "Les forums suivants ont été créés depuis ton dernier passage :"
+msgstr ""
+
+#: ../banana/banana.inc.php:140 ../banana/misc.inc.php:150
+msgid "Abonnements"
+msgstr ""
+
+#: ../banana/banana.inc.php:175
+msgid "Impossible d'accéder au message. Le message a peut-être été annulé"
+msgstr ""
+
+#: ../banana/banana.inc.php:179
+msgid "Message"
+msgstr ""
+
+#: ../banana/banana.inc.php:194
+msgid "Vous n'avez pas les permissions pour annuler ce message"
+msgstr ""
+
+#: ../banana/banana.inc.php:208
+msgid "Impossible d'annuler le message"
+msgstr ""
+
+#: ../banana/banana.inc.php:222
+msgid "a écrit"
+msgstr ""
+
+#: ../banana/banana.inc.php:230 ../banana/misc.inc.php:156
+msgid "Nouveau message"
+msgstr ""
+
+#: ../banana/banana.inc.php:233 ../banana/post.inc.php:100
+msgid "En-têtes"
+msgstr ""
+
+#: ../banana/banana.inc.php:234 ../banana/groups.inc.php:93
+msgid "Nom"
+msgstr ""
+
+#: ../banana/banana.inc.php:235 ../banana/misc.inc.php:34
+#: ../banana/spool.inc.php:360
+msgid "Sujet"
+msgstr ""
+
+#: ../banana/banana.inc.php:236 ../banana/misc.inc.php:35
+msgid "Forums"
+msgstr ""
+
+#: ../banana/banana.inc.php:237
+msgid "Suivi à "
+msgstr ""
+
+#: ../banana/banana.inc.php:238 ../banana/misc.inc.php:38
+msgid "Organisation"
+msgstr ""
+
+#: ../banana/banana.inc.php:239 ../banana/post.inc.php:111
+msgid "Corps"
+msgstr ""
+
+#: ../banana/banana.inc.php:275 ../banana/banana.inc.php:283
+msgid "Impossible de poster le message"
+msgstr ""
+
+#: ../banana/groups.inc.php:87
+msgid "Total"
+msgstr ""
+
+#: ../banana/groups.inc.php:89
+msgid "Abo."
+msgstr ""
+
+#: ../banana/groups.inc.php:91
+msgid "Nouveaux"
+msgstr ""
+
+#: ../banana/groups.inc.php:93
+msgid "Description"
+msgstr ""
+
+#: ../banana/misc.inc.php:33
+msgid "De"
+msgstr ""
+
+#: ../banana/misc.inc.php:36
+msgid "Suivi-Ã "
+msgstr ""
+
+#: ../banana/misc.inc.php:37 ../banana/spool.inc.php:359
+msgid "Date"
+msgstr ""
+
+#: ../banana/misc.inc.php:39
+msgid "Références"
+msgstr ""
+
+#: ../banana/misc.inc.php:40
+msgid "Image"
+msgstr ""
+
+#: ../banana/misc.inc.php:115
+msgid "hier"
+msgstr ""
+
+#: ../banana/misc.inc.php:148
+msgid "Liste des forums"
+msgstr ""
+
+#: ../banana/misc.inc.php:171
+msgid "Répondre"
+msgstr ""
+
+#: ../banana/misc.inc.php:174
+msgid "Annuler ce message"
+msgstr ""
+
+#: ../banana/post.inc.php:114
+msgid "apercu"
+msgstr ""
+
+#: ../banana/spool.inc.php:361
+msgid "Auteur"
+msgstr ""
+
+#: ../banana/spool.inc.php:372
+msgid "Aucun message dans ce forum"
+msgstr ""
--- /dev/null
+# translation of en.po to
+# This file is distributed under the same license as the PACKAGE package.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER.
+# Pierre Habouzit <pierre.habouzit@m4x.org>, 2005.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: en\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2005-05-24 21:04+0200\n"
+"PO-Revision-Date: 2005-01-02 17:13+0100\n"
+"Last-Translator: Pierre Habouzit <pierre.habouzit@m4x.org>\n"
+"Language-Team: <en@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.9.1\n"
+
+#: ../banana/banana.inc.php:54
+msgid "Impossible de contacter le serveur"
+msgstr "Server unreachable"
+
+#: ../banana/banana.inc.php:93
+msgid "Voulez-vous vraiment annuler ce message ?"
+msgstr "Do you really want to cancel that post ?"
+
+#: ../banana/banana.inc.php:124
+msgid "Les forums de Banana"
+msgstr "Banana's Bewsgroups"
+
+#: ../banana/banana.inc.php:126
+msgid "Les forums suivants ont été créés depuis ton dernier passage :"
+msgstr "This newsgroups are recent :"
+
+#: ../banana/banana.inc.php:140 ../banana/misc.inc.php:150
+msgid "Abonnements"
+msgstr "Subscription list"
+
+#: ../banana/banana.inc.php:175
+msgid "Impossible d'accéder au message. Le message a peut-être été annulé"
+msgstr "The post is not reachable. It may have been canceled"
+
+#: ../banana/banana.inc.php:179
+msgid "Message"
+msgstr "Post"
+
+#: ../banana/banana.inc.php:194
+msgid "Vous n'avez pas les permissions pour annuler ce message"
+msgstr "You are not allowed to cancel that post"
+
+#: ../banana/banana.inc.php:208
+msgid "Impossible d'annuler le message"
+msgstr "Impossible to cancel that post"
+
+#: ../banana/banana.inc.php:222
+msgid "a écrit"
+msgstr "wrote"
+
+#: ../banana/banana.inc.php:230 ../banana/misc.inc.php:156
+msgid "Nouveau message"
+msgstr "New post"
+
+#: ../banana/banana.inc.php:233 ../banana/post.inc.php:100
+msgid "En-têtes"
+msgstr "Headers"
+
+#: ../banana/banana.inc.php:234 ../banana/groups.inc.php:93
+msgid "Nom"
+msgstr "From"
+
+#: ../banana/banana.inc.php:235 ../banana/misc.inc.php:34
+#: ../banana/spool.inc.php:360
+msgid "Sujet"
+msgstr "Subject"
+
+#: ../banana/banana.inc.php:236 ../banana/misc.inc.php:35
+msgid "Forums"
+msgstr "NewsGroups"
+
+#: ../banana/banana.inc.php:237
+msgid "Suivi à "
+msgstr "Followup To"
+
+#: ../banana/banana.inc.php:238 ../banana/misc.inc.php:38
+msgid "Organisation"
+msgstr "Organization"
+
+#: ../banana/banana.inc.php:239 ../banana/post.inc.php:111
+msgid "Corps"
+msgstr "Body"
+
+#: ../banana/banana.inc.php:275 ../banana/banana.inc.php:283
+msgid "Impossible de poster le message"
+msgstr "Impossible to post that message"
+
+#: ../banana/groups.inc.php:87
+msgid "Total"
+msgstr "Total"
+
+#: ../banana/groups.inc.php:89
+msgid "Abo."
+msgstr "Sub."
+
+#: ../banana/groups.inc.php:91
+msgid "Nouveaux"
+msgstr "New"
+
+#: ../banana/groups.inc.php:93
+msgid "Description"
+msgstr "Description"
+
+#: ../banana/misc.inc.php:33
+msgid "De"
+msgstr "From"
+
+#: ../banana/misc.inc.php:36
+msgid "Suivi-Ã "
+msgstr "Followup To"
+
+#: ../banana/misc.inc.php:37 ../banana/spool.inc.php:359
+msgid "Date"
+msgstr "Date"
+
+#: ../banana/misc.inc.php:39
+msgid "Références"
+msgstr "References"
+
+#: ../banana/misc.inc.php:40
+msgid "Image"
+msgstr "Image"
+
+#: ../banana/misc.inc.php:115
+msgid "hier"
+msgstr "yesterday"
+
+#: ../banana/misc.inc.php:148
+msgid "Liste des forums"
+msgstr "Newsgroups list"
+
+#: ../banana/misc.inc.php:171
+msgid "Répondre"
+msgstr "Answer"
+
+#: ../banana/misc.inc.php:174
+msgid "Annuler ce message"
+msgstr "Cancel post"
+
+#: ../banana/post.inc.php:114
+msgid "apercu"
+msgstr "preview"
+
+#: ../banana/spool.inc.php:361
+msgid "Auteur"
+msgstr "Author"
+
+#: ../banana/spool.inc.php:372
+msgid "Aucun message dans ce forum"
+msgstr "No post in this newsgroup"
--- /dev/null
+# translation of fr.po to
+# This file is distributed under the same license as the PACKAGE package.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER.
+# Pierre Habouzit <pierre.habouzit@m4x.org>, 2005.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: fr\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2005-05-24 21:04+0200\n"
+"PO-Revision-Date: 2005-01-02 17:13+0100\n"
+"Last-Translator: Pierre Habouzit <pierre.habouzit@m4x.org>\n"
+"Language-Team: <fr@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.9.1\n"
+
+#: ../banana/banana.inc.php:54
+msgid "Impossible de contacter le serveur"
+msgstr "Impossible de contacter le serveur"
+
+#: ../banana/banana.inc.php:93
+msgid "Voulez-vous vraiment annuler ce message ?"
+msgstr "Voulez-vous vraiment annuler ce message ?"
+
+#: ../banana/banana.inc.php:124
+msgid "Les forums de Banana"
+msgstr "Les forums de Banana"
+
+#: ../banana/banana.inc.php:126
+msgid "Les forums suivants ont été créés depuis ton dernier passage :"
+msgstr "Les forums suivants ont été créés depuis ton dernier passage :"
+
+#: ../banana/banana.inc.php:140 ../banana/misc.inc.php:150
+msgid "Abonnements"
+msgstr "Abonnements"
+
+#: ../banana/banana.inc.php:175
+msgid "Impossible d'accéder au message. Le message a peut-être été annulé"
+msgstr "Impossible d'accéder au message. Le message a peut-être été annulé"
+
+#: ../banana/banana.inc.php:179
+msgid "Message"
+msgstr "Message"
+
+#: ../banana/banana.inc.php:194
+msgid "Vous n'avez pas les permissions pour annuler ce message"
+msgstr "Vous n'avez pas les permissions pour annuler ce message"
+
+#: ../banana/banana.inc.php:208
+msgid "Impossible d'annuler le message"
+msgstr "Impossible d'annuler le message"
+
+#: ../banana/banana.inc.php:222
+msgid "a écrit"
+msgstr "a écrit"
+
+#: ../banana/banana.inc.php:230 ../banana/misc.inc.php:156
+msgid "Nouveau message"
+msgstr "Nouveau message"
+
+#: ../banana/banana.inc.php:233 ../banana/post.inc.php:100
+msgid "En-têtes"
+msgstr "En-têtes"
+
+#: ../banana/banana.inc.php:234 ../banana/groups.inc.php:93
+msgid "Nom"
+msgstr "Nom"
+
+#: ../banana/banana.inc.php:235 ../banana/misc.inc.php:34
+#: ../banana/spool.inc.php:360
+msgid "Sujet"
+msgstr "Sujet"
+
+#: ../banana/banana.inc.php:236 ../banana/misc.inc.php:35
+msgid "Forums"
+msgstr "Forums"
+
+#: ../banana/banana.inc.php:237
+msgid "Suivi à "
+msgstr "Suivi à "
+
+#: ../banana/banana.inc.php:238 ../banana/misc.inc.php:38
+msgid "Organisation"
+msgstr "Organisation"
+
+#: ../banana/banana.inc.php:239 ../banana/post.inc.php:111
+msgid "Corps"
+msgstr "Corps"
+
+#: ../banana/banana.inc.php:275 ../banana/banana.inc.php:283
+msgid "Impossible de poster le message"
+msgstr "Impossible de poster le message"
+
+#: ../banana/groups.inc.php:87
+msgid "Total"
+msgstr "Total"
+
+#: ../banana/groups.inc.php:89
+msgid "Abo."
+msgstr "Abo."
+
+#: ../banana/groups.inc.php:91
+msgid "Nouveaux"
+msgstr "Nouveaux"
+
+#: ../banana/groups.inc.php:93
+msgid "Description"
+msgstr "Description"
+
+#: ../banana/misc.inc.php:33
+msgid "De"
+msgstr "De"
+
+#: ../banana/misc.inc.php:36
+msgid "Suivi-Ã "
+msgstr "Suivi-Ã "
+
+#: ../banana/misc.inc.php:37 ../banana/spool.inc.php:359
+msgid "Date"
+msgstr "Date"
+
+#: ../banana/misc.inc.php:39
+msgid "Références"
+msgstr "Références"
+
+#: ../banana/misc.inc.php:40
+msgid "Image"
+msgstr "Image"
+
+#: ../banana/misc.inc.php:115
+msgid "hier"
+msgstr "hier"
+
+#: ../banana/misc.inc.php:148
+msgid "Liste des forums"
+msgstr "Liste des forums"
+
+#: ../banana/misc.inc.php:171
+msgid "Répondre"
+msgstr "Répondre"
+
+#: ../banana/misc.inc.php:174
+msgid "Annuler ce message"
+msgstr "Annuler ce message"
+
+#: ../banana/post.inc.php:114
+msgid "apercu"
+msgstr "apercu"
+
+#: ../banana/spool.inc.php:361
+msgid "Auteur"
+msgstr "Auteur"
+
+#: ../banana/spool.inc.php:372
+msgid "Aucun message dans ce forum"
+msgstr "Aucun message dans ce forum"
--- /dev/null
+#!/bin/sh
+##
+## GNU shtool -- The GNU Portable Shell Tool
+## Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>
+##
+## See http://www.gnu.org/software/shtool/ for more information.
+## See ftp://ftp.gnu.org/gnu/shtool/ for latest version.
+##
+## Version 1.4.9 (16-Apr-2000)
+## Ingredients: 3/17 available modules
+##
+
+##
+## 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, or contact Ralf S. Engelschall <rse@engelschall.com>.
+##
+## Notice: Given that you include this file verbatim into your own
+## source tree, you are justified in saying that it remains separate
+## from your package, and that this way you are simply just using GNU
+## shtool. So, in this situation, there is no requirement that your
+## package itself is licensed under the GNU General Public License in
+## order to take advantage of GNU shtool.
+##
+
+##
+## Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]
+##
+## Available commands:
+## echo Print string with optional construct expansion
+## install Install a program, script or datafile
+## mkdir Make one or more directories
+##
+## Not available commands (because module was not built-in):
+## mdate Pretty-print modification time of a file or dir
+## table Pretty-print a field-separated list as a table
+## prop Display progress with a running propeller
+## move Move files with simultaneous substitution
+## mkln Make link with calculation of relative paths
+## mkshadow Make a shadow tree through symbolic links
+## fixperm Fix file permissions inside a source tree
+## tarball Roll distribution tarballs
+## guessos Simple operating system guesser
+## arx Extended archive command
+## slo Separate linker options by library class
+## scpp Sharing C Pre-Processor
+## version Generate and maintain a version information file
+## path Deal with program paths
+##
+
+if [ $# -eq 0 ]; then
+ echo "$0:Error: invalid command line" 1>&2
+ echo "$0:Hint: run \`$0 -h' for usage" 1>&2
+ exit 1
+fi
+if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
+ echo "This is GNU shtool, version 1.4.9 (16-Apr-2000)"
+ echo "Copyright (c) 1994-2000 Ralf S. Engelschall <rse@engelschall.com>"
+ echo "Report bugs to <bug-shtool@gnu.org>"
+ echo ''
+ echo "Usage: shtool [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]"
+ echo ''
+ echo 'Available global <options>:'
+ echo ' -v, --version display shtool version information'
+ echo ' -h, --help display shtool usage help page (this one)'
+ echo ' -d, --debug display shell trace information'
+ echo ''
+ echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:'
+ echo ' echo [-n] [-e] [<str> ...]'
+ echo ' install [-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>]'
+ echo ' [-e<ext>] <file> <path>'
+ echo ' mkdir [-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]'
+ echo ''
+ echo 'Not available <cmd-name> (because module was not built-in):'
+ echo ' mdate [-n] [-z] [-s] [-d] [-f<str>] [-o<spec>] <path>'
+ echo ' table [-F<sep>] [-w<width>] [-c<cols>] [-s<strip>] <str><sep><str>...'
+ echo ' prop [-p<str>]'
+ echo ' move [-v] [-t] [-e] [-p] <src-file> <dst-file>'
+ echo ' mkln [-t] [-f] [-s] <src-path> [<src-path> ...] <dst-path>'
+ echo ' mkshadow [-v] [-t] [-a] <src-dir> <dst-dir>'
+ echo ' fixperm [-v] [-t] <path> [<path> ...]'
+ echo ' tarball [-t] [-v] [-o <tarball>] [-c <prog>] [-d <dir>] [-u'
+ echo ' <user>] [-g <group>] [-e <pattern>] <path> [<path> ...]'
+ echo ' guessos '
+ echo ' arx [-t] [-C<cmd>] <op> <archive> [<file> ...]'
+ echo ' slo [-p<str>] -- -L<dir> -l<lib> [-L<dir> -l<lib> ...]'
+ echo ' scpp [-v] [-p] [-f<filter>] [-o<ofile>] [-t<tfile>] [-M<mark>]'
+ echo ' [-D<dname>] [-C<cname>] <file> [<file> ...]'
+ echo ' version [-l<lang>] [-n<name>] [-p<prefix>] [-s<version>] [-i<knob>]'
+ echo ' [-d<type>] <file>'
+ echo ' path [-s] [-r] [-d] [-b] [-m] [-p<path>] <str> [<str> ...]'
+ echo ''
+ exit 0
+fi
+if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then
+ echo "GNU shtool 1.4.9 (16-Apr-2000)"
+ exit 0
+fi
+if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then
+ shift
+ set -x
+fi
+name=`echo "$0" | sed -e 's;.*/\([^/]*\)$;\1;' -e 's;-sh$;;' -e 's;\.sh$;;'`
+case "$name" in
+ echo|install|mkdir )
+ # implicit tool command selection
+ tool="$name"
+ ;;
+ * )
+ # explicit tool command selection
+ tool="$1"
+ shift
+ ;;
+esac
+arg_spec=""
+opt_spec=""
+gen_tmpfile=no
+
+##
+## DISPATCH INTO SCRIPT PROLOG
+##
+
+case $tool in
+ echo )
+ str_tool="echo"
+ str_usage="[-n] [-e] [<str> ...]"
+ arg_spec="0+"
+ opt_spec="n.e."
+ opt_n=no
+ opt_e=no
+ ;;
+ install )
+ str_tool="install"
+ str_usage="[-v] [-t] [-c] [-C] [-s] [-m<mode>] [-o<owner>] [-g<group>] [-e<ext>] <file> <path>"
+ arg_spec="2="
+ opt_spec="v.t.c.C.s.m:o:g:e:"
+ opt_v=no
+ opt_t=no
+ opt_c=no
+ opt_C=no
+ opt_s=no
+ opt_m=""
+ opt_o=""
+ opt_g=""
+ opt_e=""
+ ;;
+ mkdir )
+ str_tool="mkdir"
+ str_usage="[-t] [-f] [-p] [-m<mode>] <dir> [<dir> ...]"
+ arg_spec="1+"
+ opt_spec="t.f.p.m:"
+ opt_t=no
+ opt_f=no
+ opt_p=no
+ opt_m=""
+ ;;
+ -* )
+ echo "$0:Error: unknown option \`$tool'" 2>&1
+ echo "$0:Hint: run \`$0 -h' for usage" 2>&1
+ exit 1
+ ;;
+ * )
+ echo "$0:Error: unknown command \`$tool'" 2>&1
+ echo "$0:Hint: run \`$0 -h' for usage" 2>&1
+ exit 1
+ ;;
+esac
+
+##
+## COMMON UTILITY CODE
+##
+
+# determine name of tool
+if [ ".$tool" != . ]; then
+ # used inside shtool script
+ toolcmd="$0 $tool"
+ toolcmdhelp="shtool $tool"
+ msgprefix="shtool:$tool"
+else
+ # used as standalone script
+ toolcmd="$0"
+ toolcmdhelp="sh $0"
+ msgprefix="$str_tool"
+fi
+
+# parse argument specification string
+eval `echo $arg_spec |\
+ sed -e 's/^\([0-9]*\)\([+=]\)/arg_NUMS=\1; arg_MODE=\2/'`
+
+# parse option specification string
+eval `echo h.$opt_spec |\
+ sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'`
+
+# interate over argument line
+opt_PREV=''
+while [ $# -gt 0 ]; do
+ # special option stops processing
+ if [ ".$1" = ".--" ]; then
+ shift
+ break
+ fi
+
+ # determine option and argument
+ opt_ARG_OK=no
+ if [ ".$opt_PREV" != . ]; then
+ # merge previous seen option with argument
+ opt_OPT="$opt_PREV"
+ opt_ARG="$1"
+ opt_ARG_OK=yes
+ opt_PREV=''
+ else
+ # split argument into option and argument
+ case "$1" in
+ -[a-zA-Z0-9]*)
+ eval `echo "x$1" |\
+ sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \
+ -e 's/";\(.*\)$/"; opt_ARG="\1"/'`
+ ;;
+ -[a-zA-Z0-9])
+ opt_OPT=`echo "x$1" | cut -c3-`
+ opt_ARG=''
+ ;;
+ *)
+ break
+ ;;
+ esac
+ fi
+
+ # eat up option
+ shift
+
+ # determine whether option needs an argument
+ eval "opt_MODE=\$opt_MODE_${opt_OPT}"
+ if [ ".$opt_ARG" = . -a ".$opt_ARG_OK" != .yes ]; then
+ if [ ".$opt_MODE" = ".:" -o ".$opt_MODE" = ".+" ]; then
+ opt_PREV="$opt_OPT"
+ continue
+ fi
+ fi
+
+ # process option
+ case $opt_MODE in
+ '.' )
+ # boolean option
+ eval "opt_${opt_OPT}=yes"
+ ;;
+ ':' )
+ # option with argument (multiple occurances override)
+ eval "opt_${opt_OPT}=\"\$opt_ARG\""
+ ;;
+ '+' )
+ # option with argument (multiple occurances append)
+ eval "opt_${opt_OPT}=\"\$opt_${opt_OPT} \$opt_ARG\""
+ ;;
+ * )
+ echo "$msgprefix:Error: unknown option: \`-$opt_OPT'" 1>&2
+ echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
+ exit 1
+ ;;
+ esac
+done
+if [ ".$opt_PREV" != . ]; then
+ echo "$msgprefix:Error: missing argument to option \`-$opt_PREV'" 1>&2
+ echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
+ exit 1
+fi
+
+# process help option
+if [ ".$opt_h" = .yes ]; then
+ echo "Usage: $toolcmdhelp $str_usage"
+ exit 0
+fi
+
+# complain about incorrect number of arguments
+case $arg_MODE in
+ '=' )
+ if [ $# -ne $arg_NUMS ]; then
+ echo "$msgprefix:Error: invalid number of arguments (exactly $arg_NUMS expected)" 1>&2
+ echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man shtool' for details" 1>&2
+ exit 1
+ fi
+ ;;
+ '+' )
+ if [ $# -lt $arg_NUMS ]; then
+ echo "$msgprefix:Error: invalid number of arguments (at least $arg_NUMS expected)" 1>&2
+ echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man shtool' for details" 1>&2
+ exit 1
+ fi
+ ;;
+esac
+
+# establish a temporary file on request
+if [ ".$gen_tmpfile" = .yes ]; then
+ if [ ".$TMPDIR" != . ]; then
+ tmpdir="$TMPDIR"
+ elif [ ".$TEMPDIR" != . ]; then
+ tmpdir="$TEMPDIR"
+ else
+ tmpdir="/tmp"
+ fi
+ tmpfile="$tmpdir/.shtool.$$"
+ rm -f $tmpfile >/dev/null 2>&1
+ touch $tmpfile
+fi
+
+##
+## DISPATCH INTO SCRIPT BODY
+##
+
+case $tool in
+
+echo )
+ ##
+ ## echo -- Print string with optional construct expansion
+ ## Copyright (c) 1998-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Originally written for WML as buildinfo
+ ##
+
+ text="$*"
+
+ # check for broken escape sequence expansion
+ seo=''
+ bytes=`echo '\1' | wc -c | awk '{ printf("%s", $1); }'`
+ if [ ".$bytes" != .3 ]; then
+ bytes=`echo -E '\1' | wc -c | awk '{ printf("%s", $1); }'`
+ if [ ".$bytes" = .3 ]; then
+ seo='-E'
+ fi
+ fi
+
+ # check for existing -n option (to suppress newline)
+ minusn=''
+ bytes=`echo -n 123 2>/dev/null | wc -c | awk '{ printf("%s", $1); }'`
+ if [ ".$bytes" = .3 ]; then
+ minusn='-n'
+ fi
+
+ # determine terminal bold sequence
+ term_bold=''
+ term_norm=''
+ if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[Bb]'`" != . ]; then
+ case $TERM in
+ # for the most important terminal types we directly know the sequences
+ xterm|xterm*|vt220|vt220*)
+ term_bold=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
+ term_norm=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
+ ;;
+ vt100|vt100*)
+ term_bold=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
+ term_norm=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
+ ;;
+ # for all others, we try to use a possibly existing `tput' or `tcout' utility
+ * )
+ paths=`echo $PATH | sed -e 's/:/ /g'`
+ for tool in tput tcout; do
+ for dir in $paths; do
+ if [ -r "$dir/$tool" ]; then
+ for seq in bold md smso; do # 'smso' is last
+ bold="`$dir/$tool $seq 2>/dev/null`"
+ if [ ".$bold" != . ]; then
+ term_bold="$bold"
+ break
+ fi
+ done
+ if [ ".$term_bold" != . ]; then
+ for seq in sgr0 me rmso reset; do # 'reset' is last
+ norm="`$dir/$tool $seq 2>/dev/null`"
+ if [ ".$norm" != . ]; then
+ term_norm="$norm"
+ break
+ fi
+ done
+ fi
+ break
+ fi
+ done
+ if [ ".$term_bold" != . -a ".$term_norm" != . ]; then
+ break;
+ fi
+ done
+ ;;
+ esac
+ if [ ".$term_bold" = . -o ".$term_norm" = . ]; then
+ echo "$msgprefix:Warning: unable to determine terminal sequence for bold mode" 1>&2
+ fi
+ fi
+
+ # determine user name
+ username=''
+ if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[uU]'`" != . ]; then
+ username="$LOGNAME"
+ if [ ".$username" = . ]; then
+ username="$USER"
+ if [ ".$username" = . ]; then
+ username="`(whoami) 2>/dev/null |\
+ awk '{ printf("%s", $1); }'`"
+ if [ ".$username" = . ]; then
+ username="`(who am i) 2>/dev/null |\
+ awk '{ printf("%s", $1); }'`"
+ if [ ".$username" = . ]; then
+ username='unknown'
+ fi
+ fi
+ fi
+ fi
+ fi
+
+ # determine user id
+ userid=''
+ if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%U'`" != . ]; then
+ userid="`(id -u) 2>/dev/null`"
+ if [ ".$userid" = . ]; then
+ str="`(id) 2>/dev/null`"
+ if [ ".`echo $str | grep '^uid[ ]*=[ ]*[0-9]*('`" != . ]; then
+ userid=`echo $str | sed -e 's/^uid[ ]*=[ ]*//' -e 's/(.*//'`
+ fi
+ if [ ".$userid" = . ]; then
+ userid=`egrep "^${username}:" /etc/passwd 2>/dev/null | \
+ sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
+ if [ ".$userid" = . ]; then
+ userid=`(ypcat passwd) 2>/dev/null |
+ egrep "^${username}:" | \
+ sed -e 's/[^:]*:[^:]*://' -e 's/:.*$//'`
+ if [ ".$userid" = . ]; then
+ userid='?'
+ fi
+ fi
+ fi
+ fi
+ fi
+
+ # determine host name
+ hostname=''
+ if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%h'`" != . ]; then
+ hostname="`(uname -n) 2>/dev/null |\
+ awk '{ printf("%s", $1); }'`"
+ if [ ".$hostname" = . ]; then
+ hostname="`(hostname) 2>/dev/null |\
+ awk '{ printf("%s", $1); }'`"
+ if [ ".$hostname" = . ]; then
+ hostname='unknown'
+ fi
+ fi
+ case $hostname in
+ *.* )
+ domainname=".`echo $hostname | cut -d. -f2-`"
+ hostname="`echo $hostname | cut -d. -f1`"
+ ;;
+ esac
+ fi
+
+ # determine domain name
+ domainname=''
+ if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%d'`" != . ]; then
+ if [ ".$domainname" = . ]; then
+ if [ -f /etc/resolv.conf ]; then
+ domainname="`egrep '^[ ]*domain' /etc/resolv.conf | head -1 |\
+ sed -e 's/.*domain//' \
+ -e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
+ -e 's/^\.//' -e 's/^/./' |\
+ awk '{ printf("%s", $1); }'`"
+ if [ ".$domainname" = . ]; then
+ domainname="`egrep '^[ ]*search' /etc/resolv.conf | head -1 |\
+ sed -e 's/.*search//' \
+ -e 's/^[ ]*//' -e 's/^ *//' -e 's/^ *//' \
+ -e 's/ .*//' -e 's/ .*//' \
+ -e 's/^\.//' -e 's/^/./' |\
+ awk '{ printf("%s", $1); }'`"
+ fi
+ fi
+ fi
+ fi
+
+ # determine current time
+ time_day=''
+ time_month=''
+ time_year=''
+ time_monthname=''
+ if [ ".$opt_e" = .yes -a ".`echo $text | egrep '%[DMYm]'`" != . ]; then
+ time_day=`date '+%d'`
+ time_month=`date '+%m'`
+ time_year=`date '+%Y' 2>/dev/null`
+ if [ ".$time_year" = . ]; then
+ time_year=`date '+%y'`
+ case $time_year in
+ [5-9][0-9]) time_year="19$time_year" ;;
+ [0-4][0-9]) time_year="20$time_year" ;;
+ esac
+ fi
+ case $time_month in
+ 1|01) time_monthname='Jan' ;;
+ 2|02) time_monthname='Feb' ;;
+ 3|03) time_monthname='Mar' ;;
+ 4|04) time_monthname='Apr' ;;
+ 5|05) time_monthname='May' ;;
+ 6|06) time_monthname='Jun' ;;
+ 7|07) time_monthname='Jul' ;;
+ 8|08) time_monthname='Aug' ;;
+ 9|09) time_monthname='Sep' ;;
+ 10) time_monthname='Oct' ;;
+ 11) time_monthname='Nov' ;;
+ 12) time_monthname='Dec' ;;
+ esac
+ fi
+
+ # expand special ``%x'' constructs
+ if [ ".$opt_e" = .yes ]; then
+ text=`echo $seo "$text" |\
+ sed -e "s/%B/${term_bold}/g" \
+ -e "s/%b/${term_norm}/g" \
+ -e "s/%u/${username}/g" \
+ -e "s/%U/${userid}/g" \
+ -e "s/%h/${hostname}/g" \
+ -e "s/%d/${domainname}/g" \
+ -e "s/%D/${time_day}/g" \
+ -e "s/%M/${time_month}/g" \
+ -e "s/%Y/${time_year}/g" \
+ -e "s/%m/${time_monthname}/g" 2>/dev/null`
+ fi
+
+ # create output
+ if [ .$opt_n = .no ]; then
+ echo $seo "$text"
+ else
+ # the harder part: echo -n is best, because
+ # awk may complain about some \xx sequences.
+ if [ ".$minusn" != . ]; then
+ echo $seo $minusn "$text"
+ else
+ echo dummy | awk '{ printf("%s", TEXT); }' TEXT="$text"
+ fi
+ fi
+ ;;
+
+install )
+ ##
+ ## install -- Install a program, script or datafile
+ ## Copyright (c) 1997-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Originally written for shtool
+ ##
+
+ src="$1"
+ dst="$2"
+
+ # If destination is a directory, append the input filename
+ if [ -d $dst ]; then
+ dst=`echo "$dst" | sed -e 's:/$::'`
+ dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`
+ dst="$dst/$dstfile"
+ fi
+
+ # Add a possible extension to src and dst
+ if [ ".$opt_e" != . ]; then
+ src="$src$opt_e"
+ dst="$dst$opt_e"
+ fi
+
+ # Check for correct arguments
+ if [ ".$src" = ".$dst" ]; then
+ echo "$msgprefix:Error: source and destination are the same" 1>&2
+ exit 1
+ fi
+
+ # Make a temp file name in the destination directory
+ dstdir=`echo $dst | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;'`
+ dsttmp="$dstdir/#INST@$$#"
+
+ # Verbosity
+ if [ ".$opt_v" = .yes ]; then
+ echo "$src -> $dst" 1>&2
+ fi
+
+ # Copy or move the file name to the temp name
+ # (because we might be not allowed to change the source)
+ if [ ".$opt_C" = .yes ]; then
+ opt_c=yes
+ fi
+ if [ ".$opt_c" = .yes ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "cp $src $dsttmp" 1>&2
+ fi
+ cp $src $dsttmp || exit $?
+ else
+ if [ ".$opt_t" = .yes ]; then
+ echo "mv $src $dsttmp" 1>&2
+ fi
+ mv $src $dsttmp || exit $?
+ fi
+
+ # Adjust the target file
+ # (we do chmod last to preserve setuid bits)
+ if [ ".$opt_s" = .yes ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "strip $dsttmp" 1>&2
+ fi
+ strip $dsttmp || exit $?
+ fi
+ if [ ".$opt_o" != . ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "chown $opt_o $dsttmp" 1>&2
+ fi
+ chown $opt_o $dsttmp || exit $?
+ fi
+ if [ ".$opt_g" != . ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "chgrp $opt_g $dsttmp" 1>&2
+ fi
+ chgrp $opt_g $dsttmp || exit $?
+ fi
+ if [ ".$opt_m" != . ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "chmod $opt_m $dsttmp" 1>&2
+ fi
+ chmod $opt_m $dsttmp || exit $?
+ fi
+
+ # Determine whether to do a quick install
+ # (has to be done _after_ the strip was already done)
+ quick=no
+ if [ ".$opt_C" = .yes ]; then
+ if [ -r $dst ]; then
+ if cmp -s $src $dst; then
+ quick=yes
+ fi
+ fi
+ fi
+
+ # Finally install the file to the real destination
+ if [ $quick = yes ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "rm -f $dsttmp" 1>&2
+ fi
+ rm -f $dsttmp
+ else
+ if [ ".$opt_t" = .yes ]; then
+ echo "rm -f $dst && mv $dsttmp $dst" 1>&2
+ fi
+ rm -f $dst && mv $dsttmp $dst
+ fi
+ ;;
+
+mkdir )
+ ##
+ ## mkdir -- Make one or more directories
+ ## Copyright (c) 1996-2000 Ralf S. Engelschall <rse@engelschall.com>
+ ## Originally written for public domain by Noah Friedman <friedman@prep.ai.mit.edu>
+ ## Cleaned up and enhanced for shtool
+ ##
+
+ errstatus=0
+ for p in ${1+"$@"}; do
+ # if the directory already exists...
+ if [ -d "$p" ]; then
+ if [ ".$opt_f" = .no ] && [ ".$opt_p" = .no ]; then
+ echo "$msgprefix:Error: directory already exists: $p" 1>&2
+ errstatus=1
+ break
+ else
+ continue
+ fi
+ fi
+ # if the directory has to be created...
+ if [ ".$opt_p" = .no ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "mkdir $p" 1>&2
+ fi
+ mkdir $p || errstatus=$?
+ else
+ # the smart situation
+ set fnord `echo ":$p" |\
+ sed -e 's/^:\//%/' \
+ -e 's/^://' \
+ -e 's/\// /g' \
+ -e 's/^%/\//'`
+ shift
+ pathcomp=''
+ for d in ${1+"$@"}; do
+ pathcomp="$pathcomp$d"
+ case "$pathcomp" in
+ -* ) pathcomp="./$pathcomp" ;;
+ esac
+ if [ ! -d "$pathcomp" ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "mkdir $pathcomp" 1>&2
+ fi
+ mkdir $pathcomp || errstatus=$?
+ if [ ".$opt_m" != . ]; then
+ if [ ".$opt_t" = .yes ]; then
+ echo "chmod $opt_m $pathcomp" 1>&2
+ fi
+ chmod $opt_m $pathcomp || errstatus=$?
+ fi
+ fi
+ pathcomp="$pathcomp/"
+ done
+ fi
+ done
+ exit $errstatus
+ ;;
+
+esac
+
+exit 0
+
+##EOF##