From d7b95f0d040deb1b34af31c7c8e2f66c1e37686e Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Tue, 12 Feb 2019 18:53:12 +0800 Subject: First update. --- .gitignore | 3 + History | 8 ++ cgi/gb_newentry.cgi | 69 +++++++++++++++ common.css | 12 +-- index.html | 147 ++++++++++++++++--------------- libs/pictures/osunix-logo_sq_thicken.png | Bin 0 -> 692232 bytes theme0a.css | 3 + theme0b.css | 3 + theme1a.css | 3 + theme1b.css | 3 + theme2a.css | 3 + theme2b.css | 3 + theme3a.css | 3 + theme3b.css | 3 + 14 files changed, 184 insertions(+), 79 deletions(-) create mode 100755 cgi/gb_newentry.cgi create mode 100644 libs/pictures/osunix-logo_sq_thicken.png diff --git a/.gitignore b/.gitignore index bd98048..60b6945 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/History b/History index 8f01064..f289860 100644 --- a/History +++ b/History @@ -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','
') + 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') diff --git a/common.css b/common.css index e400635..41585eb 100644 --- a/common.css +++ b/common.css @@ -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{ diff --git a/index.html b/index.html index de4abc3..e9e6098 100644 --- a/index.html +++ b/index.html @@ -17,11 +17,15 @@ +
@@ -166,15 +155,13 @@ function swonload(){

Have fun exploring!

-

+

This site uses reCAPTCHA for traffic analysis. Terms and privacy policy of Google may apply.

Projects


@@ -323,7 +310,7 @@ function swonload(){
  • Chris' Timidity Player (2012) - [archive] + [archive] [short desc.]
    @@ -333,7 +320,7 @@ function swonload(){
  • Simple Tester for OI (2012) - [archive] + [archive] [short desc.]
    @@ -361,7 +348,7 @@ function swonload(){
  • Cross Noodles (Virtools) (2012) - [details] + [details] [short desc.]
    @@ -370,7 +357,7 @@ function swonload(){
  • Compiz 0.9.7.99 (2012-2016) - [archive] + [archive] [short desc.]
    @@ -381,7 +368,6 @@ function swonload(){
  • Minesweeper in HGE (2012) - [archive] [short desc.]
    @@ -390,7 +376,7 @@ function swonload(){
  • Desktop (2012) - [archive] + [archive] [short desc.]
    @@ -469,9 +455,9 @@ function swonload(){

    Music arranged and some, composed, by me.

    -

    Picture Library

    +

    Picture Library

    - My collection of pictures from the Internet. + Nothin'.

    Code Library

    @@ -481,6 +467,7 @@ function swonload(){

    Leave a Message


    + All times are in CST (UTC+8). Messages are not censored (except messages for testing, which would be deleted shortly after posting; advertising is also prohibited). @@ -493,57 +480,79 @@ function swonload(){

    -
    +
    Message:
    -
    - Something Annoying:
    -

    - +
    @@ -565,11 +574,6 @@ function swonload(){
    @@ -613,9 +618,5 @@ function swonload(){
    - diff --git a/libs/pictures/osunix-logo_sq_thicken.png b/libs/pictures/osunix-logo_sq_thicken.png new file mode 100644 index 0000000..510bba2 Binary files /dev/null and b/libs/pictures/osunix-logo_sq_thicken.png differ 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; -- cgit v1.2.3