detect spam sites

This commit is contained in:
Kyle Drake 2014-08-29 21:19:03 -07:00
parent 71d4e99b1c
commit 74f5ef31d9

View file

@ -70,6 +70,8 @@ class Site < Sequel::Model
/PHP\.Hide/
]
SPAM_MATCH_REGEX = /#{$config['spam_smart_filter'].join('|')}/i
EMAIL_SANITY_REGEX = /.+@.+\..+/i
EDITABLE_FILE_EXT = /html|htm|txt|js|css|md/i
@ -342,6 +344,24 @@ class Site < Sequel::Model
return false
end
open(uploaded.path) { |f| matches = f.grep SPAM_MATCH_REGEX }
if !matches.empty?
EmailWorker.perform_async({
from: 'web@neocities.org',
reply_to: email,
to: 'spam@neocities.org',
subject: "[Neocities SPAM]: #{username}",
body: %{
#{username}
<br>
https://#{self.host}#{relative_path}
<br>
<a href="https://#{self.host}/#{relative_path}">link</a>
}
})
end
pathname = Pathname(path)
if pathname.basename.to_s == 'index.html'
new_title = Nokogiri::HTML(File.read(uploaded.path)).css('title').first.text