Version 18.52.2

This commit is contained in:
Antonio Cañas Vargas 2019-02-21 01:21:39 +01:00
parent cd58031c02
commit 0b94efff3d
7 changed files with 76 additions and 37 deletions

View File

@ -431,10 +431,12 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.52 (2019-02-20)"
#define Log_PLATFORM_VERSION "SWAD 18.52.2 (2019-02-21)"
#define CSS_FILE "swad18.52.css"
#define JS_FILE "swad18.51.js"
/*
Version 18.52.2: Feb 20, 2019 Fixed bug in reception of images. (237458 lines)
Version 18.52.1: Feb 20, 2019 Messages to debug problem with files. (237425 lines)
Version 18.52: Feb 20, 2019 Two new color themes: purple and pink. (237424 lines)
Copy the following icons to icon public directory:
sudo mkdir /var/www/html/swad/icon/theme/purple

View File

@ -431,7 +431,7 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1])
if (Fil_CheckIfPathExists (Path))
{
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in Fil_RemoveTree.");
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
{
if (rmdir (Path))
@ -497,7 +497,10 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDire
struct stat FileStatus;
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
{
Ale_ShowAlert (Ale_ERROR,"Error while trying to remove old temporary files in directory "%s"",Path);
Lay_ShowErrorAndExit ("Can not get information about a file or folder in Fil_RemoveOldTmpFiles.");
}
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
{
/***** Scan the directory *****/

View File

