Example #1
0
def paste(paste):
    getPaste = d2_paste.query.filter(d2_paste.paste_id == paste).first()
    subheading = ['<a href="/pastebin/">Pastebin</a>']
    if getPaste:
        return syndbb.render_template('pastebin.html', paste=getPaste, title="" + getPaste.title, subheading=subheading)
    else:
        return syndbb.render_template('invalid.html', title="Invalid Paste", subheading=subheading)
Example #2
0
def view_post(post):
    isInline = syndbb.request.args.get('inlinecontent', '')
    postcheck = d2_activity.query.filter_by(id=post).first()
    if postcheck:
        if postcheck.title:
            thread_title = (
                postcheck.title[:75] +
                '...') if len(postcheck.title) > 75 else postcheck.title
            postvars = postcheck
        else:
            threadcheck = d2_activity.query.filter_by(
                id=postcheck.replyto).first()
            thread_title = (
                threadcheck.title[:75] +
                '...') if len(threadcheck.title) > 75 else threadcheck.title
            postvars = threadcheck
        forumcheck = d2_forums.query.filter_by(id=postvars.category).first()
        if ('logged_in' in syndbb.session and checkSession(
                str(syndbb.session['logged_in']))) or not forumcheck.auth:
            return syndbb.render_template(
                'view_post.html',
                isInline=isInline,
                post=postcheck,
                title="#" + forumcheck.short_name + " &bull; " + thread_title +
                " &bull; " + forumcheck.name,
                forumtitle="<a href='/" + forumcheck.short_name + "/" +
                str(postvars.id) + "'>" + thread_title + "</a>")
        else:
            return syndbb.render_template('error_not_logged_in.html',
                                          title="Not logged in")
    else:
        return syndbb.render_template('invalid.html',
                                      title=" &bull; No post found")
Example #3
0
def submit_emoticon():
    if 'logged_in' in syndbb.session:
        dynamic_js_footer = ["js/lazyload.transpiled.min.js", "js/bootbox.min.js", "js/delete.js"]
        emote_list = get_submitted_emote()
        return syndbb.render_template('submit-emoticon.html', emote_list=emote_list, dynamic_js_footer=dynamic_js_footer, title="Submit Emoticon", subheading=["Emoticons"])
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Submit Emoticon", subheading=["Emoticons"])
Example #4
0
def delete_file():
    ufile = syndbb.request.args.get('file', '')
    uniqid = syndbb.request.args.get('uniqid', '')
    uploader = syndbb.request.args.get('uploader', '')
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(uniqid))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if uploader == "upload_anon":
                uploaded_file = syndbb.app.static_folder + "/data/uploads/" + d2_hash(
                    user.username + user.password)[:10] + "/" + ufile
            else:
                uploaded_file = syndbb.app.static_folder + "/data/uploads/" + user.username + "/" + ufile
            if syndbb.os.path.isfile(uploaded_file):
                syndbb.os.system("shred -u " + uploaded_file)
                syndbb.flash('File deleted successfully.', 'success')
                syndbb.cache.delete_memoized(
                    syndbb.views.upload.get_user_files)
                return syndbb.redirect(syndbb.url_for(uploader))
            else:
                syndbb.flash('No such file exists.', 'danger')
                return syndbb.redirect(syndbb.url_for(uploader))
        else:
            return syndbb.render_template('error_not_logged_in.html',
                                          title="Upload")
    else:
        return syndbb.render_template('error_not_logged_in.html',
                                      title="Upload")
Example #5
0
def view_user_posts(user):
    if 'logged_in' in syndbb.session:
        userid = checkSession(str(syndbb.session['logged_in']))
        if userid:
            dynamic_css_header = ["css/bbcode_editor.css"]
            isInline = syndbb.request.args.get('inlinecontent', '')
            postcheck = d2_activity.query.filter_by(user_id=user).filter(
                d2_activity.replyto != 0).filter(
                    d2_activity.anonymous != 1).order_by(
                        d2_activity.time.desc()).all()
            usercheck = d2_user.query.filter_by(user_id=user).first()
            if usercheck:
                if postcheck:
                    subheading = []
                    subheading.append('<a href="/user/' + usercheck.username +
                                      '">' + usercheck.username + '</a>')
                    return syndbb.render_template('view_user_posts.html',
                                                  isInline=isInline,
                                                  posts=postcheck,
                                                  title="All posts by " +
                                                  usercheck.username,
                                                  subheading=subheading)
                else:
                    return syndbb.render_template(
                        'invalid.html', title=" &bull; No posts found")
            else:
                return syndbb.render_template('invalid.html',
                                              title=" &bull; No user found")
    else:
        return syndbb.render_template('error_not_logged_in.html',
                                      title="Not logged in")
