Example #1
0
	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")
Example #2
0
	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
Example #3
0
    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"))
Example #4
0
	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))
Example #5
0
 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"))
Example #6
0
	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")
Example #7
0
	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))
Example #8
0
	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
Example #9
0
	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>")		
Example #10
0
	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))
Example #11
0
    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()
Example #12
0
	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,"ランキングを更新しました。")
Example #13
0
	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))
Example #14
0
	def get(self,mode_url):
		mode=self.request.get("mode")

		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
		else:
			if(Event.all().filter("id =",self.request.get("id")).count()>=1):
				Alert.alert_msg_with_write(self,"このIDは既に使われています")
				return

		user = users.get_current_user()
		event=Event()
		if(not self._update(event,user,False,False)):
			return
		Alert.alert_msg_with_write(self,"このイベントは作成可能です")
Example #15
0
	def get(self):
		SetUtf8.set()

		is_english=CssDesign.is_english(self)

		short=self.request.get('id')
		if(MappingId.key_format_check(short)):
			txt="IDは半角英数である必要があります。"
			if(is_english):
				txt="ID must be 16 characters or less"
			Alert.alert_msg_with_write(self,txt)
			return
		if(MappingId.check_capability(short,"")==0):
			txt="ID:"+short+"は既に登録されていて利用できません。"
			if(is_english):
				txt="ID:"+short+" is not available"
			Alert.alert_msg_with_write(self,txt)
			return
		txt="ID:"+short+"は利用可能です。"
		if(is_english):
			txt="ID:"+short+" is available"
		Alert.alert_msg_with_write(self,txt)
Example #16
0
	def post(self):
		bbs_key=self.request.get("bbs_key")
		short=self.request.get('short')
		if(MappingId.key_format_check(short)):
			Alert.alert_msg_with_write(self,"IDは半角英数である必要があります。")
			return
		if(MappingId.check_capability(short,bbs_key)==0):
			Alert.alert_msg_with_write(self,"ID:"+short+"は既に登録されています。")
			return
		bbs=db.get(bbs_key);
		user = users.get_current_user()
		if(OwnerCheck.check(bbs,user) and not OwnerCheck.is_admin(user)):
			Alert.alert_msg_with_write(self,"デザインの編集を行う権限がありません。")
			return
		summary = self.request.get('bbs_summary')

		bg_color=self.format_color(self.request.get('bg_color'))
		font_color=self.format_color(self.request.get('font_color'))
		hr_color=self.format_color(self.request.get('hr_color'))
		content_bg_color=self.format_color(self.request.get('content_bg_color'))
		content_font_color=self.format_color(self.request.get('content_font_color'))
		menu_bg_color=self.format_color(self.request.get('menu_bg_color'))
		menu_font_color=self.format_color(self.request.get('menu_font_color'))
		side_color=self.format_color(self.request.get('side_color'))
		side_font_color=self.format_color(self.request.get('side_font_color'))
		twitter_bg_color=self.format_color(self.request.get('twitter_bg_color'))
		twitter_font_color=self.format_color(self.request.get('twitter_font_color'))
		twitter_shell_color=self.format_color(self.request.get('twitter_shell_color'))

		if(menu_bg_color=="None"):
			menu_bg_color="ffffff";
		if(menu_font_color=="None"):
			menu_font_color="333333";
		if(content_bg_color=="None"):
			content_bg_color="ffffff";
		if(content_font_color=="None"):
			content_font_color="333333";
		if(hr_color=="None"):
			hr_color="b5ae9d";

		if(side_color=="None"):
			side_color="ffffff";
		if(side_font_color=="None"):
			side_font_color="333333";
		if(twitter_bg_color=="None"):
			twitter_bg_color="ffffff";
		if(twitter_font_color=="None"):
			twitter_font_color="333333";
		if(twitter_shell_color=="None"):
			twitter_shell_color="ffffff";

		if re.match('[0-9a-fA-F]{1,6}', bg_color) == None:
			error_str="bg_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return
		if re.match('[0-9a-fA-F]{1,6}', font_color) == None:
			error_str="font_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return
		if re.match('[0-9a-fA-F]{1,6}', hr_color) == None:
			error_str="hr_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return
		if re.match('[0-9a-fA-F]{1,6}', twitter_bg_color) == None:
			error_str="twitter_bg_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return
		if re.match('[0-9a-fA-F]{1,6}', twitter_font_color) == None:
			error_str="twitter_font_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return
		if re.match('[0-9a-fA-F]{1,6}', side_color) == None:
			error_str="side_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return
		if re.match('[0-9a-fA-F]{1,6}', side_font_color) == None:
			error_str="side_font_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return

		if re.match('[0-9a-fA-F]{1,6}', content_bg_color) == None:
			error_str="content_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return
		if re.match('[0-9a-fA-F]{1,6}', content_font_color) == None:
			error_str="content_font_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return

		if re.match('[0-9a-fA-F]{1,6}', menu_bg_color) == None:
			error_str="menu_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return
		if re.match('[0-9a-fA-F]{1,6}', menu_font_color) == None:
			error_str="menu_font_color is invalid"
			self.redirect(str('./edit_bbs?bbs_key='+self.request.get("bbs_key")+'&error_str='+error_str))
			return
			
		if self.request.get('title'):
			bbs.bbs_name=self.request.get('title')
		bbs.my_homepage=self.request.get('my_homepage')
		bbs.background_image=self.request.get('background_image')
		bbs.side_background_image=self.request.get('side_background_image')
		bbs.bottom_image=self.request.get('bottom_image')
		if(bbs.background_image=="None"):
			bbs.background_image=""
		if(bbs.side_background_image=="None"):
			bbs.side_background_image=""
		if(bbs.bottom_image=="None"):
			bbs.bottom_image=""
		bbs.short=short
		if(bbs.short=="None"):
			bbs.short=""
		MappingId.invalidate(short)

		try:
			if(self.request.get('default_canvas_width')=="None"):
				bbs.default_canvas_width=0
			else:
				bbs.default_canvas_width=int(self.request.get('default_canvas_width'))
			if(self.request.get('default_canvas_height')=="None"):
				bbs.default_canvas_height=0
			else:
				bbs.default_canvas_height=int(self.request.get('default_canvas_height'))
		except:
			bbs.default_canvas_width=0
			bbs.default_canvas_height=0

		if(self.request.get('content_width')=="None"):
			bbs.content_width=800
		else:
			try:
				bbs.content_width=int(self.request.get('content_width'))
			except:
				bbs.content_width=800
		if(bbs.content_width<800):
			bbs.content_width=800
		if(bbs.content_width>1280):
			bbs.content_width=1280

		try:
			if(self.request.get('illust_reply_width')=="None"):
				bbs.illust_reply_width=400
			else:
				bbs.illust_reply_width=int(self.request.get('illust_reply_width'))
			if(self.request.get('illust_reply_height')=="None"):
				bbs.illust_reply_height=200
			else:
				bbs.illust_reply_height=int(self.request.get('illust_reply_height'))
		except:
			bbs.illust_reply_width=400
			bbs.illust_reply_height=200
		
		try:
			bbs.recent_comment_n=int(self.request.get('recent_comment_n'))
		except:
			bbs.recent_comment_n=8

		try:
			bbs.recent_thread_n=int(self.request.get('recent_thread_n'))
		except:
			bbs.recent_thread_n=8

		try:
			bbs.font_size=int(self.request.get('font_size'))
		except:
			bbs.font_size=0

		bbs.disable_counter=int(self.request.get('disable_counter'))
		bbs.disable_draw_time=int(self.request.get('disable_draw_time'))
		#bbs.disable_portal_menu=int(self.request.get('disable_portal_menu'))
		bbs.disable_news=int(self.request.get('disable_news'))
		bbs.violate_terms=int(self.request.get('violate_terms'))
		bbs.disable_comment=int(self.request.get('disable_comment'))
		bbs.disable_tag=int(self.request.get('disable_tag'))
		bbs.default_order=int(self.request.get('order'))
		bbs.default_comment_order=int(self.request.get('comment_order'))
		bbs.comment_hidden_button=int(self.request.get('comment_hidden_button'))
		bbs.disable_author=int(self.request.get('disable_author'))
		bbs.disable_title=int(self.request.get('disable_title'))
		bbs.show_remote_addr_id=int(self.request.get('show_remote_addr_id'))

		bbs.tweet_disable=int(self.request.get('tweet_disable'))
		bbs.twitter_enable=int(self.request.get('twitter_enable'))
		bbs.twitter_id=self.request.get('twitter_id')
		height=self.request.get('twitter_height')
		if(height=="None" or height==""):
			height="300"
		bbs.twitter_height=int(height)

		bbs.in_frame_mode=int(self.request.get('in_frame_mode'))
		
		bbs.button_color=self.format_color(self.request.get('button_color'))
		bbs.button_font_color=self.format_color(self.request.get('button_font_color'))
		bbs.button_border_color=self.format_color(self.request.get('button_border_color'))
		bbs.button_active_color=self.format_color(self.request.get('button_active_color'))

		if(bbs.button_color=="None"):
			bbs.button_color=""
		if(bbs.button_active_color=="None"):
			bbs.button_active_color=""
		if(bbs.button_border_color=="None"):
			bbs.button_border_color=""
		if(bbs.button_font_color=="None"):
			bbs.button_font_color=""

		bbs.button_color_enable=int(self.request.get("button_color_enable"))

		amazon=self.request.get('amazon')
		amazon_title=self.request.get('amazon_title')
		freearea=self.request.get('freearea')
		freearea_title=self.request.get('freearea_title')
		comment_rule=self.request.get('comment_rule')
		if(amazon=="None"):
			amazon=""
		if(amazon_title=="None"):
			amazon_title=""
		if(freearea=="None"):
			freearea=""
		if(freearea_title=="None"):
			freearea_title=""
		if(comment_rule=="None"):
			comment_rule=""

		#summary = cgi.escape(summary)
		compiled_line = re.compile("\r\n|\r|\n")
		summary = compiled_line.sub(r'<br/>', summary)
		freearea = compiled_line.sub(r'<br/>', freearea)
		amazon = compiled_line.sub(r'<br/>', amazon)
		comment_rule = compiled_line.sub(r'<br/>', comment_rule)
		
		bbs.summary = summary
		bbs.amazon = amazon
		bbs.freearea = freearea
		bbs.comment_rule = comment_rule
		bbs.amazon_title = amazon_title
		bbs.freearea_title = freearea_title
		
		bbs.script_head = self.request.get("script_head")

		bbs.bg_color=bg_color
		bbs.font_color=font_color
		bbs.hr_color=hr_color
		bbs.content_bg_color=content_bg_color
		bbs.content_font_color=content_font_color
		bbs.menu_bg_color=menu_bg_color
		bbs.menu_font_color=menu_font_color

		bbs.twitter_bg_color=twitter_bg_color
		bbs.twitter_font_color=twitter_font_color
		bbs.twitter_shell_color=twitter_shell_color
		bbs.side_color=side_color
		bbs.side_font_color=side_font_color
		bbs.disable_content_image=int(self.request.get("disable_content_image"))

		try:
			bbs.design_template_no=int(self.request.get("design_template_no"))
		except:
			css=self.request.get("design_template_no")
			bbs.design_template_no=BbsConst.CSS_CUSTOM
			#css=self.request.get("css")
			if(not UpdateBbs.set_css(self,css,bbs)):
				return

		bbs.bbs_mode=int(self.request.get("mode"))
		bbs.comment_rule_enable=int(self.request.get("comment_rule_enable"))
		bbs.category_list=self.request.get("category_list")
		bbs.disable_category_sort=int(self.request.get("disable_category_sort"))
		bbs.deny_host_list=self.request.get("deny_host_list")
		bbs.enable_continue_draw=int(self.request.get("enable_continue_draw"))
		bbs.enable_illust_reply=int(self.request.get("enable_illust_reply"))
		bbs.enable_illust_reply_continue=int(self.request.get("enable_illust_reply_continue"))
		bbs.disable_normal_reply=int(self.request.get("disable_normal_reply"))
		bbs.enable_moper=int(self.request.get("enable_moper"))
		bbs.enable_full_flat=int(self.request.get("enable_full_flat"))
		bbs.enable_full_comment=int(self.request.get("enable_full_comment"))
		bbs.disable_applause=int(self.request.get("disable_applause"))
		bbs.disable_analyze=int(self.request.get("disable_analyze"))
		bbs.comment_login_require=int(self.request.get("comment_login_require"))
		bbs.disable_create_new_thread=int(self.request.get("disable_create_new_thread"))
		bbs.disable_create_new_illust=int(self.request.get("disable_create_new_illust"))
		bbs.dont_count_owner=int(self.request.get("dont_count_owner"))
		bbs.date_format=int(self.request.get("date_format"))
		bbs.move_account=self.request.get("move_account")
		bbs.show_only_movie=int(self.request.get("show_only_movie"))
		#bbs.dont_permit_app=int(self.request.get("dont_permit_app"))
		bbs.delete_when_upload_success=int(self.request.get("delete_when_upload_success"))
		bbs.disable_import_image=int(self.request.get("disable_import_image"))
		
		bbs.tool_bg_color=self.request.get("tool_bg_color")
		if(bbs.tool_bg_color=="None"):
			bbs.tool_bg_color=None
		
		try:
			bbs.page_illust_n=int(self.request.get("page_illust_n"))
		except:
			bbs.page_illust_n=5

		try:
			bbs.page_comment_n=int(self.request.get("page_comment_n"))
		except:
			bbs.page_comment_n=10
		
		if(bbs.page_illust_n<1) :bbs.page_illust_n=1
		if(bbs.page_illust_n>10) :bbs.page_illust_n=10
		if(bbs.page_comment_n<1) :bbs.page_comment_n=1
		if(bbs.page_comment_n>50) :bbs.page_comment_n=50
				
		bbs.put()
		
		RecentCommentCache.invalidate(bbs);

		#feed update
		ApiFeed.invalidate_cache()
		
		if(bbs.move_account):
			self.redirect(str('./move_account?bbs_key='+self.request.get("bbs_key")))
		else:
			self.redirect(str('./bbs_index?bbs_key='+self.request.get("bbs_key")))
