Version 18.6.6

This commit is contained in:
Antonio Cañas Vargas 2018-10-18 02:02:32 +02:00
parent 2f2c0b731c
commit 86ed4799a8
53 changed files with 1155 additions and 720 deletions

View File

@ -516,7 +516,9 @@ void ID_ShowFormChangeMyID (bool IShouldFillID)
Lay_StartSection (ID_ID_SECTION_ID); Lay_StartSection (ID_ID_SECTION_ID);
/***** Start box *****/ /***** Start box *****/
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH); snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
Box_StartBox (StrRecordWidth,Txt_ID,Acc_PutLinkToRemoveMyAccount, Box_StartBox (StrRecordWidth,Txt_ID,Acc_PutLinkToRemoveMyAccount,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE); Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
@ -546,7 +548,9 @@ void ID_ShowFormChangeOtherUsrID (void)
Lay_StartSection (ID_ID_SECTION_ID); Lay_StartSection (ID_ID_SECTION_ID);
/***** Start box *****/ /***** Start box *****/
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH); snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
Box_StartBox (StrRecordWidth,Txt_ID,NULL, Box_StartBox (StrRecordWidth,Txt_ID,NULL,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE); Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
@ -646,10 +650,10 @@ static void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,
} }
/* User's ID */ /* User's ID */
sprintf (Gbl.Title, snprintf (Gbl.Title,sizeof (Gbl.Title),
UsrDat->IDs.List[NumID].Confirmed ? Txt_ID_X_confirmed : UsrDat->IDs.List[NumID].Confirmed ? Txt_ID_X_confirmed :
Txt_ID_X_not_confirmed, Txt_ID_X_not_confirmed,
UsrDat->IDs.List[NumID].ID); UsrDat->IDs.List[NumID].ID);
fprintf (Gbl.F.Out,"<span class=\"%s\" title=\"%s\">%s</span>", fprintf (Gbl.F.Out,"<span class=\"%s\" title=\"%s\">%s</span>",
UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" : UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" :
"USR_ID_NC", "USR_ID_NC",
@ -659,7 +663,9 @@ static void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,
/* ID confirmed? */ /* ID confirmed? */
if (UsrDat->IDs.List[NumID].Confirmed) if (UsrDat->IDs.List[NumID].Confirmed)
{ {
sprintf (Gbl.Title,Txt_ID_X_confirmed,UsrDat->IDs.List[NumID].ID); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_ID_X_confirmed,
UsrDat->IDs.List[NumID].ID);
fprintf (Gbl.F.Out,"<img src=\"%s/ok_green16x16.gif\"" fprintf (Gbl.F.Out,"<img src=\"%s/ok_green16x16.gif\""
" alt=\"%s\" title=\"%s\"" " alt=\"%s\" title=\"%s\""
" class=\"ICO20x20\" />", " class=\"ICO20x20\" />",

View File

@ -235,7 +235,9 @@ void MFU_WriteBigMFUActions (struct MFU_ListMFUActions *ListMFUActions)
MFU_MAX_BYTES_TAB); MFU_MAX_BYTES_TAB);
Str_Copy (MenuStr,Title, Str_Copy (MenuStr,Title,
MFU_MAX_BYTES_MENU); MFU_MAX_BYTES_MENU);
sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr); snprintf (TabMenuStr,sizeof (TabMenuStr),
"%s &gt; %s",
TabStr,MenuStr);
/* Icon and text */ /* Icon and text */
fprintf (Gbl.F.Out,"<li>"); fprintf (Gbl.F.Out,"<li>");
@ -296,7 +298,9 @@ void MFU_WriteSmallMFUActions (struct MFU_ListMFUActions *ListMFUActions)
MFU_MAX_BYTES_TAB); MFU_MAX_BYTES_TAB);
Str_Copy (MenuStr,Title, Str_Copy (MenuStr,Title,
MFU_MAX_BYTES_MENU); MFU_MAX_BYTES_MENU);
sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr); snprintf (TabMenuStr,sizeof (TabMenuStr),
"%s &gt; %s",
TabStr,MenuStr);
/* Icon and text */ /* Icon and text */
fprintf (Gbl.F.Out,"<li>"); fprintf (Gbl.F.Out,"<li>");

View File

@ -65,11 +65,15 @@ void RSS_UpdateRSSFileForACrs (struct Course *Crs)
struct tm *tm; struct tm *tm;
/***** Create RSS directory if not exists *****/ /***** Create RSS directory if not exists *****/
sprintf (PathRelPublRSSDir,"%s/%s/%ld/%s",Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CRS,Crs->CrsCod,Cfg_RSS_FOLDER); snprintf (PathRelPublRSSDir,sizeof (PathRelPublRSSDir),
"%s/%s/%ld/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CRS,Crs->CrsCod,Cfg_RSS_FOLDER);
Fil_CreateDirIfNotExists (PathRelPublRSSDir); Fil_CreateDirIfNotExists (PathRelPublRSSDir);
/***** Create RSS file *****/ /***** Create RSS file *****/
sprintf (PathRelPublRSSFile,"%s/%s",PathRelPublRSSDir,Cfg_RSS_FILE); snprintf (PathRelPublRSSFile,sizeof (PathRelPublRSSFile),
"%s/%s",
PathRelPublRSSDir,Cfg_RSS_FILE);
if ((FileRSS = fopen (PathRelPublRSSFile,"wb")) == NULL) if ((FileRSS = fopen (PathRelPublRSSFile,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not create RSS file."); Lay_ShowErrorAndExit ("Can not create RSS file.");

View File

@ -5241,12 +5241,12 @@ static void Act_StartFormInternal (Act_Action_t NextAction,bool PutParameterLoca
} }
} }
void Act_SetParamsForm (char ParamsStr[Act_MAX_BYTES_PARAMS_STR],Act_Action_t NextAction, void Act_SetParamsForm (char ParamsStr[Act_MAX_BYTES_PARAMS_STR + 1],Act_Action_t NextAction,
bool PutParameterLocationIfNoSesion) bool PutParameterLocationIfNoSesion)
{ {
char ParamAction[Act_MAX_BYTES_PARAM_ACTION]; char ParamAction[Act_MAX_BYTES_PARAM_ACTION + 1];
char ParamSession[Act_MAX_BYTES_PARAM_SESSION]; char ParamSession[Act_MAX_BYTES_PARAM_SESSION + 1];
char ParamLocation[Act_MAX_BYTES_PARAM_LOCATION]; char ParamLocation[Act_MAX_BYTES_PARAM_LOCATION + 1];
ParamAction[0] = '\0'; ParamAction[0] = '\0';
ParamSession[0] = '\0'; ParamSession[0] = '\0';
@ -5294,7 +5294,7 @@ void Act_SetParamsForm (char ParamsStr[Act_MAX_BYTES_PARAMS_STR],Act_Action_t Ne
Gbl.CurrentCty.Cty.CtyCod); Gbl.CurrentCty.Cty.CtyCod);
} }
snprintf (ParamsStr,Act_MAX_BYTES_PARAMS_STR, snprintf (ParamsStr,Act_MAX_BYTES_PARAMS_STR + 1,
"%s%s%s", "%s%s%s",
ParamAction,ParamSession,ParamLocation); ParamAction,ParamSession,ParamLocation);
} }
@ -5375,7 +5375,7 @@ void Act_LinkFormSubmitAnimated (const char *Title,const char *LinkStyle,
/***************************** Get unique Id *********************************/ /***************************** Get unique Id *********************************/
/*****************************************************************************/ /*****************************************************************************/
void Act_SetUniqueId (char UniqueId[Act_MAX_BYTES_ID]) void Act_SetUniqueId (char UniqueId[Act_MAX_BYTES_ID + 1])
{ {
static unsigned CountForThisExecution = 0; static unsigned CountForThisExecution = 0;
@ -5384,7 +5384,7 @@ void Act_SetUniqueId (char UniqueId[Act_MAX_BYTES_ID])
So, Id uses: So, Id uses:
- a name for this execution (Gbl.UniqueNameEncrypted) - a name for this execution (Gbl.UniqueNameEncrypted)
- a number for each element in this execution (CountForThisExecution) *****/ - a number for each element in this execution (CountForThisExecution) *****/
snprintf (UniqueId,Act_MAX_BYTES_ID, snprintf (UniqueId,Act_MAX_BYTES_ID + 1,
"id_%s_%u", "id_%s_%u",
Gbl.UniqueNameEncrypted, Gbl.UniqueNameEncrypted,
++CountForThisExecution); ++CountForThisExecution);

View File

@ -67,7 +67,7 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13
#define Act_MAX_BYTES_ID (32 + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 10 + 1) #define Act_MAX_BYTES_ID (32 + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 10)
#define Act_MAX_BYTES_PARAM_ACTION 256 #define Act_MAX_BYTES_PARAM_ACTION 256
#define Act_MAX_BYTES_PARAM_SESSION (256 + Cns_BYTES_SESSION_ID) #define Act_MAX_BYTES_PARAM_SESSION (256 + Cns_BYTES_SESSION_ID)
@ -1689,7 +1689,7 @@ void Act_LinkFormSubmitId (const char *Title,const char *LinkStyle,
void Act_LinkFormSubmitAnimated (const char *Title,const char *LinkStyle, void Act_LinkFormSubmitAnimated (const char *Title,const char *LinkStyle,
const char *OnSubmit); const char *OnSubmit);
void Act_SetUniqueId (char UniqueId[Act_MAX_BYTES_ID]); void Act_SetUniqueId (char UniqueId[Act_MAX_BYTES_ID + 1]);
void Act_AdjustActionWhenNoUsrLogged (void); void Act_AdjustActionWhenNoUsrLogged (void);
void Act_AdjustCurrentAction (void); void Act_AdjustCurrentAction (void);

View File

@ -116,7 +116,7 @@ void Ale_ShowAlertAndButton (Ale_AlertType_t AlertType,const char *Txt,
void Ale_ShowAlertAndButton1 (Ale_AlertType_t AlertType,const char *Txt) void Ale_ShowAlertAndButton1 (Ale_AlertType_t AlertType,const char *Txt)
{ {
extern const char *Txt_Close; extern const char *Txt_Close;
char IdAlert[Act_MAX_BYTES_ID]; char IdAlert[Act_MAX_BYTES_ID + 1];
static const bool AlertClosable[Ale_NUM_ALERT_TYPES] = static const bool AlertClosable[Ale_NUM_ALERT_TYPES] =
{ {
false, // Ale_NONE false, // Ale_NONE

View File

@ -114,7 +114,7 @@ static void Box_StartBoxInternal (const char *Width,const char *Title,
{ {
extern const char *Txt_Help; extern const char *Txt_Help;
extern const char *Txt_Close; extern const char *Txt_Close;
char IdFrame[Act_MAX_BYTES_ID]; char IdFrame[Act_MAX_BYTES_ID + 1];
/***** Start box container *****/ /***** Start box container *****/
fprintf (Gbl.F.Out,"<div class=\"FRAME_CONTAINER\""); fprintf (Gbl.F.Out,"<div class=\"FRAME_CONTAINER\"");

View File

@ -355,14 +355,15 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 18.6.4 (2018-10-17)" #define Log_PLATFORM_VERSION "SWAD 18.6.6 (2018-10-17)"
#define CSS_FILE "swad18.4.css" #define CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js" #define JS_FILE "swad17.17.1.js"
/* /*
* *
* Código QR no sale en la ficha cuando no estoy en una asignatura!!!!! * Código QR no sale en la ficha cuando no estoy en una asignatura!!!!!
Version 18.6.5: Oct 17, 2018 Some sprintf changed by snprintf. (236125 lines) Version 18.6.6: Oct 17, 2018 Some sprintf changed by snprintf. (236560 lines)
Version 18.6.4: Oct 17, 2018 Some sprintf changed by snprintf. (236034 lines) Version 18.6.5: Oct 17, 2018 Some sprintf changed by snprintf or asprintf. (236125 lines)
Version 18.6.4: Oct 17, 2018 Some sprintf changed by snprintf or asprintf. (236034 lines)
Version 18.6.3: Oct 17, 2018 Some sprintf changed by snprintf or asprintf. (235954 lines) Version 18.6.3: Oct 17, 2018 Some sprintf changed by snprintf or asprintf. (235954 lines)
Version 18.6.2: Oct 17, 2018 Some sprintf changed by snprintf. (235808 lines) Version 18.6.2: Oct 17, 2018 Some sprintf changed by snprintf. (235808 lines)
Version 18.6.1: Oct 16, 2018 Some sprintf changed by snprintf. (235755 lines) Version 18.6.1: Oct 16, 2018 Some sprintf changed by snprintf. (235755 lines)

View File

@ -395,21 +395,21 @@ void Dat_ConvDateToDateStr (struct Date *Date,char StrDate[Cns_MAX_BYTES_DATE +
switch (Gbl.Prefs.DateFormat) switch (Gbl.Prefs.DateFormat)
{ {
case Dat_FORMAT_YYYY_MM_DD: case Dat_FORMAT_YYYY_MM_DD:
snprintf (StrDate,Cns_MAX_BYTES_DATE, snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,
"%04u-%02u-%02u", "%04u-%02u-%02u",
Date->Year, Date->Year,
Date->Month, Date->Month,
Date->Day); Date->Day);
break; break;
case Dat_FORMAT_DD_MONTH_YYYY: case Dat_FORMAT_DD_MONTH_YYYY:
snprintf (StrDate,Cns_MAX_BYTES_DATE, snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,
"%u&nbsp;%s&nbsp;%04u", "%u&nbsp;%s&nbsp;%04u",
Date->Day, Date->Day,
Txt_MONTHS_SMALL_SHORT[Date->Month - 1], Txt_MONTHS_SMALL_SHORT[Date->Month - 1],
Date->Year); Date->Year);
break; break;
case Dat_FORMAT_MONTH_DD_YYYY: case Dat_FORMAT_MONTH_DD_YYYY:
snprintf (StrDate,Cns_MAX_BYTES_DATE, snprintf (StrDate,Cns_MAX_BYTES_DATE + 1,
"%s&nbsp;%u,&nbsp;%04u", "%s&nbsp;%u,&nbsp;%04u",
Txt_MONTHS_SMALL_SHORT[Date->Month - 1], Txt_MONTHS_SMALL_SHORT[Date->Month - 1],
Date->Day, Date->Day,
@ -781,12 +781,12 @@ void Dat_GetBrowserTimeZone (char BrowserTimeZone[Dat_MAX_BYTES_TIME_ZONE + 1])
/* Convert from minutes to +-hh:mm */ /* Convert from minutes to +-hh:mm */
// BrowserTimeZone must have space for strings in +hh:mm format (6 chars + \0) // BrowserTimeZone must have space for strings in +hh:mm format (6 chars + \0)
if (ClientUTCMinusLocal > 0) if (ClientUTCMinusLocal > 0)
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE, snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,
"-%02u:%02u", "-%02u:%02u",
(unsigned) ClientUTCMinusLocal / 60, (unsigned) ClientUTCMinusLocal / 60,
(unsigned) ClientUTCMinusLocal % 60); (unsigned) ClientUTCMinusLocal % 60);
else // ClientUTCMinusLocal <= 0 else // ClientUTCMinusLocal <= 0
snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE, snprintf (BrowserTimeZone,Dat_MAX_BYTES_TIME_ZONE + 1,
"+%02u:%02u", "+%02u:%02u",
(unsigned) (-ClientUTCMinusLocal) / 60, (unsigned) (-ClientUTCMinusLocal) / 60,
(unsigned) (-ClientUTCMinusLocal) % 60); (unsigned) (-ClientUTCMinusLocal) % 60);

View File

@ -41,6 +41,8 @@
#define Dat_MAX_BYTES_TIME_ZONE 256 #define Dat_MAX_BYTES_TIME_ZONE 256
#define Dat_MAX_BYTES_TIME (128 - 1)
/*****************************************************************************/ /*****************************************************************************/
/******************************* Public types ********************************/ /******************************* Public types ********************************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -75,15 +75,18 @@ void Fil_CreateFileForHTMLOutput (void)
char PathHTMLOutputPriv[PATH_MAX + 1]; char PathHTMLOutputPriv[PATH_MAX + 1];
/***** Check if exists the directory for HTML output. If not exists, create it *****/ /***** Check if exists the directory for HTML output. If not exists, create it *****/
sprintf (PathHTMLOutputPriv,"%s/%s",Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT); snprintf (PathHTMLOutputPriv,sizeof (PathHTMLOutputPriv),
"%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT);
Fil_CreateDirIfNotExists (PathHTMLOutputPriv); Fil_CreateDirIfNotExists (PathHTMLOutputPriv);
/***** Remove old files *****/ /***** Remove old files *****/
Fil_RemoveOldTmpFiles (PathHTMLOutputPriv,Cfg_TIME_TO_DELETE_HTML_OUTPUT,false); Fil_RemoveOldTmpFiles (PathHTMLOutputPriv,Cfg_TIME_TO_DELETE_HTML_OUTPUT,false);
/***** Create a unique name for the file *****/ /***** Create a unique name for the file *****/
sprintf (Gbl.HTMLOutput.FileName,"%s/%s.html", snprintf (Gbl.HTMLOutput.FileName,sizeof (Gbl.HTMLOutput.FileName),
PathHTMLOutputPriv,Gbl.UniqueNameEncrypted); "%s/%s.html",
PathHTMLOutputPriv,Gbl.UniqueNameEncrypted);
/***** Open file for writing and reading *****/ /***** Open file for writing and reading *****/
if ((Gbl.F.Out = fopen (Gbl.HTMLOutput.FileName,"w+t")) == NULL) if ((Gbl.F.Out = fopen (Gbl.HTMLOutput.FileName,"w+t")) == NULL)
@ -331,7 +334,9 @@ void Fil_CreateUpdateFile (const char CurrentName[PATH_MAX + 1],
Str_Copy (NewName,CurrentName, Str_Copy (NewName,CurrentName,
PATH_MAX); PATH_MAX);
NewName[LengthFileRoot] = '\0'; NewName[LengthFileRoot] = '\0';
sprintf (OldName,"%s%s",NewName,ExtensionOldName); snprintf (OldName,PATH_MAX + 1,
"%s%s",
NewName,ExtensionOldName);
Str_Concat (NewName,".new", Str_Concat (NewName,".new",
PATH_MAX); PATH_MAX);
@ -477,7 +482,9 @@ void Fil_RemoveTree (const char *Path)
if (strcmp (FileList[NumFile]->d_name,".") && if (strcmp (FileList[NumFile]->d_name,".") &&
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".." strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
{ {
sprintf (PathFileRel,"%s/%s",Path,FileList[NumFile]->d_name); snprintf (PathFileRel,sizeof (PathFileRel),
"%s/%s",
Path,FileList[NumFile]->d_name);
Fil_RemoveTree (PathFileRel); Fil_RemoveTree (PathFileRel);
} }
free ((void *) FileList[NumFile]); free ((void *) FileList[NumFile]);
@ -535,7 +542,9 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDire
if (strcmp (FileList[NumFile]->d_name,".") && if (strcmp (FileList[NumFile]->d_name,".") &&
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".." strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
{ {
sprintf (Path2,"%s/%s",Path,FileList[NumFile]->d_name); snprintf (Path2,sizeof (Path2),
"%s/%s",
Path,FileList[NumFile]->d_name);
Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call
} }
free ((void *) FileList[NumFile]); free ((void *) FileList[NumFile]);
@ -632,28 +641,48 @@ void Fil_WriteFileSizeBrief (double SizeInBytes,
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1]) char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1])
{ {
if (SizeInBytes < Ki) if (SizeInBytes < Ki)
sprintf (FileSizeStr,"%.0f&nbsp;B" ,SizeInBytes); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;B",
SizeInBytes);
else if (SizeInBytes < Mi) else if (SizeInBytes < Mi)
sprintf (FileSizeStr,"%.0f&nbsp;KiB",SizeInBytes / Ki); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;KiB",
SizeInBytes / Ki);
else if (SizeInBytes < Gi) else if (SizeInBytes < Gi)
sprintf (FileSizeStr,"%.0f&nbsp;MiB",SizeInBytes / Mi); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;MiB",
SizeInBytes / Mi);
else if (SizeInBytes < Ti) else if (SizeInBytes < Ti)
sprintf (FileSizeStr,"%.0f&nbsp;GiB",SizeInBytes / Gi); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;GiB",
SizeInBytes / Gi);
else else
sprintf (FileSizeStr,"%.0f&nbsp;TiB",SizeInBytes / Ti); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;TiB",
SizeInBytes / Ti);
} }
void Fil_WriteFileSizeFull (double SizeInBytes, void Fil_WriteFileSizeFull (double SizeInBytes,
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1]) char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1])
{ {
if (SizeInBytes < Ki) if (SizeInBytes < Ki)
sprintf (FileSizeStr,"%.0f&nbsp;B" ,SizeInBytes); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.0f&nbsp;B",
SizeInBytes);
else if (SizeInBytes < Mi) else if (SizeInBytes < Mi)
sprintf (FileSizeStr,"%.1f&nbsp;KiB",SizeInBytes / Ki); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.1f&nbsp;KiB",
SizeInBytes / Ki);
else if (SizeInBytes < Gi) else if (SizeInBytes < Gi)
sprintf (FileSizeStr,"%.1f&nbsp;MiB",SizeInBytes / Mi); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.1f&nbsp;MiB",
SizeInBytes / Mi);
else if (SizeInBytes < Ti) else if (SizeInBytes < Ti)
sprintf (FileSizeStr,"%.1f&nbsp;GiB",SizeInBytes / Gi); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.1f&nbsp;GiB",
SizeInBytes / Gi);
else else
sprintf (FileSizeStr,"%.1f&nbsp;TiB",SizeInBytes / Ti); snprintf (FileSizeStr,Fil_MAX_BYTES_FILE_SIZE_STRING + 1,
"%.1f&nbsp;TiB",
SizeInBytes / Ti);
} }

View File

@ -1009,7 +1009,9 @@ static void For_ShowPostsOfAThread (Ale_AlertType_t AlertType,const char *Messag
Ale_ShowAlert (AlertType,Message); Ale_ShowAlert (AlertType,Message);
/***** Start box *****/ /***** Start box *****/
sprintf (FrameTitle,"%s: %s",Txt_Thread,Thr.Subject); snprintf (FrameTitle,sizeof (FrameTitle),
"%s: %s",
Txt_Thread,Thr.Subject);
Box_StartBox (NULL,FrameTitle,For_PutIconNewPost, Box_StartBox (NULL,FrameTitle,For_PutIconNewPost,
Hlp_SOCIAL_Forums_posts,Box_NOT_CLOSABLE); Hlp_SOCIAL_Forums_posts,Box_NOT_CLOSABLE);
@ -1267,9 +1269,10 @@ static void For_ShowAForumPost (unsigned PstNum,long PstCod,
Gbl.Forum.ForumSelected.ThrCod, Gbl.Forum.ForumSelected.ThrCod,
PstCod); PstCod);
sprintf (Gbl.Title,Enabled ? Txt_Post_X_allowed_Click_to_ban_it : snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Post_X_banned_Click_to_unban_it, Enabled ? Txt_Post_X_allowed_Click_to_ban_it :
PstNum); Txt_Post_X_banned_Click_to_unban_it,
PstNum);
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s-on64x64.png\"" fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s-on64x64.png\""
" alt=\"%s\" title=\"%s\"" " alt=\"%s\" title=\"%s\""
" class=\"ICO20x20\" />", " class=\"ICO20x20\" />",
@ -1282,9 +1285,10 @@ static void For_ShowAForumPost (unsigned PstNum,long PstCod,
} }
else else
{ {
sprintf (Gbl.Title,Enabled ? Txt_Post_X_allowed : snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Post_X_banned, Enabled ? Txt_Post_X_allowed :
PstNum); Txt_Post_X_banned,
PstNum);
fprintf (Gbl.F.Out,"<span title=\"%s\">" fprintf (Gbl.F.Out,"<span title=\"%s\">"
"<img src=\"%s/%s-off64x64.png\"" "<img src=\"%s/%s-off64x64.png\""
" alt=\"%s\" title=\"%s\"" " alt=\"%s\" title=\"%s\""
@ -2221,20 +2225,22 @@ void For_SetForumName (struct Forum *Forum,
For_MAX_BYTES_FORUM_NAME); For_MAX_BYTES_FORUM_NAME);
break; break;
case For_FORUM_GLOBAL_TCHS: case For_FORUM_GLOBAL_TCHS:
sprintf (ForumName,"%s%s", snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
UseHTMLEntities ? Txt_General : "%s%s",
Txt_General_NO_HTML[Language], UseHTMLEntities ? Txt_General :
UseHTMLEntities ? Txt_only_teachers : Txt_General_NO_HTML[Language],
Txt_only_teachers_NO_HTML[Language]); UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM__SWAD__USRS: case For_FORUM__SWAD__USRS:
Str_Copy (ForumName,Cfg_PLATFORM_SHORT_NAME, Str_Copy (ForumName,Cfg_PLATFORM_SHORT_NAME,
For_MAX_BYTES_FORUM_NAME); For_MAX_BYTES_FORUM_NAME);
break; break;
case For_FORUM__SWAD__TCHS: case For_FORUM__SWAD__TCHS:
sprintf (ForumName,"%s%s",Cfg_PLATFORM_SHORT_NAME, snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
UseHTMLEntities ? Txt_only_teachers : "%s%s",Cfg_PLATFORM_SHORT_NAME,
Txt_only_teachers_NO_HTML[Language]); UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_INSTIT_USRS: case For_FORUM_INSTIT_USRS:
Ins.InsCod = Forum->Location; Ins.InsCod = Forum->Location;
@ -2247,9 +2253,10 @@ void For_SetForumName (struct Forum *Forum,
Ins.InsCod = Forum->Location; Ins.InsCod = Forum->Location;
if (!Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA)) if (!Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA))
Lay_ShowErrorAndExit ("Institution not found."); Lay_ShowErrorAndExit ("Institution not found.");
sprintf (ForumName,"%s%s",Ins.ShrtName, snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
UseHTMLEntities ? Txt_only_teachers : "%s%s",Ins.ShrtName,
Txt_only_teachers_NO_HTML[Language]); UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_CENTRE_USRS: case For_FORUM_CENTRE_USRS:
Ctr.CtrCod = Forum->Location; Ctr.CtrCod = Forum->Location;
@ -2262,9 +2269,10 @@ void For_SetForumName (struct Forum *Forum,
Ctr.CtrCod = Forum->Location; Ctr.CtrCod = Forum->Location;
if (!Ctr_GetDataOfCentreByCod (&Ctr)) if (!Ctr_GetDataOfCentreByCod (&Ctr))
Lay_ShowErrorAndExit ("Centre not found."); Lay_ShowErrorAndExit ("Centre not found.");
sprintf (ForumName,"%s%s",Ctr.ShrtName, snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
UseHTMLEntities ? Txt_only_teachers : "%s%s",Ctr.ShrtName,
Txt_only_teachers_NO_HTML[Language]); UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_DEGREE_USRS: case For_FORUM_DEGREE_USRS:
Deg.DegCod = Forum->Location; Deg.DegCod = Forum->Location;
@ -2277,9 +2285,10 @@ void For_SetForumName (struct Forum *Forum,
Deg.DegCod = Forum->Location; Deg.DegCod = Forum->Location;
if (!Deg_GetDataOfDegreeByCod (&Deg)) if (!Deg_GetDataOfDegreeByCod (&Deg))
Lay_ShowErrorAndExit ("Degree not found."); Lay_ShowErrorAndExit ("Degree not found.");
sprintf (ForumName,"%s%s",Deg.ShrtName, snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
UseHTMLEntities ? Txt_only_teachers : "%s%s",Deg.ShrtName,
Txt_only_teachers_NO_HTML[Language]); UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_COURSE_USRS: case For_FORUM_COURSE_USRS:
Crs.CrsCod = Forum->Location; Crs.CrsCod = Forum->Location;
@ -2292,9 +2301,10 @@ void For_SetForumName (struct Forum *Forum,
Crs.CrsCod = Forum->Location; Crs.CrsCod = Forum->Location;
if (!Crs_GetDataOfCourseByCod (&Crs)) if (!Crs_GetDataOfCourseByCod (&Crs))
Lay_ShowErrorAndExit ("Course not found."); Lay_ShowErrorAndExit ("Course not found.");
sprintf (ForumName,"%s%s",Crs.ShrtName, snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,
UseHTMLEntities ? Txt_only_teachers : "%s%s",Crs.ShrtName,
Txt_only_teachers_NO_HTML[Language]); UseHTMLEntities ? Txt_only_teachers :
Txt_only_teachers_NO_HTML[Language]);
break; break;
default: default:
Str_Copy (ForumName,Txt_Unknown_FORUM, Str_Copy (ForumName,Txt_Unknown_FORUM,
@ -2575,7 +2585,9 @@ static void For_ShowForumThreadsHighlightingOneThread (long ThrCodHighlighted,
Ale_ShowAlert (AlertType,Message); Ale_ShowAlert (AlertType,Message);
/***** Start box for threads of this forum *****/ /***** Start box for threads of this forum *****/
sprintf (FrameTitle,"%s: %s",Txt_Forum,ForumName); snprintf (FrameTitle,sizeof (FrameTitle),
"%s: %s",
Txt_Forum,ForumName);
Box_StartBox (NULL,FrameTitle,For_PutIconNewThread, Box_StartBox (NULL,FrameTitle,For_PutIconNewThread,
Hlp_SOCIAL_Forums_threads,Box_NOT_CLOSABLE); Hlp_SOCIAL_Forums_threads,Box_NOT_CLOSABLE);
@ -3548,7 +3560,9 @@ static void For_GetThrData (struct ForumThread *Thr)
Str_Copy (Thr->Subject,row[6], Str_Copy (Thr->Subject,row[6],
Cns_MAX_BYTES_SUBJECT); Cns_MAX_BYTES_SUBJECT);
if (!Thr->Subject[0]) if (!Thr->Subject[0])
sprintf (Thr->Subject,"[%s]",Txt_no_subject); snprintf (Thr->Subject,sizeof (Thr->Subject),
"[%s]",
Txt_no_subject);
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);

View File

@ -2889,7 +2889,9 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Game *Game,
{ {
Gbl.RowEvenOdd = NumQst % 2; Gbl.RowEvenOdd = NumQst % 2;
sprintf (StrNumQst,"%u",NumQst + 1); snprintf (StrNumQst,sizeof (StrNumQst),
"%u",
NumQst + 1);
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* /*
@ -2924,7 +2926,9 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Game *Game,
/* Put icon to move up the question */ /* Put icon to move up the question */
if (NumQst) if (NumQst)
{ {
sprintf (Gbl.Title,Txt_Move_up_X,StrNumQst); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Move_up_X,
StrNumQst);
Lay_PutContextualLink (ActUp_GamQst,NULL,Gam_PutParamsOneQst, Lay_PutContextualLink (ActUp_GamQst,NULL,Gam_PutParamsOneQst,
"up_on16x16.gif", "up_on16x16.gif",
Gbl.Title,NULL, Gbl.Title,NULL,
@ -2936,7 +2940,9 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Game *Game,
/* Put icon to move down the question */ /* Put icon to move down the question */
if (NumQst + 1 < NumQsts) if (NumQst + 1 < NumQsts)
{ {
sprintf (Gbl.Title,Txt_Move_down_X,StrNumQst); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Move_down_X,
StrNumQst);
Lay_PutContextualLink (ActDwnGamQst,NULL,Gam_PutParamsOneQst, Lay_PutContextualLink (ActDwnGamQst,NULL,Gam_PutParamsOneQst,
"down_on16x16.gif", "down_on16x16.gif",
Gbl.Title,NULL, Gbl.Title,NULL,
@ -3204,13 +3210,15 @@ static void Gam_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
/***** String with the number of users *****/ /***** String with the number of users *****/
if (MaxUsrs) if (MaxUsrs)
sprintf (Gbl.Title,"%u&nbsp;(%u%%&nbsp;%s&nbsp;%u)", snprintf (Gbl.Title,sizeof (Gbl.Title),
NumUsrs, "%u&nbsp;(%u%%&nbsp;%s&nbsp;%u)",
(unsigned) ((((float) NumUsrs * 100.0) / (float) MaxUsrs) + 0.5), NumUsrs,
Txt_of_PART_OF_A_TOTAL,MaxUsrs); (unsigned) ((((float) NumUsrs * 100.0) / (float) MaxUsrs) + 0.5),
Txt_of_PART_OF_A_TOTAL,MaxUsrs);
else else
sprintf (Gbl.Title,"0&nbsp;(0%%&nbsp;%s&nbsp;%u)", snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_of_PART_OF_A_TOTAL,MaxUsrs); "0&nbsp;(0%%&nbsp;%s&nbsp;%u)",
Txt_of_PART_OF_A_TOTAL,MaxUsrs);
/***** Draw bar with a with proportional to the number of clicks *****/ /***** Draw bar with a with proportional to the number of clicks *****/
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_TOP\" style=\"width:%upx;\">", fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_TOP\" style=\"width:%upx;\">",
@ -3770,7 +3778,9 @@ static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod)
Lay_ShowErrorAndExit ("Error: wrong question code."); Lay_ShowErrorAndExit ("Error: wrong question code.");
/* Get possible parameter with the user's answer */ /* Get possible parameter with the user's answer */
sprintf (ParamName,"Ans%010u",(unsigned) QstCod); snprintf (ParamName,sizeof (ParamName),
"Ans%010u",
(unsigned) QstCod);
// Lay_ShowAlert (Lay_INFO,ParamName); // Lay_ShowAlert (Lay_INFO,ParamName);
Par_GetParMultiToText (ParamName,StrAnswersIndexes, Par_GetParMultiToText (ParamName,StrAnswersIndexes,
Gam_MAX_ANSWERS_PER_QUESTION * (10 + 1)); Gam_MAX_ANSWERS_PER_QUESTION * (10 + 1));

View File

@ -135,16 +135,19 @@ void Gbl_InitializeGlobals (void)
Gbl.Prefs.Menu = Mnu_MENU_DEFAULT; // Default menu Gbl.Prefs.Menu = Mnu_MENU_DEFAULT; // Default menu
Gbl.Prefs.Theme = The_THEME_DEFAULT; // Default theme Gbl.Prefs.Theme = The_THEME_DEFAULT; // Default theme
Gbl.Prefs.IconSet = Ico_ICON_SET_DEFAULT; // Default icon set Gbl.Prefs.IconSet = Ico_ICON_SET_DEFAULT; // Default icon set
sprintf (Gbl.Prefs.IconsURL,"%s/%s", snprintf (Gbl.Prefs.IconsURL,sizeof (Gbl.Prefs.IconsURL),
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON); "%s/%s",
sprintf (Gbl.Prefs.PathTheme,"%s/%s/%s/%s", Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON);
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON, snprintf (Gbl.Prefs.PathTheme,sizeof (Gbl.Prefs.PathTheme),
Cfg_ICON_FOLDER_THEMES, "%s/%s/%s/%s",
The_ThemeId[Gbl.Prefs.Theme]); Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON,
sprintf (Gbl.Prefs.PathIconSet,"%s/%s/%s/%s", Cfg_ICON_FOLDER_THEMES,
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON, The_ThemeId[Gbl.Prefs.Theme]);
Cfg_ICON_FOLDER_ICON_SETS, snprintf (Gbl.Prefs.PathIconSet,sizeof (Gbl.Prefs.PathIconSet),
Ico_IconSetId[Gbl.Prefs.IconSet]); "%s/%s/%s/%s",
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON,
Cfg_ICON_FOLDER_ICON_SETS,
Ico_IconSetId[Gbl.Prefs.IconSet]);
Gbl.Session.NumSessions = 0; Gbl.Session.NumSessions = 0;
Gbl.Session.IsOpen = false; Gbl.Session.IsOpen = false;

View File

@ -1378,7 +1378,9 @@ static void Grp_ListGroupTypesForEdition (void)
Txt_The_groups_will_not_automatically_open, Txt_The_groups_will_not_automatically_open,
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MustBeOpened ? Txt_The_groups_will_automatically_open : Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MustBeOpened ? Txt_The_groups_will_automatically_open :
Txt_The_groups_will_not_automatically_open); Txt_The_groups_will_not_automatically_open);
sprintf (Id,"open_time_%u",UniqueId); snprintf (Id,sizeof (Id),
"open_time_%u",
UniqueId);
Dat_WriteFormClientLocalDateTimeFromTimeUTC (Id, Dat_WriteFormClientLocalDateTimeFromTimeUTC (Id,
"Open", "Open",
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].OpenTimeUTC, Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].OpenTimeUTC,
@ -1521,10 +1523,10 @@ static void Grp_ListGroupsForEdition (void)
ActOpeGrp, ActOpeGrp,
Grp_GROUPS_SECTION_ID); Grp_GROUPS_SECTION_ID);
Grp_PutParamGrpCod (Grp->GrpCod); Grp_PutParamGrpCod (Grp->GrpCod);
sprintf (Gbl.Title, snprintf (Gbl.Title,sizeof (Gbl.Title),
Grp->Open ? Txt_Group_X_open_click_to_close_it : Grp->Open ? Txt_Group_X_open_click_to_close_it :
Txt_Group_X_closed_click_to_open_it, Txt_Group_X_closed_click_to_open_it,
Grp->GrpName); Grp->GrpName);
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s-on64x64.png\"" fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s-on64x64.png\""
" alt=\"%s\" title=\"%s\"" " alt=\"%s\" title=\"%s\""
" class=\"ICO20x20\" />", " class=\"ICO20x20\" />",
@ -1542,10 +1544,10 @@ static void Grp_ListGroupsForEdition (void)
ActEnaFilZonGrp, ActEnaFilZonGrp,
Grp_GROUPS_SECTION_ID); Grp_GROUPS_SECTION_ID);
Grp_PutParamGrpCod (Grp->GrpCod); Grp_PutParamGrpCod (Grp->GrpCod);
sprintf (Gbl.Title, snprintf (Gbl.Title,sizeof (Gbl.Title),
Grp->FileZones ? Txt_File_zones_of_the_group_X_enabled_click_to_disable_them : Grp->FileZones ? Txt_File_zones_of_the_group_X_enabled_click_to_disable_them :
Txt_File_zones_of_the_group_X_disabled_click_to_enable_them, Txt_File_zones_of_the_group_X_disabled_click_to_enable_them,
Grp->GrpName); Grp->GrpName);
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s16x16.gif\"" fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/%s16x16.gif\""
" alt=\"%s\" title=\"%s\"" " alt=\"%s\" title=\"%s\""
" class=\"ICO20x20\" />", " class=\"ICO20x20\" />",
@ -2380,9 +2382,10 @@ static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight)
Rol_Role_t Role; Rol_Role_t Role;
/***** Write icon to show if group is open or closed *****/ /***** Write icon to show if group is open or closed *****/
sprintf (Gbl.Title,Grp->Open ? Txt_Group_X_open : snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Group_X_closed, Grp->Open ? Txt_Group_X_open :
Grp->GrpName); Txt_Group_X_closed,
Grp->GrpName);
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE"); fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE");
if (Highlight) if (Highlight)
fprintf (Gbl.F.Out," LIGHT_BLUE"); fprintf (Gbl.F.Out," LIGHT_BLUE");
@ -4786,8 +4789,9 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
Lay_ShowErrorAndExit ("Not enough memory to store codes of groups in which a user wants to be enroled."); Lay_ShowErrorAndExit ("Not enough memory to store codes of groups in which a user wants to be enroled.");
/***** Get the multiple parameter code of group of this type *****/ /***** Get the multiple parameter code of group of this type *****/
sprintf (Param,"GrpCod%ld", snprintf (Param,sizeof (Param),
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); "GrpCod%ld",
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod);
Par_GetParMultiToText (Param,LstStrCodGrps[NumGrpTyp], Par_GetParMultiToText (Param,LstStrCodGrps[NumGrpTyp],
((1 + 10 + 1) * Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) - 1); ((1 + 10 + 1) * Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) - 1);
if (LstStrCodGrps[NumGrpTyp][0]) if (LstStrCodGrps[NumGrpTyp][0])

View File

@ -145,8 +145,9 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
if (ActionsRemoveMe[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role] != ActUnk) if (ActionsRemoveMe[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role] != ActUnk)
{ {
/* Request my removing from this course */ /* Request my removing from this course */
sprintf (Gbl.Title,Txt_Remove_me_from_THE_COURSE_X, snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.CurrentCrs.Crs.ShrtName); Txt_Remove_me_from_THE_COURSE_X,
Gbl.CurrentCrs.Crs.ShrtName);
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActionsRemoveMe[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role], ActionsRemoveMe[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role],
Btn_REMOVE_BUTTON,Txt_Remove_me); Btn_REMOVE_BUTTON,Txt_Remove_me);
@ -155,8 +156,9 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
else // I do not belong to this course else // I do not belong to this course
{ {
/* Request my registration in this course */ /* Request my registration in this course */
sprintf (Gbl.Title,Txt_Register_me_in_X, snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.CurrentCrs.Crs.ShrtName); Txt_Register_me_in_X,
Gbl.CurrentCrs.Crs.ShrtName);
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActReqSignUp, ActReqSignUp,
Btn_CREATE_BUTTON,Txt_Sign_up); Btn_CREATE_BUTTON,Txt_Sign_up);
@ -170,8 +172,9 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role == Rol_TCH) // I am a teacher in current course Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role == Rol_TCH) // I am a teacher in current course
{ {
/* Request students enrolment */ /* Request students enrolment */
sprintf (Gbl.Title,Txt_Register_students_in_COURSE_X, snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.CurrentCrs.Crs.ShrtName); Txt_Register_students_in_COURSE_X,
Gbl.CurrentCrs.Crs.ShrtName);
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActReqEnrSevStd, ActReqEnrSevStd,
Btn_CREATE_BUTTON,Txt_Register_students); Btn_CREATE_BUTTON,Txt_Register_students);
@ -187,9 +190,10 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
if (Gbl.CurrentDeg.Deg.DegCod > 0) // Degree selected if (Gbl.CurrentDeg.Deg.DegCod > 0) // Degree selected
{ {
/* Select a course */ /* Select a course */
sprintf (Gbl.Title,Gbl.CurrentCrs.Crs.CrsCod > 0 ? Txt_Select_create_course_in_X : snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Select_or_create_one_course_in_X, Gbl.CurrentCrs.Crs.CrsCod > 0 ? Txt_Select_create_course_in_X :
Gbl.CurrentDeg.Deg.ShrtName); Txt_Select_or_create_one_course_in_X,
Gbl.CurrentDeg.Deg.ShrtName);
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActSeeCrs, ActSeeCrs,
Btn_CONFIRM_BUTTON,Txt_Courses); Btn_CONFIRM_BUTTON,Txt_Courses);
@ -197,9 +201,10 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
else if (Gbl.CurrentCtr.Ctr.CtrCod > 0) // Centre selected else if (Gbl.CurrentCtr.Ctr.CtrCod > 0) // Centre selected
{ {
/* Select a degree */ /* Select a degree */
sprintf (Gbl.Title,Gbl.CurrentDeg.Deg.DegCod > 0 ? Txt_Select_or_create_another_degree_in_X : snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Select_or_create_one_degree_in_X, Gbl.CurrentDeg.Deg.DegCod > 0 ? Txt_Select_or_create_another_degree_in_X :
Gbl.CurrentCtr.Ctr.ShrtName); Txt_Select_or_create_one_degree_in_X,
Gbl.CurrentCtr.Ctr.ShrtName);
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActSeeDeg, ActSeeDeg,
Btn_CONFIRM_BUTTON,Txt_Degrees); Btn_CONFIRM_BUTTON,Txt_Degrees);
@ -207,9 +212,10 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
else if (Gbl.CurrentIns.Ins.InsCod > 0) // Institution selected else if (Gbl.CurrentIns.Ins.InsCod > 0) // Institution selected
{ {
/* Select a centre */ /* Select a centre */
sprintf (Gbl.Title,Gbl.CurrentCtr.Ctr.CtrCod > 0 ? Txt_Select_or_create_another_centre_in_X : snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Select_or_create_one_centre_in_X, Gbl.CurrentCtr.Ctr.CtrCod > 0 ? Txt_Select_or_create_another_centre_in_X :
Gbl.CurrentIns.Ins.ShrtName); Txt_Select_or_create_one_centre_in_X,
Gbl.CurrentIns.Ins.ShrtName);
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActSeeCtr, ActSeeCtr,
Btn_CONFIRM_BUTTON,Txt_Centres); Btn_CONFIRM_BUTTON,Txt_Centres);
@ -217,9 +223,10 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
else if (Gbl.CurrentCty.Cty.CtyCod > 0) // Country selected else if (Gbl.CurrentCty.Cty.CtyCod > 0) // Country selected
{ {
/* Select an institution */ /* Select an institution */
sprintf (Gbl.Title,Gbl.CurrentIns.Ins.InsCod > 0 ? Txt_Select_or_create_another_institution_in_X : snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Select_or_create_one_institution_in_X, Gbl.CurrentIns.Ins.InsCod > 0 ? Txt_Select_or_create_another_institution_in_X :
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]); Txt_Select_or_create_one_institution_in_X,
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActSeeIns, ActSeeIns,
Btn_CONFIRM_BUTTON,Txt_Institutions); Btn_CONFIRM_BUTTON,Txt_Institutions);
@ -244,8 +251,9 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
Btn_CONFIRM_BUTTON,Txt_Log_in); Btn_CONFIRM_BUTTON,Txt_Log_in);
/* Sign up */ /* Sign up */
sprintf (Gbl.Title,Txt_New_on_PLATFORM_Sign_up, snprintf (Gbl.Title,sizeof (Gbl.Title),
Cfg_PLATFORM_SHORT_NAME); Txt_New_on_PLATFORM_Sign_up,
Cfg_PLATFORM_SHORT_NAME);
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActFrmMyAcc, ActFrmMyAcc,
Btn_CREATE_BUTTON,Txt_Create_account); Btn_CREATE_BUTTON,Txt_Create_account);