Example #6
0
def edit_post(post):
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            isInline = syndbb.request.args.get('inlinecontent', '')
            postcheck = d2_activity.query.filter_by(id=post).first()
            if postcheck:
                if postcheck.title:
                    thread_title = (postcheck.title[:75] + '...') if len(postcheck.title) > 75 else postcheck.title
                    postvars = postcheck
                else:
                    threadcheck = get_thread_contents(postcheck.replyto)
                    thread_title = (threadcheck.title[:75] + '...') if len(threadcheck.title) > 75 else threadcheck.title
                    postvars = threadcheck
                channelcheck = d2_channels.query.filter_by(id=postvars.category).first()
                if not check_channel_auth(channelcheck): return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")

                dynamic_css_header = ["css/bbcode_editor.css"]
                dynamic_js_footer = ["js/jquery.rangyinputs.js", "js/bbcode_editor_channels.js", "js/editing.js", "js/bootbox.min.js"]
                subheading = []
                subheading.append("<a href='/" + channelcheck.short_name + "/'>" + channelcheck.name + "</a>")
                subheading.append("<a href='/" + channelcheck.short_name + "/"+str(postvars.id)+"'>" + thread_title + "</a>")
                return syndbb.render_template('edit_post.html', isInline=isInline, post=postcheck, dynamic_css_header=dynamic_css_header, dynamic_js_footer=dynamic_js_footer, title="#"+channelcheck.short_name + " &bull; " + thread_title + " &bull; " + channelcheck.name, channeltitle="Editing Post", subheading=subheading)
            else:
                return syndbb.render_template('invalid.html', title=" &bull; No post found")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Not logged in")
Example #7
0
def logout():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            uniqid = syndbb.request.args.get('uniqid', '')
            if str(uniqid) == str(syndbb.session['logged_in']):
                check_session = d2_ip.query.filter_by(sessionid=uniqid).filter_by(ip=gdpr_check(syndbb.request.remote_addr)).first()
                if check_session:
                    syndbb.db.session.delete(check_session)
                    syndbb.db.session.commit()

                    syndbb.session.pop('logged_in', None)
                    syndbb.flash('You have been logged out.', 'warning')
                    return syndbb.redirect(syndbb.url_for('home'))
                else:
                    syndbb.flash('Invalid request.', 'warning')
                    syndbb.session.pop('logged_in', None)
                    return syndbb.redirect(syndbb.url_for('home'))
            else:
                syndbb.flash('Invalid session.', 'warning')
                syndbb.session.pop('logged_in', None)
                return syndbb.redirect(syndbb.url_for('home'))
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Not logged in")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Not logged in")
Example #8
0
def siteadmin_emoticons():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 100:
                emote_list = []
                emotfolder = syndbb.app.static_folder + "/data/emoticons/"
                if not syndbb.os.path.exists(emotfolder):
                    syndbb.os.makedirs(emotfolder)

                for emote in glob.glob(emotfolder+"**", recursive=True):
                    filepath = emote.replace(emotfolder, "")
                    if syndbb.os.path.isfile(emote):
                        addtime = int(syndbb.os.stat(emote).st_mtime)
                        code = syndbb.os.path.splitext(emote)[0]
                        code = ":" + syndbb.re.sub(r'.*/', '', code) + ":"
                        emote_list.append([filepath, code])
                emote_list.sort(reverse=False)
                return syndbb.render_template('admin_emoticons.html', emote_list=emote_list, title="Administration &bull; Emoticon List")
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Administration")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Administration")
Example #9
0
def upload_anon():
    page = syndbb.request.args.get('page', type=int, default=1)
    per_page = syndbb.request.args.get('amount', type=int, default=25)
    dynamic_css_header = []
    dynamic_js_footer = [
        "js/bootstrap-filestyle.min.js", "js/bootbox.min.js", "js/delete.js",
        "js/lazyload.transpiled.min.js"
    ]
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            cached_list = get_user_files(userid, anon=1)
            file_list = cached_list['file_list']

            page_count = math.ceil(len(file_list) / per_page)
            pagination = Pagination(page=page,
                                    per_page=per_page,
                                    css_framework='bootstrap3',
                                    total=len(file_list))

            amount_options = ["25", "50", "100", "500", "1000", "1500", "2000"]

            countselector = ''
            for amount in amount_options:
                if str(per_page) == amount:
                    countselector += '<option value="' + amount + '" selected>' + amount + '</option>'
                else:
                    countselector += '<option value="' + amount + '">' + amount + '</option>'

            start_index = (page * per_page) - per_page
            end_index = start_index + per_page
            if end_index > len(file_list):
                end_index = len(file_list)
            file_list = file_list[start_index:end_index]

            return syndbb.render_template(
                'upload_anon.html',
                uploadurl=cached_list['uploadurl'],
                filecount=cached_list['file_count'],
                file_list=file_list,
                pagination=pagination,
                countselector=countselector,
                total_size=cached_list['total_size'],
                uploader_name=cached_list['user_name'],
                dynamic_js_footer=dynamic_js_footer,
                dynamic_css_header=dynamic_css_header,
                title="Anonymous Upload",
                subheading=['<a href="/upload/">Upload</a>'])
        else:
            return syndbb.render_template(
                'error_not_logged_in.html',
                title="Anonymous Upload",
                subheading=['<a href="/upload/">Upload</a>'])
    else:
        return syndbb.render_template('error_not_logged_in.html',
                                      title="Upload",
                                      subheading=[""])
