summaryrefslogtreecommitdiff
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
parent07704199616228849c17302f21dd5a5a30dbea66 (diff)
*修改
-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.html (renamed from html/add.html)2
-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
-rw-r--r--html/.add.html.swpbin12288 -> 0 bytes
-rw-r--r--html/.add.html.un~bin32860 -> 0 bytes
-rw-r--r--html/.style.css.swpbin12288 -> 0 bytes
-rw-r--r--html/.style.css.un~bin47414 -> 1418 bytes
-rw-r--r--html/imgs/1516948982.jpgbin0 -> 775702 bytes
-rw-r--r--html/imgs/1517194089.jpgbin0 -> 15428 bytes
-rw-r--r--html/imgs/1517194132.pngbin0 -> 105704 bytes
-rw-r--r--html/imgs/1517202617.jpgbin0 -> 15428 bytes
-rw-r--r--html/imgs/1517202643.pngbin0 -> 105704 bytes
-rw-r--r--html/style.css2
-rw-r--r--sql/issue.sql0
-rw-r--r--sql/issues.sql56
-rw-r--r--sql/relation.sql0
-rw-r--r--sql/tag.sql1
42 files changed, 141 insertions, 26 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/html/add.html b/cgi-bin/add.html
index a664f58..378d58a 100644
--- a/html/add.html
+++ b/cgi-bin/add.html
@@ -8,7 +8,7 @@
<br/>
<script src="ckeditor/ckeditor.js"></script>
- <form action="/add" class="form_add">
+ <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"/>
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()
diff --git a/html/.add.html.swp b/html/.add.html.swp
deleted file mode 100644
index 2e8af71..0000000
--- a/html/.add.html.swp
+++ /dev/null
Binary files differ
diff --git a/html/.add.html.un~ b/html/.add.html.un~
deleted file mode 100644
index 3e8dea0..0000000
--- a/html/.add.html.un~
+++ /dev/null
Binary files differ
diff --git a/html/.style.css.swp b/html/.style.css.swp
deleted file mode 100644
index 06400be..0000000
--- a/html/.style.css.swp
+++ /dev/null
Binary files differ
diff --git a/html/.style.css.un~ b/html/.style.css.un~
index b688347..730471b 100644
--- a/html/.style.css.un~
+++ b/html/.style.css.un~
Binary files differ
diff --git a/html/imgs/1516948982.jpg b/html/imgs/1516948982.jpg
new file mode 100644
index 0000000..fa4fd41
--- /dev/null
+++ b/html/imgs/1516948982.jpg
Binary files differ
diff --git a/html/imgs/1517194089.jpg b/html/imgs/1517194089.jpg
new file mode 100644
index 0000000..d41d4c3
--- /dev/null
+++ b/html/imgs/1517194089.jpg
Binary files differ
diff --git a/html/imgs/1517194132.png b/html/imgs/1517194132.png
new file mode 100644
index 0000000..af6549d
--- /dev/null
+++ b/html/imgs/1517194132.png
Binary files differ
diff --git a/html/imgs/1517202617.jpg b/html/imgs/1517202617.jpg
new file mode 100644
index 0000000..d41d4c3
--- /dev/null
+++ b/html/imgs/1517202617.jpg
Binary files differ
diff --git a/html/imgs/1517202643.png b/html/imgs/1517202643.png
new file mode 100644
index 0000000..af6549d
--- /dev/null
+++ b/html/imgs/1517202643.png
Binary files differ
diff --git a/html/style.css b/html/style.css
index dd447a4..6d1a447 100644
--- a/html/style.css
+++ b/html/style.css
@@ -1,5 +1,5 @@
#container{
- width:640;
+ width:768px;
}
#pagejump_next{
diff --git a/sql/issue.sql b/sql/issue.sql
deleted file mode 100644
index e69de29..0000000
--- a/sql/issue.sql
+++ /dev/null
diff --git a/sql/issues.sql b/sql/issues.sql
new file mode 100644
index 0000000..8be37e6
--- /dev/null
+++ b/sql/issues.sql
@@ -0,0 +1,56 @@
+/*
+SQLyog Ultimate v12.09 (64 bit)
+MySQL - 5.5.28 : Database - issues
+*********************************************************************
+*/
+
+/*!40101 SET NAMES utf8 */;
+
+/*!40101 SET SQL_MODE=''*/;
+
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+CREATE DATABASE /*!32312 IF NOT EXISTS*/`issues` /*!40100 DEFAULT CHARACTER SET utf8 */;
+
+USE `issues`;
+
+/*Table structure for table `issue` */
+
+DROP TABLE IF EXISTS `issue`;
+
+CREATE TABLE `issue` (
+ `issueId` int(32) NOT NULL AUTO_INCREMENT,
+ `issueTitle` varchar(64) DEFAULT NULL,
+ `issueDesc` text,
+ `issueSolve` text,
+ `issueTime` int(32) DEFAULT NULL,
+ PRIMARY KEY (`issueId`)
+) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8;
+
+/*Table structure for table `relation` */
+
+DROP TABLE IF EXISTS `relation`;
+
+CREATE TABLE `relation` (
+ `relationId` int(32) NOT NULL AUTO_INCREMENT,
+ `tagId` int(32) NOT NULL,
+ `issueId` int(32) NOT NULL,
+ PRIMARY KEY (`relationId`)
+) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
+
+/*Table structure for table `tag` */
+
+DROP TABLE IF EXISTS `tag`;
+
+CREATE TABLE `tag` (
+ `tagId` int(32) unsigned NOT NULL AUTO_INCREMENT,
+ `tagName` varchar(64) NOT NULL,
+ PRIMARY KEY (`tagId`)
+) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
diff --git a/sql/relation.sql b/sql/relation.sql
deleted file mode 100644
index e69de29..0000000
--- a/sql/relation.sql
+++ /dev/null
diff --git a/sql/tag.sql b/sql/tag.sql
deleted file mode 100644
index e82f07f..0000000
--- a/sql/tag.sql
+++ /dev/null
@@ -1 +0,0 @@
-`relation` \ No newline at end of file