annotate reloadarticle.php @ 3:0dcdb73cbcbf

Increased article body length to 16MB in database scheme, cleaned up the code, added a script to forcefully reload an individual article
author Ivo Smits <Ivo@UCIS.nl>
date Tue, 12 Apr 2011 01:47:09 +0200
parents
children 005339a1b2ce
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:
diff changeset
1 #!/usr/bin/php
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:
diff changeset
2 <?php
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:
diff changeset
3 chdir(__DIR__);
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:
diff changeset
4 require_once './common.php';
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:
diff changeset
5
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:
diff changeset
6 if (count($_SERVER['argv']) < 2) die('Not enough arguments (usage: [server] [messageid])');
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:
diff changeset
7 $messageid = $_SERVER['argv'][2];
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:
diff changeset
8 $db->update('DELETE FROM `messages` WHERE `messageid` = ?', $messageid);
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:
diff changeset
9 $socket = stream_socket_client($_SERVER['argv'][1]);
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:
diff changeset
10 if ($socket === FALSE) die("Could not connect to peer\n");
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:
diff changeset
11 $line = nntp_readline($socket);
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:
diff changeset
12 $code = 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:
diff changeset
13 if ($code == 200) {
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:
diff changeset
14 } else if ($code == 201) {
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:
diff changeset
15 } else die("Error code $code\n");
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:
diff changeset
16 nntp_writeline($socket, 'ARTICLE <'.$messageid.'>');
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:
diff changeset
17 $line = nntp_readline($socket);
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:
diff changeset
18 $code = 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:
diff changeset
19 if ($code != 220) die("Error code $code\n");
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:
diff changeset
20 strtok(" \t"); //article number
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:
diff changeset
21 $lines = nntp_readlines($socket);
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:
diff changeset
22 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:
diff changeset
23
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:
diff changeset
24 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:
diff changeset
25 print($line."\n");
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:
diff changeset
26 }