mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
detect spam sites
This commit is contained in:
parent
71d4e99b1c
commit
74f5ef31d9
1 changed files with 20 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue