summaryrefslogtreecommitdiff
path: root/cgi-bin/add.py
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-07-13 21:53:49 +0800
committerchai <chaifix@163.com>2018-07-13 21:53:49 +0800
commit7ca80e57f06922e464626c7a6a1d7965e716b53f (patch)
treebda9271234720424b7dfc5c2d25b9df4ba3d01df /cgi-bin/add.py
parent181b206863d3765fe5343ceea8e1e00e52ffba9e (diff)
Diffstat (limited to 'cgi-bin/add.py')
-rw-r--r--cgi-bin/add.py63
1 files changed, 0 insertions, 63 deletions
diff --git a/cgi-bin/add.py b/cgi-bin/add.py
deleted file mode 100644
index e3a7d4e..0000000
--- a/cgi-bin/add.py
+++ /dev/null
@@ -1,63 +0,0 @@
-#!D:/Programs/Python3/python.exe
-# -*- coding: utf-8 -*-
-import cgi, cgitb
-import pymysql
-import sys, codecs
-import configparser, codecs
-import connect
-from connect import Connect
-import config
-from config import Config
-import path
-from path import Path
-import time
-
-sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer)
-print("Content-type:text/html\n")
-
-form = cgi.FieldStorage()
-action = form.getvalue('action')
-if action == "modify":
- whisper_content = form.getvalue('whisper_content')
- if whisper_content == None:
- whisper_content = ""
- whisper_id = form.getvalue('whisper_id')
- db = Connect.produce()
- cursor = db.cursor()
- query = "update whisper set content = '{0}' where id = {1}".format(pymysql.escape_string(whisper_content), whisper_id)
- cursor.execute(query)
- db.commit()
- cursor.close()
- db.close()
- _url = Config.get("route", "url")
- redirect = """
- <html>
- <head>
- <meta http-equiv="refresh" content="0;url={0}/page.py">
- </head>
- </html>
- """.format(_url)
- print(redirect)
-elif action == "new":
- whisper_content = form.getvalue('whisper_content')
- if whisper_content == None:
- whisper_content = ""
- t = time.time()
- db = Connect.produce()
- cursor = db.cursor()
- query = "insert into whisper (content, date) values ('{0}', '{1}')".format(pymysql.escape_string(whisper_content), t)
- cursor.execute(query)
- db.commit()
- cursor.close()
- db.close()
- _url = Config.get("route", "url")
- redirect = """
- <html>
- <head>
- <meta http-equiv="refresh" content="0;url={0}/page.py">
- </head>
- </html>
- """.format(_url)
- print(redirect)
-else:
- print("Invalid action") \ No newline at end of file