918博天堂

Server : Microsoft-IIS/10.0
System : Windows NT EBS-6136 10.0 build 17763 (Windows Server 2016) i586
User : jxgj ( 0)
PHP Version : 7.0.33
Disable Function : passthru,exec,system,shell_exec,proc_open,popen,pcntl_exec,socket_bind,stream_socket_server
Directory :  D:/tmp_aspnet/root/30d84c9f/424ff89a/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : D:/tmp_aspnet/root/30d84c9f/424ff89a/App_Code.oxegv2qw.6.cs
?#pragma checksum "D:\wwwroot\nuoya\wwwroot\App_Code\StringManager.cs" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "6379D7C44D9AD071751FF164F1253A4C"

#line 1 "D:\wwwroot\nuoya\wwwroot\App_Code\StringManager.cs"
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Drawing;
using System.Web;
using System.Collections.Specialized;
using System.Security.Cryptography;
using Microsoft.VisualBasic;
using System.Collections;
using System.Web.Security;
using System.Net;


   public class StringManager
    {
        /// <summary>
        /// 凭据 关键字 截取字符串。。就跟HTML新闻分页一样。。
        /// </summary>
        /// <param name="array">ArrayList 存放返回字符串的处所</param>
        /// <param name="str">要截取的字符串</param>
        /// <param name="pagecode">关键字 好比:“aa”</param>
        /// <returns>好比:123aa321aa4354654   返回 123   321  4354654  存放到ArrayList里面</returns>
        public static ArrayList GetSplit(string str, string pagecode)
        {
            ArrayList array = new ArrayList();
            int strcount = str.Length;
            for (int i = 0; i < strcount; )
            {
                int temp = str.IndexOf(pagecode);
                if (temp < 0)
                {
                    break;
                }
                else
                {
                    array.Add(str.Substring(0, temp));
                    str = str.Substring(temp + pagecode.Length);
                    i = i + temp + pagecode.Length;
                }
            }
            array.Add(str);
            return array;
        }
        /// <summary>
        /// 删除最后一个字符
        /// </summary>
        /// <param name="Input">输入值</param>
        /// <param name="indexStr"></param>
        /// <returns></returns>
        public static string CutLastInput(string Input, string indexStr)
        {
            if (Input.IndexOf(indexStr) >= 0)
                return Input.Remove(Input.LastIndexOf(indexStr));
            else
                return Input;

        }
        /// <summary>
        /// 返回字符串真实长度, 1个汉字长度为2
        /// </summary>
        /// <returns></returns>
        public static int GetStringLength(string str)
        {
            return Encoding.Default.GetBytes(str).Length;
        }
        /// <summary>
        /// 字符串若是操过指定长度则将超出的部门用指定字符串包办
        /// </summary>
        /// <param name="p_SrcString">要查抄的字符串</param>
        /// <param name="p_Length">指定长度</param>
        /// <param name="p_TailString">用于代替的字符串</param>
        /// <returns>截取后的字符串</returns>
        public static string CutString(string strInput, int intlen)//截取字符串
        {
            ASCIIEncoding ascii = new ASCIIEncoding();
            int intLength = 0;
            string strString = "";
            byte[] s = ascii.GetBytes(strInput);
            for (int i = 0; i < s.Length; i++)
            {
                if ((int)s[i] == 63)
                {
                    intLength += 2;
                }
                else
                {
                    intLength += 1;
                }

                try
                {
                    strString += strInput.Substring(i, 1);
                }
                catch
                {
                    break;
                }

                if (intLength > intlen)
                {
                    break;
                }
            }
            //若是截过则加上半个省略号
            byte[] mybyte = System.Text.Encoding.Default.GetBytes(strInput);
            if (mybyte.Length > intlen)
            {
                strString += "...";
            }
            return strString;
        }
        /// <summary>
        /// 天生指定数量的html空格符号
        /// </summary>
        public static string Spaces(int nSpaces)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < nSpaces; i++)
            {
                sb.Append(" &nbsp;&nbsp;");
            }
            return sb.ToString();
        }
        /// <summary>
        /// 代替回车换行符为html换行符
        /// </summary>
        public static string StrFormat(string str)
        {
            string str2;

            if (str == null)
            {
                str2 = "";
            }
            else
            {
                str = str.Replace("\r\n", "<br />");
                str = str.Replace("\n", "<br />");
                str2 = str;
            }
            return str2;
        }
        /// <summary>
        /// 删除最后一个字符
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string ClearLastChar(string str)
        {
            if (str == "")
                return "";
            else
                return str.Substring(0, str.Length - 1);
        }
        /// <summary>
        /// 进行指定的代替(脏字过滤,有多个脏字的用&符号隔开)
        /// </summary>
        public static string StrFilter(string str, string bantext)
        {
            string[] textArray1 = bantext.Split('&');

            for (int num1 = 0; num1 < textArray1.Length; num1++)
            {
                str = str.Replace(textArray1[num1], "");
            }
            return str;
        }
        /// <summary>
        /// 获得指定字符之间的字符串
        /// </summary>
        /// <param name="str">要查找的字符串</param>
        /// <param name="StartStr">肇始字符</param>
        /// <param name="EndStr">实现字符</param>
        /// <returns></returns>
        public string GetString(string str, string StartStr, string EndStr)
        {
            int intStart = 0;
            int intEnd = 0;

            if (str == string.Empty || StartStr == string.Empty || EndStr == string.Empty)
                return str;
            else
            {
                intStart = str.IndexOf(StartStr);
                intEnd = str.IndexOf(EndStr);
                if (intStart > intEnd)
                    return str;
                else
                    return str.Substring(intStart, intEnd);
            }

        }
        /// <summary>
        /// 获得指定字符之间的字符串
        /// </summary>
        /// <param name="str">要查找的字符串</param>
        /// <param name="StartStr">肇始字符</param>
        /// <param name="EndStr">实现字符</param>
        /// <returns></returns>
        public string GetString(string str, int startIndex, int Length)
        {
            int intStart = 0;
            int intEnd = 0;
            if (startIndex > 0) intStart = startIndex;
            if (Length > 0) intEnd = Length;
            if (intEnd > intStart)
                if (str.Length < Length)
                    return str.Substring(intStart);
                else
                    return str.Substring(intStart, Length);
            else
                return str.Substring(intStart);

        } 
        /// <summary>
        /// 返回 HTML 字符串的编码了局
        /// </summary>
        /// <param name="str">字符串</param>
        /// <returns>编码了局</returns>
        public static string HtmlEncode(string str)
        {
            str = str + "";
            //str = str.Replace("\r\n", "<br>");
            //str = str.Replace("\n", "<br>");
            //str = str.Replace(" ", "&nbsp;");
            str = str.Replace("'", "######");
            str = str.Replace("“", "$$$$$$");
            str = str.Replace("”", "%%%%%%");
            return HttpUtility.HtmlEncode(str);
        }
        /// <summary>
        /// 返回 HTML 字符串的解码了局
        /// </summary>
        /// <param name="str">字符串</param>
        /// <returns>解码了局</returns>
        public static string HtmlDecode(string str)
        {
            str = str + "";
            str = str.Replace("&lt;br&gt;", "\r\n"); //在数据库中"<"是"&lt;" ">"是"&gt;",
          //  str = str.Replace("&amp;nbsp;", " ");   //&amp;暗示的是&
           // str = str.Replace("&nbsp;", " ");
            str = str.Replace("######", "'");
            str = str.Replace("$$$$$$", "“");
            str = str.Replace("%%%%%%", "”");
            return HttpUtility.HtmlDecode(str);
        }
       public static string HtmlDecode(object str)
       {
           if (str != null)
           {
               str = str + "";
               str = str.ToString().Replace("&lt;br&gt;", "\r\n"); //在数据库中"<"是"&lt;" ">"是"&gt;",
               //str = str.ToString().Replace("&amp;nbsp;", " ");   //&amp;暗示的是&
               //str = str.ToString().Replace("&nbsp;", " ");
               str = str.ToString().Replace("######", "'");
               str = str.ToString().Replace("$$$$$$", "“");
               str = str.ToString().Replace("%%%%%%", "”");
               return HttpUtility.HtmlDecode(str.ToString());
           }
           else
               return "";
       }
        /// <summary>
        /// 返回 URL 字符串的编码了局
        /// </summary>
        /// <param name="str">字符串</param>
        /// <returns>编码了局</returns>
        public static string UrlEncode(string str)
        {
            return HttpUtility.UrlEncode(str);
        }
        /// <summary>
        /// 返回 URL 字符串的解码了局
        /// </summary>
        /// <param name="str">字符串</param>
        /// <returns>解码了局</returns>
        public static string UrlDecode(string str)
        {
            return HttpUtility.UrlDecode(str);

        }

        #region 验证部门

        /// <summary>
        /// 查抄一个字符串是否能够转化为日期,通常用于验证用户输入日期的合法性。
        /// </summary>
        /// <param name="_value">需验证的字符串。</param>
        /// <returns>是否能够转化为日期的bool值。</returns>
        public static bool IsStringDate(string _value)
        {
            DateTime dTime;
            try
            {
                dTime = DateTime.Parse(_value);
            }
            catch (FormatException e)
            {
                //日期体式不正确时
                Console.WriteLine(e.Message);
                return false;
            }
            return true;
        }
        /// <summary>
        /// 检测是否有中文字符
        /// </summary>
        /// <param name="inputData"></param>
        /// <returns></returns>
        public static bool IsHasCHZN(string inputData)
        {
            Regex RegCHZN = new Regex("[\u4e00-\u9fa5]");
            Match m = RegCHZN.Match(inputData);
            return m.Success;
        }
        /// <summary>
        /// 验证是否为正整数
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool IsNumeric(string str)
        {
            return Regex.IsMatch(str, @"^[0-9]*$");
        }

        /// <summary>
        /// 判断文件名是否为浏览器能够直接显示的图片文件名
        /// </summary>
        /// <param name="filename">文件名</param>
        /// <returns>是否能够直接显示</returns>
        public static bool IsImgFilename(string filename)
        {
            filename = filename.Trim();
            if (filename.EndsWith(".") || filename.IndexOf(".") == -1)
            {
                return false;
            }
            string extname = filename.Substring(filename.LastIndexOf(".") + 1).ToLower();
            return (extname == "jpg" || extname == "jpeg" || extname == "png" || extname == "bmp" || extname == "gif");
        }

        /// <summary>
        /// 查抄一个字符串是否是纯字母和数字组成的,通常用于查问字符串参数的有效性验证。
        /// </summary>
        /// <param name="_value">需验证的字符串。</param>
        /// <returns>是否合法的bool值。</returns>
        public static bool IsLetterOrNumber(string _value)
        {
            return StringManager.QuickValidate("^[a-zA-Z0-9_]*$", _value);
        }
        /// <summary>
        /// 判断是否是数字,蕴含幼数和整数。
        /// </summary>
        /// <param name="_value">需验证的字符串。</param>
        /// <returns>是否合法的bool值。</returns>
        public static bool IsNumber(string _value)
        {
            return StringManager.QuickValidate("^(0|([1-9]+[0-9]*))(.[0-9]+)?$", _value);
        }
        /// <summary>
        /// 急剧验证一个字符串是否切合指定的正则表白式。
        /// </summary>
        /// <param name="_express">正则表白式的内容。</param>
        /// <param name="_value">需验证的字符串。</param>
        /// <returns>是否合法的bool值。</returns>
        public static bool QuickValidate(string _express, string _value)
        {
            System.Text.RegularExpressions.Regex myRegex = new System.Text.RegularExpressions.Regex(_express);
            if (_value.Length == 0)
            {
                return false;
            }
            return myRegex.IsMatch(_value);
        }
        #region IsEmail
        /// <summary>
        /// 验证字符串Email地址
        /// </summary>
        /// <param name="input">要验证的字符串</param>
        /// <returns></returns>
        public static bool IsEmail(string input)
        {
            // Return true if strIn is in valid e-mail format.
            string regexString = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

            return Regex.IsMatch(input, regexString);
        }
        #endregion
        /// <summary>
        /// 判断一个字符串是否为ID体式
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public static bool IsIDCard(string _value)
        {
            Regex regex;
            string[] strArray;
            DateTime time;
            if ((_value.Length != 15) && (_value.Length != 0x12))
            {
                return false;
            }
            if (_value.Length == 15)
            {
                regex = new Regex(@"^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$");
                if (!regex.Match(_value).Success)
                {
                    return false;
                }
                strArray = regex.Split(_value);
                try
                {
                    time = new DateTime(int.Parse("19" + strArray[2]), int.Parse(strArray[3]), int.Parse(strArray[4]));
                    return true;
                }
                catch
                {
                    return false;
                }
            }
            regex = new Regex(@"^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9Xx])$");
            if (!regex.Match(_value).Success)
            {
                return false;
            }
            strArray = regex.Split(_value);
            try
            {
                time = new DateTime(int.Parse(strArray[2]), int.Parse(strArray[3]), int.Parse(strArray[4]));
                return true;
            }
            catch
            {
                return false;
            }
        }
        /// <summary>
        /// 判断一个字符串是否为Int
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public static bool IsInt(string _value)
        {
            Regex regex = new Regex(@"^(-){0,1}\d+$");
            if (regex.Match(_value).Success)
            {
                if ((long.Parse(_value) > 0x7fffffffL) || (long.Parse(_value) < -2147483648L))
                {
                    return false;
                }
                return true;
            }
            return false;
        }
        /// <summary>
        /// 判断一个字符串是否为手机号码
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public static bool IsMobileNum(string _value)
        {
            Regex regex = new Regex(@"^13\d{9}$", RegexOptions.IgnoreCase);
            return regex.Match(_value).Success;
        }
        /// <summary>
        /// 判断一个字符串是否为电话号码
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public static bool IsPhoneNum(string _value)
        {
            //    return Regex.IsMatch(strIn, @"(\d+-)?(\d{4}-?\d{7}|\d{3}-?\d{8}|^\d{7,8})(-\d+)?");
            Regex regex = new Regex(@"^(86)?(-)?(0\d{2,3})?(-)?(\d{7,8})(-)?(\d{3,5})?$", RegexOptions.IgnoreCase);
            return regex.Match(_value).Success;
        }
        /// <summary>
        /// 检测是否是正确的Url
        /// </summary>
        /// <param name="strUrl">要验证的Url</param>
        /// <returns>判断了局</returns>
        public static bool IsURL(string strUrl)
        {
            return Regex.IsMatch(strUrl, @"^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{1,10}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");
        }
        /// <summary>
        /// 判断一个字符串是否为字母加数字
        /// Regex("[a-zA-Z0-9]?"
        /// </summary>
        /// <param name="_value"></param>
        /// <returns></returns>
        public static bool IsWordAndNum(string _value)
        {
            Regex regex = new Regex("[a-zA-Z0-9]?");
            return regex.Match(_value).Success;
        }
        /// <summary>
        /// 是否为ip
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public static bool IsIP(string ip)
        {
            return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
        }


        #region IsInt32
        /// <summary>
        /// 验证字符串是否整数
        /// </summary>
        /// <param name="input">要验证的字符串</param>
        /// <returns></returns>
        public static bool IsInt32(string input)
        {
            string regexString = @"^-?\\d+$";

            return Regex.IsMatch(input, regexString);
        }
        #endregion

        #region IsDouble
        /// <summary>
        /// 验证字符串是否浮点数字
        /// </summary>
        /// <param name="v">要验证的字符串</param>
        /// <returns></returns>
        public static bool IsDouble(string input)
        {
            string regexString = @"^(-?\\d+)(\\.\\d+)?$";

            return Regex.IsMatch(input, regexString);
        }
        #endregion

        /// <summary>
        /// 检测是否合法日期
        /// </summary>
        /// <param name="str">待检测的字符串</param>
        /// <returns></returns>
        public static bool ChkDate(string Input)
        {
            try
            {
                DateTime t1 = DateTime.Parse(Input);
                return true;
            }
            catch
            {
                return false;
            }
        }

        #region IsTxtFileName
        /// <summary>
        /// 验证字符串是否TXT文件名(全名)
        /// </summary>
        /// <param name="input">要验证的字符串</param>
        /// <returns></returns>
        public static bool IsTxtFileName(string input)
        {
            string regexString = @"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$";

            return Regex.IsMatch(input, regexString);

        }
        #endregion

        //验证是否为幼数 
        public bool IsDecimal(string strIn)
        {

            return Regex.IsMatch(strIn, @"[0].\d{1,2}|[1]");
        }



        ///// <summary>
        ///// 查抄当前IP是否是受限IP
        ///// </summary>
        ///// <param name="LimitedIP">受限的IP,体式如:192.168.1.110|212.235.*.*|232.*.*.*</param>
        ///// <returns>返回true暗示IP未受到限度</returns>
        //static public bool ValidateIP(string LimitedIP)
        //{
        //    string CurrentIP =
        //    if (LimitedIP == null || LimitedIP.Trim() == string.Empty)
        //        return true;
        //    LimitedIP.Replace(".", @"\.");
        //    LimitedIP.Replace("*", @"[^\.]{1,3}");
        //    Regex reg = new Regex(LimitedIP, RegexOptions.Compiled);
        //    Match match = reg.Match(CurrentIP);
        //    return !match.Success;
        //}
        /// <summary>
        /// 字段串是否为Null或为""(空)
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool StrIsNullOrEmpty(string str)
        {
            if (str == "" || String.IsNullOrEmpty(str))
                return true;

            return false;
        }
        /// <summary>
        /// 返回文件是否存在
        /// </summary>
        /// <param name="filename">文件名</param>
        /// <returns>是否存在</returns>
        public static bool FileExists(string filename)
        {
            return System.IO.File.Exists(filename);
        }
        /// <summary>
        /// 检测是否有Sql危险字符
        /// </summary>
        /// <param name="str">要判断字符串</param>
        /// <returns>判断了局</returns>
        public static bool IsSafeSqlString(string str)
        {
            return !Regex.IsMatch(str, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']");
        }

        #endregion

        #region 系统蹊径
        /// <summary>
        /// web 的根目录
        /// </summary>
        public static string HtmlURL = HttpContext.Current.Request.PhysicalApplicationPath;
        /// <summary>
        /// c#的根目录
        /// </summary>
        public static string BinURL = System.AppDomain.CurrentDomain.BaseDirectory;
        /// <summary>
        /// 返回服务器蹊径
        /// </summary>
        public static string ServerURL(string Path)
        {
            return HttpContext.Current.Server.MapPath(Path);
        }
       

        /// <summary>
        /// 获切当前绝对蹊径administrator
        /// </summary>
        /// <param name="strPath">指定的蹊径</param>
        /// <returns>绝对蹊径</returns>
        public static string GetMapPath(string strPath)
        {
            if (HttpContext.Current != null)
            {
                return HttpContext.Current.Server.MapPath(strPath);
            }
            else //非web法式引用a
            {
                return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
            }
        }

        #endregion

    


        /// <summary>
        /// 密码加密
        /// </summary>
        /// <param name="psw">密码</param>
        /// <returns></returns>
       public static object GetMD5(string psw)
        {
            return FormsAuthentication.HashPasswordForStoringInConfigFile(psw + psw, "md5").ToLower();

        }

        public static long getDirectorySize(string path)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(path);
            long sumSize = 0;
            foreach (FileSystemInfo fsInfo in dirInfo.GetFileSystemInfos())
            {
                if (fsInfo.Attributes.ToString().ToLower() == "directory")
                {
                    sumSize += getDirectorySize(fsInfo.FullName);
                }
                else
                {
                    FileInfo fiInfo = new FileInfo(fsInfo.FullName);
                    sumSize += fiInfo.Length;
                }
            }
            return sumSize;
        }
        public static long GetDirectoryLength(string dirPath)
        {
            if (!Directory.Exists(dirPath))
                return 0;
            long len = 0;
            DirectoryInfo di = new DirectoryInfo(dirPath);
            foreach (FileInfo fi in di.GetFiles())
            {
                len += fi.Length;
            }
            DirectoryInfo[] dis = di.GetDirectories();
            if (dis.Length > 0)
            {
                for (int i = 0; i < dis.Length; i++)
                {
                    len += GetDirectoryLength(dis[i].FullName);
                }
            }
            return len;
        }
        public static bool WriteFile(string strContent, string name, string username)
        {
            //  string path = HttpContext.Current.Server.MapPath("");
            Encoding code = Encoding.GetEncoding("gb2312");
            // 读取模板文件
            //string temp = HttpContext.Current.Server.MapPath("text.html");D:\test\admin\text.html
            string temp = HttpContext.Current.Server.MapPath("~/moban/text.html");
            //@"D:\\qingdaoxinxi\\text.html";
            string web_path = AppDomain.CurrentDomain.BaseDirectory.ToString();
            StreamReader sr = null;
            StreamWriter sw = null;
            string str = "";
            try
            {
                sr = new StreamReader(temp, code);
                str = sr.ReadToEnd(); // 读取文件
            }
            catch (Exception exp)
            {
                HttpContext.Current.Response.Write(exp.Message);
                HttpContext.Current.Response.End();
                sr.Close();
            }

            //DateTime.Now.ToString("yyyyMMddHHmmss")
            //string htmlfilename = path+"/" + name + ".html";
            //string htmlfilename = path.Replace(@"\admin", "") + @"\\" + name + ".html";
            StringBuilder sb = new StringBuilder();
            sb.Append(web_path);
            sb.Append("users/");
            sb.Append(username);
            sb.Append("/");
            sb.Append(name);
            string htmlfilename = sb.ToString();// web_path + @"/users/"+username + name;
            // 代替内容
            // 这时,模板文件已经读入到名称为str的变量中了
            //str = str.Replace("ShowArticle", strText); //模板页中的ShowArticle
            //str = str.Replace("biaoti", strText);
            str = str.Replace("content", strContent);
            //str = str.Replace("author", strAuthor);
            // 写文件
            try
            {
                sw = new StreamWriter(htmlfilename, false, code);
                sw.Write(str);
                sw.Flush();
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
                HttpContext.Current.Response.End();
            }
            finally
            {
                sw.Close();
                //HttpContext.Current.Response.Write("祝贺<a href='" + name + ".html' target=_blank>" + name + "</a>已经天生,保留在htm文件夹下!");

            }
            return true;
        }

       public static object getdate(object datetime)
        {
            string[] list = (datetime + "").Split(new string[] { "-", " ", "/" }, StringSplitOptions.None);

            string mouth = list[1];
            string day = list[2];
            if (mouth.Length == 1)
                mouth = "0" + mouth;
            if (day.Length == 1)
                day = "0" + day;
            return list[0] + "-" + mouth + "-" + day;

        }

        public static object getday(object datetime)
        {
            string[] list = (datetime + "").Split(new string[] { "-", " ", "/" }, StringSplitOptions.None);

            string day = list[2];

            if (day.Length == 1)
                day = "0" + day;
            return day;

        }

        public static object getdweek(object datetime)
        {
            string str = "";
            DateTime date = Convert.ToDateTime(datetime);
            switch (date.DayOfWeek.ToString())
            {
                case "Monday":
                    str = "星期一";
                    break;
                case "Tuesday":
                    str = "星期二";
                    break;
                case "Wednesday":
                    str = "星期三";
                    break;
                case "Thursday":
                    str = "星期四";
                    break;
                case "Friday":
                    str = "星期五";
                    break;
                case "Saturday":
                    str = "星期六";
                    break;
                case "Sunday":
                    str = "星期日";
                    break;
            }



            return str;
        }

        public static string FunStr(string str)
        {
            try
            {
                string fiter = "script,iframe,input,form";
                string[] s = fiter.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string lb in s)
                {
                    string reg = String.Format(@"</?{0}[^>]*?>", lb.Trim());
                    str = Regex.Replace(str, reg, "", RegexOptions.IgnoreCase);
                }

                str = str.Replace("&", "");
                str = str.Replace("<", "");
                str = str.Replace(">", "");
                str = str.Replace("'", "");
                str = str.Replace("*", "");
                str = str.Replace("\n", "");
                str = str.Replace("\r\n", "");
                str = str.Replace("?", "");
                str = str.Replace("select", "");
                str = str.Replace("insert", "");
                str = str.Replace("update", "");
                str = str.Replace("delete", "");
                str = str.Replace("create", "");
                str = str.Replace("drop", "");
                str = str.Replace("delcare", "");
                str = str.Replace("exec ", "");
                //  str = str.Replace("   ", "");

                str = str.Trim();
                if (str.Trim().ToString() == "")
                    str = "";
                return str;
            }
            catch (Exception)
            {
                return "";
            }

        }
        public static string FunBadStr(string str)
        {
            try
            {
                string fiter = "script,iframe,input,form";
                string[] s = fiter.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string lb in s)
                {
                    string reg = String.Format(@"</?{0}[^>]*?>", lb.Trim());
                    str = Regex.Replace(str, reg, "", RegexOptions.IgnoreCase);
                }

                str = str.Replace("select", "");
                str = str.Replace("insert", "");
                str = str.Replace("update", "");
                str = str.Replace("delete", "");
                str = str.Replace("create", "");
                str = str.Replace("drop", "");
                str = str.Replace("delcare", "");
                str = str.Replace("exec ", "");

                str = str.Trim();
                if (str.Trim().ToString() == "")
                    str = "";
                return str;
            }
            catch (Exception)
            {
                return "";
            }

        }

        public static string ClearHtml(string strHtml)
        {
            if (strHtml != "")
            {
                Regex regex = null;
                Match match = null;
                regex = new Regex(@"<\/?[^>]*>", RegexOptions.IgnoreCase);
                for (match = regex.Match(strHtml); match.Success; match = match.NextMatch())
                {
                    strHtml = strHtml.Replace(match.Groups[0].ToString(), "");
                }
            }
            return strHtml;
        }

        public static string getUrltoHtml(string Url)
        {
            string errorMsg = "";
            try
            {
                StreamReader reader = new StreamReader(WebRequest.Create(Url).GetResponse().GetResponseStream(), Encoding.GetEncoding("gb2312"));
                return reader.ReadToEnd();
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }
            return "";
        }

        public static string getcontent(int i)
        {
            string str = "";
            
            return str;
        }

       public static object getdate_mmdd(object datetime)
        {
            string[] list = (datetime + "").Split(new string[] { "-", " ", "/" }, StringSplitOptions.None);
            if (list.Length > 2)
            {
                string mouth = list[1];
                string day = list[2];
                if (mouth.Length == 1)
                    mouth = "0" + mouth;
                if (day.Length == 1)
                    day = "0" + day;
                return  mouth + "." + day;
            }
            else
                return "";
        }

       public static string getsessionvalue(string name)
       {
           string str = "";
           try
           {
              str= HttpContext.Current.Session[name] + "";
           }
           catch
           {
           }
           return str;
       }
       public static void setsession(string name,string val)
       {
           
                HttpContext.Current.Session[name]= val;          
       }

       public static string getdate_ymd(string strDate)
       {
           ////2011年11月7日(星期一)
           try
           {


               DateTime d = Convert.ToDateTime(strDate);
               string st = "";
               switch (d.DayOfWeek)
               {
                   case DayOfWeek.Friday:
                       st = "五";
                       break;
                   case DayOfWeek.Monday:
                       st = "一";
                       break;
                   case DayOfWeek.Saturday:
                       st = "六";
                       break;
                   case DayOfWeek.Sunday:
                       st = "日";
                       break;
                   case DayOfWeek.Thursday:
                       break;
                   case DayOfWeek.Tuesday:
                       st = "二";
                       break;
                   case DayOfWeek.Wednesday:
                       st = "三";
                       break;
               }
               string[] str = strDate.Split(new string[] { "-" }, StringSplitOptions.None);
               return str[0] + "年" + str[1] + "月" + str[2] + "日(星期" + st + ")";
               
           }
           catch (Exception)
           {
               HttpContext.Current.Response.Redirect("appointment.aspx");
           }
           return "";
       }

       public static string getDateTime()
       {
           string str = "";
           //try
           //{
           //    using (ConfigManager cm = new ConfigManager())
           //    {
           //        str = cm.getDate();
           //    }
           //}
           //catch
           //{
           //    str = DateTime.Now.ToString();
           //}
           return str;
       }

       public static string getdate_mmdd1(string datetime)
       {
           string[] list = (datetime + "").Split(new string[] { "-", " ", "/" }, StringSplitOptions.None);
           if (list.Length > 2)
           {
               string mouth = list[1];
               string day = list[2];
               if (mouth.Length == 1)
                   mouth = "0" + mouth;
               if (day.Length == 1)
                   day = "0" + day;
               DateTime d = Convert.ToDateTime(datetime);
               string st = "";
               switch (d.DayOfWeek)
               {
                   case DayOfWeek.Friday:
                       st = "五";
                       break;
                   case DayOfWeek.Monday:
                       st = "一";
                       break;
                   case DayOfWeek.Saturday:
                       st = "六";
                       break;
                   case DayOfWeek.Sunday:
                       st = "日";
                       break;
                   case DayOfWeek.Thursday:
                       break;
                   case DayOfWeek.Tuesday:
                       st = "二";
                       break;
                   case DayOfWeek.Wednesday:
                       st = "三";
                       break;
               }
               return mouth + "." + day + " 星期" + st;
           }
           else
               return "";
       }

       //public static void showalert(string alertcontent, string links)
       //{
       //    StringBuilder str = new StringBuilder();
       //    str.Append("<script>");
       //    str.Append("alert('"+alertcontent+"')");
       //    if (links.Length > 0)
       //    {
       //        str.Append(",location.href='"+links+"';");
       //    }
       //    str.Append("</script>");
       //    System.Web.UI.Page.RegisterStartupScript("", str.ToString());
       //}

       public static void postemail(string email)
       {
           
       }

       public static void postemail(string name, string title, string content)
       {
          
       }




       



       public static object getdate(object datetime,string s)
       {
           string[] list = (datetime + "").Split(new string[] { "-", " ", "/" }, StringSplitOptions.None);

           string mouth = list[1];
           string day = list[2];
           if (mouth.Length == 1)
               mouth = "0" + mouth;
           if (day.Length == 1)
               day = "0" + day;
           return list[0] + s + mouth + s + day;

       }

       public static string getcontent(string tn, int i)
       {
           string str = "";
           try
           {
               using (Managers cm = new Managers())
               {
                   str = cm.getvalue(tn, "[values]", "id=" + i, "") + "";
               }
           }
           catch
           {
           }
           return str;
       }
    }



#line default
#line hidden