def create_room(self,user): if(self.request.get("name")==""): Alert.alert_msg_with_write(self,"ルーム名は必須です。") return if(not user): Alert.alert_msg_with_write(self,"ルームの作成にはログインが必要です。") return user_name=self.get_user_name(user) canvas_size=self.request.get("canvas_size") size=canvas_size.split("x") canvas_width=int(size[0]) canvas_height=int(size[1]) room=ChatRoom() room.name=self.request.get("name") room.user_id=user.user_id() room.user_name=user_name room.command_list="" room.command_cnt=0 room.user_count=0 room.snap_range=0 room.create_date=datetime.datetime.now() room.canvas_width=canvas_width room.canvas_height=canvas_height room.password=self.request.get("pass") room.is_always=0 if(room.password=="always"): room.is_always=1 room.password="" SyncPut.put_sync(room) self.redirect("./chat")
def del_message_list(self,user): if(self.request.get("user_id")!=user.user_id()): self.response.out.write(Alert.alert_msg("認証に失敗しました。",self.request.host)); return False bookmark=ApiObject.get_bookmark_of_user_id_for_write(user.user_id()) if(bookmark==None): self.response.out.write(Alert.alert_msg("ユーザデータが見つかりません。",self.request.host)); return False tweet_list=self.request.get_all("tweet_list") if(not tweet_list or len(tweet_list)==0): self.response.out.write(Alert.alert_msg("削除するツイートが選択されていません。",self.request.host)); return False for tweet in tweet_list: self.del_from_bookmark(bookmark,tweet) try: data=db.get(tweet) except: data=None if(data): if(data.from_user_id==user.user_id()): data.delete() bookmark.put() return True
def withdraw(self,bookmark,your_bbs_count): user_id=self.request.get("user_id") if(not user_id): Alert.alert_msg_with_write(self,"ユーザIDが必要です。") return True user=users.get_current_user() bookmark=ApiObject.get_bookmark_of_user_id_for_write(user_id) #キャッシュから取得するのを防止 if(not bookmark): Alert.alert_msg_with_write(self,"ユーザが見つかりません。") return True if(OwnerCheck.check_bookmark(bookmark,user)): Alert.alert_msg_with_write(self,"退会する権限がありません。") return True is_english=CssDesign.is_english(self) if(your_bbs_count==0): #delete_user_thread(user.user_id()) #他人の掲示板に描いたイラストは慎重に削除する必要がある気がする bookmark.delete() msg="退会が完了しました。" if(is_english): msg="Complete" Alert.alert_msg_with_write(self,msg); else: msg="退会する前にレンタルしている掲示板を削除する必要があります。<BR>掲示板の削除はマイページのイラストタブで編集を押すことで行うことができます。<BR>残りの掲示板数:"+str(your_bbs_count) if(is_english): msg="You must delete your BBS before withdraw.<br/>You have "+str(your_bbs_count)+" BBS yet." Alert.alert_msg_with_write(self,msg) return True return True
def post(self): bbs = None try: bbs = db.get(self.request.get("bbs_key")) except: bbs = None if bbs == None: self.response.out.write(Alert.alert_msg("削除対象が見つかりません。", self.request.host)) return user = users.get_current_user() if not user: self.response.out.write(Alert.alert_msg("ログインする必要があります。", self.request.host)) return is_admin = OwnerCheck.is_admin(user) if OwnerCheck.check(bbs, user) and (not is_admin): self.response.out.write(Alert.alert_msg("削除する権限がありません。", self.request.host)) return bbs.del_flag = 1 bbs.put() ApiFeed.invalidate_cache() self.redirect(str("./mypage?tab=bbs"))
def get(self): try: thread = db.get(self.request.get("thread_key")) bbs = db.get(self.request.get("bbs_key")) except: thread = None bbs = None if thread == None or bbs == None: Alert.alert_msg_with_write(self, "拍手対象のスレッドが見つかりません。") return not_spam = ( self.request.remote_addr != thread.applause_ip and self.request.remote_addr != thread.applause_ip2 and self.request.remote_addr != thread.applause_ip3 and self.request.remote_addr != thread.applause_ip4 ) if not_spam or self.request.get("comment"): if thread.applause: thread.applause = thread.applause + 1 else: thread.applause = 1 thread.applause_ip4 = thread.applause_ip3 thread.applause_ip3 = thread.applause_ip2 thread.applause_ip2 = thread.applause_ip thread.applause_ip = self.request.remote_addr thread.applause_date = datetime.datetime.today() thread.search_index_version = 0 thread.put() if bbs.applause_n: bbs.applause_n = bbs.applause_n + 1 else: bbs.applause_n = 1 bbs.put() user = users.get_current_user() comment = "" if self.request.get("comment"): comment = self.request.get("comment") StackFeed.feed_new_applause_thread(user, thread, comment) Ranking.add_rank_global(thread, BbsConst.SCORE_APPLAUSE) if self.request.get("mode") == "bbs": order = self.request.get("order") page = self.request.get("page") self.redirect(str(MappingId.get_usr_url("./", bbs) + "?order=" + order + "&page=" + page)) else: thread_url = self.request.get("thread_key") if thread.short: thread_url = thread.short self.redirect(str(MappingId.get_usr_url("./", bbs) + thread_url + ".html"))
def check_id_available(main,app_id): if(app_id=="" or MappingId.key_format_check(app_id)): main.response.out.write(Alert.alert_msg("アプリIDは半角英数である必要があります。",main.request.host)) return False query=AppCode.all().filter("app_id =",app_id) if(query.count()==0): return True main.response.out.write(Alert.alert_msg("このアプリIDは既に使われています。",main.request.host)) return False
def get_bbs(req,bbs_key): bbs_key=MappingId.mapping(bbs_key) if(bbs_key==""): Alert.alert_msg_notfound(req) return None bbs=ApiObject.get_cached_object(bbs_key) if(bbs == None): Alert.alert_msg_notfound(req) return None return bbs
def get(self): try: bbs=db.get(self.request.get("bbs_key")) except: bbs=None if(bbs==None): Alert.alert_msg_notfound(self) return host_url=MappingId.mapping_host_with_scheme(self.request)+"/"; url=MappingId.get_usr_url(host_url,bbs) self.redirect(str(url))
def get(self): try: bbs = db.get(self.request.get("bbs_key")) except: Alert.alert_msg_with_write(self,"掲示板の編集画面のURLが変更されています。掲示板からログインし、デザインの編集ボタンをクリックして下さい。") return user = users.get_current_user() is_admin=0 if(user and OwnerCheck.is_admin(user)): is_admin=1 if(bbs.short!="sample" and OwnerCheck.check(bbs,user) and not is_admin): Alert.alert_msg_with_write(self,"デザインの編集の権限がありません。") return error_str="" if self.request.get("error_str"): error_str=self.request.get("error_str") is_css_enable=OwnerCheck.is_admin(user) my_app_list=None if(user): my_app_list=AppCode.all().filter("user_id =",user.user_id()).filter("mode =",2).fetch(limit=100,offset=0) tab="all" if(self.request.get("tab")): tab=self.request.get("tab") bbs_css=None try: bbs_css=bbs.css except: bbs_css=None template_values = { 'host': './', 'bbs': bbs, 'error_str': error_str, 'is_css_enable': is_css_enable, 'is_admin': is_admin, 'is_iphone': CssDesign.is_iphone(self), 'is_tablet': CssDesign.is_tablet(self), 'my_app_list': my_app_list, 'user': user, 'tab': tab, 'redirect_url': self.request.path, 'bbs_css': bbs_css, 'is_english': CssDesign.is_english(self) } path = '/html/edit_bbs.html' self.response.out.write(template_select.render(path, template_values))
def violate_icon(self): bookmark = ApiObject.get_bookmark_of_user_id_for_write(self.request.get("user_id")) if bookmark == None: Alert.alert_msg_with_write(self, "ブックマークの取得に失敗しました。") return bookmark.thumbnail_created = BbsConst.USER_ICON_THUMBNAIL_VIOLATE bookmark.icon = None bookmark.icon_content_type = None bookmark.icon_mini = None bookmark.icon_mini_content_type = None bookmark.put() self.redirect("./mypage?user_id=" + self.request.get("user_id"))
def set_css(main,css,bbs): if(css): if(css!=""): app=AppPortal.get_app(css) if(app==None): main.response.out.write(Alert.alert_msg("CSSデザインが見つかりません。",main.request.host)) return False if(app.mode!=BbsConst.APP_MODE_CSS): main.response.out.write(Alert.alert_msg("CSSデザインではありません。",main.request.host)) return False bbs.css=app return True
def close_room(self,user): try: room=ChatRoom.get(self.request.get("key"))#db.get(self.request.get("key")) except: room=None if(not room): Alert.alert_msg_with_write(self,"ルームが見つかりません。") return if(not user or room.user_id!=user.user_id()): Alert.alert_msg_with_write(self,"終了する権限がありません。") return room.delete() self.redirect("./chat")
def get_entry_comment(self,template_values,entry_key): if(entry_key==""): return True try: entry=db.get(entry_key) except: entry=None if(entry==None): Alert.alert_msg_notfound(self) return False template_values["summary"]=ReeditEscape.escape(entry.content) template_values["author"]=ReeditEscape.escape(entry.editor) return True
def post(self): bbs=db.get(self.request.get("bbs_key")); try: thread=db.get(self.request.get("thread_key")) except: thread=None try: entry=db.get(self.request.get("entry_key")) except: entry=None try: res=db.get(self.request.get("res_key")) except: res=None user = users.get_current_user() bbs_owner=not OwnerCheck.check(bbs,user) thread_owner=False if(user): if(thread and user.user_id()==thread.user_id): thread_owner=True if(entry and user.user_id()==entry.user_id): thread_owner=True if(res and user.user_id()==res.user_id): thread_owner=True if(not bbs_owner and not thread_owner and not OwnerCheck.is_admin(user)): Alert.alert_msg_with_write(self,"更新する権限がありません。"); return if(thread): if(self.update_thread(bbs,thread,user)): return if(entry): if(self.update_entry(entry,user)): return thread=entry.thread_key if(res): entry=db.get(self.request.get("res_entry_key")) if(self.update_res(res,entry,user)): return thread=entry.thread_key url=MappingThreadId.get_thread_url("./",bbs,thread) if(entry or res): url=url+"?comment_edit=1" self.redirect(str(url))
def get(self): try: bbs=db.get(self.request.get("bbs_key")) except: bbs=None if(bbs==None): Alert.alert_msg_notfound(self) return host_name=self.request.host if(host_name=="http://www.illust-book.appspot.com/"): host_name="http://www.illustbook.net/"; host_url="http://"+MappingId.mapping_host(host_name)+"/"; url=MappingId.get_usr_url(host_url,bbs) self.redirect(str(url+self.request.get("thread_key")+".html"))
def get(self): SetUtf8.set() user = users.get_current_user() if(not user): self.response.out.write(Alert.alert_msg("ログインしている必要があります。",self.request.host)); return; thread=None try: thread = db.get(self.request.get("thread_key")) except: thread=None if(not thread): self.response.out.write(Alert.alert_msg("スレッドが見つかりません。",self.request.host)); return mode = self.request.get("mode") if(not thread.tag_list): thread.tag_list=[] tag=self.request.get("tag") if(tag==""): self.response.out.write(Alert.alert_msg("タグを入力して下さい。",self.request.host)); return; if(mode=="add"): if(thread.tag_list.count(tag)>0): thread.tag_list.remove(tag) thread.tag_list.insert(0,tag) else: thread.tag_list.insert(0,tag) tag_info="[Add Tag] "+tag+" "+str(user.user_id())+" "+user.email() thread.tag_last_edit=tag thread.tag_last_edit_user_id=str(user.user_id()) logging.info(tag_info) else: try: thread.tag_list.remove(tag) except: self.response.out.write(Alert.alert_msg("タグ"+tag+"が見つかりません。",self.request.host)); thread.put() bbs=db.get(self.request.get("bbs_key")) thread=db.get(self.request.get("thread_key")) url=MappingThreadId.get_thread_url("./",bbs,thread) self.redirect(str(url))
def get(self): try: bbs = db.get(self.request.get("bbs_key")) except: bbs=None try: thread = db.get(self.request.get("thread_key")) except: thread=None if(not bbs or not thread): self.response.out.write(Alert.alert_msg("削除対象が見つかりません。",self.request.host)) return is_english=CssDesign.is_english(self) del_ok=0 if(self.request.get("del_key")): if(thread.delete_key): if(thread.delete_key==self.request.get("del_key")): del_ok=1 else: msg="削除キーが一致しません。" if(is_english): msg="invalid key" self.response.out.write(Alert.alert_msg(msg,self.request.host)) return; user = users.get_current_user() bbs_owner = not OwnerCheck.check(bbs,user) thread_owner=False if(user and user.user_id()==thread.user_id): thread_owner=True if(del_ok==0): if(not bbs_owner and not thread_owner and not OwnerCheck.is_admin(user)): self.response.out.write(Alert.alert_msg("削除権限がありません。",self.request.host)) return DelThread.delete_thread_core(thread) bbs.cached_thumbnail_key=None bbs.put() ApiFeed.invalidate_cache() url=MappingId.get_usr_url("./",bbs) self.redirect(str(url))
def get(self): SetUtf8.set() user = users.get_current_user() is_admin=0 if(user): if(OwnerCheck.is_admin(user)): is_admin=1 if(not is_admin): Alert.alert_msg_with_write(self,"管理者権限が必要です。"); return message="" new_code=self.request.get('code') if(new_code): if(len(new_code)>=8): memcache.set("spamcheck",new_code) message="updated check code to "+new_code else: message="too short check code" checkcode=SpamCheck.get_check_code() query=Entry.all() thread=None try: thread=db.get(checkcode) except: thread=None if(thread): query.filter("thread_key =",thread) entrys=query.fetch(limit=1000) ret="" spam_detected=0 for entry in entrys: if(SpamCheck.check_with_thread(entry,checkcode)): ret+=entry.content+"<BR>" spam_detected=1 if(not spam_detected): ret="SpamNotFound" form="code:"+checkcode+"<BR>"+message+"<BR>" form+="<form method='GET' action='spam_check'>thread_key:<input type='text' name='code' size=40><input type='submit' value='UPDATE'></form>"; Alert.alert_msg_with_write(self,"<H2>SPAM CHECKER</H2><H3>CHECK CODE</H3>"+form+"<H3>SPAM LIST</H3>"+ret+"<BR><BR><A HREF='./spam_delete'>DELETE ALL</A>")
def update_thread(self,bbs,thread,user): compiled_line = re.compile("\r\n|\r|\n") title = self.request.get('thread_title') title=self.escape_comment(title) thread.title = title thread.author=self.request.get('thread_author') category = self.request.get("thread_category") thread.category=category CategoryList.add_new_category(bbs,category) event_id = self.request.get("event_id") thread.event_id=event_id summary = self.request.get('thread_summary') summary = compiled_line.sub(r'', summary) thread.summary = summary postscript = self.request.get('thread_postscript') postscript = compiled_line.sub(r'', postscript) thread.postscript = postscript new_show_in_portal = int(self.request.get('dont_show_in_portal')) if((thread.violate_photo and not new_show_in_portal) or (not thread.violate_photo and new_show_in_portal)): ApiFeed.invalidate_cache() thread.violate_photo = new_show_in_portal self.link_to_profile(thread,user) thread.adult=int(self.request.get("regulation")) #thread.hidden_in_list = int(self.request.get('hidden_in_list')) try: thread.comment_cnt = int(self.request.get('comment_cnt')) except: Alert.alert_msg_with_write(self,"コメント数は数値である必要があります。"); return True thread.search_index_version=0 #インデックス更新 thread.put() if(thread.user_id): ApiUser.invalidate_thread_count(thread.user_id) return False
def post(self): SetUtf8.set() page=None if(self.request.get("page")): page=self.request.get("page") user = users.get_current_user() if(not user): if(page=="update"): dic={"status":"failed","message":"アプリを登録するにはログインする必要があります。"} ApiObject.write_json_core(self,dic) return else: self.response.out.write(Alert.alert_msg("アプリを登録するにはログインする必要があります。",self.request.host)) return if(page=="update"): dic=DevPortal.update_app(self,user) if(dic==None): return ApiObject.write_json_core(self,dic) return if(page=="submit"): if(not DevPortal.add_new_app(self,user)): return DevPortal.ret(self,"top")
def get(self): bbs = db.get(self.request.get("bbs_key")) user = users.get_current_user() entry = db.get(self.request.get("entry_key")) entry_owner=False if(user and user.user_id()==entry.user_id): entry_owner=True bbs_owner=not OwnerCheck.check(bbs,user) if(not bbs_owner and not OwnerCheck.is_admin(user) and not entry_owner): self.response.out.write(Alert.alert_msg("削除する権限がありません。",self.request.host)) return entry.del_flag = 0 entry.put() thread = db.get(self.request.get("thread_key")) thread.comment_cnt=thread.comment_cnt-1 thread.cached_entry_key=[] thread.cached_entry_key_enable=None thread.put() url=MappingThreadId.get_thread_url("./",bbs,thread)+"?comment_edit=1" self.redirect(str(url)) RecentCommentCache.invalidate(bbs)
def add_support_forum(main,app): if(not app.support_forum and app.is_public): thread=MesThread() bbs_key=MappingId.mapping(BbsConst.APP_SUPPORT_BBS_ID) if(bbs_key==""): #return False main.response.out.write(Alert.alert_msg("サポートフォーラムBBS[ID:"+BbsConst.APP_SUPPORT_BBS_ID+"]が見つかりません。",main.request.host)) return True bbs=db.get(bbs_key) thread.bbs_key=bbs thread.title=app.app_name thread.author=app.author thread.summary=app.app_name+"のサポートフォーラムです。" thread.user_id=app.user_id thread.illust_mode=BbsConst.ILLUSTMODE_NONE thread.create_date=datetime.datetime.today() thread.comment_cnt=0 thread.date=datetime.datetime.today() thread.put() app.support_forum=thread app.put() #if(not app.support_forum.score): # app.support_forum.score = None # app.support_forum.put() return False
def get_thread_comment(self,template_values,thread_key,entry_key,is_reply): if(thread_key=="" or entry_key!="" or is_reply=="1"): return True try: thread=db.get(thread_key) except: thread=None if(thread==None): Alert.alert_msg_notfound(self) return False template_values["draw_time"]=thread.draw_time template_values["is_png"]=thread.is_png template_values["summary"]=ReeditEscape.escape(thread.summary) template_values["author"]=ReeditEscape.escape(thread.author) template_values["title"]=ReeditEscape.escape(thread.title) return True
def post(self,mode_url): mode=self.request.get("mode") user = users.get_current_user() if(not user): Alert.alert_msg_with_write(self,"ログインが必要です。") return msg="" if(mode=="add"): if(Event.all().filter("id =",self.request.get("id")).count()>=1): Alert.alert_msg_with_write(self,"このIDのイベントは既に存在しています") return event=Event() if(not self._update(event,user,True,True)): return event.put() if(mode=="edit"): event=Event.all().filter("id =",self.request.get("id")).fetch(limit=2) if(not event or len(event)==0): Alert.alert_msg_with_write(self,"イベントが存在しません") return if(len(event)>=2): Alert.alert_msg_with_write(self,"イベントが重複しています") return event=event[0] if(not self._update(event,user,True,False)): return event.put() if(mode=="del"): event=Event.all().filter("id =",self.request.get("id")).fetch(limit=2) if(not event or len(event)==0): Alert.alert_msg_with_write(self,"イベントが存在しません") return event[0].delete() host=MappingId.mapping_host_with_scheme(self.request)+"/" if(mode=="del"): self.redirect(str(host+"?order=event")) else: self.redirect(str(host+"?order=event&event_id="+event.id))
def get(self): SetUtf8.set() user = users.get_current_user() if user: if not OwnerCheck.is_admin(user): Alert.alert_msg_with_write(self, "権限がありません。") return if self.request.get("user_id"): self.violate_icon() return if self.request.get("entry_key"): self.violate_entry() return self.violate_thread()
def add_new_message(self,user): #メッセージ作成 data=StackFeedData() data.feed_mode="message" data.from_user_id=user.user_id() if(self.request.get("to_user_id")): data.to_user_id=self.request.get("to_user_id") else: data.to_user_id=None data.user_key=None data.bbs_key=None data.thread_key=None data.message=self.request.get("message") if(data.message==""): self.response.out.write(Alert.alert_msg("書き込みメッセージが存在しません。",self.request.host)); return False data.create_date=datetime.datetime.today() #二重投稿防止 message=memcache.get("StackFeedTweet") if(message==self.request.get("message")): self.response.out.write(Alert.alert_msg("このメッセージは既に投稿されています。",self.request.host)); return False memcache.set("StackFeedTweet",self.request.get("message"),5) #保存 data.put() #トップページ用ログ格納 recent=StackFeedDataRecent.get_or_insert(data.from_user_id) recent.message=data.message recent.from_user_id=data.from_user_id recent.to_user_id=data.to_user_id recent.put() #自分と相手にフィード StackFeed._append_one(data,user.user_id()) if(data.to_user_id): StackFeed._append_one(data,data.to_user_id) #フォロワーにフィード StackFeed.feed_new_message(user,data) return True
def get(self): SetUtf8.set() #ランキング更新 rank=Ranking.get_or_insert(BbsConst.THREAD_RANKING_KEY_NAME) rank.create_rank(self) ApiFeed.invalidate_cache(); #キャッシュ取得 cache=SiteAnalyzer.get_cache_from_db(); #1日単位で習得 #force=False #if(self.request.get("force")): # force=True if(cache.date and len(cache.day_list)>=1):# and not force): day1_str=NicoTracker.get_day_string(cache.date) day2_str=NicoTracker.get_day_string(datetime.datetime.today()) if(day1_str==day2_str): Alert.alert_msg_with_write(self,"ランキングを更新しました。統計情報はまだ1日が経過していないので計測していません。") return #コメント数と再生数を取得 bbs_cnt=Bbs.all().count(limit=100000) illust_cnt=MesThread.all().count(limit=100000) entry_cnt=Entry.all().count(limit=100000) user_cnt=Bookmark.all().count(limit=100000) #書き込み day_str=NicoTracker.get_day_string(datetime.datetime.today()) cache.entry_cnt_list.insert(0,entry_cnt) cache.illust_cnt_list.insert(0,illust_cnt) cache.bbs_cnt_list.insert(0,bbs_cnt) cache.user_cnt_list.insert(0,user_cnt) cache.day_list.insert(0,day_str) cache.bbs_n=bbs_cnt cache.illust_n=illust_cnt cache.put() Alert.alert_msg_with_write(self,"ランキングを更新しました。")
def delete_app(req): app_key=None if(req.request.get("app_key")): app_key=req.request.get("app_key") app=db.get(app_key) user = users.get_current_user() if(app and user and app.user_id==user.user_id()): app.delete() else: req.response.out.write(Alert.alert_msg("アプリが見つからないか削除する権限がありません。",req.request.host)) return True return False
def get(self): SetUtf8.set() user = users.get_current_user() is_admin=0 if(user): if(OwnerCheck.is_admin(user)): is_admin=1 if(not is_admin): self.response.out.write(Alert.alert_msg("管理者権限が必要です。",self.request.host)); return checkcode=SpamCheck.get_check_code() query=Entry.all() thread=None try: thread=db.get(checkcode) except: thread=None if(thread): query.filter("thread_key =",thread) entrys=query.fetch(limit=1000) ret=0 aborted="" for entry in entrys: if(SpamCheck.check_with_thread(entry,checkcode)): entry.delete() ret=ret+1 if(ret>=250): aborted="ABORTED" break; RecentCommentCache.invalidate(None); self.response.out.write(Alert.alert_msg("<H2>SPAM DELETE RESULT</H2>"+aborted+"<H2>TOTAL</H2>DELETE CNT:"+str(ret),self.request.host))
def post(self): SetUtf8.set() try: bbs = db.get(self.request.get("bbs_key")) except: Alert.alert_msg_with_write(self,"掲示板の取得に失敗しました。") return user = users.get_current_user() if(OwnerCheck.check(bbs,user) and not OwnerCheck.is_admin(user)): Alert.alert_msg_with_write(self,"削除する権限がありません。") return category_count=self.update_category() link_count=self.update_link(user) deleted_count=self.delete_thread(bbs) page=self.request.get("page") order=self.request.get("order") url="./edit_thread_list?bbs_key="+str(bbs.key())+"&page="+str(page)+"&order="+order+"&deleted_count="+str(deleted_count)+"&category_count="+str(category_count)+"&link_count="+str(link_count) self.redirect(str(url))