mirror of https://github.com/acanas/swad-core.git
Version 15.165
This commit is contained in:
parent
10d5ae1a49
commit
c025d71655
|
@ -1416,8 +1416,7 @@ a:hover /* Default ==> underlined */
|
|||
{
|
||||
box-sizing:border-box;
|
||||
width:480px;
|
||||
height:320px;
|
||||
padding:6px; margin:10px;
|
||||
padding:6px; margin:9px;
|
||||
border:solid 1px #EEE;
|
||||
}
|
||||
a:hover img.CENTRE_PHOTO_SHOW
|
||||
|
@ -1428,18 +1427,22 @@ a:hover img.CENTRE_PHOTO_SHOW
|
|||
.CENTRE_PHOTO_PRINT
|
||||
{
|
||||
box-sizing:border-box;
|
||||
width:720px;
|
||||
height:480px;
|
||||
padding:15px; margin:18px;
|
||||
width:768px;
|
||||
padding:10px; margin:15px;
|
||||
border:solid 1px #EEE;
|
||||
box-shadow:1px 1px 6px #999;
|
||||
}
|
||||
|
||||
/**************** Attribution (author and license) of images *****************/
|
||||
#AttributionArea
|
||||
{
|
||||
box-sizing:border-box;
|
||||
width:480px;
|
||||
}
|
||||
.ATTRIBUTION
|
||||
{
|
||||
box-sizing:border-box;
|
||||
max-width:500px;
|
||||
margin-bottom:15px;
|
||||
color:#A0A0A0;
|
||||
font-size:8pt;
|
||||
text-align:center;
|
137
swad_centre.c
137
swad_centre.c
|
@ -29,6 +29,7 @@
|
|||
#include <stdbool.h> // For boolean type
|
||||
#include <stdlib.h> // For calloc
|
||||
#include <string.h> // For string functions
|
||||
#include <unistd.h> // For unlink
|
||||
|
||||
#include "swad_centre.h"
|
||||
#include "swad_constant.h"
|
||||
|
@ -52,10 +53,14 @@ extern struct Globals Gbl;
|
|||
/***************************** Private constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// Centre photo must be stored in Ctr_PHOTO_REAL_WIDTH x Ctr_PHOTO_REAL_HEIGHT
|
||||
// Aspect ratio: 3:2 (1.5)
|
||||
#define Ctr_PHOTO_REAL_WIDTH 768
|
||||
#define Ctr_PHOTO_REAL_HEIGHT 512
|
||||
// Centre photo will be saved with:
|
||||
// - maximum width of Ctr_PHOTO_SAVED_MAX_HEIGHT
|
||||
// - maximum height of Ctr_PHOTO_SAVED_MAX_HEIGHT
|
||||
// - 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 *******************************/
|
||||
|
@ -339,7 +344,8 @@ static void Ctr_Configuration (bool PrintView)
|
|||
{
|
||||
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
|
||||
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();\">",
|
||||
Gbl.Form.Id);
|
||||
if (PhotoAttribution)
|
||||
|
@ -1998,7 +2004,9 @@ void Ctr_RequestPhoto (void)
|
|||
{
|
||||
extern const char *The_ClassForm[The_NUM_THEMES];
|
||||
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_Upload_photo;
|
||||
|
||||
|
@ -2011,9 +2019,14 @@ void Ctr_RequestPhoto (void)
|
|||
"<td class=\"CENTER_MIDDLE\">");
|
||||
|
||||
/***** Write help message *****/
|
||||
sprintf (Gbl.Message,Txt_You_can_send_a_file_with_an_image_in_jpg_format_and_size_X_Y,
|
||||
Ctr_PHOTO_REAL_WIDTH,
|
||||
Ctr_PHOTO_REAL_HEIGHT);
|
||||
sprintf (Gbl.Message,"%s: %s<br />"
|
||||
"%s: %u×%u %s",
|
||||
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);
|
||||
|
||||
/***** Upload photo *****/
|
||||
|
@ -2041,14 +2054,70 @@ void Ctr_RequestPhoto (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 FileNamePhotoSrc[PATH_MAX+1];
|
||||
char *PtrExtension;
|
||||
size_t LengthExtension;
|
||||
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;
|
||||
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",
|
||||
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR);
|
||||
Fil_CreateDirIfNotExists (Path);
|
||||
|
@ -2062,35 +2131,37 @@ void Ctr_ReceivePhoto (void)
|
|||
(unsigned) Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
Fil_CreateDirIfNotExists (Path);
|
||||
|
||||
/***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/
|
||||
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 */
|
||||
/***** Convert temporary file to public JPEG file *****/
|
||||
sprintf (FileNamePhoto,"%s/%s/%02u/%u/%u.jpg",
|
||||
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR,
|
||||
(unsigned) (Gbl.CurrentCtr.Ctr.CtrCod % 100),
|
||||
(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.");
|
||||
return;
|
||||
sprintf (Gbl.Message,"Photo could not be processed successfully.<br />"
|
||||
"Error code returned by the program of processing: %d",
|
||||
ReturnCode);
|
||||
Lay_ShowErrorAndExit (Gbl.Message);
|
||||
}
|
||||
|
||||
/***** Remove temporary file *****/
|
||||
unlink (FileNamePhotoTmp);
|
||||
|
||||
/***** Show the centre information again *****/
|
||||
Ctr_ShowConfiguration ();
|
||||
}
|
||||
|
|
|
@ -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: 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: Important!!!! E-mail should not be visible for not logged users
|
||||
|
@ -136,13 +137,14 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.164 (2016-03-28)"
|
||||
#define CSS_FILE "swad15.162.1.css"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.165 (2016-03-28)"
|
||||
#define CSS_FILE "swad15.165.css"
|
||||
#define JS_FILE "swad15.131.3.js"
|
||||
|
||||
// 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
|
||||
/*
|
||||
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.
|
||||
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)
|
||||
|
|
|
@ -303,10 +303,10 @@ bool Fil_EndReceptionOfFile (char *FileNameDataTmp)
|
|||
|
||||
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);
|
||||
NewName[LongRaizFich] = '\0';
|
||||
strncpy (NewName,CurrentName,LengthFileRoot);
|
||||
NewName[LengthFileRoot] = '\0';
|
||||
sprintf (OldName,"%s%s",NewName,ExtensionOldName);
|
||||
strcat (NewName,".new");
|
||||
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
/************************** 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"
|
||||
|
||||
// Maximum allowed size (in bytes) of a file when uploading it.
|
||||
|
|
|
@ -8417,7 +8417,9 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
|
|||
if (Str_ConvertFilFolLnkNameToValid (Gbl.FileBrowser.NewFilFolLnkName)) // Gbl.Message contains feedback text
|
||||
{
|
||||
/* 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)
|
||||
Lay_ShowErrorAndExit ("Path is too long.");
|
||||
strcat (Path,"/");
|
||||
|
@ -8721,14 +8723,16 @@ static bool Brw_CheckIfUploadIsAllowed (const char *MIMEType)
|
|||
if ((ExtensionIsAllowed = Str_FileIsHTML (Gbl.FileBrowser.NewFilFolLnkName)))
|
||||
{
|
||||
/* Check MIME type*/
|
||||
if (strcmp (MIMEType,"text/html") &&
|
||||
strcmp (MIMEType,"text/plain") &&
|
||||
strcmp (MIMEType,"application/octet-stream")) // MIME type forbidden
|
||||
{
|
||||
sprintf (Gbl.Message,Txt_UPLOAD_FILE_X_MIME_type_Y_not_allowed_NO_HTML,
|
||||
Gbl.FileBrowser.NewFilFolLnkName,MIMEType);
|
||||
return false;
|
||||
}
|
||||
if (strcmp (MIMEType,"text/html"))
|
||||
if (strcmp (MIMEType,"text/plain"))
|
||||
if (strcmp (MIMEType,"application/octet-stream"))
|
||||
if (strcmp (MIMEType,"application/octetstream"))
|
||||
if (strcmp (MIMEType,"application/octet"))
|
||||
{ // MIME type forbidden
|
||||
sprintf (Gbl.Message,Txt_UPLOAD_FILE_X_MIME_type_Y_not_allowed_NO_HTML,
|
||||
Gbl.FileBrowser.NewFilFolLnkName,MIMEType);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
17
swad_info.c
17
swad_info.c
|
@ -2011,6 +2011,7 @@ void Inf_ReceivePagInfo (void)
|
|||
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1];
|
||||
char StrUnzip[100+PATH_MAX*2+1];
|
||||
char *PathWebPage;
|
||||
bool WrongType = false;
|
||||
bool FileIsOK = false;
|
||||
|
||||
/***** Set info type *****/
|
||||
|
@ -2020,12 +2021,16 @@ void Inf_ReceivePagInfo (void)
|
|||
Fil_StartReceptionOfFile (SourceFileName,MIMEType);
|
||||
|
||||
/***** Check that MIME type is HTML or ZIP *****/
|
||||
if (strcmp (MIMEType,"text/html") &&
|
||||
strcmp (MIMEType,"text/plain") &&
|
||||
strcmp (MIMEType,"application/x-zip-compressed") &&
|
||||
strcmp (MIMEType,"application/zip") &&
|
||||
strcmp (MIMEType,"application/octet-stream") &&
|
||||
strcmp (MIMEType,"application/x-download"))
|
||||
if (strcmp (MIMEType,"text/html"))
|
||||
if (strcmp (MIMEType,"text/plain"))
|
||||
if (strcmp (MIMEType,"application/x-zip-compressed"))
|
||||
if (strcmp (MIMEType,"application/zip"))
|
||||
if (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,
|
||||
MIMEType);
|
||||
|
|
20
swad_photo.c
20
swad_photo.c
|
@ -456,7 +456,6 @@ void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat)
|
|||
extern const char *Txt_Faces_detected;
|
||||
char PathPhotosPriv[PATH_MAX+1];
|
||||
char PathPhotosPubl[PATH_MAX+1];
|
||||
char PathPhotosTmpPubl[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 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));
|
||||
Fil_CreateDirIfNotExists (PathPhotosPriv);
|
||||
|
||||
/***** Create directories if not exists
|
||||
and remove old temporary files *****/
|
||||
/* Create public directory for photos */
|
||||
sprintf (PathPhotosPubl,"%s/%s",
|
||||
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO);
|
||||
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 *****/
|
||||
Fil_RemoveOldTmpFiles (PathPhotosTmpPubl,Cfg_TIME_TO_DELETE_PHOTOS_TMP_FILES,false);
|
||||
/* Create temporary directory for photos */
|
||||
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) *****/
|
||||
Fil_StartReceptionOfFile (FileNamePhotoSrc,MIMEType);
|
||||
|
@ -579,8 +583,8 @@ void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat)
|
|||
break;
|
||||
default: // Error
|
||||
sprintf (Gbl.Message,"Photo could not be processed successfully.<br />"
|
||||
"Error code returned by the program of processing: %d getuid() = %u geteuid() = %u",
|
||||
ReturnCode,(unsigned) getuid(), (unsigned) geteuid());
|
||||
"Error code returned by the program of processing: %d",
|
||||
ReturnCode);
|
||||
Lay_ShowErrorAndExit (Gbl.Message);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2301,9 +2301,15 @@ long Str_ConvertStrCodToLongCod (const char *Str)
|
|||
/**** 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)
|
||||
{
|
||||
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" *****/
|
||||
if (strlen (Extension) > 5)
|
||||
/***** Check length of extension. Extension valid are, for example "zip", "html", "mhtml" *****/
|
||||
if (LengthExtension < Fil_MIN_LENGTH_FILE_EXTENSION ||
|
||||
LengthExtension > Fil_MAX_LENGTH_FILE_EXTENSION)
|
||||
return false;
|
||||
|
||||
/***** 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--, j--)
|
||||
if (Str_ConvertToLowerLetter (FileName[i]) != Str_ConvertToLowerLetter (Extension[j]))
|
||||
|
|
|
@ -100,7 +100,7 @@ void Str_ReplaceSpecialCharByCodes (char *Str,unsigned long MaxLengthStr);
|
|||
void Str_ReplaceSeveralSpacesForOne (char *Str);
|
||||
void Str_CopyStrChangingSpaces (const char *StringWithSpaces,char *StringWithoutSpaces,unsigned MaxLength);
|
||||
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,
|
||||
char *PathWithoutFileName,char *FileName);
|
||||
bool Str_FileIs (const char *FileName,const char *Extension);
|
||||
|
|
|
@ -389,7 +389,7 @@ void TsI_ImportQstsFromXML (void)
|
|||
char FileNameXMLSrc[PATH_MAX+1];
|
||||
char FileNameXMLTmp[PATH_MAX+1]; // Full name (including path and .xml) of the destination temporary file
|
||||
char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1];
|
||||
bool CorrectType;
|
||||
bool WrongType = false;
|
||||
|
||||
/***** Creates directory if not exists *****/
|
||||
sprintf (PathTestPriv,"%s/%s",Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_TEST);
|
||||
|
@ -402,29 +402,28 @@ void TsI_ImportQstsFromXML (void)
|
|||
Fil_StartReceptionOfFile (FileNameXMLSrc,MIMEType);
|
||||
|
||||
/* 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,"application/xml"))
|
||||
if (strcmp (MIMEType,"application/octet-stream"))
|
||||
if (strcmp (MIMEType,"application/octetstream"))
|
||||
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 */
|
||||
sprintf (FileNameXMLTmp,"%s/%s.jpg",PathTestPriv,Gbl.UniqueNameEncrypted);
|
||||
sprintf (FileNameXMLTmp,"%s/%s.xml",PathTestPriv,Gbl.UniqueNameEncrypted);
|
||||
if (Fil_EndReceptionOfFile (FileNameXMLTmp))
|
||||
/***** Get questions from XML file and store them in database *****/
|
||||
TsI_ReadQuestionsFromXMLFileAndStoreInDB (FileNameXMLTmp);
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,"Error uploading file.");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (Gbl.Message,Txt_The_file_is_not_X,"xml");
|
||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
114
swad_text.c
114
swad_text.c
|
@ -27451,6 +27451,27 @@ const char *Txt_photos =
|
|||
"fotos";
|
||||
#endif
|
||||
|
||||
const char *Txt_XxY_pixels_or_higher =
|
||||
#if L==1
|
||||
"píxels o més gran";
|
||||
#elif L==2
|
||||
"Pixel oder höher";
|
||||
#elif L==3
|
||||
"pixels or higher";
|
||||
#elif L==4
|
||||
"píxeles o mayor";
|
||||
#elif L==5
|
||||
"pixels ou plus";
|
||||
#elif L==6
|
||||
"píxeles o mayor"; // Okoteve traducción
|
||||
#elif L==7
|
||||
"pixel o superiore";
|
||||
#elif L==8
|
||||
"pikseli lub wyższej";
|
||||
#elif L==9
|
||||
"pixels ou superior";
|
||||
#endif
|
||||
|
||||
const char *Txt_Place = // A particular spot or area
|
||||
#if L==1
|
||||
"Lloc";
|
||||
|
@ -28823,6 +28844,48 @@ const char *Txt_Real_number_between_A_and_B_2 =
|
|||
"e";
|
||||
#endif
|
||||
|
||||
const char *Txt_Recommended_aspect_ratio =
|
||||
#if L==1
|
||||
"Relació d'aspecte recomanada";
|
||||
#elif L==2
|
||||
"Empfohlene Seitenverhältnisr";
|
||||
#elif L==3
|
||||
"Recommended aspect ratio";
|
||||
#elif L==4
|
||||
"Relación de aspecto recomendada";
|
||||
#elif L==5
|
||||
"Rapport d'aspect recommandé";
|
||||
#elif L==6
|
||||
"Relación de aspecto recomendada"; // Okoteve traducción
|
||||
#elif L==7
|
||||
"Rapporto aspetto consigliato";
|
||||
#elif L==8
|
||||
"Zalecane proporcje obrazu";
|
||||
#elif L==9
|
||||
"Proporção recomendada";
|
||||
#endif
|
||||
|
||||
const char *Txt_Recommended_resolution =
|
||||
#if L==1
|
||||
"Resolució recomanada";
|
||||
#elif L==2
|
||||
"Empfohlene Auflösung";
|
||||
#elif L==3
|
||||
"Recommended resolution";
|
||||
#elif L==4
|
||||
"Resolución recomendada";
|
||||
#elif L==5
|
||||
"Résolution recommandée";
|
||||
#elif L==6
|
||||
"Resolución recomendada"; // Okoteve traducción
|
||||
#elif L==7
|
||||
"Risoluzione consigliata";
|
||||
#elif L==8
|
||||
"Zalecana rozdzielczość";
|
||||
#elif L==9
|
||||
"Resoluçã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
|
||||
#if L==1
|
||||
"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";
|
||||
#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łowy typ pliku.";
|
||||
#elif L==9
|
||||
"Tipo de arquivo errado.";
|
||||
#endif
|
||||
|
||||
const char *Txt_WWW = // World Wide Web
|
||||
#if L==1
|
||||
"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
|
||||
#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ño %u×%u píxeles."; // Necessita traduccio
|
||||
#elif L==2
|
||||
"You can send a file with an image in <em>jpg</em> format"
|
||||
" and size %u×%u pixels."; // Need Übersetzung
|
||||
#elif L==3
|
||||
"You can send a file with an image in <em>jpg</em> format"
|
||||
" and size %u×%u pixels.";
|
||||
#elif L==4
|
||||
"Puede enviar un archivo con una imagen en formato <em>jpg</em>"
|
||||
" y tamaño %u×%u píxeles.";
|
||||
#elif L==5
|
||||
"You can send a file with an image in <em>jpg</em> format"
|
||||
" and size %u×%u pixels."; // Besoin de traduction
|
||||
#elif L==6
|
||||
"Puede enviar un archivo con una imagen en formato <em>jpg</em>"
|
||||
" y tamaño %u×%u píxeles."; // Okoteve traducción
|
||||
#elif L==7
|
||||
"Puoi inviare un file con un'immagine in formato <em>jpg</em>"
|
||||
" e di dimensione %u×%u pixel.";
|
||||
#elif L==8
|
||||
"You can send a file with an image in <em>jpg</em> format"
|
||||
" and size %u×%u pixels."; // Potrzebujesz tlumaczenie
|
||||
#elif L==9
|
||||
"You can send a file with an image in <em>jpg</em> format"
|
||||
" and size %u×%u pixels."; // Necessita de tradução
|
||||
#endif
|
||||
|
||||
const char *Txt_You_dont_follow_any_user =
|
||||
#if L==1
|
||||
"Vostè no segueix a cap usuari.";
|
||||
|
|
Loading…
Reference in New Issue