Exemplo n.º 1
0
def login():
    try:
        if request.method == "POST":
            db = database()
            username = request.form['username']
            data = db.read(
                '''SELECT Username,password,AuthKey,GUID,B3ID,level FROM users WHERE username = (?)''',
                username)
            if len(data) == 0:
                data = db.read(
                    '''SELECT Username,password,AuthKey,GUID,B3ID,level FROM users WHERE username = (?)''',
                    username)
            db.close()
            if len(data) == 1 and sha256_crypt.verify(request.form['password'],
                                                      data[0][1]):
                session['logged_in'] = True
                session['username'] = data[0][0]
                session['authkey'] = data[0][2]
                session['guid'] = data[0][3]
                session['b3id'] = data[0][4]
                session['level'] = data[0][5]
                flash('You Have Successfully Logged in !')
                return redirect(request.referrer)
            else:
                flash('Invalid credentials. Try Again.')
                return redirect(request.referrer)
    except Exception as e:
        return redirect(request.referrer)
Exemplo n.º 2
0
def requestsongs():
    try:
        if request.method == "POST":
            name = request.form['name']
            email = request.form['email']
            songname = request.form['songname']
            artists = request.form['artists']
            starttime = int(request.form['starttime'])
            url = "https://www.youtube.com/embed/{}?start={}&end={}".format(
                request.form['videoid'], starttime, starttime + 10)
            db = database()
            x = db.read("SELECT * FROM KMusic WHERE Name LIKE (?)", name)
            if len(x) > 0:
                flash('Song is Already in the Request List')
                return render_template("requestsongs.html")
            db.write(
                '''INSERT INTO KMusic(Name,Email,Song,Artist,URL) VALUES(?,?,?,?,?)''',
                name, email, songname, artists, url)
            db.close()

            flash('Your Request is Send to Admins')

        return render_template("cod4/requestsongs.html")
    except:
        flash('There was Error while sending the request')
        return render_template("cod4/requestsongs.html")
Exemplo n.º 3
0
def register():
    try:
        if request.method == "POST":
            db = database()
            displayname = request.form['displayname']
            username = request.form['username']
            password = sha256_crypt.encrypt(str(request.form['password']))
            email = request.form['email']
            AuthKey = ''.join(
                random.choice(string.ascii_uppercase + string.digits)
                for _ in range(8))
            x = db.read("SELECT * FROM users WHERE Username = (?)", username)
            y = db.read("SELECT * FROM users WHERE Email = (?)", email)
            if len(x) > 0:
                flash('Username Already in Use')
                return redirect(request.referrer)
            if len(y) > 0:
                flash('Your Email is already Registered')
                return redirect(request.referrer)
            db.write(
                '''INSERT INTO users(Name,Username,Password,Email,AuthKey) VALUES(?,?,?,?,?)''',
                displayname, username, password, email, AuthKey)
            db.close()
            flash('You Have Successfully Registered !')
            return redirect(request.referrer)
    except Exception as e:
        return render_template("home.html")
