Exemplo n.º 1
0
def SignUp():
    form=SignUpForm(request.form)
    date=datetime.now().year
    random_number=int(random()*1000000)
    customer_id=f'salemfx/{date}/{random_number}'

    if request.method=="POST" and form.validate():
        mysql=pymysql.connect(host=host,
                      port=port,
                      user=users,
                      password=password,
                      db=dbs,
                      charset=charset,
                      )
        surname=form.surname.data
        firstname=form.firstName.data
        email=form.email.data
        passwords=sha256_crypt.hash(str(form.password.data))

        

        find_query=f"SELECT * FROM perfect_trade_users WHERE Email= '{email}' OR (Surname='{surname}' AND Firstname='{firstname}')"
        db=mysql.cursor(pymysql.cursors.DictCursor)
        res= db.execute(find_query)
        if res >0:
             db.close()
             flash("User Already Exist", "red")
             redirect(url_for('SignUp'))
        else:
                details={
                'surname':surname,
                'firstname':firstname,
                'email': email,
                'password':  passwords
                }
                app.logger.info(form.password.data)
                session['details']=details
                raw_pin=int(random()*1000000)
                pin=f'{raw_pin:5}'
                app.logger.info(pin)

                session["pin"]=pin
                msg=Message()
                msg.subject="Email Verification"
                msg.body=f"Your Email Verification Pin is {pin} This Pin Will Expire In Five Minutes"
                msg.recipients=[email]
                msg.sender="Perfect Trades"
                try:
                    mail.send(msg)
                    return redirect(url_for("confirm_email"))
    
                except Exception as error:
                    flash("Sorry It Seems an Error Occured", "red")
                    redirect(url_for("SignUp"))
                    print(error)
                     
               
     

    return render_template('User/sign_up.html', Page="Sign Up", form=form)
Exemplo n.º 2
0
def contact():
    sat = {"status": ""}
    if request.method == "POST":
        mysql = pymysql.connect(
            host=host,
            port=port,
            user=users,
            password=password,
            db=dbs,
            charset=charset,
        )
        db = mysql.cursor()
        app.logger.info(request.form)
        data = dict(request.form)

        # app.logger.info(data)
        email = data["email"]
        firstname = data["firstname"]
        lastname = data["lastname"]
        subject = data["subject"]
        message = data['message']
        query = f"INSERT INTO messages (Email,Message,Firstname,Lastname,Subject) VALUES('{email}','{message}','{firstname}','{lastname}','{subject}')"
        db.execute(query)
        mysql.commit()
        count = db.rowcount
        if count > 0:
            sat = {"status": "success"}
            new_msg = Message()
            new_msg.subject = subject
            new_msg.body = message
            new_msg.recipients = ['*****@*****.**']
            new_msg.sender = f'{firstname} {lastname} From Perfect Trade'
            mail.send(new_msg)
        else:
            sat = {"status": "Failed"}
        mysql.close()

        return json.dumps(sat)
Exemplo n.º 3
0
def forgotPassword():
        if request.method=="POST":
            mysql=pymysql.connect(host=host,
                      port=port,
                      user=users,
                      password=password,
                      db=dbs,
                      charset=charset,
                      )
            email=request.form['email']
            letters=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p']
            pin=f"{letters[int(random()*len(letters))]}{int(random()*len(letters))}{letters[int(random()*len(letters))]}{int(random()*len(letters))}{letters[int(random()*len(letters))]}{int(random()*len(letters))}"
            db=mysql.cursor(pymysql.cursors.DictCursor)
            user=db.execute(f"SELECT * FROM perfect_trade_users WHERE Email='{email}'")
            if user > 0:
                session['recovery']=True
                session['recovery_pin']=pin
                session['recovery_email']=email
                new_msg=Message()
                new_msg=Message()
                new_msg.subject="Password Recovery"
                new_msg.body=f"Your Recovery Pin is {pin} Do Not Share Your Pin Use This To Change Your Password"
                new_msg.recipients=[email]
                new_msg.sender="Perfect Trades"
             
                try:
                    mail.send(new_msg)
                    return  redirect(url_for('passwordGenLogin'))
    
                except Exception as error:
                    app.logger.info(error)
                    flash("Sorry It Seems an Error Occured", "red")
            else:
                flash("User Does Not Exist","red")

        return render_template('User/forgot_password.html',Page="Forgot Password")
