/// <summary>
        /// Constructs an HTML table with the file statistics
        /// and stores that information into the builder.
        /// </summary>
        /// <param name="builder">The builder to accumulate data</param>
        /// <param name="bytes">File bytes</param>
        /// <param name="lines">File lines</param>
        /// <param name="created">File creation date</param>
        /// <param name="modified">File last modification date</param>
        public static void TildeFilePathStatisticsTable
            (StringBuilder builder,
            long bytes,
            long lines,
            DateTime created,
            DateTime modified)
        {
            string a = "";
            string b = "";

            builder.Append("<table class='filedata'>\n");

            a = bytes.ToString();
            HTML_Tools.AppendTableRow(builder, "Bytes", a);

            a = lines.ToString();
            HTML_Tools.AppendTableRow(builder, "Lines", a);

            a = created.ToYMD();
            b = created.ToHMS();

            HTML_Tools.AppendTableRow(builder, "Created", a, b);

            a = modified.ToYMD();
            b = modified.ToHMS();

            HTML_Tools.AppendTableRow(builder, "Modified", a, b);

            builder.Append("</table>\n<br />\n");
        }
        public void ProcessRequest(HttpContext context)
        {
            string title = AutoImageTools.autoImageTitle;

            string headMarkup =
                AutoImageTools.autoImageCssStyle;

            string bodyMarkup =
                AutoImageTools.MakeAutoImageMarkup(context, onlyPublic);

            string markup =
                HTML_Tools.MakePageMarkup
                    (null, title, headMarkup, null, bodyMarkup);

            context.Response.ContentType =
                HTML_Tools.htmlContentType;

            context.Response.Write(markup);
        }
        public void ProcessRequest(HttpContext context)
        {
            string title = AutoFileTools.autoFileTitle;

            string headMarkup =
                HttpContextTools.MakeStyleSheetLinks(context)
                +
                HttpContextTools.MakeJavascriptReferences(context);

            string bodyMarkup =
                AutoFileTools.MakeAutoFileMarkup(context, onlyPublic);

            string markup =
                HTML_Tools.MakePageMarkup
                    (null, title, headMarkup, null, bodyMarkup);

            context.Response.ContentType =
                HTML_Tools.htmlContentType;

            context.Response.Write(markup);
        }
        /// <summary>
        /// Make the body markup for the AutoFile utility.
        /// </summary>
        /// <param name="context">Web site HttpContext object</param>
        /// <param name="onlyPublic">If true restrict to public subdirectories</param>
        public static string MakeAutoFileMarkup
            (HttpContext context, bool onlyPublic)
        {
            StringBuilder builder = new StringBuilder();

            string markup1 = MakeServableListMarkup
                                 (context, null);

            string markup2 = MakeFileListMarkup
                                 (context, FileTools.TEXT, null);

            string markup3 = MakeFileListMarkup
                                 (context, FileTools.IMAGE, null);

            string markup4 = MakeFileListMarkup
                                 (context, FileTools.OTHER, null);

            string markup5 = MakeSubdirectoryLinkMarkup
                                 (context, autoFileName, null, onlyPublic);

            string markup6 = MakeParentDirectoryLinkMarkup
                                 (context, autoFileName);

            HTML_Tools.AppendMarkupWithHR(builder, markup1);
            HTML_Tools.AppendMarkupWithHR(builder, markup2);
            HTML_Tools.AppendMarkupWithHR(builder, markup3);
            HTML_Tools.AppendMarkupWithHR(builder, markup4);
            HTML_Tools.AppendMarkupWithHR(builder, markup5);

            if (builder.Length == 0)
            {
                HTML_Tools.AppendMarkupWithHR
                    (builder, errorEmptyDirectory);
            }

            HTML_Tools.AppendMarkupWithHR(builder, markup6);

            return(builder.ToString());
        }
Exemple #5
0
        /*
         * The main method of this IHttpHandler.
         */
        public void ProcessRequest(HttpContext context)
        {
            string url = context.Request.Url.OriginalString;

            string embeddedUrl = GetEmbeddedParameter(url, "url=", true);

            HttpWebResponse response = null;

            if (!StringTools.IsTrivial(embeddedUrl))
            {
                response = GetResponse(embeddedUrl);
            }

            if (response == null)
            {
                ProcessRequestError(context, embeddedUrl, "");
                return;
            }


            int status = (int)response.StatusCode;

            context.Response.StatusCode = status;

            if ((status < 200) || (status > 299))
            {
                ProcessRequestError(context, embeddedUrl, "Status = " + status);
            }


            string host = response.Headers.Get("Host");

            if (StringTools.IsTrivial(host))
            {
                try
                {
                    Uri uri = new Uri(embeddedUrl);
                    host = uri.Host;
                }
                catch { }
            }

            if (!StringTools.IsTrivial(host))
            {
                context.Response.AppendHeader("Host", host);
            }


            try
            {
                using (Stream stream = response.GetResponseStream())
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        string content = reader.ReadToEnd();

                        if (!StringTools.IsTrivial(content))
                        {
                            if (usePreTag(url))
                            {
                                context.Response.ContentType = "text/html";
                                content = HTML_Tools.FeedbackData(content);
                            }
                            else
                            if (useXml(url))
                            {
                                context.Response.ContentType = "text/xml";
                            }
                            else
                            {
                                context.Response.ContentType = "text/plain";
                            }

                            context.Response.Write(content);
                        }
                        else
                        {
                            context.Response.ContentType = "text/plain";
                            context.Response.Write("");
                        }
                    }
                }
            }
            catch
            {
                ProcessRequestError(context, embeddedUrl, "Error in reading Url content");
            }
        }