mirror of
https://github.com/neocities/neocities.git
synced 2025-08-04 08:42:00 +02:00
remove trump plan
This commit is contained in:
parent
3ff6f420a4
commit
7b068b0872
5 changed files with 26 additions and 145 deletions
32
app/index.rb
32
app/index.rb
|
@ -72,42 +72,10 @@ get '/?' do
|
|||
@blog_feed_html = SimpleCache.get :blog_feed_html
|
||||
end
|
||||
|
||||
if params[:trumpplan]
|
||||
flash[:is_trump_plan] = true
|
||||
end
|
||||
|
||||
erb :index, layout: :index_layout
|
||||
end
|
||||
|
||||
def trump_plan_eligible?
|
||||
trumpplan_path = File.join 'files', 'trumpplan.txt'
|
||||
|
||||
ranges = []
|
||||
|
||||
if File.exist? trumpplan_path
|
||||
parsed_ip = IPAddress.parse request.ip
|
||||
return false if parsed_ip.ipv6? # NOT EXCLUSIVE ENOUGH
|
||||
|
||||
File.readlines(trumpplan_path).each do |range|
|
||||
ranges << IPAddress.parse(range.strip)
|
||||
end
|
||||
|
||||
matched_ip = false
|
||||
ranges.each do |range|
|
||||
if range.include? parsed_ip
|
||||
matched_ip = true
|
||||
end
|
||||
end
|
||||
return matched_ip
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
get '/welcome' do
|
||||
if params[:trumpplan] || flash[:is_trump_plan] || trump_plan_eligible?
|
||||
@is_trump_plan = true
|
||||
end
|
||||
|
||||
require_login
|
||||
redirect '/' if current_site.supporter?
|
||||
erb :'welcome', locals: {site: current_site}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue