Browse Source

Merged virtual property changes.

master
Teknikode 6 years ago
parent
commit
2c91bf29b2
  1. 6
      ServerMaint/Program.cs
  2. 2
      Teknik/Areas/API/Controllers/APIv1Controller.cs
  3. 28
      Teknik/Areas/Blog/Controllers/BlogController.cs
  4. 4
      Teknik/Areas/Blog/Models/Blog.cs
  5. 4
      Teknik/Areas/Blog/Models/BlogPost.cs
  6. 4
      Teknik/Areas/Blog/Models/BlogPostComment.cs
  7. 2
      Teknik/Areas/Blog/ViewModels/PostViewModel.cs
  8. 6
      Teknik/Areas/Error/Controllers/ErrorController.cs
  9. 4
      Teknik/Areas/Home/Controllers/HomeController.cs
  10. 2
      Teknik/Areas/Paste/Controllers/PasteController.cs
  11. 2
      Teknik/Areas/Paste/Models/Paste.cs
  12. 25
      Teknik/Areas/Podcast/Controllers/PodcastController.cs
  13. 4
      Teknik/Areas/Podcast/Models/Podcast.cs
  14. 4
      Teknik/Areas/Podcast/Models/PodcastComment.cs
  15. 2
      Teknik/Areas/Podcast/Models/PodcastFile.cs
  16. 2
      Teknik/Areas/Podcast/ViewModels/PodcastViewModel.cs
  17. 10
      Teknik/Areas/RSS/Controllers/RSSController.cs
  18. 4
      Teknik/Areas/Shortener/Models/ShortenedUrl.cs
  19. 2
      Teknik/Areas/Transparency/Models/Takedown.cs
  20. 3
      Teknik/Areas/Upload/Controllers/UploadController.cs
  21. 2
      Teknik/Areas/Upload/Models/Upload.cs
  22. 21
      Teknik/Areas/Upload/Uploader.cs
  23. 4
      Teknik/Areas/User/Models/Group.cs
  24. 2
      Teknik/Areas/User/Models/RecoveryEmailVerification.cs
  25. 2
      Teknik/Areas/User/Models/ResetPasswordVerification.cs
  26. 2
      Teknik/Areas/User/Models/Role.cs
  27. 6
      Teknik/Areas/User/Models/User.cs
  28. 28
      Teknik/Areas/User/Utility/UserHelper.cs
  29. 2
      Teknik/Areas/Vault/Models/PasteItem.cs
  30. 2
      Teknik/Areas/Vault/Models/UploadItem.cs
  31. 4
      Teknik/Areas/Vault/Models/Vault.cs
  32. 2
      Teknik/Areas/Vault/Models/VaultItem.cs
  33. 2
      Teknik/Global.asax.cs
  34. 4
      Teknik/Helpers/Tracking.cs
  35. 4
      Teknik/Views/Shared/_Layout.cshtml

6
ServerMaint/Program.cs

@ -520,15 +520,15 @@ Thank you for your continued use of Teknik! @@ -520,15 +520,15 @@ Thank you for your continued use of Teknik!
bool noData = true;
// Any blog comments?
var blogCom = db.BlogComments.Include("Users").Where(c => c.UserId == user.UserId);
var blogCom = db.BlogComments.Where(c => c.UserId == user.UserId);
noData &= !(blogCom != null && blogCom.Any());
// Any blog posts?
var blogPosts = db.BlogPosts.Include("Blog").Include("Blog.Users").Where(p => p.Blog.UserId == user.UserId);
var blogPosts = db.BlogPosts.Where(p => p.Blog.UserId == user.UserId);
noData &= !(blogPosts != null && blogPosts.Any());
// Any podcast comments?
var podCom = db.PodcastComments.Include("Users").Where(p => p.UserId == user.UserId);
var podCom = db.PodcastComments.Where(p => p.UserId == user.UserId);
noData &= !(podCom != null && podCom.Any());
// Any email?

2
Teknik/Areas/API/Controllers/APIv1Controller.cs

