Version 16.118

This commit is contained in:
Antonio Cañas Vargas 2017-01-17 03:10:43 +01:00
parent 22475d77da
commit a70828bbc5
75 changed files with 1207 additions and 767 deletions

View File

@ -118,7 +118,8 @@ void ID_GetListIDsFromUsrCod (struct UsrData *UsrDat)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get ID from row[0] */ /* Get ID from row[0] */
Str_Copy (UsrDat->IDs.List[NumID].ID,row[0],ID_MAX_LENGTH_USR_ID); Str_Copy (UsrDat->IDs.List[NumID].ID,row[0],
ID_MAX_LENGTH_USR_ID);
/* Get if ID is confirmed from row[1] */ /* Get if ID is confirmed from row[1] */
UsrDat->IDs.List[NumID].Confirmed = (row[1][0] == 'Y'); UsrDat->IDs.List[NumID].Confirmed = (row[1][0] == 'Y');
@ -197,7 +198,8 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
Str_Copy (Query,CheckPassword ? "SELECT DISTINCT(usr_IDs.UsrCod) FROM usr_IDs,usr_data" Str_Copy (Query,CheckPassword ? "SELECT DISTINCT(usr_IDs.UsrCod) FROM usr_IDs,usr_data"
" WHERE usr_IDs.UsrID IN (" : " WHERE usr_IDs.UsrID IN (" :
"SELECT DISTINCT(UsrCod) FROM usr_IDs" "SELECT DISTINCT(UsrCod) FROM usr_IDs"
" WHERE UsrID IN (",MaxLength); " WHERE UsrID IN (",
MaxLength);
for (NumID = 0; for (NumID = 0;
NumID < UsrDat->IDs.Num; NumID < UsrDat->IDs.Num;
NumID++) NumID++)

View File

@ -237,7 +237,8 @@ void MFU_WriteBigMFUActions (struct MFU_ListMFUActions *ListMFUActions)
SuperAction = Act_Actions[Action].SuperAction; SuperAction = Act_Actions[Action].SuperAction;
Str_Copy (TabStr,Txt_TABS_TXT[Act_Actions[SuperAction].Tab], Str_Copy (TabStr,Txt_TABS_TXT[Act_Actions[SuperAction].Tab],
MFU_MAX_LENGTH_TAB); MFU_MAX_LENGTH_TAB);
Str_Copy (MenuStr,Title,MFU_MAX_LENGTH_MENU); Str_Copy (MenuStr,Title,
MFU_MAX_LENGTH_MENU);
sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr); sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr);
/* Icon and text */ /* Icon and text */
@ -300,7 +301,8 @@ void MFU_WriteSmallMFUActions (struct MFU_ListMFUActions *ListMFUActions)
SuperAction = Act_Actions[Action].SuperAction; SuperAction = Act_Actions[Action].SuperAction;
Str_Copy (TabStr,Txt_TABS_TXT[Act_Actions[SuperAction].Tab], Str_Copy (TabStr,Txt_TABS_TXT[Act_Actions[SuperAction].Tab],
MFU_MAX_LENGTH_TAB); MFU_MAX_LENGTH_TAB);
Str_Copy (MenuStr,Title,MFU_MAX_LENGTH_MENU); Str_Copy (MenuStr,Title,
MFU_MAX_LENGTH_MENU);
sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr); sprintf (TabMenuStr,"%s &gt; %s",TabStr,MenuStr);
/* Icon and text */ /* Icon and text */

View File

@ -152,7 +152,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
time_t CreatTimeUTC; time_t CreatTimeUTC;
long NotCod; long NotCod;
unsigned long NumNot,NumNotices; unsigned long NumNot,NumNotices;
char Content[Cns_MAX_BYTES_TEXT+1]; char Content[Cns_MAX_BYTES_TEXT + 1];
/***** Get active notices in course *****/ /***** Get active notices in course *****/
sprintf (Query,"SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS T,UsrCod,Content" sprintf (Query,"SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS T,UsrCod,Content"
@ -191,7 +191,8 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
fprintf (FileRSS,"<item>\n"); fprintf (FileRSS,"<item>\n");
/* Write title (first characters) of the notice */ /* Write title (first characters) of the notice */
Str_Copy (Content,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[3],
Cns_MAX_BYTES_TEXT);
Str_LimitLengthHTMLStr (Content,40); Str_LimitLengthHTMLStr (Content,40);
fprintf (FileRSS,"<title>%s: ",Txt_Notice); fprintf (FileRSS,"<title>%s: ",Txt_Notice);
Str_FilePrintStrChangingBRToRetAndNBSPToSpace (FileRSS,Content); Str_FilePrintStrChangingBRToRetAndNBSPToSpace (FileRSS,Content);
@ -202,7 +203,8 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
Cfg_URL_SWAD_CGI,Crs->CrsCod); Cfg_URL_SWAD_CGI,Crs->CrsCod);
/* Write full content of the notice */ /* Write full content of the notice */
Str_Copy (Content,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[3],
Cns_MAX_BYTES_TEXT);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,40); Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,40);
fprintf (FileRSS,"<description><![CDATA[<p><em>%s %s %s:</em></p><p>%s</p>]]></description>\n", fprintf (FileRSS,"<description><![CDATA[<p><em>%s %s %s:</em></p><p>%s</p>]]></description>\n",
UsrDat.FirstName,UsrDat.Surname1,UsrDat.Surname2,Content); UsrDat.FirstName,UsrDat.Surname1,UsrDat.Surname2,Content);

View File

@ -73,7 +73,7 @@ static void Acc_ShowFormCheckIfIHaveAccount (const char *Title);
static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrData *UsrDat); static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrData *UsrDat);
static void Acc_ShowFormRequestNewAccountWithParams (const char *NewNicknameWithoutArroba, static void Acc_ShowFormRequestNewAccountWithParams (const char *NewNicknameWithoutArroba,
const char *NewEmail); const char *NewEmail);
static bool Acc_GetParamsNewAccount (char *NewNicknameWithoutArroba, static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
char *NewEmail, char *NewEmail,
char *NewEncryptedPassword); char *NewEncryptedPassword);
static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat); static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat);
@ -331,7 +331,7 @@ static void Acc_ShowFormRequestNewAccountWithParams (const char *NewNicknameWith
extern const char *Txt_HELP_nickname; extern const char *Txt_HELP_nickname;
extern const char *Txt_HELP_email; extern const char *Txt_HELP_email;
extern const char *Txt_Email; extern const char *Txt_Email;
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
/***** Form to enter some data of the new user *****/ /***** Form to enter some data of the new user *****/
Act_FormStart (ActCreUsrAcc); Act_FormStart (ActCreUsrAcc);
@ -548,9 +548,9 @@ static void Acc_PrintAccountSeparator (void)
bool Acc_CreateMyNewAccountAndLogIn (void) bool Acc_CreateMyNewAccountAndLogIn (void)
{ {
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewEmail[Usr_MAX_BYTES_USR_EMAIL+1]; char NewEmail[Usr_MAX_BYTES_USR_EMAIL + 1];
char NewEncryptedPassword[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64+1]; char NewEncryptedPassword[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64 + 1];
if (Acc_GetParamsNewAccount (NewNicknameWithoutArroba,NewEmail,NewEncryptedPassword)) if (Acc_GetParamsNewAccount (NewNicknameWithoutArroba,NewEmail,NewEncryptedPassword))
{ {
@ -575,7 +575,8 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail)) if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail))
{ {
/* Email updated sucessfully */ /* Email updated sucessfully */
Str_Copy (Gbl.Usrs.Me.UsrDat.Email,NewEmail,Usr_MAX_BYTES_USR_EMAIL); Str_Copy (Gbl.Usrs.Me.UsrDat.Email,NewEmail,
Usr_MAX_BYTES_USR_EMAIL);
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false; Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
} }
@ -595,7 +596,7 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
/*****************************************************************************/ /*****************************************************************************/
// Return false on error // Return false on error
static bool Acc_GetParamsNewAccount (char *NewNicknameWithoutArroba, static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1],
char *NewEmail, char *NewEmail,
char *NewEncryptedPassword) char *NewEncryptedPassword)
{ {
@ -604,16 +605,17 @@ static bool Acc_GetParamsNewAccount (char *NewNicknameWithoutArroba,
extern const char *Txt_The_email_address_X_had_been_registered_by_another_user; extern const char *Txt_The_email_address_X_had_been_registered_by_another_user;
extern const char *Txt_The_email_address_entered_X_is_not_valid; extern const char *Txt_The_email_address_entered_X_is_not_valid;
char Query[1024]; char Query[1024];
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewPlainPassword[Pwd_MAX_LENGTH_PLAIN_PASSWORD+1]; char NewPlainPassword[Pwd_MAX_LENGTH_PLAIN_PASSWORD + 1];
bool Error = false; bool Error = false;
/***** Step 1/3: Get new nickname from form *****/ /***** Step 1/3: Get new nickname from form *****/
Par_GetParToText ("NewNick",NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Par_GetParToText ("NewNick",NewNicknameWithArroba,
Nck_MAX_BYTES_NICKNAME_FROM_FORM);
/* Remove arrobas at the beginning */ /* Remove arrobas at the beginning */
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba, Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Nck_MAX_BYTES_NICKNAME_FROM_FORM);
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba); Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
/* Create a new version of the nickname with arroba */ /* Create a new version of the nickname with arroba */

View File

@ -4593,9 +4593,10 @@ const char *Act_GetSubtitleAction (Act_Action_t Action)
/********************* Get text for action from database *********************/ /********************* Get text for action from database *********************/
/*****************************************************************************/ /*****************************************************************************/
char *Act_GetActionTextFromDB (long ActCod,char *Txt) char *Act_GetActionTextFromDB (long ActCod,
char ActTxt[Act_MAX_LENGTH_ACTION_TXT + 1])
{ {
extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES]; extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
char Query[1024]; char Query[1024];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
@ -4608,15 +4609,16 @@ char *Act_GetActionTextFromDB (long ActCod,char *Txt)
{ {
/***** Get text *****/ /***** Get text *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],Act_MAX_LENGTH_ACTION_TXT); Str_Copy (ActTxt,row[0],
Act_MAX_LENGTH_ACTION_TXT);
} }
else // ActCod-Language not found on database else // ActCod-Language not found on database
Txt[0] = '\0'; ActTxt[0] = '\0';
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
return Txt; return ActTxt;
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1512,7 +1512,8 @@ struct Act_Actions
bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action); bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action);
const char *Act_GetTitleAction (Act_Action_t Action); const char *Act_GetTitleAction (Act_Action_t Action);
const char *Act_GetSubtitleAction (Act_Action_t Action); const char *Act_GetSubtitleAction (Act_Action_t Action);
char *Act_GetActionTextFromDB (long ActCod,char *Txt); char *Act_GetActionTextFromDB (long ActCod,
char ActTxt[Act_MAX_LENGTH_ACTION_TXT + 1]);
void Act_FormGoToStart (Act_Action_t NextAction); void Act_FormGoToStart (Act_Action_t NextAction);
void Act_FormStart (Act_Action_t NextAction); void Act_FormStart (Act_Action_t NextAction);

View File

@ -96,7 +96,8 @@ static void Agd_PutFormsToRemEditOneEvent (struct AgendaEvent *AgdEvent);
static void Agd_PutParams (void); static void Agd_PutParams (void);
static void Agd_GetListEvents (Agd_AgendaType_t AgendaType); static void Agd_GetListEvents (Agd_AgendaType_t AgendaType);
static void Agd_GetDataOfEventByCod (struct AgendaEvent *AgdEvent); static void Agd_GetDataOfEventByCod (struct AgendaEvent *AgdEvent);
static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,char *Txt); static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,
char Txt[Cns_MAX_BYTES_TEXT + 1]);
static void Agd_PutParamAgdCod (long AgdCod); static void Agd_PutParamAgdCod (long AgdCod);
static bool Agd_CheckIfSimilarEventExists (struct AgendaEvent *AgdEvent); static bool Agd_CheckIfSimilarEventExists (struct AgendaEvent *AgdEvent);
static void Agd_CreateEvent (struct AgendaEvent *AgdEvent,const char *Txt); static void Agd_CreateEvent (struct AgendaEvent *AgdEvent,const char *Txt);
@ -114,7 +115,7 @@ void Agd_PutFormLogInToShowUsrAgenda (void)
void Agd_PutParamAgd (void) void Agd_PutParamAgd (void)
{ {
char Nickname[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char Nickname[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
sprintf (Nickname,"@%s",Gbl.Usrs.Other.UsrDat.Nickname); sprintf (Nickname,"@%s",Gbl.Usrs.Other.UsrDat.Nickname);
Par_PutHiddenParamString ("agd",Nickname); Par_PutHiddenParamString ("agd",Nickname);
@ -947,10 +948,12 @@ static void Agd_GetDataOfEventByCod (struct AgendaEvent *AgdEvent)
Dat_PRESENT)); Dat_PRESENT));
/* Get the event (row[7]) */ /* Get the event (row[7]) */
Str_Copy (AgdEvent->Event,row[7],Agd_MAX_LENGTH_EVENT); Str_Copy (AgdEvent->Event,row[7],
Agd_MAX_LENGTH_EVENT);
/* Get the event (row[8]) */ /* Get the event (row[8]) */
Str_Copy (AgdEvent->Location,row[8],Agd_MAX_LENGTH_LOCATION); Str_Copy (AgdEvent->Location,row[8],
Agd_MAX_LENGTH_LOCATION);
} }
else else
{ {
@ -989,7 +992,8 @@ void Agd_FreeListEvents (void)
/*********************** Get event text from database ************************/ /*********************** Get event text from database ************************/
/*****************************************************************************/ /*****************************************************************************/
static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,char *Txt) static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,
char Txt[Cns_MAX_BYTES_TEXT + 1])
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -1007,7 +1011,8 @@ static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,char *Txt)
{ {
/* Get info text */ /* Get info text */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';
@ -1260,7 +1265,7 @@ void Agd_RequestCreatOrEditEvent (void)
extern const char *Txt_Save; extern const char *Txt_Save;
struct AgendaEvent AgdEvent; struct AgendaEvent AgdEvent;
bool ItsANewEvent; bool ItsANewEvent;
char Txt[Cns_MAX_BYTES_TEXT+1]; char Txt[Cns_MAX_BYTES_TEXT + 1];
/***** Get parameters *****/ /***** Get parameters *****/
Agd_GetParamEventOrderType (); Agd_GetParamEventOrderType ();

View File

@ -52,8 +52,8 @@ struct AgendaEvent
bool Hidden; bool Hidden;
time_t TimeUTC[Agd_NUM_DATES]; time_t TimeUTC[Agd_NUM_DATES];
Dat_TimeStatus_t TimeStatus; Dat_TimeStatus_t TimeStatus;
char Event[Agd_MAX_LENGTH_EVENT+1]; char Event[Agd_MAX_LENGTH_EVENT + 1];
char Location[Agd_MAX_LENGTH_LOCATION+1]; char Location[Agd_MAX_LENGTH_LOCATION + 1];
}; };
typedef enum typedef enum

View File

@ -86,8 +86,8 @@ void Ann_ShowAllAnnouncements (void)
unsigned NumAnn; unsigned NumAnn;
long AnnCod; long AnnCod;
unsigned Roles; unsigned Roles;
char Subject[Cns_MAX_BYTES_SUBJECT+1]; char Subject[Cns_MAX_BYTES_SUBJECT + 1];
char Content[Cns_MAX_BYTES_TEXT+1]; char Content[Cns_MAX_BYTES_TEXT + 1];
unsigned UnsignedNum; unsigned UnsignedNum;
Ann_Status_t Status; Ann_Status_t Status;
bool ICanEdit = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); bool ICanEdit = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM);
@ -149,10 +149,12 @@ void Ann_ShowAllAnnouncements (void)
Lay_ShowErrorAndExit ("Error when reading roles of announcement."); Lay_ShowErrorAndExit ("Error when reading roles of announcement.");
/* Get the content (row[3]) */ /* Get the content (row[3]) */
Str_Copy (Subject,row[3],Cns_MAX_BYTES_SUBJECT); Str_Copy (Subject,row[3],
Cns_MAX_BYTES_SUBJECT);
/* Get the content (row[4]) and insert links */ /* Get the content (row[4]) and insert links */
Str_Copy (Content,row[4],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[4],
Cns_MAX_BYTES_TEXT);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50); Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
/* Show the announcement */ /* Show the announcement */
@ -210,8 +212,8 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
unsigned NumAnnouncements; unsigned NumAnnouncements;
unsigned NumAnn; unsigned NumAnn;
long AnnCod; long AnnCod;
char Subject[Cns_MAX_BYTES_SUBJECT+1]; char Subject[Cns_MAX_BYTES_SUBJECT + 1];
char Content[Cns_MAX_BYTES_TEXT+1]; char Content[Cns_MAX_BYTES_TEXT + 1];
/***** Select announcements not seen *****/ /***** Select announcements not seen *****/
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat); Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat);
@ -241,10 +243,12 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
Lay_ShowErrorAndExit ("Wrong code of announcement."); Lay_ShowErrorAndExit ("Wrong code of announcement.");
/* Get the content (row[1]) */ /* Get the content (row[1]) */
Str_Copy (Subject,row[1],Cns_MAX_BYTES_SUBJECT); Str_Copy (Subject,row[1],
Cns_MAX_BYTES_SUBJECT);
/* Get the content (row[2]) and insert links */ /* Get the content (row[2]) and insert links */
Str_Copy (Content,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[2],
Cns_MAX_BYTES_TEXT);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50); Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
/* Show the announcement */ /* Show the announcement */

View File

@ -452,8 +452,10 @@ static void Asg_WriteAsgAuthor (struct Assignment *Asg)
"PHOTO15x20",Pho_ZOOM,false); "PHOTO15x20",Pho_ZOOM,false);
/***** Write name *****/ /***** Write name *****/
Str_Copy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Copy (FirstName,UsrDat.FirstName,
Str_Copy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES); Usr_MAX_BYTES_NAME);
Str_Copy (Surnames,UsrDat.Surname1,
Usr_MAX_BYTES_SURNAMES);
if (UsrDat.Surname2[0]) if (UsrDat.Surname2[0])
{ {
Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES); Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES);
@ -776,10 +778,12 @@ static void Asg_GetDataOfAssignment (struct Assignment *Asg,const char *Query)
Asg->Open = (row[5][0] == '1'); Asg->Open = (row[5][0] == '1');
/* Get the title of the assignment (row[6]) */ /* Get the title of the assignment (row[6]) */
Str_Copy (Asg->Title,row[6],Asg_MAX_LENGTH_ASSIGNMENT_TITLE); Str_Copy (Asg->Title,row[6],
Asg_MAX_LENGTH_ASSIGNMENT_TITLE);
/* Get the folder for the assignment files (row[7]) */ /* Get the folder for the assignment files (row[7]) */
Str_Copy (Asg->Folder,row[7],Asg_MAX_LENGTH_FOLDER); Str_Copy (Asg->Folder,row[7],
Asg_MAX_LENGTH_FOLDER);
Asg->SendWork = (Asg->Folder[0] != '\0'); Asg->SendWork = (Asg->Folder[0] != '\0');
/* Can I do this assignment? */ /* Can I do this assignment? */
@ -848,7 +852,8 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT
{ {
/* Get info text */ /* Get info text */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';
@ -871,6 +876,7 @@ void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **Cont
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
size_t Length;
SummaryStr[0] = '\0'; // Return nothing on error SummaryStr[0] = '\0'; // Return nothing on error
@ -887,18 +893,19 @@ void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **Cont
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/***** Get summary *****/ /***** Get summary *****/
Str_Copy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,row[0],
Cns_MAX_BYTES_TEXT);
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
/***** Get content *****/ /***** Get content *****/
if (GetContent) if (GetContent)
{ {
if ((*ContentStr = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Length = strlen (row[1]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content."); Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[1],
Str_Copy (*ContentStr,row[1],Cns_MAX_BYTES_TEXT); Length);
} }
} }
mysql_free_result (mysql_res); mysql_free_result (mysql_res);

View File

@ -52,9 +52,9 @@ struct Assignment
long UsrCod; long UsrCod;
time_t TimeUTC[Dat_NUM_START_END_TIME]; time_t TimeUTC[Dat_NUM_START_END_TIME];
bool Open; bool Open;
char Title[Asg_MAX_LENGTH_ASSIGNMENT_TITLE+1]; char Title[Asg_MAX_LENGTH_ASSIGNMENT_TITLE + 1];
Asg_SendWork_t SendWork; Asg_SendWork_t SendWork;
char Folder[Asg_MAX_LENGTH_FOLDER+1]; char Folder[Asg_MAX_LENGTH_FOLDER + 1];
bool IBelongToCrsOrGrps; // I can do this assignment bool IBelongToCrsOrGrps; // I can do this assignment
// (it is associated to no groups // (it is associated to no groups
// or, if associated to groups, // or, if associated to groups,

View File

@ -107,7 +107,9 @@ static void Att_GetNumStdsTotalWhoAreInAttEvent (struct AttendanceEvent *Att);
static unsigned Att_GetNumStdsFromAListWhoAreInAttEvent (long AttCod,long LstSelectedUsrCods[],unsigned NumStdsInList); static unsigned Att_GetNumStdsFromAListWhoAreInAttEvent (long AttCod,long LstSelectedUsrCods[],unsigned NumStdsInList);
static bool Att_CheckIfUsrIsInTableAttUsr (long AttCod,long UsrCod,bool *Present); static bool Att_CheckIfUsrIsInTableAttUsr (long AttCod,long UsrCod,bool *Present);
static bool Att_CheckIfUsrIsPresentInAttEvent (long AttCod,long UsrCod); static bool Att_CheckIfUsrIsPresentInAttEvent (long AttCod,long UsrCod);
static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long UsrCod,char *CommentStd,char *CommentTch); static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long UsrCod,
char CommentStd[Cns_MAX_BYTES_TEXT + 1],
char CommentTch[Cns_MAX_BYTES_TEXT + 1]);
static void Att_RegUsrInAttEventChangingComments (long AttCod,long UsrCod,bool Present, static void Att_RegUsrInAttEventChangingComments (long AttCod,long UsrCod,bool Present,
const char *CommentStd,const char *CommentTch); const char *CommentStd,const char *CommentTch);
static void Att_RemoveUsrFromAttEvent (long AttCod,long UsrCod); static void Att_RemoveUsrFromAttEvent (long AttCod,long UsrCod);
@ -141,7 +143,7 @@ static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat);
void Att_SeeAttEvents (void) void Att_SeeAttEvents (void)
{ {
char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
/***** Get parameters *****/ /***** Get parameters *****/
Att_GetParamAttOrderType (); Att_GetParamAttOrderType ();
@ -492,8 +494,10 @@ static void Att_WriteAttEventAuthor (struct AttendanceEvent *Att)
"PHOTO15x20",Pho_ZOOM,false); "PHOTO15x20",Pho_ZOOM,false);
/***** Write name *****/ /***** Write name *****/
Str_Copy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Copy (FirstName,UsrDat.FirstName,
Str_Copy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES); Usr_MAX_BYTES_NAME);
Str_Copy (Surnames,UsrDat.Surname1,
Usr_MAX_BYTES_SURNAMES);
if (UsrDat.Surname2[0]) if (UsrDat.Surname2[0])
{ {
Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES); Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES);
@ -785,7 +789,8 @@ bool Att_GetDataOfAttEventByCod (struct AttendanceEvent *Att)
Att->CommentTchVisible = (row[7][0] == 'Y'); Att->CommentTchVisible = (row[7][0] == 'Y');
/* Get the title of the attendance event (row[8]) */ /* Get the title of the attendance event (row[8]) */
Str_Copy (Att->Title,row[8],Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE); Str_Copy (Att->Title,row[8],
Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -856,7 +861,8 @@ static void Att_GetAttEventTxtFromDB (long AttCod,char Txt[Cns_MAX_BYTES_TEXT +
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get info text */ /* Get info text */
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';
@ -2493,7 +2499,9 @@ static bool Att_CheckIfUsrIsPresentInAttEvent (long AttCod,long UsrCod)
/***************** Check if a student attended to an event *******************/ /***************** Check if a student attended to an event *******************/
/*****************************************************************************/ /*****************************************************************************/
static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long UsrCod,char *CommentStd,char *CommentTch) static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long UsrCod,
char CommentStd[Cns_MAX_BYTES_TEXT + 1],
char CommentTch[Cns_MAX_BYTES_TEXT + 1])
{ {
char Query[256]; char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -2514,10 +2522,12 @@ static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long Us
Present = (row[0][0] == 'Y'); Present = (row[0][0] == 'Y');
/* Get student's comment (row[1]) */ /* Get student's comment (row[1]) */
Str_Copy (CommentStd,row[1],Cns_MAX_BYTES_TEXT); Str_Copy (CommentStd,row[1],
Cns_MAX_BYTES_TEXT);
/* Get teacher's comment (row[2]) */ /* Get teacher's comment (row[2]) */
Str_Copy (CommentTch,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (CommentTch,row[2],
Cns_MAX_BYTES_TEXT);
} }
else // User is not present else // User is not present
{ {
@ -3450,8 +3460,8 @@ static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat)
bool Present; bool Present;
bool ShowCommentStd; bool ShowCommentStd;
bool ShowCommentTch; bool ShowCommentTch;
char CommentStd[Cns_MAX_BYTES_TEXT+1]; char CommentStd[Cns_MAX_BYTES_TEXT + 1];
char CommentTch[Cns_MAX_BYTES_TEXT+1]; char CommentTch[Cns_MAX_BYTES_TEXT + 1];
/***** Write number of student in the list *****/ /***** Write number of student in the list *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"

View File

@ -204,16 +204,20 @@ static void Ban_GetListBanners (const char *Query)
Ban->Hidden = (row[1][0] == 'Y'); Ban->Hidden = (row[1][0] == 'Y');
/* Get the short name of the banner (row[2]) */ /* Get the short name of the banner (row[2]) */
Str_Copy (Ban->ShrtName,row[2],Ban_MAX_LENGTH_SHRT_NAME); Str_Copy (Ban->ShrtName,row[2],
Ban_MAX_LENGTH_SHRT_NAME);
/* Get the full name of the banner (row[3]) */ /* Get the full name of the banner (row[3]) */
Str_Copy (Ban->FullName,row[3],Ban_MAX_LENGTH_FULL_NAME); Str_Copy (Ban->FullName,row[3],
Ban_MAX_LENGTH_FULL_NAME);
/* Get the image of the banner (row[4]) */ /* Get the image of the banner (row[4]) */
Str_Copy (Ban->Img,row[4],Ban_MAX_LENGTH_IMAGE); Str_Copy (Ban->Img,row[4],
Ban_MAX_LENGTH_IMAGE);
/* Get the URL of the banner (row[5]) */ /* Get the URL of the banner (row[5]) */
Str_Copy (Ban->WWW,row[5],Cns_MAX_LENGTH_WWW); Str_Copy (Ban->WWW,row[5],
Cns_MAX_LENGTH_WWW);
} }
} }
else else
@ -257,16 +261,20 @@ void Ban_GetDataOfBannerByCod (struct Banner *Ban)
Ban->Hidden = (row[0][0] == 'Y'); Ban->Hidden = (row[0][0] == 'Y');
/* Get the short name of the banner (row[1]) */ /* Get the short name of the banner (row[1]) */
Str_Copy (Ban->ShrtName,row[1],Ban_MAX_LENGTH_SHRT_NAME); Str_Copy (Ban->ShrtName,row[1],
Ban_MAX_LENGTH_SHRT_NAME);
/* Get the full name of the banner (row[2]) */ /* Get the full name of the banner (row[2]) */
Str_Copy (Ban->FullName,row[2],Ban_MAX_LENGTH_FULL_NAME); Str_Copy (Ban->FullName,row[2],
Ban_MAX_LENGTH_FULL_NAME);
/* Get the image of the banner (row[3]) */ /* Get the image of the banner (row[3]) */
Str_Copy (Ban->Img,row[3],Ban_MAX_LENGTH_IMAGE); Str_Copy (Ban->Img,row[3],
Ban_MAX_LENGTH_IMAGE);
/* Get the URL of the banner (row[4]) */ /* Get the URL of the banner (row[4]) */
Str_Copy (Ban->WWW,row[4],Cns_MAX_LENGTH_WWW); Str_Copy (Ban->WWW,row[4],
Cns_MAX_LENGTH_WWW);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -616,7 +624,8 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (CurrentBanName,NewBanName,MaxLength); Str_Copy (CurrentBanName,NewBanName,
MaxLength);
Ban_EditBanners (); Ban_EditBanners ();
} }
@ -674,7 +683,8 @@ void Ban_ChangeBannerImg (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_image_empty); Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_image_empty);
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Ban->Img,NewImg,Ban_MAX_LENGTH_IMAGE); Str_Copy (Ban->Img,NewImg,
Ban_MAX_LENGTH_IMAGE);
Ban_EditBanners (); Ban_EditBanners ();
} }
@ -718,7 +728,8 @@ void Ban_ChangeBannerWWW (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty); Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty);
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Ban->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Ban->WWW,NewWWW,
Cns_MAX_LENGTH_WWW);
Ban_EditBanners (); Ban_EditBanners ();
} }

View File

