Mercurial > hg > pnewss
annotate server.php @ 14:372f4e195986 draft default tip
Added article blacklist function, switch to binary-safe latin1 character set for database
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Thu, 17 Jul 2014 23:24:17 +0200 |
parents | cccd73f72bf6 |
children |
rev | line source |
---|---|
0 | 1 #!/usr/bin/php |
2 <?php | |
8 | 3 /* Copyright 2010 Ivo Smits <Ivo@UCIS.nl>. All rights reserved. |
4 Redistribution and use in source and binary forms, with or without modification, are | |
5 permitted provided that the following conditions are met: | |
6 | |
7 1. Redistributions of source code must retain the above copyright notice, this list of | |
8 conditions and the following disclaimer. | |
9 | |
10 2. Redistributions in binary form must reproduce the above copyright notice, this list | |
11 of conditions and the following disclaimer in the documentation and/or other materials | |
12 provided with the distribution. | |
13 | |
14 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
15 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR | |
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
18 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
19 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |
20 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
21 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
22 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
23 | |
24 The views and conclusions contained in the software and documentation are those of the | |
25 authors and should not be interpreted as representing official policies, either expressed | |
26 or implied, of Ivo Smits.*/ | |
27 | |
2
40e545510a57
Added support for POSTing to the server, added readme and todo, added support for upstream synchronization using POST
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
28 chdir(__DIR__); |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
29 require_once './common.php'; |
0 | 30 |
31 $logfile = fopen('./server.log', 'w'); | |
32 $currentgroup = NULL; | |
33 $currentarticle = NULL; | |
34 | |
35 function exception_handler($exception) { | |
36 nntp_writeline(STDOUT, ''); | |
37 nntp_writeline(STDOUT, '590 Exception: '.$exception->getMessage()); | |
38 die(); | |
39 } | |
40 function error_handler($errno, $errstr, $errfile, $errline) { | |
41 nntp_writeline(STDOUT, ''); | |
42 nntp_writeline(STDOUT, '590 Error in file '.$errfile.' line '.$errline.' error '.$errno.' '.$errstr); | |
43 die(); | |
44 } | |
45 set_exception_handler('exception_handler'); | |
46 set_error_handler("error_handler"); | |
47 | |
48 nntp_writeline(STDOUT, '200 pNewss ready'); | |
49 while (TRUE) { | |
50 $line = nntp_readline(STDIN); | |
2
40e545510a57
Added support for POSTing to the server, added readme and todo, added support for upstream synchronization using POST
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
51 if ($line === FALSE || $line === NULL) break; |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
52 $cmd = strtoupper(strtok($line, " \t")); |
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
53 switch ($cmd) { |
12
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
54 case '': |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
55 break; |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
56 case 'MODE': |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
57 $mode = strtok(" \t"); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
58 switch (strtoupper($mode)) { |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
59 case 'READER': nntp_writeline(STDOUT, '200 Hello, you can post'); break; |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
60 case 'STREAM': nntp_writeline(STDOUT, '203 Streaming permitted'); break; |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
61 default: nntp_writeline(STDOUT, '501 Unknown MODE variant'); break; |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
62 } |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
63 break; |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
64 case 'CAPABILITIES': |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
65 nntp_writeline(STDOUT, '101 Capability list:'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
66 nntp_writeline_data(STDOUT, 'VERSION 2'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
67 nntp_writeline_data(STDOUT, 'IMPLEMENTATION pNewss [http://wiki.ucis.nl/pNewss]'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
68 nntp_writeline_data(STDOUT, 'POST'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
69 nntp_writeline_data(STDOUT, 'READER'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
70 nntp_writeline_data(STDOUT, 'IHAVE'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
71 nntp_writeline_data(STDOUT, 'LIST ACTIVE'); |
12
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
72 nntp_writeline_data(STDOUT, 'MODE-READER'); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
73 nntp_writeline_data(STDOUT, 'STREAMING'); |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
74 nntp_writeline(STDOUT, '.'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
75 break; |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
76 case 'DATE': |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
77 nntp_writeline(STDOUT, '111 '.gmdate('YmdHis')); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
78 break; |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
79 case 'HELP': |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
80 nntp_writeline(STDOUT, '100 Help text follows:'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
81 nntp_writeline_data(STDOUT, 'Supported commands: CAPABILITIES,DATE,HELP,LIST,GROUP,LISTGROUP,STAT,HEAD,BODY,ARTICLE,LAST,NEXT,POST,IHAVE,QUIT'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
82 nntp_writeline(STDOUT, '.'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
83 break; |
0 | 84 case 'LIST': |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
85 nntp_writeline(STDOUT, '215 list of groups follows'); |
0 | 86 foreach ($db->evalAllAssoc('SELECT * FROM `groups`') as $group) { |
87 $groupmessages = $db->evalRow('SELECT MIN(`number`), MAX(`number`) FROM `groupmessages` WHERE `group` = ?', $group['id']); | |
12
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
88 nntp_writeline_data(STDOUT, $group['name'].' '.intval($groupmessages[1]).' '.intval($groupmessages[0]).' y'); |
0 | 89 } |
90 nntp_writeline(STDOUT, '.'); | |
91 break; | |
92 case 'GROUP': | |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
93 case 'LISTGROUP': |
0 | 94 $groupname = strtok(" \t"); |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
95 if ($groupname === FALSE) { |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
96 $group = $currentgroup; |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
97 } else { |
13
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
98 $group = $db->evalRowAssoc('SELECT * FROM `groups` WHERE `name` = ?', array($groupname)); |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
99 } |
13
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
100 if (!$group) { |
0 | 101 nntp_writeline(STDOUT, '411 No such group '.$groupname); |
102 } else { | |
103 $currentgroup = $group; | |
104 $groupmessages = $db->evalRow('SELECT MIN(`number`), MAX(`number`), COUNT(`number`) FROM `groupmessages` WHERE `group` = ?', $group['id']); | |
105 nntp_writeline(STDOUT, '211 '.intval($groupmessages[2]).' '.intval($groupmessages[0]).' '.intval($groupmessages[1]).' '.$group['name']); | |
14
372f4e195986
Added article blacklist function, switch to binary-safe latin1 character set for database
Ivo Smits <Ivo@UCIS.nl>
parents:
13
diff
changeset
|
106 $currentarticle = $db->evalRowAssoc('SELECT * FROM `groupmessages` WHERE `group` = ? AND `message` IS NOT NULL ORDER BY `number` ASC LIMIT 1', $group['id']); |
372f4e195986
Added article blacklist function, switch to binary-safe latin1 character set for database
Ivo Smits <Ivo@UCIS.nl>
parents:
13
diff
changeset
|
107 if ($currentarticle === FALSE) $currentarticle = NULL; |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
108 if ($cmd == 'LISTGROUP') { |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
109 $range = strtok(" \t"); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
110 if ($range !== FALSE) { |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
111 $parts = explode('-', $range); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
112 if (count($parts) == 1 || !strlen($parts[1])) { |
14
372f4e195986
Added article blacklist function, switch to binary-safe latin1 character set for database
Ivo Smits <Ivo@UCIS.nl>
parents:
13
diff
changeset
|
113 $query = 'SELECT `number` FROM `groupmessages` WHERE `group` = ? AND `number` >= ? AND `message` IS NOT NULL'; |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
114 $queryargs = array($group['id'], $parts[0]); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
115 } else { |
14
372f4e195986
Added article blacklist function, switch to binary-safe latin1 character set for database
Ivo Smits <Ivo@UCIS.nl>
parents:
13
diff
changeset
|
116 $query = 'SELECT `number` FROM `groupmessages` WHERE `group` = ? AND `number` BETWEEN ? AND ? AND `message` IS NOT NULL'; |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
117 $queryargs = array($group['id'], $parts[0], $parts[1]); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
118 } |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
119 } else { |
14
372f4e195986
Added article blacklist function, switch to binary-safe latin1 character set for database
Ivo Smits <Ivo@UCIS.nl>
parents:
13
diff
changeset
|
120 $query = 'SELECT `number` FROM `groupmessages` WHERE `group` = ? AND `message` IS NOT NULL'; |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
121 $queryargs = array($group['id']); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
122 } |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
123 foreach ($db->evalColumn($query, $queryargs) as $number) nntp_writeline_data(STDOUT, $number); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
124 nntp_writeline(STDOUT, '.'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
125 } |
0 | 126 } |
127 break; | |
128 case 'STAT': | |
129 case 'HEAD': | |
130 case 'BODY': | |
131 case 'ARTICLE': | |
132 $article = nntp_get_article(strtok(" \t")); | |
133 if ($article === NULL) break; | |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
134 switch ($cmd) { |
5
5d62af5270dd
Small bugfix in server STAT command (no data follows, so don't send a dot)
Ivo Smits <Ivo@UCIS.nl>
parents:
3
diff
changeset
|
135 case 'ARTICLE': nntp_writeline(STDOUT, '220 '.$article['messagenumber'].' <'.$article['messageid'].'> article'); break; |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
136 case 'HEAD': nntp_writeline(STDOUT, '221 '.$article['messagenumber'].' <'.$article['messageid'].'> head'); break; |
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
137 case 'BODY': nntp_writeline(STDOUT, '222 '.$article['messagenumber'].' <'.$article['messageid'].'> body'); break; |
5
5d62af5270dd
Small bugfix in server STAT command (no data follows, so don't send a dot)
Ivo Smits <Ivo@UCIS.nl>
parents:
3
diff
changeset
|
138 case 'STAT': nntp_writeline(STDOUT, '223 '.$article['messagenumber'].' <'.$article['messageid'].'> stat'); break; |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
139 default: throw new Exception('Internal error'); |
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
140 } |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
141 if ($cmd == 'HEAD' || $cmd == 'ARTICLE') foreach (explode("\r\n", $article['header']) as $line) nntp_writeline_data(STDOUT, $line); |
10
ca88deec5352
Add Xref header when sending messages to client (seems to fix message corruption issues in Thunderbird)
Ivo Smits <Ivo@UCIS.nl>
parents:
8
diff
changeset
|
142 if ($cmd == 'HEAD' || $cmd == 'ARTICLE') { |
ca88deec5352
Add Xref header when sending messages to client (seems to fix message corruption issues in Thunderbird)
Ivo Smits <Ivo@UCIS.nl>
parents:
8
diff
changeset
|
143 $grouprefsh = array('localhost'); |
ca88deec5352
Add Xref header when sending messages to client (seems to fix message corruption issues in Thunderbird)
Ivo Smits <Ivo@UCIS.nl>
parents:
8
diff
changeset
|
144 foreach ($db->evalAllAssoc('SELECT * FROM `groupmessages` WHERE `message` = ?', $article['id']) as $groupref) { |
ca88deec5352
Add Xref header when sending messages to client (seems to fix message corruption issues in Thunderbird)
Ivo Smits <Ivo@UCIS.nl>
parents:
8
diff
changeset
|
145 $groupname = $db->eval('SELECT `name` FROM `groups` WHERE `id` = ?', $groupref['group']); |
ca88deec5352
Add Xref header when sending messages to client (seems to fix message corruption issues in Thunderbird)
Ivo Smits <Ivo@UCIS.nl>
parents:
8
diff
changeset
|
146 $grouprefsh[] = $groupname.':'.$groupref['number']; |
ca88deec5352
Add Xref header when sending messages to client (seems to fix message corruption issues in Thunderbird)
Ivo Smits <Ivo@UCIS.nl>
parents:
8
diff
changeset
|
147 } |
ca88deec5352
Add Xref header when sending messages to client (seems to fix message corruption issues in Thunderbird)
Ivo Smits <Ivo@UCIS.nl>
parents:
8
diff
changeset
|
148 nntp_writeline_data(STDOUT, 'Xref: '.implode(' ', $grouprefsh)); |
ca88deec5352
Add Xref header when sending messages to client (seems to fix message corruption issues in Thunderbird)
Ivo Smits <Ivo@UCIS.nl>
parents:
8
diff
changeset
|
149 } |
ca88deec5352
Add Xref header when sending messages to client (seems to fix message corruption issues in Thunderbird)
Ivo Smits <Ivo@UCIS.nl>
parents:
8
diff
changeset
|
150 if ($cmd == 'ARTICLE') nntp_writeline_data(STDOUT, ''); |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
151 if ($cmd == 'BODY' || $cmd == 'ARTICLE') foreach (explode("\r\n", $article['body']) as $line) nntp_writeline_data(STDOUT, $line); |
5
5d62af5270dd
Small bugfix in server STAT command (no data follows, so don't send a dot)
Ivo Smits <Ivo@UCIS.nl>
parents:
3
diff
changeset
|
152 if ($cmd != 'STAT') nntp_writeline(STDOUT, '.'); |
0 | 153 break; |
154 case 'LAST': | |
155 case 'NEXT': | |
156 if ($currentarticle === NULL) { | |
157 nntp_writeline(STDOUT, '420 no current article has been selected'); | |
158 break; | |
159 } | |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
160 switch ($cmd) { |
14
372f4e195986
Added article blacklist function, switch to binary-safe latin1 character set for database
Ivo Smits <Ivo@UCIS.nl>
parents:
13
diff
changeset
|
161 case 'LAST': $query = 'SELECT * FROM `groupmessages` WHERE `group` = ? AND `number` < ? AND `message` IS NOT NULL ORDER BY `number` DESC LIMIT 1'; break; |
372f4e195986
Added article blacklist function, switch to binary-safe latin1 character set for database
Ivo Smits <Ivo@UCIS.nl>
parents:
13
diff
changeset
|
162 case 'NEXT': $query = 'SELECT * FROM `groupmessages` WHERE `group` = ? AND `number` > ? AND `message` IS NOT NULL ORDER BY `number` ASC LIMIT 1'; break; |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
163 default: throw new Exception('Internal error'); |
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
164 } |
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
165 $article = $db->evalRowAssoc($query, array($currentarticle['group'], $currentarticle['number'])); |
0 | 166 if ($article === FALSE) { |
167 nntp_writeline(STDOUT, '422 no previous article in this group'); | |
168 } else { | |
169 $articlea = $db->evalRowAssoc('SELECT * FROM `messages` WHERE `id` = ?', $article['message']); | |
170 if ($articlea === FALSE) { | |
171 nntp_writeline(STDOUT, '430 no such article found'); | |
13
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
172 } else { |
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
173 $currentarticle = $article; |
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
174 nntp_writeline(STDOUT, '223 '.$article['number'].' <'.$articlea['messageid'].'> ok'); |
0 | 175 } |
176 } | |
177 break; | |
2
40e545510a57
Added support for POSTing to the server, added readme and todo, added support for upstream synchronization using POST
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
178 case 'POST': |
40e545510a57
Added support for POSTing to the server, added readme and todo, added support for upstream synchronization using POST
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
179 nntp_writeline(STDOUT, '340 Ok, recommended message-ID <'.md5(time().rand()).'@pNews.Core.UCIS.nl>'); |
40e545510a57
Added support for POSTing to the server, added readme and todo, added support for upstream synchronization using POST
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
180 $lines = nntp_readlines(STDIN); |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
181 try { |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
182 $messageid = nntp_article_store($lines); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
183 nntp_writeline(STDOUT, '240 Article received <'.$messageid.'>'); |
3
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
184 } catch (Exception $ex) { |
0dcdb73cbcbf
Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
185 nntp_writeline(STDOUT, '441 '.$ex->getMessage()); |
2
40e545510a57
Added support for POSTing to the server, added readme and todo, added support for upstream synchronization using POST
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
186 } |
40e545510a57
Added support for POSTing to the server, added readme and todo, added support for upstream synchronization using POST
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
187 break; |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
188 case 'IHAVE': |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
189 $messageid = strtok(" \t"); |
12
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
190 if ($messageid === FALSE || strlen($messageid) <= 2 || $messageid[0] != '<' || $messageid[strlen($messageid)-1] != '>') { |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
191 nntp_writeline(STDOUT, '435 Argument error'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
192 break; |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
193 } |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
194 $messageid = substr($messageid, 1, -1); |
13
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
195 if (!nntp_article_wanted($messageid)) { |
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
196 nntp_writeline(STDOUT, '435 Duplicate or filtered'); |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
197 break; |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
198 } |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
199 nntp_writeline(STDOUT, '335 Send article to be transferred'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
200 $lines = nntp_readlines(STDIN); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
201 try { |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
202 $messageid = nntp_article_store($lines); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
203 nntp_writeline(STDOUT, '235 Article received <'.$messageid.'>'); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
204 } catch (Exception $ex) { |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
205 nntp_writeline(STDOUT, '437 '.$ex->getMessage()); |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
206 } |
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
207 break; |
12
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
208 case 'CHECK': |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
209 $messageid = strtok(" \t"); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
210 if ($messageid === FALSE || strlen($messageid) <= 2 || $messageid[0] != '<' || $messageid[strlen($messageid)-1] != '>') { |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
211 nntp_writeline(STDOUT, '435 Argument error'); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
212 break; |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
213 } |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
214 $messageid = substr($messageid, 1, -1); |
13
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
215 if (!nntp_article_wanted($messageid)) { |
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
216 nntp_writeline(STDOUT, '438 <'.$messageid.'> Duplicate or filtered'); |
12
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
217 break; |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
218 } |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
219 nntp_writeline(STDOUT, '238 <'.$messageid.'> Send article to be transferred'); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
220 break; |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
221 case 'TAKETHIS': |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
222 $messageid = strtok(" \t"); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
223 $lines = nntp_readlines(STDIN); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
224 if ($messageid === FALSE || strlen($messageid) <= 2 || $messageid[0] != '<' || $messageid[strlen($messageid)-1] != '>') { |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
225 nntp_writeline(STDOUT, '435 Argument error'); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
226 break; |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
227 } |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
228 $messageid = substr($messageid, 1, -1); |
13
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
229 if (!nntp_article_wanted($messageid)) { |
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
230 nntp_writeline(STDOUT, '439 <'.$messageid.'> Duplicate or filtered'); |
12
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
231 break; |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
232 } |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
233 try { |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
234 $messageid = nntp_article_store($lines); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
235 nntp_writeline(STDOUT, '239 <'.$messageid.'> Article stored'); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
236 } catch (Exception $ex) { |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
237 nntp_writeline(STDOUT, '437 '.$ex->getMessage()); |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
238 } |
7917bd536187
Added hook for new articles, detect send/write failures, fixed handling of multiline headers, add Date header if it doesn't exist, add option to disable peers, fixes for synchronization with INN, added streaming mode support, small fixes
Ivo Smits <Ivo@UCIS.nl>
parents:
10
diff
changeset
|
239 break; |
0 | 240 case 'QUIT': |
7
01dc7eeaf5df
Added some more checks to article data, added some commands, added 'dot stuffing' for block transfers
Ivo Smits <Ivo@UCIS.nl>
parents:
5
diff
changeset
|
241 nntp_writeline(STDOUT, '205 Bye.'); |
0 | 242 return; |
243 default: | |
244 nntp_writeline(STDOUT, '500 Command not understood'); | |
245 break; | |
246 } | |
247 } | |
248 | |
249 function nntp_get_article($article) { | |
250 global $currentgroup, $currentarticle, $db; | |
251 if ($article === FALSE) { | |
252 if ($currentarticle === NULL) { | |
253 nntp_writeline(STDOUT, '420 no current article has been selected'); | |
254 return NULL; | |
255 } | |
256 $messagenumber = $currentarticle['number']; | |
257 $article = $db->evalRowAssoc('SELECT * FROM `messages` WHERE `id` = ?', $currentarticle['message']); | |
258 if ($article === FALSE) { | |
259 nntp_writeline(STDOUT, '430 no such article found'); | |
260 return NULL; | |
261 } | |
262 } elseif (strlen($article) > 2 && $article[0] == '<' && $article[strlen($article)-1] == '>') { | |
263 $messagenumber = 0; | |
264 $article = substr($article, 1, -1); | |
265 $article = $db->evalRowAssoc('SELECT * FROM `messages` WHERE `messageid` = ?', $article); | |
266 if ($article === FALSE) { | |
267 nntp_writeline(STDOUT, '430 no such article found'); | |
268 return NULL; | |
269 } | |
270 } elseif (is_numeric($article)) { | |
271 if ($currentgroup === NULL) { | |
272 nntp_writeline(STDOUT, '412 no newsgroup has been selected'); | |
273 return NULL; | |
274 } | |
14
372f4e195986
Added article blacklist function, switch to binary-safe latin1 character set for database
Ivo Smits <Ivo@UCIS.nl>
parents:
13
diff
changeset
|
275 $article = $db->evalRowAssoc('SELECT * FROM `groupmessages` WHERE `group` = ? AND `number` = ? AND `message` IS NOT NULL', array($currentgroup['id'], $article)); |
0 | 276 if ($article === FALSE) { |
277 nntp_writeline(STDOUT, '423 no such article number in this group'); | |
278 return NULL; | |
279 } | |
280 $currentarticle = $article; | |
281 $messagenumber = $article['number']; | |
282 $article = $db->evalRowAssoc('SELECT * FROM `messages` WHERE `id` = ?', $article['message']); | |
283 if ($article === FALSE) { | |
284 nntp_writeline(STDOUT, '430 no such article found'); | |
285 return NULL; | |
286 } | |
287 } else { | |
288 nntp_writeline(STDOUT, '500 Error in arguments'); | |
13
cccd73f72bf6
Added filtering support and several bugfixes
Ivo Smits <Ivo@UCIS.nl>
parents:
12
diff
changeset
|
289 return NULL; |
0 | 290 } |
291 $article['messagenumber'] = $messagenumber; | |
292 return $article; | |
293 } | |
294 | |
295 function writelog($line) { | |
296 global $logfile; | |
297 fwrite($logfile, $line."\n"); | |
298 } |