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 $pattern pattern to filter some specified files
|
||||
* @return <boolean> if the $path, assuming that is a directory -> all files in it are writeables or not
|
||||
* @param string $path The path to the directory to scan recursively.
|
||||
* @param string $pattern The pattern to filter specific files (default is '*').
|
||||
* @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);
|
||||
|
||||
// Check write permissions for each file
|
||||
foreach ($files as $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();
|
||||
$response->data = $languagesList;
|
||||
print (G::json_encode($response));
|
||||
print (json_encode($response));
|
||||
break;
|
||||
case 'delete':
|
||||
include_once 'classes/model/Translation.php';
|
||||
@@ -122,7 +122,7 @@ try {
|
||||
//Verify if is the current language
|
||||
if ($locale != SYS_LANG) {
|
||||
try {
|
||||
Content::removeLanguageContent($locale);
|
||||
(new Content)->removeLanguageContent($locale);
|
||||
$trn->removeTranslationEnvironment($locale);
|
||||
echo G::LoadTranslation('ID_LANGUAGE_DELETED_SUCCESSFULLY');
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -26,28 +26,36 @@ if ($access != 1) {
|
||||
$result = new stdClass();
|
||||
|
||||
try {
|
||||
// Validate uploaded files
|
||||
ValidationUploadedFiles::getValidationUploadedFiles()->dispatch(function($validator) {
|
||||
throw new Exception($validator->getMessage());
|
||||
});
|
||||
//if the xmlform path is writeable
|
||||
|
||||
// Check if the XML form path is writable
|
||||
if (!is_writable(PATH_XMLFORM)) {
|
||||
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)) {
|
||||
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');
|
||||
|
||||
// Create an input filter instance
|
||||
$filter = new InputFilter();
|
||||
|
||||
// Retrieve and filter the uploaded language file
|
||||
$languageFile = $_FILES['form']['tmp_name']['LANGUAGE_FILENAME'];
|
||||
$languageFilename = $_FILES['form']['name']['LANGUAGE_FILENAME'];
|
||||
|
||||
// Apply XSS filtering
|
||||
$languageFile = $filter->xssFilterHard($languageFile, 'path');
|
||||
$languageFilename = $filter->xssFilterHard($languageFilename, 'path');
|
||||
|
||||
if (substr_compare($languageFilename, ".gz", - 3, 3, true) == 0) {
|
||||
$zp = gzopen($languageFile, "r");
|
||||
$languageFile = tempnam(__FILE__, '');
|
||||
@@ -94,5 +102,5 @@ try {
|
||||
}
|
||||
|
||||
ob_clean();
|
||||
echo G::json_encode($result);
|
||||
echo json_encode($result);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?x ml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<dynaForm name="login" version="1.0" basedir="" xmlform_type="NORMAL" width="400px" enabletemplate="1">
|
||||
<BROWSER_TIME_ZONE_OFFSET type="hidden" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user