Пример #1
0
	def post(self):
		self.response.headers ['Content-type'] = "text/html;charset=utf-8"  

		try:
			bbs = db.get(self.request.get("bbs_key"))
			user = users.get_current_user()

			if(bbs.bbs_mode==BbsConst.BBS_MODE_ONLY_ADMIN):
				if(OwnerCheck.check(bbs,user)):
					self.response.out.write("[error]")
					return
			
			if(self.request.get("thread_key")):
				thread=db.get(self.request.get("thread_key"))
				timage=thread.image_key
				if(OwnerCheck.check(bbs,user)):
					if(thread.delete_key=="" or thread.delete_key!=self.request.get("delete_key")):
						self.response.out.write("[error]")
						return					
			else:
				timage=ThreadImage()
			
			timage.bbs_key=db.get(self.request.get("bbs_key"))
			timage.image=db.Blob(self.request.get("image"))			
			timage.thumbnail=db.Blob(self.request.get("thumbnail"))			
			
			#削除するチャンクのリスト
			old_chunk_list_key=copy.deepcopy(timage.chunk_list_key)

			#Chunkに分割して入れる
			timage.moper=None
			timage.chunk_list_key=ChunkManager.upload(self.request.get("moper"),db.get(self.request.get("bbs_key")))
			
			timage.gif_thumbnail=db.Blob(self.request.get("gif_thumbnail"))			
			timage.illust_mode=2;

			timage.width=int(self.request.get("canvas_width"))	
			timage.height=int(self.request.get("canvas_height"))	

			timage.put()
			
			ImageFile.invalidate_cache(str(timage.key()))

			self.response.out.write(""+str(timage.key()))		

			#古いデータの削除
			if(old_chunk_list_key):
				ChunkManager.delete(old_chunk_list_key)
		except:
			self.response.out.write("[error]")
			return

		#投稿数の更新
		if(user):
			ApiUser.invalidate_thread_count(user.user_id())
Пример #2
0
	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)
Пример #3
0
    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"))
Пример #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))
Пример #5
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))
Пример #6
0
	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))
Пример #7
0
	def get(self):
		bbs = db.get(self.request.get("bbs_key"))
		user = users.get_current_user()
		if(OwnerCheck.check(bbs,user)):
			return
		entry = db.get(self.request.get("entry_key"))
		if(entry.hidden_flag):
			entry.hidden_flag = 0
		else:
			entry.hidden_flag = 1
		entry.put()

		thread = db.get(self.request.get("thread_key"))
		url=MappingThreadId.get_thread_url("./",bbs,thread)
		self.redirect(str(url))
Пример #8
0
	def get(self):
		entry = db.get(self.request.get("entry_key"))
		
		if(self.request.get("res_key")=="all"):
			res=None
		else:
			res= db.get(self.request.get("res_key"))

		thread_key=entry.thread_key
		bbs_key=thread_key.bbs_key

		user = users.get_current_user()
		bbs_owner =not OwnerCheck.check(bbs_key,user)
		res_owner=False
		if(user and res and user.user_id()==res.user_id):
			res_owner=True
		
		if(not bbs_owner and not OwnerCheck.is_admin(user) and not res_owner):
			self.response.out.write(Alert.alert_msg("削除する権限がありません。",self.request.host))
			return

		if(not res):
			for res in entry.res_list:
				db.get(res).delete()
			entry.res_list=[]
		else:
			res.delete()
			idx = entry.res_list.index(db.Key(self.request.get("res_key")))
			entry.res_list.pop(idx)
		
		res_n=len(entry.res_list)
		if(res_n>=1):
			entry.date=db.get(entry.res_list[res_n-1]).date
		else:
			entry.date=entry.create_date

		entry.put()

		url=MappingThreadId.get_thread_url("./",bbs_key,thread_key)+"?comment_edit=1"
		self.redirect(str(url))
		
		thread = db.get(str(thread_key.key()))
		thread.comment_cnt=thread.comment_cnt-1
		thread.put()

		RecentCommentCache.invalidate(bbs_key)
