migrate to new git

This commit is contained in:
2025-08-29 01:27:25 +08:00
parent 946eb9961e
commit af2c152ef6
8623 changed files with 1000453 additions and 1 deletions

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http.Controllers;
/// <summary>
/// HttpReferrer https://zh.wikipedia.org/wiki/HTTP%E5%8F%83%E7%85%A7%E4%BD%8D%E5%9D%80
/// HTTP參照位址referer或HTTP referer是HTTP表頭的一個欄位用來表示從哪兒連結到目前的網頁採用的格式是URL。換句話說藉著HTTP參照位址目前的網頁可以檢查訪客從哪裡而來這也常被用來對付偽造的跨網站請求。
/// </summary>
public class HttpReferrerAttribute : System.Web.Http.AuthorizeAttribute
{
public string Url { get; set; }
public override void OnAuthorization(HttpActionContext actionContext)
{
base.OnAuthorization(actionContext);
}
protected override void HandleUnauthorizedRequest(HttpActionContext actionContext)
{
base.HandleUnauthorizedRequest(actionContext);
}
protected override bool IsAuthorized(HttpActionContext actionContext)
{
if (actionContext.Request.Headers.Referrer == null) return false;
try
{
string host = HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.PathAndQuery, "/");
string referrer = actionContext.Request.Headers.Referrer.AbsoluteUri.Replace(actionContext.Request.Headers.Referrer.AbsolutePath, "/");
if (string.IsNullOrEmpty(this.Url))
{
return host == referrer;
}
else
{
return actionContext.Request.Headers.Referrer.AbsoluteUri.IndexOf(host + Url) > -1;
}
}
catch
{
}
return false;
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http.Controllers;
/// <summary>
/// MemberIsLogin 檢查前台會員是否登入
/// </summary>
public class MemberIsLoginAttribute : System.Web.Http.AuthorizeAttribute
{
public override void OnAuthorization(HttpActionContext actionContext)
{
base.OnAuthorization(actionContext);
}
protected override void HandleUnauthorizedRequest(HttpActionContext actionContext)
{
base.HandleUnauthorizedRequest(actionContext);
}
protected override bool IsAuthorized(HttpActionContext actionContext)
{
//return new ez.data.member().isLogin();
return true;
}
}