@ -5352,7 +5352,7 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
"%s/%s",
Path,FileList[NumFile]->d_name);
if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_CalcSizeOfDirRecursive.");
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
{
Gbl.FileBrowser.Size.NumFolds++;
@ -5423,7 +5423,7 @@ static void Brw_ListDir (unsigned Level,const char *ParentRowId,
/***** Get file or folder status *****/
if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_ListDir.");
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
{
if (Gbl.FileBrowser.FullTree)
@ -6764,7 +6764,7 @@ void Brw_RemFileFromTree (void)
/***** Check if is a file/link or a folder *****/
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_RemFileFromTree.");
else if (S_ISREG (FileStatus.st_mode)) // It's a file or a link
{
/* Name of the file/link to be shown */
@ -6818,7 +6818,7 @@ void Brw_RemFolderFromTree (void)
/***** Check if it's a file or a folder *****/
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_RemFolderFromTree.");
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
if (Brw_RemoveFolderFromDiskAndDB (Path,
Gbl.FileBrowser.Priv.FullPathInTree))
@ -8288,7 +8288,7 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
/***** Is it a file or a folder? *****/
FileType = Brw_IS_UNKNOWN;
if (lstat (PathOrg,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_PasteTreeIntoFolder.");
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
FileType = Brw_IS_FOLDER;
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
@ -12558,7 +12558,7 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,
// Folder st_mtime must be saved before remove files inside it
// because st_mtime is updated by the deletion
if (lstat (Path,&FolderStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_ScanDirRemovingOldFiles.");
/***** Scan directory *****/
else if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error
{
@ -12580,7 +12580,7 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,
/***** Get file or folder status *****/
if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in Brw_ScanDirRemovingOldFiles.");
else if (S_ISDIR (FileStatus.st_mode)) // It's a folder
/* Scan subtree starting at this this directory recursively */
Brw_ScanDirRemovingOldFiles (Level + 1,PathFileRel,

View File

@ -65,9 +65,13 @@ extern struct Globals Gbl;
/***************************** Internal prototypes ***************************/
/*****************************************************************************/
static void Img_ProcessImage (struct Image *Image,
const char *FileNameImgOriginal,
const char *FileNameImgProcessed);
static Img_Action_t Img_GetImageActionFromForm (const char *ParamAction);
static void Img_GetAndProcessImageFileFromForm (struct Image *Image,
const char *ParamFile);
static int Img_ProcessImage (struct Image *Image,
const char *FileNameImgOriginal,
const char *FileNameImgProcessed);
/*****************************************************************************/
/*************************** Reset image fields ******************************/
@ -381,7 +385,7 @@ void Img_SetParamNames (struct ParamUploadImg *ParamUploadImg,int NumImgInForm)
/************************* Get image action from form ************************/
/*****************************************************************************/
Img_Action_t Img_GetImageActionFromForm (const char *ParamAction)
static Img_Action_t Img_GetImageActionFromForm (const char *ParamAction)
{
/***** Get parameter with the action to perform on image *****/
return (Img_Action_t)
@ -395,8 +399,10 @@ Img_Action_t Img_GetImageActionFromForm (const char *ParamAction)
/**************************** Get image from form ****************************/
/*****************************************************************************/
void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFile)
static void Img_GetAndProcessImageFileFromForm (struct Image *Image,
const char *ParamFile)
{
extern const char *Txt_The_image_could_not_be_processed_successfully;
struct Param *Param;
char FileNameImgSrc[PATH_MAX + 1];
char *PtrExtension;
@ -407,7 +413,7 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
char FileNameImgTmp[PATH_MAX + 1]; // Full name of temporary processed file
bool WrongType = false;
/***** Rest image file status *****/
/***** Set image file status *****/
Image->Status = Img_FILE_NONE;
/***** Get filename and MIME type *****/
@ -418,6 +424,10 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
/* Get filename extension */
if ((PtrExtension = strrchr (FileNameImgSrc,(int) '.')) == NULL)
return;
// PtrExtension now points to last '.' in file
PtrExtension++;
// PtrExtension now points to first char in extension
LengthExtension = strlen (PtrExtension);
if (LengthExtension < Fil_MIN_BYTES_FILE_EXTENSION ||
@ -453,7 +463,7 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
Fil_RemoveOldTmpFiles (PathImgPriv,Cfg_TIME_TO_DELETE_IMAGES_TMP_FILES,false);
/***** End the reception of original not processed image
(it can be very big) into a temporary file *****/
(it may be very big) into a temporary file *****/
Image->Status = Img_FILE_NONE;
snprintf (FileNameImgOrig,sizeof (FileNameImgOrig),
"%s/%s/%s/%s_original.%s",
@ -469,8 +479,18 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
"%s/%s/%s/%s.jpg",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP,
Image->Name);
Img_ProcessImage (Image,FileNameImgOrig,FileNameImgTmp);
Image->Status = Img_FILE_PROCESSED;
if (Img_ProcessImage (Image,FileNameImgOrig,FileNameImgTmp) == 0) // Return 0 on success
/* Success */
Image->Status = Img_FILE_PROCESSED;
else // Error processing image
{
/* Error ==> remove temporary destination image file */
if (Fil_CheckIfPathExists (FileNameImgTmp))
unlink (FileNameImgTmp);
/* Show error alert */
Ale_ShowAlert (Ale_ERROR,Txt_The_image_could_not_be_processed_successfully);
}
/***** Remove temporary original file *****/
unlink (FileNameImgOrig);
@ -480,14 +500,16 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
/*****************************************************************************/
/************ Process original image generating processed image **************/
/*****************************************************************************/
// Return 0 on success
// Return != 0 on error
static void Img_ProcessImage (struct Image *Image,
const char *FileNameImgOriginal,
const char *FileNameImgProcessed)
static int Img_ProcessImage (struct Image *Image,
const char *FileNameImgOriginal,
const char *FileNameImgProcessed)
{
char Command[1024 + PATH_MAX * 2];
int ReturnCode;
char ErrorMsg[256];
// char ErrorMsg[256];
snprintf (Command,sizeof (Command),
"convert %s -resize '%ux%u>' -quality %u %s",
@ -500,16 +522,9 @@ static void Img_ProcessImage (struct Image *Image,
if (ReturnCode == -1)
Lay_ShowErrorAndExit ("Error when running command to process image.");
/***** Write message depending on return code *****/
ReturnCode = WEXITSTATUS(ReturnCode);
if (ReturnCode != 0)
{
snprintf (ErrorMsg,sizeof (ErrorMsg),
"Image could not be processed successfully.<br />"
"Error code returned by the program of processing: %d",
ReturnCode);
Lay_ShowErrorAndExit (ErrorMsg);
}
return ReturnCode;
}
/*****************************************************************************/

View File

@ -133,8 +133,6 @@ void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTitURL);
void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
void (*GetImageFromDB) (int NumImgInForm,struct Image *Image));
void Img_SetParamNames (struct ParamUploadImg *ParamUploadImg,int NumImgInForm);
Img_Action_t Img_GetImageActionFromForm (const char *ParamAction);
void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFile);
void Img_MoveImageToDefinitiveDirectory (struct Image *Image);
void Img_ShowImage (struct Image *Image,

View File

@ -44888,6 +44888,27 @@ const char *Txt_The_ID_X_matches_one_of_the_existing = // Warning: it is very im
" corresponde a um dos existentes.";
#endif
const char *Txt_The_image_could_not_be_processed_successfully =
#if L==1 // ca
"La imatge no s'ha pogut processar correctament.";
#elif L==2 // de
"Das Bild konnte nicht erfolgreich verarbeitet werden.";
#elif L==3 // en
"The image could not be processed successfully.";
#elif L==4 // es
"La imagen no ha podido procesarse correctamente.";
#elif L==5 // fr
"L'image n'a pas pu &ecirc;tre trait&eacute;e avec succ&egrave;s.";
#elif L==6 // gn
"La imagen no ha podido procesarse correctamente."; // Okoteve traducción
#elif L==7 // it
"L'immagine non pu&ograve; essere elaborata con successo.";
#elif L==8 // pl
"Obraz nie m&oacute;g&lstrok; zosta&cacute; pomy&sacute;lnie przetworzony.";
#elif L==9 // pt
"A imagem n&atilde;o p&ocirc;de ser processada com sucesso.";
#endif
const char *Txt_The_institution_X_already_exists = // Warning: it is very important to include %s in the following sentences
#if L==1 // ca
"La instituci&oacute;n <strong>%s</strong> ya existe."; // Necessita traduccio

View File

@ -236,7 +236,7 @@ void ZIP_CreateZIPAsgWrk (void)
{
/***** Get file size *****/
if (lstat (PathFileZIP,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in ZIP_CreateZIPAsgWrk.");
else
{
/***** Create URL pointing to ZIP file *****/
@ -489,7 +489,7 @@ static void ZIP_CompressFolderIntoZIP (void)
{
/***** Get file size *****/
if (lstat (PathFileZIP,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in ZIP_CompressFolderIntoZIP.");
else
{
/***** Create URL pointing to ZIP file *****/
@ -574,7 +574,7 @@ static unsigned long long ZIP_CloneDir (const char *Path,const char *PathClone,c
FileType = Brw_IS_UNKNOWN;
if (lstat (PathFile,&FileStatus)) // On success ==> 0 is returned
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
Lay_ShowErrorAndExit ("Can not get information about a file or folder in ZIP_CloneDir.");
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
FileType = Brw_IS_FOLDER;
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file