Пример #9
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))
Пример #10
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)
Пример #11
0
	def post(self):
		SetUtf8.set()
		is_english=CssDesign.is_english(self)

		#エラーコードはFlash向けかどうか
		is_flash=False
		if(self.request.get('image')):
			is_flash=True

		#書き込み対象のコメントを取得
		if(self.request.get("entry_key")):	#上書きモード
			entry = db.get(self.request.get("entry_key"))
			overwrite = True
		else:
			entry = Entry()
			overwrite = False
	
		#コメント
		if(self.request.get('comment')):
			entry.content = self.request.get('comment')
		else:
			if(self.request.get('image')):
				entry.content = ""
			else:
				if(is_english):
					self.write_status(is_flash,"Please input comment");
				else:
					self.write_status(is_flash,"コメントを入力して下さい。");
				return

		#名前
		if(self.request.get('author')):
			entry.editor = cgi.escape(self.request.get('author'))
		else:
			entry.editor = "no_name"
			if(is_english):
				self.write_status(is_flash,"Please input name");
			else:
				self.write_status(is_flash,"名前を入力して下さい。");
			return
			

		if(not self.request.get('image')):
			if(self.request.get("seed")!=BbsConst.SUBMIT_SEED):
				self.write_status(is_flash,"シードが一致しません。");
				return

		if(self.request.get('mail_addr')):
			entry.mail=self.request.get('mail_addr')
		else:
			entry.mail=""
		
		if(self.request.get('homepage_addr') and self.request.get('homepage_addr')!="http://"):
			entry.homepage_addr=self.request.get('homepage_addr')
		else:
			entry.homepage_addr=""

		user = users.get_current_user()

		thread=db.Key(self.request.get("thread_key"))
		bbs = db.get(self.request.get("bbs_key"))

		if(SpamCheck.check_all(self,entry.content,self.request.get("remote_host"),user,bbs,is_flash,is_english)):
			return

		#二重投稿ブロック
		if(entry.content!="" and memcache.get("add_entry_double_block")==entry.content):
			if(is_flash):
				self.write_status(is_flash,"二重投稿を検出しました。時間を置いて、再度、投稿して下さい。");
			else:
				url=MappingThreadId.get_thread_url("./",bbs,db.get(self.request.get("thread_key")))
				self.redirect(str(url))
			return
		
		#コメント禁止
		if(db.get(thread).prohibit_comment):
			self.write_status(is_flash,"このイラストへのコメントは禁止されています。");
			return
		
		#書き込み権限確認
		if(bbs.comment_login_require):
			if(not(user)):
				self.write_status(is_flash,"この掲示板ではコメントする際にログインが必須です。");
				return

		#上書き権限確認
		if(overwrite):
			bbs=db.get(self.request.get("bbs_key"))
			if(OwnerCheck.check(bbs,user)):
				if(user and entry.user_id!=user.user_id()):
					self.write_status(is_flash,"上書き投稿する権限がありません。");
					return
		
		#イラストの設定
		delete_thread_image=None
		if(self.request.get('image')):
			if(overwrite):
				delete_thread_image=entry.illust_reply_image_key
			timage=ThreadImage()
			timage.bbs_key=bbs

			if(self.request.get("base64") and self.request.get("base64")=="1"):
				timage.image=db.Blob(base64.b64decode(self.request.get("image")))
				timage.thumbnail=db.Blob(base64.b64decode(self.request.get("thumbnail")))
			else:
				timage.image=db.Blob(self.request.get("image"))
				timage.thumbnail=db.Blob(self.request.get("thumbnail"))
			timage.thumbnail2=None
			timage.illust_mode=1;
			try:
				timage.put()
			except:
				if(is_english):
					self.write_status(is_flash,"Too big image");
				else:
					self.write_status(is_flash,"画像サイズが大きすぎます。");
				return

			entry.illust_reply=1
			entry.illust_reply_image_key=timage
		else:
			entry.content=cgi.escape(entry.content)
			entry.content=EscapeComment.auto_link(entry.content)

		entry.content=EscapeComment.escape_br(entry.content)

		entry.thread_key = thread
		entry.bbs_key = bbs
		entry.del_flag = 1
		if(self.request.get("regulation")):
			entry.adult=int(self.request.get("regulation"))

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

		#スレッドを取得
		thread = db.get(self.request.get("thread_key"))

		#基本情報を設定
		if(not overwrite):
			self.set_basic_info(entry,thread)

		#保存
		if(not SyncPut.put_sync(entry)):
			message="コメントの投稿は成功しましたが表示が遅延しています。反映まで数分お待ちください。"
			memcache.set(BbsConst.OBJECT_THREAD_MESSAGE_HEADER+str(thread.key()),message,BbsConst.OBJECT_THREAD_MESSAGE_CACHE_TIME)
			memcache.set(BbsConst.OBJECT_BBS_MESSAGE_HEADER+str(bbs.key()),message,BbsConst.OBJECT_BBS_MESSAGE_CACHE_TIME)

		#スレッドと掲示板の情報を更新
		if(not overwrite):
			self.update_thread_and_bbs_information(thread,bbs,entry)

		#上書き投稿時の昔のイラストの削除
		if(delete_thread_image):
			delete_thread_image.delete()

		#ステータスコードを出力
		if(self.request.get('image')):
			self.response.headers ['Content-type'] = "text/html;charset=utf-8"  
			self.response.out.write("success")			
		else:
			url=MappingThreadId.get_thread_url("./",bbs,thread)
			if(self.request.get("redirect_url")):
				url=self.request.get("redirect_url")
			self.redirect(str(url))

		#二重投稿ブロック
		memcache.set("add_entry_double_block",self.request.get("comment"),30)
		
		#ランキング
		is_owner=False
		if(thread.user_id and entry.user_id and thread.user_id == entry.user_id):
			is_owner=True
		if(not is_owner): #自分のスレッドへのコメントはランキングに反映しない
			Ranking.add_rank_global(thread,BbsConst.SCORE_ENTRY)

		#フィード
		if(not link_to_profile):
			user=None
		try:
			StackFeed.feed_new_comment_thread(user,thread,entry)
		except:
			logging.error("new entry stackfeed add error")
