update banana
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Mon, 3 Jan 2005 08:47:27 +0000 (08:47 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:09 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-209

htdocs/banana/.arch-inventory
htdocs/banana/include/config.inc.php
htdocs/banana/include/format.inc.php
htdocs/banana/include/hack.inc.php
htdocs/banana/include/password.inc.php [deleted file]
htdocs/banana/include/profile.inc.php [deleted file]
htdocs/banana/install.sh
htdocs/banana/xface.php [deleted file]

index 15b777d..a19da22 100644 (file)
@@ -1 +1 @@
-precious ^(img|locales|spool)
+precious ^(img|spool|xface.php)
index 61b5b24..56f0021 100644 (file)
 <?php
 
-// spool config in spool.inc.php
-$news['maxspool'] = 2000;
+function hook_banana(&$banana) {
+    global $globals;
 
-// encoded headers
-$news['hdecode'] = array('from','name','organization','subject');
+    array_splice($banana->show_hdr,  count($banana->show_hdr)  - 2, 0, 'x-org-id');
+    array_splice($banana->parse_hdr, count($banana->parse_hdr) - 2, 0, 'x-org-id');
 
-// headers in post
-$news['head'] = array('from', 'subject', 'newsgroups', 'message-id', 'followup-to', 'date',
-    'x-org-id', 'organization', 'references', 'x-face', 'content-type', 'content-transfer-encoding');
 
-// headers in article.php
-$news['headdisp'] = array(
-  'from',
-  'subject',
-  'newsgroups',
-  'followup-id',
-  'date',
-  'organization',
-  'references',
-  'x-org-id',
-  'x-face',
-);
-$locale['headers']['xorgid']='Identité';
+    $serv  = "{$globals->banana->server}:{$globals->banana->port}/";
+    $sname = basename($_SERVER['SCRIPT_NAME']);
+    if ($sname == "spoolgen.php") {
+        $banana->host = "news://{$globals->banana->web_user}:{$globals->banana->web_pass}@$serv";
+    } elseif (Session::has('forlife')) {
+        $banana->host = 'news://web_'.Session::get('forlife').":{$globals->banana->password}@$serv";
+    }
+}
+
+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 '';
+}
+
+function hook_formatDisplayHeader($_header,$_text) {
+    global $banana;
+    switch ($_header) {
+        case "x-org-id":
+            return "$_text".(preg_match("/[\w]+\.[\w\d]+/",$_text)?" [<a href=\"".url("fiche.php")."?user=$_text\" class='popup2'>fiche</a>]":"");
+
+        default:
+            return htmlentities($_text);
+    }
+}
 
-// overview configuration in article.php
-$news['threadtop'] = 5;
-$news['threadbottom'] = 5;
+function hook_header_translate($hdr) {
+    switch ($hdr) {
+        case 'x-org-id': return 'Identité';
+            
+        default:      
+            return $hdr;
+    }
+}
 
-// wordwrap configuration
-$news['wrap'] = 80;
+function hook_checkcancel($_headers) {
+    return ($_headers['x-org-id'] == Session::get('forlife') or has_perms());
+}
 
