protected void Page_Load(object sender, EventArgs e) { if (Session["sessionID"] == null) { MultiView_HeaderTitle.SetActiveView(View_HeaderTitle_Default); MultiView_NavTop.SetActiveView(View_NavTop_Default); MultiView_Main.SetActiveView(View_Main_Default); Literal_Title.Text = PageKits.SiteName; } else { MultiView_HeaderTitle.SetActiveView(View_HeaderTitle_User); MultiView_NavTop.SetActiveView(View_NavTop_User); MultiView_Main.SetActiveView(View_Main_User); UsersData users = new UsersData(MapPath(".")); SessionsData sessions = new SessionsData(MapPath(".")); string userID = (string)Session["userID"]; if (!sessions.IsValidSession((string)Session["sessionID"], userID)) { Response.Redirect("signout.aspx?signout=true"); return; } string userName = users.FindUserID(userID)["userName"]; Literal_Title.Text = userName + " - " + PageKits.SiteName; Literal_NavTop.Text = PageKits.generateNavTopContent(userID, userName); ShowActivities(); } }
protected void ShowPage() { UsersData users = new UsersData(MapPath(".")); ImagesData images = new ImagesData(MapPath(".")); var image = new System.Collections.Generic.Dictionary<string, string>(); if ((string)Request.QueryString["new"] == "true") { MultiView_Char.SetActiveView(View_NewChar); image["imageName"] = "新しい文字"; } else if (Request.QueryString["id"] != null) { MultiView_Char.SetActiveView(View_ShowChar); image = images.FindImageId((string)Request.QueryString["id"]); Label_UserName.Text = users.FindUserID(image["userID"])["userName"]; Image_Char.ImageUrl = string.Format("images/{0}.{1}", image["imageID"], image["imageType"]); TextBox_CharName.Text = image["imageName"]; } else { Response.Redirect("index.aspx"); } if (TextBox_NewCharName.Text == "") { TextBox_NewCharName.Text = image["imageName"]; } Literal_Title.Text = image["imageName"]; Literal_HeaderTitle.Text = image["imageName"]; string userID = (string)Session["userID"]; Literal_NavTop.Text = PageKits.generateNavTopContent(userID, users.FindUserID(userID)["userName"]); }
protected void SignDown() { if (HiddenField_Token.Value != (string)Session["sessinID"]) { throw new InvalidOperationException("Cross-Site Request Forgery (CSRF)"); } SessionsData sessions = new SessionsData(MapPath(".")); UsersData users = new UsersData(MapPath(".")); if (!sessions.IsValidSession((string)Session["sessionID"], (string)Session["userID"])) { throw new InvalidOperationException("The session is invalid."); } sessions.RemoveSession((string)Session["sessionID"]); users.RemoveUser((string)Session["userID"]); Session.Abandon(); }
protected void Page_Load(object sender, EventArgs e) { SessionsData sessions = new SessionsData(MapPath(".")); string userID = (string)Session["userID"]; if (!sessions.IsValidSession((string)Session["sessionID"], userID)) { Response.Redirect("signout.aspx?signout=true"); return; } if (Request.QueryString["id"] == null) { Response.Redirect("index.aspx"); } string targetUserID = (string)Request.QueryString["id"]; UsersData users = new UsersData(MapPath(".")); string targetUserName = users.FindUserID(targetUserID)["userName"]; Literal_NavTop.Text = PageKits.generateNavTopContent(userID, users.FindUserID(userID)["userName"]); Literal_Title.Text = targetUserName; Literal_HeaderTitle.Text = targetUserName; ShowFollowingStatus(); ShowFollows(); ShowActivities(targetUserID); }
protected void ShowFollowing() { FollowsData follows = new FollowsData(MapPath(".")); UsersData users = new UsersData(MapPath(".")); string fontID = (string)Request.QueryString["id"]; if (follows.IsFollow((string)Session["userID"], "font", fontID)) { Button_Follow.Enabled = false; Button_Unfollow.Enabled = true; } else { Button_Follow.Enabled = true; Button_Unfollow.Enabled = false; } var followers = follows.FindObjectIDs("font", fontID); foreach (var follower in followers) { Label_Followers.Text += "<div class=\"follows\">" + string.Format("<a href=\"user.aspx?id={0}\">{1}</a>", follower["userID"], users.FindUserID(follower["userID"])["userName"]) + "</div>"; } }
protected void ShowActivities(string userID) { Literal_Activities.Text = ""; ActivitiesData activities = new ActivitiesData(MapPath(".")); ImagesData images = new ImagesData(MapPath(".")); FontsData fonts = new FontsData(MapPath(".")); UsersData users = new UsersData(MapPath(".")); var myActivities = activities.FindUserIDs(userID); foreach (var activity in myActivities.Reverse()) { string targetUri; string targetName; string actionName; switch (activity["activityType"]) { case "makeImage": targetName = "文字 " + images.FindImageId(activity["objectID"])["imageName"]; targetUri = "char.aspx?id=" + activity["objectID"]; actionName = "作成"; break; case "editImage": targetName = "文字 " + images.FindImageId(activity["objectID"])["imageName"]; targetUri = "char.aspx?id=" + activity["objectID"]; actionName = "編集"; break; case "makeFont": targetName = "字体 " + fonts.FindFontID(activity["objectID"])["fontName"]; targetUri = "font.aspx?id=" + activity["objectID"]; actionName = "作成"; break; case "editFont": targetName = "字体 " + fonts.FindFontID(activity["objectID"])["fontName"]; targetUri = "font.aspx?id=" + activity["objectID"]; actionName = "編集"; break; case "makeSentence": targetName = "例文"; targetUri = "sentence.aspx?id=" + activity["objectID"]; actionName = "作成"; break; case "followFont": targetName = "字体 " + fonts.FindFontID(activity["objectID"])["fontName"]; targetUri = "font.aspx?id=" + activity["objectID"]; actionName = "認知"; break; case "followUser": targetName = "賢者 " + users.FindUserID(activity["objectID"])["userName"]; targetUri = "user.aspx?id=" + activity["objectID"]; actionName = "認知"; break; default: targetName = "UMA"; targetUri = "index.aspx"; actionName = "UFO"; break; } if (activity["activityType"] == "makeSentence") { var sentence = new SentencesData(MapPath(".")).FindSentenceID(activity["objectID"]); Literal_Activities.Text += "<a href=\"" + targetUri + "\">" + PageKits.generateFontedContent(sentence["sentence"], sentence["fontID"]) + "</a>"; } Literal_Activities.Text += "<div class=\"activity\">" + "<a href=\"" + targetUri + "\">" + targetName + "</a>を" + actionName + "しました。" + "<span class=\"activityDate\">" + activity["activityDate"] + "</span>" + "</div>"; } }
protected void ShowFollows() { FollowsData follows = new FollowsData(MapPath(".")); UsersData users = new UsersData(MapPath(".")); string targetUserID = (string)Request.QueryString["id"]; var hisFollowings = follows.FindUserIDs(targetUserID); foreach (var hisFollowing in hisFollowings) { string followingUserID = hisFollowing["objectID"]; Label_Followings.Text += "<div class=\"follows\">" + string.Format("<a href=\"user.aspx?id={0}\">{1}</a>", followingUserID, users.FindUserID(followingUserID)["userName"]) + "</div>"; } var hisFollowers = follows.FindObjectIDs("user", targetUserID); foreach (var hisFollower in hisFollowers) { string followerUserID = hisFollower["userID"]; Label_Followers.Text += "<div class=\"follows\">" + string.Format("<a href=\"user.aspx?id={0}\">{1}</a>", followerUserID, users.FindUserID(followerUserID)["userName"]) + "</div>"; } }
protected void ShowActivities() { ActivitiesData activities = new ActivitiesData(MapPath(".")); FollowsData follows = new FollowsData(MapPath(".")); UsersData users = new UsersData(MapPath(".")); FontsData fonts = new FontsData(MapPath(".")); ImagesData images = new ImagesData(MapPath(".")); var myFollowings = follows.FindUserIDs((string)Session["userID"]); List<Dictionary<string, string>> shownActivities = new List<Dictionary<string, string>>(); foreach (var following in myFollowings) { Dictionary<string, string>[] thisActivities; switch (following["targetType"]) { case "font": thisActivities = activities.FindObjectIDs("font", following["objectID"]); break; case "user": thisActivities = activities.FindUserIDs(following["objectID"]); break; default: thisActivities = new Dictionary<string, string>[0]; break; } foreach (var thisActivity in thisActivities) { shownActivities.Add(thisActivity); } } Literal_Activities.Text = ""; foreach (Dictionary<string, string> activity in shownActivities.ToArray().Reverse()) { string targetUri; string targetName; string actionName; switch (activity["activityType"]) { case "makeImage": targetName = "文字 " + images.FindImageId(activity["objectID"])["imageName"]; targetUri = "char.aspx?id=" + activity["objectID"]; actionName = "作成"; break; case "editImage": targetName = "文字 " + images.FindImageId(activity["objectID"])["imageName"]; targetUri = "char.aspx?id=" + activity["objectID"]; actionName = "編集"; break; case "makeFont": targetName = "字体 " + fonts.FindFontID(activity["objectID"])["fontName"]; targetUri = "font.aspx?id=" + activity["objectID"]; actionName = "作成"; break; case "editFont": targetName = "字体 " + fonts.FindFontID(activity["objectID"])["fontName"]; targetUri = "font.aspx?id=" + activity["objectID"]; actionName = "編集"; break; case "makeSentence": targetName = "例文"; targetUri = "sentence.aspx?id=" + activity["objectID"]; actionName = "作成"; break; case "followFont": targetName = "字体 " + fonts.FindFontID(activity["objectID"])["fontName"]; targetUri = "font.aspx?id=" + activity["objectID"]; actionName = "認知"; break; case "followUser": targetName = "賢者 " + users.FindUserID(activity["objectID"])["userName"]; targetUri = "user.aspx?id=" + activity["objectID"]; actionName = "認知"; break; default: targetName = "UMA"; targetUri = "index.aspx"; actionName = "UFO"; break; } string userID = activity["userID"]; string userName = users.FindUserID(userID)["userName"]; if (activity["activityType"] == "makeSentence") { var sentence = new SentencesData(MapPath(".")).FindSentenceID(activity["objectID"]); Literal_Activities.Text += "<a href=\"" + targetUri + "\">" + PageKits.generateFontedContent(sentence["sentence"], sentence["fontID"]) + "</a>"; } Literal_Activities.Text += "<div class=\"activity\">" + "<a href=\"user.aspx?id=" + userID + "\">" + userName + "さん</a>が" + "<a href=\"" + targetUri + "\">" + targetName + "</a>を" + actionName + "しました。" + "<span class=\"activityDate\">" + activity["activityDate"] + "</span>" + "</div>"; } }