Пример #12
0
	def post(self):
		is_flash=self.request.get('mode')=="illust" or self.request.get('mode')=="illust_all";
		is_english=CssDesign.is_english(self)

		if(self.request.get('thread_title')==""):
			if(is_english):
				self.write_status(is_flash,"Please input title");
			else:
				self.write_status(is_flash,"スレッドタイトルを入力して下さい。");
			return                        
		if(self.request.get('author')==""):
			if(is_english):
				self.write_status(is_flash,"Please input author");
			else:
				self.write_status(is_flash,"投稿者名を入力して下さい。");
			return

		permission_error_str="スレッドを作成する権限がありません。"
		if(is_english):
			permission_error_str="Permission denied"

		login_require="ログインが必要です。"
		if(is_english):
			login_require="Login require"

		bbs = db.get(self.request.get("bbs_key"))
		user = users.get_current_user()

		if(not user and self.request.get('mode')=="illust_all"):
			self.write_status(is_flash,login_require);
			return

		if(bbs.bbs_mode==BbsConst.BBS_MODE_ONLY_ADMIN):
			if(OwnerCheck.check(bbs,user)):
				self.write_status(is_flash,permission_error_str);
				return
		if(bbs.bbs_mode==BbsConst.BBS_MODE_NO_IMAGE):
			if(bbs.disable_create_new_thread==1):
				if(OwnerCheck.check(bbs,user)):
					self.write_status(is_flash,permission_error_str);
					return
			if(bbs.disable_create_new_thread==2):
				if(not user):
					self.write_status(is_flash,permission_error_str);
					return

		if(SpamCheck.check_all(self,self.request.get('thread_title'),self.request.get("remote_host"),user,bbs,is_flash,is_english)):
			return

		homepage_addr=""
		if(self.request.get('homepage_addr') and self.request.get('homepage_addr')!="http://"):
			homepage_addr=self.request.get('homepage_addr')
		
		overwrite_mode=False
		if(self.request.get("thread_key")):	#上書きモード
			#上書きの場合
			overwrite_mode=True
			new_thread=db.get(self.request.get("thread_key"))
			if(OwnerCheck.check(bbs,user)):
				if((not user) or (not new_thread.user_id) or new_thread.user_id!=user.user_id()):
					if(self.request.get("delete_key")!=new_thread.delete_key or new_thread.delete_key==""):
						self.write_status(is_flash,"上書きをする権限がありません。");
						return;
		else:
			#新規作成の場合
			new_thread = MesThread()
			new_thread.put()	#キーの確保
			
			new_thread.score = None
			
			new_thread.comment_cnt=0

			bbs.illust_n=bbs.illust_n+1
			bbs.cached_threads_num=None	#キャッシュ更新リクエスト
			bbs.put()
			
			#上書きモードの場合は作成日を更新しない
			new_thread.create_date=datetime.datetime.today()
		
		#更新日は更新する
		new_thread.date=datetime.datetime.today()
		
		#各種設定値を書き込み
		new_thread.illust_mode = int(self.request.get('illust_mode'))
		new_thread.title = cgi.escape(self.request.get('thread_title'))
		if(self.request.get('mode')=="illust_all"):
			new_thread.summary = self.request.get('comment')
		else:
			new_thread.summary = cgi.escape(self.request.get('comment'))
		new_thread.bbs_key = db.Key(self.request.get('bbs_key'))

		new_thread.summary=EscapeComment.escape_br(new_thread.summary)

		new_thread.homepage_addr=homepage_addr
		new_thread.author=self.request.get('author')
		if(self.request.get("draw_time")):
			new_thread.draw_time=int(self.request.get("draw_time"))
		if(self.request.get("delete_key")):
			new_thread.delete_key=self.request.get("delete_key")

		if(self.request.get("category")):
			new_thread.category=self.request.get("category")
			CategoryList.add_new_category(bbs,new_thread.category)

		if(self.request.get("event_id")):
			new_thread.event_id=self.request.get("event_id")

		if(self.request.get("regulation")):
			new_thread.adult=int(self.request.get("regulation"))

		if(self.request.get("dont_show_in_portal")):
			new_thread.violate_photo=1

		if(self.request.get("is_png")):
			new_thread.is_png=1
		else:
			new_thread.is_png=0
		
		#プロフィールにリンクするか
		link_to_profile=StackFeed.is_link_to_profile(self)
		if(link_to_profile and user):
			new_thread.user_id=user.user_id()
		
		#通常投稿モード(MOPER)
		if(self.request.get('mode')=="illust"):
			new_thread.image_key=db.get(self.request.get('thread_image'))
			new_thread.mail=self.request.get('thread_mail')

			compiled_line = re.compile("(http://[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)")
			new_thread.summary = compiled_line.sub(r'<a href=\1 TARGET="_blank">\1</a>', new_thread.summary)

			if(user):
				new_thread.user_id=user.user_id()	#必ずプロフィールにマップ

		#一括投稿モード(新エディタ)
		timage=None
		if((self.request.get('mode')=="illust_all" or self.request.get('mode')=="illust_temp") and new_thread.illust_mode!=BbsConst.ILLUSTMODE_TEXT):
			timage=ThreadImage()
			timage.bbs_key=db.get(self.request.get("bbs_key"))
			
			if(self.request.get('mode')=="illust_temp"):
				try:
					temp_image=db.get(self.request.get("temp_illust_key"))
				except:
					temp_image=None
				if(not temp_image):
					self.write_status(is_flash,"画像データが見つかりません。")
					return
				timage.image=temp_image.image
				timage.thumbnail=temp_image.thumbnail
			else:
				if(self.request.get("base64") and self.request.get("base64")=="1"):
					timage.image=db.Blob(base64.b64decode(self.request.get("image")))
					timage.thumbnail=db.Blob(base64.b64decode(self.request.get("thumbnail")))
					new_thread.is_ipad=1
				else:
					timage.image=db.Blob(self.request.get("image"))
					timage.thumbnail=db.Blob(self.request.get("thumbnail"))
			
			if(len(timage.image)<=0 or len(timage.thumbnail)<=0):
				self.write_status(is_flash,"画像データが不正です。");
				return

			timage.illust_mode=new_thread.illust_mode
			timage.is_png=new_thread.is_png
			timage.thumbnail2=None

			try:
				timage.put()
			except:
				if(is_english):
					self.write_status(is_flash,"Too big image");
				else:
					self.write_status(is_flash,"画像の容量が大きすぎます。");
				return
			new_thread.image_key=timage
			ImageFile.invalidate_cache(str(timage.key()))

		#url assign
		MappingThreadId.assign(bbs,new_thread,False)
		
		#IPアドレスを書き込み
		new_thread.remote_addr=self.request.remote_addr
		new_thread.remote_host=self.request.get("remote_host")
		new_thread.thumbnail2_version=0
		new_thread.search_index_version=0

		#put
		if(not SyncPut.put_sync(new_thread)):
			message="イラストの投稿は成功しましたが表示が遅延しています。反映まで数分お待ちください。"
			memcache.set(BbsConst.OBJECT_BBS_MESSAGE_HEADER+str(bbs.key()),message,BbsConst.OBJECT_BBS_MESSAGE_CACHE_TIME)

		#サムネイル更新
		if(timage):
			if(new_thread.adult==0):
				bbs.cached_thumbnail_key=str(timage.key())
				bbs.put()

		#新着イラストのキャッシュ無効化
		RecentCommentCache.invalidate(bbs)
		
		#ステータスを出力
		if(is_flash):
			self.write_status(is_flash,"success")
		else:
			self.redirect(str('./bbs_index?bbs_key='+self.request.get('bbs_key')))
		
		#feed
		if(not link_to_profile):
			user=None
		url=self.get_thread_url(bbs,new_thread)

		if(not overwrite_mode):
			try:
				StackFeed.feed_new_thread(user,bbs,new_thread)
			except:
				logging.error("new thread stack feed add error")

		#submit thread count
		if(user):
			ApiUser.invalidate_thread_count(user.user_id())
		
		#news
		ApiFeed.invalidate_cache()

		#Rss
		RssFeed.invalidate_cache(str(bbs.key()))
Пример #13
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)
Пример #14
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))
Пример #15
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")))
Пример #16
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))