fixing error importing es language
This commit is contained in:
@@ -3701,23 +3701,35 @@ class G
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursive Is writeable function
|
* Recursively checks if all files in a directory are writable.
|
||||||
*
|
*
|
||||||
* @author Erik Amaru Ortiz <erik@colosa.com>
|
* This function scans the specified directory and checks the write permissions
|
||||||
|
* of all files that match the given pattern. If any file is not writable,
|
||||||
|
* the function returns false; otherwise, it returns true.
|
||||||
*
|
*
|
||||||
* @param $path path to scan recursively the write permission
|
* @param string $path The path to the directory to scan recursively.
|
||||||
* @param $pattern pattern to filter some specified files
|
* @param string $pattern The pattern to filter specific files (default is '*').
|
||||||
* @return <boolean> if the $path, assuming that is a directory -> all files in it are writeables or not
|
* @return bool Returns true if all files are writable, false otherwise.
|
||||||
|
* @throws InvalidArgumentException If the provided path is not a directory.
|
||||||
*/
|
*/
|
||||||
public static function is_rwritable($path, $pattern = '*')
|
public static function is_rwritable(string $path, string $pattern = '*'): bool
|
||||||
{
|
{
|
||||||
|
// Check if the provided path is a directory
|
||||||
|
if (!is_dir($path)) {
|
||||||
|
throw new InvalidArgumentException("The provided path is not a directory: $path");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve all files matching the pattern
|
||||||
$files = G::rglob($pattern, 0, $path);
|
$files = G::rglob($pattern, 0, $path);
|
||||||
|
|
||||||
|
// Check write permissions for each file
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (!is_writable($file)) {
|
if (!is_writable($file)) {
|
||||||
return false;
|
return false; // Return false if any file is not writable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
return true; // All files are writable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ try {
|
|||||||
}
|
}
|
||||||
$translationRow = new Translation();
|
$translationRow = new Translation();
|
||||||
$response->data = $languagesList;
|
$response->data = $languagesList;
|
||||||
print (G::json_encode($response));
|
print (json_encode($response));
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
include_once 'classes/model/Translation.php';
|
include_once 'classes/model/Translation.php';
|
||||||
@@ -122,7 +122,7 @@ try {
|
|||||||
//Verify if is the current language
|
//Verify if is the current language
|
||||||
if ($locale != SYS_LANG) {
|
if ($locale != SYS_LANG) {
|
||||||
try {
|
try {
|
||||||
Content::removeLanguageContent($locale);
|
(new Content)->removeLanguageContent($locale);
|
||||||
$trn->removeTranslationEnvironment($locale);
|
$trn->removeTranslationEnvironment($locale);
|
||||||
echo G::LoadTranslation('ID_LANGUAGE_DELETED_SUCCESSFULLY');
|
echo G::LoadTranslation('ID_LANGUAGE_DELETED_SUCCESSFULLY');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|||||||
@@ -26,28 +26,36 @@ if ($access != 1) {
|
|||||||
$result = new stdClass();
|
$result = new stdClass();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Validate uploaded files
|
||||||
ValidationUploadedFiles::getValidationUploadedFiles()->dispatch(function($validator) {
|
ValidationUploadedFiles::getValidationUploadedFiles()->dispatch(function($validator) {
|
||||||
throw new Exception($validator->getMessage());
|
throw new Exception($validator->getMessage());
|
||||||
});
|
});
|
||||||
//if the xmlform path is writeable
|
|
||||||
|
// Check if the XML form path is writable
|
||||||
if (!is_writable(PATH_XMLFORM)) {
|
if (!is_writable(PATH_XMLFORM)) {
|
||||||
throw new Exception(G::LoadTranslation('IMPORT_LANGUAGE_ERR_NO_WRITABLE'));
|
throw new Exception(G::LoadTranslation('IMPORT_LANGUAGE_ERR_NO_WRITABLE'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//if all xml files within the xmlform directory are writeable
|
// Check if all XML files within the XML form directory are writable
|
||||||
if (!G::is_rwritable(PATH_XMLFORM)) {
|
if (!G::is_rwritable(PATH_XMLFORM)) {
|
||||||
throw new Exception(G::LoadTranslation('IMPORT_LANGUAGE_ERR_NO_WRITABLE2'));
|
throw new Exception(G::LoadTranslation('IMPORT_LANGUAGE_ERR_NO_WRITABLE2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sMaxExecutionTime = ini_get('max_execution_time');
|
// Set maximum execution time to unlimited
|
||||||
|
$originalMaxExecutionTime = ini_get('max_execution_time');
|
||||||
ini_set('max_execution_time', '0');
|
ini_set('max_execution_time', '0');
|
||||||
|
|
||||||
|
// Create an input filter instance
|
||||||
$filter = new InputFilter();
|
$filter = new InputFilter();
|
||||||
|
|
||||||
|
// Retrieve and filter the uploaded language file
|
||||||
$languageFile = $_FILES['form']['tmp_name']['LANGUAGE_FILENAME'];
|
$languageFile = $_FILES['form']['tmp_name']['LANGUAGE_FILENAME'];
|
||||||
$languageFilename = $_FILES['form']['name']['LANGUAGE_FILENAME'];
|
$languageFilename = $_FILES['form']['name']['LANGUAGE_FILENAME'];
|
||||||
|
|
||||||
|
// Apply XSS filtering
|
||||||
$languageFile = $filter->xssFilterHard($languageFile, 'path');
|
$languageFile = $filter->xssFilterHard($languageFile, 'path');
|
||||||
$languageFilename = $filter->xssFilterHard($languageFilename, 'path');
|
$languageFilename = $filter->xssFilterHard($languageFilename, 'path');
|
||||||
|
|
||||||
if (substr_compare($languageFilename, ".gz", - 3, 3, true) == 0) {
|
if (substr_compare($languageFilename, ".gz", - 3, 3, true) == 0) {
|
||||||
$zp = gzopen($languageFile, "r");
|
$zp = gzopen($languageFile, "r");
|
||||||
$languageFile = tempnam(__FILE__, '');
|
$languageFile = tempnam(__FILE__, '');
|
||||||
@@ -94,5 +102,5 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ob_clean();
|
ob_clean();
|
||||||
echo G::json_encode($result);
|
echo json_encode($result);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user