def pay_for_order (): data=request.form address=data['address'] address=address[0:200] address=address.strip() if address=="": return "Error, empty address" bitcoin=Bitcoin() database=Database() #address=re.sub('[^A-Za-z0-9:_-]','',address) address_salt=address+configuration.Configuration.salt address_salt=address_salt.encode() address_hash=hashlib.sha224(address_salt).hexdigest()[0:9] address=address.replace('\n', '|') address = re.sub('[^A-Za-z0-9:_-|]', '', address) item_index=data['index'] item_amount=data['amount'] item_index=re.sub('[^0-9]', '', item_index) item_amount=re.sub('[^0-9]', '', item_amount) item1=database.fetch_one_item(item_index) order_price=round(item1.price/bitcoin.btc_eur*float(item_amount),6) #print (order_price) order=Bitcoin.order(item_index,address,address_hash,item_amount,order_price) #print (order.order_index) return redirect("/pay/"+str(order.btc_address))
def show_item(index): index=re.sub('[^0-9]', '', index) database=Database() bitcoin=Bitcoin() item1=database.fetch_one_item(index) if item1 is None: abort(404) else: return render_template('item.html',index=index,item=item1,rate=bitcoin.btc_eur,header=configuration.Configuration.header)
def order_item(index,amount): index=re.sub('[^0-9]', '', index) amount=re.sub('[^0-9]', '', amount) database=Database() bitcoin=Bitcoin() item1=database.fetch_one_item(index) #print(item1.pcs) if item1 is None: return 'Error' else: from flask_wtf import FlaskForm from wtforms import TextAreaField,validators class OrderForm(FlaskForm): address=TextAreaField('Address', [validators.Length(min=10, max=200)]) order_form=OrderForm() return render_template('order.html',item=item1, index=index,rate=bitcoin.btc_eur, amount=int(amount),form=order_form,header=configuration.Configuration.header)
def console(): if 'adminkey' not in session: return redirect('/login') elif (session['adminkey']!=hashlib.sha224(configuration.Configuration.secret_key.encode('utf-8')).hexdigest()): return redirect('/login') database=Database() orders=database.get_orders(0) orders_interest=[] for order in orders: if (order.paid>0) or (order.note is not None): item=database.fetch_one_item(order.item_index) order.item_name=item.name orders_interest.append(order) orders=orders_interest items=database.get_items() required_items=[] for item in items: item.pcs=",".join(str(x) for x in item.pcs) required_items.append(item) items=required_items return render_template('admin.html',orders=orders,items=items,header=configuration.Configuration.header)