MarkItUp.SingleUserBlog/Services/FileSystemBlogDataProvider.cs

(开头部分) 26KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections;
using System.Xml;
using System.Web;
using MarkItUp.SingleUserBlog.Common;
using System.Collections.Generic;
using System.Diagnostics;
using System.Web.Security;

namespace MarkItUp.SingleUserBlog.Services {
	public class FileSystemBlogDataProvider : BlogDataProvider {
		public override bool Authenticate(string username, string password) {
			if (password == Globals.UserPassword && username == Globals.UserLoginName) {
                FormsAuthentication.Authenticate(username, password);
                FormsAuthentication.SetAuthCookie(username, true);
                return true;
			}

			return false;
		}


		// Feedback Methods
		public override void DeleteFeedback(string feedbackId) {

			if (!SecurityHelper.CurrentUserIsBlogOwner)
				throw new ApplicationException("You do not have permission to delete this feedback item.");

			// Remove from the index
            XmlDocument doc = FileHelper.GetPostCommentsIndex(Globals.BlogIndexDataFolderPath);
			XmlNode node = doc.DocumentElement.SelectSingleNode("PostComment[@commentId='" + feedbackId + "']");

			if (node != null) {
				string postId = node.Attributes["postId"].Value;
				doc.DocumentElement.RemoveChild(node);
                FileHelper.SavePostCommentsIndex(Globals.BlogIndexDataFolderPath, doc);


				// Remove the comment
				XmlDocument doc1 = FileHelper.GetPostComments(Globals.BlogPostDataFolderPath, postId);
				XmlNode node1 = doc1.DocumentElement.SelectSingleNode("Comment[@id='" + feedbackId + "']");

				if (node1 != null) {
					doc1.DocumentElement.RemoveChild(node1);
					FileHelper.SavePostComments(Globals.BlogPostDataFolderPath, postId, doc1);
				}

				string cacheKey = "FeedbackItem_" + feedbackId;
				CacheHelper.InvalidateCache(cacheKey);

				cacheKey = "FeedbackItemsByPost_" + postId;
				CacheHelper.InvalidateCache(cacheKey);
			}
		}


		public override FeedbackItem LoadFeedback(string feedbackItemId) {
			return LoadFeedback(feedbackItemId, false);
		}

后面还有 668 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。