Example #10
0
def request_forum():
    if 'logged_in' in syndbb.session:
        return syndbb.render_template('request_forum.html',
                                      title="New Channel",
                                      subheading=[""])
    else:
        return syndbb.render_template('error_not_logged_in.html',
                                      title="New Channel",
                                      subheading=[""])
Example #11
0
def profile(username):
    isInline = syndbb.request.args.get('inlinecontent', '')
    user = get_user_profile(username)
    if user:
        subheading = []
        subheading.append("User Profile")
        dynamic_js_footer = ["js/bootbox.min.js", "js/delete.js", "js/profileAvatar.js"]
        return syndbb.render_template('profile.html', isInline=isInline, dynamic_js_footer=dynamic_js_footer, profile=user, title=user.username, subheading=subheading)
    else:
        return syndbb.render_template('invalid.html', isInline=isInline, title="Invalid User")
Example #12
0
def pastebin():
    if 'logged_in' in syndbb.session:
        dynamic_js_footer = ["js/bootbox.min.js", "js/delete.js"]
        userid = checkSession(str(syndbb.session['logged_in']))
        if userid:
            getPastes = d2_paste.query.filter(d2_paste.user_id == userid).order_by(syndbb.db.desc(d2_paste.time)).all()
            return syndbb.render_template('pastebin.html', dynamic_js_footer=dynamic_js_footer, paste_list=getPastes, title="Pastebin", subheading=[""])
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Pastebin", subheading=[""])
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Pastebin", subheading=[""])
Example #13
0
def view_thread(category, thread):
    forumcheck = d2_forums.query.filter_by(short_name=category).first()
    forumlogo = ""
    if forumcheck:
        if ('logged_in' in syndbb.session and checkSession(
                str(syndbb.session['logged_in']))) or not forumcheck.auth:
            topbuttons = '<a href="/' + forumcheck.short_name + '/' + thread + '/gallery" title="Gallery View" style="float:right;"><i class="silk-icon icon_application_view_tile" aria-hidden="true"></i></a>'
            dynamic_css_header = ["css/bbcode_editor.css"]
            dynamic_js_footer = [
                "js/bootstrap-filestyle.min.js", "js/jquery.rangyinputs.js",
                "js/bbcode_editor_forums.js", "js/posts.js",
                "js/post_ratings.js", "js/bootbox.min.js", "js/delete.js",
                "js/inline.js"
            ]
            #            if forumcheck.short_name == "yiff":
            #                dynamic_css_header.append("css/oify.css")
            if (forumcheck.nsfw) and ('nsfwAllow'
                                      not in syndbb.request.cookies):
                dynamic_js_footer.append("js/nsfwprompt.js")
                dynamic_css_header.append("css/nsfw_fill.css")
            logo_file = syndbb.app.static_folder + "/images/logos/" + forumcheck.short_name + ".png"
            if syndbb.os.path.isfile(logo_file):
                forumlogo = '<img src="' + cdn_path(
                ) + '/images/logos/' + forumcheck.short_name + '.png" alt="D2K5" class="sitelogo mask">'
            threadcheck = d2_activity.query.filter_by(id=thread).first()
            if threadcheck:
                subheading = []
                subheading.append('<a href="/' + forumcheck.short_name + '">' +
                                  forumcheck.name + '</a>')
                thread_title = (threadcheck.title[:75] + '...') if len(
                    threadcheck.title) > 75 else threadcheck.title
                replycheck = d2_activity.query.filter_by(replyto=thread).all()
                return syndbb.render_template(
                    'view_thread.html',
                    forum=forumcheck,
                    replies=replycheck,
                    thread=threadcheck,
                    forumlogo=forumlogo,
                    dynamic_css_header=dynamic_css_header,
                    dynamic_js_footer=dynamic_js_footer,
                    title="#" + forumcheck.short_name + " &bull; " +
                    thread_title + " &bull; " + forumcheck.name,
                    forumtitle=thread_title,
                    topbuttons=topbuttons,
                    subheading=subheading)
            else:
                return syndbb.render_template('invalid.html',
                                              title="No thread found")
        else:
            return syndbb.render_template('error_not_logged_in.html',
                                          title="Not logged in")
    else:
        return syndbb.render_template('invalid.html', title="No page found")
