Created
February 12, 2010 13:35
-
-
Save pirj/302554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 6b9484bd51ce108dcab1158062a0183348aa16d4 | |
Author: Phil Pirj <pirj@mail.ru> | |
Date: Wed Feb 10 23:17:46 2010 +0300 | |
adding /logs | |
diff --git a/container.rb b/container.rb | |
index 6bec45a..5d80b29 100644 | |
--- a/container.rb | |
+++ b/container.rb | |
@@ -8,6 +8,12 @@ require 'builder' | |
# require 'lib/authentication' | |
+class Sessions | |
+ def self.data | |
+ @@data ||= [] | |
+ end | |
+end | |
+ | |
class AllBots | |
def self.bots | |
@@bots ||= {} | |
@@ -27,13 +33,57 @@ class BotContainter < Sinatra::Base | |
q[key] = req.search(key).inner_html.strip unless req.search(key).nil? | |
end | |
- if q[:oper] == 'auth' | |
+ # !! debug | |
+ q[:time] = Time.now | |
+ q[:client_request] = params[:q] | |
+ q[:sid] = env['rack.session.options'][:id] | |
+ | |
+ reply = if q[:oper] == 'auth' | |
do_auth q | |
elsif q[:oper] == 'sugg' | |
do_sugg q | |
else | |
xmlerror "10" | |
end | |
+ | |
+ q[:server_reply] = reply | |
+ | |
+ Sessions.data.insert -1, q | |
+ | |
+ reply | |
+ end | |
+ | |
+ get '/logs' do | |
+ Builder::XmlMarkup.new.html do |html| | |
+ html.body do |body| | |
+ body.table({:border => "1px solid black"}) do |table| | |
+ table.tr do |tr| | |
+ tr.th 'time' | |
+ tr.th 'client_request' | |
+ tr.th 'server_reply' | |
+ tr.th 'sid' | |
+ tr.th 'oper' | |
+ tr.th 'login' | |
+ tr.th 'password' | |
+ tr.th 'response' | |
+ tr.th 'result' | |
+ end | |
+ Sessions.data.each do |row| | |
+ table.tr do |tr| | |
+ tr.td row[:time] | |
+ tr.td row[:client_request] | |
+ tr.td row[:server_reply] | |
+ tr.td row[:sid] | |
+ tr.td row[:oper] | |
+ tr.td row[:login] | |
+ tr.td row[:password] | |
+ tr.td row[:response] | |
+ tr.td row[:result] | |
+ end | |
+ end | |
+ end | |
+ end | |
+ end | |
end | |
def do_auth q | |
@@ -48,7 +98,6 @@ class BotContainter < Sinatra::Base | |
Builder::XmlMarkup.new.server do |d| | |
d.id q[:id] | |
- # d.sid env['rack.session.options'][:id] | |
d.result "00" | |
end | |
end | |
@@ -59,7 +108,6 @@ class BotContainter < Sinatra::Base | |
Builder::XmlMarkup.new.server do |d| | |
d.id q[:id] | |
- # d.sid env['rack.session.options'][:id] | |
d.request do |b| | |
b.navigate do |n| | |
n.url 'http://s5.travian.ru' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment