453a29c9d95ecd2fa75ee4fa4e394b7b3aa7c09f.html (16787B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 5 <title>better handling for sessionkey and pendinginfo - getdafuckouttahere.net - Unnamed repository; edit this file 'description' to name the repository. 6 </title> 7 <link rel="icon" type="image/png" href="../favicon.png" /> 8 <link rel="alternate" type="application/atom+xml" title="getdafuckouttahere.net Atom Feed" href="../atom.xml" /> 9 <link rel="alternate" type="application/atom+xml" title="getdafuckouttahere.net Atom Feed (tags)" href="../tags.xml" /> 10 <link rel="stylesheet" type="text/css" href="../style.css" /> 11 </head> 12 <body> 13 <table><tr><td><a href="../../"><img src="../logo.png" alt="" width="32" height="32" /></a></td><td><h1>getdafuckouttahere.net</h1><span class="desc">Unnamed repository; edit this file 'description' to name the repository. 14 </span></td></tr><tr><td></td><td> 15 <a href="../log.html">Log</a> | <a href="../files.html">Files</a> | <a href="../refs.html">Refs</a></td></tr></table> 16 <hr/> 17 <div id="content"> 18 <pre><b>commit</b> <a href="../commit/453a29c9d95ecd2fa75ee4fa4e394b7b3aa7c09f.html">453a29c9d95ecd2fa75ee4fa4e394b7b3aa7c09f</a> 19 <b>parent</b> <a href="../commit/f88862ebd308659e5ac56b166f8534cfe486f3ae.html">f88862ebd308659e5ac56b166f8534cfe486f3ae</a> 20 <b>Author:</b> rob <<a href="mailto:rob@tarina.org">rob@tarina.org</a>> 21 <b>Date:</b> Tue, 26 Oct 2021 20:26:34 +0300 22 23 better handling for sessionkey and pendinginfo 24 25 <b>Diffstat:</b> 26 <table><tr><td class="M">M</td><td><a href="#h0">public_html/templates/index.html</a></td><td> | </td><td class="num">2</td><td><span class="i">+</span><span class="d">-</span></td></tr> 27 <tr><td class="M">M</td><td><a href="#h1">public_html/templates/pending.html</a></td><td> | </td><td class="num">2</td><td><span class="i">+</span><span class="d">-</span></td></tr> 28 <tr><td class="M">M</td><td><a href="#h2">server.py</a></td><td> | </td><td class="num">65</td><td><span class="i">++++++++++++++++++++++++++++++++++</span><span class="d">-------------------------------</span></td></tr> 29 </table></pre><pre>3 files changed, 36 insertions(+), 33 deletions(-) 30 <hr/><b>diff --git a/<a id="h0" href="../file/public_html/templates/index.html.html">public_html/templates/index.html</a> b/<a href="../file/public_html/templates/index.html.html">public_html/templates/index.html</a></b> 31 <a href="#h0-0" id="h0-0" class="h">@@ -59,6 +59,6 @@ $if bag != []: 32 </a> $if tot > 0: 33 <br> 34 total: $(tot)&euro; or in real money $int(b.convert_to_btc(tot, 'EUR') * 100000000) Satoshi 35 <a href="#h0-0-3" id="h0-0-3" class="d">- <a href="/checkout/">Checkout</a> 36 </a><a href="#h0-0-4" id="h0-0-4" class="i">+ <a href="/checkout">Checkout</a> 37 </a> </div> 38 </div> 39 <b>diff --git a/<a id="h1" href="../file/public_html/templates/pending.html.html">public_html/templates/pending.html</a> b/<a href="../file/public_html/templates/pending.html.html">public_html/templates/pending.html</a></b> 40 <a href="#h1-0" id="h1-0" class="h">@@ -38,7 +38,7 @@ $if tot > 0: 41 </a> total: $(tot)&euro; or in real money $int(b.convert_to_btc(tot, 'EUR') * 100000000) Satoshi 42 </h3> 43 <br> 44 <a href="#h1-0-3" id="h1-0-3" class="d">-<a href="/checkout/$pending_key">Go back!</a> 45 </a><a href="#h1-0-4" id="h1-0-4" class="i">+<a href="/checkout">Go back!</a> 46 </a> <div id="addevent"> 47 <form method="POST"> 48 $:pendingform.render() 49 <b>diff --git a/<a id="h2" href="../file/server.py.html">server.py</a> b/<a href="../file/server.py.html">server.py</a></b> 50 <a href="#h2-0" id="h2-0" class="h">@@ -26,8 +26,8 @@ urls = ( 51 </a> '/payln/(.*)', 'payln', 52 '/paybtc/(.*)', 'paybtc', 53 '/payment/(.*)', 'payment', 54 <a href="#h2-0-3" id="h2-0-3" class="d">- '/checkout/(.*)', 'checkout', 55 </a><a href="#h2-0-4" id="h2-0-4" class="d">- '/pending/(.*)', 'pending', 56 </a><a href="#h2-0-5" id="h2-0-5" class="i">+ '/checkout', 'checkout', 57 </a><a href="#h2-0-6" id="h2-0-6" class="i">+ '/pending', 'pending', 58 </a> '/thankyou', 'thankyou', 59 '/login', 'login', 60 '/logout', 'logout', 61 <a href="#h2-1" id="h2-1" class="h">@@ -216,6 +216,13 @@ def organizepics(product): 62 </a> os.system(mv + mv2) 63 organized_nr += 1 64 65 <a href="#h2-1-3" id="h2-1-3" class="i">+def getpendinginfo(): 66 </a><a href="#h2-1-4" id="h2-1-4" class="i">+ try: 67 </a><a href="#h2-1-5" id="h2-1-5" class="i">+ pendinginfo = db.select('pending', where="invoice_key='" + session.sessionkey + "'", what='country, firstname, lastname, address, town, postalcode, email')[0] 68 </a><a href="#h2-1-6" id="h2-1-6" class="i">+ except: 69 </a><a href="#h2-1-7" id="h2-1-7" class="i">+ pendinginfo = '' 70 </a><a href="#h2-1-8" id="h2-1-8" class="i">+ return pendinginfo 71 </a><a href="#h2-1-9" id="h2-1-9" class="i">+ 72 </a> class index(): 73 def GET(self): 74 checkforoldbags() 75 <a href="#h2-2" id="h2-2" class="h">@@ -290,52 +297,48 @@ class checkout: 76 </a> web.form.Textbox('postalcode', web.form.regexp('\d+', 'number thanx!'), web.form.notnull, description="Postalcode / zip"), 77 web.form.Textbox('email', web.form.notnull, description="Email:"), 78 web.form.Button('Calculate shipping cost')) 79 <a href="#h2-2-3" id="h2-2-3" class="d">- def GET(self, pending_key): 80 </a><a href="#h2-2-4" id="h2-2-4" class="i">+ 81 </a><a href="#h2-2-5" id="h2-2-5" class="i">+ def GET(self): 82 </a> #checkavailable() 83 checkoutform = self.form() 84 <a href="#h2-2-8" id="h2-2-8" class="d">- if pending_key: 85 </a><a href="#h2-2-9" id="h2-2-9" class="d">- oldinfo = db.select('pending', where="invoice_key='" + pending_key + "'", what='country, firstname, lastname, address, town, postalcode, email') 86 </a><a href="#h2-2-10" id="h2-2-10" class="d">- oldinfo = oldinfo[0] 87 </a><a href="#h2-2-11" id="h2-2-11" class="d">- checkoutform.fill(country=oldinfo.country, firstname=oldinfo.firstname, lastname=oldinfo.lastname, address=oldinfo.address, town=oldinfo.town, postalcode=oldinfo.postalcode, email=oldinfo.email) 88 </a><a href="#h2-2-12" id="h2-2-12" class="i">+ pendinginfo = getpendinginfo() 89 </a><a href="#h2-2-13" id="h2-2-13" class="i">+ if pendinginfo: 90 </a><a href="#h2-2-14" id="h2-2-14" class="i">+ checkoutform.fill(country=pendinginfo.country, firstname=pendinginfo.firstname, lastname=pendinginfo.lastname, address=pendinginfo.address, town=pendinginfo.town, postalcode=pendinginfo.postalcode, email=pendinginfo.email) 91 </a> b = BtcConverter() 92 bag = db.query("SELECT * FROM customerbag WHERE sessionkey='" + session.sessionkey +"';") 93 return render.checkout(checkoutform, bag, b, productname, float) 94 <a href="#h2-2-18" id="h2-2-18" class="d">- def POST(self, pending_key): 95 </a><a href="#h2-2-19" id="h2-2-19" class="i">+ def POST(self): 96 </a> checkoutform = self.form() 97 <a href="#h2-2-21" id="h2-2-21" class="i">+ pendinginfo = getpendinginfo() 98 </a> i = web.input() 99 if i.country != 'NO-SHIPPING': 100 if not checkoutform.validates(): 101 b = BtcConverter() 102 return render.checkout(checkoutform, session.bag, b) 103 <a href="#h2-2-27" id="h2-2-27" class="d">- if pending_key: 104 </a><a href="#h2-2-28" id="h2-2-28" class="d">- db.update('pending', where="invoice_key='" + pending_key +"'", country=i.country, firstname=i.firstname, lastname=i.lastname, address=i.address, town=i.town, postalcode=i.postalcode, email=i.email, dateadded=datetime.datetime.now()) 105 </a><a href="#h2-2-29" id="h2-2-29" class="i">+ if pendinginfo: 106 </a><a href="#h2-2-30" id="h2-2-30" class="i">+ db.update('pending', where="invoice_key='" + session.sessionkey +"'", country=i.country, firstname=i.firstname, lastname=i.lastname, address=i.address, town=i.town, postalcode=i.postalcode, email=i.email, dateadded=datetime.datetime.now()) 107 </a> else: 108 <a href="#h2-2-32" id="h2-2-32" class="d">- pending_key = session.sessionkey 109 </a><a href="#h2-2-33" id="h2-2-33" class="d">- db.insert('pending', invoice_key=pending_key, country=i.country, firstname=i.firstname, lastname=i.lastname, address=i.address, town=i.town, postalcode=i.postalcode, email=i.email, dateadded=datetime.datetime.now()) 110 </a><a href="#h2-2-34" id="h2-2-34" class="d">- raise web.seeother('/pending/' + pending_key) 111 </a><a href="#h2-2-35" id="h2-2-35" class="i">+ db.insert('pending', invoice_key=session.sessionkey, country=i.country, firstname=i.firstname, lastname=i.lastname, address=i.address, town=i.town, postalcode=i.postalcode, email=i.email, dateadded=datetime.datetime.now()) 112 </a><a href="#h2-2-36" id="h2-2-36" class="i">+ raise web.seeother('/pending') 113 </a> 114 class pending: 115 form = web.form.Form( 116 web.form.Dropdown('payment', ['Bitcoin Lightning', 'Bitcoin'], web.form.notnull, description="Select payment method"), 117 web.form.Button('Pay')) 118 <a href="#h2-2-42" id="h2-2-42" class="d">- def GET(self, pending_key): 119 </a><a href="#h2-2-43" id="h2-2-43" class="i">+ def GET(self): 120 </a> #checkavailable() 121 pendingform = self.form() 122 <a href="#h2-2-46" id="h2-2-46" class="d">- if pending_key: 123 </a><a href="#h2-2-47" id="h2-2-47" class="d">- pendinginfo = db.select('pending', where="invoice_key='" + pending_key + "'", what='country, firstname, lastname, address, town, postalcode, email') 124 </a><a href="#h2-2-48" id="h2-2-48" class="d">- pendinginfo = pendinginfo[0] 125 </a><a href="#h2-2-49" id="h2-2-49" class="d">- shippinginfo = db.select('shipping', where="country='" + pendinginfo.country + "'", what='price, days') 126 </a><a href="#h2-2-50" id="h2-2-50" class="d">- shippinginfo = shippinginfo[0] 127 </a><a href="#h2-2-51" id="h2-2-51" class="i">+ pendinginfo = getpendinginfo() 128 </a><a href="#h2-2-52" id="h2-2-52" class="i">+ if pendinginfo: 129 </a><a href="#h2-2-53" id="h2-2-53" class="i">+ shippinginfo = db.select('shipping', where="country='" + pendinginfo.country + "'", what='price, days')[0] 130 </a> b = BtcConverter() 131 bag = db.query("SELECT * FROM customerbag WHERE sessionkey='" + session.sessionkey +"';") 132 <a href="#h2-2-56" id="h2-2-56" class="d">- return render.pending(pending_key, pendingform, pendinginfo, shippinginfo, bag, b, productname, float) 133 </a><a href="#h2-2-57" id="h2-2-57" class="d">- def POST(self, pending_key): 134 </a><a href="#h2-2-58" id="h2-2-58" class="i">+ return render.pending(session.sessionkey, pendingform, pendinginfo, shippinginfo, bag, b, productname, float) 135 </a><a href="#h2-2-59" id="h2-2-59" class="i">+ def POST(self): 136 </a> pendingform = self.form() 137 <a href="#h2-2-61" id="h2-2-61" class="d">- if pending_key: 138 </a><a href="#h2-2-62" id="h2-2-62" class="d">- pendinginfo = db.select('pending', where="invoice_key='" + pending_key + "'", what='country, firstname, lastname, address, town, postalcode, email') 139 </a><a href="#h2-2-63" id="h2-2-63" class="d">- pendinginfo = pendinginfo[0] 140 </a><a href="#h2-2-64" id="h2-2-64" class="d">- shippinginfo = db.select('shipping', where="country='" + pendinginfo.country + "'", what='price, days') 141 </a><a href="#h2-2-65" id="h2-2-65" class="d">- shippinginfo = shippinginfo[0] 142 </a><a href="#h2-2-66" id="h2-2-66" class="i">+ pendinginfo = getpendinginfo() 143 </a><a href="#h2-2-67" id="h2-2-67" class="i">+ if pendinginfo: 144 </a><a href="#h2-2-68" id="h2-2-68" class="i">+ shippinginfo = db.select('shipping', where="country='" + pendinginfo.country + "'", what='price, days')[0] 145 </a> i = web.input() 146 #if session.bag != []: 147 totalamount = 0 148 <a href="#h2-3" id="h2-3" class="h">@@ -355,7 +358,7 @@ class pending: 149 </a> #else: 150 # web.seeother('/') 151 #make lightning invoice 152 <a href="#h2-3-3" id="h2-3-3" class="d">- invoice = createinvoice(totsats, description, pending_key) 153 </a><a href="#h2-3-4" id="h2-3-4" class="i">+ invoice = createinvoice(totsats, description, session.sessionkey) 154 </a> callsubprocess('qrencode -s 5 -o '+ staticdir + 'qr/' + invoice['id']+'.png ' + invoice['payreq']) 155 #make bitcoin address 156 bitcoinrpc = AuthServiceProxy(rpcauth) 157 <a href="#h2-4" id="h2-4" class="h">@@ -367,7 +370,7 @@ class pending: 158 </a> db.query("DELETE FROM invoices WHERE invoice_key='" + session.sessionkey +"';") 159 except: 160 print('no old invoices to delete') 161 <a href="#h2-4-3" id="h2-4-3" class="d">- db.insert('invoices', invoice_key=pending_key, btc=newaddress, ln=invoice['id'], products=description, payment=i.payment, amount=totalamount, totsats=totsats, timestamp=time.strftime('%Y-%m-%d %H:%M:%S')) 162 </a><a href="#h2-4-4" id="h2-4-4" class="i">+ db.insert('invoices', invoice_key=session.sessionkey, btc=newaddress, ln=invoice['id'], products=description, payment=i.payment, amount=totalamount, totsats=totsats, timestamp=time.strftime('%Y-%m-%d %H:%M:%S')) 163 </a> # send mail to op 164 msg = 'You got a new order, from ' + pendinginfo.firstname + ' ' + pendinginfo.lastname + ' from ' + pendinginfo.country + ' email: ' + pendinginfo.email + ' this dude wantz ' + description + ' for ' + str(int(totalamount/100)) + '€ ' + ' with ' + i.payment 165 sendmail(webmaster, 'GetDaFuckOuttaHere Shop', msg) 166 <a href="#h2-5" id="h2-5" class="h">@@ -377,12 +380,12 @@ class pending: 167 </a> if i.payment == 'Bitcoin Lightning': 168 paymentlink = 'payln/' 169 if pendinginfo.email != '': 170 <a href="#h2-5-3" id="h2-5-3" class="d">- msg = "Thank you for ordering " + description + " at GetDaFuckOuttaHere Shop, we'll be processing your order as soon as possible and send it to " + pendinginfo.firstname + ' ' + pendinginfo.lastname + ', ' + pendinginfo.address + ', ' + str(pendinginfo.postalcode) + ', ' + pendinginfo.town + ', ' + pendinginfo.country + '. To pay/view status of your order please visit ' + baseurl + paymentlink + pending_key 171 </a><a href="#h2-5-4" id="h2-5-4" class="i">+ msg = "Thank you for ordering " + description + " at GetDaFuckOuttaHere Shop, we'll be processing your order as soon as possible and send it to " + pendinginfo.firstname + ' ' + pendinginfo.lastname + ', ' + pendinginfo.address + ', ' + str(pendinginfo.postalcode) + ', ' + pendinginfo.town + ', ' + pendinginfo.country + '. To pay/view status of your order please visit ' + baseurl + paymentlink + session.sessionkey 172 </a> sendmail(pendinginfo.email, 'GetDaFuckOuttaHere Shop', msg) 173 if i.payment == 'Bitcoin': 174 <a href="#h2-5-7" id="h2-5-7" class="d">- return web.seeother('/paybtc/' + pending_key) 175 </a><a href="#h2-5-8" id="h2-5-8" class="i">+ return web.seeother('/paybtc/' + session.sessionkey) 176 </a> if i.payment == 'Bitcoin Lightning': 177 <a href="#h2-5-10" id="h2-5-10" class="d">- return web.seeother('/payln/' + pending_key) 178 </a><a href="#h2-5-11" id="h2-5-11" class="i">+ return web.seeother('/payln/' + session.sessionkey) 179 </a> else: 180 return web.seeother('/') 181 182 </pre> 183 </div> 184 </body> 185 </html>