def post(self):

        self.get_current_user()
        if len(self.current_user) == 0:
            self.write(renderMSG('Please LogIn First!!'))
            self.finish()
            return

        d = self.request.arguments
        for x in d: d[x] = d[x][0].decode()

        if self.check_args(d) == False:
            self.write(renderMSG('create fail some arguments miss'))
            self.finish()
            return

        uid = self.get_secure_cookie('uid').decode()
        data = self.getContestData(uid, d)

        if 'error' in data:
            self.write(data['error'])
            self.finish()
            return

        cid = yield self.CreateNewContest(data)

        self.MakePendingContestTempFile(cid, data)

        self.write(renderMSG('create success !!'))
        self.finish()
Beispiel #2
0
    def get(self, *args, **kwargs):

        cid = self.get_argument('cid', -1)
        OJ = self.get_argument('OJ', None)
        Prob = self.get_argument('Prob', None)
        pid = self.get_argument('pid', None)
        self.get_current_user()

        if OJ is None or Prob is None or pid is None:
            self.finish()
            return

        cstatus = -1
        if cid != -1:
            cstatus = yield self.getContestStatus(cid)

        if cstatus == 2:
            self.write(renderMSG('contest {} is end!'.format(cid)))
            self.finish()
            return

        if cstatus == 0:
            self.write(renderMSG('contest {} is not Begin!'.format(cid)))
            self.finish()
            return

        ret = str(self.current_user) + OJ + Prob

        if len(self.current_user) == 0:
            self.write(renderMSG('Please LogIn first!!!'))
            self.finish()
        else:
            self.render('submit.html', OJ=OJ, Prob=Prob, pid=pid, cid=cid)
Beispiel #3
0
    def post(self, *args, **kwargs):

        self.get_current_user()
        pid = self.get_argument('pid', None)
        Prob = self.get_argument('Prob', None)
        lang = self.get_argument('language', None)
        code = self.get_argument('usercode', None)
        oj = self.get_argument('OJ', None)
        cid = self.get_argument('cid', -1)

        if lang is None or len(
                code) == 0 or oj is None or code is None or pid is None:
            self.write(renderMSG('Submit Error!!'))
        else:
            print('lang: ', lang, ' oj: ', oj, ' Prob: ', Prob, ' code ', code,
                  'user: '******'Submit Success!!'))

        self.finish()
    def post(self):

        if self.request.files is not None and len(self.request.files.keys())!=0:
            csv_meta = self.request.files
            content = csv_meta['csv'][0]['body'].decode()
            problemlist = content.split('\n')
            if len(problemlist) > 20 :
                self.write(renderMSG('Too many Problem to Crawler'))
                self.finish()
            else :
                nt = yield self.CrawlerCSV(problemlist)
                self.write(renderMSG('{} problem crawler success'.format(nt)))
                self.finish()
            return

        vj = self.get_argument('VJ',None)
        oj = self.get_argument('oj',None)
        prob = self.get_argument('prob',None)

        if oj is None or vj is None or prob is None or oj == 'ALL' :
            self.finish()
            return


        isok = yield self.CrawlerIt(vj,oj,prob)
        msg = renderMSG('Crawler Success! Visit <a href="/problem/{}/{}">here</a> enjoy it!'.format(oj,prob),waittime=1000000)
        self.write(msg)
        self.finish()