Example #14
0
def register():
    if 'logged_in' in syndbb.session:
        userid = checkSession(str(syndbb.session['logged_in']))
        if userid:
            return syndbb.render_template('error_already_logged_in.html',
                                          title="Registration")
    dynamic_js_footer = [
        "js/crypt.js", "js/auth/auth_regd.js", "js/bootbox.min.js"
    ]
    return syndbb.render_template('register.html',
                                  dynamic_js_footer=dynamic_js_footer,
                                  title="Registration")
Example #15
0
def login():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            return syndbb.render_template('error_already_logged_in.html', title="Log In")

    dynamic_js_footer = ["js/crypt.js", "js/bootbox.min.js"]
    if syndbb.core_config['ldap']['enabled'] :
        dynamic_js_footer.append("js/auth_plain/auth_login.js")
    else:
        dynamic_js_footer.append("js/auth_hash/auth_login.js")
    return syndbb.render_template('login.html', dynamic_js_footer=dynamic_js_footer, title="Log In")
Example #16
0
def change_password():
    if 'logged_in' in syndbb.session:
        userid = checkSession(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            dynamic_js_footer = ["js/crypt.js", "js/auth/auth_chpw.js", "js/bootbox.min.js"]
            subheading = []
            subheading.append("<a href='/user/" + user.username + "'>" + user.username + "</a>")
            return syndbb.render_template('change_password.html', dynamic_js_footer=dynamic_js_footer, title="Change Password", subheading=subheading)
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Change Password")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Change Password")
Example #17
0
def login_history():
    if 'logged_in' in syndbb.session:
        userid = checkSession(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            logins = d2_ip.query.filter_by(user_id=userid).order_by(d2_ip.time.desc()).all()
            subheading = []
            subheading.append("<a href='/user/" + user.username + "'>" + user.username + "</a>")
            return syndbb.render_template('login_info.html', logins=logins, title="Login History", subheading=subheading)
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Login History")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Login History")
Example #18
0
def siteadmin_logins():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 900:
                return syndbb.render_template('admin_logins.html', logins=get_all_logins(), title="Administration &bull; Login History")
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Administration")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Administration")
Example #19
0
def siteadmin_rank():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 500:
                rankuser = syndbb.request.args.get('user', '')
                return syndbb.render_template('admin_rank.html', rankuser=rankuser, title="Administration &bull; Change Rank")
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Administration")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Administration")
Example #20
0
def siteadmin_channels():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 100:
                unapproved = d2_channels.query.filter(d2_channels.approved == 0).all()
                return syndbb.render_template('admin_channels.html', unapproved=unapproved, title="Administration &bull; Unapproved Channels")
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Administration")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Administration")
Example #21
0
def siteadmin_users():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 500:
                dynamic_js_footer = ["js/bootbox.min.js", "js/delete.js"]
                users = d2_user.query.order_by(d2_user.rank.desc()).order_by(d2_user.join_date.asc()).all()
                return syndbb.render_template('admin_users.html', dynamic_js_footer=dynamic_js_footer, users=users, title="Administration &bull; User List")
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Administration")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Administration")
Example #22
0
def siteadmin_invites():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 100:
                dynamic_js_footer = ["js/bootbox.min.js", "js/delete.js"]
                invites = d2_requests.query.all()
                return syndbb.render_template('admin_invites.html', dynamic_js_footer=dynamic_js_footer, invites=invites, title="Administration &bull; Requested Invites")
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Administration")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Administration")
Example #23
0
def register():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            return syndbb.render_template('error_already_logged_in.html', title="Registration")

    dynamic_js_footer = ["js/crypt.js", "js/bootbox.min.js", "js/random_name.js"]
    if syndbb.core_config['ldap']['enabled'] :
        dynamic_js_footer.append("js/auth_plain/auth_regd.js")
    else:
        dynamic_js_footer.append("js/auth_hash/auth_regd.js")
    reg_template = "register_invite.html" if syndbb.core_config['site']['invite_only'] else "register.html"
    if not syndbb.core_config['site']['registration'] :
        reg_template = "register_disabled.html"
    return syndbb.render_template(reg_template, dynamic_js_footer=dynamic_js_footer, invite_code='', title="Registration")
