-
Notifications
You must be signed in to change notification settings - Fork 117
/
retrieve.php
115 lines (92 loc) · 3.4 KB
/
retrieve.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
error_reporting(E_ALL & ~E_DEPRECATED);
require_once "settings.php";
require_once "db.php";
require_once "SpotParser.php";
require_once "SpotNntp.php";
require_once "SpotRetriever.php";
function cbRetrieveSpots($hdrList, $curMsg) {
global $db, $settings;
$db->beginTransaction();
$signedCount = 0;
foreach($hdrList as $msgid => $msgheader) {
# Reset timelimit
set_time_limit(120);
$spotParser = new SpotParser();
$spot = $spotParser->parseXover($msgheader['Subject'],
$msgheader['From'],
$msgheader['Message-ID'],
$settings['rsa_keys']);
if (($spot != null) && ($spot['Verified'])) {
$db->addSpot($spot);
} # if
if ($spot['Verified']) {
if ($spot['WasSigned']) {
$signedCount++;
} # if
} # if
} # foreach
if (count($hdrList) > 0) {
echo ", verified " . $signedCount . " signatures of " . count($hdrList) . " valid spots (" . count($hdrList) . " msgs)\r\n";
} else {
echo ", no valid spots found in this message range...\r\n";
} # else
$db->setMaxArticleid($settings['nntp_hdr']['host'], $curMsg);
$db->endTransaction();
} # cbRetrieveSpots
function cbRetrieveComments($hdrList, $curMsg) {
global $db, $settings;
$db->beginTransaction();
$signedCount = 0;
foreach($hdrList as $msgid => $msgheader) {
# Reset timelimit
set_time_limit(120);
# strip de reference van de <>'s en sla het edit nummer apart op
$msgidParts = explode('@', substr($msgheader['Message-ID'], 1, strlen($msgheader['Message-ID']) - 2));
$msgidNumber = explode('.', $msgidParts[0]);
if (count($msgidNumber) >= 3) {
$msgid = $msgidNumber[0] . '.' . $msgidNumber[1] . '@' . $msgidParts[1];
} else {
$msgid = $msgidParts[0] . '@' . $msgidParts[1];
$msgidNumber[2] = 0;
} # if
# voeg spot aan db toe
$db->addCommentRef($msgid,
$msgidNumber[2],
$msgheader['References']);
} # foreach
if (count($hdrList) > 0) {
echo ", added " . count($hdrList) . " comments\r\n";
} else {
echo ", no valid comments found in this message range...\r\n";
} # else
$db->setMaxArticleid('comments', $curMsg);
$db->endTransaction();
} # cbRetrieveComments
# in safe mode, max execution time cannot be set, warn the user
if (ini_get('safe_mode') ) {
echo "WARNING: PHP safemode is enabled, maximum execution cannot be reset! Turn off safemode if this causes problems\r\n\r\n";
} # if
$db = new db($settings['db']);
echo "Spots in database: " . $db->getSpotCount() . "\r\n";
## Spots
$retriever = new SpotRetriever($settings['nntp_hdr']);
if (! ($msgdata = $retriever->connect($settings['hdr_group']))) {
echo "\r\n";
echo "Unable to logon or connect to NNTP server, check NNTP settings: \r\n";
die($retriever->getError() . "\r\n\r\n");
} # if
$curMsg = $db->getMaxArticleId($settings['nntp_hdr']['host']);
$retriever->loopTillEnd($curMsg, 'cbRetrieveSpots');
$retriever->quit();
## Spots
echo "Done retrieving spots, retrieving comments...\r\n";
$retriever = new SpotRetriever($settings['nntp_hdr']);
if (! ($msgdata = $retriever->connect($settings['comment_group']))) {
echo "\r\n";
echo "Unable to logon or connect to NNTP server, check NNTP settings: \r\n";
die($retriever->getError() . "\r\n\r\n");
} # if
$curMsg = $db->getMaxArticleId('comments');
$retriever->loopTillEnd($curMsg, 'cbRetrieveComments');
$retriever->quit();