Skip to content
This repository
Browse code

Overwrite the private constructor with a public one #1554

  • Loading branch information...
commit 752e4db0016e6f86e8a77b4a1de42ae94046d876 1 parent be500da
spotweb authored June 25, 2012
708  lib/SpotPosting.php
... ...
@@ -1,354 +1,354 @@
1  
-<?php
2  
-
3  
-class SpotPosting {
4  
-	private $_db;
5  
-	private $_settings;
6  
-	private $_nntp_post;
7  
-
8  
-	function __construct(SpotDb $db, SpotSettings $settings) {
9  
-		$this->_db = $db;
10  
-		$this->_settings = $settings;
11  
-		
12  
-		$this->_nntp_post = new SpotNntp($settings->get('nntp_post'));
13  
-	} # ctor
14  
-
15  
-	/*
16  
-	 * Post een comment op een spot naar de newsserver, als dit lukt komt er
17  
-	 * een 'true' terug, anders een foutmelding
18  
-	 */
19  
-	public function postComment($user, $comment) {
20  
-		$errorList = array();
21  
-
22  
-		# haal de spot op waar dit een reply op is
23  
-		$spotsOverview = new SpotsOverview($this->_db, $this->_settings);
24  
-		$fullSpot = $spotsOverview->getFullSpot($comment['inreplyto'], $user['userid'], $this->_nntp_post);
25  
-
26  
-		# als de hashcash al niet klopt, doen we verder geen moeite
27  
-		if (substr(sha1('<' . $comment['newmessageid'] . '>'), 0, 4) != '0000') {
28  
-			$errorList[] = _('Hash was not calculated properly');
29  
-		} # if
30  
-
31  
-		# Body mag niet leeg zijn of heel kort
32  
-		$comment['body'] = trim($comment['body']);
33  
-		if (strlen($comment['body']) < 2) {
34  
-			$errorList[] = _('Please enter a comment');
35  
-		} # if
36  
-		if (strlen($comment['body']) > 9000) {
37  
-			$errorList[] = _('Comment is too long');
38  
-		} # if
39  
-		
40  
-		# Rating mag niet uit de range vallen
41  
-		if (($comment['rating'] > 10) || ($comment['rating'] < 0)) {
42  
-			$errorList[] = _('Invalid rating');
43  
-		} # if
44  
-		
45  
-		# controleer dat de messageid waarop we replyen overeenkomt
46  
-		# met het newMessageid om replay-attacks te voorkomen.
47  
-		$replyToPart = substr($comment['inreplyto'], 0, strpos($comment['inreplyto'], '@'));
48  
-
49  
-		if (substr($comment['newmessageid'], 0, strlen($replyToPart)) != $replyToPart) { 
50  
-			$errorList[] = _('Replay attack!?');
51  
-		} # if
52  
-		
53  
-		# controleer dat het random getal niet recentelijk ook al gebruikt
54  
-		# is voor deze messageid (hiermee voorkomen we dat de hashcash niet
55  
-		# steeds herberekend wordt voor het volspammen van 1 spot).
56  
-		if (!$this->_db->isCommentMessageIdUnique($comment['newmessageid'])) {
57  
-			$errorList[] = _('Replay attack!?');
58  
-		} # if
59  
-
60  
-		# Make sure a newmessageid contains a certain length
61  
-		if (strlen($comment['newmessageid']) < 10) {
62  
-			$errorList[] = _('MessageID too short!?');
63  
-		} # if
64  
-
65  
-		# Add the title as a comment property
66  
-		$comment['title'] = 'Re: ' . $fullSpot['title'];
67  
-		
68  
-		# Body komt vanuit het form als UTF-8, maar moet verzonden worden als ISO-8859-1
69  
-		# De database wil echter alleen UTF-8, dus moeten we dat even opsplitsen
70  
-		$dbComment = $comment;
71  
-		$comment['body'] = utf8_decode($comment['body']);
72  
-		
73  
-		# en post daadwerkelijk de comment
74  
-		if (empty($errorList)) {
75  
-			$this->_nntp_post->postComment($user,
76  
-										   $this->_settings->get('privatekey'),  # Server private key
77  
-										   $this->_settings->get('comment_group'),
78  
-										   $comment);
79  
-			$this->_db->addPostedComment($user['userid'], $dbComment);
80  
-		} # if
81  
-		
82  
-		return $errorList;
83  
-	} # postComment
84  
-
85  
-	/*
86  
-	 * Post a spot to the usenet server. 
87  
-	 */
88  
-	public function postSpot($user, $spot, $imageFilename, $nzbFilename) {
89  
-		$errorList = array();
90  
-		$hdr_newsgroup = $this->_settings->get('hdr_group');
91  
-		$bin_newsgroup = $this->_settings->get('nzb_group');
92  
-
93  
-/*
94  
-		$hdr_newsgroup = 'alt.test';
95  
-		$bin_newsgroup = 'alt.test';
96  
-*/
97  
-
98  
-		# If the hashcash doesn't match, we will never post it
99  
-		if (substr(sha1('<' . $spot['newmessageid'] . '>'), 0, 4) != '0000') {
100  
-			$errorList[] = _('Hash was not calculated properly');
101  
-		} # if
102  
-
103  
-		# Read the contents of image so we can check it
104  
-		$imageContents = file_get_contents($imageFilename);
105  
-
106  
-		# the image should be below 1MB
107  
-		if (strlen($imageContents) > 1024*1024) {
108  
-			$errorList[] = _('Uploaded image is too large (maximum 1MB)');
109  
-		} # if
110  
-
111  
-		/*
112  
-		 * Get some image information, if it fails, this is an
113  
-		 * error as well
114  
-		 */
115  
-		$tmpGdImageSize = getimagesize($imageFilename);
116  
-		if ($tmpGdImageSize === false) {
117  
-			$errorList[] = _('Uploaded image was not recognized as an image');
118  
-		} else {
119  
-			$imageInfo = array('width' => $tmpGdImageSize[0],
120  
-					  	       'height' => $tmpGdImageSize[1]);
121  
-		} # if
122  
-
123  
-		# Body cannot be empty, very short or too long
124  
-		$spot['body'] = trim($spot['body']);
125  
-		if (strlen($spot['body']) < 30) {
126  
-			$errorList[] = _('Please enter an description');
127  
-		} # if
128  
-		if (strlen($spot['body']) > 9000) {
129  
-			$errorList[] = _('Entered description is too long');
130  
-		} # if
131  
-
132  
-		# Title cannot be empty or very short
133  
-		$spot['title'] = trim($spot['title']);
134  
-		if (strlen($spot['title']) < 5) {
135  
-			$errorList[] = _('Enter a title');
136  
-		} # if
137  
-		
138  
-		# Subcategory should be valid
139  
-		if (($spot['category'] < 0) || ($spot['category'] > count(SpotCategories::$_head_categories))) {
140  
-			$errorList[] = sprintf(_('Incorrect headcategory (%s)'), $spot['category']);
141  
-		} # if
142  
-		
143  
-		/*
144  
-		 * Load the NZB file as an XML file so we can make sure 
145  
-		 * it's a valid XML and NZB file and we can determine the
146  
-		 * filesize
147  
-		 */
148  
-		$nzbFileContents = file_get_contents($nzbFilename);
149  
-		$nzbXml = simplexml_load_string($nzbFileContents);
150  
-
151  
-		# Do some basic sanity checking for some required NZB elements
152  
-		if (empty($nzbXml->file)) {
153  
-			$errorList[] = _('Incorrect NZB file');
154  
-		} # if
155  
-		
156  
-		# and determine the total filesize
157  
-		$spot['filesize'] = 0;
158  
-		foreach($nzbXml->file as $file) {
159  
-			foreach($file->segments->segment as $seg) {
160  
-				$spot['filesize'] += (int) $seg['bytes'];
161  
-			} # foreach
162  
-		} # foreach
163  
-		
164  
-		/*
165  
-		 * Make sure we didn't use this messageid recently or at all, this
166  
-		 * prevents people from not recalculating the hashcash in order to spam
167  
-		 * the system
168  
-		 */
169  
-		if (!$this->_db->isNewSpotMessageIdUnique($spot['newmessageid'])) {
170  
-			$errorList[] = _('Replay attack!?');
171  
-		} # if
172  
-
173  
-		# Make sure a newmessageid contains a certain length
174  
-		if (strlen($spot['newmessageid']) < 10) {
175  
-			$errorList[] = _('MessageID too short!?');
176  
-		} # if
177  
-
178  
-		# We require the keyid 7 because it is selfsigned
179  
-		$spot['key'] = 7;
180  
-		
181  
-		# Poster's  username
182  
-		$spot['poster'] = $user['username'];
183  
-		
184  
-		# Fix up some overly long spot properties and other minor issues
185  
-		$spot['tag'] = substr(trim($spot['tag'], " |;\r\n\t"), 0, 99);
186  
-		$spot['http'] = substr(trim($spot['website']), 0, 449);
187  
-		
188  
-		/**
189  
-		 * If the post's character do not fit into ISO-8859-1, we HTML
190  
-		 * encode the UTF-8 characters so we can properly post the spots
191  
-		 */
192  
-		if (mb_detect_encoding($spot['title'], 'UTF-8, ISO-8859-1', true) == 'UTF-8') {
193  
-			$spot['title'] = mb_convert_encoding($spot['title'], 'HTML-ENTITIES', 'UTF-8');
194  
-		} # if
195  
-
196  
-		/*
197  
-		 * Loop through all subcategories and check if they are valid in
198  
-		 * our list of subcategories
199  
-		 */
200  
-		$subCatSplitted = array('a' => array(), 'b' => array(), 'c' => array(), 'd' => array(), 'z' => array());
201  
-
202  
-		foreach($spot['subcatlist'] as $subCat) {
203  
-			$subcats = explode('_', $subCat);
204  
-			# If not in our format
205  
-			if (count($subcats) != 3) {
206  
-				$errorList[] = sprintf(_('Incorrect subcategories (%s)'), $subCat);
207  
-			} else {
208  
-				$subCatLetter = substr($subcats[2], 0, 1);
209  
-				
210  
-				$subCatSplitted[$subCatLetter][] = $subCat;
211  
-				
212  
-				if (!isset(SpotCategories::$_categories[$spot['category']][$subCatLetter][substr($subcats[2], 1)])) {
213  
-					$errorList[] = sprintf(_('Incorrect subcategories (%s)'), $subCat . ' !! ' . $subCatLetter . ' !! ' . substr($subcats[2], 1));
214  
-				} # if
215  
-			} # else
216  
-		} # foreach	
217  
-
218  
-		/*
219  
-		 * Make sure all subcategories are in the format we expect, for
220  
-		 * example we strip the 'cat' part and strip the z-subcat
221  
-		 */
222  
-		$subcatCount = count($spot['subcatlist']);
223  
-		for($i = 0; $i < $subcatCount; $i++) {
224  
-			$subcats = explode('_', $spot['subcatlist'][$i]);
225  
-			
226  
-			# If not in our format
227  
-			if (count($subcats) != 3) {
228  
-				$errorList[] = sprintf(_('Incorrect subcateories (%s)'), $spot['subcatlist'][$i]);
229  
-			} else {
230  
-				$spot['subcatlist'][$i] = substr($subcats[2], 0, 1) . str_pad(substr($subcats[2], 1), 2, '0', STR_PAD_LEFT);
231  
-				
232  
-				# Explicitly add the 'z'-category - we derive it from the full categorynames we already have
233  
-				$zcatStr = substr($subcats[1], 0, 1) . str_pad(substr($subcats[1], 1), 2, '0', STR_PAD_LEFT);
234  
-				if ((is_numeric(substr($subcats[1], 1))) && (array_search($zcatStr, $spot['subcatlist']) === false)) {
235  
-					$spot['subcatlist'][] = $zcatStr;
236  
-				} # if
237  
-			} # else			
238  
-		} # for
239  
-
240  
-		# Make sure the spot isn't being posted in many categories
241  
-		if (count($subCatSplitted['a']) > 1) {
242  
-			$errorList[] = _('You can only specify one format for a spot');
243  
-		} # if
244  
-
245  
-		# Make sure the spot has at least a format
246  
-		if (count($subCatSplitted['a']) < 1) {
247  
-			$errorList[] = _('You need to specify a format for a spot');
248  
-		} # if
249  
-		
250  
-		# Make sure the spot isn't being posted for too many categories
251  
-		if (count($spot['subcatlist']) > 10) {
252  
-			$errorList[] = _('Too many categories');
253  
-		} # if
254  
-
255  
-		# Make sure the spot isn't being posted for too many categories
256  
-		if (count($spot['subcatlist']) < 2) {
257  
-			$errorList[] = _('At least one category need to be selected');
258  
-		} # if
259  
-
260  
-		# en post daadwerkelijk de spot
261  
-		if (empty($errorList)) {
262  
-			/*
263  
-			 * Retrieve the image information and post the image to 
264  
-			 * the appropriate newsgroup so we have the messageid list of 
265  
-			 * images
266  
-			 */
267  
-			$imgSegmentList = $this->_nntp_post->postBinaryMessage($user, $bin_newsgroup, $imageContents, '');
268  
-			$imageInfo['segments'] = $imgSegmentList;
269  
-				
270  
-			# Post the NZB file to the appropriate newsgroups
271  
-			$nzbSegmentList = $this->_nntp_post->postBinaryMessage($user, $bin_newsgroup, gzdeflate($nzbFileContents), '');
272  
-			
273  
-			# Convert the current Spotnet info, to an XML structure
274  
-			$spotParser = new SpotParser();
275  
-			$spotXml = $spotParser->convertSpotToXml($spot, $imageInfo, $nzbSegmentList);
276  
-			$spot['spotxml'] = $spotXml;
277  
-			
278  
-			# And actually post to the newsgroups
279  
-			$this->_nntp_post->postFullSpot($user,
280  
-										   $this->_settings->get('privatekey'),  # Server private key
281  
-										   $hdr_newsgroup,
282  
-										   $spot);
283  
-			$this->_db->addPostedSpot($user['userid'], $spot, $spotXml);
284  
-		} # if
285  
-
286  
-		return $errorList;
287  
-	} # postSpot
288  
-	
289  
-	/*
290  
-	 * Post een spam report van een spot naar de newsserver, als dit lukt komt er
291  
-	 * een 'true' terug, anders een foutmelding
292  
-	 */
293  
-	public function reportSpotAsSpam($user, $report) {
294  
-		$errorList = array();
295  
-
296  
-		# Controleer eerst of de user al een report heeft aangemaakt, dan kunnen we gelijk stoppen.
297  
-		if ($this->_db->isReportPlaced($report['inreplyto'], $user['userid'])) {
298  
-			$errorList[] = _('This spot has already been marked as spam');
299  
-		} # if
300  
-		
301  
-		# haal de spot op waar dit een reply op is
302  
-		$spotsOverview = new SpotsOverview($this->_db, $this->_settings);
303  
-		$fullSpot = $spotsOverview->getFullSpot($report['inreplyto'], $user['userid'], $this->_nntp_post);
304  
-
305  
-		# als de hashcash al niet klopt, doen we verder geen moeite
306  
-		if (substr(sha1('<' . $report['newmessageid'] . '>'), 0, 4) != '0000') {
307  
-			$errorList[] = _('Hash was not calculated properly');
308  
-		} # if
309  
-
310  
-		# Body mag niet leeg zijn of heel kort
311  
-		$report['body'] = trim($report['body']);
312  
-		if (strlen($report['body']) < 2) {
313  
-			$errorList[] = _('Please provide a comment');
314  
-		} # if
315  
-		
316  
-		# controleer dat de messageid waarop we replyen overeenkomt
317  
-		# met het newMessageid om replay-attacks te voorkomen.
318  
-		$replyToPart = substr($report['inreplyto'], 0, strpos($report['inreplyto'], '@'));
319  
-
320  
-		if (substr($report['newmessageid'], 0, strlen($replyToPart)) != $replyToPart) { 
321  
-			$errorList[] = _('Replay attack!?');
322  
-		} # if
323  
-		
324  
-		# controleer dat het random getal niet recentelijk ook al gebruikt
325  
-		# is voor deze messageid (hiermee voorkomen we dat de hashcash niet
326  
-		# steeds herberekend wordt voor het volspammen van 1 spot).
327  
-		if (!$this->_db->isReportMessageIdUnique($report['newmessageid'])) {
328  
-			$errorList[] = _('Replay attack!?');
329  
-		} # if
330  
-
331  
-		# Make sure a newmessageid contains a certain length
332  
-		if (strlen($report['newmessageid']) < 10) {
333  
-			$errorList[] = _('MessageID too short!?');
334  
-		} # if
335  
-
336  
-		# Body komt vanuit het form als UTF-8, maar moet verzonden worden als ISO-8859-1
337  
-		# De database wil echter alleen UTF-8, dus moeten we dat even opsplitsen
338  
-		$dbReport = $report;
339  
-		$report['body'] = utf8_decode($report['body']);
340  
-		$report['title'] = 'REPORT <' . $report['inreplyto'] . '> ' . $fullSpot['title'];
341  
-
342  
-		# en post daadwerkelijk de report
343  
-		if (empty($errorList)) {
344  
-			$this->_nntp_post->reportSpotAsSpam($user,
345  
-										   $this->_settings->get('privatekey'),  # Server private key
346  
-										   $this->_settings->get('report_group'),
347  
-										   $report);
348  
-			$this->_db->addPostedReport($user['userid'], $dbReport);
349  
-		} # if
350  
-		
351  
-		return $errorList;
352  
-	} # reportSpotAsSpam
353  
-	
354  
-} # SpotPosting
  1
