diff options
Diffstat (limited to 'cgi-bin')
-rw-r--r-- | cgi-bin/.add.html.un~ | bin | 0 -> 88954 bytes | |||
-rw-r--r-- | cgi-bin/.add.py.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.add.py.un~ | bin | 0 -> 28657 bytes | |||
-rw-r--r-- | cgi-bin/.img.py.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.img.py.un~ | bin | 0 -> 10922 bytes | |||
-rw-r--r-- | cgi-bin/.imgs.py.un~ | bin | 0 -> 117919 bytes | |||
-rw-r--r-- | cgi-bin/.issue.html.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.issue.html.un~ | bin | 14943 -> 26503 bytes | |||
-rw-r--r-- | cgi-bin/.issue.py.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.issue.py.un~ | bin | 85310 -> 90754 bytes | |||
-rw-r--r-- | cgi-bin/.page.html.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.page.html.un~ | bin | 7876 -> 8323 bytes | |||
-rw-r--r-- | cgi-bin/.page.py.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.path.py.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | cgi-bin/.path.py.un~ | bin | 0 -> 14735 bytes | |||
-rw-r--r-- | cgi-bin/__pycache__/path.cpython-36.pyc | bin | 0 -> 691 bytes | |||
-rw-r--r-- | cgi-bin/add.py | 22 | ||||
-rw-r--r-- | cgi-bin/img.py | 52 | ||||
-rw-r--r-- | cgi-bin/issue.html | 4 | ||||
-rw-r--r-- | cgi-bin/issue.py | 57 | ||||
-rw-r--r-- | cgi-bin/log.txt | 0 | ||||
-rw-r--r-- | cgi-bin/page.html | 2 | ||||
-rw-r--r-- | cgi-bin/path.py | 12 |
23 files changed, 117 insertions, 32 deletions
diff --git a/cgi-bin/.add.html.un~ b/cgi-bin/.add.html.un~ Binary files differnew file mode 100644 index 0000000..57c1714 --- /dev/null +++ b/cgi-bin/.add.html.un~ diff --git a/cgi-bin/.add.py.swp b/cgi-bin/.add.py.swp Binary files differnew file mode 100644 index 0000000..465de26 --- /dev/null +++ b/cgi-bin/.add.py.swp diff --git a/cgi-bin/.add.py.un~ b/cgi-bin/.add.py.un~ Binary files differnew file mode 100644 index 0000000..6547452 --- /dev/null +++ b/cgi-bin/.add.py.un~ diff --git a/cgi-bin/.img.py.swp b/cgi-bin/.img.py.swp Binary files differnew file mode 100644 index 0000000..82da003 --- /dev/null +++ b/cgi-bin/.img.py.swp diff --git a/cgi-bin/.img.py.un~ b/cgi-bin/.img.py.un~ Binary files differnew file mode 100644 index 0000000..d15ae3a --- /dev/null +++ b/cgi-bin/.img.py.un~ diff --git a/cgi-bin/.imgs.py.un~ b/cgi-bin/.imgs.py.un~ Binary files differnew file mode 100644 index 0000000..a86dd44 --- /dev/null +++ b/cgi-bin/.imgs.py.un~ diff --git a/cgi-bin/.issue.html.swp b/cgi-bin/.issue.html.swp Binary files differnew file mode 100644 index 0000000..8a34f7e --- /dev/null +++ b/cgi-bin/.issue.html.swp diff --git a/cgi-bin/.issue.html.un~ b/cgi-bin/.issue.html.un~ Binary files differindex 69fa826..1981975 100644 --- a/cgi-bin/.issue.html.un~ +++ b/cgi-bin/.issue.html.un~ diff --git a/cgi-bin/.issue.py.swp b/cgi-bin/.issue.py.swp Binary files differnew file mode 100644 index 0000000..2d89ae4 --- /dev/null +++ b/cgi-bin/.issue.py.swp diff --git a/cgi-bin/.issue.py.un~ b/cgi-bin/.issue.py.un~ Binary files differindex 665ee64..b3bc373 100644 --- a/cgi-bin/.issue.py.un~ +++ b/cgi-bin/.issue.py.un~ diff --git a/cgi-bin/.page.html.swp b/cgi-bin/.page.html.swp Binary files differnew file mode 100644 index 0000000..3632958 --- /dev/null +++ b/cgi-bin/.page.html.swp diff --git a/cgi-bin/.page.html.un~ b/cgi-bin/.page.html.un~ Binary files differindex e3e37d6..e28b9b7 100644 --- a/cgi-bin/.page.html.un~ +++ b/cgi-bin/.page.html.un~ diff --git a/cgi-bin/.page.py.swp b/cgi-bin/.page.py.swp Binary files differnew file mode 100644 index 0000000..4c9b355 --- /dev/null +++ b/cgi-bin/.page.py.swp diff --git a/cgi-bin/.path.py.swp b/cgi-bin/.path.py.swp Binary files differnew file mode 100644 index 0000000..298517e --- /dev/null +++ b/cgi-bin/.path.py.swp diff --git a/cgi-bin/.path.py.un~ b/cgi-bin/.path.py.un~ Binary files differnew file mode 100644 index 0000000..85f7f9f --- /dev/null +++ b/cgi-bin/.path.py.un~ diff --git a/cgi-bin/__pycache__/path.cpython-36.pyc b/cgi-bin/__pycache__/path.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..c230e92 --- /dev/null +++ b/cgi-bin/__pycache__/path.cpython-36.pyc diff --git a/cgi-bin/add.py b/cgi-bin/add.py index e69de29..440b67f 100644 --- a/cgi-bin/add.py +++ b/cgi-bin/add.py @@ -0,0 +1,22 @@ +#!C:\Python364\python3.exe +# -*- coding: utf-8 -*- +import sys, codecs +import cgi, cgitb +import pymysql +import issuedb +from issuedb import IssueDBFactory +sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) + +db = IssueDBFactory.produce() +cursor = db.cursor() + +print("Content-type:text/html\n") +redirect = """ +<html> +<head> +<meta http-equiv="refresh" content="0;url=issue?id={0}"> +</head> +</html> +""".format(1) +print(redirect) + diff --git a/cgi-bin/img.py b/cgi-bin/img.py new file mode 100644 index 0000000..7a7751f --- /dev/null +++ b/cgi-bin/img.py @@ -0,0 +1,52 @@ +#!C:\Python364\python3.exe +# -*- coding: utf-8 -*- +import sys, codecs +import cgi, cgitb +import pymysql +import issuedb +from issuedb import IssueDBFactory +import os +import path +from path import Path +import time +sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) + +form = cgi.FieldStorage() + +fileobj = form['upload'] +callback = form.getvalue("CKEditorFuncNum") +fname, fext = os.path.splitext(fileobj.filename) + +def randname(): + return int(time.time()); + +rnd_name = '%s%s' % (randname(), fext) +filepath = Path.img(rnd_name) + +# 检查路径是否存在,不存在则创建 +dirname = os.path.dirname(filepath) +url = "" +error = "" +if not os.path.exists(dirname): + try: + os.makedirs(dirname) + except: + error = 'ERROR_CREATE_DIR' +elif not os.access(dirname, os.W_OK): + error = 'ERROR_DIR_NOT_WRITEABLE' +if not error: + open(filepath, 'wb').write(fileobj.file.read()) + #url = url_for('static', filename='%s/%s' % ('upload', rnd_name)) + url = Path.url("imgs/" + rnd_name) + +res = """ +<html> +<script type="text/javascript"> + window.parent.CKEDITOR.tools.callFunction(%s, '%s', '%s'); +</script> +</html> +""" % (callback, url, error) + +print("Content-type:text/html\n") +print(res) + diff --git a/cgi-bin/issue.html b/cgi-bin/issue.html index 129a531..4315c9a 100644 --- a/cgi-bin/issue.html +++ b/cgi-bin/issue.html @@ -1,6 +1,6 @@ <html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>issues tags</title> +<title>issue#{issueId} {issueTitle}</title> <body> <link rel="stylesheet" href="style.css" type="text/css" /> <div id="container"> @@ -13,9 +13,11 @@ <div class="issue_tags"> {tags} </div> + <font class="issue_description_font issue_font">问题描述:</font> <div class="issue_description"> {issueDescription} </div> + <font class="issue_solve_font issue_font">解决方案:</font> <div class="issue_solve"> {issueSolve} </div> diff --git a/cgi-bin/issue.py b/cgi-bin/issue.py index 83f6950..19a5414 100644 --- a/cgi-bin/issue.py +++ b/cgi-bin/issue.py @@ -17,36 +17,33 @@ issue_html_file = open("issue.html", 'r', encoding='utf8') issue_html = issue_html_file.read() tag_unit_html = tag_unit_html_file.read() - issue = "" -#try: -issueId = cgi.FieldStorage().getvalue("id") -cursor.execute("select * from issue where issueId={0}".format(issueId)) -issue_content = cursor.fetchall() -issue_content = issue_content[0] - -if issue_content != None: - taglist = "" - cursor.execute("SELECT * FROM tag WHERE tagId IN (SELECT tagId FROM relation WHERE issueId = {0})".format(issueId)) - tags_rows = cursor.fetchall() - for tag_row in tags_rows: - tag = tag_unit_html.format(\ - tagid = tag_row[0], \ - tag_name = tag_row[1],\ - tag_count = '' \ - ) - taglist += tag - issue = issue_html.format( \ - issueId = issue_content[0], \ - issueTitle = issue_content[1],\ - issueDescription = issue_content[2],\ - issueSolve = issue_content[3],\ - tags = taglist\ - ) -print(issue) -#except Exception, e: -#print("Error: unable to fetch data \n" + e.message) - - +try: + issueId = cgi.FieldStorage().getvalue("id") + cursor.execute("select * from issue where issueId={0}".format(issueId)) + issue_content = cursor.fetchall() + issue_content = issue_content[0] + + if issue_content != None: + taglist = "" + cursor.execute("SELECT * FROM tag WHERE tagId IN (SELECT tagId FROM relation WHERE issueId = {0})".format(issueId)) + tags_rows = cursor.fetchall() + for tag_row in tags_rows: + tag = tag_unit_html.format(\ + tagid = tag_row[0], \ + tag_name = tag_row[1],\ + tag_count = '' \ + ) + taglist += tag + issue = issue_html.format( \ + issueId = issue_content[0], \ + issueTitle = issue_content[1],\ + issueDescription = issue_content[2],\ + issueSolve = issue_content[3],\ + tags = taglist\ + ) + print(issue) +except: + print("Error: unable to fetch data \n" + e.message) diff --git a/cgi-bin/log.txt b/cgi-bin/log.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/cgi-bin/log.txt diff --git a/cgi-bin/page.html b/cgi-bin/page.html index f5a5641..e2609f6 100644 --- a/cgi-bin/page.html +++ b/cgi-bin/page.html @@ -9,7 +9,7 @@ <input type="text" id="searchbar_input" name="content"/> <input type="submit" id="searchbar_submit" value="搜索"/> <a href="/tags">标签</a> - <a href="/add">添加</a> + <a href="/add.html">添加</a> </form> <br/> <!--issues--> diff --git a/cgi-bin/path.py b/cgi-bin/path.py new file mode 100644 index 0000000..99152ce --- /dev/null +++ b/cgi-bin/path.py @@ -0,0 +1,12 @@ +dir = "C:/Users/chaifeixiang/Documents/python/issues/html/" + +class Path(object): + def full(p): + return dir + p + + def url(p): + return "/" + p + + def img(p): + return dir + 'imgs/' + p + |