Ejemplo n.º 1
0
def update():
    stuid = session.get('stuid')
    if not stuid:
        return redirect(url_for('login'))
    newphone = request.form.get('newphone', '').strip()
    complaint = None

    visit_ip = session.get('vip')
    f = open('block-ip.txt', 'r')
    getip = f.read()
    bye_ip_list = getip.split()
    f.close()
    if checkip(bye_ip_list, visit_ip):
        abort(403)

    if request.method == 'POST':
        if newphone:
            db = bank.open_database()
            msg = ''
            if checkdigit(newphone):
                bank.update_info(db, newphone, stuid)
                db.commit()
                msg = 'Update successful'
                logfile = open('logfile.txt', 'a')
                get_current_time = datetime.datetime.now()
                logfile.write(
                    str(get_current_time) + ' - ' + stuid +
                    ' update phone info with ' + newphone + '\n')
                logfile.close()
            else:
                msg = 'Update failure, please check your phone format'
                logfile = open('logfile.txt', 'a')
                get_current_time = datetime.datetime.now()
                logfile.write(
                    str(get_current_time) + ' - ' + stuid +
                    ' update failure with wrong format ' + newphone + '\n')
                logfile.close()
            #==============================
            stuid = session.get('stuid')
            if not stuid:
                return redirect(url_for('login'))
            db = bank.open_database()
            cla = bank.get_cla(db, stuid)
            username = bank.get_name(db, stuid)
            userlist = bank.showlist(db, cla)
            #==============================
            return render_template('index.html',
                                   username=username,
                                   cla=cla,
                                   userlist=userlist,
                                   sqlmsg=msg)
    return render_template('update.html')
Ejemplo n.º 2
0
def update():
    stuid = session.get("stuid")
    if not stuid:
        return redirect(url_for("login"))
    newphone = request.form.get("newphone", "").strip()
    complaint = None

    visit_ip = session.get("vip")
    f = open("block-ip.txt", "r")
    getip = f.read()
    bye_ip_list = getip.split()
    f.close()
    if checkip(bye_ip_list, visit_ip):
        abort(403)

    if request.method == "POST":
        if newphone:
            db = bank.open_database()
            msg = ""
            if checkdigit(newphone):
                bank.update_info(db, newphone, stuid)
                db.commit()
                msg = "Update successful"
                logfile = open("logfile.txt", "a")
                get_current_time = datetime.datetime.now()
                logfile.write(str(get_current_time) + " - " + stuid + " update phone info with " + newphone + "\n")
                logfile.close()
            else:
                msg = "Update failure, please check your phone format"
                logfile = open("logfile.txt", "a")
                get_current_time = datetime.datetime.now()
                logfile.write(
                    str(get_current_time) + " - " + stuid + " update failure with wrong format " + newphone + "\n"
                )
                logfile.close()
            # ==============================
            stuid = session.get("stuid")
            if not stuid:
                return redirect(url_for("login"))
            db = bank.open_database()
            cla = bank.get_cla(db, stuid)
            username = bank.get_name(db, stuid)
            userlist = bank.showlist(db, cla)
            # ==============================
            return render_template("index.html", username=username, cla=cla, userlist=userlist, sqlmsg=msg)
    return render_template("update.html")
Ejemplo n.º 3
0
def index():
    stuid = session.get("stuid")
    if not stuid:
        return redirect(url_for("login"))

    visit_ip = session.get("vip")
    f = open("block-ip.txt", "r")
    getip = f.read()
    bye_ip_list = getip.split()
    f.close()
    if checkip(bye_ip_list, visit_ip):
        abort(403)

    db = bank.open_database()
    cla = bank.get_cla(db, stuid)
    username = bank.get_name(db, stuid)
    userlist = bank.showlist(db, cla)
    return render_template("index.html", username=username, cla=cla, userlist=userlist)
Ejemplo n.º 4
0
def index():
    stuid = session.get('stuid')
    if not stuid:
        return redirect(url_for('login'))

    visit_ip = session.get('vip')
    f = open('block-ip.txt', 'r')
    getip = f.read()
    bye_ip_list = getip.split()
    f.close()
    if checkip(bye_ip_list, visit_ip):
        abort(403)

    db = bank.open_database()
    cla = bank.get_cla(db, stuid)
    username = bank.get_name(db, stuid)
    userlist = bank.showlist(db, cla)
    return render_template('index.html',
                           username=username,
                           cla=cla,
                           userlist=userlist)