Пример #1
0
        private void LoadConfig()
        {
            string errorFolder = _Config.Get("DefaultErrorFolder", "/error");

            _Files.FilesRoot = _Config.Get("StaticFilesPath", "./www");
            if (!Directory.Exists(_Files.FilesRoot))
            {
                Directory.CreateDirectory(_Files.FilesRoot);
            }

            if (errorFolder != null)
            {
                string serverPath = errorFolder + (errorFolder.EndsWith("/") ? "" : "/");

                if (!errorFolder.StartsWith("."))
                {
                    errorFolder = "." + errorFolder;
                }

                if (Directory.Exists(errorFolder))
                {
                    foreach (var item in Directory.EnumerateFiles(errorFolder, "???.html", SearchOption.TopDirectoryOnly))
                    {
                        var filename = Path.GetFileNameWithoutExtension(item);

                        if (int.TryParse(filename, out int code))
                        {
                            ErrorPages.Add((HttpStatusCode)code, serverPath + filename + ".html");
                        }
                    }
                }
            }

            foreach (var item in _Config)
            {
                var match = Regex.Match(item.Key, @"ErrorPage\d\d\d");

                if (match.Success)
                {
                    int code = int.Parse(item.Key.Substring(item.Key.Length - 3));
                    ErrorPages.Add((HttpStatusCode)code, item.Value as string);
                }
            }

            _PHP = new PhpInstallation(Program.GetPhpVersion(_Config));
        }
Пример #2
0
        public PHP(Configuration config) : base(config)
        {
            //We still haven't created a PHP installation
            if (_Installation == null)
            {
                //If we have a custom PHP path in the config, use it
                if (config.TryGet("CustomPhpPath", out string path))
                {
                    _Installation = new PhpInstallation(path);
                }
                else //Else, create an installation with the version in the config
                {
                    _Installation = new PhpInstallation(Program.GetPhpVersion(config));
                }

                //Set the execution timeout from the config
                _Installation.ExecutionTimeout = config.Get("PhpExecutionTimeout", 4);
            }
        }
Пример #3
0
 public PhpScript(PhpInstallation install, string filePath)
 {
     this.PhpFilePath = filePath;
     _Installation    = install;
 }