Exemple #1
0
def pic_gallery():
    alerts = generateAlerts()
    user_data = sec.getUserSession()
    imageGallery = db.getImageDetails()
    cfg.debug(imageGallery,True)

    return render_template(cfg.gallery_page, title="Minecraft Gallery", u=user_data, i=imageGallery, a=alerts)
Exemple #2
0
def home():
    rule = request.url_rule

    sec.generateAppKeys()

    if 'logout' in rule.rule:
        sec.clearSession()
        user_data = user.clearUserData()
        sec.setSessionVar(sec.user_data_key, user_data)

    if sec.getSessionVar(sec.user_data_key) == False:
        user_data = user.clearUserData()
        sec.setSessionVar(sec.user_data_key, user_data)

    user_data = sec.getUserSession()


    cfg.debug(f">>>>>>USERDATA {user_data}",True)




    alerts = generateAlerts()
    server_data = getMCServerData()
    projects = getProjectData()
    return render_template(cfg.dashboard_page, title="Dashboard", a=alerts, u=user_data, s=server_data,p=projects)
Exemple #3
0
def errorpage(error):
    alerts = generateAlerts()
    user_data = sec.getUserSession()
    errorMsg = "404"
    if "500" in f"{error}":
        errorMsg = "500"#

    return render_template('404.html', title="SOMETHING WENt WRONG - OUCH", errorshort=errorMsg, error=error, u=user_data, a=alerts)
Exemple #4
0
def admin_page():
    user_data = sec.getUserSession()
    if user_data['role'] not in cfg.ADMIN_ROLES or user_data['loggedIn'] == False:
        return redirect("/")

    alerts = generateAlerts()

    return render_template(cfg.admin_page, u=user_data, a=alerts)
Exemple #5
0
def contact_action():
    alerts = generateAlerts()
    user_data = sec.getUserSession()
    title = "Thank you for contacting us"
    message = {
        "heading": "Thank you",
        "message": "We will respond to your message shortly."
    }

    return render_template(cfg.contact_action_page, title=title, msg=message, u=user_data, a=alerts)
Exemple #6
0
def profile_page(uid=""):

    rule  = request.url_rule.rule


    user_data= sec.getUserSession()

    alerts = generateAlerts()
    if request.method == 'POST' and "update" in rule:

        # get formdata s
        cfg.debug("UPDATING PROFILE ",True)
        pwd = request.form['new_pwd']
        name = request.form['mcUsername']
        if request.form['orig_mc'] != name or pwd != "":
            sql = "UPDATE members set minecraftName = ? , pic = ?"
            if pwd.strip() != "":
                sql = sql + f", password = {pwd}"
            sql = sql + " where memberId = " + request.form['uid']

            pic = f"https://minotar.net/helm/{name}/50.png"

            data = (name, pic)

            cfg.debug(sql,True)
            cfg.debug(data,True)
            conn = create_connection(cfg.DB)
            cur = conn.cursor()
            cur.execute(sql,data)
            conn.commit()
            conn.close()

            user_data['mcUsername'] = name
            user_data['pic'] = pic

            sec.setSessionVar(sec.user_data_key,user_data)


        return render_template(cfg.profile_page, a=alerts, u=user_data)



    if uid == "" or user_data['loggedIn'] == False or uid != user_data['mcUsername']:
        cfg.debug(f"REDIRECTING FROM MEMBERS UPADTE uid: {uid} loggedIn: {user_data['loggedIn']} id: {user_data['id']}",True)
        return redirect("/")

    # display normal profile page

    return render_template(cfg.profile_page, a=alerts, u=user_data)
Exemple #7
0
def alerts():
    user_data = sec.getUserSession()
    alerts = generateAlerts()
    if request.method == "POST":
        rule = request.url_rule

        if "edit" in rule.rule:
            print("EDIT")


            alertIds = []
            for i in alerts:
                # print(i)
                alertIds.append(i['id'])

            for i in alertIds:
                '''
                alert_sub_1
                alert_sub_orig_1
                alert_txt_1
                alert_txt_orig_1
                '''

                txt_key = f'alert_txt_{i}'
                sub_key = f'alert_sub_{i}'
                orig_txt_key = f'alert_txt_orig_{i}'
                orig_sub_key = f'alert_sub_orig_{i}'
                del_key = f'alert_del_{i}'

                new_txt = request.form[txt_key]
                new_sub = request.form[sub_key]
                orig_txt = request.form[orig_txt_key]
                orig_sub = request.form[orig_sub_key]
                try:
                    delme = request.form[del_key]
                except KeyError as e:
                    delme = False

                if new_sub != orig_sub or new_txt != orig_txt or delme != False:
                    print(f"UPDATE {i}")
                    #print(f"{new_txt} | {orig_txt} | {new_sub} | {orig_sub} | >{delme}< |")
                    sql = ""
                    data = ()
                    if delme == "on":
                        sql = "DELETE FROM messages where id = ?"
                        data = (i,)
                    else:
                        sql = "UPDATE messages set 'subject' = ?, 'message' = ? where id = ?"
                        data = (new_sub, new_txt, i)

                    conn = create_connection(cfg.DB)
                    cur = conn.cursor()
                    cur.execute(sql,data)
                    conn.commit()

            return redirect("/alerts")


        # edit

        if "add" in rule.rule:
            # add
            alert_subject = request.form["new_alert_subject"]
            alert_txt = request.form["new_alert_txt"]
            icon = request.form["new_alert_icon"]

            now = date.today().strftime("%Y-%m-%d")
            sql = f"INSERT INTO MESSAGES ('type', 'from', 'subject', 'message', 'icon', 'date') "\
                    f"VALUES (?,?,?,?,?,?)"
            conn = create_connection(cfg.DB)
            cur = conn.cursor()
            data = ("alert", user_data['id'],alert_subject, alert_txt, icon, now)

            cur.execute(sql,data)
            conn.commit()
            return redirect("/alerts")

    else:
        user_data = sec.getUserSession()

        iconList = generateIconList()
        print(iconList)
        if sec.isLoggedIn():

            return render_template(cfg.adm_alerts_page, u=user_data,a=alerts, title="Admin - Alerts", icons=iconList)
Exemple #8
0
def register():
    alerts = generateAlerts()
    user_data = sec.getUserSession()

    return render_template(cfg.register_page, title="Register", a=alerts, u=user_data)
Exemple #9
0
def contact():
    alerts = generateAlerts()
    user_data = sec.getUserSession()
    cfg.debug(f"Alerts: {alerts}", True)
    return render_template(cfg.contact_page, title="Contact us", u=user_data, a=alerts)
Exemple #10
0
def members_page():
    user_data= sec.getUserSession()
    memberList = db.getMemberList()
    alerts = generateAlerts()
    return render_template(cfg.members_page, title="Members List", u=user_data, ml=memberList, a=alerts)