+<?php
  2
+
  3
+class SpotPosting {
  4
+	private $_db;
  5
+	private $_settings;
  6
+	private $_nntp_post;
  7
+
  8
+	function __construct(SpotDb $db, SpotSettings $settings) {
  9
+		$this->_db = $db;
  10
+		$this->_settings = $settings;
  11
+		
  12
+		$this->_nntp_post = new SpotNntp($settings->get('nntp_post'));
  13
+	} # ctor
  14
+
  15
+	/*
  16
+	 * Post een comment op een spot naar de newsserver, als dit lukt komt er
  17
+	 * een 'true' terug, anders een foutmelding
  18
+	 */
  19
+	public function postComment($user, $comment) {
  20
+		$errorList = array();
  21
+
  22
+		# haal de spot op waar dit een reply op is
  23
+		$spotsOverview = new SpotsOverview($this->_db, $this->_settings);
  24
+		$fullSpot = $spotsOverview->getFullSpot($comment['inreplyto'], $user['userid'], $this->_nntp_post);
  25
+
  26
+		# als de hashcash al niet klopt, doen we verder geen moeite
  27
+		if (substr(sha1('<' . $comment['newmessageid'] . '>'), 0, 4) != '0000') {
  28
+			$errorList[] = _('Hash was not calculated properly');
  29
+		} # if
  30
+
  31
+		# Body mag niet leeg zijn of heel kort
  32
+		$comment['body'] = trim($comment['body']);
  33
+		if (strlen($comment['body']) < 2) {
  34
+			$errorList[] = _('Please enter a comment');
  35
+		} # if
  36
+		if (strlen($comment['body']) > 9000) {
  37
+			$errorList[] = _('Comment is too long');
  38
+		} # if
  39
+		
  40
+		# Rating mag niet uit de range vallen
  41
+		if (($comment['rating'] > 10) || ($comment['rating'] < 0)) {
  42
+			$errorList[] = _('Invalid rating');
  43
+		} # if
  44
+		
  45
+		# controleer dat de messageid waarop we replyen overeenkomt
  46
+		# met het newMessageid om replay-attacks te voorkomen.
  47
+		$replyToPart = substr($comment['inreplyto'], 0, strpos($comment['inreplyto'], '@'));
  48
+
  49
+		if (substr($comment['newmessageid'], 0, strlen($replyToPart)) != $replyToPart) { 
  50
+			$errorList[] = _('Replay attack!?');
  51
+		} # if
  52
+		
  53
+		# controleer dat het random getal niet recentelijk ook al gebruikt
  54
+		# is voor deze messageid (hiermee voorkomen we dat de hashcash niet
  55
+		# steeds herberekend wordt voor het volspammen van 1 spot).
  56
+		if (!$this->_db->isCommentMessageIdUnique($comment['newmessageid'])) {
  57
+			$errorList[] = _('Replay attack!?');
  58
+		} # if
  59
+
  60
+		# Make sure a newmessageid contains a certain length
  61
+		if (strlen($comment['newmessageid']) < 10) {
  62
+			$errorList[] = _('MessageID too short!?');
  63
+		} # if
  64
+
  65
+		# Add the title as a comment property
  66
+		$comment['title'] = 'Re: ' . $fullSpot['title'];
  67
+		
  68
+		# Body komt vanuit het form als UTF-8, maar moet verzonden worden als ISO-8859-1
  69
+		# De database wil echter alleen UTF-8, dus moeten we dat even opsplitsen
  70
+		$dbComment = $comment;
  71
+		$comment['body'] = utf8_decode($comment['body']);
  72
+		
  73
+		# en post daadwerkelijk de comment
  74
+		if (empty($errorList)) {
  75
+			$this->_nntp_post->postComment($user,
  76
+										   $this->_settings->get('privatekey'),  # Server private key
  77
+										   $this->_settings->get('comment_group'),
  78
+										   $comment);
  79
+			$this->_db->addPostedComment($user['userid'], $dbComment);
  80
+		} # if
  81
+		
  82
+		return $errorList;
  83
+	} # postComment
  84
+
  85
+	/*
  86
+	 * Post a spot to the usenet server. 
  87
+	 */
  88
+	public function postSpot($user, $spot, $imageFilename, $nzbFilename) {
  89
+		$errorList = array();
  90
+		$hdr_newsgroup = $this->_settings->get('hdr_group');
  91
+		$bin_newsgroup = $this->_settings->get('nzb_group');
  92
+
  93
+/*
  94
+		$hdr_newsgroup = 'alt.test';
  95
+		$bin_newsgroup = 'alt.test';
  96
+*/
  97
+
  98
+		# If the hashcash doesn't match, we will never post it
  99
+		if (substr(sha1('<' . $spot['newmessageid'] . '>'), 0, 4) != '0000') {
  100
+			$errorList[] = _('Hash was not calculated properly');
  101
+		} # if
  102
+
  103
+		# Read the contents of image so we can check it
  104
+		$imageContents = file_get_contents($imageFilename);
  105
+
  106
+		# the image should be below 1MB
  107
+		if (strlen($imageContents) > 1024*1024) {
  108
+			$errorList[] = _('Uploaded image is too large (maximum 1MB)');
  109
+		} # if
  110
+
  111
+		/*
  112
+		 * Get some image information, if it fails, this is an
  113
+		 * error as well
  114
+		 */
  115
+		$tmpGdImageSize = getimagesize($imageFilename);
  116
+		if ($tmpGdImageSize === false) {
  117
+			$errorList[] = _('Uploaded image was not recognized as an image');
  118
+		} else {
  119
+			$imageInfo = array('width' => $tmpGdImageSize[0],
  120
+					  	       'height' => $tmpGdImageSize[1]);
  121
+		} # if
  122
+
  123
+		# Body cannot be empty, very short or too long
  124
+		$spot['body'] = trim($spot['body']);
  125
+		if (strlen($spot['body']) < 30) {
  126
+			$errorList[] = _('Please enter an description');
  127
+		} # if
  128
+		if (strlen($spot['body']) > 9000) {
  129
+			$errorList[] = _('Entered description is too long');
  130
+		} # if
  131
+
  132
+		# Title cannot be empty or very short
  133
+		$spot['title'] = trim($spot['title']);
  134
+		if (strlen($spot['title']) < 5) {
  135
+			$errorList[] = _('Enter a title');
  136
+		} # if
  137
+		
  138
+		# Subcategory should be valid
  139
+		if (($spot['category'] < 0) || ($spot['category'] > count(SpotCategories::$_head_categories))) {
  140
+			$errorList[] = sprintf(_('Incorrect headcategory (%s)'), $spot['category']);
  141
+		} # if
  142
+		
  143
+		/*
  144
+		 * Load the NZB file as an XML file so we can make sure 
  145
+		 * it's a valid XML and NZB file and we can determine the
  146
+		 * filesize
  147
+		 */
  148
+		$nzbFileContents = file_get_contents($nzbFilename);
  149
+		$nzbXml = simplexml_load_string($nzbFileContents);
  150
+
  151
+		# Do some basic sanity checking for some required NZB elements
  152
+		if (empty($nzbXml->file)) {
  153
+			$errorList[] = _('Incorrect NZB file');
  154
+		} # if
  155
+		
  156
+		# and determine the total filesize
  157
+		$spot['filesize'] = 0;
  158
+		foreach($nzbXml->file as $file) {
  159
+			foreach($file->segments->segment as $seg) {
  160
+				$spot['filesize'] += (int) $seg['bytes'];
  161
+			} # foreach
  162
+		} # foreach
  163
+		
  164
+		/*
  165
+		 * Make sure we didn't use this messageid recently or at all, this
  166
+		 * prevents people from not recalculating the hashcash in order to spam
  167
+		 * the system
  168
+		 */
  169
+		if (!$this->_db->isNewSpotMessageIdUnique($spot['newmessageid'])) {
  170
+			$errorList[] = _('Replay attack!?');
  171
+		} # if
  172
+
  173
+		# Make sure a newmessageid contains a certain length
  174
+		if (strlen($spot['newmessageid']) < 10) {
  175
+			$errorList[] = _('MessageID too short!?');
  176
+		} # if
  177
+
  178
+		# We require the keyid 7 because it is selfsigned
  179
+		$spot['key'] = 7;
  180
+		
  181
+		# Poster's  username
  182
+		$spot['poster'] = $user['username'];
  183
+		
  184
+		# Fix up some overly long spot properties and other minor issues
  185
+		$spot['tag'] = substr(trim($spot['tag'], " |;\r\n\t"), 0, 99);
  186
+		$spot['http'] = substr(trim($spot['website']), 0, 449);
  187
+		
  188
+		/**
  189
+		 * If the post's character do not fit into ISO-8859-1, we HTML
  190
+		 * encode the UTF-8 characters so we can properly post the spots
  191
+		 */
  192
+		if (mb_detect_encoding($spot['title'], 'UTF-8, ISO-8859-1', true) == 'UTF-8') {
  193
+			$spot['title'] = mb_convert_encoding($spot['title'], 'HTML-ENTITIES', 'UTF-8');
  194
+		} # if
  195
+
  196
+		/*
  197
+		 * Loop through all subcategories and check if they are valid in
  198
+		 * our list of subcategories
  199
+		 */
  200
+		$subCatSplitted = array('a' => array(), 'b' => array(), 'c' => array(), 'd' => array(), 'z' => array());
  201
+
  202
+		foreach($spot['subcatlist'] as $subCat) {
  203
+			$subcats = explode('_', $subCat);
  204
+			# If not in our format
  205
+			if (count($subcats) != 3) {
  206
+				$errorList[] = sprintf(_('Incorrect subcategories (%s)'), $subCat);
  207
+			} else {
  208
+				$subCatLetter = substr($subcats[2], 0, 1);
  209
+				
  210
+				$subCatSplitted[$subCatLetter][] = $subCat;
  211
+				
  212
+				if (!isset(SpotCategories::$_categories[$spot['category']][$subCatLetter][substr($subcats[2], 1)])) {
  213
+					$errorList[] = sprintf(_('Incorrect subcategories (%s)'), $subCat . ' !! ' . $subCatLetter . ' !! ' . substr($subcats[2], 1));
  214
+				} # if
  215
+			} # else
  216
+		} # foreach	
  217
+
  218
+		/*
  219
+		 * Make sure all subcategories are in the format we expect, for
  220
+		 * example we strip the 'cat' part and strip the z-subcat
  221
+		 */
  222
+		$subcatCount = count($spot['subcatlist']);
  223
+		for($i = 0; $i < $subcatCount; $i++) {
  224
+			$subcats = explode('_', $spot['subcatlist'][$i]);
  225
+			
  226
+			# If not in our format
  227
+			if (count($subcats) != 3) {
  228
+				$errorList[] = sprintf(_('Incorrect subcateories (%s)'), $spot['subcatlist'][$i]);
  229
+			} else {
  230
+				$spot['subcatlist'][$i] = substr($subcats[2], 0, 1) . str_pad(substr($subcats[2], 1), 2, '0', STR_PAD_LEFT);
  231
+				
  232
+				# Explicitly add the 'z'-category - we derive it from the full categorynames we already have
  233
+				$zcatStr = substr($subcats[1], 0, 1) . str_pad(substr($subcats[1], 1), 2, '0', STR_PAD_LEFT);
  234
+				if ((is_numeric(substr($subcats[1], 1))) && (array_search($zcatStr, $spot['subcatlist']) === false)) {
  235
+					$spot['subcatlist'][] = $zcatStr;
  236
+				} # if
  237
+			} # else			
  238
+		} # for
  239
+
  240
+		# Make sure the spot isn't being posted in many categories
  241
+		if (count($subCatSplitted['a']) > 1) {
  242
+			$errorList[] = _('You can only specify one format for a spot');
  243
+		} # if
  244
+
  245
+		# Make sure the spot has at least a format
  246
+		if (count($subCatSplitted['a']) < 1) {
  247
+			$errorList[] = _('You need to specify a format for a spot');
  248
+		} # if
  249
+		
  250
+		# Make sure the spot isn't being posted for too many categories
  251
+		if (count($spot['subcatlist']) > 10) {
  252
+			$errorList[] = _('Too many categories');
  253
+		} # if
  254
+
  255
+		# Make sure the spot isn't being posted for too many categories
  256
+		if (count($spot['subcatlist']) < 2) {
  257
+			$errorList[] = _('At least one category need to be selected');
  258
+		} # if
  259
+
  260
+		# en post daadwerkelijk de spot
  261
+		if (empty($errorList)) {
  262
+			/*
  263
+			 * Retrieve the image information and post the image to 
  264
+			 * the appropriate newsgroup so we have the messageid list of 
  265
+			 * images
  266
+			 */
  267
+			$imgSegmentList = $this->_nntp_post->postBinaryMessage($user, $bin_newsgroup, $imageContents, '');
  268
+			$imageInfo['segments'] = $imgSegmentList;
  269
+				
  270
+			# Post the NZB file to the appropriate newsgroups
  271
+			$nzbSegmentList = $this->_nntp_post->postBinaryMessage($user, $bin_newsgroup, gzdeflate($nzbFileContents), '');
  272
+			
  273
+			# Convert the current Spotnet info, to an XML structure
  274
+			$spotParser = new SpotParser();
  275
+			$spotXml = $spotParser->convertSpotToXml($spot, $imageInfo, $nzbSegmentList);
  276
+			$spot['spotxml'] = $spotXml;
  277
+			
  278
+			# And actually post to the newsgroups
  279
+			$this->_nntp_post->postFullSpot($user,
  280
+										   $this->_settings->get('privatekey'),  # Server private key
  281
+										   $hdr_newsgroup,
  282
+										   $spot);
  283
+			$this->_db->addPostedSpot($user['userid'], $spot, $spotXml);
  284
+		} # if
  285
+
  286
+		return $errorList;
  287
+	} # postSpot
  288
+	
  289
+	/*
  290
+	 * Post een spam report van een spot naar de newsserver, als dit lukt komt er
  291
+	 * een 'true' terug, anders een foutmelding
  292
+	 */
  293
+	public function reportSpotAsSpam($user, $report) {
  294
+		$errorList = array();
  295
+
  296
+		# Controleer eerst of de user al een report heeft aangemaakt, dan kunnen we gelijk stoppen.
  297
+		if ($this->_db->isReportPlaced($report['inreplyto'], $user['userid'])) {
  298
+			$errorList[] = _('This spot has already been marked as spam');
  299
+		} # if
  300
+		
  301
+		# haal de spot op waar dit een reply op is
  302
+		$spotsOverview = new SpotsOverview($this->_db, $this->_settings);
  303
+		$fullSpot = $spotsOverview->getFullSpot($report['inreplyto'], $user['userid'], $this->_nntp_post);
  304
+
  305
+		# als de hashcash al niet klopt, doen we verder geen moeite
  306
+		if (substr(sha1('<' . $report['newmessageid'] . '>'), 0, 4) != '0000') {
  307
+			$errorList[] = _('Hash was not calculated properly');
  308
+		} # if
  309
+
  310
+		# Body mag niet leeg zijn of heel kort
  311
+		$report['body'] = trim($report['body']);
  312
+		if (strlen($report['body']) < 2) {
  313
+			$errorList[] = _('Please provide a comment');
  314
+		} # if
  315
+		
  316
+		# controleer dat de messageid waarop we replyen overeenkomt
  317
+		# met het newMessageid om replay-attacks te voorkomen.
  318
+		$replyToPart = substr($report['inreplyto'], 0, strpos($report['inreplyto'], '@'));
  319
+
  320
+		if (substr($report['newmessageid'], 0, strlen($replyToPart)) != $replyToPart) { 
  321
+			$errorList[] = _('Replay attack!?');
  322
+		} # if
  323
+		
  324
+		# controleer dat het random getal niet recentelijk ook al gebruikt
  325
+		# is voor deze messageid (hiermee voorkomen we dat de hashcash niet
  326
+		# steeds herberekend wordt voor het volspammen van 1 spot).
  327
+		if (!$this->_db->isReportMessageIdUnique($report['newmessageid'])) {
  328
+			$errorList[] = _('Replay attack!?');
  329
+		} # if
  330
+
  331
+		# Make sure a newmessageid contains a certain length
  332
+		if (strlen($report['newmessageid']) < 10) {
  333
+			$errorList[] = _('MessageID too short!?');
  334
+		} # if
  335
+
  336
+		# Body komt vanuit het form als UTF-8, maar moet verzonden worden als ISO-8859-1
  337
+		# De database wil echter alleen UTF-8, dus moeten we dat even opsplitsen
  338
+		$dbReport = $report;
  339
+		$report['body'] = utf8_decode($report['body']);
  340
+		$report['title'] = 'REPORT <' . $report['inreplyto'] . '> ' . $fullSpot['title'];
  341
+
  342
+		# en post daadwerkelijk de report
  343
+		if (empty($errorList)) {
  344
+			$this->_nntp_post->reportSpotAsSpam($user,
  345
+										   $this->_settings->get('privatekey'),  # Server private key
  346
+										   $this->_settings->get('report_group'),
  347
+										   $report);
  348
+			$this->_db->addPostedReport($user['userid'], $dbReport);
  349
+		} # if
  350
+		
  351
+		return $errorList;
  352
+	} # reportSpotAsSpam
  353
+	
  354
+} # SpotPosting
482  lib/retriever/SpotRetriever_Abs.php
... ...
@@ -1,241 +1,241 @@
1  
-<?php
2  
-abstract class SpotRetriever_Abs {
3  
-		protected $_server;
4  
-		protected $_spotnntp;
5  
-		protected $_db;
6  
-		protected $_settings;
7  
-		protected $_debug;
8  
-		protected $_retro;
9  
-		
10  
-		private $_msgdata;
11  
-
12  
-		/*
13  
-		 * Returns the status in either xml or text format 
14  
-		 */
15  
-		abstract function displayStatus($cat, $txt);
16  
-		
17  
-		/*
18  
-		 * Actual processing of the headers
19  
-		 */
20  
-		abstract function process($hdrList, $curMsg, $increment, $timer);
21  
-		
22  
-		/*
23  
-		 * Remove any extraneous reports from the database because we assume
24  
-		 * the highest messgeid in the database is the latest on the server.
25  
-		 */
26  
-		abstract function updateLastRetrieved($highestMessageId);
27  
-		
28  
-		/*
29  
-		 * returns the name of the group we are expected to retrieve messages from
30  
-		 */
31  
-		abstract function getGroupName();
32  
-		
33  
-		/*
34  
-		 * Highest articleid for the implementation in the database
35  
-		 */
36  
-		abstract function getMaxArticleId();
37  
-		
38  
-		/*
39  
-		 * Returns the highest messageid in the database
40  
-		 */
41  
-		abstract function getMaxMessageId();
42  
-		
43  
-		/*
44  
-		 * default ctor 
45  
-		 */
46  
-		function __construct($server, SpotDb $db, SpotSettings $settings, $debug, $retro) {
47  
-			$this->_server = $server;
48  
-			$this->_db = $db;
49  
-			$this->_settings = $settings;
50  
-			$this->_debug = $debug;
51  
-			$this->_retro = $retro;
52  
-		} # ctor
53  
-
54  
-		function debug($s) {
55  
-			if ($this->_debug) {
56  
-				echo 'DEBUG: ' . microtime(true) . ':' . $s . PHP_EOL;
57  
-			} # if
58  
-		} # debug
59  
-		
60  
-		function connect($group) {
61  
-			# if an retriever instance is already running, stop this one
62  
-			if ($this->_db->isRetrieverRunning($this->_server['host'])) {
63  
-				throw new RetrieverRunningException();
64  
-			} # if
65  
-			
66  
-			/*
67  
-			 * and notify the system we are running
68  
-			 */
69  
-			$this->_db->setRetrieverRunning($this->_server['host'], true);
70  
-
71  
-			# and fireup the nntp connection
72  
-			$this->displayStatus("lastretrieve", $this->_db->getLastUpdate($this->_server['host']));
73  
-			$this->displayStatus("start", $this->_server['host']);
74  
-			$this->_spotnntp = new SpotNntp($this->_server);
75  
-			$this->_msgdata = $this->_spotnntp->selectGroup($group);
76  
-			
77  
-			return $this->_msgdata;
78  
-		} # connect
79  
-		
80  
-
81  
-		/*
82  
-		 * Given a list of messageids, check if we can find the corresponding
83  
-		 * articlenumber on the NNTP server. 
84  
-		 */
85  
-		function searchMessageid($messageIdList) {
86  
-			$this->debug('searchMessageId=' . serialize($messageIdList));
87  
-			
88  
-			if (empty($messageIdList) || $this->_retro) {
89  
-				return 0;
90  
-			} # if
91  
-				
92  
-			$this->displayStatus('searchmsgid', '');
93  
-			
94  
-			$found = false;
95  
-			$decrement = 5000;
96  
-			$curMsg = $this->_msgdata['last'];
97  
-
98  
-			# start searching 
99  
-			while (($curMsg >= $this->_msgdata['first']) && (!$found)) {
100  
-				# Reset timelimit
101  
-				set_time_limit(120);			
102  
-				
103  
-				$curMsg = max(($curMsg - $decrement), $this->_msgdata['first'] - 1);
104  
-
105  
-				# get the list of headers (XHDR)
106  
-				$hdrList = $this->_spotnntp->getMessageIdList($curMsg - 1, ($curMsg + $decrement));
107  
-				$this->debug('getMessageIdList returned=' . serialize($hdrList));
108  
-				
109  
-				/*
110  
-				 * Reverse the list with messageids because we assume we are at a recent
111  
-				 * run and the last retrieved messageid should be on the top of the list
112  
-				 * somewhere
113  
-				 */
114  
-				$hdrList = array_reverse($hdrList, true);
115  
-
116  
-				echo 'Searching from ' . ($curMsg -1) . ' to ' . ($curMsg + $decrement) . PHP_EOL;
117  
-				
118  
- 				foreach($hdrList as $msgNum => $msgId) {
119  
-					if (isset($messageIdList[$msgId])) {
120  
-						$curMsg = $msgNum;
121  
-						$found = true;
122  
-						break;
123  
-					} # if
124  
-				} # for
125  
-			} # while
126  
-
127  
-			$this->debug('getMessageIdList loop finished, found = ' . $found);
128  
-			$this->debug('getMessageIdList loop finished, curMsg = ' . $curMsg);
129  
-			
130  
-			return $curMsg;
131  
-		} # searchMessageId
132  
-		
133  
-		/*
134  
-		 * Process all headers in $increment pieces and call the corresponding
135  
-		 * actual implementation
136  
-		 */
137  
-		function loopTillEnd($curMsg, $increment = 1000) {
138  
-			$processed = 0;
139  
-			$headersProcessed = 0;
140  
-			$highestMessageId = '';
141  
-			
142  
-			# make sure we handle articlenumber wrap arounds
143  
-			if ($curMsg < $this->_msgdata['first']) {
144  
-				$curMsg = $this->_msgdata['first'];
145  
-			} # if
146  
-
147  
-			$this->displayStatus("groupmessagecount", ($this->_msgdata['last'] - $this->_msgdata['first']));
148  
-			$this->displayStatus("firstmsg", $this->_msgdata['first']);
149  
-			$this->displayStatus("lastmsg", $this->_msgdata['last']);
150  
-			$this->displayStatus("curmsg", $curMsg);
151  
-			$this->displayStatus("", "");
152  
-
153  
-			while ($curMsg < $this->_msgdata['last']) {
154  
-				$timer = microtime(true);
155  
-				
156  
-				# get the list of headers (XOVER)
157  
-				$hdrList = $this->_spotnntp->getOverview($curMsg, ($curMsg + $increment));
158  
-
159  
-				$saveCurMsg = $curMsg;
160  
-				# If no spots were found, just manually increase the
161  
-				# messagenumber with the increment to make sure we advance
162  
-				if ((count($hdrList) < 1) || ($hdrList[count($hdrList)-1]['Number'] < $curMsg)) {
163  
-					$curMsg += $increment;
164  
-				} else {
165  
-					$curMsg = ($hdrList[count($hdrList)-1]['Number'] + 1);
166  
-				} # else
167  
-				
168  
-				# run the processing method
169  
-				$processOutput = $this->process($hdrList, $saveCurMsg, $curMsg, $timer);
170  
-				$processed += $processOutput['count'];
171  
-				$headersProcessed += $processOutput['headercount'];
172  
-				$highestMessageId = $processOutput['lastmsgid'];
173  
-
174  
-				# reset the start time to prevent a another retriever from starting
175  
-				# during the intial retrieve which can take many hours 
176  
-				$this->_db->setRetrieverRunning($this->_server['host'], true);
177  
-			} # while
178  
-			
179  
-			# we are done updating, make sure that if the newsserver deleted 
180  
-			# earlier retrieved messages, we remove them from our database
181  
-			if ($highestMessageId != '') {
182  
-				$this->debug('loopTillEnd() finished, highestMessageId = ' . $highestMessageId);
183  
-				$this->updateLastRetrieved($highestMessageId);
184  
-			} # if
185  
-	
186  
-			$this->displayStatus("totalprocessed", $processed);
187  
-			return $headersProcessed;
188  
-		} # loopTillEnd()
189  
-
190  
-		function quit() {
191  
-			# notify the system we are not running anymore
192  
-			$this->_db->setRetrieverRunning($this->_server['host'], false);
193  
-			
194  
-			# and disconnect
195  
-			$this->_spotnntp->quit();
196  
-			$this->displayStatus("done", "");
197  
-		} # quit()
198  
-		
199  
-		function perform() {
200  
-			/*
201  
-			 * try to connect to the usenet server and select the group
202  
-			 */
203  
-			$msgdata = $this->connect($this->getGroupName());
204  
-			
205  
-			/*
206  
-			 * Ask the implementation class for the highest articleid
207  
-			 * found on the system
208  
-			 */
209  
-			$curMsg = $this->getMaxArticleId();
210  
-
211  
-			/*
212  
-			 * If this usenet server is new for us, we just assume
213  
-			 * we have to start from zero. Else we do a lookup from
214  
-			 * the messageid to find the correct articlenumber.
215  
-			 *
216  
-			 * We cannot just use the articlenumber because the NNTP
217  
-			 * spec allows a server to renumber of course.
218  
-			 */
219  
-			if (($curMsg != 0) && (!$this->_retro)) {
220  
-				$curMsg = $this->searchMessageId($this->getMaxMessageId());
221  
-				
222  
-				if ($this->_server['buggy']) {
223  
-					$curMsg = max(1, $curMsg - 15000);
224  
-				} # if
225  
-			} # if
226  
-
227  
-			/*
228  
-			 * and actually start looping till we retrieved all headers or articles
229  
-			 */
230  
-			$newProcessedCount = $this->loopTillEnd($curMsg, $this->_settings->get('retrieve_increment'));
231  
-			
232  
-			/* 
233  
-			 * and cleanup
234  
-			 */
235  
-			$this->quit();
236  
-			$this->_db->setLastUpdate($this->_server['host']);
237  
-			
238  
-			return $newProcessedCount;
239  
-		} # perform
240  
-		
241  
-} # class SpotRetriever
  1