@ -1038,13 +1038,16 @@ void Ctr_GetListCentres (long InsCod)
Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]); Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
/* Get the short name of the centre (row[5]) */ /* Get the short name of the centre (row[5]) */
Str_Copy (Ctr->ShrtName,row[5],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME); Str_Copy (Ctr->ShrtName,row[5],
Ctr_MAX_LENGTH_CENTRE_SHRT_NAME);
/* Get the full name of the centre (row[6]) */ /* Get the full name of the centre (row[6]) */
Str_Copy (Ctr->FullName,row[6],Ctr_MAX_LENGTH_CENTRE_FULL_NAME); Str_Copy (Ctr->FullName,row[6],
Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
/* Get the URL of the centre (row[7]) */ /* Get the URL of the centre (row[7]) */
Str_Copy (Ctr->WWW,row[7],Cns_MAX_LENGTH_WWW); Str_Copy (Ctr->WWW,row[7],
Cns_MAX_LENGTH_WWW);
/* Get number of users who claim to belong to this centre (row[8]) */ /* Get number of users who claim to belong to this centre (row[8]) */
if (sscanf (row[8],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1) if (sscanf (row[8],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1)
@ -1133,13 +1136,16 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr)
Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]); Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]);
/* Get the short name of the centre (row[4]) */ /* Get the short name of the centre (row[4]) */
Str_Copy (Ctr->ShrtName,row[4],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME); Str_Copy (Ctr->ShrtName,row[4],
Ctr_MAX_LENGTH_CENTRE_SHRT_NAME);
/* Get the full name of the centre (row[5]) */ /* Get the full name of the centre (row[5]) */
Str_Copy (Ctr->FullName,row[5],Ctr_MAX_LENGTH_CENTRE_FULL_NAME); Str_Copy (Ctr->FullName,row[5],
Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
/* Get the URL of the centre (row[6]) */ /* Get the URL of the centre (row[6]) */
Str_Copy (Ctr->WWW,row[6],Cns_MAX_LENGTH_WWW); Str_Copy (Ctr->WWW,row[6],
Cns_MAX_LENGTH_WWW);
/* Get number of users who claim to belong to this centre (row[7]) */ /* Get number of users who claim to belong to this centre (row[7]) */
if (sscanf (row[7],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1) if (sscanf (row[7],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1)
@ -1217,7 +1223,8 @@ void Ctr_GetShortNameOfCentreByCod (struct Centre *Ctr)
/***** Get the short name of this centre *****/ /***** Get the short name of this centre *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Ctr->ShrtName,row[0],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME); Str_Copy (Ctr->ShrtName,row[0],
Ctr_MAX_LENGTH_CENTRE_SHRT_NAME);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -1252,11 +1259,10 @@ static void Ctr_GetPhotoAttribution (long CtrCod,char **PhotoAttribution)
if (row[0][0]) if (row[0][0])
{ {
Length = strlen (row[0]); Length = strlen (row[0]);
if (((*PhotoAttribution) = (char *) malloc (Length + 1)) == NULL) if (((*PhotoAttribution) = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for photo attribution."); Lay_ShowErrorAndExit ("Error allocating memory for photo attribution.");
Str_Copy (*PhotoAttribution,row[0],
Str_Copy (*PhotoAttribution,row[0],Length); Length);
} }
} }
@ -1363,7 +1369,7 @@ void Ctr_WriteSelectorOfCentre (void)
/*************************** List all the centres ****************************/ /*************************** List all the centres ****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Ctr_MAX_LENGTH_WWW_ON_SCREEN 10 #define Ctr_MAX_LENGTH_WWW_ON_SCREEN 15
static void Ctr_ListCentresForEdition (void) static void Ctr_ListCentresForEdition (void)
{ {
@ -1374,7 +1380,7 @@ static void Ctr_ListCentresForEdition (void)
unsigned NumCtr; unsigned NumCtr;
struct Centre *Ctr; struct Centre *Ctr;
unsigned NumPlc; unsigned NumPlc;
char WWW[Ctr_MAX_LENGTH_WWW_ON_SCREEN+1]; char WWW[Cns_MAX_LENGTH_WWW + 1];
struct UsrData UsrDat; struct UsrData UsrDat;
bool ICanEdit; bool ICanEdit;
Ctr_StatusTxt_t StatusTxt; Ctr_StatusTxt_t StatusTxt;
@ -1510,12 +1516,14 @@ static void Ctr_ListCentresForEdition (void)
} }
else else
{ {
Str_Copy (WWW,Ctr->WWW,Ctr_MAX_LENGTH_WWW_ON_SCREEN); Str_Copy (WWW,Ctr->WWW,
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\">%s", Cns_MAX_LENGTH_WWW);
Str_LimitLengthHTMLStr (WWW,Ctr_MAX_LENGTH_WWW_ON_SCREEN);
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"DAT\" title=\"%s\">"
"%s"
"</a>",
Ctr->WWW,Ctr->WWW,WWW); Ctr->WWW,Ctr->WWW,WWW);
if (strlen (Ctr->WWW) > Ctr_MAX_LENGTH_WWW_ON_SCREEN)
fprintf (Gbl.F.Out,"&hellip;");
fprintf (Gbl.F.Out,"</a>");
} }
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
@ -1889,7 +1897,7 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull
extern const char *Txt_The_centre_X_already_exists; extern const char *Txt_The_centre_X_already_exists;
extern const char *Txt_The_centre_X_has_been_renamed_as_Y; extern const char *Txt_The_centre_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_centre_X_has_not_changed; extern const char *Txt_The_name_of_the_centre_X_has_not_changed;
char Query[128+Ctr_MAX_LENGTH_CENTRE_FULL_NAME]; char Query[128 + Ctr_MAX_LENGTH_CENTRE_FULL_NAME];
const char *ParamName = NULL; // Initialized to avoid warning const char *ParamName = NULL; // Initialized to avoid warning
const char *FieldName = NULL; // Initialized to avoid warning const char *FieldName = NULL; // Initialized to avoid warning
unsigned MaxLength = 0; // Initialized to avoid warning unsigned MaxLength = 0; // Initialized to avoid warning
@ -1950,7 +1958,8 @@ static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFull
CurrentCtrName,NewCtrName); CurrentCtrName,NewCtrName);
/* Change current centre name in order to display it properly */ /* Change current centre name in order to display it properly */
Str_Copy (CurrentCtrName,NewCtrName,MaxLength); Str_Copy (CurrentCtrName,NewCtrName,
MaxLength);
} }
} }
else // The same name else // The same name
@ -2003,7 +2012,8 @@ void Ctr_ChangeCtrWWW (void)
/***** Update database changing old WWW by new WWW *****/ /***** Update database changing old WWW by new WWW *****/
Ctr_UpdateCtrWWWDB (Ctr->CtrCod,NewWWW); Ctr_UpdateCtrWWWDB (Ctr->CtrCod,NewWWW);
Str_Copy (Ctr->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Ctr->WWW,NewWWW,
Cns_MAX_LENGTH_WWW);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);
@ -2034,7 +2044,8 @@ void Ctr_ChangeCtrWWWInConfig (void)
{ {
/***** Update database changing old WWW by new WWW *****/ /***** Update database changing old WWW by new WWW *****/
Ctr_UpdateCtrWWWDB (Gbl.CurrentCtr.Ctr.CtrCod,NewWWW); Ctr_UpdateCtrWWWDB (Gbl.CurrentCtr.Ctr.CtrCod,NewWWW);
Str_Copy (Gbl.CurrentCtr.Ctr.WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Gbl.CurrentCtr.Ctr.WWW,NewWWW,
Cns_MAX_LENGTH_WWW);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);

View File

@ -184,18 +184,22 @@
// TODO: Draw future dates in attendance, surveys, assignments in blue? // TODO: Draw future dates in attendance, surveys, assignments in blue?
// TODO: Fix bug in generate a test: after entering a number of questions with empty tags and type of answers, number of questions is not remembered // TODO: Fix bug in generate a test: after entering a number of questions with empty tags and type of answers, number of questions is not remembered
// TODO: Fix bug when editing a test question with images: when "Change image" is selected but no image is uploades, other images (for example in answers) are lost // TODO: Fix bug when editing a test question with images: when "Change image" is selected but no image is uploades, other images (for example in answers) are lost
// TODO: Fix bug when creating a new attendance event: if title is repeated, form is cleared
// TODO: Fix bug: When registering an administrator, the user's name changes are ignored
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.117 (2017-01-16)" #define Log_PLATFORM_VERSION "SWAD 16.118 (2017-01-16)"
#define CSS_FILE "swad16.111.5.css" #define CSS_FILE "swad16.111.5.css"
#define JS_FILE "swad16.114.js" #define JS_FILE "swad16.114.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/* /*
Version 16.118: Jan 17, 2017 Code refactoring related to string copy. (211676 lines)
Version 16.117.1: Jan 16, 2017 Code refactoring related to string concatenation. (211229 lines)
Version 16.117: Jan 16, 2017 Code refactoring related to string concatenation. (211244 lines) Version 16.117: Jan 16, 2017 Code refactoring related to string concatenation. (211244 lines)
Version 16.116: Jan 15, 2017 Code refactoring related to string copy. (211195 lines) Version 16.116: Jan 15, 2017 Code refactoring related to string copy. (211195 lines)
Version 16.115: Jan 15, 2017 Code refactoring related to string copy. (211046 lines) Version 16.115: Jan 15, 2017 Code refactoring related to string copy. (211046 lines)

View File

@ -372,6 +372,10 @@ static unsigned Cht_GetNumUsrsInChatRoom (const char *RoomCode)
/******************************* Enter a chat room ***************************/ /******************************* Enter a chat room ***************************/
/*****************************************************************************/ /*****************************************************************************/
#define Cht_MAX_LENGTH_ROOM_CODES ((2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_CODE)
#define Cht_MAX_LENGTH_ROOM_SHRT_NAMES ((2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_SHRT_NAME)
#define Cht_MAX_LENGTH_ROOM_FULL_NAMES ((2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_FULL_NAME)
void Cht_OpenChatWindow (void) void Cht_OpenChatWindow (void)
{ {
extern const char *Txt_SEX_PLURAL_Abc[Usr_NUM_SEXS]; extern const char *Txt_SEX_PLURAL_Abc[Usr_NUM_SEXS];
@ -393,9 +397,9 @@ void Cht_OpenChatWindow (void)
char ThisRoomCode [MAX_LENGTH_ROOM_CODE + 1]; char ThisRoomCode [MAX_LENGTH_ROOM_CODE + 1];
char ThisRoomShortName[MAX_LENGTH_ROOM_SHRT_NAME + 1]; char ThisRoomShortName[MAX_LENGTH_ROOM_SHRT_NAME + 1];
char ThisRoomFullName [MAX_LENGTH_ROOM_FULL_NAME + 1]; char ThisRoomFullName [MAX_LENGTH_ROOM_FULL_NAME + 1];
char ListRoomCodes [(2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_CODE + 1]; char ListRoomCodes [Cht_MAX_LENGTH_ROOM_CODES + 1];
char ListRoomShortNames[(2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_SHRT_NAME + 1]; char ListRoomShortNames[Cht_MAX_LENGTH_ROOM_SHRT_NAMES + 1];
char ListRoomFullNames [(2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_FULL_NAME + 1]; char ListRoomFullNames [Cht_MAX_LENGTH_ROOM_FULL_NAMES + 1];
FILE *FileChat; FILE *FileChat;
/***** Get the code and the nombre of the room *****/ /***** Get the code and the nombre of the room *****/
@ -415,19 +419,22 @@ void Cht_OpenChatWindow (void)
Usr_GetMyCourses (); Usr_GetMyCourses ();
/***** Build my user's name *****/ /***** Build my user's name *****/
Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME); Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,
Usr_MAX_BYTES_FULL_NAME);
if (Gbl.Usrs.Me.UsrDat.Surname2[0]) if (Gbl.Usrs.Me.UsrDat.Surname2[0])
{ {
Str_Concat (UsrName," ",Usr_MAX_BYTES_NAME); Str_Concat (UsrName," ",Usr_MAX_BYTES_FULL_NAME);
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_NAME); Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_FULL_NAME);
} }
Str_Concat (UsrName,", ",Usr_MAX_BYTES_NAME); Str_Concat (UsrName,", ",Usr_MAX_BYTES_FULL_NAME);
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_FULL_NAME);
/***** Build the lists of available rooms *****/ /***** Build the lists of available rooms *****/
sprintf (ListRoomCodes,"#%s",RoomCode); sprintf (ListRoomCodes,"#%s",RoomCode);
Str_Copy (ListRoomShortNames,RoomShortName,sizeof (ListRoomShortNames) - 1); Str_Copy (ListRoomShortNames,RoomShortName,
Str_Copy (ListRoomFullNames ,RoomFullName,sizeof (ListRoomFullNames) - 1); Cht_MAX_LENGTH_ROOM_SHRT_NAMES);
Str_Copy (ListRoomFullNames ,RoomFullName,
Cht_MAX_LENGTH_ROOM_FULL_NAMES);
if (strcmp (RoomCode,"GBL_USR")) if (strcmp (RoomCode,"GBL_USR"))
{ {

View File

@ -33,6 +33,7 @@
#include "swad_database.h" #include "swad_database.h"
#include "swad_global.h" #include "swad_global.h"
#include "swad_hierarchy.h"
#include "swad_parameter.h" #include "swad_parameter.h"
#include "swad_photo.h" #include "swad_photo.h"
#include "swad_role.h" #include "swad_role.h"
@ -457,7 +458,7 @@ static void Con_ShowConnectedUsrsBelongingToLocation (void)
{ {
extern const char *The_ClassConnected[The_NUM_THEMES]; extern const char *The_ClassConnected[The_NUM_THEMES];
extern const char *Txt_from; extern const char *Txt_from;
char LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR + 1]; char LocationName[Hie_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR + 1];
struct ConnectedUsrs Usrs; struct ConnectedUsrs Usrs;
/***** Set location name depending on scope *****/ /***** Set location name depending on scope *****/
@ -465,42 +466,42 @@ static void Con_ShowConnectedUsrsBelongingToLocation (void)
{ {
case Sco_SCOPE_SYS: // Show connected users in the whole platform case Sco_SCOPE_SYS: // Show connected users in the whole platform
Str_Copy (LocationName,Cfg_PLATFORM_SHORT_NAME, Str_Copy (LocationName,Cfg_PLATFORM_SHORT_NAME,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Hie_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
break; break;
case Sco_SCOPE_CTY: // Show connected users in the current country case Sco_SCOPE_CTY: // Show connected users in the current country
if (Gbl.CurrentCty.Cty.CtyCod <= 0) // There is no country selected if (Gbl.CurrentCty.Cty.CtyCod <= 0) // There is no country selected
return; return;
Str_Copy (LocationName,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language], Str_Copy (LocationName,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language],
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Hie_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
break; break;
case Sco_SCOPE_INS: // Show connected users in the current institution case Sco_SCOPE_INS: // Show connected users in the current institution
if (Gbl.CurrentIns.Ins.InsCod <= 0) // There is no institution selected if (Gbl.CurrentIns.Ins.InsCod <= 0) // There is no institution selected
return; return;
Str_Copy (LocationName,Gbl.CurrentIns.Ins.ShrtName, Str_Copy (LocationName,Gbl.CurrentIns.Ins.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Hie_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
break; break;
case Sco_SCOPE_CTR: // Show connected users in the current centre case Sco_SCOPE_CTR: // Show connected users in the current centre
if (Gbl.CurrentCtr.Ctr.CtrCod <= 0) // There is no centre selected if (Gbl.CurrentCtr.Ctr.CtrCod <= 0) // There is no centre selected
return; return;
Str_Copy (LocationName,Gbl.CurrentCtr.Ctr.ShrtName, Str_Copy (LocationName,Gbl.CurrentCtr.Ctr.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Hie_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
break; break;
case Sco_SCOPE_DEG: // Show connected users in the current degree case Sco_SCOPE_DEG: // Show connected users in the current degree
if (Gbl.CurrentDeg.Deg.DegCod <= 0) // There is no degree selected if (Gbl.CurrentDeg.Deg.DegCod <= 0) // There is no degree selected
return; return;
Str_Copy (LocationName,Gbl.CurrentDeg.Deg.ShrtName, Str_Copy (LocationName,Gbl.CurrentDeg.Deg.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Hie_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
break; break;
case Sco_SCOPE_CRS: // Show connected users in the current course case Sco_SCOPE_CRS: // Show connected users in the current course
if (Gbl.CurrentCrs.Crs.CrsCod <= 0) // There is no course selected if (Gbl.CurrentCrs.Crs.CrsCod <= 0) // There is no course selected
return; return;
Str_Copy (LocationName,Gbl.CurrentCrs.Crs.ShrtName, Str_Copy (LocationName,Gbl.CurrentCrs.Crs.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR); Hie_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
break; break;
default: default:
return; return;

View File

@ -3,6 +3,8 @@
// Author: Antonio Cañas Vargas // Author: Antonio Cañas Vargas
// Compile with: gcc -Wall -O1 swad_convert_BRIEFs.c -o swad_convert_BRIEFs -lmysqlclient -L/usr/lib64/mysql // Compile with: gcc -Wall -O1 swad_convert_BRIEFs.c -o swad_convert_BRIEFs -lmysqlclient -L/usr/lib64/mysql
#include "swad_ID.h"
#include <mysql/mysql.h> #include <mysql/mysql.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
@ -46,7 +48,7 @@ int main (void)
unsigned NumUsrs = 0; unsigned NumUsrs = 0;
unsigned i; unsigned i;
long UsrCod; long UsrCod;
char UsrID[16 + 1]; char UsrID[ID_MAX_LENGTH_USR_ID + 1];
char OldPathUsr[PATH_MAX + 1]; char OldPathUsr[PATH_MAX + 1];
char Command[1024 + PATH_MAX * 2]; char Command[1024 + PATH_MAX * 2];
@ -94,8 +96,8 @@ int main (void)
if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod
if (row[1]) if (row[1])
{ {
Str_Copy (UsrID,row[1],16); // UsrID Str_Copy (UsrID,row[1],
ID_MAX_LENGTH_USR_ID); // UsrID
sprintf (OldPathUsr,"%s/%s_backup/%c/%s", sprintf (OldPathUsr,"%s/%s_backup/%c/%s",
PATH_SWAD_PRIVATE,FOLDER_USR,UsrID[strlen (UsrID)-1],UsrID); PATH_SWAD_PRIVATE,FOLDER_USR,UsrID[strlen (UsrID)-1],UsrID);
if (CheckIfPathExists (OldPathUsr)) if (CheckIfPathExists (OldPathUsr))

View File

@ -97,7 +97,8 @@ int main (void)
if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod
if (row[1]) if (row[1])
{ {
Str_Copy (UsrID,row[1],ID_MAX_LENGTH_USR_ID); // UsrID Str_Copy (UsrID,row[1],
ID_MAX_LENGTH_USR_ID); // UsrID
sprintf (OldPathPhoto,"%s/%s_backup/%s_original.jpg", sprintf (OldPathPhoto,"%s/%s_backup/%s_original.jpg",
PATH_SWAD_PRIVATE,FOLDER_PHOTO,UsrID); PATH_SWAD_PRIVATE,FOLDER_PHOTO,UsrID);
if (CheckIfPathExists (OldPathPhoto)) if (CheckIfPathExists (OldPathPhoto))

View File

@ -126,8 +126,8 @@ int main (void)
if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod if (sscanf (row[0],"%ld",&UsrCod) == 1) // UsrCod
if (row[1]) if (row[1])
{ {
Str_Copy (UsrID,row[1],ID_MAX_LENGTH_USR_ID); // UsrID Str_Copy (UsrID,row[1],
ID_MAX_LENGTH_USR_ID,62); // UsrID
sprintf (OldPathUsr,"%s_backup/%s",OldPathUsrs,UsrID); sprintf (OldPathUsr,"%s_backup/%s",OldPathUsrs,UsrID);
if (CheckIfPathExists (OldPathUsr)) if (CheckIfPathExists (OldPathUsr))
{ {

View File

@ -759,7 +759,7 @@ void Cty_DrawCountryMapAndNameWithLink (struct Country *Cty,Act_Action_t Action,
const char *ClassLink,const char *ClassMap) const char *ClassLink,const char *ClassMap)
{ {
extern const char *Txt_Go_to_X; extern const char *Txt_Go_to_X;
char CountryName[Cty_MAX_BYTES_COUNTRY_NAME+1]; char CountryName[Cty_MAX_BYTES_COUNTRY_NAME + 1];
/***** Start form *****/ /***** Start form *****/
Act_FormGoToStart (Action); Act_FormGoToStart (Action);
@ -1033,7 +1033,8 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
Lay_ShowErrorAndExit ("Wrong code of country."); Lay_ShowErrorAndExit ("Wrong code of country.");
/* Get Alpha-2 country code (row[1]) */ /* Get Alpha-2 country code (row[1]) */
Str_Copy (Cty->Alpha2,row[1],2); Str_Copy (Cty->Alpha2,row[1],
2);
switch (GetExtraData) switch (GetExtraData)
{ {
@ -1162,8 +1163,8 @@ void Cty_WriteSelectorOfCountry (void)
void Cty_WriteCountryName (long CtyCod,const char *Class) void Cty_WriteCountryName (long CtyCod,const char *Class)
{ {
extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS];
char CtyName[Cty_MAX_BYTES_COUNTRY_NAME+1]; char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1];
char ActTxt[Act_MAX_LENGTH_ACTION_TXT+1]; char ActTxt[Act_MAX_LENGTH_ACTION_TXT + 1];
bool PutForm = !Gbl.Form.Inside && // Only if not inside another form bool PutForm = !Gbl.Form.Inside && // Only if not inside another form
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW; // Only in main window Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW; // Only in main window
@ -1292,7 +1293,8 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get Alpha-2 country code (row[0]) */ /* Get Alpha-2 country code (row[0]) */
Str_Copy (Cty->Alpha2,row[0],2); Str_Copy (Cty->Alpha2,row[0],
2);
switch (GetExtraData) switch (GetExtraData)
{ {
@ -1300,7 +1302,8 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
/* Get name and WWW of the country in current language */ /* Get name and WWW of the country in current language */
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[1], Str_Copy (Cty->Name[Gbl.Prefs.Language],row[1],
Cty_MAX_BYTES_COUNTRY_NAME); Cty_MAX_BYTES_COUNTRY_NAME);
Str_Copy (Cty->WWW[Gbl.Prefs.Language],row[2],Cns_MAX_LENGTH_WWW); Str_Copy (Cty->WWW[Gbl.Prefs.Language],row[2],
Cns_MAX_LENGTH_WWW);
break; break;
case Cty_GET_EXTRA_DATA: case Cty_GET_EXTRA_DATA:
/* Get name and WWW of the country in several languages */ /* Get name and WWW of the country in several languages */
@ -1340,7 +1343,7 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
/***************************** Get country name ******************************/ /***************************** Get country name ******************************/
/*****************************************************************************/ /*****************************************************************************/
void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME+1]) void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1])
{ {
extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES]; extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES];
char Query[128]; char Query[128];
@ -1362,7 +1365,8 @@ void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME+1])
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the name of the country */ /* Get the name of the country */
Str_Copy (CtyName,row[0],Cty_MAX_BYTES_COUNTRY_NAME); Str_Copy (CtyName,row[0],
Cty_MAX_BYTES_COUNTRY_NAME);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -1399,8 +1403,8 @@ static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution)
Length = strlen (row[0]); Length = strlen (row[0]);
if (((*MapAttribution) = (char *) malloc (Length + 1)) == NULL) if (((*MapAttribution) = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for map attribution."); Lay_ShowErrorAndExit ("Error allocating memory for map attribution.");
Str_Copy (*MapAttribution,row[0],
Str_Copy (*MapAttribution,row[0],Length); Length);
} }
} }
@ -1709,7 +1713,8 @@ void Cty_RenameCountry (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Cty->Name[Language],NewCtyName,Cty_MAX_BYTES_COUNTRY_NAME); Str_Copy (Cty->Name[Language],NewCtyName,
Cty_MAX_BYTES_COUNTRY_NAME);
Cty_EditCountries (); Cty_EditCountries ();
} }
@ -1796,7 +1801,8 @@ void Cty_ChangeCtyWWW (void)
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Cty->WWW[Language],NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Cty->WWW[Language],NewWWW,
Cns_MAX_LENGTH_WWW);
Cty_EditCountries (); Cty_EditCountries ();
} }

View File

@ -96,7 +96,7 @@ void Cty_FreeListCountries (void);
void Cty_WriteSelectorOfCountry (void); void Cty_WriteSelectorOfCountry (void);
void Cty_WriteCountryName (long CtyCod,const char *Class); void Cty_WriteCountryName (long CtyCod,const char *Class);
bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraData); bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraData);
void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME+1]); void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_COUNTRY_NAME + 1]);
void Cty_PutParamCtyCod (long CtyCod); void Cty_PutParamCtyCod (long CtyCod);
long Cty_GetAndCheckParamOtherCtyCod (void); long Cty_GetAndCheckParamOtherCtyCod (void);
void Cty_RemoveCountry (void); void Cty_RemoveCountry (void);

View File

@ -643,7 +643,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Highlight ? ClassHighlight : Highlight ? ClassHighlight :
ClassNormal,NULL); ClassNormal,NULL);
Log_DrawLogo (Sco_SCOPE_INS,Ins.InsCod,Ins.ShrtName,20,NULL,true); Log_DrawLogo (Sco_SCOPE_INS,Ins.InsCod,Ins.ShrtName,20,NULL,true);
Str_Copy (InsFullName,Ins.FullName,Ins_MAX_LENGTH_INSTIT_FULL_NAME); Str_Copy (InsFullName,Ins.FullName,
Ins_MAX_LENGTH_INSTIT_FULL_NAME);
Str_LimitLengthHTMLStr (InsFullName,Crs_MAX_BYTES_TXT_LINK); Str_LimitLengthHTMLStr (InsFullName,Crs_MAX_BYTES_TXT_LINK);
fprintf (Gbl.F.Out,"&nbsp;%s</a>",InsFullName); fprintf (Gbl.F.Out,"&nbsp;%s</a>",InsFullName);
Act_FormEnd (); Act_FormEnd ();
@ -678,7 +679,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Highlight ? ClassHighlight : Highlight ? ClassHighlight :
ClassNormal,NULL); ClassNormal,NULL);
Log_DrawLogo (Sco_SCOPE_CTR,Ctr.CtrCod,Ctr.ShrtName,20,NULL,true); Log_DrawLogo (Sco_SCOPE_CTR,Ctr.CtrCod,Ctr.ShrtName,20,NULL,true);
Str_Copy (CtrFullName,Ctr.FullName,Ctr_MAX_LENGTH_CENTRE_FULL_NAME); Str_Copy (CtrFullName,Ctr.FullName,
Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
Str_LimitLengthHTMLStr (CtrFullName,Crs_MAX_BYTES_TXT_LINK); Str_LimitLengthHTMLStr (CtrFullName,Crs_MAX_BYTES_TXT_LINK);
fprintf (Gbl.F.Out,"&nbsp;%s</a>",CtrFullName); fprintf (Gbl.F.Out,"&nbsp;%s</a>",CtrFullName);
Act_FormEnd (); Act_FormEnd ();
@ -713,7 +715,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Highlight ? ClassHighlight : Highlight ? ClassHighlight :
ClassNormal,NULL); ClassNormal,NULL);
Log_DrawLogo (Sco_SCOPE_DEG,Deg.DegCod,Deg.ShrtName,20,NULL,true); Log_DrawLogo (Sco_SCOPE_DEG,Deg.DegCod,Deg.ShrtName,20,NULL,true);
Str_Copy (DegFullName,Deg.FullName,Deg_MAX_LENGTH_DEGREE_FULL_NAME); Str_Copy (DegFullName,Deg.FullName,
Deg_MAX_LENGTH_DEGREE_FULL_NAME);
Str_LimitLengthHTMLStr (DegFullName,Crs_MAX_BYTES_TXT_LINK); Str_LimitLengthHTMLStr (DegFullName,Crs_MAX_BYTES_TXT_LINK);
fprintf (Gbl.F.Out,"&nbsp;%s</a>",DegFullName); fprintf (Gbl.F.Out,"&nbsp;%s</a>",DegFullName);
Act_FormEnd (); Act_FormEnd ();
@ -2103,7 +2106,8 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row)
Crs->Year = Deg_ConvStrToYear (row[2]); Crs->Year = Deg_ConvStrToYear (row[2]);
/***** Get institutional course code (row[3]) *****/ /***** Get institutional course code (row[3]) *****/
Str_Copy (Crs->InstitutionalCrsCod,row[3],Crs_LENGTH_INSTITUTIONAL_CRS_COD); Str_Copy (Crs->InstitutionalCrsCod,row[3],
Crs_LENGTH_INSTITUTIONAL_CRS_COD);
/***** Get course status (row[4]) *****/ /***** Get course status (row[4]) *****/
if (sscanf (row[4],"%u",&(Crs->Status)) != 1) if (sscanf (row[4],"%u",&(Crs->Status)) != 1)
@ -2113,10 +2117,12 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row)
Crs->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[5]); Crs->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[5]);
/***** Get the short name of the course (row[6]) *****/ /***** Get the short name of the course (row[6]) *****/
Str_Copy (Crs->ShrtName,row[6],Crs_MAX_LENGTH_COURSE_SHRT_NAME); Str_Copy (Crs->ShrtName,row[6],
Crs_MAX_LENGTH_COURSE_SHRT_NAME);
/***** Get the full name of the course (row[7]) *****/ /***** Get the full name of the course (row[7]) *****/
Str_Copy (Crs->FullName,row[7],Crs_MAX_LENGTH_COURSE_FULL_NAME); Str_Copy (Crs->FullName,row[7],
Crs_MAX_LENGTH_COURSE_FULL_NAME);
/***** Get number of teachers *****/ /***** Get number of teachers *****/
Crs->NumTchs = Usr_GetNumUsrsInCrs (Rol_TEACHER,Crs->CrsCod); Crs->NumTchs = Usr_GetNumUsrsInCrs (Rol_TEACHER,Crs->CrsCod);
@ -2155,8 +2161,10 @@ static void Crs_GetShortNamesByCod (long CrsCod,
/***** Get the short name of this course *****/ /***** Get the short name of this course *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (CrsShortName,row[0],Crs_MAX_LENGTH_COURSE_SHRT_NAME); Str_Copy (CrsShortName,row[0],
Str_Copy (DegShortName,row[1],Deg_MAX_LENGTH_DEGREE_SHRT_NAME); Crs_MAX_LENGTH_COURSE_SHRT_NAME);
Str_Copy (DegShortName,row[1],
Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -2381,8 +2389,7 @@ void Crs_ChangeInsCrsCod (void)
else else
{ {
Gbl.Error = true; Gbl.Error = true;
Str_Copy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course, sprintf (Gbl.Message,"%s",Txt_You_dont_have_permission_to_edit_this_course);
Lay_MAX_BYTES_ALERT);
} }
} }
@ -2588,8 +2595,7 @@ void Crs_ChangeCrsYear (void)
else else
{ {
Gbl.Error = true; Gbl.Error = true;
Str_Copy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course, sprintf (Gbl.Message,"%s",Txt_You_dont_have_permission_to_edit_this_course);
Lay_MAX_BYTES_ALERT);
} }
} }
@ -2733,7 +2739,8 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull
CurrentCrsName,NewCrsName); CurrentCrsName,NewCrsName);
/* Change current course name in order to display it properly */ /* Change current course name in order to display it properly */
Str_Copy (CurrentCrsName,NewCrsName,MaxLength); Str_Copy (CurrentCrsName,NewCrsName,
MaxLength);
} }
} }
else // The same name else // The same name
@ -2744,8 +2751,7 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull
else else
{ {
Gbl.Error = true; Gbl.Error = true;
Str_Copy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course, sprintf (Gbl.Message,"%s",Txt_You_dont_have_permission_to_edit_this_course);
Lay_MAX_BYTES_ALERT);
} }
} }

View File

@ -144,7 +144,8 @@ bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDD)
if (YYYYMMDD[0]) if (YYYYMMDD[0])
if (sscanf (YYYYMMDD,"%04u%02u%02u",&(Date->Year),&(Date->Month),&(Date->Day)) == 3) if (sscanf (YYYYMMDD,"%04u%02u%02u",&(Date->Year),&(Date->Month),&(Date->Day)) == 3)
{ {
Str_Copy (Date->YYYYMMDD,YYYYMMDD,Dat_LENGTH_YYYYMMDD); Str_Copy (Date->YYYYMMDD,YYYYMMDD,
Dat_LENGTH_YYYYMMDD);
return true; return true;
} }
@ -1263,7 +1264,8 @@ void Dat_AssignDate (struct Date *DateDst,struct Date *DateSrc)
DateDst->Month = DateSrc->Month; DateDst->Month = DateSrc->Month;
DateDst->Day = DateSrc->Day; DateDst->Day = DateSrc->Day;
DateDst->Week = DateSrc->Week; DateDst->Week = DateSrc->Week;
Str_Copy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD,Dat_LENGTH_YYYYMMDD); Str_Copy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD,
Dat_LENGTH_YYYYMMDD);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -677,7 +677,7 @@ void Deg_ShowDegsOfCurrentCtr (void)
/********************* List current degrees for edition **********************/ /********************* List current degrees for edition **********************/
/*****************************************************************************/ /*****************************************************************************/
#define Deg_MAX_LENGTH_WWW_ON_SCREEN 10 #define Deg_MAX_LENGTH_WWW_ON_SCREEN 15
static void Deg_ListDegreesForEdition (void) static void Deg_ListDegreesForEdition (void)
{ {
@ -688,7 +688,7 @@ static void Deg_ListDegreesForEdition (void)
struct DegreeType *DegTyp; struct DegreeType *DegTyp;
struct Degree *Deg; struct Degree *Deg;
unsigned NumDegTyp; unsigned NumDegTyp;
char WWW[Deg_MAX_LENGTH_WWW_ON_SCREEN+1]; char WWW[Cns_MAX_LENGTH_WWW + 1];
struct UsrData UsrDat; struct UsrData UsrDat;
bool ICanEdit; bool ICanEdit;
Deg_StatusTxt_t StatusTxt; Deg_StatusTxt_t StatusTxt;
@ -822,13 +822,14 @@ static void Deg_ListDegreesForEdition (void)
} }
else else
{ {
Str_Copy (WWW,Deg->WWW,Deg_MAX_LENGTH_WWW_ON_SCREEN); Str_Copy (WWW,Deg->WWW,
Cns_MAX_LENGTH_WWW);
Str_LimitLengthHTMLStr (WWW,Deg_MAX_LENGTH_WWW_ON_SCREEN);
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\"" fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"DAT\" title=\"%s\">%s", " class=\"DAT\" title=\"%s\">"
"%s"
"</a>",
Deg->WWW,Deg->WWW,WWW); Deg->WWW,Deg->WWW,WWW);
if (strlen (Deg->WWW) > Deg_MAX_LENGTH_WWW_ON_SCREEN)
fprintf (Gbl.F.Out,"&hellip;");
fprintf (Gbl.F.Out,"</a>");
} }
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
@ -1737,13 +1738,16 @@ static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row)
Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]); Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
/***** Get degree short name (row[5]) *****/ /***** Get degree short name (row[5]) *****/
Str_Copy (Deg->ShrtName,row[5],Deg_MAX_LENGTH_DEGREE_SHRT_NAME); Str_Copy (Deg->ShrtName,row[5],
Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
/***** Get degree full name (row[6]) *****/ /***** Get degree full name (row[6]) *****/
Str_Copy (Deg->FullName,row[6],Deg_MAX_LENGTH_DEGREE_FULL_NAME); Str_Copy (Deg->FullName,row[6],
Deg_MAX_LENGTH_DEGREE_FULL_NAME);
/***** Get WWW (row[7]) *****/ /***** Get WWW (row[7]) *****/
Str_Copy (Deg->WWW,row[7],Cns_MAX_LENGTH_WWW); Str_Copy (Deg->WWW,row[7],
Cns_MAX_LENGTH_WWW);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1768,7 +1772,8 @@ void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg)
/***** Get the short name of this degree *****/ /***** Get the short name of this degree *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Deg->ShrtName,row[0],Deg_MAX_LENGTH_DEGREE_SHRT_NAME); Str_Copy (Deg->ShrtName,row[0],
Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -2006,7 +2011,8 @@ static void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFull
CurrentDegName,NewDegName); CurrentDegName,NewDegName);
/* Change current degree name in order to display it properly */ /* Change current degree name in order to display it properly */
Str_Copy (CurrentDegName,NewDegName,MaxLength); Str_Copy (CurrentDegName,NewDegName,
MaxLength);
} }
} }
else // The same name else // The same name
@ -2137,7 +2143,8 @@ void Deg_ChangeDegWWW (void)
{ {
/***** Update the table changing old WWW by new WWW *****/ /***** Update the table changing old WWW by new WWW *****/
Deg_UpdateDegWWWDB (Deg->DegCod,NewWWW); Deg_UpdateDegWWWDB (Deg->DegCod,NewWWW);
Str_Copy (Deg->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Deg->WWW,NewWWW,
Cns_MAX_LENGTH_WWW);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);
@ -2168,7 +2175,8 @@ void Deg_ChangeDegWWWInConfig (void)
{ {
/***** Update the table changing old WWW by new WWW *****/ /***** Update the table changing old WWW by new WWW *****/
Deg_UpdateDegWWWDB (Gbl.CurrentDeg.Deg.DegCod,NewWWW); Deg_UpdateDegWWWDB (Gbl.CurrentDeg.Deg.DegCod,NewWWW);
Str_Copy (Gbl.CurrentDeg.Deg.WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Gbl.CurrentDeg.Deg.WWW,NewWWW,
Cns_MAX_LENGTH_WWW);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);

View File

@ -43,9 +43,6 @@
#define Deg_MAX_LENGTH_DEGREE_SHRT_NAME 32 #define Deg_MAX_LENGTH_DEGREE_SHRT_NAME 32
#define Deg_MAX_LENGTH_DEGREE_FULL_NAME (128 - 1) #define Deg_MAX_LENGTH_DEGREE_FULL_NAME (128 - 1)
#define Deg_MAX_LENGTH_LOCATION_SHORT_NAME 32
#define Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR (Deg_MAX_LENGTH_LOCATION_SHORT_NAME * Str_MAX_LENGTH_SPEC_CHAR_HTML)
/*****************************************************************************/ /*****************************************************************************/
/******************************* Public types ********************************/ /******************************* Public types ********************************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -650,7 +650,8 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the name of the degree type (row[0]) */ /* Get the name of the degree type (row[0]) */
Str_Copy (DegTyp->DegTypName,row[0],Deg_MAX_LENGTH_DEGREE_TYPE_NAME); Str_Copy (DegTyp->DegTypName,row[0],
Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
/* Count number of degrees of this type */ /* Count number of degrees of this type */
DegTyp->NumDegs = DT_CountNumDegsOfType (DegTyp->DegTypCod); DegTyp->NumDegs = DT_CountNumDegsOfType (DegTyp->DegTypCod);
@ -785,7 +786,8 @@ void DT_RenameDegreeType (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (DegTyp->DegTypName,NewNameDegTyp,Deg_MAX_LENGTH_DEGREE_TYPE_NAME); Str_Copy (DegTyp->DegTypName,NewNameDegTyp,
Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
DT_ReqEditDegreeTypes (); DT_ReqEditDegreeTypes ();
} }

View File

@ -351,13 +351,16 @@ void Dpt_GetListDepartments (long InsCod)
Lay_ShowErrorAndExit ("Wrong code of institution."); Lay_ShowErrorAndExit ("Wrong code of institution.");
/* Get the short name of the department (row[2]) */ /* Get the short name of the department (row[2]) */
Str_Copy (Dpt->ShrtName,row[2],MAX_LENGTH_DEPARTMENT_SHRT_NAME); Str_Copy (Dpt->ShrtName,row[2],
Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME);
/* Get the full name of the department (row[3]) */ /* Get the full name of the department (row[3]) */
Str_Copy (Dpt->FullName,row[3],MAX_LENGTH_DEPARTMENT_FULL_NAME); Str_Copy (Dpt->FullName,row[3],
Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME);
/* Get the URL of the department (row[4]) */ /* Get the URL of the department (row[4]) */
Str_Copy (Dpt->WWW,row[4],Cns_MAX_LENGTH_WWW); Str_Copy (Dpt->WWW,row[4],
Cns_MAX_LENGTH_WWW);
/* Get number of teachers in this department (row[5]) */ /* Get number of teachers in this department (row[5]) */
if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1) if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1)
@ -392,9 +395,9 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt)
if (Dpt->DptCod == 0) if (Dpt->DptCod == 0)
{ {
Str_Copy (Dpt->ShrtName,Txt_Another_department, Str_Copy (Dpt->ShrtName,Txt_Another_department,
MAX_LENGTH_DEPARTMENT_SHRT_NAME); Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME);
Str_Copy (Dpt->FullName,Txt_Another_department, Str_Copy (Dpt->FullName,Txt_Another_department,
MAX_LENGTH_DEPARTMENT_FULL_NAME); Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME);
} }
else if (Dpt->DptCod > 0) else if (Dpt->DptCod > 0)
{ {
@ -426,13 +429,16 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt)
Dpt->InsCod = Str_ConvertStrCodToLongCod (row[0]); Dpt->InsCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get the short name of the department (row[1]) */ /* Get the short name of the department (row[1]) */
Str_Copy (Dpt->ShrtName,row[1],MAX_LENGTH_DEPARTMENT_SHRT_NAME); Str_Copy (Dpt->ShrtName,row[1],
Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME);
/* Get the full name of the department (row[2]) */ /* Get the full name of the department (row[2]) */
Str_Copy (Dpt->FullName,row[2],MAX_LENGTH_DEPARTMENT_FULL_NAME); Str_Copy (Dpt->FullName,row[2],
Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME);
/* Get the URL of the department (row[3]) */ /* Get the URL of the department (row[3]) */
Str_Copy (Dpt->WWW,row[3],Cns_MAX_LENGTH_WWW); Str_Copy (Dpt->WWW,row[3],
Cns_MAX_LENGTH_WWW);
/* Get number of teachers in this department (row[4]) */ /* Get number of teachers in this department (row[4]) */
if (sscanf (row[4],"%u",&Dpt->NumTchs) != 1) if (sscanf (row[4],"%u",&Dpt->NumTchs) != 1)
@ -556,7 +562,7 @@ static void Dpt_ListDepartmentsForEdition (void)
" maxlength=\"%u\" value=\"%s\"" " maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_SHORT_NAME\"" " class=\"INPUT_SHORT_NAME\""
" onchange=\"document.getElementById('%s').submit();\" />", " onchange=\"document.getElementById('%s').submit();\" />",
MAX_LENGTH_DEPARTMENT_SHRT_NAME,Dpt->ShrtName,Gbl.Form.Id); Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME,Dpt->ShrtName,Gbl.Form.Id);
Act_FormEnd (); Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
@ -568,7 +574,7 @@ static void Dpt_ListDepartmentsForEdition (void)
" maxlength=\"%u\" value=\"%s\"" " maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_FULL_NAME\"" " class=\"INPUT_FULL_NAME\""
" onchange=\"document.getElementById('%s').submit();\" />", " onchange=\"document.getElementById('%s').submit();\" />",
MAX_LENGTH_DEPARTMENT_FULL_NAME,Dpt->FullName,Gbl.Form.Id); Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME,Dpt->FullName,Gbl.Form.Id);
Act_FormEnd (); Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
@ -720,7 +726,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
const char *FieldName = NULL; // Initialized to avoid warning const char *FieldName = NULL; // Initialized to avoid warning
size_t MaxLength = 0; // Initialized to avoid warning size_t MaxLength = 0; // Initialized to avoid warning
char *CurrentDptName = NULL; // Initialized to avoid warning char *CurrentDptName = NULL; // Initialized to avoid warning
char NewDptName[MAX_LENGTH_DEPARTMENT_FULL_NAME + 1]; char NewDptName[Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME + 1];
Dpt = &Gbl.Dpts.EditingDpt; Dpt = &Gbl.Dpts.EditingDpt;
switch (ShrtOrFullName) switch (ShrtOrFullName)
@ -728,13 +734,13 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
case Cns_SHRT_NAME: case Cns_SHRT_NAME:
ParamName = "ShortName"; ParamName = "ShortName";
FieldName = "ShortName"; FieldName = "ShortName";
MaxLength = MAX_LENGTH_DEPARTMENT_SHRT_NAME; MaxLength = Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME;
CurrentDptName = Dpt->ShrtName; CurrentDptName = Dpt->ShrtName;
break; break;
case Cns_FULL_NAME: case Cns_FULL_NAME:
ParamName = "FullName"; ParamName = "FullName";
FieldName = "FullName"; FieldName = "FullName";
MaxLength = MAX_LENGTH_DEPARTMENT_FULL_NAME; MaxLength = Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME;
CurrentDptName = Dpt->FullName; CurrentDptName = Dpt->FullName;
break; break;
} }
@ -791,7 +797,8 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (CurrentDptName,NewDptName,MaxLength); Str_Copy (CurrentDptName,NewDptName,
MaxLength);
Dpt_EditDepartments (); Dpt_EditDepartments ();
} }
@ -852,7 +859,8 @@ void Dpt_ChangeDptWWW (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Dpt->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Dpt->WWW,NewWWW,
Cns_MAX_LENGTH_WWW);
Dpt_EditDepartments (); Dpt_EditDepartments ();
} }
@ -928,7 +936,7 @@ static void Dpt_PutFormToCreateDepartment (void)
" class=\"INPUT_SHORT_NAME\"" " class=\"INPUT_SHORT_NAME\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
MAX_LENGTH_DEPARTMENT_SHRT_NAME,Dpt->ShrtName); Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME,Dpt->ShrtName);
/***** Department full name *****/ /***** Department full name *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -937,7 +945,7 @@ static void Dpt_PutFormToCreateDepartment (void)
" class=\"INPUT_FULL_NAME\"" " class=\"INPUT_FULL_NAME\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
MAX_LENGTH_DEPARTMENT_FULL_NAME,Dpt->FullName); Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME,Dpt->FullName);
/***** Department WWW *****/ /***** Department WWW *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -1017,10 +1025,10 @@ void Dpt_RecFormNewDpt (void)
Dpt->InsCod = Ins_GetAndCheckParamOtherInsCod (); Dpt->InsCod = Ins_GetAndCheckParamOtherInsCod ();
/* Get department short name */ /* Get department short name */
Par_GetParToText ("ShortName",Dpt->ShrtName,MAX_LENGTH_DEPARTMENT_SHRT_NAME); Par_GetParToText ("ShortName",Dpt->ShrtName,Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME);
/* Get department full name */ /* Get department full name */
Par_GetParToText ("FullName",Dpt->FullName,MAX_LENGTH_DEPARTMENT_FULL_NAME); Par_GetParToText ("FullName",Dpt->FullName,Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME);
/* Get department WWW */ /* Get department WWW */
Par_GetParToText ("WWW",Dpt->WWW,Cns_MAX_LENGTH_WWW); Par_GetParToText ("WWW",Dpt->WWW,Cns_MAX_LENGTH_WWW);

View File

@ -31,15 +31,15 @@
/************************** Public types and constants ***********************/ /************************** Public types and constants ***********************/
/*****************************************************************************/ /*****************************************************************************/
#define MAX_LENGTH_DEPARTMENT_SHRT_NAME 32 #define Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME 32
#define MAX_LENGTH_DEPARTMENT_FULL_NAME (256 - 1) #define Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME (256 - 1)
struct Department struct Department
{ {
long DptCod; long DptCod;
long InsCod; long InsCod;
char ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME + 1]; char ShrtName[Dpt_MAX_LENGTH_DEPARTMENT_SHRT_NAME + 1];
char FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME + 1]; char FullName[Dpt_MAX_LENGTH_DEPARTMENT_FULL_NAME + 1];
char WWW[Cns_MAX_LENGTH_WWW + 1]; char WWW[Cns_MAX_LENGTH_WWW + 1];
unsigned NumTchs; unsigned NumTchs;
}; };

View File

