public static void Initialize(Member LoggedInMem) { LoggedInMember = LoggedInMem; BackgroundColor = Color.FromArgb(243, 224, 221); ForegroundColor = Color.FromArgb(81, 81, 81); BorderColor = Color.FromArgb(222, 183, 183); }
public static void Initialize(MySqlConnection SqlConn) { LoggedInMember = null; SqlConnection = SqlConn; BackgroundColor = Color.FromArgb(243, 224, 221); ForegroundColor = Color.FromArgb(81, 81, 81); BorderColor = Color.FromArgb(222, 183, 183); }
public DynamicPages(string PageUrl, MySqlConnection SqlConnection, Member LoggedInMember, Logging Log, HttpHeader HttpHead, Events Event) { this.LoggedInMember = LoggedInMember; this.Log = Log; this.SqlConnection = SqlConnection; this.HttpHead = HttpHead; this.Event = Event; #region PageUrl if (PageUrl == "/") PageUrl = "/home/"; else PageUrl = PageUrl.ToLower(); if (!PageUrl.StartsWith("/")) PageUrl = "/" + PageUrl; if (!PageUrl.EndsWith("/")) PageUrl = PageUrl + "/"; this.PageURL = PageUrl; #endregion string Domain = HttpContext.Current.Request.Url.Host.ToLower(); CurrentPage = new Page(PageUrl, Domain, SqlConnection); if (CurrentPage.Exists) { if (CurrentPage.RequireSecure || LoggedInMember.RequestSecure) Utilities.MoveToSecure(); if (!CurrentPage.HtmlPage) { if (CurrentPage.Compiled) { PageObject = Assembly.Load(CurrentPage.CompiledCode).CreateInstance("BlazeGames.Web." + "DynamicPage"); onPagePreInitialize(); if (!onPageAuthenticate()) { Event.Call("AuthenticateFailure()"); ErrorManager.Error("Please login to view this page."); } else Event.Call("AuthenticateSuccess()"); } else { if (LoggedInMember.Authority >= 5) ErrorManager.Message("<a href='/Admin/Pages/?Act=Compile&ID=" + CurrentPage.ID + "'>This page needs compiled first.</a>"); else ErrorManager.Error("A developer needs to compile this page first."); } } } else { HttpContext.Current.Response.StatusCode = 404; ErrorManager.Message("<img onclick='window.location=\"/Home/\";' style='margin-left:-10px;margin-top:-10px;margin-bottom:-14px;cursor:pointer;' src='https://c326078.ssl.cf1.rackcdn.com/404.png' alt='Error 404, The page you requested was not found on our server.' />"); } }
public virtual void onPagePreInitialize(MySqlConnection SQLConn, HttpContext Http, Member LoggedInMember, Logging Log, Page CurrentPage, HttpHeader HttpHead, Events Event) { this.SqlConnection = SQLConn; this.Http = Http; this.LoggedInMember = LoggedInMember; this.Log = Log; this.CurrentPage = CurrentPage; this.HttpHead = HttpHead; this.Event = Event; }
public Logging(MySqlConnection SqlConnection, Member LoggedInMember) { this.SqlConnection = SqlConnection; this.LoggedInMember = LoggedInMember; this.Http = HttpContext.Current; try { string IP = this.Http.Request.UserHostAddress; try { IP += "," + System.Net.Dns.GetHostByAddress(this.Http.Request.UserHostAddress).HostName; } catch { } MySqlCommand LogVisitQuery = new MySqlCommand("INSERT INTO logs (IP, Time, MemberID) VALUES(@IP, @Time, @MemberID)", SqlConnection); LogVisitQuery.Parameters.AddWithValue("@IP", IP); LogVisitQuery.Parameters.AddWithValue("@Time", DateTime.Now); LogVisitQuery.Parameters.AddWithValue("@MemberID", this.LoggedInMember.ID); LogVisitQuery.ExecuteNonQuery(); } catch { } }
public override void onPageLoad() { if (Utilities.GET("Compile") == "true") { echo("<h1>Welcome " + LoggedInMember.Nickname + "</h1>"); echo("<h3 style='margin-left:10px;'>There is currently " + Log.TotalVisitors() + " users viewing this website and " + Log.TotalMembers() + " registered members.</h3><br />"); echo("<div style='float: right;'><a href='/Admin/Pages/'>Back</a></div><br /><br />"); int PageID = Convert.ToInt32(Utilities.GET("ID")); Page EditPage = new Page(PageID, SqlConnection); System.CodeDom.Compiler.CompilerErrorCollection Errors = EditPage.Compile(); if (Errors != null) { foreach (System.CodeDom.Compiler.CompilerError Error in Errors) { if (Error.IsWarning) echo("<span style='color:yellow'>" + Error.ErrorText + "</span><br />"); else echo("<span style='color:red'>" + Error.ErrorText + " on line " + Error.Line + "</span><br />"); } } else echo("<span style='color:green'>Compiled Successfully!</span>"); } else if (Utilities.GET("NewPage") == "true") { echo(string.Format(@"<div class='boxcontainer'> <span class='header'>Welcome, {0}</span> <span class='links'> <a href='#' onclick='setFullScreen(editor, true);return false;'>Fullscreen</a> <a href='#' onclick='CreatePage(); return false;'>Create</a> <a href='/Admin/Pages/'>Quit</a> </span> <br /> <br /> There is currently {1} users viewing the website and {2} registered members. </div>", LoggedInMember.Nickname, Log.TotalVisitors(), Log.TotalMembers())); echo("<div class='boxcontainer'>"); echo("<a href='#' onclick='$(\".PageSettings\").animate({ height: \"toggle\" }); return false;'>Edit Settings</a><br /><span class='PageSettings'>"); echo("Page Url:<br /><input style='width:150px;' class='txtbar' type='text' id='Url' onkeypress='Edited();' onchange='Edited();' value='' /><br />"); echo("Page Domain:<br /><input style='width:150px;' class='txtbar' type='text' id='Domain' onkeypress='Edited();' onchange='Edited();' value='blaze-games.com' /><br />"); echo("Page References:<br /><input style='width:150px;' class='txtbar' type='text' id='new_reference' /> <a href='#' onclick='AddReference();return false;' title='Add Reference'>+</a> | <a href='#' onclick='RemoveReference();return false;' title='Remove Reference'>x</a><br />"); echo("<select style='width:200px;' multiple='multiple' class='dropdown' id='References'>"); echo("<option value='System.dll'>System.dll</option>"); echo("<option value='System.dll'>System.Core.dll</option>"); echo("<option value='System.Web.dll'>System.Web.dll</option>"); echo("<option value='System.Data.dll'>System.Data.dll</option>"); echo("<option value='mysql.data.dll'>mysql.data.dll</option>"); echo("<option value='BlazeGames.Web.dll'>BlazeGames.Web.dll</option>"); echo("</select><br />"); echo("Page Authorization:<br /><input style='width:20px;' class='txtbar' type='text' id='MinimumAuthorization' onkeypress='Edited();' onchange='Edited();' value='0' /><br />"); echo("RequireSecure:<br /><select style='width:75px;' class='dropdown' id='RequireSecure' onchange='Edited();'>"); echo("<option value='False'>False</option><option value='True'>True</option>"); echo("</select><br /><br />"); //echo("HtmlPage: <input style='width:200px;' class='txtbar' type='text' name='' value='" + EditPage.HtmlPage + "' /><br />"); echo("Page Code:<br /></span>"); echo(Utilities.CodeMirror("maincode", Page.DefaultCode, "text/x-csharp", true, "ambiance")); echo("Page CSS:<br />"); echo(Utilities.CodeMirror("csscode", Page.DefaultCSS, "text/css", false, "ambiance")); echo("Page Javascript:<br />"); echo(Utilities.CodeMirror("jscode", Page.DefaultJS, "text/javascript", false, "ambiance")); echo("Page Html:<br />"); echo(Utilities.CodeMirror("htmlcode", Page.DefaultHTML, "text/html", false, "ambiance")); echo("</div>"); } else if (Utilities.GET("EditPage") == "true" && Utilities.GET("ID") != "") { int PageID = Convert.ToInt32(Utilities.GET("ID")); Page EditPage = new Page(PageID, SqlConnection); if (EditPage.IsEditing == 0) { EditPage.IsEditing = LoggedInMember.ID; EditPage.Save(); } echo(string.Format(@"<div class='boxcontainer'> <span class='header'>Welcome, {0}</span> <span class='links'> <a href='#' onclick='setFullScreen(editor, true);return false;'>Fullscreen</a> <a href='#' onclick='UnlockPageNoRedirect({3}); return false;'>Unlock</a> <a href='#' onclick='DeletePage({3}); return false;'>Delete</a> <a href='#' onclick='CompilePage(false); return false;'>Compile</a> <a href='#' onclick='CompilePage(true); return false;'>Compile And Quit</a> <a href='/Admin/Pages/'>Quit</a> </span> <br /> <br /> There is currently {1} users viewing the website and {2} registered members. </div>", LoggedInMember.Nickname, Log.TotalVisitors(), Log.TotalMembers(), EditPage.ID)); if (EditPage.Exists) { echo("<div class='boxcontainer'>"); echo("<a href='#' onclick='$(\".PageSettings\").animate({ height: \"toggle\" }); return false;'>Edit Settings</a><br /><span class='PageSettings'>"); echo("<span style='display:none;' id='ID'>" + EditPage.ID + "</span>"); echo("Page Url:<br /><input style='width:150px;' class='txtbar' type='text' id='Url' onkeypress='Edited();' onchange='Edited();' value='" + EditPage.Url + "' /><br />"); echo("Page Domain:<br /><input style='width:150px;' class='txtbar' type='text' id='Domain' onkeypress='Edited();' onchange='Edited();' value='" + EditPage.Domain + "' /><br />"); echo("Page References:<br /><input style='width:150px;' class='txtbar' type='text' id='new_reference' /> <a href='#' onclick='AddReference();return false;' title='Add Reference'>+</a> | <a href='#' onclick='RemoveReference();return false;' title='Remove Reference'>x</a><br />"); echo("<select style='width:200px;' multiple='multiple' class='dropdown' id='References'>"); foreach (string Reference in EditPage.References) echo("<option value='" + Reference + "'>" + Reference + "</option>"); echo("</select><br />"); echo("Page Authorization:<br /><input style='width:20px;' class='txtbar' type='text' id='MinimumAuthorization' onkeypress='Edited();' onchange='Edited();' value='" + EditPage.MinimumAuthorization + "' /><br />"); echo("RequireSecure:<br /><select style='width:75px;' class='dropdown' id='RequireSecure' onchange='Edited();'>"); echo("<option value='" + EditPage.RequireSecure + "'>" + EditPage.RequireSecure + "</option><option value='" + (!EditPage.RequireSecure) + "'>" + (!EditPage.RequireSecure) + "</option>"); echo("</select><br /><br />"); //echo("HtmlPage: <input style='width:200px;' class='txtbar' type='text' name='' value='" + EditPage.HtmlPage + "' /><br />"); echo("Page Code:<br /></span>"); echo(Utilities.CodeMirror("maincode", EditPage.Code, "text/x-csharp", true, "ambiance")); echo("Page CSS:<br />"); echo(Utilities.CodeMirror("csscode", EditPage.PageCSS, "text/css", false, "ambiance")); echo("Page Javascript:<br />"); echo(Utilities.CodeMirror("jscode", EditPage.PageJS, "text/javascript", false, "ambiance")); echo("Page Html:<br />"); echo(Utilities.CodeMirror("htmlcode", EditPage.PageHTML, "text/html", false, "ambiance")); echo("</form><script>$('.PageSettings').animate({ height: 'toggle' });</script>"); echo("</div>"); } else echo("<div class='boxcontainer'>Unable to find the page you want to edit.</div>"); } else { echo(string.Format(@"<div class='boxcontainer'> <span class='header'>Welcome, {0}</span> <span class='links'> <a href='/Admin/'>Admin Home</a> <a href='/Admin/Pages/NewPage/'>New Page</a> <a href='#' onclick='CompileAll(); return false;'>Compile All Pages</a> </span> <br /> <br /> There is currently {1} users viewing the website and {2} registered members. </div>", LoggedInMember.Nickname, Log.TotalVisitors(), Log.TotalMembers())); MySqlCommand PageFetchQuery = new MySqlCommand("SELECT * FROM pages ORDER BY LastUpdate DESC", SqlConnection); MySqlDataReader PageFetchReader = PageFetchQuery.ExecuteReader(); List<object[]> Pages = new List<object[]>(); while (PageFetchReader.Read()) { int ID = PageFetchReader.GetInt32("ID"); string Url = PageFetchReader.GetString("Url"); string Domain = PageFetchReader.GetString("Domain"); DateTime Updated = PageFetchReader.GetDateTime("LastUpdate"); TimeSpan LastUpdate = DateTime.Now - Updated; int MinimumAuthorization = PageFetchReader.GetInt32("MinimumAuthorization"); int PageVersion = PageFetchReader.GetInt32("PageVersion"); int IsEditing = PageFetchReader.GetInt32("IsEditing"); Pages.Add(new object[] { ID, Url, Domain, Updated, MinimumAuthorization, PageVersion, IsEditing }); } PageFetchReader.Close(); echo("<style type='text/css'>.table_row:hover{ background-color:#CCCCCC; }</style>"); echo("<div class='boxcontainer'><br /><br /><table style='width:100%;' class='display pagelist'><thead><tr><th>ID</th><th>Domain</th><th>Url</th><th>Last Update</th><th>Update Sort</th><th>Auth</th><th>Locked To</th></tr></thead><tbody>"); foreach (object[] PageObj in Pages) { int ID = Convert.ToInt32(PageObj[0]); string Url = PageObj[1] as string; string Domain = PageObj[2] as string; DateTime Updated = Convert.ToDateTime(PageObj[3]); TimeSpan LastUpdate = DateTime.Now - Updated; int MinimumAuthorization = Convert.ToInt32(PageObj[4]); int PageVersion = Convert.ToInt32(PageObj[5]); int IsEditing = Convert.ToInt32(PageObj[6]); string LockedBy = "Unlocked"; if (IsEditing > 0) { Member LockedByMember = new Member(IsEditing, SqlConnection); LockedBy = LockedByMember.FirstName + " " + LockedByMember.LastName; } string RowStyle = ""; if (IsEditing > 0) RowStyle = "background-color:#DCECF2;"; else if (PageVersion != Page.CurrentPageVersion) RowStyle = "background-color:#EAE7D3;"; if (IsEditing != 0 && IsEditing != LoggedInMember.ID) echo("<tr class='table_row' pageid='" + ID + "' style='" + RowStyle + "'><td>" + ID + "</td><td>" + Domain + "</td><td>" + Url + "</td><td>" + Utilities.GetTimeSpan(LastUpdate) + "</td><td>" + Utilities.GetSortableDate(Updated) + "</td><td>" + MinimumAuthorization + "</td><td>" + LockedBy + "</td></tr>"); else echo("<tr class='table_row' pageid='" + ID + "' style='cursor:pointer;" + RowStyle + "'><td onclick=\"window.location='./EditPage/ID-" + ID + "/';\">" + ID + "</td><td onclick=\"window.location='./EditPage/ID-" + ID + "/';\">" + Domain + "</td><td onclick=\"window.location='./EditPage/ID-" + ID + "/';\">" + Url + "</td><td onclick=\"window.location='./EditPage/ID-" + ID + "/';\">" + Utilities.GetTimeSpan(LastUpdate) + "</td><td>" + Utilities.GetSortableDate(Updated) + "</td><td onclick=\"window.location='./EditPage/ID-" + ID + "/';\">" + MinimumAuthorization + "</td><td onclick=\"window.location='./EditPage/ID-" + ID + "/';\">" + LockedBy + "</td></tr>"); } echo("</tbody></table></div>"); } }
public static void Fatal(string Message, string Detail, string Title, string Source) { Message = Message.Replace("\r", "<br>"); Detail = Detail.Replace("\r", "<br>"); Source = Source.Replace("\r", "<br>").Replace(" ", " ").Replace("\t", " ").Replace("_", " "); string Buffer = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Error.txt"); Buffer = Buffer.Replace("<!--{Title}-->", Title); if (DetailedError) Buffer = Buffer.Replace("<!--{Message}-->", Message + "<br /><br />" + Detail); else { if(Utilities.isMobileBrowser()) Buffer = Buffer.Replace("<!--{Message}-->", "<div id='main' style='width:100%; margin-left:-11px; padding:10px; border: 1px solid #CCC;'>" + Message + "</div>"); else Buffer = Buffer.Replace("<!--{Message}-->", Message); } Buffer = Buffer.Replace("<!--{BackgroundColor}-->", System.Drawing.ColorTranslator.ToHtml(BackgroundColor)); Buffer = Buffer.Replace("<!--{ForegroundColor}-->", System.Drawing.ColorTranslator.ToHtml(ForegroundColor)); Buffer = Buffer.Replace("<!--{BorderColor}-->", System.Drawing.ColorTranslator.ToHtml(BorderColor)); string Buffer2 = ""; if (Utilities.isMobileBrowser()) Buffer2 = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Mobile/index.txt"); else Buffer2 = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/index.txt"); Buffer2 = Buffer2.Replace("<!--{PageContents}-->", Buffer); Buffer2 = Buffer2.Replace("<!--{WIDGET_Clock}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Clock.txt")); try { if (LoggedInMember.IsValid) Buffer2 = Buffer2.Replace("<!--{WIDGET_Login}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Login_Member.txt")); else Buffer2 = Buffer2.Replace("<!--{WIDGET_Login}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Login_Guest.txt")); } catch { Buffer2 = Buffer2.Replace("<!--{WIDGET_Login}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Login_Guest.txt")); } Buffer2 = Buffer2.Replace("<!--{WIDGET_Social)-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Social.txt")); Buffer2 = Buffer2.Replace("<!--{WIDGET_Posts}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Posts.txt")); Buffer2 = Buffer2.Replace("<!--{Time}-->", Utilities.GetDateTime()); Buffer2 = Buffer2.Replace("<!--{Url_Secure)-->", Utilities.GetCurrentUrl(true)); try { Buffer2 = Buffer2.Replace("<!--{Nickname}-->", LoggedInMember.Nickname); Buffer2 = Buffer2.Replace("<!--{ProfileImage}-->", LoggedInMember.GetProfileImage()); } catch { } try { SqlConnection.Close(); } catch { } HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(Buffer2); LoggedInMember = Member.Null(); HttpContext.Current.Response.End(); }
public void Load() { MySqlCommand PostFetchQuery = new MySqlCommand("SELECT * FROM posts WHERE ID=@ID", SqlConnection); PostFetchQuery.Parameters.AddWithValue("@ID", this.ID); MySqlDataReader PostFetchReader = PostFetchQuery.ExecuteReader(); if (PostFetchReader.Read()) { this.ForumID = PostFetchReader.GetInt32("ForumID"); this.ThreadID = PostFetchReader.GetInt32("ThreadID"); this.PostOwner = PostFetchReader.GetInt32("PostOwner"); this.PostReputation = PostFetchReader.GetInt32("PostReputation"); this.PostDate = PostFetchReader.GetDateTime("PostDate"); this.PostTitle = PostFetchReader.GetString("PostTitle"); this.PostContent = PostFetchReader.GetString("PostContent"); this.Exists = true; } else { this.Exists = false; } PostFetchReader.Close(); if (this.Exists) this.PostOwnerMember = new Member(this.PostOwner, SqlConnection); }
public DynamicPages(string PageUrl, MySqlConnection SqlConnection, Member LoggedInMember, Logging Log, HttpHeader HttpHead, Events Event) { this.LoggedInMember = LoggedInMember; this.Log = Log; this.SqlConnection = SqlConnection; this.HttpHead = HttpHead; this.Event = Event; #region PageUrl if (PageUrl == "/") { PageUrl = "/home/"; } else { PageUrl = PageUrl.ToLower(); } if (!PageUrl.StartsWith("/")) { PageUrl = "/" + PageUrl; } if (!PageUrl.EndsWith("/")) { PageUrl = PageUrl + "/"; } this.PageURL = PageUrl; #endregion string Domain = HttpContext.Current.Request.Url.Host.ToLower(); CurrentPage = new Page(PageUrl, Domain, SqlConnection); if (CurrentPage.Exists) { if (CurrentPage.RequireSecure || LoggedInMember.RequestSecure) { Utilities.MoveToSecure(); } if (!CurrentPage.HtmlPage) { if (CurrentPage.Compiled) { PageObject = Assembly.Load(CurrentPage.CompiledCode).CreateInstance("BlazeGames.Web." + "DynamicPage"); onPagePreInitialize(); if (!onPageAuthenticate()) { Event.Call("AuthenticateFailure()"); ErrorManager.Error("Please login to view this page."); } else { Event.Call("AuthenticateSuccess()"); } } else { if (LoggedInMember.Authority >= 5) { ErrorManager.Message("<a href='/Admin/Pages/?Act=Compile&ID=" + CurrentPage.ID + "'>This page needs compiled first.</a>"); } else { ErrorManager.Error("A developer needs to compile this page first."); } } } } else { HttpContext.Current.Response.StatusCode = 404; ErrorManager.Message("<img onclick='window.location=\"/Home/\";' style='margin-left:-10px;margin-top:-10px;margin-bottom:-14px;cursor:pointer;' src='https://c326078.ssl.cf1.rackcdn.com/404.png' alt='Error 404, The page you requested was not found on our server.' />"); } }
protected void Page_Load(object sender, EventArgs e) { int i = 0; while(true) { i++; try { Response.Clear(); ErrorManager.Initialize(Member.Null()); if (Utilities.isMobileBrowser()) Utilities.MoveToSecure(); DateTime startTime = DateTime.Now; string HTTP_Protocol = (Request.IsSecureConnection) ? "https://" : "http://"; Uri PageUri = new Uri(HTTP_Protocol + Request.Url.Host + Request.RawUrl); try { SqlConnection = new MySqlConnection("Server=localhost;Uid=root;Pwd=hl1vlAbR9a3Riu;database=blazegameshome5;Pooling=true;Min Pool Size=5;Max Pool Size=60;"); SqlConnection.Open(); } catch (MySql.Data.MySqlClient.MySqlException) { MySqlConnection.ClearAllPools(); SqlConnection = new MySqlConnection("Server=localhost;Uid=root;Pwd=hl1vlAbR9a3Riu;database=blazegameshome5"); SqlConnection.Open(); } #region Build PageEditor If Needed BlazeGames.Web.Core.Page PageEditor = new BlazeGames.Web.Core.Page(1, SqlConnection); if (PageEditor.Code != File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/bin/PageEditor.cs")) { PageEditor.Code = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/bin/PageEditor.cs"); System.CodeDom.Compiler.CompilerErrorCollection errors = PageEditor.Compile(); if (errors.Count >= 1) ErrorManager.Error(errors[0].ErrorText); } #endregion ErrorManager.Initialize(SqlConnection); string NewSessionKey = ""; while (true) { NewSessionKey = Guid.NewGuid().ToString(); MySqlCommand SessionVerifyQuery = new MySqlCommand("SELECT ID FROM members WHERE WebSessionKey=@WebSessionKey", SqlConnection); SessionVerifyQuery.Parameters.AddWithValue("@WebSessionKey", NewSessionKey); MySqlDataReader SessionVerifyReader = SessionVerifyQuery.ExecuteReader(); if (!SessionVerifyReader.Read()) { SessionVerifyReader.Close(); break; } else { SessionVerifyReader.Close(); continue; } } if (Request.Cookies["BlazeGames"] == null) { BGxCookie = new System.Web.HttpCookie("BlazeGames"); BGxCookie.Values.Add("WebSession", NewSessionKey); BGxCookie.Expires = DateTime.Now.AddDays(7); BGxCookie.Domain = ".blaze-games.com"; Response.Cookies.Add(BGxCookie); } else { BGxCookie = Request.Cookies["BlazeGames"]; System.Web.HttpCookie BGxCookieNew = new System.Web.HttpCookie("BlazeGames"); BGxCookieNew.Values.Add("WebSession", BGxCookie.Values["WebSession"]); BGxCookieNew.Expires = DateTime.Now.AddDays(7); BGxCookieNew.Domain = ".blaze-games.com"; Response.Cookies.Add(BGxCookieNew); BGxCookie = BGxCookieNew; } //Response.Write(BGxCookie.Values["WebSession"] + "<br />" + Request.UserHostAddress); //Response.End(); Member LoggedInMember; if (Utilities.GET("Account") != "" && Utilities.GET("Password") != "") { string Account = Utilities.GET("Account"), Password = Utilities.GET("Password"); if (Member.TryLoginWithPassword(Account, Password, SqlConnection)) LoggedInMember = new Member(Account, SqlConnection); else LoggedInMember = new Member(BGxCookie.Values["WebSession"], Request.UserHostAddress, SqlConnection); } else LoggedInMember = new Member(BGxCookie.Values["WebSession"], Request.UserHostAddress, SqlConnection); if (Utilities.POST("Account") != "" && Utilities.POST("Password") != "" && Utilities.POST("Act") == "Login" && !LoggedInMember.IsValid) { if (!Member.Login(Utilities.POST("Account"), Utilities.POST("Password"), BGxCookie.Values.Get("WebSession"), Request.UserHostAddress, SqlConnection)) ErrorManager.Fatal("Login Failed!\r\n<a href='" + PageUri.AbsolutePath + "'>Go Back</a><script>setTimeout('location.href = \"" + PageUri.AbsolutePath + "\";', 2500);</script>", "Account: " + Utilities.POST("Account") + "<br />Hash: " + Member.HashPassword(Utilities.POST("Password"))); else { LoggedInMember.Load(); ErrorManager.Initialize(LoggedInMember); ErrorManager.Message("Login Complete!\r\n<a href='" + PageUri.AbsolutePath + "'>Continue</a><script>setTimeout('location.href = \"" + PageUri.AbsolutePath + "\";', 2500);</script>"); } } else if (Utilities.GET("Act") == "Logout") { BGxCookie = new System.Web.HttpCookie("BlazeGames"); BGxCookie.Values.Add("WebSession", Guid.NewGuid().ToString()); BGxCookie.Domain = ".blaze-games.com"; BGxCookie.Expires = DateTime.Now.AddMonths(1); Response.Cookies.Add(BGxCookie); ErrorManager.Initialize(new Member("", "", SqlConnection)); ErrorManager.Message("Logout Complete!\r\n<a href='" + PageUri.AbsolutePath + "'>Go Back</a><script>setTimeout('location.href = \"" + PageUri.AbsolutePath + "\";', 2500);</script>"); } LoggedInMember.Load(); ErrorManager.Initialize(LoggedInMember); Logging Log = new Logging(SqlConnection, LoggedInMember); HttpHeader HttpHead = new HttpHeader(); Core.Events Event = new Core.Events(); PageSys = new DynamicPages(PageUri.AbsolutePath, SqlConnection, LoggedInMember, Log, HttpHead, Event); PageSys.onPageInitialize(); PageSys.onPageLoad(); string Buffer = ""; if (Utilities.isMobileApps()) Buffer = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/MobileApps/index.txt"); else if (Utilities.isMobileBrowser()) Buffer = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Mobile/index.txt"); else Buffer = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/" + HttpHead.Theme + "/index.txt"); Buffer = Buffer.Replace("<!--{PageHeader}-->", HttpHead.ToString() + "\r\n<style type='text/css'>\r\n" + PageSys.CurrentPage.PageCSS + "\r\n</style>\r\n" + "<script type='text/javascript'>\r\n" + PageSys.CurrentPage.PageJS + "\r\n</script>"); Buffer = Buffer.Replace("<!--{PageContents}-->", PageSys.CurrentPage.PageHTML); Buffer = Buffer.Replace("<!--{PageCode}-->", PageSys.onPageReturn()); Buffer = Buffer.Replace("<!--{WIDGET_Clock}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Clock.txt")); if (LoggedInMember.IsValid) Buffer = Buffer.Replace("<!--{WIDGET_Login}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Login_Member.txt")); else Buffer = Buffer.Replace("<!--{WIDGET_Login}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Login_Guest.txt")); Buffer = Buffer.Replace("<!--{WIDGET_Social)-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Social.txt")); Buffer = Buffer.Replace("<!--{WIDGET_Posts}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Posts.txt")); Buffer = Buffer.Replace("<!--{Time}-->", Utilities.GetDateTime()); Buffer = Buffer.Replace("<!--{Nickname}-->", LoggedInMember.Nickname); Buffer = Buffer.Replace("<!--{ProfileImage}-->", LoggedInMember.GetProfileImage()); Buffer = Buffer.Replace("<!--{Url_Secure)-->", Utilities.GetCurrentUrl(true)); Buffer = Buffer.Replace("<!--{PageName}-->", PageSys.PageURL); foreach (string ParamKey in HttpHead.ThemeParameters.Keys) Buffer = Buffer.Replace("{" + ParamKey + "}", HttpHead.ThemeParameters[ParamKey]); Buffer = Buffer.Replace("{ThemePath}", "/Themes/" + HttpHead.Theme + "/"); DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; SqlConnection.CancelQuery(100); SqlConnection.Close(); //SqlConnection.Dispose(); Response.Write(@"<!-- ------------------------------------------ ---- Blaze Games Web v5 Debug Console ---- ------------------------------------------ Script Execution Time: " + duration.Milliseconds + @"MS sqlConnection State: " + SqlConnection.State + @" --> "); Response.Write(Buffer); Response.Flush(); Response.End(); PageSys.onPageUnLoad(); break; } catch (Exception ex) { if (i == 5) { throw ex; } continue; } } }