Beispiel #1
0
def add_comment(forum, articleID):
    comment = request.form.get('comment')
    addr = request.form.get('addr')
    if actions.is_valid_email(addr) == False:
        return 'Sorry,it is not valid e-mail'
    b = Blacklist(addr)
    if b.is_in_blacklist():
        return 'Sorry,you are in black list'
    if Evil_comment.is_evil_comment(comment) == True:
        return 'Evil comment! Comment failed'
    if Comment.time_limit(addr) == 0:
        return 'You can not publish a article in a very short period. '
    Comment.addComment(articleID, comment, addr, forum)
    return redirect(url_for('text', f=forum, id=articleID))
Beispiel #2
0
def search():
    if request.method == 'POST':
        keyword = request.form.get('keyword')
        keyword = str(keyword)
        if keyword == '':
            return redirect(url_for('index'))
        result, c = actions.searchinfo(keyword)
        result.reverse()
        b = Blacklist.query()
        blacklist = []
        articles = []
        for i in result:
            article = Article(str(i[0]))
            i = list(i)
            i.append(actions.addr_protect(i[2]))
            i.append(article.score())
            articles.append(i)
        comments = []
        for i in c:
            comment = Comment(str(i[0]))
            i = list(i)
            i.append(actions.addr_protect(i[5]))
            i.append(comment.score())
            i.append(actions.exchange(str(i[1])))
            comments.append(i)
        for i in b:
            blacklist.append(i[1])
        return render_template('search.html',
                               keyword=keyword,
                               articles=articles,
                               blacklist=blacklist,
                               comments=comments)
    else:
        return redirect(url_for('index'))
Beispiel #3
0
def author(address):
    author = Author(address)
    li = author.articlelist()
    l = sorted(li, key=lambda s: s[3], reverse=True)
    b = Blacklist.query()
    blacklist = []
    for i in b:
        blacklist.append(i[1])
    articles = []
    for i in l:
        article = Article(i[0])
        i = list(i)
        i.append(actions.addr_protect(i[2]))
        i.append(article.score())
        articles.append(i)
    c1 = author.commentlist()
    c = sorted(c1, key=lambda s: s[7], reverse=True)
    comments = []
    for i in c:
        i = list(i)
        i.append(actions.addr_protect(i[5]))
        comments.append(i)
    addr = actions.addr_protect(address)
    return render_template('author.html',
                           articles=articles,
                           addr=addr,
                           blacklist=blacklist,
                           comments=comments)
Beispiel #4
0
def publish(forum):
    if request.method == 'GET':
        return render_template('publish.html', forum=forum)
    else:
        address = request.form.get('address')
        title = request.form.get('title')
        abstract = request.form.get('abstract')
        describe = request.form.get('describe')
        f = request.files['file']

        i = request.form.get('i')
        i = str(i).lower()
        code = str(session.get('code')).lower()

        b = Blacklist(address)
        if b.is_in_blacklist():
            return 'Sorry,you are in black list'
        if actions.is_valid_email(address) == False:
            return 'Please enter valid e-mail'

        if Evil_comment.is_evil_comment(title) == True:
            return 'Evil title! Publish failed'
        if Evil_comment.is_evil_comment(abstract) == True:
            return 'Evil abstract! Publish failed'
        if Evil_comment.is_evil_comment(describe) == True:
            return 'Evil describe! Publish failed'

        if i != code:
            return 'Error Verification Code'

        if Article.time_limit(address) == 0:
            return 'You can not publish a article in a very short period. '
        if address != '' and title != '' and abstract != '' and describe != '':
            if actions.allowed_file(secure_filename(f.filename)) == False:
                return 'You only can upload pdf file! '
            basepath = os.path.dirname(__file__)  # 当前文件所在路径
            filename = actions.set_id() + '.pdf'
            upload_path = os.path.join(basepath, 'static/uploads', filename)
            f.save(upload_path)
            Article.article_add(title, address, abstract, describe, forum)
        else:
            return 'Please enter all information'
        return redirect(url_for('forum', forum=forum))
Beispiel #5
0
def forum(forum):
    art = Article.query(forum)
    a = sorted(art, key=lambda s: s[3], reverse=True)
    articles = []
    for i in a:
        article = Article(i[0])
        i = list(i)
        i.append(actions.addr_protect(i[2]))
        i.append(article.score())
        articles.append(i)
    b = Blacklist.query()
    blacklist = []
    for i in b:
        blacklist.append(i[1])
    a1 = sorted(articles, key=lambda s: s[11], reverse=True)
    if a1 == []:
        top = []
    else:
        top = a1[0]
    return render_template('forum.html',
                           articles=articles,
                           forum=forum,
                           blacklist=blacklist,
                           top=top)