예제 #1
0
		/// <summary>
		/// Writes Core legacy options and their values to XML text stream.
		/// Skips options whose values are the same as default values of Phalanger.
		/// </summary>
		/// <param name="writer">XML writer.</param>
		/// <param name="options">A hashtable containing PHP names and option values. Consumed options are removed from the table.</param>
		/// <param name="writePhpNames">Whether to add "phpName" attribute to option nodes.</param>
		public static void CoreOptionsToXml(XmlTextWriter writer, Hashtable options, bool writePhpNames) // GENERICS: <string,string>
		{
			if (writer == null)
				throw new ArgumentNullException("writer");
			if (options == null)
				throw new ArgumentNullException("options");

			ApplicationConfiguration app = new ApplicationConfiguration();
			GlobalConfiguration global = new GlobalConfiguration();
			LocalConfiguration local = new LocalConfiguration();
			PhpIniXmlWriter ow = new PhpIniXmlWriter(writer, options, writePhpNames);

			ow.StartSection("compiler");
			ow.WriteOption("short_open_tag", "ShortOpenTag", true, app.Compiler.ShortOpenTags);
			ow.WriteOption("asp_tags", "AspTags", false, app.Compiler.AspTags);

			ow.StartSection("variables");
			//ow.WriteOption("zend.ze1_compatibility_mode", "ZendEngineV1Compatible", false, local.Variables.ZendEngineV1Compatible);
			ow.WriteOption("register_globals", "RegisterGlobals", false, global.GlobalVariables.RegisterGlobals);
			ow.WriteOption("register_argc_argv", "RegisterArgcArgv", true, global.GlobalVariables.RegisterArgcArgv);
			ow.WriteOption("register_long_arrays", "RegisterLongArrays", true, global.GlobalVariables.RegisterLongArrays);
			ow.WriteOption("variables_order", "RegisteringOrder", "EGPCS", local.Variables.RegisteringOrder);
			//ow.WriteOption("magic_quotes_gpc", "QuoteGpcVariables", true, global.GlobalVariables.QuoteGpcVariables);
			ow.WriteOption("magic_quotes_runtime", "QuoteRuntimeVariables", false, local.Variables.QuoteRuntimeVariables);
			//ow.WriteOption("magic_quotes_sybase", "QuoteInDbManner", false, local.Variables.QuoteInDbManner);
			ow.WriteOption("unserialize_callback_func", "DeserializationCallback", null, local.Variables.DeserializationCallback);

			ow.StartSection("output-control");
			ow.WriteOption("output_buffering", "OutputBuffering", false, local.OutputControl.OutputBuffering);
			ow.WriteOption("output_handler", "OutputHandler", null, local.OutputControl.OutputHandler);
			ow.WriteOption("implicit_flush", "ImplicitFlush", false, local.OutputControl.ImplicitFlush);
			ow.WriteOption("default_mimetype", "ContentType", "text/html", DefaultMimetype);
			ow.WriteOption("default_charset", "Charset", "", DefaultCharset);

			ow.StartSection("request-control");
			ow.WriteOption("max_execution_time", "ExecutionTimeout", 30, local.RequestControl.ExecutionTimeout);
			ow.WriteOption("ignore_user_abort", "IgnoreUserAbort", false, local.RequestControl.IgnoreUserAbort);

			ow.StartSection("error-control");
			ow.WriteEnumOption("error_reporting", "ReportErrors", (int)PhpErrorSet.AllButStrict, (int)local.ErrorControl.ReportErrors, typeof(PhpError));
			ow.WriteOption("display_errors", "DisplayErrors", true, local.ErrorControl.DisplayErrors);
			ow.WriteOption("html_errors", "HtmlMessages", true, local.ErrorControl.HtmlMessages);
			ow.WriteOption("docref_root", "DocRefRoot", null, local.ErrorControl.DocRefRoot.ToString());
			ow.WriteOption("docref_ext", "DocRefExtension", null, local.ErrorControl.DocRefExtension);
			ow.WriteErrorLog("error_log", null, local.ErrorControl.SysLog, local.ErrorControl.LogFile);
			ow.WriteOption("log_errors", "EnableLogging", false, local.ErrorControl.EnableLogging);
			ow.WriteOption("error_prepend_string", "ErrorPrependString", null, local.ErrorControl.ErrorPrependString);
			ow.WriteOption("error_append_string", "ErrorAppendString", null, local.ErrorControl.ErrorAppendString);

			ow.StartSection("session-control");
			ow.WriteOption("session.auto_start", "AutoStart", false, local.Session.AutoStart);
			ow.WriteOption("session.save_handler", "Handler", "files", local.Session.Handler.Name);

			ow.StartSection("assertion");
			ow.WriteOption("assert.active", "Active", true, local.Assertion.Active);
			ow.WriteOption("assert.warning", "ReportWarning", true, local.Assertion.ReportWarning);
			ow.WriteOption("assert.bail", "Terminate", false, local.Assertion.Terminate);
			ow.WriteOption("assert.quiet_eval", "Quiet", false, local.Assertion.Quiet);
			ow.WriteOption("assert.callback", "Callback", null, local.Assertion.Callback);

			ow.StartSection("safe-mode");
			ow.WriteOption("safe_mode", "Enabled", false, global.SafeMode.Enabled);
			ow.WriteOption("open_basedir", "AllowedPathPrefixes", null, global.SafeMode.GetAllowedPathPrefixesJoin());
			ow.WriteOption("safe_mode_exec_dir", "ExecutionDirectory", null, global.SafeMode.ExecutionDirectory);

			ow.StartSection("posted-files");
			ow.WriteOption("file_uploads", "Accept", true, global.PostedFiles.Accept);
			ow.WriteOption("upload_tmp_dir", "TempPath", null, global.PostedFiles.TempPath);

			ow.StartSection("file-system");
			ow.WriteOption("allow_url_fopen", "AllowUrlFopen", true, local.FileSystem.AllowUrlFopen);
			ow.WriteOption("default_socket_timeout", "DefaultSocketTimeout", 60, local.FileSystem.DefaultSocketTimeout);
			ow.WriteOption("user_agent", "UserAgent", null, local.FileSystem.UserAgent);
			ow.WriteOption("from", "AnonymousFtpPassword", null, local.FileSystem.AnonymousFtpPassword);
			ow.WriteOption("include_path", "IncludePaths", ".", local.FileSystem.IncludePaths);

			ow.WriteEnd();
		}