Exemplo n.º 4
0
def submitss():
    try:
        if request.method == "POST" and request.form[
                'secretkey'] == 'WK3vKwJs4ZDCV5HrthRnOGreY12mEYwS2ljpm0AI':
            db = database()
            try:
                id = int(db.read('''SELECT ID FROM ScreenShots''')[-1][0]) + 1
            except:
                id = 1
            name = request.form['name'][:-2]
            b3id = int(request.form['b3id'])
            connections = int(request.form['connections'])
            aliases = request.form['aliases']
            guid = request.form['guid']
            penalties = int(request.form['penalties'])
            ip = request.form['ip']
            score = request.form['score']
            try:
                with urllib.request.urlopen(
                        "https://ipinfo.io/{}/json".format(ip)) as url:
                    data = json.loads(url.read().decode())
                    address = '{}, {}'.format(data['city'], data['country'])
            except:
                address = 'Not Found'
            f = request.files['ss']
            f.save('static/screenshots/{}.jpg'.format(id))
            query = '''INSERT INTO ScreenShots (Name,B3ID,Connections,Aliases,GUID,Address,IP,Penalties,Score) VALUES ('{}',{},{},'{}','{}','{}','{}',{},{})'''.format(
                name, b3id, connections, aliases, guid, address, ip, penalties,
                score)
            db.write(query)
            db.close()
            return jsonify('Got IT')
    except Exception as e:
        print(e, file=open('/home/ba_error.log', 'a'))
        return jsonify('Something Went Wrong')
    def __init__(self):
        self.db_equipment = database('equipment')

        handlers = [(r"/", IndexHandler), (r"/issuedManager", IssuedManager),
                    (r"/getEquipment", CreateEquipment),
                    (r"/getSpecificEquipmentIssueEquipment",
                     SpecificEquipmentIssueEquipment),
                    (r"/isseuEquipment", IssueEquipment)]
        tornado.web.Application.__init__(self, handlers)
Exemplo n.º 6
0
 def post(self):
     data = request.get_json(force=True)
     if(data['password']=="123456"and data['username']=="BBT"):
         return database().query()
     else:
      return jsonify({
         "errcode":400,
         "errmsg":"用户名或密码错误"
     })
Exemplo n.º 7
0
 def __init__(self, cnx=None, host='catalogservice.cbufftirwvx9.us-east-2.rds.amazonaws.com', db='CatalogService',
              user=None, password=None, key_columns = None, notIncludedCols = None):
     self.cnx = cnx
     if not cnx:
         db = database(host=host, db=db, user=user, password=password)
         self.cnx = db.cnx
     self.key_columns, self.notIncludedCols = key_columns, notIncludedCols
     if not key_columns: self.key_columns = ['name', 'byline', 'categories', 'experience']
     if not notIncludedCols: self.notIncludedCols = ['fields', 'limit', 'offset']
Exemplo n.º 8
0
 def post(self):
     time = checkTime()
     if not time['errcode']:
         data = request.get_json(force=True)
         check = database().isRecruit(data['tele'])
         if check['errcode'] == 401:
             result = checkInfo(data['name'], data['gender'], data['grade'],
                                data['college'], data['campus'],
                                data['tele'], data['time'])
             if result['errcode'] == 0:
                 #时间数组转字符串
                 data['time'] = ','.join(data['time'])
                 return database().updateUser(data)
             else:
                 return result
         else:
             return check
     else:
         return time
Exemplo n.º 9
0
def ssview():
    try:
        db = database()
        data = db.read(
            '''SELECT ID,Name,B3ID,GUID,Score FROM ScreenShots WHERE Banned IS NULL ORDER BY ID DESC'''
        )
        db.close()
        return render_template("cod4/ssviewer.html", data=data)
    except:
        flash('Something Went Wrong')
        return render_template("cod4/ssviewer.html")
Exemplo n.º 10
0
def banned():
    try:
        db = database()
        data = db.read(
            '''SELECT * FROM ScreenShots WHERE Banned IS NOT NULL ORDER BY ID DESC'''
        )
        db.close()
        return render_template("cod4/banlist.html", data=data, fullwidth=True)
    except:
        flash('Something Went Wrong')
        return render_template("cod4/banlist.html")
def homepage():
    try:
        db = database()
        data = db.read(
            '''SELECT ID,Name FROM ScreenShots WHERE Banned IS NULL ORDER BY ID DESC'''
        )[:100]
        db.close()
        shuffle(data)
        return render_template("home.html", fullwidth=True, ss=data[:6])
    except:
        return render_template("home.html", fullwidth=True)
