1<?php 2// $Id$ 3 4// Not implemented yet 5$spamassassin_path = '/opt/ecelerity/3rdParty/bin/spamassassin'; 6 7// List of usual SPAM words 8$words_blacklist = [ 9 '000webhost', 10 'adipex', 11 'alprazolam', 12 'arimidex', 13 'ativan', 14 'bitcoin', 15 'bontril', 16 'carisoprodol', 17 'coralclub24', 18 'http://cars-4-you.org', 19 'http://the-best-cars.org', 20 'casino', 21 'cialis', 22 'ciprofloxacin', 23 'clonazepam', 24 'digoxin', 25 'earning', 26 'ephedra', 27 'erectile', 28 'esomeprazole', 29 'firearms', 30 'glucophage', 31 'http://20six.co.uk', 32 'hydrochlorothiazide', 33 'hydrocodone', 34 'lisinopril', 35 'lopressor', 36 'lorazepam', 37 'meridia', 38 'metronidazole', 39 'mining', 40 'naproxen', 41 'nexium', 42 'paroxetine', 43 'pharmacy', 44 'phentermine', 45 'poker', 46 'potassium chloride', 47 'pravachol', 48 'testosterone', 49 'tramadol', 50 'ultram', 51 'valium', 52 'viagra', 53 'vicodin', 54 'vicoprofen', 55 'xanax', 56 'zanaflex', 57 'http://republika.pl', 58]; 59 60function check_spam_words ($text, $badwords) { 61 foreach($badwords as $badword) { 62 if (strpos($text, $badword) !== false) { 63 return true; 64 } 65 } 66 return false; 67} 68 69// Miscellaneous URL related spam checks 70// * BBCode links (a common spam technique) 71// * Too many http://'s 72function check_spam_urls ($text, $httplimit = 4) { 73 if (preg_match('/\[(url|link)=[^]]+\]/', $text)) { 74 return true; 75 } 76 if (substr_count($text, 'http://') >= $httplimit) { 77 return true; 78 } 79 return false; 80} 81 82// Check with spam assassin if the text is spam or not 83// This has not been fully tested or implemented 84function check_spam_assassin ($text, $sa_path) { 85 86 $spam = shell_exec ('echo ' . escapeshellarg($text) . " | $sa_path -L -e 8"); 87 88 $match = ''; 89 if (preg_match ('/^X-Spam-Status:.+(?:\n\t.+)*'.'/m', (string)$spam, $match)) { 90 $spam_data = $match[0]; 91 } else { 92 $spam_data = 'Error matching the SpamAssassin data'; 93 } 94 return $spam_data; 95} 96 97// Check if an IP is marked as spammer 98// Test with 127.0.0.2 for positive and 127.0.0.1 for negative 99function is_spam_ip ($ip) { 100 $reverse_ip = implode('.', array_reverse(explode('.', $ip))); 101 $lists = array(); 102 103 // spammers lists 104 // [0] => dns server, [1] => exclude ip 105 $lists[] = ['bl.spamcop.net']; 106 $lists[] = ['dnsbl.sorbs.net', '127.0.0.10']; // exclude dynamic ips list 107 108 foreach ($lists as $list) { 109 $host = $reverse_ip . '.' . $list[0]; 110 $dns = gethostbyname ($host); 111 112 if ($dns != $host && (empty($list[1]) || $dns != $list[1])) { 113 return $ip; 114 } 115 } 116 return false; 117} 118