diff options
author | chai <chaifix@163.com> | 2018-01-29 15:37:45 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-01-29 15:37:45 +0800 |
commit | 5d77906331243354710712ddf45b8bcb2152dacc (patch) | |
tree | 28319897afc0d22fde2e42e834885f16834a6db6 | |
parent | 07704199616228849c17302f21dd5a5a30dbea66 (diff) |
*修改
-rw-r--r-- | cgi-bin/.add.html.un~ | bin | 88954 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.add.py.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.add.py.un~ | bin | 28657 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.conf.ini.un~ | bin | 4882 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.conf.py.un~ | bin | 2234 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.config.py.un~ | bin | 31412 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.img.py.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.img.py.un~ | bin | 10922 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.imgs.py.un~ | bin | 117919 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.issue.html.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.issue.html.un~ | bin | 26503 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.issue.py.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.issue.py.un~ | bin | 90754 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.issue_unit.html.un~ | bin | 20181 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.page.html.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.page.html.un~ | bin | 8323 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.page.py.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.page.py.un~ | bin | 198461 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.path.py.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.path.py.un~ | bin | 14735 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.tag_unit.html.un~ | bin | 4962 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/.tags.py.un~ | bin | 26004 -> 0 bytes | |||
-rw-r--r-- | cgi-bin/add.html (renamed from html/add.html) | 2 | ||||
-rw-r--r-- | cgi-bin/add.py | 16 | ||||
-rw-r--r-- | cgi-bin/insert.py | 59 | ||||
-rw-r--r-- | cgi-bin/issue.py | 3 | ||||
-rw-r--r-- | cgi-bin/page.html | 2 | ||||
-rw-r--r-- | cgi-bin/page.py | 26 | ||||
-rw-r--r-- | html/.add.html.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | html/.add.html.un~ | bin | 32860 -> 0 bytes | |||
-rw-r--r-- | html/.style.css.swp | bin | 12288 -> 0 bytes | |||
-rw-r--r-- | html/.style.css.un~ | bin | 47414 -> 1418 bytes | |||
-rw-r--r-- | html/imgs/1516948982.jpg | bin | 0 -> 775702 bytes | |||
-rw-r--r-- | html/imgs/1517194089.jpg | bin | 0 -> 15428 bytes | |||
-rw-r--r-- | html/imgs/1517194132.png | bin | 0 -> 105704 bytes | |||
-rw-r--r-- | html/imgs/1517202617.jpg | bin | 0 -> 15428 bytes | |||
-rw-r--r-- | html/imgs/1517202643.png | bin | 0 -> 105704 bytes | |||
-rw-r--r-- | html/style.css | 2 | ||||
-rw-r--r-- | sql/issue.sql | 0 | ||||
-rw-r--r-- | sql/issues.sql | 56 | ||||
-rw-r--r-- | sql/relation.sql | 0 | ||||
-rw-r--r-- | sql/tag.sql | 1 |
42 files changed, 141 insertions, 26 deletions
diff --git a/cgi-bin/.add.html.un~ b/cgi-bin/.add.html.un~ Binary files differdeleted file mode 100644 index 57c1714..0000000 --- a/cgi-bin/.add.html.un~ +++ /dev/null diff --git a/cgi-bin/.add.py.swp b/cgi-bin/.add.py.swp Binary files differdeleted file mode 100644 index 465de26..0000000 --- a/cgi-bin/.add.py.swp +++ /dev/null diff --git a/cgi-bin/.add.py.un~ b/cgi-bin/.add.py.un~ Binary files differdeleted file mode 100644 index 6547452..0000000 --- a/cgi-bin/.add.py.un~ +++ /dev/null diff --git a/cgi-bin/.conf.ini.un~ b/cgi-bin/.conf.ini.un~ Binary files differdeleted file mode 100644 index 3d1e5b5..0000000 --- a/cgi-bin/.conf.ini.un~ +++ /dev/null diff --git a/cgi-bin/.conf.py.un~ b/cgi-bin/.conf.py.un~ Binary files differdeleted file mode 100644 index ea49443..0000000 --- a/cgi-bin/.conf.py.un~ +++ /dev/null diff --git a/cgi-bin/.config.py.un~ b/cgi-bin/.config.py.un~ Binary files differdeleted file mode 100644 index 9271503..0000000 --- a/cgi-bin/.config.py.un~ +++ /dev/null diff --git a/cgi-bin/.img.py.swp b/cgi-bin/.img.py.swp Binary files differdeleted file mode 100644 index 82da003..0000000 --- a/cgi-bin/.img.py.swp +++ /dev/null diff --git a/cgi-bin/.img.py.un~ b/cgi-bin/.img.py.un~ Binary files differdeleted file mode 100644 index d15ae3a..0000000 --- a/cgi-bin/.img.py.un~ +++ /dev/null diff --git a/cgi-bin/.imgs.py.un~ b/cgi-bin/.imgs.py.un~ Binary files differdeleted file mode 100644 index a86dd44..0000000 --- a/cgi-bin/.imgs.py.un~ +++ /dev/null diff --git a/cgi-bin/.issue.html.swp b/cgi-bin/.issue.html.swp Binary files differdeleted file mode 100644 index 8a34f7e..0000000 --- a/cgi-bin/.issue.html.swp +++ /dev/null diff --git a/cgi-bin/.issue.html.un~ b/cgi-bin/.issue.html.un~ Binary files differdeleted file mode 100644 index 1981975..0000000 --- a/cgi-bin/.issue.html.un~ +++ /dev/null diff --git a/cgi-bin/.issue.py.swp b/cgi-bin/.issue.py.swp Binary files differdeleted file mode 100644 index 2d89ae4..0000000 --- a/cgi-bin/.issue.py.swp +++ /dev/null diff --git a/cgi-bin/.issue.py.un~ b/cgi-bin/.issue.py.un~ Binary files differdeleted file mode 100644 index b3bc373..0000000 --- a/cgi-bin/.issue.py.un~ +++ /dev/null diff --git a/cgi-bin/.issue_unit.html.un~ b/cgi-bin/.issue_unit.html.un~ Binary files differdeleted file mode 100644 index fa271bd..0000000 --- a/cgi-bin/.issue_unit.html.un~ +++ /dev/null diff --git a/cgi-bin/.page.html.swp b/cgi-bin/.page.html.swp Binary files differdeleted file mode 100644 index 3632958..0000000 --- a/cgi-bin/.page.html.swp +++ /dev/null diff --git a/cgi-bin/.page.html.un~ b/cgi-bin/.page.html.un~ Binary files differdeleted file mode 100644 index e28b9b7..0000000 --- a/cgi-bin/.page.html.un~ +++ /dev/null diff --git a/cgi-bin/.page.py.swp b/cgi-bin/.page.py.swp Binary files differdeleted file mode 100644 index 4c9b355..0000000 --- a/cgi-bin/.page.py.swp +++ /dev/null diff --git a/cgi-bin/.page.py.un~ b/cgi-bin/.page.py.un~ Binary files differdeleted file mode 100644 index 8128fc8..0000000 --- a/cgi-bin/.page.py.un~ +++ /dev/null diff --git a/cgi-bin/.path.py.swp b/cgi-bin/.path.py.swp Binary files differdeleted file mode 100644 index 298517e..0000000 --- a/cgi-bin/.path.py.swp +++ /dev/null diff --git a/cgi-bin/.path.py.un~ b/cgi-bin/.path.py.un~ Binary files differdeleted file mode 100644 index 85f7f9f..0000000 --- a/cgi-bin/.path.py.un~ +++ /dev/null diff --git a/cgi-bin/.tag_unit.html.un~ b/cgi-bin/.tag_unit.html.un~ Binary files differdeleted file mode 100644 index ff82ead..0000000 --- a/cgi-bin/.tag_unit.html.un~ +++ /dev/null diff --git a/cgi-bin/.tags.py.un~ b/cgi-bin/.tags.py.un~ Binary files differdeleted file mode 100644 index 9184da7..0000000 --- a/cgi-bin/.tags.py.un~ +++ /dev/null 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 Binary files differdeleted file mode 100644 index 2e8af71..0000000 --- a/html/.add.html.swp +++ /dev/null diff --git a/html/.add.html.un~ b/html/.add.html.un~ Binary files differdeleted file mode 100644 index 3e8dea0..0000000 --- a/html/.add.html.un~ +++ /dev/null diff --git a/html/.style.css.swp b/html/.style.css.swp Binary files differdeleted file mode 100644 index 06400be..0000000 --- a/html/.style.css.swp +++ /dev/null diff --git a/html/.style.css.un~ b/html/.style.css.un~ Binary files differindex b688347..730471b 100644 --- a/html/.style.css.un~ +++ b/html/.style.css.un~ diff --git a/html/imgs/1516948982.jpg b/html/imgs/1516948982.jpg Binary files differnew file mode 100644 index 0000000..fa4fd41 --- /dev/null +++ b/html/imgs/1516948982.jpg diff --git a/html/imgs/1517194089.jpg b/html/imgs/1517194089.jpg Binary files differnew file mode 100644 index 0000000..d41d4c3 --- /dev/null +++ b/html/imgs/1517194089.jpg diff --git a/html/imgs/1517194132.png b/html/imgs/1517194132.png Binary files differnew file mode 100644 index 0000000..af6549d --- /dev/null +++ b/html/imgs/1517194132.png diff --git a/html/imgs/1517202617.jpg b/html/imgs/1517202617.jpg Binary files differnew file mode 100644 index 0000000..d41d4c3 --- /dev/null +++ b/html/imgs/1517202617.jpg diff --git a/html/imgs/1517202643.png b/html/imgs/1517202643.png Binary files differnew file mode 100644 index 0000000..af6549d --- /dev/null +++ b/html/imgs/1517202643.png 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 |