summaryrefslogtreecommitdiff
path: root/cgi-bin
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-01-29 15:37:45 +0800
committerchai <chaifix@163.com>2018-01-29 15:37:45 +0800
commit5d77906331243354710712ddf45b8bcb2152dacc (patch)
tree28319897afc0d22fde2e42e834885f16834a6db6 /cgi-bin
parent07704199616228849c17302f21dd5a5a30dbea66 (diff)
*修改
Diffstat (limited to 'cgi-bin')
-rw-r--r--cgi-bin/.add.html.un~bin88954 -> 0 bytes
-rw-r--r--cgi-bin/.add.py.swpbin12288 -> 0 bytes
-rw-r--r--cgi-bin/.add.py.un~bin28657 -> 0 bytes
-rw-r--r--cgi-bin/.conf.ini.un~bin4882 -> 0 bytes
-rw-r--r--cgi-bin/.conf.py.un~bin2234 -> 0 bytes
-rw-r--r--cgi-bin/.config.py.un~bin31412 -> 0 bytes
-rw-r--r--cgi-bin/.img.py.swpbin12288 -> 0 bytes
-rw-r--r--cgi-bin/.img.py.un~bin10922 -> 0 bytes
-rw-r--r--cgi-bin/.imgs.py.un~bin117919 -> 0 bytes
-rw-r--r--cgi-bin/.issue.html.swpbin12288 -> 0 bytes
-rw-r--r--cgi-bin/.issue.html.un~bin26503 -> 0 bytes
-rw-r--r--cgi-bin/.issue.py.swpbin12288 -> 0 bytes
-rw-r--r--cgi-bin/.issue.py.un~bin90754 -> 0 bytes
-rw-r--r--cgi-bin/.issue_unit.html.un~bin20181 -> 0 bytes
-rw-r--r--cgi-bin/.page.html.swpbin12288 -> 0 bytes
-rw-r--r--cgi-bin/.page.html.un~bin8323 -> 0 bytes
-rw-r--r--cgi-bin/.page.py.swpbin12288 -> 0 bytes
-rw-r--r--cgi-bin/.page.py.un~bin198461 -> 0 bytes
-rw-r--r--cgi-bin/.path.py.swpbin12288 -> 0 bytes
-rw-r--r--cgi-bin/.path.py.un~bin14735 -> 0 bytes
-rw-r--r--cgi-bin/.tag_unit.html.un~bin4962 -> 0 bytes
-rw-r--r--cgi-bin/.tags.py.un~bin26004 -> 0 bytes
-rw-r--r--cgi-bin/add.html26
-rw-r--r--cgi-bin/add.py16
-rw-r--r--cgi-bin/insert.py59
-rw-r--r--cgi-bin/issue.py3
-rw-r--r--cgi-bin/page.html2
-rw-r--r--cgi-bin/page.py26
28 files changed, 109 insertions, 23 deletions
diff --git a/cgi-bin/.add.html.un~ b/cgi-bin/.add.html.un~
deleted file mode 100644
index 57c1714..0000000
--- a/cgi-bin/.add.html.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.add.py.swp b/cgi-bin/.add.py.swp
deleted file mode 100644
index 465de26..0000000
--- a/cgi-bin/.add.py.swp
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.add.py.un~ b/cgi-bin/.add.py.un~
deleted file mode 100644
index 6547452..0000000
--- a/cgi-bin/.add.py.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.conf.ini.un~ b/cgi-bin/.conf.ini.un~
deleted file mode 100644
index 3d1e5b5..0000000
--- a/cgi-bin/.conf.ini.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.conf.py.un~ b/cgi-bin/.conf.py.un~
deleted file mode 100644
index ea49443..0000000
--- a/cgi-bin/.conf.py.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.config.py.un~ b/cgi-bin/.config.py.un~
deleted file mode 100644
index 9271503..0000000
--- a/cgi-bin/.config.py.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.img.py.swp b/cgi-bin/.img.py.swp
deleted file mode 100644
index 82da003..0000000
--- a/cgi-bin/.img.py.swp
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.img.py.un~ b/cgi-bin/.img.py.un~
deleted file mode 100644
index d15ae3a..0000000
--- a/cgi-bin/.img.py.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.imgs.py.un~ b/cgi-bin/.imgs.py.un~
deleted file mode 100644
index a86dd44..0000000
--- a/cgi-bin/.imgs.py.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.issue.html.swp b/cgi-bin/.issue.html.swp
deleted file mode 100644
index 8a34f7e..0000000
--- a/cgi-bin/.issue.html.swp
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.issue.html.un~ b/cgi-bin/.issue.html.un~
deleted file mode 100644
index 1981975..0000000
--- a/cgi-bin/.issue.html.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.issue.py.swp b/cgi-bin/.issue.py.swp
deleted file mode 100644
index 2d89ae4..0000000
--- a/cgi-bin/.issue.py.swp
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.issue.py.un~ b/cgi-bin/.issue.py.un~
deleted file mode 100644
index b3bc373..0000000
--- a/cgi-bin/.issue.py.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.issue_unit.html.un~ b/cgi-bin/.issue_unit.html.un~
deleted file mode 100644
index fa271bd..0000000
--- a/cgi-bin/.issue_unit.html.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.page.html.swp b/cgi-bin/.page.html.swp
deleted file mode 100644
index 3632958..0000000
--- a/cgi-bin/.page.html.swp
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.page.html.un~ b/cgi-bin/.page.html.un~
deleted file mode 100644
index e28b9b7..0000000
--- a/cgi-bin/.page.html.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.page.py.swp b/cgi-bin/.page.py.swp
deleted file mode 100644
index 4c9b355..0000000
--- a/cgi-bin/.page.py.swp
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.page.py.un~ b/cgi-bin/.page.py.un~
deleted file mode 100644
index 8128fc8..0000000
--- a/cgi-bin/.page.py.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.path.py.swp b/cgi-bin/.path.py.swp
deleted file mode 100644
index 298517e..0000000
--- a/cgi-bin/.path.py.swp
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.path.py.un~ b/cgi-bin/.path.py.un~
deleted file mode 100644
index 85f7f9f..0000000
--- a/cgi-bin/.path.py.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.tag_unit.html.un~ b/cgi-bin/.tag_unit.html.un~
deleted file mode 100644
index ff82ead..0000000
--- a/cgi-bin/.tag_unit.html.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/.tags.py.un~ b/cgi-bin/.tags.py.un~
deleted file mode 100644
index 9184da7..0000000
--- a/cgi-bin/.tags.py.un~
+++ /dev/null
Binary files differ
diff --git a/cgi-bin/add.html b/cgi-bin/add.html
new file mode 100644
index 0000000..378d58a
--- /dev/null
+++ b/cgi-bin/add.html
@@ -0,0 +1,26 @@
+<html>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>添加issue</title>
+<body>
+<link rel="stylesheet" href="style.css" type="text/css" />
+<div id="container">
+ <img src="logo.png" id="logo"/>
+ <br/>
+ <script src="ckeditor/ckeditor.js"></script>
+
+ <form action="/insert" method="post" class="form_add">
+ <font class="issue_font">标题:</font><input name="issue_title" type="text" class="issue_title"/>
+ <br/>
+ <font class="issue_font">标签(用空格分割):</font><input name="issue_tags" type="text" class="issue_tags"/>
+ <font class="issue_font">问题描述:</font>
+ <textarea name="issue_description" id="editor1" class="ckeditor" rows="10" cols="80">
+ </textarea>
+ <font class="issue_font">解决方案:</font>
+ <textarea name="issue_solve" id="editor2" class="ckeditor" rows="20" cols="80">
+ </textarea>
+ <input type="submit" value="提交" class="submit"/>
+ </form>
+</div>
+</body>
+</html>
+
diff --git a/cgi-bin/add.py b/cgi-bin/add.py
index 440b67f..0f7c13d 100644
--- a/cgi-bin/add.py
+++ b/cgi-bin/add.py
@@ -7,16 +7,12 @@ import issuedb
from issuedb import IssueDBFactory
sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer)
-db = IssueDBFactory.produce()
-cursor = db.cursor()
+add_html_file = open("add.html", 'r', encoding='utf8')
+add_html = add_html_file.read()
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)
+print(add_html)
+
+add_html_file.close()
+
diff --git a/cgi-bin/insert.py b/cgi-bin/insert.py
new file mode 100644
index 0000000..61f5cd9
--- /dev/null
+++ b/cgi-bin/insert.py
@@ -0,0 +1,59 @@
+#!C:\Python364\python3.exe
+# -*- coding: utf-8 -*-
+import sys, codecs
+import cgi, cgitb
+import pymysql
+import issuedb
+import time
+from issuedb import IssueDBFactory
+sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer)
+
+db = IssueDBFactory.produce()
+cursor = db.cursor()
+
+form = cgi.FieldStorage()
+title = form.getvalue('issue_title')
+
+tags = form.getvalue('issue_tags')
+issue_desc = form.getvalue('issue_description')
+issue_solve = form.getvalue('issue_solve')
+tag_list = None
+if tags != None:
+ tag_list = tags.split()
+
+query = "insert into issue (issueTitle, issueDesc, issueSolve, issueTime) values ('{0}', '{1}', '{2}', '{3}');".format(pymysql.escape_string(title), pymysql.escape_string(issue_desc), pymysql.escape_string(issue_solve), str(time.time()))
+
+cursor.execute(query)
+db.commit()
+issueId = cursor.lastrowid
+
+for tag in tag_list:
+ cursor.execute("select tagId from tag where tagName = '{0}'".format(tag))
+ tagId = cursor.fetchone()
+ if tagId == None:
+ cursor.execute("insert into tag (tagName) values ('{0}');".format(tag))
+ db.commit()
+ tagId = cursor.lastrowid
+ else:
+ tagId = tagId[0]
+ cursor.execute("select relationId from relation where tagId ='{0}' and issueId = '{1}'".format(tagId, issueId))
+ relationId = cursor.fetchone()
+ if relationId == None:
+ cursor.execute("insert into relation (tagId, issueId) values ('{0}', '{1}')".format(tagId, issueId))
+ db.commit()
+
+print("Content-type:text/html\n")
+redirect = """
+<html>
+<head>
+<meta http-equiv="refresh" content="0;url=issue?id={0}">
+</head>
+</html>
+""".format(issueId)
+print(redirect)
+
+cursor.close()
+db.close()
+
+
+
diff --git a/cgi-bin/issue.py b/cgi-bin/issue.py
index 19a5414..0c694e0 100644
--- a/cgi-bin/issue.py
+++ b/cgi-bin/issue.py
@@ -47,3 +47,6 @@ try:
except:
print("Error: unable to fetch data \n" + e.message)
+cursor.close()
+db.close()
+
diff --git a/cgi-bin/page.html b/cgi-bin/page.html
index e2609f6..f5a5641 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.html">添加</a>
+ <a href="/add">添加</a>
</form>
<br/>
<!--issues-->
diff --git a/cgi-bin/page.py b/cgi-bin/page.py
index 8bdbc0a..ac5e89b 100644
--- a/cgi-bin/page.py
+++ b/cgi-bin/page.py
@@ -10,7 +10,6 @@ from config import Config
sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer)
-print("Content-type:text/html\n")
db = IssueDBFactory.produce()
cursor = db.cursor()
@@ -28,8 +27,20 @@ tag_unit_html_file.close()
issues_list = ""
issues_count = Config.get("config", "issues_count")
+issues_count = int(issues_count)
+#处理页号
+form = cgi.FieldStorage()
+
+pagen = form.getvalue('p')
+if pagen == None:
+ pagen = 0
+pageprev = int(pagen) - 1
+if pageprev < 0:
+ pageprev = 0
+pagenext = int(pagen) + 1
+
try:
- cursor.execute("select * from issue limit 0, 10")
+ cursor.execute("select * from issue ORDER BY issueId DESC LIMIT {0}, {1}".format(pagen*issues_count, issues_count))
issues_rows = cursor.fetchall()
odd = True
for row in issues_rows:
@@ -56,16 +67,6 @@ try:
except:
print("Error: unable to fetch data")
-#处理页号
-form = cgi.FieldStorage()
-pagen = form.getvalue('p')
-if pagen == None:
- pagen = 0
-pageprev = pagen - 1
-if pageprev < 0:
- pageprev = 0
-pagenext = pagen + 1
-
page = page_html.format(\
issues = issues_list, \
page_prev = pageprev, \
@@ -73,6 +74,7 @@ page = page_html.format(\
)
# HTTP header
+print("Content-type:text/html\n")
print(page)
db.commit()