Beispiel #5
0
    def post(self):

        self.get_current_user()
        if len(self.current_user) == 0:
            self.write(renderMSG('Please LogIn First!!'))
            self.finish()
            return

        d = self.request.arguments
        for x in d:
            d[x] = d[x][0].decode()

        if self.check_args(d) == False:
            self.write(renderMSG('create fail some arguments miss'))
            self.finish()
            return

        uid = self.get_secure_cookie('uid').decode()
        data = self.getContestData(uid, d)

        if 'error' in data:
            self.write(data['error'])
            self.finish()
            return

        cid = yield self.CreateNewContest(data)

        self.MakePendingContestTempFile(cid, data)

        self.write(renderMSG('create success !!'))
        self.finish()
    def post(self):

        uid = self.get_argument('uid')
        username = self.get_argument('username')
        password = self.get_argument('password')
        newpassword = self.get_argument('newpassword')
        email = self.get_argument('email')
        school = self.get_argument('school')
        nickname = self.get_argument('nickname')

        # Check Password

        rs = yield self.CheckPasswrod(username=username, password=password)

        if rs[0] == 0:
            self.write(renderMSG('Wrong Password for user {}. Can\'t modify.'.format(username)))
            self.finish()

        # Update user Info
        data = dict()
        data['email'] = email
        data['school'] = school
        data['nickname'] = nickname

        if newpassword is not None and len(newpassword) != 0:
            data['password'] = SHA512(username+'@'+newpassword)

        isOK = yield self.UpdateUserInfo(uid=uid, data=data)

        if isOK == False:
            self.write(renderMSG('Update False!'))
        else:
            self.write(renderMSG('Update Success!'))

        self.finish()
    def get(self, *args, **kwargs):

        cid = self.get_argument('cid', -1)
        OJ = self.get_argument('OJ', None)
        Prob = self.get_argument('Prob', None)
        pid = self.get_argument('pid', None)
        self.get_current_user()

        if OJ is None or Prob is None or pid is None:
            self.finish()
            return

        cstatus = -1
        if cid != -1:
            cstatus = yield self.getContestStatus(cid)

        if cstatus == 2:
            self.write(renderMSG('contest {} is end!'.format(cid)))
            self.finish()
            return

        if cstatus == 0:
            self.write(renderMSG('contest {} is not Begin!'.format(cid)))
            self.finish()
            return

        ret = str(self.current_user) + OJ + Prob

        if len(self.current_user) == 0:
            self.write(renderMSG('Please LogIn first!!!'))
            self.finish()
        else:
            self.render('submit.html', OJ=OJ, Prob=Prob, pid=pid, cid=cid)
Beispiel #8
0
    def get(self):
        self.get_current_user()
        sid = self.get_argument('sid', -1)

        if sid == -1:
            self.write(renderMSG('wrong sid'))
            self.finish()
            return

        rs = yield self.getSubmitData(sid)

        isopen = int(rs[9])

        cid = int(rs[6])
        if cid == -1:
            pass
        else:
            cstatus = yield self.getContestStatus(cid)
            if cstatus <= 1: isopen = 0

        uid = int(rs[10])
        cookie_uid = self.get_secure_cookie('uid', None)
        if isopen == 0:
            if cookie_uid is None:
                pass
            elif int(cookie_uid) == uid:
                isopen = 1

        if isopen == 0:
            self.write(renderMSG('submit not public'))
            self.finish()
            return

        OJ = rs[12]
        Prob = rs[13]
        Code = Base64StrToUTF8Str(rs[8])
        Status = rs[2]
        Timesubmit = rs[1]
        PID = rs[5]
        Author = rs[11]
        language = rs[7]

        self.render('showcode.html',
                    OJ=OJ,
                    Prob=Prob,
                    Code=Code,
                    Status=Status,
                    Timesubmit=Timesubmit,
                    PID=PID,
                    Author=Author,
                    language=language)
    def get(self, oj=None, pid=None):

        cid = self.get_argument('cid', -1)

        print('oj: ' + oj + ' pid: ' + pid)
        D = yield self.getProblem(oj, pid)

        if D is None :
            yield self.CrawlerOnLine(oj,pid)
            D = yield self.getProblem(oj, pid)

        if D is None :
            self.write(renderMSG('Can\'t find this problem',waittime=1000000))
            self.finish()
            return

        clearkeys = list()
        for x in D.keys():
            lenth = len(str(D[x]))
            if lenth == 0 : clearkeys.append(x)

        for x in clearkeys :    del D[x]

        current_user = self.get_secure_cookie('username')
        self.render('problem.html', D=D, current_user=current_user, cid=cid)
    def get(self):
        username = self.get_argument('username')
        rs = yield self.getUserInfo(username)
        if rs is None:
            self.write(renderMSG('Can\'t find user {}'.format(username)))
            self.finish()

        uid = rs[0]
        nickname = rs[2]
        email = str(rs[4])
        school = rs[5]
        urlpart = hashlib.md5(email.lower().encode('utf-8')).hexdigest()

        rs = yield self.getUserACSubmit(username=username)

        rs2 = yield self.getSubmitInfo(uid=uid)

        rankinfo = yield self.getRankInfo(uname=username)
        '''
        submitdata = ''
        for x in rs2 :
            if len(submitdata) != 0 :
                submitdata += ',\n'
            submitdata += '{value:'+str(x[1])+',name:"'+str(x[0])+'"}'
        '''
        submitdata = rs2

        self.get_current_user()
        showpsw = False
        if self.current_user == username : showpsw= True

        self.render("userstatus.html", uid=uid, uname=username,nickname=nickname, email=email, school=school, urlpart=urlpart, rs=rs,
                    submitdata=submitdata,rank=rankinfo,showpsw=showpsw)