View File

@ -543,12 +543,15 @@ void Hie_InitHierarchy (void)
if (Gbl.CurrentCrs.Crs.CrsCod > 0) if (Gbl.CurrentCrs.Crs.CrsCod > 0)
{ {
/***** Paths of course directories *****/ /***** Paths of course directories *****/
sprintf (Gbl.CurrentCrs.PathPriv,"%s/%s/%ld", snprintf (Gbl.CurrentCrs.PathPriv,sizeof (Gbl.CurrentCrs.PathPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod); "%s/%s/%ld",
sprintf (Gbl.CurrentCrs.PathRelPubl,"%s/%s/%ld", Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod);
Cfg_PATH_SWAD_PUBLIC ,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod); snprintf (Gbl.CurrentCrs.PathRelPubl,sizeof (Gbl.CurrentCrs.PathRelPubl),
sprintf (Gbl.CurrentCrs.PathURLPubl,"%s/%s/%ld", "%s/%s/%ld",
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod); Cfg_PATH_SWAD_PUBLIC ,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod);
snprintf (Gbl.CurrentCrs.PathURLPubl,sizeof (Gbl.CurrentCrs.PathURLPubl),
"%s/%s/%ld",
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod);
/***** If any of the course directories does not exist, create it *****/ /***** If any of the course directories does not exist, create it *****/
if (!Fil_CheckIfPathExists (Gbl.CurrentCrs.PathPriv)) if (!Fil_CheckIfPathExists (Gbl.CurrentCrs.PathPriv))

View File

@ -125,10 +125,11 @@ void Ico_ChangeIconSet (void)
/***** Get param with icon set *****/ /***** Get param with icon set *****/
Gbl.Prefs.IconSet = Ico_GetParamIconSet (); Gbl.Prefs.IconSet = Ico_GetParamIconSet ();
sprintf (Gbl.Prefs.PathIconSet,"%s/%s/%s/%s", snprintf (Gbl.Prefs.PathIconSet,sizeof (Gbl.Prefs.PathIconSet),
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON, "%s/%s/%s/%s",
Cfg_ICON_FOLDER_ICON_SETS, Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PUBLIC_ICON,
Ico_IconSetId[Gbl.Prefs.IconSet]); Cfg_ICON_FOLDER_ICON_SETS,
Ico_IconSetId[Gbl.Prefs.IconSet]);
/***** Store icon set in database *****/ /***** Store icon set in database *****/
if (Gbl.Usrs.Me.Logged) if (Gbl.Usrs.Me.Logged)

View File

@ -197,7 +197,7 @@ void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTitURL)
extern const char *Txt_Image_title_attribution; extern const char *Txt_Image_title_attribution;
extern const char *Txt_Link; extern const char *Txt_Link;
struct ParamUploadImg ParamUploadImg; struct ParamUploadImg ParamUploadImg;
char Id[Act_MAX_BYTES_ID]; char Id[Act_MAX_BYTES_ID + 1];
/***** Set names of parameters depending on number of image in form *****/ /***** Set names of parameters depending on number of image in form *****/
Img_SetParamNames (&ParamUploadImg,NumImgInForm); Img_SetParamNames (&ParamUploadImg,NumImgInForm);
@ -361,10 +361,18 @@ void Img_SetParamNames (struct ParamUploadImg *ParamUploadImg,int NumImgInForm)
} }
else // Several images in form ==> add suffix else // Several images in form ==> add suffix
{ {
sprintf (ParamUploadImg->Action,"ImgAct%u",NumImgInForm); snprintf (ParamUploadImg->Action,sizeof (ParamUploadImg->Action),
sprintf (ParamUploadImg->File ,"ImgFil%u",NumImgInForm); "ImgAct%u",
sprintf (ParamUploadImg->Title ,"ImgTit%u",NumImgInForm); NumImgInForm);
sprintf (ParamUploadImg->URL ,"ImgURL%u",NumImgInForm); snprintf (ParamUploadImg->File ,sizeof (ParamUploadImg->File),
"ImgFil%u",
NumImgInForm);
snprintf (ParamUploadImg->Title ,sizeof (ParamUploadImg->Title),
"ImgTit%u",
NumImgInForm);
snprintf (ParamUploadImg->URL ,sizeof (ParamUploadImg->URL),
"ImgURL%u",
NumImgInForm);
} }
} }
@ -429,13 +437,15 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
/***** Create private directories if not exist *****/ /***** Create private directories if not exist *****/
/* Create private directory for images if it does not exist */ /* Create private directory for images if it does not exist */
sprintf (PathImgPriv,"%s/%s", snprintf (PathImgPriv,sizeof (PathImgPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG); "%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG);
Fil_CreateDirIfNotExists (PathImgPriv); Fil_CreateDirIfNotExists (PathImgPriv);
/* Create temporary private directory for images if it does not exist */ /* Create temporary private directory for images if it does not exist */
sprintf (PathImgPriv,"%s/%s/%s", snprintf (PathImgPriv,sizeof (PathImgPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP); "%s/%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP);
Fil_CreateDirIfNotExists (PathImgPriv); Fil_CreateDirIfNotExists (PathImgPriv);
/***** Remove old temporary private files *****/ /***** Remove old temporary private files *****/
@ -444,18 +454,20 @@ void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFi
/***** End the reception of original not processed image /***** End the reception of original not processed image
(it can be very big) into a temporary file *****/ (it can be very big) into a temporary file *****/
Image->Status = Img_FILE_NONE; Image->Status = Img_FILE_NONE;
sprintf (FileNameImgOrig,"%s/%s/%s/%s_original.%s", snprintf (FileNameImgOrig,sizeof (FileNameImgOrig),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP, "%s/%s/%s/%s_original.%s",
Image->Name,PtrExtension); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP,
Image->Name,PtrExtension);
if (Fil_EndReceptionOfFile (FileNameImgOrig,Param)) // Success if (Fil_EndReceptionOfFile (FileNameImgOrig,Param)) // Success
{ {
Image->Status = Img_FILE_RECEIVED; Image->Status = Img_FILE_RECEIVED;
/***** Convert original image to temporary JPEG processed file /***** Convert original image to temporary JPEG processed file
by calling to program that makes the conversion *****/ by calling to program that makes the conversion *****/
sprintf (FileNameImgTmp,"%s/%s/%s/%s.jpg", snprintf (FileNameImgTmp,sizeof (FileNameImgTmp),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP, "%s/%s/%s/%s.jpg",
Image->Name); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP,
Image->Name);
Img_ProcessImage (Image,FileNameImgOrig,FileNameImgTmp); Img_ProcessImage (Image,FileNameImgOrig,FileNameImgTmp);
Image->Status = Img_FILE_PROCESSED; Image->Status = Img_FILE_PROCESSED;
@ -475,12 +487,13 @@ static void Img_ProcessImage (struct Image *Image,
char Command[1024 + PATH_MAX * 2]; char Command[1024 + PATH_MAX * 2];
int ReturnCode; int ReturnCode;
sprintf (Command,"convert %s -resize '%ux%u>' -quality %u %s", snprintf (Command,sizeof (Command),
FileNameImgOriginal, "convert %s -resize '%ux%u>' -quality %u %s",
Image->Width, FileNameImgOriginal,
Image->Height, Image->Width,
Image->Quality, Image->Height,
FileNameImgProcessed); Image->Quality,
FileNameImgProcessed);
ReturnCode = system (Command); ReturnCode = system (Command);
if (ReturnCode == -1) if (ReturnCode == -1)
Lay_ShowErrorAndExit ("Error when running command to process image."); Lay_ShowErrorAndExit ("Error when running command to process image.");
@ -508,23 +521,26 @@ void Img_MoveImageToDefinitiveDirectory (struct Image *Image)
char FileNameImg[PATH_MAX + 1]; // Full name of definitive processed file char FileNameImg[PATH_MAX + 1]; // Full name of definitive processed file
/***** Create subdirectory if it does not exist *****/ /***** Create subdirectory if it does not exist *****/
sprintf (PathImgPriv,"%s/%s/%c%c", snprintf (PathImgPriv,sizeof (PathImgPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG, "%s/%s/%c%c",
Image->Name[0], Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,
Image->Name[1]); Image->Name[0],
Image->Name[1]);
Fil_CreateDirIfNotExists (PathImgPriv); Fil_CreateDirIfNotExists (PathImgPriv);
/***** Temporary processed file *****/ /***** Temporary processed file *****/
sprintf (FileNameImgTmp,"%s/%s/%s/%s.jpg", snprintf (FileNameImgTmp,sizeof (FileNameImgTmp),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP, "%s/%s/%s/%s.jpg",
Image->Name); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP,
Image->Name);
/***** Definitive processed file *****/ /***** Definitive processed file *****/
sprintf (FileNameImg,"%s/%s/%c%c/%s.jpg", snprintf (FileNameImg,sizeof (FileNameImg),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG, "%s/%s/%c%c/%s.jpg",
Image->Name[0], Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,
Image->Name[1], Image->Name[0],
Image->Name); Image->Name[1],
Image->Name);
/***** Move file *****/ /***** Move file *****/
if (rename (FileNameImgTmp,FileNameImg)) // Fail if (rename (FileNameImgTmp,FileNameImg)) // Fail
@ -558,12 +574,15 @@ void Img_ShowImage (struct Image *Image,
Brw_CreateDirDownloadTmp (); Brw_CreateDirDownloadTmp ();
/***** Build private path to image *****/ /***** Build private path to image *****/
sprintf (FileNameImgPriv,"%s.jpg",Image->Name); snprintf (FileNameImgPriv,sizeof (FileNameImgPriv),
sprintf (FullPathImgPriv,"%s/%s/%c%c/%s", "%s.jpg",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG, Image->Name);
Image->Name[0], snprintf (FullPathImgPriv,sizeof (FullPathImgPriv),
Image->Name[1], "%s/%s/%c%c/%s",
FileNameImgPriv); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,
Image->Name[0],
Image->Name[1],
FileNameImgPriv);
/***** Check if private image file exists *****/ /***** Check if private image file exists *****/
if (Fil_CheckIfPathExists (FullPathImgPriv)) if (Fil_CheckIfPathExists (FullPathImgPriv))
@ -573,10 +592,11 @@ void Img_ShowImage (struct Image *Image,
Brw_CreateTmpPublicLinkToPrivateFile (FullPathImgPriv,FileNameImgPriv); Brw_CreateTmpPublicLinkToPrivateFile (FullPathImgPriv,FileNameImgPriv);
/***** Create URL pointing to symbolic link *****/ /***** Create URL pointing to symbolic link *****/
sprintf (URL,"%s/%s/%s/%s", snprintf (URL,sizeof (URL),
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_FILE_BROWSER_TMP, "%s/%s/%s/%s",
Gbl.FileBrowser.TmpPubDir, Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_FILE_BROWSER_TMP,
FileNameImgPriv); Gbl.FileBrowser.TmpPubDir,
FileNameImgPriv);
/***** Show image *****/ /***** Show image *****/
/* Check if optional link is present */ /* Check if optional link is present */
@ -621,11 +641,12 @@ void Img_RemoveImageFile (const char *ImageName)
if (ImageName[0]) if (ImageName[0])
{ {
/***** Build path to private file *****/ /***** Build path to private file *****/
sprintf (FullPathImgPriv,"%s/%s/%c%c/%s.jpg", snprintf (FullPathImgPriv,sizeof (FullPathImgPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG, "%s/%s/%c%c/%s.jpg",
ImageName[0], Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,
ImageName[1], ImageName[0],
ImageName); ImageName[1],
ImageName);
/***** Remove private file *****/ /***** Remove private file *****/
unlink (FullPathImgPriv); unlink (FullPathImgPriv);

View File

@ -310,11 +310,12 @@ static void Inf_SetIHaveReadIntoDB (bool IHaveRead);
static bool Inf_CheckPage (long CrsCod,Inf_InfoType_t InfoType); static bool Inf_CheckPage (long CrsCod,Inf_InfoType_t InfoType);
static bool Inf_CheckAndShowPage (void); static bool Inf_CheckAndShowPage (void);
static void Inf_BuildPathPage (long CrsCod,Inf_InfoType_t InfoType,char *PathDir); static void Inf_BuildPathPage (long CrsCod,Inf_InfoType_t InfoType,char PathDir[PATH_MAX + 1]);
static bool Inf_CheckURL (long CrsCod,Inf_InfoType_t InfoType); static bool Inf_CheckURL (long CrsCod,Inf_InfoType_t InfoType);
static bool Inf_CheckAndShowURL (void); static bool Inf_CheckAndShowURL (void);
static void Inf_BuildPathURL (long CrsCod,Inf_InfoType_t InfoType,char *PathFile); static void Inf_BuildPathURL (long CrsCod,Inf_InfoType_t InfoType,
char PathFile[PATH_MAX + 1]);
static void Inf_ShowPage (const char *URL); static void Inf_ShowPage (const char *URL);
@ -771,12 +772,16 @@ static bool Inf_CheckPage (long CrsCod,Inf_InfoType_t InfoType)
/***** Open file with web page *****/ /***** Open file with web page *****/
/* 1. Check if index.html exists */ /* 1. Check if index.html exists */
sprintf (PathRelFileHTML,"%s/index.html",PathRelDirHTML); snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty? if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
return true; return true;
/* 2. If index.html does not exist, try index.htm */ /* 2. If index.html does not exist, try index.htm */
sprintf (PathRelFileHTML,"%s/index.htm",PathRelDirHTML); snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.htm",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty? if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
return true; return true;
@ -802,24 +807,30 @@ static bool Inf_CheckAndShowPage (void)
/***** Open file with web page *****/ /***** Open file with web page *****/
/* 1. Check if index.html exists */ /* 1. Check if index.html exists */
sprintf (PathRelFileHTML,"%s/index.html",PathRelDirHTML); snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty? if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
{ {
sprintf (URL,"%s/%s/%ld/%s/index.html", snprintf (URL,sizeof (URL),
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod, "%s/%s/%ld/%s/index.html",
Inf_FileNamesForInfoType[Gbl.CurrentCrs.Info.Type]); Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod,
Inf_FileNamesForInfoType[Gbl.CurrentCrs.Info.Type]);
Inf_ShowPage (URL); Inf_ShowPage (URL);
return true; return true;
} }
/* 2. If index.html does not exist, try index.htm */ /* 2. If index.html does not exist, try index.htm */
sprintf (PathRelFileHTML,"%s/index.htm",PathRelDirHTML); snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.htm",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty? if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
{ {
sprintf (URL,"%s/%s/%ld/%s/index.htm", snprintf (URL,sizeof (URL),
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod, "%s/%s/%ld/%s/index.htm",
Inf_FileNamesForInfoType[Gbl.CurrentCrs.Info.Type]); Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod,
Inf_FileNamesForInfoType[Gbl.CurrentCrs.Info.Type]);
Inf_ShowPage (URL); Inf_ShowPage (URL);
return true; return true;
@ -832,11 +843,12 @@ static bool Inf_CheckAndShowPage (void)
/* Build path inside a course for a given a info type to store web page file */ /* Build path inside a course for a given a info type to store web page file */
/*****************************************************************************/ /*****************************************************************************/
static void Inf_BuildPathPage (long CrsCod,Inf_InfoType_t InfoType,char *PathDir) static void Inf_BuildPathPage (long CrsCod,Inf_InfoType_t InfoType,char PathDir[PATH_MAX + 1])
{ {
sprintf (PathDir,"%s/%s/%ld/%s", snprintf (PathDir,PATH_MAX + 1,
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CRS,CrsCod, "%s/%s/%ld/%s",
Inf_FileNamesForInfoType[InfoType]); Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CRS,CrsCod,
Inf_FileNamesForInfoType[InfoType]);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -860,13 +872,17 @@ int Inf_WritePageIntoHTMLBuffer (char **HTMLBuffer)
/***** Open file with web page *****/ /***** Open file with web page *****/
/* 1. Check if index.html exists */ /* 1. Check if index.html exists */
sprintf (PathRelFileHTML,"%s/index.html",PathRelDirHTML); snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty? if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
FileExists = true; FileExists = true;
else else
{ {
/* 2. If index.html not exists, try index.htm */ /* 2. If index.html not exists, try index.htm */
sprintf (PathRelFileHTML,"%s/index.htm",PathRelDirHTML); snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.htm",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty? if (Fil_CheckIfPathExists (PathRelFileHTML)) // TODO: Check if not empty?
FileExists = true; FileExists = true;
} }
@ -973,11 +989,13 @@ static bool Inf_CheckAndShowURL (void)
/*** Build path inside a course for a given a info type to store URL file ****/ /*** Build path inside a course for a given a info type to store URL file ****/
/*****************************************************************************/ /*****************************************************************************/
static void Inf_BuildPathURL (long CrsCod,Inf_InfoType_t InfoType,char *PathFile) static void Inf_BuildPathURL (long CrsCod,Inf_InfoType_t InfoType,
char PathFile[PATH_MAX + 1])
{ {
sprintf (PathFile,"%s/%s/%ld/%s.url", snprintf (PathFile,PATH_MAX + 1,
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod, "%s/%s/%ld/%s.url",
Inf_FileNamesForInfoType[InfoType]); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod,
Inf_FileNamesForInfoType[InfoType]);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1844,7 +1862,7 @@ static bool Inf_CheckAndShowRichTxt (void)
char PathFileHTML[PATH_MAX + 1]; char PathFileHTML[PATH_MAX + 1];
FILE *FileMD; // Temporary Markdown file FILE *FileMD; // Temporary Markdown file
FILE *FileHTML; // Temporary HTML file FILE *FileHTML; // Temporary HTML file
char MathJaxURL[PATH_MAX]; char MathJaxURL[PATH_MAX + 1];
char Command[512 + PATH_MAX * 3]; // Command to call the program of preprocessing of photos char Command[512 + PATH_MAX * 3]; // Command to call the program of preprocessing of photos
int ReturnCode; int ReturnCode;
bool ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH || bool ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
@ -1882,10 +1900,12 @@ static bool Inf_CheckAndShowRichTxt (void)
/***** Store text into a temporary .md file in HTML output directory *****/ /***** Store text into a temporary .md file in HTML output directory *****/
// TODO: change to another directory? // TODO: change to another directory?
/* Create a unique name for the .md file */ /* Create a unique name for the .md file */
sprintf (PathFileMD,"%s/%s/%s.md", snprintf (PathFileMD,sizeof (PathFileMD),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted); "%s/%s/%s.md",
sprintf (PathFileHTML,"%s/%s/%s.md.html", // Do not use only .html because that is the output temporary file Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted);
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted); snprintf (PathFileHTML,sizeof (PathFileHTML),
"%s/%s/%s.md.html", // Do not use only .html because that is the output temporary file
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted);
/* Open Markdown file for writing */ /* Open Markdown file for writing */
if ((FileMD = fopen (PathFileMD,"wb")) == NULL) if ((FileMD = fopen (PathFileMD,"wb")) == NULL)
@ -1900,8 +1920,9 @@ static bool Inf_CheckAndShowRichTxt (void)
/***** Convert from Markdown to HTML *****/ /***** Convert from Markdown to HTML *****/
#ifdef Cfg_MATHJAX_LOCAL #ifdef Cfg_MATHJAX_LOCAL
// Use the local copy of MathJax // Use the local copy of MathJax
sprintf (MathJaxURL,"=%s/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML", snprintf (MathJaxURL,sizeof (MathJaxURL),
Cfg_URL_SWAD_PUBLIC); "=%s/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML",
Cfg_URL_SWAD_PUBLIC);
#else #else
// Use the MathJax Content Delivery Network (CDN) // Use the MathJax Content Delivery Network (CDN)
MathJaxURL[0] = '\0'; MathJaxURL[0] = '\0';
@ -1909,14 +1930,15 @@ static bool Inf_CheckAndShowRichTxt (void)
// --ascii uses only ascii characters in output // --ascii uses only ascii characters in output
// (uses numerical entities instead of UTF-8) // (uses numerical entities instead of UTF-8)
// is mandatory in order to convert (with iconv) the UTF-8 output of pandoc to WINDOWS-1252 // is mandatory in order to convert (with iconv) the UTF-8 output of pandoc to WINDOWS-1252
sprintf (Command,"iconv -f WINDOWS-1252 -t UTF-8 %s" snprintf (Command,sizeof (Command),
" | " "iconv -f WINDOWS-1252 -t UTF-8 %s"
"pandoc --ascii --mathjax%s -f markdown -t html5" " | "
" | " "pandoc --ascii --mathjax%s -f markdown -t html5"
"iconv -f UTF-8 -t WINDOWS-1252 -o %s", " | "
PathFileMD, "iconv -f UTF-8 -t WINDOWS-1252 -o %s",
MathJaxURL, PathFileMD,
PathFileHTML); MathJaxURL,
PathFileHTML);
ReturnCode = system (Command); ReturnCode = system (Command);
if (ReturnCode == -1) if (ReturnCode == -1)
Lay_ShowErrorAndExit ("Error when running command to convert from Markdown to HTML."); Lay_ShowErrorAndExit ("Error when running command to convert from Markdown to HTML.");
@ -1969,8 +1991,9 @@ int Inf_WritePlainTextIntoHTMLBuffer (char **HTMLBuffer)
if (TxtHTML[0]) if (TxtHTML[0])
{ {
/***** Create a unique name for the file *****/ /***** Create a unique name for the file *****/
sprintf (FileNameHTMLTmp,"%s/%s/%s_info.html", snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted); "%s/%s/%s_info.html",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted);
/***** Create a new temporary file for writing and reading *****/ /***** Create a new temporary file for writing and reading *****/
if ((FileHTMLTmp = fopen (FileNameHTMLTmp,"w+b")) == NULL) if ((FileHTMLTmp = fopen (FileNameHTMLTmp,"w+b")) == NULL)
@ -2320,7 +2343,9 @@ void Inf_ReceivePagInfo (void)
{ {
Fil_RemoveTree (PathRelDirHTML); Fil_RemoveTree (PathRelDirHTML);
Fil_CreateDirIfNotExists (PathRelDirHTML); Fil_CreateDirIfNotExists (PathRelDirHTML);
sprintf (PathRelFileHTML,"%s/index.html",PathRelDirHTML); snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
PathRelDirHTML);
if (Fil_EndReceptionOfFile (PathRelFileHTML,Param)) if (Fil_EndReceptionOfFile (PathRelFileHTML,Param))
{ {
Ale_ShowAlert (Ale_SUCCESS,Txt_The_HTML_file_has_been_received_successfully); Ale_ShowAlert (Ale_SUCCESS,Txt_The_HTML_file_has_been_received_successfully);
@ -2333,21 +2358,25 @@ void Inf_ReceivePagInfo (void)
{ {
Fil_RemoveTree (PathRelDirHTML); Fil_RemoveTree (PathRelDirHTML);
Fil_CreateDirIfNotExists (PathRelDirHTML); Fil_CreateDirIfNotExists (PathRelDirHTML);
sprintf (PathRelFileZIP,"%s/%s.zip", snprintf (PathRelFileZIP,sizeof (PathRelFileZIP),
Gbl.CurrentCrs.PathPriv, "%s/%s.zip",
Inf_FileNamesForInfoType[Gbl.CurrentCrs.Info.Type]); Gbl.CurrentCrs.PathPriv,
Inf_FileNamesForInfoType[Gbl.CurrentCrs.Info.Type]);
if (Fil_EndReceptionOfFile (PathRelFileZIP,Param)) if (Fil_EndReceptionOfFile (PathRelFileZIP,Param))
{ {
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_received_successfully); Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_received_successfully);
/* Uncompress ZIP */ /* Uncompress ZIP */
sprintf (StrUnzip,"unzip -qq -o %s -d %s", snprintf (StrUnzip,sizeof (StrUnzip),
PathRelFileZIP,PathRelDirHTML); "unzip -qq -o %s -d %s",
PathRelFileZIP,PathRelDirHTML);
if (system (StrUnzip) == 0) if (system (StrUnzip) == 0)
{ {
/* Check if uploaded file is index.html or index.htm */ /* Check if uploaded file is index.html or index.htm */
sprintf (PathRelFileHTML,"%s/index.html",PathRelDirHTML); snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.html",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) if (Fil_CheckIfPathExists (PathRelFileHTML))
{ {
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully); Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully);
@ -2356,7 +2385,9 @@ void Inf_ReceivePagInfo (void)
} }
else else
{ {
sprintf (PathRelFileHTML,"%s/index.htm",PathRelDirHTML); snprintf (PathRelFileHTML,sizeof (PathRelFileHTML),
"%s/index.htm",
PathRelDirHTML);
if (Fil_CheckIfPathExists (PathRelFileHTML)) if (Fil_CheckIfPathExists (PathRelFileHTML))
{ {
Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully); Ale_ShowAlert (Ale_SUCCESS,Txt_The_ZIP_file_has_been_unzipped_successfully);

View File

@ -248,7 +248,9 @@ void Ins_DrawInstitutionLogoAndNameWithLink (struct Instit *Ins,Act_Action_t Act
Ins_PutParamInsCod (Ins->InsCod); Ins_PutParamInsCod (Ins->InsCod);
/***** Link to action *****/ /***** Link to action *****/
sprintf (Gbl.Title,Txt_Go_to_X,Ins->FullName); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Go_to_X,
Ins->FullName);
Act_LinkFormSubmit (Gbl.Title,ClassLink,NULL); Act_LinkFormSubmit (Gbl.Title,ClassLink,NULL);
/***** Draw institution logo *****/ /***** Draw institution logo *****/
@ -529,8 +531,9 @@ static void Ins_Configuration (bool PrintView)
/* Form to go to see centres of this institution */ /* Form to go to see centres of this institution */
Act_StartFormGoTo (ActSeeCtr); Act_StartFormGoTo (ActSeeCtr);
Ins_PutParamInsCod (Gbl.CurrentIns.Ins.InsCod); Ins_PutParamInsCod (Gbl.CurrentIns.Ins.InsCod);
sprintf (Gbl.Title,Txt_Centres_of_INSTITUTION_X, snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.CurrentIns.Ins.ShrtName); Txt_Centres_of_INSTITUTION_X,
Gbl.CurrentIns.Ins.ShrtName);
Act_LinkFormSubmit (Gbl.Title,"DAT",NULL); Act_LinkFormSubmit (Gbl.Title,"DAT",NULL);
fprintf (Gbl.F.Out,"%u</a>", fprintf (Gbl.F.Out,"%u</a>",
Ctr_GetNumCtrsInIns (Gbl.CurrentIns.Ins.InsCod)); Ctr_GetNumCtrsInIns (Gbl.CurrentIns.Ins.InsCod));
@ -670,7 +673,9 @@ static void Ins_ListInstitutions (void)
unsigned NumIns; unsigned NumIns;
/***** Start box *****/ /***** Start box *****/
sprintf (Gbl.Title,Txt_Institutions_of_COUNTRY_X,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Institutions_of_COUNTRY_X,
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
Box_StartBox (NULL,Gbl.Title,Ins_PutIconsListInstitutions, Box_StartBox (NULL,Gbl.Title,Ins_PutIconsListInstitutions,
Hlp_COUNTRY_Institutions,Box_NOT_CLOSABLE); Hlp_COUNTRY_Institutions,Box_NOT_CLOSABLE);
@ -919,8 +924,9 @@ void Ins_EditInstitutions (void)
Ins_GetListInstitutions (Gbl.CurrentCty.Cty.CtyCod,Ins_GET_EXTRA_DATA); Ins_GetListInstitutions (Gbl.CurrentCty.Cty.CtyCod,Ins_GET_EXTRA_DATA);
/***** Start box *****/ /***** Start box *****/
sprintf (Gbl.Title,Txt_Institutions_of_COUNTRY_X, snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]); Txt_Institutions_of_COUNTRY_X,
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
Box_StartBox (NULL,Gbl.Title,Ins_PutIconToViewInstitutions, Box_StartBox (NULL,Gbl.Title,Ins_PutIconToViewInstitutions,
Hlp_COUNTRY_Institutions,Box_NOT_CLOSABLE); Hlp_COUNTRY_Institutions,Box_NOT_CLOSABLE);
@ -1711,10 +1717,11 @@ void Ins_RemoveInstitution (void)
Brw_RemoveInsFilesFromDB (Ins.InsCod); Brw_RemoveInsFilesFromDB (Ins.InsCod);
/***** Remove directories of the institution *****/ /***** Remove directories of the institution *****/
sprintf (PathIns,"%s/%s/%02u/%u", snprintf (PathIns,sizeof (PathIns),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_INS, "%s/%s/%02u/%u",
(unsigned) (Ins.InsCod % 100), Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_INS,
(unsigned) Ins.InsCod); (unsigned) (Ins.InsCod % 100),
(unsigned) Ins.InsCod);
Fil_RemoveTree (PathIns); Fil_RemoveTree (PathIns);
/***** Remove institution *****/ /***** Remove institution *****/
@ -2129,7 +2136,9 @@ static void Ins_ShowAlertAndButtonToGoToIns (void)
if (Gbl.Inss.EditingIns.InsCod != Gbl.CurrentIns.Ins.InsCod) if (Gbl.Inss.EditingIns.InsCod != Gbl.CurrentIns.Ins.InsCod)
{ {
/***** Alert with button to go to degree *****/ /***** Alert with button to go to degree *****/
sprintf (Gbl.Title,Txt_Go_to_X,Gbl.Inss.EditingIns.ShrtName); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Go_to_X,
Gbl.Inss.EditingIns.ShrtName);
Ale_ShowAlertAndButton (Gbl.Alert.Type,Gbl.Alert.Txt, Ale_ShowAlertAndButton (Gbl.Alert.Type,Gbl.Alert.Txt,
ActSeeCtr,NULL,NULL,Ins_PutParamGoToIns, ActSeeCtr,NULL,NULL,Ins_PutParamGoToIns,
Btn_CONFIRM_BUTTON,Gbl.Title); Btn_CONFIRM_BUTTON,Gbl.Title);
@ -2549,9 +2558,10 @@ unsigned Ins_ListInssFound (const char *Query)
{ {
/***** Start box and table *****/ /***** Start box and table *****/
/* Number of institutions found */ /* Number of institutions found */
sprintf (Gbl.Title,"%u %s", snprintf (Gbl.Title,sizeof (Gbl.Title),
NumInss,NumInss == 1 ? Txt_institution : "%u %s",
Txt_institutions); NumInss,NumInss == 1 ? Txt_institution :
Txt_institutions);
Box_StartBoxTable (NULL,Gbl.Title,NULL, Box_StartBoxTable (NULL,Gbl.Title,NULL,
NULL,Box_NOT_CLOSABLE,2); NULL,Box_NOT_CLOSABLE,2);

View File

@ -93,11 +93,12 @@ void Log_DrawLogo (Sco_Scope_t Scope,long Cod,const char *AltText,
{ {
Folder = Cfg_FOLDER_DEG; Folder = Cfg_FOLDER_DEG;
DegCod = Cod; DegCod = Cod;
sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", snprintf (PathLogo,sizeof (PathLogo),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u/%u/logo/%u.png",
(unsigned) (DegCod % 100), Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) DegCod, (unsigned) (DegCod % 100),
(unsigned) DegCod); (unsigned) DegCod,
(unsigned) DegCod);
LogoFound = Fil_CheckIfPathExists (PathLogo); LogoFound = Fil_CheckIfPathExists (PathLogo);
if (LogoFound) if (LogoFound)
Cod = DegCod; Cod = DegCod;
@ -111,11 +112,12 @@ void Log_DrawLogo (Sco_Scope_t Scope,long Cod,const char *AltText,
CtrCod = Deg_GetCtrCodOfDegreeByCod (Cod); CtrCod = Deg_GetCtrCodOfDegreeByCod (Cod);
else else
CtrCod = Cod; CtrCod = Cod;
sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", snprintf (PathLogo,sizeof (PathLogo),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u/%u/logo/%u.png",
(unsigned) (CtrCod % 100), Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) CtrCod, (unsigned) (CtrCod % 100),
(unsigned) CtrCod); (unsigned) CtrCod,
(unsigned) CtrCod);
LogoFound = Fil_CheckIfPathExists (PathLogo); LogoFound = Fil_CheckIfPathExists (PathLogo);
if (LogoFound) if (LogoFound)
Cod = CtrCod; Cod = CtrCod;
@ -131,11 +133,12 @@ void Log_DrawLogo (Sco_Scope_t Scope,long Cod,const char *AltText,
InsCod = Ctr_GetInsCodOfCentreByCod (Cod); InsCod = Ctr_GetInsCodOfCentreByCod (Cod);
else else
InsCod = Cod; InsCod = Cod;
sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", snprintf (PathLogo,sizeof (PathLogo),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u/%u/logo/%u.png",
(unsigned) (InsCod % 100), Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) InsCod, (unsigned) (InsCod % 100),
(unsigned) InsCod); (unsigned) InsCod,
(unsigned) InsCod);
LogoFound = Fil_CheckIfPathExists (PathLogo); LogoFound = Fil_CheckIfPathExists (PathLogo);
if (LogoFound) if (LogoFound)
Cod = InsCod; Cod = InsCod;
@ -206,11 +209,12 @@ void Log_PutIconToChangeLogo (Sco_Scope_t Scope)
} }
/***** Check if logo exists *****/ /***** Check if logo exists *****/
sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", snprintf (PathLogo,sizeof (PathLogo),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u/%u/logo/%u.png",
(unsigned) (Cod % 100), Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) Cod, (unsigned) (Cod % 100),
(unsigned) Cod); (unsigned) Cod,
(unsigned) Cod);
LogoExists = Fil_CheckIfPathExists (PathLogo); LogoExists = Fil_CheckIfPathExists (PathLogo);
/***** Link for changing / uploading the logo *****/ /***** Link for changing / uploading the logo *****/
@ -264,11 +268,12 @@ void Log_RequestLogo (Sco_Scope_t Scope)
} }
/***** Check if logo exists *****/ /***** Check if logo exists *****/
sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", snprintf (PathLogo,sizeof (PathLogo),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u/%u/logo/%u.png",
(unsigned) (Cod % 100), Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) Cod, (unsigned) (Cod % 100),
(unsigned) Cod); (unsigned) Cod,
(unsigned) Cod);
if (Fil_CheckIfPathExists (PathLogo)) if (Fil_CheckIfPathExists (PathLogo))
{ {
/***** Form to remove photo *****/ /***** Form to remove photo *****/
@ -347,22 +352,26 @@ void Log_ReceiveLogo (Sco_Scope_t Scope)
} }
/***** Creates directories if not exist *****/ /***** Creates directories if not exist *****/
sprintf (Path,"%s/%s", snprintf (Path,sizeof (Path),
Cfg_PATH_SWAD_PUBLIC,Folder); "%s/%s",
Cfg_PATH_SWAD_PUBLIC,Folder);
Fil_CreateDirIfNotExists (Path); Fil_CreateDirIfNotExists (Path);
sprintf (Path,"%s/%s/%02u", snprintf (Path,sizeof (Path),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u",
(unsigned) (Cod % 100)); Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) (Cod % 100));
Fil_CreateDirIfNotExists (Path); Fil_CreateDirIfNotExists (Path);
sprintf (Path,"%s/%s/%02u/%u", snprintf (Path,sizeof (Path),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u/%u",
(unsigned) (Cod % 100), Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) Cod); (unsigned) (Cod % 100),
(unsigned) Cod);
Fil_CreateDirIfNotExists (Path); Fil_CreateDirIfNotExists (Path);
sprintf (Path,"%s/%s/%02u/%u/logo", snprintf (Path,sizeof (Path),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u/%u/logo",
(unsigned) (Cod % 100), Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) Cod); (unsigned) (Cod % 100),
(unsigned) Cod);
Fil_CreateDirIfNotExists (Path); Fil_CreateDirIfNotExists (Path);
/***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/ /***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/
@ -386,11 +395,12 @@ void Log_ReceiveLogo (Sco_Scope_t Scope)
else else
{ {
/* End the reception of logo in a temporary file */ /* End the reception of logo in a temporary file */
sprintf (FileNameLogo,"%s/%s/%02u/%u/logo/%u.png", snprintf (FileNameLogo,sizeof (FileNameLogo),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u/%u/logo/%u.png",
(unsigned) (Cod % 100), Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) Cod, (unsigned) (Cod % 100),
(unsigned) Cod); (unsigned) Cod,
(unsigned) Cod);
if (!Fil_EndReceptionOfFile (FileNameLogo,Param)) if (!Fil_EndReceptionOfFile (FileNameLogo,Param))
Ale_ShowAlert (Ale_WARNING,"Error copying file."); Ale_ShowAlert (Ale_WARNING,"Error copying file.");
} }
@ -426,10 +436,11 @@ void Log_RemoveLogo (Sco_Scope_t Scope)
} }
/***** Remove logo *****/ /***** Remove logo *****/
sprintf (FileNameLogo,"%s/%s/%02u/%u/logo/%u.png", snprintf (FileNameLogo,sizeof (FileNameLogo),
Cfg_PATH_SWAD_PUBLIC,Folder, "%s/%s/%02u/%u/logo/%u.png",
(unsigned) (Cod % 100), Cfg_PATH_SWAD_PUBLIC,Folder,
(unsigned) Cod, (unsigned) (Cod % 100),
(unsigned) Cod); (unsigned) Cod,
(unsigned) Cod);
Fil_RemoveTree (FileNameLogo); Fil_RemoveTree (FileNameLogo);
} }

View File

@ -1161,7 +1161,9 @@ void Mai_ShowFormChangeMyEmail (bool IMustFillEmail,bool IShouldConfirmEmail)
Lay_StartSection (Mai_EMAIL_SECTION_ID); Lay_StartSection (Mai_EMAIL_SECTION_ID);
/***** Start box *****/ /***** Start box *****/
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH); snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
Box_StartBox (StrRecordWidth,Txt_Email,Acc_PutLinkToRemoveMyAccount, Box_StartBox (StrRecordWidth,Txt_Email,Acc_PutLinkToRemoveMyAccount,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE); Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
@ -1191,7 +1193,9 @@ void Mai_ShowFormChangeOtherUsrEmail (void)
Lay_StartSection (Mai_EMAIL_SECTION_ID); Lay_StartSection (Mai_EMAIL_SECTION_ID);
/***** Start box *****/ /***** Start box *****/
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH); snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
Box_StartBox (StrRecordWidth,Txt_Email,NULL, Box_StartBox (StrRecordWidth,Txt_Email,NULL,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE); Hlp_PROFILE_Account,Box_NOT_CLOSABLE);
@ -1323,7 +1327,9 @@ static void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe,
/* Email confirmed? */ /* Email confirmed? */
if (Confirmed) if (Confirmed)
{ {
sprintf (Gbl.Title,Txt_Email_X_confirmed,row[0]); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Email_X_confirmed,
row[0]);
fprintf (Gbl.F.Out,"<img src=\"%s/ok_green16x16.gif\"" fprintf (Gbl.F.Out,"<img src=\"%s/ok_green16x16.gif\""
" alt=\"%s\" title=\"%s\"" " alt=\"%s\" title=\"%s\""
" class=\"ICO20x20\" />", " class=\"ICO20x20\" />",
@ -1722,15 +1728,16 @@ bool Mai_SendMailMsgToConfirmEmail (void)
fclose (Gbl.Msg.FileMail); fclose (Gbl.Msg.FileMail);
/***** Call the script to send an email *****/ /***** Call the script to send an email *****/
sprintf (Command,"%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"[%s] %s\" \"%s\"", snprintf (Command,sizeof (Command),
Cfg_COMMAND_SEND_AUTOMATIC_EMAIL, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"[%s] %s\" \"%s\"",
Cfg_AUTOMATIC_EMAIL_SMTP_SERVER, Cfg_COMMAND_SEND_AUTOMATIC_EMAIL,
Cfg_AUTOMATIC_EMAIL_SMTP_PORT, Cfg_AUTOMATIC_EMAIL_SMTP_SERVER,
Cfg_AUTOMATIC_EMAIL_FROM, Cfg_AUTOMATIC_EMAIL_SMTP_PORT,
Gbl.Config.SMTPPassword, Cfg_AUTOMATIC_EMAIL_FROM,
Gbl.Usrs.Me.UsrDat.Email, Gbl.Config.SMTPPassword,
Cfg_PLATFORM_SHORT_NAME,Txt_Confirmation_of_your_email_NO_HTML, Gbl.Usrs.Me.UsrDat.Email,
Gbl.Msg.FileNameMail); Cfg_PLATFORM_SHORT_NAME,Txt_Confirmation_of_your_email_NO_HTML,
Gbl.Msg.FileNameMail);
ReturnCode = system (Command); ReturnCode = system (Command);
if (ReturnCode == -1) if (ReturnCode == -1)
Lay_ShowErrorAndExit ("Error when running script to send email."); Lay_ShowErrorAndExit ("Error when running script to send email.");
@ -1894,8 +1901,9 @@ void Mai_ConfirmEmail (void)
void Mai_CreateFileNameMail (void) void Mai_CreateFileNameMail (void)
{ {
sprintf (Gbl.Msg.FileNameMail,"%s/%s/%s_mail.txt", snprintf (Gbl.Msg.FileNameMail,sizeof (Gbl.Msg.FileNameMail),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted); "%s/%s/%s_mail.txt",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted);
if ((Gbl.Msg.FileMail = fopen (Gbl.Msg.FileNameMail,"wb")) == NULL) if ((Gbl.Msg.FileMail = fopen (Gbl.Msg.FileNameMail,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not open file to send email."); Lay_ShowErrorAndExit ("Can not open file to send email.");
} }

View File

@ -25,9 +25,11 @@
/********************************** Headers **********************************/ /********************************** Headers **********************************/
/*****************************************************************************/ /*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/limits.h> // For PATH_MAX #include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL #include <linux/stddef.h> // For NULL
#include <malloc.h> // For malloc #include <malloc.h> // For malloc
#include <stdio.h> // For asprintf
#include <string.h> // For string functions #include <string.h> // For string functions
#include <unistd.h> // For unlink #include <unistd.h> // For unlink
@ -628,9 +630,10 @@ void Mrk_ShowMyMarks (void)
/***** Get the path of the file of marks *****/ /***** Get the path of the file of marks *****/
Brw_SetFullPathInTree (Gbl.FileBrowser.Priv.PathInTreeUntilFilFolLnk, Brw_SetFullPathInTree (Gbl.FileBrowser.Priv.PathInTreeUntilFilFolLnk,
Gbl.FileBrowser.FilFolLnkName); Gbl.FileBrowser.FilFolLnkName);
sprintf (PathPrivate,"%s/%s", snprintf (PathPrivate,sizeof (PathPrivate),
Gbl.FileBrowser.Priv.PathAboveRootFolder, "%s/%s",
Gbl.FileBrowser.Priv.FullPathInTree); Gbl.FileBrowser.Priv.PathAboveRootFolder,
Gbl.FileBrowser.Priv.FullPathInTree);
/***** Get number of rows of header or footer *****/ /***** Get number of rows of header or footer *****/
Mrk_GetNumRowsHeaderAndFooter (&Marks); Mrk_GetNumRowsHeaderAndFooter (&Marks);
@ -670,8 +673,9 @@ void Mrk_ShowMyMarks (void)
/***** Create temporal file to store my marks (in HTML) *****/ /***** Create temporal file to store my marks (in HTML) *****/
/* If the private directory does not exist, create it */ /* If the private directory does not exist, create it */
sprintf (PathMarksPriv,"%s/%s", snprintf (PathMarksPriv,sizeof (PathMarksPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_MARK); "%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_MARK);
Fil_CreateDirIfNotExists (PathMarksPriv); Fil_CreateDirIfNotExists (PathMarksPriv);
/* First of all, we remove the oldest temporary files. /* First of all, we remove the oldest temporary files.
@ -681,7 +685,9 @@ void Mrk_ShowMyMarks (void)
Fil_RemoveOldTmpFiles (PathMarksPriv,Cfg_TIME_TO_DELETE_MARKS_TMP_FILES,false); Fil_RemoveOldTmpFiles (PathMarksPriv,Cfg_TIME_TO_DELETE_MARKS_TMP_FILES,false);
/* Create a new temporary file *****/ /* Create a new temporary file *****/
sprintf (FileNameUsrMarks,"%s/%s.html",PathMarksPriv,Gbl.UniqueNameEncrypted); snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),
"%s/%s.html",
PathMarksPriv,Gbl.UniqueNameEncrypted);
if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")) == NULL) if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not open file for my marks."); Lay_ShowErrorAndExit ("Can not open file for my marks.");
@ -811,18 +817,21 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
if (UsrDat.IDs.Num) if (UsrDat.IDs.Num)
{ {
if (GrpCod > 0) if (GrpCod > 0)
sprintf (PathMarks,"%s/%s/%ld/grp/%ld/%s", snprintf (PathMarks,sizeof (PathMarks),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod,GrpCod, "%s/%s/%ld/grp/%ld/%s",
FullPathInTreeFromDBMarksTable); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod,GrpCod,
FullPathInTreeFromDBMarksTable);
else else
sprintf (PathMarks,"%s/%s/%ld/%s", snprintf (PathMarks,sizeof (PathMarks),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod, "%s/%s/%ld/%s",
FullPathInTreeFromDBMarksTable); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod,
FullPathInTreeFromDBMarksTable);
/***** Create temporal file to store my marks (in HTML) *****/ /***** Create temporal file to store my marks (in HTML) *****/
/* If the private directory does not exist, create it */ /* If the private directory does not exist, create it */
sprintf (PathMarksPriv,"%s/%s", snprintf (PathMarksPriv,sizeof (PathMarksPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_MARK); "%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_MARK);
Fil_CreateDirIfNotExists (PathMarksPriv); Fil_CreateDirIfNotExists (PathMarksPriv);
/* First of all, we remove the oldest temporary files. /* First of all, we remove the oldest temporary files.
@ -832,7 +841,9 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
Fil_RemoveOldTmpFiles (PathMarksPriv,Cfg_TIME_TO_DELETE_MARKS_TMP_FILES,false); Fil_RemoveOldTmpFiles (PathMarksPriv,Cfg_TIME_TO_DELETE_MARKS_TMP_FILES,false);
/* Create a new temporary file *****/ /* Create a new temporary file *****/
sprintf (FileNameUsrMarks,"%s/%s.html",PathMarksPriv,Gbl.UniqueNameEncrypted); snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),
"%s/%s.html",
PathMarksPriv,Gbl.UniqueNameEncrypted);
if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb"))) if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")))
{ {
/***** Get user's marks *****/ /***** Get user's marks *****/
@ -867,8 +878,9 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
else else
{ {
fclose (FileUsrMarks); fclose (FileUsrMarks);
if ((*ContentStr = (char *) malloc (9 + strlen (Gbl.Alert.Txt) + 3 + 1))) if (asprintf (ContentStr,"<![CDATA[%s]]>",
sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Alert.Txt); Gbl.Alert.Txt) < 0)
Lay_ShowErrorAndExit ("Not enough memory to store string.");
} }
} }
else else
@ -876,8 +888,9 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Type = Ale_WARNING;
Str_Copy (Gbl.Alert.Txt,"Can not open file of marks.", // TODO: Need translation! Str_Copy (Gbl.Alert.Txt,"Can not open file of marks.", // TODO: Need translation!
Ale_MAX_BYTES_ALERT); Ale_MAX_BYTES_ALERT);
if ((*ContentStr = (char *) malloc (9 + strlen (Gbl.Alert.Txt) + 3 + 1))) if (asprintf (ContentStr,"<![CDATA[%s]]>",
sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Alert.Txt); Gbl.Alert.Txt) < 0)
Lay_ShowErrorAndExit ("Not enough memory to store string.");
} }
unlink (FileNameUsrMarks); // File with marks is no longer necessary unlink (FileNameUsrMarks); // File with marks is no longer necessary
} }
@ -886,8 +899,9 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
Gbl.Alert.Type = Ale_WARNING; Gbl.Alert.Type = Ale_WARNING;
Str_Copy (Gbl.Alert.Txt,"User's IDs not found!", // TODO: Need translation! Str_Copy (Gbl.Alert.Txt,"User's IDs not found!", // TODO: Need translation!
Ale_MAX_BYTES_ALERT); Ale_MAX_BYTES_ALERT);
if ((*ContentStr = (char *) malloc (9 + strlen (Gbl.Alert.Txt) + 3 + 1))) if (asprintf (ContentStr,"<![CDATA[%s]]>",
sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Alert.Txt); Gbl.Alert.Txt) < 0)
Lay_ShowErrorAndExit ("Not enough memory to store string.");
} }
} }
} }

