Initial Commit

This commit is contained in:
2021-08-23 21:50:46 -04:00
commit ddc0eaa0f9
122 changed files with 62616 additions and 0 deletions

26
Pages/Error.cshtml Normal file
View File

@ -0,0 +1,26 @@
@page
@model ErrorModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

32
Pages/Error.cshtml.cs Normal file
View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
namespace NightmareCoreWeb2.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _logger;
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}

110
Pages/Index.cshtml Normal file
View File

@ -0,0 +1,110 @@
@page
@model IndexModel
@{
ViewData["Title"] = "WotDN";
}
<!-- Sidebar -->
<div class="bg-light border-right" id="sidebar-wrapper">
<div class="list-group list-group-flush">
<form action="?handler=RequestToken" class="list-group-item list-group-item-action bg-light" method="post" enctype="multipart/form-data">
Request an Acount Token:
<div class="form-group">
<label for="RequestTokenEmail">Email: </label>
<input asp-for="RequestTokenEmail" type="text" name="RequestTokenEmail" id="RequestTokenEmail">
</div>
@Html.AntiForgeryToken()
<input class="button" type="submit" value="Request Token" name="authenticate">
</form>
<form action="?handler=ActivateAccount" class="list-group-item list-group-item-action bg-light" method="post" enctype="multipart/form-data">
Activate Account:
<div class="form-group">
<label for="ActivateEmail">E-mail:</label>
<input asp-for="ActivateEmail" type="text" id="ActivateEmail" />
</div>
<div class="form-group">
<label for="ActivatePassword">Password:</label>
<input asp-for="ActivatePassword" type="password" id="ActivatePassword">
</div>
<div class="form-group">
<label for="ActivateToken">Token:</label>
<input asp-for="ActivateToken" type="text" id="ActivateToken">
</div>
<input class="button" value="Activate Account" type="submit">
@Html.AntiForgeryToken()
</form>
<div class="list-group-item list-group-item-action bg-light">
<table>
<tr>
<td>Realms</td>
<td>online: </td>
</tr>
@foreach(var k in Model.Realms) {
<tr>
<td>@k.Value</td>
<td>@k.Key</td>
</tr>
}
</table>
</div>
<div class="list-group-item list-group-item-action bg-light">
<a href="https://wow.gamepedia.com/Realmlist.wtf">Realmlist:</a><br>
<code>wotdn.nightmare.haus</code>
</div>
<div class="list-group-item list-group-item-action bg-light">
<a href="/vendor/WotDN.tgz">Download Windows Client Here</a><br>
<a href="/vendor/WotDN.app">Download macOS Client Here</a><br>
</div>
<br>
</div>
</div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<h1 class="mt-4">@Model.CharacterListType</h1>
<table class="table table-striped table-dark" >
<thead class="thead-dark">
<tr>
<th scope="col">Player</th>
<th scope="col">Character</th>
<th scope="col">Level</th>
<th scope="col">Race</th>
<th scope="col">Class</th>
</tr>
</thead>
<tbody>
@foreach (var character in Model.OnlineCharacters) {
<tr>
<td>@character.Username</td>
<td>@character.Name</td>
<td>@character.Level</td>
<td>@character.GetRace()</td>
<td>@character.GetClass()</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<!-- /#wrapper -->
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Menu Toggle Script -->
<script>
$("#menu-toggle").click(function (e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
</script>

94
Pages/Index.cshtml.cs Normal file
View File

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
namespace NightmareCoreWeb2.Pages
{
public class IndexModel : PageModel
{
string connStr = $"server={Program.MysqlServer};user={Program.MysqlUser};database={Program.MysqlDatabase};port={Program.MysqlPort};password={Program.MysqlPassword}";
public List<Character> OnlineCharacters = new List<Character>();
public Dictionary<string, string> Realms = new Dictionary<string, string>();
public string ActivateEmail {get; set;}
public string ActivatePassword {get; set;}
public string ActivateToken {get; set;}
public string RequestTokenEmail {get; set;}
public string CharacterListType {get; set;}
private MySqlConnection conn;
private readonly ILogger<IndexModel> _logger;
public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
conn = new MySqlConnection(connStr);
try
{
conn.Open();
string sql = "select username,name,level,race,class from characters.characters join auth.account on characters.characters.account = auth.account.id where characters.characters.online = 1";
MySqlCommand cmd = new MySqlCommand(sql, conn);
MySqlDataReader rdr = cmd.ExecuteReader();
CharacterListType = "Online Players";
while (rdr.Read())
{
Character c = new Character();
c.Username = rdr.GetString(0);
c.Name = rdr.GetString(1);
c.Level = rdr.GetByte(2);
c.Race = rdr.GetByte(3);
c.Class = rdr.GetByte(4);
OnlineCharacters.Add(c);
}
rdr.Close();
sql = "SELECT name,flag FROM realmlist";
cmd = new MySqlCommand(sql, conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Realms.Add(rdr.GetString(0), rdr.GetString(1).Equals("2") ? "❌" : "✔️");
}
rdr.Close();
conn.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
public void OnGet() {}
public void OnGetAccount(string name) {
Account a = new Account(name, conn);
CharacterListType = $"{name}'s Characters";
OnlineCharacters = a.characters;
}
public void OnPostActivateAccount() {
ActivateEmail = Request.Form["ActivateEmail"];
ActivatePassword = Request.Form["ActivatePassword"];
ActivateToken = Request.Form["ActivateToken"];
Console.WriteLine($"PostActivateAccount e {ActivateEmail} p {ActivatePassword} t {ActivateToken}");
}
public void OnPostRequestToken() {
RequestTokenEmail = Request.Form["RequestTokenEmail"];
}
public bool RequestToken() {
return false;
}
public bool CreateAccount() {
return false;
}
public bool IsTokenValid(string username, string token) {
return false;
}
}
}

8
Pages/Privacy.cshtml Normal file
View File

@ -0,0 +1,8 @@
@page
@model PrivacyModel
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

24
Pages/Privacy.cshtml.cs Normal file
View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
namespace NightmareCoreWeb2.Pages
{
public class PrivacyModel : PageModel
{
private readonly ILogger<PrivacyModel> _logger;
public PrivacyModel(ILogger<PrivacyModel> logger)
{
_logger = logger;
}
public void OnGet()
{
}
}
}

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - NightmareCoreWeb2</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index">Wrath of the DogNet</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<main role="main" class="d-flex">
@RenderBody()
</main>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2021 - NightmareCoreWeb2 - <a asp-area="" asp-page="/Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@ -0,0 +1,3 @@
@using NightmareCoreWeb2
@namespace NightmareCoreWeb2.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

3
Pages/_ViewStart.cshtml Normal file
View File

@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}