@ -207,25 +207,25 @@ static long Exa_GetParamsExamAnnouncement (void)
static void Exa_AllocMemExamAnnouncement (void) static void Exa_AllocMemExamAnnouncement (void)
{ {
if ((Gbl.ExamAnns.ExaDat.Place = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.Place = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnns.ExaDat.Mode = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.Mode = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnns.ExaDat.Structure = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.Structure = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnns.ExaDat.DocRequired = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.DocRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnns.ExaDat.MatRequired = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.MatRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnns.ExaDat.MatAllowed = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.MatAllowed = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
if ((Gbl.ExamAnns.ExaDat.OtherInfo = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((Gbl.ExamAnns.ExaDat.OtherInfo = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement."); Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
} }
@ -946,7 +946,8 @@ static void Exa_GetDataExamAnnouncementFromDB (void)
Lay_ShowErrorAndExit ("Wrong year."); Lay_ShowErrorAndExit ("Wrong year.");
/* Exam session (row[4]) */ /* Exam session (row[4]) */
Str_Copy (Gbl.ExamAnns.ExaDat.Session,row[4],Cns_MAX_BYTES_STRING); Str_Copy (Gbl.ExamAnns.ExaDat.Session,row[4],
Cns_MAX_BYTES_STRING);
/* Date of exam announcement (row[5]) */ /* Date of exam announcement (row[5]) */
if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u", if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u",
@ -967,25 +968,32 @@ static void Exa_GetDataExamAnnouncementFromDB (void)
Lay_ShowErrorAndExit ("Wrong duration of exam."); Lay_ShowErrorAndExit ("Wrong duration of exam.");
/* Place (row[8]) */ /* Place (row[8]) */
Str_Copy (Gbl.ExamAnns.ExaDat.Place,row[8],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.Place,row[8],
Cns_MAX_BYTES_TEXT);
/* Exam mode (row[9]) */ /* Exam mode (row[9]) */
Str_Copy (Gbl.ExamAnns.ExaDat.Mode,row[9],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.Mode,row[9],
Cns_MAX_BYTES_TEXT);
/* Structure (row[10]) */ /* Structure (row[10]) */
Str_Copy (Gbl.ExamAnns.ExaDat.Structure,row[10],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.Structure,row[10],
Cns_MAX_BYTES_TEXT);
/* Documentation required (row[11]) */ /* Documentation required (row[11]) */
Str_Copy (Gbl.ExamAnns.ExaDat.DocRequired,row[11],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.DocRequired,row[11],
Cns_MAX_BYTES_TEXT);
/* Material required (row[12]) */ /* Material required (row[12]) */
Str_Copy (Gbl.ExamAnns.ExaDat.MatRequired,row[12],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.MatRequired,row[12],
Cns_MAX_BYTES_TEXT);
/* Material allowed (row[13]) */ /* Material allowed (row[13]) */
Str_Copy (Gbl.ExamAnns.ExaDat.MatAllowed,row[13],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.MatAllowed,row[13],
Cns_MAX_BYTES_TEXT);
/* Other information for students (row[14]) */ /* Other information for students (row[14]) */
Str_Copy (Gbl.ExamAnns.ExaDat.OtherInfo,row[14],Cns_MAX_BYTES_TEXT); Str_Copy (Gbl.ExamAnns.ExaDat.OtherInfo,row[14],
Cns_MAX_BYTES_TEXT);
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);

View File

@ -326,7 +326,9 @@ void Fil_CreateUpdateFile (const char CurrentName[PATH_MAX + 1],
{ {
size_t LengthFileRoot = Str_GetLengthRootFileName (CurrentName); size_t LengthFileRoot = Str_GetLengthRootFileName (CurrentName);
Str_Copy (NewName,CurrentName,LengthFileRoot); Str_Copy (NewName,CurrentName,
PATH_MAX);
NewName[LengthFileRoot] = '\0';
sprintf (OldName,"%s%s",NewName,ExtensionOldName); sprintf (OldName,"%s%s",NewName,ExtensionOldName);
Str_Concat (NewName,".new",PATH_MAX); Str_Concat (NewName,".new",PATH_MAX);

View File

@ -1523,7 +1523,9 @@ static void Brw_WriteFileName (unsigned Level,bool IsPublic,
static void Brw_GetFileNameToShow (Brw_FileBrowser_t FileBrowser,unsigned Level, static void Brw_GetFileNameToShow (Brw_FileBrowser_t FileBrowser,unsigned Level,
Brw_FileType_t FileType, Brw_FileType_t FileType,
const char *FileName,char *FileNameToShow); const char *FileName,char *FileNameToShow);
static void Brw_LimitLengthFileNameToShow (Brw_FileType_t FileType,const char *FileName,char *FileNameToShow); static void Brw_LimitLengthFileNameToShow (Brw_FileType_t FileType,
const char FileName[NAME_MAX + 1],
char FileNameToShow[NAME_MAX + 1]);
static void Brw_WriteDatesAssignment (void); static void Brw_WriteDatesAssignment (void);
static void Brw_WriteFileSizeAndDate (struct FileMetadata *FileMetadata); static void Brw_WriteFileSizeAndDate (struct FileMetadata *FileMetadata);
static void Brw_WriteFileOrFolderPublisher (unsigned Level,unsigned long UsrCod); static void Brw_WriteFileOrFolderPublisher (unsigned Level,unsigned long UsrCod);
@ -2606,7 +2608,8 @@ static void Brw_SetPathFileBrowser (void)
case Brw_SHOW_MARKS_CRS: case Brw_SHOW_MARKS_CRS:
case Brw_ADMI_MARKS_CRS: case Brw_ADMI_MARKS_CRS:
Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder, Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
Gbl.CurrentCrs.PathPriv,PATH_MAX); Gbl.CurrentCrs.PathPriv,
PATH_MAX);
break; break;
case Brw_SHOW_DOCUM_GRP: case Brw_SHOW_DOCUM_GRP:
case Brw_ADMI_DOCUM_GRP: case Brw_ADMI_DOCUM_GRP:
@ -2657,7 +2660,8 @@ static void Brw_SetPathFileBrowser (void)
break; break;
case Brw_ADMI_BRIEF_USR: case Brw_ADMI_BRIEF_USR:
Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder, Str_Copy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
Gbl.Usrs.Me.PathDir,PATH_MAX); Gbl.Usrs.Me.PathDir,
PATH_MAX);
break; break;
default: default:
return; return;
@ -4798,7 +4802,8 @@ void Brw_CreateDirDownloadTmp (void)
if (NumDir) if (NumDir)
sprintf (Gbl.FileBrowser.TmpPubDir,"%s_%u",Gbl.UniqueNameEncrypted,NumDir); sprintf (Gbl.FileBrowser.TmpPubDir,"%s_%u",Gbl.UniqueNameEncrypted,NumDir);
else else
Str_Copy (Gbl.FileBrowser.TmpPubDir,Gbl.UniqueNameEncrypted,NAME_MAX); Str_Copy (Gbl.FileBrowser.TmpPubDir,Gbl.UniqueNameEncrypted,
NAME_MAX);
sprintf (PathPubDirTmp,"%s/%s",PathFileBrowserTmpPubl,Gbl.FileBrowser.TmpPubDir); sprintf (PathPubDirTmp,"%s/%s",PathFileBrowserTmpPubl,Gbl.FileBrowser.TmpPubDir);
if (mkdir (PathPubDirTmp,(mode_t) 0xFFF)) if (mkdir (PathPubDirTmp,(mode_t) 0xFFF))
Lay_ShowErrorAndExit ("Can not create a temporary folder for download."); Lay_ShowErrorAndExit ("Can not create a temporary folder for download.");
@ -5207,7 +5212,8 @@ static bool Brw_WriteRowFileBrowser (unsigned Level,Brw_ExpandTree_t ExpandTree,
{ {
if (Level == 1) // Main folder of the assignment if (Level == 1) // Main folder of the assignment
{ {
Str_Copy (Gbl.FileBrowser.Asg.Folder,FileName,Asg_MAX_LENGTH_FOLDER); Str_Copy (Gbl.FileBrowser.Asg.Folder,FileName,
Asg_MAX_LENGTH_FOLDER);
Asg_GetDataOfAssignmentByFolder (&Gbl.FileBrowser.Asg); Asg_GetDataOfAssignmentByFolder (&Gbl.FileBrowser.Asg);
// The data of this assignment remains in Gbl.FileBrowser.Asg // The data of this assignment remains in Gbl.FileBrowser.Asg
// for all subsequent rows with Level > 1 (files or folders inside this folder), // for all subsequent rows with Level > 1 (files or folders inside this folder),
@ -5343,8 +5349,8 @@ void Brw_SetFullPathInTree (const char *PathInTreeUntilFileOrFolder,const char *
sprintf (Gbl.FileBrowser.Priv.FullPathInTree,"%s/%s", sprintf (Gbl.FileBrowser.Priv.FullPathInTree,"%s/%s",
PathInTreeUntilFileOrFolder,FilFolLnkName); PathInTreeUntilFileOrFolder,FilFolLnkName);
else // It's the root folder else // It's the root folder
Str_Copy (Gbl.FileBrowser.Priv.FullPathInTree, Str_Copy (Gbl.FileBrowser.Priv.FullPathInTree,PathInTreeUntilFileOrFolder,
PathInTreeUntilFileOrFolder,PATH_MAX); PATH_MAX);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -5985,19 +5991,24 @@ static void Brw_GetFileNameToShow (Brw_FileBrowser_t FileBrowser,unsigned Level,
/*****************************************************************************/ /*****************************************************************************/
/*************** Limit the length of the filename to be shown ****************/ /*************** Limit the length of the filename to be shown ****************/
/*****************************************************************************/ /*****************************************************************************/
// FileNameToShow must have at least NAME_MAX+1 bytes
static void Brw_LimitLengthFileNameToShow (Brw_FileType_t FileType,const char *FileName,char *FileNameToShow) static void Brw_LimitLengthFileNameToShow (Brw_FileType_t FileType,
const char FileName[NAME_MAX + 1],
char FileNameToShow[NAME_MAX + 1])
{ {
size_t NumCharsToCopy; size_t NumChars;
/***** Limit length of the name of the file *****/ /***** Copy file name *****/
NumCharsToCopy = strlen (FileName); Str_Copy (FileNameToShow,FileName,
NAME_MAX);
/***** Remove .url if link *****/
NumChars = strlen (FileNameToShow);
if (FileType == Brw_IS_LINK) // It's a link (URL inside a .url file) if (FileType == Brw_IS_LINK) // It's a link (URL inside a .url file)
NumCharsToCopy -= 4; // Remove .url NumChars -= 4; // Remove .url
if (NumCharsToCopy > NAME_MAX) FileNameToShow[NumChars] = '\0';
NumCharsToCopy = NAME_MAX;
Str_Copy (FileNameToShow,FileName,NumCharsToCopy); /***** Limit length of the file name to show *****/
Str_LimitLengthHTMLStr (FileNameToShow,60); Str_LimitLengthHTMLStr (FileNameToShow,60);
} }
@ -6217,7 +6228,7 @@ void Brw_RemFileFromTree (void)
extern const char *Txt_You_can_not_remove_this_file_or_link; extern const char *Txt_You_can_not_remove_this_file_or_link;
char Path[PATH_MAX+1]; char Path[PATH_MAX+1];
struct stat FileStatus; struct stat FileStatus;
char FileNameToShow[NAME_MAX+1]; char FileNameToShow[NAME_MAX + 1];
/***** Get parameters related to file browser *****/ /***** Get parameters related to file browser *****/
Brw_GetParAndInitFileBrowser (); Brw_GetParAndInitFileBrowser ();
@ -6665,7 +6676,7 @@ static bool Brw_GetMyClipboard (void)
char Query[256]; char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
char PathUntilFileName[PATH_MAX+1]; char PathUntilFileName[PATH_MAX + 1];
unsigned NumRows; unsigned NumRows;
unsigned UnsignedNum; unsigned UnsignedNum;
@ -6707,7 +6718,8 @@ static bool Brw_GetMyClipboard (void)
Gbl.FileBrowser.Clipboard.FileType = (Brw_FileType_t) UnsignedNum; Gbl.FileBrowser.Clipboard.FileType = (Brw_FileType_t) UnsignedNum;
/* Get file path (row[4]) */ /* Get file path (row[4]) */
Str_Copy (Gbl.FileBrowser.Clipboard.Path,row[4],PATH_MAX); Str_Copy (Gbl.FileBrowser.Clipboard.Path,row[4],
PATH_MAX);
Str_SplitFullPathIntoPathAndFileName (Gbl.FileBrowser.Clipboard.Path, Str_SplitFullPathIntoPathAndFileName (Gbl.FileBrowser.Clipboard.Path,
PathUntilFileName, PathUntilFileName,
Gbl.FileBrowser.Clipboard.FileName); Gbl.FileBrowser.Clipboard.FileName);
@ -6902,7 +6914,8 @@ static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char
// if (strcmp (Path,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type])) // Don't insert root folder // if (strcmp (Path,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type])) // Don't insert root folder
/***** Make a copy to keep Path unchanged *****/ /***** Make a copy to keep Path unchanged *****/
Str_Copy (CopyOfPath,Path,PATH_MAX); Str_Copy (CopyOfPath,Path,
PATH_MAX);
/***** Insert paths in table of expanded folders if they are not yet there *****/ /***** Insert paths in table of expanded folders if they are not yet there *****/
do do
@ -7632,12 +7645,12 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
extern const char *Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_you_can_not_paste_a_file_here_of_a_type_other_than_HTML; extern const char *Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_you_can_not_paste_a_file_here_of_a_type_other_than_HTML;
Brw_FileType_t FileType; Brw_FileType_t FileType;
char PathUntilFileNameOrg[PATH_MAX+1]; char PathUntilFileNameOrg[PATH_MAX + 1];
char FileNameOrg[NAME_MAX+1]; char FileNameOrg[NAME_MAX + 1];
char FileNameToShow[NAME_MAX+1]; char FileNameToShow[NAME_MAX + 1];
char PathInFolderOrg[PATH_MAX+1]; char PathInFolderOrg[PATH_MAX + 1];
char PathDstInTreeWithFile[PATH_MAX+1]; char PathDstInTreeWithFile[PATH_MAX + 1];
char PathDstWithFile[PATH_MAX+1]; char PathDstWithFile[PATH_MAX + 1];
struct stat FileStatus; struct stat FileStatus;
struct dirent **FileList; struct dirent **FileList;
bool AdminMarks; bool AdminMarks;
@ -7670,7 +7683,8 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
if (LevelOrg == 0) // Origin of copy is the root folder, if (LevelOrg == 0) // Origin of copy is the root folder,
// for example "sha" // for example "sha"
// ==> do not copy the root folder itself into destination // ==> do not copy the root folder itself into destination
Str_Copy (PathDstInTreeWithFile,PathDstInTree,PATH_MAX); Str_Copy (PathDstInTreeWithFile,PathDstInTree,
PATH_MAX);
else // Origin of copy is a file or folder inside the root folder else // Origin of copy is a file or folder inside the root folder
// for example "sha/folder1/file1" // for example "sha/folder1/file1"
sprintf (PathDstInTreeWithFile,"%s/%s",PathDstInTree,FileNameOrg); sprintf (PathDstInTreeWithFile,"%s/%s",PathDstInTree,FileNameOrg);
@ -8551,12 +8565,10 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
} }
} }
else // Empty filename else // Empty filename
Str_Copy (Gbl.Message,Txt_UPLOAD_FILE_You_must_specify_the_file_NO_HTML, sprintf (Gbl.Message,"%s",Txt_UPLOAD_FILE_You_must_specify_the_file_NO_HTML);
Lay_MAX_BYTES_ALERT);
} }
else // I do not have permission to create files here else // I do not have permission to create files here
Str_Copy (Gbl.Message,Txt_UPLOAD_FILE_Forbidden_NO_HTML, sprintf (Gbl.Message,"%s",Txt_UPLOAD_FILE_Forbidden_NO_HTML);
Lay_MAX_BYTES_ALERT);
return UploadSucessful; return UploadSucessful;
} }
@ -8602,7 +8614,8 @@ void Brw_RecLinkFileBrowser (void)
Name given by me: intel-architectures.pdf Name given by me: intel-architectures.pdf
File in swad: intel-architectures.pdf.url File in swad: intel-architectures.pdf.url
*/ */
Str_Copy (URLWithoutEndingSlash,Gbl.FileBrowser.NewFilFolLnkName,PATH_MAX); Str_Copy (URLWithoutEndingSlash,Gbl.FileBrowser.NewFilFolLnkName,
PATH_MAX);
else else
/* /*
Gbl.FileBrowser.NewFilFolLnkName is empty Gbl.FileBrowser.NewFilFolLnkName is empty
@ -8611,7 +8624,8 @@ void Brw_RecLinkFileBrowser (void)
URL: http://www.intel.es/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-manual-325462.pdf URL: http://www.intel.es/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-manual-325462.pdf
File in swad: 64-ia-32-architectures-software-developer-manual-325462.pdf.url File in swad: 64-ia-32-architectures-software-developer-manual-325462.pdf.url
*/ */
Str_Copy (URLWithoutEndingSlash,URL,PATH_MAX); Str_Copy (URLWithoutEndingSlash,URL,
PATH_MAX);
/* Remove possible final '/' from URL */ /* Remove possible final '/' from URL */
if (URLWithoutEndingSlash[LengthURL - 1] == '/') if (URLWithoutEndingSlash[LengthURL - 1] == '/')
@ -8966,7 +8980,7 @@ void Brw_ShowFileMetadata (void)
extern const char *Txt_Save_file_properties; extern const char *Txt_Save_file_properties;
struct FileMetadata FileMetadata; struct FileMetadata FileMetadata;
struct UsrData PublisherUsrDat; struct UsrData PublisherUsrDat;
char FileNameToShow[NAME_MAX+1]; char FileNameToShow[NAME_MAX + 1];
char URL[PATH_MAX+1]; char URL[PATH_MAX+1];
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1]; char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1];
bool Found; bool Found;
@ -8976,7 +8990,7 @@ void Brw_ShowFileMetadata (void)
bool ICanChangePublic = false; bool ICanChangePublic = false;
bool FileHasPublisher; bool FileHasPublisher;
bool ShowPhoto; bool ShowPhoto;
char PhotoURL[PATH_MAX+1]; char PhotoURL[PATH_MAX + 1];
Brw_License_t License; Brw_License_t License;
/***** Get parameters related to file browser *****/ /***** Get parameters related to file browser *****/
@ -9968,7 +9982,8 @@ void Brw_GetFileMetadataByPath (struct FileMetadata *FileMetadata)
FileMetadata->FileType = (Brw_FileType_t) UnsignedNum; FileMetadata->FileType = (Brw_FileType_t) UnsignedNum;
/* Get path (row[6]) */ /* Get path (row[6]) */
Str_Copy (FileMetadata->FullPathInTree,row[6],PATH_MAX); Str_Copy (FileMetadata->FullPathInTree,row[6],
PATH_MAX);
Str_SplitFullPathIntoPathAndFileName (FileMetadata->FullPathInTree, Str_SplitFullPathIntoPathAndFileName (FileMetadata->FullPathInTree,
FileMetadata->PathInTreeUntilFilFolLnk, FileMetadata->PathInTreeUntilFilFolLnk,
FileMetadata->FilFolLnkName); FileMetadata->FilFolLnkName);
@ -10097,7 +10112,8 @@ void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata)
FileMetadata->FileType = (Brw_FileType_t) UnsignedNum; FileMetadata->FileType = (Brw_FileType_t) UnsignedNum;
/* Get path (row[6]) */ /* Get path (row[6]) */
Str_Copy (FileMetadata->FullPathInTree,row[6],PATH_MAX); Str_Copy (FileMetadata->FullPathInTree,row[6],
PATH_MAX);
Str_SplitFullPathIntoPathAndFileName (FileMetadata->FullPathInTree, Str_SplitFullPathIntoPathAndFileName (FileMetadata->FullPathInTree,
FileMetadata->PathInTreeUntilFilFolLnk, FileMetadata->PathInTreeUntilFilFolLnk,
FileMetadata->FilFolLnkName); FileMetadata->FilFolLnkName);
@ -11158,7 +11174,8 @@ void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],cha
Brw_GetFileMetadataByCod (&FileMetadata); Brw_GetFileMetadataByCod (&FileMetadata);
/***** Copy file name into summary string *****/ /***** Copy file name into summary string *****/
Str_Copy (SummaryStr,FileMetadata.FilFolLnkName,Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,FileMetadata.FilFolLnkName,
Cns_MAX_BYTES_TEXT);
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -11320,7 +11337,7 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row)
const char *CrsShortName; const char *CrsShortName;
const char *BgColor; const char *BgColor;
const char *Title; const char *Title;
char FileNameToShow[NAME_MAX+1]; char FileNameToShow[NAME_MAX + 1];
/* /*
row[ 0] = FilCod row[ 0] = FilCod
row[ 1] = PathFromRoot row[ 1] = PathFromRoot

View File

@ -114,10 +114,10 @@ struct FileMetadata
long Cod; // Code of institution, centre, degree, course or group long Cod; // Code of institution, centre, degree, course or group
long ZoneUsrCod; long ZoneUsrCod;
long PublisherUsrCod; long PublisherUsrCod;
char FullPathInTree[PATH_MAX+1]; char FullPathInTree[PATH_MAX + 1];
// FullPathInTree is splitted as PathInTreeUntilFilFolLnk/FilFolLnkName // FullPathInTree is splitted as PathInTreeUntilFilFolLnk/FilFolLnkName
char PathInTreeUntilFilFolLnk[PATH_MAX+1]; // Path in tree, without ending '/', until file, folder or link name char PathInTreeUntilFilFolLnk[PATH_MAX + 1]; // Path in tree, without ending '/', until file, folder or link name
char FilFolLnkName[NAME_MAX+1]; // File, folder or link name char FilFolLnkName[NAME_MAX + 1]; // File, folder or link name
bool IsHidden; bool IsHidden;
bool IsPublic; bool IsPublic;
Brw_License_t License; Brw_License_t License;

View File

@ -265,7 +265,7 @@ static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod);
static long For_InsertForumThread (For_ForumType_t ForumType,long FirstPstCod); static long For_InsertForumThread (For_ForumType_t ForumType,long FirstPstCod);
static void For_RemoveThreadOnly (long ThrCod); static void For_RemoveThreadOnly (long ThrCod);
static void For_RemoveThreadAndItsPsts (long ThrCod); static void For_RemoveThreadAndItsPsts (long ThrCod);
static void For_GetThrSubject (long ThrCod,char *Subject,size_t MaxSize); static void For_GetThrSubject (long ThrCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1]);
static void For_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long LastPstCod); static void For_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long LastPstCod);
static void For_UpdateThrLastPst (long ThrCod,long LastPstCod); static void For_UpdateThrLastPst (long ThrCod,long LastPstCod);
static long For_GetLastPstCod (long ThrCod); static long For_GetLastPstCod (long ThrCod);
@ -276,16 +276,18 @@ static unsigned For_GetNumOfWritersInThr (long ThrCod);
static unsigned For_GetNumPstsInThr (long ThrCod); static unsigned For_GetNumPstsInThr (long ThrCod);
static unsigned For_GetNumMyPstInThr (long ThrCod); static unsigned For_GetNumMyPstInThr (long ThrCod);
static time_t For_GetThrReadTime (long ThrCod); static time_t For_GetThrReadTime (long ThrCod);
static void For_ShowThreadPosts (long ThrCod,char *LastSubject); static void For_ShowThreadPosts (long ThrCod,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1]);
static void For_PutIconsForums (void); static void For_PutIconsForums (void);
static void For_WriteNumPsts (unsigned NumPsts); static void For_WriteNumPsts (unsigned NumPsts);
static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long PstCod, static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long PstCod,
bool LastPst,char *LastSubject, bool LastPst,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1],
bool NewPst,bool ICanModerateForum); bool NewPst,bool ICanModerateForum);
static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC, static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
char *Subject,char *Content,struct Image *Image); char Subject[Cns_MAX_BYTES_SUBJECT + 1],
char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
struct Image *Image);
static void For_WriteNumberOfPosts (For_ForumType_t ForumType,long UsrCod); static void For_WriteNumberOfPosts (For_ForumType_t ForumType,long UsrCod);
static void For_PutParamWhichForum (void); static void For_PutParamWhichForum (void);
@ -661,7 +663,7 @@ static void For_RemoveThreadAndItsPsts (long ThrCod)
/********************* Get the thread subject from a thread ******************/ /********************* Get the thread subject from a thread ******************/
/*****************************************************************************/ /*****************************************************************************/
static void For_GetThrSubject (long ThrCod,char *Subject,size_t MaxSize) static void For_GetThrSubject (long ThrCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1])
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -676,7 +678,8 @@ static void For_GetThrSubject (long ThrCod,char *Subject,size_t MaxSize)
/***** Write the subject of the thread *****/ /***** Write the subject of the thread *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Subject,row[0],MaxSize); Str_Copy (Subject,row[0],
Cns_MAX_BYTES_SUBJECT);
Str_LimitLengthHTMLStr (Subject,20); Str_LimitLengthHTMLStr (Subject,20);
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -942,7 +945,7 @@ void For_RemoveUsrFromReadThrs (long UsrCod)
/****************************** Show forum posts *****************************/ /****************************** Show forum posts *****************************/
/*****************************************************************************/ /*****************************************************************************/
static void For_ShowThreadPosts (long ThrCod,char *LastSubject) static void For_ShowThreadPosts (long ThrCod,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1])
{ {
extern const char *Hlp_SOCIAL_Forums; extern const char *Hlp_SOCIAL_Forums;
extern const char *Txt_Thread; extern const char *Txt_Thread;
@ -954,7 +957,8 @@ static void For_ShowThreadPosts (long ThrCod,char *LastSubject)
char Query[1024]; char Query[1024];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRow,NumRows; unsigned long NumRow;
unsigned long NumRows;
unsigned NumPst = 0; // Initialized to avoid warning unsigned NumPst = 0; // Initialized to avoid warning
unsigned NumPsts; unsigned NumPsts;
time_t ReadTimeUTC; // Read time of thread for the current user time_t ReadTimeUTC; // Read time of thread for the current user
@ -1158,7 +1162,7 @@ static void For_WriteNumPsts (unsigned NumPsts)
/*****************************************************************************/ /*****************************************************************************/
static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long PstCod, static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long PstCod,
bool LastPst,char *LastSubject, bool LastPst,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1],
bool NewPst,bool ICanModerateForum) bool NewPst,bool ICanModerateForum)
{ {
extern const char *Txt_unread_MESSAGE; extern const char *Txt_unread_MESSAGE;
@ -1172,9 +1176,9 @@ static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long Pst
extern const char *Txt_This_post_has_been_banned_probably_for_not_satisfy_the_rules_of_the_forums; extern const char *Txt_This_post_has_been_banned_probably_for_not_satisfy_the_rules_of_the_forums;
struct UsrData UsrDat; struct UsrData UsrDat;
time_t CreatTimeUTC; // Creation time of a post time_t CreatTimeUTC; // Creation time of a post
char OriginalContent[Cns_MAX_BYTES_LONG_TEXT+1]; char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1];
char Subject[Cns_MAX_BYTES_SUBJECT+1]; char Subject[Cns_MAX_BYTES_SUBJECT + 1];
char Content[Cns_MAX_BYTES_LONG_TEXT+1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
struct Image Image; struct Image Image;
bool Enabled; bool Enabled;
@ -1193,7 +1197,8 @@ static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long Pst
if (Enabled) if (Enabled)
/* Return this subject as last subject */ /* Return this subject as last subject */
Str_Copy (LastSubject,Subject,Cns_MAX_BYTES_SUBJECT); Str_Copy (LastSubject,Subject,
Cns_MAX_BYTES_SUBJECT);
/***** Put an icon with post status *****/ /***** Put an icon with post status *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
@ -1319,7 +1324,8 @@ static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long Pst
"<td class=\"MSG_TXT LEFT_TOP\">"); "<td class=\"MSG_TXT LEFT_TOP\">");
if (Enabled) if (Enabled)
{ {
Str_Copy (Content,OriginalContent,Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,OriginalContent,
Cns_MAX_BYTES_LONG_TEXT);
Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false); Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false);
/***** Show image *****/ /***** Show image *****/
@ -1342,7 +1348,9 @@ static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long Pst
/*****************************************************************************/ /*****************************************************************************/
static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC, static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
char *Subject, char *Content,struct Image *Image) char Subject[Cns_MAX_BYTES_SUBJECT + 1],
char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
struct Image *Image)
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -1370,10 +1378,12 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
*CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]); *CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
/****** Get subject (row[2]) *****/ /****** Get subject (row[2]) *****/
Str_Copy (Subject,row[2],Cns_MAX_BYTES_SUBJECT); Str_Copy (Subject,row[2],
Cns_MAX_BYTES_SUBJECT);
/****** Get location (row[3]) *****/ /****** Get location (row[3]) *****/
Str_Copy (Content,row[3],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[3],
Cns_MAX_BYTES_LONG_TEXT);
/****** Get image name (row[4]), title (row[5]) and URL (row[6]) *****/ /****** Get image name (row[4]), title (row[5]) and URL (row[6]) *****/
Img_GetImageNameTitleAndURLFromRow (row[4],row[5],row[6],Image); Img_GetImageNameTitleAndURLFromRow (row[4],row[5],row[6],Image);
@ -1412,7 +1422,8 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/***** Copy subject *****/ /***** Copy subject *****/
Str_Copy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,row[0],
Cns_MAX_BYTES_TEXT);
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -1424,7 +1435,11 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL) if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content."); Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[1],Length); if (Length)
Str_Copy (*ContentStr,row[1],
Length);
else
**ContentStr = '\0';
} }
} }
mysql_free_result (mysql_res); mysql_free_result (mysql_res);
@ -2191,7 +2206,8 @@ void For_SetForumName (For_ForumType_t ForumType,
switch (ForumType) switch (ForumType)
{ {
case For_FORUM_COURSE_USRS: case For_FORUM_COURSE_USRS:
Str_Copy (ForumName,Crs->ShrtName,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Crs->ShrtName,
For_MAX_BYTES_FORUM_NAME);
break; break;
case For_FORUM_COURSE_TCHS: case For_FORUM_COURSE_TCHS:
sprintf (ForumName,"%s%s",Crs->ShrtName, sprintf (ForumName,"%s%s",Crs->ShrtName,
@ -2199,7 +2215,8 @@ void For_SetForumName (For_ForumType_t ForumType,
Txt_only_teachers_NO_HTML[Language]); Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_DEGREE_USRS: case For_FORUM_DEGREE_USRS:
Str_Copy (ForumName,Deg->ShrtName,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Deg->ShrtName,
For_MAX_BYTES_FORUM_NAME);
break; break;
case For_FORUM_DEGREE_TCHS: case For_FORUM_DEGREE_TCHS:
sprintf (ForumName,"%s%s",Deg->ShrtName, sprintf (ForumName,"%s%s",Deg->ShrtName,
@ -2207,7 +2224,8 @@ void For_SetForumName (For_ForumType_t ForumType,
Txt_only_teachers_NO_HTML[Language]); Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_CENTRE_USRS: case For_FORUM_CENTRE_USRS:
Str_Copy (ForumName,Ctr->ShrtName,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Ctr->ShrtName,
For_MAX_BYTES_FORUM_NAME);
break; break;
case For_FORUM_CENTRE_TCHS: case For_FORUM_CENTRE_TCHS:
sprintf (ForumName,"%s%s",Ctr->ShrtName, sprintf (ForumName,"%s%s",Ctr->ShrtName,
@ -2215,7 +2233,8 @@ void For_SetForumName (For_ForumType_t ForumType,
Txt_only_teachers_NO_HTML[Language]); Txt_only_teachers_NO_HTML[Language]);
break; break;
case For_FORUM_INSTIT_USRS: case For_FORUM_INSTIT_USRS:
Str_Copy (ForumName,Ins->ShrtName,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Ins->ShrtName,
For_MAX_BYTES_FORUM_NAME);
break; break;
case For_FORUM_INSTIT_TCHS: case For_FORUM_INSTIT_TCHS:
sprintf (ForumName,"%s%s",Ins->ShrtName, sprintf (ForumName,"%s%s",Ins->ShrtName,
@ -2224,7 +2243,7 @@ void For_SetForumName (For_ForumType_t ForumType,
break; break;
case For_FORUM_GLOBAL_USRS: case For_FORUM_GLOBAL_USRS:
Str_Copy (ForumName,UseHTMLEntities ? Txt_General : Str_Copy (ForumName,UseHTMLEntities ? Txt_General :
Txt_General_NO_HTML[Language], Txt_General_NO_HTML[Language],
For_MAX_BYTES_FORUM_NAME); For_MAX_BYTES_FORUM_NAME);
break; break;
case For_FORUM_GLOBAL_TCHS: case For_FORUM_GLOBAL_TCHS:
@ -2235,7 +2254,8 @@ void For_SetForumName (For_ForumType_t ForumType,
Txt_only_teachers_NO_HTML[Language]); 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,For_MAX_BYTES_FORUM_NAME); Str_Copy (ForumName,Cfg_PLATFORM_SHORT_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, sprintf (ForumName,"%s%s",Cfg_PLATFORM_SHORT_NAME,
@ -3597,7 +3617,8 @@ void For_GetThrData (struct ForumThread *Thr)
Thr->WriteTime[For_LAST_MSG ] = Dat_GetUNIXTimeFromStr (row[5]); Thr->WriteTime[For_LAST_MSG ] = Dat_GetUNIXTimeFromStr (row[5]);
/***** Get the subject of this thread (row[6]) *****/ /***** Get the subject of this thread (row[6]) *****/
Str_Copy (Thr->Subject,row[6],Cns_MAX_BYTES_SUBJECT); Str_Copy (Thr->Subject,row[6],
Cns_MAX_BYTES_SUBJECT);
if (!Thr->Subject[0]) if (!Thr->Subject[0])
sprintf (Thr->Subject,"[%s]",Txt_no_subject); sprintf (Thr->Subject,"[%s]",Txt_no_subject);
@ -3794,7 +3815,7 @@ static long For_GetParamPstCod (void)
void For_ShowForumLevel2 (long ThrCod) void For_ShowForumLevel2 (long ThrCod)
{ {
char Subject[Cns_MAX_BYTES_SUBJECT+1]; char Subject[Cns_MAX_BYTES_SUBJECT + 1];
/***** Get order type, degree and course of the forum *****/ /***** Get order type, degree and course of the forum *****/
For_GetParamsForum (); For_GetParamsForum ();
@ -4127,7 +4148,7 @@ void For_ReqDelThr (void)
extern const char *Txt_Do_you_really_want_to_remove_the_entire_thread; extern const char *Txt_Do_you_really_want_to_remove_the_entire_thread;
extern const char *Txt_Remove_thread; extern const char *Txt_Remove_thread;
long ThrCod; long ThrCod;
char Subject[Cns_MAX_BYTES_SUBJECT+1]; char Subject[Cns_MAX_BYTES_SUBJECT + 1];
/***** Get order type, degree and course of the forum *****/ /***** Get order type, degree and course of the forum *****/
For_GetParamsForum (); For_GetParamsForum ();
@ -4139,7 +4160,7 @@ void For_ReqDelThr (void)
ThrCod = For_GetParamThrCod (); ThrCod = For_GetParamThrCod ();
/***** Get subject of thread to delete *****/ /***** Get subject of thread to delete *****/
For_GetThrSubject (ThrCod,Subject,Cns_MAX_BYTES_SUBJECT); For_GetThrSubject (ThrCod,Subject);
/***** Request confirmation to remove the thread *****/ /***** Request confirmation to remove the thread *****/
if (Subject[0]) if (Subject[0])
@ -4179,7 +4200,7 @@ void For_DelThr (void)
ThrCod = For_GetParamThrCod (); ThrCod = For_GetParamThrCod ();
/***** Get subject of thread to delete *****/ /***** Get subject of thread to delete *****/
For_GetThrSubject (ThrCod,Subject,Cns_MAX_BYTES_SUBJECT); For_GetThrSubject (ThrCod,Subject);
/***** Remove the thread and all its posts *****/ /***** Remove the thread and all its posts *****/
For_RemoveThreadAndItsPsts (ThrCod); For_RemoveThreadAndItsPsts (ThrCod);
@ -4222,7 +4243,7 @@ void For_CutThr (void)
ThrCod = For_GetParamThrCod (); ThrCod = For_GetParamThrCod ();
/***** Get subject of thread to cut *****/ /***** Get subject of thread to cut *****/
For_GetThrSubject (ThrCod,Subject,Cns_MAX_BYTES_SUBJECT); For_GetThrSubject (ThrCod,Subject);
/***** Mark the thread as cut *****/ /***** Mark the thread as cut *****/
For_InsertThrInClipboard (ThrCod); For_InsertThrInClipboard (ThrCod);
@ -4262,7 +4283,7 @@ void For_PasteThr (void)
ThrCod = For_GetParamThrCod (); ThrCod = For_GetParamThrCod ();
/***** Get subject of thread to paste *****/ /***** Get subject of thread to paste *****/
For_GetThrSubject (ThrCod,Subject,Cns_MAX_BYTES_SUBJECT); For_GetThrSubject (ThrCod,Subject);
/***** Paste (move) the thread to current forum *****/ /***** Paste (move) the thread to current forum *****/
if (For_CheckIfThrBelongsToForum (ThrCod,Gbl.Forum.ForumType)) if (For_CheckIfThrBelongsToForum (ThrCod,Gbl.Forum.ForumType))

View File

@ -70,7 +70,7 @@ struct ForumThread
long UsrCod[2]; long UsrCod[2];
time_t WriteTime[2]; time_t WriteTime[2];
bool Enabled[2]; bool Enabled[2];
char Subject[Cns_MAX_BYTES_SUBJECT+1]; char Subject[Cns_MAX_BYTES_SUBJECT + 1];
unsigned NumPosts; unsigned NumPosts;
unsigned NumUnreadPosts; // Number of my unread posts in thread unsigned NumUnreadPosts; // Number of my unread posts in thread
unsigned NumMyPosts; // Number of posts written by me in thread unsigned NumMyPosts; // Number of posts written by me in thread

View File

@ -264,7 +264,7 @@ struct Globals
struct struct
{ {
Sch_WhatToSearch_t WhatToSearch; Sch_WhatToSearch_t WhatToSearch;
char Str[Sch_MAX_LENGTH_STRING_TO_FIND+1]; char Str[Sch_MAX_LENGTH_STRING_TO_FIND + 1];
} Search; } Search;
struct struct
{ {
@ -641,13 +641,13 @@ struct Globals
unsigned Num; unsigned Num;
bool All; bool All;
char *List; char *List;
char Txt[Tst_MAX_TAGS_PER_QUESTION][Tst_MAX_BYTES_TAG+1]; char Txt[Tst_MAX_TAGS_PER_QUESTION][Tst_MAX_BYTES_TAG + 1];
} Tags; } Tags;
Tst_AnswerType_t AnswerType; Tst_AnswerType_t AnswerType;
unsigned NumQsts; unsigned NumQsts;
long QstCodes[Tst_MAX_QUESTIONS_PER_TEST]; // Codes of the sent/received questions in a test long QstCodes[Tst_MAX_QUESTIONS_PER_TEST]; // Codes of the sent/received questions in a test
char StrIndexesOneQst[Tst_MAX_QUESTIONS_PER_TEST][Tst_MAX_SIZE_INDEXES_ONE_QST+1]; // 0 1 2 3, 3 0 2 1, etc. char StrIndexesOneQst[Tst_MAX_QUESTIONS_PER_TEST][Tst_MAX_SIZE_INDEXES_ONE_QST + 1]; // 0 1 2 3, 3 0 2 1, etc.
char StrAnswersOneQst[Tst_MAX_QUESTIONS_PER_TEST][Tst_MAX_SIZE_ANSWERS_ONE_QST+1]; // Answers selected by user char StrAnswersOneQst[Tst_MAX_QUESTIONS_PER_TEST][Tst_MAX_SIZE_ANSWERS_ONE_QST + 1]; // Answers selected by user
bool AllowTeachers; // Can teachers of this course see the test result? bool AllowTeachers; // Can teachers of this course see the test result?
bool AllAnsTypes; bool AllAnsTypes;
struct struct
@ -671,7 +671,7 @@ struct Globals
long Integer; long Integer;
double FloatingPoint[2]; double FloatingPoint[2];
} Answer; } Answer;
char ListAnsTypes[Tst_MAX_BYTES_LIST_ANSWER_TYPES+1]; char ListAnsTypes[Tst_MAX_BYTES_LIST_ANSWER_TYPES + 1];
Tst_QuestionsOrder_t SelectedOrderType; Tst_QuestionsOrder_t SelectedOrderType;
struct struct
{ {

View File

@ -2498,7 +2498,8 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
Lay_ShowErrorAndExit ("Wrong code of group."); Lay_ShowErrorAndExit ("Wrong code of group.");
/* Get group name (row[1]) */ /* Get group name (row[1]) */
Str_Copy (Grp->GrpName,row[1],Grp_MAX_LENGTH_GROUP_NAME); Str_Copy (Grp->GrpName,row[1],
Grp_MAX_LENGTH_GROUP_NAME);
/* Get max number of students of group (row[2]) and number of current students */ /* Get max number of students of group (row[2]) and number of current students */
Grp->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[2]); Grp->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[2]);
@ -2626,7 +2627,8 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
/***** Get some data of group type *****/ /***** Get some data of group type *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (GrpTyp->GrpTypName,row[0],Grp_MAX_LENGTH_GROUP_TYPE_NAME); Str_Copy (GrpTyp->GrpTypName,row[0],
Grp_MAX_LENGTH_GROUP_TYPE_NAME);
GrpTyp->MandatoryEnrollment = (row[1][0] == 'Y'); GrpTyp->MandatoryEnrollment = (row[1][0] == 'Y');
GrpTyp->MultipleEnrollment = (row[2][0] == 'Y'); GrpTyp->MultipleEnrollment = (row[2][0] == 'Y');
GrpTyp->MustBeOpened = (row[3][0] == 'Y'); GrpTyp->MustBeOpened = (row[3][0] == 'Y');
@ -2712,13 +2714,15 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
Lay_ShowErrorAndExit ("Wrong code of course."); Lay_ShowErrorAndExit ("Wrong code of course.");
/* Get the name of the group type (row[2]) */ /* Get the name of the group type (row[2]) */
Str_Copy (GrpDat->GrpTypName,row[2],Grp_MAX_LENGTH_GROUP_TYPE_NAME); Str_Copy (GrpDat->GrpTypName,row[2],
Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Get whether a student may be in one or multiple groups (row[3]) */ /* Get whether a student may be in one or multiple groups (row[3]) */
GrpDat->MultipleEnrollment = (row[3][0] == 'Y'); GrpDat->MultipleEnrollment = (row[3][0] == 'Y');
/* Get the name of the group (row[4]) */ /* Get the name of the group (row[4]) */
Str_Copy (GrpDat->GrpName,row[4],Grp_MAX_LENGTH_GROUP_NAME); Str_Copy (GrpDat->GrpName,row[4],
Grp_MAX_LENGTH_GROUP_NAME);
/* Get maximum number of students (row[5]) */ /* Get maximum number of students (row[5]) */
GrpDat->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[5]); GrpDat->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[5]);
@ -4089,7 +4093,8 @@ void Grp_RenameGroup (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Gbl.CurrentCrs.Grps.GrpName,NewNameGrp,Grp_MAX_LENGTH_GROUP_NAME); Str_Copy (Gbl.CurrentCrs.Grps.GrpName,NewNameGrp,
Grp_MAX_LENGTH_GROUP_NAME);
Grp_ReqEditGroups (); Grp_ReqEditGroups ();
} }

View File

@ -31,6 +31,9 @@
/***************************** Public constants ******************************/ /***************************** Public constants ******************************/
/*****************************************************************************/ /*****************************************************************************/
#define Hie_MAX_LENGTH_LOCATION_SHORT_NAME 32
#define Hie_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR (Hie_MAX_LENGTH_LOCATION_SHORT_NAME * Str_MAX_LENGTH_SPEC_CHAR_HTML)
/*****************************************************************************/ /*****************************************************************************/
/******************************* Public types ********************************/ /******************************* Public types ********************************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -312,7 +312,8 @@ void Hld_GetListHolidays (void)
Hld->PlcCod = Str_ConvertStrCodToLongCod (row[1]); Hld->PlcCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get the full name of the place (row[2]) */ /* Get the full name of the place (row[2]) */
Str_Copy (Hld->PlaceFullName,row[2],Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Hld->PlaceFullName,row[2],
Plc_MAX_LENGTH_PLACE_FULL_NAME);
/* Get type (row[3]) */ /* Get type (row[3]) */
Hld->HldTyp = Hld_GetTypeOfHoliday (row[3]); Hld->HldTyp = Hld_GetTypeOfHoliday (row[3]);
@ -336,7 +337,8 @@ void Hld_GetListHolidays (void)
} }
/* Get the name of the holiday/non school period (row[6]) */ /* Get the name of the holiday/non school period (row[6]) */
Str_Copy (Hld->Name,row[6],Hld_MAX_LENGTH_HOLIDAY_NAME); Str_Copy (Hld->Name,row[6],
Hld_MAX_LENGTH_HOLIDAY_NAME);
} }
} }
@ -402,7 +404,8 @@ static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld)
Hld->PlcCod = Str_ConvertStrCodToLongCod (row[0]); Hld->PlcCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get the full name of the place (row[1]) */ /* Get the full name of the place (row[1]) */
Str_Copy (Hld->PlaceFullName,row[1],Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Hld->PlaceFullName,row[1],
Plc_MAX_LENGTH_PLACE_FULL_NAME);
/* Get type (row[2]) */ /* Get type (row[2]) */
Hld->HldTyp = Hld_GetTypeOfHoliday (row[2]); Hld->HldTyp = Hld_GetTypeOfHoliday (row[2]);
@ -426,7 +429,8 @@ static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld)
} }
/* Get the name of the holiday/non school period (row[5]) */ /* Get the name of the holiday/non school period (row[5]) */
Str_Copy (Hld->Name,row[5],Hld_MAX_LENGTH_HOLIDAY_NAME); Str_Copy (Hld->Name,row[5],
Hld_MAX_LENGTH_HOLIDAY_NAME);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -694,7 +698,8 @@ void Hld_ChangeHolidayPlace (void)
/***** Show the form again *****/ /***** Show the form again *****/
Hld->PlcCod = NewPlace.PlcCod; Hld->PlcCod = NewPlace.PlcCod;
Str_Copy (Hld->PlaceFullName,NewPlace.FullName,Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Hld->PlaceFullName,NewPlace.FullName,
Plc_MAX_LENGTH_PLACE_FULL_NAME);
Hld_EditHolidays (); Hld_EditHolidays ();
} }
@ -889,7 +894,8 @@ void Hld_RenameHoliday (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Hld->Name,NewHldName,Hld_MAX_LENGTH_HOLIDAY_NAME); Str_Copy (Hld->Name,NewHldName,
Hld_MAX_LENGTH_HOLIDAY_NAME);
Hld_EditHolidays (); Hld_EditHolidays ();
} }