View File

@ -620,7 +620,9 @@ void Msg_PutHiddenParamAnotherRecipient (const struct UsrData *UsrDat)
{ {
char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1]; char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
sprintf (NicknameWithArroba,"@%s",UsrDat->Nickname); snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
"@%s",
UsrDat->Nickname);
Par_PutHiddenParamString ("OtherRecipients",NicknameWithArroba); Par_PutHiddenParamString ("OtherRecipients",NicknameWithArroba);
} }
@ -2388,34 +2390,41 @@ static char *Msg_WriteNumMsgs (unsigned NumUnreadMsgs)
if (Gbl.Msg.NumMsgs == 1) if (Gbl.Msg.NumMsgs == 1)
{ {
if (NumUnreadMsgs) if (NumUnreadMsgs)
sprintf (Gbl.Title,"1 %s, 1 %s", snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_message_received,Txt_unread_MESSAGE); "1 %s, 1 %s",
Txt_message_received,Txt_unread_MESSAGE);
else else
sprintf (Gbl.Title,"1 %s", snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_message_received); "1 %s",
Txt_message_received);
} }
else else
{ {
if (NumUnreadMsgs == 0) if (NumUnreadMsgs == 0)
sprintf (Gbl.Title,"%u %s", snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.Msg.NumMsgs,Txt_messages_received); "%u %s",
Gbl.Msg.NumMsgs,Txt_messages_received);
else if (NumUnreadMsgs == 1) else if (NumUnreadMsgs == 1)
sprintf (Gbl.Title,"%u %s, 1 %s", snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.Msg.NumMsgs,Txt_messages_received, "%u %s, 1 %s",
Txt_unread_MESSAGE); Gbl.Msg.NumMsgs,Txt_messages_received,
Txt_unread_MESSAGE);
else else
sprintf (Gbl.Title,"%u %s, %u %s", snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.Msg.NumMsgs,Txt_messages_received, "%u %s, %u %s",
NumUnreadMsgs,Txt_unread_MESSAGES); Gbl.Msg.NumMsgs,Txt_messages_received,
NumUnreadMsgs,Txt_unread_MESSAGES);
} }
break; break;
case Msg_MESSAGES_SENT: case Msg_MESSAGES_SENT:
if (Gbl.Msg.NumMsgs == 1) if (Gbl.Msg.NumMsgs == 1)
sprintf (Gbl.Title,"1 %s", snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_message_sent); "1 %s",
Txt_message_sent);
else else
sprintf (Gbl.Title,"%u %s", snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.Msg.NumMsgs,Txt_messages_sent); "%u %s",
Gbl.Msg.NumMsgs,Txt_messages_sent);
break; break;
} }
@ -3230,7 +3239,9 @@ bool Msg_WriteCrsOrgMsg (long CrsCod)
Crs_PutParamCrsCod (Crs.CrsCod); Crs_PutParamCrsCod (Crs.CrsCod);
fprintf (Gbl.F.Out,"<div class=\"AUTHOR_TXT\">" fprintf (Gbl.F.Out,"<div class=\"AUTHOR_TXT\">"
"("); "(");
sprintf (Gbl.Title,Txt_Go_to_X,Crs.FullName); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Go_to_X,
Crs.FullName);
Act_LinkFormSubmit (Gbl.Title,"AUTHOR_TXT",NULL); Act_LinkFormSubmit (Gbl.Title,"AUTHOR_TXT",NULL);
fprintf (Gbl.F.Out,"%s</a>)" fprintf (Gbl.F.Out,"%s</a>)"
"</div>", "</div>",

View File

@ -289,7 +289,9 @@ void Net_ShowFormMyWebsAndSocialNets (void)
Lay_StartSection (Net_MY_WEBS_ID); Lay_StartSection (Net_MY_WEBS_ID);
/***** Start box and table *****/ /***** Start box and table *****/
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH); snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
Box_StartBoxTable (StrRecordWidth, Box_StartBoxTable (StrRecordWidth,
Txt_Webs_social_networks,Net_PutIconsWebsSocialNetworks, Txt_Webs_social_networks,Net_PutIconsWebsSocialNetworks,
Hlp_PROFILE_Webs,Box_NOT_CLOSABLE,2); Hlp_PROFILE_Webs,Box_NOT_CLOSABLE,2);

View File

@ -246,7 +246,9 @@ static void Nck_ShowFormChangeUsrNickname (const struct UsrData *UsrDat,bool Its
NumNicks = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get nicknames of a user"); NumNicks = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get nicknames of a user");
/***** Start box *****/ /***** Start box *****/
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH); snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
Box_StartBox (StrRecordWidth,Txt_Nickname,Acc_PutLinkToRemoveMyAccount, Box_StartBox (StrRecordWidth,Txt_Nickname,Acc_PutLinkToRemoveMyAccount,
Hlp_PROFILE_Account,Box_NOT_CLOSABLE); Hlp_PROFILE_Account,Box_NOT_CLOSABLE);

