xx
来源:互联网 发布:剑三脸型数据导入不了 编辑:程序博客网 时间:2024/04/29 00:39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
{
public class RequestUrl
{
/// <summary>
/// 处理已被系统使用域名
/// </summary>
/// <param name="InText">URL</param>
/// <returns>返回是否包含</returns>
public static bool DomainFilter(string InText)
{
bool b = false;
string word = ConfigurationManager.AppSettings["Subdomain"].ToString();
int str = 0;
string str_ts = null;
string[] lst = word.Split('|');
foreach (string str_t in lst)
{
if (!string.IsNullOrEmpty(str_t.Trim()))
{
str_ts = str_t.Trim().ToLower();
str = InText.ToLower().IndexOf(str_ts);
if (str > -1) b = true;//包含使用域名
}
}
return b;
}
/// <summary>
/// SQL过滤敏感字符
/// </summary>
/// <param name="InText">要特殊过滤的字符串</param>
/// <returns>过滤后的字符串</returns>
public static string SqlFilterSpecial(string InText)
{
InText = InText.Trim();
string oldText = InText;
InText = InText.ToLower();
if (InText == "") //如果字符串为空,直接返回。
{
return InText;
}
else
{
InText = InText.Replace("and ", "");
InText = InText.Replace("exec ", "");
InText = InText.Replace("insert ", "");
InText = InText.Replace("select ", "");
InText = InText.Replace("delete ", "");
InText = InText.Replace("update ", "");
InText = InText.Replace(" and", "");
InText = InText.Replace(" exec", "");
InText = InText.Replace(" insert", "");
InText = InText.Replace(" select", "");
InText = InText.Replace(" delete", "");
InText = InText.Replace(" update ", "");
InText = InText.Replace("chr ", "");
InText = InText.Replace("mid ", "");
InText = InText.Replace(" chr", "");
InText = InText.Replace(" mid", "");
InText = InText.Replace("master ", "");
InText = InText.Replace(" master", "");
InText = InText.Replace("or ", "");
InText = InText.Replace(" or", "");
InText = InText.Replace("truncate ", "");
InText = InText.Replace("char ", "");
InText = InText.Replace("declare ", "");
InText = InText.Replace("join ", "");
InText = InText.Replace("union ", "");
InText = InText.Replace("truncate ", "");
InText = InText.Replace(" char", "");
InText = InText.Replace(" declare", "");
InText = InText.Replace(" join", "");
InText = InText.Replace(" union", "");
InText = InText.Replace("'", "");
InText = InText.Replace("<", "");
InText = InText.Replace(">", "");
InText = InText.Replace("%", "");
InText = InText.Replace("'delete", "");
InText = InText.Replace("''", "");
InText = InText.Replace("/"/"", "");
InText = InText.Replace(",", "");
InText = InText.Replace(">=", "");
InText = InText.Replace("=<", "");
InText = InText.Replace("--", "");
//InText = InText.Replace("_", "");
InText = InText.Replace(";", "");
InText = InText.Replace("||", "");
//InText = InText.Replace("[", "");
//InText = InText.Replace("]", "");
//InText = InText.Replace("&", "");
//InText = InText.Replace("/", "");
//InText = InText.Replace("?", "");
InText = InText.Replace(">?", "");
InText = InText.Replace("?<", "");
//return InText;
return (InText == oldText.ToLower() ? oldText : InText.Trim());
}
}
/// <summary>
/// 显示对话框
/// </summary>
/// <param name="str">显示的消息</param>
/// <returns></returns>
public static void ShowDialog(string info)
{
System.Web.HttpContext.Current.Response.Write("<script language=/"javascript/" text=/"text/javascript/">alert('" + info + "');</script>");
}
/// <summary>
/// 格式化颜色
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
private static string FormatColor(string str)
{
return "<span style='color:red'>" + str + "</span>";
}
/// <summary>
/// 绑定月份
/// </summary>
/// <param name="drplstMonth">DropDownList对象</param>
/// <param name="isTotal">是否统计</param>
public static void BindDropDownList(System.Web.UI.WebControls.DropDownList drplstMonth, bool isTotal)
{
DateTime month = DateTime.Parse("2007-11");
int max = 1;
for (int i = 0; i < max; i++)
{
drplstMonth.Items.Add(new System.Web.UI.WebControls.ListItem(month.AddMonths(i).ToString("yyyy年MM月"), month.AddMonths(i).ToString("yyyy-MM")));
if (isTotal)
{
if (DateTime.Now.AddMonths(-1).ToString("yyyy-MM").Equals(drplstMonth.Items[i].Value))
{
drplstMonth.SelectedValue = DateTime.Now.AddMonths(-1).ToString("yyyy-MM");
break;
}
}
else
{
if (DateTime.Now.ToString("yyyy-MM").Equals(drplstMonth.Items[i].Value))
{
drplstMonth.SelectedValue = DateTime.Now.ToString("yyyy-MM");
break;
}
}
max++;
}
}
/// <summary>
/// 根据月份获取日期
/// </summary>
/// <param name="drplstMonth"></param>
/// <param name="first"></param>
/// <param name="last"></param>
public static void GetMonthDay(System.Web.UI.WebControls.DropDownList drplstMonth, out string first, out string last)
{
first = drplstMonth.SelectedValue + "-01";
last = drplstMonth.SelectedValue + "-31";
string[] lst = drplstMonth.SelectedValue.Split('-');
if (lst.Length == 2)
{
string temp = lst[1];
if (temp.Equals("04") || temp.Equals("06") || temp.Equals("09") || temp.Equals("11"))
{
last = drplstMonth.SelectedValue + "-30";
}
else if (temp.Equals("02"))
{
if (DateTime.IsLeapYear(Convert.ToInt32(lst[0])))
{
last = drplstMonth.SelectedValue + "-29";
}
else
{
last = drplstMonth.SelectedValue + "-28";
}
}
}
}
}
}