Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JP's domain blacklist
<?php
/** BlackList Generator from domain list
*
* @author Jan Pecha, <janpecha@email.cz>
* @version 2013-01-26-1
*/
$content = file($_SERVER['argv'][1]);
$domains = array();
if($content !== FALSE)
{
$i = 1;
foreach($content as $line)
{
if($line[0] === '=' || $line[0] === '-')
{
continue;
}
$domain = $line;
$pos = strpos($domain, ' ');
if($pos !== FALSE)
{
$domain = substr($domain, 0, $pos); // TODO: or pos-1??
}
$domain = trim($domain);
$pos = strrpos($domain, '.');
if(!$pos) // FALSE or position ZERO
{
throw new Exception('This is bad line on line ' . $i . ': ' . $line);
}
$tld = substr($domain, $pos+1);
$domain = substr($domain, 0, $pos);
$domains[$tld][$domain] = TRUE;
$i++;
}
}
$output = array();
foreach($domains as $tld => $entry)
{
$item = array();
foreach($entry as $domain => $value)
{
$item[] = $domain;
}
$cond = count($item) === 1;
$item = implode('|', $item);
$item = strtr($item, array(
'.' => '\\.',
));
if(!$cond)
{
$item = '(' . $item . ')';
}
$item = '(' . $item . '\\.' . $tld . ')';
$output[] = $item;
}
$output = '/.+@' . implode('|', $output) . '/';
// Testing
foreach($domains as $tld => $entry)
{
foreach($entry as $domain => $value)
{
$res = preg_match($output, 'testmail@' . $domain . '.' . $tld);
if(!$res)
{
echo "ERROR IN REGEXP!!!\n\n";
exit(1);
}
}
}
echo $output, "\n";
petrovakreditka.cz
cgmail.cz (cgmail.cz, cgmail.cz)
nejlevnejsiucet.cz
proom.cz (proom.cz)
pozadejte.si
vyridte.cz (vyridte.cz)
cgmail2.cz (cgmail2.cz, cgmail2.cz, cgmail2.cz, cgmail2.cz, cgmail2.cz)
dryad.cz
pujcime-ihned.cz
usetri.si
rencrapote.com
rhom.cz
rozhodnuto.cz
chcikreditnikartu.cz
croom.cz (croom.cz)
printmanshop.net
themailcentrum.net
topmessanger.com (topmessanger.com, topmessanger.com, topmessanger.com)
necum.cz (necum.cz)
pujcka600.cz
messbarnet.com
xmasonline.org (xmasonline.org, xmasonline.org)
droom.cz (droom.cz)
p-c-vinohrady.cz
p-e.cz
mekandetransfer.com (mekandetransfer.com, mekandetransfer.com)
sms-pujcka.tv
petrovapujcka.cz
yivo.cz
nejvyhodnejsi-dovolena.com
realpressing.net (realpressing.net, realpressing.net)
gandrematre.com (gandrematre.com)
schvalenapujcka.cz
pujcime-ihned.cz
sms-loans.eu
keuroperda.net (keuroperda.net)
keuroperdax.net (keuroperdax.net)
==
usetri.si
proom.cz
keuroperda.net
proom.cz
usetri.si
cgmail.cz
cgmail.cz
keuroperdax.net
tomovapujcka.cz
keuroperda.net
petrovakreditka.cz
vyridte.cz
secondsnowmarket.net
secondsnowmarket.net
okamzitahotovost.cz
keuroperda.net
secondsnowmarket.net
pozadejte.si
chcikreditnikartu.cz
croom.cz
aaa-auto-40000.com
cgmail.cz
rhom.cz
croom.cz
droom.cz
yivo.cz
secondsnowmarket.net
secondsnowmarket.net
proom.cz
pemelectro.ru
elephantmailing.net
pujcime-ihned.cz
elephantmailing.net
petrovapujcka.cz
pujcka600.cz
superchristmas.net
secondsnowmarket.net
yes-pujcka.cz
cgmail.cz
elephantmailing.net
droom.cz
superchristmas.net
petrovakreditka.cz
cgmail2.cz
modrfeng.net
modrfeng.net
pujcka500.cz
cgmail1.cz
kukingples.net
droom.cz
nejlepsi-autopujcka.com
modrfeng.net
modrfeng.net
motorophone.net
kukingples.net
garantovano.cz
kukingples.net
me-pujcky.cz
farmarkazuzanka.cz
pozadejte.si
motorophone.net
motorophone.net
modrfeng.net
croom.cz
dryad.cz
motorophone.net
smejkafighter.com
cgmail.cz
nokimobink.net
aaa-auto-40000.cz
pujcka600.cz
yivo.cz
schvalenapujcka.cz
smejkafighter.com
patromord.net
patromord.net
smejkafighter.com
smejkafighter.com
rhom.cz
smejkafighter.com
proom.cz
vetchyprokarla.cz
gogoblade.com
gogoblade.com
gogoblade.com
mikroplusdat.net
korkondeta.net
rhom.cz
mikroplusdat.net
croom.cz
big-man-kdykoli.cz
dryad.cz
slevkohyp.net
kerdomet.com
pozadejte.si
slevkohyp.net
sexypumas.net
kerdomet.com
dryad.cz
---------- mimo napr. z Lupy.cz ze Zpravicek
mailbox4free.eu
/.+@((petrovakreditka|cgmail|nejlevnejsiucet|proom|vyridte|cgmail2|dryad|pujcime-ihned|rhom|rozhodnuto|chcikreditnikartu|croom|necum|pujcka600|droom|p-c-vinohrady|p-e|petrovapujcka|yivo|schvalenapujcka|tomovapujcka|okamzitahotovost|yes-pujcka|pujcka500|cgmail1|garantovano|me-pujcky|farmarkazuzanka|aaa-auto-40000|vetchyprokarla|big-man-kdykoli)\.cz)|((pozadejte|usetri)\.si)|((rencrapote|topmessanger|messbarnet|mekandetransfer|nejvyhodnejsi-dovolena|gandrematre|aaa-auto-40000|nejlepsi-autopujcka|smejkafighter|gogoblade|kerdomet)\.com)|((printmanshop|themailcentrum|realpressing|keuroperda|keuroperdax|secondsnowmarket|elephantmailing|superchristmas|modrfeng|kukingples|motorophone|nokimobink|patromord|mikroplusdat|korkondeta|slevkohyp|sexypumas)\.net)|(xmasonline\.org)|(sms-pujcka\.tv)|((sms-loans|mailbox4free)\.eu)|(pemelectro\.ru)/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.