Example #17
0
	def get(self,regist_mode):
		SetUtf8.set()

		#表示モードかどうか
		view_mode=None
		if(self.request.get("user")):
			view_mode=self.request.get("user")
		
		#ユーザ検索
		if(self.request.get("user_id")):
			target_bookmark=ApiObject.get_bookmark_of_user_id(self.request.get("user_id"))
			if(target_bookmark==None):
				Alert.alert_msg_with_write(self,"ユーザが見つかりません。")
				return
			view_mode=str(target_bookmark.key());
		
		#リダイレクトURL
		host=MappingId.mapping_host_with_scheme(self.request)+"/";
		redirect_url=host+"mypage";
	
		#編集モードか
		edit_mode=0
		if(self.request.get("edit")):
			edit_mode=int(self.request.get("edit"))
	
		#掲示板一覧
		user = users.get_current_user()
		favorite=""
		bookmark=None

		#管理人かどうか
		is_admin=0
		if(OwnerCheck.is_admin(user)):# and self.request.get("is_admin")):
			is_admin=1

		#自分だったらビューモードにしない
		if(user and self.request.get("user_id")==user.user_id() and not self.request.get("withdraw")):
			view_mode=0
		
		#ログインしているか
		login_flag=0
		if(user):
			login_flag=1

		#表示設定
		if(view_mode):
			bookmark=db.get(view_mode)
		else:
			if user:
				bookmark=ApiObject.get_bookmark_of_user_id(user.user_id())
			else:
				bookmark=None

		#掲示板の新規作成が完了したか
		regist_finish=False
		if(regist_mode=="regist"):
			regist_finish=True
		
		#プロフィールを編集
		edit_profile=Pinterest.get_profile_for_edit(bookmark,view_mode)
		
		#アカウントの凍結
		if(self.request.get("freez") and is_admin):
			bookmark=ApiObject.get_bookmark_of_user_id_for_write(self.request.get("user_id"))
			bookmark.frozen=int(self.request.get("freez"))
			bookmark.put()
		
		#退会
		if(self.request.get("withdraw") and self.request.get("withdraw")=="go"):
			if(not bookmark):
				Alert.alert_msg_with_write(self,"ユーザ情報は未登録です。");
				return
			your_bbs_count=Bbs.all().filter("del_flag =",0).filter("user_id =",bookmark.user_id).count()
			if(self.withdraw(bookmark,your_bbs_count)):
				return;

		#リダイレクト
		if(BbsConst.PINTEREST_MODE):
			if((user and OwnerCheck.is_admin(user)) or BbsConst.PINTEREST_MODE==2):
				if(regist_finish):
					return Pinterest.get_core(self,Pinterest.PAGE_MODE_REGIST)
				else:
					return Pinterest.get_core(self,Pinterest.PAGE_MODE_MYPAGE)
