diff --git a/ServerMaint/Program.cs b/ServerMaint/Program.cs index f7a2612..0ab5c17 100644 --- a/ServerMaint/Program.cs +++ b/ServerMaint/Program.cs @@ -8,7 +8,7 @@ using System.Net; using System.Net.Mail; using System.Reflection; using System.Text; -using Teknik.Areas.Transparency.Models; +using Teknik.Areas.Status.Models; using Teknik.Areas.Upload.Models; using Teknik.Areas.Users.Models; using Teknik.Areas.Users.Utility; diff --git a/Teknik/Areas/Status/Controllers/StatusController.cs b/Teknik/Areas/Status/Controllers/StatusController.cs index 6615a27..4a59b90 100644 --- a/Teknik/Areas/Status/Controllers/StatusController.cs +++ b/Teknik/Areas/Status/Controllers/StatusController.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using System.Web; using System.Web.Mvc; +using Teknik.Areas.Status.Models; using Teknik.Areas.Status.ViewModels; using Teknik.Attributes; using Teknik.Controllers; @@ -24,12 +25,13 @@ namespace Teknik.Areas.Status.Controllers [AllowAnonymous] public ActionResult Index() { - ViewBag.Title = "Status Information - " + Config.Title; + ViewBag.Title = "System Status - " + Config.Title; ViewBag.Description = "Current status information for the server and resources."; StatusViewModel model = new StatusViewModel(); // Load initial status info + #region Statistics Upload.Models.Upload upload = db.Uploads.OrderByDescending(u => u.UploadId).FirstOrDefault(); model.UploadCount = (upload != null) ? upload.UploadId : 0; model.UploadSize = (upload != null) ? db.Uploads.Sum(u => (long)u.ContentLength) : 0; @@ -45,6 +47,116 @@ namespace Teknik.Areas.Status.Controllers Vault.Models.Vault vault = db.Vaults.OrderByDescending(v => v.VaultId).FirstOrDefault(); model.VaultCount = (url != null) ? vault.VaultId : 0; + #endregion + + // Get Transaction Inforomation + #region Transactions + DateTime curTime = DateTime.Now; + + var billSums = db.Transactions.OfType().GroupBy(b => new { b.Currency, b.DateSent.Month, b.DateSent.Year}).Select(b => new { month = b.Key.Month, year = b.Key.Year, currency = b.Key.Currency, total = b.Sum(c => c.Amount) }).ToList(); + foreach (var sum in billSums) + { + decimal exchangeRate = CurrencyHelper.GetExchangeRate(sum.currency); + decimal realValue = sum.total * exchangeRate; + model.Transactions.TotalBills += realValue; + model.Transactions.TotalNet += realValue; + if (curTime.Month == sum.month && curTime.Year == sum.year) + { + model.Transactions.CurrentMonthBills += Math.Abs(realValue); + } + } + + var oneSums = db.Transactions.OfType().GroupBy(b => new { b.Currency, b.DateSent.Month, b.DateSent.Year }).Select(b => new { month = b.Key.Month, year = b.Key.Year, currency = b.Key.Currency, total = b.Sum(c => c.Amount) }).ToList(); + foreach (var sum in oneSums) + { + decimal exchangeRate = CurrencyHelper.GetExchangeRate(sum.currency); + decimal realValue = sum.total * exchangeRate; + model.Transactions.TotalOneTimes += realValue; + model.Transactions.TotalNet += realValue; + if (curTime.Month == sum.month && curTime.Year == sum.year) + { + model.Transactions.CurrentMonthBills += Math.Abs(realValue); + } + } + + var donationSums = db.Transactions.OfType().GroupBy(b => new { b.Currency, b.DateSent.Month, b.DateSent.Year }).Select(b => new { month = b.Key.Month, year = b.Key.Year, currency = b.Key.Currency, total = b.Sum(c => c.Amount) }).ToList(); + foreach (var sum in donationSums) + { + decimal exchangeRate = CurrencyHelper.GetExchangeRate(sum.currency); + decimal realValue = sum.total * exchangeRate; + model.Transactions.TotalDonations += realValue; + model.Transactions.TotalNet += realValue; + if (curTime.Month == sum.month && curTime.Year == sum.year) + { + model.Transactions.CurrentMonthIncome += Math.Abs(realValue); + } + } + + List bills = db.Transactions.OfType().OrderByDescending(b => b.DateSent).ToList(); + if (bills != null) + { + foreach (Bill bill in bills) + { + BillViewModel billModel = new BillViewModel(); + billModel.Amount = bill.Amount; + billModel.Currency = bill.Currency; + billModel.Reason = bill.Reason; + billModel.DateSent = bill.DateSent; + billModel.Recipient = bill.Recipient; + model.Transactions.Bills.Add(billModel); + } + } + + List oneTimes = db.Transactions.OfType().OrderByDescending(b => b.DateSent).ToList(); + if (oneTimes != null) + { + foreach (OneTime oneTime in oneTimes) + { + OneTimeViewModel oneTimeModel = new OneTimeViewModel(); + oneTimeModel.Amount = oneTime.Amount; + oneTimeModel.Currency = oneTime.Currency; + oneTimeModel.Reason = oneTime.Reason; + oneTimeModel.DateSent = oneTime.DateSent; + oneTimeModel.Recipient = oneTime.Recipient; + model.Transactions.OneTimes.Add(oneTimeModel); + } + } + + List donations = db.Transactions.OfType().OrderByDescending(b => b.DateSent).ToList(); + if (donations != null) + { + foreach (Donation donation in donations) + { + DonationViewModel donationModel = new DonationViewModel(); + donationModel.Amount = donation.Amount; + donationModel.Currency = donation.Currency; + donationModel.Reason = donation.Reason; + donationModel.DateSent = donation.DateSent; + donationModel.Sender = donation.Sender; + model.Transactions.Donations.Add(donationModel); + } + } + #endregion + + // Takedown information + #region Takedowns + List takedowns = db.Takedowns.OrderByDescending(b => b.DateRequested).ToList(); + if (takedowns != null) + { + foreach (Takedown takedown in takedowns) + { + TakedownViewModel takedownModel = new TakedownViewModel(); + takedownModel.Requester = takedown.Requester; + takedownModel.RequesterContact = takedown.RequesterContact; + takedownModel.Reason = takedown.Reason; + takedownModel.ActionTaken = takedown.ActionTaken; + takedownModel.DateRequested = takedown.DateRequested; + takedownModel.DateActionTaken = takedown.DateActionTaken; + + model.Takedowns.Add(takedownModel); + } + } + #endregion return View(model); } diff --git a/Teknik/Areas/Transparency/Models/Bill.cs b/Teknik/Areas/Status/Models/Bill.cs similarity index 83% rename from Teknik/Areas/Transparency/Models/Bill.cs rename to Teknik/Areas/Status/Models/Bill.cs index 3e322e9..0e5c0a6 100644 --- a/Teknik/Areas/Transparency/Models/Bill.cs +++ b/Teknik/Areas/Status/Models/Bill.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Teknik.Areas.Transparency.Models +namespace Teknik.Areas.Status.Models { public class Bill : Transaction { diff --git a/Teknik/Areas/Transparency/Models/Donation.cs b/Teknik/Areas/Status/Models/Donation.cs similarity index 83% rename from Teknik/Areas/Transparency/Models/Donation.cs rename to Teknik/Areas/Status/Models/Donation.cs index 18e34e2..7fc3981 100644 --- a/Teknik/Areas/Transparency/Models/Donation.cs +++ b/Teknik/Areas/Status/Models/Donation.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Teknik.Areas.Transparency.Models +namespace Teknik.Areas.Status.Models { public class Donation : Transaction { diff --git a/Teknik/Areas/Transparency/Models/OneTime.cs b/Teknik/Areas/Status/Models/OneTime.cs similarity index 83% rename from Teknik/Areas/Transparency/Models/OneTime.cs rename to Teknik/Areas/Status/Models/OneTime.cs index 274b53d..dda070c 100644 --- a/Teknik/Areas/Transparency/Models/OneTime.cs +++ b/Teknik/Areas/Status/Models/OneTime.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Teknik.Areas.Transparency.Models +namespace Teknik.Areas.Status.Models { public class OneTime : Transaction { diff --git a/Teknik/Areas/Transparency/Models/Takedown.cs b/Teknik/Areas/Status/Models/Takedown.cs similarity index 93% rename from Teknik/Areas/Transparency/Models/Takedown.cs rename to Teknik/Areas/Status/Models/Takedown.cs index 096f24c..95dc8a3 100644 --- a/Teknik/Areas/Transparency/Models/Takedown.cs +++ b/Teknik/Areas/Status/Models/Takedown.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Teknik.Areas.Transparency.Models +namespace Teknik.Areas.Status.Models { public class Takedown { diff --git a/Teknik/Areas/Transparency/Models/Transaction.cs b/Teknik/Areas/Status/Models/Transaction.cs similarity index 66% rename from Teknik/Areas/Transparency/Models/Transaction.cs rename to Teknik/Areas/Status/Models/Transaction.cs index 455f985..6236121 100644 --- a/Teknik/Areas/Transparency/Models/Transaction.cs +++ b/Teknik/Areas/Status/Models/Transaction.cs @@ -3,16 +3,17 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Teknik.Utilities; -namespace Teknik.Areas.Transparency.Models +namespace Teknik.Areas.Status.Models { public class Transaction { public int TransactionId { get; set; } - public double Amount { get; set; } + public decimal Amount { get; set; } - public string Currency { get; set; } + public CurrencyType Currency { get; set; } public string Reason { get; set; } diff --git a/Teknik/Areas/Status/Scripts/Status.js b/Teknik/Areas/Status/Scripts/Status.js index 0290e34..a8603a6 100644 --- a/Teknik/Areas/Status/Scripts/Status.js +++ b/Teknik/Areas/Status/Scripts/Status.js @@ -3,6 +3,11 @@ var memUsageChart; var networkUsageChart; $(document).ready(function () { + $('#bills-section').collapse('hide'); + $('#oneTime-section').collapse('hide'); + $('#donations-section').collapse('hide'); + $('#takedowns-section').collapse('hide'); + /* ---------------------------------------- CPU Usage -----------------------------------------*/ @@ -22,11 +27,13 @@ $(document).ready(function () { }, yAxis: { title: { - text: 'Percentage %' + text: 'Percentage' }, max: 100, min: 0, - format: '{value}', + labels: { + format: '{value}%' + }, plotLines: [{ value: 0, width: 1, @@ -38,6 +45,9 @@ $(document).ready(function () { crosshairs: true, pointFormat: '\u25CF {series.name}: {point.y:.2f}%
' }, + credits: { + enabled: false + }, series: [ { name: 'Total', @@ -98,6 +108,9 @@ $(document).ready(function () { return '\u25CF ' + this.series.name + ': ' + yVal + '
'; } }, + credits: { + enabled: false + }, series: [ { name: 'Total', @@ -156,6 +169,9 @@ $(document).ready(function () { return '\u25CF ' + this.series.name + ': ' + yVal + '
'; } }, + credits: { + enabled: false + }, series: [ { name: 'Sent', @@ -173,7 +189,9 @@ $(document).ready(function () { -----------------------------------------*/ visitChart = new Highcharts.chart({ chart: { - renderTo: 'visitor-chart' + renderTo: 'visitor-chart', + type: 'line', + marginRight: 10 }, title: { text: 'Daily Visitors' @@ -199,6 +217,9 @@ $(document).ready(function () { headerFormat: '{point.key:%B %e, %Y}
', pointFormat: '\u25CF {series.name}: {point.y}
' }, + credits: { + enabled: false + }, series: [ { name: 'All Visitors', @@ -260,8 +281,9 @@ $(document).ready(function () { url: getVisitorDataURL, success: function (response) { if (response.result) { - visitChart.series[0].setData(response.result.totalVisitors); - visitChart.series[1].setData(response.result.uniqueVisitors); + visitChart.series[0].setData(response.result.totalVisitors, false); + visitChart.series[1].setData(response.result.uniqueVisitors, false); + visitChart.redraw(); } else { var err = response; @@ -274,4 +296,9 @@ $(document).ready(function () { } }); } + + // Resize the chart when viewing the tab (initial width is wrong due to chart being hidden) + $('a[href="#site-stats"]').on('shown.bs.tab', function (e) { + visitChart.setSize($('#visitor-chart').width(), $('#visitor-chart').height()); + }) }); \ No newline at end of file diff --git a/Teknik/Areas/Status/ViewModels/BillViewModel.cs b/Teknik/Areas/Status/ViewModels/BillViewModel.cs new file mode 100644 index 0000000..a45bdd7 --- /dev/null +++ b/Teknik/Areas/Status/ViewModels/BillViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Teknik.ViewModels; + +namespace Teknik.Areas.Status.ViewModels +{ + public class BillViewModel : TransactionViewModel + { + public string Recipient { get; set; } + } +} \ No newline at end of file diff --git a/Teknik/Areas/Status/ViewModels/DonationViewModel.cs b/Teknik/Areas/Status/ViewModels/DonationViewModel.cs new file mode 100644 index 0000000..c5dffd7 --- /dev/null +++ b/Teknik/Areas/Status/ViewModels/DonationViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Teknik.ViewModels; + +namespace Teknik.Areas.Status.ViewModels +{ + public class DonationViewModel : TransactionViewModel + { + public string Sender { get; set; } + } +} \ No newline at end of file diff --git a/Teknik/Areas/Status/ViewModels/OneTimeViewModel.cs b/Teknik/Areas/Status/ViewModels/OneTimeViewModel.cs new file mode 100644 index 0000000..8144f84 --- /dev/null +++ b/Teknik/Areas/Status/ViewModels/OneTimeViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Teknik.ViewModels; + +namespace Teknik.Areas.Status.ViewModels +{ + public class OneTimeViewModel : TransactionViewModel + { + public string Recipient { get; set; } + } +} \ No newline at end of file diff --git a/Teknik/Areas/Status/ViewModels/StatusViewModel.cs b/Teknik/Areas/Status/ViewModels/StatusViewModel.cs index 05da0be..746191a 100644 --- a/Teknik/Areas/Status/ViewModels/StatusViewModel.cs +++ b/Teknik/Areas/Status/ViewModels/StatusViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Web; +using Teknik.Areas.Status.Models; using Teknik.Models; using Teknik.ViewModels; @@ -21,6 +22,10 @@ namespace Teknik.Areas.Status.ViewModels public int VaultCount { get; set; } + public TransactionsViewModel Transactions { get; set; } + + public List Takedowns { get; set; } + public StatusViewModel() { UploadCount = 0; @@ -29,6 +34,8 @@ namespace Teknik.Areas.Status.ViewModels UserCount = 0; ShortenedUrlCount = 0; VaultCount = 0; + Transactions = new TransactionsViewModel(); + Takedowns = new List(); } } } \ No newline at end of file diff --git a/Teknik/Areas/Status/ViewModels/TakedownViewModel.cs b/Teknik/Areas/Status/ViewModels/TakedownViewModel.cs new file mode 100644 index 0000000..89c7e99 --- /dev/null +++ b/Teknik/Areas/Status/ViewModels/TakedownViewModel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Teknik.ViewModels; + +namespace Teknik.Areas.Status.ViewModels +{ + public class TakedownViewModel : ViewModelBase + { + public string Requester { get; set; } + + public string RequesterContact { get; set; } + + public string Reason { get; set; } + + public string ActionTaken { get; set; } + + public DateTime DateRequested { get; set; } + + public DateTime DateActionTaken { get; set; } + + public virtual ICollection Attachments { get; set; } + } +} \ No newline at end of file diff --git a/Teknik/Areas/Status/ViewModels/TransactionViewModel.cs b/Teknik/Areas/Status/ViewModels/TransactionViewModel.cs new file mode 100644 index 0000000..08595e9 --- /dev/null +++ b/Teknik/Areas/Status/ViewModels/TransactionViewModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Teknik.Areas.Status.Models; +using Teknik.Utilities; +using Teknik.ViewModels; + +namespace Teknik.Areas.Status.ViewModels +{ + public class TransactionViewModel : ViewModelBase + { + public decimal Amount { get; set; } + + public CurrencyType Currency { get; set; } + + public string Reason { get; set; } + + public DateTime DateSent { get; set; } + } +} \ No newline at end of file diff --git a/Teknik/Areas/Status/ViewModels/TransactionsViewModel.cs b/Teknik/Areas/Status/ViewModels/TransactionsViewModel.cs new file mode 100644 index 0000000..486b33d --- /dev/null +++ b/Teknik/Areas/Status/ViewModels/TransactionsViewModel.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Teknik.ViewModels; + +namespace Teknik.Areas.Status.ViewModels +{ + public class TransactionsViewModel : ViewModelBase + { + public decimal CurrentMonthBills { get; set; } + + public decimal CurrentMonthIncome { get; set; } + + public decimal TotalBills { get; set; } + + public decimal TotalOneTimes { get; set; } + + public decimal TotalDonations { get; set; } + + public decimal TotalNet { get; set; } + + public List Bills { get; set; } + + public List OneTimes { get; set; } + + public List Donations { get; set; } + + public TransactionsViewModel() + { + TotalBills = 0; + TotalOneTimes = 0; + TotalDonations = 0; + TotalNet = 0; + Bills = new List(); + OneTimes = new List(); + Donations = new List(); + } + } +} \ No newline at end of file diff --git a/Teknik/Areas/Status/Views/Status/Bills.cshtml b/Teknik/Areas/Status/Views/Status/Bills.cshtml new file mode 100644 index 0000000..445ca52 --- /dev/null +++ b/Teknik/Areas/Status/Views/Status/Bills.cshtml @@ -0,0 +1,35 @@ +@model List + +@using Teknik.Areas.Status.ViewModels + +@if (Model != null && Model.Any()) +{ +
+
+

Bills

+
+
+ +
+
+
+
+ + + + + + + @foreach (BillViewModel bill in Model) + { + + + + + + } +
DateAmountDescription
@bill.DateSent.ToString("MMMM dd, yyyy")@bill.Amount @bill.Currency.ToString()@bill.Reason
+
+
+
+} diff --git a/Teknik/Areas/Status/Views/Status/Donations.cshtml b/Teknik/Areas/Status/Views/Status/Donations.cshtml new file mode 100644 index 0000000..be87b83 --- /dev/null +++ b/Teknik/Areas/Status/Views/Status/Donations.cshtml @@ -0,0 +1,37 @@ +@model List + +@using Teknik.Areas.Status.ViewModels + +@if (Model != null && Model.Any()) +{ +
+
+

Donations

+
+
+ +
+
+
+
+ + + + + + + + @foreach (DonationViewModel donation in Model) + { + + + + + + + } +
DateAmountDonorReason for Donation
@donation.DateSent.ToString("MMMM dd, yyyy")@donation.Amount @donation.Currency.ToString()@donation.Sender@donation.Reason
+
+
+
+} diff --git a/Teknik/Areas/Status/Views/Shared/Index.cshtml b/Teknik/Areas/Status/Views/Status/Index.cshtml similarity index 71% rename from Teknik/Areas/Status/Views/Shared/Index.cshtml rename to Teknik/Areas/Status/Views/Status/Index.cshtml index 8ba51bb..16ed311 100644 --- a/Teknik/Areas/Status/Views/Shared/Index.cshtml +++ b/Teknik/Areas/Status/Views/Status/Index.cshtml @@ -1,7 +1,7 @@ @model Teknik.Areas.Status.ViewModels.StatusViewModel @using Teknik.Utilities -@using Newtonsoft.Json +@using Teknik.Areas.Status.Models @Scripts.Render("~/bundles/signalr") @Scripts.Render("~/signalr/hubs") @@ -20,9 +20,16 @@
@if (Model.Config.StatusConfig.Enabled) { -
-
-

Realtime Usage

+ + +
+
+

Realtime Server Usage


@@ -40,11 +47,8 @@
-
-
-
-
-

Statistics

+
+

Site Statistics


@if (Model.Config.PiwikConfig.Enabled) { @@ -53,7 +57,6 @@
-
}
@@ -80,6 +83,13 @@

Number of Users: @Model.UserCount

+ +
+
+ @Html.Partial("~/Areas/Status/Views/Status/Transactions.cshtml", Model.Transactions) +
+
+ @Html.Partial("~/Areas/Status/Views/Status/Takedowns.cshtml", Model.Takedowns)
} diff --git a/Teknik/Areas/Status/Views/Status/OneTimes.cshtml b/Teknik/Areas/Status/Views/Status/OneTimes.cshtml new file mode 100644 index 0000000..ae71dc2 --- /dev/null +++ b/Teknik/Areas/Status/Views/Status/OneTimes.cshtml @@ -0,0 +1,35 @@ +@model List + +@using Teknik.Areas.Status.ViewModels + +@if (Model != null && Model.Any()) +{ +
+
+

One Time Payments

+
+
+ +
+
+
+
+ + + + + + + @foreach (OneTimeViewModel oneTime in Model) + { + + + + + + } +
DateAmountReason for Payment
@oneTime.DateSent.ToString("MMMM dd, yyyy")@oneTime.Amount @oneTime.Currency.ToString()@oneTime.Reason
+
+
+
+} \ No newline at end of file diff --git a/Teknik/Areas/Status/Views/Status/Takedowns.cshtml b/Teknik/Areas/Status/Views/Status/Takedowns.cshtml new file mode 100644 index 0000000..023c43a --- /dev/null +++ b/Teknik/Areas/Status/Views/Status/Takedowns.cshtml @@ -0,0 +1,37 @@ +@model List + +@using Teknik.Areas.Status.ViewModels + +@if (Model != null && Model.Any()) +{ +
+
+

Takedowns

+
+ @if (Model != null && Model.Any()) + { + + + + + + + + + + @foreach (TakedownViewModel takedown in Model) + { + + + + + + + + + } +
RequesterContactDate RequestedDate Of ActionReasonAction Taken
@takedown.Requester@takedown.RequesterContact@takedown.DateRequested.ToString("MMMM dd, yyyy")@takedown.DateActionTaken.ToString("MMMM dd, yyyy")@takedown.Reason@takedown.ActionTaken
+ } +
+
+} \ No newline at end of file diff --git a/Teknik/Areas/Status/Views/Status/Transactions.cshtml b/Teknik/Areas/Status/Views/Status/Transactions.cshtml new file mode 100644 index 0000000..994571b --- /dev/null +++ b/Teknik/Areas/Status/Views/Status/Transactions.cshtml @@ -0,0 +1,60 @@ +@model Teknik.Areas.Status.ViewModels.TransactionsViewModel + +@using Teknik.Areas.Status.ViewModels + +@{ + decimal totalBills = Model.CurrentMonthBills; + decimal totalIncome = Model.CurrentMonthIncome; + int incomePercentage = 100; + if (totalIncome != 0 && totalBills != 0) + { + incomePercentage = (int)Math.Max((Math.Floor(totalBills / totalIncome) * 100), 100); + } + + string processStyle = "progress-bar progress-bar-success"; + if (incomePercentage < 100) + { + processStyle += " progress-bar-striped"; + } +} + +
+
+

