function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'frontend_saveComment': if (!is_array($eventData) || serendipity_db_bool($eventData['allow_comments'])) { // Check for IP listed in SURBL if (serendipity_db_bool($this->get_config('surbl_enabled', false))) { require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : 'bundled-libs/') . 'Net/DNSBL/SURBL.php'; $surbl = new Net_DNSBL_SURBL(); if ($surbl->isListed($addData['url'])) { $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_SURBL, $addData); $eventData = array('allow_comments' => false); $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_SURBL; return false; } // BEGIN Code copied from http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php $urls = '(http|file|ftp)'; $ltrs = '\\w'; $gunk = '/#~:.?+=&%@!\\-'; $punc = '.:?\\-'; $any = "{$ltrs}{$gunk}{$punc}"; preg_match_all("{\n \\b\n {$urls} :\n [{$any}] +?\n\n\n (?=\n [{$punc}] *\n [^{$any}]\n |\n \$\n )\n }x", $addData['comment'], $matches); // END Code copied from http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php foreach ($matches[0] as $surbl_check_url) { if ($surbl->isListed($surbl_check_url)) { $eventData = array('allow_comments' => false); $serendipity['messagestack']['comments'][] = PLUGIN_EVENT_SPAMBLOCK_ERROR_SURBL; return false; } } } } return true; break; default: return false; break; } } else { return false; } }
} else { // This is a read transaction, use the slave database $lilurl = new lilURL(READ_ONLY); if (isset($_GET['id'])) { $id = mysql_escape_string($_GET['id']); } elseif (REWRITE) { $explodo = explode('/', $_SERVER['REQUEST_URI']); $id = mysql_escape_string($explodo[count($explodo) - 1]); } else { $id = ''; } // if the id isn't empty and it's not this file, redirect to it's url if ($id != '' && $id != basename($_SERVER['PHP_SELF'])) { $location = $lilurl->get_url($id); if ($location != -1) { $surbl = new Net_DNSBL_SURBL(); $dnsbl = new Net_DNSBL(); if ($surbl->isListed($location) || $dnsbl->isListed(parse_url($location, PHP_URL_HOST))) { // 410 Gone // XXX: cache this result header("HTTP/1.1 410 Gone"); $msg = '<p class="error">Blacklisted URL!</p>'; } else { header('Location: ' . $location); } } else { $msg = '<p class="error">Sorry, but that ur1 isn\'t in our database.</p>'; } } } // print the form
<?php require_once 'Net/DNSBL/SURBL.php'; $surbl = new Net_DNSBL_SURBL(); require_once 'DB.php'; $dbh = DB::connect('mysqli://*****:*****@localhost/pear'); $sql = 'SELECT homepage, handle FROM users WHERE registered = 1'; $users = $dbh->getAll($sql, DB_FETCHMODE_ASSOC); foreach ($users as $u) { if (!empty($u['homepage']) && $surbl->isListed($u['homepage'])) { echo $u['handle'] . "\n"; } }