示例#1
0
            static SessionSection()
            {
                // load configuration into the context every request
                RequestContext.RequestBegin += () =>
                {
                    var config = LibraryConfiguration.Local;
                    if (config == null)
                    {
                        return;
                    }

                    RequestContext context = RequestContext.CurrentContext;
                    if (context == null)
                    {
                        return;
                    }

                    HttpCookie cookie = AspNetSessionHandler.GetCookie(context.HttpContext);

                    if (config.Session.CacheExpire >= 0)
                    {
                        context.HttpContext.Session.Timeout = config.Session.CacheExpire;
                    }

                    if (config.Session.CacheLimiter != null)
                    {
                        PhpSession.CacheLimiter(config.Session.CacheLimiter);
                    }

                    if (cookie != null)
                    {
                        if (config.Session.CookieLifetime >= 0)
                        {
                            context.SessionCookieLifetime = config.Session.CookieLifetime;
                        }

                        if (config.Session.CookiePath != null)
                        {
                            cookie.Path = config.Session.CookiePath;
                        }

                        if (config.Session.CookieDomain != null)
                        {
                            cookie.Domain = config.Session.CookieDomain;
                        }

                        cookie.Secure = config.Session.CookieSecure;
                    }
                };
            }
示例#2
0
        /// <summary>
        /// Gets, sets, or restores a value of a legacy configuration option.
        /// </summary>
        private static object GetSetRestore(LocalConfiguration config, string option, object value, IniAction action)
        {
            LibraryConfiguration local    = (LibraryConfiguration)config.GetLibraryConfig(LibraryDescriptor.Singleton);
            LibraryConfiguration @default = DefaultLocal;

            switch (option)
            {
            case "sendmail_from": return(PhpIni.GSR(ref local.Mailer.DefaultFromHeader, @default.Mailer.DefaultFromHeader, value, action));

            case "SMTP": return(PhpIni.GSR(ref local.Mailer.SmtpServer, @default.Mailer.SmtpServer, value, action));

            case "smtp_port": return(PhpIni.GSR(ref local.Mailer.SmtpPort, @default.Mailer.SmtpPort, value, action));

            case "mail.add_x_header": return(PhpIni.GSR(ref local.Mailer.AddXHeader, @default.Mailer.AddXHeader, value, action));

            case "highlight.bg": return(PhpIni.GSR(ref local.Highlighting.Background, @default.Highlighting.Background, value, action));

            case "highlight.comment": return(PhpIni.GSR(ref local.Highlighting.Comment, @default.Highlighting.Comment, value, action));

            case "highlight.default": return(PhpIni.GSR(ref local.Highlighting.Default, @default.Highlighting.Default, value, action));

            case "highlight.html": return(PhpIni.GSR(ref local.Highlighting.Html, @default.Highlighting.Html, value, action));

            case "highlight.keyword": return(PhpIni.GSR(ref local.Highlighting.Keyword, @default.Highlighting.Keyword, value, action));

            case "highlight.string": return(PhpIni.GSR(ref local.Highlighting.String, @default.Highlighting.String, value, action));

            case "session.serialize_handler": return(PhpSession.GsrSerializer(local, @default, value, action));

            case "session.cache_expire": return(PhpSession.GsrCacheExpire(value, action));

            case "session.cache_limiter": return(PhpSession.GsrCacheLimiter(value, action));

            case "session.save_path": return(PhpIni.GSR(ref local.Session.SavePath, @default.Session.SavePath, value, action));

            case "session.gc_maxlifetime": return(PhpIni.GSR(ref local.Session.GcMaxLifetime, @default.Session.GcMaxLifetime, value, action));

            case "session.gc_probability": return(PhpIni.GSR(ref local.Session.GcProbability, @default.Session.GcProbability, value, action));

            case "session.gc_divisor": return(PhpIni.GSR(ref local.Session.GcDivisor, @default.Session.GcDivisor, value, action));

            case "session.cookie_lifetime": return(PhpSession.GsrCookieLifetime(value, action));

            case "session.cookie_path": return(PhpSession.GsrCookiePath(value, action));

            case "session.cookie_domain": return(PhpSession.GsrCookieDomain(value, action));

            case "session.cookie_secure": return(PhpSession.GsrCookieSecure(value, action));

            case "date.default_latitude": return(PhpIni.GSR(ref local.Date.Latitude, @default.Date.Latitude, value, action));

            case "date.default_longitude": return(PhpIni.GSR(ref local.Date.Longitude, @default.Date.Longitude, value, action));

            case "date.sunrise_zenith": return(PhpIni.GSR(ref local.Date.SunriseZenith, @default.Date.SunriseZenith, value, action));

            case "date.sunset_zenith": return(PhpIni.GSR(ref local.Date.SunsetZenith, @default.Date.SunsetZenith, value, action));

            case "date.timezone": return(PhpTimeZone.GsrTimeZone(local, @default, value, action));
            }

            Debug.Fail("Option '" + option + "' is supported but not implemented.");
            return(null);
        }