View File

@ -143,7 +143,8 @@ void Img_GetImageNameTitleAndURLFromRow (const char *Name,
size_t Length; size_t Length;
/***** Copy image name to struct *****/ /***** Copy image name to struct *****/
Str_Copy (Image->Name,Name,Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Str_Copy (Image->Name,Name,
Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
/***** Set status of image file *****/ /***** Set status of image file *****/
Image->Status = Image->Name[0] ? Img_NAME_STORED_IN_DB : Image->Status = Image->Name[0] ? Img_NAME_STORED_IN_DB :
@ -161,9 +162,10 @@ void Img_GetImageNameTitleAndURLFromRow (const char *Name,
if (Length > Img_MAX_BYTES_TITLE) if (Length > Img_MAX_BYTES_TITLE)
Length = Img_MAX_BYTES_TITLE; Length = Img_MAX_BYTES_TITLE;
if ((Image->Title = (char *) malloc (Length+1)) == NULL) if ((Image->Title = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for image title."); Lay_ShowErrorAndExit ("Error allocating memory for image title.");
Str_Copy (Image->Title,Title,Length); Str_Copy (Image->Title,Title,
Length);
} }
/***** Copy image URL to struct *****/ /***** Copy image URL to struct *****/
@ -177,9 +179,10 @@ void Img_GetImageNameTitleAndURLFromRow (const char *Name,
if (Length > Img_MAX_BYTES_TITLE) if (Length > Img_MAX_BYTES_TITLE)
Length = Img_MAX_BYTES_TITLE; Length = Img_MAX_BYTES_TITLE;
if ((Image->URL = (char *) malloc (Length+1)) == NULL) if ((Image->URL = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for image URL."); Lay_ShowErrorAndExit ("Error allocating memory for image URL.");
Str_Copy (Image->URL,URL,Length); Str_Copy (Image->URL,URL,
Length);
} }
} }
@ -317,7 +320,8 @@ void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
Img_FreeImageTitle (Image); Img_FreeImageTitle (Image);
if ((Image->Title = (char *) malloc (Length + 1)) == NULL) if ((Image->Title = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for image title."); Lay_ShowErrorAndExit ("Error allocating memory for image title.");
Str_Copy (Image->Title,Title,Length); Str_Copy (Image->Title,Title,
Length);
} }
/***** By last, get image URL from form *****/ /***** By last, get image URL from form *****/
@ -331,7 +335,8 @@ void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
Img_FreeImageURL (Image); Img_FreeImageURL (Image);
if ((Image->URL = (char *) malloc (Length + 1)) == NULL) if ((Image->URL = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for image URL."); Lay_ShowErrorAndExit ("Error allocating memory for image URL.");
Str_Copy (Image->URL,URL,Length); Str_Copy (Image->URL,URL,
Length);
} }
} }
@ -345,10 +350,14 @@ void Img_SetParamNames (struct ParamUploadImg *ParamUploadImg,int NumImgInForm)
{ {
if (NumImgInForm < 0) // One unique image in form ==> no suffix needed if (NumImgInForm < 0) // One unique image in form ==> no suffix needed
{ {
Str_Copy (ParamUploadImg->Action,"ImgAct",Img_MAX_LENGTH_PARAM_UPLOAD_IMG); Str_Copy (ParamUploadImg->Action,"ImgAct",
Str_Copy (ParamUploadImg->File ,"ImgFil",Img_MAX_LENGTH_PARAM_UPLOAD_IMG); Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
Str_Copy (ParamUploadImg->Title ,"ImgTit",Img_MAX_LENGTH_PARAM_UPLOAD_IMG); Str_Copy (ParamUploadImg->File ,"ImgFil",
Str_Copy (ParamUploadImg->URL ,"ImgURL",Img_MAX_LENGTH_PARAM_UPLOAD_IMG); Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
Str_Copy (ParamUploadImg->Title ,"ImgTit",
Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
Str_Copy (ParamUploadImg->URL ,"ImgURL",
Img_MAX_LENGTH_PARAM_UPLOAD_IMG);
} }
else // Several images in form ==> add suffix else // Several images in form ==> add suffix
{ {

View File

@ -87,7 +87,7 @@ struct Image
{ {
Img_Action_t Action; Img_Action_t Action;
Img_FileStatus_t Status; Img_FileStatus_t Status;
char Name[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+1]; char Name[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64 + 1];
char *Title; // Title/attribution (it must be initialized to NULL char *Title; // Title/attribution (it must be initialized to NULL
// in order to not trying to free it when no memory allocated) // in order to not trying to free it when no memory allocated)
char *URL; // URL, i.e. link to original big photo or video char *URL; // URL, i.e. link to original big photo or video

View File

@ -320,8 +320,8 @@ static bool Inf_CheckIfInfoAvailable (Inf_InfoSrc_t InfoSrc);
static Inf_InfoType_t Inf_AsignInfoType (void); static Inf_InfoType_t Inf_AsignInfoType (void);
static void Inf_SetInfoTxtIntoDB (const char *InfoTxtHTML,const char *InfoTxtMD); static void Inf_SetInfoTxtIntoDB (const char *InfoTxtHTML,const char *InfoTxtMD);
static void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType, static void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
char *InfoTxtHTML,char *InfoTxtMD, char InfoTxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1],
size_t MaxLength); char InfoTxtMD[Cns_MAX_BYTES_LONG_TEXT + 1]);
static bool Inf_CheckPlainTxt (long CrsCod,Inf_InfoType_t InfoType); static bool Inf_CheckPlainTxt (long CrsCod,Inf_InfoType_t InfoType);
static bool Inf_CheckAndShowPlainTxt (void); static bool Inf_CheckAndShowPlainTxt (void);
@ -1692,8 +1692,8 @@ static void Inf_SetInfoTxtIntoDB (const char *InfoTxtHTML,const char *InfoTxtMD)
/*****************************************************************************/ /*****************************************************************************/
static void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType, static void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
char *InfoTxtHTML,char *InfoTxtMD, char InfoTxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1],
size_t MaxLength) char InfoTxtMD[Cns_MAX_BYTES_LONG_TEXT + 1])
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -1715,11 +1715,13 @@ static void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
/* Get text in HTML format (not rigorous) */ /* Get text in HTML format (not rigorous) */
if (InfoTxtHTML) if (InfoTxtHTML)
Str_Copy (InfoTxtHTML,row[0],MaxLength); Str_Copy (InfoTxtHTML,row[0],
Cns_MAX_BYTES_LONG_TEXT);
/* Get text in Markdown format */ /* Get text in Markdown format */
if (InfoTxtMD) if (InfoTxtMD)
Str_Copy (InfoTxtMD,row[1],MaxLength); Str_Copy (InfoTxtMD,row[1],
Cns_MAX_BYTES_LONG_TEXT);
} }
else else
{ {
@ -1743,10 +1745,10 @@ static void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
static bool Inf_CheckPlainTxt (long CrsCod,Inf_InfoType_t InfoType) static bool Inf_CheckPlainTxt (long CrsCod,Inf_InfoType_t InfoType)
{ {
char TxtHTML[Cns_MAX_BYTES_LONG_TEXT+1]; char TxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1];
/***** Get info text from database *****/ /***** Get info text from database *****/
Inf_GetInfoTxtFromDB (CrsCod,InfoType,TxtHTML,NULL,Cns_MAX_BYTES_LONG_TEXT); Inf_GetInfoTxtFromDB (CrsCod,InfoType,TxtHTML,NULL);
return (TxtHTML[0] != '\0'); return (TxtHTML[0] != '\0');
} }
@ -1776,7 +1778,7 @@ static bool Inf_CheckAndShowPlainTxt (void)
/***** Get info text from database *****/ /***** Get info text from database *****/
Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type, Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,
TxtHTML,NULL,Cns_MAX_BYTES_LONG_TEXT); TxtHTML,NULL);
if (TxtHTML[0]) if (TxtHTML[0])
{ {
@ -1817,12 +1819,12 @@ static bool Inf_CheckAndShowPlainTxt (void)
static bool Inf_CheckRichTxt (long CrsCod,Inf_InfoType_t InfoType) static bool Inf_CheckRichTxt (long CrsCod,Inf_InfoType_t InfoType)
{ {
char TxtHTML[Cns_MAX_BYTES_LONG_TEXT+1]; char TxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1];
char TxtMD[Cns_MAX_BYTES_LONG_TEXT+1]; char TxtMD[Cns_MAX_BYTES_LONG_TEXT + 1];
/***** Get info text from database *****/ /***** Get info text from database *****/
Inf_GetInfoTxtFromDB (CrsCod,InfoType, Inf_GetInfoTxtFromDB (CrsCod,InfoType,
TxtHTML,TxtMD,Cns_MAX_BYTES_LONG_TEXT); TxtHTML,TxtMD);
return (TxtMD[0] != '\0'); return (TxtMD[0] != '\0');
} }
@ -1835,14 +1837,14 @@ static bool Inf_CheckRichTxt (long CrsCod,Inf_InfoType_t InfoType)
static bool Inf_CheckAndShowRichTxt (void) static bool Inf_CheckAndShowRichTxt (void)
{ {
extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES]; extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES];
char TxtHTML[Cns_MAX_BYTES_LONG_TEXT+1]; char TxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1];
char TxtMD[Cns_MAX_BYTES_LONG_TEXT+1]; char TxtMD[Cns_MAX_BYTES_LONG_TEXT + 1];
char PathFileMD[PATH_MAX+1]; char PathFileMD[PATH_MAX + 1];
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];
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.LoggedRole == Rol_TEACHER || bool ICanEdit = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM);
@ -1860,7 +1862,7 @@ static bool Inf_CheckAndShowRichTxt (void)
/***** Get info text from database *****/ /***** Get info text from database *****/
Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type, Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,
TxtHTML,TxtMD,Cns_MAX_BYTES_LONG_TEXT); TxtHTML,TxtMD);
if (TxtMD[0]) if (TxtMD[0])
{ {
@ -1951,8 +1953,8 @@ static bool Inf_CheckAndShowRichTxt (void)
int Inf_WritePlainTextIntoHTMLBuffer (char **HTMLBuffer) int Inf_WritePlainTextIntoHTMLBuffer (char **HTMLBuffer)
{ {
extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES]; extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES];
char TxtHTML[Cns_MAX_BYTES_LONG_TEXT+1]; char TxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1];
char FileNameHTMLTmp[PATH_MAX+1]; char FileNameHTMLTmp[PATH_MAX + 1];
FILE *FileHTMLTmp; FILE *FileHTMLTmp;
size_t Length; size_t Length;
@ -1961,7 +1963,7 @@ int Inf_WritePlainTextIntoHTMLBuffer (char **HTMLBuffer)
/***** Get info text from database *****/ /***** Get info text from database *****/
Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type, Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,
TxtHTML,NULL,Cns_MAX_BYTES_LONG_TEXT); TxtHTML,NULL);
if (TxtHTML[0]) if (TxtHTML[0])
{ {
@ -2062,7 +2064,7 @@ void Inf_EditPlainTxtInfo (void)
/***** Get info text from database *****/ /***** Get info text from database *****/
Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type, Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,
TxtHTML,NULL,Cns_MAX_BYTES_LONG_TEXT); TxtHTML,NULL);
/***** Edition area *****/ /***** Edition area *****/
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">"); fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
@ -2113,7 +2115,7 @@ void Inf_EditRichTxtInfo (void)
/***** Get info text from database *****/ /***** Get info text from database *****/
Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type, Inf_GetInfoTxtFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,
TxtHTML,NULL,Cns_MAX_BYTES_LONG_TEXT); TxtHTML,NULL);
/***** Edition area *****/ /***** Edition area *****/
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">"); fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
@ -2144,7 +2146,8 @@ void Inf_RecAndChangePlainTxtInfo (void)
/***** Get text with course information from form *****/ /***** Get text with course information from form *****/
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat, Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT,NULL); Cns_MAX_BYTES_LONG_TEXT,NULL);
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT);
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML, Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous) Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN, Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,
@ -2179,7 +2182,8 @@ void Inf_RecAndChangeRichTxtInfo (void)
/***** Get text with course information from form *****/ /***** Get text with course information from form *****/
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat, Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT,NULL); Cns_MAX_BYTES_LONG_TEXT,NULL);
Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Txt_MarkdownFormat,Txt_HTMLFormat,
Cns_MAX_BYTES_LONG_TEXT);
Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML, Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML,
Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous) Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous)
Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN, Str_ChangeFormat (Str_FROM_FORM,Str_TO_MARKDOWN,

View File

@ -1028,13 +1028,16 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]); Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]);
/* Get the short name of the institution (row[4]) */ /* Get the short name of the institution (row[4]) */
Str_Copy (Ins->ShrtName,row[4],Ins_MAX_LENGTH_INSTIT_SHRT_NAME); Str_Copy (Ins->ShrtName,row[4],
Ins_MAX_LENGTH_INSTIT_SHRT_NAME);
/* Get the full name of the institution (row[5]) */ /* Get the full name of the institution (row[5]) */
Str_Copy (Ins->FullName,row[5],Ins_MAX_LENGTH_INSTIT_FULL_NAME); Str_Copy (Ins->FullName,row[5],
Ins_MAX_LENGTH_INSTIT_FULL_NAME);
/* Get the URL of the institution (row[6]) */ /* Get the URL of the institution (row[6]) */
Str_Copy (Ins->WWW,row[6],Cns_MAX_LENGTH_WWW); Str_Copy (Ins->WWW,row[6],
Cns_MAX_LENGTH_WWW);
/* Get extra data */ /* Get extra data */
switch (GetExtraData) switch (GetExtraData)
@ -1122,13 +1125,16 @@ bool Ins_GetDataOfInstitutionByCod (struct Instit *Ins,
Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[2]); Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[2]);
/* Get the short name of the institution (row[3]) */ /* Get the short name of the institution (row[3]) */
Str_Copy (Ins->ShrtName,row[3],Ins_MAX_LENGTH_INSTIT_SHRT_NAME); Str_Copy (Ins->ShrtName,row[3],
Ins_MAX_LENGTH_INSTIT_SHRT_NAME);
/* Get the full name of the institution (row[4]) */ /* Get the full name of the institution (row[4]) */
Str_Copy (Ins->FullName,row[4],Ins_MAX_LENGTH_INSTIT_FULL_NAME); Str_Copy (Ins->FullName,row[4],
Ins_MAX_LENGTH_INSTIT_FULL_NAME);
/* Get the URL of the institution (row[5]) */ /* Get the URL of the institution (row[5]) */
Str_Copy (Ins->WWW,row[5],Cns_MAX_LENGTH_WWW); Str_Copy (Ins->WWW,row[5],
Cns_MAX_LENGTH_WWW);
/* Get extra data */ /* Get extra data */
if (GetExtraData == Ins_GET_EXTRA_DATA) if (GetExtraData == Ins_GET_EXTRA_DATA)
@ -1178,7 +1184,8 @@ void Ins_GetShortNameOfInstitutionByCod (struct Instit *Ins)
/***** Get the short name of this institution *****/ /***** Get the short name of this institution *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Ins->ShrtName,row[0],Ins_MAX_LENGTH_INSTIT_SHRT_NAME); Str_Copy (Ins->ShrtName,row[0],
Ins_MAX_LENGTH_INSTIT_SHRT_NAME);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -1270,7 +1277,7 @@ void Ins_WriteSelectorOfInstitution (void)
/************************* List all the institutions *************************/ /************************* List all the institutions *************************/
/*****************************************************************************/ /*****************************************************************************/
#define Ins_MAX_LENGTH_WWW_ON_SCREEN 10 #define Ins_MAX_LENGTH_WWW_ON_SCREEN 15
static void Ins_ListInstitutionsForEdition (void) static void Ins_ListInstitutionsForEdition (void)
{ {
@ -1279,7 +1286,7 @@ static void Ins_ListInstitutionsForEdition (void)
extern const char *Txt_INSTITUTION_STATUS[Ins_NUM_STATUS_TXT]; extern const char *Txt_INSTITUTION_STATUS[Ins_NUM_STATUS_TXT];
unsigned NumIns; unsigned NumIns;
struct Instit *Ins; struct Instit *Ins;
char WWW[Ins_MAX_LENGTH_WWW_ON_SCREEN+1]; char WWW[Cns_MAX_LENGTH_WWW + 1];
struct UsrData UsrDat; struct UsrData UsrDat;
bool ICanEdit; bool ICanEdit;
Ins_StatusTxt_t StatusTxt; Ins_StatusTxt_t StatusTxt;
@ -1387,12 +1394,14 @@ static void Ins_ListInstitutionsForEdition (void)
} }
else else
{ {
Str_Copy (WWW,Ins->WWW,Ins_MAX_LENGTH_WWW_ON_SCREEN); Str_Copy (WWW,Ins->WWW,
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\">%s", Cns_MAX_LENGTH_WWW);
Str_LimitLengthHTMLStr (WWW,Ins_MAX_LENGTH_WWW_ON_SCREEN);
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
" class=\"DAT\" title=\"%s\">"
"%s"
"</a>",
Ins->WWW,Ins->WWW,WWW); Ins->WWW,Ins->WWW,WWW);
if (strlen (Ins->WWW) > Ins_MAX_LENGTH_WWW_ON_SCREEN)
fprintf (Gbl.F.Out,"&hellip;");
fprintf (Gbl.F.Out,"</a>");
} }
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
@ -1853,7 +1862,8 @@ void Ins_ChangeInsWWW (void)
{ {
/***** Update database changing old WWW by new WWW *****/ /***** Update database changing old WWW by new WWW *****/
Ins_UpdateInsWWWDB (Ins->InsCod,NewWWW); Ins_UpdateInsWWWDB (Ins->InsCod,NewWWW);
Str_Copy (Ins->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Ins->WWW,NewWWW,
Cns_MAX_LENGTH_WWW);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);
@ -1884,7 +1894,8 @@ void Ins_ChangeInsWWWInConfig (void)
{ {
/***** Update database changing old WWW by new WWW *****/ /***** Update database changing old WWW by new WWW *****/
Ins_UpdateInsWWWDB (Gbl.CurrentIns.Ins.InsCod,NewWWW); Ins_UpdateInsWWWDB (Gbl.CurrentIns.Ins.InsCod,NewWWW);
Str_Copy (Gbl.CurrentIns.Ins.WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Gbl.CurrentIns.Ins.WWW,NewWWW,
Cns_MAX_LENGTH_WWW);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW); sprintf (Gbl.Message,Txt_The_new_web_address_is_X,NewWWW);

View File

@ -232,13 +232,16 @@ void Lnk_GetListLinks (void)
Lay_ShowErrorAndExit ("Wrong code of institutional link."); Lay_ShowErrorAndExit ("Wrong code of institutional link.");
/* Get the short name of the link (row[1]) */ /* Get the short name of the link (row[1]) */
Str_Copy (Lnk->ShrtName,row[1],Lnk_MAX_LENGTH_LINK_SHRT_NAME); Str_Copy (Lnk->ShrtName,row[1],
Lnk_MAX_LENGTH_LINK_SHRT_NAME);
/* Get the full name of the link (row[2]) */ /* Get the full name of the link (row[2]) */
Str_Copy (Lnk->FullName,row[2],Lnk_MAX_LENGTH_LINK_FULL_NAME); Str_Copy (Lnk->FullName,row[2],
Lnk_MAX_LENGTH_LINK_FULL_NAME);
/* Get the URL of the link (row[3]) */ /* Get the URL of the link (row[3]) */
Str_Copy (Lnk->WWW,row[3],Cns_MAX_LENGTH_WWW); Str_Copy (Lnk->WWW,row[3],
Cns_MAX_LENGTH_WWW);
} }
} }
else else
@ -277,13 +280,16 @@ void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the short name of the link (row[0]) */ /* Get the short name of the link (row[0]) */
Str_Copy (Lnk->ShrtName,row[0],Lnk_MAX_LENGTH_LINK_SHRT_NAME); Str_Copy (Lnk->ShrtName,row[0],
Lnk_MAX_LENGTH_LINK_SHRT_NAME);
/* Get the full name of the link (row[1]) */ /* Get the full name of the link (row[1]) */
Str_Copy (Lnk->FullName,row[1],Lnk_MAX_LENGTH_LINK_FULL_NAME); Str_Copy (Lnk->FullName,row[1],
Lnk_MAX_LENGTH_LINK_FULL_NAME);
/* Get the URL of the link (row[2]) */ /* Get the URL of the link (row[2]) */
Str_Copy (Lnk->WWW,row[2],Cns_MAX_LENGTH_WWW); Str_Copy (Lnk->WWW,row[2],
Cns_MAX_LENGTH_WWW);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -545,7 +551,8 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (CurrentLnkName,NewLnkName,MaxLength); Str_Copy (CurrentLnkName,NewLnkName,
MaxLength);
Lnk_EditLinks (); Lnk_EditLinks ();
} }
@ -602,7 +609,8 @@ void Lnk_ChangeLinkWWW (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty); Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty);
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Lnk->WWW,NewWWW,Cns_MAX_LENGTH_WWW); Str_Copy (Lnk->WWW,NewWWW,
Cns_MAX_LENGTH_WWW);
Lnk_EditLinks (); Lnk_EditLinks ();
} }

View File

@ -67,6 +67,7 @@ extern struct Globals Gbl;
static void Mai_GetParamMaiOrderType (void); static void Mai_GetParamMaiOrderType (void);
static void Mai_PutIconToEditMailDomains (void); static void Mai_PutIconToEditMailDomains (void);
static void Mai_GetListMailDomainsAllowedForNotif (void); static void Mai_GetListMailDomainsAllowedForNotif (void);
static void Mai_GetMailBox (const char *Email,char MailBox[Usr_MAX_BYTES_USR_EMAIL + 1]);
static bool Mai_CheckIfMailDomainIsAllowedForNotif (const char *MailDomain); static bool Mai_CheckIfMailDomainIsAllowedForNotif (const char *MailDomain);
static void Mai_ListMailDomainsForEdition (void); static void Mai_ListMailDomainsForEdition (void);
@ -288,10 +289,12 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
Lay_ShowErrorAndExit ("Wrong code of mail domain."); Lay_ShowErrorAndExit ("Wrong code of mail domain.");
/* Get the mail domain (row[1]) */ /* Get the mail domain (row[1]) */
Str_Copy (Mai->Domain,row[1],Mai_MAX_LENGTH_MAIL_DOMAIN); Str_Copy (Mai->Domain,row[1],
Mai_MAX_LENGTH_MAIL_DOMAIN);
/* Get the mail domain info (row[2]) */ /* Get the mail domain info (row[2]) */
Str_Copy (Mai->Info,row[2],Mai_MAX_LENGTH_MAIL_INFO); Str_Copy (Mai->Info,row[2],
Mai_MAX_LENGTH_MAIL_INFO);
/* Get number of users (row[3]) */ /* Get number of users (row[3]) */
if (sscanf (row[3],"%u",&(Mai->NumUsrs)) != 1) if (sscanf (row[3],"%u",&(Mai->NumUsrs)) != 1)
@ -316,17 +319,37 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
bool Mai_CheckIfUsrCanReceiveEmailNotif (const struct UsrData *UsrDat) bool Mai_CheckIfUsrCanReceiveEmailNotif (const struct UsrData *UsrDat)
{ {
char MailDomain[Usr_MAX_BYTES_USR_EMAIL+1]; char MailDomain[Usr_MAX_BYTES_USR_EMAIL + 1];
/***** Check #1: is my email address confirmed? *****/ /***** Check #1: is my email address confirmed? *****/
if (!UsrDat->EmailConfirmed) if (!UsrDat->EmailConfirmed)
return false; return false;
/***** Check #2: if my mail domain allowed? *****/ /***** Check #2: if my mail domain allowed? *****/
Str_GetMailBox (UsrDat->Email,MailDomain,Usr_MAX_BYTES_USR_EMAIL); Mai_GetMailBox (UsrDat->Email,MailDomain);
return Mai_CheckIfMailDomainIsAllowedForNotif (MailDomain); return Mai_CheckIfMailDomainIsAllowedForNotif (MailDomain);
} }
/*****************************************************************************/
/********************** Get mailbox from email address ***********************/
/*****************************************************************************/
static void Mai_GetMailBox (const char *Email,char MailBox[Usr_MAX_BYTES_USR_EMAIL + 1])
{
const char *Ptr;
MailBox[0] = '\0'; // Return empty mailbox on error
if ((Ptr = strchr (Email,(int) '@'))) // Find first '@' in address
if (Ptr != Email) // '@' is not the first character in Email
{
Ptr++; // Skip '@'
if (strchr (Ptr,(int) '@') == NULL) // No more '@' found
Str_Copy (MailBox,Ptr,
Usr_MAX_BYTES_USR_EMAIL);
}
}
/*****************************************************************************/ /*****************************************************************************/
/************ Check if a mail domain is allowed for notifications ************/ /************ Check if a mail domain is allowed for notifications ************/
/*****************************************************************************/ /*****************************************************************************/
@ -392,10 +415,12 @@ void Mai_GetDataOfMailDomainByCod (struct Mail *Mai)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the short name of the mail (row[0]) */ /* Get the short name of the mail (row[0]) */
Str_Copy (Mai->Domain,row[0],Mai_MAX_LENGTH_MAIL_DOMAIN); Str_Copy (Mai->Domain,row[0],
Mai_MAX_LENGTH_MAIL_DOMAIN);
/* Get the full name of the mail (row[1]) */ /* Get the full name of the mail (row[1]) */
Str_Copy (Mai->Info,row[1],Mai_MAX_LENGTH_MAIL_INFO); Str_Copy (Mai->Info,row[1],
Mai_MAX_LENGTH_MAIL_INFO);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -649,7 +674,8 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (CurrentMaiName,NewMaiName,MaxLength); Str_Copy (CurrentMaiName,NewMaiName,
MaxLength);
Mai_EditMailDomains (); Mai_EditMailDomains ();
} }
@ -966,7 +992,7 @@ bool Mai_CheckIfEmailIsValid (const char *Email)
bool ArrobaFound = false; bool ArrobaFound = false;
/***** An email address must have a number of characters /***** An email address must have a number of characters
5 <= Length <= Mai_MAX_BYTES_USR_EMAIL *****/ 5 <= Length <= Usr_MAX_BYTES_USR_EMAIL *****/
if (Length < 5 || if (Length < 5 ||
Length > Usr_MAX_BYTES_USR_EMAIL) Length > Usr_MAX_BYTES_USR_EMAIL)
return false; return false;
@ -1029,7 +1055,8 @@ bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat)
{ {
/* Get email */ /* Get email */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (UsrDat->Email,row[0],Usr_MAX_BYTES_USR_EMAIL); Str_Copy (UsrDat->Email,row[0],
Usr_MAX_BYTES_USR_EMAIL);
UsrDat->EmailConfirmed = (row[1][0] == 'Y'); UsrDat->EmailConfirmed = (row[1][0] == 'Y');
Found = true; Found = true;
} }
@ -1677,7 +1704,8 @@ void Mai_ConfirmEmail (void)
UsrCod = Str_ConvertStrCodToLongCod (row[0]); UsrCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get user's email */ /* Get user's email */
Str_Copy (Email,row[1],Usr_MAX_BYTES_USR_EMAIL); Str_Copy (Email,row[1],
Usr_MAX_BYTES_USR_EMAIL);
KeyIsCorrect = true; KeyIsCorrect = true;
} }

View File