Beispiel #11
0
    def get(self, oj=None, pid=None):

        cid = self.get_argument('cid', -1)

        print('oj: ' + oj + ' pid: ' + pid)
        D = yield self.getProblem(oj, pid)

        if D is None:
            yield self.CrawlerOnLine(oj, pid)
            D = yield self.getProblem(oj, pid)

        if D is None:
            self.write(renderMSG('Can\'t find this problem', waittime=1000000))
            self.finish()
            return

        clearkeys = list()
        for x in D.keys():
            lenth = len(str(D[x]))
            if lenth == 0: clearkeys.append(x)

        for x in clearkeys:
            del D[x]

        current_user = self.get_secure_cookie('username')
        self.render('problem.html', D=D, current_user=current_user, cid=cid)
Beispiel #12
0
    def get(self):
        cid = self.get_argument('cid', None)

        uid = self.get_secure_cookie('uid', None)
        if uid is not None: uid = uid.decode()

        contestdetail = yield self.getContestsDetail(cid)
        now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

        cstatus = contestdetail[10]

        if cstatus == 0:
            self.write(renderMSG('Not Start'))
            self.finish()
            return

        rs, ac, totalsubmit, acsubmit, tr = yield self.getProblemList(cid, uid)
        print(contestdetail)

        self.render(
            'contestshow.html',
            begintime=contestdetail[5],
            endtime=contestdetail[6],
            cstatus=contestdetail[10],
            ctitle=contestdetail[1],
            now=now,
            rs=rs,
            cid=cid,
            ac=ac,
            totalsubmit=totalsubmit,
            acsubmit=acsubmit,
            tr=tr,
        )
    def get(self):
        self.get_current_user()
        sid = self.get_argument('sid', -1)

        if sid == -1:
            self.write(renderMSG('wrong sid'))
            self.finish()
            return

        rs = yield self.getSubmitData(sid)


        isopen = int(rs[9])

        cid = int(rs[6])
        if cid == -1 :
            pass
        else :
            cstatus = yield self.getContestStatus(cid)
            if cstatus <= 1 : isopen = 0

        uid = int(rs[10])
        cookie_uid = self.get_secure_cookie('uid', None)
        if isopen == 0:
            if cookie_uid is None:
                pass
            elif int(cookie_uid) == uid:
                isopen = 1


        if isopen == 0:
            self.write(renderMSG('submit not public'))
            self.finish()
            return

        OJ = rs[12]
        Prob = rs[13]
        Code = Base64StrToUTF8Str(rs[8])
        Status = rs[2]
        Timesubmit = rs[1]
        PID = rs[5]
        Author = rs[11]
        language = rs[7]

        self.render('showcode.html', OJ=OJ, Prob=Prob, Code=Code, Status=Status,
                    Timesubmit=Timesubmit, PID=PID, Author=Author, language=language)
    def get(self):
        self.get_current_user()
        if len(self.current_user) == 0:
            self.write(renderMSG('Please LogIn First!!'))
            return
        now = datetime.datetime.now()
        now = now + datetime.timedelta(minutes=10)

        self.render('createcontest.html', year=now.year, hour=now.hour, month=now.month, day=now.day, minute=now.minute)
