Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Mailpit and Xlight in class.action.switchVersion.php and update icon paths in class.winbinder.php and class.core.php #82

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 90 additions & 61 deletions core/classes/actions/class.action.switchVersion.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
/*
* Copyright (c) 2021-2024 Bearsampp
* License: GNU General Public License version 3 or later; see LICENSE.txt
* Author: Bear
* Website: https://bearsampp.com
* Github: https://github.com/Bearsampp
*
* * Copyright (c) 2021-2024 Bearsampp
* * License: GNU General Public License version 3 or later; see LICENSE.txt
* * Website: https://bearsampp.com
* * Github: https://github.com/Bearsampp
*
*/

/**
Expand All @@ -28,117 +29,143 @@ class ActionSwitchVersion
* ActionSwitchVersion constructor.
* Initializes the class with the provided arguments and sets up the splash screen.
*
* @param array $args Command line arguments for switching versions.
* @param array $args Command line arguments for switching versions.
*/
public function __construct($args)
{
global $bearsamppLang, $bearsamppBins, $bearsamppWinbinder;

if (isset($args[0]) && !empty($args[0]) && isset($args[1]) && !empty($args[1])) {
$this->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);
Expand All @@ -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)
{
Expand Down Expand Up @@ -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));
Expand All @@ -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);

Expand Down
16 changes: 15 additions & 1 deletion core/classes/class.core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

/**
Expand Down
16 changes: 9 additions & 7 deletions core/classes/class.winbinder.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
/*
* Copyright (c) 2021-2024 Bearsampp
* License: GNU General Public License version 3 or later; see LICENSE.txt
* Author: Bear
* Website: https://bearsampp.com
* Github: https://github.com/Bearsampp
*
* * Copyright (c) 2021-2024 Bearsampp
* * License: GNU General Public License version 3 or later; see LICENSE.txt
* * Website: https://bearsampp.com
* * Github: https://github.com/Bearsampp
*
*/

/**
Expand All @@ -24,6 +25,7 @@ class WinBinder
const INCR_PROGRESS_BAR = '++';
const NEW_LINE = '@nl@';

// TODO why does it say we have undelcared constants
// Constants for message box types
const BOX_INFO = WBC_INFO;
const BOX_OK = WBC_OK;
Expand Down Expand Up @@ -142,7 +144,7 @@ public function createWindow($parent, $wclass, $caption, $xPos, $yPos, $width, $
$window = $this->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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
Loading