From: Pierre Habouzit (MadCoder Date: Mon, 3 Jan 2005 11:28:40 +0000 (+0000) Subject: update banana X-Git-Tag: xorg/old~535 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=d7eaa2694a348fd67d16aa482a5b1a3600dfbeaf;p=platal.git update banana git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-213 --- diff --git a/htdocs/banana/include/config.inc.php b/htdocs/banana/include/config.inc.php deleted file mode 100644 index f35d725..0000000 --- a/htdocs/banana/include/config.inc.php +++ /dev/null @@ -1,130 +0,0 @@ -xdb->execute('UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}', gmdate('YmdHis'), Session::getInt('uid')); - $_SESSION['banana_last'] = time(); - } -} - - -function hook_banana(&$banana) { - global $globals; - - 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'); - - - $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)?" [fiche]":""); - - default: - return htmlentities($_text); - } -} - -function hook_header_translate($hdr) { - switch ($hdr) { - case 'x-org-id': return 'Identité'; - - default: - return $hdr; - } -} - -function hook_checkcancel($_headers) { - return ($_headers['x-org-id'] == Session::get('forlife') or has_perms()); -} - -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; -} - - -global $css; -$css = array( - 'bananashortcuts' => 'bananashortcuts', - '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/format.inc.php b/htdocs/banana/include/format.inc.php deleted file mode 100644 index ec83714..0000000 --- a/htdocs/banana/include/format.inc.php +++ /dev/null @@ -1,75 +0,0 @@ -"; - - switch ($sname) { - case 'subscribe.php' : - echo '[Liste des forums] '; - echo '[Profil] '; - break; - case 'index.php' : - if (!$banana->profile['autoup']) { - echo '[Mettre à jour] '; - } - echo '[Profil] '; - echo '[Abonnements] '; - break; - case 'thread.php' : - if (!$banana->profile['autoup']) { - echo '[Mettre à jour] '; - } - echo '[Profil] '; - echo '['._('Liste des forums').'] '; - echo "[spool->group}\">"._('Nouveau message')."] "; - 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+$banana->tmax-1,sizeof($banana->spool->overview))."] "; - } else { - echo "[spool->group}&first=$ndx\">$ndx-".min($ndx+$banan->tmax-1,sizeof($banana->spool->overview))."] "; - } - } - } - break; - case 'article.php' : - if (!$banana->profile['autoup']) { - echo '[Mettre à jour] '; - } - echo '[Profil] '; - echo '['._('Liste des forums').'] '; - echo "[spool->group}\">{$banana->spool->group}]"; - echo "[spool->group}&id={$banana->post->id}&type=followup\">" - ._('Répondre')."] "; - if ($banana->post->checkcancel()) { - echo "[spool->group}&id={$banana->post->id}&type=cancel\">" - ._('Annuler ce message')."] "; - } - break; - case 'post.php' : - if (!$banana->profile['autoup']) { - echo '[Mettre à jour] '; - } - echo '[Profil] '; - echo '['._('Liste des forums').'] '; - echo "[spool->group}\">{$banana->spool->group}] "; - break; - } - echo ''; -} - -?> - diff --git a/htdocs/banana/include/hack.inc.php b/htdocs/banana/include/hack.inc.php index 3a18053..e5f59b8 100644 --- a/htdocs/banana/include/hack.inc.php +++ b/htdocs/banana/include/hack.inc.php @@ -1,10 +1,154 @@ xdb->execute('UPDATE auth_user_quick SET banana_last={?} WHERE user_id={?}', gmdate('YmdHis'), Session::getInt('uid')); + $_SESSION['banana_last'] = time(); + } +} + +function hook_banana(&$banana) { + global $globals; + + 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'); + + + $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_displayshortcuts($sname, $first = -1) { + global $banana,$css; + + switch ($sname) { + case 'subscribe.php' : + echo '[Liste des forums] '; + echo '[Profil] '; + break; + + case 'index.php' : + case 'thread.php' : + case 'article.php' : + case 'post.php' : + if (!$banana->profile['autoup']) { + echo '[Mettre à jour] '; + } + echo '[Profil] '; + break; + } +} + +function hook_formatDisplayHeader($_header,$_text) { + global $banana; + switch ($_header) { + case "x-org-id": + return "$_text".(preg_match("/[\w]+\.[\w\d]+/",$_text)?" [fiche]":""); + + default: + return htmlentities($_text); + } +} + +function hook_header_translate($hdr) { + switch ($hdr) { + case 'x-org-id': return 'Identité'; + + default: + return $hdr; + } +} + +function hook_checkcancel($_headers) { + return ($_headers['x-org-id'] == Session::get('forlife') or has_perms()); +} + +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; +} + +$css = array( + 'bananashortcuts' => 'bananashortcuts', + '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' +); + function banana($params) { global $globals, $page; global $banana,$css; $sname = basename($_SERVER['SCRIPT_NAME']); - require_once('config.inc.php'); require_once("../../../banana/$sname"); }