View File

@ -389,8 +389,9 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing)
if (TypeNoticesListing == Not_LIST_FULL_NOTICES) if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
{ {
/***** Start box *****/ /***** Start box *****/
sprintf (StrWidth,"%upx", snprintf (StrWidth,sizeof (StrWidth),
Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50); "%upx",
Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50);
Box_StartBox (StrWidth, Box_StartBox (StrWidth,
Gbl.CurrentCrs.Notices.HighlightNotCod > 0 ? Txt_All_notices : Gbl.CurrentCrs.Notices.HighlightNotCod > 0 ? Txt_All_notices :
Txt_Notices, Txt_Notices,
@ -442,8 +443,10 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing)
case Not_LIST_BRIEF_NOTICES: case Not_LIST_BRIEF_NOTICES:
/***** Link to RSS file *****/ /***** Link to RSS file *****/
/* Create RSS file if not exists */ /* Create RSS file if not exists */
sprintf (PathRelRSSFile,"%s/%s/%ld/%s/%s", snprintf (PathRelRSSFile,sizeof (PathRelRSSFile),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE); "%s/%s/%ld/%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CRS,
Gbl.CurrentCrs.Crs.CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
if (!Fil_CheckIfPathExists (PathRelRSSFile)) if (!Fil_CheckIfPathExists (PathRelRSSFile))
RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs); RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs);

View File

@ -1747,16 +1747,17 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
fclose (Gbl.Msg.FileMail); fclose (Gbl.Msg.FileMail);
/***** Call the command to send an email *****/ /***** Call the command to send an email *****/
sprintf (Command,"%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"[%s] %s\" \"%s\"", snprintf (Command,sizeof (Command),
Cfg_COMMAND_SEND_AUTOMATIC_EMAIL, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"[%s] %s\" \"%s\"",
Cfg_AUTOMATIC_EMAIL_SMTP_SERVER, Cfg_COMMAND_SEND_AUTOMATIC_EMAIL,
Cfg_AUTOMATIC_EMAIL_SMTP_PORT, Cfg_AUTOMATIC_EMAIL_SMTP_SERVER,
Cfg_AUTOMATIC_EMAIL_FROM, Cfg_AUTOMATIC_EMAIL_SMTP_PORT,
Gbl.Config.SMTPPassword, Cfg_AUTOMATIC_EMAIL_FROM,
ToUsrDat->Email, Gbl.Config.SMTPPassword,
Cfg_PLATFORM_SHORT_NAME, ToUsrDat->Email,
Txt_Notifications_NO_HTML[ToUsrLanguage], Cfg_PLATFORM_SHORT_NAME,
Gbl.Msg.FileNameMail); Txt_Notifications_NO_HTML[ToUsrLanguage],
Gbl.Msg.FileNameMail);
ReturnCode = system (Command); ReturnCode = system (Command);
if (ReturnCode == -1) if (ReturnCode == -1)
Lay_ShowErrorAndExit ("Error when running script to send email."); Lay_ShowErrorAndExit ("Error when running script to send email.");

View File

@ -234,8 +234,9 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
sprintf (Gbl.Title,Txt_Page_X_of_Y, snprintf (Gbl.Title,sizeof (Gbl.Title),
1,Pagination->NumPags); Txt_Page_X_of_Y,
1,Pagination->NumPags);
Act_LinkFormSubmit (Gbl.Title,Font,NULL); Act_LinkFormSubmit (Gbl.Title,Font,NULL);
} }
else else
@ -257,7 +258,9 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
/***** Links to several pages start here *****/ /***** Links to several pages start here *****/
if (Pagination->MoreThanOnePage) if (Pagination->MoreThanOnePage)
{ {
sprintf (LinkStyle,"PAG %s",Font); snprintf (LinkStyle,sizeof (LinkStyle),
"PAG %s",
Font);
/***** Possible link to page 1 *****/ /***** Possible link to page 1 *****/
if (Pagination->StartPage > 1) if (Pagination->StartPage > 1)
@ -342,8 +345,9 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
sprintf (Gbl.Title,Txt_Page_X_of_Y, snprintf (Gbl.Title,sizeof (Gbl.Title),
1,Pagination->NumPags); Txt_Page_X_of_Y,
1,Pagination->NumPags);
Act_LinkFormSubmit (Gbl.Title,LinkStyle,NULL); Act_LinkFormSubmit (Gbl.Title,LinkStyle,NULL);
fprintf (Gbl.F.Out,"1" fprintf (Gbl.F.Out,"1"
"</a>"); "</a>");
@ -436,9 +440,10 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
sprintf (Gbl.Title,Txt_Page_X_of_Y, snprintf (Gbl.Title,sizeof (Gbl.Title),
Pagination->LeftPage, Txt_Page_X_of_Y,
Pagination->NumPags); Pagination->LeftPage,
Pagination->NumPags);
Act_LinkFormSubmit (Gbl.Title,LinkStyle,NULL); Act_LinkFormSubmit (Gbl.Title,LinkStyle,NULL);
fprintf (Gbl.F.Out,"%u</a>", fprintf (Gbl.F.Out,"%u</a>",
Pagination->LeftPage); Pagination->LeftPage);
@ -452,8 +457,9 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
NumPage <= Pagination->EndPage; NumPage <= Pagination->EndPage;
NumPage++) NumPage++)
{ {
sprintf (Gbl.Title,Txt_Page_X_of_Y, snprintf (Gbl.Title,sizeof (Gbl.Title),
NumPage,Pagination->NumPags); Txt_Page_X_of_Y,
NumPage,Pagination->NumPags);
if (!LinkToPagCurrent && NumPage == Pagination->CurrentPage) if (!LinkToPagCurrent && NumPage == Pagination->CurrentPage)
fprintf (Gbl.F.Out,"<span title=\"%s\" class=\"PAG_CUR %s\">" fprintf (Gbl.F.Out,"<span title=\"%s\" class=\"PAG_CUR %s\">"
"%u" "%u"
@ -634,8 +640,9 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
sprintf (Gbl.Title,Txt_Page_X_of_Y, snprintf (Gbl.Title,sizeof (Gbl.Title),
Pagination->RightPage,Pagination->NumPags); Txt_Page_X_of_Y,
Pagination->RightPage,Pagination->NumPags);
Act_LinkFormSubmit (Gbl.Title,LinkStyle,NULL); Act_LinkFormSubmit (Gbl.Title,LinkStyle,NULL);
fprintf (Gbl.F.Out,"%u</a>",Pagination->RightPage); fprintf (Gbl.F.Out,"%u</a>",Pagination->RightPage);
Act_EndForm (); Act_EndForm ();
@ -726,8 +733,9 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted (); Usr_PutParamOtherUsrCodEncrypted ();
break; break;
} }
sprintf (Gbl.Title,Txt_Page_X_of_Y, snprintf (Gbl.Title,sizeof (Gbl.Title),
Pagination->NumPags,Pagination->NumPags); Txt_Page_X_of_Y,
Pagination->NumPags,Pagination->NumPags);
Act_LinkFormSubmit (Gbl.Title,LinkStyle,NULL); Act_LinkFormSubmit (Gbl.Title,LinkStyle,NULL);
fprintf (Gbl.F.Out,"%u</a>",Pagination->NumPags); fprintf (Gbl.F.Out,"%u</a>",Pagination->NumPags);
Act_EndForm (); Act_EndForm ();

View File

@ -178,10 +178,12 @@ static void Par_GetBoundary (void)
Lay_ShowErrorAndExit ("Delimiter string too long."); Lay_ShowErrorAndExit ("Delimiter string too long.");
/***** Create boundary strings *****/ /***** Create boundary strings *****/
sprintf (Gbl.Boundary.StrWithoutCRLF,"--%s", snprintf (Gbl.Boundary.StrWithoutCRLF,sizeof (Gbl.Boundary.StrWithoutCRLF),
PtrToBoundary); "--%s",
sprintf (Gbl.Boundary.StrWithCRLF,"%c%c%s", PtrToBoundary);
0x0D,0x0A,Gbl.Boundary.StrWithoutCRLF); snprintf (Gbl.Boundary.StrWithCRLF,sizeof (Gbl.Boundary.StrWithCRLF),
"%c%c%s",
0x0D,0x0A,Gbl.Boundary.StrWithoutCRLF);
/***** Compute lengths *****/ /***** Compute lengths *****/
Gbl.Boundary.LengthWithoutCRLF = strlen (Gbl.Boundary.StrWithoutCRLF); Gbl.Boundary.LengthWithoutCRLF = strlen (Gbl.Boundary.StrWithoutCRLF);
@ -794,15 +796,17 @@ void Par_GetMainParameters (void)
Gbl.Prefs.Theme = The_THEME_DEFAULT; Gbl.Prefs.Theme = The_THEME_DEFAULT;
/***** Set path of theme *****/ /***** Set path of theme *****/
sprintf (Path,"%s/%s/%s", snprintf (Path,sizeof (Path),
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_THEMES,The_ThemeId[Gbl.Prefs.Theme]); "%s/%s/%s",
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_THEMES,The_ThemeId[Gbl.Prefs.Theme]);
Str_Copy (Gbl.Prefs.PathTheme,Path, Str_Copy (Gbl.Prefs.PathTheme,Path,
PATH_MAX); PATH_MAX);
/***** Set path of icon set *****/ /***** Set path of icon set *****/
sprintf (Path,"%s/%s/%s", snprintf (Path,sizeof (Path),
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_ICON_SETS, "%s/%s/%s",
Ico_IconSetId[Gbl.Prefs.IconSet]); Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_ICON_SETS,
Ico_IconSetId[Gbl.Prefs.IconSet]);
Str_Copy (Gbl.Prefs.PathIconSet,Path, Str_Copy (Gbl.Prefs.PathIconSet,Path,
PATH_MAX); PATH_MAX);
} }

View File