Example #24
0
def profiles():
    linked_users = []
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user:
                if user.user_auth and user.user_auth != "":
                    linked_users = d2_user.query.filter_by(user_auth=user.user_auth).all()
            subheading = []
            subheading.append("<a href='/user/" + user.username + "'>" + user.username + "</a>")
            return syndbb.render_template('profiles.html', linked_users=linked_users, title="My Profiles", subheading=subheading)
        else:
            return syndbb.render_template('error_not_logged_in.html', title="My Profiles")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="My Profiles")
Example #25
0
def siteadmin_ban():
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 500:
                banuser = syndbb.request.args.get('user', '')
                banpost = syndbb.request.args.get('post_id', '')
                isbanned = check_ban_by_id(banuser)
                return syndbb.render_template('admin_ban.html', isbanned=isbanned, banuser=banuser, banpost=banpost, title="Administration &bull; Ban User")
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return syndbb.render_template('error_not_logged_in.html', title="Administration")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Administration")
Example #26
0
def do_rank_user():
    rankuser = syndbb.request.form['user_id']
    rank = syndbb.request.form['rank']
    uniqid = syndbb.request.form['uniqid']

    if rankuser and rank and uniqid:
        userid = check_session_by_id(uniqid)
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 500:
                changeuser = d2_user.query.filter_by(user_id=rankuser).first()
                changeuser.rank = rank
                syndbb.db.session.commit()

                syndbb.cache.delete_memoized(syndbb.models.users.get_title_by_id)
                syndbb.cache.delete_memoized(syndbb.models.users.get_group_style_by_id)

                syndbb.flash('User rank changed successfully.', 'success')
                return syndbb.redirect(syndbb.url_for('siteadmin_users'))
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return "Invalid Session"
    else:
        return "Invalid Request"
Example #27
0
def approve_emoticon():
    emote = syndbb.request.args.get('file', '')
    uniqid = syndbb.request.args.get('uniqid', '')

    if uniqid:
        userid = check_session_by_id(uniqid)
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 500:
                emotepath = syndbb.app.static_folder + "/data/emoticons/" + emote
                destpath = syndbb.app.static_folder + "/images/emots/"
                if syndbb.os.path.isfile(emotepath):
                    shutil.copy2(emotepath, destpath)
                    syndbb.os.remove(emotepath)
                    syndbb.flash('Emoticon approved successfully.', 'success')
                    return syndbb.redirect(syndbb.url_for('siteadmin_emoticons'))
                else:
                    syndbb.flash('No such emoticon exists.', 'danger')
                    return syndbb.redirect(syndbb.url_for('siteadmin_emoticons'))
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return "Invalid Session"
    else:
        return "Invalid Request"
Example #28
0
def view_post(post):
    isInline = syndbb.request.args.get('inlinecontent', '')
    postcheck = d2_activity.query.filter_by(id=post).first()
    if postcheck:
        if postcheck.title:
            thread_title = (postcheck.title[:75] + '...') if len(postcheck.title) > 75 else postcheck.title
            postvars = postcheck
        else:
            threadcheck = get_thread_contents(postcheck.replyto)
            thread_title = (threadcheck.title[:75] + '...') if len(threadcheck.title) > 75 else threadcheck.title
            postvars = threadcheck
        channelcheck = d2_channels.query.filter_by(id=postvars.category).first()
        if not check_channel_auth(channelcheck): return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        return syndbb.render_template('view_post.html', isInline=isInline, post=postcheck, title="#"+channelcheck.short_name + " &bull; " + thread_title + " &bull; " + channelcheck.name, channeltitle="<a href='/" + channelcheck.short_name + "/"+str(postvars.id)+"'>" + thread_title + "</a>")
    else:
        return syndbb.render_template('invalid.html', title=" &bull; No post found")
