Exemple #1
0
        public static string ini_set(Context ctx, string option, PhpValue value)
        {
            var old = StandardPhpOptions.TryGetSet(ctx, ctx.Configuration, option, value, StandardPhpOptions.IniAction.Set, out var error);

            if (error)
            {
                return(null);
            }
            else
            {
                return(old.ToString(ctx));
            }
        }
Exemple #2
0
        public static string ini_get(Context ctx, string option)
        {
            var result = StandardPhpOptions.TryGetSet(ctx, ctx.Configuration, option, PhpValue.Null, StandardPhpOptions.IniAction.Get, out var error);

            if (error)
            {
                return(null);
            }
            else
            {
                return(result.ToString(ctx));
            }
        }
Exemple #3
0
        /// <summary>
        /// Restores the value of a configuration option to its global value.
        /// No value is returned.
        /// </summary>
        /// <param name="ctx">Runtime context.</param>
        /// <param name="option">The option name (case sensitive).</param>
        public static void ini_restore(Context ctx, string option)
        {
            var def = StandardPhpOptions.GetOption(option);

            if (def.Gsr != null)
            {
                var @default = def.Gsr(ctx, ctx.Configuration.Parent, option, PhpValue.Null, StandardPhpOptions.IniAction.Get);
                def.Gsr(ctx, ctx.Configuration, option, @default, StandardPhpOptions.IniAction.Set);
            }
            else
            {
                // TODO: Err, see TryGetSet() errors
                throw new ArgumentException("option_not_supported");
            }
        }
Exemple #4
0
        private static void Configuration(HtmlTagWriter container, Context ctx)
        {
            container.EchoTag("h1", "Configuration");

            var extensions = Context.GetLoadedExtensions();

            foreach (string ext in extensions)
            {
                container.EchoTag("h2", ext);
            }

            // TODO: extensions configuration
            var options = StandardPhpOptions.DumpOptions(ctx, null);

            foreach (var extensionopt in options.GroupBy(opt => opt.ExtensionName))
            {
            }
        }
Exemple #5
0
        static void Configuration(Context ctx, InfoWriter writer)
        {
            writer.Header(InfoResources.Configuration);

            foreach (string ext in Context.GetLoadedExtensions())
            {
                //container.EchoTag("h2", ext);
            }

            // TODO: extensions configuration
            var options = StandardPhpOptions.DumpOptions(ctx, null);
            foreach (var opts in options.GroupBy(opt => opt.ExtensionName))
            {
                foreach (var o in opts)
                {
                    //yield return new[] { o.Name, o.LocalValue.ToString(ctx), o.DefaultValue.ToString(ctx) };
                }
            }
        }
Exemple #6
0
            /// <summary>
            /// Gets or sets a value of a legacy configuration option.
            /// </summary>
            private static PhpValue GetSet(Context ctx, IPhpConfigurationService config, string option, PhpValue value, IniAction action)
            {
                var local = config.Get <IconvConfig>();

                if (local == null)
                {
                    return(PhpValue.False);
                }

                switch (option)
                {
                case "iconv.input_encoding":
                    return(StandardPhpOptions.GetSet(ref local.InputEncoding, "ISO-8859-1", value, action));

                case "iconv.internal_encoding":
                    return(StandardPhpOptions.GetSet(ref local.InternalEncoding, "ISO-8859-1", value, action));

                case "iconv.output_encoding":
                    return(StandardPhpOptions.GetSet(ref local.OutputEncoding, "ISO-8859-1", value, action));
                }

                return(PhpValue.False);
            }
Exemple #7
0
            /// <summary>
            /// Gets or sets a value of a legacy configuration option.
            /// </summary>
            private static PhpValue GetSet(Context ctx, IPhpConfigurationService config, string option, PhpValue value, IniAction action)
            {
                var local = config.Get <IconvConfig>();

                if (local == null)
                {
                    return(PhpValue.Null);
                }

                switch (option)
                {
                case "iconv.input_encoding":
                    return((PhpValue)StandardPhpOptions.GetSet(ref local.InputEncoding, "ISO-8859-1", value, action));

                case "iconv.internal_encoding":
                    return((PhpValue)StandardPhpOptions.GetSet(ref local.InternalEncoding, "ISO-8859-1", value, action));

                case "iconv.output_encoding":
                    return((PhpValue)StandardPhpOptions.GetSet(ref local.OutputEncoding, "ISO-8859-1", value, action));
                }

                Debug.Fail("Option '" + option + "' is not currently supported.");
                return(PhpValue.Null);
            }
Exemple #8
0
 /// <summary>
 /// Retrieves an array of configuration entries of a specified extension.
 /// </summary>
 /// <param name="ctx">Runtime context.</param>
 /// <param name="extension">Optional. The PHP internal extension name.</param>
 /// <param name="details">Retrieve details settings or only the current value for each setting. Default is TRUE.</param>
 /// <remarks>
 /// For each supported configuration option an entry is added to the resulting array.
 /// The key is the name of the option and the value is an array having three entries:
 /// <list type="bullet">
 ///   <item><c>global_value</c> - global value of the option</item>
 ///   <item><c>local_value</c> - local value of the option</item>
 ///   <item><c>access</c> - 7 (PHP_INI_ALL), 6 (PHP_INI_PERDIR | PHP_INI_SYSTEM) or 4 (PHP_INI_SYSTEM)</item>
 /// </list>
 /// </remarks>
 public static PhpArray ini_get_all(Context ctx, string extension = null, bool details = true)
 {
     return(StandardPhpOptions.GetAllOptionStates(ctx, extension, new PhpArray()));
 }