it's more than ugly, but banana works ...
authorx2000habouzit <x2000habouzit>
Sun, 26 Sep 2004 15:02:32 +0000 (15:02 +0000)
committerx2000habouzit <x2000habouzit>
Sun, 26 Sep 2004 15:02:32 +0000 (15:02 +0000)
please don't look at the code, it's an insanity. but we will go on with this until we can make better

25 files changed:
htdocs/banana/article.php [new file with mode: 0644]
htdocs/banana/banana.css [new file with mode: 0644]
htdocs/banana/disconnect.php [new file with mode: 0644]
htdocs/banana/include/config.inc.php [new file with mode: 0644]
htdocs/banana/include/error.inc.php [new file with mode: 0644]
htdocs/banana/include/footer.inc.php [new file with mode: 0644]
htdocs/banana/include/format.inc.php [new file with mode: 0644]
htdocs/banana/include/hack.inc.php [new file with mode: 0644]
htdocs/banana/include/header.inc.php [new file with mode: 0644]
htdocs/banana/include/password.inc.php [new file with mode: 0644]
htdocs/banana/include/profile.inc.php [new file with mode: 0644]
htdocs/banana/include/session.inc.php [new file with mode: 0644]
htdocs/banana/include/subscribe.inc.php [new file with mode: 0644]
htdocs/banana/index.php [new file with mode: 0644]
htdocs/banana/install.sh [new file with mode: 0755]
htdocs/banana/post.php [new file with mode: 0644]
htdocs/banana/scripts/spoolgen.php [new file with mode: 0755]
htdocs/banana/spool/.cvsignore [new file with mode: 0644]
htdocs/banana/subscribe.php [new file with mode: 0644]
htdocs/banana/thread.php [new file with mode: 0644]
htdocs/banana/xface.php [new file with mode: 0644]
htdocs/confbanana.php [new file with mode: 0644]
templates/banana.head.tpl [new file with mode: 0644]
templates/banana.tpl [new file with mode: 0644]
templates/confbanana.tpl [new file with mode: 0644]

