1
0

final update

This commit is contained in:
Labality
2021-08-19 16:35:32 +07:00
parent c2e012237f
commit f4fa1d8085
11877 changed files with 1192560 additions and 0 deletions

View File

@ -0,0 +1,12 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
public class AboutController : Controller
{
public ActionResult Index()
{
return View();
}
}
}

View File

@ -0,0 +1,158 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using Models;
public class AccountController : Controller
{
public IFormsAuthenticationService FormsService { get; set; }
public IMembershipService MembershipService { get; set; }
protected override void Initialize(RequestContext requestContext)
{
if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
if (MembershipService == null) { MembershipService = new AccountMembershipService(); }
base.Initialize(requestContext);
}
// **************************************
// URL: /Account/LogOn
// **************************************
public ActionResult LogOn()
{
return View();
}
public ActionResult Test()
{
return View();
}
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (MembershipService.ValidateUser(model.UserName, model.Password))
{
FormsService.SignIn(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
[Authorize]
public ActionResult ManageRoles()
{
return View();
}
// **************************************
// URL: /Account/LogOff
// **************************************
public ActionResult LogOff()
{
FormsService.SignOut();
return RedirectToAction("Index", "Home");
}
// **************************************
// URL: /Account/Register
// **************************************
[Authorize]
public ActionResult Register()
{
ViewBag.PasswordLength = MembershipService.MinPasswordLength;
return View();
}
[Authorize]
[HttpPost]
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
// Attempt to register the user
MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);
if (createStatus == MembershipCreateStatus.Success)
{
FormsService.SignIn(model.UserName, false /* createPersistentCookie */);
return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
}
}
// If we got this far, something failed, redisplay form
ViewBag.PasswordLength = MembershipService.MinPasswordLength;
return View(model);
}
// **************************************
// URL: /Account/ChangePassword
// **************************************
[Authorize]
public ActionResult ChangePassword()
{
ViewBag.PasswordLength = MembershipService.MinPasswordLength;
return View();
}
[Authorize]
[HttpPost]
public ActionResult ChangePassword(ChangePasswordModel model)
{
if (ModelState.IsValid)
{
if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword))
{
return RedirectToAction("ChangePasswordSuccess");
}
else
{
ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
}
}
// If we got this far, something failed, redisplay form
ViewBag.PasswordLength = MembershipService.MinPasswordLength;
return View(model);
}
// **************************************
// URL: /Account/ChangePasswordSuccess
// **************************************
public ActionResult ChangePasswordSuccess()
{
return View();
}
}
}

View File

@ -0,0 +1,29 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
using Common.Models;
using Core.Model.Server.GameServer.CaptureThePig.Stats;
using Newtonsoft.Json;
public class CaptureThePigController : PvpController
{
private readonly ICaptureThePigAdministrator _captureThePigAdministrator;
public CaptureThePigController(ICaptureThePigAdministrator captureThePigAdministrator)
{
_captureThePigAdministrator = captureThePigAdministrator;
}
protected override IPvpAdministrator GetAdministrator()
{
return _captureThePigAdministrator;
}
[HttpPost]
public ContentResult UploadStats(CaptureThePigGameStatsToken token)
{
var json = JsonConvert.SerializeObject(_captureThePigAdministrator.UploadStats(token));
return Content(json, "application/json");
}
}
}

View File

@ -0,0 +1,63 @@
using LOC.Core.Tokens.Clan;
namespace LOC.Website.Web.Controllers
{
using System.Collections.Generic;
using System.Web.Mvc;
using Common.Models;
using Newtonsoft.Json;
public class ClanController : Controller
{
private readonly IClanAdministrator _clanAdministrator;
public ClanController(IClanAdministrator clanAdministrator)
{
_clanAdministrator = clanAdministrator;
}
[HttpPost]
public void AddClan(ClanToken clan)
{
_clanAdministrator.AddClan(clan);
}
[HttpPost]
public void EditClan(ClanToken clan)
{
_clanAdministrator.EditClan(clan);
}
[HttpPost]
public void DeleteClan(ClanToken clan)
{
_clanAdministrator.DeleteClan(clan);
}
[HttpPost]
public ActionResult GetClans(string serverName)
{
var clans = _clanAdministrator.GetClans(serverName);
var json = JsonConvert.SerializeObject(clans);
return Content(json, "application/json");
}
[HttpPost]
public void UpdateClanTNTGenerators(List<ClanGeneratorToken> tokens)
{
_clanAdministrator.UpdateClanTNTGenerators(tokens);
}
[HttpPost]
public void UpdateClanTNTGenerator(ClanGeneratorToken token)
{
_clanAdministrator.UpdateClanTNTGenerator(token);
}
[HttpPost]
public void ResetClanData()
{
_clanAdministrator.ResetClanData();
}
}
}

