Esempio n. 1
0
def add_new_video():
    usr = request.cookies.get('usr')
    uid = request.cookies.get('uid')
    title = request.form['title']
    link = request.form['link']
    ifr = request.form['ifr']
    com = request.form['comment']
    if check_uid(usr, uid) and check_admin(usr):
        insert_video(title, link, ifr, com, usr)
    return redirect(url_for('manage.manage_video'))
Esempio n. 2
0
def check_login():
    usr = request.cookies.get('usr')
    uid = request.cookies.get('uid')
    if usr is None or uid is None:
        return 0
    else:
        try:
            b = check_admin(usr)
        except:
            return 0
        if b:
            return 2
        else:
            return 1
Esempio n. 3
0
def manage_index():
    usr = request.cookies.get('usr')
    uid = request.cookies.get('uid')
    if check_uid(usr, uid):
        if check_admin(usr):
            lines = count_comments()
            datas = get_comments(0, lines)
            return render_template("manage/manage_com.html",
                                   usr=usr,
                                   uid=uid,
                                   datas=datas)
        else:
            return redirect(url_for('main_index'))
    else:
        return redirect(url_for("login.login_index"))
Esempio n. 4
0
def clarify_usrpwd():
    usr = request.form['username']
    pwd = request.form['passwd']
    try:
        if check_usrpwd(usr, pwd):
            uid = get_uid()
            insert_uid(usr, uid)
            if check_admin(usr):
                resp = make_response(redirect(url_for('manage.manage_index')))
                resp.set_cookie('usr', usr)
                resp.set_cookie('uid', uid)
                return resp
            else:
                resp = redirect('/comment')
                resp.set_cookie('usr', usr)
                resp.set_cookie('uid', uid)
                return resp
    except UsernameNotExists:
        err_id = 1
    except WrongPassword:
        err_id = 2
    return redirect(url_for('login.login_index', err_id=err_id))