annotate fetchnews.php @ 9:ae0c67d72670

Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
author Ivo Smits <Ivo@UCIS.nl>
date Tue, 12 Apr 2011 14:54:26 +0200
parents 005339a1b2ce
children e0807e0b1a67
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
1 #!/usr/bin/php
0
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
2 <?php
8
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
3 /* Copyright 2010 Ivo Smits <Ivo@UCIS.nl>. All rights reserved.
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
4 Redistribution and use in source and binary forms, with or without modification, are
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
5 permitted provided that the following conditions are met:
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
6
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
7 1. Redistributions of source code must retain the above copyright notice, this list of
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
8 conditions and the following disclaimer.
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
9
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
10 2. Redistributions in binary form must reproduce the above copyright notice, this list
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
11 of conditions and the following disclaimer in the documentation and/or other materials
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
12 provided with the distribution.
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
13
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
14 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
15 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
18 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
19 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
20 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
21 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
22 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
23
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
24 The views and conclusions contained in the software and documentation are those of the
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
25 authors and should not be interpreted as representing official policies, either expressed
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
26 or implied, of Ivo Smits.*/
005339a1b2ce Added copyright notice
Ivo Smits <Ivo@UCIS.nl>
parents: 7
diff changeset
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: 1
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
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
30
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
31 foreach ($db->evalAllAssoc('SELECT * FROM `peers`') as $peer) {
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
32 $socket = stream_socket_client($peer['address']);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
33 if ($socket === FALSE) die("Could not connect to peer $peer[address]\n");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
34 $line = nntp_readline($socket);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
35 $code = strtok($line, " \t");
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: 1
diff changeset
36 if ($code == 200) {
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: 1
diff changeset
37 } else if ($code == 201) {
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: 1
diff changeset
38 $peer['post'] = 0;
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: 1
diff changeset
39 } else die("Error code $code from $peer[address]\n");
0
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
40 foreach ($db->evalAllAssoc('SELECT * FROM `peergroups` WHERE `peer` = ?', $peer['id']) as $peergroup) {
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
41 $group = $db->evalRowAssoc('SELECT * FROM `groups` WHERE `id` = ?', $peergroup['group']);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
42 nntp_writeline($socket, 'GROUP '.$group['name']);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
43 $line = nntp_readline($socket);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
44 $code = strtok($line, " \t");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
45 if ($code != 211) die("Error code $code from $peer[address]\n");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
46 strtok(" \t"); //number of articles
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
47 $low = strtok(" \t");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
48 $high = strtok(" \t");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
49 strtok(" \t"); //group name
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
50 if ($low != $peergroup['low'] || $high != $peergroup['high'] || $peergroup['low'] === NULL || $peergroup['high'] === NULL) {
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
51 for ($i = $low; $i <= $high; $i++) {
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
52 if ($i >= $peergroup['low'] && $i <= $peergroup['high'] && $peergroup['low'] !== NULL && $peergroup['high'] !== NULL) continue;
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
53 nntp_writeline($socket, 'STAT '.$i);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
54 $line = nntp_readline($socket);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
55 $code = strtok($line, " \t");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
56 if ($code == 423) {
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
57 print("Gap in article numbering at $i\n");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
58 continue;
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
59 }
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
60 if ($code != 223) die("Error code $code from $peer[address]\n");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
61 strtok(" \t"); //article number
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
62 $messageid = strtok(" \t");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
63 if ($messageid[0] != '<' || $messageid[strlen($messageid)-1] != '>') die("Malformed message ID $messageid\n");
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
64 $messageid = substr($messageid, 1, -1);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
65 $message = $db->evalRowAssoc('SELECT * FROM `messages` WHERE `messageid` = ?', $messageid);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
66 if ($message) {
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
67 $groupmessage = $db->evalRowAssoc('SELECT * FROM `groupmessages` WHERE `group` = ? AND `message` = ?', array($group['id'], $message['id']));
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
68 if (!$groupmessage) {
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
69 $db->insert('INSERT INTO `groupmessages` (`group`, `message`) VALUES (?, ?)', array($group['id'], $message['id']));
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
70 }
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
71 } else {
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
72 nntp_writeline($socket, 'ARTICLE '.$i);
0
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
73 $line = nntp_readline($socket);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
74 $code = strtok($line, " \t");
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
75 if ($code != 220) die("Error code $code from $peer[address]\n");
0
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
76 strtok(" \t"); //article number
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
77 $lines = nntp_readlines($socket);
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
78 try {
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
79 nntp_article_store($lines);
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
80 } 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
81 writelog($ex->getMessage());
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
82 }
0
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
83 }
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
84 }
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
85 $db->update('UPDATE `peergroups` SET `low` = ?, `high` = ? WHERE `peer` = ? AND `group` = ?', array($low, $high, $peergroup['peer'], $peergroup['group']));
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
86 }
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
87 }
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: 1
diff changeset
88 while ($peer['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: 1
diff changeset
89 if ($peer['lastposted'] === NULL) {
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: 1
diff changeset
90 $articles = $db->evalAllAssoc('SELECT * FROM `messages` LIMIT 10');
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: 1
diff changeset
91 } else {
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: 1
diff changeset
92 $articles = $db->evalAllAssoc('SELECT * FROM `messages` WHERE `id` > ? LIMIT 10', $peer['lastposted']);
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: 1
diff changeset
93 }
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: 1
diff changeset
94 if (!count($articles)) break;
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: 1
diff changeset
95 foreach ($articles as $article) {
9
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
96 $dopost = FALSE;
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
97 if ($peer['post'] == 2) {
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
98 nntp_writeline($socket, 'IHAVE <'.$article['messageid'].'>');
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
99 $line = nntp_readline($socket);
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
100 $code = strtok($line, " \t");
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
101 if ($code == 335) $dopost = TRUE;
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
102 elseif ($code != 435) $peer['post'] = 1;
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
103 }
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
104 if ($peer['post'] != 2) {
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
105 nntp_writeline($socket, 'STAT <'.$article['messageid'].'>');
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
106 $line = nntp_readline($socket);
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
107 $code = strtok($line, " \t");
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
108 if ($code == 430) $dopost = TRUE;
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
109 elseif ($code != 223) die("Error code $code from $peer[address]\n");
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
110 if ($dopost) {
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
111 nntp_writeline($socket, 'POST');
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
112 $line = nntp_readline($socket);
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
113 $code = strtok($line, " \t");
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
114 if ($code != 340) die("Error code $code from $peer[address]\n");
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: 1
diff changeset
115 }
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: 1
diff changeset
116 }
9
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
117 if ($dopost) {
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
118 foreach (explode("\r\n", $article['header']) as $line) nntp_writeline_data($socket, $line);
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
119 nntp_writeline($socket, '');
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
120 foreach (explode("\r\n", $article['body']) as $line) nntp_writeline_data($socket, $line);
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
121 nntp_writeline($socket, '.');
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
122 $line = nntp_readline($socket);
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
123 $code = strtok($line, " \t");
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
124 if ($code != 240 && $code != 235) print("Article $article[messageid] was not accepted ($code)\n");
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
125 }
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: 1
diff changeset
126 if ($article['id'] > $peer['lastposted']) $peer['lastposted'] = $article['id'];
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: 1
diff changeset
127 }
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: 1
diff changeset
128 $db->update('UPDATE `peers` SET `lastposted` = ? WHERE `id` = ?', array($peer['lastposted'], $peer['id']));
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: 1
diff changeset
129 }
0
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
130 nntp_writeline($socket, 'QUIT');
9
ae0c67d72670 Bugfix in server POST code, add support for client side IHAVE and fall back to STAT-before-POST
Ivo Smits <Ivo@UCIS.nl>
parents: 8
diff changeset
131 nntp_readline($socket);
0
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
132 fclose($socket);
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
133 }
d7ab68b71c74 Initial commit
Ivo Smits <Ivo@UCIS.nl>
parents:
diff changeset
134
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
135 function writelog($line) {
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 print($line."\n");
1
61fac319ca3e Update Path and Xref header fields while fetching messages, added database schema export
Ivo Smits <Ivo@UCIS.nl>
parents: 0
diff changeset
137 }