Пример #1
0
        public virtual void Throw(string message, string title, string links, string autojump, bool showback)
        {
            HttpContext.Current.Response.ContentType = "text/html";
            HttpContext.Current.Response.AddHeader("Content-Type", "text/html");
            StringBuilder builder = new StringBuilder(this.template);

            builder.Replace("{$Charset}", Encoding.UTF8.BodyName);
            builder.Replace("{$Message}", TextUtility.TextEncode(message));
            builder.Replace("{$Title}", ((title == null) || (title == "")) ? "发生了系统错误, 错误信息已经被记录, 请联系管理员" : title);
            if ((links != null) && (links != ""))
            {
                string[] strArray = links.Split(new char[] { '|' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    string[] strArray2 = strArray[i].Split(new char[] { ',' });
                    if (strArray2.Length > 1)
                    {
                        if (strArray2[1].Trim() == "RefHref")
                        {
                            strArray2[1] = Utility.Referrer;
                        }
                        if ((strArray2[1] != string.Empty) && (strArray2[1] != null))
                        {
                            string str = "<a href='" + strArray2[1] + "'";
                            if (strArray2.Length == 3)
                            {
                                str = str + " target='" + strArray2[2].Trim() + "'";
                            }
                            if (strArray2[0].Trim() == "RefText")
                            {
                                strArray2[0] = TextUtility.TextEncode(Utility.Referrer);
                            }
                            str = str + ">" + strArray2[0].Trim() + "</a>\r\n\t\t\t\t";
                            builder.Replace("{$Links}", str + "{$Links}");
                        }
                    }
                }
            }
            if ((autojump != null) && (autojump != string.Empty))
            {
                builder.Replace("{$AutoJump}", "<meta http-equiv='refresh' content='3; url=" + ((autojump == "back") ? "javascript:history.back()" : autojump) + "' />");
            }
            else
            {
                builder.Replace("{$AutoJump}", "<!-- no jump -->");
            }
            if (showback)
            {
                builder.Replace("{$Links}", "<a href='javascript:history.back()'>返回前一页</a>");
            }
            else
            {
                builder.Replace("{$Links}", "<!-- no back -->");
            }
            this.Echo(builder.ToString());
            this.End();
        }
Пример #2
0
        public static string EmailEncode(string originalStr)
        {
            string text = TextUtility.TextEncode(originalStr).Replace("@", "&#64;").Replace(".", "&#46;");

            return(TextUtility.JoinString("<a href='mailto:", new string[]
            {
                text,
                "'>",
                text,
                "</a>"
            }));
        }