1 a
:20:{i
:0;a
:3:{i
:0;s
:14:"document_start";i
:1;a
:0:{}i
:2;i
:0;}i
:1;a
:3:{i
:0;s
:6:"p_open";i
:1;a
:0:{}i
:2;i
:0;}i
:2;a
:3:{i
:0;s
:7:"p_close";i
:1;a
:0:{}i
:2;i
:1;}i
:3;a
:3:{i
:0;s
:12:"section_edit";i
:1;a
:4:{i
:0;i
:-1;i
:1;i
:0;i
:2;i
:1;i
:3;s
:0:"";}i
:2;i
:1;}i
:4;a
:3:{i
:0;s
:6:"header";i
:1;a
:3:{i
:0;s
:9:"Appengine";i
:1;i
:1;i
:2;i
:1;}i
:2;i
:1;}i
:5;a
:3:{i
:0;s
:12:"section_open";i
:1;a
:1:{i
:0;i
:1;}i
:2;i
:1;}i
:6;a
:3:{i
:0;s
:6:"p_open";i
:1;a
:0:{}i
:2;i
:24;}i
:7;a
:3:{i
:0;s
:5:"cdata";i
:1;a
:1:{i
:0;s
:1:"
2 ";}i
:2;i
:25;}i
:8;a
:3:{i
:0;s
:12:"externallink";i
:1;a
:2:{i
:0;s
:33:"http://code.google.com/appengine/";i
:1;s
:16:"Google Appengine";}i
:2;i
:26;}i
:9;a
:3:{i
:0;s
:7:"p_close";i
:1;a
:0:{}i
:2;i
:80;}i
:10;a
:2:{i
:0;s
:6:"plugin";i
:1;a
:4:{i
:0;s
:7:"uparrow";i
:1;a
:1:{i
:0;s
:42:"lib/plugins/uparrow/images/tango-small.png";}i
:2;i
:1;i
:3;s
:6:"~~UP~~";}}i
:11;a
:3:{i
:0;s
:13:"section_close";i
:1;a
:0:{}i
:2;i
:82;}i
:12;a
:3:{i
:0;s
:12:"section_edit";i
:1;a
:4:{i
:0;i
:1;i
:1;i
:81;i
:2;i
:1;i
:3;s
:9:"Appengine";}i
:2;i
:82;}i
:13;a
:3:{i
:0;s
:6:"header";i
:1;a
:3:{i
:0;s
:7:"Example";i
:1;i
:2;i
:2;i
:82;}i
:2;i
:82;}i
:14;a
:3:{i
:0;s
:12:"section_open";i
:1;a
:1:{i
:0;i
:2;}i
:2;i
:82;}i
:15;a
:3:{i
:0;s
:4:"code";i
:1;a
:3:{i
:0;s
:4160:"
3 from google.appengine.ext import webapp
4 from google.appengine.ext.webapp.util import run_wsgi_app
5 from google.appengine.ext import db
7 from HTMLParser import HTMLParser
10 class MyHTMLParser(HTMLParser):
12 HTMLParser.__init__(self)
15 def handle_starttag(self, tag, attrs):
18 if attr[0] == 'flashvars':
22 HTMLParser.feed(self, data)
28 class Level(db.Model):
29 content = db.TextProperty()
31 class Current(db.Model):
32 x = db.IntegerProperty()
33 y = db.IntegerProperty()
34 d = db.IntegerProperty()
35 n = db.IntegerProperty()
36 m = db.IntegerProperty()
37 l = db.IntegerProperty()
39 class Wrong(db.Model):
40 x = db.IntegerProperty()
41 y = db.IntegerProperty()
42 d = db.IntegerProperty()
43 l = db.IntegerProperty()
45 class CrossPage(webapp.RequestHandler):
47 url = 'http://www.hacker.org/cross/index.php?name=kauesilv&password=a1b2c3d4'
48 regex = r'boardinit = "([^
"]*)"'
49 debug
= self.request.get
('debug'
)
50 s
= self.request.get
('s'
)
51 path
= self.request.get
('path'
)
52 self.response.headers
['Content-Type'
] = 'text
/plain'
54 urllib.urlopen
(url
+ '
&sol=' + path).read()
55 s
= urllib.urlopen
(url
).read
()
56 #self.response.out.write
(s
+ '\n'
)
57 board
= re.compile
(regex
).search
(s
).groups
()[0].split
('
,'
)
58 self.response.out.write
(str
(len
(board
)) + '\n'
+ str
(len
(board
[0])) + '\n'
)
60 self.response.out.write
(str
(line
) + '\n'
)
62 class MainPage
(webapp.RequestHandler
):
64 delete
= self.request.get
('delete'
)
66 db.delete
(Wrong.all
().fetch
(100))
67 if Wrong.all
().count
(1) == 1:
70 url
= 'http
://www.hacker.org
/coil
/index.php?name
=kauesilv
&password=a1b2c3d4'
71 regex
= r'x
=(\d
*)&y=(\d*)&board=(.*)'
72 regexLevel
= r'Level
: (\d
*)'
73 self.response.headers
['Content-Type'
] = 'text
/plain'
74 debug
= self.request.get
('debug'
)
75 s
= self.request.get
('s'
)
76 r
= self.request.get
('r'
)
77 x
= self.request.get
('x'
)
78 y
= self.request.get
('y'
)
79 d
= self.request.get
('d'
)
80 w
= self.request.get
('w'
)
81 path
= self.request.get
('path'
)
84 currents
= Current.all
()
87 urllib.urlopen
(url
+ '
&x=' + x + '&y=' + y + '&path=' + path).read()
94 wrong.l
= currents.fetch
(1)[0].l
97 if s
== '
1' or r
== '
1'
:
98 s
= urllib.urlopen
(url
).read
()
99 x
, y
, board
= re.compile
(regex
).search
(MyHTMLParser
().feed
(s
).get_s
()).groups
()
100 lvl
, = re.compile
(regexLevel
).search
(s
).groups
()
101 db.delete
(Level.all
().fetch
(1000000))
102 db.delete
(Current.all
().fetch
(1000000))
105 level.content
= x
+ '\n'
+ y
+ '\n'
+ board
+ '\n'
109 current.x
= current.y
= current.d
= 0
115 cur
= currents.fetch
(1)[0]
127 wrong
= Wrong
().gql
("WHERE x = :1 AND y = :2 AND d = :3 AND l = :4", cur.x
, cur.y
, cur.d
, cur.l
)
128 if
(wrong.count
(1) == 0):
131 self.response.out.write
(str
(cur.x
) + '\n'
+ str
(cur.y
) + '\n'
+ str
(cur.d
) + '\n'
+ str
(cur.l
) + '\n'
)
132 self.response.out.write
(levels.fetch
(1)[0].content
)
135 self.response.out.write
('\n\n----DEBUG----\n\nwrongs\n'
)
136 wrongs
= Wrong.gql
("WHERE l = :1", cur.l
)
138 self.response.out.write
(str
(wrong.x
) + ' '
+ str
(wrong.y
) + ' '
+ str
(wrong.d
) + ' '
+ str
(wrong.l
) + '\n'
)
140 self.response.out.write
('\ncurrents\n'
)
141 for current in currents
:
142 self.response.out.write
(str
(current.x
) + ' '
+ str
(current.y
) + ' '
+ str
(current.d
) + ' '
+ str
(current.l
) + '\n'
)
144 application
= webapp.WSGIApplication
([('
/'
, MainPage
), ('
/cross'
, CrossPage
)], debug
=True
)
147 run_wsgi_app
(application
)
149 if __name__
== "__main__":
151 ";i:1;s:6:"python
";i:2;N;}i:2;i:108;}i:16;a:2:{i:0;s:6:"plugin
";i:1;a:4:{i:0;s:7:"uparrow
";i:1;a:1:{i:0;s:42:"lib
/plugins
/uparrow
/images
/tango-small.png
";}i:2;i:1;i:3;s:6:"~~
UP~~
";}}i:17;a:3:{i:0;s:13:"section_close
";i:1;a:0:{}i:2;i:4285;}i:18;a:3:{i:0;s:12:"section_edit
";i:1;a:4:{i:0;i:82;i:1;i:0;i:2;i:2;i:3;s:7:"Example
";}i:2;i:4285;}i:19;a:3:{i:0;s:12:"document_end
";i:1;a:0:{}i:2;i:4285;}}