コード例 #1
0
ファイル: index.py プロジェクト: lyzhanghai/sxuhelp
 def post(self, *args, **kwargs):
     captcha = get_cleaned_post_data(self, ['captcha'])['captcha']
     if self.get_login_cookie(self.current_user, captcha):
         return
     if self.get_myscore(self.current_user):
         return
     return
コード例 #2
0
ファイル: cethandler.py プロジェクト: lyzhanghai/sxuhelp
 def post(self, province, school, *args, **kwargs):
     #判断学校是否在授权列表中
     if school not in config.school_pro:
         #self.write("School not in Pro")
         #return
         pass
     post_data=get_cleaned_post_data(self,['username','cet_type',])
     g=CetTicket.find_ticket_number(int(province),school,post_data['username'],cet_type=int(post_data['cet_type']))
     resp=yield next(g)
     try:
         g.send(resp)
     except Exception as e:
         ticket=e.value
     if ticket:
         g=CetTicket.get_score(ticket, post_data['username'])
         resp=yield next(g)
         try:
             g.send(resp)
         # 触发生成器StopIteration
         except StopIteration as e:
             result=e.value
             if result:
                 r = result
     self.write(json.dumps(r))
     return
コード例 #3
0
ファイル: cethandler.py プロジェクト: lyzhanghai/sxuhelp
 def post(self, *args, **kwargs):
     post_data=get_cleaned_post_data(self,['username','ticket',])
     #在不破坏逻辑的状况下异步调用函数
     g=CetTicket.get_score(post_data['ticket'],post_data['username'])
     resp=yield next(g)
     try:
         result=g.send(resp)
     except StopIteration as e:
         result=e.value
         if result:
             r=result
     self.write(json.dumps(r))
コード例 #4
0
ファイル: index.py プロジェクト: lyzhanghai/sxuhelp
 def post(self, *args, **kwargs):
     post_data = get_cleaned_post_data(self, ['username', 'password'])
     #try:
     #    post_data=get_cleaned_post_data(self,['username','password'])
     #except RequestArgumentError as e:
     #    self.write(json_result(e.code,e.msg))
     #    return
     user = User.auth(post_data['username'], post_data['password'])
     if user:
         self.set_secure_cookie('uuid', user.username)
         result = json_result(0, 'login success!')
         self.redirect('/')
     else:
         result = json_result(-1, 'login failed!')
         self.redirect('/login')
コード例 #5
0
 def post(self, *args, **kwargs):
     post_data=get_cleaned_post_data(self,['username','password'])
     #try:
     #    post_data=get_cleaned_post_data(self,['username','password'])
     #except RequestArgumentError as e:
     #    self.write(json_result(e.code,e.msg))
     #    return
     user=User.auth(post_data['username'],post_data['password'])
     if user:
         self.set_secure_cookie('uuid',user.username)
         result=json_result(0,'login success!')
         self.redirect('/')
     else:
         result=json_result(-1,'login failed!')
         self.redirect('/login')
コード例 #6
0
ファイル: cethandler.py プロジェクト: lyzhanghai/sxuhelp
 def post(self, *args, **kwargs):
     post_data=get_cleaned_post_data(self,['username','province','school','cet_type',])
     g=CetTicket.find_ticket_number(int(post_data['province']),post_data['school'],post_data['username'],cet_type=int(post_data['cet_type']))
     resp=yield next(g)
     try:
         g.send(resp)
     except Exception as e:
         ticket=e.value
     if ticket:
         g=CetTicket.get_score(ticket, post_data['username'])
         resp=yield next(g)
         try:
             result=g.send(resp)
         # 触发生成器StopIteration
         except StopIteration as e:
             result=e.value
             if result:
                 r=result
     self.write(json.dumps(r))
