annotate pyikriam/createAccount.py @ 369:fb3cfa5533ac

merged
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Thu, 05 Mar 2009 17:36:03 +0800
parents c0b9604b0be9
children
rev   line source
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
1 import urllib2,urllib
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
2 import libgmail,email,string,time
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
3 from ikariam import fake_moz
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
4 from lazy.www import c
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
5
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
6 class CreateAccount:
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
7 """
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
8 For create sheep to cheat. take care of the ip address & email check by yourself.
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
9 """
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
10 def __init__(self,account,password,server):
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
11 self.account=account
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
12 self.password=password
231
c0b9604b0be9 the currect version of last bug fix
kevin@tombear.tombears.com
parents: 228
diff changeset
13 if len(self.password)<8:
c0b9604b0be9 the currect version of last bug fix
kevin@tombear.tombears.com
parents: 228
diff changeset
14 print 'Password size mast bigger then 8 chars'
c0b9604b0be9 the currect version of last bug fix
kevin@tombear.tombears.com
parents: 228
diff changeset
15 pass
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
16 self.server=server
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
17 headers=[('Referer','http://'+self.server[self.server.find('.')+1:]+'/register.php')]
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
18 self.browser = fake_moz(headers)
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
19 urllib2.install_opener(self.browser)
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
20 pass
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
21
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
22 def ca(self):
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
23 self.baseurl='http://'+self.server
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
24 params = {
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
25 "function":"createAvatar",\
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
26 "name":self.account,\
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
27 "email":self.account+"@ossug.org",\
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
28 "password":self.password,\
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
29 "agb":"on"}
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
30 self.ret=c(self.baseurl+'/index.php?action=newPlayer').get(params).get_content()
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
31 print "Waiting for 30 seconds to get confirme..."
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
32 time.sleep(30)
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
33 confirme(self.account).run()
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
34 pass
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
35
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
36 class confirme:
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
37 def __init__(self,account):
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
38 self.account=account
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
39 self.browser = fake_moz()
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
40 urllib2.install_opener(self.browser)
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
41 pass
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
42
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
43 def run(self):
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
44 print "Start get confirme url..."
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
45 ga = libgmail.GmailAccount("gmp3fs@gmail.com", "ossug.org")
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
46 ga.login()
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
47 folder = ga.getMessagesByFolder('inbox')
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
48
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
49 for thread in folder:
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
50 #thread.id, len(thread), thread.subject
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
51 account=string.split(thread.subject)[0]
231
c0b9604b0be9 the currect version of last bug fix
kevin@tombear.tombears.com
parents: 228
diff changeset
52 acsize=len(self.account)
c0b9604b0be9 the currect version of last bug fix
kevin@tombear.tombears.com
parents: 228
diff changeset
53 if account[-acsize:]==self.account:
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
54 print "find "+account
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
55 for msg in thread:
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
56 mmsg=email.message_from_string(msg.source)
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
57 confcontext=mmsg.get_payload(decode = True)
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
58 for x in string.split(confcontext):
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
59 if x[0:7]=='http://':
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
60 confurl=x
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
61 break
231
c0b9604b0be9 the currect version of last bug fix
kevin@tombear.tombears.com
parents: 228
diff changeset
62 print "send confirme."
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
63 self.ret=c(confurl).get().get_content()
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
64 pass
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
65
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
66 def rename(self):
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
67 """
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
68 http://s4.ikariam.tw/index.php?view=renameCity&id=6079&position=0
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
69 <input class="textfield" id="newCityName" name="name" size="30" maxlength="15" type="text">
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
70 <input class="button" value="" type="submit">
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
71 """
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
72
231
c0b9604b0be9 the currect version of last bug fix
kevin@tombear.tombears.com
parents: 228
diff changeset
73 ikariamca=CreateAccount('jdanny','taaaa123','s4.ikariam.tw')
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
74 a=ikariamca.ca()
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
75