Beispiel #15
0
    def post(self):

        username = self.get_argument('username', 'None')
        password = self.get_argument('password', 'None')

        print(username, '   ', password)

        if argCheck(username) and argCheck(password):
            isOK = yield self.checkPasswd(username, password)
            if isOK is not None:
                self.set_secure_cookie('username', username)
                print('isOK: ', isOK)
                self.set_secure_cookie('uid', str(isOK))
                self.write(renderMSG(msg='LogIn Success'))
            else:
                self.write(renderMSG(msg='LogIn Fail'))

        self.finish()
Beispiel #16
0
    def post(self):

        username = self.get_argument('username', 'None')
        password = self.get_argument('password', 'None')

        print(username, '   ', password)

        if argCheck(username) and argCheck(password):
            isOK = yield self.checkPasswd(username, password)
            if isOK is not None:
                self.set_secure_cookie('username', username)
                print('isOK: ', isOK)
                self.set_secure_cookie('uid', str(isOK))
                self.write(renderMSG(msg='LogIn Success'))
            else:
                self.write(renderMSG(msg='LogIn Fail'))

        self.finish()
    def post(self, *args, **kwargs):

        self.get_current_user()
        pid = self.get_argument('pid', None)
        Prob = self.get_argument('Prob', None)
        lang = self.get_argument('language', None)
        code = self.get_argument('usercode', None)
        oj = self.get_argument('OJ', None)
        cid = self.get_argument('cid', -1)

        if lang is None or len(code) == 0 or oj is None or code is None or pid is None:
            self.write(renderMSG('Submit Error!!'))
        else:
            print('lang: ', lang, ' oj: ', oj, ' Prob: ', Prob, ' code ', code, 'user: '******'Submit Success!!'))

        self.finish()
    def get(self, *args, **kwargs):
        self.get_current_user()

        if len(self.current_user) == 0:
            self.write(renderMSG('please log in first !!'))
            self.finish()
            return

        uid = self.get_secure_cookie('uid').decode()

        rs = yield self.getContests(uid)

        self.render('managecontestlist.html', rs=rs)
Beispiel #19
0
    def get(self, *args, **kwargs):
        self.get_current_user()

        if len(self.current_user) == 0:
            self.write(renderMSG('please log in first !!'))
            self.finish()
            return

        uid = self.get_secure_cookie('uid').decode()

        rs = yield self.getContests(uid)

        self.render('managecontestlist.html', rs=rs)
Beispiel #20
0
    def get(self):
        self.get_current_user()
        if len(self.current_user) == 0:
            self.write(renderMSG('Please LogIn First!!'))
            return
        now = datetime.datetime.now()
        now = now + datetime.timedelta(minutes=10)

        self.render('createcontest.html',
                    year=now.year,
                    hour=now.hour,
                    month=now.month,
                    day=now.day,
                    minute=now.minute)
Beispiel #21
0
    def post(self):

        uid = self.get_argument('uid')
        username = self.get_argument('username')
        password = self.get_argument('password')
        newpassword = self.get_argument('newpassword')
        email = self.get_argument('email')
        school = self.get_argument('school')
        nickname = self.get_argument('nickname')

        # Check Password

        rs = yield self.CheckPasswrod(username=username, password=password)

        if rs[0] == 0:
            self.write(
                renderMSG('Wrong Password for user {}. Can\'t modify.'.format(
                    username)))
            self.finish()

        # Update user Info
        data = dict()
        data['email'] = email
        data['school'] = school
        data['nickname'] = nickname

        if newpassword is not None and len(newpassword) != 0:
            data['password'] = SHA512(username + '@' + newpassword)

        isOK = yield self.UpdateUserInfo(uid=uid, data=data)

        if isOK == False:
            self.write(renderMSG('Update False!'))
        else:
            self.write(renderMSG('Update Success!'))

        self.finish()