Exemplo n.º 4
0
def rejectWthdraw():
    stats = {"Success": ""}
    if request.method == "POST":
        data = dict(request.form)
        count = reject(data['id'])
        if count > 0:
            stats["Success"] = "True"
            new_msg = Message()
            new_msg.subject = "Withdrawal Rejected"
            new_msg.body = f"Your withDrawal Of {data['amount']} Requested On {data['date']} Has Been Rejected Email Us For More Info"
            new_msg.recipients = [data['email']]
            new_msg.sender = "Perfect Trade"

            try:
                mail.send(new_msg)
                return redirect(url_for('passwordGenLogin'))

            except Exception as error:
                app.logger.info(error)
                flash("Sorry It Seems an Error Occured", "red")
        else:
            stats["Success"] = "False"

    return jsonify(stats)
Exemplo n.º 5
0
def invest():
    user = getUserData()
    fullname = f"{user['Firstname']} {user['Surname']}"
    if request.method == 'POST':
        status = {"Success": False}
        data = dict(request.form)
        app.logger.info(data)
        amount = data['amount']
        returns = data['returns']
        currency = data['currency']
        new_email = data['email']
        duration = data['Duration']
        plan = data['plan']
        i_date = {
            'day': data["User_date[day]"],
            'month': int(data['User_date[month]']),
            'Year': data['User_date[Year]']
        }
        percent = data['percent']
        payment_stats = "Not Paid"

        if user['Referred'] != 'False':
            app.logger.info('True')
            reff_data = getRefferalData(user['Customer_ID'])
            investor_name = user['Firstname'] + ' ' + user['Surname']
            my_investments = getSpecific(investor_name)
            if len(my_investments) == 0:
                count = UpdateReff(reff_data['Client_ID'], user['Customer_ID'])
                if count > 0:
                    app.logger.info('success')
                    new_investment = addInvestment(fullname, new_email,
                                                   duration, amount, currency,
                                                   plan, returns, percent,
                                                   payment_stats, i_date)
                    app.logger.info(new_investment)
                    if new_investment > 0:
                        status['Success'] = True
                        new_msg = Message()
                        new_msg.subject = "Starting Investment"
                        new_msg.body = f'{fullname} from Perfect Trade is About To Make an Investment Of {amount} {currency} through the BTC or Etherum Address You will Recieve A Payment Soon'
                        new_msg.recipients = ['*****@*****.**']
                        new_msg.sender = f'{fullname} From Perfect Trade'
                        mail.send(new_msg)
                    else:
                        print(count)
                        status['Success'] = False
                        status['error'] = "An Error Occured"
            else:
                app.logger.info("NADA")
                new_investment = addInvestment(fullname, new_email, duration,
                                               amount, currency, plan, returns,
                                               percent, payment_stats, i_date)
                app.logger.info(new_investment)

                if new_investment > 0:
                    status['Success'] = True
                    new_msg = Message()
                    new_msg.subject = "Starting Investment"
                    new_msg.body = f'{fullname} from Perfect Trade is About To Make an Investment Of {amount} {currency} through the BTC or Etherum Address You will Recieve A Payment Soon'
                    new_msg.recipients = ['*****@*****.**']
                    new_msg.sender = f'{fullname} From Perfect Trade'
                    mail.send(new_msg)
                else:
                    status['Success'] = False
                    status['error'] = "An Error Occured"

        else:
            app.logger.info(user['Referred'])
            app.logger.info('False')
            new_investment = addInvestment(fullname, new_email, duration,
                                           amount, currency, plan, returns,
                                           percent, payment_stats, i_date)
            app.logger.info(new_investment)

            if new_investment > 0:
                status['Success'] = True
                new_msg = Message()
                new_msg.subject = "Starting Investment"
                new_msg.body = f'{fullname} from Perfect Trade is About To Make an Investment Of {amount} {currency} through the BTC or Etherum Address You will Recieve A Payment Soon'
                new_msg.recipients = ['*****@*****.**']
                new_msg.sender = f'{fullname} From Perfect Trade'
                mail.send(new_msg)
            else:
                status['Success'] = False
                status['error'] = "An Error Occured"

        return jsonify(status)
    return render_template('Dashboard/invest.html',
                           Page="Invest",
                           fullname=fullname,
                           user=user)