View File

@ -0,0 +1,12 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
public class ClassesController : Controller
{
public ActionResult Index()
{
return View();
}
}
}

View File

@ -0,0 +1,19 @@
namespace LOC.Website.Web.DependencyResolution
{
using StructureMap;
public static class IoC {
public static IContainer Initialize()
{
ObjectFactory.Initialize(
x => x.Scan(
scan =>
{
scan.TheCallingAssembly();
scan.AssembliesFromApplicationBaseDirectory();
scan.WithDefaultConventions();
}));
return ObjectFactory.Container;
}
}
}

View File

@ -0,0 +1,34 @@
namespace LOC.Website.Web.DependencyResolution
{
using StructureMap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
public class SmDependencyResolver : IDependencyResolver {
private readonly IContainer _container;
public SmDependencyResolver(IContainer container) {
_container = container;
}
public object GetService(Type serviceType) {
if (serviceType == null) return null;
try {
return serviceType.IsAbstract || serviceType.IsInterface
? _container.TryGetInstance(serviceType)
: _container.GetInstance(serviceType);
}
catch {
return null;
}
}
public IEnumerable<object> GetServices(Type serviceType) {
return _container.GetAllInstances(serviceType).Cast<object>();
}
}
}

View File

@ -0,0 +1,29 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
using Common.Models;
using Core.Model.GameServer.Stats;
using Newtonsoft.Json;
public class DominateController : PvpController
{
private readonly IDominateAdministrator _dominateAdministrator;
public DominateController(IDominateAdministrator dominateAdministrator)
{
_dominateAdministrator = dominateAdministrator;
}
protected override IPvpAdministrator GetAdministrator()
{
return _dominateAdministrator;
}
[HttpPost]
public ContentResult UploadStats(DominateGameStatsToken token)
{
var json = JsonConvert.SerializeObject(_dominateAdministrator.UploadStats(token));
return Content(json, "application/json");
}
}
}

View File

@ -0,0 +1,106 @@
namespace LOC.Website.Web.Controllers
{
using System.Linq;
using System.Web.Mvc;
using Common.Contexts;
using Core.Model.Server.PvpServer;
using Newtonsoft.Json;
public class FieldsController : Controller
{
private readonly LocContext context = new LocContext();
[HttpPost]
public ActionResult GetFieldBlocks(string key)
{
var json = JsonConvert.SerializeObject(context.Fields.Where(x => x.Server == key).ToList());
return Content(json, "application/json");
}
[HttpPost]
public void AddField(FieldBlock newFieldBlock)
{
var field = context.Fields.FirstOrDefault(x => x.Location == newFieldBlock.Location);
if (field != null)
context.Fields.Remove(field);
context.Fields.Add(newFieldBlock);
context.SaveChanges();
}
[HttpPost]
public void DeleteField(FieldBlock block)
{
var field = context.Fields.FirstOrDefault(x => x.Server == block.Server && x.Location == block.Location);
if (field != null)
{
context.Fields.Remove(field);
context.SaveChanges();
}
}
[HttpPost]
public ActionResult GetFieldOres(string key)
{
var json = JsonConvert.SerializeObject(context.FieldOres.Where(x => x.Server == key).ToList());
return Content(json, "application/json");
}
[HttpPost]
public void AddFieldOre(FieldOre newField)
{
var field = context.FieldOres.FirstOrDefault(x => x.Location == newField.Location);
if (field != null)
context.FieldOres.Remove(field);
context.FieldOres.Add(newField);
context.SaveChanges();
}
[HttpPost]
public void DeleteFieldOre(FieldOre ore)
{
var field = context.FieldOres.FirstOrDefault(x => x.Server == ore.Server && x.Location == ore.Location);
if (field != null)
{
context.FieldOres.Remove(field);
context.SaveChanges();
}
}
[HttpPost]
public ActionResult GetFieldMonsters(string key)
{
var json = JsonConvert.SerializeObject(context.FieldMonsters.Where(x => x.Server == key).ToList());
return Content(json, "application/json");
}
[HttpPost]
public void AddFieldMonster(FieldMonster newField)
{
var field = context.FieldMonsters.FirstOrDefault(x => x.Name == newField.Name);
if (field != null)
context.FieldMonsters.Remove(field);
context.FieldMonsters.Add(newField);
context.SaveChanges();
}
[HttpPost]
public void DeleteFieldMonster(FieldMonster monster)
{
var field = context.FieldMonsters.FirstOrDefault(x => x.Server == monster.Server && x.Name == monster.Name);
while (field != null)
{
context.FieldMonsters.Remove(field);
context.SaveChanges();
}
}
}
}