@ -27,12 +27,14 @@
/********************************* Headers ***********************************/ /********************************* Headers ***********************************/
/*****************************************************************************/ /*****************************************************************************/
#include "swad_user.h"
/*****************************************************************************/ /*****************************************************************************/
/************************** Public types and constants ***********************/ /************************** Public types and constants ***********************/
/*****************************************************************************/ /*****************************************************************************/
#define Mai_MAX_LENGTH_MAIL_DOMAIN 255 #define Mai_MAX_LENGTH_MAIL_DOMAIN (128 - 1)
#define Mai_MAX_LENGTH_MAIL_INFO 255 #define Mai_MAX_LENGTH_MAIL_INFO (128 - 1)
typedef enum typedef enum
{ {

View File

@ -323,8 +323,7 @@ bool Mrk_CheckFileOfMarks (const char *Path,struct MarksProperties *Marks)
// Only one table is allowed // Only one table is allowed
if (Str_FindStrInFile (FileAllMarks,"<table",Str_NO_SKIP_HTML_COMMENTS)) if (Str_FindStrInFile (FileAllMarks,"<table",Str_NO_SKIP_HTML_COMMENTS))
{ {
Str_Copy (Gbl.Message,Txt_There_are_more_than_one_table_in_the_file_of_marks, sprintf (Gbl.Message,"%s",Txt_There_are_more_than_one_table_in_the_file_of_marks);
Lay_MAX_BYTES_ALERT);
FileIsCorrect = false; FileIsCorrect = false;
} }
else else
@ -385,8 +384,7 @@ bool Mrk_CheckFileOfMarks (const char *Path,struct MarksProperties *Marks)
} }
else else
{ {
Str_Copy (Gbl.Message,Txt_Table_not_found_in_the_file_of_marks, sprintf (Gbl.Message,"%s",Txt_Table_not_found_in_the_file_of_marks);
Lay_MAX_BYTES_ALERT);
FileIsCorrect = false; FileIsCorrect = false;
} }
@ -458,8 +456,7 @@ static bool Mrk_GetUsrMarks (FILE *FileUsrMarks,struct UsrData *UsrDat,
/***** Open HTML file with the table of marks *****/ /***** Open HTML file with the table of marks *****/
if (!(FileAllMarks = fopen (PathFileAllMarks,"rb"))) if (!(FileAllMarks = fopen (PathFileAllMarks,"rb")))
{ // Can't open the file with the table of marks { // Can't open the file with the table of marks
Str_Copy (Gbl.Message,"Can not open file of marks.", // TODO: Need translation! sprintf (Gbl.Message,"%s","Can not open file of marks."); // TODO: Need translation!
Lay_MAX_BYTES_ALERT);
return false; return false;
} }
@ -730,12 +727,12 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
long CrsCod; long CrsCod;
long GrpCod; long GrpCod;
struct MarksProperties Marks; struct MarksProperties Marks;
char FullPathInTreeFromDBMarksTable[PATH_MAX+1]; char FullPathInTreeFromDBMarksTable[PATH_MAX + 1];
char PathUntilFileName[PATH_MAX+1]; char PathUntilFileName[PATH_MAX + 1];
char FileName[NAME_MAX+1]; char FileName[NAME_MAX + 1];
char PathMarksPriv[PATH_MAX+1]; char PathMarksPriv[PATH_MAX + 1];
char PathMarks[PATH_MAX+1]; char PathMarks[PATH_MAX + 1];
char FileNameUsrMarks[PATH_MAX+1]; char FileNameUsrMarks[PATH_MAX + 1];
FILE *FileUsrMarks; FILE *FileUsrMarks;
size_t SizeOfMyMarks; size_t SizeOfMyMarks;
size_t Length; size_t Length;
@ -779,11 +776,13 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
&InsCod,&CtrCod,&DegCod,&CrsCod,&GrpCod); &InsCod,&CtrCod,&DegCod,&CrsCod,&GrpCod);
/* Path (row[2]) */ /* Path (row[2]) */
Str_Copy (FullPathInTreeFromDBMarksTable,row[2],PATH_MAX); Str_Copy (FullPathInTreeFromDBMarksTable,row[2],
PATH_MAX);
Str_SplitFullPathIntoPathAndFileName (FullPathInTreeFromDBMarksTable, Str_SplitFullPathIntoPathAndFileName (FullPathInTreeFromDBMarksTable,
PathUntilFileName, PathUntilFileName,
FileName); FileName);
Str_Copy (SummaryStr,FileName,NAME_MAX); Str_Copy (SummaryStr,FileName,
Cns_MAX_BYTES_TEXT);
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -834,7 +833,8 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
if ((*ContentStr = (char *) malloc (Length + 1))) if ((*ContentStr = (char *) malloc (Length + 1)))
{ {
/* 9 starting chars */ /* 9 starting chars */
Str_Copy (*ContentStr,"<![CDATA[",9); Str_Copy (*ContentStr,"<![CDATA[",
9);
/* Content */ /* Content */
Ptr = (*ContentStr) + 9; Ptr = (*ContentStr) + 9;
@ -848,7 +848,8 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
} }
/* 3 ending chars */ /* 3 ending chars */
Str_Copy (Ptr,"]]>",3); Str_Copy (Ptr,"]]>",
3);
} }
} }
else else
@ -860,8 +861,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
} }
else else
{ {
Str_Copy (Gbl.Message,"Can not open file with user's marks!", // TODO: Need translation! sprintf (Gbl.Message,"%s","Can not open file with user's marks!"); // TODO: Need translation!
Lay_MAX_BYTES_ALERT);
if ((*ContentStr = (char *) malloc (9+strlen (Gbl.Message)+3+1))) if ((*ContentStr = (char *) malloc (9+strlen (Gbl.Message)+3+1)))
sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Message); sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Message);
} }
@ -869,8 +869,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
} }
else else
{ {
Str_Copy (Gbl.Message,"User's IDs not found!", // TODO: Need translation! sprintf (Gbl.Message,"%s","User's IDs not found!"); // TODO: Need translation!
Lay_MAX_BYTES_ALERT);
if ((*ContentStr = (char *) malloc (9+strlen (Gbl.Message)+3+1))) if ((*ContentStr = (char *) malloc (9+strlen (Gbl.Message)+3+1)))
sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Message); sprintf (*ContentStr,"<![CDATA[%s]]>",Gbl.Message);
} }

View File

@ -74,7 +74,7 @@ extern struct Globals Gbl;
/**************************** Internal prototypes ****************************/ /**************************** Internal prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Msg_PutFormMsgUsrs (char *Content); static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1]);
static void Msg_ShowSentOrReceivedMessages (void); static void Msg_ShowSentOrReceivedMessages (void);
static unsigned long Msg_GetNumUsrsBannedByMe (void); static unsigned long Msg_GetNumUsrsBannedByMe (void);
@ -100,7 +100,7 @@ static void Msg_PutLinkToShowMorePotentialRecipients (void);
static void Msg_PutParamsShowMorePotentialRecipients (void); static void Msg_PutParamsShowMorePotentialRecipients (void);
static void Msg_ShowOneUniqueRecipient (void); static void Msg_ShowOneUniqueRecipient (void);
static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void); static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void);
static void Msg_WriteFormSubjectAndContentMsgToUsrs (char *Content); static void Msg_WriteFormSubjectAndContentMsgToUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1]);
static void Msg_ShowNumMsgsDeleted (unsigned NumMsgs); static void Msg_ShowNumMsgsDeleted (unsigned NumMsgs);
static void Msg_MakeFilterFromToSubquery (char FilterFromToSubquery[Msg_MAX_LENGTH_MESSAGES_QUERY + 1]); static void Msg_MakeFilterFromToSubquery (char FilterFromToSubquery[Msg_MAX_LENGTH_MESSAGES_QUERY + 1]);
@ -125,8 +125,11 @@ static bool Msg_CheckIfReceivedMsgIsDeletedForAllItsRecipients (long MsgCod);
static unsigned Msg_GetNumUnreadMsgs (long FilterCrsCod,const char *FilterFromToSubquery); static unsigned Msg_GetNumUnreadMsgs (long FilterCrsCod,const char *FilterFromToSubquery);
static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod, static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
time_t *CreatTimeUTC,char *Subject,bool *Deleted); time_t *CreatTimeUTC,
static void Msg_GetMsgContent (long MsgCod,char *Content,struct Image *Image); char Subject[Cns_MAX_BYTES_SUBJECT + 1],
bool *Deleted);
static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
struct Image *Image);
static void Msg_WriteSentOrReceivedMsgSubject (long MsgCod,const char *Subject,bool Open,bool Expanded); static void Msg_WriteSentOrReceivedMsgSubject (long MsgCod,const char *Subject,bool Open,bool Expanded);
static void Msg_WriteFormToReply (long MsgCod,long CrsCod, static void Msg_WriteFormToReply (long MsgCod,long CrsCod,
@ -148,7 +151,7 @@ static bool Msg_CheckIfUsrIsBanned (long FromUsrCod,long ToUsrCod);
void Msg_FormMsgUsrs (void) void Msg_FormMsgUsrs (void)
{ {
char Content[Cns_MAX_BYTES_LONG_TEXT+1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
/***** Get possible hidden subject and content of the message *****/ /***** Get possible hidden subject and content of the message *****/
Par_GetParToHTML ("HiddenSubject",Gbl.Msg.Subject,Cns_MAX_BYTES_SUBJECT); Par_GetParToHTML ("HiddenSubject",Gbl.Msg.Subject,Cns_MAX_BYTES_SUBJECT);
@ -162,7 +165,7 @@ void Msg_FormMsgUsrs (void)
/***************** Put a form to write a new message to users ****************/ /***************** Put a form to write a new message to users ****************/
/*****************************************************************************/ /*****************************************************************************/
static void Msg_PutFormMsgUsrs (char *Content) static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
{ {
extern const char *Hlp_MESSAGES_Write; extern const char *Hlp_MESSAGES_Write;
extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *The_ClassForm[The_NUM_THEMES];
@ -422,7 +425,7 @@ static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void)
extern const char *Txt_Other_recipients; extern const char *Txt_Other_recipients;
extern const char *Txt_Recipients; extern const char *Txt_Recipients;
extern const char *Txt_nicks_emails_or_IDs_separated_by_commas; extern const char *Txt_nicks_emails_or_IDs_separated_by_commas;
char Nickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1]; char Nickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA + 1];
unsigned Colspan; unsigned Colspan;
bool StdsAndTchsWritten = Gbl.CurrentCrs.Crs.CrsCod > 0 && // If there is a course selected bool StdsAndTchsWritten = Gbl.CurrentCrs.Crs.CrsCod > 0 && // If there is a course selected
(Gbl.Usrs.Me.IBelongToCurrentCrs || // I belong to it (Gbl.Usrs.Me.IBelongToCurrentCrs || // I belong to it
@ -472,7 +475,7 @@ static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void)
/****** Write form fields with subject and content of a message to users *****/ /****** Write form fields with subject and content of a message to users *****/
/*****************************************************************************/ /*****************************************************************************/
static void Msg_WriteFormSubjectAndContentMsgToUsrs (char *Content) static void Msg_WriteFormSubjectAndContentMsgToUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
{ {
extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *The_ClassForm[The_NUM_THEMES];
extern const char *Txt_MSG_Subject; extern const char *Txt_MSG_Subject;
@ -518,10 +521,12 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (char *Content)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get subject */ /* Get subject */
Str_Copy (Gbl.Msg.Subject,row[0],Cns_MAX_BYTES_SUBJECT); Str_Copy (Gbl.Msg.Subject,row[0],
Cns_MAX_BYTES_SUBJECT);
/* Get content */ /* Get content */
Str_Copy (Content,row[1],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[1],
Cns_MAX_BYTES_LONG_TEXT);
/* Free structure that stores the query result */ /* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -598,7 +603,7 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (char *Content)
void Msg_PutHiddenParamAnotherRecipient (const struct UsrData *UsrDat) void Msg_PutHiddenParamAnotherRecipient (const struct UsrData *UsrDat)
{ {
char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
sprintf (NicknameWithArroba,"@%s",UsrDat->Nickname); sprintf (NicknameWithArroba,"@%s",UsrDat->Nickname);
Par_PutHiddenParamString ("OtherRecipients",NicknameWithArroba); Par_PutHiddenParamString ("OtherRecipients",NicknameWithArroba);
@ -647,7 +652,7 @@ void Msg_RecMsgFromUsr (void)
bool MsgAlreadyInserted = false; bool MsgAlreadyInserted = false;
bool CreateNotif; bool CreateNotif;
bool NotifyByEmail; bool NotifyByEmail;
char Content[Cns_MAX_BYTES_LONG_TEXT+1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
struct Image Image; struct Image Image;
bool Error = false; bool Error = false;
@ -2651,7 +2656,9 @@ static void Msg_GetParamOnlyUnreadMsgs (void)
/*****************************************************************************/ /*****************************************************************************/
static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod, static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
time_t *CreatTimeUTC,char *Subject,bool *Deleted) time_t *CreatTimeUTC,
char Subject[Cns_MAX_BYTES_SUBJECT + 1],
bool *Deleted)
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -2703,7 +2710,7 @@ static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
/************************ Get the subject of a message ***********************/ /************************ Get the subject of a message ***********************/
/*****************************************************************************/ /*****************************************************************************/
void Msg_GetMsgSubject (long MsgCod,char *Subject) void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1])
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -2717,7 +2724,8 @@ void Msg_GetMsgSubject (long MsgCod,char *Subject)
{ {
/***** Get subject *****/ /***** Get subject *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Subject,row[0],Cns_MAX_BYTES_SUBJECT); Str_Copy (Subject,row[0],
Cns_MAX_BYTES_SUBJECT);
} }
else else
Subject[0] = '\0'; Subject[0] = '\0';
@ -2730,7 +2738,8 @@ void Msg_GetMsgSubject (long MsgCod,char *Subject)
/*************** Get content and optional image of a message *****************/ /*************** Get content and optional image of a message *****************/
/*****************************************************************************/ /*****************************************************************************/
static void Msg_GetMsgContent (long MsgCod,char *Content,struct Image *Image) static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
struct Image *Image)
{ {
char Query[256]; char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -2751,7 +2760,8 @@ static void Msg_GetMsgContent (long MsgCod,char *Content,struct Image *Image)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/ /****** Get content (row[0]) *****/
Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[0],
Cns_MAX_BYTES_LONG_TEXT);
/****** Get image name (row[1]), title (row[2]) and URL (row[3]) *****/ /****** Get image name (row[1]), title (row[2]) and URL (row[3]) *****/
Img_GetImageNameTitleAndURLFromRow (row[1],row[2],row[3],Image); Img_GetImageNameTitleAndURLFromRow (row[1],row[2],row[3],Image);
@ -2846,8 +2856,8 @@ static void Msg_ShowASentOrReceivedMessage (long MsgNum,long MsgCod)
bool FromThisCrs = false; // Initialized to avoid warning bool FromThisCrs = false; // Initialized to avoid warning
time_t CreatTimeUTC; // Creation time of a message time_t CreatTimeUTC; // Creation time of a message
long CrsCod; long CrsCod;
char Subject[Cns_MAX_BYTES_SUBJECT+1]; char Subject[Cns_MAX_BYTES_SUBJECT + 1];
char Content[Cns_MAX_BYTES_LONG_TEXT+1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
struct Image Image; struct Image Image;
bool Deleted; bool Deleted;
bool Open = true; bool Open = true;
@ -3027,7 +3037,8 @@ void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/***** Copy subject *****/ /***** Copy subject *****/
Str_Copy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,row[0],
Cns_MAX_BYTES_TEXT);
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -3037,7 +3048,8 @@ void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
Length = strlen (row[1]); Length = strlen (row[1]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL) if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content."); Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[1],Length); Str_Copy (*ContentStr,row[1],
Length);
} }
} }
mysql_free_result (mysql_res); mysql_free_result (mysql_res);

View File

@ -93,7 +93,7 @@ void Msg_PutHiddenParamsMsgsFilters (void);
void Msg_GetDistinctCoursesInMyMessages (void); void Msg_GetDistinctCoursesInMyMessages (void);
void Msg_ShowFormSelectCourseSentOrRecMsgs (void); void Msg_ShowFormSelectCourseSentOrRecMsgs (void);
void Msg_ShowFormToFilterMsgs (void); void Msg_ShowFormToFilterMsgs (void);
void Msg_GetMsgSubject (long MsgCod,char *Subject); void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1]);
void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
char **ContentStr,long MsgCod, char **ContentStr,long MsgCod,
unsigned MaxChars,bool GetContent); unsigned MaxChars,bool GetContent);

View File

@ -78,6 +78,8 @@ typedef enum
Net_YOUTUBE, Net_YOUTUBE,
} Net_WebsAndSocialNetworks_t; } Net_WebsAndSocialNetworks_t;
#define Net_MAX_LENGTH_NETWORK_NAME 32
const char *Net_WebsAndSocialNetworksDB[Net_NUM_WEBS_AND_SOCIAL_NETWORKS] = const char *Net_WebsAndSocialNetworksDB[Net_NUM_WEBS_AND_SOCIAL_NETWORKS] =
{ {
"www", // Net_WWW "www", // Net_WWW
@ -225,7 +227,8 @@ void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
{ {
/* Get URL */ /* Get URL */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (URL,row[0],Cns_MAX_LENGTH_WWW); Str_Copy (URL,row[0],
Cns_MAX_LENGTH_WWW);
/* Show the web / social network */ /* Show the web / social network */
Net_ShowAWebOrSocialNet (URL, Net_ShowAWebOrSocialNet (URL,
@ -315,7 +318,8 @@ void Net_ShowFormMyWebsAndSocialNets (void)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get URL */ /* Get URL */
Str_Copy (URL,row[0],Cns_MAX_LENGTH_WWW); Str_Copy (URL,row[0],
Cns_MAX_LENGTH_WWW);
} }
else else
URL[0] = '\0'; URL[0] = '\0';
@ -438,9 +442,10 @@ void Net_ShowWebAndSocialNetworksStats (void)
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumRows,NumRow; unsigned NumRows;
unsigned NumRow;
Net_WebsAndSocialNetworks_t Web; Net_WebsAndSocialNetworks_t Web;
char WebStr[32]; char NetName[Net_MAX_LENGTH_NETWORK_NAME + 1];
unsigned NumUsrsTotalInPlatform; unsigned NumUsrsTotalInPlatform;
unsigned NumUsrs; unsigned NumUsrs;
@ -551,11 +556,12 @@ void Net_ShowWebAndSocialNetworksStats (void)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get web / social network (row[0]) */ /* Get web / social network (row[0]) */
Str_Copy (WebStr,row[0],sizeof (WebStr) - 1); Str_Copy (NetName,row[0],
Net_MAX_LENGTH_NETWORK_NAME);
for (Web = (Net_WebsAndSocialNetworks_t) 0; for (Web = (Net_WebsAndSocialNetworks_t) 0;
Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS; Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
Web++) Web++)
if (!strcmp (Net_WebsAndSocialNetworksDB[Web],WebStr)) if (!strcmp (Net_WebsAndSocialNetworksDB[Web],NetName))
break; break;
if (Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS) if (Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS)
{ {

View File

@ -64,7 +64,7 @@ static void Nck_RemoveNicknameFromDB (const char *Nickname);
bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba) bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba)
{ {
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
unsigned Length; unsigned Length;
const char *Ptr; const char *Ptr;
@ -74,7 +74,7 @@ bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba)
/***** Make a copy of nickname *****/ /***** Make a copy of nickname *****/
Str_Copy (NicknameWithoutArroba,NicknameWithArroba, Str_Copy (NicknameWithoutArroba,NicknameWithArroba,
Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Nck_MAX_BYTES_NICKNAME_FROM_FORM);
Str_RemoveLeadingArrobas (NicknameWithoutArroba); Str_RemoveLeadingArrobas (NicknameWithoutArroba);
Length = strlen (NicknameWithoutArroba); Length = strlen (NicknameWithoutArroba);
@ -101,7 +101,8 @@ bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba)
/************* Get nickname of a user from his/her user's code ***************/ /************* Get nickname of a user from his/her user's code ***************/
/*****************************************************************************/ /*****************************************************************************/
bool Nck_GetNicknameFromUsrCod (long UsrCod,char *Nickname) bool Nck_GetNicknameFromUsrCod (long UsrCod,
char Nickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA + 1])
{ {
char Query[256]; char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -116,12 +117,13 @@ bool Nck_GetNicknameFromUsrCod (long UsrCod,char *Nickname)
{ {
/* Get nickname */ /* Get nickname */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Nickname,row[0],Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA); Str_Copy (Nickname,row[0],
Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
Found = true; Found = true;
} }
else else
{ {
*Nickname = '\0'; Nickname[0] = '\0';
Found = false; Found = false;
} }
@ -139,7 +141,7 @@ bool Nck_GetNicknameFromUsrCod (long UsrCod,char *Nickname)
long Nck_GetUsrCodFromNickname (const char *Nickname) long Nck_GetUsrCodFromNickname (const char *Nickname)
{ {
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA + 1]; char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
@ -150,7 +152,7 @@ long Nck_GetUsrCodFromNickname (const char *Nickname)
{ {
/***** Make a copy without possible starting arrobas *****/ /***** Make a copy without possible starting arrobas *****/
Str_Copy (NicknameWithoutArroba,Nickname, Str_Copy (NicknameWithoutArroba,Nickname,
Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Nck_MAX_BYTES_NICKNAME_FROM_FORM);
Str_RemoveLeadingArrobas (NicknameWithoutArroba); Str_RemoveLeadingArrobas (NicknameWithoutArroba);
/***** Get user's code from database *****/ /***** Get user's code from database *****/
@ -195,7 +197,7 @@ void Nck_ShowFormChangeUsrNickname (void)
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumNicks; unsigned NumNicks;
unsigned NumNick; unsigned NumNick;
char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
/***** Get my nicknames *****/ /***** Get my nicknames *****/
sprintf (Query,"SELECT Nickname FROM usr_nicknames" sprintf (Query,"SELECT Nickname FROM usr_nicknames"
@ -352,17 +354,17 @@ void Nck_UpdateNick (void)
extern const char *Txt_Your_nickname_X_has_been_registered_successfully; extern const char *Txt_Your_nickname_X_has_been_registered_successfully;
extern const char *Txt_The_nickname_entered_X_is_not_valid_; extern const char *Txt_The_nickname_entered_X_is_not_valid_;
char Query[1024]; char Query[1024];
char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
bool Error = false; bool Error = false;
/***** Get new nickname from form *****/ /***** Get new nickname from form *****/
Par_GetParToText ("NewNick",NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Par_GetParToText ("NewNick",NewNicknameWithArroba,Nck_MAX_BYTES_NICKNAME_FROM_FORM);
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
{ {
/***** Remove arrobas at the beginning *****/ /***** Remove arrobas at the beginning *****/
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba, Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Nck_MAX_BYTES_NICKNAME_FROM_FORM);
Str_RemoveLeadingArrobas (NewNicknameWithoutArroba); Str_RemoveLeadingArrobas (NewNicknameWithoutArroba);
/***** Check if new nickname exists in database *****/ /***** Check if new nickname exists in database *****/

View File

@ -34,9 +34,10 @@
#define Nck_MIN_LENGTH_NICKNAME_WITHOUT_ARROBA 3 #define Nck_MIN_LENGTH_NICKNAME_WITHOUT_ARROBA 3
#define Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA 16 #define Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA 16
#define Nck_MAX_BYTES_NICKNAME_WITH_ARROBA 127 // Used for variables that store the characters typed in a form
#define Nck_MAX_BYTES_LIST_NICKS ((Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+2)*Cfg_MAX_USRS_IN_LIST) #define Nck_MAX_BYTES_NICKNAME_FROM_FORM (128 - 1) // For variables that store characters typed in a form
#define Nck_MAX_BYTES_LIST_NICKS ((Nck_MAX_BYTES_NICKNAME_FROM_FORM+2)*Cfg_MAX_USRS_IN_LIST)
/*****************************************************************************/ /*****************************************************************************/
/***************************** Public prototypes *****************************/ /***************************** Public prototypes *****************************/
@ -44,7 +45,8 @@
bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba); bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba);
bool Nck_GetNicknameFromUsrCod (long UsrCod,char *Nickname); bool Nck_GetNicknameFromUsrCod (long UsrCod,
char Nickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA + 1]);
long Nck_GetUsrCodFromNickname (const char *Nickname); long Nck_GetUsrCodFromNickname (const char *Nickname);
void Nck_ShowFormChangeUsrNickname (void); void Nck_ShowFormChangeUsrNickname (void);

View File

@ -346,11 +346,11 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing)
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
char StrWidth[10+2+1]; char StrWidth[10+2+1];
char PathRelRSSFile[PATH_MAX+1]; char PathRelRSSFile[PATH_MAX + 1];
long NotCod; long NotCod;
unsigned long NumNot; unsigned long NumNot;
unsigned long NumNotices; unsigned long NumNotices;
char Content[Cns_MAX_BYTES_TEXT+1]; char Content[Cns_MAX_BYTES_TEXT + 1];
time_t TimeUTC; time_t TimeUTC;
long UsrCod; long UsrCod;
unsigned UnsignedNum; unsigned UnsignedNum;
@ -411,7 +411,8 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing)
UsrCod = Str_ConvertStrCodToLongCod (row[2]); UsrCod = Str_ConvertStrCodToLongCod (row[2]);
/* Get the content (row[3]) and insert links */ /* Get the content (row[3]) and insert links */
Str_Copy (Content,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[3],
Cns_MAX_BYTES_TEXT);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT, Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
Not_MaxCharsURLOnScreen[TypeNoticesListing]); Not_MaxCharsURLOnScreen[TypeNoticesListing]);
if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES) if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES)
@ -532,7 +533,7 @@ static void Not_GetDataAndShowNotice (long NotCod)
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
char Content[Cns_MAX_BYTES_TEXT+1]; char Content[Cns_MAX_BYTES_TEXT + 1];
time_t TimeUTC; time_t TimeUTC;
long UsrCod; long UsrCod;
unsigned UnsignedNum; unsigned UnsignedNum;
@ -555,7 +556,8 @@ static void Not_GetDataAndShowNotice (long NotCod)
UsrCod = Str_ConvertStrCodToLongCod (row[1]); UsrCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get the content (row[2]) and insert links*/ /* Get the content (row[2]) and insert links*/
Str_Copy (Content,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (Content,row[2],
Cns_MAX_BYTES_TEXT);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT, Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]); Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]);
@ -767,7 +769,8 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/***** Copy summary *****/ /***** Copy summary *****/
Str_Copy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,row[0],
Cns_MAX_BYTES_TEXT);
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -777,7 +780,8 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
Length = strlen (row[0]); Length = strlen (row[0]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL) if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content."); Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[0],Length); Str_Copy (*ContentStr,row[0],
Length);
} }
} }
mysql_free_result (mysql_res); mysql_free_result (mysql_res);

View File

@ -80,7 +80,8 @@ bool Par_GetQueryString (void)
char UnsignedLongStr[10 + 1]; char UnsignedLongStr[10 + 1];
unsigned long UnsignedLong; unsigned long UnsignedLong;
Str_Copy (Method,getenv ("REQUEST_METHOD"),Par_MAX_LENGTH_METHOD); Str_Copy (Method,getenv ("REQUEST_METHOD"),
Par_MAX_LENGTH_METHOD);
if (!strcmp (Method,"GET")) if (!strcmp (Method,"GET"))
{ {
@ -105,7 +106,8 @@ bool Par_GetQueryString (void)
/* Get content length */ /* Get content length */
if (getenv ("CONTENT_LENGTH")) if (getenv ("CONTENT_LENGTH"))
{ {
Str_Copy (UnsignedLongStr,getenv ("CONTENT_LENGTH"),10); Str_Copy (UnsignedLongStr,getenv ("CONTENT_LENGTH"),
10);
if (sscanf (UnsignedLongStr,"%lu",&UnsignedLong) != 1) if (sscanf (UnsignedLongStr,"%lu",&UnsignedLong) != 1)
return false; return false;
Gbl.Params.ContentLength = (size_t) UnsignedLong; Gbl.Params.ContentLength = (size_t) UnsignedLong;
@ -119,7 +121,8 @@ bool Par_GetQueryString (void)
if (getenv ("CONTENT_TYPE") == NULL) if (getenv ("CONTENT_TYPE") == NULL)
return false; return false;
Str_Copy (ContentType,getenv ("CONTENT_TYPE"),Par_MAX_LENGTH_CONTENT_TYPE); Str_Copy (ContentType,getenv ("CONTENT_TYPE"),
Par_MAX_LENGTH_CONTENT_TYPE);
if (!strncmp (ContentType,"multipart/form-data",strlen ("multipart/form-data"))) if (!strncmp (ContentType,"multipart/form-data",strlen ("multipart/form-data")))
{ {
@ -581,8 +584,8 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName,
{ {
case Act_CONT_NORM: case Act_CONT_NORM:
if (PtrDst) if (PtrDst)
Str_Copy (PtrDst,&Gbl.Params.QueryString[Param->Value.Start], strncpy (PtrDst,&Gbl.Params.QueryString[Param->Value.Start],
Param->Value.Length); Param->Value.Length);
break; break;
case Act_CONT_DATA: case Act_CONT_DATA:
if (Param->FileName.Start == 0 && // Copy into destination only if it's not a file if (Param->FileName.Start == 0 && // Copy into destination only if it's not a file
@ -650,7 +653,7 @@ void Par_GetMainParameters (void)
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS]; extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
char UnsignedStr[10+1]; char UnsignedStr[10+1];
unsigned UnsignedNum; unsigned UnsignedNum;
char Nickname[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char Nickname[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
char LongStr[1+10+1]; char LongStr[1+10+1];
/***** Reset codes of country, institution, centre, degree and course *****/ /***** Reset codes of country, institution, centre, degree and course *****/
@ -677,7 +680,7 @@ void Par_GetMainParameters (void)
/***** Get another user's nickname, if exists /***** Get another user's nickname, if exists
(this nickname is used to go to another user's profile, (this nickname is used to go to another user's profile,
not to get the logged user) *****/ not to get the logged user) *****/
if (Par_GetParToText ("usr",Nickname,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA)) if (Par_GetParToText ("usr",Nickname,Nck_MAX_BYTES_NICKNAME_FROM_FORM))
{ {
if (Nickname[0]) if (Nickname[0])
{ {
@ -693,7 +696,7 @@ void Par_GetMainParameters (void)
Gbl.Action.Act = ActSeePubPrf; // Set default action if no other is specified Gbl.Action.Act = ActSeePubPrf; // Set default action if no other is specified
} }
} }
else if (Par_GetParToText ("agd",Nickname,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA)) else if (Par_GetParToText ("agd",Nickname,Nck_MAX_BYTES_NICKNAME_FROM_FORM))
{ {
if (Nickname[0]) if (Nickname[0])
{ {

View File

@ -179,8 +179,7 @@ void Pwd_ActChgMyPwd1 (void)
/***** Check if I have written twice the same password *****/ /***** Check if I have written twice the same password *****/
if (strcmp (NewPlainPassword[0],NewPlainPassword[1])) if (strcmp (NewPlainPassword[0],NewPlainPassword[1]))
// Passwords don't match // Passwords don't match
Str_Copy (Gbl.Message,Txt_You_have_not_written_twice_the_same_new_password, sprintf (Gbl.Message,"%s",Txt_You_have_not_written_twice_the_same_new_password);
Lay_MAX_BYTES_ALERT);
else else
{ {
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT, Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,
@ -192,15 +191,13 @@ void Pwd_ActChgMyPwd1 (void)
Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64); Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64);
Ses_UpdateSessionDataInDB (); Ses_UpdateSessionDataInDB ();
Enr_UpdateUsrData (&Gbl.Usrs.Me.UsrDat); Enr_UpdateUsrData (&Gbl.Usrs.Me.UsrDat);
Str_Copy (Gbl.Message,Txt_Your_password_has_been_changed_successfully, sprintf (Gbl.Message,"%s",Txt_Your_password_has_been_changed_successfully);
Lay_MAX_BYTES_ALERT);
Gbl.Usrs.Error = false; Gbl.Usrs.Error = false;
} }
} }
} }
else else
Str_Copy (Gbl.Message,Txt_You_have_not_entered_your_password_correctly, sprintf (Gbl.Message,"%s",Txt_You_have_not_entered_your_password_correctly);
Lay_MAX_BYTES_ALERT);
} }
void Pwd_ActChgMyPwd2 (void) void Pwd_ActChgMyPwd2 (void)
@ -501,8 +498,7 @@ void Pwd_UpdateOtherPwd1 (void)
if (strcmp (NewPlainPassword[0],NewPlainPassword[1])) if (strcmp (NewPlainPassword[0],NewPlainPassword[1]))
// Paswords don't match // Paswords don't match
Str_Copy (Gbl.Message,Txt_You_have_not_written_twice_the_same_new_password, sprintf (Gbl.Message,"%s",Txt_You_have_not_written_twice_the_same_new_password);
Lay_MAX_BYTES_ALERT);
else else
{ {
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT, Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,
@ -522,12 +518,10 @@ void Pwd_UpdateOtherPwd1 (void)
} }
} }
else else
Str_Copy (Gbl.Message,Txt_User_not_found_or_you_do_not_have_permission_, sprintf (Gbl.Message,"%s",Txt_User_not_found_or_you_do_not_have_permission_);
Lay_MAX_BYTES_ALERT);
} }
else // User not found else // User not found
Str_Copy (Gbl.Message,Txt_User_not_found_or_you_do_not_have_permission_, sprintf (Gbl.Message,"%s",Txt_User_not_found_or_you_do_not_have_permission_);
Lay_MAX_BYTES_ALERT);
} }
void Pwd_UpdateOtherPwd2 (void) void Pwd_UpdateOtherPwd2 (void)
@ -563,8 +557,7 @@ bool Pwd_SlowCheckIfPasswordIsGood (const char *PlainPassword,
/***** Check if password is found in user's ID, first name or surnames of anybody *****/ /***** Check if password is found in user's ID, first name or surnames of anybody *****/
if (Pwd_CheckIfPasswdIsUsrIDorName (PlainPassword)) // PlainPassword is a user's ID, name or surname if (Pwd_CheckIfPasswdIsUsrIDorName (PlainPassword)) // PlainPassword is a user's ID, name or surname
{ {
Str_Copy (Gbl.Message,Txt_The_password_is_too_trivial_, sprintf (Gbl.Message,"%s",Txt_The_password_is_too_trivial_);
Lay_MAX_BYTES_ALERT);
return false; return false;
} }
@ -572,8 +565,7 @@ bool Pwd_SlowCheckIfPasswordIsGood (const char *PlainPassword,
if (Pwd_GetNumOtherUsrsWhoUseThisPassword (EncryptedPassword,UsrCod) > if (Pwd_GetNumOtherUsrsWhoUseThisPassword (EncryptedPassword,UsrCod) >
Pwd_MAX_OTHER_USERS_USING_THE_SAME_PASSWORD) Pwd_MAX_OTHER_USERS_USING_THE_SAME_PASSWORD)
{ {
Str_Copy (Gbl.Message,Txt_The_password_is_too_trivial_, sprintf (Gbl.Message,"%s",Txt_The_password_is_too_trivial_);
Lay_MAX_BYTES_ALERT);
return false; return false;
} }
@ -650,8 +642,7 @@ bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword)
/***** Check spaces in password *****/ /***** Check spaces in password *****/
if (strchr (PlainPassword,(int) ' ') != NULL) // PlainPassword with spaces if (strchr (PlainPassword,(int) ' ') != NULL) // PlainPassword with spaces
{ {
Str_Copy (Gbl.Message,Txt_The_password_can_not_contain_spaces, sprintf (Gbl.Message,"%s",Txt_The_password_can_not_contain_spaces);
Lay_MAX_BYTES_ALERT);
return false; return false;
} }
@ -663,8 +654,7 @@ bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword)
ItsANumber = false; ItsANumber = false;
if (ItsANumber) if (ItsANumber)
{ {
Str_Copy (Gbl.Message,Txt_The_password_can_not_consist_only_of_digits, sprintf (Gbl.Message,"%s",Txt_The_password_can_not_consist_only_of_digits);
Lay_MAX_BYTES_ALERT);
return false; return false;
} }

View File

@ -1157,14 +1157,17 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
} }
/***** Hidden div to pass user's name to Javascript *****/ /***** Hidden div to pass user's name to Javascript *****/
Str_Copy (FullName,UsrDat->FullName,Usr_MAX_BYTES_FULL_NAME); Str_Copy (FullName,UsrDat->FullName,
Usr_MAX_BYTES_FULL_NAME);
if (PutZoomCode) if (PutZoomCode)
{ {
Str_Copy (ShortName,UsrDat->FirstName,Usr_MAX_BYTES_FULL_NAME); Str_Copy (ShortName,UsrDat->FirstName,
Usr_MAX_BYTES_FULL_NAME);
Str_LimitLengthHTMLStr (ShortName,23); Str_LimitLengthHTMLStr (ShortName,23);
Surnames[0] = '\0'; Surnames[0] = '\0';
if (UsrDat->Surname1[0]) if (UsrDat->Surname1[0])
Str_Copy (Surnames,UsrDat->Surname1,Usr_MAX_BYTES_SURNAMES); Str_Copy (Surnames,UsrDat->Surname1,
Usr_MAX_BYTES_SURNAMES);
if (UsrDat->Surname2[0]) if (UsrDat->Surname2[0])
{ {
Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES); Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES);
@ -2372,7 +2375,8 @@ static void Pho_ShowDegreeAvgPhotoAndStat (struct Degree *Deg,
Pho_ComputePhotoSize (NumStds,NumStdsWithPhoto,&PhotoWidth,&PhotoHeight); Pho_ComputePhotoSize (NumStds,NumStdsWithPhoto,&PhotoWidth,&PhotoHeight);
/***** Make a copy of the degree short name *****/ /***** Make a copy of the degree short name *****/
Str_Copy (CopyOfDegShortName,Deg->ShrtName,Deg_MAX_LENGTH_DEGREE_SHRT_NAME); Str_Copy (CopyOfDegShortName,Deg->ShrtName,
Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
Str_LimitLengthHTMLStr (CopyOfDegShortName, Str_LimitLengthHTMLStr (CopyOfDegShortName,
SeeOrPrint == Pho_DEGREES_SEE ? 10 : SeeOrPrint == Pho_DEGREES_SEE ? 10 :
15); 15);

View File

@ -302,10 +302,12 @@ void Plc_GetListPlaces (void)
Lay_ShowErrorAndExit ("Wrong code of place."); Lay_ShowErrorAndExit ("Wrong code of place.");
/* Get the short name of the place (row[1]) */ /* Get the short name of the place (row[1]) */
Str_Copy (Plc->ShrtName,row[1],Plc_MAX_LENGTH_PLACE_SHRT_NAME); Str_Copy (Plc->ShrtName,row[1],
Plc_MAX_LENGTH_PLACE_SHRT_NAME);
/* Get the full name of the place (row[2]) */ /* Get the full name of the place (row[2]) */
Str_Copy (Plc->FullName,row[2],Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Plc->FullName,row[2],
Plc_MAX_LENGTH_PLACE_FULL_NAME);
/* Get number of centres in this place (row[3]) */ /* Get number of centres in this place (row[3]) */
if (sscanf (row[3],"%u",&Plc->NumCtrs) != 1) if (sscanf (row[3],"%u",&Plc->NumCtrs) != 1)
@ -347,8 +349,10 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
} }
else if (Plc->PlcCod == 0) else if (Plc->PlcCod == 0)
{ {
Str_Copy (Plc->ShrtName,Txt_Another_place,Plc_MAX_LENGTH_PLACE_SHRT_NAME); Str_Copy (Plc->ShrtName,Txt_Another_place,
Str_Copy (Plc->FullName,Txt_Another_place,Plc_MAX_LENGTH_PLACE_FULL_NAME); Plc_MAX_LENGTH_PLACE_SHRT_NAME);
Str_Copy (Plc->FullName,Txt_Another_place,
Plc_MAX_LENGTH_PLACE_FULL_NAME);
} }
else if (Plc->PlcCod > 0) else if (Plc->PlcCod > 0)
{ {
@ -377,10 +381,12 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the short name of the place (row[0]) */ /* Get the short name of the place (row[0]) */
Str_Copy (Plc->ShrtName,row[0],Plc_MAX_LENGTH_PLACE_SHRT_NAME); Str_Copy (Plc->ShrtName,row[0],
Plc_MAX_LENGTH_PLACE_SHRT_NAME);
/* Get the full name of the place (row[1]) */ /* Get the full name of the place (row[1]) */
Str_Copy (Plc->FullName,row[1],Plc_MAX_LENGTH_PLACE_FULL_NAME); Str_Copy (Plc->FullName,row[1],
Plc_MAX_LENGTH_PLACE_FULL_NAME);
/* Get number of centres in this place (row[2]) */ /* Get number of centres in this place (row[2]) */
if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1) if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1)
@ -651,7 +657,8 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (CurrentPlcName,NewPlcName,MaxLength); Str_Copy (CurrentPlcName,NewPlcName,
MaxLength);
Plc_EditPlaces (); Plc_EditPlaces ();
} }

View File