diff --git a/htdocs/banana/article.php b/htdocs/banana/article.php
new file mode 100644 (file)
index 0000000..cff7f97
--- /dev/null
@@ -0,0 +1,18 @@
+<?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('auto.prepend.inc.php');
+new_skinned_page('banana.tpl', AUTH_COOKIE, true, 'banana.head.tpl');
+$page->caching = false;
+require('hack.inc.php');
+
+$page->register_function('banana', 'banana', false);
+
+$page->run();
+?>
diff --git a/htdocs/banana/banana.css b/htdocs/banana/banana.css
new file mode 100644 (file)
index 0000000..57e1294
--- /dev/null
@@ -0,0 +1,93 @@
+img { border: 0px; margin: 0; }
+
+table.bicol div, table.bananaoverview div { height: 21px; }
+
+
+table.bicol { width: 100%; }
+
+table.bicol td {
+    padding-left: 0.5em;
+    padding-right: 0.5em;
+    white-space: nowrap;
+    overflow: hidden;
+}
+table.bicol td.bicolvpadd, td.bouton {
+    padding-top: 0.5em;
+    padding-bottom: 0.5em;
+}
+table.bicol td.bouton {
+    text-align: center;
+}
+
+/*******************************************
+*             FORUMS                       *
+*******************************************/
+
+div.bananashortcuts {
+    text-align: left;
+    padding-bottom: 1em;
+    padding-top: 1em;
+}
+
+div.bananatree {
+    float: left;
+    padding-right: 0.3em;
+}
+
+span.bananaisref {
+    font-style: italic;
+}
+
+table.bicol td.banananopadd {
+    padding-left: 0em;
+    padding-right: 0em;
+}
+
+table.bicol td.bananatotal,td.bananaunread,td.bananadate {
+    text-align: center;
+    padding-left: 0.1em;
+    padding-right: 0.1em;
+}
+
+table.bicol td.bananasubject,td.bananagroup,td.bananafrom,td.bananadescription {
+    text-align: left;
+}
+
+table.bananaoverview {
+    /*  background-color: #eeeeee;*/
+    background-color: inherit;
+    color: inherit;
+    width: 100%;
+    font-size: 95%;
+}
+
+table.bananaoverview tr.impair {}
+
+table.bananaoverview tr.pair {
+    background-color: #eeeed0;
+    color: inherit;
+}
+
+table.bananaoverview th {
+    /*  background-color: #336699;*/
+    background-color: inherit;
+    color: #FFFFFF;
+    font-weight: bold;
+    text-align: center;
+    vertical-align: middle;
+}
+
+table.bananaoverview td {
+    color: #000000;
+    background-color: inherit;
+    padding: 0px 0.4em 0px 0.4em;
+}
+
+table.bananaoverview td.bananasubject,td.bananagroup,td.bananafrom,td.bananadescription {
+    text-align: left;
+}
+
+table.bananaoverview span.isref {
+    font-style: italic;
+}
+
diff --git a/htdocs/banana/disconnect.php b/htdocs/banana/disconnect.php
new file mode 100644 (file)
index 0000000..cff7f97
--- /dev/null
@@ -0,0 +1,18 @@
+<?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('auto.prepend.inc.php');
+new_skinned_page('banana.tpl', AUTH_COOKIE, true, 'banana.head.tpl');
+$page->caching = false;
+require('hack.inc.php');
+
+$page->register_function('banana', 'banana', false);
+
+$page->run();
+?>
diff --git a/htdocs/banana/include/config.inc.php b/htdocs/banana/include/config.inc.php
new file mode 100644 (file)
index 0000000..1e27879
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+
+/** comparison function for the overview 
+ * @param $a OBJECT spoolhead 
+ * @param $b OBJECT spoolhead
+ * @return
+ */
+
+function spoolcompare($a,$b) {
+  global $news;
+  return ($b->date>=$a->date);
+}
+
+// spool config in spool.inc.php
+$news['maxspool'] = 2000;
+
+// encoded headers
+$news['hdecode'] = array('from','name','organization','subject');
+
+// headers in post
+$news['head'] = array(
+  'From' => 'from',
+  'Subject' => 'subject',
+  'Newsgroups' => 'newsgroups',
+  'Message-ID' => 'msgid',
+  'Followup-To' => 'followup',
+  'Date' => 'date',
+  'X-Org-Id' => 'xorgid',
+  'Organization' => 'organization',
+  'References' => 'references',
+  'X-Face' => 'xface',
+  'Content-Transfer-Encoding' => 'contentencoding'
+  );
+
+// headers in article.php
+$news['headdisp']=array(
+  'from',
+  'subject',
+  'newsgroups',
+  'followup',
+  'date',
+  'organization',
+  'references',
+  'xorgid',
+  'xface',
+);
+$locale['headers']['xorgid']='Identité';
+
+// overview configuration in article.php
+$news['threadtop'] = 5;
+$news['threadbottom'] = 5;
+
+// wordwrap configuration
+$news['wrap'] = 80;
+
+// overview configuration in thread.php
+$news['max'] = 50;
+
+// custom headers in post.php
+$news['customhdr'] = 
+   "Date: ".date("r")."\n"
+  ."Content-Type: text/plain; charset=iso-8859-15\n"
+  ."Mime-Version: 1.0\n"
+  ."Content-Transfer-Encoding: 8bit\n"
+  ."HTTP-Posting-Host: ".gethostbyname($_SERVER['REMOTE_ADDR'])."\n"
+  ."User-Agent: Banana 0.7.1\n";
+
+$css = array(
+ 'bananashortcuts' => 'bananashortcuts',
+ 'title' => 'rubrique',
+ 'bicol' => 'bicol',
+ 'bicoltitre' => 'bicoltitre',
+ 'bicolvpadd' => 'bicolvpadd',
+ 'pair' => 'pair',
+ 'impair' => 'impair',
+ 'bouton' => 'bouton',
+ 'error' => 'erreur',
+ 'normal' => 'normal',
+ 'total' => 'bananatotal',
+ 'unread' => 'bananaunread',
+ 'group' => 'bananagroup',
+ 'description' => 'bananadescription',
+ 'date' => 'bananadate',
+ 'subject' => 'bananasubject',
+ 'from' => 'bananafrom',
+ 'author' => 'author',
+ 'nopadd' => 'banananopadd',
+ 'overview' => 'bananaoverview',
+ 'tree' => 'bananatree'
+);
+
+?>
diff --git a/htdocs/banana/include/error.inc.php b/htdocs/banana/include/error.inc.php
new file mode 100644 (file)
index 0000000..b42781a
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+function error($_type) {
+  global $locale,$css,$group;
+  switch ($_type) {
+    case "nntpsock":
+      echo "<p class=\"error\">\n\t".$locale['error']['connect']."\n</p>";
+      break;  
+    case "nntpauth":
+      echo "<p class=\"error\">\n\t".$locale['error']['credentials']
+        ."\n</p>";
+      break;
+    case "nntpgroups":
+      echo "<p class=\"{$css['normal']}\">";
+      echo "\n".$locale['error']['nogroup']."\n";
+      echo "</p>\n";
+      break;
+    case "nntpspool":
+      echo "<div class=\"{$css['bananashortcuts']}\">\n";
+      echo "[<a href=\"index.php\">Liste des forums</a>]\n";
+      echo "</div>\n";
+      echo "<p class=\"error\">\n\t".$locale['error']['group']."\n</p>";
+      break;
+    case "nntpart":
+      echo "<div class=\"{$css['bananashortcuts']}\">\n";
+      echo "[<a href=\"index.php\">Liste des forums</a>] \n";
+      echo "[<a href=\"thread.php?group=$group\">$group</a>] \n";
+      echo "</div>\n";
+      echo "<p class=\"error\">\n\t".$locale['error']['post']."\n</p>";
+      break;
+  }
+}
+
+?>
diff --git a/htdocs/banana/include/footer.inc.php b/htdocs/banana/include/footer.inc.php
new file mode 100644 (file)
index 0000000..acb6c35
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+?>
diff --git a/htdocs/banana/include/format.inc.php b/htdocs/banana/include/format.inc.php
new file mode 100644 (file)
index 0000000..dcd0059
--- /dev/null
@@ -0,0 +1,232 @@
+<?php
+/********************************************************************************
+* install.d/format.inc.php : HTML output subroutines
+* --------------------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+function url($string)
+{
+    if(strpos($string, "http://")!==false)
+       return $string;
+    $chemins = Array('', '../', '../../');
+    foreach ($chemins as $ch) {
+       if (file_exists($ch.'../htdocs/')) {
+           return $ch.$string;
+       }
+    }
+    return '';
+}
+
+/** produces HTML output for overview
+ * @param $_header STRING name of the header
+ * @param $_text STRING value of the header
+ * @param $_id INTEGER MSGNUM of message
+ * @param $_group TEXT name of newsgroup
+ * @param $_isref BOOLEAN emphasizes message in overview tree ?
+ * @param $_isread BOOLEAN displays message as read ?
+ * @return STRING HTML output
+ * @see disp_desc
+ */
+
+function formatSpoolHeader($_header,$_text,$_id,$_group,$_isref,$_isread=true) {
+  global $locale;
+  switch ($_header) {
+    case "date": 
+      return locale_header_date($_text);
+    case "from":
+#     From: mark@cbosgd.ATT.COM
+#     From: mark@cbosgd.ATT.COM (Mark Horton)
+#     From: Mark Horton <mark@cbosgd.ATT.COM>
+      $result = htmlentities($_text);
+      if (preg_match("/^([^ ]+)@([^ ]+)$/",$_text,$regs))
+        $result="<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;".
+          "{$regs[1]}&#64;{$regs[2]}\">".htmlentities($regs[1].
+          "&#64;".$regs[2])."</a>";
+      if (preg_match("/^([^ ]+)@([^ ]+) \((.*)\)$/",$_text,$regs))
+        $result="<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;".
+          "{$regs[1]}&#64;{$regs[2]}\">".htmlentities($regs[3])."</a>";
+      if (preg_match("/^\"?([^<>\"]+)\"? +<(.+)@(.+)>$/",$_text,$regs))
+        $result="<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;".
+          "{$regs[2]}&#64;{$regs[3]}\">".htmlentities($regs[1])."</a>";
+      return preg_replace("/\\\(\(|\))/","\\1",$result);
+    case "subject":
+      if ($_isref) {
+        return '<span class="isref">'.htmlentities($_text).'</span>';
+      } else {
+        if ($_isread) {
+          return "<a href=\"article.php?group=$_group&amp;id=$_id\">"
+          .htmlentities($_text)."</a>";
+        }else {
+          return "<a href=\"article.php?group=$_group&amp;id=$_id\"><b>"
+          .htmlentities($_text)."</b></a>";
+        }
+      }
+    default:
+      return htmlentities($_text);
+  }
+}
+
+/** produces HTML ouput for header section in post.php
+ * @param $_header STRING name of the header
+ * @param $_text STRING value of the header
+ * @param $_spool OBJECT spool object for building references
+ * @return STRING HTML output
+ */
+
+function formatDisplayHeader($_header,$_text,$_spool) {
+  global $locale;
+  switch ($_header) {
+    case "date": 
+      return locale_date($_text);
+    case "followup":
+    case "newsgroups":
+      $res = "";
+      $groups = preg_split("/(\t| )*,(\t| )*/",$_text);
+      foreach ($groups as $g) {
+        $res.='<a href="thread.php?group='.$g.'">'.$g.'</a>, ';
+      }
+      return substr($res,0, -2);
+    case "from":
+#     From: mark@cbosgd.ATT.COM
+#     From: mark@cbosgd.ATT.COM (Mark Horton)
+#     From: Mark Horton <mark@cbosgd.ATT.COM>
+#     From: Anonymous <anonymous>
+      $result = htmlentities($_text);
+      if (preg_match("/^([^ ]+)@([^ ]+)$/",$_text,$regs))
+        $result="<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;"
+          ."{$regs[1]}&#64;{$regs[2]}\">".htmlentities($regs[1])
+          ."&#64;{$regs[2]}</a>";
+      if (preg_match("/^([^ ]+)@([^ ]+) \((.*)\)$/",$_text,$regs))
+        $result="<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;"
+          ."{$regs[1]}&#64;{$regs[2]}\">".htmlentities($regs[3])
+          ."</a>";
+      if (preg_match("/^\"?([^<>\"]+)\"? +<(.+)@(.+)>$/",$_text,$regs))
+        $result="<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;"
+          ."{$regs[2]}&#64;{$regs[3]}\">".htmlentities($regs[1])
+          ."</a>";
+      return preg_replace("/\\\(\(|\))/","\\1",$result);
+    case "references":
+      $rsl = "";
+      $ndx = 1;
+      $text=str_replace("><","> <",$_text);
+      $text=preg_split("/( |\t)/",strtr($text,$_spool->ids));
+      $parents=preg_grep("/^\d+$/",$text);
+      $p=array_pop($parents);
+      while ($p) {
+        $valid_parents[]=$p;
+        $p = $_spool->overview[$p]->parent;
+      }
+      foreach (array_reverse($valid_parents) as $p) {
+        $rsl .= "<a href=\"article.php?group={$_spool->group}"
+          ."&amp;id=$p\">$ndx</a> ";
+        $ndx++;
+      }
+      return $rsl;
+    case "xface":
+      return '<img src="xface.php?face='.base64_encode($_text)
+      .'"  alt="x-face" />';
+    case "xorgid":
+      return "$_text".(preg_match("/[\w]+\.[\w\d]+/",$_text)?
+        " [<a href=\"javascript:x()\"  onclick=\"popWin('"
+        .url("fiche.php")."?user=$_text')\">fiche</a>]":"");
+    default:
+      return htmlentities($_text);
+  }
+}
+
+/** produces HTML output for message body
+ * @param $_text STRING message body
+ * @return STRING HTML output
+ */
+function formatbody($_text) {
+  global $news;
+  $res ="\n\n";
+  $res .= htmlentities(wrap($_text,"",$news['wrap']))."\n";
+  $res = preg_replace("/(&lt;|&gt;|&quot;)/"," \\1 ",$res);
+  $res = preg_replace('/(["\[])?((https?|ftp|news):\/\/[a-z@0-9.~%$£µ&i#\-+=_\/\?]*)(["\]])?/i',
+    "\\1<a href=\"\\2\">\\2</a>\\4", $res);
+  $res = preg_replace("/ (&lt;|&gt;|&quot;) /","\\1",$res);
+  return $res."\n";
+}
+
+/** contextual links 
+ * @return STRING HTML output
+ */
+function displayshortcuts() {
+  global $news,$locale,$first,$spool,$group,$post,$id,$profile,$css;
+  $sname = $_SERVER['SCRIPT_NAME'];
+  $array = explode('/',$sname);
+  $sname = array_pop($array);
+
+  echo "<div class=\"{$css['bananashortcuts']}\">";
+
+  switch ($sname) {
+    case 'subscribe.php' :
+      echo '[<a href="index.php">Liste des forums</a>] ';
+      echo '[<a href="'.url("confbanana.php").'">Profil</a>] ';
+      break;
+    case 'index.php' :
+      if (!$profile['autoup']) { 
+        echo '[<a href="index.php?banana=updateall">Mettre à jour</a>] ';
+      }
+      echo '[<a href="'.url("confbanana.php").'">Profil</a>] ';
+      echo '[<a href="subscribe.php">Abonnements</a>] ';
+      break;
+    case 'thread.php' :
+      if (!$profile['autoup']) { 
+        echo '[<a href="index.php?banana=updateall">Mettre à jour</a>] ';
+      }
+      echo '[<a href="'.url("confbanana.php").'">Profil</a>] ';
+      echo '[<a href="index.php">'.$locale['format']['grouplist']
+        .'</a>] ';
+      echo "[<a href=\"post.php?group=$group\">"
+        .$locale['format']['newpost']."</a>] ";
+      if (sizeof($spool->overview)>$news['max']) {
+        for ($ndx=1; $ndx<=sizeof($spool->overview); $ndx += $news['max']) {
+          if ($first==$ndx) {
+            echo "[$ndx-".min($ndx+$news['max']-1,sizeof($spool->overview))."] ";
+          } else {
+            echo "[<a href=\"".$_SERVER['PHP_SELF']."?group=$group&amp;first="
+           ."$ndx\">$ndx-".min($ndx+$news['max']-1,sizeof($spool->overview))
+            ."</a>] ";
+          }
+        }
+      }
+      break;
+    case 'article.php' :
+      if (!$profile['autoup']) { 
+        echo '[<a href="index.php?banana=updateall">Mettre à jour</a>] ';
+      }
+      echo '[<a href="'.url("confbanana.php").'">Profil</a>] ';
+      echo '[<a href="index.php">'.$locale['format']['grouplist']
+        .'</a>] ';
+      echo "[<a href=\"thread.php?group=$group\">"
+        .$locale['format']['group_b'].$group
+        .$locale['format']['group_a']."</a>] ";
+      echo "[<a href=\"post.php?group=$group&amp;id=$id&amp;type=followup\">"
+        .$locale['format']['followup']."</a>] ";
+      if (checkcancel($post->headers)) {
+        echo "[<a href=\"article.php?group=$group&amp;id=$id&amp;type=cancel\">"
+        .$locale['format']['cancel']."</a>] ";
+      }
+      break;
+    case 'post.php' :
+      if (!$profile['autoup']) { 
+        echo '[<a href="index.php?banana=updateall">Mettre à jour</a>] ';
+      }
+      echo '[<a href="'.url("confbanana.php").'">Profil</a>] ';
+      echo '[<a href="index.php">'.$locale['format']['grouplist']
+        .'</a>] ';
+      echo "[<a href=\"thread.php?group=$group\">"
+        .$locale['format']['group_b'].$group
+        .$locale['format']['group_a']."</a>] ";
+      break;
+  }
+  echo '</div>';
+}
+
+?>
+
diff --git a/htdocs/banana/include/hack.inc.php b/htdocs/banana/include/hack.inc.php
new file mode 100644 (file)
index 0000000..f0bebaa
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+    
+function banana($params) {
+    global $globals,$news_server,$news_port,$page,$news_auth_pass;
+    global $news,$locale,$first,$spool,$group,$post,$id,$profile,$css;
+    $sname = $_SERVER['SCRIPT_NAME'];
+    $array = explode('/',$sname);
+    $sname = array_pop($array);
+    unset($array);
+
+    include("../../../banana/$sname");
+}
+
+?>
diff --git a/htdocs/banana/include/header.inc.php b/htdocs/banana/include/header.inc.php
new file mode 100644 (file)
index 0000000..acb6c35
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+?>
diff --git a/htdocs/banana/include/password.inc.php b/htdocs/banana/include/password.inc.php
new file mode 100644 (file)
index 0000000..0a8ec3c
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$sname = $_SERVER['SCRIPT_NAME'];
+$array = explode('/',$sname);
+$sname = array_pop($array);
+unset($array);
+
+if ($sname == "spoolgen.php") {
+    require('config.xorg.inc.php');
+    $news["user"]=$news_web_user;
+    $news["pass"]=$news_web_pass;
+} elseif (isset($_SESSION['forlife'])) {
+    $news["user"]="web_pierre.habouzit";#.$_SESSION['forlife'];
+    $news["pass"]=$news_auth_pass;
+}
+$news['server']="$news_server:$news_port";
+?>
diff --git a/htdocs/banana/include/profile.inc.php b/htdocs/banana/include/profile.inc.php
new file mode 100644 (file)
index 0000000..c1878fa
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+/********************************************************************************
+* install.d/profile.inc.php : class for posts
+* -----------------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+/** checkcancel : sets cancel rights
+ * @param $_headers OBJECT headers of message to cancel
+ * @return BOOLEAN true if user has right to cancel message
+ */
+
+function checkcancel($_headers) {
+    return ($_headers->xorgid == $_SESSION['forlife'] or has_perms());
+}
+
+/** getprofile : sets profile variables
+ * @return ARRAY associative array. Keys are 'name' (name), 'sig' (signature), 'org' 
+ *   (organization), 'display' (display threads with new posts only or all threads),
+ *   'lastnews' (timestamp for empasizing new posts)
+ */
+
+function getprofile() {
+    if (logged()) {
+       $req = mysql_query("SELECT  nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
+                                   IF(FIND_IN_SET('automaj',flags),'1','0') 
+                             FROM  forums.profils
+                            WHERE  uid='{$_SESSION['uid']}'");
+       if (!(list($nom,$mail,$sig,$disp,$maj)=mysql_fetch_row($req))) {
+           $nom = $_SESSION['prenom']." ".$_SESSION['nom'];
+           $mail = $_SESSION['forlife']."@polytechnique.org";
+           $sig = $nom." (".$_SESSION['promo'].")";
+           $disp = 0;
+           $maj = 1;
+       }
+       $array['name'] = "$nom <$mail>";
+       $array['sig'] = $sig;
+       $array['org']  = "Utilisateur de Polytechnique.org";
+       $array['customhdr'] = "";
+       $array['display'] = $disp;
+       $array['autoup'] = $maj;
+       $array['lastnews'] = $_SESSION['lastnewslogin'];
+       $array['dropsig'] = true;
+       if ($maj) {
+           mysql_query("UPDATE auth_user_md5 SET lastnewslogin='"
+               .gmdate("YmdHis")."' WHERE user_id='{$_SESSION['uid']}'");
+       }
+       $req=mysql_query("SELECT  nom
+                           FROM  forums.abos
+                      LEFT JOIN  forums.list ON list.fid=abos.fid
+                          WHERE  uid={$_SESSION['uid']};");
+       $array['subscribe']=array();
+       while (list($fnom)=mysql_fetch_array($req)) {
+           array_push($array['subscribe'],$fnom);
+       }
+    } else {
+       $array = array();
+    }
+    $array['locale'] = "locales/fr.inc.php";
+    return $array;
+}
+?>
diff --git a/htdocs/banana/include/session.inc.php b/htdocs/banana/include/session.inc.php
new file mode 100644 (file)
index 0000000..a845aaf
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/********************************************************************************
+* include/session.inc.php : sessions for profile
+* -------------------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+$sname = $_SERVER['SCRIPT_NAME'];
+$array = explode('/',$sname);
+$sname = array_pop($array);
+unset($array);
+switch ($sname) {
+  case "thread.php":
+    if (!isset($_SESSION['bananapostok'])) 
+      $_SESSION['bananapostok']=true;
+    break;
+  case "index.php":
+    if (isset($_GET["banana"]) && ($_GET["banana"]=="updateall")) {
+      mysql_query("UPDATE auth_user_md5 SET lastnewslogin='"
+              .gmdate("YmdHis")."' WHERE user_id='{$_SESSION['uid']}'");
+      $_SESSION["lastnewslogin"]=time();
+    }
+  default:
+    $_SESSION['bananapostok']=true;
+    break;
+}
+?>
diff --git a/htdocs/banana/include/subscribe.inc.php b/htdocs/banana/include/subscribe.inc.php
new file mode 100644 (file)
index 0000000..649265c
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+  /** mise à jour des abonnements
+   * @param $_subscriptions ARRAY liste des forums auxquel l'utilisateur est abonné
+   */
+
+function update_subscriptions($_subscriptions) {
+  mysql_query("DELETE FROM forums.abos WHERE uid='{$_SESSION['uid']}'");
+  if (!count($_subscriptions)) {
+    return true;
+  }
+  // Récupération des fid
+  $req = mysql_query("SELECT fid,nom FROM forums.list");
+  $fids=array();
+  while (list($fid,$fnom)=mysql_fetch_row($req)) {
+    $fids[$fnom]=$fid;
+  }
+  // MAJ table de forums
+  if (count(array_keys($fids))) {
+    $diff = array_diff($_subscriptions,array_keys($fids));
+  } else {
+    $diff = $_subscriptions;
+  }
+  if (count($diff)) {
+    foreach ($diff as $g) {
+      mysql_query("INSERT INTO forums.list (nom) VALUES ('$g')");
+      $fids[$g]=mysql_insert_id();
+    }
+  }
+  // MAJ Abonnements
+  foreach ($_subscriptions as $g) {
+    mysql_query("REPLACE INTO forums.abos (fid,uid) VALUES "
+        ."('{$fids[$g]}','{$_SESSION['uid']}')");
+  }
+}
+
+?>
diff --git a/htdocs/banana/index.php b/htdocs/banana/index.php
new file mode 100644 (file)
index 0000000..cff7f97
--- /dev/null
@@ -0,0 +1,18 @@
+<?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('auto.prepend.inc.php');
+new_skinned_page('banana.tpl', AUTH_COOKIE, true, 'banana.head.tpl');
+$page->caching = false;
+require('hack.inc.php');
+
+$page->register_function('banana', 'banana', false);
+
+$page->run();
+?>
diff --git a/htdocs/banana/install.sh b/htdocs/banana/install.sh
new file mode 100755 (executable)
index 0000000..ce25a36
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+ln -sf ../../../banana/{img,locales,scripts} .
+
+pushd include &> /dev/null
+ln -sf ../../../../banana/include/*.php .
+popd &> /dev/null
+
+chmod a+w spool
diff --git a/htdocs/banana/post.php b/htdocs/banana/post.php
new file mode 100644 (file)
index 0000000..cff7f97
--- /dev/null
@@ -0,0 +1,18 @@
+<?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('auto.prepend.inc.php');
+new_skinned_page('banana.tpl', AUTH_COOKIE, true, 'banana.head.tpl');
+$page->caching = false;
+require('hack.inc.php');
+
+$page->register_function('banana', 'banana', false);
+
+$page->run();
+?>
diff --git a/htdocs/banana/scripts/spoolgen.php b/htdocs/banana/scripts/spoolgen.php
new file mode 100755 (executable)
index 0000000..996aee0
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/********************************************************************************
+* spoolgen.php : spool generation
+* --------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+ini_set('max_execution_time','300');
+ini_set('include_path', '..:../include:../../include:../../../include');
+
+require("include/encoding.inc.php");
+require("include/config.inc.php");
+require("include/NetNNTP.inc.php");
+include("include/post.inc.php");
+include("include/groups.inc.php");
+require("include/spool.inc.php");
+require("include/password.inc.php");
+
+
+$nntp = new nntp($news['server']);
+if (!$nntp) {
+  print "cannot connect to server\n";
+  exit;
+}
+
+if ($news['user']!="anonymous") {
+  $result = $nntp->authinfo($news["user"],$news["pass"]);
+  if (!$result) {
+    print "authentication error\n";
+    exit;
+  }
+}
+unset($result);
+
+$groups = new groups($nntp,2);
+$list = array_keys($groups->overview);
+unset($groups);
+foreach ($list as $g) {
+  print "Generating spool for $g : ";
+  $spool = new spool($nntp,$g);
+  print "done.\n";
+  unset($spool);
+}
+$nntp->quit();
+?>
diff --git a/htdocs/banana/spool/.cvsignore b/htdocs/banana/spool/.cvsignore
new file mode 100644 (file)
index 0000000..72e8ffc
--- /dev/null
@@ -0,0 +1 @@
+*
diff --git a/htdocs/banana/subscribe.php b/htdocs/banana/subscribe.php
new file mode 100644 (file)
index 0000000..cff7f97
--- /dev/null
@@ -0,0 +1,18 @@
+<?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('auto.prepend.inc.php');
+new_skinned_page('banana.tpl', AUTH_COOKIE, true, 'banana.head.tpl');
+$page->caching = false;
+require('hack.inc.php');
+
+$page->register_function('banana', 'banana', false);
+
+$page->run();
+?>
diff --git a/htdocs/banana/thread.php b/htdocs/banana/thread.php
new file mode 100644 (file)
index 0000000..cff7f97
--- /dev/null
@@ -0,0 +1,18 @@
+<?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('auto.prepend.inc.php');
+new_skinned_page('banana.tpl', AUTH_COOKIE, true, 'banana.head.tpl');
+$page->caching = false;
+require('hack.inc.php');
+
+$page->register_function('banana', 'banana', false);
+
+$page->run();
+?>
diff --git a/htdocs/banana/xface.php b/htdocs/banana/xface.php
new file mode 100644 (file)
index 0000000..cff7f97
--- /dev/null
@@ -0,0 +1,18 @@
+<?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('auto.prepend.inc.php');
+new_skinned_page('banana.tpl', AUTH_COOKIE, true, 'banana.head.tpl');
+$page->caching = false;
+require('hack.inc.php');
+
+$page->register_function('banana', 'banana', false);
+
+$page->run();
+?>
diff --git a/htdocs/confbanana.php b/htdocs/confbanana.php
new file mode 100644 (file)
index 0000000..9dacf9e
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+/***************************************************************************
+ *  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                *
+ ***************************************************************************
+        $Id: confbanana.php,v 1.1 2004-09-26 15:02:32 x2000habouzit Exp $
+ ***************************************************************************/
+
+require("auto.prepend.inc.php");
+new_skinned_page('confbanana.tpl', AUTH_MDP);
+
+if (!(isset($_POST["action"]) && isset($_POST["banananame"]) && 
+       isset($_POST["bananasig"]) &&  isset($_POST["bananadisplay"]) && 
+       isset($_POST["bananamail"]) && isset($_POST["bananaupdate"])
+       && $_POST["action"]=="OK" ))
+{
+  
+    $req = $globals->db->query("
+       SELECT  nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
+               IF(FIND_IN_SET('automaj',flags),'1','0') 
+         FROM  forums.profils
+        WHERE  uid='{$_SESSION['uid']}'");
+    if (!(list($nom,$mail,$sig,$disp,$maj)=mysql_fetch_row($req))) {
+       $nom = $_SESSION["prenom"]." ".$_SESSION["nom"];
+       $mail = $_SESSION["forlife"]."@polytechnique.org";
+       $sig = $nom." ({$_SESSION['promo']})";
+       $disp=0;
+       $maj=0;
+    }
+    $page->assign('nom', $nom);
+    $page->assign('mail', $mail);
+    $page->assign('sig', $sig);
+    $page->assign('disp', $disp);
+    $page->assign('maj', $maj);
+} else {
+  mysql_query("REPLACE INTO forums.profils (uid,sig,mail,nom,flags)
+                    VALUES ('{$_SESSION['uid']}','{$_POST['bananasig']}',
+                            '{$_POST['bananamail']}','{$_POST['banananame']}',
+                            '".($_POST['bananadisplay']?"threads":"").","
+                              .($_POST['bananaupdate']?"automaj":"")."')");
+}
+
+$page->run();
+?>
diff --git a/templates/banana.head.tpl b/templates/banana.head.tpl
new file mode 100644 (file)
index 0000000..5cf1d3f
--- /dev/null
@@ -0,0 +1,25 @@
+{***************************************************************************
+ *  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                *
+ ***************************************************************************
+        $Id: banana.head.tpl,v 1.1 2004-09-26 15:02:34 x2000habouzit Exp $
+ ***************************************************************************}
+
+<link rel="stylesheet" type="text/css" href="banana.css" media="screen" />
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/banana.tpl b/templates/banana.tpl
new file mode 100644 (file)
index 0000000..1eb7535
--- /dev/null
@@ -0,0 +1,25 @@
+{***************************************************************************
+ *  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                *
+ ***************************************************************************
+        $Id: banana.tpl,v 1.1 2004-09-26 15:02:34 x2000habouzit Exp $
+ ***************************************************************************}
+
+{banana}
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/confbanana.tpl b/templates/confbanana.tpl
new file mode 100644 (file)
index 0000000..f804a12
--- /dev/null
@@ -0,0 +1,122 @@
+{***************************************************************************
+ *  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                *
+ ***************************************************************************
+        $Id: confbanana.tpl,v 1.1 2004-09-26 15:02:34 x2000habouzit Exp $
+ ***************************************************************************}
+<div class="rubrique">
+  Configuration de Banana
+</div>
+
+{dynamic}
+{if !$smarty.post}
+
+<p class="normal">
+  Tu peux régler quelques paramètres qui apparaîtront sur les messages lorsque 
+  tu posteras sur les forums. Cela ne te permettra pas d'être anonyme, puisque
+  tout le monde pourra remonter à ton identité en regardant ta fiche. L'objectif
+  est simplement de permettre plus de convivialité.
+</p>
+<p class="normal">
+  Tu pourras voir dans les forums les nouveaux messages mis en valeur (en
+  général en gras). Si tu consultes les forums régulièrement, tu peux en avoir
+  assez de voir tout le contenu du forum : la dernière option te permet de
+  n'afficher que les fils de discussion contenant des messages lus.
+</p>
+<p class="normal">
+  Retour aux <a href="banana/index.php">forums</a>
+</p>
+
+<form action="{$smarty.server.PHP_SELF}" method="post">
+  <table class="bicol" cellpadding="3" cellspacing="0" summary="Configuration de Banana">
+    <tr>
+      <th colspan="2">
+        Profil Banana
+      </th>
+    </tr>
+    <tr class="pair">
+      <td class="bicoltitre">
+        Nom
+      </td>
+      <td>
+        <input type="text" name="banananame" value="{$nom}" />
+      </td>
+    </tr>
+    <tr class="impair">
+      <td class="bicoltitre">
+        Adresse électronique
+      </td>
+      <td>
+        <input type="text" name="bananamail" value="{$mail}" />
+      </td>
+    </tr>
+    <tr class="pair">
+      <td class="bicoltitre">
+        Signature
+      </td>
+      <td>
+        <textarea name="bananasig" cols="50" rows="4">{$sig}</textarea>
+      </td>
+    </tr>
+    <tr class="impair">
+      <td class="bicoltitre">
+        Affichage des fils de discussion
+      </td>
+      <td>
+        <input type="radio" name="bananadisplay" value="0" 
+        {if !$disp}checked="checked"{/if} /> Afficher tous 
+        les messages
+        <br />
+        <input type="radio" name="bananadisplay" value="1" 
+        {if $disp}checked="checked"{/if} /> Afficher 
+        seulement les fils de discussion contenant des messages non lus 
+      </td>
+    </tr>
+    <tr class="pair">
+      <td class="bicoltitre">
+        Mise à jour des messages non lus
+      </td>
+      <td>
+        <input type="radio" name="bananaupdate" value="1" 
+        {if $maj}checked="checked"{/if} /> Automatique
+        <br />
+        <input type="radio" name="bananaupdate" value="0" 
+        {if !$maj}checked="checked"{/if} /> Manuelle
+      </td>
+    </tr>
+    <tr class="impair">
+      <td class="bouton" colspan="2">
+        <input type="submit" name="action" value="OK" />
+      </td>
+    </tr>
+  </table>
+</form>
+
+{else}
+<p class="normal">
+  Ton profil est enregistré !!!
+</p>
+<p class="normal">
+  Retour aux <a href="banana/index.php">forums</a>
+</p>
+{/if}
+
+{/dynamic}
+
+{* vim:set et sw=2 sts=2 sws=2: *}