View File

@ -0,0 +1,112 @@
namespace LOC.Website.Web.Controllers
{
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web.Mvc;
using Common.Contexts;
using Core.Model.Server.PvpServer;
using Core.Tokens.Client;
using Newtonsoft.Json;
public class FishingController : Controller
{
private readonly LocContext _context = new LocContext();
[HttpPost]
public ContentResult GetFishingAllTimeHigh()
{
var tokenList = new List<FishToken>();
foreach (var fish in _context.FishCatches.Where(x => string.Equals(x.Owner, "AllTimeHigh")).Include(x => x.Catcher))
{
tokenList.Add(new FishToken { Catcher = fish.Catcher.Name, Name = fish.Name, Size = fish.Size });
}
var json = JsonConvert.SerializeObject(tokenList);
return Content(json, "application/json");
}
[HttpPost]
public ContentResult GetFishingDayHigh()
{
var tokenList = new List<FishToken>();
foreach (var fish in _context.FishCatches.Where(x => string.Equals(x.Owner, "DayHigh")).Include(x => x.Catcher))
{
tokenList.Add(new FishToken { Catcher = fish.Catcher.Name, Name = fish.Name, Size = fish.Size });
}
var json = JsonConvert.SerializeObject(tokenList);
return Content(json, "application/json");
}
[HttpPost]
public void ClearDailyFishingScores()
{
foreach (var id in _context.FishCatches.Where(x => string.Equals(x.Owner, "DayHigh")).Select(e => e.FishCatchId))
{
var entity = new FishCatch { FishCatchId = id };
_context.FishCatches.Attach(entity);
_context.FishCatches.Remove(entity);
}
_context.SaveChanges();
}
[HttpPost]
public void SaveFishingAllTimeHigh(FishToken fishToken)
{
SaveFishingScore("AllTimeHigh", fishToken);
}
[HttpPost]
public void SaveFishingDayHigh(FishToken fishToken)
{
SaveFishingScore("DayHigh", fishToken);
}
[HttpPost]
public void SaveFishingScore(FishToken fishToken)
{
SaveFishingScore(fishToken.Catcher, fishToken);
}
private void SaveFishingScore(string owner, FishToken fishToken)
{
var account = _context.Accounts.First(x => string.Equals(x.Name, fishToken.Catcher));
var fishCatch =
_context.FishCatches.Where(
x => string.Equals(x.Owner, owner) && string.Equals(x.Name, fishToken.Name)).Include(x => x.Catcher).FirstOrDefault();
if (fishCatch == null)
{
fishCatch = new FishCatch { Owner = owner };
_context.FishCatches.Add(fishCatch);
}
else
{
if (string.Equals(owner, fishToken.Catcher))
{
account.FishCatches.Remove(fishCatch);
account.FishCatches.Add(fishCatch);
}
_context.FishCatches.Attach(fishCatch);
}
fishCatch.Catcher = account;
fishCatch.Name = fishToken.Name;
fishCatch.Size = fishToken.Size;
_context.Entry(account).State = EntityState.Modified;
_context.SaveChanges();
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace LOC.Website.Web.Controllers
{
public class ForumsController : Controller
{
public ActionResult Index()
{
return View();
}
}
}

View File

@ -0,0 +1,22 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
return View();
}
public ActionResult PaypalTest()
{
return View();
}
}
}

View File

@ -0,0 +1,13 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
public class ManageController : Controller
{
[Authorize(Roles = "Admins")]
public ActionResult Index()
{
return View();
}
}
}

View File

