Changeset 1717
- Timestamp:
- 07/24/08 16:28:26 (6 months ago)
- Files:
-
- community_hive/trunk/community_hive_web/app/controllers/account_controller.rb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/controllers/main_controller.rb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/helpers/application_helper.rb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/models/history_url.rb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/models/queue_url.rb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/views/layouts/application.html.erb (modified) (1 diff)
- community_hive/trunk/community_hive_web/app/views/main/index.html.erb (modified) (1 diff)
- community_hive/trunk/community_hive_web/config/routes.rb (modified) (1 diff)
- community_hive/trunk/community_hive_web/public/images/bee-small.jpg (added)
- community_hive/trunk/community_hive_web/public/images/title.png (added)
- community_hive/trunk/community_hive_web/public/stylesheets/style.css (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
community_hive/trunk/community_hive_web/app/controllers/account_controller.rb
r1620 r1717 1 1 class AccountController < ApplicationController 2 3 layout 'application' 2 4 def login 3 5 return unless request.post? community_hive/trunk/community_hive_web/app/controllers/main_controller.rb
r1620 r1717 1 1 class MainController < ApplicationController 2 before_filter :login_required2 # before_filter :login_required 3 3 4 # List the latest history urls5 4 def index 6 @count = HistoryUrl.count7 @urls = HistoryUrl.paginate(:order => 'time_at DESC, status',:page => params[:page])8 5 end 6 7 # Submit a URL to the Queue 8 def create 9 q = QueueUrl.new(:url => params[:url]) 10 if q.save 11 # Create it 12 flash[:message] = "Thank you. The URL will be sent to our machines for processing." 13 else 14 flash[:error] = q.errors.on 'url' 15 end 16 17 redirect_to :action => 'index' 18 end 19 20 9 21 end community_hive/trunk/community_hive_web/app/helpers/application_helper.rb
r1620 r1717 2 2 module ApplicationHelper 3 3 4 def main_nav(user) 4 def nav_bar(user) 5 b = "" 6 b << "<li>#{link_to("Check a URL", :controller => 'main', :action => 'index')}</li>" 7 b << "<li>#{link_to("Search URLs", :controller => 'urls', :action => 'search')}</li>" 8 b << "<li>#{link_to("Stats", :controller => 'statistics', :action => 'index')}</li>" 9 b << "<li>#{link_to("About", :controller => 'about', :action => 'index')}</li>" 5 10 if user 6 which_link ="" 11 b << "<li>#{link_to("My Account", :controller => 'myaccount', :action => 'index')}</li>" 12 b << "<li>#{link_to("Logout", :controller => 'account', :action => 'logout')}</li>" 7 13 if user.admin 8 which_link=<<-AL 9 <td> 10 #{link_to('Admin', :controller => 'users', :action => 'index')} 11 </Td> 12 AL 13 else 14 which_link=<<-AL 15 <td> 16 #{link_to('My Account', :controller => 'myaccount', :action => 'index')} 17 </td> 18 AL 14 b << "<li>#{link_to("Admin", :controller => 'accounts', :action => 'index')}</li>" 19 15 end 20 ## Link below are for everyone 21 which_link = which_link.strip 22 data=<<-EOD 23 #{which_link} 24 <td> 25 #{link_to('History', :controller => 'main', :action => 'index')} 26 </td> 27 <td> 28 #{link_to('Queue', :controller => 'queued_urls', :action => 'index')} 29 </td> 30 <td> 31 #{link_to('Logout', :controller => 'account', :action => 'logout')} 32 </td> 33 EOD 34 data.strip 16 else 17 b << "<li>#{link_to("Login", :controller => 'account', :action => 'login')}</li>" 35 18 end 19 b 20 end 21 22 def show_message 23 [:error, :message].collect do |key| 24 content_tag(:div, flash[key], :class => "flash flash_#{key}") unless flash[key].blank? 25 end.join 36 26 end 37 27 community_hive/trunk/community_hive_web/app/models/history_url.rb
r1620 r1717 1 require 'uri' 1 2 class HistoryUrl < ActiveRecord::Base 3 # Is this connection needed? Will we show *who* reported this? 2 4 belongs_to :user 5 6 # Shorten URLs for displaying on website 7 def host 8 u = URI.parse(self.url) 9 u.host 10 end 11 3 12 end community_hive/trunk/community_hive_web/app/models/queue_url.rb
r1620 r1717 1 require 'uri' 1 2 class QueueUrl < ActiveRecord::Base 2 validates_presence_of :url 3 validates_format_of :url, 4 :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix, 5 :message => "There's was something wrong with the format of the Url you entered. We only accept HTTP Urls in the proper format. See the example below." 6 3 7 end community_hive/trunk/community_hive_web/app/views/layouts/application.html.erb
r1620 r1717 4 4 <head> 5 5 <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 6 <title>Community Hive</title> 7 <%= stylesheet_link_tag 'scaffold' %> 8 <%= javascript_include_tag :defaults %> 6 <title>communityHive - a honeyclient project</title> 7 <%= stylesheet_link_tag 'style' %> 9 8 </head> 10 9 <body> 11 <div id="container"> 12 <div id="header"> 13 <div id="logo"><%= link_to "Community Hive", :controller => 'main', :action => 'index' %></div> 14 <div id="topnav"> 15 <table width="250px"> 16 <tr> 17 <%= main_nav(@current_user)%> 18 </tr> 19 </table> 20 </div> 21 </div> 22 23 <div id="main"> 24 <div id="mainpadding"> 25 <p style="color: green"><%= flash[:notice] %></p> 26 <%= yield %> 27 </div> 28 </div> 29 <!-- 30 <div id="footer"> 31 Hive Storage is part of the HoneyClient project from the <a href="http://www.mitre.org">MITRE Corporation</a> 32 </div> 33 --> 34 </div> 10 <div id="container"> 11 <div id="header"> 12 <img src="/images/bee-small.jpg"/> 13 <img style="margin-bottom: 50px; margin-left: 150px;" src="/images/title.png" /> 14 </div> 15 <div id="navbar"> 16 <ul id="nav"> 17 <%= nav_bar(@current_user) %> 18 </ul> 19 </div> 20 <div id="page"> 21 <%= yield %> 22 </div> 23 <div id="footer"> 24 <a href="#">terms of Use</a> 25 <a href="#">privacy</a> 26 <a href="#">contact us</a> 27 <p> 28 communityHive is part of the <a href="#">honeyclient project</a> sponsored by the MITRE Corporation 29 </p> 30 </div> 31 32 </div> 35 33 </body> 36 34 </html> community_hive/trunk/community_hive_web/app/views/main/index.html.erb
r1620 r1717 1 <h2>Processed URLs (history)</h2> 2 Total of <%=h @count %> Urls 3 <div id="data"> 4 <table> 5 <tbody> 6 <tr> 7 <th>Url</th> 8 <th>Status</th> 9 <th>Collected</th> 10 </tr> 11 12 <% for u in @urls %> 13 <tr> 14 <td><%=h truncate(u.url,50) %></td> 15 <td><%=h u.status %></td> 16 <td><%=h u.time_at %></td> 17 </tr> 18 <% end %> 19 </tbody> 20 </table> 21 </div> 1 <h2>Check a Url</h2> 2 <p> 3 Send us a Url of a site you would like to check for malicious software. 4 </p> 5 <% form_tag '/main/create' do -%> 6 <%= show_message %> 7 Url: <%= text_field_tag 'url', '', :size => '50' %> 8 <p style="font-size: small; color: #444; padding-left: 35px; padding-top: 5px; margin: 0;"> 9 Example: http://example.com/hello 10 </p> 11 <p> 12 CAPTCH HERE... 13 </p> 14 <%= submit_tag 'Check It' %> 15 <% end -%> 22 16 23 <br/>24 <%= will_paginate @urls, :inner_window => 10, :outer_window => 10 %>community_hive/trunk/community_hive_web/config/routes.rb
r1620 r1717 27 27 # You can have the root of your site routed with map.root -- just remember to delete public/index.html. 28 28 map.root :controller => "main" 29 30 map.login '/login', :controller => 'account', :action => 'login' 31 map.logout '/logout', :controller => 'account', :action => 'logout' 29 32 30 33 # See how all your routes lay out with "rake routes"
