protected override void OnInit(EventArgs e) { base.OnInit(e); // Check if revisit is valid or not if (!base.IsPostBack) { ANO_User cooike = ANOProfile.GetCookieValues(HttpContext.Current.Request.UserHostAddress); if (cooike != null) { if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.ReVisit)) { Response.End(); } } else { if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.FirstVisit)) { Response.End(); } } } else { // Limit number of postbacks if (!ActionValidator.IsValid(ActionValidator.ActionTypeEnum.Postback)) { Response.End(); } } }
public ChatSystem(HttpContext context, string currentUserIP) { mngInfo = new TimeZoneManager(currentUserIP); this.context = context; this.currentUserIp = currentUserIP; user = ANOProfile.GetCookieValues(currentUserIP); }
public static ANO_User GetCookieValues(string userIpAddress, HttpContext context) { // Get UserIpAddress string getUserIp = userIpAddress; ANO_User createrANOuser = new ANO_User(); // Get Cookie HttpCookie getCookie = context.Request.Cookies.Get(cookieName); if (getCookie != null) { if (getCookie.Values["IpAddress"].Equals(getUserIp.EncodeToMd5())) { createrANOuser.IPAddress = getUserIp; createrANOuser.DateAdded = new DateTime(Convert.ToInt64(getCookie.Values["DateAdded"])); // Check lang if (System.Text.RegularExpressions.Regex.Match(getCookie.Values["ShortLang"].ToString(), "^[a-z]{2}-[A-Z]{2}$").Success.Equals(true)) { createrANOuser.ShortLang = context.Server.HtmlEncode(getCookie.Values["ShortLang"].ToString()); } else { throw (new ArgumentException(getCookie.Values["ShortLang"].ToString() + " dont match", "Wrong lang (Not match)")); } createrANOuser.SearchMatchID = !string.IsNullOrEmpty(getCookie.Values["SearchMatchID"]) ? (Guid?)new Guid(getCookie.Values["SearchMatchID"]) : null; createrANOuser.UserID = new Guid(getCookie.Values["UserId"]); if (!string.IsNullOrEmpty(getCookie.Values["TimeZone"])) { createrANOuser.TimeZone = HttpUtility.UrlDecode(getCookie.Values["TimeZone"]); } else { createrANOuser.TimeZone = null; } return(createrANOuser); } } return(null); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { ImgLoading.ImageUrl = ImgLoading.ImageUrl.ChangeToImageHost(); H1Results.InnerHtml += " - " + Request.QueryString["sg"]; // insert game name #region Search engine HttpRequest currentR = Request; // Set values of current lang LangaugeSystem ls = new LangaugeSystem(); CurrentLang = ls.CurrentLang; CurrentLangId = ls.CurrentLangId; #region Get QueryStringsDatas (Convert to htmlencodes) var searchQueryDatas = new { ClanSkill = currentR.QueryString["cs"], ClanContinent = currentR.QueryString["cct"], ClanCountry = currentR.QueryString["cc"], SearchSkill = currentR.QueryString["ss"], SearchContinent = currentR.QueryString["sct"], SearchCountry = (string)currentR.QueryString["sc"], SearchGame = (string)currentR.QueryString["sg"], SearchGameMode = (string)currentR.QueryString["sgt"] }.ToAnonymousObjectCollection(); foreach (AnonymousObject s in searchQueryDatas) { s.SetValue(Server.HtmlEncode(Server.UrlDecode(s.GetValue <string>()))); } #endregion #region Get QueryStrings custom text data (no validate or convert) var searchQueryCustomTextData = new { ClanName = Server.HtmlEncode(Server.UrlDecode(currentR.QueryString["cn"])), SearchMap = Server.HtmlEncode(Server.UrlDecode(currentR.QueryString["sm"])) }; #endregion #region Get QueryStrings customdata var searchQueryCustomData = new { SearchMatchStart = currentR.QueryString["sfd"], SearchXvs = currentR.QueryString["sxv"], SearchvsX = currentR.QueryString["svx"] }; #endregion try { #region Get IDs of searchQueryDatas int? clanSkillId = null; SkillsSystem ss = new SkillsSystem(); if (!string.IsNullOrEmpty(searchQueryDatas.GetAnonymousObject("ClanSkill").GetValue <string>())) { clanSkillId = ((dynamic)ss.GetSkill(searchQueryDatas.GetAnonymousObject("ClanSkill").GetValue <string>(), CurrentLangId)).SearchWarSkillId; } int?searchSkillId = null; if (!string.IsNullOrEmpty(searchQueryDatas.GetAnonymousObject("SearchSkill").GetValue <string>())) { searchSkillId = ((dynamic)ss.GetSkill(searchQueryDatas.GetAnonymousObject("SearchSkill").GetValue <string>(), CurrentLangId)).SearchWarSkillId; } ContinentSystem cs = new ContinentSystem(); int clanContinentId = ((dynamic)cs.GetContinent(CurrentLangId, searchQueryDatas.GetAnonymousObject("ClanContinent"). GetValue <string>())).SearchWarContinentId; CountrySystem cys = new CountrySystem(); int clanCountryId = ((dynamic)cys.GetCountry(CurrentLangId, searchQueryDatas.GetAnonymousObject("ClanCountry").GetValue <string>())).SearchWarCountryId; int searchContinent = ((dynamic)cs.GetContinent(CurrentLangId, searchQueryDatas.GetAnonymousObject("SearchContinent") . GetValue <string>())).SearchWarContinentId; int?searchCountryId = null; if (!string.IsNullOrEmpty(searchQueryDatas.GetAnonymousObject("SearchCountry").GetValue <string>())) { searchCountryId = ((dynamic)cys.GetCountry(CurrentLangId, searchQueryDatas.GetAnonymousObject("SearchCountry"). GetValue <string>())).SearchWarCountryId; } GamesSystem gs = new GamesSystem(); int searchGameId = gs.GetGame(searchQueryDatas.GetAnonymousObject("SearchGame").GetValue <string>()).SearchWarGameId; int?searchGameModeId = null; if (!string.IsNullOrEmpty(searchQueryDatas.GetAnonymousObject("SearchGameMode").GetValue <string>())) { GameModeSystem gms = new GameModeSystem(); searchGameModeId = gms.GetGameType(searchQueryDatas.GetAnonymousObject("SearchGameMode").GetValue <string>()).SearchWarGameTypeId; } #endregion #region Create url to the "client javascript" (get "data search results" as xml) ANO_User getprofile = ANOProfile.GetCookieValues(CurrentUserIP); Guid newID = Guid.NewGuid(); ANOProfile.SaveCookies(CurrentUserIP, newID); xmlSearchUrl = "http://" + GetDomain.GetDomainFromUrl(Context.Request.Url.ToString()) + "/m.ashx"; xmlSearchUrlaction = xmlSearchUrl + "?li= " + CurrentLangId.ToString() + "&cn=" + Server.UrlEncode(searchQueryCustomTextData.ClanName) + ((clanSkillId.HasValue) ? "&cs=" + clanSkillId.Value.ToString() : "") + "&cct=" + clanContinentId.ToString() + "&cc=" + clanCountryId.ToString() + "&sg=" + searchGameId.ToString() + ((searchGameModeId.HasValue) ? "&sgt=" + searchGameModeId.Value.ToString() : "") + ((searchSkillId.HasValue) ? "&ss=" + searchSkillId.Value.ToString() : "") + "&sct=" + searchContinent.ToString() + ((searchCountryId.HasValue) ? "&sc=" + searchCountryId.Value.ToString() : "") + "&sxv=" + searchQueryCustomData.SearchXvs + "&svx=" + searchQueryCustomData.SearchvsX + (!string.IsNullOrEmpty(searchQueryCustomTextData.SearchMap) ? "&sm=" + Server.UrlEncode(searchQueryCustomTextData.SearchMap) : "") + "&sfd=" + Server.UrlEncode(searchQueryCustomData.SearchMatchStart) + "&option=search,chat&action=1"; xmlSearchUrl = xmlSearchUrl + "?option=search,chat&li= " + CurrentLangId.ToString(); #endregion } catch { // nothing "error" } } catch { } #endregion } }
public void ProcessRequest(HttpContext context) { // Set defaults values string data = null; string currentUserIp = "62.107.21.129"; HttpRequest currentR = context.Request; HttpServerUtility currentS = context.Server; int currentLangId; bool isValid = true; string errorMessage = "succes"; ANO_User getUser = ANOProfile.GetCookieValues(currentUserIp, context); string userAction = context.Request.QueryString["a"]; if (string.IsNullOrEmpty(userAction)) { isValid = false; errorMessage = "You forgot action (querystring a)"; } // Create documet and root element called "c" for "chat" XDocument createXml = new XDocument( new XDeclaration("1.0", "iso-8859-1", "true"), new XElement("chat")); // Get root element "c" XElement getRootElement = createXml.Descendants("chat").Single(); if (userAction == ChatCmds.SendMessage.ToString()) { string userText = context.Request["t"]; if (string.IsNullOrEmpty(userText)) { isValid = false; errorMessage = "You forgot the message (post/querystring t)"; } string chatIdQuery = context.Request["c"]; Guid? chatId = null; if (string.IsNullOrEmpty(chatIdQuery)) { isValid = false; errorMessage = "You forgot the chat window id (post/querystring c"; } // Convert chatid querystring to Guid try { chatId = new Guid(chatIdQuery); } catch { isValid = false; errorMessage = "Problem with converting chat window id (querystring c)"; } if (isValid == true && chatId.HasValue) { string getUsername = null; if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { getUsername = Membership.GetUser(getUser.UserID).UserName; } if (string.IsNullOrEmpty(getUsername)) { Searchwar_netEntities db = new Searchwar_netEntities(); SW_SearchWar matchSearch = db.SW_SearchWar.SingleOrDefault(w => w.SearchWarId == getUser.SearchMatchID); if (matchSearch != null) { getUsername = matchSearch.SearchWarClanName; } } if (!string.IsNullOrEmpty(getUsername)) { ChatSystem mngChat = new ChatSystem(context, currentUserIp); mngChat.CreateMsg(userText, chatId, getUser.UserID, getUsername); } else { isValid = false; errorMessage = "You muct be logged in or searching for a match"; } } } // write status for result getRootElement.Add(new XElement("status", new XAttribute("bool", isValid.ToString()), errorMessage)); // Write/save data StringWriter sw = new StringWriter(); XmlWriter xw = XmlWriter.Create(sw); createXml.Save(xw); xw.Close(); data = sw.ToString(); context.Response.ContentType = "text/xml"; context.Response.ContentEncoding = Encoding.UTF8; context.Response.Write(XmlWhiteSpaceModule.RemoveWhitespace(data)); }
protected void Page_Load(object sender, EventArgs e) { // Select current langauge string currentLang = new LangaugeSystem().CurrentLang; // Show if javascript is disable ErrorJS.InnerText = GetLocalResourceObject("JavascriptBoxErrorMessageError").ToString(); // url for JS string pageId = Context.Request.AppRelativeCurrentExecutionFilePath.ToString(); string jsurl = ("~/js.axd?p=" + HttpUtility.UrlEncode(pageId)).ChangeToJsHost(); scriptsall.Scripts.Add(new System.Web.UI.ScriptReference(jsurl)); if (Page.IsPostBack) { return; } // get timezone ANO_User GetUserCookie = ANOProfile.GetCookieValues(CurrentUserIP); string currentZone = GetUserCookie.TimeZone; if (string.IsNullOrEmpty(currentZone)) { DivTimeZone.Visible = true; } else { DivTimeZone.Visible = false; } // check cache System.Collections.ObjectModel.ReadOnlyCollection <TimeZoneInfo> getTimeZones = (System.Collections.ObjectModel.ReadOnlyCollection <TimeZoneInfo>)Cache["masterpage_timezones"]; if (getTimeZones == null) { getTimeZones = TimeZoneInfo.GetSystemTimeZones(); if (getTimeZones != null) { // add Cache Cache.Add("masterpage_timezones", getTimeZones, null, TimeZoneManager.DateTimeNow.AddDays(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } DdlTimeZones.Items.Clear(); foreach (var zone in getTimeZones) { DdlTimeZones.Items.Add(new ListItem(zone.DisplayName.ToString(), zone.BaseUtcOffset.ToString())); } if (!string.IsNullOrEmpty(currentZone)) { DdlTimeZones.Items.FindByValue(currentZone).Selected = true; } // Insert Langauges in DropDownList DropDownList ddlLang = DdlSelectLang; ddlLang.Items.Clear(); // check cache List <SW_Lang> langs = (List <SW_Lang>)Cache["masterpage_langs"]; LangaugeSystem ls = new LangaugeSystem(); if (langs == null) { langs = ls.GetLangs(); if (langs != null) { // add Cache Cache.Add("masterpage_langs", langs, null, TimeZoneManager.DateTimeNow.AddDays(10), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } foreach (var lang in langs) { ddlLang.Items.Add(new ListItem(lang.LangName, lang.LangShortname)); } // check cache int?currentLangId = (int?)Cache["masterpage_LangId" + currentLang]; if (currentLangId.HasValue == false) { currentLangId = ls.GetLang(currentLang).LangId; if (currentLangId.HasValue == true) { // add Cache Cache.Add("masterpage_LangId" + currentLang, currentLangId, null, TimeZoneManager.DateTimeNow.AddDays(10), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } if (!string.IsNullOrEmpty(currentLang)) { DdlSelectLang.Items.FindByValue(currentLang).Selected = true; } // change url for logo (Now with shortlang) CustomSiteMapNode csm = new CustomSiteMapNode(); cSiteMapNode homeCSiteMapNode = csm.GetSiteMapNode(2, currentLangId.Value); string getPath = homeCSiteMapNode.SiteMapNodePath; if (!string.IsNullOrEmpty(homeCSiteMapNode.SiteMapNodeRewrittedPath)) { getPath = homeCSiteMapNode.SiteMapNodeRewrittedPath; } HyperImgLogo.NavigateUrl = getPath; // Insert menu data // check cache List <cSiteMapNode> sitemapnodes = (List <cSiteMapNode>)Cache["masterpage_nodes" + currentLangId]; if (sitemapnodes == null) { sitemapnodes = csm.GetSiteMapNodes((int)currentLangId, false); if (sitemapnodes != null) { // add Cache Cache.Add("masterpage_nodes" + currentLangId, sitemapnodes, null, TimeZoneManager.DateTimeNow.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } CMenu.DataSource = sitemapnodes; CMenu.CurrentUserIP = CurrentUserIP; CMenu.DataBind(); // Properties for metatags event SiteMapNodeMetatagsObject getMapMetaTags = null; cSiteMapNode getCurrentSiteMap = null; int currentSiteMapId; // Get CurrentSiteMapNode getCurrentSiteMap = csm.GetCurrentSiteMapNode((int)currentLangId); currentSiteMapId = getCurrentSiteMap.SiteMapNodeId; // Get Metatags for current cSiteMapNode // check cache getMapMetaTags = (SiteMapNodeMetatagsObject)Cache["masterpage_NodeMetatags" + currentSiteMapId.ToString() + currentLangId.ToString()]; SiteMapNodeMetaTags smm = new SiteMapNodeMetaTags(); if (getMapMetaTags == null) { getMapMetaTags = smm.GetMetaTags(currentSiteMapId, (int)currentLangId); if (getMapMetaTags != null) { // add cache Cache.Add("masterpage_NodeMetatags" + currentSiteMapId.ToString() + currentLangId.ToString(), getMapMetaTags, null, TimeZoneManager.DateTimeNow.AddDays(4), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null); } } // Insert MetaTags string pageTitle = Request.Url.Host; if (getMapMetaTags != null) { MetaAuthor.Content = getMapMetaTags.MetaTagAuthor; MetaCache.Content = getMapMetaTags.MetaTagCache; MetaCopyright.Content = getMapMetaTags.MetaTagCopyright; MetaDescription.Content = getMapMetaTags.MetaTagDescription; MetaKeywords.Content = getMapMetaTags.MetaTagKeywords; MetaLanguage.Content = getMapMetaTags.MetaTagLanguage; MetaPublisher.Content = getMapMetaTags.MetaTagPublisher; MetaRobots.Content = getMapMetaTags.MetaTagRobots; MetaRevisitAfter.Content = getMapMetaTags.MetaTagRevisitAfter; MetaCacheControl.Content = getMapMetaTags.MetaTagCacheControl; pageTitle += " - " + getMapMetaTags.MetaTagTitle; } Page.Title = pageTitle; }