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

file manager languages - #4275 #4382

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tlcd96
Copy link
Contributor

@tlcd96 tlcd96 commented May 12, 2024

this file will tell the file manager what language to use, missing include in web/fm/configuration.php

@tlcd96
Copy link
Contributor Author

tlcd96 commented May 12, 2024

missing the optional include on file web/fm/configuration.php

if(file_exists("../file_manager_languages.php")){
  include_once("../file_manager_languages.php");
}

before

return $dist_config;

Copy link
Member

@jaapmarcus jaapmarcus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this function to

./web/fm/configuration.php

I don't see any reason to make it optional...

*
* @see https://docs.filegator.io/translations/default.html#rtl-support
*/
switch (get_language_from_system()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SESSION['language'] is fine we should prefer the user language above server language...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that function exists solely to see if the session language is defined and if not, use "en"

web/file_manager_languages.php Outdated Show resolved Hide resolved
@tlcd96
Copy link
Contributor Author

tlcd96 commented May 13, 2024

We should move this function to

./web/fm/configuration.php

I don't see any reason to make it optional...

it's optional because many systems don't have it yet, I'm just preventing future problems.

I didn't saw where is the modified configuration on the install so I've put it there, with a direct include of index.php PHP and termination of script after the include

@tlcd96
Copy link
Contributor Author

tlcd96 commented May 13, 2024

where is the modified script of the web/fm/configuration.php? if it does exist

Copy link
Contributor Author

@tlcd96 tlcd96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with the explanation inside the function, of the function, it should be easier to understand

* - check if the session language exists
* - check if language is supported by hestia,
* - return default if both are false
*/
Copy link
Contributor Author

@tlcd96 tlcd96 May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with the explanation inside the function, of the function, it should be easier to understand,
Quote on quote:

	/* I don't think I need to explain this */
	include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
	/**
	 * Get all supported language
	 */
	exec(HESTIA_CMD . "v-list-sys-languages json", $output, $return_var);
	$languages = json_decode(implode("", $output), true);
	/**
	 * - check if the session language exists
	 * - check if language is supported by hestia,
	 * - return default if both are false
	 */
	 return isset($_SESSION["language"]) && in_array($_SESSION["language"], $languages)
		? $_SESSION["language"]
		: "en";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$_SESSION language is always set if not they ar not logged into Hestia ....

All languages in $_SESSION['language'] is supported by Hestia as it is loaded from hestia.conf and if not it falls back to English anyway...

Copy link
Contributor Author

@tlcd96 tlcd96 May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can pentest for a non-existing language. but that function does what it needs to be done to prevent rouge authors from altering the language to an non-existing one.

@jaapmarcus
Copy link
Member

We should move this function to
./web/fm/configuration.php
I don't see any reason to make it optional...

it's optional because many systems don't have it yet, I'm just preventing future problems.

All servers that have support if the have Filegator installed so it should not matter.. I don't see an reason to keep it optional...

I didn't saw where is the modified configuration on the install so I've put it there, with a direct include of index.php PHP and termination of script after the include

/install/common/filegator/ if I am right

@tlcd96
Copy link
Contributor Author

tlcd96 commented May 13, 2024

We should move this function to
./web/fm/configuration.php
I don't see any reason to make it optional...

it's optional because many systems don't have it yet, I'm just preventing future problems.

All servers that have support if the have Filegator installed so it should not matter.. I don't see an reason to keep it optional...

I didn't saw where is the modified configuration on the install so I've put it there, with a direct include of index.php PHP and termination of script after the include

/install/common/filegator/ if I am right

image

I don't see that file there

@jaapmarcus
Copy link
Member

@tlcd96
Copy link
Contributor Author

tlcd96 commented May 13, 2024

On bin/v-add-sys-filemanager

/* 67 - 88 */
rm --recursive --force "$FM_INSTALL_DIR"
mkdir -p "$FM_INSTALL_DIR"
cd "$FM_INSTALL_DIR"

[ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] && wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}.zip"

unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}.zip"
mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
rm --recursive --force ${FM_INSTALL_DIR}/${FM_FILE}
[[ -f "${FM_INSTALL_DIR}/${FM_FILE}" ]] && rm "${FM_INSTALL_DIR}/${FM_FILE}"

cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"

chown $user: -R "${FM_INSTALL_DIR}"

if [ -z "$openssl_installed" ]; then
	COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php $COMPOSER_BIN --quiet --no-dev install
else
	COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/local/hestia/php/bin/php $COMPOSER_BIN --quiet --no-dev install
fi
/* 102 - 103 */
# Add configuration file
cp -f $HESTIA_INSTALL_DIR/filemanager/filegator/configuration.php $HESTIA/web/fm/configuration.php

… file `file_manager_language.php` is removed
@tlcd96
Copy link
Contributor Author

tlcd96 commented May 13, 2024

just a quick reminder, this pull request I think the user wants to sponsor

#### Describe the feature or change in detail
Is it possible to do something so that Filegator follows the same language as HestiaCP?

#### Would you like to sponsor this feature to have it implemented?
Yes

Copy link
Contributor Author

@tlcd96 tlcd96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User wants to sponsor this feature. it's in the issue 4275

@jaapmarcus jaapmarcus linked an issue May 13, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Filegator follows the same language as HestiaCP
2 participants