2dbc0167 |
1 | <?php |
2 | /******************************************************************************** |
3 | * install.d/config.inc.php : configuration file |
4 | * -------------------------- |
5 | * |
6 | * This file is part of the banana distribution |
7 | * Copyright: See COPYING files that comes with this distribution |
8 | ********************************************************************************/ |
9 | |
2dbc0167 |
10 | require_once("include/misc.inc.php"); |
2dbc0167 |
11 | require_once("include/error.inc.php"); |
2dbc0167 |
12 | |
13 | class Banana |
14 | { |
15 | var $maxspool = 3000; |
16 | |
17 | var $hdecode = array('from','name','organization','subject'); |
18 | var $parse_hdr = array('content-transfer-encoding', 'content-type', 'date', 'followup-to', 'from', |
19 | 'message-id', 'newsgroups', 'organization', 'references', 'subject', 'x-face'); |
20 | var $show_hdr = array('from', 'subject', 'newsgroups', 'followup', 'date', 'organization', 'references', 'x-face'); |
21 | |
22 | |
23 | var $tbefore = 5; |
24 | var $tafter = 5; |
25 | var $tmax = 50; |
26 | |
27 | var $wrap = 74; |
28 | |
29 | var $custom = "Content-Type: text/plain; charset=iso-8859-15\nMime-Version: 1.0\nContent-Transfer-Encoding: 8bit\nUser-Agent: Banana @VERSION@\n"; |
30 | |
31 | var $host = 'news://localhost:119/'; |
32 | |
33 | var $profile = Array( 'name' => 'Anonymous <anonymouse@example.com', 'sig' => '', 'org' => '', |
1dd3e06a |
34 | 'customhdr' =>'', 'display' => 0, 'lastnews' => 0, 'locale' => 'fr_FR', 'subscribe' => array()); |
2dbc0167 |
35 | |
36 | var $nntp; |
1dd3e06a |
37 | var $groups; |
38 | var $newgroups; |
b9ea5b30 |
39 | var $post; |
1dd3e06a |
40 | var $spool; |
2dbc0167 |
41 | |
42 | function Banana() |
43 | { |
44 | if (function_exists('hook_banana')) { |
45 | hook_banana($this); |
46 | } |
47 | $this->_setupProfile(); |
48 | require_once('include/NetNNTP.inc.php'); |
49 | $this->nntp = new nntp($this->host); |
50 | } |
51 | |
1dd3e06a |
52 | /**************************************************************************/ |
53 | /* actions */ |
54 | /**************************************************************************/ |
55 | |
56 | function action_listGroups() |
57 | { |
6fa87b6e |
58 | $this->newGroup(); |
1dd3e06a |
59 | |
60 | $cuts = displayshortcuts(); |
61 | $res = '<h1>'._b_('Les forums de Banana').'</h1>'.$cuts.$this->groups->to_html(); |
62 | if (count($this->newgroups->overview)) { |
63 | $res .= '<p>'._b_('Les forums suivants ont été créés depuis ton dernier passage :').'</p>'; |
64 | $res .= $this->newgroups->to_html(); |
65 | } |
66 | |
67 | $this->nntp->quit(); |
68 | return $res.$cuts; |
69 | } |
70 | |
6fa87b6e |
71 | function action_listSubs() |
72 | { |
73 | require_once("include/groups.inc.php"); |
74 | $this->groups = new BananaGroups(BANANA_GROUP_ALL); |
75 | |
76 | $cuts = displayshortcuts(); |
77 | $res = '<h1>'._b_('Abonnements').'</h1>'.$cuts.$this->groups->to_html(true).$cuts; |
78 | |
79 | $this->nntp->quit(); |
80 | return $res; |
81 | } |
82 | |
1dd3e06a |
83 | function action_showThread($group, $first) |
84 | { |
85 | $this->newSpool($group, $this->profile['display'], $this->profile['lastnews']); |
86 | |
87 | if ($first > count($this->spool->overview)) { |
88 | $first = count($this->spool->overview); |
89 | } |
90 | |
91 | $first = $first - ($first % $this->tmax) + 1; |
92 | |
93 | $cuts = displayshortcuts($first); |
94 | |
95 | $res = '<h1>'.$group.'</h1>'.$cuts; |
96 | $res .= $this->spool->to_html($first, $first+$this->tmax); |
97 | |
98 | $this->nntp->quit(); |
99 | |
100 | return $res.$cuts; |
101 | } |
102 | |
103 | function action_showArticle($group, $id) |
104 | { |
105 | $this->newSpool($group, $this->profile['display'], $this->profile['lastnews']); |
106 | $this->newPost($id); |
107 | if (!$this->post) { |
108 | if ($this->nntp->lasterrorcode == "423") { |
109 | $this->spool->delid($id); |
110 | } |
111 | $this->nntp->quit(); |
112 | return displayshortcuts().'<p class="error">'._b_('Impossible d\'accéder au message. Le message a peut-être été annulé').'</p>'; |
113 | } |
114 | |
115 | $cuts = displayshortcuts(); |
116 | $res = '<h1>'._b_('Message').'</h1>'.$cuts; |
117 | $res .= $this->post->to_html(); |
118 | |
119 | $this->nntp->quit(); |
120 | |
121 | return $res.$cuts; |
122 | } |
123 | |
124 | /**************************************************************************/ |
125 | /* */ |
126 | /**************************************************************************/ |
127 | |
2dbc0167 |
128 | function newSpool($group, $disp=0, $since='') { |
129 | require_once('include/spool.inc.php'); |
130 | $this->spool = new BananaSpool($group, $disp, $since); |
2dbc0167 |
131 | } |
132 | |
b9ea5b30 |
133 | function newPost($id) |
134 | { |
135 | require_once("include/post.inc.php"); |
136 | $this->post = new BananaPost($id); |
137 | } |
138 | |
1dd3e06a |
139 | function newGroup() |
140 | { |
141 | require_once("include/groups.inc.php"); |
142 | $this->groups = new BananaGroups(BANANA_GROUP_SUB); |
143 | if ($this->groups->type == BANANA_GROUP_SUB) { |
144 | $this->newgroups = new BananaGroups(BANANA_GROUP_NEW); |
145 | } |
146 | } |
147 | |
148 | /**************************************************************************/ |
149 | /* */ |
150 | /**************************************************************************/ |
151 | |
2dbc0167 |
152 | function _setupProfile() |
153 | { |
154 | if (function_exists('hook_getprofile')) { |
155 | $this->profile = hook_getprofile(); |
2dbc0167 |
156 | } |
157 | |
1dd3e06a |
158 | setlocale(LC_ALL, $this->profile['locale']); |
2dbc0167 |
159 | } |
160 | } |
161 | |
162 | $banana = new Banana; |
163 | |
2dbc0167 |
164 | ?> |