Beispiel #22
0
    def post(self, *args, **kwargs):

        dt = dict()

        dt['username'] = self.get_argument("username", None)
        dt['password'] = self.get_argument("password", None)
        repassword = self.get_argument("repassword", None)
        dt['email'] = self.get_argument("email", None)
        dt['school'] = self.get_argument('school', None)
        dt['localstatus'] = 0

        if dt['password'] != repassword:
            self.render('register.html')
        else:
            ret = yield self.AddUser(dt)
            if ret == 1:
                ''' success '''
                self.write(renderMSG('Regiest Success!!'))
                self.finish()
            else:
                ''' fail '''
                self.write(renderMSG('Regiest Fail !!!'))
                self.finish()
                return
    def post(self, *args, **kwargs):

        dt = dict()

        dt['username'] = self.get_argument("username", None)
        dt['password'] = self.get_argument("password", None)
        repassword = self.get_argument("repassword", None)
        dt['email'] = self.get_argument("email", None)
        dt['school'] = self.get_argument('school', None)
        dt['localstatus'] = 0

        if dt['password'] != repassword:
            self.render('register.html')
        else:
            ret = yield self.AddUser(dt)
            if ret == 1:
                ''' success '''
                self.write(renderMSG('Regiest Success!!'))
                self.finish()
            else:
                ''' fail '''
                self.write(renderMSG('Regiest Fail !!!'))
                self.finish()
                return
