diff options
author | Chris Xiong <chirs241097@gmail.com> | 2019-02-12 18:53:12 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2019-02-12 18:53:12 +0800 |
commit | d7b95f0d040deb1b34af31c7c8e2f66c1e37686e (patch) | |
tree | 282d9b605c70cedee96224f6625780a8d8a2f5ce | |
parent | ec9d9b4da39e6c74b8514bfaf623ed7ac310d128 (diff) | |
download | web-d7b95f0d040deb1b34af31c7c8e2f66c1e37686e.tar.xz |
First update.
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | History | 8 | ||||
-rwxr-xr-x | cgi/gb_newentry.cgi | 69 | ||||
-rw-r--r-- | common.css | 12 | ||||
-rw-r--r-- | index.html | 147 | ||||
-rw-r--r-- | libs/pictures/osunix-logo_sq_thicken.png | bin | 0 -> 692232 bytes | |||
-rw-r--r-- | theme0a.css | 3 | ||||
-rw-r--r-- | theme0b.css | 3 | ||||
-rw-r--r-- | theme1a.css | 3 | ||||
-rw-r--r-- | theme1b.css | 3 | ||||
-rw-r--r-- | theme2a.css | 3 | ||||
-rw-r--r-- | theme2b.css | 3 | ||||
-rw-r--r-- | theme3a.css | 3 | ||||
-rw-r--r-- | theme3b.css | 3 |
14 files changed, 184 insertions, 79 deletions
@@ -12,8 +12,11 @@ /libs/pictures/a /libs/pictures/b +/leave-a-message/messages /leave-a-message/messages.json /leave-a-message/messages.txt /leave-a-message/archive.txt +/grecaptcha_key + .directory @@ -1,3 +1,11 @@ +2019.02.12 +New guestbook (leave-a-message) backend. +Site update for separation of filestorage.chrisoft.org. + +2019.02.10 +Migrated to a mirror hosted by ConoHa. +Legacy PHP leave-a-message interface deprecated. + 2018.11.29 Set theme color. TSOP fixes. diff --git a/cgi/gb_newentry.cgi b/cgi/gb_newentry.cgi new file mode 100755 index 0000000..9e8c4dd --- /dev/null +++ b/cgi/gb_newentry.cgi @@ -0,0 +1,69 @@ +#!/usr/bin/python3 +import os,sys,html,json,datetime +import urllib.parse,urllib.request + +if os.environ['SERVER_NAME']!='chrisoft.org': + import socks,socket + socks.set_default_proxy(socks.SOCKS5,"127.0.0.1",1080) + socket.socket=socks.socksocket + def getaddrinfo(*args): + return [(socket.AF_INET,socket.SOCK_STREAM,6,'',(args[0],args[1]))] + socket.getaddrinfo=getaddrinfo + +def fail(x=None): + print('Status: 400 Bad Request',end='\r\n') + print('Content-type: text/plain',end='\r\n') + print(end='\r\n') + print('400.') + if x is not None:print(x) + exit() + +if os.environ['REQUEST_METHOD']!='POST': + fail() +try: + f=json.load(sys.stdin) +except Exception: + fail() + +try: + mname=urllib.parse.unquote(f['mname'],encoding='utf-8') + mcontent=urllib.parse.unquote(f['mcontent'],encoding='utf-8') + mname=html.escape(mname) + mcontent=html.escape(mcontent).replace('\n','<br>') + mtime=datetime.datetime.now(tz=datetime.timezone(datetime.timedelta(hours=8))).strftime('%Y-%m-%d %H:%M') +except Exception as e: + fail() + +if len(mname)+len(mcontent)>16384: + fail(x=':)') + +try: + with open(os.environ['DOCUMENT_ROOT']+'/grecaptcha_key',mode='r',encoding='utf-8') as gr_secret_f: + gr_secret=gr_secret_f.read() + req={'secret':gr_secret,'response':f['gr_ret'],'remoteip':os.environ['REMOTE_ADDR']} + r=urllib.request.Request('https://www.google.com/recaptcha/api/siteverify',data=urllib.parse.urlencode(req).encode('utf-8'),method='POST') + rr=urllib.request.urlopen(r,timeout=5) + rsp=json.loads(str(rr.read(),'utf-8')) + if not rsp['success'] or rsp['score']<0.6: + fail(x=':)') +except Exception as e: + fail(x=e) + +print('Status: 200 OK',end='\r\n') +print('Content-type: text/plain',end='\r\n') +print(end='\r\n') + +msgp=os.environ['DOCUMENT_ROOT']+'/leave-a-message/messages' +with open(msgp,mode='r',encoding='utf-8') as f: + o=json.load(f) +newm={'cont':mcontent,'author':mname,'time':mtime} +o.append(newm) +with open(msgp,mode='w',encoding='utf-8') as f: + json.dump(o,f) + +archivp=os.environ['DOCUMENT_ROOT']+'/leave-a-message/archive.txt' +with open(archivp,mode='a',encoding='utf-8') as f: + f.write(f'comment: {mcontent}\n') + f.write(f'author: {mname}\n') + f.write(f'time: {mtime}\n') + f.write(f'IP: {os.environ["REMOTE_ADDR"]}\n\n') @@ -54,15 +54,15 @@ button{ text-align:center; -webkit-transition-duration:0.4s; transition-duration:0.4s; - font-family: 'TeX Gyre Cursor', 'FreeMono', 'Courier New', Courier, monospace; + font-family: 'TeX Gyre Cursor', 'FreeMono', 'Courier New', Courier, monospace; font-variant-ligatures: none; } input[type="text"]{ - border: none; - border-bottom: 2px solid; - outline: none !important; - background-color: rgba(0,0,0,0) !important; - font-family: 'TeX Gyre Cursor', 'FreeMono', 'Courier New', Courier, monospace; + border: none; + border-bottom: 2px solid; + outline: none !important; + background-color: rgba(0,0,0,0) !important; + font-family: 'TeX Gyre Cursor', 'FreeMono', 'Courier New', Courier, monospace; font-variant-ligatures: none; } textarea{ @@ -17,11 +17,15 @@ <link rel="stylesheet" type="text/css" href="theme2b.css" id="theme2b"> <link rel="stylesheet" type="text/css" href="theme3a.css" id="theme3a"> <link rel="stylesheet" type="text/css" href="theme3b.css" id="theme3b"> +<script src="https://www.google.com/recaptcha/api.js?render=6LdCZ5AUAAAAAPL9Fooi8Zh3m0VTepvpNR9S4G5L"></script> <style> reduced{font-size:75%;} #msgform{width:50%;margin:auto;} @media (max-width:768px) {#msgform{width:auto;margin:1em;}} + .grecaptcha-badge{ + visibility: collapse !important; + } </style> </head> <!-- @@ -32,7 +36,7 @@ Contents are licensed under the CC BY-SA 4.0 license. <body onload="swonload();"> <script type="text/javascript" src="panel.js"></script> <script type="text/javascript"> -var rcaptcha=null; +var recaptcha=null; function changeImage(a,b){ document.getElementById(a).style.display='inline'; document.getElementById(b).style.display='none'; @@ -98,15 +102,11 @@ function toggleblkdisplay(e){ } function contsw(cont){ var lst=document.getElementById('content').getElementsByClassName('block'); + if(recaptcha&&typeof(recaptcha.execute)=='function') + recaptcha.execute('6LdCZ5AUAAAAAPL9Fooi8Zh3m0VTepvpNR9S4G5L',{action:cont}).then(function(t){}); for(var i=0;i<lst.length;++i) lst.item(i).style.display='none'; if(document.getElementById(cont)===null)cont='main'; - if(cont=='guestbook'&&rcaptcha===null) - { - rcaptcha=document.createElement('script'); - rcaptcha.setAttribute('src','https://www.google.com/recaptcha/api.js'); - document.body.appendChild(rcaptcha); - } document.getElementById(cont).style.display='block'; lst=document.getElementById('panellist').getElementsByTagName('a'); for(var i=0;i<lst.length;++i) @@ -121,22 +121,14 @@ function swonload(){ else unsetevents(); } window.onresize(); + if(grecaptcha) + grecaptcha.ready(function(){recaptcha=grecaptcha;}); loadTheme(); if(!location.hash.length)contsw('main'); else contsw(location.hash.substr(1)); var unsupportedpf=['Macintosh','MacIntel','MacPPC','Mac68K','iPhone','iPad','iPod']; if(unsupportedpf.indexOf(window.navigator.platform)!==-1) document.getElementById('appleouter').style.display='block'; - /*var h=new XMLHttpRequest(); - h.open("GET","/cgi/4or6.cgi?"+(new Date()).getTime()); - h.send(); - h.onload=function() - { - if(Number(h.responseText)==(6)) - document.getElementById("v6").style.display="block"; - else - document.getElementById("v4").style.display="block"; - }*/ } </script> <div id="panel" class="TText"> @@ -150,9 +142,6 @@ function swonload(){ <li><a id="linkslk" href="#links" onclick="contsw('links');">Links</a></li> <li><a href="javascript:showthemesw()">Themes</a></li> </ul> - <!--<div class="themesw"> - theme:<br><a href="./" onclick="changeTheme('day')"><img src="day.svg" alt="day"></a> <a href="./" onclick="changeTheme('night')"><img src="night.svg" alt="night"></a> <a href="./" onclick="changeTheme('auto')"><img src="auto.svg" alt="auto"></a> - </div>--> </div> <div id="content" class="TText"> <div class="block" id="main"> @@ -166,15 +155,13 @@ function swonload(){ <p> Have fun exploring! </p> - <!--<p> - (If you see Koishi instead of Yuyuko, you are reaching this site via IPv6.) - </p>--> <p id="appleouter" style="display:none;"> <b>Please read [<a href="https://stallman.org/apple.html" rel="external" target="_blank" onclick="document.getElementById('apple').style.display='block';">this</a>] in case of any trouble, Your Excellency.</b> <div id="apple" class="block" style="display:none;"><p> The owner of this site doesn't have any Apple devices that can go online so you may experience major problems browsing this site. If you consider this unacceptable, you may donate me an Apple device. Please mail your generous donation to <code>/dev/null</code>. </p></div> </p> + <p style="font-size:75%;text-indent:2.67em;">This site uses reCAPTCHA for traffic analysis. <a href="https://policies.google.com/terms">Terms</a> and <a href="https://policies.google.com/privacy">privacy policy</a> of Google may apply.</p> </div> <div class="block" id="projects"> <h2>Projects</h2><hr> @@ -323,7 +310,7 @@ function swonload(){ </li> <li>Chris' Timidity Player (2012) <reduced> - <a id="timidityplyr" href="./inactive/TimidityPlayer.tar.xz">[archive]</a> + <a id="timidityplyr" href="//filestorage.chrisoft.org/inactive/TimidityPlayer.tar.xz">[archive]</a> <a href="javascript:toggleblkdisplay('tmidp-desc')">[short desc.]</a> </reduced> <div class="block" id="tmidp-desc"> @@ -333,7 +320,7 @@ function swonload(){ </li> <li>Simple Tester for OI (2012) <reduced> - <a href="./inactive/Tester.tar.xz">[archive]</a> + <a href="//filestorage.chrisoft.org/inactive/Tester.tar.xz">[archive]</a> <a href="javascript:toggleblkdisplay('testr-desc')">[short desc.]</a> </reduced> <div class="block" id="testr-desc"> @@ -361,7 +348,7 @@ function swonload(){ </li> <li>Cross Noodles (Virtools) (2012) <reduced> - <a href="./Cross_Noodles.html">[details]</a> + <a href="//cgit.chrisoft.org/oddities.git/tree/Virtools/Cross_Noodles.cmo">[details]</a> <a href="javascript:toggleblkdisplay('crxnd-desc')">[short desc.]</a> </reduced> <div class="block" id="crxnd-desc"> @@ -370,7 +357,7 @@ function swonload(){ </li> <li>Compiz 0.9.7.99 (2012-2016) <reduced> - <a href="./data/compiz0.9.7.9.tar.xz">[archive]</a> + <a href="//filestorage.chrisoft.org/inactive/compiz0.9.7.9.tar.xz">[archive]</a> <a href="javascript:toggleblkdisplay('cmpz-desc')">[short desc.]</a> </reduced> <div class="block" id="cmpz-desc"> @@ -381,7 +368,6 @@ function swonload(){ </li> <li>Minesweeper in HGE (2012) <reduced> - <a href="./data/minesweeper.zip">[archive]</a> <a href="javascript:toggleblkdisplay('mswp-desc')">[short desc.]</a> </reduced> <div class="block" id="mswp-desc"> @@ -390,7 +376,7 @@ function swonload(){ </li> <li>Desktop (2012) <reduced> - <a href="./inactive/Desktop.tar.xz">[archive]</a> + <a href="//filestorage.chrisoft.org/inactive/Desktop.tar.xz">[archive]</a> <a href="javascript:toggleblkdisplay('dskt-desc')">[short desc.]</a> </reduced> <div class="block" id="dskt-desc"> @@ -469,9 +455,9 @@ function swonload(){ <p> Music arranged and some, composed, by me. </p> - <h3><a href="./libs/pictures">Picture Library</a></h3> + <h3><a href="./libs/pictures/osunix-logo_sq_thicken.png">Picture Library</a></h3> <p> - My collection of pictures from the Internet. + Nothin'. </p> <h3><a href="//cgit.chrisoft.org">Code Library</a></h3> <p> @@ -481,6 +467,7 @@ function swonload(){ <div class="block" id="guestbook"> <h2>Leave a Message</h2><hr> <p style="font-size:75%;"> + All times are in CST (UTC+8). Messages are <b>not</b> censored (except messages for testing, which would be deleted shortly after posting; advertising is also prohibited). @@ -493,57 +480,79 @@ function swonload(){ <div id="commentdiv"> </div> <script> - function verify() + function gb_send() { - if(document.getElementById("mcontent").value.length+document.getElementById("mname").value.length>16300)return; + if(document.getElementById("mcontent").value.length+document.getElementById("mname").value.length>16300) + alert('super duper secure client side security'); + document.getElementById('button_send').innerHTML='...'; + document.getElementById('button_send').disabled=true; try { - if(grecaptcha.getResponse().length===0) - document.getElementById("ann").style.display="inline-block"; - else document.getElementById("msgform").submit(); + recaptcha.execute('6LdCZ5AUAAAAAPL9Fooi8Zh3m0VTepvpNR9S4G5L',{action:'guestbook_newentry'}).then( + function(t){ + var h=new XMLHttpRequest(); + var f={}; + f.mname=encodeURIComponent(document.getElementById('mname').value); + f.mcontent=encodeURIComponent(document.getElementById('mcontent').value); + f.gr_ret=t; + h.open('POST','/cgi/gb_newentry.cgi'); + h.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + h.send(JSON.stringify(f)); + h.onerror=function(){ + alert('You broke something, or something broke itself...'); + document.getElementById('button_send').innerHTML='Leave the message!'; + document.getElementById('button_send').disabled=false; + }; + h.onload=function(){ + gb_load(); + document.getElementById('button_send').innerHTML='Leave the message!'; + document.getElementById('button_send').disabled=false; + }; + } + ); } catch(e){return;} } - var h=new XMLHttpRequest(); - h.open("GET","/leave-a-message/messages.json?"+(new Date()).getTime()); - h.send(); - h.onload=function() + function gb_load() { - var r=h.responseText.split('\n'); - for(var i=r.length-1;i>=0;--i) + while(document.getElementById('commentdiv').firstChild) + document.getElementById('commentdiv').removeChild(document.getElementById('commentdiv').firstChild); + var h=new XMLHttpRequest(); + h.open("GET","/leave-a-message/messages?"+(new Date()).getTime()); + h.send(); + h.onload=function() { - r[i].trim(); - if(!r[i])continue; - var o=JSON.parse(r[i]); - if(o.cont===undefined||o.cont===null) - continue; - var e=document.createElement('div'); - e.classList.add('comment'); - var p=document.createElement('div'); - p.style.padding='0.5em 0 0.5em 0.5em'; - p.innerHTML=o.cont; - var t=document.createElement('div'); - t.classList.add('author'); - if(!o.author.length)o.author='Anonymous'; - t.innerHTML=o.author+" at "+o.time; - e.appendChild(p); - e.appendChild(t); - document.getElementById('commentdiv').appendChild(e); + var ro=JSON.parse(h.responseText.split('\n')) + for(var i=ro.length-1;i>=0;--i) + { + var o=ro[i]; + if(!o.cont)continue; + var e=document.createElement('div'); + e.classList.add('comment'); + var p=document.createElement('div'); + p.style.padding='0.5em 0 0.5em 0.5em'; + p.innerHTML=o.cont; + var t=document.createElement('div'); + t.classList.add('author'); + if(!o.author.length)o.author='Anonymous'; + t.innerHTML=o.author+" at "+o.time; + e.appendChild(p); + e.appendChild(t); + document.getElementById('commentdiv').appendChild(e); + } } } + gb_load(); </script> - <form action="/leave-a-message/writemessage.php" id="msgform" method="post" style="padding:5px;border:1px solid #CCC;"> + <form id="msgform" method="post" style="padding:5px;border:1px solid #CCC;"> <span style="width:98%;display:table;"> <label for="name" style="display:table-cell;width:1px;white-space:nowrap;">Your honourable name:</label> <input type="text" id="mname" name="name" required style="margin-left:5px;display:table-cell;width:100%;"> </span> <div style="padding:0.5em;">Message:</div> <textarea required id="mcontent" name="content" rows="5" style="width:97%;margin:0.5em;"></textarea> - <div style="padding:0.5em;"> - Something Annoying: <span id="ann" style="color:#F00;display:none;">Please complete the annoying challenge!</span></div> - <div style="margin:0 auto;width:304px;" class="g-recaptcha" data-sitekey="6Lf1lAcUAAAAAGep8SpTETdIrEiw6w8uVy8IXp9U"></div><br> <div style="text-align:center;"> - <button onclick="verify();" type="button">Leave the message!</button> + <button id="button_send" onclick="gb_send();" type="button">Leave the message!</button> </div> </form> </div> @@ -565,11 +574,6 @@ function swonload(){ </div> <div class="block" id="links"> <h2>Links</h2><hr> - <h3>File transfer</h3> - <ul> - <li><a href="./data">Data folder</a></li> - <li><a href="./upload">File upload(LAN only)</a></li> - </ul> <h3>Miscellaneous tools and games</h3> <ul> <li><a href="/codeforces-rating-cmp">CodeForces Rating Comparator</a></li> @@ -587,6 +591,7 @@ function swonload(){ <li><a rel="external" target="_blank" href="https://yyc12345.github.io/MyBlog/">yyc12345 の Blog</a></li> <li><a rel="external" target="_blank" href="https://oing9179.github.io/blog">oing9179 的笔记本儿</a></li> <li><a rel="external" target="_blank" href="https://719daze.me">719daze</a></li> + <li><a rel="external" target="_blank" href="https://owner203.com">OWNER203'S WORLD</a></li> </ul> </div> <div style="text-align:center;padding:0.5em;"> @@ -613,9 +618,5 @@ function swonload(){ <img src="koishi_norm.png" alt="" width="320" id="aqt6" decoding="async"> <img src="koishi_hovr.png" alt="" width="320" id="aqt6a" decoding="async" style="display:none;"> </div> - <!--<div id="v4" style="display:none;transform:none !important;" class="floatingr" onmouseover="changeImage('aqt4a','aqt4')" onmouseout="changeImage('aqt4','aqt4a')" onclick="this.style.display='none';"> - <img src="yuyuko_debian.png" alt="" width="240" id="aqt4" decoding="async"> - <img src="yuyuko_debian.png" alt="" width="240" id="aqt4a" decoding="async" style="display:none;"> - </div>--> </body> </html> diff --git a/libs/pictures/osunix-logo_sq_thicken.png b/libs/pictures/osunix-logo_sq_thicken.png Binary files differnew file mode 100644 index 0000000..510bba2 --- /dev/null +++ b/libs/pictures/osunix-logo_sq_thicken.png diff --git a/theme0a.css b/theme0a.css index 95e9a5a..ac5b599 100644 --- a/theme0a.css +++ b/theme0a.css @@ -44,6 +44,9 @@ button:hover,.fakebtn:hover{ button:active,.fakebtn:active{ background-color:#E9D; } +button:disabled{ + background-color:#999; +} input[type="text"]{ color:#000; border-bottom-color:#C7B; diff --git a/theme0b.css b/theme0b.css index 38de3a8..0ac2a36 100644 --- a/theme0b.css +++ b/theme0b.css @@ -44,6 +44,9 @@ button:hover,.fakebtn:hover{ button:active,.fakebtn:active{ background-color:#A59; } +button:disabled{ + background-color:#666; +} input[type="text"]{ color:#FFF; border-bottom-color:#746; diff --git a/theme1a.css b/theme1a.css index c0bfd2c..142e5e3 100644 --- a/theme1a.css +++ b/theme1a.css @@ -44,6 +44,9 @@ button:hover,.fakebtn:hover{ button:active,.fakebtn:active{ background-color:#6C6; } +button:disabled{ + background-color:#999; +} input[type="text"]{ color:#000; border-bottom-color:#4A4; diff --git a/theme1b.css b/theme1b.css index 4d7db01..0e0d1aa 100644 --- a/theme1b.css +++ b/theme1b.css @@ -44,6 +44,9 @@ button:hover,.fakebtn:hover{ button:active,.fakebtn:active{ background-color:#383; } +button:disabled{ + background-color:#666; +} input[type="text"]{ color:#FFF; border-bottom-color:#161; diff --git a/theme2a.css b/theme2a.css index 1dc6b82..53a61b1 100644 --- a/theme2a.css +++ b/theme2a.css @@ -44,6 +44,9 @@ button:hover,.fakebtn:hover{ button:active,.fakebtn:active{ background-color:#EC9; } +button:disabled{ + background-color:#999; +} input[type="text"]{ color:#000; border-bottom-color:#CA7; diff --git a/theme2b.css b/theme2b.css index 32f24c4..2f5964d 100644 --- a/theme2b.css +++ b/theme2b.css @@ -44,6 +44,9 @@ button:hover,.fakebtn:hover{ button:active,.fakebtn:active{ background-color:#B85; } +button:disabled{ + background-color:#666; +} input[type="text"]{ color:#FFF; border-bottom-color:#863; diff --git a/theme3a.css b/theme3a.css index c7666de..dfbe17f 100644 --- a/theme3a.css +++ b/theme3a.css @@ -44,6 +44,9 @@ button:hover,.fakebtn:hover{ button:active,.fakebtn:active{ background-color:#9DF; } +button:disabled{ + background-color:#999; +} input[type="text"]{ color:#000; border-bottom-color:#6BD; diff --git a/theme3b.css b/theme3b.css index b9b98b3..143f081 100644 --- a/theme3b.css +++ b/theme3b.css @@ -44,6 +44,9 @@ button:hover,.fakebtn:hover{ button:active,.fakebtn:active{ background-color:#68B; } +button:disabled{ + background-color:#666; +} input[type="text"]{ color:#FFF; border-bottom-color:#469; |