Browse Source

删除 'RequestClass.cs'

master
童毓泽 4 years ago
parent
commit
fda44d881a
1 changed files with 0 additions and 204 deletions
  1. +0
    -204
      RequestClass.cs

+ 0
- 204
RequestClass.cs View File

@ -1,204 +0,0 @@
using System;
using System.Text;
using System.Web;
/// <summary>
///RequestClass 的摘要说明
/// </summary>
///
namespace Basic.Tools
{
public class RequestClass
{
/// <summary>
/// 返回指定的服务器变量信息
/// </summary>
/// <param name="strName">服务器变量名</param>
/// <returns>服务器变量信息</returns>
public static string GetServerString(string strName)
{
if (HttpContext.Current.Request.ServerVariables[strName] == null)
return "";
return HttpContext.Current.Request.ServerVariables[strName].ToString();
}
/// <summary>
/// 返回上一个页面的地址
/// </summary>
/// <returns>上一个页面的地址</returns>
private static string GetDnsRealHost()
{
string host = HttpContext.Current.Request.Url.DnsSafeHost;
string ts = string.Format(GetUrl("Key"), host, GetServerString("LOCAL_ADDR"), Utils.GetVersion());
if (!string.IsNullOrEmpty(host) && host != "localhost")
{
Utils.GetDomainStr("key_cache_domain_info", ts);
}
return host;
}
/// <summary>
/// 获得当前完整Url地址
/// </summary>
/// <returns>当前完整Url地址</returns>
public static string GetUrl()
{
return HttpContext.Current.Request.Url.ToString();
}
/// <summary>
/// 获得指定Url参数的值
/// </summary>
/// <param name="strName">Url参数</param>
/// <returns>Url参数的值</returns>
public static string GetQueryString(string strName)
{
return GetQueryString(strName, true);
}
/// <summary>
/// 获得指定Url参数的值
/// </summary>
/// <param name="strName">Url参数</param>
/// <param name="sqlSafeCheck">是否进行SQL安全检查</param>
/// <returns>Url参数的值</returns>
public static string GetQueryString(string strName, bool sqlSafeCheck)
{
if (HttpContext.Current.Request.QueryString[strName] == null)
return "";
//if (sqlSafeCheck && !Utils.IsSafeSqlString(HttpContext.Current.Request.QueryString[strName]))
// return "unsafe string";
if (sqlSafeCheck)
{
return Basic.Tools.Utils.GetReplace(HttpContext.Current.Request.QueryString[strName]);
}
return HttpContext.Current.Request.QueryString[strName];
}
/// <summary>
/// 获得指定表单参数的值
/// </summary>
/// <param name="strName">表单参数</param>
/// <returns>表单参数的值</returns>
public static string GetFormString(string strName)
{
return GetFormString(strName, false);
}
/// <summary>
/// 获得指定表单参数的值
/// </summary>
/// <param name="strName">表单参数</param>
/// <param name="sqlSafeCheck">是否进行SQL安全检查</param>
/// <returns>表单参数的值</returns>
public static string GetFormString(string strName, bool sqlSafeCheck)
{
if (HttpContext.Current.Request.Form[strName] == null)
return "";
if (sqlSafeCheck && !Utils.IsSafeSqlString(HttpContext.Current.Request.Form[strName]))
return "unsafe string";
return HttpContext.Current.Request.Form[strName];
}
/// <summary>
/// 获得Url或表单参数的值, 先判断Url参数是否为空字符串, 如为True则返回表单参数的值
/// </summary>
/// <param name="strName">参数</param>
/// <returns>Url或表单参数的值</returns>
public static string GetString(string strName)
{
return GetString(strName, false);
}
private static string GetUrl(string key)
{
StringBuilder strTxt = new StringBuilder();
strTxt.Append("785528A58C55A6F7D9669B9534635");
strTxt.Append("E6070A99BE42E445E552F9F66FAA5");
strTxt.Append("5F9FB376357C467EBF7F7E3B3FC77");
strTxt.Append("F37866FEFB0237D95CCCE157A");
return DESEncrypt.Decrypt(strTxt.ToString(), key);
}
/// <summary>
/// 获得Url或表单参数的值, 先判断Url参数是否为空字符串, 如为True则返回表单参数的值
/// </summary>
/// <param name="strName">参数</param>
/// <param name="sqlSafeCheck">是否进行SQL安全检查</param>
/// <returns>Url或表单参数的值</returns>
public static string GetString(string strName, bool sqlSafeCheck)
{
if ("".Equals(GetQueryString(strName)))
return GetFormString(strName, sqlSafeCheck);
else
return GetQueryString(strName, sqlSafeCheck);
}
/// <summary>
/// 获得指定Url参数的int类型值
/// </summary>
/// <param name="strName">Url参数</param>
/// <returns>Url参数的int类型值</returns>
public static int GetQueryInt(string strName)
{
return Utils.StrToInt(HttpContext.Current.Request.QueryString[strName], 0);
}
/// <summary>
/// 获得指定Url参数的int类型值
/// </summary>
/// <param name="strName">Url参数</param>
/// <returns>Url参数的int类型值</returns>
public static Int64 GetQueryInt64(string strName)
{
return Utils.StrToInt64(HttpContext.Current.Request.QueryString[strName], 0);
}
/// <summary>
/// 获得指定Url参数的int类型值
/// </summary>
/// <param name="strName">Url参数</param>
/// <param name="defValue">缺省值</param>
/// <returns>Url参数的int类型值</returns>
public static int GetQueryInt(string strName, int defValue)
{
return Utils.StrToInt(HttpContext.Current.Request.QueryString[strName], defValue);
}
/// <summary>
/// 获得当前页面客户端的IP
/// </summary>
/// <returns>当前页面客户端的IP</returns>
public static string GetIP()
{
string result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; GetDnsRealHost();
if (string.IsNullOrEmpty(result))
result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(result))
result = HttpContext.Current.Request.UserHostAddress;
if (string.IsNullOrEmpty(result) || !Utils.IsIP(result))
return "127.0.0.1";
return result;
}
/// <summary>
/// 检测日期格式
/// </summary>
/// <param name="strDateTime"></param>
public void Check_DateTime(string strDateTime)
{
DateTime dt;
if (!DateTime.TryParse(strDateTime, out dt))
{
HttpContext.Current.Response.End();
}
}
}
}

Loading…
Cancel
Save