コード例 #1
0
ファイル: server.py プロジェクト: kooksee/myblog
 def get(self):
     ID=self.get_argument('ID','')
     if db.delete(ID):
         tohtml.html().ALL()
         os.remove("./html/%s.html" % ID)
         self.write("0")
     else:
         self.write("数据库异常,刪除失败!")
コード例 #2
0
ファイル: BAE.py プロジェクト: kooksee/myblog
 def post(self):
     Result = True
     NAME=self.get_argument('bkname','')
     Subtitle=self.get_argument('subtitle','')
     description=self.get_argument('description','')
     keywords=self.get_argument('keywords','')
     try:
         db.db("update CONFIG SET SITENAME='%s',subtitle='%s',description='%s',keywords='%s' WHERE ID=1 " % (NAME,Subtitle,description,keywords))
     except:
         self.write("ERROR")
     else:
         tohtml.html().ALL()
         self.write("0")
コード例 #3
0
ファイル: server.py プロジェクト: kooksee/myblog
    def post(self):
        TYPE=self.get_argument('TYPE','')
        ID=self.get_argument('ID','')
        subject = self.get_argument('subject','')
        tags = self.get_argument('tags','')
        markdown = self.get_argument('markdown','')
        Category = self.get_argument('Category','')
        if TYPE=='DEL':
            Category = Category[0:-1]
            SQL = "DELETE FROM Category WHERE ID IN (%s)" % Category
            self.write(db.exe(SQL))

        elif TYPE=='NEW':
            SQL = "INSERT INTO Category (Category) VALUES ('%s')" % Category
            self.write(db.exe(SQL))
        elif None or "" in (subject,tags,markdown):
            self.write(u"主题、标签、类别及内容均不可为空!")
        else:
            if db.edit(TYPE,subject.encode("utf-8"),tags.encode("utf-8"),markdown.encode("utf-8"),Category.encode("utf-8"),ID):
                tohtml.html().ALL()
                self.write(u'OK,文章已成功发布!')
            else:
                self.write(u'Error!')
コード例 #4
0
ファイル: server.py プロジェクト: kooksee/myblog
 def get(self):
     tohtml.html().ALL()
     self.redirect('/')
コード例 #5
0
ファイル: server.py プロジェクト: kooksee/myblog
 def post(self):
     CMD = self.get_argument('CMD','')
     ID = self.get_argument('ID','')
     name = self.get_argument('name','')
     TYPE = self.get_argument('TYPE','')
     remark = self.get_argument('remark','')
     HTML = self.get_argument('EHTML','')
     LINK = self.get_argument('LINK','')
     if CMD=='DEL':
         if TYPE in ('NAV','LINK'):
             try:
                 db.db("DELETE FROM LINK WHERE ID='%s' " % ID)
             except:
                 pass
         elif TYPE=='LAST':
             try:
                 db.db("DELETE FROM Other WHERE ID='%s' " % ID)
             except:
                 pass
         tohtml.html().ALL()
         self.redirect('/custom')
     elif CMD=='UP':
         if TYPE=="LAST":
             db.db("UPDATE Other SET NAME='%s',HTML='%s',Remark='%s' WHERE ID='%s'" % (name,HTML.replace('\'','\'\'').replace('\\','\\\\'),remark,ID))
         elif TYPE in ('NAV','LINK'):
             db.db("UPDATE LINK SET NAME='%s',LINK='%s' WHERE ID='%s'" % (name,LINK,ID))
         tohtml.html().ALL()
         self.redirect('/custom')
     elif CMD=='NEW':
         if TYPE=="LAST":
             db.db("INSERT INTO  Other (NAME,HTML,Remark,LOCATION,TYPE) VALUES ('%s','%s','%s','%s','belong')" % (name,HTML.replace('\'','\'\'').replace('\\','\\\\'),remark,TYPE.lower()))
         elif TYPE in ('NAV','LINK'):
             db.db("INSERT INTO  LINK (NAME,LINK,TYPE) VALUES ('%s','%s','%s')" % (name,LINK,TYPE.lower()))
         tohtml.html().ALL()
         self.redirect('/custom')
     elif CMD == 'HTML':
         try:
             HTML = db.db("SELECT HTML FROM Other WHERE ID='%s' " % ID)[0][0]
         except:
             pass
         else:
             self.write(HTML.strip().replace('\'\'','\'').replace('\\\\','\\'))
     elif CMD=="DUOSHUO":
         try:
             db.db("UPDATE Ver SET DUOSHUO='%s' WHERE ID='1' " % name)
         except Exception as e:
             self.write("设定失败,原因:%s" % e)
         else:
             tohtml.html().ALL()
             self.write("多说ID已成功设定为:%s" % name)
     elif CMD=="JS":
         if TYPE=='CX':
             try:
                 JSCODE = db.db("SELECT HTML FROM Other WHERE NAME='JSCODE' ")[0][0]
             except:
                 self.write('')
             else:
                 self.write(JSCODE.replace('\'\'','\'').replace('\\\\','\\'))
         elif TYPE=='UP':
             try:
                 db.db("UPDATE Other SET HTML='%s' WHERE NAME='JSCODE'" % HTML.replace('\'','\'\'').replace('\\','\\\\'))
             except Exception as e:
                 self.write(u'修改失败!')
             else:
                 tohtml.html().ALL()
                 self.write(u'修改成功!')