-// overview configuration in thread.php
-$news['max'] = 50;
+function hook_getprofile() {
+    if (logged()) {
+        global $globals;
+        
+        $uid = Session::getInt('uid');
+       $req = $globals->xdb->query(
+                "SELECT  nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
+                         IF(FIND_IN_SET('automaj',flags),'1','0') 
+                   FROM  {$globals->banana->table_prefix}profils
+                  WHERE  uid={?}", $uid);
+       if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
+           $nom  = Session::get('prenom')." ".Session::get('nom');
+           $mail = Session::get('forlife')."@polytechnique.org";
+           $sig  = $nom." (".Session::getInt('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::get('banana_last');
+       if ($maj) {
+            $globals->xdb->execute("UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}", gmdate("YmdHis"), $uid);
+       }
+       $req = $globals->xdb->query(
+                "SELECT  nom
+                   FROM  {$globals->banana->table_prefix}abos
+              LEFT JOIN  {$globals->banana->table_prefix}list ON list.fid=abos.fid
+                  WHERE  uid={?}", $uid);
+       $array['subscribe'] = $req->fetchColumn();
+    } else {
+       $array = array();
+    }
+    $array['locale'] = 'fr';
+    return $array;
+}
 
-// 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";
 
+global $css;
 $css = array(
  'bananashortcuts' => 'bananashortcuts',
  'bicol' => 'bicol',
index b491fba..6908c1e 100644 (file)
@@ -7,78 +7,11 @@
 * 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 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) {
-    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="thread.php?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,$_spool->ids));
-            $parents=preg_grep("/^\d+$/",$text);
-            $p=array_pop($parents);
-            $valid_parents = Array();
-            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 "x-face":
-            return '<img src="xface.php?face='.base64_encode($_text).'"  alt="x-face" />';
-
-        case "x-org-id":
-            return "$_text".(preg_match("/[\w]+\.[\w\d]+/",$_text)?" [<a href=\"".url("fiche.php")."?user=$_text\" class='popup2'>fiche</a>]":"");
-
-        default:
-            return htmlentities($_text);
-    }
-}
-
 /** contextual links 
  * @return STRING HTML output
  */
 function displayshortcuts() {
-    global $news,$first,$spool,$group,$post,$id,$profile,$css;
+    global $banana,$first,$group,$post,$id,$css;
     $sname = basename($_SERVER['SCRIPT_NAME']);
 
     echo "<div class=\"{$css['bananashortcuts']}\">";
@@ -89,31 +22,31 @@ function displayshortcuts() {
             echo '[<a href="'.url("confbanana.php").'">Profil</a>] ';
             break;
         case 'index.php' :
-            if (!$profile['autoup']) { 
+            if (!$banana->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']) { 
+            if (!$banana->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">'._('Liste des forums').'</a>] ';
             echo "[<a href=\"post.php?group=$group\">"._('Nouveau message')."</a>] ";
-            if (sizeof($spool->overview)>$news['max']) {
-                for ($ndx=1; $ndx<=sizeof($spool->overview); $ndx += $news['max']) {
+            if (sizeof($banana->spool->overview)>$banana->tmax) {
+                for ($ndx=1; $ndx<=sizeof($banana->spool->overview); $ndx += $banana->tmax) {
                     if ($first==$ndx) {
-                        echo "[$ndx-".min($ndx+$news['max']-1,sizeof($spool->overview))."] ";
+                        echo "[$ndx-".min($ndx+$banana->tmax-1,sizeof($banana->spool->overview))."] ";
                     } else {
-                        echo "[<a href=\"?group=$group&amp;first=$ndx\">$ndx-".min($ndx+$news['max']-1,sizeof($spool->overview))."</a>] ";
+                        echo "[<a href=\"?group=$group&amp;first=$ndx\">$ndx-".min($ndx+$banan->tmax-1,sizeof($banana->spool->overview))."</a>] ";
                     }
                 }
             }
             break;
         case 'article.php' :
-            if (!$profile['autoup']) { 
+            if (!$banana->profile['autoup']) { 
                 echo '[<a href="index.php?banana=updateall">Mettre à jour</a>] ';
             }
             echo '[<a href="'.url("confbanana.php").'">Profil</a>] ';
@@ -125,7 +58,7 @@ function displayshortcuts() {
             }
             break;
         case 'post.php' :
-            if (!$profile['autoup']) { 
+            if (!$banana->profile['autoup']) { 
                 echo '[<a href="index.php?banana=updateall">Mettre à jour</a>] ';
             }
             echo '[<a href="'.url("confbanana.php").'">Profil</a>] ';
index be72b0f..0dba042 100644 (file)
@@ -2,17 +2,15 @@
     
 function banana($params) {
     global $globals, $page;
-    global $news,$locale,$first,$spool,$group,$post,$id,$profile,$css;
-    $sname = $_SERVER['SCRIPT_NAME'];
-    $array = explode('/',$sname);
-    $sname = array_pop($array);
-    unset($array);
+    global $banana,$first,$group,$post,$id,$css;
+    $sname = basename($_SERVER['SCRIPT_NAME']);
 
     global $news_server,$news_port;
 
     $news_server    = $globals->banana->server;
     $news_port      = $globals->banana->port;
 
+    require_once('config.inc.php');
     require_once("../../../banana/$sname");
 }
 
diff --git a/htdocs/banana/include/password.inc.php b/htdocs/banana/include/password.inc.php
deleted file mode 100644 (file)
index 464480f..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-$sname = $_SERVER['SCRIPT_NAME'];
-$array = explode('/',$sname);
-$sname = array_pop($array);
-unset($array);
-
-if ($sname == "spoolgen.php") {
-    $news["user"] = $globals->banana->web_user;
-    $news["pass"] = $globals->banana->web_pass;
-} elseif (Session::has('forlife')) {
-    $news["user"]= "web_".Session::get('forlife');
-    $news["pass"]= $globals->banana->password;
-}
-$news['server']="$news_server:$news_port";
-?>
diff --git a/htdocs/banana/include/profile.inc.php b/htdocs/banana/include/profile.inc.php
deleted file mode 100644 (file)
index 26239c8..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?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['x-org-id'] == Session::get('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()) {
-        global $globals;
-        
-        $uid = Session::getInt('uid');
-       $req = $globals->xdb->query(
-                "SELECT  nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
-                         IF(FIND_IN_SET('automaj',flags),'1','0') 
-                   FROM  {$globals->banana->table_prefix}profils
-                  WHERE  uid={?}", $uid);
-       if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
-           $nom  = Session::get('prenom')." ".Session::get('nom');
-           $mail = Session::get('forlife')."@polytechnique.org";
-           $sig  = $nom." (".Session::getInt('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::get('banana_last');
-       $array['dropsig']   = true;
-       if ($maj) {
-            $globals->xdb->execute("UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}", gmdate("YmdHis"), $uid);
-       }
-       $req = $globals->xdb->query(
-                "SELECT  nom
-                   FROM  {$globals->banana->table_prefix}abos
-              LEFT JOIN  {$globals->banana->table_prefix}list ON list.fid=abos.fid
-                  WHERE  uid={?}", $uid);
-       $array['subscribe'] = $req->fetchColumn();
-    } else {
-       $array = array();
-    }
-    $array['locale'] = "locales/fr.inc.php";
-    return $array;
-}
-?>
index 4b5e5fb..f4bffc9 100755 (executable)
@@ -2,5 +2,7 @@
 ln -sf ../../../banana/{img,spool} .
 
 pushd include &> /dev/null
-ln -sf ../../../../banana/include/{encoding,groups,NetNNTP,post,spool,wrapper}.inc.php .
+ln -sf ../../../../banana/include/{groups,NetNNTP,post,spool,banana}.inc.php .
 popd &> /dev/null
+
+ln -sf ../../../banana/xface.php .
diff --git a/htdocs/banana/xface.php b/htdocs/banana/xface.php
deleted file mode 100644 (file)
index 98078c3..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-$face = base64_decode($_REQUEST['face']);
-$face = escapeshellarg($face);
-
-header("Content-Type: image/png");
-passthru("echo $face|uncompface -X |convert xbm:- png:-");
-
-?>