Example #18
0
	def post(self):
		if(self.request.get('bbs_title')==""):
			Alert.alert_msg_with_write(self,"タイトルを入力して下さい。");
			return                        
		if(self.request.get('bbs_summary')==""):
			Alert.alert_msg_with_write(self,"概要を入力して下さい。");
			return                        
		user = users.get_current_user()
		summary = self.request.get('bbs_summary')		
		
		if(int(self.request.get('official'))==1):
			Alert.alert_msg_with_write(self,"オフィシャル掲示板は廃止されました。");
			return                        
		
		if (not user):
			if(int(self.request.get('official'))==0):
				self.redirect(str(users.create_login_url("")))
				return
		
		#summary = cgi.escape(summary)
		compiled_line = re.compile("\r\n|\r|\n")
		summary = compiled_line.sub(r'<br>', summary)

		short=self.request.get('short')
		if(MappingId.key_format_check(short)):
			Alert.alert_msg_with_write(self,"IDは半角英数である必要があります。")
			return		
		if(MappingId.check_capability(short,"")==0):
			Alert.alert_msg_with_write(self,"ID:"+short+"は既に登録されています。")
			return
		if(short==""):
			Alert.alert_msg_with_write(self,"IDを入力する必要があります。")
			return
				
		new_bbs = Bbs()
		new_bbs.official=int(self.request.get('official'))
		new_bbs.illust_n=0
		new_bbs.bbs_name = cgi.escape(self.request.get('bbs_title'))
		new_bbs.summary = summary
		new_bbs.owner = user
		new_bbs.user_id = user.user_id()
		new_bbs.bg_color="ffffff"
		new_bbs.font_color="333333"
		new_bbs.background_image=""
		new_bbs.bottom_image=""
		new_bbs.button_color="999999"
		new_bbs.button_active_color="777777"
		new_bbs.bbs_mode=int(self.request.get('mode'))
		new_bbs.my_homepage=""
		new_bbs.del_flag=0
		new_bbs.enable_continue_draw=0
		new_bbs.enable_moper=0
		new_bbs.enable_full_flat=1
		new_bbs.short=short
		new_bbs.delete_when_upload_success=1
		
		new_bbs.applause_n=0
		new_bbs.illust_n=0
		new_bbs.comment_n=0
		
		new_bbs.page_illust_n=5
		new_bbs.page_comment_n=10
		new_bbs.disable_applause=0
		new_bbs.default_order=0
		
		new_bbs.enable_illust_reply=1
		new_bbs.enable_illust_reply_continue=0
		new_bbs.disable_normal_reply=0
		new_bbs.illust_reply_width=400
		new_bbs.illust_reply_height=200
		
		new_bbs.side_color="ffffff"
		new_bbs.side_font_color="333333"
		new_bbs.side_background_image=""
		
		new_bbs.comment_rule_enable=0
		new_bbs.comment_rule=""

		new_bbs.default_canvas_size=0
		new_bbs.default_canvas_width=0
		new_bbs.default_canvas_height=0
		new_bbs.disable_counter=0
		new_bbs.disable_draw_time=0
		new_bbs.disable_portal_menu=0
		new_bbs.in_frame_mode=0;
		new_bbs.spoit_mode=0;
		new_bbs.disable_news=0;
		
		new_bbs.twitter_id=""
		new_bbs.twitter_enable=0
		new_bbs.twitter_bg_color="ffffff"
		new_bbs.twitter_font_color="333333"
		new_bbs.twitter_shell_color="ffffff"
		new_bbs.twitter_height=300
		
		new_bbs.design_template_no=1
		
		new_bbs.content_bg_color="ffffff"
		new_bbs.content_font_color="333333"
		
		new_bbs.content_width=800
		
		new_bbs.enable_full_comment=1

		new_bbs.freearea=""
		new_bbs.amazon=""
		new_bbs.freearea_title=""
		new_bbs.amazon_title=""
		
		new_bbs.create_date=datetime.datetime.today()

		if(memcache.get(BbsConst.OBJECT_NEW_BBS_CREATING_HEADER+short)):
			Alert.alert_msg_with_write(self,"二重投稿を検知しました。戻ってリロードして下さい。")
			return
		memcache.set(BbsConst.OBJECT_NEW_BBS_CREATING_HEADER+short,"creating",BbsConst.NEW_BBS_CACHE_TIME)
		
		counter=Counter()
		counter.init_cnt()
		counter.put()
		new_bbs.counter=counter.key()
		SyncPut.put_sync(new_bbs)

		self.redirect(str(self.request.get('redirect')))
