Skip to content

Commit b2f2876

Browse files
author
zhaowu
committed
不处理domain和ip,删除hosthash
1 parent 99358f5 commit b2f2876

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

app/helpers/api_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def search(query, page_count=10)
1010

1111
@results = nil
1212
begin
13-
options = {:index => 'idx1',:sql => { :select => 'id,ip,title,header,host,hosthash,lastupdatetime'},:per_page => page_count,:page => params['page'],:order => "lastupdatetime DESC"}#:retry_stale => 2,
13+
options = {:index => 'idx1',:sql => { :select => 'id,ip,title,header,host,lastupdatetime'},:per_page => page_count,:page => params['page'],:order => "lastupdatetime DESC"}#:retry_stale => 2,
1414
if @query_l
1515
@mode = "extended"
1616
options[:match_mode] = :extended
@@ -22,7 +22,7 @@ def search(query, page_count=10)
2222
@tags = {}
2323
#if @results
2424
# @results.each {|x|
25-
# @tags[x.hosthash] = Tag.find_by_hosthash x.hosthash
25+
# @tags[x.host] = Tag.find_by_host x.host
2626
# @error, @msg = Userhost.add_user_host(x.host, '127.0.0.2')
2727
# puts "error: #{@msg}" if @error
2828
# }

app/jobs/module/process_class.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ def add_host_to_webdb(host, force=false)
137137
#puts host
138138
#pp http_info
139139
#更新ip
140-
@webdb.insert_ip_to_ipaddr(http_info[:ip])
140+
#@webdb.insert_ip_to_ipaddr(http_info[:ip])
141141

142142
if domain_is_ip
143143
@webdb.update_host_to_subdomain(host, domain, '', http_info, exists_host)
144144
else
145145
#更新根域名表
146-
@webdb.insert_domain_to_rootdomain(domain, exists_host)
146+
#@webdb.insert_domain_to_rootdomain(domain, exists_host)
147147
#更新子域名表
148148
@webdb.update_host_to_subdomain(host, domain, domain_info.subdomain, http_info, exists_host)
149149
end
@@ -200,4 +200,4 @@ def self.perform(url)
200200
#puts "#{@@p.class.name}.perform called"
201201
@@p.add_host_to_webdb(url,false)
202202
end
203-
end
203+
end

app/jobs/module/webdb2_class.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def db_insert_host(db, host, domain, subdomain, r)
100100
body ||= ''
101101
ip = r[:ip]
102102

103-
sql = "insert into subdomain (host, hosthash, domain, reverse_domain, subdomain, ip, header, title, body, lastchecktime, lastupdatetime)"
104-
sql += " values('#{Mysql2::Client.escape(host)}', '#{Digest::MD5.hexdigest(host)}', '#{Mysql2::Client.escape(domain)}', '#{Mysql2::Client.escape(domain.reverse)}', "
103+
sql = "insert into subdomain (host, domain, reverse_domain, subdomain, ip, header, title, body, lastchecktime, lastupdatetime)"
104+
sql += " values('#{Mysql2::Client.escape(host)}', '#{Mysql2::Client.escape(domain)}', '#{Mysql2::Client.escape(domain.reverse)}', "
105105
sql += "'#{Mysql2::Client.escape(subdomain)}', '#{Mysql2::Client.escape(ip)}', '#{Mysql2::Client.escape(header)}', "
106106
sql += "'#{Mysql2::Client.escape(title)}', '#{Mysql2::Client.escape(body.force_encoding('UTF-8'))}', now(), now())"
107107
#puts sql
@@ -122,7 +122,7 @@ def db_update_host(db, host, r)
122122
sql += ", header='#{Mysql2::Client.escape(header)}'"
123123
sql += ", title='#{Mysql2::Client.escape(title)}'"
124124
sql += ", body='#{Mysql2::Client.escape(body.force_encoding('UTF-8'))}'"
125-
sql += ", lastupdatetime=now() where hosthash='#{Digest::MD5.hexdigest(host)}'"
125+
sql += ", lastupdatetime=now() where host='#{Mysql2::Client.escape(host)}'"
126126
#puts sql
127127
db_exec(db, sql)
128128
end
@@ -138,7 +138,7 @@ def db_insert_ip(ip)
138138
end
139139

140140
def db_update_subdomain_checktime(host)
141-
db_exec(@mysql, "update subdomain set lastchecktime=NOW() where hosthash='#{Digest::MD5.hexdigest(host)}'")
141+
db_exec(@mysql, "update subdomain set lastchecktime=NOW() where host='#{Mysql2::Client.escape(host)}'")
142142
redis_update_checktime(host)
143143
end
144144

app/models/tag.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Tag < ActiveRecord::Base
22
self.table_name = "tags"
33

4-
def get(hosthash)
4+
def get(host)
55

66
end
77
end

app/views/search/result.html.erb

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@
7878
<br/> <%= link_to doc.ip, "/search/result?qbase64="+CGI.escape(Base64.encode64('ip="'+doc.ip+'"')) %>
7979
<br/> 更新时间:<%= doc.lastupdatetime.to_datetime.strftime('%F') %>
8080
<br/>
81-
<% if @tags[doc.hosthash] %>
82-
<% if @tags[doc.hosthash].is_a?(Array) %>
83-
<% @tags[doc.hosthash].each do |tag| %>
81+
<% if @tags[doc.host] %>
82+
<% if @tags[doc.host].is_a?(Array) %>
83+
<% @tags[doc.host].each do |tag| %>
8484
<a type="button" class="btn btn-success" href="/search/result?q=<%=tag.tag%>"><%=tag.tag%></a>
8585
<% end %>
8686
<% else %>
87-
<a type="button" class="btn btn-success" href="/search/result?q=<%=@tags[doc.hosthash].tag%>"><%=@tags[doc.hosthash].tag%></a>
87+
<a type="button" class="btn btn-success" href="/search/result?q=<%=@tags[doc.host].tag%>"><%=@tags[doc.host].tag%></a>
8888
<% end %>
8989
<% end %>
9090
</div>

0 commit comments

Comments
 (0)