thiswebshoprules

git clone https://git.tarina.org/thiswebshoprules
Log | Files | Refs

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 &#39;description&#39; 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 &#39;description&#39; 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 &lt;<a href="mailto:rob@tarina.org">rob@tarina.org</a>&gt;
     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 &gt; 0:
     33      &lt;br&gt;
     34      total: $(tot)&amp;euro; or in real money $int(b.convert_to_btc(tot, &#39;EUR&#39;) * 100000000) Satoshi
     35 <a href="#h0-0-3" id="h0-0-3" class="d">-    &lt;a href=&quot;/checkout/&quot;&gt;Checkout&lt;/a&gt;
     36 </a><a href="#h0-0-4" id="h0-0-4" class="i">+    &lt;a href=&quot;/checkout&quot;&gt;Checkout&lt;/a&gt;
     37 </a>     &lt;/div&gt;
     38  &lt;/div&gt;
     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 &gt; 0:
     41 </a>     total: $(tot)&amp;euro; or in real money $int(b.convert_to_btc(tot, &#39;EUR&#39;) * 100000000) Satoshi
     42  &lt;/h3&gt;
     43  &lt;br&gt;
     44 <a href="#h1-0-3" id="h1-0-3" class="d">-&lt;a href=&quot;/checkout/$pending_key&quot;&gt;Go back!&lt;/a&gt;
     45 </a><a href="#h1-0-4" id="h1-0-4" class="i">+&lt;a href=&quot;/checkout&quot;&gt;Go back!&lt;/a&gt;
     46 </a> &lt;div id=&quot;addevent&quot;&gt;
     47  &lt;form method=&quot;POST&quot;&gt;
     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>     &#39;/payln/(.*)&#39;, &#39;payln&#39;,
     52      &#39;/paybtc/(.*)&#39;, &#39;paybtc&#39;,
     53      &#39;/payment/(.*)&#39;, &#39;payment&#39;,
     54 <a href="#h2-0-3" id="h2-0-3" class="d">-    &#39;/checkout/(.*)&#39;, &#39;checkout&#39;,
     55 </a><a href="#h2-0-4" id="h2-0-4" class="d">-    &#39;/pending/(.*)&#39;, &#39;pending&#39;,
     56 </a><a href="#h2-0-5" id="h2-0-5" class="i">+    &#39;/checkout&#39;, &#39;checkout&#39;,
     57 </a><a href="#h2-0-6" id="h2-0-6" class="i">+    &#39;/pending&#39;, &#39;pending&#39;,
     58 </a>     &#39;/thankyou&#39;, &#39;thankyou&#39;,
     59      &#39;/login&#39;, &#39;login&#39;,
     60      &#39;/logout&#39;, &#39;logout&#39;,
     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(&#39;pending&#39;, where=&quot;invoice_key=&#39;&quot; + session.sessionkey + &quot;&#39;&quot;, what=&#39;country, firstname, lastname, address, town, postalcode, email&#39;)[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 = &#39;&#39;
     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(&#39;postalcode&#39;, web.form.regexp(&#39;\d+&#39;, &#39;number thanx!&#39;), web.form.notnull, description=&quot;Postalcode / zip&quot;),
     77      web.form.Textbox(&#39;email&#39;, web.form.notnull, description=&quot;Email:&quot;),
     78      web.form.Button(&#39;Calculate shipping cost&#39;))
     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(&#39;pending&#39;, where=&quot;invoice_key=&#39;&quot; + pending_key + &quot;&#39;&quot;, what=&#39;country, firstname, lastname, address, town, postalcode, email&#39;)
     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(&quot;SELECT * FROM customerbag WHERE sessionkey=&#39;&quot; + session.sessionkey +&quot;&#39;;&quot;)
     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 != &#39;NO-SHIPPING&#39;:
    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(&#39;pending&#39;, where=&quot;invoice_key=&#39;&quot; + pending_key +&quot;&#39;&quot;, 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(&#39;pending&#39;, where=&quot;invoice_key=&#39;&quot; + session.sessionkey +&quot;&#39;&quot;, 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(&#39;pending&#39;, 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(&#39;/pending/&#39; + pending_key)
    111 </a><a href="#h2-2-35" id="h2-2-35" class="i">+            db.insert(&#39;pending&#39;, 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(&#39;/pending&#39;)
    113 </a> 
    114  class pending:
    115      form = web.form.Form(
    116      web.form.Dropdown(&#39;payment&#39;, [&#39;Bitcoin Lightning&#39;, &#39;Bitcoin&#39;], web.form.notnull, description=&quot;Select payment method&quot;),
    117      web.form.Button(&#39;Pay&#39;))
    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(&#39;pending&#39;, where=&quot;invoice_key=&#39;&quot; + pending_key + &quot;&#39;&quot;, what=&#39;country, firstname, lastname, address, town, postalcode, email&#39;)
    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(&#39;shipping&#39;, where=&quot;country=&#39;&quot; + pendinginfo.country + &quot;&#39;&quot;, what=&#39;price, days&#39;)
    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(&#39;shipping&#39;, where=&quot;country=&#39;&quot; + pendinginfo.country + &quot;&#39;&quot;, what=&#39;price, days&#39;)[0]
    130 </a>         b = BtcConverter()
    131          bag = db.query(&quot;SELECT * FROM customerbag WHERE sessionkey=&#39;&quot; + session.sessionkey +&quot;&#39;;&quot;)
    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(&#39;pending&#39;, where=&quot;invoice_key=&#39;&quot; + pending_key + &quot;&#39;&quot;, what=&#39;country, firstname, lastname, address, town, postalcode, email&#39;)
    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(&#39;shipping&#39;, where=&quot;country=&#39;&quot; + pendinginfo.country + &quot;&#39;&quot;, what=&#39;price, days&#39;)
    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(&#39;shipping&#39;, where=&quot;country=&#39;&quot; + pendinginfo.country + &quot;&#39;&quot;, what=&#39;price, days&#39;)[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(&#39;/&#39;)
    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(&#39;qrencode -s 5 -o &#39;+ staticdir + &#39;qr/&#39; + invoice[&#39;id&#39;]+&#39;.png &#39; + invoice[&#39;payreq&#39;])
    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(&quot;DELETE FROM invoices WHERE invoice_key=&#39;&quot; + session.sessionkey +&quot;&#39;;&quot;)
    159              except:
    160                  print(&#39;no old invoices to delete&#39;)
    161 <a href="#h2-4-3" id="h2-4-3" class="d">-            db.insert(&#39;invoices&#39;, invoice_key=pending_key, btc=newaddress, ln=invoice[&#39;id&#39;], products=description, payment=i.payment, amount=totalamount, totsats=totsats, timestamp=time.strftime(&#39;%Y-%m-%d %H:%M:%S&#39;))
    162 </a><a href="#h2-4-4" id="h2-4-4" class="i">+            db.insert(&#39;invoices&#39;, invoice_key=session.sessionkey, btc=newaddress, ln=invoice[&#39;id&#39;], products=description, payment=i.payment, amount=totalamount, totsats=totsats, timestamp=time.strftime(&#39;%Y-%m-%d %H:%M:%S&#39;))
    163 </a>             # send mail to op
    164              msg = &#39;You got a new order, from &#39; + pendinginfo.firstname + &#39; &#39; + pendinginfo.lastname + &#39; from &#39; + pendinginfo.country + &#39; email: &#39; + pendinginfo.email + &#39; this dude wantz &#39; + description + &#39; for &#39; + str(int(totalamount/100)) + &#39;€ &#39; + &#39; with &#39; + i.payment
    165              sendmail(webmaster, &#39;GetDaFuckOuttaHere Shop&#39;, msg)
    166 <a href="#h2-5" id="h2-5" class="h">@@ -377,12 +380,12 @@ class pending:
    167 </a>             if i.payment == &#39;Bitcoin Lightning&#39;:
    168                  paymentlink = &#39;payln/&#39;
    169              if pendinginfo.email != &#39;&#39;:
    170 <a href="#h2-5-3" id="h2-5-3" class="d">-                msg = &quot;Thank you for ordering &quot; + description + &quot; at GetDaFuckOuttaHere Shop, we&#39;ll be processing your order as soon as possible and send it to &quot; + pendinginfo.firstname + &#39; &#39; + pendinginfo.lastname + &#39;, &#39; + pendinginfo.address + &#39;, &#39; + str(pendinginfo.postalcode) + &#39;, &#39; + pendinginfo.town + &#39;, &#39; + pendinginfo.country + &#39;. To pay/view status of your order please visit &#39; + baseurl + paymentlink + pending_key
    171 </a><a href="#h2-5-4" id="h2-5-4" class="i">+                msg = &quot;Thank you for ordering &quot; + description + &quot; at GetDaFuckOuttaHere Shop, we&#39;ll be processing your order as soon as possible and send it to &quot; + pendinginfo.firstname + &#39; &#39; + pendinginfo.lastname + &#39;, &#39; + pendinginfo.address + &#39;, &#39; + str(pendinginfo.postalcode) + &#39;, &#39; + pendinginfo.town + &#39;, &#39; + pendinginfo.country + &#39;. To pay/view status of your order please visit &#39; + baseurl + paymentlink + session.sessionkey
    172 </a>                 sendmail(pendinginfo.email, &#39;GetDaFuckOuttaHere Shop&#39;, msg)
    173              if i.payment == &#39;Bitcoin&#39;:
    174 <a href="#h2-5-7" id="h2-5-7" class="d">-                return web.seeother(&#39;/paybtc/&#39; + pending_key)
    175 </a><a href="#h2-5-8" id="h2-5-8" class="i">+                return web.seeother(&#39;/paybtc/&#39; + session.sessionkey)
    176 </a>             if i.payment == &#39;Bitcoin Lightning&#39;:
    177 <a href="#h2-5-10" id="h2-5-10" class="d">-                return web.seeother(&#39;/payln/&#39; + pending_key)
    178 </a><a href="#h2-5-11" id="h2-5-11" class="i">+                return web.seeother(&#39;/payln/&#39; + session.sessionkey)
    179 </a>         else:
    180              return web.seeother(&#39;/&#39;)
    181  
    182 </pre>
    183 </div>
    184 </body>
    185 </html>