/**
     * Notice that automatic compression doesn't work!
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        if (directive == "compile")
        {
            _mode = CompositeScriptMode.COMPILE;
        }
        else if (CookieHandler.Get("mode") == "develop")
        {
            _mode = CompositeScriptMode.DEVELOP;
        }
        else
        {
            _mode = CompositeScriptMode.OPERATE;
        }

        string folderPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "Composite");

        switch (type)
        {
        case "top":
            _defaultscripts = ScriptHandler.GetTopScripts(_mode, folderPath);

            break;

        case "sub":
            _defaultscripts = ScriptHandler.GetSubScripts(_mode, folderPath);
            break;
        }
    }
        protected override void Render(HtmlTextWriter writer)
        {
            string root = UrlUtils.AdminRootPath;

            if (Directive == "compile")
            {
                StyleCompiler.Compile(HostingEnvironment.MapPath(root + "/styles/styles.css"),
                                      HostingEnvironment.MapPath(root + "/styles/styles_compiled.css"));

                StyleCompiler.Compile(HostingEnvironment.MapPath(root + "/skins/skin.css"),
                                      HostingEnvironment.MapPath(root + "/skins/skin_compiled.css"));

                return;
            }

            bool isInDevelopMode = CookieHandler.Get("mode") == "develop";

            if (isInDevelopMode)
            {
                writer.WriteLine(stylesheet(root + "/styles/styles.css.aspx"));
                writer.WriteLine(stylesheet(root + "/skins/skin.css.aspx"));
            }
            else
            {
                writer.WriteLine(stylesheet(root + "/styles/styles_compiled.css.aspx"));
                writer.WriteLine(stylesheet(root + "/skins/skin_compiled.css.aspx"));
            }

            writer.WriteLine(stylesheet(root + "/skins/dynamicskin.css.aspx"));
        }
Beispiel #3
0
        /**
         * Process request.
         */
        public void ProcessRequest(HttpContext context)
        {
            if (CookieHandler.Get("mode") == "develop")
            {
                context.Response.Cache.SetExpires(DateTime.Now.AddMonths(-1));
                context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            }
            else
            {
                context.Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
                context.Response.Cache.SetCacheability(HttpCacheability.Private);
            }

            string webPath  = context.Request.Path;
            string cssPath  = webPath.Substring(0, webPath.LastIndexOf(".aspx"));
            string filePath = context.Server.MapPath(cssPath);

            context.Response.ContentType = "text/css";

            State  state  = new State(context);
            User   user   = new User(context);
            Colors colors = new Colors(user);

            if (C1File.Exists(filePath))
            {
                var sb = new StringBuilder();

                string[] lines = C1File.ReadAllLines(filePath);
                foreach (string line in lines)
                {
                    // context.Response.Write ( "/*" + line.ToString() + "*/" + "\n" );
                    string result = Parse(line, user, state, colors);
                    if (result != null)
                    {
                        sb.Append(result).Append("\n");
                    }
                }

                context.Response.Write(sb.ToString());
            }
            else
            {
                // Make it obvious that there is some kind of css fåk up.
                context.Response.Write("body { border: 1px solid red ! important; }");
                context.Response.StatusCode = 404;
            }
        }
    protected void Page_Init(object sender, EventArgs e)
    {
        /*
         * Set the browsing mode cookie.
         */
        string mode = Request.QueryString["mode"];

        if (String.IsNullOrEmpty(mode))
        {
            CookieHandler.Set("mode", "operate");
        }
        else
        {
            CookieHandler.Set("mode", mode == "develop" ? "develop" : "operate");
        }

        /*
         * Set the version cookie. If version doesn't match
         * last session version, redirect to upgraded page.
         */
        string nowversion = Composite.RuntimeInformation.ProductVersion.ToString();

        bool isUpdated = false;

        if (CookieHandler.Get("CompositeVersionString") != null)
        {
            string oldversion = CookieHandler.Get("CompositeVersionString");
            if (nowversion != oldversion)
            {
                var installationAge = DateTime.Now - SystemSetupFacade.GetFirstTimeStart();
                isUpdated = installationAge.TotalMinutes > 5;
            }
        }

        CookieHandler.Set("CompositeVersionString", nowversion, DateTime.Now.AddYears(23));

        if ((RuntimeInformation.IsDebugBuild == false) && (isUpdated == true))
        {
            string url = "updated.aspx";
            if (CookieHandler.Get("mode") == "develop")
            {
                url += "?mode=develop"; // TODO: copy entire querystring (no intellisense here)!
            }
            Response.Redirect(url);
        }
    }
        private static string GetUsernameFromCookie()
        {
            try
            {
                string cookieValue = CookieHandler.Get(AuthCookieName);

                if (!string.IsNullOrEmpty(cookieValue))
                {
                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookieValue);

                    if (!ticket.Expired && (ticket.Expiration - DateTime.Now) < TempTicketMinAge)
                    {
                        StoreUsernameImpl(ticket.Name, false);
                    }

                    return(ticket.Name);
                }
            }
            catch (CryptographicException)
            {
            }
            return(null);
        }
Beispiel #6
0
            public override void Close()
            {
                var httpContext = HttpContext.Current;

                try
                {
                    if (!_buffer.CanRead || (_buffer.Length == 0))
                    {
                        return;
                    }

                    MemoryStream output = _buffer;

                    if (httpContext.Response.StatusCode == 200)
                    {
                        try
                        {
                            string mode     = CookieHandler.Get("mode");
                            string browser  = "undefined";
                            string platform = "undefined";

                            string userAgent = httpContext.Request.UserAgent;

                            if (!userAgent.IsNullOrEmpty())
                            {
                                if (userAgent.IndexOf("Gecko", StringComparison.Ordinal) > -1 /*&& !userAgent.Contains("Trident")*/)
                                {
                                    browser = "mozilla";
                                }
                                else
                                {
                                    browser = "explorer";
                                }
                                if (userAgent.IndexOf("Windows NT", StringComparison.Ordinal) > -1)
                                {
                                    platform = "vista";
                                }
                                else if (userAgent.IndexOf("OS X", StringComparison.Ordinal) > -1)
                                {
                                    platform = "osx";
                                }
                                else
                                {
                                    platform = "default";
                                }
                            }

                            output = Transform(_buffer, mode, browser, platform);
                        }
                        catch (Exception ex)
                        {
                            Log.LogCritical("AdministrativeOutputTransformationHttpModule", ex);
                        }
                    }

                    if (output.Position != 0)
                    {
                        output.Seek(0, SeekOrigin.Begin);
                    }
                    output.WriteTo(_responseOutputStream);
                }
                finally
                {
                    _responseOutputStream.Close();
                }
            }