Exemplo n.º 12
0
    def __init__(self):
        db = database()
        db.select(["title", "content", "is_test"])
        # db.where("is_test = false")
        db.table("eng_texts_tab")
        all_datas = db.get_result()

        tot_num_words = 0

        for data in all_datas:
            all_data.append(data[0])
            all_data.append(data[1])
            titles.append(data[0])
            contents.append(data[1])
            tot_num_words += len(data[0])
            tot_num_words += len(data[1])
Exemplo n.º 13
0
def get_word_index(self):
    db = database()
    db.select(["pre_title", "pre_content", "is_test"])
    db.table("eng_texts_tab")
    datas = db.get_result()
    token_data = []
    for data in datas:
        token_data.append(self.listToString(data[0]))
        token_data.append(self.listToString(data[1]))

    tokenizer = Tokenizer(num_words=MAX_NUM_WORDS)
    tokenizer.fit_on_texts(token_data)
    list_tokenized = tokenizer.texts_to_sequences(token_data)
    # tokenized_datas = pad_sequences(list_tokenized, maxlen=MAX_SEQUENCE_LENGTH)
    word_index = tokenizer.word_index
    return word_index
Exemplo n.º 14
0
def submitss():
    try:
        if request.method == "POST" and request.form[
                'secretkey'] == 'WK3vKwJs4ZDCV5HrthRnOGreY12mEYwS2ljpm0AI':
            db = database()
            b3id = int(request.form['b3id'])
            guid = request.form['guid']
            level = int(request.form['level'])
            authkey = request.form['authkey']
            db.write(
                '''UPDATE users SET b3id = (?), guid = (?) ,level = (?), authkey = (?) WHERE authkey = (?)''',
                b3id, guid, level, None, authkey)
            db.close()
        return render_template("home.html")
    except Exception as e:
        return render_template("home.html")
Exemplo n.º 15
0
def imageview():
    try:
        db = database()
        data = db.read('''SELECT * FROM ScreenShots WHERE ID = (?)''',
                       request.args.get('ssid'))
        db.close()
        metadata = [
            'screenshots/{}'.format(data[0][0]),
            'Screenshot of {} (@{})'.format(data[0][1], data[0][2]),
            'ss/view/?ssid={}'.format(data[0][0])
        ]
        return render_template("cod4/imageview.html",
                               data=data,
                               metadata=metadata)

    except:
        flash('Something Went Wrong :/')
        return redirect(request.referrer)
Exemplo n.º 16
0
def banplayer():
    try:
        db = database()
        id = str(
            db.read('''SELECT B3ID from ScreenShots where ID = (?)''',
                    str(int(request.args.get('ssid'))))[0][0])

        m = MultipartEncoder(
            fields={
                "b3id":
                str(session['b3id']),
                "cmd":
                'ban',
                "args":
                '@' + id,
                "args2":
                '^3WallHacker^0|^1Proof- blackassassins.tk/ss/view/?ssid=' +
                str(int(request.args.get('ssid'))),
                "secretkey":
                'WK3vKwJs4ZDCV5HrthRnOGreY12mEYwS2ljpm0AI'
            })
        r = str(
            requests.post('http://188.166.187.32:5001/wufcw66i5aetl2w1f1zp24',
                          data=m,
                          headers={
                              'Content-Type': m.content_type
                          }).text)
        if 'true' in str(r):
            data = db.write(
                '''UPDATE ScreenShots SET banned = (?) WHERE ID = (?)''',
                session['username'], str(int(request.args.get('ssid'))))
            flash('Player Was Successfully Banned')
        else:
            flash(
                'There was a error while banning the player, Try Again in Bit !'
            )
            flash('Make Sure You are Connected to Server Before Banning Again')
        db.close()
        return redirect(request.referrer)
    except:
        flash('Something Went Wrong')
        return redirect(request.referrer)