@ -227,22 +227,28 @@ static void Plg_GetListPlugins (void)
Lay_ShowErrorAndExit ("Wrong code of plugin."); Lay_ShowErrorAndExit ("Wrong code of plugin.");
/* Get the name of the plugin (row[1]) */ /* Get the name of the plugin (row[1]) */
Str_Copy (Plg->Name,row[1],Plg_MAX_LENGTH_PLUGIN_NAME); Str_Copy (Plg->Name,row[1],
Plg_MAX_LENGTH_PLUGIN_NAME);
/* Get the description of the plugin (row[2]) */ /* Get the description of the plugin (row[2]) */
Str_Copy (Plg->Description,row[2],Plg_MAX_LENGTH_PLUGIN_DESCRIPTION); Str_Copy (Plg->Description,row[2],
Plg_MAX_LENGTH_PLUGIN_DESCRIPTION);
/* Get the logo of the plugin (row[3]) */ /* Get the logo of the plugin (row[3]) */
Str_Copy (Plg->Logo,row[3],Plg_MAX_LENGTH_PLUGIN_LOGO); Str_Copy (Plg->Logo,row[3],
Plg_MAX_LENGTH_PLUGIN_LOGO);
/* Get the application key of the plugin (row[4]) */ /* Get the application key of the plugin (row[4]) */
Str_Copy (Plg->AppKey,row[4],Plg_MAX_LENGTH_PLUGIN_APP_KEY); Str_Copy (Plg->AppKey,row[4],
Plg_MAX_LENGTH_PLUGIN_APP_KEY);
/* Get the URL of the plugin (row[5]) */ /* Get the URL of the plugin (row[5]) */
Str_Copy (Plg->URL,row[5],Cns_MAX_LENGTH_WWW); Str_Copy (Plg->URL,row[5],
Cns_MAX_LENGTH_WWW);
/* Get the IP of the plugin (row[6]) */ /* Get the IP of the plugin (row[6]) */
Str_Copy (Plg->IP,row[6],Cns_MAX_LENGTH_IP); Str_Copy (Plg->IP,row[6],
Cns_MAX_LENGTH_IP);
} }
} }
else else
@ -288,22 +294,28 @@ bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get the name of the plugin (row[0]) */ /* Get the name of the plugin (row[0]) */
Str_Copy (Plg->Name,row[0],Plg_MAX_LENGTH_PLUGIN_NAME); Str_Copy (Plg->Name,row[0],
Plg_MAX_LENGTH_PLUGIN_NAME);
/* Get the description of the plugin (row[1]) */ /* Get the description of the plugin (row[1]) */
Str_Copy (Plg->Description,row[1],Plg_MAX_LENGTH_PLUGIN_DESCRIPTION); Str_Copy (Plg->Description,row[1],
Plg_MAX_LENGTH_PLUGIN_DESCRIPTION);
/* Get the logo of the plugin (row[2]) */ /* Get the logo of the plugin (row[2]) */
Str_Copy (Plg->Logo,row[2],Plg_MAX_LENGTH_PLUGIN_LOGO); Str_Copy (Plg->Logo,row[2],
Plg_MAX_LENGTH_PLUGIN_LOGO);
/* Get the application key of the plugin (row[3]) */ /* Get the application key of the plugin (row[3]) */
Str_Copy (Plg->AppKey,row[3],Plg_MAX_LENGTH_PLUGIN_APP_KEY); Str_Copy (Plg->AppKey,row[3],
Plg_MAX_LENGTH_PLUGIN_APP_KEY);
/* Get the URL of the plugin (row[4]) */ /* Get the URL of the plugin (row[4]) */
Str_Copy (Plg->URL,row[4],Cns_MAX_LENGTH_WWW); Str_Copy (Plg->URL,row[4],
Cns_MAX_LENGTH_WWW);
/* Get the IP of the plugin (row[5]) */ /* Get the IP of the plugin (row[5]) */
Str_Copy (Plg->IP,row[5],Cns_MAX_LENGTH_IP); Str_Copy (Plg->IP,row[5],
Cns_MAX_LENGTH_IP);
} }
else else
PluginFound = false; PluginFound = false;
@ -569,7 +581,8 @@ void Plg_RenamePlugin (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Plg->Name,NewPlgName,Plg_MAX_LENGTH_PLUGIN_NAME); Str_Copy (Plg->Name,NewPlgName,
Plg_MAX_LENGTH_PLUGIN_NAME);
Plg_EditPlugins (); Plg_EditPlugins ();
} }
@ -629,7 +642,8 @@ void Plg_ChangePlgDescription (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Plg->Description,NewDescription,Plg_MAX_LENGTH_PLUGIN_DESCRIPTION); Str_Copy (Plg->Description,NewDescription,
Plg_MAX_LENGTH_PLUGIN_DESCRIPTION);
Plg_EditPlugins (); Plg_EditPlugins ();
} }
@ -672,7 +686,8 @@ void Plg_ChangePlgLogo (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_logo_empty); Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_logo_empty);
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Plg->Logo,NewLogo,Plg_MAX_LENGTH_PLUGIN_LOGO); Str_Copy (Plg->Logo,NewLogo,
Plg_MAX_LENGTH_PLUGIN_LOGO);
Plg_EditPlugins (); Plg_EditPlugins ();
} }
@ -715,7 +730,8 @@ void Plg_ChangePlgAppKey (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_logo_empty); // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_logo_empty); // TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Plg->AppKey,NewAppKey,Plg_MAX_LENGTH_PLUGIN_APP_KEY); Str_Copy (Plg->AppKey,NewAppKey,
Plg_MAX_LENGTH_PLUGIN_APP_KEY);
Plg_EditPlugins (); Plg_EditPlugins ();
} }
@ -758,7 +774,8 @@ void Plg_ChangePlgURL (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_URL_empty); Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_URL_empty);
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Plg->URL,NewURL,Cns_MAX_LENGTH_WWW); Str_Copy (Plg->URL,NewURL,
Cns_MAX_LENGTH_WWW);
Plg_EditPlugins (); Plg_EditPlugins ();
} }
@ -801,7 +818,8 @@ void Plg_ChangePlgIP (void)
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_IP_address_empty); Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_IP_address_empty);
/***** Show the form again *****/ /***** Show the form again *****/
Str_Copy (Plg->IP,NewIP,Cns_MAX_LENGTH_IP); Str_Copy (Plg->IP,NewIP,
Cns_MAX_LENGTH_IP);
Plg_EditPlugins (); Plg_EditPlugins ();
} }

View File

@ -180,7 +180,7 @@ static void Prf_RequestUserProfileWithDefaultNickname (const char *DefaultNickna
"</label>", "</label>",
The_ClassForm[Gbl.Prefs.Theme], The_ClassForm[Gbl.Prefs.Theme],
Txt_Nickname, Txt_Nickname,
Nck_MAX_BYTES_NICKNAME_WITH_ARROBA, Nck_MAX_BYTES_NICKNAME_FROM_FORM,
DefaultNickname); DefaultNickname);
/***** Send button and end frame *****/ /***** Send button and end frame *****/

View File

@ -624,7 +624,10 @@ void Rec_AskConfirmRemFieldWithRecords (unsigned NumRecords)
char Message_part2[512]; char Message_part2[512];
/***** Get from the database the name of the field *****/ /***** Get from the database the name of the field *****/
Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,Gbl.CurrentCrs.Records.Field.Name,&Gbl.CurrentCrs.Records.Field.NumLines,&Gbl.CurrentCrs.Records.Field.Visibility); Rec_GetFieldByCod (Gbl.CurrentCrs.Records.Field.FieldCod,
Gbl.CurrentCrs.Records.Field.Name,
&Gbl.CurrentCrs.Records.Field.NumLines,
&Gbl.CurrentCrs.Records.Field.Visibility);
/***** Write mensaje to ask confirmation of deletion *****/ /***** Write mensaje to ask confirmation of deletion *****/
sprintf (Gbl.Message,Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_X, sprintf (Gbl.Message,Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_X,
@ -704,7 +707,8 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_LENGTH_NAME_FIELD
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Name of the field */ /* Name of the field */
Str_Copy (Name,row[0],Rec_MAX_LENGTH_NAME_FIELD); Str_Copy (Name,row[0],
Rec_MAX_LENGTH_NAME_FIELD);
/* Number of lines of the field (row[1]) */ /* Number of lines of the field (row[1]) */
*NumLines = Rec_ConvertToNumLinesField (row[1]); *NumLines = Rec_ConvertToNumLinesField (row[1]);
@ -1723,7 +1727,8 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
{ {
if (ThisFieldHasText) if (ThisFieldHasText)
{ {
Str_Copy (Text,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (Text,row[0],
Cns_MAX_BYTES_TEXT);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Text,Cns_MAX_BYTES_TEXT,false); Text,Cns_MAX_BYTES_TEXT,false);
fprintf (Gbl.F.Out,"%s",Text); fprintf (Gbl.F.Out,"%s",Text);
@ -2577,17 +2582,20 @@ static void Rec_ShowFullName (struct UsrData *UsrDat)
fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID REC_NAME LEFT_TOP\">"); fprintf (Gbl.F.Out,"<td class=\"REC_C2_MID REC_NAME LEFT_TOP\">");
/***** First name *****/ /***** First name *****/
Str_Copy (Name,UsrDat->FirstName,Usr_MAX_BYTES_NAME); Str_Copy (Name,UsrDat->FirstName,
Usr_MAX_BYTES_NAME);
Str_LimitLengthHTMLStr (Name,20); Str_LimitLengthHTMLStr (Name,20);
fprintf (Gbl.F.Out,"%s<br />",Name); fprintf (Gbl.F.Out,"%s<br />",Name);
/***** Surname 1 *****/ /***** Surname 1 *****/
Str_Copy (Name,UsrDat->Surname1,Usr_MAX_BYTES_NAME); Str_Copy (Name,UsrDat->Surname1,
Usr_MAX_BYTES_NAME);
Str_LimitLengthHTMLStr (Name,20); Str_LimitLengthHTMLStr (Name,20);
fprintf (Gbl.F.Out,"%s<br />",Name); fprintf (Gbl.F.Out,"%s<br />",Name);
/***** Surname 2 *****/ /***** Surname 2 *****/
Str_Copy (Name,UsrDat->Surname2,Usr_MAX_BYTES_NAME); Str_Copy (Name,UsrDat->Surname2,
Usr_MAX_BYTES_NAME);
Str_LimitLengthHTMLStr (Name,20); Str_LimitLengthHTMLStr (Name,20);
fprintf (Gbl.F.Out,"%s",Name); fprintf (Gbl.F.Out,"%s",Name);
@ -2601,7 +2609,7 @@ static void Rec_ShowFullName (struct UsrData *UsrDat)
static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks) static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks)
{ {
extern const char *Txt_View_public_profile; extern const char *Txt_View_public_profile;
char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
"<td class=\"REC_C2_MID REC_NAME LEFT_BOTTOM\">" "<td class=\"REC_C2_MID REC_NAME LEFT_BOTTOM\">"

View File

@ -355,6 +355,7 @@ void Sch_PutFormToSearchInPageTopHeading (void)
ActionSearch = ActSysSch; ActionSearch = ActSysSch;
Gbl.Scope.Default = Sco_SCOPE_SYS; Gbl.Scope.Default = Sco_SCOPE_SYS;
} }
Act_FormStart (ActionSearch); Act_FormStart (ActionSearch);
Sco_GetScope ("ScopeSch"); Sco_GetScope ("ScopeSch");
Sco_PutParamScope ("ScopeSch",Gbl.Scope.Current); Sco_PutParamScope ("ScopeSch",Gbl.Scope.Current);

View File

@ -80,7 +80,8 @@ void Ses_GetNumSessions (void)
void Ses_CreateSession (void) void Ses_CreateSession (void)
{ {
/***** Create a unique name for the session *****/ /***** Create a unique name for the session *****/
Str_Copy (Gbl.Session.Id,Gbl.UniqueNameEncrypted,Ses_LENGTH_SESSION_ID); Str_Copy (Gbl.Session.Id,Gbl.UniqueNameEncrypted,
Ses_LENGTH_SESSION_ID);
/***** Check that session is not open *****/ /***** Check that session is not open *****/
if (Ses_CheckIfSessionExists (Gbl.Session.Id)) if (Ses_CheckIfSessionExists (Gbl.Session.Id))
@ -315,7 +316,8 @@ bool Ses_GetSessionData (void)
Gbl.Search.WhatToSearch = (Sch_WhatToSearch_t) UnsignedNum; Gbl.Search.WhatToSearch = (Sch_WhatToSearch_t) UnsignedNum;
/* Get search string (row[9]) */ /* Get search string (row[9]) */
Str_Copy (Gbl.Search.Str,row[9],Sch_MAX_LENGTH_STRING_TO_FIND); Str_Copy (Gbl.Search.Str,row[9],
Sch_MAX_LENGTH_STRING_TO_FIND);
} }
Result = true; Result = true;
@ -428,8 +430,11 @@ unsigned Ses_GetHiddenParFromDB (Act_Action_t Action,const char *ParamName,char
{ {
/***** Get the value del parameter *****/ /***** Get the value del parameter *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (ParamValue,row[0],MaxBytes);
ParameterIsTooBig = (strlen (row[0]) > MaxBytes); ParameterIsTooBig = (strlen (row[0]) > MaxBytes);
if (!ParameterIsTooBig)
Str_Copy (ParamValue,row[0],
MaxBytes);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/

View File

@ -113,7 +113,7 @@ struct SocialComment
long NotCod; // Note code long NotCod; // Note code
time_t DateTimeUTC; time_t DateTimeUTC;
unsigned NumFavs; // Number of times (users) this comment has been favourited unsigned NumFavs; // Number of times (users) this comment has been favourited
char Content[Cns_MAX_BYTES_LONG_TEXT+1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
struct Image Image; struct Image Image;
}; };
@ -1475,7 +1475,7 @@ static void Soc_GetAndWriteSocialPost (long PstCod)
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRows; unsigned long NumRows;
char Content[Cns_MAX_BYTES_LONG_TEXT+1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
struct Image Image; struct Image Image;
/***** Initialize image *****/ /***** Initialize image *****/
@ -1493,7 +1493,8 @@ static void Soc_GetAndWriteSocialPost (long PstCod)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/ /****** Get content (row[0]) *****/
Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[0],
Cns_MAX_BYTES_LONG_TEXT);
/****** Get image name (row[1]), title (row[2]) and URL (row[3]) *****/ /****** Get image name (row[1]), title (row[2]) and URL (row[3]) *****/
Img_GetImageNameTitleAndURLFromRow (row[1],row[2],row[3],&Image); Img_GetImageNameTitleAndURLFromRow (row[1],row[2],row[3],&Image);
@ -1982,7 +1983,8 @@ static void Soc_PutFormToWriteNewPost (void)
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_NOTE_RIGHT_CONTAINER\">"); fprintf (Gbl.F.Out,"<div class=\"SOCIAL_NOTE_RIGHT_CONTAINER\">");
/* Write author's full name and nickname */ /* Write author's full name and nickname */
Str_Copy (FullName,Gbl.Usrs.Me.UsrDat.FullName,Usr_MAX_BYTES_FULL_NAME); Str_Copy (FullName,Gbl.Usrs.Me.UsrDat.FullName,
Usr_MAX_BYTES_FULL_NAME);
Str_LimitLengthHTMLStr (FullName,16); Str_LimitLengthHTMLStr (FullName,16);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_RIGHT_AUTHOR\">" fprintf (Gbl.F.Out,"<div class=\"SOCIAL_RIGHT_AUTHOR\">"
"<span class=\"DAT_N_BOLD\">%s</span>" "<span class=\"DAT_N_BOLD\">%s</span>"
@ -4561,7 +4563,8 @@ static void Soc_GetDataOfSocialCommentFromRow (MYSQL_ROW row,struct SocialCommen
SocCom->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]); SocCom->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]);
/***** Get content (row[4]) *****/ /***** Get content (row[4]) *****/
Str_Copy (SocCom->Content,row[4],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (SocCom->Content,row[4],
Cns_MAX_BYTES_LONG_TEXT);
/***** Get number of times this comment has been favourited *****/ /***** Get number of times this comment has been favourited *****/
SocCom->NumFavs = Soc_GetNumTimesACommHasBeenFav (SocCom); SocCom->NumFavs = Soc_GetNumTimesACommHasBeenFav (SocCom);
@ -4654,7 +4657,7 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
MYSQL_ROW row; MYSQL_ROW row;
struct SocialPublishing SocPub; struct SocialPublishing SocPub;
struct SocialNote SocNot; struct SocialNote SocNot;
char Content[Cns_MAX_BYTES_LONG_TEXT+1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
size_t Length; size_t Length;
bool ContentCopied = false; bool ContentCopied = false;
@ -4701,7 +4704,8 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/ /****** Get content (row[0]) *****/
Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[0],
Cns_MAX_BYTES_LONG_TEXT);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -4713,14 +4717,16 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
Length = strlen (Content); Length = strlen (Content);
if ((*ContentStr = (char *) malloc (Length + 1)) != NULL) if ((*ContentStr = (char *) malloc (Length + 1)) != NULL)
{ {
Str_Copy (*ContentStr,Content,Length); Str_Copy (*ContentStr,Content,
Length);
ContentCopied = true; ContentCopied = true;
} }
} }
/***** Copy summary string *****/ /***** Copy summary string *****/
Str_LimitLengthHTMLStr (Content,MaxChars); Str_LimitLengthHTMLStr (Content,MaxChars);
Str_Copy (SummaryStr,Content,Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,Content,
Cns_MAX_BYTES_TEXT);
} }
else else
Soc_GetNoteSummary (&SocNot,SummaryStr,Soc_MAX_BYTES_SUMMARY); Soc_GetNoteSummary (&SocNot,SummaryStr,Soc_MAX_BYTES_SUMMARY);
@ -4737,7 +4743,8 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/****** Get content (row[0]) *****/ /****** Get content (row[0]) *****/
Str_Copy (Content,row[0],Cns_MAX_BYTES_LONG_TEXT); Str_Copy (Content,row[0],
Cns_MAX_BYTES_LONG_TEXT);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -4749,14 +4756,16 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
Length = strlen (Content); Length = strlen (Content);
if ((*ContentStr = (char *) malloc (Length + 1)) != NULL) if ((*ContentStr = (char *) malloc (Length + 1)) != NULL)
{ {
Str_Copy (*ContentStr,Content,Length); Str_Copy (*ContentStr,Content,
Length);
ContentCopied = true; ContentCopied = true;
} }
} }
/***** Copy summary string *****/ /***** Copy summary string *****/
Str_LimitLengthHTMLStr (Content,MaxChars); Str_LimitLengthHTMLStr (Content,MaxChars);
Str_Copy (SummaryStr,Content,Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,Content,
Cns_MAX_BYTES_TEXT);
break; break;
} }
@ -4824,7 +4833,8 @@ static void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const
if (IsNickname) if (IsNickname)
{ {
/* Copy nickname */ /* Copy nickname */
Str_Copy (UsrDat.Nickname,Nickname.PtrStart,Nickname.Length); Str_Copy (UsrDat.Nickname,Nickname.PtrStart,
Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
if ((UsrDat.UsrCod = Nck_GetUsrCodFromNickname (UsrDat.Nickname)) > 0) if ((UsrDat.UsrCod = Nck_GetUsrCodFromNickname (UsrDat.Nickname)) > 0)
if (UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // It's not me if (UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) // It's not me

View File

@ -255,7 +255,8 @@ The IP address of the remote host making the request.
void Sta_GetRemoteAddr (void) void Sta_GetRemoteAddr (void)
{ {
if (getenv ("REMOTE_ADDR")) if (getenv ("REMOTE_ADDR"))
Str_Copy (Gbl.IP,getenv ("REMOTE_ADDR"),Cns_MAX_LENGTH_IP); Str_Copy (Gbl.IP,getenv ("REMOTE_ADDR"),
Cns_MAX_LENGTH_IP);
else else
Gbl.IP[0] = '\0'; Gbl.IP[0] = '\0';
} }
@ -983,7 +984,8 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
switch (Gbl.Stat.CountType) switch (Gbl.Stat.CountType)
{ {
case Sta_TOTAL_CLICKS: case Sta_TOTAL_CLICKS:
Str_Copy (StrQueryCountType,"COUNT(*)",Sta_MAX_LENGTH_COUNT_TYPE); Str_Copy (StrQueryCountType,"COUNT(*)",
Sta_MAX_LENGTH_COUNT_TYPE);
break; break;
case Sta_DISTINCT_USRS: case Sta_DISTINCT_USRS:
sprintf (StrQueryCountType,"COUNT(DISTINCT(%s.UsrCod))",LogTable); sprintf (StrQueryCountType,"COUNT(DISTINCT(%s.UsrCod))",LogTable);
@ -5451,10 +5453,14 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
if (SizeOfFileZones.NumCrss == -1) if (SizeOfFileZones.NumCrss == -1)
{ {
Str_Copy (StrNumCrss ,"-",10); Str_Copy (StrNumCrss,"-",
Str_Copy (StrNumFoldersPerCrs,"-",10); 10);
Str_Copy (StrNumFilesPerCrs ,"-",10); Str_Copy (StrNumFoldersPerCrs,"-",
Str_Copy (FileSizePerCrsStr ,"-",Fil_MAX_BYTES_FILE_SIZE_STRING); 10);
Str_Copy (StrNumFilesPerCrs,"-",
10);
Str_Copy (FileSizePerCrsStr,"-",
Fil_MAX_BYTES_FILE_SIZE_STRING);
} }
else else
{ {
@ -5474,16 +5480,21 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
} }
if (SizeOfFileZones.NumGrps == -1) if (SizeOfFileZones.NumGrps == -1)
Str_Copy (StrNumGrps,"-",10); Str_Copy (StrNumGrps,"-",
10);
else else
sprintf (StrNumGrps,"%d",SizeOfFileZones.NumGrps); sprintf (StrNumGrps,"%d",SizeOfFileZones.NumGrps);
if (SizeOfFileZones.NumUsrs == -1) if (SizeOfFileZones.NumUsrs == -1)
{ {
Str_Copy (StrNumUsrs ,"-",10); Str_Copy (StrNumUsrs,"-",
Str_Copy (StrNumFoldersPerUsr,"-",10); 10);
Str_Copy (StrNumFilesPerUsr ,"-",10); Str_Copy (StrNumFoldersPerUsr,"-",
Str_Copy (FileSizePerUsrStr ,"-",Fil_MAX_BYTES_FILE_SIZE_STRING); 10);
Str_Copy (StrNumFilesPerUsr,"-",
10);
Str_Copy (FileSizePerUsrStr,"-",
Fil_MAX_BYTES_FILE_SIZE_STRING);
} }
else else
{ {

View File

@ -104,14 +104,14 @@ action="https://localhost/swad/es" method="post">
#define MAX_LINKS 1000 #define MAX_LINKS 1000
#define MAX_BYTES_LIMITED_URL 1024 // Max. number of bytes of the URL shown on screen #define MAX_BYTES_LIMITED_URL (1024 - 1) // Max. number of bytes of the URL shown on screen
void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScreen) void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScreen)
{ {
extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES]; extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
char ParamsStr[256+256+Ses_LENGTH_SESSION_ID+256]; char ParamsStr[256 + 256 + Ses_LENGTH_SESSION_ID + 256];
char Anchor1Nick[256+256+256+Ses_LENGTH_SESSION_ID+256+256]; char Anchor1Nick[256 + 256 + 256 + Ses_LENGTH_SESSION_ID + 256 + 256];
char Anchor2Nick[256+Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64]; char Anchor2Nick[256 + Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64];
size_t TxtLength; size_t TxtLength;
size_t TxtLengthWithInsertedAnchors; size_t TxtLengthWithInsertedAnchors;
@ -232,8 +232,6 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
/* Initialize anchors for this link */ /* Initialize anchors for this link */
Links[NumLinks].Anchor1Nick = NULL; Links[NumLinks].Anchor1Nick = NULL;
Links[NumLinks].Anchor2Nick = NULL; Links[NumLinks].Anchor2Nick = NULL;
Links[NumLinks].Anchor1NickLength = 0;
Links[NumLinks].Anchor2NickLength = 0;
/* Calculate length of this URL */ /* Calculate length of this URL */
Links[NumLinks].NumActualBytes = (size_t) (Links[NumLinks].PtrEnd + 1 - Links[NumLinks].PtrStart); Links[NumLinks].NumActualBytes = (size_t) (Links[NumLinks].PtrEnd + 1 - Links[NumLinks].PtrStart);
@ -244,7 +242,8 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
/* Make a copy of this URL */ /* Make a copy of this URL */
NumBytesToCopy = (Links[NumLinks].NumActualBytes < MAX_BYTES_LIMITED_URL) ? Links[NumLinks].NumActualBytes : NumBytesToCopy = (Links[NumLinks].NumActualBytes < MAX_BYTES_LIMITED_URL) ? Links[NumLinks].NumActualBytes :
MAX_BYTES_LIMITED_URL; MAX_BYTES_LIMITED_URL;
Str_Copy (LimitedURL,Links[NumLinks].PtrStart,NumBytesToCopy); strncpy (LimitedURL,Links[NumLinks].PtrStart,NumBytesToCopy);
LimitedURL[NumBytesToCopy] = '\0';
/* Limit the number of characters on screen of the copy, and calculate its length in bytes */ /* Limit the number of characters on screen of the copy, and calculate its length in bytes */
LengthVisibleLink = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen); LengthVisibleLink = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen);
@ -314,9 +313,9 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
Gbl.Form.Id, Gbl.Form.Id,
ParamsStr); 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.");
Str_Copy (Links[NumLinks].Anchor1Nick,Anchor1Nick,Anchor1NickLength); strcpy (Links[NumLinks].Anchor1Nick,Anchor1Nick);
Links[NumLinks].Anchor1NickLength = Anchor1NickLength; Links[NumLinks].Anchor1NickLength = Anchor1NickLength;
/* Store second part of anchor */ /* Store second part of anchor */
@ -327,9 +326,9 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId : Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId :
Gbl.Form.Id); 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.");
Str_Copy (Links[NumLinks].Anchor2Nick,Anchor2Nick,Anchor2NickLength); strcpy (Links[NumLinks].Anchor2Nick,Anchor2Nick);
Links[NumLinks].Anchor2NickLength = Anchor2NickLength; Links[NumLinks].Anchor2NickLength = Anchor2NickLength;
AnchorNickTotalLength = Anchor1NickLength + Anchor2NickLength + Anchor3NickLength; AnchorNickTotalLength = Anchor1NickLength + Anchor2NickLength + Anchor3NickLength;
@ -407,7 +406,8 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
/* Make a copy of this URL */ /* Make a copy of this URL */
NumBytesToCopy = (Links[NumLink].NumActualBytes < MAX_BYTES_LIMITED_URL) ? Links[NumLink].NumActualBytes : NumBytesToCopy = (Links[NumLink].NumActualBytes < MAX_BYTES_LIMITED_URL) ? Links[NumLink].NumActualBytes :
MAX_BYTES_LIMITED_URL; MAX_BYTES_LIMITED_URL;
Str_Copy (LimitedURL,Links[NumLink].PtrStart,NumBytesToCopy); strncpy (LimitedURL,Links[NumLink].PtrStart,NumBytesToCopy);
LimitedURL[NumBytesToCopy] = '\0';
/* Limit the length of the copy */ /* Limit the length of the copy */
NumBytesToShow = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen); NumBytesToShow = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen);
@ -985,7 +985,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
if (ChangeTo != Str_DONT_CHANGE) if (ChangeTo != Str_DONT_CHANGE)
{ {
/***** Allocate memory for a destination string where to do the changes *****/ /***** Allocate memory for a destination string where to do the changes *****/
if ((StrDst = (char *) malloc (MaxLengthStr)) == NULL) if ((StrDst = (char *) malloc (MaxLengthStr + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to change the format of a string."); Lay_ShowErrorAndExit ("Not enough memory to change the format of a string.");
/***** Make the change *****/ /***** Make the change *****/
@ -1366,7 +1366,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
Lay_ShowErrorAndExit ("Space allocated to string is full."); Lay_ShowErrorAndExit ("Space allocated to string is full.");
/* Copy to appropiate place the special character string */ /* Copy to appropiate place the special character string */
Str_Copy (PtrDst,StrSpecialChar,LengthSpecStrDst); strncpy (PtrDst,StrSpecialChar,LengthSpecStrDst);
/* Increment pointer to character after ';' */ /* Increment pointer to character after ';' */
PtrSrc += LengthSpecStrSrc; PtrSrc += LengthSpecStrSrc;
@ -1388,9 +1388,11 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
LengthStrDst++; LengthStrDst++;
} }
} }
StrDst[LengthStrDst] = '\0';
/***** Copy destination string with changes to source string *****/ /***** Copy destination string with changes to source string *****/
Str_Copy (Str,StrDst,LengthStrDst); // Str <-- StrDst strncpy (Str,StrDst,LengthStrDst); // Str <-- StrDst
Str[LengthStrDst] = '\0';
/***** Free memory used for the destination string *****/ /***** Free memory used for the destination string *****/
free ((void *) StrDst); free ((void *) StrDst);
@ -2384,12 +2386,10 @@ size_t Str_GetLengthRootFileName (const char *FileName)
/************** Get the name of a file from a complete path ******************/ /************** Get the name of a file from a complete path ******************/
/*****************************************************************************/ /*****************************************************************************/
// Split a full path in path (without ending '/' ) and a file name // Split a full path in path (without ending '/' ) and a file name
// PathWithoutFileName must have space for at least PATH_MAX+1 bytes
// FileName must have space for at least NAME_MAX+1 bytes
void Str_SplitFullPathIntoPathAndFileName (const char *FullPath, void Str_SplitFullPathIntoPathAndFileName (const char FullPath[PATH_MAX + 1],
char *PathWithoutFileName, char PathWithoutFileName[PATH_MAX + 1],
char *FileName) char FileName[NAME_MAX + 1])
{ {
const char *PtrFileName; const char *PtrFileName;
size_t LengthUntilFileName; size_t LengthUntilFileName;
@ -2403,16 +2403,19 @@ void Str_SplitFullPathIntoPathAndFileName (const char *FullPath,
PtrFileName = FullPath; PtrFileName = FullPath;
/***** Get PathWithoutFileName *****/ /***** Get PathWithoutFileName *****/
LengthUntilFileName = (size_t) (PtrFileName - FullPath); // Last slash included LengthUntilFileName = (size_t) (PtrFileName - FullPath); // Last slash included
if (LengthUntilFileName > 1) if (LengthUntilFileName > 1)
{
Str_Copy (PathWithoutFileName,FullPath, Str_Copy (PathWithoutFileName,FullPath,
LengthUntilFileName > PATH_MAX ? PATH_MAX : PATH_MAX);
LengthUntilFileName - 1); // Do not copy ending slash PathWithoutFileName[LengthUntilFileName - 1] = '\0'; // Do not copy ending slash
}
else else
PathWithoutFileName[0] = '\0'; PathWithoutFileName[0] = '\0';
/***** Get FileName *****/ /***** Get FileName *****/
Str_Copy (FileName,PtrFileName,NAME_MAX); Str_Copy (FileName,PtrFileName,
NAME_MAX);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2751,10 +2754,9 @@ bool Str_ConvertFilFolLnkNameToValid (char *FileName)
FileName); FileName);
} }
else // FileName is empty else // FileName is empty
Str_Copy (Gbl.Message, sprintf (Gbl.Message,"%s",
Gbl.FileBrowser.UploadingWithDropzone ? Txt_UPLOAD_FILE_Invalid_name_NO_HTML : Gbl.FileBrowser.UploadingWithDropzone ? Txt_UPLOAD_FILE_Invalid_name_NO_HTML :
Txt_UPLOAD_FILE_Invalid_name, Txt_UPLOAD_FILE_Invalid_name);
Lay_MAX_BYTES_ALERT);
return FileNameIsOK; return FileNameIsOK;
} }
@ -2827,40 +2829,53 @@ void Str_CreateRandomAlphanumStr (char *Str,size_t Length)
Str[Length] = '\0'; Str[Length] = '\0';
} }
/*****************************************************************************/
/********************** Get mailbox from email address ***********************/
/*****************************************************************************/
void Str_GetMailBox (const char *Email,char *MailBox,size_t MaxLength)
{
const char *Ptr;
MailBox[0] = '\0'; // Return empty mailbox on error
if ((Ptr = strchr (Email,(int) '@'))) // Find first '@' in address
if (Ptr != Email) // '@' is not the first character in Email
{
Ptr++; // Skip '@'
if (strchr (Ptr,(int) '@') == NULL) // No more '@' found
Str_Copy (MailBox,Ptr,MaxLength);
}
}
/*****************************************************************************/ /*****************************************************************************/
/****************************** Safe string copy *****************************/ /****************************** Safe string copy *****************************/
/*****************************************************************************/ /*****************************************************************************/
void Str_Copy (char *Dst,const char *Src,size_t MaxLength) void Str_Copy (char *Dst,const char *Src,size_t DstSize)
{ {
strncpy (Dst,Src,MaxLength); size_t LengthSrc = strlen (Src);
Dst[MaxLength] = '\0';
if (DstSize < LengthSrc)
{
sprintf (Gbl.Message,"Trying to copy %lu chars into a %lu-chars buffer.",
LengthSrc,DstSize);
Lay_ShowErrorAndExit (Gbl.Message);
}
// strncpy (Dst,Src,MaxLength);
// Dst[MaxLength] = '\0';
strcpy (Dst,Src);
} }
/*****************************************************************************/ /*****************************************************************************/
/************************** Safe string concatenation ************************/ /************************** Safe string concatenation ************************/
/*****************************************************************************/ /*****************************************************************************/
void Str_Concat (char *Dst,const char *Src,size_t MaxLength) void Str_Concat (char *Dst,const char *Src,size_t DstSize)
{ {
strncat (Dst,Src,MaxLength - strlen (Dst)); size_t LengthDst;
size_t LengthSrc;
size_t FreeSpace;
LengthDst = strlen (Dst);
if (LengthDst > DstSize)
{
sprintf (Gbl.Message,"%lu-chars buffer has %lu chars!",
DstSize,LengthSrc);
Lay_ShowErrorAndExit (Gbl.Message);
}
FreeSpace = DstSize - LengthDst;
LengthSrc = strlen (Src);
if (FreeSpace < LengthSrc)
{
sprintf (Gbl.Message,"Trying to concatenate %lu chars to a %lu-chars buffer with free space for only %lu chars!",
LengthSrc,DstSize,FreeSpace);
Lay_ShowErrorAndExit (Gbl.Message);
}
// strncat (Dst,Src,FreeSpace);
strcat (Dst,Src);
} }

View File

@ -27,6 +27,7 @@
/********************************* Headers **********************************/ /********************************* Headers **********************************/
/*****************************************************************************/ /*****************************************************************************/
#include <limits.h> // For NAME_MAX and PATH_MAX
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include <stdio.h> // For FILE #include <stdio.h> // For FILE
@ -102,8 +103,9 @@ void Str_ReplaceSeveralSpacesForOne (char *Str);
void Str_CopyStrChangingSpaces (const char *StringWithSpaces,char *StringWithoutSpaces,unsigned MaxLength); void Str_CopyStrChangingSpaces (const char *StringWithSpaces,char *StringWithoutSpaces,unsigned MaxLength);
long Str_ConvertStrCodToLongCod (const char *Str); long Str_ConvertStrCodToLongCod (const char *Str);
size_t Str_GetLengthRootFileName (const char *FileName); size_t Str_GetLengthRootFileName (const char *FileName);
void Str_SplitFullPathIntoPathAndFileName (const char *FullPath, void Str_SplitFullPathIntoPathAndFileName (const char FullPath[PATH_MAX + 1],
char *PathWithoutFileName,char *FileName); char PathWithoutFileName[PATH_MAX + 1],
char FileName[NAME_MAX + 1]);
bool Str_FileIs (const char *FileName,const char *Extension); bool Str_FileIs (const char *FileName,const char *Extension);
bool Str_FileIsHTML (const char *FileName); bool Str_FileIsHTML (const char *FileName);
bool Str_Path1BeginsByPath2 (const char *Path1,const char *Path2); bool Str_Path1BeginsByPath2 (const char *Path1,const char *Path2);
@ -117,9 +119,8 @@ bool Str_ConvertFilFolLnkNameToValid (char *FileName);
void Str_ConvertToValidFileName (char *Str); void Str_ConvertToValidFileName (char *Str);
void Str_CreateRandomAlphanumStr (char *Str,size_t Length); void Str_CreateRandomAlphanumStr (char *Str,size_t Length);
void Str_GetMailBox (const char *Email,char *MailBox,size_t MaxLength);
void Str_Copy (char *Dst,const char *Src,size_t MaxLength); void Str_Copy (char *Dst,const char *Src,size_t DstSize);
void Str_Concat (char *Dst,const char *Src,size_t MaxLength); void Str_Concat (char *Dst,const char *Src,size_t DstSize);
#endif #endif

View File