Transactions

+
+
+
+

Monthly Donation Target

+
+
+
+
+
$@totalIncome Donated / $@totalBills Bills
+
+
+
+

Transaction Totals

+
+
+

Donations

+

$@Math.Round(Model.TotalDonations, 2)

+
+
+

Bills

+

$@Math.Round(Model.TotalBills, 2)

+
+
+

One-Time Payments

+

$@Math.Round(Model.TotalOneTimes, 2)

+
+
+

Net Profit

+

$@Math.Round(Model.TotalNet, 2)

+
+
+
+
+ +@Html.Partial("~/Areas/Status/Views/Status/Bills.cshtml", Model.Bills) +@Html.Partial("~/Areas/Status/Views/Status/OneTimes.cshtml", Model.OneTimes) +@Html.Partial("~/Areas/Status/Views/Status/Donations.cshtml", Model.Donations) \ No newline at end of file diff --git a/Teknik/Areas/Transparency/Controllers/TransparencyController.cs b/Teknik/Areas/Transparency/Controllers/TransparencyController.cs deleted file mode 100644 index 2669d91..0000000 --- a/Teknik/Areas/Transparency/Controllers/TransparencyController.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using Teknik.Areas.Transparency.Models; -using Teknik.Areas.Transparency.ViewModels; -using Teknik.Attributes; -using Teknik.Controllers; -using Teknik.Filters; -using Teknik.Models; -using Teknik.Piwik; - -namespace Teknik.Areas.Transparency.Controllers -{ - [TeknikAuthorize] - public class TransparencyController : DefaultController - { - private TeknikEntities db = new TeknikEntities(); - - [TrackPageView] - [AllowAnonymous] - public ActionResult Index() - { - ViewBag.Title = "Transparency - " + Config.Title; - ViewBag.Description = "Teknik transparency and statistics."; - TransparencyViewModel model = new TransparencyViewModel(); - - if (Config.TransparencyConfig.Enabled) - { - model.TotalNet = new Dictionary(); - - var billSums = db.Transactions.OfType().GroupBy(b => b.Currency).Select(b => new { currency = b.Key, total = b.Sum(c => c.Amount) }).ToList(); - model.TotalBills = new Dictionary(); - foreach (var sum in billSums) - { - model.TotalBills.Add(sum.currency, sum.total); - if (model.TotalNet.ContainsKey(sum.currency)) - { - model.TotalNet[sum.currency] += sum.total; - } - else - { - model.TotalNet.Add(sum.currency, sum.total); - } - } - - var oneSums = db.Transactions.OfType().GroupBy(b => b.Currency).Select(b => new { currency = b.Key, total = b.Sum(c => c.Amount) }).ToList(); - model.TotalOneTimes = new Dictionary(); - foreach (var sum in oneSums) - { - model.TotalOneTimes.Add(sum.currency, sum.total); - if (model.TotalNet.ContainsKey(sum.currency)) - { - model.TotalNet[sum.currency] += sum.total; - } - else - { - model.TotalNet.Add(sum.currency, sum.total); - } - } - - var donationSums = db.Transactions.OfType().GroupBy(b => b.Currency).Select(b => new { currency = b.Key, total = b.Sum(c => c.Amount) }).ToList(); - model.TotalDonations = new Dictionary(); - foreach (var sum in donationSums) - { - model.TotalDonations.Add(sum.currency, sum.total); - if (model.TotalNet.ContainsKey(sum.currency)) - { - model.TotalNet[sum.currency] += sum.total; - } - else - { - model.TotalNet.Add(sum.currency, sum.total); - } - } - - List bills = db.Transactions.OfType().OrderByDescending(b => b.DateSent).ToList(); - model.Bills = (bills != null) ? bills : new List(); - - List oneTimes = db.Transactions.OfType().OrderByDescending(b => b.DateSent).ToList(); - model.OneTimes = (oneTimes != null) ? oneTimes : new List(); - - List donations = db.Transactions.OfType().OrderByDescending(b => b.DateSent).ToList(); - model.Donations = (donations != null) ? donations : new List(); - - - List takedowns = db.Takedowns.OrderByDescending(b => b.DateRequested).ToList(); - model.Takedowns = (takedowns != null) ? takedowns : new List(); - - // Grab canary file - if (System.IO.File.Exists(Config.TransparencyConfig.CanaryPath)) - { - model.Canary = System.IO.File.ReadAllText(Config.TransparencyConfig.CanaryPath); - } - else - { - model.Canary = string.Empty; - } - } - return View(model); - } - - [HttpGet] - [AllowAnonymous] - public ActionResult GetVisitorData() - { - // Get the data from the Piwik - if (!string.IsNullOrEmpty(Config.PiwikConfig.API)) - { - List dataList = Reporting.GetVisitSummaryByDays(Config, 31); - - List uniqueData = new List(); - List totalData = new List(); - - foreach (VisitorData data in dataList.OrderBy(d => d.Date)) - { - object uniqueDay = new { x = Convert.ToInt64((data.Date.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds), y = data.UniqueVisitors }; - uniqueData.Add(uniqueDay); - object totalDay = new { x = Convert.ToInt64((data.Date.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds), y = data.Visits }; - totalData.Add(totalDay); - } - - return Json(new { result = new { uniqueVisitors = uniqueData.ToArray(), totalVisitors = totalData.ToArray() } }, JsonRequestBehavior.AllowGet); - } - return Json(new { error = new { message = "Piwik not configured" } }, JsonRequestBehavior.AllowGet); - } - } -} \ No newline at end of file diff --git a/Teknik/Areas/Transparency/Scripts/Transparency.js b/Teknik/Areas/Transparency/Scripts/Transparency.js deleted file mode 100644 index 24598cd..0000000 --- a/Teknik/Areas/Transparency/Scripts/Transparency.js +++ /dev/null @@ -1,69 +0,0 @@ -var visitChart; - -$(document).ready(function () { - $('#bills-section').collapse('hide'); - $('#oneTime-section').collapse('hide'); - $('#donations-section').collapse('hide'); - $('#takedowns-section').collapse('hide'); - - visitChart = new Highcharts.chart({ - chart: { - renderTo: 'visitor-chart' - }, - title: { - text: 'Daily Visitors' - }, - xAxis: { - type: 'datetime', - dateTimeLabelFormats: { // don't display the dummy year - month: '%e. %b', - year: '%b' - }, - title: { - text: 'Date' - } - }, - yAxis: { - title: { - text: 'Visitors' - } - }, - tooltip: { - shared: true, - crosshairs: true, - headerFormat: '{point.key:%B %e, %Y}
', - pointFormat: '\u25CF {series.name}: {point.y}
' - }, - series: [ - { - name: 'All Visitors', - data: [] - }, - { - name: 'Unique Visitors', - data: [] - } - ] - }); - - if (statsEnabled) { - $.ajax({ - type: "GET", - url: getVisitorDataURL, - success: function (response) { - if (response.result) { - visitChart.series[0].setData(response.result.totalVisitors); - visitChart.series[1].setData(response.result.uniqueVisitors); - } - else { - var err = response; - if (response.error) { - err = response.error.message; - } - $("#top_msg").css('display', 'inline', 'important'); - $("#top_msg").html('
' + err + '
'); - } - } - }); - } -}); \ No newline at end of file diff --git a/Teknik/Areas/Transparency/TransparencyAreaRegistration.cs b/Teknik/Areas/Transparency/TransparencyAreaRegistration.cs deleted file mode 100644 index 974a6d0..0000000 --- a/Teknik/Areas/Transparency/TransparencyAreaRegistration.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Collections.Generic; -using System.Web.Mvc; -using System.Web.Optimization; -using Teknik.Configuration; -using Teknik.Utilities; - -namespace Teknik.Areas.Transparency -{ - public class TransparencyAreaRegistration : AreaRegistration - { - public override string AreaName - { - get - { - return "Transparency"; - } - } - - public override void RegisterArea(AreaRegistrationContext context) - { - Config config = Config.Load(); - context.MapSubdomainRoute( - "Transparency.Index", - new List() { "transparency" }, // Subdomains - new List() { config.Host }, // domains - "", - new { controller = "Transparency", action = "Index" }, - new[] { typeof(Controllers.TransparencyController).Namespace } - ); - context.MapSubdomainRoute( - "Transparency.Action", - new List() { "transparency" }, // Subdomains - new List() { config.Host }, // domains - "Action/{controller}/{action}", - new { controller = "Transparency", action = "Index" }, - new[] { typeof(Controllers.TransparencyController).Namespace } - ); - - // Register Script Bundle - BundleTable.Bundles.Add(new CdnScriptBundle("~/bundles/transparency", config.CdnHost).Include( - "~/Scripts/Highcharts/highcharts.js", - "~/Areas/Transparency/Scripts/Transparency.js")); - } - } -} \ No newline at end of file diff --git a/Teknik/Areas/Transparency/ViewModels/TransparencyViewModel.cs b/Teknik/Areas/Transparency/ViewModels/TransparencyViewModel.cs deleted file mode 100644 index c520652..0000000 --- a/Teknik/Areas/Transparency/ViewModels/TransparencyViewModel.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Teknik.Areas.Transparency.Models; -using Teknik.ViewModels; - -namespace Teknik.Areas.Transparency.ViewModels -{ - public class TransparencyViewModel : ViewModelBase - { - public string Canary { get; set; } - - public Dictionary TotalBills { get; set; } - - public Dictionary TotalOneTimes { get; set; } - - public Dictionary TotalDonations { get; set; } - - public Dictionary TotalNet { get; set; } - - public List Bills { get; set; } - - public List OneTimes { get; set; } - - public List Donations { get; set; } - - public List Takedowns { get; set; } - } -} diff --git a/Teknik/Areas/Transparency/Views/Transparency/Index.cshtml b/Teknik/Areas/Transparency/Views/Transparency/Index.cshtml deleted file mode 100644 index 6f3cfd7..0000000 --- a/Teknik/Areas/Transparency/Views/Transparency/Index.cshtml +++ /dev/null @@ -1,255 +0,0 @@ -@model Teknik.Areas.Transparency.ViewModels.TransparencyViewModel - -@using Teknik.Utilities -@using Teknik.Areas.Transparency.Models - -@Scripts.Render("~/bundles/transparency") - - - -
- @if (Model.Config.TransparencyConfig.Enabled) - { -
-
-

Behind the Scenes

-
-

- Here you can view all of Teknik's financial information, takedown requests and the actions we took. -

-

- If you would like to request additional information about Teknik, please feel free to contact us through our Contact Form or by emailing us at @Model.Config.SupportEmail. -

-
-

Transactions

-
-

Total Amounts

-
-
-

Donations

- @foreach (var val in Model.TotalDonations) - { -

@Math.Round(val.Value, 2) @val.Key

- } -
-
-

Bills

- @foreach (var val in Model.TotalBills) - { -

@Math.Round(val.Value, 2) @val.Key

- } -
-
-

One-Time Payments

- @foreach (var val in Model.TotalOneTimes) - { -

@Math.Round(val.Value, 2) @val.Key

- } -
-
-

Net Profit

- @foreach (var val in Model.TotalNet) - { -

@Math.Round(val.Value, 2) @val.Key

- } -
-
- @if (Model.Bills != null && Model.Bills.Any()) - { -

Bills

-
-
- -
-
-
-
-
-
-

Date

-
-
-

Amount

-
-
-

Description

-
-
- @foreach (Bill bill in Model.Bills) - { -
-
- @bill.DateSent.ToString("MMMM dd, yyyy") -
-
- @bill.Amount @bill.Currency -
-
- @bill.Reason -
-
- } -
- } - @if (Model.OneTimes != null && Model.OneTimes.Any()) - { -

One Time Payments

-
-
- -
-
-
-
-
-
-

Date

-
-
-

Amount

-
-
-

Reason for Payment

-
-
- @foreach (OneTime oneTime in Model.OneTimes) - { -
-
- @oneTime.DateSent.ToString("MMMM dd, yyyy") -
-
- @oneTime.Amount @oneTime.Currency -
-
- @oneTime.Reason -
-
- } -
- } - @if (Model.Donations != null && Model.Donations.Any()) - { -

Donations

-
-
- -
-
-
-
-
-
-

Date

-
-
-

Amount

-
-
-

Donor

-
-
-

Reason for Donation

-
-
- @foreach (Donation donation in Model.Donations) - { -
-
- @donation.DateSent.ToString("MMMM dd, yyyy") -
-
- @donation.Amount @donation.Currency -
-
- @donation.Sender -
-
- @donation.Reason -
-
- } -
- } -
-

Takedowns

-
- @if (Model.Takedowns != null && Model.Takedowns.Any()) - { -

Takedowns

-
-
- -
-
-
-
-
-
-

Requester

-
-
-

Contact

-
-
-

Reason

-
-
-

Action Taken

-
-
-

Date Requested

-
-
-

Date Of Action

-
-
- @foreach (Takedown takedown in Model.Takedowns) - { -
-
- @takedown.Requester -
-
- @takedown.RequesterContact -
-
- @takedown.Reason -
-
- @takedown.ActionTaken -
-
- @takedown.DateRequested.ToString("MMMM dd, yyyy") -
-
- @takedown.DateActionTaken.ToString("MMMM dd, yyyy") -
-
- } -
- } -
-
-
-
-
- @if (!string.IsNullOrEmpty(Model.Canary)) - { -
@Model.Canary
- } -
-
- } - else - { -
-
-

Transparency Information has been disabled

-
-
- } -
\ No newline at end of file diff --git a/Teknik/Areas/Transparency/Views/_ViewStart.cshtml b/Teknik/Areas/Transparency/Views/_ViewStart.cshtml deleted file mode 100644 index 2de6241..0000000 --- a/Teknik/Areas/Transparency/Views/_ViewStart.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@{ - Layout = "~/Views/Shared/_Layout.cshtml"; -} diff --git a/Teknik/Areas/Transparency/Views/web.config b/Teknik/Areas/Transparency/Views/web.config deleted file mode 100644 index ada5aaf..0000000 --- a/Teknik/Areas/Transparency/Views/web.config +++ /dev/null @@ -1,36 +0,0 @@ - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Teknik/Models/TeknikEntities.cs b/Teknik/Models/TeknikEntities.cs index fc52244..e82035a 100644 --- a/Teknik/Models/TeknikEntities.cs +++ b/Teknik/Models/TeknikEntities.cs @@ -8,7 +8,7 @@ using Teknik.Migrations; using Teknik.Areas.Upload.Models; using Teknik.Areas.Paste.Models; using Teknik.Areas.Podcast.Models; -using Teknik.Areas.Transparency.Models; +using Teknik.Areas.Status.Models; using Teknik.Areas.Shortener.Models; using Teknik.Attributes; using System.Data.Entity.ModelConfiguration.Conventions; diff --git a/Teknik/Scripts/_references.js b/Teknik/Scripts/_references.js index bad7c67..34b19db 100644 Binary files a/Teknik/Scripts/_references.js and b/Teknik/Scripts/_references.js differ diff --git a/Teknik/Teknik.csproj b/Teknik/Teknik.csproj index c81cc37..3dc1116 100644 --- a/Teknik/Teknik.csproj +++ b/Teknik/Teknik.csproj @@ -103,6 +103,10 @@ ..\packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll True + + ..\packages\NBitcoin.3.0.2.4\lib\net45\NBitcoin.dll + True + ..\packages\nClam.2.0.6.0\lib\net40-Client\nClam.dll True @@ -259,8 +263,19 @@ + + + + + + + + + + + @@ -302,14 +317,6 @@ - - - - - - - - @@ -371,7 +378,6 @@ - @@ -564,9 +570,7 @@ - - @@ -612,14 +616,18 @@ - - + + + + + + @@ -718,12 +726,10 @@ - - + - diff --git a/Teknik/Views/Shared/_Footer.cshtml b/Teknik/Views/Shared/_Footer.cshtml index 0ade751..da17826 100644 --- a/Teknik/Views/Shared/_Footer.cshtml +++ b/Teknik/Views/Shared/_Footer.cshtml @@ -51,7 +51,7 @@ }
- © Teknik 2013-2017 | Privacy | TOS | Transparency + © Teknik 2013-2017 | Privacy | TOS | Status