@ -0,0 +1,37 @@
namespace LOC.Website.Web.Controllers
{
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web.Mvc;
using Common.Data;
using Core.Model.Server.GameServer.MineKart;
using Newtonsoft.Json;
public class MineKartController : Controller
{
private readonly INautilusRepositoryFactory _repositoryFactory;
public MineKartController(INautilusRepositoryFactory nautilusRepositoryFactory)
{
_repositoryFactory = nautilusRepositoryFactory;
}
[HttpPost]
public ContentResult GetKartItems(List<MineKart> minekarts)
{
using (var repository = _repositoryFactory.CreateRepository())
{
foreach (var item in minekarts.Where(item => !repository.Any<MineKart>(x => x.Name == item.Name)))
{
repository.Add(item);
}
repository.CommitChanges();
var json = JsonConvert.SerializeObject(repository.GetAll<MineKart>().Include(x => x.SalesPackage).ToList());
return Content(json, "application/json");
}
}
}
}

View File

@ -0,0 +1,225 @@
namespace LOC.Website.Web.Controllers
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web.Mvc;
using Common;
using Common.Models;
public class PaypalController : Controller
{
private readonly IAccountAdministrator _accountAdministrator;
private readonly ISalesPackageAdministrator _salesPackageAdministrator;
private readonly ILogger _logger;
public PaypalController(IAccountAdministrator accountAdministrator, ISalesPackageAdministrator salesPackageAdministrator, ILogger logger)
{
_accountAdministrator = accountAdministrator;
_salesPackageAdministrator = salesPackageAdministrator;
_logger = logger;
}
public ActionResult ImpulseIpn()
{
var formVals = new Dictionary<string, string>();
formVals.Add("cmd", "_notify-validate");
string response = GetPayPalResponse(formVals, false);
if (response == "VERIFIED")
{
var transactionType = Request["txn_type"];
if (String.Equals(transactionType, "web_accept"))
{
var itemNumber = Request["item_number"];
var playerName = Request["option_selection1"];
var fee = Convert.ToDecimal(Request["mc_fee"]);
var gross = Convert.ToDecimal(Request["mc_gross"]);
try
{
var account = _accountAdministrator.GetAccountByName(playerName);
if (account == null)
{
if (!String.IsNullOrEmpty(playerName))
{
account = _accountAdministrator.CreateAccount(playerName);
}
else
{
account = _accountAdministrator.CreateAccount("NullPlayerNameInTransactionRequest");
}
}
var salesPackage = _salesPackageAdministrator.GetSalesPackageById(Convert.ToInt32(itemNumber));
_accountAdministrator.ApplySalesPackage(salesPackage, account.AccountId, gross, fee);
}
catch (Exception ex)
{
StringBuilder sb = new StringBuilder();
foreach (var variable in Request.Params.AllKeys)
{
sb.AppendLine(variable + "=" + Request.Params[variable]);
}
_logger.Log("Error", sb + ex.Message + "\n" + ex.StackTrace);
throw;
}
}
}
return View();
}
public ActionResult Ipn()
{
var formVals = new Dictionary<string, string>();
formVals.Add("cmd", "_notify-validate");
string response = GetPayPalResponse(formVals, false);
if (response == "VERIFIED")
{
var transactionType = Request["txn_type"];
if (String.Equals(transactionType, "web_accept") || String.Equals(transactionType, "subscr_payment"))
{
var itemNumber = Request["item_number"];
var playerName = Request["option_selection1"];
var serverName = Request["option_selection2"];
var fee = Convert.ToDecimal(Request["mc_fee"]);
var gross = Convert.ToDecimal(Request["mc_gross"]);
if (String.Equals(serverName, "impulse"))
{
PostToImpulse();
return null;
}
try
{
var account = _accountAdministrator.GetAccountByName(playerName);
if (account == null)
{
if(!String.IsNullOrEmpty(playerName))
{
account = _accountAdministrator.CreateAccount(playerName);
}
else
{
account = _accountAdministrator.GetAccountByName("NullPlayerNameInTransactionRequest") ??
_accountAdministrator.CreateAccount("NullPlayerNameInTransactionRequest");
}
}
var salesPackage = _salesPackageAdministrator.GetSalesPackageById(Convert.ToInt32(itemNumber));
_accountAdministrator.ApplySalesPackage(salesPackage, account.AccountId, gross, fee);
}
catch (Exception ex)
{
StringBuilder sb = new StringBuilder();
foreach (var variable in Request.Params.AllKeys)
{
sb.AppendLine(variable + "=" + Request.Params[variable]);
}
_logger.Log("Error", sb + ex.Message + "\n" + ex.StackTrace);
throw;
}
}
}
return View();
}
public ActionResult Receipt()
{
return View();
}
/// <summary>
/// Utility method for handling PayPal Responses
/// </summary>
string GetPayPalResponse(Dictionary<string, string> formVals, bool useSandbox) {
string paypalUrl = useSandbox ? "https://www.sandbox.paypal.com/cgi-bin/webscr"
: "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(paypalUrl);
// Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
StringBuilder sb = new StringBuilder();
sb.Append(strRequest);
foreach (string key in formVals.Keys)
{
sb.AppendFormat("&{0}={1}", key, formVals[key]);
}
strRequest += sb.ToString();
req.ContentLength = strRequest.Length;
//Send the request to PayPal and get the response
string response = "";
using (var streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII))
{
streamOut.Write(strRequest);
streamOut.Close();
using (var streamIn = new StreamReader(req.GetResponse().GetResponseStream()))
{
response = streamIn.ReadToEnd();
}
}
return response;
}
void PostToImpulse()
{
var req = (HttpWebRequest)WebRequest.Create(@"http://www.gamingminecraft.com/battleau/Paypal/ImpulseIpn");
// Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
StringBuilder sb = new StringBuilder();
sb.Append(strRequest);
foreach (string key in Request.Params.AllKeys)
{
sb.AppendFormat("&{0}={1}", key, Request.Params[key]);
}
strRequest += sb.ToString();
req.ContentLength = strRequest.Length;
//Send the request to PayPal and get the response
using (var streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII))
{
streamOut.Write(strRequest);
streamOut.Close();
}
}
}
}

