From 0f315d2f6f4d50caa85d9a093fbcfac5d8cc639b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 1 Apr 2016 01:59:27 +0200 Subject: [PATCH] Version 15.170 --- swad_centre.c | 7 +-- swad_changelog.h | 3 +- swad_file.c | 112 ++++++++++++++++++++------------------------ swad_file.h | 4 +- swad_file_browser.c | 5 +- swad_info.c | 7 +-- swad_logo.c | 7 +-- swad_parameter.c | 60 ++++++++++++------------ swad_parameter.h | 6 +-- swad_photo.c | 7 +-- swad_test_import.c | 7 +-- 11 files changed, 112 insertions(+), 113 deletions(-) diff --git a/swad_centre.c b/swad_centre.c index d0d37a00..53682aab 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -2054,6 +2054,7 @@ void Ctr_ReceivePhoto (void) { extern const char *Txt_Wrong_file_type; char Path[PATH_MAX+1]; + struct Param *Param; char FileNameImgSrc[PATH_MAX+1]; char *PtrExtension; size_t LengthExtension; @@ -2066,7 +2067,7 @@ void Ctr_ReceivePhoto (void) int ReturnCode; /***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/ - Fil_StartReceptionOfFile (FileNameImgSrc,MIMEType); + Param = Fil_StartReceptionOfFile (FileNameImgSrc,MIMEType); /* Check if the file type is image/ or application/octet-stream */ if (strncmp (MIMEType,"image/",strlen ("image/"))) @@ -2109,9 +2110,9 @@ void Ctr_ReceivePhoto (void) sprintf (FileNameImgTmp,"%s/%s/%s/%s.%s", Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP, Gbl.UniqueNameEncrypted,PtrExtension); - if (!Fil_EndReceptionOfFile (FileNameImgTmp)) + if (!Fil_EndReceptionOfFile (FileNameImgTmp,Param)) { - Lay_ShowAlert (Lay_WARNING,"Error uploading file."); + Lay_ShowAlert (Lay_WARNING,"Error copying file."); return; } diff --git a/swad_changelog.h b/swad_changelog.h index 709fa6a3..3812c738 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -138,13 +138,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.169.6 (2016-03-31)" +#define Log_PLATFORM_VERSION "SWAD 15.170 (2016-04-01)" #define CSS_FILE "swad15.165.5.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.170: Apr 01, 2016 Code refactoring in function to receive file. (197310 lines) Version 15.169.6: Mar 31, 2016 Code refactoring in function to get a parameter. (197313 lines) Version 15.169.5: Mar 31, 2016 Code refactoring in function to get a parameter. (197292 lines) Version 15.169.4: Mar 31, 2016 Code refactoring in list of parameters. (197280 lines) diff --git a/swad_file.c b/swad_file.c index 053d9e9d..efa16395 100644 --- a/swad_file.c +++ b/swad_file.c @@ -54,6 +54,8 @@ extern struct Globals Gbl; /***************************** Private constants *****************************/ /*****************************************************************************/ +#define NUM_BYTES_PER_CHUNK 4096 + /*****************************************************************************/ /******************************* Private types *******************************/ /*****************************************************************************/ @@ -233,85 +235,75 @@ Content-Type: image/pjpeg 000020 03030304 03030405 08050504 04050A07 ················ etc, etc. */ -void Fil_StartReceptionOfFile (char *SrcFileName,char *MIMEType) +struct Param *Fil_StartReceptionOfFile (char *FileName,char *MIMEType) { - char *Ptr; - int Ch; - int i; -/* struct Param *Param; - Par_GetParameter (Par_PARAM_SINGLE,Fil_NAME_OF_PARAM_FILENAME_ORG,SrcFileName, - PATH_MAX,Param); -*/ - /* At this point, a heading has been read from Gbl.F.Tmp - with all the variables passed by form */ - rewind (Gbl.F.Tmp); - if (!Str_FindStrInFile (Gbl.F.Tmp,Fil_NAME_OF_PARAM_FILENAME_ORG,Str_NO_SKIP_HTML_COMMENTS)) - { - sprintf (Gbl.Message,"Error uploading file: parameter %s not found.", - Fil_NAME_OF_PARAM_FILENAME_ORG); - Lay_ShowErrorAndExit (Gbl.Message); - } - /* Go to the name of the source file */ - if (!Str_FindStrInFile (Gbl.F.Tmp,"filename=\"",Str_NO_SKIP_HTML_COMMENTS)) - Lay_ShowErrorAndExit ("Error uploading file: parameter "filename" not found."); + /***** Get filename *****/ + Par_GetParameter (Par_PARAM_SINGLE,Fil_NAME_OF_PARAM_FILENAME_ORG,FileName, + PATH_MAX,&Param); - /* Get the name of the source file */ - Ptr = SrcFileName; - while ((Ch = fgetc (Gbl.F.Tmp)) != (int) '\"') - *Ptr++ = Ch; - *Ptr = '\0'; + /***** Get MIME type *****/ + /* Check if MIME type exists */ + if (Param->ContentType.Start == 0 || + Param->ContentType.Length == 0 || + Param->ContentType.Length > Brw_MAX_BYTES_MIME_TYPE) + Lay_ShowErrorAndExit ("Error while getting content type."); - /* Get and check the type of data */ - if (!Str_FindStrInFile (Gbl.F.Tmp,"Content-Type:",Str_NO_SKIP_HTML_COMMENTS)) - Lay_ShowErrorAndExit ("Error uploading file: "Content-Type" not found."); + /* Copy MIME type */ + fseek (Gbl.F.Tmp,Param->ContentType.Start,SEEK_SET); + if (fread (MIMEType,sizeof (char),Param->ContentType.Length,Gbl.F.Tmp) != + Param->ContentType.Length) + Lay_ShowErrorAndExit ("Error while getting content type."); - /* Skip spaces and get the type of file */ - while (isspace (Ch = fgetc (Gbl.F.Tmp))); - for (i=0, Ptr = MIMEType; - !isspace (Ch) && i < Brw_MAX_BYTES_MIME_TYPE; - i++) - { - *Ptr++ = Str_ConvertToLowerLetter ((char) Ch); - Ch = fgetc (Gbl.F.Tmp); - } - *Ptr = '\0'; + return Param; } /*****************************************************************************/ /****************** End the reception of data of a file **********************/ /*****************************************************************************/ -bool Fil_EndReceptionOfFile (char *FileNameDataTmp) +bool Fil_EndReceptionOfFile (char *FileNameDataTmp,struct Param *Param) { extern const char *Txt_UPLOAD_FILE_File_too_large_maximum_X_MiB_NO_HTML; FILE *FileDataTmp; - int Result; // Result of the reception of the file + unsigned char Bytes[NUM_BYTES_PER_CHUNK]; + size_t RemainingBytesToCopy; + size_t BytesToCopy; - /***** Open a new file temporary *****/ + /***** Open destination file *****/ if ((FileDataTmp = fopen (FileNameDataTmp,"wb")) == NULL) Lay_ShowErrorAndExit ("Can not open temporary file."); - /***** Skip carriage returns, spaces, etc. *****/ - Str_SkipSpacesInFile (Gbl.F.Tmp); + /***** Copy file *****/ + /* Go to start of source */ + if (Param->Value.Start == 0) + Lay_ShowErrorAndExit ("Error while copying file."); + fseek (Gbl.F.Tmp,Param->Value.Start,SEEK_SET); - /* At this point, the data of the file begin */ - - /***** Write the file *****/ - Result = Str_ReceiveFileUntilDelimitStr (Gbl.F.Tmp,FileDataTmp,(char *) NULL, - Gbl.Boundary.StrWithCRLF, - Fil_MAX_FILE_SIZE); - fclose (FileDataTmp); - if (Result != 1) - /* 0 ==> File too large; -1 ==> Unfinished transmission */ + /* Copy part of Gbl.F.Tmp to FileDataTmp */ + for (RemainingBytesToCopy = Param->Value.Length; + RemainingBytesToCopy != 0; + RemainingBytesToCopy -= BytesToCopy) { - unlink (FileNameDataTmp); - sprintf (Gbl.Message,Txt_UPLOAD_FILE_File_too_large_maximum_X_MiB_NO_HTML, - (unsigned long) (Fil_MAX_FILE_SIZE / (1024ULL * 1024ULL))); - return false; // Error + BytesToCopy = (RemainingBytesToCopy >= NUM_BYTES_PER_CHUNK) ? NUM_BYTES_PER_CHUNK : + RemainingBytesToCopy; + if (fread ((void *) Bytes,1,BytesToCopy,Gbl.F.Tmp) != BytesToCopy) + { + fclose (FileDataTmp); + return false; + } + if (fwrite ((void *) Bytes,sizeof (Bytes[0]),BytesToCopy,FileDataTmp) != BytesToCopy) + { + fclose (FileDataTmp); + return false; + } } - return true; // Success + + /***** Close destination file *****/ + fclose (FileDataTmp); + + return true; } /*****************************************************************************/ @@ -503,14 +495,12 @@ void Fil_FastCopyOfFiles (const char *PathSrc,const char *PathTgt) /************************* Fast copy of open files ***************************/ /*****************************************************************************/ -#define NUM_BYTES_PER_COPY 4096 - void Fil_FastCopyOfOpenFiles (FILE *FileSrc,FILE *FileTgt) { - unsigned char Bytes[NUM_BYTES_PER_COPY]; + unsigned char Bytes[NUM_BYTES_PER_CHUNK]; size_t NumBytesRead; - while ((NumBytesRead = fread ((void *) Bytes,sizeof (Bytes[0]),(size_t) NUM_BYTES_PER_COPY,FileSrc))) + while ((NumBytesRead = fread ((void *) Bytes,sizeof (Bytes[0]),(size_t) NUM_BYTES_PER_CHUNK,FileSrc))) fwrite ((void *) Bytes,sizeof (Bytes[0]),NumBytesRead,FileTgt); } diff --git a/swad_file.h b/swad_file.h index 7dd17c98..3ba61649 100644 --- a/swad_file.h +++ b/swad_file.h @@ -59,8 +59,8 @@ void Fil_CreateFileForHTMLOutput (void); void Fil_CloseAndRemoveFileForHTMLOutput (void); bool Fil_ReadStdinIntoTmpFile (void); void Fil_EndOfReadingStdin (void); -void Fil_StartReceptionOfFile (char *SrcFileName,char *MIMEType); -bool Fil_EndReceptionOfFile (char *FileNameDataTmp); +struct Param *Fil_StartReceptionOfFile (char *FileName,char *MIMEType); +bool Fil_EndReceptionOfFile (char *FileNameDataTmp,struct Param *Param); void Fil_CreateUpdateFile (const char *CurrentName,const char *ExtensionOldName,char *OldName,char *NewName,FILE **NewFile); void Fil_CloseUpdateFile (const char *CurrentName,const char *OldName,const char *NewName,FILE *NewFile); bool Fil_RenameFileOrDir (const char *PathOld,const char *PathNew); diff --git a/swad_file_browser.c b/swad_file_browser.c index a711c4cb..ded362ca 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -8380,6 +8380,7 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) extern const char *Txt_The_file_X_has_been_placed_inside_the_folder_Y; extern const char *Txt_UPLOAD_FILE_You_must_specify_the_file_NO_HTML; extern const char *Txt_UPLOAD_FILE_Forbidden_NO_HTML; + struct Param *Param; char SrcFileName[PATH_MAX+1]; char PathUntilFileName[PATH_MAX+1]; char Path[PATH_MAX+1]; @@ -8404,7 +8405,7 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) if (Brw_CheckIfICanCreateIntoFolder (Gbl.FileBrowser.Level)) { /***** First, we save in disk the file from stdin (really from Gbl.F.Tmp) *****/ - Fil_StartReceptionOfFile (SrcFileName,MIMEType); + Param = Fil_StartReceptionOfFile (SrcFileName,MIMEType); /***** Get filename from path *****/ // Spaces at start or end are allowed @@ -8437,7 +8438,7 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) { /* End receiving the file */ sprintf (PathTmp,"%s.tmp",Path); - FileIsValid = Fil_EndReceptionOfFile (PathTmp); // Gbl.Message contains feedback text + FileIsValid = Fil_EndReceptionOfFile (PathTmp,Param); // Gbl.Message contains feedback text /* Check if the content of the file of marks is valid */ if (FileIsValid) diff --git a/swad_info.c b/swad_info.c index 27b85bd3..e61514d7 100644 --- a/swad_info.c +++ b/swad_info.c @@ -2008,6 +2008,7 @@ void Inf_ReceivePagInfo (void) extern const char *Txt_Found_an_index_htm_file; extern const char *Txt_No_file_index_html_index_htm_found_within_the_ZIP_file; extern const char *Txt_The_file_type_should_be_HTML_or_ZIP; + struct Param *Param; char SourceFileName[PATH_MAX+1]; char PathRelFileHTML[PATH_MAX+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; @@ -2020,7 +2021,7 @@ void Inf_ReceivePagInfo (void) Gbl.CurrentCrs.Info.Type = Inf_AsignInfoType (); /***** First of all, store in disk the file from stdin (really from Gbl.F.Tmp) *****/ - Fil_StartReceptionOfFile (SourceFileName,MIMEType); + Param = Fil_StartReceptionOfFile (SourceFileName,MIMEType); /***** Check that MIME type is HTML or ZIP *****/ if (strcmp (MIMEType,"text/html")) @@ -2048,7 +2049,7 @@ void Inf_ReceivePagInfo (void) Brw_RemoveTree (PathWebPage); Fil_CreateDirIfNotExists (PathWebPage); sprintf (PathRelFileHTML,"%s/index.html",PathWebPage); - if (Fil_EndReceptionOfFile (PathRelFileHTML)) + if (Fil_EndReceptionOfFile (PathRelFileHTML,Param)) { Lay_ShowAlert (Lay_SUCCESS,Txt_The_HTML_file_has_been_received_successfully); FileIsOK = true; @@ -2060,7 +2061,7 @@ void Inf_ReceivePagInfo (void) { Brw_RemoveTree (PathWebPage); Fil_CreateDirIfNotExists (PathWebPage); - if (Fil_EndReceptionOfFile (Gbl.CurrentCrs.Info.Links[Gbl.CurrentCrs.Info.Type].PathRelFileZIP)) + if (Fil_EndReceptionOfFile (Gbl.CurrentCrs.Info.Links[Gbl.CurrentCrs.Info.Type].PathRelFileZIP,Param)) { Lay_ShowAlert (Lay_SUCCESS,Txt_The_ZIP_file_has_been_received_successfully); diff --git a/swad_logo.c b/swad_logo.c index 7e00e8b8..f29e6ae6 100644 --- a/swad_logo.c +++ b/swad_logo.c @@ -321,6 +321,7 @@ void Log_ReceiveLogo (Sco_Scope_t Scope) long Cod; const char *Folder; char Path[PATH_MAX+1]; + struct Param *Param; char FileNameLogoSrc[PATH_MAX+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; char FileNameLogo[PATH_MAX+1]; // Full name (including path and .png) of the destination file @@ -365,7 +366,7 @@ void Log_ReceiveLogo (Sco_Scope_t Scope) Fil_CreateDirIfNotExists (Path); /***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/ - Fil_StartReceptionOfFile (FileNameLogoSrc,MIMEType); + Param = Fil_StartReceptionOfFile (FileNameLogoSrc,MIMEType); /* Check if the file type is image/jpeg or image/pjpeg or application/octet-stream */ if (strcmp (MIMEType,"image/png")) @@ -387,8 +388,8 @@ void Log_ReceiveLogo (Sco_Scope_t Scope) (unsigned) (Cod % 100), (unsigned) Cod, (unsigned) Cod); - if (!Fil_EndReceptionOfFile (FileNameLogo)) - Lay_ShowAlert (Lay_WARNING,"Error uploading file."); + if (!Fil_EndReceptionOfFile (FileNameLogo,Param)) + Lay_ShowAlert (Lay_WARNING,"Error copying file."); } } diff --git a/swad_parameter.c b/swad_parameter.c index 635df8b7..1d9de4ad 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -192,9 +192,9 @@ List --> |Name.Start | -> |Name.Start | +------------------+ / +------------------+ |Name.Length | | |Name.Length | +------------------+ | +------------------+ - |Filename.Start | | |Filename.Start | + |FileName.Start | | |FileName.Start | +------------------+ | +------------------+ - |Filename.Lenght | | |Filename.Lenght | + |FileName.Lenght | | |FileName.Lenght | +------------------+ . +------------------+ |ContentType.Start | . |ContentType.Start | +------------------+ . +------------------+ @@ -354,10 +354,10 @@ static void Par_CreateListOfParamsFromTmpFile (void) { /* Get filename */ CurPos = (unsigned long) ftell (Gbl.F.Tmp); // At start of filename - Param->Filename.Start = CurPos; + Param->FileName.Start = CurPos; Ch = Par_ReadTmpFileUntilQuote (); CurPos = (unsigned long) ftell (Gbl.F.Tmp); // Just after quote - Param->Filename.Length = CurPos - 1 - Param->Filename.Start; + Param->FileName.Length = CurPos - 1 - Param->FileName.Start; /* Check if last character read after filename is a quote */ if (Ch != (int) '\"') break; // '\"' @@ -525,7 +525,7 @@ void Par_FreeParams (void) unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, char *ParamValue,size_t MaxBytes, - struct Param *ParamPtr) // NULL is not used + struct Param **ParamPtr) // NULL if not used { size_t BytesAlreadyCopied = 0; unsigned i; @@ -534,7 +534,8 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, unsigned NumTimes; bool ParamFound = false; unsigned ParamNameLength; - struct StartLength CopyValueFrom; + struct StartLength Copy; + bool FindMoreThanOneOcurrence; /***** Default values returned *****/ ParamValue[0] = '\0'; // By default, the value of the parameter will be an empty string @@ -547,12 +548,12 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, /***** Initializations *****/ ParamNameLength = strlen (ParamName); PtrDst = ParamValue; + FindMoreThanOneOcurrence = (ParamType == Par_PARAM_MULTIPLE); /***** For multiple parameters, loop for any ocurrence of the parameter For unique parameter, find only the first ocurrence *****/ for (Param = Gbl.Params.List, NumTimes = 0; - Param != NULL && - (ParamType == Par_PARAM_MULTIPLE || NumTimes < 1); + Param != NULL && (FindMoreThanOneOcurrence || NumTimes < 1); NumTimes++) /***** Find next ocurrence of parameter in list of parameters *****/ for (ParamFound = false; @@ -585,7 +586,7 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, { /***** Get the first ocurrence of this parameter in list *****/ if (ParamPtr) - ParamPtr = Param; + *ParamPtr = Param; } else // Not the first ocurrence of this parameter { @@ -607,8 +608,21 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, /***** Copy parameter value *****/ if (Param->Value.Length) { + if (Param->FileName.Start != 0) // It's a file + { + /* Copy filename into ParamValue */ + Copy.Start = Param->FileName.Start; + Copy.Length = Param->FileName.Length; + } + else // It's a normal parameter + { + /* Copy value into ParamValue */ + Copy.Start = Param->Value.Start; + Copy.Length = Param->Value.Length; + } + /* Check if there is space to copy the parameter value */ - if (BytesAlreadyCopied + Param->Value.Length > MaxBytes) + if (BytesAlreadyCopied + Copy.Length > MaxBytes) { sprintf (Gbl.Message,"Parameter %s too large," " it exceed the maximum allowed size (%lu bytes).", @@ -620,31 +634,19 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, switch (Gbl.ContentReceivedByCGI) { case Act_CONTENT_NORM: - strncpy (PtrDst,&Gbl.Params.QueryString[Param->Value.Start], - Param->Value.Length); + strncpy (PtrDst,&Gbl.Params.QueryString[Copy.Start], + Copy.Length); break; case Act_CONTENT_DATA: - if (Param->Filename.Start) // It's a file - { - /* Copy filename in ParamValue */ - CopyValueFrom.Start = Param->Filename.Start; - CopyValueFrom.Length = Param->Filename.Length; - } - else // It's a normal parameter - { - /* Copy value in ParamValue */ - CopyValueFrom.Start = Param->Value.Start; - CopyValueFrom.Length = Param->Value.Length; - } - fseek (Gbl.F.Tmp,CopyValueFrom.Start,SEEK_SET); - if (fread (PtrDst,sizeof (char),CopyValueFrom.Length,Gbl.F.Tmp) != - CopyValueFrom.Length) + fseek (Gbl.F.Tmp,Copy.Start,SEEK_SET); + if (fread ((void *) PtrDst,sizeof (char),Copy.Length,Gbl.F.Tmp) != + Copy.Length) Lay_ShowErrorAndExit ("Error while getting value of parameter."); break; } - BytesAlreadyCopied += Param->Value.Length; - PtrDst += Param->Value.Length; + BytesAlreadyCopied += Copy.Length; + PtrDst += Copy.Length; } } } diff --git a/swad_parameter.h b/swad_parameter.h index d38d90a4..3722a272 100644 --- a/swad_parameter.h +++ b/swad_parameter.h @@ -44,8 +44,8 @@ struct StartLength struct Param { struct StartLength Name; // Parameter name - struct StartLength Filename; // optional - struct StartLength ContentType; // optional + struct StartLength FileName; // optional, present only when uploading files + struct StartLength ContentType; // optional, present only when uploading files struct StartLength Value; // Parameter value or file content struct Param *Next; }; @@ -67,7 +67,7 @@ void Par_CreateListOfParams (void); void Par_FreeParams (void); unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, char *ParamValue,size_t MaxBytes, - struct Param *ParamPtr); + struct Param **ParamPtr); void Par_GetMainParameters (void); diff --git a/swad_photo.c b/swad_photo.c index b5b3a706..c8578959 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -450,6 +450,7 @@ 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]; + struct Param *Param; 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 @@ -497,7 +498,7 @@ void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat) 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); + Param = Fil_StartReceptionOfFile (FileNamePhotoSrc,MIMEType); /* Check if the file type is image/jpeg or image/pjpeg or application/octet-stream */ if (strcmp (MIMEType,"image/jpeg")) @@ -517,9 +518,9 @@ void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat) sprintf (FileNamePhotoTmp,"%s/%s/%s/%s.jpg", Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO, Cfg_FOLDER_PHOTO_TMP,Gbl.UniqueNameEncrypted); - if (!Fil_EndReceptionOfFile (FileNamePhotoTmp)) + if (!Fil_EndReceptionOfFile (FileNamePhotoTmp,Param)) { - Lay_ShowAlert (Lay_WARNING,"Error uploading file."); + Lay_ShowAlert (Lay_WARNING,"Error copying file."); return; } diff --git a/swad_test_import.c b/swad_test_import.c index b7f1069d..1b1780af 100644 --- a/swad_test_import.c +++ b/swad_test_import.c @@ -386,6 +386,7 @@ void TsI_ImportQstsFromXML (void) { extern const char *Txt_The_file_is_not_X; char PathTestPriv[PATH_MAX+1]; + struct Param *Param; 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]; @@ -399,7 +400,7 @@ void TsI_ImportQstsFromXML (void) Fil_RemoveOldTmpFiles (PathTestPriv,Cfg_TIME_TO_DELETE_TEST_TMP_FILES,false); /***** First of all, copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/ - Fil_StartReceptionOfFile (FileNameXMLSrc,MIMEType); + Param = Fil_StartReceptionOfFile (FileNameXMLSrc,MIMEType); /* Check if the file type is image/jpeg or image/pjpeg or application/octet-stream */ if (strcmp (MIMEType,"text/xml")) @@ -418,11 +419,11 @@ void TsI_ImportQstsFromXML (void) { /* End the reception of XML in a temporary file */ sprintf (FileNameXMLTmp,"%s/%s.xml",PathTestPriv,Gbl.UniqueNameEncrypted); - if (Fil_EndReceptionOfFile (FileNameXMLTmp)) + if (Fil_EndReceptionOfFile (FileNameXMLTmp,Param)) /***** Get questions from XML file and store them in database *****/ TsI_ReadQuestionsFromXMLFileAndStoreInDB (FileNameXMLTmp); else - Lay_ShowAlert (Lay_WARNING,"Error uploading file."); + Lay_ShowAlert (Lay_WARNING,"Error copying file."); } }