Version 15.165

This commit is contained in:
Antonio Cañas Vargas 2016-03-28 19:30:37 +02:00
parent 10d5ae1a49
commit c025d71655
12 changed files with 269 additions and 115 deletions

View File

@ -1416,8 +1416,7 @@ a:hover /* Default ==> underlined */
{ {
box-sizing:border-box; box-sizing:border-box;
width:480px; width:480px;
height:320px; padding:6px; margin:9px;
padding:6px; margin:10px;
border:solid 1px #EEE; border:solid 1px #EEE;
} }
a:hover img.CENTRE_PHOTO_SHOW a:hover img.CENTRE_PHOTO_SHOW
@ -1428,18 +1427,22 @@ a:hover img.CENTRE_PHOTO_SHOW
.CENTRE_PHOTO_PRINT .CENTRE_PHOTO_PRINT
{ {
box-sizing:border-box; box-sizing:border-box;
width:720px; width:768px;
height:480px; padding:10px; margin:15px;
padding:15px; margin:18px;
border:solid 1px #EEE; border:solid 1px #EEE;
box-shadow:1px 1px 6px #999; box-shadow:1px 1px 6px #999;
} }
/**************** Attribution (author and license) of images *****************/ /**************** Attribution (author and license) of images *****************/
#AttributionArea
{
box-sizing:border-box;
width:480px;
}
.ATTRIBUTION .ATTRIBUTION
{ {
box-sizing:border-box; box-sizing:border-box;
max-width:500px; margin-bottom:15px;
color:#A0A0A0; color:#A0A0A0;
font-size:8pt; font-size:8pt;
text-align:center; text-align:center;

View File

@ -29,6 +29,7 @@
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include <stdlib.h> // For calloc #include <stdlib.h> // For calloc
#include <string.h> // For string functions #include <string.h> // For string functions
#include <unistd.h> // For unlink
#include "swad_centre.h" #include "swad_centre.h"
#include "swad_constant.h" #include "swad_constant.h"
@ -52,10 +53,14 @@ extern struct Globals Gbl;
/***************************** Private constants *****************************/ /***************************** Private constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
// Centre photo must be stored in Ctr_PHOTO_REAL_WIDTH x Ctr_PHOTO_REAL_HEIGHT // Centre photo will be saved with:
// Aspect ratio: 3:2 (1.5) // - maximum width of Ctr_PHOTO_SAVED_MAX_HEIGHT
#define Ctr_PHOTO_REAL_WIDTH 768 // - maximum height of Ctr_PHOTO_SAVED_MAX_HEIGHT
#define Ctr_PHOTO_REAL_HEIGHT 512 // - maintaining the original aspect ratio (aspect ratio recommended: 3:2)
#define Ctr_RECOMMENDED_ASPECT_RATIO "3:2"
#define Ctr_PHOTO_SAVED_MAX_WIDTH 768
#define Ctr_PHOTO_SAVED_MAX_HEIGHT 512
#define Ctr_PHOTO_SAVED_QUALITY 75 // 1 to 100
/*****************************************************************************/ /*****************************************************************************/
/******************************* Private types *******************************/ /******************************* Private types *******************************/
@ -339,7 +344,8 @@ static void Ctr_Configuration (bool PrintView)
{ {
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">"); fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
Act_FormStart (ActChgCtrPhoAtt); Act_FormStart (ActChgCtrPhoAtt);
fprintf (Gbl.F.Out,"<textarea name=\"Attribution\" cols=\"50\" rows=\"2\"" fprintf (Gbl.F.Out,"<textarea id=\"AttributionArea\""
" name=\"Attribution\" rows=\"2\""
" onchange=\"document.getElementById('%s').submit();\">", " onchange=\"document.getElementById('%s').submit();\">",
Gbl.Form.Id); Gbl.Form.Id);
if (PhotoAttribution) if (PhotoAttribution)
@ -1998,7 +2004,9 @@ void Ctr_RequestPhoto (void)
{ {
extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *The_ClassForm[The_NUM_THEMES];
extern const char *Txt_Photo; extern const char *Txt_Photo;
extern const char *Txt_You_can_send_a_file_with_an_image_in_jpg_format_and_size_X_Y; extern const char *Txt_Recommended_aspect_ratio;
extern const char *Txt_Recommended_resolution;
extern const char *Txt_XxY_pixels_or_higher;
extern const char *Txt_File_with_the_photo; extern const char *Txt_File_with_the_photo;
extern const char *Txt_Upload_photo; extern const char *Txt_Upload_photo;
@ -2011,9 +2019,14 @@ void Ctr_RequestPhoto (void)
"<td class=\"CENTER_MIDDLE\">"); "<td class=\"CENTER_MIDDLE\">");
/***** Write help message *****/ /***** Write help message *****/
sprintf (Gbl.Message,Txt_You_can_send_a_file_with_an_image_in_jpg_format_and_size_X_Y, sprintf (Gbl.Message,"%s: %s<br />"
Ctr_PHOTO_REAL_WIDTH, "%s: %u&times;%u %s",
Ctr_PHOTO_REAL_HEIGHT); Txt_Recommended_aspect_ratio,
Ctr_RECOMMENDED_ASPECT_RATIO,
Txt_Recommended_resolution,
Ctr_PHOTO_SAVED_MAX_WIDTH,
Ctr_PHOTO_SAVED_MAX_HEIGHT,
Txt_XxY_pixels_or_higher);
Lay_ShowAlert (Lay_INFO,Gbl.Message); Lay_ShowAlert (Lay_INFO,Gbl.Message);
/***** Upload photo *****/ /***** Upload photo *****/
@ -2041,14 +2054,70 @@ void Ctr_RequestPhoto (void)
void Ctr_ReceivePhoto (void) void Ctr_ReceivePhoto (void)
{ {
extern const char *Txt_The_file_is_not_X; extern const char *Txt_Wrong_file_type;
char Path[PATH_MAX+1]; char Path[PATH_MAX+1];
char FileNamePhotoSrc[PATH_MAX+1]; char FileNamePhotoSrc[PATH_MAX+1];
char *PtrExtension;
size_t LengthExtension;
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1];
char FileNamePhoto[PATH_MAX+1]; // Full name (including path and .jpg) of the destination file char PathPhotosPriv[PATH_MAX+1];
char FileNamePhotoTmp[PATH_MAX+1]; // Full name (including path and .jpg) of the destination temporary file
char FileNamePhoto[PATH_MAX+1]; // Full name (including path and .jpg) of the destination file
bool WrongType = false; bool WrongType = false;
char Command[1024+PATH_MAX*2];
int ReturnCode;
/***** Creates directories if not exist *****/ /***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/
Fil_StartReceptionOfFile (FileNamePhotoSrc,MIMEType);
/* Check if the file type is image/ or application/octet-stream */
if (strncmp (MIMEType,"image/",strlen ("image/")))
if (strcmp (MIMEType,"application/octet-stream"))
if (strcmp (MIMEType,"application/octetstream"))
if (strcmp (MIMEType,"application/octet"))
WrongType = true;
if (WrongType)
{
Lay_ShowAlert (Lay_WARNING,Txt_Wrong_file_type);
return;
}
/***** Creates private directories if not exist *****/
/* Create private directory for photos if it does not exist */
sprintf (PathPhotosPriv,"%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO);
Fil_CreateDirIfNotExists (PathPhotosPriv);
/* Create temporary private directory for photos if it does not exist */
sprintf (PathPhotosPriv,"%s/%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP);
Fil_CreateDirIfNotExists (PathPhotosPriv);
/* Get filename extension */
if ((PtrExtension = strrchr (FileNamePhotoSrc,(int) '.')) == NULL)
{
Lay_ShowAlert (Lay_WARNING,Txt_Wrong_file_type);
return;
}
LengthExtension = strlen (PtrExtension);
if (LengthExtension < Fil_MIN_LENGTH_FILE_EXTENSION ||
LengthExtension > Fil_MAX_LENGTH_FILE_EXTENSION)
{
Lay_ShowAlert (Lay_WARNING,Txt_Wrong_file_type);
return;
}
/* End the reception of photo in a temporary file */
sprintf (FileNamePhotoTmp,"%s/%s/%s/%s.%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP,
Gbl.UniqueNameEncrypted,PtrExtension);
if (!Fil_EndReceptionOfFile (FileNamePhotoTmp))
{
Lay_ShowAlert (Lay_WARNING,"Error uploading file.");
return;
}
/***** Creates public directories if not exist *****/
sprintf (Path,"%s/%s", sprintf (Path,"%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR); Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR);
Fil_CreateDirIfNotExists (Path); Fil_CreateDirIfNotExists (Path);
@ -2062,35 +2131,37 @@ void Ctr_ReceivePhoto (void)
(unsigned) Gbl.CurrentCtr.Ctr.CtrCod); (unsigned) Gbl.CurrentCtr.Ctr.CtrCod);
Fil_CreateDirIfNotExists (Path); Fil_CreateDirIfNotExists (Path);
/***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/ /***** Convert temporary file to public JPEG file *****/
Fil_StartReceptionOfFile (FileNamePhotoSrc,MIMEType);
/* Check if the file type is image/jpeg or image/pjpeg or application/octet-stream */
if (strcmp (MIMEType,"image/jpeg"))
if (strcmp (MIMEType,"image/pjpeg"))
if (strcmp (MIMEType,"application/octet-stream"))
if (strcmp (MIMEType,"application/octetstream"))
if (strcmp (MIMEType,"application/octet"))
WrongType = true;
if (WrongType)
{
sprintf (Gbl.Message,Txt_The_file_is_not_X,"jpg");
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
return;
}
/* End the reception of photo in a temporary file */
sprintf (FileNamePhoto,"%s/%s/%02u/%u/%u.jpg", sprintf (FileNamePhoto,"%s/%s/%02u/%u/%u.jpg",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR, Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR,
(unsigned) (Gbl.CurrentCtr.Ctr.CtrCod % 100), (unsigned) (Gbl.CurrentCtr.Ctr.CtrCod % 100),
(unsigned) Gbl.CurrentCtr.Ctr.CtrCod, (unsigned) Gbl.CurrentCtr.Ctr.CtrCod,
(unsigned) Gbl.CurrentCtr.Ctr.CtrCod); (unsigned) Gbl.CurrentCtr.Ctr.CtrCod);
if (!Fil_EndReceptionOfFile (FileNamePhoto))
/* Call to program that makes the conversion */
sprintf (Command,"convert %s -resize '%ux%u>' -quality %u %s",
FileNamePhotoTmp,
Ctr_PHOTO_SAVED_MAX_WIDTH,
Ctr_PHOTO_SAVED_MAX_HEIGHT,
Ctr_PHOTO_SAVED_QUALITY,
FileNamePhoto);
ReturnCode = system (Command);
if (ReturnCode == -1)
Lay_ShowErrorAndExit ("Error when running command to process photo.");
/***** Write message depending on return code *****/
ReturnCode = WEXITSTATUS(ReturnCode);
if (ReturnCode != 0)
{ {
Lay_ShowAlert (Lay_WARNING,"Error uploading file."); sprintf (Gbl.Message,"Photo could not be processed successfully.<br />"
return; "Error code returned by the program of processing: %d",
ReturnCode);
Lay_ShowErrorAndExit (Gbl.Message);
} }
/***** Remove temporary file *****/
unlink (FileNamePhotoTmp);
/***** Show the centre information again *****/ /***** Show the centre information again *****/
Ctr_ShowConfiguration (); Ctr_ShowConfiguration ();
} }

View File

@ -125,7 +125,8 @@
// TODO: To avoid wrong email addresses, when a user fills his/her email address, check if the domain is in the white list of allowed domains. If not, ask for confirmation. // TODO: To avoid wrong email addresses, when a user fills his/her email address, check if the domain is in the white list of allowed domains. If not, ask for confirmation.
// TODO: Filtering email addresses --> an email address can not finish in "." // TODO: Filtering email addresses --> an email address can not finish in "."
// TODO: Use libjpeg or similar to check size of uploaded image of a centre // TODO: Use convert after uploading an image of a centre
// convert original-file -resize '768x512>' -quality 75 output-jpeg-file
// TODO: Upload an image in social posts, in test questions, in forum posts, in private messages, etc. // TODO: Upload an image in social posts, in test questions, in forum posts, in private messages, etc.
// TODO: Important!!!! E-mail should not be visible for not logged users // TODO: Important!!!! E-mail should not be visible for not logged users
@ -136,13 +137,14 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.164 (2016-03-28)" #define Log_PLATFORM_VERSION "SWAD 15.165 (2016-03-28)"
#define CSS_FILE "swad15.162.1.css" #define CSS_FILE "swad15.165.css"
#define JS_FILE "swad15.131.3.js" #define JS_FILE "swad15.131.3.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/* /*
Version 15.165: Mar 28, 2016 Use ImageMagick 'convert' after uploading an image of a centre. (? lines)
Version 15.164: Mar 28, 2016 Scope selector inside frame in listing of students. Version 15.164: Mar 28, 2016 Scope selector inside frame in listing of students.
Fix bug in edition of groups. (196664 lines) Fix bug in edition of groups. (196664 lines)
Version 15.163.4: Mar 28, 2016 Scope selector inside frame in listing of teachers. (196656 lines) Version 15.163.4: Mar 28, 2016 Scope selector inside frame in listing of teachers. (196656 lines)

View File

@ -303,10 +303,10 @@ bool Fil_EndReceptionOfFile (char *FileNameDataTmp)
void Fil_CreateUpdateFile (const char *CurrentName,const char *ExtensionOldName,char *OldName,char *NewName,FILE **NewFile) void Fil_CreateUpdateFile (const char *CurrentName,const char *ExtensionOldName,char *OldName,char *NewName,FILE **NewFile)
{ {
int LongRaizFich = Str_GetLengthRootFileName (CurrentName); size_t LengthFileRoot = Str_GetLengthRootFileName (CurrentName);
strncpy (NewName,CurrentName,LongRaizFich); strncpy (NewName,CurrentName,LengthFileRoot);
NewName[LongRaizFich] = '\0'; NewName[LengthFileRoot] = '\0';
sprintf (OldName,"%s%s",NewName,ExtensionOldName); sprintf (OldName,"%s%s",NewName,ExtensionOldName);
strcat (NewName,".new"); strcat (NewName,".new");

View File

@ -34,6 +34,9 @@
/************************** Public types and constants ***********************/ /************************** Public types and constants ***********************/
/*****************************************************************************/ /*****************************************************************************/
#define Fil_MIN_LENGTH_FILE_EXTENSION 1
#define Fil_MAX_LENGTH_FILE_EXTENSION 5
#define Fil_NAME_OF_PARAM_FILENAME_ORG "file" #define Fil_NAME_OF_PARAM_FILENAME_ORG "file"
// Maximum allowed size (in bytes) of a file when uploading it. // Maximum allowed size (in bytes) of a file when uploading it.

View File

@ -8417,7 +8417,9 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
if (Str_ConvertFilFolLnkNameToValid (Gbl.FileBrowser.NewFilFolLnkName)) // Gbl.Message contains feedback text if (Str_ConvertFilFolLnkNameToValid (Gbl.FileBrowser.NewFilFolLnkName)) // Gbl.Message contains feedback text
{ {
/* Gbl.FileBrowser.NewFilFolLnkName holds the name of the new file */ /* Gbl.FileBrowser.NewFilFolLnkName holds the name of the new file */
sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree); sprintf (Path,"%s/%s",
Gbl.FileBrowser.Priv.PathAboveRootFolder,
Gbl.FileBrowser.Priv.FullPathInTree);
if (strlen (Path) + 1 + strlen (Gbl.FileBrowser.NewFilFolLnkName) + strlen (".tmp") > PATH_MAX) if (strlen (Path) + 1 + strlen (Gbl.FileBrowser.NewFilFolLnkName) + strlen (".tmp") > PATH_MAX)
Lay_ShowErrorAndExit ("Path is too long."); Lay_ShowErrorAndExit ("Path is too long.");
strcat (Path,"/"); strcat (Path,"/");
@ -8721,14 +8723,16 @@ static bool Brw_CheckIfUploadIsAllowed (const char *MIMEType)
if ((ExtensionIsAllowed = Str_FileIsHTML (Gbl.FileBrowser.NewFilFolLnkName))) if ((ExtensionIsAllowed = Str_FileIsHTML (Gbl.FileBrowser.NewFilFolLnkName)))
{ {
/* Check MIME type*/ /* Check MIME type*/
if (strcmp (MIMEType,"text/html") && if (strcmp (MIMEType,"text/html"))
strcmp (MIMEType,"text/plain") && if (strcmp (MIMEType,"text/plain"))
strcmp (MIMEType,"application/octet-stream")) // MIME type forbidden if (strcmp (MIMEType,"application/octet-stream"))
{ if (strcmp (MIMEType,"application/octetstream"))
sprintf (Gbl.Message,Txt_UPLOAD_FILE_X_MIME_type_Y_not_allowed_NO_HTML, if (strcmp (MIMEType,"application/octet"))
Gbl.FileBrowser.NewFilFolLnkName,MIMEType); { // MIME type forbidden
return false; sprintf (Gbl.Message,Txt_UPLOAD_FILE_X_MIME_type_Y_not_allowed_NO_HTML,
} Gbl.FileBrowser.NewFilFolLnkName,MIMEType);
return false;
}
} }
else else
{ {

View File

@ -2011,6 +2011,7 @@ void Inf_ReceivePagInfo (void)
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1];
char StrUnzip[100+PATH_MAX*2+1]; char StrUnzip[100+PATH_MAX*2+1];
char *PathWebPage; char *PathWebPage;
bool WrongType = false;
bool FileIsOK = false; bool FileIsOK = false;
/***** Set info type *****/ /***** Set info type *****/
@ -2020,12 +2021,16 @@ void Inf_ReceivePagInfo (void)
Fil_StartReceptionOfFile (SourceFileName,MIMEType); Fil_StartReceptionOfFile (SourceFileName,MIMEType);
/***** Check that MIME type is HTML or ZIP *****/ /***** Check that MIME type is HTML or ZIP *****/
if (strcmp (MIMEType,"text/html") && if (strcmp (MIMEType,"text/html"))
strcmp (MIMEType,"text/plain") && if (strcmp (MIMEType,"text/plain"))
strcmp (MIMEType,"application/x-zip-compressed") && if (strcmp (MIMEType,"application/x-zip-compressed"))
strcmp (MIMEType,"application/zip") && if (strcmp (MIMEType,"application/zip"))
strcmp (MIMEType,"application/octet-stream") && if (strcmp (MIMEType,"application/x-download"))
strcmp (MIMEType,"application/x-download")) if (strcmp (MIMEType,"application/octet-stream"))
if (strcmp (MIMEType,"application/octetstream"))
if (strcmp (MIMEType,"application/octet"))
WrongType = true;
if (WrongType)
{ {
sprintf (Gbl.Message,Txt_The_file_type_is_X_and_should_be_HTML_or_ZIP, sprintf (Gbl.Message,Txt_The_file_type_is_X_and_should_be_HTML_or_ZIP,
MIMEType); MIMEType);

View File

@ -456,7 +456,6 @@ void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat)
extern const char *Txt_Faces_detected; extern const char *Txt_Faces_detected;
char PathPhotosPriv[PATH_MAX+1]; char PathPhotosPriv[PATH_MAX+1];
char PathPhotosPubl[PATH_MAX+1]; char PathPhotosPubl[PATH_MAX+1];
char PathPhotosTmpPubl[PATH_MAX+1];
char FileNamePhotoSrc[PATH_MAX+1]; char FileNamePhotoSrc[PATH_MAX+1];
char FileNamePhotoTmp[PATH_MAX+1]; // Full name (including path and .jpg) of the destination temporary file char FileNamePhotoTmp[PATH_MAX+1]; // Full name (including path and .jpg) of the destination temporary file
char FileNamePhotoMap[PATH_MAX+1]; // Full name (including path) of the temporary file with the original image with faces char FileNamePhotoMap[PATH_MAX+1]; // Full name (including path) of the temporary file with the original image with faces
@ -488,15 +487,20 @@ void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat)
(unsigned) (UsrDat->UsrCod % 100)); (unsigned) (UsrDat->UsrCod % 100));
Fil_CreateDirIfNotExists (PathPhotosPriv); Fil_CreateDirIfNotExists (PathPhotosPriv);
/***** Create directories if not exists
and remove old temporary files *****/
/* Create public directory for photos */
sprintf (PathPhotosPubl,"%s/%s", sprintf (PathPhotosPubl,"%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO); Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO);
Fil_CreateDirIfNotExists (PathPhotosPubl); Fil_CreateDirIfNotExists (PathPhotosPubl);
sprintf (PathPhotosTmpPubl,"%s/%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP);
Fil_CreateDirIfNotExists (PathPhotosTmpPubl);
/***** Remove old files *****/ /* Create temporary directory for photos */
Fil_RemoveOldTmpFiles (PathPhotosTmpPubl,Cfg_TIME_TO_DELETE_PHOTOS_TMP_FILES,false); sprintf (PathPhotosPubl,"%s/%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP);
Fil_CreateDirIfNotExists (PathPhotosPubl);
/* Remove old temporary files */
Fil_RemoveOldTmpFiles (PathPhotosPubl,Cfg_TIME_TO_DELETE_PHOTOS_TMP_FILES,false);
/***** First of all, copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/ /***** First of all, copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/
Fil_StartReceptionOfFile (FileNamePhotoSrc,MIMEType); Fil_StartReceptionOfFile (FileNamePhotoSrc,MIMEType);
@ -579,8 +583,8 @@ void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat)
break; break;
default: // Error default: // Error
sprintf (Gbl.Message,"Photo could not be processed successfully.<br />" sprintf (Gbl.Message,"Photo could not be processed successfully.<br />"
"Error code returned by the program of processing: %d getuid() = %u geteuid() = %u", "Error code returned by the program of processing: %d",
ReturnCode,(unsigned) getuid(), (unsigned) geteuid()); ReturnCode);
Lay_ShowErrorAndExit (Gbl.Message); Lay_ShowErrorAndExit (Gbl.Message);
break; break;
} }

View File

@ -2301,9 +2301,15 @@ long Str_ConvertStrCodToLongCod (const char *Str)
/**** Compute length of root (all except extension) of the name of a file ****/ /**** Compute length of root (all except extension) of the name of a file ****/
/*****************************************************************************/ /*****************************************************************************/
int Str_GetLengthRootFileName (const char *FileName) size_t Str_GetLengthRootFileName (const char *FileName)
{ {
return strlen (FileName) - strlen (strrchr (FileName,(int) '.')); char *PtrToDot = strrchr (FileName,(int) '.');
size_t LengthFileName = strlen (FileName);
if (PtrToDot)
return LengthFileName - strlen (PtrToDot);
else
return LengthFileName;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2359,14 +2365,17 @@ void Str_SplitFullPathIntoPathAndFileName (const char *FullPath,
bool Str_FileIs (const char *FileName,const char *Extension) bool Str_FileIs (const char *FileName,const char *Extension)
{ {
int i,j; int i;
int j;
size_t LengthExtension = strlen (Extension);
/***** Only extensiones of 5 or less characters are valid. For example "zip", "html", "mhtml" *****/ /***** Check length of extension. Extension valid are, for example "zip", "html", "mhtml" *****/
if (strlen (Extension) > 5) if (LengthExtension < Fil_MIN_LENGTH_FILE_EXTENSION ||
LengthExtension > Fil_MAX_LENGTH_FILE_EXTENSION)
return false; return false;
/***** Check the extension *****/ /***** Check the extension *****/
for (i = strlen (FileName) - 1, j = strlen (Extension) - 1; for (i = strlen (FileName) - 1, j = LengthExtension - 1;
i > 0 && j >= 0; i > 0 && j >= 0;
i--, j--) i--, j--)
if (Str_ConvertToLowerLetter (FileName[i]) != Str_ConvertToLowerLetter (Extension[j])) if (Str_ConvertToLowerLetter (FileName[i]) != Str_ConvertToLowerLetter (Extension[j]))

View File

@ -100,7 +100,7 @@ void Str_ReplaceSpecialCharByCodes (char *Str,unsigned long MaxLengthStr);
void Str_ReplaceSeveralSpacesForOne (char *Str); void Str_ReplaceSeveralSpacesForOne (char *Str);
void Str_CopyStrChangingSpaces (const char *StringWithSpaces,char *StringWithoutSpaces,unsigned MaxLength); void Str_CopyStrChangingSpaces (const char *StringWithSpaces,char *StringWithoutSpaces,unsigned MaxLength);
long Str_ConvertStrCodToLongCod (const char *Str); long Str_ConvertStrCodToLongCod (const char *Str);
int Str_GetLengthRootFileName (const char *FileName); size_t Str_GetLengthRootFileName (const char *FileName);
void Str_SplitFullPathIntoPathAndFileName (const char *FullPath, void Str_SplitFullPathIntoPathAndFileName (const char *FullPath,
char *PathWithoutFileName,char *FileName); char *PathWithoutFileName,char *FileName);
bool Str_FileIs (const char *FileName,const char *Extension); bool Str_FileIs (const char *FileName,const char *Extension);

View File

@ -389,7 +389,7 @@ void TsI_ImportQstsFromXML (void)
char FileNameXMLSrc[PATH_MAX+1]; char FileNameXMLSrc[PATH_MAX+1];
char FileNameXMLTmp[PATH_MAX+1]; // Full name (including path and .xml) of the destination temporary file char FileNameXMLTmp[PATH_MAX+1]; // Full name (including path and .xml) of the destination temporary file
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1];
bool CorrectType; bool WrongType = false;
/***** Creates directory if not exists *****/ /***** Creates directory if not exists *****/
sprintf (PathTestPriv,"%s/%s",Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_TEST); sprintf (PathTestPriv,"%s/%s",Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_TEST);
@ -402,29 +402,28 @@ void TsI_ImportQstsFromXML (void)
Fil_StartReceptionOfFile (FileNameXMLSrc,MIMEType); Fil_StartReceptionOfFile (FileNameXMLSrc,MIMEType);
/* Check if the file type is image/jpeg or image/pjpeg or application/octet-stream */ /* Check if the file type is image/jpeg or image/pjpeg or application/octet-stream */
CorrectType = true;
if (strcmp (MIMEType,"text/xml")) if (strcmp (MIMEType,"text/xml"))
if (strcmp (MIMEType,"application/xml")) if (strcmp (MIMEType,"application/xml"))
if (strcmp (MIMEType,"application/octet-stream")) if (strcmp (MIMEType,"application/octet-stream"))
if (strcmp (MIMEType,"application/octetstream")) if (strcmp (MIMEType,"application/octetstream"))
if (strcmp (MIMEType,"application/octet")) if (strcmp (MIMEType,"application/octet"))
CorrectType = false; WrongType = true;
if (CorrectType) if (WrongType)
{
sprintf (Gbl.Message,Txt_The_file_is_not_X,"xml");
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
else
{ {
/* End the reception of XML in a temporary file */ /* End the reception of XML in a temporary file */
sprintf (FileNameXMLTmp,"%s/%s.jpg",PathTestPriv,Gbl.UniqueNameEncrypted); sprintf (FileNameXMLTmp,"%s/%s.xml",PathTestPriv,Gbl.UniqueNameEncrypted);
if (Fil_EndReceptionOfFile (FileNameXMLTmp)) if (Fil_EndReceptionOfFile (FileNameXMLTmp))
/***** Get questions from XML file and store them in database *****/ /***** Get questions from XML file and store them in database *****/
TsI_ReadQuestionsFromXMLFileAndStoreInDB (FileNameXMLTmp); TsI_ReadQuestionsFromXMLFileAndStoreInDB (FileNameXMLTmp);
else else
Lay_ShowAlert (Lay_WARNING,"Error uploading file."); Lay_ShowAlert (Lay_WARNING,"Error uploading file.");
} }
else
{
sprintf (Gbl.Message,Txt_The_file_is_not_X,"xml");
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -27451,6 +27451,27 @@ const char *Txt_photos =
"fotos"; "fotos";
#endif #endif
const char *Txt_XxY_pixels_or_higher =
#if L==1
"p&iacute;xels o m&eacute;s gran";
#elif L==2
"Pixel oder h&ouml;her";
#elif L==3
"pixels or higher";
#elif L==4
"p&iacute;xeles o mayor";
#elif L==5
"pixels ou plus";
#elif L==6
"p&iacute;xeles o mayor"; // Okoteve traducción
#elif L==7
"pixel o superiore";
#elif L==8
"pikseli lub wy&zdot;szej";
#elif L==9
"pixels ou superior";
#endif
const char *Txt_Place = // A particular spot or area const char *Txt_Place = // A particular spot or area
#if L==1 #if L==1
"Lloc"; "Lloc";
@ -28823,6 +28844,48 @@ const char *Txt_Real_number_between_A_and_B_2 =
"e"; "e";
#endif #endif
const char *Txt_Recommended_aspect_ratio =
#if L==1
"Relaci&oacute; d'aspecte recomanada";
#elif L==2
"Empfohlene Seitenverh&auml;ltnisr";
#elif L==3
"Recommended aspect ratio";
#elif L==4
"Relaci&oacute;n de aspecto recomendada";
#elif L==5
"Rapport d'aspect recommand&eacute;";
#elif L==6
"Relaci&oacute;n de aspecto recomendada"; // Okoteve traducción
#elif L==7
"Rapporto aspetto consigliato";
#elif L==8
"Zalecane proporcje obrazu";
#elif L==9
"Propor&ccedil;&atilde;o recomendada";
#endif
const char *Txt_Recommended_resolution =
#if L==1
"Resoluci&oacute; recomanada";
#elif L==2
"Empfohlene Aufl&ouml;sung";
#elif L==3
"Recommended resolution";
#elif L==4
"Resoluci&oacute;n recomendada";
#elif L==5
"R&eacute;solution recommand&eacute;e";
#elif L==6
"Resoluci&oacute;n recomendada"; // Okoteve traducción
#elif L==7
"Risoluzione consigliata";
#elif L==8
"Zalecana rozdzielczo&sacute;&cacute;";
#elif L==9
"Resolu&ccedil;&atilde;o recomendada";
#endif
const char *Txt_Record_card_of_THE_USER_X_has_been_removed = // Warning: it is very important to include %s in the following sentences const char *Txt_Record_card_of_THE_USER_X_has_been_removed = // Warning: it is very important to include %s in the following sentences
#if L==1 #if L==1
"Se ha eliminado la ficha de <strong>%s</strong>."; // Necessita traduccio "Se ha eliminado la ficha de <strong>%s</strong>."; // Necessita traduccio
@ -49938,6 +50001,27 @@ const char *Txt_Write_a_message_to_X = // Warning: it is very important to inclu
"Escrever uma mensagem para %s"; "Escrever uma mensagem para %s";
#endif #endif
const char *Txt_Wrong_file_type =
#if L==1
"Tipus d'arxiu incorrecte.";
#elif L==2
"Falsche Dateityp.";
#elif L==3
"Wrong file type.";
#elif L==4
"Tipo de archivo incorrecto.";
#elif L==5
"Mauvais type de fichier.";
#elif L==6
"Tipo de archivo incorrecto."; // Okoteve traducción
#elif L==7
"Tipo di file sbagliato.";
#elif L==8
"Nieprawid&lstrok;owy typ pliku.";
#elif L==9
"Tipo de arquivo errado.";
#endif
const char *Txt_WWW = // World Wide Web const char *Txt_WWW = // World Wide Web
#if L==1 #if L==1
"WWW"; "WWW";
@ -51670,36 +51754,6 @@ const char *Txt_You_can_send_a_file_with_an_image_in_jpg_format_ =
" and the background must be white or very light."; // Necessita de tradução " and the background must be white or very light."; // Necessita de tradução
#endif #endif
const char *Txt_You_can_send_a_file_with_an_image_in_jpg_format_and_size_X_Y = // Warning: it is very important to include two %u in the following sentences
#if L==1
"Puede enviar un archivo con una imagen en formato <em>jpg</em>"
" y tama&ntilde;o %u&times;%u p&iacute;xeles."; // Necessita traduccio
#elif L==2
"You can send a file with an image in <em>jpg</em> format"
" and size %u&times;%u pixels."; // Need Übersetzung
#elif L==3
"You can send a file with an image in <em>jpg</em> format"
" and size %u&times;%u pixels.";
#elif L==4
"Puede enviar un archivo con una imagen en formato <em>jpg</em>"
" y tama&ntilde;o %u&times;%u p&iacute;xeles.";
#elif L==5
"You can send a file with an image in <em>jpg</em> format"
" and size %u&times;%u pixels."; // Besoin de traduction
#elif L==6
"Puede enviar un archivo con una imagen en formato <em>jpg</em>"
" y tama&ntilde;o %u&times;%u p&iacute;xeles."; // Okoteve traducción
#elif L==7
"Puoi inviare un file con un'immagine in formato <em>jpg</em>"
" e di dimensione %u&times;%u pixel.";
#elif L==8
"You can send a file with an image in <em>jpg</em> format"
" and size %u&times;%u pixels."; // Potrzebujesz tlumaczenie
#elif L==9
"You can send a file with an image in <em>jpg</em> format"
" and size %u&times;%u pixels."; // Necessita de tradução
#endif
const char *Txt_You_dont_follow_any_user = const char *Txt_You_dont_follow_any_user =
#if L==1 #if L==1
"Vost&egrave; no segueix a cap usuari."; "Vost&egrave; no segueix a cap usuari.";