Exemplo n.º 17
0
def reportadmin():
    try:
        db = database()
        emails = db.read('''SELECT Email from users where Level >= 64''')
        emaillist = []
        for email in emails:
            emaillist.append(email[0])

        data = request.args.get('data')
        adminid = request.args.get('adminid')
        reason = str(request.args.get('reason'))

        if len(data) != int(adminid) + 20:
            flash('Something Went Wrong :(')
            return redirect(request.referrer)

        data = data.split(';;;')
        try:
            msg = Message("{} Made a Ban appeal".format(data[2]),
                          sender="*****@*****.**",
                          recipients=emaillist)
            msg.body = '''Ban appeal by {}\n
                        {} Think Following Penalty is unfair becouse {} \n
                        Penalty ID :- {} \nPenalty Type :- {} \nPlayer Name :- {} \n
                        Reason for Penalty :- {} \n
                        Admin Name :- {} \n
                        Expire Time :- {}'''.format(data[2], data[2], reason,
                                                    data[0], data[1], data[2],
                                                    data[3], data[4], data[5])
            msg.html = render_template('/emails/report_admin.html',
                                       data=data,
                                       reason=reason)
            mail.send(msg)
            flash('Your Appeal was successfully send to Responsible Persons')
        except:
            flash(
                'There was errro while making the Appeal, Try Again later :(')
        return redirect(request.referrer)
    except:
        flash(str(e))
        flash('There was errro while making the Appeal, Try Again later :(')
        return redirect(request.referrer)
Exemplo n.º 18
0
 def post(self):
     data = request.get_json(force=True)
     return database().isRecruit(data['tele'])
Exemplo n.º 19
0
 def post(self):
     data = request.get_json(force=True)
     return database().showCollege(data['campus'])
Exemplo n.º 20
0
#!/usr/bin/python
# -*- coding: utf-8 -*-



from bottle import run
import json
from database.database import DataBaseManager as database
import sys
import os
os.environ['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'

"""
App.__init__.py:
Script principal do Aplicativo, controla o servidor e a conexção com o banco.
A variavel db é global e é importada onde a conexão com o banco é necessaria.

"""


#Cria o objeto de conexão com o banco de dados.
db = database()
# Importa os controladores.
import controller as __name__

#Função responsavel pelo inico do servidor.
def runserver(host, port):
	run(host=host, port=port)
Exemplo n.º 21
0
from database.database import database
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.stem import WordNetLemmatizer
from snowballstemmer import stemmer
import json
import psycopg2 as psycopg2
from jpype import JClass, JString, getDefaultJVMPath, shutdownJVM, startJVM, java

ZEMBEREK_PATH = r'C:\Users\casper\PycharmProjects\title_generate\zemberek-full.jar'
startJVM(getDefaultJVMPath(),
         '-ea',
         f'-Djava.class.path={ZEMBEREK_PATH}',
         convertStrings=False)

db = database()
stopWords = set(stopwords.words('turkish'))
lemmatizer = WordNetLemmatizer()
stemmer = stemmer('turkish')


class preprocessing:
    def __init__(self):
        self.preprocess()

    def preprocess(self):

        sql = """ UPDATE texts_tab
                  SET pre_title = %s, pre_content = %s
                  WHERE id = %s"""
        conn = None
Exemplo n.º 22
0
import os
import sys
import jwt
import requests

from flask import Flask, Response
from flask import request
from flask import render_template

from database.database import database
from database.tutors import tutorsDatabase
from database.catalog import catalogDatabase
from database.categories import categoriesDatabase
from database.bookings import bookingsDatabase
db = database(host='catalogservice.cbufftirwvx9.us-east-2.rds.amazonaws.com',
              db='CatalogService',
              user=None,
              password=None)
cnx = db.cnx
tutorD = tutorsDatabase(cnx)
catalogD = catalogDatabase(cnx)
categoriesD = categoriesDatabase(cnx)
bookingsD = bookingsDatabase(cnx)

cwd = os.getcwd()
sys.path.append(cwd)

application = Flask('CatalogService')


def response400(e):
    return Response('Error: {}'.format(str(e)), status=400)