@ -473,16 +473,17 @@ int Pwd_SendNewPasswordByEmail (char NewRandomPlainPassword[Pwd_MAX_BYTES_PLAIN_
fclose (Gbl.Msg.FileMail); fclose (Gbl.Msg.FileMail);
/***** Call the script to send an email *****/ /***** Call the script to send an email *****/
sprintf (Command,"%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"[%s] %s\" \"%s\"", snprintf (Command,sizeof (Command),
Cfg_COMMAND_SEND_AUTOMATIC_EMAIL, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"[%s] %s\" \"%s\"",
Cfg_AUTOMATIC_EMAIL_SMTP_SERVER, Cfg_COMMAND_SEND_AUTOMATIC_EMAIL,
Cfg_AUTOMATIC_EMAIL_SMTP_PORT, Cfg_AUTOMATIC_EMAIL_SMTP_SERVER,
Cfg_AUTOMATIC_EMAIL_FROM, Cfg_AUTOMATIC_EMAIL_SMTP_PORT,
Gbl.Config.SMTPPassword, Cfg_AUTOMATIC_EMAIL_FROM,
Gbl.Usrs.Me.UsrDat.Email, Gbl.Config.SMTPPassword,
Cfg_PLATFORM_SHORT_NAME, Gbl.Usrs.Me.UsrDat.Email,
Txt_New_password_NO_HTML[Gbl.Usrs.Me.UsrDat.Prefs.Language], Cfg_PLATFORM_SHORT_NAME,
Gbl.Msg.FileNameMail); Txt_New_password_NO_HTML[Gbl.Usrs.Me.UsrDat.Prefs.Language],
Gbl.Msg.FileNameMail);
ReturnCode = system (Command); ReturnCode = system (Command);
if (ReturnCode == -1) if (ReturnCode == -1)
Lay_ShowErrorAndExit ("Error when running script to send email."); Lay_ShowErrorAndExit ("Error when running script to send email.");
@ -690,7 +691,9 @@ void Pwd_ShowFormChgMyPwd (void)
Act_StartFormAnchor (ActChgPwd,Pwd_PASSWORD_SECTION_ID); Act_StartFormAnchor (ActChgPwd,Pwd_PASSWORD_SECTION_ID);
/***** Start box *****/ /***** Start box *****/
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH); snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
Box_StartBox (StrRecordWidth,Txt_Password,NULL, Box_StartBox (StrRecordWidth,Txt_Password,NULL,
Hlp_PROFILE_Password,Box_NOT_CLOSABLE); Hlp_PROFILE_Password,Box_NOT_CLOSABLE);

View File

@ -609,24 +609,28 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
Act_Action_t NextAction; Act_Action_t NextAction;
/***** Creates directories if not exist *****/ /***** Creates directories if not exist *****/
sprintf (PathPhotosPriv,"%s/%s", snprintf (PathPhotosPriv,sizeof (PathPhotosPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO); "%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO);
Fil_CreateDirIfNotExists (PathPhotosPriv); Fil_CreateDirIfNotExists (PathPhotosPriv);
sprintf (PathPhotosPriv,"%s/%s/%02u", snprintf (PathPhotosPriv,sizeof (PathPhotosPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO, "%s/%s/%02u",
(unsigned) (UsrDat->UsrCod % 100)); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,
(unsigned) (UsrDat->UsrCod % 100));
Fil_CreateDirIfNotExists (PathPhotosPriv); Fil_CreateDirIfNotExists (PathPhotosPriv);
/***** Create directories if not exists /***** Create directories if not exists
and remove old temporary files *****/ and remove old temporary files *****/
/* Create public directory for photos */ /* Create public directory for photos */
sprintf (PathPhotosPubl,"%s/%s", snprintf (PathPhotosPubl,sizeof (PathPhotosPubl),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO); "%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO);
Fil_CreateDirIfNotExists (PathPhotosPubl); Fil_CreateDirIfNotExists (PathPhotosPubl);
/* Create temporary directory for photos */ /* Create temporary directory for photos */
sprintf (PathPhotosPubl,"%s/%s/%s", snprintf (PathPhotosPubl,sizeof (PathPhotosPubl),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP); "%s/%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP);
Fil_CreateDirIfNotExists (PathPhotosPubl); Fil_CreateDirIfNotExists (PathPhotosPubl);
/* Remove old temporary files */ /* Remove old temporary files */
@ -653,9 +657,10 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
} }
/* End the reception of photo in a temporary file */ /* End the reception of photo in a temporary file */
sprintf (FileNamePhotoTmp,"%s/%s/%s/%s.jpg", snprintf (FileNamePhotoTmp,sizeof (FileNamePhotoTmp),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO, "%s/%s/%s/%s.jpg",
Cfg_FOLDER_PHOTO_TMP,Gbl.UniqueNameEncrypted); Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,
Cfg_FOLDER_PHOTO_TMP,Gbl.UniqueNameEncrypted);
if (!Fil_EndReceptionOfFile (FileNamePhotoTmp,Param)) if (!Fil_EndReceptionOfFile (FileNamePhotoTmp,Param))
{ {
Ale_ShowAlert (Ale_WARNING,"Error copying file."); Ale_ShowAlert (Ale_WARNING,"Error copying file.");
@ -664,13 +669,16 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
/* Copy the original photo received to private directory. /* Copy the original photo received to private directory.
The purpose of this copy is only to have a backup used for researching better methods to detect faces in images */ The purpose of this copy is only to have a backup used for researching better methods to detect faces in images */
sprintf (PathRelPhoto,"%s/%s/%02u/%ld_original.jpg", snprintf (PathRelPhoto,sizeof (PathRelPhoto),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO, "%s/%s/%02u/%ld_original.jpg",
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
Fil_FastCopyOfFiles (FileNamePhotoTmp,PathRelPhoto); Fil_FastCopyOfFiles (FileNamePhotoTmp,PathRelPhoto);
/***** Call to program that makes photo processing / face detection *****/ /***** Call to program that makes photo processing / face detection *****/
sprintf (Command,Cfg_COMMAND_FACE_DETECTION,FileNamePhotoTmp); snprintf (Command,sizeof (Command),
Cfg_COMMAND_FACE_DETECTION,
FileNamePhotoTmp);
ReturnCode = system (Command); ReturnCode = system (Command);
if (ReturnCode == -1) if (ReturnCode == -1)
Lay_ShowErrorAndExit ("Error when running command to process photo and detect faces."); Lay_ShowErrorAndExit ("Error when running command to process photo and detect faces.");
@ -681,9 +689,10 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
{ {
case 0: // Faces detected case 0: // Faces detected
/***** Open text file with text for image map *****/ /***** Open text file with text for image map *****/
sprintf (FileNameTxtMap,"%s/%s/%s/%s_map.txt", snprintf (FileNameTxtMap,sizeof (FileNameTxtMap),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO, "%s/%s/%s/%s_map.txt",
Cfg_FOLDER_PHOTO_TMP,Gbl.UniqueNameEncrypted); Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,
Cfg_FOLDER_PHOTO_TMP,Gbl.UniqueNameEncrypted);
if ((FileTxtMap = fopen (FileNameTxtMap,"rb")) == NULL) if ((FileTxtMap = fopen (FileNameTxtMap,"rb")) == NULL)
Lay_ShowErrorAndExit ("Can not read text file with coordinates of detected faces."); Lay_ShowErrorAndExit ("Can not read text file with coordinates of detected faces.");
@ -805,7 +814,9 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
if (BackgroundCode == 1) if (BackgroundCode == 1)
{ {
NumFace++; NumFace++;
sprintf (FormId,"form_%d",NumLastForm + NumFace); snprintf (FormId,sizeof (FormId),
"form_%d",
NumLastForm + NumFace);
fprintf (Gbl.F.Out,"<area shape=\"circle\"" fprintf (Gbl.F.Out,"<area shape=\"circle\""
" href=\"javascript:document.getElementById('%s').submit();\"" " href=\"javascript:document.getElementById('%s').submit();\""
" coords=\"%u,%u,%u\">\n", " coords=\"%u,%u,%u\">\n",
@ -818,8 +829,10 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
fprintf (Gbl.F.Out,"</map>\n"); fprintf (Gbl.F.Out,"</map>\n");
/***** Show map photo *****/ /***** Show map photo *****/
sprintf (FileNamePhotoMap,"%s/%s/%s/%s_map.jpg", snprintf (FileNamePhotoMap,sizeof (FileNamePhotoMap),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP,Gbl.UniqueNameEncrypted); "%s/%s/%s/%s_map.jpg",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP,
Gbl.UniqueNameEncrypted);
fprintf (Gbl.F.Out,"<div class=\"TIT CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<div class=\"TIT CENTER_MIDDLE\">"
"<img src=\"%s/%s/%s/%s_map.jpg\"" "<img src=\"%s/%s/%s/%s_map.jpg\""
" usemap=\"#faces_map\"" " usemap=\"#faces_map\""
@ -893,14 +906,16 @@ static void Pho_UpdatePhoto1 (struct UsrData *UsrDat)
Par_GetParToText ("FileName",Gbl.Usrs.FileNamePhoto,NAME_MAX); // Example of FileNamePhoto: "4924a838630e_016" Par_GetParToText ("FileName",Gbl.Usrs.FileNamePhoto,NAME_MAX); // Example of FileNamePhoto: "4924a838630e_016"
/***** Convert the temporary photo resulting of the processing to the current photo of the user *****/ /***** Convert the temporary photo resulting of the processing to the current photo of the user *****/
sprintf (PathPhotoTmp,"%s/%s/%s/%s_paso3.jpg", snprintf (PathPhotoTmp,sizeof (PathPhotoTmp),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP,Gbl.Usrs.FileNamePhoto); "%s/%s/%s/%s_paso3.jpg",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP,Gbl.Usrs.FileNamePhoto);
if (Fil_CheckIfPathExists (PathPhotoTmp)) // The file with the selected photo exists if (Fil_CheckIfPathExists (PathPhotoTmp)) // The file with the selected photo exists
{ {
/* Copy the temporary file of the third (last) step resulting of the processing to the directory of private photos */ /* Copy the temporary file of the third (last) step resulting of the processing to the directory of private photos */
sprintf (PathRelPhoto,"%s/%s/%02u/%ld.jpg", snprintf (PathRelPhoto,sizeof (PathRelPhoto),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO, "%s/%s/%02u/%ld.jpg",
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
Fil_FastCopyOfFiles (PathPhotoTmp,PathRelPhoto); Fil_FastCopyOfFiles (PathPhotoTmp,PathRelPhoto);
/* Update public photo name in database */ /* Update public photo name in database */
@ -1026,7 +1041,7 @@ void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod)
// Returns true if the photo can be shown and false if not. // Returns true if the photo can be shown and false if not.
// Public photo means two different things depending on the user's type // Public photo means two different things depending on the user's type
bool Pho_ShowingUsrPhotoIsAllowed (struct UsrData *UsrDat,char *PhotoURL) bool Pho_ShowingUsrPhotoIsAllowed (struct UsrData *UsrDat,char PhotoURL[PATH_MAX + 1])
{ {
bool ICanSeePhoto; bool ICanSeePhoto;
@ -1044,7 +1059,7 @@ bool Pho_ShowingUsrPhotoIsAllowed (struct UsrData *UsrDat,char *PhotoURL)
// Returns false if photo does not exist // Returns false if photo does not exist
// Returns true if link is created successfully // Returns true if link is created successfully
bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char *PhotoURL) bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX + 1])
{ {
char PathPublPhoto[PATH_MAX + 1]; char PathPublPhoto[PATH_MAX + 1];
char PathPrivPhoto[PATH_MAX + 1]; char PathPrivPhoto[PATH_MAX + 1];
@ -1052,13 +1067,15 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char *PhotoURL)
if (UsrDat->Photo[0]) if (UsrDat->Photo[0])
{ {
/***** Make path to public photo *****/ /***** Make path to public photo *****/
sprintf (PathPublPhoto,"%s/%s/%s.jpg", snprintf (PathPublPhoto,sizeof (PathPublPhoto),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,UsrDat->Photo); "%s/%s/%s.jpg",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,UsrDat->Photo);
/***** Make path to private photo from public directory *****/ /***** Make path to private photo from public directory *****/
sprintf (PathPrivPhoto,"%s/%s/%02u/%ld.jpg", snprintf (PathPrivPhoto,sizeof (PathPrivPhoto),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO, "%s/%s/%02u/%ld.jpg",
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
/***** Create a symbolic link to the private photo, if not exists *****/ /***** Create a symbolic link to the private photo, if not exists *****/
if (!Fil_CheckIfPathExists (PathPublPhoto)) if (!Fil_CheckIfPathExists (PathPublPhoto))
@ -1067,8 +1084,9 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char *PhotoURL)
" to access to user's private photo"); " to access to user's private photo");
/***** Create the public URL of the photo *****/ /***** Create the public URL of the photo *****/
sprintf (PhotoURL,"%s/%s/%s.jpg", snprintf (PhotoURL,PATH_MAX + 1,
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,UsrDat->Photo); "%s/%s/%s.jpg",
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,UsrDat->Photo);
return true; return true;
} }
@ -1085,12 +1103,13 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char *PhotoURL)
// Returns false if photo does not exist // Returns false if photo does not exist
// Returns true if photo exists // Returns true if photo exists
bool Pho_CheckIfPrivPhotoExists (long UsrCod,char *PathPrivRelPhoto) bool Pho_CheckIfPrivPhotoExists (long UsrCod,char PathPrivRelPhoto[PATH_MAX + 1])
{ {
/***** Make path to private photo *****/ /***** Make path to private photo *****/
sprintf (PathPrivRelPhoto,"%s/%s/%02u/%ld.jpg", snprintf (PathPrivRelPhoto,PATH_MAX + 1,
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO, "%s/%s/%02u/%ld.jpg",
(unsigned) (UsrCod % 100),UsrCod); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,
(unsigned) (UsrCod % 100),UsrCod);
return Fil_CheckIfPathExists (PathPrivRelPhoto); return Fil_CheckIfPathExists (PathPrivRelPhoto);
} }
@ -1113,16 +1132,18 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat)
Pho_ClearPhotoName (UsrDat->UsrCod); Pho_ClearPhotoName (UsrDat->UsrCod);
/***** Remove public link *****/ /***** Remove public link *****/
sprintf (PathPublPhoto,"%s/%s/%s.jpg", snprintf (PathPublPhoto,sizeof (PathPublPhoto),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,UsrDat->Photo); "%s/%s/%s.jpg",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,UsrDat->Photo);
if (Fil_CheckIfPathExists (PathPublPhoto)) // Public link exists if (Fil_CheckIfPathExists (PathPublPhoto)) // Public link exists
if (unlink (PathPublPhoto)) // Remove public link if (unlink (PathPublPhoto)) // Remove public link
NumErrors++; NumErrors++;
/***** Remove photo *****/ /***** Remove photo *****/
sprintf (PathPrivRelPhoto,"%s/%s/%02u/%ld.jpg", snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO, "%s/%s/%02u/%ld.jpg",
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Photo exists if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Photo exists
{ {
if (unlink (PathPrivRelPhoto)) // Remove photo if (unlink (PathPrivRelPhoto)) // Remove photo
@ -1130,9 +1151,10 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat)
} }
/***** Remove original photo *****/ /***** Remove original photo *****/
sprintf (PathPrivRelPhoto,"%s/%s/%02u/%ld_original.jpg", snprintf (PathPrivRelPhoto,sizeof (PathPrivRelPhoto),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO, "%s/%s/%02u/%ld_original.jpg",
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,
(unsigned) (UsrDat->UsrCod % 100),UsrDat->UsrCod);
if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Original photo exists if (Fil_CheckIfPathExists (PathPrivRelPhoto)) // Original photo exists
if (unlink (PathPrivRelPhoto)) // Remove original photo if (unlink (PathPrivRelPhoto)) // Remove original photo
NumErrors++; NumErrors++;
@ -1188,8 +1210,9 @@ void Pho_UpdatePhotoName (struct UsrData *UsrDat)
DB_QueryUPDATE (Query,"can not update the name of a user's photo"); DB_QueryUPDATE (Query,"can not update the name of a user's photo");
/***** Remove the old symbolic link to photo *****/ /***** Remove the old symbolic link to photo *****/
sprintf (PathPublPhoto,"%s/%s/%s.jpg", snprintf (PathPublPhoto,sizeof (PathPublPhoto),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,UsrDat->Photo); "%s/%s/%s.jpg",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,UsrDat->Photo);
unlink (PathPublPhoto); // Remove public link unlink (PathPublPhoto); // Remove public link
/***** Update photo name in user's data *****/ /***** Update photo name in user's data *****/
@ -1211,7 +1234,7 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
BrowserTabIs1stTab; // Only in main browser tab BrowserTabIs1stTab; // Only in main browser tab
bool PutZoomCode = (Zoom == Pho_ZOOM) && // Make zoom bool PutZoomCode = (Zoom == Pho_ZOOM) && // Make zoom
BrowserTabIs1stTab; // Only in main browser tab BrowserTabIs1stTab; // Only in main browser tab
char IdCaption[Act_MAX_BYTES_ID]; char IdCaption[Act_MAX_BYTES_ID + 1];
/***** Start form to go to public profile *****/ /***** Start form to go to public profile *****/
if (PutLinkToPublicProfile) if (PutLinkToPublicProfile)
@ -1341,21 +1364,25 @@ void Pho_CalcPhotoDegree (void)
Gbl.Stat.DegPhotos.TypeOfAverage = Pho_GetPhotoAvgTypeFromForm (); Gbl.Stat.DegPhotos.TypeOfAverage = Pho_GetPhotoAvgTypeFromForm ();
/***** Create public directories for average photos if not exist *****/ /***** Create public directories for average photos if not exist *****/
sprintf (PathPhotosPublic,"%s/%s", snprintf (PathPhotosPublic,sizeof (PathPhotosPublic),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO); "%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO);
Fil_CreateDirIfNotExists (PathPhotosPublic); Fil_CreateDirIfNotExists (PathPhotosPublic);
for (TypeOfAverage = (Pho_AvgPhotoTypeOfAverage_t) 0; for (TypeOfAverage = (Pho_AvgPhotoTypeOfAverage_t) 0;
TypeOfAverage < Pho_NUM_AVERAGE_PHOTO_TYPES; TypeOfAverage < Pho_NUM_AVERAGE_PHOTO_TYPES;
TypeOfAverage++) TypeOfAverage++)
{ {
sprintf (DirAvgPhotosRelPath[TypeOfAverage],"%s/%s/%s", snprintf (DirAvgPhotosRelPath[TypeOfAverage],
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Pho_StrAvgPhotoDirs[TypeOfAverage]); sizeof (DirAvgPhotosRelPath[TypeOfAverage]),
"%s/%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,Pho_StrAvgPhotoDirs[TypeOfAverage]);
Fil_CreateDirIfNotExists (DirAvgPhotosRelPath[TypeOfAverage]); Fil_CreateDirIfNotExists (DirAvgPhotosRelPath[TypeOfAverage]);
} }
/***** Creates private directory for lists of users' photos if not exists *****/ /***** Creates private directory for lists of users' photos if not exists *****/
sprintf (PathPhotosTmpPriv,"%s/%s/%s", snprintf (PathPhotosTmpPriv,sizeof (PathPhotosTmpPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP); "%s/%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP);
Fil_CreateDirIfNotExists (PathPhotosTmpPriv); Fil_CreateDirIfNotExists (PathPhotosTmpPriv);
/***** Remove old private files used for lists *****/ /***** Remove old private files used for lists *****/
@ -1602,16 +1629,18 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role,
*NumStds = *NumStdsWithPhoto = 0; *NumStds = *NumStdsWithPhoto = 0;
/***** Build name for file with average photo *****/ /***** Build name for file with average photo *****/
sprintf (PathRelAvgPhoto,"%s/%ld_%s.jpg", snprintf (PathRelAvgPhoto,sizeof (PathRelAvgPhoto),
DirAvgPhotosRelPath,DegCod,Usr_StringsSexDB[Sex]); "%s/%ld_%s.jpg",
DirAvgPhotosRelPath,DegCod,Usr_StringsSexDB[Sex]);
/***** Remove old file if exists *****/ /***** Remove old file if exists *****/
if (Fil_CheckIfPathExists (PathRelAvgPhoto)) // If file exists if (Fil_CheckIfPathExists (PathRelAvgPhoto)) // If file exists
unlink (PathRelAvgPhoto); unlink (PathRelAvgPhoto);
/***** Build names for text file with photo paths *****/ /***** Build names for text file with photo paths *****/
sprintf (FileNamePhotoNames,"%s/%s/%s/%ld.txt", snprintf (FileNamePhotoNames,sizeof (FileNamePhotoNames),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP,DegCod); "%s/%s/%s/%ld.txt",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_PHOTO,Cfg_FOLDER_PHOTO_TMP,DegCod);
if ((FilePhotoNames = fopen (FileNamePhotoNames,"wb")) == NULL) if ((FilePhotoNames = fopen (FileNamePhotoNames,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not open file to compute average photo."); Lay_ShowErrorAndExit ("Can not open file to compute average photo.");
@ -1639,9 +1668,10 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role,
/***** Call to program to calculate average photo *****/ /***** Call to program to calculate average photo *****/
if (*NumStdsWithPhoto) if (*NumStdsWithPhoto)
{ {
sprintf (StrCallToProgram,"%s %s %s", snprintf (StrCallToProgram,sizeof (StrCallToProgram),
Pho_StrAvgPhotoPrograms[TypeOfAverage], "%s %s %s",
FileNamePhotoNames,PathRelAvgPhoto); Pho_StrAvgPhotoPrograms[TypeOfAverage],
FileNamePhotoNames,PathRelAvgPhoto);
ReturnCode = system (StrCallToProgram); ReturnCode = system (StrCallToProgram);
if (ReturnCode == -1) if (ReturnCode == -1)
Lay_ShowErrorAndExit ("Error when running program that computes the average photo."); Lay_ShowErrorAndExit ("Error when running program that computes the average photo.");
@ -1969,8 +1999,6 @@ static void Pho_PutLinkToPrintViewOfDegreeStatsParams (void)
/*************** Put a link to calculate the stats of degrees ****************/ /*************** Put a link to calculate the stats of degrees ****************/
/*****************************************************************************/ /*****************************************************************************/
#define Pho_MAX_BYTES_ESTIMATED_TIME (128 - 1)
static void Pho_PutLinkToCalculateDegreeStats (void) static void Pho_PutLinkToCalculateDegreeStats (void)
{ {
extern const char *The_ClassFormBold[The_NUM_THEMES]; extern const char *The_ClassFormBold[The_NUM_THEMES];
@ -1982,7 +2010,7 @@ static void Pho_PutLinkToCalculateDegreeStats (void)
unsigned NumDeg; unsigned NumDeg;
struct Degree Deg; struct Degree Deg;
long EstimatedTimeToComputeAvgPhotoInMicroseconds; long EstimatedTimeToComputeAvgPhotoInMicroseconds;
char StrEstimatedTimeToComputeAvgPhoto[Pho_MAX_BYTES_ESTIMATED_TIME + 1]; char StrEstimatedTimeToComputeAvgPhoto[Dat_MAX_BYTES_TIME + 1];
if ((Deg.DegCod = Pho_GetDegWithAvgPhotoLeastRecentlyUpdated ()) > 0) if ((Deg.DegCod = Pho_GetDegWithAvgPhotoLeastRecentlyUpdated ()) > 0)
{ {
@ -2017,7 +2045,7 @@ static void Pho_PutLinkToCalculateDegreeStats (void)
EstimatedTimeToComputeAvgPhotoInMicroseconds = Pho_GetTimeToComputeAvgPhoto (Degs.Lst[NumDeg].DegCod); EstimatedTimeToComputeAvgPhotoInMicroseconds = Pho_GetTimeToComputeAvgPhoto (Degs.Lst[NumDeg].DegCod);
if (EstimatedTimeToComputeAvgPhotoInMicroseconds == -1L) if (EstimatedTimeToComputeAvgPhotoInMicroseconds == -1L)
Str_Copy (StrEstimatedTimeToComputeAvgPhoto,Txt_unknown_TIME, Str_Copy (StrEstimatedTimeToComputeAvgPhoto,Txt_unknown_TIME,
Pho_MAX_BYTES_ESTIMATED_TIME); Dat_MAX_BYTES_TIME);
else else
Sta_WriteTime (StrEstimatedTimeToComputeAvgPhoto, Sta_WriteTime (StrEstimatedTimeToComputeAvgPhoto,
EstimatedTimeToComputeAvgPhotoInMicroseconds); EstimatedTimeToComputeAvgPhotoInMicroseconds);
@ -2412,7 +2440,7 @@ static void Pho_ShowDegreeAvgPhotoAndStat (struct Degree *Deg,
char PhotoURL[PATH_MAX + 1]; char PhotoURL[PATH_MAX + 1];
char PhotoCaption[1024 + Hie_MAX_BYTES_SHRT_NAME]; char PhotoCaption[1024 + Hie_MAX_BYTES_SHRT_NAME];
bool ShowDegPhoto; bool ShowDegPhoto;
char IdCaption[Act_MAX_BYTES_ID]; char IdCaption[Act_MAX_BYTES_ID + 1];
/***** Initializations *****/ /***** Initializations *****/
PhotoURL[0] = '\0'; PhotoURL[0] = '\0';
@ -2427,7 +2455,9 @@ static void Pho_ShowDegreeAvgPhotoAndStat (struct Degree *Deg,
{ {
Act_StartFormGoTo (ActSeeDegInf); Act_StartFormGoTo (ActSeeDegInf);
Deg_PutParamDegCod (Deg->DegCod); Deg_PutParamDegCod (Deg->DegCod);
sprintf (Gbl.Title,Txt_Go_to_X,Deg->FullName); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Go_to_X,
Deg->FullName);
Act_LinkFormSubmit (Gbl.Title,NULL,NULL); Act_LinkFormSubmit (Gbl.Title,NULL,NULL);
} }
@ -2440,28 +2470,30 @@ static void Pho_ShowDegreeAvgPhotoAndStat (struct Degree *Deg,
if (ShowDegPhoto) if (ShowDegPhoto)
{ {
sprintf (PathRelAvgPhoto,"%s/%s/%s/%ld_%s.jpg", snprintf (PathRelAvgPhoto,sizeof (PathRelAvgPhoto),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO, "%s/%s/%s/%ld_%s.jpg",
Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage], Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,
Deg->DegCod,Usr_StringsSexDB[Sex]); Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage],
Deg->DegCod,Usr_StringsSexDB[Sex]);
if (Fil_CheckIfPathExists (PathRelAvgPhoto)) if (Fil_CheckIfPathExists (PathRelAvgPhoto))
{ {
sprintf (PhotoURL,"%s/%s/%s/%ld_%s.jpg", snprintf (PhotoURL,sizeof (PhotoURL),
Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PHOTO, "%s/%s/%s/%ld_%s.jpg",
Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage], Cfg_URL_SWAD_PUBLIC,Cfg_FOLDER_PHOTO,
Deg->DegCod,Usr_StringsSexDB[Sex]); Pho_StrAvgPhotoDirs[Gbl.Stat.DegPhotos.TypeOfAverage],
if (SeeOrPrint == Pho_DEGREES_SEE) Deg->DegCod,Usr_StringsSexDB[Sex]);
if (SeeOrPrint == Pho_DEGREES_SEE) if (SeeOrPrint == Pho_DEGREES_SEE)
{ {
/***** Hidden div to pass user's name to Javascript *****/ /***** Hidden div to pass user's name to Javascript *****/
sprintf (PhotoCaption,"%s<br />" snprintf (PhotoCaption,sizeof (PhotoCaption),
"%d&nbsp;%s&nbsp;(%s)<br />" "%s<br />"
"%d&nbsp;%s&nbsp;(%d%%)", "%d&nbsp;%s&nbsp;(%s)<br />"
Deg->ShrtName, "%d&nbsp;%s&nbsp;(%d%%)",
NumStds,Txt_students_ABBREVIATION,Txt_SEX_PLURAL_abc[Sex], Deg->ShrtName,
NumStdsWithPhoto,Txt_photos, NumStds,Txt_students_ABBREVIATION,Txt_SEX_PLURAL_abc[Sex],
NumStds > 0 ? (int) (((NumStdsWithPhoto * 100.0) / NumStds) + 0.5) : NumStdsWithPhoto,Txt_photos,
0); NumStds > 0 ? (int) (((NumStdsWithPhoto * 100.0) / NumStds) + 0.5) :
0);
Act_SetUniqueId (IdCaption); Act_SetUniqueId (IdCaption);
fprintf (Gbl.F.Out,"<div id=\"%s\" class=\"NOT_SHOWN\">" fprintf (Gbl.F.Out,"<div id=\"%s\" class=\"NOT_SHOWN\">"
"<div class=\"ZOOM_TXT_LINE DAT_N\">" "<div class=\"ZOOM_TXT_LINE DAT_N\">"

View File

@ -104,9 +104,9 @@ void Pho_UpdateUsrPhoto2 (void);
unsigned Pho_UpdateMyClicksWithoutPhoto (void); unsigned Pho_UpdateMyClicksWithoutPhoto (void);
void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod); void Pho_RemoveUsrFromTableClicksWithoutPhoto (long UsrCod);
bool Pho_ShowingUsrPhotoIsAllowed (struct UsrData *UsrDat,char *PhotoURL); bool Pho_ShowingUsrPhotoIsAllowed (struct UsrData *UsrDat,char PhotoURL[PATH_MAX + 1]);
bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char *PhotoURL); bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX + 1]);
bool Pho_CheckIfPrivPhotoExists (long UsrCod,char *PathPrivRelPhoto); bool Pho_CheckIfPrivPhotoExists (long UsrCod,char PathPrivRelPhoto[PATH_MAX + 1]);
bool Pho_RemovePhoto (struct UsrData *UsrDat); bool Pho_RemovePhoto (struct UsrData *UsrDat);
void Pho_UpdatePhotoName (struct UsrData *UsrDat); void Pho_UpdatePhotoName (struct UsrData *UsrDat);
void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL, void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,

View File

@ -114,7 +114,9 @@ void Plg_ListPlugins (void)
{ {
Plg = &(Gbl.Plugins.Lst[NumPlg]); Plg = &(Gbl.Plugins.Lst[NumPlg]);
sprintf (URL,"%s%s",Plg->URL,Gbl.Session.Id); snprintf (URL,sizeof (URL),
"%s%s",
Plg->URL,Gbl.Session.Id);
/* Plugin logo */ /* Plugin logo */
// TODO: Change plugin icons to 32x32 // TODO: Change plugin icons to 32x32

View File

@ -110,15 +110,17 @@ void Prf_SeeSocialProfiles (void)
/************************** Get public profile URL ***************************/ /************************** Get public profile URL ***************************/
/*****************************************************************************/ /*****************************************************************************/
char *Prf_GetURLPublicProfile (char *URL,const char *NicknameWithoutArroba) char *Prf_GetURLPublicProfile (char URL[Cns_MAX_BYTES_WWW + 1],
const char *NicknameWithoutArroba)
{ {
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES]; extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
/***** Build URL using nickname *****/ /***** Build URL using nickname *****/
sprintf (URL,"%s/%s?usr=@%s", snprintf (URL,Cns_MAX_BYTES_WWW + 1,
Cfg_URL_SWAD_CGI, "%s/%s?usr=@%s",
Txt_STR_LANG_ID[Gbl.Prefs.Language], Cfg_URL_SWAD_CGI,
NicknameWithoutArroba); Txt_STR_LANG_ID[Gbl.Prefs.Language],
NicknameWithoutArroba);
return URL; return URL;
} }
@ -379,7 +381,7 @@ void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat)
unsigned NumCrssUsrIsStudent; unsigned NumCrssUsrIsStudent;
unsigned NumFiles; unsigned NumFiles;
unsigned NumPublicFiles; unsigned NumPublicFiles;
char IdFirstClickTime[Act_MAX_BYTES_ID]; char IdFirstClickTime[Act_MAX_BYTES_ID + 1];
/***** Start left list *****/ /***** Start left list *****/
fprintf (Gbl.F.Out,"<div class=\"PRF_FIG_LEFT_CONTAINER\">" fprintf (Gbl.F.Out,"<div class=\"PRF_FIG_LEFT_CONTAINER\">"
@ -754,8 +756,9 @@ static void Prf_ShowRanking (unsigned long Rank,unsigned long NumUsrs)
extern const char *Txt_of_PART_OF_A_TOTAL; extern const char *Txt_of_PART_OF_A_TOTAL;
/***** Part of a total and end container *****/ /***** Part of a total and end container *****/
sprintf (Gbl.Title,"#%lu %s %lu", snprintf (Gbl.Title,sizeof (Gbl.Title),
Rank,Txt_of_PART_OF_A_TOTAL,NumUsrs); "#%lu %s %lu",
Rank,Txt_of_PART_OF_A_TOTAL,NumUsrs);
/***** Rank in form to go to ranking *****/ /***** Rank in form to go to ranking *****/
Act_StartForm (ActSeeUseGbl); Act_StartForm (ActSeeUseGbl);

View File

@ -51,7 +51,8 @@ struct UsrFigures
void Prf_SeeSocialProfiles (void); void Prf_SeeSocialProfiles (void);
char *Prf_GetURLPublicProfile (char *URL,const char *NicknameWithoutArroba); char *Prf_GetURLPublicProfile (char URL[Cns_MAX_BYTES_WWW + 1],
const char *NicknameWithoutArroba);
void Prf_PutLinkMyPublicProfile (void); void Prf_PutLinkMyPublicProfile (void);
void Prf_PutLinkRequestAnotherUserProfile (void); void Prf_PutLinkRequestAnotherUserProfile (void);
void Prf_RequestUserProfile (void); void Prf_RequestUserProfile (void);

View File

@ -1708,7 +1708,9 @@ static void Prj_ShowOneProjectMembersWithARole (const struct Project *Prj,
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
"<td class=\"CENTER_TOP\" style=\"width:30px;\">"); "<td class=\"CENTER_TOP\" style=\"width:30px;\">");
Gbl.Prjs.PrjCod = Prj->PrjCod; // Used to pass project code as a parameter Gbl.Prjs.PrjCod = Prj->PrjCod; // Used to pass project code as a parameter
sprintf (Gbl.Title,Txt_Add_USER,Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject]); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Add_USER,
Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject]);
Lay_PutContextualLink (ActionReqAddUsr[RoleInProject],NULL,Prj_PutCurrentParams, Lay_PutContextualLink (ActionReqAddUsr[RoleInProject],NULL,Prj_PutCurrentParams,
"plus64x64.png", "plus64x64.png",
Gbl.Title,NULL, Gbl.Title,NULL,
@ -1905,7 +1907,9 @@ static void Prj_ReqAnotherUsrID (Prj_RoleInProject_t RoleInProject)
Lay_ShowErrorAndExit ("Code of project is missing."); Lay_ShowErrorAndExit ("Code of project is missing.");
/***** Start box *****/ /***** Start box *****/
sprintf (Gbl.Title,Txt_Add_USER,Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject]); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Add_USER,
Txt_PROJECT_ROLES_SINGUL_abc[RoleInProject]);
Box_StartBox (NULL,Gbl.Title,NULL, Box_StartBox (NULL,Gbl.Title,NULL,
Hlp_ASSESSMENT_Projects_add_user,Box_NOT_CLOSABLE); Hlp_ASSESSMENT_Projects_add_user,Box_NOT_CLOSABLE);
@ -2794,9 +2798,10 @@ void Prj_RemoveProject (void)
Brw_RemovePrjFilesFromDB (Prj.PrjCod); Brw_RemovePrjFilesFromDB (Prj.PrjCod);
/***** Remove directory of the project *****/ /***** Remove directory of the project *****/
sprintf (PathRelPrj,"%s/%s/%ld/%s/%02u/%ld", snprintf (PathRelPrj,sizeof (PathRelPrj),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Prj.CrsCod,Cfg_FOLDER_PRJ, "%s/%s/%ld/%s/%02u/%ld",
(unsigned) (Prj.PrjCod % 100),Prj.PrjCod); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Prj.CrsCod,Cfg_FOLDER_PRJ,
(unsigned) (Prj.PrjCod % 100),Prj.PrjCod);
Fil_RemoveTree (PathRelPrj); Fil_RemoveTree (PathRelPrj);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/

View File

@ -666,8 +666,9 @@ void Rec_AskConfirmRemFieldWithRecords (unsigned NumRecords)
Ale_MAX_BYTES_ALERT); Ale_MAX_BYTES_ALERT);
else else
{ {
sprintf (Message_part2,Txt_this_field_is_filled_in_the_records_of_X_students, snprintf (Message_part2,sizeof (Message_part2),
NumRecords); Txt_this_field_is_filled_in_the_records_of_X_students,
NumRecords);
Str_Concat (Gbl.Alert.Txt,Message_part2, Str_Concat (Gbl.Alert.Txt,Message_part2,
Ale_MAX_BYTES_ALERT); Ale_MAX_BYTES_ALERT);
} }
@ -1071,7 +1072,9 @@ static void Rec_ListRecordsGsts (Rec_SharedRecordViewType_t TypeOfView)
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
{ {
/* Start container for this user */ /* Start container for this user */
sprintf (RecordSectionId,"record_%u",NumUsr); snprintf (RecordSectionId,sizeof (RecordSectionId),
"record_%u",
NumUsr);
Lay_StartSection (RecordSectionId); Lay_StartSection (RecordSectionId);
fprintf (Gbl.F.Out,"<div class=\"REC_USR\""); fprintf (Gbl.F.Out,"<div class=\"REC_USR\"");
if (Gbl.Action.Act == ActPrnRecSevGst && if (Gbl.Action.Act == ActPrnRecSevGst &&
@ -1276,7 +1279,9 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat); UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
/* Start container for this user */ /* Start container for this user */
sprintf (RecordSectionId,"record_%u",NumUsr); snprintf (RecordSectionId,sizeof (RecordSectionId),
"record_%u",
NumUsr);
Lay_StartSection (RecordSectionId); Lay_StartSection (RecordSectionId);
fprintf (Gbl.F.Out,"<div class=\"REC_USR\""); fprintf (Gbl.F.Out,"<div class=\"REC_USR\"");
if (Gbl.Action.Act == ActPrnRecSevStd && if (Gbl.Action.Act == ActPrnRecSevStd &&
@ -1355,7 +1360,9 @@ static void Rec_ShowRecordOneTchCrs (void)
bool ShowOfficeHours; bool ShowOfficeHours;
/***** Width for office hours *****/ /***** Width for office hours *****/
sprintf (Width,"%upx",Rec_RECORD_WIDTH); snprintf (Width,sizeof (Width),
"%upx",
Rec_RECORD_WIDTH);
/***** Get if teacher has accepted enrolment in current course *****/ /***** Get if teacher has accepted enrolment in current course *****/
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat); Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
@ -1434,7 +1441,9 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
char Width[10 + 2 + 1]; char Width[10 + 2 + 1];
/***** Width for office hours *****/ /***** Width for office hours *****/
sprintf (Width,"%upx",Rec_RECORD_WIDTH); snprintf (Width,sizeof (Width),
"%upx",
Rec_RECORD_WIDTH);
/***** Assign users listing type depending on current action *****/ /***** Assign users listing type depending on current action *****/
Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS; Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_TEACHERS;
@ -1496,7 +1505,9 @@ static void Rec_ListRecordsTchs (Rec_SharedRecordViewType_t TypeOfView)
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat); UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
/* Start container for this user */ /* Start container for this user */
sprintf (RecordSectionId,"record_%u",NumUsr); snprintf (RecordSectionId,sizeof (RecordSectionId),
"record_%u",
NumUsr);
Lay_StartSection (RecordSectionId); Lay_StartSection (RecordSectionId);
fprintf (Gbl.F.Out,"<div class=\"REC_USR\""); fprintf (Gbl.F.Out,"<div class=\"REC_USR\"");
if (Gbl.Action.Act == ActPrnRecSevTch && if (Gbl.Action.Act == ActPrnRecSevTch &&
@ -1806,7 +1817,9 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
} }
/***** Start box and table *****/ /***** Start box and table *****/
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH); snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
Box_StartBoxTable (StrRecordWidth,NULL,NULL, Box_StartBoxTable (StrRecordWidth,NULL,NULL,
Rec_RecordHelp[TypeOfView],Box_NOT_CLOSABLE,2); Rec_RecordHelp[TypeOfView],Box_NOT_CLOSABLE,2);
@ -1960,7 +1973,9 @@ void Rec_GetFieldsCrsRecordFromForm (void)
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility)) if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
{ {
/* Get text of the form */ /* Get text of the form */
sprintf (FieldParamName,"Field%ld",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod); snprintf (FieldParamName,sizeof (FieldParamName),
"Field%ld",
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
Par_GetParToHTML (FieldParamName,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text,Cns_MAX_BYTES_TEXT); Par_GetParToHTML (FieldParamName,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text,Cns_MAX_BYTES_TEXT);
} }
} }

View File

@ -155,7 +155,9 @@ void Rep_ReqMyUsageReport (void)
Act_StartForm (ActSeeMyUsgRep); Act_StartForm (ActSeeMyUsgRep);
/***** Start box *****/ /***** Start box *****/
sprintf (Gbl.Title,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Report_of_use_of_PLATFORM,
Cfg_PLATFORM_SHORT_NAME);
Box_StartBox (NULL,Gbl.Title,NULL, Box_StartBox (NULL,Gbl.Title,NULL,
Hlp_ANALYTICS_Report,Box_NOT_CLOSABLE); Hlp_ANALYTICS_Report,Box_NOT_CLOSABLE);
@ -260,7 +262,9 @@ static void Rep_PutLinkToMyUsageReport (struct Rep_Report *Report)
extern const char *Txt_This_link_will_remain_active_as_long_as_your_user_s_account_exists; extern const char *Txt_This_link_will_remain_active_as_long_as_your_user_s_account_exists;
/***** Start box *****/ /***** Start box *****/
sprintf (Gbl.Title,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Report_of_use_of_PLATFORM,
Cfg_PLATFORM_SHORT_NAME);
Box_StartBox (NULL,Gbl.Title,NULL, Box_StartBox (NULL,Gbl.Title,NULL,
Hlp_ANALYTICS_Report,Box_NOT_CLOSABLE); Hlp_ANALYTICS_Report,Box_NOT_CLOSABLE);
@ -333,14 +337,18 @@ static void Rep_GetCurrentDateTimeUTC (struct Rep_Report *Report)
if ((gmtime_r (&CurrentTime,&Report->tm_CurrentTime)) != NULL) if ((gmtime_r (&CurrentTime,&Report->tm_CurrentTime)) != NULL)
{ {
/* Date and time as strings */ /* Date and time as strings */
sprintf (Report->CurrentTimeUTC.StrDate,"%04d-%02d-%02d", snprintf (Report->CurrentTimeUTC.StrDate,
1900 + Report->tm_CurrentTime.tm_year, // year sizeof (Report->CurrentTimeUTC.StrDate),
1 + Report->tm_CurrentTime.tm_mon, // month "%04d-%02d-%02d",
Report->tm_CurrentTime.tm_mday); // day of the month 1900 + Report->tm_CurrentTime.tm_year, // year
sprintf (Report->CurrentTimeUTC.StrTime,"%02d:%02d:%02d", 1 + Report->tm_CurrentTime.tm_mon, // month
Report->tm_CurrentTime.tm_hour, // hours Report->tm_CurrentTime.tm_mday); // day of the month
Report->tm_CurrentTime.tm_min, // minutes snprintf (Report->CurrentTimeUTC.StrTime,
Report->tm_CurrentTime.tm_sec); // seconds sizeof (Report->CurrentTimeUTC.StrTime),
"%02d:%02d:%02d",
Report->tm_CurrentTime.tm_hour, // hours
Report->tm_CurrentTime.tm_min, // minutes
Report->tm_CurrentTime.tm_sec); // seconds
/* Date and time as unsigned */ /* Date and time as unsigned */
Report->CurrentTimeUTC.Date = (1900 + Report->tm_CurrentTime.tm_year) * 10000 + Report->CurrentTimeUTC.Date = (1900 + Report->tm_CurrentTime.tm_year) * 10000 +
@ -362,43 +370,54 @@ static void Rep_CreateNewReportFile (struct Rep_Report *Report)
char PathUniqueDirL[PATH_MAX + 1]; char PathUniqueDirL[PATH_MAX + 1];
char PathUniqueDirR[PATH_MAX + 1]; char PathUniqueDirR[PATH_MAX + 1];
char PathFileReport[PATH_MAX + 1]; char PathFileReport[PATH_MAX + 1];
char Permalink[128 +
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 +
NAME_MAX];
/***** Path for reports *****/ /***** Path for reports *****/
sprintf (PathReports,"%s/%s", snprintf (PathReports,sizeof (PathReports),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_REP); "%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_REP);
Fil_CreateDirIfNotExists (PathReports); Fil_CreateDirIfNotExists (PathReports);
/***** Unique directory for the file with the report *****/ /***** Unique directory for the file with the report *****/
/* 1. Create a directory using the leftmost 2 chars of a unique name */ /* 1. Create a directory using the leftmost 2 chars of a unique name */
sprintf (PathUniqueDirL,"%s/%s/%c%c", snprintf (PathUniqueDirL,sizeof (PathUniqueDirL),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_REP, "%s/%s/%c%c",
Gbl.UniqueNameEncrypted[0], Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_REP,
Gbl.UniqueNameEncrypted[1]); Gbl.UniqueNameEncrypted[0],
Gbl.UniqueNameEncrypted[1]);
Fil_CreateDirIfNotExists (PathUniqueDirL); Fil_CreateDirIfNotExists (PathUniqueDirL);
/* 2. Create a directory using the rightmost 41 chars of a unique name */ /* 2. Create a directory using the rightmost 41 chars of a unique name */
sprintf (PathUniqueDirR,"%s/%s", snprintf (PathUniqueDirR,sizeof (PathUniqueDirR),
PathUniqueDirL, "%s/%s",
&Gbl.UniqueNameEncrypted[2]); PathUniqueDirL,
&Gbl.UniqueNameEncrypted[2]);
if (mkdir (PathUniqueDirR,(mode_t) 0xFFF)) if (mkdir (PathUniqueDirR,(mode_t) 0xFFF))
Lay_ShowErrorAndExit ("Can not create directory for report."); Lay_ShowErrorAndExit ("Can not create directory for report.");
/***** Path of the public file with the report */ /***** Path of the public file with the report */
sprintf (Report->FilenameReport,"%s_%06u_%06u.html", snprintf (Report->FilenameReport,sizeof (Report->FilenameReport),
Rep_FILENAME_ROOT,Report->CurrentTimeUTC.Date,Report->CurrentTimeUTC.Time); "%s_%06u_%06u.html",
sprintf (PathFileReport,"%s/%s", Rep_FILENAME_ROOT,Report->CurrentTimeUTC.Date,Report->CurrentTimeUTC.Time);
PathUniqueDirR,Report->FilenameReport); snprintf (PathFileReport,sizeof (PathFileReport),
"%s/%s",
PathUniqueDirR,Report->FilenameReport);
if ((Gbl.F.Rep = fopen (PathFileReport,"wb")) == NULL) if ((Gbl.F.Rep = fopen (PathFileReport,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not create report file."); Lay_ShowErrorAndExit ("Can not create report file.");
/***** Permalink *****/ /***** Permalink *****/
sprintf (Report->Permalink,"%s/%s/%c%c/%s/%s", snprintf (Permalink,sizeof (Permalink),
Cfg_URL_SWAD_PUBLIC, "%s/%s/%c%c/%s/%s",
Cfg_FOLDER_REP, Cfg_URL_SWAD_PUBLIC,
Gbl.UniqueNameEncrypted[0], Cfg_FOLDER_REP,
Gbl.UniqueNameEncrypted[1], Gbl.UniqueNameEncrypted[0],
&Gbl.UniqueNameEncrypted[2], Gbl.UniqueNameEncrypted[1],
Report->FilenameReport); &Gbl.UniqueNameEncrypted[2],
Report->FilenameReport);
Str_Copy (Report->Permalink,Permalink,
Cns_MAX_BYTES_WWW);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -447,7 +466,9 @@ static void Rep_WriteHeader (const struct Rep_Report *Report)
fprintf (Gbl.F.Rep,"<header>"); fprintf (Gbl.F.Rep,"<header>");
/***** Main title *****/ /***** Main title *****/
sprintf (Gbl.Title,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Report_of_use_of_PLATFORM,
Cfg_PLATFORM_SHORT_NAME);
fprintf (Gbl.F.Rep,"<h1>%s</h1>" fprintf (Gbl.F.Rep,"<h1>%s</h1>"
"<ul>", "<ul>",
Gbl.Title); Gbl.Title);
@ -984,7 +1005,9 @@ static void Rep_GetAndWriteMyCurrentCrss (Rol_Role_t Role,
long CrsCod; long CrsCod;
NumCrss = Usr_GetNumCrssOfUsrWithARole (Gbl.Usrs.Me.UsrDat.UsrCod,Role); NumCrss = Usr_GetNumCrssOfUsrWithARole (Gbl.Usrs.Me.UsrDat.UsrCod,Role);
sprintf (Gbl.Title,Txt_USER_in_COURSE,Txt_ROLES_SINGUL_Abc[Role][Gbl.Usrs.Me.UsrDat.Sex]); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_USER_in_COURSE,
Txt_ROLES_SINGUL_Abc[Role][Gbl.Usrs.Me.UsrDat.Sex]);
fprintf (Gbl.F.Rep,"<li>%s %u %s", fprintf (Gbl.F.Rep,"<li>%s %u %s",
Gbl.Title, Gbl.Title,
NumCrss, NumCrss,
@ -1097,8 +1120,9 @@ static void Rep_GetAndWriteMyHistoricCrss (Rol_Role_t Role,
if ((NumCrss = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get courses of a user"))) if ((NumCrss = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get courses of a user")))
{ {
/* Heading row */ /* Heading row */
sprintf (Gbl.Title,Txt_Hits_as_a_USER, snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_ROLES_SINGUL_abc[Role][Gbl.Usrs.Me.UsrDat.Sex]); Txt_Hits_as_a_USER,
Txt_ROLES_SINGUL_abc[Role][Gbl.Usrs.Me.UsrDat.Sex]);
fprintf (Gbl.F.Rep,"<li>%s:" fprintf (Gbl.F.Rep,"<li>%s:"
"<ol>", "<ol>",
Gbl.Title); Gbl.Title);
@ -1397,8 +1421,9 @@ static void Rep_RemoveUsrReportsFiles (long UsrCod)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Remove report directory and file */ /* Remove report directory and file */
sprintf (PathUniqueDirReport,"%s/%s/%s/%s", snprintf (PathUniqueDirReport,sizeof (PathUniqueDirReport),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_REP,row[0],row[1]); "%s/%s/%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_REP,row[0],row[1]);
Fil_RemoveTree (PathUniqueDirReport); Fil_RemoveTree (PathUniqueDirReport);
} }

View File

@ -627,7 +627,9 @@ static unsigned Sch_SearchCountriesInDB (const char *RangeQuery)
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_COUNTRIES)) if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_COUNTRIES))
{ {
/***** Split countries string into words *****/ /***** Split countries string into words *****/
sprintf (FieldName,"Name_%s",Txt_STR_LANG_ID[Gbl.Prefs.Language]); snprintf (FieldName,sizeof (FieldName),
"Name_%s",
Txt_STR_LANG_ID[Gbl.Prefs.Language]);
if (Sch_BuildSearchQuery (SearchQuery,FieldName,NULL,NULL)) if (Sch_BuildSearchQuery (SearchQuery,FieldName,NULL,NULL))
{ {
/***** Query database and list institutions found *****/ /***** Query database and list institutions found *****/

View File

@ -183,10 +183,10 @@ static void Soc_PutTextarea (const char *Placeholder,
static long Soc_ReceiveSocialPost (void); static long Soc_ReceiveSocialPost (void);
static void Soc_PutIconToToggleCommentSocialNote (const char UniqueId[Act_MAX_BYTES_ID]); static void Soc_PutIconToToggleCommentSocialNote (const char UniqueId[Act_MAX_BYTES_ID + 1]);
static void Soc_PutIconCommentDisabled (void); static void Soc_PutIconCommentDisabled (void);
static void Soc_PutHiddenFormToWriteNewCommentToSocialNote (long NotCod, static void Soc_PutHiddenFormToWriteNewCommentToSocialNote (long NotCod,
const char IdNewComment[Act_MAX_BYTES_ID]); const char IdNewComment[Act_MAX_BYTES_ID + 1]);
static unsigned long Soc_GetNumCommentsInSocialNote (long NotCod); static unsigned long Soc_GetNumCommentsInSocialNote (long NotCod);
static void Soc_WriteCommentsInSocialNote (const struct SocialNote *SocNot); static void Soc_WriteCommentsInSocialNote (const struct SocialNote *SocNot);
static void Soc_WriteSocialComment (struct SocialComment *SocCom, static void Soc_WriteSocialComment (struct SocialComment *SocCom,
@ -396,7 +396,9 @@ static void Soc_ShowTimelineUsrHighlightingNot (long NotCod)
Query); Query);
/***** Show timeline *****/ /***** Show timeline *****/
sprintf (Gbl.Title,Txt_Timeline_OF_A_USER,Gbl.Usrs.Other.UsrDat.FirstName); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Timeline_OF_A_USER,
Gbl.Usrs.Other.UsrDat.FirstName);
Soc_ShowTimeline (Query,Gbl.Title,NotCod); Soc_ShowTimeline (Query,Gbl.Title,NotCod);
/***** Drop temporary tables *****/ /***** Drop temporary tables *****/
@ -1271,7 +1273,7 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot,
char ForumName[For_MAX_BYTES_FORUM_NAME + 1]; char ForumName[For_MAX_BYTES_FORUM_NAME + 1];
char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]; char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1];
unsigned NumComments; unsigned NumComments;
char IdNewComment[Act_MAX_BYTES_ID]; char IdNewComment[Act_MAX_BYTES_ID + 1];
/***** Start box ****/ /***** Start box ****/
if (ShowNoteAlone) if (ShowNoteAlone)
@ -1615,7 +1617,7 @@ static void Soc_WriteAuthorNote (const struct UsrData *UsrDat)
static void Soc_WriteDateTime (time_t TimeUTC) static void Soc_WriteDateTime (time_t TimeUTC)
{ {
extern const char *Txt_Today; extern const char *Txt_Today;
char IdDateTime[Act_MAX_BYTES_ID]; char IdDateTime[Act_MAX_BYTES_ID + 1];
/***** Create unique Id *****/ /***** Create unique Id *****/
Act_SetUniqueId (IdDateTime); Act_SetUniqueId (IdDateTime);
@ -1854,7 +1856,9 @@ static void Soc_PutFormGoToAction (const struct SocialNote *SocNot)
} }
/***** Link and end form *****/ /***** Link and end form *****/
sprintf (Class,"%s ICO_HIGHLIGHT",The_ClassFormBold[Gbl.Prefs.Theme]); snprintf (Class,sizeof (Class),
"%s ICO_HIGHLIGHT",
The_ClassFormBold[Gbl.Prefs.Theme]);
Act_LinkFormSubmitUnique (Txt_SOCIAL_NOTE[SocNot->NoteType],Class); Act_LinkFormSubmitUnique (Txt_SOCIAL_NOTE[SocNot->NoteType],Class);
fprintf (Gbl.F.Out,"<img src=\"%s/%s\"" fprintf (Gbl.F.Out,"<img src=\"%s/%s\""
" alt=\"%s\" title=\"%s\"" " alt=\"%s\" title=\"%s\""
@ -2196,7 +2200,7 @@ static void Soc_PutTextarea (const char *Placeholder,
const char *ClassTextArea,const char *ClassImgTit) const char *ClassTextArea,const char *ClassImgTit)
{ {
extern const char *Txt_Post; extern const char *Txt_Post;
char IdDivImgButton[Act_MAX_BYTES_ID]; char IdDivImgButton[Act_MAX_BYTES_ID + 1];
/***** Set unique id for the hidden div *****/ /***** Set unique id for the hidden div *****/
Act_SetUniqueId (IdDivImgButton); Act_SetUniqueId (IdDivImgButton);
@ -2345,7 +2349,7 @@ static long Soc_ReceiveSocialPost (void)
/****** Put an icon to toggle on/off the form to comment a social note *******/ /****** Put an icon to toggle on/off the form to comment a social note *******/
/*****************************************************************************/ /*****************************************************************************/
static void Soc_PutIconToToggleCommentSocialNote (const char UniqueId[Act_MAX_BYTES_ID]) static void Soc_PutIconToToggleCommentSocialNote (const char UniqueId[Act_MAX_BYTES_ID + 1])
{ {
extern const char *Txt_Comment; extern const char *Txt_Comment;
@ -2387,7 +2391,7 @@ static void Soc_PutIconCommentDisabled (void)
// All forms in this function and nested functions must have unique identifiers // All forms in this function and nested functions must have unique identifiers
static void Soc_PutHiddenFormToWriteNewCommentToSocialNote (long NotCod, static void Soc_PutHiddenFormToWriteNewCommentToSocialNote (long NotCod,
const char IdNewComment[Act_MAX_BYTES_ID]) const char IdNewComment[Act_MAX_BYTES_ID + 1])
{ {
extern const char *Txt_New_SOCIAL_comment; extern const char *Txt_New_SOCIAL_comment;
bool ShowPhoto = false; bool ShowPhoto = false;
@ -2713,7 +2717,9 @@ static void Soc_PutDisabledIconShare (unsigned NumShared)
extern const char *Txt_SOCIAL_NOTE_Not_shared_by_anyone; extern const char *Txt_SOCIAL_NOTE_Not_shared_by_anyone;
if (NumShared) if (NumShared)
sprintf (Gbl.Title,Txt_SOCIAL_NOTE_Shared_by_X_USERS,NumShared); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_SOCIAL_NOTE_Shared_by_X_USERS,
NumShared);
else else
Str_Copy (Gbl.Title,Txt_SOCIAL_NOTE_Not_shared_by_anyone, Str_Copy (Gbl.Title,Txt_SOCIAL_NOTE_Not_shared_by_anyone,
Lay_MAX_BYTES_TITLE); Lay_MAX_BYTES_TITLE);
@ -2738,7 +2744,9 @@ static void Soc_PutDisabledIconFav (unsigned NumFavs)
extern const char *Txt_SOCIAL_NOTE_Not_favourited_by_anyone; extern const char *Txt_SOCIAL_NOTE_Not_favourited_by_anyone;
if (NumFavs) if (NumFavs)
sprintf (Gbl.Title,Txt_SOCIAL_NOTE_Favourited_by_X_USERS,NumFavs); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_SOCIAL_NOTE_Favourited_by_X_USERS,
NumFavs);
else else
Str_Copy (Gbl.Title,Txt_SOCIAL_NOTE_Not_favourited_by_anyone, Str_Copy (Gbl.Title,Txt_SOCIAL_NOTE_Not_favourited_by_anyone,
Lay_MAX_BYTES_TITLE); Lay_MAX_BYTES_TITLE);

View File

@ -484,8 +484,9 @@ void Sta_AskShowCrsHits (void)
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs;
/***** Start box *****/ /***** Start box *****/
sprintf (Gbl.Title,Txt_Statistics_of_visits_to_the_course_X, snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.CurrentCrs.Crs.ShrtName); Txt_Statistics_of_visits_to_the_course_X,
Gbl.CurrentCrs.Crs.ShrtName);
Box_StartBox (NULL,Gbl.Title,NULL, Box_StartBox (NULL,Gbl.Title,NULL,
Hlp_ANALYTICS_Visits_visits_to_course,Box_NOT_CLOSABLE); Hlp_ANALYTICS_Visits_visits_to_course,Box_NOT_CLOSABLE);
@ -1694,8 +1695,9 @@ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\" style=\"width:20%%;\">"); fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\" style=\"width:20%%;\">");
if (FirstRow > 1) if (FirstRow > 1)
{ {
sprintf (Gbl.Title,Txt_Show_previous_X_clicks, snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.Stat.RowsPerPage); Txt_Show_previous_X_clicks,
Gbl.Stat.RowsPerPage);
Act_LinkFormSubmit (Gbl.Title,"TIT_TBL",NULL); Act_LinkFormSubmit (Gbl.Title,"TIT_TBL",NULL);
fprintf (Gbl.F.Out,"<strong>&lt;%s</strong></a>", fprintf (Gbl.F.Out,"<strong>&lt;%s</strong></a>",
Txt_PAGES_Previous); Txt_PAGES_Previous);
@ -1729,8 +1731,9 @@ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql
fprintf (Gbl.F.Out,"<td class=\"RIGHT_MIDDLE\" style=\"width:20%%;\">"); fprintf (Gbl.F.Out,"<td class=\"RIGHT_MIDDLE\" style=\"width:20%%;\">");
if (LastRow < NumRows) if (LastRow < NumRows)
{ {
sprintf (Gbl.Title,Txt_Show_next_X_clicks, snprintf (Gbl.Title,sizeof (Gbl.Title),
Gbl.Stat.RowsPerPage); Txt_Show_next_X_clicks,
Gbl.Stat.RowsPerPage);
Act_LinkFormSubmit (Gbl.Title,"TIT_TBL",NULL); Act_LinkFormSubmit (Gbl.Title,"TIT_TBL",NULL);
fprintf (Gbl.F.Out,"<strong>%s&gt;</strong>" fprintf (Gbl.F.Out,"<strong>%s&gt;</strong>"
"</a>", "</a>",
@ -3932,7 +3935,9 @@ static void Sta_ShowNumHitsPerCourse (unsigned long NumRows,
{ {
Act_StartFormGoTo (ActSeeCrsInf); Act_StartFormGoTo (ActSeeCrsInf);
Crs_PutParamCrsCod (Crs.CrsCod); Crs_PutParamCrsCod (Crs.CrsCod);
sprintf (Gbl.Title,Txt_Go_to_X,Crs.FullName); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Go_to_X,
Crs.FullName);
Act_LinkFormSubmit (Gbl.Title,"LOG",NULL); Act_LinkFormSubmit (Gbl.Title,"LOG",NULL);
fprintf (Gbl.F.Out,"%s" fprintf (Gbl.F.Out,"%s"
"</a>", "</a>",
@ -5749,15 +5754,19 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
} }
else else
{ {
sprintf (StrNumCrss,"%d",SizeOfFileZones.NumCrss); snprintf (StrNumCrss,sizeof (StrNumCrss),
sprintf (StrNumFoldersPerCrs,"%.1f", "%d",
SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.NumFolders / SizeOfFileZones.NumCrss);
(double) SizeOfFileZones.NumCrss : snprintf (StrNumFoldersPerCrs,sizeof (StrNumFoldersPerCrs),
0.0); "%.1f",
sprintf (StrNumFilesPerCrs,"%.1f", SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.NumFolders /
SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.NumFiles / (double) SizeOfFileZones.NumCrss :
(double) SizeOfFileZones.NumCrss : 0.0);
0.0); snprintf (StrNumFilesPerCrs,sizeof (StrNumFilesPerCrs),
"%.1f",
SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.NumFiles /
(double) SizeOfFileZones.NumCrss :
0.0);
Fil_WriteFileSizeFull (SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.Size / Fil_WriteFileSizeFull (SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.Size /
(double) SizeOfFileZones.NumCrss : (double) SizeOfFileZones.NumCrss :
0.0, 0.0,
@ -5768,7 +5777,9 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
Str_Copy (StrNumGrps,"-", Str_Copy (StrNumGrps,"-",
10); 10);
else else
sprintf (StrNumGrps,"%d",SizeOfFileZones.NumGrps); snprintf (StrNumGrps,sizeof (StrNumGrps),
"%d",
SizeOfFileZones.NumGrps);
if (SizeOfFileZones.NumUsrs == -1) if (SizeOfFileZones.NumUsrs == -1)
{ {
@ -5783,15 +5794,19 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
} }
else else
{ {
sprintf (StrNumUsrs,"%d",SizeOfFileZones.NumUsrs); snprintf (StrNumUsrs,sizeof (StrNumUsrs),
sprintf (StrNumFoldersPerUsr,"%.1f", "%d",
SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.NumFolders / SizeOfFileZones.NumUsrs);
(double) SizeOfFileZones.NumUsrs : snprintf (StrNumFoldersPerUsr,sizeof (StrNumFoldersPerUsr),
0.0); "%.1f",
sprintf (StrNumFilesPerUsr,"%.1f", SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.NumFolders /
SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.NumFiles / (double) SizeOfFileZones.NumUsrs :
(double) SizeOfFileZones.NumUsrs : 0.0);
0.0); snprintf (StrNumFilesPerUsr,sizeof (StrNumFilesPerUsr),
"%.1f",
SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.NumFiles /
(double) SizeOfFileZones.NumUsrs :
0.0);
Fil_WriteFileSizeFull (SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.Size / Fil_WriteFileSizeFull (SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.Size /
(double) SizeOfFileZones.NumUsrs : (double) SizeOfFileZones.NumUsrs :
0.0, 0.0,
@ -9919,8 +9934,8 @@ void Sta_WriteTimeToGenerateAndSendPage (void)
{ {
extern const char *Txt_PAGE1_Page_generated_in; extern const char *Txt_PAGE1_Page_generated_in;
extern const char *Txt_PAGE2_and_sent_in; extern const char *Txt_PAGE2_and_sent_in;
char StrTimeGenerationInMicroseconds[64]; char StrTimeGenerationInMicroseconds[Dat_MAX_BYTES_TIME + 1];
char StrTimeSendInMicroseconds[64]; char StrTimeSendInMicroseconds[Dat_MAX_BYTES_TIME + 1];
Sta_WriteTime (StrTimeGenerationInMicroseconds,Gbl.TimeGenerationInMicroseconds); Sta_WriteTime (StrTimeGenerationInMicroseconds,Gbl.TimeGenerationInMicroseconds);
Sta_WriteTime (StrTimeSendInMicroseconds,Gbl.TimeSendInMicroseconds); Sta_WriteTime (StrTimeSendInMicroseconds,Gbl.TimeSendInMicroseconds);
@ -9933,16 +9948,23 @@ void Sta_WriteTimeToGenerateAndSendPage (void)
/********* Write time (given in microseconds) depending on amount ************/ /********* Write time (given in microseconds) depending on amount ************/
/*****************************************************************************/ /*****************************************************************************/
void Sta_WriteTime (char *Str,long TimeInMicroseconds) void Sta_WriteTime (char Str[Dat_MAX_BYTES_TIME],long TimeInMicroseconds)
{ {
if (TimeInMicroseconds < 1000L) if (TimeInMicroseconds < 1000L)
sprintf (Str,"%ld &micro;s",TimeInMicroseconds); snprintf (Str,Dat_MAX_BYTES_TIME + 1,
"%ld &micro;s",
TimeInMicroseconds);
else if (TimeInMicroseconds < 1000000L) else if (TimeInMicroseconds < 1000000L)
sprintf (Str,"%ld ms",TimeInMicroseconds / 1000); snprintf (Str,Dat_MAX_BYTES_TIME + 1,
"%ld ms",
TimeInMicroseconds / 1000);
else if (TimeInMicroseconds < (60 * 1000000L)) else if (TimeInMicroseconds < (60 * 1000000L))
sprintf (Str,"%.1f s",(float) TimeInMicroseconds / 1E6); snprintf (Str,Dat_MAX_BYTES_TIME + 1,
"%.1f s",
(float) TimeInMicroseconds / 1E6);
else else
sprintf (Str,"%ld min, %ld s", snprintf (Str,Dat_MAX_BYTES_TIME + 1,
TimeInMicroseconds / (60 * 1000000L), "%ld min, %ld s",
(TimeInMicroseconds / 1000000L) % 60); TimeInMicroseconds / (60 * 1000000L),
(TimeInMicroseconds / 1000000L) % 60);
} }

View File

@ -189,6 +189,6 @@ void Sta_WriteParamsDatesSeeAccesses (void);
void Sta_ComputeTimeToGeneratePage (void); void Sta_ComputeTimeToGeneratePage (void);
void Sta_ComputeTimeToSendPage (void); void Sta_ComputeTimeToSendPage (void);
void Sta_WriteTimeToGenerateAndSendPage (void); void Sta_WriteTimeToGenerateAndSendPage (void);
void Sta_WriteTime (char *Str,long TimeInMicroseconds); void Sta_WriteTime (char Str[Dat_MAX_BYTES_TIME],long TimeInMicroseconds);
#endif #endif

View File

@ -300,21 +300,25 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
/* Create id for this form */ /* Create id for this form */
Gbl.Form.Num++; Gbl.Form.Num++;
if (Gbl.Usrs.Me.Logged) if (Gbl.Usrs.Me.Logged)
sprintf (Gbl.Form.UniqueId,"form_%s_%d", snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),
Gbl.UniqueNameEncrypted,Gbl.Form.Num); "form_%s_%d",
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
else else
sprintf (Gbl.Form.Id,"form_%d",Gbl.Form.Num); snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),
"form_%d",
Gbl.Form.Num);
/* Store first part of anchor */ /* Store first part of anchor */
Act_SetParamsForm (ParamsStr,ActSeeOthPubPrf,true); Act_SetParamsForm (ParamsStr,ActSeeOthPubPrf,true);
sprintf (Anchor1Nick,"<form method=\"post\" action=\"%s/%s\" id=\"%s\">" snprintf (Anchor1Nick,sizeof (Anchor1Nick),
"%s" "<form method=\"post\" action=\"%s/%s\" id=\"%s\">"
"<input type=\"hidden\" name=\"usr\" value=\"", "%s"
Cfg_URL_SWAD_CGI, "<input type=\"hidden\" name=\"usr\" value=\"",
Txt_STR_LANG_ID[Gbl.Prefs.Language], Cfg_URL_SWAD_CGI,
Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId : Txt_STR_LANG_ID[Gbl.Prefs.Language],
Gbl.Form.Id, Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId :
ParamsStr); Gbl.Form.Id,
ParamsStr);
Anchor1NickLength = strlen (Anchor1Nick); Anchor1NickLength = strlen (Anchor1Nick);
if ((Links[NumLinks].Anchor1Nick = (char *) malloc (Anchor1NickLength + 1)) == NULL) if ((Links[NumLinks].Anchor1Nick = (char *) malloc (Anchor1NickLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to insert link."); Lay_ShowErrorAndExit ("Not enough memory to insert link.");
@ -322,12 +326,13 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
Links[NumLinks].Anchor1NickLength = Anchor1NickLength; Links[NumLinks].Anchor1NickLength = Anchor1NickLength;
/* Store second part of anchor */ /* Store second part of anchor */
sprintf (Anchor2Nick,"\">" snprintf (Anchor2Nick,sizeof (Anchor2Nick),
"<a href=\"\"" "\">"
" onclick=\"document.getElementById('%s').submit();" "<a href=\"\""
"return false;\">", " onclick=\"document.getElementById('%s').submit();"
Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId : "return false;\">",
Gbl.Form.Id); Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId :
Gbl.Form.Id);
Anchor2NickLength = strlen (Anchor2Nick); Anchor2NickLength = strlen (Anchor2Nick);
if ((Links[NumLinks].Anchor2Nick = (char *) malloc (Anchor2NickLength + 1)) == NULL) if ((Links[NumLinks].Anchor2Nick = (char *) malloc (Anchor2NickLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to insert link."); Lay_ShowErrorAndExit ("Not enough memory to insert link.");
@ -1236,7 +1241,8 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
StrSpecialChar[2] = '\0'; // End of string StrSpecialChar[2] = '\0'; // End of string
} }
else else
sprintf (StrSpecialChar,"&#34;"); // Double comilla is stored as HTML code to avoid problems when displaying it Str_Copy (StrSpecialChar,"&#34;", // Double comilla is stored as HTML code to avoid problems when displaying it
Str_MAX_BYTES_SPECIAL_CHAR);
NumPrintableCharsFromReturn++; NumPrintableCharsFromReturn++;
ThereIsSpaceChar = false; ThereIsSpaceChar = false;
break; break;
@ -1260,7 +1266,8 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
StrSpecialChar[2] = '\0'; // End of string StrSpecialChar[2] = '\0'; // End of string
} }
else else
sprintf (StrSpecialChar,"&#39;"); // Single comilla is stored as HTML entity to avoid problem when querying database (SQL code injection) Str_Copy (StrSpecialChar,"&#39;", // Single comilla is stored as HTML entity to avoid problem when querying database (SQL code injection)
Str_MAX_BYTES_SPECIAL_CHAR);
NumPrintableCharsFromReturn++; NumPrintableCharsFromReturn++;
ThereIsSpaceChar = false; ThereIsSpaceChar = false;
break; break;
@ -1422,11 +1429,11 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
ThereIsSpaceChar = false; ThereIsSpaceChar = false;
break; break;
default: /* The rest of special chars are stored as special code */ default: /* The rest of special chars are stored as special code */
sprintf (StrSpecialChar, snprintf (StrSpecialChar,sizeof (StrSpecialChar),
(ChangeTo == Str_TO_TEXT || (ChangeTo == Str_TO_TEXT ||
ChangeTo == Str_TO_MARKDOWN) ? "%c" : ChangeTo == Str_TO_MARKDOWN) ? "%c" :
"&#%u;", "&#%u;",
SpecialChar); SpecialChar);
NumPrintableCharsFromReturn++; NumPrintableCharsFromReturn++;
ThereIsSpaceChar = false; ThereIsSpaceChar = false;
break; break;
@ -2874,6 +2881,7 @@ void Str_CreateRandomAlphanumStr (char *Str,size_t Length)
/*****************************************************************************/ /*****************************************************************************/
/****************************** Safe string copy *****************************/ /****************************** Safe string copy *****************************/
/*****************************************************************************/ /*****************************************************************************/
// DstSize does not include ending byte '\0'
void Str_Copy (char *Dst,const char *Src,size_t DstSize) void Str_Copy (char *Dst,const char *Src,size_t DstSize)
{ {
@ -2895,6 +2903,7 @@ void Str_Copy (char *Dst,const char *Src,size_t DstSize)
/*****************************************************************************/ /*****************************************************************************/
/************************** Safe string concatenation ************************/ /************************** Safe string concatenation ************************/
/*****************************************************************************/ /*****************************************************************************/
// DstSize does not include ending byte '\0'
void Str_Concat (char *Dst,const char *Src,size_t DstSize) void Str_Concat (char *Dst,const char *Src,size_t DstSize)
{ {

View File

@ -2698,8 +2698,9 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,
Gbl.Svys.SvyCodToEdit = SvyCod; Gbl.Svys.SvyCodToEdit = SvyCod;
Gbl.Svys.SvyQstCodToEdit = SvyQst->QstCod; Gbl.Svys.SvyQstCodToEdit = SvyQst->QstCod;
sprintf (Gbl.Title,"%s %u", snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Question,SvyQst->QstInd + 1); // Question index may be 0, 1, 2, 3,... "%s %u",
Txt_Question,SvyQst->QstInd + 1); // Question index may be 0, 1, 2, 3,...
Box_StartBox (NULL,Gbl.Title,Svy_PutIconToRemoveOneQst, Box_StartBox (NULL,Gbl.Title,Svy_PutIconToRemoveOneQst,
NULL,Box_NOT_CLOSABLE); NULL,Box_NOT_CLOSABLE);
} }
@ -3006,7 +3007,9 @@ void Svy_ReceiveQst (void)
{ {
if (!Svy_AllocateTextChoiceAnswer (&SvyQst,NumAns)) if (!Svy_AllocateTextChoiceAnswer (&SvyQst,NumAns))
Lay_ShowErrorAndExit (Gbl.Alert.Txt); Lay_ShowErrorAndExit (Gbl.Alert.Txt);
sprintf (AnsStr,"AnsStr%u",NumAns); snprintf (AnsStr,sizeof (AnsStr),
"AnsStr%u",
NumAns);
Par_GetParToHTML (AnsStr,SvyQst.AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER); Par_GetParToHTML (AnsStr,SvyQst.AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER);
} }
@ -3515,13 +3518,15 @@ static void Svy_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
/***** String with the number of users *****/ /***** String with the number of users *****/
if (MaxUsrs) if (MaxUsrs)
sprintf (Gbl.Title,"%u&nbsp;(%u%%&nbsp;%s&nbsp;%u)", snprintf (Gbl.Title,sizeof (Gbl.Title),
NumUsrs, "%u&nbsp;(%u%%&nbsp;%s&nbsp;%u)",
(unsigned) ((((float) NumUsrs * 100.0) / (float) MaxUsrs) + 0.5), NumUsrs,
Txt_of_PART_OF_A_TOTAL,MaxUsrs); (unsigned) ((((float) NumUsrs * 100.0) / (float) MaxUsrs) + 0.5),
Txt_of_PART_OF_A_TOTAL,MaxUsrs);
else else
sprintf (Gbl.Title,"0&nbsp;(0%%&nbsp;%s&nbsp;%u)", snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_of_PART_OF_A_TOTAL,MaxUsrs); "0&nbsp;(0%%&nbsp;%s&nbsp;%u)",
Txt_of_PART_OF_A_TOTAL,MaxUsrs);
/***** Draw bar with a with proportional to the number of clicks *****/ /***** Draw bar with a with proportional to the number of clicks *****/
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_TOP\" style=\"width:%upx;\">", fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_TOP\" style=\"width:%upx;\">",
@ -3732,7 +3737,9 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod)
Lay_ShowErrorAndExit ("Error: wrong question code."); Lay_ShowErrorAndExit ("Error: wrong question code.");
/* Get possible parameter with the user's answer */ /* Get possible parameter with the user's answer */
sprintf (ParamName,"Ans%010u",(unsigned) QstCod); snprintf (ParamName,sizeof (ParamName),
"Ans%010u",
(unsigned) QstCod);
// Lay_ShowAlert (Lay_INFO,ParamName); // Lay_ShowAlert (Lay_INFO,ParamName);
Par_GetParMultiToText (ParamName,StrAnswersIndexes, Par_GetParMultiToText (ParamName,StrAnswersIndexes,
Svy_MAX_ANSWERS_PER_QUESTION * (10 + 1)); Svy_MAX_ANSWERS_PER_QUESTION * (10 + 1));

View File

@ -351,10 +351,11 @@ void Syl_LoadListItemsSyllabusIntoMemory (long CrsCod)
unsigned NumItemsWithChildren = 0; unsigned NumItemsWithChildren = 0;
/* Path of the private directory for the XML file with the syllabus */ /* Path of the private directory for the XML file with the syllabus */
sprintf (Gbl.Syllabus.PathDir,"%s/%s/%ld/%s", snprintf (Gbl.Syllabus.PathDir,sizeof (Gbl.Syllabus.PathDir),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod, "%s/%s/%ld/%s",
Gbl.Syllabus.WhichSyllabus == Syl_LECTURES ? Cfg_SYLLABUS_FOLDER_LECTURES : Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod,
Cfg_SYLLABUS_FOLDER_PRACTICALS); Gbl.Syllabus.WhichSyllabus == Syl_LECTURES ? Cfg_SYLLABUS_FOLDER_LECTURES :
Cfg_SYLLABUS_FOLDER_PRACTICALS);
/***** Open the file with the syllabus *****/ /***** Open the file with the syllabus *****/
Syl_OpenSyllabusFile (Gbl.Syllabus.PathDir,PathFile); Syl_OpenSyllabusFile (Gbl.Syllabus.PathDir,PathFile);
@ -622,10 +623,10 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
fprintf (Gbl.F.Out,"<td class=\"BM%u\">",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"<td class=\"BM%u\">",Gbl.RowEvenOdd);
if (Subtree.MovAllowed) if (Subtree.MovAllowed)
{ {
sprintf (Gbl.Title, snprintf (Gbl.Title,sizeof (Gbl.Title),
LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_up_X_and_its_subsections : LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_up_X_and_its_subsections :
Txt_Move_up_X, Txt_Move_up_X,
StrItemCod); StrItemCod);
Lay_PutContextualLink (Gbl.CurrentCrs.Info.Type == Inf_LECTURES ? ActUp_IteSylLec : Lay_PutContextualLink (Gbl.CurrentCrs.Info.Type == Inf_LECTURES ? ActUp_IteSylLec :
ActUp_IteSylPra, ActUp_IteSylPra,
NULL,Syl_PutParamNumItem, NULL,Syl_PutParamNumItem,
@ -642,10 +643,10 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
fprintf (Gbl.F.Out,"<td class=\"BM%u\">",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"<td class=\"BM%u\">",Gbl.RowEvenOdd);
if (Subtree.MovAllowed) if (Subtree.MovAllowed)
{ {
sprintf (Gbl.Title, snprintf (Gbl.Title,sizeof (Gbl.Title),
LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_down_X_and_its_subsections : LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_down_X_and_its_subsections :
Txt_Move_down_X, Txt_Move_down_X,
StrItemCod); StrItemCod);
Lay_PutContextualLink (Gbl.CurrentCrs.Info.Type == Inf_LECTURES ? ActDwnIteSylLec : Lay_PutContextualLink (Gbl.CurrentCrs.Info.Type == Inf_LECTURES ? ActDwnIteSylLec :
ActDwnIteSylPra, ActDwnIteSylPra,
NULL,Syl_PutParamNumItem, NULL,Syl_PutParamNumItem,
@ -661,7 +662,9 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
fprintf (Gbl.F.Out,"<td class=\"BM%u\">",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"<td class=\"BM%u\">",Gbl.RowEvenOdd);
if (Level > 1) if (Level > 1)
{ {
sprintf (Gbl.Title,Txt_Increase_level_of_X,StrItemCod); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Increase_level_of_X,
StrItemCod);
Lay_PutContextualLink (Gbl.CurrentCrs.Info.Type == Inf_LECTURES ? ActRgtIteSylLec : Lay_PutContextualLink (Gbl.CurrentCrs.Info.Type == Inf_LECTURES ? ActRgtIteSylLec :
ActRgtIteSylPra, ActRgtIteSylPra,
NULL,Syl_PutParamNumItem, NULL,Syl_PutParamNumItem,
@ -678,7 +681,9 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
if (Level < LastLevel + 1 && if (Level < LastLevel + 1 &&
Level < Syl_MAX_LEVELS_SYLLABUS) Level < Syl_MAX_LEVELS_SYLLABUS)
{ {
sprintf (Gbl.Title,Txt_Decrease_level_of_X,StrItemCod); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Decrease_level_of_X,
StrItemCod);
Lay_PutContextualLink (Gbl.CurrentCrs.Info.Type == Inf_LECTURES ? ActLftIteSylLec : Lay_PutContextualLink (Gbl.CurrentCrs.Info.Type == Inf_LECTURES ? ActLftIteSylLec :
ActLftIteSylPra, ActLftIteSylPra,
NULL,Syl_PutParamNumItem, NULL,Syl_PutParamNumItem,
@ -749,8 +754,9 @@ int Syl_WriteSyllabusIntoHTMLBuffer (char **HTMLBuffer)
if (LstItemsSyllabus.NumItems) if (LstItemsSyllabus.NumItems)
{ {
/***** Create a unique name for the file *****/ /***** Create a unique name for the file *****/
sprintf (FileNameHTMLTmp,"%s/%s/%s_syllabus.html", snprintf (FileNameHTMLTmp,sizeof (FileNameHTMLTmp),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted); "%s/%s/%s_syllabus.html",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT,Gbl.UniqueNameEncrypted);
/***** Create a new temporary file for writing and reading *****/ /***** Create a new temporary file for writing and reading *****/
if ((FileHTMLTmp = fopen (FileNameHTMLTmp,"w+b")) == NULL) if ((FileHTMLTmp = fopen (FileNameHTMLTmp,"w+b")) == NULL)
@ -958,7 +964,9 @@ static void Syl_WriteNumItem (char *StrDst,FILE *FileTgt,int Level,int *CodItem)
if (FileTgt) if (FileTgt)
fprintf (FileTgt,"."); fprintf (FileTgt,".");
} }
sprintf (InStr,"%d",CodItem[N]); snprintf (InStr,sizeof (InStr),
"%d",
CodItem[N]);
if (StrDst) if (StrDst)
Str_Concat (StrDst,InStr, Str_Concat (StrDst,InStr,
Syl_MAX_BYTES_ITEM_COD); Syl_MAX_BYTES_ITEM_COD);
@ -1406,7 +1414,9 @@ void Syl_BuildPathFileSyllabus (char *PathFile)
{ {
char Path[PATH_MAX + 1 + NAME_MAX + 1]; char Path[PATH_MAX + 1 + NAME_MAX + 1];
sprintf (Path,"%s/%s",Gbl.Syllabus.PathDir,Cfg_SYLLABUS_FILENAME); snprintf (Path,sizeof (Path),
"%s/%s",
Gbl.Syllabus.PathDir,Cfg_SYLLABUS_FILENAME);
Str_Copy (PathFile,Path, Str_Copy (PathFile,Path,
PATH_MAX); PATH_MAX);
} }

View File

@ -613,17 +613,23 @@ static void Tst_GetQuestionsAndAnswersFromForm (void)
NumQst++) NumQst++)
{ {
/* Get question code */ /* Get question code */
sprintf (StrQstIndOrAns,"Qst%06u",NumQst); snprintf (StrQstIndOrAns,sizeof (StrQstIndOrAns),
"Qst%06u",
NumQst);
if ((Gbl.Test.QstCodes[NumQst] = Par_GetParToLong (StrQstIndOrAns)) <= 0) if ((Gbl.Test.QstCodes[NumQst] = Par_GetParToLong (StrQstIndOrAns)) <= 0)
Lay_ShowErrorAndExit ("Code of question is missing."); Lay_ShowErrorAndExit ("Code of question is missing.");
/* Get indexes for this question */ /* Get indexes for this question */
sprintf (StrQstIndOrAns,"Ind%06u",NumQst); snprintf (StrQstIndOrAns,sizeof (StrQstIndOrAns),
"Ind%06u",
NumQst);
Par_GetParMultiToText (StrQstIndOrAns,Gbl.Test.StrIndexesOneQst[NumQst], Par_GetParMultiToText (StrQstIndOrAns,Gbl.Test.StrIndexesOneQst[NumQst],
Tst_MAX_BYTES_INDEXES_ONE_QST); /* If choice ==> "0", "1", "2",... */ Tst_MAX_BYTES_INDEXES_ONE_QST); /* If choice ==> "0", "1", "2",... */
/* Get answers selected by user for this question */ /* Get answers selected by user for this question */
sprintf (StrQstIndOrAns,"Ans%06u",NumQst); snprintf (StrQstIndOrAns,sizeof (StrQstIndOrAns),
"Ans%06u",
NumQst);
Par_GetParMultiToText (StrQstIndOrAns,Gbl.Test.StrAnswersOneQst[NumQst], Par_GetParMultiToText (StrQstIndOrAns,Gbl.Test.StrAnswersOneQst[NumQst],
Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */ Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */
} }
@ -1881,7 +1887,9 @@ static void Tst_PutIconEnable (long TagCod,const char *TagTxt)
fprintf (Gbl.F.Out,"<td class=\"BM\">"); fprintf (Gbl.F.Out,"<td class=\"BM\">");
Act_StartForm (ActEnableTag); Act_StartForm (ActEnableTag);
Par_PutHiddenParamLong ("TagCod",TagCod); Par_PutHiddenParamLong ("TagCod",TagCod);
sprintf (Gbl.Title,Txt_Tag_X_not_allowed_Click_to_allow_it,TagTxt); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Tag_X_not_allowed_Click_to_allow_it,
TagTxt);
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/eye-slash-on64x64.png\"" fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/eye-slash-on64x64.png\""
" alt=\"%s\" title=\"%s\"" " alt=\"%s\" title=\"%s\""
" class=\"ICO20x20\" />", " class=\"ICO20x20\" />",
@ -1903,7 +1911,9 @@ static void Tst_PutIconDisable (long TagCod,const char *TagTxt)
fprintf (Gbl.F.Out,"<td class=\"BM\">"); fprintf (Gbl.F.Out,"<td class=\"BM\">");
Act_StartForm (ActDisableTag); Act_StartForm (ActDisableTag);
Par_PutHiddenParamLong ("TagCod",TagCod); Par_PutHiddenParamLong ("TagCod",TagCod);
sprintf (Gbl.Title,Txt_Tag_X_allowed_Click_to_disable_it,TagTxt); snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Tag_X_allowed_Click_to_disable_it,
TagTxt);
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/eye-on64x64.png\"" fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/eye-on64x64.png\""
" alt=\"%s\" title=\"%s\"" " alt=\"%s\" title=\"%s\""
" class=\"ICO20x20\" />", " class=\"ICO20x20\" />",
@ -2526,17 +2536,23 @@ static unsigned long Tst_GetQuestions (MYSQL_RES **mysql_res)
Str_Concat (Query," WHERE tst_questions.CrsCod='", Str_Concat (Query," WHERE tst_questions.CrsCod='",
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
sprintf (CrsCodStr,"%ld",Gbl.CurrentCrs.Crs.CrsCod); snprintf (CrsCodStr,sizeof (CrsCodStr),
"%ld",
Gbl.CurrentCrs.Crs.CrsCod);
Str_Concat (Query,CrsCodStr, Str_Concat (Query,CrsCodStr,
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"' AND tst_questions.EditTime>=FROM_UNIXTIME('", Str_Concat (Query,"' AND tst_questions.EditTime>=FROM_UNIXTIME('",
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
sprintf (LongStr,"%ld",(long) Gbl.DateRange.TimeUTC[0]); snprintf (LongStr,sizeof (LongStr),
"%ld",
(long) Gbl.DateRange.TimeUTC[0]);
Str_Concat (Query,LongStr, Str_Concat (Query,LongStr,
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"') AND tst_questions.EditTime<=FROM_UNIXTIME('", Str_Concat (Query,"') AND tst_questions.EditTime<=FROM_UNIXTIME('",
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
sprintf (LongStr,"%ld",(long) Gbl.DateRange.TimeUTC[1]); snprintf (LongStr,sizeof (LongStr),
"%ld",
(long) Gbl.DateRange.TimeUTC[1]);
Str_Concat (Query,LongStr, Str_Concat (Query,LongStr,
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
Str_Concat (Query,"')", Str_Concat (Query,"')",
@ -2759,7 +2775,9 @@ static unsigned long Tst_GetQuestionsForTest (MYSQL_RES **mysql_res)
/* End query */ /* End query */
Str_Concat (Query," ORDER BY RAND(NOW()) LIMIT ", Str_Concat (Query," ORDER BY RAND(NOW()) LIMIT ",
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
sprintf (StrNumQsts,"%u",Gbl.Test.NumQsts); snprintf (StrNumQsts,sizeof (StrNumQsts),
"%u",
Gbl.Test.NumQsts);
Str_Concat (Query,StrNumQsts, Str_Concat (Query,StrNumQsts,
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
/* /*
@ -3768,7 +3786,9 @@ static void Tst_WriteChoiceAnsViewTest (unsigned NumQst,long QstCod,bool Shuffle
/***** Write selectors and letter of this option *****/ /***** Write selectors and letter of this option *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
"<td class=\"LEFT_TOP\">"); "<td class=\"LEFT_TOP\">");
sprintf (ParamName,"Ind%06u",NumQst); snprintf (ParamName,sizeof (ParamName),
"Ind%06u",
NumQst);
Par_PutHiddenParamUnsigned (ParamName,Index); Par_PutHiddenParamUnsigned (ParamName,Index);
fprintf (Gbl.F.Out,"<input type=\""); fprintf (Gbl.F.Out,"<input type=\"");
if (Gbl.Test.AnswerType == Tst_ANS_UNIQUE_CHOICE) if (Gbl.Test.AnswerType == Tst_ANS_UNIQUE_CHOICE)
@ -4637,7 +4657,9 @@ static void Tst_WriteParamQstCod (unsigned NumQst,long QstCod)
{ {
char ParamName[3 + 6 + 1]; char ParamName[3 + 6 + 1];
sprintf (ParamName,"Qst%06u",NumQst); snprintf (ParamName,sizeof (ParamName),
"Qst%06u",
NumQst);
Par_PutHiddenParamLong (ParamName,QstCod); Par_PutHiddenParamLong (ParamName,QstCod);
} }
@ -4752,7 +4774,9 @@ static bool Tst_GetParamsTst (Tst_ActionToDoWithQuestions_t ActionToDoWithQuesti
case Tst_SELECT_QUESTIONS_FOR_GAME: case Tst_SELECT_QUESTIONS_FOR_GAME:
/* The unique allowed type of answer in a game is unique choice */ /* The unique allowed type of answer in a game is unique choice */
Gbl.Test.AllAnsTypes = false; Gbl.Test.AllAnsTypes = false;
sprintf (Gbl.Test.ListAnsTypes,"%u",(unsigned) Tst_ANS_UNIQUE_CHOICE); snprintf (Gbl.Test.ListAnsTypes,sizeof (Gbl.Test.ListAnsTypes),
"%u",
(unsigned) Tst_ANS_UNIQUE_CHOICE);
break; break;
default: default:
break; break;
@ -4950,7 +4974,6 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
extern const char *Txt_Contract; extern const char *Txt_Contract;
extern const char *Txt_Save; extern const char *Txt_Save;
extern const char *Txt_Create_question; extern const char *Txt_Create_question;
char Title[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRows; unsigned long NumRows;
@ -4966,8 +4989,10 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
/***** Start box *****/ /***** Start box *****/
if (Gbl.Test.QstCod > 0) // The question already has assigned a code if (Gbl.Test.QstCod > 0) // The question already has assigned a code
{ {
sprintf (Title,Txt_Question_code_X,Gbl.Test.QstCod); snprintf (Gbl.Title,sizeof (Gbl.Title),
Box_StartBox (NULL,Title,Tst_PutIconToRemoveOneQst, Txt_Question_code_X,
Gbl.Test.QstCod);
Box_StartBox (NULL,Gbl.Title,Tst_PutIconToRemoveOneQst,
Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE);
} }
else else
@ -5231,7 +5256,9 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
'a' + (char) NumOpt); 'a' + (char) NumOpt);
/* Icon to expand (show the answer) */ /* Icon to expand (show the answer) */
sprintf (Gbl.Title,"%s %c)",Txt_Expand,'a' + (char) NumOpt); snprintf (Gbl.Title,sizeof (Gbl.Title),
"%s %c)",
Txt_Expand,'a' + (char) NumOpt);
fprintf (Gbl.F.Out,"<a href=\"\" id=\"exp_%u\"",NumOpt); fprintf (Gbl.F.Out,"<a href=\"\" id=\"exp_%u\"",NumOpt);
if (DisplayRightColumn) // Answer does not have content if (DisplayRightColumn) // Answer does not have content
fprintf (Gbl.F.Out," style=\"display:none;\""); // Hide icon fprintf (Gbl.F.Out," style=\"display:none;\""); // Hide icon
@ -5243,7 +5270,9 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
Gbl.Title,Gbl.Title); Gbl.Title,Gbl.Title);
/* Icon to contract (hide the answer) */ /* Icon to contract (hide the answer) */
sprintf (Gbl.Title,"%s %c)",Txt_Contract,'a' + (char) NumOpt); snprintf (Gbl.Title,sizeof (Gbl.Title),
"%s %c)",
Txt_Contract,'a' + (char) NumOpt);
fprintf (Gbl.F.Out,"<a href=\"\" id=\"con_%u\"",NumOpt); fprintf (Gbl.F.Out,"<a href=\"\" id=\"con_%u\"",NumOpt);
if (!DisplayRightColumn) // Answer does not have content if (!DisplayRightColumn) // Answer does not have content
fprintf (Gbl.F.Out," style=\"display:none;\""); // Hide icon fprintf (Gbl.F.Out," style=\"display:none;\""); // Hide icon
@ -5792,7 +5821,9 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
NumTag < Tst_MAX_TAGS_PER_QUESTION; NumTag < Tst_MAX_TAGS_PER_QUESTION;
NumTag++) NumTag++)
{ {
sprintf (TagStr,"TagTxt%u",NumTag); snprintf (TagStr,sizeof (TagStr),
"TagTxt%u",
NumTag);
Par_GetParToText (TagStr,Gbl.Test.Tags.Txt[NumTag],Tst_MAX_BYTES_TAG); Par_GetParToText (TagStr,Gbl.Test.Tags.Txt[NumTag],Tst_MAX_BYTES_TAG);
if (Gbl.Test.Tags.Txt[NumTag][0]) if (Gbl.Test.Tags.Txt[NumTag][0])
@ -5865,7 +5896,9 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
Lay_ShowErrorAndExit (Gbl.Alert.Txt); Lay_ShowErrorAndExit (Gbl.Alert.Txt);
/* Get answer */ /* Get answer */
sprintf (AnsStr,"AnsStr%u",NumOpt); snprintf (AnsStr,sizeof (AnsStr),
"AnsStr%u",
NumOpt);
Par_GetParToHTML (AnsStr,Gbl.Test.Answer.Options[NumOpt].Text, Par_GetParToHTML (AnsStr,Gbl.Test.Answer.Options[NumOpt].Text,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
if (Gbl.Test.AnswerType == Tst_ANS_TEXT) if (Gbl.Test.AnswerType == Tst_ANS_TEXT)
@ -5874,7 +5907,9 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
Str_ReplaceSeveralSpacesForOne (Gbl.Test.Answer.Options[NumOpt].Text); Str_ReplaceSeveralSpacesForOne (Gbl.Test.Answer.Options[NumOpt].Text);
/* Get feedback */ /* Get feedback */
sprintf (FbStr,"FbStr%u",NumOpt); snprintf (FbStr,sizeof (FbStr),
"FbStr%u",
NumOpt);
Par_GetParToHTML (FbStr,Gbl.Test.Answer.Options[NumOpt].Feedback, Par_GetParToHTML (FbStr,Gbl.Test.Answer.Options[NumOpt].Feedback,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);

View File

@ -180,9 +180,10 @@ void TsI_CreateXML (unsigned long NumRows,MYSQL_RES *mysql_res)
Brw_CreateDirDownloadTmp (); Brw_CreateDirDownloadTmp ();
/***** Create public XML file with the questions *****/ /***** Create public XML file with the questions *****/
sprintf (PathPubFile,"%s/%s/%s/test.xml", snprintf (PathPubFile,sizeof (PathPubFile),
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_FILE_BROWSER_TMP, "%s/%s/%s/test.xml",
Gbl.FileBrowser.TmpPubDir); Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_FILE_BROWSER_TMP,
Gbl.FileBrowser.TmpPubDir);
if ((Gbl.Test.XML.FileXML = fopen (PathPubFile,"wb")) == NULL) if ((Gbl.Test.XML.FileXML = fopen (PathPubFile,"wb")) == NULL)
Lay_ShowErrorAndExit ("Can not open target file."); Lay_ShowErrorAndExit ("Can not open target file.");
@ -406,7 +407,9 @@ void TsI_ImportQstsFromXML (void)
bool WrongType = false; bool WrongType = false;
/***** Creates directory if not exists *****/ /***** Creates directory if not exists *****/
sprintf (PathTestPriv,"%s/%s",Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_TEST); snprintf (PathTestPriv,sizeof (PathTestPriv),
"%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_TEST);
Fil_CreateDirIfNotExists (PathTestPriv); Fil_CreateDirIfNotExists (PathTestPriv);
/***** Remove old files *****/ /***** Remove old files *****/
@ -434,7 +437,9 @@ void TsI_ImportQstsFromXML (void)
else else
{ {
/* End the reception of XML in a temporary file */ /* End the reception of XML in a temporary file */
sprintf (FileNameXMLTmp,"%s/%s.xml",PathTestPriv,Gbl.UniqueNameEncrypted); snprintf (FileNameXMLTmp,sizeof (FileNameXMLTmp),
"%s/%s.xml",
PathTestPriv,Gbl.UniqueNameEncrypted);
if (Fil_EndReceptionOfFile (FileNameXMLTmp,Param)) if (Fil_EndReceptionOfFile (FileNameXMLTmp,Param))
/***** 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);

View File

@ -283,10 +283,11 @@ void The_ChangeTheme (void)
/***** Get param theme *****/ /***** Get param theme *****/
Gbl.Prefs.Theme = The_GetParamTheme (); Gbl.Prefs.Theme = The_GetParamTheme ();
sprintf (Path,"%s/%s/%s", snprintf (Path,sizeof (Path),
Gbl.Prefs.IconsURL, "%s/%s/%s",
Cfg_ICON_FOLDER_THEMES, Gbl.Prefs.IconsURL,
The_ThemeId[Gbl.Prefs.Theme]); Cfg_ICON_FOLDER_THEMES,
The_ThemeId[Gbl.Prefs.Theme]);
Str_Copy (Gbl.Prefs.PathTheme,Path, Str_Copy (Gbl.Prefs.PathTheme,Path,
PATH_MAX); PATH_MAX);

View File

@ -261,8 +261,9 @@ void Usr_InformAboutNumClicksBeforePhoto (void)
Ale_ShowAlert (Ale_WARNING,Txt_You_must_send_your_photo_because_); Ale_ShowAlert (Ale_WARNING,Txt_You_must_send_your_photo_because_);
else if (Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB) else if (Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB)
{ {
sprintf (Message,Txt_You_can_only_perform_X_further_actions_, snprintf (Message,sizeof (Message),
Pho_MAX_CLICKS_WITHOUT_PHOTO - Gbl.Usrs.Me.NumAccWithoutPhoto); Txt_You_can_only_perform_X_further_actions_,
Pho_MAX_CLICKS_WITHOUT_PHOTO - Gbl.Usrs.Me.NumAccWithoutPhoto);
Ale_ShowAlertAndButton (Ale_WARNING,Message, Ale_ShowAlertAndButton (Ale_WARNING,Message,
ActReqMyPho,NULL,NULL,NULL, ActReqMyPho,NULL,NULL,NULL,
Btn_CONFIRM_BUTTON,Txt_Upload_photo); Btn_CONFIRM_BUTTON,Txt_Upload_photo);
@ -2520,10 +2521,11 @@ void Usr_CreateBirthdayStrDB (const struct UsrData *UsrDat,
Str_Copy (BirthdayStrDB,"NULL", // Without apostrophes Str_Copy (BirthdayStrDB,"NULL", // Without apostrophes
Usr_BIRTHDAY_STR_DB_LENGTH); Usr_BIRTHDAY_STR_DB_LENGTH);
else else
sprintf (BirthdayStrDB,"'%04u-%02u-%02u'", // With apostrophes snprintf (BirthdayStrDB,Usr_BIRTHDAY_STR_DB_LENGTH + 1,
UsrDat->Birthday.Year, "'%04u-%02u-%02u'", // With apostrophes
UsrDat->Birthday.Month, UsrDat->Birthday.Year,
UsrDat->Birthday.Day); UsrDat->Birthday.Month,
UsrDat->Birthday.Day);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -3216,16 +3218,18 @@ static void Usr_SetMyPrefsAndRoles (void)
Gbl.Prefs.SideCols = Gbl.Usrs.Me.UsrDat.Prefs.SideCols; Gbl.Prefs.SideCols = Gbl.Usrs.Me.UsrDat.Prefs.SideCols;
Gbl.Prefs.Theme = Gbl.Usrs.Me.UsrDat.Prefs.Theme; Gbl.Prefs.Theme = Gbl.Usrs.Me.UsrDat.Prefs.Theme;
sprintf (Path,"%s/%s/%s", snprintf (Path,sizeof (Path),
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_THEMES, "%s/%s/%s",
The_ThemeId[Gbl.Prefs.Theme]); Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_THEMES,
The_ThemeId[Gbl.Prefs.Theme]);
Str_Copy (Gbl.Prefs.PathTheme,Path, Str_Copy (Gbl.Prefs.PathTheme,Path,
PATH_MAX); PATH_MAX);
Gbl.Prefs.IconSet = Gbl.Usrs.Me.UsrDat.Prefs.IconSet; Gbl.Prefs.IconSet = Gbl.Usrs.Me.UsrDat.Prefs.IconSet;
sprintf (Path,"%s/%s/%s", snprintf (Path,sizeof (Path),
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_ICON_SETS, "%s/%s/%s",
Ico_IconSetId[Gbl.Prefs.IconSet]); Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_ICON_SETS,
Ico_IconSetId[Gbl.Prefs.IconSet]);
Str_Copy (Gbl.Prefs.PathIconSet,Path, Str_Copy (Gbl.Prefs.PathIconSet,Path,
PATH_MAX); PATH_MAX);
@ -3422,7 +3426,9 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat,
Str_Copy (BgColor,"LIGHT_GREEN", Str_Copy (BgColor,"LIGHT_GREEN",
Usr_MAX_BYTES_BG_COLOR); Usr_MAX_BYTES_BG_COLOR);
else else
sprintf (BgColor,"COLOR%u",Gbl.RowEvenOdd); snprintf (BgColor,sizeof (BgColor),
"COLOR%u",
Gbl.RowEvenOdd);
if (PutCheckBoxToSelectUsr) if (PutCheckBoxToSelectUsr)
{ {
@ -3874,7 +3880,9 @@ static void Usr_WriteEmail (struct UsrData *UsrDat,const char *BgColor)
{ {
ShowEmail = Mai_ICanSeeOtherUsrEmail (UsrDat); ShowEmail = Mai_ICanSeeOtherUsrEmail (UsrDat);
if (ShowEmail) if (ShowEmail)
sprintf (MailLink,"mailto:%s",UsrDat->Email); snprintf (MailLink,sizeof (MailLink),
"mailto:%s",
UsrDat->Email);
} }
else else
ShowEmail = false; ShowEmail = false;
@ -4317,7 +4325,9 @@ static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,
Str_Concat (Query,NumPositiveCods ? " OR GrpCod='" : Str_Concat (Query,NumPositiveCods ? " OR GrpCod='" :
" GrpCod='", " GrpCod='",
Usr_MAX_BYTES_QUERY_GET_LIST_USRS); Usr_MAX_BYTES_QUERY_GET_LIST_USRS);
sprintf (LongStr,"%ld",GrpCod); snprintf (LongStr,sizeof (LongStr),
"%ld",
GrpCod);
Str_Concat (Query,LongStr, Str_Concat (Query,LongStr,
Usr_MAX_BYTES_QUERY_GET_LIST_USRS); Usr_MAX_BYTES_QUERY_GET_LIST_USRS);
Str_Concat (Query,"'", Str_Concat (Query,"'",
@ -4347,7 +4357,9 @@ static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,
" FROM crs_grp,crs_grp_usr" " FROM crs_grp,crs_grp_usr"
" WHERE crs_grp.GrpTypCod='", " WHERE crs_grp.GrpTypCod='",
Usr_MAX_BYTES_QUERY_GET_LIST_USRS); Usr_MAX_BYTES_QUERY_GET_LIST_USRS);
sprintf (LongStr,"%ld",Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); snprintf (LongStr,sizeof (LongStr),
"%ld",
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod);
Str_Concat (Query,LongStr, Str_Concat (Query,LongStr,
Usr_MAX_BYTES_QUERY_GET_LIST_USRS); Usr_MAX_BYTES_QUERY_GET_LIST_USRS);
Str_Concat (Query,"' AND crs_grp.GrpCod=crs_grp_usr.GrpCod)", Str_Concat (Query,"' AND crs_grp.GrpCod=crs_grp_usr.GrpCod)",
@ -6825,12 +6837,13 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role,
/***** Start box and table *****/ /***** Start box and table *****/
/* Number of users found */ /* Number of users found */
Sex = Usr_GetSexOfUsrsLst (Role); Sex = Usr_GetSexOfUsrsLst (Role);
sprintf (Gbl.Title,"%u %s", snprintf (Gbl.Title,sizeof (Gbl.Title),
NumUsrs, "%u %s",
(Role == Rol_UNK) ? ((NumUsrs == 1) ? Txt_user[Sex] : NumUsrs,
Txt_users[Sex]) : (Role == Rol_UNK) ? ((NumUsrs == 1) ? Txt_user[Sex] :
((NumUsrs == 1) ? Txt_ROLES_SINGUL_abc[Role][Sex] : Txt_users[Sex]) :
Txt_ROLES_PLURAL_abc[Role][Sex])); ((NumUsrs == 1) ? Txt_ROLES_SINGUL_abc[Role][Sex] :
Txt_ROLES_PLURAL_abc[Role][Sex]));
Box_StartBoxTable (NULL,Gbl.Title,NULL, Box_StartBoxTable (NULL,Gbl.Title,NULL,
NULL,Box_NOT_CLOSABLE,2); NULL,Box_NOT_CLOSABLE,2);
@ -8356,21 +8369,27 @@ void Usr_PutSelectorNumColsClassPhoto (void)
/********** Build the relative path of a user from his user's code ***********/ /********** Build the relative path of a user from his user's code ***********/
/*****************************************************************************/ /*****************************************************************************/
void Usr_ConstructPathUsr (long UsrCod,char *PathUsr) void Usr_ConstructPathUsr (long UsrCod,char PathUsr[PATH_MAX + 1])
{ {
char PathUsrs[PATH_MAX + 1]; char PathUsrs[PATH_MAX + 1];
char PathAboveUsr[PATH_MAX + 1]; char PathAboveUsr[PATH_MAX + 1];
/***** Path for users *****/ /***** Path for users *****/
sprintf (PathUsrs,"%s/%s",Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_USR); snprintf (PathUsrs,sizeof (PathUsrs),
"%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_USR);
Fil_CreateDirIfNotExists (PathUsrs); Fil_CreateDirIfNotExists (PathUsrs);
/***** Path above user's ID *****/ /***** Path above user's ID *****/
sprintf (PathAboveUsr,"%s/%02u",PathUsrs,(unsigned) (UsrCod % 100)); snprintf (PathAboveUsr,sizeof (PathAboveUsr),
"%s/%02u",
PathUsrs,(unsigned) (UsrCod % 100));
Fil_CreateDirIfNotExists (PathAboveUsr); Fil_CreateDirIfNotExists (PathAboveUsr);
/***** Path for user *****/ /***** Path for user *****/
sprintf (PathUsr,"%s/%ld",PathAboveUsr,UsrCod); snprintf (PathUsr,PATH_MAX + 1,
"%s/%ld",
PathAboveUsr,UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -8503,7 +8522,9 @@ unsigned Usr_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,unsigned Roles)
Role++) Role++)
if (Roles & (1 << Role)) if (Roles & (1 << Role))
{ {
sprintf (UnsignedStr,"%u",(unsigned) Role); snprintf (UnsignedStr,sizeof (UnsignedStr),
"%u",
(unsigned) Role);
if (FirstRole) // Not the first role if (FirstRole) // Not the first role
FirstRole = false; FirstRole = false;
else else
@ -8964,7 +8985,9 @@ void Usr_PrintUsrQRCode (void)
/***** Show QR code *****/ /***** Show QR code *****/
if (Gbl.Usrs.Other.UsrDat.Nickname[0]) if (Gbl.Usrs.Other.UsrDat.Nickname[0])
{ {
sprintf (NewNicknameWithArroba,"@%s",Gbl.Usrs.Other.UsrDat.Nickname); snprintf (NewNicknameWithArroba,sizeof (NewNicknameWithArroba),
"@%s",
Gbl.Usrs.Other.UsrDat.Nickname);
QR_ImageQRCode (NewNicknameWithArroba); QR_ImageQRCode (NewNicknameWithArroba);
} }

View File

@ -415,7 +415,7 @@ void Usr_SeeStdClassPhotoPrn (void);
void Usr_SeeTchClassPhotoPrn (void); void Usr_SeeTchClassPhotoPrn (void);
void Usr_PutSelectorNumColsClassPhoto (void); void Usr_PutSelectorNumColsClassPhoto (void);
void Usr_ConstructPathUsr (long UsrCod,char *PathUsr); void Usr_ConstructPathUsr (long UsrCod,char PathUsr[PATH_MAX + 1]);
bool Usr_ChkIfUsrCodExists (long UsrCod); bool Usr_ChkIfUsrCodExists (long UsrCod);
void Usr_ShowWarningNoUsersFound (Rol_Role_t Role); void Usr_ShowWarningNoUsersFound (Rol_Role_t Role);

View File

@ -2278,10 +2278,10 @@ static void Svc_GetListGrpsInAttendanceEventFromDB (long AttCod,char **ListGroup
/* Get group code (row[0]) */ /* Get group code (row[0]) */
GrpCod = Str_ConvertStrCodToLongCod (row[0]); GrpCod = Str_ConvertStrCodToLongCod (row[0]);
sprintf (GrpCodStr, snprintf (GrpCodStr,sizeof (GrpCodStr),
NumGrp ? ",%ld" : NumGrp ? ",%ld" :
"%ld", "%ld",
GrpCod); GrpCod);
Str_Concat (*ListGroups,GrpCodStr, Str_Concat (*ListGroups,GrpCodStr,
Length); Length);
} }
@ -4099,12 +4099,16 @@ int swad__getTrivialQuestion (struct soap *soap,
/* Add this degree to query */ /* Add this degree to query */
if (FirstDegree) if (FirstDegree)
{ {
sprintf (DegreesStr,"%ld",DegCod); snprintf (DegreesStr,sizeof (DegreesStr),
"%ld",
DegCod);
FirstDegree = false; FirstDegree = false;
} }
else else
{ {
sprintf (DegStr,",%ld",DegCod); snprintf (DegStr,sizeof (DegStr),
",%ld",
DegCod);
Str_Concat (DegreesStr,DegStr, Str_Concat (DegreesStr,DegStr,
Svc_MAX_BYTES_DEGREES_STR); Svc_MAX_BYTES_DEGREES_STR);
} }
@ -4377,18 +4381,22 @@ int swad__getDirectoryTree (struct soap *soap,
Gbl.CurrentCrs.Grps.GrpCod = (groupCode > 0) ? (long) groupCode : Gbl.CurrentCrs.Grps.GrpCod = (groupCode > 0) ? (long) groupCode :
-1L; -1L;
sprintf (Gbl.CurrentCrs.PathPriv,"%s/%s/%ld", snprintf (Gbl.CurrentCrs.PathPriv,sizeof (Gbl.CurrentCrs.PathPriv),
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod); "%s/%s/%ld",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod);
Brw_InitializeFileBrowser (); Brw_InitializeFileBrowser ();
Brw_SetFullPathInTree (Brw_RootFolderInternalNames[Gbl.FileBrowser.Type],"."); Brw_SetFullPathInTree (Brw_RootFolderInternalNames[Gbl.FileBrowser.Type],".");
/* Check if exists the directory for HTML output. If not exists, create it */ /* Check if exists the directory for HTML output. If not exists, create it */
sprintf (PathXMLPriv,"%s/%s",Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT); snprintf (PathXMLPriv,sizeof (PathXMLPriv),
"%s/%s",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_OUT);
Fil_CreateDirIfNotExists (PathXMLPriv); Fil_CreateDirIfNotExists (PathXMLPriv);
/* Create a unique name for the file */ /* Create a unique name for the file */
sprintf (XMLFileName,"%s/%s.xml", snprintf (XMLFileName,sizeof (XMLFileName),
PathXMLPriv,Gbl.UniqueNameEncrypted); "%s/%s.xml",
PathXMLPriv,Gbl.UniqueNameEncrypted);
/* Open file for writing and reading */ /* Open file for writing and reading */
if ((Gbl.F.XML = fopen (XMLFileName,"w+t")) == NULL) if ((Gbl.F.XML = fopen (XMLFileName,"w+t")) == NULL)
@ -4445,8 +4453,12 @@ static void Svc_ListDir (unsigned Level,const char *Path,const char *PathInTree)
if (strcmp (FileList[NumFile]->d_name,".") && if (strcmp (FileList[NumFile]->d_name,".") &&
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".." strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
{ {
sprintf (PathFileRel ,"%s/%s",Path ,FileList[NumFile]->d_name); snprintf (PathFileRel,sizeof (PathFileRel),
sprintf (PathFileInExplTree,"%s/%s",PathInTree,FileList[NumFile]->d_name); "%s/%s",
Path,FileList[NumFile]->d_name);
snprintf (PathFileInExplTree,sizeof (PathFileInExplTree),
"%s/%s",
PathInTree,FileList[NumFile]->d_name);
if (!lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned if (!lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
{ {