예제 #2
0
		/// <summary>
		/// Writes Phalanger BCL legacy options and their values to XML text stream.
		/// Skips options whose values are the same as default values of Phalanger.
		/// </summary>
		/// <param name="writer">XML writer.</param>
		/// <param name="options">A hashtable containing PHP names and option values. Consumed options are removed from the table.</param>
		/// <param name="writePhpNames">Whether to add "phpName" attribute to option nodes.</param>
		public static void LegacyOptionsToXml(XmlTextWriter writer, Hashtable options, bool writePhpNames) // GENERICS:<string,string>
		{
			if (writer == null)
				throw new ArgumentNullException("writer");
			if (options == null)
				throw new ArgumentNullException("options");

			LibraryConfiguration local = new LibraryConfiguration();
			PhpIniXmlWriter ow = new PhpIniXmlWriter(writer, options, writePhpNames);

			ow.StartSection("session");
			ow.WriteOption("session.cache_limiter", "CacheLimiter", "no-cache", PhpSession.DefaultCacheLimiter);
			ow.WriteOption("session.cache_expire", "CacheExpire", 180, PhpSession.DefaultCacheExpire);
			ow.WriteOption("session.serialize_handler", "Serializer", "php", local.Session.Serializer.Name);
			ow.WriteOption("session.gc_probability", "GcProbability", 1, local.Session.GcProbability);
			ow.WriteOption("session.gc_divisor", "GcDivisor", 100, local.Session.GcDivisor);
			ow.WriteOption("session.gc_maxlifetime", "GcMaxLifetime", 1440, local.Session.GcMaxLifetime);
			ow.WriteOption("session.save_path", "SavePath", "", local.Session.SavePath);
			ow.WriteOption("session.cookie_lifetime", "CookieLifetime", 0, PhpSession.DefaultCookieLifetime);
			ow.WriteOption("session.cookie_path", "CookiePath", "/", PhpSession.DefaultCookiePath);
			ow.WriteOption("session.cookie_domain", "CookieDomain", "", PhpSession.DefaultCookieDomain);
			ow.WriteOption("session.cookie_secure", "CookieSecure", false, PhpSession.DefaultCookieSecure);

			ow.StartSection("mailer");
			ow.WriteOption("SMTP", "SmtpServer", "localhost", local.Mailer.SmtpServer);
			ow.WriteOption("smtp_port", "SmtpPort", 25, local.Mailer.SmtpPort);
			ow.WriteOption("sendmail_from", "DefaultFromHeader", null, local.Mailer.DefaultFromHeader);

			ow.StartSection("highlighting");
			ow.WriteOption("highlight.bg", "Background", "#FFFFFF", local.Highlighting.Background);
			ow.WriteOption("highlight.string", "String", "#DD0000", local.Highlighting.String);
			ow.WriteOption("highlight.comment", "Comment", "#FF8000", local.Highlighting.Comment);
			ow.WriteOption("highlight.keyword", "Keyword", "#007700", local.Highlighting.Keyword);
			ow.WriteOption("highlight.html", "Html", "#000000", local.Highlighting.Html);
			ow.WriteOption("highlight.default", "Default", "#0000BB", local.Highlighting.Default);

			ow.StartSection("date");
			ow.WriteOption("date.default_latitude", "Latitude", 31.7667, local.Date.Latitude);
			ow.WriteOption("date.default_longitude", "Longitude", 35.2333, local.Date.Longitude);
			ow.WriteOption("date.sunrise_zenith", "SunriseZenith", 90.83, local.Date.SunriseZenith);
			ow.WriteOption("date.sunset_zenith", "SunsetZenith", 90.83, local.Date.SunsetZenith);
			ow.WriteOption("date.timezone", "TimeZone", null, local.Date.TimeZone.StandardName);

			ow.WriteEnd();
		}