function ewiki_edit_save_antispam_urlblock(&$save, &$old_data) { global $ewiki_errmsg, $ewiki_id; $BLOCK = EWIKI_PAGE_BLOCKED; preg_match_all('°(http://[^\\s*<>"\'\\[\\]\\#]+)°', $save["content"], $save_urls); preg_match_all('°(http://[^\\s*<>"\'\\[\\]\\#]+)°', $old_data["content"], $old_urls); $added_urls = array_diff($save_urls[1], $old_urls[1]); if ($added_urls) { foreach ($added_urls as $i => $url) { #-- test against BannedLinks, then deface (filter page) URL if (ewiki_blocked_link($url, $BLOCK)) { $block = true; unset($added_urls[$i]); } } $old = $i + 1; } #-- if matched if ($block) { #-- add new URLs to our BannedLinks page if ($new = count($added_urls)) { $content = ""; foreach ($added_urls as $d) { $d = preg_replace('#^.+//(?:www\\.)?#', '', $d); $d = preg_replace('#^([^/]+)(/.*)?$*', '$1', $d); if ($d) { $content .= "\n* [{$d}] (auto-added by spam attack on [{$ewiki_id}])"; } } if ($content) { ewiki_db::APPEND($BLOCK, $content); } $date = strftime("%c", time()); ewiki_append_to_page("SpamLog", "\n* spam attack on [{$ewiki_id}] from {$_SERVER['REMOTE_ADDRESS']}:{$_SERVER['REMOTE_PORT']} ({$_SERVER['HTTP_USER_AGENT']}) happend at {$date}, around {$new} of the {$old} added URLs were already on BlockedLinks"); } #-- error reporting method for ["edit_save"] $save = array(); $ewiki_errmsg = ewiki_t("BLOCKED_URL"); return false; } }
if (MAIL2WIKI_SPAM) { ewiki_db::APPEND(MAIL2WIKI_SPAM, "\n----\n{$mbox}\n"); } } elseif (!ewiki_db::GET($id)) { ewiki_db::APPEND($id, $page); } else { if (preg_match("/^From: [^\n]+/m", $mbox, $uu)) { $from = from_mail_or_link($uu[1]); $from = "[{$from}]: "; } else { $from = "----\n\n"; } #-- do echo "[{$cron}]: storing mail from '{$from}' onto page '{$id}'\n"; $page = trim($page); ewiki_db::APPEND($id, "\n\n{$from}{$page}\n"); } } } unset($mbox); unset($incoming); #-- return a WikiPageUserName or [name|email@...] string back function from_mail_or_link($from) { $from = strtr($from, "<>\"\\'", " "); $l = strpos($from, "@"); if ($l = strrpos($from, " ", $l)) { $name = substr($from, 0, $l); $mail = substr($from, $l + 1); $wiki = str_replace(" ", "", $name); if (ewiki_db::GET($wiki)) {