Beispiel #24
0
    def get(self):
        username = self.get_argument('username')
        rs = yield self.getUserInfo(username)
        if rs is None:
            self.write(renderMSG('Can\'t find user {}'.format(username)))
            self.finish()

        uid = rs[0]
        nickname = rs[2]
        email = str(rs[4])
        school = rs[5]
        urlpart = hashlib.md5(email.lower().encode('utf-8')).hexdigest()

        rs = yield self.getUserACSubmit(username=username)

        rs2 = yield self.getSubmitInfo(uid=uid)

        rankinfo = yield self.getRankInfo(uname=username)
        '''
        submitdata = ''
        for x in rs2 :
            if len(submitdata) != 0 :
                submitdata += ',\n'
            submitdata += '{value:'+str(x[1])+',name:"'+str(x[0])+'"}'
        '''
        submitdata = rs2

        self.get_current_user()
        showpsw = False
        if self.current_user == username: showpsw = True

        self.render("userstatus.html",
                    uid=uid,
                    uname=username,
                    nickname=nickname,
                    email=email,
                    school=school,
                    urlpart=urlpart,
                    rs=rs,
                    submitdata=submitdata,
                    rank=rankinfo,
                    showpsw=showpsw)
    def get(self):

        cid = self.get_argument('cid', -1)

        if cid == -1:
            self.write(renderMSG('wrong contest id'))
            self.finish()

        contestInfo = yield self.getContestInfo(cid)
        now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

        statusdata = yield self.getStatusInfo(cid)
        problemlist = yield self.getProblemList(cid)
        begintime = contestInfo[5]
        ranklist = yield self.CaluRankList(begintime, statusdata, problemlist)

        self.render('ranklist.html',
                    ctitle=contestInfo[1], begintime=contestInfo[5], endtime=contestInfo[6],
                    now=str(now), cstatus=contestInfo[10], cid=cid, ranklist=ranklist
                    )
    def get(self):
        cid = self.get_argument('cid', None)

        uid = self.get_secure_cookie('uid',None)
        if uid is not None : uid = uid.decode()

        contestdetail = yield self.getContestsDetail(cid)
        now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

        cstatus = contestdetail[10]

        if cstatus == 0:
            self.write(renderMSG('Not Start'))
            self.finish()
            return

        rs,ac,totalsubmit,acsubmit,tr = yield self.getProblemList(cid,uid)
        print(contestdetail)

        self.render('contestshow.html',
                    begintime=contestdetail[5], endtime=contestdetail[6],
                    cstatus=contestdetail[10], ctitle=contestdetail[1],
                    now=now, rs=rs, cid=cid,ac=ac,totalsubmit=totalsubmit,acsubmit=acsubmit,tr=tr,
                    )
    def get(self):

        cid = self.get_argument('cid', -1)

        if cid == -1:
            self.write(renderMSG('wrong contest id'))
            self.finish()

        contestInfo = yield self.getContestInfo(cid)
        now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

        statusdata = yield self.getStatusInfo(cid)
        problemlist = yield self.getProblemList(cid)
        begintime = contestInfo[5]
        ranklist = yield self.CaluRankList(begintime, statusdata, problemlist)

        self.render('ranklist.html',
                    ctitle=contestInfo[1],
                    begintime=contestInfo[5],
                    endtime=contestInfo[6],
                    now=str(now),
                    cstatus=contestInfo[10],
                    cid=cid,
                    ranklist=ranklist)
    def post(self):

        action = self.get_argument('action', None)

        if action is None:
            self.write(renderMSG('Error Manage Operation!!'))
            self.finish()
            return

        if action == 'updateproblem':

            cid = self.get_argument('cid', None)
            txt = self.get_argument('problemlist', None)

            if cid is None:
                self.write(renderMSG('Wrong CID'))
                self.finish()
                return

            CD = yield self.getContestDetail(cid)
            cstatus = CD[10]

            if cstatus == 1 or cstatus == 2:
                self.write(renderMSG('Contest is frost can\'t modify'))
                self.finish()
                return

            problemlist = self.getProblem(txt)

            log = yield self.UpdateProblem(cid, problemlist)

            self.write(renderMSG(log))
            self.finish()
            return

        elif action == 'updatedetail':

            d = self.request.arguments
            for x in d: d[x] = d[x][0].decode()
            cid = d['cid']

            if self.check_args(d) == False:
                self.write(renderMSG('create fail some arguments miss'))
                self.finish()
                return

            uid = self.get_secure_cookie('uid').decode()
            data = self.getContestData(uid, d)

            if 'error' in data:
                self.write(renderMSG(data['error']))
                self.finish()
                return

            CD = yield self.getContestDetail(cid)
            cstatus = CD[10]

            if cstatus == 1 or cstatus == 2:
                self.write(renderMSG('Contest is frost can\'t modify'))
                self.finish()
                return

            yield self.updateContestDetail(cid, data)
            self.MakePendingContestTempFile(cid, data)

            self.write(renderMSG('Update Success'))
            self.finish()
            return

        elif action=='delete' :
            cid = self.get_argument('cid', None)

            if cid is None:
                self.write(renderMSG('Wrong CID'))
                self.finish()
                return

            yield  self.DeleteContest(cid)

            self.write(renderMSG('Delete Success!'))
            self.finish()
    def get(self, *args, **kwargs):

        action = self.get_argument('action')
        cid = self.get_argument('cid')

        if action == 'modify':
            # modify contest
            rs = yield self.getContestDetail(cid)
            d1 = rs[5]
            d2 = rs[6]
            dt = d2 - d1

            '''
            print(rs)
            print(d1.year,d1.month,d1.day,d1.hour,d1.minute)
            print(dt.days,dt.seconds)
            mm,ss = divmod(dt.seconds,60)
            hh,mm = divmod(mm,60)
            print(hh,mm,ss)
            '''

            lday = dt.days
            lmm, lss = divmod(dt.seconds, 60)
            lhh, lmm = divmod(lmm, 60)

            contesttype = int(rs[8])

            password = ''

            check1 = 'checked'
            check2 = ''

            if contesttype == 1:
                password = rs[4]
                check1 = ''
                check2 = "checked"

            ctitle = rs[1]
            cdescription = rs[2]

            problemlist = yield self.getContestProblem(cid)
            problemlisttxt = self.getProblemTxt(problemlist)

            self.render('contestdetail.html',
                        cid=cid,
                        check1=check1, check2=check2,
                        ctitle=ctitle, cdescription=cdescription,
                        year=d1.year, month=d1.month, day=d1.day, hour=d1.hour, minute=d1.minute,
                        lday=lday, lhour=lhh, lminute=lmm, lsecond=lss, password=password,
                        problemlist=problemlist, problemlisttxt=problemlisttxt
                        )


        elif action == 'delete':

            if cid is None:
                self.write(renderMSG('Wrong CID'))
                self.finish()
                return

            flag = yield  self.DeleteContest(cid)

            if flag == True :
                self.write(renderMSG('Delete Success!'))
            else :
                self.write(renderMSG('Can\'t delete'))

            self.finish()
Beispiel #30
0
 def post(self, *args, **kwargs):
     self.set_secure_cookie('username', '', 0)
     self.set_secure_cookie('uid', '', 0)
     self.write(renderMSG('LogOut Success'))