def jstie(db): """ 新版本的Tie过程 """ url = request.GET.get('url', '').strip() title = request.GET.get('title', '').strip() tag = request.GET.get('tag', '').strip() catid = int(request.GET.get('category', '').strip()) notes = request.GET.get('notes', '').strip() isheart = request.GET.get('heart', '').strip() if not url or isdeny(url): #返回1x1的数据,表示正确,实为吞没 response['Content-Type'] = 'image/png' return png_1x1 if ulen(url) > 1024: url = ulenget(url, 1024) if ulen(title) > 1024: title = ulenget(title, 1024) if tag: tag = refineTag(tag) if ulen(tag) > 1024: tag = ulenget(tag, 1024) if ulen(notes) > 1024: notes = ulenget(notes, 1024) try: catid = int(catid) #检查这个catid是否存在 db.execute('SELECT ID FROM CATEGORY WHERE ID=%s', catid) v = db.getone() if not v: raise Exception("invalid catid param") #非法用户插入,选用默认的结果. except: catid = getdefaultcatid(db) heart = 0 if isheart: heart = 1 shortid = 0 if url: shortid = getshorturlid(url) db.execute( 'INSERT INTO URLS(IS_HEART,IS_ARCHIVED,ARCHIVED_OK,CATEGORY_ID,URL,SHORT_URL_ID,TITLE,TAG,NOTES,TIE_TIME) VALUES(%s,0,0,%s,%s,%s,%s,%s,%s,%s)', (heart, catid, url, shortid, title, tag, notes, nt())) recordid = db.insert_id() if needarchive(db) and archiveapiok(db) and url: db.execute('UPDATE URLS SET IS_ARCHIVED=2 WHERE ID=%s', recordid) db.commit() response['Content-Type'] = 'image/png' return png_1x1
def jstie(db): """ 新版本的Tie过程 """ url = request.GET.get('url','').strip() title = request.GET.get('title','').strip() tag = request.GET.get('tag','').strip() catid = int(request.GET.get('category','').strip()) notes = request.GET.get('notes','').strip() isheart = request.GET.get('heart','').strip() if not url or isdeny(url): #返回1x1的数据,表示正确,实为吞没 response['Content-Type'] = 'image/png' return png_1x1 if ulen(url) > 1024: url = ulenget(url,1024) if ulen(title) > 1024: title=ulenget(title,1024) if tag: tag = refineTag(tag) if ulen(tag) > 1024: tag = ulenget(tag,1024) if ulen(notes) > 1024: notes= ulenget(notes,1024) try: catid = int(catid) #检查这个catid是否存在 db.execute('SELECT ID FROM CATEGORY WHERE ID=%s',catid) v = db.getone() if not v: raise Exception("invalid catid param") #非法用户插入,选用默认的结果. except: catid = getdefaultcatid(db) heart = 0 if isheart: heart = 1 shortid = 0 if url: shortid = getshorturlid(url) db.execute('INSERT INTO URLS(IS_HEART,IS_ARCHIVED,ARCHIVED_OK,CATEGORY_ID,URL,SHORT_URL_ID,TITLE,TAG,NOTES,TIE_TIME) VALUES(%s,0,0,%s,%s,%s,%s,%s,%s,%s)',(heart,catid,url,shortid,title,tag,notes,nt())) recordid = db.insert_id() if needarchive(db) and archiveapiok(db) and url: db.execute('UPDATE URLS SET IS_ARCHIVED=2 WHERE ID=%s',recordid) db.commit() response['Content-Type'] = 'image/png' return png_1x1
def importonecat(db, cat): catname = cat['title'] if ulen(catname) > 128: catname = ulenget(catname, 128) catid = createnewcat(db, catname) for alink in cat['links']: importalink(db, catid, alink)
def importonecat(db,cat): catname = cat['title'] if ulen(catname) > 128: catname = ulenget(catname,128) catid = createnewcat(db,catname) for alink in cat['links']: importalink(db,catid,alink)