コード例 #7
0
ファイル: index.py プロジェクト: lyzhanghai/sxuhelp
    def post_old(self, *args, **kwargs):
        post_data = get_cleaned_post_data(self, ['stuid', 'passwd', 'stutype'])
        #stuid = '2012241004'
        stuid = post_data['stuid']
        #passwd = 'qwaszx'
        passwd = post_data['passwd']
        stutype = post_data['stutype']
        openid = get_cleaned_query_data(self, ['openid'])['openid']

        data = {
            'Login.Token1': stuid,
            'Login.Token2': passwd,
        }
        response = requests.post(
            'http://myportal.sxu.edu.cn/userPasswordValidate.portal',
            data=data,
            headers={
                'Host': 'myportal.sxu.edu.cn',
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            #proxies = {'http': 'http://127.0.0.1:8080'}
        )
        if 'handleLoginSuccessed' not in response.text:
            self.write(json_result(1, '用户名密码验证失败'))
            return
        iPlanetDirectoryPro = response.cookies.get('iPlanetDirectoryPro')
        response = requests.get(
            'http://stuach.sxu.edu.cn/student/caslogin.asp',
            allow_redirects=False,
            headers={
                'Host': 'stuach.sxu.edu.cn',
                'User-Agent': ''
            },
            cookies={'iPlanetDirectoryPro': iPlanetDirectoryPro},
            #proxies = {'http': 'http://127.0.0.1:8080'}
        )

        ASPSESSIONIDACRRADAD = response.cookies.get('ASPSESSIONIDACRRADAD')
        response = requests.get(
            'http://stuach.sxu.edu.cn/student/studentinfo.asp',
            headers={
                'Host': 'stuach.sxu.edu.cn',
                'User-Agent': ''
            },
            cookies={'ASPSESSIONIDACRRADAD': ASPSESSIONIDACRRADAD},
            #proxies = {'http': 'http://127.0.0.1:8080'}
        )
        stuname, stumajor = find_stu_info_old(
            response.content.decode('gb2312', 'ignore'))
        temp_user = User.get_by_openid(openid)
        if temp_user:
            temp_user.openid = temp_user.openid + '_d'
            temp_user.save()
        User.new(stuid, stuname, stumajor, passwd, stutype, openid, 'test')
        self.write(
            json_result(0, {
                'stuid': stuid,
                'stuname': stuname,
                'stumajor': stumajor
            }))
        return
コード例 #8
0
ファイル: index.py プロジェクト: lyzhanghai/sxuhelp
 def post(self, *args, **kwargs):
     stutype = get_cleaned_post_data(self, ['stutype'])['stutype']
     if int(stutype) == 1:
         self.post_new(*args, **kwargs)
     else:
         self.post_old(*args, **kwargs)
コード例 #9
0
ファイル: index.py プロジェクト: lyzhanghai/sxuhelp
    def post_new(self, *args, **kwargs):
        #stuid = self.get_body_argument('stuid')
        #passwd = self.get_body_argument('passwd')
        post_data = get_cleaned_post_data(
            self, ['stuid', 'passwd', 'captcha', 'stutype'])
        captcha = post_data['captcha']
        #stuid = '201502401037'
        stuid = post_data['stuid']
        #passwd = '622307'
        passwd = post_data['passwd']
        stutype = post_data['stutype']
        openid = get_cleaned_query_data(self, ['openid'])['openid']
        passwd_encrpyt, captcha_encrpt = get_encrypt_code(
            stuid, passwd, captcha)
        cookies = {'ASP.NET_SessionId': self.get_cookie('ASP.NET_SessionId')}
        data = {
            '__VIEWSTATE': self.get_cookie('ViewState'),
            'pcInfo':
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko/20100101 Firefox/47.0Intel Mac OS X 10.115.0 (Macintosh) SN:NULL',
            'txt_asmcdefsddsd': stuid,
            # 密码密文
            'dsdsdsdsdxcxdfgfg': passwd_encrpyt,
            # 验证码
            'fgfggfdgtyuuyyuuckjg': captcha_encrpt,
            'Sel_Type': 'STU',
            'typeName': '学生'
        }

        response = requests.post(
            'http://bkjw.sxu.edu.cn/_data/login.aspx',
            data=data,
            cookies=cookies,
            headers={
                'Host': 'bkjw.sxu.edu.cn',
                'Referer': 'http://bkjw.sxu.edu.cn/_data/login.aspx'
            },
            #proxies = {'http': 'http://127.0.0.1:8080'}
        )
        if '帐号或密码不正确' in response.text:
            self.write(json_result(1, '账号或密码不正确'))
            return
        elif '验证码错误' in response.text:
            self.write(json_result(1, '验证码错误'))
            return
        elif '权限' not in response.text:
            self.write(json_result(1, '未知错误'))
            return

        response = requests.get(
            'http://bkjw.sxu.edu.cn/xsxj/Stu_MyInfo_RPT.aspx',
            cookies=cookies,
            headers={
                'Host': 'bkjw.sxu.edu.cn',
                'Referer': 'http://bkjw.sxu.edu.cn/xsxj/Stu_MyInfo.aspx'
            },
            #proxies = {'http': 'http://127.0.0.1:8080'}
        )

        stuid, stuname, stumajor = get_stu_info(response.text)
        temp_user = User.get_by_openid(openid)
        if temp_user:
            temp_user.openid = temp_user.openid + '_d'
            temp_user.save()
        User.new(stuid, stuname, stumajor, passwd, stutype, openid, 'test')
        self.write(
            json_result(0, {
                'stuid': stuid,
                'stuname': stuname,
                'stumajor': stumajor
            }))
        return