@ -131,7 +131,8 @@ static void Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (struct Survey *Svy);
static bool Svy_CheckIfICanDoThisSurveyBasedOnGrps (long SvyCod); static bool Svy_CheckIfICanDoThisSurveyBasedOnGrps (long SvyCod);
static unsigned Svy_GetNumQstsSvy (long SvyCod); static unsigned Svy_GetNumQstsSvy (long SvyCod);
static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,char *Txt); static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,
char Txt[Cns_MAX_BYTES_TEXT + 1]);
static void Svy_InitQst (struct SurveyQuestion *SvyQst); static void Svy_InitQst (struct SurveyQuestion *SvyQst);
static void Svy_PutParamQstCod (long QstCod); static void Svy_PutParamQstCod (long QstCod);
static long Svy_GetParamQstCod (void); static long Svy_GetParamQstCod (void);
@ -690,8 +691,10 @@ static void Svy_WriteAuthor (struct Survey *Svy)
"PHOTO15x20",Pho_ZOOM,false); "PHOTO15x20",Pho_ZOOM,false);
/***** Write name *****/ /***** Write name *****/
Str_Copy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Copy (FirstName,UsrDat.FirstName,
Str_Copy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES); Usr_MAX_BYTES_NAME);
Str_Copy (Surnames,UsrDat.Surname1,
Usr_MAX_BYTES_SURNAMES);
if (UsrDat.Surname2[0]) if (UsrDat.Surname2[0])
{ {
Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES); Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES);
@ -1247,7 +1250,8 @@ void Svy_GetDataOfSurveyByCod (struct Survey *Svy)
Svy->Status.Open = (row[8][0] == '1'); Svy->Status.Open = (row[8][0] == '1');
/* Get the title of the survey (row[9]) */ /* Get the title of the survey (row[9]) */
Str_Copy (Svy->Title,row[9],Svy_MAX_LENGTH_SURVEY_TITLE); Str_Copy (Svy->Title,row[9],
Svy_MAX_LENGTH_SURVEY_TITLE);
/* Get number of questions and number of users who have already answer this survey */ /* Get number of questions and number of users who have already answer this survey */
Svy->NumQsts = Svy_GetNumQstsSvy (Svy->SvyCod); Svy->NumQsts = Svy_GetNumQstsSvy (Svy->SvyCod);
@ -1427,7 +1431,8 @@ static void Svy_GetSurveyTxtFromDB (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1]
{ {
/* Get info text */ /* Get info text */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Txt,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (Txt,row[0],
Cns_MAX_BYTES_TEXT);
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';
@ -1467,7 +1472,8 @@ void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/***** Get summary *****/ /***** Get summary *****/
Str_Copy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (SummaryStr,row[0],
Cns_MAX_BYTES_TEXT);
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -1477,7 +1483,8 @@ void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
Length = strlen (row[1]); Length = strlen (row[1]);
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL) if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content."); Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
Str_Copy (*ContentStr,row[1],Length); Str_Copy (*ContentStr,row[1],
Length);
} }
} }
mysql_free_result (mysql_res); mysql_free_result (mysql_res);
@ -2579,7 +2586,7 @@ void Svy_RequestEditQuestion (void)
{ {
long SvyCod; long SvyCod;
struct SurveyQuestion SvyQst; struct SurveyQuestion SvyQst;
char Txt[Cns_MAX_BYTES_TEXT+1]; char Txt[Cns_MAX_BYTES_TEXT + 1];
/***** Initialize question to zero *****/ /***** Initialize question to zero *****/
Svy_InitQst (&SvyQst); Svy_InitQst (&SvyQst);
@ -2608,7 +2615,8 @@ void Svy_RequestEditQuestion (void)
/******************* Show form to edit one survey question *******************/ /******************* Show form to edit one survey question *******************/
/*****************************************************************************/ /*****************************************************************************/
static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,char *Txt) static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,
char Txt[Cns_MAX_BYTES_TEXT + 1])
{ {
extern const char *Hlp_STATS_Surveys_questions; extern const char *Hlp_STATS_Surveys_questions;
extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *The_ClassForm[The_NUM_THEMES];
@ -2647,7 +2655,8 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,ch
SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]); SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
/* Get the stem of the question from the database (row[2]) */ /* Get the stem of the question from the database (row[2]) */
Str_Copy (Txt,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (Txt,row[2],
Cns_MAX_BYTES_TEXT);
/* Free structure that stores the query result */ /* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -2665,7 +2674,8 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,ch
if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns)) if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns))
Lay_ShowErrorAndExit (Gbl.Message); Lay_ShowErrorAndExit (Gbl.Message);
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER); Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],
Svy_MAX_BYTES_ANSWER);
} }
/* Free structure that stores the query result */ /* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -2918,7 +2928,7 @@ static unsigned Svy_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res)
static int Svy_AllocateTextChoiceAnswer (struct SurveyQuestion *SvyQst,unsigned NumAns) static int Svy_AllocateTextChoiceAnswer (struct SurveyQuestion *SvyQst,unsigned NumAns)
{ {
Svy_FreeTextChoiceAnswer (SvyQst,NumAns); Svy_FreeTextChoiceAnswer (SvyQst,NumAns);
if ((SvyQst->AnsChoice[NumAns].Text = malloc (Svy_MAX_BYTES_ANSWER+1)) == NULL) if ((SvyQst->AnsChoice[NumAns].Text = malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL)
{ {
sprintf (Gbl.Message,"Not enough memory to store answer."); sprintf (Gbl.Message,"Not enough memory to store answer.");
return 0; return 0;
@ -3381,7 +3391,8 @@ static void Svy_WriteQstStem (const char *Stem)
Length = strlen (Stem) * Str_MAX_LENGTH_SPEC_CHAR_HTML; Length = strlen (Stem) * Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((HeadingRigorousHTML = malloc (Length + 1)) == NULL) if ((HeadingRigorousHTML = malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store stem of question."); Lay_ShowErrorAndExit ("Not enough memory to store stem of question.");
Str_Copy (HeadingRigorousHTML,Stem,Length); Str_Copy (HeadingRigorousHTML,Stem,
Length);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
HeadingRigorousHTML,Length,false); HeadingRigorousHTML,Length,false);
@ -3426,7 +3437,8 @@ static void Svy_WriteAnswersOfAQst (struct Survey *Svy,struct SurveyQuestion *Sv
AnsLength = strlen (row[2]); AnsLength = strlen (row[2]);
if ((Answer = malloc (AnsLength + 1)) == NULL) if ((Answer = malloc (AnsLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store answer."); Lay_ShowErrorAndExit ("Not enough memory to store answer.");
Str_Copy (Answer,row[2],AnsLength); Str_Copy (Answer,row[2],
AnsLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Answer,AnsLength,false); Answer,AnsLength,false);

View File

@ -218,7 +218,8 @@ static void Tst_GetParamNumQst (void);
static bool Tst_GetCreateXMLFromForm (void); static bool Tst_GetCreateXMLFromForm (void);
static int Tst_CountNumTagsInList (void); static int Tst_CountNumTagsInList (void);
static int Tst_CountNumAnswerTypesInList (void); static int Tst_CountNumAnswerTypesInList (void);
static void Tst_PutFormEditOneQst (char *Stem,char *Feedback); static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
char Feedback[Cns_MAX_BYTES_TEXT + 1]);
static void Tst_PutFloatInputField (const char *Label,const char *Field, static void Tst_PutFloatInputField (const char *Label,const char *Field,
double Value); double Value);
static void Tst_PutTFInputField (const char *Label,char Value); static void Tst_PutTFInputField (const char *Label,char Value);
@ -229,7 +230,8 @@ static void Tst_FreeTextChoiceAnswer (unsigned NumOpt);
static void Tst_InitImagesOfQuestion (void); static void Tst_InitImagesOfQuestion (void);
static void Tst_FreeImagesOfQuestion (void); static void Tst_FreeImagesOfQuestion (void);
static void Tst_GetQstDataFromDB (char *Stem,char *Feedback); static void Tst_GetQstDataFromDB (char Stem[Cns_MAX_BYTES_TEXT + 1],
char Feedback[Cns_MAX_BYTES_TEXT + 1]);
static void Tst_GetImageFromDB (int NumOpt,struct Image *Image); static void Tst_GetImageFromDB (int NumOpt,struct Image *Image);
static Tst_AnswerType_t Tst_ConvertFromUnsignedStrToAnsTyp (const char *UnsignedStr); static Tst_AnswerType_t Tst_ConvertFromUnsignedStrToAnsTyp (const char *UnsignedStr);
@ -1023,9 +1025,10 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem)
/***** Convert the stem, that is in HTML, to rigorous HTML *****/ /***** Convert the stem, that is in HTML, to rigorous HTML *****/
StemLength = strlen (Stem) * Str_MAX_LENGTH_SPEC_CHAR_HTML; StemLength = strlen (Stem) * Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((StemRigorousHTML = malloc (StemLength+1)) == NULL) if ((StemRigorousHTML = malloc (StemLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store stem of question."); Lay_ShowErrorAndExit ("Not enough memory to store stem of question.");
Str_Copy (StemRigorousHTML,Stem,StemLength); Str_Copy (StemRigorousHTML,Stem,
StemLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
StemRigorousHTML,StemLength,false); StemRigorousHTML,StemLength,false);
@ -1152,9 +1155,10 @@ void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback)
{ {
/***** Convert the feedback, that is in HTML, to rigorous HTML *****/ /***** Convert the feedback, that is in HTML, to rigorous HTML *****/
FeedbackLength = strlen (Feedback) * Str_MAX_LENGTH_SPEC_CHAR_HTML; FeedbackLength = strlen (Feedback) * Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((FeedbackRigorousHTML = malloc (FeedbackLength+1)) == NULL) if ((FeedbackRigorousHTML = malloc (FeedbackLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store stem of question."); Lay_ShowErrorAndExit ("Not enough memory to store stem of question.");
Str_Copy (FeedbackRigorousHTML,Feedback,FeedbackLength); Str_Copy (FeedbackRigorousHTML,Feedback,
FeedbackLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
FeedbackRigorousHTML,FeedbackLength,false); FeedbackRigorousHTML,FeedbackLength,false);
@ -3053,9 +3057,10 @@ static void Tst_WriteAnswersOfAQstEdit (long QstCod)
/* Convert the answer (row[1]), that is in HTML, to rigorous HTML */ /* Convert the answer (row[1]), that is in HTML, to rigorous HTML */
LengthAnswer = strlen (row[1]) * Str_MAX_LENGTH_SPEC_CHAR_HTML; LengthAnswer = strlen (row[1]) * Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((Answer = malloc (LengthAnswer+1)) == NULL) if ((Answer = malloc (LengthAnswer + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store answer."); Lay_ShowErrorAndExit ("Not enough memory to store answer.");
Str_Copy (Answer,row[1],LengthAnswer); Str_Copy (Answer,row[1],
LengthAnswer);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Answer,LengthAnswer,false); Answer,LengthAnswer,false);
@ -3066,9 +3071,10 @@ static void Tst_WriteAnswersOfAQstEdit (long QstCod)
if (row[2][0]) if (row[2][0])
{ {
LengthFeedback = strlen (row[2]) * Str_MAX_LENGTH_SPEC_CHAR_HTML; LengthFeedback = strlen (row[2]) * Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((Feedback = malloc (LengthFeedback+1)) == NULL) if ((Feedback = malloc (LengthFeedback + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store feedback."); Lay_ShowErrorAndExit ("Not enough memory to store feedback.");
Str_Copy (Feedback,row[2],LengthFeedback); Str_Copy (Feedback,row[2],
LengthFeedback);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Feedback,LengthFeedback,false); Feedback,LengthFeedback,false);
} }
@ -4427,8 +4433,8 @@ void Tst_FreeTagsList (void)
void Tst_ShowFormEditOneQst (void) void Tst_ShowFormEditOneQst (void)
{ {
char Stem[Cns_MAX_BYTES_TEXT+1]; char Stem[Cns_MAX_BYTES_TEXT + 1];
char Feedback[Cns_MAX_BYTES_TEXT+1]; char Feedback[Cns_MAX_BYTES_TEXT + 1];
/***** Create test question *****/ /***** Create test question *****/
Tst_QstConstructor (); Tst_QstConstructor ();
@ -4453,7 +4459,8 @@ void Tst_ShowFormEditOneQst (void)
// 2. By clicking "Edit" icon in a listing of existing questions // 2. By clicking "Edit" icon in a listing of existing questions
// 3. From the action associated to reception of a question, on error in the parameters received from the form // 3. From the action associated to reception of a question, on error in the parameters received from the form
static void Tst_PutFormEditOneQst (char *Stem,char *Feedback) static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
char Feedback[Cns_MAX_BYTES_TEXT + 1])
{ {
extern const char *Hlp_ASSESSMENT_Tests; extern const char *Hlp_ASSESSMENT_Tests;
extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *The_ClassForm[The_NUM_THEMES];
@ -5038,7 +5045,8 @@ static void Tst_FreeImagesOfQuestion (void)
/****************** Get data of a question from database *********************/ /****************** Get data of a question from database *********************/
/*****************************************************************************/ /*****************************************************************************/
static void Tst_GetQstDataFromDB (char *Stem,char *Feedback) static void Tst_GetQstDataFromDB (char Stem[Cns_MAX_BYTES_TEXT + 1],
char Feedback[Cns_MAX_BYTES_TEXT + 1])
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -5073,13 +5081,15 @@ static void Tst_GetQstDataFromDB (char *Stem,char *Feedback)
Gbl.Test.Shuffle = (row[1][0] == 'Y'); Gbl.Test.Shuffle = (row[1][0] == 'Y');
/* Get the stem of the question from the database (row[2]) */ /* Get the stem of the question from the database (row[2]) */
Str_Copy (Stem,row[2],Cns_MAX_BYTES_TEXT); Str_Copy (Stem,row[2],
Cns_MAX_BYTES_TEXT);
/* Get the feedback of the question from the database (row[3]) */ /* Get the feedback of the question from the database (row[3]) */
Feedback[0] = '\0'; Feedback[0] = '\0';
if (row[3]) if (row[3])
if (row[3][0]) if (row[3][0])
Str_Copy (Feedback,row[3],Cns_MAX_BYTES_TEXT); Str_Copy (Feedback,row[3],
Cns_MAX_BYTES_TEXT);
/* Get the image name, title and URL of the question /* Get the image name, title and URL of the question
from the database (row[4], row[5], row[6]) */ from the database (row[4], row[5], row[6]) */
@ -5095,7 +5105,8 @@ static void Tst_GetQstDataFromDB (char *Stem,char *Feedback)
NumRow++) NumRow++)
{ {
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Gbl.Test.Tags.Txt[NumRow],row[0],Tst_MAX_BYTES_TAG); Str_Copy (Gbl.Test.Tags.Txt[NumRow],row[0],
Tst_MAX_BYTES_TAG);
} }
/* Free structure that stores the query result */ /* Free structure that stores the query result */
@ -5755,13 +5766,13 @@ static long Tst_GetTagCodFromTagTxt (const char *TagTxt)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
if ((TagCod = Str_ConvertStrCodToLongCod (row[0])) < 0) if ((TagCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
{ {
Str_Copy (Gbl.Message,"Wrong code of tag.",Lay_MAX_BYTES_ALERT); sprintf (Gbl.Message,"%s","Wrong code of tag.");
Error = true; Error = true;
} }
} }
else if (NumRows > 1) else if (NumRows > 1)
{ {
Str_Copy (Gbl.Message,"Duplicated tag.",Lay_MAX_BYTES_ALERT); sprintf (Gbl.Message,"%s","Duplicated tag.");
Error = true; Error = true;
} }

View File

@ -499,8 +499,8 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
struct XMLAttribute *Attribute; struct XMLAttribute *Attribute;
bool AnswerTypeFound; bool AnswerTypeFound;
bool QuestionExists; bool QuestionExists;
char Stem[Cns_MAX_BYTES_TEXT+1]; char Stem[Cns_MAX_BYTES_TEXT + 1];
char Feedback[Cns_MAX_BYTES_TEXT+1]; char Feedback[Cns_MAX_BYTES_TEXT + 1];
/***** Allocate and get XML tree *****/ /***** Allocate and get XML tree *****/
XML_GetTree (XMLBuffer,&RootElem); XML_GetTree (XMLBuffer,&RootElem);
@ -571,7 +571,8 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
if (TagElem->Content) if (TagElem->Content)
{ {
Str_Copy (Gbl.Test.Tags.Txt[Gbl.Test.Tags.Num], Str_Copy (Gbl.Test.Tags.Txt[Gbl.Test.Tags.Num],
TagElem->Content,Tst_MAX_BYTES_TAG); TagElem->Content,
Tst_MAX_BYTES_TAG);
Gbl.Test.Tags.Num++; Gbl.Test.Tags.Num++;
} }
} }
@ -587,7 +588,8 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
if (StemElem->Content) if (StemElem->Content)
{ {
/* Convert stem from text to HTML (in database stem is stored in HTML) */ /* Convert stem from text to HTML (in database stem is stored in HTML) */
Str_Copy (Stem,StemElem->Content,Cns_MAX_BYTES_TEXT); Str_Copy (Stem,StemElem->Content,
Cns_MAX_BYTES_TEXT);
Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML, Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
Stem,Cns_MAX_BYTES_TEXT,true); Stem,Cns_MAX_BYTES_TEXT,true);
@ -719,7 +721,7 @@ static bool TsI_CheckIfQuestionExistsInDB (void)
/***** Check if stem exists *****/ /***** Check if stem exists *****/
/* Allocate space for query */ /* Allocate space for query */
if ((QueryQst = malloc (256+Gbl.Test.Stem.Length)) == NULL) if ((QueryQst = malloc (256 + Gbl.Test.Stem.Length)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store database query."); Lay_ShowErrorAndExit ("Not enough memory to store database query.");
/* Make database query */ /* Make database query */
@ -843,7 +845,8 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem)
if (!strcmp (LowerUpperElem->TagName,"lower")) if (!strcmp (LowerUpperElem->TagName,"lower"))
{ {
if (LowerUpperElem->Content) if (LowerUpperElem->Content)
Str_Copy (Gbl.Test.Answer.Options[0].Text,LowerUpperElem->Content, Str_Copy (Gbl.Test.Answer.Options[0].Text,
LowerUpperElem->Content,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
break; // Only first element "lower" break; // Only first element "lower"
} }
@ -853,7 +856,8 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem)
if (!strcmp (LowerUpperElem->TagName,"upper")) if (!strcmp (LowerUpperElem->TagName,"upper"))
{ {
if (LowerUpperElem->Content) if (LowerUpperElem->Content)
Str_Copy (Gbl.Test.Answer.Options[1].Text,LowerUpperElem->Content, Str_Copy (Gbl.Test.Answer.Options[1].Text,
LowerUpperElem->Content,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); Tst_MAX_BYTES_ANSWER_OR_FEEDBACK);
break; // Only first element "upper" break; // Only first element "upper"
} }
@ -1120,7 +1124,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
/* Convert the answer, that is in HTML, to rigorous HTML */ /* Convert the answer, that is in HTML, to rigorous HTML */
AnswerTextLength = strlen (Gbl.Test.Answer.Options[NumOpt].Text) * AnswerTextLength = strlen (Gbl.Test.Answer.Options[NumOpt].Text) *
Str_MAX_LENGTH_SPEC_CHAR_HTML; Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((AnswerText = malloc (AnswerTextLength+1)) == NULL) if ((AnswerText = malloc (AnswerTextLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store answer."); Lay_ShowErrorAndExit ("Not enough memory to store answer.");
Str_Copy (AnswerText,Gbl.Test.Answer.Options[NumOpt].Text, Str_Copy (AnswerText,Gbl.Test.Answer.Options[NumOpt].Text,
AnswerTextLength); AnswerTextLength);
@ -1135,7 +1139,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
{ {
AnswerFeedbackLength = strlen (Gbl.Test.Answer.Options[NumOpt].Feedback) * AnswerFeedbackLength = strlen (Gbl.Test.Answer.Options[NumOpt].Feedback) *
Str_MAX_LENGTH_SPEC_CHAR_HTML; Str_MAX_LENGTH_SPEC_CHAR_HTML;
if ((AnswerFeedback = malloc (AnswerFeedbackLength+1)) == NULL) if ((AnswerFeedback = malloc (AnswerFeedbackLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store feedback."); Lay_ShowErrorAndExit ("Not enough memory to store feedback.");
Str_Copy (AnswerFeedback, Str_Copy (AnswerFeedback,
Gbl.Test.Answer.Options[NumOpt].Feedback, Gbl.Test.Answer.Options[NumOpt].Feedback,

View File

@ -743,12 +743,14 @@ static void TT_CreatTimeTableFromDB (long UsrCod)
(Gbl.TimeTable.Type == TT_MY_TIMETABLE ? Str_ConvertStrCodToLongCod (row[7]) : (Gbl.TimeTable.Type == TT_MY_TIMETABLE ? Str_ConvertStrCodToLongCod (row[7]) :
Gbl.CurrentCrs.Crs.CrsCod); Gbl.CurrentCrs.Crs.CrsCod);
Str_Copy (TimeTable[Day][Hour].Columns[FirstFreeColumn].Group, Str_Copy (TimeTable[Day][Hour].Columns[FirstFreeColumn].Group,
row[5],TT_MAX_BYTES_GROUP); row[5],
TT_MAX_BYTES_GROUP);
TimeTable[Day][Hour].Columns[FirstFreeColumn].GrpCod = GrpCod; TimeTable[Day][Hour].Columns[FirstFreeColumn].GrpCod = GrpCod;
// no break; // no break;
case TT_TUTOR_TIMETABLE: case TT_TUTOR_TIMETABLE:
Str_Copy (TimeTable[Day][Hour].Columns[FirstFreeColumn].Place, Str_Copy (TimeTable[Day][Hour].Columns[FirstFreeColumn].Place,
row[3],TT_MAX_BYTES_PLACE); row[3],
TT_MAX_BYTES_PLACE);
break; break;
} }
@ -798,9 +800,11 @@ static void TT_ModifTimeTable (void)
TimeTable[Gbl.TimeTable.Day][Gbl.TimeTable.Hour].Columns[Gbl.TimeTable.Column].ClassType = Gbl.TimeTable.ClassType; TimeTable[Gbl.TimeTable.Day][Gbl.TimeTable.Hour].Columns[Gbl.TimeTable.Column].ClassType = Gbl.TimeTable.ClassType;
TimeTable[Gbl.TimeTable.Day][Gbl.TimeTable.Hour].Columns[Gbl.TimeTable.Column].Duration = Gbl.TimeTable.Duration; TimeTable[Gbl.TimeTable.Day][Gbl.TimeTable.Hour].Columns[Gbl.TimeTable.Column].Duration = Gbl.TimeTable.Duration;
Str_Copy (TimeTable[Gbl.TimeTable.Day][Gbl.TimeTable.Hour].Columns[Gbl.TimeTable.Column].Group, Str_Copy (TimeTable[Gbl.TimeTable.Day][Gbl.TimeTable.Hour].Columns[Gbl.TimeTable.Column].Group,
Gbl.TimeTable.Group,TT_MAX_BYTES_GROUP); Gbl.TimeTable.Group,
TT_MAX_BYTES_GROUP);
Str_Copy (TimeTable[Gbl.TimeTable.Day][Gbl.TimeTable.Hour].Columns[Gbl.TimeTable.Column].Place, Str_Copy (TimeTable[Gbl.TimeTable.Day][Gbl.TimeTable.Hour].Columns[Gbl.TimeTable.Column].Place,
Gbl.TimeTable.Place,TT_MAX_BYTES_PLACE); Gbl.TimeTable.Place,
TT_MAX_BYTES_PLACE);
} }
} }

View File

@ -244,7 +244,7 @@ void Usr_InformAboutNumClicksBeforePhoto (void)
void Usr_UsrDataConstructor (struct UsrData *UsrDat) void Usr_UsrDataConstructor (struct UsrData *UsrDat)
{ {
/***** Allocate memory for the comments *****/ /***** Allocate memory for the comments *****/
if ((UsrDat->Comments = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL) if ((UsrDat->Comments = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store user's data."); Lay_ShowErrorAndExit ("Not enough memory to store user's data.");
/***** Initialize to zero the data of the user *****/ /***** Initialize to zero the data of the user *****/
@ -485,7 +485,8 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
/* Get encrypted password */ /* Get encrypted password */
Str_Copy (UsrDat->Password,row[1],Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64); Str_Copy (UsrDat->Password,row[1],
Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64);
/* Get roles */ /* Get roles */
UsrDat->RoleInCurrentCrsDB = Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod); UsrDat->RoleInCurrentCrsDB = Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod);
@ -497,9 +498,12 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
Rol_VISITOR; // User belongs to some courses Rol_VISITOR; // User belongs to some courses
/* Get name */ /* Get name */
Str_Copy (UsrDat->Surname1 ,row[2],Usr_MAX_BYTES_NAME); Str_Copy (UsrDat->Surname1,row[2],
Str_Copy (UsrDat->Surname2 ,row[3],Usr_MAX_BYTES_NAME); Usr_MAX_BYTES_NAME);
Str_Copy (UsrDat->FirstName,row[4],Usr_MAX_BYTES_NAME); Str_Copy (UsrDat->Surname2,row[3],
Usr_MAX_BYTES_NAME);
Str_Copy (UsrDat->FirstName,row[4],
Usr_MAX_BYTES_NAME);
/* Get sex */ /* Get sex */
UsrDat->Sex = Usr_GetSexFromStr (row[5]); UsrDat->Sex = Usr_GetSexFromStr (row[5]);
@ -544,7 +548,8 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
UsrDat->Prefs.FirstDayOfWeek = UnsignedNum; UsrDat->Prefs.FirstDayOfWeek = UnsignedNum;
/* Get rest of data */ /* Get rest of data */
Str_Copy (UsrDat->Photo,row[10],Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Str_Copy (UsrDat->Photo,row[10],
Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
UsrDat->PhotoVisibility = Pri_GetVisibilityFromStr (row[11]); UsrDat->PhotoVisibility = Pri_GetVisibilityFromStr (row[11]);
UsrDat->ProfileVisibility = Pri_GetVisibilityFromStr (row[12]); UsrDat->ProfileVisibility = Pri_GetVisibilityFromStr (row[12]);
UsrDat->CtyCod = Str_ConvertStrCodToLongCod (row[13]); UsrDat->CtyCod = Str_ConvertStrCodToLongCod (row[13]);
@ -553,14 +558,21 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
UsrDat->Tch.DptCod = Str_ConvertStrCodToLongCod (row[16]); UsrDat->Tch.DptCod = Str_ConvertStrCodToLongCod (row[16]);
UsrDat->Tch.CtrCod = Str_ConvertStrCodToLongCod (row[17]); UsrDat->Tch.CtrCod = Str_ConvertStrCodToLongCod (row[17]);
Str_Copy (UsrDat->Tch.Office ,row[18],Cns_MAX_BYTES_STRING); Str_Copy (UsrDat->Tch.Office,row[18],
Str_Copy (UsrDat->Tch.OfficePhone,row[19],Usr_MAX_BYTES_PHONE); Cns_MAX_BYTES_STRING);
Str_Copy (UsrDat->Tch.OfficePhone,row[19],
Usr_MAX_BYTES_PHONE);
Str_Copy (UsrDat->LocalAddress ,row[20],Cns_MAX_BYTES_STRING); Str_Copy (UsrDat->LocalAddress,row[20],
Str_Copy (UsrDat->LocalPhone ,row[21],Usr_MAX_BYTES_PHONE); Cns_MAX_BYTES_STRING);
Str_Copy (UsrDat->FamilyAddress,row[22],Cns_MAX_BYTES_STRING); Str_Copy (UsrDat->LocalPhone,row[21],
Str_Copy (UsrDat->FamilyPhone ,row[23],Usr_MAX_BYTES_PHONE); Usr_MAX_BYTES_PHONE);
Str_Copy (UsrDat->OriginPlace ,row[24],Cns_MAX_BYTES_STRING); Str_Copy (UsrDat->FamilyAddress,row[22],
Cns_MAX_BYTES_STRING);
Str_Copy (UsrDat->FamilyPhone,row[23],
Usr_MAX_BYTES_PHONE);
Str_Copy (UsrDat->OriginPlace,row[24],
Cns_MAX_BYTES_STRING);
Dat_GetDateFromYYYYMMDD (&(UsrDat->Birthday),row[25]); Dat_GetDateFromYYYYMMDD (&(UsrDat->Birthday),row[25]);
@ -618,7 +630,8 @@ static void Usr_GetUsrCommentsFromString (char *Str,struct UsrData *UsrDat)
/***** Check that memory for comments is allocated *****/ /***** Check that memory for comments is allocated *****/
if (UsrDat->Comments) if (UsrDat->Comments)
/***** Copy comments from Str to Comments *****/ /***** Copy comments from Str to Comments *****/
Str_Copy (UsrDat->Comments,Str,Cns_MAX_BYTES_TEXT); Str_Copy (UsrDat->Comments,Str,
Cns_MAX_BYTES_TEXT);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -704,7 +717,8 @@ static Usr_Sex_t Usr_GetSexFromStr (const char *Str)
void Usr_BuildFullName (struct UsrData *UsrDat) void Usr_BuildFullName (struct UsrData *UsrDat)
{ {
Str_Copy (UsrDat->FullName,UsrDat->FirstName,Usr_MAX_BYTES_FULL_NAME); Str_Copy (UsrDat->FullName,UsrDat->FirstName,
Usr_MAX_BYTES_FULL_NAME);
if (UsrDat->Surname1[0]) if (UsrDat->Surname1[0])
{ {
Str_Concat (UsrDat->FullName," ",Usr_MAX_BYTES_FULL_NAME); Str_Concat (UsrDat->FullName," ",Usr_MAX_BYTES_FULL_NAME);
@ -727,10 +741,12 @@ void Usr_RestrictLengthAndWriteName (const struct UsrData *UsrDat,unsigned MaxCh
char Surnames[Usr_MAX_BYTES_SURNAMES + 1]; char Surnames[Usr_MAX_BYTES_SURNAMES + 1];
/***** Restrict length of firstname and surnames *****/ /***** Restrict length of firstname and surnames *****/
Str_Copy (FirstName,UsrDat->FirstName,Usr_MAX_BYTES_NAME); Str_Copy (FirstName,UsrDat->FirstName,
Usr_MAX_BYTES_NAME);
Str_LimitLengthHTMLStr (FirstName,MaxChars); Str_LimitLengthHTMLStr (FirstName,MaxChars);
Str_Copy (Surnames,UsrDat->Surname1,Usr_MAX_BYTES_SURNAMES); Str_Copy (Surnames,UsrDat->Surname1,
Usr_MAX_BYTES_SURNAMES);
if (UsrDat->Surname2[0]) if (UsrDat->Surname2[0])
{ {
Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES); Str_Concat (Surnames," ",Usr_MAX_BYTES_SURNAMES);
@ -1996,7 +2012,8 @@ void Usr_CreateBirthdayStrDB (const struct UsrData *UsrDat,
if (UsrDat->Birthday.Year == 0 || if (UsrDat->Birthday.Year == 0 ||
UsrDat->Birthday.Month == 0 || UsrDat->Birthday.Month == 0 ||
UsrDat->Birthday.Day == 0) UsrDat->Birthday.Day == 0)
Str_Copy (BirthdayStrDB,"NULL",Usr_BIRTHDAY_STR_DB_LENGTH); Str_Copy (BirthdayStrDB,"NULL",
Usr_BIRTHDAY_STR_DB_LENGTH);
else else
sprintf (BirthdayStrDB,"'%04u-%02u-%02u'", sprintf (BirthdayStrDB,"'%04u-%02u-%02u'",
UsrDat->Birthday.Year, UsrDat->Birthday.Year,
@ -2105,7 +2122,8 @@ void Usr_WriteLoggedUsrHead (void)
/* Name */ /* Name */
if (Gbl.Usrs.Me.UsrDat.FullName[0]) if (Gbl.Usrs.Me.UsrDat.FullName[0])
{ {
Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME); Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.FirstName,
Usr_MAX_BYTES_NAME);
Str_LimitLengthHTMLStr (UsrName,12); Str_LimitLengthHTMLStr (UsrName,12);
fprintf (Gbl.F.Out,"%s",UsrName); fprintf (Gbl.F.Out,"%s",UsrName);
} }
@ -2976,7 +2994,8 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat,
/***** Checkbox to select user *****/ /***** Checkbox to select user *****/
// Two colors are used alternatively to better distinguish the rows // Two colors are used alternatively to better distinguish the rows
if (UsrIsTheMsgSender) if (UsrIsTheMsgSender)
Str_Copy (BgColor,"LIGHT_GREEN",Usr_MAX_LENGTH_BG_COLOR); Str_Copy (BgColor,"LIGHT_GREEN",
Usr_MAX_LENGTH_BG_COLOR);
else else
sprintf (BgColor,"COLOR%u",Gbl.RowEvenOdd); sprintf (BgColor,"COLOR%u",Gbl.RowEvenOdd);
@ -3247,7 +3266,8 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames)
if (Rec_GetFieldFromCrsRecord (UsrDat->UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res)) if (Rec_GetFieldFromCrsRecord (UsrDat->UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res))
{ {
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
Str_Copy (Text,row[0],Cns_MAX_BYTES_TEXT); Str_Copy (Text,row[0],
Cns_MAX_BYTES_TEXT);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Text,Cns_MAX_BYTES_TEXT,false); // Se convierte of HTML a HTML respetuoso Text,Cns_MAX_BYTES_TEXT,false); // Se convierte of HTML a HTML respetuoso
} }
@ -4676,13 +4696,16 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop
Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
/* Get user's surname 1 (row[2]) */ /* Get user's surname 1 (row[2]) */
Str_Copy (UsrInList->Surname1 ,row[2],Usr_MAX_BYTES_NAME); Str_Copy (UsrInList->Surname1,row[2],
Usr_MAX_BYTES_NAME);
/* Get user's surname 2 (row[3]) */ /* Get user's surname 2 (row[3]) */
Str_Copy (UsrInList->Surname2 ,row[3],Usr_MAX_BYTES_NAME); Str_Copy (UsrInList->Surname2,row[3],
Usr_MAX_BYTES_NAME);
/* Get user's first name (row[4]) */ /* Get user's first name (row[4]) */
Str_Copy (UsrInList->FirstName,row[4],Usr_MAX_BYTES_NAME); Str_Copy (UsrInList->FirstName,row[4],
Usr_MAX_BYTES_NAME);
/* Get user's sex (row[5]) */ /* Get user's sex (row[5]) */
UsrInList->Sex = Usr_GetSexFromStr (row[5]); UsrInList->Sex = Usr_GetSexFromStr (row[5]);
@ -4787,9 +4810,12 @@ void Usr_CopyBasicUsrDataFromList (struct UsrData *UsrDat,const struct UsrInList
UsrDat->UsrCod = UsrInList->UsrCod; UsrDat->UsrCod = UsrInList->UsrCod;
Str_Copy (UsrDat->EncryptedUsrCod,UsrInList->EncryptedUsrCod, Str_Copy (UsrDat->EncryptedUsrCod,UsrInList->EncryptedUsrCod,
Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
Str_Copy (UsrDat->Surname1 ,UsrInList->Surname1 ,Usr_MAX_BYTES_NAME); Str_Copy (UsrDat->Surname1,UsrInList->Surname1,
Str_Copy (UsrDat->Surname2 ,UsrInList->Surname2 ,Usr_MAX_BYTES_NAME); Usr_MAX_BYTES_NAME);
Str_Copy (UsrDat->FirstName,UsrInList->FirstName,Usr_MAX_BYTES_NAME); Str_Copy (UsrDat->Surname2,UsrInList->Surname2,
Usr_MAX_BYTES_NAME);
Str_Copy (UsrDat->FirstName,UsrInList->FirstName,
Usr_MAX_BYTES_NAME);
UsrDat->Sex = UsrInList->Sex; UsrDat->Sex = UsrInList->Sex;
Str_Copy (UsrDat->Photo,UsrInList->Photo, Str_Copy (UsrDat->Photo,UsrInList->Photo,
Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
@ -5128,7 +5154,7 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs)
{ {
if (strlen (UsrDat.EncryptedUsrCod) < Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS) if (strlen (UsrDat.EncryptedUsrCod) < Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS)
Str_Copy (Gbl.Usrs.Select.All,UsrDat.EncryptedUsrCod, Str_Copy (Gbl.Usrs.Select.All,UsrDat.EncryptedUsrCod,
Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); // Add first user Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); // Add first user
} }
else // Not first user in list else // Not first user in list
{ {

View File

@ -53,9 +53,8 @@
#define Usr_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 12 #define Usr_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 12
#define Usr_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 60 #define Usr_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS 60
#define Usr_MAX_BYTES_USR_EMAIL (128-1) #define Usr_MAX_LENGTH_USR_LOGIN (128 - 1) // @nick, email or ID
#define Usr_MAX_LENGTH_USR_LOGIN (128-1) // @nick, email or ID #define Usr_MAX_BYTES_USR_LOGIN (128 - 1)
#define Usr_MAX_BYTES_USR_LOGIN (128-1)
#define Usr_MAX_LENGTH_USR_NAME_OR_SURNAME 32 #define Usr_MAX_LENGTH_USR_NAME_OR_SURNAME 32
#define Usr_MAX_BYTES_NAME 32 #define Usr_MAX_BYTES_NAME 32
@ -66,6 +65,8 @@
// Surname1 +' '+ Surname2 + ','+' ' + FirstName // Surname1 +' '+ Surname2 + ','+' ' + FirstName
// Surname1 +' '+ Surname2 + '<br />' + FirstName // Surname1 +' '+ Surname2 + '<br />' + FirstName
#define Usr_MAX_BYTES_USR_EMAIL (128 - 1)
#define Usr_BIRTHDAY_STR_DB_LENGTH (4+1+2+1+2) // "'%04u-%02u-%02u'" #define Usr_BIRTHDAY_STR_DB_LENGTH (4+1+2+1+2) // "'%04u-%02u-%02u'"
#define Usr_MAX_LENGTH_PHONE 16 #define Usr_MAX_LENGTH_PHONE 16

View File

@ -214,7 +214,7 @@ static int Svc_GetCurrentDegCodFromCurrentCrsCod (void);
static bool Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod); static bool Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod);
static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
char *NewNicknameWithoutArroba, // Output char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
char *NewEmail, // Input-output char *NewEmail, // Input-output
char *NewPlainPassword, // Input char *NewPlainPassword, // Input
char *NewEncryptedPassword); // Output char *NewEncryptedPassword); // Output
@ -553,12 +553,16 @@ static bool Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* Get user's name */ /* Get user's name */
Str_Copy (UsrDat->Surname1 ,row[0],Usr_MAX_BYTES_NAME); Str_Copy (UsrDat->Surname1,row[0],
Str_Copy (UsrDat->Surname2 ,row[1],Usr_MAX_BYTES_NAME); Usr_MAX_BYTES_NAME);
Str_Copy (UsrDat->FirstName,row[2],Usr_MAX_BYTES_NAME); Str_Copy (UsrDat->Surname2,row[1],
Usr_MAX_BYTES_NAME);
Str_Copy (UsrDat->FirstName,row[2],
Usr_MAX_BYTES_NAME);
/* Get user's photo */ /* Get user's photo */
Str_Copy (UsrDat->Photo,row[3],Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Str_Copy (UsrDat->Photo,row[3],
Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64);
/* Get user's brithday */ /* Get user's brithday */
Dat_GetDateFromYYYYMMDD (&(UsrDat->Birthday),row[4]); Dat_GetDateFromYYYYMMDD (&(UsrDat->Birthday),row[4]);
@ -637,8 +641,8 @@ int swad__createAccount (struct soap *soap,
char *userNickname,char *userEmail,char *userPassword,char *appKey, // input char *userNickname,char *userEmail,char *userPassword,char *appKey, // input
struct swad__createAccountOutput *createAccountOut) // output struct swad__createAccountOutput *createAccountOut) // output
{ {
char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
char NewEncryptedPassword[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64+1]; char NewEncryptedPassword[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64 + 1];
int Result; int Result;
int ReturnCode; int ReturnCode;
@ -690,7 +694,8 @@ int swad__createAccount (struct soap *soap,
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,userEmail)) if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,userEmail))
{ {
/* Email updated sucessfully */ /* Email updated sucessfully */
Str_Copy (Gbl.Usrs.Me.UsrDat.Email,userEmail,Usr_MAX_BYTES_USR_EMAIL); Str_Copy (Gbl.Usrs.Me.UsrDat.Email,userEmail,
Usr_MAX_BYTES_USR_EMAIL);
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false; Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
} }
@ -708,7 +713,7 @@ int swad__createAccount (struct soap *soap,
// Return false on error // Return false on error
//char *userNickname,char *userEmail,char *userID,char *userPassword //char *userNickname,char *userEmail,char *userID,char *userPassword
static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
char *NewNicknameWithoutArroba, // Output char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], // Output
char *NewEmail, // Input-output char *NewEmail, // Input-output
char *NewPlainPassword, // Input char *NewPlainPassword, // Input
char *NewEncryptedPassword) // Output char *NewEncryptedPassword) // Output
@ -718,7 +723,7 @@ static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
/***** Step 1/3: Check new nickname *****/ /***** Step 1/3: Check new nickname *****/
/* Make a copy without possible starting arrobas */ /* Make a copy without possible starting arrobas */
Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba, Str_Copy (NewNicknameWithoutArroba,NewNicknameWithArroba,
Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Nck_MAX_BYTES_NICKNAME_FROM_FORM);
if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid if (Nck_CheckIfNickWithArrobaIsValid (NewNicknameWithArroba)) // If new nickname is valid
{ {
/***** Remove arrobas at the beginning *****/ /***** Remove arrobas at the beginning *****/
@ -777,7 +782,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
/***** Allocate space for strings *****/ /***** Allocate space for strings *****/
loginByUserPasswordKeyOut->wsKey = (char *) soap_malloc (Gbl.soap,Svc_LENGTH_WS_KEY + 1); loginByUserPasswordKeyOut->wsKey = (char *) soap_malloc (Gbl.soap,Svc_LENGTH_WS_KEY + 1);
loginByUserPasswordKeyOut->userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA+1); loginByUserPasswordKeyOut->userNickname = (char *) soap_malloc (Gbl.soap,Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA + 1);
loginByUserPasswordKeyOut->userID = (char *) soap_malloc (Gbl.soap,ID_MAX_LENGTH_USR_ID + 1); loginByUserPasswordKeyOut->userID = (char *) soap_malloc (Gbl.soap,ID_MAX_LENGTH_USR_ID + 1);
loginByUserPasswordKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginByUserPasswordKeyOut->userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
loginByUserPasswordKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); loginByUserPasswordKeyOut->userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
@ -802,7 +807,8 @@ int swad__loginByUserPasswordKey (struct soap *soap,
return ReturnCode; return ReturnCode;
/***** Check if user's email, @nickname or ID are valid *****/ /***** Check if user's email, @nickname or ID are valid *****/
Str_Copy (UsrIDNickOrEmail,userID,Usr_MAX_BYTES_USR_LOGIN); Str_Copy (UsrIDNickOrEmail,userID,
Usr_MAX_BYTES_USR_LOGIN);
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
{ {
Str_RemoveLeadingArrobas (UsrIDNickOrEmail); Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
@ -877,20 +883,26 @@ int swad__loginByUserPasswordKey (struct soap *soap,
if (Gbl.Usrs.Me.UsrDat.IDs.Num) if (Gbl.Usrs.Me.UsrDat.IDs.Num)
Str_Copy (loginByUserPasswordKeyOut->userID, Str_Copy (loginByUserPasswordKeyOut->userID,
Gbl.Usrs.Me.UsrDat.IDs.List[0].ID,ID_MAX_LENGTH_USR_ID); // TODO: What user's ID? Gbl.Usrs.Me.UsrDat.IDs.List[0].ID, // TODO: What user's ID?
ID_MAX_LENGTH_USR_ID);
Str_Copy (loginByUserPasswordKeyOut->userSurname1, Str_Copy (loginByUserPasswordKeyOut->userSurname1,
Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME); Gbl.Usrs.Me.UsrDat.Surname1,
Usr_MAX_BYTES_NAME);
Str_Copy (loginByUserPasswordKeyOut->userSurname2, Str_Copy (loginByUserPasswordKeyOut->userSurname2,
Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_NAME); Gbl.Usrs.Me.UsrDat.Surname2,
Usr_MAX_BYTES_NAME);
Str_Copy (loginByUserPasswordKeyOut->userFirstname, Str_Copy (loginByUserPasswordKeyOut->userFirstname,
Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME); Gbl.Usrs.Me.UsrDat.FirstName,
Usr_MAX_BYTES_NAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
Str_Copy (loginByUserPasswordKeyOut->userPhoto,PhotoURL,Cns_MAX_LENGTH_WWW); Str_Copy (loginByUserPasswordKeyOut->userPhoto,PhotoURL,
Cns_MAX_LENGTH_WWW);
Str_Copy (loginByUserPasswordKeyOut->userBirthday, Str_Copy (loginByUserPasswordKeyOut->userBirthday,
Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,Dat_LENGTH_YYYYMMDD); Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,
Dat_LENGTH_YYYYMMDD);
loginByUserPasswordKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB]; loginByUserPasswordKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
@ -1020,7 +1032,7 @@ int swad__loginBySessionKey (struct soap *soap,
loginBySessionKeyOut->userCode = (int) Gbl.Usrs.Me.UsrDat.UsrCod; loginBySessionKeyOut->userCode = (int) Gbl.Usrs.Me.UsrDat.UsrCod;
Str_Copy (loginBySessionKeyOut->userNickname,Gbl.Usrs.Me.UsrDat.Nickname, Str_Copy (loginBySessionKeyOut->userNickname,Gbl.Usrs.Me.UsrDat.Nickname,
Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA); Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
if (Gbl.Usrs.Me.UsrDat.IDs.Num) if (Gbl.Usrs.Me.UsrDat.IDs.Num)
Str_Copy (loginBySessionKeyOut->userID, Str_Copy (loginBySessionKeyOut->userID,
@ -1028,17 +1040,22 @@ int swad__loginBySessionKey (struct soap *soap,
ID_MAX_LENGTH_USR_ID); ID_MAX_LENGTH_USR_ID);
Str_Copy (loginBySessionKeyOut->userSurname1, Str_Copy (loginBySessionKeyOut->userSurname1,
Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME); Gbl.Usrs.Me.UsrDat.Surname1,
Usr_MAX_BYTES_NAME);
Str_Copy (loginBySessionKeyOut->userSurname2, Str_Copy (loginBySessionKeyOut->userSurname2,
Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_NAME); Gbl.Usrs.Me.UsrDat.Surname2,
Usr_MAX_BYTES_NAME);
Str_Copy (loginBySessionKeyOut->userFirstname, Str_Copy (loginBySessionKeyOut->userFirstname,
Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME); Gbl.Usrs.Me.UsrDat.FirstName,
Usr_MAX_BYTES_NAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Me.UsrDat,PhotoURL);
Str_Copy (loginBySessionKeyOut->userPhoto,PhotoURL,Cns_MAX_LENGTH_WWW); Str_Copy (loginBySessionKeyOut->userPhoto,PhotoURL,
Cns_MAX_LENGTH_WWW);
Str_Copy (loginBySessionKeyOut->userBirthday, Str_Copy (loginBySessionKeyOut->userBirthday,
Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,Dat_LENGTH_YYYYMMDD); Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,
Dat_LENGTH_YYYYMMDD);
loginBySessionKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB]; loginBySessionKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
@ -1080,7 +1097,8 @@ int swad__getNewPassword (struct soap *soap,
return ReturnCode; return ReturnCode;
/***** Check if user's email, @nickname or ID are valid *****/ /***** Check if user's email, @nickname or ID are valid *****/
Str_Copy (UsrIDNickOrEmail,userID,Usr_MAX_BYTES_USR_LOGIN); Str_Copy (UsrIDNickOrEmail,userID,
Usr_MAX_BYTES_USR_LOGIN);
if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname if (Nck_CheckIfNickWithArrobaIsValid (UsrIDNickOrEmail)) // 1: It's a nickname
{ {
Str_RemoveLeadingArrobas (UsrIDNickOrEmail); Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
@ -1208,13 +1226,13 @@ int swad__getCourses (struct soap *soap,
/* Get course short name (row[1]) */ /* Get course short name (row[1]) */
getCoursesOut->coursesArray.__ptr[NumRow].courseShortName = (char *) soap_malloc (Gbl.soap,Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1); getCoursesOut->coursesArray.__ptr[NumRow].courseShortName = (char *) soap_malloc (Gbl.soap,Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1);
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName, Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseShortName,row[1],
row[1],Crs_MAX_LENGTH_COURSE_SHRT_NAME); Crs_MAX_LENGTH_COURSE_SHRT_NAME);
/* Get course full name (row[2]) */ /* Get course full name (row[2]) */
getCoursesOut->coursesArray.__ptr[NumRow].courseFullName = (char *) soap_malloc (Gbl.soap,Crs_MAX_LENGTH_COURSE_FULL_NAME + 1); getCoursesOut->coursesArray.__ptr[NumRow].courseFullName = (char *) soap_malloc (Gbl.soap,Crs_MAX_LENGTH_COURSE_FULL_NAME + 1);
Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName, Str_Copy (getCoursesOut->coursesArray.__ptr[NumRow].courseFullName,row[2],
row[2],Crs_MAX_LENGTH_COURSE_FULL_NAME); Crs_MAX_LENGTH_COURSE_FULL_NAME);
/* Get role (row[3]) */ /* Get role (row[3]) */
if (sscanf (row[3],"%u",&Role) != 1) // Role in this course if (sscanf (row[3],"%u",&Role) != 1) // Role in this course
@ -1311,7 +1329,8 @@ int swad__getCourseInfo (struct soap *soap,
Inf_GetAndCheckInfoSrcFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,&InfoSrc,&MustBeRead); Inf_GetAndCheckInfoSrcFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,&InfoSrc,&MustBeRead);
Length = strlen (NamesInWSForInfoSrc[InfoSrc]); Length = strlen (NamesInWSForInfoSrc[InfoSrc]);
getCourseInfo->infoSrc = (char *) soap_malloc (Gbl.soap,Length + 1); getCourseInfo->infoSrc = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getCourseInfo->infoSrc,NamesInWSForInfoSrc[InfoSrc],Length); Str_Copy (getCourseInfo->infoSrc,NamesInWSForInfoSrc[InfoSrc],
Length);
/***** Set paths *****/ /***** Set paths *****/
Hie_InitHierarchy (); Hie_InitHierarchy ();
@ -1495,7 +1514,8 @@ int swad__findUsers (struct soap *soap,
Role = Svc_SvcRole_to_RolRole[userRole]; Role = Svc_SvcRole_to_RolRole[userRole];
/***** Query users beloging to course or group from database *****/ /***** Query users beloging to course or group from database *****/
Str_Copy (Gbl.Search.Str,filter,Sch_MAX_LENGTH_STRING_TO_FIND); Str_Copy (Gbl.Search.Str,filter,
Sch_MAX_LENGTH_STRING_TO_FIND);
if (Gbl.Search.Str[0]) // Search some users if (Gbl.Search.Str[0]) // Search some users
{ {
@ -1670,8 +1690,8 @@ int swad__getGroupTypes (struct soap *soap,
/* Get group type name (row[1]) */ /* Get group type name (row[1]) */
getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1); getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1);
Str_Copy (getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName, Str_Copy (getGroupTypesOut->groupTypesArray.__ptr[NumRow].groupTypeName,row[1],
row[1],Grp_MAX_LENGTH_GROUP_TYPE_NAME); Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Get whether enrollment is mandatory ('Y') or voluntary ('N') (row[2]) */ /* Get whether enrollment is mandatory ('Y') or voluntary ('N') (row[2]) */
getGroupTypesOut->groupTypesArray.__ptr[NumRow].mandatory = (row[2][0] == 'Y') ? 1 : getGroupTypesOut->groupTypesArray.__ptr[NumRow].mandatory = (row[2][0] == 'Y') ? 1 :
@ -1781,8 +1801,8 @@ int swad__getGroups (struct soap *soap,
/* Get group type name (row[1]) */ /* Get group type name (row[1]) */
getGroupsOut->groupsArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1); getGroupsOut->groupsArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1);
Str_Copy (getGroupsOut->groupsArray.__ptr[NumRow].groupTypeName, Str_Copy (getGroupsOut->groupsArray.__ptr[NumRow].groupTypeName,row[1],
row[1],Grp_MAX_LENGTH_GROUP_TYPE_NAME); Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Get group code (row[2]) */ /* Get group code (row[2]) */
GrpCod = Str_ConvertStrCodToLongCod (row[2]); GrpCod = Str_ConvertStrCodToLongCod (row[2]);
@ -1790,8 +1810,8 @@ int swad__getGroups (struct soap *soap,
/* Get group name (row[3]) */ /* Get group name (row[3]) */
getGroupsOut->groupsArray.__ptr[NumRow].groupName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_NAME + 1); getGroupsOut->groupsArray.__ptr[NumRow].groupName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_NAME + 1);
Str_Copy (getGroupsOut->groupsArray.__ptr[NumRow].groupName, Str_Copy (getGroupsOut->groupsArray.__ptr[NumRow].groupName,row[3],
row[3],Grp_MAX_LENGTH_GROUP_NAME); Grp_MAX_LENGTH_GROUP_NAME);
/* Get max number of students of group (row[4]) and number of current students */ /* Get max number of students of group (row[4]) and number of current students */
MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[4]); MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[4]);
@ -1942,8 +1962,8 @@ int swad__sendMyGroups (struct soap *soap,
/* Get group type name (row[1]) */ /* Get group type name (row[1]) */
SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1); SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1);
Str_Copy (SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeName, Str_Copy (SendMyGroupsOut->groupsArray.__ptr[NumRow].groupTypeName,row[1],
row[1],Grp_MAX_LENGTH_GROUP_TYPE_NAME); Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Get group code (row[2]) */ /* Get group code (row[2]) */
GrpCod = Str_ConvertStrCodToLongCod (row[2]); GrpCod = Str_ConvertStrCodToLongCod (row[2]);
@ -1951,8 +1971,8 @@ int swad__sendMyGroups (struct soap *soap,
/* Get group name (row[3]) */ /* Get group name (row[3]) */
SendMyGroupsOut->groupsArray.__ptr[NumRow].groupName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_NAME + 1); SendMyGroupsOut->groupsArray.__ptr[NumRow].groupName = (char *) soap_malloc (Gbl.soap,Grp_MAX_LENGTH_GROUP_NAME + 1);
Str_Copy (SendMyGroupsOut->groupsArray.__ptr[NumRow].groupName, Str_Copy (SendMyGroupsOut->groupsArray.__ptr[NumRow].groupName,row[3],
row[3],Grp_MAX_LENGTH_GROUP_NAME); Grp_MAX_LENGTH_GROUP_NAME);
/* Get max number of students of group (row[4]) and number of current students */ /* Get max number of students of group (row[4]) and number of current students */
MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[4]); MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[4]);
@ -1998,7 +2018,8 @@ static void Svc_CopyUsrData (struct swad__user *Usr,struct UsrData *UsrDat,bool
/* Copy user's nickname */ /* Copy user's nickname */
Length = strlen (UsrDat->Nickname); Length = strlen (UsrDat->Nickname);
Usr->userNickname = (char *) soap_malloc (Gbl.soap,Length + 1); Usr->userNickname = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (Usr->userNickname,UsrDat->Nickname,Length); Str_Copy (Usr->userNickname,UsrDat->Nickname,
Length);
/* Copy user's first ID */ /* Copy user's first ID */
if (UsrIDIsVisible && UsrDat->IDs.List) if (UsrIDIsVisible && UsrDat->IDs.List)
@ -2007,28 +2028,33 @@ static void Svc_CopyUsrData (struct swad__user *Usr,struct UsrData *UsrDat,bool
FirstID = "********"; FirstID = "********";
Length = strlen (FirstID); Length = strlen (FirstID);
Usr->userID = (char *) soap_malloc (Gbl.soap,Length + 1); Usr->userID = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (Usr->userID,FirstID,Length); Str_Copy (Usr->userID,FirstID,
Length);
/* Copy user's surname1 */ /* Copy user's surname1 */
Length = strlen (UsrDat->Surname1); Length = strlen (UsrDat->Surname1);
Usr->userSurname1 = (char *) soap_malloc (Gbl.soap,Length + 1); Usr->userSurname1 = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (Usr->userSurname1,UsrDat->Surname1,Length); Str_Copy (Usr->userSurname1,UsrDat->Surname1,
Length);
/* Copy user's surname2 */ /* Copy user's surname2 */
Length = strlen (UsrDat->Surname2); Length = strlen (UsrDat->Surname2);
Usr->userSurname2 = (char *) soap_malloc (Gbl.soap,Length + 1); Usr->userSurname2 = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (Usr->userSurname2,UsrDat->Surname2,Length); Str_Copy (Usr->userSurname2,UsrDat->Surname2,
Length);
/* Copy user's first name */ /* Copy user's first name */
Length = strlen (UsrDat->FirstName); Length = strlen (UsrDat->FirstName);
Usr->userFirstname = (char *) soap_malloc (Gbl.soap,Length + 1); Usr->userFirstname = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (Usr->userFirstname,UsrDat->FirstName,Length); Str_Copy (Usr->userFirstname,UsrDat->FirstName,
Length);
/* User's photo URL */ /* User's photo URL */
Pho_BuildLinkToPhoto (UsrDat,PhotoURL); Pho_BuildLinkToPhoto (UsrDat,PhotoURL);
Length = strlen (PhotoURL); Length = strlen (PhotoURL);
Usr->userPhoto = (char *) soap_malloc (Gbl.soap,Length + 1); Usr->userPhoto = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (Usr->userPhoto,PhotoURL,Length); Str_Copy (Usr->userPhoto,PhotoURL,
Length);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2123,23 +2149,27 @@ int swad__getAttendanceEvents (struct soap *soap,
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname1); Length = strlen (Gbl.Usrs.Other.UsrDat.Surname1);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1 = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1 = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1, Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname1,
Gbl.Usrs.Other.UsrDat.Surname1,Length); Gbl.Usrs.Other.UsrDat.Surname1,
Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2); Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2 = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2 = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2, Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userSurname2,
Gbl.Usrs.Other.UsrDat.Surname2,Length); Gbl.Usrs.Other.UsrDat.Surname2,
Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName); Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname, Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userFirstname,
Gbl.Usrs.Other.UsrDat.FirstName,Length); Gbl.Usrs.Other.UsrDat.FirstName,
Length);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
Length = strlen (PhotoURL); Length = strlen (PhotoURL);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto, Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto,
PhotoURL,Length); PhotoURL,
Length);
} }
else else
{ {
@ -2168,14 +2198,14 @@ int swad__getAttendanceEvents (struct soap *soap,
/* Get title of the event (row[6]) */ /* Get title of the event (row[6]) */
Length = strlen (row[6]); Length = strlen (row[6]);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title, Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title,row[6],
row[6],Length); Length);
/* Get Txt (row[7]) */ /* Get Txt (row[7]) */
Length = strlen (row[7]); Length = strlen (row[7]);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text, Str_Copy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text,row[7],
row[7],Length); Length);
/* Get list of groups for this attendance event */ /* Get list of groups for this attendance event */
Svc_GetListGrpsInAttendanceEventFromDB (AttCod,&(getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].groups)); Svc_GetListGrpsInAttendanceEventFromDB (AttCod,&(getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].groups));
@ -2323,7 +2353,8 @@ int swad__sendAttendanceEvent (struct soap *soap,
return soap_receiver_fault (Gbl.soap, return soap_receiver_fault (Gbl.soap,
"Request forbidden", "Request forbidden",
"Title of attendance event is empty"); "Title of attendance event is empty");
Str_Copy (Att.Title,title,Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE); Str_Copy (Att.Title,title,
Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE);
/* Create a list of groups selected */ /* Create a list of groups selected */
Svc_GetLstGrpsSel (groups); Svc_GetLstGrpsSel (groups);
@ -2566,14 +2597,16 @@ int swad__getAttendanceUsers (struct soap *soap,
Length = strlen (Gbl.Usrs.Other.UsrDat.Nickname); Length = strlen (Gbl.Usrs.Other.UsrDat.Nickname);
getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname, Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userNickname,
Gbl.Usrs.Other.UsrDat.Nickname,Length); Gbl.Usrs.Other.UsrDat.Nickname,
Length);
if (Gbl.Usrs.Other.UsrDat.IDs.Num) if (Gbl.Usrs.Other.UsrDat.IDs.Num)
{ {
Length = strlen (Gbl.Usrs.Other.UsrDat.IDs.List[0].ID); // TODO: What user's ID? Length = strlen (Gbl.Usrs.Other.UsrDat.IDs.List[0].ID); // TODO: What user's ID?
getAttendanceUsersOut->usersArray.__ptr[NumRow].userID = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceUsersOut->usersArray.__ptr[NumRow].userID = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userID, Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userID,
Gbl.Usrs.Other.UsrDat.IDs.List[0].ID,Length); Gbl.Usrs.Other.UsrDat.IDs.List[0].ID,
Length);
} }
else else
{ {
@ -2584,23 +2617,27 @@ int swad__getAttendanceUsers (struct soap *soap,
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname1); Length = strlen (Gbl.Usrs.Other.UsrDat.Surname1);
getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1 = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1 = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1, Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname1,
Gbl.Usrs.Other.UsrDat.Surname1,Length); Gbl.Usrs.Other.UsrDat.Surname1,
Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2); Length = strlen (Gbl.Usrs.Other.UsrDat.Surname2);
getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2 = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2 = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2, Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userSurname2,
Gbl.Usrs.Other.UsrDat.Surname2,Length); Gbl.Usrs.Other.UsrDat.Surname2,
Length);
Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName); Length = strlen (Gbl.Usrs.Other.UsrDat.FirstName);
getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname, Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userFirstname,
Gbl.Usrs.Other.UsrDat.FirstName,Length); Gbl.Usrs.Other.UsrDat.FirstName,
Length);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
Length = strlen (PhotoURL); Length = strlen (PhotoURL);
getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto = (char *) soap_malloc (Gbl.soap,Length + 1); getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto, Str_Copy (getAttendanceUsersOut->usersArray.__ptr[NumRow].userPhoto,
PhotoURL,Length); PhotoURL,
Length);
} }
else else
{ {
@ -2835,7 +2872,8 @@ int swad__getNotifications (struct soap *soap,
NotifyEvent = Ntf_GetNotifyEventFromDB ((const char *) row[1]); NotifyEvent = Ntf_GetNotifyEventFromDB ((const char *) row[1]);
getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType = (char *) soap_malloc (Gbl.soap,Ntf_MAX_LENGTH_NOTIFY_EVENT + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType = (char *) soap_malloc (Gbl.soap,Ntf_MAX_LENGTH_NOTIFY_EVENT + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType, Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].eventType,
Ntf_WSNotifyEvents[NotifyEvent],Ntf_MAX_LENGTH_NOTIFY_EVENT); Ntf_WSNotifyEvents[NotifyEvent],
Ntf_MAX_LENGTH_NOTIFY_EVENT);
/* Get time of the event (row[2]) */ /* Get time of the event (row[2]) */
EventTime = 0L; EventTime = 0L;
@ -2859,20 +2897,24 @@ int swad__getNotifications (struct soap *soap,
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1, Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname1,
Gbl.Usrs.Other.UsrDat.Surname1 ,Usr_MAX_BYTES_NAME); Gbl.Usrs.Other.UsrDat.Surname1,
Usr_MAX_BYTES_NAME);
getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2 = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2, Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userSurname2,
Gbl.Usrs.Other.UsrDat.Surname2 ,Usr_MAX_BYTES_NAME); Gbl.Usrs.Other.UsrDat.Surname2,
Usr_MAX_BYTES_NAME);
getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname = (char *) soap_malloc (Gbl.soap,Usr_MAX_BYTES_NAME + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname, Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userFirstname,
Gbl.Usrs.Other.UsrDat.FirstName,Usr_MAX_BYTES_NAME); Gbl.Usrs.Other.UsrDat.FirstName,
Usr_MAX_BYTES_NAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto = (char *) soap_malloc (Gbl.soap,Cns_MAX_LENGTH_WWW + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto = (char *) soap_malloc (Gbl.soap,Cns_MAX_LENGTH_WWW + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto, Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].userPhoto,
PhotoURL,Cns_MAX_LENGTH_WWW); PhotoURL,
Cns_MAX_LENGTH_WWW);
} }
else else
{ {
@ -2927,8 +2969,8 @@ int swad__getNotifications (struct soap *soap,
sprintf (getNotificationsOut->notificationsArray.__ptr[NumNotif].location,"%s: %s", sprintf (getNotificationsOut->notificationsArray.__ptr[NumNotif].location,"%s: %s",
Txt_Institution,Ins.ShrtName); Txt_Institution,Ins.ShrtName);
else else
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].location, Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].location,"-",
"-",Ntf_MAX_LENGTH_NOTIFY_LOCATION); Ntf_MAX_LENGTH_NOTIFY_LOCATION);
/* Get status (row[9]) */ /* Get status (row[9]) */
if (sscanf (row[9],"%u",&Status) != 1) if (sscanf (row[9],"%u",&Status) != 1)
@ -2944,7 +2986,8 @@ int swad__getNotifications (struct soap *soap,
Length = strlen (SummaryStr); Length = strlen (SummaryStr);
getNotificationsOut->notificationsArray.__ptr[NumNotif].summary = (char *) soap_malloc (Gbl.soap,Length + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].summary = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].summary, Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].summary,
SummaryStr,Length); SummaryStr,
Length);
if (ContentStr == NULL) if (ContentStr == NULL)
{ {
@ -2956,7 +2999,8 @@ int swad__getNotifications (struct soap *soap,
Length = strlen (ContentStr); Length = strlen (ContentStr);
getNotificationsOut->notificationsArray.__ptr[NumNotif].content = (char *) soap_malloc (Gbl.soap,Length + 1); getNotificationsOut->notificationsArray.__ptr[NumNotif].content = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].content, Str_Copy (getNotificationsOut->notificationsArray.__ptr[NumNotif].content,
ContentStr,Length); ContentStr,
Length);
/* Free memory used by content string */ /* Free memory used by content string */
free ((void *) ContentStr); free ((void *) ContentStr);
@ -3097,7 +3141,7 @@ int swad__sendMessage (struct soap *soap,
{ {
int ReturnCode; int ReturnCode;
long ReplyUsrCod = -1L; long ReplyUsrCod = -1L;
char Nickname[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; char Nickname[Nck_MAX_BYTES_NICKNAME_FROM_FORM+1];
char Query[Svc_MAX_LENGTH_QUERY_RECIPIENTS + 1]; char Query[Svc_MAX_LENGTH_QUERY_RECIPIENTS + 1];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
@ -3195,7 +3239,7 @@ int swad__sendMessage (struct soap *soap,
while (*Ptr) while (*Ptr)
{ {
/* Find next string in text until comma (leading and trailing spaces are removed) */ /* Find next string in text until comma (leading and trailing spaces are removed) */
Str_GetNextStringUntilComma (&Ptr,Nickname,Nck_MAX_BYTES_NICKNAME_WITH_ARROBA); Str_GetNextStringUntilComma (&Ptr,Nickname,Nck_MAX_BYTES_NICKNAME_FROM_FORM);
/* Check if string is a valid nickname */ /* Check if string is a valid nickname */
if (Nck_CheckIfNickWithArrobaIsValid (Nickname)) // String is a nickname? if (Nck_CheckIfNickWithArrobaIsValid (Nickname)) // String is a nickname?
@ -3749,7 +3793,8 @@ static int Svc_GetTstQuestions (long CrsCod,long BeginTime,struct swad__getTests
AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
getTestsOut->questionsArray.__ptr[NumRow].answerType = (char *) soap_malloc (Gbl.soap,Tst_MAX_LENGTH_ANSWER_TYPE + 1); getTestsOut->questionsArray.__ptr[NumRow].answerType = (char *) soap_malloc (Gbl.soap,Tst_MAX_LENGTH_ANSWER_TYPE + 1);
Str_Copy (getTestsOut->questionsArray.__ptr[NumRow].answerType, Str_Copy (getTestsOut->questionsArray.__ptr[NumRow].answerType,
Tst_StrAnswerTypesXML[AnswerType],Tst_MAX_LENGTH_ANSWER_TYPE); Tst_StrAnswerTypesXML[AnswerType],
Tst_MAX_LENGTH_ANSWER_TYPE);
/* Get shuffle (row[2]) */ /* Get shuffle (row[2]) */
getTestsOut->questionsArray.__ptr[NumRow].shuffle = (row[2][0] == 'Y') ? 1 : getTestsOut->questionsArray.__ptr[NumRow].shuffle = (row[2][0] == 'Y') ? 1 :
@ -3842,13 +3887,13 @@ static int Svc_GetTstAnswers (long CrsCod,long BeginTime,struct swad__getTestsOu
/* Get answer (row[3]) */ /* Get answer (row[3]) */
getTestsOut->answersArray.__ptr[NumRow].answerText = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1); getTestsOut->answersArray.__ptr[NumRow].answerText = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerText, Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerText,row[3],
row[3],Cns_MAX_BYTES_TEXT); Cns_MAX_BYTES_TEXT);
/* Get feedback (row[4]) */ /* Get feedback (row[4]) */
getTestsOut->answersArray.__ptr[NumRow].answerFeedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1); getTestsOut->answersArray.__ptr[NumRow].answerFeedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerFeedback, Str_Copy (getTestsOut->answersArray.__ptr[NumRow].answerFeedback,row[4],
row[4],Cns_MAX_BYTES_TEXT); Cns_MAX_BYTES_TEXT);
} }
} }
@ -4077,7 +4122,8 @@ int swad__getTrivialQuestion (struct soap *soap,
AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
getTrivialQuestionOut->question.answerType = (char *) soap_malloc (Gbl.soap,Tst_MAX_LENGTH_ANSWER_TYPE + 1); getTrivialQuestionOut->question.answerType = (char *) soap_malloc (Gbl.soap,Tst_MAX_LENGTH_ANSWER_TYPE + 1);
Str_Copy (getTrivialQuestionOut->question.answerType, Str_Copy (getTrivialQuestionOut->question.answerType,
Tst_StrAnswerTypesXML[AnswerType],Tst_MAX_LENGTH_ANSWER_TYPE); Tst_StrAnswerTypesXML[AnswerType],
Tst_MAX_LENGTH_ANSWER_TYPE);
/* Get shuffle (row[2]) */ /* Get shuffle (row[2]) */
getTrivialQuestionOut->question.shuffle = (row[2][0] == 'Y') ? 1 : getTrivialQuestionOut->question.shuffle = (row[2][0] == 'Y') ? 1 :
@ -4157,13 +4203,13 @@ int swad__getTrivialQuestion (struct soap *soap,
/* Get answer (row[3]) */ /* Get answer (row[3]) */
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1); getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText, Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerText,row[3],
row[3],Cns_MAX_BYTES_TEXT); Cns_MAX_BYTES_TEXT);
/* Get feedback (row[4]) */ /* Get feedback (row[4]) */
getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1); getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback = (char *) soap_malloc (Gbl.soap,Cns_MAX_BYTES_TEXT + 1);
Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback, Str_Copy (getTrivialQuestionOut->answersArray.__ptr[NumRow].answerFeedback,row[4],
row[4],Cns_MAX_BYTES_TEXT); Cns_MAX_BYTES_TEXT);
} }
} }
@ -4589,9 +4635,11 @@ int swad__getFile (struct soap *soap,
URL); URL);
/***** Copy data into output structure *****/ /***** Copy data into output structure *****/
Str_Copy (getFileOut->fileName,FileMetadata.FilFolLnkName,NAME_MAX); Str_Copy (getFileOut->fileName,FileMetadata.FilFolLnkName,
NAME_MAX);
Str_Copy (getFileOut->URL,URL,Cns_MAX_LENGTH_WWW); Str_Copy (getFileOut->URL,URL,
Cns_MAX_LENGTH_WWW);
getFileOut->size = (int) FileMetadata.Size; getFileOut->size = (int) FileMetadata.Size;
@ -4609,7 +4657,8 @@ int swad__getFile (struct soap *soap,
Usr_MAX_BYTES_FULL_NAME); Usr_MAX_BYTES_FULL_NAME);
Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL); Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
Str_Copy (getFileOut->publisherPhoto,PhotoURL,Cns_MAX_LENGTH_WWW); Str_Copy (getFileOut->publisherPhoto,PhotoURL,
Cns_MAX_LENGTH_WWW);
} }
return SOAP_OK; return SOAP_OK;
@ -4697,7 +4746,8 @@ int swad__getMarks (struct soap *soap,
{ {
Length = strlen (ContentStr); Length = strlen (ContentStr);
getMarksOut->content = (char *) soap_malloc (Gbl.soap,Length + 1); getMarksOut->content = (char *) soap_malloc (Gbl.soap,Length + 1);
Str_Copy (getMarksOut->content,ContentStr,Length); Str_Copy (getMarksOut->content,ContentStr,
Length);
free ((void *) ContentStr); free ((void *) ContentStr);
ContentStr = NULL; ContentStr = NULL;
} }

View File

@ -178,9 +178,10 @@ static void XML_GetElement (struct XMLElement *ParentElem)
/* Copy content */ /* Copy content */
if (ContentLength) if (ContentLength)
{ {
if ((ParentElem->Content = malloc (ContentLength+1)) == NULL) if ((ParentElem->Content = malloc (ContentLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory."); Lay_ShowErrorAndExit ("Not enough memory.");
Str_Copy (ParentElem->Content,StartContent,ContentLength); strncpy (ParentElem->Content,StartContent,ContentLength);
ParentElem->Content[ContentLength] = '\0';
ParentElem->ContentLength = ContentLength; ParentElem->ContentLength = ContentLength;
} }
@ -214,9 +215,10 @@ static void XML_GetElement (struct XMLElement *ParentElem)
/***** Get child tag name *****/ /***** Get child tag name *****/
ChildElem->TagNameLength = strcspn (Gbl.XMLPtr,">/ \t"); ChildElem->TagNameLength = strcspn (Gbl.XMLPtr,">/ \t");
if ((ChildElem->TagName = malloc (ChildElem->TagNameLength+1)) == NULL) if ((ChildElem->TagName = malloc (ChildElem->TagNameLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory."); Lay_ShowErrorAndExit ("Not enough memory.");
Str_Copy (ChildElem->TagName,Gbl.XMLPtr,ChildElem->TagNameLength); strncpy (ChildElem->TagName,Gbl.XMLPtr,ChildElem->TagNameLength);
ChildElem->TagName[ChildElem->TagNameLength] = '\0';
Gbl.XMLPtr += ChildElem->TagNameLength; Gbl.XMLPtr += ChildElem->TagNameLength;
/* /*
@ -333,9 +335,10 @@ static void XML_GetAttributes (struct XMLElement *Elem)
/***** Get attribute name *****/ /***** Get attribute name *****/
Attribute->AttributeNameLength = strcspn (Gbl.XMLPtr,"="); Attribute->AttributeNameLength = strcspn (Gbl.XMLPtr,"=");
if ((Attribute->AttributeName = malloc (Attribute->AttributeNameLength+1)) == NULL) if ((Attribute->AttributeName = malloc (Attribute->AttributeNameLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory."); Lay_ShowErrorAndExit ("Not enough memory.");
Str_Copy (Attribute->AttributeName,Gbl.XMLPtr,Attribute->AttributeNameLength); strncpy (Attribute->AttributeName,Gbl.XMLPtr,Attribute->AttributeNameLength);
Attribute->AttributeName[Attribute->AttributeNameLength] = '\0';
Gbl.XMLPtr += Attribute->AttributeNameLength; Gbl.XMLPtr += Attribute->AttributeNameLength;
/* End of attribute name: /* End of attribute name:
<parent><child attribute1="value" attribute2="value">...</child>...</parent> <parent><child attribute1="value" attribute2="value">...</child>...</parent>
@ -362,9 +365,10 @@ static void XML_GetAttributes (struct XMLElement *Elem)
Lay_ShowErrorAndExit (Gbl.Message); Lay_ShowErrorAndExit (Gbl.Message);
} }
if ((Attribute->Content = malloc (Attribute->ContentLength+1)) == NULL) if ((Attribute->Content = malloc (Attribute->ContentLength + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory."); Lay_ShowErrorAndExit ("Not enough memory.");
Str_Copy (Attribute->Content,Gbl.XMLPtr,Attribute->ContentLength); strncpy (Attribute->Content,Gbl.XMLPtr,Attribute->ContentLength);
Attribute->Content[Attribute->ContentLength] = '\0';
Gbl.XMLPtr += Attribute->ContentLength; Gbl.XMLPtr += Attribute->ContentLength;
Gbl.XMLPtr++; Gbl.XMLPtr++;

View File

@ -272,7 +272,8 @@ static void ZIP_CreateTmpDirForCompression (void)
Fil_RemoveOldTmpFiles (PathZipPriv,Cfg_TIME_TO_DELETE_BROWSER_ZIP_FILES,false); Fil_RemoveOldTmpFiles (PathZipPriv,Cfg_TIME_TO_DELETE_BROWSER_ZIP_FILES,false);
/***** Create a new temporary directory *****/ /***** Create a new temporary directory *****/
Str_Copy (Gbl.FileBrowser.ZIP.TmpDir,Gbl.UniqueNameEncrypted,NAME_MAX); Str_Copy (Gbl.FileBrowser.ZIP.TmpDir,Gbl.UniqueNameEncrypted,
NAME_MAX);
sprintf (PathDirTmp,"%s/%s",PathZipPriv,Gbl.FileBrowser.ZIP.TmpDir); sprintf (PathDirTmp,"%s/%s",PathZipPriv,Gbl.FileBrowser.ZIP.TmpDir);
if (mkdir (PathDirTmp,(mode_t) 0xFFF)) if (mkdir (PathDirTmp,(mode_t) 0xFFF))
Lay_ShowErrorAndExit ("Can not create temporary folder for compression."); Lay_ShowErrorAndExit ("Can not create temporary folder for compression.");
@ -298,7 +299,8 @@ static void ZIP_CreateDirCompressionUsr (struct UsrData *UsrDat)
with a name that identifies the owner with a name that identifies the owner
of the assignments and works *****/ of the assignments and works *****/
/* Create link name for this user */ /* Create link name for this user */
Str_Copy (FullNameAndUsrID,UsrDat->Surname1,ZIP_MAX_LENGTH_FULL_NAME_AND_ID); Str_Copy (FullNameAndUsrID,UsrDat->Surname1,
ZIP_MAX_LENGTH_FULL_NAME_AND_ID);
if (UsrDat->Surname1[0] && if (UsrDat->Surname1[0] &&
UsrDat->Surname2[0]) UsrDat->Surname2[0])
Str_Concat (FullNameAndUsrID,"_",ZIP_MAX_LENGTH_FULL_NAME_AND_ID); // Separation between surname 1 and surname 2 Str_Concat (FullNameAndUsrID,"_",ZIP_MAX_LENGTH_FULL_NAME_AND_ID); // Separation between surname 1 and surname 2
@ -602,7 +604,8 @@ static void ZIP_ShowLinkToDownloadZIP (const char *FileName,const char *URL,
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1]; char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING + 1];
/***** Limit length of the name of the file *****/ /***** Limit length of the name of the file *****/
Str_Copy (FileNameShort,FileName,NAME_MAX); Str_Copy (FileNameShort,FileName,
NAME_MAX);
Str_LimitLengthHTMLStr (FileNameShort,50); Str_LimitLengthHTMLStr (FileNameShort,50);
/***** Start frame *****/ /***** Start frame *****/