1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Added .net core piwik tracking api to most entry points

This commit is contained in:
Uncled1023 2019-01-31 23:43:23 -08:00
parent 0597455180
commit 7945ade961
27 changed files with 81 additions and 10 deletions

View File

@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Teknik.Configuration;
using Teknik.Data;
using Teknik.Filters;
using Teknik.Logging;
namespace Teknik.Areas.API.V1.Controllers
@ -18,6 +19,7 @@ namespace Teknik.Areas.API.V1.Controllers
public AccountAPIv1Controller(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[HttpGet]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult GetClaims()
{
return new JsonResult(from c in User.Claims select new { c.Type, c.Value });

View File

@ -12,6 +12,7 @@ using Teknik.Areas.Users.Models;
using Teknik.Areas.Users.Utility;
using Teknik.Configuration;
using Teknik.Data;
using Teknik.Filters;
using Teknik.Logging;
using Teknik.Utilities;
@ -24,6 +25,7 @@ namespace Teknik.Areas.API.V1.Controllers
[HttpPost]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Paste(PasteAPIv1Model model)
{
try

View File

@ -13,6 +13,7 @@ using Teknik.Areas.Users.Models;
using Teknik.Areas.Users.Utility;
using Teknik.Configuration;
using Teknik.Data;
using Teknik.Filters;
using Teknik.Logging;
using Teknik.Utilities;
@ -25,6 +26,7 @@ namespace Teknik.Areas.API.V1.Controllers
[HttpPost]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Shorten(ShortenAPIv1Model model)
{
try

View File

@ -17,6 +17,7 @@ using Teknik.Areas.Users.Models;
using Teknik.Areas.Users.Utility;
using Teknik.Configuration;
using Teknik.Data;
using Teknik.Filters;
using Teknik.Logging;
using Teknik.Utilities;
@ -29,6 +30,7 @@ namespace Teknik.Areas.API.V1.Controllers
[HttpPost]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> Upload(UploadAPIv1Model model)
{
try

View File

@ -22,6 +22,7 @@ namespace Teknik.Areas.About.Controllers
public AboutController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index([FromServices] Config config)
{
ViewBag.Title = "About";

View File

@ -22,6 +22,7 @@ namespace Teknik.Areas.Abuse.Controllers
public AbuseController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
ViewBag.Title = "Abuse Reporting";

View File

@ -29,6 +29,7 @@ namespace Teknik.Areas.Admin.Controllers
public AdminController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base (logger, config, dbContext) { }
[HttpGet]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Dashboard()
{
DashboardViewModel model = new DashboardViewModel();
@ -36,6 +37,7 @@ namespace Teknik.Areas.Admin.Controllers
}
[HttpGet]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult UserSearch()
{
UserSearchViewModel model = new UserSearchViewModel();
@ -43,6 +45,7 @@ namespace Teknik.Areas.Admin.Controllers
}
[HttpGet]
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> UserInfo(string username)
{
if (UserHelper.UserExists(_dbContext, username))
@ -63,6 +66,7 @@ namespace Teknik.Areas.Admin.Controllers
}
[HttpGet]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult UploadSearch()
{
UploadSearchViewModel model = new UploadSearchViewModel();

View File

@ -30,6 +30,7 @@ namespace Teknik.Areas.Blog.Controllers
public BlogController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Blog(string username)
{
BlogViewModel model = new BlogViewModel();
@ -119,6 +120,7 @@ namespace Teknik.Areas.Blog.Controllers
#region Posts
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Post(string username, int id)
{
if (string.IsNullOrEmpty(username))
@ -160,7 +162,8 @@ namespace Teknik.Areas.Blog.Controllers
model.ErrorMessage = "Blog Post does not exist.";
return View("~/Areas/Blog/Views/Blog/ViewPost.cshtml", model);
}
[ServiceFilter(typeof(TrackPageView))]
public IActionResult NewPost(string username, int blogID)
{
if (string.IsNullOrEmpty(username))
@ -200,6 +203,7 @@ namespace Teknik.Areas.Blog.Controllers
return View("~/Areas/Blog/Views/Blog/Blog.cshtml", model);
}
[ServiceFilter(typeof(TrackPageView))]
public IActionResult EditPost(string username, int id)
{
if (string.IsNullOrEmpty(username))

View File

@ -26,6 +26,7 @@ namespace Teknik.Areas.Contact.Controllers
public ContactController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
ViewBag.Title = "Contact Us";

View File

@ -28,6 +28,7 @@ namespace Teknik.Areas.Error.Controllers
public ErrorController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult HttpError(int statusCode)
{
switch (statusCode)
@ -44,6 +45,7 @@ namespace Teknik.Areas.Error.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult HttpGeneral(int statusCode)
{
ViewBag.Title = statusCode;
@ -57,6 +59,7 @@ namespace Teknik.Areas.Error.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Http401()
{
Response.StatusCode = StatusCodes.Status401Unauthorized;
@ -73,6 +76,7 @@ namespace Teknik.Areas.Error.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Http403()
{
Response.StatusCode = StatusCodes.Status403Forbidden;
@ -89,6 +93,7 @@ namespace Teknik.Areas.Error.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Http404()
{
Response.StatusCode = StatusCodes.Status404NotFound;
@ -105,6 +110,7 @@ namespace Teknik.Areas.Error.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Http500(Exception exception)
{
try

View File

@ -18,6 +18,7 @@ namespace Teknik.Areas.FAQ.Controllers
public FAQController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
ViewBag.Title = "Frequently Asked Questions";

View File

@ -14,6 +14,7 @@ namespace Teknik.Areas.Help.Controllers
{
[Authorize]
[Area("Help")]
[ServiceFilter(typeof(TrackPageView))]
public class HelpController : DefaultController
{
public HelpController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }

View File

@ -23,6 +23,7 @@ namespace Teknik.Areas.Home.Controllers
public HomeController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
HomeViewModel model = new HomeViewModel();

View File

@ -31,6 +31,7 @@ namespace Teknik.Areas.Paste.Controllers
public PasteController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
ViewBag.Title = "Pastebin";
@ -40,6 +41,7 @@ namespace Teknik.Areas.Paste.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> ViewPaste(string type, string url, string password)
{
Models.Paste paste = _dbContext.Pastes.Where(p => p.Url == url).FirstOrDefault();
@ -202,7 +204,8 @@ namespace Teknik.Areas.Paste.Controllers
}
return View("~/Areas/Paste/Views/Paste/Index.cshtml", model);
}
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> Edit(string url, string password)
{
Models.Paste paste = _dbContext.Pastes.Where(p => p.Url == url).FirstOrDefault();

View File

@ -29,6 +29,7 @@ namespace Teknik.Areas.Podcast.Controllers
public PodcastController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
MainViewModel model = new MainViewModel();
@ -63,6 +64,7 @@ namespace Teknik.Areas.Podcast.Controllers
#region Podcasts
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult View(int episode)
{
PodcastViewModel model = new PodcastViewModel();
@ -84,6 +86,7 @@ namespace Teknik.Areas.Podcast.Controllers
[HttpGet]
[AllowAnonymous]
[ResponseCache(Duration = 31536000, Location = ResponseCacheLocation.Any)]
[ServiceFilter(typeof(TrackDownload))]
public IActionResult Download(int episode, string fileName)
{
string path = string.Empty;

View File

@ -18,6 +18,7 @@ namespace Teknik.Areas.Privacy.Controllers
public PrivacyController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
ViewBag.Title = "Privacy Policy";

View File

@ -32,6 +32,7 @@ namespace Teknik.Areas.RSS.Controllers
public RSSController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task Index()
{
Response.ContentType = "application/rss+xml";
@ -49,6 +50,7 @@ namespace Teknik.Areas.RSS.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task Blog(string username)
{
Response.ContentType = "application/rss+xml";
@ -154,6 +156,7 @@ namespace Teknik.Areas.RSS.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task Podcast()
{
Response.ContentType = "application/rss+xml";

View File

@ -24,6 +24,7 @@ namespace Teknik.Areas.Shortener.Controllers
public ShortenerController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
ViewBag.Title = "Url Shortener";
@ -32,6 +33,7 @@ namespace Teknik.Areas.Shortener.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult RedirectToUrl(string url)
{
ShortenedUrl shortUrl = _dbContext.ShortenedUrls.Where(s => s.ShortUrl == url).FirstOrDefault();

View File

@ -24,6 +24,7 @@ namespace Teknik.Areas.Stats.Controllers
public StatsController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
ViewBag.Title = "System Statistics";

View File

@ -18,6 +18,7 @@ namespace Teknik.Areas.TOS.Controllers
public TOSController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Index()
{
ViewBag.Title = "Terms of Service";

View File

@ -33,6 +33,7 @@ namespace Teknik.Areas.Upload.Controllers
[HttpGet]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> Index()
{
ViewBag.Title = "Upload Files";
@ -180,6 +181,8 @@ namespace Teknik.Areas.Upload.Controllers
[HttpGet]
[AllowAnonymous]
[ServiceFilter(typeof(TrackDownload))]
[ServiceFilter(typeof(TrackPageView))]
[ResponseCache(Duration = 31536000, Location = ResponseCacheLocation.Any)]
public async Task<IActionResult> Download(string file)
{

View File

@ -62,6 +62,7 @@ namespace Teknik.Areas.Users.Controllers
}
[HttpGet]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Login(string returnUrl)
{
// Let's double check their email and git accounts to make sure they exist
@ -85,6 +86,7 @@ namespace Teknik.Areas.Users.Controllers
}
[HttpGet]
[ServiceFilter(typeof(TrackPageView))]
public async Task Logout()
{
// these are the sub & sid to signout
@ -98,6 +100,7 @@ namespace Teknik.Areas.Users.Controllers
}
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult GetPremium()
{
ViewBag.Title = "Get a Premium Account";
@ -109,6 +112,7 @@ namespace Teknik.Areas.Users.Controllers
[HttpGet]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Register(string inviteCode, string ReturnUrl)
{
RegisterViewModel model = new RegisterViewModel();
@ -202,6 +206,7 @@ namespace Teknik.Areas.Users.Controllers
// GET: Profile/Profile
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> ViewProfile(string username)
{
if (string.IsNullOrEmpty(username))
@ -259,6 +264,7 @@ namespace Teknik.Areas.Users.Controllers
return View(model);
}
[ServiceFilter(typeof(TrackPageView))]
public IActionResult ViewServiceData()
{
string username = User.Identity.Name;
@ -297,11 +303,13 @@ namespace Teknik.Areas.Users.Controllers
return View(model);
}
[ServiceFilter(typeof(TrackPageView))]
public IActionResult Settings()
{
return Redirect(Url.SubRouteUrl("account", "User.ProfileSettings"));
}
[ServiceFilter(typeof(TrackPageView))]
public IActionResult ProfileSettings()
{
string username = User.Identity.Name;
@ -326,6 +334,7 @@ namespace Teknik.Areas.Users.Controllers
return new StatusCodeResult(StatusCodes.Status403Forbidden);
}
[ServiceFilter(typeof(TrackPageView))]
public IActionResult AccountSettings()
{
string username = User.Identity.Name;
@ -347,6 +356,7 @@ namespace Teknik.Areas.Users.Controllers
return new StatusCodeResult(StatusCodes.Status403Forbidden);
}
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> SecuritySettings()
{
string username = User.Identity.Name;
@ -389,6 +399,7 @@ namespace Teknik.Areas.Users.Controllers
return new StatusCodeResult(StatusCodes.Status403Forbidden);
}
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> DeveloperSettings()
{
string username = User.Identity.Name;
@ -436,6 +447,7 @@ namespace Teknik.Areas.Users.Controllers
return new StatusCodeResult(StatusCodes.Status403Forbidden);
}
[ServiceFilter(typeof(TrackPageView))]
public IActionResult InviteSettings()
{
string username = User.Identity.Name;
@ -480,7 +492,8 @@ namespace Teknik.Areas.Users.Controllers
return new StatusCodeResult(StatusCodes.Status403Forbidden);
}
[ServiceFilter(typeof(TrackPageView))]
public IActionResult BlogSettings()
{
string username = User.Identity.Name;
@ -503,7 +516,8 @@ namespace Teknik.Areas.Users.Controllers
return new StatusCodeResult(StatusCodes.Status403Forbidden);
}
[ServiceFilter(typeof(TrackPageView))]
public IActionResult UploadSettings()
{
string username = User.Identity.Name;
@ -530,6 +544,7 @@ namespace Teknik.Areas.Users.Controllers
[HttpGet]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> ViewRawPGP(string username)
{
ViewBag.Title = username + "'s Public Key";
@ -824,6 +839,7 @@ namespace Teknik.Areas.Users.Controllers
[HttpGet]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult ResetPassword(string username)
{
ResetPasswordViewModel model = new ResetPasswordViewModel();
@ -867,6 +883,7 @@ namespace Teknik.Areas.Users.Controllers
[HttpGet]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> VerifyResetPassword(string username, string code)
{
bool verified = true;

View File

@ -34,6 +34,7 @@ namespace Teknik.Areas.Vault.Controllers
public VaultController(ILogger<Logger> logger, Config config, TeknikEntities dbContext) : base(logger, config, dbContext) { }
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public async Task<IActionResult> ViewVault(string id)
{
Models.Vault foundVault = _dbContext.Vaults.Where(v => v.Url == id).FirstOrDefault();
@ -135,6 +136,7 @@ namespace Teknik.Areas.Vault.Controllers
[HttpGet]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult NewVault()
{
ViewBag.Title = "Create Vault";
@ -145,6 +147,7 @@ namespace Teknik.Areas.Vault.Controllers
[HttpGet]
[AllowAnonymous]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult NewVaultFromService(string type, string items)
{
ViewBag.Title = "Create Vault";
@ -181,6 +184,7 @@ namespace Teknik.Areas.Vault.Controllers
}
[HttpGet]
[ServiceFilter(typeof(TrackPageView))]
public IActionResult EditVault(string url, string type, string items)
{
ViewBag.Title = "Edit Vault";

View File

@ -24,8 +24,9 @@ using Teknik.Utilities;
namespace Teknik.Controllers
{
[CORSActionFilter]
[Area("Default")]
[CORSActionFilter]
[ResponseCache(Duration = 3600, Location = ResponseCacheLocation.Any)]
public class DefaultController : Controller
{
protected string Subdomain

View File

@ -97,9 +97,9 @@ namespace Teknik
});
// Add Tracking Filter scopes
//services.AddScoped<TrackDownload>();
services.AddScoped<TrackDownload>();
//services.AddScoped<TrackLink>();
//services.AddScoped<TrackPageView>();
services.AddScoped<TrackPageView>();
// Create the Database Context
services.AddDbContext<TeknikEntities>(options => options

View File

@ -7,13 +7,17 @@
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;linux-arm;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<None Remove="lib\Piwik.Tracker.NetStandard1.4.dll" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Configuration\Configuration.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Piwik.Tracker.NetStandard1.4">
<HintPath>lib\Piwik.Tracker.NetStandard1.4.dll</HintPath>
<Reference Include="Piwik.Tracker">
<HintPath>lib\Piwik.Tracker.dll</HintPath>
</Reference>
</ItemGroup>

Binary file not shown.