View File

@ -0,0 +1,176 @@
namespace LOC.Website.Web.Controllers
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web.Mvc;
using Common;
using Common.Models;
using ViewModels;
public class PaypalTestController : Controller
{
private readonly IAccountAdministrator _accountAdministrator;
private readonly ISalesPackageAdministrator _salesPackageAdministrator;
private readonly IStoreViewModel _storeModel;
private readonly ILogger _logger;
public PaypalTestController(IAccountAdministrator accountAdministrator, ISalesPackageAdministrator salesPackageAdministrator, IStoreViewModel storeModel, ILogger logger)
{
_accountAdministrator = accountAdministrator;
_salesPackageAdministrator = salesPackageAdministrator;
_storeModel = storeModel;
_logger = logger;
}
public ActionResult Ipn()
{
var formVals = new Dictionary<string, string>();
formVals.Add("cmd", "_notify-validate");
string response = GetPayPalResponse(formVals, true);
if (response == "VERIFIED")
{
var transactionType = Request["txn_type"];
if (String.Equals(transactionType, "web_accept"))
{
var itemNumber = Request["item_number"];
var playerName = Request["option_selection1"];
var serverName = Request["option_selection2"];
var fee = Convert.ToDecimal(Request["mc_fee"]);
var gross = Convert.ToDecimal(Request["mc_gross"]);
if (String.Equals(serverName, "impulse"))
{
PostToImpulse();
return null;
}
try
{
var account = _accountAdministrator.GetAccountByName(playerName);
if (account == null)
{
if(!String.IsNullOrEmpty(playerName))
{
account = _accountAdministrator.CreateAccount(playerName);
}
else
{
account = _accountAdministrator.CreateAccount("NullPlayerNameInTransactionRequest");
}
}
var salesPackage = _salesPackageAdministrator.GetSalesPackageById(Convert.ToInt32(itemNumber));
_accountAdministrator.ApplySalesPackage(salesPackage, account.AccountId, gross, fee);
}
catch (Exception ex)
{
StringBuilder sb = new StringBuilder();
foreach (var variable in Request.Params.AllKeys)
{
sb.AppendLine(variable + "=" + Request.Params[variable]);
}
_logger.Log("Error", sb + ex.Message + "\n" + ex.StackTrace);
throw;
}
}
}
return View();
}
public ActionResult Receipt(int transactionId)
{
return View(transactionId);
}
public ActionResult Index()
{
return View(_storeModel.SalesPackages.Where(x => x.Test).ToList());
}
void PostToImpulse()
{
var req = (HttpWebRequest)WebRequest.Create(@"http://www.gamingminecraft.com/impulse/PaypalTest/Ipn");
// Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
StringBuilder sb = new StringBuilder();
sb.Append(strRequest);
foreach (string key in Request.Params.AllKeys)
{
sb.AppendFormat("&{0}={1}", key, Request.Params[key]);
}
strRequest += sb.ToString();
req.ContentLength = strRequest.Length;
//Send the request to PayPal and get the response
using (var streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII))
{
streamOut.Write(strRequest);
streamOut.Close();
}
}
/// <summary>
/// Utility method for handling PayPal Responses
/// </summary>
string GetPayPalResponse(Dictionary<string, string> formVals, bool useSandbox) {
string paypalUrl = useSandbox ? "https://www.sandbox.paypal.com/cgi-bin/webscr"
: "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(paypalUrl);
// Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
StringBuilder sb = new StringBuilder();
sb.Append(strRequest);
foreach (string key in formVals.Keys)
{
sb.AppendFormat("&{0}={1}", key, formVals[key]);
}
strRequest += sb.ToString();
req.ContentLength = strRequest.Length;
//Send the request to PayPal and get the response
string response = "";
using (var streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII))
{
streamOut.Write(strRequest);
streamOut.Close();
using (var streamIn = new StreamReader(req.GetResponse().GetResponseStream()))
{
response = streamIn.ReadToEnd();
}
}
return response;
}
}
}