Example #19
0
	def get(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

		user = users.get_current_user()

		page=1
		if(self.request.get("page")):
			page=int(self.request.get("page"))

		order="new"
		if(self.request.get("order")):
			order=self.request.get("order")
		
		limit=20
		offset=(page-1)*limit

		query=db.Query(MesThread,keys_only=True)
		query.filter("bbs_key =",bbs)
		if(order=="new"):
			query.order("-create_date")
		else:
			query.order("create_date")

		thread_key_list=query.fetch(offset=offset,limit=limit)
		thread_list=[]
		for thread_key in thread_key_list:
			try:
				thread_list.append(db.get(thread_key))
			except:
				continue

		deleted_count=self.request.get("deleted_count")
		category_count=self.request.get("category_count")
		link_count=self.request.get("link_count")

		if(deleted_count):
			deleted_count=int(deleted_count)
		if(category_count):
			category_count=int(category_count)
		if(link_count):
			link_count=int(link_count)

		category_list=CategoryList.get_category_list(bbs)

		template_values = {
			'host': './',
			'bbs': bbs,
			'user': user,
			'thread_list': thread_list,
			'redirect_url': self.request.path,
			'page': page,
			'order': order,
			'deleted_count': deleted_count,
			'category_count': category_count,
			'link_count': link_count,
			'is_iphone': CssDesign.is_iphone(self),
			'is_tablet': CssDesign.is_tablet(self),
			'category_list': category_list,
			'is_english': CssDesign.is_english(self)
		}

		path = '/html/edit_thread_list.html'
		self.response.out.write(template_select.render(path, template_values))
Example #20
0
	def write_status(self,is_flash,msg):
		if(is_flash):
			self.response.headers ['Content-type'] = "text/html;charset=utf-8";
			self.response.out.write(msg);
		else:
			Alert.alert_msg_with_write(self,msg);
Example #21
0
	def tool(self,user):
		bbs=None
		bbs_key=""
		thread_key=""

		if(self.request.get("key")=="always"):
			try:
				room_key=ChatRoom.all().filter("is_always =",1).fetch(1)[0].key()
			except:
				room_key=None
		else:
			room_key=self.request.get("key")
		if(not room_key):
			Alert.alert_msg_with_write(self,"ルームキーが必要です。")
			return

		ipad=CssDesign.is_tablet(self)
		viewmode=self.request.get("viewmode")
		password=self.request.get("pass")

		try:
			room=ChatRoom.get(room_key)#db.get(room_key)
		except:
			room=None

		alert_footer=""#<BR><A HREF='./chat'><IMG SRC='./static_files/chat/logo.png'/></A>"

		login_message=""
		if(not user):
			login_url=users.create_login_url(self.request.url)
			login_message="<BR><A HREF='"+login_url+"' class='g-button'>Googleアカウントでログイン</A><BR>"

		if(not room):
			Alert.alert_msg_with_write(self,"このチャットルームは終了されています。"+alert_footer)
			return
		
		if(room.password and room.password!=password):
			Alert.alert_msg_with_write(self,"チャットルームのパスワードが一致しません。"+alert_footer)
			return
		
		#if(not user):
		#	Alert.alert_msg_with_write(self,"チャットルームへの参加にはログインが必要です。<BR>"+login_message+alert_footer)
		#	return

		canvas_width=room.canvas_width
		canvas_height=room.canvas_height

		if(user):
			user_id=user.user_id()
			#user_name=self.get_user_name(user)
		else:
			user_id=0
		
		user_name=self.request.get("name")

		server_time=Chat.get_sec(datetime.datetime.now())
		
		if(user):
			bbs_list=Bbs.all().filter("user_id =",user.user_id()).filter("del_flag =",0).fetch(limit=10)
		else:
			bbs_list=None

		quote_name=urllib.quote_plus(str(user_name)).replace("%","-")
		client_id=str(user_id)+"_"+str(server_time)+"_"+quote_name
		token = channel.create_channel(client_id)

		#排他制御が必要
		Chat.add_user(room_key,client_id)

		template_values = {
		'host': "./",
		'bbs': bbs,
		'bbs_key': bbs_key,
		'thread_key': thread_key,
		'entry_key': "",
		'draw_time': "",
		'canvas_width': canvas_width,
		'canvas_height': canvas_height,
		'canvas_url': "",
		'reply': False,
		'summary': "",
		'author': "",
		'title': "",
		'chat': room_key,
		'ipad': ipad,
		'user_id':user_id,
		'user_name':user_name,
		'server_time':server_time,
		'bbs_list':bbs_list,
		'logined':True,
		'viewmode':viewmode,
		'room_name':room.name,
		'token':token,
		'client_id':client_id,
		'is_english':CssDesign.is_english(self)
		}
		
		path = '/html/tools/draw_window_ipad.htm'
		self.response.out.write(template_select.render(path, template_values))
Example #22
0
	def get(self):
		try:
			bbs=db.get(self.request.get("bbs_key"));
		except:
			bbs=None

		if(not bbs):
			Alert.alert_msg_with_write(self,"編集する掲示板が見つかりません。")
			return

		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

		if(not thread and not entry and not res):
			Alert.alert_msg_with_write(self,"編集する対象が見つかりません。")
			return

		user = users.get_current_user()
		
		bbs_owner=not OwnerCheck.check(bbs,user)

		thread_owner=False
		if(user):
			if(thread):
				if(user.user_id()==thread.user_id):
					thread_owner=True
			if(entry):
				if(user.user_id()==entry.user_id):
					thread_owner=True
			if(res):
				if(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
		
		summary=""
		postscript=""
		category=""

		if(thread):
			summary=thread.summary
			if(thread.postscript):
				postscript=thread.postscript
			summary=ReeditEscape.escape(summary);
			postscript=ReeditEscape.escape(postscript);
			category=thread.category

		host_url="./"
		design=CssDesign.get_design_object(self,bbs,host_url,1)
		category_list=CategoryList.get_category_list(bbs)
		event_list=EventList.get_event_list()

		template_values = {
			'host': './',
			'bbs': bbs,
			'thread': thread,
			'entry': entry,
			'res': res,
			'summary': summary,
			'postscript': postscript,
			'template_path':design["template_path"],
			'css_name':design["css_name"],
			'is_iphone':design["is_iphone"],
			'is_tablet':design["is_tablet"],
			'template_base_color':design["template_base_color"],
			'user': user,
			'redirect_url': self.request.path,
			'edit_thread': True,
			'category_list': category_list,
			'event_list': event_list,
			'selecting_category': category,
			'res_entry_key': self.request.get("res_entry_key"),
			'is_english': CssDesign.is_english(self)
		}

		path = '/html/edit_thread.html'
		self.response.out.write(template_select.render(path, template_values))
Example #23
0
	def get(self):
		SetUtf8.set()

		mode = self.request.get("mode")

		#スレッド取得
		thread = AddBookmark.get_one_db(self.request.get("thread_key"))
		if(not thread and mode=="add"):	#削除はスレッドが見つからなくてもできるようにする
			Alert.alert_msg_with_write(self,"スレッドが見つかりません。");
			return
		
		#BBS取得
		bbs=AddBookmark.get_one_db(self.request.get("bbs_key"))
		if(not bbs and mode=="add_bbs"):
			Alert.alert_msg_with_write(self,"掲示板が見つかりません。");
			return
		
		#アプリ取得
		app=AddBookmark.get_one_db(self.request.get("app_key"))
		if(not app and mode=="add_app"):
			Alert.alert_msg_with_write(self,"アプリが見つかりません。");
			return
		
		#ログイン要求
		user = users.get_current_user()
		if(not(user)):
			Alert.alert_msg_with_write(self,"ブックマークをする場合はログインが必須です。");
			return
		
		bookmark=ApiObject.get_bookmark_of_user_id_for_write(user.user_id())
		if(bookmark==None):
			Alert.alert_msg_with_write(self,"ブックマークの取得に失敗しました。");
			return
		
		#ユーザ
		add_user_key=self.request.get("user_key")

		#ブックマーク数を初期化
		if(thread):
			if(not thread.bookmark_count):
				thread.bookmark_count=0
		if(bbs):
			if(not bbs.bookmark_count):
				bbs.bookmark_count=0

		add_thread_key=None
		if(self.request.get("thread_key")):
			add_thread_key=db.Key(self.request.get("thread_key"))
		
		add_bbs_key=None
		if(self.request.get("bbs_key")):
			add_bbs_key=db.Key(self.request.get("bbs_key"))
		
		add_app_key=None
		if(self.request.get("app_key")):
			add_app_key=db.Key(self.request.get("app_key"))

		comment=None
		if(self.request.get("comment")):
			comment=self.request.get("comment")

		#unpack mute_bbs_list
		mute_bbs_list=bookmark.get_mute_bbs_list()
		mute_user_list=bookmark.get_mute_user_list()

		#add bookmark
		feed_enable=False
		if(mode=="add"):
			AddBookmark.add_comment(thread,user.user_id(),comment)
			feed_enable=AddBookmark.add_one(bookmark.thread_key_list,add_thread_key,thread,True)
		if(mode=="add_bbs"):
			feed_enable=AddBookmark.add_one(bookmark.bbs_key_list,add_bbs_key,bbs,True)
		if(mode=="add_mute_bbs"):
			feed_enable=AddBookmark.add_one(mute_bbs_list,str(add_bbs_key),bbs,False)
		if(mode=="add_app"):
			AddBookmark.add_one(bookmark.app_key_list,add_app_key,app,True)
		if(mode=="add_user"):
			feed_enable=AddBookmark.add_user(bookmark.user_list,add_user_key)
		if(mode=="add_mute_user"):
			feed_enable=AddBookmark.add_user(mute_user_list,add_user_key)
		
		#del bookmark
		if(mode=="del"):
			AddBookmark.del_one(bookmark.thread_key_list,add_thread_key,thread,True)
		if(mode=="del_bbs"):
			AddBookmark.del_one(bookmark.bbs_key_list,add_bbs_key,bbs,True)
		if(mode=="del_mute_bbs"):
			AddBookmark.del_one(mute_bbs_list,str(add_bbs_key),bbs,False)
		if(mode=="del_app"):
			AddBookmark.del_one(bookmark.app_key_list,add_app_key,app,True)
		if(mode=="del_user"):
			if(add_user_key in bookmark.user_list):
				bookmark.user_list.remove(add_user_key)
		if(mode=="del_mute_user"):
			if(add_user_key in mute_user_list):
				mute_user_list.remove(add_user_key)
	
		#pack mute_bbs_list
		bookmark.mute_bbs_packed_str_list=""
		for one_bbs in mute_bbs_list:
			bookmark.mute_bbs_packed_str_list+=str(one_bbs)+"#"
		bookmark.mute_user_packed_str_list=""
		for m_user in mute_user_list:
			bookmark.mute_user_packed_str_list+=str(m_user)+"#"

		#フォロー先のユーザのフォロワーを更新するようにリクエスト
		if(mode=="add_user" or mode=="del_user"):
			ApiObject.invalidate_follower_list(add_user_key)

		#write
		bookmark.put()

		#feed(feed内でもbookmark.putを行うため、bookmark.putの前に置いてはいけない)
		if(mode=="add"):
			if(feed_enable):
				StackFeed.feed_new_bookmark_thread(user,thread,comment)
				Ranking.add_rank_global(thread,BbsConst.SCORE_BOOKMARK)
		if(mode=="add_bbs"):
			if(feed_enable):
				StackFeed.feed_new_bookmark_bbs(user,bbs)
		if(mode=="add_user"):
			if(feed_enable):
				StackFeed.feed_new_follow(user,add_user_key)
		if(mode=="del_user"):
			StackFeed.feed_unfollow(user,add_user_key)

		#redirect
		url="./mypage"
		if(mode=="del" or mode=="add"):
			url=url+"?tab=bookmark"
		if(mode=="del_bbs" or mode=="add_bbs"):
			url=url+"?tab=bbs"
		if(mode=="del_mute_bbs" or mode=="add_mute_bbs"):
			url=url+"?tab=bbs"
		if(mode=="add_user" or mode=="del_user"):
			url=url+"?user_id="+add_user_key

		if(mode=="add" or mode=="add_bbs"):
			Alert.alert_msg_with_write(self,"success");
		else:
			self.redirect(str(url))
Example #24
0
    def get(self):
        SetUtf8.set()

        page_name = ""
        mode = "access"
        if self.request.get("mode"):
            mode = self.request.get("mode")

        bbs = None

        user = None
        if page_name == "":
            try:
                bbs = db.get(self.request.get("bbs_key"))
            except:
                bbs = None
            if bbs == None:
                Alert.alert_msg_notfound(self)
                return

            user = users.get_current_user()
            if user:
                if bbs.user_id != user.user_id():
                    user = None

            page_name = bbs.bbs_name

        if self.request.get("start_date"):
            start_date = self.request.get("start_date")
            if not self.validate_date(start_date):
                Alert.alert_msg_with_write(self, "日付指定は0000-00-00形式である必要があります。")
                return
        else:
            start_date = str(datetime.date.today() + datetime.timedelta(days=-31))

        if self.request.get("end_date"):
            end_date = self.request.get("end_date")
            if not self.validate_date(end_date):
                Alert.alert_msg_with_write(self, "日付指定は0000-00-00形式である必要があります。")
                return
        else:
            end_date = str(datetime.date.today() + datetime.timedelta(days=-1))

        start_day = datetime.datetime.strptime(start_date, "%Y-%m-%d")
        end_day = datetime.datetime.strptime(end_date, "%Y-%m-%d")
        if start_day > end_day:
            Alert.alert_msg_with_write(self, "終了日よりも開始日の方が大きくなっています。")
            return

        bbs_id = bbs.short
        is_admin = OwnerCheck.is_admin(user)
        if is_admin:
            if self.request.get("bbs_id"):
                bbs_id = self.request.get("bbs_id")
                if bbs.short != bbs_id:
                    page_name = bbs_id

        page_list = None
        ref_list = None
        keyword_list = None
        access_list = None

        show_analyze = False
        if user or bbs.short == "sample":
            show_analyze = True

        if show_analyze:
            try:
                result = self.get_analytics(mode, bbs_id, start_date, end_date)
            except:
                time.sleep(1)
                try:
                    result = self.get_analytics(mode, bbs_id, start_date, end_date)
                except:
                    Alert.alert_msg_with_write(self, "Analytics APIへのアクセスに失敗しました。リロードして下さい")
                    logging.error("failed analytics api")
                    return

            if mode == "page":
                page_list = result
            if mode == "ref":
                ref_list = result
            if mode == "keyword":
                keyword_list = result
            if mode == "access":
                access_list = result

        quota_error = mode == "access" and not access_list

        redirect_api = (
            "analyze?start_date="
            + start_date
            + "&amp;end_date="
            + end_date
            + "&amp;bbs_id="
            + bbs_id
            + "&amp;bbs_key="
            + str(bbs.key())
            + "&amp;"
        )

        host_url = "./"
        template_values = {
            "host": host_url,
            "mode": mode,
            "redirect_api": redirect_api,
            "quota_error": quota_error,
            "bbs": bbs,
            "bbs_id": bbs_id,
            "page_name": page_name,
            "is_admin": is_admin,
            "user": user,
            "show_analyze": show_analyze,
            "ref_list": ref_list,
            "page_list": page_list,
            "keyword_list": keyword_list,
            "access_list": access_list,
            "start_date": start_date,
            "end_date": end_date,
            "is_iphone": CssDesign.is_iphone(self),
            "is_tablet": CssDesign.is_tablet(self),
            "is_english": CssDesign.is_english(self),
            "redirect_url": self.request.path,
        }
        path = "/html/analyze.html"
        self.response.out.write(template_select.render(path, template_values))
Example #25
0
	def _update(self,event,user,validate_all,is_create):
		event.title=self.request.get("title")
		event.summary=self.request.get("summary")

		if(is_create):
			event.summary=EscapeComment.escape_br(event.summary)
			event.summary=EscapeComment.auto_link(event.summary)

		event.id=self.request.get("id")
		if(event.id==""):
			Alert.alert_msg_with_write(self,"IDを入力する必要があります。")
			return False
		if(MappingId.key_format_check(event.id)):
			Alert.alert_msg_with_write(self,"IDは半角英数で16文字以下である必要があります。")
			return False

		try:
			event.start_date=datetime.datetime.strptime(self.request.get("start_date"), '%Y/%m/%d').replace(tzinfo=JST()).astimezone(UTC())
			event.end_date=datetime.datetime.strptime(self.request.get("end_date"), '%Y/%m/%d').replace(tzinfo=JST()).astimezone(UTC())
		except:
			Alert.alert_msg_with_write(self,"日付の変換に失敗しました。")
			return False

		if(event.end_date <= event.start_date):
			Alert.alert_msg_with_write(self,"終了日の方が開始日より早くなっています。")
			return False

		event_list=Event.all().filter("start_date <=",event.end_date).order("-start_date").fetch(limit=1)	#既存のDBが重複していないと仮定すると最新の1つだけチェックすればよい
		for e in event_list:
			if(e.id==event.id):
				continue
			err=False
			if(e.start_date.replace(tzinfo=UTC()).astimezone(UTC()) <= event.start_date):
				if(e.end_date.replace(tzinfo=UTC()).astimezone(UTC()) > event.start_date):
					err=True
			if(e.start_date.replace(tzinfo=UTC()).astimezone(UTC()) < event.end_date):
				if(e.end_date.replace(tzinfo=UTC()).astimezone(UTC()) > event.end_date):
					err=True
			if(err):
				mes ="今回のイベント&nbsp;"+str(event.start_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"〜"+str(event.end_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"<br/>";
				mes+="他のイベント&nbsp;"+str(e.start_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"〜"+str(e.end_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"<br/>";
				Alert.alert_msg_with_write(self,"日程が他のイベントと重複しています。<br/>"+mes)
				return False

		if(event.end_date - event.start_date > datetime.timedelta(days=BbsConst.EVENT_MAX_DAYS)):
			Alert.alert_msg_with_write(self,"日程が2週間を超えています。")
			return False

		if(validate_all):
			if(event.title=="" or event.id==""):
				Alert.alert_msg_with_write(self,"タイトルとIDを入力して下さい。")
				return False
		if(is_create):
			event.user_id=user.user_id()
		if(is_create or event.user_id==user.user_id()):
			event.author=self.request.get("author")
		return True
Example #26
0
	def post(self):
		SetUtf8.set()

		mode = self.request.get("mode")
		name = self.request.get("name")
		profile = self.request.get("profile")
		homepage = self.request.get("homepage")
		mail = self.request.get("mail")
		twitter = self.request.get("twitter")
		birthday_year = self.request.get("birthday_year")
		birthday_month = self.request.get("birthday_month")
		birthday_day = self.request.get("birthday_day")

		regulation=0
		if(self.request.get("regulation_r15_nl")):
			regulation+=1
		if(self.request.get("regulation_r15_bl")):
			regulation+=2
		if(self.request.get("regulation_r15_gl")):
			regulation+=4

		privacy_rental_bbs=1
		if(self.request.get("privacy_rental_bbs")):
			privacy_rental_bbs=0

		disable_global_tweet=1
		if(self.request.get("privacy_tweet")):
			disable_global_tweet=0

		disable_rankwatch=1
		if(self.request.get("privacy_user_ranking")):
			disable_rankwatch=0

		if(disable_global_tweet):
			cache_id=BbsConst.OBJECT_CACHE_HEADER+BbsConst.OBJECT_TWEET_LIST_HEADER
			memcache.delete(cache_id)

		is_english=CssDesign.is_english(self)

		if(name==""):
			if(is_english):
				Alert.alert_msg_with_write(self,"No name");
			else:
				Alert.alert_msg_with_write(self,"名前がありません。");
			return

		#if(profile==""):
		#	Alert.alert_msg_with_write(self,"プロフィールがありません。");
		#	return

		user = users.get_current_user()
		if(not(user)):
			Alert.alert_msg_with_write(self,"ログインが必要です。");
			return
		
		bookmark=ApiObject.get_bookmark_of_user_id_for_write(user.user_id())
		if(bookmark==None):
			Alert.alert_msg_with_write(self,"プロフィールの取得に失敗しました。");
			return
		
		profile = cgi.escape(profile)
		compiled_line = re.compile("\r\n|\r|\n")
		profile = compiled_line.sub(r'<br/>', profile)

		if(mail=="None"):
			mail=""
		if(homepage=="None"):
			homepage=""
		if(twitter=="None"):
			twitter=""

		bookmark.name=name
		bookmark.profile=profile
		bookmark.mail=mail
		bookmark.twitter_id=twitter
		bookmark.homepage=homepage
		bookmark.owner=user
		bookmark.disable_rankwatch=disable_rankwatch
		bookmark.disable_global_tweet=disable_global_tweet
		bookmark.regulation=regulation
		bookmark.privacy_rental_bbs=privacy_rental_bbs

		if(self.request.get("my_color")=="" or self.request.get("my_color")=="#f2f2f2"):
			bookmark.my_color=None
		else:
			bookmark.my_color=self.request.get("my_color")
		
		bookmark.sex=int(self.request.get("sex"))

		if(birthday_year):
			try:
				birthday_year=int(birthday_year)
			except:
				if is_english:
					Alert.alert_msg_with_write(self,"Birthday must be number");
				else:
					Alert.alert_msg_with_write(self,"生まれた年は半角数字である必要があります。");
				return
		else:
			birthday_year=0

		if(birthday_month):
			try:
				birthday_month=int(birthday_month)
			except:
				if is_english:
					Alert.alert_msg_with_write(self,"Birthday must be number");
				else:
					Alert.alert_msg_with_write(self,"生まれた月は半角数字である必要があります。");
				return
		else:
			birthday_month=0
		
		if(birthday_day):
			try:
				birthday_day=int(birthday_day)
			except:
				if is_english:
					Alert.alert_msg_with_write(self,"Birthday must be number");
				else:
					Alert.alert_msg_with_write(self,"生まれた日は半角数字である必要があります。");
				return
		else:
			birthday_day=0
		
		bookmark.birthday_year=birthday_year
		bookmark.birthday_month=birthday_month
		bookmark.birthday_day=birthday_day
		
		bookmark.icon_mini=None	#サムネイルの再作成を要求
		bookmark.thumbnail_created=0

		age=Pinterest.get_age(bookmark)
		if(bookmark.regulation and age>=1 and age<=14):
			Alert.alert_msg_with_write(self,"制限付きコンテンツを表示するには15歳以上である必要があります。");
			return


		if(self.request.get("icon")):
			bookmark.icon=db.Blob(self.request.get("icon"))
			img = self.request.body_file.vars['icon']
			bookmark.icon_content_type=img.headers['content-type']
			if(not ApiObject.create_user_thumbnail(bookmark)):
				if is_english:
					Alert.alert_msg_with_write(self,"Too big icon image");
				else:
					Alert.alert_msg_with_write(self,"アイコン画像が大きすぎます。");
				return

		try:
			SyncPut.put_sync(bookmark)
		except:
			Alert.alert_msg_with_write(self,"データストアへの保存に失敗しました。アイコンの容量が1MBを超えている場合は縮小してからアップロードして下さい。");
			return

		self.redirect(str("./mypage"))
Example #27
0
	def get(self):
		host_url=MappingId.mapping_host_with_scheme(self.request)+"/"
		bbs_key=self.request.get("bbs_key")
		thread_key=self.request.get("thread_key")
		try:
			bbs = db.get(self.request.get("bbs_key"))
		except:
			 bbs=None
		if(bbs==None):
			Alert.alert_msg_with_write(self,"ブックが見つかりません。")
			return

		ipad=CssDesign.is_tablet(self)
		iphone=CssDesign.is_iphone(self)
		if(ipad or iphone):
			Alert.alert_msg_with_write(self,"iPhoneやiPadでは動画お絵かきツールは使用できません。")
			return

		draw_time=0
		summary=""
		author=""
		title=""

		if(thread_key!=""):
			try:
				thread=db.get(thread_key)
			except:
				thread=None
			if(thread==None):
				Alert.alert_msg_with_write(self,"スレッドが見つかりません。")
				return
			draw_time=thread.draw_time

			summary=ReeditEscape.escape(thread.summary)
			author=ReeditEscape.escape(thread.author)
			title=ReeditEscape.escape(thread.title)

		canvas_url=self.request.get("canvas_url");
		if(canvas_url!=""):
			canvas_url=host_url+"moper_load?id="+canvas_url
			
		force=0
		canvas_width=400
		canvas_height=400
		if(self.request.get("canvas_width")):
			canvas_width=self.request.get("canvas_width")
		if(self.request.get("canvas_height")):
			canvas_height=self.request.get("canvas_height")
		if(self.request.get("force")):
			force=self.request.get("force")
		
		template_values = {
		'host': host_url,
		'bbs': bbs,
		'thread_key': thread_key,
		'bbs_key': bbs_key,
		'canvas_url': canvas_url,
		'canvas_width': canvas_width,
		'canvas_height': canvas_height,
		'force': force,
		'draw_time': draw_time,
		'summary': summary,
		'author': author,
		'title': title
		}
		path = '/html/tools/draw_window_moper.htm'
		self.response.out.write(template_select.render(path, template_values))
Example #28
0
	def get(self,bbs_key):
		#日本語対応
		SetUtf8.set()

		#英語版かどうか
		is_english=CssDesign.is_english(self)

		
		#メンテナンス中かどうか
		is_maintenance=0
		if(MaintenanceCheck.is_appengine_maintenance()):
			is_maintenance=1

		#掲示板を取得
		bbs=ShowBbs.get_bbs(self,bbs_key)
		if(bbs==None):
			return

		#掲示板削除チェック
		if(bbs.del_flag) :
			if(is_english):
				Alert.alert_msg_with_write(self,"This bbs was deleted.")
			else:
				Alert.alert_msg_with_write(self,"この掲示板は削除されました。")
			return

		#ページ取得
		page = 1
		if self.request.get("page"):
			try:
				page = int(self.request.get("page"))
			except:
				Alert.alert_msg_with_write(self,"ページ番号が異常です。")
				return
			if page<1 :
				page=1

		#描画順を取得
		order=ShowBbs.get_order(self,bbs)
		
		#カテゴリ取得
		category=""
		if(self.request.get("category")):
			category=self.request.get("category")
		
		#スレッド一覧を取得
		thread_query=ShowBbs.get_thread_query(bbs,category,order)
		
		#1ページのイラスト数を取得
		col_num=ShowBbs.get_col_num(bbs,order)

		#スレッド数とスレッドを取得
		count_limit=(BbsConst.PAGE_LIST_COUNT+page)*col_num	#ページ番号生成用にしか使わないのでページ番号のMaxがわかれば良い
		if(category==""):
			threads_num = bbs.cached_threads_num
		else:
			threads_num = thread_query.count(limit=count_limit)
		all_threads = thread_query.fetch(limit=col_num, offset=(page-1)*col_num)
		
		#返信イラストを取得
		all_entries = None
		#if(order=="thumbnail"):
		#	all_entries=ShowBbs.get_illust_reply(bbs,page,col_num)
		#	if(threads_num<all_entries["count"]):
		#		threads_num=all_entries["count"]
		#	all_entries=all_entries["entry"]
		
		#ホストURLを取得
		host_url="http://"+MappingId.mapping_host(self.request.host)+"/";
		
		#URLを作成
		mapped_category=urllib.quote(category.encode('utf-8'))
		page_url=MappingId.get_usr_url(host_url,bbs)
		page_url_base=MappingId.get_usr_url(host_url,bbs)+'?order='+order+'&amp;category='+mapped_category+'&amp;page='
		page_url_order_base=MappingId.get_usr_url(host_url,bbs)+'?page=1&amp;category='+mapped_category+'&amp;order='
		page_url_category_base=MappingId.get_usr_url(host_url,bbs)+'?page=1&amp;order='+order+"&amp;category="

		#ページリストを作成
		page_list=PageGenerate.generate_page(page,threads_num,col_num)
		
		#ログインユーザを取得
		user = users.get_current_user()

		logined=0
		if(user):
			logined=1
		
		owner=user
		if(OwnerCheck.check(bbs,user)):
			owner=None
		
		#サイドバーコメントを取得
		side_comment=RecentCommentCache.get_entry(bbs)
		side_thread=RecentCommentCache.get_thread(bbs)
		
		#カテゴリ一覧を取得
		category_list=None
		if(bbs.category_list):
			if(bbs.category_list!=""):
				category_list=CategoryList.get_category_list(bbs) #bbs.category_list.split(",")

		#ページデザインを取得
		css_key=self.request.get("css_key")
		design=CssDesign.get_design_object(self,bbs,host_url,0)

		#サイドバー一覧を作成
		sidebar_list=ShowBbs.get_sidebar(bbs,category_list,side_comment,side_thread)

		#新規スレッドを作成できるか
		can_create_thread=ShowBbs.get_can_create_thread(bbs,user,logined)
		can_create_new_image=ShowBbs.get_can_create_new_image(bbs,owner)

		#スレッドを全て取得
		all_threads_cached=ApiObject.get_cached_object_list(all_threads)
		
		#コメントフォームを表示するか
		show_comment_form=1
		if(bbs.comment_login_require and not(owner)):
			show_comment_form=0

		#フルコメントデバッグ
		if(self.request.get("full_comment")):
			bbs.enable_full_comment=1

		#フルフラット表示をデフォルト化
		if(bbs.bbs_mode==BbsConst.BBS_MODE_NO_IMAGE):
			bbs.enable_full_flat=0
			bbs.enable_full_comment=0
		else:
			bbs.enable_full_flat=1
			#bbs.enable_full_comment=1 #デフォルト化を止める

		#コメントを全て取得
		#user_name=""
		user_name=ShowEntry.get_user_name(user)
		if(bbs.enable_full_comment):
			admin_user=OwnerCheck.is_admin(user)
			ShowEntry.render_comment_list(self,all_threads_cached,host_url,bbs,show_comment_form,logined,admin_user,user_name,user)

		#デザインの編集ができるか
		can_edit_design=False
		is_admin=OwnerCheck.is_admin(user)
		if(owner or (is_admin and bbs.bbs_mode==BbsConst.BBS_MODE_EVERYONE)):
			can_edit_design=True

		#infinite_scrollを使用するかどうか
		infinite_scroll=False
		#if(bbs.bbs_mode!=BbsConst.BBS_MODE_NO_IMAGE):# and design["is_iphone"]):
		infinite_scroll=True

		#infinite_scrollの2ページ目以降
		contents_only=0
		if(self.request.get("contents_only")=="1"):
			contents_only=1

		#メッセージ
		message=memcache.get(BbsConst.OBJECT_BBS_MESSAGE_HEADER+str(bbs.key()))

		#カウントアップコメント
		if(bbs.counter):
			bbs.counter.new_day_update()
		count_up_comment=None
		#if(bbs.dont_count_owner):
		#	if(owner):
		#		count_up_comment="管理人"
		#	else:
		#		count_up_comment="ユーザ"

		#カテゴリリスト
		show_category_list=False
		if(self.request.get("show_category_list")=="1"):
			show_category_list=True

		#レンダリング
		template_values = {
			'host': host_url,
			'usrhost': MappingId.get_usr_url(host_url,bbs),
			'threads': all_threads_cached,
			'all_entries':all_entries,
			'bbs':bbs,
			'new_url': 'create_new_thread',
			'page':page,
			'page_url':page_url,
			'page_url_base':page_url_base,
			'order':order,
			'page_url_order_base':page_url_order_base,
			'page_list':page_list,
			'user':user,
			'owner': owner,
			'side_comment':side_comment,
			'side_thread':side_thread,
			'logined':logined,
			'can_create_thread':can_create_thread,
			'category_list':category_list,
			'page_url_category_base':page_url_category_base,
			'now_category':category,
			'can_create_new_image':can_create_new_image,
			'template_path':design["template_path"],
			'css_name':design["css_name"],
			'is_iphone':design["is_iphone"],
			'is_tablet':design["is_tablet"],
			'template_base_color':design["template_base_color"],
			'sidebar_list': sidebar_list,
			'is_maintenance': is_maintenance,
			'css_key': css_key,
			'redirect_url': self.request.path,
			'show_comment_form': show_comment_form,
			'user_name': user_name,
			'is_admin': is_admin,
			'can_edit_design': can_edit_design,
			'infinite_scroll': infinite_scroll,
			'infinite_scroll_selecter': ".entry",
			'contents_only': contents_only,
			'message': message,
			'is_english': is_english,
			'count_up_comment': count_up_comment,
			'show_category_list': show_category_list
		}

		path = "/html/"+design["base_name"]
		self.response.out.write(template_select.render(path, template_values))
		
		if(is_maintenance):
			return
		
		CounterWorker.update_counter(self,bbs,None,owner)
Example #29
0
	def get(self,bbs_key,thread_key):
		SetUtf8.set()

		#ホストチェック
		if SpamCheck.is_deny(self.request):
			self.response.set_status(401)
			return

		#英語版かどうか
		is_english=CssDesign.is_english(self)

		#BBSを取得
		bbs_key=MappingId.mapping(bbs_key)
		bbs=ApiObject.get_cached_object(bbs_key)
		if(bbs == None):
			Alert.alert_msg_notfound(self)
			return

		#BBSが削除されていた場合
		if(bbs.del_flag) :
			if(is_english):
				Alert.alert_msg_with_write(self,"This bbs was deleted.")
			else:
				Alert.alert_msg_with_write(self,"このBBSは削除されました。")
			return
		
		#ページ番号を取得
		col_num = 10
		page = 1
		if self.request.get("page"):
			page = int(self.request.get("page"))
			if page < 1:
				page=1
		
		#メンテナンス画面
		is_maintenance=0
		if(MaintenanceCheck.is_appengine_maintenance()):
			is_maintenance=1

		#オーダー取得
		order="update"
		if(bbs.default_comment_order==1):
			order="new"
		if self.request.get("order"):
			order=self.request.get("order")
		
		#スレッド取得
		thread=ShowThread.get_thread(bbs,thread_key)
		if(thread == None):
			Alert.alert_msg_notfound(self)
			return

		#コメント数を更新
		if(bbs.page_comment_n):
			col_num=bbs.page_comment_n
		if(self.request.get("limit")):
			col_num=int(self.request.get("limit"))

		#コメントの一覧を取得
		query=ShowThread.get_comment_query(thread,order)
		entry_num = query.count()
		if(entry_num==0):
			com_list_ = []
		else:
			com_list_ = query.fetch(limit=col_num, offset=(page-1)*col_num)
		
		#検索
		search=""
		if(self.request.get("search")):
			search=self.request.get("search")
			query=""+search+' thread_key:"'+str(thread.key())+'"'
			com_list_=SearchThread.search(query,page,col_num,BbsConst.SEARCH_ENTRY_INDEX_NAME)
		
		#実体への変換
		com_list_=ApiObject.get_cached_object_list(com_list_)

		#現在のスレッドへのURLを取得
		host_url=MappingId.mapping_host_with_scheme(self.request)+"/"
		
		#編集モードか
		user = users.get_current_user()
		edit_flag = 0
		if(not OwnerCheck.check(bbs,user)):
			edit_flag = 1

		logined=0
		if(user):
			logined=1

		owner=user
		if(OwnerCheck.check(bbs,user)):
			owner=None

		admin_user=OwnerCheck.is_admin(user)

		#ページリンクを作成
		page_url_base = MappingId.get_usr_url(host_url,bbs)+thread_key+'.html?page='
		page_list=ShowThread.create_page_list(page,entry_num,col_num)
		
		#掲示板のデザインを取得
		design=CssDesign.get_design_object(self,bbs,host_url,1)

		#コメントフォームを取得する
		show_comment_form=1
		if(bbs.comment_login_require and not(owner)):
			show_comment_form=0
		
		#名前取得
		user_name=ShowEntry.get_user_name(user)
		
		#自分のイラストか
		my_illust=False
		if(user and thread.user_id==user.user_id()):
			my_illust=True

		#IPを表示するかどうか
		show_ip=False
		if(self.request.get("show_ip") and (owner or admin_user)):
			show_ip=True

		#コメントのレンダリング
		comment=ShowEntry.render_comment(self,host_url,bbs,thread,com_list_,edit_flag,bbs_key,logined,show_comment_form,admin_user,user_name,user,show_ip)
		
		#凍結されているか
		frozen=ApiObject.is_frozen_thread(thread)

		#拍手が有効かどうか
		applause_enable=not (user and thread.user_id and thread.user_id==user.user_id())

		#メッセージ
		message=memcache.get(BbsConst.OBJECT_THREAD_MESSAGE_HEADER+str(thread.key()))

		#関連イラスト
		related=self._get_related(bbs,thread,design["is_iphone"],design["is_tablet"])

		#スパム対策
		force_login_to_create_new_image=BbsConst.FORCE_LOGIN_TO_CREATE_NEW_IMAGE
		force_login_to_create_new_comment=BbsConst.FORCE_LOGIN_TO_CREATE_NEW_COMMENT

		#描画
		template_values = {
			'host': host_url,
			'usrhost': MappingId.get_usr_url(host_url,bbs),
			'bbs': bbs,
			'bbs_str_key': str(bbs.key()),
			'thread': thread,
			'edit_flag':edit_flag,
			'url': 'edit',
			'url_linktext': 'edit blogs',
			'bbs_key': bbs_key,
			'page':page,
			'page_url_base':page_url_base,
			'page_list':page_list,
			'logined':logined,
			'user':user,
			'owner':owner,
			'my_illust':my_illust,
			'template_path':design["template_path"],
			'css_name':design["css_name"],
			'is_iphone':design["is_iphone"],
			'is_tablet':design["is_tablet"],
			'template_base_color':design["template_base_color"],
			'admin_user':admin_user,
			'order':order,
			'is_maintenance':is_maintenance,
			'redirect_url': self.request.path,
			'comment':comment,
			'show_comment_form':show_comment_form,
			'user_name':user_name,
			'search': search,
			'limit': col_num,
			'frozen': frozen,
			'applause_enable': applause_enable,
			'message': message,
			'is_english': is_english,
			'related': related,
			'show_ip': show_ip,
			'force_login_to_create_new_image': force_login_to_create_new_image,
			'force_login_to_create_new_comment': force_login_to_create_new_comment
			}

		path = "/html/"+design["base_name"]
		self.response.out.write(template_select.render(path, template_values))

		CounterWorker.update_counter(self,bbs,thread,owner)
Example #30
0
	def post(self):
		SetUtf8.set()
		is_english=CssDesign.is_english(self)

		entry=None
		try:
			entry = db.get(self.request.get("entry_key"))
		except:
			entry=None
		if(not entry):
			Alert.alert_msg_with_write(self,"エントリーが見つかりません。");
			return

		thread_key=entry.thread_key
		bbs_key=thread_key.bbs_key

		#スパムチェック
		if(self.request.get("seed")!=BbsConst.SUBMIT_SEED):
			Alert.alert_msg_with_write(self,"シードが一致しません。");
			return

		#コメント禁止
		if(thread_key.prohibit_comment):
			Alert.alert_msg_with_write(self,"このイラストへのコメントは禁止されています。");
			return

		#書き込み権限チェック
		user = users.get_current_user()
		if(bbs_key.comment_login_require):
			if(not(user)):
				Alert.alert_msg_with_write(self,"この掲示板ではコメントする際にログインが必須です。");
				return

		response = Response()
		if(self.request.get('comment')):
			response.content = cgi.escape(self.request.get('comment'))
		else:
			Alert.alert_msg_with_write(self,"コメントを入力して下さい。");
			return

		#二重投稿ブロック
		if(response.content!="" and memcache.get("add_res_double_block")==response.content):
			url=MappingThreadId.get_thread_url("./",bbs_key,thread_key)
			self.redirect(str(url))
			return

		is_flash=False
		if(SpamCheck.check_all(self,response.content,self.request.get("remote_host"),user,bbs_key,is_flash,is_english)):
			return

		response.content=EscapeComment.escape_br(response.content)
		response.content=EscapeComment.auto_link(response.content)
		
		if(self.request.get('author')):
			try:
				response.editor = cgi.escape(self.request.get('author'))
			except:
				Alert.alert_msg_with_write(self,"名前に改行は使用できません。");
				return
		else:
			response.editor = "no_name"
			if(is_english):
				Alert.alert_msg_with_write(self,"Please input name");
			else:
				Alert.alert_msg_with_write(self,"名前を入力して下さい。");
			return

		#プロフィールにリンクするか
		link_to_profile=StackFeed.is_link_to_profile(self)
		if(link_to_profile and user):
			response.user_id=user.user_id()

		#コメント番号を設定
		response.comment_no=thread_key.comment_cnt+1
		response.remote_addr=self.request.remote_addr
		response.remote_host=self.request.get("remote_host")

		#レスを書き込み
		response.put()
		
		#レスをコメントに追加
		entry.res_list.append(response.key())
		entry.last_update_editor = response.editor
		entry.date=datetime.datetime.today()
		entry.search_index_version=0
		entry.put()
		
		#スレッドのコメント数を更新
		thread = thread_key
		thread.comment_cnt = thread.comment_cnt+1
		thread.date=datetime.datetime.today()
		thread.put()

		#コメント数を更新
		if(bbs_key.comment_n) :
			bbs_key.comment_n=bbs_key.comment_n+1
		else:
			bbs_key.comment_n=1
		bbs_key.put()
		RecentCommentCache.invalidate(bbs_key)

		#ステータス出力
		url=MappingThreadId.get_thread_url("./",bbs_key,thread_key)
		if(self.request.get("redirect_url")):
			url=self.request.get("redirect_url")
		self.redirect(str(url))

		#二重投稿ブロック
		memcache.set("add_res_double_block",self.request.get("comment"),30)

		#ランキング
		Ranking.add_rank_global(thread,BbsConst.SCORE_RES)

		#フィード
		if(not link_to_profile):
			user=None
		try:
			StackFeed.feed_new_response_entry(user,thread,entry,response)
		except:
			logging.error("new res stack feed add error")