public void btnServices_Click(object sender, EventArgs e) { if (!File.Exists(References.AppRootPath(@"\pkg\httpd\conf\httpd.conf"))) { MessageBox.Show("Apache configuration file not found!"); return; } ChangePhpVersion(); btnServices.Enabled = false; switch (btnServices.Text) { case "Stop Services": btnServices.Enabled = false; StoppingServices(); Refresh(); break; case "Start Services": btnServices.Enabled = false; AutoGenerateVhost(); StartingServices(); Refresh(); break; } }
private void lblMailhogLog_Click(object sender, EventArgs e) { var file = References.AppRootPath(@"\tmp\mailhogservice.err.log"); if (!File.Exists(file)) { MessageBox.Show("File " + file + " not found!"); } else { Utilities.OpenWithNotepad(file); } }
private void lblPhpIni_Click(object sender, EventArgs e) { var file = References.AppRootPath(@"\pkg\php\" + cmbPhpVersion.Text + @"\php.ini"); if (!File.Exists(file)) { MessageBox.Show("File " + file + " not found!"); } else { Utilities.OpenWithNotepad(file); } }
private void ListAvailablePhp() { var pkgPhp = References.AppRootPath(@"\pkg\php"); if (!Directory.Exists(pkgPhp)) { return; } foreach (var t in Directory.GetDirectories(pkgPhp)) { cmbPhpVersion.Items.Add(Path.GetFileName(t)); } cmbPhpVersion.SelectedIndex = !string.IsNullOrEmpty(Config.Get("App", "SelectedPhpVersion")) ? cmbPhpVersion.FindStringExact(Config.Get("App", "SelectedPhpVersion")) : 0; }
private void lblApacheConfig_Click(object sender, EventArgs e) { var path = References.AppRootPath(@"\pkg\httpd\conf"); if (!Directory.Exists(path)) { return; } var proc = new Process { StartInfo = { FileName = "explorer.exe", Arguments = path, UseShellExecute = false } }; proc.Start(); }
private void ChangePhpVersion() { var cfgApache = References.AppRootPath(@"\pkg\httpd\conf\httpd.conf"); const string keyword = "PHPVERSION"; var oldVersion = Config.Get("App", "SelectedPhpVersion"); var newVersion = cmbPhpVersion.Text; var sr = new StreamReader(cfgApache); string currentLine; var foundText = false; do { currentLine = sr.ReadLine(); if (currentLine != null) { foundText = currentLine.Contains(keyword); } } while(currentLine != null && !foundText); if (foundText) { var result = currentLine.Substring(currentLine.IndexOf(keyword) + keyword.Length); oldVersion = result; sr.Close(); } // Update PHP Version on Apache Configuration Utilities.ReplaceStringInFile(cfgApache, oldVersion, " \"" + newVersion + "\""); // Update PHP Version on Composer var phpExe = References.AppRootPath(@"\pkg\php\" + newVersion + @"\php.exe"); var composerPhar = References.AppRootPath(@"\utils\composer.phar"); var content = "@echo off\n\"" + phpExe + "\" \"" + composerPhar + "\" %*"; File.WriteAllText(References.AppRootPath(@"\utils\composer.bat"), content); Config.Set("App", "SelectedPhpVersion", cmbPhpVersion.Text); }