View File

@ -0,0 +1,73 @@
namespace LOC.Website.Web.Controllers
{
using System.Collections.Generic;
using System.Web.Mvc;
using Common.Models;
using Core.Model.Server;
using Core.Tokens.Client;
using Newtonsoft.Json;
using LOC.Website.Common;
public class PetsController : Controller
{
private readonly IPetAdministrator _petAdministrator;
private readonly ILogger _logger;
public PetsController(IPetAdministrator petAdministrator, ILogger logger)
{
_petAdministrator = petAdministrator;
_logger = logger;
}
[HttpPost]
public ContentResult GetPets(List<Pet> pets)
{
var json = JsonConvert.SerializeObject(_petAdministrator.GetPets(pets));
return Content(json, "application/json");
}
[HttpPost]
public ContentResult GetBulkPets(BulkConfig bulkConfig)
{
var json = JsonConvert.SerializeObject(_petAdministrator.GetBulkPets(bulkConfig.Start, bulkConfig.Count));
return Content(json, "application/json");
}
[HttpPost]
public ContentResult GetPetExtras(List<PetExtra> petExtras)
{
var json = JsonConvert.SerializeObject(_petAdministrator.GetPetExtras(petExtras));
return Content(json, "application/json");
}
[HttpPost]
public void AddPet(PetChangeToken pet)
{
_petAdministrator.AddPet(pet);
}
[HttpPost]
public void UpdatePet(PetChangeToken pet)
{
_petAdministrator.UpdatePet(pet);
}
[HttpPost]
public void RemovePet(PetChangeToken pet)
{
_petAdministrator.RemovePet(pet);
}
[HttpPost]
public void AddPetNameTag(string name)
{
_petAdministrator.AddPetNameTag(name);
}
[HttpPost]
public void RemovePetNameTag(string name)
{
_petAdministrator.RemovePetNameTag(name);
}
}
}

View File

