diff common.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
line wrap: on
line diff
--- a/common.php	Thu Jul 10 22:26:45 2014 +0200
+++ b/common.php	Thu Jul 17 23:24:17 2014 +0200
@@ -72,6 +72,7 @@
 function nntp_article_wanted($messageid) {
 	global $db, $pnewss_hooks;
 	if ($db->evalRow('SELECT `id` FROM `messages` WHERE `messageid` = ?', $messageid) !== FALSE) return FALSE;
+	if ($db->evalRow('SELECT * FROM `blacklist` WHERE `messageid` = ?', $messageid) !== FALSE) return FALSE;
 	if (!pnewss_call_filter_hooks($pnewss_hooks['article_filter'], array(array('messageid' => $messageid)))) return FALSE;
 	return TRUE;
 }
@@ -136,6 +137,7 @@
 	$messageid = substr($messageid, 1, -1);
 	$article = $db->evalRowAssoc('SELECT * FROM `messages` WHERE `messageid` = ?', $messageid);
 	if ($article !== FALSE) throw new Exception('Duplicate');
+	if ($db->evalRow('SELECT * FROM `blacklist` WHERE `messageid` = ?', $messageid) !== FALSE) throw new Exception('Blacklisted Message-ID');
 	$headers['PATH'] = 'pNewss.Core.UCIS.nl'.(isset($headers['PATH'])?'!'.$headers['PATH']:'');
 	foreach (array('Path', 'From', 'Newsgroups', 'Subject', 'Date', 'Message-ID', 'Sender') as $headername) {
 		if (isset($headers[strtoupper($headername)])) $header[] = $headername.': '.$headers[strtoupper($headername)];
@@ -143,7 +145,7 @@
 	if (!pnewss_call_filter_hooks($pnewss_hooks['article_filter'], array(array('messageid' => $messageid, 'headers' => $headers, 'body' => $lines)))) throw new Exception('Filtered');
 	$headertext = implode("\r\n", $header);
 	$bodytext = implode("\r\n", $lines);
-	if (strlen($headertext) > 65535 || strlen($bodytext) > 16777215) throw new Exception('Message too big');
+	if (strlen($messageid) > 255 || strlen($headertext) > 65535 || strlen($bodytext) > 16777215) throw new Exception('Message too big');
 	$id = $db->insert('INSERT INTO `messages` (`messageid`, `header`, `body`) VALUES (?, ?, ?)', array($messageid, $headertext, $bodytext));
 	foreach ($newsgroups as $groupid) $db->insert('INSERT INTO `groupmessages` (`group`, `message`) VALUES (?, ?)', array($groupid, $id));
 	pnewss_call_hooks($pnewss_hooks['article_stored'], array(array('messageid' => $messageid, 'headers' => $headers, 'body' => $lines, 'dbid' => $id)));