@ -113,7 +113,7 @@ namespace Teknik.Areas.API.Controllers @@ -113,7 +113,7 @@ namespace Teknik.Areas.API.Controllers
}
// Save the file data
Upload.Models.Upload upload = Uploader.SaveFile((encrypt) ? data : fileData, contentType, contentLength, fileExt, iv, (saveKey) ? key : null, keySize, blockSize);
Upload.Models.Upload upload = Uploader.SaveFile(db, Config, (encrypt) ? data : fileData, contentType, contentLength, fileExt, iv, (saveKey) ? key : null, keySize, blockSize);
if (upload != null)
{

28
Teknik/Areas/Blog/Controllers/BlogController.cs

@ -32,7 +32,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -32,7 +32,7 @@ namespace Teknik.Areas.Blog.Controllers
ViewBag.Title = Config.BlogConfig.Title + " - " + Config.Title;
ViewBag.Description = Config.BlogConfig.Description;
bool isAuth = User.IsInRole("Admin");
var foundPosts = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => ((p.System || isAuth) && p.Published));
var foundPosts = db.BlogPosts.Where(p => ((p.System || isAuth) && p.Published));
model = new BlogViewModel();
model.BlogId = Config.BlogConfig.ServerBlogId;
@ -47,7 +47,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -47,7 +47,7 @@ namespace Teknik.Areas.Blog.Controllers
}
else // A user specific blog
{
Models.Blog blog = db.Blogs.Include("User").Where(p => p.User.Username == username && p.BlogId != Config.BlogConfig.ServerBlogId).FirstOrDefault();
Models.Blog blog = db.Blogs.Where(p => p.User.Username == username && p.BlogId != Config.BlogConfig.ServerBlogId).FirstOrDefault();
// find the blog specified
if (blog != null)
{
@ -58,7 +58,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -58,7 +58,7 @@ namespace Teknik.Areas.Blog.Controllers
}
ViewBag.Description = blog.User.BlogSettings.Description;
bool isAuth = User.IsInRole("Admin");
var foundPosts = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => (p.BlogId == blog.BlogId && !p.System) &&
var foundPosts = db.BlogPosts.Where(p => (p.BlogId == blog.BlogId && !p.System) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
model = new BlogViewModel();
model.BlogId = blog.BlogId;
@ -87,7 +87,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -87,7 +87,7 @@ namespace Teknik.Areas.Blog.Controllers
PostViewModel model = new PostViewModel();
// find the post specified
bool isAuth = User.IsInRole("Admin");
var post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => (p.Blog.User.Username == username && p.BlogPostId == id) &&
var post = db.BlogPosts.Where(p => (p.Blog.User.Username == username && p.BlogPostId == id) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (post != null)
{
@ -120,7 +120,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -120,7 +120,7 @@ namespace Teknik.Areas.Blog.Controllers
public ActionResult GetPosts(int blogID, int startPostID, int count)
{
bool isAuth = User.IsInRole("Admin");
var posts = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => ((p.BlogId == blogID && !p.System) || (p.System && blogID == Config.BlogConfig.ServerBlogId)) &&
var posts = db.BlogPosts.Where(p => ((p.BlogId == blogID && !p.System) || (p.System && blogID == Config.BlogConfig.ServerBlogId)) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).OrderByDescending(p => p.DatePosted).Skip(startPostID).Take(count).ToList();
List<PostViewModel> postViews = new List<PostViewModel>();
if (posts != null)
@ -138,7 +138,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -138,7 +138,7 @@ namespace Teknik.Areas.Blog.Controllers
public ActionResult GetPostTitle(int postID)
{
bool isAuth = User.IsInRole("Admin");
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (post != null)
{
return Json(new { result = post.Title });
@ -151,7 +151,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -151,7 +151,7 @@ namespace Teknik.Areas.Blog.Controllers
public ActionResult GetPostArticle(int postID)
{
bool isAuth = User.IsInRole("Admin");
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => (p.BlogPostId == postID) && (p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (post != null)
{
return Json(new { result = post.Article });
@ -169,7 +169,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -169,7 +169,7 @@ namespace Teknik.Areas.Blog.Controllers
bool system = (blogID == Config.BlogConfig.ServerBlogId);
if (system)
{
var user = db.Blogs.Include("User").Where(b => b.User.Username == User.Identity.Name);
var user = db.Blogs.Where(b => b.User.Username == User.Identity.Name);
if (user != null)
{
blogID = user.First().BlogId;
@ -198,7 +198,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -198,7 +198,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => p.BlogPostId == postID).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => p.BlogPostId == postID).FirstOrDefault();
if (post != null)
{
if (User.IsInRole("Admin") || post.Blog.User.Username == User.Identity.Name)
@ -222,7 +222,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -222,7 +222,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => p.BlogPostId == postID).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => p.BlogPostId == postID).FirstOrDefault();
if (post != null)
{
if (User.IsInRole("Admin") || post.Blog.User.Username == User.Identity.Name)
@ -246,7 +246,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -246,7 +246,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPost post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => p.BlogPostId == postID).FirstOrDefault();
BlogPost post = db.BlogPosts.Where(p => p.BlogPostId == postID).FirstOrDefault();
if (post != null)
{
if (User.IsInRole("Admin") || post.Blog.User.Username == User.Identity.Name)
@ -268,7 +268,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -268,7 +268,7 @@ namespace Teknik.Areas.Blog.Controllers
[AllowAnonymous]
public ActionResult GetComments(int postID, int startCommentID, int count)
{
var comments = db.BlogComments.Include("BlogPost").Include("BlogPost.Blog").Include("BlogPost.Blog.User").Include("User").Where(p => (p.BlogPostId == postID)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
var comments = db.BlogComments.Where(p => (p.BlogPostId == postID)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
List<CommentViewModel> commentViews = new List<CommentViewModel>();
if (comments != null)
{
@ -320,7 +320,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -320,7 +320,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPostComment comment = db.BlogComments.Include("User").Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
BlogPostComment comment = db.BlogComments.Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))
@ -343,7 +343,7 @@ namespace Teknik.Areas.Blog.Controllers @@ -343,7 +343,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPostComment comment = db.BlogComments.Include("User").Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
BlogPostComment comment = db.BlogComments.Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))

4
Teknik/Areas/Blog/Models/Blog.cs

@ -10,8 +10,8 @@ namespace Teknik.Areas.Blog.Models @@ -10,8 +10,8 @@ namespace Teknik.Areas.Blog.Models
public int UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public List<BlogPost> BlogPosts { get; set; }
public virtual ICollection<BlogPost> BlogPosts { get; set; }
}
}

4
Teknik/Areas/Blog/Models/BlogPost.cs

@ -10,7 +10,7 @@ namespace Teknik.Areas.Blog.Models @@ -10,7 +10,7 @@ namespace Teknik.Areas.Blog.Models
public int BlogId { get; set; }
public Blog Blog { get; set; }
public virtual Blog Blog { get; set; }
public bool System { get; set; }
@ -28,6 +28,6 @@ namespace Teknik.Areas.Blog.Models @@ -28,6 +28,6 @@ namespace Teknik.Areas.Blog.Models
public List<string> Tags { get; set; }
public List<BlogPostComment> Comments { get; set; }
public virtual ICollection<BlogPostComment> Comments { get; set; }
}
}

4
Teknik/Areas/Blog/Models/BlogPostComment.cs

@ -12,11 +12,11 @@ namespace Teknik.Areas.Blog.Models @@ -12,11 +12,11 @@ namespace Teknik.Areas.Blog.Models
public int BlogPostId { get; set; }
public BlogPost BlogPost { get; set; }
public virtual BlogPost BlogPost { get; set; }
public int? UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public DateTime DatePosted { get; set; }
public DateTime DateEdited { get; set; }

2
Teknik/Areas/Blog/ViewModels/PostViewModel.cs

@ -52,7 +52,7 @@ namespace Teknik.Areas.Blog.ViewModels @@ -52,7 +52,7 @@ namespace Teknik.Areas.Blog.ViewModels
Title = post.Title;
Tags = post.Tags;
Article = post.Article;
Comments = post.Comments;
Comments = post.Comments.ToList();
}
}
}

6
Teknik/Areas/Error/Controllers/ErrorController.cs

@ -49,8 +49,7 @@ namespace Teknik.Areas.Error.Controllers @@ -49,8 +49,7 @@ namespace Teknik.Areas.Error.Controllers
return View(model);
}
[TrackPageView]
[AllowAnonymous]
public ActionResult Http403(Exception exception)
{
@ -68,8 +67,7 @@ namespace Teknik.Areas.Error.Controllers @@ -68,8 +67,7 @@ namespace Teknik.Areas.Error.Controllers
return View(model);
}
[TrackPageView]
[AllowAnonymous]
public ActionResult Http404(Exception exception)
{

4
Teknik/Areas/Home/Controllers/HomeController.cs

@ -27,7 +27,7 @@ namespace Teknik.Areas.Home.Controllers @@ -27,7 +27,7 @@ namespace Teknik.Areas.Home.Controllers
List<BlogPost> lastSite = new List<BlogPost>();
if (db.BlogPosts.Count() > 0)
{
var foundSite = db.BlogPosts.Include("Blog").Include("Blog.User").OrderByDescending(post => post.DatePosted).Where(p => p.Published && p.System).Take(5);
var foundSite = db.BlogPosts.OrderByDescending(post => post.DatePosted).Where(p => p.Published && p.System).Take(5);
if (foundSite != null)
lastSite = foundSite.ToList();
}
@ -35,7 +35,7 @@ namespace Teknik.Areas.Home.Controllers @@ -35,7 +35,7 @@ namespace Teknik.Areas.Home.Controllers
List<BlogPost> lastPosts = new List<BlogPost>();
if (db.BlogPosts.Count() > 0)
{
var foundPosts = db.BlogPosts.Include("Blog").Include("Blog.User").OrderByDescending(post => post.DatePosted).Where(p => p.Published && !p.System).Take(5);
var foundPosts = db.BlogPosts.OrderByDescending(post => post.DatePosted).Where(p => p.Published && !p.System).Take(5);
if (foundPosts != null)
lastPosts = foundPosts.ToList();
}

2
Teknik/Areas/Paste/Controllers/PasteController.cs

@ -30,7 +30,7 @@ namespace Teknik.Areas.Paste.Controllers @@ -30,7 +30,7 @@ namespace Teknik.Areas.Paste.Controllers
return View(model);
}
[TrackPageView]
[TrackDownload]
[AllowAnonymous]
public ActionResult ViewPaste(string type, string url, string password)
{

2
Teknik/Areas/Paste/Models/Paste.cs

@ -14,7 +14,7 @@ namespace Teknik.Areas.Paste.Models @@ -14,7 +14,7 @@ namespace Teknik.Areas.Paste.Models
public int? UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public DateTime DatePosted { get; set; }

25
Teknik/Areas/Podcast/Controllers/PodcastController.cs

@ -59,7 +59,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -59,7 +59,7 @@ namespace Teknik.Areas.Podcast.Controllers
PodcastViewModel model = new PodcastViewModel();
// find the podcast specified
bool editor = User.IsInRole("Podcast");
var foundPodcast = db.Podcasts.Include("Files").Where(p => ((p.Published || editor) && p.Episode == episode)).FirstOrDefault();
var foundPodcast = db.Podcasts.Where(p => ((p.Published || editor) && p.Episode == episode)).FirstOrDefault();
if (foundPodcast != null)
{
model = new PodcastViewModel(foundPodcast);
@ -76,7 +76,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -76,7 +76,7 @@ namespace Teknik.Areas.Podcast.Controllers
public ActionResult Download(int episode, string fileName)
{
// find the podcast specified
var foundPodcast = db.Podcasts.Include("Files").Where(p => (p.Published && p.Episode == episode)).FirstOrDefault();
var foundPodcast = db.Podcasts.Where(p => (p.Published && p.Episode == episode)).FirstOrDefault();
if (foundPodcast != null)
{
PodcastFile file = foundPodcast.Files.Where(f => f.FileName == fileName).FirstOrDefault();
@ -108,7 +108,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -108,7 +108,7 @@ namespace Teknik.Areas.Podcast.Controllers
public ActionResult GetPodcasts(int startPodcastID, int count)
{
bool editor = User.IsInRole("Podcast");
var podcasts = db.Podcasts.Include("Files").Where(p => p.Published || editor).OrderByDescending(p => p.DatePosted).Skip(startPodcastID).Take(count).ToList();
var podcasts = db.Podcasts.Where(p => p.Published || editor).OrderByDescending(p => p.DatePosted).Skip(startPodcastID).Take(count).ToList();
List<PodcastViewModel> podcastViews = new List<PodcastViewModel>();
if (podcasts != null)
{
@ -164,7 +164,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -164,7 +164,7 @@ namespace Teknik.Areas.Podcast.Controllers
public ActionResult GetPodcastFiles(int podcastId)
{
bool editor = User.IsInRole("Podcast");
var foundPodcast = db.Podcasts.Include("Files").Where(p => ((p.Published || editor) && p.PodcastId == podcastId)).FirstOrDefault();
var foundPodcast = db.Podcasts.Where(p => ((p.Published || editor) && p.PodcastId == podcastId)).FirstOrDefault();
if (foundPodcast != null)
{
List<object> files = new List<object>();
@ -221,7 +221,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -221,7 +221,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (User.IsInRole("Podcast"))
{
Models.Podcast podcast = db.Podcasts.Include("Files").Where(p => p.PodcastId == podcastId).FirstOrDefault();
Models.Podcast podcast = db.Podcasts.Where(p => p.PodcastId == podcastId).FirstOrDefault();
if (podcast != null)
{
if (db.Podcasts.Where(p => p.Episode != episode).FirstOrDefault() == null || podcast.Episode == episode)
@ -238,7 +238,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -238,7 +238,7 @@ namespace Teknik.Areas.Podcast.Controllers
}
for (int i = 0; i < podcast.Files.Count; i++)
{
PodcastFile curFile = podcast.Files[i];
PodcastFile curFile = podcast.Files.ElementAt(i);
if (!fileIdList.Exists(id => id == curFile.PodcastFileId.ToString()))
{
if (System.IO.File.Exists(curFile.Path))
@ -251,7 +251,10 @@ namespace Teknik.Areas.Podcast.Controllers @@ -251,7 +251,10 @@ namespace Teknik.Areas.Podcast.Controllers
}
// Add any new files
List<PodcastFile> newFiles = SaveFiles(Request.Files, episode);
podcast.Files.AddRange(newFiles);
foreach (PodcastFile file in newFiles)
{
podcast.Files.Add(file);
}
// Save podcast
db.Entry(podcast).State = EntityState.Modified;
@ -298,7 +301,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -298,7 +301,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (User.IsInRole("Podcast"))
{
Models.Podcast podcast = db.Podcasts.Include("Files").Where(p => p.PodcastId == podcastId).FirstOrDefault();
Models.Podcast podcast = db.Podcasts.Where(p => p.PodcastId == podcastId).FirstOrDefault();
if (podcast != null)
{
foreach (PodcastFile file in podcast.Files)
@ -322,7 +325,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -322,7 +325,7 @@ namespace Teknik.Areas.Podcast.Controllers
[AllowAnonymous]
public ActionResult GetComments(int podcastId, int startCommentID, int count)
{
var comments = db.PodcastComments.Include("BlogPost").Include("BlogPost.Blog").Include("BlogPost.Blog.User").Include("User").Where(p => (p.PodcastId == podcastId)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
var comments = db.PodcastComments.Where(p => (p.PodcastId == podcastId)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
List<CommentViewModel> commentViews = new List<CommentViewModel>();
if (comments != null)
{
@ -374,7 +377,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -374,7 +377,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (ModelState.IsValid)
{
PodcastComment comment = db.PodcastComments.Include("User").Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
PodcastComment comment = db.PodcastComments.Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))
@ -397,7 +400,7 @@ namespace Teknik.Areas.Podcast.Controllers @@ -397,7 +400,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (ModelState.IsValid)
{
PodcastComment comment = db.PodcastComments.Include("User").Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
PodcastComment comment = db.PodcastComments.Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))

4
Teknik/Areas/Podcast/Models/Podcast.cs

@ -15,7 +15,7 @@ namespace Teknik.Areas.Podcast.Models @@ -15,7 +15,7 @@ namespace Teknik.Areas.Podcast.Models
public string Description { get; set; }
public List<PodcastFile> Files { get; set; }
public virtual ICollection<PodcastFile> Files { get; set; }
public List<string> Tags { get; set; }
@ -27,6 +27,6 @@ namespace Teknik.Areas.Podcast.Models @@ -27,6 +27,6 @@ namespace Teknik.Areas.Podcast.Models
public DateTime DateEdited { get; set; }
public List<PodcastComment> Comments { get; set; }
public virtual ICollection<PodcastComment> Comments { get; set; }
}
}

4
Teknik/Areas/Podcast/Models/PodcastComment.cs

@ -12,11 +12,11 @@ namespace Teknik.Areas.Podcast.Models @@ -12,11 +12,11 @@ namespace Teknik.Areas.Podcast.Models
public int PodcastId { get; set; }
public Podcast Podcast { get; set; }
public virtual Podcast Podcast { get; set; }
public int UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public DateTime DatePosted { get; set; }

2
Teknik/Areas/Podcast/Models/PodcastFile.cs

@ -11,7 +11,7 @@ namespace Teknik.Areas.Podcast.Models @@ -11,7 +11,7 @@ namespace Teknik.Areas.Podcast.Models
public int PodcastId { get; set; }
public Podcast Podcast { get; set; }
public virtual Podcast Podcast { get; set; }
public string FileName { get; set; }

2
Teknik/Areas/Podcast/ViewModels/PodcastViewModel.cs

@ -37,7 +37,7 @@ namespace Teknik.Areas.Podcast.ViewModels @@ -37,7 +37,7 @@ namespace Teknik.Areas.Podcast.ViewModels
Episode = podcast.Episode;
Title = podcast.Title;
Description = podcast.Description;
Files = podcast.Files;
Files = podcast.Files.ToList();
Tags = podcast.Tags;
DatePosted = podcast.DatePosted;
Published = podcast.Published;

10
Teknik/Areas/RSS/Controllers/RSSController.cs

@ -25,7 +25,8 @@ namespace Teknik.Areas.RSS.Controllers @@ -25,7 +25,8 @@ namespace Teknik.Areas.RSS.Controllers
return new RssResult(feed);
}
[TrackDownload]
[AllowAnonymous]
public ActionResult Blog(string username)
{
@ -37,12 +38,12 @@ namespace Teknik.Areas.RSS.Controllers @@ -37,12 +38,12 @@ namespace Teknik.Areas.RSS.Controllers
bool isSystem = string.IsNullOrEmpty(username);
if (isSystem)
{
blog = db.Blogs.Include("BlogPosts").Include("User").Where(b => b.BlogId == Config.BlogConfig.ServerBlogId).FirstOrDefault();
blog = db.Blogs.Where(b => b.BlogId == Config.BlogConfig.ServerBlogId).FirstOrDefault();
blogUrl = Url.SubRouteUrl("blog", "Blog.Blog");
}
else
{
blog = db.Blogs.Include("BlogPosts").Include("User").Where(b => b.User.Username == username).FirstOrDefault();
blog = db.Blogs.Where(b => b.User.Username == username).FirstOrDefault();
blogUrl = Url.SubRouteUrl("blog", "Blog.Blog", new { username = username });
}
if (blog != null)
@ -83,11 +84,12 @@ namespace Teknik.Areas.RSS.Controllers @@ -83,11 +84,12 @@ namespace Teknik.Areas.RSS.Controllers
return new RssResult(badFeed);
}
[TrackDownload]
[AllowAnonymous]
public ActionResult Podcast()
{
List<SyndicationItem> items = new List<SyndicationItem>();
List<Podcast.Models.Podcast> podcasts = db.Podcasts.Include("Files").Where(p => p.Published).ToList();
List<Podcast.Models.Podcast> podcasts = db.Podcasts.Where(p => p.Published).ToList();
if (podcasts != null)
{
foreach (Podcast.Models.Podcast podcast in podcasts)

4
Teknik/Areas/Shortener/Models/ShortenedUrl.cs

@ -13,8 +13,8 @@ namespace Teknik.Areas.Shortener.Models @@ -13,8 +13,8 @@ namespace Teknik.Areas.Shortener.Models
public int? UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
[CaseSensitive]
public string ShortUrl { get; set; }

2
Teknik/Areas/Transparency/Models/Takedown.cs

@ -22,6 +22,6 @@ namespace Teknik.Areas.Transparency.Models @@ -22,6 +22,6 @@ namespace Teknik.Areas.Transparency.Models
public DateTime DateActionTaken { get; set; }
public List<Upload.Models.Upload> Attachments { get; set; }
public virtual ICollection<Upload.Models.Upload> Attachments { get; set; }
}
}

3
Teknik/Areas/Upload/Controllers/UploadController.cs

@ -110,7 +110,7 @@ namespace Teknik.Areas.Upload.Controllers @@ -110,7 +110,7 @@ namespace Teknik.Areas.Upload.Controllers
return Json(new { error = new { message = "Unable to encrypt file" } });
}
}
Models.Upload upload = Uploader.SaveFile(fileData, fileType, contentLength, fileExt, iv, (saveKey) ? key : null, keySize, blockSize);
Models.Upload upload = Uploader.SaveFile(db, Config, fileData, fileType, contentLength, fileExt, iv, (saveKey) ? key : null, keySize, blockSize);
if (upload != null)
{
if (User.Identity.IsAuthenticated)
@ -142,6 +142,7 @@ namespace Teknik.Areas.Upload.Controllers @@ -142,6 +142,7 @@ namespace Teknik.Areas.Upload.Controllers
// User did not supply key
[HttpGet]
[TrackDownload]
[AllowAnonymous]
public ActionResult Download(string file)
{

2
Teknik/Areas/Upload/Models/Upload.cs

@ -13,7 +13,7 @@ namespace Teknik.Areas.Upload.Models @@ -13,7 +13,7 @@ namespace Teknik.Areas.Upload.Models
public int? UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public DateTime DateUploaded { get; set; }

21
Teknik/Areas/Upload/Uploader.cs

@ -10,30 +10,27 @@ namespace Teknik.Areas.Upload @@ -10,30 +10,27 @@ namespace Teknik.Areas.Upload
{
public static class Uploader
{
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength)
{
return SaveFile(file, contentType, contentLength, string.Empty, null, null, 256, 128);
return SaveFile(db, config, file, contentType, contentLength, string.Empty, null, null, 256, 128);
}
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength, string defaultExtension)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension)
{
return SaveFile(file, contentType, contentLength, defaultExtension, null, null, 256, 128);
return SaveFile(db, config, file, contentType, contentLength, defaultExtension, null, null, 256, 128);
}
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength, string defaultExtension, string iv)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension, string iv)
{
return SaveFile(file, contentType, contentLength, defaultExtension, iv, null, 256, 128);
return SaveFile(db, config, file, contentType, contentLength, defaultExtension, iv, null, 256, 128);
}
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key)
{
return SaveFile(file, contentType, contentLength, defaultExtension, iv, key, 256, 128);
return SaveFile(db, config, file, contentType, contentLength, defaultExtension, iv, key, 256, 128);
}
public static Models.Upload SaveFile(byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key, int keySize, int blockSize)
public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key, int keySize, int blockSize)
{
Config config = Config.Load();
TeknikEntities db = new TeknikEntities();
if (!Directory.Exists(config.UploadConfig.UploadDirectory))
{
Directory.CreateDirectory(config.UploadConfig.UploadDirectory);

4
Teknik/Areas/User/Models/Group.cs

@ -14,8 +14,8 @@ namespace Teknik.Areas.Users.Models @@ -14,8 +14,8 @@ namespace Teknik.Areas.Users.Models
public string Description { get; set; }
public List<User> Users { get; set; }
public virtual ICollection<User> Users { get; set; }
public List<Role> Roles { get; set; }
public virtual ICollection<Role> Roles { get; set; }
}
}

2
Teknik/Areas/User/Models/RecoveryEmailVerification.cs

@ -11,7 +11,7 @@ namespace Teknik.Areas.Users.Models @@ -11,7 +11,7 @@ namespace Teknik.Areas.Users.Models
public int UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public string Code { get; set; }

2
Teknik/Areas/User/Models/ResetPasswordVerification.cs

@ -11,7 +11,7 @@ namespace Teknik.Areas.Users.Models @@ -11,7 +11,7 @@ namespace Teknik.Areas.Users.Models
public int UserId { get; set; }
public User User { get; set; }
public virtual User User { get; set; }
public string Code { get; set; }

2
Teknik/Areas/User/Models/Role.cs

@ -14,6 +14,6 @@ namespace Teknik.Areas.Users.Models @@ -14,6 +14,6 @@ namespace Teknik.Areas.Users.Models
public string Description { get; set; }
public List<Group> Groups { get; set; }
public virtual ICollection<Group> Groups { get; set; }
}
}

6
Teknik/Areas/User/Models/User.cs

@ -28,7 +28,7 @@ namespace Teknik.Areas.Users.Models @@ -28,7 +28,7 @@ namespace Teknik.Areas.Users.Models
public DateTime LastSeen { get; set; }
public List<Group> Groups { get; set; }
public virtual ICollection<Group> Groups { get; set; }
public virtual UserSettings UserSettings { get; set; }
@ -36,9 +36,9 @@ namespace Teknik.Areas.Users.Models @@ -36,9 +36,9 @@ namespace Teknik.Areas.Users.Models
public virtual UploadSettings UploadSettings { get; set; }
public List<Upload.Models.Upload> Uploads { get; set; }
public virtual ICollection<Upload.Models.Upload> Uploads { get; set; }
public List<Paste.Models.Paste> Pastes { get; set; }
public virtual ICollection<Paste.Models.Paste> Pastes { get; set; }
public User()
{

28
Teknik/Areas/User/Utility/UserHelper.cs

@ -331,7 +331,7 @@ namespace Teknik.Areas.Users.Utility @@ -331,7 +331,7 @@ namespace Teknik.Areas.Users.Utility
try
{
// Update uploads
List<Upload.Models.Upload> uploads = db.Uploads.Include("User").Where(u => u.User.Username == user.Username).ToList();
List<Upload.Models.Upload> uploads = db.Uploads.Where(u => u.User.Username == user.Username).ToList();
if (uploads != null)
{
foreach (Upload.Models.Upload upload in uploads)
@ -342,7 +342,7 @@ namespace Teknik.Areas.Users.Utility @@ -342,7 +342,7 @@ namespace Teknik.Areas.Users.Utility
}
// Update pastes
List<Paste.Models.Paste> pastes = db.Pastes.Include("User").Where(u => u.User.Username == user.Username).ToList();
List<Paste.Models.Paste> pastes = db.Pastes.Where(u => u.User.Username == user.Username).ToList();
if (pastes != null)
{
foreach (Paste.Models.Paste paste in pastes)
@ -353,7 +353,7 @@ namespace Teknik.Areas.Users.Utility @@ -353,7 +353,7 @@ namespace Teknik.Areas.Users.Utility
}
// Update shortened urls
List<ShortenedUrl> shortUrls = db.ShortenedUrls.Include("User").Where(u => u.User.Username == user.Username).ToList();
List<ShortenedUrl> shortUrls = db.ShortenedUrls.Where(u => u.User.Username == user.Username).ToList();
if (shortUrls != null)
{
foreach (ShortenedUrl shortUrl in shortUrls)
@ -364,14 +364,14 @@ namespace Teknik.Areas.Users.Utility @@ -364,14 +364,14 @@ namespace Teknik.Areas.Users.Utility
}
// Delete Blogs
Blog.Models.Blog blog = db.Blogs.Include("BlogPosts").Include("BlogPosts.Comments").Include("User").Where(u => u.User.Username == user.Username).FirstOrDefault();
Blog.Models.Blog blog = db.Blogs.Where(u => u.User.Username == user.Username).FirstOrDefault();
if (blog != null)
{
db.Blogs.Remove(blog);
}
// Delete post comments
List<BlogPostComment> postComments = db.BlogComments.Include("User").Where(u => u.User.Username == user.Username).ToList();
List<BlogPostComment> postComments = db.BlogComments.Where(u => u.User.Username == user.Username).ToList();
if (postComments != null)
{
foreach (BlogPostComment postComment in postComments)
@ -381,7 +381,7 @@ namespace Teknik.Areas.Users.Utility @@ -381,7 +381,7 @@ namespace Teknik.Areas.Users.Utility
}
// Delete podcast comments
List<Podcast.Models.PodcastComment> podComments = db.PodcastComments.Include("User").Where(u => u.User.Username == user.Username).ToList();
List<Podcast.Models.PodcastComment> podComments = db.PodcastComments.Where(u => u.User.Username == user.Username).ToList();
if (podComments != null)
{
foreach (Podcast.Models.PodcastComment podComment in podComments)
@ -391,7 +391,7 @@ namespace Teknik.Areas.Users.Utility @@ -391,7 +391,7 @@ namespace Teknik.Areas.Users.Utility
}
// Delete Recovery Email Verifications
List<RecoveryEmailVerification> verCodes = db.RecoveryEmailVerifications.Include("User").Where(r => r.User.Username == user.Username).ToList();
List<RecoveryEmailVerification> verCodes = db.RecoveryEmailVerifications.Where(r => r.User.Username == user.Username).ToList();
if (verCodes != null)
{
foreach (RecoveryEmailVerification verCode in verCodes)
@ -401,7 +401,7 @@ namespace Teknik.Areas.Users.Utility @@ -401,7 +401,7 @@ namespace Teknik.Areas.Users.Utility
}
// Delete Password Reset Verifications
List<ResetPasswordVerification> verPass = db.ResetPasswordVerifications.Include("User").Where(r => r.User.Username == user.Username).ToList();
List<ResetPasswordVerification> verPass = db.ResetPasswordVerifications.Where(r => r.User.Username == user.Username).ToList();
if (verPass != null)
{
foreach (ResetPasswordVerification ver in verPass)
@ -423,7 +423,7 @@ namespace Teknik.Areas.Users.Utility @@ -423,7 +423,7 @@ namespace Teknik.Areas.Users.Utility
public static string CreateRecoveryEmailVerification(TeknikEntities db, Config config, User user)
{
// Check to see if there already is a verification code for the user
List<RecoveryEmailVerification> verCodes = db.RecoveryEmailVerifications.Include("User").Where(r => r.User.Username == user.Username).ToList();
List<RecoveryEmailVerification> verCodes = db.RecoveryEmailVerifications.Where(r => r.User.Username == user.Username).ToList();
if (verCodes != null && verCodes.Any())
{
foreach (RecoveryEmailVerification verCode in verCodes)
@ -479,11 +479,11 @@ Thank you and enjoy! @@ -479,11 +479,11 @@ Thank you and enjoy!
public static bool VerifyRecoveryEmail(TeknikEntities db, Config config, string username, string code)
{
User user = GetUser(db, username);
RecoveryEmailVerification verCode = db.RecoveryEmailVerifications.Include("User").Where(r => r.User.Username == username && r.Code == code).FirstOrDefault();
RecoveryEmailVerification verCode = db.RecoveryEmailVerifications.Where(r => r.User.Username == username && r.Code == code).FirstOrDefault();
if (verCode != null)
{
// We have a match, so clear out the verifications for that user
List<RecoveryEmailVerification> verCodes = db.RecoveryEmailVerifications.Include("User").Where(r => r.User.Username == username).ToList();
List<RecoveryEmailVerification> verCodes = db.RecoveryEmailVerifications.Where(r => r.User.Username == username).ToList();
if (verCodes != null && verCodes.Any())
{
foreach (RecoveryEmailVerification ver in verCodes)
@ -504,7 +504,7 @@ Thank you and enjoy! @@ -504,7 +504,7 @@ Thank you and enjoy!
public static string CreateResetPasswordVerification(TeknikEntities db, Config config, User user)
{
// Check to see if there already is a verification code for the user
List<ResetPasswordVerification> verCodes = db.ResetPasswordVerifications.Include("User").Where(r => r.User.Username == user.Username).ToList();
List<ResetPasswordVerification> verCodes = db.ResetPasswordVerifications.Where(r => r.User.Username == user.Username).ToList();
if (verCodes != null && verCodes.Any())
{
foreach (ResetPasswordVerification verCode in verCodes)
@ -556,11 +556,11 @@ If you recieved this email and you did not reset your password, you can ignore t @@ -556,11 +556,11 @@ If you recieved this email and you did not reset your password, you can ignore t
public static bool VerifyResetPassword(TeknikEntities db, Config config, string username, string code)
{
User user = GetUser(db, username);
ResetPasswordVerification verCode = db.ResetPasswordVerifications.Include("User").Where(r => r.User.Username == username && r.Code == code).FirstOrDefault();
ResetPasswordVerification verCode = db.ResetPasswordVerifications.Where(r => r.User.Username == username && r.Code == code).FirstOrDefault();
if (verCode != null)
{
// We have a match, so clear out the verifications for that user
List<ResetPasswordVerification> verCodes = db.ResetPasswordVerifications.Include("User").Where(r => r.User.Username == username).ToList();
List<ResetPasswordVerification> verCodes = db.ResetPasswordVerifications.Where(r => r.User.Username == username).ToList();
if (verCodes != null && verCodes.Any())
{
foreach (ResetPasswordVerification ver in verCodes)

2
Teknik/Areas/Vault/Models/PasteItem.cs

@ -8,6 +8,6 @@ namespace Teknik.Areas.Vault.Models @@ -8,6 +8,6 @@ namespace Teknik.Areas.Vault.Models
public class PasteItem : VaultItem
{
public int PasteId { get; set; }
public Paste.Models.Paste Paste { get; set; }
public virtual Paste.Models.Paste Paste { get; set; }
}
}

2
Teknik/Areas/Vault/Models/UploadItem.cs

@ -8,6 +8,6 @@ namespace Teknik.Areas.Vault.Models @@ -8,6 +8,6 @@ namespace Teknik.Areas.Vault.Models
public class UploadItem : VaultItem
{
public int UploadId { get; set; }
public Upload.Models.Upload Upload { get; set; }
public virtual Upload.Models.Upload Upload { get; set; }
}
}

4
Teknik/Areas/Vault/Models/Vault.cs

@ -9,12 +9,12 @@ namespace Teknik.Areas.Vault.Models @@ -9,12 +9,12 @@ namespace Teknik.Areas.Vault.Models
{
public int VaultId { get; set; }
public int? UserId { get; set; }
public Users.Models.User User { get; set; }
public virtual Users.Models.User User { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateEdited { get; set; }
public List<VaultItem> Items { get; set; }
public virtual ICollection<VaultItem> Items { get; set; }
public Vault()
{

2
Teknik/Areas/Vault/Models/VaultItem.cs

@ -8,6 +8,8 @@ namespace Teknik.Areas.Vault.Models @@ -8,6 +8,8 @@ namespace Teknik.Areas.Vault.Models
public class VaultItem
{
public int VaultItemId { get; set; }
public int VaultId { get; set; }
public virtual Vault Vault { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTime DateAdded { get; set; }

2
Teknik/Global.asax.cs

@ -80,7 +80,7 @@ namespace Teknik @@ -80,7 +80,7 @@ namespace Teknik
using (TeknikEntities entities = new TeknikEntities())
{
User user = entities.Users.Include("Groups").Include("Groups.Roles").SingleOrDefault(u => u.Username == username);
User user = entities.Users.SingleOrDefault(u => u.Username == username);
if (user != null)
{

4
Teknik/Helpers/Tracking.cs

@ -98,6 +98,10 @@ namespace Teknik.Helpers @@ -98,6 +98,10 @@ namespace Teknik.Helpers
tracker.setIp(ipAddress);
tracker.setTokenAuth(config.PiwikConfig.TokenAuth);
// Get Referral
if (request.UrlReferrer != null)
tracker.setUrlReferrer(request.UrlReferrer.ToString());
tracker.doTrackAction(url, type);
}
}

4
Teknik/Views/Shared/_Layout.cshtml

@ -13,6 +13,10 @@ @@ -13,6 +13,10 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="@ViewBag.Description" />
<meta name="author" content="@Model.Config.Author" />
<!-- Site Verification Tags -->
<meta name="google-site-verification" content="X54N1YTsjgOc7hivpZK7RRKyvhGwaTI4BoFfxqOLlbc" />
<title>@ViewBag.Title</title>
<link rel="shortcut icon" href="/Images/favicon.ico" type="image/x-icon" />

Loading…
Cancel
Save