@ -0,0 +1,203 @@
namespace LOC.Website.Web.Controllers
{
using System;
using System.Web.Mvc;
using Common;
using Common.Models;
using Core.Model.Server;
using Core.Tokens;
using Core.Tokens.Client;
using Newtonsoft.Json;
using System.Collections.Generic;
using LOC.Core;
public class PlayerAccountController : Controller
{
private readonly IAccountAdministrator _accountAdministrator;
private readonly ILogger _logger;
public PlayerAccountController(IAccountAdministrator accountAdministrator, ILogger logger)
{
_accountAdministrator = accountAdministrator;
_logger = logger;
}
[HttpPost]
public ActionResult GetAccountNames()
{
var accountNames = _accountAdministrator.GetAccountNames();
var json = JsonConvert.SerializeObject(accountNames);
return Content(json, "application/json");
}
[HttpPost]
public ActionResult GetAccount(string name)
{
var account = _accountAdministrator.GetAccountByName(name);
var json = JsonConvert.SerializeObject(account);
return Content(json, "application/json");
}
/*
[HttpPost]
public ActionResult GetTasksByCount(SearchConf searchConf)
{
var tasks = _accountAdministrator.GetTasksByCount(searchConf);
var json = JsonConvert.SerializeObject(tasks);
return Content(json, "application/json");
}
*/
[HttpPost]
public ActionResult GetAccountByUUID(string uuid)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.GetAccountByUUID(uuid));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult GetDonor(string name)
{
var account = _accountAdministrator.GetAccountByName(name);
var json = JsonConvert.SerializeObject(account);
return Content(json, "application/json");
}
[HttpPost]
public ActionResult Login(LoginRequestToken loginRequest)
{
var json = JsonConvert.SerializeObject(new ClientToken(_accountAdministrator.Login(loginRequest)));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult PurchaseKnownSalesPackage(PurchaseToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.PurchaseGameSalesPackage(token));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult PurchaseUnknownSalesPackage(UnknownPurchaseToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.PurchaseUnknownSalesPackage(token));
return Content(json, "application/json");
}
[HttpPost]
public void ApplyKits(string name)
{
_accountAdministrator.ApplyKits(name);
}
[HttpPost]
public void Logout(string name)
{
_accountAdministrator.Logout(name);
}
[HttpPost]
public ActionResult AccountExists(string name)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.AccountExists(name));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult GetMatches(string name)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.GetAllAccountNamesMatching(name));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult Punish(PunishToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.Punish(token).ToString());
return Content(json, "application/json");
}
[HttpPost]
public ActionResult RemovePunishment(RemovePunishmentToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.RemovePunishment(token).ToString());
return Content(json, "application/json");
}
[HttpPost]
public void RemoveBan(RemovePunishmentToken token)
{
_accountAdministrator.RemoveBan(token);
}
[HttpPost]
public void Ignore(ClientIgnoreToken token)
{
_accountAdministrator.Ignore(token.Name, token.IgnoredPlayer);
}
[HttpPost]
public void RemoveIgnore(ClientIgnoreToken token)
{
_accountAdministrator.RemoveIgnore(token.Name, token.IgnoredPlayer);
}
[HttpPost]
public void SaveCustomBuild(CustomBuildToken token)
{
_accountAdministrator.SaveCustomBuild(token);
}
[HttpPost]
public void UpdateAccountUUIDs(List<AccountNameToken> tokens)
{
_accountAdministrator.UpdateAccountUUIDs(tokens);
}
[HttpPost]
public ActionResult GetAccounts(AccountBatchToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.GetAccounts(token));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult GemReward(GemRewardToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.GemReward(token));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult CoinReward(GemRewardToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.CoinReward(token));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult RankUpdate(RankUpdateToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.UpdateRank(token));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult GetPunishClient(string name)
{
var json = JsonConvert.SerializeObject(new ClientToken(_accountAdministrator.GetAccountByName(name)));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult GetAdminPunishments(string name)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.GetAdminPunishments(name));
return Content(json, "application/json");
}
}
}

View File

@ -0,0 +1,36 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
using Common;
using Common.Models;
using Core;
using Core.Model.Account;
public class ProfileController : Controller
{
private readonly IAccountAdministrator _accountAdministrator;
public ProfileController(IAccountAdministrator accountAdministrator)
{
_accountAdministrator = accountAdministrator;
}
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Index(string name)
{
Account account = _accountAdministrator.GetAccountByName(name);
if (account != null)
{
return View(account);
}
return RedirectToAction("Error");
}
public ActionResult Error()
{
return View();
}
}
}

View File