Example #29
0
def do_unban_user():
    banuser = syndbb.request.form['user_id']
    uniqid = syndbb.request.form['uniqid']

    if banuser and uniqid:
        userid = check_session_by_id(uniqid)
        if userid:
            user = d2_user.query.filter_by(user_id=userid).first()
            if user.rank >= 500:
                ban = d2_bans.query.filter_by(banned_id=banuser).order_by(d2_bans.time.desc()).first()
                if ban.length == 0:
                    ban.length = "-1"
                ban.expires = unix_time_current()
                syndbb.db.session.commit()

                syndbb.cache.delete_memoized(syndbb.models.users.get_title_by_id)
                syndbb.cache.delete_memoized(syndbb.models.users.get_group_style_by_id)
                syndbb.cache.delete_memoized(syndbb.models.activity.ban_list)

                syndbb.flash('User unbanned successfully.', 'success')
                return syndbb.redirect(syndbb.url_for('siteadmin_ban'))
            else:
                return syndbb.render_template('error_insufficient_permissions.html', title="Insufficient permission")
        else:
            return "Invalid Session"
    else:
        return "Invalid Request"
Example #30
0
def view_user_threads(user):
    if 'logged_in' in syndbb.session:
        userid = check_session_by_id(str(syndbb.session['logged_in']))
        if userid:
            dynamic_css_header = ["css/bbcode_editor.css"]
            isInline = syndbb.request.args.get('inlinecontent', '')
            threadcheck = d2_activity.query.filter_by(user_id=user).filter(d2_activity.replyto == 0).filter(d2_activity.anonymous != 1).order_by(d2_activity.time.desc()).all()
            usercheck = d2_user.query.filter_by(user_id=user).first()
            if usercheck:
                if threadcheck:
                    thread_list = ""
                    for thread in threadcheck:
                        channelcheck = d2_channels.query.filter_by(id=thread.category).first()
                        if channelcheck and check_channel_auth(channelcheck):
                            if thread.reply_count == 1:
                                replystr = "reply"
                            else:
                                replystr = "replies"
                            lastpost = d2_activity.query.filter_by(replyto=thread.id).order_by(d2_activity.time.desc()).first()
                            if lastpost:
                                latest = lastpost.id
                                latestreplier = lastpost
                            else:
                                latest = thread.id
                                latestreplier = thread
                            thread_list += '''<tr>
                                                    <td class="home-channel home-channel-icon"><img src="'''+cdn_path()+'''/images/posticons/'''+str(thread.post_icon)+'''.png" alt=""/></td>
                                                    <td class="home-channel">
                                                    <span class="small" style="float:right; text-align: right;">
                                                        <span class="timedisplay">'''+recent_date(thread.reply_time)+'''</span><br/>
                                                        by <a href="/user/'''+get_username_by_id(latestreplier.user_id)+'''" class="profile-inline">'''+get_username_by_id(latestreplier.user_id)+'''</a> <a href="/'''+str(channelcheck.short_name)+'''/'''+str(thread.id)+'''#'''+str(latest)+'''"><img src="'''+cdn_path()+'''/icons/thread_new.png" style="margin-top: -2px;"/></a>
                                                    </span>
                                                    <a href="/'''+str(channelcheck.short_name)+'''/'''+str(thread.id)+'''"><b>'''+thread.title+'''</b></a>
                                                    <span class="small"><br/>
                                                    <a href="/user/'''+get_username_by_id(thread.user_id)+'''" class="profile-inline">'''+get_username_by_id(thread.user_id)+'''</a>, <span class="timedisplay">'''+recent_date(thread.time)+'''</span>
                                                    </span>
                                                    </td>
                                                </tr>'''
                    subheading = []
                    subheading.append('<a href="/user/'+usercheck.username+'">'+usercheck.username+'</a>')
                    return syndbb.render_template('view_user_threads.html', dynamic_css_header=dynamic_css_header, isInline=isInline, thread_list=thread_list, title="All threads by " + usercheck.username, subheading=subheading)
                else:
                    return syndbb.render_template('invalid.html', title=" &bull; No threads found")
            else:
                return syndbb.render_template('invalid.html', title=" &bull; No threads found")
    else:
        return syndbb.render_template('error_not_logged_in.html', title="Not logged in")