From c60952a14ce86e9138a1bdc77d6ca69f8917a745 Mon Sep 17 00:00:00 2001 From: Bear Date: Fri, 6 Sep 2024 05:45:46 -0500 Subject: [PATCH] Add support for Mailpit and Xlight in `class.action.switchVersion.php` and update icon paths in `class.winbinder.php` and `class.core.php` --- .../actions/class.action.switchVersion.php | 151 +++++++++++------- core/classes/class.core.php | 16 +- core/classes/class.winbinder.php | 16 +- 3 files changed, 114 insertions(+), 69 deletions(-) diff --git a/core/classes/actions/class.action.switchVersion.php b/core/classes/actions/class.action.switchVersion.php index 5ab15bea8..e6b73d031 100644 --- a/core/classes/actions/class.action.switchVersion.php +++ b/core/classes/actions/class.action.switchVersion.php @@ -1,10 +1,11 @@ pathsToScan = array(); - $this->version = $args[1]; + $this->version = $args[1]; if ($args[0] == $bearsamppBins->getApache()->getName()) { - $this->bin = $bearsamppBins->getApache(); + $this->bin = $bearsamppBins->getApache(); $this->currentVersion = $bearsamppBins->getApache()->getVersion(); - $this->service = $bearsamppBins->getApache()->getService(); - $this->changePort = true; - $folderList = Util::getFolderList($bearsamppBins->getApache()->getRootPath()); + $this->service = $bearsamppBins->getApache()->getService(); + $this->changePort = true; + $folderList = Util::getFolderList($bearsamppBins->getApache()->getRootPath()); foreach ($folderList as $folder) { $this->pathsToScan[] = array( - 'path' => $bearsamppBins->getApache()->getRootPath() . '/' . $folder, - 'includes' => array('.ini', '.conf'), + 'path' => $bearsamppBins->getApache()->getRootPath() . '/' . $folder, + 'includes' => array('.ini', '.conf'), 'recursive' => true ); } } elseif ($args[0] == $bearsamppBins->getPhp()->getName()) { - $this->bin = $bearsamppBins->getPhp(); + $this->bin = $bearsamppBins->getPhp(); $this->currentVersion = $bearsamppBins->getPhp()->getVersion(); - $this->service = $bearsamppBins->getApache()->getService(); - $this->changePort = false; - $folderList = Util::getFolderList($bearsamppBins->getPhp()->getRootPath()); + $this->service = $bearsamppBins->getApache()->getService(); + $this->changePort = false; + $folderList = Util::getFolderList($bearsamppBins->getPhp()->getRootPath()); foreach ($folderList as $folder) { $this->pathsToScan[] = array( - 'path' => $bearsamppBins->getPhp()->getRootPath() . '/' . $folder, - 'includes' => array('.php', '.bat', '.ini', '.reg', '.inc'), + 'path' => $bearsamppBins->getPhp()->getRootPath() . '/' . $folder, + 'includes' => array('.php', '.bat', '.ini', '.reg', '.inc'), 'recursive' => true ); } } elseif ($args[0] == $bearsamppBins->getMysql()->getName()) { - $this->bin = $bearsamppBins->getMysql(); + $this->bin = $bearsamppBins->getMysql(); $this->currentVersion = $bearsamppBins->getMysql()->getVersion(); - $this->service = $bearsamppBins->getMysql()->getService(); - $this->changePort = true; - $folderList = Util::getFolderList($bearsamppBins->getMysql()->getRootPath()); + $this->service = $bearsamppBins->getMysql()->getService(); + $this->changePort = true; + $folderList = Util::getFolderList($bearsamppBins->getMysql()->getRootPath()); foreach ($folderList as $folder) { $this->pathsToScan[] = array( - 'path' => $bearsamppBins->getMysql()->getRootPath() . '/' . $folder, - 'includes' => array('my.ini'), + 'path' => $bearsamppBins->getMysql()->getRootPath() . '/' . $folder, + 'includes' => array('my.ini'), 'recursive' => false ); } } elseif ($args[0] == $bearsamppBins->getMariadb()->getName()) { - $this->bin = $bearsamppBins->getMariadb(); + $this->bin = $bearsamppBins->getMariadb(); $this->currentVersion = $bearsamppBins->getMariadb()->getVersion(); - $this->service = $bearsamppBins->getMariadb()->getService(); - $this->changePort = true; - $folderList = Util::getFolderList($bearsamppBins->getMariadb()->getRootPath()); + $this->service = $bearsamppBins->getMariadb()->getService(); + $this->changePort = true; + $folderList = Util::getFolderList($bearsamppBins->getMariadb()->getRootPath()); foreach ($folderList as $folder) { $this->pathsToScan[] = array( - 'path' => $bearsamppBins->getMariadb()->getRootPath() . '/' . $folder, - 'includes' => array('my.ini'), + 'path' => $bearsamppBins->getMariadb()->getRootPath() . '/' . $folder, + 'includes' => array('my.ini'), 'recursive' => false ); } } elseif ($args[0] == $bearsamppBins->getPostgresql()->getName()) { - $this->bin = $bearsamppBins->getPostgresql(); + $this->bin = $bearsamppBins->getPostgresql(); $this->currentVersion = $bearsamppBins->getPostgresql()->getVersion(); - $this->service = $bearsamppBins->getPostgresql()->getService(); - $this->changePort = true; - $folderList = Util::getFolderList($bearsamppBins->getPostgresql()->getRootPath()); + $this->service = $bearsamppBins->getPostgresql()->getService(); + $this->changePort = true; + $folderList = Util::getFolderList($bearsamppBins->getPostgresql()->getRootPath()); foreach ($folderList as $folder) { $this->pathsToScan[] = array( - 'path' => $bearsamppBins->getPostgresql()->getRootPath() . '/' . $folder, - 'includes' => array('.ber', '.conf', '.bat'), + 'path' => $bearsamppBins->getPostgresql()->getRootPath() . '/' . $folder, + 'includes' => array('.ber', '.conf', '.bat'), 'recursive' => true ); } } elseif ($args[0] == $bearsamppBins->getNodejs()->getName()) { - $this->bin = $bearsamppBins->getNodejs(); + $this->bin = $bearsamppBins->getNodejs(); $this->currentVersion = $bearsamppBins->getNodejs()->getVersion(); - $this->service = null; - $this->changePort = false; - $folderList = Util::getFolderList($bearsamppBins->getNodejs()->getRootPath()); + $this->service = null; + $this->changePort = false; + $folderList = Util::getFolderList($bearsamppBins->getNodejs()->getRootPath()); foreach ($folderList as $folder) { $this->pathsToScan[] = array( - 'path' => $bearsamppBins->getNodejs()->getRootPath() . '/' . $folder . '/etc', - 'includes' => array('npmrc'), + 'path' => $bearsamppBins->getNodejs()->getRootPath() . '/' . $folder . '/etc', + 'includes' => array('npmrc'), 'recursive' => true ); $this->pathsToScan[] = array( - 'path' => $bearsamppBins->getNodejs()->getRootPath() . '/' . $folder . '/node_modules/npm', - 'includes' => array('npmrc'), + 'path' => $bearsamppBins->getNodejs()->getRootPath() . '/' . $folder . '/node_modules/npm', + 'includes' => array('npmrc'), 'recursive' => false ); } } elseif ($args[0] == $bearsamppBins->getFilezilla()->getName()) { - $this->bin = $bearsamppBins->getFilezilla(); + $this->bin = $bearsamppBins->getFilezilla(); $this->currentVersion = $bearsamppBins->getFilezilla()->getVersion(); - $this->service = $bearsamppBins->getFilezilla()->getService(); - $this->changePort = true; - $folderList = Util::getFolderList($bearsamppBins->getFilezilla()->getRootPath()); + $this->service = $bearsamppBins->getFilezilla()->getService(); + $this->changePort = true; + $folderList = Util::getFolderList($bearsamppBins->getFilezilla()->getRootPath()); foreach ($folderList as $folder) { $this->pathsToScan[] = array( - 'path' => $bearsamppBins->getFilezilla()->getRootPath() . '/' . $folder, - 'includes' => array('.xml'), + 'path' => $bearsamppBins->getFilezilla()->getRootPath() . '/' . $folder, + 'includes' => array('.xml'), 'recursive' => true ); } } elseif ($args[0] == $bearsamppBins->getMemcached()->getName()) { - $this->bin = $bearsamppBins->getMemcached(); + $this->bin = $bearsamppBins->getMemcached(); $this->currentVersion = $bearsamppBins->getMemcached()->getVersion(); - $this->service = $bearsamppBins->getMemcached()->getService(); - $this->changePort = true; + $this->service = $bearsamppBins->getMemcached()->getService(); + $this->changePort = true; + } elseif ($args[0] == $bearsamppBins->getMailpit()->getName()) { + $this->bin = $bearsamppBins->getMailpit(); + $this->currentVersion = $bearsamppBins->getMailpit()->getVersion(); + $this->service = $bearsamppBins->getMailpit()->getService(); + $this->changePort = false; + $folderList = Util::getFolderList($bearsamppBins->getMailpit()->getRootPath()); + foreach ($folderList as $folder) { + $this->pathsToScan[] = array( + 'path' => $bearsamppBins->getMailpit()->getRootPath() . '/' . $folder, + 'includes' => array('.conf'), + 'recursive' => true + ); + } + } elseif ($args[0] == $bearsamppBins->getXlight()->getName()) { + $this->bin = $bearsamppBins->getXlight(); + $this->currentVersion = $bearsamppBins->getXlight()->getVersion(); + $this->service = $bearsamppBins->getXlight()->getService(); + $this->changePort = true; + $folderList = Util::getFolderList($bearsamppBins->getXlight()->getRootPath()); + foreach ($folderList as $folder) { + $this->pathsToScan[] = array( + 'path' => $bearsamppBins->getXlight()->getRootPath() . '/' . $folder, + 'includes' => array('.conf, ftpd.hosts, ftpd.option, ftpd.password, ftpd.rules, ftpd.users, .ini'), + 'recursive' => true + ); + } } $this->boxTitle = sprintf($bearsamppLang->getValue(Lang::SWITCH_VERSION_TITLE), $this->bin->getName(), $this->version); @@ -160,11 +187,11 @@ public function __construct($args) /** * Processes the window events for the splash screen. * - * @param mixed $window The window handle. - * @param int $id The event ID. - * @param mixed $ctrl The control handle. - * @param mixed $param1 The first parameter. - * @param mixed $param2 The second parameter. + * @param mixed $window The window handle. + * @param int $id The event ID. + * @param mixed $ctrl The control handle. + * @param mixed $param1 The first parameter. + * @param mixed $param2 The second parameter. */ public function processWindow($window, $id, $ctrl, $param1, $param2) { @@ -227,7 +254,8 @@ public function processWindow($window, $id, $ctrl, $param1, $param2) $this->bearsamppSplash->incrProgressBar(self::GAUGE_SERVICES * count($bearsamppBins->getServices()) + 1); $bearsamppWinbinder->messageBoxInfo( sprintf($bearsamppLang->getValue(Lang::SWITCH_VERSION_OK), $this->bin->getName(), $this->version), - $this->boxTitle); + $this->boxTitle + ); $bearsamppWinbinder->destroyWindow($window); $this->bearsamppSplash->setTextLoading(sprintf($bearsamppLang->getValue(Lang::SWITCH_VERSION_REGISTRY), Registry::APP_BINS_REG_ENTRY)); @@ -242,7 +270,8 @@ public function processWindow($window, $id, $ctrl, $param1, $param2) $bearsamppWinbinder->messageBoxInfo( sprintf($bearsamppLang->getValue(Lang::SWITCH_VERSION_OK_RESTART), $this->bin->getName(), $this->version, APP_TITLE), - $this->boxTitle); + $this->boxTitle + ); $bearsamppCore->setExec(ActionExec::RESTART); diff --git a/core/classes/class.core.php b/core/classes/class.core.php index b8fee2bc7..b6647e585 100644 --- a/core/classes/class.core.php +++ b/core/classes/class.core.php @@ -117,7 +117,21 @@ public function getIconsPath($aetrayPath = false) { global $bearsamppCore; - return $bearsamppCore->getResourcesPath( $aetrayPath ) . '/img/icons'; + return $bearsamppCore->getResourcesPath( $aetrayPath ) . '/homepage/img/icons'; + } + + /** + * Retrieves the path to the images. + * + * @param bool $aetrayPath Whether to format the path for AeTrayMenu. + * + * @return string The path to the icons. + */ + public function getImagesPath($aetrayPath = false) + { + global $bearsamppCore; + + return $bearsamppCore->getResourcesPath( $aetrayPath ) . '/homepage/img'; } /** diff --git a/core/classes/class.winbinder.php b/core/classes/class.winbinder.php index 8505ad0e3..0c669e869 100644 --- a/core/classes/class.winbinder.php +++ b/core/classes/class.winbinder.php @@ -1,10 +1,11 @@ callWinBinder( 'wb_create_window', array($parent, $wclass, $caption, $xPos, $yPos, $width, $height, $style, $params) ); // Set tiny window icon - $this->setImage( $window, $bearsamppCore->getResourcesPath() . '/homepage/img/icons/app.ico' ); + $this->setImage( $window, $bearsamppCore->getIconsPath() . '/app.ico' ); return $window; } @@ -913,7 +915,7 @@ public function messageBox($message, $type, $title = null) // TODO why does this create an error sometimes. // Set tiny window icon - $this->setImage( $messageBox, $bearsamppCore->getResourcesPath() . '/homepage/img/icons/app.ico' ); + $this->setImage( $messageBox, $bearsamppCore->getIconsPath() . '/app.ico' ); return $messageBox; }