site inspector, hotlinking page

This commit is contained in:
Kyle Drake 2015-12-29 20:26:00 -06:00
parent 71fabef58f
commit d86f614248
3 changed files with 108 additions and 0 deletions

View file

@ -11,10 +11,26 @@ get '/admin/reports' do
erb :'admin/reports' erb :'admin/reports'
end end
get '/admin/site/:username' do |username|
require_admin
@site = Site[username: username]
erb :'admin/site'
end
post '/admin/reports' do post '/admin/reports' do
end end
post '/admin/site_files/train' do
require_admin
site = Site[params[:site_id]]
site_file = site.site_files_dataset.where(path: params[:path]).first
not_found if site_file.nil?
site.untrain site_file.path
site.train site_file.path, params[:classifier]
'ok'
end
get '/admin/usage' do get '/admin/usage' do
require_admin require_admin
today = Date.today today = Date.today

57
views/admin/site.erb Normal file
View file

@ -0,0 +1,57 @@
<div class="header-Outro">
<div class="row content single-Col">
<h1>Site Inspector</h1>
<h2 class="subtitle"><%= @site.username %></h2>
</div>
</div>
<div class="content misc-page single-Col txt-Center" style="padding-top: 20px;">
<h3>Site Pages</h3>
<table>
<% @site.site_files_dataset.where(path: /\.html/).all.each do |site_file| %>
<tr style="outline: thin solid black;">
<td><img src="<%= @site.screenshot_url(site_file.path, '210x158') %>"></td>
<td>
<p><strong><%= site_file.path %></strong></p>
<% if !site_file.classifier.blank? %>
<p>
<% if site_file.classifier == 'ham' %>
<span style="color: green"><%= site_file.classifier %></span>
<% else %>
<span style="color: red"><strong><%= site_file.classifier %></strong></span>
<% end %>
</p>
<% else %>
<p>Not Classified</p>
<% end %>
<form action="/admin/site_files/train" target="_blank" method="POST">
<%== csrf_token_input_html %>
<input type="hidden" name="site_id" value="<%= @site.id %>">
<input type="hidden" name="path" value="<%= site_file.path %>">
<input type="hidden" name="classifier" value="ham">
<button>Ham</button>
</form>
<form action="/admin/site_files/train" target="_blank" method="POST" onsubmit="return confirm('Confirm spam train of <%= "#{@site.username}/#{site_file.path}" %>');">
<%== csrf_token_input_html %>
<input type="hidden" name="site_id" value="<%= @site.id %>">
<input type="hidden" name="path" value="<%= site_file.path %>">
<input type="hidden" name="classifier" value="spam">
<button>Spam</button>
</form>
<form action="/admin/site_files/train" target="_blank" method="POST" onsubmit="return confirm('Confirm phishing train of <%= "#{@site.username}/#{site_file.path}" %>');">
<%== csrf_token_input_html %>
<input type="hidden" name="site_id" value="<%= @site.id %>">
<input type="hidden" name="path" value="<%= site_file.path %>">
<input type="hidden" name="classifier" value="phishing">
<button>Phishing</button>
</form>
</td>
</tr>
<% end %>
</table>
</div>

View file

@ -0,0 +1,35 @@
<div class="header-Outro">
<div class="row content single-Col">
<h1>Neocities Hotlinking Policy</h1>
</div>
</div>
<div class="content single-Col misc-page">
<p>Neocities has put measures in place to prevent hotlinking of content from non-Neocities sites. This is a part of our process to improve the performance of Neocities web sites, provide more free space for our users, and ensure the site's future sustainability.</p>
<h2>What is hotlinking, and why don't you allow it?</h2>
<p>
<a href="https://en.wikipedia.org/wiki/Inline_linking">Hotlinking</a> is when a non-HTML file hosted by Neocities is embedded into another site that is not hosted by Neocities.
</p>
<p>
We don't allow this because the purpose of Neocities is not to be a "file dump", but to be a portal for people creating their own web sites. When Neocities is used as a file dump for other sites, it hurts Neocities sites by cutting into the amount of bandwidth available to them. We want to focus our resources on those sites.
</p>
<p>
<strong>If you have a web site on another server, the best way to serve files for it is by putting those files directly on that server!</strong> Not only does this ensure that the files will not disappear in the future, but it also makes it easier for you to backup that site independently. There's really no good reason to use Neocities to host files for other web sites.
</p>
<p>
If you need to store files for hotlinking use, there are plenty of alternatives. <a href="http://imgur.com/">Imgur</a> for example is a place you can store images that can be embedded by any site. Again, this is bad practice because you have to trust Imgur to not delete the image in the future for your site to continue loading. You're still better off hosting the images on the site's own server.
</p>
<p>
Please keep in mind that our reasons for doing this are purely out of requirement. We need to focus on being sustainable to run Neocities without advertisers and stay independent, and preventing Neocites from being used as a "file dump host" has always been a part of that process.
</p>
<h2>Is there a way to remove the hotlinking restriction?</h2>
<p>
The hotlinking policy currently applies to all sites. We can't currently make exceptions because of the way our proxy servers work. We may change this in the future.
</p>
</div>