+<?php
  2
+abstract class SpotRetriever_Abs {
  3
+		protected $_server;
  4
+		protected $_spotnntp;
  5
+		protected $_db;
  6
+		protected $_settings;
  7
+		protected $_debug;
  8
+		protected $_retro;
  9
+		
  10
+		private $_msgdata;
  11
+
  12
+		/*
  13
+		 * Returns the status in either xml or text format 
  14
+		 */
  15
+		abstract function displayStatus($cat, $txt);
  16
+		
  17
+		/*
  18
+		 * Actual processing of the headers
  19
+		 */
  20
+		abstract function process($hdrList, $curMsg, $increment, $timer);
  21
+		
  22
+		/*
  23
+		 * Remove any extraneous reports from the database because we assume
  24
+		 * the highest messgeid in the database is the latest on the server.
  25
+		 */
  26
+		abstract function updateLastRetrieved($highestMessageId);
  27
+		
  28
+		/*
  29
+		 * returns the name of the group we are expected to retrieve messages from
  30
+		 */
  31
+		abstract function getGroupName();
  32
+		
  33
+		/*
  34
+		 * Highest articleid for the implementation in the database
  35
+		 */
  36
+		abstract function getMaxArticleId();
  37
+		
  38
+		/*
  39
+		 * Returns the highest messageid in the database
  40
+		 */
  41
+		abstract function getMaxMessageId();
  42
+		
  43
+		/*
  44
+		 * default ctor 
  45
+		 */
  46
+		function __construct($server, SpotDb $db, SpotSettings $settings, $debug, $retro) {
  47
+			$this->_server = $server;
  48
+			$this->_db = $db;
  49
+			$this->_settings = $settings;
  50
+			$this->_debug = $debug;
  51
+			$this->_retro = $retro;
  52
+		} # ctor
  53
+
  54
+		function debug($s) {
  55
+			if ($this->_debug) {
  56
+				echo 'DEBUG: ' . microtime(true) . ':' . $s . PHP_EOL;
  57
+			} # if
  58
+		} # debug
  59
+		
  60
+		function connect($group) {
  61
+			# if an retriever instance is already running, stop this one
  62
+			if ($this->_db->isRetrieverRunning($this->_server['host'])) {
  63
+				throw new RetrieverRunningException();
  64
+			} # if
  65
+			
  66
+			/*
  67
+			 * and notify the system we are running
  68
+			 */
  69
+			$this->_db->setRetrieverRunning($this->_server['host'], true);
  70
+
  71
+			# and fireup the nntp connection
  72
+			$this->displayStatus("lastretrieve", $this->_db->getLastUpdate($this->_server['host']));
  73
+			$this->displayStatus("start", $this->_server['host']);
  74
+			$this->_spotnntp = new SpotNntp($this->_server);
  75
+			$this->_msgdata = $this->_spotnntp->selectGroup($group);
  76
+			
  77
+			return $this->_msgdata;
  78
+		} # connect
  79
+		
  80
+
  81
+		/*
  82
+		 * Given a list of messageids, check if we can find the corresponding
  83
+		 * articlenumber on the NNTP server. 
  84
+		 */
  85
+		function searchMessageid($messageIdList) {
  86
+			$this->debug('searchMessageId=' . serialize($messageIdList));
  87
+			
  88
+			if (empty($messageIdList) || $this->_retro) {
  89
+				return 0;
  90
+			} # if
  91
+				
  92
+			$this->displayStatus('searchmsgid', '');
  93
+			
  94
+			$found = false;
  95
+			$decrement = 5000;
  96
+			$curMsg = $this->_msgdata['last'];
  97
+
  98
+			# start searching 
  99
+			while (($curMsg >= $this->_msgdata['first']) && (!$found)) {
  100
+				# Reset timelimit
  101
+				set_time_limit(120);			
  102
+				
  103
+				$curMsg = max(($curMsg - $decrement), $this->_msgdata['first'] - 1);
  104
+
  105
+				# get the list of headers (XHDR)
  106
+				$hdrList = $this->_spotnntp->getMessageIdList($curMsg - 1, ($curMsg + $decrement));
  107
+				$this->debug('getMessageIdList returned=' . serialize($hdrList));
  108
+				
  109
+				/*
  110
+				 * Reverse the list with messageids because we assume we are at a recent
  111
+				 * run and the last retrieved messageid should be on the top of the list
  112
+				 * somewhere
  113
+				 */
  114
+				$hdrList = array_reverse($hdrList, true);
  115
+
  116
+				echo 'Searching from ' . ($curMsg -1) . ' to ' . ($curMsg + $decrement) . PHP_EOL;
  117
+				
  118
+ 				foreach($hdrList as $msgNum => $msgId) {
  119
+					if (isset($messageIdList[$msgId])) {
  120
+						$curMsg = $msgNum;
  121
+						$found = true;
  122
+						break;
  123
+					} # if
  124
+				} # for
  125
+			} # while
  126
+
  127
+			$this->debug('getMessageIdList loop finished, found = ' . $found);
  128
+			$this->debug('getMessageIdList loop finished, curMsg = ' . $curMsg);
  129
+			
  130
+			return $curMsg;
  131
+		} # searchMessageId
  132
+		
  133
+		/*
  134
+		 * Process all headers in $increment pieces and call the corresponding
  135
+		 * actual implementation
  136
+		 */
  137
+		function loopTillEnd($curMsg, $increment = 1000) {
  138
+			$processed = 0;
  139
+			$headersProcessed = 0;
  140
+			$highestMessageId = '';
  141
+			
  142
+			# make sure we handle articlenumber wrap arounds
  143
+			if ($curMsg < $this->_msgdata['first']) {
  144
+				$curMsg = $this->_msgdata['first'];
  145
+			} # if
  146
+
  147
+			$this->displayStatus("groupmessagecount", ($this->_msgdata['last'] - $this->_msgdata['first']));
  148
+			$this->displayStatus("firstmsg", $this->_msgdata['first']);
  149
+			$this->displayStatus("lastmsg", $this->_msgdata['last']);
  150
+			$this->displayStatus("curmsg", $curMsg);
  151
+			$this->displayStatus("", "");
  152
+
  153
+			while ($curMsg < $this->_msgdata['last']) {
  154
+				$timer = microtime(true);
  155
+				
  156
+				# get the list of headers (XOVER)
  157
+				$hdrList = $this->_spotnntp->getOverview($curMsg, ($curMsg + $increment));
  158
+
  159
+				$saveCurMsg = $curMsg;
  160
+				# If no spots were found, just manually increase the
  161
+				# messagenumber with the increment to make sure we advance
  162
+				if ((count($hdrList) < 1) || ($hdrList[count($hdrList)-1]['Number'] < $curMsg)) {
  163
+					$curMsg += $increment;
  164
+				} else {
  165
+					$curMsg = ($hdrList[count($hdrList)-1]['Number'] + 1);