Esempio n. 1
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,"ランキングを更新しました。")
Esempio n. 2
0
	def check_capability(check_id,bbs_key):
		if(check_id==""):
			return 1
		if(check_id=="usr"):
			return 0
		if(check_id=="img"):
			return 0
		if(check_id=="js"):
			return 0
		if(check_id=="bin"):
			return 0
		if(check_id=="swf"):
			return 0
		if(check_id=="code"):
			return 0
		if(check_id=="flash"):
			return 0
		if(check_id=="static_files"):
			return 0
		if(check_id=="static_files_stable"):
			return 0
		if(check_id=="twitter"):
			return 0
		if(check_id=="css"):
			return 0
		if(check_id=="app"):
			return 0
		if(check_id=="thumbnail"):
			return 0
		if(check_id=="template"):
			return 0
		if(check_id=="tolot"):
			return 0
		query=Bbs.all()
		query.filter("short =",check_id)
		cnt=query.count()
		if(cnt==0):
			return 1
		if(bbs_key!=""):
			if(str(query[0].key())==bbs_key):
				return 1
		return 0
Esempio n. 3
0
	def mapping(bbs_key):
		#直値
		if(len(bbs_key)>16):
			return bbs_key

		#キャッシュヒット判定
		data=memcache.get(BbsConst.OBJECT_BBS_ID_MAPPING_HEADER+bbs_key)
		if data is not None:
			return data

		#BBSのIDに対応するBBSを取得
		query=Bbs.all()
		query.filter("short =",bbs_key)
		try:
			data=str(query[0].key())
		except:
			return ""
		
		#キーを返す
		memcache.set(BbsConst.OBJECT_BBS_ID_MAPPING_HEADER+bbs_key,data,BbsConst.OBJECT_MAPPING_CACHE_TIME)
		return data
Esempio n. 4
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)
Esempio n. 5
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))
Esempio n. 6
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')))
Esempio n. 7
0
	def get(self):
		user = users.get_current_user()
		is_admin=0
		is_high_admin=0
		account="ログインしていない状態"
		if(user):
			account="アカウント"+user.email()
			is_admin=1
			if(OwnerCheck.is_admin(user)):
				is_high_admin=1

		SetUtf8.set()

		thread_query = MesThread.all().order('-create_date')
		cnt=thread_query.count(10000)

		thread_page_unit=12
		thread_page=1
		if self.request.get("page"):
			thread_page = int(self.request.get("page"))
		thread_page_list=PageGenerate.generate_page(thread_page,cnt,thread_page_unit)

		comment_page=1
		only_comment=0
		if self.request.get("comment_page"):
			comment_page = int(self.request.get("comment_page"))
			only_comment=1

		if(not only_comment):
			thread_query.filter("illust_mode =",1)
			thread=thread_query.fetch(limit=thread_page_unit,offset=(thread_page-1)*thread_page_unit)
		
			new_moper_query=MesThread.all().order("-create_date")
			new_moper_query.filter("illust_mode =",2)
			new_moper=new_moper_query.fetch(limit=12)

			entry=None
			try:
				entry_query = Entry.all().order('-create_date')
				entry_query.filter("illust_reply =",1)
				entry=entry_query.fetch(limit=thread_page_unit,offset=(thread_page-1)*thread_page_unit)
			except:
				None
		else:
			thread=None
			new_moper=None
			entry=None

		comment=None
		try:
			comment_unit=7
			comment_query = Entry.all().order('-create_date')
			comment_query.filter("del_flag =", 1)
			comment=comment_query.fetch(limit=comment_unit,offset=comment_unit*(comment_page-1))
		except:
			None

		if(not only_comment):
			new_bbs_count=SiteAnalyzer.create_graph(self,0);
			new_illust_count=SiteAnalyzer.create_graph(self,1);
			new_entry_count=SiteAnalyzer.create_graph(self,2);
			new_user_count=SiteAnalyzer.create_graph(self,3);

			today_start = datetime.datetime.today()
			week_start = today_start - datetime.timedelta(days=7)
			month1_start = today_start - datetime.timedelta(days=31)
		
			weekly=Bbs.all().filter("date >=",week_start).count(limit=10000)
			monthly=Bbs.all().filter("date >=",month1_start).count(limit=10000)
		else:
			new_bbs_count=0
			new_illust_count=0
			new_entry_count=0
			new_user_count=0
			weekly=0
			monthly=0

		if os.environ["SERVER_SOFTWARE"].find("Development")!=-1:
			new_moper=[]
			
		host_url ="./"
		template_values = {
			'host': host_url,
			'threads':thread,
			'moper_threads':new_moper,
			'entries':entry,
			'comment':comment,
			'new_bbs_count':new_bbs_count,
			'new_entry_count':new_entry_count,
			'new_illust_count':new_illust_count,
			'new_user_count':new_user_count,
			'is_admin':is_admin,
			'is_high_admin': is_high_admin,
			'account':account,
			'url_logout':users.create_logout_url("./admin"),
			'url_login':users.create_login_url("./admin"),
			'page_list':thread_page_list,
			'page_url_base':"./admin?page=",
			'page':thread_page,
			'weekly':weekly,
			'monthly':monthly,
			'comment_page':comment_page,
			'only_comment': only_comment
			}
		path = '/html/admin.html'
		render=template_select.render(path, template_values)
		self.response.out.write(render)