diff options
| author | Michael <[email protected]> | 2017-03-20 16:45:17 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-03-20 16:45:17 -0400 |
| commit | cdc61eb4ea5309769ad4db84d92594e4dc3dff67 (patch) | |
| tree | a8297a7aecc4376f07a497a5e02ab5ff165bfbd3 /Project-Unite/Global.asax.cs | |
| parent | d9f475e1f33bbf39ca0d79d7a6b0c2fd501b4f2d (diff) | |
| download | project-unite-cdc61eb4ea5309769ad4db84d92594e4dc3dff67.tar.gz project-unite-cdc61eb4ea5309769ad4db84d92594e4dc3dff67.tar.bz2 project-unite-cdc61eb4ea5309769ad4db84d92594e4dc3dff67.zip | |
Initial commit (azure deploy test)
Diffstat (limited to 'Project-Unite/Global.asax.cs')
| -rw-r--r-- | Project-Unite/Global.asax.cs | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/Project-Unite/Global.asax.cs b/Project-Unite/Global.asax.cs new file mode 100644 index 0000000..198560c --- /dev/null +++ b/Project-Unite/Global.asax.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using System.Web.Optimization; +using System.Web.Routing; +using Microsoft.AspNet.Identity; +using Project_Unite.Models; + +namespace Project_Unite +{ + public class MvcApplication : System.Web.HttpApplication + { + protected void Application_Start() + { + AreaRegistration.RegisterAllAreas(); + FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); + RouteConfig.RegisterRoutes(RouteTable.Routes); + BundleConfig.RegisterBundles(BundleTable.Bundles); + } + + protected void Application_BeginRequest(object sender, EventArgs e) + { + + var addr = HttpContext.Current.Request.UserHostAddress; + var db = new ApplicationDbContext(); + var ip = db.BannedIPs.FirstOrDefault(i => i.Address == addr); + if (ip != null) + { + //The user is banned. Anally rape their ability to get on here. + this.Response.StatusCode = 403; + this.CompleteRequest(); + return; + } + } + + protected void Application_EndRequest(object s, EventArgs e) + { + var db = new ApplicationDbContext(); + if (!string.IsNullOrEmpty(User.Identity.Name)) + { + //Check for a username ban. + var usr = db.Users.First(x => x.UserName == User.Identity.Name); + var banned = usr.IsBanned; + if (banned == true) + { + //The user is banned. Anally rape their ability to get on here. + this.Response.StatusCode = 200; + this.Response.ContentType = "plaintext"; + this.Response.ClearContent(); + this.Response.Output.Write($@"Greetings from the ShiftOS administration team, {ACL.UserNameRaw(User.Identity.GetUserId())}. + +If you are seeing this page, it means two things: + +1. I, Michael, am an awesome programmer and managed to get this ban system fully working. +2. You've been banned. + +If you would like to appeal the ban, contact me through my email address: [email protected] + +Ban information: + +Bannee: {ACL.UserNameRaw(User.Identity.GetUserId())} +Banner: {ACL.UserNameRaw(usr.BannedBy)} +Timestamp: {usr.BannedAt} + +DISCLAIMER: +============= + +We reserve the right to disregard ban appeals if we see fit. Users other than myself or another Administrator +may administrate a ban appeal. Do not try to contact the banner. They will most likely not respond, and if they do, +it will most likely not end well for your status. + +Do not attempt to multi-account or perform any form of ban-evading. If you are detected ban-evading, +you will be IP-banned and this screen won't be as friendly to you. + +As it stands, this ban does not affect your ability to play ShiftOS. You can still connect to the multi-user domain, +however, if you do ban-evade, your IP ban CAN and WILL be extended to the multi-user domain. + +We also reserve the right to purge your data after 2 months of a permanent ban. This is to save space on our database, +so do not cry to us when you find out you can't log in because your account got anhilated by the automatic purge system. + + - Michael VanOverbeek, on behalf of the ShiftOS staff. Play fair."); + this.CompleteRequest(); + return; + + } + if (usr.LastKnownIPAddress != Request.UserHostAddress) + { + usr.LastKnownIPAddress = Request.UserHostAddress; + db.SaveChanges(); + } + } + + } + } +} |