@ -0,0 +1,42 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
public class PurchaseController : Controller
{
public ActionResult SinglePack(string id)
{
return Redirect(@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3426KNUNF6Z3S&on1=Name&os1=" + id);
}
public ActionResult DoublePack(string id)
{
return Redirect(@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G7BJ3LUJ5HDE6&on1=Name&os1=" + id);
}
public ActionResult MegaPack(string id)
{
return Redirect(@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AM33KJ2DW5RSS&on1=Name&os1=" + id);
}
public ActionResult UltraPack(string id)
{
return Redirect(@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AE478DQAV9EYL&on1=Name&os1=" + id);
}
public ActionResult TruckLoad(string id)
{
return Redirect(@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YP6RBNHQ5XAWJ&on1=Name&os1=" + id);
}
public ActionResult SilverRank(string id)
{
return Redirect(@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=S4VKBM7BB4CP2&on1=Name&os1=" + id);
}
public ActionResult GoldRank(string id)
{
return Redirect(@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MBQUM7FMGZ9UN&on1=Name&os1=" + id);
}
}
}

View File

@ -0,0 +1,49 @@
namespace LOC.Website.Web.Controllers
{
using System.Collections.Generic;
using System.Web.Mvc;
using Common.Models;
using Core.Model.PvpServer;
using Core.Model.Server.PvpServer;
using Newtonsoft.Json;
public abstract class PvpController : Controller
{
protected abstract IPvpAdministrator GetAdministrator();
[HttpPost]
public ContentResult GetItems(List<Item> items)
{
var json = JsonConvert.SerializeObject(GetAdministrator().GetItems(items));
return Content(json, "application/json");
}
[HttpPost]
public ContentResult GetSkills(List<Skill> skills)
{
var json = JsonConvert.SerializeObject(GetAdministrator().GetSkills(skills));
return Content(json, "application/json");
}
[HttpPost]
public ContentResult GetWeapons(List<Weapon> weapons)
{
var json = JsonConvert.SerializeObject(GetAdministrator().GetWeapons(weapons));
return Content(json, "application/json");
}
[HttpPost]
public ContentResult GetClasses(List<PvpClass> pvpClasses)
{
var json = JsonConvert.SerializeObject(GetAdministrator().GetPvpClasses(pvpClasses));
return Content(json, "application/json");
}
[HttpPost]
public ContentResult GetBenefitItems(List<BenefitItem> benefitItems)
{
var json = JsonConvert.SerializeObject(GetAdministrator().GetBenefitItems(benefitItems));
return Content(json, "application/json");
}
}
}

View File

@ -0,0 +1,39 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
using Common.Models;
using Core.Model.GameServer;
using Newtonsoft.Json;
public class ServerController : Controller
{
private readonly IServerAdministrator _serverAdministrator;
public ServerController(IServerAdministrator serverAdministrator)
{
_serverAdministrator = serverAdministrator;
}
[HttpPost]
public void Start(Server server)
{
_serverAdministrator.Started(server);
}
[HttpPost]
public ActionResult GetFilteredWords()
{
var json = JsonConvert.SerializeObject(_serverAdministrator.GetFilteredWords());
return Content(json, "application/json");
}
[HttpPost]
public ActionResult CheckForUpdates(ServerHistory server)
{
_serverAdministrator.UpdateServerStatus(server);
var serverUpdates = _serverAdministrator.GetServerUpdates(server.ServerId);
var json = JsonConvert.SerializeObject(serverUpdates);
return Content(json, "application/json");
}
}
}

View File

@ -0,0 +1,28 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
using Common;
using Newtonsoft.Json;
public class ServersController : Controller
{
[HttpPost]
public void RegisterServer(string address)
{
ServerStatusManager.Instance.RegisterServer(address);
}
[HttpPost]
public void RemoveServer(string address)
{
ServerStatusManager.Instance.RemoveServer(address);
}
[HttpPost]
public ActionResult GetServers()
{
var json = JsonConvert.SerializeObject(ServerStatusManager.Instance.GetServers());
return Content(json, "application/json");
}
}
}

View File

@ -0,0 +1,15 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
using Common.Models;
public class StatsController : Controller
{
private readonly IDominateAdministrator _dominateAdministrator;
public StatsController(IDominateAdministrator dominateAdministrator)
{
_dominateAdministrator = dominateAdministrator;
}
}
}

View File

@ -0,0 +1,29 @@
namespace LOC.Website.Web.Controllers
{
using System.Linq;
using System.Web.Mvc;
using Newtonsoft.Json;
using ViewModels;
public class StoreController : Controller
{
private readonly IStoreViewModel _storeModel;
public StoreController(IStoreViewModel storeModel)
{
_storeModel = storeModel;
}
[HttpPost]
public ActionResult GetSalesPackages()
{
var json = JsonConvert.SerializeObject(_storeModel.SalesPackages.Where(x => !x.Test).ToList());
return Content(json, "application/json");
}
public ActionResult Index()
{
return View(_storeModel.SalesPackages.Where(x => !x.Test).ToList());
}
}
}

View File

@ -0,0 +1,12 @@
namespace LOC.Website.Web.Controllers
{
using System.Web.Mvc;
public class VoteController : Controller
{
public ActionResult Index()
{
return Redirect(@"http://minecraftservers.org/server/31063");
}
}
}