view pyikriam/createAccount.py @ 328:6782280a886b

merged
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Thu, 12 Feb 2009 01:19:27 +0800
parents c0b9604b0be9
children
line wrap: on
line source

import urllib2,urllib
import libgmail,email,string,time
from ikariam import fake_moz
from lazy.www import c

class CreateAccount:
    """
    For create sheep to cheat. take care of the ip address & email check by yourself.
    """
    def __init__(self,account,password,server):
        self.account=account
        self.password=password
        if len(self.password)<8:
            print 'Password size mast bigger then 8 chars'
            pass
        self.server=server
        headers=[('Referer','http://'+self.server[self.server.find('.')+1:]+'/register.php')]
        self.browser = fake_moz(headers)
        urllib2.install_opener(self.browser)
        pass

    def ca(self):
        self.baseurl='http://'+self.server
        params = {
        "function":"createAvatar",\
        "name":self.account,\
        "email":self.account+"@ossug.org",\
        "password":self.password,\
        "agb":"on"}
        self.ret=c(self.baseurl+'/index.php?action=newPlayer').get(params).get_content()
        print "Waiting for 30 seconds to get confirme..."
        time.sleep(30)
        confirme(self.account).run()
        pass

class confirme:
    def __init__(self,account):
        self.account=account
        self.browser = fake_moz()
        urllib2.install_opener(self.browser)
        pass

    def run(self):
        print "Start get confirme url..."
        ga = libgmail.GmailAccount("gmp3fs@gmail.com", "ossug.org")
        ga.login()
        folder = ga.getMessagesByFolder('inbox')

        for thread in folder:
            #thread.id, len(thread), thread.subject
            account=string.split(thread.subject)[0]
            acsize=len(self.account)
            if account[-acsize:]==self.account:
                print "find "+account
                for msg in thread:
                    mmsg=email.message_from_string(msg.source)
                    confcontext=mmsg.get_payload(decode = True)
                    for x in string.split(confcontext):
                        if x[0:7]=='http://':
                            confurl=x
                            break
        print "send confirme."
        self.ret=c(confurl).get().get_content()
        pass

    def rename(self):
        """
        http://s4.ikariam.tw/index.php?view=renameCity&id=6079&position=0
        <input class="textfield" id="newCityName" name="name" size="30" maxlength="15" type="text">
        <input class="button" value="" type="submit">
        """

ikariamca=CreateAccount('jdanny','taaaa123','s4.ikariam.tw')
a=ikariamca.ca()